@vllnt/convex-consent 0.1.0-canary.591da41

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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -0
  3. package/dist/client/index.d.ts +156 -0
  4. package/dist/client/index.d.ts.map +1 -0
  5. package/dist/client/index.js +142 -0
  6. package/dist/client/index.js.map +1 -0
  7. package/dist/client/types.d.ts +79 -0
  8. package/dist/client/types.d.ts.map +1 -0
  9. package/dist/client/types.js +3 -0
  10. package/dist/client/types.js.map +1 -0
  11. package/dist/component/_generated/api.d.ts +40 -0
  12. package/dist/component/_generated/api.d.ts.map +1 -0
  13. package/dist/component/_generated/api.js +31 -0
  14. package/dist/component/_generated/api.js.map +1 -0
  15. package/dist/component/_generated/component.d.ts +102 -0
  16. package/dist/component/_generated/component.d.ts.map +1 -0
  17. package/dist/component/_generated/component.js +11 -0
  18. package/dist/component/_generated/component.js.map +1 -0
  19. package/dist/component/_generated/dataModel.d.ts +46 -0
  20. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  21. package/dist/component/_generated/dataModel.js +11 -0
  22. package/dist/component/_generated/dataModel.js.map +1 -0
  23. package/dist/component/_generated/server.d.ts +133 -0
  24. package/dist/component/_generated/server.d.ts.map +1 -0
  25. package/dist/component/_generated/server.js +80 -0
  26. package/dist/component/_generated/server.js.map +1 -0
  27. package/dist/component/convex.config.d.ts +3 -0
  28. package/dist/component/convex.config.d.ts.map +1 -0
  29. package/dist/component/convex.config.js +7 -0
  30. package/dist/component/convex.config.js.map +1 -0
  31. package/dist/component/crons.d.ts +16 -0
  32. package/dist/component/crons.d.ts.map +1 -0
  33. package/dist/component/crons.js +19 -0
  34. package/dist/component/crons.js.map +1 -0
  35. package/dist/component/mutations.d.ts +60 -0
  36. package/dist/component/mutations.d.ts.map +1 -0
  37. package/dist/component/mutations.js +149 -0
  38. package/dist/component/mutations.js.map +1 -0
  39. package/dist/component/queries.d.ts +78 -0
  40. package/dist/component/queries.d.ts.map +1 -0
  41. package/dist/component/queries.js +119 -0
  42. package/dist/component/queries.js.map +1 -0
  43. package/dist/component/schema.d.ts +53 -0
  44. package/dist/component/schema.d.ts.map +1 -0
  45. package/dist/component/schema.js +40 -0
  46. package/dist/component/schema.js.map +1 -0
  47. package/dist/component/validators.d.ts +80 -0
  48. package/dist/component/validators.d.ts.map +1 -0
  49. package/dist/component/validators.js +62 -0
  50. package/dist/component/validators.js.map +1 -0
  51. package/dist/shared.d.ts +31 -0
  52. package/dist/shared.d.ts.map +1 -0
  53. package/dist/shared.js +29 -0
  54. package/dist/shared.js.map +1 -0
  55. package/package.json +101 -0
  56. package/src/client/index.ts +298 -0
  57. package/src/client/types.ts +85 -0
  58. package/src/component/_generated/api.ts +56 -0
  59. package/src/component/_generated/component.ts +127 -0
  60. package/src/component/_generated/dataModel.ts +60 -0
  61. package/src/component/_generated/server.ts +169 -0
  62. package/src/component/convex.config.ts +9 -0
  63. package/src/component/crons.ts +23 -0
  64. package/src/component/mutations.ts +158 -0
  65. package/src/component/queries.ts +142 -0
  66. package/src/component/schema.ts +41 -0
  67. package/src/component/validators.ts +70 -0
  68. package/src/shared.ts +36 -0
  69. package/src/test.ts +15 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bntvllnt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ <!-- Badges -->
