@twin.org/identity-models 0.0.3-next.3 → 0.0.3-next.30

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 (91) hide show
  1. package/README.md +3 -3
  2. package/dist/es/contextIdHandlers/didContextIdHandler.js +7 -0
  3. package/dist/es/contextIdHandlers/didContextIdHandler.js.map +1 -1
  4. package/dist/es/index.js +6 -0
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/es/models/IIdentityComponent.js.map +1 -1
  7. package/dist/es/models/IIdentityConnector.js.map +1 -1
  8. package/dist/es/models/api/identity/IIdentityAlsoKnownAsCreateRequest.js +4 -0
  9. package/dist/es/models/api/identity/IIdentityAlsoKnownAsCreateRequest.js.map +1 -0
  10. package/dist/es/models/api/identity/IIdentityAlsoKnownAsRemoveRequest.js +4 -0
  11. package/dist/es/models/api/identity/IIdentityAlsoKnownAsRemoveRequest.js.map +1 -0
  12. package/dist/es/models/api/identity/IIdentityVerifiableCredentialCreateRequest.js.map +1 -1
  13. package/dist/es/models/api/identity/IIdentityVerifiableCredentialRevokeRequest.js.map +1 -1
  14. package/dist/es/models/api/identity/IIdentityVerifiableCredentialUnrevokeRequest.js.map +1 -1
  15. package/dist/es/models/api/identity/IIdentityVerifiableCredentialVerifyDocumentRequest.js +2 -0
  16. package/dist/es/models/api/identity/IIdentityVerifiableCredentialVerifyDocumentRequest.js.map +1 -0
  17. package/dist/es/models/api/identity/IIdentityVerifiablePresentationCreateRequest.js.map +1 -1
  18. package/dist/es/models/api/identity/IIdentityVerifiablePresentationVerifyDocumentRequest.js +2 -0
  19. package/dist/es/models/api/identity/IIdentityVerifiablePresentationVerifyDocumentRequest.js.map +1 -0
  20. package/dist/es/models/identityMetricIds.js +49 -0
  21. package/dist/es/models/identityMetricIds.js.map +1 -0
  22. package/dist/es/models/identityMetrics.js +61 -0
  23. package/dist/es/models/identityMetrics.js.map +1 -0
  24. package/dist/types/contextIdHandlers/didContextIdHandler.d.ts +5 -0
  25. package/dist/types/index.d.ts +6 -0
  26. package/dist/types/models/IIdentityComponent.d.ts +47 -6
  27. package/dist/types/models/IIdentityConnector.d.ts +47 -6
  28. package/dist/types/models/api/identity/IIdentityAlsoKnownAsCreateRequest.d.ts +23 -0
  29. package/dist/types/models/api/identity/IIdentityAlsoKnownAsRemoveRequest.d.ts +18 -0
  30. package/dist/types/models/api/identity/IIdentityVerifiableCredentialCreateRequest.d.ts +12 -0
  31. package/dist/types/models/api/identity/IIdentityVerifiableCredentialRevokeRequest.d.ts +1 -1
  32. package/dist/types/models/api/identity/IIdentityVerifiableCredentialUnrevokeRequest.d.ts +1 -1
  33. package/dist/types/models/api/identity/IIdentityVerifiableCredentialVerifyDocumentRequest.d.ts +10 -0
  34. package/dist/types/models/api/identity/IIdentityVerifiablePresentationCreateRequest.d.ts +14 -2
  35. package/dist/types/models/api/identity/IIdentityVerifiablePresentationVerifyDocumentRequest.d.ts +10 -0
  36. package/dist/types/models/identityMetricIds.d.ts +49 -0
  37. package/dist/types/models/identityMetrics.d.ts +5 -0
  38. package/docs/changelog.md +304 -76
  39. package/docs/examples.md +157 -1
  40. package/docs/reference/classes/Did.md +4 -4
  41. package/docs/reference/classes/DidContextIdHandler.md +21 -3
  42. package/docs/reference/classes/DocumentHelper.md +5 -5
  43. package/docs/reference/classes/VerificationHelper.md +3 -3
  44. package/docs/reference/index.md +10 -0
  45. package/docs/reference/interfaces/IIdentityAlsoKnownAsCreateRequest.md +31 -0
  46. package/docs/reference/interfaces/IIdentityAlsoKnownAsRemoveRequest.md +23 -0
  47. package/docs/reference/interfaces/IIdentityComponent.md +150 -36
  48. package/docs/reference/interfaces/IIdentityConnector.md +150 -36
  49. package/docs/reference/interfaces/IIdentityCreateRequest.md +3 -3
  50. package/docs/reference/interfaces/IIdentityCreateResponse.md +1 -1
  51. package/docs/reference/interfaces/IIdentityProfileComponent.md +6 -6
  52. package/docs/reference/interfaces/IIdentityProfileConnector.md +5 -5
  53. package/docs/reference/interfaces/IIdentityProfileCreateRequest.md +3 -3
  54. package/docs/reference/interfaces/IIdentityProfileGetPublicRequest.md +4 -4
  55. package/docs/reference/interfaces/IIdentityProfileGetPublicResponse.md +2 -2
  56. package/docs/reference/interfaces/IIdentityProfileGetRequest.md +4 -4
  57. package/docs/reference/interfaces/IIdentityProfileGetResponse.md +3 -3
  58. package/docs/reference/interfaces/IIdentityProfileListRequest.md +6 -6
  59. package/docs/reference/interfaces/IIdentityProfileListResponse.md +2 -2
  60. package/docs/reference/interfaces/IIdentityProfileUpdateRequest.md +3 -3
  61. package/docs/reference/interfaces/IIdentityProofCreateRequest.md +2 -2
  62. package/docs/reference/interfaces/IIdentityProofCreateResponse.md +1 -1
  63. package/docs/reference/interfaces/IIdentityProofVerifyRequest.md +1 -1
  64. package/docs/reference/interfaces/IIdentityProofVerifyResponse.md +1 -1
  65. package/docs/reference/interfaces/IIdentityRemoveRequest.md +1 -1
  66. package/docs/reference/interfaces/IIdentityResolveRequest.md +1 -1
  67. package/docs/reference/interfaces/IIdentityResolveResponse.md +1 -1
  68. package/docs/reference/interfaces/IIdentityResolverComponent.md +1 -1
  69. package/docs/reference/interfaces/IIdentityResolverConnector.md +1 -1
  70. package/docs/reference/interfaces/IIdentityServiceCreateRequest.md +2 -2
  71. package/docs/reference/interfaces/IIdentityServiceCreateResponse.md +1 -1
  72. package/docs/reference/interfaces/IIdentityServiceRemoveRequest.md +1 -1
  73. package/docs/reference/interfaces/IIdentityVerifiableCredentialCreateRequest.md +25 -5
  74. package/docs/reference/interfaces/IIdentityVerifiableCredentialCreateResponse.md +1 -1
  75. package/docs/reference/interfaces/IIdentityVerifiableCredentialRevokeRequest.md +2 -2
  76. package/docs/reference/interfaces/IIdentityVerifiableCredentialUnrevokeRequest.md +2 -2
  77. package/docs/reference/interfaces/IIdentityVerifiableCredentialVerifyDocumentRequest.md +11 -0
  78. package/docs/reference/interfaces/IIdentityVerifiableCredentialVerifyRequest.md +1 -1
  79. package/docs/reference/interfaces/IIdentityVerifiableCredentialVerifyResponse.md +2 -2
  80. package/docs/reference/interfaces/IIdentityVerifiablePresentationCreateRequest.md +28 -8
  81. package/docs/reference/interfaces/IIdentityVerifiablePresentationCreateResponse.md +1 -1
  82. package/docs/reference/interfaces/IIdentityVerifiablePresentationVerifyDocumentRequest.md +11 -0
  83. package/docs/reference/interfaces/IIdentityVerifiablePresentationVerifyRequest.md +1 -1
  84. package/docs/reference/interfaces/IIdentityVerifiablePresentationVerifyResponse.md +3 -3
  85. package/docs/reference/interfaces/IIdentityVerificationMethodCreateRequest.md +3 -3
  86. package/docs/reference/interfaces/IIdentityVerificationMethodCreateResponse.md +1 -1
  87. package/docs/reference/interfaces/IIdentityVerificationMethodRemoveRequest.md +1 -1
  88. package/docs/reference/type-aliases/IdentityMetricIds.md +5 -0
  89. package/docs/reference/variables/IdentityMetricIds.md +67 -0
  90. package/docs/reference/variables/IdentityMetrics.md +5 -0
  91. package/package.json +5 -4
