@twin.org/standards-w3c-did 0.0.3-next.16 → 0.0.3-next.17

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 (30) hide show
  1. package/dist/es/models/IDataIntegrityProof.js.map +1 -1
  2. package/dist/es/models/IDidDocument.js.map +1 -1
  3. package/dist/es/models/IDidVerifiableCredentialV1.js.map +1 -1
  4. package/dist/es/models/IDidVerifiableCredentialV2.js.map +1 -1
  5. package/dist/es/models/IDidVerifiablePresentationV1.js.map +1 -1
  6. package/dist/es/models/IDidVerifiablePresentationV2.js.map +1 -1
  7. package/dist/es/models/IJsonWebSignature2020Proof.js.map +1 -1
  8. package/dist/es/models/IMultikey.js.map +1 -1
  9. package/dist/es/models/didContexts.js +57 -9
  10. package/dist/es/models/didContexts.js.map +1 -1
  11. package/dist/es/signerVerifiers/dataIntegrityProofSignerVerifier.js +2 -2
  12. package/dist/es/signerVerifiers/dataIntegrityProofSignerVerifier.js.map +1 -1
  13. package/dist/es/signerVerifiers/jsonWebSignature2020SignerVerifier.js +2 -2
  14. package/dist/es/signerVerifiers/jsonWebSignature2020SignerVerifier.js.map +1 -1
  15. package/dist/es/utils/multikeyHelper.js +1 -1
  16. package/dist/es/utils/multikeyHelper.js.map +1 -1
  17. package/dist/es/utils/proofHelper.js +2 -2
  18. package/dist/es/utils/proofHelper.js.map +1 -1
  19. package/dist/types/models/IDataIntegrityProof.d.ts +1 -1
  20. package/dist/types/models/IDidDocument.d.ts +1 -1
  21. package/dist/types/models/IDidVerifiableCredentialV1.d.ts +1 -1
  22. package/dist/types/models/IDidVerifiableCredentialV2.d.ts +1 -1
  23. package/dist/types/models/IDidVerifiablePresentationV1.d.ts +1 -1
  24. package/dist/types/models/IDidVerifiablePresentationV2.d.ts +1 -1
  25. package/dist/types/models/IJsonWebSignature2020Proof.d.ts +1 -1
  26. package/dist/types/models/IMultikey.d.ts +1 -1
  27. package/dist/types/models/didContexts.d.ts +56 -8
  28. package/docs/changelog.md +7 -0
  29. package/docs/reference/variables/DidContexts.md +72 -8
  30. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"IDataIntegrityProof.js","sourceRoot":"","sources":["../../../src/models/IDataIntegrityProof.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { DidCryptoSuites } from \"./didCryptoSuites.js\";\nimport type { ProofTypes } from \"./proofTypes.js\";\n\n/**\n * Interface describing a did proof.\n * https://www.w3.org/TR/vc-data-integrity/\n */\nexport interface IDataIntegrityProof {\n\t/**\n\t * JSON-LD Context.\n\t */\n\t\"@context\"?:\n\t\t| typeof DidContexts.NamespaceDataIntegrity\n\t\t| [typeof DidContexts.NamespaceDataIntegrity, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * JSON-LD Type.\n\t */\n\ttype: typeof ProofTypes.DataIntegrityProof;\n\n\t/**\n\t * An identifier for the cryptographic suite that can be used to verify the proof.\n\t */\n\tcryptosuite: DidCryptoSuites | string;\n\n\t/**\n\t * The id of the proof.\n\t */\n\tid?: string;\n\n\t/**\n\t * The reason the proof was created.\n\t */\n\tproofPurpose: string;\n\n\t/**\n\t * Contains the base-encoded binary data necessary to verify the\n\t * digital proof using the verificationMethod specified.\n\t */\n\tproofValue?: string;\n\n\t/**\n\t * The verification method of the proof.\n\t */\n\tverificationMethod?: string;\n\n\t/**\n\t * The iso date of when the proof was created.\n\t */\n\tcreated?: string;\n\n\t/**\n\t * The iso date of when the proof expires.\n\t */\n\texpires?: string;\n\n\t/**\n\t * One or more security domains in which the proof is meant to be used.\n\t */\n\tdomain?: string | string[];\n\n\t/**\n\t * Provided to mitigate replay attacks on domains.\n\t */\n\tchallenge?: string | string[];\n\n\t/**\n\t * Identifies another data integrity proof that MUST verify before\n\t * the current proof is processed\n\t */\n\tpreviousProof?: string;\n\n\t/**\n\t * Use of this field is to increase privacy by decreasing linkability\n\t * that is the result of deterministically generated signatures.\n\t */\n\tnonce?: string;\n}\n"]}
