@twin.org/identity-service 0.0.3-next.2 → 0.0.3-next.20
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/README.md +2 -2
- package/dist/es/identityProfileService.js.map +1 -1
- package/dist/es/identityRoutes.js +277 -8
- package/dist/es/identityRoutes.js.map +1 -1
- package/dist/es/identityService.js +91 -23
- package/dist/es/identityService.js.map +1 -1
- package/dist/types/identityRoutes.d.ts +33 -1
- package/dist/types/identityService.d.ts +31 -6
- package/docs/changelog.md +404 -77
- package/docs/examples.md +196 -1
- package/docs/open-api/spec.json +496 -363
- package/docs/reference/classes/IdentityProfileService.md +8 -8
- package/docs/reference/classes/IdentityResolverService.md +3 -3
- package/docs/reference/classes/IdentityService.md +136 -38
- package/docs/reference/functions/identityAlsoKnownAsCreate.md +31 -0
- package/docs/reference/functions/identityAlsoKnownAsRemove.md +31 -0
- package/docs/reference/functions/identityVerifiableCredentialVerifyDocument.md +31 -0
- package/docs/reference/functions/identityVerifiablePresentationVerifyDocument.md +31 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IIdentityProfileServiceConstructorOptions.md +2 -2
- package/docs/reference/interfaces/IIdentityResolverServiceConfig.md +2 -2
- package/docs/reference/interfaces/IIdentityResolverServiceConstructorOptions.md +4 -4
- package/docs/reference/interfaces/IIdentityServiceConfig.md +2 -2
- package/docs/reference/interfaces/IIdentityServiceConstructorOptions.md +2 -2
- package/locales/en.json +2 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# TWIN Identity
|
|
1
|
+
# TWIN Identity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The identity-service package defines service-side identity contracts and REST endpoint behaviour so applications can expose identity capabilities through stable interfaces. It helps backend services remain consistent with shared models and supports predictable integration for client and connector implementations.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identityProfileService.js","sourceRoot":"","sources":["../../src/identityProfileService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EACN,+BAA+B,EAG/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAKlC;;OAEG;IACI,MAAM,CAAU,UAAU,4BAA4C;IAE7E;;;OAGG;IACc,yBAAyB,CAAkC;IAE5E;;;OAGG;IACH,YAAY,OAAmD;QAC9D,IAAI,CAAC,yBAAyB,GAAG,+BAA+B,CAAC,GAAG,CAElE,OAAO,EAAE,0BAA0B,IAAI,kBAAkB,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,eAAe,CAAC,UAAU,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,aAAiB,EAAE,cAAkB,EAAE,QAAiB;QAC3E,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAElF,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,YAAY,CACrB,sBAAsB,CAAC,UAAU,EACjC,cAAc,EACd,EAAE,QAAQ,EAAE,EACZ,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;OAMG;IAC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, NotFoundError } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tIdentityProfileConnectorFactory,\n\ttype IIdentityProfileComponent,\n\ttype IIdentityProfileConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityProfileServiceConstructorOptions } from \"./models/IIdentityProfileServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile contract.\n */\nexport class IdentityProfileService<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileComponent<T, U>\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileService>();\n\n\t/**\n\t * The identity profile connector.\n\t * @internal\n\t */\n\tprivate readonly _identityProfileConnector: IIdentityProfileConnector<T, U>;\n\n\t/**\n\t * Create a new instance of IdentityProfileService.\n\t * @param options The dependencies for the identity profile service.\n\t */\n\tconstructor(options?: IIdentityProfileServiceConstructorOptions) {\n\t\tthis._identityProfileConnector = IdentityProfileConnectorFactory.get<\n\t\t\tIIdentityProfileConnector<T, U>\n\t\t>(options?.profileEntityConnectorType ?? \"identity-profile\");\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 the profile properties for an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tawait this._identityProfileConnector.create(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"createFailed\",\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 * Get the profile properties for an identity.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns The items identity and the properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(\n\t\t\t\tidentity,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tprivatePropertyNames\n\t\t\t);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile: result.publicProfile,\n\t\t\t\tprivateProfile: result.privateProfile\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the public profile properties for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @param propertyNames The properties to get for the item, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity, propertyNames);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn result.publicProfile;\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"getPublicFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.update(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\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 * Delete the profile for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\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 * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: { identity: string; publicProfile?: Partial<T>; privateProfile?: Partial<U> }[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\t// We don't want to return private profile for this type of query\n\t\t\t// as it would expose the values to the REST api\n\t\t\tconst result = await this._identityProfileConnector.list(\n\t\t\t\tpublicFilters,\n\t\t\t\tundefined,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"listFailed\", undefined, error);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"identityProfileService.js","sourceRoot":"","sources":["../../src/identityProfileService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EACN,+BAA+B,EAG/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAIlC;;OAEG;IACI,MAAM,CAAU,UAAU,4BAA4C;IAE7E;;;OAGG;IACc,yBAAyB,CAAkC;IAE5E;;;OAGG;IACH,YAAY,OAAmD;QAC9D,IAAI,CAAC,yBAAyB,GAAG,+BAA+B,CAAC,GAAG,CAElE,OAAO,EAAE,0BAA0B,IAAI,kBAAkB,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,eAAe,CAAC,UAAU,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,aAAiB,EAAE,cAAkB,EAAE,QAAiB;QAC3E,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAElF,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,YAAY,CACrB,sBAAsB,CAAC,UAAU,EACjC,cAAc,EACd,EAAE,QAAQ,EAAE,EACZ,KAA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\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tIdentityProfileConnectorFactory,\n\ttype IIdentityProfileComponent,\n\ttype IIdentityProfileConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityProfileServiceConstructorOptions } from \"./models/IIdentityProfileServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile contract.\n */\nexport class IdentityProfileService<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileComponent<T, U> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileService>();\n\n\t/**\n\t * The identity profile connector.\n\t * @internal\n\t */\n\tprivate readonly _identityProfileConnector: IIdentityProfileConnector<T, U>;\n\n\t/**\n\t * Create a new instance of IdentityProfileService.\n\t * @param options The dependencies for the identity profile service.\n\t */\n\tconstructor(options?: IIdentityProfileServiceConstructorOptions) {\n\t\tthis._identityProfileConnector = IdentityProfileConnectorFactory.get<\n\t\t\tIIdentityProfileConnector<T, U>\n\t\t>(options?.profileEntityConnectorType ?? \"identity-profile\");\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 the profile properties for an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tawait this._identityProfileConnector.create(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"createFailed\",\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 * Get the profile properties for an identity.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns The items identity and the properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(\n\t\t\t\tidentity,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tprivatePropertyNames\n\t\t\t);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile: result.publicProfile,\n\t\t\t\tprivateProfile: result.privateProfile\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the public profile properties for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @param propertyNames The properties to get for the item, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity, propertyNames);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn result.publicProfile;\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"getPublicFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.update(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\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 * Delete the profile for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\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 * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: { identity: string; publicProfile?: Partial<T>; privateProfile?: Partial<U> }[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\t// We don't want to return private profile for this type of query\n\t\t\t// as it would expose the values to the REST api\n\t\t\tconst result = await this._identityProfileConnector.list(\n\t\t\t\tpublicFilters,\n\t\t\t\tundefined,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"listFailed\", undefined, error);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -251,6 +251,70 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
251
251
|
}
|
|
252
252
|
]
|
|
253
253
|
};
|
|
254
|
+
const identityAlsoKnownAsCreateRoute = {
|
|
255
|
+
operationId: "identityAlsoKnownAsCreate",
|
|
256
|
+
summary: "Add an alias to the alsoKnownAs property on the document",
|
|
257
|
+
tag: tagsIdentity[0].name,
|
|
258
|
+
method: "POST",
|
|
259
|
+
path: `${baseRouteName}/:identity/alias`,
|
|
260
|
+
handler: async (httpRequestContext, request) => identityAlsoKnownAsCreate(httpRequestContext, componentName, request),
|
|
261
|
+
requestType: {
|
|
262
|
+
type: "IIdentityAlsoKnownAsCreateRequest",
|
|
263
|
+
examples: [
|
|
264
|
+
{
|
|
265
|
+
id: "identityAlsoKnownAsCreateRequestExample",
|
|
266
|
+
request: {
|
|
267
|
+
pathParams: {
|
|
268
|
+
identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a"
|
|
269
|
+
},
|
|
270
|
+
body: {
|
|
271
|
+
alias: "did:example:123"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
responseType: [
|
|
278
|
+
{
|
|
279
|
+
type: "INoContentResponse"
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
};
|
|
283
|
+
const identityAlsoKnownAsRemoveRoute = {
|
|
284
|
+
operationId: "identityAlsoKnownAsRemove",
|
|
285
|
+
summary: "Remove an alias from the alsoKnownAs property on the document",
|
|
286
|
+
tag: tagsIdentity[0].name,
|
|
287
|
+
method: "DELETE",
|
|
288
|
+
path: `${baseRouteName}/:identity/alias/:alias`,
|
|
289
|
+
handler: async (httpRequestContext, request) => identityAlsoKnownAsRemove(httpRequestContext, componentName, request),
|
|
290
|
+
requestType: {
|
|
291
|
+
type: "IIdentityAlsoKnownAsRemoveRequest",
|
|
292
|
+
examples: [
|
|
293
|
+
{
|
|
294
|
+
id: "identityAlsoKnownAsRemoveRequestExample",
|
|
295
|
+
request: {
|
|
296
|
+
pathParams: {
|
|
297
|
+
identity: "did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a",
|
|
298
|
+
alias: "did:example:123"
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
},
|
|
304
|
+
responseType: [
|
|
305
|
+
{
|
|
306
|
+
type: "INoContentResponse",
|
|
307
|
+
examples: [
|
|
308
|
+
{
|
|
309
|
+
id: "identityAlsoKnownAsRemoveResponseExample",
|
|
310
|
+
response: {
|
|
311
|
+
statusCode: HttpStatusCode.noContent
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
};
|
|
254
318
|
const identityVerifiableCredentialCreateRoute = {
|
|
255
319
|
operationId: "identityVerifiableCredentialCreate",
|
|
256
320
|
summary: "Create an identity verifiable credential",
|
|
@@ -367,6 +431,72 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
367
431
|
],
|
|
368
432
|
skipAuth: true
|
|
369
433
|
};
|
|
434
|
+
const identityVerifiableCredentialVerifyDocumentRoute = {
|
|
435
|
+
operationId: "identityVerifiableCredentialVerifyDocument",
|
|
436
|
+
summary: "Verify an identity verifiable credential document",
|
|
437
|
+
tag: tagsIdentity[0].name,
|
|
438
|
+
method: "POST",
|
|
439
|
+
path: `${baseRouteName}/verifiable-credential/verify/document`,
|
|
440
|
+
handler: async (httpRequestContext, request) => identityVerifiableCredentialVerifyDocument(httpRequestContext, componentName, request),
|
|
441
|
+
requestType: {
|
|
442
|
+
type: "IIdentityVerifiableCredentialVerifyDocumentRequest",
|
|
443
|
+
examples: [
|
|
444
|
+
{
|
|
445
|
+
id: "identityVerifiableCredentialVerifyDocumentRequestExample",
|
|
446
|
+
request: {
|
|
447
|
+
body: {
|
|
448
|
+
"@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
|
|
449
|
+
id: "https://example.com/credentials/3732",
|
|
450
|
+
type: ["VerifiableCredential", "Person"],
|
|
451
|
+
credentialSubject: {
|
|
452
|
+
id: "did:entity-storage:0x4757993355b921a8229bd780f30921b6a0216a72e6c3f37a09d13b8426a17def",
|
|
453
|
+
name: "Jane Doe"
|
|
454
|
+
},
|
|
455
|
+
issuer: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
|
|
456
|
+
issuanceDate: "2025-01-24T09:21:51.500Z",
|
|
457
|
+
credentialStatus: {
|
|
458
|
+
id: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a#revocation",
|
|
459
|
+
type: "BitstringStatusList",
|
|
460
|
+
revocationBitmapIndex: "5"
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
responseType: [
|
|
468
|
+
{
|
|
469
|
+
type: "IIdentityVerifiableCredentialVerifyResponse",
|
|
470
|
+
examples: [
|
|
471
|
+
{
|
|
472
|
+
id: "identityVerifiableCredentialVerifyResponseExample",
|
|
473
|
+
response: {
|
|
474
|
+
body: {
|
|
475
|
+
revoked: false,
|
|
476
|
+
verifiableCredential: {
|
|
477
|
+
"@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
|
|
478
|
+
id: "https://example.com/credentials/3732",
|
|
479
|
+
type: ["VerifiableCredential", "Person"],
|
|
480
|
+
credentialSubject: {
|
|
481
|
+
id: "did:entity-storage:0x4757993355b921a8229bd780f30921b6a0216a72e6c3f37a09d13b8426a17def",
|
|
482
|
+
name: "Jane Doe"
|
|
483
|
+
},
|
|
484
|
+
issuer: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
|
|
485
|
+
issuanceDate: "2025-01-24T09:21:51.500Z",
|
|
486
|
+
credentialStatus: {
|
|
487
|
+
id: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a#revocation",
|
|
488
|
+
type: "BitstringStatusList",
|
|
489
|
+
revocationBitmapIndex: "5"
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
],
|
|
498
|
+
skipAuth: true
|
|
499
|
+
};
|
|
370
500
|
const identityVerifiableCredentialRevokeRoute = {
|
|
371
501
|
operationId: "identityVerifiableCredentialRevoke",
|
|
372
502
|
summary: "Revoke an identity verifiable credential",
|
|
@@ -382,7 +512,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
382
512
|
request: {
|
|
383
513
|
pathParams: {
|
|
384
514
|
identity: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
|
|
385
|
-
revocationIndex: 5
|
|
515
|
+
revocationIndex: "5"
|
|
386
516
|
}
|
|
387
517
|
}
|
|
388
518
|
}
|
|
@@ -417,7 +547,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
417
547
|
request: {
|
|
418
548
|
pathParams: {
|
|
419
549
|
identity: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
|
|
420
|
-
revocationIndex: 5
|
|
550
|
+
revocationIndex: "5"
|
|
421
551
|
}
|
|
422
552
|
}
|
|
423
553
|
}
|
|
@@ -529,6 +659,70 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
529
659
|
],
|
|
530
660
|
skipAuth: true
|
|
531
661
|
};
|
|
662
|
+
const identityVerifiablePresentationVerifyDocumentRoute = {
|
|
663
|
+
operationId: "identityVerifiablePresentationVerifyDocument",
|
|
664
|
+
summary: "Verify an identity verifiable presentation document",
|
|
665
|
+
tag: tagsIdentity[0].name,
|
|
666
|
+
method: "POST",
|
|
667
|
+
path: `${baseRouteName}/verifiable-presentation/verify/document`,
|
|
668
|
+
handler: async (httpRequestContext, request) => identityVerifiablePresentationVerifyDocument(httpRequestContext, componentName, request),
|
|
669
|
+
requestType: {
|
|
670
|
+
type: "IIdentityVerifiablePresentationVerifyDocumentRequest",
|
|
671
|
+
examples: [
|
|
672
|
+
{
|
|
673
|
+
id: "identityVerifiablePresentationVerifyDocumentRequestExample",
|
|
674
|
+
request: {
|
|
675
|
+
body: {
|
|
676
|
+
"@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
|
|
677
|
+
id: "https://example.com/credentials/3732",
|
|
678
|
+
type: ["VerifiableCredential", "Person"],
|
|
679
|
+
verifiableCredential: [
|
|
680
|
+
{
|
|
681
|
+
"@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
|
|
682
|
+
id: "https://example.com/credentials/3732",
|
|
683
|
+
type: ["VerifiableCredential", "Person"],
|
|
684
|
+
credentialSubject: {
|
|
685
|
+
id: "did:entity-storage:0x4757993355b921a8229bd780f30921b6a0216a72e6c3f37a09d13b8426a17def",
|
|
686
|
+
name: "Jane Doe"
|
|
687
|
+
},
|
|
688
|
+
issuer: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a",
|
|
689
|
+
issuanceDate: "2025-01-24T09:21:51.500Z",
|
|
690
|
+
credentialStatus: {
|
|
691
|
+
id: "did:entity-storage:0x879c31386f992cfa29b77fe31e37256d69f6a57653cee4eb60ad4c4613c5515a#revocation",
|
|
692
|
+
type: "BitstringStatusList",
|
|
693
|
+
revocationBitmapIndex: "5"
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
]
|
|
701
|
+
},
|
|
702
|
+
responseType: [
|
|
703
|
+
{
|
|
704
|
+
type: "IIdentityVerifiablePresentationVerifyResponse",
|
|
705
|
+
examples: [
|
|
706
|
+
{
|
|
707
|
+
id: "identityVerifiablePresentationVerifyResponseExample",
|
|
708
|
+
response: {
|
|
709
|
+
body: {
|
|
710
|
+
revoked: false,
|
|
711
|
+
verifiablePresentation: {
|
|
712
|
+
"@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.org"],
|
|
713
|
+
id: "presentationId",
|
|
714
|
+
type: ["VerifiablePresentation", "Person"],
|
|
715
|
+
verifiableCredential: ["eyJraWQiOi...D1Z3AQ"],
|
|
716
|
+
holder: "did:entity-storage:0xcea318e06e89f3fb4048160770effd84d0cfa5801fee13dfa6f9413a00429cec"
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
]
|
|
722
|
+
}
|
|
723
|
+
],
|
|
724
|
+
skipAuth: true
|
|
725
|
+
};
|
|
532
726
|
const identityProofCreateRoute = {
|
|
533
727
|
operationId: "identityProofCreate",
|
|
534
728
|
summary: "Create an identity proof",
|
|
@@ -578,7 +772,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
578
772
|
response: {
|
|
579
773
|
body: {
|
|
580
774
|
"@context": [
|
|
581
|
-
"https://
|
|
775
|
+
"https://w3id.org/security/data-integrity/v2",
|
|
582
776
|
"https://www.w3.org/ns/credentials/examples/v2"
|
|
583
777
|
],
|
|
584
778
|
type: "DataIntegrityProof",
|
|
@@ -625,7 +819,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
625
819
|
}
|
|
626
820
|
},
|
|
627
821
|
proof: {
|
|
628
|
-
"@context": "https://
|
|
822
|
+
"@context": "https://w3id.org/security/data-integrity/v2",
|
|
629
823
|
type: "DataIntegrityProof",
|
|
630
824
|
cryptosuite: "eddsa-jcs-2022",
|
|
631
825
|
created: "2025-01-24T11:32:13.106Z",
|
|
@@ -662,11 +856,15 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
|
|
|
662
856
|
identityVerificationMethodRemoveRoute,
|
|
663
857
|
identityServiceCreateRoute,
|
|
664
858
|
identityServiceRemoveRoute,
|
|
859
|
+
identityAlsoKnownAsCreateRoute,
|
|
860
|
+
identityAlsoKnownAsRemoveRoute,
|
|
665
861
|
identityVerifiableCredentialCreateRoute,
|
|
862
|
+
identityVerifiableCredentialVerifyDocumentRoute,
|
|
666
863
|
identityVerifiableCredentialVerifyRoute,
|
|
667
864
|
identityVerifiableCredentialRevokeRoute,
|
|
668
865
|
identityVerifiableCredentialUnrevokeRoute,
|
|
669
866
|
identityVerifiablePresentationCreateRoute,
|
|
867
|
+
identityVerifiablePresentationVerifyDocumentRoute,
|
|
670
868
|
identityVerifiablePresentationVerifyRoute,
|
|
671
869
|
identityProofCreateRoute,
|
|
672
870
|
identityProofVerifyRoute
|
|
@@ -785,6 +983,45 @@ export async function identityServiceRemove(httpRequestContext, componentName, r
|
|
|
785
983
|
statusCode: HttpStatusCode.noContent
|
|
786
984
|
};
|
|
787
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Create an identity alias.
|
|
988
|
+
* @param httpRequestContext The request context for the API.
|
|
989
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
990
|
+
* @param request The request.
|
|
991
|
+
* @returns The response object with additional http response properties.
|
|
992
|
+
*/
|
|
993
|
+
export async function identityAlsoKnownAsCreate(httpRequestContext, componentName, request) {
|
|
994
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
995
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
996
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
|
|
997
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
998
|
+
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
999
|
+
const component = ComponentFactory.get(componentName);
|
|
1000
|
+
await component.alsoKnownAsAdd(request.pathParams.identity, request.body.alias, contextIds[ContextIdKeys.Organization]);
|
|
1001
|
+
return {
|
|
1002
|
+
statusCode: HttpStatusCode.noContent
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Remove an identity alias.
|
|
1007
|
+
* @param httpRequestContext The request context for the API.
|
|
1008
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
1009
|
+
* @param request The request.
|
|
1010
|
+
* @returns The response object with additional http response properties.
|
|
1011
|
+
*/
|
|
1012
|
+
export async function identityAlsoKnownAsRemove(httpRequestContext, componentName, request) {
|
|
1013
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1014
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
1015
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.identity", request.pathParams.identity);
|
|
1016
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.alias", request.pathParams.alias);
|
|
1017
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
1018
|
+
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
1019
|
+
const component = ComponentFactory.get(componentName);
|
|
1020
|
+
await component.alsoKnownAsRemove(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.alias), contextIds[ContextIdKeys.Organization]);
|
|
1021
|
+
return {
|
|
1022
|
+
statusCode: HttpStatusCode.noContent
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
788
1025
|
/**
|
|
789
1026
|
* Create a verifiable credential.
|
|
790
1027
|
* @param httpRequestContext The request context for the API.
|
|
@@ -802,7 +1039,7 @@ export async function identityVerifiableCredentialCreate(httpRequestContext, com
|
|
|
802
1039
|
const component = ComponentFactory.get(componentName);
|
|
803
1040
|
const result = await component.verifiableCredentialCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.credentialId, request.body.subject, {
|
|
804
1041
|
revocationIndex: request.body.revocationIndex,
|
|
805
|
-
expirationDate: Coerce.
|
|
1042
|
+
expirationDate: Coerce.dateTime(request.body.expirationDate)
|
|
806
1043
|
}, contextIds[ContextIdKeys.Organization]);
|
|
807
1044
|
return {
|
|
808
1045
|
body: result
|
|
@@ -818,9 +1055,25 @@ export async function identityVerifiableCredentialCreate(httpRequestContext, com
|
|
|
818
1055
|
export async function identityVerifiableCredentialVerify(httpRequestContext, componentName, request) {
|
|
819
1056
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
820
1057
|
Guards.object(ROUTES_SOURCE, "request.query", request.query);
|
|
821
|
-
Guards.stringValue(ROUTES_SOURCE, "request.query.jwt", request.query.jwt);
|
|
822
1058
|
const component = ComponentFactory.get(componentName);
|
|
823
|
-
const result = await component.verifiableCredentialVerify(request.query
|
|
1059
|
+
const result = await component.verifiableCredentialVerify(request.query?.jwt);
|
|
1060
|
+
return {
|
|
1061
|
+
body: result
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Verify a verifiable credential document.
|
|
1066
|
+
* @param httpRequestContext The request context for the API.
|
|
1067
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
1068
|
+
* @param request The request.
|
|
1069
|
+
* @returns The response object with additional http response properties.
|
|
1070
|
+
*/
|
|
1071
|
+
export async function identityVerifiableCredentialVerifyDocument(httpRequestContext, componentName, request) {
|
|
1072
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1073
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
1074
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
1075
|
+
const component = ComponentFactory.get(componentName);
|
|
1076
|
+
const result = await component.verifiableCredentialVerify(request.body);
|
|
824
1077
|
return {
|
|
825
1078
|
body: result
|
|
826
1079
|
};
|
|
@@ -882,7 +1135,7 @@ export async function identityVerifiablePresentationCreate(httpRequestContext, c
|
|
|
882
1135
|
const contextIds = await ContextIdStore.getContextIds();
|
|
883
1136
|
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
884
1137
|
const component = ComponentFactory.get(componentName);
|
|
885
|
-
const result = await component.verifiablePresentationCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.presentationId, request.body.contexts, request.body.types, request.body.verifiableCredentials, request.body.
|
|
1138
|
+
const result = await component.verifiablePresentationCreate(DocumentHelper.joinId(request.pathParams.identity, request.pathParams.verificationMethodId), request.body.presentationId, request.body.contexts, request.body.types, request.body.verifiableCredentials, { expirationDate: Coerce.dateTime(request.body.expirationDate) }, contextIds[ContextIdKeys.Organization]);
|
|
886
1139
|
return {
|
|
887
1140
|
body: result
|
|
888
1141
|
};
|
|
@@ -904,6 +1157,22 @@ export async function identityVerifiablePresentationVerify(httpRequestContext, c
|
|
|
904
1157
|
body: result
|
|
905
1158
|
};
|
|
906
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Verify a verifiable presentation document.
|
|
1162
|
+
* @param httpRequestContext The request context for the API.
|
|
1163
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
1164
|
+
* @param request The request.
|
|
1165
|
+
* @returns The response object with additional http response properties.
|
|
1166
|
+
*/
|
|
1167
|
+
export async function identityVerifiablePresentationVerifyDocument(httpRequestContext, componentName, request) {
|
|
1168
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1169
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
1170
|
+
const component = ComponentFactory.get(componentName);
|
|
1171
|
+
const result = await component.verifiablePresentationVerify(request.body);
|
|
1172
|
+
return {
|
|
1173
|
+
body: result
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
907
1176
|
/**
|
|
908
1177
|
* Create an identity proof.
|
|
909
1178
|
* @param httpRequestContext The request context for the API.
|