fix: let team members correct handshake contracts
This commit is contained in:
parent
f4977ee9f7
commit
1340927b73
2 changed files with 69 additions and 10 deletions
|
|
@ -88,6 +88,7 @@ async function modelAcknowledge({
|
|||
config,
|
||||
identity,
|
||||
challenge,
|
||||
validatorError = null,
|
||||
fetchImpl = globalThis.fetch,
|
||||
}) {
|
||||
const response = await fetchImpl(completionEndpoint(config.apiUrl), {
|
||||
|
|
@ -121,6 +122,7 @@ async function modelAcknowledge({
|
|||
caller_nonce: challenge.caller_nonce,
|
||||
role_acknowledged: true,
|
||||
},
|
||||
validator_error_from_previous_attempt: validatorError,
|
||||
scoped_duties: challenge.scoped_duties,
|
||||
identity_source: identity,
|
||||
}),
|
||||
|
|
@ -213,16 +215,27 @@ function createMemberRuntime(config, options = {}) {
|
|||
) {
|
||||
throw new Error("invalid_team_scope");
|
||||
}
|
||||
const acknowledgement = validateAcknowledgement(
|
||||
await modelAcknowledge({
|
||||
config,
|
||||
identity,
|
||||
challenge,
|
||||
fetchImpl: options.fetchImpl,
|
||||
}),
|
||||
config,
|
||||
challenge,
|
||||
);
|
||||
let acknowledgement = null;
|
||||
let validatorError = null;
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
try {
|
||||
acknowledgement = validateAcknowledgement(
|
||||
await modelAcknowledge({
|
||||
config,
|
||||
identity,
|
||||
challenge,
|
||||
validatorError,
|
||||
fetchImpl: options.fetchImpl,
|
||||
}),
|
||||
config,
|
||||
challenge,
|
||||
);
|
||||
break;
|
||||
} catch (error) {
|
||||
validatorError = String(error.message || error).slice(0, 200);
|
||||
if (attempt === 3) throw error;
|
||||
}
|
||||
}
|
||||
const payload = {
|
||||
schema: "guanghu.persona-team-member-handshake-payload/v1",
|
||||
persona_id: config.personaId,
|
||||
|
|
|
|||
Loading…
Reference in a new issue