@twin.org/standards-w3c-did 0.0.1-next.25 → 0.0.1-next.26

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 (36) hide show
  1. package/dist/cjs/index.cjs +381 -6
  2. package/dist/esm/index.mjs +377 -7
  3. package/dist/types/index.d.ts +9 -1
  4. package/dist/types/models/{IDidProof.d.ts → IDataIntegrityProof.d.ts} +6 -6
  5. package/dist/types/models/IDidDocumentVerificationMethod.d.ts +3 -2
  6. package/dist/types/models/IDidVerifiableCredential.d.ts +4 -3
  7. package/dist/types/models/IDidVerifiablePresentation.d.ts +3 -2
  8. package/dist/types/models/IJsonWebSignature2020Proof.d.ts +33 -0
  9. package/dist/types/models/IMultikey.d.ts +41 -0
  10. package/dist/types/models/IProofSignerVerifier.d.ts +30 -0
  11. package/dist/types/models/didContexts.d.ts +9 -1
  12. package/dist/types/models/didTypes.d.ts +4 -4
  13. package/dist/types/models/proofTypes.d.ts +17 -0
  14. package/dist/types/signerVerifiers/dataIntegrityProofSignerVerifier.d.ts +36 -0
  15. package/dist/types/signerVerifiers/jsonWebSignature2020SignerVerifier.d.ts +35 -0
  16. package/dist/types/utils/multikeyHelper.d.ts +37 -0
  17. package/dist/types/utils/proofHelper.d.ts +41 -0
  18. package/docs/changelog.md +1 -1
  19. package/docs/reference/classes/DataIntegrityProofSignerVerifier.md +134 -0
  20. package/docs/reference/classes/JsonWebSignature2020SignerVerifier.md +133 -0
  21. package/docs/reference/classes/MultikeyHelper.md +119 -0
  22. package/docs/reference/classes/ProofHelper.md +121 -0
  23. package/docs/reference/index.md +13 -1
  24. package/docs/reference/interfaces/{IDidProof.md → IDataIntegrityProof.md} +17 -5
  25. package/docs/reference/interfaces/IDidDocumentVerificationMethod.md +9 -1
  26. package/docs/reference/interfaces/IDidVerifiableCredential.md +2 -2
  27. package/docs/reference/interfaces/IDidVerifiablePresentation.md +1 -1
  28. package/docs/reference/interfaces/IJsonWebSignature2020Proof.md +52 -0
  29. package/docs/reference/interfaces/IMultikey.md +68 -0
  30. package/docs/reference/interfaces/IProofSignerVerifier.md +99 -0
  31. package/docs/reference/type-aliases/ProofTypes.md +5 -0
  32. package/docs/reference/variables/DidContexts.md +14 -2
  33. package/docs/reference/variables/DidTypes.md +6 -6
  34. package/docs/reference/variables/ProofTypes.md +19 -0
  35. package/locales/en.json +27 -1
  36. package/package.json +4 -1
@@ -1,16 +1,26 @@
1
1
  # @twin.org/standards-w3c-did
2
2
 
3
+ ## Classes
4
+
5
+ - [DataIntegrityProofSignerVerifier](classes/DataIntegrityProofSignerVerifier.md)
6
+ - [JsonWebSignature2020SignerVerifier](classes/JsonWebSignature2020SignerVerifier.md)
7
+ - [MultikeyHelper](classes/MultikeyHelper.md)
8
+ - [ProofHelper](classes/ProofHelper.md)
9
+
3
10
  ## Interfaces
4
11
 
12
+ - [IDataIntegrityProof](interfaces/IDataIntegrityProof.md)
5
13
  - [IDidCredentialSchema](interfaces/IDidCredentialSchema.md)
6
14
  - [IDidCredentialStatus](interfaces/IDidCredentialStatus.md)
7
15
  - [IDidDocument](interfaces/IDidDocument.md)
8
16
  - [IDidDocumentVerificationMethod](interfaces/IDidDocumentVerificationMethod.md)
9
17
  - [IDidPresentationVerification](interfaces/IDidPresentationVerification.md)
10
- - [IDidProof](interfaces/IDidProof.md)
11
18
  - [IDidService](interfaces/IDidService.md)
12
19
  - [IDidVerifiableCredential](interfaces/IDidVerifiableCredential.md)
13
20
  - [IDidVerifiablePresentation](interfaces/IDidVerifiablePresentation.md)
21
+ - [IJsonWebSignature2020Proof](interfaces/IJsonWebSignature2020Proof.md)
22
+ - [IMultikey](interfaces/IMultikey.md)
23
+ - [IProofSignerVerifier](interfaces/IProofSignerVerifier.md)
14
24
 
