@voltro/plugin-deactivation 0.89.1 → 0.90.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 +1835 -0
- package/README.md +2 -0
- package/dist/accountMerge.js +18 -0
- package/dist/privacyCoordinator.js +17 -17
- package/dist/privacyPlugin.d.ts +1 -1
- package/dist/privacyPlugin.js +174 -94
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ Installation, guides, the full API reference, and examples all live in the
|
|
|
20
20
|
**[Voltro documentation](https://docs.voltro.dev/docs/intro/getting-started)** — the single source of truth. This README is
|
|
21
21
|
deliberately short so there is nothing here to drift out of date.
|
|
22
22
|
|
|
23
|
+
The installed privacy factory captures its operations, request store, registry and authenticated subject when an operation is called. Queued work cannot borrow a later binding; retired results, export packaging, workflow starts and finalizer writes refuse with `request_unavailable`. An already admitted SQL request can finish; retry its original request ID to read the same deadline and receipt. Deactivation permits a later installation on another store or registry, while old operations stay retired. Registry preparation and every participant still need their own resource-withdrawal contract; this factory fence does not establish cross-phase quiescence.
|
|
24
|
+
|
|
23
25
|
## License
|
|
24
26
|
|
|
25
27
|
Proprietary. © 2026 Voltro UG. Your use is governed by the
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { privacyRequestsTable as e } from "./privacyRequests.js";
|
|
2
|
+
import { and as t, eq as n, inSet as r, or as i, queryFor as a } from "@voltro/database";
|
|
3
|
+
import { Effect as o } from "effect";
|
|
4
|
+
// src/accountMerge.ts
|
|
5
|
+
var s = class extends Error {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("An erasure of one of the accounts is pending");
|
|
8
|
+
}
|
|
9
|
+
}, c = (c) => o.tryPromise({
|
|
10
|
+
try: async () => {
|
|
11
|
+
let o = c.store;
|
|
12
|
+
if ((await o.query(a(e).where(t(n("tenantId", c.tenantId), i(n("subjectId", c.sourceId), n("subjectId", c.targetId)))).forUpdate().descriptor)).some((e) => e.status === "pending" || e.status === "erasing")) throw new s();
|
|
13
|
+
let l = await o.query(a(e).where(t(n("tenantId", c.tenantId), n("subjectId", c.sourceId), r("status", ["withdrawn", "completed"]))).descriptor);
|
|
14
|
+
for (let t of l) await o.delete(e.tableName, String(t.id));
|
|
15
|
+
},
|
|
16
|
+
catch: (e) => e
|
|
17
|
+
});
|
|
18
|
+
export { s as PrivacyMergeRefused, c as mergePrivacyRequests };
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PrivacyRequestRefused as e, dataStorePrivacyRequests as t } from "./privacyRequests.js";
|
|
2
|
+
import { PrivacyCoordinatorFailure as n } from "./privacyContract.js";
|
|
3
3
|
import { Effect as r, Result as i } from "effect";
|
|
4
4
|
import { randomUUID as a } from "node:crypto";
|
|
5
5
|
// src/privacyCoordinator.ts
|
|
6
|
-
var o = (
|
|
7
|
-
code:
|
|
6
|
+
var o = (e) => new n({
|
|
7
|
+
code: e,
|
|
8
8
|
completed: [],
|
|
9
9
|
missing: []
|
|
10
|
-
}), s = (
|
|
11
|
-
try:
|
|
12
|
-
catch: (
|
|
10
|
+
}), s = (t) => r.tryPromise({
|
|
11
|
+
try: t,
|
|
12
|
+
catch: (t) => o(t instanceof e ? t.code : "request_unavailable")
|
|
13
13
|
}), c = (e) => r.suspend(() => e.type !== "user" || !e.id.trim() || !e.tenantId.trim() ? r.fail(o("identity_required")) : r.succeed(Object.freeze({
|
|
14
14
|
subjectId: e.id,
|
|
15
15
|
tenantId: e.tenantId,
|
|
16
16
|
kind: e.kind === "guest" ? "guest" : "user"
|
|
17
|
-
}))), l = (
|
|
18
|
-
let d =
|
|
17
|
+
}))), l = (e, l, u = {}) => {
|
|
18
|
+
let d = t(e, {
|
|
19
19
|
withdrawalMs: u.withdrawalMs ?? 2592e6,
|
|
20
20
|
...u.now === void 0 ? {} : { now: u.now }
|
|
21
|
-
}), f = (
|
|
22
|
-
let
|
|
23
|
-
return
|
|
21
|
+
}), f = (e) => r.suspend(() => {
|
|
22
|
+
let t = l.coverage(e);
|
|
23
|
+
return t.missing.length !== 0 || t.participants.length === 0 ? r.fail(new n({
|
|
24
24
|
code: "coverage_missing",
|
|
25
25
|
completed: [],
|
|
26
|
-
missing: [...
|
|
26
|
+
missing: [...t.missing]
|
|
27
27
|
})) : r.void;
|
|
28
|
-
}), p = (
|
|
29
|
-
code:
|
|
30
|
-
completed: [...
|
|
31
|
-
missing: [...
|
|
28
|
+
}), p = (e) => new n({
|
|
29
|
+
code: e.code === "coverage_missing" ? "coverage_missing" : e.code === "invalid_request" ? "invalid_request" : e.code === "unavailable" ? "request_unavailable" : "hook_failed",
|
|
30
|
+
completed: [...e.completed],
|
|
31
|
+
missing: [...e.missing]
|
|
32
32
|
});
|
|
33
33
|
return {
|
|
34
34
|
requestErasure: (e, t = a()) => r.gen(function* () {
|
package/dist/privacyPlugin.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ export declare const privacyRequestsTable: Table<"_voltro_privacy_requests", Fie
|
|
|
105
105
|
readonly tenantId: ColumnBuilder<string | null, "text", boolean>;
|
|
106
106
|
readonly kind: ColumnBuilder<"user" | "guest", "text", boolean>;
|
|
107
107
|
readonly activeKey: ColumnBuilder<string, "text", boolean>;
|
|
108
|
-
readonly status: ColumnBuilder<"
|
|
108
|
+
readonly status: ColumnBuilder<"pending" | "completed" | "withdrawn" | "erasing", "text", boolean>;
|
|
109
109
|
readonly requestedAt: ColumnBuilder<Date, "timestamp", boolean>;
|
|
110
110
|
readonly dueAt: ColumnBuilder<Date, "timestamp", boolean>;
|
|
111
111
|
readonly claimedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
|
package/dist/privacyPlugin.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { PrivacyRequestRefused as e, dataStorePrivacyRequests as t, privacyRequestsTable as n } from "./privacyRequests.js";
|
|
2
|
+
import { mergePrivacyRequests as r } from "./accountMerge.js";
|
|
3
|
+
import { PrivacyCoordinatorFailure as i, PrivacyExportPackageSchema as a, PrivacyRequestReceiptSchema as o, jsonPrivacyExport as s } from "./privacyContract.js";
|
|
4
|
+
import { dataStorePrivacyCoordinator as c, privacyTargetFromSubject as l } from "./privacyCoordinator.js";
|
|
5
|
+
import { PrivacyService as u } from "./privacyService.js";
|
|
6
|
+
import { exportSelfDescriptor as d, privacyRpcClientImports as f, requestErasureDescriptor as p, requestStatusDescriptor as m, withdrawErasureDescriptor as h } from "./privacyRpc.js";
|
|
7
|
+
import { Effect as g, Layer as _, Schema as v } from "effect";
|
|
8
|
+
import { decodePrivacyStatus as y } from "@voltro/protocol/inspect";
|
|
9
|
+
import { fileURLToPath as b } from "node:url";
|
|
10
|
+
import { PluginPrivacyFailure as x, definePlugin as S } from "@voltro/protocol";
|
|
9
11
|
// src/privacyPlugin.ts
|
|
10
|
-
var
|
|
12
|
+
var C = {
|
|
11
13
|
slots: { exportPackage: {
|
|
12
14
|
defaultExport: "jsonPrivacyExport",
|
|
13
15
|
fixtureExport: "privacyExportFixture"
|
|
@@ -18,121 +20,199 @@ var b = {
|
|
|
18
20
|
fixtureExport: "privacyPortFixture"
|
|
19
21
|
} },
|
|
20
22
|
events: []
|
|
21
|
-
},
|
|
23
|
+
}, w = () => new i({
|
|
22
24
|
code: "request_unavailable",
|
|
23
25
|
completed: [],
|
|
24
26
|
missing: []
|
|
25
|
-
}),
|
|
26
|
-
let
|
|
27
|
-
if (!Number.isSafeInteger(
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
}), T = (e) => e.requestId, E = (o = {}) => {
|
|
28
|
+
let C = o.withdrawalMs ?? 2592e6;
|
|
29
|
+
if (!Number.isSafeInteger(C) || C < 0) throw Error("Privacy withdrawal window must be a non-negative safe integer");
|
|
30
|
+
let E = o.exportPackage ?? s, D, O, k, A, j = Object.freeze({}), M = (e) => D !== void 0 && j === e, N = (e, t) => g.suspend(() => M(e) ? t() : g.fail(w())).pipe(g.flatMap((t) => M(e) ? g.succeed(t) : g.fail(w())), g.catchDefect(() => g.fail(w()))), P = (e) => {
|
|
31
|
+
let t = D, n = j;
|
|
32
|
+
return N(n, () => t === void 0 ? g.fail(w()) : e(t, n));
|
|
33
|
+
}, F = (e, t) => {
|
|
34
|
+
try {
|
|
35
|
+
let n = structuredClone(e), r = P((e, r) => t(e, n, r));
|
|
36
|
+
return l(n).pipe(g.flatMap(() => r));
|
|
37
|
+
} catch {
|
|
38
|
+
return g.fail(new i({
|
|
39
|
+
code: "identity_required",
|
|
40
|
+
completed: [],
|
|
41
|
+
missing: []
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}, I = {
|
|
45
|
+
requestErasure: (e, t) => F(e, (e, n) => e.requestErasure(n, t)),
|
|
46
|
+
readSelf: (e, t) => F(e, (e, n) => e.readSelf(n, t)),
|
|
47
|
+
withdraw: (e, t) => F(e, (e, n) => e.withdraw(n, t)),
|
|
48
|
+
exportSelf: (e, t) => F(e, (e, n, r) => e.exportSelf(n, t).pipe(g.flatMap((e) => N(r, () => g.try({
|
|
49
|
+
try: () => v.decodeUnknownSync(a)(E(e)),
|
|
50
|
+
catch: w
|
|
51
|
+
}))))),
|
|
52
|
+
execute: (e) => P((t) => t.execute(e)),
|
|
53
|
+
dispatch: (e, t) => {
|
|
54
|
+
let n = {
|
|
55
|
+
limit: e.limit,
|
|
56
|
+
...e.after === void 0 ? {} : { after: { ...e.after } }
|
|
57
|
+
};
|
|
58
|
+
return P((e, r) => e.dispatch(n, async (e) => {
|
|
59
|
+
if (!M(r)) throw w();
|
|
60
|
+
let n = await t(e);
|
|
61
|
+
if (!M(r)) throw w();
|
|
62
|
+
return n;
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}, L = [
|
|
43
66
|
{
|
|
44
67
|
...p,
|
|
45
|
-
execute: (e, t) =>
|
|
68
|
+
execute: (e, t) => I.requestErasure(t.request.subject, T(e))
|
|
46
69
|
},
|
|
47
70
|
{
|
|
48
71
|
...m,
|
|
49
|
-
execute: (e, t) =>
|
|
72
|
+
execute: (e, t) => I.readSelf(t.request.subject, e.requestId)
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
...h,
|
|
76
|
+
execute: (e, t) => I.withdraw(t.request.subject, e.requestId)
|
|
50
77
|
},
|
|
51
78
|
{
|
|
52
|
-
...
|
|
53
|
-
execute: (e, t) =>
|
|
79
|
+
...d,
|
|
80
|
+
execute: (e, t) => I.exportSelf(t.request.subject, T(e))
|
|
54
81
|
}
|
|
55
82
|
];
|
|
56
|
-
return
|
|
83
|
+
return S({
|
|
57
84
|
name: "@voltro/plugin-deactivation",
|
|
58
85
|
description: "Durable subject privacy requests, withdrawal and JSON export.",
|
|
59
86
|
permissions: ["store:write", "inspect:read"],
|
|
60
|
-
services:
|
|
61
|
-
routes:
|
|
62
|
-
rpcClientDescriptors:
|
|
63
|
-
sources:
|
|
64
|
-
extendSchema: { tables: [
|
|
87
|
+
services: _.succeed(u, I),
|
|
88
|
+
routes: L,
|
|
89
|
+
rpcClientDescriptors: f,
|
|
90
|
+
sources: b(new URL("./privacy-app", "" + import.meta.url)),
|
|
91
|
+
extendSchema: { tables: [n] },
|
|
92
|
+
subjectMerge: {
|
|
93
|
+
tables: [n.tableName],
|
|
94
|
+
kinds: ["guest"]
|
|
95
|
+
},
|
|
96
|
+
onMergeAccounts: (e) => r(e),
|
|
65
97
|
inspectEndpoints: [{
|
|
66
98
|
method: "GET",
|
|
67
99
|
path: "/status",
|
|
68
100
|
scope: "shared-store",
|
|
69
101
|
description: "Bounded recent privacy receipts and declared subject hook coverage; no subject or tenant identifiers.",
|
|
70
|
-
handler: () =>
|
|
71
|
-
|
|
102
|
+
handler: () => {
|
|
103
|
+
let e = O, t = A, n = j;
|
|
104
|
+
return e === void 0 || t === void 0 ? g.succeed({
|
|
72
105
|
kind: "json",
|
|
73
106
|
status: 503,
|
|
74
107
|
data: { error: "privacy_unavailable" }
|
|
75
|
-
} : {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
}) : N(n, () => g.tryPromise({
|
|
109
|
+
try: async () => {
|
|
110
|
+
let r = await e.inspectRecent();
|
|
111
|
+
if (!M(n)) throw w();
|
|
112
|
+
let i = y({
|
|
113
|
+
...r,
|
|
114
|
+
withdrawalMs: C,
|
|
115
|
+
limit: 100,
|
|
116
|
+
coverage: {
|
|
117
|
+
user: t.coverage("user"),
|
|
118
|
+
guest: t.coverage("guest")
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (!M(n)) throw w();
|
|
122
|
+
return {
|
|
123
|
+
kind: "json",
|
|
124
|
+
data: i
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
catch: w
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
89
130
|
}],
|
|
90
131
|
subjectPrivacy: {
|
|
91
|
-
tables: [
|
|
132
|
+
tables: [n.tableName],
|
|
92
133
|
kinds: ["user", "guest"],
|
|
93
134
|
erasePhase: "finalize"
|
|
94
135
|
},
|
|
95
|
-
onExport: (e, t) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
onExport: (e, t) => {
|
|
137
|
+
let n = O, r = j, i = {
|
|
138
|
+
subjectId: e,
|
|
139
|
+
tenantId: t.tenantId,
|
|
140
|
+
kind: t.kind
|
|
141
|
+
};
|
|
142
|
+
return N(r, () => g.tryPromise({
|
|
143
|
+
try: async () => {
|
|
144
|
+
if (n === void 0) throw w();
|
|
145
|
+
return n.exportOwned(i);
|
|
146
|
+
},
|
|
147
|
+
catch: w
|
|
148
|
+
}));
|
|
149
|
+
},
|
|
150
|
+
onErase: (t, n) => {
|
|
151
|
+
let r = O, a = j, o = n.requestId, s = n.completed === void 0 ? void 0 : [...n.completed], c = {
|
|
152
|
+
subjectId: t,
|
|
153
|
+
tenantId: n.tenantId,
|
|
154
|
+
kind: n.kind
|
|
155
|
+
};
|
|
156
|
+
return N(a, () => g.tryPromise({
|
|
157
|
+
try: async () => {
|
|
158
|
+
if (r === void 0 || s === void 0) throw w();
|
|
159
|
+
let e = await r.readWorker(o);
|
|
160
|
+
if (!M(a)) throw w();
|
|
161
|
+
e?.receipt.status !== "completed" && await r.finish(o, c, [...s, "@voltro/plugin-deactivation"]);
|
|
162
|
+
},
|
|
163
|
+
catch: (t) => new i({
|
|
164
|
+
code: t instanceof e ? t.code : "request_unavailable",
|
|
165
|
+
completed: [],
|
|
166
|
+
missing: []
|
|
167
|
+
})
|
|
168
|
+
}));
|
|
169
|
+
},
|
|
170
|
+
bindDataStore: (e, n) => {
|
|
171
|
+
if (n?.privacyRegistry === void 0) throw Error("Privacy orchestration requires the installing app privacy registry");
|
|
172
|
+
if (k !== void 0 && k !== e) throw Error("Privacy plugin instance cannot be shared between app stores");
|
|
173
|
+
if (A !== void 0 && A !== n.privacyRegistry) throw Error("Privacy plugin instance cannot be shared between app registries");
|
|
174
|
+
k = e, A = n.privacyRegistry, j = Object.freeze({}), D = void 0, O = void 0;
|
|
175
|
+
let r = A, a = j, s = (e) => {
|
|
176
|
+
let t = e.assertCurrent;
|
|
177
|
+
return {
|
|
178
|
+
...e,
|
|
179
|
+
assertCurrent: () => {
|
|
180
|
+
if (!M(a) || t?.() !== void 0) throw w();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}, l = {
|
|
184
|
+
coverage: (e) => {
|
|
185
|
+
if (!M(a)) throw w();
|
|
186
|
+
return r.coverage(e);
|
|
187
|
+
},
|
|
188
|
+
exportSubject: (e) => N(a, () => r.exportSubject(s(e))).pipe(g.mapError((t) => t instanceof i ? new x({
|
|
189
|
+
code: "unavailable",
|
|
190
|
+
operation: "export",
|
|
191
|
+
requestId: e.requestId,
|
|
192
|
+
plugin: null,
|
|
193
|
+
completed: [],
|
|
194
|
+
missing: []
|
|
195
|
+
}) : t)),
|
|
196
|
+
eraseSubject: (e) => N(a, () => r.eraseSubject(s(e))).pipe(g.mapError((t) => t instanceof i ? new x({
|
|
197
|
+
code: "unavailable",
|
|
198
|
+
operation: "erase",
|
|
199
|
+
requestId: e.requestId,
|
|
200
|
+
plugin: null,
|
|
201
|
+
completed: [],
|
|
202
|
+
missing: []
|
|
203
|
+
}) : t))
|
|
204
|
+
};
|
|
205
|
+
O = t(e, {
|
|
206
|
+
withdrawalMs: C,
|
|
207
|
+
...o.now === void 0 ? {} : { now: o.now }
|
|
208
|
+
}), D = o.operations ?? c(e, l, {
|
|
209
|
+
withdrawalMs: C,
|
|
210
|
+
...o.now === void 0 ? {} : { now: o.now }
|
|
131
211
|
});
|
|
132
212
|
},
|
|
133
|
-
onDeactivate: () =>
|
|
134
|
-
|
|
213
|
+
onDeactivate: () => g.sync(() => {
|
|
214
|
+
j = Object.freeze({}), D = void 0, O = void 0, k = void 0, A = void 0;
|
|
135
215
|
})
|
|
136
216
|
});
|
|
137
217
|
};
|
|
138
|
-
export {
|
|
218
|
+
export { i as PrivacyCoordinatorFailure, a as PrivacyExportPackageSchema, o as PrivacyRequestReceiptSchema, u as PrivacyService, s as jsonPrivacyExport, E as privacyPlugin, n as privacyRequestsTable, C as privacySystemContract };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-deactivation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
4
4
|
"description": "Deactivation plugin — ships the `deactivation()` schema mixin (deactivatedAt + deactivatedBy → Actor). A deactivated subject can't log in but its data stays VISIBLE (distinct from soft-delete, which hides + anonymises). Pure schema mixin, like audit().",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -68,16 +68,16 @@
|
|
|
68
68
|
"node": ">=24.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@voltro/database": "0.
|
|
72
|
-
"@voltro/plugin-audit": "0.
|
|
73
|
-
"@voltro/protocol": "0.
|
|
74
|
-
"@voltro/workflow": "0.
|
|
75
|
-
"@voltro/runtime": "0.
|
|
71
|
+
"@voltro/database": "0.90.0",
|
|
72
|
+
"@voltro/plugin-audit": "0.90.0",
|
|
73
|
+
"@voltro/protocol": "0.90.0",
|
|
74
|
+
"@voltro/workflow": "0.90.0",
|
|
75
|
+
"@voltro/runtime": "0.90.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@voltro/plugin-auth": "0.
|
|
78
|
+
"@voltro/plugin-auth": "0.90.0",
|
|
79
79
|
"effect": "4.1.2",
|
|
80
|
-
"@voltro/testing": "0.
|
|
80
|
+
"@voltro/testing": "0.90.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependenciesMeta": {
|
|
83
83
|
"@voltro/plugin-auth": {
|