roster-server 2.2.10 → 2.3.0

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.
Files changed (52) hide show
  1. package/README.md +25 -2
  2. package/index.js +28 -38
  3. package/lib/resolve-site-app.js +42 -0
  4. package/lib/static-site-handler.js +122 -0
  5. package/package.json +12 -3
  6. package/skills/roster-server/SKILL.md +15 -4
  7. package/test/roster-server.test.js +87 -0
  8. package/vendor/greenlock/.prettierrc +8 -0
  9. package/vendor/greenlock/LICENSE +312 -0
  10. package/vendor/greenlock/MIGRATION_GUIDE.md +403 -0
  11. package/vendor/greenlock/README.md +667 -0
  12. package/vendor/greenlock/accounts.js +218 -0
  13. package/vendor/greenlock/bin/add.js +72 -0
  14. package/vendor/greenlock/bin/certonly.js +368 -0
  15. package/vendor/greenlock/bin/config.js +77 -0
  16. package/vendor/greenlock/bin/defaults.js +58 -0
  17. package/vendor/greenlock/bin/greenlock.js +26 -0
  18. package/vendor/greenlock/bin/init.js +159 -0
  19. package/vendor/greenlock/bin/lib/cli.js +230 -0
  20. package/vendor/greenlock/bin/lib/flags.js +385 -0
  21. package/vendor/greenlock/bin/remove.js +46 -0
  22. package/vendor/greenlock/bin/tmpl/app.tmpl.js +9 -0
  23. package/vendor/greenlock/bin/tmpl/cluster.tmpl.js +30 -0
  24. package/vendor/greenlock/bin/tmpl/greenlock.tmpl.js +13 -0
  25. package/vendor/greenlock/bin/tmpl/server.tmpl.js +20 -0
  26. package/vendor/greenlock/bin/update.js +62 -0
  27. package/vendor/greenlock/certificates.js +324 -0
  28. package/vendor/greenlock/errors.js +58 -0
  29. package/vendor/greenlock/greenlock.js +621 -0
  30. package/vendor/greenlock/greenlockrc.js +169 -0
  31. package/vendor/greenlock/lib/challenges-wrapper.js +88 -0
  32. package/vendor/greenlock/lib/directory-url.js +44 -0
  33. package/vendor/greenlock/lib/init.js +191 -0
  34. package/vendor/greenlock/lib/manager-wrapper.js +625 -0
  35. package/vendor/greenlock/lib/rc.js +70 -0
  36. package/vendor/greenlock/logo/beaker-browser-301x112.png +0 -0
  37. package/vendor/greenlock/logo/from-not-secure-to-secure-url-bar.png +0 -0
  38. package/vendor/greenlock/logo/greenlock-1063x250.png +0 -0
  39. package/vendor/greenlock/logo/greenlock-850x200.png +0 -0
  40. package/vendor/greenlock/logo/ibm-301x112.png +0 -0
  41. package/vendor/greenlock/logo/telebit-301x112.png +0 -0
  42. package/vendor/greenlock/order.js +63 -0
  43. package/vendor/greenlock/package-lock.json +140 -0
  44. package/vendor/greenlock/package.json +56 -0
  45. package/vendor/greenlock/plugins.js +270 -0
  46. package/vendor/greenlock/tests/cli.sh +31 -0
  47. package/vendor/greenlock/tests/index.js +53 -0
  48. package/vendor/greenlock/user-events.js +7 -0
  49. package/vendor/greenlock/utils.js +281 -0
  50. package/vendor/greenlock-express/greenlock-shim.js +3 -1
  51. package/vendor/greenlock-express/package.json +0 -1
  52. package/tasks/lessons.md +0 -4