15
25
  ## Type Aliases
16
26
 
@@ -18,6 +28,7 @@
18
28
  - [DidCryptoSuites](type-aliases/DidCryptoSuites.md)
19
29
  - [DidTypes](type-aliases/DidTypes.md)
20
30
  - [DidVerificationMethodType](type-aliases/DidVerificationMethodType.md)
31
+ - [ProofTypes](type-aliases/ProofTypes.md)
21
32
 
22
33
  ## Variables
23
34
 
@@ -25,3 +36,4 @@
25
36
  - [DidCryptoSuites](variables/DidCryptoSuites.md)
26
37
  - [DidTypes](variables/DidTypes.md)
27
38
  - [DidVerificationMethodType](variables/DidVerificationMethodType.md)
39
+ - [ProofTypes](variables/ProofTypes.md)
@@ -1,21 +1,33 @@
1
- # Interface: IDidProof
1
+ # Interface: IDataIntegrityProof
2
2
 
3
3
  Interface describing a did proof.
4
4
  https://www.w3.org/TR/vc-data-integrity/
5
5
 
6
+ ## Extends
7
+
8
+ - `IJsonLdNodeObject`
9
+
10
+ ## Indexable
11
+
12
+ \[`key`: `string`\]: `undefined` \| `null` \| `string` \| `number` \| `boolean` \| `string`[] \| `IJsonLdContextDefinition` \| `IJsonLdContextDefinitionElement`[] \| `IJsonLdIdMap` \| `IJsonLdNodeObject` \| `IJsonLdListObject` \| `object` & `object` \| `object` & `object` \| `object` & `object` \| `IJsonLdSetObject` \| `IJsonLdJsonObject` \| `IJsonLdIndexMap` \| `IJsonLdLanguageMap` \| `IJsonLdGraphObject` \| `IJsonLdNodeObject`[] \| `IJsonLdJsonObject`[] \| \{\} \| `IJsonLdTypeMap` \| `IJsonLdNodePrimitive`[]
13
+
6
14
  ## Properties
7
15
 
8
16
  ### @context?
9
17
 
10
- > `optional` **@context**: `"https://w3id.org/security/data-integrity/v2"` \| \[`"https://w3id.org/security/data-integrity/v2"`, `...IJsonLdContextDefinitionElement[]`\]
18
+ > `optional` **@context**: `"https://www.w3.org/ns/credentials/v2"` \| \[`"https://www.w3.org/ns/credentials/v2"`, `...IJsonLdContextDefinitionElement[]`\]
11
19
 
12
20
  JSON-LD Context.
13
21
 
22
+ #### Overrides
23
+
24
+ `IJsonLdNodeObject.@context`
25
+
14
26
  ***
15
27
 
16
28
  ### type
17
29
 
18
- > **type**: `string`
30
+ > **type**: `"DataIntegrityProof"`
19
31
 
20
32
  JSON-LD Type.
21
33
 
@@ -45,9 +57,9 @@ The reason the proof was created.
45
57
 
46
58
  ***
47
59
 
48
- ### proofValue
60
+ ### proofValue?
49
61
 
50
- > **proofValue**: `string`
62
+ > `optional` **proofValue**: `string`
51
63
 
52
64
  Contains the base-encoded binary data necessary to verify the
53
65
  digital proof using the verificationMethod specified.
@@ -2,6 +2,14 @@
2
2
 
3
3
  Interface describing a DID document verification method.
4
4
 
5
+ ## Extends
6
+
7
+ - `IJsonLdNodeObject`
8
+
9
+ ## Indexable
10
+
11
+ \[`key`: `string`\]: `undefined` \| `null` \| `string` \| `number` \| `boolean` \| `string`[] \| `IJsonLdContextDefinition` \| `IJsonLdContextDefinitionElement`[] \| `IJsonLdIdMap` \| `IJsonLdNodeObject` \| `IJsonLdListObject` \| `object` & `object` \| `object` & `object` \| `object` & `object` \| `IJsonLdSetObject` \| `IJsonLdJsonObject` \| `IJsonLdIndexMap` \| `IJsonLdLanguageMap` \| `IJsonLdGraphObject` \| `IJsonLdNodeObject`[] \| `IJsonLdJsonObject`[] \| \{\} \| `IJsonLdTypeMap` \| `IJsonLdNodePrimitive`[]
12
+
5
13
  ## Properties
6
14
 
7
15
  ### id
@@ -39,7 +47,7 @@ Spec https://datatracker.ietf.org/doc/html/draft-multiformats-multibase-03 .
39
47
 
40
48
  ### publicKeyJwk?
