@opendatalabs/personal-server-ts-core 0.0.1-canary.01ca694 → 0.0.1-canary.052d47e
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/api/index.d.ts +282 -9
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +867 -163
- package/dist/api/index.js.map +1 -1
- package/dist/auth/request.d.ts.map +1 -1
- package/dist/auth/request.js.map +1 -1
- package/dist/client.d.ts +8 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +21 -3
- package/dist/client.js.map +1 -1
- package/dist/contracts/binary.d.ts +12 -0
- package/dist/contracts/binary.d.ts.map +1 -1
- package/dist/contracts/binary.js +31 -0
- package/dist/contracts/binary.js.map +1 -1
- package/dist/contracts/data.d.ts +51 -5
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +166 -30
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/grants.d.ts +7 -5
- package/dist/contracts/grants.d.ts.map +1 -1
- package/dist/contracts/grants.js +60 -37
- package/dist/contracts/grants.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/derivatives/api.d.ts +48 -0
- package/dist/derivatives/api.d.ts.map +1 -0
- package/dist/derivatives/api.js +366 -0
- package/dist/derivatives/api.js.map +1 -0
- package/dist/derivatives/compute.d.ts +106 -0
- package/dist/derivatives/compute.d.ts.map +1 -0
- package/dist/derivatives/compute.js +414 -0
- package/dist/derivatives/compute.js.map +1 -0
- package/dist/derivatives/e2ee/aad.d.ts +22 -0
- package/dist/derivatives/e2ee/aad.d.ts.map +1 -0
- package/dist/derivatives/e2ee/aad.js +32 -0
- package/dist/derivatives/e2ee/aad.js.map +1 -0
- package/dist/derivatives/e2ee/attestation.d.ts +134 -0
- package/dist/derivatives/e2ee/attestation.d.ts.map +1 -0
- package/dist/derivatives/e2ee/attestation.js +248 -0
- package/dist/derivatives/e2ee/attestation.js.map +1 -0
- package/dist/derivatives/e2ee/index.d.ts +6 -0
- package/dist/derivatives/e2ee/index.d.ts.map +1 -0
- package/dist/derivatives/e2ee/index.js +6 -0
- package/dist/derivatives/e2ee/index.js.map +1 -0
- package/dist/derivatives/e2ee/jcs.d.ts +17 -0
- package/dist/derivatives/e2ee/jcs.d.ts.map +1 -0
- package/dist/derivatives/e2ee/jcs.js +55 -0
- package/dist/derivatives/e2ee/jcs.js.map +1 -0
- package/dist/derivatives/e2ee/phala.d.ts +62 -0
- package/dist/derivatives/e2ee/phala.d.ts.map +1 -0
- package/dist/derivatives/e2ee/phala.js +168 -0
- package/dist/derivatives/e2ee/phala.js.map +1 -0
- package/dist/derivatives/e2ee/suite.d.ts +56 -0
- package/dist/derivatives/e2ee/suite.d.ts.map +1 -0
- package/dist/derivatives/e2ee/suite.js +164 -0
- package/dist/derivatives/e2ee/suite.js.map +1 -0
- package/dist/derivatives/index.d.ts +10 -0
- package/dist/derivatives/index.d.ts.map +1 -0
- package/dist/derivatives/index.js +10 -0
- package/dist/derivatives/index.js.map +1 -0
- package/dist/derivatives/inference.d.ts +151 -0
- package/dist/derivatives/inference.d.ts.map +1 -0
- package/dist/derivatives/inference.js +262 -0
- package/dist/derivatives/inference.js.map +1 -0
- package/dist/derivatives/prompt.d.ts +64 -0
- package/dist/derivatives/prompt.d.ts.map +1 -0
- package/dist/derivatives/prompt.js +193 -0
- package/dist/derivatives/prompt.js.map +1 -0
- package/dist/derivatives/registration.d.ts +54 -0
- package/dist/derivatives/registration.d.ts.map +1 -0
- package/dist/derivatives/registration.js +180 -0
- package/dist/derivatives/registration.js.map +1 -0
- package/dist/derivatives/scheduler.d.ts +84 -0
- package/dist/derivatives/scheduler.d.ts.map +1 -0
- package/dist/derivatives/scheduler.js +257 -0
- package/dist/derivatives/scheduler.js.map +1 -0
- package/dist/derivatives/store.d.ts +14 -0
- package/dist/derivatives/store.d.ts.map +1 -0
- package/dist/derivatives/store.js +77 -0
- package/dist/derivatives/store.js.map +1 -0
- package/dist/derivatives/types.d.ts +92 -0
- package/dist/derivatives/types.d.ts.map +1 -0
- package/dist/derivatives/types.js +27 -0
- package/dist/derivatives/types.js.map +1 -0
- package/dist/errors/catalog.d.ts +75 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/catalog.js +104 -0
- package/dist/errors/catalog.js.map +1 -1
- package/dist/grants/index.d.ts +2 -1
- package/dist/grants/index.d.ts.map +1 -1
- package/dist/grants/index.js +1 -1
- package/dist/grants/index.js.map +1 -1
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +1 -1
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/public-only-account.d.ts +8 -0
- package/dist/keys/public-only-account.d.ts.map +1 -0
- package/dist/keys/public-only-account.js +21 -0
- package/dist/keys/public-only-account.js.map +1 -0
- package/dist/keys/server-account.d.ts +2 -2
- package/dist/keys/server-account.d.ts.map +1 -1
- package/dist/lineage/attestation.d.ts +42 -0
- package/dist/lineage/attestation.d.ts.map +1 -0
- package/dist/lineage/attestation.js +25 -0
- package/dist/lineage/attestation.js.map +1 -0
- package/dist/lineage/gateway.d.ts +105 -0
- package/dist/lineage/gateway.d.ts.map +1 -0
- package/dist/lineage/gateway.js +242 -0
- package/dist/lineage/gateway.js.map +1 -0
- package/dist/lineage/index.d.ts +5 -0
- package/dist/lineage/index.d.ts.map +1 -0
- package/dist/lineage/index.js +5 -0
- package/dist/lineage/index.js.map +1 -0
- package/dist/lineage/lineage.d.ts +141 -0
- package/dist/lineage/lineage.d.ts.map +1 -0
- package/dist/lineage/lineage.js +255 -0
- package/dist/lineage/lineage.js.map +1 -0
- package/dist/logging/access-log.d.ts +10 -1
- package/dist/logging/access-log.d.ts.map +1 -1
- package/dist/mcp/activity.d.ts.map +1 -1
- package/dist/mcp/activity.js.map +1 -1
- package/dist/mcp/connection-api.d.ts.map +1 -1
- package/dist/mcp/connection-api.js +0 -1
- package/dist/mcp/connection-api.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/read-client.d.ts +61 -1
- package/dist/mcp/read-client.d.ts.map +1 -1
- package/dist/mcp/read-client.js +397 -42
- package/dist/mcp/read-client.js.map +1 -1
- package/dist/mcp/resources.d.ts +37 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +114 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/search/index.d.ts.map +1 -1
- package/dist/mcp/search/index.js +108 -21
- package/dist/mcp/search/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +27 -9
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session.d.ts +160 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +243 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +29 -3
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +515 -48
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/payment/index.d.ts +2 -0
- package/dist/payment/index.d.ts.map +1 -0
- package/dist/payment/index.js +2 -0
- package/dist/payment/index.js.map +1 -0
- package/dist/payment/x402.d.ts +155 -0
- package/dist/payment/x402.d.ts.map +1 -0
- package/dist/payment/x402.js +402 -0
- package/dist/payment/x402.js.map +1 -0
- package/dist/policy/data-read.d.ts +18 -2
- package/dist/policy/data-read.d.ts.map +1 -1
- package/dist/policy/data-read.js +80 -49
- package/dist/policy/data-read.js.map +1 -1
- package/dist/policy/data-write.d.ts +69 -0
- package/dist/policy/data-write.d.ts.map +1 -0
- package/dist/policy/data-write.js +131 -0
- package/dist/policy/data-write.js.map +1 -0
- package/dist/policy/index.d.ts +3 -1
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +3 -1
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/signed-artifacts.d.ts +17 -0
- package/dist/policy/signed-artifacts.d.ts.map +1 -0
- package/dist/policy/signed-artifacts.js +110 -0
- package/dist/policy/signed-artifacts.js.map +1 -0
- package/dist/ports/index.d.ts +159 -32
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +6 -5
- package/dist/ports/index.js.map +1 -1
- package/dist/schemas/server-config.d.ts +49 -4
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +95 -13
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/signing/index.d.ts +2 -2
- package/dist/signing/index.d.ts.map +1 -1
- package/dist/signing/index.js +1 -1
- package/dist/signing/index.js.map +1 -1
- package/dist/signing/request-signer.d.ts +2 -0
- package/dist/signing/request-signer.d.ts.map +1 -1
- package/dist/signing/request-signer.js +1 -0
- package/dist/signing/request-signer.js.map +1 -1
- package/dist/signing/signer.d.ts +27 -25
- package/dist/signing/signer.d.ts.map +1 -1
- package/dist/signing/signer.js +27 -51
- package/dist/signing/signer.js.map +1 -1
- package/dist/storage/adapters/index.d.ts +1 -1
- package/dist/storage/adapters/index.d.ts.map +1 -1
- package/dist/storage/adapters/index.js +1 -1
- package/dist/storage/adapters/index.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +10 -0
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.d.ts +11 -1
- package/dist/storage/adapters/sdk.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.js +38 -3
- package/dist/storage/adapters/sdk.js.map +1 -1
- package/dist/storage/adapters/vana.d.ts +3 -0
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +95 -2
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/blocks/errors.d.ts.map +1 -1
- package/dist/storage/blocks/errors.js.map +1 -1
- package/dist/storage/blocks/index.d.ts +2 -0
- package/dist/storage/blocks/index.d.ts.map +1 -1
- package/dist/storage/blocks/index.js +2 -0
- package/dist/storage/blocks/index.js.map +1 -1
- package/dist/storage/blocks/select.d.ts +29 -0
- package/dist/storage/blocks/select.d.ts.map +1 -0
- package/dist/storage/blocks/select.js +120 -0
- package/dist/storage/blocks/select.js.map +1 -0
- package/dist/storage/blocks/types.d.ts +7 -0
- package/dist/storage/blocks/types.d.ts.map +1 -1
- package/dist/storage/index/manager.d.ts +30 -2
- package/dist/storage/index/manager.d.ts.map +1 -1
- package/dist/storage/index/schema.d.ts +1 -1
- package/dist/storage/index/schema.js +1 -1
- package/dist/storage/index/types.d.ts +6 -1
- package/dist/storage/index/types.d.ts.map +1 -1
- package/dist/sync/data-point-feed.d.ts +35 -0
- package/dist/sync/data-point-feed.d.ts.map +1 -0
- package/dist/sync/data-point-feed.js +122 -0
- package/dist/sync/data-point-feed.js.map +1 -0
- package/dist/sync/data-point-id.d.ts +7 -0
- package/dist/sync/data-point-id.d.ts.map +1 -0
- package/dist/sync/data-point-id.js +16 -0
- package/dist/sync/data-point-id.js.map +1 -0
- package/dist/sync/delete-data-port.d.ts +50 -0
- package/dist/sync/delete-data-port.d.ts.map +1 -0
- package/dist/sync/delete-data-port.js +244 -0
- package/dist/sync/delete-data-port.js.map +1 -0
- package/dist/sync/engine/sync-manager.d.ts +16 -4
- package/dist/sync/engine/sync-manager.d.ts.map +1 -1
- package/dist/sync/engine/sync-manager.js +93 -32
- package/dist/sync/engine/sync-manager.js.map +1 -1
- package/dist/sync/index.d.ts +7 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +7 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/issues.d.ts.map +1 -1
- package/dist/sync/issues.js +21 -3
- package/dist/sync/issues.js.map +1 -1
- package/dist/sync/pending-blob-deletions.d.ts +29 -0
- package/dist/sync/pending-blob-deletions.d.ts.map +1 -0
- package/dist/sync/pending-blob-deletions.js +116 -0
- package/dist/sync/pending-blob-deletions.js.map +1 -0
- package/dist/sync/retry-memory.d.ts +33 -0
- package/dist/sync/retry-memory.d.ts.map +1 -0
- package/dist/sync/retry-memory.js +68 -0
- package/dist/sync/retry-memory.js.map +1 -0
- package/dist/sync/scope-deletions.d.ts +155 -0
- package/dist/sync/scope-deletions.d.ts.map +1 -0
- package/dist/sync/scope-deletions.js +225 -0
- package/dist/sync/scope-deletions.js.map +1 -0
- package/dist/sync/tombstone.d.ts +27 -0
- package/dist/sync/tombstone.d.ts.map +1 -0
- package/dist/sync/tombstone.js +28 -0
- package/dist/sync/tombstone.js.map +1 -0
- package/dist/sync/workers/delete.d.ts +152 -31
- package/dist/sync/workers/delete.d.ts.map +1 -1
- package/dist/sync/workers/delete.js +457 -55
- package/dist/sync/workers/delete.js.map +1 -1
- package/dist/sync/workers/download.d.ts +108 -27
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +321 -126
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/upload.d.ts +65 -10
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +371 -42
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-utils/e2ee-fixtures.d.ts +94 -0
- package/dist/test-utils/e2ee-fixtures.d.ts.map +1 -0
- package/dist/test-utils/e2ee-fixtures.js +116 -0
- package/dist/test-utils/e2ee-fixtures.js.map +1 -0
- package/dist/test-utils/e2ee-gateway.d.ts +61 -0
- package/dist/test-utils/e2ee-gateway.d.ts.map +1 -0
- package/dist/test-utils/e2ee-gateway.js +248 -0
- package/dist/test-utils/e2ee-gateway.js.map +1 -0
- package/dist/test-utils/index.d.ts +3 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +3 -0
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/memory-storage.d.ts +12 -0
- package/dist/test-utils/memory-storage.d.ts.map +1 -0
- package/dist/test-utils/memory-storage.js +146 -0
- package/dist/test-utils/memory-storage.js.map +1 -0
- package/dist/test-utils/wallet.d.ts +6 -0
- package/dist/test-utils/wallet.d.ts.map +1 -1
- package/dist/test-utils/wallet.js +46 -0
- package/dist/test-utils/wallet.js.map +1 -1
- package/dist/write/attribution.d.ts +185 -0
- package/dist/write/attribution.d.ts.map +1 -0
- package/dist/write/attribution.js +450 -0
- package/dist/write/attribution.js.map +1 -0
- package/dist/write/authorize.d.ts +77 -0
- package/dist/write/authorize.d.ts.map +1 -0
- package/dist/write/authorize.js +109 -0
- package/dist/write/authorize.js.map +1 -0
- package/dist/write/index.d.ts +5 -0
- package/dist/write/index.d.ts.map +1 -0
- package/dist/write/index.js +5 -0
- package/dist/write/index.js.map +1 -0
- package/dist/write/route.d.ts +61 -0
- package/dist/write/route.d.ts.map +1 -0
- package/dist/write/route.js +132 -0
- package/dist/write/route.js.map +1 -0
- package/dist/write/session.d.ts +96 -0
- package/dist/write/session.d.ts.map +1 -0
- package/dist/write/session.js +136 -0
- package/dist/write/session.js.map +1 -0
- package/package.json +19 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway client for the lineage endpoints. A thin fetch wrapper (not the SDK
|
|
3
|
+
* GatewayClient) because the three calls need things the SDK client does not
|
|
4
|
+
* expose yet: `includeDeleted=true` on the data point lookup, a server-signed
|
|
5
|
+
* request on the lineage read, and the `lineage` field on registration.
|
|
6
|
+
*/
|
|
7
|
+
import type { RequestSigner } from "../signing/request-signer.js";
|
|
8
|
+
import type { LineageDataPointRecord } from "./lineage.js";
|
|
9
|
+
export type LineageNode = {
|
|
10
|
+
dataPointId: string;
|
|
11
|
+
scope: string;
|
|
12
|
+
version: string;
|
|
13
|
+
deletedAt: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A node the caller's grant does not cover. It carries NO identifier:
|
|
17
|
+
* dataPointId is keccak256(owner, scope) and a grantee knows the owner,
|
|
18
|
+
* so an id would let it dictionary-test scope names. Only position and
|
|
19
|
+
* count survive, which is all a consent UI needs to show the shape.
|
|
20
|
+
*/
|
|
21
|
+
| {
|
|
22
|
+
redacted: true;
|
|
23
|
+
};
|
|
24
|
+
/** `data` of a gateway lineage response (see docs/derivative-data-api.md). */
|
|
25
|
+
export interface LineageView {
|
|
26
|
+
dataPointId: string;
|
|
27
|
+
ownerAddress: string;
|
|
28
|
+
scope: string;
|
|
29
|
+
version: string;
|
|
30
|
+
deletedAt: string | null;
|
|
31
|
+
sources: LineageNode[];
|
|
32
|
+
derivatives: LineageNode[];
|
|
33
|
+
/** Present (true) only when the gateway capped `derivatives`. */
|
|
34
|
+
derivativesTruncated?: true;
|
|
35
|
+
/**
|
|
36
|
+
* The grant this view was attested for. Absent on the owner's full view;
|
|
37
|
+
* set (lowercase) on a redacted grant view. The client refuses a view
|
|
38
|
+
* whose grantId does not match the one it asked for.
|
|
39
|
+
*/
|
|
40
|
+
grantId?: string;
|
|
41
|
+
}
|
|
42
|
+
export type LineageGatewayResult = {
|
|
43
|
+
ok: true;
|
|
44
|
+
data: LineageView;
|
|
45
|
+
proof: GatewayProof;
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
status: number;
|
|
49
|
+
body: unknown;
|
|
50
|
+
};
|
|
51
|
+
export interface GetLineageInput {
|
|
52
|
+
dataPointId: string;
|
|
53
|
+
/** Decimal version string; absent = the current version. */
|
|
54
|
+
version?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Ask for the view a specific grant sees (nodes outside the grant's scopes
|
|
57
|
+
* come back redacted), attested as such. The gateway only honors it for the
|
|
58
|
+
* owner or one of the owner's registered servers.
|
|
59
|
+
*/
|
|
60
|
+
grantId?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface RegisterDataPointWithLineageParams {
|
|
63
|
+
ownerAddress: string;
|
|
64
|
+
scope: string;
|
|
65
|
+
dataHash: string;
|
|
66
|
+
metadataHash: string;
|
|
67
|
+
expectedVersion: string;
|
|
68
|
+
signature: string;
|
|
69
|
+
lineage: readonly string[];
|
|
70
|
+
/** LineageAttestation signature over (owner, scope, version, dataHash, lineage). */
|
|
71
|
+
lineageSignature: string;
|
|
72
|
+
}
|
|
73
|
+
export interface RegisterDataPointWithLineageResult {
|
|
74
|
+
dataPointId?: string;
|
|
75
|
+
expectedVersion?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface LineageGatewayPort {
|
|
78
|
+
/** GET /v1/data/:id?includeDeleted=true; null on 404. */
|
|
79
|
+
getDataPoint(dataPointId: string): Promise<LineageDataPointRecord | null>;
|
|
80
|
+
/** GET /v1/data/:id/lineage, signed with the server key. */
|
|
81
|
+
getLineage(input: GetLineageInput): Promise<LineageGatewayResult>;
|
|
82
|
+
/**
|
|
83
|
+
* POST /v1/data with `lineage`. Same body and error contract as the SDK's
|
|
84
|
+
* registerDataPoint (a non-2xx throws `Gateway error: <status> <detail>`)
|
|
85
|
+
* so the upload worker's stale-version handling applies unchanged.
|
|
86
|
+
*/
|
|
87
|
+
registerDataPoint(params: RegisterDataPointWithLineageParams): Promise<RegisterDataPointWithLineageResult>;
|
|
88
|
+
}
|
|
89
|
+
export interface GatewayLineageClientOptions {
|
|
90
|
+
gatewayUrl: string;
|
|
91
|
+
/** Signs lineage reads as this server; absent = getLineage is unavailable. */
|
|
92
|
+
requestSigner?: RequestSigner;
|
|
93
|
+
fetch?: typeof fetch;
|
|
94
|
+
}
|
|
95
|
+
/** The gateway attestation shape (ProofData); a 200 without it is not a view. */
|
|
96
|
+
export interface GatewayProof {
|
|
97
|
+
userSignature: string;
|
|
98
|
+
gatewaySignature: string;
|
|
99
|
+
timestamp: number;
|
|
100
|
+
status: string;
|
|
101
|
+
estimatedConfirmation: string | null;
|
|
102
|
+
chainBlockHeight: number | null;
|
|
103
|
+
}
|
|
104
|
+
export declare function createGatewayLineageClient(options: GatewayLineageClientOptions): LineageGatewayPort;
|
|
105
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway client for the lineage endpoints. A thin fetch wrapper (not the SDK
|
|
3
|
+
* GatewayClient) because the three calls need things the SDK client does not
|
|
4
|
+
* expose yet: `includeDeleted=true` on the data point lookup, a server-signed
|
|
5
|
+
* request on the lineage read, and the `lineage` field on registration.
|
|
6
|
+
*/
|
|
7
|
+
import { LineageUnavailableError } from "../errors/catalog.js";
|
|
8
|
+
import { computeDataPointId } from "../sync/data-point-id.js";
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function isLineageNode(value) {
|
|
13
|
+
if (!isRecord(value))
|
|
14
|
+
return false;
|
|
15
|
+
if (value.redacted === true) {
|
|
16
|
+
// A redacted node must be exactly { redacted: true }. A gateway that
|
|
17
|
+
// attaches an id, scope or version to a redacted node is leaking, and the
|
|
18
|
+
// view is refused rather than passed on with the leak intact.
|
|
19
|
+
return Object.keys(value).length === 1;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value.dataPointId !== "string")
|
|
22
|
+
return false;
|
|
23
|
+
return (typeof value.scope === "string" &&
|
|
24
|
+
typeof value.version === "string" &&
|
|
25
|
+
(value.deletedAt === null || typeof value.deletedAt === "string"));
|
|
26
|
+
}
|
|
27
|
+
function isGatewayProof(value) {
|
|
28
|
+
return (isRecord(value) &&
|
|
29
|
+
typeof value.userSignature === "string" &&
|
|
30
|
+
typeof value.gatewaySignature === "string" &&
|
|
31
|
+
typeof value.timestamp === "number" &&
|
|
32
|
+
typeof value.status === "string" &&
|
|
33
|
+
(value.estimatedConfirmation === null ||
|
|
34
|
+
typeof value.estimatedConfirmation === "string") &&
|
|
35
|
+
(value.chainBlockHeight === null ||
|
|
36
|
+
typeof value.chainBlockHeight === "number"));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A data point id is keccak256(owner, scope). Any gateway response that
|
|
40
|
+
* labels an owner and scope with an id must derive that id from them; an
|
|
41
|
+
* owner that is not an address, or a pair that hashes elsewhere, fails.
|
|
42
|
+
*/
|
|
43
|
+
function derivesDataPointId(id, ownerAddress, scope) {
|
|
44
|
+
try {
|
|
45
|
+
return (computeDataPointId(ownerAddress, scope).toLowerCase() ===
|
|
46
|
+
id.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function parseLineageView(value) {
|
|
53
|
+
if (!isRecord(value) ||
|
|
54
|
+
typeof value.dataPointId !== "string" ||
|
|
55
|
+
typeof value.ownerAddress !== "string" ||
|
|
56
|
+
typeof value.scope !== "string" ||
|
|
57
|
+
typeof value.version !== "string" ||
|
|
58
|
+
!(value.deletedAt === null || typeof value.deletedAt === "string") ||
|
|
59
|
+
!Array.isArray(value.sources) ||
|
|
60
|
+
!value.sources.every(isLineageNode) ||
|
|
61
|
+
!Array.isArray(value.derivatives) ||
|
|
62
|
+
!value.derivatives.every(isLineageNode) ||
|
|
63
|
+
!(value.grantId === undefined || typeof value.grantId === "string") ||
|
|
64
|
+
!(value.derivativesTruncated === undefined ||
|
|
65
|
+
value.derivativesTruncated === true)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
export function createGatewayLineageClient(options) {
|
|
71
|
+
const base = options.gatewayUrl.replace(/\/+$/, "");
|
|
72
|
+
const origin = new URL(base).origin;
|
|
73
|
+
const doFetch = options.fetch ?? fetch;
|
|
74
|
+
async function readJson(res) {
|
|
75
|
+
try {
|
|
76
|
+
return await res.json();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
async getDataPoint(dataPointId) {
|
|
84
|
+
const res = await doFetch(`${base}/v1/data/${encodeURIComponent(dataPointId)}?includeDeleted=true`);
|
|
85
|
+
if (res.status === 404)
|
|
86
|
+
return null;
|
|
87
|
+
if (!res.ok) {
|
|
88
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
89
|
+
}
|
|
90
|
+
const body = await readJson(res);
|
|
91
|
+
const data = isRecord(body) ? body.data : undefined;
|
|
92
|
+
if (!isRecord(data) ||
|
|
93
|
+
typeof data.id !== "string" ||
|
|
94
|
+
typeof data.ownerAddress !== "string" ||
|
|
95
|
+
typeof data.scope !== "string" ||
|
|
96
|
+
typeof data.expectedVersion !== "string") {
|
|
97
|
+
throw new Error("Gateway error: malformed data point response");
|
|
98
|
+
}
|
|
99
|
+
// Bind the record to what was asked for: a stale or misrouted 200 must
|
|
100
|
+
// not validate a different source than the one the caller named.
|
|
101
|
+
if (data.id.toLowerCase() !== dataPointId.toLowerCase()) {
|
|
102
|
+
throw new Error(`Gateway error: data point response is for ${data.id}, requested ${dataPointId}`);
|
|
103
|
+
}
|
|
104
|
+
// The id is keccak256(owner, scope): the record's own owner and scope
|
|
105
|
+
// must derive the id it claims, or a malformed response could pair the
|
|
106
|
+
// requested id with an arbitrary same-owner scope and slip past local
|
|
107
|
+
// naming validation.
|
|
108
|
+
if (!derivesDataPointId(data.id, data.ownerAddress, data.scope)) {
|
|
109
|
+
throw new Error(`Gateway error: data point ${data.id} does not derive from its owner and scope`);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
dataPointId: data.id,
|
|
113
|
+
ownerAddress: data.ownerAddress,
|
|
114
|
+
scope: data.scope,
|
|
115
|
+
version: data.expectedVersion,
|
|
116
|
+
deletedAt: typeof data.deletedAt === "string" ? data.deletedAt : null,
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
async getLineage(input) {
|
|
120
|
+
if (!options.requestSigner) {
|
|
121
|
+
throw new LineageUnavailableError({ reason: "no request signer" });
|
|
122
|
+
}
|
|
123
|
+
// The view selectors are signed, never free query parameters: the
|
|
124
|
+
// version is a path segment (inside the signed uri) and the grant view
|
|
125
|
+
// is the scheme's own `grantId` claim, so a captured signature cannot
|
|
126
|
+
// be replayed for another version or grant view.
|
|
127
|
+
const uri = `/v1/data/${input.dataPointId.toLowerCase()}/lineage` +
|
|
128
|
+
(input.version !== undefined ? `/${input.version}` : "");
|
|
129
|
+
const authorization = await options.requestSigner.signRequest({
|
|
130
|
+
aud: origin,
|
|
131
|
+
method: "GET",
|
|
132
|
+
uri,
|
|
133
|
+
grantId: input.grantId?.toLowerCase(),
|
|
134
|
+
});
|
|
135
|
+
const res = await doFetch(`${base}${uri}`, {
|
|
136
|
+
headers: { Authorization: authorization },
|
|
137
|
+
});
|
|
138
|
+
const body = await readJson(res);
|
|
139
|
+
if (!res.ok)
|
|
140
|
+
return { ok: false, status: res.status, body };
|
|
141
|
+
// The API promises an attested view: a 200 whose data or proof does
|
|
142
|
+
// not have the documented shape is reported as a gateway error, never
|
|
143
|
+
// passed on as a view.
|
|
144
|
+
const data = parseLineageView(isRecord(body) ? body.data : undefined);
|
|
145
|
+
const proof = isRecord(body) ? body.proof : undefined;
|
|
146
|
+
if (!data || !isGatewayProof(proof)) {
|
|
147
|
+
return {
|
|
148
|
+
ok: false,
|
|
149
|
+
status: res.status,
|
|
150
|
+
body: { error: "malformed lineage response", received: body },
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// The attested view must be the one that was requested. A response for
|
|
154
|
+
// another data point, or for a version other than the signed path
|
|
155
|
+
// segment, is a gateway error, never served to an authorized caller.
|
|
156
|
+
const requestedId = input.dataPointId.toLowerCase();
|
|
157
|
+
// The grant view is part of the identity of the response: a builder
|
|
158
|
+
// asking under its grant must get a view attested for that grant, and
|
|
159
|
+
// a full owner view (no grantId) must never be handed to a builder.
|
|
160
|
+
const requestedGrant = input.grantId?.toLowerCase();
|
|
161
|
+
const servedGrant = data.grantId?.toLowerCase();
|
|
162
|
+
const viewMismatch = data.dataPointId.toLowerCase() !== requestedId ||
|
|
163
|
+
(input.version !== undefined && data.version !== input.version) ||
|
|
164
|
+
requestedGrant !== servedGrant;
|
|
165
|
+
if (viewMismatch) {
|
|
166
|
+
return {
|
|
167
|
+
ok: false,
|
|
168
|
+
status: res.status,
|
|
169
|
+
body: {
|
|
170
|
+
error: "lineage response does not match the requested view",
|
|
171
|
+
requested: {
|
|
172
|
+
dataPointId: requestedId,
|
|
173
|
+
version: input.version,
|
|
174
|
+
grantId: requestedGrant,
|
|
175
|
+
},
|
|
176
|
+
received: {
|
|
177
|
+
dataPointId: data.dataPointId,
|
|
178
|
+
version: data.version,
|
|
179
|
+
grantId: servedGrant,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
// The view's own owner and scope must derive the id it is labeled
|
|
185
|
+
// with, exactly as getDataPoint demands of a record. Otherwise a
|
|
186
|
+
// malformed response could carry the requested id while exposing the
|
|
187
|
+
// lineage of another owner or scope under that label.
|
|
188
|
+
if (!derivesDataPointId(data.dataPointId, data.ownerAddress, data.scope)) {
|
|
189
|
+
return {
|
|
190
|
+
ok: false,
|
|
191
|
+
status: res.status,
|
|
192
|
+
body: {
|
|
193
|
+
error: "lineage view does not derive from its owner and scope",
|
|
194
|
+
received: {
|
|
195
|
+
dataPointId: data.dataPointId,
|
|
196
|
+
ownerAddress: data.ownerAddress,
|
|
197
|
+
scope: data.scope,
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return { ok: true, data, proof };
|
|
203
|
+
},
|
|
204
|
+
async registerDataPoint(params) {
|
|
205
|
+
const res = await doFetch(`${base}/v1/data`, {
|
|
206
|
+
method: "POST",
|
|
207
|
+
headers: {
|
|
208
|
+
"Content-Type": "application/json",
|
|
209
|
+
Authorization: `Web3Signed ${params.signature}`,
|
|
210
|
+
},
|
|
211
|
+
body: JSON.stringify({
|
|
212
|
+
ownerAddress: params.ownerAddress,
|
|
213
|
+
scope: params.scope,
|
|
214
|
+
dataHash: params.dataHash,
|
|
215
|
+
metadataHash: params.metadataHash,
|
|
216
|
+
expectedVersion: params.expectedVersion,
|
|
217
|
+
lineage: [...params.lineage],
|
|
218
|
+
lineageSignature: params.lineageSignature,
|
|
219
|
+
}),
|
|
220
|
+
});
|
|
221
|
+
if (!res.ok) {
|
|
222
|
+
const body = await readJson(res);
|
|
223
|
+
const detail = (isRecord(body) && typeof body.error === "string" && body.error) ||
|
|
224
|
+
res.statusText;
|
|
225
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
226
|
+
}
|
|
227
|
+
const body = await readJson(res);
|
|
228
|
+
const record = isRecord(body) ? body : {};
|
|
229
|
+
return {
|
|
230
|
+
dataPointId: typeof record.dataPointId === "string"
|
|
231
|
+
? record.dataPointId
|
|
232
|
+
: typeof record.id === "string"
|
|
233
|
+
? record.id
|
|
234
|
+
: undefined,
|
|
235
|
+
expectedVersion: typeof record.expectedVersion === "string"
|
|
236
|
+
? record.expectedVersion
|
|
237
|
+
: undefined,
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/lineage/gateway.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AA6F/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5B,qEAAqE;QACrE,0EAA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GE_KEY, LOCAL_SCOPE_SCAN_PAGE, MAX_LINEAGE_SOURCES, assertDerivedScopeNaming, derivedScopeViolatesNaming, extractLineageField, hasReservedLineageKey, parseLineageSources, prepareLineage, readStoredLineage, resolveLineageSources, scopeNamespace, stampLineage, type LineageDataPointRecord, type LineageSourceLookup, type PrepareLineageInput, type ResolveLineageSourcesInput, type ResolvedLineageSource, type StoredLineage, } from "./lineage.js";
|
|
2
|
+
export { createGatewayLineageClient, type GatewayLineageClientOptions, type GatewayProof, type GetLineageInput, type LineageGatewayPort, type LineageGatewayResult, type LineageNode, type LineageView, type RegisterDataPointWithLineageParams, type RegisterDataPointWithLineageResult, } from "./gateway.js";
|
|
3
|
+
export { LINEAGE_ATTESTATION_TYPES, type LineageAttestationMessage, } from "./attestation.js";
|
|
4
|
+
export { computeDataPointId } from "../sync/data-point-id.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lineage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,GACxC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,KAAK,yBAAyB,GAC/B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { LINEAGE_FIELD, LINEAGE_KEY, LOCAL_SCOPE_SCAN_PAGE, MAX_LINEAGE_SOURCES, assertDerivedScopeNaming, derivedScopeViolatesNaming, extractLineageField, hasReservedLineageKey, parseLineageSources, prepareLineage, readStoredLineage, resolveLineageSources, scopeNamespace, stampLineage, } from "./lineage.js";
|
|
2
|
+
export { createGatewayLineageClient, } from "./gateway.js";
|
|
3
|
+
export { LINEAGE_ATTESTATION_TYPES, } from "./attestation.js";
|
|
4
|
+
export { computeDataPointId } from "../sync/data-point-id.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lineage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,YAAY,GAOb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,0BAA0B,GAU3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,GAE1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derivative data: lineage on the write path.
|
|
3
|
+
*
|
|
4
|
+
* A derivative is an ordinary write whose body names the data points it was
|
|
5
|
+
* computed from. The caller's `lineage` field (top level of a JSON body, or
|
|
6
|
+
* inside the `X-Vana-Metadata` object of a binary write) is a list of data
|
|
7
|
+
* point ids, `keccak256(abi.encode(owner, scope))`. The Personal Server
|
|
8
|
+
* validates it against the owner's own data points and mirrors it into the
|
|
9
|
+
* envelope `data` under the reserved `$lineage` key, the same in-`data`
|
|
10
|
+
* marker idiom as `$writtenBy` and `$binary`, so lineage rides the unchanged
|
|
11
|
+
* encrypt / upload / register path and `metadataHash` commits to it.
|
|
12
|
+
*
|
|
13
|
+
* The caller's `lineage` field is left in the record untouched: for session
|
|
14
|
+
* writes it is inside the bytes the builder signed, so the lineage claim is
|
|
15
|
+
* builder-signed and `$lineage` is the server-validated mirror of it.
|
|
16
|
+
*
|
|
17
|
+
* See docs/derivative-data-api.md for the wire contract.
|
|
18
|
+
*/
|
|
19
|
+
import type { DataStoragePort } from "../ports/index.js";
|
|
20
|
+
/** Reserved key inside the envelope `data` record for validated lineage. */
|
|
21
|
+
export declare const LINEAGE_KEY: "$lineage";
|
|
22
|
+
/** The caller-facing field name (JSON body top level / binary metadata). */
|
|
23
|
+
export declare const LINEAGE_FIELD: "lineage";
|
|
24
|
+
/** Upper bound on sources per record; keeps validation and hashing bounded. */
|
|
25
|
+
export declare const MAX_LINEAGE_SOURCES = 256;
|
|
26
|
+
/** Page size of the local index scan the source resolver runs. */
|
|
27
|
+
export declare const LOCAL_SCOPE_SCAN_PAGE = 1000;
|
|
28
|
+
export interface StoredLineage {
|
|
29
|
+
/** Validated, lowercased source data point ids in the order given. */
|
|
30
|
+
sources: `0x${string}`[];
|
|
31
|
+
/** ISO timestamp the Personal Server validated and stamped the lineage. */
|
|
32
|
+
writtenAt: string;
|
|
33
|
+
}
|
|
34
|
+
/** A source as the resolver saw it (local index or gateway). */
|
|
35
|
+
export interface ResolvedLineageSource {
|
|
36
|
+
dataPointId: `0x${string}`;
|
|
37
|
+
scope: string;
|
|
38
|
+
/** Null while the source is only known locally (not registered yet). */
|
|
39
|
+
version: string | null;
|
|
40
|
+
deletedAt: string | null;
|
|
41
|
+
}
|
|
42
|
+
/** The subset of a gateway data-point record the resolver needs. */
|
|
43
|
+
export interface LineageDataPointRecord {
|
|
44
|
+
dataPointId: string;
|
|
45
|
+
ownerAddress: string;
|
|
46
|
+
scope: string;
|
|
47
|
+
version: string;
|
|
48
|
+
deletedAt: string | null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gateway lookup for a source that is not in the local index. Must include
|
|
52
|
+
* deleted (tombstoned) data points: a deleted source is still a valid
|
|
53
|
+
* lineage target, it is only reported as deleted when the lineage is walked.
|
|
54
|
+
*/
|
|
55
|
+
export interface LineageSourceLookup {
|
|
56
|
+
getDataPoint(dataPointId: string): Promise<LineageDataPointRecord | null>;
|
|
57
|
+
}
|
|
58
|
+
export declare function hasReservedLineageKey(data: Record<string, unknown>): boolean;
|
|
59
|
+
/** Stamp validated lineage into an envelope `data` record. */
|
|
60
|
+
export declare function stampLineage(data: Record<string, unknown>, lineage: StoredLineage): Record<string, unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* The stored `$lineage` of a record, or null for a root record. Tolerates
|
|
63
|
+
* hand-crafted envelopes: anything that is not the exact stamped shape is
|
|
64
|
+
* treated as no lineage rather than thrown on.
|
|
65
|
+
*/
|
|
66
|
+
export declare class StoredLineageMalformedError extends Error {
|
|
67
|
+
constructor(detail: string);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Absent `$lineage` (or a data object that is not a record) is `null`: no
|
|
71
|
+
* statement. A PRESENT but malformed `$lineage` throws: a corrupted or
|
|
72
|
+
* hand-crafted derivative must fail closed, never fall through the root
|
|
73
|
+
* path and get registered as if it made no lineage statement.
|
|
74
|
+
*/
|
|
75
|
+
export declare function readStoredLineage(data: Record<string, unknown> | undefined): StoredLineage | null;
|
|
76
|
+
/**
|
|
77
|
+
* The caller's `lineage` field from a JSON body or a binary write's parsed
|
|
78
|
+
* metadata. `undefined` when the container is not an object or carries no
|
|
79
|
+
* such field, so a bare-string metadata header or a lineage-less body is a
|
|
80
|
+
* root record.
|
|
81
|
+
*/
|
|
82
|
+
export declare function extractLineageField(container: unknown): unknown;
|
|
83
|
+
/**
|
|
84
|
+
* Parse the caller's `lineage` value: an array of distinct 0x-prefixed
|
|
85
|
+
* 32-byte hex strings, at most MAX_LINEAGE_SOURCES long. Ids are lowercased
|
|
86
|
+
* so equal ids compare equal wherever they are stored. Throws
|
|
87
|
+
* LineageInvalidError (400).
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseLineageSources(value: unknown): `0x${string}`[];
|
|
90
|
+
/** First dot-segment of a scope (`chatgpt` for `chatgpt.conversations`). */
|
|
91
|
+
export declare function scopeNamespace(scope: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* The naming rule. Grant patterns are exact, `prefix.*` or `*`; `prefix.*`
|
|
94
|
+
* covers every scope that starts with `prefix.`. A derived scope and a
|
|
95
|
+
* source scope are both covered by the same non-universal pattern exactly
|
|
96
|
+
* when they share their first segment, and that is the one way the current
|
|
97
|
+
* grammar can leak across a lineage edge (a grant on `chatgpt.*` would read
|
|
98
|
+
* both `chatgpt.conversations` and a derivative named `chatgpt.summary`).
|
|
99
|
+
* `*` reads everything by definition and is not a lineage leak.
|
|
100
|
+
*/
|
|
101
|
+
export declare function derivedScopeViolatesNaming(derivedScope: string, sourceScope: string): boolean;
|
|
102
|
+
export declare function assertDerivedScopeNaming(derivedScope: string, sourceScopes: readonly string[]): void;
|
|
103
|
+
export interface ResolveLineageSourcesInput {
|
|
104
|
+
/** The derived record's scope. */
|
|
105
|
+
scope: string;
|
|
106
|
+
sources: readonly `0x${string}`[];
|
|
107
|
+
serverOwner: `0x${string}`;
|
|
108
|
+
storage: Pick<DataStoragePort, "listScopes">;
|
|
109
|
+
/** Absent = sources must be in the local index. */
|
|
110
|
+
gateway?: LineageSourceLookup;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve every source id to a data point of this owner. The local index is
|
|
114
|
+
* consulted first (`keccak256(owner, scope)` over the server's own scopes,
|
|
115
|
+
* so an unsynced local scope is a valid source), then the gateway with
|
|
116
|
+
* deleted points included. An id that resolves to nothing, or to another
|
|
117
|
+
* owner's data point, fails the whole write with 422
|
|
118
|
+
* LINEAGE_SOURCE_UNKNOWN listing every offending id; a gateway that cannot
|
|
119
|
+
* be reached fails with 502 so the builder retries instead of being told
|
|
120
|
+
* its source does not exist.
|
|
121
|
+
*/
|
|
122
|
+
export declare function resolveLineageSources(input: ResolveLineageSourcesInput): Promise<ResolvedLineageSource[]>;
|
|
123
|
+
export interface PrepareLineageInput {
|
|
124
|
+
scope: string;
|
|
125
|
+
/** The raw caller value (`body.lineage` / `metadata.lineage`). */
|
|
126
|
+
field: unknown;
|
|
127
|
+
serverOwner: `0x${string}` | undefined;
|
|
128
|
+
storage: Pick<DataStoragePort, "listScopes">;
|
|
129
|
+
gateway?: LineageSourceLookup;
|
|
130
|
+
now: () => Date;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Validate a write's lineage end to end (shape, sources, naming rule) and
|
|
134
|
+
* produce the `$lineage` record to stamp. An empty list is an EXPLICIT root
|
|
135
|
+
* statement: it is stamped (`sources: []`) and registered as an attested
|
|
136
|
+
* root, distinct from an absent field, which makes no lineage statement.
|
|
137
|
+
* Throws ProtocolErrors; callers on the write path let them propagate
|
|
138
|
+
* before anything is stored.
|
|
139
|
+
*/
|
|
140
|
+
export declare function prepareLineage(input: PrepareLineageInput): Promise<StoredLineage>;
|
|
141
|
+
//# sourceMappingURL=lineage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage.d.ts","sourceRoot":"","sources":["../../src/lineage/lineage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,4EAA4E;AAC5E,eAAO,MAAM,WAAW,EAAG,UAAmB,CAAC;AAE/C,4EAA4E;AAC5E,eAAO,MAAM,aAAa,EAAG,SAAkB,CAAC;AA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