@atelic-action/ui 3.15.0 → 3.16.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 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 emails that may receive a link. Taking an address off, then redeploying, refuses its outstanding link and ends its session |
277
+ | `GATE_ALLOWLIST` | all three | Comma separated emails that may receive a link, or a whole domain as `@example.com`, which admits every address on it. 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) |
@@ -2,7 +2,11 @@
2
2
  * How the gate reads its settings from the environment. Shared by the two
3
3
  * sign in functions and the middleware, so each reads a value the same way.
4
4
  */
5
- /** Whether an address is on the comma separated allowlist. */
5
+ /**
6
+ * Whether an address is on the comma separated allowlist. An entry is an
7
+ * address, or a whole domain written as `@example.com`, which admits every
8
+ * address on it (the business's own people, whoever the page is forwarded to).
9
+ */
6
10
  export declare function isAllowed(email: string, allowlist: string | undefined): boolean;
7
11
  /**
8
12
  * A setting that has to be a positive, finite number, or its default. A
@@ -2,15 +2,24 @@
2
2
  * How the gate reads its settings from the environment. Shared by the two
3
3
  * sign in functions and the middleware, so each reads a value the same way.
4
4
  */
5
- /** Whether an address is on the comma separated allowlist. */
5
+ /**
6
+ * Whether an address is on the comma separated allowlist. An entry is an
7
+ * address, or a whole domain written as `@example.com`, which admits every
8
+ * address on it (the business's own people, whoever the page is forwarded to).
9
+ */
6
10
  export function isAllowed(email, allowlist) {
7
11
  const wanted = email.trim().toLowerCase();
8
- if (!wanted)
12
+ // A domain entry only admits one plain address (one `@`, a local part, no
13
+ // whitespace or list and quoting characters), so a crafted string such as
14
+ // `a@evil.example,b@widget.example` can never ride a domain match into a send.
15
+ const plain = /^[^@\s,;<>()"\\]+@[^@\s,;<>()"\\]+$/.test(wanted);
16
+ if (!plain)
9
17
  return false;
18
+ const domain = wanted.slice(wanted.indexOf("@"));
10
19
  return (allowlist ?? "")
11
20
  .split(",")
12
21
  .map((entry) => entry.trim().toLowerCase())
13
- .includes(wanted);
22
+ .some((entry) => entry === wanted || (entry.length > 1 && entry === domain));
14
23
  }
15
24
  /**
16
25
  * A setting that has to be a positive, finite number, or its default. A
@@ -8,7 +8,7 @@
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 emails allowed to receive a link
11
+ * - GATE_ALLOWLIST comma separated emails allowed to receive a link, or a whole domain as @example.com
12
12
  * - RESEND_API_KEY sending only Resend key
13
13
  * - GATE_FROM sender display name (optional)
14
14
  * - GATE_SUBJECT email subject (optional)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atelic-action/ui",
3
- "version": "3.15.0",
3
+ "version": "3.16.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",
@@ -15,7 +15,7 @@ export interface WriteupPerson {
15
15
  /**
16
16
  * The sign off a printed artifact closes on: the script line, then the person
17
17
  * lockup, the photo beside the name, the role, and the address
18
- * (Brand/voice.md, Pitch Surfaces 9). The documents in @atelic-action/artifact
18
+ * (Brand/VOICE.md, Pitch Surfaces 9). The documents in @atelic-action/artifact
19
19
  * (the writeup, the read, the monthly page, the note) all wear it, so its
20
20
  * styles live in the base sheet chain
21
21
  * (styles/artifact.css); its container sets the type size and the color.
@@ -3,14 +3,23 @@
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. */
6
+ /**
7
+ * Whether an address is on the comma separated allowlist. An entry is an
8
+ * address, or a whole domain written as `@example.com`, which admits every
9
+ * address on it (the business's own people, whoever the page is forwarded to).
10
+ */
7
11
  export function isAllowed(email: string, allowlist: string | undefined): boolean {
8
12
  const wanted = email.trim().toLowerCase();
9
- if (!wanted) return false;
13
+ // A domain entry only admits one plain address (one `@`, a local part, no
14
+ // whitespace or list and quoting characters), so a crafted string such as
15
+ // `a@evil.example,b@widget.example` can never ride a domain match into a send.
16
+ const plain = /^[^@\s,;<>()"\\]+@[^@\s,;<>()"\\]+$/.test(wanted);
17
+ if (!plain) return false;
18
+ const domain = wanted.slice(wanted.indexOf("@"));
10
19
  return (allowlist ?? "")
11
20
  .split(",")
12
21
  .map((entry) => entry.trim().toLowerCase())
13
- .includes(wanted);
22
+ .some((entry) => entry === wanted || (entry.length > 1 && entry === domain));
14
23
  }
15
24
 
16
25
  /**
@@ -8,7 +8,7 @@
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 emails allowed to receive a link
11
+ * - GATE_ALLOWLIST comma separated emails allowed to receive a link, or a whole domain as @example.com
12
12
  * - RESEND_API_KEY sending only Resend key
13
13
  * - GATE_FROM sender display name (optional)
14
14
  * - GATE_SUBJECT email subject (optional)