1
+ {"version":3,"file":"IDataIntegrityProof.js","sourceRoot":"","sources":["../../../src/models/IDataIntegrityProof.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { DidCryptoSuites } from \"./didCryptoSuites.js\";\nimport type { ProofTypes } from \"./proofTypes.js\";\n\n/**\n * Interface describing a did proof.\n * https://www.w3.org/TR/vc-data-integrity/\n */\nexport interface IDataIntegrityProof {\n\t/**\n\t * JSON-LD Context.\n\t */\n\t\"@context\"?:\n\t\t| typeof DidContexts.ContextDataIntegrity\n\t\t| [typeof DidContexts.ContextDataIntegrity, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * JSON-LD Type.\n\t */\n\ttype: typeof ProofTypes.DataIntegrityProof;\n\n\t/**\n\t * An identifier for the cryptographic suite that can be used to verify the proof.\n\t */\n\tcryptosuite: DidCryptoSuites | string;\n\n\t/**\n\t * The id of the proof.\n\t */\n\tid?: string;\n\n\t/**\n\t * The reason the proof was created.\n\t */\n\tproofPurpose: string;\n\n\t/**\n\t * Contains the base-encoded binary data necessary to verify the\n\t * digital proof using the verificationMethod specified.\n\t */\n\tproofValue?: string;\n\n\t/**\n\t * The verification method of the proof.\n\t */\n\tverificationMethod?: string;\n\n\t/**\n\t * The iso date of when the proof was created.\n\t */\n\tcreated?: string;\n\n\t/**\n\t * The iso date of when the proof expires.\n\t */\n\texpires?: string;\n\n\t/**\n\t * One or more security domains in which the proof is meant to be used.\n\t */\n\tdomain?: string | string[];\n\n\t/**\n\t * Provided to mitigate replay attacks on domains.\n\t */\n\tchallenge?: string | string[];\n\n\t/**\n\t * Identifies another data integrity proof that MUST verify before\n\t * the current proof is processed\n\t */\n\tpreviousProof?: string;\n\n\t/**\n\t * Use of this field is to increase privacy by decreasing linkability\n\t * that is the result of deterministically generated signatures.\n\t */\n\tnonce?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDidDocument.js","sourceRoot":"","sources":["../../../src/models/IDidDocument.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidDocumentVerificationMethod } from \"./IDidDocumentVerificationMethod.js\";\nimport type { IDidService } from \"./IDidService.js\";\n\n/**\n * Interface describing a DID Document.\n * Spec https://www.w3.org/TR/did-core/#did-document-properties.\n */\nexport interface IDidDocument {\n\t/**\n\t * The context for the document.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.Namespace\n\t\t| [typeof DidContexts.Namespace, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The id for the document.\n\t */\n\tid: string;\n\n\t/**\n\t * Aliases for the document.\n\t */\n\talsoKnownAs?: string | string[];\n\n\t/**\n\t * The controller for the document.\n\t */\n\tcontroller?: string | string[];\n\n\t/**\n\t * The verification methods.\n\t */\n\tverificationMethod?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The authentication methods.\n\t */\n\tauthentication?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The assertion methods.\n\t */\n\tassertionMethod?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The key agreements.\n\t */\n\tkeyAgreement?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The capability invocations.\n\t */\n\tcapabilityInvocation?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The capability delegations.\n\t */\n\tcapabilityDelegation?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The services.\n\t */\n\tservice?: IDidService[];\n}\n"]}
1
+ {"version":3,"file":"IDidDocument.js","sourceRoot":"","sources":["../../../src/models/IDidDocument.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidDocumentVerificationMethod } from \"./IDidDocumentVerificationMethod.js\";\nimport type { IDidService } from \"./IDidService.js\";\n\n/**\n * Interface describing a DID Document.\n * Spec https://www.w3.org/TR/did-core/#did-document-properties.\n */\nexport interface IDidDocument {\n\t/**\n\t * The context for the document.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.Context\n\t\t| [typeof DidContexts.Context, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The id for the document.\n\t */\n\tid: string;\n\n\t/**\n\t * Aliases for the document.\n\t */\n\talsoKnownAs?: string | string[];\n\n\t/**\n\t * The controller for the document.\n\t */\n\tcontroller?: string | string[];\n\n\t/**\n\t * The verification methods.\n\t */\n\tverificationMethod?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The authentication methods.\n\t */\n\tauthentication?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The assertion methods.\n\t */\n\tassertionMethod?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The key agreements.\n\t */\n\tkeyAgreement?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The capability invocations.\n\t */\n\tcapabilityInvocation?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The capability delegations.\n\t */\n\tcapabilityDelegation?: (string | IDidDocumentVerificationMethod)[];\n\n\t/**\n\t * The services.\n\t */\n\tservice?: IDidService[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDidVerifiableCredentialV1.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiableCredentialV1.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialCommon } from \"./IDidVerifiableCredentialCommon.js\";\n\n/**\n * Interface describing a verifiable credential.\n * https://www.w3.org/TR/vc-data-model-1.1\n */\nexport interface IDidVerifiableCredentialV1 extends IDidVerifiableCredentialCommon {\n\t/**\n\t * The context for the verifiable credential.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.NamespaceVCv1\n\t\t| [typeof DidContexts.NamespaceVCv1, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The date the verifiable credential was issued, depending on version validFrom might be set instead.\n\t */\n\tissuanceDate?: string;\n\n\t/**\n\t * The date the verifiable credential expires, depending on version validUntil might be set instead.\n\t */\n\texpirationDate?: string;\n}\n"]}
1
+ {"version":3,"file":"IDidVerifiableCredentialV1.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiableCredentialV1.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialCommon } from \"./IDidVerifiableCredentialCommon.js\";\n\n/**\n * Interface describing a verifiable credential.\n * https://www.w3.org/TR/vc-data-model-1.1\n */\nexport interface IDidVerifiableCredentialV1 extends IDidVerifiableCredentialCommon {\n\t/**\n\t * The context for the verifiable credential.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.ContextVCv1\n\t\t| [typeof DidContexts.ContextVCv1, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The date the verifiable credential was issued, depending on version validFrom might be set instead.\n\t */\n\tissuanceDate?: string;\n\n\t/**\n\t * The date the verifiable credential expires, depending on version validUntil might be set instead.\n\t */\n\texpirationDate?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDidVerifiableCredentialV2.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiableCredentialV2.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialCommon } from \"./IDidVerifiableCredentialCommon.js\";\n\n/**\n * Interface describing a verifiable credential.\n * https://www.w3.org/TR/vc-data-model-2.0\n */\nexport interface IDidVerifiableCredentialV2 extends IDidVerifiableCredentialCommon {\n\t/**\n\t * The context for the verifiable credential.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.NamespaceVCv2\n\t\t| [typeof DidContexts.NamespaceVCv2, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The date the verifiable credential is valid from.\n\t */\n\tvalidFrom?: string;\n\n\t/**\n\t * The date the verifiable credential is valid until.\n\t */\n\tvalidUntil?: string;\n}\n"]}
1
+ {"version":3,"file":"IDidVerifiableCredentialV2.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiableCredentialV2.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialCommon } from \"./IDidVerifiableCredentialCommon.js\";\n\n/**\n * Interface describing a verifiable credential.\n * https://www.w3.org/TR/vc-data-model-2.0\n */\nexport interface IDidVerifiableCredentialV2 extends IDidVerifiableCredentialCommon {\n\t/**\n\t * The context for the verifiable credential.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.ContextVCv2\n\t\t| [typeof DidContexts.ContextVCv2, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The date the verifiable credential is valid from.\n\t */\n\tvalidFrom?: string;\n\n\t/**\n\t * The date the verifiable credential is valid until.\n\t */\n\tvalidUntil?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDidVerifiablePresentationV1.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiablePresentationV1.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialV1 } from \"./IDidVerifiableCredentialV1.js\";\nimport type { IDidVerifiablePresentationCommon } from \"./IDidVerifiablePresentationCommon.js\";\n\n/**\n * Interface describing a verifiable presentation.\n */\nexport interface IDidVerifiablePresentationV1 extends IDidVerifiablePresentationCommon {\n\t/**\n\t * The context for the verifiable presentation.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.NamespaceVCv1\n\t\t| [typeof DidContexts.NamespaceVCv1, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The data for the verifiable credentials.\n\t */\n\tverifiableCredential?: (string | IDidVerifiableCredentialV1)[];\n}\n"]}
1
+ {"version":3,"file":"IDidVerifiablePresentationV1.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiablePresentationV1.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialV1 } from \"./IDidVerifiableCredentialV1.js\";\nimport type { IDidVerifiablePresentationCommon } from \"./IDidVerifiablePresentationCommon.js\";\n\n/**\n * Interface describing a verifiable presentation.\n */\nexport interface IDidVerifiablePresentationV1 extends IDidVerifiablePresentationCommon {\n\t/**\n\t * The context for the verifiable presentation.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.ContextVCv1\n\t\t| [typeof DidContexts.ContextVCv1, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The data for the verifiable credentials.\n\t */\n\tverifiableCredential?: (string | IDidVerifiableCredentialV1)[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IDidVerifiablePresentationV2.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiablePresentationV2.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialV2 } from \"./IDidVerifiableCredentialV2.js\";\nimport type { IDidVerifiablePresentationCommon } from \"./IDidVerifiablePresentationCommon.js\";\n\n/**\n * Interface describing a verifiable presentation.\n */\nexport interface IDidVerifiablePresentationV2 extends IDidVerifiablePresentationCommon {\n\t/**\n\t * The context for the verifiable presentation.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.NamespaceVCv2\n\t\t| [typeof DidContexts.NamespaceVCv2, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The data for the verifiable credentials.\n\t */\n\tverifiableCredential?: (string | IDidVerifiableCredentialV2)[];\n}\n"]}
1
+ {"version":3,"file":"IDidVerifiablePresentationV2.js","sourceRoot":"","sources":["../../../src/models/IDidVerifiablePresentationV2.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { IDidVerifiableCredentialV2 } from \"./IDidVerifiableCredentialV2.js\";\nimport type { IDidVerifiablePresentationCommon } from \"./IDidVerifiablePresentationCommon.js\";\n\n/**\n * Interface describing a verifiable presentation.\n */\nexport interface IDidVerifiablePresentationV2 extends IDidVerifiablePresentationCommon {\n\t/**\n\t * The context for the verifiable presentation.\n\t */\n\t\"@context\":\n\t\t| typeof DidContexts.ContextVCv2\n\t\t| [typeof DidContexts.ContextVCv2, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The data for the verifiable credentials.\n\t */\n\tverifiableCredential?: (string | IDidVerifiableCredentialV2)[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IJsonWebSignature2020Proof.js","sourceRoot":"","sources":["../../../src/models/IJsonWebSignature2020Proof.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { ProofTypes } from \"./proofTypes.js\";\n\n/**\n * Interface describing a did proof in JSON Web Signature 2020 Format.\n * https://www.w3.org/TR/vc-jws-2020/\n */\nexport interface IJsonWebSignature2020Proof {\n\t/**\n\t * JSON-LD Context.\n\t */\n\t\"@context\"?:\n\t\t| typeof DidContexts.NamespaceSecurityJws2020\n\t\t| [typeof DidContexts.NamespaceSecurityJws2020, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * JSON-LD Type.\n\t */\n\ttype: typeof ProofTypes.JsonWebSignature2020;\n\n\t/**\n\t * The reason the proof was created.\n\t */\n\tproofPurpose: string;\n\n\t/**\n\t * The verification method of the proof.\n\t */\n\tverificationMethod?: string;\n\n\t/**\n\t * The iso date of when the proof was created.\n\t */\n\tcreated?: string;\n\n\t/**\n\t * The JSON Web Signature.\n\t */\n\tjws?: string;\n}\n"]}
1
+ {"version":3,"file":"IJsonWebSignature2020Proof.js","sourceRoot":"","sources":["../../../src/models/IJsonWebSignature2020Proof.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { ProofTypes } from \"./proofTypes.js\";\n\n/**\n * Interface describing a did proof in JSON Web Signature 2020 Format.\n * https://www.w3.org/TR/vc-jws-2020/\n */\nexport interface IJsonWebSignature2020Proof {\n\t/**\n\t * JSON-LD Context.\n\t */\n\t\"@context\"?:\n\t\t| typeof DidContexts.ContextSecurityJws2020\n\t\t| [typeof DidContexts.ContextSecurityJws2020, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * JSON-LD Type.\n\t */\n\ttype: typeof ProofTypes.JsonWebSignature2020;\n\n\t/**\n\t * The reason the proof was created.\n\t */\n\tproofPurpose: string;\n\n\t/**\n\t * The verification method of the proof.\n\t */\n\tverificationMethod?: string;\n\n\t/**\n\t * The iso date of when the proof was created.\n\t */\n\tcreated?: string;\n\n\t/**\n\t * The JSON Web Signature.\n\t */\n\tjws?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IMultikey.js","sourceRoot":"","sources":["../../../src/models/IMultikey.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { DidTypes } from \"./didTypes.js\";\n\n/**\n * Interface describing a Multikey.\n * https://www.w3.org/TR/cid-1.0/\n */\nexport interface IMultikey {\n\t/**\n\t * JSON-LD Context.\n\t */\n\t\"@context\"?:\n\t\t| typeof DidContexts.NamespaceControllerIdentifiers\n\t\t| typeof DidContexts.NamespaceSecurityMultikey\n\t\t| [typeof DidContexts.NamespaceControllerIdentifiers, ...IJsonLdContextDefinitionElement[]]\n\t\t| [typeof DidContexts.NamespaceSecurityMultikey, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The id of the entry.\n\t */\n\tid?: string;\n\n\t/**\n\t * The type of the entry.\n\t */\n\ttype: typeof DidTypes.Multikey;\n\n\t/**\n\t * The controller for the entry.\n\t */\n\tcontroller?: string;\n\n\t/**\n\t * The public key for the entry.\n\t */\n\tpublicKeyMultibase: string;\n\n\t/**\n\t * The secret key for the entry.\n\t */\n\tsecretKeyMultibase?: string;\n\n\t/**\n\t * The date the entry expires.\n\t */\n\texpires?: string;\n\n\t/**\n\t * The date the entry was revoked.\n\t */\n\trevoked?: string;\n}\n"]}
1
+ {"version":3,"file":"IMultikey.js","sourceRoot":"","sources":["../../../src/models/IMultikey.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type { DidContexts } from \"./didContexts.js\";\nimport type { DidTypes } from \"./didTypes.js\";\n\n/**\n * Interface describing a Multikey.\n * https://www.w3.org/TR/cid-1.0/\n */\nexport interface IMultikey {\n\t/**\n\t * JSON-LD Context.\n\t */\n\t\"@context\"?:\n\t\t| typeof DidContexts.ContextControllerIdentifiers\n\t\t| typeof DidContexts.ContextSecurityMultikey\n\t\t| [typeof DidContexts.ContextControllerIdentifiers, ...IJsonLdContextDefinitionElement[]]\n\t\t| [typeof DidContexts.ContextSecurityMultikey, ...IJsonLdContextDefinitionElement[]];\n\n\t/**\n\t * The id of the entry.\n\t */\n\tid?: string;\n\n\t/**\n\t * The type of the entry.\n\t */\n\ttype: typeof DidTypes.Multikey;\n\n\t/**\n\t * The controller for the entry.\n\t */\n\tcontroller?: string;\n\n\t/**\n\t * The public key for the entry.\n\t */\n\tpublicKeyMultibase: string;\n\n\t/**\n\t * The secret key for the entry.\n\t */\n\tsecretKeyMultibase?: string;\n\n\t/**\n\t * The date the entry expires.\n\t */\n\texpires?: string;\n\n\t/**\n\t * The date the entry was revoked.\n\t */\n\trevoked?: string;\n}\n"]}
@@ -6,36 +6,84 @@
6
6
  // eslint-disable-next-line @typescript-eslint/naming-convention
7
7
  export const DidContexts = {
8
8
  /**
9
- * The context root for DID.
9
+ * The canonical RDF namespace URI for DID.
10
10
  */
11
11
  Namespace: "https://www.w3.org/ns/did/v1",
12
12
  /**
13
- * The context root for DID VC v1.
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.
16
+ */
17
+ Context: "https://www.w3.org/ns/did/v1",
18
+ /**
19
+ * The canonical RDF namespace URI for DID VC v1.
14
20
  */
15
21
  NamespaceVCv1: "https://www.w3.org/2018/credentials/v1",
16
22
  /**
17
- * The context root for DID VC v2.
23
+ * The value to use in JSON-LD context for DID VC v1.
24
+ * Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.
25
+ * The W3C VC v1 JSON-LD context URL format does not include a trailing slash.
26
+ */
27
+ ContextVCv1: "https://www.w3.org/2018/credentials/v1",
28
+ /**
29
+ * The canonical RDF namespace URI for DID VC v2.
18
30
  */
19
31
  NamespaceVCv2: "https://www.w3.org/ns/credentials/v2",
20
32
  /**
21
- * The context root for security ed25519 suites.
33
+ * The value to use in JSON-LD context for DID VC v2.
34
+ * Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.
35
+ * The W3C VC v2 JSON-LD context URL format does not include a trailing slash.
36
+ */
37
+ ContextVCv2: "https://www.w3.org/ns/credentials/v2",
38
+ /**
39
+ * The canonical RDF namespace URI for security ed25519 suites.
22
40
  */
23
41
  NamespaceSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1",
24
42
  /**
25
- * The context root for security jws-2020 suites.
43
+ * The value to use in JSON-LD context for security ed25519 suites.
44
+ * Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.
45
+ * The ed25519-2020 JSON-LD context URL format does not include a trailing slash.
46
+ */
47
+ ContextSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1",
48
+ /**
49
+ * The canonical RDF namespace URI for security jws-2020 suites.
26
50
  */
27
51
  NamespaceSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1",
28
52
  /**
29
- * The context root for VC Data Integrity.
53
+ * The value to use in JSON-LD context for security jws-2020 suites.
54
+ * Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.
55
+ * The jws-2020 JSON-LD context URL format does not include a trailing slash.
56
+ */
57
+ ContextSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1",
58
+ /**
59
+ * The canonical RDF namespace URI for VC Data Integrity.
30
60
  */
31
61
  NamespaceDataIntegrity: "https://www.w3.org/ns/credentials/v2",
32
62
  /**
33
- * The context root for VC Data Integrity.
63
+ * The value to use in JSON-LD context for VC Data Integrity.
64
+ * Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.
65
+ * The Data Integrity JSON-LD context URL format does not include a trailing slash.
66
+ */
67
+ ContextDataIntegrity: "https://www.w3.org/ns/credentials/v2",
68
+ /**
69
+ * The canonical RDF namespace URI for controller identifiers.
34
70
  */
35
71
  NamespaceControllerIdentifiers: "https://www.w3.org/ns/cid/v1",
36
72
  /**
37
- * The context root for security multikey suites.
73
+ * The value to use in JSON-LD context for controller identifiers.
74
+ * Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.
75
+ * The Controller Identifiers JSON-LD context URL format does not include a trailing slash.
76
+ */
77
+ ContextControllerIdentifiers: "https://www.w3.org/ns/cid/v1",
78
+ /**
79
+ * The canonical RDF namespace URI for security multikey suites.
80
+ */
81
+ NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1",
82
+ /**
83
+ * The value to use in JSON-LD context for security multikey suites.
84
+ * Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.
85
+ * The multikey JSON-LD context URL format does not include a trailing slash.
38
86
  */
39
- NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1"
87
+ ContextSecurityMultikey: "https://w3id.org/security/multikey/v1"
40
88
  };
41
89
  //# sourceMappingURL=didContexts.js.map
@@ -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;;OAEG;IACH,aAAa,EAAE,wCAAwC;IAEvD;;OAEG;IACH,aAAa,EAAE,sCAAsC;IAErD;;OAEG;IACH,wBAAwB,EAAE,kDAAkD;IAE5E;;OAEG;IACH,wBAAwB,EAAE,8CAA8C;IAExE;;OAEG;IACH,sBAAsB,EAAE,sCAAsC;IAE9D;;OAEG;IACH,8BAA8B,EAAE,8BAA8B;IAE9D;;OAEG;IACH,yBAAyB,EAAE,uCAAuC;CACzD,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 context root for DID.\n\t */\n\tNamespace: \"https://www.w3.org/ns/did/v1\",\n\n\t/**\n\t * The context root for DID VC v1.\n\t */\n\tNamespaceVCv1: \"https://www.w3.org/2018/credentials/v1\",\n\n\t/**\n\t * The context root for DID VC v2.\n\t */\n\tNamespaceVCv2: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The context root for security ed25519 suites.\n\t */\n\tNamespaceSecurityEd25519: \"https://w3id.org/security/suites/ed25519-2020/v1\",\n\n\t/**\n\t * The context root for security jws-2020 suites.\n\t */\n\tNamespaceSecurityJws2020: \"https://w3id.org/security/suites/jws-2020/v1\",\n\n\t/**\n\t * The context root for VC Data Integrity.\n\t */\n\tNamespaceDataIntegrity: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The context root for VC Data Integrity.\n\t */\n\tNamespaceControllerIdentifiers: \"https://www.w3.org/ns/cid/v1\",\n\n\t/**\n\t * The context root for security multikey suites.\n\t */\n\tNamespaceSecurityMultikey: \"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;;;;OAIG;IACH,OAAO,EAAE,8BAA8B;IAEvC;;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,sCAAsC;IAE9D;;;;OAIG;IACH,oBAAoB,EAAE,sCAAsC;IAE5D;;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 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://www.w3.org/ns/credentials/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://www.w3.org/ns/credentials/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"]}
@@ -32,7 +32,7 @@ export class DataIntegrityProofSignerVerifier {
32
32
  }