2
+ [![convex-component](https://img.shields.io/badge/convex-component-EE342F.svg)](https://www.convex.dev/components)
3
+ [![npm](https://img.shields.io/npm/v/@vllnt/convex-consent.svg)](https://www.npmjs.com/package/@vllnt/convex-consent)
4
+ [![CI](https://github.com/vllnt/convex-consent/actions/workflows/ci.yml/badge.svg)](https://github.com/vllnt/convex-consent/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/npm/l/@vllnt/convex-consent.svg)](./LICENSE)
6
+
7
+ # @vllnt/convex-consent
8
+
9
+ An append-only consent ledger (GDPR Art. 6/7), as a Convex component.
10
+
11
+ ```ts
12
+ const consent = new Consent(components.consent);
13
+ await consent.record(ctx, subjectRef, "analytics", "granted");
14
+ const gate = await consent.check(ctx, subjectRef, "analytics"); // { granted, stale, ... }
15
+ ```
16
+
17
+ The host records a subject's decision for a purpose (`granted` / `denied` /
18
+ `withdrawn`) — each call appends an immutable ledger event (the legal proof) and
19
+ updates an O(1) current-state projection — then gates processing with `check`. When
20
+ the policy version changes, a prior grant goes `stale` so the host re-prompts.
21
+ Domain-neutral: a cookie gate, a marketing opt-in, a device-tied consent.
22
+
23
+ ## Features
24
+
25
+ - **Record-and-gate** — `record` appends an immutable event and updates the projection; `check` is the O(1) runtime gate before processing.
26
+ - **Append-only ledger** — every decision is a `consentEvents` row, never mutated; `history` pages the full trail for an audit or DSR.
27
+ - **Easy withdrawal** — `withdraw` (Art. 7(3)) revokes a held grant; withdrawing something never granted throws a coded error.
28
+ - **Version staleness** — `check` returns `stale: true` when a grant is for an older policy version than `requiredVersion`.
29
+ - **Server-sourced time** — every event's `at` is stamped from the server clock; a caller can never supply a timestamp.
30
+ - **Typed, opaque proof** — `Consent<TProof>` with an optional `proofValidator` narrows the stored evidence at the boundary.
31
+ - **Bounded prune + cron** — a daily cron sweeps superseded ledger events past retention; the live projection is never pruned.
32
+ - **Mount-safe** — correct under multiple named `app.use` mounts (web + marketing consent on one backend), each an isolated sandbox.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pnpm add @vllnt/convex-consent
38
+ ```
39
+
40
+ Peer dependency: `convex@^1.41.0`.
41
+
42
+ ## Usage
43
+
44
+ ```ts
45
+ // convex/convex.config.ts
46
+ import { defineApp } from "convex/server";
47
+ import consent from "@vllnt/convex-consent/convex.config";
48
+
49
+ const app = defineApp();
50
+ app.use(consent);
51
+ export default app;
52
+ ```
53
+
54
+ ```ts
55
+ // convex/consent.ts — host owns auth; pass an opaque subjectRef in.
56
+ import { components } from "./_generated/api";
57
+ import { mutation, query } from "./_generated/server";
58
+ import { v } from "convex/values";
59
+ import { Consent } from "@vllnt/convex-consent";
60
+
61
+ const consent = new Consent<{ policyHash: string }>(components.consent, {
62
+ defaultVersion: "2024-policy",
63
+ proofValidator: v.object({ policyHash: v.string() }).parse,
64
+ });
65
+
66
+ // Record a decision, gate processing on it, and withdraw — host resolves identity → subjectRef.
67
+ export const setConsent = mutation({
68
+ args: { purpose: v.string(), granted: v.boolean(), policyHash: v.string() },
69
+ handler: async (ctx, { purpose, granted, policyHash }) => {
70
+ const subjectRef = await resolveSubject(ctx);
71
+ await consent.record(ctx, subjectRef, purpose, granted ? "granted" : "denied", { proof: { policyHash } });
72
+ },
73
+ });
74
+
75
+ export const mayProcess = query({
76
+ args: { purpose: v.string() },
77
+ handler: async (ctx, { purpose }) => {
78
+ const subjectRef = await resolveSubject(ctx);
79
+ const gate = await consent.check(ctx, subjectRef, purpose, "2024-policy");
80
+ return gate.granted; // false (gate.stale === true) if they consented to an older policy
81
+ },
82
+ });
83
+
84
+ export const revoke = mutation({
85
+ args: { purpose: v.string() },
86
+ handler: async (ctx, { purpose }) => consent.withdraw(ctx, await resolveSubject(ctx), purpose),
87
+ });
88
+ ```
89
+
90
+ Client options: `new Consent(component, { defaultVersion?, proofValidator? })`.
91
+
92
+ ## API Reference
93
+
94
+ | Method | Kind | Result |
95
+ |--------|------|--------|
96
+ | `record(ctx, subjectRef, purpose, decision, opts?)` | mutation | `{ at }` (`decision`: `"granted" \| "denied" \| "withdrawn"`; `opts`: `{ version?; proof? }`) |
97
+ | `withdraw(ctx, subjectRef, purpose, proof?)` | mutation | `{ at }` |
98
+ | `check(ctx, subjectRef, purpose, requiredVersion?)` | query | `ConsentCheck` (`{ granted; stale; decision; version; at }`) |
99
+ | `getState(ctx, subjectRef, purpose)` | query | `ConsentState \| null` |
100
+ | `getStatesForSubject(ctx, subjectRef)` | query | `ConsentState[]` |
101
+ | `history(ctx, subjectRef, purpose, paginationOpts)` | query | `PaginationResult<ConsentEvent>` |
102
+ | `prune(ctx, opts?)` | mutation | `number` (ledger events removed in the first bounded pass) |
103
+
104
+ Full reference: [docs/API.md](docs/API.md).
105
+
106
+ ## React
107
+
108
+ Backend-only — no `./react` entry. Consent state is read through an ordinary
109
+ reactive `useQuery` over the host's re-exported `check` / `getState` refs; consent
110
+ proof is sensitive and gating is server-side, so there is no safe client surface.
111
+
112
+ ## Security
113
+
114
+ - **Auth-agnostic** — the host authenticates the caller, decides who may record/read a subject's consent, and passes an opaque `subjectRef`; tables are sandboxed.
115
+ - **Append-only** — a recorded decision and its proof can never be silently rewritten; withdrawal is a new event, not an edit.
116
+ - **Server-sourced time** — every event's `at` comes from `Date.now()` in the handler, never the caller; the `proof` is opaque, narrowed by the host validator.
117
+
118
+ See [docs/API.md](docs/API.md).
119
+
120
+ ## Testing
121
+
122
+ ```bash
123
+ pnpm test # single run
124
+ pnpm test:coverage # enforced 100% on covered files
125
+ ```
126
+
127
+ Tests run against the real component runtime via `convex-test` (`@edge-runtime/vm`), not mocks.
128
+
129
+ ## Contributing
130
+
131
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
132
+
133
+ ## Author
134
+
135
+ Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
136
+
137
+ Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
138
+
139
+ If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
140
+
141
+ ## License
142
+
143
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,156 @@
1
+ import type { FunctionArgs, FunctionReference, FunctionReturnType, PaginationOptions, PaginationResult } from "convex/server";
2
+ import type { ConsentCheck, ConsentDecision, ConsentEvent, ConsentOptions, ConsentState, Parser, RecordOptions } from "./types.js";
3
+ /**
4
+ * The component's raw ledger event, before the client narrows opaque host proof.
5
+ * `proof` is `unknown` here; the {@link Consent} client runs the host validator
6
+ * over it at its typed boundary.
7
+ */
8
+ type RawEvent = {
9
+ subjectRef: string;
10
+ purpose: string;
11
+ decision: ConsentDecision;
12
+ version: string;
13
+ proof?: unknown;
14
+ at: number;
15
+ };
16
+ /**
17
+ * The consent component's function references, as exposed on the host via
18
+ * `components.consent`. The host's stored `proof` is opaque here (`unknown`); the
19
+ * {@link Consent} client narrows it at its own typed boundary.
20
+ */
21
+ export interface ConsentComponent {
22
+ mutations: {
23
+ record: FunctionReference<"mutation", "internal", {
24
+ subjectRef: string;
25
+ purpose: string;
26
+ decision: ConsentDecision;
27
+ version: string;
28
+ proof?: unknown;
29
+ }, {
30
+ at: number;
31
+ }>;
32
+ withdraw: FunctionReference<"mutation", "internal", {
33
+ subjectRef: string;
34
+ purpose: string;
35
+ proof?: unknown;
36
+ }, {
37
+ at: number;
38
+ }>;
39
+ prune: FunctionReference<"mutation", "internal", {
40
+ before?: number;
41
+ batch: number;
42
+ }, number>;
43
+ };
44
+ queries: {
45
+ check: FunctionReference<"query", "internal", {
46
+ subjectRef: string;
47
+ purpose: string;
48
+ requiredVersion?: string;
49
+ }, ConsentCheck>;
50
+ getState: FunctionReference<"query", "internal", {
51
+ subjectRef: string;
52
+ purpose: string;
53
+ }, ConsentState | null>;
54
+ getStatesForSubject: FunctionReference<"query", "internal", {
55
+ subjectRef: string;
56
+ }, ConsentState[]>;
57
+ history: FunctionReference<"query", "internal", {
58
+ subjectRef: string;
59
+ purpose: string;
60
+ paginationOpts: PaginationOptions;
61
+ }, PaginationResult<RawEvent>>;
62
+ };
63
+ }
64
+ interface RunQueryCtx {
65
+ runQuery<Q extends FunctionReference<"query", "internal">>(reference: Q, args: FunctionArgs<Q>): Promise<FunctionReturnType<Q>>;
66
+ }
67
+ interface RunMutationCtx {
68
+ runMutation<M extends FunctionReference<"mutation", "internal">>(reference: M, args: FunctionArgs<M>): Promise<FunctionReturnType<M>>;
69
+ }
70
+ /**
71
+ * Consumer-facing client for the consent ledger (GDPR Art. 6/7). The host records
72
+ * a subject's decision for a purpose with `record` (or revokes one with
73
+ * `withdraw`) — each call appends an immutable ledger event (the legal proof) and
74
+ * updates the O(1) current-state projection. Before processing, the host calls
75
+ * `check` to gate: "may I process `<purpose>` for `<subject>`?". `subjectRef` and
76
+ * `purpose` are opaque host strings; the host owns meaning and auth. Pass
77
+ * `proofValidator` to narrow the opaque stored `proof` to `TProof` at the
78
+ * boundary — there is no unchecked cast.
79
+ *
80
+ * @typeParam TProof - The host's consent-proof type (defaults to `unknown`).
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const consent = new Consent(components.consent, {
85
+ * defaultVersion: "2024-policy",
86
+ * proofValidator: v.object({ policyHash: v.string() }).parse,
87
+ * });
88
+ * await consent.record(ctx, "user_42", "analytics", "granted", {
89
+ * proof: { policyHash },
90
+ * });
91
+ * const gate = await consent.check(ctx, "user_42", "analytics", "2024-policy");
92
+ * if (gate.granted) {
93
+ * // process the personal data
94
+ * }
95
+ * ```
96
+ */
97
+ export declare class Consent<TProof = unknown> {
98
+ private readonly component;
99
+ private readonly defaultVersion;
100
+ private readonly proofValidator;
101
+ constructor(component: ConsentComponent, options?: ConsentOptions<TProof>);
102
+ /** Narrow an opaque value through the host proof parser; pass `undefined` and an unset parser through. */
103
+ private parseProof;
104
+ /** Project a raw component event into the typed, validated client event. */
105
+ private event;
106
+ /**
107
+ * Record a consent decision for `(subjectRef, purpose)`. Appends an immutable
108
+ * ledger event and updates the current-state projection. `opts.version` defaults
109
+ * to the client's `defaultVersion`; `opts.proof` is opaque host evidence
110
+ * validated against `proofValidator` before storage. Returns the server
111
+ * timestamp stamped on the event.
112
+ */
113
+ record(ctx: RunMutationCtx, subjectRef: string, purpose: string, decision: ConsentDecision, opts?: RecordOptions<TProof>): Promise<{
114
+ at: number;
115
+ }>;
116
+ /**
117
+ * Withdraw a previously-granted consent (GDPR Art. 7(3)). Appends a `withdrawn`
118
+ * event and updates the projection, but only when the subject currently holds a
119
+ * `granted` decision — the component throws a coded `ConvexError` (`NO_CONSENT`
120
+ * / `NOT_GRANTED`) otherwise so the audit trail stays meaningful.
121
+ */
122
+ withdraw(ctx: RunMutationCtx, subjectRef: string, purpose: string, proof?: TProof): Promise<{
123
+ at: number;
124
+ }>;
125
+ /**
126
+ * The runtime gate: may the host process `purpose` for `subjectRef`? Pass
127
+ * `requiredVersion` to also require the consent be for the current policy
128
+ * version — when the subject granted an older version the result is `stale`
129
+ * (and not `granted`) so the host re-prompts.
130
+ */
131
+ check(ctx: RunQueryCtx, subjectRef: string, purpose: string, requiredVersion?: string): Promise<ConsentCheck>;
132
+ /** The raw current decision for one `(subjectRef, purpose)` pair, or `null`. */
133
+ getState(ctx: RunQueryCtx, subjectRef: string, purpose: string): Promise<ConsentState | null>;
134
+ /** Every current decision held by one subject, across all purposes. */
135
+ getStatesForSubject(ctx: RunQueryCtx, subjectRef: string): Promise<ConsentState[]>;
136
+ /**
137
+ * Page the immutable consent ledger for one `(subjectRef, purpose)` pair,
138
+ * newest-first. Returns the standard Convex pagination envelope with each event
139
+ * narrowed to the typed view — the full proof trail for an audit or a data
140
+ * subject request.
141
+ */
142
+ history(ctx: RunQueryCtx, subjectRef: string, purpose: string, paginationOpts: PaginationOptions): Promise<PaginationResult<ConsentEvent<TProof>>>;
143
+ /**
144
+ * Delete superseded ledger events whose `at < before` in bounded batches,
145
+ * oldest first. `before` defaults to the server clock; `batch` caps each pass
146
+ * and the sweep self-reschedules until the tail is clean. The current-state
147
+ * projection is never pruned. Returns the count removed in the first pass. The
148
+ * built-in daily cron drives this automatically.
149
+ */
150
+ prune(ctx: RunMutationCtx, opts?: {
151
+ before?: number;
152
+ batch?: number;
153
+ }): Promise<number>;
154
+ }
155
+ export type { ConsentCheck, ConsentDecision, ConsentEvent, ConsentOptions, ConsentState, Parser, RecordOptions, };
156
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,MAAM,EACN,aAAa,EACd,MAAM,YAAY,CAAC;AAGpB;;;;GAIG;AACH,KAAK,QAAQ,GAAG;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE;QACT,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YACE,UAAU,EAAE,MAAM,CA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AAE,CAAC,CAMzB;IAED;;;;;OAKG;IACH,KAAK,CACH,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,YAAY,CAAC,CAMvB;IAED,gFAAgF;IAChF,QAAQ,CACN,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAK9B;IAED,uEAAuE;IACvE,mBAAmB,CACjB,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC,CAIzB;IAED;;;;;OAKG;IACG,OAAO,CACX,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,iBAAiB,GAChC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAOjD;IAED;;;;;;OAMG;IACH,KAAK,CACH,GAAG,EAAE,cAAc,EACnB,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAC7C,OAAO,CAAC,MAAM,CAAC,CAKjB;CACF;AAED,YAAY,EACV,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,MAAM,EACN,aAAa,GACd,CAAC"}
@@ -0,0 +1,142 @@
1
+ import { DEFAULT_PRUNE_BATCH, DEFAULT_VERSION } from "../shared.js";
2
+ /**
3
+ * Consumer-facing client for the consent ledger (GDPR Art. 6/7). The host records
4
+ * a subject's decision for a purpose with `record` (or revokes one with
5
+ * `withdraw`) — each call appends an immutable ledger event (the legal proof) and
6
+ * updates the O(1) current-state projection. Before processing, the host calls
7
+ * `check` to gate: "may I process `<purpose>` for `<subject>`?". `subjectRef` and
8
+ * `purpose` are opaque host strings; the host owns meaning and auth. Pass
9
+ * `proofValidator` to narrow the opaque stored `proof` to `TProof` at the
10
+ * boundary — there is no unchecked cast.
11
+ *
12
+ * @typeParam TProof - The host's consent-proof type (defaults to `unknown`).
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const consent = new Consent(components.consent, {
17
+ * defaultVersion: "2024-policy",
18
+ * proofValidator: v.object({ policyHash: v.string() }).parse,
19
+ * });
20
+ * await consent.record(ctx, "user_42", "analytics", "granted", {
21
+ * proof: { policyHash },
22
+ * });
23
+ * const gate = await consent.check(ctx, "user_42", "analytics", "2024-policy");
24
+ * if (gate.granted) {
25
+ * // process the personal data
26
+ * }
27
+ * ```
28
+ */
29
+ export class Consent {
30
+ component;
31
+ defaultVersion;
32
+ proofValidator;
33
+ constructor(component, options = {}) {
34
+ this.component = component;
35
+ this.defaultVersion = options.defaultVersion ?? DEFAULT_VERSION;
36
+ this.proofValidator = options.proofValidator;
37
+ }
38
+ /** Narrow an opaque value through the host proof parser; pass `undefined` and an unset parser through. */
39
+ parseProof(value) {
40
+ if (value === undefined) {
41
+ return undefined;
42
+ }
43
+ if (this.proofValidator === undefined) {
44
+ return value;
45
+ }
46
+ return this.proofValidator(value);
47
+ }
48
+ /** Project a raw component event into the typed, validated client event. */
49
+ event(raw) {
50
+ return {
51
+ subjectRef: raw.subjectRef,
52
+ purpose: raw.purpose,
53
+ decision: raw.decision,
54
+ version: raw.version,
55
+ proof: this.parseProof(raw.proof),
56
+ at: raw.at,
57
+ };
58
+ }
59
+ /**
60
+ * Record a consent decision for `(subjectRef, purpose)`. Appends an immutable
61
+ * ledger event and updates the current-state projection. `opts.version` defaults
62
+ * to the client's `defaultVersion`; `opts.proof` is opaque host evidence
63
+ * validated against `proofValidator` before storage. Returns the server
64
+ * timestamp stamped on the event.
65
+ */
66
+ record(ctx, subjectRef, purpose, decision, opts = {}) {
67
+ return ctx.runMutation(this.component.mutations.record, {
68
+ subjectRef,
69
+ purpose,
70
+ decision,
71
+ version: opts.version ?? this.defaultVersion,
72
+ proof: opts.proof === undefined ? undefined : this.parseProof(opts.proof),
73
+ });
74
+ }
75
+ /**
76
+ * Withdraw a previously-granted consent (GDPR Art. 7(3)). Appends a `withdrawn`
77
+ * event and updates the projection, but only when the subject currently holds a
78
+ * `granted` decision — the component throws a coded `ConvexError` (`NO_CONSENT`
79
+ * / `NOT_GRANTED`) otherwise so the audit trail stays meaningful.
80
+ */
81
+ withdraw(ctx, subjectRef, purpose, proof) {
82
+ return ctx.runMutation(this.component.mutations.withdraw, {
83
+ subjectRef,
84
+ purpose,
85
+ proof: proof === undefined ? undefined : this.parseProof(proof),
86
+ });
87
+ }
88
+ /**
89
+ * The runtime gate: may the host process `purpose` for `subjectRef`? Pass
90
+ * `requiredVersion` to also require the consent be for the current policy
91
+ * version — when the subject granted an older version the result is `stale`
92
+ * (and not `granted`) so the host re-prompts.
93
+ */
94
+ check(ctx, subjectRef, purpose, requiredVersion) {
95
+ return ctx.runQuery(this.component.queries.check, {
96
+ subjectRef,
97
+ purpose,
98
+ requiredVersion,
99
+ });
100
+ }
101
+ /** The raw current decision for one `(subjectRef, purpose)` pair, or `null`. */
102
+ getState(ctx, subjectRef, purpose) {
103
+ return ctx.runQuery(this.component.queries.getState, {
104
+ subjectRef,
105
+ purpose,
106
+ });
107
+ }
108
+ /** Every current decision held by one subject, across all purposes. */
109
+ getStatesForSubject(ctx, subjectRef) {
110
+ return ctx.runQuery(this.component.queries.getStatesForSubject, {
111
+ subjectRef,
112
+ });
113
+ }
114
+ /**
115
+ * Page the immutable consent ledger for one `(subjectRef, purpose)` pair,
116
+ * newest-first. Returns the standard Convex pagination envelope with each event
117
+ * narrowed to the typed view — the full proof trail for an audit or a data
118
+ * subject request.
119
+ */
120
+ async history(ctx, subjectRef, purpose, paginationOpts) {
121
+ const result = await ctx.runQuery(this.component.queries.history, {
122
+ subjectRef,
123
+ purpose,
124
+ paginationOpts,
125
+ });
126
+ return { ...result, page: result.page.map((raw) => this.event(raw)) };
127
+ }
128
+ /**
129
+ * Delete superseded ledger events whose `at < before` in bounded batches,
130
+ * oldest first. `before` defaults to the server clock; `batch` caps each pass
131
+ * and the sweep self-reschedules until the tail is clean. The current-state
132
+ * projection is never pruned. Returns the count removed in the first pass. The
133
+ * built-in daily cron drives this automatically.
134
+ */
135
+ prune(ctx, opts = {}) {
136
+ return ctx.runMutation(this.component.mutations.prune, {
137
+ before: opts.before,
138
+ batch: opts.batch ?? DEFAULT_PRUNE_BATCH,
139
+ });
140
+ }
141
+ }
142
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA0FpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,OAAO;IAKC,SAAS;IAJX,cAAc,CAAS;IACvB,cAAc,CAA6B;IAE5D,YACmB,SAA2B,EAC5C,OAAO,GAA2B,EAAE;yBADnB,SAAS;QAG1B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,eAAe,CAAC;QAChE,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAC/C,CAAC;IAED,0GAA0G;IAClG,UAAU,CAAC,KAAc;QAC/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,KAAe,CAAC;QACzB,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,4EAA4E;IACpE,KAAK,CAAC,GAAa;QACzB,OAAO;YACL,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,QAAQ,EAAE,GAAG,CA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OAAe;QAEf,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE;YACnD,UAAU;YACV,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAED,uEAAuE;IACvE,mBAAmB,CACjB,GAAgB,EAChB,UAAkB;QAElB,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,mBAAmB,EAAE;YAC9D,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CACX,GAAgB,EAChB,UAAkB,EAClB,OAAe,EACf,cAAiC;QAEjC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE;YAChE,UAAU;YACV,OAAO;YACP,cAAc;SACf,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IACxE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CACH,GAAmB,EACnB,IAAI,GAAwC,EAAE;QAE9C,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE;YACrD,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,mBAAmB;SACzC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,79 @@
1
+ /** Public TypeScript surface for the consent client. */
2
+ /**
3
+ * The three consent decisions a subject can hold for a purpose. `granted` and
4
+ * `denied` are explicit answers to the prompt; `withdrawn` revokes a prior grant.
5
+ */
6
+ export type ConsentDecision = "granted" | "denied" | "withdrawn";
7
+ /**
8
+ * Validates and narrows an opaque stored value to a host type `T` at the client
9
+ * boundary. Receives the raw value the component returned (`unknown`) and MUST
10
+ * return a typed `T` or throw. A `convex/values` validator's `.parse` (or a Zod
11
+ * `.parse`) fits directly; omit it to keep the value unvalidated.
12
+ *
13
+ * @typeParam T - The host's stored type (the consent `proof`).
14
+ */
15
+ export type Parser<T> = (value: unknown) => T;
16
+ /** One immutable row in the consent ledger — a recorded decision plus its proof. */
17
+ export interface ConsentEvent<TProof = unknown> {
18
+ /** The opaque host-supplied subject identifier. */
19
+ subjectRef: string;
20
+ /** The opaque host-supplied purpose key. */
21
+ purpose: string;
22
+ /** The recorded decision. */
23
+ decision: ConsentDecision;
24
+ /** The policy version the subject consented to. */
25
+ version: string;
26
+ /** The opaque host proof recorded with the decision (narrowed if a `proofValidator` is set). */
27
+ proof?: TProof;
28
+ /** Absolute ms timestamp the decision was recorded (server clock). */
29
+ at: number;
30
+ }
31
+ /** The current decision for one `(subjectRef, purpose)` pair. */
32
+ export interface ConsentState {
33
+ /** The opaque host-supplied subject identifier. */
34
+ subjectRef: string;
35
+ /** The opaque host-supplied purpose key. */
36
+ purpose: string;
37
+ /** The latest decision. */
38
+ decision: ConsentDecision;
39
+ /** The policy version of the latest decision. */
40
+ version: string;
41
+ /** Absolute ms timestamp of the latest decision (server clock). */
42
+ at: number;
43
+ }
44
+ /** The answer to "may I process `purpose` for `subjectRef`?" returned by `check`. */
45
+ export interface ConsentCheck {
46
+ /** The gate: `true` only when the latest decision is `granted` and the version matches any requirement. */
47
+ granted: boolean;
48
+ /** `true` when a `granted` decision is for an older version than the one now required — re-prompt. */
49
+ stale: boolean;
50
+ /** The current decision, or `null` if none was ever recorded. */
51
+ decision: ConsentDecision | null;
52
+ /** The current version, or `null` if none was ever recorded. */
53
+ version: string | null;
54
+ /** The current decision timestamp, or `null` if none was ever recorded. */
55
+ at: number | null;
56
+ }
57
+ /** Per-call options for {@link Consent.record}. */
58
+ export interface RecordOptions<TProof> {
59
+ /** The policy version the subject consented to (defaults to the client's `defaultVersion`). */
60
+ version?: string;
61
+ /** The opaque host proof to store (validated against `proofValidator`). */
62
+ proof?: TProof;
63
+ }
64
+ /** Construction options for the {@link Consent} client. */
65
+ export interface ConsentOptions<TProof> {
66
+ /**
67
+ * The policy version stamped on a decision when `record` is called without an
68
+ * explicit `version`. Lets a host bump its policy version in one place. Defaults
69
+ * to `"1"`.
70
+ */
71
+ defaultVersion?: string;
72
+ /**
73
+ * Validates/narrows a stored `proof` to `TProof` at the boundary — applied to
74
+ * the `proof` passed into `record`/`withdraw` (before storage) and the `proof`
75
+ * returned by `history`. Throws on a mismatch. Omit to leave proof unvalidated.
76
+ */
77
+ proofValidator?: Parser<TProof>;
78
+ }
79
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC;AAE9C,oFAAoF;AACpF,MAAM,WAAW,YAAY,CAAC,MAAM,GAAG,OAAO;IAC5C,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC3B,2GAA2G;IAC3G,OAAO,EAAE,OAAO,CAAC;IACjB,sGAAsG;IACtG,KAAK,EAAE,OAAO,CAAC;IACf,iEAAiE;IACjE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,gEAAgE;IAChE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2EAA2E;IAC3E,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACnB;AAED,mDAAmD;AACnD,MAAM,WAAW,aAAa,CAAC,MAAM;IACnC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc,CAAC,MAAM;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CACjC"}
@@ -0,0 +1,3 @@
1
+ /** Public TypeScript surface for the consent client. */
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,wDAAwD"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Generated `api` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type * as crons from "../crons.js";
10
+ import type * as mutations from "../mutations.js";
11
+ import type * as queries from "../queries.js";
12
+ import type * as validators from "../validators.js";
13
+ import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
14
+ declare const fullApi: ApiFromModules<{
15
+ crons: typeof crons;
16
+ mutations: typeof mutations;
17
+ queries: typeof queries;
18
+ validators: typeof validators;
19
+ }>;
20
+ /**
21
+ * A utility for referencing Convex functions in your app's public API.
22
+ *
23
+ * Usage:
24
+ * ```js
25
+ * const myFunctionReference = api.myModule.myFunction;
26
+ * ```
27
+ */
28
+ export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
29
+ /**
30
+ * A utility for referencing Convex functions in your app's internal API.
31
+ *
32
+ * Usage:
33
+ * ```js
34
+ * const myFunctionReference = internal.myModule.myFunction;
35
+ * ```
36
+ */
37
+ export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
38
+ export declare const components: {};
39
+ export {};
40
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,UAAU,CAAC;CAC/B,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `api` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ import { anyApi, componentsGeneric } from "convex/server";
11
+ const fullApi = anyApi;
12
+ /**
13
+ * A utility for referencing Convex functions in your app's public API.
14
+ *
15
+ * Usage:
16
+ * ```js
17
+ * const myFunctionReference = api.myModule.myFunction;
18
+ * ```
19
+ */
20
+ export const api = anyApi;
21
+ /**
22
+ * A utility for referencing Convex functions in your app's internal API.
23
+ *
24
+ * Usage:
25
+ * ```js
26
+ * const myFunctionReference = internal.myModule.myFunction;
27
+ * ```
28
+ */
29
+ export const internal = anyApi;
30
+ export const components = componentsGeneric();
31
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAYH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAKR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}