@twin.org/identity-models 0.0.1-next.3

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 (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +71 -0
  4. package/dist/esm/index.mjs +66 -0
  5. package/dist/types/factories/identityConnectorFactory.d.ts +6 -0
  6. package/dist/types/factories/identityProfileConnectorFactory.d.ts +6 -0
  7. package/dist/types/index.d.ts +18 -0
  8. package/dist/types/models/IIdentityComponent.d.ts +13 -0
  9. package/dist/types/models/IIdentityConnector.d.ts +145 -0
  10. package/dist/types/models/IIdentityProfileComponent.d.ts +72 -0
  11. package/dist/types/models/IIdentityProfileConnector.d.ts +70 -0
  12. package/dist/types/models/api/IIdentityProfileCreateRequest.d.ts +19 -0
  13. package/dist/types/models/api/IIdentityProfileGetPublicRequest.d.ts +23 -0
  14. package/dist/types/models/api/IIdentityProfileGetPublicResponse.d.ts +17 -0
  15. package/dist/types/models/api/IIdentityProfileGetRequest.d.ts +18 -0
  16. package/dist/types/models/api/IIdentityProfileGetResponse.d.ts +23 -0
  17. package/dist/types/models/api/IIdentityProfileListRequest.d.ts +26 -0
  18. package/dist/types/models/api/IIdentityProfileListResponse.d.ts +28 -0
  19. package/dist/types/models/api/IIdentityProfileUpdateRequest.d.ts +19 -0
  20. package/dist/types/models/api/IIdentityResolveRequest.d.ts +14 -0
  21. package/dist/types/models/api/IIdentityResolveResponse.d.ts +10 -0
  22. package/dist/types/models/identityRole.d.ts +21 -0
  23. package/dist/types/utils/documentHelper.d.ts +14 -0
  24. package/docs/changelog.md +5 -0
  25. package/docs/examples.md +1 -0
  26. package/docs/reference/classes/DocumentHelper.md +41 -0
  27. package/docs/reference/index.md +32 -0
  28. package/docs/reference/interfaces/IIdentityComponent.md +27 -0
  29. package/docs/reference/interfaces/IIdentityConnector.md +491 -0
  30. package/docs/reference/interfaces/IIdentityProfileComponent.md +197 -0
  31. package/docs/reference/interfaces/IIdentityProfileConnector.md +177 -0
  32. package/docs/reference/interfaces/IIdentityProfileCreateRequest.md +23 -0
  33. package/docs/reference/interfaces/IIdentityProfileGetPublicRequest.md +31 -0
  34. package/docs/reference/interfaces/IIdentityProfileGetPublicResponse.md +23 -0
  35. package/docs/reference/interfaces/IIdentityProfileGetRequest.md +23 -0
  36. package/docs/reference/interfaces/IIdentityProfileGetResponse.md +29 -0
  37. package/docs/reference/interfaces/IIdentityProfileListRequest.md +35 -0
  38. package/docs/reference/interfaces/IIdentityProfileListResponse.md +23 -0
  39. package/docs/reference/interfaces/IIdentityProfileUpdateRequest.md +23 -0
  40. package/docs/reference/interfaces/IIdentityResolveRequest.md +17 -0
  41. package/docs/reference/interfaces/IIdentityResolveResponse.md +11 -0
  42. package/docs/reference/type-aliases/IdentityRole.md +5 -0
  43. package/docs/reference/variables/IdentityConnectorFactory.md +5 -0
  44. package/docs/reference/variables/IdentityProfileConnectorFactory.md +5 -0
  45. package/docs/reference/variables/IdentityRole.md +25 -0
  46. package/locales/en.json +13 -0
  47. package/package.json +68 -0
@@ -0,0 +1,177 @@
1
+ # Interface: IIdentityProfileConnector\<T, U\>
2
+
3
+ Interface describing a contract which provides profile operations.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Type Parameters
10
+
11
+ • **T** *extends* `IJsonLdDocument` = `IJsonLdDocument`
12
+
13
+ • **U** *extends* `IJsonLdDocument` = `IJsonLdDocument`
14
+
15
+ ## Methods
16
+
17
+ ### create()
18
+
19
+ > **create**(`identity`, `publicProfile`?, `privateProfile`?): `Promise`\<`void`\>
20
+
21
+ Create the profile properties for an identity.
22
+
23
+ #### Parameters
24
+
25
+ • **identity**: `string`
26
+
27
+ The identity of the profile to create.
28
+
29
+ • **publicProfile?**: `T`
30
+
31
+ The public profile data as JSON-LD.
32
+
33
+ • **privateProfile?**: `U`
34
+
35
+ The private profile data as JSON-LD.
36
+
37
+ #### Returns
38
+
39
+ `Promise`\<`void`\>
40
+
41
+ Nothing.
42
+
43
+ ***
44
+
45
+ ### get()
46
+
47
+ > **get**(`identity`, `publicPropertyNames`?, `privatePropertyNames`?): `Promise`\<`object`\>
48
+
49
+ Get the profile properties for an identity.
50
+
51
+ #### Parameters
52
+
53
+ • **identity**: `string`
54
+
55
+ The identity of the item to get.
56
+
57
+ • **publicPropertyNames?**: keyof `T`[]
58
+
59
+ The public properties to get for the profile, defaults to all.
60
+
61
+ • **privatePropertyNames?**: keyof `U`[]
62
+
63
+ The private properties to get for the profile, defaults to all.
64
+
65
+ #### Returns
66
+
67
+ `Promise`\<`object`\>
68
+
69
+ The identity profile, will only return private data if you have correct permissions.
70
+
71
+ ##### publicProfile
72
+
73
+ > **publicProfile**: `Partial`\<`T`\>
74
+
75
+ ##### privateProfile
76
+
77
+ > **privateProfile**: `Partial`\<`U`\>
78
+
79
+ ***
80
+
81
+ ### update()
82
+
83
+ > **update**(`identity`, `publicProfile`?, `privateProfile`?): `Promise`\<`void`\>
84
+
85
+ Update the profile properties of an identity.
86
+
87
+ #### Parameters
88
+
89
+ • **identity**: `string`
90
+
91
+ The identity to update.
92
+
93
+ • **publicProfile?**: `T`
94
+
95
+ The public profile data as JSON-LD.
96
+
97
+ • **privateProfile?**: `U`
98
+
99
+ The private profile data as JSON-LD.
100
+
101
+ #### Returns
102
+
103
+ `Promise`\<`void`\>
104
+
105
+ Nothing.
106
+
107
+ ***
108
+
109
+ ### remove()
110
+
111
+ > **remove**(`identity`): `Promise`\<`void`\>
112
+
113
+ Delete the profile for an identity.
114
+
115
+ #### Parameters
116
+
117
+ • **identity**: `string`
118
+
119
+ The identity to delete.
120
+
121
+ #### Returns
122
+
123
+ `Promise`\<`void`\>
124
+
125
+ Nothing.
126
+
127
+ ***
128
+
129
+ ### list()
130
+
131
+ > **list**(`publicFilters`?, `privateFilters`?, `publicPropertyNames`?, `privatePropertyNames`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
132
+
133
+ Get a list of the requested identities.
134
+
135
+ #### Parameters
136
+
137
+ • **publicFilters?**: `object`[]
138
+
139
+ The filters to apply to the identities public profiles.
140
+
141
+ • **privateFilters?**: `object`[]
142
+
143
+ The filters to apply to the identities private profiles.
144
+
145
+ • **publicPropertyNames?**: keyof `T`[]
146
+
147
+ The public properties to get for the profile, defaults to all.
148
+
149
+ • **privatePropertyNames?**: keyof `U`[]
150
+
151
+ The private properties to get for the profile, defaults to all.
152
+
153
+ • **cursor?**: `string`
154
+
155
+ The cursor for paged requests.
156
+
157
+ • **pageSize?**: `number`
158
+
159
+ The maximum number of items in a page.
160
+
161
+ #### Returns
162
+
163
+ `Promise`\<`object`\>
164
+
165
+ The list of items and cursor for paging.
166
+
167
+ ##### items
168
+
169
+ > **items**: `object`[]
170
+
171
+ The identity profiles.
172
+
173
+ ##### cursor?
174
+
175
+ > `optional` **cursor**: `string`
176
+
177
+ An optional cursor, when defined can be used to call find to get more entities.
@@ -0,0 +1,23 @@
1
+ # Interface: IIdentityProfileCreateRequest
2
+
3
+ Request to create an identity profile.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The data for the request.
12
+
13
+ #### publicProfile?
14
+
15
+ > `optional` **publicProfile**: `IJsonLdDocument`
16
+
17
+ The public profile data.
18
+
19
+ #### privateProfile?
20
+
21
+ > `optional` **privateProfile**: `IJsonLdDocument`
22
+
23
+ The private profile data.
@@ -0,0 +1,31 @@
1
+ # Interface: IIdentityProfileGetPublicRequest
2
+
3
+ Get the public profile for an identity.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### identity
14
+
15
+ > **identity**: `string`
16
+
17
+ The identity to get the profile for.
18
+
19
+ ***
20
+
21
+ ### query?
22
+
23
+ > `optional` **query**: `object`
24
+
25
+ The query parameters.
26
+
27
+ #### propertyNames?
28
+
29
+ > `optional` **propertyNames**: `string`
30
+
31
+ The properties to get for the public profile, defaults to all, should be a comma separated list.
@@ -0,0 +1,23 @@
1
+ # Interface: IIdentityProfileGetPublicResponse
2
+
3
+ Response to get an identity public profile.
4
+
5
+ ## Properties
6
+
7
+ ### headers
8
+
9
+ > **headers**: `object`
10
+
11
+ The response headers.
12
+
13
+ #### Content-Type
14
+
15
+ > **Content-Type**: `"application/ld+json"`
16
+
17
+ ***
18
+
19
+ ### body
20
+
21
+ > **body**: `Partial`\<`IJsonLdDocument`\>
22
+
23
+ The response payload.
@@ -0,0 +1,23 @@
1
+ # Interface: IIdentityProfileGetRequest
2
+
3
+ Get the profile for an identity.
4
+
5
+ ## Properties
6
+
7
+ ### query?
8
+
9
+ > `optional` **query**: `object`
10
+
11
+ The query parameters.
12
+
13
+ #### publicPropertyNames?
14
+
15
+ > `optional` **publicPropertyNames**: `string`
16
+
17
+ The public properties to get for the profile, defaults to all, should be a comma separated list.
18
+
19
+ #### privatePropertyNames?
20
+
21
+ > `optional` **privatePropertyNames**: `string`
22
+
23
+ The private properties to get for the profile, defaults to all, should be a comma separated list.
@@ -0,0 +1,29 @@
1
+ # Interface: IIdentityProfileGetResponse
2
+
3
+ Response to get an identity details.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The response payload.
12
+
13
+ #### identity
14
+
15
+ > **identity**: `string`
16
+
17
+ The identity of the profile, this is the authenticated user identity.
18
+
19
+ #### publicProfile?
20
+
21
+ > `optional` **publicProfile**: `Partial`\<`IJsonLdDocument`\>
22
+
23
+ The public profile data.
24
+
25
+ #### privateProfile?
26
+
27
+ > `optional` **privateProfile**: `Partial`\<`IJsonLdDocument`\>
28
+
29
+ The private profile data.
@@ -0,0 +1,35 @@
1
+ # Interface: IIdentityProfileListRequest
2
+
3
+ Request to get a list of identities.
4
+
5
+ ## Properties
6
+
7
+ ### query?
8
+
9
+ > `optional` **query**: `object`
10
+
11
+ The query parameters.
12
+
13
+ #### publicFilters?
14
+
15
+ > `optional` **publicFilters**: `string`
16
+
17
+ The public filters to apply to the list, comma separated list with color between key and value for each pair e.g. prop1:value1,prop2:value2.
18
+
19
+ #### publicPropertyNames?
20
+
21
+ > `optional` **publicPropertyNames**: `string`
22
+
23
+ The public properties to get for the profile, defaults to all, should be a comma separated list.
24
+
25
+ #### cursor?
26
+
27
+ > `optional` **cursor**: `string`
28
+
29
+ The cursor for paged requests.
30
+
31
+ #### pageSize?
32
+
33
+ > `optional` **pageSize**: `number`
34
+
35
+ Number of items to return.
@@ -0,0 +1,23 @@
1
+ # Interface: IIdentityProfileListResponse
2
+
3
+ Response to get a list of identities.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The response payload.
12
+
13
+ #### items
14
+
15
+ > **items**: `object`[]
16
+
17
+ The identities.
18
+
19
+ #### cursor?
20
+
21
+ > `optional` **cursor**: `string`
22
+
23
+ An optional cursor, when defined can be used to call find to get more entities.
@@ -0,0 +1,23 @@
1
+ # Interface: IIdentityProfileUpdateRequest
2
+
3
+ Request to update an identity profile.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The data for the request.
12
+
13
+ #### publicProfile?
14
+
15
+ > `optional` **publicProfile**: `IJsonLdDocument`
16
+
17
+ The public profile data.
18
+
19
+ #### privateProfile?
20
+
21
+ > `optional` **privateProfile**: `IJsonLdDocument`
22
+
23
+ The private profile data.
@@ -0,0 +1,17 @@
1
+ # Interface: IIdentityResolveRequest
2
+
3
+ Resolve an identity.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The identity to get the document for.
@@ -0,0 +1,11 @@
1
+ # Interface: IIdentityResolveResponse
2
+
3
+ Response to resolving an identity.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `IDidDocument`
10
+
11
+ The response payload.
@@ -0,0 +1,5 @@
1
+ # Type Alias: IdentityRole
2
+
3
+ > **IdentityRole**: *typeof* [`IdentityRole`](../variables/IdentityRole.md)\[keyof *typeof* [`IdentityRole`](../variables/IdentityRole.md)\]
4
+
5
+ The roles that an identity can have.
@@ -0,0 +1,5 @@
1
+ # Variable: IdentityConnectorFactory
2
+
3
+ > `const` **IdentityConnectorFactory**: `Factory`\<[`IIdentityConnector`](../interfaces/IIdentityConnector.md)\>
4
+
5
+ Factory for creating identity connectors.
@@ -0,0 +1,5 @@
1
+ # Variable: IdentityProfileConnectorFactory
2
+
3
+ > `const` **IdentityProfileConnectorFactory**: `Factory`\<[`IIdentityProfileConnector`](../interfaces/IIdentityProfileConnector.md)\<`IJsonLdDocument`, `IJsonLdDocument`\>\>
4
+
5
+ Factory for creating identity profile connectors.
@@ -0,0 +1,25 @@
1
+ # Variable: IdentityRole
2
+
3
+ > `const` **IdentityRole**: `object`
4
+
5
+ The roles that an identity can have.
6
+
7
+ ## Type declaration
8
+
9
+ ### Node
10
+
11
+ > `readonly` **Node**: `"node"` = `"node"`
12
+
13
+ Node.
14
+
15
+ ### Organization
16
+
17
+ > `readonly` **Organization**: `"organization"` = `"organization"`
18
+
19
+ Organization.
20
+
21
+ ### User
22
+
23
+ > `readonly` **User**: `"user"` = `"user"`
24
+
25
+ User.
@@ -0,0 +1,13 @@
1
+ {
2
+ "identityRole": {
3
+ "organization": "Organization",
4
+ "user": "User",
5
+ "node": "Node"
6
+ },
7
+ "verifiableCredentialStates": {
8
+ "pendingVerification": "Pending Verification",
9
+ "rejected": "Rejected",
10
+ "issued": "Issued",
11
+ "revoked": "Revoked"
12
+ }
13
+ }
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@twin.org/identity-models",
3
+ "version": "0.0.1-next.3",
4
+ "description": "Models which define the structure of the contracts and connectors",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/identity.git",
8
+ "directory": "packages/identity-models"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage docs/reference",
18
+ "build": "tspc",
19
+ "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
+ "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
+ "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
+ "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
+ "bundle": "npm run bundle:esm && npm run bundle:cjs",
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 test && npm run bundle && npm run docs"
28
+ },
29
+ "dependencies": {
30
+ "@twin.org/core": "next",
31
+ "@twin.org/data-core": "next",
32
+ "@twin.org/data-json-ld": "next",
33
+ "@twin.org/entity": "next",
34
+ "@twin.org/standards-w3c-did": "next",
35
+ "@twin.org/web": "next"
36
+ },
37
+ "devDependencies": {
38
+ "@twin.org/nameof-transformer": "next",
39
+ "@vitest/coverage-v8": "2.1.1",
40
+ "copyfiles": "2.4.1",
41
+ "rimraf": "6.0.1",
42
+ "rollup": "4.22.0",
43
+ "rollup-plugin-typescript2": "0.36.0",
44
+ "ts-patch": "3.2.1",
45
+ "typedoc": "0.26.7",
46
+ "typedoc-plugin-markdown": "4.2.7",
47
+ "typescript": "5.6.2",
48
+ "vitest": "2.1.1"
49
+ },
50
+ "main": "./dist/cjs/index.cjs",
51
+ "module": "./dist/esm/index.mjs",
52
+ "types": "./dist/types/index.d.ts",
53
+ "exports": {
54
+ ".": {
55
+ "require": "./dist/cjs/index.cjs",
56
+ "import": "./dist/esm/index.mjs",
57
+ "types": "./dist/types/index.d.ts"
58
+ },
59
+ "./locales": "./locales"
60
+ },
61
+ "files": [
62
+ "dist/cjs",
63
+ "dist/esm",
64
+ "dist/types",
65
+ "locales",
66
+ "docs"
67
+ ]
68
+ }