@aeolus-fleet/common 0.25.1 → 0.25.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/rules/index.d.ts +1 -0
- package/dist/rules/index.js +1 -0
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/plain-http.d.ts +8 -0
- package/dist/rules/plain-http.js +20 -0
- package/dist/rules/plain-http.js.map +1 -0
- package/dist/rules/sign-in.d.ts +9 -3
- package/dist/rules/sign-in.js +14 -3
- package/dist/rules/sign-in.js.map +1 -1
- package/dist/schemas/console.d.ts +1 -1
- package/dist/schemas/console.js +1 -1
- package/dist/schemas/console.js.map +1 -1
- package/package.json +1 -1
package/dist/rules/index.d.ts
CHANGED
package/dist/rules/index.js
CHANGED
package/dist/rules/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain http beyond localhost: the console's session cookie is Secure, so a
|
|
3
|
+
* browser drops it there, and passwords and crew tokens travel in clear
|
|
4
|
+
* text. Browsers treat localhost, names under it and loopback addresses as
|
|
5
|
+
* secure contexts, so plain http there is fine.
|
|
6
|
+
*/
|
|
7
|
+
/** The startup warning for a setting holding a plain http URL beyond localhost; undefined when it holds none. */
|
|
8
|
+
export declare function plainHttpWarning(setting: string, url: string): string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain http beyond localhost: the console's session cookie is Secure, so a
|
|
3
|
+
* browser drops it there, and passwords and crew tokens travel in clear
|
|
4
|
+
* text. Browsers treat localhost, names under it and loopback addresses as
|
|
5
|
+
* secure contexts, so plain http there is fine.
|
|
6
|
+
*/
|
|
7
|
+
const LOOPBACK_IPV4 = /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
8
|
+
/** Whether a browser treats this host as secure over plain http. */
|
|
9
|
+
function isLocalhost(hostname) {
|
|
10
|
+
return hostname === 'localhost' || hostname.endsWith('.localhost') || LOOPBACK_IPV4.test(hostname) || hostname === '[::1]';
|
|
11
|
+
}
|
|
12
|
+
/** The startup warning for a setting holding a plain http URL beyond localhost; undefined when it holds none. */
|
|
13
|
+
export function plainHttpWarning(setting, url) {
|
|
14
|
+
const parsed = URL.parse(url);
|
|
15
|
+
if (parsed?.protocol !== 'http:' || isLocalhost(parsed.hostname)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return `${setting} is plain http on ${parsed.hostname}: browsers drop the Secure session cookie, so console sign-in fails, and passwords and crew tokens travel in clear text. Put a TLS proxy in front and use https (README, "Beyond localhost").`;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=plain-http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plain-http.js","sourceRoot":"","sources":["../../src/rules/plain-http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,aAAa,GAAG,kCAAkC,CAAC;AAEzD,oEAAoE;AACpE,SAAS,WAAW,CAAC,QAAgB;IACnC,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,QAAQ,KAAK,OAAO,CAAC;AAC7H,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,GAAW;IAC3D,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,MAAM,EAAE,QAAQ,KAAK,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,OAAO,qBAAqB,MAAM,CAAC,QAAQ,+LAA+L,CAAC;AACvP,CAAC"}
|
package/dist/rules/sign-in.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/** The operator's email: at most 254 characters, the longest address mail carries. */
|
|
2
2
|
export declare const OPERATOR_EMAIL_MAX_LENGTH = 254;
|
|
3
|
+
/** The bound only keeps an absurd input from reaching the password hash. */
|
|
4
|
+
export declare const OPERATOR_PASSWORD_MAX_LENGTH = 1024;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
+
* A new operator password (fleet:init, operator:reset-password) is at least
|
|
7
|
+
* this long. Sign-in checks no minimum, so a shorter password set before
|
|
8
|
+
* still signs in.
|
|
6
9
|
*/
|
|
7
|
-
export declare const
|
|
10
|
+
export declare const OPERATOR_PASSWORD_MIN_LENGTH = 12;
|
|
8
11
|
export declare const EMAIL_REQUIRED = "Enter your email";
|
|
9
12
|
export declare const EMAIL_TOO_LONG: string;
|
|
10
13
|
export declare const PASSWORD_REQUIRED = "Enter your password";
|
|
11
14
|
export declare const PASSWORD_TOO_LONG: string;
|
|
15
|
+
export declare const PASSWORD_TOO_SHORT: string;
|
|
12
16
|
/** What is wrong with a sign-in email, whitespace around it dropped; undefined when nothing is. */
|
|
13
17
|
export declare function signInEmailProblem(email: string): string | undefined;
|
|
14
18
|
/** What is wrong with a sign-in password, taken exactly as typed; undefined when nothing is. */
|
|
15
19
|
export declare function signInPasswordProblem(password: string): string | undefined;
|
|
20
|
+
/** What is wrong with a new operator password, taken exactly as typed; undefined when nothing is. */
|
|
21
|
+
export declare function newOperatorPasswordProblem(password: string): string | undefined;
|
package/dist/rules/sign-in.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/** The operator's email: at most 254 characters, the longest address mail carries. */
|
|
2
2
|
export const OPERATOR_EMAIL_MAX_LENGTH = 254;
|
|
3
|
+
/** The bound only keeps an absurd input from reaching the password hash. */
|
|
4
|
+
export const OPERATOR_PASSWORD_MAX_LENGTH = 1024;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
+
* A new operator password (fleet:init, operator:reset-password) is at least
|
|
7
|
+
* this long. Sign-in checks no minimum, so a shorter password set before
|
|
8
|
+
* still signs in.
|
|
6
9
|
*/
|
|
7
|
-
export const
|
|
10
|
+
export const OPERATOR_PASSWORD_MIN_LENGTH = 12;
|
|
8
11
|
export const EMAIL_REQUIRED = 'Enter your email';
|
|
9
12
|
export const EMAIL_TOO_LONG = `Use an email of at most ${String(OPERATOR_EMAIL_MAX_LENGTH)} characters`;
|
|
10
13
|
export const PASSWORD_REQUIRED = 'Enter your password';
|
|
11
14
|
export const PASSWORD_TOO_LONG = `Use a password of at most ${String(OPERATOR_PASSWORD_MAX_LENGTH)} characters`;
|
|
15
|
+
export const PASSWORD_TOO_SHORT = `Use a password of at least ${String(OPERATOR_PASSWORD_MIN_LENGTH)} characters`;
|
|
12
16
|
/** What is wrong with a sign-in email, whitespace around it dropped; undefined when nothing is. */
|
|
13
17
|
export function signInEmailProblem(email) {
|
|
14
18
|
const trimmed = email.trim();
|
|
@@ -24,4 +28,11 @@ export function signInPasswordProblem(password) {
|
|
|
24
28
|
}
|
|
25
29
|
return password.length > OPERATOR_PASSWORD_MAX_LENGTH ? PASSWORD_TOO_LONG : undefined;
|
|
26
30
|
}
|
|
31
|
+
/** What is wrong with a new operator password, taken exactly as typed; undefined when nothing is. */
|
|
32
|
+
export function newOperatorPasswordProblem(password) {
|
|
33
|
+
if (password.length < OPERATOR_PASSWORD_MIN_LENGTH) {
|
|
34
|
+
return PASSWORD_TOO_SHORT;
|
|
35
|
+
}
|
|
36
|
+
return password.length > OPERATOR_PASSWORD_MAX_LENGTH ? PASSWORD_TOO_LONG : undefined;
|
|
37
|
+
}
|
|
27
38
|
//# sourceMappingURL=sign-in.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../src/rules/sign-in.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../src/rules/sign-in.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,2BAA2B,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC;AACxG,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,6BAA6B,MAAM,CAAC,4BAA4B,CAAC,aAAa,CAAC;AAChH,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,MAAM,CAAC,4BAA4B,CAAC,aAAa,CAAC;AAElH,mGAAmG;AACnG,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,GAAG,yBAAyB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,GAAG,4BAA4B,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;AACxF,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,0BAA0B,CAAC,QAAgB;IACzD,IAAI,QAAQ,CAAC,MAAM,GAAG,4BAA4B,EAAE,CAAC;QACnD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,GAAG,4BAA4B,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;AACxF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/** One @ with something on each side, and no whitespace. */
|
|
3
3
|
export declare const OPERATOR_EMAIL_PATTERN: RegExp;
|
|
4
|
-
export { OPERATOR_EMAIL_MAX_LENGTH, OPERATOR_PASSWORD_MAX_LENGTH } from '../rules/sign-in.js';
|
|
4
|
+
export { newOperatorPasswordProblem, OPERATOR_EMAIL_MAX_LENGTH, OPERATOR_PASSWORD_MAX_LENGTH } from '../rules/sign-in.js';
|
|
5
5
|
/**
|
|
6
6
|
* Input of `console.signIn`: the operator's email and password. Whitespace
|
|
7
7
|
* around the email is dropped; the password is taken exactly as typed. The
|
package/dist/schemas/console.js
CHANGED
|
@@ -4,7 +4,7 @@ import { idSchema } from '../ids/index.js';
|
|
|
4
4
|
import { EMAIL_REQUIRED, EMAIL_TOO_LONG, OPERATOR_EMAIL_MAX_LENGTH, OPERATOR_PASSWORD_MAX_LENGTH, PASSWORD_REQUIRED, PASSWORD_TOO_LONG } from '../rules/sign-in.js';
|
|
5
5
|
/** One @ with something on each side, and no whitespace. */
|
|
6
6
|
export const OPERATOR_EMAIL_PATTERN = /^[^\s@]+@[^\s@]+$/;
|
|
7
|
-
export { OPERATOR_EMAIL_MAX_LENGTH, OPERATOR_PASSWORD_MAX_LENGTH } from '../rules/sign-in.js';
|
|
7
|
+
export { newOperatorPasswordProblem, OPERATOR_EMAIL_MAX_LENGTH, OPERATOR_PASSWORD_MAX_LENGTH } from '../rules/sign-in.js';
|
|
8
8
|
/**
|
|
9
9
|
* Input of `console.signIn`: the operator's email and password. Whitespace
|
|
10
10
|
* around the email is dropped; the password is taken exactly as typed. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/schemas/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpK,4DAA4D;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/schemas/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,yBAAyB,EAAE,4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