@verana-labs/vs-agent-sdk 1.13.2-dev.1 → 2.0.0-ayni.1
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/README.md +0 -2
- package/build/adminApi/AdminApiError.d.ts +28 -0
- package/build/adminApi/AdminApiError.js +67 -0
- package/build/adminApi/AdminApiError.js.map +1 -0
- package/build/adminApi/didcommModules.d.ts +2 -0
- package/build/adminApi/didcommModules.js +8 -0
- package/build/adminApi/didcommModules.js.map +1 -0
- package/build/adminApi/index.d.ts +4 -0
- package/build/adminApi/index.js +21 -0
- package/build/adminApi/index.js.map +1 -0
- package/build/adminApi/moduleEndpoint.d.ts +7 -0
- package/build/adminApi/moduleEndpoint.js +21 -0
- package/build/adminApi/moduleEndpoint.js.map +1 -0
- package/build/adminApi/pagination/PageDto.d.ts +7 -0
- package/build/adminApi/pagination/PageDto.js +50 -0
- package/build/adminApi/pagination/PageDto.js.map +1 -0
- package/build/adminApi/pagination/PaginationQueryDto.d.ts +11 -0
- package/build/adminApi/pagination/PaginationQueryDto.js +46 -0
- package/build/adminApi/pagination/PaginationQueryDto.js.map +1 -0
- package/build/adminApi/pagination/cursor.d.ts +28 -0
- package/build/adminApi/pagination/cursor.js +64 -0
- package/build/adminApi/pagination/cursor.js.map +1 -0
- package/build/adminApi/pagination/index.d.ts +4 -0
- package/build/adminApi/pagination/index.js +21 -0
- package/build/adminApi/pagination/index.js.map +1 -0
- package/build/adminApi/pagination/paginate.d.ts +27 -0
- package/build/adminApi/pagination/paginate.js +77 -0
- package/build/adminApi/pagination/paginate.js.map +1 -0
- package/build/agent/VsAgent.d.ts +30 -34
- package/build/agent/VsAgent.js +148 -221
- package/build/agent/VsAgent.js.map +1 -1
- package/build/agent/createVsAgent.d.ts +9 -6
- package/build/agent/createVsAgent.js +5 -5
- package/build/agent/createVsAgent.js.map +1 -1
- package/build/blockchain/AnonCredsTrustService.d.ts +84 -0
- package/build/blockchain/AnonCredsTrustService.js +276 -0
- package/build/blockchain/AnonCredsTrustService.js.map +1 -0
- package/build/blockchain/AuthorizationService.d.ts +8 -6
- package/build/blockchain/AuthorizationService.js +30 -38
- package/build/blockchain/AuthorizationService.js.map +1 -1
- package/build/blockchain/IndexerWebSocketService.d.ts +7 -0
- package/build/blockchain/IndexerWebSocketService.js +72 -20
- package/build/blockchain/IndexerWebSocketService.js.map +1 -1
- package/build/blockchain/VeranaChainService.d.ts +38 -21
- package/build/blockchain/VeranaChainService.js +172 -140
- package/build/blockchain/VeranaChainService.js.map +1 -1
- package/build/blockchain/VeranaIndexerService.d.ts +14 -1
- package/build/blockchain/VeranaIndexerService.js +122 -8
- package/build/blockchain/VeranaIndexerService.js.map +1 -1
- package/build/blockchain/feePreflight.d.ts +32 -0
- package/build/blockchain/feePreflight.js +89 -0
- package/build/blockchain/feePreflight.js.map +1 -0
- package/build/blockchain/handlers/authorizationHandlers.js +2 -2
- package/build/blockchain/handlers/authorizationHandlers.js.map +1 -1
- package/build/blockchain/handlers/defaultHandlers.js +6 -1
- package/build/blockchain/handlers/defaultHandlers.js.map +1 -1
- package/build/blockchain/handlers/index.d.ts +1 -0
- package/build/blockchain/handlers/index.js +1 -0
- package/build/blockchain/handlers/index.js.map +1 -1
- package/build/blockchain/handlers/selfIssuanceHandlers.d.ts +13 -0
- package/build/blockchain/handlers/selfIssuanceHandlers.js +76 -0
- package/build/blockchain/handlers/selfIssuanceHandlers.js.map +1 -0
- package/build/blockchain/handlers/stateMutations.d.ts +26 -2
- package/build/blockchain/handlers/stateMutations.js +343 -48
- package/build/blockchain/handlers/stateMutations.js.map +1 -1
- package/build/blockchain/index.d.ts +4 -0
- package/build/blockchain/index.js +4 -0
- package/build/blockchain/index.js.map +1 -1
- package/build/blockchain/indexerMappers.d.ts +3 -0
- package/build/blockchain/indexerMappers.js +53 -0
- package/build/blockchain/indexerMappers.js.map +1 -0
- package/build/blockchain/triggerResolver.d.ts +26 -0
- package/build/blockchain/triggerResolver.js +110 -0
- package/build/blockchain/triggerResolver.js.map +1 -0
- package/build/blockchain/types.d.ts +15 -59
- package/build/blockchain/types.js.map +1 -1
- package/build/bootstrap/EcsBootstrapService.d.ts +16 -3
- package/build/bootstrap/EcsBootstrapService.js +214 -79
- package/build/bootstrap/EcsBootstrapService.js.map +1 -1
- package/build/connections/InvitationRecord.d.ts +50 -0
- package/build/connections/InvitationRecord.js +60 -0
- package/build/connections/InvitationRecord.js.map +1 -0
- package/build/connections/ParentConnectionModule.d.ts +22 -0
- package/build/connections/ParentConnectionModule.js +91 -0
- package/build/connections/ParentConnectionModule.js.map +1 -0
- package/build/credentials/FullTailsFileService.d.ts +0 -1
- package/build/credentials/FullTailsFileService.js +0 -49
- package/build/credentials/FullTailsFileService.js.map +1 -1
- package/build/did/CachedDocumentLoader.d.ts +3 -0
- package/build/did/CachedDocumentLoader.js +7 -1
- package/build/did/CachedDocumentLoader.js.map +1 -1
- package/build/did/CachedWebDidResolver.d.ts +0 -4
- package/build/did/CachedWebDidResolver.js +1 -5
- package/build/did/CachedWebDidResolver.js.map +1 -1
- package/build/did/artifactServices.d.ts +12 -0
- package/build/did/artifactServices.js +48 -0
- package/build/did/artifactServices.js.map +1 -0
- package/build/did/legacyDidWeb.d.ts +6 -4
- package/build/did/legacyDidWeb.js +17 -14
- package/build/did/legacyDidWeb.js.map +1 -1
- package/build/did/publicDid.d.ts +4 -0
- package/build/did/publicDid.js +19 -0
- package/build/did/publicDid.js.map +1 -0
- package/build/events/BaseMessageEvents.js +138 -14
- package/build/events/BaseMessageEvents.js.map +1 -1
- package/build/events/ConnectionEvents.js +121 -83
- package/build/events/ConnectionEvents.js.map +1 -1
- package/build/events/InvitationEvents.d.ts +6 -0
- package/build/events/InvitationEvents.js +68 -0
- package/build/events/InvitationEvents.js.map +1 -0
- package/build/events/VsAgentEvents.d.ts +18 -9
- package/build/events/VsAgentEvents.js +9 -1
- package/build/events/VsAgentEvents.js.map +1 -1
- package/build/events/VtFlowEvents.d.ts +1 -1
- package/build/events/VtFlowEvents.js +29 -17
- package/build/events/VtFlowEvents.js.map +1 -1
- package/build/events/index.d.ts +1 -0
- package/build/events/index.js +1 -0
- package/build/events/index.js.map +1 -1
- package/build/index.d.ts +9 -1
- package/build/index.js +20 -2
- package/build/index.js.map +1 -1
- package/build/plugins/setupBaseDidComm.js +20 -21
- package/build/plugins/setupBaseDidComm.js.map +1 -1
- package/build/transports/HttpInboundTransport.js +6 -1
- package/build/transports/HttpInboundTransport.js.map +1 -1
- package/build/transports/VsAgentWsInboundTransport.d.ts +1 -1
- package/build/transports/VsAgentWsInboundTransport.js +20 -14
- package/build/transports/VsAgentWsInboundTransport.js.map +1 -1
- package/build/types.d.ts +14 -13
- package/build/types.js +1 -2
- package/build/types.js.map +1 -1
- package/build/utils/agent.d.ts +42 -4
- package/build/utils/agent.js +126 -22
- package/build/utils/agent.js.map +1 -1
- package/build/utils/boundedFetch.d.ts +13 -0
- package/build/utils/boundedFetch.js +47 -0
- package/build/utils/boundedFetch.js.map +1 -0
- package/build/utils/data.js +212 -134
- package/build/utils/data.js.map +1 -1
- package/build/utils/didReadiness.d.ts +9 -0
- package/build/utils/didReadiness.js +42 -0
- package/build/utils/didReadiness.js.map +1 -0
- package/build/utils/ecsClaims.d.ts +46 -0
- package/build/utils/ecsClaims.js +115 -0
- package/build/utils/ecsClaims.js.map +1 -0
- package/build/utils/ecsService.d.ts +8 -0
- package/build/utils/ecsService.js +23 -0
- package/build/utils/ecsService.js.map +1 -0
- package/build/utils/index.d.ts +7 -0
- package/build/utils/index.js +7 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/publishedDidRecord.d.ts +15 -0
- package/build/utils/publishedDidRecord.js +83 -0
- package/build/utils/publishedDidRecord.js.map +1 -0
- package/build/utils/selfIssuedEcsCredential.d.ts +8 -0
- package/build/utils/selfIssuedEcsCredential.js +158 -0
- package/build/utils/selfIssuedEcsCredential.js.map +1 -0
- package/build/utils/setupSelfTr.d.ts +36 -74
- package/build/utils/setupSelfTr.js +95 -323
- package/build/utils/setupSelfTr.js.map +1 -1
- package/build/utils/trustCredentialStore.d.ts +87 -7
- package/build/utils/trustCredentialStore.js +388 -118
- package/build/utils/trustCredentialStore.js.map +1 -1
- package/build/utils/typeMetadata.d.ts +44 -0
- package/build/utils/typeMetadata.js +89 -0
- package/build/utils/typeMetadata.js.map +1 -0
- package/build/utils/util.d.ts +20 -0
- package/build/utils/util.js +29 -0
- package/build/utils/util.js.map +1 -1
- package/build/utils/vcdm2.d.ts +34 -0
- package/build/utils/vcdm2.js +60 -0
- package/build/utils/vcdm2.js.map +1 -0
- package/build/utils/vtjscResolver.d.ts +23 -0
- package/build/utils/vtjscResolver.js +53 -0
- package/build/utils/vtjscResolver.js.map +1 -0
- package/build/vtFlow/VtFlowOrchestrator.d.ts +111 -14
- package/build/vtFlow/VtFlowOrchestrator.js +724 -133
- package/build/vtFlow/VtFlowOrchestrator.js.map +1 -1
- package/build/vtFlow/assertVerifiableService.d.ts +31 -2
- package/build/vtFlow/assertVerifiableService.js +68 -10
- package/build/vtFlow/assertVerifiableService.js.map +1 -1
- package/build/vtFlow/ecsIssuanceExemption.d.ts +12 -0
- package/build/vtFlow/ecsIssuanceExemption.js +84 -0
- package/build/vtFlow/ecsIssuanceExemption.js.map +1 -0
- package/build/vtFlow/index.d.ts +1 -0
- package/build/vtFlow/index.js +1 -0
- package/build/vtFlow/index.js.map +1 -1
- package/package.json +26 -20
- package/build/did/migrateWebVhLog.d.ts +0 -34
- package/build/did/migrateWebVhLog.js +0 -230
- package/build/did/migrateWebVhLog.js.map +0 -1
- package/build/did/migrateWebVhVersionTime.d.ts +0 -9
- package/build/did/migrateWebVhVersionTime.js +0 -191
- package/build/did/migrateWebVhVersionTime.js.map +0 -1
- package/build/vtFlow/credentialDigest.d.ts +0 -3
- package/build/vtFlow/credentialDigest.js +0 -23
- package/build/vtFlow/credentialDigest.js.map +0 -1
package/build/agent/VsAgent.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnonCredsModule } from '@credo-ts/anoncreds';
|
|
2
|
+
import { AnonCredsDidCommCredentialFormatService, AnonCredsDidCommProofFormatService } from '@credo-ts/anoncreds/didcomm';
|
|
2
3
|
import { AskarModule, AskarModuleConfigStoreOptions } from '@credo-ts/askar';
|
|
3
4
|
import { Agent, AgentDependencies, DidsModule, InitConfig, W3cCredentialsModule } from '@credo-ts/core';
|
|
4
|
-
import { DidCommCredentialsModuleConfigOptions, DidCommCredentialV2Protocol,
|
|
5
|
+
import { DidCommCredentialsModuleConfigOptions, DidCommCredentialV2Protocol, DidCommDataIntegrityCredentialFormatService, DidCommFeatureQueryOptions, DidCommModule, DidCommModuleConfigOptions, DidCommProofsModuleConfigOptions, DidCommProofV2Protocol } from '@credo-ts/didcomm';
|
|
5
6
|
import { VtFlowModule } from '@verana-labs/credo-ts-didcomm-vt-flow';
|
|
7
|
+
import { AnonCredsTrustService } from '../blockchain/AnonCredsTrustService';
|
|
6
8
|
import { AuthorizationService } from '../blockchain/AuthorizationService';
|
|
7
9
|
import { VeranaChainService } from '../blockchain/VeranaChainService';
|
|
10
|
+
import { VeranaIndexerService } from '../blockchain/VeranaIndexerService';
|
|
11
|
+
import { ParentConnectionModule } from '../connections/ParentConnectionModule';
|
|
12
|
+
import { EcsClaims } from '../utils/ecsClaims';
|
|
8
13
|
type VsAgentDidCommModule = DidCommModule<DidCommModuleConfigOptions & {
|
|
9
14
|
credentials: DidCommCredentialsModuleConfigOptions<[
|
|
10
15
|
DidCommCredentialV2Protocol<[
|
|
11
|
-
LegacyIndyDidCommCredentialFormatService,
|
|
12
16
|
AnonCredsDidCommCredentialFormatService,
|
|
13
|
-
|
|
17
|
+
DidCommDataIntegrityCredentialFormatService
|
|
14
18
|
]>
|
|
15
19
|
]>;
|
|
16
|
-
proofs: DidCommProofsModuleConfigOptions<[
|
|
17
|
-
DidCommProofV2Protocol<[LegacyIndyDidCommProofFormatService, AnonCredsDidCommProofFormatService]>
|
|
18
|
-
]>;
|
|
20
|
+
proofs: DidCommProofsModuleConfigOptions<[DidCommProofV2Protocol<[AnonCredsDidCommProofFormatService]>]>;
|
|
19
21
|
}>;
|
|
20
22
|
export type BaseAgentModules = {
|
|
21
23
|
askar: AskarModule;
|
|
@@ -23,6 +25,7 @@ export type BaseAgentModules = {
|
|
|
23
25
|
dids: DidsModule;
|
|
24
26
|
w3cCredentials: W3cCredentialsModule;
|
|
25
27
|
didcomm: VsAgentDidCommModule;
|
|
28
|
+
parentConnection: ParentConnectionModule;
|
|
26
29
|
vtFlow: VtFlowModule;
|
|
27
30
|
};
|
|
28
31
|
interface AgentOptions<TModules extends BaseAgentModules> {
|
|
@@ -32,61 +35,54 @@ interface AgentOptions<TModules extends BaseAgentModules> {
|
|
|
32
35
|
}
|
|
33
36
|
export declare class VsAgent<TModules extends BaseAgentModules = BaseAgentModules> extends Agent<TModules> {
|
|
34
37
|
did?: string;
|
|
35
|
-
autoDiscloseUserProfile?: boolean;
|
|
36
38
|
publicApiBaseUrl: string;
|
|
37
39
|
adminApiServiceEndpoint?: string;
|
|
38
|
-
displayPictureUrl?: string;
|
|
39
|
-
label: string;
|
|
40
40
|
veranaChain?: VeranaChainService;
|
|
41
|
+
indexer: VeranaIndexerService;
|
|
42
|
+
trustedEcosystemDids?: string[];
|
|
43
|
+
ecsClaims?: EcsClaims;
|
|
41
44
|
authorizationService?: AuthorizationService;
|
|
42
45
|
discoveryOptions?: DidCommFeatureQueryOptions[];
|
|
46
|
+
readonly anonCredsTrust: AnonCredsTrustService;
|
|
43
47
|
constructor(options: AgentOptions<TModules> & {
|
|
44
48
|
did?: string;
|
|
45
|
-
autoDiscloseUserProfile?: boolean;
|
|
46
49
|
publicApiBaseUrl: string;
|
|
47
50
|
adminApiServiceEndpoint?: string;
|
|
48
|
-
displayPictureUrl?: string;
|
|
49
|
-
label: string;
|
|
50
51
|
veranaChain?: VeranaChainService;
|
|
52
|
+
indexer: VeranaIndexerService;
|
|
53
|
+
trustedEcosystemDids?: string[];
|
|
54
|
+
ecsClaims?: EcsClaims;
|
|
51
55
|
authorizationService?: AuthorizationService;
|
|
52
56
|
discoveryOptions?: DidCommFeatureQueryOptions[];
|
|
57
|
+
anonCredsTrust?: AnonCredsTrustService;
|
|
58
|
+
/** DEMO ONLY: see AnonCredsTrustServiceOptions.skipOwnAuthorization. */
|
|
59
|
+
skipOwnAuthorization?: boolean;
|
|
53
60
|
});
|
|
54
61
|
private get hasUserProfile();
|
|
62
|
+
/**
|
|
63
|
+
* [VSA-VT-LVP-5]: a `TriggerResolver` that the coalescing window still holds is the only signal of
|
|
64
|
+
* the publication change behind it, so the agent sends it before it stops.
|
|
65
|
+
*/
|
|
66
|
+
shutdown(): Promise<void>;
|
|
55
67
|
initialize(): Promise<void>;
|
|
68
|
+
private ensureSharedPublicDidInvitation;
|
|
56
69
|
private findCreatedDid;
|
|
57
70
|
private findEd25519VerificationMethodId;
|
|
58
71
|
private getDidCommServices;
|
|
59
|
-
private
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* (e.g. `#z6Mk...`) while the DID document verification method uses a short fragment (e.g. `#BVhGnL79`).
|
|
63
|
-
* `getKmsKeyIdForVerifiacationMethod` matches by suffix (`vm.id.endsWith(relativeKeyId)`), so the
|
|
64
|
-
* mismatch leaves the update key unresolvable and every webvh update fails with
|
|
65
|
-
* "The key ID must be present before the log can be edited." The private key is present in the KMS;
|
|
66
|
-
* only the mapping label is wrong. Idempotent: a mapping that already correlates to a VM is left alone.
|
|
67
|
-
*/
|
|
68
|
-
private repairWebvhUpdateKeyMapping;
|
|
72
|
+
private replaceDerivedKeyAgreementKey;
|
|
73
|
+
private createKeyAgreementKey;
|
|
74
|
+
private addDidKey;
|
|
69
75
|
private createAndAddDidCommKeysAndServices;
|
|
70
|
-
private
|
|
71
|
-
/**
|
|
72
|
-
* Basic implicit webvh services, for the moment pointing to the service VP
|
|
73
|
-
* and public base URL
|
|
74
|
-
*/
|
|
75
|
-
private createAndAddWebVhImplicitServices;
|
|
76
|
-
private createAndAddAnonCredsServices;
|
|
76
|
+
private addLinkedVpContext;
|
|
77
77
|
private applyAdminApiService;
|
|
78
78
|
}
|
|
79
79
|
export interface VsAgentOptions {
|
|
80
80
|
config: InitConfig;
|
|
81
81
|
did?: string;
|
|
82
|
-
autoDiscloseUserProfile?: boolean;
|
|
83
82
|
dependencies: AgentDependencies;
|
|
84
83
|
publicApiBaseUrl: string;
|
|
85
84
|
adminApiServiceEndpoint?: string;
|
|
86
|
-
masterListCscaLocation?: string;
|
|
87
85
|
endpoints: string[];
|
|
88
86
|
walletConfig: AskarModuleConfigStoreOptions;
|
|
89
|
-
displayPictureUrl?: string;
|
|
90
|
-
label: string;
|
|
91
87
|
}
|
|
92
88
|
export {};
|
package/build/agent/VsAgent.js
CHANGED
|
@@ -2,157 +2,151 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VsAgent = void 0;
|
|
4
4
|
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const didcomm_1 = require("@credo-ts/didcomm");
|
|
5
6
|
const didwebvh_ts_1 = require("didwebvh-ts");
|
|
7
|
+
const AnonCredsTrustService_1 = require("../blockchain/AnonCredsTrustService");
|
|
8
|
+
const triggerResolver_1 = require("../blockchain/triggerResolver");
|
|
6
9
|
const adminApiService_1 = require("../did/adminApiService");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
10
|
+
const artifactServices_1 = require("../did/artifactServices");
|
|
11
|
+
const legacyDidWeb_1 = require("../did/legacyDidWeb");
|
|
9
12
|
const BaseMessageEvents_1 = require("../events/BaseMessageEvents");
|
|
10
13
|
const ConnectionEvents_1 = require("../events/ConnectionEvents");
|
|
14
|
+
const InvitationEvents_1 = require("../events/InvitationEvents");
|
|
11
15
|
const VtFlowEvents_1 = require("../events/VtFlowEvents");
|
|
16
|
+
const agent_1 = require("../utils/agent");
|
|
12
17
|
const MANAGED_DIDCOMM_SERVICE_TYPES = [core_1.DidCommV1Service.type, core_1.NewDidCommV2Service.type];
|
|
18
|
+
const KEY_AGREEMENT_FRAGMENT = 'key-agreement-1';
|
|
13
19
|
class VsAgent extends core_1.Agent {
|
|
14
20
|
constructor(options) {
|
|
21
|
+
var _a;
|
|
15
22
|
super(options);
|
|
16
23
|
this.did = options.did;
|
|
17
|
-
this.autoDiscloseUserProfile = options.autoDiscloseUserProfile;
|
|
18
24
|
this.publicApiBaseUrl = options.publicApiBaseUrl;
|
|
19
25
|
this.adminApiServiceEndpoint = options.adminApiServiceEndpoint;
|
|
20
|
-
this.displayPictureUrl = options.displayPictureUrl;
|
|
21
|
-
this.label = options.label;
|
|
22
26
|
this.veranaChain = options.veranaChain;
|
|
27
|
+
this.indexer = options.indexer;
|
|
28
|
+
this.trustedEcosystemDids = options.trustedEcosystemDids;
|
|
29
|
+
this.ecsClaims = options.ecsClaims;
|
|
23
30
|
this.authorizationService = options.authorizationService;
|
|
24
31
|
this.discoveryOptions = options.discoveryOptions;
|
|
32
|
+
this.anonCredsTrust =
|
|
33
|
+
(_a = options.anonCredsTrust) !== null && _a !== void 0 ? _a : new AnonCredsTrustService_1.AnonCredsTrustService(this, { skipOwnAuthorization: options.skipOwnAuthorization });
|
|
25
34
|
}
|
|
26
35
|
get hasUserProfile() {
|
|
27
36
|
return 'userProfile' in this.modules;
|
|
28
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* [VSA-VT-LVP-5]: a `TriggerResolver` that the coalescing window still holds is the only signal of
|
|
40
|
+
* the publication change behind it, so the agent sends it before it stops.
|
|
41
|
+
*/
|
|
42
|
+
async shutdown() {
|
|
43
|
+
await (0, triggerResolver_1.flushPendingTriggerResolvers)().catch(error => this.config.logger.error(`[TriggerResolver] the pending trigger was not sent: ${error}`));
|
|
44
|
+
await super.shutdown();
|
|
45
|
+
}
|
|
29
46
|
async initialize() {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
31
48
|
await super.initialize();
|
|
32
49
|
const logger = this.config.logger;
|
|
33
50
|
await (0, ConnectionEvents_1.connectionEvents)(this, { discoveryOptions: this.discoveryOptions, logger });
|
|
51
|
+
(0, InvitationEvents_1.invitationEvents)(this, logger);
|
|
34
52
|
await (0, BaseMessageEvents_1.baseMessageEvents)(this, logger);
|
|
35
53
|
await (0, VtFlowEvents_1.vtFlowEvents)(this, logger);
|
|
36
|
-
if (this.hasUserProfile) {
|
|
37
|
-
// Make sure default User Profile corresponds to settings in environment variables
|
|
38
|
-
const imageUrl = this.displayPictureUrl;
|
|
39
|
-
const displayPicture = imageUrl ? { links: [imageUrl], mimeType: 'image/png' } : undefined;
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
await this.modules.userProfile.updateUserProfileData({
|
|
42
|
-
displayName: this.label,
|
|
43
|
-
displayPicture,
|
|
44
|
-
}); // TODO: Move this logic to the ChatPlugin
|
|
45
|
-
}
|
|
46
54
|
const parsedDid = this.did ? (0, core_1.parseDid)(this.did) : null;
|
|
47
55
|
if (parsedDid) {
|
|
48
|
-
//
|
|
49
|
-
//
|
|
56
|
+
// The DID is derived from the public API base URL and is always SCID-less: its id is the
|
|
57
|
+
// location (domain[%3Aport][:path...]). Create it if the wallet holds no record yet.
|
|
50
58
|
// TODO: Make DIDComm version, keys, etc. configurable. Keys can also be imported
|
|
51
|
-
const
|
|
59
|
+
const location = parsedDid.id;
|
|
60
|
+
const [domain, ...pathSegments] = location.split(':');
|
|
61
|
+
const path = pathSegments.length ? pathSegments.join('/') : undefined;
|
|
52
62
|
const existingRecord = await this.findCreatedDid(parsedDid);
|
|
63
|
+
if (!existingRecord) {
|
|
64
|
+
const otherMethod = parsedDid.method === 'webvh' ? 'web' : 'webvh';
|
|
65
|
+
const foreignRecord = await this.findCreatedDid(Object.assign(Object.assign({}, parsedDid), { method: otherMethod }));
|
|
66
|
+
if (foreignRecord) {
|
|
67
|
+
throw new core_1.CredoError(`Persisted public DID '${foreignRecord.did}' was created with method '${otherMethod}', but AGENT_PUBLIC_DID_METHOD is now '${parsedDid.method}'. Refusing to start: creating a second DID would discard the credentials, Participant entries and permissions bound to the persisted one.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (existingRecord) {
|
|
71
|
+
const persistedLocation = parsedDid.method === 'webvh'
|
|
72
|
+
? existingRecord.getTag('domain')
|
|
73
|
+
: (0, core_1.parseDid)(existingRecord.did).id;
|
|
74
|
+
if (persistedLocation !== location) {
|
|
75
|
+
throw new core_1.CredoError(`Persisted public DID '${existingRecord.did}' was created for location '${persistedLocation}', but PUBLIC_API_BASE_URL now derives location '${location}'. Refusing to start: restore the previous URL or deliberately reset the wallet.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
53
78
|
// DID has not been created yet. Let's do it
|
|
54
79
|
if (!existingRecord) {
|
|
55
80
|
if (parsedDid.method === 'web') {
|
|
56
81
|
const didDocument = new core_1.DidDocument({ id: parsedDid.did });
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// Add AnonCreds Services
|
|
61
|
-
await this.createAndAddAnonCredsServices(didDocument);
|
|
82
|
+
const didCommKeys = await this.createAndAddDidCommKeysAndServices(didDocument);
|
|
83
|
+
this.addLinkedVpContext(didDocument);
|
|
84
|
+
(0, artifactServices_1.applyArtifactServices)(didDocument, { method: 'web', publicApiBaseUrl: this.publicApiBaseUrl });
|
|
62
85
|
this.applyAdminApiService(didDocument);
|
|
63
|
-
await this.dids.create({
|
|
86
|
+
const createResult = await this.dids.create({
|
|
64
87
|
method: 'web',
|
|
65
|
-
domain,
|
|
88
|
+
domain: location,
|
|
66
89
|
didDocument,
|
|
67
|
-
keys:
|
|
90
|
+
keys: didCommKeys,
|
|
68
91
|
});
|
|
92
|
+
if (createResult.didState.state !== 'finished') {
|
|
93
|
+
throw new core_1.CredoError(`Failed to create did:web record: ${(_a = createResult.didState.reason) !== null && _a !== void 0 ? _a : 'unknown reason'}`);
|
|
94
|
+
}
|
|
69
95
|
this.did = parsedDid.did;
|
|
70
96
|
}
|
|
71
97
|
else if (parsedDid.method === 'webvh') {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// can use newer keys for DIDComm bootstrapping, but we should at least warn
|
|
75
|
-
// about that
|
|
76
|
-
const didRepository = this.dependencyManager.resolve(core_1.DidRepository);
|
|
77
|
-
const existingDidWebRecord = await didRepository.findCreatedDid(this.context, `did:web:${domain}`);
|
|
78
|
-
if (existingDidWebRecord) {
|
|
79
|
-
this.logger.warn('Existing record for legacy did:web found. Removing it');
|
|
80
|
-
await didRepository.delete(this.context, existingDidWebRecord);
|
|
81
|
-
}
|
|
82
|
-
const { didState: { did: publicDid, didDocument }, } = await this.dids.create({ method: 'webvh', domain });
|
|
98
|
+
const createResult = await this.dids.create({ method: 'webvh', domain, path });
|
|
99
|
+
const { did: publicDid, didDocument } = createResult.didState;
|
|
83
100
|
if (!publicDid || !didDocument) {
|
|
84
|
-
|
|
85
|
-
process.exit(1);
|
|
101
|
+
throw new core_1.CredoError(`Failed to create did:webvh record: ${(_b = createResult.didState.reason) !== null && _b !== void 0 ? _b : 'unknown reason'}`);
|
|
86
102
|
}
|
|
87
103
|
// Add DIDComm services and keys
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
104
|
+
const didCommKeys = await this.createAndAddDidCommKeysAndServices(didDocument);
|
|
105
|
+
this.addLinkedVpContext(didDocument);
|
|
106
|
+
(0, artifactServices_1.applyArtifactServices)(didDocument, { method: 'webvh', publicApiBaseUrl: this.publicApiBaseUrl });
|
|
107
|
+
const legacyDidWeb = (0, legacyDidWeb_1.getLegacyDidWeb)(publicDid);
|
|
108
|
+
if (legacyDidWeb)
|
|
109
|
+
didDocument.alsoKnownAs = [legacyDidWeb];
|
|
94
110
|
// The webvh registrar doesn't merge new keys into the DidRecord on update,
|
|
95
111
|
// so persist the DIDComm key mapping directly on the existing record.
|
|
96
|
-
|
|
112
|
+
const didRepository = this.agentContext.resolve(core_1.DidRepository);
|
|
113
|
+
const [record] = await didRepository.findByQuery(this.agentContext, { did: publicDid });
|
|
114
|
+
if (record) {
|
|
115
|
+
record.keys = [...((_c = record.keys) !== null && _c !== void 0 ? _c : []), ...didCommKeys];
|
|
116
|
+
if (legacyDidWeb)
|
|
117
|
+
record.setTag('alternativeDids', [legacyDidWeb]);
|
|
118
|
+
await didRepository.update(this.agentContext, record);
|
|
119
|
+
}
|
|
97
120
|
this.applyAdminApiService(didDocument);
|
|
98
121
|
const result = await this.dids.update({ did: publicDid, didDocument });
|
|
99
122
|
if (result.didState.state !== 'finished') {
|
|
100
|
-
|
|
101
|
-
process.exit(1);
|
|
123
|
+
throw new core_1.CredoError(`Cannot update DID ${publicDid}: ${(_d = result.didState.reason) !== null && _d !== void 0 ? _d : 'unknown reason'}`);
|
|
102
124
|
}
|
|
103
|
-
(
|
|
125
|
+
(_e = this.logger) === null || _e === void 0 ? void 0 : _e.debug('Public did:webvh record created');
|
|
104
126
|
this.did = publicDid;
|
|
105
127
|
}
|
|
106
128
|
else {
|
|
107
129
|
throw new core_1.CredoError(`Agent DID method not supported: ${parsedDid.method}`);
|
|
108
130
|
}
|
|
131
|
+
await this.ensureSharedPublicDidInvitation();
|
|
109
132
|
return;
|
|
110
133
|
}
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// same-second versionTimes the old create+update-at-init flow produced. Both migrations
|
|
114
|
-
// rebuild the log in-place, preserving entry #1 (and therefore the SCID and public DID).
|
|
115
|
-
if (parsedDid.method === 'webvh') {
|
|
116
|
-
try {
|
|
117
|
-
await (0, migrateWebVhVersionTime_1.migrateWebVhVersionTimeIfBroken)(this.agentContext, existingRecord, this.logger);
|
|
118
|
-
await (0, migrateWebVhLog_1.migrateWebVhLogIfBroken)(this.agentContext, existingRecord, this.logger);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
this.logger.error(`Failed to migrate webvh DID log for ${existingRecord.did}: ${error instanceof Error ? error.message : String(error)}`);
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Make sure did:webvh record has the did:web form as an alternative, in order to support
|
|
126
|
-
// implicit invitations
|
|
127
|
-
if (parsedDid.method === 'webvh' &&
|
|
128
|
-
!((_b = existingRecord === null || existingRecord === void 0 ? void 0 : existingRecord.getTag('alternativeDids')) === null || _b === void 0 ? void 0 : _b.includes(`did:web:${domain}`))) {
|
|
129
|
-
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug('Adding did:web form as an alternative DID');
|
|
130
|
-
existingRecord.setTag('alternativeDids', [`did:web:${domain}`]);
|
|
131
|
-
const didRepository = this.dependencyManager.resolve(core_1.DidRepository);
|
|
132
|
-
await didRepository.update(this.agentContext, existingRecord);
|
|
133
|
-
}
|
|
134
|
-
// Fix a legacy webvh update-key mapping before the self-heal update below relies on it.
|
|
135
|
-
if (parsedDid.method === 'webvh')
|
|
136
|
-
await this.repairWebvhUpdateKeyMapping(existingRecord);
|
|
137
|
-
// DID Already exists: update it in case that agent parameters have been changed. At the moment, we can only update
|
|
138
|
-
// DIDComm endpoints, so we'll only replace the service (if different from previous)
|
|
134
|
+
// DID already exists: reconcile the stored document with the current agent parameters,
|
|
135
|
+
// updating it only if one of the checks below finds a difference
|
|
139
136
|
const didDocument = existingRecord.didDocument;
|
|
140
|
-
const hasLegacyMethods = ((_d = didDocument.verificationMethod) !== null && _d !== void 0 ? _d : []).some(vm => ['Ed25519VerificationKey2018', 'X25519KeyAgreementKey2019'].includes(vm.type));
|
|
141
137
|
const ed25519VerificationMethodId = this.findEd25519VerificationMethodId(didDocument);
|
|
138
|
+
const keyAgreementKey = await this.replaceDerivedKeyAgreementKey(existingRecord, didDocument);
|
|
142
139
|
const servicesChanged = !ed25519VerificationMethodId ||
|
|
143
|
-
JSON.stringify(didDocument.
|
|
144
|
-
|
|
145
|
-
// One-shot migration for did:webvh records published before authentication-replace
|
|
146
|
-
// landed, which still carry the didwebvh-ts update key in authentication.
|
|
147
|
-
const authHasUpdateKey = parsedDid.method === 'webvh' &&
|
|
148
|
-
!!ed25519VerificationMethodId &&
|
|
149
|
-
((_e = didDocument.authentication) !== null && _e !== void 0 ? _e : []).some(a => {
|
|
150
|
-
const id = typeof a === 'string' ? a : a.id;
|
|
151
|
-
return id !== ed25519VerificationMethodId;
|
|
152
|
-
});
|
|
153
|
-
const currentAdminEntry = ((_f = didDocument.service) !== null && _f !== void 0 ? _f : []).find(s => s.type === 'VsAgentAdminAPI');
|
|
140
|
+
JSON.stringify(((_f = didDocument.service) !== null && _f !== void 0 ? _f : []).filter(service => MANAGED_DIDCOMM_SERVICE_TYPES.includes(service.type))) !== JSON.stringify(this.getDidCommServices(didDocument.id, ed25519VerificationMethodId));
|
|
141
|
+
const currentAdminEntry = ((_g = didDocument.service) !== null && _g !== void 0 ? _g : []).find(s => s.type === 'VsAgentAdminAPI');
|
|
154
142
|
const adminEntryChanged = (currentAdminEntry === null || currentAdminEntry === void 0 ? void 0 : currentAdminEntry.serviceEndpoint) !== this.adminApiServiceEndpoint;
|
|
155
|
-
|
|
143
|
+
// A record from an earlier version may still carry the service of the other method.
|
|
144
|
+
const artifactMethod = parsedDid.method === 'webvh' ? 'webvh' : 'web';
|
|
145
|
+
const artifactServicesChanged = !(0, artifactServices_1.artifactServicesMatch)(didDocument, {
|
|
146
|
+
method: artifactMethod,
|
|
147
|
+
publicApiBaseUrl: this.publicApiBaseUrl,
|
|
148
|
+
});
|
|
149
|
+
if (keyAgreementKey || servicesChanged || adminEntryChanged || artifactServicesChanged) {
|
|
156
150
|
if (servicesChanged && ed25519VerificationMethodId) {
|
|
157
151
|
didDocument.service = [
|
|
158
152
|
...(didDocument.service
|
|
@@ -161,46 +155,47 @@ class VsAgent extends core_1.Agent {
|
|
|
161
155
|
...this.getDidCommServices(didDocument.id, ed25519VerificationMethodId),
|
|
162
156
|
];
|
|
163
157
|
}
|
|
158
|
+
(0, artifactServices_1.applyArtifactServices)(didDocument, {
|
|
159
|
+
method: artifactMethod,
|
|
160
|
+
publicApiBaseUrl: this.publicApiBaseUrl,
|
|
161
|
+
});
|
|
164
162
|
this.applyAdminApiService(didDocument);
|
|
165
|
-
const newKeys = [];
|
|
166
|
-
if (hasLegacyMethods) {
|
|
167
|
-
newKeys.push(await this.createAndAddDidCommKeysAndServices(didDocument));
|
|
168
|
-
}
|
|
169
|
-
if (authHasUpdateKey)
|
|
170
|
-
didDocument.authentication = [ed25519VerificationMethodId];
|
|
171
|
-
if (newKeys.length && parsedDid.method === 'webvh') {
|
|
172
|
-
// webvh registrar doesn't accept keys in update options; persist directly
|
|
173
|
-
for (const key of newKeys)
|
|
174
|
-
await this.persistDidDocumentKey(didDocument.id, key);
|
|
175
|
-
}
|
|
176
163
|
// The webvh registrar returns state:"failed" WITHOUT throwing, so an unchecked update
|
|
177
164
|
// silently no-ops. Check the result and surface the reason instead of assuming success.
|
|
178
|
-
const updateResult = await this.dids.update(
|
|
165
|
+
const updateResult = await this.dids.update({ did: didDocument.id, didDocument });
|
|
179
166
|
if (updateResult.didState.state !== 'finished') {
|
|
180
|
-
(
|
|
181
|
-
did: didDocument.id,
|
|
182
|
-
state: updateResult.didState.state,
|
|
183
|
-
reason: updateResult.didState.reason,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
(_h = this.logger) === null || _h === void 0 ? void 0 : _h.debug('Public did record updated');
|
|
167
|
+
throw new core_1.CredoError(`Cannot update DID ${didDocument.id}: ${(_h = updateResult.didState.reason) !== null && _h !== void 0 ? _h : 'unknown reason'}`);
|
|
188
168
|
}
|
|
169
|
+
// Mapped only once the document publishes the key, so an interrupted update is retried on the next start
|
|
170
|
+
if (keyAgreementKey)
|
|
171
|
+
await this.addDidKey(didDocument.id, keyAgreementKey);
|
|
172
|
+
(_j = this.logger) === null || _j === void 0 ? void 0 : _j.debug('Public did record updated');
|
|
189
173
|
}
|
|
190
174
|
else {
|
|
191
|
-
(
|
|
175
|
+
(_k = this.logger) === null || _k === void 0 ? void 0 : _k.debug('Existing DID record found. No updates');
|
|
192
176
|
}
|
|
193
177
|
this.did = existingRecord.did;
|
|
178
|
+
await this.ensureSharedPublicDidInvitation();
|
|
194
179
|
}
|
|
195
180
|
}
|
|
181
|
+
// Credo refuses implicit connections to a public DID that the agent dialed peers from, unless a
|
|
182
|
+
// shared invitation names it. This one keeps the public DID open and is never shown.
|
|
183
|
+
async ensureSharedPublicDidInvitation() {
|
|
184
|
+
const agent = this;
|
|
185
|
+
if (!agent.did || !agent.didcomm.config.didcommVersions.includes('v2'))
|
|
186
|
+
return;
|
|
187
|
+
const [invitation] = await agent.didcomm.oob.findAllByQuery({ role: didcomm_1.DidCommOutOfBandRole.Sender, recipientDid: agent.did, sharedRecipientDid: true }, { limit: 1 });
|
|
188
|
+
if (!invitation)
|
|
189
|
+
await (0, agent_1.createInvitation)({ agent });
|
|
190
|
+
}
|
|
196
191
|
async findCreatedDid(parsedDid) {
|
|
197
192
|
const didRepository = this.dependencyManager.resolve(core_1.DidRepository);
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
193
|
+
// Method-scoped on purpose: a location change must surface as a mismatch error in
|
|
194
|
+
// initialize, never as a lookup miss that silently mints a second DID
|
|
195
|
+
return await didRepository.findSingleByQuery(this.context, {
|
|
196
|
+
method: parsedDid.method,
|
|
197
|
+
role: core_1.DidDocumentRole.Created,
|
|
198
|
+
});
|
|
204
199
|
}
|
|
205
200
|
// Prefer Ed25519VerificationKey2020 over Multikey: webvh's update Multikey is not ours to use.
|
|
206
201
|
findEd25519VerificationMethodId(didDocument) {
|
|
@@ -243,55 +238,39 @@ class VsAgent extends core_1.Agent {
|
|
|
243
238
|
});
|
|
244
239
|
return services;
|
|
245
240
|
}
|
|
246
|
-
|
|
241
|
+
// DIDs created by earlier versions publish an X25519 key derived from the Ed25519 key, with no KMS key of its own
|
|
242
|
+
async replaceDerivedKeyAgreementKey(didRecord, didDocument) {
|
|
243
|
+
var _a, _b, _c;
|
|
244
|
+
const keyAgreementId = `${didDocument.id}#${KEY_AGREEMENT_FRAGMENT}`;
|
|
245
|
+
const verificationMethod = (_a = didDocument.verificationMethod) === null || _a === void 0 ? void 0 : _a.find(vm => vm.id === keyAgreementId);
|
|
246
|
+
if (!verificationMethod)
|
|
247
|
+
return;
|
|
248
|
+
if ((_b = didRecord.keys) === null || _b === void 0 ? void 0 : _b.some(({ didDocumentRelativeKeyId }) => keyAgreementId.endsWith(didDocumentRelativeKeyId))) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.info(`Key agreement key of ${didDocument.id} has no KMS key. Replacing it with a new X25519 key`);
|
|
252
|
+
const { key, publicKeyMultibase } = await this.createKeyAgreementKey();
|
|
253
|
+
verificationMethod.publicKeyMultibase = publicKeyMultibase;
|
|
254
|
+
return key;
|
|
255
|
+
}
|
|
256
|
+
async createKeyAgreementKey() {
|
|
257
|
+
const kms = this.agentContext.resolve(core_1.Kms.KeyManagementApi);
|
|
258
|
+
const { keyId, publicJwk } = await kms.createKey({ type: { kty: 'OKP', crv: 'X25519' } });
|
|
259
|
+
return {
|
|
260
|
+
key: { kmsKeyId: keyId, didDocumentRelativeKeyId: `#${KEY_AGREEMENT_FRAGMENT}` },
|
|
261
|
+
publicKeyMultibase: core_1.Kms.PublicJwk.fromPublicJwk(publicJwk).fingerprint,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
async addDidKey(did, key) {
|
|
247
265
|
var _a;
|
|
248
266
|
const didRepository = this.agentContext.resolve(core_1.DidRepository);
|
|
249
267
|
const [record] = await didRepository.findByQuery(this.agentContext, { did });
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return;
|
|
255
|
-
record.keys = [...existing, key];
|
|
268
|
+
record.keys = [
|
|
269
|
+
...((_a = record.keys) !== null && _a !== void 0 ? _a : []).filter(({ didDocumentRelativeKeyId }) => didDocumentRelativeKeyId !== key.didDocumentRelativeKeyId),
|
|
270
|
+
key,
|
|
271
|
+
];
|
|
256
272
|
await didRepository.update(this.agentContext, record);
|
|
257
273
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Fix a webvh update-key mapping whose `didDocumentRelativeKeyId` was stored as the full multibase
|
|
260
|
-
* (e.g. `#z6Mk...`) while the DID document verification method uses a short fragment (e.g. `#BVhGnL79`).
|
|
261
|
-
* `getKmsKeyIdForVerifiacationMethod` matches by suffix (`vm.id.endsWith(relativeKeyId)`), so the
|
|
262
|
-
* mismatch leaves the update key unresolvable and every webvh update fails with
|
|
263
|
-
* "The key ID must be present before the log can be edited." The private key is present in the KMS;
|
|
264
|
-
* only the mapping label is wrong. Idempotent: a mapping that already correlates to a VM is left alone.
|
|
265
|
-
*/
|
|
266
|
-
async repairWebvhUpdateKeyMapping(record) {
|
|
267
|
-
var _a, _b, _c;
|
|
268
|
-
if (!record.didDocument || !((_a = record.keys) === null || _a === void 0 ? void 0 : _a.length))
|
|
269
|
-
return;
|
|
270
|
-
const vms = (_b = record.didDocument.verificationMethod) !== null && _b !== void 0 ? _b : [];
|
|
271
|
-
let repaired = false;
|
|
272
|
-
for (const key of record.keys) {
|
|
273
|
-
const rel = key.didDocumentRelativeKeyId;
|
|
274
|
-
if (vms.some(vm => vm.id.endsWith(rel)))
|
|
275
|
-
continue; // already correlates
|
|
276
|
-
const vm = vms.find(v => `#${v.publicKeyMultibase}` === rel); // was stored as #<multibase>
|
|
277
|
-
if (!vm)
|
|
278
|
-
continue;
|
|
279
|
-
const correct = `#${vm.id.split('#')[1]}`;
|
|
280
|
-
if (correct !== rel) {
|
|
281
|
-
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.warn('Fixing webvh update-key mapping', {
|
|
282
|
-
from: rel,
|
|
283
|
-
to: correct,
|
|
284
|
-
kmsKeyId: key.kmsKeyId,
|
|
285
|
-
});
|
|
286
|
-
key.didDocumentRelativeKeyId = correct;
|
|
287
|
-
repaired = true;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (repaired) {
|
|
291
|
-
const didRepository = this.dependencyManager.resolve(core_1.DidRepository);
|
|
292
|
-
await didRepository.update(this.agentContext, record);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
274
|
async createAndAddDidCommKeysAndServices(didDocument) {
|
|
296
275
|
var _a, _b, _c, _d, _e;
|
|
297
276
|
const publicDid = didDocument.id;
|
|
@@ -300,7 +279,7 @@ class VsAgent extends core_1.Agent {
|
|
|
300
279
|
'https://w3id.org/security/suites/ed25519-2020/v1',
|
|
301
280
|
'https://w3id.org/security/suites/x25519-2019/v1',
|
|
302
281
|
];
|
|
303
|
-
const keyAgreementId = `${publicDid}
|
|
282
|
+
const keyAgreementId = `${publicDid}#${KEY_AGREEMENT_FRAGMENT}`;
|
|
304
283
|
const kms = this.agentContext.resolve(core_1.Kms.KeyManagementApi);
|
|
305
284
|
// Create didcomm keys
|
|
306
285
|
const key = await kms.createKey({ type: { kty: 'OKP', crv: 'Ed25519' } });
|
|
@@ -311,8 +290,7 @@ class VsAgent extends core_1.Agent {
|
|
|
311
290
|
didDocumentRelativeKeyId: `#${publicKeyMultibase}`,
|
|
312
291
|
};
|
|
313
292
|
const verificationMethodId = `${publicDid}#${publicKeyMultibase}`;
|
|
314
|
-
const
|
|
315
|
-
const x25519Key = core_1.Kms.PublicJwk.fromPublicKey({ kty: 'OKP', crv: 'X25519', publicKey: publicKeyX25519 });
|
|
293
|
+
const keyAgreementKey = await this.createKeyAgreementKey();
|
|
316
294
|
// Remove legacy if exist
|
|
317
295
|
const legacyContexts = ['https://w3id.org/security/suites/ed25519-2018/v1'];
|
|
318
296
|
const legacyAuthId = (_b = ((_a = didDocument.verificationMethod) !== null && _a !== void 0 ? _a : []).find(vm => ['Ed25519VerificationKey2018'].includes(vm.type))) === null || _b === void 0 ? void 0 : _b.id;
|
|
@@ -331,7 +309,7 @@ class VsAgent extends core_1.Agent {
|
|
|
331
309
|
{
|
|
332
310
|
controller: publicDid,
|
|
333
311
|
id: keyAgreementId,
|
|
334
|
-
publicKeyMultibase:
|
|
312
|
+
publicKeyMultibase: keyAgreementKey.publicKeyMultibase,
|
|
335
313
|
type: 'Multikey',
|
|
336
314
|
},
|
|
337
315
|
];
|
|
@@ -359,66 +337,15 @@ class VsAgent extends core_1.Agent {
|
|
|
359
337
|
: []),
|
|
360
338
|
...didcommServices,
|
|
361
339
|
];
|
|
362
|
-
return didDocumentKey;
|
|
340
|
+
return [didDocumentKey, keyAgreementKey.key];
|
|
363
341
|
}
|
|
364
|
-
|
|
365
|
-
var _a
|
|
366
|
-
const publicDid = didDocument.id;
|
|
367
|
-
didDocument.service = [
|
|
368
|
-
...((_a = didDocument.service) !== null && _a !== void 0 ? _a : []),
|
|
369
|
-
...[
|
|
370
|
-
new core_1.DidDocumentService({
|
|
371
|
-
id: `${publicDid}#vpr-ecs-service-c-vp`,
|
|
372
|
-
serviceEndpoint: `${this.publicApiBaseUrl}/vt/ecs-service-c-vp.json`,
|
|
373
|
-
type: 'LinkedVerifiablePresentation',
|
|
374
|
-
}),
|
|
375
|
-
new core_1.DidDocumentService({
|
|
376
|
-
id: `${publicDid}#vpr-ecs-org-c-vp`,
|
|
377
|
-
serviceEndpoint: `${this.publicApiBaseUrl}/vt/ecs-org-c-vp.json`,
|
|
378
|
-
type: 'LinkedVerifiablePresentation',
|
|
379
|
-
}),
|
|
380
|
-
],
|
|
381
|
-
];
|
|
342
|
+
addLinkedVpContext(didDocument) {
|
|
343
|
+
var _a;
|
|
382
344
|
didDocument.context = [
|
|
383
|
-
...((
|
|
345
|
+
...((_a = didDocument.context) !== null && _a !== void 0 ? _a : []),
|
|
384
346
|
'https://identity.foundation/linked-vp/contexts/v1',
|
|
385
347
|
];
|
|
386
348
|
}
|
|
387
|
-
/**
|
|
388
|
-
* Basic implicit webvh services, for the moment pointing to the service VP
|
|
389
|
-
* and public base URL
|
|
390
|
-
*/
|
|
391
|
-
async createAndAddWebVhImplicitServices(didDocument) {
|
|
392
|
-
var _a;
|
|
393
|
-
const publicDid = didDocument.id;
|
|
394
|
-
didDocument.service = [
|
|
395
|
-
...((_a = didDocument.service) !== null && _a !== void 0 ? _a : []),
|
|
396
|
-
...[
|
|
397
|
-
new core_1.DidDocumentService({
|
|
398
|
-
id: `${publicDid}#whois`,
|
|
399
|
-
serviceEndpoint: `${this.publicApiBaseUrl}/vt/ecs-service-c-vp.json`,
|
|
400
|
-
type: 'LinkedVerifiablePresentation',
|
|
401
|
-
}),
|
|
402
|
-
new core_1.DidDocumentService({
|
|
403
|
-
id: `${publicDid}#files`,
|
|
404
|
-
serviceEndpoint: `${this.publicApiBaseUrl}`,
|
|
405
|
-
type: 'relativeRef',
|
|
406
|
-
}),
|
|
407
|
-
],
|
|
408
|
-
];
|
|
409
|
-
}
|
|
410
|
-
async createAndAddAnonCredsServices(didDocument) {
|
|
411
|
-
var _a;
|
|
412
|
-
const publicDid = didDocument.id;
|
|
413
|
-
didDocument.service = [
|
|
414
|
-
...((_a = didDocument.service) !== null && _a !== void 0 ? _a : []),
|
|
415
|
-
new core_1.DidDocumentService({
|
|
416
|
-
id: `${publicDid}#anoncreds`,
|
|
417
|
-
serviceEndpoint: `${this.publicApiBaseUrl}/anoncreds/v1`,
|
|
418
|
-
type: 'AnonCredsRegistry',
|
|
419
|
-
}),
|
|
420
|
-
];
|
|
421
|
-
}
|
|
422
349
|
applyAdminApiService(didDocument) {
|
|
423
350
|
(0, adminApiService_1.applyAdminApiServiceEntry)(didDocument, this.adminApiServiceEndpoint);
|
|
424
351
|
}
|