@vllnt/convex-suppression 0.2.0-canary.4bb2fbc → 0.2.0-canary.f851df9

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/CHANGELOG.md CHANGED
@@ -4,92 +4,79 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [0.2.0] - Unreleased
7
+ ## [0.2.0] - 2026-11-28
8
8
 
9
9
  ### Added
10
10
 
11
- - The npm package now ships `docs/*.md`, `CHANGELOG.md` and `llms.txt`, so
11
+ - The npm package now ships `docs/API.md`, `CHANGELOG.md` and `llms.txt`, so
12
12
  coding agents can read docs that match the installed version from
13
- `node_modules/@vllnt/convex-suppression/`. `llms.txt` links to bundled files
14
- with `./` paths. A test fails when a required file is missing from the
15
- tarball.
13
+ `node_modules/@vllnt/convex-suppression/`. `llms.txt` links to them with `./`
14
+ paths.
16
15
 
17
16
  ### Changed
18
17
 
19
18
  - **Breaking:** `suppress` and `recordOptIn` now throw
20
- `ConvexError({ code: "INVALID_ARGUMENT", field })` for a `contactHash`,
21
- `channel`, `listKey` or `source` over 256 UTF-8 bytes, and for an opt-in
22
- `proof` over 16384 UTF-8 bytes of its JSON form (`field: "proof"`). Sizes
23
- count UTF-8 bytes, not characters: `"é"` is 2 bytes. Hash and normalize each
24
- contact to a short fixed-length key such as a hex SHA-256 (64 bytes), keep
25
- `proof` small, and store large evidence in the host and pass a reference.
26
- Rows stored earlier with longer keys stay readable through `isSuppressed`,
27
- `isEligible` and `getOptInProof`; `suppress` or `recordOptIn` on such a key
28
- now throws and leaves the row unchanged; `unsuppress` is not size-checked and
29
- still removes it.
30
- - Removed the `by_hash` index; it was unused and a prefix of `by_hash_channel`.
31
- One less index entry written per suppression and less index storage. No
32
- migration is needed; the next deploy drops the index.
33
- - Release automation: pinned actions, least-privilege permissions, npm trusted
34
- publishing with provenance; `@latest` is published only from a `vX.Y.Z` tag on
35
- `main`.
36
- - Every push to `main` publishes a `@canary` build of that commit; the opt-in
37
- repository-variable gate is removed.
38
- - The README install command now installs the stable release.
39
- - Internal: CI and publish set up pnpm through Corepack, so every action in
40
- `ci.yml` and `publish.yml` is GitHub's own and pinned to a commit; the
41
- privacy guard pins its GitHub actions to commits; CI cancels only superseded
42
- pull request runs; there is no version-update bot.
19
+ `ConvexError({ code: "INVALID_ARGUMENT", field })` for a key over 256 UTF-8
20
+ bytes (`contactHash` or `channel` in `suppress`; `contactHash`, `listKey` or
21
+ `source` in `recordOptIn`), and for an opt-in `proof` over 16384 UTF-8 bytes
22
+ of its JSON form (`field: "proof"`). Sizes count UTF-8 bytes, not characters:
23
+ `"é"` is 2 bytes. Hash and normalize each contact to a short fixed-length key
24
+ such as a hex SHA-256 (64 bytes). Keep `source` a short tag such as
25
+ `"double-opt-in"` and move long text such as a URL into `proof`. Keep `proof`
26
+ small: store large evidence in the host and pass a reference. Rows stored
27
+ earlier with a longer key, or with a `proof` over 16384 bytes, stay readable
28
+ through `isSuppressed`, `isEligible` and `getOptInProof`. `suppress` or
29
+ `recordOptIn` on such a key now throws and leaves the row unchanged;
30
+ `unsuppress` is not size-checked and still removes it. Recording that large
31
+ `proof` again throws; recording a smaller one replaces it.
32
+ - **Breaking:** `suppress` and `recordOptIn` now throw
33
+ `ConvexError({ code: "INVALID_ARGUMENT", field })` for an empty `contactHash`,
34
+ `channel`, `listKey` or `source`; 0.1.0 stored it. Check for empty values
35
+ before calling, and omit `channel` or `listKey` for the global entry instead
36
+ of passing `""`. Rows that 0.1.0 stored with an empty key are kept:
37
+ `isSuppressed` and `getOptInProof` still return them, and `unsuppress` removes
38
+ them.
39
+ - `isEligible` now returns `false` for an empty `contactHash` or `channel`
40
+ (0.1.0 could return `true`), so the send gate fails closed. Pass the real hash
41
+ and the channel you send on.
42
+ - **Breaking:** A `proofValidator` error from `recordOptIn` now rejects the
43
+ returned promise instead of throwing synchronously, as `getOptInProof` already
44
+ did; nothing is written. `await` in a try/catch and `.catch()` on the promise
45
+ both catch it. If you called `recordOptIn` inside a try/catch without `await`,
46
+ add `await` or a `.catch()`.
47
+ - `engines.node` is now `>=20` (was `>=18`), because the lowest supported peer,
48
+ `convex@1.45.0`, needs Node.js 20. Run Node.js 20 or later (22 or later with
49
+ convex 1.49 and newer). The peer `convex` range is unchanged (`^1.45.0`).
50
+ - Every push to `main` now publishes a `@canary` build of that commit; `@latest`
51
+ is published only from a `vX.Y.Z` tag on `main`, with npm provenance.
52
+ - README, `docs/API.md` and `llms.txt` rewritten and checked against the code,
53
+ including behavior that was not documented before: keys match exactly (no
54
+ case, whitespace or plus-address folding), `"*"` as a `channel` or `listKey`
55
+ targets the global entry, `reason: "global"` does not make an entry global,
56
+ and recording an opt-in again without `proof` removes the stored proof. TSDoc
57
+ on every public export. New package description, keywords and homepage
58
+ (`https://oss.vllnt.com/packages/convex-suppression`).
59
+ - Internal: CI, release, test and docs-check tooling; no runtime effect.
60
+
61
+ ### Removed
62
+
63
+ - The unused `by_hash` index on `suppressions`, a prefix of `by_hash_channel`:
64
+ one less index entry written per suppression. No migration is needed; the next
65
+ deploy drops the index.
43
66
 