@@ -57,6 +57,28 @@ export interface IIdentityConnector extends IComponent {
57
57
  * @throws NotFoundError if the id can not be resolved.
58
58
  */
59
59
  removeService(controller: string, serviceId: string): Promise<void>;
60
+ /**
61
+ * Add an alias to the alsoKnownAs property on the document.
62
+ * If the alias is already present the operation is a no-op.
63
+ * @param controller The controller of the identity who can make changes.
64
+ * @param documentId The id of the document to update.
65
+ * @param alias The alias to add. Must be a Url or Urn (typically another DID).
66
+ * @returns Nothing.
67
+ * @throws GeneralError if the alias is not a Url or Urn.
68
+ * @throws NotFoundError if the id can not be resolved.
69
+ */
70
+ addAlsoKnownAs(controller: string, documentId: string, alias: string): Promise<void>;
71
+ /**
72
+ * Remove an alias from the alsoKnownAs property on the document.
73
+ * If the alias is not present the operation is a no-op.
74
+ * @param controller The controller of the identity who can make changes.
75
+ * @param documentId The id of the document to update.
76
+ * @param alias The alias to remove. Must be a Url or Urn.
77
+ * @returns Nothing.
78
+ * @throws GeneralError if the alias is not a Url or Urn.
79
+ * @throws NotFoundError if the id can not be resolved.
80
+ */
81
+ removeAlsoKnownAs(controller: string, documentId: string, alias: string): Promise<void>;
60
82
  /**
61
83
  * Create a verifiable credential for a verification method.
62
84
  * @param controller The controller of the identity who can make changes.
@@ -66,22 +88,30 @@ export interface IIdentityConnector extends IComponent {
66
88
  * @param options Additional options for creating the verifiable credential.
67
89
  * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
68
90
  * @param options.expirationDate The date the verifiable credential is valid until.
91
+ * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.
92
+ * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.
69
93
  * @returns The created verifiable credential and its token.
70
94
  * @throws NotFoundError if the id can not be resolved.
71
95
  */
72
96
  createVerifiableCredential(controller: string, verificationMethodId: string, id: string | undefined, subject: IJsonLdNodeObject, options?: {
73
97
  revocationIndex?: number;
74
98
  expirationDate?: Date;
99
+ jwtHeaderFields?: {
100
+ [id: string]: string;
101
+ };
102
+ jwtPayloadFields?: {
103
+ [id: string]: string;
104
+ };
75
105
  }): Promise<{
76
106
  verifiableCredential: IDidVerifiableCredential;
77
107
  jwt: string;
78
108
  }>;
79
109
  /**
80
110
  * Check a verifiable credential is valid.
81
- * @param credentialJwt The credential to verify.
111
+ * @param credential The credential to verify.
82
112
  * @returns The credential stored in the jwt and the revocation status.
83
113
  */
84
- checkVerifiableCredential(credentialJwt: string): Promise<{
114
+ checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{
85
115
  revoked: boolean;
86
116
  verifiableCredential?: IDidVerifiableCredential;
87
117
  }>;
@@ -109,20 +139,31 @@ export interface IIdentityConnector extends IComponent {
109
139
  * @param contexts The contexts for the data stored in the verifiable credential.
110
140
  * @param types The types for the data stored in the verifiable credential.
111
141
  * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
112
- * @param expiresInMinutes The time in minutes for the presentation to expire.
142
+ * @param options Additional options for creating the verifiable presentation.
143
+ * @param options.expirationDate The date the verifiable presentation is valid until.
144
+ * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.
145
+ * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.
113
146
  * @returns The created verifiable presentation and its token.
114
147
  * @throws NotFoundError if the id can not be resolved.
115
148
  */
116
- createVerifiablePresentation(controller: string, verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number): Promise<{
149
+ createVerifiablePresentation(controller: string, verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], options?: {
150
+ expirationDate?: Date;
151
+ jwtHeaderFields?: {
152
+ [id: string]: string;
153
+ };
154
+ jwtPayloadFields?: {
155
+ [id: string]: string;
156
+ };
157
+ }): Promise<{
117
158
  verifiablePresentation: IDidVerifiablePresentation;
118
159
  jwt: string;
119
160
  }>;
120
161
  /**
121
162
  * Check a verifiable presentation is valid.
122
- * @param presentationJwt The presentation to verify.
163
+ * @param presentation The presentation to verify.
123
164
  * @returns The presentation stored in the jwt and the revocation status.
124
165
  */
125
- checkVerifiablePresentation(presentationJwt: string): Promise<{
166
+ checkVerifiablePresentation(presentation: string | IDidVerifiablePresentation): Promise<{
126
167
  revoked: boolean;
127
168
  verifiablePresentation?: IDidVerifiablePresentation;
128
169
  issuers?: IDidDocument[];
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Request to create an alias for an identity.
3
+ */
4
+ export interface IIdentityAlsoKnownAsCreateRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The identity to create the alias for.
11
+ */
12
+ identity: string;
13
+ };
14
+ /**
15
+ * The data for the request.
16
+ */
17
+ body: {
18
+ /**
19
+ * The alias to create for the identity.
20
+ */
21
+ alias: string;
22
+ };
23
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Request to remove an alias from an identity.
3
+ */
4
+ export interface IIdentityAlsoKnownAsRemoveRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The identity to remove the alias from.
11
+ */
12
+ identity: string;
13
+ /**
14
+ * The alias to remove.
15
+ */
16
+ alias: string;
17
+ };
18
+ }
@@ -36,5 +36,17 @@ export interface IIdentityVerifiableCredentialCreateRequest {
36
36
  * The date the verifiable credential is valid until.
37
37
  */
38
38
  expirationDate?: string;
39
+ /**
40
+ * Additional fields to include in the JWT when creating the verifiable credential in jwt format.
41
+ */
42
+ jwtHeaderFields?: {
43
+ [id: string]: string;
44
+ };
45
+ /**
46
+ * Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.
47
+ */
48
+ jwtPayloadFields?: {
49
+ [id: string]: string;
50
+ };
39
51
  };
40
52
  }
@@ -13,6 +13,6 @@ export interface IIdentityVerifiableCredentialRevokeRequest {
13
13
  /**
14
14
  * The revocation index to revoke.
15
15
  */
16
- revocationIndex: number;
16
+ revocationIndex: string;
17
17
  };
18
18
  }
