@twin.org/identity-models 0.0.1-next.10
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/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +71 -0
- package/dist/esm/index.mjs +66 -0
- package/dist/types/factories/identityConnectorFactory.d.ts +6 -0
- package/dist/types/factories/identityProfileConnectorFactory.d.ts +6 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/models/IIdentityComponent.d.ts +13 -0
- package/dist/types/models/IIdentityConnector.d.ts +145 -0
- package/dist/types/models/IIdentityProfileComponent.d.ts +72 -0
- package/dist/types/models/IIdentityProfileConnector.d.ts +70 -0
- package/dist/types/models/api/IIdentityProfileCreateRequest.d.ts +19 -0
- package/dist/types/models/api/IIdentityProfileGetPublicRequest.d.ts +23 -0
- package/dist/types/models/api/IIdentityProfileGetPublicResponse.d.ts +17 -0
- package/dist/types/models/api/IIdentityProfileGetRequest.d.ts +18 -0
- package/dist/types/models/api/IIdentityProfileGetResponse.d.ts +23 -0
- package/dist/types/models/api/IIdentityProfileListRequest.d.ts +26 -0
- package/dist/types/models/api/IIdentityProfileListResponse.d.ts +28 -0
- package/dist/types/models/api/IIdentityProfileUpdateRequest.d.ts +19 -0
- package/dist/types/models/api/IIdentityResolveRequest.d.ts +14 -0
- package/dist/types/models/api/IIdentityResolveResponse.d.ts +10 -0
- package/dist/types/models/identityRole.d.ts +21 -0
- package/dist/types/utils/documentHelper.d.ts +14 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/DocumentHelper.md +41 -0
- package/docs/reference/index.md +32 -0
- package/docs/reference/interfaces/IIdentityComponent.md +27 -0
- package/docs/reference/interfaces/IIdentityConnector.md +495 -0
- package/docs/reference/interfaces/IIdentityProfileComponent.md +197 -0
- package/docs/reference/interfaces/IIdentityProfileConnector.md +177 -0
- package/docs/reference/interfaces/IIdentityProfileCreateRequest.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileGetPublicRequest.md +31 -0
- package/docs/reference/interfaces/IIdentityProfileGetPublicResponse.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileGetRequest.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileGetResponse.md +29 -0
- package/docs/reference/interfaces/IIdentityProfileListRequest.md +35 -0
- package/docs/reference/interfaces/IIdentityProfileListResponse.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileUpdateRequest.md +23 -0
- package/docs/reference/interfaces/IIdentityResolveRequest.md +17 -0
- package/docs/reference/interfaces/IIdentityResolveResponse.md +11 -0
- package/docs/reference/type-aliases/IdentityRole.md +5 -0
- package/docs/reference/variables/IdentityConnectorFactory.md +5 -0
- package/docs/reference/variables/IdentityProfileConnectorFactory.md +5 -0
- package/docs/reference/variables/IdentityRole.md +25 -0
- package/locales/en.json +13 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 IOTA Stiftung.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# TWIN Identity Service Models
|
|
2
|
+
|
|
3
|
+
Models which define the structure of the service implementations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @twin.org/identity-service-models
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
|
|
14
|
+
|
|
15
|
+
## Reference
|
|
16
|
+
|
|
17
|
+
Detailed reference documentation for the API can be found in [docs/reference/index.md](docs/reference/index.md)
|
|
18
|
+
|
|
19
|
+
## Changelog
|
|
20
|
+
|
|
21
|
+
The changes between each version can be found in [docs/changelog.md](docs/changelog.md)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@twin.org/core');
|
|
4
|
+
|
|
5
|
+
// Copyright 2024 IOTA Stiftung.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
7
|
+
/**
|
|
8
|
+
* Factory for creating identity connectors.
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11
|
+
const IdentityConnectorFactory = core.Factory.createFactory("identity-connector");
|
|
12
|
+
|
|
13
|
+
// Copyright 2024 IOTA Stiftung.
|
|
14
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
15
|
+
/**
|
|
16
|
+
* Factory for creating identity profile connectors.
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
+
const IdentityProfileConnectorFactory = core.Factory.createFactory("identity-profile-connector");
|
|
20
|
+
|
|
21
|
+
// Copyright 2024 IOTA Stiftung.
|
|
22
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
23
|
+
/**
|
|
24
|
+
* The roles that an identity can have.
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
const IdentityRole = {
|
|
28
|
+
/**
|
|
29
|
+
* Node.
|
|
30
|
+
*/
|
|
31
|
+
Node: "node",
|
|
32
|
+
/**
|
|
33
|
+
* Organization.
|
|
34
|
+
*/
|
|
35
|
+
Organization: "organization",
|
|
36
|
+
/**
|
|
37
|
+
* User.
|
|
38
|
+
*/
|
|
39
|
+
User: "user"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Copyright 2024 IOTA Stiftung.
|
|
43
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
44
|
+
/**
|
|
45
|
+
* Helper methods for documents.
|
|
46
|
+
*/
|
|
47
|
+
class DocumentHelper {
|
|
48
|
+
/**
|
|
49
|
+
* Parse the document id into its parts.
|
|
50
|
+
* @param documentId The full document id.
|
|
51
|
+
* @returns The parsed document id.
|
|
52
|
+
*/
|
|
53
|
+
static parse(documentId) {
|
|
54
|
+
if (!core.Is.stringValue(documentId)) {
|
|
55
|
+
return {
|
|
56
|
+
id: "",
|
|
57
|
+
hash: ""
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const hashIndex = documentId.indexOf("#");
|
|
61
|
+
return {
|
|
62
|
+
id: hashIndex === -1 ? documentId : documentId.slice(0, hashIndex),
|
|
63
|
+
hash: hashIndex === -1 ? undefined : documentId.slice(hashIndex + 1)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.DocumentHelper = DocumentHelper;
|
|
69
|
+
exports.IdentityConnectorFactory = IdentityConnectorFactory;
|
|
70
|
+
exports.IdentityProfileConnectorFactory = IdentityProfileConnectorFactory;
|
|
71
|
+
exports.IdentityRole = IdentityRole;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Factory, Is } from '@twin.org/core';
|
|
2
|
+
|
|
3
|
+
// Copyright 2024 IOTA Stiftung.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
5
|
+
/**
|
|
6
|
+
* Factory for creating identity connectors.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
+
const IdentityConnectorFactory = Factory.createFactory("identity-connector");
|
|
10
|
+
|
|
11
|
+
// Copyright 2024 IOTA Stiftung.
|
|
12
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
13
|
+
/**
|
|
14
|
+
* Factory for creating identity profile connectors.
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
|
+
const IdentityProfileConnectorFactory = Factory.createFactory("identity-profile-connector");
|
|
18
|
+
|
|
19
|
+
// Copyright 2024 IOTA Stiftung.
|
|
20
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
21
|
+
/**
|
|
22
|
+
* The roles that an identity can have.
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
|
+
const IdentityRole = {
|
|
26
|
+
/**
|
|
27
|
+
* Node.
|
|
28
|
+
*/
|
|
29
|
+
Node: "node",
|
|
30
|
+
/**
|
|
31
|
+
* Organization.
|
|
32
|
+
*/
|
|
33
|
+
Organization: "organization",
|
|
34
|
+
/**
|
|
35
|
+
* User.
|
|
36
|
+
*/
|
|
37
|
+
User: "user"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Copyright 2024 IOTA Stiftung.
|
|
41
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
42
|
+
/**
|
|
43
|
+
* Helper methods for documents.
|
|
44
|
+
*/
|
|
45
|
+
class DocumentHelper {
|
|
46
|
+
/**
|
|
47
|
+
* Parse the document id into its parts.
|
|
48
|
+
* @param documentId The full document id.
|
|
49
|
+
* @returns The parsed document id.
|
|
50
|
+
*/
|
|
51
|
+
static parse(documentId) {
|
|
52
|
+
if (!Is.stringValue(documentId)) {
|
|
53
|
+
return {
|
|
54
|
+
id: "",
|
|
55
|
+
hash: ""
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const hashIndex = documentId.indexOf("#");
|
|
59
|
+
return {
|
|
60
|
+
id: hashIndex === -1 ? documentId : documentId.slice(0, hashIndex),
|
|
61
|
+
hash: hashIndex === -1 ? undefined : documentId.slice(hashIndex + 1)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { DocumentHelper, IdentityConnectorFactory, IdentityProfileConnectorFactory, IdentityRole };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Factory } from "@twin.org/core";
|
|
2
|
+
import type { IIdentityProfileConnector } from "../models/IIdentityProfileConnector";
|
|
3
|
+
/**
|
|
4
|
+
* Factory for creating identity profile connectors.
|
|
5
|
+
*/
|
|
6
|
+
export declare const IdentityProfileConnectorFactory: Factory<IIdentityProfileConnector<import("@twin.org/data-json-ld").IJsonLdDocument, import("@twin.org/data-json-ld").IJsonLdDocument>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./factories/identityConnectorFactory";
|
|
2
|
+
export * from "./factories/identityProfileConnectorFactory";
|
|
3
|
+
export * from "./models/api/IIdentityProfileCreateRequest";
|
|
4
|
+
export * from "./models/api/IIdentityProfileGetPublicRequest";
|
|
5
|
+
export * from "./models/api/IIdentityProfileGetPublicResponse";
|
|
6
|
+
export * from "./models/api/IIdentityProfileGetRequest";
|
|
7
|
+
export * from "./models/api/IIdentityProfileGetResponse";
|
|
8
|
+
export * from "./models/api/IIdentityProfileListRequest";
|
|
9
|
+
export * from "./models/api/IIdentityProfileListResponse";
|
|
10
|
+
export * from "./models/api/IIdentityProfileUpdateRequest";
|
|
11
|
+
export * from "./models/api/IIdentityResolveRequest";
|
|
12
|
+
export * from "./models/api/IIdentityResolveResponse";
|
|
13
|
+
export * from "./models/identityRole";
|
|
14
|
+
export * from "./models/IIdentityComponent";
|
|
15
|
+
export * from "./models/IIdentityConnector";
|
|
16
|
+
export * from "./models/IIdentityProfileComponent";
|
|
17
|
+
export * from "./models/IIdentityProfileConnector";
|
|
18
|
+
export * from "./utils/documentHelper";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IDidDocument } from "@twin.org/standards-w3c-did";
|
|
3
|
+
/**
|
|
4
|
+
* Interface describing a contract which provides identity operations.
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdentityComponent extends IComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Resolve an identity.
|
|
9
|
+
* @param documentId The id of the document to resolve.
|
|
10
|
+
* @returns The resolved document.
|
|
11
|
+
*/
|
|
12
|
+
resolve(documentId: string): Promise<IDidDocument>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IJsonLdContextDefinitionRoot, IJsonLdObject } from "@twin.org/data-json-ld";
|
|
3
|
+
import type { DidVerificationMethodType, IDidDocument, IDidDocumentVerificationMethod, IDidService, IDidVerifiableCredential, IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
|
|
4
|
+
/**
|
|
5
|
+
* Interface describing an identity connector.
|
|
6
|
+
*/
|
|
7
|
+
export interface IIdentityConnector extends IComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new document.
|
|
10
|
+
* @param controller The controller of the identity who can make changes.
|
|
11
|
+
* @returns The created document.
|
|
12
|
+
*/
|
|
13
|
+
createDocument(controller: string): Promise<IDidDocument>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a document from its id.
|
|
16
|
+
* @param documentId The id of the document to resolve.
|
|
17
|
+
* @returns The resolved document.
|
|
18
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
19
|
+
*/
|
|
20
|
+
resolveDocument(documentId: string): Promise<IDidDocument>;
|
|
21
|
+
/**
|
|
22
|
+
* Add a verification method to the document in JSON Web key Format.
|
|
23
|
+
* @param controller The controller of the identity who can make changes.
|
|
24
|
+
* @param documentId The id of the document to add the verification method to.
|
|
25
|
+
* @param verificationMethodType The type of the verification method to add.
|
|
26
|
+
* @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.
|
|
27
|
+
* @returns The verification method.
|
|
28
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
29
|
+
* @throws NotSupportedError if the platform does not support multiple keys.
|
|
30
|
+
*/
|
|
31
|
+
addVerificationMethod(controller: string, documentId: string, verificationMethodType: DidVerificationMethodType, verificationMethodId?: string): Promise<IDidDocumentVerificationMethod>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove a verification method from the document.
|
|
34
|
+
* @param controller The controller of the identity who can make changes.
|
|
35
|
+
* @param verificationMethodId The id of the verification method.
|
|
36
|
+
* @returns Nothing.
|
|
37
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
38
|
+
* @throws NotSupportedError if the platform does not support multiple revocable keys.
|
|
39
|
+
*/
|
|
40
|
+
removeVerificationMethod(controller: string, verificationMethodId: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Add a service to the document.
|
|
43
|
+
* @param controller The controller of the identity who can make changes.
|
|
44
|
+
* @param documentId The id of the document to add the service to.
|
|
45
|
+
* @param serviceId The id of the service.
|
|
46
|
+
* @param serviceType The type of the service.
|
|
47
|
+
* @param serviceEndpoint The endpoint for the service.
|
|
48
|
+
* @returns The service.
|
|
49
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
50
|
+
*/
|
|
51
|
+
addService(controller: string, documentId: string, serviceId: string, serviceType: string, serviceEndpoint: string): Promise<IDidService>;
|
|
52
|
+
/**
|
|
53
|
+
* Remove a service from the document.
|
|
54
|
+
* @param controller The controller of the identity who can make changes.
|
|
55
|
+
* @param serviceId The id of the service.
|
|
56
|
+
* @returns Nothing.
|
|
57
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
58
|
+
*/
|
|
59
|
+
removeService(controller: string, serviceId: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Create a verifiable credential for a verification method.
|
|
62
|
+
* @param controller The controller of the identity who can make changes.
|
|
63
|
+
* @param verificationMethodId The verification method id to use.
|
|
64
|
+
* @param id The id of the credential.
|
|
65
|
+
* @param credential The credential to store in the verifiable credential.
|
|
66
|
+
* @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
67
|
+
* @returns The created verifiable credential and its token.
|
|
68
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
69
|
+
*/
|
|
70
|
+
createVerifiableCredential<T extends IJsonLdObject = IJsonLdObject>(controller: string, verificationMethodId: string, id: string | undefined, credential: T, revocationIndex?: number): Promise<{
|
|
71
|
+
verifiableCredential: IDidVerifiableCredential<T>;
|
|
72
|
+
jwt: string;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Check a verifiable credential is valid.
|
|
76
|
+
* @param credentialJwt The credential to verify.
|
|
77
|
+
* @returns The credential stored in the jwt and the revocation status.
|
|
78
|
+
*/
|
|
79
|
+
checkVerifiableCredential<T extends IJsonLdObject = IJsonLdObject>(credentialJwt: string): Promise<{
|
|
80
|
+
revoked: boolean;
|
|
81
|
+
verifiableCredential?: IDidVerifiableCredential<T>;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Revoke verifiable credential(s).
|
|
85
|
+
* @param controller The controller of the identity who can make changes.
|
|
86
|
+
* @param issuerDocumentId The id of the document to update the revocation list for.
|
|
87
|
+
* @param credentialIndices The revocation bitmap index or indices to revoke.
|
|
88
|
+
* @returns Nothing.
|
|
89
|
+
*/
|
|
90
|
+
revokeVerifiableCredentials(controller: string, issuerDocumentId: string, credentialIndices: number[]): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Unrevoke verifiable credential(s).
|
|
93
|
+
* @param controller The controller of the identity who can make changes.
|
|
94
|
+
* @param issuerDocumentId The id of the document to update the revocation list for.
|
|
95
|
+
* @param credentialIndices The revocation bitmap index or indices to un revoke.
|
|
96
|
+
* @returns Nothing.
|
|
97
|
+
*/
|
|
98
|
+
unrevokeVerifiableCredentials(controller: string, issuerDocumentId: string, credentialIndices: number[]): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a verifiable presentation from the supplied verifiable credentials.
|
|
101
|
+
* @param controller The controller of the identity who can make changes.
|
|
102
|
+
* @param presentationMethodId The method to associate with the presentation.
|
|
103
|
+
* @param presentationId The id of the presentation.
|
|
104
|
+
* @param contexts The contexts for the data stored in the verifiable credential.
|
|
105
|
+
* @param types The types for the data stored in the verifiable credential.
|
|
106
|
+
* @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
|
|
107
|
+
* @param expiresInMinutes The time in minutes for the presentation to expire.
|
|
108
|
+
* @returns The created verifiable presentation and its token.
|
|
109
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
110
|
+
*/
|
|
111
|
+
createVerifiablePresentation<T extends IJsonLdObject = IJsonLdObject>(controller: string, presentationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential<T>)[], expiresInMinutes?: number): Promise<{
|
|
112
|
+
verifiablePresentation: IDidVerifiablePresentation<T>;
|
|
113
|
+
jwt: string;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Check a verifiable presentation is valid.
|
|
117
|
+
* @param presentationJwt The presentation to verify.
|
|
118
|
+
* @returns The presentation stored in the jwt and the revocation status.
|
|
119
|
+
*/
|
|
120
|
+
checkVerifiablePresentation<T extends IJsonLdObject = IJsonLdObject>(presentationJwt: string): Promise<{
|
|
121
|
+
revoked: boolean;
|
|
122
|
+
verifiablePresentation?: IDidVerifiablePresentation<T>;
|
|
123
|
+
issuers?: IDidDocument[];
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Create a proof for arbitrary data with the specified verification method.
|
|
127
|
+
* @param controller The controller of the identity who can make changes.
|
|
128
|
+
* @param verificationMethodId The verification method id to use.
|
|
129
|
+
* @param bytes The data bytes to sign.
|
|
130
|
+
* @returns The proof signature type and value.
|
|
131
|
+
*/
|
|
132
|
+
createProof(controller: string, verificationMethodId: string, bytes: Uint8Array): Promise<{
|
|
133
|
+
type: string;
|
|
134
|
+
value: Uint8Array;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Verify proof for arbitrary data with the specified verification method.
|
|
138
|
+
* @param verificationMethodId The verification method id to use.
|
|
139
|
+
* @param bytes The data bytes to verify.
|
|
140
|
+
* @param signatureType The type of the signature for the proof.
|
|
141
|
+
* @param signatureValue The value of the signature for the proof.
|
|
142
|
+
* @returns True if the signature is valid.
|
|
143
|
+
*/
|
|
144
|
+
verifyProof(verificationMethodId: string, bytes: Uint8Array, signatureType: string, signatureValue: Uint8Array): Promise<boolean>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
3
|
+
/**
|
|
4
|
+
* Interface describing a contract which provides profile operations.
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdentityProfileComponent<T extends IJsonLdDocument = IJsonLdDocument, U extends IJsonLdDocument = IJsonLdDocument> extends IComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Create the profile properties for an identity.
|
|
9
|
+
* @param publicProfile The public profile data as JSON-LD.
|
|
10
|
+
* @param privateProfile The private profile data as JSON-LD.
|
|
11
|
+
* @param identity The identity to perform the profile operation on.
|
|
12
|
+
* @returns Nothing.
|
|
13
|
+
*/
|
|
14
|
+
create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the profile properties for an identity.
|
|
17
|
+
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
18
|
+
* @param privatePropertyNames The private properties to get for the profile, defaults to all.
|
|
19
|
+
* @param identity The identity to perform the profile operation on.
|
|
20
|
+
* @returns The items identity and the properties.
|
|
21
|
+
*/
|
|
22
|
+
get(publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], identity?: string): Promise<{
|
|
23
|
+
identity: string;
|
|
24
|
+
publicProfile?: Partial<T>;
|
|
25
|
+
privateProfile?: Partial<U>;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the public profile properties for an identity.
|
|
29
|
+
* @param identity The identity to perform the profile operation on.
|
|
30
|
+
* @param propertyNames The public properties to get for the profile, defaults to all.
|
|
31
|
+
* @returns The items properties.
|
|
32
|
+
*/
|
|
33
|
+
getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* Update the profile properties of an identity.
|
|
36
|
+
* @param publicProfile The public profile data as JSON-LD.
|
|
37
|
+
* @param privateProfile The private profile data as JSON-LD.
|
|
38
|
+
* @param identity The identity to perform the profile operation on.
|
|
39
|
+
* @returns Nothing.
|
|
40
|
+
*/
|
|
41
|
+
update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete the profile for an identity.
|
|
44
|
+
* @param identity The identity to perform the profile operation on.
|
|
45
|
+
* @returns Nothing.
|
|
46
|
+
*/
|
|
47
|
+
remove(identity?: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Get a list of the requested identities.
|
|
50
|
+
* @param publicFilters The filters to apply to the identities public profiles.
|
|
51
|
+
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
52
|
+
* @param cursor The cursor for paged requests.
|
|
53
|
+
* @param pageSize The maximum number of items in a page.
|
|
54
|
+
* @returns The list of items and cursor for paging.
|
|
55
|
+
*/
|
|
56
|
+
list(publicFilters?: {
|
|
57
|
+
propertyName: string;
|
|
58
|
+
propertyValue: unknown;
|
|
59
|
+
}[], publicPropertyNames?: (keyof T)[], cursor?: string, pageSize?: number): Promise<{
|
|
60
|
+
/**
|
|
61
|
+
* The identities.
|
|
62
|
+
*/
|
|
63
|
+
items: {
|
|
64
|
+
identity: string;
|
|
65
|
+
publicProfile?: Partial<T>;
|
|
66
|
+
}[];
|
|
67
|
+
/**
|
|
68
|
+
* An optional cursor, when defined can be used to call find to get more entities.
|
|
69
|
+
*/
|
|
70
|
+
cursor?: string;
|
|
71
|
+
}>;
|
|
72
|
+
}
|