@twin.org/standards-w3c-did 0.0.3-next.67 → 0.0.3-next.68

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 (33) hide show
  1. package/dist/es/dataTypes/didDataTypes.js +1 -1
  2. package/dist/es/dataTypes/didDataTypes.js.map +1 -1
  3. package/dist/es/models/IDidVerifiableCredentialCommon.js.map +1 -1
  4. package/dist/es/models/didContexts.js +8 -24
  5. package/dist/es/models/didContexts.js.map +1 -1
  6. package/dist/es/signerVerifiers/dataIntegrityProofAsyncSignerVerifier.js +1 -3
  7. package/dist/es/signerVerifiers/dataIntegrityProofAsyncSignerVerifier.js.map +1 -1
  8. package/dist/es/signerVerifiers/dataIntegrityProofSignerVerifier.js +3 -3
  9. package/dist/es/signerVerifiers/dataIntegrityProofSignerVerifier.js.map +1 -1
  10. package/dist/es/signerVerifiers/jsonWebSignature2020AsyncSignerVerifier.js +0 -2
  11. package/dist/es/signerVerifiers/jsonWebSignature2020AsyncSignerVerifier.js.map +1 -1
  12. package/dist/es/signerVerifiers/jsonWebSignature2020SignerVerifier.js +3 -2
  13. package/dist/es/signerVerifiers/jsonWebSignature2020SignerVerifier.js.map +1 -1
  14. package/dist/es/utils/verifiableCredentialHelper.js +16 -16
  15. package/dist/es/utils/verifiableCredentialHelper.js.map +1 -1
  16. package/dist/types/dataTypes/didDataTypes.d.ts +1 -1
  17. package/dist/types/models/IDidVerifiableCredentialCommon.d.ts +2 -2
  18. package/dist/types/models/didContexts.d.ts +8 -24
  19. package/dist/types/signerVerifiers/dataIntegrityProofAsyncSignerVerifier.d.ts +1 -3
  20. package/dist/types/signerVerifiers/dataIntegrityProofSignerVerifier.d.ts +3 -3
  21. package/dist/types/signerVerifiers/jsonWebSignature2020AsyncSignerVerifier.d.ts +0 -2
  22. package/dist/types/signerVerifiers/jsonWebSignature2020SignerVerifier.d.ts +3 -2
  23. package/dist/types/utils/verifiableCredentialHelper.d.ts +16 -16
  24. package/docs/changelog.md +14 -0
  25. package/docs/reference/classes/DataIntegrityProofAsyncSignerVerifier.md +3 -2
  26. package/docs/reference/classes/DataIntegrityProofSignerVerifier.md +5 -2
  27. package/docs/reference/classes/DidDataTypes.md +1 -1
  28. package/docs/reference/classes/JsonWebSignature2020AsyncSignerVerifier.md +0 -2
  29. package/docs/reference/classes/JsonWebSignature2020SignerVerifier.md +6 -2
  30. package/docs/reference/classes/VerifiableCredentialHelper.md +16 -16
  31. package/docs/reference/interfaces/IDidVerifiableCredentialCommon.md +4 -1
  32. package/docs/reference/variables/DidContexts.md +8 -24
  33. package/package.json +1 -1