44
67
  ### Fixed
45
68
 
46
- - `suppress` and `recordOptIn` now throw
47
- `ConvexError({ code: "INVALID_ARGUMENT", field })` for an empty `contactHash`,
48
- `channel`, `listKey` or `source`. `isEligible` previously answered `true` for
49
- an empty `contactHash` or `channel`; it now answers `false`, so the send gate
50
- fails closed. Documented that keys are matched exactly (no case, whitespace or
51
- plus-address normalization; the host normalizes). **Upgrade note:** a
52
- `suppress` or `recordOptIn` call that passed an empty string for one of these
53
- fields succeeded in 0.1.0 and now throws; check for empty values before
54
- calling. Omitting `channel` or `listKey` (global entry) is unaffected.
55
- - The `./test` entry now type-checks for consumers using
56
- `moduleResolution: nodenext` (relative imports use `.js`; Vite client types
57
- are referenced). The README documents the `convex-test` and `vitest`
58
- requirement.
69
+ - The `./test` entry now type-checks under `moduleResolution: nodenext`
70
+ (relative imports use `.js`; Vite client types are referenced). The README
71
+ lists what it needs: `convex-test`, `vitest`, `vite` and `@edge-runtime/vm`.
59
72
  - `register(t)` from `./test` now accepts the host app's
60
73
  `convexTest(hostSchema)`; it was typed against the component's own schema, so
61
74
  any host schema with its own tables failed with TS2345. Types only; no runtime
62
75
  change.
63
76
  - The `proofValidator` example in the `Suppression` JSDoc passed
64
77
  `v.object(...).parse`, which Convex validators do not have; it now shows a
