@verana-labs/vs-agent-sdk 2.0.0-dev.51 → 2.0.0-dev.53

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.
Files changed (38) hide show
  1. package/build/agent/VsAgent.d.ts +2 -2
  2. package/build/blockchain/AnonCredsTrustService.d.ts +5 -0
  3. package/build/blockchain/AnonCredsTrustService.js +16 -3
  4. package/build/blockchain/AnonCredsTrustService.js.map +1 -1
  5. package/build/blockchain/handlers/stateMutations.js +5 -1
  6. package/build/blockchain/handlers/stateMutations.js.map +1 -1
  7. package/build/did/CachedDocumentLoader.d.ts +3 -0
  8. package/build/did/CachedDocumentLoader.js +7 -1
  9. package/build/did/CachedDocumentLoader.js.map +1 -1
  10. package/build/did/artifactServices.d.ts +2 -1
  11. package/build/did/artifactServices.js.map +1 -1
  12. package/build/did/publicDid.d.ts +4 -0
  13. package/build/did/publicDid.js +19 -0
  14. package/build/did/publicDid.js.map +1 -0
  15. package/build/index.d.ts +2 -0
  16. package/build/index.js +5 -1
  17. package/build/index.js.map +1 -1
  18. package/build/plugins/setupBaseDidComm.js +1 -1
  19. package/build/plugins/setupBaseDidComm.js.map +1 -1
  20. package/build/utils/index.d.ts +1 -0
  21. package/build/utils/index.js +1 -0
  22. package/build/utils/index.js.map +1 -1
  23. package/build/utils/selfIssuedEcsCredential.d.ts +5 -1
  24. package/build/utils/selfIssuedEcsCredential.js +20 -14
  25. package/build/utils/selfIssuedEcsCredential.js.map +1 -1
  26. package/build/utils/setupSelfTr.d.ts +24 -9
  27. package/build/utils/setupSelfTr.js +37 -35
  28. package/build/utils/setupSelfTr.js.map +1 -1
  29. package/build/utils/trustCredentialStore.d.ts +34 -4
  30. package/build/utils/trustCredentialStore.js +116 -32
  31. package/build/utils/trustCredentialStore.js.map +1 -1
  32. package/build/utils/vcdm2.d.ts +34 -0
  33. package/build/utils/vcdm2.js +62 -0
  34. package/build/utils/vcdm2.js.map +1 -0
  35. package/build/vtFlow/VtFlowOrchestrator.d.ts +13 -6
  36. package/build/vtFlow/VtFlowOrchestrator.js +32 -31
  37. package/build/vtFlow/VtFlowOrchestrator.js.map +1 -1
  38. package/package.json +11 -11
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.publishSelfIssuedEcsPresentation = publishSelfIssuedEcsPresentation;
4
4
  const core_1 = require("@credo-ts/core");
5
5
  const setupSelfTr_1 = require("./setupSelfTr");
6
+ const vcdm2_1 = require("./vcdm2");
6
7
  const buildIntegrityData = (data) => {
7
8
  return (0, setupSelfTr_1.generateDigestSRI)(JSON.stringify((0, setupSelfTr_1.sortKeysDeep)(data)));
8
9
  };
@@ -10,6 +11,9 @@ function storedCredentialIsCurrent(credential, credentialSchemaId, did, didRecor
10
11
  var _a, _b, _c;
11
12
  if (!credential)
12
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;
13
17
  const issuer = typeof credential.issuer === 'string' ? credential.issuer : (_a = credential.issuer) === null || _a === void 0 ? void 0 : _a.id;
14
18
  if (issuer !== did)
15
19
  return false;
@@ -28,18 +32,27 @@ function storedCredentialIsCurrent(credential, credentialSchemaId, did, didRecor
28
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));
29
33
  return proofs.every(proof => !!proof.verificationMethod && assertionMethods.has(proof.verificationMethod));
30
34
  }
31
- async function signSelfIssuedEcsCredential(agent, didRecord, type, claims, credentialSchema, presentation) {
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) {
32
40
  const unsignedCredential = (0, setupSelfTr_1.createCredential)({
33
41
  id: agent.did,
34
42
  type,
35
43
  issuer: agent.did,
36
- credentialSubject: { id: agent.did, claims },
44
+ credentialSubject: Object.assign(Object.assign({}, claims), { id: agent.did }),
45
+ credentialSchema: { id: credentialSchema.id, type: credentialSchema.type },
37
46
  });
38
- unsignedCredential.credentialSchema = credentialSchema;
39
47
  const verificationMethodId = (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord);
40
48
  const signedCredential = await (0, setupSelfTr_1.signerW3c)(agent, unsignedCredential, verificationMethodId);
41
- presentation.verifiableCredential = [signedCredential];
42
- return await (0, setupSelfTr_1.signerW3c)(agent, presentation, 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;
43
56
  }
44
57
  async function publishSelfIssuedEcsPresentation(agent, id, ecsSchemas, schemaKey, type, credentialSchema, ecsClaims, beforePublish) {
45
58
  var _a, _b, _c, _d, _e, _f, _g;
@@ -68,12 +81,7 @@ async function publishSelfIssuedEcsPresentation(agent, id, ecsSchemas, schemaKey
68
81
  await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(metadata.verifiablePresentation));
69
82
  return metadata.verifiablePresentation;
70
83
  }
71
- const presentation = (0, setupSelfTr_1.createPresentation)({
72
- id,
73
- holder: agent.did,
74
- verifiableCredential: [],
75
- });
76
- const verifiablePresentation = await signSelfIssuedEcsCredential(agent, didRecord, type, claims, credentialSchema, presentation);
84
+ const verifiablePresentation = await signSelfIssuedEcsCredential(agent, didRecord, id, type, claims, credentialSchema);
77
85
  // nothing is persisted yet, so a failure here leaves no public presentation behind
78
86
  if (attached)
79
87
  await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(verifiablePresentation));
