@opendatalabs/personal-server-ts-core 0.0.1-canary.82bbb2e → 0.0.1-canary.82fa1a0

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 (203) hide show
  1. package/dist/api/index.d.ts +91 -3
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/api/index.js +270 -19
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/contracts/data.d.ts +37 -5
  6. package/dist/contracts/data.d.ts.map +1 -1
  7. package/dist/contracts/data.js +105 -26
  8. package/dist/contracts/data.js.map +1 -1
  9. package/dist/contracts/index.d.ts +1 -1
  10. package/dist/contracts/index.d.ts.map +1 -1
  11. package/dist/errors/pdpp-catalog.d.ts +36 -0
  12. package/dist/errors/pdpp-catalog.d.ts.map +1 -0
  13. package/dist/errors/pdpp-catalog.js +86 -0
  14. package/dist/errors/pdpp-catalog.js.map +1 -0
  15. package/dist/grants/index.d.ts +2 -0
  16. package/dist/grants/index.d.ts.map +1 -1
  17. package/dist/grants/index.js +4 -0
  18. package/dist/grants/index.js.map +1 -1
  19. package/dist/grants/pdpp-binding-store.d.ts +89 -0
  20. package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
  21. package/dist/grants/pdpp-binding-store.js +112 -0
  22. package/dist/grants/pdpp-binding-store.js.map +1 -0
  23. package/dist/grants/pdpp-binding.d.ts +169 -0
  24. package/dist/grants/pdpp-binding.d.ts.map +1 -0
  25. package/dist/grants/pdpp-binding.js +236 -0
  26. package/dist/grants/pdpp-binding.js.map +1 -0
  27. package/dist/mcp/connection-api.d.ts +33 -2
  28. package/dist/mcp/connection-api.d.ts.map +1 -1
  29. package/dist/mcp/connection-api.js +144 -17
  30. package/dist/mcp/connection-api.js.map +1 -1
  31. package/dist/mcp/index.d.ts +1 -0
  32. package/dist/mcp/index.d.ts.map +1 -1
  33. package/dist/mcp/index.js +1 -0
  34. package/dist/mcp/index.js.map +1 -1
  35. package/dist/mcp/read-client.d.ts +2 -0
  36. package/dist/mcp/read-client.d.ts.map +1 -1
  37. package/dist/mcp/read-client.js +4 -1
  38. package/dist/mcp/read-client.js.map +1 -1
  39. package/dist/mcp/server.d.ts +19 -0
  40. package/dist/mcp/server.d.ts.map +1 -1
  41. package/dist/mcp/server.js +155 -15
  42. package/dist/mcp/server.js.map +1 -1
  43. package/dist/mcp/store.d.ts.map +1 -1
  44. package/dist/mcp/store.js +21 -0
  45. package/dist/mcp/store.js.map +1 -1
  46. package/dist/mcp/token-expiry.d.ts +38 -0
  47. package/dist/mcp/token-expiry.d.ts.map +1 -0
  48. package/dist/mcp/token-expiry.js +55 -0
  49. package/dist/mcp/token-expiry.js.map +1 -0
  50. package/dist/mcp/tools.d.ts +26 -1
  51. package/dist/mcp/tools.d.ts.map +1 -1
  52. package/dist/mcp/tools.js +58 -23
  53. package/dist/mcp/tools.js.map +1 -1
  54. package/dist/mcp/types.d.ts +42 -4
  55. package/dist/mcp/types.d.ts.map +1 -1
  56. package/dist/mcp/types.js +1 -1
  57. package/dist/mcp/types.js.map +1 -1
  58. package/dist/pdpp/approval.d.ts +271 -0
  59. package/dist/pdpp/approval.d.ts.map +1 -0
  60. package/dist/pdpp/approval.js +467 -0
  61. package/dist/pdpp/approval.js.map +1 -0
  62. package/dist/pdpp/client-identity.d.ts +88 -0
  63. package/dist/pdpp/client-identity.d.ts.map +1 -0
  64. package/dist/pdpp/client-identity.js +196 -0
  65. package/dist/pdpp/client-identity.js.map +1 -0
  66. package/dist/pdpp/client-metadata.d.ts +95 -0
  67. package/dist/pdpp/client-metadata.d.ts.map +1 -0
  68. package/dist/pdpp/client-metadata.js +96 -0
  69. package/dist/pdpp/client-metadata.js.map +1 -0
  70. package/dist/pdpp/commitments.d.ts +75 -0
  71. package/dist/pdpp/commitments.d.ts.map +1 -0
  72. package/dist/pdpp/commitments.js +113 -0
  73. package/dist/pdpp/commitments.js.map +1 -0
  74. package/dist/pdpp/declaration.d.ts +118 -0
  75. package/dist/pdpp/declaration.d.ts.map +1 -0
  76. package/dist/pdpp/declaration.js +836 -0
  77. package/dist/pdpp/declaration.js.map +1 -0
  78. package/dist/pdpp/index.d.ts +37 -0
  79. package/dist/pdpp/index.d.ts.map +1 -0
  80. package/dist/pdpp/index.js +23 -0
  81. package/dist/pdpp/index.js.map +1 -0
  82. package/dist/pdpp/issuance.d.ts +126 -0
  83. package/dist/pdpp/issuance.d.ts.map +1 -0
  84. package/dist/pdpp/issuance.js +180 -0
  85. package/dist/pdpp/issuance.js.map +1 -0
  86. package/dist/pdpp/pkce.d.ts +53 -0
  87. package/dist/pdpp/pkce.d.ts.map +1 -0
  88. package/dist/pdpp/pkce.js +109 -0
  89. package/dist/pdpp/pkce.js.map +1 -0
  90. package/dist/pdpp/redirect.d.ts +60 -0
  91. package/dist/pdpp/redirect.d.ts.map +1 -0
  92. package/dist/pdpp/redirect.js +125 -0
  93. package/dist/pdpp/redirect.js.map +1 -0
  94. package/dist/pdpp/resolve.d.ts +109 -0
  95. package/dist/pdpp/resolve.d.ts.map +1 -0
  96. package/dist/pdpp/resolve.js +393 -0
  97. package/dist/pdpp/resolve.js.map +1 -0
  98. package/dist/pdpp/review.d.ts +280 -0
  99. package/dist/pdpp/review.d.ts.map +1 -0
  100. package/dist/pdpp/review.js +205 -0
  101. package/dist/pdpp/review.js.map +1 -0
  102. package/dist/pdpp/selection.d.ts +50 -0
  103. package/dist/pdpp/selection.d.ts.map +1 -0
  104. package/dist/pdpp/selection.js +442 -0
  105. package/dist/pdpp/selection.js.map +1 -0
  106. package/dist/pdpp/store.d.ts +228 -0
  107. package/dist/pdpp/store.d.ts.map +1 -0
  108. package/dist/pdpp/store.js +542 -0
  109. package/dist/pdpp/store.js.map +1 -0
  110. package/dist/pdpp/tokens.d.ts +181 -0
  111. package/dist/pdpp/tokens.d.ts.map +1 -0
  112. package/dist/pdpp/tokens.js +419 -0
  113. package/dist/pdpp/tokens.js.map +1 -0
  114. package/dist/pdpp/types.d.ts +441 -0
  115. package/dist/pdpp/types.d.ts.map +1 -0
  116. package/dist/pdpp/types.js +61 -0
  117. package/dist/pdpp/types.js.map +1 -0
  118. package/dist/pdpp-version.d.ts +28 -0
  119. package/dist/pdpp-version.d.ts.map +1 -0
  120. package/dist/pdpp-version.js +28 -0
  121. package/dist/pdpp-version.js.map +1 -0
  122. package/dist/policy/data-read.d.ts +24 -0
  123. package/dist/policy/data-read.d.ts.map +1 -1
  124. package/dist/policy/data-read.js +48 -0
  125. package/dist/policy/data-read.js.map +1 -1
  126. package/dist/ports/index.d.ts +16 -0
  127. package/dist/ports/index.d.ts.map +1 -1
  128. package/dist/ports/index.js.map +1 -1
  129. package/dist/ports/pdpp-auth.d.ts +129 -0
  130. package/dist/ports/pdpp-auth.d.ts.map +1 -0
  131. package/dist/ports/pdpp-auth.js +60 -0
  132. package/dist/ports/pdpp-auth.js.map +1 -0
  133. package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
  134. package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
  135. package/dist/ports/pdpp-auth.test-utils.js +18 -0
  136. package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
  137. package/dist/schemas/server-config.d.ts +37 -0
  138. package/dist/schemas/server-config.d.ts.map +1 -1
  139. package/dist/schemas/server-config.js +90 -0
  140. package/dist/schemas/server-config.js.map +1 -1
  141. package/dist/storage/adapters/vana.d.ts +1 -1
  142. package/dist/storage/adapters/vana.d.ts.map +1 -1
  143. package/dist/storage/index/manager.d.ts +29 -2
  144. package/dist/storage/index/manager.d.ts.map +1 -1
  145. package/dist/storage/index/schema.d.ts +1 -1
  146. package/dist/storage/index/schema.js +1 -1
  147. package/dist/storage/index/types.d.ts +7 -1
  148. package/dist/storage/index/types.d.ts.map +1 -1
  149. package/dist/storage/pdpp-records/cursor.d.ts +41 -0
  150. package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
  151. package/dist/storage/pdpp-records/cursor.js +49 -0
  152. package/dist/storage/pdpp-records/cursor.js.map +1 -0
  153. package/dist/storage/pdpp-records/enforcement.d.ts +52 -0
  154. package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
  155. package/dist/storage/pdpp-records/enforcement.js +116 -0
  156. package/dist/storage/pdpp-records/enforcement.js.map +1 -0
  157. package/dist/storage/pdpp-records/index.d.ts +9 -0
  158. package/dist/storage/pdpp-records/index.d.ts.map +1 -0
  159. package/dist/storage/pdpp-records/index.js +9 -0
  160. package/dist/storage/pdpp-records/index.js.map +1 -0
  161. package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
  162. package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
  163. package/dist/storage/pdpp-records/ingest-plan.js +103 -0
  164. package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
  165. package/dist/storage/pdpp-records/interface.d.ts +104 -0
  166. package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
  167. package/dist/storage/pdpp-records/interface.js +2 -0
  168. package/dist/storage/pdpp-records/interface.js.map +1 -0
  169. package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
  170. package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
  171. package/dist/storage/pdpp-records/memory-store.js +466 -0
  172. package/dist/storage/pdpp-records/memory-store.js.map +1 -0
  173. package/dist/storage/pdpp-records/record-key.d.ts +52 -0
  174. package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
  175. package/dist/storage/pdpp-records/record-key.js +97 -0
  176. package/dist/storage/pdpp-records/record-key.js.map +1 -0
  177. package/dist/storage/pdpp-records/stream-declaration.d.ts +88 -0
  178. package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
  179. package/dist/storage/pdpp-records/stream-declaration.js +57 -0
  180. package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
  181. package/dist/storage/pdpp-records/types.d.ts +138 -0
  182. package/dist/storage/pdpp-records/types.d.ts.map +1 -0
  183. package/dist/storage/pdpp-records/types.js +38 -0
  184. package/dist/storage/pdpp-records/types.js.map +1 -0
  185. package/dist/sync/index.d.ts +2 -0
  186. package/dist/sync/index.d.ts.map +1 -1
  187. package/dist/sync/index.js +4 -0
  188. package/dist/sync/index.js.map +1 -1
  189. package/dist/sync/pdpp-import.d.ts +192 -0
  190. package/dist/sync/pdpp-import.d.ts.map +1 -0
  191. package/dist/sync/pdpp-import.js +441 -0
  192. package/dist/sync/pdpp-import.js.map +1 -0
  193. package/dist/sync/workers/download.d.ts +14 -0
  194. package/dist/sync/workers/download.d.ts.map +1 -1
  195. package/dist/sync/workers/download.js +109 -1
  196. package/dist/sync/workers/download.js.map +1 -1
  197. package/dist/sync/workers/upload.d.ts +1 -1
  198. package/dist/sync/workers/upload.d.ts.map +1 -1
  199. package/dist/test-utils/memory-storage.d.ts +1 -1
  200. package/dist/test-utils/memory-storage.d.ts.map +1 -1
  201. package/dist/test-utils/memory-storage.js +11 -5
  202. package/dist/test-utils/memory-storage.js.map +1 -1
  203. package/package.json +26 -2