65
- host parser `(unknown) => TProof`.
66
-
67
- ### Documentation
68
-
69
- - README rewritten in the shared @vllnt layout: For coding agents, When to use,
70
- Install, Quick start, API (one row per export), Common tasks, Errors and
71
- fixes, Limits and gotchas, Compatibility, Testing, Security, Related
72
- packages, Contributing, Links, License and the vllnt footer. Badges moved to
73
- the end.
74
- - `docs/API.md` checked against the code: one section per export and per
75
- `Suppression` method, the tables and indexes, and newly documented behavior:
76
- `"*"` as a `channel` or `listKey` targets the global entry, `reason:
77
- "global"` does not make an entry global, recording an opt-in again without
78
- `proof` removes the stored proof, the `proofValidator` return value is what
79
- is stored, an empty `channel` in `isSuppressed` checks only the global
80
- entry, and a `proofValidator` error from `recordOptIn` is a
81
- synchronous throw, not a rejected promise.
82
- - `llms.txt` now has the package summary, When to use, a link to the errors
83
- table and the shared Ecosystem block.
84
- - New `package.json` description and keywords, shared by the README and
85
- `llms.txt`.
86
- - TSDoc summaries on every public export, and
87
- `@see https://oss.vllnt.com/packages/convex-suppression` on `Suppression`.
88
- Comment-only: `dist` changes only in comments and source maps.
89
- - `pnpm test:package` now runs a docs contract test
90
- (`scripts/check-documentation.mjs`) on the installed tarball, and type-checks
91
- every README and `docs/API.md` TypeScript example against it; the README test
92
- example runs under Vitest.
78
+ host parser `(unknown) => TProof`, and the `Parser` TSDoc no longer recommends
79
+ a `convex/values` `.parse`.
93
80
 
94
81
  ## [0.1.0] - 2026-09-01
95
82
 
package/README.md CHANGED
@@ -330,9 +330,9 @@ read `error.data.code` and `error.data.field`.
330
330
 
331
331
  | Code or message | Thrown by | Cause | Fix |
332
332
  | -------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
333
- | `INVALID_ARGUMENT` | `suppress`, `recordOptIn` | `field` names a key that is empty or longer than 256 UTF-8 bytes: `contactHash` or `channel` (`suppress`); `contactHash`, `listKey` or `source` (`recordOptIn`). Or `field` is `proof`, over 16384 UTF-8 bytes of its JSON form (`recordOptIn`) | Check the value before calling. Omit `channel` or `listKey` for the global entry instead of passing `""`. Hash contacts to a short fixed-length key (a hex SHA-256 is 64 bytes); store large proof evidence in your app and pass a reference |
333
+ | `INVALID_ARGUMENT` | `suppress`, `recordOptIn` | `field` names a key that is empty or longer than 256 UTF-8 bytes: `contactHash` or `channel` (`suppress`); `contactHash`, `listKey` or `source` (`recordOptIn`). Or `field` is `proof`, over 16384 UTF-8 bytes of its JSON form (`recordOptIn`) | Check the value before calling. Omit `channel` or `listKey` for the global entry instead of passing `""`. Hash contacts to a short fixed-length key (a hex SHA-256 is 64 bytes). Keep `source` a short tag such as `"double-opt-in"` and move long text such as a URL into `proof`. Store large proof evidence in your app and pass a reference |
334
334
  | Convex argument validation error | any method | An argument has the wrong type, or `reason` is not one of the five `SuppressionReason` values | Pass a `SuppressionReason`; TypeScript catches this at compile time |
335
- | The error your `proofValidator` throws | `recordOptIn` (before the write), `getOptInProof` (on read) | Your parser rejected `proof`. From `recordOptIn` it is a synchronous throw, not a rejected promise: a try/catch around the call catches it (with or without `await`), and a `.catch()` on the returned promise never runs | Fix the proof, or let the parser accept every shape you have stored before |
335
+ | The error your `proofValidator` throws | `recordOptIn` (before the write), `getOptInProof` (on read) | Your parser rejected `proof`. Both methods reject their promise with it (`recordOptIn` writes nothing); neither throws synchronously, so `await` in a try/catch or `.catch()` on the promise catches it | Fix the proof, or let the parser accept every shape you have stored before |
336
336
 
337
337
  These never throw `INVALID_ARGUMENT`: `isEligible` returns `false` for an empty
338
338
  `contactHash` or `channel`. `isSuppressed` returns `null` for an empty
@@ -340,6 +340,9 @@ These never throw `INVALID_ARGUMENT`: `isEligible` returns `false` for an empty
340
340
  returns that entry if one exists, otherwise `null`). `getOptInProof` returns
341
341
  `null` for an empty key and `unsuppress` returns `false`. A missing entry is
