@verana-labs/vs-agent-sdk 2.0.0-dev.6 → 2.0.0-dev.60
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 +27 -3
- package/build/utils/agent.js +83 -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 +139 -91
- 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
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishSelfIssuedEcsPresentation = publishSelfIssuedEcsPresentation;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const setupSelfTr_1 = require("./setupSelfTr");
|
|
6
|
+
const vcdm2_1 = require("./vcdm2");
|
|
7
|
+
const buildIntegrityData = (data) => {
|
|
8
|
+
return (0, setupSelfTr_1.generateDigestSRI)(JSON.stringify((0, setupSelfTr_1.sortKeysDeep)(data)));
|
|
9
|
+
};
|
|
10
|
+
function storedCredentialIsCurrent(credential, credentialSchemaId, did, didRecord) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if (!credential)
|
|
13
|
+
return false;
|
|
14
|
+
// a credential published by an older agent as data model 1.1 is rebuilt on upgrade
|
|
15
|
+
if (!(0, vcdm2_1.isDataIntegrityVcdm2Credential)(credential))
|
|
16
|
+
return false;
|
|
17
|
+
const issuer = typeof credential.issuer === 'string' ? credential.issuer : (_a = credential.issuer) === null || _a === void 0 ? void 0 : _a.id;
|
|
18
|
+
if (issuer !== did)
|
|
19
|
+
return false;
|
|
20
|
+
const schema = Array.isArray(credential.credentialSchema)
|
|
21
|
+
? credential.credentialSchema[0]
|
|
22
|
+
: credential.credentialSchema;
|
|
23
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.id) !== credentialSchemaId)
|
|
24
|
+
return false;
|
|
25
|
+
const proofs = !credential.proof
|
|
26
|
+
? []
|
|
27
|
+
: Array.isArray(credential.proof)
|
|
28
|
+
? credential.proof
|
|
29
|
+
: [credential.proof];
|
|
30
|
+
if (proofs.length === 0)
|
|
31
|
+
return false;
|
|
32
|
+
const assertionMethods = new Set(((_c = (_b = didRecord.didDocument) === null || _b === void 0 ? void 0 : _b.assertionMethod) !== null && _c !== void 0 ? _c : []).map(entry => typeof entry === 'string' ? entry : entry.id));
|
|
33
|
+
return proofs.every(proof => !!proof.verificationMethod && assertionMethods.has(proof.verificationMethod));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Issues the ECS credential to the agent itself and wraps it in the linked presentation, both
|
|
37
|
+
* secured with a DataIntegrityProof by the DID Document assertion key.
|
|
38
|
+
*/
|
|
39
|
+
async function signSelfIssuedEcsCredential(agent, didRecord, presentationId, type, claims, credentialSchema) {
|
|
40
|
+
const unsignedCredential = (0, setupSelfTr_1.createCredential)({
|
|
41
|
+
id: agent.did,
|
|
42
|
+
type,
|
|
43
|
+
issuer: agent.did,
|
|
44
|
+
credentialSubject: Object.assign(Object.assign({}, claims), { id: agent.did }),
|
|
45
|
+
credentialSchema: { id: credentialSchema.id, type: credentialSchema.type },
|
|
46
|
+
});
|
|
47
|
+
const verificationMethodId = (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord);
|
|
48
|
+
const signedCredential = await (0, setupSelfTr_1.signerW3c)(agent, unsignedCredential, verificationMethodId);
|
|
49
|
+
const presentation = (0, setupSelfTr_1.createPresentation)({
|
|
50
|
+
id: presentationId,
|
|
51
|
+
holder: agent.did,
|
|
52
|
+
verifiableCredential: [signedCredential],
|
|
53
|
+
});
|
|
54
|
+
const signedPresentation = await (0, setupSelfTr_1.signerW3c)(agent, presentation, verificationMethodId);
|
|
55
|
+
return signedPresentation.securedPresentation;
|
|
56
|
+
}
|
|
57
|
+
async function publishSelfIssuedEcsPresentation(agent, id, ecsSchemas, schemaKey, type, credentialSchema, ecsClaims, beforePublish) {
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
59
|
+
if (!agent.did)
|
|
60
|
+
throw Error('The DID must be set up');
|
|
61
|
+
const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
|
|
62
|
+
const didDocument = didRecord.didDocument;
|
|
63
|
+
if (!didDocument)
|
|
64
|
+
throw Error('The DID Document must be set up');
|
|
65
|
+
const claims = await (0, setupSelfTr_1.getClaims)(agent.config.logger, ecsSchemas, { id: agent.did }, schemaKey, ecsClaims);
|
|
66
|
+
const didDocumentServiceId = `${agent.did}#${(0, setupSelfTr_1.linkedVpFragment)(schemaKey)}`;
|
|
67
|
+
const integrityData = buildIntegrityData({ id, type, credentialSchema, claims });
|
|
68
|
+
const record = (_a = didRecord.metadata.get('_vt/vtc')) !== null && _a !== void 0 ? _a : {};
|
|
69
|
+
const metadata = record[credentialSchema.id];
|
|
70
|
+
const superseded = Object.entries(record).some(([storedSchemaId, entry]) => {
|
|
71
|
+
var _a;
|
|
72
|
+
return storedSchemaId !== credentialSchema.id &&
|
|
73
|
+
((_a = entry === null || entry === void 0 ? void 0 : entry.verifiablePresentation) === null || _a === void 0 ? void 0 : _a.id) === id &&
|
|
74
|
+
(entry === null || entry === void 0 ? void 0 : entry.attached) !== false;
|
|
75
|
+
});
|
|
76
|
+
const attached = ((_b = metadata === null || metadata === void 0 ? void 0 : metadata.attached) !== null && _b !== void 0 ? _b : true) && !superseded;
|
|
77
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.integrityData) === integrityData &&
|
|
78
|
+
storedCredentialIsCurrent(metadata === null || metadata === void 0 ? void 0 : metadata.credential, credentialSchema.id, agent.did, didRecord)) {
|
|
79
|
+
// the presentation is already public, so a failed beforePublish step still needs a retry here
|
|
80
|
+
if (attached)
|
|
81
|
+
await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(metadata.verifiablePresentation));
|
|
82
|
+
return metadata.verifiablePresentation;
|
|
83
|
+
}
|
|
84
|
+
const verifiablePresentation = await signSelfIssuedEcsCredential(agent, didRecord, id, type, claims, credentialSchema);
|
|
85
|
+
// nothing is persisted yet, so a failure here leaves no public presentation behind
|
|
86
|
+
if (attached)
|
|
87
|
+
await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(verifiablePresentation));
|
|
88
|
+
// Update linked VP when the presentation has changed. Match by fragment or by the file the
|
|
89
|
+
// endpoint ends with: a `contains` test also matches the host, so an agent at a host such as
|
|
90
|
+
// ecs-org-issuer.example rewrote its DIDComm endpoint and every other ECS linked VP onto this one.
|
|
91
|
+
const linkedVpFile = `/${schemaKey}-vtc-vp.json`;
|
|
92
|
+
if (attached)
|
|
93
|
+
didDocument.service = (_c = didDocument.service) === null || _c === void 0 ? void 0 : _c.map(s => {
|
|
94
|
+
if (typeof s.serviceEndpoint !== 'string')
|
|
95
|
+
return s;
|
|
96
|
+
if (s.type !== 'LinkedVerifiablePresentation' || s.id === `${agent.did}#whois`)
|
|
97
|
+
return s;
|
|
98
|
+
if (s.id !== didDocumentServiceId && !s.serviceEndpoint.endsWith(linkedVpFile))
|
|
99
|
+
return s;
|
|
100
|
+
s.id = didDocumentServiceId;
|
|
101
|
+
s.serviceEndpoint = id;
|
|
102
|
+
return s;
|
|
103
|
+
});
|
|
104
|
+
// Resolvers only discover the credential through the [VT-CRED-W3C-LINKED-VP] fragment, and
|
|
105
|
+
// #whois does not match it. The rename above only covers documents that already carry the
|
|
106
|
+
// service, so publish it here when nothing declared it yet.
|
|
107
|
+
let didDocumentChanged = false;
|
|
108
|
+
if (attached && !((_d = didDocument.service) === null || _d === void 0 ? void 0 : _d.some(s => s.id === didDocumentServiceId))) {
|
|
109
|
+
didDocument.service = [
|
|
110
|
+
...((_e = didDocument.service) !== null && _e !== void 0 ? _e : []),
|
|
111
|
+
new core_1.DidDocumentService({
|
|
112
|
+
id: didDocumentServiceId,
|
|
113
|
+
serviceEndpoint: id,
|
|
114
|
+
type: 'LinkedVerifiablePresentation',
|
|
115
|
+
}),
|
|
116
|
+
];
|
|
117
|
+
didDocumentChanged = true;
|
|
118
|
+
}
|
|
119
|
+
const whoisId = `${agent.did}#whois`;
|
|
120
|
+
if (attached && schemaKey === 'ecs-service') {
|
|
121
|
+
const whois = (_f = didDocument.service) === null || _f === void 0 ? void 0 : _f.find(s => s.id === whoisId);
|
|
122
|
+
if (whois) {
|
|
123
|
+
if (whois.serviceEndpoint !== id) {
|
|
124
|
+
whois.serviceEndpoint = id;
|
|
125
|
+
didDocumentChanged = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
didDocument.service = [
|
|
130
|
+
...((_g = didDocument.service) !== null && _g !== void 0 ? _g : []),
|
|
131
|
+
new core_1.DidDocumentService({ id: whoisId, serviceEndpoint: id, type: 'LinkedVerifiablePresentation' }),
|
|
132
|
+
];
|
|
133
|
+
didDocumentChanged = true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const [credential] = verifiablePresentation.verifiableCredential;
|
|
137
|
+
record[credentialSchema.id] = {
|
|
138
|
+
credential,
|
|
139
|
+
verifiablePresentation,
|
|
140
|
+
didDocumentServiceId,
|
|
141
|
+
integrityData,
|
|
142
|
+
attached,
|
|
143
|
+
};
|
|
144
|
+
didRecord.metadata.set('_vt/vtc', record);
|
|
145
|
+
await agent.context.dependencyManager.resolve(core_1.DidRepository).update(agent.context, didRecord);
|
|
146
|
+
if (didDocumentChanged) {
|
|
147
|
+
await agent.dids.update({ did: didRecord.did, didDocument });
|
|
148
|
+
}
|
|
149
|
+
return verifiablePresentation;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=selfIssuedEcsCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selfIssuedEcsCredential.js","sourceRoot":"","sources":["../../src/utils/selfIssuedEcsCredential.ts"],"names":[],"mappings":";;AA8FA,4EAuGC;AArMD,yCAAkG;AAIlG,+CASsB;AACtB,mCAAwD;AAExD,MAAM,kBAAkB,GAAG,CAAC,IAA6B,EAAE,EAAE;IAC3D,OAAO,IAAA,+BAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,IAAA,0BAAY,EAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAA;AAQD,SAAS,yBAAyB,CAChC,UAAkD,EAClD,kBAA0B,EAC1B,GAAW,EACX,SAAoB;;IAEpB,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAA;IAC7B,mFAAmF;IACnF,IAAI,CAAC,IAAA,sCAA8B,EAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAA;IAE7D,MAAM,MAAM,GAAG,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,MAAA,UAAU,CAAC,MAAM,0CAAE,EAAE,CAAA;IAChG,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IAEhC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO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KACT,CAAA;IACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IACzC,MAAM,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,oBAAa,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC7F,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,sBAAsB,CAAA;AAC/B,CAAC"}
|
|
@@ -1,74 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DidRecord, Logger, W3cCredentialSchema, W3cCredentialSubject, W3cV2Credential, W3cV2CredentialOptions, W3cV2DataIntegrityVerifiableCredential, W3cV2DataIntegrityVerifiablePresentation, W3cV2Presentation, W3cV2PresentationOptions } from '@credo-ts/core';
|
|
2
2
|
import { AnySchemaObject } from 'ajv/dist/2020';
|
|
3
|
-
import { VsAgent } from '../agent/VsAgent';
|
|
4
|
-
|
|
5
|
-
agentLabel: string;
|
|
6
|
-
serviceLogoUri: string;
|
|
7
|
-
serviceLogoDigestSri?: string;
|
|
8
|
-
serviceType: string;
|
|
9
|
-
serviceDescription: string;
|
|
10
|
-
serviceMinimumAgeRequired: number;
|
|
11
|
-
serviceTermsAndConditions: string;
|
|
12
|
-
serviceTermsAndConditionsDigestSri?: string;
|
|
13
|
-
servicePrivacyPolicy: string;
|
|
14
|
-
servicePrivacyPolicyDigestSri?: string;
|
|
15
|
-
orgRegistryId: string;
|
|
16
|
-
orgRegistryUri: string;
|
|
17
|
-
orgAddress: string;
|
|
18
|
-
orgOrganizationKind: string;
|
|
19
|
-
orgCountryCode: string;
|
|
20
|
-
}
|
|
21
|
-
export declare const presentations: {
|
|
22
|
-
name: string;
|
|
23
|
-
schemaUrl: string;
|
|
24
|
-
}[];
|
|
25
|
-
export declare const credentials: {
|
|
26
|
-
name: string;
|
|
27
|
-
credUrl: string;
|
|
28
|
-
schemaUrl: string;
|
|
29
|
-
}[];
|
|
3
|
+
import type { VsAgent } from '../agent/VsAgent';
|
|
4
|
+
import { EcsClaims } from './ecsClaims';
|
|
30
5
|
export declare const createJsonSchema: W3cCredentialSchema;
|
|
31
6
|
export declare const createJsonSubjectRef: (id: string) => W3cCredentialSubject;
|
|
7
|
+
export declare const linkedVpSchemaId: (schemaKey: string) => string;
|
|
32
8
|
export declare const linkedVpFragment: (schemaKey: string) => string;
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const setupSelfTr: ({ agent, publicApiBaseUrl, defaults, }: {
|
|
35
|
-
agent: VsAgent;
|
|
36
|
-
publicApiBaseUrl: string;
|
|
37
|
-
defaults: SelfTrDefaults;
|
|
38
|
-
}) => Promise<void>;
|
|
39
|
-
export declare function createCredential(options: Partial<W3cCredentialOptions>): W3cCredential;
|
|
9
|
+
export declare const sortKeysDeep: (value: unknown) => unknown;
|
|
40
10
|
/**
|
|
41
|
-
*
|
|
11
|
+
* Builds an unsigned credential: a VC Data Model 2.0 credential, as
|
|
12
|
+
* [VT-CRED-W3C] and [VT-JSON-SCHEMA-CRED-W3C] require the `https://www.w3.org/ns/credentials/v2`
|
|
13
|
+
* context, valid from now for ten years unless told otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createCredential(options: Partial<W3cV2CredentialOptions>): W3cV2Credential;
|
|
16
|
+
/**
|
|
17
|
+
* The Data Integrity cryptosuite this agent is configured with, read from the registered
|
|
18
|
+
* `VtFlowModuleConfig` so the self issued credentials are secured and linked VPs with the
|
|
19
|
+
* same suite `VtFlowApi.issueCredentialForSession` applies to the credentials it issues. Falls back
|
|
20
|
+
* to the module default when the vt-flow module is not registered on the agent.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDataIntegrityCryptosuite(agent: Pick<VsAgent, 'context'>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Secures a W3C credential or presentation with a Data Integrity proof under the cryptosuite the
|
|
25
|
+
* agent is configured with, using the provided verification method.
|
|
42
26
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
27
|
+
* A credential is secured for `assertionMethod` and a presentation for `authentication`, the proof
|
|
28
|
+
* purposes VC Data Integrity defines for each; the presentation is published from the DID Document
|
|
29
|
+
* rather than presented to a verifier, so it carries no challenge.
|
|
45
30
|
*
|
|
46
31
|
* @param agent - The agent instance.
|
|
47
32
|
* @param obj - The credential or presentation object to be signed.
|
|
48
33
|
* @param verificationMethod - The DID verification method used to generate the proof.
|
|
49
|
-
* @returns
|
|
34
|
+
* @returns The secured credential or presentation, wrapping the JSON that gets published.
|
|
50
35
|
*/
|
|
51
|
-
export declare function signerW3c(agent: VsAgent, obj:
|
|
52
|
-
export declare function signerW3c(agent: VsAgent, obj:
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
* Stores the signed presentation and its integrity metadata in the DID record.
|
|
56
|
-
*
|
|
57
|
-
* - Retrieves and validates claims for the agent's DID.
|
|
58
|
-
* - Computes an integrity digest for the claims.
|
|
59
|
-
* - If a presentation with the same integrity already exists in the DID metadata, it is returned.
|
|
60
|
-
* - Otherwise, a new presentation is created, signed, and stored in the DID metadata.
|
|
61
|
-
*
|
|
62
|
-
* @param agent - The VsAgent instance used for signing and DID management.
|
|
63
|
-
* @param logger - Logger instance for logging operations.
|
|
64
|
-
* @param ecsSchemas - Map of ECS schemas for validation.
|
|
65
|
-
* @param schemaKey - Unique identifier for the presentation type and metadata key.
|
|
66
|
-
* @param type - Array of credential types to include.
|
|
67
|
-
* @param credentialSchema - Schema definition for the credential.
|
|
68
|
-
* @returns The signed verifiable presentation, with integrity metadata.
|
|
69
|
-
*/
|
|
70
|
-
export declare function generateVerifiablePresentation(agent: VsAgent, id: string, ecsSchemas: Record<string, string>, schemaKey: string, type: string[], credentialSchema: W3cCredentialSchema, defaults: SelfTrDefaults): Promise<any>;
|
|
71
|
-
export declare function createPresentation(options: Partial<W3cPresentationOptions>): W3cPresentation;
|
|
36
|
+
export declare function signerW3c(agent: VsAgent, obj: W3cV2Credential, verificationMethod: string): Promise<W3cV2DataIntegrityVerifiableCredential>;
|
|
37
|
+
export declare function signerW3c(agent: VsAgent, obj: W3cV2Presentation, verificationMethod: string): Promise<W3cV2DataIntegrityVerifiablePresentation>;
|
|
38
|
+
/** Builds an unsigned VC Data Model 2.0 presentation; the class supplies the v2 context. */
|
|
39
|
+
export declare function createPresentation(options: Partial<W3cV2PresentationOptions>): W3cV2Presentation;
|
|
72
40
|
/**
|
|
73
41
|
* Retrieves and validates claims for a credential subject.
|
|
74
42
|
* If claims are not found, builds default claims based on the schemaKey.
|
|
@@ -80,7 +48,7 @@ export declare function createPresentation(options: Partial<W3cPresentationOptio
|
|
|
80
48
|
* @returns The validated claims object.
|
|
81
49
|
* @throws If claims are invalid or schema is missing.
|
|
82
50
|
*/
|
|
83
|
-
export declare function getClaims(logger: Logger, ecsSchemas: Record<string, string>, { id
|
|
51
|
+
export declare function getClaims(logger: Logger, ecsSchemas: Record<string, string>, { id }: W3cCredentialSubject, schemaKey: string, ecsClaims: EcsClaims): Promise<Record<string, unknown>>;
|
|
84
52
|
/**
|
|
85
53
|
* Validate a validateSchema object against the corresponding AJV schema.
|
|
86
54
|
* Throws an Error if the schema is missing or validation fails.
|
|
@@ -107,9 +75,4 @@ export declare function addDigestSRI<T extends object>(id?: string, data?: T, ec
|
|
|
107
75
|
* @returns The SRI digest string.
|
|
108
76
|
*/
|
|
109
77
|
export declare function generateDigestSRI(content: string, algorithm?: string): string;
|
|
110
|
-
/**
|
|
111
|
-
* Digest of the resource a credential references. Throws rather than attest content it could
|
|
112
|
-
* not read: a wrong digestSRI is a false integrity claim in a signed credential.
|
|
113
|
-
*/
|
|
114
|
-
export declare function urlDigestSri(url: string): Promise<string>;
|
|
115
78
|
export declare function getVerificationMethodId(logger: Logger, didRecord: DidRecord): string;
|