@twin.org/identity-models 0.0.2-next.1 → 0.0.2-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.
- package/dist/es/contextIdHandlers/didContextIdHandler.js +34 -0
- package/dist/es/contextIdHandlers/didContextIdHandler.js.map +1 -0
- package/dist/es/factories/identityConnectorFactory.js +9 -0
- package/dist/es/factories/identityConnectorFactory.js.map +1 -0
- package/dist/es/factories/identityProfileConnectorFactory.js +9 -0
- package/dist/es/factories/identityProfileConnectorFactory.js.map +1 -0
- package/dist/es/factories/identityResolverConnectorFactory.js +9 -0
- package/dist/es/factories/identityResolverConnectorFactory.js.map +1 -0
- package/dist/es/index.js +49 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IIdentityComponent.js +2 -0
- package/dist/es/models/IIdentityComponent.js.map +1 -0
- package/dist/es/models/IIdentityConnector.js +2 -0
- package/dist/es/models/IIdentityConnector.js.map +1 -0
- package/dist/es/models/IIdentityProfileComponent.js +2 -0
- package/dist/es/models/IIdentityProfileComponent.js.map +1 -0
- package/dist/es/models/IIdentityProfileConnector.js +2 -0
- package/dist/es/models/IIdentityProfileConnector.js.map +1 -0
- package/dist/es/models/IIdentityResolverComponent.js +2 -0
- package/dist/es/models/IIdentityResolverComponent.js.map +1 -0
- package/dist/es/models/IIdentityResolverConnector.js +2 -0
- package/dist/es/models/IIdentityResolverConnector.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityCreateRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityCreateRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityCreateResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityCreateResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityProofCreateRequest.js +2 -0
- package/dist/es/models/api/identity/IIdentityProofCreateRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityProofCreateResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityProofCreateResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityProofVerifyRequest.js +2 -0
- package/dist/es/models/api/identity/IIdentityProofVerifyRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityProofVerifyResponse.js +4 -0
- package/dist/es/models/api/identity/IIdentityProofVerifyResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityRemoveRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityRemoveRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityServiceCreateRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityServiceCreateRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityServiceCreateResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityServiceCreateResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityServiceRemoveRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityServiceRemoveRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialCreateRequest.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialCreateRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialCreateResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialCreateResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialRevokeRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialRevokeRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialUnrevokeRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialUnrevokeRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialVerifyRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialVerifyRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialVerifyResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerifiableCredentialVerifyResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationCreateRequest.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationCreateRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationCreateResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationCreateResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationVerifyRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationVerifyRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationVerifyResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerifiablePresentationVerifyResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerificationMethodCreateRequest.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerificationMethodCreateRequest.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerificationMethodCreateResponse.js +2 -0
- package/dist/es/models/api/identity/IIdentityVerificationMethodCreateResponse.js.map +1 -0
- package/dist/es/models/api/identity/IIdentityVerificationMethodRemoveRequest.js +4 -0
- package/dist/es/models/api/identity/IIdentityVerificationMethodRemoveRequest.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileCreateRequest.js +2 -0
- package/dist/es/models/api/profile/IIdentityProfileCreateRequest.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileGetPublicRequest.js +4 -0
- package/dist/es/models/api/profile/IIdentityProfileGetPublicRequest.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileGetPublicResponse.js +2 -0
- package/dist/es/models/api/profile/IIdentityProfileGetPublicResponse.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileGetRequest.js +4 -0
- package/dist/es/models/api/profile/IIdentityProfileGetRequest.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileGetResponse.js +2 -0
- package/dist/es/models/api/profile/IIdentityProfileGetResponse.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileListRequest.js +4 -0
- package/dist/es/models/api/profile/IIdentityProfileListRequest.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileListResponse.js +2 -0
- package/dist/es/models/api/profile/IIdentityProfileListResponse.js.map +1 -0
- package/dist/es/models/api/profile/IIdentityProfileUpdateRequest.js +2 -0
- package/dist/es/models/api/profile/IIdentityProfileUpdateRequest.js.map +1 -0
- package/dist/es/models/api/resolver/IIdentityResolveRequest.js +4 -0
- package/dist/es/models/api/resolver/IIdentityResolveRequest.js.map +1 -0
- package/dist/es/models/api/resolver/IIdentityResolveResponse.js +2 -0
- package/dist/es/models/api/resolver/IIdentityResolveResponse.js.map +1 -0
- package/dist/es/types/did.js +53 -0
- package/dist/es/types/did.js.map +1 -0
- package/dist/es/utils/documentHelper.js +92 -0
- package/dist/es/utils/documentHelper.js.map +1 -0
- package/dist/es/utils/verificationHelper.js +79 -0
- package/dist/es/utils/verificationHelper.js.map +1 -0
- package/dist/types/contextIdHandlers/didContextIdHandler.d.ts +22 -0
- package/dist/types/factories/identityConnectorFactory.d.ts +1 -1
- package/dist/types/factories/identityProfileConnectorFactory.d.ts +1 -1
- package/dist/types/factories/identityResolverConnectorFactory.d.ts +1 -1
- package/dist/types/index.d.ts +46 -44
- package/dist/types/models/IIdentityComponent.d.ts +7 -2
- package/dist/types/models/IIdentityConnector.d.ts +7 -2
- package/dist/types/models/IIdentityProfileComponent.d.ts +2 -2
- package/dist/types/models/IIdentityProfileConnector.d.ts +2 -2
- package/dist/types/models/api/identity/IIdentityVerifiableCredentialCreateRequest.d.ts +4 -0
- package/dist/types/models/api/profile/IIdentityProfileListRequest.d.ts +1 -1
- package/dist/types/types/did.d.ts +28 -0
- package/dist/types/utils/verificationHelper.d.ts +1 -1
- package/docs/changelog.md +63 -0
- package/docs/reference/classes/Did.md +95 -0
- package/docs/reference/classes/DidContextIdHandler.md +79 -0
- package/docs/reference/classes/DocumentHelper.md +2 -2
- package/docs/reference/classes/VerificationHelper.md +2 -2
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IIdentityComponent.md +108 -2
- package/docs/reference/interfaces/IIdentityConnector.md +108 -2
- package/docs/reference/interfaces/IIdentityProfileComponent.md +98 -2
- package/docs/reference/interfaces/IIdentityProfileConnector.md +98 -2
- package/docs/reference/interfaces/IIdentityProfileListRequest.md +2 -2
- package/docs/reference/interfaces/IIdentityResolverComponent.md +96 -0
- package/docs/reference/interfaces/IIdentityResolverConnector.md +96 -0
- package/docs/reference/interfaces/IIdentityVerifiableCredentialCreateRequest.md +6 -0
- package/locales/en.json +4 -7
- package/package.json +53 -8
- package/dist/cjs/index.cjs +0 -200
- package/dist/esm/index.mjs +0 -194
|
@@ -18,6 +18,102 @@ Interface describing a contract which provides profile operations.
|
|
|
18
18
|
|
|
19
19
|
## Methods
|
|
20
20
|
|
|
21
|
+
### className()
|
|
22
|
+
|
|
23
|
+
> **className**(): `string`
|
|
24
|
+
|
|
25
|
+
Returns the class name of the component.
|
|
26
|
+
|
|
27
|
+
#### Returns
|
|
28
|
+
|
|
29
|
+
`string`
|
|
30
|
+
|
|
31
|
+
The class name of the component.
|
|
32
|
+
|
|
33
|
+
#### Inherited from
|
|
34
|
+
|
|
35
|
+
`IComponent.className`
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### bootstrap()?
|
|
40
|
+
|
|
41
|
+
> `optional` **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
42
|
+
|
|
43
|
+
Bootstrap the component by creating and initializing any resources it needs.
|
|
44
|
+
|
|
45
|
+
#### Parameters
|
|
46
|
+
|
|
47
|
+
##### nodeLoggingComponentType?
|
|
48
|
+
|
|
49
|
+
`string`
|
|
50
|
+
|
|
51
|
+
The node logging component type.
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`Promise`\<`boolean`\>
|
|
56
|
+
|
|
57
|
+
True if the bootstrapping process was successful.
|
|
58
|
+
|
|
59
|
+
#### Inherited from
|
|
60
|
+
|
|
61
|
+
`IComponent.bootstrap`
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
65
|
+
### start()?
|
|
66
|
+
|
|
67
|
+
> `optional` **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
68
|
+
|
|
69
|
+
The component needs to be started when the node is initialized.
|
|
70
|
+
|
|
71
|
+
#### Parameters
|
|
72
|
+
|
|
73
|
+
##### nodeLoggingComponentType?
|
|
74
|
+
|
|
75
|
+
`string`
|
|
76
|
+
|
|
77
|
+
The node logging component type.
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
`Promise`\<`void`\>
|
|
82
|
+
|
|
83
|
+
Nothing.
|
|
84
|
+
|
|
85
|
+
#### Inherited from
|
|
86
|
+
|
|
87
|
+
`IComponent.start`
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### stop()?
|
|
92
|
+
|
|
93
|
+
> `optional` **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
94
|
+
|
|
95
|
+
The component needs to be stopped when the node is closed.
|
|
96
|
+
|
|
97
|
+
#### Parameters
|
|
98
|
+
|
|
99
|
+
##### nodeLoggingComponentType?
|
|
100
|
+
|
|
101
|
+
`string`
|
|
102
|
+
|
|
103
|
+
The node logging component type.
|
|
104
|
+
|
|
105
|
+
#### Returns
|
|
106
|
+
|
|
107
|
+
`Promise`\<`void`\>
|
|
108
|
+
|
|
109
|
+
Nothing.
|
|
110
|
+
|
|
111
|
+
#### Inherited from
|
|
112
|
+
|
|
113
|
+
`IComponent.stop`
|
|
114
|
+
|
|
115
|
+
***
|
|
116
|
+
|
|
21
117
|
### create()
|
|
22
118
|
|
|
23
119
|
> **create**(`identity`, `publicProfile?`, `privateProfile?`): `Promise`\<`void`\>
|
|
@@ -144,7 +240,7 @@ Nothing.
|
|
|
144
240
|
|
|
145
241
|
### list()
|
|
146
242
|
|
|
147
|
-
> **list**(`publicFilters?`, `privateFilters?`, `publicPropertyNames?`, `privatePropertyNames?`, `cursor?`, `
|
|
243
|
+
> **list**(`publicFilters?`, `privateFilters?`, `publicPropertyNames?`, `privatePropertyNames?`, `cursor?`, `limit?`): `Promise`\<\{ `items`: `object`[]; `cursor?`: `string`; \}\>
|
|
148
244
|
|
|
149
245
|
Get a list of the requested identities.
|
|
150
246
|
|
|
@@ -180,7 +276,7 @@ The private properties to get for the profile, defaults to all.
|
|
|
180
276
|
|
|
181
277
|
The cursor for paged requests.
|
|
182
278
|
|
|
183
|
-
#####
|
|
279
|
+
##### limit?
|
|
184
280
|
|
|
185
281
|
`number`
|
|
186
282
|
|
|
@@ -28,8 +28,8 @@ The public properties to get for the profile, defaults to all, should be a comma
|
|
|
28
28
|
|
|
29
29
|
The cursor for paged requests.
|
|
30
30
|
|
|
31
|
-
####
|
|
31
|
+
#### limit?
|
|
32
32
|
|
|
33
|
-
> `optional` **
|
|
33
|
+
> `optional` **limit**: `string`
|
|
34
34
|
|
|
35
35
|
Number of items to return.
|
|
@@ -8,6 +8,102 @@ Interface describing a contract which provides identity operations.
|
|
|
8
8
|
|
|
9
9
|
## Methods
|
|
10
10
|
|
|
11
|
+
### className()
|
|
12
|
+
|
|
13
|
+
> **className**(): `string`
|
|
14
|
+
|
|
15
|
+
Returns the class name of the component.
|
|
16
|
+
|
|
17
|
+
#### Returns
|
|
18
|
+
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
The class name of the component.
|
|
22
|
+
|
|
23
|
+
#### Inherited from
|
|
24
|
+
|
|
25
|
+
`IComponent.className`
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### bootstrap()?
|
|
30
|
+
|
|
31
|
+
> `optional` **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
32
|
+
|
|
33
|
+
Bootstrap the component by creating and initializing any resources it needs.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
##### nodeLoggingComponentType?
|
|
38
|
+
|
|
39
|
+
`string`
|
|
40
|
+
|
|
41
|
+
The node logging component type.
|
|
42
|
+
|
|
43
|
+
#### Returns
|
|
44
|
+
|
|
45
|
+
`Promise`\<`boolean`\>
|
|
46
|
+
|
|
47
|
+
True if the bootstrapping process was successful.
|
|
48
|
+
|
|
49
|
+
#### Inherited from
|
|
50
|
+
|
|
51
|
+
`IComponent.bootstrap`
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### start()?
|
|
56
|
+
|
|
57
|
+
> `optional` **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
58
|
+
|
|
59
|
+
The component needs to be started when the node is initialized.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
|
|
63
|
+
##### nodeLoggingComponentType?
|
|
64
|
+
|
|
65
|
+
`string`
|
|
66
|
+
|
|
67
|
+
The node logging component type.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`Promise`\<`void`\>
|
|
72
|
+
|
|
73
|
+
Nothing.
|
|
74
|
+
|
|
75
|
+
#### Inherited from
|
|
76
|
+
|
|
77
|
+
`IComponent.start`
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
### stop()?
|
|
82
|
+
|
|
83
|
+
> `optional` **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
84
|
+
|
|
85
|
+
The component needs to be stopped when the node is closed.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
##### nodeLoggingComponentType?
|
|
90
|
+
|
|
91
|
+
`string`
|
|
92
|
+
|
|
93
|
+
The node logging component type.
|
|
94
|
+
|
|
95
|
+
#### Returns
|
|
96
|
+
|
|
97
|
+
`Promise`\<`void`\>
|
|
98
|
+
|
|
99
|
+
Nothing.
|
|
100
|
+
|
|
101
|
+
#### Inherited from
|
|
102
|
+
|
|
103
|
+
`IComponent.stop`
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
11
107
|
### identityResolve()
|
|
12
108
|
|
|
13
109
|
> **identityResolve**(`identity`): `Promise`\<`IDidDocument`\>
|
|
@@ -8,6 +8,102 @@ Interface describing an identity connector.
|
|
|
8
8
|
|
|
9
9
|
## Methods
|
|
10
10
|
|
|
11
|
+
### className()
|
|
12
|
+
|
|
13
|
+
> **className**(): `string`
|
|
14
|
+
|
|
15
|
+
Returns the class name of the component.
|
|
16
|
+
|
|
17
|
+
#### Returns
|
|
18
|
+
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
The class name of the component.
|
|
22
|
+
|
|
23
|
+
#### Inherited from
|
|
24
|
+
|
|
25
|
+
`IComponent.className`
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### bootstrap()?
|
|
30
|
+
|
|
31
|
+
> `optional` **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
32
|
+
|
|
33
|
+
Bootstrap the component by creating and initializing any resources it needs.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
##### nodeLoggingComponentType?
|
|
38
|
+
|
|
39
|
+
`string`
|
|
40
|
+
|
|
41
|
+
The node logging component type.
|
|
42
|
+
|
|
43
|
+
#### Returns
|
|
44
|
+
|
|
45
|
+
`Promise`\<`boolean`\>
|
|
46
|
+
|
|
47
|
+
True if the bootstrapping process was successful.
|
|
48
|
+
|
|
49
|
+
#### Inherited from
|
|
50
|
+
|
|
51
|
+
`IComponent.bootstrap`
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### start()?
|
|
56
|
+
|
|
57
|
+
> `optional` **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
58
|
+
|
|
59
|
+
The component needs to be started when the node is initialized.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
|
|
63
|
+
##### nodeLoggingComponentType?
|
|
64
|
+
|
|
65
|
+
`string`
|
|
66
|
+
|
|
67
|
+
The node logging component type.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`Promise`\<`void`\>
|
|
72
|
+
|
|
73
|
+
Nothing.
|
|
74
|
+
|
|
75
|
+
#### Inherited from
|
|
76
|
+
|
|
77
|
+
`IComponent.start`
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
### stop()?
|
|
82
|
+
|
|
83
|
+
> `optional` **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
84
|
+
|
|
85
|
+
The component needs to be stopped when the node is closed.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
##### nodeLoggingComponentType?
|
|
90
|
+
|
|
91
|
+
`string`
|
|
92
|
+
|
|
93
|
+
The node logging component type.
|
|
94
|
+
|
|
95
|
+
#### Returns
|
|
96
|
+
|
|
97
|
+
`Promise`\<`void`\>
|
|
98
|
+
|
|
99
|
+
Nothing.
|
|
100
|
+
|
|
101
|
+
#### Inherited from
|
|
102
|
+
|
|
103
|
+
`IComponent.stop`
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
11
107
|
### resolveDocument()
|
|
12
108
|
|
|
13
109
|
> **resolveDocument**(`documentId`): `Promise`\<`IDidDocument`\>
|
|
@@ -47,3 +47,9 @@ The credential subject to store in the verifiable credential.
|
|
|
47
47
|
> `optional` **revocationIndex**: `number`
|
|
48
48
|
|
|
49
49
|
The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
50
|
+
|
|
51
|
+
#### expirationDate?
|
|
52
|
+
|
|
53
|
+
> `optional` **expirationDate**: `string`
|
|
54
|
+
|
|
55
|
+
The date the verifiable credential is valid until.
|
package/locales/en.json
CHANGED
|
@@ -2,18 +2,15 @@
|
|
|
2
2
|
"error": {
|
|
3
3
|
"verificationHelper": {
|
|
4
4
|
"jwtDecodeFailed": "Decoding the JWT failed",
|
|
5
|
-
"proofTypeNotSupported": "The proof type \"{proofType}\" is not supported",
|
|
6
5
|
"proofMissingVerificationMethod": "The proof is missing the verification method"
|
|
7
6
|
},
|
|
8
7
|
"documentHelper": {
|
|
9
8
|
"verificationMethodNotFound": "The verification method \"{methodName}\" of type \"{methodType}\" could not be found",
|
|
10
9
|
"verificationMethodJwkNotFound": "The verification method \"{methodName}\" of type \"{methodType}\" is missing the JWK"
|
|
10
|
+
},
|
|
11
|
+
"guard": {
|
|
12
|
+
"didPartsTooFew": "The DID \"{value}\" is invalid: expected at least 3 parts but got fewer",
|
|
13
|
+
"didInvalidStart": "The DID \"{value}\" is invalid: expected to start with 'did'"
|
|
11
14
|
}
|
|
12
|
-
},
|
|
13
|
-
"verifiableCredentialStates": {
|
|
14
|
-
"pendingVerification": "Pending Verification",
|
|
15
|
-
"rejected": "Rejected",
|
|
16
|
-
"issued": "Issued",
|
|
17
|
-
"revoked": "Revoked"
|
|
18
15
|
}
|
|
19
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-models",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.11",
|
|
4
4
|
"description": "Models which define the structure of the contracts and connectors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,7 +13,22 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"clean": "rimraf dist coverage docs/reference",
|
|
18
|
+
"build": "tspc",
|
|
19
|
+
"dev": "nodemon --watch src --ext ts --exec \"npm run build\"",
|
|
20
|
+
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
21
|
+
"test:build": "tspc -p ./tests/tsconfig.json --noEmit",
|
|
22
|
+
"validate-locales": "validate-locales",
|
|
23
|
+
"test:coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
24
|
+
"docs:clean": "rimraf docs/reference",
|
|
25
|
+
"docs:generate": "typedoc",
|
|
26
|
+
"docs": "npm run docs:clean && npm run docs:generate",
|
|
27
|
+
"dist": "npm run clean && npm run build && npm run validate-locales && npm run test:build && npm run test && npm run docs",
|
|
28
|
+
"dist:no-test": "npm run clean && npm run build && npm run test:build && npm run docs"
|
|
29
|
+
},
|
|
16
30
|
"dependencies": {
|
|
31
|
+
"@twin.org/context": "next",
|
|
17
32
|
"@twin.org/core": "next",
|
|
18
33
|
"@twin.org/data-core": "next",
|
|
19
34
|
"@twin.org/data-json-ld": "next",
|
|
@@ -21,22 +36,52 @@
|
|
|
21
36
|
"@twin.org/standards-w3c-did": "next",
|
|
22
37
|
"@twin.org/web": "next"
|
|
23
38
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@twin.org/nameof-transformer": "next",
|
|
41
|
+
"@twin.org/nameof-vitest-plugin": "next",
|
|
42
|
+
"@twin.org/validate-locales": "next",
|
|
43
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
44
|
+
"copyfiles": "2.4.1",
|
|
45
|
+
"nodemon": "3.1.10",
|
|
46
|
+
"rimraf": "6.0.1",
|
|
47
|
+
"ts-patch": "3.3.0",
|
|
48
|
+
"typedoc": "0.28.13",
|
|
49
|
+
"typedoc-plugin-markdown": "4.9.0",
|
|
50
|
+
"typescript": "5.9.3",
|
|
51
|
+
"vitest": "3.2.4"
|
|
52
|
+
},
|
|
53
|
+
"main": "./dist/es/index.js",
|
|
26
54
|
"types": "./dist/types/index.d.ts",
|
|
27
55
|
"exports": {
|
|
28
56
|
".": {
|
|
29
57
|
"types": "./dist/types/index.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
58
|
+
"import": "./dist/es/index.js",
|
|
59
|
+
"default": "./dist/es/index.js"
|
|
32
60
|
},
|
|
33
61
|
"./locales/*.json": "./locales/*.json"
|
|
34
62
|
},
|
|
35
63
|
"files": [
|
|
36
|
-
"dist/
|
|
37
|
-
"dist/esm",
|
|
64
|
+
"dist/es",
|
|
38
65
|
"dist/types",
|
|
39
66
|
"locales",
|
|
40
67
|
"docs"
|
|
41
|
-
]
|
|
68
|
+
],
|
|
69
|
+
"keywords": [
|
|
70
|
+
"twin",
|
|
71
|
+
"trade",
|
|
72
|
+
"iota",
|
|
73
|
+
"framework",
|
|
74
|
+
"blockchain",
|
|
75
|
+
"identity",
|
|
76
|
+
"did",
|
|
77
|
+
"credentials",
|
|
78
|
+
"authentication",
|
|
79
|
+
"models",
|
|
80
|
+
"types",
|
|
81
|
+
"schemas"
|
|
82
|
+
],
|
|
83
|
+
"bugs": {
|
|
84
|
+
"url": "git+https://github.com/twinfoundation/identity/issues"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://twindev.org"
|
|
42
87
|
}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@twin.org/core');
|
|
4
|
-
var standardsW3cDid = require('@twin.org/standards-w3c-did');
|
|
5
|
-
var web = require('@twin.org/web');
|
|
6
|
-
|
|
7
|
-
// Copyright 2024 IOTA Stiftung.
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
9
|
-
/**
|
|
10
|
-
* Factory for creating identity connectors.
|
|
11
|
-
*/
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
-
const IdentityConnectorFactory = core.Factory.createFactory("identity-connector");
|
|
14
|
-
|
|
15
|
-
// Copyright 2024 IOTA Stiftung.
|
|
16
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
17
|
-
/**
|
|
18
|
-
* Factory for creating identity profile connectors.
|
|
19
|
-
*/
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
|
-
const IdentityProfileConnectorFactory = core.Factory.createFactory("identity-profile-connector");
|
|
22
|
-
|
|
23
|
-
// Copyright 2024 IOTA Stiftung.
|
|
24
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
25
|
-
/**
|
|
26
|
-
* Factory for creating identity resolver connectors.
|
|
27
|
-
*/
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
29
|
-
const IdentityResolverConnectorFactory = core.Factory.createFactory("identity-resolver-connector");
|
|
30
|
-
|
|
31
|
-
// Copyright 2024 IOTA Stiftung.
|
|
32
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
33
|
-
/**
|
|
34
|
-
* Helper methods for documents.
|
|
35
|
-
*/
|
|
36
|
-
class DocumentHelper {
|
|
37
|
-
/**
|
|
38
|
-
* Runtime name for the class.
|
|
39
|
-
*/
|
|
40
|
-
static CLASS_NAME = "DocumentHelper";
|
|
41
|
-
/**
|
|
42
|
-
* Parse the document id into its parts.
|
|
43
|
-
* @param documentId The full document id.
|
|
44
|
-
* @returns The parsed document id.
|
|
45
|
-
*/
|
|
46
|
-
static parseId(documentId) {
|
|
47
|
-
if (!core.Is.stringValue(documentId)) {
|
|
48
|
-
return {
|
|
49
|
-
id: "",
|
|
50
|
-
fragment: ""
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const fragmentIndex = documentId.indexOf("#");
|
|
54
|
-
return {
|
|
55
|
-
id: fragmentIndex === -1 ? documentId : documentId.slice(0, fragmentIndex),
|
|
56
|
-
fragment: fragmentIndex === -1 ? undefined : documentId.slice(fragmentIndex + 1)
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Join the document id parts.
|
|
61
|
-
* @param documentId The document id.
|
|
62
|
-
* @param fragment The fragment part for the identifier.
|
|
63
|
-
* @returns The full id.
|
|
64
|
-
*/
|
|
65
|
-
static joinId(documentId, fragment) {
|
|
66
|
-
if (!core.Is.stringValue(documentId)) {
|
|
67
|
-
return "";
|
|
68
|
-
}
|
|
69
|
-
let fullId = documentId;
|
|
70
|
-
if (core.Is.stringValue(fragment)) {
|
|
71
|
-
if (fragment.startsWith(documentId)) {
|
|
72
|
-
fragment = fragment.slice(documentId.length);
|
|
73
|
-
}
|
|
74
|
-
if (fragment.startsWith("#")) {
|
|
75
|
-
fullId += fragment;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
fullId += `#${fragment}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return fullId;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get a verification method from a DID document.
|
|
85
|
-
* @param didDocument The DID Document to get the method from.
|
|
86
|
-
* @param methodName The name of the method to get the JWK from.
|
|
87
|
-
* @param methodType The type of the method, defaults to verificationMethod.
|
|
88
|
-
* @returns The verification method if found.
|
|
89
|
-
* @throws Error if the method is not found.
|
|
90
|
-
*/
|
|
91
|
-
static getVerificationMethod(didDocument, methodName, methodType) {
|
|
92
|
-
const verificationMethod = didDocument[methodType ?? standardsW3cDid.DidVerificationMethodType.VerificationMethod]?.find(vm => core.Is.object(vm) && vm.id === methodName);
|
|
93
|
-
if (core.Is.object(verificationMethod)) {
|
|
94
|
-
return verificationMethod;
|
|
95
|
-
}
|
|
96
|
-
throw new core.GeneralError(DocumentHelper.CLASS_NAME, "verificationMethodNotFound", {
|
|
97
|
-
methodName,
|
|
98
|
-
methodType
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Gets a JWK from a DID document verification method.
|
|
103
|
-
* @param didDocument The DID Document to get the method from.
|
|
104
|
-
* @param methodName The name of the method to get the JWK from.
|
|
105
|
-
* @param methodType The type of the method, defaults to verificationMethod.
|
|
106
|
-
* @returns The JWK if found.
|
|
107
|
-
* @throws Error if the method is not found.
|
|
108
|
-
*/
|
|
109
|
-
static getJwk(didDocument, methodName, methodType) {
|
|
110
|
-
const verificationMethod = DocumentHelper.getVerificationMethod(didDocument, methodName, methodType);
|
|
111
|
-
if (core.Is.object(verificationMethod) && core.Is.object(verificationMethod.publicKeyJwk)) {
|
|
112
|
-
return verificationMethod.publicKeyJwk;
|
|
113
|
-
}
|
|
114
|
-
throw new core.GeneralError(DocumentHelper.CLASS_NAME, "verificationMethodJwkNotFound", {
|
|
115
|
-
methodName,
|
|
116
|
-
methodType
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Copyright 2024 IOTA Stiftung.
|
|
122
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
123
|
-
/**
|
|
124
|
-
* Helper methods for verification.
|
|
125
|
-
*/
|
|
126
|
-
class VerificationHelper {
|
|
127
|
-
/**
|
|
128
|
-
* Runtime name for the class.
|
|
129
|
-
*/
|
|
130
|
-
static CLASS_NAME = "VerificationHelper";
|
|
131
|
-
/**
|
|
132
|
-
* Verified the JWT.
|
|
133
|
-
* @param resolver The resolver to use for finding the document.
|
|
134
|
-
* @param jwt The token to verify.
|
|
135
|
-
* @returns The decoded payload.
|
|
136
|
-
*/
|
|
137
|
-
static async verifyJwt(resolver, jwt) {
|
|
138
|
-
core.Guards.object(VerificationHelper.CLASS_NAME, "resolver", resolver);
|
|
139
|
-
core.Guards.string(VerificationHelper.CLASS_NAME, "jwt", jwt);
|
|
140
|
-
const jwtDecoded = await web.Jwt.decode(jwt);
|
|
141
|
-
const jwtHeader = jwtDecoded.header;
|
|
142
|
-
const jwtPayload = jwtDecoded.payload;
|
|
143
|
-
const jwtSignature = jwtDecoded.signature;
|
|
144
|
-
if (!core.Is.object(jwtHeader) || !core.Is.object(jwtPayload) || !core.Is.uint8Array(jwtSignature)) {
|
|
145
|
-
throw new core.GeneralError(VerificationHelper.CLASS_NAME, "jwtDecodeFailed");
|
|
146
|
-
}
|
|
147
|
-
const iss = jwtHeader?.iss;
|
|
148
|
-
const kid = jwtHeader?.kid;
|
|
149
|
-
core.Guards.stringValue(VerificationHelper.CLASS_NAME, "iss", iss);
|
|
150
|
-
core.Guards.stringValue(VerificationHelper.CLASS_NAME, "kid", kid);
|
|
151
|
-
const didDocument = await resolver.identityResolve(iss);
|
|
152
|
-
const jwk = DocumentHelper.getJwk(didDocument, kid);
|
|
153
|
-
const publicKey = await web.Jwk.toCryptoKey(jwk);
|
|
154
|
-
return web.Jwt.verify(jwt, publicKey);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Verified the proof for the document e.g. verifiable credential.
|
|
158
|
-
* @param resolver The resolver to use for finding the document.
|
|
159
|
-
* @param secureDocument The secure document to verify.
|
|
160
|
-
* @returns True if the verification is successful.
|
|
161
|
-
*/
|
|
162
|
-
static async verifyProof(resolver, secureDocument) {
|
|
163
|
-
core.Guards.object(VerificationHelper.CLASS_NAME, "resolver", resolver);
|
|
164
|
-
core.Guards.object(VerificationHelper.CLASS_NAME, "secureDocument", secureDocument);
|
|
165
|
-
core.Guards.object(VerificationHelper.CLASS_NAME, "secureDocument.proof", secureDocument.proof);
|
|
166
|
-
const proofList = core.Is.array(secureDocument.proof)
|
|
167
|
-
? secureDocument.proof
|
|
168
|
-
: [secureDocument.proof];
|
|
169
|
-
const documentCache = {};
|
|
170
|
-
for (const proof of proofList) {
|
|
171
|
-
if (!core.Is.stringValue(proof?.verificationMethod)) {
|
|
172
|
-
throw new core.GeneralError(VerificationHelper.CLASS_NAME, "proofMissingVerificationMethod");
|
|
173
|
-
}
|
|
174
|
-
const proofVerificationMethod = DocumentHelper.parseId(proof.verificationMethod);
|
|
175
|
-
if (!core.Is.stringValue(proofVerificationMethod.fragment)) {
|
|
176
|
-
throw new core.GeneralError(VerificationHelper.CLASS_NAME, "proofMissingVerificationMethod");
|
|
177
|
-
}
|
|
178
|
-
let document;
|
|
179
|
-
if (documentCache[proofVerificationMethod.id]) {
|
|
180
|
-
document = documentCache[proofVerificationMethod.id];
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
document = await resolver.identityResolve(proofVerificationMethod.id);
|
|
184
|
-
documentCache[proofVerificationMethod.id] = document;
|
|
185
|
-
}
|
|
186
|
-
const verificationJwk = await DocumentHelper.getJwk(document, proofVerificationMethod.id);
|
|
187
|
-
const verified = standardsW3cDid.ProofHelper.verifyProof(secureDocument, proof, verificationJwk);
|
|
188
|
-
if (!verified) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
exports.DocumentHelper = DocumentHelper;
|
|
197
|
-
exports.IdentityConnectorFactory = IdentityConnectorFactory;
|
|
198
|
-
exports.IdentityProfileConnectorFactory = IdentityProfileConnectorFactory;
|
|
199
|
-
exports.IdentityResolverConnectorFactory = IdentityResolverConnectorFactory;
|
|
200
|
-
exports.VerificationHelper = VerificationHelper;
|