@@ -5,6 +5,7 @@ import type { DataReadPolicyPorts } from "../policy/index.js";
5
5
  import type { SyncManager } from "../sync/index.js";
6
6
  import { type ScopeDeletionTracker } from "../sync/scope-deletions.js";
7
7
  import type { IndexEntry } from "../storage/index/types.js";
8
+ import { type PdppImporter } from "../sync/pdpp-import.js";
8
9
  import { type DeleteScopeResult } from "../sync/workers/delete.js";
9
10
  import { type OAuthDeviceSessionLookup, type OAuthTokenStorePort } from "../contracts/index.js";
10
11
  import type { DataFileEnvelope, DataPortabilityGatewayConfig, GatewayClient } from "@opendatalabs/vana-sdk/browser";
@@ -34,6 +35,11 @@ export interface PersonalServerWriteAuthInput {
34
35
  * same precedence as the owner write path). */
35
36
  scope: string;
36
37
  }
38
+ export interface PersonalServerScopeAuthInput {
39
+ request: Request;
40
+ /** Raw scope path param; auth ports that need scope binding validate it. */
41
+ scope: string;
42
+ }
37
43
  /**
38
44
  * Result of authorizing a DELEGATED (write-session) write. A void return
39
45
  * means the request was authorized as the owner instead — the ingest then
@@ -70,22 +76,53 @@ export interface PersonalServerWriteSessionResult {
70
76
  /** Rolls back the per-call proof reservation; see the write result. */
