dpdpstack-js-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -0
- package/dist/dpdpstack.global.js +2 -0
- package/dist/dpdpstack.global.js.map +1 -0
- package/dist/index.cjs +325 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +539 -0
- package/dist/index.d.ts +539 -0
- package/dist/index.js +319 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response shapes for the DPDPStack HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* The SDK mirrors the wire format (snake_case) exactly, so these types double as
|
|
5
|
+
* documentation and line up 1:1 with the curl examples in the docs. Free-form
|
|
6
|
+
* maps (`metadata`, `payload`, `translations`) are intentionally `Record<…>`.
|
|
7
|
+
*/
|
|
8
|
+
/** ISO-8601 timestamp string, or null when not yet set. */
|
|
9
|
+
type Timestamp = string;
|
|
10
|
+
type Nullable<T> = T | null;
|
|
11
|
+
interface LocalizedNotice {
|
|
12
|
+
name?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
interface Purpose {
|
|
16
|
+
code: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
/** Per-locale notice overrides, e.g. `{ hi: { name, description } }`. */
|
|
20
|
+
translations: Record<string, LocalizedNotice>;
|
|
21
|
+
active: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface PurposeInput {
|
|
24
|
+
code: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
translations?: Record<string, LocalizedNotice>;
|
|
28
|
+
active?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface ConsentGrantInput {
|
|
31
|
+
/** Your opaque user id (an internal id or hash) — never PII. */
|
|
32
|
+
principal_ref: string;
|
|
33
|
+
/** Purpose `code` to record consent for. */
|
|
34
|
+
purpose: string;
|
|
35
|
+
locale?: string;
|
|
36
|
+
/** Arbitrary metadata stored on the audit receipt (kept verbatim). */
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
interface ConsentReceipt {
|
|
40
|
+
/** Hash of the immutable audit entry — the consent receipt id. */
|
|
41
|
+
receipt_id: string;
|
|
42
|
+
audit_sequence: number;
|
|
43
|
+
principal_ref: string;
|
|
44
|
+
purpose: string;
|
|
45
|
+
status: string;
|
|
46
|
+
granted_at: Nullable<Timestamp>;
|
|
47
|
+
/** The exact notice text shown to the principal, in the chosen locale. */
|
|
48
|
+
notice_shown: Required<LocalizedNotice>;
|
|
49
|
+
}
|
|
50
|
+
interface ConsentWithdrawInput {
|
|
51
|
+
principal_ref: string;
|
|
52
|
+
purpose: string;
|
|
53
|
+
}
|
|
54
|
+
/** Outcome of an erasure resolution (fires now, or defers under a legal hold). */
|
|
55
|
+
interface ErasureOutcome {
|
|
56
|
+
status: string;
|
|
57
|
+
action?: string;
|
|
58
|
+
legal_basis?: string;
|
|
59
|
+
erase_after?: Nullable<Timestamp>;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
interface ConsentWithdrawResult {
|
|
63
|
+
principal_ref: string;
|
|
64
|
+
purpose: string;
|
|
65
|
+
status: string;
|
|
66
|
+
withdrawn_at: Nullable<Timestamp>;
|
|
67
|
+
erasure: ErasureOutcome;
|
|
68
|
+
}
|
|
69
|
+
interface ConsentStatusEntry {
|
|
70
|
+
purpose: string;
|
|
71
|
+
status: string;
|
|
72
|
+
granted_at: Nullable<Timestamp>;
|
|
73
|
+
withdrawn_at: Nullable<Timestamp>;
|
|
74
|
+
}
|
|
75
|
+
interface ConsentStatus {
|
|
76
|
+
principal_ref: string;
|
|
77
|
+
consents: ConsentStatusEntry[];
|
|
78
|
+
}
|
|
79
|
+
interface ConsentRecordSummary {
|
|
80
|
+
principal_ref: string;
|
|
81
|
+
purpose: string;
|
|
82
|
+
status: string;
|
|
83
|
+
granted_at: Nullable<Timestamp>;
|
|
84
|
+
withdrawn_at: Nullable<Timestamp>;
|
|
85
|
+
}
|
|
86
|
+
interface ErasureInput {
|
|
87
|
+
principal_ref: string;
|
|
88
|
+
}
|
|
89
|
+
interface ErasureResult {
|
|
90
|
+
principal_ref: string;
|
|
91
|
+
status: string;
|
|
92
|
+
results: Array<{
|
|
93
|
+
purpose: string;
|
|
94
|
+
} & ErasureOutcome>;
|
|
95
|
+
}
|
|
96
|
+
interface ErasureConfirmResult {
|
|
97
|
+
status: string;
|
|
98
|
+
target: string;
|
|
99
|
+
}
|
|
100
|
+
interface AuditEntry {
|
|
101
|
+
sequence: number;
|
|
102
|
+
event_type: string;
|
|
103
|
+
principal_ref: string;
|
|
104
|
+
payload: Record<string, unknown>;
|
|
105
|
+
prev_hash: string;
|
|
106
|
+
entry_hash: string;
|
|
107
|
+
created_at: Timestamp;
|
|
108
|
+
}
|
|
109
|
+
interface AuditLog {
|
|
110
|
+
/** Whether the hash chain still verifies end-to-end. */
|
|
111
|
+
chain_verified: boolean;
|
|
112
|
+
count: number;
|
|
113
|
+
entries: AuditEntry[];
|
|
114
|
+
}
|
|
115
|
+
type RetentionTrigger = "consent_withdrawn" | "inactivity" | "fixed_period" | string;
|
|
116
|
+
type ErasureAction = "delete" | "anonymize";
|
|
117
|
+
interface RetentionPolicy {
|
|
118
|
+
purpose: string;
|
|
119
|
+
retention_days: number;
|
|
120
|
+
trigger: RetentionTrigger;
|
|
121
|
+
notice_hours_before: number;
|
|
122
|
+
erasure_action: ErasureAction;
|
|
123
|
+
legal_hold_days: number;
|
|
124
|
+
legal_basis: string;
|
|
125
|
+
active: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface RetentionPolicyInput {
|
|
128
|
+
purpose: string;
|
|
129
|
+
retention_days: number;
|
|
130
|
+
trigger?: RetentionTrigger;
|
|
131
|
+
notice_hours_before?: number;
|
|
132
|
+
erasure_action?: ErasureAction;
|
|
133
|
+
legal_hold_days?: number;
|
|
134
|
+
legal_basis?: string;
|
|
135
|
+
active?: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface RetentionRunResult {
|
|
138
|
+
dry_run: boolean;
|
|
139
|
+
[key: string]: unknown;
|
|
140
|
+
}
|
|
141
|
+
interface ActivityInput {
|
|
142
|
+
principal_ref: string;
|
|
143
|
+
purpose?: string;
|
|
144
|
+
}
|
|
145
|
+
interface ActivityResult {
|
|
146
|
+
updated: number;
|
|
147
|
+
last_activity_at: Timestamp;
|
|
148
|
+
}
|
|
149
|
+
/** The certificate payload (subject, status, action, legal_basis, chain_verified, …). */
|
|
150
|
+
type CertificatePayload = Record<string, unknown>;
|
|
151
|
+
interface IssueCertificateInput {
|
|
152
|
+
principal_ref: string;
|
|
153
|
+
purpose?: string;
|
|
154
|
+
}
|
|
155
|
+
interface IssuedCertificate {
|
|
156
|
+
certificate_jwt: string;
|
|
157
|
+
fingerprint: string;
|
|
158
|
+
issued_at: Timestamp;
|
|
159
|
+
payload: CertificatePayload;
|
|
160
|
+
public_key_url: string;
|
|
161
|
+
verify_url: string;
|
|
162
|
+
}
|
|
163
|
+
interface CertificateVerifyResult {
|
|
164
|
+
valid: boolean;
|
|
165
|
+
error?: string;
|
|
166
|
+
issuer?: string;
|
|
167
|
+
fingerprint?: string;
|
|
168
|
+
in_registry?: boolean;
|
|
169
|
+
revoked?: boolean;
|
|
170
|
+
payload?: CertificatePayload;
|
|
171
|
+
}
|
|
172
|
+
interface CertificatePublicKey {
|
|
173
|
+
issuer: string;
|
|
174
|
+
algorithm: string;
|
|
175
|
+
public_key_pem: string;
|
|
176
|
+
}
|
|
177
|
+
interface CertificateRegistryResult {
|
|
178
|
+
found: boolean;
|
|
179
|
+
fingerprint?: string;
|
|
180
|
+
status?: string;
|
|
181
|
+
issued_at?: Timestamp;
|
|
182
|
+
revoked?: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface IssueEvidenceCertificateInput {
|
|
185
|
+
subject: string;
|
|
186
|
+
purpose?: string;
|
|
187
|
+
source?: string;
|
|
188
|
+
}
|
|
189
|
+
interface EvidenceIngestInput {
|
|
190
|
+
/** SDK-pushed hash-chain entries (each needs at least `sequence` + `entry_hash`). */
|
|
191
|
+
entries: Array<Record<string, unknown>>;
|
|
192
|
+
source?: string;
|
|
193
|
+
}
|
|
194
|
+
interface EvidenceIngestResult {
|
|
195
|
+
source: string;
|
|
196
|
+
stored: number;
|
|
197
|
+
total: number;
|
|
198
|
+
chain_verified: boolean;
|
|
199
|
+
}
|
|
200
|
+
interface EvidenceEntry {
|
|
201
|
+
sequence: number;
|
|
202
|
+
event_type: string;
|
|
203
|
+
subject: string;
|
|
204
|
+
payload: Record<string, unknown>;
|
|
205
|
+
entry_hash: string;
|
|
206
|
+
source_timestamp: Nullable<Timestamp>;
|
|
207
|
+
received_at: Timestamp;
|
|
208
|
+
}
|
|
209
|
+
interface EvidenceListResult {
|
|
210
|
+
source: string;
|
|
211
|
+
chain_verified: boolean;
|
|
212
|
+
total: number;
|
|
213
|
+
entries: EvidenceEntry[];
|
|
214
|
+
}
|
|
215
|
+
interface EvidenceListQuery {
|
|
216
|
+
source?: string;
|
|
217
|
+
subject?: string;
|
|
218
|
+
}
|
|
219
|
+
type DSRRequestType = "access" | "correction" | "erasure" | "nomination" | "grievance";
|
|
220
|
+
type DSRStatus = "received" | "in_progress" | "completed" | "rejected" | "extended";
|
|
221
|
+
type DSRAction = "acknowledge" | "start" | "complete" | "reject" | "extend";
|
|
222
|
+
interface DSR {
|
|
223
|
+
id: number;
|
|
224
|
+
principal_ref: string;
|
|
225
|
+
request_type: DSRRequestType;
|
|
226
|
+
status: DSRStatus;
|
|
227
|
+
detail: string;
|
|
228
|
+
response: string;
|
|
229
|
+
sla_days: number;
|
|
230
|
+
received_at: Timestamp;
|
|
231
|
+
deadline_at: Nullable<Timestamp>;
|
|
232
|
+
acknowledged_at: Nullable<Timestamp>;
|
|
233
|
+
completed_at: Nullable<Timestamp>;
|
|
234
|
+
is_overdue: boolean;
|
|
235
|
+
days_remaining: Nullable<number>;
|
|
236
|
+
}
|
|
237
|
+
interface DSRCreateInput {
|
|
238
|
+
principal_ref: string;
|
|
239
|
+
request_type: DSRRequestType;
|
|
240
|
+
detail?: string;
|
|
241
|
+
sla_days?: number;
|
|
242
|
+
}
|
|
243
|
+
interface DSRActionInput {
|
|
244
|
+
action: DSRAction;
|
|
245
|
+
/** Used by `complete`/`reject`. */
|
|
246
|
+
response?: string;
|
|
247
|
+
/** Used by `extend` (default 30). */
|
|
248
|
+
extra_days?: number;
|
|
249
|
+
}
|
|
250
|
+
interface DSRListQuery {
|
|
251
|
+
status?: DSRStatus;
|
|
252
|
+
request_type?: DSRRequestType;
|
|
253
|
+
principal_ref?: string;
|
|
254
|
+
overdue?: boolean;
|
|
255
|
+
}
|
|
256
|
+
type BreachSeverity = "low" | "medium" | "high" | "critical";
|
|
257
|
+
type BreachStatus = "reported" | "investigating" | "contained" | "notified" | "closed";
|
|
258
|
+
type BreachAction = "investigate" | "contain" | "notify_board" | "notify_principals" | "close";
|
|
259
|
+
interface Breach {
|
|
260
|
+
id: number;
|
|
261
|
+
title: string;
|
|
262
|
+
description: string;
|
|
263
|
+
severity: BreachSeverity;
|
|
264
|
+
status: BreachStatus;
|
|
265
|
+
nature: string;
|
|
266
|
+
affected_count: number;
|
|
267
|
+
measures: string;
|
|
268
|
+
discovered_at: Timestamp;
|
|
269
|
+
occurred_at: Nullable<Timestamp>;
|
|
270
|
+
notified_board_at: Nullable<Timestamp>;
|
|
271
|
+
notified_principals_at: Nullable<Timestamp>;
|
|
272
|
+
}
|
|
273
|
+
interface BreachReportInput {
|
|
274
|
+
title: string;
|
|
275
|
+
description?: string;
|
|
276
|
+
severity?: BreachSeverity;
|
|
277
|
+
nature?: string;
|
|
278
|
+
affected_count?: number;
|
|
279
|
+
measures?: string;
|
|
280
|
+
occurred_at?: Nullable<Timestamp>;
|
|
281
|
+
}
|
|
282
|
+
interface BreachActionInput {
|
|
283
|
+
action: BreachAction;
|
|
284
|
+
measures?: string;
|
|
285
|
+
}
|
|
286
|
+
interface BreachListQuery {
|
|
287
|
+
status?: BreachStatus;
|
|
288
|
+
severity?: BreachSeverity;
|
|
289
|
+
}
|
|
290
|
+
/** Draft Board + data-principal breach notices generated from the incident. */
|
|
291
|
+
type BreachNotifications = Record<string, unknown>;
|
|
292
|
+
interface Target {
|
|
293
|
+
id: number;
|
|
294
|
+
name: string;
|
|
295
|
+
url: string;
|
|
296
|
+
active: boolean;
|
|
297
|
+
created_at: Timestamp;
|
|
298
|
+
}
|
|
299
|
+
interface TargetCreateInput {
|
|
300
|
+
name: string;
|
|
301
|
+
url: string;
|
|
302
|
+
active?: boolean;
|
|
303
|
+
}
|
|
304
|
+
/** Target create response — includes the signing `secret`, returned only once. */
|
|
305
|
+
interface TargetWithSecret extends Target {
|
|
306
|
+
secret: string;
|
|
307
|
+
}
|
|
308
|
+
interface TargetUpdateInput {
|
|
309
|
+
name?: string;
|
|
310
|
+
url?: string;
|
|
311
|
+
active?: boolean;
|
|
312
|
+
}
|
|
313
|
+
interface ErasureTask {
|
|
314
|
+
id: number;
|
|
315
|
+
target: string;
|
|
316
|
+
principal_ref: string;
|
|
317
|
+
purpose: string;
|
|
318
|
+
action: string;
|
|
319
|
+
reason: string;
|
|
320
|
+
status: string;
|
|
321
|
+
status_code: Nullable<number>;
|
|
322
|
+
error: string;
|
|
323
|
+
created_at: Timestamp;
|
|
324
|
+
delivered_at: Nullable<Timestamp>;
|
|
325
|
+
confirmed_at: Nullable<Timestamp>;
|
|
326
|
+
}
|
|
327
|
+
interface ErasureTaskListQuery {
|
|
328
|
+
principal_ref?: string;
|
|
329
|
+
status?: string;
|
|
330
|
+
target?: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare const DEFAULT_API_BASE = "https://getdpdp.net/api/v1";
|
|
334
|
+
interface DPDPStackOptions {
|
|
335
|
+
/**
|
|
336
|
+
* API key. A **secret** key (`dpdp_sk_…`) for server-side use, or a
|
|
337
|
+
* **publishable** key (`dpdp_pk_…`) — the only kind safe to ship to a browser,
|
|
338
|
+
* limited to reading purposes and recording consent. Omit for public-only
|
|
339
|
+
* calls (certificate verify/registry/public-key).
|
|
340
|
+
*/
|
|
341
|
+
apiKey?: string;
|
|
342
|
+
/** API base URL. Default `https://getdpdp.net/api/v1`. Use a relative path (e.g. `/api/v1`) to call a same-origin proxy. */
|
|
343
|
+
apiBase?: string;
|
|
344
|
+
/** Custom fetch implementation (for Node < 18, testing, or proxies). Defaults to the global `fetch`. */
|
|
345
|
+
fetch?: typeof fetch;
|
|
346
|
+
/** Extra headers sent with every request. */
|
|
347
|
+
headers?: Record<string, string>;
|
|
348
|
+
/** `fetch` credentials mode (e.g. `"include"` to send cookies). Default: unset. */
|
|
349
|
+
credentials?: RequestCredentials;
|
|
350
|
+
}
|
|
351
|
+
/** Thrown for any non-2xx API response. */
|
|
352
|
+
declare class DPDPError extends Error {
|
|
353
|
+
readonly status: number;
|
|
354
|
+
readonly detail: string;
|
|
355
|
+
readonly body: unknown;
|
|
356
|
+
constructor(status: number, detail: string, body: unknown);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Thin, typed client for the DPDPStack API.
|
|
360
|
+
*
|
|
361
|
+
* ```ts
|
|
362
|
+
* const dpdp = new DPDPStack({ apiKey: "dpdp_sk_…" });
|
|
363
|
+
* await dpdp.grantConsent({ principal_ref: "user_42", purpose: "marketing" });
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
declare class DPDPStack {
|
|
367
|
+
private readonly apiBase;
|
|
368
|
+
private readonly apiKey?;
|
|
369
|
+
private readonly fetchImpl;
|
|
370
|
+
private readonly defaultHeaders;
|
|
371
|
+
private readonly credentials?;
|
|
372
|
+
constructor(options?: DPDPStackOptions);
|
|
373
|
+
/** Low-level request. Most callers use the typed methods below. */
|
|
374
|
+
request<T>(method: string, path: string, opts?: {
|
|
375
|
+
query?: object;
|
|
376
|
+
body?: unknown;
|
|
377
|
+
}): Promise<T>;
|
|
378
|
+
/** List consent purposes (with multilingual notices). Publishable-key safe. */
|
|
379
|
+
listPurposes(): Promise<Purpose[]>;
|
|
380
|
+
/** Create a consent purpose. Requires a secret key. */
|
|
381
|
+
createPurpose(input: PurposeInput): Promise<Purpose>;
|
|
382
|
+
/** Record purpose-level consent and get an immutable receipt. Publishable-key safe. */
|
|
383
|
+
grantConsent(input: ConsentGrantInput): Promise<ConsentReceipt>;
|
|
384
|
+
/** Withdraw consent for a purpose (triggers erasure/deferral). Requires a secret key. */
|
|
385
|
+
withdrawConsent(input: ConsentWithdrawInput): Promise<ConsentWithdrawResult>;
|
|
386
|
+
/** Current consent state for a principal. Requires a secret key. */
|
|
387
|
+
consentStatus(principalRef: string): Promise<ConsentStatus>;
|
|
388
|
+
/** List the organization's consent records (latest first). Requires a secret key. */
|
|
389
|
+
listConsentRecords(): Promise<ConsentRecordSummary[]>;
|
|
390
|
+
/** Record principal activity, resetting inactivity-based retention. Requires a secret key. */
|
|
391
|
+
recordActivity(input: ActivityInput): Promise<ActivityResult>;
|
|
392
|
+
/** Right to erasure: resolve erasure across the principal's purposes. Requires a secret key. */
|
|
393
|
+
requestErasure(input: ErasureInput): Promise<ErasureResult>;
|
|
394
|
+
/** Confirm a downstream erasure with the token delivered to that system. No API key needed. */
|
|
395
|
+
confirmErasure(token: string): Promise<ErasureConfirmResult>;
|
|
396
|
+
/** Hash-chained audit trail (optionally filtered by principal), plus chain status. Requires a secret key. */
|
|
397
|
+
getAuditLog(query?: {
|
|
398
|
+
principal_ref?: string;
|
|
399
|
+
}): Promise<AuditLog>;
|
|
400
|
+
readonly retention: {
|
|
401
|
+
/** List retention policies. Requires a secret key. */
|
|
402
|
+
list: () => Promise<RetentionPolicy[]>;
|
|
403
|
+
/** Create or update a retention policy. Requires a secret key. */
|
|
404
|
+
upsert: (input: RetentionPolicyInput) => Promise<RetentionPolicy>;
|
|
405
|
+
/** Run the retention sweep now (`{ dry_run: true }` to preview). Requires a secret key. */
|
|
406
|
+
run: (input?: {
|
|
407
|
+
dry_run?: boolean;
|
|
408
|
+
}) => Promise<RetentionRunResult>;
|
|
409
|
+
};
|
|
410
|
+
readonly certificates: {
|
|
411
|
+
/** Issue a counter-signed Certificate of Erasure for a principal. Requires a secret key. */
|
|
412
|
+
issue: (input: IssueCertificateInput) => Promise<IssuedCertificate>;
|
|
413
|
+
/** Verify a Certificate of Erasure (JWT) against the public key. Public — no key needed. */
|
|
414
|
+
verify: (certificateJwt: string) => Promise<CertificateVerifyResult>;
|
|
415
|
+
/** Fetch the issuer public key. Public — no key needed. */
|
|
416
|
+
publicKey: () => Promise<CertificatePublicKey>;
|
|
417
|
+
/** Look up a certificate in the public registry by fingerprint. Public — no key needed. */
|
|
418
|
+
registry: (fingerprint: string) => Promise<CertificateRegistryResult>;
|
|
419
|
+
/** Issue a certificate from SDK-pushed evidence. Requires a secret key. */
|
|
420
|
+
issueFromEvidence: (input: IssueEvidenceCertificateInput) => Promise<IssuedCertificate>;
|
|
421
|
+
};
|
|
422
|
+
readonly evidence: {
|
|
423
|
+
/** Push tamper-evident audit evidence (hash chain) for server-timestamping. Requires a secret key. */
|
|
424
|
+
ingest: (input: EvidenceIngestInput) => Promise<EvidenceIngestResult>;
|
|
425
|
+
/** List stored evidence for a source/subject, with chain status. Requires a secret key. */
|
|
426
|
+
list: (query?: EvidenceListQuery) => Promise<EvidenceListResult>;
|
|
427
|
+
};
|
|
428
|
+
readonly dsr: {
|
|
429
|
+
/** List rights requests (filter by status/type/principal/overdue). Requires a secret key. */
|
|
430
|
+
list: (query?: DSRListQuery) => Promise<DSR[]>;
|
|
431
|
+
/** Create a rights request. Requires a secret key. */
|
|
432
|
+
create: (input: DSRCreateInput) => Promise<DSR>;
|
|
433
|
+
/** Get a single rights request. Requires a secret key. */
|
|
434
|
+
get: (id: number) => Promise<DSR>;
|
|
435
|
+
/** Advance a rights request (acknowledge/start/complete/reject/extend). Requires a secret key. */
|
|
436
|
+
act: (id: number, input: DSRActionInput) => Promise<DSR>;
|
|
437
|
+
};
|
|
438
|
+
readonly breaches: {
|
|
439
|
+
/** List breach incidents. Requires a secret key. */
|
|
440
|
+
list: (query?: BreachListQuery) => Promise<Breach[]>;
|
|
441
|
+
/** Report a breach incident (metadata only — never PII). Requires a secret key. */
|
|
442
|
+
report: (input: BreachReportInput) => Promise<Breach>;
|
|
443
|
+
/** Get a single breach. Requires a secret key. */
|
|
444
|
+
get: (id: number) => Promise<Breach>;
|
|
445
|
+
/** Advance a breach (investigate/contain/notify_board/notify_principals/close). Requires a secret key. */
|
|
446
|
+
act: (id: number, input: BreachActionInput) => Promise<Breach>;
|
|
447
|
+
/** Generate draft Board + principal breach notices. Requires a secret key. */
|
|
448
|
+
notifications: (id: number) => Promise<BreachNotifications>;
|
|
449
|
+
};
|
|
450
|
+
readonly targets: {
|
|
451
|
+
/** List downstream erasure targets. Requires a secret key. */
|
|
452
|
+
list: () => Promise<Target[]>;
|
|
453
|
+
/** Register a target. The signing `secret` is returned only once. Requires a secret key. */
|
|
454
|
+
create: (input: TargetCreateInput) => Promise<TargetWithSecret>;
|
|
455
|
+
/** Get a single target. Requires a secret key. */
|
|
456
|
+
get: (id: number) => Promise<Target>;
|
|
457
|
+
/** Update a target. Requires a secret key. */
|
|
458
|
+
update: (id: number, input: TargetUpdateInput) => Promise<Target>;
|
|
459
|
+
/** Delete a target. Requires a secret key. */
|
|
460
|
+
remove: (id: number) => Promise<void>;
|
|
461
|
+
};
|
|
462
|
+
readonly erasureTasks: {
|
|
463
|
+
/** List per-system erasure fan-out tasks (the propagation evidence). Requires a secret key. */
|
|
464
|
+
list: (query?: ErasureTaskListQuery) => Promise<ErasureTask[]>;
|
|
465
|
+
/** Re-deliver an erasure instruction to a target. Requires a secret key. */
|
|
466
|
+
retry: (id: number) => Promise<ErasureTask>;
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
interface ConsentWidgetTexts {
|
|
471
|
+
heading: string;
|
|
472
|
+
subheading: string;
|
|
473
|
+
save: string;
|
|
474
|
+
saving: string;
|
|
475
|
+
saved: string;
|
|
476
|
+
loading: string;
|
|
477
|
+
error: string;
|
|
478
|
+
}
|
|
479
|
+
interface ConsentWidgetOptions {
|
|
480
|
+
/** Your opaque user id (internal id or hash) — never PII. */
|
|
481
|
+
principalRef: string;
|
|
482
|
+
/** Pre-built client. If omitted, one is built from `apiBase`/`apiKey`. */
|
|
483
|
+
client?: DPDPStack;
|
|
484
|
+
/** Used to build a client when `client` is not supplied. */
|
|
485
|
+
apiBase?: string;
|
|
486
|
+
/** Publishable key (`dpdp_pk_…`). Used to build a client when `client` is not supplied. */
|
|
487
|
+
apiKey?: string;
|
|
488
|
+
/** Purposes to render. If omitted, they're fetched via `client.listPurposes()`. */
|
|
489
|
+
purposes?: Purpose[];
|
|
490
|
+
/** Initial locale for notice text. Default `"en"`. */
|
|
491
|
+
locale?: string;
|
|
492
|
+
/** Purpose codes checked on first render. */
|
|
493
|
+
defaultChecked?: string[];
|
|
494
|
+
/** Override any UI strings. */
|
|
495
|
+
texts?: Partial<ConsentWidgetTexts>;
|
|
496
|
+
/** Called with the receipts after a successful save. */
|
|
497
|
+
onSave?: (receipts: ConsentReceipt[]) => void;
|
|
498
|
+
/** Called if loading purposes or saving fails. */
|
|
499
|
+
onError?: (error: unknown) => void;
|
|
500
|
+
}
|
|
501
|
+
interface ConsentWidgetController {
|
|
502
|
+
/** Switch the notice language and re-render. */
|
|
503
|
+
setLocale(locale: string): void;
|
|
504
|
+
/** Re-fetch purposes (when not passed in) and re-render. */
|
|
505
|
+
refresh(): Promise<void>;
|
|
506
|
+
/** Remove the widget from the DOM. */
|
|
507
|
+
destroy(): void;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Mount a drop-in consent capture widget. Returns a controller for switching
|
|
511
|
+
* locale, refreshing, or removing it.
|
|
512
|
+
*
|
|
513
|
+
* ```ts
|
|
514
|
+
* mountConsentWidget("#consent", {
|
|
515
|
+
* apiBase: "/api/v1",
|
|
516
|
+
* apiKey: "dpdp_pk_…", // publishable key
|
|
517
|
+
* principalRef: "user_123",
|
|
518
|
+
* });
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
declare function mountConsentWidget(target: string | HTMLElement, options: ConsentWidgetOptions): ConsentWidgetController;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Backward-compatible shim for the original `DPDPConsent.init({ el, … })`
|
|
525
|
+
* script-tag widget. Prefer {@link mountConsentWidget} in new code.
|
|
526
|
+
*/
|
|
527
|
+
declare const DPDPConsent: {
|
|
528
|
+
init(config: {
|
|
529
|
+
el: string | HTMLElement;
|
|
530
|
+
apiBase?: string;
|
|
531
|
+
apiKey?: string;
|
|
532
|
+
principalRef: string;
|
|
533
|
+
locale?: string;
|
|
534
|
+
purposes?: Purpose[];
|
|
535
|
+
onSave?: (receipts: ConsentReceipt[]) => void;
|
|
536
|
+
}): ConsentWidgetController;
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
export { type ActivityInput, type ActivityResult, type AuditEntry, type AuditLog, type Breach, type BreachAction, type BreachActionInput, type BreachListQuery, type BreachNotifications, type BreachReportInput, type BreachSeverity, type BreachStatus, type CertificatePayload, type CertificatePublicKey, type CertificateRegistryResult, type CertificateVerifyResult, type ConsentGrantInput, type ConsentReceipt, type ConsentRecordSummary, type ConsentStatus, type ConsentStatusEntry, type ConsentWidgetController, type ConsentWidgetOptions, type ConsentWidgetTexts, type ConsentWithdrawInput, type ConsentWithdrawResult, DEFAULT_API_BASE, DPDPConsent, DPDPError, DPDPStack, type DPDPStackOptions, type DSR, type DSRAction, type DSRActionInput, type DSRCreateInput, type DSRListQuery, type DSRRequestType, type DSRStatus, type ErasureAction, type ErasureConfirmResult, type ErasureInput, type ErasureOutcome, type ErasureResult, type ErasureTask, type ErasureTaskListQuery, type EvidenceEntry, type EvidenceIngestInput, type EvidenceIngestResult, type EvidenceListQuery, type EvidenceListResult, type IssueCertificateInput, type IssueEvidenceCertificateInput, type IssuedCertificate, type LocalizedNotice, type Nullable, type Purpose, type PurposeInput, type RetentionPolicy, type RetentionPolicyInput, type RetentionRunResult, type RetentionTrigger, type Target, type TargetCreateInput, type TargetUpdateInput, type TargetWithSecret, type Timestamp, mountConsentWidget };
|