@vllnt/convex-consent 0.1.0 → 0.1.1-canary.6894cc6
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 +136 -47
- package/dist/component/crons.js +1 -1
- package/dist/component/crons.js.map +1 -1
- package/dist/component/mutations.d.ts +5 -0
- package/dist/component/mutations.d.ts.map +1 -1
- package/dist/component/mutations.js +26 -4
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.js +2 -2
- package/dist/component/queries.js.map +1 -1
- package/dist/component/schema.js +1 -1
- package/dist/component/schema.js.map +1 -1
- package/package.json +22 -12
- package/src/component/crons.ts +1 -1
- package/src/component/mutations.ts +27 -4
- package/src/component/queries.ts +2 -2
- package/src/component/schema.ts +1 -1
- package/src/test.ts +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!-- Badges -->
|
|
2
|
+
|
|
2
3
|
[](https://www.convex.dev/components)
|
|
3
4
|
[](https://www.npmjs.com/package/@vllnt/convex-consent)
|
|
4
5
|
[](https://github.com/vllnt/convex-consent/actions/workflows/ci.yml)
|
|
@@ -15,31 +16,48 @@ const gate = await consent.check(ctx, subjectRef, "analytics"); // { granted, st
|
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
The host records a subject's decision for a purpose (`granted` / `denied` /
|
|
18
|
-
`withdrawn`) — each call appends an immutable ledger event (the
|
|
19
|
-
updates an O(1) current-state projection — then gates processing with
|
|
20
|
-
the policy version changes, a
|
|
21
|
-
Domain-neutral: a cookie gate, a marketing
|
|
19
|
+
`withdrawn`) — each call appends an immutable ledger event (the stored evidence)
|
|
20
|
+
and updates an O(1) current-state projection — then gates processing with
|
|
21
|
+
`check`. When the policy version changes, a grant with a different version goes
|
|
22
|
+
`stale` so the host re-prompts. Domain-neutral: a cookie gate, a marketing
|
|
23
|
+
opt-in, a device-tied consent.
|
|
22
24
|
|
|
23
25
|
## Features
|
|
24
26
|
|
|
25
|
-
- **Record-and-gate** — `record` appends an immutable event and updates the
|
|
26
|
-
|
|
27
|
-
- **
|
|
28
|
-
|
|
29
|
-
- **
|
|
30
|
-
|
|
31
|
-
- **
|
|
32
|
-
|
|
27
|
+
- **Record-and-gate** — `record` appends an immutable event and updates the
|
|
28
|
+
projection; `check` is the O(1) runtime gate before processing.
|
|
29
|
+
- **Append-only ledger** — every decision is a `consentEvents` row, never
|
|
30
|
+
mutated; `history` pages the retained trail for an audit or DSR.
|
|
31
|
+
- **Easy withdrawal** — `withdraw` (Art. 7(3)) revokes a held grant; withdrawing
|
|
32
|
+
something never granted throws a coded error.
|
|
33
|
+
- **Version staleness** — `check` returns `stale: true` when a grant's policy
|
|
34
|
+
version differs from `requiredVersion` (string equality, not version
|
|
35
|
+
ordering).
|
|
36
|
+
- **Server-sourced time** — every event's `at` is stamped from the server clock;
|
|
37
|
+
a caller can never supply a timestamp.
|
|
38
|
+
- **Typed, opaque proof** — `Consent<TProof>` with an optional `proofValidator`
|
|
39
|
+
narrows the stored evidence at the boundary.
|
|
40
|
+
- **Bounded prune + cron** — a daily cron sweeps all ledger events past
|
|
41
|
+
retention, including evidence for the current decision; the live projection is
|
|
42
|
+
never pruned.
|
|
43
|
+
- **Mount-safe** — correct under multiple named `app.use` mounts (web +
|
|
44
|
+
marketing consent on one backend), each an isolated sandbox.
|
|
33
45
|
|
|
34
46
|
## Installation
|
|
35
47
|
|
|
36
48
|
```bash
|
|
37
|
-
pnpm add @vllnt/convex-consent
|
|
49
|
+
pnpm add @vllnt/convex-consent@canary convex@^1.45.0
|
|
38
50
|
```
|
|
39
51
|
|
|
40
|
-
Peer dependency: `convex@^1.
|
|
52
|
+
Peer dependency: `convex@^1.45.0`. This README follows `main` and the canary
|
|
53
|
+
channel; `latest` is the separate stable release. Pin an exact canary version
|
|
54
|
+
for reproducible installs.
|
|
55
|
+
|
|
56
|
+
## Quick start
|
|
41
57
|
|
|
42
|
-
|
|
58
|
+
After mounting, run `pnpm exec convex dev` to generate `components.consent`.
|
|
59
|
+
These internal functions are for trusted server callers. Public wrappers must
|
|
60
|
+
derive and authorize the subject rather than trust a caller-supplied identity.
|
|
43
61
|
|
|
44
62
|
```ts
|
|
45
63
|
// convex/convex.config.ts
|
|
@@ -54,36 +72,56 @@ export default app;
|
|
|
54
72
|
```ts
|
|
55
73
|
// convex/consent.ts — host owns auth; pass an opaque subjectRef in.
|
|
56
74
|
import { components } from "./_generated/api";
|
|
57
|
-
import {
|
|
75
|
+
import { internalMutation, internalQuery } from "./_generated/server";
|
|
58
76
|
import { v } from "convex/values";
|
|
59
77
|
import { Consent } from "@vllnt/convex-consent";
|
|
60
78
|
|
|
61
79
|
const consent = new Consent<{ policyHash: string }>(components.consent, {
|
|
62
80
|
defaultVersion: "2024-policy",
|
|
63
|
-
proofValidator:
|
|
81
|
+
proofValidator: (value) => {
|
|
82
|
+
if (
|
|
83
|
+
typeof value !== "object" ||
|
|
84
|
+
value === null ||
|
|
85
|
+
!("policyHash" in value) ||
|
|
86
|
+
typeof value.policyHash !== "string"
|
|
87
|
+
) {
|
|
88
|
+
throw new Error("Expected a policyHash string");
|
|
89
|
+
}
|
|
90
|
+
return { policyHash: value.policyHash };
|
|
91
|
+
},
|
|
64
92
|
});
|
|
65
93
|
|
|
66
94
|
// Record a decision, gate processing on it, and withdraw — host resolves identity → subjectRef.
|
|
67
|
-
export const setConsent =
|
|
68
|
-
args: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
95
|
+
export const setConsent = internalMutation({
|
|
96
|
+
args: {
|
|
97
|
+
subjectRef: v.string(),
|
|
98
|
+
purpose: v.string(),
|
|
99
|
+
granted: v.boolean(),
|
|
100
|
+
policyHash: v.string(),
|
|
101
|
+
},
|
|
102
|
+
handler: async (ctx, { subjectRef, purpose, granted, policyHash }) => {
|
|
103
|
+
await consent.record(
|
|
104
|
+
ctx,
|
|
105
|
+
subjectRef,
|
|
106
|
+
purpose,
|
|
107
|
+
granted ? "granted" : "denied",
|
|
108
|
+
{ proof: { policyHash } },
|
|
109
|
+
);
|
|
72
110
|
},
|
|
73
111
|
});
|
|
74
112
|
|
|
75
|
-
export const mayProcess =
|
|
76
|
-
args: { purpose: v.string() },
|
|
77
|
-
handler: async (ctx, { purpose }) => {
|
|
78
|
-
const subjectRef = await resolveSubject(ctx);
|
|
113
|
+
export const mayProcess = internalQuery({
|
|
114
|
+
args: { subjectRef: v.string(), purpose: v.string() },
|
|
115
|
+
handler: async (ctx, { subjectRef, purpose }) => {
|
|
79
116
|
const gate = await consent.check(ctx, subjectRef, purpose, "2024-policy");
|
|
80
|
-
return gate.granted; // false (gate.stale === true) if
|
|
117
|
+
return gate.granted; // false (gate.stale === true) if their grant has a different version
|
|
81
118
|
},
|
|
82
119
|
});
|
|
83
120
|
|
|
84
|
-
export const revoke =
|
|
85
|
-
args: { purpose: v.string() },
|
|
86
|
-
handler:
|
|
121
|
+
export const revoke = internalMutation({
|
|
122
|
+
args: { subjectRef: v.string(), purpose: v.string() },
|
|
123
|
+
handler: (ctx, { subjectRef, purpose }) =>
|
|
124
|
+
consent.withdraw(ctx, subjectRef, purpose),
|
|
87
125
|
});
|
|
88
126
|
```
|
|
89
127
|
|
|
@@ -91,29 +129,53 @@ Client options: `new Consent(component, { defaultVersion?, proofValidator? })`.
|
|
|
91
129
|
|
|
92
130
|
## API Reference
|
|
93
131
|
|
|
94
|
-
| Method
|
|
95
|
-
|
|
132
|
+
| Method | Kind | Result |
|
|
133
|
+
| --------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------- |
|
|
96
134
|
| `record(ctx, subjectRef, purpose, decision, opts?)` | mutation | `{ at }` (`decision`: `"granted" \| "denied" \| "withdrawn"`; `opts`: `{ version?; proof? }`) |
|
|
97
|
-
| `withdraw(ctx, subjectRef, purpose, proof?)`
|
|
98
|
-
| `check(ctx, subjectRef, purpose, requiredVersion?)` | query
|
|
99
|
-
| `getState(ctx, subjectRef, purpose)`
|
|
100
|
-
| `getStatesForSubject(ctx, subjectRef)`
|
|
101
|
-
| `history(ctx, subjectRef, purpose, paginationOpts)` | query
|
|
102
|
-
| `prune(ctx, opts?)`
|
|
135
|
+
| `withdraw(ctx, subjectRef, purpose, proof?)` | mutation | `{ at }` |
|
|
136
|
+
| `check(ctx, subjectRef, purpose, requiredVersion?)` | query | `ConsentCheck` (`{ granted; stale; decision; version; at }`) |
|
|
137
|
+
| `getState(ctx, subjectRef, purpose)` | query | `ConsentState \| null` |
|
|
138
|
+
| `getStatesForSubject(ctx, subjectRef)` | query | `ConsentState[]` |
|
|
139
|
+
| `history(ctx, subjectRef, purpose, paginationOpts)` | query | `PaginationResult<ConsentEvent>` |
|
|
140
|
+
| `prune(ctx, opts?)` | mutation | `number` (ledger events removed in the first bounded pass) |
|
|
103
141
|
|
|
104
142
|
Full reference: [docs/API.md](docs/API.md).
|
|
105
143
|
|
|
106
|
-
##
|
|
144
|
+
## Options and limitations
|
|
145
|
+
|
|
146
|
+
- `defaultVersion` defaults to `"1"` and is used for records that omit
|
|
147
|
+
`version`; `check` compares only an explicitly supplied `requiredVersion`.
|
|
148
|
+
- `proofValidator` is a parser `(unknown) => TProof`, not `v.*.parse`.
|
|
149
|
+
- `prune` defaults to 365 days and batch 200 (integer 1–500); non-finite cutoffs
|
|
150
|
+
throw `INVALID_BEFORE`, invalid batches `INVALID_BATCH`.
|
|
151
|
+
- The default daily cron can delete even the latest event's proof. Custom calls
|
|
152
|
+
cannot extend its retention. Export evidence before expiry if your policy
|
|
153
|
+
requires longer storage; this package alone does not establish legal
|
|
154
|
+
compliance.
|
|
155
|
+
- `record` and `withdraw` throw `INVALID_ARGUMENT` for an empty `subjectRef`,
|
|
156
|
+
`purpose` or `version`.
|
|
157
|
+
- `withdraw` throws `NO_CONSENT` for an unrecorded pair and `NOT_GRANTED` for a
|
|
158
|
+
non-granted current decision; it is not an idempotent revoke.
|
|
159
|
+
- Mount separately with `app.use(consent, { name: "marketingConsent" })` and
|
|
160
|
+
`new Consent(components.marketingConsent)`.
|
|
161
|
+
|
|
162
|
+
## Integrations
|
|
107
163
|
|
|
108
164
|
Backend-only — no `./react` entry. Consent state is read through an ordinary
|
|
109
|
-
reactive `useQuery` over the host's re-exported `check` / `getState` refs;
|
|
110
|
-
proof is sensitive and gating is server-side, so there is no safe client
|
|
165
|
+
reactive `useQuery` over the host's re-exported `check` / `getState` refs;
|
|
166
|
+
consent proof is sensitive and gating is server-side, so there is no safe client
|
|
167
|
+
surface.
|
|
111
168
|
|
|
112
169
|
## Security
|
|
113
170
|
|
|
114
|
-
- **Auth-agnostic** — the host authenticates the caller, decides who may
|
|
115
|
-
|
|
116
|
-
|
|
171
|
+
- **Auth-agnostic** — the host authenticates the caller, decides who may
|
|
172
|
+
record/read a subject's consent, and passes an opaque `subjectRef`; tables are
|
|
173
|
+
sandboxed.
|
|
174
|
+
- **Append-only** — a recorded decision and its proof can never be silently
|
|
175
|
+
rewritten; withdrawal is a new event, not an edit.
|
|
176
|
+
- **Server-sourced time** — every event's `at` comes from `Date.now()` in the
|
|
177
|
+
handler, never the caller; the `proof` is opaque, narrowed by the host
|
|
178
|
+
validator.
|
|
117
179
|
|
|
118
180
|
See [docs/API.md](docs/API.md).
|
|
119
181
|
|
|
@@ -124,7 +186,32 @@ pnpm test # single run
|
|
|
124
186
|
pnpm test:coverage # enforced 100% on covered files
|
|
125
187
|
```
|
|
126
188
|
|
|
127
|
-
Tests run against the real component runtime via `convex-test`
|
|
189
|
+
Tests run against the real component runtime via `convex-test`
|
|
190
|
+
(`@edge-runtime/vm`), not mocks.
|
|
191
|
+
|
|
192
|
+
### Testing your app
|
|
193
|
+
|
|
194
|
+
`@vllnt/convex-consent/test` exports `register(t, name = "consent")` to mount
|
|
195
|
+
the component in a `convex-test` instance. It needs `convex-test` and `vitest`
|
|
196
|
+
(with Vite's `import.meta.glob`) in the consuming app:
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
/// <reference types="vite/client" />
|
|
200
|
+
import { convexTest } from "convex-test";
|
|
201
|
+
import { register } from "@vllnt/convex-consent/test";
|
|
202
|
+
import schema from "./schema";
|
|
203
|
+
|
|
204
|
+
const t = convexTest(schema, import.meta.glob("./**/*.ts"));
|
|
205
|
+
register(t);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Documentation
|
|
209
|
+
|
|
210
|
+
`llms.txt` is the maintained discovery index. `pnpm generate:llms` checks its
|
|
211
|
+
heading and local links without generating a source bundle.
|
|
212
|
+
|
|
213
|
+
[API reference](docs/API.md) · [LLM index](llms.txt) ·
|
|
214
|
+
[Security policy](SECURITY.md)
|
|
128
215
|
|
|
129
216
|
## Contributing
|
|
130
217
|
|
|
@@ -132,9 +219,11 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
|
132
219
|
|
|
133
220
|
## Author
|
|
134
221
|
|
|
135
|
-
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
222
|
+
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
223
|
+
[bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
136
224
|
|
|
137
|
-
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
|
|
225
|
+
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
|
|
226
|
+
[vllnt.com](https://vllnt.com)
|
|
138
227
|
|
|
139
228
|
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
140
229
|
|
package/dist/component/crons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cronJobs } from "convex/server";
|
|
2
|
-
import { api } from "./_generated/api";
|
|
2
|
+
import { api } from "./_generated/api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Default sweep cadence and page size for the built-in prune cron. The cron is
|
|
5
5
|
* the component's own self-healing safety net — a host that wants a different
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,EAAE,EAAW,CAAC;AAErD,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE/B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;IACnE,KAAK,EAAE,WAAW;CACnB,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* the client boundary); `proof` is opaque host evidence stored verbatim. The
|
|
12
12
|
* ledger row is the legal record — it is never mutated, only swept by retention
|
|
13
13
|
* `prune`.
|
|
14
|
+
*
|
|
15
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `subjectRef`, `purpose`
|
|
16
|
+
* or `version` is empty.
|
|
14
17
|
*/
|
|
15
18
|
export declare const record: import("convex/server").RegisteredMutation<"public", {
|
|
16
19
|
decision: "denied" | "granted" | "withdrawn";
|
|
@@ -28,6 +31,8 @@ export declare const record: import("convex/server").RegisteredMutation<"public"
|
|
|
28
31
|
* something never granted is a no-op error rather than a silent ledger entry, so
|
|
29
32
|
* the audit trail stays meaningful.
|
|
30
33
|
*
|
|
34
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `subjectRef` or `purpose`
|
|
35
|
+
* is empty.
|
|
31
36
|
* @throws `ConvexError({ code: "NO_CONSENT" })` when no consent was ever recorded
|
|
32
37
|
* for the pair.
|
|
33
38
|
* @throws `ConvexError({ code: "NOT_GRANTED" })` when the current decision is not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM;;;;;;;;GA6CjB,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ;;;;;;GAwCnB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK;;;mBA6BhB,CAAC"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { ConvexError, v } from "convex/values";
|
|
2
|
-
import { api } from "./_generated/api";
|
|
3
|
-
import { mutation } from "./_generated/server";
|
|
4
|
-
import { DEFAULT_RETENTION_MS, MAX_PRUNE_BATCH } from "../shared";
|
|
5
|
-
import { consentDecision, jsonValue } from "./validators";
|
|
2
|
+
import { api } from "./_generated/api.js";
|
|
3
|
+
import { mutation } from "./_generated/server.js";
|
|
4
|
+
import { DEFAULT_RETENTION_MS, MAX_PRUNE_BATCH } from "../shared.js";
|
|
5
|
+
import { consentDecision, jsonValue } from "./validators.js";
|
|
6
|
+
/** Reject empty identifiers: an empty ref/purpose/version would store a meaningless ledger row. */
|
|
7
|
+
function assertNonEmpty(fields) {
|
|
8
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
9
|
+
if (value === "") {
|
|
10
|
+
throw new ConvexError({
|
|
11
|
+
code: "INVALID_ARGUMENT",
|
|
12
|
+
message: `${name} must be non-empty`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
6
17
|
/**
|
|
7
18
|
* Record a consent decision for a `(subjectRef, purpose)` pair. Appends one
|
|
8
19
|
* immutable row to the `consentEvents` ledger — the GDPR proof — and overwrites
|
|
@@ -16,6 +27,9 @@ import { consentDecision, jsonValue } from "./validators";
|
|
|
16
27
|
* the client boundary); `proof` is opaque host evidence stored verbatim. The
|
|
17
28
|
* ledger row is the legal record — it is never mutated, only swept by retention
|
|
18
29
|
* `prune`.
|
|
30
|
+
*
|
|
31
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `subjectRef`, `purpose`
|
|
32
|
+
* or `version` is empty.
|
|
19
33
|
*/
|
|
20
34
|
export const record = mutation({
|
|
21
35
|
args: {
|
|
@@ -27,6 +41,11 @@ export const record = mutation({
|
|
|
27
41
|
},
|
|
28
42
|
returns: v.object({ at: v.number() }),
|
|
29
43
|
handler: async (ctx, args) => {
|
|
44
|
+
assertNonEmpty({
|
|
45
|
+
subjectRef: args.subjectRef,
|
|
46
|
+
purpose: args.purpose,
|
|
47
|
+
version: args.version,
|
|
48
|
+
});
|
|
30
49
|
const at = Date.now();
|
|
31
50
|
await ctx.db.insert("consentEvents", {
|
|
32
51
|
subjectRef: args.subjectRef,
|
|
@@ -63,6 +82,8 @@ export const record = mutation({
|
|
|
63
82
|
* something never granted is a no-op error rather than a silent ledger entry, so
|
|
64
83
|
* the audit trail stays meaningful.
|
|
65
84
|
*
|
|
85
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `subjectRef` or `purpose`
|
|
86
|
+
* is empty.
|
|
66
87
|
* @throws `ConvexError({ code: "NO_CONSENT" })` when no consent was ever recorded
|
|
67
88
|
* for the pair.
|
|
68
89
|
* @throws `ConvexError({ code: "NOT_GRANTED" })` when the current decision is not
|
|
@@ -76,6 +97,7 @@ export const withdraw = mutation({
|
|
|
76
97
|
},
|
|
77
98
|
returns: v.object({ at: v.number() }),
|
|
78
99
|
handler: async (ctx, args) => {
|
|
100
|
+
assertNonEmpty({ subjectRef: args.subjectRef, purpose: args.purpose });
|
|
79
101
|
const state = await ctx.db
|
|
80
102
|
.query("consentState")
|
|
81
103
|
.withIndex("by_subject_purpose", (q) => q.eq("subjectRef", args.subjectRef).eq("purpose", args.purpose))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D,mGAAmG;AACnG,SAAS,cAAc,CAAC,MAA8B;IACpD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,GAAG,IAAI,oBAAoB;aACrC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC7B,IAAI,EAAE;QACJ,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,KAAK,EAAE,CAAC,CAAC,QAAQ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7 +1,7 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
2
|
import { paginationOptsValidator } from "convex/server";
|
|
3
|
-
import { query } from "./_generated/server";
|
|
4
|
-
import { consentCheckView, consentEventView, consentStateView, } from "./validators";
|
|
3
|
+
import { query } from "./_generated/server.js";
|
|
4
|
+
import { consentCheckView, consentEventView, consentStateView, } from "./validators.js";
|
|
5
5
|
/** Project a stored ledger row to its public event view (drops internal fields). */
|
|
6
6
|
function eventView(e) {
|
|
7
7
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAGzB,oFAAoF;AACpF,SAAS,SAAS,CAAC,CAAuB;IACxC,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,EAAE,EAAE,CAAC,CAAC,EAAE;KACT,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAS,SAAS,CAAC,CAAsB;IACvC,OAAO;QACL,UAAU,EAAE,CAAC,C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AAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAChE;aACA,KAAK,CAAC,MAAM,CAAC;aACb,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACjC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;IACzD,CAAC;CACF,CAAC,CAAC"}
|
package/dist/component/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineSchema, defineTable } from "convex/server";
|
|
2
2
|
import { v } from "convex/values";
|
|
3
|
-
import { consentDecision, jsonValue } from "./validators";
|
|
3
|
+
import { consentDecision, jsonValue } from "./validators.js";
|
|
4
4
|
/**
|
|
5
5
|
* Two sandboxed tables — the consent ledger's own concern.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;;;;;GAcG;AACH,eAAe,YAAY,CAAC;IAC1B,aAAa,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC5B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;KACf,CAAC;SACC,KAAK,CAAC,uBAAuB,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;SAC/D,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IAEzB,YAAY,EAAE,WAAW,CAAC;QACxB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,QAAQ,EAAE,eAAe;QACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;KACf,CAAC;SACC,KAAK,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;SACtD,KAAK,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC;CACvC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vllnt/convex-consent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-canary.6894cc6",
|
|
4
4
|
"description": "Append-only consent ledger (GDPR Art. 6/7) — record, withdraw, and gate consent per subject + purpose as a Convex component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@
|
|
7
|
+
"packageManager": "pnpm@10.34.8",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"src"
|
|
@@ -45,9 +45,6 @@
|
|
|
45
45
|
"test:coverage": "vitest run --coverage --coverage.reporter=text",
|
|
46
46
|
"generate:llms": "node scripts/generate-llms.mjs",
|
|
47
47
|
"preversion": "pnpm install --frozen-lockfile && pnpm build && pnpm test:coverage && pnpm typecheck && pnpm generate:llms",
|
|
48
|
-
"prepublishOnly": "npm whoami || npm login",
|
|
49
|
-
"alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
|
|
50
|
-
"release": "npm version patch && npm publish && git push --follow-tags",
|
|
51
48
|
"check:agents": "node -e \"const f=require('node:fs');if(!f.existsSync('AGENTS.md')||f.existsSync('CLAUDE.md')||f.existsSync('.claude'))process.exit(1)\"",
|
|
52
49
|
"codegen": "pnpm convex codegen --component-dir ./src/component"
|
|
53
50
|
},
|
|
@@ -57,16 +54,16 @@
|
|
|
57
54
|
"devDependencies": {
|
|
58
55
|
"@edge-runtime/vm": "^5.0.0",
|
|
59
56
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
60
|
-
"@vitest/coverage-v8": "^
|
|
57
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
61
58
|
"@vllnt/eslint-config": "2.0.0",
|
|
62
59
|
"@vllnt/typescript": "2.0.0",
|
|
63
|
-
"convex": "^1.
|
|
64
|
-
"convex-test": "^0.0.
|
|
60
|
+
"convex": "^1.48.0",
|
|
61
|
+
"convex-test": "^0.0.65",
|
|
65
62
|
"eslint": "^9.39.5",
|
|
66
|
-
"prettier": "^3.9.
|
|
63
|
+
"prettier": "^3.9.10",
|
|
67
64
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
68
|
-
"vite": "^8.
|
|
69
|
-
"vitest": "^
|
|
65
|
+
"vite": "^8.3.5",
|
|
66
|
+
"vitest": "^5.0.5"
|
|
70
67
|
},
|
|
71
68
|
"homepage": "https://github.com/vllnt/convex-consent#readme",
|
|
72
69
|
"bugs": {
|
|
@@ -97,5 +94,18 @@
|
|
|
97
94
|
"consent",
|
|
98
95
|
"gdpr",
|
|
99
96
|
"privacy"
|
|
100
|
-
]
|
|
97
|
+
],
|
|
98
|
+
"pnpm": {
|
|
99
|
+
"minimumReleaseAge": 10080,
|
|
100
|
+
"minimumReleaseAgeExclude": [
|
|
101
|
+
"@vllnt/*"
|
|
102
|
+
],
|
|
103
|
+
"ignoredBuiltDependencies": [
|
|
104
|
+
"esbuild"
|
|
105
|
+
],
|
|
106
|
+
"overrides": {
|
|
107
|
+
"handlebars@<4.7.10": "^4.7.10",
|
|
108
|
+
"deepmerge-ts@<8.0.0": "^8.0.2"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
101
111
|
}
|
package/src/component/crons.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { ConvexError, v } from "convex/values";
|
|
2
|
-
import { api } from "./_generated/api";
|
|
3
|
-
import { mutation } from "./_generated/server";
|
|
4
|
-
import { DEFAULT_RETENTION_MS, MAX_PRUNE_BATCH } from "../shared";
|
|
5
|
-
import { consentDecision, jsonValue } from "./validators";
|
|
2
|
+
import { api } from "./_generated/api.js";
|
|
3
|
+
import { mutation } from "./_generated/server.js";
|
|
4
|
+
import { DEFAULT_RETENTION_MS, MAX_PRUNE_BATCH } from "../shared.js";
|
|
5
|
+
import { consentDecision, jsonValue } from "./validators.js";
|
|
6
|
+
|
|
7
|
+
/** Reject empty identifiers: an empty ref/purpose/version would store a meaningless ledger row. */
|
|
8
|
+
function assertNonEmpty(fields: Record<string, string>): void {
|
|
9
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
10
|
+
if (value === "") {
|
|
11
|
+
throw new ConvexError({
|
|
12
|
+
code: "INVALID_ARGUMENT",
|
|
13
|
+
message: `${name} must be non-empty`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
6
18
|
|
|
7
19
|
/**
|
|
8
20
|
* Record a consent decision for a `(subjectRef, purpose)` pair. Appends one
|
|
@@ -17,6 +29,9 @@ import { consentDecision, jsonValue } from "./validators";
|
|
|
17
29
|
* the client boundary); `proof` is opaque host evidence stored verbatim. The
|
|
18
30
|
* ledger row is the legal record — it is never mutated, only swept by retention
|
|
19
31
|
* `prune`.
|
|
32
|
+
*
|
|
33
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `subjectRef`, `purpose`
|
|
34
|
+
* or `version` is empty.
|
|
20
35
|
*/
|
|
21
36
|
export const record = mutation({
|
|
22
37
|
args: {
|
|
@@ -28,6 +43,11 @@ export const record = mutation({
|
|
|
28
43
|
},
|
|
29
44
|
returns: v.object({ at: v.number() }),
|
|
30
45
|
handler: async (ctx, args) => {
|
|
46
|
+
assertNonEmpty({
|
|
47
|
+
subjectRef: args.subjectRef,
|
|
48
|
+
purpose: args.purpose,
|
|
49
|
+
version: args.version,
|
|
50
|
+
});
|
|
31
51
|
const at = Date.now();
|
|
32
52
|
await ctx.db.insert("consentEvents", {
|
|
33
53
|
subjectRef: args.subjectRef,
|
|
@@ -67,6 +87,8 @@ export const record = mutation({
|
|
|
67
87
|
* something never granted is a no-op error rather than a silent ledger entry, so
|
|
68
88
|
* the audit trail stays meaningful.
|
|
69
89
|
*
|
|
90
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `subjectRef` or `purpose`
|
|
91
|
+
* is empty.
|
|
70
92
|
* @throws `ConvexError({ code: "NO_CONSENT" })` when no consent was ever recorded
|
|
71
93
|
* for the pair.
|
|
72
94
|
* @throws `ConvexError({ code: "NOT_GRANTED" })` when the current decision is not
|
|
@@ -80,6 +102,7 @@ export const withdraw = mutation({
|
|
|
80
102
|
},
|
|
81
103
|
returns: v.object({ at: v.number() }),
|
|
82
104
|
handler: async (ctx, args) => {
|
|
105
|
+
assertNonEmpty({ subjectRef: args.subjectRef, purpose: args.purpose });
|
|
83
106
|
const state = await ctx.db
|
|
84
107
|
.query("consentState")
|
|
85
108
|
.withIndex("by_subject_purpose", (q) =>
|
package/src/component/queries.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
2
|
import { paginationOptsValidator } from "convex/server";
|
|
3
|
-
import { query } from "./_generated/server";
|
|
3
|
+
import { query } from "./_generated/server.js";
|
|
4
4
|
import {
|
|
5
5
|
consentCheckView,
|
|
6
6
|
consentEventView,
|
|
7
7
|
consentStateView,
|
|
8
|
-
} from "./validators";
|
|
8
|
+
} from "./validators.js";
|
|
9
9
|
import type { Doc } from "./_generated/dataModel";
|
|
10
10
|
|
|
11
11
|
/** Project a stored ledger row to its public event view (drops internal fields). */
|
package/src/component/schema.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineSchema, defineTable } from "convex/server";
|
|
2
2
|
import { v } from "convex/values";
|
|
3
|
-
import { consentDecision, jsonValue } from "./validators";
|
|
3
|
+
import { consentDecision, jsonValue } from "./validators.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Two sandboxed tables — the consent ledger's own concern.
|