33
33
  const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
34
34
  const signedProof = ObjectHelper.clone(unsignedProof);
35
- unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceDataIntegrity);
35
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextDataIntegrity);
36
36
  signedProof["@context"] = unsecuredDocumentClone["@context"];
37
37
  const combinedHash = await this.createHash(unsecuredDocument, unsignedProof);
38
38
  const signature = Ed25519.sign(rawKeys.privateKey, combinedHash);
@@ -78,7 +78,7 @@ export class DataIntegrityProofSignerVerifier {
78
78
  cryptoSuite: proofOptionsClone.cryptosuite
79
79
  });
80
80
  }
81
- unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceDataIntegrity);
81
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextDataIntegrity);
82
82
  proofOptionsClone["@context"] = unsecuredDocumentClone["@context"];
83
83
  const transformedDocument = JsonHelper.canonicalize(unsecuredDocumentClone);
84
84
  const transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(transformedDocument));
@@ -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,wBAAwB,CAAC;AAEjF,OAAO,EAAE,GAAG,EAAa,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D;;;GAGG;AACH,MAAM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,\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.NamespaceDataIntegrity\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.NamespaceDataIntegrity\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,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D;;;GAGG;AACH,MAAM,OAAO,gCAAgC;IAC5C;;OAEG;IACI,MAAM,CAAU,UAAU,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8ArrayHelper\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"]}
@@ -25,7 +25,7 @@ export class JsonWebSignature2020SignerVerifier {
25
25
  Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
26
26
  Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "signKey", signKey);
