@peerbit/server 5.8.2 → 5.8.3
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/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +7 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/domain.d.ts +1 -1
- package/dist/src/domain.d.ts.map +1 -1
- package/dist/src/domain.js +10 -2
- package/dist/src/domain.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/cli.ts +7 -2
- package/src/domain.ts +13 -1
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -218,6 +218,11 @@ export const cli = async (args?: string[]) => {
|
|
|
218
218
|
describe:
|
|
219
219
|
"Setup a testing domain with SSL (no guarantess on how long the domain will be available)",
|
|
220
220
|
builder: {
|
|
221
|
+
email: {
|
|
222
|
+
describe: "Email for Lets security messages",
|
|
223
|
+
type: "string",
|
|
224
|
+
demandOption: true,
|
|
225
|
+
},
|
|
221
226
|
outdir: {
|
|
222
227
|
describe: "Output path for Nginx config",
|
|
223
228
|
type: "string",
|
|
@@ -232,7 +237,7 @@ export const cli = async (args?: string[]) => {
|
|
|
232
237
|
},
|
|
233
238
|
handler: async (args) => {
|
|
234
239
|
const domain = await createTestDomain();
|
|
235
|
-
await startCertbot(domain, args.wait);
|
|
240
|
+
await startCertbot(domain, args.email, args.wait);
|
|
236
241
|
exit();
|
|
237
242
|
},
|
|
238
243
|
})
|
|
@@ -300,7 +305,7 @@ export const cli = async (args?: string[]) => {
|
|
|
300
305
|
}
|
|
301
306
|
: undefined,
|
|
302
307
|
});
|
|
303
|
-
await startCertbot(args.domain, args.wait);
|
|
308
|
+
await startCertbot(args.domain, args.email, args.wait);
|
|
304
309
|
exit();
|
|
305
310
|
},
|
|
306
311
|
})
|
package/src/domain.ts
CHANGED
|
@@ -121,11 +121,23 @@ export const createTestDomain = async () => {
|
|
|
121
121
|
return domain;
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
+
const validateEmail = (email: any) => {
|
|
125
|
+
return String(email)
|
|
126
|
+
.toLowerCase()
|
|
127
|
+
.match(
|
|
128
|
+
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
124
132
|
export const startCertbot = async (
|
|
125
133
|
domain: string,
|
|
134
|
+
email: string,
|
|
126
135
|
waitForUp = false,
|
|
127
136
|
dockerProcessName = "nginx-certbot",
|
|
128
137
|
): Promise<void> => {
|
|
138
|
+
if (!validateEmail(email)) {
|
|
139
|
+
throw new Error("Email for SSL renenewal is invalid");
|
|
140
|
+
}
|
|
129
141
|
const { installDocker, startContainer } = await import("./docker.js");
|
|
130
142
|
|
|
131
143
|
const nginxConfigPath = await getNginxFolderPath();
|
|
@@ -141,7 +153,7 @@ export const startCertbot = async (
|
|
|
141
153
|
// copy ui from node_modules to home for permission reasons (volume will not work otherwise)
|
|
142
154
|
const certbotDockerCommand = `cp -r ${uiPath} $(pwd)/ui && docker pull jonasal/nginx-certbot:latest && docker run -d --net=host \
|
|
143
155
|
--restart unless-stopped \
|
|
144
|
-
${isTest ? "--env STAGING=1" : ""}\
|
|
156
|
+
--env CERTBOT_EMAIL=${email} ${isTest ? "--env STAGING=1" : ""}\
|
|
145
157
|
-v $(pwd)/nginx_secrets:/etc/letsencrypt \
|
|
146
158
|
-v ${nginxConfigPath}:/etc/nginx/user_conf.d:ro \
|
|
147
159
|
-v $(pwd)/ui:/usr/share/nginx/html:ro \
|