@twin.org/attestation-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 (34) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +13 -0
  4. package/dist/esm/index.mjs +11 -0
  5. package/dist/types/factories/attestationConnectorFactory.d.ts +6 -0
  6. package/dist/types/index.d.ts +12 -0
  7. package/dist/types/models/IAttestationComponent.d.ts +42 -0
  8. package/dist/types/models/IAttestationConnector.d.ts +42 -0
  9. package/dist/types/models/IAttestationInformation.d.ts +34 -0
  10. package/dist/types/models/IAttestationProof.d.ts +13 -0
  11. package/dist/types/models/api/IAttestationAttestRequest.d.ts +22 -0
  12. package/dist/types/models/api/IAttestationAttestResponse.d.ts +12 -0
  13. package/dist/types/models/api/IAttestationDestroyRequest.d.ts +14 -0
  14. package/dist/types/models/api/IAttestationTransferRequest.d.ts +23 -0
  15. package/dist/types/models/api/IAttestationTransferResponse.d.ts +15 -0
  16. package/dist/types/models/api/IAttestationVerifyRequest.d.ts +14 -0
  17. package/dist/types/models/api/IAttestationVerifyResponse.d.ts +23 -0
  18. package/docs/changelog.md +5 -0
  19. package/docs/examples.md +1 -0
  20. package/docs/reference/index.md +19 -0
  21. package/docs/reference/interfaces/IAttestationAttestRequest.md +29 -0
  22. package/docs/reference/interfaces/IAttestationAttestResponse.md +15 -0
  23. package/docs/reference/interfaces/IAttestationComponent.md +139 -0
  24. package/docs/reference/interfaces/IAttestationConnector.md +139 -0
  25. package/docs/reference/interfaces/IAttestationDestroyRequest.md +17 -0
  26. package/docs/reference/interfaces/IAttestationInformation.md +63 -0
  27. package/docs/reference/interfaces/IAttestationProof.md +19 -0
  28. package/docs/reference/interfaces/IAttestationTransferRequest.md +31 -0
  29. package/docs/reference/interfaces/IAttestationTransferResponse.md +17 -0
  30. package/docs/reference/interfaces/IAttestationVerifyRequest.md +17 -0
  31. package/docs/reference/interfaces/IAttestationVerifyResponse.md +29 -0
  32. package/docs/reference/variables/AttestationConnectorFactory.md +5 -0
  33. package/locales/en.json +3 -0
  34. package/package.json +66 -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 Attestation Models
