@dreamboard-games/cli 0.1.30-alpha.12 → 0.1.30-alpha.15

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 (143) hide show
  1. package/README.md +2 -6
  2. package/dist/agent-verifier/agent-workspace-verifier.mjs +18 -17
  3. package/dist/agent-verifier/agent-workspace-verifier.mjs.map +1 -1
  4. package/dist/agent-verifier/{chunk-VLOIZDR6.mjs → chunk-4BECKTAF.mjs} +199 -190
  5. package/dist/agent-verifier/chunk-4BECKTAF.mjs.map +1 -0
  6. package/dist/agent-verifier/{chunk-TLYGTHXU.mjs → chunk-5GCZZ6NW.mjs} +3 -3
  7. package/dist/agent-verifier/{chunk-YR664DJX.mjs → chunk-A67WUYN2.mjs} +42 -68
  8. package/dist/agent-verifier/chunk-A67WUYN2.mjs.map +1 -0
  9. package/dist/agent-verifier/chunk-AXXUGU7Q.mjs +255 -0
  10. package/dist/agent-verifier/chunk-AXXUGU7Q.mjs.map +1 -0
  11. package/dist/agent-verifier/chunk-CO3BRUD6.mjs +342 -0
  12. package/dist/agent-verifier/chunk-CO3BRUD6.mjs.map +1 -0
  13. package/dist/agent-verifier/chunk-DPYC2NDB.mjs +59 -0
  14. package/dist/agent-verifier/chunk-DPYC2NDB.mjs.map +1 -0
  15. package/dist/agent-verifier/{chunk-4GU3PCHV.mjs → chunk-DWLTCUUX.mjs} +576 -393
  16. package/dist/agent-verifier/chunk-DWLTCUUX.mjs.map +1 -0
  17. package/dist/agent-verifier/{chunk-COB56ESI.mjs → chunk-G2ECODRB.mjs} +2 -2
  18. package/dist/agent-verifier/{chunk-6XRC5PWB.mjs → chunk-H3XNWKJU.mjs} +217 -232
  19. package/dist/agent-verifier/chunk-H3XNWKJU.mjs.map +1 -0
  20. package/dist/agent-verifier/{chunk-Z6OZWUIZ.mjs → chunk-HLHT57AW.mjs} +64 -16
  21. package/dist/agent-verifier/chunk-HLHT57AW.mjs.map +1 -0
  22. package/dist/agent-verifier/{chunk-YDIOW2BO.mjs → chunk-INIK6LHK.mjs} +2 -2
  23. package/dist/agent-verifier/{chunk-UWJIZML3.mjs → chunk-LKQ557TJ.mjs} +30 -23
  24. package/dist/agent-verifier/chunk-LKQ557TJ.mjs.map +1 -0
  25. package/dist/agent-verifier/{chunk-NAK77WXW.mjs → chunk-MYMVXTZT.mjs} +4 -5
  26. package/dist/agent-verifier/chunk-MYMVXTZT.mjs.map +1 -0
  27. package/dist/agent-verifier/{chunk-UIJ2NDG6.mjs → chunk-NFL3Z4Z7.mjs} +31 -238
  28. package/dist/agent-verifier/chunk-NFL3Z4Z7.mjs.map +1 -0
  29. package/dist/agent-verifier/{chunk-XKCJBIRY.mjs → chunk-QD4SQNUP.mjs} +2 -2
  30. package/dist/agent-verifier/{chunk-IAYRNVUC.mjs → chunk-RDYXWXXC.mjs} +1 -3
  31. package/dist/agent-verifier/{chunk-QBAF7EYR.mjs → chunk-TTB7AIHZ.mjs} +4 -4
  32. package/dist/agent-verifier/{chunk-QBAF7EYR.mjs.map → chunk-TTB7AIHZ.mjs.map} +1 -1
  33. package/dist/agent-verifier/chunk-V6AQDR7W.mjs +89 -0
  34. package/dist/agent-verifier/chunk-V6AQDR7W.mjs.map +1 -0
  35. package/dist/agent-verifier/{chunk-RHI6S4SU.mjs → chunk-V7ABTZXW.mjs} +1 -3
  36. package/dist/agent-verifier/{chunk-RHI6S4SU.mjs.map → chunk-V7ABTZXW.mjs.map} +1 -1
  37. package/dist/agent-verifier/chunk-WAFBU5U7.mjs +467 -0
  38. package/dist/agent-verifier/chunk-WAFBU5U7.mjs.map +1 -0
  39. package/dist/agent-verifier/{chunk-3IJBOLGT.mjs → chunk-WSIYUUSD.mjs} +2 -2
  40. package/dist/agent-verifier/{compile-WZ7X6I2A.mjs → compile-6G6GENLP.mjs} +22 -18
  41. package/dist/agent-verifier/compile-6G6GENLP.mjs.map +1 -0
  42. package/dist/agent-verifier/{global-config-XHL7BCKN.mjs → global-config-6UGFPLDA.mjs} +4 -3
  43. package/dist/agent-verifier/{keychain-backend-A3MRWLPF.mjs → keychain-backend-BQLW5VEC.mjs} +11 -6
  44. package/dist/agent-verifier/keychain-backend-BQLW5VEC.mjs.map +1 -0
  45. package/dist/agent-verifier/{local-files-ZW52HSVT.mjs → local-files-WPHUV6GU.mjs} +6 -6
  46. package/dist/agent-verifier/{materialize-workspace-BKZLLFI4.mjs → materialize-workspace-S24JA46C.mjs} +17 -17
  47. package/dist/agent-verifier/materialize-workspace-S24JA46C.mjs.map +1 -0
  48. package/dist/agent-verifier/{reducer-bundle-preflight-7NYZF5ZT.mjs → reducer-bundle-preflight-3DSXIELT.mjs} +4 -4
  49. package/dist/agent-verifier/reducer-contract-preflight-FQB7M4PU.mjs +11 -0
  50. package/dist/agent-verifier/{reducer-native-test-harness-D4VWPIAC.mjs → reducer-native-test-harness-GY2CCQWN.mjs} +12 -9
  51. package/dist/agent-verifier/{static-scaffold-JCRBDKEH.mjs → static-scaffold-5YD6QHIS.mjs} +7 -9
  52. package/dist/agent-verifier/{sync-ELLJEWMB.mjs → sync-3OZBFABA.mjs} +24 -22
  53. package/dist/agent-verifier/{sync-ELLJEWMB.mjs.map → sync-3OZBFABA.mjs.map} +1 -1
  54. package/dist/agent-verifier/{test-OSXBPLSP.mjs → test-LQAGEQLY.mjs} +19 -17
  55. package/dist/agent-verifier/test-LQAGEQLY.mjs.map +1 -0
  56. package/dist/agent-verifier/{workspace-codegen-WPZHMATU.mjs → workspace-codegen-4IWICKLB.mjs} +3 -3
  57. package/dist/agent-verifier/{workspace-dependencies-ULZZZPNX.mjs → workspace-dependencies-ZMHPHVQV.mjs} +2 -2
  58. package/dist/authoring-compatibility-internal.js +12 -0
  59. package/dist/{agent-verifier/chunk-W2MDP5ZN.mjs → chunk-AVOAT522.js} +118 -21
  60. package/dist/chunk-AVOAT522.js.map +1 -0
  61. package/dist/chunk-FFO2IJL3.js +204 -0
  62. package/dist/chunk-FFO2IJL3.js.map +1 -0
  63. package/dist/chunk-JMV5ZFMK.js +4298 -0
  64. package/dist/chunk-JMV5ZFMK.js.map +1 -0
  65. package/dist/{chunk-P5TITCD3.js → chunk-JSF7PMIF.js} +2240 -4554
  66. package/dist/chunk-JSF7PMIF.js.map +1 -0
  67. package/dist/{global-config-WPJRXVDO.js → global-config-NLGAFSRU.js} +3 -2
  68. package/dist/global-config-NLGAFSRU.js.map +1 -0
  69. package/dist/index.js +1371 -3545
  70. package/dist/index.js.map +1 -1
  71. package/dist/internal.js +14 -8
  72. package/dist/{keychain-backend-JHTXAKWC.js → keychain-backend-47LZ5IX5.js} +11 -6
  73. package/dist/keychain-backend-47LZ5IX5.js.map +1 -0
  74. package/package.json +9 -19
  75. package/release/authoring-release-set.json +38 -0
  76. package/skills/dreamboard/references/manifest-authoring.md +11 -3
  77. package/dist/agent-verifier/chunk-4GU3PCHV.mjs.map +0 -1
  78. package/dist/agent-verifier/chunk-6XRC5PWB.mjs.map +0 -1
  79. package/dist/agent-verifier/chunk-G42BGGG2.mjs +0 -70
  80. package/dist/agent-verifier/chunk-G42BGGG2.mjs.map +0 -1
  81. package/dist/agent-verifier/chunk-KK47X7RV.mjs +0 -14
  82. package/dist/agent-verifier/chunk-KK47X7RV.mjs.map +0 -1
  83. package/dist/agent-verifier/chunk-NAK77WXW.mjs.map +0 -1
  84. package/dist/agent-verifier/chunk-UIJ2NDG6.mjs.map +0 -1
  85. package/dist/agent-verifier/chunk-UWJIZML3.mjs.map +0 -1
  86. package/dist/agent-verifier/chunk-VLOIZDR6.mjs.map +0 -1
  87. package/dist/agent-verifier/chunk-W2MDP5ZN.mjs.map +0 -1
  88. package/dist/agent-verifier/chunk-YR664DJX.mjs.map +0 -1
  89. package/dist/agent-verifier/chunk-Z6OZWUIZ.mjs.map +0 -1
  90. package/dist/agent-verifier/compile-WZ7X6I2A.mjs.map +0 -1
  91. package/dist/agent-verifier/keychain-backend-A3MRWLPF.mjs.map +0 -1
  92. package/dist/agent-verifier/materialize-workspace-BKZLLFI4.mjs.map +0 -1
  93. package/dist/agent-verifier/reducer-contract-preflight-COD2CO22.mjs +0 -11
  94. package/dist/agent-verifier/test-OSXBPLSP.mjs.map +0 -1
  95. package/dist/chunk-GXM7RRZJ.js +0 -433
  96. package/dist/chunk-GXM7RRZJ.js.map +0 -1
  97. package/dist/chunk-P5TITCD3.js.map +0 -1
  98. package/dist/dev-host/components/drawer.tsx +0 -132
  99. package/dist/dev-host/components/input.tsx +0 -21
  100. package/dist/dev-host/dev-api-proxy-plugin.ts +0 -328
  101. package/dist/dev-host/dev-author-dom-warnings.ts +0 -100
  102. package/dist/dev-host/dev-diagnostics.ts +0 -62
  103. package/dist/dev-host/dev-fallback-stylesheet.ts +0 -53
  104. package/dist/dev-host/dev-hmr-guard-plugin.ts +0 -47
  105. package/dist/dev-host/dev-host-controller.ts +0 -674
  106. package/dist/dev-host/dev-host-player-query.ts +0 -17
  107. package/dist/dev-host/dev-host-session-transport.ts +0 -52
  108. package/dist/dev-host/dev-host-storage.ts +0 -56
  109. package/dist/dev-host/dev-log-relay-plugin.ts +0 -510
  110. package/dist/dev-host/dev-runtime-config.ts +0 -14
  111. package/dist/dev-host/dev-runtime-platform.ts +0 -335
  112. package/dist/dev-host/dev-virtual-modules-plugin.ts +0 -64
  113. package/dist/dev-host/host-main.css +0 -224
  114. package/dist/dev-host/host-main.tsx +0 -954
  115. package/dist/dev-host/index.html +0 -56
  116. package/dist/dev-host/lib/utils.ts +0 -6
  117. package/dist/dev-host/plugin-main.ts +0 -61
  118. package/dist/dev-host/plugin.html +0 -24
  119. package/dist/dev-host/shared-styles.css +0 -144
  120. package/dist/dev-host/start-dev-server.ts +0 -140
  121. package/dist/dev-host/virtual-modules.d.ts +0 -27
  122. package/dist/keychain-backend-JHTXAKWC.js.map +0 -1
  123. /package/dist/agent-verifier/{chunk-TLYGTHXU.mjs.map → chunk-5GCZZ6NW.mjs.map} +0 -0
  124. /package/dist/agent-verifier/{chunk-COB56ESI.mjs.map → chunk-G2ECODRB.mjs.map} +0 -0
  125. /package/dist/agent-verifier/{chunk-YDIOW2BO.mjs.map → chunk-INIK6LHK.mjs.map} +0 -0
  126. /package/dist/agent-verifier/{chunk-XKCJBIRY.mjs.map → chunk-QD4SQNUP.mjs.map} +0 -0
  127. /package/dist/agent-verifier/{chunk-IAYRNVUC.mjs.map → chunk-RDYXWXXC.mjs.map} +0 -0
  128. /package/dist/agent-verifier/{chunk-3IJBOLGT.mjs.map → chunk-WSIYUUSD.mjs.map} +0 -0
  129. /package/dist/agent-verifier/{global-config-XHL7BCKN.mjs.map → global-config-6UGFPLDA.mjs.map} +0 -0
  130. /package/dist/agent-verifier/{local-files-ZW52HSVT.mjs.map → local-files-WPHUV6GU.mjs.map} +0 -0
  131. /package/dist/agent-verifier/{reducer-bundle-preflight-7NYZF5ZT.mjs.map → reducer-bundle-preflight-3DSXIELT.mjs.map} +0 -0
  132. /package/dist/agent-verifier/{reducer-contract-preflight-COD2CO22.mjs.map → reducer-contract-preflight-FQB7M4PU.mjs.map} +0 -0
  133. /package/dist/agent-verifier/{reducer-native-test-harness-D4VWPIAC.mjs.map → reducer-native-test-harness-GY2CCQWN.mjs.map} +0 -0
  134. /package/dist/agent-verifier/{static-scaffold-JCRBDKEH.mjs.map → static-scaffold-5YD6QHIS.mjs.map} +0 -0
  135. /package/dist/agent-verifier/{workspace-codegen-WPZHMATU.mjs.map → workspace-codegen-4IWICKLB.mjs.map} +0 -0
  136. /package/dist/agent-verifier/{workspace-dependencies-ULZZZPNX.mjs.map → workspace-dependencies-ZMHPHVQV.mjs.map} +0 -0
  137. /package/dist/{global-config-WPJRXVDO.js.map → authoring-compatibility-internal.js.map} +0 -0
  138. /package/{dist/scaffold → scaffold}/assets/static/app/tsconfig.framework.json +0 -0
  139. /package/{dist/scaffold → scaffold}/assets/static/app/tsconfig.json +0 -0
  140. /package/{dist/scaffold → scaffold}/assets/static/ui/index.tsx +0 -0
  141. /package/{dist/scaffold → scaffold}/assets/static/ui/style.css +0 -0
  142. /package/{dist/scaffold → scaffold}/assets/static/ui/tsconfig.framework.json +0 -0
  143. /package/{dist/scaffold → scaffold}/assets/static/ui/tsconfig.json +0 -0
