doipjs/src/utils.js

23 lines
595 B
JavaScript
Raw Normal View History

const generateProxyURL = (type, url, opts) => {
return `https://${opts.doipProxyHostname}/api/1/get/${type}/${encodeURIComponent(url)}`
2020-11-03 19:01:02 -07:00
}
2020-10-24 16:39:43 -06:00
const generateClaim = (fingerprint, format) => {
switch (format) {
2020-10-24 16:31:14 -06:00
case 'uri':
2020-10-24 16:39:43 -06:00
return `openpgp4fpr:${fingerprint}`
2020-10-24 16:31:14 -06:00
break;
case 'message':
2020-10-24 16:39:43 -06:00
return `[Verifying my OpenPGP key: openpgp4fpr:${fingerprint}]`
2020-10-24 16:31:14 -06:00
break;
case 'fingerprint':
2020-10-24 16:39:43 -06:00
return fingerprint
2020-10-24 16:31:14 -06:00
break;
default:
throw new Error('No valid claim format')
}
}
2020-11-03 19:01:02 -07:00
exports.generateProxyURL = generateProxyURL
2020-10-24 16:31:14 -06:00
exports.generateClaim = generateClaim