@opendatalabs/personal-server-ts-core 1.33.8 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/dist/additions/budget.d.ts +28 -0
  2. package/dist/additions/budget.d.ts.map +1 -0
  3. package/dist/additions/budget.js +119 -0
  4. package/dist/additions/budget.js.map +1 -0
  5. package/dist/additions/durable.d.ts +64 -0
  6. package/dist/additions/durable.d.ts.map +1 -0
  7. package/dist/additions/durable.js +591 -0
  8. package/dist/additions/durable.js.map +1 -0
  9. package/dist/additions/first-added.d.ts +32 -48
  10. package/dist/additions/first-added.d.ts.map +1 -1
  11. package/dist/additions/first-added.js +68 -123
  12. package/dist/additions/first-added.js.map +1 -1
  13. package/dist/additions/index.d.ts +3 -0
  14. package/dist/additions/index.d.ts.map +1 -1
  15. package/dist/additions/index.js +3 -0
  16. package/dist/additions/index.js.map +1 -1
  17. package/dist/additions/ledger-store.js +1 -1
  18. package/dist/additions/record-rules.d.ts.map +1 -1
  19. package/dist/additions/record-rules.js +7 -0
  20. package/dist/additions/record-rules.js.map +1 -1
  21. package/dist/additions/summary.d.ts +88 -1
  22. package/dist/additions/summary.d.ts.map +1 -1
  23. package/dist/additions/summary.js +173 -8
  24. package/dist/additions/summary.js.map +1 -1
  25. package/dist/additions/version-inventory.d.ts +80 -0
  26. package/dist/additions/version-inventory.d.ts.map +1 -0
  27. package/dist/additions/version-inventory.js +232 -0
  28. package/dist/additions/version-inventory.js.map +1 -0
  29. package/dist/api/index.d.ts +70 -2
  30. package/dist/api/index.d.ts.map +1 -1
  31. package/dist/api/index.js +506 -79
  32. package/dist/api/index.js.map +1 -1
  33. package/dist/auth/index.d.ts +1 -1
  34. package/dist/auth/index.d.ts.map +1 -1
  35. package/dist/auth/index.js +1 -1
  36. package/dist/auth/index.js.map +1 -1
  37. package/dist/auth/request.d.ts +6 -0
  38. package/dist/auth/request.d.ts.map +1 -1
  39. package/dist/auth/request.js +66 -4
  40. package/dist/auth/request.js.map +1 -1
  41. package/dist/contracts/data.d.ts +54 -8
  42. package/dist/contracts/data.d.ts.map +1 -1
  43. package/dist/contracts/data.js +178 -35
  44. package/dist/contracts/data.js.map +1 -1
  45. package/dist/contracts/index.d.ts +1 -1
  46. package/dist/contracts/index.d.ts.map +1 -1
  47. package/dist/derivatives/registration.d.ts +0 -5
  48. package/dist/derivatives/registration.d.ts.map +1 -1
  49. package/dist/derivatives/registration.js +2 -1
  50. package/dist/derivatives/registration.js.map +1 -1
  51. package/dist/errors/pdpp-catalog.d.ts +36 -0
  52. package/dist/errors/pdpp-catalog.d.ts.map +1 -0
  53. package/dist/errors/pdpp-catalog.js +86 -0
  54. package/dist/errors/pdpp-catalog.js.map +1 -0
  55. package/dist/grants/index.d.ts +2 -0
  56. package/dist/grants/index.d.ts.map +1 -1
  57. package/dist/grants/index.js +4 -0
  58. package/dist/grants/index.js.map +1 -1
  59. package/dist/grants/pdpp-binding-store.d.ts +89 -0
  60. package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
  61. package/dist/grants/pdpp-binding-store.js +112 -0
  62. package/dist/grants/pdpp-binding-store.js.map +1 -0
  63. package/dist/grants/pdpp-binding.d.ts +169 -0
  64. package/dist/grants/pdpp-binding.d.ts.map +1 -0
  65. package/dist/grants/pdpp-binding.js +236 -0
  66. package/dist/grants/pdpp-binding.js.map +1 -0
  67. package/dist/legacy-projection/bindings.d.ts +28 -1
  68. package/dist/legacy-projection/bindings.d.ts.map +1 -1
  69. package/dist/legacy-projection/bindings.js +622 -189
  70. package/dist/legacy-projection/bindings.js.map +1 -1
  71. package/dist/legacy-projection/claude-source-record.d.ts +22 -0
  72. package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
  73. package/dist/legacy-projection/claude-source-record.js +360 -0
  74. package/dist/legacy-projection/claude-source-record.js.map +1 -0
  75. package/dist/legacy-projection/declared-text.d.ts +41 -0
  76. package/dist/legacy-projection/declared-text.d.ts.map +1 -0
  77. package/dist/legacy-projection/declared-text.js +199 -0
  78. package/dist/legacy-projection/declared-text.js.map +1 -0
  79. package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -1
  80. package/dist/legacy-projection/github-browser-bindings.js +89 -5
  81. package/dist/legacy-projection/github-browser-bindings.js.map +1 -1
  82. package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
  83. package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
  84. package/dist/legacy-projection/github-legacy-fields.js +202 -0
  85. package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
  86. package/dist/legacy-projection/index.d.ts +3 -1
  87. package/dist/legacy-projection/index.d.ts.map +1 -1
  88. package/dist/legacy-projection/index.js +49 -1
  89. package/dist/legacy-projection/index.js.map +1 -1
  90. package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -1
  91. package/dist/legacy-projection/oura-browser-bindings.js +43 -41
  92. package/dist/legacy-projection/oura-browser-bindings.js.map +1 -1
  93. package/dist/legacy-projection/types.d.ts +38 -2
  94. package/dist/legacy-projection/types.d.ts.map +1 -1
  95. package/dist/mcp/resources.d.ts.map +1 -1
  96. package/dist/mcp/resources.js +3 -0
  97. package/dist/mcp/resources.js.map +1 -1
  98. package/dist/mcp/tools.d.ts.map +1 -1
  99. package/dist/mcp/tools.js +11 -2
  100. package/dist/mcp/tools.js.map +1 -1
  101. package/dist/pdpp/approval.d.ts +271 -0
  102. package/dist/pdpp/approval.d.ts.map +1 -0
  103. package/dist/pdpp/approval.js +467 -0
  104. package/dist/pdpp/approval.js.map +1 -0
  105. package/dist/pdpp/client-identity.d.ts +88 -0
  106. package/dist/pdpp/client-identity.d.ts.map +1 -0
  107. package/dist/pdpp/client-identity.js +196 -0
  108. package/dist/pdpp/client-identity.js.map +1 -0
  109. package/dist/pdpp/client-metadata.d.ts +95 -0
  110. package/dist/pdpp/client-metadata.d.ts.map +1 -0
  111. package/dist/pdpp/client-metadata.js +96 -0
  112. package/dist/pdpp/client-metadata.js.map +1 -0
  113. package/dist/pdpp/commitments.d.ts +75 -0
  114. package/dist/pdpp/commitments.d.ts.map +1 -0
  115. package/dist/pdpp/commitments.js +113 -0
  116. package/dist/pdpp/commitments.js.map +1 -0
  117. package/dist/pdpp/declaration.d.ts +118 -0
  118. package/dist/pdpp/declaration.d.ts.map +1 -0
  119. package/dist/pdpp/declaration.js +836 -0
  120. package/dist/pdpp/declaration.js.map +1 -0
  121. package/dist/pdpp/index.d.ts +37 -0
  122. package/dist/pdpp/index.d.ts.map +1 -0
  123. package/dist/pdpp/index.js +23 -0
  124. package/dist/pdpp/index.js.map +1 -0
  125. package/dist/pdpp/issuance.d.ts +126 -0
  126. package/dist/pdpp/issuance.d.ts.map +1 -0
  127. package/dist/pdpp/issuance.js +180 -0
  128. package/dist/pdpp/issuance.js.map +1 -0
  129. package/dist/pdpp/pkce.d.ts +53 -0
  130. package/dist/pdpp/pkce.d.ts.map +1 -0
  131. package/dist/pdpp/pkce.js +109 -0
  132. package/dist/pdpp/pkce.js.map +1 -0
  133. package/dist/pdpp/redirect.d.ts +60 -0
  134. package/dist/pdpp/redirect.d.ts.map +1 -0
  135. package/dist/pdpp/redirect.js +125 -0
  136. package/dist/pdpp/redirect.js.map +1 -0
  137. package/dist/pdpp/resolve.d.ts +109 -0
  138. package/dist/pdpp/resolve.d.ts.map +1 -0
  139. package/dist/pdpp/resolve.js +393 -0
  140. package/dist/pdpp/resolve.js.map +1 -0
  141. package/dist/pdpp/review.d.ts +280 -0
  142. package/dist/pdpp/review.d.ts.map +1 -0
  143. package/dist/pdpp/review.js +205 -0
  144. package/dist/pdpp/review.js.map +1 -0
  145. package/dist/pdpp/selection.d.ts +50 -0
  146. package/dist/pdpp/selection.d.ts.map +1 -0
  147. package/dist/pdpp/selection.js +442 -0
  148. package/dist/pdpp/selection.js.map +1 -0
  149. package/dist/pdpp/store.d.ts +228 -0
  150. package/dist/pdpp/store.d.ts.map +1 -0
  151. package/dist/pdpp/store.js +542 -0
  152. package/dist/pdpp/store.js.map +1 -0
  153. package/dist/pdpp/tokens.d.ts +181 -0
  154. package/dist/pdpp/tokens.d.ts.map +1 -0
  155. package/dist/pdpp/tokens.js +419 -0
  156. package/dist/pdpp/tokens.js.map +1 -0
  157. package/dist/pdpp/types.d.ts +441 -0
  158. package/dist/pdpp/types.d.ts.map +1 -0
  159. package/dist/pdpp/types.js +61 -0
  160. package/dist/pdpp/types.js.map +1 -0
  161. package/dist/pdpp-version.d.ts +28 -0
  162. package/dist/pdpp-version.d.ts.map +1 -0
  163. package/dist/pdpp-version.js +28 -0
  164. package/dist/pdpp-version.js.map +1 -0
  165. package/dist/policy/data-read.d.ts +24 -0
  166. package/dist/policy/data-read.d.ts.map +1 -1
  167. package/dist/policy/data-read.js +60 -3
  168. package/dist/policy/data-read.js.map +1 -1
  169. package/dist/policy/data-write.d.ts.map +1 -1
  170. package/dist/policy/data-write.js +3 -0
  171. package/dist/policy/data-write.js.map +1 -1
  172. package/dist/policy/index.d.ts +1 -0
  173. package/dist/policy/index.d.ts.map +1 -1
  174. package/dist/policy/index.js +1 -0
  175. package/dist/policy/index.js.map +1 -1
  176. package/dist/policy/reserved-scopes.d.ts +3 -0
  177. package/dist/policy/reserved-scopes.d.ts.map +1 -0
  178. package/dist/policy/reserved-scopes.js +5 -0
  179. package/dist/policy/reserved-scopes.js.map +1 -0
  180. package/dist/ports/index.d.ts +63 -0
  181. package/dist/ports/index.d.ts.map +1 -1
  182. package/dist/ports/index.js.map +1 -1
  183. package/dist/ports/pdpp-auth.d.ts +129 -0
  184. package/dist/ports/pdpp-auth.d.ts.map +1 -0
  185. package/dist/ports/pdpp-auth.js +60 -0
  186. package/dist/ports/pdpp-auth.js.map +1 -0
  187. package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
  188. package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
  189. package/dist/ports/pdpp-auth.test-utils.js +18 -0
  190. package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
  191. package/dist/schemas/server-config.d.ts +44 -0
  192. package/dist/schemas/server-config.d.ts.map +1 -1
  193. package/dist/schemas/server-config.js +91 -0
  194. package/dist/schemas/server-config.js.map +1 -1
  195. package/dist/signing/request-signer.d.ts +2 -0
  196. package/dist/signing/request-signer.d.ts.map +1 -1
  197. package/dist/signing/request-signer.js +1 -0
  198. package/dist/signing/request-signer.js.map +1 -1
  199. package/dist/storage/adapters/interface.d.ts +3 -0
  200. package/dist/storage/adapters/interface.d.ts.map +1 -1
  201. package/dist/storage/adapters/vana-audience.d.ts +12 -0
  202. package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
  203. package/dist/storage/adapters/vana-audience.js +72 -0
  204. package/dist/storage/adapters/vana-audience.js.map +1 -0
  205. package/dist/storage/adapters/vana.d.ts +2 -0
  206. package/dist/storage/adapters/vana.d.ts.map +1 -1
  207. package/dist/storage/adapters/vana.js +53 -20
  208. package/dist/storage/adapters/vana.js.map +1 -1
  209. package/dist/storage/canonical-legacy-projection.d.ts +262 -0
  210. package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
  211. package/dist/storage/canonical-legacy-projection.js +761 -0
  212. package/dist/storage/canonical-legacy-projection.js.map +1 -0
  213. package/dist/storage/index/manager.d.ts +29 -2
  214. package/dist/storage/index/manager.d.ts.map +1 -1
  215. package/dist/storage/index/schema.d.ts +1 -1
  216. package/dist/storage/index/schema.js +1 -1
  217. package/dist/storage/index/types.d.ts +7 -1
  218. package/dist/storage/index/types.d.ts.map +1 -1
  219. package/dist/storage/legacy-projection.d.ts +4 -3
  220. package/dist/storage/legacy-projection.d.ts.map +1 -1
  221. package/dist/storage/legacy-projection.js +145 -42
  222. package/dist/storage/legacy-projection.js.map +1 -1
  223. package/dist/storage/legacy-scope-coverage-exceptions.d.ts +8 -0
  224. package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
  225. package/dist/storage/legacy-scope-coverage-exceptions.js +10 -0
  226. package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
  227. package/dist/storage/legacy-scope-coverage.d.ts +53 -0
  228. package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
  229. package/dist/storage/legacy-scope-coverage.js +403 -0
  230. package/dist/storage/legacy-scope-coverage.js.map +1 -0
  231. package/dist/storage/legacy-scope-entity-keys.d.ts +4 -0
  232. package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
  233. package/dist/storage/legacy-scope-entity-keys.js +92 -0
  234. package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
  235. package/dist/storage/legacy-scope-view.d.ts +154 -0
  236. package/dist/storage/legacy-scope-view.d.ts.map +1 -0
  237. package/dist/storage/legacy-scope-view.js +735 -0
  238. package/dist/storage/legacy-scope-view.js.map +1 -0
  239. package/dist/storage/pdpp-records/completion.d.ts +91 -0
  240. package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
  241. package/dist/storage/pdpp-records/completion.js +170 -0
  242. package/dist/storage/pdpp-records/completion.js.map +1 -0
  243. package/dist/storage/pdpp-records/cursor.d.ts +41 -0
  244. package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
  245. package/dist/storage/pdpp-records/cursor.js +49 -0
  246. package/dist/storage/pdpp-records/cursor.js.map +1 -0
  247. package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
  248. package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
  249. package/dist/storage/pdpp-records/declaration-witness.js +230 -0
  250. package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
  251. package/dist/storage/pdpp-records/enforcement.d.ts +52 -0
  252. package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
  253. package/dist/storage/pdpp-records/enforcement.js +116 -0
  254. package/dist/storage/pdpp-records/enforcement.js.map +1 -0
  255. package/dist/storage/pdpp-records/index.d.ts +5 -0
  256. package/dist/storage/pdpp-records/index.d.ts.map +1 -0
  257. package/dist/storage/pdpp-records/index.js +5 -0
  258. package/dist/storage/pdpp-records/index.js.map +1 -0
  259. package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
  260. package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
  261. package/dist/storage/pdpp-records/ingest-plan.js +103 -0
  262. package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
  263. package/dist/storage/pdpp-records/interface.d.ts +104 -0
  264. package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
  265. package/dist/storage/pdpp-records/interface.js +2 -0
  266. package/dist/storage/pdpp-records/interface.js.map +1 -0
  267. package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
  268. package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
  269. package/dist/storage/pdpp-records/memory-store.js +466 -0
  270. package/dist/storage/pdpp-records/memory-store.js.map +1 -0
  271. package/dist/storage/pdpp-records/portable.d.ts +9 -0
  272. package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
  273. package/dist/storage/pdpp-records/portable.js +8 -0
  274. package/dist/storage/pdpp-records/portable.js.map +1 -0
  275. package/dist/storage/pdpp-records/read-port.d.ts +44 -0
  276. package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
  277. package/dist/storage/pdpp-records/read-port.js +22 -0
  278. package/dist/storage/pdpp-records/read-port.js.map +1 -0
  279. package/dist/storage/pdpp-records/record-key.d.ts +52 -0
  280. package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
  281. package/dist/storage/pdpp-records/record-key.js +97 -0
  282. package/dist/storage/pdpp-records/record-key.js.map +1 -0
  283. package/dist/storage/pdpp-records/schema.d.ts +41 -0
  284. package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
  285. package/dist/storage/pdpp-records/schema.js +153 -0
  286. package/dist/storage/pdpp-records/schema.js.map +1 -0
  287. package/dist/storage/pdpp-records/stream-declaration.d.ts +88 -0
  288. package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
  289. package/dist/storage/pdpp-records/stream-declaration.js +57 -0
  290. package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
  291. package/dist/storage/pdpp-records/types.d.ts +138 -0
  292. package/dist/storage/pdpp-records/types.d.ts.map +1 -0
  293. package/dist/storage/pdpp-records/types.js +38 -0
  294. package/dist/storage/pdpp-records/types.js.map +1 -0
  295. package/dist/sync/data-point-feed.d.ts +3 -0
  296. package/dist/sync/data-point-feed.d.ts.map +1 -1
  297. package/dist/sync/data-point-feed.js +17 -1
  298. package/dist/sync/data-point-feed.js.map +1 -1
  299. package/dist/sync/delete-data-port.d.ts +2 -0
  300. package/dist/sync/delete-data-port.d.ts.map +1 -1
  301. package/dist/sync/delete-data-port.js +1 -1
  302. package/dist/sync/delete-data-port.js.map +1 -1
  303. package/dist/sync/engine/sync-manager.d.ts.map +1 -1
  304. package/dist/sync/engine/sync-manager.js +5 -2
  305. package/dist/sync/engine/sync-manager.js.map +1 -1
  306. package/dist/sync/index.d.ts +3 -1
  307. package/dist/sync/index.d.ts.map +1 -1
  308. package/dist/sync/index.js +4 -0
  309. package/dist/sync/index.js.map +1 -1
  310. package/dist/sync/pdpp-import.d.ts +192 -0
  311. package/dist/sync/pdpp-import.d.ts.map +1 -0
  312. package/dist/sync/pdpp-import.js +441 -0
  313. package/dist/sync/pdpp-import.js.map +1 -0
  314. package/dist/sync/scope-deletions.d.ts +10 -0
  315. package/dist/sync/scope-deletions.d.ts.map +1 -1
  316. package/dist/sync/scope-deletions.js +40 -7
  317. package/dist/sync/scope-deletions.js.map +1 -1
  318. package/dist/sync/workers/download.d.ts +14 -0
  319. package/dist/sync/workers/download.d.ts.map +1 -1
  320. package/dist/sync/workers/download.js +149 -13
  321. package/dist/sync/workers/download.js.map +1 -1
  322. package/dist/sync/workers/upload.d.ts +2 -0
  323. package/dist/sync/workers/upload.d.ts.map +1 -1
  324. package/dist/sync/workers/upload.js +7 -0
  325. package/dist/sync/workers/upload.js.map +1 -1
  326. package/dist/test-utils/memory-storage.d.ts +1 -1
  327. package/dist/test-utils/memory-storage.d.ts.map +1 -1
  328. package/dist/test-utils/memory-storage.js +11 -5
  329. package/dist/test-utils/memory-storage.js.map +1 -1
  330. package/package.json +54 -4
