@twin.org/identity-models 0.0.3-next.9 → 0.9.0

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 (97) hide show
  1. package/README.md +3 -3
  2. package/dist/es/contextIdHandlers/didContextIdHandler.js +3 -3
  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/IIdentityProfileComponent.js.map +1 -1
  9. package/dist/es/models/IIdentityProfileConnector.js.map +1 -1
  10. package/dist/es/models/api/identity/IIdentityAlsoKnownAsCreateRequest.js +4 -0
  11. package/dist/es/models/api/identity/IIdentityAlsoKnownAsCreateRequest.js.map +1 -0
  12. package/dist/es/models/api/identity/IIdentityAlsoKnownAsRemoveRequest.js +4 -0
  13. package/dist/es/models/api/identity/IIdentityAlsoKnownAsRemoveRequest.js.map +1 -0
  14. package/dist/es/models/api/identity/IIdentityVerifiableCredentialCreateRequest.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/es/types/did.js +3 -3
  25. package/dist/es/types/did.js.map +1 -1
  26. package/dist/es/utils/verificationHelper.js +4 -4
  27. package/dist/es/utils/verificationHelper.js.map +1 -1
  28. package/dist/types/contextIdHandlers/didContextIdHandler.d.ts +3 -3
  29. package/dist/types/index.d.ts +6 -0
  30. package/dist/types/models/IIdentityComponent.d.ts +54 -13
  31. package/dist/types/models/IIdentityConnector.d.ts +53 -12
  32. package/dist/types/models/IIdentityProfileComponent.d.ts +3 -3
  33. package/dist/types/models/IIdentityProfileConnector.d.ts +3 -3
  34. package/dist/types/models/api/identity/IIdentityAlsoKnownAsCreateRequest.d.ts +23 -0
  35. package/dist/types/models/api/identity/IIdentityAlsoKnownAsRemoveRequest.d.ts +18 -0
  36. package/dist/types/models/api/identity/IIdentityVerifiableCredentialCreateRequest.d.ts +12 -0
  37. package/dist/types/models/api/identity/IIdentityVerifiableCredentialVerifyDocumentRequest.d.ts +10 -0
  38. package/dist/types/models/api/identity/IIdentityVerifiablePresentationCreateRequest.d.ts +14 -2
  39. package/dist/types/models/api/identity/IIdentityVerifiablePresentationVerifyDocumentRequest.d.ts +10 -0
  40. package/dist/types/models/identityMetricIds.d.ts +49 -0
  41. package/dist/types/models/identityMetrics.d.ts +5 -0
  42. package/dist/types/types/did.d.ts +3 -3
  43. package/dist/types/utils/verificationHelper.d.ts +4 -4
  44. package/docs/changelog.md +409 -99
  45. package/docs/examples.md +157 -1
  46. package/docs/reference/classes/Did.md +7 -7
  47. package/docs/reference/classes/DidContextIdHandler.md +7 -7
  48. package/docs/reference/classes/DocumentHelper.md +5 -5
  49. package/docs/reference/classes/VerificationHelper.md +7 -7
  50. package/docs/reference/index.md +10 -0
  51. package/docs/reference/interfaces/IIdentityAlsoKnownAsCreateRequest.md +31 -0
  52. package/docs/reference/interfaces/IIdentityAlsoKnownAsRemoveRequest.md +23 -0
  53. package/docs/reference/interfaces/IIdentityComponent.md +157 -43
  54. package/docs/reference/interfaces/IIdentityConnector.md +156 -42
  55. package/docs/reference/interfaces/IIdentityCreateRequest.md +3 -3
  56. package/docs/reference/interfaces/IIdentityCreateResponse.md +1 -1
  57. package/docs/reference/interfaces/IIdentityProfileComponent.md +9 -9
  58. package/docs/reference/interfaces/IIdentityProfileConnector.md +8 -8
  59. package/docs/reference/interfaces/IIdentityProfileCreateRequest.md +3 -3
  60. package/docs/reference/interfaces/IIdentityProfileGetPublicRequest.md +4 -4
  61. package/docs/reference/interfaces/IIdentityProfileGetPublicResponse.md +2 -2
  62. package/docs/reference/interfaces/IIdentityProfileGetRequest.md +4 -4
  63. package/docs/reference/interfaces/IIdentityProfileGetResponse.md +3 -3
  64. package/docs/reference/interfaces/IIdentityProfileListRequest.md +6 -6
  65. package/docs/reference/interfaces/IIdentityProfileListResponse.md +2 -2
  66. package/docs/reference/interfaces/IIdentityProfileUpdateRequest.md +3 -3
  67. package/docs/reference/interfaces/IIdentityProofCreateRequest.md +2 -2
  68. package/docs/reference/interfaces/IIdentityProofCreateResponse.md +1 -1
  69. package/docs/reference/interfaces/IIdentityProofVerifyRequest.md +1 -1
  70. package/docs/reference/interfaces/IIdentityProofVerifyResponse.md +1 -1
  71. package/docs/reference/interfaces/IIdentityRemoveRequest.md +1 -1
  72. package/docs/reference/interfaces/IIdentityResolveRequest.md +1 -1
  73. package/docs/reference/interfaces/IIdentityResolveResponse.md +1 -1
  74. package/docs/reference/interfaces/IIdentityResolverComponent.md +1 -1
  75. package/docs/reference/interfaces/IIdentityResolverConnector.md +1 -1
  76. package/docs/reference/interfaces/IIdentityServiceCreateRequest.md +2 -2
  77. package/docs/reference/interfaces/IIdentityServiceCreateResponse.md +1 -1
  78. package/docs/reference/interfaces/IIdentityServiceRemoveRequest.md +1 -1
  79. package/docs/reference/interfaces/IIdentityVerifiableCredentialCreateRequest.md +25 -5
  80. package/docs/reference/interfaces/IIdentityVerifiableCredentialCreateResponse.md +1 -1
  81. package/docs/reference/interfaces/IIdentityVerifiableCredentialRevokeRequest.md +1 -1
  82. package/docs/reference/interfaces/IIdentityVerifiableCredentialUnrevokeRequest.md +1 -1
  83. package/docs/reference/interfaces/IIdentityVerifiableCredentialVerifyDocumentRequest.md +11 -0
  84. package/docs/reference/interfaces/IIdentityVerifiableCredentialVerifyRequest.md +1 -1
  85. package/docs/reference/interfaces/IIdentityVerifiableCredentialVerifyResponse.md +2 -2
  86. package/docs/reference/interfaces/IIdentityVerifiablePresentationCreateRequest.md +28 -8
  87. package/docs/reference/interfaces/IIdentityVerifiablePresentationCreateResponse.md +1 -1
  88. package/docs/reference/interfaces/IIdentityVerifiablePresentationVerifyDocumentRequest.md +11 -0
  89. package/docs/reference/interfaces/IIdentityVerifiablePresentationVerifyRequest.md +1 -1
  90. package/docs/reference/interfaces/IIdentityVerifiablePresentationVerifyResponse.md +3 -3
  91. package/docs/reference/interfaces/IIdentityVerificationMethodCreateRequest.md +3 -3
  92. package/docs/reference/interfaces/IIdentityVerificationMethodCreateResponse.md +1 -1
  93. package/docs/reference/interfaces/IIdentityVerificationMethodRemoveRequest.md +1 -1
  94. package/docs/reference/type-aliases/IdentityMetricIds.md +5 -0
  95. package/docs/reference/variables/IdentityMetricIds.md +67 -0
  96. package/docs/reference/variables/IdentityMetrics.md +5 -0
  97. package/package.json +12 -11
