1.2.0 • Published 8 years ago
pan-domain-public-keys v1.2.0
Utility functions to fetch pan domain public keys.
fetchKey
Fetch the public key of a given stage. It will make a network request on every call.
import {fetchKey} from 'pan-domain-public-keys';
fetchKey('PROD').then(key => {
console.log(key);
// Single line base 64 key as stored in the file:
// abcdef0123456789abcdef...
})
You can either pass a stage to fetchKey
(case insensitive) or a full domain.
When using a stage, it assumes gutools
domain.
fetchPEM
Fetch the public key of a given stage and convert to PEM. It will make a network request on every call.
import {fetchPEM} from 'pan-domain-public-keys';
fetchPEM('PROD').then(key => {
console.log(key);
// PEM formatted key:
/*
-----BEGIN PUBLIC KEY-----
abcdef0123456789abcdef...
-----END PUBLIC KEY-----
*/
})
getKey
Same as fetchKey
but uses an internal cache. It will make a network call only on cache miss.
getPEM
Same as fetchPEM
but uses an internal cache. It will make a network call only on cache miss.
configure
Configure the module
import {configure} from 'pan-domain-public-keys';
configure({
expires: 60 * 1000 // milliseconds after which cached keys expire, default 1hour
});