41
49
 
42
- > `optional` **publicKeyJwk**: `IJwk`
50
+ > `optional` **publicKeyJwk**: `IJwk` & `IJsonLdNodeObject`
43
51
 
44
52
  The public key for the entry as a JWK.
45
53
  Spec https://datatracker.ietf.org/doc/html/rfc7517 .
@@ -7,7 +7,7 @@ https://www.w3.org/TR/vc-data-model-2.0
7
7
 
8
8
  ### @context
9
9
 
10
- > **@context**: `"https://www.w3.org/ns/credentials/v2"` \| \[`"https://www.w3.org/ns/credentials/v2"`, `...IJsonLdContextDefinitionElement[]`\]
10
+ > **@context**: `"https://www.w3.org/2018/credentials/v1"` \| `"https://www.w3.org/ns/credentials/v2"` \| \[`"https://www.w3.org/ns/credentials/v2"`, `...IJsonLdContextDefinitionElement[]`\] \| \[`"https://www.w3.org/2018/credentials/v1"`, `...IJsonLdContextDefinitionElement[]`\]
11
11
 
12
12
  The context for the verifiable credential.
13
13
 
@@ -112,7 +112,7 @@ Evidence associated with the Credential.
112
112
 
113
113
  ### proof?
114
114
 
115
- > `optional` **proof**: [`IDidProof`](IDidProof.md) \| [`IDidProof`](IDidProof.md)[]
115
+ > `optional` **proof**: [`IDataIntegrityProof`](IDataIntegrityProof.md) \| [`IJsonWebSignature2020Proof`](IJsonWebSignature2020Proof.md) \| ([`IDataIntegrityProof`](IDataIntegrityProof.md) \| [`IJsonWebSignature2020Proof`](IJsonWebSignature2020Proof.md))[]
116
116
 
117
117
  Proofs that the verifiable credential is valid.
118
118
  Optional if a different proof method is used, such as JWT.
@@ -46,7 +46,7 @@ The entity generating the presentation.
46
46
 
47
47
  ### proof?
48
48
 
49
- > `optional` **proof**: [`IDidProof`](IDidProof.md) \| [`IDidProof`](IDidProof.md)[]
49
+ > `optional` **proof**: [`IDataIntegrityProof`](IDataIntegrityProof.md) \| [`IJsonWebSignature2020Proof`](IJsonWebSignature2020Proof.md) \| ([`IDataIntegrityProof`](IDataIntegrityProof.md) \| [`IJsonWebSignature2020Proof`](IJsonWebSignature2020Proof.md))[]
50
50
 
51
51
  Proofs that the verifiable presentation is valid.
52
52
  Optional if a different proof method is used, such as JWT.
