@cloudflare/vite-plugin 2.0.0-beta.sha-91c870c02 → 2.0.0-beta.sha-8c6014f9a
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 childProcess, { execFile, execFileSync, spawn, spawnSync } from "node:chi
|
|
|
23
23
|
import * as timersPromises from "node:timers/promises";
|
|
24
24
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
25
25
|
import os$1 from "os";
|
|
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 vite from "vite";
|
|
28
28
|
import { normalizePath, version } from "vite";
|
|
29
29
|
import P from "node:readline";
|
|
@@ -19164,7 +19164,7 @@ function createFatalError(message, isJson, options) {
|
|
|
19164
19164
|
__name$3(createFatalError, "createFatalError");
|
|
19165
19165
|
|
|
19166
19166
|
//#endregion
|
|
19167
|
-
//#region ../workers-utils/dist/chunk-
|
|
19167
|
+
//#region ../workers-utils/dist/chunk-A5AS5XTW.mjs
|
|
19168
19168
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19169
19169
|
function hasKnownExportType(entry) {
|
|
19170
19170
|
const type = entry?.type;
|
|
@@ -19269,12 +19269,12 @@ function getDurableObjectClassNameToUseSQLiteMap(migrations, exports$1) {
|
|
|
19269
19269
|
return durableObjectClassNameToUseSQLiteMap;
|
|
19270
19270
|
}
|
|
19271
19271
|
__name$3(getDurableObjectClassNameToUseSQLiteMap, "getDurableObjectClassNameToUseSQLiteMap");
|
|
19272
|
-
function validateDurableObjectContainerApplications(config$3, containers = getDurableObjectContainerApps(config$3.containers)) {
|
|
19272
|
+
function validateDurableObjectContainerApplications(config$3, containers = getDurableObjectContainerApps(config$3.containers), configFileName2 = "Wrangler config file") {
|
|
19273
19273
|
const allDOs = getDurableObjectClassNameToUseSQLiteMap(config$3.migrations, config$3.exports);
|
|
19274
19274
|
for (const container of getResolvedDurableObjectContainerApps(containers, config$3.exports)) {
|
|
19275
19275
|
const maybeBoundDO = config$3.durable_objects.bindings.find((durableObject) => durableObject.class_name === container.class_name);
|
|
19276
19276
|
const useSQLite = allDOs.get(container.class_name);
|
|
19277
|
-
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
|
|
19277
|
+
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" });
|
|
19278
19278
|
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" });
|
|
19279
19279
|
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" });
|
|
19280
19280
|
}
|
|
@@ -19977,10 +19977,10 @@ function parseTree(text, errors$1 = [], options = ParseOptions.DEFAULT) {
|
|
|
19977
19977
|
return result;
|
|
19978
19978
|
}
|
|
19979
19979
|
__name$3(parseTree, "parseTree");
|
|
19980
|
-
function findNodeAtLocation(root,
|
|
19980
|
+
function findNodeAtLocation(root, path3) {
|
|
19981
19981
|
if (!root) return;
|
|
19982
19982
|
let node$2 = root;
|
|
19983
|
-
for (let segment of
|
|
19983
|
+
for (let segment of path3) if (typeof segment === "string") {
|
|
19984
19984
|
if (node$2.type !== "object" || !Array.isArray(node$2.children)) return;
|
|
19985
19985
|
let found = false;
|
|
19986
19986
|
for (const propertyNode of node$2.children) if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
@@ -20207,13 +20207,13 @@ function getNodeType(value) {
|
|
|
20207
20207
|
}
|
|
20208
20208
|
__name$3(getNodeType, "getNodeType");
|
|
20209
20209
|
function setProperty(text, originalPath, value, options) {
|
|
20210
|
-
const
|
|
20210
|
+
const path3 = originalPath.slice();
|
|
20211
20211
|
const root = parseTree(text, []);
|
|
20212
20212
|
let parent = void 0;
|
|
20213
20213
|
let lastSegment = void 0;
|
|
20214
|
-
while (
|
|
20215
|
-
lastSegment =
|
|
20216
|
-
parent = findNodeAtLocation(root,
|
|
20214
|
+
while (path3.length > 0) {
|
|
20215
|
+
lastSegment = path3.pop();
|
|
20216
|
+
parent = findNodeAtLocation(root, path3);
|
|
20217
20217
|
if (parent === void 0 && value !== void 0) if (typeof lastSegment === "string") value = { [lastSegment]: value };
|
|
20218
20218
|
else value = [value];
|
|
20219
20219
|
else break;
|
|
@@ -20455,8 +20455,8 @@ function format2(documentText, range, options) {
|
|
|
20455
20455
|
return format$2(documentText, range, options);
|
|
20456
20456
|
}
|
|
20457
20457
|
__name$3(format2, "format");
|
|
20458
|
-
function modify(text,
|
|
20459
|
-
return setProperty(text,
|
|
20458
|
+
function modify(text, path3, value, options) {
|
|
20459
|
+
return setProperty(text, path3, value, options);
|
|
20460
20460
|
}
|
|
20461
20461
|
__name$3(modify, "modify");
|
|
20462
20462
|
function applyEdits(text, edits) {
|
|
@@ -21662,7 +21662,8 @@ function configFormat(configPath) {
|
|
|
21662
21662
|
return "none";
|
|
21663
21663
|
}
|
|
21664
21664
|
__name$3(configFormat, "configFormat");
|
|
21665
|
-
function configFileName(configPath) {
|
|
21665
|
+
function configFileName(configPath, userConfigPath) {
|
|
21666
|
+
if (userConfigPath !== void 0) return path__default.basename(userConfigPath);
|
|
21666
21667
|
switch (configFormat(configPath)) {
|
|
21667
21668
|
case "toml": return "wrangler.toml";
|
|
21668
21669
|
case "json": return "wrangler.json";
|
|
@@ -50143,7 +50144,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
50143
50144
|
}, {});
|
|
50144
50145
|
}
|
|
50145
50146
|
__name$3(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
50146
|
-
var DEFAULT_COMPAT_DATE = "2026-10-
|
|
50147
|
+
var DEFAULT_COMPAT_DATE = "2026-10-12";
|
|
50147
50148
|
function constructWranglerConfig(config$3) {
|
|
50148
50149
|
const mappedBindings = mapWorkerMetadataBindings(config$3.bindings);
|
|
50149
50150
|
const durableObjectClassNames = config$3.bindings.filter((binding) => binding.type === "durable_object_namespace" && binding.script_name === config$3.name).map((durableObject) => durableObject.class_name);
|
|
@@ -52248,6 +52249,50 @@ The local dev server started at ${origin.href}
|
|
|
52248
52249
|
return new Error(errorMessage);
|
|
52249
52250
|
}
|
|
52250
52251
|
__name$3(createTunnelStartupError, "createTunnelStartupError");
|
|
52252
|
+
var WRANGLER_COMMANDS = {
|
|
52253
|
+
deploy: "wrangler deploy",
|
|
52254
|
+
preview: "wrangler preview",
|
|
52255
|
+
versionsUpload: "wrangler versions upload",
|
|
52256
|
+
versionsDeploy: "wrangler versions deploy",
|
|
52257
|
+
versionsDeployAt: /* @__PURE__ */ __name$3((n2) => `wrangler versions deploy <new-version-id>@${n2}%`, "versionsDeployAt"),
|
|
52258
|
+
triggersDeploy: "wrangler triggers deploy",
|
|
52259
|
+
d1List: "wrangler d1 list",
|
|
52260
|
+
d1Delete: "wrangler d1 delete",
|
|
52261
|
+
queuesCreate: "wrangler queues create",
|
|
52262
|
+
secretPut: "wrangler secret put",
|
|
52263
|
+
versionsSecretPut: "wrangler versions secret put",
|
|
52264
|
+
containerRegistryConfigure: "wrangler containers registries configure"
|
|
52265
|
+
};
|
|
52266
|
+
var WRANGLER_CONFIG_FIELDS = {
|
|
52267
|
+
workersDev: "workers_dev",
|
|
52268
|
+
containerObservabilityTargetPercentage: "target_instance_percentage",
|
|
52269
|
+
containerObservabilityTargetCount: "target_instance_count"
|
|
52270
|
+
};
|
|
52271
|
+
var WRANGLER_CLI_PRESENTATION = {
|
|
52272
|
+
cliName: "wrangler",
|
|
52273
|
+
displayName: "Wrangler",
|
|
52274
|
+
displayConfigFileName: "Wrangler config file",
|
|
52275
|
+
configFieldAssignmentSeparator: " = ",
|
|
52276
|
+
commands: WRANGLER_COMMANDS,
|
|
52277
|
+
configFields: WRANGLER_CONFIG_FIELDS
|
|
52278
|
+
};
|
|
52279
|
+
function resolveCliPresentation(overrides) {
|
|
52280
|
+
return {
|
|
52281
|
+
cliName: overrides?.cliName ?? WRANGLER_CLI_PRESENTATION.cliName,
|
|
52282
|
+
displayName: overrides?.displayName ?? WRANGLER_CLI_PRESENTATION.displayName,
|
|
52283
|
+
displayConfigFileName: overrides?.displayConfigFileName ?? WRANGLER_CLI_PRESENTATION.displayConfigFileName,
|
|
52284
|
+
configFieldAssignmentSeparator: overrides?.configFieldAssignmentSeparator ?? WRANGLER_CLI_PRESENTATION.configFieldAssignmentSeparator,
|
|
52285
|
+
commands: {
|
|
52286
|
+
...WRANGLER_COMMANDS,
|
|
52287
|
+
...overrides?.commands
|
|
52288
|
+
},
|
|
52289
|
+
configFields: {
|
|
52290
|
+
...WRANGLER_CONFIG_FIELDS,
|
|
52291
|
+
...overrides?.configFields
|
|
52292
|
+
}
|
|
52293
|
+
};
|
|
52294
|
+
}
|
|
52295
|
+
__name$3(resolveCliPresentation, "resolveCliPresentation");
|
|
52251
52296
|
var UPDATE_CHECK_TIMEOUT_MS = 3e3;
|
|
52252
52297
|
var CACHE_TTL_MS = 3600 * 1e3;
|
|
52253
52298
|
var NPM_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
@@ -65406,7 +65451,7 @@ var __name$1 = (target$1, value) => __defProp$2(target$1, "name", {
|
|
|
65406
65451
|
});
|
|
65407
65452
|
|
|
65408
65453
|
//#endregion
|
|
65409
|
-
//#region ../workers-auth/dist/chunk-
|
|
65454
|
+
//#region ../workers-auth/dist/chunk-RNFAO324.mjs
|
|
65410
65455
|
var import_undici$2 = require_undici();
|
|
65411
65456
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
65412
65457
|
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
@@ -65583,7 +65628,7 @@ Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environm
|
|
|
65583
65628
|
See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`, { telemetryMessage: "user access missing service token non interactive" });
|
|
65584
65629
|
logger$2.debug("Spawning cloudflared to get Access token for domain:");
|
|
65585
65630
|
const output$1 = await spawnCloudflaredAccessLogin(buildProbeUrl(domain$1, options.previewToken), options.signal);
|
|
65586
|
-
if (output$1.error) throw new UserError(
|
|
65631
|
+
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" });
|
|
65587
65632
|
const stringOutput = output$1.stdout;
|
|
65588
65633
|
logger$2.debug("cloudflared output:", stringOutput);
|
|
65589
65634
|
const matches = stringOutput.match(/fetched your token:\n\n(.*)/m);
|
|
@@ -65801,7 +65846,7 @@ function getCachedTemporaryPreviewAccount(storage) {
|
|
|
65801
65846
|
return temporaryPreviewAccount;
|
|
65802
65847
|
}
|
|
65803
65848
|
__name$1(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
|
|
65804
|
-
async function requestPowSolution(temporaryAccountLogger) {
|
|
65849
|
+
async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
|
|
65805
65850
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewChallengeUrl(), {
|
|
65806
65851
|
method: "POST",
|
|
65807
65852
|
headers: { "Content-Type": "application/json" },
|
|
@@ -65816,7 +65861,7 @@ async function requestPowSolution(temporaryAccountLogger) {
|
|
|
65816
65861
|
}
|
|
65817
65862
|
const { challengeToken, seed, k, g } = body.result ?? {};
|
|
65818
65863
|
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" });
|
|
65819
|
-
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(
|
|
65864
|
+
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" });
|
|
65820
65865
|
temporaryAccountLogger.log("Solving proof-of-work challenge…");
|
|
65821
65866
|
return solveChallenge({
|
|
65822
65867
|
challengeToken,
|
|
@@ -65826,8 +65871,8 @@ async function requestPowSolution(temporaryAccountLogger) {
|
|
|
65826
65871
|
});
|
|
65827
65872
|
}
|
|
65828
65873
|
__name$1(requestPowSolution, "requestPowSolution");
|
|
65829
|
-
async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2) {
|
|
65830
|
-
const pow = await requestPowSolution(temporaryAccountLogger);
|
|
65874
|
+
async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2, cliDisplayName = "Wrangler") {
|
|
65875
|
+
const pow = await requestPowSolution(temporaryAccountLogger, cliDisplayName);
|
|
65831
65876
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewUrl(), {
|
|
65832
65877
|
method: "POST",
|
|
65833
65878
|
headers: { "Content-Type": "application/json" },
|
|
@@ -65880,14 +65925,14 @@ __name$1(createTemporaryPreviewAccount, "createTemporaryPreviewAccount");
|
|
|
65880
65925
|
async function getOrCreateTemporaryPreviewAccount(options) {
|
|
65881
65926
|
const cachedPreviewAccount = getCachedTemporaryPreviewAccount(options.storage);
|
|
65882
65927
|
if (cachedPreviewAccount) {
|
|
65883
|
-
if (options.request?.eventCode) throw new UserError(
|
|
65928
|
+
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" });
|
|
65884
65929
|
return {
|
|
65885
65930
|
account: cachedPreviewAccount,
|
|
65886
65931
|
cached: true
|
|
65887
65932
|
};
|
|
65888
65933
|
}
|
|
65889
65934
|
if (!await options.prompt(TEMPORARY_TERMS_PROMPT, TEMPORARY_TERMS_NOTICE)) throw new UserError(TEMPORARY_TERMS_ERROR, { telemetryMessage: "user temporary terms not accepted" });
|
|
65890
|
-
const temporaryPreviewAccount = await createTemporaryPreviewAccount(options.temporaryAccountLogger, options.request);
|
|
65935
|
+
const temporaryPreviewAccount = await createTemporaryPreviewAccount(options.temporaryAccountLogger, options.request, options.cliDisplayName);
|
|
65891
65936
|
options.storage.write(temporaryPreviewAccount);
|
|
65892
65937
|
return {
|
|
65893
65938
|
account: temporaryPreviewAccount,
|
|
@@ -66146,6 +66191,7 @@ function toErrorClass(rawError, description, uri) {
|
|
|
66146
66191
|
return error$3;
|
|
66147
66192
|
}
|
|
66148
66193
|
__name$1(toErrorClass, "toErrorClass");
|
|
66194
|
+
var TOKEN_REQUEST_TIMEOUT_MS = 3e4;
|
|
66149
66195
|
function isReturningFromAuthServer(query, state, logger$2) {
|
|
66150
66196
|
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);
|
|
66151
66197
|
const code = query.code;
|
|
@@ -66178,7 +66224,7 @@ async function getAuthURL(scopes, clientId, redirectUri, state, generators) {
|
|
|
66178
66224
|
});
|
|
66179
66225
|
}
|
|
66180
66226
|
__name$1(getAuthURL, "getAuthURL");
|
|
66181
|
-
async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI2, clientId, storage) {
|
|
66227
|
+
async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI2, clientId, storage, cliDisplayName) {
|
|
66182
66228
|
const storedRefreshToken = readStoredAuthState({
|
|
66183
66229
|
warningLogger: logger$2,
|
|
66184
66230
|
storage
|
|
@@ -66188,7 +66234,7 @@ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI
|
|
|
66188
66234
|
grant_type: "refresh_token",
|
|
66189
66235
|
refresh_token: storedRefreshToken?.value ?? "",
|
|
66190
66236
|
client_id: clientId
|
|
66191
|
-
}), logger$2, isNonInteractiveOrCI2);
|
|
66237
|
+
}), logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
66192
66238
|
if (response.status >= 400) {
|
|
66193
66239
|
let tokenExchangeResErr = void 0;
|
|
66194
66240
|
try {
|
|
@@ -66216,7 +66262,7 @@ async function exchangeRefreshTokenForAccessToken(logger$2, isNonInteractiveOrCI
|
|
|
66216
66262
|
}
|
|
66217
66263
|
}
|
|
66218
66264
|
__name$1(exchangeRefreshTokenForAccessToken, "exchangeRefreshTokenForAccessToken");
|
|
66219
|
-
async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveOrCI2, clientId, redirectUri) {
|
|
66265
|
+
async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveOrCI2, clientId, redirectUri, cliDisplayName) {
|
|
66220
66266
|
const { authorizationCode, codeVerifier = "" } = state;
|
|
66221
66267
|
if (!codeVerifier) logger$2.warn("No code verifier is being sent.");
|
|
66222
66268
|
else if (!authorizationCode) logger$2.warn("No authorization grant code is being passed.");
|
|
@@ -66226,7 +66272,7 @@ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveO
|
|
|
66226
66272
|
redirect_uri: redirectUri,
|
|
66227
66273
|
client_id: clientId,
|
|
66228
66274
|
code_verifier: codeVerifier
|
|
66229
|
-
}), logger$2, isNonInteractiveOrCI2);
|
|
66275
|
+
}), logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
66230
66276
|
if (!response.ok) {
|
|
66231
66277
|
const { error: error$3 } = await getJSONFromResponse(response, logger$2);
|
|
66232
66278
|
if (error$3 === "invalid_grant") logger$2.log("Expired! Auth code or refresh token needs to be renewed.");
|
|
@@ -66246,14 +66292,15 @@ async function exchangeAuthCodeForAccessToken(state, logger$2, isNonInteractiveO
|
|
|
66246
66292
|
};
|
|
66247
66293
|
}
|
|
66248
66294
|
__name$1(exchangeAuthCodeForAccessToken, "exchangeAuthCodeForAccessToken");
|
|
66249
|
-
async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2) {
|
|
66295
|
+
async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
66250
66296
|
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
|
66251
66297
|
logger$2.debug("fetching auth token", `grant_type=${body.get("grant_type") ?? "<unknown>"}`);
|
|
66252
66298
|
if (await domainUsesAccess(getAuthDomainFromEnv(), logger$2)) {
|
|
66253
66299
|
logger$2.debug("Using Cloudflare Access to get an access token for the auth request");
|
|
66254
66300
|
const accessHeaders = await getCloudflareAccessHeaders({
|
|
66255
66301
|
logger: logger$2,
|
|
66256
|
-
isNonInteractiveOrCI: isNonInteractiveOrCI2
|
|
66302
|
+
isNonInteractiveOrCI: isNonInteractiveOrCI2,
|
|
66303
|
+
cliDisplayName
|
|
66257
66304
|
});
|
|
66258
66305
|
Object.assign(headers, accessHeaders);
|
|
66259
66306
|
}
|
|
@@ -66262,14 +66309,15 @@ async function fetchAuthToken(body, logger$2, isNonInteractiveOrCI2) {
|
|
|
66262
66309
|
const response = await (0, import_undici$2.fetch)(getTokenUrlFromEnv(), {
|
|
66263
66310
|
method: "POST",
|
|
66264
66311
|
body: body.toString(),
|
|
66265
|
-
headers
|
|
66312
|
+
headers,
|
|
66313
|
+
signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
|
|
66266
66314
|
});
|
|
66267
66315
|
if (!response.ok) logger$2.debug("Failed to fetch auth token:", response.status, response.statusText);
|
|
66268
66316
|
return response;
|
|
66269
66317
|
} catch (e) {
|
|
66270
66318
|
logger$2.debug("Failed to fetch auth token:", e);
|
|
66271
66319
|
const cause = e?.cause;
|
|
66272
|
-
const code = typeof cause?.code === "string" ? ` (${cause.code})` : "";
|
|
66320
|
+
const code = e?.name === "TimeoutError" ? ` (timed out after ${TOKEN_REQUEST_TIMEOUT_MS / 1e3} seconds)` : typeof cause?.code === "string" ? ` (${cause.code})` : "";
|
|
66273
66321
|
throw new ErrorAuthServerUnreachable(`Could not reach the Cloudflare auth server at ${getTokenUrlFromEnv()}${code}.`, {
|
|
66274
66322
|
cause: e,
|
|
66275
66323
|
telemetryMessage: "user oauth token endpoint unreachable"
|
|
@@ -66291,6 +66339,41 @@ async function getJSONFromResponse(response, logger$2) {
|
|
|
66291
66339
|
}
|
|
66292
66340
|
}
|
|
66293
66341
|
__name$1(getJSONFromResponse, "getJSONFromResponse");
|
|
66342
|
+
function renderOauthErrorPage(cliDisplayName, detail) {
|
|
66343
|
+
const escape = /* @__PURE__ */ __name$1((value) => value.replace(/[&<>"']/g, (character) => ({
|
|
66344
|
+
"&": "&",
|
|
66345
|
+
"<": "<",
|
|
66346
|
+
">": ">",
|
|
66347
|
+
"\"": """,
|
|
66348
|
+
"'": "'"
|
|
66349
|
+
})[character]), "escape");
|
|
66350
|
+
const codeRow = detail.code ? `<p>Code: <code>${escape(detail.code)}</code></p>` : "";
|
|
66351
|
+
const descriptionRow = detail.description ? `<p class="detail">${escape(detail.description)}</p>` : "";
|
|
66352
|
+
const escapedDisplayName = escape(cliDisplayName);
|
|
66353
|
+
return esm_default`
|
|
66354
|
+
<!doctype html>
|
|
66355
|
+
<html lang="en">
|
|
66356
|
+
<head>
|
|
66357
|
+
<meta charset="utf-8" />
|
|
66358
|
+
<title>${escapedDisplayName} login failed</title>
|
|
66359
|
+
<style>
|
|
66360
|
+
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; }
|
|
66361
|
+
h1 { color: #c12d3f; }
|
|
66362
|
+
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
66363
|
+
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
66364
|
+
</style>
|
|
66365
|
+
</head>
|
|
66366
|
+
<body>
|
|
66367
|
+
<h1>${escapedDisplayName} login failed</h1>
|
|
66368
|
+
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
66369
|
+
${codeRow}
|
|
66370
|
+
${descriptionRow}
|
|
66371
|
+
<p>You can close this tab and return to your terminal for more details.</p>
|
|
66372
|
+
</body>
|
|
66373
|
+
</html>
|
|
66374
|
+
`;
|
|
66375
|
+
}
|
|
66376
|
+
__name$1(renderOauthErrorPage, "renderOauthErrorPage");
|
|
66294
66377
|
async function getOauthToken(options, state, ctx, generators) {
|
|
66295
66378
|
const urlToOpen = await getAuthURL(options.scopes, options.clientId, options.redirectUri, state, generators);
|
|
66296
66379
|
const callbackPath = new URL(options.redirectUri).pathname;
|
|
@@ -66318,35 +66401,8 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
66318
66401
|
}
|
|
66319
66402
|
__name$1(finish, "finish");
|
|
66320
66403
|
function renderErrorPage(detail) {
|
|
66321
|
-
const escape = /* @__PURE__ */ __name$1((s) => s.replace(/[&<>"']/g, (c$1) => ({
|
|
66322
|
-
"&": "&",
|
|
66323
|
-
"<": "<",
|
|
66324
|
-
">": ">",
|
|
66325
|
-
"\"": """,
|
|
66326
|
-
"'": "'"
|
|
66327
|
-
})[c$1]), "escape");
|
|
66328
|
-
const body = `<!doctype html>
|
|
66329
|
-
<html lang="en">
|
|
66330
|
-
<head>
|
|
66331
|
-
<meta charset="utf-8" />
|
|
66332
|
-
<title>Wrangler login failed</title>
|
|
66333
|
-
<style>
|
|
66334
|
-
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; }
|
|
66335
|
-
h1 { color: #c12d3f; }
|
|
66336
|
-
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
66337
|
-
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
66338
|
-
</style>
|
|
66339
|
-
</head>
|
|
66340
|
-
<body>
|
|
66341
|
-
<h1>Wrangler login failed</h1>
|
|
66342
|
-
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
66343
|
-
${detail.code ? `<p>Code: <code>${escape(detail.code)}</code></p>` : ""}
|
|
66344
|
-
${detail.description ? `<p class="detail">${escape(detail.description)}</p>` : ""}
|
|
66345
|
-
<p>You can close this tab and return to your terminal for more details.</p>
|
|
66346
|
-
</body>
|
|
66347
|
-
</html>`;
|
|
66348
66404
|
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
66349
|
-
res.end(
|
|
66405
|
+
res.end(renderOauthErrorPage(ctx.cliDisplayName, detail));
|
|
66350
66406
|
}
|
|
66351
66407
|
__name$1(renderErrorPage, "renderErrorPage");
|
|
66352
66408
|
assert(req.url, "This request doesn't have a URL");
|
|
@@ -66380,7 +66436,7 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
66380
66436
|
return;
|
|
66381
66437
|
}
|
|
66382
66438
|
try {
|
|
66383
|
-
const exchange = await exchangeAuthCodeForAccessToken(state, ctx.logger, ctx.isNonInteractiveOrCI, options.clientId, options.redirectUri);
|
|
66439
|
+
const exchange = await exchangeAuthCodeForAccessToken(state, ctx.logger, ctx.isNonInteractiveOrCI, options.clientId, options.redirectUri, ctx.cliDisplayName);
|
|
66384
66440
|
res.writeHead(307, { Location: options.granted.url });
|
|
66385
66441
|
res.end(() => {
|
|
66386
66442
|
finish(exchange);
|
|
@@ -66473,24 +66529,25 @@ async function readJson(response, logger$2) {
|
|
|
66473
66529
|
}
|
|
66474
66530
|
}
|
|
66475
66531
|
__name$1(readJson, "readJson");
|
|
66476
|
-
async function buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2) {
|
|
66532
|
+
async function buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
66477
66533
|
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
|
66478
66534
|
if (await domainUsesAccess(getAuthDomainFromEnv(), logger$2)) {
|
|
66479
66535
|
logger$2.debug("Using Cloudflare Access to get an access token for the device authorization request");
|
|
66480
66536
|
Object.assign(headers, await getCloudflareAccessHeaders({
|
|
66481
66537
|
logger: logger$2,
|
|
66482
|
-
isNonInteractiveOrCI: isNonInteractiveOrCI2
|
|
66538
|
+
isNonInteractiveOrCI: isNonInteractiveOrCI2,
|
|
66539
|
+
cliDisplayName
|
|
66483
66540
|
}));
|
|
66484
66541
|
}
|
|
66485
66542
|
return headers;
|
|
66486
66543
|
}
|
|
66487
66544
|
__name$1(buildDeviceAuthHeaders, "buildDeviceAuthHeaders");
|
|
66488
|
-
async function requestDeviceAuthorization(scopes, clientId, logger$2, isNonInteractiveOrCI2) {
|
|
66545
|
+
async function requestDeviceAuthorization(scopes, clientId, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
66489
66546
|
const params = new URLSearchParams({
|
|
66490
66547
|
client_id: clientId,
|
|
66491
66548
|
scope: [...scopes, "offline_access"].join(" ")
|
|
66492
66549
|
});
|
|
66493
|
-
const headers = await buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2);
|
|
66550
|
+
const headers = await buildDeviceAuthHeaders(logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
66494
66551
|
const deviceAuthUrl = getDeviceAuthUrl();
|
|
66495
66552
|
logger$2.debug("Fetching device authorization from", deviceAuthUrl);
|
|
66496
66553
|
const response = await (0, import_undici$2.fetch)(deviceAuthUrl, {
|
|
@@ -66512,12 +66569,12 @@ Enable debug logging to see the full response.`, { telemetryMessage: "user devic
|
|
|
66512
66569
|
return deviceAuth;
|
|
66513
66570
|
}
|
|
66514
66571
|
__name$1(requestDeviceAuthorization, "requestDeviceAuthorization");
|
|
66515
|
-
async function pollDeviceToken(deviceCode, clientId, logger$2, isNonInteractiveOrCI2) {
|
|
66572
|
+
async function pollDeviceToken(deviceCode, clientId, logger$2, isNonInteractiveOrCI2, cliDisplayName) {
|
|
66516
66573
|
const response = await fetchAuthToken(new URLSearchParams({
|
|
66517
66574
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
66518
66575
|
device_code: deviceCode,
|
|
66519
66576
|
client_id: clientId
|
|
66520
|
-
}), logger$2, isNonInteractiveOrCI2);
|
|
66577
|
+
}), logger$2, isNonInteractiveOrCI2, cliDisplayName);
|
|
66521
66578
|
const body = await readJson(response, logger$2);
|
|
66522
66579
|
const error$3 = getStringMember(body, "error");
|
|
66523
66580
|
if (error$3 !== void 0) return {
|
|
@@ -66551,7 +66608,7 @@ function sleep(seconds) {
|
|
|
66551
66608
|
__name$1(sleep, "sleep");
|
|
66552
66609
|
async function getOauthTokenViaDeviceFlow(options, ctx) {
|
|
66553
66610
|
const { logger: logger$2, openInBrowser: openInBrowser$1, isNonInteractiveOrCI: isNonInteractiveOrCI2 } = ctx;
|
|
66554
|
-
const deviceAuth = await requestDeviceAuthorization(options.scopes, options.clientId, logger$2, isNonInteractiveOrCI2);
|
|
66611
|
+
const deviceAuth = await requestDeviceAuthorization(options.scopes, options.clientId, logger$2, isNonInteractiveOrCI2, ctx.cliDisplayName);
|
|
66555
66612
|
const authDomain = getAuthDomainFromEnv();
|
|
66556
66613
|
assertTrustedVerificationUrl(deviceAuth.verification_uri, {
|
|
66557
66614
|
field: "verification_uri",
|
|
@@ -66567,7 +66624,7 @@ async function getOauthTokenViaDeviceFlow(options, ctx) {
|
|
|
66567
66624
|
});
|
|
66568
66625
|
const maxDurationSeconds = Math.min(deviceAuth.expires_in, DEVICE_FLOW_MAX_DURATION_SECONDS);
|
|
66569
66626
|
logger$2.log(esm_default`
|
|
66570
|
-
To authorize ${ctx.
|
|
66627
|
+
To authorize ${ctx.cliDisplayName}, please visit:
|
|
66571
66628
|
|
|
66572
66629
|
${deviceAuth.verification_uri}
|
|
66573
66630
|
|
|
@@ -66591,7 +66648,7 @@ Opening a link in your default browser: ${verificationUrl}`);
|
|
|
66591
66648
|
firstPoll = false;
|
|
66592
66649
|
let result;
|
|
66593
66650
|
try {
|
|
66594
|
-
result = await pollDeviceToken(deviceAuth.device_code, options.clientId, logger$2, isNonInteractiveOrCI2);
|
|
66651
|
+
result = await pollDeviceToken(deviceAuth.device_code, options.clientId, logger$2, isNonInteractiveOrCI2, ctx.cliDisplayName);
|
|
66595
66652
|
} catch (e) {
|
|
66596
66653
|
logger$2.debug("Ignoring transient error while polling for token:", e);
|
|
66597
66654
|
lastPollFailure = e instanceof Error ? e.message : String(e);
|
|
@@ -66610,7 +66667,7 @@ Enable debug logging to see the full response.`, { telemetryMessage: "user devic
|
|
|
66610
66667
|
case "slow_down":
|
|
66611
66668
|
intervalSeconds += 5;
|
|
66612
66669
|
continue;
|
|
66613
|
-
case "access_denied": throw new UserError(`Consent denied. You must grant consent to ${ctx.
|
|
66670
|
+
case "access_denied": throw new UserError(`Consent denied. You must grant consent to ${ctx.cliDisplayName} in order to login.
|
|
66614
66671
|
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" });
|
|
66615
66672
|
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" });
|
|
66616
66673
|
default: throw toErrorClass(result.error);
|
|
@@ -66717,7 +66774,7 @@ function createOAuthFlow(ctx) {
|
|
|
66717
66774
|
const { token: { value: oauth_token, expiry: expiration_time } = {
|
|
66718
66775
|
value: "",
|
|
66719
66776
|
expiry: ""
|
|
66720
|
-
}, refreshToken: { value: refresh_token } = {}, scopes } = await exchangeRefreshTokenForAccessToken(ctx.logger, ctx.isNonInteractiveOrCI, getClientId(), storage);
|
|
66777
|
+
}, refreshToken: { value: refresh_token } = {}, scopes } = await exchangeRefreshTokenForAccessToken(ctx.logger, ctx.isNonInteractiveOrCI, getClientId(), storage, ctx.cliDisplayName);
|
|
66721
66778
|
storage.write({
|
|
66722
66779
|
oauth_token,
|
|
66723
66780
|
expiration_time,
|
|
@@ -66727,7 +66784,7 @@ function createOAuthFlow(ctx) {
|
|
|
66727
66784
|
return "refreshed";
|
|
66728
66785
|
} catch (e) {
|
|
66729
66786
|
ctx.logger.debug(`Token refresh failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
66730
|
-
return e instanceof ErrorAuthServerUnreachable ? "unreachable" : "rejected";
|
|
66787
|
+
return e instanceof ErrorAuthServerUnreachable || e instanceof Error && e.name === "TimeoutError" ? "unreachable" : "rejected";
|
|
66731
66788
|
}
|
|
66732
66789
|
}
|
|
66733
66790
|
__name$1(refreshToken, "refreshToken");
|
|
@@ -66839,7 +66896,7 @@ function createOAuthFlow(ctx) {
|
|
|
66839
66896
|
}
|
|
66840
66897
|
__name$1(getActiveTemporaryAccount, "getActiveTemporaryAccount");
|
|
66841
66898
|
async function activateTemporaryAccount() {
|
|
66842
|
-
if (!ctx.temporary) throw new UserError(
|
|
66899
|
+
if (!ctx.temporary) throw new UserError(`Temporary preview accounts are not supported by ${ctx.cliDisplayName}.`, { telemetryMessage: "user temporary account unsupported" });
|
|
66843
66900
|
const result = await getOrCreateTemporaryPreviewAccount({
|
|
66844
66901
|
...ctx.temporary,
|
|
66845
66902
|
...temporaryRequest ? { request: temporaryRequest } : {}
|
|
@@ -67879,7 +67936,7 @@ function scrubEncryptedCredentials(options) {
|
|
|
67879
67936
|
__name$1(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
67880
67937
|
|
|
67881
67938
|
//#endregion
|
|
67882
|
-
//#region ../workers-auth/dist/chunk-
|
|
67939
|
+
//#region ../workers-auth/dist/chunk-6KNWUFJ7.mjs
|
|
67883
67940
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
67884
67941
|
function createPreferences(getConfigPath) {
|
|
67885
67942
|
function getUserPreferencesPath() {
|
|
@@ -68624,13 +68681,15 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
68624
68681
|
purgeOnLoginOrLogout: configCache.purgeConfigCaches,
|
|
68625
68682
|
clientId: descriptor.clientId,
|
|
68626
68683
|
consent: descriptor.consent,
|
|
68627
|
-
|
|
68684
|
+
cliDisplayName: descriptor.displayName,
|
|
68628
68685
|
deviceLoginCommand: descriptor.commands.deviceLogin,
|
|
68629
68686
|
redirectUri: descriptor.redirectUri,
|
|
68630
68687
|
storageFactory: credentialStorage.storageFactory,
|
|
68631
68688
|
allowGlobalAuthKey,
|
|
68632
68689
|
temporary: {
|
|
68633
68690
|
storage: createFileStorage(descriptor.fileFormat, descriptor.getTemporaryAccountConfigPath),
|
|
68691
|
+
cliDisplayName: descriptor.displayName,
|
|
68692
|
+
logoutCommand: descriptor.commands.logout,
|
|
68634
68693
|
prompt: createTemporaryTermsPrompt({
|
|
68635
68694
|
temporaryAccountLogger,
|
|
68636
68695
|
prompt: ctx.prompt
|
|
@@ -69081,6 +69140,7 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
69081
69140
|
"email_sending:read",
|
|
69082
69141
|
"email_sending:write",
|
|
69083
69142
|
"firstpartytags:write",
|
|
69143
|
+
"hyperdrive-planetscale:setup",
|
|
69084
69144
|
"images:read",
|
|
69085
69145
|
"images:write",
|
|
69086
69146
|
"lb:edit",
|
|
@@ -69522,16 +69582,19 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
69522
69582
|
"zone.read",
|
|
69523
69583
|
"zone.write"
|
|
69524
69584
|
];
|
|
69525
|
-
var
|
|
69585
|
+
var CF_REGISTERED_BUT_UNGRANTABLE_SCOPES = [
|
|
69526
69586
|
"billing:read",
|
|
69527
69587
|
"billing:write",
|
|
69528
69588
|
"email_routing:read",
|
|
69529
69589
|
"email_sending:read",
|
|
69530
69590
|
"notebook-managed:read",
|
|
69531
69591
|
"oauth_account_ssl_and_certificates_write"
|
|
69532
|
-
]
|
|
69592
|
+
];
|
|
69593
|
+
var CF_EXPLICIT_ONLY_SCOPES = ["hyperdrive-planetscale:setup"];
|
|
69594
|
+
var CF_UNGRANTABLE_SCOPE_SET = new Set(CF_REGISTERED_BUT_UNGRANTABLE_SCOPES);
|
|
69533
69595
|
var CF_REQUESTABLE_SCOPES = CF_CLIENT_REGISTERED_SCOPES.filter((scope) => !CF_UNGRANTABLE_SCOPE_SET.has(scope));
|
|
69534
|
-
var
|
|
69596
|
+
var CF_EXPLICIT_ONLY_SCOPE_SET = new Set(CF_EXPLICIT_ONLY_SCOPES);
|
|
69597
|
+
var DefaultScopeKeys$1 = CF_REQUESTABLE_SCOPES.filter((scope) => !CF_EXPLICIT_ONLY_SCOPE_SET.has(scope));
|
|
69535
69598
|
function setLoginScopeKeys$1(scopes) {
|
|
69536
69599
|
DefaultScopeKeys$1 = scopes;
|
|
69537
69600
|
}
|
|
@@ -69563,6 +69626,7 @@ var CF_CLI = {
|
|
|
69563
69626
|
displayName: CF_DISPLAY_NAME,
|
|
69564
69627
|
commands: {
|
|
69565
69628
|
login: "cf auth login",
|
|
69629
|
+
logout: "cf auth logout",
|
|
69566
69630
|
whoami: "cf auth whoami",
|
|
69567
69631
|
createProfile: "cf auth create",
|
|
69568
69632
|
deviceLogin: "cf auth login"
|
|
@@ -70201,10 +70265,7 @@ const isRolldown = "rolldownVersion" in vite;
|
|
|
70201
70265
|
*/
|
|
70202
70266
|
function getForwardedProto(req) {
|
|
70203
70267
|
const raw = req.headers["x-forwarded-proto"];
|
|
70204
|
-
|
|
70205
|
-
if (!value) return;
|
|
70206
|
-
const first = value.split(",")[0]?.trim().toLowerCase();
|
|
70207
|
-
if (first === "http" || first === "https") return `${first}:`;
|
|
70268
|
+
return parseForwardedProto(Array.isArray(raw) ? raw[0] : raw);
|
|
70208
70269
|
}
|
|
70209
70270
|
/**
|
|
70210
70271
|
* Extracts the authority (host and port) from an incoming Node.js request.
|
|
@@ -75629,7 +75690,9 @@ var fetchResult$1 = /* @__PURE__ */ __name$2(() => {
|
|
|
75629
75690
|
var fetchPagedListResult = /* @__PURE__ */ __name$2(() => {
|
|
75630
75691
|
throw new Error("initContainersSharedContext() must be called first");
|
|
75631
75692
|
}, "fetchPagedListResult");
|
|
75693
|
+
var cliPresentation = resolveCliPresentation();
|
|
75632
75694
|
function initContainersSharedContext(ctx) {
|
|
75695
|
+
cliPresentation = resolveCliPresentation(ctx.cliPresentation);
|
|
75633
75696
|
logger$1 = ctx.logger;
|
|
75634
75697
|
fetchResult$1 = ctx.fetchResult;
|
|
75635
75698
|
if (ctx.fetchPagedListResult !== void 0) fetchPagedListResult = ctx.fetchPagedListResult;
|
|
@@ -75724,7 +75787,10 @@ var runDockerCmd = /* @__PURE__ */ __name$2((dockerPath, args, stdio) => {
|
|
|
75724
75787
|
}, "runDockerCmd");
|
|
75725
75788
|
var runDockerCmdWithOutput = /* @__PURE__ */ __name$2((dockerPath, args) => {
|
|
75726
75789
|
try {
|
|
75727
|
-
return execFileSync(dockerPath, args, {
|
|
75790
|
+
return execFileSync(dockerPath, args, {
|
|
75791
|
+
encoding: "utf8",
|
|
75792
|
+
stdio: "pipe"
|
|
75793
|
+
}).trim();
|
|
75728
75794
|
} catch (error$3) {
|
|
75729
75795
|
throw new UserError(`Failed running docker command: ${error$3.message}. Command: ${dockerPath} ${args.join(" ")}`, { telemetryMessage: false });
|
|
75730
75796
|
}
|
|
@@ -75890,7 +75956,9 @@ async function pullImage(dockerPath, options, logger2, complianceConfig) {
|
|
|
75890
75956
|
await dockerLoginImageRegistry(dockerPath, domain$1);
|
|
75891
75957
|
} catch (e) {
|
|
75892
75958
|
if (!isExternalRegistry) throw e;
|
|
75893
|
-
logger2?.warn(
|
|
75959
|
+
logger2?.warn(`Unable to retrieve configured registry credentials from Cloudflare.
|
|
75960
|
+
Unless this is a public image, you will need to run \`${cliPresentation.commands.containerRegistryConfigure}\` before deploying.
|
|
75961
|
+
Attempting to pull image anyway...`);
|
|
75894
75962
|
}
|
|
75895
75963
|
const pull = runDockerCmd(dockerPath, [
|
|
75896
75964
|
"pull",
|
|
@@ -75922,7 +75990,7 @@ async function prepareContainerImagesForDev(args) {
|
|
|
75922
75990
|
dockerPath,
|
|
75923
75991
|
operation: "running dev",
|
|
75924
75992
|
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
75925
|
-
hint:
|
|
75993
|
+
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.`
|
|
75926
75994
|
});
|
|
75927
75995
|
for (const options of containerOptions) {
|
|
75928
75996
|
if ("dockerfile" in options) {
|
|
@@ -77221,7 +77289,7 @@ __name$2(buildApplicationObservabilityPatch, "buildApplicationObservabilityPatch
|
|
|
77221
77289
|
function assertCanUseApplicationObservabilityTargeting(prevApp, containerConfig) {
|
|
77222
77290
|
if (!hasTopLevelOnlyObservabilityFields(containerConfig.observability)) return;
|
|
77223
77291
|
if (!hasLegacyRolloutObservabilityEnabled(prevApp)) return;
|
|
77224
|
-
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
|
|
77292
|
+
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" });
|
|
77225
77293
|
}
|
|
77226
77294
|
__name$2(assertCanUseApplicationObservabilityTargeting, "assertCanUseApplicationObservabilityTargeting");
|
|
77227
77295
|
function hasRolloutDiff(prevApp, nextApp) {
|
|
@@ -77674,7 +77742,7 @@ async function sshCommand(sshArgs) {
|
|
|
77674
77742
|
}
|
|
77675
77743
|
const ws = new import_websocket.default(sshResponse.url, { headers: {
|
|
77676
77744
|
authorization: `Bearer ${sshResponse.token}`,
|
|
77677
|
-
"user-agent":
|
|
77745
|
+
"user-agent": cliPresentation.cliName
|
|
77678
77746
|
} });
|
|
77679
77747
|
ws.binaryType = "arraybuffer";
|
|
77680
77748
|
if (useStdio) {
|
|
@@ -78168,8 +78236,14 @@ const PRERENDER_WORKER_DIRECTORY_NAME = "prerender";
|
|
|
78168
78236
|
|
|
78169
78237
|
//#endregion
|
|
78170
78238
|
//#region src/build-output-env.ts
|
|
78239
|
+
/** Internal caller name set by the `cf-vite` delegate. */
|
|
78240
|
+
const CLI_DISPLAY_NAME_ENV_VAR = "CLOUDFLARE_VITE_CLI_DISPLAY_NAME";
|
|
78171
78241
|
/** Shared build context flag set by Cloudflare tooling for Preview builds. */
|
|
78172
78242
|
const PREVIEW_BUILD_ENV_VAR = "CLOUDFLARE_PREVIEW_BUILD";
|
|
78243
|
+
/** Return the CLI name used in actionable messages. */
|
|
78244
|
+
function getCliDisplayName() {
|
|
78245
|
+
return process.env[CLI_DISPLAY_NAME_ENV_VAR] === "cf" ? "cf" : "Wrangler";
|
|
78246
|
+
}
|
|
78173
78247
|
/** Whether Cloudflare tooling requested Preview Build Output. */
|
|
78174
78248
|
function isPreviewBuild() {
|
|
78175
78249
|
return process.env[PREVIEW_BUILD_ENV_VAR] === "true";
|
|
@@ -84868,6 +84942,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
84868
84942
|
Object.assign(process.env, Object.fromEntries(Object.entries(localEnv.values).filter(([name]) => name.startsWith("CLOUDFLARE_"))));
|
|
84869
84943
|
const types$5 = normalizeTypes(pluginConfig.types);
|
|
84870
84944
|
const shared = {
|
|
84945
|
+
cliDisplayName: getCliDisplayName(),
|
|
84871
84946
|
persistState: pluginConfig.persistState ?? true,
|
|
84872
84947
|
inspectorPort: pluginConfig.inspectorPort,
|
|
84873
84948
|
types: types$5,
|
|
@@ -87603,6 +87678,7 @@ var WRANGLER_CLI = {
|
|
|
87603
87678
|
displayName: WRANGLER_DISPLAY_NAME,
|
|
87604
87679
|
commands: {
|
|
87605
87680
|
login: "wrangler login",
|
|
87681
|
+
logout: "wrangler logout",
|
|
87606
87682
|
whoami: "wrangler whoami",
|
|
87607
87683
|
createProfile: "wrangler auth create",
|
|
87608
87684
|
deviceLogin: "wrangler login --device"
|
|
@@ -88341,7 +88417,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
88341
88417
|
//#endregion
|
|
88342
88418
|
//#region ../remote-bindings/dist/index.mjs
|
|
88343
88419
|
var import_undici = require_undici();
|
|
88344
|
-
var version$1 = "0.0.
|
|
88420
|
+
var version$1 = "0.0.46";
|
|
88345
88421
|
var NoDefaultValueProvided = class extends UserError {
|
|
88346
88422
|
constructor() {
|
|
88347
88423
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|
|
@@ -88636,10 +88712,13 @@ async function getOrRegisterWorkersDevSubdomain(complianceConfig, account, abort
|
|
|
88636
88712
|
* fails for any reason (expected with particular zone settings).
|
|
88637
88713
|
* Rethrows AbortError so callers can handle cancellation.
|
|
88638
88714
|
*/
|
|
88639
|
-
async function tryExpandToken(exchangeUrl, abortSignal) {
|
|
88715
|
+
async function tryExpandToken(exchangeUrl, cliDisplayName, abortSignal) {
|
|
88640
88716
|
try {
|
|
88641
88717
|
const switchedExchangeUrl = new URL$1(exchangeUrl);
|
|
88642
|
-
const headers = { ...await getAccessHeaders(switchedExchangeUrl.hostname, {
|
|
88718
|
+
const headers = { ...await getAccessHeaders(switchedExchangeUrl.hostname, {
|
|
88719
|
+
logger,
|
|
88720
|
+
cliDisplayName
|
|
88721
|
+
}) };
|
|
88643
88722
|
logger.debug("-- START EXCHANGE API REQUEST:");
|
|
88644
88723
|
logger.debug("-- END EXCHANGE API REQUEST");
|
|
88645
88724
|
const exchangeResponse = await (0, import_undici.fetch)(switchedExchangeUrl, {
|
|
@@ -88662,10 +88741,10 @@ async function tryExpandToken(exchangeUrl, abortSignal) {
|
|
|
88662
88741
|
/**
|
|
88663
88742
|
* Generates a preview session token.
|
|
88664
88743
|
*/
|
|
88665
|
-
async function createPreviewSession(complianceConfig, account, abortSignal, name) {
|
|
88744
|
+
async function createPreviewSession(complianceConfig, account, abortSignal, name, cliDisplayName) {
|
|
88666
88745
|
const { accountId } = account;
|
|
88667
88746
|
const { token, exchange_url } = await fetchResult(complianceConfig, account, `/accounts/${accountId}/workers/subdomain/edge-preview`, void 0, withTimeout(abortSignal));
|
|
88668
|
-
const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, withTimeout(abortSignal)) ?? token : token;
|
|
88747
|
+
const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, cliDisplayName, withTimeout(abortSignal)) ?? token : token;
|
|
88669
88748
|
try {
|
|
88670
88749
|
return {
|
|
88671
88750
|
value: previewSessionToken,
|
|
@@ -88848,7 +88927,7 @@ var RemoteRuntimeController = class {
|
|
|
88848
88927
|
}
|
|
88849
88928
|
async #previewSession(props) {
|
|
88850
88929
|
try {
|
|
88851
|
-
return await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name), logger, void 0, void 0, this.#abortController.signal);
|
|
88930
|
+
return await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name, props.cliDisplayName), logger, void 0, void 0, this.#abortController.signal);
|
|
88852
88931
|
} catch (err) {
|
|
88853
88932
|
if (err instanceof Error && err.name == "AbortError") return;
|
|
88854
88933
|
handlePreviewSessionCreationError(err, props.accountId);
|
|
@@ -88905,7 +88984,8 @@ var RemoteRuntimeController = class {
|
|
|
88905
88984
|
complianceConfig: { compliance_region: config$3.complianceRegion },
|
|
88906
88985
|
accountId: auth.accountId,
|
|
88907
88986
|
apiToken: auth.apiToken,
|
|
88908
|
-
name: config$3.name
|
|
88987
|
+
name: config$3.name,
|
|
88988
|
+
cliDisplayName: config$3.cliDisplayName
|
|
88909
88989
|
});
|
|
88910
88990
|
}
|
|
88911
88991
|
async #updatePreviewToken(config$3, bundle, auth, bundleId) {
|
|
@@ -88919,11 +88999,13 @@ var RemoteRuntimeController = class {
|
|
|
88919
88999
|
bindings: config$3.bindings,
|
|
88920
89000
|
compatibilityDate: config$3.compatibilityDate,
|
|
88921
89001
|
compatibilityFlags: config$3.compatibilityFlags,
|
|
89002
|
+
cliDisplayName: config$3.cliDisplayName,
|
|
88922
89003
|
bundleId
|
|
88923
89004
|
});
|
|
88924
89005
|
if (bundleId !== this.#currentBundleId || !token) return false;
|
|
88925
89006
|
const accessHeaders = await getAccessHeaders(token.host, {
|
|
88926
89007
|
logger,
|
|
89008
|
+
cliDisplayName: config$3.cliDisplayName,
|
|
88927
89009
|
previewToken: token.value
|
|
88928
89010
|
});
|
|
88929
89011
|
const proxyData = {
|
|
@@ -89125,6 +89207,7 @@ async function startRemoteProxySession(bindings, options) {
|
|
|
89125
89207
|
const rawBindings = toRawBindings(bindings);
|
|
89126
89208
|
const workerConfig = {
|
|
89127
89209
|
name: options.workerName ?? randomUUID(),
|
|
89210
|
+
cliDisplayName: options.cliDisplayName,
|
|
89128
89211
|
entrypointSource: ProxyServerWorker_default,
|
|
89129
89212
|
compatibilityDate: "2025-04-28",
|
|
89130
89213
|
compatibilityFlags: [],
|
|
@@ -89226,6 +89309,7 @@ async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExist
|
|
|
89226
89309
|
remoteProxySession = await startSession(remoteBindings, {
|
|
89227
89310
|
workerName: workerConfigObject.name,
|
|
89228
89311
|
complianceRegion: workerConfigObject.complianceRegion,
|
|
89312
|
+
cliDisplayName: context.cliDisplayName,
|
|
89229
89313
|
auth: getRemoteBindingsAuthHook(auth, workerConfigObject.account_id, workerConfigObject.profileDir, context.logger),
|
|
89230
89314
|
logger: context.logger
|
|
89231
89315
|
});
|
|
@@ -89233,6 +89317,7 @@ async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExist
|
|
|
89233
89317
|
if (Object.keys(remoteBindings).length > 0) remoteProxySession = await startSession(remoteBindings, {
|
|
89234
89318
|
workerName: workerConfigObject.name,
|
|
89235
89319
|
complianceRegion: workerConfigObject.complianceRegion,
|
|
89320
|
+
cliDisplayName: context.cliDisplayName,
|
|
89236
89321
|
auth: getRemoteBindingsAuthHook(auth, workerConfigObject.account_id, workerConfigObject.profileDir, context.logger),
|
|
89237
89322
|
logger: context.logger
|
|
89238
89323
|
});
|
|
@@ -89742,7 +89827,10 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
89742
89827
|
complianceRegion: toApiComplianceRegion(settings.complianceRegion),
|
|
89743
89828
|
account_id: settings.accountId,
|
|
89744
89829
|
profileDir: resolvedViteConfig.root
|
|
89745
|
-
}, preExistingRemoteProxySession ?? null, void 0, {
|
|
89830
|
+
}, preExistingRemoteProxySession ?? null, void 0, {
|
|
89831
|
+
cliDisplayName: resolvedPluginConfig.cliDisplayName,
|
|
89832
|
+
logger: createRemoteBindingsLogger(viteDevServer.config.logger)
|
|
89833
|
+
});
|
|
89746
89834
|
if (remoteProxySessionData) remoteProxySessionsDataMap.set(worker.config.name, remoteProxySessionData);
|
|
89747
89835
|
const wrappers = [
|
|
89748
89836
|
`import { createWorkerEntrypointWrapper, createDurableObjectWrapper, createWorkflowEntrypointWrapper } from "${RUNNER_PATH}";`,
|
|
@@ -89913,7 +90001,10 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
89913
90001
|
complianceRegion: toApiComplianceRegion(resolvedPluginConfig.settings.complianceRegion),
|
|
89914
90002
|
account_id: resolvedPluginConfig.settings.accountId,
|
|
89915
90003
|
profileDir: resolvedViteConfig.root
|
|
89916
|
-
}, preExistingRemoteProxySessionData ?? null, void 0, {
|
|
90004
|
+
}, preExistingRemoteProxySessionData ?? null, void 0, {
|
|
90005
|
+
cliDisplayName: resolvedPluginConfig.cliDisplayName,
|
|
90006
|
+
logger: createRemoteBindingsLogger(vitePreviewServer.config.logger)
|
|
90007
|
+
});
|
|
89917
90008
|
if (remoteProxySessionData) remoteProxySessionsDataMap.set(workerConfig.name, remoteProxySessionData);
|
|
89918
90009
|
const { manifest: _manifest, assets, exports: exports$1,...config$3 } = workerConfig;
|
|
89919
90010
|
const resolvedLocalBindings = resolvedLocalBindingsByWorkerName.get(workerConfig.name);
|