@3sixty/identity-rest-client 0.0.0-stage → 0.20.0-next.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.
@@ -0,0 +1,388 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@3sixty/api-core";
4
+ import { Coerce, Guards, Is } from "@3sixty/core";
5
+ import { DocumentHelper } from "@3sixty/identity-models";
6
+ import { DidVerificationMethodType, ProofTypes } from "@3sixty/standards-w3c-did";
7
+ import { HttpMethod } from "@3sixty/web";
8
+ /**
9
+ * Client for performing identity through to REST endpoints.
10
+ */
11
+ export class IdentityRestClient extends BaseRestClient {
12
+ /**
13
+ * Runtime name for the class.
14
+ */
15
+ static CLASS_NAME = "IdentityRestClient";
16
+ /**
17
+ * Create a new instance of IdentityRestClient.
18
+ * @param config The configuration for the client.
19
+ */
20
+ constructor(config) {
21
+ super("IdentityRestClient", config, "identity");
22
+ }
23
+ /**
24
+ * Returns the class name of the component.
25
+ * @returns The class name of the component.
26
+ */
27
+ className() {
28
+ return IdentityRestClient.CLASS_NAME;
29
+ }
30
+ /**
31
+ * Create a new identity.
32
+ * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
33
+ * @returns The created identity document.
34
+ */
35
+ async identityCreate(namespace) {
36
+ const response = await this.fetch("/", HttpMethod.POST, {
37
+ body: {
38
+ namespace
39
+ }
40
+ });
41
+ return response.body;
42
+ }
43
+ /**
44
+ * Remove an identity.
45
+ * @param identity The id of the document to remove.
46
+ * @param options Optional settings.
47
+ * @param options.removeKeys Also remove any associated private keys from the vault.
48
+ * @param options.removeDocumentKey Also remove the document key from the vault.
49
+ * @returns A promise that resolves when the identity has been removed.
50
+ */
51
+ async identityRemove(identity, options) {
52
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
53
+ await this.fetch("/:identity", HttpMethod.DELETE, {
54
+ pathParams: {
55
+ identity
56
+ },
57
+ query: {
58
+ removeKeys: Coerce.string(options?.removeKeys),
59
+ removeDocumentKey: Coerce.string(options?.removeDocumentKey)
60
+ }
61
+ });
62
+ }
63
+ /**
64
+ * Add a verification method to the document in JSON Web key Format.
65
+ * @param identity The id of the document to add the verification method to.
66
+ * @param verificationMethodType The type of the verification method to add.
67
+ * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.
68
+ * @returns The verification method.
69
+ * @throws NotFoundError if the id can not be resolved.
70
+ * @throws NotSupportedError if the platform does not support multiple keys.
71
+ */
72
+ async verificationMethodCreate(identity, verificationMethodType, verificationMethodId) {
73
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
74
+ Guards.arrayOneOf(IdentityRestClient.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(DidVerificationMethodType));
75
+ const response = await this.fetch("/:identity/verification-method", HttpMethod.POST, {
76
+ pathParams: {
77
+ identity
78
+ },
79
+ body: {
80
+ verificationMethodType,
81
+ verificationMethodId
82
+ }
83
+ });
84
+ return response.body;
85
+ }
86
+ /**
87
+ * Remove a verification method from the document.
88
+ * @param verificationMethodId The id of the verification method.
89
+ * @param options Optional settings.
90
+ * @param options.removeKeys Also remove any associated private key from the vault.
91
+ * @param controller Unused by the REST client; the controller is resolved server-side from the session context.
92
+ * @returns A promise that resolves when the verification method has been removed.
93
+ * @throws NotFoundError if the id can not be resolved.
94
+ * @throws NotSupportedError if the platform does not support multiple revocable keys.
95
+ */
96
+ async verificationMethodRemove(verificationMethodId, options, controller) {
97
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
98
+ const idParts = DocumentHelper.parseId(verificationMethodId);
99
+ await this.fetch("/:identity/verification-method/:verificationMethodId", HttpMethod.DELETE, {
100
+ pathParams: {
101
+ identity: idParts.id,
102
+ verificationMethodId: idParts.fragment ?? ""
103
+ },
104
+ query: { removeKeys: Coerce.string(options?.removeKeys) }
105
+ });
106
+ }
107
+ /**
108
+ * Add a service to the document.
109
+ * @param identity The id of the document to add the service to.
110
+ * @param serviceId The id of the service.
111
+ * @param serviceType The type of the service.
112
+ * @param serviceEndpoint The endpoint for the service.
113
+ * @returns The service.
114
+ * @throws NotFoundError if the id can not be resolved.
115
+ */
116
+ async serviceCreate(identity, serviceId, serviceType, serviceEndpoint) {
117
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
118
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceId", serviceId);
119
+ if (Is.array(serviceType)) {
120
+ Guards.arrayValue(IdentityRestClient.CLASS_NAME, "serviceType", serviceType);
121
+ }
122
+ else {
123
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceType", serviceType);
124
+ }
125
+ if (Is.array(serviceEndpoint)) {
126
+ Guards.arrayValue(IdentityRestClient.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
127
+ }
128
+ else {
129
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
130
+ }
131
+ const response = await this.fetch("/:identity/service", HttpMethod.POST, {
132
+ pathParams: {
133
+ identity
134
+ },
135
+ body: {
136
+ serviceId,
137
+ type: serviceType,
138
+ endpoint: serviceEndpoint
139
+ }
140
+ });
141
+ return response.body;
142
+ }
143
+ /**
144
+ * Remove a service from the document.
145
+ * @param serviceId The id of the service.
146
+ * @returns A promise that resolves when the service has been removed.
147
+ * @throws NotFoundError if the id can not be resolved.
148
+ */
149
+ async serviceRemove(serviceId) {
150
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceId", serviceId);
151
+ const idParts = DocumentHelper.parseId(serviceId);
152
+ await this.fetch("/:identity/service/:serviceId", HttpMethod.DELETE, {
153
+ pathParams: {
154
+ identity: idParts.id,
155
+ serviceId: idParts.fragment ?? ""
156
+ }
157
+ });
158
+ }
159
+ /**
160
+ * Add an alias to the alsoKnownAs property on the document.
161
+ * If the alias is already present the operation is a no-op.
162
+ * @param documentId The id of the document to update.
163
+ * @param alias The alias to add. Must be a Url or Urn (typically another DID).
164
+ * @returns A promise that resolves when the alias has been added.
165
+ * @throws GeneralError if the alias is not a Url or Urn.
166
+ * @throws NotFoundError if the id can not be resolved.
167
+ */
168
+ async alsoKnownAsAdd(documentId, alias) {
169
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "documentId", documentId);
170
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "alias", alias);
171
+ await this.fetch("/:identity/alias", HttpMethod.POST, {
172
+ pathParams: {
173
+ identity: documentId
174
+ },
175
+ body: {
176
+ alias
177
+ }
178
+ });
179
+ }
180
+ /**
181
+ * Remove an alias from the alsoKnownAs property on the document.
182
+ * If the alias is not present the operation is a no-op.
183
+ * @param documentId The id of the document to update.
184
+ * @param alias The alias to remove. Must be a Url or Urn.
185
+ * @returns A promise that resolves when the alias has been removed.
186
+ * @throws GeneralError if the alias is not a Url or Urn.
187
+ * @throws NotFoundError if the id can not be resolved.
188
+ */
189
+ async alsoKnownAsRemove(documentId, alias) {
190
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "documentId", documentId);
191
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "alias", alias);
192
+ await this.fetch("/:identity/alias/:alias", HttpMethod.DELETE, {
193
+ pathParams: {
194
+ identity: documentId,
195
+ alias
196
+ }
197
+ });
198
+ }
199
+ /**
200
+ * Create a verifiable credential for a verification method.
201
+ * @param verificationMethodId The verification method id to use.
202
+ * @param id The id of the credential.
203
+ * @param subject The credential subject to store in the verifiable credential.
204
+ * @param options Additional options for creating the verifiable credential.
205
+ * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
206
+ * @param options.expirationDate The date the verifiable credential is valid until.
207
+ * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.
208
+ * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.
209
+ * @returns The created verifiable credential and its token.
210
+ * @throws NotFoundError if the id can not be resolved.
211
+ */
212
+ async verifiableCredentialCreate(verificationMethodId, id, subject, options) {
213
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
214
+ Guards.object(IdentityRestClient.CLASS_NAME, "subject", subject);
215
+ if (!Is.undefined(options?.revocationIndex)) {
216
+ Guards.number(IdentityRestClient.CLASS_NAME, "options.revocationIndex", options?.revocationIndex);
217
+ }
218
+ const idParts = DocumentHelper.parseId(verificationMethodId);
219
+ const response = await this.fetch("/:identity/verifiable-credential", HttpMethod.POST, {
220
+ pathParams: {
221
+ identity: idParts.id,
222
+ verificationMethodId: idParts.fragment ?? ""
223
+ },
224
+ body: {
225
+ credentialId: id,
226
+ subject,
227
+ revocationIndex: options?.revocationIndex,
228
+ expirationDate: options?.expirationDate?.toISOString(),
229
+ jwtHeaderFields: options?.jwtHeaderFields,
230
+ jwtPayloadFields: options?.jwtPayloadFields
231
+ }
232
+ });
233
+ return response.body;
234
+ }
235
+ /**
236
+ * Verify a verifiable credential is valid.
237
+ * @param credential The credential to verify.
238
+ * @returns The credential stored in the jwt and the revocation status.
239
+ */
240
+ async verifiableCredentialVerify(credential) {
241
+ if (Is.object(credential)) {
242
+ Guards.object(IdentityRestClient.CLASS_NAME, "credential", credential);
243
+ const response = await this.fetch("/verifiable-credential/verify/document", HttpMethod.POST, { body: credential });
244
+ return response.body;
245
+ }
246
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "credential", credential);
247
+ const response = await this.fetch("/verifiable-credential/verify", HttpMethod.GET, { query: { jwt: credential } });
248
+ return response.body;
249
+ }
250
+ /**
251
+ * Revoke verifiable credential.
252
+ * @param issuerId The id of the document to update the revocation list for.
253
+ * @param credentialIndex The revocation bitmap index to revoke.
254
+ * @returns A promise that resolves when the credential has been revoked.
255
+ */
256
+ async verifiableCredentialRevoke(issuerId, credentialIndex) {
257
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "issuerId", issuerId);
258
+ Guards.integer(IdentityRestClient.CLASS_NAME, "credentialIndex", credentialIndex);
259
+ await this.fetch("/:identity/verifiable-credential/revoke/:revocationIndex", HttpMethod.GET, {
260
+ pathParams: {
261
+ identity: issuerId,
262
+ revocationIndex: credentialIndex.toString()
263
+ }
264
+ });
265
+ }
266
+ /**
267
+ * Unrevoke verifiable credential.
268
+ * @param issuerId The id of the document to update the revocation list for.
269
+ * @param credentialIndex The revocation bitmap index to unrevoke.
270
+ * @returns A promise that resolves when the credential has been unrevoked.
271
+ */
272
+ async verifiableCredentialUnrevoke(issuerId, credentialIndex) {
273
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "issuerId", issuerId);
274
+ Guards.integer(IdentityRestClient.CLASS_NAME, "credentialIndex", credentialIndex);
275
+ await this.fetch("/:identity/verifiable-credential/unrevoke/:revocationIndex", HttpMethod.GET, {
276
+ pathParams: {
277
+ identity: issuerId,
278
+ revocationIndex: credentialIndex.toString()
279
+ }
280
+ });
281
+ }
282
+ /**
283
+ * Create a verifiable presentation from the supplied verifiable credentials.
284
+ * @param verificationMethodId The method to associate with the presentation.
285
+ * @param presentationId The id of the presentation.
286
+ * @param contexts The contexts for the data stored in the verifiable credential.
287
+ * @param types The types for the data stored in the verifiable credential.
288
+ * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
289
+ * @param options Additional options for creating the verifiable presentation.
290
+ * @param options.expirationDate The date the verifiable presentation is valid until.
291
+ * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.
292
+ * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.
293
+ * @returns The created verifiable presentation and its token.
294
+ * @throws NotFoundError if the id can not be resolved.
295
+ */
296
+ async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, options) {
297
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
298
+ if (Is.array(types)) {
299
+ Guards.arrayValue(IdentityRestClient.CLASS_NAME, "types", types);
300
+ }
301
+ else if (Is.string(types)) {
302
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "types", types);
303
+ }
304
+ Guards.arrayValue(IdentityRestClient.CLASS_NAME, "verifiableCredentials", verifiableCredentials);
305
+ if (!Is.undefined(options?.expirationDate)) {
306
+ Guards.date(IdentityRestClient.CLASS_NAME, "options.expirationDate", options?.expirationDate);
307
+ }
308
+ const idParts = DocumentHelper.parseId(verificationMethodId);
309
+ const response = await this.fetch("/:identity/verifiable-presentation", HttpMethod.POST, {
310
+ pathParams: {
311
+ identity: idParts.id,
312
+ verificationMethodId: idParts.fragment ?? ""
313
+ },
314
+ body: {
315
+ presentationId,
316
+ contexts,
317
+ types,
318
+ verifiableCredentials,
319
+ expirationDate: options?.expirationDate?.toISOString(),
320
+ jwtHeaderFields: options?.jwtHeaderFields,
321
+ jwtPayloadFields: options?.jwtPayloadFields
322
+ }
323
+ });
324
+ return response.body;
325
+ }
326
+ /**
327
+ * Verify a verifiable presentation is valid.
328
+ * @param presentation The presentation to verify.
329
+ * @returns The presentation stored in the jwt and the revocation status.
330
+ */
331
+ async verifiablePresentationVerify(presentation) {
332
+ if (Is.object(presentation)) {
333
+ Guards.object(IdentityRestClient.CLASS_NAME, "presentation", presentation);
334
+ const response = await this.fetch("/verifiable-presentation/verify/document", HttpMethod.POST, { body: presentation });
335
+ return response.body;
336
+ }
337
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "presentation", presentation);
338
+ const response = await this.fetch("/verifiable-presentation/verify", HttpMethod.POST, {
339
+ query: {
340
+ jwt: presentation
341
+ }
342
+ });
343
+ return response.body;
344
+ }
345
+ /**
346
+ * Create a proof for a document with the specified verification method.
347
+ * @param verificationMethodId The verification method id to use.
348
+ * @param proofType The type of proof to create.
349
+ * @param unsecureDocument The unsecure document to create the proof for.
350
+ * @returns The proof.
351
+ */
352
+ async proofCreate(verificationMethodId, proofType, unsecureDocument) {
353
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
354
+ Guards.arrayOneOf(IdentityRestClient.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
355
+ Guards.object(IdentityRestClient.CLASS_NAME, "unsecureDocument", unsecureDocument);
356
+ const idParts = DocumentHelper.parseId(verificationMethodId);
357
+ const response = await this.fetch("/:identity/proof", HttpMethod.POST, {
358
+ pathParams: {
359
+ identity: idParts.id,
360
+ verificationMethodId: idParts.fragment ?? ""
361
+ },
362
+ body: {
363
+ document: unsecureDocument,
364
+ proofType
365
+ }
366
+ });
367
+ return response.body;
368
+ }
369
+ /**
370
+ * Verify proof for a document with the specified verification method.
371
+ * @param document The document to verify.
372
+ * @param proof The proof to verify.
373
+ * @returns True if the proof is verified.
374
+ */
375
+ async proofVerify(document, proof) {
376
+ Guards.object(IdentityRestClient.CLASS_NAME, "document", document);
377
+ Guards.object(IdentityRestClient.CLASS_NAME, "proof", proof);
378
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "proof.verificationMethod", proof.verificationMethod);
379
+ const response = await this.fetch("/proof/verify", HttpMethod.POST, {
380
+ body: {
381
+ document,
382
+ proof
383
+ }
384
+ });
385
+ return response.body.verified;
386
+ }
387
+ }
388
+ //# sourceMappingURL=identityRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityRestClient.js","sourceRoot":"","sources":["../../src/identityRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EACN,cAAc,EA6Bd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,yBAAyB,EAOzB,UAAU,EACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACrD;;OAEG;IACI,MAAM,CAAU,UAAU,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AE;gBACL,QAAQ;gBACR,KAAK;aACL;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC/B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@3sixty/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@3sixty/api-models\";\nimport { Coerce, Guards, Is } from \"@3sixty/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@3sixty/data-json-ld\";\nimport {\n\tDocumentHelper,\n\ttype IIdentityVerifiablePresentationVerifyDocumentRequest,\n\ttype IIdentityAlsoKnownAsCreateRequest,\n\ttype IIdentityAlsoKnownAsRemoveRequest,\n\ttype IIdentityComponent,\n\ttype IIdentityCreateRequest,\n\ttype IIdentityCreateResponse,\n\ttype IIdentityProofCreateRequest,\n\ttype IIdentityProofCreateResponse,\n\ttype IIdentityProofVerifyRequest,\n\ttype IIdentityProofVerifyResponse,\n\ttype IIdentityRemoveRequest,\n\ttype IIdentityServiceCreateRequest,\n\ttype IIdentityServiceCreateResponse,\n\ttype IIdentityServiceRemoveRequest,\n\ttype IIdentityVerifiableCredentialCreateRequest,\n\ttype IIdentityVerifiableCredentialCreateResponse,\n\ttype IIdentityVerifiableCredentialRevokeRequest,\n\ttype IIdentityVerifiableCredentialUnrevokeRequest,\n\ttype IIdentityVerifiableCredentialVerifyDocumentRequest,\n\ttype IIdentityVerifiableCredentialVerifyRequest,\n\ttype IIdentityVerifiableCredentialVerifyResponse,\n\ttype IIdentityVerifiablePresentationCreateRequest,\n\ttype IIdentityVerifiablePresentationCreateResponse,\n\ttype IIdentityVerifiablePresentationVerifyRequest,\n\ttype IIdentityVerifiablePresentationVerifyResponse,\n\ttype IIdentityVerificationMethodCreateRequest,\n\ttype IIdentityVerificationMethodCreateResponse,\n\ttype IIdentityVerificationMethodRemoveRequest\n} from \"@3sixty/identity-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\tDidVerificationMethodType,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation,\n\ttype IProof,\n\tProofTypes\n} from \"@3sixty/standards-w3c-did\";\nimport { HttpMethod } from \"@3sixty/web\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityRestClient extends BaseRestClient implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityRestClient>(), config, \"identity\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string): Promise<IDidDocument> {\n\t\tconst response = await this.fetch<IIdentityCreateRequest, IIdentityCreateResponse>(\n\t\t\t\"/\",\n\t\t\tHttpMethod.POST,\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tnamespace\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @param options.removeDocumentKey Also remove the document key from the vault.\n\t * @returns A promise that resolves when the identity has been removed.\n\t */\n\tpublic async identityRemove(\n\t\tidentity: string,\n\t\toptions?: { removeKeys?: boolean; removeDocumentKey?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tawait this.fetch<IIdentityRemoveRequest, INoContentResponse>(\"/:identity\", HttpMethod.DELETE, {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tremoveKeys: Coerce.string(options?.removeKeys),\n\t\t\t\tremoveDocumentKey: Coerce.string(options?.removeDocumentKey)\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param identity The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerificationMethodCreateRequest,\n\t\t\tIIdentityVerificationMethodCreateResponse\n\t\t>(\"/:identity/verification-method\", HttpMethod.POST, {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @param controller Unused by the REST client; the controller is resolved server-side from the session context.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async verificationMethodRemove(\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean },\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tawait this.fetch<IIdentityVerificationMethodRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/verification-method/:verificationMethodId\",\n\t\t\tHttpMethod.DELETE,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t},\n\t\t\t\tquery: { removeKeys: Coerce.string(options?.removeKeys) }\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param identity The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityServiceCreateRequest,\n\t\t\tIIdentityServiceCreateResponse\n\t\t>(\"/:identity/service\", HttpMethod.POST, {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tserviceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tendpoint: serviceEndpoint\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\tawait this.fetch<IIdentityServiceRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/service/:serviceId\",\n\t\t\tHttpMethod.DELETE,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tserviceId: idParts.fragment ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsAdd(documentId: string, alias: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(alias), alias);\n\n\t\tawait this.fetch<IIdentityAlsoKnownAsCreateRequest, INoContentResponse>(\n\t\t\t\"/:identity/alias\",\n\t\t\tHttpMethod.POST,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: documentId\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\talias\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsRemove(documentId: string, alias: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(alias), alias);\n\n\t\tawait this.fetch<IIdentityAlsoKnownAsRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/alias/:alias\",\n\t\t\tHttpMethod.DELETE,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: documentId,\n\t\t\t\t\talias\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.\n\t * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async verifiableCredentialCreate(\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(subject), subject);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options?.revocationIndex),\n\t\t\t\toptions?.revocationIndex\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialCreateRequest,\n\t\t\tIIdentityVerifiableCredentialCreateResponse\n\t\t>(\"/:identity/verifiable-credential\", HttpMethod.POST, {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tcredentialId: id,\n\t\t\t\tsubject,\n\t\t\t\trevocationIndex: options?.revocationIndex,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString(),\n\t\t\t\tjwtHeaderFields: options?.jwtHeaderFields,\n\t\t\t\tjwtPayloadFields: options?.jwtPayloadFields\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiableCredentialVerify(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.object<IDidVerifiableCredential>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tconst response = await this.fetch<\n\t\t\t\tIIdentityVerifiableCredentialVerifyDocumentRequest,\n\t\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t\t>(\"/verifiable-credential/verify/document\", HttpMethod.POST, { body: credential });\n\n\t\t\treturn response.body;\n\t\t}\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialVerifyRequest,\n\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t>(\"/verifiable-credential/verify\", HttpMethod.GET, { query: { jwt: credential } });\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to revoke.\n\t * @returns A promise that resolves when the credential has been revoked.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialRevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/revoke/:revocationIndex\",\n\t\t\tHttpMethod.GET,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to unrevoke.\n\t * @returns A promise that resolves when the credential has been unrevoked.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialUnrevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/unrevoke/:revocationIndex\",\n\t\t\tHttpMethod.GET,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.\n\t * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async verifiablePresentationCreate(\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredential)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions?.expirationDate\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationCreateRequest,\n\t\t\tIIdentityVerifiablePresentationCreateResponse\n\t\t>(\"/:identity/verifiable-presentation\", HttpMethod.POST, {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString(),\n\t\t\t\tjwtHeaderFields: options?.jwtHeaderFields,\n\t\t\t\tjwtPayloadFields: options?.jwtPayloadFields\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiablePresentationVerify(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tGuards.object<IDidVerifiablePresentation>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(presentation),\n\t\t\t\tpresentation\n\t\t\t);\n\t\t\tconst response = await this.fetch<\n\t\t\t\tIIdentityVerifiablePresentationVerifyDocumentRequest,\n\t\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t\t>(\"/verifiable-presentation/verify/document\", HttpMethod.POST, { body: presentation });\n\n\t\t\treturn response.body;\n\t\t}\n\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(presentation), presentation);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationVerifyRequest,\n\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t>(\"/verifiable-presentation/verify\", HttpMethod.POST, {\n\t\t\tquery: {\n\t\t\t\tjwt: presentation\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Create a proof for a document with the specified verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<IIdentityProofCreateRequest, IIdentityProofCreateResponse>(\n\t\t\t\"/:identity/proof\",\n\t\t\tHttpMethod.POST,\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tdocument: unsecureDocument,\n\t\t\t\t\tproofType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify proof for a document with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityRestClient.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\tconst response = await this.fetch<IIdentityProofVerifyRequest, IIdentityProofVerifyResponse>(\n\t\t\t\"/proof/verify\",\n\t\t\tHttpMethod.POST,\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdocument,\n\t\t\t\t\tproof\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body.verified;\n\t}\n}\n"]}
@@ -0,0 +1,6 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./identityRestClient.js";
4
+ export * from "./identityProfileRestClient.js";
5
+ export * from "./identityResolverRestClient.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./identityRestClient.js\";\nexport * from \"./identityProfileRestClient.js\";\nexport * from \"./identityResolverRestClient.js\";\n"]}
@@ -0,0 +1,111 @@
1
+ import { BaseRestClient } from "@3sixty/api-core";
2
+ import { type IBaseRestClientConfig } from "@3sixty/api-models";
3
+ import type { IJsonLdDocument } from "@3sixty/data-json-ld";
4
+ import type { IIdentityProfileComponent } from "@3sixty/identity-models";
5
+ /**
6
+ * Client for performing identity profile operations through REST endpoints.
7
+ */
8
+ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJsonLdDocument, U extends IJsonLdDocument = IJsonLdDocument> extends BaseRestClient implements IIdentityProfileComponent<T, U> {
9
+ /**
10
+ * Runtime name for the class.
11
+ */
12
+ static readonly CLASS_NAME: string;
13
+ /**
14
+ * Create a new instance of IdentityProfileRestClient.
15
+ * @param config The configuration for the client.
16
+ */
17
+ constructor(config: IBaseRestClientConfig);
18
+ /**
19
+ * Returns the class name of the component.
20
+ * @returns The class name of the component.
21
+ */
22
+ className(): string;
23
+ /**
24
+ * Create the profile properties for an identity.
25
+ * @param publicProfile The public profile data as JSON-LD.
26
+ * @param privateProfile The private profile data as JSON-LD.
27
+ * @returns A promise that resolves when the profile has been created.
28
+ */
29
+ create(publicProfile?: T, privateProfile?: U): Promise<void>;
30
+ /**
31
+ * Get the profile properties for an identity.
32
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
33
+ * @param privatePropertyNames The private properties to get for the profile, defaults to all.
34
+ * @param identity The identity to perform the profile operation on, defaults to the current user.
35
+ * @returns The identity and the items properties.
36
+ */
37
+ get(publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], identity?: string): Promise<{
38
+ identity: string;
39
+ publicProfile?: Partial<T>;
40
+ privateProfile?: Partial<U>;
41
+ }>;
42
+ /**
43
+ * Get the public profile properties for an identity.
44
+ * @param identity The identity to perform the profile operation on.
45
+ * @param propertyNames The public properties to get for the profile, defaults to all.
46
+ * @returns The items properties.
47
+ */
48
+ getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>>;
49
+ /**
50
+ * Update the profile properties of an identity.
51
+ * @param publicProfile The public profile data as JSON-LD.
52
+ * @param privateProfile The private profile data as JSON-LD.
53
+ * @param identity The identity to perform the profile operation on, defaults to the current user.
54
+ * @returns A promise that resolves when the profile has been updated.
55
+ */
56
+ update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
57
+ /**
58
+ * Delete the profile for an identity.
59
+ * @param identity The identity to perform the profile operation on, defaults to the current user.
60
+ * @returns A promise that resolves when the profile has been removed.
61
+ */
62
+ remove(identity?: string): Promise<void>;
63
+ /**
64
+ * Get a list of the requested identities.
65
+ * @param publicFilters The filters to apply to the identities public profiles.
66
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
67
+ * @param cursor The cursor for paged requests.
68
+ * @param limit The maximum number of items in a page.
69
+ * @returns The list of items and cursor for paging.
70
+ */
71
+ list(publicFilters?: {
72
+ propertyName: string;
73
+ propertyValue: unknown;
74
+ }[], publicPropertyNames?: (keyof T)[], cursor?: string, limit?: number): Promise<{
75
+ /**
76
+ * The identities.
77
+ */
78
+ items: {
79
+ identity: string;
80
+ publicProfile?: Partial<T>;
81
+ }[];
82
+ /**
83
+ * An optional cursor, when defined can be used to call find to get more entities.
84
+ */
85
+ cursor?: string;
86
+ }>;
87
+ /**
88
+ * Get the list of identity profiles including private properties.
89
+ * @param publicFilters The filters to apply to the identities public profiles.
90
+ * @param privateFilters The filters to apply to the identities private profiles.
91
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
92
+ * @param privatePropertyNames The private properties to get for the profile, defaults to none.
93
+ * @param cursor The cursor for paged requests.
94
+ * @param limit The maximum number of items in a page.
95
+ * @returns The list of items and cursor for paging.
96
+ */
97
+ listAdmin(publicFilters?: {
98
+ propertyName: string;
99
+ propertyValue: unknown;
100
+ }[], privateFilters?: {
101
+ propertyName: string;
102
+ propertyValue: unknown;
103
+ }[], publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], cursor?: string, limit?: number): Promise<{
104
+ items: {
105
+ identity: string;
106
+ publicProfile?: Partial<T>;
107
+ privateProfile?: Partial<U>;
108
+ }[];
109
+ cursor?: string;
110
+ }>;
111
+ }
@@ -0,0 +1,29 @@
1
+ import { BaseRestClient } from "@3sixty/api-core";
2
+ import type { IBaseRestClientConfig } from "@3sixty/api-models";
3
+ import type { IIdentityResolverComponent } from "@3sixty/identity-models";
4
+ import type { IDidDocument } from "@3sixty/standards-w3c-did";
5
+ /**
6
+ * Client for performing identity resolution through REST endpoints.
7
+ */
8
+ export declare class IdentityResolverRestClient extends BaseRestClient implements IIdentityResolverComponent {
9
+ /**
10
+ * Runtime name for the class.
11
+ */
12
+ static readonly CLASS_NAME: string;
13
+ /**
14
+ * Create a new instance of IdentityResolverRestClient.
15
+ * @param config The configuration for the client.
16
+ */
17
+ constructor(config: IBaseRestClientConfig);
18
+ /**
19
+ * Returns the class name of the component.
20
+ * @returns The class name of the component.
21
+ */
22
+ className(): string;
23
+ /**
24
+ * Resolve an identity.
25
+ * @param documentId The id of the document to resolve.
26
+ * @returns The resolved document.
27
+ */
28
+ identityResolve(documentId: string): Promise<IDidDocument>;
29
+ }