@@ -2,6 +2,8 @@ export * from "./contextIdHandlers/didContextIdHandler.js";
2
2
  export * from "./factories/identityConnectorFactory.js";
3
3
  export * from "./factories/identityProfileConnectorFactory.js";
4
4
  export * from "./factories/identityResolverConnectorFactory.js";
5
+ export * from "./models/api/identity/IIdentityAlsoKnownAsCreateRequest.js";
6
+ export * from "./models/api/identity/IIdentityAlsoKnownAsRemoveRequest.js";
5
7
  export * from "./models/api/identity/IIdentityCreateRequest.js";
6
8
  export * from "./models/api/identity/IIdentityCreateResponse.js";
7
9
  export * from "./models/api/identity/IIdentityProofCreateRequest.js";
@@ -16,10 +18,12 @@ export * from "./models/api/identity/IIdentityVerifiableCredentialCreateRequest.
16
18
  export * from "./models/api/identity/IIdentityVerifiableCredentialCreateResponse.js";
17
19
  export * from "./models/api/identity/IIdentityVerifiableCredentialRevokeRequest.js";
18
20
  export * from "./models/api/identity/IIdentityVerifiableCredentialUnrevokeRequest.js";
21
+ export * from "./models/api/identity/IIdentityVerifiableCredentialVerifyDocumentRequest.js";
19
22
  export * from "./models/api/identity/IIdentityVerifiableCredentialVerifyRequest.js";
