Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor cont #118

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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