@powerhousedao/switchboard 5.1.0-dev.4 → 5.1.0-dev.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,314 @@
1
+ ## 5.1.0-dev.40 (2026-01-10)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **builder-tools:** improved validation on doc model editor and unit tests ([336f5d575](https://github.com/powerhouse-inc/powerhouse/commit/336f5d575))
6
+ - **codegen:** add validation to package json test ([03d06ef57](https://github.com/powerhouse-inc/powerhouse/commit/03d06ef57))
7
+
8
+ ### ❤️ Thank You
9
+
10
+ - acaldas @acaldas
11
+ - ryanwolhuter @ryanwolhuter
12
+
13
+ ## 5.1.0-dev.39 (2026-01-09)
14
+
15
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
16
+
17
+ ## 5.1.0-dev.38 (2026-01-09)
18
+
19
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
20
+
21
+ ## 5.1.0-dev.37 (2026-01-09)
22
+
23
+ ### 🚀 Features
24
+
25
+ - **codegen,ph-cmd:** use templates for project boilerplate creation ([#2190](https://github.com/powerhouse-inc/powerhouse/pull/2190))
26
+
27
+ ### ❤️ Thank You
28
+
29
+ - Ryan Wolhuter @ryanwolhuter
30
+
31
+ ## 5.1.0-dev.36 (2026-01-09)
32
+
33
+ ### 🩹 Fixes
34
+
35
+ - **connect, switchboard:** run pnpm install after ph install in entrypoint ([c4145c07d](https://github.com/powerhouse-inc/powerhouse/commit/c4145c07d))
36
+ - **connect, switchboard:** create .npmrc after ph init and reinstall ([dc78e58f5](https://github.com/powerhouse-inc/powerhouse/commit/dc78e58f5))
37
+ - **connect, switchboard:** create .npmrc with hoisted node-linker before ph init ([4c8cdb1e5](https://github.com/powerhouse-inc/powerhouse/commit/4c8cdb1e5))
38
+ - **connect, switchboard:** scope node-linker hoisted to project only ([948cc7bdf](https://github.com/powerhouse-inc/powerhouse/commit/948cc7bdf))
39
+ - use hoisted node-linker for containerd/k8s compatibility ([5ae9e4abd](https://github.com/powerhouse-inc/powerhouse/commit/5ae9e4abd))
40
+
41
+ ### ❤️ Thank You
42
+
43
+ - Frank
44
+
45
+ ## 5.1.0-dev.35 (2026-01-08)
46
+
47
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
48
+
49
+ ## 5.1.0-dev.34 (2026-01-07)
50
+
51
+ ### 🚀 Features
52
+
53
+ - adding feature flag support for v2 storage ([2f34fff4b](https://github.com/powerhouse-inc/powerhouse/commit/2f34fff4b))
54
+ - **ph-cli:** add index.html migration to migrate command ([#2186](https://github.com/powerhouse-inc/powerhouse/pull/2186))
55
+
56
+ ### ❤️ Thank You
57
+
58
+ - Benjamin Jordan (@thegoldenmule)
59
+ - Ryan Wolhuter @ryanwolhuter
60
+
61
+ ## 5.1.0-dev.33 (2026-01-06)
62
+
63
+ ### 🩹 Fixes
64
+
65
+ - added configuration to debug switchboard, and cleaned up some of the subgraph code ([9ce04c899](https://github.com/powerhouse-inc/powerhouse/commit/9ce04c899))
66
+
67
+ ### ❤️ Thank You
68
+
69
+ - Benjamin Jordan (@thegoldenmule)
70
+
71
+ ## 5.1.0-dev.32 (2026-01-02)
72
+
73
+ ### 🚀 Features
74
+
75
+ - **tracing:** migrate from Datadog to OpenTelemetry with Tempo service graphs ([6b4eb9c82](https://github.com/powerhouse-inc/powerhouse/commit/6b4eb9c82))
76
+
77
+ ### ❤️ Thank You
78
+
79
+ - Frank
80
+
81
+ ## 5.1.0-dev.31 (2026-01-02)
82
+
83
+ ### 🚀 Features
84
+
85
+ - **switchboard:** added tracing ([c978736b7](https://github.com/powerhouse-inc/powerhouse/commit/c978736b7))
86
+
87
+ ### ❤️ Thank You
88
+
89
+ - Frank
90
+
91
+ ## 5.1.0-dev.30 (2026-01-01)
92
+
93
+ ### 🩹 Fixes
94
+
95
+ - **document-drive:** do not export redis cache from index ([38b647cf9](https://github.com/powerhouse-inc/powerhouse/commit/38b647cf9))
96
+
97
+ ### ❤️ Thank You
98
+
99
+ - acaldas @acaldas
100
+
101
+ ## 5.1.0-dev.29 (2025-12-30)
102
+
103
+ ### 🩹 Fixes
104
+
105
+ - **connect,builder-tools,vetra:** avoid page reload on vite HMR ([1c3f5d1dd](https://github.com/powerhouse-inc/powerhouse/commit/1c3f5d1dd))
106
+
107
+ ### ❤️ Thank You
108
+
109
+ - acaldas @acaldas
110
+
111
+ ## 5.1.0-dev.28 (2025-12-30)
112
+
113
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
114
+
115
+ ## 5.1.0-dev.27 (2025-12-24)
116
+
117
+ ### 🚀 Features
118
+
119
+ - **reactor-api:** datadog integration ([3c433c686](https://github.com/powerhouse-inc/powerhouse/commit/3c433c686))
120
+ - **reactor-browser:** improved document retrieval hooks ([4fed49391](https://github.com/powerhouse-inc/powerhouse/commit/4fed49391))
121
+
122
+ ### ❤️ Thank You
123
+
124
+ - acaldas @acaldas
125
+ - Frank
126
+
127
+ ## 5.1.0-dev.26 (2025-12-20)
128
+
129
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
130
+
131
+ ## 5.1.0-dev.25 (2025-12-19)
132
+
133
+ ### 🩹 Fixes
134
+
135
+ - **switchboard, vetra:** fix issue with processors not being added on initial boot ([25432a663](https://github.com/powerhouse-inc/powerhouse/commit/25432a663))
136
+
137
+ ### ❤️ Thank You
138
+
139
+ - Benjamin Jordan (@thegoldenmule)
140
+
141
+ ## 5.1.0-dev.24 (2025-12-18)
142
+
143
+ ### 🩹 Fixes
144
+
145
+ - switchboard's new reactor signs everything ([b7fafb7fa](https://github.com/powerhouse-inc/powerhouse/commit/b7fafb7fa))
146
+ - don't sign default drive header as that changes the id, and pass along the unsigned header to the signed ([d8cd47c9d](https://github.com/powerhouse-inc/powerhouse/commit/d8cd47c9d))
147
+ - addDefaultDrive should not add if the drive already exists ([79352a5f8](https://github.com/powerhouse-inc/powerhouse/commit/79352a5f8))
148
+ - **switchboard:** use pglite inmemory ([f7c926fa9](https://github.com/powerhouse-inc/powerhouse/commit/f7c926fa9))
149
+ - **switchboard:** pglite path ([140422ab6](https://github.com/powerhouse-inc/powerhouse/commit/140422ab6))
150
+ - **switchboard:** use pglite for new reactor ([b5dece44e](https://github.com/powerhouse-inc/powerhouse/commit/b5dece44e))
151
+ - **switchboard:** added skip db migrations flag ([f1597c838](https://github.com/powerhouse-inc/powerhouse/commit/f1597c838))
152
+
153
+ ### ❤️ Thank You
154
+
155
+ - Benjamin Jordan (@thegoldenmule)
156
+ - Frank
157
+
158
+ ## 5.1.0-dev.23 (2025-12-17)
159
+
160
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
161
+
162
+ ## 5.1.0-dev.22 (2025-12-16)
163
+
164
+ ### 🚀 Features
165
+
166
+ - added support for runtime document model subgraphs ([dc8248ec6](https://github.com/powerhouse-inc/powerhouse/commit/dc8248ec6))
167
+
168
+ ### ❤️ Thank You
169
+
170
+ - acaldas @acaldas
171
+
172
+ ## 5.1.0-dev.21 (2025-12-13)
173
+
174
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
175
+
176
+ ## 5.1.0-dev.20 (2025-12-12)
177
+
178
+ ### 🚀 Features
179
+
180
+ - **reactor-browsers:** added onErrors callback to dispatch method ([4824a0a10](https://github.com/powerhouse-inc/powerhouse/commit/4824a0a10))
181
+
182
+ ### ❤️ Thank You
183
+
184
+ - acaldas @acaldas
185
+
186
+ ## 5.1.0-dev.19 (2025-12-12)
187
+
188
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
189
+
190
+ ## 5.1.0-dev.18 (2025-12-11)
191
+
192
+ ### 🚀 Features
193
+
194
+ - **codegen:** add versioned document model generation ([#2130](https://github.com/powerhouse-inc/powerhouse/pull/2130))
195
+
196
+ ### ❤️ Thank You
197
+
198
+ - Ryan Wolhuter @ryanwolhuter
199
+
200
+ ## 5.1.0-dev.17 (2025-12-11)
201
+
202
+ ### 🩹 Fixes
203
+
204
+ - **ph-cli:** auth with access-token ([df48be6e9](https://github.com/powerhouse-inc/powerhouse/commit/df48be6e9))
205
+
206
+ ### ❤️ Thank You
207
+
208
+ - Frank
209
+
210
+ ## 5.1.0-dev.16 (2025-12-11)
211
+
212
+ ### 🚀 Features
213
+
214
+ - **ph-cli:** added access-token command ([e48181df6](https://github.com/powerhouse-inc/powerhouse/commit/e48181df6))
215
+ - **switchboard:** use identity ([1be03ddb7](https://github.com/powerhouse-inc/powerhouse/commit/1be03ddb7))
216
+ - **codegen:** update zod schema generation library ([#2129](https://github.com/powerhouse-inc/powerhouse/pull/2129))
217
+ - integrate visibility tools for remotes and pglite instance ([#2122](https://github.com/powerhouse-inc/powerhouse/pull/2122))
218
+
219
+ ### 🩹 Fixes
220
+
221
+ - backfill tests + create default via new reactor to get create/update ([889d890a3](https://github.com/powerhouse-inc/powerhouse/commit/889d890a3))
222
+ - syncenvelope shape was incorrect ([cc6226be9](https://github.com/powerhouse-inc/powerhouse/commit/cc6226be9))
223
+
224
+ ### ❤️ Thank You
225
+
226
+ - Benjamin Jordan (@thegoldenmule)
227
+ - Frank
228
+ - Guillermo Puente Sandoval @gpuente
229
+ - Ryan Wolhuter @ryanwolhuter
230
+
231
+ ## 5.1.0-dev.15 (2025-12-09)
232
+
233
+ ### 🩹 Fixes
234
+
235
+ - adding powerhouse drive to default options for switchboard when running with pnpm start ([4347307dc](https://github.com/powerhouse-inc/powerhouse/commit/4347307dc))
236
+
237
+ ### ❤️ Thank You
238
+
239
+ - Benjamin Jordan (@thegoldenmule)
240
+
241
+ ## 5.1.0-dev.14 (2025-12-08)
242
+
243
+ ### 🚀 Features
244
+
245
+ - **connect, switchboard:** added healthcheck route ([9a0671113](https://github.com/powerhouse-inc/powerhouse/commit/9a0671113))
246
+ - **academy:** added docker build and publish workflow ([b17562994](https://github.com/powerhouse-inc/powerhouse/commit/b17562994))
247
+
248
+ ### ❤️ Thank You
249
+
250
+ - Frank
251
+
252
+ ## 5.1.0-dev.13 (2025-12-08)
253
+
254
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
255
+
256
+ ## 5.1.0-dev.12 (2025-12-08)
257
+
258
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
259
+
260
+ ## 5.1.0-dev.11 (2025-12-08)
261
+
262
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
263
+
264
+ ## 5.1.0-dev.10 (2025-12-06)
265
+
266
+ ### 🚀 Features
267
+
268
+ - **design-system:** added remotes inspector and channel inspector components ([093896ebf](https://github.com/powerhouse-inc/powerhouse/commit/093896ebf))
269
+
270
+ ### ❤️ Thank You
271
+
272
+ - Guillermo Puente @gpuente
273
+
274
+ ## 5.1.0-dev.9 (2025-12-05)
275
+
276
+ ### 🩹 Fixes
277
+
278
+ - **renown:** small ui fixes and made connectcrypto and renown id available in hooks ([c06e17226](https://github.com/powerhouse-inc/powerhouse/commit/c06e17226))
279
+
280
+ ### ❤️ Thank You
281
+
282
+ - Frank
283
+
284
+ ## 5.1.0-dev.8 (2025-12-05)
285
+
286
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
287
+
288
+ ## 5.1.0-dev.7 (2025-12-04)
289
+
290
+ ### 🩹 Fixes
291
+
292
+ - set jsr as registry in dockerfiles ([291027b16](https://github.com/powerhouse-inc/powerhouse/commit/291027b16))
293
+
294
+ ### ❤️ Thank You
295
+
296
+ - Frank
297
+
298
+ ## 5.1.0-dev.6 (2025-12-04)
299
+
300
+ ### 🩹 Fixes
301
+
302
+ - **renown:** build issues ([1893c35a0](https://github.com/powerhouse-inc/powerhouse/commit/1893c35a0))
303
+
304
+ ### ❤️ Thank You
305
+
306
+ - Frank
307
+
308
+ ## 5.1.0-dev.5 (2025-12-04)
309
+
310
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
311
+
1
312
  ## 5.1.0-dev.4 (2025-12-03)
2
313
 
3
314
  ### 🚀 Features
package/Dockerfile CHANGED
@@ -25,6 +25,7 @@ ENV PH_SWITCHBOARD_GUESTS_LIST="0x123,0x456"
25
25
  # Database
26
26
  ENV PH_SWITCHBOARD_DATABASE_URL="dev.db"
27
27
  ENV PH_SWITCHBOARD_REDIS_URL=""
28
+ ENV SKIP_DB_MIGRATIONS="false"
28
29
 
29
30
  # Heroku Workaround
30
31
  ENV PORT=4001
@@ -36,17 +37,24 @@ ENV PH_SWITCHBOARD_PORT=$PORT
36
37
  ARG TAG=latest
37
38
  ENV TAG=$TAG
38
39
  # RUN apk add --no-cache openssl
40
+ # Configure JSR registry for @jsr scoped packages
41
+ RUN pnpm config set @jsr:registry https://npm.jsr.io
39
42
  RUN pnpm add -g ph-cmd@$TAG prisma@5.17.0
43
+
40
44
  RUN case "$TAG" in \
41
45
  *dev*) ph init project --dev --package-manager pnpm ;; \
42
46
  *staging*) ph init project --staging --package-manager pnpm ;; \
43
47
  *) ph init project --package-manager pnpm ;; \
44
48
  esac
45
49
 
46
-
47
50
  WORKDIR /app/project
48
51
 
49
- # Copy and set up entrypoint script
52
+ # Install curl for health checks
53
+ RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
54
+
55
+ EXPOSE $PORT
50
56
 
57
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
58
+ CMD curl -f http://localhost:${PORT}/health || exit 1
51
59
 
52
60
  ENTRYPOINT ["/app/entrypoint.sh"]
@@ -1,9 +1,11 @@
1
+ import type { DriveInput } from "document-drive";
1
2
  interface Config {
2
3
  database: {
3
4
  url: string;
4
5
  };
5
6
  port: number;
6
7
  mcp: boolean;
8
+ drive: DriveInput;
7
9
  }
8
10
  export declare const config: Config;
9
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAMA,UAAU,MAAM;IACd,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;CACd;AACD,eAAO,MAAM,MAAM,EAAE,MAcpB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,UAAU,MAAM;IACd,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;CACnB;AACD,eAAO,MAAM,MAAM,EAAE,MA4BpB,CAAC"}
@@ -15,5 +15,19 @@ export const config = {
15
15
  ? Number(process.env.PH_SWITCHBOARD_PORT)
16
16
  : (switchboard?.port ?? 4001),
17
17
  mcp: true,
18
+ drive: {
19
+ id: "powerhouse",
20
+ slug: "powerhouse",
21
+ global: {
22
+ name: "Powerhouse",
23
+ icon: "https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7",
24
+ },
25
+ local: {
26
+ availableOffline: true,
27
+ listeners: [],
28
+ sharingType: "public",
29
+ triggers: [],
30
+ },
31
+ },
18
32
  };
19
33
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;AAC7B,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;AAQjC,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,QAAQ,EAAE;QACR,0FAA0F;QAC1F,GAAG,E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,YAAY;YAClB,IAAI,EAAE,qEAAqE;SAC5E;QACD,KAAK,EAAE;YACL,gBAAgB,EAAE,IAAI;YACtB,SAAS,EAAE,EAAE;YACb,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,EAAE;SACb;KACF;CACF,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type IConnectCrypto, type JsonWebKeyPairStorage, type JwkKeyPair } from "@renown/sdk";
2
+ /**
3
+ * Key storage that supports:
4
+ * 1. PH_RENOWN_PRIVATE_KEY environment variable (JSON-encoded JwkKeyPair)
5
+ * 2. Custom file path passed via options
6
+ * 3. Falls back to file storage at .keypair.json in current working directory
7
+ */
8
+ export declare class SwitchboardKeyStorage implements JsonWebKeyPairStorage {
9
+ #private;
10
+ constructor(filePath?: string);
11
+ loadKeyPair(): Promise<JwkKeyPair | undefined>;
12
+ saveKeyPair(keyPair: JwkKeyPair): Promise<void>;
13
+ }
14
+ export interface ConnectCryptoOptions {
15
+ /** Path to the keypair file. Defaults to .keypair.json in cwd */
16
+ keypairPath?: string;
17
+ /** If true, won't generate a new keypair if none exists */
18
+ requireExisting?: boolean;
19
+ }
20
+ /**
21
+ * Initialize ConnectCrypto for the switchboard.
22
+ * This allows the switchboard to authenticate with remote services
23
+ * using the same identity established during `ph login`.
24
+ */
25
+ export declare function initConnectCrypto(options?: ConnectCryptoOptions): Promise<IConnectCrypto | null>;
26
+ /**
27
+ * Get the current ConnectCrypto instance.
28
+ * Returns null if not initialized.
29
+ */
30
+ export declare function getConnectCrypto(): IConnectCrypto | null;
31
+ /**
32
+ * Get the DID of the current ConnectCrypto instance.
33
+ * Returns null if not initialized.
34
+ */
35
+ export declare function getConnectDid(): Promise<string | null>;
36
+ /**
37
+ * Get a bearer token for authenticating with remote services.
38
+ * Returns null if ConnectCrypto is not initialized.
39
+ */
40
+ export declare function getBearerToken(driveUrl: string, address?: string, refresh?: boolean): Promise<string | null>;
41
+ //# sourceMappingURL=connect-crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-crypto.d.ts","sourceRoot":"","sources":["../../src/connect-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAUrB;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,qBAAqB;;gBAGrD,QAAQ,CAAC,EAAE,MAAM;IAUvB,WAAW,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAuB9C,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAgCtD;AAKD,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA0BhC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,cAAc,GAAG,IAAI,CAExD;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAK5D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,UAAQ,GACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxB"}
@@ -0,0 +1,127 @@
1
+ import { ConnectCrypto, } from "@renown/sdk";
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { childLogger } from "document-drive";
5
+ const logger = childLogger(["switchboard", "connect-crypto"]);
6
+ const ENV_KEY_NAME = "PH_RENOWN_PRIVATE_KEY";
7
+ const DEFAULT_KEYPAIR_PATH = join(process.cwd(), ".keypair.json");
8
+ /**
9
+ * Key storage that supports:
10
+ * 1. PH_RENOWN_PRIVATE_KEY environment variable (JSON-encoded JwkKeyPair)
11
+ * 2. Custom file path passed via options
12
+ * 3. Falls back to file storage at .keypair.json in current working directory
13
+ */
14
+ export class SwitchboardKeyStorage {
15
+ #filePath;
16
+ constructor(filePath) {
17
+ this.#filePath = filePath || DEFAULT_KEYPAIR_PATH;
18
+ // Ensure directory exists
19
+ const dir = dirname(this.#filePath);
20
+ if (!existsSync(dir)) {
21
+ mkdirSync(dir, { recursive: true });
22
+ }
23
+ }
24
+ async loadKeyPair() {
25
+ // First check environment variable
26
+ const envKey = process.env[ENV_KEY_NAME];
27
+ if (envKey) {
28
+ try {
29
+ const keyPair = JSON.parse(envKey);
30
+ // Validate it has the required structure
31
+ if (keyPair.publicKey && keyPair.privateKey) {
32
+ logger.debug("Loaded keypair from environment variable");
33
+ return keyPair;
34
+ }
35
+ logger.warn(`${ENV_KEY_NAME} is set but doesn't contain valid publicKey and privateKey`);
36
+ }
37
+ catch (e) {
38
+ logger.warn(`Failed to parse ${ENV_KEY_NAME} as JSON:`, e);
39
+ }
40
+ }
41
+ // Fall back to file storage
42
+ return this.#loadFromFile();
43
+ }
44
+ async saveKeyPair(keyPair) {
45
+ // Don't save if using env var
46
+ if (process.env[ENV_KEY_NAME]) {
47
+ return;
48
+ }
49
+ // Save to file
50
+ this.#saveToFile(keyPair);
51
+ }
52
+ #loadFromFile() {
53
+ try {
54
+ if (!existsSync(this.#filePath)) {
55
+ return undefined;
56
+ }
57
+ const data = readFileSync(this.#filePath, "utf-8");
58
+ const parsed = JSON.parse(data);
59
+ const keyPair = parsed.keyPair;
60
+ if (keyPair) {
61
+ logger.debug(`Loaded keypair from ${this.#filePath}`);
62
+ }
63
+ return keyPair;
64
+ }
65
+ catch {
66
+ return undefined;
67
+ }
68
+ }
69
+ #saveToFile(keyPair) {
70
+ const data = { keyPair };
71
+ writeFileSync(this.#filePath, JSON.stringify(data, null, 2), "utf-8");
72
+ logger.debug(`Saved keypair to ${this.#filePath}`);
73
+ }
74
+ }
75
+ // Singleton instance of ConnectCrypto for the switchboard
76
+ let connectCryptoInstance = null;
77
+ /**
78
+ * Initialize ConnectCrypto for the switchboard.
79
+ * This allows the switchboard to authenticate with remote services
80
+ * using the same identity established during `ph login`.
81
+ */
82
+ export async function initConnectCrypto(options = {}) {
83
+ const { keypairPath, requireExisting = false } = options;
84
+ const keyStorage = new SwitchboardKeyStorage(keypairPath);
85
+ // Check if we have an existing keypair
86
+ const existingKeyPair = await keyStorage.loadKeyPair();
87
+ if (!existingKeyPair && requireExisting) {
88
+ logger.warn("No existing keypair found and requireExisting is true. " +
89
+ 'Run "ph login" to create one.');
90
+ return null;
91
+ }
92
+ if (!existingKeyPair) {
93
+ logger.info("No existing keypair found. A new one will be generated.");
94
+ }
95
+ connectCryptoInstance = new ConnectCrypto(keyStorage);
96
+ const did = await connectCryptoInstance.did();
97
+ logger.info(`Switchboard identity initialized: ${did}`);
98
+ return connectCryptoInstance;
99
+ }
100
+ /**
101
+ * Get the current ConnectCrypto instance.
102
+ * Returns null if not initialized.
103
+ */
104
+ export function getConnectCrypto() {
105
+ return connectCryptoInstance;
106
+ }
107
+ /**
108
+ * Get the DID of the current ConnectCrypto instance.
109
+ * Returns null if not initialized.
110
+ */
111
+ export async function getConnectDid() {
112
+ if (!connectCryptoInstance) {
113
+ return null;
114
+ }
115
+ return connectCryptoInstance.did();
116
+ }
117
+ /**
118
+ * Get a bearer token for authenticating with remote services.
119
+ * Returns null if ConnectCrypto is not initialized.
120
+ */
121
+ export async function getBearerToken(driveUrl, address, refresh = false) {
122
+ if (!connectCryptoInstance) {
123
+ return null;
124
+ }
125
+ return connectCryptoInstance.getBearerToken(driveUrl, address, refresh);
126
+ }
127
+ //# sourceMappingURL=connect-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-crypto.js","sourceRoot":"","sources":["../../src/connect-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAId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;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,qBAAqB,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC"}
@@ -1,4 +1,2 @@
1
1
  export declare function initFeatureFlags(): Promise<import("@openfeature/server-sdk").Client>;
2
- export declare function isReactorv2Enabled(): Promise<boolean>;
3
- export declare function isDualActionCreateEnabled(): Promise<boolean>;
4
2
  //# sourceMappingURL=feature-flags.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../src/feature-flags.ts"],"names":[],"mappings":"AAGA,wBAAsB,gBAAgB,sDAOrC;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAG3D;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAMlE"}
1
+ {"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../src/feature-flags.ts"],"names":[],"mappings":"AAGA,wBAAsB,gBAAgB,sDAOrC"}
@@ -6,12 +6,4 @@ export async function initFeatureFlags() {
6
6
  await OpenFeature.setProviderAndWait(provider);
7
7
  return OpenFeature.getClient();
8
8
  }
9
- export async function isReactorv2Enabled() {
10
- const client = OpenFeature.getClient();
11
- return await client.getBooleanValue("FEATURE_REACTORV2_ENABLED", false);
12
- }
13
- export async function isDualActionCreateEnabled() {
14
- const client = OpenFeature.getClient();
15
- return await client.getBooleanValue("FEATURE_DUAL_ACTION_CREATE_ENABLED", false);
16
- }
17
9
  //# sourceMappingURL=feature-flags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../../src/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,uDAAuD;IACvD,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IAEtC,MAAM,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE/C,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;IACvC,OAAO,MAAM,MAAM,CAAC,eAAe,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;IACvC,OAAO,MAAM,MAAM,CAAC,eAAe,CACjC,oCAAoC,EACpC,KAAK,CACN,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../../src/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,uDAAuD;IACvD,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IAEtC,MAAM,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE/C,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import type { StartServerOptions, SwitchboardReactor } from "./types.js";
3
3
  export declare const startSwitchboard: (options?: StartServerOptions) => Promise<SwitchboardReactor>;
4
+ export { getBearerToken, getConnectCrypto, getConnectDid, } from "./connect-crypto.js";
4
5
  export * from "./types.js";
5
6
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";AAqCA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAsOzE,eAAO,MAAM,gBAAgB,GAC3B,UAAS,kBAAuB,KAC/B,OAAO,CAAC,kBAAkB,CAgC5B,CAAC;AAEF,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";AA0CA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAqRzE,eAAO,MAAM,gBAAgB,GAC3B,UAAS,kBAAuB,KAC/B,OAAO,CAAC,kBAAkB,CA+D5B,CAAC;AAEF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC"}