Skip to content

Commit

Permalink
Merge pull request #118 from velocitycareerlabs/VL-8115-nrefactor-2
Browse files Browse the repository at this point in the history
refactor cont
  • Loading branch information
michaelavoyan authored Jul 11, 2024
2 parents f3d9325 + f0c6279 commit 587050b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 35 deletions.
14 changes: 3 additions & 11 deletions packages/sample-server/src/crypto-services/JwtSignServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,10 @@ export class JwtSignServiceImpl implements VCLJwtSignService {
jwtDescriptor: VCLJwtDescriptor,
didJwk: VCLDidJwk,
nonce: Nullish<string>,
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
// eslint-disable-next-line unused-imports/no-unused-vars,no-unused-vars
remoteCryptoServicesToken: Nullish<VCLToken>
): Promise<VCLJwt> {
try {
const jwtJson = await generateSignedJwtFetcher(jwtDescriptor, didJwk, nonce);
return new Promise((resolve) => {
resolve(VCLJwt.fromEncodedJwt(jwtJson['compactJwt'] as string));
});
} catch (e) {
return new Promise((resolve, reject) => {
reject(e);
});
}
const jwtJson = await generateSignedJwtFetcher(jwtDescriptor, didJwk, nonce);
return VCLJwt.fromEncodedJwt(jwtJson['compactJwt'] as string)
}
}
12 changes: 2 additions & 10 deletions packages/sample-server/src/crypto-services/JwtVerifyServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ export class JwtVerifyServiceImpl implements VCLJwtVerifyService {
jwt: VCLJwt,
publicJwk: Nullish<VCLPublicJwk>,
): Promise<boolean> {
try {
const verificationJson = await verifyJwtFetcher(jwt, publicJwk);
return new Promise((resolve) => {
resolve(verificationJson['verified'] as boolean || false);
});
} catch (e) {
return new Promise((resolve, reject) => {
reject(e);
});
}
const verificationJson = await verifyJwtFetcher(jwt, publicJwk);
return verificationJson['verified'] as boolean || false
}
}
14 changes: 1 addition & 13 deletions packages/sample-server/src/crypto-services/KeyServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,7 @@ import { VCLDidJwk, VCLDidJwkDescriptor, VCLKeyService } from "@velocitycareerla
import { generateDidJwkFetcher } from "./fetchers";

export class KeyServiceImpl implements VCLKeyService {

async generateDidJwk(didJwkDescriptor: VCLDidJwkDescriptor): Promise<VCLDidJwk> {
try {
const didJwkJson = await generateDidJwkFetcher(
didJwkDescriptor,
);
return new Promise((resolve) => {
resolve(VCLDidJwk.fromJSON(didJwkJson));
});
} catch (e) {
return new Promise((resolve, reject) => {
reject(e);
});
}
return VCLDidJwk.fromJSON(await generateDidJwkFetcher(didJwkDescriptor));
}
}
4 changes: 3 additions & 1 deletion packages/sample-server/src/routes/Routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export default async function routes(fastify) {
"/getCredentialManifest",
async (req, reply) => {
reply.send(
await req.vclSdk.getCredentialManifest(credentialManifestDescriptorFromJson(req.body, req.didJwk))
await req.vclSdk.getCredentialManifest(
credentialManifestDescriptorFromJson(req.body, req.didJwk)
)
)
}
);
Expand Down

0 comments on commit 587050b

Please sign in to comment.