@@ -2,23 +2,26 @@
2
2
  import {
3
3
  findProjectRoot,
4
4
  loadProjectConfig
5
- } from "./chunk-3IJBOLGT.mjs";
5
+ } from "./chunk-WSIYUUSD.mjs";
6
6
  import {
7
- getStoredSession,
8
- loadGlobalConfig,
9
- setCredentials
10
- } from "./chunk-W2MDP5ZN.mjs";
7
+ createUserTokenManager,
8
+ resolveLocalHarnessAccessToken
9
+ } from "./chunk-CO3BRUD6.mjs";
11
10
  import {
12
- IS_PUBLISHED_BUILD,
13
- PUBLISHED_ENVIRONMENT
14
- } from "./chunk-KK47X7RV.mjs";
11
+ loadGlobalConfig
12
+ } from "./chunk-DPYC2NDB.mjs";
15
13
  import {
16
- client
17
- } from "./chunk-NAK77WXW.mjs";
14
+ IS_PUBLISHED_BUILD,
15
+ PUBLISHED_ENVIRONMENT,
16
+ getStoredSession
17
+ } from "./chunk-AXXUGU7Q.mjs";
18
18
  import {
19
19
  readJsonFile,
20
20
  readTextFileIfExists
21
- } from "./chunk-IAYRNVUC.mjs";
21
+ } from "./chunk-RDYXWXXC.mjs";
22
+ import {
23
+ client
24
+ } from "./chunk-MYMVXTZT.mjs";
22
25
  import {
23
26
  DEFAULT_API_BASE_URL,
24
27
  DEFAULT_WEB_BASE_URL,
@@ -1126,155 +1129,6 @@ function _getDefaultLogLevel() {
1126
1129
  }
1127
1130
  var consola = createConsola2();
1128
1131
 
1129
- // src/auth/clerk-oauth.ts
1130
- import crypto from "crypto";
1131
- async function refreshClerkOAuthToken(input) {
1132
- const { clientId, tokenUrl } = assertConfigured(input.config);
1133
- const body = new URLSearchParams({
1134
- grant_type: "refresh_token",
1135
- client_id: clientId,
1136
- refresh_token: input.refreshToken
1137
- });
1138
- return requestClerkToken(tokenUrl, body);
1139
- }
1140
- function assertConfigured(config) {
1141
- const issuer = config.issuer?.trim().replace(/\/$/, "");
1142
- const clientId = config.clientId?.trim();
1143
- if (!issuer || !clientId) {
1144
- throw new Error(
1145
- [
1146
- "Clerk OAuth CLI is not configured for this environment.",
1147
- "The CLI expects first-party environments to be configured in its built-in registry.",
1148
- "If this environment has no registered public Clerk OAuth client, create one and release a CLI with its client id.",
1149
- "For emergency overrides, set the environment-specific DREAMBOARD_<ENV>_CLERK_OAUTH_* variables or DREAMBOARD_CLERK_OAUTH_*.",
1150
- "For local harness auth, use `pnpm auth:local` or the auto-bootstrapped local harness flows instead."
1151
- ].join(" ")
1152
- );
1153
- }
1154
- return {
1155
- issuer,
1156
- clientId,
1157
- tokenUrl: config.tokenUrl?.trim() || new URL("/oauth/token", issuer).toString(),
1158
- scope: config.scope?.trim() || void 0
1159
- };
1160
- }
1161
- async function requestClerkToken(tokenUrl, body) {
1162
- const response = await fetch(tokenUrl, {
1163
- method: "POST",
1164
- headers: {
1165
- "Content-Type": "application/x-www-form-urlencoded",
1166
- Accept: "application/json"
1167
- },
1168
- body
1169
- });
1170
- if (!response.ok) {
1171
- const detail = await response.text();
1172
- throw new Error(
1173
- `Clerk OAuth token request failed (${response.status}): ${detail}`
1174
- );
1175
- }
1176
- const payload = await response.json();
1177
- if (typeof payload.access_token !== "string") {
1178
- throw new Error("Clerk OAuth token response did not include access_token.");
1179
- }
1180
- if (typeof payload.refresh_token !== "string") {
1181
- throw new Error(
1182
- "Clerk OAuth token response did not include refresh_token."
1183
- );
1184
- }
1185
- const expiresAt = typeof payload.expires_in === "number" ? new Date(Date.now() + payload.expires_in * 1e3).toISOString() : void 0;
1186
- return {
1187
- accessToken: payload.access_token,
1188
- refreshToken: payload.refresh_token,
1189
- expiresAt,
1190
- tokenUrl
1191
- };
1192
- }
1193
-
1194
- // src/config/local-harness-auth.ts
1195
- import { createHmac, randomUUID } from "crypto";
1196
- var DEFAULT_SUBJECT = "harness-smoke-local@dreamboard.local";
1197
- var DEFAULT_ISSUER = "dreamboard-local-harness";
1198
- var DEFAULT_SECRET = "dreamboard-local-harness-token-secret";
1199
- var LOCAL_AWS_ISSUER = "dreamboard-local-aws-harness";
1200
- var LOCAL_AWS_SECRET = "dreamboard-local-aws-harness-token-secret";
1201
- var DEFAULT_TTL_SECONDS = 8 * 60 * 60;
1202
- var mintedTokens = /* @__PURE__ */ new Map();
1203
- function resolveLocalHarnessAccessToken(config) {
1204
- if (IS_PUBLISHED_BUILD || config.environment !== "local") {
1205
- return void 0;
1206
- }
1207
- const profile = inferLocalHarnessProfile(config);
1208
- if (config.authToken && (profile !== "local-aws" || isExplicitTokenSource(config.authTokenSource))) {
1209
- return void 0;
1210
- }
1211
- const cacheKey = [
1212
- profile,
1213
- process.env.LOCAL_HARNESS_TOKEN_ISSUER ?? "",
1214
- process.env.LOCAL_HARNESS_TOKEN_SECRET ?? "",
1215
- process.env.LOCAL_HARNESS_SUBJECT ?? "",
1216
- process.env.HARNESS_USER_EMAIL ?? "",
1217
- process.env.LOCAL_HARNESS_EMAIL ?? "",
1218
- process.env.LOCAL_HARNESS_TOKEN_TTL_SECONDS ?? ""
1219
- ].join("\0");
1220
- const cached = mintedTokens.get(cacheKey);
1221
- if (cached) return cached;
1222
- const token = mintLocalHarnessToken(profile);
1223
- mintedTokens.set(cacheKey, token);
1224
- return token;
1225
- }
1226
- function isExplicitTokenSource(source) {
1227
- return source === "flag" || source === "env" || source === "agent-env";
1228
- }
1229
- function inferLocalHarnessProfile(config) {
1230
- return isLocalAwsUrl(config.apiBaseUrl) || isLocalAwsUrl(config.webBaseUrl) ? "local-aws" : "local";
1231
- }
1232
- function mintLocalHarnessToken(profile) {
1233
- const subject = envValue(process.env.LOCAL_HARNESS_SUBJECT) ?? envValue(process.env.HARNESS_USER_EMAIL) ?? DEFAULT_SUBJECT;
1234
- const email = envValue(process.env.LOCAL_HARNESS_EMAIL) ?? (subject.includes("@") ? subject : void 0);
1235
- const issuer = envValue(process.env.LOCAL_HARNESS_TOKEN_ISSUER) ?? (profile === "local-aws" ? LOCAL_AWS_ISSUER : DEFAULT_ISSUER);
1236
- const secret = envValue(process.env.LOCAL_HARNESS_TOKEN_SECRET) ?? (profile === "local-aws" ? LOCAL_AWS_SECRET : DEFAULT_SECRET);
1237
- const ttlSeconds = Number(
1238
- envValue(process.env.LOCAL_HARNESS_TOKEN_TTL_SECONDS) ?? String(DEFAULT_TTL_SECONDS)
1239
- );
1240
- if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
1241
- throw new Error(
1242
- "LOCAL_HARNESS_TOKEN_TTL_SECONDS must be a positive number."
1243
- );
1244
- }
1245
- const now = Math.floor(Date.now() / 1e3);
1246
- const payload = {
1247
- typ: "local_harness_access",
1248
- dreamboard_provider: "local-harness",
1249
- dreamboard_provider_subject: subject,
1250
- ...email ? { email } : {},
1251
- iss: issuer,
1252
- sub: subject,
1253
- iat: now,
1254
- exp: now + Math.floor(ttlSeconds),
1255
- jti: randomUUID()
1256
- };
1257
- const headerPart = base64UrlJson({ alg: "HS256", typ: "JWT" });
1258
- const payloadPart = base64UrlJson(payload);
1259
- const signature = createHmac("sha256", secret).update(`${headerPart}.${payloadPart}`).digest("base64url");
1260
- return `${headerPart}.${payloadPart}.${signature}`;
1261
- }
1262
- function base64UrlJson(value) {
1263
- return Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
1264
- }
1265
- function envValue(raw) {
1266
- return typeof raw === "string" && raw.trim().length > 0 ? raw.trim() : void 0;
1267
- }
1268
- function isLocalAwsUrl(rawUrl) {
1269
- if (!rawUrl) return false;
1270
- try {
1271
- const url = new URL(rawUrl);
1272
- return (url.hostname === "localhost" || url.hostname === "127.0.0.1") && (url.port === "18080" || url.port === "8088");
1273
- } catch {
1274
- return false;
1275
- }
1276
- }
1277
-
1278
1132
  // src/config/resolve.ts
