roster-server 2.2.9 → 2.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/package.json +12 -3
- package/tasks/lessons.md +2 -1
- package/test/roster-server.test.js +5 -6
- package/vendor/greenlock/.prettierrc +8 -0
- package/vendor/greenlock/LICENSE +312 -0
- package/vendor/greenlock/MIGRATION_GUIDE.md +403 -0
- package/vendor/greenlock/README.md +667 -0
- package/vendor/greenlock/accounts.js +218 -0
- package/vendor/greenlock/bin/add.js +72 -0
- package/vendor/greenlock/bin/certonly.js +368 -0
- package/vendor/greenlock/bin/config.js +77 -0
- package/vendor/greenlock/bin/defaults.js +58 -0
- package/vendor/greenlock/bin/greenlock.js +26 -0
- package/vendor/greenlock/bin/init.js +159 -0
- package/vendor/greenlock/bin/lib/cli.js +230 -0
- package/vendor/greenlock/bin/lib/flags.js +385 -0
- package/vendor/greenlock/bin/remove.js +46 -0
- package/vendor/greenlock/bin/tmpl/app.tmpl.js +9 -0
- package/vendor/greenlock/bin/tmpl/cluster.tmpl.js +30 -0
- package/vendor/greenlock/bin/tmpl/greenlock.tmpl.js +13 -0
- package/vendor/greenlock/bin/tmpl/server.tmpl.js +20 -0
- package/vendor/greenlock/bin/update.js +62 -0
- package/vendor/greenlock/certificates.js +324 -0
- package/vendor/greenlock/errors.js +58 -0
- package/vendor/greenlock/greenlock.js +621 -0
- package/vendor/greenlock/greenlockrc.js +169 -0
- package/vendor/greenlock/lib/challenges-wrapper.js +88 -0
- package/vendor/greenlock/lib/directory-url.js +44 -0
- package/vendor/greenlock/lib/init.js +191 -0
- package/vendor/greenlock/lib/manager-wrapper.js +625 -0
- package/vendor/greenlock/lib/rc.js +70 -0
- package/vendor/greenlock/logo/beaker-browser-301x112.png +0 -0
- package/vendor/greenlock/logo/from-not-secure-to-secure-url-bar.png +0 -0
- package/vendor/greenlock/logo/greenlock-1063x250.png +0 -0
- package/vendor/greenlock/logo/greenlock-850x200.png +0 -0
- package/vendor/greenlock/logo/ibm-301x112.png +0 -0
- package/vendor/greenlock/logo/telebit-301x112.png +0 -0
- package/vendor/greenlock/order.js +63 -0
- package/vendor/greenlock/package-lock.json +140 -0
- package/vendor/greenlock/package.json +56 -0
- package/vendor/greenlock/plugins.js +270 -0
- package/vendor/greenlock/tests/cli.sh +31 -0
- package/vendor/greenlock/tests/index.js +53 -0
- package/vendor/greenlock/user-events.js +7 -0
- package/vendor/greenlock/utils.js +281 -0
- package/vendor/greenlock-express/greenlock-shim.js +3 -1
- package/vendor/greenlock-express/package.json +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var log = require('lemonlog')('greenlock-order');
|
|
2
|
+
var accountKeypair = await Keypairs.generate({ kty: accKty });
|
|
3
|
+
if (config.debug) {
|
|
4
|
+
log.info('Account key created', accountKeypair);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var account = await acme.accounts.create({
|
|
8
|
+
agreeToTerms: agree,
|
|
9
|
+
// TODO detect jwk/pem/der?
|
|
10
|
+
accountKeypair: { privateKeyJwk: accountKeypair.private },
|
|
11
|
+
subscriberEmail: config.email
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// TODO top-level agree
|
|
15
|
+
function agree(tos) {
|
|
16
|
+
if (config.debug) log.info('Agreeing to Terms of Service:', tos);
|
|
17
|
+
agreed = true;
|
|
18
|
+
return Promise.resolve(tos);
|
|
19
|
+
}
|
|
20
|
+
if (config.debug) log.info('New subscriber account', account);
|
|
21
|
+
if (!agreed) {
|
|
22
|
+
throw new Error('Failed to ask the user to agree to terms');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var certKeypair = await Keypairs.generate({ kty: srvKty });
|
|
26
|
+
var pem = await Keypairs.export({
|
|
27
|
+
jwk: certKeypair.private,
|
|
28
|
+
encoding: 'pem'
|
|
29
|
+
});
|
|
30
|
+
if (config.debug) {
|
|
31
|
+
log.info('Server key created (privkey.%s.pem)', srvKty.toLowerCase(), certKeypair);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 'subject' should be first in list
|
|
35
|
+
var domains = randomDomains(rnd);
|
|
36
|
+
if (config.debug) {
|
|
37
|
+
log.info('Requesting certificates for domains:', domains.map(function(p) {
|
|
38
|
+
var u = punycode.toUnicode(p);
|
|
39
|
+
return p !== u ? p + ' (' + u + ')' : p;
|
|
40
|
+
}).join(', '));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Create CSR
|
|
44
|
+
var csrDer = await CSR.csr({
|
|
45
|
+
jwk: certKeypair.private,
|
|
46
|
+
domains: domains,
|
|
47
|
+
encoding: 'der'
|
|
48
|
+
});
|
|
49
|
+
var csr = Enc.bufToUrlBase64(csrDer);
|
|
50
|
+
var csrPem = PEM.packBlock({
|
|
51
|
+
type: 'CERTIFICATE REQUEST',
|
|
52
|
+
bytes: csrDer /* { jwk: jwk, domains: opts.domains } */
|
|
53
|
+
});
|
|
54
|
+
if (config.debug) log.info('Certificate signing request (CSR) created');
|
|
55
|
+
|
|
56
|
+
var results = await acme.certificates.create({
|
|
57
|
+
account: account,
|
|
58
|
+
accountKeypair: { privateKeyJwk: accountKeypair.private },
|
|
59
|
+
csr: csr,
|
|
60
|
+
domains: domains,
|
|
61
|
+
challenges: challenges, // must be implemented
|
|
62
|
+
customerEmail: null
|
|
63
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@root/greenlock",
|
|
3
|
+
"version": "4.0.5",
|
|
4
|
+
"lockfileVersion": 1,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@greenlock/manager": {
|
|
8
|
+
"version": "3.1.0",
|
|
9
|
+
"resolved": "https://registry.npmjs.org/@greenlock/manager/-/manager-3.1.0.tgz",
|
|
10
|
+
"integrity": "sha512-PBy5CMK+j4oD7sj7hF5qE+xKEOSiiuL2hHd5X5ttEbtnTSDKjNeqbrR5k2ZddwVNdjOVeBIeuqlm81IFZ+Ftew==",
|
|
11
|
+
"requires": {
|
|
12
|
+
"greenlock-manager-fs": "^3.1.0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"greenlock-manager-fs": {
|
|
16
|
+
"version": "3.1.1",
|
|
17
|
+
"resolved": "https://registry.npmjs.org/greenlock-manager-fs/-/greenlock-manager-fs-3.1.1.tgz",
|
|
18
|
+
"integrity": "sha512-np6qdnPIOZx40PAcSQcqK1eMPWjTKxsxcgRd/OVg0ai49WC1Ds74CTrwmB84pq2n53ikbnDBQFmKEQ4AC0DK8w==",
|
|
19
|
+
"requires": {
|
|
20
|
+
"@root/mkdirp": "^1.0.0",
|
|
21
|
+
"safe-replace": "^1.1.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"@root/acme": {
|
|
27
|
+
"version": "3.1.0",
|
|
28
|
+
"resolved": "https://registry.npmjs.org/@root/acme/-/acme-3.1.0.tgz",
|
|
29
|
+
"integrity": "sha512-GAyaW63cpSYd2KvVp5lHLbCWeEhJPKZK9nsJvZJOKsD9Uv88KEttn4FpDZEJ+2q3Jsey0DWpuQ2I4ft0JV9p2w==",
|
|
30
|
+
"requires": {
|
|
31
|
+
"@root/csr": "^0.8.1",
|
|
32
|
+
"@root/encoding": "^1.0.1",
|
|
33
|
+
"@root/keypairs": "^0.10.0",
|
|
34
|
+
"@root/pem": "^1.0.4",
|
|
35
|
+
"@root/request": "^1.6.1",
|
|
36
|
+
"@root/x509": "^0.7.2"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@root/request": {
|
|
40
|
+
"version": "1.6.1",
|
|
41
|
+
"resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz",
|
|
42
|
+
"integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ=="
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"@root/asn1": {
|
|
47
|
+
"version": "1.0.0",
|
|
48
|
+
"resolved": "https://registry.npmjs.org/@root/asn1/-/asn1-1.0.0.tgz",
|
|
49
|
+
"integrity": "sha512-0lfZNuOULKJDJmdIkP8V9RnbV3XaK6PAHD3swnFy4tZwtlMDzLKoM/dfNad7ut8Hu3r91wy9uK0WA/9zym5mig==",
|
|
50
|
+
"requires": {
|
|
51
|
+
"@root/encoding": "^1.0.1"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"@root/csr": {
|
|
55
|
+
"version": "0.8.1",
|
|
56
|
+
"resolved": "https://registry.npmjs.org/@root/csr/-/csr-0.8.1.tgz",
|
|
57
|
+
"integrity": "sha512-hKl0VuE549TK6SnS2Yn9nRvKbFZXn/oAg+dZJU/tlKl/f/0yRXeuUzf8akg3JjtJq+9E592zDqeXZ7yyrg8fSQ==",
|
|
58
|
+
"requires": {
|
|
59
|
+
"@root/asn1": "^1.0.0",
|
|
60
|
+
"@root/pem": "^1.0.4",
|
|
61
|
+
"@root/x509": "^0.7.2"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"@root/encoding": {
|
|
65
|
+
"version": "1.0.1",
|
|
66
|
+
"resolved": "https://registry.npmjs.org/@root/encoding/-/encoding-1.0.1.tgz",
|
|
67
|
+
"integrity": "sha512-OaEub02ufoU038gy6bsNHQOjIn8nUjGiLcaRmJ40IUykneJkIW5fxDqKxQx48cszuNflYldsJLPPXCrGfHs8yQ=="
|
|
68
|
+
},
|
|
69
|
+
"@root/keypairs": {
|
|
70
|
+
"version": "0.10.0",
|
|
71
|
+
"resolved": "https://registry.npmjs.org/@root/keypairs/-/keypairs-0.10.0.tgz",
|
|
72
|
+
"integrity": "sha512-t8VocY46Mtb0NTsxzyLLf5tsgfw0BXLYVADAyiRdEdqHcvPFGJdjkXNtHVQuSV/FMaC65iTOHVP4E6X8iT3Ikg==",
|
|
73
|
+
"requires": {
|
|
74
|
+
"@root/encoding": "^1.0.1",
|
|
75
|
+
"@root/pem": "^1.0.4",
|
|
76
|
+
"@root/x509": "^0.7.2"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"@root/mkdirp": {
|
|
80
|
+
"version": "1.0.0",
|
|
81
|
+
"resolved": "https://registry.npmjs.org/@root/mkdirp/-/mkdirp-1.0.0.tgz",
|
|
82
|
+
"integrity": "sha512-hxGAYUx5029VggfG+U9naAhQkoMSXtOeXtbql97m3Hi6/sQSRL/4khKZPyOF6w11glyCOU38WCNLu9nUcSjOfA=="
|
|
83
|
+
},
|
|
84
|
+
"@root/pem": {
|
|
85
|
+
"version": "1.0.4",
|
|
86
|
+
"resolved": "https://registry.npmjs.org/@root/pem/-/pem-1.0.4.tgz",
|
|
87
|
+
"integrity": "sha512-rEUDiUsHtild8GfIjFE9wXtcVxeS+ehCJQBwbQQ3IVfORKHK93CFnRtkr69R75lZFjcmKYVc+AXDB+AeRFOULA=="
|
|
88
|
+
},
|
|
89
|
+
"@root/request": {
|
|
90
|
+
"version": "1.6.1",
|
|
91
|
+
"resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz",
|
|
92
|
+
"integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ=="
|
|
93
|
+
},
|
|
94
|
+
"@root/x509": {
|
|
95
|
+
"version": "0.7.2",
|
|
96
|
+
"resolved": "https://registry.npmjs.org/@root/x509/-/x509-0.7.2.tgz",
|
|
97
|
+
"integrity": "sha512-ENq3LGYORK5NiMFHEVeNMt+fTXaC7DTS6sQXoqV+dFdfT0vmiL5cDLjaXQhaklJQq0NiwicZegzJRl1ZOTp3WQ==",
|
|
98
|
+
"requires": {
|
|
99
|
+
"@root/asn1": "^1.0.0",
|
|
100
|
+
"@root/encoding": "^1.0.1"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"acme-http-01-standalone": {
|
|
104
|
+
"version": "3.0.5",
|
|
105
|
+
"resolved": "https://registry.npmjs.org/acme-http-01-standalone/-/acme-http-01-standalone-3.0.5.tgz",
|
|
106
|
+
"integrity": "sha512-W4GfK+39GZ+u0mvxRVUcVFCG6gposfzEnSBF20T/NUwWAKG59wQT1dUbS1NixRIAsRuhpGc4Jx659cErFQH0Pg=="
|
|
107
|
+
},
|
|
108
|
+
"cert-info": {
|
|
109
|
+
"version": "1.5.1",
|
|
110
|
+
"resolved": "https://registry.npmjs.org/cert-info/-/cert-info-1.5.1.tgz",
|
|
111
|
+
"integrity": "sha512-eoQC/yAgW3gKTKxjzyClvi+UzuY97YCjcl+lSqbsGIy7HeGaWxCPOQFivhUYm27hgsBMhsJJFya3kGvK6PMIcQ=="
|
|
112
|
+
},
|
|
113
|
+
"dotenv": {
|
|
114
|
+
"version": "8.2.0",
|
|
115
|
+
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
|
|
116
|
+
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
|
|
117
|
+
"dev": true
|
|
118
|
+
},
|
|
119
|
+
"greenlock-store-fs": {
|
|
120
|
+
"version": "3.2.2",
|
|
121
|
+
"resolved": "https://registry.npmjs.org/greenlock-store-fs/-/greenlock-store-fs-3.2.2.tgz",
|
|
122
|
+
"integrity": "sha512-92ejLB4DyV4qv/2b6VLGF2nKfYQeIfg3o+e/1cIoYLjlIaUFdbBXkzLTRozFlHsQPZt2ALi5qYrpC9IwH7GK8A==",
|
|
123
|
+
"requires": {
|
|
124
|
+
"@root/mkdirp": "^1.0.0",
|
|
125
|
+
"safe-replace": "^1.1.0"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"punycode": {
|
|
129
|
+
"version": "1.4.1",
|
|
130
|
+
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
|
|
131
|
+
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
|
|
132
|
+
"dev": true
|
|
133
|
+
},
|
|
134
|
+
"safe-replace": {
|
|
135
|
+
"version": "1.1.0",
|
|
136
|
+
"resolved": "https://registry.npmjs.org/safe-replace/-/safe-replace-1.1.0.tgz",
|
|
137
|
+
"integrity": "sha512-9/V2E0CDsKs9DWOOwJH7jYpSl9S3N05uyevNjvsnDauBqRowBPOyot1fIvV5N2IuZAbYyvrTXrYFVG0RZInfFw=="
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@root/greenlock",
|
|
3
|
+
"version": "4.0.5",
|
|
4
|
+
"description": "The easiest Let's Encrypt client for Node.js and Browsers",
|
|
5
|
+
"homepage": "https://rootprojects.org/greenlock/",
|
|
6
|
+
"main": "greenlock.js",
|
|
7
|
+
"browser": {},
|
|
8
|
+
"bin": {
|
|
9
|
+
"greenlock": "bin/greenlock.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"*.js",
|
|
13
|
+
"lib",
|
|
14
|
+
"bin",
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "nodex bin/bundle.js",
|
|
19
|
+
"lint": "jshint lib bin",
|
|
20
|
+
"test": "node server.js",
|
|
21
|
+
"start": "node server.js"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://git.rootprojects.org/root/greenlock.js.git"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"Let's Encrypt",
|
|
29
|
+
"ACME",
|
|
30
|
+
"browser",
|
|
31
|
+
"EC",
|
|
32
|
+
"RSA",
|
|
33
|
+
"CSR",
|
|
34
|
+
"greenlock",
|
|
35
|
+
"VanillaJS",
|
|
36
|
+
"ZeroSSL"
|
|
37
|
+
],
|
|
38
|
+
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
|
|
39
|
+
"license": "MPL-2.0",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@greenlock/manager": "^3.1.0",
|
|
42
|
+
"@root/acme": "^3.1.0",
|
|
43
|
+
"@root/csr": "^0.8.1",
|
|
44
|
+
"@root/keypairs": "^0.10.0",
|
|
45
|
+
"@root/mkdirp": "^1.0.0",
|
|
46
|
+
"@root/request": "^1.6.1",
|
|
47
|
+
"acme-http-01-standalone": "^3.0.5",
|
|
48
|
+
"cert-info": "^1.5.1",
|
|
49
|
+
"greenlock-store-fs": "^3.2.2",
|
|
50
|
+
"safe-replace": "^1.1.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"dotenv": "^8.2.0",
|
|
54
|
+
"punycode": "^1.4.1"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var P = module.exports;
|
|
4
|
+
var log = require('lemonlog')('greenlock-plugins');
|
|
5
|
+
|
|
6
|
+
var spawn = require('child_process').spawn;
|
|
7
|
+
var spawnSync = require('child_process').spawnSync;
|
|
8
|
+
var promisify = require('util').promisify;
|
|
9
|
+
|
|
10
|
+
// Exported for CLIs and such to override
|
|
11
|
+
P.PKG_DIR = __dirname;
|
|
12
|
+
|
|
13
|
+
P._loadStore = function(storeConf) {
|
|
14
|
+
return P._loadHelper(storeConf.module).then(function(plugin) {
|
|
15
|
+
return P._normalizeStore(storeConf.module, plugin.create(storeConf));
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
P._loadChallenge = function(chConfs, typ01) {
|
|
19
|
+
return P._loadHelper(chConfs[typ01].module).then(function(plugin) {
|
|
20
|
+
var ch = P._normalizeChallenge(
|
|
21
|
+
chConfs[typ01].module,
|
|
22
|
+
plugin.create(chConfs[typ01])
|
|
23
|
+
);
|
|
24
|
+
ch._type = typ01;
|
|
25
|
+
return ch;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
P._loadHelper = function(modname) {
|
|
29
|
+
try {
|
|
30
|
+
return Promise.resolve(require(modname));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
log.error("Could not load plugin '%s'. Install: npm install --save %s", modname, modname);
|
|
33
|
+
e.context = 'load_plugin';
|
|
34
|
+
throw e;
|
|
35
|
+
|
|
36
|
+
// Fun experiment, bad idea
|
|
37
|
+
/*
|
|
38
|
+
return P._install(modname).then(function() {
|
|
39
|
+
return require(modname);
|
|
40
|
+
});
|
|
41
|
+
*/
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
P._normalizeStore = function(name, store) {
|
|
46
|
+
var acc = store.accounts;
|
|
47
|
+
var crt = store.certificates;
|
|
48
|
+
|
|
49
|
+
var warned = false;
|
|
50
|
+
function warn() {
|
|
51
|
+
if (warned) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
warned = true;
|
|
55
|
+
log.warn("Store '%s' may have incorrect signatures or deprecated callbacks", name);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// accs
|
|
59
|
+
if (acc.check && 2 === acc.check.length) {
|
|
60
|
+
warn();
|
|
61
|
+
acc._thunk_check = acc.check;
|
|
62
|
+
acc.check = promisify(acc._thunk_check);
|
|
63
|
+
}
|
|
64
|
+
if (acc.set && 3 === acc.set.length) {
|
|
65
|
+
warn();
|
|
66
|
+
acc._thunk_set = acc.set;
|
|
67
|
+
acc.set = promisify(acc._thunk_set);
|
|
68
|
+
}
|
|
69
|
+
if (2 === acc.checkKeypair.length) {
|
|
70
|
+
warn();
|
|
71
|
+
acc._thunk_checkKeypair = acc.checkKeypair;
|
|
72
|
+
acc.checkKeypair = promisify(acc._thunk_checkKeypair);
|
|
73
|
+
}
|
|
74
|
+
if (3 === acc.setKeypair.length) {
|
|
75
|
+
warn();
|
|
76
|
+
acc._thunk_setKeypair = acc.setKeypair;
|
|
77
|
+
acc.setKeypair = promisify(acc._thunk_setKeypair);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// certs
|
|
81
|
+
if (2 === crt.check.length) {
|
|
82
|
+
warn();
|
|
83
|
+
crt._thunk_check = crt.check;
|
|
84
|
+
crt.check = promisify(crt._thunk_check);
|
|
85
|
+
}
|
|
86
|
+
if (3 === crt.set.length) {
|
|
87
|
+
warn();
|
|
88
|
+
crt._thunk_set = crt.set;
|
|
89
|
+
crt.set = promisify(crt._thunk_set);
|
|
90
|
+
}
|
|
91
|
+
if (2 === crt.checkKeypair.length) {
|
|
92
|
+
warn();
|
|
93
|
+
crt._thunk_checkKeypair = crt.checkKeypair;
|
|
94
|
+
crt.checkKeypair = promisify(crt._thunk_checkKeypair);
|
|
95
|
+
}
|
|
96
|
+
if (2 === crt.setKeypair.length) {
|
|
97
|
+
warn();
|
|
98
|
+
crt._thunk_setKeypair = crt.setKeypair;
|
|
99
|
+
crt.setKeypair = promisify(crt._thunk_setKeypair);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return store;
|
|
103
|
+
};
|
|
104
|
+
P._normalizeChallenge = function(name, ch) {
|
|
105
|
+
var gch = {};
|
|
106
|
+
var warned = false;
|
|
107
|
+
function warn() {
|
|
108
|
+
if (warned) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
warned = true;
|
|
112
|
+
log.warn("Challenge '%s' may have incorrect signatures or deprecated callbacks", name);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var warned2 = false;
|
|
116
|
+
function warn2() {
|
|
117
|
+
if (warned2) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
warned2 = true;
|
|
121
|
+
log.warn("Challenge '%s' did not return a Promise; maintainer should fix", name);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function wrappy(fn) {
|
|
125
|
+
return function(_params) {
|
|
126
|
+
return Promise.resolve().then(function() {
|
|
127
|
+
var result = fn.call(ch, _params);
|
|
128
|
+
if (!result || !result.then) {
|
|
129
|
+
warn2();
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// init, zones, set, get, remove, propagationDelay
|
|
137
|
+
if (ch.init) {
|
|
138
|
+
if (2 === ch.init.length) {
|
|
139
|
+
warn();
|
|
140
|
+
ch._thunk_init = ch.init;
|
|
141
|
+
ch.init = promisify(ch._thunk_init);
|
|
142
|
+
}
|
|
143
|
+
gch.init = wrappy(ch.init);
|
|
144
|
+
}
|
|
145
|
+
if (ch.zones) {
|
|
146
|
+
if (2 === ch.zones.length) {
|
|
147
|
+
warn();
|
|
148
|
+
ch._thunk_zones = ch.zones;
|
|
149
|
+
ch.zones = promisify(ch._thunk_zones);
|
|
150
|
+
}
|
|
151
|
+
gch.zones = wrappy(ch.zones);
|
|
152
|
+
}
|
|
153
|
+
if (2 === ch.set.length) {
|
|
154
|
+
warn();
|
|
155
|
+
ch._thunk_set = ch.set;
|
|
156
|
+
ch.set = promisify(ch._thunk_set);
|
|
157
|
+
}
|
|
158
|
+
gch.set = wrappy(ch.set);
|
|
159
|
+
if (2 === ch.remove.length) {
|
|
160
|
+
warn();
|
|
161
|
+
ch._thunk_remove = ch.remove;
|
|
162
|
+
ch.remove = promisify(ch._thunk_remove);
|
|
163
|
+
}
|
|
164
|
+
gch.remove = wrappy(ch.remove);
|
|
165
|
+
if (ch.get) {
|
|
166
|
+
if (2 === ch.get.length) {
|
|
167
|
+
warn();
|
|
168
|
+
ch._thunk_get = ch.get;
|
|
169
|
+
ch.get = promisify(ch._thunk_get);
|
|
170
|
+
}
|
|
171
|
+
gch.get = wrappy(ch.get);
|
|
172
|
+
}
|
|
173
|
+
if("number" === typeof ch.propagationDelay) {
|
|
174
|
+
gch.propagationDelay = ch.propagationDelay;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return gch;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
P._loadSync = function(modname) {
|
|
181
|
+
try {
|
|
182
|
+
return require(modname);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
log.error("Could not load plugin '%s'. Install: npm install --save %s", modname, modname);
|
|
185
|
+
e.context = 'load_plugin';
|
|
186
|
+
throw e;
|
|
187
|
+
}
|
|
188
|
+
/*
|
|
189
|
+
try {
|
|
190
|
+
mod = require(modname);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
P._installSync(modname);
|
|
193
|
+
mod = require(modname);
|
|
194
|
+
}
|
|
195
|
+
*/
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
P._installSync = function(moduleName) {
|
|
199
|
+
try {
|
|
200
|
+
return require(moduleName);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
// continue
|
|
203
|
+
}
|
|
204
|
+
var npm = 'npm';
|
|
205
|
+
var args = ['install', '--save', moduleName];
|
|
206
|
+
var out = '';
|
|
207
|
+
var cmd;
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
cmd = spawnSync(npm, args, {
|
|
211
|
+
cwd: P.PKG_DIR,
|
|
212
|
+
windowsHide: true
|
|
213
|
+
});
|
|
214
|
+
} catch (e) {
|
|
215
|
+
log.error("Failed to start npm install in %s: %s", P.PKG_DIR, e.message);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!cmd.status) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
out += cmd.stdout.toString('utf8');
|
|
224
|
+
out += cmd.stderr.toString('utf8');
|
|
225
|
+
if (out) log.error(out);
|
|
226
|
+
log.error("npm install failed in %s. Try: cd %s && npm %s", P.PKG_DIR, P.PKG_DIR, args.join(' '));
|
|
227
|
+
process.exit(1);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
P._install = function(moduleName) {
|
|
231
|
+
return new Promise(function(resolve) {
|
|
232
|
+
if (!moduleName) {
|
|
233
|
+
throw new Error('no module name given');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
var npm = 'npm';
|
|
237
|
+
var args = ['install', '--save', moduleName];
|
|
238
|
+
var out = '';
|
|
239
|
+
var cmd = spawn(npm, args, {
|
|
240
|
+
cwd: P.PKG_DIR,
|
|
241
|
+
windowsHide: true
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
cmd.stdout.on('data', function(chunk) {
|
|
245
|
+
out += chunk.toString('utf8');
|
|
246
|
+
});
|
|
247
|
+
cmd.stdout.on('data', function(chunk) {
|
|
248
|
+
out += chunk.toString('utf8');
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
cmd.on('error', function(e) {
|
|
252
|
+
log.error("Failed to start npm install in %s: %s", P.PKG_DIR, e.message);
|
|
253
|
+
process.exit(1);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
cmd.on('exit', function(code) {
|
|
257
|
+
if (!code) {
|
|
258
|
+
resolve();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (out) log.error(out);
|
|
262
|
+
log.error("npm install failed in %s. Try: cd %s && npm %s", P.PKG_DIR, P.PKG_DIR, args.join(' '));
|
|
263
|
+
process.exit(1);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
if (require.main === module) {
|
|
269
|
+
P._installSync(process.argv[2]);
|
|
270
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# TODO notify if wildcard is selected and no dns challenge is present
|
|
6
|
+
node bin/greenlock.js add --subject example.com --altnames 'example.com,*.example.com'
|
|
7
|
+
node bin/greenlock.js update --subject example.com
|
|
8
|
+
node bin/greenlock.js config --subject example.com
|
|
9
|
+
node bin/greenlock.js config --subject *.example.com
|
|
10
|
+
node bin/greenlock.js defaults
|
|
11
|
+
node bin/greenlock.js defaults --account-key-type
|
|
12
|
+
node bin/greenlock.js defaults
|
|
13
|
+
# using --challenge-xx-xx-xxx is additive
|
|
14
|
+
node bin/greenlock.js defaults --challenge-dns-01 foo-http-01-bar --challenge-dns-01-token BIG_TOKEN
|
|
15
|
+
# using --challenge is exclusive (will delete things not mentioned)
|
|
16
|
+
node bin/greenlock.js defaults --challenge acme-http-01-standalone
|
|
17
|
+
# should delete all and add just this one anew
|
|
18
|
+
node bin/greenlock.js update --subject example.com --challenge bar-http-01-baz
|
|
19
|
+
# should add, leaving the existing
|
|
20
|
+
node bin/greenlock.js update --subject example.com --challenge-dns-01 baz-dns-01-qux --challenge-dns-01-token BIG_TOKEN
|
|
21
|
+
# should delete all and add just this one anew
|
|
22
|
+
node bin/greenlock.js update --subject example.com --challenge bar-http-01-baz
|
|
23
|
+
node bin/greenlock.js remove --subject example.com
|
|
24
|
+
|
|
25
|
+
# TODO test for failure
|
|
26
|
+
# node bin/greenlock.js add --subject example.com
|
|
27
|
+
# node bin/greenlock.js add --subject example --altnames example
|
|
28
|
+
# node bin/greenlock.js add --subject example.com --altnames '*.example.com'
|
|
29
|
+
# node bin/greenlock.js add --subject example.com --altnames '*.example.com,example.com'
|
|
30
|
+
# node bin/greenlock.js update --altnames example.com
|
|
31
|
+
# node bin/greenlock.js config foo.example.com
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('dotenv').config();
|
|
4
|
+
var log = require('lemonlog')('greenlock-test');
|
|
5
|
+
|
|
6
|
+
var Greenlock = require('../');
|
|
7
|
+
|
|
8
|
+
var subject = process.env.BASE_DOMAIN;
|
|
9
|
+
var altnames = [subject, '*.' + subject, 'foo.bar.' + subject];
|
|
10
|
+
var email = process.env.SUBSCRIBER_EMAIL;
|
|
11
|
+
var challenge = JSON.parse(process.env.CHALLENGE_OPTIONS);
|
|
12
|
+
challenge.module = process.env.CHALLENGE_PLUGIN;
|
|
13
|
+
|
|
14
|
+
var greenlock = Greenlock.create({
|
|
15
|
+
packageAgent: 'Greenlock_Test/v0',
|
|
16
|
+
maintainerEmail: email,
|
|
17
|
+
staging: true,
|
|
18
|
+
manager: require('greenlock-manager-fs').create({
|
|
19
|
+
//configFile: '~/.config/greenlock/certs.json',
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
greenlock.manager
|
|
24
|
+
.defaults({
|
|
25
|
+
agreeToTerms: true,
|
|
26
|
+
subscriberEmail: email,
|
|
27
|
+
challenges: {
|
|
28
|
+
'dns-01': challenge
|
|
29
|
+
}
|
|
30
|
+
//store: args.storeOpts,
|
|
31
|
+
//renewOffset: args.renewOffset || '30d',
|
|
32
|
+
//renewStagger: '1d'
|
|
33
|
+
})
|
|
34
|
+
.then(function() {
|
|
35
|
+
return greenlock
|
|
36
|
+
.add({
|
|
37
|
+
subject: subject,
|
|
38
|
+
altnames: altnames,
|
|
39
|
+
subscriberEmail: email
|
|
40
|
+
})
|
|
41
|
+
.then(function() {
|
|
42
|
+
return greenlock
|
|
43
|
+
.get({ servername: subject })
|
|
44
|
+
.then(function(pems) {
|
|
45
|
+
if (pems && pems.privkey && pems.cert && pems.chain) {
|
|
46
|
+
log.info('Success');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
.catch(function(e) {
|
|
52
|
+
log.error('Test failed: %s', e.code, e);
|
|
53
|
+
});
|