dpdp-kit 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +130 -8
- package/dist/access.d.ts +106 -0
- package/dist/audit.d.ts +3 -1
- package/dist/chunk-5TVA2TKG.js +37 -0
- package/dist/chunk-YOEAZX65.js +937 -0
- package/dist/cli.js +30 -10
- package/dist/config.d.ts +69 -0
- package/dist/data-access.d.ts +6 -2
- package/dist/dpdp.d.ts +146 -0
- package/dist/drizzle.d.ts +195 -5
- package/dist/drizzle.js +99 -7
- package/dist/errors.d.ts +1 -1
- package/dist/express.d.ts +17 -1
- package/dist/express.js +10 -2
- package/dist/fastify.d.ts +41 -0
- package/dist/fastify.js +25 -0
- package/dist/guard.d.ts +19 -0
- package/dist/hono.d.ts +16 -1
- package/dist/hono.js +11 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.js +189 -103
- package/dist/nestjs.d.ts +65 -0
- package/dist/nestjs.js +41 -0
- package/dist/protect.d.ts +74 -0
- package/dist/protect.js +114 -0
- package/dist/retention.d.ts +1 -1
- package/dist/run-audit.d.ts +5 -0
- package/dist/safeguards.d.ts +23 -0
- package/dist/schedule.d.ts +37 -0
- package/dist/schedule.js +66 -0
- package/dist/schema-check.d.ts +5 -7
- package/dist/store.d.ts +8 -1
- package/package.json +35 -4
- package/dist/chunk-FGZAH2NF.js +0 -16
- package/dist/chunk-KVTUMHXO.js +0 -491
package/dist/protect.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DpdpError
|
|
3
|
+
} from "./chunk-67Q5GFD6.js";
|
|
4
|
+
|
|
5
|
+
// src/protect.ts
|
|
6
|
+
import { createCipheriv, createDecipheriv, createHmac, randomBytes } from "crypto";
|
|
7
|
+
var VERSION = "v1";
|
|
8
|
+
var KEY_BYTES = 32;
|
|
9
|
+
var IV_BYTES = 12;
|
|
10
|
+
function generateKey() {
|
|
11
|
+
return randomBytes(KEY_BYTES).toString("base64url");
|
|
12
|
+
}
|
|
13
|
+
function toKey(input, label, exact = true) {
|
|
14
|
+
const key = typeof input === "string" ? Buffer.from(input, "base64") : Buffer.from(input);
|
|
15
|
+
if (exact ? key.length !== KEY_BYTES : key.length < KEY_BYTES) {
|
|
16
|
+
throw new DpdpError(
|
|
17
|
+
"invalid-key",
|
|
18
|
+
`${label} must be ${exact ? "" : "at least "}${KEY_BYTES} bytes (base64 or base64url text, or bytes); got ${key.length}`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return key;
|
|
22
|
+
}
|
|
23
|
+
function createEncryptor(options) {
|
|
24
|
+
const keys = /* @__PURE__ */ new Map();
|
|
25
|
+
for (const [id, key] of Object.entries(options.keys)) {
|
|
26
|
+
if (!/^[A-Za-z0-9_-]+$/.test(id)) {
|
|
27
|
+
throw new DpdpError("invalid-key", `Key id ${JSON.stringify(id)} may only use letters, digits, "_" and "-"`);
|
|
28
|
+
}
|
|
29
|
+
keys.set(id, toKey(key, `Key ${JSON.stringify(id)}`));
|
|
30
|
+
}
|
|
31
|
+
const current = keys.get(options.current);
|
|
32
|
+
if (!current) throw new DpdpError("invalid-key", `current key ${JSON.stringify(options.current)} isn't in keys`);
|
|
33
|
+
const parse = (value) => {
|
|
34
|
+
const parts = value.split(".");
|
|
35
|
+
if (parts.length !== 5 || parts[0] !== VERSION) return void 0;
|
|
36
|
+
const [, keyId, iv, tag, data] = parts;
|
|
37
|
+
return { keyId, iv: Buffer.from(iv, "base64url"), tag: Buffer.from(tag, "base64url"), data: Buffer.from(data, "base64url") };
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
encrypt(plaintext, context) {
|
|
41
|
+
if (typeof plaintext !== "string") throw new DpdpError("invalid-input", "encrypt() takes a string");
|
|
42
|
+
const iv = randomBytes(IV_BYTES);
|
|
43
|
+
const cipher = createCipheriv("aes-256-gcm", current, iv);
|
|
44
|
+
if (context !== void 0) cipher.setAAD(Buffer.from(context, "utf8"));
|
|
45
|
+
const data = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
46
|
+
const tag = cipher.getAuthTag();
|
|
47
|
+
return [VERSION, options.current, iv.toString("base64url"), tag.toString("base64url"), data.toString("base64url")].join(".");
|
|
48
|
+
},
|
|
49
|
+
decrypt(ciphertext, context) {
|
|
50
|
+
const parsed = typeof ciphertext === "string" ? parse(ciphertext) : void 0;
|
|
51
|
+
if (!parsed) throw new DpdpError("decrypt-failed", "Not a value from encrypt()");
|
|
52
|
+
const key = keys.get(parsed.keyId);
|
|
53
|
+
if (!key) throw new DpdpError("decrypt-failed", `Encrypted with key ${JSON.stringify(parsed.keyId)}, which isn't in keys`);
|
|
54
|
+
try {
|
|
55
|
+
const decipher = createDecipheriv("aes-256-gcm", key, parsed.iv);
|
|
56
|
+
if (context !== void 0) decipher.setAAD(Buffer.from(context, "utf8"));
|
|
57
|
+
decipher.setAuthTag(parsed.tag);
|
|
58
|
+
return Buffer.concat([decipher.update(parsed.data), decipher.final()]).toString("utf8");
|
|
59
|
+
} catch {
|
|
60
|
+
throw new DpdpError("decrypt-failed", "Couldn't decrypt: the value was changed, or the key or context is wrong");
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
isEncrypted: (value) => typeof value === "string" && parse(value) !== void 0,
|
|
64
|
+
needsRotation(ciphertext) {
|
|
65
|
+
const parsed = parse(ciphertext);
|
|
66
|
+
return parsed !== void 0 && parsed.keyId !== options.current;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function createTokenizer(options) {
|
|
71
|
+
const key = toKey(options.key, "Tokenizer key", false);
|
|
72
|
+
const normalize = options.normalize ?? ((v) => v.trim());
|
|
73
|
+
return {
|
|
74
|
+
token(value) {
|
|
75
|
+
if (typeof value !== "string") throw new DpdpError("invalid-input", "token() takes a string");
|
|
76
|
+
return `tk_${createHmac("sha256", key).update(normalize(value), "utf8").digest("base64url")}`;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function mask(value, options = {}) {
|
|
81
|
+
const { keepStart = 0, keepEnd = 4, char = "\u2022" } = options;
|
|
82
|
+
const chars = [...value];
|
|
83
|
+
if (chars.length <= keepStart + keepEnd) return char.repeat(chars.length);
|
|
84
|
+
return chars.slice(0, keepStart).join("") + char.repeat(chars.length - keepStart - keepEnd) + chars.slice(chars.length - keepEnd).join("");
|
|
85
|
+
}
|
|
86
|
+
function maskPhone(value) {
|
|
87
|
+
const digits = value.replace(/\D/g, "");
|
|
88
|
+
if (digits.length === 12 && digits.startsWith("91")) return `+91 ${mask(digits.slice(2))}`;
|
|
89
|
+
return mask(digits);
|
|
90
|
+
}
|
|
91
|
+
function maskEmail(value) {
|
|
92
|
+
const at = value.lastIndexOf("@");
|
|
93
|
+
if (at <= 0) return mask(value);
|
|
94
|
+
const local = value.slice(0, at);
|
|
95
|
+
return mask(local, { keepStart: local.length > 1 ? 1 : 0, keepEnd: 0 }) + value.slice(at);
|
|
96
|
+
}
|
|
97
|
+
function maskAadhaar(value) {
|
|
98
|
+
const digits = value.replace(/\D/g, "");
|
|
99
|
+
if (digits.length !== 12) return mask(digits, { char: "X" });
|
|
100
|
+
return `XXXX XXXX ${digits.slice(8)}`;
|
|
101
|
+
}
|
|
102
|
+
function maskPan(value) {
|
|
103
|
+
return mask(value.trim().toUpperCase(), { char: "X" });
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
createEncryptor,
|
|
107
|
+
createTokenizer,
|
|
108
|
+
generateKey,
|
|
109
|
+
mask,
|
|
110
|
+
maskAadhaar,
|
|
111
|
+
maskEmail,
|
|
112
|
+
maskPan,
|
|
113
|
+
maskPhone
|
|
114
|
+
};
|
package/dist/retention.d.ts
CHANGED
package/dist/run-audit.d.ts
CHANGED
|
@@ -19,3 +19,8 @@ export declare function formatGithubAnnotations(issues: readonly Issue[], files:
|
|
|
19
19
|
export declare function loadDrizzleSchema(file: string): Promise<Schema>;
|
|
20
20
|
/** Run `dpdp-kit audit`. Returns the exit code: 1 when there are errors (or `--strict` and warnings). */
|
|
21
21
|
export declare function runAudit(argv: readonly string[], cwd: string, log: (line: string) => void): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Run `dpdp-kit safeguards`: a Rule 6(1) report from the config. Returns 0, or with `--strict` 1
|
|
24
|
+
* when a safeguard is missing or partly recorded.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runSafeguards(argv: readonly string[], cwd: string, log: (line: string) => void): Promise<number>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DpdpConfig } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* - `declared`: the config records it (a measure described, fields protected, contracts noted).
|
|
4
|
+
* - `partly`: some of it is recorded.
|
|
5
|
+
* - `missing`: nothing is recorded.
|
|
6
|
+
* - `in-code`: dpdp-kit provides it when your app uses the API (`dpdp.access`).
|
|
7
|
+
*/
|
|
8
|
+
export type SafeguardStatus = "declared" | "partly" | "missing" | "in-code";
|
|
9
|
+
export interface Safeguard {
|
|
10
|
+
/** The clause of Rule 6(1), e.g. `"(a)"`. */
|
|
11
|
+
clause: string;
|
|
12
|
+
title: string;
|
|
13
|
+
status: SafeguardStatus;
|
|
14
|
+
/** What the config says, or what to add. */
|
|
15
|
+
details: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Rule 6(1) of the DPDP Rules lists the minimum reasonable security safeguards, (a) to (g). This
|
|
19
|
+
* reports, for each one, what your config records as evidence and what's missing. It can't see
|
|
20
|
+
* your infrastructure: a described measure is only as true as the description.
|
|
21
|
+
*/
|
|
22
|
+
export declare function safeguardsReport(config: DpdpConfig<string>): Safeguard[];
|
|
23
|
+
export declare function formatSafeguards(report: readonly Safeguard[]): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DailyReport, Dpdp } from "./dpdp.js";
|
|
2
|
+
export interface StartDailyOptions {
|
|
3
|
+
/** Local time of day to run, `"HH:MM"` in 24-hour time. Default `"03:00"`. */
|
|
4
|
+
at?: string;
|
|
5
|
+
/** Called with each run's report, e.g. to alert on failed tasks or review findings. */
|
|
6
|
+
onReport?: (report: DailyReport) => void | Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Called when a run, or a step of it, fails. Default: `console.error`. The next day's run still
|
|
9
|
+
* happens, and its access review starts where the last successful one ended (up to a week back).
|
|
10
|
+
*/
|
|
11
|
+
onError?: (error: unknown) => void;
|
|
12
|
+
/** Clock, for tests. */
|
|
13
|
+
now?: () => Date;
|
|
14
|
+
}
|
|
15
|
+
export interface DailySchedule {
|
|
16
|
+
/** Run once now (skipped if a run is already going). Resolves with the report, or undefined if skipped or failed. */
|
|
17
|
+
runNow(): Promise<DailyReport | undefined>;
|
|
18
|
+
/** When the next run is due. */
|
|
19
|
+
nextRunAt(): Date;
|
|
20
|
+
/** Stop scheduling runs. */
|
|
21
|
+
stop(): void;
|
|
22
|
+
}
|
|
23
|
+
/** Milliseconds from `now` until the next local `hours:minutes`. */
|
|
24
|
+
export declare function msUntil(now: Date, hours: number, minutes: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Run `dpdp.daily()` every day at a set local time, in this process, with no dependencies. Runs
|
|
27
|
+
* never overlap, and the timer doesn't keep the process alive on its own. If several servers each
|
|
28
|
+
* call this, each runs the job; that's safe (erasure tasks are claimed atomically), but you'll get
|
|
29
|
+
* one report per server. To run it once across servers, use your platform's cron or a BullMQ
|
|
30
|
+
* repeatable job with `dpdp.daily()` instead.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { startDaily } from "dpdp-kit/schedule";
|
|
34
|
+
* startDaily(dpdp, { at: "03:00", onReport: (r) => r.retention?.failed.length && alert(r) });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function startDaily<P extends string>(dpdp: Dpdp<P>, options?: StartDailyOptions): DailySchedule;
|
package/dist/schedule.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DpdpError
|
|
3
|
+
} from "./chunk-67Q5GFD6.js";
|
|
4
|
+
|
|
5
|
+
// src/schedule.ts
|
|
6
|
+
function msUntil(now, hours, minutes) {
|
|
7
|
+
const next = new Date(now);
|
|
8
|
+
next.setHours(hours, minutes, 0, 0);
|
|
9
|
+
if (next.getTime() <= now.getTime()) next.setDate(next.getDate() + 1);
|
|
10
|
+
return next.getTime() - now.getTime();
|
|
11
|
+
}
|
|
12
|
+
function startDaily(dpdp, options = {}) {
|
|
13
|
+
const at = options.at ?? "03:00";
|
|
14
|
+
const match = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(at);
|
|
15
|
+
if (!match) throw new DpdpError("invalid-input", `at must be "HH:MM" in 24-hour time, e.g. "03:00"; got ${JSON.stringify(at)}`);
|
|
16
|
+
const [hours, minutes] = [Number(match[1]), Number(match[2])];
|
|
17
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
18
|
+
const onError = options.onError ?? ((err) => console.error("dpdp-kit: the daily run failed", err));
|
|
19
|
+
let timer;
|
|
20
|
+
let running;
|
|
21
|
+
let stopped = false;
|
|
22
|
+
let next = new Date(now().getTime() + msUntil(now(), hours, minutes));
|
|
23
|
+
let reviewedUntil;
|
|
24
|
+
const MAX_CATCH_UP_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
25
|
+
async function run() {
|
|
26
|
+
if (running) return void 0;
|
|
27
|
+
running = (async () => {
|
|
28
|
+
try {
|
|
29
|
+
const catchUp = reviewedUntil && now().getTime() - Date.parse(reviewedUntil) <= MAX_CATCH_UP_MS ? reviewedUntil : void 0;
|
|
30
|
+
const report = await dpdp.daily(catchUp ? { review: { from: catchUp } } : {});
|
|
31
|
+
if (report.review) reviewedUntil = report.review.to;
|
|
32
|
+
for (const failure of report.errors ?? []) onError(failure.error);
|
|
33
|
+
await options.onReport?.(report);
|
|
34
|
+
return report;
|
|
35
|
+
} catch (err) {
|
|
36
|
+
onError(err);
|
|
37
|
+
return void 0;
|
|
38
|
+
} finally {
|
|
39
|
+
running = void 0;
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
return running;
|
|
43
|
+
}
|
|
44
|
+
function arm() {
|
|
45
|
+
if (stopped) return;
|
|
46
|
+
const wait = msUntil(now(), hours, minutes);
|
|
47
|
+
next = new Date(now().getTime() + wait);
|
|
48
|
+
timer = setTimeout(() => {
|
|
49
|
+
void run().finally(arm);
|
|
50
|
+
}, wait);
|
|
51
|
+
timer.unref?.();
|
|
52
|
+
}
|
|
53
|
+
arm();
|
|
54
|
+
return {
|
|
55
|
+
runNow: run,
|
|
56
|
+
nextRunAt: () => next,
|
|
57
|
+
stop() {
|
|
58
|
+
stopped = true;
|
|
59
|
+
if (timer) clearTimeout(timer);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
msUntil,
|
|
65
|
+
startDaily
|
|
66
|
+
};
|
package/dist/schema-check.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Issue } from "./audit.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type DpdpConfig } from "./config.js";
|
|
3
3
|
/** A column as your ORM sees it: its database name, and the property name in code if different. */
|
|
4
4
|
export interface SchemaColumn {
|
|
5
5
|
name: string;
|
|
6
6
|
key?: string;
|
|
7
|
+
/** The column rejects NULL. Used to check each field's `erase` setting. */
|
|
8
|
+
notNull?: boolean;
|
|
9
|
+
/** Kind of value the column holds, when known. Used to check each field's `erase` setting. */
|
|
10
|
+
type?: "string" | "number" | "boolean" | "other";
|
|
7
11
|
}
|
|
8
12
|
export interface SchemaTable {
|
|
9
13
|
name: string;
|
|
@@ -13,10 +17,4 @@ export interface SchemaTable {
|
|
|
13
17
|
export interface Schema {
|
|
14
18
|
tables: readonly SchemaTable[];
|
|
15
19
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Compare the data map with the real schema, both ways:
|
|
18
|
-
* - columns that look personal but aren't in the data map (strong guesses are errors, weak ones
|
|
19
|
-
* warnings), so a new `phone` column can't ship without a purpose;
|
|
20
|
-
* - data map entries whose table or column no longer exists, so the map can't go stale.
|
|
21
|
-
*/
|
|
22
20
|
export declare function checkSchema(config: DpdpConfig<string>, schema: Schema): Issue[];
|
package/dist/store.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AccessEntry, AccessLogStore } from "./access.js";
|
|
1
2
|
import type { NoticeLanguage } from "./languages.js";
|
|
2
3
|
import { type ErasureTask, type RequestStore, type RightsRequest, type TaskStore } from "./records.js";
|
|
3
4
|
export type ConsentAction = "grant" | "withdraw";
|
|
@@ -38,8 +39,14 @@ export type DpdpStore = ConsentStore & RequestStore & TaskStore;
|
|
|
38
39
|
/** Whether a store can keep rights requests and erasure tasks too (custom stores may not). */
|
|
39
40
|
export declare function isDpdpStore(store: ConsentStore): store is DpdpStore;
|
|
40
41
|
/** Keeps everything in memory. For tests and trying the library out; everything is lost on restart. */
|
|
41
|
-
export declare function memoryStore(): DpdpStore & {
|
|
42
|
+
export declare function memoryStore(): DpdpStore & AccessLogStore & {
|
|
42
43
|
readonly all: Map<string, ConsentEvent[]>;
|
|
43
44
|
readonly requests: Map<string, RightsRequest>;
|
|
44
45
|
readonly tasks: Map<string, ErasureTask>;
|
|
46
|
+
readonly accessLog: AccessEntry[];
|
|
45
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Purposes whose latest event is a grant: the person's consent state. Pass `until` (ISO 8601) for
|
|
50
|
+
* the state at that moment, counting only events at or before it.
|
|
51
|
+
*/
|
|
52
|
+
export declare function grantedPurposes(events: readonly ConsentEvent[], until?: string): Set<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dpdp-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Build India's DPDP Act 2023 into your Node.js backend: declared purposes, tamper-evident consent records, erasure plans and an audit you can run in CI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dpdp",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "git+https://github.com/yogesh2902/dpdp-kit.git"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://github.
|
|
22
|
+
"homepage": "https://yogesh2902.github.io/dpdp-kit/",
|
|
23
23
|
"bugs": {
|
|
24
24
|
"url": "https://github.com/yogesh2902/dpdp-kit/issues"
|
|
25
25
|
},
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"packageManager": "pnpm@12.15.0",
|
|
32
32
|
"files": [
|
|
33
|
-
"dist"
|
|
33
|
+
"dist",
|
|
34
|
+
"CHANGELOG.md"
|
|
34
35
|
],
|
|
35
36
|
"bin": {
|
|
36
37
|
"dpdp-kit": "dist/cli.js"
|
|
@@ -52,13 +53,30 @@
|
|
|
52
53
|
"types": "./dist/hono.d.ts",
|
|
53
54
|
"default": "./dist/hono.js"
|
|
54
55
|
},
|
|
56
|
+
"./fastify": {
|
|
57
|
+
"types": "./dist/fastify.d.ts",
|
|
58
|
+
"default": "./dist/fastify.js"
|
|
59
|
+
},
|
|
60
|
+
"./nestjs": {
|
|
61
|
+
"types": "./dist/nestjs.d.ts",
|
|
62
|
+
"default": "./dist/nestjs.js"
|
|
63
|
+
},
|
|
64
|
+
"./schedule": {
|
|
65
|
+
"types": "./dist/schedule.d.ts",
|
|
66
|
+
"default": "./dist/schedule.js"
|
|
67
|
+
},
|
|
68
|
+
"./protect": {
|
|
69
|
+
"types": "./dist/protect.d.ts",
|
|
70
|
+
"default": "./dist/protect.js"
|
|
71
|
+
},
|
|
55
72
|
"./package.json": "./package.json"
|
|
56
73
|
},
|
|
57
74
|
"scripts": {
|
|
58
75
|
"build": "tsup && tsc -p tsconfig.build.json",
|
|
59
76
|
"typecheck": "tsc --noEmit",
|
|
60
77
|
"test": "vitest run",
|
|
61
|
-
"prepublishOnly": "pnpm typecheck && pnpm test && pnpm build"
|
|
78
|
+
"prepublishOnly": "pnpm typecheck && pnpm test && pnpm build",
|
|
79
|
+
"site": "node site/build.mjs"
|
|
62
80
|
},
|
|
63
81
|
"peerDependencies": {
|
|
64
82
|
"drizzle-orm": ">=0.38"
|
|
@@ -73,8 +91,21 @@
|
|
|
73
91
|
},
|
|
74
92
|
"devDependencies": {
|
|
75
93
|
"@electric-sql/pglite": "^0.5.16",
|
|
94
|
+
"@nestjs/common": "^12.5.1",
|
|
95
|
+
"@nestjs/core": "^12.5.1",
|
|
96
|
+
"@nestjs/platform-express": "^12.5.1",
|
|
97
|
+
"@types/express": "^5.0.6",
|
|
76
98
|
"@types/node": "^26.6.6",
|
|
99
|
+
"@types/pg": "^8.23.1",
|
|
77
100
|
"drizzle-orm": "^0.45.4",
|
|
101
|
+
"express": "^5.3.0",
|
|
102
|
+
"fastify": "^5.12.8",
|
|
103
|
+
"hono": "^4.13.19",
|
|
104
|
+
"marked": "^18.2.1",
|
|
105
|
+
"pg": "^8.23.1",
|
|
106
|
+
"reflect-metadata": "^0.2.2",
|
|
107
|
+
"rxjs": "^7.8.2",
|
|
108
|
+
"shiki": "^4.6.0",
|
|
78
109
|
"tsup": "^9.0.0",
|
|
79
110
|
"typescript": "^7.0.2",
|
|
80
111
|
"vitest": "^5.1.0"
|
package/dist/chunk-FGZAH2NF.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// src/guard.ts
|
|
2
|
-
var CONSENT_REQUIRED_BODY = (purpose) => ({
|
|
3
|
-
error: "consent_required",
|
|
4
|
-
purpose,
|
|
5
|
-
message: "You haven't agreed to this yet. You can turn it on in your privacy settings."
|
|
6
|
-
});
|
|
7
|
-
async function checkConsent(dpdp, purpose, options, ctx) {
|
|
8
|
-
const subjectId = await options.subject(ctx);
|
|
9
|
-
if (!subjectId) return false;
|
|
10
|
-
return dpdp.consent.has(subjectId, purpose);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
CONSENT_REQUIRED_BODY,
|
|
15
|
-
checkConsent
|
|
16
|
-
};
|