@twin.org/standards-w3c-did 0.0.3-next.10 → 0.0.3-next.11

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 +8 -8
  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 +8 -8
  28. package/docs/changelog.md +7 -0
  29. package/docs/reference/variables/DidContexts.md +16 -16
  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.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
+ {"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 +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.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
+ {"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 +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.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
+ {"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 +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.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
+ {"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 +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.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
+ {"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 +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.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
+ {"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 +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.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
+ {"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 +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.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"]}
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"]}
@@ -8,34 +8,34 @@ export const DidContexts = {
8
8
  /**
9
9
  * The context root for DID.
10
10
  */
11
- Context: "https://www.w3.org/ns/did/v1",
11
+ Namespace: "https://www.w3.org/ns/did/v1",
12
12
  /**
13
13
  * The context root for DID VC v1.
14
14
  */
15
- ContextVCv1: "https://www.w3.org/2018/credentials/v1",
15
+ NamespaceVCv1: "https://www.w3.org/2018/credentials/v1",
16
16
  /**
17
17
  * The context root for DID VC v2.
18
18
  */
19
- ContextVCv2: "https://www.w3.org/ns/credentials/v2",
19
+ NamespaceVCv2: "https://www.w3.org/ns/credentials/v2",
20
20
  /**
21
21
  * The context root for security ed25519 suites.
22
22
  */
23
- ContextSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1",
23
+ NamespaceSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1",
24
24
  /**
25
25
  * The context root for security jws-2020 suites.
26
26
  */
27
- ContextSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1",
27
+ NamespaceSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1",
28
28
  /**
29
29
  * The context root for VC Data Integrity.
30
30
  */
31
- ContextDataIntegrity: "https://www.w3.org/ns/credentials/v2",
31
+ NamespaceDataIntegrity: "https://www.w3.org/ns/credentials/v2",
32
32
  /**
33
33
  * The context root for VC Data Integrity.
34
34
  */
35
- ContextControllerIdentifiers: "https://www.w3.org/ns/cid/v1",
35
+ NamespaceControllerIdentifiers: "https://www.w3.org/ns/cid/v1",
36
36
  /**
37
37
  * The context root for security multikey suites.
38
38
  */
39
- ContextSecurityMultikey: "https://w3id.org/security/multikey/v1"
39
+ NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1"
40
40
  };
41
41
  //# 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,OAAO,EAAE,8BAA8B;IAEvC;;OAEG;IACH,WAAW,EAAE,wCAAwC;IAErD;;OAEG;IACH,WAAW,EAAE,sCAAsC;IAEnD;;OAEG;IACH,sBAAsB,EAAE,kDAAkD;IAE1E;;OAEG;IACH,sBAAsB,EAAE,8CAA8C;IAEtE;;OAEG;IACH,oBAAoB,EAAE,sCAAsC;IAE5D;;OAEG;IACH,4BAA4B,EAAE,8BAA8B;IAE5D;;OAEG;IACH,uBAAuB,EAAE,uCAAuC;CACvD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The contexts for DIDs.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const DidContexts = {\n\t/**\n\t * The context root for DID.\n\t */\n\tContext: \"https://www.w3.org/ns/did/v1\",\n\n\t/**\n\t * The context root for DID VC v1.\n\t */\n\tContextVCv1: \"https://www.w3.org/2018/credentials/v1\",\n\n\t/**\n\t * The context root for DID VC v2.\n\t */\n\tContextVCv2: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The context root for security ed25519 suites.\n\t */\n\tContextSecurityEd25519: \"https://w3id.org/security/suites/ed25519-2020/v1\",\n\n\t/**\n\t * The context root for security jws-2020 suites.\n\t */\n\tContextSecurityJws2020: \"https://w3id.org/security/suites/jws-2020/v1\",\n\n\t/**\n\t * The context root for VC Data Integrity.\n\t */\n\tContextDataIntegrity: \"https://www.w3.org/ns/credentials/v2\",\n\n\t/**\n\t * The context root for VC Data Integrity.\n\t */\n\tContextControllerIdentifiers: \"https://www.w3.org/ns/cid/v1\",\n\n\t/**\n\t * The context root for security multikey suites.\n\t */\n\tContextSecurityMultikey: \"https://w3id.org/security/multikey/v1\"\n} as const;\n\n/**\n * The contexts for DIDs.\n */\nexport type DidContexts = (typeof DidContexts)[keyof typeof DidContexts];\n"]}
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"]}
@@ -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.ContextDataIntegrity);
35
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceDataIntegrity);
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.ContextDataIntegrity);
81
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceDataIntegrity);
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,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,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAC7E,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tObjectHelper,\n\tUint8ArrayHelper\n} from \"@twin.org/core\";\nimport { Ed25519, Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Jwk, type IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidCryptoSuites } from \"../models/didCryptoSuites.js\";\nimport type { IDataIntegrityProof } from \"../models/IDataIntegrityProof.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022\n */\nexport class DataIntegrityProofSignerVerifier implements IProofSignerVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataIntegrityProofSignerVerifier>();\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signKey The key to sign the proof with.\n\t * @returns The created proof.\n\t */\n\tpublic async createProof(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof,\n\t\tsignKey: IJwk\n\t): Promise<IProof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(signKey), signKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(signKey);\n\t\tif (!Is.uint8Array(rawKeys.privateKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPrivateKey\");\n\t\t}\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\"@context\"] as IDataIntegrityProof[\"@context\"];\n\n\t\tconst combinedHash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\tconst signature = Ed25519.sign(rawKeys.privateKey, combinedHash);\n\n\t\tsignedProof.proofValue = `z${Converter.bytesToBase58(signature)}`;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data in format.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IDataIntegrityProof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IDataIntegrityProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof),\n\t\t\tsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof.proofValue),\n\t\t\tsignedProof.proofValue\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(verifyKey), verifyKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(verifyKey);\n\t\tif (!Is.uint8Array(rawKeys.publicKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPublicKey\");\n\t\t}\n\n\t\tconst combinedHash = await this.createHash(securedDocument, signedProof);\n\n\t\treturn Ed25519.verify(\n\t\t\trawKeys.publicKey,\n\t\t\tcombinedHash,\n\t\t\tConverter.base58ToBytes(signedProof.proofValue.slice(1))\n\t\t);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof\n\t): Promise<Uint8Array> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IDataIntegrityProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.cryptosuite),\n\t\t\tunsignedProof.cryptosuite\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.verificationMethod),\n\t\t\tunsignedProof.verificationMethod\n\t\t);\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\t\tconst proofOptionsClone = ObjectHelper.clone(unsignedProof);\n\n\t\tdelete unsecuredDocumentClone.proof;\n\t\tdelete proofOptionsClone.proofValue;\n\n\t\tif (proofOptionsClone.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\t\t\"cryptosuiteNotSupported\",\n\t\t\t\t{\n\t\t\t\t\tcryptoSuite: proofOptionsClone.cryptosuite\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextDataIntegrity\n\t\t);\n\n\t\tproofOptionsClone[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IDataIntegrityProof[\"@context\"];\n\n\t\tconst transformedDocument = JsonHelper.canonicalize(unsecuredDocumentClone);\n\n\t\tconst transformedDocumentHash = Sha256.sum256(Converter.utf8ToBytes(transformedDocument));\n\n\t\tconst transformedProofOptions = JsonHelper.canonicalize(proofOptionsClone);\n\n\t\tconst proofOptionsHash = Sha256.sum256(Converter.utf8ToBytes(transformedProofOptions));\n\n\t\treturn Uint8ArrayHelper.concat([proofOptionsHash, transformedDocumentHash]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataIntegrityProofSignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/dataIntegrityProofSignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,GAAG,EAAa,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;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Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tObjectHelper,\n\tUint8ArrayHelper\n} from \"@twin.org/core\";\nimport { Ed25519, Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Jwk, type IJwk } from \"@twin.org/web\";\nimport { DidContexts } from \"../models/didContexts.js\";\nimport { DidCryptoSuites } from \"../models/didCryptoSuites.js\";\nimport type { IDataIntegrityProof } from \"../models/IDataIntegrityProof.js\";\nimport type { IProof } from \"../models/IProof.js\";\nimport type { IProofSignerVerifier } from \"../models/IProofSignerVerifier.js\";\n\n/**\n * Helper methods for creating and verifying proofs.\n * https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022\n */\nexport class DataIntegrityProofSignerVerifier implements IProofSignerVerifier {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataIntegrityProofSignerVerifier>();\n\n\t/**\n\t * Create a proof for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The proof options.\n\t * @param signKey The key to sign the proof with.\n\t * @returns The created proof.\n\t */\n\tpublic async createProof(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IDataIntegrityProof,\n\t\tsignKey: IJwk\n\t): Promise<IProof> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IProof>(\n\t\t\tDataIntegrityProofSignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(DataIntegrityProofSignerVerifier.CLASS_NAME, nameof(signKey), signKey);\n\n\t\tconst rawKeys = await Jwk.toRaw(signKey);\n\t\tif (!Is.uint8Array(rawKeys.privateKey)) {\n\t\t\tthrow new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, \"missingPrivateKey\");\n\t\t}\n\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.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"]}
@@ -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.ContextSecurityJws2020);
28
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceSecurityJws2020);
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.ContextSecurityJws2020);
68
+ unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.NamespaceSecurityJws2020);
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,C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AC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;QACzE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,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.ContextSecurityJws2020\n\t\t);\n\n\t\tconst hash = await this.createHash(unsecuredDocument, unsignedProof);\n\n\t\tconst cryptoKey = await Jwk.toCryptoKey(signKey);\n\n\t\tconst signature = await Jws.create(cryptoKey, hash, signKey.alg);\n\n\t\tconst signedProof = ObjectHelper.clone(unsignedProof);\n\n\t\tsignedProof[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tsignedProof.jws = signature;\n\n\t\treturn signedProof;\n\t}\n\n\t/**\n\t * Verify a proof for the given data in format.\n\t * @param securedDocument The credential to verify.\n\t * @param signedProof The proof to verify.\n\t * @param verifyKey The public key to verify the proof with.\n\t * @returns True if the credential was verified.\n\t */\n\tpublic async verifyProof(\n\t\tsecuredDocument: IJsonLdNodeObject,\n\t\tsignedProof: IJsonWebSignature2020Proof,\n\t\tverifyKey: IJwk\n\t): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(securedDocument),\n\t\t\tsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(signedProof),\n\t\t\tsignedProof\n\t\t);\n\t\tGuards.object<IJwk>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(verifyKey),\n\t\t\tverifyKey\n\t\t);\n\t\tconst jws = signedProof.jws;\n\t\tif (!Is.stringValue(jws)) {\n\t\t\tthrow new GeneralError(JsonWebSignature2020SignerVerifier.CLASS_NAME, \"missingJws\");\n\t\t}\n\n\t\tconst hash = await this.createHash(securedDocument, signedProof);\n\n\t\tconst cryptoKey = await Jwk.toCryptoKey(verifyKey);\n\n\t\treturn Jws.verify(jws, cryptoKey, hash);\n\t}\n\n\t/**\n\t * Create a hash for the given data.\n\t * @param unsecuredDocument The data to create the proof for.\n\t * @param unsignedProof The unsigned proof.\n\t * @returns The created hash.\n\t */\n\tpublic async createHash(\n\t\tunsecuredDocument: IJsonLdNodeObject,\n\t\tunsignedProof: IJsonWebSignature2020Proof\n\t): Promise<Uint8Array> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsecuredDocument),\n\t\t\tunsecuredDocument\n\t\t);\n\t\tGuards.object<IJsonWebSignature2020Proof>(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof),\n\t\t\tunsignedProof\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tJsonWebSignature2020SignerVerifier.CLASS_NAME,\n\t\t\tnameof(unsignedProof.verificationMethod),\n\t\t\tunsignedProof.verificationMethod\n\t\t);\n\t\tconst unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);\n\t\tconst proofOptionsClone = ObjectHelper.clone(unsignedProof);\n\n\t\tunsecuredDocumentClone[\"@context\"] = JsonLdProcessor.combineContexts(\n\t\t\tunsecuredDocumentClone[\"@context\"],\n\t\t\tDidContexts.ContextSecurityJws2020\n\t\t);\n\n\t\tproofOptionsClone[\"@context\"] = unsecuredDocumentClone[\n\t\t\t\"@context\"\n\t\t] as IJsonWebSignature2020Proof[\"@context\"];\n\n\t\tdelete unsecuredDocumentClone.proof;\n\t\tdelete proofOptionsClone.jws;\n\n\t\tconst canonizedData: string = await JsonLdProcessor.canonize(unsecuredDocumentClone);\n\t\tconst canonizedProof: string = await JsonLdProcessor.canonize(\n\t\t\tproofOptionsClone as unknown as IJsonLdNodeObject\n\t\t);\n\n\t\tconst hashedProof = Sha256.sum256(Converter.utf8ToBytes(canonizedProof));\n\t\tconst hashedData = Sha256.sum256(Converter.utf8ToBytes(canonizedData));\n\n\t\treturn Uint8ArrayHelper.concat([hashedProof, hashedData]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonWebSignature2020SignerVerifier.js","sourceRoot":"","sources":["../../../src/signerVerifiers/jsonWebSignature2020SignerVerifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAa,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD;;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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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"]}
@@ -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.ContextControllerIdentifiers,
56
+ "@context": DidContexts.NamespaceControllerIdentifiers,
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,CAA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.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"]}
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,OA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AC;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"]}
@@ -78,7 +78,7 @@ export class ProofHelper {
78
78
  let proof;
79
79
  if (proofType === ProofTypes.DataIntegrityProof) {
80
80
  proof = {
81
- "@context": DidContexts.ContextDataIntegrity,
81
+ "@context": DidContexts.NamespaceDataIntegrity,
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.ContextSecurityJws2020,
92
+ "@context": DidContexts.NamespaceSecurityJws2020,
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,EA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I,SAAS,KAAK,UAAU,CAAC,oBAAoB,EAAE,CAAC;YAC1D,KAAK,GAAG;gBACP,UAAU,EAAE,WAAW,CAAC,sBAAsB;gBAC9C,IAAI,EAAE,UAAU,CAAC,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.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"]}
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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,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"]}
@@ -10,7 +10,7 @@ export interface IDataIntegrityProof {
10
10
  /**
11
11
  * JSON-LD Context.
12
12
  */
13
- "@context"?: typeof DidContexts.ContextDataIntegrity | [typeof DidContexts.ContextDataIntegrity, ...IJsonLdContextDefinitionElement[]];
13
+ "@context"?: typeof DidContexts.NamespaceDataIntegrity | [typeof DidContexts.NamespaceDataIntegrity, ...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.Context | [typeof DidContexts.Context, ...IJsonLdContextDefinitionElement[]];
13
+ "@context": typeof DidContexts.Namespace | [typeof DidContexts.Namespace, ...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.ContextVCv1 | [typeof DidContexts.ContextVCv1, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.NamespaceVCv1 | [typeof DidContexts.NamespaceVCv1, ...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.ContextVCv2 | [typeof DidContexts.ContextVCv2, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.NamespaceVCv2 | [typeof DidContexts.NamespaceVCv2, ...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.ContextVCv1 | [typeof DidContexts.ContextVCv1, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.NamespaceVCv1 | [typeof DidContexts.NamespaceVCv1, ...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.ContextVCv2 | [typeof DidContexts.ContextVCv2, ...IJsonLdContextDefinitionElement[]];
12
+ "@context": typeof DidContexts.NamespaceVCv2 | [typeof DidContexts.NamespaceVCv2, ...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.ContextSecurityJws2020 | [typeof DidContexts.ContextSecurityJws2020, ...IJsonLdContextDefinitionElement[]];
12
+ "@context"?: typeof DidContexts.NamespaceSecurityJws2020 | [typeof DidContexts.NamespaceSecurityJws2020, ...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.ContextControllerIdentifiers | typeof DidContexts.ContextSecurityMultikey | [typeof DidContexts.ContextControllerIdentifiers, ...IJsonLdContextDefinitionElement[]] | [typeof DidContexts.ContextSecurityMultikey, ...IJsonLdContextDefinitionElement[]];
12
+ "@context"?: typeof DidContexts.NamespaceControllerIdentifiers | typeof DidContexts.NamespaceSecurityMultikey | [typeof DidContexts.NamespaceControllerIdentifiers, ...IJsonLdContextDefinitionElement[]] | [typeof DidContexts.NamespaceSecurityMultikey, ...IJsonLdContextDefinitionElement[]];
13
13
  /**
14
14
  * The id of the entry.
15
15
  */
@@ -5,35 +5,35 @@ export declare const DidContexts: {
5
5
  /**
6
6
  * The context root for DID.
7
7
  */
8
- readonly Context: "https://www.w3.org/ns/did/v1";
8
+ readonly Namespace: "https://www.w3.org/ns/did/v1";
9
9
  /**
10
10
  * The context root for DID VC v1.
11
11
  */
12
- readonly ContextVCv1: "https://www.w3.org/2018/credentials/v1";
12
+ readonly NamespaceVCv1: "https://www.w3.org/2018/credentials/v1";
13
13
  /**
14
14
  * The context root for DID VC v2.
15
15
  */
16
- readonly ContextVCv2: "https://www.w3.org/ns/credentials/v2";
16
+ readonly NamespaceVCv2: "https://www.w3.org/ns/credentials/v2";
17
17
  /**
18
18
  * The context root for security ed25519 suites.
19
19
  */
20
- readonly ContextSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1";
20
+ readonly NamespaceSecurityEd25519: "https://w3id.org/security/suites/ed25519-2020/v1";
21
21
  /**
22
22
  * The context root for security jws-2020 suites.
23
23
  */
24
- readonly ContextSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1";
24
+ readonly NamespaceSecurityJws2020: "https://w3id.org/security/suites/jws-2020/v1";
25
25
  /**
26
26
  * The context root for VC Data Integrity.
27
27
  */
28
- readonly ContextDataIntegrity: "https://www.w3.org/ns/credentials/v2";
28
+ readonly NamespaceDataIntegrity: "https://www.w3.org/ns/credentials/v2";
29
29
  /**
30
30
  * The context root for VC Data Integrity.
31
31
  */
32
- readonly ContextControllerIdentifiers: "https://www.w3.org/ns/cid/v1";
32
+ readonly NamespaceControllerIdentifiers: "https://www.w3.org/ns/cid/v1";
33
33
  /**
34
34
  * The context root for security multikey suites.
35
35
  */
36
- readonly ContextSecurityMultikey: "https://w3id.org/security/multikey/v1";
36
+ readonly NamespaceSecurityMultikey: "https://w3id.org/security/multikey/v1";
37
37
  };
38
38
  /**
39
39
  * 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.11](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.3-next.10...standards-w3c-did-v0.0.3-next.11) (2026-01-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * improved namespaces and contexts ([#102](https://github.com/twinfoundation/standards/issues/102)) ([c74c370](https://github.com/twinfoundation/standards/commit/c74c370cd8145d6166ca4454353f3774c302ac3b))
9
+
3
10
  ## [0.0.3-next.10](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.3-next.9...standards-w3c-did-v0.0.3-next.10) (2026-01-13)
4
11
 
5
12
 
@@ -6,50 +6,50 @@ The contexts for DIDs.
6
6
 
7
7
  ## Type Declaration
8
8
 
9
- ### Context
9
+ ### Namespace
10
10
 
11
- > `readonly` **Context**: `"https://www.w3.org/ns/did/v1"` = `"https://www.w3.org/ns/did/v1"`
11
+ > `readonly` **Namespace**: `"https://www.w3.org/ns/did/v1"` = `"https://www.w3.org/ns/did/v1"`
12
12
 
13
13
  The context root for DID.
14
14
 
15
- ### ContextVCv1
15
+ ### NamespaceVCv1
16
16
 
17
- > `readonly` **ContextVCv1**: `"https://www.w3.org/2018/credentials/v1"` = `"https://www.w3.org/2018/credentials/v1"`
17
+ > `readonly` **NamespaceVCv1**: `"https://www.w3.org/2018/credentials/v1"` = `"https://www.w3.org/2018/credentials/v1"`
18
18
 
19
19
  The context root for DID VC v1.
20
20
 
21
- ### ContextVCv2
21
+ ### NamespaceVCv2
22
22
 
23
- > `readonly` **ContextVCv2**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
23
+ > `readonly` **NamespaceVCv2**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
24
24
 
25
25
  The context root for DID VC v2.
26
26
 
27
- ### ContextSecurityEd25519
27
+ ### NamespaceSecurityEd25519
28
28
 
29
- > `readonly` **ContextSecurityEd25519**: `"https://w3id.org/security/suites/ed25519-2020/v1"` = `"https://w3id.org/security/suites/ed25519-2020/v1"`
29
+ > `readonly` **NamespaceSecurityEd25519**: `"https://w3id.org/security/suites/ed25519-2020/v1"` = `"https://w3id.org/security/suites/ed25519-2020/v1"`
30
30
 
31
31
  The context root for security ed25519 suites.
32
32
 
33
- ### ContextSecurityJws2020
33
+ ### NamespaceSecurityJws2020
34
34
 
35
- > `readonly` **ContextSecurityJws2020**: `"https://w3id.org/security/suites/jws-2020/v1"` = `"https://w3id.org/security/suites/jws-2020/v1"`
35
+ > `readonly` **NamespaceSecurityJws2020**: `"https://w3id.org/security/suites/jws-2020/v1"` = `"https://w3id.org/security/suites/jws-2020/v1"`
36
36
 
37
37
  The context root for security jws-2020 suites.
38
38
 
39
- ### ContextDataIntegrity
39
+ ### NamespaceDataIntegrity
40
40
 
41
- > `readonly` **ContextDataIntegrity**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
41
+ > `readonly` **NamespaceDataIntegrity**: `"https://www.w3.org/ns/credentials/v2"` = `"https://www.w3.org/ns/credentials/v2"`
42
42
 
43
43
  The context root for VC Data Integrity.
44
44
 
45
- ### ContextControllerIdentifiers
45
+ ### NamespaceControllerIdentifiers
46
46
 
47
- > `readonly` **ContextControllerIdentifiers**: `"https://www.w3.org/ns/cid/v1"` = `"https://www.w3.org/ns/cid/v1"`
47
+ > `readonly` **NamespaceControllerIdentifiers**: `"https://www.w3.org/ns/cid/v1"` = `"https://www.w3.org/ns/cid/v1"`
48
48
 
49
49
  The context root for VC Data Integrity.
50
50
 
51
- ### ContextSecurityMultikey
51
+ ### NamespaceSecurityMultikey
52
52
 
53
- > `readonly` **ContextSecurityMultikey**: `"https://w3id.org/security/multikey/v1"` = `"https://w3id.org/security/multikey/v1"`
53
+ > `readonly` **NamespaceSecurityMultikey**: `"https://w3id.org/security/multikey/v1"` = `"https://w3id.org/security/multikey/v1"`
54
54
 
55
55
  The context root for security multikey suites.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/standards-w3c-did",
3
- "version": "0.0.3-next.10",
3
+ "version": "0.0.3-next.11",
4
4
  "description": "Models which define the structure of W3C DID Standard",
5
5
  "repository": {
6
6
  "type": "git",