@shopify/cli 3.63.1 → 3.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.
Files changed (130) hide show
  1. package/dist/assets/cli-ruby/lib/shopify_cli/reporting_configuration_controller.rb +2 -37
  2. package/dist/assets/cli-ruby/lib/shopify_cli/theme/file.rb +12 -30
  3. package/dist/assets/dev-console/extensions/dev-console/assets/index-Cgb-oKsM.css +1 -0
  4. package/dist/assets/dev-console/extensions/dev-console/assets/{index-Dui3DO9f.js → index-D7F9wNys.js} +12 -12
  5. package/dist/assets/dev-console/index.html +2 -2
  6. package/dist/assets/hydrogen/starter/CHANGELOG.md +98 -5
  7. package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +37 -0
  8. package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +150 -0
  9. package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +68 -0
  10. package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +101 -0
  11. package/dist/assets/hydrogen/starter/app/components/Header.tsx +3 -3
  12. package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +1 -1
  13. package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +80 -0
  14. package/dist/assets/hydrogen/starter/app/components/ProductImage.tsx +23 -0
  15. package/dist/assets/hydrogen/starter/app/components/ProductPrice.tsx +27 -0
  16. package/dist/assets/hydrogen/starter/app/components/Search.tsx +1 -0
  17. package/dist/assets/hydrogen/starter/app/root.tsx +11 -17
  18. package/dist/assets/hydrogen/starter/app/routes/cart.tsx +2 -2
  19. package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +51 -232
  20. package/dist/assets/hydrogen/starter/package.json +11 -11
  21. package/dist/assets/hydrogen/tailwind/package.json +1 -6
  22. package/dist/assets/hydrogen/tailwind/tailwind.css +6 -3
  23. package/dist/assets/hydrogen/vanilla-extract/package.json +2 -3
  24. package/dist/assets/hydrogen/virtual-routes/components/{Layout.jsx → PageLayout.jsx} +2 -2
  25. package/dist/assets/hydrogen/virtual-routes/virtual-root.jsx +8 -30
  26. package/dist/{chunk-TD4ZV7BS.js → chunk-2TZRSXDZ.js} +3 -3
  27. package/dist/{chunk-EARPFFS7.js → chunk-5A6QTLMF.js} +241 -4
  28. package/dist/{chunk-SRLLZENE.js → chunk-6LPAIJ4Y.js} +2 -2
  29. package/dist/{chunk-TYOQQCHN.js → chunk-6TPBPH6V.js} +905 -896
  30. package/dist/{chunk-UZ3EKGD4.js → chunk-7GYETEC3.js} +3 -3
  31. package/dist/{chunk-UNPXLODI.js → chunk-B7RN7IRD.js} +3 -4
  32. package/dist/{chunk-SML7F4EL.js → chunk-BKBHZTOE.js} +3 -3
  33. package/dist/{chunk-A2UVOX6O.js → chunk-C2AKAEMR.js} +7066 -6051
  34. package/dist/{chunk-HZUY7I72.js → chunk-CLBFKLWA.js} +4 -4
  35. package/dist/{chunk-6UDFXWNE.js → chunk-EJITPGUJ.js} +21 -4
  36. package/dist/{chunk-SCKZAIMH.js → chunk-G4TC4KHZ.js} +3 -3
  37. package/dist/{chunk-ZSWSHFDT.js → chunk-GEAZ65AU.js} +1429 -2847
  38. package/dist/{chunk-HCYSYR53.js → chunk-GUB3OCYR.js} +4 -4
  39. package/dist/{chunk-QCB66M7L.js → chunk-H66NIXGL.js} +9 -14
  40. package/dist/chunk-I6HNYSMO.js +29 -0
  41. package/dist/{chunk-GICOHCP4.js → chunk-JSLLI5MY.js} +3 -3
  42. package/dist/{chunk-N5XLVLT2.js → chunk-KDK32T2A.js} +5 -5
  43. package/dist/{chunk-CBNQDBKA.js → chunk-L5WUZYLP.js} +5 -5
  44. package/dist/{chunk-OVW3UN2A.js → chunk-LHP5F5LY.js} +4 -4
  45. package/dist/{chunk-TOO3W2BY.js → chunk-LP2H26NY.js} +3 -3
  46. package/dist/{chunk-NIEJLNRY.js → chunk-LQX3GDBO.js} +2 -2
  47. package/dist/{chunk-WJ6UGHRU.js → chunk-LVLKZYIC.js} +3 -3
  48. package/dist/{chunk-WADS2TV5.js → chunk-NO7MYZEO.js} +5 -4
  49. package/dist/{chunk-LH533WG4.js → chunk-NPH2SXRO.js} +2 -2
  50. package/dist/{chunk-IJ3PP7ZN.js → chunk-PIJQNKK6.js} +5 -5
  51. package/dist/{chunk-S4VBXFXP.js → chunk-PWYMBX34.js} +220 -16
  52. package/dist/{chunk-DIRL62CL.js → chunk-QCK4QLB3.js} +17912 -17444
  53. package/dist/{chunk-5D3LUZSS.js → chunk-QI5O2CU6.js} +5 -5
  54. package/dist/{chunk-BZUV56IY.js → chunk-RX7VCI62.js} +4 -4
  55. package/dist/{chunk-HULX6T4O.js → chunk-T7DHXEC7.js} +3 -3
  56. package/dist/{chunk-VB3O7QTH.js → chunk-TCQUNDAY.js} +3 -3
  57. package/dist/{chunk-CM4H6QMH.js → chunk-TSZPIP7J.js} +3 -3
  58. package/dist/{chunk-OHZL7KKD.js → chunk-UTXBNNRZ.js} +4 -4
  59. package/dist/{chunk-QAB3YP77.js → chunk-VPPZXHAK.js} +2 -2
  60. package/dist/{chunk-ARLG6JTK.js → chunk-W26344X5.js} +3 -3
  61. package/dist/{chunk-EQPYUHNM.js → chunk-WIG6CPGR.js} +1497 -112
  62. package/dist/{chunk-MMRWTLF3.js → chunk-X34BQYQP.js} +2 -2
  63. package/dist/chunk-YLPSXWEZ.js +12 -0
  64. package/dist/cli/commands/auth/logout.js +14 -19
  65. package/dist/cli/commands/auth/logout.test.js +17 -21
  66. package/dist/cli/commands/debug/command-flags.js +11 -15
  67. package/dist/cli/commands/demo/catalog.js +13 -18
  68. package/dist/cli/commands/demo/generate-file.js +13 -18
  69. package/dist/cli/commands/demo/index.js +13 -18
  70. package/dist/cli/commands/demo/print-ai-prompt.js +13 -18
  71. package/dist/cli/commands/docs/generate.js +11 -15
  72. package/dist/cli/commands/docs/generate.test.js +11 -15
  73. package/dist/cli/commands/help.js +11 -15
  74. package/dist/cli/commands/kitchen-sink/async.js +12 -16
  75. package/dist/cli/commands/kitchen-sink/async.test.js +12 -16
  76. package/dist/cli/commands/kitchen-sink/index.js +14 -18
  77. package/dist/cli/commands/kitchen-sink/index.test.js +14 -18
  78. package/dist/cli/commands/kitchen-sink/prompts.js +12 -16
  79. package/dist/cli/commands/kitchen-sink/prompts.test.js +12 -16
  80. package/dist/cli/commands/kitchen-sink/static.js +12 -16
  81. package/dist/cli/commands/kitchen-sink/static.test.js +12 -16
  82. package/dist/cli/commands/search.js +12 -16
  83. package/dist/cli/commands/upgrade.js +11 -15
  84. package/dist/cli/commands/version.js +12 -16
  85. package/dist/cli/commands/version.test.js +12 -16
  86. package/dist/cli/services/commands/search.js +4 -4
  87. package/dist/cli/services/commands/search.test.js +4 -4
  88. package/dist/cli/services/commands/version.js +6 -7
  89. package/dist/cli/services/commands/version.test.js +7 -8
  90. package/dist/cli/services/demo.js +5 -6
  91. package/dist/cli/services/demo.test.js +5 -6
  92. package/dist/cli/services/kitchen-sink/async.js +4 -4
  93. package/dist/cli/services/kitchen-sink/prompts.js +4 -4
  94. package/dist/cli/services/kitchen-sink/static.js +4 -4
  95. package/dist/cli/services/upgrade.js +5 -6
  96. package/dist/cli/services/upgrade.test.js +7 -8
  97. package/dist/{constants-3CLHB4LQ.js → constants-EVER32LA.js} +3 -3
  98. package/dist/{custom-oclif-loader-T44V63XJ.js → custom-oclif-loader-F5UKFNJS.js} +13 -6
  99. package/dist/{error-handler-5KEL3EJC.js → error-handler-GCSQB44R.js} +10 -8
  100. package/dist/hooks/postrun.js +12 -14
  101. package/dist/hooks/prerun.js +8 -11
  102. package/dist/index.js +7708 -7452
  103. package/dist/{local-LBAOYPL4.js → local-VDSO2Y52.js} +4 -4
  104. package/dist/{morph-6NYGHGNT.js → morph-DQWX4LPS.js} +9 -9
  105. package/dist/{node-3X5EZ2GL.js → node-3B62KLPY.js} +21 -19
  106. package/dist/{node-package-manager-BU3KHLYT.js → node-package-manager-QLAS6UPG.js} +5 -6
  107. package/dist/{path-JVVXOELJ.js → path-KUSF6CYC.js} +2 -2
  108. package/dist/{system-GPQDWNIQ.js → system-CPU6ZDBW.js} +4 -4
  109. package/dist/templates/ui-extensions/projects/web_pixel_extension/package.json.liquid +1 -1
  110. package/dist/tsconfig.tsbuildinfo +1 -1
  111. package/dist/{ui-4ZQNF2YQ.js → ui-Y4GW3DUK.js} +4 -4
  112. package/dist/{workerd-66AMV47V.js → workerd-LSXMDY5M.js} +22 -19
  113. package/oclif.manifest.json +265 -4
  114. package/package.json +7 -10
  115. package/dist/assets/dev-console/extensions/dev-console/assets/index-Bi7y6lI5.css +0 -1
  116. package/dist/assets/hydrogen/css-modules/package.json +0 -6
  117. package/dist/assets/hydrogen/postcss/package.json +0 -10
  118. package/dist/assets/hydrogen/postcss/postcss.config.js +0 -8
  119. package/dist/assets/hydrogen/starter/app/components/Cart.tsx +0 -364
  120. package/dist/assets/hydrogen/tailwind/postcss.config.js +0 -10
  121. package/dist/assets/hydrogen/tailwind/tailwind.config.js +0 -8
  122. package/dist/chunk-6EIVOQYP.js +0 -1070
  123. package/dist/chunk-GITQBCE5.js +0 -4385
  124. package/dist/chunk-HNAZOLMG.js +0 -1453
  125. package/dist/chunk-MO3UHUJB.js +0 -221
  126. package/dist/chunk-NBSFQYKI.js +0 -496
  127. package/dist/chunk-NVFSN34M.js +0 -265
  128. package/dist/chunk-QOUOFEGO.js +0 -35
  129. package/dist/chunk-WLZZJLBE.js +0 -12
  130. package/dist/error-handler-QVRMTAG7.js +0 -43
