roster-server 1.9.8 → 2.0.2

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 (35) hide show
  1. package/index.js +1 -1
  2. package/package.json +4 -3
  3. package/skills/roster-server/SKILL.md +6 -9
  4. package/vendor/greenlock-express/.prettierrc +7 -0
  5. package/vendor/greenlock-express/LICENSE +375 -0
  6. package/vendor/greenlock-express/README.md +536 -0
  7. package/vendor/greenlock-express/WALKTHROUGH.md +256 -0
  8. package/vendor/greenlock-express/config.js +20 -0
  9. package/vendor/greenlock-express/demo.js +35 -0
  10. package/vendor/greenlock-express/examples/cluster/package.json +12 -0
  11. package/vendor/greenlock-express/examples/express/my-express-app.js +17 -0
  12. package/vendor/greenlock-express/examples/express/package.json +12 -0
  13. package/vendor/greenlock-express/examples/http/package.json +12 -0
  14. package/vendor/greenlock-express/examples/http-proxy/package.json +12 -0
  15. package/vendor/greenlock-express/examples/http2/package.json +12 -0
  16. package/vendor/greenlock-express/examples/https/package.json +12 -0
  17. package/vendor/greenlock-express/examples/quickstart/README.md +22 -0
  18. package/vendor/greenlock-express/examples/quickstart/package.json +12 -0
  19. package/vendor/greenlock-express/examples/socket.io/package.json +12 -0
  20. package/vendor/greenlock-express/examples/websockets/package.json +12 -0
  21. package/vendor/greenlock-express/greenlock-express.js +48 -0
  22. package/vendor/greenlock-express/greenlock-shim.js +72 -0
  23. package/vendor/greenlock-express/http-middleware.js +154 -0
  24. package/vendor/greenlock-express/https-middleware.js +139 -0
  25. package/vendor/greenlock-express/install.sh +14 -0
  26. package/vendor/greenlock-express/lib/compat.js +37 -0
  27. package/vendor/greenlock-express/main.js +32 -0
  28. package/vendor/greenlock-express/master.js +164 -0
  29. package/vendor/greenlock-express/package-lock.json +149 -0
  30. package/vendor/greenlock-express/package.json +51 -0
  31. package/vendor/greenlock-express/scripts/postinstall +77 -0
  32. package/vendor/greenlock-express/servers.js +171 -0
  33. package/vendor/greenlock-express/single.js +36 -0
  34. package/vendor/greenlock-express/sni.js +215 -0
  35. package/vendor/greenlock-express/worker.js +73 -0