27
27
  const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
28
- unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceSecurityJws2020);
28
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextSecurityJws2020);
29
29
  const hash = await this.createHash(unsecuredDocument, unsignedProof);
30
30
  const cryptoKey = await Jwk.toCryptoKey(signKey);
31
31
  const signature = await Jws.create(cryptoKey, hash, signKey.alg);
@@ -65,7 +65,7 @@ export class JsonWebSignature2020SignerVerifier {
65
65
  Guards.stringValue(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof.verificationMethod", unsignedProof.verificationMethod);
66
66
  const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
67
67
  const proofOptionsClone = ObjectHelper.clone(unsignedProof);
68
- unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceSecurityJws2020);
68
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextSecurityJws2020);
69
69
  proofOptionsClone["@context"] = unsecuredDocumentClone["@context"];
70
70
  delete unsecuredDocumentClone.proof;
71
71
  delete proofOptionsClone.jws;
@@ -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,G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C,aAAa,CAAC,CAAC,CAAC;QAEvE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,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.NamespaceSecurityJws2020\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.NamespaceSecurityJws2020\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;;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,GAAG,eAAe,CAAC,eAAe,CACnE,sBAAsB,CAAC,UAAU,CAAC,EAClC,WAAW,CAAC,sBAAsB,CAClC,CAAC;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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"]}
@@ -53,7 +53,7 @@ export class MultikeyHelper {
53
53
  publicKey[1] = 0x01;
54
54
  publicKey.set(publicRaw, 2);
55
55
  const multikey = {
56
- "@context": DidContexts.NamespaceControllerIdentifiers,
56
+ "@context": DidContexts.ContextControllerIdentifiers,
57
57
  type: DidTypes.Multikey,
58
58
  controller,
59
59
  id,
@@ -1 +1 @@
1
- {"version":3,"file":"multikeyHelper.js","sourceRoot":"","sources":["../../../src/utils/multikeyHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAU,UAAU,oBAAoC;IAErE;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,QAAmB;QACtC,MAAM,CAAC,MAAM,CAAY,cAAc,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAEhF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEjE,OAAO;YACN,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,OAAO;YACZ,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;YAC/E,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;SACjF,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,OAAO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,EAAE,CAAC;gBAC1D,MAAM,IAAI,YAAY,CAAC,cAAc,CAAC,UAAU,EAAE,iCAAiC,EAAE;oBACpF,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;iBAC/C,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,IAAI,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACjD,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClD,MAAM,IAAI,YAAY,CAAC,cAAc,CAAC,UAAU,EAAE,2BAA2B,EAAE;oBAC9E,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;iBAC/C,CAAC,CAAC;YACJ,CAAC;YACD,YAAY,GAAG,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7E,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC1D,MAAM,IAAI,YAAY,CAAC,cAAc,CAAC,UAAU,EAAE,iCAAiC,EAAE;oBACpF,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;iBAC/C,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO;YACN,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,UAAU,EAAE;YACrD,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,UAAU,EAAE;SAC1D,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, GeneralError, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidTypes } from \"../models/didTypes.js\";\nimport type { IMultikey } from \"../models/IMultikey.js\";\n\n/**\n * Helper methods for multikey.\n */\nexport class MultikeyHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<MultikeyHelper>();\n\n\t/**\n\t * Convert a multikey to a JWK.\n\t * @param multikey The multikey to convert.\n\t * @returns The JWK.\n\t * @throws GeneralError if the multikey is invalid.\n\t */\n\tpublic static toJwk(multikey: IMultikey): IJwk {\n\t\tGuards.object<IMultikey>(MultikeyHelper.CLASS_NAME, nameof(multikey), multikey);\n\n\t\tconst { publicKey, privateKey } = MultikeyHelper.toRaw(multikey);\n\n\t\treturn {\n\t\t\tkty: \"OKP\",\n\t\t\tcrv: \"Ed25519\",\n\t\t\talg: \"EdDSA\",\n\t\t\tx: Is.uint8Array(publicKey) ? Converter.bytesToBase64Url(publicKey) : undefined,\n\t\t\td: Is.uint8Array(privateKey) ? Converter.bytesToBase64Url(privateKey) : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Convert a JWK to a Multikey.\n\t * @param controller The controller of the multikey.\n\t * @param id The id of the multikey.\n\t * @param jwk The jwk to convert.\n\t * @returns The multikey.\n\t * @throws GeneralError if the jwk is invalid.\n\t */\n\tpublic static fromJwk(controller: string, id: string, jwk: IJwk): IMultikey {\n\t\tGuards.stringValue(MultikeyHelper.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(MultikeyHelper.CLASS_NAME, nameof(id), id);\n\t\tGuards.object<IJwk>(MultikeyHelper.CLASS_NAME, nameof(jwk), jwk);\n\t\tGuards.stringValue(MultikeyHelper.CLASS_NAME, nameof(jwk.x), jwk.x);\n\n\t\tif (jwk.kty !== \"OKP\") {\n\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"unsupportedKty\", { kty: jwk.kty });\n\t\t}\n\n\t\tif (jwk.crv !== \"Ed25519\") {\n\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"unsupportedCrv\", { crv: jwk.crv });\n\t\t}\n\n\t\tconst publicRaw = Converter.base64UrlToBytes(jwk.x);\n\t\tconst publicKey = new Uint8Array(2 + publicRaw.length);\n\t\tpublicKey[0] = 0xed;\n\t\tpublicKey[1] = 0x01;\n\t\tpublicKey.set(publicRaw, 2);\n\n\t\tconst multikey: IMultikey = {\n\t\t\t\"@context\": DidContexts.NamespaceControllerIdentifiers,\n\t\t\ttype: DidTypes.Multikey,\n\t\t\tcontroller,\n\t\t\tid,\n\t\t\tpublicKeyMultibase: `z${Converter.bytesToBase58(publicKey)}`\n\t\t};\n\n\t\tif (Is.stringValue(jwk.d)) {\n\t\t\tconst privateRaw = Converter.base64UrlToBytes(jwk.d);\n\t\t\tconst secretKey = new Uint8Array(2 + privateRaw.length);\n\t\t\tsecretKey[0] = 0x80;\n\t\t\tsecretKey[1] = 0x26;\n\t\t\tsecretKey.set(privateRaw, 2);\n\t\t\tmultikey.secretKeyMultibase = `z${Converter.bytesToBase58(secretKey)}`;\n\t\t}\n\n\t\treturn multikey;\n\t}\n\n\t/**\n\t * Convert a multikey to raw keys.\n\t * @param multikey The multikey to convert.\n\t * @returns The JWK.\n\t * @throws GeneralError if the multikey is invalid.\n\t */\n\tpublic static toRaw(multikey: IMultikey): {\n\t\tpublicKey: Uint8Array;\n\t\tprivateKey: Uint8Array;\n\t} {\n\t\tGuards.object<IMultikey>(MultikeyHelper.CLASS_NAME, nameof(multikey), multikey);\n\n\t\tlet publicKeyRaw: Uint8Array | undefined;\n\t\tlet secretKeyRaw: Uint8Array | undefined;\n\n\t\tif (Is.stringValue(multikey.publicKeyMultibase)) {\n\t\t\tif (!multikey.publicKeyMultibase.startsWith(\"z\")) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"invalidPublicKeyMultibase\", {\n\t\t\t\t\tpublicKeyMultibase: multikey.publicKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublicKeyRaw = Converter.base58ToBytes(multikey.publicKeyMultibase.slice(1));\n\t\t\tif (publicKeyRaw[0] !== 0xed || publicKeyRaw[1] !== 0x01) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"publicKeyMultibaseMissingHeader\", {\n\t\t\t\t\tpublicKeyMultibase: multikey.publicKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (Is.stringValue(multikey.secretKeyMultibase)) {\n\t\t\tif (!multikey.secretKeyMultibase.startsWith(\"z\")) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"invalidSecretKeyMultibase\", {\n\t\t\t\t\tsecretKeyMultibase: multikey.secretKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\t\t\tsecretKeyRaw = Converter.base58ToBytes(multikey.secretKeyMultibase.slice(1));\n\t\t\tif (secretKeyRaw[0] !== 0x80 || secretKeyRaw[1] !== 0x26) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"secretKeyMultibaseMissingHeader\", {\n\t\t\t\t\tsecretKeyMultibase: multikey.secretKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tpublicKey: publicKeyRaw?.slice(2) ?? new Uint8Array(),\n\t\t\tprivateKey: secretKeyRaw?.slice(2, 34) ?? new Uint8Array()\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"multikeyHelper.js","sourceRoot":"","sources":["../../../src/utils/multikeyHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAU,UAAU,oBAAoC;IAErE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C,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC1D,MAAM,IAAI,YAAY,CAAC,cAAc,CAAC,UAAU,EAAE,iCAAiC,EAAE;oBACpF,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;iBAC/C,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO;YACN,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,UAAU,EAAE;YACrD,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,UAAU,EAAE;SAC1D,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, GeneralError, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidTypes } from \"../models/didTypes.js\";\nimport type { IMultikey } from \"../models/IMultikey.js\";\n\n/**\n * Helper methods for multikey.\n */\nexport class MultikeyHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<MultikeyHelper>();\n\n\t/**\n\t * Convert a multikey to a JWK.\n\t * @param multikey The multikey to convert.\n\t * @returns The JWK.\n\t * @throws GeneralError if the multikey is invalid.\n\t */\n\tpublic static toJwk(multikey: IMultikey): IJwk {\n\t\tGuards.object<IMultikey>(MultikeyHelper.CLASS_NAME, nameof(multikey), multikey);\n\n\t\tconst { publicKey, privateKey } = MultikeyHelper.toRaw(multikey);\n\n\t\treturn {\n\t\t\tkty: \"OKP\",\n\t\t\tcrv: \"Ed25519\",\n\t\t\talg: \"EdDSA\",\n\t\t\tx: Is.uint8Array(publicKey) ? Converter.bytesToBase64Url(publicKey) : undefined,\n\t\t\td: Is.uint8Array(privateKey) ? Converter.bytesToBase64Url(privateKey) : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Convert a JWK to a Multikey.\n\t * @param controller The controller of the multikey.\n\t * @param id The id of the multikey.\n\t * @param jwk The jwk to convert.\n\t * @returns The multikey.\n\t * @throws GeneralError if the jwk is invalid.\n\t */\n\tpublic static fromJwk(controller: string, id: string, jwk: IJwk): IMultikey {\n\t\tGuards.stringValue(MultikeyHelper.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(MultikeyHelper.CLASS_NAME, nameof(id), id);\n\t\tGuards.object<IJwk>(MultikeyHelper.CLASS_NAME, nameof(jwk), jwk);\n\t\tGuards.stringValue(MultikeyHelper.CLASS_NAME, nameof(jwk.x), jwk.x);\n\n\t\tif (jwk.kty !== \"OKP\") {\n\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"unsupportedKty\", { kty: jwk.kty });\n\t\t}\n\n\t\tif (jwk.crv !== \"Ed25519\") {\n\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"unsupportedCrv\", { crv: jwk.crv });\n\t\t}\n\n\t\tconst publicRaw = Converter.base64UrlToBytes(jwk.x);\n\t\tconst publicKey = new Uint8Array(2 + publicRaw.length);\n\t\tpublicKey[0] = 0xed;\n\t\tpublicKey[1] = 0x01;\n\t\tpublicKey.set(publicRaw, 2);\n\n\t\tconst multikey: IMultikey = {\n\t\t\t\"@context\": DidContexts.ContextControllerIdentifiers,\n\t\t\ttype: DidTypes.Multikey,\n\t\t\tcontroller,\n\t\t\tid,\n\t\t\tpublicKeyMultibase: `z${Converter.bytesToBase58(publicKey)}`\n\t\t};\n\n\t\tif (Is.stringValue(jwk.d)) {\n\t\t\tconst privateRaw = Converter.base64UrlToBytes(jwk.d);\n\t\t\tconst secretKey = new Uint8Array(2 + privateRaw.length);\n\t\t\tsecretKey[0] = 0x80;\n\t\t\tsecretKey[1] = 0x26;\n\t\t\tsecretKey.set(privateRaw, 2);\n\t\t\tmultikey.secretKeyMultibase = `z${Converter.bytesToBase58(secretKey)}`;\n\t\t}\n\n\t\treturn multikey;\n\t}\n\n\t/**\n\t * Convert a multikey to raw keys.\n\t * @param multikey The multikey to convert.\n\t * @returns The JWK.\n\t * @throws GeneralError if the multikey is invalid.\n\t */\n\tpublic static toRaw(multikey: IMultikey): {\n\t\tpublicKey: Uint8Array;\n\t\tprivateKey: Uint8Array;\n\t} {\n\t\tGuards.object<IMultikey>(MultikeyHelper.CLASS_NAME, nameof(multikey), multikey);\n\n\t\tlet publicKeyRaw: Uint8Array | undefined;\n\t\tlet secretKeyRaw: Uint8Array | undefined;\n\n\t\tif (Is.stringValue(multikey.publicKeyMultibase)) {\n\t\t\tif (!multikey.publicKeyMultibase.startsWith(\"z\")) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"invalidPublicKeyMultibase\", {\n\t\t\t\t\tpublicKeyMultibase: multikey.publicKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublicKeyRaw = Converter.base58ToBytes(multikey.publicKeyMultibase.slice(1));\n\t\t\tif (publicKeyRaw[0] !== 0xed || publicKeyRaw[1] !== 0x01) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"publicKeyMultibaseMissingHeader\", {\n\t\t\t\t\tpublicKeyMultibase: multikey.publicKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (Is.stringValue(multikey.secretKeyMultibase)) {\n\t\t\tif (!multikey.secretKeyMultibase.startsWith(\"z\")) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"invalidSecretKeyMultibase\", {\n\t\t\t\t\tsecretKeyMultibase: multikey.secretKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\t\t\tsecretKeyRaw = Converter.base58ToBytes(multikey.secretKeyMultibase.slice(1));\n\t\t\tif (secretKeyRaw[0] !== 0x80 || secretKeyRaw[1] !== 0x26) {\n\t\t\t\tthrow new GeneralError(MultikeyHelper.CLASS_NAME, \"secretKeyMultibaseMissingHeader\", {\n\t\t\t\t\tsecretKeyMultibase: multikey.secretKeyMultibase\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tpublicKey: publicKeyRaw?.slice(2) ?? new Uint8Array(),\n\t\t\tprivateKey: secretKeyRaw?.slice(2, 34) ?? new Uint8Array()\n\t\t};\n\t}\n}\n"]}
@@ -78,7 +78,7 @@ export class ProofHelper {
78
78
  let proof;
79
79
  if (proofType === ProofTypes.DataIntegrityProof) {
80
80
  proof = {
81
- "@context": DidContexts.NamespaceDataIntegrity,
81
+ "@context": DidContexts.ContextDataIntegrity,
82
82
  type: ProofTypes.DataIntegrityProof,
83
83
  cryptosuite: DidCryptoSuites.EdDSAJcs2022,
84
84
  created: new Date(Date.now()).toISOString(),
@@ -89,7 +89,7 @@ export class ProofHelper {
89
89
  }
90
90
  else if (proofType === ProofTypes.JsonWebSignature2020) {
91
91
  proof = {
92
- "@context": DidContexts.NamespaceSecurityJws2020,
92
+ "@context": DidContexts.ContextSecurityJws2020,
93
93
  type: ProofTypes.JsonWebSignature2020,
94
94
  created: new Date(Date.now()).toISOString(),
95
95
  verificationMethod: verificationMethodId,
@@ -1 +1 @@
1
- {"version":3,"file":"proofHelper.js","sourceRoot":"","sources":["../../../src/utils/proofHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAC;AAC1G,OAAO,EAAE,kCAAkC,EAAE,MAAM,0DAA0D,CAAC;AAE9G;;GAEG;AACH,MAAM,OAAO,WAAW;IACv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C,oBAAoB;gBACrC,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;gBAC3C,kBAAkB,EAAE,oBAAoB;gBACxC,YAAY,EAAE,iBAAiB;gBAC/B,GAAG,WAAW;aACd,CAAC;QACH,CAAC;QACD,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,YAAY,CAAC,WAAW,CAAC,UAAU,EAAE,sBAAsB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidCryptoSuites } from \"../models/didCryptoSuites.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\nimport { ProofTypes } from \"../models/proofTypes.js\";\nimport { DataIntegrityProofSignerVerifier } from \"../signerVerifiers/dataIntegrityProofSignerVerifier.js\";\nimport { JsonWebSignature2020SignerVerifier } from \"../signerVerifiers/jsonWebSignature2020SignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class ProofHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ProofHelper>();\n\n\t/**\n\t * Create a signer verifier.\n\t * @param proofType The type of proof to create.\n\t * @returns The created signer verifier.\n\t * @throws GeneralError if the proof type is not supported.\n\t */\n\tpublic static createSignerVerifier(proofType: ProofTypes): IProofSignerVerifier {\n\t\tGuards.arrayOneOf(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\n\t\tlet signerVerifier: IProofSignerVerifier | undefined;\n\t\tif (proofType === ProofTypes.DataIntegrityProof) {\n\t\t\tsignerVerifier = new DataIntegrityProofSignerVerifier();\n\t\t} else if (proofType === ProofTypes.JsonWebSignature2020) {\n\t\t\tsignerVerifier = new JsonWebSignature2020SignerVerifier();\n\t\t}\n\n\t\tif (Is.empty(signerVerifier)) {\n\t\t\tthrow new GeneralError(ProofHelper.CLASS_NAME, \"unsupportedProofType\", { proofType });\n\t\t}\n\t\treturn signerVerifier;\n\t}\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param proofType The type of proof to create.\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 static async createProof(\n\t\tproofType: ProofTypes,\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IProof,\n\t\tsignKey: IJwk\n\t): Promise<IProof> {\n\t\tGuards.arrayOneOf(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(ProofHelper.CLASS_NAME, nameof(unsignedProof), unsignedProof);\n\t\tGuards.object<IJwk>(ProofHelper.CLASS_NAME, nameof(signKey), signKey);\n\t\treturn ProofHelper.createSignerVerifier(proofType).createProof(\n\t\t\tunsecuredDocument as unknown as IJsonLdNodeObject,\n\t\t\tunsignedProof,\n\t\t\tsignKey\n\t\t);\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 static async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(ProofHelper.CLASS_NAME, nameof(signedProof), signedProof);\n\t\tGuards.stringValue(ProofHelper.CLASS_NAME, nameof(signedProof.type), signedProof.type);\n\t\tGuards.object<IJwk>(ProofHelper.CLASS_NAME, nameof(verifyKey), verifyKey);\n\n\t\tconst signerVerifier = ProofHelper.createSignerVerifier(signedProof.type as ProofTypes);\n\n\t\treturn signerVerifier.verifyProof(securedDocument, signedProof, verifyKey);\n\t}\n\n\t/**\n\t * Create an unsigned proof.\n\t * @param proofType The type of proof to create.\n\t * @param verificationMethodId The verification method id.\n\t * @param otherParams Other parameters for the proof.\n\t * @returns The created proof.\n\t * @throws GeneralError if the proof type is not supported.\n\t */\n\tpublic static createUnsignedProof(\n\t\tproofType: ProofTypes,\n\t\tverificationMethodId: string,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\totherParams?: any\n\t): IProof {\n\t\tlet proof: IProof | undefined;\n\t\tif (proofType === ProofTypes.DataIntegrityProof) {\n\t\t\tproof = {\n\t\t\t\t\"@context\": DidContexts.NamespaceDataIntegrity,\n\t\t\t\ttype: ProofTypes.DataIntegrityProof,\n\t\t\t\tcryptosuite: DidCryptoSuites.EdDSAJcs2022,\n\t\t\t\tcreated: new Date(Date.now()).toISOString(),\n\t\t\t\tverificationMethod: verificationMethodId,\n\t\t\t\tproofPurpose: \"assertionMethod\",\n\t\t\t\t...otherParams\n\t\t\t};\n\t\t} else if (proofType === ProofTypes.JsonWebSignature2020) {\n\t\t\tproof = {\n\t\t\t\t\"@context\": DidContexts.NamespaceSecurityJws2020,\n\t\t\t\ttype: ProofTypes.JsonWebSignature2020,\n\t\t\t\tcreated: new Date(Date.now()).toISOString(),\n\t\t\t\tverificationMethod: verificationMethodId,\n\t\t\t\tproofPurpose: \"assertionMethod\",\n\t\t\t\t...otherParams\n\t\t\t};\n\t\t}\n\t\tif (Is.empty(proof)) {\n\t\t\tthrow new GeneralError(ProofHelper.CLASS_NAME, \"unsupportedProofType\", { proofType });\n\t\t}\n\t\treturn proof;\n\t}\n}\n"]}
1
+ {"version":3,"file":"proofHelper.js","sourceRoot":"","sources":["../../../src/utils/proofHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAC;AAC1G,OAAO,EAAE,kCAAkC,EAAE,MAAM,0DAA0D,CAAC;AAE9G;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB;;OAEG;IACI,MAAM,CAAU,UAAU,iBAAiC;IAElE;;;;;OAKG;IACI,MAAM,CAAC,oBAAoB,CAAC,SAAqB;QACvD,MAAM,CAAC,UAAU,CAChB,WAAW,CAAC,UAAU,eAEtB,SAAS,EACT,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CACzB,CAAC;QAEF,IAAI,cAAgD,CAAC;QACrD,IAAI,SAAS,KAAK,UAAU,CAAC,kBAAkB,EAAE,CAAC;YACjD,cAAc,GAAG,IAAI,gCAAgC,EAAE,CAAC;QACzD,CAAC;aAAM,IAAI,SAAS,KAAK,UAAU,CAAC,oBAAoB,EAAE,CAAC;YAC1D,cAAc,GAAG,IAAI,kCAAkC,EAAE,CAAC;QAC3D,C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0.\nimport { GeneralError, Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidCryptoSuites } from \"../models/didCryptoSuites.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\nimport { ProofTypes } from \"../models/proofTypes.js\";\nimport { DataIntegrityProofSignerVerifier } from \"../signerVerifiers/dataIntegrityProofSignerVerifier.js\";\nimport { JsonWebSignature2020SignerVerifier } from \"../signerVerifiers/jsonWebSignature2020SignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n */\nexport class ProofHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ProofHelper>();\n\n\t/**\n\t * Create a signer verifier.\n\t * @param proofType The type of proof to create.\n\t * @returns The created signer verifier.\n\t * @throws GeneralError if the proof type is not supported.\n\t */\n\tpublic static createSignerVerifier(proofType: ProofTypes): IProofSignerVerifier {\n\t\tGuards.arrayOneOf(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\n\t\tlet signerVerifier: IProofSignerVerifier | undefined;\n\t\tif (proofType === ProofTypes.DataIntegrityProof) {\n\t\t\tsignerVerifier = new DataIntegrityProofSignerVerifier();\n\t\t} else if (proofType === ProofTypes.JsonWebSignature2020) {\n\t\t\tsignerVerifier = new JsonWebSignature2020SignerVerifier();\n\t\t}\n\n\t\tif (Is.empty(signerVerifier)) {\n\t\t\tthrow new GeneralError(ProofHelper.CLASS_NAME, \"unsupportedProofType\", { proofType });\n\t\t}\n\t\treturn signerVerifier;\n\t}\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param proofType The type of proof to create.\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 static async createProof(\n\t\tproofType: ProofTypes,\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IProof,\n\t\tsignKey: IJwk\n\t): Promise<IProof> {\n\t\tGuards.arrayOneOf(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(ProofHelper.CLASS_NAME, nameof(unsignedProof), unsignedProof);\n\t\tGuards.object<IJwk>(ProofHelper.CLASS_NAME, nameof(signKey), signKey);\n\t\treturn ProofHelper.createSignerVerifier(proofType).createProof(\n\t\t\tunsecuredDocument as unknown as IJsonLdNodeObject,\n\t\t\tunsignedProof,\n\t\t\tsignKey\n\t\t);\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 static async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tProofHelper.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(ProofHelper.CLASS_NAME, nameof(signedProof), signedProof);\n\t\tGuards.stringValue(ProofHelper.CLASS_NAME, nameof(signedProof.type), signedProof.type);\n\t\tGuards.object<IJwk>(ProofHelper.CLASS_NAME, nameof(verifyKey), verifyKey);\n\n\t\tconst signerVerifier = ProofHelper.createSignerVerifier(signedProof.type as ProofTypes);\n\n\t\treturn signerVerifier.verifyProof(securedDocument, signedProof, verifyKey);\n\t}\n\n\t/**\n\t * Create an unsigned proof.\n\t * @param proofType The type of proof to create.\n\t * @param verificationMethodId The verification method id.\n\t * @param otherParams Other parameters for the proof.\n\t * @returns The created proof.\n\t * @throws GeneralError if the proof type is not supported.\n\t */\n\tpublic static createUnsignedProof(\n\t\tproofType: ProofTypes,\n\t\tverificationMethodId: string,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\totherParams?: any\n\t): IProof {\n\t\tlet proof: IProof | undefined;\n\t\tif (proofType === ProofTypes.DataIntegrityProof) {\n\t\t\tproof = {\n\t\t\t\t\"@context\": DidContexts.ContextDataIntegrity,\n\t\t\t\ttype: ProofTypes.DataIntegrityProof,\n\t\t\t\tcryptosuite: DidCryptoSuites.EdDSAJcs2022,\n\t\t\t\tcreated: new Date(Date.now()).toISOString(),\n\t\t\t\tverificationMethod: verificationMethodId,\n\t\t\t\tproofPurpose: \"assertionMethod\",\n\t\t\t\t...otherParams\n\t\t\t};\n\t\t} else if (proofType === ProofTypes.JsonWebSignature2020) {\n\t\t\tproof = {\n\t\t\t\t\"@context\": DidContexts.ContextSecurityJws2020,\n\t\t\t\ttype: ProofTypes.JsonWebSignature2020,\n\t\t\t\tcreated: new Date(Date.now()).toISOString(),\n\t\t\t\tverificationMethod: verificationMethodId,\n\t\t\t\tproofPurpose: \"assertionMethod\",\n\t\t\t\t...otherParams\n\t\t\t};\n\t\t}\n\t\tif (Is.empty(proof)) {\n\t\t\tthrow new GeneralError(ProofHelper.CLASS_NAME, \"unsupportedProofType\", { proofType });\n\t\t}\n\t\treturn proof;\n\t}\n}\n"]}
@@ -10,7 +10,7 @@ export interface IDataIntegrityProof {
10
10
  /**
11
11
  * JSON-LD Context.
12
12
  */
13
- "@context"?: typeof DidContexts.NamespaceDataIntegrity | [typeof DidContexts.NamespaceDataIntegrity, ...IJsonLdContextDefinitionElement[]];
13
+ "@context"?: typeof DidContexts.ContextDataIntegrity | [typeof DidContexts.ContextDataIntegrity, ...IJsonLdContextDefinitionElement[]];
14
14
  /**
15
15
  * JSON-LD Type.
16
16
  */
@@ -10,7 +10,7 @@ export interface IDidDocument {
10
10
  /**
11
11
  * The context for the document.
12
12
  */
13
- "@context": typeof DidContexts.Namespace | [typeof DidContexts.Namespace, ...IJsonLdContextDefinitionElement[]];
13
+ "@context": typeof DidContexts.Context | [typeof DidContexts.Context, ...IJsonLdContextDefinitionElement[]];
14
14
  /**
15
15
  * The id for the document.
16
16
  */
@@ -9,7 +9,7 @@ export interface IDidVerifiableCredentialV1 extends IDidVerifiableCredentialComm
9
9
  /**
10
10
  * The context for the verifiable credential.
11
11
  */
12
- "@context": typeof DidContexts.NamespaceVCv1 | [typeof DidContexts.NamespaceVCv1, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.ContextVCv1 | [typeof DidContexts.ContextVCv1, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * The date the verifiable credential was issued, depending on version validFrom might be set instead.
15
15
  */
@@ -9,7 +9,7 @@ export interface IDidVerifiableCredentialV2 extends IDidVerifiableCredentialComm
9
9
  /**
10
10
  * The context for the verifiable credential.
11
11
  */
12
- "@context": typeof DidContexts.NamespaceVCv2 | [typeof DidContexts.NamespaceVCv2, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.ContextVCv2 | [typeof DidContexts.ContextVCv2, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * The date the verifiable credential is valid from.
15
15
  */
@@ -9,7 +9,7 @@ export interface IDidVerifiablePresentationV1 extends IDidVerifiablePresentation
9
9
  /**
10
10
  * The context for the verifiable presentation.
11
11
  */
12
- "@context": typeof DidContexts.NamespaceVCv1 | [typeof DidContexts.NamespaceVCv1, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.ContextVCv1 | [typeof DidContexts.ContextVCv1, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * The data for the verifiable credentials.
15
15
  */
@@ -9,7 +9,7 @@ export interface IDidVerifiablePresentationV2 extends IDidVerifiablePresentation
9
9
  /**
10
10
  * The context for the verifiable presentation.
11
11
  */
12
- "@context": typeof DidContexts.NamespaceVCv2 | [typeof DidContexts.NamespaceVCv2, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.ContextVCv2 | [typeof DidContexts.ContextVCv2, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * The data for the verifiable credentials.
15
15
  */
@@ -9,7 +9,7 @@ export interface IJsonWebSignature2020Proof {
9
9
  /**
10
10
  * JSON-LD Context.
11
11
  */
12
- "@context"?: typeof DidContexts.NamespaceSecurityJws2020 | [typeof DidContexts.NamespaceSecurityJws2020, ...IJsonLdContextDefinitionElement[]];
12
+ "@context"?: typeof DidContexts.ContextSecurityJws2020 | [typeof DidContexts.ContextSecurityJws2020, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * JSON-LD Type.
15
15
  */
@@ -9,7 +9,7 @@ export interface IMultikey {
9
9
  /**
10
10
  * JSON-LD Context.
11
11
  */
12
- "@context"?: typeof DidContexts.NamespaceControllerIdentifiers | typeof DidContexts.NamespaceSecurityMultikey | [typeof DidContexts.NamespaceControllerIdentifiers, ...IJsonLdContextDefinitionElement[]] | [typeof DidContexts.NamespaceSecurityMultikey, ...IJsonLdContextDefinitionElement[]];
12
+ "@context"?: typeof DidContexts.ContextControllerIdentifiers | typeof DidContexts.ContextSecurityMultikey | [typeof DidContexts.ContextControllerIdentifiers, ...IJsonLdContextDefinitionElement[]] | [typeof DidContexts.ContextSecurityMultikey, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * The id of the entry.
15
15
  */
@@ -3,37 +3,85 @@
3
3
  */
4
4
  export declare const DidContexts: {
5
5
  /**
6
- * The context root for DID.
6
+ * The canonical RDF namespace URI for DID.
7
7
  */
8
8
  readonly Namespace: "https://www.w3.org/ns/did/v1";
9
9
  /**
10
- * The context root for DID VC v1.
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.
13
+ */
14
+ readonly Context: "https://www.w3.org/ns/did/v1";
15
+ /**
16
+ * The canonical RDF namespace URI for DID VC v1.
11
17
  */
12
18
  readonly NamespaceVCv1: "https://www.w3.org/2018/credentials/v1";
13
19
  /**
14
- * The context root for DID VC v2.
20
+ * The value to use in JSON-LD context for DID VC v1.
21
+ * Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.
22
+ * The W3C VC v1 JSON-LD context URL format does not include a trailing slash.
23
+ */
24
+ readonly ContextVCv1: "https://www.w3.org/2018/credentials/v1";
25
+ /**
26
+ * The canonical RDF namespace URI for DID VC v2.
15
27
  */
16
28
  readonly NamespaceVCv2: "https://www.w3.org/ns/credentials/v2";
17
29
  /**
18
- * The context root for security ed25519 suites.
30
+ * The value to use in JSON-LD context for DID VC v2.
31
+ * Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.
32
+ * The W3C VC v2 JSON-LD context URL format does not include a trailing slash.
33
+ */
34
+ readonly ContextVCv2: "https://www.w3.org/ns/credentials/v2";
35
+ /**
36
+ * The canonical RDF namespace URI for security ed25519 suites.
19
37
  */
20
38
  readonly NamespaceSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1";
21
39
  /**
22
- * The context root for security jws-2020 suites.
40
+ * The value to use in JSON-LD context for security ed25519 suites.
41
+ * Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.
42
+ * The ed25519-2020 JSON-LD context URL format does not include a trailing slash.
43
+ */
44
+ readonly ContextSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1";
45
+ /**
46
+ * The canonical RDF namespace URI for security jws-2020 suites.
23
47
  */
24
48
  readonly NamespaceSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1";
25
49
  /**
26
- * The context root for VC Data Integrity.
50
+ * The value to use in JSON-LD context for security jws-2020 suites.
51
+ * Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.
52
+ * The jws-2020 JSON-LD context URL format does not include a trailing slash.
53
+ */
54
+ readonly ContextSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1";
55
+ /**
56
+ * The canonical RDF namespace URI for VC Data Integrity.
27
57
  */
28
58
  readonly NamespaceDataIntegrity: "https://www.w3.org/ns/credentials/v2";
29
59
  /**
30
- * The context root for VC Data Integrity.
60
+ * The value to use in JSON-LD context for VC Data Integrity.
61
+ * Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.
62
+ * The Data Integrity JSON-LD context URL format does not include a trailing slash.
63
+ */
64
+ readonly ContextDataIntegrity: "https://www.w3.org/ns/credentials/v2";
65
+ /**
66
+ * The canonical RDF namespace URI for controller identifiers.
31
67
  */
32
68
  readonly NamespaceControllerIdentifiers: "https://www.w3.org/ns/cid/v1";
33
69
  /**
34
- * The context root for security multikey suites.
70
+ * The value to use in JSON-LD context for controller identifiers.
71
+ * Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.
72
+ * The Controller Identifiers JSON-LD context URL format does not include a trailing slash.
73
+ */
74
+ readonly ContextControllerIdentifiers: "https://www.w3.org/ns/cid/v1";
75
+ /**
76
+ * The canonical RDF namespace URI for security multikey suites.
35
77
  */
36
78
  readonly NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1";
79
+ /**
80
+ * The value to use in JSON-LD context for security multikey suites.
81
+ * Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.
82
+ * The multikey JSON-LD context URL format does not include a trailing slash.
83
+ */
84
+ readonly ContextSecurityMultikey: "https://w3id.org/security/multikey/v1";
37
85
  };
38
86
  /**
39
87
  * The contexts for DIDs.
package/docs/changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @twin.org/standards-w3c-did - Changelog
2
2
 
3
+ ## [0.0.3-next.17](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.3-next.16...standards-w3c-did-v0.0.3-next.17) (2026-01-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * updating the missing packages ([#114](https://github.com/twinfoundation/standards/issues/114)) ([90b03f8](https://github.com/twinfoundation/standards/commit/90b03f8bdcd81506284d74a445840386c2da2d35))
9
+
3
10
  ## [0.0.3-next.16](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.3-next.15...standards-w3c-did-v0.0.3-next.16) (2026-01-19)
4
11
 
5
12
 
@@ -10,46 +10,110 @@ The contexts for DIDs.
10
10
 
11
11
  > `readonly` **Namespace**: `"https://www.w3.org/ns/did/v1"` = `"https://www.w3.org/ns/did/v1"`
12
12
 
13
- The context root for DID.
13
+ The canonical RDF namespace URI for DID.
14
+
15
+ ### Context
16
+
17
+ > `readonly` **Context**: `"https://www.w3.org/ns/did/v1"` = `"https://www.w3.org/ns/did/v1"`
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.
14
22
 
15
23
  ### NamespaceVCv1
16
24
 
17
25
  > `readonly` **NamespaceVCv1**: `"https://www.w3.org/2018/credentials/v1"` = `"https://www.w3.org/2018/credentials/v1"`
18
26
 
19
- The context root for DID VC v1.
27
+ The canonical RDF namespace URI for DID VC v1.
28
+
29
+ ### ContextVCv1
30
+
31
+ > `readonly` **ContextVCv1**: `"https://www.w3.org/2018/credentials/v1"` = `"https://www.w3.org/2018/credentials/v1"`
32
+
33
+ The value to use in JSON-LD context for DID VC v1.
34
+ Note: ContextVCv1 matches NamespaceVCv1 (no trailing slash) as per W3C Verifiable Credentials v1 specification.
35
+ The W3C VC v1 JSON-LD context URL format does not include a trailing slash.
20
36
 
21
37
  ### NamespaceVCv2
22
38
 
23
39
  > `readonly` **NamespaceVCv2**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
24
40
 
25
- The context root for DID VC v2.
41
+ The canonical RDF namespace URI for DID VC v2.
42
+
43
+ ### ContextVCv2
44
+
45
+ > `readonly` **ContextVCv2**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
46
+
47
+ The value to use in JSON-LD context for DID VC v2.
48
+ Note: ContextVCv2 matches NamespaceVCv2 (no trailing slash) as per W3C Verifiable Credentials v2 specification.
49
+ The W3C VC v2 JSON-LD context URL format does not include a trailing slash.
26
50
 
27
51
  ### NamespaceSecurityEd25519
28
52
 
29
53
  > `readonly` **NamespaceSecurityEd25519**: `"https://w3id.org/security/suites/ed25519-2020/v1"` = `"https://w3id.org/security/suites/ed25519-2020/v1"`
30
54
 
31
- The context root for security ed25519 suites.
55
+ The canonical RDF namespace URI for security ed25519 suites.
56
+
57
+ ### ContextSecurityEd25519
58
+
59
+ > `readonly` **ContextSecurityEd25519**: `"https://w3id.org/security/suites/ed25519-2020/v1"` = `"https://w3id.org/security/suites/ed25519-2020/v1"`
60
+
61
+ The value to use in JSON-LD context for security ed25519 suites.
62
+ Note: ContextSecurityEd25519 matches NamespaceSecurityEd25519 (no trailing slash) as per W3C Security Suites specification.
63
+ The ed25519-2020 JSON-LD context URL format does not include a trailing slash.
32
64
 
33
65
  ### NamespaceSecurityJws2020
34
66
 
35
67
  > `readonly` **NamespaceSecurityJws2020**: `"https://w3id.org/security/suites/jws-2020/v1"` = `"https://w3id.org/security/suites/jws-2020/v1"`
36
68
 
37
- The context root for security jws-2020 suites.
69
+ The canonical RDF namespace URI for security jws-2020 suites.
70
+
71
+ ### ContextSecurityJws2020
72
+
73
+ > `readonly` **ContextSecurityJws2020**: `"https://w3id.org/security/suites/jws-2020/v1"` = `"https://w3id.org/security/suites/jws-2020/v1"`
74
+
75
+ The value to use in JSON-LD context for security jws-2020 suites.
76
+ Note: ContextSecurityJws2020 matches NamespaceSecurityJws2020 (no trailing slash) as per W3C Security Suites specification.
77
+ The jws-2020 JSON-LD context URL format does not include a trailing slash.
38
78
 
39
79
  ### NamespaceDataIntegrity
40
80
 
41
81
  > `readonly` **NamespaceDataIntegrity**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
42
82
 
43
- The context root for VC Data Integrity.
83
+ The canonical RDF namespace URI for VC Data Integrity.
84
+
85
+ ### ContextDataIntegrity
86
+
87
+ > `readonly` **ContextDataIntegrity**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
88
+
89
+ The value to use in JSON-LD context for VC Data Integrity.
90
+ Note: ContextDataIntegrity matches NamespaceDataIntegrity (no trailing slash) as per W3C Data Integrity specification.
91
+ The Data Integrity JSON-LD context URL format does not include a trailing slash.
44
92
 
45
93
  ### NamespaceControllerIdentifiers
46
94
 
47
95
  > `readonly` **NamespaceControllerIdentifiers**: `"https://www.w3.org/ns/cid/v1"` = `"https://www.w3.org/ns/cid/v1"`
48
96
 
49
- The context root for VC Data Integrity.
97
+ The canonical RDF namespace URI for controller identifiers.
98
+
99
+ ### ContextControllerIdentifiers
100
+
101
+ > `readonly` **ContextControllerIdentifiers**: `"https://www.w3.org/ns/cid/v1"` = `"https://www.w3.org/ns/cid/v1"`
102
+
103
+ The value to use in JSON-LD context for controller identifiers.
104
+ Note: ContextControllerIdentifiers matches NamespaceControllerIdentifiers (no trailing slash) as per W3C Controller Identifiers specification.
105
+ The Controller Identifiers JSON-LD context URL format does not include a trailing slash.
50
106
 
51
107
  ### NamespaceSecurityMultikey
52
108
 
53
109
  > `readonly` **NamespaceSecurityMultikey**: `"https://w3id.org/security/multikey/v1"` = `"https://w3id.org/security/multikey/v1"`
54
110
 
55
- The context root for security multikey suites.
111
+ The canonical RDF namespace URI for security multikey suites.
112
+
113
+ ### ContextSecurityMultikey
114
+
115
+ > `readonly` **ContextSecurityMultikey**: `"https://w3id.org/security/multikey/v1"` = `"https://w3id.org/security/multikey/v1"`
116
+
117
+ The value to use in JSON-LD context for security multikey suites.
118
+ Note: ContextSecurityMultikey matches NamespaceSecurityMultikey (no trailing slash) as per W3C Security Suites specification.
119
+ The multikey JSON-LD context URL format does not include a trailing slash.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/standards-w3c-did",
3
- "version": "0.0.3-next.16",
3
+ "version": "0.0.3-next.17",
4
4
  "description": "Models which define the structure of W3C DID Standard",
5
5
  "repository": {
6
6
  "type": "git",