@twin.org/identity-service 0.0.3-next.24 → 0.0.3-next.26
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.
- package/dist/es/identityService.js +49 -2
- package/dist/es/identityService.js.map +1 -1
- package/dist/es/models/IIdentityServiceConstructorOptions.js.map +1 -1
- package/dist/types/identityService.d.ts +4 -0
- package/dist/types/models/IIdentityServiceConstructorOptions.d.ts +4 -0
- package/docs/changelog.md +32 -0
- package/docs/reference/classes/IdentityService.md +16 -0
- package/docs/reference/interfaces/IIdentityServiceConstructorOptions.md +8 -0
- package/package.json +3 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { GeneralError, Guards, Is, Urn } from "@twin.org/core";
|
|
4
|
-
import { DocumentHelper, IdentityConnectorFactory } from "@twin.org/identity-models";
|
|
3
|
+
import { ComponentFactory, GeneralError, Guards, Is, Urn } from "@twin.org/core";
|
|
4
|
+
import { DocumentHelper, IdentityConnectorFactory, IdentityMetricIds, IdentityMetrics } from "@twin.org/identity-models";
|
|
5
5
|
import { DidVerificationMethodType, ProofTypes } from "@twin.org/standards-w3c-did";
|
|
6
|
+
import { MetricHelper } from "@twin.org/telemetry-models";
|
|
6
7
|
import { Jwt } from "@twin.org/web";
|
|
7
8
|
/**
|
|
8
9
|
* Class which implements the identity contract.
|
|
@@ -17,6 +18,11 @@ export class IdentityService {
|
|
|
17
18
|
* @internal
|
|
18
19
|
*/
|
|
19
20
|
_defaultNamespace;
|
|
21
|
+
/**
|
|
22
|
+
* The telemetry component.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
_telemetryComponent;
|
|
20
26
|
/**
|
|
21
27
|
* Create a new instance of IdentityService.
|
|
22
28
|
* @param options The options for the service.
|
|
@@ -27,6 +33,7 @@ export class IdentityService {
|
|
|
27
33
|
throw new GeneralError(IdentityService.CLASS_NAME, "noConnectors");
|
|
28
34
|
}
|
|
29
35
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
36
|
+
this._telemetryComponent = ComponentFactory.getIfExists(options?.telemetryComponentType);
|
|
30
37
|
}
|
|
31
38
|
/**
|
|
32
39
|
* Returns the class name of the component.
|
|
@@ -35,6 +42,15 @@ export class IdentityService {
|
|
|
35
42
|
className() {
|
|
36
43
|
return IdentityService.CLASS_NAME;
|
|
37
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Register all identity metrics with the telemetry component.
|
|
47
|
+
*/
|
|
48
|
+
async start() {
|
|
49
|
+
if (Is.undefined(this._telemetryComponent)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
await MetricHelper.createMetrics(this._telemetryComponent, IdentityMetrics);
|
|
53
|
+
}
|
|
38
54
|
/**
|
|
39
55
|
* Create a new identity.
|
|
40
56
|
* @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
|
|
@@ -46,6 +62,9 @@ export class IdentityService {
|
|
|
46
62
|
try {
|
|
47
63
|
const identityConnector = this.getConnectorByNamespace(namespace);
|
|
48
64
|
const result = await identityConnector.createDocument(controller);
|
|
65
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {
|
|
66
|
+
namespace: namespace ?? this._defaultNamespace
|
|
67
|
+
});
|
|
49
68
|
return result;
|
|
50
69
|
}
|
|
51
70
|
catch (error) {
|
|
@@ -64,6 +83,7 @@ export class IdentityService {
|
|
|
64
83
|
try {
|
|
65
84
|
const identityConnector = this.getConnectorByUri(identity);
|
|
66
85
|
const result = await identityConnector.removeDocument(controller, identity);
|
|
86
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);
|
|
67
87
|
return result;
|
|
68
88
|
}
|
|
69
89
|
catch (error) {
|
|
@@ -233,6 +253,10 @@ export class IdentityService {
|
|
|
233
253
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
234
254
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
235
255
|
const service = await identityConnector.createVerifiableCredential(controller, verificationMethodId, id, subject, options);
|
|
256
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {
|
|
257
|
+
hasRevocation: Is.number(options?.revocationIndex),
|
|
258
|
+
hasExpiration: Is.date(options?.expirationDate)
|
|
259
|
+
});
|
|
236
260
|
return service;
|
|
237
261
|
}
|
|
238
262
|
catch (error) {
|
|
@@ -252,6 +276,12 @@ export class IdentityService {
|
|
|
252
276
|
try {
|
|
253
277
|
const identityConnector = this.getConnectorByUri(credential.issuer);
|
|
254
278
|
const service = await identityConnector.checkVerifiableCredential(credential);
|
|
279
|
+
if (service.revoked) {
|
|
280
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerificationFailed, { failureReason: "revoked" });
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
|
|
284
|
+
}
|
|
255
285
|
return service;
|
|
256
286
|
}
|
|
257
287
|
catch (error) {
|
|
@@ -272,6 +302,12 @@ export class IdentityService {
|
|
|
272
302
|
try {
|
|
273
303
|
const identityConnector = this.getConnectorByUri(jwtPayload.iss);
|
|
274
304
|
const service = await identityConnector.checkVerifiableCredential(credential);
|
|
305
|
+
if (service.revoked) {
|
|
306
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerificationFailed, { failureReason: "revoked" });
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);
|
|
310
|
+
}
|
|
275
311
|
return service;
|
|
276
312
|
}
|
|
277
313
|
catch (error) {
|
|
@@ -293,6 +329,7 @@ export class IdentityService {
|
|
|
293
329
|
const idParts = DocumentHelper.parseId(issuerIdentity);
|
|
294
330
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
295
331
|
const result = await identityConnector.revokeVerifiableCredentials(controller, issuerIdentity, [credentialIndex]);
|
|
332
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);
|
|
296
333
|
return result;
|
|
297
334
|
}
|
|
298
335
|
catch (error) {
|
|
@@ -314,6 +351,7 @@ export class IdentityService {
|
|
|
314
351
|
const idParts = DocumentHelper.parseId(issuerIdentity);
|
|
315
352
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
316
353
|
const result = await identityConnector.unrevokeVerifiableCredentials(controller, issuerIdentity, [credentialIndex]);
|
|
354
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);
|
|
317
355
|
return result;
|
|
318
356
|
}
|
|
319
357
|
catch (error) {
|
|
@@ -340,6 +378,9 @@ export class IdentityService {
|
|
|
340
378
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
341
379
|
const identityConnector = this.getConnectorByUri(idParts.id);
|
|
342
380
|
const result = await identityConnector.createVerifiablePresentation(controller, verificationMethodId, presentationId, contexts, types, verifiableCredentials, options);
|
|
381
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {
|
|
382
|
+
credentialCount: verifiableCredentials.length
|
|
383
|
+
});
|
|
343
384
|
return result;
|
|
344
385
|
}
|
|
345
386
|
catch (error) {
|
|
@@ -374,6 +415,12 @@ export class IdentityService {
|
|
|
374
415
|
try {
|
|
375
416
|
const identityConnector = this.getConnectorByUri(holder);
|
|
376
417
|
const service = await identityConnector.checkVerifiablePresentation(presentation);
|
|
418
|
+
if (service.revoked) {
|
|
419
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerificationFailed, { failureReason: "revoked" });
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
await MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);
|
|
423
|
+
}
|
|
377
424
|
return service;
|
|
378
425
|
}
|
|
379
426
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identityService.js","sourceRoot":"","sources":["../../src/identityService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EACN,cAAc,EACd,wBAAwB,EAGxB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EACzB,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACH,YAAY,OAA4C;QACvD,MAAM,KAAK,GAAG,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,MAAM,EAAE,gBAAgB,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,eAAe,CAAC,UAAU,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CAAC,SAAkB,EAAE,UAAmB;QAClE,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAE/E,IAAI,CAAC;YACJ,MAAM,iBAAiB,GAAG,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;YAClE,MAAM,MAAM,GAAG,MAAM,iBA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;IACK,uBAAuB,CAAC,SAAkB;QACjD,MAAM,eAAe,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,CAAC;QAE5D,MAAM,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAqB,eAAe,CAAC,CAAC;QAE5F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,eAAe;aAC1B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\ttype IIdentityComponent,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IProof,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IIdentityServiceConstructorOptions } from \"./models/IIdentityServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity contract.\n */\nexport class IdentityService implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Create a new instance of IdentityService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityServiceConstructorOptions) {\n\t\tconst names = IdentityConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\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 IdentityService.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 * @param controller The controller of the identity who can make changes.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string, controller?: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByNamespace(namespace);\n\t\t\tconst result = await identityConnector.createDocument(controller);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"identityCreateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async identityRemove(identity: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\t\t\tconst result = await identityConnector.removeDocument(controller, identity);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"identityRemoveFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\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\tcontroller?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t);\n\n\t\t\treturn verificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodCreateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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 controller The controller of the identity who can make changes.\n\t * @returns Nothing.\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\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeVerificationMethod(controller, verificationMethodId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodRemoveFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\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\tcontroller?: string\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityService.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(IdentityService.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst service = await identityConnector.addService(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tserviceId,\n\t\t\t\tserviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceCreateFailed\",\n\t\t\t\t{ identity, serviceId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeService(controller, serviceId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceRemoveFailed\",\n\t\t\t\t{ serviceId },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\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(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.addAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsAddFailed\",\n\t\t\t\t{ identity: documentId, alias },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\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(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsRemoveFailed\",\n\t\t\t\t{ identity: documentId, alias },\n\t\t\t\terror\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 controller The controller of the identity who can make changes.\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},\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\t\tGuards.object(IdentityService.CLASS_NAME, nameof(subject), subject);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst service = await identityConnector.createVerifiableCredential(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tid,\n\t\t\t\tsubject,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential.issuer), credential.issuer);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tconst identityConnector = this.getConnectorByUri(credential.issuer);\n\n\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\t\treturn service;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\tundefined,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\tconst jwtHeader = jwtDecoded.header;\n\t\tconst jwtPayload = jwtDecoded.payload;\n\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\tif (\n\t\t\tIs.undefined(jwtHeader) ||\n\t\t\tIs.undefined(jwtPayload) ||\n\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\tIs.undefined(jwtSignature)\n\t\t) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(jwtPayload.iss);\n\n\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.revokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialRevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.unrevokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialUnrevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\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 controller The controller of the identity who can make changes.\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?: { expirationDate?: Date },\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createVerifiablePresentation(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\toptions\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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\tlet holder;\n\t\tif (Is.stringValue(presentation)) {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(presentation), presentation);\n\n\t\t\tconst jwtDecoded = await Jwt.decode(presentation);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t\t}\n\n\t\t\tholder = jwtPayload.iss;\n\t\t} else {\n\t\t\tholder = presentation.holder;\n\t\t}\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(holder), holder);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(holder);\n\n\t\t\tconst service = await identityConnector.checkVerifiablePresentation(presentation);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationVerifyFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\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 * @param controller The controller of the identity who can make changes.\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\tcontroller?: string\n\t): Promise<IProof> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityService.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\tIdentityService.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"proofCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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>(IdentityService.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityService.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.verifyProof(document, proof);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"proofVerifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tconst connector = IdentityConnectorFactory.getIfExists<IIdentityConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\tnamespace: namespaceMethod\n\t\t\t});\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"identityService.js","sourceRoot":"","sources":["../../src/identityService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAGf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EACzB,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,mBAAmB,CAAuB;IAE3D;;;OAGG;IACH,YAAY,OAA4C;QACvD,MAAM,KAAK,GAAG,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,MAAM,KA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AAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACK,uBAAuB,CAAC,SAAkB;QACjD,MAAM,eAAe,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,CAAC;QAE5D,MAAM,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAqB,eAAe,CAAC,CAAC;QAE5F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,eAAe;aAC1B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityMetricIds,\n\tIdentityMetrics,\n\ttype IIdentityComponent,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IProof,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport { MetricHelper, type ITelemetryComponent } from \"@twin.org/telemetry-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IIdentityServiceConstructorOptions } from \"./models/IIdentityServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity contract.\n */\nexport class IdentityService implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The telemetry component.\n\t * @internal\n\t */\n\tprivate readonly _telemetryComponent?: ITelemetryComponent;\n\n\t/**\n\t * Create a new instance of IdentityService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityServiceConstructorOptions) {\n\t\tconst names = IdentityConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\n\t\tthis._telemetryComponent = ComponentFactory.getIfExists<ITelemetryComponent>(\n\t\t\toptions?.telemetryComponentType\n\t\t);\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register all identity metrics with the telemetry component.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tif (Is.undefined(this._telemetryComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait MetricHelper.createMetrics(this._telemetryComponent, IdentityMetrics);\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 * @param controller The controller of the identity who can make changes.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string, controller?: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByNamespace(namespace);\n\t\t\tconst result = await identityConnector.createDocument(controller);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {\n\t\t\t\tnamespace: namespace ?? this._defaultNamespace\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"identityCreateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async identityRemove(identity: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\t\t\tconst result = await identityConnector.removeDocument(controller, identity);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"identityRemoveFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\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\tcontroller?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t);\n\n\t\t\treturn verificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodCreateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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 controller The controller of the identity who can make changes.\n\t * @returns Nothing.\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\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeVerificationMethod(controller, verificationMethodId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodRemoveFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\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\tcontroller?: string\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityService.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(IdentityService.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst service = await identityConnector.addService(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tserviceId,\n\t\t\t\tserviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceCreateFailed\",\n\t\t\t\t{ identity, serviceId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeService(controller, serviceId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceRemoveFailed\",\n\t\t\t\t{ serviceId },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\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(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.addAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsAddFailed\",\n\t\t\t\t{ identity: documentId, alias },\n\t\t\t\terror\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 * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\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(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsRemoveFailed\",\n\t\t\t\t{ identity: documentId, alias },\n\t\t\t\terror\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 controller The controller of the identity who can make changes.\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},\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\t\tGuards.object(IdentityService.CLASS_NAME, nameof(subject), subject);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst service = await identityConnector.createVerifiableCredential(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tid,\n\t\t\t\tsubject,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {\n\t\t\t\thasRevocation: Is.number(options?.revocationIndex),\n\t\t\t\thasExpiration: Is.date(options?.expirationDate)\n\t\t\t});\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential.issuer), credential.issuer);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tconst identityConnector = this.getConnectorByUri(credential.issuer);\n\n\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\t\tif (service.revoked) {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerified\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn service;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\tundefined,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\tconst jwtHeader = jwtDecoded.header;\n\t\tconst jwtPayload = jwtDecoded.payload;\n\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\tif (\n\t\t\tIs.undefined(jwtHeader) ||\n\t\t\tIs.undefined(jwtPayload) ||\n\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\tIs.undefined(jwtSignature)\n\t\t) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(jwtPayload.iss);\n\n\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.revokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialRevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.unrevokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialUnrevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\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 controller The controller of the identity who can make changes.\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?: { expirationDate?: Date },\n\t\tcontroller?: string\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createVerifiablePresentation(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {\n\t\t\t\tcredentialCount: verifiableCredentials.length\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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\tlet holder;\n\t\tif (Is.stringValue(presentation)) {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(presentation), presentation);\n\n\t\t\tconst jwtDecoded = await Jwt.decode(presentation);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t\t}\n\n\t\t\tholder = jwtPayload.iss;\n\t\t} else {\n\t\t\tholder = presentation.holder;\n\t\t}\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(holder), holder);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(holder);\n\n\t\t\tconst service = await identityConnector.checkVerifiablePresentation(presentation);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VpsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationVerifyFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\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 * @param controller The controller of the identity who can make changes.\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\tcontroller?: string\n\t): Promise<IProof> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityService.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\tIdentityService.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"proofCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\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>(IdentityService.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityService.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.verifyProof(document, proof);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"proofVerifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tconst connector = IdentityConnectorFactory.getIfExists<IIdentityConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\tnamespace: namespaceMethod\n\t\t\t});\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IIdentityServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IIdentityServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IIdentityServiceConfig } from \"./IIdentityServiceConfig.js\";\n\n/**\n * Options for the identity service constructor.\n */\nexport interface IIdentityServiceConstructorOptions {\n\t/**\n\t * The configuration for the identity service.\n\t */\n\tconfig?: IIdentityServiceConfig;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IIdentityServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IIdentityServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IIdentityServiceConfig } from \"./IIdentityServiceConfig.js\";\n\n/**\n * Options for the identity service constructor.\n */\nexport interface IIdentityServiceConstructorOptions {\n\t/**\n\t * The configuration for the identity service.\n\t */\n\tconfig?: IIdentityServiceConfig;\n\n\t/**\n\t * The component type for the optional telemetry component used for event metrics.\n\t */\n\ttelemetryComponentType?: string;\n}\n"]}
|
|
@@ -20,6 +20,10 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
20
20
|
* @returns The class name of the component.
|
|
21
21
|
*/
|
|
22
22
|
className(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Register all identity metrics with the telemetry component.
|
|
25
|
+
*/
|
|
26
|
+
start(): Promise<void>;
|
|
23
27
|
/**
|
|
24
28
|
* Create a new identity.
|
|
25
29
|
* @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
|
|
@@ -7,4 +7,8 @@ export interface IIdentityServiceConstructorOptions {
|
|
|
7
7
|
* The configuration for the identity service.
|
|
8
8
|
*/
|
|
9
9
|
config?: IIdentityServiceConfig;
|
|
10
|
+
/**
|
|
11
|
+
* The component type for the optional telemetry component used for event metrics.
|
|
12
|
+
*/
|
|
13
|
+
telemetryComponentType?: string;
|
|
10
14
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.26](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.0.3-next.25...identity-service-v0.0.3-next.26) (2026-05-21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add telemetry metrics ([#132](https://github.com/iotaledger/twin-identity/issues/132)) ([b51cd78](https://github.com/iotaledger/twin-identity/commit/b51cd7816905fd55e250035daf1b8f2047cba83d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.0.3-next.25 to 0.0.3-next.26
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/identity-connector-entity-storage bumped from 0.0.3-next.25 to 0.0.3-next.26
|
|
18
|
+
|
|
19
|
+
## [0.0.3-next.25](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.0.3-next.24...identity-service-v0.0.3-next.25) (2026-05-20)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Miscellaneous Chores
|
|
23
|
+
|
|
24
|
+
* **identity-service:** Synchronize repo versions
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @twin.org/identity-models bumped from 0.0.3-next.24 to 0.0.3-next.25
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @twin.org/identity-connector-entity-storage bumped from 0.0.3-next.24 to 0.0.3-next.25
|
|
34
|
+
|
|
3
35
|
## [0.0.3-next.24](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.0.3-next.23...identity-service-v0.0.3-next.24) (2026-05-13)
|
|
4
36
|
|
|
5
37
|
|
|
@@ -54,6 +54,22 @@ The class name of the component.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
+
### start() {#start}
|
|
58
|
+
|
|
59
|
+
> **start**(): `Promise`\<`void`\>
|
|
60
|
+
|
|
61
|
+
Register all identity metrics with the telemetry component.
|
|
62
|
+
|
|
63
|
+
#### Returns
|
|
64
|
+
|
|
65
|
+
`Promise`\<`void`\>
|
|
66
|
+
|
|
67
|
+
#### Implementation of
|
|
68
|
+
|
|
69
|
+
`IIdentityComponent.start`
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
57
73
|
### identityCreate() {#identitycreate}
|
|
58
74
|
|
|
59
75
|
> **identityCreate**(`namespace?`, `controller?`): `Promise`\<`IDidDocument`\>
|
|
@@ -9,3 +9,11 @@ Options for the identity service constructor.
|
|
|
9
9
|
> `optional` **config?**: [`IIdentityServiceConfig`](IIdentityServiceConfig.md)
|
|
10
10
|
|
|
11
11
|
The configuration for the identity service.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### telemetryComponentType? {#telemetrycomponenttype}
|
|
16
|
+
|
|
17
|
+
> `optional` **telemetryComponentType?**: `string`
|
|
18
|
+
|
|
19
|
+
The component type for the optional telemetry component used for event metrics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.26",
|
|
4
4
|
"description": "Service contracts and REST endpoint definitions for exposing identity workflows through stable interfaces.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"@twin.org/data-json-ld": "next",
|
|
23
23
|
"@twin.org/entity": "next",
|
|
24
24
|
"@twin.org/entity-storage-models": "next",
|
|
25
|
-
"@twin.org/identity-models": "0.0.3-next.
|
|
25
|
+
"@twin.org/identity-models": "0.0.3-next.26",
|
|
26
26
|
"@twin.org/standards-w3c-did": "next",
|
|
27
|
+
"@twin.org/telemetry-models": "next",
|
|
27
28
|
"@twin.org/vault-models": "next",
|
|
28
29
|
"@twin.org/web": "next"
|
|
29
30
|
},
|