@@ -0,0 +1,393 @@
1
+ /**
2
+ * PDPP Core §6→§7 resolution: turn a validated selection request into the
3
+ * explicit grant facts that get frozen at issuance.
4
+ *
5
+ * Every request-only convenience dies here. Wildcards and presets expand to
6
+ * concrete stream rows, views resolve to field lists, omitted fields become
7
+ * the declaration's full field set, omitted instance handles resolve against
8
+ * the owner's connection inventory, and `time_range` freezes against the
9
+ * declaration's `consent_time_field`. §7 is explicit that none of these
10
+ * conveniences are continuing authority in the grant — the RS must never have
11
+ * to resolve anything, which is also what the AS→RS contract promises.
12
+ *
13
+ * Resolution runs against the same retained snapshot `selection.ts` validated
14
+ * against. Passing a newer declaration here is the bug §9 AS item 16 exists to
15
+ * prevent: it would let a later declaration widen an in-flight authorization.
16
+ */
17
+ import { PDPP_DATA_ACCESS_TYPE_V02, } from "./types.js";
18
+ function failure(code, message, extra) {
19
+ return { ok: false, failure: { code, message, ...extra } };
20
+ }
21
+ /** Stable de-duplication. Grant field and instance lists must be unique (§7). */
22
+ function unique(values) {
23
+ return Array.from(new Set(values));
24
+ }
25
+ /**
26
+ * The requested field ceiling for one stream, before owner choices.
27
+ *
28
+ * Under v0.1 the declaration's `required_fields` are unioned in: §6 called
29
+ * them the per-stream consent floor, so a client asking for fewer fields got
30
+ * the floor rather than an error.
31
+ *
32
+ * Under v0.2 that union is gone. PR #1 changes the rule deliberately: the
33
+ * record format describes a complete record, while the owner's approval
34
+ * determines which fields the app receives. A schema can require a field of
35
+ * every valid record and the owner can still withhold it, and the RS must not
36
+ * add it back. Keeping the union here would make the whole withholding
37
+ * guarantee unreachable — the AS would re-add the field before the owner ever
38
+ * saw a choice about it.
39
+ */
40
+ function requestedFields(request, declared, snapshot, revision) {
41
+ let requested;
42
+ if (request.view !== undefined) {
43
+ const view = snapshot.views?.find((v) => v.name === request.view);
44
+ if (!view) {
45
+ return {
46
+ ok: false,
47
+ failure: {
48
+ code: "unknown_view",
49
+ message: `view '${request.view}' is not defined for this source`,
50
+ stream: declared.name,
51
+ },
52
+ };
53
+ }
54
+ requested = view.fields;
55
+ }
56
+ else if (request.fields !== undefined) {
57
+ requested = request.fields;
58
+ }
59
+ else {
60
+ // §6 "Note on defaults": omitting both asks the AS to resolve all
61
+ // permitted fields from the retained snapshot.
62
+ requested = declared.fields;
63
+ }
64
+ // Intersect with the declared schema first, so a view or allowlist can
65
+ // never introduce a field the snapshot does not define.
66
+ const permitted = requested.filter((f) => declared.fields.includes(f));
67
+ const fields = revision === "0.1"
68
+ ? unique([...permitted, ...declared.required_fields])
69
+ : unique(permitted);
70
+ if (fields.length === 0) {
71
+ return {
72
+ ok: false,
73
+ failure: {
74
+ code: "empty_field_set",
75
+ message: `stream '${declared.name}' resolved to an empty field set`,
76
+ stream: declared.name,
77
+ },
78
+ };
79
+ }
80
+ return { ok: true, fields };
81
+ }
82
+ /**
83
+ * Apply the owner's field narrowing by intersection with the ceiling.
84
+ *
85
+ * Intersection rather than replacement is the security property: a choice
86
+ * naming a field the request never asked for cannot add it. An *absent*
87
+ * choice means "no narrowing", which is different from an empty one — an
88
+ * empty choice is a real decision to share nothing from this stream, and
89
+ * silently reading it as "all fields" would invert it.
90
+ */
91
+ function narrowFields(ceiling, chosen) {
92
+ if (chosen === undefined)
93
+ return ceiling;
94
+ return ceiling.filter((f) => chosen.includes(f));
95
+ }
96
+ /** Instant for a bound, with an absent bound reading as the open end. */
97
+ function instant(value, open) {
98
+ return value === undefined ? open : Date.parse(value);
99
+ }
100
+ /**
101
+ * Clamp the owner's window into the requested window.
102
+ *
103
+ * The result is the intersection, so the later `since` and the earlier
104
+ * `until` win. An owner asking for more history than the client requested
105
+ * gets the client's limit, not their own ask.
106
+ */
107
+ function narrowTimeRange(ceiling, chosen) {
108
+ if (chosen === undefined)
109
+ return ceiling;
110
+ const since = [ceiling?.since, chosen.since]
111
+ .filter((v) => v !== undefined)
112
+ .sort((a, b) => Date.parse(b) - Date.parse(a))[0];
113
+ const until = [ceiling?.until, chosen.until]
114
+ .filter((v) => v !== undefined)
115
+ .sort((a, b) => Date.parse(a) - Date.parse(b))[0];
116
+ if (since === undefined && until === undefined)
117
+ return undefined;
118
+ return {
119
+ ...(since !== undefined && { since }),
120
+ ...(until !== undefined && { until }),
121
+ };
122
+ }
123
+ /**
124
+ * Whether one stream's resolved shape satisfies its explicit minimum.
125
+ *
126
+ * This answers a permission question and nothing else. A satisfied minimum
127
+ * says the grant *permits* those fields and that window; v0.2 is explicit
128
+ * that it asserts nothing about record existence, freshness, completeness, or
129
+ * suitability, and that the AS must not require records to exist to satisfy
130
+ * one. So this function never touches a record.
131
+ */
132
+ function minimumSatisfied(minimum, fields, window) {
133
+ if (!minimum)
134
+ return { ok: true };
135
+ if (minimum.fields) {
136
+ const missing = minimum.fields.filter((f) => !fields.includes(f));
137
+ if (missing.length > 0) {
138
+ return {
139
+ ok: false,
140
+ reason: `the approved fields omit the required minimum field(s) ${missing.join(", ")}`,
141
+ };
142
+ }
143
+ }
144
+ if (minimum.time_range) {
145
+ // The resolved window must *contain* the entire minimum window. An absent
146
+ // resolved lower bound is negative infinity and an absent upper bound is
147
+ // positive infinity, so an unbounded window contains every floor.
148
+ const from = instant(window?.since, -Infinity);
149
+ const to = instant(window?.until, Infinity);
150
+ if (Date.parse(minimum.time_range.since) < from ||
151
+ Date.parse(minimum.time_range.until) > to) {
152
+ return {
153
+ ok: false,
154
+ reason: "the approved time window does not contain the required minimum window",
155
+ };
156
+ }
157
+ }
158
+ return { ok: true };
159
+ }
160
+ /**
161
+ * Resolve instance handles for one stream.
162
+ *
163
+ * Three outcomes, per §6 and §7: explicit handles are verified for
164
+ * eligibility; a single eligible handle resolves automatically; anything else
165
+ * is an owner choice the AS must surface before the final approval surface.
166
+ */
167
+ function resolveInstances(request, streamName, inventory) {
168
+ const eligible = inventory.eligibleFor(streamName);
169
+ if (request.instance_ids !== undefined && request.instance_ids.length > 0) {
170
+ const ineligible = request.instance_ids.filter((id) => !eligible.includes(id));
171
+ if (ineligible.length > 0) {
172
+ return {
173
+ ok: false,
174
+ failure: {
175
+ code: "unknown_instance",
176
+ message: `stream '${streamName}' requests instance handles that are not eligible: ${ineligible.join(", ")}`,
177
+ stream: streamName,
178
+ },
179
+ };
180
+ }
181
+ // Explicitly listing more than one handle is how a client asks for
182
+ // fan-in, and it is allowed precisely because it is explicit.
183
+ return { ok: true, instanceIds: unique(request.instance_ids) };
184
+ }
185
+ if (eligible.length === 0) {
186
+ return {
187
+ ok: false,
188
+ failure: {
189
+ code: "no_eligible_instance",
190
+ message: `stream '${streamName}' has no connected instance to authorize`,
191
+ stream: streamName,
192
+ },
193
+ };
194
+ }
195
+ if (eligible.length > 1) {
196
+ // Omission never means fan-in. The owner picks.
197
+ return {
198
+ ok: false,
199
+ failure: {
200
+ code: "instance_choice_required",
201
+ message: `stream '${streamName}' has ${eligible.length} eligible instances and the request named none`,
202
+ stream: streamName,
203
+ candidates: eligible,
204
+ },
205
+ };
206
+ }
207
+ return { ok: true, instanceIds: [eligible[0]] };
208
+ }
209
+ /**
210
+ * Freeze `time_range` into the grant's `time_constraint`, binding the
211
+ * declaration's `consent_time_field` as the field the RS evaluates against.
212
+ * Freezing the field name (not just the bounds) is what stops a later
213
+ * declaration that renames its time field from silently re-scoping the grant.
214
+ */
215
+ function resolveTimeConstraint(window, declared) {
216
+ if (!window)
217
+ return undefined;
218
+ const { since, until } = window;
219
+ if (since === undefined && until === undefined)
220
+ return undefined;
221
+ // Validation already rejected time_range on a stream with no time field.
222
+ const field = declared.consent_time_field;
223
+ if (!field)
224
+ return undefined;
225
+ return {
226
+ field,
227
+ ...(since !== undefined && { since }),
228
+ ...(until !== undefined && { until }),
229
+ };
230
+ }
231
+ function resolveOneStream(request, declared, snapshot, inventory, revision, choices) {
232
+ const ceiling = requestedFields(request, declared, snapshot, revision);
233
+ if (!ceiling.ok)
234
+ return { kind: "failed", failure: ceiling.failure };
235
+ // v0.1 has no narrowing step, so its resolution is untouched by choices.
236
+ const fields = revision === "0.2"
237
+ ? narrowFields(ceiling.fields, choices?.fields?.[declared.name])
238
+ : ceiling.fields;
239
+ if (fields.length === 0) {
240
+ // The resolved selection must contain at least one field per retained
241
+ // stream, so an owner who narrowed everything away has refused the
242
+ // stream, not asked for all of it.
243
+ return {
244
+ kind: "failed",
245
+ failure: {
246
+ code: "empty_field_set",
247
+ message: `stream '${declared.name}' resolved to an empty field set`,
248
+ stream: declared.name,
249
+ },
250
+ };
251
+ }
252
+ const window = revision === "0.2"
253
+ ? narrowTimeRange(request.time_range, choices?.time_ranges?.[declared.name])
254
+ : request.time_range;
255
+ if (revision === "0.2") {
256
+ // Checked before instance resolution: an unsatisfiable minimum is a
257
+ // decision about this stream that does not depend on which handle serves
258
+ // it, and an optional stream that is about to drop out should not fail
259
+ // the whole authorization on a missing instance it will never use.
260
+ const satisfied = minimumSatisfied(request.minimum, fields, window);
261
+ if (!satisfied.ok) {
262
+ return { kind: "minimum_unmet", reason: satisfied.reason };
263
+ }
264
+ }
265
+ const instances = resolveInstances(request, declared.name, inventory);
266
+ if (!instances.ok)
267
+ return { kind: "failed", failure: instances.failure };
268
+ const timeConstraint = resolveTimeConstraint(window, declared);
269
+ return {
270
+ kind: "resolved",
271
+ stream: {
272
+ name: declared.name,
273
+ instance_ids: instances.instanceIds,
274
+ fields,
275
+ ...(timeConstraint && { time_constraint: timeConstraint }),
276
+ ...(request.resources && { resources: unique(request.resources) }),
277
+ },
278
+ };
279
+ }
280
+ /**
281
+ * Expand the request's stream selections into the concrete list to resolve.
282
+ *
283
+ * A wildcard entry fans out to every declared stream, carrying its own
284
+ * per-stream parameters with it — §6 says a wildcard's `instance_ids` apply to
285
+ * every expanded stream, and each handle is then verified per stream by
286
+ * `resolveInstances`. A preset expands from the snapshot instead.
287
+ *
288
+ * Exported because the consent surface must expand a request the same way
289
+ * resolution does. `approval.ts` collects the owner's pending instance
290
+ * choices over these expanded streams; when it derived its own list from
291
+ * `request.streams` alone, a `selection_preset` expanded to nothing there and
292
+ * to two eligible instances here, so the owner was never asked and the
293
+ * request died as unresolvable. One expansion, two readers.
294
+ */
295
+ export function expandSelections(request, snapshot) {
296
+ if (request.selection_preset !== undefined) {
297
+ const preset = snapshot.selection_presets?.find((p) => p.name === request.selection_preset);
298
+ return preset ? preset.streams : [];
299
+ }
300
+ const streams = request.streams ?? [];
301
+ const wildcard = streams.find((s) => s.name === "*");
302
+ if (wildcard) {
303
+ return snapshot.streams.map((declared) => ({
304
+ ...wildcard,
305
+ name: declared.name,
306
+ // A wildcard cannot carry a view (validation rejects that pairing), and
307
+ // its time_range only applies to streams that can accept one. Dropping
308
+ // it for time-incapable streams is what makes `{"name":"*"}` with a
309
+ // time_range usable on a mixed-capability source at all.
310
+ ...(wildcard.time_range && !declared.consent_time_field
311
+ ? { time_range: undefined }
312
+ : {}),
313
+ }));
314
+ }
315
+ return streams;
316
+ }
317
+ /**
318
+ * Resolve every enforcement axis for a validated selection request.
319
+ *
320
+ * Call this before showing the final approval surface: §7 requires the
321
+ * approval artifact to contain the exact resolved instance handles, stream
322
+ * names, fields, resources, and temporal bounds, which only exist once this
323
+ * has run.
324
+ */
325
+ export function resolveSelection(request, snapshot, inventory, choices) {
326
+ const revision = request.type === PDPP_DATA_ACCESS_TYPE_V02 ? "0.2" : "0.1";
327
+ const selections = expandSelections(request, snapshot);
328
+ if (selections.length === 0) {
329
+ return failure("unknown_stream", "the selection resolved to no streams against the retained snapshot");
330
+ }
331
+ const resolved = [];
332
+ const omitted = [];
333
+ const requestedStreams = [];
334
+ for (const selection of selections) {
335
+ const declared = snapshot.streams.find((s) => s.name === selection.name);
336
+ if (!declared) {
337
+ return failure("unknown_stream", `stream '${selection.name}' is not declared by the retained snapshot`, { stream: selection.name });
338
+ }
339
+ // `necessity` defaults to `required`, so an unmarked stream is one the AS
340
+ // must retain or refuse. Inferring "optional" from omission would let a
341
+ // client's silence become the owner's permission to drop a stream the
342
+ // client actually depends on.
343
+ const necessity = selection.necessity ?? "required";
344
+ if (revision === "0.2") {
345
+ const ceiling = requestedFields(selection, declared, snapshot, "0.2");
346
+ requestedStreams.push({
347
+ name: declared.name,
348
+ necessity,
349
+ fields: ceiling.ok ? ceiling.fields : [],
350
+ ...(selection.time_range && { time_range: selection.time_range }),
351
+ ...(selection.minimum && { minimum: selection.minimum }),
352
+ });
353
+ if (choices?.declined_streams?.includes(declared.name)) {
354
+ if (necessity === "required") {
355
+ // A required stream is retained or the authorization is refused.
356
+ // There is no third outcome, and in particular no weaker grant.
357
+ return failure("required_stream_declined", `stream '${declared.name}' is required by the request and cannot be declined`, { stream: declared.name });
358
+ }
359
+ omitted.push(declared.name);
360
+ continue;
361
+ }
362
+ }
363
+ const outcome = resolveOneStream(selection, declared, snapshot, inventory, revision, choices);
364
+ if (outcome.kind === "failed") {
365
+ return { ok: false, failure: outcome.failure };
366
+ }
367
+ if (outcome.kind === "minimum_unmet") {
368
+ if (necessity === "required") {
369
+ // Refuse issuance rather than issue a weaker grant for this stream.
370
+ // The OAuth binding reports this as `access_denied`: the request was
371
+ // well-formed and the owner decided: the two are simply incompatible.
372
+ return failure("minimum_not_met", `stream '${declared.name}' is required and ${outcome.reason}`, { stream: declared.name });
373
+ }
374
+ // For an optional stream, failing its minimum permits omission of the
375
+ // whole stream — never a retained stream with a weaker projection.
376
+ omitted.push(declared.name);
377
+ continue;
378
+ }
379
+ resolved.push(outcome.stream);
380
+ }
381
+ if (resolved.length === 0) {
382
+ // No empty grants, and nothing added to compensate for a refused
383
+ // selection. A different proposal needs a new authorization request.
384
+ return failure("no_streams_approved", "the owner approved no streams; a grant with no authorized stream cannot be issued");
385
+ }
386
+ return {
387
+ ok: true,
388
+ streams: resolved,
389
+ ...(omitted.length > 0 && { omittedStreams: omitted }),
390
+ ...(revision === "0.2" && { requestedStreams }),
391
+ };
392
+ }
393
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/pdpp/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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