@opendatalabs/personal-server-ts-server 0.0.1-canary.f5febb3 → 0.0.1-canary.f7730cd

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 (107) hide show
  1. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.d.ts +41 -0
  2. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.d.ts.map +1 -0
  3. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.js +34 -0
  4. package/dist/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.js.map +1 -0
  5. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.d.ts +112 -0
  6. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.d.ts.map +1 -0
  7. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.js +226 -0
  8. package/dist/__fixtures__/cg-pdpp-client/pdpp-context-client.js.map +1 -0
  9. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.d.ts +135 -0
  10. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.d.ts.map +1 -0
  11. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.js +21 -0
  12. package/dist/__fixtures__/cg-pdpp-client/pdpp-types.js.map +1 -0
  13. package/dist/app.d.ts +43 -1
  14. package/dist/app.d.ts.map +1 -1
  15. package/dist/app.js +81 -1
  16. package/dist/app.js.map +1 -1
  17. package/dist/bootstrap.d.ts.map +1 -1
  18. package/dist/bootstrap.js +71 -0
  19. package/dist/bootstrap.js.map +1 -1
  20. package/dist/config/loader.d.ts.map +1 -1
  21. package/dist/config/loader.js +7 -3
  22. package/dist/config/loader.js.map +1 -1
  23. package/dist/index.js +5 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/jobs/access-reporter.d.ts +7 -2
  26. package/dist/jobs/access-reporter.d.ts.map +1 -1
  27. package/dist/jobs/access-reporter.js +157 -12
  28. package/dist/jobs/access-reporter.js.map +1 -1
  29. package/dist/mcp/durable-state.d.ts +23 -1
  30. package/dist/mcp/durable-state.d.ts.map +1 -1
  31. package/dist/mcp/durable-state.js +34 -0
  32. package/dist/mcp/durable-state.js.map +1 -1
  33. package/dist/mcp/index.d.ts +1 -1
  34. package/dist/mcp/index.d.ts.map +1 -1
  35. package/dist/mcp/index.js +1 -1
  36. package/dist/mcp/index.js.map +1 -1
  37. package/dist/mcp/tee-ingress.d.ts +4 -0
  38. package/dist/mcp/tee-ingress.d.ts.map +1 -1
  39. package/dist/mcp/tee-ingress.js +149 -3
  40. package/dist/mcp/tee-ingress.js.map +1 -1
  41. package/dist/middleware/local-listener.d.ts +33 -0
  42. package/dist/middleware/local-listener.d.ts.map +1 -0
  43. package/dist/middleware/local-listener.js +103 -0
  44. package/dist/middleware/local-listener.js.map +1 -0
  45. package/dist/package.json +4 -1
  46. package/dist/pdpp/bootstrap.d.ts +56 -0
  47. package/dist/pdpp/bootstrap.d.ts.map +1 -0
  48. package/dist/pdpp/bootstrap.js +193 -0
  49. package/dist/pdpp/bootstrap.js.map +1 -0
  50. package/dist/pdpp/chain-enforcement.d.ts +95 -0
  51. package/dist/pdpp/chain-enforcement.d.ts.map +1 -0
  52. package/dist/pdpp/chain-enforcement.js +145 -0
  53. package/dist/pdpp/chain-enforcement.js.map +1 -0
  54. package/dist/pdpp/client-document-fetch.d.ts +63 -0
  55. package/dist/pdpp/client-document-fetch.d.ts.map +1 -0
  56. package/dist/pdpp/client-document-fetch.js +254 -0
  57. package/dist/pdpp/client-document-fetch.js.map +1 -0
  58. package/dist/pdpp/deployment.d.ts +85 -0
  59. package/dist/pdpp/deployment.d.ts.map +1 -0
  60. package/dist/pdpp/deployment.js +122 -0
  61. package/dist/pdpp/deployment.js.map +1 -0
  62. package/dist/pdpp/records-bootstrap.d.ts +80 -0
  63. package/dist/pdpp/records-bootstrap.d.ts.map +1 -0
  64. package/dist/pdpp/records-bootstrap.js +187 -0
  65. package/dist/pdpp/records-bootstrap.js.map +1 -0
  66. package/dist/routes/data.d.ts +7 -1
  67. package/dist/routes/data.d.ts.map +1 -1
  68. package/dist/routes/data.js +1 -0
  69. package/dist/routes/data.js.map +1 -1
  70. package/dist/routes/mcp.d.ts.map +1 -1
  71. package/dist/routes/mcp.js +4 -1
  72. package/dist/routes/mcp.js.map +1 -1
  73. package/dist/routes/pdpp-auth.d.ts +118 -0
  74. package/dist/routes/pdpp-auth.d.ts.map +1 -0
  75. package/dist/routes/pdpp-auth.js +589 -0
  76. package/dist/routes/pdpp-auth.js.map +1 -0
  77. package/dist/routes/pdpp-blobs.d.ts +24 -0
  78. package/dist/routes/pdpp-blobs.d.ts.map +1 -0
  79. package/dist/routes/pdpp-blobs.js +162 -0
  80. package/dist/routes/pdpp-blobs.js.map +1 -0
  81. package/dist/routes/pdpp-records.d.ts +128 -0
  82. package/dist/routes/pdpp-records.d.ts.map +1 -0
  83. package/dist/routes/pdpp-records.js +850 -0
  84. package/dist/routes/pdpp-records.js.map +1 -0
  85. package/dist/routes/pdpp-well-known.d.ts +13 -0
  86. package/dist/routes/pdpp-well-known.d.ts.map +1 -0
  87. package/dist/routes/pdpp-well-known.js +20 -0
  88. package/dist/routes/pdpp-well-known.js.map +1 -0
  89. package/dist/routes/ui.d.ts +7 -0
  90. package/dist/routes/ui.d.ts.map +1 -1
  91. package/dist/routes/ui.js +32 -3
  92. package/dist/routes/ui.js.map +1 -1
  93. package/dist/storage/pdpp-grant-binding-sqlite-store.d.ts +17 -0
  94. package/dist/storage/pdpp-grant-binding-sqlite-store.d.ts.map +1 -0
  95. package/dist/storage/pdpp-grant-binding-sqlite-store.js +159 -0
  96. package/dist/storage/pdpp-grant-binding-sqlite-store.js.map +1 -0
  97. package/dist/storage/pdpp-records-sqlite-store.d.ts +8 -0
  98. package/dist/storage/pdpp-records-sqlite-store.d.ts.map +1 -0
  99. package/dist/storage/pdpp-records-sqlite-store.js +649 -0
  100. package/dist/storage/pdpp-records-sqlite-store.js.map +1 -0
  101. package/dist/tunnel/binary.d.ts +8 -0
  102. package/dist/tunnel/binary.d.ts.map +1 -1
  103. package/dist/tunnel/binary.js +11 -0
  104. package/dist/tunnel/binary.js.map +1 -1
  105. package/dist/ui/index.html +13 -0
  106. package/dist/ui/ps-lite-debug.js +371 -40
  107. package/package.json +7 -4
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Vendored from Context Gateway branch `pdpp/context-client-0917` (PR #284),
3
+ * file `apps/api/src/lib/pdpp-authorization-strategy.ts`.
4
+ *
5
+ * ONLY the bearer-token strategy is carried across. The upstream file also
6
+ * exports `webSignedAuthorizationStrategy`, which imports
7
+ * `@/lib/personal-server-data-read` — a Context Gateway internal that pulls in
8
+ * that repo's wallet custody. Vendoring it would mean vendoring half of
9
+ * Context Gateway to test the half that matters here, so it is deliberately
10
+ * omitted rather than stubbed: a stub would be a fixture pretending to be the
11
+ * real strategy, which is exactly what this journey exists to avoid.
12
+ *
13
+ * The bearer strategy below is byte-identical to upstream, and it is the
14
+ * spec-conformant path (§8 "Authentication": client operations use
15
+ * `Authorization: Bearer <access_token>`). The token it carries here is
16
+ * minted by the real AS, not fabricated.
17
+ */
18
+ /**
19
+ * Produces the `Authorization` header value for one PDPP §8 request.
20
+ * `uri` is always the request pathname only (never including the query
21
+ * string — both PS's Web3Signed verifier and this client's callers must
22
+ * agree on that), so a strategy that needs to bind the header to the
23
+ * request (Web3Signed) gets exactly what it needs to do so correctly.
24
+ */
25
+ export type PdppAuthorizationStrategy = (params: {
26
+ origin: string;
27
+ method: string;
28
+ uri: string;
29
+ }) => Promise<string>;
30
+ /**
31
+ * Spec-conformant strategy: send the client access token issued by PS's
32
+ * PDPP AS as `Authorization: Bearer <access_token>`.
33
+ */
34
+ export declare function bearerTokenAuthorizationStrategy(accessToken: string): PdppAuthorizationStrategy;
35
+ /**
36
+ * Not vendored — see the file header. Present only so that importing code
37
+ * which references it by name fails loudly rather than silently binding to
38
+ * something that looks like the real Web3Signed strategy.
39
+ */
40
+ export declare function webSignedAuthorizationStrategy(): never;
41
+ //# sourceMappingURL=pdpp-authorization-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdpp-authorization-strategy.d.ts","sourceRoot":"","sources":["../../../src/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEtB;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,MAAM,GAClB,yBAAyB,CAE3B;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,KAAK,CAKtD"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Vendored from Context Gateway branch `pdpp/context-client-0917` (PR #284),
3
+ * file `apps/api/src/lib/pdpp-authorization-strategy.ts`.
4
+ *
5
+ * ONLY the bearer-token strategy is carried across. The upstream file also
6
+ * exports `webSignedAuthorizationStrategy`, which imports
7
+ * `@/lib/personal-server-data-read` — a Context Gateway internal that pulls in
8
+ * that repo's wallet custody. Vendoring it would mean vendoring half of
9
+ * Context Gateway to test the half that matters here, so it is deliberately
10
+ * omitted rather than stubbed: a stub would be a fixture pretending to be the
11
+ * real strategy, which is exactly what this journey exists to avoid.
12
+ *
13
+ * The bearer strategy below is byte-identical to upstream, and it is the
14
+ * spec-conformant path (§8 "Authentication": client operations use
15
+ * `Authorization: Bearer <access_token>`). The token it carries here is
16
+ * minted by the real AS, not fabricated.
17
+ */
18
+ /**
19
+ * Spec-conformant strategy: send the client access token issued by PS's
20
+ * PDPP AS as `Authorization: Bearer <access_token>`.
21
+ */
22
+ export function bearerTokenAuthorizationStrategy(accessToken) {
23
+ return async () => `Bearer ${accessToken}`;
24
+ }
25
+ /**
26
+ * Not vendored — see the file header. Present only so that importing code
27
+ * which references it by name fails loudly rather than silently binding to
28
+ * something that looks like the real Web3Signed strategy.
29
+ */
30
+ export function webSignedAuthorizationStrategy() {
31
+ throw new Error("webSignedAuthorizationStrategy is not vendored into this fixture; " +
32
+ "this journey exercises the spec-conformant bearer path only");
33
+ }
34
+ //# sourceMappingURL=pdpp-authorization-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdpp-authorization-strategy.js","sourceRoot":"","sources":["../../../src/__fixtures__/cg-pdpp-client/pdpp-authorization-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAeH;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC9C,WAAmB;IAEnB,OAAO,KAAK,IAAI,EAAE,CAAC,UAAU,WAAW,EAAE,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,IAAI,KAAK,CACb,oEAAoE;QAClE,6DAA6D,CAChE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Context Gateway → PDPP Core §8 Resource Server client.
3
+ *
4
+ * This is a typed transport for PDPP's Client role (spec §9 "Client
5
+ * conformance"), built alongside the existing legacy PS read path in
6
+ * `personal-server-data-read.ts` — it does not replace it. The legacy path
7
+ * (`GET /v1/data/{scope}`, one JSON body, no cursor) stays live until PS
8
+ * actually serves the §8 surface; this module targets `GET /v1/streams`,
9
+ * `GET /v1/streams/{stream}`, and `GET /v1/streams/{stream}/records` per
10
+ * spec-core.md §8, cited exhaustively in `pdpp-types.ts`.
11
+ *
12
+ * Authentication is pluggable via `PdppAuthorizationStrategy`, not
13
+ * hardcoded, because two genuinely different mechanisms exist and must not
14
+ * collapse into one:
15
+ *
16
+ * - **Grantee identity** (which app is calling): one Privy-custodied
17
+ * Ethereum wallet per builder app (`grantee-wallets.ts`,
18
+ * `ensureGranteeWalletForApp`), unchanged by this PR. No shared CG
19
+ * wallet, no per-app Hydra OAuth client — neither exists in this
20
+ * codebase and this file does not add one.
21
+ * - **Request authorization** (what proves the request is allowed): per
22
+ * `local/conformance-fleet-0917/ps-auth-contract.md` (the AS/RS lane's
23
+ * published seam, `vana-com/personal-server-ts` branch
24
+ * `feat/pdpp-as-grants`, not yet pushed as of this revision), PS's PDPP
25
+ * AS issues real `access_token`s bound to a `Grant`, resolved via
26
+ * `PdppAuthorizationService.resolveToken`/`introspect`. That token,
27
+ * sent as `Authorization: Bearer <access_token>`, is what spec §8
28
+ * actually requires — not a Web3Signed header. Web3Signed remains valid
29
+ * only for the legacy `/v1/data/{scope}` endpoint, which this client
30
+ * does not call. `webSignedAuthorizationStrategy` below exists for
31
+ * conformance testing against a PS deployment that has not yet adopted
32
+ * real token issuance, not as this client's default.
33
+ *
34
+ * The two are complementary, not substitutable: obtaining an
35
+ * `access_token` from the AS in the first place still requires the caller
36
+ * to authenticate as a specific grantee app (out of scope for this file —
37
+ * that's the AS's `/v1/pdpp/authorize` + `/v1/pdpp/token` flow per the
38
+ * contract doc); this client only consumes the resulting bearer token.
39
+ *
40
+ * PROVISIONAL: neither the AS lane's branch (`pdpp-as-build-0917`,
41
+ * `feat/pdpp-as-grants`) nor the RS lane's branch (`pdpp-ps-records-v2-0917`)
42
+ * is pushed to `vana-com/personal-server-ts` as of this revision (verified
43
+ * via `git ls-remote`) — the peer session claiming to run
44
+ * `pdpp-as-build-0917` was not even found in this environment's live agent
45
+ * list. This client is typed against `ps-auth-contract.md`'s TypeScript
46
+ * seam and the spec text, not against a running server; there is nothing
47
+ * to integration-test against yet. See the result report for the exact
48
+ * live acceptance this leaves open.
49
+ */
50
+ import { bearerTokenAuthorizationStrategy, type PdppAuthorizationStrategy, webSignedAuthorizationStrategy } from "./pdpp-authorization-strategy.js";
51
+ import { type PdppErrorCode, type PdppErrorType, type PdppGetRecordParams, type PdppListRecordsParams, type PdppListRecordsResponse, type PdppListStreamsResponse, type PdppRecord, type PdppStreamMetadata, type PdppTombstone } from "./pdpp-types.js";
52
+ export { bearerTokenAuthorizationStrategy, webSignedAuthorizationStrategy };
53
+ export type { PdppAuthorizationStrategy };
54
+ export interface PdppClientConfig {
55
+ /** Base URL of the target Resource Server, e.g. the resolved PS URL. */
56
+ baseUrl: string;
57
+ /**
58
+ * How to produce the `Authorization` header for each request. Required —
59
+ * there is no default, so a caller cannot silently fall back to
60
+ * Web3Signed by omission. Use `bearerTokenAuthorizationStrategy` (the
61
+ * spec-conformant path, once the AS lane's token issuance is reachable)
62
+ * or `webSignedAuthorizationStrategy` (explicit legacy-PS opt-in).
63
+ */
64
+ authorization: PdppAuthorizationStrategy;
65
+ /** Overrides `PDPP_VERSION` for conformance testing against other versions. */
66
+ pdppVersion?: string;
67
+ }
68
+ /**
69
+ * Thrown for any non-2xx §8 response. Carries the parsed spec error body so
70
+ * callers can branch on `code`, not on message text (`meta.warnings[]`
71
+ * mirrors this rule for non-fatal cases — see spec §8 "Non-fatal warnings").
72
+ */
73
+ export declare class PdppClientError extends Error {
74
+ readonly httpStatus: number;
75
+ readonly code: PdppErrorCode;
76
+ readonly type: PdppErrorType;
77
+ readonly requestId?: string;
78
+ readonly param?: string;
79
+ constructor(params: {
80
+ httpStatus: number;
81
+ code: PdppErrorCode;
82
+ type: PdppErrorType;
83
+ message: string;
84
+ requestId?: string;
85
+ param?: string;
86
+ });
87
+ }
88
+ /** Thrown when a response cannot be parsed as the spec §8 error envelope at all. */
89
+ export declare class PdppTransportError extends Error {
90
+ readonly httpStatus: number;
91
+ constructor(params: {
92
+ httpStatus: number;
93
+ message: string;
94
+ });
95
+ }
96
+ /**
97
+ * PDPP Core §8 client for the Resource Server's read surface. One instance
98
+ * is scoped to one `PdppAuthorizationStrategy` closure, which in turn is
99
+ * scoped to one grant/one grantee wallet — mirrors the immutability of the
100
+ * DCR snapshot the legacy path relies on (never re-derive credentials from
101
+ * a shared or ambient identity).
102
+ */
103
+ export declare class PdppContextClient {
104
+ private readonly config;
105
+ constructor(config: PdppClientConfig);
106
+ listStreams(): Promise<PdppListStreamsResponse>;
107
+ getStreamMetadata(stream: string): Promise<PdppStreamMetadata>;
108
+ listRecords(stream: string, params?: PdppListRecordsParams): Promise<PdppListRecordsResponse>;
109
+ getRecord(stream: string, id: string, params?: PdppGetRecordParams): Promise<PdppRecord | PdppTombstone>;
110
+ private get;
111
+ }
112
+ //# sourceMappingURL=pdpp-context-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdpp-context-client.d.ts","sourceRoot":"","sources":["../../../src/__fixtures__/cg-pdpp-client/pdpp-context-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EACL,gCAAgC,EAChC,KAAK,yBAAyB,EAC9B,8BAA8B,EAC/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,CAAC;AAC5E,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,aAAa,EAAE,yBAAyB,CAAC;IACzC,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,aAAa,CAAC;QACpB,IAAI,EAAE,aAAa,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;CASF;AAED,oFAAoF;AACpF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAK5D;AAiGD;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;gBAE9B,MAAM,EAAE,gBAAgB;IAI9B,WAAW,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAI/C,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAM9D,WAAW,CACf,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,qBAA0B,GACjC,OAAO,CAAC,uBAAuB,CAAC;IAO7B,SAAS,CACb,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,mBAAwB,GAC/B,OAAO,CAAC,UAAU,GAAG,aAAa,CAAC;YAUxB,GAAG;CA6BlB"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Context Gateway → PDPP Core §8 Resource Server client.
3
+ *
4
+ * This is a typed transport for PDPP's Client role (spec §9 "Client
5
+ * conformance"), built alongside the existing legacy PS read path in
6
+ * `personal-server-data-read.ts` — it does not replace it. The legacy path
7
+ * (`GET /v1/data/{scope}`, one JSON body, no cursor) stays live until PS
8
+ * actually serves the §8 surface; this module targets `GET /v1/streams`,
9
+ * `GET /v1/streams/{stream}`, and `GET /v1/streams/{stream}/records` per
10
+ * spec-core.md §8, cited exhaustively in `pdpp-types.ts`.
11
+ *
12
+ * Authentication is pluggable via `PdppAuthorizationStrategy`, not
13
+ * hardcoded, because two genuinely different mechanisms exist and must not
14
+ * collapse into one:
15
+ *
16
+ * - **Grantee identity** (which app is calling): one Privy-custodied
17
+ * Ethereum wallet per builder app (`grantee-wallets.ts`,
18
+ * `ensureGranteeWalletForApp`), unchanged by this PR. No shared CG
19
+ * wallet, no per-app Hydra OAuth client — neither exists in this
20
+ * codebase and this file does not add one.
21
+ * - **Request authorization** (what proves the request is allowed): per
22
+ * `local/conformance-fleet-0917/ps-auth-contract.md` (the AS/RS lane's
23
+ * published seam, `vana-com/personal-server-ts` branch
24
+ * `feat/pdpp-as-grants`, not yet pushed as of this revision), PS's PDPP
25
+ * AS issues real `access_token`s bound to a `Grant`, resolved via
26
+ * `PdppAuthorizationService.resolveToken`/`introspect`. That token,
27
+ * sent as `Authorization: Bearer <access_token>`, is what spec §8
28
+ * actually requires — not a Web3Signed header. Web3Signed remains valid
29
+ * only for the legacy `/v1/data/{scope}` endpoint, which this client
30
+ * does not call. `webSignedAuthorizationStrategy` below exists for
31
+ * conformance testing against a PS deployment that has not yet adopted
32
+ * real token issuance, not as this client's default.
33
+ *
34
+ * The two are complementary, not substitutable: obtaining an
35
+ * `access_token` from the AS in the first place still requires the caller
36
+ * to authenticate as a specific grantee app (out of scope for this file —
37
+ * that's the AS's `/v1/pdpp/authorize` + `/v1/pdpp/token` flow per the
38
+ * contract doc); this client only consumes the resulting bearer token.
39
+ *
40
+ * PROVISIONAL: neither the AS lane's branch (`pdpp-as-build-0917`,
41
+ * `feat/pdpp-as-grants`) nor the RS lane's branch (`pdpp-ps-records-v2-0917`)
42
+ * is pushed to `vana-com/personal-server-ts` as of this revision (verified
43
+ * via `git ls-remote`) — the peer session claiming to run
44
+ * `pdpp-as-build-0917` was not even found in this environment's live agent
45
+ * list. This client is typed against `ps-auth-contract.md`'s TypeScript
46
+ * seam and the spec text, not against a running server; there is nothing
47
+ * to integration-test against yet. See the result report for the exact
48
+ * live acceptance this leaves open.
49
+ */
50
+ import { bearerTokenAuthorizationStrategy, webSignedAuthorizationStrategy, } from "./pdpp-authorization-strategy.js";
51
+ import { PDPP_REQUEST_ID_HEADER, PDPP_VERSION, PDPP_VERSION_HEADER, } from "./pdpp-types.js";
52
+ export { bearerTokenAuthorizationStrategy, webSignedAuthorizationStrategy };
53
+ /**
54
+ * Thrown for any non-2xx §8 response. Carries the parsed spec error body so
55
+ * callers can branch on `code`, not on message text (`meta.warnings[]`
56
+ * mirrors this rule for non-fatal cases — see spec §8 "Non-fatal warnings").
57
+ */
58
+ export class PdppClientError extends Error {
59
+ httpStatus;
60
+ code;
61
+ type;
62
+ requestId;
63
+ param;
64
+ constructor(params) {
65
+ super(params.message);
66
+ this.name = "PdppClientError";
67
+ this.httpStatus = params.httpStatus;
68
+ this.code = params.code;
69
+ this.type = params.type;
70
+ this.requestId = params.requestId;
71
+ this.param = params.param;
72
+ }
73
+ }
74
+ /** Thrown when a response cannot be parsed as the spec §8 error envelope at all. */
75
+ export class PdppTransportError extends Error {
76
+ httpStatus;
77
+ constructor(params) {
78
+ super(params.message);
79
+ this.name = "PdppTransportError";
80
+ this.httpStatus = params.httpStatus;
81
+ }
82
+ }
83
+ function isPdppErrorBody(value) {
84
+ if (!value || typeof value !== "object") {
85
+ return false;
86
+ }
87
+ const error = value.error;
88
+ return (Boolean(error) &&
89
+ typeof error === "object" &&
90
+ typeof error.code === "string" &&
91
+ typeof error.type === "string" &&
92
+ typeof error.message === "string");
93
+ }
94
+ async function throwForErrorResponse(response) {
95
+ let parsed;
96
+ try {
97
+ parsed = await response.json();
98
+ }
99
+ catch {
100
+ parsed = null;
101
+ }
102
+ if (isPdppErrorBody(parsed)) {
103
+ const { error } = parsed;
104
+ throw new PdppClientError({
105
+ code: error.code,
106
+ httpStatus: response.status,
107
+ message: error.message,
108
+ param: error.param,
109
+ requestId: error.request_id ??
110
+ response.headers.get(PDPP_REQUEST_ID_HEADER) ??
111
+ undefined,
112
+ type: error.type,
113
+ });
114
+ }
115
+ throw new PdppTransportError({
116
+ httpStatus: response.status,
117
+ message: `PDPP resource server returned HTTP ${response.status} without a valid spec §8 error body`,
118
+ });
119
+ }
120
+ /** Builds `filter[{field}]` / `filter[{field}][gte|gt|lte|lt]` query entries per spec §8. */
121
+ function appendFilterParams(search, filter) {
122
+ if (!filter) {
123
+ return;
124
+ }
125
+ for (const [field, value] of Object.entries(filter)) {
126
+ if (typeof value === "string") {
127
+ search.set(`filter[${field}]`, value);
128
+ continue;
129
+ }
130
+ for (const op of ["gte", "gt", "lte", "lt"]) {
131
+ const opValue = value[op];
132
+ if (opValue !== undefined) {
133
+ search.set(`filter[${field}][${op}]`, opValue);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ function buildListRecordsSearchParams(params) {
139
+ const search = new URLSearchParams();
140
+ if (params.limit !== undefined) {
141
+ search.set("limit", String(params.limit));
142
+ }
143
+ if (params.cursor !== undefined) {
144
+ search.set("cursor", params.cursor);
145
+ }
146
+ if (params.order !== undefined) {
147
+ search.set("order", params.order);
148
+ }
149
+ appendFilterParams(search, params.filter);
150
+ if (params.view !== undefined) {
151
+ search.set("view", params.view);
152
+ }
153
+ if (params.fields !== undefined) {
154
+ search.set("fields", params.fields.join(","));
155
+ }
156
+ for (const relation of params.expand ?? []) {
157
+ search.append("expand[]", relation);
158
+ }
159
+ for (const [relation, limit] of Object.entries(params.expand_limit ?? {})) {
160
+ search.set(`expand_limit[${relation}]`, String(limit));
161
+ }
162
+ if (params.changes_since !== undefined) {
163
+ search.set("changes_since", params.changes_since);
164
+ }
165
+ return search;
166
+ }
167
+ /**
168
+ * PDPP Core §8 client for the Resource Server's read surface. One instance
169
+ * is scoped to one `PdppAuthorizationStrategy` closure, which in turn is
170
+ * scoped to one grant/one grantee wallet — mirrors the immutability of the
171
+ * DCR snapshot the legacy path relies on (never re-derive credentials from
172
+ * a shared or ambient identity).
173
+ */
174
+ export class PdppContextClient {
175
+ config;
176
+ constructor(config) {
177
+ this.config = config;
178
+ }
179
+ async listStreams() {
180
+ return await this.get("/v1/streams");
181
+ }
182
+ async getStreamMetadata(stream) {
183
+ return await this.get(`/v1/streams/${encodeURIComponent(stream)}`);
184
+ }
185
+ async listRecords(stream, params = {}) {
186
+ const search = buildListRecordsSearchParams(params);
187
+ const qs = search.toString();
188
+ const path = `/v1/streams/${encodeURIComponent(stream)}/records${qs ? `?${qs}` : ""}`;
189
+ return await this.get(path);
190
+ }
191
+ async getRecord(stream, id, params = {}) {
192
+ const search = new URLSearchParams();
193
+ for (const relation of params.expand ?? []) {
194
+ search.append("expand[]", relation);
195
+ }
196
+ const qs = search.toString();
197
+ const path = `/v1/streams/${encodeURIComponent(stream)}/records/${encodeURIComponent(id)}${qs ? `?${qs}` : ""}`;
198
+ return await this.get(path);
199
+ }
200
+ async get(pathname) {
201
+ const origin = new URL(this.config.baseUrl).origin;
202
+ const url = new URL(pathname, origin);
203
+ // The `uri` passed to the authorization strategy is always the
204
+ // pathname only, never the query string — required by the Web3Signed
205
+ // strategy's verifier and harmless for the bearer-token strategy,
206
+ // which ignores it.
207
+ const authorization = await this.config.authorization({
208
+ method: "GET",
209
+ origin,
210
+ uri: url.pathname,
211
+ });
212
+ const response = await fetch(url.toString(), {
213
+ headers: {
214
+ accept: "application/json",
215
+ authorization,
216
+ [PDPP_VERSION_HEADER]: this.config.pdppVersion ?? PDPP_VERSION,
217
+ },
218
+ method: "GET",
219
+ });
220
+ if (!response.ok) {
221
+ await throwForErrorResponse(response);
222
+ }
223
+ return (await response.json());
224
+ }
225
+ }
226
+ //# sourceMappingURL=pdpp-context-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdpp-context-client.js","sourceRoot":"","sources":["../../../src/__fixtures__/cg-pdpp-client/pdpp-context-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,GAAG,CAAC,QAAQ,EAAE,EAAE;YAC3C,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,aAAa;gBACb,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,YAAY;aAC/D;YACD,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * PDPP Core §8 (Resource Server Interface) request/response types.
3
+ *
4
+ * Cited against `PDP-Connect/pdpp` `apps/site/content/docs/spec-core.md`
5
+ * section 8 (`#resource-server-interface`) as of 2026-09-17. This module is
6
+ * intentionally the *only* place that names PDPP wire shapes for the Client
7
+ * role — do not redeclare `PdppRecord`/`PdppListRecordsResponse`/etc. inline
8
+ * at a call site.
9
+ *
10
+ * PS's actual §8 endpoints have not landed yet (no PR in
11
+ * vana-com/personal-server-ts implements them as of this writing; see
12
+ * `local/conformance-fleet-0917/scope-lanes.md` Lane B/C in the pdpp repo).
13
+ * These types are derived directly from the spec text, not from PS's
14
+ * implementation — per that same plan's warning against reverse-engineering
15
+ * a vendor's behavior instead of the normative document.
16
+ */
17
+ /** Spec §8 "Errors": every non-2xx response has this envelope. */
18
+ export interface PdppErrorBody {
19
+ error: {
20
+ type: PdppErrorType;
21
+ code: PdppErrorCode;
22
+ message: string;
23
+ param?: string;
24
+ request_id?: string;
25
+ };
26
+ }
27
+ export type PdppErrorType = "invalid_request_error" | "authentication_error" | "permission_error" | "not_found_error" | "gone_error" | "rate_limit_error" | "api_error";
28
+ /** Spec §8 error table, `#errors`. */
29
+ export type PdppErrorCode = "invalid_cursor" | "invalid_request" | "invalid_record" | "invalid_record_identity" | "invalid_expand" | "unknown_field" | "unsupported_version" | "authentication_error" | "field_not_granted" | "insufficient_scope" | "grant_stream_not_allowed" | "grant_time_range_exceeded" | "grant_expired" | "grant_revoked" | "grant_invalid" | "blob_not_found" | "not_found" | "cursor_expired" | "rate_limit_exceeded" | "api_error";
30
+ export interface PdppFreshness {
31
+ captured_at: string | null;
32
+ status: "current" | "stale" | "unknown";
33
+ last_attempted_at: string | null;
34
+ }
35
+ /** Spec §8 "List streams". */
36
+ export interface PdppStreamListItem {
37
+ object: "stream";
38
+ name: string;
39
+ record_count: number;
40
+ last_updated: string;
41
+ freshness?: PdppFreshness;
42
+ }
43
+ export interface PdppListStreamsResponse {
44
+ object: "list";
45
+ data: PdppStreamListItem[];
46
+ }
47
+ /** Spec §8 "Get stream metadata". Not grant-projected. */
48
+ export interface PdppStreamMetadata {
49
+ object: "stream_metadata";
50
+ name: string;
51
+ schema: Record<string, unknown>;
52
+ primary_key: string[];
53
+ cursor_field: string;
54
+ consent_time_field: string;
55
+ selection: {
56
+ fields: boolean;
57
+ resources: boolean;
58
+ };
59
+ query?: {
60
+ range_filters?: Record<string, Array<"gte" | "gt" | "lte" | "lt">>;
61
+ expand?: Array<{
62
+ name: string;
63
+ default_limit: number;
64
+ max_limit: number;
65
+ }>;
66
+ };
67
+ freshness?: PdppFreshness;
68
+ views?: Array<{
69
+ id: string;
70
+ label: string;
71
+ fields: string[];
72
+ }>;
73
+ relationships?: Array<{
74
+ name: string;
75
+ stream: string;
76
+ foreign_key: string;
77
+ cardinality: "has_one" | "has_many";
78
+ }>;
79
+ }
80
+ /** Spec §4 "The RECORD envelope" / §8 list-records response item. */
81
+ export interface PdppRecord {
82
+ object: "record";
83
+ id: string;
84
+ stream: string;
85
+ data: Record<string, unknown>;
86
+ emitted_at: string;
87
+ expanded?: Record<string, PdppRecord[] | PdppRecord>;
88
+ }
89
+ /** Spec §4 "Tombstones": present in `changes_since` responses for deletions. */
90
+ export interface PdppTombstone {
91
+ object: "tombstone";
92
+ id: string;
93
+ stream: string;
94
+ deleted_at: string;
95
+ }
96
+ /** Spec §8 "Non-fatal warnings", `meta.warnings[]`. */
97
+ export interface PdppWarning {
98
+ code: string;
99
+ message: string;
100
+ }
101
+ /** Spec §8 "List records" query parameters — the durable v0.1 base surface. */
102
+ export interface PdppListRecordsParams {
103
+ limit?: number;
104
+ cursor?: string;
105
+ order?: "asc" | "desc";
106
+ /** `filter[{field}]` and `filter[{field}][gte|gt|lte|lt]`, keyed by field name. */
107
+ filter?: Record<string, string | Partial<Record<"gte" | "gt" | "lte" | "lt", string>>>;
108
+ view?: string;
109
+ fields?: string[];
110
+ expand?: string[];
111
+ expand_limit?: Record<string, number>;
112
+ /** Opaque incremental-sync token — a distinct token space from `cursor`. */
113
+ changes_since?: string;
114
+ }
115
+ export interface PdppListRecordsResponse {
116
+ object: "list";
117
+ url: string;
118
+ has_more: boolean;
119
+ next_cursor?: string;
120
+ /** Present only on the terminal page of a `changes_since` request. */
121
+ next_changes_since?: string;
122
+ freshness?: PdppFreshness;
123
+ data: Array<PdppRecord | PdppTombstone>;
124
+ meta?: {
125
+ warnings?: PdppWarning[];
126
+ };
127
+ }
128
+ export interface PdppGetRecordParams {
129
+ expand?: string[];
130
+ }
131
+ /** Spec §8 API versioning: request/response header name and stable value used by this client. */
132
+ export declare const PDPP_VERSION_HEADER = "PDPP-Version";
133
+ export declare const PDPP_VERSION = "2026-04-06";
134
+ export declare const PDPP_REQUEST_ID_HEADER = "Request-Id";
135
+ //# sourceMappingURL=pdpp-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdpp-types.d.ts","sourceRoot":"","sources":["../../../src/__fixtures__/cg-pdpp-client/pdpp-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,aAAa,CAAC;QACpB,IAAI,EAAE,aAAa,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC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iBAAiB,CAAC;AAClD,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,sBAAsB,eAAe,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * PDPP Core §8 (Resource Server Interface) request/response types.
3
+ *
4
+ * Cited against `PDP-Connect/pdpp` `apps/site/content/docs/spec-core.md`
5
+ * section 8 (`#resource-server-interface`) as of 2026-09-17. This module is
6
+ * intentionally the *only* place that names PDPP wire shapes for the Client
7
+ * role — do not redeclare `PdppRecord`/`PdppListRecordsResponse`/etc. inline
8
+ * at a call site.
9
+ *
10
+ * PS's actual §8 endpoints have not landed yet (no PR in
11
+ * vana-com/personal-server-ts implements them as of this writing; see
12
+ * `local/conformance-fleet-0917/scope-lanes.md` Lane B/C in the pdpp repo).
13
+ * These types are derived directly from the spec text, not from PS's
14
+ * implementation — per that same plan's warning against reverse-engineering
15
+ * a vendor's behavior instead of the normative document.
16
+ */
17
+ /** Spec §8 API versioning: request/response header name and stable value used by this client. */
18
+ export const PDPP_VERSION_HEADER = "PDPP-Version";
19
+ export const PDPP_VERSION = "2026-04-06";
20
+ export const PDPP_REQUEST_ID_HEADER = "Request-Id";
21
+ //# sourceMappingURL=pdpp-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdpp-types.js","sourceRoot":"","sources":["../../../src/__fixtures__/cg-pdpp-client/pdpp-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAkJH,iGAAiG;AACjG,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAClD,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC"}