diff --git a/packages/sdk/src/impl/data/repositories/CredentialTypeSchemaRepositoryImpl.ts b/packages/sdk/src/impl/data/repositories/CredentialTypeSchemaRepositoryImpl.ts index ce4def1..99e3ed8 100644 --- a/packages/sdk/src/impl/data/repositories/CredentialTypeSchemaRepositoryImpl.ts +++ b/packages/sdk/src/impl/data/repositories/CredentialTypeSchemaRepositoryImpl.ts @@ -3,7 +3,6 @@ import NetworkService from "../../domain/infrastructure/network/NetworkService"; import CredentialTypeSchemaRepository from "../../domain/repositories/CredentialTypeSchemaRepository"; import { HttpMethod } from "../infrastructure/network/Request"; import Urls, { HeaderKeys, HeaderValues } from "./Urls"; -import VCLCredentialTypes from "../../../api/entities/VCLCredentialTypes"; export default class CredentialTypeSchemaRepositoryImpl implements CredentialTypeSchemaRepository diff --git a/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts index 1c971e1..cb44c4c 100644 --- a/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/CountriesModelUseCaseImpl.ts @@ -1,6 +1,7 @@ import VCLCountries from "../../../api/entities/VCLCountries"; import CountriesRepository from "../../domain/repositories/CountriesRepository"; import CountriesUseCase from "../../domain/usecases/CountriesModelUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class CountriesUseCaseImpl implements CountriesUseCase { constructor(private readonly countriesRepository: CountriesRepository) {} @@ -9,7 +10,7 @@ export default class CountriesUseCaseImpl implements CountriesUseCase { try { return await this.countriesRepository.getCountries(); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts index 6a524a9..db9f950 100644 --- a/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/CredentialTypesUIFormSchemaUseCaseImpl.ts @@ -3,6 +3,7 @@ import VCLCredentialTypesUIFormSchema from "../../../api/entities/VCLCredentialT import VCLCredentialTypesUIFormSchemaDescriptor from "../../../api/entities/VCLCredentialTypesUIFormSchemaDescriptor"; import CredentialTypesUIFormSchemaRepository from "../../domain/repositories/CredentialTypesUIFormSchemaRepository"; import CredentialTypesUIFormSchemaUseCase from "../../domain/usecases/CredentialTypesUIFormSchemaUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class CredentialTypesUIFormSchemaUseCaseImpl implements CredentialTypesUIFormSchemaUseCase @@ -21,7 +22,7 @@ export default class CredentialTypesUIFormSchemaUseCaseImpl countries ); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts index 9141191..3cba697 100644 --- a/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/ExchangeProgressUseCaseImpl.ts @@ -2,6 +2,7 @@ import VCLExchange from "../../../api/entities/VCLExchange"; import VCLExchangeDescriptor from "../../../api/entities/VCLExchangeDescriptor"; import ExchangeProgressRepository from "../../domain/repositories/ExchangeProgressRepository"; import ExchangeProgressUseCase from "../../domain/usecases/ExchangeProgressUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class ExchangeProgressUseCaseImpl implements ExchangeProgressUseCase { constructor(private exchangeProgressRepository: ExchangeProgressRepository) { @@ -13,7 +14,7 @@ export default class ExchangeProgressUseCaseImpl implements ExchangeProgressUseC try { return await this.exchangeProgressRepository.getExchangeProgress(exchangeDescriptor); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts index d8d2e32..c5f7345 100644 --- a/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/FinalizeOffersUseCaseImpl.ts @@ -5,6 +5,7 @@ import VCLToken from "../../../api/entities/VCLToken"; import FinalizeOffersRepository from "../../domain/repositories/FinalizeOffersRepository"; import JwtServiceRepository from "../../domain/repositories/JwtServiceRepository"; import FinalizeOffersUseCase from "../../domain/usecases/FinalizeOffersUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class FinalizeOffersUseCaseImpl implements FinalizeOffersUseCase { @@ -38,7 +39,7 @@ export default class FinalizeOffersUseCaseImpl } return new VCLJwtVerifiableCredentials(passedCredentials, failedCredentials); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } diff --git a/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts index e8bba72..5687dda 100644 --- a/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/GenerateOffersUseCaseImpl.ts @@ -3,6 +3,7 @@ import VCLOffers from "../../../api/entities/VCLOffers"; import VCLToken from "../../../api/entities/VCLToken"; import GenerateOffersRepository from "../../domain/repositories/GenerateOffersRepository"; import GenerateOffersUseCase from "../../domain/usecases/GenerateOffersUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class GenerateOffersUseCaseImpl implements GenerateOffersUseCase @@ -16,7 +17,7 @@ export default class GenerateOffersUseCaseImpl try { return await this.generateOffersRepository.generateOffers(generateOffersDescriptor, sessionToken); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts index eb72609..53d9ed2 100644 --- a/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/JwtServiceUseCaseImpl.ts @@ -6,6 +6,7 @@ import JwtServiceRepository from "../../domain/repositories/JwtServiceRepository import JwtServiceUseCase from "../../domain/usecases/JwtServiceUseCase"; import { Nullish } from "../../../api/VCLTypes"; import VCLToken from "../../../api/entities/VCLToken"; +import VCLError from "../../../api/entities/error/VCLError"; export default class JwtServiceUseCaseImpl implements JwtServiceUseCase { constructor(private readonly jwtServiceRepository: JwtServiceRepository) {} @@ -18,7 +19,7 @@ export default class JwtServiceUseCaseImpl implements JwtServiceUseCase { try { return await this.jwtServiceRepository.verifyJwt(jwt, publicJwk, remoteCryptoServicesToken); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } diff --git a/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts index 497d337..28e1ccd 100644 --- a/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/KeyServiceUseCaseImpl.ts @@ -2,6 +2,7 @@ import VCLDidJwk from "../../../api/entities/VCLDidJwk"; import VCLDidJwkDescriptor from "../../../api/entities/VCLDidJwkDescriptor"; import KeyServiceRepository from "../../domain/repositories/KeyServiceRepository"; import KeyServiceUseCase from "../../domain/usecases/KeyServiceUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class KeyServiceUseCaseImpl implements KeyServiceUseCase { constructor(private readonly keyServiceRepository: KeyServiceRepository) {} @@ -11,7 +12,7 @@ export default class KeyServiceUseCaseImpl implements KeyServiceUseCase { try { return await this.keyServiceRepository.generateDidJwk(didJwkDescriptor); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts index bd6b007..949f565 100644 --- a/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/OrganizationsUseCaseImpl.ts @@ -2,6 +2,7 @@ import VCLOrganizations from "../../../api/entities/VCLOrganizations"; import VCLOrganizationsSearchDescriptor from "../../../api/entities/VCLOrganizationsSearchDescriptor"; import OrganizationsRepository from "../../domain/repositories/OrganizationsRepository"; import OrganizationsUseCase from "../../domain/usecases/OrganizationsUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class OrganizationsUseCaseImpl implements OrganizationsUseCase { constructor(private organizationsRepository: OrganizationsRepository) {} @@ -12,7 +13,7 @@ export default class OrganizationsUseCaseImpl implements OrganizationsUseCase { try { return await this.organizationsRepository.searchForOrganizations(organizationsSearchDescriptor); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/PresentationRequestUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/PresentationRequestUseCaseImpl.ts index 13a7f34..e9ff3f4 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 Error(error); + throw new VCLError(error); } } diff --git a/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts index 9d3660d..d2bdf00 100644 --- a/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts @@ -4,6 +4,7 @@ import VCLSubmissionResult from "../../../api/entities/VCLSubmissionResult"; import JwtServiceRepository from "../../domain/repositories/JwtServiceRepository"; import SubmissionRepository from "../../domain/repositories/SubmissionRepository"; import SubmissionUseCase from "../../domain/usecases/SubmissionUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class SubmissionUseCaseImpl implements SubmissionUseCase { constructor( @@ -28,7 +29,7 @@ export default class SubmissionUseCaseImpl implements SubmissionUseCase { ); return await this.submissionRepository.submit(submission, jwt); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts b/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts index 8650de8..f50cf40 100644 --- a/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts +++ b/packages/sdk/src/impl/data/usecases/VerifiedProfileUseCaseImpl.ts @@ -1,6 +1,7 @@ import VCLVerifiedProfileDescriptor from "../../../api/entities/VCLVerifiedProfileDescriptor"; import VerifiedProfileRepository from "../../domain/repositories/VerifiedProfileRepository"; import VerifiedProfileUseCase from "../../domain/usecases/VerifiedProfileUseCase"; +import VCLError from "../../../api/entities/error/VCLError"; export default class VerifiedProfileUseCaseImpl implements VerifiedProfileUseCase { @@ -13,7 +14,7 @@ export default class VerifiedProfileUseCaseImpl try { return await this.verifiedProfileRepository.getVerifiedProfile(verifiedProfileDescriptor); } catch (error: any) { - throw new Error(error); + throw new VCLError(error); } } } diff --git a/packages/sdk/test/usecases/CredentialManifestUseCase.test.ts b/packages/sdk/test/usecases/CredentialManifestUseCase.test.ts index 4f97322..7f5af24 100644 --- a/packages/sdk/test/usecases/CredentialManifestUseCase.test.ts +++ b/packages/sdk/test/usecases/CredentialManifestUseCase.test.ts @@ -83,8 +83,9 @@ describe("CredentialManifestUseCase Tests", () => { ), new VCLVerifiedProfile(JSON.parse(VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1)) ); + expect(true).toBe(false); } catch (error: any) { - expect(error?.errorCode).toBe(VCLErrorCode.SdkError); + expect(error?.errorCode).toBe(VCLErrorCode.SdkError.toString()); } }); }); \ No newline at end of file diff --git a/packages/sdk/test/usecases/ExchangeProgressUseCase.test.ts b/packages/sdk/test/usecases/ExchangeProgressUseCase.test.ts index 0ebda4e..1115440 100644 --- a/packages/sdk/test/usecases/ExchangeProgressUseCase.test.ts +++ b/packages/sdk/test/usecases/ExchangeProgressUseCase.test.ts @@ -2,9 +2,8 @@ import NetworkServiceSuccess from "../NetworkServiceSuccess"; import ExchangeProgressRepositoryImpl from "../../src/impl/data/repositories/ExchangeProgressRepositoryImpl"; import ExchangeProgressUseCaseImpl from "../../src/impl/data/usecases/ExchangeProgressUseCaseImpl"; import { ExchangeProgressMocks } from "../infrastructure/resources/valid/ExchangeProgressMocks"; -import { Dictionary, VCLErrorCode, VCLExchange, VCLExchangeDescriptor, VCLToken } from "../../src"; -import { mock } from "node:test"; -import { beforeAll, expect } from "@jest/globals"; +import { Dictionary, VCLExchange, VCLExchangeDescriptor, VCLToken } from "../../src"; +import { expect } from "@jest/globals"; describe("ExchangeProgressUseCase Tests", () => { const subject1 = new ExchangeProgressUseCaseImpl( @@ -14,7 +13,7 @@ describe("ExchangeProgressUseCase Tests", () => { ) const subject2 = new ExchangeProgressUseCaseImpl( new ExchangeProgressRepositoryImpl( - new NetworkServiceSuccess({ wrong: 'payload' }) + new NetworkServiceSuccess('') ) ) const exchangeDescriptor = { @@ -30,11 +29,12 @@ describe("ExchangeProgressUseCase Tests", () => { }); test("testGetExchangeProgressFailure", async () => { - try { - await subject1.getExchangeProgress(exchangeDescriptor) - } catch (error: any) { - expect(error.errorCode).toBe(VCLErrorCode.SdkError.toString()) - } + const exchange = await subject2.getExchangeProgress(exchangeDescriptor) + + expect(exchange.id).toBe(undefined) + expect(exchange.type).toBe(undefined) + expect(exchange.disclosureComplete).toBe(undefined) + expect(exchange.exchangeComplete).toBe(undefined) }); const expectedExchange = (exchangeJsonObj: Dictionary): VCLExchange => { diff --git a/packages/sdk/test/usecases/PresentationRequestUseCase.test.ts b/packages/sdk/test/usecases/PresentationRequestUseCase.test.ts index 7040038..e183ab2 100644 --- a/packages/sdk/test/usecases/PresentationRequestUseCase.test.ts +++ b/packages/sdk/test/usecases/PresentationRequestUseCase.test.ts @@ -86,8 +86,9 @@ describe("PresentationRequestUseCase Tests", () => { ), new VCLVerifiedProfile({}) ); + expect(true).toBe(false); } catch (error: any) { - expect(error.errorCode).toBe(VCLErrorCode.SdkError); + expect(error.errorCode).toBe(VCLErrorCode.SdkError.toString()); } }); }); \ No newline at end of file