71
77
  releaseProof?: () => Promise<void>;
72
78
  }
79
+ /** A read the server actually served, or one it refused. */
80
+ export type PersonalServerReadOutcome = "served" | "denied";
81
+ /** Which surface the read came in on. */
82
+ export type PersonalServerReadSource = "mcp" | "api";
83
+ /**
84
+ * Stand-in for a grant/grantee that does not exist on a denial — a scope that
85
+ * no grant covers has no grant id and no builder to attribute the read to.
86
+ */
87
+ export declare const READ_FULFILLMENT_NONE = "none";
73
88
  export interface PersonalServerReadFulfillment {
89
+ /** Grantee address, or `READ_FULFILLMENT_NONE` on a denial. */
74
90
  builder: string;
91
+ /** Deny code (e.g. `scope_not_granted`); only set when outcome is denied. */
92
+ denyReason?: string;
75
93
  fileId?: string;
94
+ /**
95
+ * Grant id. A denial names the grant the refused call arrived on: the
96
+ * Gateway stores a 32-byte id, so `READ_FULFILLMENT_NONE` is refused there.
97
+ */
76
98
  grantId: string;
77
- ipAddress: string;
99
+ /** Absent on surfaces that carry no request metadata (MCP tool calls). */
100
+ ipAddress?: string;
78
101
  logId: string;
102
+ outcome: PersonalServerReadOutcome;
79
103
  scope: string;
80
104
  servedAt: string;
81
- userAgent: string;
105
+ source: PersonalServerReadSource;
106
+ /** MCP tool name; absent on the plain HTTP read path. */
107
+ tool?: string;
108
+ userAgent?: string;
82
109
  }
83
110
  export interface PersonalServerReadFulfillmentReporter {
84
111
  report(event: PersonalServerReadFulfillment): Promise<void>;
112
+ /**
113
+ * Optional: reporters that only settle served reads (relay-gated Lite) can
114
+ * omit it and denials are simply not recorded.
115
+ */
116
+ reportDenied?(event: PersonalServerReadFulfillment): Promise<void>;
85
117
  }
86
118
  export interface PersonalServerApiAuthPort {
87
119
  authorizeOwner(request: Request): Promise<void>;
88
120
  authorizeBuilderList(request: Request): Promise<void>;
121
+ /**
122
+ * Authorize listing versions for one legacy scope. Optional so auth ports
123
+ * without scoped owner-token support keep the existing builder-list gate.
124
+ */
125
+ authorizeScopeVersions?(input: PersonalServerScopeAuthInput): Promise<void>;
89
126
  authorizeBuilderRead(input: PersonalServerReadAuthInput): Promise<PersonalServerReadAuthResult | void>;
90
127
  /**
91
128
  * Authorize a data ingest (POST /v1/data/:scope). Optional — auth ports
@@ -221,6 +258,25 @@ export interface PersonalServerDataApiDeps {
221
258
  /** The stamped `$lineage.sources` of the written record, if any. */
222
259
  lineageSources?: string[];
223
260
  }) => void;
