in backend/Functions/Main/webpush_vapid_generate/app.js [47:76]
async function handleCreate(event) {
try {
const vapidKeys = webPush.generateVAPIDKeys();
const stackName = event.ResourceProperties.StackName;
const publicKeyPath = `/${stackName}/vapid/public`;
const params = {
Name: publicKeyPath,
Value: vapidKeys.publicKey,
DataType: 'text',
Description: 'Public Key for Voluntary Application Server Identification for Web Push',
Overwrite: true,
Type: 'String',
};
await ssm.putParameter(params).promise();
const privateKeyPath = `/${stackName}/vapid/private`;
const params2 = {
Name: privateKeyPath,
Value: vapidKeys.privateKey,
DataType: 'text',
Description: 'Private Key for Voluntary Application Server Identification for Web Push',
Overwrite: true,
Type: 'SecureString',
};
await ssm.putParameter(params2).promise();
return { status: 'SUCCESS', data: { PublicKeyPath: publicKeyPath, PrivateKeyPath: privateKeyPath, PublicKey: vapidKeys.publicKey } };
} catch (e) {
console.error(`error creating parameters ${JSON.stringify(e.stack)}`);
return { status: 'FAILED', data: { Error: 'Put parameters failed' } };
}
}