@powerhousedao/reactor-privacy 6.2.3-dev.100

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 ADDED
@@ -0,0 +1,87 @@
1
+ # @powerhousedao/reactor-privacy
2
+
3
+ GDPR add-on for the Powerhouse reactor. It keeps its own migration ledger
4
+ (`kysely_migration_reactor_privacy`) in the reactor schema and owns:
5
+
6
+ - `erasure_requests`, `erasure_items`, `erasure_audit` (append-only): the
7
+ erasure request ledger;
8
+ - `subject_documents`: an index from `HMAC-SHA256(deploymentSecret,
9
+ lower(identifier))` to the documents an identifier appears in, maintained by
10
+ `SubjectDocumentsReadModel`, a fenced read model over the reactor handle;
11
+ - `DisclosureService.disclose(identifier)`: the index rows plus the sync
12
+ remotes bound to the address, peer manifests announcing the key, and the
13
+ permission rows a host-supplied `IPermissionRowsLookup` returns. The response
14
+ lists what it does not cover.
15
+
16
+ The host registers it after the reactor is built:
17
+
18
+ ```ts
19
+ await registerSubjectDocumentsReadModel(reactorModule, { deploymentSecret });
20
+ const disclosure = new DisclosureService(
21
+ reactorModule.database,
22
+ deploymentSecret,
23
+ permissionLookup,
24
+ );
25
+ ```
26
+
27
+ Identifiers match case-insensitively. A header key is indexed as the did:key
28
+ of its P-256 JWK, the same form an app key takes. Rotating the deployment
29
+ secret requires rebuilding the index.
30
+
31
+ ## Erasure
32
+
33
+ `createModuleErasure(reactorModule, { deploymentSecret, signer, permissions })`
34
+ returns an `ErasureService` (`plan`, `request`, `status`) and an
35
+ `ErasureScheduler`; call `scheduler.start()` and, on shutdown,
36
+ `await scheduler.stop()`. The scheduler refuses to exist without a signer
37
+ carrying an app key, because every receiver refuses an unsigned marker.
38
+ `permissions` is an `IDocumentPermissionEraser`; reactor-api's
39
+ `PrivacyPermissionAdapter` implements it and `IPermissionRowsLookup`.
40
+
41
+ Each tick (60 s by default) moves items `waiting -> purging -> purged ->
42
+ erased`, one purge at a time across every request, a drive only after its
43
+ members. `document_purges` is the only success signal. Remotes bound to a
44
+ purged drive and the document's permission rows are removed only after the
45
+ marker converged or `markerGrace` (7 days) passed. Operator documentation:
46
+ academy, Reference, Reactor, Document erasure.
47
+
48
+ ## Admin subgraph
49
+
50
+ `createPrivacySubgraph` returns the typeDefs and resolvers of an admin-only
51
+ subgraph: queries `disclose(identifier)`, `erasurePlan(ids)`,
52
+ `erasureRequest(requestId)` and the mutation
53
+ `requestErasure(ids, deadline, allowLarge)`. Every field refuses, before any
54
+ work, a caller whose `ctx.user.address` is missing or is not a supreme admin
55
+ (`FORBIDDEN`, "Admin access required"). `requestErasure` passes the caller's
56
+ address to `IErasureService.request` as `requestedBy`; hashing it for storage
57
+ is the service's job.
58
+
59
+ Under `AuthorizationPolicy.OPEN` every caller, anonymous included, is a
60
+ supreme admin, so the factory throws `PrivacySubgraphOpenPolicyError` rather
61
+ than return a subgraph. It throws for any authorization service that answers
62
+ `isSupremeAdmin` true for an anonymous caller. The authenticated-caller floor
63
+ is not a substitute. A host that wants to boot anyway catches the error and
64
+ does not register the subgraph.
65
+
66
+ The package does not depend on reactor-api: the authorization service is typed
67
+ structurally (`config.policy`, `isSupremeAdmin`), so reactor-api's
68
+ `IAuthorizationService` is passed unchanged. The host registers the result as
69
+ a late subgraph, as switchboard does for reactor-drive:
70
+
71
+ ```ts
72
+ const privacySubgraph = createPrivacySubgraph({
73
+ authorizationService: graphqlManager.getAuthorizationService(),
74
+ erasure, // an IErasureService
75
+ disclosure, // a DisclosureService
76
+ });
77
+ await graphqlManager.registerSubgraphInstance(
78
+ {
79
+ ...privacySubgraph,
80
+ path: graphqlManager.getBasePath(),
81
+ reactorClient: client,
82
+ relationalDb: undefined as never,
83
+ },
84
+ "graphql",
85
+ false,
86
+ );
87
+ ```
@@ -0,0 +1,483 @@
1
+ import { BaseReadModel, Database, DocumentPurgeService, DocumentViewDatabase, IConsistencyTracker, IEventBus, IJobTracker, IOperationIndex, ISyncManager, IWriteCache, InProcessReactorModule, StorageDatabase } from "@powerhousedao/reactor";
2
+ import { ColumnType, Generated, Kysely, Transaction } from "kysely";
3
+ import { ISigner, OperationWithContext } from "@powerhousedao/shared/document-model";
4
+ import { DocumentNode } from "graphql";
5
+ //#region src/schema/migrations/migrator.d.ts
6
+ interface ReactorPrivacyMigrationResult {
7
+ success: boolean;
8
+ migrationsExecuted: string[];
9
+ error?: Error;
10
+ }
11
+ export declare function runReactorPrivacyMigrations(db: Kysely<unknown>, schema?: string): Promise<ReactorPrivacyMigrationResult>;
12
+ export declare function getReactorPrivacyMigrationStatus(db: Kysely<unknown>, schema?: string): Promise<readonly import("kysely").MigrationInfo[]>;
13
+ //#endregion
14
+ //#region src/schema/tables.d.ts
15
+ type ErasureRequestStatus = "open" | "complete" | "failed";
16
+ type ErasureItemStatus = "waiting" | "purging" | "purged" | "erased" | "failed";
17
+ type ErasureAuditEvent = "requested" | "expanded" | "waiting" | "purged" | "marker-converged" | "marker-undelivered" | "remotes-removed" | "permissions-erased" | "deadline-passed" | "failed" | "reopened" | "complete";
18
+ type SubjectRole = "signer" | "app-key" | "creator" | "header-key" | "named";
19
+ type Bigint = ColumnType<string | number, number | bigint, number | bigint>;
20
+ interface ErasureRequestTable {
21
+ requestId: string;
22
+ subjectHash: string | null;
23
+ requestedBy: string;
24
+ requestedAt: Date;
25
+ deadline: Date;
26
+ status: ErasureRequestStatus;
27
+ }
28
+ interface ErasureItemTable {
29
+ requestId: string;
30
+ documentId: string;
31
+ status: ErasureItemStatus;
32
+ allowLarge: ColumnType<boolean, boolean | undefined, boolean>;
33
+ markerOrdinal: Bigint | null;
34
+ lastError: string | null;
35
+ updatedAt: Date;
36
+ }
37
+ interface ErasureAuditTable {
38
+ ordinal: Generated<string>;
39
+ requestId: string;
40
+ documentId: string | null;
41
+ event: ErasureAuditEvent;
42
+ detail: unknown;
43
+ atUtc: Date;
44
+ }
45
+ interface SubjectDocumentTable {
46
+ subjectHash: string;
47
+ documentId: string;
48
+ role: SubjectRole;
49
+ firstOrdinal: Bigint;
50
+ lastOrdinal: Bigint;
51
+ }
52
+ interface ReactorPrivacyDatabase {
53
+ erasure_requests: ErasureRequestTable;
54
+ erasure_items: ErasureItemTable;
55
+ erasure_audit: ErasureAuditTable;
56
+ subject_documents: SubjectDocumentTable;
57
+ }
58
+ //#endregion
59
+ //#region src/subject-hash.d.ts
60
+ /** Shorter keys make the HMAC guessable along with the address. */
61
+ export declare const MIN_DEPLOYMENT_SECRET_BYTES = 32;
62
+ export declare class DeploymentSecretError extends Error {
63
+ constructor();
64
+ }
65
+ type DeploymentSecret = string | Uint8Array;
66
+ /** HMAC-SHA256(secret, lower(identifier)), hex. */
67
+ export declare function subjectHash(secret: DeploymentSecret, identifier: string): string;
68
+ //#endregion
69
+ //#region src/read-model/subject-documents-read-model.d.ts
70
+ export declare const SUBJECT_DOCUMENTS_READ_MODEL_ID = "subject-documents-read-model";
71
+ /** Keyed hash of each identifier an operation carries, to its document. */
72
+ export declare class SubjectDocumentsReadModel extends BaseReadModel {
73
+ private readonly deploymentSecret;
74
+ static readonly commitsInFenceTransaction = true;
75
+ constructor(db: Kysely<DocumentViewDatabase>, operationIndex: IOperationIndex, writeCache: IWriteCache, consistencyTracker: IConsistencyTracker, deploymentSecret: DeploymentSecret);
76
+ protected commitOperations(items: OperationWithContext[], trx?: Transaction<DocumentViewDatabase>): Promise<void>;
77
+ /** The auth scope's creator, as the INITIALIZE_AUTH reducer derives it. */
78
+ private creatorOf;
79
+ }
80
+ //#endregion
81
+ //#region src/read-model/register.d.ts
82
+ export declare class LiveReadModelRegistrationError extends Error {
83
+ constructor();
84
+ }
85
+ /** Post-build registration on the host thread, as switchboard's add-ons do. */
86
+ export declare function registerSubjectDocumentsReadModel(reactorModule: InProcessReactorModule, options: {
87
+ deploymentSecret: DeploymentSecret;
88
+ }): Promise<SubjectDocumentsReadModel>;
89
+ //#endregion
90
+ //#region src/read-model/subjects.d.ts
91
+ type SubjectMention = {
92
+ identifier: string;
93
+ role: SubjectRole;
94
+ };
95
+ /** A condition literal counts as an identifier only in these two shapes. */
96
+ export declare function isAddressLiteral(value: unknown): value is string;
97
+ /** The did:key of a P-256 JWK, the form an app key takes; else undefined. */
98
+ export declare function jwkToDidKey(jwk: unknown): string | undefined;
99
+ /** Every mention an operation carries, except `creator` (needs the header). */
100
+ export declare function mentionsOf(item: OperationWithContext): SubjectMention[];
101
+ //#endregion
102
+ //#region src/erasure/types.d.ts
103
+ /** One document an erasure of the requested ids would remove. */
104
+ type ErasurePlanItem = {
105
+ documentId: string;
106
+ /** The requested drive this document was expanded from; null if requested. */
107
+ expandedFrom: string | null;
108
+ /** A live document is refused with DocumentNotDeletedError. */
109
+ live: boolean;
110
+ /** Rows in operation_index_operations, against maxPurgeOperations. */
111
+ operationCount: number;
112
+ /** Surviving documents whose accepted auth history names this group. */
113
+ groupReferencers: string[];
114
+ };
115
+ type ErasurePlan = {
116
+ maxPurgeOperations: number;
117
+ items: ErasurePlanItem[];
118
+ };
119
+ type ErasureItem = {
120
+ documentId: string;
121
+ status: ErasureItemStatus;
122
+ allowLarge: boolean;
123
+ markerOrdinal: number | null;
124
+ lastError: string | null;
125
+ updatedAt: Date;
126
+ };
127
+ type ErasureRequest = {
128
+ requestId: string;
129
+ subjectHash: string | null;
130
+ /** The stored form: hashed when it is an address. */
131
+ requestedBy: string;
132
+ requestedAt: Date;
133
+ deadline: Date;
134
+ status: ErasureRequestStatus;
135
+ items: ErasureItem[];
136
+ };
137
+ interface IErasureService {
138
+ /** What erasing these ids would remove, and what blocks each. Read-only. */
139
+ plan(ids: string[]): Promise<ErasurePlan>;
140
+ /** Records the request; returns immediately. */
141
+ request(ids: string[], opts: {
142
+ requestedBy: string;
143
+ deadline?: Date;
144
+ allowLarge?: string[];
145
+ }): Promise<ErasureRequest>;
146
+ status(requestId: string): Promise<ErasureRequest>;
147
+ }
148
+ //#endregion
149
+ //#region src/erasure/ledger.d.ts
150
+ /** Both ledgers live in the reactor schema: the handle is already scoped to it. */
151
+ type ErasureDb = Kysely<ReactorPrivacyDatabase & StorageDatabase>;
152
+ //#endregion
153
+ //#region src/erasure/erasure-service.d.ts
154
+ export declare const DEFAULT_ERASURE_DEADLINE_MS: number;
155
+ export declare class ErasureRequestNotFoundError extends Error {
156
+ readonly requestId: string;
157
+ constructor(requestId: string);
158
+ }
159
+ type ErasureServiceOptions = {
160
+ /** The reactor schema handle: `module.database.withSchema(REACTOR_SCHEMA)`. */
161
+ db: ErasureDb;
162
+ deploymentSecret: DeploymentSecret;
163
+ /** The executor's cap; plan() reports each document against it. */
164
+ maxPurgeOperations?: number;
165
+ driveContainerTypes?: ReadonlySet<string>;
166
+ /** Default deadline, from the request time. */
167
+ deadlineMs?: number;
168
+ now?: () => Date;
169
+ newRequestId?: () => string;
170
+ };
171
+ export declare class ErasureService implements IErasureService {
172
+ private readonly db;
173
+ private readonly secret;
174
+ private readonly maxPurgeOperations;
175
+ private readonly driveTypes;
176
+ private readonly deadlineMs;
177
+ private readonly now;
178
+ private readonly newRequestId;
179
+ constructor(options: ErasureServiceOptions);
180
+ plan(ids: string[]): Promise<ErasurePlan>;
181
+ request(ids: string[], opts: {
182
+ requestedBy: string;
183
+ deadline?: Date;
184
+ allowLarge?: string[];
185
+ }): Promise<ErasureRequest>;
186
+ status(requestId: string): Promise<ErasureRequest>;
187
+ }
188
+ //#endregion
189
+ //#region src/erasure/scheduler.d.ts
190
+ export declare const DEFAULT_ERASURE_INTERVAL_MS = 60000;
191
+ export declare const DEFAULT_MARKER_GRACE_MS: number;
192
+ export declare const DEFAULT_PURGE_TIMEOUT_MS: number;
193
+ /** An unsigned marker is refused by every receiver. */
194
+ export declare class ErasureSignerMissingError extends Error {
195
+ constructor();
196
+ }
197
+ /** Implemented over reactor-api's DocumentPermissionService by the host. */
198
+ interface IDocumentPermissionEraser {
199
+ /** Deletes every permission and protection row for the document; row counts. */
200
+ erasePermissions(documentId: string): Promise<Record<string, number>>;
201
+ }
202
+ type ErasureLogger = {
203
+ info(message: string, ...args: unknown[]): void;
204
+ warn(message: string, ...args: unknown[]): void;
205
+ error(message: string, ...args: unknown[]): void;
206
+ };
207
+ type ErasureSchedulerOptions = {
208
+ /** The reactor schema handle: `module.database.withSchema(REACTOR_SCHEMA)`. */
209
+ db: ErasureDb;
210
+ deploymentSecret: DeploymentSecret;
211
+ /** The signer the reactor's executor signs purge markers with. */
212
+ signer: ISigner | undefined;
213
+ purges: Pick<DocumentPurgeService, "enqueuePurge">;
214
+ jobs: Pick<IJobTracker, "getJobStatus">;
215
+ /** A purge's completion starts the next tick, so purges run back to back. */
216
+ eventBus?: IEventBus;
217
+ syncManager?: Pick<ISyncManager, "list" | "remove">;
218
+ permissions?: IDocumentPermissionEraser;
219
+ driveContainerTypes?: ReadonlySet<string>;
220
+ intervalMs?: number;
221
+ markerGraceMs?: number;
222
+ /** A purge with no tombstone after this long is enqueued again. */
223
+ purgeTimeoutMs?: number;
224
+ now?: () => Date;
225
+ logger?: ErasureLogger;
226
+ };
227
+ /** One purge at a time across all requests; document_purges is the truth. */
228
+ export declare class ErasureScheduler {
229
+ private readonly db;
230
+ private readonly secret;
231
+ private readonly options;
232
+ private readonly driveTypes;
233
+ private readonly intervalMs;
234
+ private readonly markerGraceMs;
235
+ private readonly purgeTimeoutMs;
236
+ private readonly now;
237
+ private readonly logger;
238
+ /** Purge job per item; lost on restart like the job tracker's own entries. */
239
+ private readonly jobIds;
240
+ /** Failed or abandoned purges whose transaction may still be open. */
241
+ private readonly unsettled;
242
+ private readonly documentTypes;
243
+ private timer;
244
+ private unsubscribes;
245
+ private running;
246
+ private runningPass;
247
+ private queued;
248
+ /** Items the last full pass found ready, in purge order, not yet enqueued. */
249
+ private ready;
250
+ constructor(options: ErasureSchedulerOptions);
251
+ start(): void;
252
+ /** Stops the interval and the triggers, and waits for the tick in flight. */
253
+ stop(): Promise<void>;
254
+ /** One full pass; joins a full pass in flight, follows a dispatch pass. */
255
+ tick(): Promise<void>;
256
+ private pass;
257
+ /** A pass now, or right after the one running; inert unless started. */
258
+ private trigger;
259
+ private runTick;
260
+ /** After a purge settles: that item, then the next ready one; no backlog scan. */
261
+ private runDispatch;
262
+ /** The head of the last full pass's ready list, checked again on its own. */
263
+ private dispatchReady;
264
+ private guarded;
265
+ private stepFailed;
266
+ private activeItems;
267
+ private tickReads;
268
+ private storedRemotes;
269
+ /** A failed item whose purge committed after all, e.g. after a timeout. */
270
+ private recoverFailed;
271
+ /** Every failed request with no failed item left is open again. */
272
+ private reopenRequests;
273
+ private advanceWaiting;
274
+ /** Members before their drive: a drive purge needs its members gone. */
275
+ private inPurgeOrder;
276
+ /** A drive waits for every member of its request still to be purged. */
277
+ private eligible;
278
+ private isDrive;
279
+ private loadDocumentTypes;
280
+ /** A timed-out purge's transaction can outlive its job: wait for its lock. */
281
+ private previousPurgesEnded;
282
+ /** An exclusive purge lock on one of the ids' buckets, held or awaited. */
283
+ private purgeLockTaken;
284
+ private enqueue;
285
+ private dispatch;
286
+ /** Enqueued again with the dispatch time reset; the purge lock gates it. */
287
+ private redispatch;
288
+ private advancePurging;
289
+ private markPurged;
290
+ private markFailed;
291
+ private advancePurged;
292
+ private markerSettled;
293
+ /** Refusals by remotes bound to the document, each audited once when read. */
294
+ private refusedRemotes;
295
+ /** Stored rows bound to the drive; one not loaded is deleted at markerGrace. */
296
+ private removeRemotes;
297
+ /** What SyncManager.remove deletes; cursors, holds, dead letters cascade. */
298
+ private deleteStoredRemotes;
299
+ private erasePermissions;
300
+ private deleteConvergence;
301
+ /** Fails closed: a stored remote owed the ordinal but not loaded is unknown. */
302
+ private convergence;
303
+ /** A waiting row each tick the pending list changes. */
304
+ private recordWaiting;
305
+ private settleRequests;
306
+ private transition;
307
+ private setLastError;
308
+ private audit;
309
+ }
310
+ //#endregion
311
+ //#region src/erasure/module.d.ts
312
+ type ModuleErasureOptions = {
313
+ deploymentSecret: DeploymentSecret;
314
+ /** The signer the reactor was built with; the scheduler refuses without one. */
315
+ signer: ISigner | undefined;
316
+ permissions?: IDocumentPermissionEraser;
317
+ /** The executor's maxPurgeOperations, when the host overrides the default. */
318
+ maxPurgeOperations?: number;
319
+ deadlineMs?: number;
320
+ intervalMs?: number;
321
+ markerGraceMs?: number;
322
+ purgeTimeoutMs?: number;
323
+ now?: () => Date;
324
+ logger?: ErasureLogger;
325
+ };
326
+ /** The service and scheduler over one reactor module; start the scheduler. */
327
+ export declare function createModuleErasure(reactorModule: InProcessReactorModule, options: ModuleErasureOptions): {
328
+ service: ErasureService;
329
+ scheduler: ErasureScheduler;
330
+ };
331
+ //#endregion
332
+ //#region src/disclosure/disclosure-service.d.ts
333
+ /** One row outside the reactor schema that names the address. */
334
+ type PermissionRow = {
335
+ table: string;
336
+ column: string;
337
+ documentId: string | null;
338
+ detail?: Record<string, unknown>;
339
+ };
340
+ /** Implemented over reactor-api's DocumentPermissionService by the host. */
341
+ interface IPermissionRowsLookup {
342
+ rowsForAddress(address: string): Promise<PermissionRow[]>;
343
+ }
344
+ type SubjectDocument = {
345
+ documentId: string;
346
+ role: SubjectRole;
347
+ firstOrdinal: number;
348
+ lastOrdinal: number;
349
+ };
350
+ type BoundSyncRemote = {
351
+ name: string;
352
+ collectionId: string;
353
+ channelType: string;
354
+ };
355
+ type PeerManifestAppKey = {
356
+ remoteName: string;
357
+ appKey: string;
358
+ heardAtUtcMs: number | null;
359
+ };
360
+ type Disclosure = {
361
+ subjectHash: string;
362
+ documents: SubjectDocument[];
363
+ boundSyncRemotes: BoundSyncRemote[];
364
+ peerManifests: PeerManifestAppKey[];
365
+ permissions: PermissionRow[];
366
+ notCovered: string[];
367
+ };
368
+ export declare const DISCLOSURE_NOT_COVERED: readonly string[];
369
+ /** Lists what is held about one identifier. Read-only. */
370
+ export declare class DisclosureService {
371
+ private readonly deploymentSecret;
372
+ private readonly permissions?;
373
+ private readonly db;
374
+ constructor(reactorDb: Kysely<Database>, deploymentSecret: DeploymentSecret, permissions?: IPermissionRowsLookup | undefined, schema?: string);
375
+ disclose(identifier: string): Promise<Disclosure>;
376
+ }
377
+ //#endregion
378
+ //#region src/subgraph/schema.d.ts
379
+ declare const typeDefs: import("graphql").DocumentNode;
380
+ //#endregion
381
+ //#region src/subgraph/resolvers.d.ts
382
+ /** The slice of reactor-api's IAuthorizationService the subgraph uses. */
383
+ interface PrivacyAuthorization {
384
+ readonly config: {
385
+ readonly policy: string;
386
+ };
387
+ isSupremeAdmin(userAddress?: string): boolean;
388
+ }
389
+ interface IDisclosureService {
390
+ disclose(identifier: string): Promise<Disclosure>;
391
+ }
392
+ type PrivacySubgraphContext = {
393
+ user?: {
394
+ address?: string;
395
+ };
396
+ };
397
+ type PrivacyResolverDeps = {
398
+ authorizationService: PrivacyAuthorization;
399
+ erasure: IErasureService;
400
+ disclosure: IDisclosureService;
401
+ };
402
+ /** Every field refuses a caller that is not a supreme admin, before any work. */
403
+ export declare function createPrivacyResolvers(deps: PrivacyResolverDeps): {
404
+ Query: {
405
+ disclose(_root: unknown, args: {
406
+ identifier: string;
407
+ }, ctx: PrivacySubgraphContext): Promise<{
408
+ subjectHash: string;
409
+ documents: SubjectDocument[];
410
+ boundSyncRemotes: BoundSyncRemote[];
411
+ peerManifests: PeerManifestAppKey[];
412
+ notCovered: string[];
413
+ permissions: {
414
+ table: string;
415
+ column: string;
416
+ documentId: string | null;
417
+ detail: string | null;
418
+ }[];
419
+ }>;
420
+ erasurePlan(_root: unknown, args: {
421
+ ids: string[];
422
+ }, ctx: PrivacySubgraphContext): Promise<ErasurePlan>;
423
+ erasureRequest(_root: unknown, args: {
424
+ requestId: string;
425
+ }, ctx: PrivacySubgraphContext): Promise<{
426
+ requestId: string;
427
+ subjectHash: string | null;
428
+ requestedBy: string;
429
+ status: ErasureRequestStatus;
430
+ requestedAt: string;
431
+ deadline: string;
432
+ items: {
433
+ documentId: string;
434
+ status: ErasureItemStatus;
435
+ allowLarge: boolean;
436
+ markerOrdinal: number | null;
437
+ lastError: string | null;
438
+ updatedAt: string;
439
+ }[];
440
+ }>;
441
+ };
442
+ Mutation: {
443
+ requestErasure(_root: unknown, args: {
444
+ ids: string[];
445
+ deadline?: string | null;
446
+ allowLarge?: string[] | null;
447
+ }, ctx: PrivacySubgraphContext): Promise<{
448
+ requestId: string;
449
+ subjectHash: string | null;
450
+ requestedBy: string;
451
+ status: ErasureRequestStatus;
452
+ requestedAt: string;
453
+ deadline: string;
454
+ items: {
455
+ documentId: string;
456
+ status: ErasureItemStatus;
457
+ allowLarge: boolean;
458
+ markerOrdinal: number | null;
459
+ lastError: string | null;
460
+ updatedAt: string;
461
+ }[];
462
+ }>;
463
+ };
464
+ };
465
+ //#endregion
466
+ //#region src/subgraph/subgraph.d.ts
467
+ export declare const PRIVACY_SUBGRAPH_NAME = "privacy";
468
+ /** Under OPEN every caller, anonymous included, is a supreme admin. */
469
+ export declare class PrivacySubgraphOpenPolicyError extends Error {
470
+ readonly policy: string;
471
+ constructor(policy: string);
472
+ }
473
+ type PrivacySubgraph = {
474
+ name: string;
475
+ typeDefs: DocumentNode;
476
+ resolvers: ReturnType<typeof createPrivacyResolvers>;
477
+ };
478
+ /** Throws PrivacySubgraphOpenPolicyError when anonymous callers are admins. */
479
+ export declare function createPrivacySubgraph(deps: PrivacyResolverDeps): PrivacySubgraph;
480
+ //#endregion
481
+ export { type BoundSyncRemote, type DeploymentSecret, type Disclosure, type ErasureAuditEvent, type ErasureAuditTable, type ErasureDb, type ErasureItem, type ErasureItemStatus, type ErasureItemTable, type ErasureLogger, type ErasurePlan, type ErasurePlanItem, type ErasureRequest, type ErasureRequestStatus, type ErasureRequestTable, type ErasureSchedulerOptions, type ErasureServiceOptions, type IDisclosureService, type IDocumentPermissionEraser, type IErasureService, type IPermissionRowsLookup, type ModuleErasureOptions, type PeerManifestAppKey, type PermissionRow, type PrivacyAuthorization, type PrivacyResolverDeps, type PrivacySubgraph, type PrivacySubgraphContext, type ReactorPrivacyDatabase, type ReactorPrivacyMigrationResult, type SubjectDocument, type SubjectDocumentTable, type SubjectMention, type SubjectRole, typeDefs as privacySubgraphTypeDefs };
482
+ export {};
483
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/schema/migrations/migrator.ts","../src/schema/tables.ts","../src/subject-hash.ts","../src/read-model/subject-documents-read-model.ts","../src/read-model/register.ts","../src/read-model/subjects.ts","../src/erasure/types.ts","../src/erasure/ledger.ts","../src/erasure/erasure-service.ts","../src/erasure/scheduler.ts","../src/erasure/module.ts","../src/disclosure/disclosure-service.ts","../src/subgraph/schema.ts","../src/subgraph/resolvers.ts","../src/subgraph/subgraph.ts"],"mappings":";;;;;UAUiB;EACf;EACA;EACA,QAAQ;;wBAmCY,4BACpB,IAAI,iBACJ,kBACC,QAAQ;wBAsCW,iCACpB,IAAI,iBACJ,kBAA+B,kCAAA;;;KCzFrB;KAEA;KAOA;KAcA;KAOP,SAAS;UAEG;EACf;EACA;EACA;EACA,aAAa;EACb,UAAU;EACV,QAAQ;;UAGO;EACf;EACA;EACA,QAAQ;EACR,YAAY;EACZ,eAAe;EACf;EACA,WAAW;;UAGI;EACf,SAAS;EACT;EACA;EACA,OAAO;EACP;EACA,OAAO;;UAGQ;EACf;EACA;EACA,MAAM;EACN,cAAc;EACd,aAAa;;UAGE;EACf,kBAAkB;EAClB,eAAe;EACf,eAAe;EACf,mBAAmB;;;;;qBCvER;qBAEA,8BAA8B;EACzC;;KAQU,4BAA4B;;wBAWxB,YACd,QAAQ,kBACR;;;qBCJW;;qBAiBA,kCAAkC;mBAQ1B;kBAPM;EAEzB,YACE,IAAI,OAAO,uBACX,gBAAgB,iBAChB,YAAY,aACZ,oBAAoB,qBACH,kBAAkB;YAYZ,iBACvB,OAAO,wBACP,MAAM,YAAY,wBACjB;;UAgEW;;;;qBCnHH,uCAAuC;EAClD;;;wBASoB,kCACpB,eAAe,wBACf;EAAW,kBAAkB;IAC5B,QAAQ;;;KCjBC;EAAmB;EAAoB,MAAM;;;wBAazC,iBAAiB,iBAAiB;;wBAoClC,YAAY;;wBA0FZ,WAAW,MAAM,uBA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