@opendatalabs/personal-server-ts-server 1.33.7 → 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 (167) hide show
  1. package/dist/__fixtures__/bound-record-store.d.ts +19 -0
  2. package/dist/__fixtures__/bound-record-store.d.ts.map +1 -0
  3. package/dist/__fixtures__/bound-record-store.js +60 -0
  4. package/dist/__fixtures__/bound-record-store.js.map +1 -0
  5. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.d.ts +41 -0
  6. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.d.ts.map +1 -0
  7. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.js +34 -0
  8. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.js.map +1 -0
  9. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.d.ts +112 -0
  10. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.d.ts.map +1 -0
  11. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.js +226 -0
  12. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.js.map +1 -0
  13. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.d.ts +135 -0
  14. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.d.ts.map +1 -0
  15. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.js +21 -0
  16. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.js.map +1 -0
  17. package/dist/api-auth.d.ts +18 -2
  18. package/dist/api-auth.d.ts.map +1 -1
  19. package/dist/api-auth.js +114 -22
  20. package/dist/api-auth.js.map +1 -1
  21. package/dist/app.d.ts +60 -1
  22. package/dist/app.d.ts.map +1 -1
  23. package/dist/app.js +139 -1
  24. package/dist/app.js.map +1 -1
  25. package/dist/bootstrap.d.ts +10 -0
  26. package/dist/bootstrap.d.ts.map +1 -1
  27. package/dist/bootstrap.js +358 -7
  28. package/dist/bootstrap.js.map +1 -1
  29. package/dist/enclave-main.d.ts +4 -0
  30. package/dist/enclave-main.d.ts.map +1 -1
  31. package/dist/enclave-main.js +152 -1
  32. package/dist/enclave-main.js.map +1 -1
  33. package/dist/middleware/body-limit.d.ts +1 -1
  34. package/dist/middleware/body-limit.d.ts.map +1 -1
  35. package/dist/middleware/body-limit.js +8 -3
  36. package/dist/middleware/body-limit.js.map +1 -1
  37. package/dist/middleware/cors.d.ts.map +1 -1
  38. package/dist/middleware/cors.js +1 -0
  39. package/dist/middleware/cors.js.map +1 -1
  40. package/dist/package.json +9 -1
  41. package/dist/pdpp/bootstrap.d.ts +72 -0
  42. package/dist/pdpp/bootstrap.d.ts.map +1 -0
  43. package/dist/pdpp/bootstrap.js +270 -0
  44. package/dist/pdpp/bootstrap.js.map +1 -0
  45. package/dist/pdpp/chain-enforcement.d.ts +95 -0
  46. package/dist/pdpp/chain-enforcement.d.ts.map +1 -0
  47. package/dist/pdpp/chain-enforcement.js +145 -0
  48. package/dist/pdpp/chain-enforcement.js.map +1 -0
  49. package/dist/pdpp/client-document-fetch.d.ts +63 -0
  50. package/dist/pdpp/client-document-fetch.d.ts.map +1 -0
  51. package/dist/pdpp/client-document-fetch.js +254 -0
  52. package/dist/pdpp/client-document-fetch.js.map +1 -0
  53. package/dist/pdpp/declaration-registry.d.ts +83 -0
  54. package/dist/pdpp/declaration-registry.d.ts.map +1 -0
  55. package/dist/pdpp/declaration-registry.js +251 -0
  56. package/dist/pdpp/declaration-registry.js.map +1 -0
  57. package/dist/pdpp/deployment.d.ts +70 -0
  58. package/dist/pdpp/deployment.d.ts.map +1 -0
  59. package/dist/pdpp/deployment.js +104 -0
  60. package/dist/pdpp/deployment.js.map +1 -0
  61. package/dist/pdpp/record-schema.d.ts +2 -0
  62. package/dist/pdpp/record-schema.d.ts.map +1 -0
  63. package/dist/pdpp/record-schema.js +2 -0
  64. package/dist/pdpp/record-schema.js.map +1 -0
  65. package/dist/pdpp/records-bootstrap.d.ts +111 -0
  66. package/dist/pdpp/records-bootstrap.d.ts.map +1 -0
  67. package/dist/pdpp/records-bootstrap.js +353 -0
  68. package/dist/pdpp/records-bootstrap.js.map +1 -0
  69. package/dist/pdpp/source-id-compat.d.ts +5 -0
  70. package/dist/pdpp/source-id-compat.d.ts.map +1 -0
  71. package/dist/pdpp/source-id-compat.js +16 -0
  72. package/dist/pdpp/source-id-compat.js.map +1 -0
  73. package/dist/pdpp/test-connections.d.ts +6 -0
  74. package/dist/pdpp/test-connections.d.ts.map +1 -0
  75. package/dist/pdpp/test-connections.js +37 -0
  76. package/dist/pdpp/test-connections.js.map +1 -0
  77. package/dist/routes/auth-device.d.ts.map +1 -1
  78. package/dist/routes/auth-device.js +3 -0
  79. package/dist/routes/auth-device.js.map +1 -1
  80. package/dist/routes/chunked-scope-import.d.ts +41 -0
  81. package/dist/routes/chunked-scope-import.d.ts.map +1 -0
  82. package/dist/routes/chunked-scope-import.js +901 -0
  83. package/dist/routes/chunked-scope-import.js.map +1 -0
  84. package/dist/routes/data.d.ts +23 -1
  85. package/dist/routes/data.d.ts.map +1 -1
  86. package/dist/routes/data.js +112 -1
  87. package/dist/routes/data.js.map +1 -1
  88. package/dist/routes/grants.d.ts.map +1 -1
  89. package/dist/routes/grants.js +2 -0
  90. package/dist/routes/grants.js.map +1 -1
  91. package/dist/routes/mcp.d.ts.map +1 -1
  92. package/dist/routes/mcp.js +21 -12
  93. package/dist/routes/mcp.js.map +1 -1
  94. package/dist/routes/pdpp-auth.d.ts +157 -0
  95. package/dist/routes/pdpp-auth.d.ts.map +1 -0
  96. package/dist/routes/pdpp-auth.js +953 -0
  97. package/dist/routes/pdpp-auth.js.map +1 -0
  98. package/dist/routes/pdpp-blobs.d.ts +26 -0
  99. package/dist/routes/pdpp-blobs.d.ts.map +1 -0
  100. package/dist/routes/pdpp-blobs.js +179 -0
  101. package/dist/routes/pdpp-blobs.js.map +1 -0
  102. package/dist/routes/pdpp-connections.d.ts +28 -0
  103. package/dist/routes/pdpp-connections.d.ts.map +1 -0
  104. package/dist/routes/pdpp-connections.js +144 -0
  105. package/dist/routes/pdpp-connections.js.map +1 -0
  106. package/dist/routes/pdpp-declarations.d.ts +58 -0
  107. package/dist/routes/pdpp-declarations.d.ts.map +1 -0
  108. package/dist/routes/pdpp-declarations.js +94 -0
  109. package/dist/routes/pdpp-declarations.js.map +1 -0
  110. package/dist/routes/pdpp-instance-bindings.d.ts +26 -0
  111. package/dist/routes/pdpp-instance-bindings.d.ts.map +1 -0
  112. package/dist/routes/pdpp-instance-bindings.js +124 -0
  113. package/dist/routes/pdpp-instance-bindings.js.map +1 -0
  114. package/dist/routes/pdpp-records.d.ts +158 -0
  115. package/dist/routes/pdpp-records.d.ts.map +1 -0
  116. package/dist/routes/pdpp-records.js +1537 -0
  117. package/dist/routes/pdpp-records.js.map +1 -0
  118. package/dist/routes/pdpp-well-known.d.ts +13 -0
  119. package/dist/routes/pdpp-well-known.d.ts.map +1 -0
  120. package/dist/routes/pdpp-well-known.js +20 -0
  121. package/dist/routes/pdpp-well-known.js.map +1 -0
  122. package/dist/storage/declaration-witness.d.ts +56 -0
  123. package/dist/storage/declaration-witness.d.ts.map +1 -0
  124. package/dist/storage/declaration-witness.js +273 -0
  125. package/dist/storage/declaration-witness.js.map +1 -0
  126. package/dist/storage/hierarchy.d.ts +25 -1
  127. package/dist/storage/hierarchy.d.ts.map +1 -1
  128. package/dist/storage/hierarchy.js +210 -16
  129. package/dist/storage/hierarchy.js.map +1 -1
  130. package/dist/storage/import-operations.d.ts +11 -0
  131. package/dist/storage/import-operations.d.ts.map +1 -0
  132. package/dist/storage/import-operations.js +261 -0
  133. package/dist/storage/import-operations.js.map +1 -0
  134. package/dist/storage/index-manager.d.ts +24 -2
  135. package/dist/storage/index-manager.d.ts.map +1 -1
  136. package/dist/storage/index-manager.js +279 -30
  137. package/dist/storage/index-manager.js.map +1 -1
  138. package/dist/storage/index-schema.d.ts +1 -1
  139. package/dist/storage/index-schema.d.ts.map +1 -1
  140. package/dist/storage/index-schema.js +189 -8
  141. package/dist/storage/index-schema.js.map +1 -1
  142. package/dist/storage/legacy-scope-authority.d.ts +14 -0
  143. package/dist/storage/legacy-scope-authority.d.ts.map +1 -0
  144. package/dist/storage/legacy-scope-authority.js +298 -0
  145. package/dist/storage/legacy-scope-authority.js.map +1 -0
  146. package/dist/storage/node-data-storage.d.ts +6 -0
  147. package/dist/storage/node-data-storage.d.ts.map +1 -1
  148. package/dist/storage/node-data-storage.js +161 -2
  149. package/dist/storage/node-data-storage.js.map +1 -1
  150. package/dist/storage/pdpp-grant-binding-sqlite-store.d.ts +17 -0
  151. package/dist/storage/pdpp-grant-binding-sqlite-store.d.ts.map +1 -0
  152. package/dist/storage/pdpp-grant-binding-sqlite-store.js +159 -0
  153. package/dist/storage/pdpp-grant-binding-sqlite-store.js.map +1 -0
  154. package/dist/storage/pdpp-records-sqlite-store.d.ts +112 -0
  155. package/dist/storage/pdpp-records-sqlite-store.d.ts.map +1 -0
  156. package/dist/storage/pdpp-records-sqlite-store.js +1440 -0
  157. package/dist/storage/pdpp-records-sqlite-store.js.map +1 -0
  158. package/dist/storage/pdpp-stream-completion.d.ts +5 -0
  159. package/dist/storage/pdpp-stream-completion.d.ts.map +1 -0
  160. package/dist/storage/pdpp-stream-completion.js +10 -0
  161. package/dist/storage/pdpp-stream-completion.js.map +1 -0
  162. package/dist/storage/scope-deletion-history.d.ts +8 -0
  163. package/dist/storage/scope-deletion-history.d.ts.map +1 -0
  164. package/dist/storage/scope-deletion-history.js +40 -0
  165. package/dist/storage/scope-deletion-history.js.map +1 -0
  166. package/dist/ui/ps-lite-debug.js +3697 -876
  167. package/package.json +12 -4
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Deployment wiring for the PDPP Authorization Server.
3
+ *
4
+ * Two jobs the route module deliberately does not do, because both are
5
+ * deployment policy rather than protocol:
6
+ *
7
+ * 1. Decide which source declarations this server will accept as authority
8
+ * over a source. Core §5 requires an explicit trust policy; "we could
9
+ * reach it over HTTPS" is not one. The policy here is derived from what
10
+ * this PS actually serves, so a server that holds no Spotify data does
11
+ * not accept a Spotify declaration and cannot be talked into issuing a
12
+ * grant over data it has never collected.
13
+ *
14
+ * 2. Map a verified owner wallet to the PDPP subject. This PS is
15
+ * single-owner, so the subject is the server owner and nothing else.
16
+ *
17
+ * There is no trust-all default. A deployment that has configured no
18
+ * declarations accepts none, which makes `/pdpp/v1` inert rather than
19
+ * dangerous — the failure mode of a misconfigured authorization server should
20
+ * be "issues nothing", never "issues anything".
21
+ */
22
+ import type { DeclarationSnapshot } from "@opendatalabs/personal-server-ts-core/pdpp";
23
+ import type { Logger } from "pino";
24
+ /**
25
+ * The connector inventory this PS serves, derived from the scopes it actually
26
+ * holds. A scope is `{source}.{category}[.{subcategory}]`, so the leading
27
+ * segment is the connector.
28
+ */
29
+ export declare function deriveSupportedConnectors(scopes: string[]): string[];
30
+ /**
31
+ * A declaration this deployment retains, as configured.
32
+ *
33
+ * `document` is the exact retained bytes. Keeping the raw document (rather
34
+ * than a parsed object) is what lets the digest be computed over what was
35
+ * actually retrieved, which is the evidence §9 item 16 requires to survive
36
+ * into consent and issuance.
37
+ */
38
+ export interface ConfiguredDeclaration {
39
+ sourceId: string;
40
+ document: string;
41
+ path?: string;
42
+ }
43
+ export interface PdppDeclarationRegistryOptions {
44
+ /** Declarations this deployment has explicitly retained. */
45
+ declarations: ConfiguredDeclaration[];
46
+ /** Connector inventory; a declaration for an unserved source is rejected. */
47
+ supportedConnectors: string[];
48
+ logger: Logger;
49
+ }
50
+ /**
51
+ * Build the `resolveDeclaration` lookup the AS routes consume.
52
+ *
53
+ * Every configured declaration is validated and digested once at startup, then
54
+ * pinned. A declaration that fails validation is dropped with a warning rather
55
+ * than accepted-and-hoped-for: an AS resolving grants against a malformed
56
+ * declaration would freeze nonsense into an immutable consent artifact.
57
+ *
58
+ * The connector gate is the part that makes this a real trust policy rather
59
+ * than a config list. A declaration naming a source this PS does not serve is
60
+ * refused even if an operator pasted it in, because a grant over data that
61
+ * cannot exist here is at best useless and at worst a consent screen showing
62
+ * an owner something they cannot actually be sharing.
63
+ */
64
+ export declare function buildDeclarationRegistry(options: PdppDeclarationRegistryOptions): {
65
+ resolve: (sourceId: string) => DeclarationSnapshot | null;
66
+ retained: DeclarationSnapshot[];
67
+ /** The exact retained bytes per source id, for digest verification. */
68
+ retainedDocuments: Map<string, string>;
69
+ };
70
+ //# sourceMappingURL=deployment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/pdpp/deployment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAOpE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,8BAA8B;IAC7C,4DAA4D;IAC5D,YAAY,EAAE,qBAAqB,EAAE,CAAC;IACtC,6EAA6E;IAC7E,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,8BAA8B,GACtC;IACD,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,mBAAmB,GAAG,IAAI,CAAC;IAC1D,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,uEAAuE;IACvE,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CA8CA"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Deployment wiring for the PDPP Authorization Server.
3
+ *
4
+ * Two jobs the route module deliberately does not do, because both are
5
+ * deployment policy rather than protocol:
6
+ *
7
+ * 1. Decide which source declarations this server will accept as authority
8
+ * over a source. Core §5 requires an explicit trust policy; "we could
9
+ * reach it over HTTPS" is not one. The policy here is derived from what
10
+ * this PS actually serves, so a server that holds no Spotify data does
11
+ * not accept a Spotify declaration and cannot be talked into issuing a
12
+ * grant over data it has never collected.
13
+ *
14
+ * 2. Map a verified owner wallet to the PDPP subject. This PS is
15
+ * single-owner, so the subject is the server owner and nothing else.
16
+ *
17
+ * There is no trust-all default. A deployment that has configured no
18
+ * declarations accepts none, which makes `/pdpp/v1` inert rather than
19
+ * dangerous — the failure mode of a misconfigured authorization server should
20
+ * be "issues nothing", never "issues anything".
21
+ */
22
+ import { parseDeclaration } from "@opendatalabs/personal-server-ts-core/pdpp";
23
+ /**
24
+ * The connector inventory this PS serves, derived from the scopes it actually
25
+ * holds. A scope is `{source}.{category}[.{subcategory}]`, so the leading
26
+ * segment is the connector.
27
+ */
28
+ export function deriveSupportedConnectors(scopes) {
29
+ const sources = new Set();
30
+ for (const scope of scopes) {
31
+ const source = scope.split(".")[0];
32
+ if (source && source.length > 0)
33
+ sources.add(source);
34
+ }
35
+ return Array.from(sources).sort();
36
+ }
37
+ /**
38
+ * Build the `resolveDeclaration` lookup the AS routes consume.
39
+ *
40
+ * Every configured declaration is validated and digested once at startup, then
41
+ * pinned. A declaration that fails validation is dropped with a warning rather
42
+ * than accepted-and-hoped-for: an AS resolving grants against a malformed
43
+ * declaration would freeze nonsense into an immutable consent artifact.
44
+ *
45
+ * The connector gate is the part that makes this a real trust policy rather
46
+ * than a config list. A declaration naming a source this PS does not serve is
47
+ * refused even if an operator pasted it in, because a grant over data that
48
+ * cannot exist here is at best useless and at worst a consent screen showing
49
+ * an owner something they cannot actually be sharing.
50
+ */
51
+ export function buildDeclarationRegistry(options) {
52
+ const { logger } = options;
53
+ const supported = new Set(options.supportedConnectors);
54
+ const bySourceId = new Map();
55
+ // Only the documents that survived validation AND the connector gate. A
56
+ // rejected declaration must not leave its bytes behind for something else
57
+ // to verify against, or the trust policy would apply to the snapshot and
58
+ // not to the document.
59
+ const documentsBySourceId = new Map();
60
+ for (const configured of options.declarations) {
61
+ const parsed = parseDeclaration(configured.document, configured.sourceId);
62
+ if (!parsed.ok) {
63
+ logger.warn({ sourceId: configured.sourceId, reason: parsed.failure.message }, "PDPP declaration rejected: not retained");
64
+ continue;
65
+ }
66
+ const connector = connectorNameFor(parsed.snapshot);
67
+ if (!supported.has(connector)) {
68
+ logger.warn({ sourceId: configured.sourceId, connector }, "PDPP declaration rejected: this server does not serve that connector");
69
+ continue;
70
+ }
71
+ bySourceId.set(parsed.snapshot.source_id, parsed.snapshot);
72
+ documentsBySourceId.set(parsed.snapshot.source_id, configured.document);
73
+ logger.info({
74
+ sourceId: parsed.snapshot.source_id,
75
+ version: parsed.snapshot.version,
76
+ digest: parsed.snapshot.digest.slice(0, 12),
77
+ }, "PDPP declaration retained");
78
+ }
79
+ return {
80
+ resolve: (sourceId) => bySourceId.get(sourceId) ?? null,
81
+ retained: Array.from(bySourceId.values()),
82
+ retainedDocuments: documentsBySourceId,
83
+ };
84
+ }
85
+ /**
86
+ * The connector a declaration belongs to.
87
+ *
88
+ * Source IDs are absolute URIs whose last path segment names the connector
89
+ * (`https://registry.pdpp.dev/connectors/spotify` → `spotify`). Falling back
90
+ * to the whole ID for an unparseable value means an odd source fails the
91
+ * `supported` check rather than silently matching a connector it is not.
92
+ */
93
+ function connectorNameFor(snapshot) {
94
+ try {
95
+ const segments = new URL(snapshot.source_id).pathname
96
+ .split("/")
97
+ .filter((s) => s.length > 0);
98
+ return segments[segments.length - 1] ?? snapshot.source_id;
99
+ }
100
+ catch {
101
+ return snapshot.source_id;
102
+ }
103
+ }
104
+ //# sourceMappingURL=deployment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.js","sourceRoot":"","sources":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C,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/B,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC,SAAS,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createRecordDataValidator } from "@opendatalabs/personal-server-ts-core/storage/pdpp-records/schema";
2
+ //# sourceMappingURL=record-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-schema.d.ts","sourceRoot":"","sources":["../../src/pdpp/record-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mEAAmE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createRecordDataValidator } from "@opendatalabs/personal-server-ts-core/storage/pdpp-records/schema";
2
+ //# sourceMappingURL=record-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-schema.js","sourceRoot":"","sources":["../../src/pdpp/record-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mEAAmE,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Boot the PDPP Resource Server for a real Personal Server.
3
+ *
4
+ * `createPdppAuthDeps` makes a running server a PDPP *authorization* server.
5
+ * This is its counterpart: without it a real deployment can issue a perfectly
6
+ * valid grant-bound token that has nothing to read, and cannot even publish
7
+ * the RFC 9728 metadata a client needs to discover where to authorize.
8
+ *
9
+ * Two deliberate choices about where things come from:
10
+ *
11
+ * 1. Stream declarations are derived from the SAME retained declaration
12
+ * snapshots the AS resolved grants against — not a second config list.
13
+ * A grant freezes a declaration version at consent time; if the RS read
14
+ * its stream shapes from somewhere else, the two could disagree about
15
+ * what a stream's primary key or required fields are, and enforcement
16
+ * would be measured against a different document than the one the owner
17
+ * consented to. One retained snapshot, one authority.
18
+ *
19
+ * 2. Token resolution is the co-located path: the RS resolves through the
20
+ * AS's own `PdppTokenService` in-process. Core §8 permits this for a
21
+ * co-located AS+RS, and it is the only correct option here because there
22
+ * is exactly one authority — introspecting over HTTP against ourselves
23
+ * would add a network hop and a second code path without adding a second
24
+ * opinion. A separated deployment is a different wiring, not this one.
25
+ *
26
+ * Returns undefined when the AS did not mount, which leaves the resource
27
+ * surface unmounted too. An RS with no authorization server cannot enforce a
28
+ * grant, and a resource server that cannot enforce is worse than absent.
29
+ */
30
+ import type { Database } from "better-sqlite3";
31
+ import type { Logger } from "pino";
32
+ import type { DeclarationSnapshot } from "@opendatalabs/personal-server-ts-core/pdpp";
33
+ import { type PdppRecordStore, type StreamDeclarationRegistry } from "@opendatalabs/personal-server-ts-core/storage/pdpp-records";
34
+ import type { PdppAuthorizationService } from "@opendatalabs/personal-server-ts-core/ports/pdpp-auth";
35
+ import { type PdppImporter } from "@opendatalabs/personal-server-ts-core/sync";
36
+ import type { PdppAuthRouteDeps } from "../routes/pdpp-auth.js";
37
+ import { createSqliteRecordStore } from "../storage/pdpp-records-sqlite-store.js";
38
+ export interface PdppRecordsDeps {
39
+ store: PdppRecordStore;
40
+ bindingStore: ReturnType<typeof createSqliteRecordStore>;
41
+ configuredMethods: Map<string, string[]>;
42
+ auth: PdppAuthorizationService;
43
+ declarations: StreamDeclarationRegistry;
44
+ instancesForSubject?: (subjectId: string) => string[];
45
+ instancesForSource?: (subjectId: string, sourceId: string) => string[];
46
+ readBlobBytes?: (blobId: string) => Promise<Uint8Array<ArrayBuffer> | undefined>;
47
+ resource: string;
48
+ authorizationServers?: string[];
49
+ }
50
+ export interface CreatePdppRecordsDepsOptions {
51
+ /** The mounted AS, or undefined when it did not mount. */
52
+ pdppAuth: PdppAuthRouteDeps | undefined;
53
+ /** The retained snapshots the AS resolves grants against. */
54
+ declarations: DeclarationSnapshot[];
55
+ /** The server's own database; records live alongside the rest of its state. */
56
+ db: Database;
57
+ serverOwner: `0x${string}` | undefined;
58
+ resource: string;
59
+ logger: Logger;
60
+ configuredMethods?: {
61
+ sourceId: string;
62
+ methodId: string;
63
+ }[];
64
+ }
65
+ /** Restore account-one registry rows for legacy scopes before Desktop reads the registry. */
66
+ export declare function registerLegacyDataConnections(options: {
67
+ db: Database;
68
+ serverOwner: string | undefined;
69
+ connectionMethods: Map<string, string[]>;
70
+ legacyScopes: string[];
71
+ logger: Logger;
72
+ }): void;
73
+ export declare function createPdppRecordsDeps(options: CreatePdppRecordsDepsOptions): PdppRecordsDeps | undefined;
74
+ /**
75
+ * Resolve tokens through the AS in-process.
76
+ *
77
+ * The AS's `resolveToken` is synchronous and marks `tokenKind`/`subjectId`
78
+ * optional, because an inactive token carries neither (RFC 7662 §2.2). The
79
+ * RS port is async and requires them, so this narrows explicitly rather than
80
+ * casting: an inactive result must never yield an undefined subject that
81
+ * flows onward into an authorization decision.
82
+ */
83
+ export declare function coLocatedAuthorizationService(pdppAuth: PdppAuthRouteDeps): PdppAuthorizationService;
84
+ /**
85
+ * Build the sync importer that maps qualifying DataPipe envelopes into the
86
+ * record store the RS reads from.
87
+ *
88
+ * Built from the SAME retained snapshots and the SAME instance derivation as
89
+ * the RS above, for the same reason given at the top of this file: a record
90
+ * imported under a different stream shape or a different instance handle than
91
+ * the RS enforces against is a record no grant can correctly reach. One
92
+ * retained declaration, one authority — on the write path too.
93
+ *
94
+ * The SQLite store refuses every write from this importer with
95
+ * `method_required`: `$pdpp` metadata names no acquisition method or binding
96
+ * generation, so P8a and P8c cannot be applied to it. The importer reports
97
+ * that as a terminal `method_authority` rejection and does not retry it.
98
+ *
99
+ * Returns undefined when the RS did not mount. Importing into a store nothing
100
+ * can read would be write-only work, and it would do it against declarations
101
+ * this deployment has not accepted.
102
+ */
103
+ export declare function createPdppSyncImporter(options: {
104
+ records: PdppRecordsDeps | undefined;
105
+ declarations: DeclarationSnapshot[];
106
+ /** Exact retained bytes per source id, from the AS boot. */
107
+ documents: Map<string, string>;
108
+ serverOwner: `0x${string}` | undefined;
109
+ logger: Logger;
110
+ }): PdppImporter | undefined;
111
+ //# sourceMappingURL=records-bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-bootstrap.d.ts","sourceRoot":"","sources":["../../src/pdpp/records-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAEL,KAAK,eAAe,EAGpB,KAAK,yBAAyB,EAC/B,MAAM,4DAA4D,CAAC;AACpE,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,uBAAuB,EAExB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACzD,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,YAAY,EAAE,yBAAyB,CAAC;IACxC,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACtD,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACvE,aAAa,CAAC,EAAE,CACd,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG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