261
+ /**
262
+ * Import a locally-ingested envelope into the PDPP record store, when the
263
+ * deployment mounted one.
264
+ *
265
+ * The same importer, the same envelope shape and the same best-effort
266
+ * contract as the download worker's (`sync/workers/download.ts`). It is
267
+ * here because a `$pdpp`-annotated envelope can reach this server two ways
268
+ * — pulled from the gateway by sync, or POSTed to `/v1/data/:scope` by a
269
+ * local owner-authenticated producer — and only the first offered it to the
270
+ * importer. A record that arrived by the second route was stored and
271
+ * indexed but never became readable over the PDPP resource surface, which
272
+ * made a local producer's write silently half-land.
273
+ *
274
+ * Runs AFTER the legacy write and index, never in place of them, and a
275
+ * failure is logged and swallowed: the record is already durable by the
276
+ * time this runs, so throwing would turn a committed write into a 500 and
277
+ * invite a duplicate on retry.
278
+ */
279
+ pdppImporter?: PdppImporter;
224
280
  /**
225
281
  * Called on GET /v1/data/:scope once the read is authorized (a live grant
226
282
  * covering the scope, or the owner) and the scope is not tombstoned, and
@@ -268,6 +324,31 @@ export interface PersonalServerOauthTokenApiDeps {
268
324
  export interface PersonalServerApiDispatchOptions {
269
325
  basePath?: string;
270
326
  }
327
+ /**
328
+ * What a 500 out of this layer must leave behind.
329
+ *
330
+ * These handlers run INSIDE the Hono app, so an error they catch never
331
+ * reaches the framework's `onError` — which is the one place that used to
332
+ * log. The result was that any unexpected fault on `/v1/data` answered a
333
+ * bare `INTERNAL_ERROR` and left nothing in stdout, nothing in the access
334
+ * log, and nothing for an operator to work from. Diagnosing one meant
335
+ * patching the server.
336
+ *
337
+ * Deliberately no request body, no headers, no query string and no
338
+ * authorization material: the route and method are the diagnostic value, and
339
+ * a grant id or signed header in a log file is a credential at rest. The
340
+ * request id is minted here when the caller did not supply one so the log
341
+ * line and the response can always be correlated.
342
+ */
343
+ export interface ApiErrorLogContext {
344
+ logger?: PersonalServerApiLogger;
345
+ /** Stable route label, e.g. `GET /v1/data/:scope`. Never the raw path. */
346
+ route: string;
347
+ /** Correlates the log line with the response. Minted if absent. */
348
+ requestId?: string;
349
+ /** Non-secret route parameters worth having in the line (e.g. scope). */
350
+ detail?: Record<string, string | undefined>;
351
+ }
271
352
  /**
272
353
  * The grant the caller nominates for a read: `?grantId=` or the
273
354
  * `x-ps-grant-id` header, the SDK's shape on every read route. Exported so
@@ -343,7 +424,14 @@ export declare function resolveReadDeletion(deps: Pick<PersonalServerDataApiDeps
343
424
  export declare function assertScopeNotDeleted(deps: Pick<PersonalServerDataApiDeps, "scopeDeletions" | "serverOwner">, scope: string, entry: ReadDeletionEntry | null | undefined): Promise<void>;
344
425
  /** The index fields the deletion gate needs from the entry a read would serve. */
345
426
  export type ReadDeletionEntry = Pick<IndexEntry, "version" | "dataPointId" | "afterTombstoneVersion">;
