@verana-labs/credo-ts-didcomm-vt-flow 2.0.0-dev.70 → 2.0.0-dev.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/VtFlowApi.d.ts +5 -1
- package/build/VtFlowApi.js +76 -7
- package/build/VtFlowApi.js.map +1 -1
- package/build/VtFlowModule.js +10 -5
- package/build/VtFlowModule.js.map +1 -1
- package/build/VtFlowModuleConfig.d.ts +18 -0
- package/build/VtFlowModuleConfig.js +6 -0
- package/build/VtFlowModuleConfig.js.map +1 -1
- package/build/errors/VtFlowErrorCode.d.ts +6 -0
- package/build/errors/VtFlowErrorCode.js +10 -1
- package/build/errors/VtFlowErrorCode.js.map +1 -1
- package/build/errors/buildVtFlowProblemReport.d.ts +1 -0
- package/build/errors/buildVtFlowProblemReport.js +1 -0
- package/build/errors/buildVtFlowProblemReport.js.map +1 -1
- package/build/errors/index.d.ts +2 -2
- package/build/errors/index.js +3 -1
- package/build/errors/index.js.map +1 -1
- package/build/handlers/IssuanceRequestHandler.d.ts +2 -1
- package/build/handlers/IssuanceRequestHandler.js +11 -2
- package/build/handlers/IssuanceRequestHandler.js.map +1 -1
- package/build/handlers/OnboardingRequestHandler.d.ts +2 -1
- package/build/handlers/OnboardingRequestHandler.js +11 -2
- package/build/handlers/OnboardingRequestHandler.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/repository/VtFlowRecord.d.ts +4 -0
- package/build/repository/VtFlowRecord.js +1 -0
- package/build/repository/VtFlowRecord.js.map +1 -1
- package/build/services/VtFlowService.d.ts +12 -5
- package/build/services/VtFlowService.js +171 -57
- package/build/services/VtFlowService.js.map +1 -1
- package/build/types.d.ts +7 -2
- package/build/types.js +11 -0
- package/build/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OnboardingRequestHandler = void 0;
|
|
4
|
+
const didcomm_1 = require("@credo-ts/didcomm");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
4
6
|
const messages_1 = require("../messages");
|
|
5
7
|
/** Validator-side inbound handler for `onboarding-request`; delegates to `VtFlowService.processReceiveOnboardingRequest`. */
|
|
6
8
|
class OnboardingRequestHandler {
|
|
@@ -9,8 +11,15 @@ class OnboardingRequestHandler {
|
|
|
9
11
|
this.supportedMessages = [messages_1.OnboardingRequestMessage];
|
|
10
12
|
}
|
|
11
13
|
async handle(messageContext) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
try {
|
|
15
|
+
await this.vtFlowService.processReceiveOnboardingRequest(messageContext);
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (!(error instanceof errors_1.VtFlowError))
|
|
20
|
+
throw error;
|
|
21
|
+
return new didcomm_1.DidCommOutboundMessageContext((0, errors_1.buildVtFlowProblemReport)({ code: error.code, threadId: messageContext.message.threadId }), { agentContext: messageContext.agentContext, connection: messageContext.assertReadyConnection() });
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
exports.OnboardingRequestHandler = OnboardingRequestHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingRequestHandler.js","sourceRoot":"","sources":["../../src/handlers/OnboardingRequestHandler.ts"],"names":[],"mappings":";;;AAGA,0CAAsD;AAEtD,6HAA6H;AAC7H,MAAa,wBAAwB;IAGnC,YAAoC,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAFzD,sBAAiB,GAAG,CAAC,mCAAwB,CAAC,CAAA;IAEc,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,cAA6E;QAC/F,MAAM,IAAI,CAAC,aAAa,CAAC,+BAA+B,CAAC,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"OnboardingRequestHandler.js","sourceRoot":"","sources":["../../src/handlers/OnboardingRequestHandler.ts"],"names":[],"mappings":";;;AAGA,+CAAiE;AAEjE,sCAAiE;AACjE,0CAAsD;AAEtD,6HAA6H;AAC7H,MAAa,wBAAwB;IAGnC,YAAoC,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAFzD,sBAAiB,GAAG,CAAC,mCAAwB,CAAC,CAAA;IAEc,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,cAA6E;QAC/F,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,aAAa,CAAC,+BAA+B,CAAC,cAAc,CAAC,CAAA;YACxE,OAAO,SAAS,CAAA;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,oBAAW,CAAC;gBAAE,MAAM,KAAK,CAAA;YAChD,OAAO,IAAI,uCAA6B,CACtC,IAAA,iCAAwB,EAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EACzF,EAAE,YAAY,EAAE,cAAc,CAAC,YAAY,EAAE,UAAU,EAAE,cAAc,CAAC,qBAAqB,EAAE,EAAE,CAClG,CAAA;QACH,CAAC;IACH,CAAC;CACF;AAjBD,4DAiBC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { VtFlowEventTypes, VtFlowMessageType, VtFlowPendingAction, VtFlowRole, VtFlowState, VtFlowSubmission, VtFlowTerminalStates, VtFlowTxReason, VtFlowTxStatus, VtFlowValidatedFromStates, VtFlowVariant, isVtFlowTerminalState, } from './types';
|
|
1
|
+
export { VtFlowEventTypes, VtFlowMessageType, VtFlowPendingAction, VtFlowRole, VtFlowState, VtFlowSubmission, VtFlowTerminalStates, VtFlowTxReason, VtFlowTxStatus, VtFlowValidatedFromStates, VtFlowVariant, isVtFlowRenewable, isVtFlowTerminalState, } from './types';
|
|
2
2
|
export type { NotifyCredentialStateChangeOptions, VtFlowIssuance, VtFlowMessage, VtFlowOobLink, VtFlowTx, VtFlowValidation, OfferCredentialForSessionOptions, ProblemReportDispatchOptions, ResendOnboardingRequestOptions, SendIssuanceRequestOptions, SendOnboardingRequestOptions, SendOobLinkOptions, VtFlowStateChangedEvent, } from './types';
|
|
3
3
|
export { VT_FLOW_PROTOCOL_URI, VT_FLOW_ONBOARDING_REQUEST_TYPE, VT_FLOW_ISSUANCE_REQUEST_TYPE, VT_FLOW_OOB_LINK_TYPE, VT_FLOW_VALIDATING_TYPE, VT_FLOW_CREDENTIAL_STATE_CHANGE_TYPE, OnboardingRequestMessage, IssuanceRequestMessage, OobLinkMessage, ValidatingMessage, CredentialStateChangeMessage, VtCredentialState, } from './messages';
|
|
4
4
|
export type { OnboardingRequestMessageOptions, IssuanceRequestMessageOptions, OobLinkMessageOptions, ValidatingMessageOptions, CredentialStateChangeMessageOptions, } from './messages';
|
|
@@ -11,6 +11,6 @@ export type { CreateIssuanceRequestParams, CreateOnboardingRequestParams } from
|
|
|
11
11
|
export { peerAnchorDid } from './utils';
|
|
12
12
|
export { CredentialStateChangeHandler, IssuanceRequestHandler, OnboardingRequestHandler, OobLinkHandler, ValidatingHandler, } from './handlers';
|
|
13
13
|
export { DEFAULT_DATA_INTEGRITY_CRYPTOSUITE, VtFlowModuleConfig } from './VtFlowModuleConfig';
|
|
14
|
-
export type { VtFlowAssertVerifiableServiceContext, VtFlowAssertVerifiableServiceHook, VtFlowBuildCredentialOfferContext, VtFlowBuildCredentialOfferHook, VtFlowCredentialLifecycleContext, VtFlowCredentialOfferPayload, VtFlowModuleConfigOptions, VtFlowOnCompletedHook, VtFlowRequestPurpose, VtFlowEcsIssuanceExemptionContext, VtFlowEcsIssuanceExemptionHook, VtFlowVerifyCredentialHook, } from './VtFlowModuleConfig';
|
|
14
|
+
export type { VtFlowAssertVerifiableServiceContext, VtFlowAssertVerifiableServiceHook, VtFlowBuildCredentialOfferContext, VtFlowBuildCredentialOfferHook, VtFlowCheckParticipantIdContext, VtFlowCheckParticipantIdHook, VtFlowCredentialLifecycleContext, VtFlowCredentialOfferPayload, VtFlowModuleConfigOptions, VtFlowOnCompletedHook, VtFlowRequestPurpose, VtFlowEcsIssuanceExemptionContext, VtFlowEcsIssuanceExemptionHook, VtFlowVerifyCredentialHook, } from './VtFlowModuleConfig';
|
|
15
15
|
export { VtFlowModule } from './VtFlowModule';
|
|
16
16
|
export { VtFlowApi } from './VtFlowApi';
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VtFlowApi = exports.VtFlowModule = exports.VtFlowModuleConfig = exports.DEFAULT_DATA_INTEGRITY_CRYPTOSUITE = exports.ValidatingHandler = exports.OobLinkHandler = exports.OnboardingRequestHandler = exports.IssuanceRequestHandler = exports.CredentialStateChangeHandler = exports.peerAnchorDid = exports.VtFlowService = exports.VtFlowRepository = exports.VtFlowRecord = exports.isVtFlowErrorCode = exports.buildVtFlowProblemReport = exports.VtFlowErrorCode = exports.VT_FLOW_ERROR_INFO = exports.VtCredentialState = exports.CredentialStateChangeMessage = exports.ValidatingMessage = exports.OobLinkMessage = exports.IssuanceRequestMessage = exports.OnboardingRequestMessage = exports.VT_FLOW_CREDENTIAL_STATE_CHANGE_TYPE = exports.VT_FLOW_VALIDATING_TYPE = exports.VT_FLOW_OOB_LINK_TYPE = exports.VT_FLOW_ISSUANCE_REQUEST_TYPE = exports.VT_FLOW_ONBOARDING_REQUEST_TYPE = exports.VT_FLOW_PROTOCOL_URI = exports.isVtFlowTerminalState = exports.VtFlowVariant = exports.VtFlowValidatedFromStates = exports.VtFlowTxStatus = exports.VtFlowTxReason = exports.VtFlowTerminalStates = exports.VtFlowSubmission = exports.VtFlowState = exports.VtFlowRole = exports.VtFlowPendingAction = exports.VtFlowMessageType = exports.VtFlowEventTypes = void 0;
|
|
3
|
+
exports.VtFlowApi = exports.VtFlowModule = exports.VtFlowModuleConfig = exports.DEFAULT_DATA_INTEGRITY_CRYPTOSUITE = exports.ValidatingHandler = exports.OobLinkHandler = exports.OnboardingRequestHandler = exports.IssuanceRequestHandler = exports.CredentialStateChangeHandler = exports.peerAnchorDid = exports.VtFlowService = exports.VtFlowRepository = exports.VtFlowRecord = exports.isVtFlowErrorCode = exports.buildVtFlowProblemReport = exports.VtFlowErrorCode = exports.VT_FLOW_ERROR_INFO = exports.VtCredentialState = exports.CredentialStateChangeMessage = exports.ValidatingMessage = exports.OobLinkMessage = exports.IssuanceRequestMessage = exports.OnboardingRequestMessage = exports.VT_FLOW_CREDENTIAL_STATE_CHANGE_TYPE = exports.VT_FLOW_VALIDATING_TYPE = exports.VT_FLOW_OOB_LINK_TYPE = exports.VT_FLOW_ISSUANCE_REQUEST_TYPE = exports.VT_FLOW_ONBOARDING_REQUEST_TYPE = exports.VT_FLOW_PROTOCOL_URI = exports.isVtFlowTerminalState = exports.isVtFlowRenewable = exports.VtFlowVariant = exports.VtFlowValidatedFromStates = exports.VtFlowTxStatus = exports.VtFlowTxReason = exports.VtFlowTerminalStates = exports.VtFlowSubmission = exports.VtFlowState = exports.VtFlowRole = exports.VtFlowPendingAction = exports.VtFlowMessageType = exports.VtFlowEventTypes = void 0;
|
|
4
4
|
// Types: enums, events, API option interfaces
|
|
5
5
|
var types_1 = require("./types");
|
|
6
6
|
Object.defineProperty(exports, "VtFlowEventTypes", { enumerable: true, get: function () { return types_1.VtFlowEventTypes; } });
|
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "VtFlowTxReason", { enumerable: true, get: functi
|
|
|
14
14
|
Object.defineProperty(exports, "VtFlowTxStatus", { enumerable: true, get: function () { return types_1.VtFlowTxStatus; } });
|
|
15
15
|
Object.defineProperty(exports, "VtFlowValidatedFromStates", { enumerable: true, get: function () { return types_1.VtFlowValidatedFromStates; } });
|
|
16
16
|
Object.defineProperty(exports, "VtFlowVariant", { enumerable: true, get: function () { return types_1.VtFlowVariant; } });
|
|
17
|
+
Object.defineProperty(exports, "isVtFlowRenewable", { enumerable: true, get: function () { return types_1.isVtFlowRenewable; } });
|
|
17
18
|
Object.defineProperty(exports, "isVtFlowTerminalState", { enumerable: true, get: function () { return types_1.isVtFlowTerminalState; } });
|
|
18
19
|
// Wire messages
|
|
19
20
|
var messages_1 = require("./messages");
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,iCAcgB;AAbd,yGAAA,gBAAgB,OAAA;AAChB,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA;AACnB,mGAAA,UAAU,OAAA;AACV,oGAAA,WAAW,OAAA;AACX,yGAAA,gBAAgB,OAAA;AAChB,6GAAA,oBAAoB,OAAA;AACpB,uGAAA,cAAc,OAAA;AACd,uGAAA,cAAc,OAAA;AACd,kHAAA,yBAAyB,OAAA;AACzB,sGAAA,aAAa,OAAA;AACb,0GAAA,iBAAiB,OAAA;AACjB,8GAAA,qBAAqB,OAAA;AAkBvB,gBAAgB;AAChB,uCAamB;AAZjB,gHAAA,oBAAoB,OAAA;AACpB,2HAAA,+BAA+B,OAAA;AAC/B,yHAAA,6BAA6B,OAAA;AAC7B,iHAAA,qBAAqB,OAAA;AACrB,mHAAA,uBAAuB,OAAA;AACvB,gIAAA,oCAAoC,OAAA;AACpC,oHAAA,wBAAwB,OAAA;AACxB,kHAAA,sBAAsB,OAAA;AACtB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,wHAAA,4BAA4B,OAAA;AAC5B,6GAAA,iBAAiB,OAAA;AAUnB,SAAS;AACT,mCAA2G;AAAlG,4GAAA,kBAAkB,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,kHAAA,wBAAwB,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAGzF,sBAAsB;AACtB,2CAA6D;AAApD,0GAAA,YAAY,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAGvC,UAAU;AACV,uCAA0C;AAAjC,yGAAA,aAAa,OAAA;AAGtB,QAAQ;AACR,iCAAuC;AAA9B,sGAAA,aAAa,OAAA;AAEtB,WAAW;AACX,uCAMmB;AALjB,wHAAA,4BAA4B,OAAA;AAC5B,kHAAA,sBAAsB,OAAA;AACtB,oHAAA,wBAAwB,OAAA;AACxB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AAGnB,iBAAiB;AACjB,2DAA6F;AAApF,wIAAA,kCAAkC,OAAA;AAAE,wHAAA,kBAAkB,OAAA;AAkB/D,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AACrB,yCAAuC;AAA9B,sGAAA,SAAS,OAAA"}
|
|
@@ -43,6 +43,7 @@ export interface VtFlowStorageProps {
|
|
|
43
43
|
validation?: VtFlowValidation;
|
|
44
44
|
issuance?: VtFlowIssuance;
|
|
45
45
|
proofsAttach?: DidCommAttachment[];
|
|
46
|
+
credentialId?: string;
|
|
46
47
|
credentialDigest?: string;
|
|
47
48
|
errorMessage?: string;
|
|
48
49
|
tags?: CustomVtFlowTags;
|
|
@@ -74,8 +75,11 @@ export declare class VtFlowRecord extends BaseRecord<DefaultVtFlowTags, CustomVt
|
|
|
74
75
|
validation?: VtFlowValidation;
|
|
75
76
|
issuance?: VtFlowIssuance;
|
|
76
77
|
proofsAttach?: DidCommAttachment[];
|
|
78
|
+
credentialId?: string;
|
|
77
79
|
credentialDigest?: string;
|
|
78
80
|
errorMessage?: string;
|
|
81
|
+
/** Outlives TERMINATED_BY_VALIDATOR when a validation in flight lands, until the applicant re-attaches ([VSA-ADM-VT-FL-REJECT-2]) */
|
|
82
|
+
connectionTerminated?: boolean;
|
|
79
83
|
constructor(props: VtFlowStorageProps);
|
|
80
84
|
getTags(): DefaultVtFlowTags & CustomVtFlowTags;
|
|
81
85
|
assertRole(expectedRole: VtFlowRole): void;
|
|
@@ -34,6 +34,7 @@ class VtFlowRecord extends core_1.BaseRecord {
|
|
|
34
34
|
this.validation = props.validation;
|
|
35
35
|
this.issuance = props.issuance;
|
|
36
36
|
this.proofsAttach = props.proofsAttach;
|
|
37
|
+
this.credentialId = props.credentialId;
|
|
37
38
|
this.credentialDigest = props.credentialDigest;
|
|
38
39
|
this.errorMessage = props.errorMessage;
|
|
39
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VtFlowRecord.js","sourceRoot":"","sources":["../../src/repository/VtFlowRecord.ts"],"names":[],"mappings":";;;AAGA,yCAA8D;
|
|
1
|
+
{"version":3,"file":"VtFlowRecord.js","sourceRoot":"","sources":["../../src/repository/VtFlowRecord.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,7 +5,7 @@ import { VtFlowModuleConfig, type VtFlowRequestPurpose } from '../VtFlowModuleCo
|
|
|
5
5
|
import { type BuildVtFlowProblemReportOptions, VtFlowErrorCode, buildVtFlowProblemReport } from '../errors';
|
|
6
6
|
import { CredentialStateChangeMessage, type CredentialStateChangeMessageOptions, IssuanceRequestMessage, OnboardingRequestMessage, OobLinkMessage, type OobLinkMessageOptions, VtFlowProblemReportMessage, ValidatingMessage, type ValidatingMessageOptions } from '../messages';
|
|
7
7
|
import { VtFlowRecord, VtFlowRepository } from '../repository';
|
|
8
|
-
import { type VtFlowMessage, type VtFlowValidation, VtFlowState } from '../types';
|
|
8
|
+
import { type VtFlowIssuance, type VtFlowMessage, type VtFlowValidation, VtFlowState } from '../types';
|
|
9
9
|
export interface CreateOnboardingRequestParams {
|
|
10
10
|
connectionId: string;
|
|
11
11
|
participantSessionId: string;
|
|
@@ -71,17 +71,17 @@ export declare class VtFlowService {
|
|
|
71
71
|
processReceiveValidating(messageContext: DidCommInboundMessageContext<ValidatingMessage>): Promise<VtFlowRecord>;
|
|
72
72
|
/** Applicant-side inbound `credential-state-change`; v1.0 handles `REVOKED` only. */
|
|
73
73
|
processReceiveCredentialStateChange(messageContext: DidCommInboundMessageContext<CredentialStateChangeMessage>): Promise<VtFlowRecord | null>;
|
|
74
|
-
/** `AWAITING_OR => VALIDATING
|
|
74
|
+
/** `AWAITING_OR => VALIDATING` once the `checkParticipantId` hook accepts the `participant_id`, with no transition and no message once it reports the request settled by a `VALIDATED` entry; caller is expected to have verified agent/wallet IDs on-chain. */
|
|
75
75
|
acceptOnboardingRequest(agentContext: AgentContext, recordId: string): Promise<{
|
|
76
76
|
record: VtFlowRecord;
|
|
77
|
-
message
|
|
77
|
+
message?: ValidatingMessage;
|
|
78
78
|
}>;
|
|
79
79
|
/** DirectIssuance: `AWAITING_IR => VALIDATING`; transient before `CRED_OFFERED`. */
|
|
80
80
|
acceptIssuanceRequest(agentContext: AgentContext, recordId: string): Promise<{
|
|
81
81
|
record: VtFlowRecord;
|
|
82
82
|
message: ValidatingMessage;
|
|
83
83
|
}>;
|
|
84
|
-
/** Reject with a problem-report;
|
|
84
|
+
/** Reject with a problem-report; a fatal code moves the sender to the Error Codes state, a retryable one returns a validator to `AWAITING_OR` or `AWAITING_IR`. */
|
|
85
85
|
rejectRequest(agentContext: AgentContext, recordId: string, params: RejectRequestParams): Promise<{
|
|
86
86
|
record: VtFlowRecord;
|
|
87
87
|
problemReport: ReturnType<typeof buildVtFlowProblemReport>;
|
|
@@ -117,6 +117,10 @@ export declare class VtFlowService {
|
|
|
117
117
|
}>;
|
|
118
118
|
/** Record the validation decision or its transaction outcome, moving the flow when `state` is given. */
|
|
119
119
|
recordValidation(agentContext: AgentContext, recordId: string, validation: VtFlowValidation, state?: VtFlowState): Promise<VtFlowRecord>;
|
|
120
|
+
/** Record the outcome of the `CreateOrUpdateParticipantSession` transaction that anchors the issued credential. */
|
|
121
|
+
recordIssuance(agentContext: AgentContext, recordId: string, issuance: VtFlowIssuance): Promise<VtFlowRecord>;
|
|
122
|
+
/** `VALIDATED` => `VALIDATED_PENDING_CLAIMS`, when the claims fail the schema at offer time ([VSA-VTI-FLOW-OP-ISSUE-4]). */
|
|
123
|
+
markPendingClaims(agentContext: AgentContext, recordId: string): Promise<VtFlowRecord>;
|
|
120
124
|
/** Validator-side states preceding `VALIDATED` => `VALIDATED`; call after `SetParticipantOPtoValidated` lands on-chain. */
|
|
121
125
|
markValidated(agentContext: AgentContext, recordId: string): Promise<VtFlowRecord>;
|
|
122
126
|
/**
|
|
@@ -130,7 +134,7 @@ export declare class VtFlowService {
|
|
|
130
134
|
/** Validator states that an `offer-credential` moves to `CRED_OFFERED`; from `COMPLETED` it starts a new subprotocol run. */
|
|
131
135
|
assertCanOfferCredential(record: VtFlowRecord): void;
|
|
132
136
|
/** Link a Credo exchange record to the session and transition to `CRED_OFFERED`. */
|
|
133
|
-
attachCredentialExchangeRecord(agentContext: AgentContext, recordId: string, credentialExchangeRecord: DidCommCredentialExchangeRecord, credentialDigest?: string, issuerParticipantId?: number): Promise<VtFlowRecord>;
|
|
137
|
+
attachCredentialExchangeRecord(agentContext: AgentContext, recordId: string, credentialExchangeRecord: DidCommCredentialExchangeRecord, credentialDigest?: string, issuerParticipantId?: number, credentialId?: string): Promise<VtFlowRecord>;
|
|
134
138
|
setEcsSchemaKey(agentContext: AgentContext, recordId: string, ecsSchemaKey: string): Promise<VtFlowRecord>;
|
|
135
139
|
setCredentialDigest(agentContext: AgentContext, recordId: string, credentialDigest: string): Promise<VtFlowRecord>;
|
|
136
140
|
/** Validator-side `credential-state-change`; `COMPLETED => CRED_REVOKED`, re-notify allowed from `CRED_REVOKED`. */
|
|
@@ -162,7 +166,10 @@ export declare class VtFlowService {
|
|
|
162
166
|
/** Persist record changes without state-transition semantics (no event emitted). */
|
|
163
167
|
updateRecord(agentContext: AgentContext, record: VtFlowRecord): Promise<void>;
|
|
164
168
|
/** participant_session_ids are public on-chain, so only the original peer may re-attach a flow with one. */
|
|
169
|
+
private isSamePeer;
|
|
165
170
|
private assertSamePeer;
|
|
171
|
+
/** VS-CONN-VS failure is fatal, so it ends the flow of the request in ERROR unless that flow has ended or belongs to another peer. */
|
|
172
|
+
private checkRequestFromVerifiableService;
|
|
166
173
|
private emitStateChanged;
|
|
167
174
|
getModuleConfig(): VtFlowModuleConfig;
|
|
168
175
|
getLogger(): Logger;
|
|
@@ -41,7 +41,7 @@ let VtFlowService = class VtFlowService {
|
|
|
41
41
|
message.setThread({ threadId: message.id });
|
|
42
42
|
const existing = await this.repository.findByParticipantSessionId(agentContext, params.participantSessionId, types_1.VtFlowRole.Applicant);
|
|
43
43
|
if (existing) {
|
|
44
|
-
if (
|
|
44
|
+
if (!(0, types_1.isVtFlowRenewable)(existing)) {
|
|
45
45
|
throw new core_1.CredoError(`vt-flow: participant_session_id '${params.participantSessionId}' already belongs to a flow in state ${existing.state}; use a new session id`);
|
|
46
46
|
}
|
|
47
47
|
existing.connectionId = params.connectionId;
|
|
@@ -137,22 +137,40 @@ let VtFlowService = class VtFlowService {
|
|
|
137
137
|
}
|
|
138
138
|
record.credentialExchangeRecordId = undefined;
|
|
139
139
|
record.subprotocolThid = undefined;
|
|
140
|
+
record.issuance = undefined;
|
|
140
141
|
}
|
|
141
142
|
/** Validator-side OnboardingProcess: create or re-attach (by `participant_session_id`) a record in `AWAITING_OR` from an inbound `onboarding-request`. */
|
|
142
143
|
async processReceiveOnboardingRequest(messageContext) {
|
|
143
144
|
const { message, agentContext } = messageContext;
|
|
144
145
|
const connection = messageContext.assertReadyConnection();
|
|
145
|
-
await this.checkIsVerifiableService(agentContext, connection, { participantId: message.participantId });
|
|
146
146
|
const existing = await this.repository.findByParticipantSessionId(agentContext, message.participantSessionId, types_1.VtFlowRole.Validator);
|
|
147
|
+
const record = existing !== null && existing !== void 0 ? existing : new repository_1.VtFlowRecord({
|
|
148
|
+
threadId: message.threadId,
|
|
149
|
+
participantSessionId: message.participantSessionId,
|
|
150
|
+
connectionId: connection.id,
|
|
151
|
+
role: types_1.VtFlowRole.Validator,
|
|
152
|
+
state: types_1.VtFlowState.AwaitingOr,
|
|
153
|
+
variant: types_1.VtFlowVariant.OnboardingProcess,
|
|
154
|
+
agentParticipantId: message.agentParticipantId,
|
|
155
|
+
walletAgentParticipantId: message.walletAgentParticipantId,
|
|
156
|
+
applicantParticipantId: message.participantId,
|
|
157
|
+
claims: message.claims,
|
|
158
|
+
proofsAttach: message.proofsAttach,
|
|
159
|
+
});
|
|
160
|
+
await this.checkRequestFromVerifiableService(agentContext, connection, record, !existing, {
|
|
161
|
+
participantId: message.participantId,
|
|
162
|
+
});
|
|
147
163
|
if (existing) {
|
|
148
164
|
if ((0, types_1.isVtFlowTerminalState)(existing.state)) {
|
|
149
|
-
throw new
|
|
165
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.InvalidParticipantSessionId, `vt-flow: participant_session_id '${message.participantSessionId}' collides with a terminated flow`);
|
|
150
166
|
}
|
|
151
167
|
if (existing.applicantParticipantId !== message.participantId) {
|
|
152
|
-
throw new
|
|
168
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.InvalidParticipantSessionId, `vt-flow: participant_id '${message.participantId}' does not match the flow of participant_session_id '${message.participantSessionId}'`);
|
|
153
169
|
}
|
|
154
170
|
await this.assertSamePeer(agentContext, existing, connection);
|
|
171
|
+
const reconnected = existing.connectionTerminated;
|
|
155
172
|
existing.connectionId = connection.id;
|
|
173
|
+
existing.connectionTerminated = undefined;
|
|
156
174
|
if (existing.threadId !== message.threadId) {
|
|
157
175
|
existing.threadId = message.threadId;
|
|
158
176
|
if (message.claims)
|
|
@@ -160,9 +178,11 @@ let VtFlowService = class VtFlowService {
|
|
|
160
178
|
if (message.proofsAttach)
|
|
161
179
|
existing.proofsAttach = message.proofsAttach;
|
|
162
180
|
}
|
|
163
|
-
if (
|
|
181
|
+
if ((0, types_1.isVtFlowRenewable)(existing)) {
|
|
164
182
|
// A finished flow re-entered with a new OR is a renewal (VSA-VTI-FLOW-OP-RENEW): re-run it.
|
|
165
183
|
existing.oobLink = undefined;
|
|
184
|
+
existing.validation = undefined;
|
|
185
|
+
existing.issuance = undefined;
|
|
166
186
|
await this.updateState(agentContext, existing, types_1.VtFlowState.AwaitingOr);
|
|
167
187
|
}
|
|
168
188
|
else if (existing.state === types_1.VtFlowState.CredOffered) {
|
|
@@ -171,22 +191,14 @@ let VtFlowService = class VtFlowService {
|
|
|
171
191
|
}
|
|
172
192
|
else {
|
|
173
193
|
await this.repository.update(agentContext, existing);
|
|
194
|
+
// [VSA-VTI-FLOW-OP-OR] checks every request, and [VSA-ADM-VT-FL-REJECT-2] issuance waits for this reconnection
|
|
195
|
+
if (existing.state === types_1.VtFlowState.AwaitingOr ||
|
|
196
|
+
(reconnected && existing.state === types_1.VtFlowState.Validated)) {
|
|
197
|
+
this.emitStateChanged(agentContext, existing, existing.state);
|
|
198
|
+
}
|
|
174
199
|
}
|
|
175
200
|
return existing;
|
|
176
201
|
}
|
|
177
|
-
const record = new repository_1.VtFlowRecord({
|
|
178
|
-
threadId: message.threadId,
|
|
179
|
-
participantSessionId: message.participantSessionId,
|
|
180
|
-
connectionId: connection.id,
|
|
181
|
-
role: types_1.VtFlowRole.Validator,
|
|
182
|
-
state: types_1.VtFlowState.AwaitingOr,
|
|
183
|
-
variant: types_1.VtFlowVariant.OnboardingProcess,
|
|
184
|
-
agentParticipantId: message.agentParticipantId,
|
|
185
|
-
walletAgentParticipantId: message.walletAgentParticipantId,
|
|
186
|
-
applicantParticipantId: message.participantId,
|
|
187
|
-
claims: message.claims,
|
|
188
|
-
proofsAttach: message.proofsAttach,
|
|
189
|
-
});
|
|
190
202
|
await this.repository.save(agentContext, record);
|
|
191
203
|
this.emitStateChanged(agentContext, record, null);
|
|
192
204
|
return record;
|
|
@@ -195,14 +207,28 @@ let VtFlowService = class VtFlowService {
|
|
|
195
207
|
async processReceiveIssuanceRequest(messageContext) {
|
|
196
208
|
const { message, agentContext } = messageContext;
|
|
197
209
|
const connection = messageContext.assertReadyConnection();
|
|
198
|
-
await this.checkIsVerifiableService(agentContext, connection, { schemaId: message.schemaId });
|
|
199
210
|
const existing = await this.repository.findByParticipantSessionId(agentContext, message.participantSessionId, types_1.VtFlowRole.Validator);
|
|
211
|
+
const record = existing !== null && existing !== void 0 ? existing : new repository_1.VtFlowRecord({
|
|
212
|
+
threadId: message.threadId,
|
|
213
|
+
participantSessionId: message.participantSessionId,
|
|
214
|
+
connectionId: connection.id,
|
|
215
|
+
role: types_1.VtFlowRole.Validator,
|
|
216
|
+
state: types_1.VtFlowState.AwaitingIr,
|
|
217
|
+
variant: types_1.VtFlowVariant.DirectIssuance,
|
|
218
|
+
agentParticipantId: message.agentParticipantId,
|
|
219
|
+
walletAgentParticipantId: message.walletAgentParticipantId,
|
|
220
|
+
schemaId: message.schemaId,
|
|
221
|
+
claims: message.claims,
|
|
222
|
+
});
|
|
223
|
+
await this.checkRequestFromVerifiableService(agentContext, connection, record, !existing, {
|
|
224
|
+
schemaId: message.schemaId,
|
|
225
|
+
});
|
|
200
226
|
if (existing) {
|
|
201
227
|
if ((0, types_1.isVtFlowTerminalState)(existing.state)) {
|
|
202
|
-
throw new
|
|
228
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.InvalidParticipantSessionId, `vt-flow: participant_session_id '${message.participantSessionId}' collides with a terminated flow`);
|
|
203
229
|
}
|
|
204
230
|
if (existing.variant !== types_1.VtFlowVariant.DirectIssuance || existing.schemaId !== message.schemaId) {
|
|
205
|
-
throw new
|
|
231
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.InvalidParticipantSessionId, `vt-flow: schema_id '${message.schemaId}' does not match the flow of participant_session_id '${message.participantSessionId}'`);
|
|
206
232
|
}
|
|
207
233
|
await this.assertSamePeer(agentContext, existing, connection);
|
|
208
234
|
existing.connectionId = connection.id;
|
|
@@ -216,18 +242,6 @@ let VtFlowService = class VtFlowService {
|
|
|
216
242
|
}
|
|
217
243
|
return existing;
|
|
218
244
|
}
|
|
219
|
-
const record = new repository_1.VtFlowRecord({
|
|
220
|
-
threadId: message.threadId,
|
|
221
|
-
participantSessionId: message.participantSessionId,
|
|
222
|
-
connectionId: connection.id,
|
|
223
|
-
role: types_1.VtFlowRole.Validator,
|
|
224
|
-
state: types_1.VtFlowState.AwaitingIr,
|
|
225
|
-
variant: types_1.VtFlowVariant.DirectIssuance,
|
|
226
|
-
agentParticipantId: message.agentParticipantId,
|
|
227
|
-
walletAgentParticipantId: message.walletAgentParticipantId,
|
|
228
|
-
schemaId: message.schemaId,
|
|
229
|
-
claims: message.claims,
|
|
230
|
-
});
|
|
231
245
|
await this.repository.save(agentContext, record);
|
|
232
246
|
this.emitStateChanged(agentContext, record, null);
|
|
233
247
|
return record;
|
|
@@ -267,7 +281,8 @@ let VtFlowService = class VtFlowService {
|
|
|
267
281
|
messageContext.assertReadyConnection();
|
|
268
282
|
const record = await this.getByThreadId(agentContext, message.threadId);
|
|
269
283
|
this.logger.debug(`[vt-flow] validating received for session ${record.threadId}: ${(_a = message.comment) !== null && _a !== void 0 ? _a : '(no comment)'}`);
|
|
270
|
-
if (record.role === types_1.VtFlowRole.Applicant &&
|
|
284
|
+
if (record.role === types_1.VtFlowRole.Applicant &&
|
|
285
|
+
(message.comment || record.state === types_1.VtFlowState.OobPending)) {
|
|
271
286
|
this.appendMessage(record, {
|
|
272
287
|
type: types_1.VtFlowMessageType.Validating,
|
|
273
288
|
text: message.comment,
|
|
@@ -298,12 +313,24 @@ let VtFlowService = class VtFlowService {
|
|
|
298
313
|
}
|
|
299
314
|
return record;
|
|
300
315
|
}
|
|
301
|
-
/** `AWAITING_OR => VALIDATING
|
|
316
|
+
/** `AWAITING_OR => VALIDATING` once the `checkParticipantId` hook accepts the `participant_id`, with no transition and no message once it reports the request settled by a `VALIDATED` entry; caller is expected to have verified agent/wallet IDs on-chain. */
|
|
302
317
|
async acceptOnboardingRequest(agentContext, recordId) {
|
|
303
|
-
|
|
318
|
+
let record = await this.repository.getById(agentContext, recordId);
|
|
304
319
|
record.assertRole(types_1.VtFlowRole.Validator);
|
|
305
320
|
record.assertState(types_1.VtFlowState.AwaitingOr);
|
|
306
321
|
record.assertVariant(types_1.VtFlowVariant.OnboardingProcess);
|
|
322
|
+
const { checkParticipantId } = this.config;
|
|
323
|
+
if (checkParticipantId) {
|
|
324
|
+
const checked = await checkParticipantId({ agentContext, record });
|
|
325
|
+
if (!checked) {
|
|
326
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.InvalidParticipantId, `vt-flow: participant_id '${record.applicantParticipantId}' is not a PENDING entry that names this agent as its validator`);
|
|
327
|
+
}
|
|
328
|
+
// the check can wait for the indexer while the flow moves on
|
|
329
|
+
record = await this.repository.getById(agentContext, recordId);
|
|
330
|
+
if (checked === 'validated')
|
|
331
|
+
return { record };
|
|
332
|
+
record.assertState(types_1.VtFlowState.AwaitingOr);
|
|
333
|
+
}
|
|
307
334
|
await this.updateState(agentContext, record, types_1.VtFlowState.Validating);
|
|
308
335
|
return { record, message: new messages_1.ValidatingMessage({ threadId: record.threadId }) };
|
|
309
336
|
}
|
|
@@ -316,21 +343,42 @@ let VtFlowService = class VtFlowService {
|
|
|
316
343
|
await this.updateState(agentContext, record, types_1.VtFlowState.Validating);
|
|
317
344
|
return { record, message: new messages_1.ValidatingMessage({ threadId: record.threadId }) };
|
|
318
345
|
}
|
|
319
|
-
/** Reject with a problem-report;
|
|
346
|
+
/** Reject with a problem-report; a fatal code moves the sender to the Error Codes state, a retryable one returns a validator to `AWAITING_OR` or `AWAITING_IR`. */
|
|
320
347
|
async rejectRequest(agentContext, recordId, params) {
|
|
321
348
|
var _a;
|
|
322
349
|
const record = await this.repository.getById(agentContext, recordId);
|
|
350
|
+
if ((0, types_1.isVtFlowTerminalState)(record.state)) {
|
|
351
|
+
throw new core_1.CredoError(`vt-flow: flow '${record.id}' in state ${record.state} cannot be rejected`);
|
|
352
|
+
}
|
|
323
353
|
const problemReport = (0, errors_1.buildVtFlowProblemReport)({
|
|
324
354
|
code: params.code,
|
|
325
355
|
threadId: record.threadId,
|
|
326
356
|
enDescription: params.enDescription,
|
|
327
357
|
fixHintEn: params.fixHintEn,
|
|
328
358
|
});
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
359
|
+
const info = errors_1.VT_FLOW_ERROR_INFO[params.code];
|
|
360
|
+
const receiverRole = record.role === types_1.VtFlowRole.Validator ? types_1.VtFlowRole.Applicant : types_1.VtFlowRole.Validator;
|
|
361
|
+
// a fatal code lands both parties in the state the table gives the receiver
|
|
362
|
+
const fatalState = this.resolveErrorFlowState(info.flowState, receiverRole, errors_1.whoRetriesMap[info.whoRetries]);
|
|
363
|
+
const retryState = record.variant === types_1.VtFlowVariant.OnboardingProcess ? types_1.VtFlowState.AwaitingOr : types_1.VtFlowState.AwaitingIr;
|
|
364
|
+
if (!fatalState && record.role === types_1.VtFlowRole.Validator) {
|
|
365
|
+
record.assertState([
|
|
366
|
+
types_1.VtFlowState.AwaitingOr,
|
|
367
|
+
types_1.VtFlowState.AwaitingIr,
|
|
368
|
+
types_1.VtFlowState.Validating,
|
|
369
|
+
types_1.VtFlowState.OobPending,
|
|
370
|
+
]);
|
|
371
|
+
}
|
|
372
|
+
if (record.role === types_1.VtFlowRole.Validator) {
|
|
373
|
+
this.appendMessage(record, {
|
|
374
|
+
type: types_1.VtFlowMessageType.ProblemReport,
|
|
375
|
+
text: problemReport.description.en,
|
|
376
|
+
at: new Date().toISOString(),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
if (fatalState)
|
|
380
|
+
record.errorMessage = (_a = params.enDescription) !== null && _a !== void 0 ? _a : params.code;
|
|
381
|
+
await this.updateState(agentContext, record, fatalState !== null && fatalState !== void 0 ? fatalState : (record.role === types_1.VtFlowRole.Validator ? retryState : record.state));
|
|
334
382
|
return { record, problemReport };
|
|
335
383
|
}
|
|
336
384
|
/** Applicant-side termination producing a problem-report and landing in `TERMINATED_BY_APPLICANT`. */
|
|
@@ -361,7 +409,7 @@ let VtFlowService = class VtFlowService {
|
|
|
361
409
|
types_1.VtFlowState.OobPending,
|
|
362
410
|
types_1.VtFlowState.AwaitingValidationTx,
|
|
363
411
|
types_1.VtFlowState.ValidationTxFailed,
|
|
364
|
-
// VtFlowModule ends the flow here when auto-issue
|
|
412
|
+
// VtFlowModule ends the flow here when auto-issue throws. A failed anchoring stays in CRED_OFFERED instead
|
|
365
413
|
types_1.VtFlowState.CredOffered,
|
|
366
414
|
types_1.VtFlowState.Completed,
|
|
367
415
|
]);
|
|
@@ -373,6 +421,12 @@ let VtFlowService = class VtFlowService {
|
|
|
373
421
|
fixHintEn: params.fixHintEn,
|
|
374
422
|
});
|
|
375
423
|
record.errorMessage = (_b = params.enDescription) !== null && _b !== void 0 ? _b : code;
|
|
424
|
+
this.appendMessage(record, {
|
|
425
|
+
type: types_1.VtFlowMessageType.ProblemReport,
|
|
426
|
+
text: problemReport.description.en,
|
|
427
|
+
at: new Date().toISOString(),
|
|
428
|
+
});
|
|
429
|
+
record.connectionTerminated = true;
|
|
376
430
|
await this.updateState(agentContext, record, types_1.VtFlowState.TerminatedByValidator);
|
|
377
431
|
return { record, problemReport };
|
|
378
432
|
}
|
|
@@ -425,13 +479,11 @@ let VtFlowService = class VtFlowService {
|
|
|
425
479
|
threadId: record.threadId,
|
|
426
480
|
comment: params.comment,
|
|
427
481
|
});
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
});
|
|
434
|
-
}
|
|
482
|
+
this.appendMessage(record, {
|
|
483
|
+
type: types_1.VtFlowMessageType.Validating,
|
|
484
|
+
text: params.comment,
|
|
485
|
+
at: new Date().toISOString(),
|
|
486
|
+
});
|
|
435
487
|
await this.updateState(agentContext, record, types_1.VtFlowState.Validating);
|
|
436
488
|
return { record, message };
|
|
437
489
|
}
|
|
@@ -446,6 +498,22 @@ let VtFlowService = class VtFlowService {
|
|
|
446
498
|
await this.updateRecord(agentContext, record);
|
|
447
499
|
return record;
|
|
448
500
|
}
|
|
501
|
+
/** Record the outcome of the `CreateOrUpdateParticipantSession` transaction that anchors the issued credential. */
|
|
502
|
+
async recordIssuance(agentContext, recordId, issuance) {
|
|
503
|
+
const record = await this.repository.getById(agentContext, recordId);
|
|
504
|
+
record.assertRole(types_1.VtFlowRole.Validator);
|
|
505
|
+
record.issuance = issuance;
|
|
506
|
+
await this.updateRecord(agentContext, record);
|
|
507
|
+
return record;
|
|
508
|
+
}
|
|
509
|
+
/** `VALIDATED` => `VALIDATED_PENDING_CLAIMS`, when the claims fail the schema at offer time ([VSA-VTI-FLOW-OP-ISSUE-4]). */
|
|
510
|
+
async markPendingClaims(agentContext, recordId) {
|
|
511
|
+
const record = await this.repository.getById(agentContext, recordId);
|
|
512
|
+
record.assertRole(types_1.VtFlowRole.Validator);
|
|
513
|
+
record.assertState(types_1.VtFlowState.Validated);
|
|
514
|
+
await this.updateState(agentContext, record, types_1.VtFlowState.ValidatedPendingClaims);
|
|
515
|
+
return record;
|
|
516
|
+
}
|
|
449
517
|
/** Validator-side states preceding `VALIDATED` => `VALIDATED`; call after `SetParticipantOPtoValidated` lands on-chain. */
|
|
450
518
|
async markValidated(agentContext, recordId) {
|
|
451
519
|
const record = await this.repository.getById(agentContext, recordId);
|
|
@@ -484,10 +552,11 @@ let VtFlowService = class VtFlowService {
|
|
|
484
552
|
]);
|
|
485
553
|
}
|
|
486
554
|
/** Link a Credo exchange record to the session and transition to `CRED_OFFERED`. */
|
|
487
|
-
async attachCredentialExchangeRecord(agentContext, recordId, credentialExchangeRecord, credentialDigest, issuerParticipantId) {
|
|
555
|
+
async attachCredentialExchangeRecord(agentContext, recordId, credentialExchangeRecord, credentialDigest, issuerParticipantId, credentialId) {
|
|
488
556
|
const record = await this.repository.getById(agentContext, recordId);
|
|
489
557
|
this.assertCanOfferCredential(record);
|
|
490
558
|
record.credentialExchangeRecordId = credentialExchangeRecord.id;
|
|
559
|
+
record.credentialId = credentialId;
|
|
491
560
|
if (credentialDigest)
|
|
492
561
|
record.credentialDigest = credentialDigest;
|
|
493
562
|
if (issuerParticipantId !== undefined)
|
|
@@ -531,7 +600,16 @@ let VtFlowService = class VtFlowService {
|
|
|
531
600
|
async updateClaims(agentContext, recordId, claims) {
|
|
532
601
|
const record = await this.repository.getById(agentContext, recordId);
|
|
533
602
|
record.assertRole(types_1.VtFlowRole.Validator);
|
|
534
|
-
record.assertState([
|
|
603
|
+
record.assertState([
|
|
604
|
+
types_1.VtFlowState.AwaitingOr,
|
|
605
|
+
types_1.VtFlowState.OobPending,
|
|
606
|
+
types_1.VtFlowState.Validating,
|
|
607
|
+
types_1.VtFlowState.AwaitingValidationTx,
|
|
608
|
+
types_1.VtFlowState.ValidationTxSubmitted,
|
|
609
|
+
types_1.VtFlowState.ValidationTxFailed,
|
|
610
|
+
types_1.VtFlowState.ValidatedPendingClaims,
|
|
611
|
+
types_1.VtFlowState.CredRevoked,
|
|
612
|
+
]);
|
|
535
613
|
record.claims = claims;
|
|
536
614
|
await this.updateRecord(agentContext, record);
|
|
537
615
|
return record;
|
|
@@ -552,6 +630,11 @@ let VtFlowService = class VtFlowService {
|
|
|
552
630
|
}
|
|
553
631
|
break;
|
|
554
632
|
case didcomm_1.DidCommCredentialState.OfferReceived:
|
|
633
|
+
// the offer can beat the chain notification, and an Onboarding Process offers only from VALIDATED
|
|
634
|
+
if (record.variant === types_1.VtFlowVariant.OnboardingProcess &&
|
|
635
|
+
[types_1.VtFlowState.OrSent, types_1.VtFlowState.Validating, types_1.VtFlowState.OobPending].includes(record.state)) {
|
|
636
|
+
await this.updateState(agentContext, record, types_1.VtFlowState.Validated);
|
|
637
|
+
}
|
|
555
638
|
if (record.state !== types_1.VtFlowState.CredOffered) {
|
|
556
639
|
await this.updateState(agentContext, record, types_1.VtFlowState.CredOffered);
|
|
557
640
|
}
|
|
@@ -565,6 +648,7 @@ let VtFlowService = class VtFlowService {
|
|
|
565
648
|
}
|
|
566
649
|
break;
|
|
567
650
|
case didcomm_1.DidCommCredentialState.Abandoned:
|
|
651
|
+
case didcomm_1.DidCommCredentialState.Declined:
|
|
568
652
|
if (record.state !== types_1.VtFlowState.Error) {
|
|
569
653
|
record.errorMessage = (_a = record.errorMessage) !== null && _a !== void 0 ? _a : 'Subprotocol abandoned';
|
|
570
654
|
await this.updateState(agentContext, record, types_1.VtFlowState.Error);
|
|
@@ -667,13 +751,43 @@ let VtFlowService = class VtFlowService {
|
|
|
667
751
|
await this.repository.update(agentContext, record);
|
|
668
752
|
}
|
|
669
753
|
/** participant_session_ids are public on-chain, so only the original peer may re-attach a flow with one. */
|
|
670
|
-
async
|
|
754
|
+
async isSamePeer(agentContext, record, connection) {
|
|
671
755
|
if (record.connectionId === connection.id)
|
|
672
|
-
return;
|
|
756
|
+
return true;
|
|
673
757
|
const connectionRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommConnectionRepository);
|
|
674
758
|
const previous = await connectionRepository.findById(agentContext, record.connectionId);
|
|
675
|
-
|
|
676
|
-
|
|
759
|
+
return !((previous === null || previous === void 0 ? void 0 : previous.theirDid) && connection.theirDid && previous.theirDid !== connection.theirDid);
|
|
760
|
+
}
|
|
761
|
+
async assertSamePeer(agentContext, record, connection) {
|
|
762
|
+
if (!(await this.isSamePeer(agentContext, record, connection))) {
|
|
763
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.InvalidParticipantSessionId, `vt-flow: connection '${connection.id}' peer does not match the original connection of participant_session_id '${record.participantSessionId}'`);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
/** VS-CONN-VS failure is fatal, so it ends the flow of the request in ERROR unless that flow has ended or belongs to another peer. */
|
|
767
|
+
async checkRequestFromVerifiableService(agentContext, connection, record, isNew, purpose) {
|
|
768
|
+
try {
|
|
769
|
+
await this.checkIsVerifiableService(agentContext, connection, purpose);
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
if (error instanceof errors_1.VtFlowError &&
|
|
773
|
+
(isNew ||
|
|
774
|
+
(!(0, types_1.isVtFlowTerminalState)(record.state) && (await this.isSamePeer(agentContext, record, connection))))) {
|
|
775
|
+
record.errorMessage = error.message;
|
|
776
|
+
this.appendMessage(record, {
|
|
777
|
+
type: types_1.VtFlowMessageType.ProblemReport,
|
|
778
|
+
text: (0, errors_1.defaultEnglishDescription)(error.code),
|
|
779
|
+
at: new Date().toISOString(),
|
|
780
|
+
});
|
|
781
|
+
if (isNew) {
|
|
782
|
+
record.state = types_1.VtFlowState.Error;
|
|
783
|
+
await this.repository.save(agentContext, record);
|
|
784
|
+
this.emitStateChanged(agentContext, record, null);
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
await this.updateState(agentContext, record, types_1.VtFlowState.Error);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
throw error;
|
|
677
791
|
}
|
|
678
792
|
}
|
|
679
793
|
emitStateChanged(agentContext, record, previousState) {
|
|
@@ -726,7 +840,7 @@ let VtFlowService = class VtFlowService {
|
|
|
726
840
|
this.logger.info(`[vt-flow] peer '${peerDid}' is not (yet) a Verifiable Service, but the request qualifies for the VS-CONN-VS ECS issuance exemption`);
|
|
727
841
|
return;
|
|
728
842
|
}
|
|
729
|
-
throw new
|
|
843
|
+
throw new errors_1.VtFlowError(errors_1.VtFlowErrorCode.NotAVerifiableService, `vt-flow.not-a-verifiable-service: peer '${peerDid}' failed VS-CONN-VS check${failure ? ` (${failure})` : ''}`);
|
|
730
844
|
}
|
|
731
845
|
async isExemptFromVsConnVs(agentContext, connection, peerDid, purpose) {
|
|
732
846
|
const exemption = this.config.checkEcsIssuanceExemption;
|