@powerhousedao/switchboard 5.1.0-dev.3 → 5.1.0-dev.31

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,244 @@
1
+ ## 5.1.0-dev.31 (2026-01-02)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **switchboard:** added tracing ([c978736b7](https://github.com/powerhouse-inc/powerhouse/commit/c978736b7))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Frank
10
+
11
+ ## 5.1.0-dev.30 (2026-01-01)
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **document-drive:** do not export redis cache from index ([38b647cf9](https://github.com/powerhouse-inc/powerhouse/commit/38b647cf9))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - acaldas @acaldas
20
+
21
+ ## 5.1.0-dev.29 (2025-12-30)
22
+
23
+ ### 🩹 Fixes
24
+
25
+ - **connect,builder-tools,vetra:** avoid page reload on vite HMR ([1c3f5d1dd](https://github.com/powerhouse-inc/powerhouse/commit/1c3f5d1dd))
26
+
27
+ ### ❤️ Thank You
28
+
29
+ - acaldas @acaldas
30
+
31
+ ## 5.1.0-dev.28 (2025-12-30)
32
+
33
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
34
+
35
+ ## 5.1.0-dev.27 (2025-12-24)
36
+
37
+ ### 🚀 Features
38
+
39
+ - **reactor-api:** datadog integration ([3c433c686](https://github.com/powerhouse-inc/powerhouse/commit/3c433c686))
40
+ - **reactor-browser:** improved document retrieval hooks ([4fed49391](https://github.com/powerhouse-inc/powerhouse/commit/4fed49391))
41
+
42
+ ### ❤️ Thank You
43
+
44
+ - acaldas @acaldas
45
+ - Frank
46
+
47
+ ## 5.1.0-dev.26 (2025-12-20)
48
+
49
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
50
+
51
+ ## 5.1.0-dev.25 (2025-12-19)
52
+
53
+ ### 🩹 Fixes
54
+
55
+ - **switchboard, vetra:** fix issue with processors not being added on initial boot ([25432a663](https://github.com/powerhouse-inc/powerhouse/commit/25432a663))
56
+
57
+ ### ❤️ Thank You
58
+
59
+ - Benjamin Jordan (@thegoldenmule)
60
+
61
+ ## 5.1.0-dev.24 (2025-12-18)
62
+
63
+ ### 🩹 Fixes
64
+
65
+ - switchboard's new reactor signs everything ([b7fafb7fa](https://github.com/powerhouse-inc/powerhouse/commit/b7fafb7fa))
66
+ - 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))
67
+ - addDefaultDrive should not add if the drive already exists ([79352a5f8](https://github.com/powerhouse-inc/powerhouse/commit/79352a5f8))
68
+ - **switchboard:** use pglite inmemory ([f7c926fa9](https://github.com/powerhouse-inc/powerhouse/commit/f7c926fa9))
69
+ - **switchboard:** pglite path ([140422ab6](https://github.com/powerhouse-inc/powerhouse/commit/140422ab6))
70
+ - **switchboard:** use pglite for new reactor ([b5dece44e](https://github.com/powerhouse-inc/powerhouse/commit/b5dece44e))
71
+ - **switchboard:** added skip db migrations flag ([f1597c838](https://github.com/powerhouse-inc/powerhouse/commit/f1597c838))
72
+
73
+ ### ❤️ Thank You
74
+
75
+ - Benjamin Jordan (@thegoldenmule)
76
+ - Frank
77
+
78
+ ## 5.1.0-dev.23 (2025-12-17)
79
+
80
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
81
+
82
+ ## 5.1.0-dev.22 (2025-12-16)
83
+
84
+ ### 🚀 Features
85
+
86
+ - added support for runtime document model subgraphs ([dc8248ec6](https://github.com/powerhouse-inc/powerhouse/commit/dc8248ec6))
87
+
88
+ ### ❤️ Thank You
89
+
90
+ - acaldas @acaldas
91
+
92
+ ## 5.1.0-dev.21 (2025-12-13)
93
+
94
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
95
+
96
+ ## 5.1.0-dev.20 (2025-12-12)
97
+
98
+ ### 🚀 Features
99
+
100
+ - **reactor-browsers:** added onErrors callback to dispatch method ([4824a0a10](https://github.com/powerhouse-inc/powerhouse/commit/4824a0a10))
101
+
102
+ ### ❤️ Thank You
103
+
104
+ - acaldas @acaldas
105
+
106
+ ## 5.1.0-dev.19 (2025-12-12)
107
+
108
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
109
+
110
+ ## 5.1.0-dev.18 (2025-12-11)
111
+
112
+ ### 🚀 Features
113
+
114
+ - **codegen:** add versioned document model generation ([#2130](https://github.com/powerhouse-inc/powerhouse/pull/2130))
115
+
116
+ ### ❤️ Thank You
117
+
118
+ - Ryan Wolhuter @ryanwolhuter
119
+
120
+ ## 5.1.0-dev.17 (2025-12-11)
121
+
122
+ ### 🩹 Fixes
123
+
124
+ - **ph-cli:** auth with access-token ([df48be6e9](https://github.com/powerhouse-inc/powerhouse/commit/df48be6e9))
125
+
126
+ ### ❤️ Thank You
127
+
128
+ - Frank
129
+
130
+ ## 5.1.0-dev.16 (2025-12-11)
131
+
132
+ ### 🚀 Features
133
+
134
+ - **ph-cli:** added access-token command ([e48181df6](https://github.com/powerhouse-inc/powerhouse/commit/e48181df6))
135
+ - **switchboard:** use identity ([1be03ddb7](https://github.com/powerhouse-inc/powerhouse/commit/1be03ddb7))
136
+ - **codegen:** update zod schema generation library ([#2129](https://github.com/powerhouse-inc/powerhouse/pull/2129))
137
+ - integrate visibility tools for remotes and pglite instance ([#2122](https://github.com/powerhouse-inc/powerhouse/pull/2122))
138
+
139
+ ### 🩹 Fixes
140
+
141
+ - backfill tests + create default via new reactor to get create/update ([889d890a3](https://github.com/powerhouse-inc/powerhouse/commit/889d890a3))
142
+ - syncenvelope shape was incorrect ([cc6226be9](https://github.com/powerhouse-inc/powerhouse/commit/cc6226be9))
143
+
144
+ ### ❤️ Thank You
145
+
146
+ - Benjamin Jordan (@thegoldenmule)
147
+ - Frank
148
+ - Guillermo Puente Sandoval @gpuente
149
+ - Ryan Wolhuter @ryanwolhuter
150
+
151
+ ## 5.1.0-dev.15 (2025-12-09)
152
+
153
+ ### 🩹 Fixes
154
+
155
+ - adding powerhouse drive to default options for switchboard when running with pnpm start ([4347307dc](https://github.com/powerhouse-inc/powerhouse/commit/4347307dc))
156
+
157
+ ### ❤️ Thank You
158
+
159
+ - Benjamin Jordan (@thegoldenmule)
160
+
161
+ ## 5.1.0-dev.14 (2025-12-08)
162
+
163
+ ### 🚀 Features
164
+
165
+ - **connect, switchboard:** added healthcheck route ([9a0671113](https://github.com/powerhouse-inc/powerhouse/commit/9a0671113))
166
+ - **academy:** added docker build and publish workflow ([b17562994](https://github.com/powerhouse-inc/powerhouse/commit/b17562994))
167
+
168
+ ### ❤️ Thank You
169
+
170
+ - Frank
171
+
172
+ ## 5.1.0-dev.13 (2025-12-08)
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.12 (2025-12-08)
177
+
178
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
179
+
180
+ ## 5.1.0-dev.11 (2025-12-08)
181
+
182
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
183
+
184
+ ## 5.1.0-dev.10 (2025-12-06)
185
+
186
+ ### 🚀 Features
187
+
188
+ - **design-system:** added remotes inspector and channel inspector components ([093896ebf](https://github.com/powerhouse-inc/powerhouse/commit/093896ebf))
189
+
190
+ ### ❤️ Thank You
191
+
192
+ - Guillermo Puente @gpuente
193
+
194
+ ## 5.1.0-dev.9 (2025-12-05)
195
+
196
+ ### 🩹 Fixes
197
+
198
+ - **renown:** small ui fixes and made connectcrypto and renown id available in hooks ([c06e17226](https://github.com/powerhouse-inc/powerhouse/commit/c06e17226))
199
+
200
+ ### ❤️ Thank You
201
+
202
+ - Frank
203
+
204
+ ## 5.1.0-dev.8 (2025-12-05)
205
+
206
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
207
+
208
+ ## 5.1.0-dev.7 (2025-12-04)
209
+
210
+ ### 🩹 Fixes
211
+
212
+ - set jsr as registry in dockerfiles ([291027b16](https://github.com/powerhouse-inc/powerhouse/commit/291027b16))
213
+
214
+ ### ❤️ Thank You
215
+
216
+ - Frank
217
+
218
+ ## 5.1.0-dev.6 (2025-12-04)
219
+
220
+ ### 🩹 Fixes
221
+
222
+ - **renown:** build issues ([1893c35a0](https://github.com/powerhouse-inc/powerhouse/commit/1893c35a0))
223
+
224
+ ### ❤️ Thank You
225
+
226
+ - Frank
227
+
228
+ ## 5.1.0-dev.5 (2025-12-04)
229
+
230
+ This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
231
+
232
+ ## 5.1.0-dev.4 (2025-12-03)
233
+
234
+ ### 🚀 Features
235
+
236
+ - **codegen,ph-cli:** add tsx code generator ([#2116](https://github.com/powerhouse-inc/powerhouse/pull/2116))
237
+
238
+ ### ❤️ Thank You
239
+
240
+ - Ryan Wolhuter @ryanwolhuter
241
+
1
242
  ## 5.1.0-dev.3 (2025-12-02)
2
243
 
3
244
  This was a version bump only for @powerhousedao/switchboard to align it with other projects, there were no code changes.
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,6 +37,8 @@ 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
40
43
  RUN case "$TAG" in \
41
44
  *dev*) ph init project --dev --package-manager pnpm ;; \
@@ -46,7 +49,12 @@ RUN case "$TAG" in \
46
49
 
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/*
50
54
 
55
+ EXPOSE $PORT
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,EACD,OAAO,CAAC,GAAG,CAAC,2BAA2B;YACvC,WAAW,EAAE,QAAQ,EAAE,GAAG;YAC1B,QAAQ;KACX;IACD,IAAI,EACF,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAC/B,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC7C,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QACzC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,IAAI,IAAI,CAAC;IACjC,GAAG,EAAE,IAAI;CACV,CAAC"}
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;AAEvD,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;AAC7B,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;AASjC,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,QAAQ,EAAE;QACR,0FAA0F;QAC1F,GAAG,EACD,OAAO,CAAC,GAAG,CAAC,2BAA2B;YACvC,WAAW,EAAE,QAAQ,EAAE,GAAG;YAC1B,QAAQ;KACX;IACD,IAAI,EACF,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAC/B,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC7C,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QACzC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,IAAI,IAAI,CAAC;IACjC,GAAG,EAAE,IAAI;IACT,KAAK,EAAE;QACL,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE;YACN,IAAI,EAAE,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,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE9D,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAChC,SAAS,CAAS;IAElB,YAAY,QAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,QAAQ,IAAI,oBAAoB,CAAC;QAElD,0BAA0B;QAC1B,MAAM,GAAG,GAAG,OAAO,CAAC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;IAED,qBAAqB,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,GAAG,EAAE,CAAC;IAC9C,MAAM,CAAC,IAAI,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;IAExD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,qBAAqB,CAAC,GAAG,EAAE,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,OAAgB,EAChB,OAAO,GAAG,KAAK;IAEf,IAAI,CAAC,qBAAqB,EAAE,CAAC;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,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import "./tracing.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ // Initialize OpenTelemetry tracing first (before any other imports)
3
+ import "./tracing.js";
2
4
  import { config } from "./config.js";
3
5
  import { startSwitchboard } from "./server.js";
4
6
  function ensureNodeVersion(minVersion = "22") {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,SAAS,iBAAiB,CAAC,UAAU,GAAG,IAAI;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CACX,gBAAgB,UAAU,4CAA4C,OAAO,EAAE,CAChF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AACD,iCAAiC;AACjC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAExB,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,oEAAoE;AACpE,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,SAAS,iBAAiB,CAAC,UAAU,GAAG,IAAI;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CACX,gBAAgB,UAAU,4CAA4C,OAAO,EAAE,CAChF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AACD,iCAAiC;AACjC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAExB,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,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":";AAyCA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAmRzE,eAAO,MAAM,gBAAgB,GAC3B,UAAS,kBAAuB,KAC/B,OAAO,CAAC,kBAAkB,CA8C5B,CAAC;AAEF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC"}