346
- export declare function reportPersonalServerReadFulfillment(deps: PersonalServerDataApiDeps, event: PersonalServerReadFulfillment): void;
427
+ /** Everything the fulfillment reporters need; see the MCP tool wrapper. */
428
+ export type PersonalServerReadReporterDeps = Pick<PersonalServerDataApiDeps, "logger" | "readFulfillmentReporter">;
429
+ export declare function reportPersonalServerReadFulfillment(deps: PersonalServerReadReporterDeps, event: PersonalServerReadFulfillment): void;
430
+ /**
431
+ * Denials mirror fulfillments but skip the grant filter: a refused read has no
432
+ * grant to filter on, and the record is what proves the refusal happened.
433
+ */
434
+ export declare function reportPersonalServerReadDenial(deps: PersonalServerReadReporterDeps, event: PersonalServerReadFulfillment): void;
347
435
  /**
348
436
  * True when a read auth result entitles the caller to the owner's view of a
349
437
  * record — the same convention as resolveLineageGrantView: no result, or the
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.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IAAI,GAC9C,OAAO,CAMT;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,gBAAgB,GACzB,gBAAgB,CAqClB;AAED,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AAEtE,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,QAAQ,CAAC,CA6sBnB;AAED,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,+BAA+B,EACrC,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,QAAQ,CAAC,CAenB;AAED,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,QAAQ,CAAC,CAyCnB;AAED,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,QAAQ,CAAC,CAyEnB;AAED,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,QAAQ,CAAC,CA8BnB;AAED,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,QAAQ,CAAC,CA6BnB;AAED,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
package/dist/api/index.js CHANGED
@@ -1,12 +1,19 @@
1
1
  import { DataDeletedError, DeleteTombstoneFailedError, GrantRequiredError, InvalidCascadeError, LineageCascadeUnavailableError, LineageGatewayError, LineageUnavailableError, ProtocolError, ServerNotConfiguredError, } from "../errors/catalog.js";
2
2
  import { computeDataPointId } from "../sync/data-point-id.js";
3
3
  import { isEntryCoveredByTombstone, } from "../sync/scope-deletions.js";
4
+ import { isPermanentRejection, } from "../sync/pdpp-import.js";
4
5
  import { deleteScope as deleteScopeLocally, } from "../sync/workers/delete.js";
5
- import { ingestDataContract, ingestBinaryDataContract, listAccessLogsContract, listDataScopesContract, listDataVersionsContract, parseDataScopeContract, parseJsonObjectBody, readDataContract, syncFileContract, triggerSyncContract, getSyncStatusContract, configReadErrorContract, configWriteErrorContract, createGrantContract, listGrantsContract, oauthTokenContract, revokeGrantContract, validateServerConfigContract, verifyGrantContract, decodeBinaryEnvelope, isBinaryEnvelope, parseMetadataHeader, stringifyMetadataHeader, IngestPersistedError, } from "../contracts/index.js";
6
+ import { ingestDataContract, ingestBinaryDataContract, listAccessLogsContract, listDataScopesContract, listDataVersionsContract, parseDataScopeContract, parseJsonObjectBody, readDataContract, syncFileContract, triggerSyncContract, getSyncStatusContract, configReadErrorContract, configWriteErrorContract, createGrantContract, listGrantsContract, oauthTokenContract, revokeGrantContract, validateServerConfigContract, verifyGrantContract, decodeBinaryEnvelope, isBinaryEnvelope, parseMetadataHeader, stringifyMetadataHeader, IngestPersistedError, sha256Hex, } from "../contracts/index.js";
7
+ import { canonicalJsonBytes } from "../derivatives/e2ee/jcs.js";
6
8
  import { WRITER_ATTRIBUTION_KEY, } from "../write/attribution.js";
7
9
  import { extractLineageField, LINEAGE_KEY, prepareLineage, } from "../lineage/lineage.js";
8
10
  import { binaryFilename, binaryMimeType, isJsonContentType, } from "../contracts/binary.js";
9
11
  import { buildChallenge, parsePaymentHeader, verifyPayment, } from "../payment/index.js";
12
+ /**
13
+ * Stand-in for a grant/grantee that does not exist on a denial — a scope that
14
+ * no grant covers has no grant id and no builder to attribute the read to.
15
+ */
16
+ export const READ_FULFILLMENT_NONE = "none";
10
17
  function jsonResponse(body, init) {
11
18
  const headers = new Headers(init?.headers);
12
19
  headers.set("Content-Type", "application/json");
@@ -53,17 +60,80 @@ function methodNotAllowed() {
53
60
  function notFound() {
54
61
  return errorResponse(404, "NOT_FOUND", "Not found");
55
62
  }
56
- async function withApiErrors(handler) {
63
+ async function withApiErrors(handler, context) {
57
64
  try {
58
- return await handler();
65
+ const response = await handler();
66
+ // A handled 4xx that means "the index and the disk disagree" is an
67
+ // operator-facing fault even though it is not a 500 — log it once, here,
68
+ // rather than at the contract that cannot see the route.
69
+ if (response.status === 404 && context) {
70
+ await logMissingDataFile(response, context);
71
+ }
72
+ return response;
59
73
  }
60
74
  catch (err) {
61
75
  if (err instanceof ProtocolError) {
62
76
  return protocolErrorResponse(err);
63
77
  }
78
+ if (context) {
79
+ context.logger?.error?.({
80
+ route: context.route,
81
+ requestId: context.requestId ?? crypto.randomUUID(),
82
+ errorCode: "INTERNAL_ERROR",
83
+ ...stripUndefined(context.detail),
84
+ err: describeError(err),
85
+ }, "Unhandled error in personal server API");
86
+ }
64
87
  return errorResponse(500, "INTERNAL_ERROR", "Internal server error");
65
88
  }
66
89
  }
90
+ /**
91
+ * The `DATA_FILE_MISSING` 404 the read contract produces, logged at the one
92
+ * layer that knows which route served it. Peeks at a clone so the response
93
+ * body stays readable by the caller.
94
+ */
95
+ async function logMissingDataFile(response, context) {
96
+ if (!context.logger?.error)
97
+ return;
98
+ try {
99
+ const body = await response.clone().json();
100
+ if (typeof body !== "object" ||
101
+ body === null ||
102
+ body.error !== "DATA_FILE_MISSING") {
103
+ return;
104
+ }
105
+ context.logger.error({
106
+ route: context.route,
107
+ requestId: context.requestId ?? crypto.randomUUID(),
108
+ errorCode: "DATA_FILE_MISSING",
109
+ ...stripUndefined(context.detail),
110
+ }, "Indexed data file is missing on disk");
111
+ }
112
+ catch {
113
+ // A diagnostic log must not change the response sent to the caller.
114
+ }
115
+ }
116
+ /**
117
+ * An error rendered for a log line — name, message and stack only. Never the
118
+ * whole object: a thrown error can carry a request, a config or a token on an
119
+ * arbitrary property, and a structured logger would serialize all of it.
120
+ */
121
+ function describeError(err) {
122
+ if (err instanceof Error) {
123
+ return {
124
+ name: err.name,
125
+ message: err.message,
126
+ ...("code" in err && { code: err.code }),
127
+ stack: err.stack,
128
+ };
129
+ }
130
+ return { message: String(err) };
131
+ }
132
+ function stripUndefined(detail) {
133
+ if (!detail)
134
+ return {};
135
+ return Object.fromEntries(Object.entries(detail).filter((pair) => pair[1] !== undefined));
136
+ }
67
137
  function normalizeLimit(value, fallback) {
68
138
  if (value === null)
69
139
  return fallback;
@@ -257,10 +327,83 @@ export async function handleX402Cycle(input) {
257
327
  }
258
328
  return { kind: "gateway-error", status: gatewayRes.status, body: errorBody };
259
329
  }
260
- function collectedAt(now) {
261
- return now()
262
- .toISOString()
263
- .replace(/\.\d{3}Z$/, "Z");
330
+ const lastCollectedAtByStorage = new WeakMap();
331
+ function collectedAt(now, storage, scope) {
332
+ // Further writes in the same second need distinct paths so no version is
333
+ // overwritten. Use one timestamp format so lexical ordering remains valid.
334
+ const second = Math.floor(now().getTime() / 1000) * 1000;
335
+ // The process-local clock resets on restart. Consult the durable head so a
336
+ // same-second restart cannot reuse a committed envelope path.
337
+ const latest = Date.parse(storage.findEntry({ scope })?.collectedAt ?? "");
338
+ const current = Math.max(second, (lastCollectedAtByStorage.get(storage) ?? 0) + 1, Number.isFinite(latest) ? latest + 1 : 0);
339
+ lastCollectedAtByStorage.set(storage, current);
340
+ return new Date(current).toISOString();
341
+ }
342
+ function parseLegacyPrecondition(request) {
343
+ const none = request.headers.get("if-none-match");
344
+ const match = request.headers.get("if-match");
345
+ if (none !== null && match !== null) {
346
+ return errorResponse(400, "INVALID_PRECONDITION", "Supply only one precondition");
347
+ }
348
+ if (none !== null) {
349
+ return none === "*"
350
+ ? { kind: "none" }
351
+ : errorResponse(400, "INVALID_PRECONDITION", "If-None-Match must be *");
352
+ }
353
+ if (match !== null) {
354
+ const parsed = /^"([1-9]\d*)"$/.exec(match);
355
+ const version = parsed ? Number(parsed[1]) : NaN;
356
+ return Number.isSafeInteger(version)
357
+ ? { kind: "match", version }
358
+ : errorResponse(400, "INVALID_PRECONDITION", "If-Match must be a quoted positive version");
359
+ }
360
+ return undefined;
361
+ }
362
+ function parseProducerHeader(request) {
363
+ const producer = request.headers.get("vana-producer");
364
+ const encodedProvenance = request.headers.get("vana-producer-provenance") ?? undefined;
365
+ if (producer === null && !encodedProvenance)
366
+ return {};
367
+ if (producer !== "pdpp-projector" && producer !== "pdpp-import-projection") {
368
+ return errorResponse(400, "INVALID_PRODUCER", "Vana-Producer is unrecognized or missing");
369
+ }
370
+ if (encodedProvenance &&
371
+ (encodedProvenance.length > 8192 ||
372
+ !/^[A-Za-z0-9_-]+$/.test(encodedProvenance))) {
373
+ return errorResponse(400, "INVALID_PROVENANCE", "Vana-Producer-Provenance is malformed");
374
+ }
375
+ return { producer, encodedProvenance };
376
+ }
377
+ async function parseProducerProvenance(encoded, body) {
378
+ if (!encoded)
379
+ return undefined;
380
+ try {
381
+ const value = JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(encoded.replace(/-/g, "+").replace(/_/g, "/")), (char) => char.charCodeAt(0))));
382
+ if (!value ||
383
+ typeof value !== "object" ||
384
+ typeof value.projector_version !== "string" ||
385
+ !value.projector_version ||
386
+ typeof value.declaration_digest !== "string" ||
387
+ !value.declaration_digest ||
388
+ !Array.isArray(value.inputs) ||
389
+ !value.inputs.every((input) => input &&
390
+ typeof input.stream === "string" &&
391
+ input.stream &&
392
+ typeof input.changes_since_token === "string" &&
393
+ input.changes_since_token) ||
394
+ typeof value.payload_sha256 !== "string" ||
395
+ !/^(?:0x)?[0-9a-fA-F]{64}$/.test(value.payload_sha256)) {
396
+ return errorResponse(400, "INVALID_PROVENANCE", "Producer provenance has invalid fields");
397
+ }
398
+ const actual = (await sha256Hex(canonicalJsonBytes(body))).slice(2);
399
+ if (actual !== value.payload_sha256.replace(/^0x/, "").toLowerCase()) {
400
+ return errorResponse(400, "PAYLOAD_HASH_MISMATCH", "Provenance payload_sha256 does not match the JSON body");
401
+ }
402
+ return value;
403
+ }
404
+ catch {
405
+ return errorResponse(400, "INVALID_PROVENANCE", "Vana-Producer-Provenance is not base64url JSON");
406
+ }
264
407
  }
265
408
  /**
266
409
  * The deletion that applies to a read of `scope`, or null when the read may
@@ -334,12 +477,11 @@ async function ingestTombstoneMarker(deps, scope) {
334
477
  }
335
478
  // The delete worker wants a full Logger; the API logger is all-optional.
336
479
  function apiLoggerAsLogger(logger) {
337
- const noop = () => undefined;
338
480
  return {
339
- debug: (payload, message) => (logger?.debug ?? noop)(payload, message ?? ""),
340
- info: (payload, message) => (logger?.info ?? noop)(payload, message ?? ""),
341
- warn: (payload, message) => (logger?.warn ?? noop)(payload, message ?? ""),
342
- error: (payload, message) => (logger?.error ?? noop)(payload, message ?? ""),
481
+ debug: (payload, message) => logger?.debug?.(payload, message ?? ""),
482
+ info: (payload, message) => logger?.info?.(payload, message ?? ""),
483
+ warn: (payload, message) => logger?.warn?.(payload, message ?? ""),
484
+ error: (payload, message) => logger?.error?.(payload, message ?? ""),
343
485
  };
344
486
  }
345
487
  function notifyDataWritten(deps, event) {
@@ -355,6 +497,50 @@ function notifyDataWritten(deps, event) {
355
497
  }, "onDataWritten hook failed; record already stored");
356
498
  }
357
499
  }
500
+ /**
501
+ * Offer a just-ingested envelope to the PDPP importer.
502
+ *
503
+ * The local-ingest twin of the download worker's `importIntoPdpp`, and
504
+ * deliberately the same shape: same `ImportableEnvelope`, same total handling
505
+ * of every outcome, same permanent-vs-transient logging split. Keeping the
506
+ * two symmetric is the point — a `$pdpp` envelope must mean the same thing
507
+ * and reach the same store whether the gateway handed it over or a local
508
+ * producer POSTed it, otherwise "imported" would depend on which door the
509
+ * bytes came through.
510
+ *
511
+ * `skipped` is the ordinary legacy case (no `$pdpp` block) and stays silent.
512
+ * A rejection is a WARNING, not an error: it means the producer sent
513
+ * something this deployment could not verify — actionable, but not a failure
514
+ * of the write, which has already committed.
515
+ */
516
+ function importIngestedIntoPdpp(deps, envelope) {
517
+ if (!deps.pdppImporter)
518
+ return;
519
+ try {
520
+ const outcome = deps.pdppImporter.importEnvelope(envelope);
521
+ if (outcome.status === "rejected") {
522
+ const permanent = isPermanentRejection(outcome.rejection);
523
+ deps.logger?.warn?.({
524
+ scope: envelope.scope,
525
+ collectedAt: envelope.collectedAt,
526
+ code: outcome.rejection.code,
527
+ message: outcome.rejection.message,
528
+ permanent,
529
+ }, permanent
530
+ ? "Ingested data point was refused by the PDPP importer and will not be retried"
531
+ : "PDPP import unavailable for this ingested data point");
532
+ }
533
+ }
534
+ catch (err) {
535
+ // A throwing importer is infrastructure failing, not the envelope being
536
+ // wrong. The record is stored and indexed already, so this must never
537
+ // turn a committed write into a 500.
538
+ deps.logger?.warn?.({
539
+ scope: envelope.scope,
540
+ error: err instanceof Error ? err.message : String(err),
541
+ }, "PDPP import threw on ingest; record already stored and indexed");
542
+ }
543
+ }
358
544
  function notifyDataRead(deps, event) {
359
545
  if (!deps.onDataRead)
360
546
  return;
@@ -390,12 +576,26 @@ function warnReadFulfillmentReporterFailed(deps, event, err) {
390
576
  }, "Read fulfillment reporter failed");
391
577
  }
