@cloudflare/vite-plugin 1.63.1 → 1.64.0
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 +201 -97
- package/dist/{package-BJVbY14M.mjs → package-Dggcwsyy.mjs} +1 -1
- package/package.json +11 -11
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-
|
|
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
|
|
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,
|
|
19985
|
+
function findNodeAtLocation(root, path3) {
|
|
19986
19986
|
if (!root) return;
|
|
19987
19987
|
let node$2 = root;
|
|
19988
|
-
for (let segment of
|
|
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
|
|
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 (
|
|
20220
|
-
lastSegment =
|
|
20221
|
-
parent = findNodeAtLocation(root,
|
|
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,
|
|
20464
|
-
return setProperty(text,
|
|
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";
|
|
@@ -50148,7 +50149,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
50148
50149
|
}, {});
|
|
50149
50150
|
}
|
|
50150
50151
|
__name$6(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
50151
|
-
var DEFAULT_COMPAT_DATE = "2026-10-
|
|
50152
|
+
var DEFAULT_COMPAT_DATE = "2026-10-12";
|
|
50152
50153
|
function constructWranglerConfig(config$2) {
|
|
50153
50154
|
const mappedBindings = mapWorkerMetadataBindings(config$2.bindings);
|
|
50154
50155
|
const durableObjectClassNames = config$2.bindings.filter((binding) => binding.type === "durable_object_namespace" && binding.script_name === config$2.name).map((durableObject) => durableObject.class_name);
|
|
@@ -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
|
-
|
|
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.
|
|
@@ -62984,6 +63026,10 @@ const ObservabilitySchema = strictObject({
|
|
|
62984
63026
|
destinations: array(string()).optional()
|
|
62985
63027
|
}).optional()
|
|
62986
63028
|
});
|
|
63029
|
+
const AccessSchema = strictObject({ dev: strictObject({
|
|
63030
|
+
aud: string(),
|
|
63031
|
+
identity: record(string(), unknown()).optional()
|
|
63032
|
+
}).optional() });
|
|
62987
63033
|
const PlacementSchema = union([
|
|
62988
63034
|
strictObject({
|
|
62989
63035
|
mode: _enum(["off", "smart"]),
|
|
@@ -63074,6 +63120,7 @@ const BaseWorkerSchema = strictObject({
|
|
|
63074
63120
|
limits: LimitsSchema.optional(),
|
|
63075
63121
|
logpush: boolean().optional(),
|
|
63076
63122
|
observability: ObservabilitySchema.optional(),
|
|
63123
|
+
access: AccessSchema.optional(),
|
|
63077
63124
|
workersDev: boolean().optional(),
|
|
63078
63125
|
previewUrls: boolean().optional(),
|
|
63079
63126
|
firstPartyWorker: boolean().optional(),
|
|
@@ -63388,6 +63435,7 @@ function convertTopLevel(config$2, result) {
|
|
|
63388
63435
|
result.limits = limits;
|
|
63389
63436
|
}
|
|
63390
63437
|
if (config$2.observability !== void 0) result.observability = convertObservability(config$2.observability);
|
|
63438
|
+
if (config$2.access !== void 0) result.access = config$2.access;
|
|
63391
63439
|
if (config$2.cache !== void 0) {
|
|
63392
63440
|
const cache$2 = { enabled: config$2.cache.enabled };
|
|
63393
63441
|
if (config$2.cache.crossVersionCache !== void 0) cache$2.cross_version_cache = config$2.cache.crossVersionCache;
|
|
@@ -64067,10 +64115,14 @@ function createDefinitionResolver(ctx) {
|
|
|
64067
64115
|
return resolved;
|
|
64068
64116
|
};
|
|
64069
64117
|
}
|
|
64070
|
-
async function
|
|
64118
|
+
async function normalizeWorkerEnv(resolved, resolveDefinition) {
|
|
64071
64119
|
if (!isRecord(resolved) || !isRecord(resolved.env)) return resolved;
|
|
64072
64120
|
const env$3 = { ...resolved.env };
|
|
64073
64121
|
for (const [bindingName, binding] of Object.entries(env$3)) {
|
|
64122
|
+
if (binding === false || binding === null || binding === void 0) {
|
|
64123
|
+
delete env$3[bindingName];
|
|
64124
|
+
continue;
|
|
64125
|
+
}
|
|
64074
64126
|
if (!isRecord(binding) || typeof binding.type !== "string" || !CROSS_WORKER_BINDING_TYPES.has(binding.type) || typeof binding.worker === "string") continue;
|
|
64075
64127
|
const target$1 = await resolveDefinition(binding.worker);
|
|
64076
64128
|
env$3[bindingName] = {
|
|
@@ -64149,7 +64201,7 @@ async function normalizeContainerReferences(resolved, resolveDefinition, contain
|
|
|
64149
64201
|
};
|
|
64150
64202
|
}
|
|
64151
64203
|
async function normalizeWorkerConfig(resolved, resolveDefinition, containers) {
|
|
64152
|
-
return normalizeContainerReferences(await
|
|
64204
|
+
return normalizeContainerReferences(await normalizeWorkerEnv(normalizeWorkerEntrypoint(resolved), resolveDefinition), resolveDefinition, containers);
|
|
64153
64205
|
}
|
|
64154
64206
|
function prefixIssues(issues, prefix) {
|
|
64155
64207
|
return issues.map((issue$2) => ({
|
|
@@ -71901,6 +71953,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
71901
71953
|
}
|
|
71902
71954
|
const resolvedNewConfig = normalizeNewConfig(pluginConfig.experimental?.newConfig);
|
|
71903
71955
|
const shared = {
|
|
71956
|
+
cliDisplayName: isForcedBuildOutput() ? "cf" : "Wrangler",
|
|
71904
71957
|
persistState: pluginConfig.persistState ?? true,
|
|
71905
71958
|
inspectorPort: pluginConfig.inspectorPort,
|
|
71906
71959
|
tunnel: typeof pluginConfig.tunnel === "boolean" ? { autoStart: pluginConfig.tunnel } : {
|
|
@@ -73848,6 +73901,14 @@ const resolveExtensions = [
|
|
|
73848
73901
|
".cts",
|
|
73849
73902
|
".ctx"
|
|
73850
73903
|
];
|
|
73904
|
+
/**
|
|
73905
|
+
* Worker source maps are written to the Worker's build output rather than its
|
|
73906
|
+
* public assets, so emit them by default for readable stack traces. Users can
|
|
73907
|
+
* opt out with Vite's `build.sourcemap` or the Worker's `upload_source_maps`.
|
|
73908
|
+
*/
|
|
73909
|
+
function getWorkerSourcemap(userConfig, environmentName, workerConfig) {
|
|
73910
|
+
return userConfig.environments?.[environmentName]?.build?.sourcemap ?? userConfig.build?.sourcemap ?? workerConfig.upload_source_maps ?? true;
|
|
73911
|
+
}
|
|
73851
73912
|
function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, environmentName, isEntryWorker, isParentEnvironment, hasNodeJsCompat: hasNodeJsCompat$1 }) {
|
|
73852
73913
|
const rollupOptions = isParentEnvironment ? {
|
|
73853
73914
|
input: { [MAIN_ENTRY_NAME]: VIRTUAL_WORKER_ENTRY },
|
|
@@ -73874,6 +73935,7 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
73874
73935
|
emitAssets: true,
|
|
73875
73936
|
manifest: isEntryWorker,
|
|
73876
73937
|
outDir: getOutputDirectory(userConfig, environmentName),
|
|
73938
|
+
sourcemap: getWorkerSourcemap(userConfig, environmentName, workerConfig),
|
|
73877
73939
|
copyPublicDir: false,
|
|
73878
73940
|
ssr: true,
|
|
73879
73941
|
...isRolldown ? { rolldownOptions: {
|
|
@@ -83894,7 +83956,9 @@ var fetchResult$1 = /* @__PURE__ */ __name$2(() => {
|
|
|
83894
83956
|
var fetchPagedListResult = /* @__PURE__ */ __name$2(() => {
|
|
83895
83957
|
throw new Error("initContainersSharedContext() must be called first");
|
|
83896
83958
|
}, "fetchPagedListResult");
|
|
83959
|
+
var cliPresentation = resolveCliPresentation();
|
|
83897
83960
|
function initContainersSharedContext(ctx) {
|
|
83961
|
+
cliPresentation = resolveCliPresentation(ctx.cliPresentation);
|
|
83898
83962
|
logger$1 = ctx.logger;
|
|
83899
83963
|
fetchResult$1 = ctx.fetchResult;
|
|
83900
83964
|
if (ctx.fetchPagedListResult !== void 0) fetchPagedListResult = ctx.fetchPagedListResult;
|
|
@@ -83989,7 +84053,10 @@ var runDockerCmd = /* @__PURE__ */ __name$2((dockerPath, args, stdio) => {
|
|
|
83989
84053
|
}, "runDockerCmd");
|
|
83990
84054
|
var runDockerCmdWithOutput = /* @__PURE__ */ __name$2((dockerPath, args) => {
|
|
83991
84055
|
try {
|
|
83992
|
-
return execFileSync(dockerPath, args, {
|
|
84056
|
+
return execFileSync(dockerPath, args, {
|
|
84057
|
+
encoding: "utf8",
|
|
84058
|
+
stdio: "pipe"
|
|
84059
|
+
}).trim();
|
|
83993
84060
|
} catch (error$3) {
|
|
83994
84061
|
throw new UserError(`Failed running docker command: ${error$3.message}. Command: ${dockerPath} ${args.join(" ")}`, { telemetryMessage: false });
|
|
83995
84062
|
}
|
|
@@ -84155,7 +84222,9 @@ async function pullImage(dockerPath, options, logger2, complianceConfig) {
|
|
|
84155
84222
|
await dockerLoginImageRegistry(dockerPath, domain$1);
|
|
84156
84223
|
} catch (e) {
|
|
84157
84224
|
if (!isExternalRegistry) throw e;
|
|
84158
|
-
logger2?.warn(
|
|
84225
|
+
logger2?.warn(`Unable to retrieve configured registry credentials from Cloudflare.
|
|
84226
|
+
Unless this is a public image, you will need to run \`${cliPresentation.commands.containerRegistryConfigure}\` before deploying.
|
|
84227
|
+
Attempting to pull image anyway...`);
|
|
84159
84228
|
}
|
|
84160
84229
|
const pull = runDockerCmd(dockerPath, [
|
|
84161
84230
|
"pull",
|
|
@@ -84187,7 +84256,7 @@ async function prepareContainerImagesForDev(args) {
|
|
|
84187
84256
|
dockerPath,
|
|
84188
84257
|
operation: "running dev",
|
|
84189
84258
|
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
84190
|
-
hint:
|
|
84259
|
+
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
84260
|
});
|
|
84192
84261
|
for (const options of containerOptions) {
|
|
84193
84262
|
if ("dockerfile" in options) {
|
|
@@ -85473,7 +85542,7 @@ __name$2(buildApplicationObservabilityPatch, "buildApplicationObservabilityPatch
|
|
|
85473
85542
|
function assertCanUseApplicationObservabilityTargeting(prevApp, containerConfig) {
|
|
85474
85543
|
if (!hasTopLevelOnlyObservabilityFields(containerConfig.observability)) return;
|
|
85475
85544
|
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
|
|
85545
|
+
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
85546
|
}
|
|
85478
85547
|
__name$2(assertCanUseApplicationObservabilityTargeting, "assertCanUseApplicationObservabilityTargeting");
|
|
85479
85548
|
function hasRolloutDiff(prevApp, nextApp) {
|
|
@@ -85818,7 +85887,7 @@ async function sshCommand(sshArgs) {
|
|
|
85818
85887
|
}
|
|
85819
85888
|
const ws = new import_websocket.default(sshResponse.url, { headers: {
|
|
85820
85889
|
authorization: `Bearer ${sshResponse.token}`,
|
|
85821
|
-
"user-agent":
|
|
85890
|
+
"user-agent": cliPresentation.cliName
|
|
85822
85891
|
} });
|
|
85823
85892
|
ws.binaryType = "arraybuffer";
|
|
85824
85893
|
if (useStdio) {
|
|
@@ -86710,7 +86779,7 @@ var __name$1 = (target$1, value) => __defProp$1(target$1, "name", {
|
|
|
86710
86779
|
});
|
|
86711
86780
|
|
|
86712
86781
|
//#endregion
|
|
86713
|
-
//#region ../workers-auth/dist/chunk-
|
|
86782
|
+
//#region ../workers-auth/dist/chunk-2K52M2W5.mjs
|
|
86714
86783
|
var import_undici$2 = require_undici();
|
|
86715
86784
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
86716
86785
|
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
@@ -86887,7 +86956,7 @@ Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environm
|
|
|
86887
86956
|
See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`, { telemetryMessage: "user access missing service token non interactive" });
|
|
86888
86957
|
logger$2.debug("Spawning cloudflared to get Access token for domain:");
|
|
86889
86958
|
const output$1 = await spawnCloudflaredAccessLogin(buildProbeUrl(domain$1, options.previewToken), options.signal);
|
|
86890
|
-
if (output$1.error) throw new UserError(
|
|
86959
|
+
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
86960
|
const stringOutput = output$1.stdout;
|
|
86892
86961
|
logger$2.debug("cloudflared output:", stringOutput);
|
|
86893
86962
|
const matches = stringOutput.match(/fetched your token:\n\n(.*)/m);
|
|
@@ -87105,7 +87174,7 @@ function getCachedTemporaryPreviewAccount(storage) {
|
|
|
87105
87174
|
return temporaryPreviewAccount;
|
|
87106
87175
|
}
|
|
87107
87176
|
__name$1(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
|
|
87108
|
-
async function requestPowSolution(temporaryAccountLogger) {
|
|
87177
|
+
async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
|
|
87109
87178
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewChallengeUrl(), {
|
|
87110
87179
|
method: "POST",
|
|
87111
87180
|
headers: { "Content-Type": "application/json" },
|
|
@@ -87120,7 +87189,7 @@ async function requestPowSolution(temporaryAccountLogger) {
|
|
|
87120
87189
|
}
|
|
87121
87190
|
const { challengeToken, seed, k, g } = body.result ?? {};
|
|
87122
87191
|
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(
|
|
87192
|
+
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
87193
|
temporaryAccountLogger.log("Solving proof-of-work challenge…");
|
|
87125
87194
|
return solveChallenge({
|
|
87126
87195
|
challengeToken,
|
|
@@ -87130,8 +87199,8 @@ async function requestPowSolution(temporaryAccountLogger) {
|
|
|
87130
87199
|
});
|
|
87131
87200
|
}
|
|
87132
87201
|
__name$1(requestPowSolution, "requestPowSolution");
|
|
87133
|
-
async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2) {
|
|
87134
|
-
const pow = await requestPowSolution(temporaryAccountLogger);
|
|
87202
|
+
async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2, cliDisplayName = "Wrangler") {
|
|
87203
|
+
const pow = await requestPowSolution(temporaryAccountLogger, cliDisplayName);
|
|
87135
87204
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewUrl(), {
|
|
87136
87205
|
method: "POST",
|
|
87137
87206
|
headers: { "Content-Type": "application/json" },
|
|
@@ -87184,14 +87253,14 @@ __name$1(createTemporaryPreviewAccount, "createTemporaryPreviewAccount");
|
|
|
87184
87253
|
async function getOrCreateTemporaryPreviewAccount(options) {
|
|
87185
87254
|
const cachedPreviewAccount = getCachedTemporaryPreviewAccount(options.storage);
|
|
87186
87255
|
if (cachedPreviewAccount) {
|
|
87187
|
-
if (options.request?.eventCode) throw new UserError(
|
|
87256
|
+
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
87257
|
return {
|
|
87189
87258
|
account: cachedPreviewAccount,
|
|
87190
87259
|
cached: true
|
|
87191
87260
|
};
|
|
87192
87261
|
}
|
|
87193
87262
|
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);
|
|
87263
|
+
const temporaryPreviewAccount = await createTemporaryPreviewAccount(options.temporaryAccountLogger, options.request, options.cliDisplayName);
|
|
87195
87264
|
options.storage.write(temporaryPreviewAccount);
|
|
87196
87265
|
return {
|
|
87197
87266
|
account: temporaryPreviewAccount,
|
|
@@ -87450,6 +87519,7 @@ function toErrorClass(rawError, description, uri) {
|
|
|
87450
87519
|
return error$3;
|
|
87451
87520
|
}
|
|
87452
87521
|
__name$1(toErrorClass, "toErrorClass");
|
|
87522
|
+
var TOKEN_REQUEST_TIMEOUT_MS = 3e4;
|
|
87453
87523
|
function isReturningFromAuthServer(query, state, logger$2) {
|
|
87454
87524
|
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
87525
|
const code = query.code;
|
|
@@ -87482,7 +87552,7 @@ async function getAuthURL(scopes, clientId, redirectUri, state, generators) {
|
|
|
87482
87552
|
});
|
|
87483
87553
|
}
|
|
87484
87554
|
__name$1(getAuthURL, "getAuthURL");
|
|
87485
|
-
async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI2, clientId, storage) {
|
|
87555
|
+
async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI2, clientId, storage, cliDisplayName) {
|
|
87486
87556
|
const storedRefreshToken = readStoredAuthState({
|
|
87487
87557
|
warningLogger: logger$2,
|
|
87488
87558
|
storage
|
|
@@ -87492,7 +87562,7 @@ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI
|
|
|
87492
87562
|
grant_type: "refresh_token",
|
|
87493
87563
|
refresh_token: storedRefreshToken?.value ?? "",
|
|
87494
87564
|
client_id: clientId
|
|
87495
|
-
}), logger$2, isNonInteractiveOrCI2);
|
|
87565
|
+
}), logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
87496
87566
|
if (response.status >= 400) {
|
|
87497
87567
|
let tokenExchangeResErr = void 0;
|
|
87498
87568
|
try {
|
|
@@ -87520,7 +87590,7 @@ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI
|
|
|
87520
87590
|
}
|
|
87521
87591
|
}
|
|
87522
87592
|
__name$1(exchangeRefreshTokenForAccessToken, "exchangeRefreshTokenForAccessToken");
|
|
87523
|
-
async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveOrCI2, clientId, redirectUri) {
|
|
87593
|
+
async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveOrCI2, clientId, redirectUri, cliDisplayName) {
|
|
87524
87594
|
const { authorizationCode, codeVerifier = "" } = state;
|
|
87525
87595
|
if (!codeVerifier) logger$2.warn("No code verifier is being sent.");
|
|
87526
87596
|
else if (!authorizationCode) logger$2.warn("No authorization grant code is being passed.");
|
|
@@ -87530,7 +87600,7 @@ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveO
|
|
|
87530
87600
|
redirect_uri: redirectUri,
|
|
87531
87601
|
client_id: clientId,
|
|
87532
87602
|
code_verifier: codeVerifier
|
|
87533
|
-
}), logger$2, isNonInteractiveOrCI2);
|
|
87603
|
+
}), logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
87534
87604
|
if (!response.ok) {
|
|
87535
87605
|
const { error: error$3 } = await getJSONFromResponse(response, logger$2);
|
|
87536
87606
|
if (error$3 === "invalid_grant") logger$2.log("Expired! Auth code or refresh token needs to be renewed.");
|
|
@@ -87550,14 +87620,15 @@ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveO
|
|
|
87550
87620
|
};
|
|
87551
87621
|
}
|
|
87552
87622
|
__name$1(exchangeAuthCodeForAccessToken, "exchangeAuthCodeForAccessToken");
|
|
87553
|
-
async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2) {
|
|
87623
|
+
async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
87554
87624
|
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
|
87555
87625
|
logger$2.debug("fetching auth token", `grant_type=${body.get("grant_type") ?? "<unknown>"}`);
|
|
87556
87626
|
if (await domainUsesAccess(getAuthDomainFromEnv(), logger$2)) {
|
|
87557
87627
|
logger$2.debug("Using Cloudflare Access to get an access token for the auth request");
|
|
87558
87628
|
const accessHeaders = await getCloudflareAccessHeaders({
|
|
87559
87629
|
logger: logger$2,
|
|
87560
|
-
isNonInteractiveOrCI: isNonInteractiveOrCI2
|
|
87630
|
+
isNonInteractiveOrCI: isNonInteractiveOrCI2,
|
|
87631
|
+
cliDisplayName
|
|
87561
87632
|
});
|
|
87562
87633
|
Object.assign(headers, accessHeaders);
|
|
87563
87634
|
}
|
|
@@ -87566,14 +87637,15 @@ async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2) {
|
|
|
87566
87637
|
const response = await (0, import_undici$2.fetch)(getTokenUrlFromEnv(), {
|
|
87567
87638
|
method: "POST",
|
|
87568
87639
|
body: body.toString(),
|
|
87569
|
-
headers
|
|
87640
|
+
headers,
|
|
87641
|
+
signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
|
|
87570
87642
|
});
|
|
87571
87643
|
if (!response.ok) logger$2.debug("Failed to fetch auth token:", response.status, response.statusText);
|
|
87572
87644
|
return response;
|
|
87573
87645
|
} catch (e) {
|
|
87574
87646
|
logger$2.debug("Failed to fetch auth token:", e);
|
|
87575
87647
|
const cause = e?.cause;
|
|
87576
|
-
const code = typeof cause?.code === "string" ? ` (${cause.code})` : "";
|
|
87648
|
+
const code = e?.name === "TimeoutError" ? ` (timed out after ${TOKEN_REQUEST_TIMEOUT_MS / 1e3} seconds)` : typeof cause?.code === "string" ? ` (${cause.code})` : "";
|
|
87577
87649
|
throw new ErrorAuthServerUnreachable(`Could not reach the Cloudflare auth server at ${getTokenUrlFromEnv()}${code}.`, {
|
|
87578
87650
|
cause: e,
|
|
87579
87651
|
telemetryMessage: "user oauth token endpoint unreachable"
|
|
@@ -87595,6 +87667,41 @@ async function getJSONFromResponse(response, logger$2) {
|
|
|
87595
87667
|
}
|
|
87596
87668
|
}
|
|
87597
87669
|
__name$1(getJSONFromResponse, "getJSONFromResponse");
|
|
87670
|
+
function renderOauthErrorPage(cliDisplayName, detail) {
|
|
87671
|
+
const escape = /* @__PURE__ */ __name$1((value) => value.replace(/[&<>"']/g, (character) => ({
|
|
87672
|
+
"&": "&",
|
|
87673
|
+
"<": "<",
|
|
87674
|
+
">": ">",
|
|
87675
|
+
"\"": """,
|
|
87676
|
+
"'": "'"
|
|
87677
|
+
})[character]), "escape");
|
|
87678
|
+
const codeRow = detail.code ? `<p>Code: <code>${escape(detail.code)}</code></p>` : "";
|
|
87679
|
+
const descriptionRow = detail.description ? `<p class="detail">${escape(detail.description)}</p>` : "";
|
|
87680
|
+
const escapedDisplayName = escape(cliDisplayName);
|
|
87681
|
+
return esm_default`
|
|
87682
|
+
<!doctype html>
|
|
87683
|
+
<html lang="en">
|
|
87684
|
+
<head>
|
|
87685
|
+
<meta charset="utf-8" />
|
|
87686
|
+
<title>${escapedDisplayName} login failed</title>
|
|
87687
|
+
<style>
|
|
87688
|
+
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; }
|
|
87689
|
+
h1 { color: #c12d3f; }
|
|
87690
|
+
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
87691
|
+
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
87692
|
+
</style>
|
|
87693
|
+
</head>
|
|
87694
|
+
<body>
|
|
87695
|
+
<h1>${escapedDisplayName} login failed</h1>
|
|
87696
|
+
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
87697
|
+
${codeRow}
|
|
87698
|
+
${descriptionRow}
|
|
87699
|
+
<p>You can close this tab and return to your terminal for more details.</p>
|
|
87700
|
+
</body>
|
|
87701
|
+
</html>
|
|
87702
|
+
`;
|
|
87703
|
+
}
|
|
87704
|
+
__name$1(renderOauthErrorPage, "renderOauthErrorPage");
|
|
87598
87705
|
async function getOauthToken(options, state, ctx, generators) {
|
|
87599
87706
|
const urlToOpen = await getAuthURL(options.scopes, options.clientId, options.redirectUri, state, generators);
|
|
87600
87707
|
const callbackPath = new URL(options.redirectUri).pathname;
|
|
@@ -87622,35 +87729,8 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
87622
87729
|
}
|
|
87623
87730
|
__name$1(finish, "finish");
|
|
87624
87731
|
function renderErrorPage(detail) {
|
|
87625
|
-
const escape = /* @__PURE__ */ __name$1((s) => s.replace(/[&<>"']/g, (c$1) => ({
|
|
87626
|
-
"&": "&",
|
|
87627
|
-
"<": "<",
|
|
87628
|
-
">": ">",
|
|
87629
|
-
"\"": """,
|
|
87630
|
-
"'": "'"
|
|
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
87732
|
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
87653
|
-
res.end(
|
|
87733
|
+
res.end(renderOauthErrorPage(ctx.cliDisplayName, detail));
|
|
87654
87734
|
}
|
|
87655
87735
|
__name$1(renderErrorPage, "renderErrorPage");
|
|
87656
87736
|
assert(req.url, "This request doesn't have a URL");
|
|
@@ -87684,7 +87764,7 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
87684
87764
|
return;
|
|
87685
87765
|
}
|
|
87686
87766
|
try {
|
|
87687
|
-
const exchange = await exchangeAuthCodeForAccessToken(state, ctx.logger, ctx.isNonInteractiveOrCI, options.clientId, options.redirectUri);
|
|
87767
|
+
const exchange = await exchangeAuthCodeForAccessToken(state, ctx.logger, ctx.isNonInteractiveOrCI, options.clientId, options.redirectUri, ctx.cliDisplayName);
|
|
87688
87768
|
res.writeHead(307, { Location: options.granted.url });
|
|
87689
87769
|
res.end(() => {
|
|
87690
87770
|
finish(exchange);
|
|
@@ -87777,24 +87857,25 @@ async function readJson(response, logger$2) {
|
|
|
87777
87857
|
}
|
|
87778
87858
|
}
|
|
87779
87859
|
__name$1(readJson, "readJson");
|
|
87780
|
-
async function buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2) {
|
|
87860
|
+
async function buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
87781
87861
|
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
|
87782
87862
|
if (await domainUsesAccess(getAuthDomainFromEnv(), logger$2)) {
|
|
87783
87863
|
logger$2.debug("Using Cloudflare Access to get an access token for the device authorization request");
|
|
87784
87864
|
Object.assign(headers, await getCloudflareAccessHeaders({
|
|
87785
87865
|
logger: logger$2,
|
|
87786
|
-
isNonInteractiveOrCI: isNonInteractiveOrCI2
|
|
87866
|
+
isNonInteractiveOrCI: isNonInteractiveOrCI2,
|
|
87867
|
+
cliDisplayName
|
|
87787
87868
|
}));
|
|
87788
87869
|
}
|
|
87789
87870
|
return headers;
|
|
87790
87871
|
}
|
|
87791
87872
|
__name$1(buildDeviceAuthHeaders, "buildDeviceAuthHeaders");
|
|
87792
|
-
async function requestDeviceAuthorization(scopes, clientId, logger$2, isNonInteractiveOrCI2) {
|
|
87873
|
+
async function requestDeviceAuthorization(scopes, clientId, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
87793
87874
|
const params = new URLSearchParams({
|
|
87794
87875
|
client_id: clientId,
|
|
87795
87876
|
scope: [...scopes, "offline_access"].join(" ")
|
|
87796
87877
|
});
|
|
87797
|
-
const headers = await buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2);
|
|
87878
|
+
const headers = await buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
87798
87879
|
const deviceAuthUrl = getDeviceAuthUrl();
|
|
87799
87880
|
logger$2.debug("Fetching device authorization from", deviceAuthUrl);
|
|
87800
87881
|
const response = await (0, import_undici$2.fetch)(deviceAuthUrl, {
|
|
@@ -87816,12 +87897,12 @@ Enable debug logging to see the full response.`, { telemetryMessage: "user devic
|
|
|
87816
87897
|
return deviceAuth;
|
|
87817
87898
|
}
|
|
87818
87899
|
__name$1(requestDeviceAuthorization, "requestDeviceAuthorization");
|
|
87819
|
-
async function pollDeviceToken(deviceCode, clientId, logger$2, isNonInteractiveOrCI2) {
|
|
87900
|
+
async function pollDeviceToken(deviceCode, clientId, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
87820
87901
|
const response = await fetchAuthToken(new URLSearchParams({
|
|
87821
87902
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
87822
87903
|
device_code: deviceCode,
|
|
87823
87904
|
client_id: clientId
|
|
87824
|
-
}), logger$2, isNonInteractiveOrCI2);
|
|
87905
|
+
}), logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
87825
87906
|
const body = await readJson(response, logger$2);
|
|
87826
87907
|
const error$3 = getStringMember(body, "error");
|
|
87827
87908
|
if (error$3 !== void 0) return {
|
|
@@ -87855,7 +87936,7 @@ function sleep(seconds) {
|
|
|
87855
87936
|
__name$1(sleep, "sleep");
|
|
87856
87937
|
async function getOauthTokenViaDeviceFlow(options, ctx) {
|
|
87857
87938
|
const { logger: logger$2, openInBrowser: openInBrowser$1, isNonInteractiveOrCI: isNonInteractiveOrCI2 } = ctx;
|
|
87858
|
-
const deviceAuth = await requestDeviceAuthorization(options.scopes, options.clientId, logger$2, isNonInteractiveOrCI2);
|
|
87939
|
+
const deviceAuth = await requestDeviceAuthorization(options.scopes, options.clientId, logger$2, isNonInteractiveOrCI2, ctx.cliDisplayName);
|
|
87859
87940
|
const authDomain = getAuthDomainFromEnv();
|
|
87860
87941
|
assertTrustedVerificationUrl(deviceAuth.verification_uri, {
|
|
87861
87942
|
field: "verification_uri",
|
|
@@ -87871,7 +87952,7 @@ async function getOauthTokenViaDeviceFlow(options, ctx) {
|
|
|
87871
87952
|
});
|
|
87872
87953
|
const maxDurationSeconds = Math.min(deviceAuth.expires_in, DEVICE_FLOW_MAX_DURATION_SECONDS);
|
|
87873
87954
|
logger$2.log(esm_default`
|
|
87874
|
-
To authorize ${ctx.
|
|
87955
|
+
To authorize ${ctx.cliDisplayName}, please visit:
|
|
87875
87956
|
|
|
87876
87957
|
${deviceAuth.verification_uri}
|
|
87877
87958
|
|
|
@@ -87895,7 +87976,7 @@ Opening a link in your default browser: ${verificationUrl}`);
|
|
|
87895
87976
|
firstPoll = false;
|
|
87896
87977
|
let result;
|
|
87897
87978
|
try {
|
|
87898
|
-
result = await pollDeviceToken(deviceAuth.device_code, options.clientId, logger$2, isNonInteractiveOrCI2);
|
|
87979
|
+
result = await pollDeviceToken(deviceAuth.device_code, options.clientId, logger$2, isNonInteractiveOrCI2, ctx.cliDisplayName);
|
|
87899
87980
|
} catch (e) {
|
|
87900
87981
|
logger$2.debug("Ignoring transient error while polling for token:", e);
|
|
87901
87982
|
lastPollFailure = e instanceof Error ? e.message : String(e);
|
|
@@ -87914,7 +87995,7 @@ Enable debug logging to see the full response.`, { telemetryMessage: "user devic
|
|
|
87914
87995
|
case "slow_down":
|
|
87915
87996
|
intervalSeconds += 5;
|
|
87916
87997
|
continue;
|
|
87917
|
-
case "access_denied": throw new UserError(`Consent denied. You must grant consent to ${ctx.
|
|
87998
|
+
case "access_denied": throw new UserError(`Consent denied. You must grant consent to ${ctx.cliDisplayName} in order to login.
|
|
87918
87999
|
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
88000
|
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
88001
|
default: throw toErrorClass(result.error);
|
|
@@ -88021,7 +88102,7 @@ function createOAuthFlow(ctx) {
|
|
|
88021
88102
|
const { token: { value: oauth_token, expiry: expiration_time } = {
|
|
88022
88103
|
value: "",
|
|
88023
88104
|
expiry: ""
|
|
88024
|
-
}, refreshToken: { value: refresh_token } = {}, scopes } = await exchangeRefreshTokenForAccessToken(ctx.logger, ctx.isNonInteractiveOrCI, getClientId(), storage);
|
|
88105
|
+
}, refreshToken: { value: refresh_token } = {}, scopes } = await exchangeRefreshTokenForAccessToken(ctx.logger, ctx.isNonInteractiveOrCI, getClientId(), storage, ctx.cliDisplayName);
|
|
88025
88106
|
storage.write({
|
|
88026
88107
|
oauth_token,
|
|
88027
88108
|
expiration_time,
|
|
@@ -88031,7 +88112,7 @@ function createOAuthFlow(ctx) {
|
|
|
88031
88112
|
return "refreshed";
|
|
88032
88113
|
} catch (e) {
|
|
88033
88114
|
ctx.logger.debug(`Token refresh failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
88034
|
-
return e instanceof ErrorAuthServerUnreachable ? "unreachable" : "rejected";
|
|
88115
|
+
return e instanceof ErrorAuthServerUnreachable || e instanceof Error && e.name === "TimeoutError" ? "unreachable" : "rejected";
|
|
88035
88116
|
}
|
|
88036
88117
|
}
|
|
88037
88118
|
__name$1(refreshToken, "refreshToken");
|
|
@@ -88143,7 +88224,7 @@ function createOAuthFlow(ctx) {
|
|
|
88143
88224
|
}
|
|
88144
88225
|
__name$1(getActiveTemporaryAccount, "getActiveTemporaryAccount");
|
|
88145
88226
|
async function activateTemporaryAccount() {
|
|
88146
|
-
if (!ctx.temporary) throw new UserError(
|
|
88227
|
+
if (!ctx.temporary) throw new UserError(`Temporary preview accounts are not supported by ${ctx.cliDisplayName}.`, { telemetryMessage: "user temporary account unsupported" });
|
|
88147
88228
|
const result = await getOrCreateTemporaryPreviewAccount({
|
|
88148
88229
|
...ctx.temporary,
|
|
88149
88230
|
...temporaryRequest ? { request: temporaryRequest } : {}
|
|
@@ -89183,7 +89264,7 @@ function scrubEncryptedCredentials(options) {
|
|
|
89183
89264
|
__name$1(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
89184
89265
|
|
|
89185
89266
|
//#endregion
|
|
89186
|
-
//#region ../workers-auth/dist/chunk-
|
|
89267
|
+
//#region ../workers-auth/dist/chunk-F2REEYJC.mjs
|
|
89187
89268
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
89188
89269
|
function createPreferences(getConfigPath) {
|
|
89189
89270
|
function getUserPreferencesPath() {
|
|
@@ -89928,13 +90009,15 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
89928
90009
|
purgeOnLoginOrLogout: configCache.purgeConfigCaches,
|
|
89929
90010
|
clientId: descriptor.clientId,
|
|
89930
90011
|
consent: descriptor.consent,
|
|
89931
|
-
|
|
90012
|
+
cliDisplayName: descriptor.displayName,
|
|
89932
90013
|
deviceLoginCommand: descriptor.commands.deviceLogin,
|
|
89933
90014
|
redirectUri: descriptor.redirectUri,
|
|
89934
90015
|
storageFactory: credentialStorage.storageFactory,
|
|
89935
90016
|
allowGlobalAuthKey,
|
|
89936
90017
|
temporary: {
|
|
89937
90018
|
storage: createFileStorage(descriptor.fileFormat, descriptor.getTemporaryAccountConfigPath),
|
|
90019
|
+
cliDisplayName: descriptor.displayName,
|
|
90020
|
+
logoutCommand: descriptor.commands.logout,
|
|
89938
90021
|
prompt: createTemporaryTermsPrompt({
|
|
89939
90022
|
temporaryAccountLogger,
|
|
89940
90023
|
prompt: ctx.prompt
|
|
@@ -90385,6 +90468,7 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
90385
90468
|
"email_sending:read",
|
|
90386
90469
|
"email_sending:write",
|
|
90387
90470
|
"firstpartytags:write",
|
|
90471
|
+
"hyperdrive-planetscale:setup",
|
|
90388
90472
|
"images:read",
|
|
90389
90473
|
"images:write",
|
|
90390
90474
|
"lb:edit",
|
|
@@ -90826,16 +90910,19 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
90826
90910
|
"zone.read",
|
|
90827
90911
|
"zone.write"
|
|
90828
90912
|
];
|
|
90829
|
-
var
|
|
90913
|
+
var CF_REGISTERED_BUT_UNGRANTABLE_SCOPES = [
|
|
90830
90914
|
"billing:read",
|
|
90831
90915
|
"billing:write",
|
|
90832
90916
|
"email_routing:read",
|
|
90833
90917
|
"email_sending:read",
|
|
90834
90918
|
"notebook-managed:read",
|
|
90835
90919
|
"oauth_account_ssl_and_certificates_write"
|
|
90836
|
-
]
|
|
90920
|
+
];
|
|
90921
|
+
var CF_EXPLICIT_ONLY_SCOPES = ["hyperdrive-planetscale:setup"];
|
|
90922
|
+
var CF_UNGRANTABLE_SCOPE_SET = new Set(CF_REGISTERED_BUT_UNGRANTABLE_SCOPES);
|
|
90837
90923
|
var CF_REQUESTABLE_SCOPES = CF_CLIENT_REGISTERED_SCOPES.filter((scope) => !CF_UNGRANTABLE_SCOPE_SET.has(scope));
|
|
90838
|
-
var
|
|
90924
|
+
var CF_EXPLICIT_ONLY_SCOPE_SET = new Set(CF_EXPLICIT_ONLY_SCOPES);
|
|
90925
|
+
var DefaultScopeKeys$1 = CF_REQUESTABLE_SCOPES.filter((scope) => !CF_EXPLICIT_ONLY_SCOPE_SET.has(scope));
|
|
90839
90926
|
function setLoginScopeKeys$1(scopes) {
|
|
90840
90927
|
DefaultScopeKeys$1 = scopes;
|
|
90841
90928
|
}
|
|
@@ -90867,6 +90954,7 @@ var CF_CLI = {
|
|
|
90867
90954
|
displayName: CF_DISPLAY_NAME,
|
|
90868
90955
|
commands: {
|
|
90869
90956
|
login: "cf auth login",
|
|
90957
|
+
logout: "cf auth logout",
|
|
90870
90958
|
whoami: "cf auth whoami",
|
|
90871
90959
|
createProfile: "cf auth create",
|
|
90872
90960
|
deviceLogin: "cf auth login"
|
|
@@ -90993,6 +91081,7 @@ var WRANGLER_CLI = {
|
|
|
90993
91081
|
displayName: WRANGLER_DISPLAY_NAME,
|
|
90994
91082
|
commands: {
|
|
90995
91083
|
login: "wrangler login",
|
|
91084
|
+
logout: "wrangler logout",
|
|
90996
91085
|
whoami: "wrangler whoami",
|
|
90997
91086
|
createProfile: "wrangler auth create",
|
|
90998
91087
|
deviceLogin: "wrangler login --device"
|
|
@@ -91731,7 +91820,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
91731
91820
|
//#endregion
|
|
91732
91821
|
//#region ../remote-bindings/dist/index.mjs
|
|
91733
91822
|
var import_undici = require_undici();
|
|
91734
|
-
var version$2 = "0.0.
|
|
91823
|
+
var version$2 = "0.0.47";
|
|
91735
91824
|
var NoDefaultValueProvided = class extends UserError {
|
|
91736
91825
|
constructor() {
|
|
91737
91826
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|
|
@@ -92026,10 +92115,13 @@ async function getOrRegisterWorkersDevSubdomain(complianceConfig, account, abort
|
|
|
92026
92115
|
* fails for any reason (expected with particular zone settings).
|
|
92027
92116
|
* Rethrows AbortError so callers can handle cancellation.
|
|
92028
92117
|
*/
|
|
92029
|
-
async function tryExpandToken(exchangeUrl, abortSignal) {
|
|
92118
|
+
async function tryExpandToken(exchangeUrl, cliDisplayName, abortSignal) {
|
|
92030
92119
|
try {
|
|
92031
92120
|
const switchedExchangeUrl = new URL$1(exchangeUrl);
|
|
92032
|
-
const headers = { ...await getAccessHeaders(switchedExchangeUrl.hostname, {
|
|
92121
|
+
const headers = { ...await getAccessHeaders(switchedExchangeUrl.hostname, {
|
|
92122
|
+
logger,
|
|
92123
|
+
cliDisplayName
|
|
92124
|
+
}) };
|
|
92033
92125
|
logger.debug("-- START EXCHANGE API REQUEST:");
|
|
92034
92126
|
logger.debug("-- END EXCHANGE API REQUEST");
|
|
92035
92127
|
const exchangeResponse = await (0, import_undici.fetch)(switchedExchangeUrl, {
|
|
@@ -92052,10 +92144,10 @@ async function tryExpandToken(exchangeUrl, abortSignal) {
|
|
|
92052
92144
|
/**
|
|
92053
92145
|
* Generates a preview session token.
|
|
92054
92146
|
*/
|
|
92055
|
-
async function createPreviewSession(complianceConfig, account, abortSignal, name) {
|
|
92147
|
+
async function createPreviewSession(complianceConfig, account, abortSignal, name, cliDisplayName) {
|
|
92056
92148
|
const { accountId } = account;
|
|
92057
92149
|
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;
|
|
92150
|
+
const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, cliDisplayName, withTimeout(abortSignal)) ?? token : token;
|
|
92059
92151
|
try {
|
|
92060
92152
|
return {
|
|
92061
92153
|
value: previewSessionToken,
|
|
@@ -92238,7 +92330,7 @@ var RemoteRuntimeController = class {
|
|
|
92238
92330
|
}
|
|
92239
92331
|
async #previewSession(props) {
|
|
92240
92332
|
try {
|
|
92241
|
-
return await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name), logger, void 0, void 0, this.#abortController.signal);
|
|
92333
|
+
return await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name, props.cliDisplayName), logger, void 0, void 0, this.#abortController.signal);
|
|
92242
92334
|
} catch (err) {
|
|
92243
92335
|
if (err instanceof Error && err.name == "AbortError") return;
|
|
92244
92336
|
handlePreviewSessionCreationError(err, props.accountId);
|
|
@@ -92295,7 +92387,8 @@ var RemoteRuntimeController = class {
|
|
|
92295
92387
|
complianceConfig: { compliance_region: config$2.complianceRegion },
|
|
92296
92388
|
accountId: auth.accountId,
|
|
92297
92389
|
apiToken: auth.apiToken,
|
|
92298
|
-
name: config$2.name
|
|
92390
|
+
name: config$2.name,
|
|
92391
|
+
cliDisplayName: config$2.cliDisplayName
|
|
92299
92392
|
});
|
|
92300
92393
|
}
|
|
92301
92394
|
async #updatePreviewToken(config$2, bundle, auth, bundleId) {
|
|
@@ -92309,11 +92402,13 @@ var RemoteRuntimeController = class {
|
|
|
92309
92402
|
bindings: config$2.bindings,
|
|
92310
92403
|
compatibilityDate: config$2.compatibilityDate,
|
|
92311
92404
|
compatibilityFlags: config$2.compatibilityFlags,
|
|
92405
|
+
cliDisplayName: config$2.cliDisplayName,
|
|
92312
92406
|
bundleId
|
|
92313
92407
|
});
|
|
92314
92408
|
if (bundleId !== this.#currentBundleId || !token) return false;
|
|
92315
92409
|
const accessHeaders = await getAccessHeaders(token.host, {
|
|
92316
92410
|
logger,
|
|
92411
|
+
cliDisplayName: config$2.cliDisplayName,
|
|
92317
92412
|
previewToken: token.value
|
|
92318
92413
|
});
|
|
92319
92414
|
const proxyData = {
|
|
@@ -92515,6 +92610,7 @@ async function startRemoteProxySession(bindings, options) {
|
|
|
92515
92610
|
const rawBindings = toRawBindings(bindings);
|
|
92516
92611
|
const workerConfig = {
|
|
92517
92612
|
name: options.workerName ?? randomUUID(),
|
|
92613
|
+
cliDisplayName: options.cliDisplayName,
|
|
92518
92614
|
entrypointSource: ProxyServerWorker_default,
|
|
92519
92615
|
compatibilityDate: "2025-04-28",
|
|
92520
92616
|
compatibilityFlags: [],
|
|
@@ -92616,6 +92712,7 @@ async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExist
|
|
|
92616
92712
|
remoteProxySession = await startSession(remoteBindings, {
|
|
92617
92713
|
workerName: workerConfigObject.name,
|
|
92618
92714
|
complianceRegion: workerConfigObject.complianceRegion,
|
|
92715
|
+
cliDisplayName: context.cliDisplayName,
|
|
92619
92716
|
auth: getRemoteBindingsAuthHook(auth, workerConfigObject.account_id, workerConfigObject.profileDir, context.logger),
|
|
92620
92717
|
logger: context.logger
|
|
92621
92718
|
});
|
|
@@ -92623,6 +92720,7 @@ async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExist
|
|
|
92623
92720
|
if (Object.keys(remoteBindings).length > 0) remoteProxySession = await startSession(remoteBindings, {
|
|
92624
92721
|
workerName: workerConfigObject.name,
|
|
92625
92722
|
complianceRegion: workerConfigObject.complianceRegion,
|
|
92723
|
+
cliDisplayName: context.cliDisplayName,
|
|
92626
92724
|
auth: getRemoteBindingsAuthHook(auth, workerConfigObject.account_id, workerConfigObject.profileDir, context.logger),
|
|
92627
92725
|
logger: context.logger
|
|
92628
92726
|
});
|
|
@@ -95507,7 +95605,10 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
95507
95605
|
complianceRegion: worker.config.compliance_region,
|
|
95508
95606
|
account_id: worker.config.account_id,
|
|
95509
95607
|
profileDir: resolvedViteConfig.root
|
|
95510
|
-
}, preExistingRemoteProxySession ?? null, void 0, {
|
|
95608
|
+
}, preExistingRemoteProxySession ?? null, void 0, {
|
|
95609
|
+
cliDisplayName: resolvedPluginConfig.cliDisplayName,
|
|
95610
|
+
logger: createRemoteBindingsLogger(viteDevServer.config.logger)
|
|
95611
|
+
});
|
|
95511
95612
|
if (worker.config.configPath && remoteProxySessionData) remoteProxySessionsDataMap.set(worker.config.configPath, remoteProxySessionData);
|
|
95512
95613
|
let containerBuildId;
|
|
95513
95614
|
if (worker.config.containers?.length && worker.config.dev.enable_containers) {
|
|
@@ -95725,7 +95826,10 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
95725
95826
|
complianceRegion: workerConfig.compliance_region,
|
|
95726
95827
|
account_id: workerConfig.account_id,
|
|
95727
95828
|
profileDir: resolvedViteConfig.root
|
|
95728
|
-
}, preExistingRemoteProxySessionData ?? null, void 0, {
|
|
95829
|
+
}, preExistingRemoteProxySessionData ?? null, void 0, {
|
|
95830
|
+
cliDisplayName: resolvedPluginConfig.cliDisplayName,
|
|
95831
|
+
logger: createRemoteBindingsLogger(vitePreviewServer.config.logger)
|
|
95832
|
+
});
|
|
95729
95833
|
if (workerConfig.configPath && remoteProxySessionData) remoteProxySessionsDataMap.set(workerConfig.configPath, remoteProxySessionData);
|
|
95730
95834
|
let containerBuildId;
|
|
95731
95835
|
if (workerConfig.containers?.length && workerConfig.dev.enable_containers) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.64.0",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"unenv": "2.0.0-rc.24",
|
|
44
|
-
"workerd": "1.
|
|
44
|
+
"workerd": "1.20261012.1",
|
|
45
45
|
"ws": "8.21.0",
|
|
46
46
|
"@cloudflare/unenv-preset": "2.16.2",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"wrangler": "4.151.0",
|
|
48
|
+
"miniflare": "5.20261012.0-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.
|
|
73
|
-
"@cloudflare/build-output-utils": "0.9.
|
|
74
|
-
"@cloudflare/containers-shared": "0.21.
|
|
72
|
+
"@cloudflare/config": "0.26.0",
|
|
73
|
+
"@cloudflare/build-output-utils": "0.9.2",
|
|
74
|
+
"@cloudflare/containers-shared": "0.21.7",
|
|
75
75
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
76
|
-
"@cloudflare/remote-bindings": "0.0.
|
|
76
|
+
"@cloudflare/remote-bindings": "0.0.47",
|
|
77
|
+
"@cloudflare/runtime-types": "0.1.11",
|
|
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.
|
|
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.
|
|
84
|
+
"wrangler": "^4.151.0"
|
|
85
85
|
},
|
|
86
86
|
"workers-sdk": {
|
|
87
87
|
"prerelease": true
|