@cloudflare/vite-plugin 1.63.1 → 1.63.2

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/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import fs, { constants as constants$1, mkdir, readFile, writeFile } from "node:f
23
23
  import childProcess, { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
24
24
  import * as timersPromises from "node:timers/promises";
25
25
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
26
- import { CoreHeaders, CorePaths, DeferredPromise, Log, LogLevel, Miniflare, MiniflareCoreError, Mutex, Request as Request$1, Response as Response$1, buildPublicUrl, convertV4MiniflareOptions, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseModuleFallbackRequest } from "miniflare";
26
+ import { CoreHeaders, CorePaths, DeferredPromise, Log, LogLevel, Miniflare, MiniflareCoreError, Mutex, Request as Request$1, Response as Response$1, buildPublicUrl, convertV4MiniflareOptions, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseForwardedProto, parseModuleFallbackRequest } from "miniflare";
27
27
  import * as wrangler from "wrangler";
28
28
  import * as vite from "vite";
29
29
  import { normalizePath, version } from "vite";
@@ -19169,7 +19169,7 @@ function createFatalError$1(message, isJson, options) {
19169
19169
  __name$6(createFatalError$1, "createFatalError");
19170
19170
 
19171
19171
  //#endregion
19172
- //#region ../workers-utils/dist/chunk-TAK63GWY.mjs
19172
+ //#region ../workers-utils/dist/chunk-2HLTAS5V.mjs
19173
19173
  createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
19174
19174
  function hasKnownExportType(entry) {
19175
19175
  const type = entry?.type;
@@ -19274,12 +19274,12 @@ function getDurableObjectClassNameToUseSQLiteMap(migrations, exports$1) {
19274
19274
  return durableObjectClassNameToUseSQLiteMap;
19275
19275
  }
19276
19276
  __name$6(getDurableObjectClassNameToUseSQLiteMap, "getDurableObjectClassNameToUseSQLiteMap");
19277
- function validateDurableObjectContainerApplications(config$2, containers = getDurableObjectContainerApps(config$2.containers)) {
19277
+ function validateDurableObjectContainerApplications(config$2, containers = getDurableObjectContainerApps(config$2.containers), configFileName2 = "Wrangler config file") {
19278
19278
  const allDOs = getDurableObjectClassNameToUseSQLiteMap(config$2.migrations, config$2.exports);
19279
19279
  for (const container of getResolvedDurableObjectContainerApps(containers, config$2.exports)) {
19280
19280
  const maybeBoundDO = config$2.durable_objects.bindings.find((durableObject) => durableObject.class_name === container.class_name);
19281
19281
  const useSQLite = allDOs.get(container.class_name);
19282
- if (useSQLite === void 0 && maybeBoundDO === void 0) throw new UserError(`The container class_name ${container.class_name} does not match any durable object class_name defined in your Wrangler config file. Note that the durable object must be defined in the same script as the container.`, { telemetryMessage: "no DO defined that matches container class_name" });
19282
+ if (useSQLite === void 0 && maybeBoundDO === void 0) throw new UserError(`The container class_name ${container.class_name} does not match any durable object class_name defined in your ${configFileName2}. Note that the durable object must be defined in the same script as the container.`, { telemetryMessage: "no DO defined that matches container class_name" });
19283
19283
  if (maybeBoundDO?.script_name !== void 0) throw new UserError(`The container ${container.name} is referencing the durable object ${container.class_name}, which appears to be defined on the ${maybeBoundDO.script_name} Worker instead (via the 'script_name' field). You cannot configure a container on a Durable Object that is defined in another Worker.`, { telemetryMessage: "container class_name refers to an external durable object" });
19284
19284
  if (useSQLite === false) throw new UserError(`The container ${container.name} references Durable Object class ${container.class_name}, which uses the legacy KV storage backend. Durable Object-managed Containers require SQLite-backed Durable Objects.`, { telemetryMessage: "durable object container class uses legacy storage" });
19285
19285
  }
@@ -19982,10 +19982,10 @@ function parseTree(text, errors$1 = [], options = ParseOptions.DEFAULT) {
19982
19982
  return result;
19983
19983
  }
19984
19984
  __name$6(parseTree, "parseTree");
19985
- function findNodeAtLocation(root, path2) {
19985
+ function findNodeAtLocation(root, path3) {
19986
19986
  if (!root) return;
19987
19987
  let node$2 = root;
19988
- for (let segment of path2) if (typeof segment === "string") {
19988
+ for (let segment of path3) if (typeof segment === "string") {
19989
19989
  if (node$2.type !== "object" || !Array.isArray(node$2.children)) return;
19990
19990
  let found = false;
19991
19991
  for (const propertyNode of node$2.children) if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
@@ -20212,13 +20212,13 @@ function getNodeType(value) {
20212
20212
  }
20213
20213
  __name$6(getNodeType, "getNodeType");
20214
20214
  function setProperty(text, originalPath, value, options) {
20215
- const path2 = originalPath.slice();
20215
+ const path3 = originalPath.slice();
20216
20216
  const root = parseTree(text, []);
20217
20217
  let parent = void 0;
20218
20218
  let lastSegment = void 0;
20219
- while (path2.length > 0) {
20220
- lastSegment = path2.pop();
20221
- parent = findNodeAtLocation(root, path2);
20219
+ while (path3.length > 0) {
20220
+ lastSegment = path3.pop();
20221
+ parent = findNodeAtLocation(root, path3);
20222
20222
  if (parent === void 0 && value !== void 0) if (typeof lastSegment === "string") value = { [lastSegment]: value };
20223
20223
  else value = [value];
20224
20224
  else break;
@@ -20460,8 +20460,8 @@ function format2(documentText, range, options) {
20460
20460
  return format$2(documentText, range, options);
20461
20461
  }
20462
20462
  __name$6(format2, "format");
20463
- function modify(text, path2, value, options) {
20464
- return setProperty(text, path2, value, options);
20463
+ function modify(text, path3, value, options) {
20464
+ return setProperty(text, path3, value, options);
20465
20465
  }
20466
20466
  __name$6(modify, "modify");
20467
20467
  function applyEdits(text, edits) {
@@ -21667,7 +21667,8 @@ function configFormat(configPath) {
21667
21667
  return "none";
21668
21668
  }
21669
21669
  __name$6(configFormat, "configFormat");
21670
- function configFileName(configPath) {
21670
+ function configFileName(configPath, userConfigPath) {
21671
+ if (userConfigPath !== void 0) return path__default.basename(userConfigPath);
21671
21672
  switch (configFormat(configPath)) {
21672
21673
  case "toml": return "wrangler.toml";
21673
21674
  case "json": return "wrangler.json";
@@ -52253,6 +52254,50 @@ The local dev server started at ${origin.href}
52253
52254
  return new Error(errorMessage);
52254
52255
  }
52255
52256
  __name$6(createTunnelStartupError, "createTunnelStartupError");
52257
+ var WRANGLER_COMMANDS = {
52258
+ deploy: "wrangler deploy",
52259
+ preview: "wrangler preview",
52260
+ versionsUpload: "wrangler versions upload",
52261
+ versionsDeploy: "wrangler versions deploy",
52262
+ versionsDeployAt: /* @__PURE__ */ __name$6((n2) => `wrangler versions deploy <new-version-id>@${n2}%`, "versionsDeployAt"),
52263
+ triggersDeploy: "wrangler triggers deploy",
52264
+ d1List: "wrangler d1 list",
52265
+ d1Delete: "wrangler d1 delete",
52266
+ queuesCreate: "wrangler queues create",
52267
+ secretPut: "wrangler secret put",
52268
+ versionsSecretPut: "wrangler versions secret put",
52269
+ containerRegistryConfigure: "wrangler containers registries configure"
52270
+ };
52271
+ var WRANGLER_CONFIG_FIELDS = {
52272
+ workersDev: "workers_dev",
52273
+ containerObservabilityTargetPercentage: "target_instance_percentage",
52274
+ containerObservabilityTargetCount: "target_instance_count"
52275
+ };
52276
+ var WRANGLER_CLI_PRESENTATION = {
52277
+ cliName: "wrangler",
52278
+ displayName: "Wrangler",
52279
+ displayConfigFileName: "Wrangler config file",
52280
+ configFieldAssignmentSeparator: " = ",
52281
+ commands: WRANGLER_COMMANDS,
52282
+ configFields: WRANGLER_CONFIG_FIELDS
52283
+ };
52284
+ function resolveCliPresentation(overrides) {
52285
+ return {
52286
+ cliName: overrides?.cliName ?? WRANGLER_CLI_PRESENTATION.cliName,
52287
+ displayName: overrides?.displayName ?? WRANGLER_CLI_PRESENTATION.displayName,
52288
+ displayConfigFileName: overrides?.displayConfigFileName ?? WRANGLER_CLI_PRESENTATION.displayConfigFileName,
52289
+ configFieldAssignmentSeparator: overrides?.configFieldAssignmentSeparator ?? WRANGLER_CLI_PRESENTATION.configFieldAssignmentSeparator,
52290
+ commands: {
52291
+ ...WRANGLER_COMMANDS,
52292
+ ...overrides?.commands
52293
+ },
52294
+ configFields: {
52295
+ ...WRANGLER_CONFIG_FIELDS,
52296
+ ...overrides?.configFields
52297
+ }
52298
+ };
52299
+ }
52300
+ __name$6(resolveCliPresentation, "resolveCliPresentation");
52256
52301
  var UPDATE_CHECK_TIMEOUT_MS = 3e3;
52257
52302
  var CACHE_TTL_MS = 3600 * 1e3;
52258
52303
  var NPM_REGISTRY_URL = "https://registry.npmjs.org/";
@@ -56427,10 +56472,7 @@ const isRolldown = "rolldownVersion" in vite;
56427
56472
  */
56428
56473
  function getForwardedProto(req) {
56429
56474
  const raw = req.headers["x-forwarded-proto"];
56430
- const value = Array.isArray(raw) ? raw[0] : raw;
56431
- if (!value) return;
56432
- const first = value.split(",")[0]?.trim().toLowerCase();
56433
- if (first === "http" || first === "https") return `${first}:`;
56475
+ return parseForwardedProto(Array.isArray(raw) ? raw[0] : raw);
56434
56476
  }
56435
56477
  /**
56436
56478
  * Extracts the authority (host and port) from an incoming Node.js request.
@@ -64067,10 +64109,14 @@ function createDefinitionResolver(ctx) {
64067
64109
  return resolved;
64068
64110
  };
64069
64111
  }
64070
- async function normalizeWorkerReferences(resolved, resolveDefinition) {
64112
+ async function normalizeWorkerEnv(resolved, resolveDefinition) {
64071
64113
  if (!isRecord(resolved) || !isRecord(resolved.env)) return resolved;
64072
64114
  const env$3 = { ...resolved.env };
64073
64115
  for (const [bindingName, binding] of Object.entries(env$3)) {
64116
+ if (binding === false || binding === null || binding === void 0) {
64117
+ delete env$3[bindingName];
64118
+ continue;
64119
+ }
64074
64120
  if (!isRecord(binding) || typeof binding.type !== "string" || !CROSS_WORKER_BINDING_TYPES.has(binding.type) || typeof binding.worker === "string") continue;
64075
64121
  const target$1 = await resolveDefinition(binding.worker);
64076
64122
  env$3[bindingName] = {
@@ -64149,7 +64195,7 @@ async function normalizeContainerReferences(resolved, resolveDefinition, contain
64149
64195
  };
64150
64196
  }
64151
64197
  async function normalizeWorkerConfig(resolved, resolveDefinition, containers) {
64152
- return normalizeContainerReferences(await normalizeWorkerReferences(normalizeWorkerEntrypoint(resolved), resolveDefinition), resolveDefinition, containers);
64198
+ return normalizeContainerReferences(await normalizeWorkerEnv(normalizeWorkerEntrypoint(resolved), resolveDefinition), resolveDefinition, containers);
64153
64199
  }
64154
64200
  function prefixIssues(issues, prefix) {
64155
64201
  return issues.map((issue$2) => ({
@@ -71901,6 +71947,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
71901
71947
  }
71902
71948
  const resolvedNewConfig = normalizeNewConfig(pluginConfig.experimental?.newConfig);
71903
71949
  const shared = {
71950
+ cliDisplayName: isForcedBuildOutput() ? "cf" : "Wrangler",
71904
71951
  persistState: pluginConfig.persistState ?? true,
71905
71952
  inspectorPort: pluginConfig.inspectorPort,
71906
71953
  tunnel: typeof pluginConfig.tunnel === "boolean" ? { autoStart: pluginConfig.tunnel } : {
@@ -83894,7 +83941,9 @@ var fetchResult$1 = /* @__PURE__ */ __name$2(() => {
83894
83941
  var fetchPagedListResult = /* @__PURE__ */ __name$2(() => {
83895
83942
  throw new Error("initContainersSharedContext() must be called first");
83896
83943
  }, "fetchPagedListResult");
83944
+ var cliPresentation = resolveCliPresentation();
83897
83945
  function initContainersSharedContext(ctx) {
83946
+ cliPresentation = resolveCliPresentation(ctx.cliPresentation);
83898
83947
  logger$1 = ctx.logger;
83899
83948
  fetchResult$1 = ctx.fetchResult;
83900
83949
  if (ctx.fetchPagedListResult !== void 0) fetchPagedListResult = ctx.fetchPagedListResult;
@@ -83989,7 +84038,10 @@ var runDockerCmd = /* @__PURE__ */ __name$2((dockerPath, args, stdio) => {
83989
84038
  }, "runDockerCmd");
83990
84039
  var runDockerCmdWithOutput = /* @__PURE__ */ __name$2((dockerPath, args) => {
83991
84040
  try {
83992
- return execFileSync(dockerPath, args, { encoding: "utf8" }).trim();
84041
+ return execFileSync(dockerPath, args, {
84042
+ encoding: "utf8",
84043
+ stdio: "pipe"
84044
+ }).trim();
83993
84045
  } catch (error$3) {
83994
84046
  throw new UserError(`Failed running docker command: ${error$3.message}. Command: ${dockerPath} ${args.join(" ")}`, { telemetryMessage: false });
83995
84047
  }
@@ -84155,7 +84207,9 @@ async function pullImage(dockerPath, options, logger2, complianceConfig) {
84155
84207
  await dockerLoginImageRegistry(dockerPath, domain$1);
84156
84208
  } catch (e) {
84157
84209
  if (!isExternalRegistry) throw e;
84158
- logger2?.warn("Unable to retrieve configured registry credentials from Cloudflare.\nUnless this is a public image, you will need to run `wrangler containers registries configure` before deploying.\nAttempting to pull image anyway...");
84210
+ logger2?.warn(`Unable to retrieve configured registry credentials from Cloudflare.
84211
+ Unless this is a public image, you will need to run \`${cliPresentation.commands.containerRegistryConfigure}\` before deploying.
84212
+ Attempting to pull image anyway...`);
84159
84213
  }
84160
84214
  const pull = runDockerCmd(dockerPath, [
84161
84215
  "pull",
@@ -84187,7 +84241,7 @@ async function prepareContainerImagesForDev(args) {
84187
84241
  dockerPath,
84188
84242
  operation: "running dev",
84189
84243
  imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
84190
- hint: "To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or pass --enable-containers=false."
84244
+ hint: `To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your ${cliPresentation.displayConfigFileName} or pass --enable-containers=false.`
84191
84245
  });
84192
84246
  for (const options of containerOptions) {
84193
84247
  if ("dockerfile" in options) {
@@ -85473,7 +85527,7 @@ __name$2(buildApplicationObservabilityPatch, "buildApplicationObservabilityPatch
85473
85527
  function assertCanUseApplicationObservabilityTargeting(prevApp, containerConfig) {
85474
85528
  if (!hasTopLevelOnlyObservabilityFields(containerConfig.observability)) return;
85475
85529
  if (!hasLegacyRolloutObservabilityEnabled(prevApp)) return;
85476
- throw new UserError(`Application-level observability targeting cannot be enabled for container ${containerConfig.name} while it still uses legacy rollout-based observability. Set containers[].observability.enabled = false in your Wrangler config and deploy once, then deploy again with target_instance_percentage or target_instance_count.`, { telemetryMessage: "containers deploy observability migration blocked" });
85530
+ throw new UserError(`Application-level observability targeting cannot be enabled for container ${containerConfig.name} while it still uses legacy rollout-based observability. Set containers[].observability.enabled = false in your ${cliPresentation.displayConfigFileName} and deploy once, then deploy again with ${cliPresentation.configFields.containerObservabilityTargetPercentage} or ${cliPresentation.configFields.containerObservabilityTargetCount}.`, { telemetryMessage: "containers deploy observability migration blocked" });
85477
85531
  }
85478
85532
  __name$2(assertCanUseApplicationObservabilityTargeting, "assertCanUseApplicationObservabilityTargeting");
85479
85533
  function hasRolloutDiff(prevApp, nextApp) {
@@ -85818,7 +85872,7 @@ async function sshCommand(sshArgs) {
85818
85872
  }
85819
85873
  const ws = new import_websocket.default(sshResponse.url, { headers: {
85820
85874
  authorization: `Bearer ${sshResponse.token}`,
85821
- "user-agent": "wrangler"
85875
+ "user-agent": cliPresentation.cliName
85822
85876
  } });
85823
85877
  ws.binaryType = "arraybuffer";
85824
85878
  if (useStdio) {
@@ -86710,7 +86764,7 @@ var __name$1 = (target$1, value) => __defProp$1(target$1, "name", {
86710
86764
  });
86711
86765
 
86712
86766
  //#endregion
86713
- //#region ../workers-auth/dist/chunk-NDZDTP46.mjs
86767
+ //#region ../workers-auth/dist/chunk-2K52M2W5.mjs
86714
86768
  var import_undici$2 = require_undici();
86715
86769
  createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
86716
86770
  var hasWarnedAboutDeprecatedV1ApiToken = false;
@@ -86887,7 +86941,7 @@ Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environm
86887
86941
  See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`, { telemetryMessage: "user access missing service token non interactive" });
86888
86942
  logger$2.debug("Spawning cloudflared to get Access token for domain:");
86889
86943
  const output$1 = await spawnCloudflaredAccessLogin(buildProbeUrl(domain$1, options.previewToken), options.signal);
86890
- if (output$1.error) throw new UserError("To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation", { telemetryMessage: "user access missing cloudflared" });
86944
+ if (output$1.error) throw new UserError(`To use ${options.cliDisplayName} with Cloudflare Access, please install \`cloudflared\` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation`, { telemetryMessage: "user access missing cloudflared" });
86891
86945
  const stringOutput = output$1.stdout;
86892
86946
  logger$2.debug("cloudflared output:", stringOutput);
86893
86947
  const matches = stringOutput.match(/fetched your token:\n\n(.*)/m);
@@ -87105,7 +87159,7 @@ function getCachedTemporaryPreviewAccount(storage) {
87105
87159
  return temporaryPreviewAccount;
87106
87160
  }
87107
87161
  __name$1(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
87108
- async function requestPowSolution(temporaryAccountLogger) {
87162
+ async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
87109
87163
  const response = await (0, import_undici$2.fetch)(getTemporaryPreviewChallengeUrl(), {
87110
87164
  method: "POST",
87111
87165
  headers: { "Content-Type": "application/json" },
@@ -87120,7 +87174,7 @@ async function requestPowSolution(temporaryAccountLogger) {
87120
87174
  }
87121
87175
  const { challengeToken, seed, k, g } = body.result ?? {};
87122
87176
  if (challengeToken === void 0 || seed === void 0 || k === void 0 || g === void 0) throw new FatalError("Failed to request a proof-of-work challenge because the response was missing required fields.", { telemetryMessage: "deploy temporary account challenge incomplete" });
87123
- if (!Number.isInteger(k) || !Number.isInteger(g) || k <= 0 || g <= 0 || k * g > POW_MAX_ITERATIONS || Buffer.from(seed, "base64url").length !== 32) throw new FatalError("The proof-of-work challenge is not supported by this version of Wrangler.", { telemetryMessage: "deploy temporary account challenge difficulty unsupported" });
87177
+ if (!Number.isInteger(k) || !Number.isInteger(g) || k <= 0 || g <= 0 || k * g > POW_MAX_ITERATIONS || Buffer.from(seed, "base64url").length !== 32) throw new FatalError(`The proof-of-work challenge is not supported by this version of ${cliDisplayName}.`, { telemetryMessage: "deploy temporary account challenge difficulty unsupported" });
87124
87178
  temporaryAccountLogger.log("Solving proof-of-work challenge…");
87125
87179
  return solveChallenge({
87126
87180
  challengeToken,
@@ -87130,8 +87184,8 @@ async function requestPowSolution(temporaryAccountLogger) {
87130
87184
  });
87131
87185
  }
87132
87186
  __name$1(requestPowSolution, "requestPowSolution");
87133
- async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2) {
87134
- const pow = await requestPowSolution(temporaryAccountLogger);
87187
+ async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2, cliDisplayName = "Wrangler") {
87188
+ const pow = await requestPowSolution(temporaryAccountLogger, cliDisplayName);
87135
87189
  const response = await (0, import_undici$2.fetch)(getTemporaryPreviewUrl(), {
87136
87190
  method: "POST",
87137
87191
  headers: { "Content-Type": "application/json" },
@@ -87184,14 +87238,14 @@ __name$1(createTemporaryPreviewAccount, "createTemporaryPreviewAccount");
87184
87238
  async function getOrCreateTemporaryPreviewAccount(options) {
87185
87239
  const cachedPreviewAccount = getCachedTemporaryPreviewAccount(options.storage);
87186
87240
  if (cachedPreviewAccount) {
87187
- if (options.request?.eventCode) throw new UserError("A temporary account is already cached. Rerun without --event-code to reuse it, or run `wrangler logout` and retry to create an account for this event.", { telemetryMessage: "deploy temporary event cache conflict" });
87241
+ if (options.request?.eventCode) throw new UserError(`A temporary account is already cached. Rerun without --event-code to reuse it, or run \`${options.logoutCommand ?? "wrangler logout"}\` and retry to create an account for this event.`, { telemetryMessage: "deploy temporary event cache conflict" });
87188
87242
  return {
87189
87243
  account: cachedPreviewAccount,
87190
87244
  cached: true
87191
87245
  };
87192
87246
  }
87193
87247
  if (!await options.prompt(TEMPORARY_TERMS_PROMPT, TEMPORARY_TERMS_NOTICE)) throw new UserError(TEMPORARY_TERMS_ERROR, { telemetryMessage: "user temporary terms not accepted" });
87194
- const temporaryPreviewAccount = await createTemporaryPreviewAccount(options.temporaryAccountLogger, options.request);
87248
+ const temporaryPreviewAccount = await createTemporaryPreviewAccount(options.temporaryAccountLogger, options.request, options.cliDisplayName);
87195
87249
  options.storage.write(temporaryPreviewAccount);
87196
87250
  return {
87197
87251
  account: temporaryPreviewAccount,
@@ -87450,6 +87504,7 @@ function toErrorClass(rawError, description, uri) {
87450
87504
  return error$3;
87451
87505
  }
87452
87506
  __name$1(toErrorClass, "toErrorClass");
87507
+ var TOKEN_REQUEST_TIMEOUT_MS = 3e4;
87453
87508
  function isReturningFromAuthServer(query, state, logger$2) {
87454
87509
  if (query.error) throw toErrorClass(Array.isArray(query.error) ? query.error[0] : query.error, Array.isArray(query.error_description) ? query.error_description[0] : query.error_description, Array.isArray(query.error_uri) ? query.error_uri[0] : query.error_uri);
87455
87510
  const code = query.code;
@@ -87482,7 +87537,7 @@ async function getAuthURL(scopes, clientId, redirectUri, state, generators) {
87482
87537
  });
87483
87538
  }
87484
87539
  __name$1(getAuthURL, "getAuthURL");
87485
- async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI2, clientId, storage) {
87540
+ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI2, clientId, storage, cliDisplayName) {
87486
87541
  const storedRefreshToken = readStoredAuthState({
87487
87542
  warningLogger: logger$2,
87488
87543
  storage
@@ -87492,7 +87547,7 @@ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI
87492
87547
  grant_type: "refresh_token",
87493
87548
  refresh_token: storedRefreshToken?.value ?? "",
87494
87549
  client_id: clientId
87495
- }), logger$2, isNonInteractiveOrCI2);
87550
+ }), logger$2, isNonInteractiveOrCI2, cliDisplayName);
87496
87551
  if (response.status >= 400) {
87497
87552
  let tokenExchangeResErr = void 0;
87498
87553
  try {
@@ -87520,7 +87575,7 @@ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI
87520
87575
  }
87521
87576
  }
87522
87577
  __name$1(exchangeRefreshTokenForAccessToken, "exchangeRefreshTokenForAccessToken");
87523
- async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveOrCI2, clientId, redirectUri) {
87578
+ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveOrCI2, clientId, redirectUri, cliDisplayName) {
87524
87579
  const { authorizationCode, codeVerifier = "" } = state;
87525
87580
  if (!codeVerifier) logger$2.warn("No code verifier is being sent.");
87526
87581
  else if (!authorizationCode) logger$2.warn("No authorization grant code is being passed.");
@@ -87530,7 +87585,7 @@ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveO
87530
87585
  redirect_uri: redirectUri,
87531
87586
  client_id: clientId,
87532
87587
  code_verifier: codeVerifier
87533
- }), logger$2, isNonInteractiveOrCI2);
87588
+ }), logger$2, isNonInteractiveOrCI2, cliDisplayName);
87534
87589
  if (!response.ok) {
87535
87590
  const { error: error$3 } = await getJSONFromResponse(response, logger$2);
87536
87591
  if (error$3 === "invalid_grant") logger$2.log("Expired! Auth code or refresh token needs to be renewed.");
@@ -87550,14 +87605,15 @@ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveO
87550
87605
  };
87551
87606
  }
87552
87607
  __name$1(exchangeAuthCodeForAccessToken, "exchangeAuthCodeForAccessToken");
87553
- async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2) {
87608
+ async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
87554
87609
  const headers = { "Content-Type": "application/x-www-form-urlencoded" };
87555
87610
  logger$2.debug("fetching auth token", `grant_type=${body.get("grant_type") ?? "<unknown>"}`);
87556
87611
  if (await domainUsesAccess(getAuthDomainFromEnv(), logger$2)) {
87557
87612
  logger$2.debug("Using Cloudflare Access to get an access token for the auth request");
87558
87613
  const accessHeaders = await getCloudflareAccessHeaders({
87559
87614
  logger: logger$2,
87560
- isNonInteractiveOrCI: isNonInteractiveOrCI2
87615
+ isNonInteractiveOrCI: isNonInteractiveOrCI2,
87616
+ cliDisplayName
87561
87617
  });
87562
87618
  Object.assign(headers, accessHeaders);
87563
87619
  }
@@ -87566,14 +87622,15 @@ async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2) {
87566
87622
  const response = await (0, import_undici$2.fetch)(getTokenUrlFromEnv(), {
87567
87623
  method: "POST",
87568
87624
  body: body.toString(),
87569
- headers
87625
+ headers,
87626
+ signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
87570
87627
  });
87571
87628
  if (!response.ok) logger$2.debug("Failed to fetch auth token:", response.status, response.statusText);
87572
87629
  return response;
87573
87630
  } catch (e) {
87574
87631
  logger$2.debug("Failed to fetch auth token:", e);
87575
87632
  const cause = e?.cause;
87576
- const code = typeof cause?.code === "string" ? ` (${cause.code})` : "";
87633
+ const code = e?.name === "TimeoutError" ? ` (timed out after ${TOKEN_REQUEST_TIMEOUT_MS / 1e3} seconds)` : typeof cause?.code === "string" ? ` (${cause.code})` : "";
87577
87634
  throw new ErrorAuthServerUnreachable(`Could not reach the Cloudflare auth server at ${getTokenUrlFromEnv()}${code}.`, {
87578
87635
  cause: e,
87579
87636
  telemetryMessage: "user oauth token endpoint unreachable"
@@ -87595,6 +87652,41 @@ async function getJSONFromResponse(response, logger$2) {
87595
87652
  }
87596
87653
  }
87597
87654
  __name$1(getJSONFromResponse, "getJSONFromResponse");
87655
+ function renderOauthErrorPage(cliDisplayName, detail) {
87656
+ const escape = /* @__PURE__ */ __name$1((value) => value.replace(/[&<>"']/g, (character) => ({
87657
+ "&": "&amp;",
87658
+ "<": "&lt;",
87659
+ ">": "&gt;",
87660
+ "\"": "&quot;",
87661
+ "'": "&#39;"
87662
+ })[character]), "escape");
87663
+ const codeRow = detail.code ? `<p>Code: <code>${escape(detail.code)}</code></p>` : "";
87664
+ const descriptionRow = detail.description ? `<p class="detail">${escape(detail.description)}</p>` : "";
87665
+ const escapedDisplayName = escape(cliDisplayName);
87666
+ return esm_default`
87667
+ <!doctype html>
87668
+ <html lang="en">
87669
+ <head>
87670
+ <meta charset="utf-8" />
87671
+ <title>${escapedDisplayName} login failed</title>
87672
+ <style>
87673
+ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; color: #1f2933; line-height: 1.5; }
87674
+ h1 { color: #c12d3f; }
87675
+ code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
87676
+ p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
87677
+ </style>
87678
+ </head>
87679
+ <body>
87680
+ <h1>${escapedDisplayName} login failed</h1>
87681
+ <p>The Cloudflare OAuth provider returned an error.</p>
87682
+ ${codeRow}
87683
+ ${descriptionRow}
87684
+ <p>You can close this tab and return to your terminal for more details.</p>
87685
+ </body>
87686
+ </html>
87687
+ `;
87688
+ }
87689
+ __name$1(renderOauthErrorPage, "renderOauthErrorPage");
87598
87690
  async function getOauthToken(options, state, ctx, generators) {
87599
87691
  const urlToOpen = await getAuthURL(options.scopes, options.clientId, options.redirectUri, state, generators);
87600
87692
  const callbackPath = new URL(options.redirectUri).pathname;
@@ -87622,35 +87714,8 @@ async function getOauthToken(options, state, ctx, generators) {
87622
87714
  }
87623
87715
  __name$1(finish, "finish");
87624
87716
  function renderErrorPage(detail) {
87625
- const escape = /* @__PURE__ */ __name$1((s) => s.replace(/[&<>"']/g, (c$1) => ({
87626
- "&": "&amp;",
87627
- "<": "&lt;",
87628
- ">": "&gt;",
87629
- "\"": "&quot;",
87630
- "'": "&#39;"
87631
- })[c$1]), "escape");
87632
- const body = `<!doctype html>
87633
- <html lang="en">
87634
- <head>
87635
- <meta charset="utf-8" />
87636
- <title>Wrangler login failed</title>
87637
- <style>
87638
- body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; color: #1f2933; line-height: 1.5; }
87639
- h1 { color: #c12d3f; }
87640
- code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
87641
- p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
87642
- </style>
87643
- </head>
87644
- <body>
87645
- <h1>Wrangler login failed</h1>
87646
- <p>The Cloudflare OAuth provider returned an error.</p>
87647
- ${detail.code ? `<p>Code: <code>${escape(detail.code)}</code></p>` : ""}
87648
- ${detail.description ? `<p class="detail">${escape(detail.description)}</p>` : ""}
87649
- <p>You can close this tab and return to your terminal for more details.</p>
87650
- </body>
87651
- </html>`;
87652
87717
  res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
87653
- res.end(body);
87718
+ res.end(renderOauthErrorPage(ctx.cliDisplayName, detail));
87654
87719
  }
87655
87720
  __name$1(renderErrorPage, "renderErrorPage");
87656
87721
  assert(req.url, "This request doesn't have a URL");
@@ -87684,7 +87749,7 @@ async function getOauthToken(options, state, ctx, generators) {
87684
87749
  return;
87685
87750
  }
87686
87751
  try {
87687
- const exchange = await exchangeAuthCodeForAccessToken(state, ctx.logger, ctx.isNonInteractiveOrCI, options.clientId, options.redirectUri);
87752
+ const exchange = await exchangeAuthCodeForAccessToken(state, ctx.logger, ctx.isNonInteractiveOrCI, options.clientId, options.redirectUri, ctx.cliDisplayName);
87688
87753
  res.writeHead(307, { Location: options.granted.url });
87689
87754
  res.end(() => {
87690
87755
  finish(exchange);
@@ -87777,24 +87842,25 @@ async function readJson(response, logger$2) {
87777
87842
  }
87778
87843
  }
87779
87844
  __name$1(readJson, "readJson");
87780
- async function buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2) {
87845
+ async function buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2, cliDisplayName) {
87781
87846
  const headers = { "Content-Type": "application/x-www-form-urlencoded" };
87782
87847
  if (await domainUsesAccess(getAuthDomainFromEnv(), logger$2)) {
87783
87848
  logger$2.debug("Using Cloudflare Access to get an access token for the device authorization request");
87784
87849
  Object.assign(headers, await getCloudflareAccessHeaders({
87785
87850
  logger: logger$2,
87786
- isNonInteractiveOrCI: isNonInteractiveOrCI2
87851
+ isNonInteractiveOrCI: isNonInteractiveOrCI2,
87852
+ cliDisplayName
87787
87853
  }));
87788
87854
  }
87789
87855
  return headers;
87790
87856
  }
87791
87857
  __name$1(buildDeviceAuthHeaders, "buildDeviceAuthHeaders");
87792
- async function requestDeviceAuthorization(scopes, clientId, logger$2, isNonInteractiveOrCI2) {
87858
+ async function requestDeviceAuthorization(scopes, clientId, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
87793
87859
  const params = new URLSearchParams({
87794
87860
  client_id: clientId,
87795
87861
  scope: [...scopes, "offline_access"].join(" ")
87796
87862
  });
87797
- const headers = await buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2);
87863
+ const headers = await buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2, cliDisplayName);
87798
87864
  const deviceAuthUrl = getDeviceAuthUrl();
87799
87865
  logger$2.debug("Fetching device authorization from", deviceAuthUrl);
87800
87866
  const response = await (0, import_undici$2.fetch)(deviceAuthUrl, {
@@ -87816,12 +87882,12 @@ Enable debug logging to see the full response.`, { telemetryMessage: "user devic
87816
87882
  return deviceAuth;
87817
87883
  }
87818
87884
  __name$1(requestDeviceAuthorization, "requestDeviceAuthorization");
87819
- async function pollDeviceToken(deviceCode, clientId, logger$2, isNonInteractiveOrCI2) {
87885
+ async function pollDeviceToken(deviceCode, clientId, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
87820
87886
  const response = await fetchAuthToken(new URLSearchParams({
87821
87887
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
87822
87888
  device_code: deviceCode,
87823
87889
  client_id: clientId
87824
- }), logger$2, isNonInteractiveOrCI2);
87890
+ }), logger$2, isNonInteractiveOrCI2, cliDisplayName);
87825
87891
  const body = await readJson(response, logger$2);
87826
87892
  const error$3 = getStringMember(body, "error");
87827
87893
  if (error$3 !== void 0) return {
@@ -87855,7 +87921,7 @@ function sleep(seconds) {
87855
87921
  __name$1(sleep, "sleep");
87856
87922
  async function getOauthTokenViaDeviceFlow(options, ctx) {
87857
87923
  const { logger: logger$2, openInBrowser: openInBrowser$1, isNonInteractiveOrCI: isNonInteractiveOrCI2 } = ctx;
87858
- const deviceAuth = await requestDeviceAuthorization(options.scopes, options.clientId, logger$2, isNonInteractiveOrCI2);
87924
+ const deviceAuth = await requestDeviceAuthorization(options.scopes, options.clientId, logger$2, isNonInteractiveOrCI2, ctx.cliDisplayName);
87859
87925
  const authDomain = getAuthDomainFromEnv();
87860
87926
  assertTrustedVerificationUrl(deviceAuth.verification_uri, {
87861
87927
  field: "verification_uri",
@@ -87871,7 +87937,7 @@ async function getOauthTokenViaDeviceFlow(options, ctx) {
87871
87937
  });
87872
87938
  const maxDurationSeconds = Math.min(deviceAuth.expires_in, DEVICE_FLOW_MAX_DURATION_SECONDS);
87873
87939
  logger$2.log(esm_default`
87874
- To authorize ${ctx.displayName}, please visit:
87940
+ To authorize ${ctx.cliDisplayName}, please visit:
87875
87941
 
87876
87942
  ${deviceAuth.verification_uri}
87877
87943
 
@@ -87895,7 +87961,7 @@ Opening a link in your default browser: ${verificationUrl}`);
87895
87961
  firstPoll = false;
87896
87962
  let result;
87897
87963
  try {
87898
- result = await pollDeviceToken(deviceAuth.device_code, options.clientId, logger$2, isNonInteractiveOrCI2);
87964
+ result = await pollDeviceToken(deviceAuth.device_code, options.clientId, logger$2, isNonInteractiveOrCI2, ctx.cliDisplayName);
87899
87965
  } catch (e) {
87900
87966
  logger$2.debug("Ignoring transient error while polling for token:", e);
87901
87967
  lastPollFailure = e instanceof Error ? e.message : String(e);
@@ -87914,7 +87980,7 @@ Enable debug logging to see the full response.`, { telemetryMessage: "user devic
87914
87980
  case "slow_down":
87915
87981
  intervalSeconds += 5;
87916
87982
  continue;
87917
- case "access_denied": throw new UserError(`Consent denied. You must grant consent to ${ctx.displayName} in order to login.
87983
+ case "access_denied": throw new UserError(`Consent denied. You must grant consent to ${ctx.cliDisplayName} in order to login.
87918
87984
  If you don't want to do this consider passing an API token via the \`CLOUDFLARE_API_TOKEN\` environment variable.`, { telemetryMessage: "user device-flow consent denied" });
87919
87985
  case "expired_token": throw new UserError(`Device code expired before the request was approved. Please run \`${ctx.deviceLoginCommand}\` again to obtain a new code.`, { telemetryMessage: "user device-flow code expired" });
87920
87986
  default: throw toErrorClass(result.error);
@@ -88021,7 +88087,7 @@ function createOAuthFlow(ctx) {
88021
88087
  const { token: { value: oauth_token, expiry: expiration_time } = {
88022
88088
  value: "",
88023
88089
  expiry: ""
88024
- }, refreshToken: { value: refresh_token } = {}, scopes } = await exchangeRefreshTokenForAccessToken(ctx.logger, ctx.isNonInteractiveOrCI, getClientId(), storage);
88090
+ }, refreshToken: { value: refresh_token } = {}, scopes } = await exchangeRefreshTokenForAccessToken(ctx.logger, ctx.isNonInteractiveOrCI, getClientId(), storage, ctx.cliDisplayName);
88025
88091
  storage.write({
88026
88092
  oauth_token,
88027
88093
  expiration_time,
@@ -88031,7 +88097,7 @@ function createOAuthFlow(ctx) {
88031
88097
  return "refreshed";
88032
88098
  } catch (e) {
88033
88099
  ctx.logger.debug(`Token refresh failed: ${e instanceof Error ? e.message : String(e)}`);
88034
- return e instanceof ErrorAuthServerUnreachable ? "unreachable" : "rejected";
88100
+ return e instanceof ErrorAuthServerUnreachable || e instanceof Error && e.name === "TimeoutError" ? "unreachable" : "rejected";
88035
88101
  }
88036
88102
  }
88037
88103
  __name$1(refreshToken, "refreshToken");
@@ -88143,7 +88209,7 @@ function createOAuthFlow(ctx) {
88143
88209
  }
88144
88210
  __name$1(getActiveTemporaryAccount, "getActiveTemporaryAccount");
88145
88211
  async function activateTemporaryAccount() {
88146
- if (!ctx.temporary) throw new UserError("Temporary preview accounts are not supported by this CLI.", { telemetryMessage: "user temporary account unsupported" });
88212
+ if (!ctx.temporary) throw new UserError(`Temporary preview accounts are not supported by ${ctx.cliDisplayName}.`, { telemetryMessage: "user temporary account unsupported" });
88147
88213
  const result = await getOrCreateTemporaryPreviewAccount({
88148
88214
  ...ctx.temporary,
88149
88215
  ...temporaryRequest ? { request: temporaryRequest } : {}
@@ -89183,7 +89249,7 @@ function scrubEncryptedCredentials(options) {
89183
89249
  __name$1(scrubEncryptedCredentials, "scrubEncryptedCredentials");
89184
89250
 
89185
89251
  //#endregion
89186
- //#region ../workers-auth/dist/chunk-PGZZHNWG.mjs
89252
+ //#region ../workers-auth/dist/chunk-F2REEYJC.mjs
89187
89253
  createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
89188
89254
  function createPreferences(getConfigPath) {
89189
89255
  function getUserPreferencesPath() {
@@ -89928,13 +89994,15 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
89928
89994
  purgeOnLoginOrLogout: configCache.purgeConfigCaches,
89929
89995
  clientId: descriptor.clientId,
89930
89996
  consent: descriptor.consent,
89931
- displayName: descriptor.displayName,
89997
+ cliDisplayName: descriptor.displayName,
89932
89998
  deviceLoginCommand: descriptor.commands.deviceLogin,
89933
89999
  redirectUri: descriptor.redirectUri,
89934
90000
  storageFactory: credentialStorage.storageFactory,
89935
90001
  allowGlobalAuthKey,
89936
90002
  temporary: {
89937
90003
  storage: createFileStorage(descriptor.fileFormat, descriptor.getTemporaryAccountConfigPath),
90004
+ cliDisplayName: descriptor.displayName,
90005
+ logoutCommand: descriptor.commands.logout,
89938
90006
  prompt: createTemporaryTermsPrompt({
89939
90007
  temporaryAccountLogger,
89940
90008
  prompt: ctx.prompt
@@ -90385,6 +90453,7 @@ var CF_CLIENT_REGISTERED_SCOPES = [
90385
90453
  "email_sending:read",
90386
90454
  "email_sending:write",
90387
90455
  "firstpartytags:write",
90456
+ "hyperdrive-planetscale:setup",
90388
90457
  "images:read",
90389
90458
  "images:write",
90390
90459
  "lb:edit",
@@ -90826,16 +90895,19 @@ var CF_CLIENT_REGISTERED_SCOPES = [
90826
90895
  "zone.read",
90827
90896
  "zone.write"
90828
90897
  ];
90829
- var CF_UNGRANTABLE_SCOPE_SET = new Set([
90898
+ var CF_REGISTERED_BUT_UNGRANTABLE_SCOPES = [
90830
90899
  "billing:read",
90831
90900
  "billing:write",
90832
90901
  "email_routing:read",
90833
90902
  "email_sending:read",
90834
90903
  "notebook-managed:read",
90835
90904
  "oauth_account_ssl_and_certificates_write"
90836
- ]);
90905
+ ];
90906
+ var CF_EXPLICIT_ONLY_SCOPES = ["hyperdrive-planetscale:setup"];
90907
+ var CF_UNGRANTABLE_SCOPE_SET = new Set(CF_REGISTERED_BUT_UNGRANTABLE_SCOPES);
90837
90908
  var CF_REQUESTABLE_SCOPES = CF_CLIENT_REGISTERED_SCOPES.filter((scope) => !CF_UNGRANTABLE_SCOPE_SET.has(scope));
90838
- var DefaultScopeKeys$1 = [...CF_REQUESTABLE_SCOPES];
90909
+ var CF_EXPLICIT_ONLY_SCOPE_SET = new Set(CF_EXPLICIT_ONLY_SCOPES);
90910
+ var DefaultScopeKeys$1 = CF_REQUESTABLE_SCOPES.filter((scope) => !CF_EXPLICIT_ONLY_SCOPE_SET.has(scope));
90839
90911
  function setLoginScopeKeys$1(scopes) {
90840
90912
  DefaultScopeKeys$1 = scopes;
90841
90913
  }
@@ -90867,6 +90939,7 @@ var CF_CLI = {
90867
90939
  displayName: CF_DISPLAY_NAME,
90868
90940
  commands: {
90869
90941
  login: "cf auth login",
90942
+ logout: "cf auth logout",
90870
90943
  whoami: "cf auth whoami",
90871
90944
  createProfile: "cf auth create",
90872
90945
  deviceLogin: "cf auth login"
@@ -90993,6 +91066,7 @@ var WRANGLER_CLI = {
90993
91066
  displayName: WRANGLER_DISPLAY_NAME,
90994
91067
  commands: {
90995
91068
  login: "wrangler login",
91069
+ logout: "wrangler logout",
90996
91070
  whoami: "wrangler whoami",
90997
91071
  createProfile: "wrangler auth create",
90998
91072
  deviceLogin: "wrangler login --device"
@@ -91731,7 +91805,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
91731
91805
  //#endregion
91732
91806
  //#region ../remote-bindings/dist/index.mjs
91733
91807
  var import_undici = require_undici();
91734
- var version$2 = "0.0.45";
91808
+ var version$2 = "0.0.46";
91735
91809
  var NoDefaultValueProvided = class extends UserError {
91736
91810
  constructor() {
91737
91811
  super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
@@ -92026,10 +92100,13 @@ async function getOrRegisterWorkersDevSubdomain(complianceConfig, account, abort
92026
92100
  * fails for any reason (expected with particular zone settings).
92027
92101
  * Rethrows AbortError so callers can handle cancellation.
92028
92102
  */
92029
- async function tryExpandToken(exchangeUrl, abortSignal) {
92103
+ async function tryExpandToken(exchangeUrl, cliDisplayName, abortSignal) {
92030
92104
  try {
92031
92105
  const switchedExchangeUrl = new URL$1(exchangeUrl);
92032
- const headers = { ...await getAccessHeaders(switchedExchangeUrl.hostname, { logger }) };
92106
+ const headers = { ...await getAccessHeaders(switchedExchangeUrl.hostname, {
92107
+ logger,
92108
+ cliDisplayName
92109
+ }) };
92033
92110
  logger.debug("-- START EXCHANGE API REQUEST:");
92034
92111
  logger.debug("-- END EXCHANGE API REQUEST");
92035
92112
  const exchangeResponse = await (0, import_undici.fetch)(switchedExchangeUrl, {
@@ -92052,10 +92129,10 @@ async function tryExpandToken(exchangeUrl, abortSignal) {
92052
92129
  /**
92053
92130
  * Generates a preview session token.
92054
92131
  */
92055
- async function createPreviewSession(complianceConfig, account, abortSignal, name) {
92132
+ async function createPreviewSession(complianceConfig, account, abortSignal, name, cliDisplayName) {
92056
92133
  const { accountId } = account;
92057
92134
  const { token, exchange_url } = await fetchResult(complianceConfig, account, `/accounts/${accountId}/workers/subdomain/edge-preview`, void 0, withTimeout(abortSignal));
92058
- const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, withTimeout(abortSignal)) ?? token : token;
92135
+ const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, cliDisplayName, withTimeout(abortSignal)) ?? token : token;
92059
92136
  try {
92060
92137
  return {
92061
92138
  value: previewSessionToken,
@@ -92238,7 +92315,7 @@ var RemoteRuntimeController = class {
92238
92315
  }
92239
92316
  async #previewSession(props) {
92240
92317
  try {
92241
- return await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name), logger, void 0, void 0, this.#abortController.signal);
92318
+ return await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name, props.cliDisplayName), logger, void 0, void 0, this.#abortController.signal);
92242
92319
  } catch (err) {
92243
92320
  if (err instanceof Error && err.name == "AbortError") return;
92244
92321
  handlePreviewSessionCreationError(err, props.accountId);
@@ -92295,7 +92372,8 @@ var RemoteRuntimeController = class {
92295
92372
  complianceConfig: { compliance_region: config$2.complianceRegion },
92296
92373
  accountId: auth.accountId,
92297
92374
  apiToken: auth.apiToken,
92298
- name: config$2.name
92375
+ name: config$2.name,
92376
+ cliDisplayName: config$2.cliDisplayName
92299
92377
  });
92300
92378
  }
92301
92379
  async #updatePreviewToken(config$2, bundle, auth, bundleId) {
@@ -92309,11 +92387,13 @@ var RemoteRuntimeController = class {
92309
92387
  bindings: config$2.bindings,
92310
92388
  compatibilityDate: config$2.compatibilityDate,
92311
92389
  compatibilityFlags: config$2.compatibilityFlags,
92390
+ cliDisplayName: config$2.cliDisplayName,
92312
92391
  bundleId
92313
92392
  });
92314
92393
  if (bundleId !== this.#currentBundleId || !token) return false;
92315
92394
  const accessHeaders = await getAccessHeaders(token.host, {
92316
92395
  logger,
92396
+ cliDisplayName: config$2.cliDisplayName,
92317
92397
  previewToken: token.value
92318
92398
  });
92319
92399
  const proxyData = {
@@ -92515,6 +92595,7 @@ async function startRemoteProxySession(bindings, options) {
92515
92595
  const rawBindings = toRawBindings(bindings);
92516
92596
  const workerConfig = {
92517
92597
  name: options.workerName ?? randomUUID(),
92598
+ cliDisplayName: options.cliDisplayName,
92518
92599
  entrypointSource: ProxyServerWorker_default,
92519
92600
  compatibilityDate: "2025-04-28",
92520
92601
  compatibilityFlags: [],
@@ -92616,6 +92697,7 @@ async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExist
92616
92697
  remoteProxySession = await startSession(remoteBindings, {
92617
92698
  workerName: workerConfigObject.name,
92618
92699
  complianceRegion: workerConfigObject.complianceRegion,
92700
+ cliDisplayName: context.cliDisplayName,
92619
92701
  auth: getRemoteBindingsAuthHook(auth, workerConfigObject.account_id, workerConfigObject.profileDir, context.logger),
92620
92702
  logger: context.logger
92621
92703
  });
@@ -92623,6 +92705,7 @@ async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExist
92623
92705
  if (Object.keys(remoteBindings).length > 0) remoteProxySession = await startSession(remoteBindings, {
92624
92706
  workerName: workerConfigObject.name,
92625
92707
  complianceRegion: workerConfigObject.complianceRegion,
92708
+ cliDisplayName: context.cliDisplayName,
92626
92709
  auth: getRemoteBindingsAuthHook(auth, workerConfigObject.account_id, workerConfigObject.profileDir, context.logger),
92627
92710
  logger: context.logger
92628
92711
  });
@@ -95507,7 +95590,10 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
95507
95590
  complianceRegion: worker.config.compliance_region,
95508
95591
  account_id: worker.config.account_id,
95509
95592
  profileDir: resolvedViteConfig.root
95510
- }, preExistingRemoteProxySession ?? null, void 0, { logger: createRemoteBindingsLogger(viteDevServer.config.logger) });
95593
+ }, preExistingRemoteProxySession ?? null, void 0, {
95594
+ cliDisplayName: resolvedPluginConfig.cliDisplayName,
95595
+ logger: createRemoteBindingsLogger(viteDevServer.config.logger)
95596
+ });
95511
95597
  if (worker.config.configPath && remoteProxySessionData) remoteProxySessionsDataMap.set(worker.config.configPath, remoteProxySessionData);
95512
95598
  let containerBuildId;
95513
95599
  if (worker.config.containers?.length && worker.config.dev.enable_containers) {
@@ -95725,7 +95811,10 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
95725
95811
  complianceRegion: workerConfig.compliance_region,
95726
95812
  account_id: workerConfig.account_id,
95727
95813
  profileDir: resolvedViteConfig.root
95728
- }, preExistingRemoteProxySessionData ?? null, void 0, { logger: createRemoteBindingsLogger(vitePreviewServer.config.logger) });
95814
+ }, preExistingRemoteProxySessionData ?? null, void 0, {
95815
+ cliDisplayName: resolvedPluginConfig.cliDisplayName,
95816
+ logger: createRemoteBindingsLogger(vitePreviewServer.config.logger)
95817
+ });
95729
95818
  if (workerConfig.configPath && remoteProxySessionData) remoteProxySessionsDataMap.set(workerConfig.configPath, remoteProxySessionData);
95730
95819
  let containerBuildId;
95731
95820
  if (workerConfig.containers?.length && workerConfig.dev.enable_containers) {
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var package_default = {
3
3
  name: "@cloudflare/vite-plugin",
4
- version: "1.63.1",
4
+ version: "1.63.2",
5
5
  description: "Cloudflare plugin for Vite",
6
6
  keywords: [
7
7
  "cloudflare",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "1.63.1",
3
+ "version": "1.63.2",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -44,8 +44,8 @@
44
44
  "workerd": "1.20261006.1",
45
45
  "ws": "8.21.0",
46
46
  "@cloudflare/unenv-preset": "2.16.2",
47
- "miniflare": "5.20261006.1-alpha",
48
- "wrangler": "4.149.0"
47
+ "wrangler": "4.150.0",
48
+ "miniflare": "5.20261006.2-beta"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@cloudflare/workers-types": "^5.20261006.1",
@@ -69,19 +69,19 @@
69
69
  "vite": "8.1.5",
70
70
  "vite-legacy": "npm:vite@7.1.12",
71
71
  "vitest": "4.1.0",
72
- "@cloudflare/config": "0.24.1",
73
- "@cloudflare/build-output-utils": "0.9.0",
74
- "@cloudflare/containers-shared": "0.21.5",
72
+ "@cloudflare/build-output-utils": "0.9.1",
73
+ "@cloudflare/config": "0.25.0",
74
+ "@cloudflare/containers-shared": "0.21.6",
75
+ "@cloudflare/remote-bindings": "0.0.46",
75
76
  "@cloudflare/mock-npm-registry": "0.0.0",
76
- "@cloudflare/remote-bindings": "0.0.45",
77
+ "@cloudflare/runtime-types": "0.1.10",
77
78
  "@cloudflare/workers-shared": "0.20.1",
78
- "@cloudflare/runtime-types": "0.1.9",
79
79
  "@cloudflare/workers-tsconfig": "0.0.0",
80
- "@cloudflare/workers-utils": "0.47.1"
80
+ "@cloudflare/workers-utils": "0.47.2"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "vite": "^6.1.0 || ^7.0.0 || ^8.0.0",
84
- "wrangler": "^4.149.0"
84
+ "wrangler": "^4.150.0"
85
85
  },
86
86
  "workers-sdk": {
87
87
  "prerelease": true