wrangler 3.28.2 → 3.28.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.28.2",
3
+ "version": "3.28.3",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -96,7 +96,7 @@
96
96
  "source-map": "0.6.1",
97
97
  "xxhash-wasm": "^1.0.1",
98
98
  "@cloudflare/kv-asset-handler": "0.3.1",
99
- "miniflare": "3.20240129.2"
99
+ "miniflare": "3.20240129.3"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@cloudflare/ai": "^1.0.35",
@@ -187,7 +187,7 @@
187
187
  "yargs": "^17.7.2",
188
188
  "yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
189
189
  "@cloudflare/cli": "1.1.1",
190
- "@cloudflare/pages-shared": "^0.11.12",
190
+ "@cloudflare/pages-shared": "^0.11.13",
191
191
  "@cloudflare/workers-tsconfig": "0.0.0"
192
192
  },
193
193
  "optionalDependencies": {
@@ -310,9 +310,9 @@ declare type CacheQueryOptions_3 = {
310
310
  ignoreMethod?: boolean;
311
311
  };
312
312
 
313
- declare type CacheRequest = unknown;
313
+ declare type CacheRequest = any;
314
314
 
315
- declare type CacheResponse = unknown;
315
+ declare type CacheResponse = any;
316
316
 
317
317
  declare const caches_2: CacheStorage_2;
318
318
 
@@ -352,6 +352,7 @@ declare const CacheStorage_2: {
352
352
  * No-op implementation of CacheStorage
353
353
  */
354
354
  declare class CacheStorage_3 {
355
+ constructor();
355
356
  open(cacheName: string): Promise<Cache_3>;
356
357
  get default(): Cache_3;
357
358
  }
@@ -23508,6 +23509,8 @@ declare interface StartDevWorkerOptions {
23508
23509
  hostname?: string;
23509
23510
  port?: number;
23510
23511
  secure?: boolean;
23512
+ httpsKeyPath?: string;
23513
+ httpsCertPath?: string;
23511
23514
  };
23512
23515
  /** Controls what request.url looks like inside the worker. */
23513
23516
  urlOverrides?: {
@@ -23717,6 +23720,8 @@ export declare interface UnstableDevOptions {
23717
23720
  bundle?: boolean;
23718
23721
  inspectorPort?: number;
23719
23722
  localProtocol?: "http" | "https";
23723
+ httpsKeyPath?: string;
23724
+ httpsCertPath?: string;
23720
23725
  assets?: string;
23721
23726
  site?: string;
23722
23727
  siteInclude?: string[];
@@ -119621,7 +119621,7 @@ var import_node_assert2 = __toESM(require("node:assert"));
119621
119621
  var import_undici3 = __toESM(require_undici());
119622
119622
 
119623
119623
  // package.json
119624
- var version = "3.28.2";
119624
+ var version = "3.28.3";
119625
119625
  var package_default = {
119626
119626
  name: "wrangler",
119627
119627
  version,
@@ -127782,7 +127782,32 @@ var path22 = __toESM(require("node:path"));
127782
127782
  var import_miniflare4 = require("miniflare");
127783
127783
  var CERT_EXPIRY_DAYS = 30;
127784
127784
  var ONE_DAY_IN_MS = 864e5;
127785
- function getHttpsOptions() {
127785
+ function getHttpsOptions(customHttpsKeyPath, customHttpsCertPath) {
127786
+ if (customHttpsKeyPath !== void 0 || customHttpsCertPath !== void 0) {
127787
+ if (customHttpsKeyPath === void 0 || customHttpsCertPath === void 0) {
127788
+ throw new UserError(
127789
+ "Must specify both certificate path and key path to use a Custom Certificate."
127790
+ );
127791
+ }
127792
+ if (!fs11.existsSync(customHttpsKeyPath)) {
127793
+ throw new UserError(
127794
+ "Missing Custom Certificate Key at " + customHttpsKeyPath
127795
+ );
127796
+ }
127797
+ if (!fs11.existsSync(customHttpsCertPath)) {
127798
+ throw new UserError(
127799
+ "Missing Custom Certificate File at " + customHttpsCertPath
127800
+ );
127801
+ }
127802
+ if (hasCertificateExpired(customHttpsKeyPath, customHttpsCertPath)) {
127803
+ throw new UserError("Custom Certificate is invalid");
127804
+ }
127805
+ logger.log("Using custom certificate at ", customHttpsKeyPath);
127806
+ return {
127807
+ key: fs11.readFileSync(customHttpsKeyPath, "utf8"),
127808
+ cert: fs11.readFileSync(customHttpsCertPath, "utf8")
127809
+ };
127810
+ }
127786
127811
  const certDirectory = path22.join(getGlobalWranglerConfigPath(), "local-cert");
127787
127812
  const keyPath = path22.join(certDirectory, "key.pem");
127788
127813
  const certPath = path22.join(certDirectory, "cert.pem");
@@ -128286,7 +128311,10 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
128286
128311
  const persistOptions = buildPersistOptions(config.localPersistencePath);
128287
128312
  let httpsOptions;
128288
128313
  if (config.localProtocol === "https") {
128289
- const cert = await getHttpsOptions();
128314
+ const cert = await getHttpsOptions(
128315
+ config.httpsKeyPath,
128316
+ config.httpsCertPath
128317
+ );
128290
128318
  httpsOptions = {
128291
128319
  httpsKey: cert.key,
128292
128320
  httpsCert: cert.cert
@@ -128422,6 +128450,8 @@ async function localPropsToConfigBundle(props) {
128422
128450
  crons: props.crons,
128423
128451
  queueConsumers: props.queueConsumers,
128424
128452
  localProtocol: props.localProtocol,
128453
+ httpsKeyPath: props.httpsKeyPath,
128454
+ httpsCertPath: props.httpsCertPath,
128425
128455
  localUpstream: props.localUpstream,
128426
128456
  upstreamProtocol: props.upstreamProtocol,
128427
128457
  inspect: props.inspect,
@@ -143494,6 +143524,14 @@ __name(collectKeyValues, "collectKeyValues");
143494
143524
 
143495
143525
  // src/deploy/index.ts
143496
143526
  async function standardPricingWarning(accountId, config) {
143527
+ if (Date.now() >= Date.UTC(2024, 2, 1, 14)) {
143528
+ if (config.usage_model !== void 0) {
143529
+ logger.warn(
143530
+ "The `usage_model` defined in wrangler.toml is deprecated and no longer used. Visit our developer docs for details: https://developers.cloudflare.com/workers/wrangler/configuration/#usage-model"
143531
+ );
143532
+ }
143533
+ return;
143534
+ }
143497
143535
  try {
143498
143536
  const { standard, reason } = await fetchResult(`/accounts/${accountId}/workers/standard`);
143499
143537
  if (!standard && reason !== "enterprise without override") {
@@ -149213,6 +149251,16 @@ function Options12(yargs) {
149213
149251
  describe: "Protocol to listen to requests on, defaults to http.",
149214
149252
  choices: ["http", "https"]
149215
149253
  },
149254
+ "https-key-path": {
149255
+ describe: "Path to a custom certificate key",
149256
+ type: "string",
149257
+ requiresArg: true
149258
+ },
149259
+ "https-cert-path": {
149260
+ describe: "Path to a custom certificate",
149261
+ type: "string",
149262
+ requiresArg: true
149263
+ },
149216
149264
  "persist-to": {
149217
149265
  describe: "Specify directory to use for local persistence (defaults to .wrangler/state)",
149218
149266
  type: "string",
@@ -149262,6 +149310,8 @@ var Handler12 = /* @__PURE__ */ __name(async ({
149262
149310
  service: requestedServices = [],
149263
149311
  liveReload,
149264
149312
  localProtocol,
149313
+ httpsKeyPath,
149314
+ httpsCertPath,
149265
149315
  persistTo,
149266
149316
  nodeCompat: legacyNodeCompat,
149267
149317
  experimentalLocal,
@@ -149578,6 +149628,8 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for
149578
149628
  port: port2,
149579
149629
  inspectorPort,
149580
149630
  localProtocol,
149631
+ httpsKeyPath,
149632
+ httpsCertPath,
149581
149633
  compatibilityDate,
149582
149634
  compatibilityFlags,
149583
149635
  nodeCompat: legacyNodeCompat,
@@ -162421,6 +162473,14 @@ __name(noBundleWorker, "noBundleWorker");
162421
162473
 
162422
162474
  // src/versions/index.ts
162423
162475
  async function standardPricingWarning2(accountId, config) {
162476
+ if (Date.now() >= Date.UTC(2024, 2, 1, 14)) {
162477
+ if (config.usage_model !== void 0) {
162478
+ logger.warn(
162479
+ "The `usage_model` defined in wrangler.toml is deprecated and no longer used. Visit our developer docs for details: https://developers.cloudflare.com/workers/wrangler/configuration/#usage-model"
162480
+ );
162481
+ }
162482
+ return;
162483
+ }
162424
162484
  try {
162425
162485
  const { standard, reason } = await fetchResult(`/accounts/${accountId}/workers/standard`);
162426
162486
  if (!standard && reason !== "enterprise without override") {
@@ -163238,10 +163298,12 @@ ${tryRunningItIn}${oneOfThese}`
163238
163298
  logger.error(e3.message);
163239
163299
  } else {
163240
163300
  logger.error(e3 instanceof Error ? e3.message : e3);
163241
- logger.log(
163242
- `${fgGreenColor}%s${resetColor}`,
163243
- "If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
163244
- );
163301
+ if (!(e3 instanceof UserError)) {
163302
+ logger.log(
163303
+ `${fgGreenColor}%s${resetColor}`,
163304
+ "If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
163305
+ );
163306
+ }
163245
163307
  }
163246
163308
  if (
163247
163309
  // Only report the error if we didn't just handle it
@@ -165524,13 +165586,19 @@ async function startPreviewServer({
165524
165586
  previewToken,
165525
165587
  assetDirectory,
165526
165588
  localProtocol,
165589
+ customHttpsKeyPath,
165590
+ customHttpsCertPath,
165527
165591
  localPort: port2,
165528
165592
  ip: ip2,
165529
165593
  onReady
165530
165594
  }) {
165531
165595
  try {
165532
165596
  const abortController = new AbortController();
165533
- const server2 = await createProxyServer(localProtocol);
165597
+ const server2 = await createProxyServer(
165598
+ localProtocol,
165599
+ customHttpsKeyPath,
165600
+ customHttpsCertPath
165601
+ );
165534
165602
  const proxy2 = {
165535
165603
  server: server2,
165536
165604
  terminator: (0, import_http_terminator2.createHttpTerminator)({
@@ -165755,8 +165823,10 @@ var HTTP1_HEADERS = /* @__PURE__ */ new Set([
165755
165823
  "transfer-encoding",
165756
165824
  "http2-settings"
165757
165825
  ]);
165758
- async function createProxyServer(localProtocol) {
165759
- const server2 = localProtocol === "https" ? (0, import_node_https.createServer)(await getHttpsOptions()) : (0, import_node_http3.createServer)();
165826
+ async function createProxyServer(localProtocol, customHttpsKeyPath, customHttpsCertPath) {
165827
+ const server2 = localProtocol === "https" ? (0, import_node_https.createServer)(
165828
+ await getHttpsOptions(customHttpsKeyPath, customHttpsCertPath)
165829
+ ) : (0, import_node_http3.createServer)();
165760
165830
  return server2.on("upgrade", (req) => {
165761
165831
  logger.log(
165762
165832
  (/* @__PURE__ */ new Date()).toLocaleTimeString(),
@@ -166109,6 +166179,8 @@ async function startRemoteServer(props) {
166109
166179
  previewToken,
166110
166180
  assetDirectory: props.isWorkersSite ? void 0 : props.assetPaths?.assetDirectory,
166111
166181
  localProtocol: props.localProtocol,
166182
+ customHttpsKeyPath: props.httpsKeyPath,
166183
+ customHttpsCertPath: props.httpsCertPath,
166112
166184
  localPort: props.port,
166113
166185
  ip: props.ip,
166114
166186
  onReady: async (ip2, port2) => {
@@ -166638,6 +166710,12 @@ function DevImplementation(props) {
166638
166710
  __name(DevImplementation, "DevImplementation");
166639
166711
  var ip;
166640
166712
  var port;
166713
+ var portUsable = false;
166714
+ var portUsablePromiseResolve;
166715
+ var portUsablePromise = new Promise(
166716
+ (resolve19) => portUsablePromiseResolve = resolve19
166717
+ );
166718
+ var blockBrowserOpen = false;
166641
166719
  function InteractiveDevSession(props) {
166642
166720
  const toggles = useHotkeys({
166643
166721
  initial: {
@@ -166654,6 +166732,8 @@ function InteractiveDevSession(props) {
166654
166732
  port = props.initialPort;
166655
166733
  useTunnel(toggles.tunnel);
166656
166734
  const onReady = /* @__PURE__ */ __name((newIp, newPort, proxyData) => {
166735
+ portUsable = true;
166736
+ portUsablePromiseResolve();
166657
166737
  ip = newIp;
166658
166738
  port = newPort;
166659
166739
  props.onReady?.(newIp, newPort, proxyData);
@@ -166676,7 +166756,9 @@ function DevSession(props) {
166676
166756
  server: {
166677
166757
  hostname: props.initialIp,
166678
166758
  port: props.initialPort,
166679
- secure: props.localProtocol === "https"
166759
+ secure: props.localProtocol === "https",
166760
+ httpsKeyPath: props.httpsKeyPath,
166761
+ httpsCertPath: props.httpsCertPath
166680
166762
  },
166681
166763
  inspector: {
166682
166764
  port: props.inspectorPort
@@ -166693,6 +166775,8 @@ function DevSession(props) {
166693
166775
  props.initialIp,
166694
166776
  props.initialPort,
166695
166777
  props.localProtocol,
166778
+ props.httpsKeyPath,
166779
+ props.httpsCertPath,
166696
166780
  props.localUpstream,
166697
166781
  props.inspectorPort,
166698
166782
  props.liveReload
@@ -166831,6 +166915,8 @@ function DevSession(props) {
166831
166915
  crons: props.crons,
166832
166916
  queueConsumers: props.queueConsumers,
166833
166917
  localProtocol: "http",
166918
+ httpsKeyPath: props.httpsKeyPath,
166919
+ httpsCertPath: props.httpsCertPath,
166834
166920
  localUpstream: props.localUpstream,
166835
166921
  upstreamProtocol: props.upstreamProtocol,
166836
166922
  inspect: props.inspect,
@@ -166851,6 +166937,8 @@ function DevSession(props) {
166851
166937
  port: props.initialPort,
166852
166938
  ip: props.initialIp,
166853
166939
  localProtocol: props.localProtocol,
166940
+ httpsKeyPath: props.httpsKeyPath,
166941
+ httpsCertPath: props.httpsCertPath,
166854
166942
  inspectorPort: props.inspectorPort,
166855
166943
  inspect: props.inspect,
166856
166944
  compatibilityDate: props.compatibilityDate,
@@ -166998,6 +167086,15 @@ function useHotkeys(props) {
166998
167086
  console.log();
166999
167087
  break;
167000
167088
  case "b": {
167089
+ if (port === 0) {
167090
+ if (!portUsable)
167091
+ logger.info("Waiting for port...");
167092
+ if (blockBrowserOpen)
167093
+ return;
167094
+ blockBrowserOpen = true;
167095
+ await portUsablePromise;
167096
+ blockBrowserOpen = false;
167097
+ }
167001
167098
  if (ip === "0.0.0.0" || ip === "*") {
167002
167099
  await openInBrowser(`${localProtocol}://127.0.0.1:${port}`);
167003
167100
  return;
@@ -167107,7 +167204,9 @@ async function startDevServer(props) {
167107
167204
  server: {
167108
167205
  hostname: props.initialIp,
167109
167206
  port: props.initialPort,
167110
- secure: props.localProtocol === "https"
167207
+ secure: props.localProtocol === "https",
167208
+ httpsKeyPath: props.httpsKeyPath,
167209
+ httpsCertPath: props.httpsCertPath
167111
167210
  },
167112
167211
  inspector: {
167113
167212
  port: props.inspectorPort
@@ -167184,6 +167283,8 @@ async function startDevServer(props) {
167184
167283
  crons: props.crons,
167185
167284
  queueConsumers: props.queueConsumers,
167186
167285
  localProtocol: props.localProtocol,
167286
+ httpsKeyPath: props.httpsKeyPath,
167287
+ httpsCertPath: props.httpsCertPath,
167187
167288
  localUpstream: props.localUpstream,
167188
167289
  upstreamProtocol: props.upstreamProtocol,
167189
167290
  inspect: true,
@@ -167228,6 +167329,8 @@ async function startDevServer(props) {
167228
167329
  port: props.initialPort,
167229
167330
  ip: props.initialIp,
167230
167331
  localProtocol: props.localProtocol,
167332
+ httpsKeyPath: props.httpsKeyPath,
167333
+ httpsCertPath: props.httpsCertPath,
167231
167334
  inspectorPort: props.inspectorPort,
167232
167335
  inspect: props.inspect,
167233
167336
  compatibilityDate: props.compatibilityDate,
@@ -167481,6 +167584,14 @@ function devOptions(yargs) {
167481
167584
  }).option("local-protocol", {
167482
167585
  describe: "Protocol to listen to requests on, defaults to http.",
167483
167586
  choices: ["http", "https"]
167587
+ }).option("https-key-path", {
167588
+ describe: "Path to a custom certificate key",
167589
+ type: "string",
167590
+ requiresArg: true
167591
+ }).option("https-cert-path", {
167592
+ describe: "Path to a custom certificate",
167593
+ type: "string",
167594
+ requiresArg: true
167484
167595
  }).options("local-upstream", {
167485
167596
  type: "string",
167486
167597
  describe: "Host to act as origin in local mode, defaults to dev.host or route"
@@ -167716,10 +167827,12 @@ async function startDev(args) {
167716
167827
  tsconfig: args.tsconfig ?? configParam.tsconfig,
167717
167828
  upstreamProtocol,
167718
167829
  localProtocol: args.localProtocol || configParam.dev.local_protocol,
167830
+ httpsKeyPath: args.httpsKeyPath,
167831
+ httpsCertPath: args.httpsCertPath,
167719
167832
  localUpstream: args.localUpstream ?? host,
167720
167833
  localPersistencePath,
167721
167834
  liveReload: args.liveReload || false,
167722
- accountId: configParam.account_id || getAccountFromCache()?.id,
167835
+ accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
167723
167836
  assetPaths,
167724
167837
  assetsConfig: configParam.assets,
167725
167838
  initialPort: args.port ?? configParam.dev.port ?? await getLocalPort(),
@@ -167824,10 +167937,12 @@ async function startApiDev(args) {
167824
167937
  tsconfig: args.tsconfig ?? configParam.tsconfig,
167825
167938
  upstreamProtocol,
167826
167939
  localProtocol: args.localProtocol ?? configParam.dev.local_protocol,
167940
+ httpsKeyPath: args.httpsKeyPath,
167941
+ httpsCertPath: args.httpsCertPath,
167827
167942
  localUpstream: args.localUpstream ?? host,
167828
167943
  localPersistencePath,
167829
167944
  liveReload: args.liveReload ?? false,
167830
- accountId: configParam.account_id ?? getAccountFromCache()?.id,
167945
+ accountId: args.accountId ?? configParam.account_id ?? getAccountFromCache()?.id,
167831
167946
  assetPaths,
167832
167947
  assetsConfig: configParam.assets,
167833
167948
  //port can be 0, which means to use a random port
@@ -168135,10 +168250,17 @@ function getBindings(configParam, env5, local, args) {
168135
168250
  vectorize: configParam.vectorize,
168136
168251
  constellation: configParam.constellation,
168137
168252
  hyperdrive: configParam.hyperdrive.map((hyperdrive2) => {
168138
- if (!hyperdrive2.localConnectionString) {
168253
+ const connectionStringFromEnv = process.env[`WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive2.binding}`];
168254
+ if (!connectionStringFromEnv && !hyperdrive2.localConnectionString) {
168139
168255
  throw new UserError(
168140
- `In development, you should use a local postgres connection string to emulate hyperdrive functionality. Please setup postgres locally and set the value of "${hyperdrive2.binding}"'s "localConnectionString" to the postgres connection string in your wrangler.toml`
168256
+ `When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive2.binding}' variable or "${hyperdrive2.binding}"'s "localConnectionString" to the Postgres connection string.`
168257
+ );
168258
+ }
168259
+ if (connectionStringFromEnv) {
168260
+ logger.log(
168261
+ `Found a non-empty WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING variable for binding. Hyperdrive will connect to this database during local development.`
168141
168262
  );
168263
+ hyperdrive2.localConnectionString = connectionStringFromEnv;
168142
168264
  }
168143
168265
  return hyperdrive2;
168144
168266
  })
@@ -168225,6 +168347,8 @@ unstable_dev()'s behaviour will likely change in future releases`
168225
168347
  inspectorPort: options25?.inspectorPort ?? 0,
168226
168348
  v: void 0,
168227
168349
  localProtocol: options25?.localProtocol,
168350
+ httpsKeyPath: options25?.httpsKeyPath,
168351
+ httpsCertPath: options25?.httpsCertPath,
168228
168352
  assets: options25?.assets,
168229
168353
  site: options25?.site,
168230
168354
  // Root folder of static assets for Workers Sites
@@ -168528,7 +168652,10 @@ var ProxyController = class extends import_node_events3.EventEmitter {
168528
168652
  if (this._torndown)
168529
168653
  return;
168530
168654
  (0, import_node_assert20.default)(this.latestConfig !== void 0);
168531
- const cert = this.latestConfig.dev?.server?.secure || this.latestConfig.dev?.inspector?.secure ? getHttpsOptions() : void 0;
168655
+ const cert = this.latestConfig.dev?.server?.secure || this.latestConfig.dev?.inspector?.secure ? getHttpsOptions(
168656
+ this.latestConfig.dev.server?.httpsKeyPath,
168657
+ this.latestConfig.dev.server?.httpsCertPath
168658
+ ) : void 0;
168532
168659
  const proxyWorkerOptions = {
168533
168660
  host: this.latestConfig.dev?.server?.hostname,
168534
168661
  port: this.latestConfig.dev?.server?.port,
@@ -169075,6 +169202,23 @@ var import_miniflare18 = require("miniflare");
169075
169202
  // src/api/integrations/platform/caches.ts
169076
169203
  init_import_meta_url();
169077
169204
  var CacheStorage = class {
169205
+ constructor() {
169206
+ const unsupportedMethods = ["has", "delete", "keys", "match"];
169207
+ unsupportedMethods.forEach((method) => {
169208
+ Object.defineProperty(this, method, {
169209
+ enumerable: false,
169210
+ value: () => {
169211
+ throw new Error(
169212
+ `Failed to execute '${method}' on 'CacheStorage': the method is not implemented.`
169213
+ );
169214
+ }
169215
+ });
169216
+ });
169217
+ Object.defineProperty(this, "default", {
169218
+ enumerable: true,
169219
+ value: this.default
169220
+ });
169221
+ }
169078
169222
  async open(cacheName) {
169079
169223
  return new Cache2();
169080
169224
  }