@atelic-action/ui 3.16.0 → 3.17.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 +1 -1
- package/dist/gate/config.d.ts +7 -3
- package/dist/gate/config.js +26 -6
- package/dist/gate/request-link.js +2 -1
- package/package.json +1 -1
- package/src/gate/config.ts +25 -6
- package/src/gate/request-link.ts +2 -1
package/README.md
CHANGED
|
@@ -274,7 +274,7 @@ export const POST = createRequestLink({ noun: "preview" });
|
|
|
274
274
|
| Env | Read by | What it does |
|
|
275
275
|
|---|---|---|
|
|
276
276
|
| `GATE_SESSION_SECRET` | all three | The signing secret, and the switch: unset, the gate is off. Use 32 random bytes or more |
|
|
277
|
-
| `GATE_ALLOWLIST` | all three | Comma separated
|
|
277
|
+
| `GATE_ALLOWLIST` | all three | Comma separated entries that may receive a link. An address matches itself exactly; the business's domain, written `example.com` or `@example.com`, admits every address on it but none on its subdomains. Case never matters, and an empty entry or a word with no dot matches nothing. Taking an entry off, then redeploying, refuses its outstanding links and ends their sessions |
|
|
278
278
|
| `RESEND_API_KEY` | request link | The sending only key the link goes out on |
|
|
279
279
|
| `GATE_BASE_URL` | request link | The host the link points at; a bare host is read as https, and plain http is refused unless it is local. Unset, production uses the project's own domain and a preview uses the deployment it was asked on |
|
|
280
280
|
| `GATE_FROM`, `GATE_SUBJECT`, `GATE_LINK_TTL_MIN` | request link | Sender, subject, and link lifetime in minutes (15, a day at most) |
|
package/dist/gate/config.d.ts
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
* sign in functions and the middleware, so each reads a value the same way.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Whether an address is on the comma separated allowlist. An entry is
|
|
7
|
-
* address,
|
|
8
|
-
*
|
|
6
|
+
* Whether an address is on the comma separated allowlist. An entry is either
|
|
7
|
+
* a full address, which matches that address exactly, or the business's
|
|
8
|
+
* domain, written bare (`example.com`) or with a leading at (`@example.com`),
|
|
9
|
+
* which admits every address whose part after the `@` is that domain (the
|
|
10
|
+
* business's own people, whoever the page is forwarded to). A domain never
|
|
11
|
+
* admits its subdomains, and everything is compared case folded. An entry
|
|
12
|
+
* that is empty, or is no address and holds no dot, matches nothing.
|
|
9
13
|
*/
|
|
10
14
|
export declare function isAllowed(email: string, allowlist: string | undefined): boolean;
|
|
11
15
|
/**
|
package/dist/gate/config.js
CHANGED
|
@@ -3,23 +3,43 @@
|
|
|
3
3
|
* sign in functions and the middleware, so each reads a value the same way.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Whether an address is on the comma separated allowlist. An entry is
|
|
7
|
-
* address,
|
|
8
|
-
*
|
|
6
|
+
* Whether an address is on the comma separated allowlist. An entry is either
|
|
7
|
+
* a full address, which matches that address exactly, or the business's
|
|
8
|
+
* domain, written bare (`example.com`) or with a leading at (`@example.com`),
|
|
9
|
+
* which admits every address whose part after the `@` is that domain (the
|
|
10
|
+
* business's own people, whoever the page is forwarded to). A domain never
|
|
11
|
+
* admits its subdomains, and everything is compared case folded. An entry
|
|
12
|
+
* that is empty, or is no address and holds no dot, matches nothing.
|
|
9
13
|
*/
|
|
10
14
|
export function isAllowed(email, allowlist) {
|
|
11
15
|
const wanted = email.trim().toLowerCase();
|
|
12
|
-
//
|
|
16
|
+
// Only one plain address is ever admitted (one `@`, a local part, no
|
|
13
17
|
// whitespace or list and quoting characters), so a crafted string such as
|
|
14
18
|
// `a@evil.example,b@widget.example` can never ride a domain match into a send.
|
|
15
19
|
const plain = /^[^@\s,;<>()"\\]+@[^@\s,;<>()"\\]+$/.test(wanted);
|
|
16
20
|
if (!plain)
|
|
17
21
|
return false;
|
|
18
|
-
const domain = wanted.slice(wanted.
|
|
22
|
+
const domain = wanted.slice(wanted.lastIndexOf("@") + 1);
|
|
19
23
|
return (allowlist ?? "")
|
|
20
24
|
.split(",")
|
|
21
25
|
.map((entry) => entry.trim().toLowerCase())
|
|
22
|
-
.some((entry) =>
|
|
26
|
+
.some((entry) => {
|
|
27
|
+
if (entry.length === 0)
|
|
28
|
+
return false;
|
|
29
|
+
const named = domainOf(entry);
|
|
30
|
+
return named === undefined ? entry === wanted : named === domain;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The domain a domain entry names, or undefined when the entry is a full
|
|
35
|
+
* address. A domain entry has to look like one (labels joined by dots), so a
|
|
36
|
+
* stray word or a bare `@` names a domain no address can be on.
|
|
37
|
+
*/
|
|
38
|
+
function domainOf(entry) {
|
|
39
|
+
const bare = entry.startsWith("@") ? entry.slice(1) : entry;
|
|
40
|
+
if (bare.includes("@"))
|
|
41
|
+
return undefined;
|
|
42
|
+
return /^[^.\s@]+(\.[^.\s@]+)+$/.test(bare) ? bare : "";
|
|
23
43
|
}
|
|
24
44
|
/**
|
|
25
45
|
* A setting that has to be a positive, finite number, or its default. A
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Env (set on the Vercel project):
|
|
10
10
|
* - GATE_SESSION_SECRET signing secret; also the gate's on and off switch
|
|
11
|
-
* - GATE_ALLOWLIST comma separated
|
|
11
|
+
* - GATE_ALLOWLIST comma separated entries allowed to receive a link: an address,
|
|
12
|
+
* or the business's domain (example.com or @example.com)
|
|
12
13
|
* - RESEND_API_KEY sending only Resend key
|
|
13
14
|
* - GATE_FROM sender display name (optional)
|
|
14
15
|
* - GATE_SUBJECT email subject (optional)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atelic-action/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Shared UI for the Atelic templates: site chrome, base styles, the component library, the access gate, and the app shell they install",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
package/src/gate/config.ts
CHANGED
|
@@ -4,22 +4,41 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Whether an address is on the comma separated allowlist. An entry is
|
|
8
|
-
* address,
|
|
9
|
-
*
|
|
7
|
+
* Whether an address is on the comma separated allowlist. An entry is either
|
|
8
|
+
* a full address, which matches that address exactly, or the business's
|
|
9
|
+
* domain, written bare (`example.com`) or with a leading at (`@example.com`),
|
|
10
|
+
* which admits every address whose part after the `@` is that domain (the
|
|
11
|
+
* business's own people, whoever the page is forwarded to). A domain never
|
|
12
|
+
* admits its subdomains, and everything is compared case folded. An entry
|
|
13
|
+
* that is empty, or is no address and holds no dot, matches nothing.
|
|
10
14
|
*/
|
|
11
15
|
export function isAllowed(email: string, allowlist: string | undefined): boolean {
|
|
12
16
|
const wanted = email.trim().toLowerCase();
|
|
13
|
-
//
|
|
17
|
+
// Only one plain address is ever admitted (one `@`, a local part, no
|
|
14
18
|
// whitespace or list and quoting characters), so a crafted string such as
|
|
15
19
|
// `a@evil.example,b@widget.example` can never ride a domain match into a send.
|
|
16
20
|
const plain = /^[^@\s,;<>()"\\]+@[^@\s,;<>()"\\]+$/.test(wanted);
|
|
17
21
|
if (!plain) return false;
|
|
18
|
-
const domain = wanted.slice(wanted.
|
|
22
|
+
const domain = wanted.slice(wanted.lastIndexOf("@") + 1);
|
|
19
23
|
return (allowlist ?? "")
|
|
20
24
|
.split(",")
|
|
21
25
|
.map((entry) => entry.trim().toLowerCase())
|
|
22
|
-
.some((entry) =>
|
|
26
|
+
.some((entry) => {
|
|
27
|
+
if (entry.length === 0) return false;
|
|
28
|
+
const named = domainOf(entry);
|
|
29
|
+
return named === undefined ? entry === wanted : named === domain;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The domain a domain entry names, or undefined when the entry is a full
|
|
35
|
+
* address. A domain entry has to look like one (labels joined by dots), so a
|
|
36
|
+
* stray word or a bare `@` names a domain no address can be on.
|
|
37
|
+
*/
|
|
38
|
+
function domainOf(entry: string): string | undefined {
|
|
39
|
+
const bare = entry.startsWith("@") ? entry.slice(1) : entry;
|
|
40
|
+
if (bare.includes("@")) return undefined;
|
|
41
|
+
return /^[^.\s@]+(\.[^.\s@]+)+$/.test(bare) ? bare : "";
|
|
23
42
|
}
|
|
24
43
|
|
|
25
44
|
/**
|
package/src/gate/request-link.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Env (set on the Vercel project):
|
|
10
10
|
* - GATE_SESSION_SECRET signing secret; also the gate's on and off switch
|
|
11
|
-
* - GATE_ALLOWLIST comma separated
|
|
11
|
+
* - GATE_ALLOWLIST comma separated entries allowed to receive a link: an address,
|
|
12
|
+
* or the business's domain (example.com or @example.com)
|
|
12
13
|
* - RESEND_API_KEY sending only Resend key
|
|
13
14
|
* - GATE_FROM sender display name (optional)
|
|
14
15
|
* - GATE_SUBJECT email subject (optional)
|