@hadoku/service-kernel 0.1.136 → 0.1.137
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/dist/erase/anonymise.d.ts +31 -0
- package/dist/erase/anonymise.js +58 -6
- package/dist/erase/erase.d.ts +42 -4
- package/dist/erase/erase.js +84 -10
- package/dist/erase/index.d.ts +2 -2
- package/dist/erase/index.js +2 -2
- package/dist/server/server.js +10 -2
- package/package.json +2 -2
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* One mechanism for every store, so a store's erase is "which object to walk"
|
|
7
7
|
* and never a list of the fields that happen to hold an id today: a field added
|
|
8
8
|
* tomorrow is covered without anyone remembering this file.
|
|
9
|
+
*
|
|
10
|
+
* An account merge walks the same way (`renameIds`, `moveIds`): the merged-away person's ids
|
|
11
|
+
* become the kept account's, each to its own counterpart (a userId to a userId, a derived
|
|
12
|
+
* participant id to a derived participant id), rather than every id to one placeholder.
|
|
9
13
|
*/
|
|
10
14
|
/** The id an erased person becomes: fresh per erase, so two erased people never merge into one. */
|
|
11
15
|
export declare function placeholderId(): string;
|
|
@@ -16,3 +20,30 @@ export declare function placeholderId(): string;
|
|
|
16
20
|
* change (a record may share a frozen constant). Answers how many it replaced.
|
|
17
21
|
*/
|
|
18
22
|
export declare function replaceIds(value: unknown, ids: ReadonlySet<string>, to: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* `replaceIds` with each id renamed to its own new id (`renames`: old → new). Where a renamed
|
|
25
|
+
* key meets one that is already there (an object key, a Map key, a Set member), the one already
|
|
26
|
+
* there wins and the renamed entry is dropped: the kept account's own entry is never overwritten.
|
|
27
|
+
* Answers how many it renamed or dropped.
|
|
28
|
+
*/
|
|
29
|
+
export declare function renameIds(value: unknown, renames: ReadonlyMap<string, string>): number;
|
|
30
|
+
/** Does any string in `ids` sit anywhere in `value`, by the same walk `replaceIds` makes? Writes nothing. */
|
|
31
|
+
export declare function namesAny(value: unknown, ids: ReadonlySet<string>): boolean;
|
|
32
|
+
/** One merge's two people, as `moveIds` reads them (`erase.ts`'s `MergedAccounts` is one). */
|
|
33
|
+
export interface IdMove {
|
|
34
|
+
/** The kept account's ids. */
|
|
35
|
+
into: {
|
|
36
|
+
ids: ReadonlySet<string>;
|
|
37
|
+
};
|
|
38
|
+
/** Each of the merged-away account's ids → the kept account's counterpart. */
|
|
39
|
+
renames: ReadonlyMap<string, string>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Account merge in one shared record: the merged-away person's ids become the kept account's,
|
|
43
|
+
* unless the record already names the kept account. Such a record is a conflict (one person in
|
|
44
|
+
* it twice: a match between their two accounts, a room both sat in), and the kept account's
|
|
45
|
+
* place in it wins: the record is left alone, and the account erase that follows every merge
|
|
46
|
+
* anonymises the merged-away person's place in it as it would for anyone. Answers how many ids
|
|
47
|
+
* it renamed, 0 for a conflict or a record that names neither.
|
|
48
|
+
*/
|
|
49
|
+
export declare function moveIds(value: unknown, move: IdMove): number;
|
package/dist/erase/anonymise.js
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* One mechanism for every store, so a store's erase is "which object to walk"
|
|
7
7
|
* and never a list of the fields that happen to hold an id today: a field added
|
|
8
8
|
* tomorrow is covered without anyone remembering this file.
|
|
9
|
+
*
|
|
10
|
+
* An account merge walks the same way (`renameIds`, `moveIds`): the merged-away person's ids
|
|
11
|
+
* become the kept account's, each to its own counterpart (a userId to a userId, a derived
|
|
12
|
+
* participant id to a derived participant id), rather than every id to one placeholder.
|
|
9
13
|
*/
|
|
10
14
|
import { randomBytes } from 'node:crypto';
|
|
11
15
|
/** The id an erased person becomes: fresh per erase, so two erased people never merge into one. */
|
|
@@ -19,8 +23,20 @@ export function placeholderId() {
|
|
|
19
23
|
* change (a record may share a frozen constant). Answers how many it replaced.
|
|
20
24
|
*/
|
|
21
25
|
export function replaceIds(value, ids, to) {
|
|
26
|
+
return renameIds(value, new Map([...ids].map((id) => [id, to])));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `replaceIds` with each id renamed to its own new id (`renames`: old → new). Where a renamed
|
|
30
|
+
* key meets one that is already there (an object key, a Map key, a Set member), the one already
|
|
31
|
+
* there wins and the renamed entry is dropped: the kept account's own entry is never overwritten.
|
|
32
|
+
* Answers how many it renamed or dropped.
|
|
33
|
+
*/
|
|
34
|
+
export function renameIds(value, renames) {
|
|
22
35
|
const seen = new WeakSet();
|
|
23
|
-
const swap = (v) =>
|
|
36
|
+
const swap = (v) => {
|
|
37
|
+
const to = typeof v === 'string' ? renames.get(v) : undefined;
|
|
38
|
+
return to === undefined ? { v, n: walk(v) } : { v: to, n: 1 };
|
|
39
|
+
};
|
|
24
40
|
function walk(node) {
|
|
25
41
|
if (node === null || typeof node !== 'object' || seen.has(node))
|
|
26
42
|
return 0;
|
|
@@ -38,10 +54,13 @@ export function replaceIds(value, ids, to) {
|
|
|
38
54
|
for (const [k, v] of [...node]) {
|
|
39
55
|
const key = swap(k);
|
|
40
56
|
const val = swap(v);
|
|
41
|
-
if (key.v !== k)
|
|
57
|
+
if (key.v !== k) {
|
|
42
58
|
node.delete(k);
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
if (!node.has(key.v))
|
|
60
|
+
node.set(key.v, val.v);
|
|
61
|
+
}
|
|
62
|
+
else if (val.v !== v)
|
|
63
|
+
node.set(k, val.v);
|
|
45
64
|
n += key.n + val.n;
|
|
46
65
|
}
|
|
47
66
|
}
|
|
@@ -59,9 +78,11 @@ export function replaceIds(value, ids, to) {
|
|
|
59
78
|
const record = node;
|
|
60
79
|
for (const k of Object.keys(record)) {
|
|
61
80
|
const val = swap(record[k]);
|
|
62
|
-
|
|
81
|
+
const to = renames.get(k);
|
|
82
|
+
if (to !== undefined) {
|
|
63
83
|
delete record[k];
|
|
64
|
-
record
|
|
84
|
+
if (!Object.hasOwn(record, to))
|
|
85
|
+
record[to] = val.v;
|
|
65
86
|
n += 1 + val.n;
|
|
66
87
|
}
|
|
67
88
|
else {
|
|
@@ -75,3 +96,34 @@ export function replaceIds(value, ids, to) {
|
|
|
75
96
|
}
|
|
76
97
|
return walk(value);
|
|
77
98
|
}
|
|
99
|
+
/** Does any string in `ids` sit anywhere in `value`, by the same walk `replaceIds` makes? Writes nothing. */
|
|
100
|
+
export function namesAny(value, ids) {
|
|
101
|
+
const seen = new WeakSet();
|
|
102
|
+
const hit = (v) => (typeof v === 'string' ? ids.has(v) : visit(v));
|
|
103
|
+
function visit(node) {
|
|
104
|
+
if (node === null || typeof node !== 'object' || seen.has(node))
|
|
105
|
+
return false;
|
|
106
|
+
seen.add(node);
|
|
107
|
+
if (Array.isArray(node))
|
|
108
|
+
return node.some(hit);
|
|
109
|
+
if (node instanceof Map)
|
|
110
|
+
return [...node].some(([k, v]) => hit(k) || hit(v));
|
|
111
|
+
if (node instanceof Set)
|
|
112
|
+
return [...node].some(hit);
|
|
113
|
+
return Object.entries(node).some(([k, v]) => ids.has(k) || hit(v));
|
|
114
|
+
}
|
|
115
|
+
return visit(value);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Account merge in one shared record: the merged-away person's ids become the kept account's,
|
|
119
|
+
* unless the record already names the kept account. Such a record is a conflict (one person in
|
|
120
|
+
* it twice: a match between their two accounts, a room both sat in), and the kept account's
|
|
121
|
+
* place in it wins: the record is left alone, and the account erase that follows every merge
|
|
122
|
+
* anonymises the merged-away person's place in it as it would for anyone. Answers how many ids
|
|
123
|
+
* it renamed, 0 for a conflict or a record that names neither.
|
|
124
|
+
*/
|
|
125
|
+
export function moveIds(value, move) {
|
|
126
|
+
if (namesAny(value, move.into.ids))
|
|
127
|
+
return 0;
|
|
128
|
+
return renameIds(value, move.renames);
|
|
129
|
+
}
|
package/dist/erase/erase.d.ts
CHANGED
|
@@ -15,21 +15,47 @@
|
|
|
15
15
|
* What is erased is a list of steps each store registers where it is built (`register`), so a
|
|
16
16
|
* store and its erase live side by side in the app. Steps run one at a time, in registration
|
|
17
17
|
* order, so two never rewrite one file at once.
|
|
18
|
+
*
|
|
19
|
+
* ## Account merge, `POST /api/_account/merge`
|
|
20
|
+
*
|
|
21
|
+
* The edge merges one person's two accounts (hadoku_site `docs/planning/account-journeys-2026-11-18.md`
|
|
22
|
+
* §J6; edge-router `account-erase.ts`'s `mergeMemberData`): the same seal, `X-User-Id` the account
|
|
23
|
+
* going away (`from`), `X-Merge-Into` the account kept (`into`). It wants 200 `{ merged: { <what>:
|
|
24
|
+
* <count> } }`, zeros on a second call, and anything else leaves both accounts as they were for
|
|
25
|
+
* the edge to retry. Then it closes `from` and calls the erase hook on it as a sweep, so whatever a
|
|
26
|
+
* merge leaves under `from` is erased: a merge MOVES what should survive, and only that.
|
|
27
|
+
*
|
|
28
|
+
* The rule (operator, 2026-11-18): the kept account wins any conflict; otherwise union. Every
|
|
29
|
+
* step decides its own store's merge beside its erase — `EraseStep.merge` is required, so a store
|
|
30
|
+
* cannot gain an erase without a merge decision — and one that moves nothing answers 0 and says
|
|
31
|
+
* why where it is written.
|
|
18
32
|
*/
|
|
19
33
|
import type { Request, Response } from 'express';
|
|
20
34
|
/** `/api/_account/erase` — the one path every app answers this hook on. */
|
|
21
35
|
export declare const ERASE_PATH = "/api/_account/erase";
|
|
22
|
-
/**
|
|
23
|
-
export
|
|
36
|
+
/** `/api/_account/merge` — the merge hook's path, beside the erase hook's. */
|
|
37
|
+
export declare const MERGE_PATH = "/api/_account/merge";
|
|
38
|
+
/** One account, by every id this app knows it by. */
|
|
39
|
+
export interface AccountIds {
|
|
24
40
|
/** The registry userId, as the edge sent it. */
|
|
25
41
|
userId: string;
|
|
26
42
|
/** The app's own id for this person (its identity scheme's derived id). */
|
|
27
43
|
participantId: string;
|
|
28
44
|
/** Both of the above: what a shared record names them by (`replaceIds`). */
|
|
29
45
|
ids: ReadonlySet<string>;
|
|
46
|
+
}
|
|
47
|
+
/** Whom one erase is for. */
|
|
48
|
+
export interface ErasedPerson extends AccountIds {
|
|
30
49
|
/** What they become in a shared record, one per erase (`placeholderId`). */
|
|
31
50
|
placeholder: string;
|
|
32
51
|
}
|
|
52
|
+
/** One merge: `from` goes away, `into` is kept. */
|
|
53
|
+
export interface MergedAccounts {
|
|
54
|
+
from: AccountIds;
|
|
55
|
+
into: AccountIds;
|
|
56
|
+
/** Each of `from`'s ids → `into`'s counterpart: userId → userId, participantId → participantId (`renameIds`, `moveIds`). */
|
|
57
|
+
renames: ReadonlyMap<string, string>;
|
|
58
|
+
}
|
|
33
59
|
/**
|
|
34
60
|
* One store's part of an erase: how many of the person's records it erased or anonymised,
|
|
35
61
|
* zero when none are left. A store with several kinds of record answers a count for each,
|
|
@@ -39,14 +65,25 @@ export type EraseCounts = number | Record<string, number>;
|
|
|
39
65
|
export interface EraseStep {
|
|
40
66
|
what: string;
|
|
41
67
|
erase(person: ErasedPerson): EraseCounts | Promise<EraseCounts>;
|
|
68
|
+
/**
|
|
69
|
+
* This store's part of an account merge: move what `from` holds here to `into`, the kept
|
|
70
|
+
* account winning any conflict, and answer what moved, zero once nothing is left to move.
|
|
71
|
+
* Required, so no store is erased on a merge by omission: a store that moves nothing answers 0,
|
|
72
|
+
* with the reason written beside it.
|
|
73
|
+
*/
|
|
74
|
+
merge(accounts: MergedAccounts): EraseCounts | Promise<EraseCounts>;
|
|
42
75
|
}
|
|
43
76
|
export interface AccountErase {
|
|
44
|
-
/** Add a store's step. A second step under one name is a wiring bug and throws. */
|
|
77
|
+
/** Add a store's step. A second step under one name, or one with no `merge`, is a wiring bug and throws. */
|
|
45
78
|
register(step: EraseStep): void;
|
|
46
79
|
/** Run every step for this userId. Throws the first step's failure. */
|
|
47
80
|
erase(userId: string): Promise<Record<string, number>>;
|
|
48
|
-
/**
|
|
81
|
+
/** Run every step's merge of `fromUserId` into `intoUserId`. Throws the first step's failure. */
|
|
82
|
+
merge(fromUserId: string, intoUserId: string): Promise<Record<string, number>>;
|
|
83
|
+
/** The erase route's handler. */
|
|
49
84
|
handle(req: Request, res: Response): Promise<void>;
|
|
85
|
+
/** The merge route's handler. */
|
|
86
|
+
handleMerge(req: Request, res: Response): Promise<void>;
|
|
50
87
|
}
|
|
51
88
|
export interface AccountEraseOptions {
|
|
52
89
|
log: (entry: Record<string, unknown>) => void;
|
|
@@ -56,4 +93,5 @@ export interface AccountEraseOptions {
|
|
|
56
93
|
deriveParticipantId: (userId: string) => string;
|
|
57
94
|
}
|
|
58
95
|
export declare function personOf(userId: string, deriveParticipantId: (userId: string) => string): ErasedPerson;
|
|
96
|
+
export declare function mergedAccountsOf(fromUserId: string, intoUserId: string, deriveParticipantId: (userId: string) => string): MergedAccounts;
|
|
59
97
|
export declare function createAccountErase(opts: AccountEraseOptions): AccountErase;
|
package/dist/erase/erase.js
CHANGED
|
@@ -15,44 +15,91 @@
|
|
|
15
15
|
* What is erased is a list of steps each store registers where it is built (`register`), so a
|
|
16
16
|
* store and its erase live side by side in the app. Steps run one at a time, in registration
|
|
17
17
|
* order, so two never rewrite one file at once.
|
|
18
|
+
*
|
|
19
|
+
* ## Account merge, `POST /api/_account/merge`
|
|
20
|
+
*
|
|
21
|
+
* The edge merges one person's two accounts (hadoku_site `docs/planning/account-journeys-2026-11-18.md`
|
|
22
|
+
* §J6; edge-router `account-erase.ts`'s `mergeMemberData`): the same seal, `X-User-Id` the account
|
|
23
|
+
* going away (`from`), `X-Merge-Into` the account kept (`into`). It wants 200 `{ merged: { <what>:
|
|
24
|
+
* <count> } }`, zeros on a second call, and anything else leaves both accounts as they were for
|
|
25
|
+
* the edge to retry. Then it closes `from` and calls the erase hook on it as a sweep, so whatever a
|
|
26
|
+
* merge leaves under `from` is erased: a merge MOVES what should survive, and only that.
|
|
27
|
+
*
|
|
28
|
+
* The rule (operator, 2026-11-18): the kept account wins any conflict; otherwise union. Every
|
|
29
|
+
* step decides its own store's merge beside its erase — `EraseStep.merge` is required, so a store
|
|
30
|
+
* cannot gain an erase without a merge decision — and one that moves nothing answers 0 and says
|
|
31
|
+
* why where it is written.
|
|
18
32
|
*/
|
|
19
33
|
import { placeholderId } from "./anonymise.js";
|
|
20
34
|
import { reportSealRefused } from "../telemetry/telemetry.js";
|
|
21
35
|
/** `/api/_account/erase` — the one path every app answers this hook on. */
|
|
22
36
|
export const ERASE_PATH = '/api/_account/erase';
|
|
37
|
+
/** `/api/_account/merge` — the merge hook's path, beside the erase hook's. */
|
|
38
|
+
export const MERGE_PATH = '/api/_account/merge';
|
|
23
39
|
export function personOf(userId, deriveParticipantId) {
|
|
40
|
+
return { ...accountOf(userId, deriveParticipantId), placeholder: placeholderId() };
|
|
41
|
+
}
|
|
42
|
+
function accountOf(userId, deriveParticipantId) {
|
|
24
43
|
const participantId = deriveParticipantId(userId);
|
|
25
|
-
return { userId, participantId, ids: new Set([userId, participantId])
|
|
44
|
+
return { userId, participantId, ids: new Set([userId, participantId]) };
|
|
45
|
+
}
|
|
46
|
+
export function mergedAccountsOf(fromUserId, intoUserId, deriveParticipantId) {
|
|
47
|
+
const from = accountOf(fromUserId, deriveParticipantId);
|
|
48
|
+
const into = accountOf(intoUserId, deriveParticipantId);
|
|
49
|
+
return {
|
|
50
|
+
from,
|
|
51
|
+
into,
|
|
52
|
+
renames: new Map([
|
|
53
|
+
[from.userId, into.userId],
|
|
54
|
+
[from.participantId, into.participantId],
|
|
55
|
+
]),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** A trimmed header, or '' for none. */
|
|
59
|
+
function headerOf(req, name) {
|
|
60
|
+
const raw = req.headers[name];
|
|
61
|
+
return typeof raw === 'string' ? raw.trim() : '';
|
|
62
|
+
}
|
|
63
|
+
function totalOf(into, step, counts) {
|
|
64
|
+
if (typeof counts === 'number')
|
|
65
|
+
into[step.what] = counts;
|
|
66
|
+
else
|
|
67
|
+
Object.assign(into, counts);
|
|
26
68
|
}
|
|
27
69
|
export function createAccountErase(opts) {
|
|
28
70
|
const steps = [];
|
|
29
71
|
const erase = async (userId) => {
|
|
30
72
|
const person = personOf(userId, opts.deriveParticipantId);
|
|
31
73
|
const erased = {};
|
|
32
|
-
for (const step of steps)
|
|
33
|
-
|
|
34
|
-
if (typeof counts === 'number')
|
|
35
|
-
erased[step.what] = counts;
|
|
36
|
-
else
|
|
37
|
-
Object.assign(erased, counts);
|
|
38
|
-
}
|
|
74
|
+
for (const step of steps)
|
|
75
|
+
totalOf(erased, step, await step.erase(person));
|
|
39
76
|
return erased;
|
|
40
77
|
};
|
|
78
|
+
const merge = async (fromUserId, intoUserId) => {
|
|
79
|
+
const accounts = mergedAccountsOf(fromUserId, intoUserId, opts.deriveParticipantId);
|
|
80
|
+
const merged = {};
|
|
81
|
+
for (const step of steps)
|
|
82
|
+
totalOf(merged, step, await step.merge(accounts));
|
|
83
|
+
return merged;
|
|
84
|
+
};
|
|
41
85
|
return {
|
|
42
86
|
register(step) {
|
|
43
87
|
if (steps.some((s) => s.what === step.what))
|
|
44
88
|
throw new Error(`erase step '${step.what}' is registered twice`);
|
|
89
|
+
// The type already requires it; this catches a step built where the type was cast away.
|
|
90
|
+
if (typeof step.merge !== 'function')
|
|
91
|
+
throw new Error(`erase step '${step.what}' has no merge decision`);
|
|
45
92
|
steps.push(step);
|
|
46
93
|
},
|
|
47
94
|
erase,
|
|
95
|
+
merge,
|
|
48
96
|
async handle(req, res) {
|
|
49
97
|
if (!opts.edgeSealed(req)) {
|
|
50
98
|
reportSealRefused('http', req.headers, req.path);
|
|
51
99
|
res.status(401).json({ error: "erase needs the edge's seal" });
|
|
52
100
|
return;
|
|
53
101
|
}
|
|
54
|
-
const
|
|
55
|
-
const userId = typeof raw === 'string' ? raw.trim() : '';
|
|
102
|
+
const userId = headerOf(req, 'x-user-id');
|
|
56
103
|
if (userId === '') {
|
|
57
104
|
res.status(400).json({ error: 'X-User-Id: whose data to erase' });
|
|
58
105
|
return;
|
|
@@ -68,5 +115,32 @@ export function createAccountErase(opts) {
|
|
|
68
115
|
res.status(500).json({ error: reason });
|
|
69
116
|
}
|
|
70
117
|
},
|
|
118
|
+
async handleMerge(req, res) {
|
|
119
|
+
if (!opts.edgeSealed(req)) {
|
|
120
|
+
reportSealRefused('http', req.headers, req.path);
|
|
121
|
+
res.status(401).json({ error: "merge needs the edge's seal" });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const from = headerOf(req, 'x-user-id');
|
|
125
|
+
const into = headerOf(req, 'x-merge-into');
|
|
126
|
+
if (from === '' || into === '') {
|
|
127
|
+
res.status(400).json({ error: 'X-User-Id: the account going away; X-Merge-Into: the account kept' });
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (from === into) {
|
|
131
|
+
res.status(400).json({ error: 'an account cannot be merged into itself' });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const merged = await merge(from, into);
|
|
136
|
+
opts.log({ evt: 'account-merged', from, into, merged });
|
|
137
|
+
res.json({ merged });
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
141
|
+
opts.log({ evt: 'account-merge-failed', from, into, reason });
|
|
142
|
+
res.status(500).json({ error: reason });
|
|
143
|
+
}
|
|
144
|
+
},
|
|
71
145
|
};
|
|
72
146
|
}
|
package/dist/erase/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { placeholderId, replaceIds } from './anonymise.js';
|
|
2
|
-
export { createAccountErase, ERASE_PATH, personOf, type AccountErase, type AccountEraseOptions, type EraseCounts, type ErasedPerson, type EraseStep, } from './erase.js';
|
|
1
|
+
export { moveIds, namesAny, placeholderId, renameIds, replaceIds, type IdMove } from './anonymise.js';
|
|
2
|
+
export { createAccountErase, ERASE_PATH, MERGE_PATH, mergedAccountsOf, personOf, type AccountErase, type AccountEraseOptions, type AccountIds, type EraseCounts, type ErasedPerson, type EraseStep, type MergedAccounts, } from './erase.js';
|
package/dist/erase/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { placeholderId, replaceIds } from "./anonymise.js";
|
|
2
|
-
export { createAccountErase, ERASE_PATH, personOf, } from "./erase.js";
|
|
1
|
+
export { moveIds, namesAny, placeholderId, renameIds, replaceIds } from "./anonymise.js";
|
|
2
|
+
export { createAccountErase, ERASE_PATH, MERGE_PATH, mergedAccountsOf, personOf, } from "./erase.js";
|
package/dist/server/server.js
CHANGED
|
@@ -56,7 +56,7 @@ import express from 'express';
|
|
|
56
56
|
import { Server as SocketIOServer } from 'socket.io';
|
|
57
57
|
import { callerIdOf, tierOf, userIdOf } from "../auth/index.js";
|
|
58
58
|
import { capacitySampler } from "../capacity/index.js";
|
|
59
|
-
import { createAccountErase, ERASE_PATH } from "../erase/index.js";
|
|
59
|
+
import { createAccountErase, ERASE_PATH, MERGE_PATH } from "../erase/index.js";
|
|
60
60
|
import { healthResponse, readCommit, serviceIdOf } from "../health/index.js";
|
|
61
61
|
import { checkBundle, isEmbedEntry, stampOrigin } from "../http/index.js";
|
|
62
62
|
import { bootClock, busyHandler, closeConnections, sendThenFlush } from "../lifecycle/index.js";
|
|
@@ -132,6 +132,7 @@ export async function createGameServer({ id, config, state, plugins }) {
|
|
|
132
132
|
}));
|
|
133
133
|
// The edge's seal only, never a tier, and above first-seen so an erase does not record the person again.
|
|
134
134
|
app.post(ERASE_PATH, (req, res) => void accountErase.handle(req, res));
|
|
135
|
+
app.post(MERGE_PATH, (req, res) => void accountErase.handleMerge(req, res));
|
|
135
136
|
const sealed = express.Router();
|
|
136
137
|
app.use((req, res, next) => (config.edgeAuth.edgeSealed(req) ? sealed(req, res, next) : next()));
|
|
137
138
|
// ── The tier floor: everything below is gated ──
|
|
@@ -192,7 +193,14 @@ export async function createGameServer({ id, config, state, plugins }) {
|
|
|
192
193
|
await runPhase('config');
|
|
193
194
|
seen = firstSeen({ file: config.firstSeen.file, userIdOf: callerIdOf, tierOf, log: config.firstSeen.log });
|
|
194
195
|
const callersSeen = seen;
|
|
195
|
-
accountErase.register({
|
|
196
|
+
accountErase.register({
|
|
197
|
+
what: 'callersSeen',
|
|
198
|
+
erase: (p) => callersSeen.forget(p.userId),
|
|
199
|
+
// Nothing moves: first-seen is a fact about each account (its own `caller-first-seen`), not
|
|
200
|
+
// something the person owns. The kept account keeps its own; the merged-away one's entry goes
|
|
201
|
+
// in the erase sweep that follows the merge.
|
|
202
|
+
merge: () => 0,
|
|
203
|
+
});
|
|
196
204
|
verdict = await checkBundle(config.bundle.indexHtml, config.basePrefix);
|
|
197
205
|
await runPhase('bundle');
|
|
198
206
|
if (config.telemetry !== undefined)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/service-kernel",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.137",
|
|
4
|
+
"gitHead": "23d61b02b042b181d594268a3e6d1f0f39c7d12a",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The server parts any game keeps: edge auth and the tier gate, base path and bundle check, health and the busy probe, lifecycle, the JSON logger, the state directory, telemetry and capacity, per-caller limits, the browser relays, the erase registry, and createGameServer, which boots a game from its config and plugins. Knows no game; the app binds its service id, prefix and env names. MIT; imports only node built-ins, express, socket.io and @wolffm/*.",
|