From d8278c95a568848d83f83c1fa4b402a6db01fb5e Mon Sep 17 00:00:00 2001 From: Michael Avoyan Date: Tue, 4 Jun 2024 12:41:30 +0300 Subject: [PATCH] fixes --- packages/sample-server/package.json | 2 +- packages/sdk/package.json | 2 +- .../src/api/entities/VCLCredentialManifest.ts | 11 +++++-- .../entities/VCLFinalizeOffersDescriptor.ts | 12 +++---- .../sdk/src/api/entities/error/VCLError.ts | 9 ++++-- packages/sdk/src/impl/VCLImpl.ts | 32 +++++++++---------- .../FinalizeOffersRepositoryImpl.ts | 3 +- .../usecases/CountriesModelUseCaseImpl.ts | 2 +- .../CredentialTypesUIFormSchemaUseCaseImpl.ts | 2 +- .../usecases/CredentialTypesUseCaseImpl.ts | 2 +- .../usecases/ExchangeProgressUseCaseImpl.ts | 2 +- .../usecases/FinalizeOffersUseCaseImpl.ts | 2 +- .../usecases/GenerateOffersUseCaseImpl.ts | 2 +- .../data/usecases/JwtServiceUseCaseImpl.ts | 2 +- .../data/usecases/KeyServiceUseCaseImpl.ts | 2 +- .../data/usecases/OrganizationsUseCaseImpl.ts | 2 +- .../PresentationRequestUseCaseImpl.ts | 2 +- .../data/usecases/SubmissionUseCaseImpl.ts | 2 +- .../usecases/VerifiedProfileUseCaseImpl.ts | 2 +- .../VCLFinalizeOffersDescriptor.test.ts | 25 ++++++++++++--- 20 files changed, 74 insertions(+), 46 deletions(-) diff --git a/packages/sample-server/package.json b/packages/sample-server/package.json index 7a7423a..e73ca27 100644 --- a/packages/sample-server/package.json +++ b/packages/sample-server/package.json @@ -19,7 +19,7 @@ "@fastify/autoload": "~5.7.1", "env-var": "~7.3.0", "fastify": "~4.15.0", - "@velocitycareerlabs/vnf-nodejs-wallet-sdk": "^0.9.7" + "@velocitycareerlabs/vnf-nodejs-wallet-sdk": "^0.9.8" }, "devDependencies": { "@jest/globals": "~29.5.0", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 250da9e..4714e81 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@velocitycareerlabs/vnf-nodejs-wallet-sdk", - "version": "0.9.7", + "version": "0.9.8", "description": "VNF Wallet SDK Nodejs", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/sdk/src/api/entities/VCLCredentialManifest.ts b/packages/sdk/src/api/entities/VCLCredentialManifest.ts index 7b8d58e..b50d228 100644 --- a/packages/sdk/src/api/entities/VCLCredentialManifest.ts +++ b/packages/sdk/src/api/entities/VCLCredentialManifest.ts @@ -1,4 +1,4 @@ -import { Nullish } from "../VCLTypes"; +import { Dictionary, Nullish } from "../VCLTypes"; import VCLJwt from "./VCLJwt"; import VCLVerifiedProfile from "./VCLVerifiedProfile"; import VCLDeepLink from "./VCLDeepLink"; @@ -82,9 +82,16 @@ export default class VCLCredentialManifest { ); } + /* + * translate from kotlin to typescript private fun retrieveAud() = + ((jwt.payload?.toJSONObject() + ?.getOrDefault(CodingKeys.KeyMetadata, HashMap()) as? Map<*, *> ) + ?.getOrDefault(CodingKeys.KeyFinalizeOffersUri, "") as? String ?: "") + .substringBefore("/issue/") + * */ private retrieveAud(): string { const keyMetadata = this.jwt.payload[VCLCredentialManifest.KeyMetadata] ?? {}; - const finalizeOffersUri = (keyMetadata as Record)[VCLCredentialManifest.KeyFinalizeOffersUri] ?? ""; + const finalizeOffersUri = (keyMetadata as Dictionary)[VCLCredentialManifest.KeyFinalizeOffersUri] ?? ""; return finalizeOffersUri.split("/issue/")[0]; } diff --git a/packages/sdk/src/api/entities/VCLFinalizeOffersDescriptor.ts b/packages/sdk/src/api/entities/VCLFinalizeOffersDescriptor.ts index 72b74ad..1b0561f 100644 --- a/packages/sdk/src/api/entities/VCLFinalizeOffersDescriptor.ts +++ b/packages/sdk/src/api/entities/VCLFinalizeOffersDescriptor.ts @@ -16,12 +16,6 @@ export default class VCLFinalizeOffersDescriptor { get remoteCryptoServicesToken() { return this.credentialManifest.remoteCryptoServicesToken } - get finalizeOffersUri() { - return this.credentialManifest.finalizeOffersUri; - } - get did() { - return this.credentialManifest.did; - } get issuerId() { return this.credentialManifest.issuerId } @@ -31,6 +25,12 @@ export default class VCLFinalizeOffersDescriptor { get exchangeId() { return this.credentialManifest.exchangeId } + get finalizeOffersUri() { + return this.credentialManifest.finalizeOffersUri; + } + get serviceTypes() { + return this.credentialManifest.verifiedProfile.serviceTypes + } payload: Dictionary = { [VCLFinalizeOffersDescriptor.KeyExchangeId]: this.exchangeId, diff --git a/packages/sdk/src/api/entities/error/VCLError.ts b/packages/sdk/src/api/entities/error/VCLError.ts index 62219ed..8dd20ff 100644 --- a/packages/sdk/src/api/entities/error/VCLError.ts +++ b/packages/sdk/src/api/entities/error/VCLError.ts @@ -36,14 +36,17 @@ export default class VCLError extends Error { return result; } - static fromException( - exception: Error, + static fromError( + error: Error, statusCode: number | null = null ): VCLError { + if (error instanceof VCLError) { + return error; + } return new VCLError( null, VCLErrorCode.SdkError.toString(), - exception.message, + error.message, statusCode ); } diff --git a/packages/sdk/src/impl/VCLImpl.ts b/packages/sdk/src/impl/VCLImpl.ts index be8e1d0..28d5ab0 100644 --- a/packages/sdk/src/impl/VCLImpl.ts +++ b/packages/sdk/src/impl/VCLImpl.ts @@ -237,7 +237,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("getPresentationRequest", error); - throw error; + throw VCLError.fromError(error); } }; @@ -250,7 +250,7 @@ export class VCLImpl implements VCL { ); } catch(error: any) { logError("submit presentation", error); - throw error; + throw VCLError.fromError(error); } }; @@ -261,7 +261,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("getExchangeProgress", error); - throw error; + throw VCLError.fromError(error); } }; @@ -274,7 +274,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("getExchangeProgress", error); - throw error; + throw VCLError.fromError(error); } }; @@ -291,7 +291,7 @@ export class VCLImpl implements VCL { null ); logError('', error); - throw error; + throw VCLError.fromError(error); } let verifiedProfile: VCLVerifiedProfile; try { @@ -304,7 +304,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError(`failed to find verified profile by did ${did}`, error); - throw error; + throw VCLError.fromError(error); } try { return await this.credentialManifestUseCase.getCredentialManifest( @@ -313,7 +313,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("getCredentialManifest", error); - throw error; + throw VCLError.fromError(error); } }; @@ -332,7 +332,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("submit identification", error); - throw error; + throw VCLError.fromError(error); } VCLLog.i(VCLImpl.TAG, "Identification submitted success."); @@ -364,7 +364,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("finalizeOffers", error); - throw error; + throw VCLError.fromError(error); } }; @@ -380,14 +380,14 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("getCredentialTypesUIFormSchema", error); - throw error; + throw VCLError.fromError(error); } } else { const error = new VCLError( "No countries for getCredentialTypesUIFormSchema" ); logError("getCredentialTypesUIFormSchema", error); - throw error; + throw VCLError.fromError(error); } } @@ -400,7 +400,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("getVerifiedProfile", error); - throw error; + throw VCLError.fromError(error); } }; @@ -417,7 +417,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("verifyJwt", error); - throw error; + throw VCLError.fromError(error); } }; @@ -436,7 +436,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("generateSignedJwt", error); - throw error; + throw VCLError.fromError(error); } }; @@ -447,7 +447,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("generateDidJwk", error); - throw error; + throw VCLError.fromError(error); } }; @@ -466,7 +466,7 @@ export class VCLImpl implements VCL { ); } catch (error: any) { logError("generateOffers", error); - throw error; + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/repositories/FinalizeOffersRepositoryImpl.ts b/packages/sdk/src/impl/data/repositories/FinalizeOffersRepositoryImpl.ts index db4d1bf..2c7e9ff 100644 --- a/packages/sdk/src/impl/data/repositories/FinalizeOffersRepositoryImpl.ts +++ b/packages/sdk/src/impl/data/repositories/FinalizeOffersRepositoryImpl.ts @@ -33,8 +33,9 @@ export class FinalizeOffersRepositoryImpl implements FinalizeOffersRepository { const encodedJwtCredArr: Nullish = (finalizedOffersResponse.payload as Nullish); if (encodedJwtCredArr) { return encodedJwtCredArr.map((encodedJwtCred) => VCLJwt.fromEncodedJwt(encodedJwtCred)); + } else if (finalizedOffersResponse.payload instanceof Error) { + throw VCLError.fromError(finalizedOffersResponse.payload); } - throw new VCLError(`Failed to parse: ${finalizedOffersResponse.payload}`); } } diff --git a/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts index cb44c4c..2803ccb 100644 --- a/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts @@ -10,7 +10,7 @@ export default class CountriesUseCaseImpl implements CountriesUseCase { try { return await this.countriesRepository.getCountries(); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts index db9f950..b959b86 100644 --- a/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts @@ -22,7 +22,7 @@ export default class CredentialTypesUIFormSchemaUseCaseImpl countries ); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/CredentialTypesUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/CredentialTypesUseCaseImpl.ts index b3537a1..923f770 100644 --- a/packages/sdk/src/impl/data/usecases/CredentialTypesUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/CredentialTypesUseCaseImpl.ts @@ -11,7 +11,7 @@ export default class CredentialTypesUseCaseImpl try { return await this.credentialTypes.getCredentialTypes(); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts index 3cba697..57923d0 100644 --- a/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts @@ -14,7 +14,7 @@ export default class ExchangeProgressUseCaseImpl implements ExchangeProgressUseC try { return await this.exchangeProgressRepository.getExchangeProgress(exchangeDescriptor); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts index aeba45a..0f7d465 100644 --- a/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts @@ -52,7 +52,7 @@ export default class FinalizeOffersUseCaseImpl implements FinalizeOffersUseCase ) } } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } diff --git a/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts index 5687dda..9b0916f 100644 --- a/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts @@ -17,7 +17,7 @@ export default class GenerateOffersUseCaseImpl try { return await this.generateOffersRepository.generateOffers(generateOffersDescriptor, sessionToken); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts index 53d9ed2..fc09917 100644 --- a/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts @@ -19,7 +19,7 @@ export default class JwtServiceUseCaseImpl implements JwtServiceUseCase { try { return await this.jwtServiceRepository.verifyJwt(jwt, publicJwk, remoteCryptoServicesToken); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } diff --git a/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts index 28e1ccd..aa0597a 100644 --- a/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts @@ -12,7 +12,7 @@ export default class KeyServiceUseCaseImpl implements KeyServiceUseCase { try { return await this.keyServiceRepository.generateDidJwk(didJwkDescriptor); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts index 949f565..c1079e6 100644 --- a/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts @@ -13,7 +13,7 @@ export default class OrganizationsUseCaseImpl implements OrganizationsUseCase { try { return await this.organizationsRepository.searchForOrganizations(organizationsSearchDescriptor); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/PresentationRequestUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/PresentationRequestUseCaseImpl.ts index e9ff3f4..4b560ed 100644 --- a/packages/sdk/src/impl/data/usecases/PresentationRequestUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/PresentationRequestUseCaseImpl.ts @@ -39,7 +39,7 @@ export default class PresentationRequestUseCaseImpl ), ); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } diff --git a/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts index d2bdf00..7b294fa 100644 --- a/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts @@ -29,7 +29,7 @@ export default class SubmissionUseCaseImpl implements SubmissionUseCase { ); return await this.submissionRepository.submit(submission, jwt); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts index f50cf40..7fc2aa2 100644 --- a/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts @@ -14,7 +14,7 @@ export default class VerifiedProfileUseCaseImpl try { return await this.verifiedProfileRepository.getVerifiedProfile(verifiedProfileDescriptor); } catch (error: any) { - throw new VCLError(error); + throw VCLError.fromError(error); } } } diff --git a/packages/sdk/test/entities/VCLFinalizeOffersDescriptor.test.ts b/packages/sdk/test/entities/VCLFinalizeOffersDescriptor.test.ts index 2788dd9..edb5f5c 100644 --- a/packages/sdk/test/entities/VCLFinalizeOffersDescriptor.test.ts +++ b/packages/sdk/test/entities/VCLFinalizeOffersDescriptor.test.ts @@ -14,11 +14,20 @@ describe("VCLCredentialManifest Tests", () => { let subject: VCLFinalizeOffersDescriptor; + // const jtiMock = "some jti" + // const issMock = "some iss" + // const audMock = "some sud" const nonceMock = "some nonce" const approvedOfferIds = ["approvedOfferId1", "approvedOfferId2"] const rejectedOfferIds = ["rejectedOfferId1", "rejectedOfferId2"] + const jwtProof = VCLJwt.fromEncodedJwt( + `eyJraWQiOiJkaWQ6andrOmV5SnJkSGtpT2lKRlF5SXNJblZ6WlNJNkluTnBaeUlzSW1OeWRpSTZJbEF0TWpVMklpd2lhMmxrSWpvaVpHSmlNVGd5TXpndE56a3hZaTAwTmpkaUxXRTBZak10T0RjeE0yVTFNVGN3TkRObElpd2llQ0k2SWs1NVkxcEhhMmt5U1ZGRldta3pVRmN0UXkwNVIzRjNRakJsZDNVNWR6QkdXV2xrTTFaVmJGOTJPRFFpTENKNUlqb2liVXhtY1dNMmIyWXhVVFYwVHpZeGQwbDFkVFpQVVZaUmMySjRUR1poT0VkaGMwaFZUR3B3VTJWVmJ5SjkjMCIsInR5cCI6IkpXVCIsImFsZyI6IkVTMjU2IiwiandrIjp7Imt0eSI6IkVDIiwidXNlIjoic2lnIiwiY3J2IjoiUC0yNTYiLCJraWQiOiJkYmIxODIzOC03OTFiLTQ2N2ItYTRiMy04NzEzZTUxNzA0M2UiLCJ4IjoiTnljWkdraTJJUUVaaTNQVy1DLTlHcXdCMGV3dTl3MEZZaWQzVlVsX3Y4NCIsInkiOiJtTGZxYzZvZjFRNXRPNjF3SXV1Nk9RVlFzYnhMZmE4R2FzSFVManBTZVVvIn19.eyJhdWQiOiJzb21lIHN1ZCIsInN1YiI6IlB2aFNOdWF6MTYiLCJuYmYiOjE3MTc0ODk2NzksImlzcyI6InNvbWUgaXNzIiwiZXhwIjoxNzE4MDk0NDc5LCJpYXQiOjE3MTc0ODk2NzksIm5vbmNlIjoic29tZSBub25jZSIsImp0aSI6InNvbWUganRpIn0.VRacheqy4sWIo3CKPsOJTYJnfyx3KaFYIQykXIS4xpMs58iCCp-pRnsLmoC56eJPCqRkv_A-MCdpc3pgiM3UVA` + ) + const expectedRequestBodyStr = + `{"exchangeId":"645e315309237c760ac022b1","approvedOfferIds":["approvedOfferId1","approvedOfferId2"],"rejectedOfferIds":["rejectedOfferId1","rejectedOfferId2"],"proof":{"proof_type":"jwt","jwt":"eyJraWQiOiJkaWQ6andrOmV5SnJkSGtpT2lKRlF5SXNJblZ6WlNJNkluTnBaeUlzSW1OeWRpSTZJbEF0TWpVMklpd2lhMmxrSWpvaVpHSmlNVGd5TXpndE56a3hZaTAwTmpkaUxXRTBZak10T0RjeE0yVTFNVGN3TkRObElpd2llQ0k2SWs1NVkxcEhhMmt5U1ZGRldta3pVRmN0UXkwNVIzRjNRakJsZDNVNWR6QkdXV2xrTTFaVmJGOTJPRFFpTENKNUlqb2liVXhtY1dNMmIyWXhVVFYwVHpZeGQwbDFkVFpQVVZaUmMySjRUR1poT0VkaGMwaFZUR3B3VTJWVmJ5SjkjMCIsInR5cCI6IkpXVCIsImFsZyI6IkVTMjU2IiwiandrIjp7Imt0eSI6IkVDIiwidXNlIjoic2lnIiwiY3J2IjoiUC0yNTYiLCJraWQiOiJkYmIxODIzOC03OTFiLTQ2N2ItYTRiMy04NzEzZTUxNzA0M2UiLCJ4IjoiTnljWkdraTJJUUVaaTNQVy1DLTlHcXdCMGV3dTl3MEZZaWQzVlVsX3Y4NCIsInkiOiJtTGZxYzZvZjFRNXRPNjF3SXV1Nk9RVlFzYnhMZmE4R2FzSFVManBTZVVvIn19.eyJhdWQiOiJzb21lIHN1ZCIsInN1YiI6IlB2aFNOdWF6MTYiLCJuYmYiOjE3MTc0ODk2NzksImlzcyI6InNvbWUgaXNzIiwiZXhwIjoxNzE4MDk0NDc5LCJpYXQiOjE3MTc0ODk2NzksIm5vbmNlIjoic29tZSBub25jZSIsImp0aSI6InNvbWUganRpIn0.VRacheqy4sWIo3CKPsOJTYJnfyx3KaFYIQykXIS4xpMs58iCCp-pRnsLmoC56eJPCqRkv_A-MCdpc3pgiM3UVA"}}`; + beforeAll(async () => { const credentialManifest = new VCLCredentialManifest( @@ -36,12 +45,20 @@ describe("VCLCredentialManifest Tests", () => { ) }); - test("test generateRequest body", () => { - const jwtProof = VCLJwt.fromEncodedJwt( - 'eyJraWQiOiJkaWQ6andrOmV5SnJkSGtpT2lKRlF5SXNJblZ6WlNJNkluTnBaeUlzSW1OeWRpSTZJbEF0TWpVMklpd2lhMmxrSWpvaU56VXhOekZsWm1FdFkyTTRNaTAwWlRVeUxXSTFaVFl0WkRRMlpXRmhaamMzTkRneElpd2llQ0k2SW0xRldEbHliR2hJWVVaVmNreEtla0p4VWt4bmIySndNVmR4UzJSTmFEVndiVVp5UzJjME9WbEZkVUVpTENKNUlqb2lWakZPTVdKU1FrRXplalp2VGxrelZXdFFORUZsWVVGQk5rNUtiREl5TVRSVWFVSnFTRTlJYWpGdVVTSjkjMCIsInR5cCI6IkpXVCIsImFsZyI6IkVTMjU2IiwiandrIjp7Imt0eSI6IkVDIiwidXNlIjoic2lnIiwiY3J2IjoiUC0yNTYiLCJraWQiOiI3NTE3MWVmYS1jYzgyLTRlNTItYjVlNi1kNDZlYWFmNzc0ODEiLCJ4IjoibUVYOXJsaEhhRlVyTEp6QnFSTGdvYnAxV3FLZE1oNXBtRnJLZzQ5WUV1QSIsInkiOiJWMU4xYlJCQTN6Nm9OWTNVa1A0QWVhQUE2TkpsMjIxNFRpQmpIT0hqMW5RIn19.eyJrZXkxIjoidmFsdWUxIiwiYXVkIjoic29tZSBzdWQiLCJzdWIiOiJ3VzdCZGhXNGNQIiwibmJmIjoxNzE2OTAzNzIxLCJpc3MiOiJzb21lIGlzcyIsImV4cCI6MTcxNzUwODUyMSwiaWF0IjoxNzE2OTAzNzIxLCJub25jZSI6InNvbWUgbm9uY2UiLCJqdGkiOiJzb21lIGp0aSJ9' - ) + test("test props", async () => { + expect(subject.finalizeOffersUri).toBe("https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/issue/finalize-offers") + expect(subject.approvedOfferIds).toStrictEqual(approvedOfferIds) + expect(subject.rejectedOfferIds).toStrictEqual(rejectedOfferIds) + expect(subject.aud).toBe("https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA") + expect(subject.issuerId).toBe("did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA") + + }); + + test("test generateRequest body", async () => { const requestBody = subject.generateRequestBody(jwtProof) + expect(requestBody).toStrictEqual(JSON.parse(expectedRequestBodyStr)); + expect(requestBody["exchangeId"]).toBe("645e315309237c760ac022b1") expect(requestBody["approvedOfferIds"]).toStrictEqual(approvedOfferIds) expect(requestBody["rejectedOfferIds"]).toStrictEqual(rejectedOfferIds)