@@ -1,6 +1,75 @@
1
+ import {
2
+ setNextDeprecationDate
3
+ } from "./chunk-NPH2SXRO.js";
4
+ import {
5
+ z
6
+ } from "./chunk-EJITPGUJ.js";
7
+ import {
8
+ ClientError,
9
+ GraphQLClient,
10
+ GraphQLClientError,
11
+ RequestClientError,
12
+ allAPIs,
13
+ buildHeaders,
14
+ debugLogResponseInfo,
15
+ getIdentityTokenInformation,
16
+ getPartnersToken,
17
+ gql,
18
+ httpsAgent,
19
+ resolveRequestDocument,
20
+ sanitizedHeadersOutput,
21
+ shopifyFetch
22
+ } from "./chunk-C2AKAEMR.js";
23
+ import {
24
+ base64URLEncode,
25
+ randomBytes,
26
+ randomHex,
27
+ sha256
28
+ } from "./chunk-H66NIXGL.js";
29
+ import {
30
+ cacheRetrieveOrRepopulate,
31
+ getSession,
32
+ removeSession,
33
+ setSession
34
+ } from "./chunk-QCK4QLB3.js";
35
+ import {
36
+ AbortError,
37
+ BugError,
38
+ CancelExecution,
39
+ Environment,
40
+ FatalError,
41
+ findPathUp,
42
+ firstPartyDev,
43
+ import_ts_error,
44
+ isSpin,
45
+ isSpinEnvironment,
46
+ isTruthy,
47
+ keypress,
48
+ openURL,
49
+ outputCompleted,
50
+ outputContent,
51
+ outputDebug,
52
+ outputInfo,
53
+ outputToken,
54
+ outputWarn,
55
+ readFile,
56
+ renderConfirmationPrompt,
57
+ runWithTimer,
58
+ serviceEnvironment,
59
+ spinFqdn,
60
+ stringifyMessage,
61
+ useDeviceAuth
62
+ } from "./chunk-6TPBPH6V.js";
63
+ import {
64
+ sessionConstants
65
+ } from "./chunk-NO7MYZEO.js";
66
+ import {
67
+ moduleDirectory
68
+ } from "./chunk-B7RN7IRD.js";
1
69
  import {
2
70
  __commonJS,
3
71
  __require,
72
+ __toESM,
4
73
  init_cjs_shims
5
74
  } from "./chunk-ZPL24Y2D.js";
6
75
 
