@opendatalabs/personal-server-ts-core 1.43.1 → 1.43.2

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.
Files changed (71) hide show
  1. package/dist/api/owner-connector-delete.d.ts +20 -2
  2. package/dist/api/owner-connector-delete.d.ts.map +1 -1
  3. package/dist/api/owner-connector-delete.js +18 -6
  4. package/dist/api/owner-connector-delete.js.map +1 -1
  5. package/dist/localdb/cycle.d.ts +7 -4
  6. package/dist/localdb/cycle.d.ts.map +1 -1
  7. package/dist/localdb/cycle.js +51 -31
  8. package/dist/localdb/cycle.js.map +1 -1
  9. package/dist/localdb/delete-status.d.ts +53 -0
  10. package/dist/localdb/delete-status.d.ts.map +1 -0
  11. package/dist/localdb/delete-status.js +19 -0
  12. package/dist/localdb/delete-status.js.map +1 -0
  13. package/dist/localdb/delete.d.ts +48 -2
  14. package/dist/localdb/delete.d.ts.map +1 -1
  15. package/dist/localdb/delete.js +508 -42
  16. package/dist/localdb/delete.js.map +1 -1
  17. package/dist/localdb/index.d.ts +2 -0
  18. package/dist/localdb/index.d.ts.map +1 -1
  19. package/dist/localdb/index.js +1 -0
  20. package/dist/localdb/index.js.map +1 -1
  21. package/dist/localdb/legacy-delete.d.ts +89 -0
  22. package/dist/localdb/legacy-delete.d.ts.map +1 -0
  23. package/dist/localdb/legacy-delete.js +279 -0
  24. package/dist/localdb/legacy-delete.js.map +1 -0
  25. package/dist/localdb/log-erase.d.ts +55 -4
  26. package/dist/localdb/log-erase.d.ts.map +1 -1
  27. package/dist/localdb/log-erase.js +76 -8
  28. package/dist/localdb/log-erase.js.map +1 -1
  29. package/dist/localdb/purge.d.ts +42 -9
  30. package/dist/localdb/purge.d.ts.map +1 -1
  31. package/dist/localdb/purge.js +38 -4
  32. package/dist/localdb/purge.js.map +1 -1
  33. package/dist/localdb/schema.d.ts.map +1 -1
  34. package/dist/localdb/schema.js +39 -0
  35. package/dist/localdb/schema.js.map +1 -1
  36. package/dist/localdb/sync.d.ts +8 -0
  37. package/dist/localdb/sync.d.ts.map +1 -1
  38. package/dist/localdb/sync.js +30 -6
  39. package/dist/localdb/sync.js.map +1 -1
  40. package/dist/stream-sync/registry.d.ts.map +1 -1
  41. package/dist/stream-sync/registry.js +25 -0
  42. package/dist/stream-sync/registry.js.map +1 -1
  43. package/dist/sync/delete-data-port.d.ts +10 -0
  44. package/dist/sync/delete-data-port.d.ts.map +1 -1
  45. package/dist/sync/delete-data-port.js +70 -29
  46. package/dist/sync/delete-data-port.js.map +1 -1
  47. package/dist/sync/engine/sync-manager.d.ts +7 -2
  48. package/dist/sync/engine/sync-manager.d.ts.map +1 -1
  49. package/dist/sync/engine/sync-manager.js +6 -3
  50. package/dist/sync/engine/sync-manager.js.map +1 -1
  51. package/dist/sync/gateway-refusal.d.ts +36 -0
  52. package/dist/sync/gateway-refusal.d.ts.map +1 -0
  53. package/dist/sync/gateway-refusal.js +45 -0
  54. package/dist/sync/gateway-refusal.js.map +1 -0
  55. package/dist/sync/tombstone-resubmits.d.ts +3 -1
  56. package/dist/sync/tombstone-resubmits.d.ts.map +1 -1
  57. package/dist/sync/tombstone-resubmits.js.map +1 -1
  58. package/dist/sync/workers/delete.d.ts +6 -0
  59. package/dist/sync/workers/delete.d.ts.map +1 -1
  60. package/dist/sync/workers/delete.js +29 -30
  61. package/dist/sync/workers/delete.js.map +1 -1
  62. package/dist/test-utils/legacy-delete-ports.d.ts +24 -0
  63. package/dist/test-utils/legacy-delete-ports.d.ts.map +1 -0
  64. package/dist/test-utils/legacy-delete-ports.js +91 -0
  65. package/dist/test-utils/legacy-delete-ports.js.map +1 -0
  66. package/dist/test-utils/legacy-gateway-fake.d.ts +88 -0
  67. package/dist/test-utils/legacy-gateway-fake.d.ts.map +1 -0
  68. package/dist/test-utils/legacy-gateway-fake.js +243 -0
  69. package/dist/test-utils/legacy-gateway-fake.js.map +1 -0
  70. package/dist-test/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +2 -2