342
342
  `null` or `false`, never an error, and a repeated write updates in place.
343
+ This holds for data written by 0.2.0 or later: a row that 0.1.0 stored with an
344
+ empty key is still returned by `isSuppressed` and `getOptInProof`; remove it
345
+ with `unsuppress`.
343
346
 
344
347
  ## Limits and gotchas
345
348
 
@@ -371,15 +374,20 @@ returns that entry if one exists, otherwise `null`). `getOptInProof` returns
371
374
  - An empty `contactHash` or `channel` makes `isEligible` return `false`. For
372
375
  `isSuppressed`, an empty `contactHash` returns `null` (not suppressed), and an
373
376
  empty `channel` checks only the global entry. Use `isEligible` as the gate.
377
+ This holds for data written by 0.2.0 or later: a row that 0.1.0 stored with
378
+ an empty key is still returned by `isSuppressed` and `getOptInProof`; remove
379
+ it with `unsuppress`.
374
380
  - Keys (`contactHash`, `channel`, `listKey`, `source`) are at most 256 UTF-8
375
381
  bytes, and `proof` is at most 16384 UTF-8 bytes of its JSON form
376
382
  (`JSON.stringify(convexToJson(proof))`). Sizes count bytes, not characters:
377
383
  `"é"` is 2 bytes. A larger value makes `suppress` or `recordOptIn` throw
378
384
  `INVALID_ARGUMENT` and write nothing.
379
- - Rows stored by a version before 0.2.0 with a key over 256 UTF-8 bytes stay
380
- readable through `isSuppressed`, `isEligible` and `getOptInProof`.
381
- `suppress` or `recordOptIn` on such a key throws and leaves the row
382
- unchanged; `unsuppress` is not size-checked and still removes it.
385
+ - Rows stored by a version before 0.2.0 with a key over 256 UTF-8 bytes, or a
386
+ `proof` over 16384 UTF-8 bytes, stay readable through `isSuppressed`,
387
+ `isEligible` and `getOptInProof`. `suppress` or `recordOptIn` on such a key
388
+ throws and leaves the row unchanged; `unsuppress` is not size-checked and
389
+ still removes it. Recording that large `proof` again throws; recording a
390
+ smaller one replaces it.
383
391
  - No expiry, TTL or cron. Entries stay until `unsuppress`; proofs stay until
384
392
  replaced. There is no method to list entries, export them or delete a proof.
385
393
  - `proof` is stored as any Convex value (no functions or class instances),
@@ -394,8 +402,9 @@ returns that entry if one exists, otherwise `null`). `getOptInProof` returns
394
402
 
395
403
  - Peer dependency: `convex@^1.45.0`. CI runs the tests and the packed-package
396
404
  test on the locked convex version (1.51.0); 1.45.0 is not tested in CI.
397
- - Node.js: `engines` says `>=18`, but convex needs Node.js 20 or later
398
- (1.45–1.48) and Node.js 22 or later (1.49 and newer). ES modules only.
405
+ - Node.js: `>=20` (`engines`), the minimum of the lowest supported convex
406
+ (1.45–1.48 need Node.js 20 or later; 1.49 and newer need 22 or later). ES
407
+ modules only.
399
408
  - The component runs in the default Convex runtime; it needs no `"use node"`.
400
409
  - `@vllnt/convex-suppression/test` is TypeScript source and needs `convex-test`,
401
410
  `vitest`, `vite` and `@edge-runtime/vm`, with the Vitest config shown under
