mirror of
https://git.coolaj86.com/coolaj86/greenlock-store-memory.js.git
synced 2025-04-20 13:00:36 +00:00
v3.0.1: clarify comments and docs
This commit is contained in:
parent
169cdb6c6a
commit
5a66693cdb
29
index.js
29
index.js
@ -37,14 +37,19 @@ module.exports.create = function (opts) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This is our in-memory storage.
|
// This is our dummy in-memory storage.
|
||||||
// We take it from the outside to make testing the dummy module easier.
|
// (we optionally receive it as an option so that it can be defined outside to make testing easier)
|
||||||
var cache = opts.cache || {};
|
var cache = opts.cache || {};
|
||||||
if (!cache.accounts) { cache.accounts = {}; }
|
if (!cache.accounts) { cache.accounts = {}; }
|
||||||
if (!cache.certificates) { cache.certificates = {}; }
|
if (!cache.certificates) { cache.certificates = {}; }
|
||||||
// Although we could have two collections of keypairs,
|
// Although we could have two collections of keypairs,
|
||||||
// it's also fine to store both types together.
|
// it's also fine to store both types together (their ids will be distinct).
|
||||||
if (!cache.keypairs) { cache.keypairs = {}; }
|
if (!cache.keypairs) { cache.keypairs = {}; }
|
||||||
|
// This is an in-memory store, hence we don't actually save it.
|
||||||
|
function saveCertificate(id, blob) { cache.certificates[id] = blob; return null; }
|
||||||
|
function getCertificate(id) { return cache.certificates[id]; }
|
||||||
|
function saveKeypair(id, blob) { cache.keypairs[id] = blob; return null; }
|
||||||
|
function getKeypair(id) { return cache.keypairs[id]; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -64,10 +69,10 @@ module.exports.create = function (opts) {
|
|||||||
var id = opts.account.id || opts.email || 'default';
|
var id = opts.account.id || opts.email || 'default';
|
||||||
var keypair = opts.keypair;
|
var keypair = opts.keypair;
|
||||||
|
|
||||||
cache.keypairs[id] = JSON.stringify({
|
saveKeypair(id, JSON.stringify({
|
||||||
privateKeyPem: keypair.privateKeyPem
|
privateKeyPem: keypair.privateKeyPem
|
||||||
, privateKeyJwk: keypair.privateKeyJwk
|
, privateKeyJwk: keypair.privateKeyJwk
|
||||||
});
|
}));
|
||||||
|
|
||||||
return null; // or Promise.resolve(null);
|
return null; // or Promise.resolve(null);
|
||||||
};
|
};
|
||||||
@ -79,7 +84,7 @@ module.exports.create = function (opts) {
|
|||||||
console.log('accounts.checkKeypair:', opts.account, opts.email);
|
console.log('accounts.checkKeypair:', opts.account, opts.email);
|
||||||
|
|
||||||
var id = opts.account.id || opts.email || 'default';
|
var id = opts.account.id || opts.email || 'default';
|
||||||
var keyblob = cache.keypairs[id];
|
var keyblob = getKeypair(id);
|
||||||
|
|
||||||
if (!keyblob) { return null; }
|
if (!keyblob) { return null; }
|
||||||
|
|
||||||
@ -116,10 +121,10 @@ module.exports.create = function (opts) {
|
|||||||
var id = opts.certificate.kid || opts.certificate.id || opts.subject;
|
var id = opts.certificate.kid || opts.certificate.id || opts.subject;
|
||||||
var keypair = opts.keypair;
|
var keypair = opts.keypair;
|
||||||
|
|
||||||
cache.keypairs[id] = JSON.stringify({
|
saveKeypair(id, JSON.stringify({
|
||||||
privateKeyPem: keypair.privateKeyPem
|
privateKeyPem: keypair.privateKeyPem
|
||||||
, privateKeyJwk: keypair.privateKeyJwk
|
, privateKeyJwk: keypair.privateKeyJwk
|
||||||
});
|
}));
|
||||||
// Note: you can use the "keypairs" package to convert between
|
// Note: you can use the "keypairs" package to convert between
|
||||||
// public and private for jwk and pem, as well as convert JWK <-> PEM
|
// public and private for jwk and pem, as well as convert JWK <-> PEM
|
||||||
|
|
||||||
@ -133,7 +138,7 @@ module.exports.create = function (opts) {
|
|||||||
console.log('certificates.checkKeypair:', opts.certificate, opts.subject);
|
console.log('certificates.checkKeypair:', opts.certificate, opts.subject);
|
||||||
|
|
||||||
var id = opts.certificate.kid || opts.certificate.id || opts.subject;
|
var id = opts.certificate.kid || opts.certificate.id || opts.subject;
|
||||||
var keyblob = cache.keypairs[id];
|
var keyblob = getKeypair(id);
|
||||||
|
|
||||||
if (!keyblob) { return null; }
|
if (!keyblob) { return null; }
|
||||||
|
|
||||||
@ -150,14 +155,14 @@ module.exports.create = function (opts) {
|
|||||||
|
|
||||||
var id = opts.certificate.id || opts.subject;
|
var id = opts.certificate.id || opts.subject;
|
||||||
var pems = opts.pems;
|
var pems = opts.pems;
|
||||||
cache.certificates[id] = JSON.stringify({
|
saveCertificate(id, JSON.stringify({
|
||||||
cert: pems.cert
|
cert: pems.cert
|
||||||
, chain: pems.chain
|
, chain: pems.chain
|
||||||
, subject: pems.subject
|
, subject: pems.subject
|
||||||
, altnames: pems.altnames
|
, altnames: pems.altnames
|
||||||
, issuedAt: pems.issuedAt // a.k.a. NotBefore
|
, issuedAt: pems.issuedAt // a.k.a. NotBefore
|
||||||
, expiresAt: pems.expiresAt // a.k.a. NotAfter
|
, expiresAt: pems.expiresAt // a.k.a. NotAfter
|
||||||
});
|
}));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@ -171,7 +176,7 @@ module.exports.create = function (opts) {
|
|||||||
console.log('certificates.check:', opts.certificate, opts.subject);
|
console.log('certificates.check:', opts.certificate, opts.subject);
|
||||||
|
|
||||||
var id = opts.certificate.id || opts.subject;
|
var id = opts.certificate.id || opts.subject;
|
||||||
var certblob = cache.certificates[id];
|
var certblob = getCertificate(id);
|
||||||
|
|
||||||
if (!certblob) { return null; }
|
if (!certblob) { return null; }
|
||||||
|
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "greenlock-store-memory",
|
"name": "greenlock-store-memory",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"lockfileVersion": 1
|
"lockfileVersion": 1
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "greenlock-store-memory",
|
"name": "greenlock-store-memory",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"description": "An in-memory reference implementation for account, certificate, and keypair storage strategies in Greenlock",
|
"description": "An in-memory reference implementation for account, certificate, and keypair storage strategies in Greenlock",
|
||||||
"homepage": "https://git.coolaj86.com/coolaj86/le-store-memory.js",
|
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-store-memory.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "tests"
|
"test": "tests"
|
||||||
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.coolaj86.com/coolaj86/le-store-memory.js.git"
|
"url": "https://git.coolaj86.com/coolaj86/greenlock-store-memory.js.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"greenlock",
|
"greenlock",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user