@@ -7,7 +7,7 @@ import DidDocumentSchema from "../schemas/DidDocument.json" with { type: "json"
7
7
  import DidVerifiableCredentialSchema from "../schemas/DidVerifiableCredential.json" with { type: "json" };
8
8
  import DidVerifiablePresentationSchema from "../schemas/DidVerifiablePresentation.json" with { type: "json" };
9
9
  /**
10
- * Data Type registration for DID.
10
+ * Handles data type registration for DID.
11
11
  */
12
12
  export class DidDataTypes {
13
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"didDataTypes.js","sourceRoot":"","sources":["../../../src/dataTypes/didDataTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,iBAAiB,MAAM,6BAA6B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClF,OAAO,6BAA6B,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1G,OAAO,+BAA+B,MAAM,2CAA2C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE9G;;GAEG;AACH,MAAM,OAAgB,YAAY;IACjC;;OAEG;IACI,MAAM,CAAC,aAAa;QAC1B,MAAM,KAAK,GAAG;YACb;gBACC,IAAI,EAAE,QAAQ,CAAC,QAAQ;gBACvB,MAAM,EAAE,iBAAiB;aACzB;SACD,CAAC;QAEF,cAAc,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACtE,cAAc,CAAC,aAAa,CAC3B,WAAW,CAAC,mBAAmB,EAC/B,SAAS,EACT,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAC5D,CAAC;QAEF,MAAM,gBAAgB,GAAG;YACxB;gBACC,IAAI,EAAE,QAAQ,CAAC,oBAAoB;gBACnC,MAAM,EAAE,6BAA6B;aACrC;YACD;gBACC,IAAI,EAAE,QAAQ,CAAC,sBAAsB;gBACrC,MAAM,EAAE,+BAA+B;aACvC;SACD,CAAC;QAEF,cAAc,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACrF,cAAc,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACrF,cAAc,CAAC,aAAa,CAC3B,WAAW,CAAC,mBAAmB,EAC/B,SAAS,EACT,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CACvE,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { DataTypeHelper } from \"@twin.org/data-core\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidTypes } from \"../models/didTypes.js\";\nimport DidDocumentSchema from \"../schemas/DidDocument.json\" with { type: \"json\" };\nimport DidVerifiableCredentialSchema from \"../schemas/DidVerifiableCredential.json\" with { type: \"json\" };\nimport DidVerifiablePresentationSchema from \"../schemas/DidVerifiablePresentation.json\" with { type: \"json\" };\n\n/**\n * Data Type registration for DID.\n */\nexport abstract class DidDataTypes {\n\t/**\n\t * Register all the data types.\n\t */\n\tpublic static registerTypes(): void {\n\t\tconst types = [\n\t\t\t{\n\t\t\t\ttype: DidTypes.Document,\n\t\t\t\tschema: DidDocumentSchema\n\t\t\t}\n\t\t];\n\n\t\tDataTypeHelper.registerTypes(DidContexts.Namespace, undefined, types);\n\t\tDataTypeHelper.registerTypes(\n\t\t\tDidContexts.JsonSchemaNamespace,\n\t\t\tundefined,\n\t\t\ttypes.map(t => ({ type: `Did${t.type}`, schema: t.schema }))\n\t\t);\n\n\t\tconst typesCredentials = [\n\t\t\t{\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tschema: DidVerifiableCredentialSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: DidTypes.VerifiablePresentation,\n\t\t\t\tschema: DidVerifiablePresentationSchema\n\t\t\t}\n\t\t];\n\n\t\tDataTypeHelper.registerTypes(DidContexts.NamespaceVCv1, undefined, typesCredentials);\n\t\tDataTypeHelper.registerTypes(DidContexts.NamespaceVCv2, undefined, typesCredentials);\n\t\tDataTypeHelper.registerTypes(\n\t\t\tDidContexts.JsonSchemaNamespace,\n\t\t\tundefined,\n\t\t\ttypesCredentials.map(t => ({ type: `Did${t.type}`, schema: t.schema }))\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"didDataTypes.js","sourceRoot":"","sources":["../../../src/dataTypes/didDataTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,E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,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CACvE,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { DataTypeHelper } from \"@twin.org/data-core\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidTypes } from \"../models/didTypes.js\";\nimport DidDocumentSchema from \"../schemas/DidDocument.json\" with { type: \"json\" };\nimport DidVerifiableCredentialSchema from \"../schemas/DidVerifiableCredential.json\" with { type: \"json\" };\nimport DidVerifiablePresentationSchema from \"../schemas/DidVerifiablePresentation.json\" with { type: \"json\" };\n\n/**\n * Handles data type registration for DID.\n */\nexport abstract class DidDataTypes {\n\t/**\n\t * Register all the data types.\n\t */\n\tpublic static registerTypes(): void {\n\t\tconst types = [\n\t\t\t{\n\t\t\t\ttype: DidTypes.Document,\n\t\t\t\tschema: DidDocumentSchema\n\t\t\t}\n\t\t];\n\n\t\tDataTypeHelper.registerTypes(DidContexts.Namespace, undefined, types);\n\t\tDataTypeHelper.registerTypes(\n\t\t\tDidContexts.JsonSchemaNamespace,\n\t\t\tundefined,\n\t\t\ttypes.map(t => ({ type: `Did${t.type}`, schema: t.schema }))\n\t\t);\n\n\t\tconst typesCredentials = [\n\t\t\t{\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tschema: DidVerifiableCredentialSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: DidTypes.VerifiablePresentation,\n\t\t\t\tschema: DidVerifiablePresentationSchema\n\t\t\t}\n\t\t];\n\n\t\tDataTypeHelper.registerTypes(DidContexts.NamespaceVCv1, undefined, typesCredentials);\n\t\tDataTypeHelper.registerTypes(DidContexts.NamespaceVCv2, undefined, typesCredentials);\n\t\tDataTypeHelper.registerTypes(\n\t\t\tDidContexts.JsonSchemaNamespace,\n\t\t\tundefined,\n\t\t\ttypesCredentials.map(t => ({ type: `Did${t.type}`, schema: t.schema }))\n\t\t);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDidVerifiableCredentialCommon.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiableCredentialCommon.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ObjectOrArray } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { IDidCredentialSchema } from \"./IDidCredentialSchema.js\";\nimport type { IDidCredentialStatus } from \"./IDidCredentialStatus.js\";\nimport type { IDidLabel } from \"./IDidLabel.js\";\nimport type { IProof } from \"./IProof.js\";\n\n/**\n * Interface describing a verifiable credential.\n * https://www.w3.org/TR/vc-data-model-2.0\n */\nexport interface IDidVerifiableCredentialCommon {\n\t/**\n\t * The identifier for the verifiable credential.\n\t */\n\tid?: string;\n\n\t/**\n\t * The types of the data stored in the verifiable credential.\n\t */\n\ttype: ObjectOrArray<string>;\n\n\t/**\n\t * The data for the verifiable credential.\n\t */\n\tcredentialSubject?: ObjectOrArray<IJsonLdNodeObject>;\n\n\t/**\n\t * Used to discover information about the current status of the\n\t * verifiable credential, such as whether it is suspended or revoked.\n\t */\n\tcredentialStatus?: ObjectOrArray<IDidCredentialStatus>;\n\n\t/**\n\t * Annotate type definitions or lock them to specific versions of the vocabulary.\n\t */\n\tcredentialSchema?: ObjectOrArray<IDidCredentialSchema>;\n\n\t/**\n\t * The issuing identity.\n\t */\n\tissuer?: string | { id: string; name?: string | IDidLabel[]; description?: string | IDidLabel[] };\n\n\t/**\n\t * The name of the credential.\n\t */\n\tname?: string | IDidLabel[];\n\n\t/**\n\t * The description of the credential.\n\t */\n\tdescription?: string | IDidLabel[];\n\n\t/**\n\t * Evidence associated with the Credential.\n\t */\n\tevidence?: ObjectOrArray<IJsonLdNodeObject>;\n\n\t/**\n\t * Proofs that the verifiable credential is valid.\n\t * Optional if a different proof method is used, such as JWT.\n\t */\n\tproof?: ObjectOrArray<IProof>;\n}\n"]}
1
+ {"version":3,"file":"IDidVerifiableCredentialCommon.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiableCredentialCommon.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ObjectOrArray } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { IDidCredentialSchema } from \"./IDidCredentialSchema.js\";\nimport type { IDidCredentialStatus } from \"./IDidCredentialStatus.js\";\nimport type { IDidLabel } from \"./IDidLabel.js\";\nimport type { IProof } from \"./IProof.js\";\n\n/**\n * Common properties shared by all verifiable credential versions.\n * @see https://www.w3.org/TR/vc-data-model-2.0\n */\nexport interface IDidVerifiableCredentialCommon {\n\t/**\n\t * The identifier for the verifiable credential.\n\t */\n\tid?: string;\n\n\t/**\n\t * The types of the data stored in the verifiable credential.\n\t */\n\ttype: ObjectOrArray<string>;\n\n\t/**\n\t * The data for the verifiable credential.\n\t */\n\tcredentialSubject?: ObjectOrArray<IJsonLdNodeObject>;\n\n\t/**\n\t * Used to discover information about the current status of the\n\t * verifiable credential, such as whether it is suspended or revoked.\n\t */\n\tcredentialStatus?: ObjectOrArray<IDidCredentialStatus>;\n\n\t/**\n\t * Annotate type definitions or lock them to specific versions of the vocabulary.\n\t */\n\tcredentialSchema?: ObjectOrArray<IDidCredentialSchema>;\n\n\t/**\n\t * The issuing identity.\n\t */\n\tissuer?: string | { id: string; name?: string | IDidLabel[]; description?: string | IDidLabel[] };\n\n\t/**\n\t * The name of the credential.\n\t */\n\tname?: string | IDidLabel[];\n\n\t/**\n\t * The description of the credential.\n\t */\n\tdescription?: string | IDidLabel[];\n\n\t/**\n\t * Evidence associated with the Credential.\n\t */\n\tevidence?: ObjectOrArray<IJsonLdNodeObject>;\n\n\t/**\n\t * Proofs that the verifiable credential is valid.\n\t * Optional if a different proof method is used, such as JWT.\n\t */\n\tproof?: ObjectOrArray<IProof>;\n}\n"]}
@@ -10,9 +10,7 @@ export const DidContexts = {
10
10
  */
11
11
  Namespace: "https://www.w3.org/ns/did/v1",
12
12
  /**
13
- * The value to use in JSON-LD context for DID.
14
- * Note: Context matches Namespace (no trailing slash) as per W3C DID specification.
15
- * The W3C DID JSON-LD context URL format does not include a trailing slash.
13
+ * The value to use in the JSON-LD context for DID.
16
14
  */
17
15
  Context: "https://www.w3.org/ns/did/v1",
18
16
  /**
@@ -24,9 +22,7 @@ export const DidContexts = {
24
22
  */
25
23
  NamespaceVCv1: "https://www.w3.org/2018/credentials/v1",
26
24
  /**
27
- * The value to use in JSON-LD context for DID VC v1.
28
- * Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.
29
- * The W3C VC v1 JSON-LD context URL format does not include a trailing slash.
25
+ * The value to use in the JSON-LD context for DID VC v1.
30
26
  */
31
27
  ContextVCv1: "https://www.w3.org/2018/credentials/v1",
32
28
  /**
@@ -34,9 +30,7 @@ export const DidContexts = {
34
30
  */
35
31
  NamespaceVCv2: "https://www.w3.org/ns/credentials/v2",
36
32
  /**
37
- * The value to use in JSON-LD context for DID VC v2.
38
- * Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.
39
- * The W3C VC v2 JSON-LD context URL format does not include a trailing slash.
33
+ * The value to use in the JSON-LD context for DID VC v2.
40
34
  */
41
35
  ContextVCv2: "https://www.w3.org/ns/credentials/v2",
42
36
  /**
@@ -44,9 +38,7 @@ export const DidContexts = {
44
38
  */
45
39
  NamespaceSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1",
46
40
  /**
47
- * The value to use in JSON-LD context for security ed25519 suites.
48
- * Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.
49
- * The ed25519-2020 JSON-LD context URL format does not include a trailing slash.
41
+ * The value to use in the JSON-LD context for security ed25519 suites.
50
42
  */
51
43
  ContextSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1",
52
44
  /**
@@ -54,9 +46,7 @@ export const DidContexts = {
54
46
  */
55
47
  NamespaceSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1",
56
48
  /**
57
- * The value to use in JSON-LD context for security jws-2020 suites.
58
- * Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.
59
- * The jws-2020 JSON-LD context URL format does not include a trailing slash.
49
+ * The value to use in the JSON-LD context for security jws-2020 suites.
60
50
  */
61
51
  ContextSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1",
62
52
  /**
@@ -64,9 +54,7 @@ export const DidContexts = {
64
54
  */
65
55
  NamespaceDataIntegrity: "https://w3id.org/security/data-integrity/v2",
66
56
  /**
67
- * The value to use in JSON-LD context for VC Data Integrity.
68
- * Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.
69
- * The Data Integrity JSON-LD context URL format does not include a trailing slash.
57
+ * The value to use in the JSON-LD context for VC Data Integrity.
70
58
  */
71
59
  ContextDataIntegrity: "https://w3id.org/security/data-integrity/v2",
72
60
  /**
@@ -74,9 +62,7 @@ export const DidContexts = {
74
62
  */
75
63
  NamespaceControllerIdentifiers: "https://www.w3.org/ns/cid/v1",
76
64
  /**
77
- * The value to use in JSON-LD context for controller identifiers.
78
- * Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.
79
- * The Controller Identifiers JSON-LD context URL format does not include a trailing slash.
65
+ * The value to use in the JSON-LD context for controller identifiers.
80
66
  */
81
67
  ContextControllerIdentifiers: "https://www.w3.org/ns/cid/v1",
82
68
  /**
@@ -84,9 +70,7 @@ export const DidContexts = {
84
70
  */
85
71
  NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1",
86
72
  /**
87
- * The value to use in JSON-LD context for security multikey suites.
88
- * Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.
89
- * The multikey JSON-LD context URL format does not include a trailing slash.
73
+ * The value to use in the JSON-LD context for security multikey suites.
90
74
  */
91
75
  ContextSecurityMultikey: "https://w3id.org/security/multikey/v1"
92
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"didContexts.js","sourceRoot":"","sources":["../../../src/models/didContexts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B;;OAEG;IACH,SAAS,EAAE,8BAA8B;IAEzC;;;;OAIG;IACH,OAAO,EAAE,8BAA8B;IAEvC;;OAEG;IACH,mBAAmB,EAAE,qCAAqC;IAE1D;;OAEG;IACH,aAAa,EAAE,wCAAwC;IAEvD;;;;OAIG;IACH,WAAW,EAAE,wCAAwC;IAErD;;OAEG;IACH,aAAa,EAAE,sCAAsC;IAErD;;;;OAIG;IACH,WAAW,EAAE,sCAAsC;IAEnD;;OAEG;IACH,wBAAwB,EAAE,kDAAkD;IAE5E;;;;OAIG;IACH,sBAAsB,EAAE,kDAAkD;IAE1E;;OAEG;IACH,wBAAwB,EAAE,8CAA8C;IAExE;;;;OAIG;IACH,sBAAsB,EAAE,8CAA8C;IAEtE;;OAEG;IACH,sBAAsB,EAAE,6CAA6C;IAErE;;;;OAIG;IACH,oBAAoB,EAAE,6CAA6C;IAEnE;;OAEG;IACH,8BAA8B,EAAE,8BAA8B;IAE9D;;;;OAIG;IACH,4BAA4B,EAAE,8BAA8B;IAE5D;;OAEG;IACH,yBAAyB,EAAE,uCAAuC;IAElE;;;;OAIG;IACH,uBAAuB,EAAE,uCAAuC;CACvD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The contexts for DIDs.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const DidContexts = {\n\t/**\n\t * The canonical RDF namespace URI for DID.\n\t */\n\tNamespace: \"https://www.w3.org/ns/did/v1\",\n\n\t/**\n\t * The value to use in JSON-LD context for DID.\n\t * Note: Context matches Namespace (no trailing slash) as per W3C DID specification.\n\t * The W3C DID JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContext: \"https://www.w3.org/ns/did/v1\",\n\n\t/**\n\t * The namespace location of the hosted version of the JSON Schema.\n\t */\n\tJsonSchemaNamespace: \"https://schema.twindev.org/w3c-did/\",\n\n\t/**\n\t * The canonical RDF namespace URI for DID VC v1.\n\t */\n\tNamespaceVCv1: \"https://www.w3.org/2018/credentials/v1\",\n\n\t/**\n\t * The value to use in JSON-LD context for DID VC v1.\n\t * Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.\n\t * The W3C VC v1 JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextVCv1: \"https://www.w3.org/2018/credentials/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for DID VC v2.\n\t */\n\tNamespaceVCv2: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The value to use in JSON-LD context for DID VC v2.\n\t * Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.\n\t * The W3C VC v2 JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextVCv2: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The canonical RDF namespace URI for security ed25519 suites.\n\t */\n\tNamespaceSecurityEd25519: \"https://w3id.org/security/suites/ed25519-2020/v1\",\n\n\t/**\n\t * The value to use in JSON-LD context for security ed25519 suites.\n\t * Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.\n\t * The ed25519-2020 JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextSecurityEd25519: \"https://w3id.org/security/suites/ed25519-2020/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for security jws-2020 suites.\n\t */\n\tNamespaceSecurityJws2020: \"https://w3id.org/security/suites/jws-2020/v1\",\n\n\t/**\n\t * The value to use in JSON-LD context for security jws-2020 suites.\n\t * Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.\n\t * The jws-2020 JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextSecurityJws2020: \"https://w3id.org/security/suites/jws-2020/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for VC Data Integrity.\n\t */\n\tNamespaceDataIntegrity: \"https://w3id.org/security/data-integrity/v2\",\n\n\t/**\n\t * The value to use in JSON-LD context for VC Data Integrity.\n\t * Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.\n\t * The Data Integrity JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextDataIntegrity: \"https://w3id.org/security/data-integrity/v2\",\n\n\t/**\n\t * The canonical RDF namespace URI for controller identifiers.\n\t */\n\tNamespaceControllerIdentifiers: \"https://www.w3.org/ns/cid/v1\",\n\n\t/**\n\t * The value to use in JSON-LD context for controller identifiers.\n\t * Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.\n\t * The Controller Identifiers JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextControllerIdentifiers: \"https://www.w3.org/ns/cid/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for security multikey suites.\n\t */\n\tNamespaceSecurityMultikey: \"https://w3id.org/security/multikey/v1\",\n\n\t/**\n\t * The value to use in JSON-LD context for security multikey suites.\n\t * Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.\n\t * The multikey JSON-LD context URL format does not include a trailing slash.\n\t */\n\tContextSecurityMultikey: \"https://w3id.org/security/multikey/v1\"\n} as const;\n\n/**\n * The contexts for DIDs.\n */\nexport type DidContexts = (typeof DidContexts)[keyof typeof DidContexts];\n"]}
1
+ {"version":3,"file":"didContexts.js","sourceRoot":"","sources":["../../../src/models/didContexts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B;;OAEG;IACH,SAAS,EAAE,8BAA8B;IAEzC;;OAEG;IACH,OAAO,EAAE,8BAA8B;IAEvC;;OAEG;IACH,mBAAmB,EAAE,qCAAqC;IAE1D;;OAEG;IACH,aAAa,EAAE,wCAAwC;IAEvD;;OAEG;IACH,WAAW,EAAE,wCAAwC;IAErD;;OAEG;IACH,aAAa,EAAE,sCAAsC;IAErD;;OAEG;IACH,WAAW,EAAE,sCAAsC;IAEnD;;OAEG;IACH,wBAAwB,EAAE,kDAAkD;IAE5E;;OAEG;IACH,sBAAsB,EAAE,kDAAkD;IAE1E;;OAEG;IACH,wBAAwB,EAAE,8CAA8C;IAExE;;OAEG;IACH,sBAAsB,EAAE,8CAA8C;IAEtE;;OAEG;IACH,sBAAsB,EAAE,6CAA6C;IAErE;;OAEG;IACH,oBAAoB,EAAE,6CAA6C;IAEnE;;OAEG;IACH,8BAA8B,EAAE,8BAA8B;IAE9D;;OAEG;IACH,4BAA4B,EAAE,8BAA8B;IAE5D;;OAEG;IACH,yBAAyB,EAAE,uCAAuC;IAElE;;OAEG;IACH,uBAAuB,EAAE,uCAAuC;CACvD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The contexts for DIDs.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const DidContexts = {\n\t/**\n\t * The canonical RDF namespace URI for DID.\n\t */\n\tNamespace: \"https://www.w3.org/ns/did/v1\",\n\n\t/**\n\t * The value to use in the JSON-LD context for DID.\n\t */\n\tContext: \"https://www.w3.org/ns/did/v1\",\n\n\t/**\n\t * The namespace location of the hosted version of the JSON Schema.\n\t */\n\tJsonSchemaNamespace: \"https://schema.twindev.org/w3c-did/\",\n\n\t/**\n\t * The canonical RDF namespace URI for DID VC v1.\n\t */\n\tNamespaceVCv1: \"https://www.w3.org/2018/credentials/v1\",\n\n\t/**\n\t * The value to use in the JSON-LD context for DID VC v1.\n\t */\n\tContextVCv1: \"https://www.w3.org/2018/credentials/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for DID VC v2.\n\t */\n\tNamespaceVCv2: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The value to use in the JSON-LD context for DID VC v2.\n\t */\n\tContextVCv2: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The canonical RDF namespace URI for security ed25519 suites.\n\t */\n\tNamespaceSecurityEd25519: \"https://w3id.org/security/suites/ed25519-2020/v1\",\n\n\t/**\n\t * The value to use in the JSON-LD context for security ed25519 suites.\n\t */\n\tContextSecurityEd25519: \"https://w3id.org/security/suites/ed25519-2020/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for security jws-2020 suites.\n\t */\n\tNamespaceSecurityJws2020: \"https://w3id.org/security/suites/jws-2020/v1\",\n\n\t/**\n\t * The value to use in the JSON-LD context for security jws-2020 suites.\n\t */\n\tContextSecurityJws2020: \"https://w3id.org/security/suites/jws-2020/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for VC Data Integrity.\n\t */\n\tNamespaceDataIntegrity: \"https://w3id.org/security/data-integrity/v2\",\n\n\t/**\n\t * The value to use in the JSON-LD context for VC Data Integrity.\n\t */\n\tContextDataIntegrity: \"https://w3id.org/security/data-integrity/v2\",\n\n\t/**\n\t * The canonical RDF namespace URI for controller identifiers.\n\t */\n\tNamespaceControllerIdentifiers: \"https://www.w3.org/ns/cid/v1\",\n\n\t/**\n\t * The value to use in the JSON-LD context for controller identifiers.\n\t */\n\tContextControllerIdentifiers: \"https://www.w3.org/ns/cid/v1\",\n\n\t/**\n\t * The canonical RDF namespace URI for security multikey suites.\n\t */\n\tNamespaceSecurityMultikey: \"https://w3id.org/security/multikey/v1\",\n\n\t/**\n\t * The value to use in the JSON-LD context for security multikey suites.\n\t */\n\tContextSecurityMultikey: \"https://w3id.org/security/multikey/v1\"\n} as const;\n\n/**\n * The contexts for DIDs.\n */\nexport type DidContexts = (typeof DidContexts)[keyof typeof DidContexts];\n"]}
@@ -7,8 +7,7 @@ import { DidContexts } from "../models/didContexts.js";
7
7
  import { JwsAlgorithms } from "../models/jwsAlgorithms.js";
