manager.js
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"use strict";
var MFS = require("greenlock-manager-fs");
// TODO @greenlock/manager-cloud
var Manager = module.exports;
Manager.create = function(opts) {
var mfs = MFS.create(opts);
var manager = {};
//
// REQUIRED (basic issuance)
//
if (mfs.get) {
manager.get = async function({ servername, wildname }) {
// (optional) `wildcard` may or may not exist
// if *you* support wildcard domains, *you* should handle them
return mfs.get({ servername, wildname });
};
} else {
// (optional)
// because the current version doesn't have get()
manager.get = createGetFromFind();
}
//
// REQUIRED (basic issuance)
//
manager.set = async function(opts) {
return mfs.set(opts);
};
//
// Optional (Fully Automatic Renewal)
//
manager.find = async function(opts) {
// { subject, servernames, altnames, renewBefore }
return mfs.find(opts);
};
//
// Optional (Special Remove Functionality)
// The default behavior is to set `deletedAt`
//
//manager.remove = async function(opts) {
// return mfs.remove(opts);
//};
//
// Optional (special settings save)
// Implemented here because this module IS the fallback
//
manager.defaults = async function(opts) {
return mfs.defaults(opts);
};
//
// Optional (for common deps and/or async initialization)
//
manager.init = async function(deps) {
return mfs.init(deps);
};
return manager;
//
// IGNORE
// Backwards compat for the first versions of greenlock-manager-fs
//
function createGetFromFind() {
return async function({ servername, wildname }) {
var servernames = [servername];
if (wildname) {
servernames.push(wildname);
}
return mfs
.find({
servernames: servernames,
// because the original manager used altnames here
altnames: servernames
})
.then(function(sites) {
return sites[0] || null;
});
};
}
};