2
+
3
+ Models which define the structure of the attestation contracts and connectors.
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ npm install @twin.org/attestation-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,13 @@
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 attestation connectors.
9
+ */
10
+ // eslint-disable-next-line @typescript-eslint/naming-convention
11
+ const AttestationConnectorFactory = core.Factory.createFactory("attestation");
12
+
13
+ exports.AttestationConnectorFactory = AttestationConnectorFactory;
@@ -0,0 +1,11 @@
1
+ import { Factory } from '@twin.org/core';
2
+
3
+ // Copyright 2024 IOTA Stiftung.
4
+ // SPDX-License-Identifier: Apache-2.0.
5
+ /**
6
+ * Factory for creating attestation connectors.
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
+ const AttestationConnectorFactory = Factory.createFactory("attestation");
10
+
11
+ export { AttestationConnectorFactory };
@@ -0,0 +1,6 @@
1
+ import { Factory } from "@twin.org/core";
2
+ import type { IAttestationConnector } from "../models/IAttestationConnector";
3
+ /**
4
+ * Factory for creating attestation connectors.
5
+ */
6
+ export declare const AttestationConnectorFactory: Factory<IAttestationConnector>;
@@ -0,0 +1,12 @@
1
+ export * from "./factories/attestationConnectorFactory";
2
+ export * from "./models/IAttestationComponent";
3
+ export * from "./models/IAttestationConnector";
4
+ export * from "./models/IAttestationInformation";
5
+ export * from "./models/IAttestationProof";
6
+ export * from "./models/api/IAttestationAttestRequest";
7
+ export * from "./models/api/IAttestationAttestResponse";
8
+ export * from "./models/api/IAttestationDestroyRequest";
9
+ export * from "./models/api/IAttestationTransferRequest";
10
+ export * from "./models/api/IAttestationTransferResponse";
11
+ export * from "./models/api/IAttestationVerifyRequest";
12
+ export * from "./models/api/IAttestationVerifyResponse";
@@ -0,0 +1,42 @@
1
+ import type { IComponent } from "@twin.org/core";
2
+ import type { IAttestationInformation } from "./IAttestationInformation";
3
+ /**
4
+ * Interface describing an attestation contract.
5
+ */
6
+ export interface IAttestationComponent extends IComponent {
7
+ /**
8
+ * Attest the data and return the collated information.
9
+ * @param verificationMethodId The identity verification method to use for attesting the data.
10
+ * @param data The data to attest.
11
+ * @param namespace The namespace of the connector to use for the attestation, defaults to component configured namespace.
12
+ * @param identity The identity to perform the attestation operation with.
13
+ * @param nodeIdentity The node identity to include in the attestation.
14
+ * @returns The collated attestation data.
15
+ */
16
+ attest<T = unknown>(verificationMethodId: string, data: T, namespace?: string, identity?: string, nodeIdentity?: string): Promise<IAttestationInformation<T>>;
17
+ /**
18
+ * Resolve and verify the attestation id.
19
+ * @param attestationId The attestation id to verify.
20
+ * @returns The verified attestation details.
21
+ */
22
+ verify<T = unknown>(attestationId: string): Promise<{
23
+ verified: boolean;
24
+ failure?: string;
25
+ information?: Partial<IAttestationInformation<T>>;
26
+ }>;
27
+ /**
28
+ * Transfer the attestation to a new holder.
29
+ * @param attestationId The attestation to transfer.
30
+ * @param holderIdentity The identity to transfer the attestation to.
31
+ * @param identity The identity to perform the attestation operation with.
32
+ * @returns The updated attestation details.
33
+ */
34
+ transfer<T = unknown>(attestationId: string, holderIdentity: string, identity?: string): Promise<IAttestationInformation<T>>;
35
+ /**
36
+ * Destroy the attestation.
37
+ * @param attestationId The attestation to transfer.
38
+ * @param identity The identity to perform the attestation operation with.
39
+ * @returns The updated attestation details.
40
+ */
41
+ destroy(attestationId: string, identity?: string): Promise<void>;
42
+ }
@@ -0,0 +1,42 @@
1
+ import type { IComponent } from "@twin.org/core";
2
+ import type { IAttestationInformation } from "./IAttestationInformation";
3
+ /**
4
+ * Interface describing an attestation connector.
5
+ */
6
+ export interface IAttestationConnector extends IComponent {
7
+ /**
8
+ * Attest the data and return the collated information.
9
+ * @param controller The controller identity of the user to access the vault keys.
10
+ * @param address The controller address for the attestation.
11
+ * @param verificationMethodId The identity verification method to use for attesting the data.
12
+ * @param data The data to attest.
13
+ * @returns The collated attestation data.
14
+ */
15
+ attest<T = unknown>(controller: string, address: string, verificationMethodId: string, data: T): Promise<IAttestationInformation<T>>;
16
+ /**
17
+ * Resolve and verify the attestation id.
18
+ * @param attestationId The attestation id to verify.
19
+ * @returns The verified attestation details.
20
+ */
21
+ verify<T = unknown>(attestationId: string): Promise<{
22
+ verified: boolean;
23
+ failure?: string;
24
+ information?: Partial<IAttestationInformation<T>>;
25
+ }>;
26
+ /**
27
+ * Transfer the attestation to a new holder.
28
+ * @param controller The controller identity of the user to access the vault keys.
29
+ * @param attestationId The attestation to transfer.
30
+ * @param holderIdentity The holder identity of the attestation.
31
+ * @param holderAddress The new controller address of the attestation belonging to the holder.
32
+ * @returns The updated attestation details.
33
+ */
34
+ transfer<T = unknown>(controller: string, attestationId: string, holderIdentity: string, holderAddress: string): Promise<IAttestationInformation<T>>;
35
+ /**
36
+ * Destroy the attestation.
37
+ * @param controller The controller identity of the user to access the vault keys.
38
+ * @param attestationId The attestation to destroy.
39
+ * @returns Nothing.
40
+ */
41
+ destroy(controller: string, attestationId: string): Promise<void>;
42
+ }
@@ -0,0 +1,34 @@
1
+ import type { IAttestationProof } from "./IAttestationProof";
2
+ /**
3
+ * Interface describing the collated attestation information.
4
+ */
5
+ export interface IAttestationInformation<T = unknown> {
6
+ /**
7
+ * The unique identifier of the attestation.
8
+ */
9
+ id: string;
10
+ /**
11
+ * Created date/time of the attestation in ISO format.
12
+ */
13
+ created: string;
14
+ /**
15
+ * The identity of the owner.
16
+ */
17
+ ownerIdentity: string;
18
+ /**
19
+ * Transferred date/time of the attestation in ISO format, can be blank if holder identity is owner.
20
+ */
21
+ transferred?: string;
22
+ /**
23
+ * The identity of the current holder, can be undefined if owner is still the holder.
24
+ */
25
+ holderIdentity?: string;
26
+ /**
27
+ * The data that was attested.
28
+ */
29
+ data: T;
30
+ /**
31
+ * The proof for the attested data.
32
+ */
33
+ proof: IAttestationProof;
34
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Interface describing an attestation proof.
3
+ */
4
+ export interface IAttestationProof {
5
+ /**
6
+ * The type of the proof.
7
+ */
8
+ type: string;
9
+ /**
10
+ * The value of the proof.
11
+ */
12
+ value: string;
13
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Attest the data and return the collated attestation details.
3
+ */
4
+ export interface IAttestationAttestRequest {
5
+ /**
6
+ * The data to be used in the signing.
7
+ */
8
+ body: {
9
+ /**
10
+ * The identity verification method to use for attesting the data.
11
+ */
12
+ verificationMethodId: string;
13
+ /**
14
+ * The data object to attest.
15
+ */
16
+ data: unknown;
17
+ /**
18
+ * The namespace of the connector to use for the attestation, defaults to component configured namespace.
19
+ */
20
+ namespace?: string;
21
+ };
22
+ }
@@ -0,0 +1,12 @@
1
+ import type { IAttestationInformation } from "../IAttestationInformation";
2
+ /**
3
+ * The response when creating the attestation for some data.
4
+ */
5
+ export interface IAttestationAttestResponse {
6
+ /**
7
+ * The result of the attestation process.
8
+ */
9
+ body: {
10
+ information: IAttestationInformation;
11
+ };
12
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Destroy the attestation.
3
+ */
4
+ export interface IAttestationDestroyRequest {
5
+ /**
6
+ * The parameters to be used in the destruction.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The attestation id to destroy.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Transfer the attestation to a new holder.
3
+ */
4
+ export interface IAttestationTransferRequest {
5
+ /**
6
+ * The parameters to be used in the transfer.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The attestation id to verify.
11
+ */
12
+ id: string;
13
+ };
14
+ /**
15
+ * The parameters to be used in the transfer.
16
+ */
17
+ body: {
18
+ /**
19
+ * The new holder identity.
20
+ */
21
+ holderIdentity: string;
22
+ };
23
+ }
@@ -0,0 +1,15 @@
1
+ import type { IAttestationInformation } from "../IAttestationInformation";
2
+ /**
3
+ * The response to transferring the attestation.
4
+ */
5
+ export interface IAttestationTransferResponse {
6
+ /**
7
+ * The data returned from the transfer response.
8
+ */
9
+ body: {
10
+ /**
11
+ * The updated attestation information.
12
+ */
13
+ information: IAttestationInformation;
14
+ };
15
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Verify that the proof is valid for the attestation.
3
+ */
4
+ export interface IAttestationVerifyRequest {
5
+ /**
6
+ * The parameters to be used in the verification.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The attestation id to verify.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,23 @@
1
+ import type { IAttestationInformation } from "../IAttestationInformation";
2
+ /**
3
+ * The response to verifying the attestation.
4
+ */
5
+ export interface IAttestationVerifyResponse {
6
+ /**
7
+ * The data returned from the verification response.
8
+ */
9
+ body: {
10
+ /**
11
+ * Whether the attestation is verified.
12
+ */
13
+ verified: boolean;
14
+ /**
15
+ * The failure message if the attestation is not verified.
16
+ */
17
+ failure?: string;
18
+ /**
19
+ * The attestation information.
20
+ */
21
+ information?: Partial<IAttestationInformation>;
22
+ };
23
+ }
@@ -0,0 +1,5 @@
1
+ # @twin.org/attestation-models - Changelog
2
+
3
+ ## v0.0.1-next.3
4
+
5
+ - Initial Release
@@ -0,0 +1 @@
1
+ # @twin.org/attestation-models - Examples
@@ -0,0 +1,19 @@
1
+ # @twin.org/attestation-models
2
+
3
+ ## Interfaces
4
+
5
+ - [IAttestationComponent](interfaces/IAttestationComponent.md)
6
+ - [IAttestationConnector](interfaces/IAttestationConnector.md)
7
+ - [IAttestationInformation](interfaces/IAttestationInformation.md)
8
+ - [IAttestationProof](interfaces/IAttestationProof.md)
9
+ - [IAttestationAttestRequest](interfaces/IAttestationAttestRequest.md)
10
+ - [IAttestationAttestResponse](interfaces/IAttestationAttestResponse.md)
11
+ - [IAttestationDestroyRequest](interfaces/IAttestationDestroyRequest.md)
12
+ - [IAttestationTransferRequest](interfaces/IAttestationTransferRequest.md)
13
+ - [IAttestationTransferResponse](interfaces/IAttestationTransferResponse.md)
14
+ - [IAttestationVerifyRequest](interfaces/IAttestationVerifyRequest.md)
15
+ - [IAttestationVerifyResponse](interfaces/IAttestationVerifyResponse.md)
16
+
17
+ ## Variables
18
+
19
+ - [AttestationConnectorFactory](variables/AttestationConnectorFactory.md)
@@ -0,0 +1,29 @@
1
+ # Interface: IAttestationAttestRequest
2
+
3
+ Attest the data and return the collated attestation details.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The data to be used in the signing.
12
+
13
+ #### verificationMethodId
14
+
15
+ > **verificationMethodId**: `string`
16
+
17
+ The identity verification method to use for attesting the data.
18
+
19
+ #### data
20
+
21
+ > **data**: `unknown`
22
+
23
+ The data object to attest.
24
+
25
+ #### namespace?
26
+
27
+ > `optional` **namespace**: `string`
28
+
29
+ The namespace of the connector to use for the attestation, defaults to component configured namespace.
@@ -0,0 +1,15 @@
1
+ # Interface: IAttestationAttestResponse
2
+
3
+ The response when creating the attestation for some data.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The result of the attestation process.
12
+
13
+ #### information
14
+
15
+ > **information**: [`IAttestationInformation`](IAttestationInformation.md)\<`unknown`\>
@@ -0,0 +1,139 @@
1
+ # Interface: IAttestationComponent
2
+
3
+ Interface describing an attestation contract.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### attest()
12
+
13
+ > **attest**\<`T`\>(`verificationMethodId`, `data`, `namespace`?, `identity`?, `nodeIdentity`?): `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
14
+
15
+ Attest the data and return the collated information.
16
+
17
+ #### Type Parameters
18
+
19
+ • **T** = `unknown`
20
+
21
+ #### Parameters
22
+
23
+ • **verificationMethodId**: `string`
24
+
25
+ The identity verification method to use for attesting the data.
26
+
27
+ • **data**: `T`
28
+
29
+ The data to attest.
30
+
31
+ • **namespace?**: `string`
32
+
33
+ The namespace of the connector to use for the attestation, defaults to component configured namespace.
34
+
35
+ • **identity?**: `string`
36
+
37
+ The identity to perform the attestation operation with.
38
+
39
+ • **nodeIdentity?**: `string`
40
+
41
+ The node identity to include in the attestation.
42
+
43
+ #### Returns
44
+
45
+ `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
46
+
47
+ The collated attestation data.
48
+
49
+ ***
50
+
51
+ ### verify()
52
+
53
+ > **verify**\<`T`\>(`attestationId`): `Promise`\<`object`\>
54
+
55
+ Resolve and verify the attestation id.
56
+
57
+ #### Type Parameters
58
+
59
+ • **T** = `unknown`
60
+
61
+ #### Parameters
62
+
63
+ • **attestationId**: `string`
64
+
65
+ The attestation id to verify.
66
+
67
+ #### Returns
68
+
69
+ `Promise`\<`object`\>
70
+
71
+ The verified attestation details.
72
+
73
+ ##### verified
74
+
75
+ > **verified**: `boolean`
76
+
77
+ ##### failure?
78
+
79
+ > `optional` **failure**: `string`
80
+
81
+ ##### information?
82
+
83
+ > `optional` **information**: `Partial`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
84
+
85
+ ***
86
+
87
+ ### transfer()
88
+
89
+ > **transfer**\<`T`\>(`attestationId`, `holderIdentity`, `identity`?): `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
90
+
91
+ Transfer the attestation to a new holder.
92
+
93
+ #### Type Parameters
94
+
95
+ • **T** = `unknown`
96
+
97
+ #### Parameters
98
+
99
+ • **attestationId**: `string`
100
+
101
+ The attestation to transfer.
102
+
103
+ • **holderIdentity**: `string`
104
+
105
+ The identity to transfer the attestation to.
106
+
107
+ • **identity?**: `string`
108
+
109
+ The identity to perform the attestation operation with.
110
+
111
+ #### Returns
112
+
113
+ `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
114
+
115
+ The updated attestation details.
116
+
117
+ ***
118
+
119
+ ### destroy()
120
+
121
+ > **destroy**(`attestationId`, `identity`?): `Promise`\<`void`\>
122
+
123
+ Destroy the attestation.
124
+
125
+ #### Parameters
126
+
127
+ • **attestationId**: `string`
128
+
129
+ The attestation to transfer.
130
+
131
+ • **identity?**: `string`
132
+
133
+ The identity to perform the attestation operation with.
134
+
135
+ #### Returns
136
+
137
+ `Promise`\<`void`\>
138
+
139
+ The updated attestation details.
@@ -0,0 +1,139 @@
1
+ # Interface: IAttestationConnector
2
+
3
+ Interface describing an attestation connector.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### attest()
12
+
13
+ > **attest**\<`T`\>(`controller`, `address`, `verificationMethodId`, `data`): `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
14
+
15
+ Attest the data and return the collated information.
16
+
17
+ #### Type Parameters
18
+
19
+ • **T** = `unknown`
20
+
21
+ #### Parameters
22
+
23
+ • **controller**: `string`
24
+
25
+ The controller identity of the user to access the vault keys.
26
+
27
+ • **address**: `string`
28
+
29
+ The controller address for the attestation.
30
+
31
+ • **verificationMethodId**: `string`
32
+
33
+ The identity verification method to use for attesting the data.
34
+
35
+ • **data**: `T`
36
+
37
+ The data to attest.
38
+
39
+ #### Returns
40
+
41
+ `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
42
+
43
+ The collated attestation data.
44
+
45
+ ***
46
+
47
+ ### verify()
48
+
49
+ > **verify**\<`T`\>(`attestationId`): `Promise`\<`object`\>
50
+
51
+ Resolve and verify the attestation id.
52
+
53
+ #### Type Parameters
54
+
55
+ • **T** = `unknown`
56
+
57
+ #### Parameters
58
+
59
+ • **attestationId**: `string`
60
+
61
+ The attestation id to verify.
62
+
63
+ #### Returns
64
+
65
+ `Promise`\<`object`\>
66
+
67
+ The verified attestation details.
68
+
69
+ ##### verified
70
+
71
+ > **verified**: `boolean`
72
+
73
+ ##### failure?
74
+
75
+ > `optional` **failure**: `string`
76
+
77
+ ##### information?
78
+
79
+ > `optional` **information**: `Partial`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
80
+
81
+ ***
82
+
83
+ ### transfer()
84
+
85
+ > **transfer**\<`T`\>(`controller`, `attestationId`, `holderIdentity`, `holderAddress`): `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
86
+
87
+ Transfer the attestation to a new holder.
88
+
89
+ #### Type Parameters
90
+
91
+ • **T** = `unknown`
92
+
93
+ #### Parameters
94
+
95
+ • **controller**: `string`
96
+
97
+ The controller identity of the user to access the vault keys.
98
+
99
+ • **attestationId**: `string`
100
+
101
+ The attestation to transfer.
102
+
103
+ • **holderIdentity**: `string`
104
+
105
+ The holder identity of the attestation.
106
+
107
+ • **holderAddress**: `string`
108
+
109
+ The new controller address of the attestation belonging to the holder.
110
+
111
+ #### Returns
112
+
113
+ `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\<`T`\>\>
114
+
115
+ The updated attestation details.
116
+
117
+ ***
118
+
119
+ ### destroy()
120
+
121
+ > **destroy**(`controller`, `attestationId`): `Promise`\<`void`\>
122
+
123
+ Destroy the attestation.
124
+
125
+ #### Parameters
126
+
127
+ • **controller**: `string`
128
+
129
+ The controller identity of the user to access the vault keys.
130
+
131
+ • **attestationId**: `string`
132
+
133
+ The attestation to destroy.
134
+
135
+ #### Returns
136
+
137
+ `Promise`\<`void`\>
138
+
139
+ Nothing.
@@ -0,0 +1,17 @@
1
+ # Interface: IAttestationDestroyRequest
2
+
3
+ Destroy the attestation.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The parameters to be used in the destruction.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The attestation id to destroy.
@@ -0,0 +1,63 @@
1
+ # Interface: IAttestationInformation\<T\>
2
+
3
+ Interface describing the collated attestation information.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T** = `unknown`
8
+
9
+ ## Properties
10
+
11
+ ### id
12
+
13
+ > **id**: `string`
14
+
15
+ The unique identifier of the attestation.
16
+
17
+ ***
18
+
19
+ ### created
20
+
21
+ > **created**: `string`
22
+
23
+ Created date/time of the attestation in ISO format.
24
+
25
+ ***
26
+
27
+ ### ownerIdentity
28
+
29
+ > **ownerIdentity**: `string`
30
+
31
+ The identity of the owner.
32
+
33
+ ***
34
+
35
+ ### transferred?
36
+
37
+ > `optional` **transferred**: `string`
38
+
39
+ Transferred date/time of the attestation in ISO format, can be blank if holder identity is owner.
40
+
41
+ ***
42
+
43
+ ### holderIdentity?
44
+
45
+ > `optional` **holderIdentity**: `string`
46
+
47
+ The identity of the current holder, can be undefined if owner is still the holder.
48
+
49
+ ***
50
+
51
+ ### data
52
+
53
+ > **data**: `T`
54
+
55
+ The data that was attested.
56
+
57
+ ***
58
+
59
+ ### proof
60
+
61
+ > **proof**: [`IAttestationProof`](IAttestationProof.md)
62
+
63
+ The proof for the attested data.
@@ -0,0 +1,19 @@
1
+ # Interface: IAttestationProof
2
+
3
+ Interface describing an attestation proof.
4
+
5
+ ## Properties
6
+
7
+ ### type
8
+
9
+ > **type**: `string`
10
+
11
+ The type of the proof.
12
+
13
+ ***
14
+
15
+ ### value
16
+
17
+ > **value**: `string`
18
+
19
+ The value of the proof.
@@ -0,0 +1,31 @@
1
+ # Interface: IAttestationTransferRequest
2
+
3
+ Transfer the attestation to a new holder.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The parameters to be used in the transfer.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The attestation id to verify.
18
+
19
+ ***
20
+
21
+ ### body
22
+
23
+ > **body**: `object`
24
+
25
+ The parameters to be used in the transfer.
26
+
27
+ #### holderIdentity
28
+
29
+ > **holderIdentity**: `string`
30
+
31
+ The new holder identity.
@@ -0,0 +1,17 @@
1
+ # Interface: IAttestationTransferResponse
2
+
3
+ The response to transferring the attestation.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The data returned from the transfer response.
12
+
13
+ #### information
14
+
15
+ > **information**: [`IAttestationInformation`](IAttestationInformation.md)\<`unknown`\>
16
+
17
+ The updated attestation information.
@@ -0,0 +1,17 @@
1
+ # Interface: IAttestationVerifyRequest
2
+
3
+ Verify that the proof is valid for the attestation.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The parameters to be used in the verification.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The attestation id to verify.
@@ -0,0 +1,29 @@
1
+ # Interface: IAttestationVerifyResponse
2
+
3
+ The response to verifying the attestation.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The data returned from the verification response.
12
+
13
+ #### verified
14
+
15
+ > **verified**: `boolean`
16
+
17
+ Whether the attestation is verified.
18
+
19
+ #### failure?
20
+
21
+ > `optional` **failure**: `string`
22
+
23
+ The failure message if the attestation is not verified.
24
+
25
+ #### information?
26
+
27
+ > `optional` **information**: `Partial`\<[`IAttestationInformation`](IAttestationInformation.md)\<`unknown`\>\>
28
+
29
+ The attestation information.
@@ -0,0 +1,5 @@
1
+ # Variable: AttestationConnectorFactory
2
+
3
+ > `const` **AttestationConnectorFactory**: `Factory`\<[`IAttestationConnector`](../interfaces/IAttestationConnector.md)\>
4
+
5
+ Factory for creating attestation connectors.
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": {}
3
+ }
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@twin.org/attestation-models",
3
+ "version": "0.0.1-next.3",
4
+ "description": "Models which define the structure of the attestation connectors and services",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/attestation.git",
8
+ "directory": "packages/attestation-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/entity": "next",
32
+ "@twin.org/nameof": "next",
33
+ "@twin.org/standards-w3c-did": "next"
34
+ },
35
+ "devDependencies": {
36
+ "@twin.org/nameof-transformer": "next",
37
+ "@vitest/coverage-v8": "2.1.1",
38
+ "copyfiles": "2.4.1",
39
+ "rimraf": "6.0.1",
40
+ "rollup": "4.22.0",
41
+ "rollup-plugin-typescript2": "0.36.0",
42
+ "ts-patch": "3.2.1",
43
+ "typedoc": "0.26.7",
44
+ "typedoc-plugin-markdown": "4.2.7",
45
+ "typescript": "5.6.2",
46
+ "vitest": "2.1.1"
47
+ },
48
+ "main": "./dist/cjs/index.cjs",
49
+ "module": "./dist/esm/index.mjs",
50
+ "types": "./dist/types/index.d.ts",
51
+ "exports": {
52
+ ".": {
53
+ "require": "./dist/cjs/index.cjs",
54
+ "import": "./dist/esm/index.mjs",
55
+ "types": "./dist/types/index.d.ts"
56
+ },
57
+ "./locales": "./locales"
58
+ },
59
+ "files": [
60
+ "dist/cjs",
61
+ "dist/esm",
62
+ "dist/types",
63
+ "locales",
64
+ "docs"
65
+ ]
66
+ }