@twin.org/attestation-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.
Files changed (35) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +193 -0
  4. package/dist/esm/index.mjs +189 -0
  5. package/dist/types/dataTypes/attestationDataTypes.d.ts +9 -0
  6. package/dist/types/factories/attestationConnectorFactory.d.ts +6 -0
  7. package/dist/types/index.d.ts +12 -0
  8. package/dist/types/models/IAttestationComponent.d.ts +39 -0
  9. package/dist/types/models/IAttestationConnector.d.ts +39 -0
  10. package/dist/types/models/IAttestationInformation.d.ts +51 -0
  11. package/dist/types/models/IAttestationJwtProof.d.ts +18 -0
  12. package/dist/types/models/api/IAttestationCreateRequest.d.ts +23 -0
  13. package/dist/types/models/api/IAttestationDestroyRequest.d.ts +14 -0
  14. package/dist/types/models/api/IAttestationGetRequest.d.ts +21 -0
  15. package/dist/types/models/api/IAttestationGetResponse.d.ts +17 -0
  16. package/dist/types/models/api/IAttestationTransferRequest.d.ts +23 -0
  17. package/dist/types/models/attestationTypes.d.ts +21 -0
  18. package/docs/changelog.md +5 -0
  19. package/docs/examples.md +1 -0
  20. package/docs/reference/classes/AttestationDataTypes.md +25 -0
  21. package/docs/reference/index.md +26 -0
  22. package/docs/reference/interfaces/IAttestationComponent.md +115 -0
  23. package/docs/reference/interfaces/IAttestationConnector.md +115 -0
  24. package/docs/reference/interfaces/IAttestationCreateRequest.md +29 -0
  25. package/docs/reference/interfaces/IAttestationDestroyRequest.md +17 -0
  26. package/docs/reference/interfaces/IAttestationGetRequest.md +29 -0
  27. package/docs/reference/interfaces/IAttestationGetResponse.md +23 -0
  28. package/docs/reference/interfaces/IAttestationInformation.md +91 -0
  29. package/docs/reference/interfaces/IAttestationJwtProof.md +27 -0
  30. package/docs/reference/interfaces/IAttestationTransferRequest.md +31 -0
  31. package/docs/reference/type-aliases/AttestationTypes.md +5 -0
  32. package/docs/reference/variables/AttestationConnectorFactory.md +5 -0
  33. package/docs/reference/variables/AttestationTypes.md +25 -0
  34. package/locales/en.json +3 -0
  35. package/package.json +43 -0