@@ -138,6 +138,9 @@ export declare class Suppression<TProof = unknown> {
138
138
  * pass a reference. An empty or longer key, or a larger proof, throws
139
139
  * `ConvexError({ code: "INVALID_ARGUMENT", field })` (`field` is the key name or
140
140
  * `"proof"`) and writes nothing.
141
+ *
142
+ * A `proofValidator` error rejects the returned promise (nothing is written);
143
+ * the call itself never throws synchronously.
141
144
  */
142
145
  recordOptIn(ctx: RunMutationCtx, contactHash: string, opts: RecordOptInOptions<TProof>): Promise<null>;
143
146
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,YAAY,CA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,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAKjC;IAED;;;;;;;;;;;;OAYG;IACH,WAAW,CACT,GAAG,EAAE,cAAc,EACnB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAC/B,OAAO,CAAC,IAAI,CAAC,CAOf;IAED;;;;OAIG;IACG,aAAa,CACjB,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAexC;IAED;;;;;OAKG;IACH,UAAU,CACR,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAOlB;CACF;AAED,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,YAAY,CAAC;AAGpB;;;;GAIG;AACH,KAAK,YAAY,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG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/B,OAAO,CAAC,IAAI,CAAC,CAOf;IAED;;;;OAIG;IACG,aAAa,CACjB,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAexC;IAED;;;;;OAKG;IACH,UAAU,CACR,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,OAAO,CAAC,CAOlB;CACF;AAED,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,CAAC"}
@@ -106,8 +106,11 @@ export class Suppression {
106
106
  * pass a reference. An empty or longer key, or a larger proof, throws
107
107
  * `ConvexError({ code: "INVALID_ARGUMENT", field })` (`field` is the key name or
108
108
  * `"proof"`) and writes nothing.
109
+ *
110
+ * A `proofValidator` error rejects the returned promise (nothing is written);
111
+ * the call itself never throws synchronously.
109
112
  */
110
- recordOptIn(ctx, contactHash, opts) {
113
+ async recordOptIn(ctx, contactHash, opts) {
111
114
  return ctx.runMutation(this.component.mutations.recordOptIn, {
112
115
  contactHash,
113
116
  listKey: opts.listKey ?? GLOBAL_CHANNEL,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAkF9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,WAAW;IASH,SAAS;IARX,cAAc,CAA6B;IAE5D;;;;OAIG;IACH,YACmB,SAA+B,EAChD,OAAO,GAA+B,EAAE;yBADvB,SAAS;QAG1B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAC/C,CAAC;IAED,gGAAgG;IACxF,KAA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;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,cAAc;YACvC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;SACzC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -50,10 +50,10 @@ export declare const optInProofView: import("convex/values").VObject<{
50
50
  }, "required", "confirmedAt" | "contactHash" | "listKey" | "proof" | "source" | `proof.${string}`>;
51
51
  /**
52
52
  * Reject an empty or oversized key. The host hashes contacts, so a real
53
- * `contactHash`, `channel`, or `listKey` is never `""`; an empty one means an
54
- * upstream bug (an unset value passed through) and must not become a row or a
55
- * silent "not suppressed" answer. A key over 256 UTF-8 bytes is rejected to bound
56
- * row size (a hex SHA-256 is 64 bytes). Throws
53
+ * `contactHash`, `channel`, `listKey`, or `source` is never `""`; an empty one
54
+ * means an upstream bug (an unset value passed through) and must not become a row
55
+ * or a silent "not suppressed" answer. A key over 256 UTF-8 bytes is rejected to
56
+ * bound row size (a hex SHA-256 is 64 bytes; keep `source` a short tag). Throws
57
57
  * `ConvexError({ code: "INVALID_ARGUMENT", field })`.
58
58
  */
59
59
  export declare function assertKey(field: string, value: string): void;
@@ -48,10 +48,10 @@ export const optInProofView = v.object({
48
48
  });
49
49
  /**
50
50
  * Reject an empty or oversized key. The host hashes contacts, so a real
51
- * `contactHash`, `channel`, or `listKey` is never `""`; an empty one means an
52
- * upstream bug (an unset value passed through) and must not become a row or a
53
- * silent "not suppressed" answer. A key over 256 UTF-8 bytes is rejected to bound
54
- * row size (a hex SHA-256 is 64 bytes). Throws
51
+ * `contactHash`, `channel`, `listKey`, or `source` is never `""`; an empty one
52
+ * means an upstream bug (an unset value passed through) and must not become a row
53
+ * or a silent "not suppressed" answer. A key over 256 UTF-8 bytes is rejected to
54
+ * bound row size (a hex SHA-256 is 64 bytes; keep `source` a short tag). Throws
55
55
  * `ConvexError({ code: "INVALID_ARGUMENT", field })`.
56
56
  */
57
57
  export function assertKey(field, value) {
package/docs/API.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # API Reference — @vllnt/convex-suppression
2
2
 
3
- **Compatibility:** `convex@^1.45.0`. Backend-only; no `./react` entry.
3
+ **Compatibility:** `convex@^1.45.0`, Node.js `>=20`. Backend-only; no `./react`
4
+ entry.
4
5
 
5
6
  ## Entry points
6
7
 
@@ -65,12 +66,11 @@ a fallback for a named list.
65
66
  `proof` passed to `recordOptIn` (before the write, and the return value is what
66
67
  is stored) and over the `proof` returned by `getOptInProof`. It is skipped when
67
68
  `proof` is `undefined`. It must return the typed value or throw; the thrown
68
- error reaches your caller unchanged. `recordOptIn` is not an `async` function,
69
- so its parser error is a synchronous throw, not a rejected promise: a try/catch
70
- around the call catches it (with or without `await`), and a `.catch()` on the
71
- returned promise never runs. `getOptInProof` rejects its promise instead.
72
- Without `proofValidator`, `proof` is passed through unchecked. `isEligible`
73
- never runs it.
69
+ error reaches your caller unchanged, as a rejected promise from both
70
+ `recordOptIn` (nothing is written) and `getOptInProof`. Neither method throws
71
+ synchronously, so `await` in a try/catch or `.catch()` on the returned promise
72
+ catches it. Without `proofValidator`, `proof` is passed through unchecked.
73
+ `isEligible` never runs it.
74
74
 
75
75
  ### `suppress`
76
76
 
@@ -101,10 +101,10 @@ entry stored by an earlier version with a longer key stays readable, but
101
101
  Removes the exact `(contactHash, channel)` entry. Omit `channel` to remove the
102
102
  global entry. Removing the global entry leaves channel entries, and removing a
103
103
  channel entry leaves the global one. Returns `true` if an entry was removed and
104
- `false` if none matched (including an empty `contactHash`); it never throws
105
- `INVALID_ARGUMENT`. Keys are not size-checked, so it also removes an entry stored
106
- by an earlier version with a key over 256 UTF-8 bytes. Opt-in proofs are not
107
- touched.
104
+ `false` if none matched (including an empty `contactHash`, unless 0.1.0 stored a
105
+ row with that empty key, which it removes); it never throws `INVALID_ARGUMENT`.
106
+ Keys are not size-checked, so it also removes an entry stored by an earlier
107
+ version with a key over 256 UTF-8 bytes. Opt-in proofs are not touched.
108
108
 
109
109
  ### `isSuppressed`
110
110
 
@@ -117,7 +117,8 @@ Returns the entry that blocks `(contactHash, channel)`, or `null`. With a
117
117
  channel entry. Without `channel`, it reads only the global entry. Returns
118
118
  [`SuppressionView`](#suppressionview); `channel` is `null` for the global entry.
119
119
  An empty `contactHash` returns `null`. An empty `channel` checks only the global
120
- entry: it returns that entry if one exists, otherwise `null`. Use
120
+ entry: it returns that entry if one exists, otherwise `null`. A row that 0.1.0
121
+ stored with an empty key is still returned ([details](#error-codes)). Use
121
122
  [`isEligible`](#iseligible), which returns `false` for either and so fails
122
123
  closed, as the send gate.
123
124
 
@@ -144,9 +145,11 @@ and pass a reference.
144
145
 
145
146
  Throws `INVALID_ARGUMENT` with `field` `contactHash`, `listKey` or `source` when
146
147
  that value is `""` or longer than 256 UTF-8 bytes, and with `field` `proof` when
147
- `proof` is over 16384 UTF-8 bytes of its JSON form. A proof stored by an earlier
148
- version with a longer key stays readable through `getOptInProof`, but
149
- `recordOptIn` on that key throws and leaves it unchanged.
148
+ `proof` is over 16384 UTF-8 bytes of its JSON form. Keep `source` a short tag
149
+ and put long text such as a URL in `proof`. A proof stored by an earlier version
150
+ with a longer key stays readable through `getOptInProof`, but `recordOptIn` on
151
+ that key throws and leaves it unchanged. A stored `proof` over 16384 bytes also
152
+ stays readable; recording it again throws, and a smaller `proof` replaces it.
150
153
 
151
154
  ### `getOptInProof`
152
155
 
@@ -265,9 +268,9 @@ Other failures are not component error codes:
265
268
  - An argument of the wrong type, or a `reason` outside
266
269
  [`SuppressionReason`](#suppressionreason), fails Convex argument validation
267
270
  before the handler runs.
268
- - A `proof` rejected by `proofValidator` throws your parser's own error, in the
269
- client: synchronously from the `recordOptIn` call (nothing is written), or as
270
- a rejected promise from `getOptInProof`.
271
+ - A `proof` rejected by `proofValidator` rejects with your parser's own error,
272
+ in the client: from `recordOptIn` (nothing is written) and from
273
+ `getOptInProof`.
271
274
 
272
275
  Everything else is total: a missing entry or proof is `null` or `false`,
273
276
  `unsuppress` of an unknown entry returns `false`, and a repeated `suppress` or
@@ -275,14 +278,17 @@ Everything else is total: a missing entry or proof is `null` or `false`,
275
278
  `contactHash` or `channel`; `isSuppressed` returns `null` for an empty
276
279
  `contactHash` and checks only the global entry for an empty `channel`;
277
280
  `getOptInProof` returns `null` for an empty key. None of them throws
278
- `INVALID_ARGUMENT`.
281
+ `INVALID_ARGUMENT`. This holds for data written by 0.2.0 or later: a row that
282
+ 0.1.0 stored with an empty key is still returned by `isSuppressed` and
283
+ `getOptInProof`; remove it with `unsuppress`.
279
284
 
280
285
  ## Key matching
281
286
 
282
287
  `contactHash`, `channel` and `listKey` are matched exactly (case- and
283
- whitespace-sensitive), and each written key is at most 256 UTF-8 bytes. The component does no normalization, trimming or
284
- plus-address folding. Normalize and hash contacts the same way everywhere, and
285
- use one spelling per channel and list (always `"email"`, never `"Email"`).
288
+ whitespace-sensitive), and each written key is at most 256 UTF-8 bytes. The
289
+ component does no normalization, trimming or plus-address folding. Normalize and
290
+ hash contacts the same way everywhere, and use one spelling per channel and list
291
+ (always `"email"`, never `"Email"`).
286
292
 
287
293
  ## Tables and indexes
288
294
 
package/llms.txt CHANGED
@@ -3,9 +3,9 @@
3
3
  > TypeScript Convex component for a do-not-contact suppression list (GDPR, CAN-SPAM): unsubscribes, bounces and complaints by contact hash, plus opt-in proof.
4
4
 
5
5
  Install `@vllnt/convex-suppression` (unreleased builds from `main` use the
6
- `canary` dist-tag). Peer dependency `convex@^1.45.0`; convex needs Node.js 20+
7
- (1.45–1.48) or 22+ (1.49 and newer). Mount it with `app.use(suppression)` from
8
- `@vllnt/convex-suppression/convex.config` and call it through
6
+ `canary` dist-tag). Peer dependency `convex@^1.45.0`; Node.js `>=20` (convex
7
+ 1.45–1.48 need 20+, 1.49 and newer 22+). Mount it with `app.use(suppression)`
8
+ from `@vllnt/convex-suppression/convex.config` and call it through
9
9
  `new Suppression<TProof>(components.suppression, { proofValidator? })` from host
10
10
  functions: writes need a mutation or action, reads a query, mutation or action. Methods: `suppress(ctx, contactHash, reason,
11
11
  { channel? })`, `unsuppress(ctx, contactHash, channel?)`, `isSuppressed(ctx,
@@ -22,7 +22,8 @@ gate: not suppressed, and, only when `requireOptIn: true` (default `false`), a
22
22
  proof for the exact `listKey` (a global opt-in is not a fallback). It returns
23
23
  `false` for an empty `contactHash` or `channel`; `isSuppressed` returns `null`
24
24
  for an empty `contactHash` and checks only the global entry for an empty
25
- `channel`. `suppress` and `recordOptIn` are idempotent on `(contactHash,
25
+ `channel` (rows 0.1.0 stored with an empty key are still returned; `unsuppress`
26
+ removes them). `suppress` and `recordOptIn` are idempotent on `(contactHash,
26
27
  channel)` and `(contactHash, listKey)`: they update in place. `recordOptIn`
27
28
  keeps only the latest proof (no history), removes the stored proof when called
28
29
  again without `proof`, and never removes a suppression. `unsuppress` removes one
@@ -31,8 +32,10 @@ code is `ConvexError` `data.code` `INVALID_ARGUMENT` (with `data.field`), thrown
31
32
  by `suppress` and `recordOptIn` for an empty `contactHash`, `channel`, `listKey`
32
33
  or `source`, for one of those keys over 256 UTF-8 bytes, and for a `proof` over
33
34
  16384 UTF-8 bytes of its JSON form (`data.field` `proof`). Rows stored earlier
34
- with longer keys stay readable; `unsuppress` still removes them. `proofValidator` is a host parser `(unknown) => TProof` (not
35
- `v.*.parse`), run on write and on read. There is no TTL, cron, listing, export
35
+ with longer keys or a larger `proof` stay readable; `unsuppress` still removes
36
+ them. `proofValidator` is a host parser `(unknown) => TProof` (not `v.*.parse`),
37
+ run on write and on read; its error rejects the promise of `recordOptIn`
38
+ (nothing written) or `getOptInProof`. There is no TTL, cron, listing, export
36
39
  or proof deletion, no auth (the host authorizes every call) and no React entry.
37
40
  Mount it more than once (`app.use(suppression, { name })`) for separate lists.
38
41
  Not a legal-compliance guarantee.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vllnt/convex-suppression",
3
- "version": "0.2.0-canary.4bb2fbc",
3
+ "version": "0.2.0-canary.f851df9",
4
4
  "description": "TypeScript Convex component for a do-not-contact suppression list (GDPR, CAN-SPAM): unsubscribes, bounces and complaints by contact hash, plus opt-in proof.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -63,8 +63,8 @@
63
63
  "@edge-runtime/vm": "^5.0.0",
64
64
  "@typescript/native": "npm:typescript@7.0.2",
65
65
  "@vitest/coverage-v8": "^5.1.1",
66
- "@vllnt/eslint-config": "2.1.0",
67
- "@vllnt/typescript": "3.0.0",
66
+ "@vllnt/eslint-config": "2.2.0",
67
+ "@vllnt/typescript": "3.0.1",
68
68
  "convex": "^1.51.0",
69
69
  "convex-test": "^0.0.73",
70
70
  "eslint": "^10.15.0",
@@ -90,7 +90,7 @@
90
90
  "url": "https://github.com/vllnt/convex-suppression"
91
91
  },
92
92
  "engines": {
93
- "node": ">=18"
93
+ "node": ">=20"
94
94
  },
95
95
  "publishConfig": {
96
96
  "access": "public"
@@ -222,8 +222,11 @@ export class Suppression<TProof = unknown> {
222
222
  * pass a reference. An empty or longer key, or a larger proof, throws
223
223
  * `ConvexError({ code: "INVALID_ARGUMENT", field })` (`field` is the key name or
224
224
  * `"proof"`) and writes nothing.
225
+ *
226
+ * A `proofValidator` error rejects the returned promise (nothing is written);
227
+ * the call itself never throws synchronously.
225
228
  */
226
- recordOptIn(
229
+ async recordOptIn(
227
230
  ctx: RunMutationCtx,
228
231
  contactHash: string,
229
232
  opts: RecordOptInOptions<TProof>,
@@ -62,10 +62,10 @@ export const optInProofView = v.object({
62
62
 
63
63
  /**
64
64
  * Reject an empty or oversized key. The host hashes contacts, so a real
65
- * `contactHash`, `channel`, or `listKey` is never `""`; an empty one means an
66
- * upstream bug (an unset value passed through) and must not become a row or a
67
- * silent "not suppressed" answer. A key over 256 UTF-8 bytes is rejected to bound
68
- * row size (a hex SHA-256 is 64 bytes). Throws
65
+ * `contactHash`, `channel`, `listKey`, or `source` is never `""`; an empty one
66
+ * means an upstream bug (an unset value passed through) and must not become a row
67
+ * or a silent "not suppressed" answer. A key over 256 UTF-8 bytes is rejected to
68
+ * bound row size (a hex SHA-256 is 64 bytes; keep `source` a short tag). Throws
69
69
  * `ConvexError({ code: "INVALID_ARGUMENT", field })`.
70
70
  */
71
71
  export function assertKey(field: string, value: string): void {