@twin.org/identity-rest-client 0.0.3-next.1 → 0.0.3-next.10

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.
@@ -202,7 +202,7 @@ export class IdentityRestClient extends BaseRestClient {
202
202
  await this.fetch("/:identity/verifiable-credential/revoke/:revocationIndex", "GET", {
203
203
  pathParams: {
204
204
  identity: issuerId,
205
- revocationIndex: credentialIndex
205
+ revocationIndex: credentialIndex.toString()
206
206
  }
207
207
  });
208
208
  }
@@ -218,7 +218,7 @@ export class IdentityRestClient extends BaseRestClient {
218
218
  await this.fetch("/:identity/verifiable-credential/unrevoke/:revocationIndex", "GET", {
219
219
  pathParams: {
220
220
  identity: issuerId,
221
- revocationIndex: credentialIndex
221
+ revocationIndex: credentialIndex.toString()
222
222
  }
223
223
  });
224
224
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identityRestClient.js","sourceRoot":"","sources":["../../src/identityRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EACN,cAAc,EAyBd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EAOzB,UAAU,EACV,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACrD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,uBAA+B,MAAM,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,kBAAkB,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,SAAkB;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,C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,eAAe,EACf,MAAM,EACN;YACC,IAAI,EAAE;gBACL,QAAQ;gBACR,KAAK;aACL;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC/B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\ttype IIdentityRemoveRequest,\n\ttype IIdentityComponent,\n\ttype IIdentityCreateRequest,\n\ttype IIdentityCreateResponse,\n\ttype IIdentityProofCreateRequest,\n\ttype IIdentityProofCreateResponse,\n\ttype IIdentityProofVerifyRequest,\n\ttype IIdentityProofVerifyResponse,\n\ttype IIdentityServiceCreateRequest,\n\ttype IIdentityServiceCreateResponse,\n\ttype IIdentityServiceRemoveRequest,\n\ttype IIdentityVerifiableCredentialCreateRequest,\n\ttype IIdentityVerifiableCredentialCreateResponse,\n\ttype IIdentityVerifiableCredentialRevokeRequest,\n\ttype IIdentityVerifiableCredentialUnrevokeRequest,\n\ttype IIdentityVerifiableCredentialVerifyRequest,\n\ttype IIdentityVerifiableCredentialVerifyResponse,\n\ttype IIdentityVerifiablePresentationCreateRequest,\n\ttype IIdentityVerifiablePresentationCreateResponse,\n\ttype IIdentityVerifiablePresentationVerifyRequest,\n\ttype IIdentityVerifiablePresentationVerifyResponse,\n\ttype IIdentityVerificationMethodCreateRequest,\n\ttype IIdentityVerificationMethodCreateResponse,\n\ttype IIdentityVerificationMethodRemoveRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation,\n\ttype IProof,\n\tProofTypes\n} from \"@twin.org/standards-w3c-did\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityRestClient extends BaseRestClient implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityRestClient>(), config, \"identity\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string): Promise<IDidDocument> {\n\t\tconst response = await this.fetch<IIdentityCreateRequest, IIdentityCreateResponse>(\n\t\t\t\"/\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tnamespace\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async identityRemove(identity: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tawait this.fetch<IIdentityRemoveRequest, INoContentResponse>(\"/:identity\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param identity The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerificationMethodCreateRequest,\n\t\t\tIIdentityVerificationMethodCreateResponse\n\t\t>(\"/:identity/verification-method\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @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(verificationMethodId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tawait this.fetch<IIdentityVerificationMethodRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/verification-method/:verificationMethodId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param identity The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityServiceCreateRequest,\n\t\t\tIIdentityServiceCreateResponse\n\t\t>(\"/:identity/service\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tserviceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tendpoint: serviceEndpoint\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\tawait this.fetch<IIdentityServiceRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/service/:serviceId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tserviceId: idParts.fragment ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * 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 * @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): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(subject), subject);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options?.revocationIndex),\n\t\t\t\toptions?.revocationIndex\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialCreateRequest,\n\t\t\tIIdentityVerifiableCredentialCreateResponse\n\t\t>(\"/:identity/verifiable-credential\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tcredentialId: id,\n\t\t\t\tsubject,\n\t\t\t\trevocationIndex: options?.revocationIndex,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString()\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable credential is valid.\n\t * @param credentialJwt The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiableCredentialVerify(credentialJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(credentialJwt), credentialJwt);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialVerifyRequest,\n\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t>(\"/verifiable-credential/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: credentialJwt\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index revoke.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialRevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/revoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialUnrevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/unrevoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param expiresInMinutes The time in minutes for the presentation to expire.\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\texpiresInMinutes?: number\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(expiresInMinutes)) {\n\t\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(expiresInMinutes), expiresInMinutes);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationCreateRequest,\n\t\t\tIIdentityVerifiablePresentationCreateResponse\n\t\t>(\"/:identity/verifiable-presentation\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\texpiresInMinutes\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable presentation is valid.\n\t * @param presentationJwt The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiablePresentationVerify(presentationJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(presentationJwt), presentationJwt);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationVerifyRequest,\n\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t>(\"/verifiable-presentation/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: presentationJwt\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Create a proof for a document with the specified verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<IIdentityProofCreateRequest, IIdentityProofCreateResponse>(\n\t\t\t\"/:identity/proof\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tdocument: unsecureDocument,\n\t\t\t\t\tproofType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify proof for a document with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityRestClient.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\tconst response = await this.fetch<IIdentityProofVerifyRequest, IIdentityProofVerifyResponse>(\n\t\t\t\"/proof/verify\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdocument,\n\t\t\t\t\tproof\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body.verified;\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityRestClient.js","sourceRoot":"","sources":["../../src/identityRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EACN,cAAc,EAyBd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EAOzB,UAAU,EACV,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACrD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,uBAA+B,MAAM,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,kBAAkB,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,SAAkB;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,GAAG,EACH,MAAM,EACN;YACC,IAAI,EAAE;gBACL,SAAS;aACT;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,QAA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CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\ttype IIdentityComponent,\n\ttype IIdentityCreateRequest,\n\ttype IIdentityCreateResponse,\n\ttype IIdentityProofCreateRequest,\n\ttype IIdentityProofCreateResponse,\n\ttype IIdentityProofVerifyRequest,\n\ttype IIdentityProofVerifyResponse,\n\ttype IIdentityRemoveRequest,\n\ttype IIdentityServiceCreateRequest,\n\ttype IIdentityServiceCreateResponse,\n\ttype IIdentityServiceRemoveRequest,\n\ttype IIdentityVerifiableCredentialCreateRequest,\n\ttype IIdentityVerifiableCredentialCreateResponse,\n\ttype IIdentityVerifiableCredentialRevokeRequest,\n\ttype IIdentityVerifiableCredentialUnrevokeRequest,\n\ttype IIdentityVerifiableCredentialVerifyRequest,\n\ttype IIdentityVerifiableCredentialVerifyResponse,\n\ttype IIdentityVerifiablePresentationCreateRequest,\n\ttype IIdentityVerifiablePresentationCreateResponse,\n\ttype IIdentityVerifiablePresentationVerifyRequest,\n\ttype IIdentityVerifiablePresentationVerifyResponse,\n\ttype IIdentityVerificationMethodCreateRequest,\n\ttype IIdentityVerificationMethodCreateResponse,\n\ttype IIdentityVerificationMethodRemoveRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation,\n\ttype IProof,\n\tProofTypes\n} from \"@twin.org/standards-w3c-did\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityRestClient extends BaseRestClient implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityRestClient>(), config, \"identity\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string): Promise<IDidDocument> {\n\t\tconst response = await this.fetch<IIdentityCreateRequest, IIdentityCreateResponse>(\n\t\t\t\"/\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tnamespace\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async identityRemove(identity: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tawait this.fetch<IIdentityRemoveRequest, INoContentResponse>(\"/:identity\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param identity The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerificationMethodCreateRequest,\n\t\t\tIIdentityVerificationMethodCreateResponse\n\t\t>(\"/:identity/verification-method\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @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(verificationMethodId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tawait this.fetch<IIdentityVerificationMethodRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/verification-method/:verificationMethodId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param identity The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityServiceCreateRequest,\n\t\t\tIIdentityServiceCreateResponse\n\t\t>(\"/:identity/service\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tserviceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tendpoint: serviceEndpoint\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\tawait this.fetch<IIdentityServiceRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/service/:serviceId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tserviceId: idParts.fragment ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * 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 * @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): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(subject), subject);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options?.revocationIndex),\n\t\t\t\toptions?.revocationIndex\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialCreateRequest,\n\t\t\tIIdentityVerifiableCredentialCreateResponse\n\t\t>(\"/:identity/verifiable-credential\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tcredentialId: id,\n\t\t\t\tsubject,\n\t\t\t\trevocationIndex: options?.revocationIndex,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString()\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable credential is valid.\n\t * @param credentialJwt The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiableCredentialVerify(credentialJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(credentialJwt), credentialJwt);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialVerifyRequest,\n\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t>(\"/verifiable-credential/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: credentialJwt\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index revoke.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialRevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/revoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialUnrevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/unrevoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param expiresInMinutes The time in minutes for the presentation to expire.\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\texpiresInMinutes?: number\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(expiresInMinutes)) {\n\t\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(expiresInMinutes), expiresInMinutes);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationCreateRequest,\n\t\t\tIIdentityVerifiablePresentationCreateResponse\n\t\t>(\"/:identity/verifiable-presentation\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\texpiresInMinutes\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable presentation is valid.\n\t * @param presentationJwt The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiablePresentationVerify(presentationJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(presentationJwt), presentationJwt);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationVerifyRequest,\n\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t>(\"/verifiable-presentation/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: presentationJwt\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Create a proof for a document with the specified verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<IIdentityProofCreateRequest, IIdentityProofCreateResponse>(\n\t\t\t\"/:identity/proof\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tdocument: unsecureDocument,\n\t\t\t\t\tproofType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify proof for a document with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityRestClient.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\tconst response = await this.fetch<IIdentityProofVerifyRequest, IIdentityProofVerifyResponse>(\n\t\t\t\"/proof/verify\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdocument,\n\t\t\t\t\tproof\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body.verified;\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,146 @@
1
1
  # @twin.org/identity-rest-client - Changelog
2
2
 
3
+ ## [0.0.3-next.10](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.9...identity-rest-client-v0.0.3-next.10) (2026-01-15)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **identity-rest-client:** Synchronize repo versions
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.9 to 0.0.3-next.10
16
+
17
+ ## [0.0.3-next.9](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.8...identity-rest-client-v0.0.3-next.9) (2026-01-14)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **identity-rest-client:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/identity-models bumped from 0.0.3-next.8 to 0.0.3-next.9
30
+
31
+ ## [0.0.3-next.8](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.7...identity-rest-client-v0.0.3-next.8) (2026-01-14)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **identity-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/identity-models bumped from 0.0.3-next.7 to 0.0.3-next.8
44
+
45
+ ## [0.0.3-next.7](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.6...identity-rest-client-v0.0.3-next.7) (2026-01-13)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **identity-rest-client:** Synchronize repo versions
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/identity-models bumped from 0.0.3-next.6 to 0.0.3-next.7
58
+
59
+ ## [0.0.3-next.6](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.5...identity-rest-client-v0.0.3-next.6) (2025-11-26)
60
+
61
+
62
+ ### Miscellaneous Chores
63
+
64
+ * **identity-rest-client:** Synchronize repo versions
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/identity-models bumped from 0.0.3-next.5 to 0.0.3-next.6
72
+
73
+ ## [0.0.3-next.5](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.4...identity-rest-client-v0.0.3-next.5) (2025-11-20)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **identity-rest-client:** Synchronize repo versions
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/identity-models bumped from 0.0.3-next.4 to 0.0.3-next.5
86
+
87
+ ## [0.0.3-next.4](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.3...identity-rest-client-v0.0.3-next.4) (2025-11-17)
88
+
89
+
90
+ ### Features
91
+
92
+ * add context id features ([#62](https://github.com/twinfoundation/identity/issues/62)) ([e02ecca](https://github.com/twinfoundation/identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
93
+ * add expiration date option to vc creation ([73e05e1](https://github.com/twinfoundation/identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
94
+ * add identity remove ([eebc13f](https://github.com/twinfoundation/identity/commit/eebc13f4c2cd994d2d9cce4da2128fb346c80ba7))
95
+ * add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
96
+ * eslint migration to flat config ([fd6246d](https://github.com/twinfoundation/identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
97
+ * identity key separator use slash ([1319d0d](https://github.com/twinfoundation/identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
98
+ * update framework core ([c824497](https://github.com/twinfoundation/identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
99
+ * use shared store mechanism ([#27](https://github.com/twinfoundation/identity/issues/27)) ([ce41f3f](https://github.com/twinfoundation/identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
100
+
101
+
102
+ ### Bug Fixes
103
+
104
+ * Import path and bump version ([#21](https://github.com/twinfoundation/identity/issues/21)) ([ccea845](https://github.com/twinfoundation/identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
105
+ * Install sdk-wasm ([#20](https://github.com/twinfoundation/identity/issues/20)) ([75ec14e](https://github.com/twinfoundation/identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
106
+ * query params force coercion ([d9347d2](https://github.com/twinfoundation/identity/commit/d9347d29d4a9cc58759f30f5d8526de864ea7522))
107
+ * stricter pathParam types ([a174cdf](https://github.com/twinfoundation/identity/commit/a174cdf0ca4272bee35fcf20ab7e8e4e17b8b6f4))
108
+
109
+
110
+ ### Dependencies
111
+
112
+ * The following workspace dependencies were updated
113
+ * dependencies
114
+ * @twin.org/identity-models bumped from 0.0.3-next.3 to 0.0.3-next.4
115
+
116
+ ## [0.0.3-next.3](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.2...identity-rest-client-v0.0.3-next.3) (2025-11-17)
117
+
118
+
119
+ ### Miscellaneous Chores
120
+
121
+ * **identity-rest-client:** Synchronize repo versions
122
+
123
+
124
+ ### Dependencies
125
+
126
+ * The following workspace dependencies were updated
127
+ * dependencies
128
+ * @twin.org/identity-models bumped from 0.0.3-next.2 to 0.0.3-next.3
129
+
130
+ ## [0.0.3-next.2](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.1...identity-rest-client-v0.0.3-next.2) (2025-11-14)
131
+
132
+
133
+ ### Miscellaneous Chores
134
+
135
+ * **identity-rest-client:** Synchronize repo versions
136
+
137
+
138
+ ### Dependencies
139
+
140
+ * The following workspace dependencies were updated
141
+ * dependencies
142
+ * @twin.org/identity-models bumped from 0.0.3-next.1 to 0.0.3-next.2
143
+
3
144
  ## [0.0.3-next.1](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.0...identity-rest-client-v0.0.3-next.1) (2025-11-11)
4
145
 
5
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-rest-client",
3
- "version": "0.0.3-next.1",
3
+ "version": "0.0.3-next.10",
4
4
  "description": "Identity contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "@twin.org/data-core": "next",
21
21
  "@twin.org/data-json-ld": "next",
22
22
  "@twin.org/entity": "next",
23
- "@twin.org/identity-models": "0.0.3-next.1",
23
+ "@twin.org/identity-models": "0.0.3-next.10",
24
24
  "@twin.org/nameof": "next",
25
25
  "@twin.org/standards-w3c-did": "next"
26
26
  },