20
23
  export * from "./models/api/identity/IIdentityVerifiableCredentialVerifyResponse.js";
21
24
  export * from "./models/api/identity/IIdentityVerifiablePresentationCreateRequest.js";
22
25
  export * from "./models/api/identity/IIdentityVerifiablePresentationCreateResponse.js";
26
+ export * from "./models/api/identity/IIdentityVerifiablePresentationVerifyDocumentRequest.js";
23
27
  export * from "./models/api/identity/IIdentityVerifiablePresentationVerifyRequest.js";
24
28
  export * from "./models/api/identity/IIdentityVerifiablePresentationVerifyResponse.js";
25
29
  export * from "./models/api/identity/IIdentityVerificationMethodCreateRequest.js";
@@ -41,6 +45,8 @@ export * from "./models/IIdentityProfileComponent.js";
41
45
  export * from "./models/IIdentityProfileConnector.js";
42
46
  export * from "./models/IIdentityResolverComponent.js";
43
47
  export * from "./models/IIdentityResolverConnector.js";
48
+ export * from "./models/identityMetricIds.js";
49
+ export * from "./models/identityMetrics.js";
44
50
  export * from "./types/did.js";
45
51
  export * from "./utils/documentHelper.js";
46
52
  export * from "./utils/verificationHelper.js";