1279
1133
  var DEFAULT_REFRESH_WINDOW_MS = 5 * 60 * 1e3;
1280
1134
  var TRANSIENT_READ_RETRY_DELAYS_MS = [100, 300];
@@ -1298,9 +1152,13 @@ function resolveConfig(globalConfig, flags, project, credentials) {
1298
1152
  environment,
1299
1153
  apiBaseUrl,
1300
1154
  webBaseUrl,
1301
- authToken: snapshot.accessToken,
1155
+ authToken: snapshot.dreamboardApiToken ?? (snapshot.refreshToken ? void 0 : snapshot.accessToken),
1302
1156
  refreshToken: snapshot.refreshToken,
1303
- tokenExpiresAt: snapshot.tokenExpiresAt,
1157
+ tokenExpiresAt: snapshot.dreamboardApiExpiresAt ?? (snapshot.refreshToken ? void 0 : snapshot.tokenExpiresAt),
1158
+ clerkAccessToken: snapshot.accessToken,
1159
+ clerkAccessExpiresAt: snapshot.tokenExpiresAt,
1160
+ dreamboardApiToken: snapshot.dreamboardApiToken,
1161
+ dreamboardApiExpiresAt: snapshot.dreamboardApiExpiresAt,
1304
1162
  clerkOAuthIssuer: snapshot.clerkOAuthIssuer ?? oauthConfig.issuer,
1305
1163
  clerkOAuthClientId: snapshot.clerkOAuthClientId ?? oauthConfig.clientId,
1306
1164
  clerkOAuthTokenUrl: snapshot.clerkOAuthTokenUrl ?? oauthConfig.tokenUrl,
@@ -1321,9 +1179,7 @@ function resolveEnvironmentOAuthConfig(environment, envConfig) {
1321
1179
  tokenUrl: valueOrUndefined(
1322
1180
  process.env[`DREAMBOARD_${prefix}_CLERK_OAUTH_TOKEN_URL`]
1323
1181
  ) ?? valueOrUndefined(process.env.DREAMBOARD_CLERK_OAUTH_TOKEN_URL) ?? envConfig?.clerkOAuthTokenUrl,
1324
- scope: valueOrUndefined(
1325
- process.env[`DREAMBOARD_${prefix}_CLERK_OAUTH_SCOPE`]
1326
- ) ?? valueOrUndefined(process.env.DREAMBOARD_CLERK_OAUTH_SCOPE) ?? envConfig?.clerkOAuthScope
1182
+ scope: valueOrUndefined(process.env[`DREAMBOARD_${prefix}_CLERK_OAUTH_SCOPE`]) ?? valueOrUndefined(process.env.DREAMBOARD_CLERK_OAUTH_SCOPE) ?? envConfig?.clerkOAuthScope
1327
1183
  };
1328
1184
  }