392
578
  export function reportPersonalServerReadFulfillment(deps, event) {
393
- if (!deps.readFulfillmentReporter ||
394
- !shouldReportReadFulfillment(event.grantId)) {
579
+ const reporter = deps.readFulfillmentReporter;
580
+ if (!reporter || !shouldReportReadFulfillment(event.grantId)) {
395
581
  return;
396
582
  }
583
+ fireReadReport(deps, event, reporter.report.bind(reporter));
584
+ }
585
+ /**
586
+ * Denials mirror fulfillments but skip the grant filter: a refused read has no
587
+ * grant to filter on, and the record is what proves the refusal happened.
588
+ */
589
+ export function reportPersonalServerReadDenial(deps, event) {
590
+ const reporter = deps.readFulfillmentReporter;
591
+ if (!reporter?.reportDenied)
592
+ return;
593
+ fireReadReport(deps, event, reporter.reportDenied.bind(reporter));
594
+ }
595
+ /** Fire-and-forget: reporting must never fail or delay the read it describes. */
596
+ function fireReadReport(deps, event, send) {
397
597
  try {
398
- void Promise.resolve(deps.readFulfillmentReporter.report(event)).catch((err) => warnReadFulfillmentReporterFailed(deps, event, err));
598
+ void Promise.resolve(send(event)).catch((err) => warnReadFulfillmentReporterFailed(deps, event, err));
399
599
  }
400
600
  catch (err) {
401
601
  warnReadFulfillmentReporterFailed(deps, event, err);
@@ -498,6 +698,15 @@ export function redactEnvelopeForGrantee(envelope) {
498
698
  }
499
699
  export { redactJsonEnvelopeBytesForGrantee } from "./raw-envelope.js";
500
700
  export async function handlePersonalServerDataRequest(request, deps, options = {}) {
701
+ // Filled in as the dispatch narrows, so a 500 thrown deep in a read is
702
+ // logged against the route that served it rather than a generic label. It
703
+ // is mutable for exactly that reason: the route is not known until the path
704
+ // has been parsed, and by then we are already inside the try.
705
+ const logContext = {
706
+ logger: deps.logger,
707
+ route: `${request.method} ${options.basePath ?? "/v1/data"}`,
708
+ requestId: crypto.randomUUID(),
709
+ };
501
710
  return withApiErrors(async () => {
502
711
  const url = new URL(request.url);
503
712
  const pathname = stripBasePath(url.pathname, options.basePath);
@@ -518,7 +727,15 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
518
727
  if (parts.length === 2 && parts[1] === "versions") {
519
728
  if (request.method !== "GET")
520
729
  return methodNotAllowed();
521
- await deps.auth.authorizeBuilderList(request);
730
+ if (deps.auth.authorizeScopeVersions) {
731
+ await deps.auth.authorizeScopeVersions({
732
+ request,
733
+ scope: decodePathPart(parts[0]),
734
+ });
735
+ }
736
+ else {
737
+ await deps.auth.authorizeBuilderList(request);
738
+ }
522
739
  const result = await listDataVersionsContract({
523
740
  storage: deps.storage,
524
741
  scopeParam: decodePathPart(parts[0]),
@@ -623,10 +840,12 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
623
840
  if (parts.length !== 1)
624
841
  return notFound();
625
842
  const scopeParam = decodePathPart(parts[0]);
843
+ logContext.route = `${request.method} ${options.basePath ?? "/v1/data"}/:scope`;
626
844
  if (request.method === "GET") {
627
845
  const scopeResult = parseDataScopeContract(scopeParam);
628
846
  if (!scopeResult.ok)
629
847
  return contractErrorResponse(scopeResult);
848
+ logContext.detail = { scope: scopeResult.scope };
630
849
  const selectedEntry = deps.storage.findEntry({
631
850
  scope: scopeResult.scope,
632
851
  fileId: url.searchParams.get("fileId") ?? undefined,
@@ -792,8 +1011,10 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
792
1011
  grantId: authResult.grantId,
793
1012
  ipAddress,
794
1013
  logId,
1014
+ outcome: "served",
795
1015
  scope: scopeResult.scope,
796
1016
  servedAt: timestamp,
1017
+ source: "api",
797
1018
  userAgent,
798
1019
  });
799
1020
  };
@@ -858,7 +1079,16 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
858
1079
  const scopeResult = parseDataScopeContract(scopeParam);
859
1080
  if (!scopeResult.ok)
860
1081
  return failWrite(contractErrorResponse(scopeResult));
861
- const collectedAtValue = collectedAt(deps.now ?? (() => new Date()));
1082
+ const parsedPrecondition = parseLegacyPrecondition(request);
1083
+ if (parsedPrecondition instanceof Response)
1084
+ return failWrite(parsedPrecondition);
1085
+ const producerHeader = parseProducerHeader(request);
1086
+ if (producerHeader instanceof Response)
1087
+ return failWrite(producerHeader);
1088
+ if (writeAuth && producerHeader.producer) {
1089
+ return failWrite(errorResponse(403, "NOT_OWNER", "Only the owner may assert a producer"));
1090
+ }
1091
+ const collectedAtValue = collectedAt(deps.now ?? (() => new Date()), deps.storage, scopeResult.scope);
862
1092
  const status = deps.syncManager ? "syncing" : "stored";
863
1093
  const afterTombstoneVersion = await ingestTombstoneMarker(deps, scopeResult.scope);
864
1094
  // Builder writes land in the same access log as builder reads, so the
@@ -898,6 +1128,9 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
898
1128
  // data needs no schema at all — we ingest it schemaless. (Structured JSON
899
1129
  // below still resolves a schema for validation/metadata.)
900
1130
  if (!isJsonContentType(request)) {
1131
+ if (producerHeader.producer) {
1132
+ return failWrite(errorResponse(400, "INVALID_PRODUCER", "Producer attribution requires a JSON body"));
1133
+ }
901
1134
  const bytes = new Uint8Array(await request.arrayBuffer());
902
1135
  const metadata = parseMetadataHeader(request.headers.get("x-vana-metadata"));
903
1136
  // A binary derivative names its sources inside the metadata
@@ -915,6 +1148,7 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
915
1148
  attribution: writeAuth?.attribution,
916
1149
  lineage,
917
1150
  afterTombstoneVersion,
1151
+ precondition: parsedPrecondition,
918
1152
  });
919
1153
  if (!result.ok)
920
1154
  return failWrite(contractErrorResponse(result));
@@ -939,6 +1173,9 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
939
1173
  const parsed = await parseJsonObjectBody(request, "Request body must be valid JSON");
940
1174
  if (!parsed.ok)
941
1175
  return failWrite(contractResponse(parsed.result));
1176
+ const provenance = await parseProducerProvenance(producerHeader.encodedProvenance, parsed.body);
1177
+ if (provenance instanceof Response)
1178
+ return failWrite(provenance);
942
1179
  // Derivative writes: validate the caller's `lineage` before anything
943
1180
  // is stored (a failure here throws, releasing the builder's proof).
944
1181
  const lineage = await prepareWriteLineage(deps, scopeResult.scope, extractLineageField(parsed.body));
@@ -953,6 +1190,9 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
953
1190
  attribution: writeAuth?.attribution,
954
1191
  lineage,
955
1192
  afterTombstoneVersion,
1193
+ precondition: parsedPrecondition,
1194
+ producer: producerHeader.producer,
1195
+ producerProvenance: provenance,
956
1196
  });
957
1197
  if (!result.ok)
958
1198
  return failWrite(contractErrorResponse(result));
@@ -965,6 +1205,14 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
965
1205
  }, "Data file ingested");
966
1206
  await logBuilderWrite();
967
1207
  notifyNewData(deps.syncManager);
1208
+ // The parsed body is the envelope's `data`, which is where a producer
1209
+ // stamps `$pdpp`. Offered here rather than inside the ingest contract
1210
+ // so the import stays strictly after the record is durable.
1211
+ importIngestedIntoPdpp(deps, {
1212
+ scope: scopeResult.scope,
1213
+ collectedAt: collectedAtValue,
1214
+ data: parsed.body,
1215
+ });
968
1216
  notifyDataWritten(deps, {
969
1217
  scope: scopeResult.scope,
970
1218
  collectedAt: collectedAtValue,
@@ -983,7 +1231,7 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
983
1231
  error: err.cause instanceof Error
984
1232
  ? err.cause.message
985
1233
  : String(err.cause),
986
- }, "Envelope written but indexing failed; record persisted unindexed");
1234
+ }, "Envelope write incomplete after durable commit; boot recovery may finish it");
987
1235
  }
988
1236
  else if (!committed) {
989
1237
  await writeAuth?.releaseProof?.();
@@ -1066,7 +1314,7 @@ export async function handlePersonalServerDataRequest(request, deps, options = {
1066
1314
  return jsonResponse(result, { status: 200 });
1067
1315
  }
1068
1316
  return methodNotAllowed();
1069
- });
1317
+ }, logContext);
1070
1318
  }
1071
1319
  export async function handlePersonalServerAccessLogsRequest(request, deps, options = {}) {
1072
1320
  return withApiErrors(async () => {
@@ -1112,6 +1360,9 @@ export async function handlePersonalServerSyncRequest(request, deps, options = {
1112
1360
  }));
1113
1361
  }
1114
1362
  return notFound();
1363
+ }, {
1364
+ logger: deps.logger,
1365
+ route: `${request.method} ${options.basePath ?? "/v1/sync"}`,
1115
1366
  });
1116
1367
  }
1117
1368
  export async function handlePersonalServerGrantsRequest(request, deps, options = {}) {