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 Sep 6, 2023
1 parent 44270cf commit 8d5defb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
40 changes: 24 additions & 16 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 Expand Up @@ -320,22 +328,22 @@ didManager:
- $ref: /dbConnection
defaultProvider: did:ethr:goerli
providers:
did:ethr:
$require: '@veramo/did-provider-ethr#EthrDIDProvider'
$args:
- defaultKms: local
network: mainnet
rpcUrl: https://mainnet.infura.io/v3/3586660d179141e3801c3895de1c2eba
gas: 1000001
ttl: 31104001
did:ethr:goerli:
$require: '@veramo/did-provider-ethr#EthrDIDProvider'
$args:
- defaultKms: local
network: goerli
rpcUrl: https://goerli.infura.io/v3/3586660d179141e3801c3895de1c2eba
gas: 1000001
ttl: 31104001
# did:ethr:
# $require: '@veramo/did-provider-ethr#EthrDIDProvider'
# $args:
# - defaultKms: local
# network: mainnet
# rpcUrl: https://mainnet.infura.io/v3/3586660d179141e3801c3895de1c2eba
# gas: 1000001
# ttl: 31104001
# did:ethr:goerli:
# $require: '@veramo/did-provider-ethr#EthrDIDProvider'
# $args:
# - defaultKms: local
# network: goerli
# rpcUrl: https://goerli.infura.io/v3/3586660d179141e3801c3895de1c2eba
# gas: 1000001
# ttl: 31104001
did:web:
$require: '@veramo/did-provider-web#WebDIDProvider'
$args:
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 8d5defb

Please sign in to comment.