@@ -0,0 +1,385 @@
1
+ 'use strict';
2
+
3
+ var Flags = module.exports;
4
+ var log = require('lemonlog')('greenlock-flags');
5
+
6
+ var pkgRoot = process.cwd();
7
+ //var Init = require('../../lib/init.js');
8
+
9
+ // These are ALL options
10
+ // The individual CLI files each select a subset of them
11
+ Flags.flags = function(mconf, myOpts) {
12
+ // Current Manager Config
13
+ if (!mconf) {
14
+ mconf = {};
15
+ }
16
+
17
+ // Extra Override Options
18
+ if (!myOpts) {
19
+ myOpts = {};
20
+ }
21
+
22
+ return {
23
+ all: [
24
+ false,
25
+ 'search all site configs rather than by --subject or --servernames',
26
+ 'boolean'
27
+ ],
28
+ 'agree-to-terms': [
29
+ false,
30
+ "agree to the Let's Encrypts Subscriber Agreement and Greenlock Terms of Use",
31
+ 'boolean'
32
+ ],
33
+ subject: [
34
+ false,
35
+ 'the "subject" (primary domain) of the certificate',
36
+ 'string'
37
+ ],
38
+ altnames: [
39
+ false,
40
+ 'the "subject alternative names" (additional domains) on the certificate, the first of which MUST be the subject',
41
+ 'string'
42
+ ],
43
+ servername: [
44
+ false,
45
+ 'a name that matches a subject or altname',
46
+ 'string'
47
+ ],
48
+ servernames: [
49
+ false,
50
+ 'a list of names that matches a subject or altname',
51
+ 'string'
52
+ ],
53
+ cluster: [false, 'initialize with cluster mode on', 'boolean', false],
54
+ 'renew-offset': [
55
+ false,
56
+ "time to wait until renewing the cert such as '45d' (45 days after being issued) or '-3w' (3 weeks before expiration date)",
57
+ 'string',
58
+ mconf.renewOffset
59
+ ],
60
+ 'customer-email': [
61
+ false,
62
+ "the email address of the owner of the domain or site (not necessarily the Let's Encrypt or ACME subscriber)",
63
+ 'string'
64
+ ],
65
+ 'subscriber-email': [
66
+ false,
67
+ "the email address of the Let's Encrypt or ACME Account subscriber (not necessarily the domain owner)",
68
+ 'string'
69
+ ],
70
+ 'config-dir': [
71
+ false,
72
+ 'the directory in which config.json and other config and storage files should be written',
73
+ 'string'
74
+ ],
75
+ 'maintainer-email': [
76
+ false,
77
+ 'the maintainance contact for security and critical bug notices',
78
+ 'string'
79
+ ],
80
+ 'account-key-type': [
81
+ false,
82
+ "either 'P-256' (ECDSA) or 'RSA-2048' - although other values are technically supported, they don't make sense and won't work with many services (More bits != More security)",
83
+ 'string',
84
+ mconf.accountKeyType
85
+ ],
86
+ 'server-key-type': [
87
+ false,
88
+ "either 'RSA-2048' or 'P-256' (ECDSA) - although other values are technically supported, they don't make sense and won't work with many services (More bits != More security)",
89
+ 'string',
90
+ mconf.serverKeyType
91
+ ],
92
+ store: [
93
+ false,
94
+ 'the module name or file path of the store module to use',
95
+ 'string'
96
+ //mconf.store.module
97
+ ],
98
+ 'store-xxxx': [
99
+ false,
100
+ 'an option for the chosen store module, such as --store-apikey or --store-bucket',
101
+ 'bag'
102
+ ],
103
+ manager: [
104
+ false,
105
+ 'the module name or file path of the manager module to use',
106
+ 'string',
107
+ '@greenlock/manager'
108
+ ],
109
+ 'manager-xxxx': [
110
+ false,
111
+ 'an option for the chosen manager module, such as --manager-apikey or --manager-dburl',
112
+ 'bag'
113
+ ],
114
+ challenge: [
115
+ false,
116
+ 'the module name or file path of the HTTP-01, DNS-01, or TLS-ALPN-01 challenge module to use',
117
+ 'string',
118
+ ''
119
+ /*
120
+ Object.keys(mconf.challenges)
121
+ .map(function(typ) {
122
+ return mconf.challenges[typ].module;
123
+ })
124
+ .join(',')
125
+ */
126
+ ],
127
+ 'challenge-xxxx': [
128
+ false,
129
+ 'an option for the chosen challenge module, such as --challenge-apikey or --challenge-bucket',
130
+ 'bag'
131
+ ],
132
+ 'challenge-json': [
133
+ false,
134
+ 'a JSON string containing all option for the chosen challenge module (instead of --challenge-xxxx)',
135
+ 'json',
136
+ '{}'
137
+ ],
138
+ 'challenge-http-01': [
139
+ false,
140
+ 'the module name or file path of the HTTP-01 to add',
141
+ 'string'
142
+ //(mconf.challenges['http-01'] || {}).module
143
+ ],
144
+ 'challenge-http-01-xxxx': [
145
+ false,
146
+ 'an option for the chosen challenge module, such as --challenge-http-01-apikey or --challenge-http-01-bucket',
147
+ 'bag'
148
+ ],
149
+ 'challenge-dns-01': [
150
+ false,
151
+ 'the module name or file path of the DNS-01 to add',
152
+ 'string'
153
+ //(mconf.challenges['dns-01'] || {}).module
154
+ ],
155
+ 'challenge-dns-01-xxxx': [
156
+ false,
157
+ 'an option for the chosen challenge module, such as --challenge-dns-01-apikey or --challenge-dns-01-bucket',
158
+ 'bag'
159
+ ],
160
+ 'challenge-tls-alpn-01': [
161
+ false,
162
+ 'the module name or file path of the DNS-01 to add',
163
+ 'string'
164
+ //(mconf.challenges['tls-alpn-01'] || {}).module
165
+ ],
166
+ 'challenge-tls-alpn-01-xxxx': [
167
+ false,
168
+ 'an option for the chosen challenge module, such as --challenge-tls-alpn-01-apikey or --challenge-tls-alpn-01-bucket',
169
+ 'bag'
170
+ ],
171
+ 'force-save': [
172
+ false,
173
+ "save all options for this site, even if it's the same as the defaults",
174
+ 'boolean',
175
+ myOpts.forceSave || false
176
+ ]
177
+ };
178
+ };
179
+
180
+ Flags.init = async function(myOpts) {
181
+ var Greenlock = require('../../');
182
+
183
+ // this is a copy, so it's safe to modify
184
+ var greenlock = Greenlock.create({
185
+ packageRoot: pkgRoot,
186
+ _mustPackage: true,
187
+ _init: true,
188
+ _bin_mode: true
189
+ });
190
+ var mconf = await greenlock.manager.defaults();
191
+ var flagOptions = Flags.flags(mconf, myOpts);
192
+ return {
193
+ flagOptions,
194
+ greenlock,
195
+ mconf
196
+ };
197
+ };
198
+
199
+ Flags.mangleFlags = function(flags, mconf, sconf, extras) {
200
+ if (extras) {
201
+ if (extras.forceSave) {
202
+ flags.forceSave = true;
203
+ }
204
+ }
205
+ //console.log('debug a:', flags);
206
+
207
+ if ('altnames' in flags) {
208
+ flags.altnames = (flags.altnames || '').split(/[,\s]+/).filter(Boolean);
209
+ }
210
+ if ('servernames' in flags) {
211
+ flags.servernames = (flags.servernames || '')
212
+ .split(/[,\s]+/)
213
+ .filter(Boolean);
214
+ }
215
+
216
+ var store;
217
+ if (flags.store) {
218
+ store = flags.storeOpts;
219
+ store.module = flags.store;
220
+ flags.store = store;
221
+ } else {
222
+ delete flags.store;
223
+ }
224
+ delete flags.storeOpts;
225
+
226
+ // If this is additive, make an object to hold all values
227
+ var isAdditive = [
228
+ ['http-01', 'Http01'],
229
+ ['dns-01', 'Dns01'],
230
+ ['tls-alpn-01', 'TlsAlpn01']
231
+ ].some(function(types) {
232
+ var typCamel = types[1];
233
+ var modname = 'challenge' + typCamel;
234
+ if (flags[modname]) {
235
+ if (!flags.challenges) {
236
+ flags.challenges = {};
237
+ }
238
+ return true;
239
+ }
240
+ });
241
+ if (isAdditive && sconf) {
242
+ // copy over the old
243
+ var schallenges = sconf.challenges || {};
244
+ Object.keys(schallenges).forEach(function(k) {
245
+ if (!flags.challenges[k]) {
246
+ flags.challenges[k] = schallenges[k];
247
+ }
248
+ });
249
+ }
250
+
251
+ var typ;
252
+ var challenge;
253
+ if (flags.challenge) {
254
+ // this varient of the flag is exclusive
255
+ flags.challenges = {};
256
+ isAdditive = false;
257
+
258
+ if (/http-01/.test(flags.challenge)) {
259
+ typ = 'http-01';
260
+ } else if (/dns-01/.test(flags.challenge)) {
261
+ typ = 'dns-01';
262
+ } else if (/tls-alpn-01/.test(flags.challenge)) {
263
+ typ = 'tls-alpn-01';
264
+ }
265
+
266
+ var modname = 'challenge';
267
+ var optsname = 'challengeOpts';
268
+ challenge = flags[optsname];
269
+ // JSON may already have module name
270
+ if (challenge.module) {
271
+ if (flags[modname] && challenge.module !== flags[modname]) {
272
+ log.error('Challenge module names do not match: %s vs %s', challenge.module, flags[modname]);
273
+ process.exit(1);
274
+ }
275
+ } else {
276
+ challenge.module = flags[modname];
277
+ }
278
+ flags.challenges[typ] = challenge;
279
+
280
+ var chall = mconf.challenges[typ];
281
+ if (chall && challenge.module === chall.module) {
282
+ var keys = Object.keys(challenge);
283
+ var same =
284
+ !keys.length ||
285
+ keys.every(function(k) {
286
+ return chall[k] === challenge[k];
287
+ });
288
+ if (same && !flags.forceSave) {
289
+ delete flags.challenges;
290
+ }
291
+ }
292
+ }
293
+ delete flags.challenge;
294
+ delete flags.challengeOpts;
295
+
296
+ // Add each of the values, including the existing
297
+ [
298
+ ['http-01', 'Http01'],
299
+ ['dns-01', 'Dns01'],
300
+ ['tls-alpn-01', 'TlsAlpn01']
301
+ ].forEach(function(types) {
302
+ var typ = types[0];
303
+ var typCamel = types[1];
304
+ var modname = 'challenge' + typCamel;
305
+ var optsname = 'challenge' + typCamel + 'Opts';
306
+ var chall = mconf.challenges[typ];
307
+ var challenge = flags[optsname];
308
+
309
+ // this variant of the flag is additive
310
+ if (isAdditive && chall && flags.forceSave) {
311
+ if (flags.challenges && !flags.challenges[typ]) {
312
+ flags.challenges[typ] = chall;
313
+ }
314
+ }
315
+
316
+ if (!flags[modname]) {
317
+ delete flags[modname];
318
+ delete flags[optsname];
319
+ return;
320
+ }
321
+
322
+ // JSON may already have module name
323
+ if (challenge.module) {
324
+ if (flags[modname] && challenge.module !== flags[modname]) {
325
+ log.error('Challenge module names do not match: %s vs %s', challenge.module, flags[modname]);
326
+ process.exit(1);
327
+ }
328
+ } else {
329
+ challenge.module = flags[modname];
330
+ }
331
+ if (flags[modname]) {
332
+ if (!flags.challenges) {
333
+ flags.challenges = {};
334
+ }
335
+ flags.challenges[typ] = challenge;
336
+ }
337
+
338
+ // Check to see if this is already what's set in the defaults
339
+ if (chall && challenge.module === chall.module) {
340
+ var keys = Object.keys(challenge);
341
+ // Check if all of the options are also the same
342
+ var same =
343
+ !keys.length ||
344
+ keys.every(function(k) {
345
+ return chall[k] === challenge[k];
346
+ });
347
+ if (same && !flags.forceSave) {
348
+ // If it's already the global, don't make it the per-site
349
+ delete flags[modname];
350
+ delete flags[optsname];
351
+ }
352
+ }
353
+
354
+ delete flags[modname];
355
+ delete flags[optsname];
356
+ });
357
+
358
+ [
359
+ ['accountKeyType', [/256/, /384/, /EC/], 'EC-P256'],
360
+ ['serverKeyType', [/RSA/], 'RSA-2048']
361
+ ].forEach(function(k) {
362
+ var key = k[0];
363
+ var vals = k[1];
364
+ var val = flags[key];
365
+ if (val) {
366
+ if (
367
+ !vals.some(function(v) {
368
+ return v.test(val);
369
+ })
370
+ ) {
371
+ flags[key] = k[2];
372
+ log.warn("%s value '%s' not allowed; using default '%s'", key, val, k[2]);
373
+ }
374
+ }
375
+ });
376
+
377
+ Object.keys(flags).forEach(function(k) {
378
+ if (flags[k] === mconf[k] && !flags.forceSave) {
379
+ delete flags[k];
380
+ }
381
+ });
382
+
383
+ //console.log('debug z:', flags);
384
+ delete flags.forceSave;
385
+ };
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var log = require('lemonlog')('greenlock-remove');
4
+ var args = process.argv.slice(3);
5
+ var cli = require('./lib/cli.js');
6
+ //var path = require('path');
7
+ //var pkgpath = path.join(__dirname, '..', 'package.json');
8
+ //var pkgpath = path.join(process.cwd(), 'package.json');
9
+
10
+ var Flags = require('./lib/flags.js');
11
+
12
+ Flags.init().then(function({ flagOptions, greenlock, mconf }) {
13
+ var myFlags = {};
14
+ ['subject'].forEach(function(k) {
15
+ myFlags[k] = flagOptions[k];
16
+ });
17
+
18
+ cli.parse(myFlags);
19
+ cli.main(function(argList, flags) {
20
+ Flags.mangleFlags(flags, mconf);
21
+ main(argList, flags, greenlock);
22
+ }, args);
23
+ });
24
+
25
+ async function main(_, flags, greenlock) {
26
+ if (!flags.subject) {
27
+ log.error('Provide --subject (valid domain)');
28
+ process.exit(1);
29
+ return;
30
+ }
31
+
32
+ greenlock
33
+ .remove(flags)
34
+ .catch(function(err) {
35
+ log.error('Remove failed:', err.message);
36
+ process.exit(1);
37
+ })
38
+ .then(function(site) {
39
+ if (!site) {
40
+ log.info('No config found for', flags.subject);
41
+ process.exit(1);
42
+ return;
43
+ }
44
+ log.info('Deleted config for %s:', flags.subject, site);
45
+ });
46
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ // Here's a vanilla HTTP app to start,
4
+ // but feel free to replace it with Express, Koa, etc
5
+ var app = function(req, res) {
6
+ res.end('Hello, Encrypted World!');
7
+ };
8
+
9
+ module.exports = app;
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ require('greenlock-express')
4
+ .init(function() {
5
+ // var pkg = require('./package.json');
6
+
7
+ return {
8
+ // where to find .greenlockrc and set default paths
9
+ packageRoot: __dirname,
10
+
11
+ // name & version for ACME client user agent
12
+ //packageAgent: pkg.name + '/' + pkg.version,
13
+
14
+ // contact for security and critical bug notices
15
+ //maintainerEmail: pkg.author,
16
+
17
+ // where to look for configuration
18
+ configDir: './greenlock.d',
19
+
20
+ // whether or not to run at cloudscale
21
+ cluster: true
22
+ };
23
+ })
24
+ .ready(function(glx) {
25
+ var app = require('./app.js');
26
+
27
+ // Serves on 80 and 443
28
+ // Get's SSL certificates magically!
29
+ glx.serveApp(app);
30
+ });
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var pkg = require('./package.json');
4
+ module.exports = require('@root/greenlock').create({
5
+ // name & version for ACME client user agent
6
+ packageAgent: pkg.name + '/' + pkg.version,
7
+
8
+ // contact for security and critical bug notices
9
+ //maintainerEmail: pkg.author,
10
+
11
+ // where to find .greenlockrc and set default paths
12
+ packageRoot: __dirname
13
+ });
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var app = require('./app.js');
4
+
5
+ require('greenlock-express')
6
+ .init({
7
+ packageRoot: __dirname,
8
+
9
+ // contact for security and critical bug notices
10
+ //maintainerEmail: pkg.author,
11
+
12
+ // where to look for configuration
13
+ configDir: './greenlock.d',
14
+
15
+ // whether or not to run at cloudscale
16
+ cluster: false
17
+ })
18
+ // Serves on 80 and 443
19
+ // Get's SSL certificates magically!
20
+ .serve(app);
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var log = require('lemonlog')('greenlock-update');
4
+ var args = process.argv.slice(3);
5
+ var cli = require('./lib/cli.js');
6
+ var Flags = require('./lib/flags.js');
7
+
8
+ Flags.init().then(function({ flagOptions, greenlock, mconf }) {
9
+ var myFlags = {};
10
+ [
11
+ 'subject',
12
+ 'altnames',
13
+ 'renew-offset',
14
+ 'subscriber-email',
15
+ 'customer-email',
16
+ 'server-key-type',
17
+ 'challenge-http-01',
18
+ 'challenge-http-01-xxxx',
19
+ 'challenge-dns-01',
20
+ 'challenge-dns-01-xxxx',
21
+ 'challenge-tls-alpn-01',
22
+ 'challenge-tls-alpn-01-xxxx',
23
+ 'challenge',
24
+ 'challenge-xxxx',
25
+ 'challenge-json',
26
+ 'force-save'
27
+ ].forEach(function(k) {
28
+ myFlags[k] = flagOptions[k];
29
+ });
30
+
31
+ cli.parse(myFlags);
32
+ cli.main(async function(argList, flags) {
33
+ var sconf = await greenlock._config({ servername: flags.subject });
34
+ Flags.mangleFlags(flags, mconf, sconf);
35
+ main(argList, flags, greenlock);
36
+ }, args);
37
+ });
38
+
39
+ async function main(_, flags, greenlock) {
40
+ if (!flags.subject) {
41
+ log.error('Provide --subject (valid domain)');
42
+ process.exit(1);
43
+ return;
44
+ }
45
+
46
+ greenlock
47
+ .update(flags)
48
+ .catch(function(err) {
49
+ log.error('Update failed:', err.message);
50
+ process.exit(1);
51
+ })
52
+ .then(function() {
53
+ return greenlock._config({ servername: flags.subject }).then(function(site) {
54
+ if (!site) {
55
+ log.error('No config found for', flags.subject);
56
+ process.exit(1);
57
+ return;
58
+ }
59
+ log.info('Updated site config:', site);
60
+ });
61
+ });
62
+ }