Skip to content

Commit

Permalink
Merge pull request #76 from velocitycareerlabs/VL-7723
Browse files Browse the repository at this point in the history
v0.8.32 - clean up VCL API, redundant didJwk input parameter was removed
  • Loading branch information
michaelavoyan authored May 22, 2024
2 parents ebcc4b0 + 0562c3d commit dcf45c9
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/sample-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@fastify/autoload": "~5.7.1",
"env-var": "~7.3.0",
"fastify": "~4.15.0",
"@velocitycareerlabs/vnf-nodejs-wallet-sdk": "^0.8.31"
"@velocitycareerlabs/vnf-nodejs-wallet-sdk": "^0.8.32"
},
"devDependencies": {
"@jest/globals": "~29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@velocitycareerlabs/vnf-nodejs-wallet-sdk",
"version": "0.8.31",
"version": "0.8.32",
"description": "VNF Wallet SDK Nodejs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
9 changes: 3 additions & 6 deletions packages/sdk/src/api/VCL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export default interface VCL {
): Promise<VCLPresentationRequest>;

submitPresentation(
presentationSubmission: VCLPresentationSubmission,
didJwk: VCLDidJwk
presentationSubmission: VCLPresentationSubmission
): Promise<VCLSubmissionResult>;

getExchangeProgress(
Expand All @@ -55,8 +54,7 @@ export default interface VCL {
): Promise<VCLCredentialManifest>;

generateOffers(
generateOffersDescriptor: VCLGenerateOffersDescriptor,
didJwk: VCLDidJwk
generateOffersDescriptor: VCLGenerateOffersDescriptor
): Promise<VCLOffers>;

checkForOffers(
Expand All @@ -66,8 +64,7 @@ export default interface VCL {

finalizeOffers(
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
token: VCLToken,
didJwk: VCLDidJwk
token: VCLToken
): Promise<VCLJwtVerifiableCredentials>;

getCredentialTypesUIFormSchema(
Expand Down
14 changes: 4 additions & 10 deletions packages/sdk/src/impl/VCLImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,11 @@ export class VCLImpl implements VCL {
};

submitPresentation = async (
presentationSubmission: VCLPresentationSubmission,
didJwk: VCLDidJwk
presentationSubmission: VCLPresentationSubmission
) => {
const presentationSubmissionSubmission =
await this.presentationSubmissionUseCase.submit(
presentationSubmission,
didJwk
presentationSubmission
);
const [error, presentationSubmissionResult] =
presentationSubmissionSubmission.handleResult();
Expand Down Expand Up @@ -371,7 +369,6 @@ export class VCLImpl implements VCL {
};
generateOffers = async (
generateOffersDescriptor: VCLGenerateOffersDescriptor,
didJwk: VCLDidJwk
) => {
const identificationSubmission = new VCLIdentificationSubmission(
generateOffersDescriptor.credentialManifest,
Expand All @@ -381,7 +378,6 @@ export class VCLImpl implements VCL {
const identificationSubmissionResult =
await this.identificationUseCase.submit(
identificationSubmission,
didJwk
);

const [error, submission] = identificationSubmissionResult.handleResult();
Expand Down Expand Up @@ -410,14 +406,12 @@ export class VCLImpl implements VCL {
}
finalizeOffers = async (
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
token: VCLToken,
didJwk: VCLDidJwk
token: VCLToken
) => {
const jwtVerifiableCredentials =
await this.finalizeOffersUseCase.finalizeOffers(
token,
finalizeOffersDescriptor,
didJwk
finalizeOffersDescriptor
);

const [error, result] = jwtVerifiableCredentials.handleResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export default class FinalizeOffersUseCaseImpl
) {}
async finalizeOffers(
token: VCLToken,
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
didJwk: Nullish<VCLDidJwk>
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor
): Promise<VCLResult<VCLJwtVerifiableCredentials>> {
const passedCredentials: VCLJwt[] = [];
const failedCredentials: VCLJwt[] = [];
Expand Down
7 changes: 3 additions & 4 deletions packages/sdk/src/impl/data/usecases/SubmissionUseCaseImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ export default class SubmissionUseCaseImpl implements SubmissionUseCase {
private jwtServiceRepository: JwtServiceRepository
) {}
async submit(
submission: VCLSubmission,
didJwk: Nullish<VCLDidJwk>
submission: VCLSubmission
): Promise<VCLResult<VCLSubmissionResult>> {
const signedJwtResult = await this.jwtServiceRepository.generateSignedJwt(
new VCLJwtDescriptor(
submission.generatePayload(),
submission.iss,
submission.jti,
didJwk?.keyId
submission.didJwk?.keyId
),
null,
didJwk,
submission.didJwk,
submission.remoteCryptoServicesToken
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export default interface FinalizeOffersUseCase {
finalizeOffers(
token: VCLToken,
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
didJwk: Nullish<VCLDidJwk>
): Promise<VCLResult<VCLJwtVerifiableCredentials>>;
}
3 changes: 1 addition & 2 deletions packages/sdk/src/impl/domain/usecases/SubmissionUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import VCLSubmissionResult from "../../../api/entities/VCLSubmissionResult";

export default interface SubmissionUseCase {
submit(
submission: VCLSubmission,
didJwk: Nullish<VCLDidJwk>
submission: VCLSubmission
): Promise<VCLResult<VCLSubmissionResult>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("CredentialManifestUseCase Tests", () => {
expect(credentialManifest?.jwt.header).toStrictEqual(JSON.parse(CredentialManifestMocks.Header));
expect(credentialManifest?.jwt.payload).toStrictEqual(JSON.parse(CredentialManifestMocks.Payload));
expect(credentialManifest?.jwt.signature).toBe(CredentialManifestMocks.Signature);
expect(credentialManifest?.didJwk.did).toStrictEqual(DidJwkMocks.DidJwk.did);
expect(credentialManifest?.didJwk).toStrictEqual(DidJwkMocks.DidJwk);
expect(credentialManifest?.remoteCryptoServicesToken?.value).toBe("some token");
} catch (error) {
console.log(error);
Expand Down

0 comments on commit dcf45c9

Please sign in to comment.