Skip to content

Commit

Permalink
fix: get apple signer pem file from config
Browse files Browse the repository at this point in the history
Signed-off-by: Nam Hoang <[email protected]>
  • Loading branch information
namhoang1604 committed Mar 12, 2024
1 parent 3013ece commit 4fbd5d7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
8 changes: 8 additions & 0 deletions packages/cli/default/default-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ server:
$args:
- keyMapping:
Ed25519: JsonWebKey2020 # Ed25519VerificationKey2020 | JsonWebKey2020

# Wallet API
- - /wallet
- $require: '@vckit/wallet?t=function#WalletRouter'
$args:
- encryptedEndpoint: http://localhost:3332/encrypted-storage/encrypted-data
qrCodeVerifyEndpoint: http://localhost:3000/credential-verifier
signerPemFile: ./vc.dev.pem

# VC API
- - $require: '@vckit/vc-api?t=function#VCRouter'
Expand Down
1 change: 1 addition & 0 deletions packages/cli/default/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ server:
$args:
- encryptedEndpoint: http://localhost:3332/encrypted-storage/encrypted-data
qrCodeVerifyEndpoint: http://localhost:3000/credential-verifier
signerPemFile: ./vc.dev.pem

# VC API
- - $require: '@vckit/vc-api?t=function#VCRouter'
Expand Down
24 changes: 17 additions & 7 deletions packages/wallet/src/controllers/apple-wallet-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getApplePass = async (
if (!encryptedCredentialData) {
throw Error('Encrypted data not found');
}
const { encryptedEndpoint, qrCodeVerifyEndpoint } = args;
const { encryptedEndpoint, qrCodeVerifyEndpoint, signerPemFile } = args;

const id = encryptedCredentialData.encryptedDataId;
const uri = `${encryptedEndpoint}/${id}`;
Expand All @@ -45,7 +45,11 @@ export const getApplePass = async (
const encodedUrlPayload = encodeURIComponent(JSON.stringify({ payload }));
const vcQrcodeUrl = `${qrCodeVerifyEndpoint}?q=${encodedUrlPayload}`;

const pass = await generateApplePass(credential, vcQrcodeUrl);
const pass = await generateApplePass(
credential,
vcQrcodeUrl,
signerPemFile
);
res
.status(200)
.setHeader(
Expand All @@ -59,14 +63,20 @@ export const getApplePass = async (
}
};

async function generateApplePass(vc: any, vcQrcodeUrl: string) {
async function generateApplePass(
vc: any,
vcQrcodeUrl: string,
signerPemFile: string
) {
const template = await Template.load(
'./packages/wallet/src/apple-wallet/StudentVisaGrant.pass'
);
await template.loadCertificate(
'./packages/wallet/src/apple-wallet/pass.au.com.gosource.vc.dev.pem',
'password'
);

if (!signerPemFile) {
throw Error('Apple wallet certificate not available');
}

await template.loadCertificate(signerPemFile, 'password');
const pass = template.createPass({
serialNumber: '12354',
barcodes: [
Expand Down

0 comments on commit 4fbd5d7

Please sign in to comment.