@@ -0,0 +1,39 @@
1
+ import type { IComponent } from "@twin.org/core";
2
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
3
+ import type { IAttestationInformation } from "./IAttestationInformation";
4
+ /**
5
+ * Interface describing an attestation connector.
6
+ */
7
+ export interface IAttestationConnector extends IComponent {
8
+ /**
9
+ * Attest the data and return the collated information.
10
+ * @param controller The controller identity of the user to access the vault keys.
11
+ * @param address The controller address for the attestation.
12
+ * @param verificationMethodId The identity verification method to use for attesting the data.
13
+ * @param attestationObject The data to attest.
14
+ * @returns The collated attestation data.
15
+ */
16
+ create(controller: string, address: string, verificationMethodId: string, attestationObject: IJsonLdNodeObject): Promise<string>;
17
+ /**
18
+ * Resolve and verify the attestation id.
19
+ * @param id The attestation id to verify.
20
+ * @returns The verified attestation details.
21
+ */
22
+ get(id: string): Promise<IAttestationInformation>;
23
+ /**
24
+ * Transfer the attestation to a new holder.
25
+ * @param controller The controller identity of the user to access the vault keys.
26
+ * @param attestationId The attestation to transfer.
27
+ * @param holderIdentity The holder identity of the attestation.
28
+ * @param holderAddress The new controller address of the attestation belonging to the holder.
29
+ * @returns Nothing.
30
+ */
31
+ transfer(controller: string, attestationId: string, holderIdentity: string, holderAddress: string): Promise<void>;
32
+ /**
33
+ * Destroy the attestation.
34
+ * @param controller The controller identity of the user to access the vault keys.
35
+ * @param attestationId The attestation to destroy.
36
+ * @returns Nothing.
37
+ */
38
+ destroy(controller: string, attestationId: string): Promise<void>;
39
+ }
@@ -0,0 +1,51 @@
1
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
+ import type { AttestationTypes } from "./attestationTypes";
3
+ /**
4
+ * Interface describing the collated attestation information.
5
+ */
6
+ export interface IAttestationInformation {
7
+ /**
8
+ * JSON-LD Context.
9
+ */
10
+ "@context": typeof AttestationTypes.ContextRoot | [typeof AttestationTypes.ContextRoot, ...string[]];
11
+ /**
12
+ * JSON-LD Type.
13
+ */
14
+ type: typeof AttestationTypes.Information;
15
+ /**
16
+ * The unique identifier of the attestation.
17
+ */
18
+ id: string;
19
+ /**
20
+ * Created date/time of the attestation in ISO format.
21
+ */
22
+ dateCreated: string;
23
+ /**
24
+ * Transferred date/time of the attestation in ISO format, can be blank if holder identity is owner.
25
+ */
26
+ dateTransferred?: string;
27
+ /**
28
+ * The identity of the owner.
29
+ */
30
+ ownerIdentity: string;
31
+ /**
32
+ * The identity of the current holder, can be undefined if owner is still the holder.
33
+ */
34
+ holderIdentity?: string;
35
+ /**
36
+ * The data that was attested.
37
+ */
38
+ attestationObject: IJsonLdNodeObject;
39
+ /**
40
+ * The proof for the attested data.
41
+ */
42
+ proof?: IJsonLdNodeObject;
43
+ /**
44
+ * Whether the attestation has been verified.
45
+ */
46
+ verified?: boolean;
47
+ /**
48
+ * The verification failure message.
49
+ */
50
+ verificationFailure?: string;
51
+ }
@@ -0,0 +1,18 @@
1
+ import type { AttestationTypes } from "./attestationTypes";
2
+ /**
3
+ * Interface describing an attestation proof.
4
+ */
5
+ export interface IAttestationJwtProof {
6
+ /**
7
+ * JSON-LD Context.
8
+ */
9
+ "@context": typeof AttestationTypes.ContextRoot | [typeof AttestationTypes.ContextRoot, ...string[]];
10
+ /**
11
+ * The type of the proof.
12
+ */
13
+ type: typeof AttestationTypes.JwtProof;
14
+ /**
15
+ * The value of the proof.
16
+ */
17
+ value: string;
18
+ }
@@ -0,0 +1,23 @@
1
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
+ /**
3
+ * Attest the data and return the id of the attestation.
4
+ */
5
+ export interface IAttestationCreateRequest {
6
+ /**
7
+ * The data to be used in the signing.
8
+ */
9
+ body: {
10
+ /**
11
+ * The identity verification method to use for attesting the data.
12
+ */
13
+ verificationMethodId: string;
14
+ /**
15
+ * The data object to attest.
16
+ */
17
+ attestationObject: IJsonLdNodeObject;
18
+ /**
19
+ * The namespace of the connector to use for the attestation, defaults to component configured namespace.
20
+ */
21
+ namespace?: string;
22
+ };
23
+ }
@@ -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,21 @@
1
+ import type { HeaderTypes, MimeTypes } from "@twin.org/web";
2
+ /**
3
+ * Verify that the proof is valid for the attestation.
4
+ */
5
+ export interface IAttestationGetRequest {
6
+ /**
7
+ * The headers which can be used to determine the response data type.
8
+ */
9
+ headers?: {
10
+ [HeaderTypes.Accept]: typeof MimeTypes.Json | typeof MimeTypes.JsonLd;
11
+ };
12
+ /**
13
+ * The parameters to be used in the verification.
14
+ */
15
+ pathParams: {
16
+ /**
17
+ * The attestation id to verify.
18
+ */
19
+ id: string;
20
+ };
21
+ }
@@ -0,0 +1,17 @@
1
+ import type { HeaderTypes, MimeTypes } from "@twin.org/web";
2
+ import type { IAttestationInformation } from "../IAttestationInformation";
3
+ /**
4
+ * The response to verifying the attestation.
5
+ */
6
+ export interface IAttestationGetResponse {
7
+ /**
8
+ * The headers which can be used to determine the response data type.
9
+ */
10
+ headers?: {
11
+ [HeaderTypes.ContentType]: typeof MimeTypes.Json | typeof MimeTypes.JsonLd;
12
+ };
13
+ /**
14
+ * The data returned from the verification response.
15
+ */
16
+ body: IAttestationInformation;
17
+ }
@@ -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,21 @@
1
+ /**
2
+ * The types of attestation data.
3
+ */
4
+ export declare const AttestationTypes: {
5
+ /**
6
+ * The context root for the attestation types.
7
+ */
8
+ readonly ContextRoot: "https://schema.twindev.org/attestation/";
9
+ /**
10
+ * Represents attestation information.
11
+ */
12
+ readonly Information: "Information";
13
+ /**
14
+ * Represents attestation JWT proof.
15
+ */
16
+ readonly JwtProof: "JwtProof";
17
+ };
18
+ /**
19
+ * The types of attestation data.
20
+ */
21
+ export type AttestationTypes = (typeof AttestationTypes)[keyof typeof AttestationTypes];
@@ -0,0 +1,5 @@
1
+ # @twin.org/attestation-models - Changelog
2
+
3
+ ## v0.0.1-next.10
4
+
5
+ - Initial Release
@@ -0,0 +1 @@
1
+ # @twin.org/attestation-models - Examples
@@ -0,0 +1,25 @@
1
+ # Class: AttestationDataTypes
2
+
3
+ Handle all the data types for attestation.
4
+
5
+ ## Constructors
6
+
7
+ ### new AttestationDataTypes()
8
+
9
+ > **new AttestationDataTypes**(): [`AttestationDataTypes`](AttestationDataTypes.md)
10
+
11
+ #### Returns
12
+
13
+ [`AttestationDataTypes`](AttestationDataTypes.md)
14
+
15
+ ## Methods
16
+
17
+ ### registerTypes()
18
+
19
+ > `static` **registerTypes**(): `void`
20
+
21
+ Register all the data types.
22
+
23
+ #### Returns
24
+
25
+ `void`
@@ -0,0 +1,26 @@
1
+ # @twin.org/attestation-models
2
+
3
+ ## Classes
4
+
5
+ - [AttestationDataTypes](classes/AttestationDataTypes.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [IAttestationComponent](interfaces/IAttestationComponent.md)
10
+ - [IAttestationConnector](interfaces/IAttestationConnector.md)
11
+ - [IAttestationInformation](interfaces/IAttestationInformation.md)
12
+ - [IAttestationJwtProof](interfaces/IAttestationJwtProof.md)
13
+ - [IAttestationCreateRequest](interfaces/IAttestationCreateRequest.md)
14
+ - [IAttestationDestroyRequest](interfaces/IAttestationDestroyRequest.md)
15
+ - [IAttestationGetRequest](interfaces/IAttestationGetRequest.md)
16
+ - [IAttestationGetResponse](interfaces/IAttestationGetResponse.md)
17
+ - [IAttestationTransferRequest](interfaces/IAttestationTransferRequest.md)
18
+
19
+ ## Type Aliases
20
+
21
+ - [AttestationTypes](type-aliases/AttestationTypes.md)
22
+
23
+ ## Variables
24
+
25
+ - [AttestationConnectorFactory](variables/AttestationConnectorFactory.md)
26
+ - [AttestationTypes](variables/AttestationTypes.md)
@@ -0,0 +1,115 @@
1
+ # Interface: IAttestationComponent
2
+
3
+ Interface describing an attestation contract.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### create()
12
+
13
+ > **create**(`verificationMethodId`, `attestationObject`, `namespace`?, `identity`?, `nodeIdentity`?): `Promise`\<`string`\>
14
+
15
+ Attest the data and return the collated information.
16
+
17
+ #### Parameters
18
+
19
+ • **verificationMethodId**: `string`
20
+
21
+ The identity verification method to use for attesting the data.
22
+
23
+ • **attestationObject**: `IJsonLdNodeObject`
24
+
25
+ The data to attest.
26
+
27
+ • **namespace?**: `string`
28
+
29
+ The namespace of the connector to use for the attestation, defaults to component configured namespace.
30
+
31
+ • **identity?**: `string`
32
+
33
+ The identity to perform the attestation operation with.
34
+
35
+ • **nodeIdentity?**: `string`
36
+
37
+ The node identity to include in the attestation.
38
+
39
+ #### Returns
40
+
41
+ `Promise`\<`string`\>
42
+
43
+ The id of the attestation.
44
+
45
+ ***
46
+
47
+ ### get()
48
+
49
+ > **get**(`id`): `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\>
50
+
51
+ Resolve and verify the attestation id.
52
+
53
+ #### Parameters
54
+
55
+ • **id**: `string`
56
+
57
+ The attestation id to verify.
58
+
59
+ #### Returns
60
+
61
+ `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\>
62
+
63
+ The verified attestation details.
64
+
65
+ ***
66
+
67
+ ### transfer()
68
+
69
+ > **transfer**(`attestationId`, `holderIdentity`, `identity`?): `Promise`\<`void`\>
70
+
71
+ Transfer the attestation to a new holder.
72
+
73
+ #### Parameters
74
+
75
+ • **attestationId**: `string`
76
+
77
+ The attestation to transfer.
78
+
79
+ • **holderIdentity**: `string`
80
+
81
+ The identity to transfer the attestation to.
82
+
83
+ • **identity?**: `string`
84
+
85
+ The identity to perform the attestation operation with.
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<`void`\>
90
+
91
+ Nothing.
92
+
93
+ ***
94
+
95
+ ### destroy()
96
+
97
+ > **destroy**(`attestationId`, `identity`?): `Promise`\<`void`\>
98
+
99
+ Destroy the attestation.
100
+
101
+ #### Parameters
102
+
103
+ • **attestationId**: `string`
104
+
105
+ The attestation to transfer.
106
+
107
+ • **identity?**: `string`
108
+
109
+ The identity to perform the attestation operation with.
110
+
111
+ #### Returns
112
+
113
+ `Promise`\<`void`\>
114
+
115
+ Nothing.
@@ -0,0 +1,115 @@
1
+ # Interface: IAttestationConnector
2
+
3
+ Interface describing an attestation connector.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### create()
12
+
13
+ > **create**(`controller`, `address`, `verificationMethodId`, `attestationObject`): `Promise`\<`string`\>
14
+
15
+ Attest the data and return the collated information.
16
+
17
+ #### Parameters
18
+
19
+ • **controller**: `string`
20
+
21
+ The controller identity of the user to access the vault keys.
22
+
23
+ • **address**: `string`
24
+
25
+ The controller address for the attestation.
26
+
27
+ • **verificationMethodId**: `string`
28
+
29
+ The identity verification method to use for attesting the data.
30
+
31
+ • **attestationObject**: `IJsonLdNodeObject`
32
+
33
+ The data to attest.
34
+
35
+ #### Returns
36
+
37
+ `Promise`\<`string`\>
38
+
39
+ The collated attestation data.
40
+
41
+ ***
42
+
43
+ ### get()
44
+
45
+ > **get**(`id`): `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\>
46
+
47
+ Resolve and verify the attestation id.
48
+
49
+ #### Parameters
50
+
51
+ • **id**: `string`
52
+
53
+ The attestation id to verify.
54
+
55
+ #### Returns
56
+
57
+ `Promise`\<[`IAttestationInformation`](IAttestationInformation.md)\>
58
+
59
+ The verified attestation details.
60
+
61
+ ***
62
+
63
+ ### transfer()
64
+
65
+ > **transfer**(`controller`, `attestationId`, `holderIdentity`, `holderAddress`): `Promise`\<`void`\>
66
+
67
+ Transfer the attestation to a new holder.
68
+
69
+ #### Parameters
70
+
71
+ • **controller**: `string`
72
+
73
+ The controller identity of the user to access the vault keys.
74
+
75
+ • **attestationId**: `string`
76
+
77
+ The attestation to transfer.
78
+
79
+ • **holderIdentity**: `string`
80
+
81
+ The holder identity of the attestation.
82
+
83
+ • **holderAddress**: `string`
84
+
85
+ The new controller address of the attestation belonging to the holder.
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<`void`\>
90
+
91
+ Nothing.
92
+
93
+ ***
94
+
95
+ ### destroy()
96
+
97
+ > **destroy**(`controller`, `attestationId`): `Promise`\<`void`\>
98
+
99
+ Destroy the attestation.
100
+
101
+ #### Parameters
102
+
103
+ • **controller**: `string`
104
+
105
+ The controller identity of the user to access the vault keys.
106
+
107
+ • **attestationId**: `string`
108
+
109
+ The attestation to destroy.
110
+
111
+ #### Returns
112
+
113
+ `Promise`\<`void`\>
114
+
115
+ Nothing.
@@ -0,0 +1,29 @@
1
+ # Interface: IAttestationCreateRequest
2
+
3
+ Attest the data and return the id of the attestation.
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
+ #### attestationObject
20
+
21
+ > **attestationObject**: `IJsonLdNodeObject`
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,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,29 @@
1
+ # Interface: IAttestationGetRequest
2
+
3
+ Verify that the proof is valid for the attestation.
4
+
5
+ ## Properties
6
+
7
+ ### headers?
8
+
9
+ > `optional` **headers**: `object`
10
+
11
+ The headers which can be used to determine the response data type.
12
+
13
+ #### accept
14
+
15
+ > **accept**: `"application/json"` \| `"application/ld+json"`
16
+
17
+ ***
18
+
19
+ ### pathParams
20
+
21
+ > **pathParams**: `object`
22
+
23
+ The parameters to be used in the verification.
24
+
25
+ #### id
26
+
27
+ > **id**: `string`
28
+
29
+ The attestation id to verify.
@@ -0,0 +1,23 @@
1
+ # Interface: IAttestationGetResponse
2
+
3
+ The response to verifying the attestation.
4
+
5
+ ## Properties
6
+
7
+ ### headers?
8
+
9
+ > `optional` **headers**: `object`
10
+
11
+ The headers which can be used to determine the response data type.
12
+
13
+ #### content-type
14
+
15
+ > **content-type**: `"application/json"` \| `"application/ld+json"`
16
+
17
+ ***
18
+
19
+ ### body
20
+
21
+ > **body**: [`IAttestationInformation`](IAttestationInformation.md)
22
+
23
+ The data returned from the verification response.