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.
- package/README.md +25 -2
- package/index.js +28 -38
- package/lib/resolve-site-app.js +42 -0
- package/lib/static-site-handler.js +122 -0
- package/package.json +12 -3
- package/skills/roster-server/SKILL.md +15 -4
- package/test/roster-server.test.js +87 -0
- 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
- package/tasks/lessons.md +0 -4
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# Migrating Guide
|
|
2
|
+
|
|
3
|
+
Greenlock v4 is the current version.
|
|
4
|
+
|
|
5
|
+
# v3 to v4
|
|
6
|
+
|
|
7
|
+
v4 is a very minor, but breaking, change from v3
|
|
8
|
+
|
|
9
|
+
### `configFile` is replaced with `configDir`
|
|
10
|
+
|
|
11
|
+
The default config file `./greenlock.json` is now `./greenlock.d/config.json`.
|
|
12
|
+
|
|
13
|
+
This was change was mode to eliminate unnecessary configuration that was inadvertantly introduced in v3.
|
|
14
|
+
|
|
15
|
+
### `.greenlockrc` is auto-generated
|
|
16
|
+
|
|
17
|
+
`.greenlockrc` exists for the sake of tooling - so that the CLI, Web API, and your code naturally stay in sync.
|
|
18
|
+
|
|
19
|
+
It looks like this:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"manager": {
|
|
24
|
+
"module": "@greenlock/manager"
|
|
25
|
+
},
|
|
26
|
+
"configDir": "./greenlock.d"
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If you deploy to a read-only filesystem, it is best that you create the `.greenlockrc` file as part
|
|
31
|
+
of your image and use that rather than including any configuration in your code.
|
|
32
|
+
|
|
33
|
+
# v2 to v4
|
|
34
|
+
|
|
35
|
+
**Greenlock Express** uses Greenlock directly, the same as before.
|
|
36
|
+
|
|
37
|
+
All options described for `Greenlock.create({...})` also apply to the Greenlock Express `init()` callback.
|
|
38
|
+
|
|
39
|
+
# Overview of Major Differences
|
|
40
|
+
|
|
41
|
+
- Reduced API
|
|
42
|
+
- No code in the config
|
|
43
|
+
- (config is completely serializable)
|
|
44
|
+
- Manager callbacks replace `approveDomains`
|
|
45
|
+
- Greenlock Express does more, with less config
|
|
46
|
+
- cluster is supported out-of-the-box
|
|
47
|
+
- high-performance
|
|
48
|
+
- scalable
|
|
49
|
+
- ACME challenges are simplified
|
|
50
|
+
- init
|
|
51
|
+
- zones (dns-01)
|
|
52
|
+
- set
|
|
53
|
+
- get
|
|
54
|
+
- remove
|
|
55
|
+
- Store callbacks are simplified
|
|
56
|
+
- accounts
|
|
57
|
+
- checkKeypairs
|
|
58
|
+
- certificates
|
|
59
|
+
- checkKeypairs
|
|
60
|
+
- check
|
|
61
|
+
- set
|
|
62
|
+
|
|
63
|
+
# Greenlock JavaScript API greatly reduced
|
|
64
|
+
|
|
65
|
+
Whereas before there were many different methods with nuance differences,
|
|
66
|
+
now there's just `create`, `get`, `renew`, and sometimes `add` ().
|
|
67
|
+
|
|
68
|
+
- Greenlock.create({ maintainerEmail, packageAgent, notify })
|
|
69
|
+
- Greenlock.get({ servername, wildname, duplicate, force })
|
|
70
|
+
- (just a convenience wrapper around renew)
|
|
71
|
+
- Greenlock.renew({ subject, altnames, issuedBefore, expiresAfter })
|
|
72
|
+
- (retrieves, issues, renews, all-in-one)
|
|
73
|
+
- _optional_ Greenlock.add({ subject, altnames, subscriberEmail })
|
|
74
|
+
- (partially replaces `approveDomains`)
|
|
75
|
+
|
|
76
|
+
Also, some disambiguation on terms:
|
|
77
|
+
|
|
78
|
+
- `domains` was often ambiguous and confusing, it has been replaced by:
|
|
79
|
+
- `subject` refers to the subject of a certificate - the primary domain
|
|
80
|
+
- `altnames` refers to the domains in the SAN (Subject Alternative Names) section of the certificate
|
|
81
|
+
- `servername` refers to the TLS (SSL) SNI (Server Name Indication) request for a cetificate
|
|
82
|
+
- `wildname` refers to the wildcard version of the servername (ex: `www.example.com => *.example.com`)
|
|
83
|
+
|
|
84
|
+
When you create an instance of Greenlock, you only supply package and maintainer info.
|
|
85
|
+
|
|
86
|
+
All other configuration is A) optional and B) handled by the _Manager_.
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
'use strict';
|
|
90
|
+
|
|
91
|
+
var pkg = require('./package.json');
|
|
92
|
+
|
|
93
|
+
var Greenlock = require('greenlock');
|
|
94
|
+
var greenlock = Greenlock.create({
|
|
95
|
+
// used for the ACME client User-Agent string as per RFC 8555 and RFC 7231
|
|
96
|
+
packageAgent: pkg.name + '/' + pkg.version,
|
|
97
|
+
|
|
98
|
+
// used as the contact for critical bug and security notices
|
|
99
|
+
// should be the same as pkg.author.email
|
|
100
|
+
maintainerEmail: 'jon@example.com',
|
|
101
|
+
|
|
102
|
+
// used for logging background events and errors
|
|
103
|
+
notify: function(ev, args) {
|
|
104
|
+
if ('error' === ev || 'warning' === ev) {
|
|
105
|
+
console.error(ev, args);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
console.info(ev, args);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
By default **no certificates will be issued**. See the _manager_ section.
|
|
114
|
+
|
|
115
|
+
When you want to get a single certificate, you use `get`, which will:
|
|
116
|
+
|
|
117
|
+
- will return null if neither the `servername` or its `wildname` (wildcard) variant can be found
|
|
118
|
+
- retrieve a non-expired certificate, if possible
|
|
119
|
+
- will renew the certificate in the background, if stale
|
|
120
|
+
- will wait for the certificate to be issued if new
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
greenlock
|
|
124
|
+
.get({ servername: 'www.example.com' })
|
|
125
|
+
.then(function(result) {
|
|
126
|
+
if (!result) {
|
|
127
|
+
// certificate is not on the approved list
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var fullchain = result.pems.cert + '\n' + result.pems.chain + '\n';
|
|
132
|
+
var privkey = result.pems.privkey;
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
fullchain: fullchain,
|
|
136
|
+
privkey: privkey
|
|
137
|
+
};
|
|
138
|
+
})
|
|
139
|
+
.catch(function(e) {
|
|
140
|
+
// something went wrong in the renew process
|
|
141
|
+
console.error(e);
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
By default **no certificates will be issued**. See the _manager_ section.
|
|
146
|
+
|
|
147
|
+
When you want to renew certificates, _en masse_, you use `renew`, which will:
|
|
148
|
+
|
|
149
|
+
- check all certificates matching the given criteria
|
|
150
|
+
- only renew stale certificates by default
|
|
151
|
+
- return error objects (will NOT throw exception for failed renewals)
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
greenlock
|
|
155
|
+
.renew({})
|
|
156
|
+
.then(function(results) {
|
|
157
|
+
if (!result.length) {
|
|
158
|
+
// no certificates found
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// [{ site, error }]
|
|
163
|
+
return results;
|
|
164
|
+
})
|
|
165
|
+
.catch(function(e) {
|
|
166
|
+
// an unexpected error, not related to renewal
|
|
167
|
+
console.error(e);
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Options:
|
|
172
|
+
|
|
173
|
+
| Option | Description |
|
|
174
|
+
| ------------- | -------------------------------------------------------------------------- |
|
|
175
|
+
| `altnames` | only check and renew certs matching these altnames (including wildcards) |
|
|
176
|
+
| `renewBefore` | only check and renew certs marked for renewal before the given date, in ms |
|
|
177
|
+
| `duplicate` | renew certificates regardless of timing |
|
|
178
|
+
| `force` | allow silly things, like tiny `renewOffset`s |
|
|
179
|
+
|
|
180
|
+
By default **no certificates will be issued**. See the _manager_ section.
|
|
181
|
+
|
|
182
|
+
# Greenlock Express Example
|
|
183
|
+
|
|
184
|
+
The options that must be returned from `init()` are the same that are used in `Greenlock.create()`,
|
|
185
|
+
with a few extra that are specific to Greenlock Express:
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
require('@root/greenlock-express')
|
|
189
|
+
.init(function() {
|
|
190
|
+
// This object will be passed to Greenlock.create()
|
|
191
|
+
|
|
192
|
+
var options = {
|
|
193
|
+
// some options, like cluster, are special to Greenlock Express
|
|
194
|
+
|
|
195
|
+
cluster: false,
|
|
196
|
+
|
|
197
|
+
// The rest are the same as for Greenlock
|
|
198
|
+
|
|
199
|
+
packageAgent: pkg.name + '/' + pkg.version,
|
|
200
|
+
maintainerEmail: 'jon@example.com',
|
|
201
|
+
notify: function(ev, args) {
|
|
202
|
+
console.info(ev, args);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return options;
|
|
207
|
+
})
|
|
208
|
+
.serve(function(glx) {
|
|
209
|
+
// will start servers on port 80 and 443
|
|
210
|
+
|
|
211
|
+
glx.serveApp(function(req, res) {
|
|
212
|
+
res.end('Hello, Encrypted World!');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// you can get access to the raw server (i.e. for websockets)
|
|
216
|
+
|
|
217
|
+
glx.httpsServer(); // returns raw server object
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
# _Manager_ replaces `approveDomains`
|
|
222
|
+
|
|
223
|
+
`approveDomains` was always a little confusing. Most people didn't need it.
|
|
224
|
+
|
|
225
|
+
Instead, now there is a simple config file that will work for most people,
|
|
226
|
+
as well as a set of callbacks for easy configurability.
|
|
227
|
+
|
|
228
|
+
### Default Manager
|
|
229
|
+
|
|
230
|
+
The default manager is `@greenlock/manager` and the default `configDir` is `./.greenlock.d`.
|
|
231
|
+
|
|
232
|
+
The config file should look something like this:
|
|
233
|
+
|
|
234
|
+
`./greenlock.d/config.json`:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"subscriberEmail": "jon@example.com",
|
|
239
|
+
"agreeToTerms": true,
|
|
240
|
+
"sites": {
|
|
241
|
+
"example.com": {
|
|
242
|
+
"subject": "example.com",
|
|
243
|
+
"altnames": ["example.com", "www.example.com"]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
You can specify a `acme-dns-01-*` or `acme-http-01-*` challenge plugin globally, or per-site.
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"subscriberEmail": "jon@example.com",
|
|
254
|
+
"agreeToTerms": true,
|
|
255
|
+
"sites": {
|
|
256
|
+
"example.com": {
|
|
257
|
+
"subject": "example.com",
|
|
258
|
+
"altnames": ["example.com", "www.example.com"],
|
|
259
|
+
"challenges": {
|
|
260
|
+
"dns-01": {
|
|
261
|
+
"module": "acme-dns-01-digitalocean",
|
|
262
|
+
"token": "apikey-xxxxx"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
The same is true with `greenlock-store-*` plugins:
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"subscriberEmail": "jon@example.com",
|
|
275
|
+
"agreeToTerms": true,
|
|
276
|
+
"sites": {
|
|
277
|
+
"example.com": {
|
|
278
|
+
"subject": "example.com",
|
|
279
|
+
"altnames": ["example.com", "www.example.com"]
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"store": {
|
|
283
|
+
"module": "greenlock-store-fs",
|
|
284
|
+
"basePath": "~/.config/greenlock"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Customer Manager, the lazy way
|
|
290
|
+
|
|
291
|
+
At the very least you have to implement `get({ servername, wildname })`.
|
|
292
|
+
|
|
293
|
+
```js
|
|
294
|
+
var greenlock = Greenlock.create({
|
|
295
|
+
packageAgent: pkg.name + '/' + pkg.version,
|
|
296
|
+
maintainerEmail: 'jon@example.com',
|
|
297
|
+
notify: notify,
|
|
298
|
+
|
|
299
|
+
packageRoot: __dirname,
|
|
300
|
+
manager: {
|
|
301
|
+
module: './manager.js'
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
function notify(ev, args) {
|
|
306
|
+
if ('error' === ev || 'warning' === ev) {
|
|
307
|
+
console.error(ev, args);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
console.info(ev, args);
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
In the simplest case you can ignore all incoming options
|
|
315
|
+
and return a single site config in the same format as the config file
|
|
316
|
+
|
|
317
|
+
`./manager.js`:
|
|
318
|
+
|
|
319
|
+
```js
|
|
320
|
+
'use strict';
|
|
321
|
+
|
|
322
|
+
module.exports.create = function() {
|
|
323
|
+
return {
|
|
324
|
+
get: async function({ servername }) {
|
|
325
|
+
// do something to fetch the site
|
|
326
|
+
var site = {
|
|
327
|
+
subject: 'example.com',
|
|
328
|
+
altnames: ['example.com', 'www.example.com']
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
return site;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
If you want to use wildcards or local domains for a specific domain, you must specify the `dns-01` challenge plugin to use:
|
|
338
|
+
|
|
339
|
+
```js
|
|
340
|
+
'use strict';
|
|
341
|
+
|
|
342
|
+
module.exports.create = function() {
|
|
343
|
+
return {
|
|
344
|
+
get: async function({ servername }) {
|
|
345
|
+
// do something to fetch the site
|
|
346
|
+
var site = {
|
|
347
|
+
subject: 'example.com',
|
|
348
|
+
altnames: ['example.com', 'www.example.com'],
|
|
349
|
+
|
|
350
|
+
// dns-01 challenge
|
|
351
|
+
challenges: {
|
|
352
|
+
'dns-01': {
|
|
353
|
+
module: 'acme-dns-01-namedotcom',
|
|
354
|
+
apikey: 'xxxx'
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
return site;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Customer Manager, Complete
|
|
366
|
+
|
|
367
|
+
See <https://git.rootprojects.org/root/greenlock-manager-test.js#quick-start>
|
|
368
|
+
|
|
369
|
+
# ACME Challenge Plugins
|
|
370
|
+
|
|
371
|
+
The ACME challenge plugins are just a few simple callbacks:
|
|
372
|
+
|
|
373
|
+
- `init`
|
|
374
|
+
- `zones` (dns-01 only)
|
|
375
|
+
- `set`
|
|
376
|
+
- `get`
|
|
377
|
+
- `remove`
|
|
378
|
+
|
|
379
|
+
They are described here:
|
|
380
|
+
|
|
381
|
+
- [dns-01 documentation](https://git.rootprojects.org/root/acme-dns-01-test.js)
|
|
382
|
+
- [http-01 documentation](https://git.rootprojects.org/root/acme-http-01-test.js)
|
|
383
|
+
|
|
384
|
+
# Key and Cert Store Plugins
|
|
385
|
+
|
|
386
|
+
Again, these are just a few simple callbacks:
|
|
387
|
+
|
|
388
|
+
- `certificates.checkKeypair`
|
|
389
|
+
- `certificates.check`
|
|
390
|
+
- `certificates.setKeypair`
|
|
391
|
+
- `certificates.set`
|
|
392
|
+
- `accounts.checkKeypair`
|
|
393
|
+
- `accounts.check` (optional)
|
|
394
|
+
- `accounts.setKeypair`
|
|
395
|
+
- `accounts.set` (optional)
|
|
396
|
+
|
|
397
|
+
The name `check` is used instead of `get` because they only need to return something if it exists. They do not need to fail, nor do they need to generate anything.
|
|
398
|
+
|
|
399
|
+
They are described here:
|
|
400
|
+
|
|
401
|
+
- [greenlock store documentation](https://git.rootprojects.org/root/greenlock-store-test.js)
|
|
402
|
+
|
|
403
|
+
If you are just implenting in-house and are not going to publish a module, you can also do some hack things like this:
|