@@ -163,21 +232,21 @@ var require_find_pid = __commonJS({
163
232
  if (fs.existsSync(path)) {
164
233
  resolve();
165
234
  } else {
166
- fs.mkdir(path, (err) => {
167
- err ? reject(err) : resolve();
235
+ fs.mkdir(path, (err2) => {
236
+ err2 ? reject(err2) : resolve();
168
237
  });
169
238
  }
170
239
  });
171
240
  var finders = {
172
241
  darwin(port) {
173
242
  return new Promise((resolve, reject) => {
174
- utils.exec("netstat -anv -p TCP && netstat -anv -p UDP", function(err, stdout, stderr) {
175
- if (err) {
176
- reject(err);
243
+ utils.exec("netstat -anv -p TCP && netstat -anv -p UDP", function(err2, stdout, stderr) {
244
+ if (err2) {
245
+ reject(err2);
177
246
  } else {
178
- err = stderr.toString().trim();
179
- if (err) {
180
- reject(err);
247
+ err2 = stderr.toString().trim();
248
+ if (err2) {
249
+ reject(err2);
181
250
  return;
182
251
  }
183
252
  const data = utils.stripLine(stdout.toString(), 2);
@@ -203,9 +272,9 @@ var require_find_pid = __commonJS({
203
272
  linux(port) {
204
273
  return new Promise((resolve, reject) => {
205
274
  const cmd = "netstat -tunlp";
206
- utils.exec(cmd, function(err, stdout, stderr) {
207
- if (err) {
208
- reject(err);
275
+ utils.exec(cmd, function(err2, stdout, stderr) {
276
+ if (err2) {
277
+ reject(err2);
209
278
  } else {
210
279
  const warn = stderr.toString().trim();
211
280
  if (warn) {
@@ -234,13 +303,13 @@ var require_find_pid = __commonJS({
234
303
  },
235
304
  win32(port) {
236
305
  return new Promise((resolve, reject) => {
237
- utils.exec("netstat -ano", function(err, stdout, stderr) {
238
- if (err) {
239
- reject(err);
306
+ utils.exec("netstat -ano", function(err2, stdout, stderr) {
307
+ if (err2) {
308
+ reject(err2);
240
309
  } else {
241
- err = stderr.toString().trim();
242
- if (err) {
243
- reject(err);
310
+ err2 = stderr.toString().trim();
311
+ if (err2) {
312
+ reject(err2);
244
313
  return;
245
314
  }
246
315
  const data = utils.stripLine(stdout.toString(), 4);
@@ -266,11 +335,11 @@ var require_find_pid = __commonJS({
266
335
  const cmd = 'netstat -tunp >> "' + file + '"';
267
336
  ensureDir(dir).then(() => {
268
337
  utils.exec(cmd, () => {
269
- fs.readFile(file, "utf8", (err, data) => {
338
+ fs.readFile(file, "utf8", (err2, data) => {
270
339
  fs.unlink(file, () => {
271
340
  });
272
- if (err) {
273
- reject(err);
341
+ if (err2) {
342
+ reject(err2);
274
343
  } else {
275
344
  data = utils.stripLine(data, 2);
276
345
  const columns = utils.extractColumns(data, [3, 6], 7).find((column) => {
@@ -367,17 +436,17 @@ var require_find_process = __commonJS({
367
436
  } else {
368
437
  cmd = "ps ax -ww -o pid,ppid,uid,gid,args";
369
438
  }
370
- utils.exec(cmd, function(err, stdout, stderr) {
371
- if (err) {
439
+ utils.exec(cmd, function(err2, stdout, stderr) {
440
+ if (err2) {
372
441
  if ("pid" in cond) {
373
442
  resolve([]);
374
443
  } else {
375
- reject(err);
444
+ reject(err2);
376
445
  }
377
446
  } else {
378
- err = stderr.toString().trim();
379
- if (err) {
380
- reject(err);
447
+ err2 = stderr.toString().trim();
448
+ if (err2) {
449
+ reject(err2);
381
450
  return;
382
451
  }
383
452
  const data = utils.stripLine(stdout.toString(), 1);
@@ -455,17 +524,17 @@ var require_find_process = __commonJS({
455
524
  android(cond) {
456
525
  return new Promise((resolve, reject) => {
457
526
  const cmd = "ps";
458
- utils.exec(cmd, function(err, stdout, stderr) {
459
- if (err) {
527
+ utils.exec(cmd, function(err2, stdout, stderr) {
528
+ if (err2) {
460
529
  if ("pid" in cond) {
461
530
  resolve([]);
462
531
  } else {
463
- reject(err);
532
+ reject(err2);
464
533
  }
465
534
  } else {
466
- err = stderr.toString().trim();
467
- if (err) {
468
- reject(err);
535
+ err2 = stderr.toString().trim();
536
+ if (err2) {
537
+ reject(err2);
469
538
  return;
470
539
  }
471
540
  const data = utils.stripLine(stdout.toString(), 1);
@@ -500,7 +569,7 @@ var require_find_process = __commonJS({
500
569
  });
501
570
  }
502
571
  };
503
- function findProcess(cond) {
572
+ function findProcess2(cond) {
504
573
  const platform = process.platform;
505
574
  return new Promise((resolve, reject) => {
506
575
  if (!(platform in finders)) {
@@ -513,7 +582,7 @@ var require_find_process = __commonJS({
513
582
  find(cond).then(resolve, reject);
514
583
  });
515
584
  }
516
- module2.exports = findProcess;
585
+ module2.exports = findProcess2;
517
586
  }
518
587
  });
519
588
 
@@ -523,7 +592,7 @@ var require_find = __commonJS({
523
592
  "use strict";
524
593
  init_cjs_shims();
525
594
  var findPid = require_find_pid();
526
- var findProcess = require_find_process();
595
+ var findProcess2 = require_find_process();
527
596
  var findBy = {
528
597
  port(port, strict) {
529
598
  return findPid(port, strict).then((pid) => {
@@ -533,13 +602,13 @@ var require_find = __commonJS({
533
602
  });
534
603
  },
535
604
  pid(pid, strict) {
536
- return findProcess({
605
+ return findProcess2({
537
606
  pid,
538
607
  strict
539
608
  });
540
609
  },
541
610
  name(name, strict) {
542
- return findProcess({
611
+ return findProcess2({
543
612
  name,
544
613
  strict
545
614
  });
@@ -718,8 +787,8 @@ var require_Events = __commonJS({
718
787
  function _next(value) {
719
788
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
720
789
  }
721
- function _throw(err) {
722
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
790
+ function _throw(err2) {
791
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
723
792
  }
724
793
  _next(void 0);
725
794
  });
@@ -936,8 +1005,8 @@ var require_Job = __commonJS({
936
1005
  function _next(value) {
937
1006
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
938
1007
  }
939
- function _throw(err) {
940
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
1008
+ function _throw(err2) {
1009
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
941
1010
  }
942
1011
  _next(void 0);
943
1012
  });
@@ -1141,8 +1210,8 @@ var require_LocalDatastore = __commonJS({
1141
1210
  function _next(value) {
1142
1211
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
1143
1212
  }
1144
- function _throw(err) {
1145
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
1213
+ function _throw(err2) {
1214
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
1146
1215
  }
1147
1216
  _next(void 0);
1148
1217
  });
@@ -1706,8 +1775,8 @@ var require_RedisConnection = __commonJS({
1706
1775
  function _next(value) {
1707
1776
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1708
1777
  }
1709
- function _throw(err) {
1710
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1778
+ function _throw(err2) {
1779
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
1711
1780
  }
1712
1781
  _next(void 0);
1713
1782
  });
@@ -1769,9 +1838,9 @@ var require_RedisConnection = __commonJS({
1769
1838
  return new this.Promise((resolve, reject) => {
1770
1839
  var payload;
1771
1840
  payload = Scripts.payload(name);
1772
- return this.client.multi([["script", "load", payload]]).exec((err, replies) => {
1773
- if (err != null) {
1774
- return reject(err);
1841
+ return this.client.multi([["script", "load", payload]]).exec((err2, replies) => {
1842
+ if (err2 != null) {
1843
+ return reject(err2);
1775
1844
  }
1776
1845
  this.shas[name] = replies[0];
1777
1846
  return resolve(replies[0]);
@@ -1788,9 +1857,9 @@ var require_RedisConnection = __commonJS({
1788
1857
  return _asyncToGenerator(function* () {
1789
1858
  yield _this.ready;
1790
1859
  return new _this.Promise((resolve, reject) => {
1791
- return _this.client.multi([cmd]).exec_atomic(function(err, replies) {
1792
- if (err != null) {
1793
- return reject(err);
1860
+ return _this.client.multi([cmd]).exec_atomic(function(err2, replies) {
1861
+ if (err2 != null) {
1862
+ return reject(err2);
1794
1863
  } else {
1795
1864
  return resolve(replies[0]);
1796
1865
  }
@@ -1821,9 +1890,9 @@ var require_RedisConnection = __commonJS({
1821
1890
  var _ref = _asyncToGenerator(function* (channel) {
1822
1891
  if (!_this2.terminated) {
1823
1892
  yield new _this2.Promise((resolve, reject) => {
1824
- return _this2.subscriber.unsubscribe(channel, function(err, chan) {
1825
- if (err != null) {
1826
- return reject(err);
1893
+ return _this2.subscriber.unsubscribe(channel, function(err2, chan) {
1894
+ if (err2 != null) {
1895
+ return reject(err2);
1827
1896
  }
1828
1897
  if (chan === channel) {
1829
1898
  return resolve();
@@ -1898,9 +1967,9 @@ var require_IORedisConnection = __commonJS({
1898
1967
  if (i && _arr.length === i)
1899
1968
  break;
1900
1969
  }
1901
- } catch (err) {
1970
+ } catch (err2) {
1902
1971
  _d = true;
1903
- _e = err;
1972
+ _e = err2;
1904
1973
  } finally {
1905
1974
  try {
1906
1975
  if (!_n && _i["return"] != null)
@@ -1938,8 +2007,8 @@ var require_IORedisConnection = __commonJS({
1938
2007
  function _next(value) {
1939
2008
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1940
2009
  }
1941
- function _throw(err) {
1942
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2010
+ function _throw(err2) {
2011
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
1943
2012
  }
1944
2013
  _next(void 0);
1945
2014
  });
@@ -2112,9 +2181,9 @@ var require_RedisDatastore = __commonJS({
2112
2181
  if (i && _arr.length === i)
2113
2182
  break;
2114
2183
  }
2115
- } catch (err) {
2184
+ } catch (err2) {
2116
2185
  _d = true;
2117
- _e = err;
2186
+ _e = err2;
2118
2187
  } finally {
2119
2188
  try {
2120
2189
  if (!_n && _i["return"] != null)
@@ -2152,8 +2221,8 @@ var require_RedisDatastore = __commonJS({
2152
2221
  function _next(value) {
2153
2222
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
2154
2223
  }
2155
- function _throw(err) {
2156
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
2224
+ function _throw(err2) {
2225
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
2157
2226
  }
2158
2227
  _next(void 0);
2159
2228
  });
@@ -2293,9 +2362,9 @@ var require_RedisDatastore = __commonJS({
2293
2362
  var all_args, arr;
2294
2363
  all_args = [Date.now(), _this3.clientId].concat(args);
2295
2364
  _this3.instance.Events.trigger("debug", `Calling Redis script: ${name}.lua`, all_args);
2296
- arr = _this3.connection.__scriptArgs__(name, _this3.originalId, all_args, function(err, replies) {
2297
- if (err != null) {
2298
- return reject(err);
2365
+ arr = _this3.connection.__scriptArgs__(name, _this3.originalId, all_args, function(err2, replies) {
2366
+ if (err2 != null) {
2367
+ return reject(err2);
2299
2368
  }
2300
2369
  return resolve(replies);
2301
2370
  });
@@ -2552,8 +2621,8 @@ var require_Sync = __commonJS({
2552
2621
  function _next(value) {
2553
2622
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
2554
2623
  }
2555
- function _throw(err) {
2556
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
2624
+ function _throw(err2) {
2625
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
2557
2626
  }
2558
2627
  _next(void 0);
2559
2628
  });
@@ -2653,9 +2722,9 @@ var require_Group = __commonJS({
2653
2722
  if (i && _arr.length === i)
2654
2723
  break;
2655
2724
  }
2656
- } catch (err) {
2725
+ } catch (err2) {
2657
2726
  _d = true;
2658
- _e = err;
2727
+ _e = err2;
2659
2728
  } finally {
2660
2729
  try {
2661
2730
  if (!_n && _i["return"] != null)
@@ -2693,8 +2762,8 @@ var require_Group = __commonJS({
2693
2762
  function _next(value) {
2694
2763
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
2695
2764
  }
2696
- function _throw(err) {
2697
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
2765
+ function _throw(err2) {
2766
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
2698
2767
  }
2699
2768
  _next(void 0);
2700
2769
  });
@@ -2737,14 +2806,14 @@ var require_Group = __commonJS({
2737
2806
  key(key = "") {
2738
2807
  var ref;
2739
2808
  return (ref = this.instances[key]) != null ? ref : (() => {
2740
- var limiter;
2741
- limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, {
2809
+ var limiter2;
2810
+ limiter2 = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, {
2742
2811
  id: `${this.id}-${key}`,
2743
2812
  timeout: this.timeout,
2744
2813
  connection: this.connection
2745
2814
  }));
2746
- this.Events.trigger("created", limiter, key);
2747
- return limiter;
2815
+ this.Events.trigger("created", limiter2, key);
2816
+ return limiter2;
2748
2817
  })();
2749
2818
  }
2750
2819
  deleteKey(key = "") {
@@ -2936,9 +3005,9 @@ var require_Bottleneck = __commonJS({
2936
3005
  if (i && _arr.length === i)
2937
3006
  break;
2938
3007
  }
2939
- } catch (err) {
3008
+ } catch (err2) {
2940
3009
  _d = true;
2941
- _e = err;
3010
+ _e = err2;
2942
3011
  } finally {
2943
3012
  try {
2944
3013
  if (!_n && _i["return"] != null)
@@ -2986,14 +3055,14 @@ var require_Bottleneck = __commonJS({
2986
3055
  function _next(value) {
2987
3056
  asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "next", value);
2988
3057
  }
2989
- function _throw(err) {
2990
- asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err);
3058
+ function _throw(err2) {
3059
+ asyncGeneratorStep2(gen, resolve, reject, _next, _throw, "throw", err2);
2991
3060
  }
2992
3061
  _next(void 0);
2993
3062
  });
2994
3063
  };
2995
3064
  }
2996
- var Bottleneck;
3065
+ var Bottleneck2;
2997
3066
  var DEFAULT_PRIORITY;
2998
3067
  var Events2;
2999
3068
  var Job;
@@ -3015,8 +3084,8 @@ var require_Bottleneck = __commonJS({
3015
3084
  Events2 = require_Events();
3016
3085
  States = require_States();
3017
3086
  Sync = require_Sync();
3018
- Bottleneck = function() {
3019
- class Bottleneck2 {
3087
+ Bottleneck2 = function() {
3088
+ class Bottleneck3 {
3020
3089
  constructor(options2 = {}, ...invalid) {
3021
3090
  var storeInstanceOptions, storeOptions;
3022
3091
  this._addToQueue = this._addToQueue.bind(this);
@@ -3038,7 +3107,7 @@ var require_Bottleneck = __commonJS({
3038
3107
  storeInstanceOptions = parser2.load(options2, this.localStoreDefaults, {});
3039
3108
  return new LocalDatastore(this, storeOptions, storeInstanceOptions);
3040
3109
  } else {
3041
- throw new Bottleneck2.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`);
3110
+ throw new Bottleneck3.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`);
3042
3111
  }
3043
3112
  }.call(this);
3044
3113
  this._queues.on("leftzero", () => {
@@ -3052,7 +3121,7 @@ var require_Bottleneck = __commonJS({
3052
3121
  }
3053
3122
  _validateOptions(options2, invalid) {
3054
3123
  if (!(options2 != null && typeof options2 === "object" && invalid.length === 0)) {
3055
- throw new Bottleneck2.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.");
3124
+ throw new Bottleneck3.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.");
3056
3125
  }
3057
3126
  }
3058
3127
  ready() {
@@ -3268,10 +3337,10 @@ var require_Bottleneck = __commonJS({
3268
3337
  return waitForExecuting(1);
3269
3338
  });
3270
3339
  this._receive = function(job) {
3271
- return job._reject(new Bottleneck2.prototype.BottleneckError(options2.enqueueErrorMessage));
3340
+ return job._reject(new Bottleneck3.prototype.BottleneckError(options2.enqueueErrorMessage));
3272
3341
  };
3273
3342
  this.stop = () => {
3274
- return this.Promise.reject(new Bottleneck2.prototype.BottleneckError("stop() has already been called"));
3343
+ return this.Promise.reject(new Bottleneck3.prototype.BottleneckError("stop() has already been called"));
3275
3344
  };
3276
3345
  return done;
3277
3346
  }
@@ -3302,11 +3371,11 @@ var require_Bottleneck = __commonJS({
3302
3371
  job.doDrop();
3303
3372
  return true;
3304
3373
  } else if (reachedHWM) {
3305
- shifted = strategy === Bottleneck2.prototype.strategy.LEAK ? _this2._queues.shiftLastFrom(options2.priority) : strategy === Bottleneck2.prototype.strategy.OVERFLOW_PRIORITY ? _this2._queues.shiftLastFrom(options2.priority + 1) : strategy === Bottleneck2.prototype.strategy.OVERFLOW ? job : void 0;
3374
+ shifted = strategy === Bottleneck3.prototype.strategy.LEAK ? _this2._queues.shiftLastFrom(options2.priority) : strategy === Bottleneck3.prototype.strategy.OVERFLOW_PRIORITY ? _this2._queues.shiftLastFrom(options2.priority + 1) : strategy === Bottleneck3.prototype.strategy.OVERFLOW ? job : void 0;
3306
3375
  if (shifted != null) {
3307
3376
  shifted.doDrop();
3308
3377
  }
3309
- if (shifted == null || strategy === Bottleneck2.prototype.strategy.OVERFLOW) {
3378
+ if (shifted == null || strategy === Bottleneck3.prototype.strategy.OVERFLOW) {
3310
3379
  if (shifted == null) {
3311
3380
  job.doDrop();
3312
3381
  }
@@ -3321,7 +3390,7 @@ var require_Bottleneck = __commonJS({
3321
3390
  }
3322
3391
  _receive(job) {
3323
3392
  if (this._states.jobStatus(job.options.id) != null) {
3324
- job._reject(new Bottleneck2.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`));
3393
+ job._reject(new Bottleneck3.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`));
3325
3394
  return false;
3326
3395
  } else {
3327
3396
  job.doReceive();
@@ -3404,31 +3473,31 @@ var require_Bottleneck = __commonJS({
3404
3473
  }
3405
3474
  }
3406
3475
  ;
3407
- Bottleneck2.default = Bottleneck2;
3408
- Bottleneck2.Events = Events2;
3409
- Bottleneck2.version = Bottleneck2.prototype.version = require_version().version;
3410
- Bottleneck2.strategy = Bottleneck2.prototype.strategy = {
3476
+ Bottleneck3.default = Bottleneck3;
3477
+ Bottleneck3.Events = Events2;
3478
+ Bottleneck3.version = Bottleneck3.prototype.version = require_version().version;
3479
+ Bottleneck3.strategy = Bottleneck3.prototype.strategy = {
3411
3480
  LEAK: 1,
3412
3481
  OVERFLOW: 2,
3413
3482
  OVERFLOW_PRIORITY: 4,
3414
3483
  BLOCK: 3
3415
3484
  };
3416
- Bottleneck2.BottleneckError = Bottleneck2.prototype.BottleneckError = require_BottleneckError();
3417
- Bottleneck2.Group = Bottleneck2.prototype.Group = require_Group();
3418
- Bottleneck2.RedisConnection = Bottleneck2.prototype.RedisConnection = require_RedisConnection();
3419
- Bottleneck2.IORedisConnection = Bottleneck2.prototype.IORedisConnection = require_IORedisConnection();
3420
- Bottleneck2.Batcher = Bottleneck2.prototype.Batcher = require_Batcher();
3421
- Bottleneck2.prototype.jobDefaults = {
3485
+ Bottleneck3.BottleneckError = Bottleneck3.prototype.BottleneckError = require_BottleneckError();
3486
+ Bottleneck3.Group = Bottleneck3.prototype.Group = require_Group();
3487
+ Bottleneck3.RedisConnection = Bottleneck3.prototype.RedisConnection = require_RedisConnection();
3488
+ Bottleneck3.IORedisConnection = Bottleneck3.prototype.IORedisConnection = require_IORedisConnection();
3489
+ Bottleneck3.Batcher = Bottleneck3.prototype.Batcher = require_Batcher();
3490
+ Bottleneck3.prototype.jobDefaults = {
3422
3491
  priority: DEFAULT_PRIORITY,
3423
3492
  weight: 1,
3424
3493
  expiration: null,
3425
3494
  id: "<no-id>"
3426
3495
  };
3427
- Bottleneck2.prototype.storeDefaults = {
3496
+ Bottleneck3.prototype.storeDefaults = {
3428
3497
  maxConcurrent: null,
3429
3498
  minTime: 0,
3430
3499
  highWater: null,
3431
- strategy: Bottleneck2.prototype.strategy.LEAK,
3500
+ strategy: Bottleneck3.prototype.strategy.LEAK,
3432
3501
  penalty: null,
3433
3502
  reservoir: null,
3434
3503
  reservoirRefreshInterval: null,
@@ -3437,12 +3506,12 @@ var require_Bottleneck = __commonJS({
3437
3506
  reservoirIncreaseAmount: null,
3438
3507
  reservoirIncreaseMaximum: null
3439
3508
  };
3440
- Bottleneck2.prototype.localStoreDefaults = {
3509
+ Bottleneck3.prototype.localStoreDefaults = {
3441
3510
  Promise,
3442
3511
  timeout: null,
3443
3512
  heartbeatInterval: 250
3444
3513
  };
3445
- Bottleneck2.prototype.redisStoreDefaults = {
3514
+ Bottleneck3.prototype.redisStoreDefaults = {
3446
3515
  Promise,
3447
3516
  timeout: null,
3448
3517
  heartbeatInterval: 5e3,
@@ -3453,7 +3522,7 @@ var require_Bottleneck = __commonJS({
3453
3522
  clearDatastore: false,
3454
3523
  connection: null
3455
3524
  };
3456
- Bottleneck2.prototype.instanceDefaults = {
3525
+ Bottleneck3.prototype.instanceDefaults = {
3457
3526
  datastore: "local",
3458
3527
  connection: null,
3459
3528
  id: "<no-id>",
@@ -3461,14 +3530,14 @@ var require_Bottleneck = __commonJS({
3461
3530
  trackDoneStatus: false,
3462
3531
  Promise
3463
3532
  };
3464
- Bottleneck2.prototype.stopDefaults = {
3533
+ Bottleneck3.prototype.stopDefaults = {
3465
3534
  enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.",
3466
3535
  dropWaitingJobs: true,
3467
3536
  dropErrorMessage: "This limiter has been stopped."
3468
3537
  };
3469
- return Bottleneck2;
3538
+ return Bottleneck3;
3470
3539
  }.call(void 0);
3471
- module2.exports = Bottleneck;
3540
+ module2.exports = Bottleneck2;
3472
3541
  }
3473
3542
  });
3474
3543
 
@@ -3481,9 +3550,764 @@ var require_lib = __commonJS({
3481
3550
  }
3482
3551
  });
3483
3552
 
3553
+ // ../cli-kit/dist/public/node/session.js
3554
+ init_cjs_shims();
3555
+
3556
+ // ../cli-kit/dist/public/node/context/fqdn.js
3557
+ init_cjs_shims();
3558
+ var CouldntObtainPartnersSpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.");
3559
+ var CouldntObtainIdentitySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.");
3560
+ var CouldntObtainShopifySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.");
3561
+ var NotProvidedStoreFQDNError = new AbortError("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
3562
+ async function partnersFqdn() {
3563
+ const environment = serviceEnvironment();
3564
+ const productionFqdn = "partners.shopify.com";
3565
+ switch (environment) {
3566
+ case "local":
3567
+ return "partners.myshopify.io";
3568
+ case "spin":
3569
+ return `partners.${await spinFqdn()}`;
3570
+ default:
3571
+ return productionFqdn;
3572
+ }
3573
+ }
3574
+ async function appManagementFqdn() {
3575
+ const environment = serviceEnvironment();
3576
+ const productionFqdn = "shopify.com";
3577
+ switch (environment) {
3578
+ case "local":
3579
+ return "app.shopify.myshopify.io";
3580
+ case "spin":
3581
+ return `app.shopify.${await spinFqdn()}`;
3582
+ default:
3583
+ return productionFqdn;
3584
+ }
3585
+ }
3586
+ async function businessPlatformFqdn() {
3587
+ const environment = serviceEnvironment();
3588
+ const productionFqdn = "destinations.shopifysvc.com";
3589
+ switch (environment) {
3590
+ case "local":
3591
+ return "business-platform.myshopify.io";
3592
+ case "spin":
3593
+ return `business-platform.${await spinFqdn()}`;
3594
+ default:
3595
+ return productionFqdn;
3596
+ }
3597
+ }
3598
+ async function identityFqdn() {
3599
+ const environment = serviceEnvironment();
3600
+ const productionFqdn = "accounts.shopify.com";
3601
+ switch (environment) {
3602
+ case "local":
3603
+ return "identity.myshopify.io";
3604
+ case "spin":
3605
+ return `identity.${await spinFqdn()}`;
3606
+ default:
3607
+ return productionFqdn;
3608
+ }
3609
+ }
3610
+ async function normalizeStoreFqdn(store2) {
3611
+ const storeFqdn = store2.replace(/^https?:\/\//, "").replace(/\/$/, "");
3612
+ const addDomain = async (storeFqdn2) => isSpinEnvironment() ? `${storeFqdn2}.shopify.${await spinFqdn()}` : `${storeFqdn2}.myshopify.com`;
3613
+ const containDomain = (storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev");
3614
+ return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
3615
+ }
3616
+
3617
+ // ../cli-kit/dist/private/node/session/store.js
3618
+ init_cjs_shims();
3619
+
3620
+ // ../cli-kit/dist/private/node/session/schema.js
3621
+ init_cjs_shims();
3622
+ var DateSchema = z.preprocess((arg) => {
3623
+ if (typeof arg === "string" || arg instanceof Date)
3624
+ return new Date(arg);
3625
+ return null;
3626
+ }, z.date());
3627
+ var IdentityTokenSchema = z.object({
3628
+ accessToken: z.string(),
3629
+ refreshToken: z.string(),
3630
+ expiresAt: DateSchema,
3631
+ scopes: z.array(z.string())
3632
+ });
3633
+ var ApplicationTokenSchema = z.object({
3634
+ accessToken: z.string(),
3635
+ expiresAt: DateSchema,
3636
+ scopes: z.array(z.string())
3637
+ });
3638
+ var SessionSchema = z.object({}).catchall(z.object({
3639
+ /**
3640
+ * It contains the identity token. Before usint it, we exchange it
3641
+ * to get a token that we can use with different applications. The exchanged
3642
+ * tokens for the applications are stored under applications.
3643
+ */
3644
+ identity: IdentityTokenSchema,
3645
+ /**
3646
+ * It contains exchanged tokens for the applications the CLI
3647
+ * authenticates with. Tokens are scoped under the fqdn of the applications.
3648
+ */
3649
+ applications: z.object({}).catchall(ApplicationTokenSchema)
3650
+ }));
3651
+
3652
+ // ../cli-kit/dist/private/node/session/store.js
3653
+ async function store(session) {
3654
+ const jsonSession = JSON.stringify(session);
3655
+ setSession(jsonSession);
3656
+ }
3657
+ async function fetch() {
3658
+ const content = getSession();
3659
+ if (!content) {
3660
+ return void 0;
3661
+ }
3662
+ const contentJson = JSON.parse(content);
3663
+ const parsedSession = await SessionSchema.safeParseAsync(contentJson);
3664
+ if (parsedSession.success) {
3665
+ return parsedSession.data;
3666
+ } else {
3667
+ await remove();
3668
+ return void 0;
3669
+ }
3670
+ }
3671
+ async function remove() {
3672
+ removeSession();
3673
+ }
3674
+
3675
+ // ../cli-kit/dist/private/node/session/exchange.js
3676
+ init_cjs_shims();
3677
+
3678
+ // ../cli-kit/dist/private/node/session/identity.js
3679
+ init_cjs_shims();
3680
+ function clientId() {
3681
+ const environment = serviceEnvironment();
3682
+ if (environment === Environment.Local) {
3683
+ return "e5380e02-312a-7408-5718-e07017e9cf52";
3684
+ } else if (environment === Environment.Production) {
3685
+ return "fbdb2649-e327-4907-8f67-908d24cfd7e3";
3686
+ } else {
3687
+ return "e5380e02-312a-7408-5718-e07017e9cf52";
3688
+ }
3689
+ }
3690
+ function applicationId(api) {
3691
+ switch (api) {
3692
+ case "admin": {
3693
+ const environment = serviceEnvironment();
3694
+ if (environment === Environment.Local) {
3695
+ return "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
3696
+ } else if (environment === Environment.Production) {
3697
+ return "7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c";
3698
+ } else {
3699
+ return "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
3700
+ }
3701
+ }
3702
+ case "partners": {
3703
+ const environment = serviceEnvironment();
3704
+ if (environment === Environment.Local) {
3705
+ return "df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978";
3706
+ } else if (environment === Environment.Production) {
3707
+ return "271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6";
3708
+ } else {
3709
+ return "df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978";
3710
+ }
3711
+ }
3712
+ case "storefront-renderer": {
3713
+ const environment = serviceEnvironment();
3714
+ if (environment === Environment.Local) {
3715
+ return "46f603de-894f-488d-9471-5b721280ff49";
3716
+ } else if (environment === Environment.Production) {
3717
+ return "ee139b3d-5861-4d45-b387-1bc3ada7811c";
3718
+ } else {
3719
+ return "46f603de-894f-488d-9471-5b721280ff49";
3720
+ }
3721
+ }
3722
+ case "business-platform": {
3723
+ const environment = serviceEnvironment();
3724
+ if (environment === Environment.Local) {
3725
+ return "ace6dc89-b526-456d-a942-4b8ef6acda4b";
3726
+ } else if (environment === Environment.Production) {
3727
+ return "32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc";
3728
+ } else {
3729
+ return "ace6dc89-b526-456d-a942-4b8ef6acda4b";
3730
+ }
3731
+ }
3732
+ case "app-management": {
3733
+ const environment = serviceEnvironment();
3734
+ if (environment === Environment.Production) {
3735
+ return "7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c";
3736
+ } else {
3737
+ return "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
3738
+ }
3739
+ }
3740
+ default:
3741
+ throw new BugError(`Application id for API of type: ${api}`);
3742
+ }
3743
+ }
3744
+
3745
+ // ../cli-kit/dist/public/node/result.js
3746
+ init_cjs_shims();
3747
+ var ok = (value) => new Ok(value);
3748
+ var err = (err2) => new Err(err2);
3749
+ var Ok = class {
3750
+ constructor(value) {
3751
+ this.value = value;
3752
+ }
3753
+ /**
3754
+ * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`
3755
+ *
3756
+ * @returns `false` as the `Resul` is `OK`
3757
+ */
3758
+ isErr() {
3759
+ return false;
3760
+ }
3761
+ /**
3762
+ * Runs the `handler` method an return the same an unaltered copy of the `Result`. It could be used to log an
3763
+ * output when the result is `Ok` without breaking the flow
3764
+ *
3765
+ * @param handler - method to be run when the result is `Ok`
3766
+ * @returns a copy of the same `Result`
3767
+ */
3768
+ doOnOk(handler) {
3769
+ handler(this.value);
3770
+ return ok(this.value);
3771
+ }
3772
+ /**
3773
+ * A safe mode to throw the `error` of the `Result`
3774
+ */
3775
+ valueOrBug() {
3776
+ return this.value;
3777
+ }
3778
+ /**
3779
+ * Throws an abort error if the result doesn't represent a value.
3780
+ */
3781
+ valueOrAbort() {
3782
+ return this.value;
3783
+ }
3784
+ /**
3785
+ * Maps the value to another one with a different type. It leaves the `Error` type unaltered
3786
+ *
3787
+ * @param mapper - The mapper method to apply an `OK` value
3788
+ * @returns a new result with the new mapped value
3789
+ */
3790
+ map(mapper) {
3791
+ return ok(mapper(this.value));
3792
+ }
3793
+ /**
3794
+ * Maps the error type to another one. It leaves the `Ok` type and value unaltered
3795
+ *
3796
+ * @param _mapper - This mapper method is not used for an `Ok` value
3797
+ * @returns a new result with the new mapped error type and an value
3798
+ */
3799
+ mapError(_mapper) {
3800
+ return ok(this.value);
3801
+ }
3802
+ };
3803
+ var Err = class {
3804
+ // eslint-disable-next-line node/handle-callback-err
3805
+ constructor(error) {
3806
+ this.error = error;
3807
+ }
3808
+ /**
3809
+ * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`
3810
+ *
3811
+ * @returns `false` as the `Resul` is `OK`
3812
+ */
3813
+ isErr() {
3814
+ return true;
3815
+ }
3816
+ /**
3817
+ * Return an unaltered copy of the `Error` without doing anything.
3818
+ *
3819
+ * @param _handler - This handler method is not used for an `Error`
3820
+ * @returns a copy of the same `Error`
3821
+ */
3822
+ doOnOk(_handler) {
3823
+ return err(this.error);
3824
+ }
3825
+ /**
3826
+ * A safe mode to throw the `error` of the `Result`
3827
+ */
3828
+ valueOrBug() {
3829
+ throw this.error;
3830
+ }
3831
+ /**
3832
+ * Throws an abort error if the result doesn't represent a value.
3833
+ */
3834
+ valueOrAbort() {
3835
+ if (this.error instanceof FatalError) {
3836
+ throw this.error;
3837
+ } else if (this.error instanceof import_ts_error.ExtendableError || this.error instanceof Error) {
3838
+ const error = new AbortError(this.error.message);
3839
+ error.stack = this.error.stack;
3840
+ throw error;
3841
+ } else {
3842
+ throw new AbortError(`${this.error}`);
3843
+ }
3844
+ }
3845
+ /**
3846
+ * Maps the value type to another one. It leaves the `Error` unaltered
3847
+ *
3848
+ * @param _mapper - This mapper method is not used for an `Error` value
3849
+ * @returns a new result with the new value type and an unaltered error
3850
+ */
3851
+ map(_mapper) {
3852
+ return err(this.error);
3853
+ }
3854
+ /**
3855
+ * Maps the error to another one with a different type. It leaves the value type unaltered
3856
+ *
3857
+ * @param mapper - The mapper method to apply an `Error` value
3858
+ * @returns a new result with the new mapped error
3859
+ */
3860
+ mapError(mapper) {
3861
+ return err(mapper(this.error));
3862
+ }
3863
+ };
3864
+
3865
+ // ../cli-kit/dist/private/node/session/exchange.js
3866
+ var InvalidGrantError = class extends import_ts_error.ExtendableError {
3867
+ };
3868
+ var InvalidRequestError = class extends import_ts_error.ExtendableError {
3869
+ };
3870
+ async function exchangeCodeForAccessToken(codeData) {
3871
+ const clientId2 = await clientId();
3872
+ const params = {
3873
+ grant_type: "authorization_code",
3874
+ code: codeData.code,
3875
+ redirect_uri: "http://127.0.0.1:3456",
3876
+ client_id: clientId2,
3877
+ code_verifier: codeData.codeVerifier
3878
+ };
3879
+ const tokenResult = await tokenRequest(params);
3880
+ const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug();
3881
+ return buildIdentityToken(value);
3882
+ }
3883
+ async function exchangeAccessForApplicationTokens(identityToken, scopes, store2) {
3884
+ const token = identityToken.accessToken;
3885
+ const appManagementEnabled = isTruthy(process.env.USE_APP_MANAGEMENT_API);
3886
+ const [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([
3887
+ requestAppToken("partners", token, scopes.partners),
3888
+ requestAppToken("storefront-renderer", token, scopes.storefront),
3889
+ requestAppToken("business-platform", token, scopes.businessPlatform),
3890
+ store2 ? requestAppToken("admin", token, scopes.admin, store2) : {},
3891
+ appManagementEnabled ? requestAppToken("app-management", token, scopes.appManagement) : {}
3892
+ ]);
3893
+ return {
3894
+ ...partners,
3895
+ ...storefront,
3896
+ ...businessPlatform,
3897
+ ...admin,
3898
+ ...appManagement
3899
+ };
3900
+ }
3901
+ async function refreshAccessToken(currentToken) {
3902
+ const clientId2 = clientId();
3903
+ const params = {
3904
+ grant_type: "refresh_token",
3905
+ access_token: currentToken.accessToken,
3906
+ refresh_token: currentToken.refreshToken,
3907
+ client_id: clientId2
3908
+ };
3909
+ const tokenResult = await tokenRequest(params);
3910
+ const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug();
3911
+ return buildIdentityToken(value);
3912
+ }
3913
+ async function exchangeCustomPartnerToken(token) {
3914
+ const appId = applicationId("partners");
3915
+ try {
3916
+ const newToken = await requestAppToken("partners", token, ["https://api.shopify.com/auth/partners.app.cli.access"]);
3917
+ return newToken[appId];
3918
+ } catch (error) {
3919
+ throw new AbortError("The custom token provided is invalid.", "Ensure the token is correct and not expired.");
3920
+ }
3921
+ }
3922
+ async function exchangeDeviceCodeForAccessToken(deviceCode) {
3923
+ const clientId2 = await clientId();
3924
+ const params = {
3925
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
3926
+ device_code: deviceCode,
3927
+ client_id: clientId2
3928
+ };
3929
+ const tokenResult = await tokenRequest(params);
3930
+ if (tokenResult.isErr()) {
3931
+ return err(tokenResult.error);
3932
+ }
3933
+ const identityToken = buildIdentityToken(tokenResult.value);
3934
+ return ok(identityToken);
3935
+ }
3936
+ async function requestAppToken(api, token, scopes = [], store2) {
3937
+ const appId = applicationId(api);
3938
+ const clientId2 = await clientId();
3939
+ const params = {
3940
+ grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
3941
+ requested_token_type: "urn:ietf:params:oauth:token-type:access_token",
3942
+ subject_token_type: "urn:ietf:params:oauth:token-type:access_token",
3943
+ client_id: clientId2,
3944
+ audience: appId,
3945
+ scope: scopes.join(" "),
3946
+ subject_token: token,
3947
+ ...api === "admin" && { destination: `https://${store2}/admin` }
3948
+ };
3949
+ let identifier = appId;
3950
+ if (api === "admin" && store2) {
3951
+ identifier = `${store2}-${appId}`;
3952
+ }
3953
+ const tokenResult = await tokenRequest(params);
3954
+ const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug();
3955
+ const appToken = buildApplicationToken(value);
3956
+ return { [identifier]: appToken };
3957
+ }
3958
+ function tokenRequestErrorHandler(error) {
3959
+ if (error === "invalid_grant") {
3960
+ return new InvalidGrantError();
3961
+ }
3962
+ if (error === "invalid_request") {
3963
+ return new InvalidRequestError();
3964
+ }
3965
+ return new AbortError(error);
3966
+ }
3967
+ async function tokenRequest(params) {
3968
+ const fqdn = await identityFqdn();
3969
+ const url2 = new URL(`https://${fqdn}/oauth/token`);
3970
+ url2.search = new URLSearchParams(Object.entries(params)).toString();
3971
+ const res = await shopifyFetch(url2.href, { method: "POST" });
3972
+ const payload = await res.json();
3973
+ if (res.ok)
3974
+ return ok(payload);
3975
+ return err(payload.error);
3976
+ }
3977
+ function buildIdentityToken(result) {
3978
+ return {
3979
+ accessToken: result.access_token,
3980
+ refreshToken: result.refresh_token,
3981
+ expiresAt: new Date(Date.now() + result.expires_in * 1e3),
3982
+ scopes: result.scope.split(" ")
3983
+ };
3984
+ }
3985
+ function buildApplicationToken(result) {
3986
+ return {
3987
+ accessToken: result.access_token,
3988
+ expiresAt: new Date(Date.now() + result.expires_in * 1e3),
3989
+ scopes: result.scope.split(" ")
3990
+ };
3991
+ }
3992
+
3993
+ // ../cli-kit/dist/private/node/session.js
3994
+ init_cjs_shims();
3995
+
3996
+ // ../cli-kit/dist/private/node/session/validate.js
3997
+ init_cjs_shims();
3998
+
3999
+ // ../cli-kit/dist/private/node/session/identity-token-validation.js
4000
+ init_cjs_shims();
4001
+ async function validateIdentityToken(token) {
4002
+ if (isSpin() && firstPartyDev())
4003
+ return true;
4004
+ try {
4005
+ return withIntrospectionURL(async (introspectionURL) => {
4006
+ const options2 = {
4007
+ method: "POST",
4008
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
4009
+ body: JSON.stringify({ token })
4010
+ };
4011
+ outputDebug(`Sending Identity Introspection request to URL: ${introspectionURL}`);
4012
+ const response = await shopifyFetch(introspectionURL, options2);
4013
+ if (response.ok && response.headers.get("content-type")?.includes("json")) {
4014
+ const json = await response.json();
4015
+ outputDebug(`The identity token is valid: ${json.valid}`);
4016
+ return ok(json.valid);
4017
+ } else if (response.status === 404 || response.status > 500) {
4018
+ return err(new AbortError(`The introspection endpoint returned a ${response.status}: ${introspectionURL}`));
4019
+ } else {
4020
+ const text = await response.text();
4021
+ outputDebug(`The Introspection request failed with:
4022
+ - status: ${response.status}
4023
+ - www-authenticate header: ${JSON.stringify(response.headers.get("www-authenticate"))}
4024
+ - body: ${JSON.stringify(text)}`);
4025
+ return ok(false);
4026
+ }
4027
+ });
4028
+ } catch (error) {
4029
+ outputDebug(`The identity token is invalid: ${error}`);
4030
+ return false;
4031
+ }
4032
+ }
4033
+ async function withIntrospectionURL(fn) {
4034
+ const week = 7 * 24 * 60 * 60 * 1e3;
4035
+ const cacheKey = `identity-introspection-url-${await identityFqdn()}`;
4036
+ let introspectionURL = await cacheRetrieveOrRepopulate(cacheKey, getIntrospectionURL, week);
4037
+ let result = await fn(introspectionURL);
4038
+ if (result.isErr()) {
4039
+ introspectionURL = await cacheRetrieveOrRepopulate(cacheKey, getIntrospectionURL, 0);
4040
+ result = await fn(introspectionURL);
4041
+ }
4042
+ if (result.isErr()) {
4043
+ throw result.error;
4044
+ } else {
4045
+ return result.value;
4046
+ }
4047
+ }
4048
+ async function getIntrospectionURL() {
4049
+ const response = await shopifyFetch(`https://${await identityFqdn()}/.well-known/openid-configuration.json`);
4050
+ const json = await response.json();
4051
+ return json.introspection_endpoint;
4052
+ }
4053
+
4054
+ // ../cli-kit/dist/private/node/session/validate.js
4055
+ function validateScopes(requestedScopes, identity) {
4056
+ const currentScopes = identity.scopes;
4057
+ if (firstPartyDev() !== currentScopes.includes("employee"))
4058
+ return false;
4059
+ return requestedScopes.every((scope) => currentScopes.includes(scope));
4060
+ }
4061
+ async function validateSession(scopes, applications, session) {
4062
+ if (!session)
4063
+ return "needs_full_auth";
4064
+ const scopesAreValid = validateScopes(scopes, session.identity);
4065
+ const identityIsValid = await validateIdentityToken(session.identity.accessToken);
4066
+ if (!scopesAreValid)
4067
+ return "needs_full_auth";
4068
+ let tokensAreExpired = isTokenExpired(session.identity);
4069
+ if (applications.partnersApi) {
4070
+ const appId = applicationId("partners");
4071
+ const token = session.applications[appId];
4072
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
4073
+ }
4074
+ if (applications.appManagementApi) {
4075
+ const appId = applicationId("app-management");
4076
+ const token = session.applications[appId];
4077
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
4078
+ }
4079
+ if (applications.storefrontRendererApi) {
4080
+ const appId = applicationId("storefront-renderer");
4081
+ const token = session.applications[appId];
4082
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
4083
+ }
4084
+ if (applications.adminApi) {
4085
+ const appId = applicationId("admin");
4086
+ const realAppId = `${applications.adminApi.storeFqdn}-${appId}`;
4087
+ const token = session.applications[realAppId];
4088
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
4089
+ }
4090
+ outputDebug(`
4091
+ The validation of the token for application/identity completed with the following results:
4092
+ - It's expired: ${tokensAreExpired}
4093
+ - It's invalid in identity: ${!identityIsValid}
4094
+ `);
4095
+ if (tokensAreExpired)
4096
+ return "needs_refresh";
4097
+ if (!identityIsValid)
4098
+ return "needs_full_auth";
4099
+ return "ok";
4100
+ }
4101
+ function isTokenExpired(token) {
4102
+ if (!token)
4103
+ return true;
4104
+ return token.expiresAt < expireThreshold();
4105
+ }
4106
+ function expireThreshold() {
4107
+ return new Date(Date.now() + sessionConstants.expirationTimeMarginInMinutes * 60 * 1e3);
4108
+ }
4109
+
4110
+ // ../cli-kit/dist/private/node/session/scopes.js
4111
+ init_cjs_shims();
4112
+ function allDefaultScopes(extraScopes = [], systemEnvironment = process.env) {
4113
+ let scopes = allAPIs.map((api) => defaultApiScopes(api, systemEnvironment)).flat();
4114
+ scopes = ["openid", ...scopes, ...extraScopes].map(scopeTransform);
4115
+ return Array.from(new Set(scopes));
4116
+ }
4117
+ function apiScopes(api, extraScopes = [], systemEnvironment = process.env) {
4118
+ const scopes = [...defaultApiScopes(api, systemEnvironment), ...extraScopes.map(scopeTransform)].map(scopeTransform);
4119
+ return Array.from(new Set(scopes));
4120
+ }
4121
+ function defaultApiScopes(api, systemEnvironment = process.env) {
4122
+ switch (api) {
4123
+ case "admin":
4124
+ return ["graphql", "themes", "collaborator"];
4125
+ case "storefront-renderer":
4126
+ return ["devtools"];
4127
+ case "partners":
4128
+ return ["cli"];
4129
+ case "business-platform":
4130
+ return ["destinations"];
4131
+ case "app-management":
4132
+ return isTruthy(systemEnvironment.USE_APP_MANAGEMENT_API) ? ["app-management"] : [];
4133
+ default:
4134
+ throw new BugError(`Unknown API: ${api}`);
4135
+ }
4136
+ }
4137
+ function scopeTransform(scope) {
4138
+ switch (scope) {
4139
+ case "graphql":
4140
+ return "https://api.shopify.com/auth/shop.admin.graphql";
4141
+ case "themes":
4142
+ return "https://api.shopify.com/auth/shop.admin.themes";
4143
+ case "collaborator":
4144
+ return "https://api.shopify.com/auth/partners.collaborator-relationships.readonly";
4145
+ case "cli":
4146
+ return "https://api.shopify.com/auth/partners.app.cli.access";
4147
+ case "devtools":
4148
+ return "https://api.shopify.com/auth/shop.storefront-renderer.devtools";
4149
+ case "destinations":
4150
+ return "https://api.shopify.com/auth/destinations.readonly";
4151
+ case "app-management":
4152
+ return "https://api.shopify.com/auth/organization.apps.manage";
4153
+ default:
4154
+ return scope;
4155
+ }
4156
+ }
4157
+
4158
+ // ../cli-kit/dist/private/node/session/authorize.js
4159
+ init_cjs_shims();
4160
+
4161
+ // ../cli-kit/dist/private/node/session/redirect-listener.js
4162
+ init_cjs_shims();
4163
+
4164
+ // ../cli-kit/dist/private/node/session/post-auth.js
4165
+ init_cjs_shims();
4166
+ var HTMLFileNames = [
4167
+ "empty-url.html",
4168
+ "auth-error.html",
4169
+ "missing-code.html",
4170
+ "missing-state.html",
4171
+ "success.html"
4172
+ ];
4173
+ var StylesheetFilename = "style.css";
4174
+ var FaviconFileName = "favicon.svg";
4175
+ var getFilePath = async (fileName) => {
4176
+ const filePath = await findPathUp(`assets/${fileName}`, {
4177
+ type: "file",
4178
+ cwd: moduleDirectory(import.meta.url)
4179
+ });
4180
+ if (!filePath) {
4181
+ throw RedirectPageAssetNotFoundError();
4182
+ }
4183
+ return filePath;
4184
+ };
4185
+ var getEmptyUrlHTML = async () => {
4186
+ const filePath = await getFilePath(HTMLFileNames[0]);
4187
+ return readFile(filePath);
4188
+ };
4189
+ var getAuthErrorHTML = async () => {
4190
+ const filePath = await getFilePath(HTMLFileNames[1]);
4191
+ return readFile(filePath);
4192
+ };
4193
+ var getMissingCodeHTML = async () => {
4194
+ const filePath = await getFilePath(HTMLFileNames[2]);
4195
+ return readFile(filePath);
4196
+ };
4197
+ var getMissingStateHTML = async () => {
4198
+ const filePath = await getFilePath(HTMLFileNames[3]);
4199
+ return readFile(filePath);
4200
+ };
4201
+ var getSuccessHTML = async () => {
4202
+ const filePath = await getFilePath(HTMLFileNames[4]);
4203
+ return readFile(filePath);
4204
+ };
4205
+ var getStylesheet = async () => {
4206
+ const filePath = await getFilePath(StylesheetFilename);
4207
+ return readFile(filePath);
4208
+ };
4209
+ var getFavicon = async () => {
4210
+ const filePath = await getFilePath(FaviconFileName);
4211
+ return readFile(filePath);
4212
+ };
4213
+ var EmptyUrlString = "We received the authentication redirect but the URL is empty.";
4214
+ var MissingCodeString = "The authentication can't continue because the redirect doesn't include the code.";
4215
+ var MissingStateString = "The authentication can't continue because the redirect doesn't include the state.";
4216
+ var RedirectPageAssetNotFoundError = () => new BugError(`Redirect page asset not found`);
4217
+
4218
+ // ../cli-kit/dist/private/node/session/redirect-listener.js
4219
+ import url from "url";
4220
+ import { createServer } from "http";
4221
+ var ResponseTimeoutSeconds = 10;
4222
+ var ServerStopDelaySeconds = 0.5;
4223
+ var RedirectListener = class _RedirectListener {
4224
+ static createServer(callback) {
4225
+ const app = async (request, response) => {
4226
+ const requestUrl = request.url;
4227
+ if (requestUrl?.includes("favicon")) {
4228
+ const faviconFile = await getFavicon();
4229
+ response.setHeader("Content-Type", "image/svg+xml");
4230
+ response.write(faviconFile);
4231
+ response.end();
4232
+ return {};
4233
+ } else if (requestUrl === "/style.css") {
4234
+ const stylesheetFile = await getStylesheet();
4235
+ response.setHeader("Content-Type", "text/css");
4236
+ response.write(stylesheetFile);
4237
+ response.end();
4238
+ return {};
4239
+ }
4240
+ const respond = async (contents, error, state, code) => {
4241
+ response.setHeader("Content-Type", "text/html");
4242
+ response.write(contents);
4243
+ response.end();
4244
+ callback(error, state, code);
4245
+ return {};
4246
+ };
4247
+ if (!requestUrl) {
4248
+ const file2 = await getEmptyUrlHTML();
4249
+ const err2 = new BugError(EmptyUrlString);
4250
+ return respond(file2, err2, void 0, void 0);
4251
+ }
4252
+ const queryObject = url.parse(requestUrl, true).query;
4253
+ if (queryObject.error && queryObject.error_description) {
4254
+ const file2 = await getAuthErrorHTML();
4255
+ const err2 = new AbortError(`${queryObject.error_description}`);
4256
+ return respond(file2, err2, void 0, void 0);
4257
+ }
4258
+ if (!queryObject.code) {
4259
+ const file2 = await getMissingCodeHTML();
4260
+ const err2 = new BugError(MissingCodeString);
4261
+ return respond(file2, err2, void 0, void 0);
4262
+ }
4263
+ if (!queryObject.state) {
4264
+ const file2 = await getMissingStateHTML();
4265
+ const err2 = new BugError(MissingStateString);
4266
+ return respond(file2, err2, void 0, void 0);
4267
+ }
4268
+ const file = await getSuccessHTML();
4269
+ return respond(file, void 0, `${queryObject.code}`, `${queryObject.state}`);
4270
+ };
4271
+ return createServer(app);
4272
+ }
4273
+ constructor(options2) {
4274
+ this.port = options2.port;
4275
+ this.host = options2.host;
4276
+ this.server = _RedirectListener.createServer(options2.callback);
4277
+ }
4278
+ start() {
4279
+ this.server.listen({ port: this.port, host: this.host }, () => {
4280
+ });
4281
+ }
4282
+ async stop() {
4283
+ await this.server.close();
4284
+ }
4285
+ };
4286
+ async function listenRedirect(host, port, url2) {
4287
+ const result = await new Promise((resolve, reject) => {
4288
+ const timeout = setTimeout(() => {
4289
+ const message = "\nAuto-open timed out. Open the login page: ";
4290
+ outputInfo(outputContent`${message}${outputToken.link("Log in to Shopify Partners", url2)}\n`);
4291
+ }, ResponseTimeoutSeconds * 1e3);
4292
+ const callback = (error, code, state) => {
4293
+ clearTimeout(timeout);
4294
+ setTimeout(() => {
4295
+ redirectListener.stop();
4296
+ if (error)
4297
+ reject(error);
4298
+ else
4299
+ resolve({ code, state });
4300
+ }, ServerStopDelaySeconds * 1e3);
4301
+ };
4302
+ const redirectListener = new RedirectListener({ host, port, callback });
4303
+ redirectListener.start();
4304
+ });
4305
+ return result;
4306
+ }
4307
+
3484
4308
  // ../../node_modules/.pnpm/get-port-please@3.0.1/node_modules/get-port-please/dist/index.mjs
3485
4309
  init_cjs_shims();
3486
- import { createServer } from "node:net";
4310
+ import { createServer as createServer2 } from "node:net";
3487
4311
  import { networkInterfaces } from "node:os";
3488
4312
  var unsafePorts = /* @__PURE__ */ new Set([
3489
4313
  1,
@@ -3606,7 +4430,7 @@ async function checkPort(port, host = process.env.HOST, _verbose) {
3606
4430
  }
3607
4431
  function _checkPort(port, host) {
3608
4432
  return new Promise((resolve) => {
3609
- const server = createServer();
4433
+ const server = createServer2();
3610
4434
  server.unref();
3611
4435
  server.on("error", (error) => {
3612
4436
  if (error.code === "EINVAL" || error.code === "EADDRNOTAVAIL") {
@@ -3633,10 +4457,571 @@ function getLocalHosts(additional) {
3633
4457
  return [...hosts];
3634
4458
  }
3635
4459
 
4460
+ // ../cli-kit/dist/private/node/session/authorize.js
4461
+ var import_find_process = __toESM(require_find_process2(), 1);
4462
+ async function authorize(scopes, state = randomHex(30)) {
4463
+ const port = 3456;
4464
+ const host = "127.0.0.1";
4465
+ const redirectUri = `http://${host}:${port}`;
4466
+ const fqdn = await identityFqdn();
4467
+ const identityClientId = clientId();
4468
+ await validateRedirectionPortAvailability(port);
4469
+ let url2 = `http://${fqdn}/oauth/authorize`;
4470
+ const { codeVerifier, codeChallenge } = generateRandomChallengePair();
4471
+ const params = {
4472
+ client_id: identityClientId,
4473
+ scope: scopes.join(" "),
4474
+ redirect_uri: redirectUri,
4475
+ state,
4476
+ response_type: "code",
4477
+ code_challenge_method: "S256",
4478
+ code_challenge: codeChallenge
4479
+ };
4480
+ outputInfo("\nTo run this command, log in to Shopify.");
4481
+ outputInfo("\u{1F449} Press any key to open the login page on your browser");
4482
+ await keypress();
4483
+ url2 = `${url2}?${new URLSearchParams(params).toString()}`;
4484
+ await openURL(url2);
4485
+ return runWithTimer("cmd_all_timing_prompts_ms")(async () => {
4486
+ const result = await listenRedirect(host, port, url2);
4487
+ if (result.state !== state) {
4488
+ throw new AbortError("The state received from the authentication doesn't match the one that initiated the authentication process.");
4489
+ }
4490
+ return { code: result.code, codeVerifier };
4491
+ });
4492
+ }
4493
+ function generateRandomChallengePair() {
4494
+ const codeVerifier = base64URLEncode(randomBytes(32));
4495
+ const codeChallenge = base64URLEncode(sha256(codeVerifier));
4496
+ return { codeVerifier, codeChallenge };
4497
+ }
4498
+ async function validateRedirectionPortAvailability(port) {
4499
+ const { killPortProcess } = await import("./lib-MUDJYT6A.js");
4500
+ if (await checkPort(port)) {
4501
+ return;
4502
+ }
4503
+ if (await terminateBlockingPortProcessPrompt(port, "Authentication")) {
4504
+ await killPortProcess(port);
4505
+ } else {
4506
+ throw new CancelExecution();
4507
+ }
4508
+ }
4509
+ async function terminateBlockingPortProcessPrompt(port, stepDescription) {
4510
+ const processInfo = await (0, import_find_process.default)("port", port);
4511
+ const formattedProcessName = processInfo && processInfo.length > 0 && processInfo[0]?.name ? ` (${processInfo[0].name})` : "";
4512
+ return renderConfirmationPrompt({
4513
+ message: `${stepDescription} requires a port ${port} that's unavailable because it's running another process${formattedProcessName}. Terminate that process?`,
4514
+ confirmationMessage: "Yes, terminate process in order to log in now",
4515
+ cancellationMessage: `No, cancel command and try later`
4516
+ });
4517
+ }
4518
+
4519
+ // ../cli-kit/dist/private/node/session/device-authorization.js
4520
+ init_cjs_shims();
4521
+ async function requestDeviceAuthorization(scopes) {
4522
+ const fqdn = await identityFqdn();
4523
+ const identityClientId = await clientId();
4524
+ const queryParams = { client_id: identityClientId, scope: scopes.join(" ") };
4525
+ const url2 = `https://${fqdn}/oauth/device_authorization`;
4526
+ const response = await shopifyFetch(url2, {
4527
+ method: "POST",
4528
+ headers: { "Content-type": "application/x-www-form-urlencoded" },
4529
+ body: convertRequestToParams(queryParams)
4530
+ });
4531
+ const jsonResult = await response.json();
4532
+ outputDebug(outputContent`Received device authorization code: ${outputToken.json(jsonResult)}`);
4533
+ if (!jsonResult.device_code || !jsonResult.verification_uri_complete) {
4534
+ throw new BugError("Failed to start authorization process");
4535
+ }
4536
+ outputInfo("\nTo run this command, log in to Shopify.");
4537
+ outputInfo(outputContent`User verification code: ${jsonResult.user_code}`);
4538
+ outputInfo(outputContent`👉 Open this link to start the auth process: ${outputToken.green(jsonResult.verification_uri_complete)}`);
4539
+ return {
4540
+ deviceCode: jsonResult.device_code,
4541
+ userCode: jsonResult.user_code,
4542
+ verificationUri: jsonResult.verification_uri,
4543
+ expiresIn: jsonResult.expires_in,
4544
+ verificationUriComplete: jsonResult.verification_uri_complete,
4545
+ interval: jsonResult.interval
4546
+ };
4547
+ }
4548
+ async function pollForDeviceAuthorization(code, interval = 5) {
4549
+ let currentIntervalInSeconds = interval;
4550
+ return new Promise((resolve, reject) => {
4551
+ const onPoll = async () => {
4552
+ const result = await exchangeDeviceCodeForAccessToken(code);
4553
+ if (!result.isErr())
4554
+ return resolve(result.value);
4555
+ const error = result.error ?? "unknown_failure";
4556
+ outputDebug(outputContent`Polling for device authorization... status: ${error}`);
4557
+ switch (error) {
4558
+ case "authorization_pending":
4559
+ return startPolling();
4560
+ case "slow_down":
4561
+ currentIntervalInSeconds += 5;
4562
+ return startPolling();
4563
+ case "access_denied":
4564
+ case "expired_token":
4565
+ case "unknown_failure":
4566
+ return reject(result);
4567
+ }
4568
+ };
4569
+ const startPolling = () => {
4570
+ setTimeout(onPoll, currentIntervalInSeconds * 1e3);
4571
+ };
4572
+ startPolling();
4573
+ });
4574
+ }
4575
+ function convertRequestToParams(queryParams) {
4576
+ return Object.entries(queryParams).map(([key, value]) => value && `${key}=${value}`).filter((hasValue) => Boolean(hasValue)).join("&");
4577
+ }
4578
+
4579
+ // ../cli-kit/dist/public/node/api/partners.js
4580
+ init_cjs_shims();
4581
+
4582
+ // ../cli-kit/dist/public/node/api/graphql.js
4583
+ init_cjs_shims();
4584
+
4585
+ // ../cli-kit/dist/private/node/api/graphql.js
4586
+ init_cjs_shims();
4587
+ function debugLogRequestInfo(api, query, variables, headers = {}) {
4588
+ outputDebug(outputContent`Sending ${outputToken.json(api)} GraphQL request:
4589
+ ${outputToken.raw(query.toString().trim())}
4590
+ ${variables ? `
4591
+ With variables:
4592
+ ${sanitizeVariables(variables)}
4593
+ ` : ""}
4594
+ With request headers:
4595
+ ${sanitizedHeadersOutput(headers)}
4596
+ `);
4597
+ }
4598
+ function sanitizeVariables(variables) {
4599
+ const result = { ...variables };
4600
+ if ("apiKey" in result) {
4601
+ result.apiKey = "*****";
4602
+ }
4603
+ return JSON.stringify(result, null, 2);
4604
+ }
4605
+ function errorHandler(api) {
4606
+ return (error, requestId) => {
4607
+ if (error instanceof ClientError) {
4608
+ const { status } = error.response;
4609
+ let errorMessage = stringifyMessage(outputContent`
4610
+ The ${outputToken.raw(api)} GraphQL API responded unsuccessfully with${status === 200 ? "" : ` the HTTP status ${status} and`} errors:
4611
+
4612
+ ${outputToken.json(error.response.errors)}
4613
+ `);
4614
+ if (requestId) {
4615
+ errorMessage += `
4616
+ Request ID: ${requestId}
4617
+ `;
4618
+ }
4619
+ let mappedError;
4620
+ if (status < 500) {
4621
+ mappedError = new GraphQLClientError(errorMessage, status, error.response.errors);
4622
+ } else {
4623
+ mappedError = new AbortError(errorMessage);
4624
+ }
4625
+ mappedError.stack = error.stack;
4626
+ return mappedError;
4627
+ } else {
4628
+ return error;
4629
+ }
4630
+ };
4631
+ }
4632
+
4633
+ // ../cli-kit/dist/public/node/api/graphql.js
4634
+ async function performGraphQLRequest(options2) {
4635
+ const { token, addedHeaders, queryAsString, variables, api, url: url2, responseOptions } = options2;
4636
+ const headers = {
4637
+ ...addedHeaders,
4638
+ ...buildHeaders(token)
4639
+ };
4640
+ debugLogRequestInfo(api, queryAsString, variables, headers);
4641
+ const clientOptions = { agent: await httpsAgent(), headers };
4642
+ const client = new GraphQLClient(url2, clientOptions);
4643
+ return runWithTimer("cmd_all_timing_network_ms")(async () => {
4644
+ const response = await debugLogResponseInfo({ request: client.rawRequest(queryAsString, variables), url: url2 }, responseOptions?.handleErrors === false ? void 0 : errorHandler(api));
4645
+ if (responseOptions?.onResponse) {
4646
+ responseOptions.onResponse(response);
4647
+ }
4648
+ return response.data;
4649
+ });
4650
+ }
4651
+ async function graphqlRequest(options2) {
4652
+ return performGraphQLRequest({
4653
+ ...options2,
4654
+ queryAsString: options2.query
4655
+ });
4656
+ }
4657
+ async function graphqlRequestDoc(options2) {
4658
+ return performGraphQLRequest({
4659
+ ...options2,
4660
+ queryAsString: resolveRequestDocument(options2.query).query
4661
+ });
4662
+ }
4663
+
4664
+ // ../cli-kit/dist/public/node/api/partners.js
4665
+ var import_bottleneck = __toESM(require_lib(), 1);
4666
+ var limiter = new import_bottleneck.default({
4667
+ minTime: 150,
4668
+ maxConcurrent: 10
4669
+ });
4670
+ async function setupRequest(token) {
4671
+ const api = "Partners";
4672
+ const fqdn = await partnersFqdn();
4673
+ const url2 = `https://${fqdn}/api/cli/graphql`;
4674
+ return {
4675
+ token,
4676
+ api,
4677
+ url: url2,
4678
+ responseOptions: { onResponse: handleDeprecations }
4679
+ };
4680
+ }
4681
+ async function partnersRequest(query, token, variables) {
4682
+ const opts = await setupRequest(token);
4683
+ const result = limiter.schedule(() => graphqlRequest({
4684
+ ...opts,
4685
+ query,
4686
+ variables
4687
+ }));
4688
+ return result;
4689
+ }
4690
+ async function partnersRequestDoc(query, token, variables) {
4691
+ const opts = await setupRequest(token);
4692
+ const result = limiter.schedule(() => graphqlRequestDoc({
4693
+ ...opts,
4694
+ query,
4695
+ variables
4696
+ }));
4697
+ return result;
4698
+ }
4699
+ var FunctionUploadUrlGenerateMutation = gql`
4700
+ mutation functionUploadUrlGenerateMutation {
4701
+ functionUploadUrlGenerate {
4702
+ generatedUrlDetails {
4703
+ url
4704
+ moduleId
4705
+ headers
4706
+ maxBytes
4707
+ maxSize
4708
+ }
4709
+ }
4710
+ }
4711
+ `;
4712
+ function handleDeprecations(response) {
4713
+ if (!response.extensions)
4714
+ return;
4715
+ const deprecationDates = [];
4716
+ for (const deprecation of response.extensions.deprecations) {
4717
+ if (deprecation.supportedUntilDate) {
4718
+ deprecationDates.push(new Date(deprecation.supportedUntilDate));
4719
+ }
4720
+ }
4721
+ setNextDeprecationDate(deprecationDates);
4722
+ }
4723
+
4724
+ // ../cli-kit/dist/private/node/session.js
4725
+ async function ensureAuthenticated(applications, _env, { forceRefresh = false, noPrompt = false } = {}) {
4726
+ const fqdn = await identityFqdn();
4727
+ const previousStoreFqdn = applications.adminApi?.storeFqdn;
4728
+ if (previousStoreFqdn) {
4729
+ const normalizedStoreName = await normalizeStoreFqdn(previousStoreFqdn);
4730
+ if (previousStoreFqdn === applications.adminApi?.storeFqdn) {
4731
+ applications.adminApi.storeFqdn = normalizedStoreName;
4732
+ }
4733
+ }
4734
+ const currentSession = await fetch() || {};
4735
+ const fqdnSession = currentSession[fqdn];
4736
+ const scopes = getFlattenScopes(applications);
4737
+ outputDebug(outputContent`Validating existing session against the scopes:
4738
+ ${outputToken.json(scopes)}
4739
+ For applications:
4740
+ ${outputToken.json(applications)}
4741
+ `);
4742
+ const validationResult = await validateSession(scopes, applications, fqdnSession);
4743
+ let newSession = {};
4744
+ function throwOnNoPrompt() {
4745
+ if (!noPrompt || isSpin() && firstPartyDev())
4746
+ return;
4747
+ throw new AbortError(`The currently available CLI credentials are invalid.
4748
+
4749
+ The CLI is currently unable to prompt for reauthentication.`, "Restart the CLI process you were running. If in an interactive terminal, you will be prompted to reauthenticate. If in a non-interactive terminal, ensure the correct credentials are available in the program environment.");
4750
+ }
4751
+ if (validationResult === "needs_full_auth") {
4752
+ throwOnNoPrompt();
4753
+ outputDebug(outputContent`Initiating the full authentication flow...`);
4754
+ newSession = await executeCompleteFlow(applications, fqdn);
4755
+ } else if (validationResult === "needs_refresh" || forceRefresh) {
4756
+ outputDebug(outputContent`The current session is valid but needs refresh. Refreshing...`);
4757
+ try {
4758
+ newSession = await refreshTokens(fqdnSession.identity, applications, fqdn);
4759
+ } catch (error) {
4760
+ if (error instanceof InvalidGrantError) {
4761
+ throwOnNoPrompt();
4762
+ newSession = await executeCompleteFlow(applications, fqdn);
4763
+ } else if (error instanceof InvalidRequestError) {
4764
+ await remove();
4765
+ throw new AbortError("\nError validating auth session", "We've cleared the current session, please try again");
4766
+ } else {
4767
+ throw error;
4768
+ }
4769
+ }
4770
+ }
4771
+ const completeSession = { ...currentSession, ...newSession };
4772
+ if (Object.keys(newSession).length > 0)
4773
+ await store(completeSession);
4774
+ const tokens = await tokensFor(applications, completeSession, fqdn);
4775
+ const envToken = getPartnersToken();
4776
+ if (envToken && applications.partnersApi) {
4777
+ tokens.partners = (await exchangeCustomPartnerToken(envToken)).accessToken;
4778
+ }
4779
+ if (!envToken && tokens.partners) {
4780
+ await ensureUserHasPartnerAccount(tokens.partners);
4781
+ }
4782
+ return tokens;
4783
+ }
4784
+ async function executeCompleteFlow(applications, identityFqdn2) {
4785
+ const scopes = getFlattenScopes(applications);
4786
+ const exchangeScopes = getExchangeScopes(applications);
4787
+ const store2 = applications.adminApi?.storeFqdn;
4788
+ if (firstPartyDev()) {
4789
+ outputDebug(outputContent`Authenticating as Shopify Employee...`);
4790
+ scopes.push("employee");
4791
+ }
4792
+ let identityToken;
4793
+ const identityTokenInformation = getIdentityTokenInformation();
4794
+ if (identityTokenInformation) {
4795
+ identityToken = buildIdentityTokenFromEnv(scopes, identityTokenInformation);
4796
+ } else if (useDeviceAuth()) {
4797
+ outputDebug(outputContent`Requesting device authorization code...`);
4798
+ const deviceAuth = await requestDeviceAuthorization(scopes);
4799
+ outputDebug(outputContent`Starting polling for the identity token...`);
4800
+ identityToken = await pollForDeviceAuthorization(deviceAuth.deviceCode, deviceAuth.interval);
4801
+ } else {
4802
+ outputDebug(outputContent`Authorizing through Identity's website...`);
4803
+ const code = await authorize(scopes);
4804
+ outputDebug(outputContent`Authorization code received. Exchanging it for a CLI token...`);
4805
+ identityToken = await exchangeCodeForAccessToken(code);
4806
+ }
4807
+ outputDebug(outputContent`CLI token received. Exchanging it for application tokens...`);
4808
+ const result = await exchangeAccessForApplicationTokens(identityToken, exchangeScopes, store2);
4809
+ const session = {
4810
+ [identityFqdn2]: {
4811
+ identity: identityToken,
4812
+ applications: result
4813
+ }
4814
+ };
4815
+ outputCompleted("Logged in.");
4816
+ return session;
4817
+ }
4818
+ async function ensureUserHasPartnerAccount(partnersToken) {
4819
+ if (isTruthy(process.env.USE_APP_MANAGEMENT_API))
4820
+ return;
4821
+ outputDebug(outputContent`Verifying that the user has a Partner organization`);
4822
+ if (!await hasPartnerAccount(partnersToken)) {
4823
+ outputInfo(`
4824
+ A Shopify Partners organization is needed to proceed.`);
4825
+ outputInfo(`\u{1F449} Press any key to create one`);
4826
+ await keypress();
4827
+ await openURL(`https://${await partnersFqdn()}/signup`);
4828
+ outputInfo(outputContent`👉 Press any key when you have ${outputToken.cyan("created the organization")}`);
4829
+ outputWarn(outputContent`Make sure you've confirmed your Shopify and the Partner organization from the email`);
4830
+ await keypress();
4831
+ if (!await hasPartnerAccount(partnersToken)) {
4832
+ throw new AbortError(`Couldn't find your Shopify Partners organization`, `Have you confirmed your accounts from the emails you received?`);
4833
+ }
4834
+ }
4835
+ }
4836
+ var getFirstOrganization = gql`
4837
+ {
4838
+ organizations(first: 1) {
4839
+ nodes {
4840
+ id
4841
+ }
4842
+ }
4843
+ }
4844
+ `;
4845
+ async function hasPartnerAccount(partnersToken) {
4846
+ try {
4847
+ await partnersRequest(getFirstOrganization, partnersToken);
4848
+ return true;
4849
+ } catch (error) {
4850
+ if (error instanceof RequestClientError && error.statusCode === 404) {
4851
+ return false;
4852
+ } else {
4853
+ return true;
4854
+ }
4855
+ }
4856
+ }
4857
+ async function refreshTokens(token, applications, fqdn) {
4858
+ const identityToken = await refreshAccessToken(token);
4859
+ const exchangeScopes = getExchangeScopes(applications);
4860
+ const applicationTokens = await exchangeAccessForApplicationTokens(identityToken, exchangeScopes, applications.adminApi?.storeFqdn);
4861
+ return {
4862
+ [fqdn]: {
4863
+ identity: identityToken,
4864
+ applications: applicationTokens
4865
+ }
4866
+ };
4867
+ }
4868
+ async function tokensFor(applications, session, fqdn) {
4869
+ const fqdnSession = session[fqdn];
4870
+ if (!fqdnSession) {
4871
+ throw new BugError("No session found after ensuring authenticated");
4872
+ }
4873
+ const tokens = {};
4874
+ if (applications.adminApi) {
4875
+ const appId = applicationId("admin");
4876
+ const realAppId = `${applications.adminApi.storeFqdn}-${appId}`;
4877
+ const token = fqdnSession.applications[realAppId]?.accessToken;
4878
+ if (token) {
4879
+ tokens.admin = { token, storeFqdn: applications.adminApi.storeFqdn };
4880
+ }
4881
+ }
4882
+ if (applications.partnersApi) {
4883
+ const appId = applicationId("partners");
4884
+ tokens.partners = fqdnSession.applications[appId]?.accessToken;
4885
+ }
4886
+ if (applications.storefrontRendererApi) {
4887
+ const appId = applicationId("storefront-renderer");
4888
+ tokens.storefront = fqdnSession.applications[appId]?.accessToken;
4889
+ }
4890
+ if (applications.businessPlatformApi) {
4891
+ const appId = applicationId("business-platform");
4892
+ tokens.businessPlatform = fqdnSession.applications[appId]?.accessToken;
4893
+ }
4894
+ if (applications.appManagementApi) {
4895
+ const appId = applicationId("app-management");
4896
+ tokens.appManagement = fqdnSession.applications[appId]?.accessToken;
4897
+ }
4898
+ return tokens;
4899
+ }
4900
+ function getFlattenScopes(apps) {
4901
+ const admin = apps.adminApi?.scopes || [];
4902
+ const partner = apps.partnersApi?.scopes || [];
4903
+ const storefront = apps.storefrontRendererApi?.scopes || [];
4904
+ const businessPlatform = apps.businessPlatformApi?.scopes || [];
4905
+ const appManagement = apps.appManagementApi?.scopes || [];
4906
+ const requestedScopes = [...admin, ...partner, ...storefront, ...businessPlatform, ...appManagement];
4907
+ return allDefaultScopes(requestedScopes);
4908
+ }
4909
+ function getExchangeScopes(apps) {
4910
+ const adminScope = apps.adminApi?.scopes || [];
4911
+ const partnerScope = apps.partnersApi?.scopes || [];
4912
+ const storefrontScopes = apps.storefrontRendererApi?.scopes || [];
4913
+ const businessPlatformScopes = apps.businessPlatformApi?.scopes || [];
4914
+ const appManagementScopes = apps.appManagementApi?.scopes || [];
4915
+ return {
4916
+ admin: apiScopes("admin", adminScope),
4917
+ partners: apiScopes("partners", partnerScope),
4918
+ storefront: apiScopes("storefront-renderer", storefrontScopes),
4919
+ businessPlatform: apiScopes("business-platform", businessPlatformScopes),
4920
+ appManagement: apiScopes("app-management", appManagementScopes)
4921
+ };
4922
+ }
4923
+ function buildIdentityTokenFromEnv(scopes, identityTokenInformation) {
4924
+ return {
4925
+ ...identityTokenInformation,
4926
+ expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3),
4927
+ scopes
4928
+ };
4929
+ }
4930
+
4931
+ // ../cli-kit/dist/public/node/session.js
4932
+ async function ensureAuthenticatedPartners(scopes = [], env = process.env, options2 = {}) {
4933
+ outputDebug(outputContent`Ensuring that the user is authenticated with the Partners API with the following scopes:
4934
+ ${outputToken.json(scopes)}
4935
+ `);
4936
+ const envToken = getPartnersToken();
4937
+ if (envToken) {
4938
+ return (await exchangeCustomPartnerToken(envToken)).accessToken;
4939
+ }
4940
+ const tokens = await ensureAuthenticated({ partnersApi: { scopes } }, env, options2);
4941
+ if (!tokens.partners) {
4942
+ throw new BugError("No partners token found after ensuring authenticated");
4943
+ }
4944
+ return tokens.partners;
4945
+ }
4946
+ async function ensureAuthenticatedAppManagement(scopes = [], env = process.env, options2 = {}) {
4947
+ outputDebug(outputContent`Ensuring that the user is authenticated with the App Management API with the following scopes:
4948
+ ${outputToken.json(scopes)}
4949
+ `);
4950
+ const tokens = await ensureAuthenticated({ appManagementApi: { scopes } }, env, options2);
4951
+ if (!tokens) {
4952
+ throw new BugError("No App Management token found after ensuring authenticated");
4953
+ }
4954
+ return tokens.appManagement;
4955
+ }
4956
+ async function ensureAuthenticatedStorefront(scopes = [], password = void 0, forceRefresh = false) {
4957
+ if (password)
4958
+ return password;
4959
+ outputDebug(outputContent`Ensuring that the user is authenticated with the Storefront API with the following scopes:
4960
+ ${outputToken.json(scopes)}
4961
+ `);
4962
+ const tokens = await ensureAuthenticated({ storefrontRendererApi: { scopes } }, process.env, { forceRefresh });
4963
+ if (!tokens.storefront) {
4964
+ throw new BugError("No storefront token found after ensuring authenticated");
4965
+ }
4966
+ return tokens.storefront;
4967
+ }
4968
+ async function ensureAuthenticatedAdmin(store2, scopes = [], forceRefresh = false, options2 = {}) {
4969
+ outputDebug(outputContent`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${outputToken.raw(store2)}:
4970
+ ${outputToken.json(scopes)}
4971
+ `);
4972
+ const tokens = await ensureAuthenticated({ adminApi: { scopes, storeFqdn: store2 } }, process.env, {
4973
+ forceRefresh,
4974
+ ...options2
4975
+ });
4976
+ if (!tokens.admin) {
4977
+ throw new BugError("No admin token found after ensuring authenticated");
4978
+ }
4979
+ return tokens.admin;
4980
+ }
4981
+ async function ensureAuthenticatedThemes(store2, password, scopes = [], forceRefresh = false) {
4982
+ outputDebug(outputContent`Ensuring that the user is authenticated with the Theme API with the following scopes:
4983
+ ${outputToken.json(scopes)}
4984
+ `);
4985
+ if (password)
4986
+ return { token: password, storeFqdn: await normalizeStoreFqdn(store2) };
4987
+ return ensureAuthenticatedAdmin(store2, scopes, forceRefresh);
4988
+ }
4989
+ async function ensureAuthenticatedBusinessPlatform(scopes = []) {
4990
+ outputDebug(outputContent`Ensuring that the user is authenticated with the Business Platform API with the following scopes:
4991
+ ${outputToken.json(scopes)}
4992
+ `);
4993
+ const tokens = await ensureAuthenticated({ businessPlatformApi: { scopes } }, process.env);
4994
+ if (!tokens.businessPlatform) {
4995
+ throw new BugError("No business-platform token found after ensuring authenticated");
4996
+ }
4997
+ return tokens.businessPlatform;
4998
+ }
4999
+ function logout() {
5000
+ return remove();
5001
+ }
5002
+
3636
5003
  export {
5004
+ partnersFqdn,
5005
+ appManagementFqdn,
5006
+ businessPlatformFqdn,
5007
+ normalizeStoreFqdn,
5008
+ ok,
5009
+ err,
3637
5010
  getRandomPort,
3638
5011
  checkPort,
3639
- require_find_process2 as require_find_process,
3640
- require_lib
5012
+ graphqlRequest,
5013
+ graphqlRequestDoc,
5014
+ require_lib,
5015
+ partnersRequest,
5016
+ partnersRequestDoc,
5017
+ FunctionUploadUrlGenerateMutation,
5018
+ handleDeprecations,
5019
+ ensureAuthenticatedPartners,
5020
+ ensureAuthenticatedAppManagement,
5021
+ ensureAuthenticatedStorefront,
5022
+ ensureAuthenticatedAdmin,
5023
+ ensureAuthenticatedThemes,
5024
+ ensureAuthenticatedBusinessPlatform,
5025
+ logout
3641
5026
  };
3642
- //# sourceMappingURL=chunk-EQPYUHNM.js.map
5027
+ //# sourceMappingURL=chunk-WIG6CPGR.js.map