8
8
  /**
9
9
  * Helper methods for creating and verifying Data Integrity proofs with async signing callbacks.
10
- * This implementation delegates signing to a secure callback to prevent private key exposure.
11
- * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
10
+ * @see https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
12
11
  */
13
12
  export class DataIntegrityProofAsyncSignerVerifier {
14
13
  /**
@@ -28,7 +27,6 @@ export class DataIntegrityProofAsyncSignerVerifier {
28
27
  }
29
28
  /**
30
29
  * Create a proof with an async signing callback.
31
- * This method prevents private key exposure by delegating signing to a secure callback.
32
30
  * @param unsecuredDocument The data to create the proof for.
33
31
  * @param unsignedProof The proof options.
34
32
  * @param signCallback Async callback that signs data with a private key from secure storage.
@@ -1 +1 @@
1
- {"version":3,"file":"dataIntegrityProofAsyncSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/dataIntegrityProofAsyncSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAGjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;;GAIG;AACH,MAAM,OAAO,qCAAqC;IACjD;;OAEG;IACI,MAAM,CAAU,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O,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,eAAe,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACtF,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,UAAU,CACtB,iBAAoC,EACpC,aAAkC;QAElC,sCAAsC;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAC9E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards, ObjectHelper } from \"@twin.org/core\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { DataIntegrityProofSignerVerifier } from \"./dataIntegrityProofSignerVerifier.js\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IDataIntegrityProof } from \"../models/IDataIntegrityProof.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifierAsync } from \"../models/IProofSignerVerifierAsync.js\";\nimport { JwsAlgorithms } from \"../models/jwsAlgorithms.js\";\n\n/**\n * Helper methods for creating and verifying Data Integrity proofs with async signing callbacks.\n * This implementation delegates signing to a secure callback to prevent private key exposure.\n * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022\n */\nexport class DataIntegrityProofAsyncSignerVerifier implements IProofSignerVerifierAsync {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataIntegrityProofAsyncSignerVerifier>();\n\n\t/**\n\t * The underlying sync signer verifier for hash and verify operations.\n\t * @internal\n\t */\n\tprivate readonly _syncSignerVerifier: DataIntegrityProofSignerVerifier;\n\n\t/**\n\t * Create a new instance of DataIntegrityProofAsyncSignerVerifier.\n\t */\n\tconstructor() {\n\t\tthis._syncSignerVerifier = new DataIntegrityProofSignerVerifier();\n\t}\n\n\t/**\n\t * Create a proof with an async signing callback.\n\t * This method prevents private key exposure by delegating signing to a secure callback.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signCallback Async callback that signs data with a private key from secure storage.\n\t * @returns The created proof.\n\t */\n\tpublic async createProofWithSigner(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof,\n\t\tsignCallback: (data: Uint8Array, algorithm: string) => Promise<Uint8Array>\n\t): Promise<IProof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofAsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IProof>(\n\t\t\tDataIntegrityProofAsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.function(\n\t\t\tDataIntegrityProofAsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signCallback),\n\t\t\tsignCallback\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\"@context\"] as IDataIntegrityProof[\"@context\"];\n\n\t\t// Use the sync verifier to create the hash\n\t\tconst combinedHash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\t// Sign with the callback (key stays in secure storage)\n\t\t// Pass JWS algorithm for vault validation\n\t\tconst signature = await signCallback(combinedHash, JwsAlgorithms.EdDSA);\n\n\t\tsignedProof.proofValue = `z${Converter.bytesToBase58(signature)}`;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IDataIntegrityProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\t// Delegate to the sync implementation\n\t\treturn this._syncSignerVerifier.verifyProof(securedDocument, signedProof, verifyKey);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof\n\t): Promise<Uint8Array> {\n\t\t// Delegate to the sync implementation\n\t\treturn this._syncSignerVerifier.createHash(unsecuredDocument, unsignedProof);\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataIntegrityProofAsyncSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/dataIntegrityProofAsyncSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAGjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;GAGG;AACH,MAAM,OAAO,qCAAqC;IACjD;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,mBAAmB,CAAmC;IAEvE;;OAEG;IACH;QACC,IAAI,CAAC,mBAAmB,GAAG,IAAI,gCAAgC,EAAE,CAAC;IACnE,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,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;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAC9E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards, ObjectHelper } from \"@twin.org/core\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { DataIntegrityProofSignerVerifier } from \"./dataIntegrityProofSignerVerifier.js\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IDataIntegrityProof } from \"../models/IDataIntegrityProof.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifierAsync } from \"../models/IProofSignerVerifierAsync.js\";\nimport { JwsAlgorithms } from \"../models/jwsAlgorithms.js\";\n\n/**\n * Helper methods for creating and verifying Data Integrity proofs with async signing callbacks.\n * @see https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022\n */\nexport class DataIntegrityProofAsyncSignerVerifier implements IProofSignerVerifierAsync {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataIntegrityProofAsyncSignerVerifier>();\n\n\t/**\n\t * The underlying sync signer verifier for hash and verify operations.\n\t * @internal\n\t */\n\tprivate readonly _syncSignerVerifier: DataIntegrityProofSignerVerifier;\n\n\t/**\n\t * Create a new instance of DataIntegrityProofAsyncSignerVerifier.\n\t */\n\tconstructor() {\n\t\tthis._syncSignerVerifier = new DataIntegrityProofSignerVerifier();\n\t}\n\n\t/**\n\t * Create a proof with an async signing callback.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signCallback Async callback that signs data with a private key from secure storage.\n\t * @returns The created proof.\n\t */\n\tpublic async createProofWithSigner(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof,\n\t\tsignCallback: (data: Uint8Array, algorithm: string) => Promise<Uint8Array>\n\t): Promise<IProof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofAsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IProof>(\n\t\t\tDataIntegrityProofAsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.function(\n\t\t\tDataIntegrityProofAsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signCallback),\n\t\t\tsignCallback\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\"@context\"] as IDataIntegrityProof[\"@context\"];\n\n\t\t// Use the sync verifier to create the hash\n\t\tconst combinedHash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\t// Sign with the callback (key stays in secure storage)\n\t\t// Pass JWS algorithm for vault validation\n\t\tconst signature = await signCallback(combinedHash, JwsAlgorithms.EdDSA);\n\n\t\tsignedProof.proofValue = `z${Converter.bytesToBase58(signature)}`;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IDataIntegrityProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\t// Delegate to the sync implementation\n\t\treturn this._syncSignerVerifier.verifyProof(securedDocument, signedProof, verifyKey);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof\n\t): Promise<Uint8Array> {\n\t\t// Delegate to the sync implementation\n\t\treturn this._syncSignerVerifier.createHash(unsecuredDocument, unsignedProof);\n\t}\n}\n"]}
@@ -7,8 +7,8 @@ import { Jwk } from "@twin.org/web";
7
7
  import { DidContexts } from "../models/didContexts.js";
8
8
  import { DidCryptoSuites } from "../models/didCryptoSuites.js";
9
9
  /**
10
- * Helper methods for creating and verifying proofs.
11
- * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
10
+ * Helper methods for creating and verifying Data Integrity proofs using EdDSA-JCS-2022.
11
+ * @see https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
12
12
  */
13
13
  export class DataIntegrityProofSignerVerifier {
14
14
  /**
@@ -40,7 +40,7 @@ export class DataIntegrityProofSignerVerifier {
40
40
  return signedProof;
41
41
  }
42
42
  /**
43
- * Verify a proof for the given data in format.
43
+ * Verify a proof for the given data.
44
44
  * @param securedDocument The credential to verify.
45
45
  * @param signedProof The proof to verify.
46
46
  * @param verifyKey The public key to verify the proof with.
@@ -1 +1 @@
1
- {"version":3,"file":"dataIntegrityProofSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/dataIntegrityProofSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAA0B,MAAM,wBA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;QAEvF,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC7E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tObjectHelper,\n\tUint8ArrayHelper\n} from \"@twin.org/core\";\nimport { Ed25519, Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Jwk, type IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidCryptoSuites } from \"../models/didCryptoSuites.js\";\nimport type { IDataIntegrityProof } from \"../models/IDataIntegrityProof.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022\n */\nexport class DataIntegrityProofSignerVerifier implements IProofSignerVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataIntegrityProofSignerVerifier>();\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signKey The key to sign the proof with.\n\t * @returns The created proof.\n\t */\n\tpublic async createProof(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof,\n\t\tsignKey: IJwk\n\t): Promise<IProof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(signKey), signKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(signKey);\n\t\tif (!Is.uint8Array(rawKeys.privateKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPrivateKey\");\n\t\t}\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\"@context\"] as IDataIntegrityProof[\"@context\"];\n\n\t\tconst combinedHash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\tconst signature = Ed25519.sign(rawKeys.privateKey, combinedHash);\n\n\t\tsignedProof.proofValue = `z${Converter.bytesToBase58(signature)}`;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data in format.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IDataIntegrityProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IDataIntegrityProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof),\n\t\t\tsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof.proofValue),\n\t\t\tsignedProof.proofValue\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(verifyKey), verifyKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(verifyKey);\n\t\tif (!Is.uint8Array(rawKeys.publicKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPublicKey\");\n\t\t}\n\n\t\tconst combinedHash = await this.createHash(securedDocument, signedProof);\n\n\t\treturn Ed25519.verify(\n\t\t\trawKeys.publicKey,\n\t\t\tcombinedHash,\n\t\t\tConverter.base58ToBytes(signedProof.proofValue.slice(1))\n\t\t);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof\n\t): Promise<Uint8Array> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IDataIntegrityProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.cryptosuite),\n\t\t\tunsignedProof.cryptosuite\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.verificationMethod),\n\t\t\tunsignedProof.verificationMethod\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\t\tconst proofOptionsClone = ObjectHelper.clone(unsignedProof);\n\n\t\tdelete unsecuredDocumentClone.proof;\n\t\tdelete proofOptionsClone.proofValue;\n\n\t\tif (proofOptionsClone.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\t\t\"cryptosuiteNotSupported\",\n\t\t\t\t{\n\t\t\t\t\tcryptoSuite: proofOptionsClone.cryptosuite\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tproofOptionsClone[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IDataIntegrityProof[\"@context\"];\n\n\t\tconst transformedDocument = JsonHelper.canonicalize(unsecuredDocumentClone);\n\n\t\tconst transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(transformedDocument));\n\n\t\tconst transformedProofOptions = JsonHelper.canonicalize(proofOptionsClone);\n\n\t\tconst proofOptionsHash = Sha256.sum256(Converter.utf8ToBytes(transformedProofOptions));\n\n\t\treturn Uint8ArrayHelper.concat([proofOptionsHash, transformedDocumentHash]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataIntegrityProofSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/dataIntegrityProofSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,GAAG,EAAa,MAAM,eAAe,CAA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AE,uBAAuB,CAAC,CAAC,CAAC;IAC7E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tObjectHelper,\n\tUint8ArrayHelper\n} from \"@twin.org/core\";\nimport { Ed25519, Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Jwk, type IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidCryptoSuites } from \"../models/didCryptoSuites.js\";\nimport type { IDataIntegrityProof } from \"../models/IDataIntegrityProof.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying Data Integrity proofs using EdDSA-JCS-2022.\n * @see https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022\n */\nexport class DataIntegrityProofSignerVerifier implements IProofSignerVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataIntegrityProofSignerVerifier>();\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signKey The key to sign the proof with.\n\t * @returns The created proof.\n\t */\n\tpublic async createProof(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof,\n\t\tsignKey: IJwk\n\t): Promise<IProof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(signKey), signKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(signKey);\n\t\tif (!Is.uint8Array(rawKeys.privateKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPrivateKey\");\n\t\t}\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\"@context\"] as IDataIntegrityProof[\"@context\"];\n\n\t\tconst combinedHash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\tconst signature = Ed25519.sign(rawKeys.privateKey, combinedHash);\n\n\t\tsignedProof.proofValue = `z${Converter.bytesToBase58(signature)}`;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IDataIntegrityProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IDataIntegrityProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof),\n\t\t\tsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof.proofValue),\n\t\t\tsignedProof.proofValue\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(verifyKey), verifyKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(verifyKey);\n\t\tif (!Is.uint8Array(rawKeys.publicKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPublicKey\");\n\t\t}\n\n\t\tconst combinedHash = await this.createHash(securedDocument, signedProof);\n\n\t\treturn Ed25519.verify(\n\t\t\trawKeys.publicKey,\n\t\t\tcombinedHash,\n\t\t\tConverter.base58ToBytes(signedProof.proofValue.slice(1))\n\t\t);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof\n\t): Promise<Uint8Array> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IDataIntegrityProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.cryptosuite),\n\t\t\tunsignedProof.cryptosuite\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.verificationMethod),\n\t\t\tunsignedProof.verificationMethod\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\t\tconst proofOptionsClone = ObjectHelper.clone(unsignedProof);\n\n\t\tdelete unsecuredDocumentClone.proof;\n\t\tdelete proofOptionsClone.proofValue;\n\n\t\tif (proofOptionsClone.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\t\t\"cryptosuiteNotSupported\",\n\t\t\t\t{\n\t\t\t\t\tcryptoSuite: proofOptionsClone.cryptosuite\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tproofOptionsClone[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IDataIntegrityProof[\"@context\"];\n\n\t\tconst transformedDocument = JsonHelper.canonicalize(unsecuredDocumentClone);\n\n\t\tconst transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(transformedDocument));\n\n\t\tconst transformedProofOptions = JsonHelper.canonicalize(proofOptionsClone);\n\n\t\tconst proofOptionsHash = Sha256.sum256(Converter.utf8ToBytes(transformedProofOptions));\n\n\t\treturn Uint8ArrayHelper.concat([proofOptionsHash, transformedDocumentHash]);\n\t}\n}\n"]}
@@ -27,8 +27,6 @@ export class JsonWebSignature2020AsyncSignerVerifier {
27
27
  }
28
28
  /**
29
29
  * Create a proof with an async signing callback.
30
- * This method prevents private key exposure by delegating signing to a secure callback.
31
- * Implements JWS Compact Serialization per RFC 7515.
32
30
  * @param unsecuredDocument The data to create the proof for.
33
31
  * @param unsignedProof The proof options.
34
32
  * @param signCallback Async callback that signs data with a private key from secure storage.
@@ -1 +1 @@
1
- {"version":3,"file":"jsonWebSignature2020AsyncSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/jsonWebSignature2020AsyncSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE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EzC,sCAAsC;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAC9E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards, ObjectHelper } from \"@twin.org/core\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { JsonWebSignature2020SignerVerifier } from \"./jsonWebSignature2020SignerVerifier.js\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IJsonWebSignature2020Proof } from \"../models/IJsonWebSignature2020Proof.js\";\nimport type { IProofSignerVerifierAsync } from \"../models/IProofSignerVerifierAsync.js\";\nimport { JwsAlgorithms } from \"../models/jwsAlgorithms.js\";\n\n/**\n * Helper methods for creating and verifying JsonWebSignature2020 proofs with async signing callbacks.\n * This implementation creates JWS signatures manually per RFC 7515 to support async signing callbacks.\n */\nexport class JsonWebSignature2020AsyncSignerVerifier implements IProofSignerVerifierAsync {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<JsonWebSignature2020AsyncSignerVerifier>();\n\n\t/**\n\t * The underlying sync signer verifier for hash and verify operations.\n\t * @internal\n\t */\n\tprivate readonly _syncSignerVerifier: JsonWebSignature2020SignerVerifier;\n\n\t/**\n\t * Create a new instance of JsonWebSignature2020AsyncSignerVerifier.\n\t */\n\tconstructor() {\n\t\tthis._syncSignerVerifier = new JsonWebSignature2020SignerVerifier();\n\t}\n\n\t/**\n\t * Create a proof with an async signing callback.\n\t * This method prevents private key exposure by delegating signing to a secure callback.\n\t * Implements JWS Compact Serialization per RFC 7515.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signCallback Async callback that signs data with a private key from secure storage.\n\t * @returns The created proof.\n\t */\n\tpublic async createProofWithSigner(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof,\n\t\tsignCallback: (data: Uint8Array, algorithm: string) => Promise<Uint8Array>\n\t): Promise<IJsonWebSignature2020Proof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020AsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020AsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.function(\n\t\t\tJsonWebSignature2020AsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signCallback),\n\t\t\tsignCallback\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\t// Use the sync verifier to create the hash\n\t\tconst hash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\t// Create JWS manually per RFC 7515 (Compact Serialization)\n\t\t// Format: BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS Signature)\n\n\t\t// JWS Protected Header for EdDSA with detached payload\n\t\tconst header = {\n\t\t\talg: \"EdDSA\",\n\t\t\tcrit: [\"b64\"],\n\t\t\tb64: false\n\t\t};\n\n\t\tconst headerJson = JSON.stringify(header);\n\t\tconst headerBase64 = Converter.bytesToBase64Url(Converter.utf8ToBytes(headerJson));\n\n\t\t// Create signing input: header.payload (detached payload means payload is the hash)\n\t\tconst signingInput = Converter.utf8ToBytes(`${headerBase64}.`);\n\t\tconst dataToSign = new Uint8Array(signingInput.length + hash.length);\n\t\tdataToSign.set(signingInput, 0);\n\t\tdataToSign.set(hash, signingInput.length);\n\n\t\t// Sign with the callback (key stays in secure storage)\n\t\t// Pass JWS algorithm for vault validation\n\t\tconst signature = await signCallback(dataToSign, JwsAlgorithms.EdDSA);\n\n\t\t// Construct JWS: header..signature (empty payload section for detached content)\n\t\tconst signatureBase64 = Converter.bytesToBase64Url(signature);\n\t\tconst jws = `${headerBase64}..${signatureBase64}`;\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tsignedProof.jws = jws;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IJsonWebSignature2020Proof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\t// Delegate to the sync implementation (verification doesn't need the private key)\n\t\treturn this._syncSignerVerifier.verifyProof(securedDocument, signedProof, verifyKey);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof\n\t): Promise<Uint8Array> {\n\t\t// Delegate to the sync implementation\n\t\treturn this._syncSignerVerifier.createHash(unsecuredDocument, unsignedProof);\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonWebSignature2020AsyncSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/jsonWebSignature2020AsyncSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAA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,EACpC,aAAyC;QAEzC,sCAAsC;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAC9E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards, ObjectHelper } from \"@twin.org/core\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { JsonWebSignature2020SignerVerifier } from \"./jsonWebSignature2020SignerVerifier.js\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IJsonWebSignature2020Proof } from \"../models/IJsonWebSignature2020Proof.js\";\nimport type { IProofSignerVerifierAsync } from \"../models/IProofSignerVerifierAsync.js\";\nimport { JwsAlgorithms } from \"../models/jwsAlgorithms.js\";\n\n/**\n * Helper methods for creating and verifying JsonWebSignature2020 proofs with async signing callbacks.\n * This implementation creates JWS signatures manually per RFC 7515 to support async signing callbacks.\n */\nexport class JsonWebSignature2020AsyncSignerVerifier implements IProofSignerVerifierAsync {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<JsonWebSignature2020AsyncSignerVerifier>();\n\n\t/**\n\t * The underlying sync signer verifier for hash and verify operations.\n\t * @internal\n\t */\n\tprivate readonly _syncSignerVerifier: JsonWebSignature2020SignerVerifier;\n\n\t/**\n\t * Create a new instance of JsonWebSignature2020AsyncSignerVerifier.\n\t */\n\tconstructor() {\n\t\tthis._syncSignerVerifier = new JsonWebSignature2020SignerVerifier();\n\t}\n\n\t/**\n\t * Create a proof with an async signing callback.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signCallback Async callback that signs data with a private key from secure storage.\n\t * @returns The created proof.\n\t */\n\tpublic async createProofWithSigner(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof,\n\t\tsignCallback: (data: Uint8Array, algorithm: string) => Promise<Uint8Array>\n\t): Promise<IJsonWebSignature2020Proof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020AsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020AsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.function(\n\t\t\tJsonWebSignature2020AsyncSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signCallback),\n\t\t\tsignCallback\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\t// Use the sync verifier to create the hash\n\t\tconst hash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\t// Create JWS manually per RFC 7515 (Compact Serialization)\n\t\t// Format: BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS Signature)\n\n\t\t// JWS Protected Header for EdDSA with detached payload\n\t\tconst header = {\n\t\t\talg: \"EdDSA\",\n\t\t\tcrit: [\"b64\"],\n\t\t\tb64: false\n\t\t};\n\n\t\tconst headerJson = JSON.stringify(header);\n\t\tconst headerBase64 = Converter.bytesToBase64Url(Converter.utf8ToBytes(headerJson));\n\n\t\t// Create signing input: header.payload (detached payload means payload is the hash)\n\t\tconst signingInput = Converter.utf8ToBytes(`${headerBase64}.`);\n\t\tconst dataToSign = new Uint8Array(signingInput.length + hash.length);\n\t\tdataToSign.set(signingInput, 0);\n\t\tdataToSign.set(hash, signingInput.length);\n\n\t\t// Sign with the callback (key stays in secure storage)\n\t\t// Pass JWS algorithm for vault validation\n\t\tconst signature = await signCallback(dataToSign, JwsAlgorithms.EdDSA);\n\n\t\t// Construct JWS: header..signature (empty payload section for detached content)\n\t\tconst signatureBase64 = Converter.bytesToBase64Url(signature);\n\t\tconst jws = `${headerBase64}..${signatureBase64}`;\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tsignedProof.jws = jws;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IJsonWebSignature2020Proof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\t// Delegate to the sync implementation (verification doesn't need the private key)\n\t\treturn this._syncSignerVerifier.verifyProof(securedDocument, signedProof, verifyKey);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof\n\t): Promise<Uint8Array> {\n\t\t// Delegate to the sync implementation\n\t\treturn this._syncSignerVerifier.createHash(unsecuredDocument, unsignedProof);\n\t}\n}\n"]}
@@ -6,7 +6,8 @@ import { JsonLdProcessor } from "@twin.org/data-json-ld";
6
6
  import { Jwk, Jws } from "@twin.org/web";
7
7
  import { DidContexts } from "../models/didContexts.js";
8
8
  /**
9
- * Helper methods for creating and verifying proofs.
9
+ * Helper methods for creating and verifying JsonWebSignature2020 proofs.
10
+ * @see https://w3c-ccg.github.io/lds-jws2020/
10
11
  */
11
12
  export class JsonWebSignature2020SignerVerifier {
12
13
  /**
@@ -35,7 +36,7 @@ export class JsonWebSignature2020SignerVerifier {
35
36
  return signedProof;
36
37
  }
37
38
  /**
38
- * Verify a proof for the given data in format.
39
+ * Verify a proof for the given data.
39
40
  * @param securedDocument The credential to verify.
40
41
  * @param signedProof The proof to verify.
41
42
  * @param verifyKey The public key to verify the proof with.
@@ -1 +1 @@
1
- {"version":3,"file":"jsonWebSignature2020SignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/jsonWebSignature2020SignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAa,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD;;GAEG;AACH,MAAM,OAAO,kCAAkC;IAC9C;;OAEG;IACI,MAAM,CAAU,UAAU,wCAAwD;IAEzF;;;;;;OAMG;IACI,KAAK,CAAC,WAAW,CACvB,iBAAoC,EACpC,aAAyC,EACzC,OAAa;QAEb,MAAM,CAAC,MAAM,CACZ,kCAAkC,CAAC,UAAU,uBAE7C,iBAAiB,CACjB,CAAC;QACF,MAAM,CAAC,MAAM,CACZ,kCAAkC,CAAC,UAAU,mBAE7C,aAAa,CACb,CAAC;QACF,MAAM,CAAC,MAAM,CAAO,kCAAkC,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAE7F,MAAM,sBAAsB,GAAG,YAAY,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAErE,sBAAsB,CAAC,UAAU,CAAC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AE,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tObjectHelper,\n\tUint8ArrayHelper\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Jwk, Jws, type IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IJsonWebSignature2020Proof } from \"../models/IJsonWebSignature2020Proof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class JsonWebSignature2020SignerVerifier implements IProofSignerVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<JsonWebSignature2020SignerVerifier>();\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signKey The key to sign the proof with.\n\t * @returns The created proof.\n\t */\n\tpublic async createProof(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof,\n\t\tsignKey: IJwk\n\t): Promise<IJsonWebSignature2020Proof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(JsonWebSignature2020SignerVerifier.CLASS_NAME, nameof(signKey), signKey);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\tconst hash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\tconst cryptoKey = await Jwk.toCryptoKey(signKey);\n\n\t\tconst signature = await Jws.create(cryptoKey, hash, signKey.alg);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tsignedProof.jws = signature;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data in format.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IJsonWebSignature2020Proof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof),\n\t\t\tsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(verifyKey),\n\t\t\tverifyKey\n\t\t);\n\t\tconst jws = signedProof.jws;\n\t\tif (!Is.stringValue(jws)) {\n\t\t\tthrow new GeneralError(JsonWebSignature2020SignerVerifier.CLASS_NAME, \"missingJws\");\n\t\t}\n\n\t\tconst hash = await this.createHash(securedDocument, signedProof);\n\n\t\tconst cryptoKey = await Jwk.toCryptoKey(verifyKey);\n\n\t\treturn Jws.verify(jws, cryptoKey, hash);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof\n\t): Promise<Uint8Array> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.verificationMethod),\n\t\t\tunsignedProof.verificationMethod\n\t\t);\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\t\tconst proofOptionsClone = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\tproofOptionsClone[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tdelete unsecuredDocumentClone.proof;\n\t\tdelete proofOptionsClone.jws;\n\n\t\tconst canonizedData: string = await JsonLdProcessor.canonize(unsecuredDocumentClone);\n\t\tconst canonizedProof: string = await JsonLdProcessor.canonize(\n\t\t\tproofOptionsClone as unknown as IJsonLdNodeObject\n\t\t);\n\n\t\tconst hashedProof = Sha256.sum256(Converter.utf8ToBytes(canonizedProof));\n\t\tconst hashedData = Sha256.sum256(Converter.utf8ToBytes(canonizedData));\n\n\t\treturn Uint8ArrayHelper.concat([hashedProof, hashedData]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonWebSignature2020SignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/jsonWebSignature2020SignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAa,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD;;;GAGG;AACH,MAAM,OAAO,kCAAkC;IAC9C;;OAEG;IACI,MAAM,CAAU,UAAU,wCAAwD;IAEzF;;;;;;OAMG;IACI,KAAK,CAAC,WAAW,CACvB,iBAAoC,EACpC,aAAyC,EACzC,OAAa;QAEb,MAAM,CAAC,MAAM,CACZ,kCAAkC,CAAC,UAAU,uBAE7C,iBAAiB,CACjB,CAAC;QACF,MAAM,CAAC,MAAM,CACZ,kCAAkC,CAAC,UAAU,mBAE7C,aAAa,CACb,CAAC;QACF,MAAM,CAAC,MAAM,CAAO,kCAAkC,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAE7F,MAAM,sBAAsB,GAAG,YAAY,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAErE,sBAAsB,CAAC,UAAU,CAAC,GAAG,eAAe,CAAC,eAAe,CACnE,sBAAsB,CAAC,UAAU,CAAC,EAClC,WAAW,CAAC,sBAAsB,CAClC,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAA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from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Jwk, Jws, type IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IJsonWebSignature2020Proof } from \"../models/IJsonWebSignature2020Proof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying JsonWebSignature2020 proofs.\n * @see https://w3c-ccg.github.io/lds-jws2020/\n */\nexport class JsonWebSignature2020SignerVerifier implements IProofSignerVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<JsonWebSignature2020SignerVerifier>();\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signKey The key to sign the proof with.\n\t * @returns The created proof.\n\t */\n\tpublic async createProof(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof,\n\t\tsignKey: IJwk\n\t): Promise<IJsonWebSignature2020Proof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(JsonWebSignature2020SignerVerifier.CLASS_NAME, nameof(signKey), signKey);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\tconst hash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\tconst cryptoKey = await Jwk.toCryptoKey(signKey);\n\n\t\tconst signature = await Jws.create(cryptoKey, hash, signKey.alg);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tsignedProof.jws = signature;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IJsonWebSignature2020Proof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof),\n\t\t\tsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(verifyKey),\n\t\t\tverifyKey\n\t\t);\n\t\tconst jws = signedProof.jws;\n\t\tif (!Is.stringValue(jws)) {\n\t\t\tthrow new GeneralError(JsonWebSignature2020SignerVerifier.CLASS_NAME, \"missingJws\");\n\t\t}\n\n\t\tconst hash = await this.createHash(securedDocument, signedProof);\n\n\t\tconst cryptoKey = await Jwk.toCryptoKey(verifyKey);\n\n\t\treturn Jws.verify(jws, cryptoKey, hash);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof\n\t): Promise<Uint8Array> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.verificationMethod),\n\t\t\tunsignedProof.verificationMethod\n\t\t);\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\t\tconst proofOptionsClone = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\tproofOptionsClone[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tdelete unsecuredDocumentClone.proof;\n\t\tdelete proofOptionsClone.jws;\n\n\t\tconst canonizedData: string = await JsonLdProcessor.canonize(unsecuredDocumentClone);\n\t\tconst canonizedProof: string = await JsonLdProcessor.canonize(\n\t\t\tproofOptionsClone as unknown as IJsonLdNodeObject\n\t\t);\n\n\t\tconst hashedProof = Sha256.sum256(Converter.utf8ToBytes(canonizedProof));\n\t\tconst hashedData = Sha256.sum256(Converter.utf8ToBytes(canonizedData));\n\n\t\treturn Uint8ArrayHelper.concat([hashedProof, hashedData]);\n\t}\n}\n"]}
@@ -11,9 +11,9 @@ export class VerifiableCredentialHelper {
11
11
  */
12
12
  static CLASS_NAME = "VerifiableCredentialHelper";
13
13
  /**
14
- * Get the context for the verifiable credential.
15
- * @param verifiableCredential The verifiable credential to extract the expiration date from.
16
- * @returns The context.
14
+ * Get the JSON-LD context URL for the verifiable credential.
15
+ * @param verifiableCredential The verifiable credential to inspect.
16
+ * @returns The context URL, or undefined if the version cannot be determined.
17
17
  */
18
18
  static getContext(verifiableCredential) {
19
19
  const contextVersion = VerifiableCredentialHelper.getContextVersion(verifiableCredential);
@@ -25,9 +25,9 @@ export class VerifiableCredentialHelper {
25
25
  }
26
26
  }
27
27
  /**
28
- * Get the context version for the verifiable credential.
29
- * @param verifiableCredential The verifiable credential to extract the expiration date from.
30
- * @returns The context version.
28
+ * Get the context version string for the verifiable credential.
29
+ * @param verifiableCredential The verifiable credential to inspect.
30
+ * @returns The context version ("v1" or "v2"), or undefined if not determinable.
31
31
  */
32
32
  static getContextVersion(verifiableCredential) {
33
33
  const context = ArrayHelper.fromObjectOrArray(verifiableCredential["@context"]);
@@ -41,17 +41,17 @@ export class VerifiableCredentialHelper {
41
41
  }
42
42
  }
43
43
  /**
44
- * Get the valid until date from a verifiable credential.
45
- * @param verifiableCredential The verifiable credential to extract the expiration date from.
46
- * @returns The expiration date, if available.
44
+ * Get the expiration date from a verifiable credential.
45
+ * @param verifiableCredential The verifiable credential to inspect.
46
+ * @returns The expiration date string, or undefined if not present.
47
47
  */
48
48
  static getValidUntil(verifiableCredential) {
49
49
  return (ObjectHelper.propertyGet(verifiableCredential, "validUntil") ??
50
50
  ObjectHelper.propertyGet(verifiableCredential, "expirationDate"));
51
51
  }
52
52
  /**
53
- * Set the valid until date on a verifiable credential.
54
- * @param verifiableCredential The verifiable credential to set the expiration date on.
53
+ * Set the expiration date on a verifiable credential.
54
+ * @param verifiableCredential The verifiable credential to update.
55
55
  * @param validUntil The expiration date to set.
56
56
  */
57
57
  static setValidUntil(verifiableCredential, validUntil) {
@@ -63,17 +63,17 @@ export class VerifiableCredentialHelper {
63
63
  }
64
64
  }
65
65
  /**
66
- * Get the valid from from a verifiable credential.
67
- * @param verifiableCredential The verifiable credential to extract the issuance date from.
68
- * @returns The issuance date, if available.
66
+ * Get the issuance date from a verifiable credential.
67
+ * @param verifiableCredential The verifiable credential to inspect.
68
+ * @returns The issuance date string, or undefined if not present.
69
69
  */
70
70
  static getValidFrom(verifiableCredential) {
71
71
  return (ObjectHelper.propertyGet(verifiableCredential, "validFrom") ??
72
72
  ObjectHelper.propertyGet(verifiableCredential, "issuanceDate"));
73
73
  }
74
74
  /**
75
- * Set the valid from date on a verifiable credential.
76
- * @param verifiableCredential The verifiable credential to set the issuance date on.
75
+ * Set the issuance date on a verifiable credential.
76
+ * @param verifiableCredential The verifiable credential to update.
77
77
  * @param validFrom The issuance date to set.
78
78
  */
79
79
  static setValidFrom(verifiableCredential, validFrom) {
@@ -1 +1 @@
1
- {"version":3,"file":"verifiableCredentialHelper.js","sourceRoot":"","sources":["../../../src/utils/verifiableCredentialHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;;OAIG;IACI,MAAM,CAAC,UAAU,CACvB,oBAA8C;QAE9C,MAAM,cAAc,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QAC1F,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC,WAAW,CAAC;QAChC,CAAC;QACD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC,WAAW,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAC9B,oBAA8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CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAAE,CAAC;YACjF,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC3E,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Is, ObjectHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IDidVerifiableCredential } from \"../models/IDidVerifiableCredential.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class VerifiableCredentialHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<VerifiableCredentialHelper>();\n\n\t/**\n\t * Get the context for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The context.\n\t */\n\tpublic static getContext(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): typeof DidContexts.ContextVCv1 | typeof DidContexts.ContextVCv2 | undefined {\n\t\tconst contextVersion = VerifiableCredentialHelper.getContextVersion(verifiableCredential);\n\t\tif (contextVersion === \"v1\") {\n\t\t\treturn DidContexts.ContextVCv1;\n\t\t}\n\t\tif (contextVersion === \"v2\") {\n\t\t\treturn DidContexts.ContextVCv2;\n\t\t}\n\t}\n\n\t/**\n\t * Get the context version for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The context version.\n\t */\n\tpublic static getContextVersion(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): \"v1\" | \"v2\" | undefined {\n\t\tconst context = ArrayHelper.fromObjectOrArray(verifiableCredential[\"@context\"]);\n\t\tif (Is.arrayValue<string>(context)) {\n\t\t\tif (context.includes(DidContexts.ContextVCv1)) {\n\t\t\t\treturn \"v1\";\n\t\t\t}\n\t\t\tif (context.includes(DidContexts.ContextVCv2)) {\n\t\t\t\treturn \"v2\";\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get the valid until date from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the expiration date from.\n\t * @returns The expiration date, if available.\n\t */\n\tpublic static getValidUntil(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validUntil\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"expirationDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the valid until date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to set the expiration date on.\n\t * @param validUntil The expiration date to set.\n\t */\n\tpublic static setValidUntil(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidUntil: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validUntil\", validUntil);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"expirationDate\", validUntil);\n\t\t}\n\t}\n\n\t/**\n\t * Get the valid from from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to extract the issuance date from.\n\t * @returns The issuance date, if available.\n\t */\n\tpublic static getValidFrom(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validFrom\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"issuanceDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the valid from date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to set the issuance date on.\n\t * @param validFrom The issuance date to set.\n\t */\n\tpublic static setValidFrom(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidFrom: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validFrom\", validFrom);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"issuanceDate\", validFrom);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"verifiableCredentialHelper.js","sourceRoot":"","sources":["../../../src/utils/verifiableCredentialHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;;OAIG;IACI,MAAM,CAAC,UAAU,CACvB,oBAA8C;QAE9C,MAAM,cAAc,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QAC1F,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC,WAAW,CAAC;QAChC,CAAC;QACD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,WAAW,CAAC,WAAW,CAAC;QAChC,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAC9B,oBAA8C;QAE9C,MAAM,OAAO,GAAG,WAAW,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;QAChF,IAAI,EAAE,CAAC,UAAU,CAAS,OAAO,CAAC,EAAE,CAAC;YACpC,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAI,CAAC;YACb,CAAC;YACD,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,oBAA8C;QACzE,OAAO,CACN,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,YAAY,CAAC;YAC5D,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAChE,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAC1B,oBAA8C,EAC9C,UAAkB;QAElB,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAAE,CAAC;YACjF,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;QAC9E,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,oBAA8C;QACxE,OAAO,CACN,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,CAAC;YAC3D,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAC9D,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CACzB,oBAA8C,EAC9C,SAAiB;QAEjB,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAAE,CAAC;YACjF,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,WAAW,CAAC,oBAAoB,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC3E,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Is, ObjectHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport type { IDidVerifiableCredential } from \"../models/IDidVerifiableCredential.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class VerifiableCredentialHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<VerifiableCredentialHelper>();\n\n\t/**\n\t * Get the JSON-LD context URL for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to inspect.\n\t * @returns The context URL, or undefined if the version cannot be determined.\n\t */\n\tpublic static getContext(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): typeof DidContexts.ContextVCv1 | typeof DidContexts.ContextVCv2 | undefined {\n\t\tconst contextVersion = VerifiableCredentialHelper.getContextVersion(verifiableCredential);\n\t\tif (contextVersion === \"v1\") {\n\t\t\treturn DidContexts.ContextVCv1;\n\t\t}\n\t\tif (contextVersion === \"v2\") {\n\t\t\treturn DidContexts.ContextVCv2;\n\t\t}\n\t}\n\n\t/**\n\t * Get the context version string for the verifiable credential.\n\t * @param verifiableCredential The verifiable credential to inspect.\n\t * @returns The context version (\"v1\" or \"v2\"), or undefined if not determinable.\n\t */\n\tpublic static getContextVersion(\n\t\tverifiableCredential: IDidVerifiableCredential\n\t): \"v1\" | \"v2\" | undefined {\n\t\tconst context = ArrayHelper.fromObjectOrArray(verifiableCredential[\"@context\"]);\n\t\tif (Is.arrayValue<string>(context)) {\n\t\t\tif (context.includes(DidContexts.ContextVCv1)) {\n\t\t\t\treturn \"v1\";\n\t\t\t}\n\t\t\tif (context.includes(DidContexts.ContextVCv2)) {\n\t\t\t\treturn \"v2\";\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get the expiration date from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to inspect.\n\t * @returns The expiration date string, or undefined if not present.\n\t */\n\tpublic static getValidUntil(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validUntil\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"expirationDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the expiration date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to update.\n\t * @param validUntil The expiration date to set.\n\t */\n\tpublic static setValidUntil(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidUntil: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validUntil\", validUntil);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"expirationDate\", validUntil);\n\t\t}\n\t}\n\n\t/**\n\t * Get the issuance date from a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to inspect.\n\t * @returns The issuance date string, or undefined if not present.\n\t */\n\tpublic static getValidFrom(verifiableCredential: IDidVerifiableCredential): string | undefined {\n\t\treturn (\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"validFrom\") ??\n\t\t\tObjectHelper.propertyGet(verifiableCredential, \"issuanceDate\")\n\t\t);\n\t}\n\n\t/**\n\t * Set the issuance date on a verifiable credential.\n\t * @param verifiableCredential The verifiable credential to update.\n\t * @param validFrom The issuance date to set.\n\t */\n\tpublic static setValidFrom(\n\t\tverifiableCredential: IDidVerifiableCredential,\n\t\tvalidFrom: string\n\t): void {\n\t\tif (VerifiableCredentialHelper.getContextVersion(verifiableCredential) === \"v2\") {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"validFrom\", validFrom);\n\t\t} else {\n\t\t\tObjectHelper.propertySet(verifiableCredential, \"issuanceDate\", validFrom);\n\t\t}\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Data Type registration for DID.
2
+ * Handles data type registration for DID.
3
3
  */
4
4
  export declare abstract class DidDataTypes {
5
5
  /**
@@ -5,8 +5,8 @@ import type { IDidCredentialStatus } from "./IDidCredentialStatus.js";
5
5
  import type { IDidLabel } from "./IDidLabel.js";
6
6
  import type { IProof } from "./IProof.js";
7
7
  /**
8
- * Interface describing a verifiable credential.
9
- * https://www.w3.org/TR/vc-data-model-2.0
8
+ * Common properties shared by all verifiable credential versions.
9
+ * @see https://www.w3.org/TR/vc-data-model-2.0
10
10
  */
11
11
  export interface IDidVerifiableCredentialCommon {
12
12
  /**
@@ -7,9 +7,7 @@ export declare const DidContexts: {
7
7
  */
8
8
  readonly Namespace: "https://www.w3.org/ns/did/v1";
9
9
  /**
10
- * The value to use in JSON-LD context for DID.
11
- * Note: Context matches Namespace (no trailing slash) as per W3C DID specification.
12
- * The W3C DID JSON-LD context URL format does not include a trailing slash.
10
+ * The value to use in the JSON-LD context for DID.
13
11
  */
14
12
  readonly Context: "https://www.w3.org/ns/did/v1";
15
13
  /**
@@ -21,9 +19,7 @@ export declare const DidContexts: {
21
19
  */
22
20
  readonly NamespaceVCv1: "https://www.w3.org/2018/credentials/v1";
23
21
  /**
24
- * The value to use in JSON-LD context for DID VC v1.
25
- * Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.
26
- * The W3C VC v1 JSON-LD context URL format does not include a trailing slash.
22
+ * The value to use in the JSON-LD context for DID VC v1.
27
23
  */
28
24
  readonly ContextVCv1: "https://www.w3.org/2018/credentials/v1";
29
25
  /**
@@ -31,9 +27,7 @@ export declare const DidContexts: {
31
27
  */
32
28
  readonly NamespaceVCv2: "https://www.w3.org/ns/credentials/v2";
33
29
  /**
34
- * The value to use in JSON-LD context for DID VC v2.
35
- * Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.
36
- * The W3C VC v2 JSON-LD context URL format does not include a trailing slash.
30
+ * The value to use in the JSON-LD context for DID VC v2.
37
31
  */
38
32
  readonly ContextVCv2: "https://www.w3.org/ns/credentials/v2";
39
33
  /**
@@ -41,9 +35,7 @@ export declare const DidContexts: {
41
35
  */
42
36
  readonly NamespaceSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1";
43
37
  /**
44
- * The value to use in JSON-LD context for security ed25519 suites.
45
- * Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.
46
- * The ed25519-2020 JSON-LD context URL format does not include a trailing slash.
38
+ * The value to use in the JSON-LD context for security ed25519 suites.
47
39
  */
48
40
  readonly ContextSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1";
49
41
  /**
@@ -51,9 +43,7 @@ export declare const DidContexts: {
51
43
  */
52
44
  readonly NamespaceSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1";
53
45
  /**
54
- * The value to use in JSON-LD context for security jws-2020 suites.
55
- * Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.
56
- * The jws-2020 JSON-LD context URL format does not include a trailing slash.
46
+ * The value to use in the JSON-LD context for security jws-2020 suites.
57
47
  */
58
48
  readonly ContextSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1";
59
49
  /**
@@ -61,9 +51,7 @@ export declare const DidContexts: {
61
51
  */
62
52
  readonly NamespaceDataIntegrity: "https://w3id.org/security/data-integrity/v2";
63
53
  /**
64
- * The value to use in JSON-LD context for VC Data Integrity.
65
- * Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.
66
- * The Data Integrity JSON-LD context URL format does not include a trailing slash.
54
+ * The value to use in the JSON-LD context for VC Data Integrity.
67
55
  */
68
56
  readonly ContextDataIntegrity: "https://w3id.org/security/data-integrity/v2";
69
57
  /**
@@ -71,9 +59,7 @@ export declare const DidContexts: {
71
59
  */
72
60
  readonly NamespaceControllerIdentifiers: "https://www.w3.org/ns/cid/v1";
73
61
  /**
74
- * The value to use in JSON-LD context for controller identifiers.
75
- * Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.
76
- * The Controller Identifiers JSON-LD context URL format does not include a trailing slash.
62
+ * The value to use in the JSON-LD context for controller identifiers.
77
63
  */
78
64
  readonly ContextControllerIdentifiers: "https://www.w3.org/ns/cid/v1";
79
65
  /**
@@ -81,9 +67,7 @@ export declare const DidContexts: {
81
67
  */
82
68
  readonly NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1";
83
69
  /**
84
- * The value to use in JSON-LD context for security multikey suites.
85
- * Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.
86
- * The multikey JSON-LD context URL format does not include a trailing slash.
70
+ * The value to use in the JSON-LD context for security multikey suites.
87
71
  */
88
72
  readonly ContextSecurityMultikey: "https://w3id.org/security/multikey/v1";
89
73
  };
@@ -5,8 +5,7 @@ import type { IProof } from "../models/IProof.js";
5
5
  import type { IProofSignerVerifierAsync } from "../models/IProofSignerVerifierAsync.js";
6
6
  /**
7
7
  * Helper methods for creating and verifying Data Integrity proofs with async signing callbacks.
8
- * This implementation delegates signing to a secure callback to prevent private key exposure.
9
- * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
8
+ * @see https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
10
9
  */
11
10
  export declare class DataIntegrityProofAsyncSignerVerifier implements IProofSignerVerifierAsync {
12
11
  /**
@@ -19,7 +18,6 @@ export declare class DataIntegrityProofAsyncSignerVerifier implements IProofSign
19
18
  constructor();
20
19
  /**
21
20
  * Create a proof with an async signing callback.
22
- * This method prevents private key exposure by delegating signing to a secure callback.
23
21
  * @param unsecuredDocument The data to create the proof for.
24
22
  * @param unsignedProof The proof options.
25
23
  * @param signCallback Async callback that signs data with a private key from secure storage.
@@ -4,8 +4,8 @@ import type { IDataIntegrityProof } from "../models/IDataIntegrityProof.js";
4
4
  import type { IProof } from "../models/IProof.js";
5
5
  import type { IProofSignerVerifier } from "../models/IProofSignerVerifier.js";
6
6
  /**
7
- * Helper methods for creating and verifying proofs.
8
- * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
7
+ * Helper methods for creating and verifying Data Integrity proofs using EdDSA-JCS-2022.
8
+ * @see https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
9
9
  */
10
10
  export declare class DataIntegrityProofSignerVerifier implements IProofSignerVerifier {
11
11
  /**
@@ -21,7 +21,7 @@ export declare class DataIntegrityProofSignerVerifier implements IProofSignerVer
21
21
  */
22
22
  createProof(unsecuredDocument: IJsonLdNodeObject, unsignedProof: IDataIntegrityProof, signKey: IJwk): Promise<IProof>;
23
23
  /**
24
- * Verify a proof for the given data in format.
24
+ * Verify a proof for the given data.
25
25
  * @param securedDocument The credential to verify.
26
26
  * @param signedProof The proof to verify.
27
27
  * @param verifyKey The public key to verify the proof with.
@@ -17,8 +17,6 @@ export declare class JsonWebSignature2020AsyncSignerVerifier implements IProofSi
17
17
  constructor();
18
18
  /**
19
19
  * Create a proof with an async signing callback.
20
- * This method prevents private key exposure by delegating signing to a secure callback.
21
- * Implements JWS Compact Serialization per RFC 7515.
22
20
  * @param unsecuredDocument The data to create the proof for.
23
21
  * @param unsignedProof The proof options.
24
22
  * @param signCallback Async callback that signs data with a private key from secure storage.
@@ -3,7 +3,8 @@ import { type IJwk } from "@twin.org/web";
3
3
  import type { IJsonWebSignature2020Proof } from "../models/IJsonWebSignature2020Proof.js";
4
4
  import type { IProofSignerVerifier } from "../models/IProofSignerVerifier.js";
5
5
  /**
6
- * Helper methods for creating and verifying proofs.
6
+ * Helper methods for creating and verifying JsonWebSignature2020 proofs.
7
+ * @see https://w3c-ccg.github.io/lds-jws2020/
7
8
  */
8
9
  export declare class JsonWebSignature2020SignerVerifier implements IProofSignerVerifier {
9
10
  /**
@@ -19,7 +20,7 @@ export declare class JsonWebSignature2020SignerVerifier implements IProofSignerV
19
20
  */
20
21
  createProof(unsecuredDocument: IJsonLdNodeObject, unsignedProof: IJsonWebSignature2020Proof, signKey: IJwk): Promise<IJsonWebSignature2020Proof>;
21
22
  /**
22
- * Verify a proof for the given data in format.
23
+ * Verify a proof for the given data.
23
24
  * @param securedDocument The credential to verify.
24
25
  * @param signedProof The proof to verify.
25
26
  * @param verifyKey The public key to verify the proof with.
@@ -9,38 +9,38 @@ export declare class VerifiableCredentialHelper {
9
9
  */
10
10
  static readonly CLASS_NAME: string;
11
11
  /**
12
- * Get the context for the verifiable credential.
13
- * @param verifiableCredential The verifiable credential to extract the expiration date from.
14
- * @returns The context.
12
+ * Get the JSON-LD context URL for the verifiable credential.
13
+ * @param verifiableCredential The verifiable credential to inspect.
14
+ * @returns The context URL, or undefined if the version cannot be determined.
15
15
  */
16
16
  static getContext(verifiableCredential: IDidVerifiableCredential): typeof DidContexts.ContextVCv1 | typeof DidContexts.ContextVCv2 | undefined;
17
17
  /**
18
- * Get the context version for the verifiable credential.
19
- * @param verifiableCredential The verifiable credential to extract the expiration date from.
20
- * @returns The context version.
18
+ * Get the context version string for the verifiable credential.
19
+ * @param verifiableCredential The verifiable credential to inspect.
20
+ * @returns The context version ("v1" or "v2"), or undefined if not determinable.
21
21
  */
22
22
  static getContextVersion(verifiableCredential: IDidVerifiableCredential): "v1" | "v2" | undefined;
23
23
  /**
24
- * Get the valid until date from a verifiable credential.
25
- * @param verifiableCredential The verifiable credential to extract the expiration date from.
26
- * @returns The expiration date, if available.
24
+ * Get the expiration date from a verifiable credential.
25
+ * @param verifiableCredential The verifiable credential to inspect.
26
+ * @returns The expiration date string, or undefined if not present.
27
27
  */
28
28
  static getValidUntil(verifiableCredential: IDidVerifiableCredential): string | undefined;
29
29
  /**
30
- * Set the valid until date on a verifiable credential.
31
- * @param verifiableCredential The verifiable credential to set the expiration date on.
30
+ * Set the expiration date on a verifiable credential.
31
+ * @param verifiableCredential The verifiable credential to update.
32
32
  * @param validUntil The expiration date to set.
33
33
  */
34
34
  static setValidUntil(verifiableCredential: IDidVerifiableCredential, validUntil: string): void;
35
35
  /**
36
- * Get the valid from from a verifiable credential.
37
- * @param verifiableCredential The verifiable credential to extract the issuance date from.
38
- * @returns The issuance date, if available.
36
+ * Get the issuance date from a verifiable credential.
37
+ * @param verifiableCredential The verifiable credential to inspect.
38
+ * @returns The issuance date string, or undefined if not present.
39
39
  */
40
40
  static getValidFrom(verifiableCredential: IDidVerifiableCredential): string | undefined;
41
41
  /**
42
- * Set the valid from date on a verifiable credential.
43
- * @param verifiableCredential The verifiable credential to set the issuance date on.
42
+ * Set the issuance date on a verifiable credential.
43
+ * @param verifiableCredential The verifiable credential to update.
44
44
  * @param validFrom The issuance date to set.
45
45
  */
46
46
  static setValidFrom(verifiableCredential: IDidVerifiableCredential, validFrom: string): void;
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.68](https://github.com/iotaledger/twin-standards/compare/standards-w3c-did-v0.0.3-next.67...standards-w3c-did-v0.0.3-next.68) (2026-06-22)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **standards-w3c-did:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * devDependencies
15
+ * @twin.org/standards-ld-contexts bumped from 0.0.3-next.67 to 0.0.3-next.68
16
+
3
17
  ## [0.0.3-next.67](https://github.com/iotaledger/twin-standards/compare/standards-w3c-did-v0.0.3-next.66...standards-w3c-did-v0.0.3-next.67) (2026-06-12)
4
18
 
5
19
 
@@ -1,7 +1,9 @@
1
1
  # Class: DataIntegrityProofAsyncSignerVerifier
2
2
 
3
3
  Helper methods for creating and verifying Data Integrity proofs with async signing callbacks.
4
- This implementation delegates signing to a secure callback to prevent private key exposure.
4
+
5
+ ## See
6
+
5
7
  https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
6
8
 
7
9
  ## Implements
@@ -35,7 +37,6 @@ Runtime name for the class.
35
37
  > **createProofWithSigner**(`unsecuredDocument`, `unsignedProof`, `signCallback`): `Promise`\<[`IProof`](../type-aliases/IProof.md)\>
36
38
 
37
39
  Create a proof with an async signing callback.
38
- This method prevents private key exposure by delegating signing to a secure callback.
39
40
 
40
41
  #### Parameters
41
42
 
@@ -1,6 +1,9 @@
1
1
  # Class: DataIntegrityProofSignerVerifier
2
2
 
3
- Helper methods for creating and verifying proofs.
3
+ Helper methods for creating and verifying Data Integrity proofs using EdDSA-JCS-2022.
4
+
5
+ ## See
6
+
4
7
  https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022
5
8
 
6
9
  ## Implements
@@ -69,7 +72,7 @@ The created proof.
69
72
 
70
73
  > **verifyProof**(`securedDocument`, `signedProof`, `verifyKey`): `Promise`\<`boolean`\>
71
74
 
72
- Verify a proof for the given data in format.
75
+ Verify a proof for the given data.
73
76
 
74
77
  #### Parameters
75
78
 
@@ -1,6 +1,6 @@
1
1
  # Abstract Class: DidDataTypes
2
2
 
3
- Data Type registration for DID.
3
+ Handles data type registration for DID.
4
4
 
5
5
  ## Constructors
6
6
 
@@ -34,8 +34,6 @@ Runtime name for the class.
34
34
  > **createProofWithSigner**(`unsecuredDocument`, `unsignedProof`, `signCallback`): `Promise`\<[`IJsonWebSignature2020Proof`](../interfaces/IJsonWebSignature2020Proof.md)\>
35
35
 
36
36
  Create a proof with an async signing callback.
37
- This method prevents private key exposure by delegating signing to a secure callback.
38
- Implements JWS Compact Serialization per RFC 7515.
39
37
 
40
38
  #### Parameters
41
39
 
@@ -1,6 +1,10 @@
1
1
  # Class: JsonWebSignature2020SignerVerifier
2
2
 
3
- Helper methods for creating and verifying proofs.
3
+ Helper methods for creating and verifying JsonWebSignature2020 proofs.
4
+
5
+ ## See
6
+
7
+ https://w3c-ccg.github.io/lds-jws2020/
4
8
 
5
9
  ## Implements
6
10
 
@@ -68,7 +72,7 @@ The created proof.
68
72
 
69
73
  > **verifyProof**(`securedDocument`, `signedProof`, `verifyKey`): `Promise`\<`boolean`\>
70
74
 
71
- Verify a proof for the given data in format.
75
+ Verify a proof for the given data.
72
76
 
73
77
  #### Parameters
74
78
 
@@ -26,7 +26,7 @@ Runtime name for the class.
26
26
 
27
27
  > `static` **getContext**(`verifiableCredential`): `"https://www.w3.org/2018/credentials/v1"` \| `"https://www.w3.org/ns/credentials/v2"` \| `undefined`
28
28
 
29
- Get the context for the verifiable credential.
29
+ Get the JSON-LD context URL for the verifiable credential.
30
30
 
31
31
  #### Parameters
32
32
 
@@ -34,13 +34,13 @@ Get the context for the verifiable credential.
34
34
 
35
35
  [`IDidVerifiableCredential`](../type-aliases/IDidVerifiableCredential.md)
36
36
 
37
- The verifiable credential to extract the expiration date from.
37
+ The verifiable credential to inspect.
38
38
 
39
39
  #### Returns
40
40
 
41
41
  `"https://www.w3.org/2018/credentials/v1"` \| `"https://www.w3.org/ns/credentials/v2"` \| `undefined`
42
42
 
43
- The context.
43
+ The context URL, or undefined if the version cannot be determined.
44
44
 
45
45
  ***
46
46
 
@@ -48,7 +48,7 @@ The context.
48
48
 
49
49
  > `static` **getContextVersion**(`verifiableCredential`): `"v1"` \| `"v2"` \| `undefined`
50
50
 
51
- Get the context version for the verifiable credential.
51
+ Get the context version string for the verifiable credential.
52
52
 
53
53
  #### Parameters
54
54
 
@@ -56,13 +56,13 @@ Get the context version for the verifiable credential.
56
56
 
57
57
  [`IDidVerifiableCredential`](../type-aliases/IDidVerifiableCredential.md)
58
58
 
59
- The verifiable credential to extract the expiration date from.
59
+ The verifiable credential to inspect.
60
60
 
61
61
  #### Returns
62
62
 
63
63
  `"v1"` \| `"v2"` \| `undefined`
64
64
 
65
- The context version.
65
+ The context version ("v1" or "v2"), or undefined if not determinable.
66
66
 
67
67
  ***
68
68
 
@@ -70,7 +70,7 @@ The context version.
70
70
 
71
71
  > `static` **getValidUntil**(`verifiableCredential`): `string` \| `undefined`
72
72
 
73
- Get the valid until date from a verifiable credential.
73
+ Get the expiration date from a verifiable credential.
74
74
 
75
75
  #### Parameters
76
76
 
@@ -78,13 +78,13 @@ Get the valid until date from a verifiable credential.
78
78
 
79
79
  [`IDidVerifiableCredential`](../type-aliases/IDidVerifiableCredential.md)
80
80
 
81
- The verifiable credential to extract the expiration date from.
81
+ The verifiable credential to inspect.
82
82
 
83
83
  #### Returns
84
84
 
85
85
  `string` \| `undefined`
86
86
 
87
- The expiration date, if available.
87
+ The expiration date string, or undefined if not present.
88
88
 
89
89
  ***
90
90
 
@@ -92,7 +92,7 @@ The expiration date, if available.
92
92
 
93
93
  > `static` **setValidUntil**(`verifiableCredential`, `validUntil`): `void`
94
94
 
95
- Set the valid until date on a verifiable credential.
95
+ Set the expiration date on a verifiable credential.
96
96
 
97
97
  #### Parameters
98
98
 
@@ -100,7 +100,7 @@ Set the valid until date on a verifiable credential.
100
100
 
101
101
  [`IDidVerifiableCredential`](../type-aliases/IDidVerifiableCredential.md)
102
102
 
103
- The verifiable credential to set the expiration date on.
103
+ The verifiable credential to update.
104
104
 
105
105
  ##### validUntil
106
106
 
@@ -118,7 +118,7 @@ The expiration date to set.
118
118
 
119
119
  > `static` **getValidFrom**(`verifiableCredential`): `string` \| `undefined`
120
120
 
121
- Get the valid from from a verifiable credential.
121
+ Get the issuance date from a verifiable credential.
122
122
 
123
123
  #### Parameters
124
124
 
@@ -126,13 +126,13 @@ Get the valid from from a verifiable credential.
126
126
 
127
127
  [`IDidVerifiableCredential`](../type-aliases/IDidVerifiableCredential.md)
128
128
 
129
- The verifiable credential to extract the issuance date from.
129
+ The verifiable credential to inspect.
130
130
 
131
131
  #### Returns
132
132
 
133
133
  `string` \| `undefined`
134
134
 
135
- The issuance date, if available.
135
+ The issuance date string, or undefined if not present.
136
136
 
137
137
  ***
138
138
 
@@ -140,7 +140,7 @@ The issuance date, if available.
140
140
 
141
141
  > `static` **setValidFrom**(`verifiableCredential`, `validFrom`): `void`
142
142
 
143
- Set the valid from date on a verifiable credential.
143
+ Set the issuance date on a verifiable credential.
144
144
 
145
145
  #### Parameters
146
146
 
@@ -148,7 +148,7 @@ Set the valid from date on a verifiable credential.
148
148
 
149
149
  [`IDidVerifiableCredential`](../type-aliases/IDidVerifiableCredential.md)
150
150
 
151
- The verifiable credential to set the issuance date on.
151
+ The verifiable credential to update.
152
152
 
153
153
  ##### validFrom
154
154
 
@@ -1,6 +1,9 @@
1
1
  # Interface: IDidVerifiableCredentialCommon
2
2
 
3
- Interface describing a verifiable credential.
3
+ Common properties shared by all verifiable credential versions.
4
+
5
+ ## See
6
+
4
7
  https://www.w3.org/TR/vc-data-model-2.0
5
8
 
6
9
  ## Extended by
@@ -16,9 +16,7 @@ The canonical RDF namespace URI for DID.
16
16
 
17
17
  > `readonly` **Context**: `"https://www.w3.org/ns/did/v1"` = `"https://www.w3.org/ns/did/v1"`
18
18
 
19
- The value to use in JSON-LD context for DID.
20
- Note: Context matches Namespace (no trailing slash) as per W3C DID specification.
21
- The W3C DID JSON-LD context URL format does not include a trailing slash.
19
+ The value to use in the JSON-LD context for DID.
22
20
 
23
21
  ### JsonSchemaNamespace {#jsonschemanamespace}
24
22
 
@@ -36,9 +34,7 @@ The canonical RDF namespace URI for DID VC v1.
36
34
 
37
35
  > `readonly` **ContextVCv1**: `"https://www.w3.org/2018/credentials/v1"` = `"https://www.w3.org/2018/credentials/v1"`
38
36
 
39
- The value to use in JSON-LD context for DID VC v1.
40
- Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.
41
- The W3C VC v1 JSON-LD context URL format does not include a trailing slash.
37
+ The value to use in the JSON-LD context for DID VC v1.
42
38
 
43
39
  ### NamespaceVCv2 {#namespacevcv2}
44
40
 
@@ -50,9 +46,7 @@ The canonical RDF namespace URI for DID VC v2.
50
46
 
51
47
  > `readonly` **ContextVCv2**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
52
48
 
53
- The value to use in JSON-LD context for DID VC v2.
54
- Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.
55
- The W3C VC v2 JSON-LD context URL format does not include a trailing slash.
49
+ The value to use in the JSON-LD context for DID VC v2.
56
50
 
57
51
  ### NamespaceSecurityEd25519 {#namespacesecurityed25519}
58
52
 
@@ -64,9 +58,7 @@ The canonical RDF namespace URI for security ed25519 suites.
64
58
 
65
59
  > `readonly` **ContextSecurityEd25519**: `"https://w3id.org/security/suites/ed25519-2020/v1"` = `"https://w3id.org/security/suites/ed25519-2020/v1"`
66
60
 
67
- The value to use in JSON-LD context for security ed25519 suites.
68
- Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.
69
- The ed25519-2020 JSON-LD context URL format does not include a trailing slash.
61
+ The value to use in the JSON-LD context for security ed25519 suites.
70
62
 
71
63
  ### NamespaceSecurityJws2020 {#namespacesecurityjws2020}
72
64
 
@@ -78,9 +70,7 @@ The canonical RDF namespace URI for security jws-2020 suites.
78
70
 
79
71
  > `readonly` **ContextSecurityJws2020**: `"https://w3id.org/security/suites/jws-2020/v1"` = `"https://w3id.org/security/suites/jws-2020/v1"`
80
72
 
81
- The value to use in JSON-LD context for security jws-2020 suites.
82
- Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.
83
- The jws-2020 JSON-LD context URL format does not include a trailing slash.
73
+ The value to use in the JSON-LD context for security jws-2020 suites.
84
74
 
85
75
  ### NamespaceDataIntegrity {#namespacedataintegrity}
86
76
 
@@ -92,9 +82,7 @@ The canonical RDF namespace URI for VC Data Integrity.
92
82
 
93
83
  > `readonly` **ContextDataIntegrity**: `"https://w3id.org/security/data-integrity/v2"` = `"https://w3id.org/security/data-integrity/v2"`
94
84
 
95
- The value to use in JSON-LD context for VC Data Integrity.
96
- Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.
97
- The Data Integrity JSON-LD context URL format does not include a trailing slash.
85
+ The value to use in the JSON-LD context for VC Data Integrity.
98
86
 
99
87
  ### NamespaceControllerIdentifiers {#namespacecontrolleridentifiers}
100
88
 
@@ -106,9 +94,7 @@ The canonical RDF namespace URI for controller identifiers.
106
94
 
107
95
  > `readonly` **ContextControllerIdentifiers**: `"https://www.w3.org/ns/cid/v1"` = `"https://www.w3.org/ns/cid/v1"`
108
96
 
109
- The value to use in JSON-LD context for controller identifiers.
110
- Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.
111
- The Controller Identifiers JSON-LD context URL format does not include a trailing slash.
97
+ The value to use in the JSON-LD context for controller identifiers.
112
98
 
113
99
  ### NamespaceSecurityMultikey {#namespacesecuritymultikey}
114
100
 
@@ -120,6 +106,4 @@ The canonical RDF namespace URI for security multikey suites.
120
106
 
121
107
  > `readonly` **ContextSecurityMultikey**: `"https://w3id.org/security/multikey/v1"` = `"https://w3id.org/security/multikey/v1"`
122
108
 
123
- The value to use in JSON-LD context for security multikey suites.
124
- Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.
125
- The multikey JSON-LD context URL format does not include a trailing slash.
109
+ The value to use in the JSON-LD context for security multikey suites.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/standards-w3c-did",
3
- "version": "0.0.3-next.67",
3
+ "version": "0.0.3-next.68",
4
4
  "description": "Data models for the W3C DID Core specification.",
5
5
  "repository": {
6
6
  "type": "git",