@baukit/api-runtime 0.5.2 → 0.7.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 CHANGED
@@ -194,3 +194,51 @@ await runtime.fetch('/widgets');
194
194
  mock.assertRequest(0, { method: 'GET', url: 'https://api.example.test/widgets' });
195
195
  mock.assertQueueEmpty();
196
196
  ```
197
+
198
+ ## Profile and sign-in account deletion
199
+
200
+ Import `createProfileErasureClient` from `@baukit/api-runtime/erasure`. Pass the
201
+ account's immutable subject, an authenticated fetch, and durable
202
+ `IdempotencyKeyStorage`. Persist keys separately from tokens. The template
203
+ adapters hash the storage slot so it contains no raw subject.
204
+
205
+ ```ts
206
+ const erasure = createProfileErasureClient({
207
+ account: subject,
208
+ fetch: runtime.fetch,
209
+ storage: persistedKeys,
210
+ });
211
+ const receipt = await erasure.erase(signal);
212
+ if (receipt.status === 'pending' && receipt.operationId !== null) {
213
+ const operation = await erasure.poll(receipt.operationId, { signal });
214
+ }
215
+ ```
216
+
217
+ `erase` sends `DELETE /me` with `Idempotency-Key`. It validates the 200 completed
218
+ and 202 pending bodies. A network drop, abort after sending, malformed success
219
+ body, or uncertain server error throws `AmbiguousProfileErasureError`. Its code
220
+ is compatible with `eraseProductProfile`. Keep the same key for a later retry,
221
+ even after a reload. A completed or pending receipt, including 401
222
+ `profile_erased`, settles the key as committed and removes it from durable
223
+ storage. An uncertain key does not expire on a timer. If key removal fails,
224
+ `ProfileErasureKeyCleanupError` carries the committed receipt so callers can
225
+ still erase local data and sign out, then report the local cleanup failure.
226
+ The client releases a key on 409 `erasure_idempotency_conflict`. Other
227
+ rejections keep it because an earlier attempt could have committed before a
228
+ response was lost.
229
+
230
+ A 401 `profile_erased` confirms that server profile erasure committed. It returns
231
+ pending with a null operation ID because the fence does not prove the sign-in
232
+ account is already gone. An ordinary 401 still rejects.
233
+
234
+ `poll` reads `GET /me/erasures/{operationId}` immediately, then waits 500 ms,
235
+ 1 second, 2 seconds, and at most 5 seconds between reads. It stops at completed,
236
+ failed, or eight reads and returns the last pending state at that limit.
237
+ `maxAttempts`, `initialDelayMs`, and `maxDelayMs` can change those bounds. An abort
238
+ cancels both the fetch and the backoff timer. A failed operation needs operator
239
+ help; clients must not send another deletion to repair it.
240
+
241
+ The auth templates capture a short-lived access token for this operation before
242
+ clearing local authentication. Status checks use that token while the screen
243
+ stays open, without refreshing or restoring a signed-out session. A failed
244
+ status check does not undo deletion; the server worker continues.
@@ -0,0 +1,51 @@
1
+ import { type FetchImplementation } from './index.js';
2
+ import { type IdempotencyKeyStorage } from './idempotency.js';
3
+ export type ProfileErasureReceipt = {
4
+ readonly status: 'completed';
5
+ readonly operationId: string;
6
+ readonly completedAt: string;
7
+ } | {
8
+ readonly status: 'pending';
9
+ readonly operationId: string | null;
10
+ };
11
+ export type ProfileErasureOperation = {
12
+ readonly status: 'pending' | 'failed';
13
+ readonly operationId: string;
14
+ } | {
15
+ readonly status: 'completed';
16
+ readonly operationId: string;
17
+ readonly completedAt?: string;
18
+ };
19
+ export interface ProfileErasureClientOptions {
20
+ readonly fetch: FetchImplementation;
21
+ readonly account: string;
22
+ /** Durable storage, separate from tokens so a lost response survives a reload. */
23
+ readonly storage: IdempotencyKeyStorage;
24
+ readonly keyFactory?: () => string;
25
+ }
26
+ export interface ProfileErasurePollingOptions {
27
+ readonly signal?: AbortSignal;
28
+ /** Total status reads. Defaults to 8. A still-pending operation is returned at the limit. */
29
+ readonly maxAttempts?: number;
30
+ readonly initialDelayMs?: number;
31
+ readonly maxDelayMs?: number;
32
+ }
33
+ export interface ProfileErasureClient {
34
+ erase(signal?: AbortSignal): Promise<ProfileErasureReceipt>;
35
+ poll(operationId: string, options?: ProfileErasurePollingOptions): Promise<ProfileErasureOperation>;
36
+ }
37
+ /** A committed receipt whose durable key could not be removed from this device. */
38
+ export declare class ProfileErasureKeyCleanupError extends Error {
39
+ readonly receipt: ProfileErasureReceipt;
40
+ readonly name = "ProfileErasureKeyCleanupError";
41
+ constructor(receipt: ProfileErasureReceipt, cause: unknown);
42
+ }
43
+ /** Compatible with the ambiguous error contract in @baukit/data-contracts. */
44
+ export declare class AmbiguousProfileErasureError extends Error {
45
+ readonly name = "AmbiguousProfileErasureError";
46
+ readonly code: "product_profile_erasure_ambiguous";
47
+ constructor(cause: unknown);
48
+ }
49
+ /** Creates a client for DELETE /me and its fenced-subject status endpoint. */
50
+ export declare function createProfileErasureClient(options: ProfileErasureClientOptions): ProfileErasureClient;
51
+ //# sourceMappingURL=erasure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erasure.d.ts","sourceRoot":"","sources":["../src/erasure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC5F;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,uBAAuB,GAC/B;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC5D,IAAI,CACF,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC;AAED,mFAAmF;AACnF,qBAAa,6BAA8B,SAAQ,KAAK;aAIpC,OAAO,EAAE,qBAAqB;IAHhD,SAAyB,IAAI,mCAAmC;gBAG9C,OAAO,EAAE,qBAAqB,EAC9C,KAAK,EAAE,OAAO;CAIjB;AAED,8EAA8E;AAC9E,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAyB,IAAI,kCAAkC;IAC/D,SAAgB,IAAI,EAAG,mCAAmC,CAAU;gBAEjD,KAAK,EAAE,OAAO;CAGlC;AASD,8EAA8E;AAC9E,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,oBAAoB,CA4DtB"}
@@ -0,0 +1,172 @@
1
+ import { ApiError, normalizeResponseError } from './index.js';
2
+ import { classifyMutationError, createIdempotencyKeyStore, } from './idempotency.js';
3
+ /** A committed receipt whose durable key could not be removed from this device. */
4
+ export class ProfileErasureKeyCleanupError extends Error {
5
+ receipt;
6
+ name = 'ProfileErasureKeyCleanupError';
7
+ constructor(receipt, cause) {
8
+ super('The committed erasure key could not be removed.', { cause });
9
+ this.receipt = receipt;
10
+ }
11
+ }
12
+ /** Compatible with the ambiguous error contract in @baukit/data-contracts. */
13
+ export class AmbiguousProfileErasureError extends Error {
14
+ name = 'AmbiguousProfileErasureError';
15
+ code = 'product_profile_erasure_ambiguous';
16
+ constructor(cause) {
17
+ super('The server erasure outcome is unknown.', { cause });
18
+ }
19
+ }
20
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
21
+ const TIMESTAMP_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/u;
22
+ const IDEMPOTENCY_KEY_PATTERN = /^[\x21-\x7e]{16,128}$/u;
23
+ const INITIAL_DELAY_MS = 500;
24
+ const MAX_DELAY_MS = 5_000;
25
+ const MAX_ATTEMPTS = 8;
26
+ /** Creates a client for DELETE /me and its fenced-subject status endpoint. */
27
+ export function createProfileErasureClient(options) {
28
+ if (options.account.trim() === '')
29
+ throw new TypeError('An erasure account is required.');
30
+ const keys = createIdempotencyKeyStore({
31
+ // An uncertain erasure must keep its key, even if the user returns much later.
32
+ ttlMs: Number.MAX_SAFE_INTEGER,
33
+ storage: options.storage,
34
+ ...(options.keyFactory === undefined ? {} : { keyFactory: options.keyFactory }),
35
+ });
36
+ const intent = { account: options.account, operation: 'profile.erase', body: null };
37
+ return {
38
+ async erase(signal) {
39
+ signal?.throwIfAborted();
40
+ const key = await keys.keyFor(intent);
41
+ if (!IDEMPOTENCY_KEY_PATTERN.test(key))
42
+ throw new TypeError('Invalid erasure idempotency key.');
43
+ signal?.throwIfAborted();
44
+ let receipt;
45
+ try {
46
+ const response = await options.fetch('/me', {
47
+ method: 'DELETE',
48
+ headers: { 'Idempotency-Key': key },
49
+ ...(signal === undefined ? {} : { signal }),
50
+ });
51
+ if (!response.ok)
52
+ throw await normalizeResponseError(response);
53
+ const value = await response.json();
54
+ receipt = parseReceipt(value, response.status);
55
+ }
56
+ catch (cause) {
57
+ if (isErasedFence(cause)) {
58
+ receipt = { status: 'pending', operationId: null };
59
+ }
60
+ else if (classifyMutationError(cause) === 'not-committed') {
61
+ if (cause instanceof ApiError && cause.code === 'erasure_idempotency_conflict') {
62
+ await keys.settle(intent, 'not-committed');
63
+ }
64
+ throw cause;
65
+ }
66
+ else
67
+ throw new AmbiguousProfileErasureError(cause);
68
+ }
69
+ try {
70
+ await keys.settle(intent, 'committed');
71
+ }
72
+ catch (cause) {
73
+ throw new ProfileErasureKeyCleanupError(receipt, cause);
74
+ }
75
+ return receipt;
76
+ },
77
+ async poll(operationId, polling = {}) {
78
+ if (!UUID_PATTERN.test(operationId))
79
+ throw new TypeError('Invalid erasure operation ID.');
80
+ const maxAttempts = positiveInteger(polling.maxAttempts ?? MAX_ATTEMPTS, 'maxAttempts');
81
+ let delayMs = positiveInteger(polling.initialDelayMs ?? INITIAL_DELAY_MS, 'initialDelayMs');
82
+ const maxDelayMs = positiveInteger(polling.maxDelayMs ?? MAX_DELAY_MS, 'maxDelayMs');
83
+ delayMs = Math.min(delayMs, maxDelayMs);
84
+ for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
85
+ polling.signal?.throwIfAborted();
86
+ const operation = await readOperation(options.fetch, operationId, polling.signal);
87
+ if (operation.status !== 'pending' || attempt === maxAttempts - 1)
88
+ return operation;
89
+ await waitForPoll(delayMs, polling.signal);
90
+ delayMs = Math.min(delayMs * 2, maxDelayMs);
91
+ }
92
+ throw new RangeError('Invalid erasure polling limit.');
93
+ },
94
+ };
95
+ }
96
+ function isErasedFence(cause) {
97
+ return cause instanceof ApiError && cause.status === 401 && cause.code === 'profile_erased';
98
+ }
99
+ async function readOperation(fetch, operationId, signal) {
100
+ try {
101
+ const response = await fetch(`/me/erasures/${encodeURIComponent(operationId)}`, {
102
+ method: 'GET',
103
+ ...(signal === undefined ? {} : { signal }),
104
+ });
105
+ signal?.throwIfAborted();
106
+ if (!response.ok)
107
+ throw await normalizeResponseError(response);
108
+ const value = await response.json();
109
+ const operation = parseOperation(value);
110
+ if (operation.operationId !== operationId)
111
+ throw new TypeError('Erasure operation ID mismatch.');
112
+ return operation;
113
+ }
114
+ catch (cause) {
115
+ if (isErasedFence(cause))
116
+ return { status: 'pending', operationId };
117
+ throw cause;
118
+ }
119
+ }
120
+ function parseReceipt(value, status) {
121
+ const operation = parseOperation(value);
122
+ if (status === 202 && operation.status === 'pending') {
123
+ return { status: 'pending', operationId: operation.operationId };
124
+ }
125
+ if (status === 200 && operation.status === 'completed' && operation.completedAt !== undefined) {
126
+ return { ...operation, completedAt: operation.completedAt };
127
+ }
128
+ throw new TypeError('Invalid erasure receipt.');
129
+ }
130
+ function parseOperation(value) {
131
+ if (typeof value !== 'object' || value === null)
132
+ throw new TypeError('Invalid erasure operation.');
133
+ const operationId = Reflect.get(value, 'operationId');
134
+ const status = Reflect.get(value, 'status');
135
+ const completedAt = Reflect.get(value, 'completedAt');
136
+ if (typeof operationId !== 'string' || !UUID_PATTERN.test(operationId)) {
137
+ throw new TypeError('Invalid erasure operation ID.');
138
+ }
139
+ if (status === 'pending' || status === 'failed')
140
+ return { operationId, status };
141
+ if (status !== 'completed')
142
+ throw new TypeError('Invalid erasure operation status.');
143
+ if (completedAt === undefined)
144
+ return { operationId, status };
145
+ if (typeof completedAt !== 'string' ||
146
+ !TIMESTAMP_PATTERN.test(completedAt) ||
147
+ !Number.isFinite(Date.parse(completedAt))) {
148
+ throw new TypeError('Invalid erasure completion time.');
149
+ }
150
+ return { operationId, status, completedAt };
151
+ }
152
+ function positiveInteger(value, name) {
153
+ if (!Number.isSafeInteger(value) || value <= 0)
154
+ throw new RangeError(`${name} must be positive.`);
155
+ return value;
156
+ }
157
+ function waitForPoll(delayMs, signal) {
158
+ signal?.throwIfAborted();
159
+ return new Promise((resolve, reject) => {
160
+ const onAbort = () => {
161
+ globalThis.clearTimeout(timer);
162
+ const reason = signal?.reason;
163
+ reject(reason instanceof Error ? reason : new Error('Erasure polling aborted.', { cause: reason }));
164
+ };
165
+ const timer = globalThis.setTimeout(() => {
166
+ signal?.removeEventListener('abort', onAbort);
167
+ resolve();
168
+ }, delayMs);
169
+ signal?.addEventListener('abort', onAbort, { once: true });
170
+ });
171
+ }
172
+ //# sourceMappingURL=erasure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erasure.js","sourceRoot":"","sources":["../src/erasure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAA4B,MAAM,YAAY,CAAC;AACxF,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAE1B,MAAM,kBAAkB,CAAC;AAkC1B,mFAAmF;AACnF,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IAIpC;IAHO,IAAI,GAAG,+BAA+B,CAAC;IAEhE,YACkB,OAA8B,EAC9C,KAAc;QAEd,KAAK,CAAC,iDAAiD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAHpD,YAAO,GAAP,OAAO,CAAuB;IAIhD,CAAC;CACF;AAED,8EAA8E;AAC9E,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAC5B,IAAI,GAAG,8BAA8B,CAAC;IAC/C,IAAI,GAAG,mCAA4C,CAAC;IAEpE,YAAmB,KAAc;QAC/B,KAAK,CAAC,wCAAwC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAED,MAAM,YAAY,GAAG,kEAAkE,CAAC;AACxF,MAAM,iBAAiB,GAAG,uEAAuE,CAAC;AAClG,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,8EAA8E;AAC9E,MAAM,UAAU,0BAA0B,CACxC,OAAoC;IAEpC,IAAI,OAAO,CAAC,OAAO,CAAC,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,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,MAAM,MAAM,GAAY,MAAM,EAAE,MAAM,CAAC;YACvC,MAAM,CACJ,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAC5F,CAAC;QACJ,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE;YACvC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,OAAO,CAAC,CAAC;QACZ,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baukit/api-runtime",
3
- "version": "0.5.2",
3
+ "version": "0.7.0",
4
4
  "description": "Shared client-side behavior for product APIs: environment selection, auth and request-ID headers, trace propagation, normalized errors, and safe retries.",
5
5
  "license": "MIT",
6
6
  "author": "Patrick Koss",
@@ -27,6 +27,11 @@
27
27
  "import": "./dist/index.js",
28
28
  "default": "./dist/index.js"
29
29
  },
30
+ "./erasure": {
31
+ "types": "./dist/erasure.d.ts",
32
+ "import": "./dist/erasure.js",
33
+ "default": "./dist/erasure.js"
34
+ },
30
35
  "./backoff": {
31
36
  "types": "./dist/backoff.d.ts",
32
37
  "import": "./dist/backoff.js",