@@ -120,9 +128,7 @@ async function publishSelfIssuedEcsPresentation(agent, id, ecsSchemas, schemaKey
120
128
  didDocumentChanged = true;
121
129
  }
122
130
  }
123
- const credential = Array.isArray(verifiablePresentation.verifiableCredential)
124
- ? verifiablePresentation.verifiableCredential[0]
125
- : verifiablePresentation.verifiableCredential;
131
+ const [credential] = verifiablePresentation.verifiableCredential;
126
132
  record[credentialSchema.id] = {
127
133
  credential,
128
134
  verifiablePresentation,
@@ -1 +1 @@
1
- {"version":3,"file":"selfIssuedEcsCredential.js","sourceRoot":"","sources":["../../src/utils/selfIssuedEcsCredential.ts"],"names":[],"mappings":";;AAqFA,4EA2GC;AAhMD,yCAQuB;AAIvB,+CASsB;AAEtB,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;IAE7B,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,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACvD,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAA;IAC/B,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,MAAK,kBAAkB;QAAE,OAAO,KAAK,CAAA;IAEnD,MAAM,MAAM,GAAG,CAAC,UAAU,CAAC,KAAK;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E,EAAE,CAAC;gBACjC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAA;gBAC1B,kBAAkB,GAAG,IAAI,CAAA;YAC3B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,OAAO,GAAG;gBACpB,GAAG,CAAC,MAAA,WAAW,CAAC,OAAO,mCAAI,EAAE,CAAC;gBAC9B,IAAI,yBAAkB,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,CAAC;aACnG,CAAA;YACD,kBAAkB,GAAG,IAAI,CAAA;QAC3B,CAAC;IACH,CAAC;IACD,MAAM,CAAC,UAAU,CAAC,GAAG,sBAAsB,CAAC,oBAAoB,CAAA;IAChE,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG;QAC5B,UAAU;QACV,sBAAsB;QACtB,oBAAoB;QACpB,aAAa;QACb,QAAQ;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,4 +1,4 @@
1
- import { W3cCredential, W3cPresentation, W3cCredentialSchema, W3cCredentialSubject, W3cJsonLdVerifiableCredential, W3cJsonLdVerifiablePresentation, W3cCredentialOptions, DidRecord, W3cPresentationOptions, Logger } from '@credo-ts/core';
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
3
  import { VsAgent } from '../agent/VsAgent';
4
4
  import { EcsClaims } from './ecsClaims';
@@ -6,21 +6,36 @@ export declare const createJsonSchema: W3cCredentialSchema;
6
6
  export declare const createJsonSubjectRef: (id: string) => W3cCredentialSubject;
7
7
  export declare const linkedVpFragment: (schemaKey: string) => string;
8
8
  export declare const sortKeysDeep: (value: unknown) => unknown;
9
- export declare function createCredential(options: Partial<W3cCredentialOptions>): W3cCredential;
10
9
  /**
11
- * Signs a W3C Verifiable Credential or Presentation using the provided agent and verification method.
10
+ * Builds an unsigned credential: a VC Data Model 2.0 credential, as
11
+ * [VT-CRED-W3C] and [VT-JSON-SCHEMA-CRED-W3C] require the `https://www.w3.org/ns/credentials/v2`
12
+ * context, valid from now for ten years unless told otherwise.
13
+ */
14
+ export declare function createCredential(options: Partial<W3cV2CredentialOptions>): W3cV2Credential;
15
+ /**
16
+ * The Data Integrity cryptosuite this agent is configured with, read from the registered
17
+ * `VtFlowModuleConfig` so the self issued credentials are secured and linked VPs with the
18
+ * same suite `VtFlowApi.issueCredentialForSession` applies to the credentials it issues. Falls back
19
+ * to the module default when the vt-flow module is not registered on the agent.
20
+ */
21
+ export declare function getDataIntegrityCryptosuite(agent: Pick<VsAgent, 'context'>): string;
22
+ /**
23
+ * Secures a W3C credential or presentation with a Data Integrity proof under the cryptosuite the
24
+ * agent is configured with, using the provided verification method.
12
25
  *
13
- * The function determines whether the input object is a `W3cCredential` or a `W3cPresentation`,
14
- * and applies the appropriate signing operation using Linked Data Proofs (`Ed25519Signature2020`).
26
+ * A credential is secured for `assertionMethod` and a presentation for `authentication`, the proof
27
+ * purposes VC Data Integrity defines for each; the presentation is published from the DID Document
28
+ * rather than presented to a verifier, so it carries no challenge.
15
29
  *
16
30
  * @param agent - The agent instance.
17
31
  * @param obj - The credential or presentation object to be signed.
18
32
  * @param verificationMethod - The DID verification method used to generate the proof.
19
- * @returns A signed W3C Verifiable Credential or Presentation in JSON-LD format.
33
+ * @returns The secured credential or presentation, wrapping the JSON that gets published.
20
34
  */
21
- export declare function signerW3c(agent: VsAgent, obj: W3cCredential, verificationMethod: string): Promise<W3cJsonLdVerifiableCredential>;
22
- export declare function signerW3c(agent: VsAgent, obj: W3cPresentation, verificationMethod: string): Promise<W3cJsonLdVerifiablePresentation>;
23
- export declare function createPresentation(options: Partial<W3cPresentationOptions>): W3cPresentation;
35
+ export declare function signerW3c(agent: VsAgent, obj: W3cV2Credential, verificationMethod: string): Promise<W3cV2DataIntegrityVerifiableCredential>;
36
+ export declare function signerW3c(agent: VsAgent, obj: W3cV2Presentation, verificationMethod: string): Promise<W3cV2DataIntegrityVerifiablePresentation>;
37
+ /** Builds an unsigned VC Data Model 2.0 presentation; the class supplies the v2 context. */
38
+ export declare function createPresentation(options: Partial<W3cV2PresentationOptions>): W3cV2Presentation;
24
39
  /**
25
40
  * Retrieves and validates claims for a credential subject.
26
41
  * If claims are not found, builds default claims based on the schemaKey.
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sortKeysDeep = exports.linkedVpFragment = exports.createJsonSubjectRef = exports.createJsonSchema = void 0;
7
7
  exports.createCredential = createCredential;
8
+ exports.getDataIntegrityCryptosuite = getDataIntegrityCryptosuite;
8
9
  exports.signerW3c = signerW3c;
9
10
  exports.createPresentation = createPresentation;
10
11
  exports.getClaims = getClaims;
@@ -13,15 +14,13 @@ exports.addDigestSRI = addDigestSRI;
13
14
  exports.generateDigestSRI = generateDigestSRI;
14
15
  exports.getVerificationMethodId = getVerificationMethodId;
15
16
  const core_1 = require("@credo-ts/core");
16
- // No type definitions available for this library
17
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
- //@ts-expect-error
19
- const jsonld_signatures_1 = require("@digitalcredentials/jsonld-signatures");
17
+ const credo_ts_didcomm_vt_flow_1 = require("@verana-labs/credo-ts-didcomm-vt-flow");
20
18
  const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
21
19
  const _2020_1 = __importDefault(require("ajv/dist/2020"));
22
20
  const ajv_formats_1 = __importDefault(require("ajv-formats"));
23
21
  const crypto_1 = require("crypto");
24
22
  const ecsClaims_1 = require("./ecsClaims");
23
+ const vcdm2_1 = require("./vcdm2");
25
24
  const ajv = new _2020_1.default({ strict: false, allErrors: true });
26
25
  (0, ajv_formats_1.default)(ajv);
27
26
  exports.createJsonSchema = {
@@ -60,45 +59,48 @@ const sortKeysDeep = (value) => {
60
59
  return value;
61
60
  };
62
61
  exports.sortKeysDeep = sortKeysDeep;
62
+ /**
63
+ * Builds an unsigned credential: a VC Data Model 2.0 credential, as
64
+ * [VT-CRED-W3C] and [VT-JSON-SCHEMA-CRED-W3C] require the `https://www.w3.org/ns/credentials/v2`
65
+ * context, valid from now for ten years unless told otherwise.
66
+ */
63
67
  function createCredential(options) {
64
- var _a, _b, _c;
65
- (_a = options.context) !== null && _a !== void 0 ? _a : (options.context = [
66
- 'https://www.w3.org/2018/credentials/v1',
67
- 'https://www.w3.org/ns/credentials/examples/v2',
68
- ]);
69
- (_b = options.issuanceDate) !== null && _b !== void 0 ? _b : (options.issuanceDate = new Date().toISOString());
70
- (_c = options.expirationDate) !== null && _c !== void 0 ? _c : (options.expirationDate = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000).toISOString());
71
- return new core_1.W3cCredential(options);
68
+ return (0, vcdm2_1.createW3cV2Credential)(options);
69
+ }
70
+ /**
71
+ * The Data Integrity cryptosuite this agent is configured with, read from the registered
72
+ * `VtFlowModuleConfig` so the self issued credentials are secured and linked VPs with the
73
+ * same suite `VtFlowApi.issueCredentialForSession` applies to the credentials it issues. Falls back
74
+ * to the module default when the vt-flow module is not registered on the agent.
75
+ */
76
+ function getDataIntegrityCryptosuite(agent) {
77
+ const { dependencyManager } = agent.context;
78
+ return dependencyManager.isRegistered(credo_ts_didcomm_vt_flow_1.VtFlowModuleConfig)
79
+ ? dependencyManager.resolve(credo_ts_didcomm_vt_flow_1.VtFlowModuleConfig).dataIntegrityCryptosuite
80
+ : credo_ts_didcomm_vt_flow_1.DEFAULT_DATA_INTEGRITY_CRYPTOSUITE;
72
81
  }
73
82
  async function signerW3c(agent, obj, verificationMethod) {
74
- const proofPurpose = new jsonld_signatures_1.purposes.AssertionProofPurpose();
75
- if (obj instanceof core_1.W3cCredential) {
76
- return await agent.w3cCredentials.signCredential({
77
- format: core_1.ClaimFormat.LdpVc,
83
+ const cryptosuite = getDataIntegrityCryptosuite(agent);
84
+ if (obj instanceof core_1.W3cV2Credential) {
85
+ return await agent.w3cV2Credentials.signCredential({
86
+ format: core_1.ClaimFormat.DiVc,
78
87
  credential: obj,
79
- proofType: 'Ed25519Signature2020',
88
+ cryptosuite,
80
89
  verificationMethod,
81
- proofPurpose,
82
- });
83
- }
84
- if (obj instanceof core_1.W3cPresentation) {
85
- return await agent.w3cCredentials.signPresentation({
86
- format: core_1.ClaimFormat.LdpVp,
87
- presentation: obj,
88
- proofType: 'Ed25519Signature2020',
89
- verificationMethod,
90
- proofPurpose,
91
90
  });
92
91
  }
92
+ // The options type requires a challenge for every presentation format, while a Data Integrity
93
+ // proof only carries one when it is given
94
+ return await agent.w3cV2Credentials.signPresentation({
95
+ format: core_1.ClaimFormat.DiVp,
96
+ presentation: obj,
97
+ cryptosuite,
98
+ verificationMethod,
99
+ });
93
100
  }
101
+ /** Builds an unsigned VC Data Model 2.0 presentation; the class supplies the v2 context. */
94
102
  function createPresentation(options) {
95
- var _a, _b;
96
- (_a = options.context) !== null && _a !== void 0 ? _a : (options.context = [
97
- 'https://www.w3.org/2018/credentials/v1',
98
- 'https://www.w3.org/ns/credentials/examples/v2',
99
- ]);
100
- (_b = options.type) !== null && _b !== void 0 ? _b : (options.type = ['VerifiablePresentation']);
101
- return new core_1.W3cPresentation(options);
103
+ return new core_1.W3cV2Presentation(Object.assign({ type: ['VerifiablePresentation'] }, options));
102
104
  }
103
105
  /**
104
106
  * Retrieves and validates claims for a credential subject.
@@ -213,7 +215,7 @@ function getVerificationMethodId(logger, didRecord) {
213
215
  method.id === ((_b = (_a = didRecord.didDocument) === null || _a === void 0 ? void 0 : _a.assertionMethod) === null || _b === void 0 ? void 0 : _b[0]);
214
216
  });
215
217
  if (!verificationMethod) {
216
- throw new Error('Cannot find a suitable Ed25519Signature2020 verification method in DID Document');
218
+ throw new Error('Cannot find a suitable Ed25519 verification method in DID Document');
217
219
  }
218
220
  return verificationMethod.id;
219
221
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setupSelfTr.js","sourceRoot":"","sources":["../../src/utils/setupSelfTr.ts"],"names":[],"mappings":";;;;;;AAgEA,4CAUC;AAyBD,8BA0BC;AACD,gDAOC;AAaD,8BAkBC;AAMD,wCAcC;AAuBD,oCAuBC;AA2BD,8CAGC;AAED,0DAeC;AArRD,yCAYuB;AACvB,iDAAiD;AACjD,6DAA6D;AAC7D,kBAAkB;AAClB,6EAAgE;AAChE,gEAA4D;AAC5D,0DAAoD;AACpD,8DAAoC;AACpC,mCAAmC;AAGnC,2CAAyD;AAEzD,MAAM,GAAG,GAAG,IAAI,eAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AACvD,IAAA,qBAAU,EAAC,GAAG,CAAC,CAAA;AAEF,QAAA,gBAAgB,GAAwB;IACnD,EAAE,EAAE,uDAAuD;IAC3D,IAAI,EAAE,YAAY;CACnB,CAAA;AAEM,MAAM,oBAAoB,GAAG,CAAC,EAAU,EAAwB,EAAE,CAAC,CAAC;IACzE,EAAE;IACF,MAAM,EAAE;QACN,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE;YACV,IAAI,EAAE,EAAE;SACT;KACF;CACF,CAAC,CAAA;AARW,QAAA,oBAAoB,wBAQ/B;AAE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@credo-ts/core';
1
+ import { DidRecord, W3cJsonLdVerifiableCredential, W3cJsonLdVerifiablePresentation, type W3cV2DataIntegritySecuredCredential, W3cV2DataIntegrityVerifiableCredential, W3cV2DataIntegrityVerifiablePresentation } from '@credo-ts/core';
2
2
  import { VsAgent } from '../agent/VsAgent';
3
3
  import { EcsClaims } from './ecsClaims';
4
+ /**
5
+ * A trust credential the agent publishes from its DID Document: a VC Data Model 2.0 credential
6
+ * secured with a DataIntegrityProof, which is what the agent issues itself and receives over the
7
+ * RFC 0809 credential format, or a data model 1.1 credential carrying a linked data proof that an
8
+ * older issuer handed over.
9
+ */
10
+ export type TrustCredential = W3cJsonLdVerifiableCredential | W3cV2DataIntegrityVerifiableCredential;
11
+ export type TrustPresentation = W3cJsonLdVerifiablePresentation | W3cV2DataIntegrityVerifiablePresentation;
12
+ /**
13
+ * Wraps a VC Data Model 2.0 credential in a data model 2.0 presentation secured with a
14
+ * DataIntegrityProof under the cryptosuite the agent is configured with, the counterpart of the
15
+ * linked data proof a data model 1.1 linked VP carries. The presentation is published from the DID
16
+ * Document rather than presented to a verifier, so there is no challenge to bind; its proof purpose
17
+ * is `authentication`, as Data Integrity defines for presentations.
18
+ */
19
+ export declare function signLinkedDataIntegrityPresentation(agent: Pick<VsAgent, 'w3cV2Credentials' | 'context'>, options: {
20
+ id: string;
21
+ holder: string;
22
+ credential: W3cV2DataIntegrityVerifiableCredential;
23
+ verificationMethodId: string;
24
+ }): Promise<W3cV2DataIntegrityVerifiablePresentation>;
4
25
  export declare function findMetadataEntry(didRecord: DidRecord, key: '_vt/vtc' | '_vt/jsc', id?: string, jsonSchemaRef?: string): any;
5
- export declare function saveMetadataEntry(agent: VsAgent, didRecord: DidRecord, credential: W3cJsonLdVerifiableCredential, verifiablePresentation: W3cJsonLdVerifiablePresentation, didDocumentServiceId: string, key: '_vt/vtc' | '_vt/jsc'): Promise<void>;
26
+ export declare function saveMetadataEntry(agent: VsAgent, didRecord: DidRecord, credential: TrustCredential, verifiablePresentation: TrustPresentation, didDocumentServiceId: string, key: '_vt/vtc' | '_vt/jsc'): Promise<void>;
6
27
  export declare function deleteMetadataEntry(agent: VsAgent, id: string, didRecord: DidRecord, key: '_vt/vtc' | '_vt/jsc'): Promise<{
7
28
  schemaId: any;
8
29
  } | null>;
9
- export declare function createVtc(agent: VsAgent, publicApiBaseUrl: string, id: string, credential: W3cJsonLdVerifiableCredential): Promise<W3cJsonLdVerifiablePresentation>;
30
+ export declare function createVtc(agent: VsAgent, publicApiBaseUrl: string, id: string, credential: TrustCredential): Promise<TrustPresentation>;
10
31
  export interface CreateJscOptions {
11
32
  schemaBaseId: string;
12
33
  jsonSchemaRef: string;
13
34
  precomputedDigestSRI?: string;
14
35
  }
15
- export declare function createJsc(agent: VsAgent, publicApiBaseUrl: string, ecsSchemas: Record<string, string>, options: CreateJscOptions): Promise<import("@credo-ts/core").W3cJsonCredential>;
36
+ export declare function createJsc(agent: VsAgent, publicApiBaseUrl: string, ecsSchemas: Record<string, string>, options: CreateJscOptions): Promise<W3cV2DataIntegritySecuredCredential & {
37
+ id: string;
38
+ }>;
16
39
  export declare function removeTrustCredential(agent: VsAgent, schemaId: string, key: '_vt/jsc' | '_vt/vtc'): Promise<{
17
40
  schemaId: any;
18
41
  } | null>;
42
+ /**
43
+ * Removes the linked VP and the stored credential an exchange delivered, as
44
+ * [VSA-VTI-FLOW-OP-REVOKE] requires of the applicant. The credential is read from the RFC 0809
45
+ * format data of the exchange; exchanges earlier versions completed over other formats are not
46
+ * migrated. Returns the credential id, or `undefined` when none is found, in which case nothing is
47
+ * removed.
48
+ */
19
49
  export declare function removeStoredTrustCredential(agent: VsAgent, credentialExchangeRecordId: string): Promise<string | undefined>;
20
50
  export declare function migrateVtjscServiceIds(agent: VsAgent): Promise<void>;
21
51
  /**
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signLinkedDataIntegrityPresentation = signLinkedDataIntegrityPresentation;
3
4
  exports.findMetadataEntry = findMetadataEntry;
4
5
  exports.saveMetadataEntry = saveMetadataEntry;
5
6
  exports.deleteMetadataEntry = deleteMetadataEntry;
@@ -14,6 +15,10 @@ exports.getTrustMetadata = getTrustMetadata;
14
15
  exports.rebindEcsCredentialSchema = rebindEcsCredentialSchema;
15
16
  exports.withdrawSelfIssuedEcsCredentials = withdrawSelfIssuedEcsCredentials;
16
17
  const core_1 = require("@credo-ts/core");
18
+ // No type definitions available for this library
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ //@ts-expect-error
21
+ const jsonld_signatures_1 = require("@digitalcredentials/jsonld-signatures");
17
22
  const verre_1 = require("@verana-labs/verre");
18
23
  const adminApiService_1 = require("../did/adminApiService");
19
24
  const setupSelfTr_1 = require("./setupSelfTr");
@@ -23,6 +28,71 @@ async function getDidRecord(agent) {
23
28
  const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
24
29
  return didRecord;
25
30
  }
31
+ /** The credential fields shared by both data models: id, credentialSchema and credentialSubject */
32
+ function trustCredentialFields(credential) {
33
+ return credential instanceof core_1.W3cV2DataIntegrityVerifiableCredential
34
+ ? credential.resolvedCredential
35
+ : credential;
36
+ }
37
+ /**
38
+ * What the metadata entry stores and the DID Document service endpoint serves. A data model 1.1
39
+ * presentation is kept as its class instance, which serializes to JSON-LD when the DID record is
40
+ * saved; a Data Integrity one wraps the secured JSON, so that is what gets stored.
41
+ */
42
+ function trustCredentialEntry(credential) {
43
+ return credential instanceof core_1.W3cV2DataIntegrityVerifiableCredential
44
+ ? credential.securedCredential
45
+ : credential.jsonCredential;
46
+ }
47
+ function trustPresentationEntry(presentation) {
48
+ return presentation instanceof core_1.W3cV2DataIntegrityVerifiablePresentation
49
+ ? presentation.securedPresentation
50
+ : presentation;
51
+ }
52
+ function trustPresentationId(presentation) {
53
+ return presentation instanceof core_1.W3cV2DataIntegrityVerifiablePresentation
54
+ ? presentation.securedPresentation.id
55
+ : presentation.id;
56
+ }
57
+ /**
58
+ * Wraps a VC Data Model 2.0 credential in a data model 2.0 presentation secured with a
59
+ * DataIntegrityProof under the cryptosuite the agent is configured with, the counterpart of the
60
+ * linked data proof a data model 1.1 linked VP carries. The presentation is published from the DID
61
+ * Document rather than presented to a verifier, so there is no challenge to bind; its proof purpose
62
+ * is `authentication`, as Data Integrity defines for presentations.
63
+ */
64
+ async function signLinkedDataIntegrityPresentation(agent, options) {
65
+ const presentation = new core_1.W3cV2Presentation({
66
+ id: options.id,
67
+ holder: options.holder,
68
+ verifiableCredential: [options.credential],
69
+ });
70
+ // The options type requires a challenge for every presentation format, while a Data Integrity
71
+ // proof only carries one when it is given
72
+ return await agent.w3cV2Credentials.signPresentation({
73
+ format: core_1.ClaimFormat.DiVp,
74
+ presentation,
75
+ cryptosuite: (0, setupSelfTr_1.getDataIntegrityCryptosuite)(agent),
76
+ verificationMethod: options.verificationMethodId,
77
+ });
78
+ }
79
+ /**
80
+ * Wraps a VC Data Model 1.1 credential in a data model 1.1 presentation carrying an
81
+ * Ed25519Signature2020 linked data proof, for credentials received from issuers that still use it.
82
+ */
83
+ async function signLinkedDataProofPresentation(agent, options) {
84
+ return await agent.w3cCredentials.signPresentation({
85
+ format: core_1.ClaimFormat.LdpVp,
86
+ presentation: new core_1.W3cPresentation({
87
+ id: options.id,
88
+ holder: options.holder,
89
+ verifiableCredential: [options.credential],
90
+ }),
91
+ proofType: 'Ed25519Signature2020',
92
+ verificationMethod: options.verificationMethodId,
93
+ proofPurpose: new jsonld_signatures_1.purposes.AssertionProofPurpose(),
94
+ });
95
+ }
26
96
  async function updateDidRecord(agent, didRecord) {
27
97
  const repo = agent.context.dependencyManager.resolve(core_1.DidRepository);
28
98
  (0, adminApiService_1.applyAdminApiServiceEntry)(didRecord.didDocument, agent.adminApiServiceEndpoint);
@@ -56,14 +126,15 @@ function findMetadataEntry(didRecord, key, id, jsonSchemaRef) {
56
126
  }
57
127
  async function saveMetadataEntry(agent, didRecord, credential, verifiablePresentation, didDocumentServiceId, key) {
58
128
  var _a, _b, _c, _d, _e;
59
- const schema = key === '_vt/vtc' ? credential.credentialSchema : credential.credentialSubject;
129
+ const fields = trustCredentialFields(credential);
130
+ const schema = key === '_vt/vtc' ? fields.credentialSchema : fields.credentialSubject;
60
131
  const ref = Array.isArray(schema) ? (_a = schema[0]) === null || _a === void 0 ? void 0 : _a.id : schema === null || schema === void 0 ? void 0 : schema.id;
61
132
  if (!ref) {
62
133
  throw new Error('No ID was found in credentialSubject');
63
134
  }
64
135
  const record = (_b = didRecord.metadata.get(key)) !== null && _b !== void 0 ? _b : {};
65
136
  // Remove previous entry for this credential ID (if exists)
66
- const found = findMetadataEntry(didRecord, key, credential.id, ref);
137
+ const found = findMetadataEntry(didRecord, key, fields.id, ref);
67
138
  if (found) {
68
139
  if ((_c = didRecord.didDocument) === null || _c === void 0 ? void 0 : _c.service) {
69
140
  didRecord.didDocument.service = didRecord.didDocument.service.filter(s => s.id !== found.didDocumentServiceId);
@@ -71,13 +142,13 @@ async function saveMetadataEntry(agent, didRecord, credential, verifiablePresent
71
142
  delete record[found.schemaId];
72
143
  }
73
144
  record[ref] = {
74
- credential: credential.jsonCredential,
75
- verifiablePresentation,
145
+ credential: trustCredentialEntry(credential),
146
+ verifiablePresentation: trustPresentationEntry(verifiablePresentation),
76
147
  didDocumentServiceId,
77
148
  };
78
149
  (_e = (_d = didRecord.didDocument) === null || _d === void 0 ? void 0 : _d.service) === null || _e === void 0 ? void 0 : _e.push(new core_1.DidDocumentService({
79
150
  id: didDocumentServiceId,
80
- serviceEndpoint: verifiablePresentation.id,
151
+ serviceEndpoint: trustPresentationId(verifiablePresentation),
81
152
  type: 'LinkedVerifiablePresentation',
82
153
  }));
83
154
  didRecord.metadata.set(key, record);
@@ -100,12 +171,13 @@ async function createVtc(agent, publicApiBaseUrl, id, credential) {
100
171
  const schemaId = `schemas-${id}-vtc-vp.json`;
101
172
  const didDocumentServiceId = `${agent.did}#vpr-${schemaId.replace('.json', '')}`;
102
173
  const serviceEndpoint = `${publicApiBaseUrl}/vt/${schemaId}`;
103
- const unsignedPresentation = (0, setupSelfTr_1.createPresentation)({
104
- id: serviceEndpoint,
105
- holder: agent.did,
106
- verifiableCredential: [credential],
107
- });
108
- const verifiablePresentation = await (0, setupSelfTr_1.signerW3c)(agent, unsignedPresentation, (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord));
174
+ const verificationMethodId = (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord);
175
+ // The linked VP takes the data model of the credential it carries: a Data Integrity credential
176
+ // cannot be embedded in a data model 1.1 presentation, nor the other way round
177
+ const linkedVp = { id: serviceEndpoint, holder: agent.did, verificationMethodId };
178
+ const verifiablePresentation = credential instanceof core_1.W3cV2DataIntegrityVerifiableCredential
179
+ ? await signLinkedDataIntegrityPresentation(agent, Object.assign(Object.assign({}, linkedVp), { credential }))
180
+ : await signLinkedDataProofPresentation(agent, Object.assign(Object.assign({}, linkedVp), { credential }));
109
181
  await saveMetadataEntry(agent, didRecord, credential, verifiablePresentation, didDocumentServiceId, '_vt/vtc');
110
182
  return verifiablePresentation;
111
183
  }
@@ -115,31 +187,30 @@ async function createJsc(agent, publicApiBaseUrl, ecsSchemas, options) {
115
187
  const { id: subjectId, claims } = (0, setupSelfTr_1.createJsonSubjectRef)(jsonSchemaRef);
116
188
  const subjectClaims = precomputedDigestSRI
117
189
  ? Object.assign(Object.assign({}, claims), { digestSRI: precomputedDigestSRI }) : await (0, setupSelfTr_1.addDigestSRI)(subjectId, claims, ecsSchemas);
118
- const credentialSubject = {
119
- id: subjectId,
120
- claims: subjectClaims,
121
- };
190
+ const credentialSubject = Object.assign(Object.assign({}, subjectClaims), { id: subjectId });
122
191
  const schemaPresentation = `schemas-${schemaBaseId}-vtjsc-vp.json`;
123
192
  const schemaCredential = `schemas-${schemaBaseId}-jsc.json`;
124
193
  const serviceEndpoint = `${publicApiBaseUrl}/vt/${schemaPresentation}`;
125
194
  const didDocumentServiceId = `${agent.did}#vpr-schemas-${schemaBaseId}-vtjsc-vp`;
195
+ const credentialId = `${publicApiBaseUrl}/vt/${schemaCredential}`;
126
196
  const unsignedCredential = (0, setupSelfTr_1.createCredential)({
127
- id: `${publicApiBaseUrl}/vt/${schemaCredential}`,
197
+ id: credentialId,
128
198
  type: ['VerifiableCredential', 'JsonSchemaCredential'],
129
199
  issuer: agent.did,
130
200
  credentialSubject,
201
+ credentialSchema: await (0, setupSelfTr_1.addDigestSRI)(setupSelfTr_1.createJsonSchema.id, { id: setupSelfTr_1.createJsonSchema.id, type: setupSelfTr_1.createJsonSchema.type }, ecsSchemas),
131
202
  });
132
- unsignedCredential.credentialSchema = await (0, setupSelfTr_1.addDigestSRI)(setupSelfTr_1.createJsonSchema.id, setupSelfTr_1.createJsonSchema, ecsSchemas);
133
203
  const verificationMethodId = (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord);
134
- const credential = await (0, setupSelfTr_1.signerW3c)(agent, core_1.JsonTransformer.fromJSON(unsignedCredential, core_1.W3cCredential), verificationMethodId);
135
- const unsignedPresentation = (0, setupSelfTr_1.createPresentation)({
204
+ const credential = await (0, setupSelfTr_1.signerW3c)(agent, unsignedCredential, verificationMethodId);
205
+ const verifiablePresentation = await signLinkedDataIntegrityPresentation(agent, {
136
206
  id: serviceEndpoint,
137
207
  holder: agent.did,
138
- verifiableCredential: [credential],
208
+ credential,
209
+ verificationMethodId,
139
210
  });
140
- const verifiablePresentation = await (0, setupSelfTr_1.signerW3c)(agent, unsignedPresentation, verificationMethodId);
141
211
  await saveMetadataEntry(agent, didRecord, credential, verifiablePresentation, didDocumentServiceId, '_vt/jsc');
142
- return credential.jsonCredential;
212
+ // the credential as published; its id is the one assigned above
213
+ return credential.securedCredential;
143
214
  }
144
215
  async function removeTrustCredential(agent, schemaId, key) {
145
216
  var _a;
@@ -155,15 +226,30 @@ async function removeTrustCredential(agent, schemaId, key) {
155
226
  }
156
227
  return await deleteMetadataEntry(agent, schemaId, didRecord, key);
157
228
  }
229
+ /**
230
+ * Removes the linked VP and the stored credential an exchange delivered, as
231
+ * [VSA-VTI-FLOW-OP-REVOKE] requires of the applicant. The credential is read from the RFC 0809
232
+ * format data of the exchange; exchanges earlier versions completed over other formats are not
233
+ * migrated. Returns the credential id, or `undefined` when none is found, in which case nothing is
234
+ * removed.
235
+ */
158
236
  async function removeStoredTrustCredential(agent, credentialExchangeRecordId) {
159
- var _a, _b;
237
+ var _a, _b, _c;
160
238
  const formatData = await agent.didcomm.credentials.getFormatData(credentialExchangeRecordId);
161
- const credentialId = (_b = (_a = formatData.credential) === null || _a === void 0 ? void 0 : _a.jsonld) === null || _b === void 0 ? void 0 : _b.id;
162
- if (!credentialId)
239
+ const credentialId = (_c = (_b = (_a = formatData.credential) === null || _a === void 0 ? void 0 : _a.dataIntegrity) === null || _b === void 0 ? void 0 : _b.credential) === null || _c === void 0 ? void 0 : _c.id;
240
+ if (typeof credentialId !== 'string') {
241
+ agent.config.logger.warn(`[trust-credential] Credential exchange ${credentialExchangeRecordId} carries no RFC 0809 credential id; its linked VP and stored credential are left in place`);
163
242
  return undefined;
243
+ }
164
244
  await removeTrustCredential(agent, credentialId, '_vt/vtc');
165
- const stored = await agent.w3cCredentials.getAll();
166
- for (const storedRecord of stored) {
245
+ // The RFC 0809 format holds a data model 2.0 credential in a W3cV2CredentialRecord and a data
246
+ // model 1.1 one in a W3cCredentialRecord; the credential id is tagged on both
247
+ for (const storedRecord of await agent.w3cV2Credentials.getAll()) {
248
+ if (storedRecord.getTags().givenId === credentialId) {
249
+ await agent.w3cV2Credentials.deleteById(storedRecord.id);
250
+ }
251
+ }
252
+ for (const storedRecord of await agent.w3cCredentials.getAll()) {
167
253
  if (storedRecord.getTags().givenId === credentialId) {
168
254
  await agent.w3cCredentials.deleteById(storedRecord.id);
169
255
  }
@@ -275,7 +361,8 @@ async function anchorCredentialDigest(agent, schemaId, credential, issuerPartici
275
361
  const schema = await agent.indexer.getCredentialSchema(schemaId).catch(() => undefined);
276
362
  if (!schema)
277
363
  throw new Error(`[DigestAnchor] Credential schema ${schemaId} is not on chain`);
278
- const digest = (0, verre_1.computeCredentialDigestJCS)(core_1.JsonTransformer.toJSON(credential), schema.digest_algorithm);
364
+ // the credential as published, which is what a verifier digests
365
+ const digest = (0, verre_1.computeCredentialDigestJCS)(credential, schema.digest_algorithm);
279
366
  // the same credential gives the same digest on each run, so an anchored digest needs no second transaction
280
367
  if (await agent.indexer.getDigest(digest))
281
368
  return;
@@ -325,10 +412,7 @@ async function rebindEcsCredentialSchema(agent, publicApiBaseUrl, schemaId, sche
325
412
  didRecord.metadata.set('_vt/vtc', record);
326
413
  await updateDidRecord(agent, didRecord);
327
414
  }
328
- await (0, selfIssuedEcsCredential_1.publishSelfIssuedEcsPresentation)(agent, vpUrl, Object.assign(Object.assign({}, (0, data_1.getEcsSchemas)(publicApiBaseUrl)), (onChainJsonSchema ? { [schemaKey]: onChainJsonSchema } : {})), schemaKey, ['VerifiableCredential', 'VerifiableTrustCredential'], { id: jscUrl, type: 'JsonSchemaCredential' }, ecsClaims, async (verifiablePresentation) => {
329
- var _a;
330
- return await anchorCredentialDigest(agent, Number(schemaId), (_a = verifiablePresentation === null || verifiablePresentation === void 0 ? void 0 : verifiablePresentation.verifiableCredential) === null || _a === void 0 ? void 0 : _a[0], issuerParticipantId);
331
- });
415
+ await (0, selfIssuedEcsCredential_1.publishSelfIssuedEcsPresentation)(agent, vpUrl, Object.assign(Object.assign({}, (0, data_1.getEcsSchemas)(publicApiBaseUrl)), (onChainJsonSchema ? { [schemaKey]: onChainJsonSchema } : {})), schemaKey, ['VerifiableCredential', 'VerifiableTrustCredential'], { id: jscUrl, type: 'JsonSchemaCredential' }, ecsClaims, async (verifiablePresentation) => await anchorCredentialDigest(agent, Number(schemaId), verifiablePresentation.verifiableCredential[0], issuerParticipantId));
332
416
  const freshRecord = await getDidRecord(agent);
333
417
  let recordChanged = false;
334
418
  const vtc = (_f = freshRecord.metadata.get('_vt/vtc')) !== null && _f !== void 0 ? _f : {};