@@ -0,0 +1,24 @@
1
+ import { type LegacyDeletePorts } from "../localdb/legacy-delete.js";
2
+ import type { TombstoneFinalityState } from "../ports/index.js";
3
+ import { type LegacyGatewayFake } from "./legacy-gateway-fake.js";
4
+ export declare function legacyPortsOver(fake: LegacyGatewayFake, options?: {
5
+ /** `on`: the account switched. `off`: it did not. */
6
+ mode?: "on" | "off";
7
+ /** What the registry says of every tombstone's finality (default: final). */
8
+ finality?: TombstoneFinalityState | ((scope: string) => TombstoneFinalityState);
9
+ /** Blob deletes wait for the legacy tombstone's finality (see `deleteScope`). */
10
+ gateBlobsOnFinality?: boolean;
11
+ /**
12
+ * A crash between the gateway tombstone and the blob queue's write: the
13
+ * next N writes to this device's queue throw, after the tombstone landed.
14
+ */
15
+ queueWritesLost?: number;
16
+ }): Promise<{
17
+ ports: LegacyDeletePorts;
18
+ seal: import("../storage/legacy-write-seal.js").LegacyWriteSeal;
19
+ storage: import("./memory-storage.js").MemoryDataStorage;
20
+ authority: import("../sync/account-mode/authority.js").ModeAuthority;
21
+ retired: string[];
22
+ pendingBlobDeletions: import("../ports/index.js").PendingBlobDeletionStore;
23
+ }>;
24
+ //# sourceMappingURL=legacy-delete-ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-delete-ports.d.ts","sourceRoot":"","sources":["../../src/test-utils/legacy-delete-ports.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,wBAAsB,eAAe,CACnC,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE;IACP,qDAAqD;IACrD,IAAI,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;IACpB,6EAA6E;IAC7E,QAAQ,CAAC,EACP,sBAAsB,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,sBAAsB,CAAC,CAAC;IACvE,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;;;GAkFP"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * `LegacyDeletePorts` over the legacy gateway fake, for tests of the deleter's
3
+ * legacy stage: the real seal and storage, the real gateway delete port and
4
+ * the real `deleteScope` worker, over the fake's gateway and storage.
5
+ */
6
+ import { legacyScopesOfConnector } from "../legacy-projection/erase-connector.js";
7
+ import { createLegacyWriteSeal } from "../storage/legacy-write-seal.js";
8
+ import { deleteScope } from "../sync/workers/delete.js";
9
+ import { createGatewayDeleteDataPort } from "../sync/delete-data-port.js";
10
+ import { createMemoryPendingBlobDeletionStore } from "../sync/pending-blob-deletions.js";
11
+ import { legacyHeadFrom, modeFrom, pendingBlobsFrom, } from "../localdb/legacy-delete.js";
12
+ import { authorityHearing } from "./account-mode.js";
13
+ import { FAKE_CHAIN_ID, FAKE_GATEWAY, FAKE_STORAGE, } from "./legacy-gateway-fake.js";
14
+ import { createMemoryDataStorage } from "./memory-storage.js";
15
+ export async function legacyPortsOver(fake, options = {}) {
16
+ const owner = fake.owner;
17
+ const authority = await authorityHearing(owner, options.mode ?? "on");
18
+ const seal = createLegacyWriteSeal({ authority, owner });
19
+ const storage = createMemoryDataStorage({ legacyWriteSeal: seal });
20
+ const memoryQueue = createMemoryPendingBlobDeletionStore();
21
+ let lost = options.queueWritesLost ?? 0;
22
+ const crash = () => {
23
+ if (lost > 0) {
24
+ lost -= 1;
25
+ throw new Error("crashed before the queue was written");
26
+ }
27
+ };
28
+ const pendingBlobDeletions = {
29
+ ...memoryQueue,
30
+ add: async (...args) => {
31
+ crash();
32
+ return memoryQueue.add(...args);
33
+ },
34
+ ...(memoryQueue.enqueue && {
35
+ enqueue: async (...args) => {
36
+ crash();
37
+ return memoryQueue.enqueue(...args);
38
+ },
39
+ }),
40
+ };
41
+ const deleteData = createGatewayDeleteDataPort({
42
+ gatewayUrl: FAKE_GATEWAY,
43
+ dataPointFeed: fake.feed,
44
+ serverOwner: owner,
45
+ signer: fake.signer,
46
+ storage: {
47
+ endpoint: FAKE_STORAGE,
48
+ chainId: FAKE_CHAIN_ID,
49
+ signMessage: async () => `0x${"ab".repeat(65)}`,
50
+ },
51
+ fetch: fake.fetch,
52
+ });
53
+ const finalityOf = (scope) => {
54
+ const f = options.finality;
55
+ return typeof f === "function"
56
+ ? f(scope)
57
+ : (f ?? { finalized: "99", settling: false, rolledBack: null });
58
+ };
59
+ const tombstoneFinality = {
60
+ tombstoneState: async (scope) => finalityOf(scope),
61
+ };
62
+ const retired = [];
63
+ const ports = {
64
+ scopesOf: legacyScopesOfConnector,
65
+ mode: modeFrom(seal),
66
+ head: legacyHeadFrom(fake.feed, owner),
67
+ retire: async (scope, fence) => {
68
+ retired.push(scope);
69
+ return deleteScope({
70
+ storage,
71
+ serverOwner: owner,
72
+ deleteData,
73
+ pendingBlobDeletions,
74
+ ...(options.gateBlobsOnFinality && { tombstoneFinality }),
75
+ dataPointFeed: fake.feed,
76
+ logger: {
77
+ debug() { },
78
+ info() { },
79
+ warn() { },
80
+ error() { },
81
+ },
82
+ }, scope, { fence: { head: fence } });
83
+ },
84
+ pendingBlobs: pendingBlobsFrom(pendingBlobDeletions),
85
+ finality: tombstoneFinality,
86
+ versions: fake.inventory,
87
+ objects: deleteData,
88
+ };
89
+ return { ports, seal, storage, authority, retired, pendingBlobDeletions };
90
+ }
91
+ //# sourceMappingURL=legacy-delete-ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-delete-ports.js","sourceRoot":"","sources":["../../src/test-utils/legacy-delete-ports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,WAA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,EAAE,KAAK,CAAC;QACtC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,WAAW,CAChB;gBACE,OAAO;gBACP,WAAW,EAAE,KAAsB;gBACnC,UAAU;gBACV,oBAAoB;gBACpB,GAAG,CAAC,OAAO,CAAC,mBAAmB,IAAI,EAAE,iBAAiB,EAAE,CAAC;gBACzD,aAAa,EAAE,IAAI,CAAC,IAAI;gBACxB,MAAM,EAAE;oBACN,KAAK,KAAI,CAAC;oBACV,IAAI,KAAI,CAAC;oBACT,IAAI,KAAI,CAAC;oBACT,KAAK,KAAI,CAAC;iBACF;aACX,EACD,KAAK,EACL,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAC3B,CAAC;QACJ,CAAC;QACD,YAAY,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;QACpD,QAAQ,EAAE,iBAAiB;QAC3B,QAAQ,EAAE,IAAI,CAAC,SAAS;QACxB,OAAO,EAAE,UAAU;KACpB,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * An in-memory gateway and storage for tests of a legacy delete after the
3
+ * switch to stream sync. It answers the two requests a legacy delete makes:
4
+ *
5
+ * DELETE {gateway}/v1/data/:id the tombstone
6
+ * DELETE {storage}/v1/chains/:chain/blobs/:owner/:scope/:version
7
+ *
8
+ * The cutover rule it enforces is policy v3 of the gateway: an owner who
9
+ * switched under it admits one legacy write, the exact tombstone over a live
10
+ * head, signed by the owner or by a registered, non-revoked server. A v1
11
+ * owner admits none (`owner_stream_sync_required`). An owner with no receipt
12
+ * has not switched: every write is admitted, as before the switch.
13
+ *
14
+ * A signature is the text `signed-by:<role>`; `signerFor(role)` makes the
15
+ * `signAddData` of a `ServerSigner`. The fake checks nothing else of it.
16
+ */
17
+ import type { DataPointFeedPort } from "../ports/index.js";
18
+ export type FakeSignerRole = "owner" | "server" | "revoked" | "unregistered";
19
+ export type FakeCutover = "none" | "v1" | "v3";
20
+ export declare const FAKE_GATEWAY = "https://gateway.fake";
21
+ export declare const FAKE_STORAGE = "https://storage.fake";
22
+ export declare const FAKE_CHAIN_ID = 14800;
23
+ interface Head {
24
+ version: number;
25
+ dataHash: string;
26
+ metadataHash: string;
27
+ deletedAt: string | null;
28
+ }
29
+ export interface LegacyGatewayFakeOptions {
30
+ owner: string;
31
+ /** The owner's cutover receipt: none (unswitched), policy v1, or policy v3. */
32
+ cutover: FakeCutover;
33
+ /** Who signs the tombstones of this port (default: a registered server). */
34
+ signer?: FakeSignerRole;
35
+ }
36
+ export declare function createLegacyGatewayFake(options: LegacyGatewayFakeOptions): {
37
+ feed: DataPointFeedPort;
38
+ inventory: {
39
+ list(scope: string): Promise<{
40
+ complete: true;
41
+ versions: {
42
+ expectedVersion: string;
43
+ dataHash: string;
44
+ isTombstone: boolean;
45
+ }[];
46
+ }>;
47
+ };
48
+ fetch: typeof fetch;
49
+ state: {
50
+ cutover: FakeCutover;
51
+ signer: FakeSignerRole;
52
+ /** Awaited before the gateway handles a tombstone: lets a test interleave. */
53
+ beforeTombstone: undefined | ((scope: string) => Promise<void>);
54
+ /** Storage answers 429 for the next N blob deletes. */
55
+ storageRateLimited: number;
56
+ /** The gateway answers 503 for the next N tombstones. */
57
+ gatewayDown: number;
58
+ /**
59
+ * The feed a device read is behind the gateway: the head it saw live is
60
+ * already deleted by another writer (`already-deleted`), or the gateway
61
+ * has no such head (`absent`). The next tombstone of a scope is refused
62
+ * with the gateway's code for it, 409.
63
+ */
64
+ race: undefined | "already-deleted" | "absent";
65
+ };
66
+ requests: {
67
+ method: string;
68
+ url: string;
69
+ scope?: string;
70
+ }[];
71
+ tombstones: Map<string, number[]>;
72
+ owner: string;
73
+ /** A registered legacy point at `version`, with its blobs in storage. */
74
+ seed(scope: string, version?: number): void;
75
+ /** A write to the legacy scope that moved its head (a new lifetime's write). */
76
+ moveHead(scope: string): void;
77
+ head: (scope: string) => Head | null;
78
+ isLive: (scope: string) => boolean;
79
+ hasBlob: (scope: string, version: number) => boolean;
80
+ blobCount: (scope: string) => number;
81
+ /** `ServerSigner.signAddData`: the signature names who signed. */
82
+ signer: {
83
+ signAddData: () => Promise<`0x${string}`>;
84
+ };
85
+ };
86
+ export type LegacyGatewayFake = ReturnType<typeof createLegacyGatewayFake>;
87
+ export {};
88
+ //# sourceMappingURL=legacy-gateway-fake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-gateway-fake.d.ts","sourceRoot":"","sources":["../../src/test-utils/legacy-gateway-fake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,mBAAmB,CAAC;AAEhF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC;AAC7E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,eAAO,MAAM,YAAY,yBAAyB,CAAC;AACnD,eAAO,MAAM,YAAY,yBAAyB,CAAC;AACnD,eAAO,MAAM,aAAa,QAAQ,CAAC;AAEnC,UAAU,IAAI;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,OAAO,EAAE,WAAW,CAAC;IACrB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB;;;oBAoMnD,MAAM;;;;;;;;;;;;;QA3KxB,8EAA8E;yBAE5E,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAChD,uDAAuD;;QAEvD,yDAAyD;;QAEzD;;;;;WAKG;cACgB,SAAS,GAAG,iBAAiB,GAAG,QAAQ;;;gBAnBnC,MAAM;aAAO,MAAM;gBAAU,MAAM;;;;IAqM3D,yEAAyE;gBAC7D,MAAM;IAYlB,gFAAgF;oBAChE,MAAM;kBAOR,MAAM;oBACJ,MAAM;qBAIL,MAAM,WAAW,MAAM;uBAErB,MAAM;IAEzB,kEAAkE;;;;EAMrE;AAMD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * An in-memory gateway and storage for tests of a legacy delete after the
3
+ * switch to stream sync. It answers the two requests a legacy delete makes:
4
+ *
5
+ * DELETE {gateway}/v1/data/:id the tombstone
6
+ * DELETE {storage}/v1/chains/:chain/blobs/:owner/:scope/:version
7
+ *
8
+ * The cutover rule it enforces is policy v3 of the gateway: an owner who
9
+ * switched under it admits one legacy write, the exact tombstone over a live
10
+ * head, signed by the owner or by a registered, non-revoked server. A v1
11
+ * owner admits none (`owner_stream_sync_required`). An owner with no receipt
12
+ * has not switched: every write is admitted, as before the switch.
13
+ *
14
+ * A signature is the text `signed-by:<role>`; `signerFor(role)` makes the
15
+ * `signAddData` of a `ServerSigner`. The fake checks nothing else of it.
16
+ */
17
+ import { computeDataPointId } from "../sync/data-point-id.js";
18
+ import { TOMBSTONE_DATA_HASH, TOMBSTONE_METADATA_HASH, } from "../sync/tombstone.js";
19
+ export const FAKE_GATEWAY = "https://gateway.fake";
20
+ export const FAKE_STORAGE = "https://storage.fake";
21
+ export const FAKE_CHAIN_ID = 14800;
22
+ export function createLegacyGatewayFake(options) {
23
+ const heads = new Map();
24
+ const blobs = new Set();
25
+ /** The registry's kept history of each scope: every slot, tombstones included. */
26
+ const slots = new Map();
27
+ const record = (scope, version, dataHash, isTombstone = false) => slots.set(scope, [
28
+ ...(slots.get(scope) ?? []),
29
+ { version, dataHash, isTombstone },
30
+ ]);
31
+ /** Every request that reached the fake, in order. */
32
+ const requests = [];
33
+ /** Tombstone versions the gateway stored, by scope (a repeat would show twice). */
34
+ const tombstones = new Map();
35
+ const state = {
36
+ cutover: options.cutover,
37
+ signer: options.signer ?? "server",
38
+ /** Awaited before the gateway handles a tombstone: lets a test interleave. */
39
+ beforeTombstone: undefined,
40
+ /** Storage answers 429 for the next N blob deletes. */
41
+ storageRateLimited: 0,
42
+ /** The gateway answers 503 for the next N tombstones. */
43
+ gatewayDown: 0,
44
+ /**
45
+ * The feed a device read is behind the gateway: the head it saw live is
46
+ * already deleted by another writer (`already-deleted`), or the gateway
47
+ * has no such head (`absent`). The next tombstone of a scope is refused
48
+ * with the gateway's code for it, 409.
49
+ */
50
+ race: undefined,
51
+ };
52
+ const idOf = (scope) => computeDataPointId(options.owner, scope);
53
+ const iso = () => "2026-11-23T00:00:00.000Z";
54
+ function recordOf(scope, head) {
55
+ return {
56
+ id: idOf(scope),
57
+ ownerAddress: options.owner,
58
+ scope,
59
+ dataHash: head.dataHash,
60
+ metadataHash: head.metadataHash,
61
+ expectedVersion: String(head.version),
62
+ addedAt: iso(),
63
+ deletedAt: head.deletedAt,
64
+ };
65
+ }
66
+ const feed = {
67
+ async getDataPoint({ scope }) {
68
+ const head = heads.get(scope);
69
+ return head ? recordOf(scope, head) : null;
70
+ },
71
+ async listDataPointsByOwner() {
72
+ return {
73
+ dataPoints: [...heads].map(([scope, head]) => recordOf(scope, head)),
74
+ cursor: null,
75
+ };
76
+ },
77
+ };
78
+ const json = (status, body) => new Response(JSON.stringify(body), {
79
+ status,
80
+ headers: { "content-type": "application/json" },
81
+ });
82
+ async function tombstone(request) {
83
+ await state.beforeTombstone?.(request.scope);
84
+ if (state.gatewayDown > 0) {
85
+ state.gatewayDown -= 1;
86
+ return json(503, { success: false, error: "gateway unavailable" });
87
+ }
88
+ if (request.role === "revoked" || request.role === "unregistered") {
89
+ return json(401, {
90
+ success: false,
91
+ error: "Invalid signature: signer is not the owner or a registered server",
92
+ code: request.role === "revoked" ? "server_revoked" : "server_unregistered",
93
+ });
94
+ }
95
+ const head = heads.get(request.scope);
96
+ if (!head)
97
+ return json(404, { success: false, error: "Unknown data point" });
98
+ if (head.deletedAt !== null)
99
+ return json(200, {
100
+ data: {
101
+ dataPointId: idOf(request.scope),
102
+ expectedVersion: String(head.version),
103
+ deletedAt: head.deletedAt,
104
+ },
105
+ });
106
+ if (state.race === "already-deleted" && head.deletedAt === null) {
107
+ head.version += 1;
108
+ head.dataHash = TOMBSTONE_DATA_HASH;
109
+ head.metadataHash = TOMBSTONE_METADATA_HASH;
110
+ head.deletedAt = iso();
111
+ record(request.scope, head.version, head.dataHash, true);
112
+ return json(409, {
113
+ success: false,
114
+ code: "owner_stream_head_already_deleted",
115
+ scope: request.scope,
116
+ });
117
+ }
118
+ if (state.race === "absent") {
119
+ heads.delete(request.scope);
120
+ return json(409, {
121
+ success: false,
122
+ code: "owner_stream_head_absent",
123
+ scope: request.scope,
124
+ });
125
+ }
126
+ if (state.cutover === "v1")
127
+ return json(409, {
128
+ success: false,
129
+ code: "owner_stream_sync_required",
130
+ policyVersion: 1,
131
+ receipt: { policyVersion: 1 },
132
+ });
133
+ if (BigInt(request.expectedVersion) !== BigInt(head.version + 1))
134
+ return json(409, {
135
+ success: false,
136
+ error: "Version conflict",
137
+ currentExpectedVersion: String(head.version),
138
+ nextExpectedVersion: String(head.version + 1),
139
+ });
140
+ head.version += 1;
141
+ head.dataHash = TOMBSTONE_DATA_HASH;
142
+ head.metadataHash = TOMBSTONE_METADATA_HASH;
143
+ head.deletedAt = iso();
144
+ record(request.scope, head.version, head.dataHash, true);
145
+ tombstones.set(request.scope, [
146
+ ...(tombstones.get(request.scope) ?? []),
147
+ head.version,
148
+ ]);
149
+ return json(200, {
150
+ data: {
151
+ dataPointId: idOf(request.scope),
152
+ expectedVersion: String(head.version),
153
+ deletedAt: head.deletedAt,
154
+ },
155
+ });
156
+ }
157
+ const fetchImpl = (async (input, init) => {
158
+ const url = String(input);
159
+ const method = init?.method ?? "GET";
160
+ if (url.startsWith(FAKE_GATEWAY) && method === "DELETE") {
161
+ const body = JSON.parse(String(init?.body));
162
+ requests.push({ method, url, scope: body.scope });
163
+ const authorization = new Headers(init?.headers).get("authorization");
164
+ const role = /signed-by:(\w+)/.exec(authorization ?? "")?.[1];
165
+ return tombstone({
166
+ scope: body.scope,
167
+ expectedVersion: body.expectedVersion,
168
+ role: role ?? "unregistered",
169
+ });
170
+ }
171
+ if (url.startsWith(FAKE_STORAGE) && method === "DELETE") {
172
+ const key = decodeURIComponent(url.slice(`${FAKE_STORAGE}/v1/chains/${FAKE_CHAIN_ID}/blobs/${options.owner.toLowerCase()}/`
173
+ .length));
174
+ requests.push({ method, url });
175
+ if (state.storageRateLimited > 0) {
176
+ state.storageRateLimited -= 1;
177
+ return new Response("", { status: 429, statusText: "Too Many" });
178
+ }
179
+ return blobs.delete(key)
180
+ ? new Response("", { status: 200 })
181
+ : new Response("", { status: 404 });
182
+ }
183
+ throw new Error(`fake gateway: unexpected ${method} ${url}`);
184
+ });
185
+ /** The gateway's version inventory (`GET /v1/data/:id/versions`), read in full. */
186
+ const inventory = {
187
+ async list(scope) {
188
+ return {
189
+ complete: true,
190
+ versions: (slots.get(scope) ?? []).map((slot) => ({
191
+ expectedVersion: String(slot.version),
192
+ dataHash: slot.dataHash,
193
+ isTombstone: slot.isTombstone,
194
+ })),
195
+ };
196
+ },
197
+ };
198
+ return {
199
+ feed,
200
+ inventory,
201
+ fetch: fetchImpl,
202
+ state,
203
+ requests,
204
+ tombstones,
205
+ owner: options.owner,
206
+ /** A registered legacy point at `version`, with its blobs in storage. */
207
+ seed(scope, version = 1) {
208
+ heads.set(scope, {
209
+ version,
210
+ dataHash: `0x${"aa".repeat(32)}`,
211
+ metadataHash: `0x${"bb".repeat(32)}`,
212
+ deletedAt: null,
213
+ });
214
+ for (let v = 1; v <= version; v++) {
215
+ blobs.add(blobKey(scope, v));
216
+ record(scope, v, `0x${v.toString(16).padStart(64, "0")}`);
217
+ }
218
+ },
219
+ /** A write to the legacy scope that moved its head (a new lifetime's write). */
220
+ moveHead(scope) {
221
+ const head = heads.get(scope);
222
+ head.version += 1;
223
+ head.dataHash = `0x${"cc".repeat(32)}`;
224
+ blobs.add(blobKey(scope, head.version));
225
+ record(scope, head.version, head.dataHash);
226
+ },
227
+ head: (scope) => heads.get(scope) ?? null,
228
+ isLive: (scope) => {
229
+ const head = heads.get(scope);
230
+ return head !== undefined && head.deletedAt === null;
231
+ },
232
+ hasBlob: (scope, version) => blobs.has(blobKey(scope, version)),
233
+ blobCount: (scope) => [...blobs].filter((key) => key.startsWith(`${scope}/`)).length,
234
+ /** `ServerSigner.signAddData`: the signature names who signed. */
235
+ signer: {
236
+ signAddData: async () => `0xsigned-by:${state.signer}`,
237
+ },
238
+ };
239
+ }
240
+ function blobKey(scope, version) {
241
+ return `${scope}/${version}`;
242
+ }
243
+ //# sourceMappingURL=legacy-gateway-fake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-gateway-fake.js","sourceRoot":"","sources":["../../src/test-utils/legacy-gateway-fake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AACnD,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAiBnC,MAAM,UAAU,uBAAuB,CAAC,OAAiC;IACvE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAgB,CAA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