Skip to content

Commit

Permalink
Merge pull request #122 from velocitycareerlabs/VL-8115-split-routes
Browse files Browse the repository at this point in the history
split routes
  • Loading branch information
michaelavoyan authored Jul 14, 2024
2 parents 8ebfeeb + f8c7105 commit fc1d3c8
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 171 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/sample-app/src/screens/MeinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
verifyJwt,
generateSignedJwt
} from "../repositories";
import { Constants } from "./Constants";
import { Constants } from "../Constants";
import { Dictionary } from "../Types";
import { getApprovedRejectedOfferIdsMock } from "../utils/Utils";

Expand Down
49 changes: 49 additions & 0 deletions packages/sample-server/src/routes/CryptoServices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Created by Michael Avoyan on 14/07/2024.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
import {
didJwkDescriptorFrom,
didJwkFrom,
jwtDescriptorFrom,
jwtFromJson,
publicJwkFrom,
tokenFrom
} from "../utils/Converter";

export default async function cryptoServicesRoutes(fastify) {
fastify.post(
"/verifyJwt",
async (req, reply) => {
reply.send(
await req.vclSdk.verifyJwt(
jwtFromJson(req.body.jwt),
publicJwkFrom(req.body.publicJwk),
tokenFrom(req.body.remoteCryptoServicesToken)
)
);
}
);
fastify.post(
"/generateSignedJwt",
async (req, reply) => {
reply.send(
await req.vclSdk.generateSignedJwt(
jwtDescriptorFrom(req.body.jwtDescriptor),
didJwkFrom(req.body.didJwk),
tokenFrom(req.body.remoteCryptoServicesToken)
)
);
}
);
fastify.post(
"/generateDidJwk",
async (req, reply) => {
reply.send(
await req.vclSdk.generateDidJwk(didJwkDescriptorFrom(req.body))
);
}
);
}
27 changes: 27 additions & 0 deletions packages/sample-server/src/routes/Initialization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Created by Michael Avoyan on 14/07/2024.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/

export default async function initializationRoutes(fastify) {
fastify.get(
"/getCountries",
(req, reply) => {
reply.send(req.vclSdk.countries);
}
);
fastify.get(
"/getCredentialTypes",
(req, reply) => {
reply.send(req.vclSdk.credentialTypes);
}
);
fastify.get(
"/getCredentialTypeSchemas",
(req, reply) => {
reply.send(req.vclSdk.credentialTypeSchemas);
}
);
}
43 changes: 43 additions & 0 deletions packages/sample-server/src/routes/Inspection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Created by Michael Avoyan on 14/07/2024.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
import {
presentationRequestDescriptorFrom,
presentationSubmissionFrom,
submissionResultFrom
} from "../utils/Converter";
import { VCLExchangeDescriptor } from "@velocitycareerlabs/vnf-nodejs-wallet-sdk/src";

export default async function inspectionRoutes(fastify) {
fastify.post(
"/getPresentationRequest",
async (req, reply) => {
reply.send(
await req.vclSdk.getPresentationRequest(presentationRequestDescriptorFrom(req.body, req.didJwk))
);
}
);
fastify.post(
"/submitPresentation",
async (req, reply) => {
reply.send(
await req.vclSdk.submitPresentation(presentationSubmissionFrom(req.body))
);
}
);
fastify.post(
"/getExchangeProgress",
async (req, reply) => {
reply.send(
await req.vclSdk.getExchangeProgress(
new VCLExchangeDescriptor(
presentationSubmissionFrom(req.body.presentationSubmission),
submissionResultFrom(req.body.submissionResult)
)
));
}
);
}
55 changes: 55 additions & 0 deletions packages/sample-server/src/routes/Issuing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Created by Michael Avoyan on 14/07/2024.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
import {
credentialManifestDescriptorFrom,
finalizeOffersDescriptorFrom,
generateOffersDescriptorFrom,
tokenFrom
} from "../utils/Converter";

export default async function issuingRoutes(fastify) {
fastify.post(
"/getCredentialManifest",
async (req, reply) => {
reply.send(
await req.vclSdk.getCredentialManifest(
credentialManifestDescriptorFrom(req.body)
)
)
}
);
fastify.post(
"/generateOffers",
async (req, reply) => {
reply.send(
await req.vclSdk.generateOffers(generateOffersDescriptorFrom(req.body))
);
}
);
fastify.post(
"/checkOffers",
async (req, reply) => {
reply.send(
await req.vclSdk.checkForOffers(
generateOffersDescriptorFrom(req.body),
tokenFrom(req.body.sessionToken)
)
);
}
);
fastify.post(
"/finalizeOffers",
async (req, reply) => {
reply.send(
await req.vclSdk.finalizeOffers(
finalizeOffersDescriptorFrom(req.body.finalizeOffersDescriptor),
tokenFrom(req.body.sessionToken)
)
);
}
);
}
29 changes: 29 additions & 0 deletions packages/sample-server/src/routes/Other.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Created by Michael Avoyan on 14/07/2024.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
import {
organizationsSearchDescriptorFrom,
verifiedProfileDescriptorFrom
} from "../utils/Converter";

export default async function otherRoutes(fastify) {
fastify.post(
"/searchForOrganizations",
async (req, reply) => {
reply.send(
await req.vclSdk.searchForOrganizations(organizationsSearchDescriptorFrom(req.body))
);
}
);
fastify.post(
"/getVerifiedProfile",
async (req, reply) => {
reply.send(
await req.vclSdk.getVerifiedProfile(verifiedProfileDescriptorFrom(req.body))
);
}
);
}
170 changes: 0 additions & 170 deletions packages/sample-server/src/routes/Routes.ts

This file was deleted.

Loading

0 comments on commit fc1d3c8

Please sign in to comment.