@verana-labs/vs-agent-sdk 2.0.0-dev.6 → 2.0.0-dev.61
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 +25 -0
- package/build/adminApi/AdminApiError.js +57 -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 +3 -0
- package/build/adminApi/index.js +20 -0
- package/build/adminApi/index.js.map +1 -0
- package/build/adminApi/moduleEndpoint.d.ts +8 -0
- package/build/adminApi/moduleEndpoint.js +28 -0
- package/build/adminApi/moduleEndpoint.js.map +1 -0
- package/build/agent/VsAgent.d.ts +15 -33
- package/build/agent/VsAgent.js +75 -205
- package/build/agent/VsAgent.js.map +1 -1
- package/build/agent/createVsAgent.d.ts +5 -5
- package/build/agent/createVsAgent.js +3 -5
- package/build/agent/createVsAgent.js.map +1 -1
- package/build/blockchain/AnonCredsTrustService.d.ts +62 -0
- package/build/blockchain/AnonCredsTrustService.js +256 -0
- package/build/blockchain/AnonCredsTrustService.js.map +1 -0
- package/build/blockchain/AuthorizationService.d.ts +5 -3
- package/build/blockchain/AuthorizationService.js +17 -29
- package/build/blockchain/AuthorizationService.js.map +1 -1
- package/build/blockchain/IndexerWebSocketService.d.ts +7 -1
- package/build/blockchain/IndexerWebSocketService.js +68 -36
- package/build/blockchain/IndexerWebSocketService.js.map +1 -1
- package/build/blockchain/VeranaChainService.d.ts +2 -13
- package/build/blockchain/VeranaChainService.js +8 -113
- 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/handlers/authorizationHandlers.js +2 -2
- package/build/blockchain/handlers/authorizationHandlers.js.map +1 -1
- package/build/blockchain/handlers/defaultHandlers.js +2 -0
- 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 +71 -0
- package/build/blockchain/handlers/selfIssuanceHandlers.js.map +1 -0
- package/build/blockchain/handlers/stateMutations.d.ts +21 -2
- package/build/blockchain/handlers/stateMutations.js +280 -34
- package/build/blockchain/handlers/stateMutations.js.map +1 -1
- package/build/blockchain/index.d.ts +2 -0
- package/build/blockchain/index.js +2 -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/types.d.ts +5 -57
- package/build/blockchain/types.js.map +1 -1
- package/build/bootstrap/EcsBootstrapService.d.ts +14 -3
- package/build/bootstrap/EcsBootstrapService.js +155 -76
- package/build/bootstrap/EcsBootstrapService.js.map +1 -1
- 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 +139 -5
- package/build/events/BaseMessageEvents.js.map +1 -1
- package/build/events/ConnectionEvents.js +110 -82
- package/build/events/ConnectionEvents.js.map +1 -1
- package/build/events/VsAgentEvents.d.ts +11 -9
- package/build/events/VsAgentEvents.js +8 -1
- package/build/events/VsAgentEvents.js.map +1 -1
- package/build/events/VtFlowEvents.d.ts +1 -1
- package/build/events/VtFlowEvents.js +2 -19
- package/build/events/VtFlowEvents.js.map +1 -1
- package/build/index.d.ts +6 -1
- package/build/index.js +10 -2
- package/build/index.js.map +1 -1
- package/build/plugins/setupBaseDidComm.js +6 -12
- package/build/plugins/setupBaseDidComm.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 +5 -0
- package/build/types.js.map +1 -1
- package/build/utils/agent.d.ts +29 -4
- package/build/utils/agent.js +91 -22
- package/build/utils/agent.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 +47 -0
- package/build/utils/ecsClaims.js +120 -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 +4 -0
- package/build/utils/index.js +4 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/selfIssuedEcsCredential.d.ts +8 -0
- package/build/utils/selfIssuedEcsCredential.js +151 -0
- package/build/utils/selfIssuedEcsCredential.js.map +1 -0
- package/build/utils/setupSelfTr.d.ts +29 -66
- package/build/utils/setupSelfTr.js +78 -282
- package/build/utils/setupSelfTr.js.map +1 -1
- package/build/utils/trustCredentialStore.d.ts +67 -9
- package/build/utils/trustCredentialStore.js +296 -109
- package/build/utils/trustCredentialStore.js.map +1 -1
- package/build/utils/util.d.ts +10 -0
- package/build/utils/util.js +16 -0
- package/build/utils/util.js.map +1 -1
- package/build/utils/vcdm2.d.ts +34 -0
- package/build/utils/vcdm2.js +62 -0
- package/build/utils/vcdm2.js.map +1 -0
- package/build/utils/vtjscResolver.d.ts +18 -0
- package/build/utils/vtjscResolver.js +54 -0
- package/build/utils/vtjscResolver.js.map +1 -0
- package/build/vtFlow/VtFlowOrchestrator.d.ts +59 -13
- package/build/vtFlow/VtFlowOrchestrator.js +140 -92
- package/build/vtFlow/VtFlowOrchestrator.js.map +1 -1
- package/build/vtFlow/assertVerifiableService.d.ts +1 -0
- package/build/vtFlow/assertVerifiableService.js +45 -5
- 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 +12 -12
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VsAgentWsInboundTransport.js","sourceRoot":"","sources":["../../src/transports/VsAgentWsInboundTransport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAwE;AACxE,+CAQ0B;AAC1B,yCAAsC;AAQtC,MAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"VsAgentWsInboundTransport.js","sourceRoot":"","sources":["../../src/transports/VsAgentWsInboundTransport.ts"],"names":[],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
16
16
|
modules: Record<string, unknown>;
|
|
17
17
|
};
|
|
18
|
+
export interface DidcommModule {
|
|
19
|
+
module: string;
|
|
20
|
+
prefixes: string[];
|
|
21
|
+
}
|
|
18
22
|
export interface VsAgentNestPlugin {
|
|
19
23
|
name: string;
|
|
20
24
|
credoPlugin?: Plugin;
|
|
21
25
|
controllers?: (new (...args: any[]) => any)[];
|
|
22
26
|
providers?: any[];
|
|
23
27
|
messageHandlers?: (new (...args: any[]) => MessageHandler)[];
|
|
28
|
+
didcommModules?: DidcommModule[];
|
|
24
29
|
imports?: any[];
|
|
25
30
|
registerEvents?: (agent: VsAgent<BaseAgentModules>, logger: BaseLogger) => void;
|
|
26
31
|
}
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAMa,QAAA,gBAAgB,GAAG,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAMa,QAAA,gBAAgB,GAAG,kBAAkB,CAAA;AA8BrC,QAAA,uBAAuB,GAAG,CAAC,CAAA;AAC3B,QAAA,yBAAyB,GAAG,CAAC,CAAA;AAC7B,QAAA,+BAA+B,GAAG,CAAC,CAAA;AACnC,QAAA,iCAAiC,GAAG,CAAC,CAAA;AACrC,QAAA,uBAAuB,GAAG,CAAC,CAAA"}
|
package/build/utils/agent.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { VsAgent } from '../agent/VsAgent';
|
|
2
|
-
import {
|
|
2
|
+
import { GenericRecord, TagsBase } from '@credo-ts/core';
|
|
3
|
+
import { type DidCommConnectionRecord, DidCommMessage, type DidCommVersion } from '@credo-ts/didcomm';
|
|
3
4
|
/**
|
|
4
5
|
* Creates an out of band invitation that will equal to the public DID in case the agent has one defined,
|
|
5
6
|
* and a new one every time in case the agent does not have any public DID.
|
|
@@ -11,11 +12,35 @@ export declare function createInvitation(options: {
|
|
|
11
12
|
agent: VsAgent;
|
|
12
13
|
messages?: DidCommMessage[];
|
|
13
14
|
useLegacyDid?: boolean;
|
|
14
|
-
invitationBaseUrl: string;
|
|
15
|
-
imageUrl?: string;
|
|
16
15
|
didCommVersion?: DidCommVersion;
|
|
17
16
|
}): Promise<{
|
|
17
|
+
invitation: import("@credo-ts/didcomm").DidCommPlaintextMessage;
|
|
18
|
+
outOfBandInvitation: import("@credo-ts/didcomm").DidCommOutOfBandInvitation;
|
|
18
19
|
url: string;
|
|
19
20
|
}>;
|
|
21
|
+
export declare function isUsableConnectionTo(connection: DidCommConnectionRecord, peerPublicDid: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Connects to a peer that publishes a public DID, and reuses the connection that the
|
|
24
|
+
* agent already has to that peer.
|
|
25
|
+
*
|
|
26
|
+
* The agent must keep one connection record only for each peer. A second record for the
|
|
27
|
+
* same pair of DIDs makes the `findByDids` lookup of the message receiver throw
|
|
28
|
+
* `RecordDuplicateError`, and the agent then fails to process every inbound message from
|
|
29
|
+
* that peer. To find the existing record, the agent reads the `publicDid` tag that it
|
|
30
|
+
* sets on each connection to a peer that publishes a public DID.
|
|
31
|
+
*
|
|
32
|
+
* @param agent the local agent
|
|
33
|
+
* @param peerPublicDid the public DID of the peer
|
|
34
|
+
* @returns the id of a ready connection record
|
|
35
|
+
*/
|
|
36
|
+
export declare function connectToPublicDid(agent: VsAgent, peerPublicDid: string): Promise<string>;
|
|
20
37
|
export declare function getRecordId(agent: VsAgent, id: string): Promise<string>;
|
|
21
|
-
|
|
38
|
+
/** The record type of every attested resource of the AnonCreds registry, per [VSA-PUB-AC]. */
|
|
39
|
+
export declare const ATTESTED_RESOURCE_TYPE = "AttestedResource";
|
|
40
|
+
export type AttestedResourceTags = TagsBase & {
|
|
41
|
+
type?: never;
|
|
42
|
+
attestedResourceId?: never;
|
|
43
|
+
};
|
|
44
|
+
export declare function saveAttestedResource(agent: VsAgent, resource: Record<string, unknown>, tags?: AttestedResourceTags): Promise<GenericRecord | undefined>;
|
|
45
|
+
export declare function findAttestedResources(agent: VsAgent, query: TagsBase): Promise<GenericRecord[]>;
|
|
46
|
+
export declare function findAttestedResource(agent: VsAgent, query: TagsBase): Promise<GenericRecord | undefined>;
|
package/build/utils/agent.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ATTESTED_RESOURCE_TYPE = void 0;
|
|
3
4
|
exports.createInvitation = createInvitation;
|
|
5
|
+
exports.isUsableConnectionTo = isUsableConnectionTo;
|
|
6
|
+
exports.connectToPublicDid = connectToPublicDid;
|
|
4
7
|
exports.getRecordId = getRecordId;
|
|
5
|
-
exports.
|
|
8
|
+
exports.saveAttestedResource = saveAttestedResource;
|
|
9
|
+
exports.findAttestedResources = findAttestedResources;
|
|
10
|
+
exports.findAttestedResource = findAttestedResource;
|
|
6
11
|
const core_1 = require("@credo-ts/core");
|
|
7
12
|
const didcomm_1 = require("@credo-ts/didcomm");
|
|
13
|
+
const credo_ts_didcomm_vt_flow_1 = require("@verana-labs/credo-ts-didcomm-vt-flow");
|
|
14
|
+
const legacyDidWeb_1 = require("../did/legacyDidWeb");
|
|
15
|
+
const ecsService_1 = require("./ecsService");
|
|
8
16
|
/**
|
|
9
17
|
* Creates an out of band invitation that will equal to the public DID in case the agent has one defined,
|
|
10
18
|
* and a new one every time in case the agent does not have any public DID.
|
|
@@ -13,43 +21,104 @@ const didcomm_1 = require("@credo-ts/didcomm");
|
|
|
13
21
|
* @returns
|
|
14
22
|
*/
|
|
15
23
|
async function createInvitation(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const ourDid = agent.did
|
|
19
|
-
|
|
20
|
-
: agent.did;
|
|
21
|
-
const effectiveVersion = didCommVersion !== null && didCommVersion !== void 0 ? didCommVersion : (agent.didcomm.config.sendsV2 ? 'v2' : 'v1');
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
const { agent, messages, useLegacyDid, didCommVersion } = options;
|
|
26
|
+
const ourDid = (_a = (useLegacyDid && agent.did ? (0, legacyDidWeb_1.getLegacyDidWeb)(agent.did) : undefined)) !== null && _a !== void 0 ? _a : agent.did;
|
|
27
|
+
const effectiveVersion = didCommVersion !== null && didCommVersion !== void 0 ? didCommVersion : 'v2';
|
|
22
28
|
const isV2 = effectiveVersion === 'v2';
|
|
23
29
|
if (!agent.didcomm.config.didcommVersions.includes(effectiveVersion)) {
|
|
24
30
|
throw new Error(`Cannot create ${effectiveVersion} invitation: agent is configured with ` +
|
|
25
31
|
`didcommVersions: [${agent.didcomm.config.didcommVersions.join(', ')}]. ` +
|
|
26
|
-
`Add "${effectiveVersion}" to
|
|
32
|
+
`Add "${effectiveVersion}" to the agent's didcommVersions configuration.`);
|
|
27
33
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
34
|
+
const claims = await (0, ecsService_1.ecsServiceClaims)(agent);
|
|
35
|
+
const outOfBandInvitation = (await agent.didcomm.oob.createInvitation(Object.assign({ label: claims === null || claims === void 0 ? void 0 : claims.name, multiUseInvitation: !messages, imageUrl: claims === null || claims === void 0 ? void 0 : claims.logoUri, messages, didCommVersion: effectiveVersion }, (isV2
|
|
30
36
|
? { ourDid }
|
|
31
37
|
: {
|
|
32
|
-
handshakeProtocols: [didcomm_1.DidCommHandshakeProtocol.DidExchange
|
|
38
|
+
handshakeProtocols: [didcomm_1.DidCommHandshakeProtocol.DidExchange],
|
|
33
39
|
invitationDid: ourDid,
|
|
34
40
|
})))).outOfBandInvitation;
|
|
35
41
|
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}),
|
|
42
|
+
invitation: (_c = (_b = outOfBandInvitation.v2Invitation) === null || _b === void 0 ? void 0 : _b.toJSON()) !== null && _c !== void 0 ? _c : outOfBandInvitation.toJSON(),
|
|
43
|
+
outOfBandInvitation,
|
|
44
|
+
url: outOfBandInvitation.toUrl({ domain: agent.publicApiBaseUrl }),
|
|
39
45
|
};
|
|
40
46
|
}
|
|
47
|
+
function isUsableConnectionTo(connection, peerPublicDid) {
|
|
48
|
+
return connection.isReady && !!connection.theirDid && (0, credo_ts_didcomm_vt_flow_1.peerAnchorDid)(connection) === peerPublicDid;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Connects to a peer that publishes a public DID, and reuses the connection that the
|
|
52
|
+
* agent already has to that peer.
|
|
53
|
+
*
|
|
54
|
+
* The agent must keep one connection record only for each peer. A second record for the
|
|
55
|
+
* same pair of DIDs makes the `findByDids` lookup of the message receiver throw
|
|
56
|
+
* `RecordDuplicateError`, and the agent then fails to process every inbound message from
|
|
57
|
+
* that peer. To find the existing record, the agent reads the `publicDid` tag that it
|
|
58
|
+
* sets on each connection to a peer that publishes a public DID.
|
|
59
|
+
*
|
|
60
|
+
* @param agent the local agent
|
|
61
|
+
* @param peerPublicDid the public DID of the peer
|
|
62
|
+
* @returns the id of a ready connection record
|
|
63
|
+
*/
|
|
64
|
+
async function connectToPublicDid(agent, peerPublicDid) {
|
|
65
|
+
if (!agent.did)
|
|
66
|
+
throw new Error('Agent has no public DID');
|
|
67
|
+
const [existing] = await agent.didcomm.connections.findAllByQuery({
|
|
68
|
+
publicDid: peerPublicDid,
|
|
69
|
+
});
|
|
70
|
+
if (existing) {
|
|
71
|
+
if (isUsableConnectionTo(existing, peerPublicDid))
|
|
72
|
+
return existing.id;
|
|
73
|
+
await agent.didcomm.connections.deleteById(existing.id);
|
|
74
|
+
}
|
|
75
|
+
const { connectionRecord } = await agent.didcomm.oob.receiveImplicitInvitation({
|
|
76
|
+
did: peerPublicDid,
|
|
77
|
+
ourDid: agent.did,
|
|
78
|
+
label: await (0, ecsService_1.agentDisplayName)(agent),
|
|
79
|
+
didCommVersion: 'v2',
|
|
80
|
+
});
|
|
81
|
+
if (!connectionRecord)
|
|
82
|
+
throw new Error(`Failed to establish a DIDComm connection to ${peerPublicDid}`);
|
|
83
|
+
try {
|
|
84
|
+
// Tag the record with the public DID of the peer, to find it on the next call.
|
|
85
|
+
connectionRecord.setTag('publicDid', peerPublicDid);
|
|
86
|
+
await agent.context.resolve(didcomm_1.DidCommConnectionRepository).update(agent.context, connectionRecord);
|
|
87
|
+
const ready = await agent.didcomm.connections.returnWhenIsConnected(connectionRecord.id);
|
|
88
|
+
return ready.id;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// Without the tag, the next call cannot find this record. It dials again and leaves two
|
|
92
|
+
// records for the pair. The message receiver's findByDids then throws RecordDuplicateError.
|
|
93
|
+
await agent.didcomm.connections.deleteById(connectionRecord.id).catch(deleteError => {
|
|
94
|
+
agent.config.logger.warn(`Failed to delete the incomplete connection ${connectionRecord.id}`, {
|
|
95
|
+
error: deleteError,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
41
101
|
async function getRecordId(agent, id) {
|
|
42
102
|
var _a;
|
|
43
103
|
const record = await agent.genericRecords.findById(id);
|
|
44
104
|
return (_a = record === null || record === void 0 ? void 0 : record.getTag('messageId')) !== null && _a !== void 0 ? _a : id;
|
|
45
105
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
106
|
+
/** The record type of every attested resource of the AnonCreds registry, per [VSA-PUB-AC]. */
|
|
107
|
+
exports.ATTESTED_RESOURCE_TYPE = 'AttestedResource';
|
|
108
|
+
async function saveAttestedResource(agent, resource, tags) {
|
|
109
|
+
if (!resource)
|
|
110
|
+
return undefined;
|
|
111
|
+
return await agent.genericRecords.save({
|
|
112
|
+
id: core_1.utils.uuid(),
|
|
113
|
+
content: resource,
|
|
114
|
+
tags: Object.assign({ attestedResourceId: resource.id, type: exports.ATTESTED_RESOURCE_TYPE }, tags),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async function findAttestedResources(agent, query) {
|
|
118
|
+
return await agent.genericRecords.findAllByQuery(Object.assign(Object.assign({}, query), { type: exports.ATTESTED_RESOURCE_TYPE }));
|
|
119
|
+
}
|
|
120
|
+
async function findAttestedResource(agent, query) {
|
|
121
|
+
const [record] = await findAttestedResources(agent, query);
|
|
122
|
+
return record;
|
|
54
123
|
}
|
|
55
124
|
//# sourceMappingURL=agent.js.map
|
package/build/utils/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/utils/agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/utils/agent.ts"],"names":[],"mappings":";;;AAuBA,4CA0CC;AAED,oDAEC;AAgBD,gDAoCC;AAED,kCAGC;AAUD,oDAeC;AAED,sDAEC;AAED,oDAMC;AAjKD,yCAA+D;AAC/D,+CAM0B;AAC1B,oFAAqE;AAErE,sDAAqD;AAErD,6CAAiE;AAEjE;;;;;;GAMG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAKtC;;IACC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAA;IAEjE,MAAM,MAAM,GAAG,MAAA,CAAC,YAAY,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,8BAAe,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,mCAAI,KAAK,CAAC,GAAG,CAAA;IAEhG,MAAM,gBAAgB,GAAmB,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAI,CAAA;IAC/D,MAAM,IAAI,GAAG,gBAAgB,KAAK,IAAI,CAAA;IAEtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,iBAAiB,gBAA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C,KAAK,EAAE,KAAK,CAAC,CAAA;IAC1D,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger } from '@credo-ts/core';
|
|
2
|
+
import { VsAgent } from '../agent/VsAgent';
|
|
3
|
+
/**
|
|
4
|
+
* Waits until this agent's own DID document is fetchable at its public endpoint, so a peer
|
|
5
|
+
* can resolve it as soon as we reach out. Checks the same file a peer's resolver would fetch:
|
|
6
|
+
* did.jsonl for did:webvh, did.json for did:web. Logs and returns if the deadline passes,
|
|
7
|
+
* rather than blocking the caller forever on a misconfigured deployment.
|
|
8
|
+
*/
|
|
9
|
+
export declare function waitUntilOwnDidIsPubliclyResolvable(agent: VsAgent, logger: Logger): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitUntilOwnDidIsPubliclyResolvable = waitUntilOwnDidIsPubliclyResolvable;
|
|
4
|
+
// On a fresh deployment, the ingress route to this agent's own public endpoint
|
|
5
|
+
// can lag a few seconds behind the process becoming ready (e.g. a k8s Service
|
|
6
|
+
// has not finished propagating the new pod IP yet). A peer resolves our DID as
|
|
7
|
+
// part of processing any message we send it, so we wait for our own DID
|
|
8
|
+
// document to be publicly fetchable before reaching out to one.
|
|
9
|
+
const OWN_DID_READY_TIMEOUT_MS = 60000;
|
|
10
|
+
const OWN_DID_READY_POLL_INTERVAL_MS = 2000;
|
|
11
|
+
/**
|
|
12
|
+
* Waits until this agent's own DID document is fetchable at its public endpoint, so a peer
|
|
13
|
+
* can resolve it as soon as we reach out. Checks the same file a peer's resolver would fetch:
|
|
14
|
+
* did.jsonl for did:webvh, did.json for did:web. Logs and returns if the deadline passes,
|
|
15
|
+
* rather than blocking the caller forever on a misconfigured deployment.
|
|
16
|
+
*/
|
|
17
|
+
async function waitUntilOwnDidIsPubliclyResolvable(agent, logger) {
|
|
18
|
+
const did = agent.did;
|
|
19
|
+
if (!did || !agent.publicApiBaseUrl)
|
|
20
|
+
return;
|
|
21
|
+
const documentFile = did.startsWith('did:web:') ? 'did.json' : 'did.jsonl';
|
|
22
|
+
const baseUrl = agent.publicApiBaseUrl.replace(/\/+$/, '');
|
|
23
|
+
// A path-based DID location serves its document at <base>/did.json(l), not under /.well-known
|
|
24
|
+
const hasPath = new URL(baseUrl).pathname !== '/';
|
|
25
|
+
const url = hasPath ? `${baseUrl}/${documentFile}` : `${baseUrl}/.well-known/${documentFile}`;
|
|
26
|
+
const deadline = Date.now() + OWN_DID_READY_TIMEOUT_MS;
|
|
27
|
+
let lastStatus = 'unreachable';
|
|
28
|
+
while (Date.now() < deadline) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(url);
|
|
31
|
+
if (response.ok)
|
|
32
|
+
return;
|
|
33
|
+
lastStatus = response.status;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
lastStatus = error.message;
|
|
37
|
+
}
|
|
38
|
+
await new Promise(resolve => setTimeout(resolve, OWN_DID_READY_POLL_INTERVAL_MS));
|
|
39
|
+
}
|
|
40
|
+
logger.warn(`[DidReadiness] own DID document at ${url} was not publicly resolvable after ${OWN_DID_READY_TIMEOUT_MS}ms (last: ${lastStatus}); proceeding anyway`);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=didReadiness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"didReadiness.js","sourceRoot":"","sources":["../../src/utils/didReadiness.ts"],"names":[],"mappings":";;AAkBA,kFAyBC;AAvCD,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,gEAAgE;AAChE,MAAM,wBAAwB,GAAG,KAAM,CAAA;AACvC,MAAM,8BAA8B,GAAG,IAAK,CAAA;AAE5C;;;;;GAKG;AACI,KAAK,UAAU,mCAAmC,CAAC,KAAc,EAAE,MAAc;IACtF,MAAM,GAAG,GAAG,KA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type { Logger } from '@credo-ts/core';
|
|
2
|
+
export interface EcsClaims {
|
|
3
|
+
localResources?: Record<string, string>;
|
|
4
|
+
org?: Record<string, string | undefined>;
|
|
5
|
+
persona?: Record<string, string | undefined>;
|
|
6
|
+
service?: Record<string, string | undefined>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ECS_CLAIMS_VARIABLES: {
|
|
9
|
+
readonly org: {
|
|
10
|
+
readonly name: "ECS_CLAIMS_ORG_NAME";
|
|
11
|
+
readonly logoUri: "ECS_CLAIMS_ORG_LOGO_URI";
|
|
12
|
+
readonly registryId: "ECS_CLAIMS_ORG_REGISTRY_ID";
|
|
13
|
+
readonly registryUri: "ECS_CLAIMS_ORG_REGISTRY_URI";
|
|
14
|
+
readonly address: "ECS_CLAIMS_ORG_ADDRESS";
|
|
15
|
+
readonly countryCode: "ECS_CLAIMS_ORG_COUNTRY_CODE";
|
|
16
|
+
readonly legalJurisdiction: "ECS_CLAIMS_ORG_LEGAL_JURISDICTION";
|
|
17
|
+
readonly organizationKind: "ECS_CLAIMS_ORG_ORGANIZATION_KIND";
|
|
18
|
+
readonly lei: "ECS_CLAIMS_ORG_LEI";
|
|
19
|
+
};
|
|
20
|
+
readonly persona: {
|
|
21
|
+
readonly name: "ECS_CLAIMS_PERSONA_NAME";
|
|
22
|
+
readonly description: "ECS_CLAIMS_PERSONA_DESCRIPTION";
|
|
23
|
+
readonly descriptionFormat: "ECS_CLAIMS_PERSONA_DESCRIPTION_FORMAT";
|
|
24
|
+
readonly avatarUri: "ECS_CLAIMS_PERSONA_AVATAR_URI";
|
|
25
|
+
readonly controllerCountryCode: "ECS_CLAIMS_PERSONA_CONTROLLER_COUNTRY_CODE";
|
|
26
|
+
readonly controllerJurisdiction: "ECS_CLAIMS_PERSONA_CONTROLLER_JURISDICTION";
|
|
27
|
+
};
|
|
28
|
+
readonly service: {
|
|
29
|
+
readonly name: "ECS_CLAIMS_SERVICE_NAME";
|
|
30
|
+
readonly type: "ECS_CLAIMS_SERVICE_TYPE";
|
|
31
|
+
readonly description: "ECS_CLAIMS_SERVICE_DESCRIPTION";
|
|
32
|
+
readonly descriptionFormat: "ECS_CLAIMS_SERVICE_DESCRIPTION_FORMAT";
|
|
33
|
+
readonly logoUri: "ECS_CLAIMS_SERVICE_LOGO_URI";
|
|
34
|
+
readonly minimumAgeRequired: "ECS_CLAIMS_SERVICE_MINIMUM_AGE_REQUIRED";
|
|
35
|
+
readonly termsAndConditionsUri: "ECS_CLAIMS_SERVICE_TERMS_AND_CONDITIONS_URI";
|
|
36
|
+
readonly privacyPolicyUri: "ECS_CLAIMS_SERVICE_PRIVACY_POLICY_URI";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare function readEcsClaimsFromEnv(): Required<Pick<EcsClaims, 'org' | 'persona' | 'service'>>;
|
|
40
|
+
export declare function digestOf(content: string): string;
|
|
41
|
+
export declare function digestOfUri(uri: string, variable: string, logger?: Logger): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Compose the claims of one ECS credential from the configured variables, deriving `id` and
|
|
44
|
+
* every paired `*DigestSri`. Returns undefined when the operator configured no claim, so the
|
|
45
|
+
* caller can omit the `claims` field entirely.
|
|
46
|
+
*/
|
|
47
|
+
export declare function composeEcsClaims(claims: EcsClaims, schemaKey: string, logger?: Logger): Promise<Record<string, unknown> | undefined>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ECS_CLAIMS_VARIABLES = void 0;
|
|
7
|
+
exports.readEcsClaimsFromEnv = readEcsClaimsFromEnv;
|
|
8
|
+
exports.digestOf = digestOf;
|
|
9
|
+
exports.digestOfUri = digestOfUri;
|
|
10
|
+
exports.composeEcsClaims = composeEcsClaims;
|
|
11
|
+
const crypto_1 = require("crypto");
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
// the URI claim each derived digest claim is computed from
|
|
14
|
+
const DIGEST_OF = {
|
|
15
|
+
logoDigestSri: 'logoUri',
|
|
16
|
+
avatarDigestSri: 'avatarUri',
|
|
17
|
+
termsAndConditionsDigestSri: 'termsAndConditionsUri',
|
|
18
|
+
privacyPolicyDigestSri: 'privacyPolicyUri',
|
|
19
|
+
};
|
|
20
|
+
// [VSA-VTI-CFG-ENV-ECS] variable of each claim the agent reads
|
|
21
|
+
exports.ECS_CLAIMS_VARIABLES = {
|
|
22
|
+
org: {
|
|
23
|
+
name: 'ECS_CLAIMS_ORG_NAME',
|
|
24
|
+
logoUri: 'ECS_CLAIMS_ORG_LOGO_URI',
|
|
25
|
+
registryId: 'ECS_CLAIMS_ORG_REGISTRY_ID',
|
|
26
|
+
registryUri: 'ECS_CLAIMS_ORG_REGISTRY_URI',
|
|
27
|
+
address: 'ECS_CLAIMS_ORG_ADDRESS',
|
|
28
|
+
countryCode: 'ECS_CLAIMS_ORG_COUNTRY_CODE',
|
|
29
|
+
legalJurisdiction: 'ECS_CLAIMS_ORG_LEGAL_JURISDICTION',
|
|
30
|
+
organizationKind: 'ECS_CLAIMS_ORG_ORGANIZATION_KIND',
|
|
31
|
+
lei: 'ECS_CLAIMS_ORG_LEI',
|
|
32
|
+
},
|
|
33
|
+
persona: {
|
|
34
|
+
name: 'ECS_CLAIMS_PERSONA_NAME',
|
|
35
|
+
description: 'ECS_CLAIMS_PERSONA_DESCRIPTION',
|
|
36
|
+
descriptionFormat: 'ECS_CLAIMS_PERSONA_DESCRIPTION_FORMAT',
|
|
37
|
+
avatarUri: 'ECS_CLAIMS_PERSONA_AVATAR_URI',
|
|
38
|
+
controllerCountryCode: 'ECS_CLAIMS_PERSONA_CONTROLLER_COUNTRY_CODE',
|
|
39
|
+
controllerJurisdiction: 'ECS_CLAIMS_PERSONA_CONTROLLER_JURISDICTION',
|
|
40
|
+
},
|
|
41
|
+
service: {
|
|
42
|
+
name: 'ECS_CLAIMS_SERVICE_NAME',
|
|
43
|
+
type: 'ECS_CLAIMS_SERVICE_TYPE',
|
|
44
|
+
description: 'ECS_CLAIMS_SERVICE_DESCRIPTION',
|
|
45
|
+
descriptionFormat: 'ECS_CLAIMS_SERVICE_DESCRIPTION_FORMAT',
|
|
46
|
+
logoUri: 'ECS_CLAIMS_SERVICE_LOGO_URI',
|
|
47
|
+
minimumAgeRequired: 'ECS_CLAIMS_SERVICE_MINIMUM_AGE_REQUIRED',
|
|
48
|
+
termsAndConditionsUri: 'ECS_CLAIMS_SERVICE_TERMS_AND_CONDITIONS_URI',
|
|
49
|
+
privacyPolicyUri: 'ECS_CLAIMS_SERVICE_PRIVACY_POLICY_URI',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
function readEcsClaimsFromEnv() {
|
|
53
|
+
const read = (variables) => Object.fromEntries(Object.entries(variables).map(([claim, name]) => { var _a; return [claim, ((_a = process.env[name]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined]; }));
|
|
54
|
+
return {
|
|
55
|
+
org: read(exports.ECS_CLAIMS_VARIABLES.org),
|
|
56
|
+
persona: read(exports.ECS_CLAIMS_VARIABLES.persona),
|
|
57
|
+
service: read(exports.ECS_CLAIMS_VARIABLES.service),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const DIGEST_TIMEOUT_MS = 5000;
|
|
61
|
+
const DIGEST_ATTEMPTS = 4;
|
|
62
|
+
const DIGEST_BASE_DELAY_MS = 500;
|
|
63
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
64
|
+
// Generate a SHA-384 digest for the given content
|
|
65
|
+
function digestOf(content) {
|
|
66
|
+
return `sha384-${(0, crypto_1.createHash)('sha384').update(content).digest('base64')}`;
|
|
67
|
+
}
|
|
68
|
+
async function digestOfUri(uri, variable, logger) {
|
|
69
|
+
let lastError;
|
|
70
|
+
for (let attempt = 1; attempt <= DIGEST_ATTEMPTS; attempt++) {
|
|
71
|
+
try {
|
|
72
|
+
const response = await axios_1.default.get(uri, { responseType: 'arraybuffer', timeout: DIGEST_TIMEOUT_MS });
|
|
73
|
+
return `sha384-${(0, crypto_1.createHash)('sha384').update(Buffer.from(response.data)).digest('base64')}`;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
lastError = error;
|
|
77
|
+
if (attempt < DIGEST_ATTEMPTS)
|
|
78
|
+
await sleep(DIGEST_BASE_DELAY_MS * 2 ** (attempt - 1));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const message = `cannot compute the digest of ${variable} (${uri}): ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`;
|
|
82
|
+
logger === null || logger === void 0 ? void 0 : logger.error(`[ecs-claims] ${message}`);
|
|
83
|
+
throw new Error(message);
|
|
84
|
+
}
|
|
85
|
+
const GROUP_OF = {
|
|
86
|
+
'ecs-service': 'service',
|
|
87
|
+
'ecs-persona': 'persona',
|
|
88
|
+
'ecs-org': 'org',
|
|
89
|
+
};
|
|
90
|
+
const groupOf = (claims, schemaKey) => {
|
|
91
|
+
const group = GROUP_OF[schemaKey];
|
|
92
|
+
return group ? claims[group] : undefined;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Compose the claims of one ECS credential from the configured variables, deriving `id` and
|
|
96
|
+
* every paired `*DigestSri`. Returns undefined when the operator configured no claim, so the
|
|
97
|
+
* caller can omit the `claims` field entirely.
|
|
98
|
+
*/
|
|
99
|
+
async function composeEcsClaims(claims, schemaKey, logger) {
|
|
100
|
+
var _a;
|
|
101
|
+
const configured = groupOf(claims, schemaKey);
|
|
102
|
+
const set = Object.entries(configured !== null && configured !== void 0 ? configured : {}).filter(([, v]) => v !== undefined && v !== '');
|
|
103
|
+
if (set.length === 0)
|
|
104
|
+
return undefined;
|
|
105
|
+
const composed = {};
|
|
106
|
+
for (const [claim, value] of set) {
|
|
107
|
+
composed[claim] = claim === 'minimumAgeRequired' ? Number(value) : value;
|
|
108
|
+
}
|
|
109
|
+
for (const [digestClaim, uriClaim] of Object.entries(DIGEST_OF)) {
|
|
110
|
+
const uri = composed[uriClaim];
|
|
111
|
+
if (typeof uri !== 'string')
|
|
112
|
+
continue;
|
|
113
|
+
const group = GROUP_OF[schemaKey];
|
|
114
|
+
const variable = (group && exports.ECS_CLAIMS_VARIABLES[group][uriClaim]) || uriClaim;
|
|
115
|
+
const local = (_a = claims.localResources) === null || _a === void 0 ? void 0 : _a[uri];
|
|
116
|
+
composed[digestClaim] = local ? digestOf(local) : await digestOfUri(uri, variable, logger);
|
|
117
|
+
}
|
|
118
|
+
return composed;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=ecsClaims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecsClaims.js","sourceRoot":"","sources":["../../src/utils/ecsClaims.ts"],"names":[],"mappings":";;;;;;AAyDA,oDAUC;AASD,4BAEC;AAED,kCAcC;AAkBD,4CAsBC;AApID,mCAAmC;AAEnC,kDAAyB;AAYzB,2DAA2D;AAC3D,MAAM,SAAS,GAA2B;IACxC,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,2BAA2B,EAAE,uBAAuB;IACpD,sBAAsB,EAAE,kBAAkB;CAC3C,CAAA;AAED,+DAA+D;AAClD,QAAA,oBAAoB,GAAG;IAClC,GAAG,EAAE;QACH,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,yBAAyB;QAClC,UAAU,EAAE,4BAA4B;QACxC,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,wBAAwB;QACjC,WAAW,EAAE,6BAA6B;QAC1C,iBAAiB,EAAE,mCAAmC;QACtD,gBAAgB,EAAE,kCAAkC;QACpD,GAAG,EAAE,oBAAoB;KAC1B;IACD,OAAO,EAAE;QACP,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,gCAAgC;QAC7C,iBAAiB,EAAE,uC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A4B,CAAC,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAA;QACzG,MAAM,KAAK,GAAG,MAAA,MAAM,CAAC,cAAc,0CAAG,GAAG,CAAC,CAAA;QAC1C,QAAQ,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VsAgent } from '../agent/VsAgent';
|
|
2
|
+
export interface EcsServiceClaims {
|
|
3
|
+
name?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
logoUri?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function ecsServiceClaims(agent: VsAgent): Promise<EcsServiceClaims | undefined>;
|
|
8
|
+
export declare function agentDisplayName(agent: VsAgent): Promise<string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ecsServiceClaims = ecsServiceClaims;
|
|
4
|
+
exports.agentDisplayName = agentDisplayName;
|
|
5
|
+
const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
|
|
6
|
+
const setupSelfTr_1 = require("./setupSelfTr");
|
|
7
|
+
// Read at call time, not at startup: the credential is published asynchronously after boot
|
|
8
|
+
async function ecsServiceClaims(agent) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (!agent.did)
|
|
11
|
+
return undefined;
|
|
12
|
+
const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
|
|
13
|
+
const metadata = didRecord === null || didRecord === void 0 ? void 0 : didRecord.metadata.get('_vt/vtc');
|
|
14
|
+
if (!metadata)
|
|
15
|
+
return undefined;
|
|
16
|
+
const serviceId = `${agent.did}#${(0, setupSelfTr_1.linkedVpFragment)(vs_agent_model_1.ECS.SERVICE)}`;
|
|
17
|
+
return (_b = (_a = Object.values(metadata).find(entry => entry.didDocumentServiceId === serviceId)) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.credentialSubject;
|
|
18
|
+
}
|
|
19
|
+
async function agentDisplayName(agent) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (_b = (_a = (await ecsServiceClaims(agent))) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : new URL(agent.publicApiBaseUrl).host;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ecsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecsService.js","sourceRoot":"","sources":["../../src/utils/ecsService.ts"],"names":[],"mappings":";;AAkBA,4CAUC;AAED,4CAEC;AA9BD,gEAAiD;AAEjD,+CAAgD;AAahD,2FAA2F;AACpF,KAAK,UAAU,gBAAgB,CAAC,KAAc;;IACnD,IAAI,CAAC,KAAK,CAAC,GAAG;QAAE,OAAO,SAAS,CAAA;IAEhC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAA;IACvE,MAAM,QAAQ,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAyC,CAAA;IAC3F,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAA;IAE/B,MAAM,SAAS,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,IAAA,8BAAgB,EAAC,oBAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IACjE,OAAO,MAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,CAAC,0CAAE,UAAU,0CAC9F,iBAAiD,CAAA;AACvD,CAAC;AAEM,KAAK,UAAU,gBAAgB,CAAC,KAAc;;IACnD,OAAO,MAAA,MAAA,CAAC,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,mCAAI,IAAI,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAA;AACtF,CAAC"}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from './agent';
|
|
2
2
|
export * from './data';
|
|
3
|
+
export * from './ecsClaims';
|
|
4
|
+
export * from './ecsService';
|
|
3
5
|
export * from './setupSelfTr';
|
|
4
6
|
export * from './trustCredentialStore';
|
|
5
7
|
export * from './util';
|
|
8
|
+
export * from './vcdm2';
|
|
9
|
+
export * from './vtjscResolver';
|
package/build/utils/index.js
CHANGED
|
@@ -16,7 +16,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./agent"), exports);
|
|
18
18
|
__exportStar(require("./data"), exports);
|
|
19
|
+
__exportStar(require("./ecsClaims"), exports);
|
|
20
|
+
__exportStar(require("./ecsService"), exports);
|
|
19
21
|
__exportStar(require("./setupSelfTr"), exports);
|
|
20
22
|
__exportStar(require("./trustCredentialStore"), exports);
|
|
21
23
|
__exportStar(require("./util"), exports);
|
|
24
|
+
__exportStar(require("./vcdm2"), exports);
|
|
25
|
+
__exportStar(require("./vtjscResolver"), exports);
|
|
22
26
|
//# sourceMappingURL=index.js.map
|
package/build/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,gDAA6B;AAC7B,yDAAsC;AACtC,yCAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,8CAA2B;AAC3B,+CAA4B;AAC5B,gDAA6B;AAC7B,yDAAsC;AACtC,yCAAsB;AACtB,0CAAuB;AACvB,kDAA+B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { W3cCredentialSchema } from '@credo-ts/core';
|
|
2
|
+
import { VsAgent } from '../agent/VsAgent';
|
|
3
|
+
import { EcsClaims } from './ecsClaims';
|
|
4
|
+
/** The linked presentation as published: VC Data Model 2.0 JSON secured with Data Integrity proofs */
|
|
5
|
+
export type SelfIssuedEcsPresentation = Record<string, unknown> & {
|
|
6
|
+
verifiableCredential: Record<string, unknown>[];
|
|
7
|
+
};
|
|
8
|
+
export declare function publishSelfIssuedEcsPresentation(agent: VsAgent, id: string, ecsSchemas: Record<string, string>, schemaKey: string, type: string[], credentialSchema: W3cCredentialSchema, ecsClaims: EcsClaims, beforePublish?: (verifiablePresentation: SelfIssuedEcsPresentation) => Promise<void>): Promise<SelfIssuedEcsPresentation>;
|