1329
1185
  function buildCredentialSnapshot(flags, storedCredentials, environment) {
@@ -1346,11 +1202,13 @@ function buildCredentialSnapshot(flags, storedCredentials, environment) {
1346
1202
  accessToken: stored?.accessToken,
1347
1203
  refreshToken: stored?.refreshToken,
1348
1204
  tokenExpiresAt: stored?.tokenExpiresAt,
1205
+ dreamboardApiToken: stored?.dreamboardApiToken,
1206
+ dreamboardApiExpiresAt: stored?.dreamboardApiExpiresAt,
1349
1207
  clerkOAuthIssuer: stored?.clerkOAuthIssuer,
1350
1208
  clerkOAuthClientId: stored?.clerkOAuthClientId,
1351
1209
  clerkOAuthTokenUrl: stored?.clerkOAuthTokenUrl,
1352
1210
  environment: stored?.environment,
1353
- authTokenSource: stored?.accessToken ? "global" : "none",
1211
+ authTokenSource: stored?.dreamboardApiToken || stored?.accessToken && !stored.refreshToken ? "global" : "none",
1354
1212
  refreshTokenSource: stored?.refreshToken ? "global" : "none"
1355
1213
  };
1356
1214
  }
@@ -1362,6 +1220,8 @@ function buildCredentialSnapshot(flags, storedCredentials, environment) {
1362
1220
  accessToken,
1363
1221
  refreshToken,
1364
1222
  tokenExpiresAt: environmentScopedStoredCredentials?.tokenExpiresAt,
1223
+ dreamboardApiToken: environmentScopedStoredCredentials?.dreamboardApiToken,
1224
+ dreamboardApiExpiresAt: environmentScopedStoredCredentials?.dreamboardApiExpiresAt,
1365
1225
  clerkOAuthIssuer: environmentScopedStoredCredentials?.clerkOAuthIssuer,
1366
1226
  clerkOAuthClientId: environmentScopedStoredCredentials?.clerkOAuthClientId,
1367
1227
  clerkOAuthTokenUrl: environmentScopedStoredCredentials?.clerkOAuthTokenUrl,
@@ -1408,7 +1268,9 @@ function assertPublicRuntimeFlags(flags) {
1408
1268
  }
1409
1269
  }