@@ -13,6 +13,6 @@ export interface IIdentityVerifiableCredentialUnrevokeRequest {
13
13
  /**
14
14
  * The revocation index to unrevoke.
15
15
  */
16
- revocationIndex: number;
16
+ revocationIndex: string;
17
17
  };
18
18
  }
@@ -0,0 +1,10 @@
1
+ import type { IDidVerifiableCredential } from "@twin.org/standards-w3c-did";
2
+ /**
3
+ * Request to verify a verifiable credential.
4
+ */
5
+ export interface IIdentityVerifiableCredentialVerifyDocumentRequest {
6
+ /**
7
+ * The body parameters.
8
+ */
9
+ body: IDidVerifiableCredential;
10
+ }
@@ -38,8 +38,20 @@ export interface IIdentityVerifiablePresentationCreateRequest {
38
38
  */
39
39
  verifiableCredentials: (string | IDidVerifiableCredential)[];
40
40
  /**
41
- * The expiration time for the presentation.
41
+ * The expiration date/time for the presentation.
42
42
  */
43
- expiresInMinutes?: number;
43
+ expirationDate?: string;
44
+ /**
45
+ * Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.
46
+ */
47
+ jwtHeaderFields?: {
48
+ [id: string]: string;
49
+ };
50
+ /**
51
+ * Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.
52
+ */
53
+ jwtPayloadFields?: {
54
+ [id: string]: string;
55
+ };
44
56
  };
