@twin.org/identity-models 0.0.2-next.7 → 0.0.2-next.9
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/cjs/index.cjs +41 -0
- package/dist/esm/index.mjs +42 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/IIdentityProfileComponent.d.ts +2 -2
- package/dist/types/models/IIdentityProfileConnector.d.ts +2 -2
- package/dist/types/models/api/profile/IIdentityProfileListRequest.d.ts +1 -1
- package/dist/types/utils/idHelper.d.ts +20 -0
- package/docs/changelog.md +14 -0
- package/docs/reference/classes/IdHelper.md +59 -0
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IIdentityComponent.md +8 -0
- package/docs/reference/interfaces/IIdentityConnector.md +8 -0
- package/docs/reference/interfaces/IIdentityProfileComponent.md +10 -2
- package/docs/reference/interfaces/IIdentityProfileConnector.md +10 -2
- package/docs/reference/interfaces/IIdentityProfileListRequest.md +2 -2
- package/docs/reference/interfaces/IIdentityResolverComponent.md +8 -0
- package/docs/reference/interfaces/IIdentityResolverConnector.md +8 -0
- package/locales/en.json +3 -7
- package/package.json +20 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -118,6 +118,46 @@ class DocumentHelper {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
// Copyright 2024 IOTA Stiftung.
|
|
122
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
123
|
+
/**
|
|
124
|
+
* Helper methods for Ids.
|
|
125
|
+
*/
|
|
126
|
+
class IdHelper {
|
|
127
|
+
/**
|
|
128
|
+
* Runtime name for the class.
|
|
129
|
+
*/
|
|
130
|
+
static CLASS_NAME = "IdHelper";
|
|
131
|
+
/**
|
|
132
|
+
* Parse and id in to it's constituent parts.
|
|
133
|
+
* @param id The id to parse.
|
|
134
|
+
* @returns The parsed id.
|
|
135
|
+
* @throws GeneralError if the id is not valid.
|
|
136
|
+
*/
|
|
137
|
+
static parseId(id) {
|
|
138
|
+
core.Urn.guard(IdHelper.CLASS_NAME, "id", id);
|
|
139
|
+
const didUrn = core.Urn.fromValidString(id);
|
|
140
|
+
const didParts = didUrn.parts();
|
|
141
|
+
if (didParts[0] !== "did") {
|
|
142
|
+
throw new core.GeneralError(IdHelper.CLASS_NAME, "invalidDocumentId", { id });
|
|
143
|
+
}
|
|
144
|
+
if (didParts.length === 3) {
|
|
145
|
+
return {
|
|
146
|
+
method: didParts[1],
|
|
147
|
+
id: didParts[2]
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
else if (didParts.length === 4) {
|
|
151
|
+
return {
|
|
152
|
+
method: didParts[1],
|
|
153
|
+
network: didParts[2],
|
|
154
|
+
id: didParts[3]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
throw new core.GeneralError(IdHelper.CLASS_NAME, "invalidDocumentId", { id });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
121
161
|
// Copyright 2024 IOTA Stiftung.
|
|
122
162
|
// SPDX-License-Identifier: Apache-2.0.
|
|
123
163
|
/**
|
|
@@ -194,6 +234,7 @@ class VerificationHelper {
|
|
|
194
234
|
}
|
|
195
235
|
|
|
196
236
|
exports.DocumentHelper = DocumentHelper;
|
|
237
|
+
exports.IdHelper = IdHelper;
|
|
197
238
|
exports.IdentityConnectorFactory = IdentityConnectorFactory;
|
|
198
239
|
exports.IdentityProfileConnectorFactory = IdentityProfileConnectorFactory;
|
|
199
240
|
exports.IdentityResolverConnectorFactory = IdentityResolverConnectorFactory;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Factory, Is, GeneralError, Guards } from '@twin.org/core';
|
|
1
|
+
import { Factory, Is, GeneralError, Urn, Guards } from '@twin.org/core';
|
|
2
2
|
import { DidVerificationMethodType, ProofHelper } from '@twin.org/standards-w3c-did';
|
|
3
3
|
import { Jwt, Jwk } from '@twin.org/web';
|
|
4
4
|
|
|
@@ -116,6 +116,46 @@ class DocumentHelper {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// Copyright 2024 IOTA Stiftung.
|
|
120
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
121
|
+
/**
|
|
122
|
+
* Helper methods for Ids.
|
|
123
|
+
*/
|
|
124
|
+
class IdHelper {
|
|
125
|
+
/**
|
|
126
|
+
* Runtime name for the class.
|
|
127
|
+
*/
|
|
128
|
+
static CLASS_NAME = "IdHelper";
|
|
129
|
+
/**
|
|
130
|
+
* Parse and id in to it's constituent parts.
|
|
131
|
+
* @param id The id to parse.
|
|
132
|
+
* @returns The parsed id.
|
|
133
|
+
* @throws GeneralError if the id is not valid.
|
|
134
|
+
*/
|
|
135
|
+
static parseId(id) {
|
|
136
|
+
Urn.guard(IdHelper.CLASS_NAME, "id", id);
|
|
137
|
+
const didUrn = Urn.fromValidString(id);
|
|
138
|
+
const didParts = didUrn.parts();
|
|
139
|
+
if (didParts[0] !== "did") {
|
|
140
|
+
throw new GeneralError(IdHelper.CLASS_NAME, "invalidDocumentId", { id });
|
|
141
|
+
}
|
|
142
|
+
if (didParts.length === 3) {
|
|
143
|
+
return {
|
|
144
|
+
method: didParts[1],
|
|
145
|
+
id: didParts[2]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
else if (didParts.length === 4) {
|
|
149
|
+
return {
|
|
150
|
+
method: didParts[1],
|
|
151
|
+
network: didParts[2],
|
|
152
|
+
id: didParts[3]
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
throw new GeneralError(IdHelper.CLASS_NAME, "invalidDocumentId", { id });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
119
159
|
// Copyright 2024 IOTA Stiftung.
|
|
120
160
|
// SPDX-License-Identifier: Apache-2.0.
|
|
121
161
|
/**
|
|
@@ -191,4 +231,4 @@ class VerificationHelper {
|
|
|
191
231
|
}
|
|
192
232
|
}
|
|
193
233
|
|
|
194
|
-
export { DocumentHelper, IdentityConnectorFactory, IdentityProfileConnectorFactory, IdentityResolverConnectorFactory, VerificationHelper };
|
|
234
|
+
export { DocumentHelper, IdHelper, IdentityConnectorFactory, IdentityProfileConnectorFactory, IdentityResolverConnectorFactory, VerificationHelper };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -41,4 +41,5 @@ export * from "./models/IIdentityProfileConnector";
|
|
|
41
41
|
export * from "./models/IIdentityResolverComponent";
|
|
42
42
|
export * from "./models/IIdentityResolverConnector";
|
|
43
43
|
export * from "./utils/documentHelper";
|
|
44
|
+
export * from "./utils/idHelper";
|
|
44
45
|
export * from "./utils/verificationHelper";
|
|
@@ -50,13 +50,13 @@ export interface IIdentityProfileComponent<T extends IJsonLdDocument = IJsonLdDo
|
|
|
50
50
|
* @param publicFilters The filters to apply to the identities public profiles.
|
|
51
51
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
52
52
|
* @param cursor The cursor for paged requests.
|
|
53
|
-
* @param
|
|
53
|
+
* @param limit The maximum number of items in a page.
|
|
54
54
|
* @returns The list of items and cursor for paging.
|
|
55
55
|
*/
|
|
56
56
|
list(publicFilters?: {
|
|
57
57
|
propertyName: string;
|
|
58
58
|
propertyValue: unknown;
|
|
59
|
-
}[], publicPropertyNames?: (keyof T)[], cursor?: string,
|
|
59
|
+
}[], publicPropertyNames?: (keyof T)[], cursor?: string, limit?: number): Promise<{
|
|
60
60
|
/**
|
|
61
61
|
* The identities.
|
|
62
62
|
*/
|
|
@@ -44,7 +44,7 @@ export interface IIdentityProfileConnector<T extends IJsonLdDocument = IJsonLdDo
|
|
|
44
44
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
45
45
|
* @param privatePropertyNames The private properties to get for the profile, defaults to all.
|
|
46
46
|
* @param cursor The cursor for paged requests.
|
|
47
|
-
* @param
|
|
47
|
+
* @param limit The maximum number of items in a page.
|
|
48
48
|
* @returns The list of items and cursor for paging.
|
|
49
49
|
*/
|
|
50
50
|
list(publicFilters?: {
|
|
@@ -53,7 +53,7 @@ export interface IIdentityProfileConnector<T extends IJsonLdDocument = IJsonLdDo
|
|
|
53
53
|
}[], privateFilters?: {
|
|
54
54
|
propertyName: string;
|
|
55
55
|
propertyValue: unknown;
|
|
56
|
-
}[], publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], cursor?: string,
|
|
56
|
+
}[], publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], cursor?: string, limit?: number): Promise<{
|
|
57
57
|
/**
|
|
58
58
|
* The identity profiles.
|
|
59
59
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper methods for Ids.
|
|
3
|
+
*/
|
|
4
|
+
export declare class IdHelper {
|
|
5
|
+
/**
|
|
6
|
+
* Runtime name for the class.
|
|
7
|
+
*/
|
|
8
|
+
static readonly CLASS_NAME: string;
|
|
9
|
+
/**
|
|
10
|
+
* Parse and id in to it's constituent parts.
|
|
11
|
+
* @param id The id to parse.
|
|
12
|
+
* @returns The parsed id.
|
|
13
|
+
* @throws GeneralError if the id is not valid.
|
|
14
|
+
*/
|
|
15
|
+
static parseId(id: string): {
|
|
16
|
+
method: string;
|
|
17
|
+
network?: string | undefined;
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/identity-service-models - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.9](https://github.com/twinfoundation/identity/compare/identity-models-v0.0.2-next.8...identity-models-v0.0.2-next.9) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/identity/compare/identity-models-v0.0.2-next.7...identity-models-v0.0.2-next.8) (2025-09-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add idHelper class ([57c8bdb](https://github.com/twinfoundation/identity/commit/57c8bdb81efaa163b5e83f8a7f16f3764d12fd75))
|
|
16
|
+
|
|
3
17
|
## [0.0.2-next.7](https://github.com/twinfoundation/identity/compare/identity-models-v0.0.2-next.6...identity-models-v0.0.2-next.7) (2025-09-23)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Class: IdHelper
|
|
2
|
+
|
|
3
|
+
Helper methods for Ids.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new IdHelper**(): `IdHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`IdHelper`
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### parseId()
|
|
26
|
+
|
|
27
|
+
> `static` **parseId**(`id`): `object`
|
|
28
|
+
|
|
29
|
+
Parse and id in to it's constituent parts.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### id
|
|
34
|
+
|
|
35
|
+
`string`
|
|
36
|
+
|
|
37
|
+
The id to parse.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`object`
|
|
42
|
+
|
|
43
|
+
The parsed id.
|
|
44
|
+
|
|
45
|
+
##### method
|
|
46
|
+
|
|
47
|
+
> **method**: `string`
|
|
48
|
+
|
|
49
|
+
##### network?
|
|
50
|
+
|
|
51
|
+
> `optional` **network**: `string`
|
|
52
|
+
|
|
53
|
+
##### id
|
|
54
|
+
|
|
55
|
+
> **id**: `string`
|
|
56
|
+
|
|
57
|
+
#### Throws
|
|
58
|
+
|
|
59
|
+
GeneralError if the id is not valid.
|
package/docs/reference/index.md
CHANGED
|
@@ -6,6 +6,14 @@ Interface describing a contract which provides identity operations.
|
|
|
6
6
|
|
|
7
7
|
- `IComponent`
|
|
8
8
|
|
|
9
|
+
## Indexable
|
|
10
|
+
|
|
11
|
+
\[`key`: `string`\]: `any`
|
|
12
|
+
|
|
13
|
+
All methods are optional, so we introduce an index signature to allow
|
|
14
|
+
any additional properties or methods, which removes the TypeScript error where
|
|
15
|
+
the class has no properties in common with the type.
|
|
16
|
+
|
|
9
17
|
## Methods
|
|
10
18
|
|
|
11
19
|
### identityCreate()
|
|
@@ -6,6 +6,14 @@ Interface describing an identity connector.
|
|
|
6
6
|
|
|
7
7
|
- `IComponent`
|
|
8
8
|
|
|
9
|
+
## Indexable
|
|
10
|
+
|
|
11
|
+
\[`key`: `string`\]: `any`
|
|
12
|
+
|
|
13
|
+
All methods are optional, so we introduce an index signature to allow
|
|
14
|
+
any additional properties or methods, which removes the TypeScript error where
|
|
15
|
+
the class has no properties in common with the type.
|
|
16
|
+
|
|
9
17
|
## Methods
|
|
10
18
|
|
|
11
19
|
### createDocument()
|
|
@@ -16,6 +16,14 @@ Interface describing a contract which provides profile operations.
|
|
|
16
16
|
|
|
17
17
|
`U` *extends* `IJsonLdDocument` = `IJsonLdDocument`
|
|
18
18
|
|
|
19
|
+
## Indexable
|
|
20
|
+
|
|
21
|
+
\[`key`: `string`\]: `any`
|
|
22
|
+
|
|
23
|
+
All methods are optional, so we introduce an index signature to allow
|
|
24
|
+
any additional properties or methods, which removes the TypeScript error where
|
|
25
|
+
the class has no properties in common with the type.
|
|
26
|
+
|
|
19
27
|
## Methods
|
|
20
28
|
|
|
21
29
|
### create()
|
|
@@ -172,7 +180,7 @@ Nothing.
|
|
|
172
180
|
|
|
173
181
|
### list()
|
|
174
182
|
|
|
175
|
-
> **list**(`publicFilters?`, `publicPropertyNames?`, `cursor?`, `
|
|
183
|
+
> **list**(`publicFilters?`, `publicPropertyNames?`, `cursor?`, `limit?`): `Promise`\<\{ `items`: `object`[]; `cursor?`: `string`; \}\>
|
|
176
184
|
|
|
177
185
|
Get a list of the requested identities.
|
|
178
186
|
|
|
@@ -196,7 +204,7 @@ The public properties to get for the profile, defaults to all.
|
|
|
196
204
|
|
|
197
205
|
The cursor for paged requests.
|
|
198
206
|
|
|
199
|
-
#####
|
|
207
|
+
##### limit?
|
|
200
208
|
|
|
201
209
|
`number`
|
|
202
210
|
|
|
@@ -16,6 +16,14 @@ Interface describing a contract which provides profile operations.
|
|
|
16
16
|
|
|
17
17
|
`U` *extends* `IJsonLdDocument` = `IJsonLdDocument`
|
|
18
18
|
|
|
19
|
+
## Indexable
|
|
20
|
+
|
|
21
|
+
\[`key`: `string`\]: `any`
|
|
22
|
+
|
|
23
|
+
All methods are optional, so we introduce an index signature to allow
|
|
24
|
+
any additional properties or methods, which removes the TypeScript error where
|
|
25
|
+
the class has no properties in common with the type.
|
|
26
|
+
|
|
19
27
|
## Methods
|
|
20
28
|
|
|
21
29
|
### create()
|
|
@@ -144,7 +152,7 @@ Nothing.
|
|
|
144
152
|
|
|
145
153
|
### list()
|
|
146
154
|
|
|
147
|
-
> **list**(`publicFilters?`, `privateFilters?`, `publicPropertyNames?`, `privatePropertyNames?`, `cursor?`, `
|
|
155
|
+
> **list**(`publicFilters?`, `privateFilters?`, `publicPropertyNames?`, `privatePropertyNames?`, `cursor?`, `limit?`): `Promise`\<\{ `items`: `object`[]; `cursor?`: `string`; \}\>
|
|
148
156
|
|
|
149
157
|
Get a list of the requested identities.
|
|
150
158
|
|
|
@@ -180,7 +188,7 @@ The private properties to get for the profile, defaults to all.
|
|
|
180
188
|
|
|
181
189
|
The cursor for paged requests.
|
|
182
190
|
|
|
183
|
-
#####
|
|
191
|
+
##### limit?
|
|
184
192
|
|
|
185
193
|
`number`
|
|
186
194
|
|
|
@@ -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.
|
|
@@ -6,6 +6,14 @@ Interface describing a contract which provides identity operations.
|
|
|
6
6
|
|
|
7
7
|
- `IComponent`
|
|
8
8
|
|
|
9
|
+
## Indexable
|
|
10
|
+
|
|
11
|
+
\[`key`: `string`\]: `any`
|
|
12
|
+
|
|
13
|
+
All methods are optional, so we introduce an index signature to allow
|
|
14
|
+
any additional properties or methods, which removes the TypeScript error where
|
|
15
|
+
the class has no properties in common with the type.
|
|
16
|
+
|
|
9
17
|
## Methods
|
|
10
18
|
|
|
11
19
|
### identityResolve()
|
|
@@ -6,6 +6,14 @@ Interface describing an identity connector.
|
|
|
6
6
|
|
|
7
7
|
- `IComponent`
|
|
8
8
|
|
|
9
|
+
## Indexable
|
|
10
|
+
|
|
11
|
+
\[`key`: `string`\]: `any`
|
|
12
|
+
|
|
13
|
+
All methods are optional, so we introduce an index signature to allow
|
|
14
|
+
any additional properties or methods, which removes the TypeScript error where
|
|
15
|
+
the class has no properties in common with the type.
|
|
16
|
+
|
|
9
17
|
## Methods
|
|
10
18
|
|
|
11
19
|
### resolveDocument()
|
package/locales/en.json
CHANGED
|
@@ -2,18 +2,14 @@
|
|
|
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
|
+
"idHelper": {
|
|
12
|
+
"invalidDocumentId": "The document id \"{id}\" is invalid"
|
|
11
13
|
}
|
|
12
|
-
},
|
|
13
|
-
"verifiableCredentialStates": {
|
|
14
|
-
"pendingVerification": "Pending Verification",
|
|
15
|
-
"rejected": "Rejected",
|
|
16
|
-
"issued": "Issued",
|
|
17
|
-
"revoked": "Revoked"
|
|
18
14
|
}
|
|
19
15
|
}
|
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.9",
|
|
4
4
|
"description": "Models which define the structure of the contracts and connectors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,5 +38,23 @@
|
|
|
38
38
|
"dist/types",
|
|
39
39
|
"locales",
|
|
40
40
|
"docs"
|
|
41
|
-
]
|
|
41
|
+
],
|
|
42
|
+
"keywords": [
|
|
43
|
+
"twin",
|
|
44
|
+
"trade",
|
|
45
|
+
"iota",
|
|
46
|
+
"framework",
|
|
47
|
+
"blockchain",
|
|
48
|
+
"identity",
|
|
49
|
+
"did",
|
|
50
|
+
"credentials",
|
|
51
|
+
"authentication",
|
|
52
|
+
"models",
|
|
53
|
+
"types",
|
|
54
|
+
"schemas"
|
|
55
|
+
],
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "git+https://github.com/twinfoundation/identity/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://twindev.org"
|
|
42
60
|
}
|