1410
1270
  async function configureClient(config) {
1411
- const effectiveAccessToken = await ensureEffectiveAccessToken(config);
1271
+ const localHarnessToken = resolveLocalHarnessAccessToken(config);
1272
+ const resolvedToken = localHarnessToken ? { token: localHarnessToken } : await createUserTokenManager(config).resolveApiToken();
1273
+ const effectiveAccessToken = resolvedToken?.token;
1412
1274
  client.setConfig({
1413
1275
  baseUrl: config.apiBaseUrl,
1414
1276
  fetch: createRetryingReadFetch(globalThis.fetch.bind(globalThis)),
@@ -1448,58 +1310,8 @@ function isTransientFetchError(error) {
1448
1310
  function sleep(ms) {
1449
1311
  return new Promise((resolve) => setTimeout(resolve, ms));
1450
1312
  }
1451
- async function ensureEffectiveAccessToken(config) {
1452
- const localHarnessToken = resolveLocalHarnessAccessToken(config);
1453
- if (localHarnessToken) return localHarnessToken;
1454
- if (!usesStoredSession(config)) {
1455
- return config.authToken;
1456
- }
1457
- if (config.refreshToken) {
1458
- const credentials = await refreshClerkOAuthSessionIfNeeded(config);
1459
- return credentials?.accessToken ?? config.authToken;
1460
- }
1461
- return config.authToken;
1462
- }
1463
- async function refreshClerkOAuthSessionIfNeeded(config) {
1464
- const expiry = config.tokenExpiresAt ? new Date(config.tokenExpiresAt) : getAuthTokenExpiry(config.authToken);
1465
- if (expiry && expiry.getTime() > Date.now() + DEFAULT_REFRESH_WINDOW_MS) {
1466
- if (!config.authToken || !config.refreshToken) return null;
1467
- return {
1468
- accessToken: config.authToken,
1469
- refreshToken: config.refreshToken,
1470
- tokenExpiresAt: config.tokenExpiresAt,
1471
- clerkOAuthIssuer: config.clerkOAuthIssuer,
1472
- clerkOAuthClientId: config.clerkOAuthClientId,
1473
- clerkOAuthTokenUrl: config.clerkOAuthTokenUrl,
1474
- environment: config.environment
1475
- };
1476
- }
1477
- return refreshClerkOAuthSession(config);
1478
- }
1479
- async function refreshClerkOAuthSession(config) {
1480
- if (!config.refreshToken) return null;
1481
- const payload = await refreshClerkOAuthToken({
1482
- config: {
1483
- issuer: config.clerkOAuthIssuer,
1484
- clientId: config.clerkOAuthClientId,
1485
- tokenUrl: config.clerkOAuthTokenUrl
1486
- },
1487
- refreshToken: config.refreshToken
1488
- });
1489
- const credentials = {
1490
- accessToken: payload.accessToken,
1491
- refreshToken: payload.refreshToken,
1492
- tokenExpiresAt: payload.expiresAt,
1493
- clerkOAuthIssuer: config.clerkOAuthIssuer,
1494
- clerkOAuthClientId: config.clerkOAuthClientId,
1495
- clerkOAuthTokenUrl: payload.tokenUrl,
1496
- environment: config.environment
1497
- };
1498
- await setCredentials(credentials);
1499
- return credentials;
1500
- }
1501
1313
  function requireAuth(config) {
1502
- if (!config.authToken && !resolveLocalHarnessAccessToken(config)) {
1314
+ if (!config.authToken && !config.refreshToken && !resolveLocalHarnessAccessToken(config)) {
1503
1315
  throw new Error(
1504
1316
  "Missing Dreamboard session. Run `dreamboard login` to authenticate."
1505
1317
  );
@@ -1508,25 +1320,6 @@ function requireAuth(config) {
1508
1320
  function valueOrUndefined(value) {
1509
1321
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
1510
1322
  }
1511
- function getAuthTokenExpiry(accessToken) {
1512
- if (!accessToken) return null;
1513
- const parts = accessToken.split(".");
1514
- if (parts.length !== 3) return null;
1515
- try {
1516
- const payload = JSON.parse(
1517
- Buffer.from(parts[1], "base64url").toString("utf8")
1518
- );
1519
- if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp)) {
1520
- return null;
1521
- }
1522
- return new Date(payload.exp * 1e3);
1523
- } catch {
1524
- return null;
1525
- }
1526
- }
1527
- function usesStoredSession(config) {
1528
- return config.authTokenSource === "global" && config.refreshTokenSource === "global";
1529
- }
1530
1323
  async function resolveProjectContext(flags, opts) {
1531
1324
  const projectRoot = await findProjectRoot(process.cwd());
1532
1325
  if (!projectRoot) {
@@ -1747,4 +1540,4 @@ export {
1747
1540
  assertCompilerPortableDependencies,
1748
1541
  assertReleaseEnvironmentPortableDependencies
1749
1542
  };
1750
- //# sourceMappingURL=chunk-UIJ2NDG6.mjs.map
1543
+ //# sourceMappingURL=chunk-NFL3Z4Z7.mjs.map