@@ -0,0 +1,256 @@
1
+ # Greenlock Express Walkthrough
2
+
3
+ This will show you the basics of how to
4
+
5
+ 1. Create a node project
6
+ 2. Create an http app (i.e. express)
7
+ 3. Serve with Greenlock Express
8
+ 4. Manage SSL Certificates and Domains
9
+
10
+ ## 1. Create a node project
11
+
12
+ Create an empty node project.
13
+
14
+ Be sure to fill out the package name, version, and an author email.
15
+
16
+ ```bash
17
+ mkdir ~/my-project
18
+ pushd ~/my-project
19
+ npm init
20
+ ```
21
+
22
+ ## 2. Create an http app (i.e. express)
23
+
24
+ This example is shown with Express, but any node app will do. Greenlock
25
+ works with everything.
26
+ (or any node-style http app)
27
+
28
+ `my-express-app.js`:
29
+
30
+ ```js
31
+ "use strict";
32
+
33
+ // A plain, node-style app
34
+
35
+ function myPlainNodeHttpApp(req, res) {
36
+ res.end("Hello, Encrypted World!");
37
+ }
38
+
39
+ // Wrap that plain app in express,
40
+ // because that's what you're used to
41
+
42
+ var express = require("express");
43
+ var app = express();
44
+ app.get("/", myPlainNodeHttpApp);
45
+
46
+ // export the app normally
47
+ // do not .listen()
48
+
49
+ module.exports = app;
50
+ ```
51
+
52
+ ## 3. Serve with Greenlock Express
53
+
54
+ Greenlock Express is designed with these goals in mind:
55
+
56
+ - Simplicity and ease-of-use
57
+ - Performance and scalability
58
+ - Configurability and control
59
+
60
+ You can start with **near-zero configuration** and
61
+ slowly add options for greater performance and customization
62
+ later, if you need them.
63
+
64
+ `server.js`:
65
+
66
+ ```js
67
+ "use strict";
68
+
69
+ //var pkg = require("./package.json");
70
+ var app = require("./app.js");
71
+
72
+ require("greenlock-express")
73
+ .init({
74
+ // where to find .greenlockrc and set default paths
75
+ packageRoot: __dirname,
76
+
77
+ // where config and certificate stuff go
78
+ configDir: "./greenlock.d",
79
+
80
+ // contact for security and critical bug notices
81
+ maintainerEmail: pkg.author,
82
+
83
+ // name & version for ACME client user agent
84
+ //packageAgent: pkg.name + "/" + pkg.version,
85
+
86
+ // whether or not to run at cloudscale
87
+ cluster: false
88
+ })
89
+ .serve(app);
90
+ ```
91
+
92
+ And start your server:
93
+
94
+ ```bash
95
+ # Allow non-root node to use ports 80 (HTTP) and 443 (HTTPS)
96
+ sudo setcap 'cap_net_bind_service=+ep' $(which node)
97
+ ```
98
+
99
+ ```bash
100
+ # `npm start` will call `node ./server.js` by default
101
+ npm start
102
+ ```
103
+
104
+ ```bash
105
+ # use --staging to use the development API until you're ready to get real certificates
106
+ npm start -- --staging
107
+ ```
108
+
109
+ ```txt
110
+ Greenlock v4.0.0
111
+ Greenlock Config Dir/File: ./greenlock.d/config.json
112
+
113
+ Listening on 0.0.0.0:80 for ACME challenges and HTTPS redirects
114
+ Listening on 0.0.0.0:443 for secure traffic
115
+ ```
116
+
117
+ ## 4. Manage SSL Certificates and Domains
118
+
119
+ The management API is built to work with Databases, S3, etc.
120
+
121
+ By default, it's just a simple config file and directory.
122
+
123
+ ```bash
124
+ # see which manager and what options are in use
125
+ cat .greenlockrc
126
+ ```
127
+
128
+ <details>
129
+ <summary>Example Output</summary>
130
+
131
+ ```json
132
+ {
133
+ "manager": {
134
+ "module": "@greenlock/manager"
135
+ },
136
+ "configDir": "./greenlock.d"
137
+ }
138
+ ```
139
+
140
+ </details>
141
+
142
+ ```bash
143
+ # show the global defaults with the CLI
144
+ npx greenlock defaults
145
+ ```
146
+
147
+ ```js
148
+ // show the global defaults with the API
149
+ var defaults = await greenlock.defaults();
150
+ ```
151
+
152
+ <details>
153
+ <summary>Example Output</summary>
154
+
155
+ ```json
156
+ {
157
+ "store": {
158
+ "module": "greenlock-store-fs",
159
+ "basePath": "./greenlock.d"
160
+ },
161
+ "challenges": {
162
+ "http-01": {
163
+ "module": "acme-http-01-standalone"
164
+ }
165
+ },
166
+ "renewOffset": "-45d",
167
+ "renewStagger": "3d",
168
+ "accountKeyType": "EC-P256",
169
+ "serverKeyType": "RSA-2048",
170
+ "subscriberEmail": "jon@example.com",
171
+ "agreeToTerms": true
172
+ }
173
+ ```
174
+
175
+ </details>
176
+
177
+ ```bash
178
+ # show per-site configs with the CLI
179
+ npx greenlock config --subject example.com
180
+ ```
181
+
182
+ ```js
183
+ // show a site config with the API
184
+ greenlock.sites.get({ subject: "example.com" });
185
+ ```
186
+
187
+ <details>
188
+ <summary>Example Output</summary>
189
+
190
+ ```json
191
+ {
192
+ "subject": "example.com",
193
+ "altnames": ["example.com"],
194
+ "renewAt": 1576638107754,
195
+ "defaults": {
196
+ "store": {
197
+ "module": "greenlock-store-fs",
198
+ "basePath": "./greenlock.d"
199
+ },
200
+ "challenges": {
201
+ "http-01": {
202
+ "module": "acme-http-01-standalone"
203
+ }
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ </details>
210
+
211
+ Management can be done via the **CLI** or the JavaScript [**API**](https://git.rootprojects.org/root/greenlock.js).
212
+ Since this is the QuickStart, we'll demo the **CLI**:
213
+
214
+ You need to create a Let's Encrypt _subscriber account_, which can be done globally, or per-site.
215
+ All individuals, and most businesses, should set this globally:
216
+
217
+ ```bash
218
+ # Set a global subscriber account with the CLI
219
+ npx greenlock defaults --subscriber-email 'mycompany@example.com' --agree-to-terms true
220
+ ```
221
+
222
+ ```js
223
+ // set a global subscriber account with the API
224
+ greenlock.manager.defaults({
225
+ subscriberEmail: "mycompany@example.com",
226
+ agreeToTerms: true
227
+ });
228
+ ```
229
+
230
+ <!-- todo print where the key was saved -->
231
+
232
+ A Let's Encrypt SSL certificate has a "Subject" (Primary Domain) and up to 100 "Alternative Names"
233
+ (of which the first _must_ be the subject).
234
+
235
+ ```bash
236
+ # Add a certificate with specific domains with the CLI
237
+ npx greenlock add --subject example.com --altnames example.com,www.example.com
238
+ ```
239
+
240
+ ```js
241
+ // Add a certificate with specific domains with the API
242
+ greenlock.sites.add({
243
+ subject: "example.com",
244
+ altnames: ["example.com"]
245
+ });
246
+ ```
247
+
248
+ <!-- todo print where the cert was saved -->
249
+
250
+ Note: **Localhost**, **Wildcard**, and Certificates for Private Networks require
251
+ [**DNS validation**](https://git.rootprojects.org/root/greenlock-exp).
252
+
253
+ - DNS Validation
254
+ - [**Wildcards**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/wildcards/) (coming soon)
255
+ - [**Localhost**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/localhost/) (coming soon)
256
+ - [**CI/CD**](https://git.rootprojects.org/root/greenlock-express.js/src/branch/master/examples/ci-cd/) (coming soon)
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var path = require("path");
4
+ module.exports = {
5
+ email: "jon.doe@example.com",
6
+ configDir: path.join(__dirname, "acme"),
7
+ srv: "/srv/www/",
8
+ api: "/srv/api/",
9
+ proxy: {
10
+ "example.com": "http://localhost:4080",
11
+ "*.example.com": "http://localhost:4080"
12
+ },
13
+
14
+ // DNS-01 challenges only
15
+ challenges: {
16
+ "*.example.com": require("acme-dns-01-YOUR_DNS_HOST").create({
17
+ token: "xxxx"
18
+ })
19
+ }
20
+ };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ require("./")
4
+ .init(initialize)
5
+ .serve(worker)
6
+ .master(function() {
7
+ console.log("Hello from master");
8
+ });
9
+
10
+ function initialize() {
11
+ var pkg = require("./package.json");
12
+ var config = {
13
+ package: {
14
+ name: "Greenlock_Express_Demo",
15
+ version: pkg.version,
16
+ author: pkg.author
17
+ },
18
+ staging: true,
19
+ cluster: true,
20
+
21
+ notify: function(ev, params) {
22
+ console.info(ev, params);
23
+ }
24
+ };
25
+ return config;
26
+ }
27
+
28
+ function worker(glx) {
29
+ console.info();
30
+ console.info("Hello from worker #" + glx.id());
31
+
32
+ glx.serveApp(function(req, res) {
33
+ res.end("Hello, Encrypted World!");
34
+ });
35
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "cluster-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var express = require("express");
4
+ var app = express();
5
+
6
+ app.use("/", function(req, res) {
7
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
8
+ res.end("Hello, World!\n\n💚 🔒.js");
9
+ });
10
+
11
+ // DO NOT DO app.listen() unless we're testing this directly
12
+ if (require.main === module) {
13
+ app.listen(3000);
14
+ }
15
+
16
+ // Instead do export the app:
17
+ module.exports = app;
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "express-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "http-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "http-proxy-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "http2-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "https1-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,22 @@
1
+ # Quick Start for Let's Encrypt with Node.js
2
+
3
+ ```js
4
+ npm install --save greenlock-express
5
+ ```
6
+
7
+ Manage via API or the config file:
8
+
9
+ `~/.config/greenlock/manage.json`: (default filesystem config)
10
+
11
+ ```json
12
+ {
13
+ "subscriberEmail": "letsencrypt-test@therootcompany.com",
14
+ "agreeToTerms": true,
15
+ "sites": {
16
+ "example.com": {
17
+ "subject": "example.com",
18
+ "altnames": ["example.com", "www.example.com"]
19
+ }
20
+ }
21
+ }
22
+ ```
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "quickstart-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "socket-io-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "websockets-example",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "start": "node server.js"
9
+ },
10
+ "author": "John Doe <j.doe@example.com> (https://example.com/)",
11
+ "license": "ISC"
12
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ require("./lib/compat");
4
+ var cluster = require("cluster");
5
+
6
+ // Greenlock Express
7
+ var GLE = module.exports;
8
+
9
+ // Node's cluster is awesome, because it encourages writing scalable services.
10
+ //
11
+ // The point of this provide an API that is consistent between single-process
12
+ // and multi-process services so that beginners can more easily take advantage
13
+ // of what cluster has to offer.
14
+ //
15
+ // This API provides just enough abstraction to make it easy, but leaves just
16
+ // enough hoopla so that there's not a large gap in understanding what happens
17
+ // under the hood. That's the hope, anyway.
18
+
19
+ GLE.init = function(fn) {
20
+ // See https://git.coolaj86.com/coolaj86/greenlock-express.js/issues/80
21
+ if (fn && false !== fn.cluster && cluster.isWorker) {
22
+ // ignore the init function and launch the worker
23
+ return require("./worker.js").create();
24
+ }
25
+
26
+ var opts;
27
+ if ("function" === typeof fn) {
28
+ opts = fn();
29
+ } else if ("object" === typeof fn) {
30
+ opts = fn;
31
+ }
32
+ if (!opts || "object" !== typeof opts) {
33
+ throw new Error("the `Greenlock.init(fn)` function should return an object `{ packageRoot, cluster }`");
34
+ }
35
+
36
+ // just for ironic humor
37
+ ["cloudnative", "cloudscale", "webscale", "distributed", "blockchain"].forEach(function(k) {
38
+ if (opts[k]) {
39
+ opts.cluster = true;
40
+ }
41
+ });
42
+
43
+ if (opts.cluster) {
44
+ return require("./master.js").create(opts);
45
+ }
46
+
47
+ return require("./single.js").create(opts);
48
+ };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ module.exports.create = function(opts) {
4
+ var Greenlock = require("@root/greenlock");
5
+ //var Init = require("@root/greenlock/lib/init.js");
6
+ var greenlock = opts.greenlock;
7
+
8
+ /*
9
+ if (!greenlock && opts.packageRoot) {
10
+ try {
11
+ greenlock = require(path.resolve(opts.packageRoot, "greenlock.js"));
12
+ } catch (e) {
13
+ if ("MODULE_NOT_FOUND" !== e.code) {
14
+ throw e;
15
+ }
16
+ }
17
+ }
18
+ */
19
+
20
+ if (!greenlock) {
21
+ //opts = Init._init(opts);
22
+ greenlock = Greenlock.create(opts);
23
+ }
24
+ opts.packageAgent = addGreenlockAgent(opts);
25
+
26
+ try {
27
+ if (opts.notify) {
28
+ greenlock._defaults.notify = opts.notify;
29
+ }
30
+ } catch (e) {
31
+ console.error("Developer Error: notify not attached correctly");
32
+ }
33
+
34
+ // re-export as top-level function to simplify rpc with workers
35
+ greenlock.getAcmeHttp01ChallengeResponse = function(opts) {
36
+ return greenlock.challenges.get(opts);
37
+ };
38
+
39
+ greenlock._find({}).then(function(sites) {
40
+ if (sites.length <= 0) {
41
+ console.warn("Warning: `find({})` returned 0 sites.");
42
+ console.warn(" Does `" + greenlock.manager._modulename + "` implement `find({})`?");
43
+ console.warn(" Did you add sites?");
44
+ console.warn(" npx greenlock add --subject example.com --altnames example.com");
45
+ return;
46
+ }
47
+ // console.info("Ready to Serve:");
48
+
49
+ var max = 3;
50
+ if (sites.length >= 1) {
51
+ sites.slice(0, max).forEach(function(site) {
52
+ // console.info("\t", site.altnames.join(" "));
53
+ });
54
+ }
55
+ if (sites.length > max) {
56
+ // console.info("and %d others", sites.length - max);
57
+ }
58
+ });
59
+
60
+ return greenlock;
61
+ };
62
+
63
+ function addGreenlockAgent(opts) {
64
+ // Add greenlock as part of Agent, unless this is greenlock
65
+ var packageAgent = opts.packageAgent || "";
66
+ if (!/greenlock(-express|-pro)?/i.test(packageAgent)) {
67
+ var pkg = require("./package.json");
68
+ packageAgent += " Greenlock_Express/" + pkg.version;
69
+ }
70
+
71
+ return packageAgent.trim();
72
+ }