@@ -0,0 +1,52 @@
1
+ # Interface: IJsonWebSignature2020Proof
2
+
3
+ Interface describing a did proof in JSON Web Signature 2020 Format.
4
+ https://www.w3.org/TR/vc-jws-2020/
5
+
6
+ ## Properties
7
+
8
+ ### @context?
9
+
10
+ > `optional` **@context**: `"https://w3id.org/security/suites/jws-2020/v1"` \| \[`"https://w3id.org/security/suites/jws-2020/v1"`, `...IJsonLdContextDefinitionElement[]`\]
11
+
12
+ JSON-LD Context.
13
+
14
+ ***
15
+
16
+ ### type
17
+
18
+ > **type**: `"JsonWebSignature2020"`
19
+
20
+ JSON-LD Type.
21
+
22
+ ***
23
+
24
+ ### proofPurpose
25
+
26
+ > **proofPurpose**: `string`
27
+
28
+ The reason the proof was created.
29
+
30
+ ***
31
+
32
+ ### verificationMethod?
33
+
34
+ > `optional` **verificationMethod**: `string`
35
+
36
+ The verification method of the proof.
37
+
38
+ ***
39
+
40
+ ### created?
41
+
42
+ > `optional` **created**: `string`
43
+
44
+ The iso date of when the proof was created.
45
+
46
+ ***
47
+
48
+ ### jws?
49
+
50
+ > `optional` **jws**: `string`
51
+
52
+ The JSON Web Signature.
@@ -0,0 +1,68 @@
1
+ # Interface: IMultikey
2
+
3
+ Interface describing a Multikey.
4
+ https://www.w3.org/TR/cid-1.0/
5
+
6
+ ## Properties
7
+
8
+ ### @context?
9
+
10
+ > `optional` **@context**: `"https://www.w3.org/ns/cid/v1"` \| `"https://w3id.org/security/multikey/v1"` \| \[`"https://www.w3.org/ns/cid/v1"`, `...IJsonLdContextDefinitionElement[]`\] \| \[`"https://w3id.org/security/multikey/v1"`, `...IJsonLdContextDefinitionElement[]`\]
11
+
12
+ JSON-LD Context.
13
+
14
+ ***
15
+
16
+ ### id?
17
+
18
+ > `optional` **id**: `string`
19
+
20
+ The id of the entry.
21
+
22
+ ***
23
+
24
+ ### type
25
+
26
+ > **type**: `"Multikey"`
27
+
28
+ The type of the entry.
29
+
30
+ ***
31
+
32
+ ### controller?
33
+
34
+ > `optional` **controller**: `string`
35
+
36
+ The controller for the entry.
37
+
38
+ ***
39
+
40
+ ### publicKeyMultibase
41
+
42
+ > **publicKeyMultibase**: `string`
43
+
44
+ The public key for the entry.
45
+
46
+ ***
47
+
48
+ ### secretKeyMultibase?
49
+
50
+ > `optional` **secretKeyMultibase**: `string`
51
+
52
+ The secret key for the entry.
53
+
54
+ ***
55
+
56
+ ### expires?
57
+
58
+ > `optional` **expires**: `string`
59
+
60
+ The date the entry expires.
61
+
62
+ ***
63
+
64
+ ### revoked?
65
+
66
+ > `optional` **revoked**: `string`
67
+
68
+ The date the entry was revoked.
@@ -0,0 +1,99 @@
1
+ # Interface: IProofSignerVerifier
2
+
3
+ Interface describing a proof signer and verifier.
4
+
5
+ ## Methods
6
+
7
+ ### createProof()
8
+
9
+ > **createProof**(`unsecuredDocument`, `unsignedProof`, `signKey`): `Promise`\<`IJsonLdNodeObject`\>
10
+
11
+ Create a proof for the given data.
12
+
13
+ #### Parameters
14
+
15
+ ##### unsecuredDocument
16
+
17
+ `IJsonLdNodeObject`
18
+
19
+ The data to create the proof for.
20
+
21
+ ##### unsignedProof
22
+
23
+ `IJsonLdNodeObject`
24
+
25
+ The proof options.
26
+
27
+ ##### signKey
28
+
29
+ `IJwk`
30
+
31
+ The key to sign the proof with.
32
+
33
+ #### Returns
34
+
35
+ `Promise`\<`IJsonLdNodeObject`\>
36
+
37
+ The created proof.
38
+
39
+ ***
40
+
41
+ ### verifyProof()
42
+
43
+ > **verifyProof**(`securedDocument`, `signedProof`, `verifyKey`): `Promise`\<`boolean`\>
44
+
45
+ Verify a proof for the given data.
46
+
47
+ #### Parameters
48
+
49
+ ##### securedDocument
50
+
51
+ `IJsonLdNodeObject`
52
+
53
+ The credential to verify.
54
+
55
+ ##### signedProof
56
+
57
+ `IJsonLdNodeObject`
58
+
59
+ The proof to verify.
60
+
61
+ ##### verifyKey
62
+
63
+ `IJwk`
64
+
65
+ The public key to verify the proof with.
66
+
67
+ #### Returns
68
+
69
+ `Promise`\<`boolean`\>
70
+
71
+ True if the credential was verified.
72
+
73
+ ***
74
+
75
+ ### createHash()
76
+
77
+ > **createHash**(`unsecuredDocument`, `unsignedProof`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
78
+
79
+ Create a hash for the given data.
80
+
81
+ #### Parameters
82
+
83
+ ##### unsecuredDocument
84
+
85
+ `IJsonLdNodeObject`
86
+
87
+ The data to create the proof for.
88
+
89
+ ##### unsignedProof
90
+
91
+ `IJsonLdNodeObject`
92
+
93
+ The unsigned proof.
94
+
95
+ #### Returns
96
+
97
+ `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
98
+
99
+ The created hash.
@@ -0,0 +1,5 @@
1
+ # Type Alias: ProofTypes
2
+
3
+ > **ProofTypes**: *typeof* [`ProofTypes`](../variables/ProofTypes.md)\[keyof *typeof* [`ProofTypes`](../variables/ProofTypes.md)\]
4
+
5
+ The types for proofs.
@@ -36,8 +36,20 @@ The context root for security ed25519 suites.
36
36
 
37
37
  The context root for security jws-2020 suites.
38
38
 
39
- ### ContextVCDataIntegrity
39
+ ### ContextDataIntegrity
40
40
 
41
- > `readonly` **ContextVCDataIntegrity**: `"https://w3id.org/security/data-integrity/v2"` = `"https://w3id.org/security/data-integrity/v2"`
41
+ > `readonly` **ContextDataIntegrity**: `"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
+
45
+ ### ContextControllerIdentifiers
46
+
47
+ > `readonly` **ContextControllerIdentifiers**: `"https://www.w3.org/ns/cid/v1"` = `"https://www.w3.org/ns/cid/v1"`
48
+
49
+ The context root for VC Data Integrity.
50
+
51
+ ### ContextSecurityMultikey
52
+
53
+ > `readonly` **ContextSecurityMultikey**: `"https://w3id.org/security/multikey/v1"` = `"https://w3id.org/security/multikey/v1"`
54
+
55
+ The context root for security multikey suites.
@@ -18,12 +18,6 @@ The type for Verifiable Credential.
18
18
 
19
19
  The type for Verifiable Presentation.
20
20
 
21
- ### DataIntegrityProof
22
-
23
- > `readonly` **DataIntegrityProof**: `"DataIntegrityProof"` = `"DataIntegrityProof"`
24
-
25
- The type for Data Integrity Proof.
26
-
27
21
  ### Ed25519VerificationKey2020
28
22
 
29
23
  > `readonly` **Ed25519VerificationKey2020**: `"Ed25519VerificationKey2020"` = `"Ed25519VerificationKey2020"`
@@ -41,3 +35,9 @@ The type for JsonWebKey2020.
41
35
  > `readonly` **LinkedDomains**: `"LinkedDomains"` = `"LinkedDomains"`
42
36
 
43
37
  The type for LinkedDomains.
38
+
39
+ ### Multikey
40
+
41
+ > `readonly` **Multikey**: `"Multikey"` = `"Multikey"`
42
+
43
+ The type for Multikey.
@@ -0,0 +1,19 @@
1
+ # Variable: ProofTypes
2
+
3
+ > `const` **ProofTypes**: `object`
4
+
5
+ The types for proofs.
6
+
7
+ ## Type declaration
8
+
9
+ ### DataIntegrityProof
10
+
11
+ > `readonly` **DataIntegrityProof**: `"DataIntegrityProof"` = `"DataIntegrityProof"`
12
+
13
+ The type for Data Integrity Proof.
14
+
15
+ ### JsonWebSignature2020
16
+
17
+ > `readonly` **JsonWebSignature2020**: `"JsonWebSignature2020"` = `"JsonWebSignature2020"`
18
+
19
+ The type for Json Web Signature 2020.
package/locales/en.json CHANGED
@@ -1 +1,27 @@
1
- {}
1
+ {
2
+ "error": {
3
+ "proofHelper": {
4
+ "unsupportedProofType": "Proof type \"{proofType}\" not supported.",
5
+ "proofMissing": "Proof is missing."
6
+ },
7
+ "jsonWebSignature2020SignerVerifier": {
8
+ "missingPrivateKey": "Private key is missing.",
9
+ "missingPublicKey": "Public key is missing.",
10
+ "missingProofValue": "Proof value is missing."
11
+ },
12
+ "dataIntegrityProofSignerVerifier": {
13
+ "cryptosuiteNotSupported": "Cryptosuite \"{cryptosuite}\" is not supported.",
14
+ "missingPrivateKey": "Private key is missing.",
15
+ "missingPublicKey": "Public key is missing.",
16
+ "missingProofValue": "Proof value is missing."
17
+ },
18
+ "multikeyHelper": {
19
+ "invalidPublicKeyMultibase": "Public key multibase \"{publicKeyMultibase}\" is invalid.",
20
+ "invalidSecretKeyMultibase": "Secret key multibase \"{secretKeyMultibase}\" is invalid.",
21
+ "unsupportedCrv": "Curve \"{crv}\" is not supported.",
22
+ "unsupportedKty": "Key type \"{kty}\" is not supported.",
23
+ "publicKeyMultibaseMissingHeader": "Public key multibase \"{publicKeyMultibase}\" is missing the multi codec header",
24
+ "secretKeyMultibaseMissingHeader": "Secret key multibase \"{secretKeyMultibase}\" is missing the multi codec header"
25
+ }
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/standards-w3c-did",
3
- "version": "0.0.1-next.25",
3
+ "version": "0.0.1-next.26",
4
4
  "description": "Models which define the structure of W3C DID Standard",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,10 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
+ "@twin.org/core": "next",
18
+ "@twin.org/crypto": "next",
17
19
  "@twin.org/data-json-ld": "next",
20
+ "@twin.org/nameof": "next",
18
21
  "@twin.org/web": "next"
19
22
  },
20
23
  "main": "./dist/cjs/index.cjs",