@@ -16,7 +16,7 @@ export interface IIdentityComponent extends IComponent {
16
16
  * Remove an identity.
17
17
  * @param identity The id of the document to remove.
18
18
  * @param controller The controller of the identity who can make changes.
19
- * @returns Nothing.
19
+ * @returns A promise that resolves when the identity has been removed.
20
20
  */
21
21
  identityRemove(identity: string, controller?: string): Promise<void>;
22
22
  /**
@@ -34,7 +34,7 @@ export interface IIdentityComponent extends IComponent {
34
34
  * Remove a verification method from the document.
35
35
  * @param verificationMethodId The id of the verification method.
36
36
  * @param controller The controller of the identity who can make changes.
37
- * @returns Nothing.
37
+ * @returns A promise that resolves when the verification method has been removed.
38
38
  * @throws NotFoundError if the id can not be resolved.
39
39
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
40
40
  */
@@ -54,10 +54,32 @@ export interface IIdentityComponent extends IComponent {
54
54
  * Remove a service from the document.
55
55
  * @param serviceId The id of the service.
56
56
  * @param controller The controller of the identity who can make changes.
57
- * @returns Nothing.
57
+ * @returns A promise that resolves when the service has been removed.
58
58
  * @throws NotFoundError if the id can not be resolved.
59
59
  */
60
60
  serviceRemove(serviceId: string, controller?: string): Promise<void>;
61
+ /**
62
+ * Add an alias to the alsoKnownAs property on the document.
63
+ * If the alias is already present the operation is a no-op.
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
+ * @param controller The controller of the identity who can make changes.
67
+ * @returns A promise that resolves when the alias has been added.
68
+ * @throws GeneralError if the alias is not a Url or Urn.
69
+ * @throws NotFoundError if the id can not be resolved.
70
+ */
71
+ alsoKnownAsAdd(documentId: string, alias: string, controller?: string): Promise<void>;
72
+ /**
73
+ * Remove an alias from the alsoKnownAs property on the document.
74
+ * If the alias is not present the operation is a no-op.
75
+ * @param documentId The id of the document to update.
76
+ * @param alias The alias to remove. Must be a Url or Urn.
77
+ * @param controller The controller of the identity who can make changes.
78
+ * @returns A promise that resolves when the alias has been removed.
79
+ * @throws GeneralError if the alias is not a Url or Urn.
80
+ * @throws NotFoundError if the id can not be resolved.
81
+ */
82
+ alsoKnownAsRemove(documentId: string, alias: string, controller?: string): Promise<void>;
61
83
  /**
62
84
  * Create a verifiable credential for a verification method.
63
85
  * @param verificationMethodId The verification method id to use.
@@ -66,6 +88,8 @@ export interface IIdentityComponent 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
  * @param controller The controller of the identity who can make changes.
70
94
  * @returns The created verifiable credential and its token.
71
95
  * @throws NotFoundError if the id can not be resolved.
@@ -73,33 +97,39 @@ export interface IIdentityComponent extends IComponent {
73
97
  verifiableCredentialCreate(verificationMethodId: string, id: string | undefined, subject: IJsonLdNodeObject, options?: {
74
98
  revocationIndex?: number;
75
99
  expirationDate?: Date;
100
+ jwtHeaderFields?: {
101
+ [id: string]: string;
102
+ };
103
+ jwtPayloadFields?: {
104
+ [id: string]: string;
105
+ };
76
106
  }, controller?: string): Promise<{
77
107
  verifiableCredential: IDidVerifiableCredential;
78
108
  jwt: string;
79
109
  }>;
80
110
  /**
81
111
  * Verify a verifiable credential is valid.
82
- * @param credentialJwt The credential to verify.
112
+ * @param credential The credential to verify.
83
113
  * @returns The credential stored in the jwt and the revocation status.
84
114
  */
85
- verifiableCredentialVerify(credentialJwt: string): Promise<{
115
+ verifiableCredentialVerify(credential: string | IDidVerifiableCredential): Promise<{
86
116
  revoked: boolean;
87
117
  verifiableCredential?: IDidVerifiableCredential;
88
118
  }>;
89
119
  /**
90
120
  * Revoke verifiable credential.
91
121
  * @param issuerId The id of the document to update the revocation list for.
92
- * @param credentialIndex The revocation bitmap index revoke.
122
+ * @param credentialIndex The revocation bitmap index to revoke.
93
123
  * @param controller The controller of the identity who can make changes.
94
- * @returns Nothing.
124
+ * @returns A promise that resolves when the credential has been revoked.
95
125
  */
96
126
  verifiableCredentialRevoke(issuerId: string, credentialIndex: number, controller?: string): Promise<void>;
97
127
  /**
98
128
  * Unrevoke verifiable credential.
99
129
  * @param issuerId The id of the document to update the revocation list for.
100
- * @param credentialIndex The revocation bitmap index to un revoke.
130
+ * @param credentialIndex The revocation bitmap index to unrevoke.
101
131
  * @param controller The controller of the identity who can make changes.
102
- * @returns Nothing.
132
+ * @returns A promise that resolves when the credential has been unrevoked.
103
133
  */
104
134
  verifiableCredentialUnrevoke(issuerId: string, credentialIndex: number, controller?: string): Promise<void>;
105
135
  /**
@@ -109,21 +139,32 @@ export interface IIdentityComponent 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
  * @param controller The controller of the identity who can make changes.
114
147
  * @returns The created verifiable presentation and its token.
115
148
  * @throws NotFoundError if the id can not be resolved.
116
149
  */
117
- verifiablePresentationCreate(verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number, controller?: string): Promise<{
150
+ verifiablePresentationCreate(verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], options?: {
151
+ expirationDate?: Date;
152
+ jwtHeaderFields?: {
153
+ [id: string]: string;
154
+ };
155
+ jwtPayloadFields?: {
156
+ [id: string]: string;
157
+ };
158
+ }, controller?: string): Promise<{
118
159
  verifiablePresentation: IDidVerifiablePresentation;
119
160
  jwt: string;
120
161
  }>;
121
162
  /**
122
163
  * Verify a verifiable presentation is valid.
123
- * @param presentationJwt The presentation to verify.
164
+ * @param presentation The presentation to verify.
124
165
  * @returns The presentation stored in the jwt and the revocation status.
125
166
  */
126
- verifiablePresentationVerify(presentationJwt: string): Promise<{
167
+ verifiablePresentationVerify(presentation: string | IDidVerifiablePresentation): Promise<{
127
168
  revoked: boolean;
128
169
  verifiablePresentation?: IDidVerifiablePresentation;
129
170
  issuers?: IDidDocument[];
@@ -15,7 +15,7 @@ export interface IIdentityConnector extends IComponent {
15
15
  * Remove a document.
16
16
  * @param controller The controller of the identity who can make changes.
17
17
  * @param documentId The id of the document to remove.
18
- * @returns Nothing.
18
+ * @returns A promise that resolves when the document has been removed.
19
19
  */
20
20
  removeDocument(controller: string, documentId: string): Promise<void>;
21
21
  /**
@@ -33,7 +33,7 @@ export interface IIdentityConnector extends IComponent {
33
33
  * Remove a verification method from the document.
34
34
  * @param controller The controller of the identity who can make changes.
35
35
  * @param verificationMethodId The id of the verification method.
36
- * @returns Nothing.
36
+ * @returns A promise that resolves when the verification method has been removed.
37
37
  * @throws NotFoundError if the id can not be resolved.
38
38
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
39
39
  */
@@ -53,10 +53,32 @@ export interface IIdentityConnector extends IComponent {
53
53
  * Remove a service from the document.
54
54
  * @param controller The controller of the identity who can make changes.
55
55
  * @param serviceId The id of the service.
56
- * @returns Nothing.
56
+ * @returns A promise that resolves when the service has been removed.
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 A promise that resolves when the alias has been added.
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 A promise that resolves when the alias has been removed.
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
  }>;
@@ -90,15 +120,15 @@ export interface IIdentityConnector extends IComponent {
90
120
  * @param controller The controller of the identity who can make changes.
91
121
  * @param issuerDocumentId The id of the document to update the revocation list for.
92
122
  * @param credentialIndices The revocation bitmap index or indices to revoke.
93
- * @returns Nothing.
123
+ * @returns A promise that resolves when the credentials have been revoked.
94
124
  */
95
125
  revokeVerifiableCredentials(controller: string, issuerDocumentId: string, credentialIndices: number[]): Promise<void>;
96
126
  /**
97
127
  * Unrevoke verifiable credential(s).
98
128
  * @param controller The controller of the identity who can make changes.
99
129
  * @param issuerDocumentId The id of the document to update the revocation list for.
100
- * @param credentialIndices The revocation bitmap index or indices to un revoke.
101
- * @returns Nothing.
130
+ * @param credentialIndices The revocation bitmap index or indices to unrevoke.
131
+ * @returns A promise that resolves when the credentials have been unrevoked.
102
132
  */
103
133
  unrevokeVerifiableCredentials(controller: string, issuerDocumentId: string, credentialIndices: number[]): Promise<void>;
104
134
  /**
@@ -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[];
@@ -9,7 +9,7 @@ export interface IIdentityProfileComponent<T extends IJsonLdDocument = IJsonLdDo
9
9
  * @param publicProfile The public profile data as JSON-LD.
10
10
  * @param privateProfile The private profile data as JSON-LD.
11
11
  * @param identity The identity to perform the profile operation on.
12
- * @returns Nothing.
12
+ * @returns A promise that resolves when the profile has been created.
13
13
  */
14
14
  create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
15
15
  /**
@@ -36,13 +36,13 @@ export interface IIdentityProfileComponent<T extends IJsonLdDocument = IJsonLdDo
36
36
  * @param publicProfile The public profile data as JSON-LD.
37
37
  * @param privateProfile The private profile data as JSON-LD.
38
38
  * @param identity The identity to perform the profile operation on.
39
- * @returns Nothing.
39
+ * @returns A promise that resolves when the profile has been updated.
40
40
  */
41
41
  update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
42
42
  /**
43
43
  * Delete the profile for an identity.
44
44
  * @param identity The identity to perform the profile operation on.
45
- * @returns Nothing.
45
+ * @returns A promise that resolves when the profile has been removed.
46
46
  */
47
47
  remove(identity?: string): Promise<void>;
48
48
  /**
@@ -9,7 +9,7 @@ export interface IIdentityProfileConnector<T extends IJsonLdDocument = IJsonLdDo
9
9
  * @param identity The identity of the profile to create.
10
10
  * @param publicProfile The public profile data as JSON-LD.
11
11
  * @param privateProfile The private profile data as JSON-LD.
12
- * @returns Nothing.
12
+ * @returns A promise that resolves when the profile has been created.
13
13
  */
14
14
  create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void>;
15
15
  /**
@@ -28,13 +28,13 @@ export interface IIdentityProfileConnector<T extends IJsonLdDocument = IJsonLdDo
28
28
  * @param identity The identity to update.
29
29
  * @param publicProfile The public profile data as JSON-LD.
30
30
  * @param privateProfile The private profile data as JSON-LD.
31
- * @returns Nothing.
31
+ * @returns A promise that resolves when the profile has been updated.
32
32
  */
33
33
  update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void>;
34
34
  /**
35
35
  * Delete the profile for an identity.
36
36
  * @param identity The identity to delete.
37
- * @returns Nothing.
37
+ * @returns A promise that resolves when the profile has been removed.
38
38
  */
39
39
  remove(identity: string): Promise<void>;
40
40
  /**
@@ -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
  }
@@ -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
+ * Union type of all identity service metric ID string values.
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[];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Helper methods for Ids.
2
+ * Helper methods for parsing and validating DID identifiers.
3
3
  */
4
4
  export declare class Did {
5
5
  /**
@@ -7,7 +7,7 @@ export declare class Did {
7
7
  */
8
8
  static readonly CLASS_NAME: string;
9
9
  /**
10
- * Parse and id in to it's constituent parts.
10
+ * Parse an id into its constituent parts.
11
11
  * @param id The id to parse.
12
12
  * @returns The parsed id.
13
13
  * @throws GeneralError if the id is not valid.
@@ -21,7 +21,7 @@ export declare class Did {
21
21
  * Guard a string as a DID.
22
22
  * @param source The source of the error.
23
23
  * @param property The name of the property.
24
- * @param value The urn to parse.
24
+ * @param value The value to assert as a valid DID.
25
25
  * @throws GuardError If the value does not match the assertion.
26
26
  */
27
27
  static guard(source: string, property: string, value: unknown): asserts value is string;
@@ -10,20 +10,20 @@ export declare class VerificationHelper {
10
10
  */
11
11
  static readonly CLASS_NAME: string;
12
12
  /**
13
- * Verified the JWT.
13
+ * Verify the JWT and return the decoded header and payload.
14
14
  * @param resolver The resolver to use for finding the document.
15
15
  * @param jwt The token to verify.
16
- * @returns The decoded payload.
16
+ * @returns The decoded header and payload.
17
17
  */
18
18
  static verifyJwt<T extends IJwtHeader, U extends IJwtPayload>(resolver: IIdentityResolverComponent, jwt: string): Promise<{
19
19
  header: T;
20
20
  payload: U;
21
21
  }>;
22
22
  /**
23
- * Verified the proof for the document e.g. verifiable credential.
23
+ * Verify the proof for the document.
24
24
  * @param resolver The resolver to use for finding the document.
25
25
  * @param secureDocument The secure document to verify.
26
- * @returns True if the verification is successful.
26
+ * @returns True if all proofs in the document are verified successfully.
27
27
  */
28
28
  static verifyProof(resolver: IIdentityResolverComponent, secureDocument: IJsonLdNodeObject): Promise<boolean>;
29
29
  }