45
57
  }
@@ -0,0 +1,10 @@
1
+ import type { IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
2
+ /**
3
+ * Request to verify a verifiable presentation.
4
+ */
5
+ export interface IIdentityVerifiablePresentationVerifyDocumentRequest {
6
+ /**
7
+ * The body parameters.
8
+ */
9
+ body: IDidVerifiablePresentation;
10
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Metric IDs for the identity service.
3
+ */
4
+ export declare const IdentityMetricIds: {
5
+ /**
6
+ * Number of DIDs created.
7
+ */
8
+ readonly DidsCreated: "identity_dids_created";
9
+ /**
10
+ * Number of DIDs removed.
11
+ */
12
+ readonly DidsRemoved: "identity_dids_removed";
13
+ /**
14
+ * Number of verifiable credentials created.
15
+ */
16
+ readonly VcsCreated: "identity_vcs_created";
17
+ /**
18
+ * Number of VC verifications succeeded.
19
+ */
20
+ readonly VcsVerified: "identity_vcs_verified";
21
+ /**
22
+ * Number of VC verifications failed.
23
+ */
24
+ readonly VcsVerificationFailed: "identity_vcs_verification_failed";
25
+ /**
26
+ * Number of VCs revoked.
27
+ */
28
+ readonly VcsRevoked: "identity_vcs_revoked";
29
+ /**
30
+ * Number of VCs unrevoked.
31
+ */
32
+ readonly VcsUnrevoked: "identity_vcs_unrevoked";
33
+ /**
34
+ * Number of verifiable presentations created.
35
+ */
36
+ readonly VpsCreated: "identity_vps_created";
37
+ /**
38
+ * Number of VP verifications succeeded.
39
+ */
40
+ readonly VpsVerified: "identity_vps_verified";
41
+ /**
42
+ * Number of VP verifications failed.
43
+ */
44
+ readonly VpsVerificationFailed: "identity_vps_verification_failed";
45
+ };
46
+ /**
47
+ * Metric IDs for the identity service.
48
+ */
49
+ export type IdentityMetricIds = (typeof IdentityMetricIds)[keyof typeof IdentityMetricIds];
@@ -0,0 +1,5 @@
1
+ import { type ITelemetryMetric } from "@twin.org/telemetry-models";
2
+ /**
3
+ * Metrics registered by the identity service.
4
+ */
5
+ export declare const IdentityMetrics: ITelemetryMetric[];