@shopify/create-app 3.75.4 → 3.76.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.
@@ -4,13 +4,12 @@ import {
4
4
  formDataToBlob
5
5
  } from "./chunk-25IMI7TH.js";
6
6
  import {
7
- cacheRetrieveOrRepopulate,
8
7
  getPackageManager,
9
8
  getSession,
10
9
  packageManagerFromUserAgent,
11
10
  removeSession,
12
11
  setSession
13
- } from "./chunk-VCHNXIMX.js";
12
+ } from "./chunk-4IZOAUIJ.js";
14
13
  import {
15
14
  AbortError,
16
15
  BugError,
@@ -22,7 +21,6 @@ import {
22
21
  ciPlatform,
23
22
  cloudEnvironment,
24
23
  currentProcessIsGlobal,
25
- execa,
26
24
  firstPartyDev,
27
25
  getIdentityTokenInformation,
28
26
  getPartnersToken,
@@ -41,13 +39,13 @@ import {
41
39
  outputDebug,
42
40
  outputInfo,
43
41
  outputToken,
42
+ platformAndArch,
44
43
  runWithTimer,
45
44
  serviceEnvironment,
46
45
  sessionConstants,
47
46
  spinFqdn,
48
- themeKitAccessDomain,
49
47
  themeToken
50
- } from "./chunk-7GEGPVQ4.js";
48
+ } from "./chunk-4HFDUDDU.js";
51
49
  import {
52
50
  cwd
53
51
  } from "./chunk-ZUCWDIGE.js";
@@ -58,57 +56,6 @@ import {
58
56
  init_cjs_shims
59
57
  } from "./chunk-PKR7KJ6P.js";
60
58
 
61
- // ../../node_modules/.pnpm/network-interfaces@1.1.0/node_modules/network-interfaces/index.js
62
- var require_network_interfaces = __commonJS({
63
- "../../node_modules/.pnpm/network-interfaces@1.1.0/node_modules/network-interfaces/index.js"(exports) {
64
- "use strict";
65
- init_cjs_shims();
66
- var os2 = __require("os");
67
- function isValid2(address, options) {
68
- return !(typeof options.internal == "boolean" && address.internal !== options.internal || options.ipVersion === 4 && address.family !== "IPv4" || options.ipVersion === 6 && address.family !== "IPv6");
69
- }
70
- function findAddresses(interfaceName, options = {}) {
71
- let addresses = os2.networkInterfaces()[interfaceName];
72
- if (!addresses)
73
- throw new Error(`Network interface "${interfaceName}" does not exist`);
74
- let result = [];
75
- for (let address of addresses)
76
- isValid2(address, options) && result.push(address);
77
- return result;
78
- }
79
- exports.toIp = function(interfaceName, options) {
80
- let addresses = findAddresses(interfaceName, options);
81
- if (addresses.length === 0)
82
- throw new Error(`No suitable IP address found on interface "${interfaceName}"`);
83
- return addresses[0].address;
84
- };
85
- exports.toIps = function(interfaceName, options) {
86
- return findAddresses(interfaceName, options).map((address) => address.address);
87
- };
88
- exports.fromIp = function(ip, options) {
89
- let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces);
90
- for (let interfaceName of interfaceNames)
91
- for (let address of interfaces[interfaceName])
92
- if (address.address === ip && isValid2(address, options))
93
- return interfaceName;
94
- throw new Error(`No suitable interfaces were found with IP address "${ip}"`);
95
- };
96
- exports.getInterface = function(options) {
97
- let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces);
98
- for (let interfaceName of interfaceNames)
99
- if (findAddresses(interfaceName, options).length > 0)
100
- return interfaceName;
101
- throw new Error("No suitable interfaces were found");
102
- };
103
- exports.getInterfaces = function(options) {
104
- let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces), result = [];
105
- for (let interfaceName of interfaceNames)
106
- findAddresses(interfaceName, options).length > 0 && result.push(interfaceName);
107
- return result;
108
- };
109
- }
110
- });
111
-
112
59
  // ../../node_modules/.pnpm/graphql@16.10.0/node_modules/graphql/version.js
113
60
  var require_version = __commonJS({
114
61
  "../../node_modules/.pnpm/graphql@16.10.0/node_modules/graphql/version.js"(exports) {
@@ -15998,8 +15945,8 @@ var require_url_state_machine = __commonJS({
15998
15945
  let usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride);
15999
15946
  return usm.failure ? null : usm.url;
16000
15947
  };
16001
- module.exports.setTheUsername = function(url, username2) {
16002
- url.username = utf8PercentEncodeString(username2, isUserinfoPercentEncode);
15948
+ module.exports.setTheUsername = function(url, username) {
15949
+ url.username = utf8PercentEncodeString(username, isUserinfoPercentEncode);
16003
15950
  };
16004
15951
  module.exports.setThePassword = function(url, password) {
16005
15952
  url.password = utf8PercentEncodeString(password, isUserinfoPercentEncode);
@@ -17827,6 +17774,57 @@ var require_node_ponyfill = __commonJS({
17827
17774
  }
17828
17775
  });
17829
17776
 
17777
+ // ../../node_modules/.pnpm/network-interfaces@1.1.0/node_modules/network-interfaces/index.js
17778
+ var require_network_interfaces = __commonJS({
17779
+ "../../node_modules/.pnpm/network-interfaces@1.1.0/node_modules/network-interfaces/index.js"(exports) {
17780
+ "use strict";
17781
+ init_cjs_shims();
17782
+ var os2 = __require("os");
17783
+ function isValid2(address, options) {
17784
+ return !(typeof options.internal == "boolean" && address.internal !== options.internal || options.ipVersion === 4 && address.family !== "IPv4" || options.ipVersion === 6 && address.family !== "IPv6");
17785
+ }
17786
+ function findAddresses(interfaceName, options = {}) {
17787
+ let addresses = os2.networkInterfaces()[interfaceName];
17788
+ if (!addresses)
17789
+ throw new Error(`Network interface "${interfaceName}" does not exist`);
17790
+ let result = [];
17791
+ for (let address of addresses)
17792
+ isValid2(address, options) && result.push(address);
17793
+ return result;
17794
+ }
17795
+ exports.toIp = function(interfaceName, options) {
17796
+ let addresses = findAddresses(interfaceName, options);
17797
+ if (addresses.length === 0)
17798
+ throw new Error(`No suitable IP address found on interface "${interfaceName}"`);
17799
+ return addresses[0].address;
17800
+ };
17801
+ exports.toIps = function(interfaceName, options) {
17802
+ return findAddresses(interfaceName, options).map((address) => address.address);
17803
+ };
17804
+ exports.fromIp = function(ip, options) {
17805
+ let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces);
17806
+ for (let interfaceName of interfaceNames)
17807
+ for (let address of interfaces[interfaceName])
17808
+ if (address.address === ip && isValid2(address, options))
17809
+ return interfaceName;
17810
+ throw new Error(`No suitable interfaces were found with IP address "${ip}"`);
17811
+ };
17812
+ exports.getInterface = function(options) {
17813
+ let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces);
17814
+ for (let interfaceName of interfaceNames)
17815
+ if (findAddresses(interfaceName, options).length > 0)
17816
+ return interfaceName;
17817
+ throw new Error("No suitable interfaces were found");
17818
+ };
17819
+ exports.getInterfaces = function(options) {
17820
+ let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces), result = [];
17821
+ for (let interfaceName of interfaceNames)
17822
+ findAddresses(interfaceName, options).length > 0 && result.push(interfaceName);
17823
+ return result;
17824
+ };
17825
+ }
17826
+ });
17827
+
17830
17828
  // ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
17831
17829
  var require_delayed_stream = __commonJS({
17832
17830
  "../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js"(exports, module) {
@@ -26949,7 +26947,7 @@ var require_form_data = __commonJS({
26949
26947
 
26950
26948
  // ../cli-kit/dist/public/common/version.js
26951
26949
  init_cjs_shims();
26952
- var CLI_KIT_VERSION = "3.75.4";
26950
+ var CLI_KIT_VERSION = "3.76.0";
26953
26951
 
26954
26952
  // ../cli-kit/dist/private/node/analytics.js
26955
26953
  init_cjs_shims();
@@ -29963,252 +29961,78 @@ function validateCachedIdentityTokenStructure(identityToken) {
29963
29961
  return IdentityTokenSchema.safeParse(identityToken).success;
29964
29962
  }
29965
29963
 
29966
- // ../cli-kit/dist/private/node/session/identity-token-validation.js
29964
+ // ../cli-kit/dist/private/node/session/validate.js
29965
+ function validateScopes(requestedScopes, identity) {
29966
+ let currentScopes = identity.scopes;
29967
+ return firstPartyDev() !== currentScopes.includes("employee") ? !1 : requestedScopes.every((scope) => currentScopes.includes(scope));
29968
+ }
29969
+ async function validateSession(scopes, applications, session) {
29970
+ if (!session || !validateScopes(scopes, session.identity))
29971
+ return "needs_full_auth";
29972
+ let tokensAreExpired = isTokenExpired(session.identity);
29973
+ if (applications.partnersApi) {
29974
+ let appId = applicationId("partners"), token = session.applications[appId];
29975
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
29976
+ }
29977
+ if (applications.appManagementApi) {
29978
+ let appId = applicationId("app-management"), token = session.applications[appId];
29979
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
29980
+ }
29981
+ if (applications.storefrontRendererApi) {
29982
+ let appId = applicationId("storefront-renderer"), token = session.applications[appId];
29983
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
29984
+ }
29985
+ if (applications.adminApi) {
29986
+ let appId = applicationId("admin"), realAppId = `${applications.adminApi.storeFqdn}-${appId}`, token = session.applications[realAppId];
29987
+ tokensAreExpired = tokensAreExpired || isTokenExpired(token);
29988
+ }
29989
+ return outputDebug(`- Token validation -> It's expired: ${tokensAreExpired}`), validateCachedIdentityTokenStructure(session.identity) ? tokensAreExpired ? "needs_refresh" : "ok" : "needs_full_auth";
29990
+ }
29991
+ function isTokenExpired(token) {
29992
+ return token ? token.expiresAt < expireThreshold() : !0;
29993
+ }
29994
+ function expireThreshold() {
29995
+ return new Date(Date.now() + sessionConstants.expirationTimeMarginInMinutes * 60 * 1e3);
29996
+ }
29997
+
29998
+ // ../cli-kit/dist/private/node/session/scopes.js
29967
29999
  init_cjs_shims();
29968
30000
 
29969
- // ../cli-kit/dist/public/node/context/fqdn.js
30001
+ // ../cli-kit/dist/private/node/api.js
29970
30002
  init_cjs_shims();
29971
30003
 
29972
- // ../cli-kit/dist/public/node/vendor/dev_server/DevServer.js
30004
+ // ../cli-kit/dist/private/node/api/headers.js
29973
30005
  init_cjs_shims();
29974
- var ni = __toESM(require_network_interfaces(), 1);
29975
- import fs from "fs";
29976
- import * as os from "os";
29977
- import { execSync } from "child_process";
29978
- var DevServerUtils = class _DevServerUtils {
29979
- static assertConnectable(name, addr, port) {
29980
- try {
29981
- execSync(`nc -z -v -w 1 ${addr} ${port}`, {
29982
- timeout: _DevServerUtils.CONNECT_TIMEOUT,
29983
- stdio: "ignore"
29984
- });
29985
- } catch {
29986
- throw new Error(`NET FAILED DevServer for '${name}' is not running on ${port} / ${addr}: \`dev up ${name}\` to start it.`);
29987
- }
29988
- }
29989
- static inferenceModeAndProjectIsEdition2016(name) {
29990
- try {
29991
- fs.accessSync(_DevServerUtils.INFERENCE_MODE_SENTINEL);
29992
- try {
29993
- return fs.accessSync(`/opt/nginx/etc/manifest/${name}/current/edition-2024`), !1;
29994
- } catch {
29995
- return !0;
29996
- }
29997
- } catch {
29998
- return !1;
29999
- }
30000
- }
30001
- static getIpFromHosts(hostname) {
30002
- try {
30003
- let lines = fs.readFileSync(_DevServerUtils.HOSTS_FILE, "utf8").split(/\r?\n/);
30004
- for (let line of lines) {
30005
- let matches = /^\s*?([^#]+?)\s+([^#]+?)$/.exec(line);
30006
- if (matches && matches.length === 3 && matches[2] === hostname)
30007
- return matches[1];
30008
- }
30009
- } catch (error) {
30010
- console.error("Error reading hosts file:", error);
30011
- }
30012
- throw new Error(`No IP found for hostname: ${hostname}`);
30013
- }
30014
- static getAddrPort2024(name) {
30015
- try {
30016
- let backendIp = _DevServerUtils.resolveBackendHost(name), interfaceName = ni.fromIp(backendIp, {
30017
- internal: !0,
30018
- ipVersion: 4
30019
- });
30020
- return [backendIp, _DevServerUtils.BACKEND_PORT];
30021
- } catch {
30022
- throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30023
- }
30024
- }
30025
- static getAddrPort2016(name) {
30026
- try {
30027
- let portContent = fs.readFileSync(`${os.homedir()}/.local/run/services/${name}/server/port`, "utf-8");
30028
- return ["localhost", parseInt(portContent, 10)];
30029
- } catch {
30030
- throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30031
- }
30006
+ import https from "https";
30007
+ var RequestClientError = class extends import_ts_error.ExtendableError {
30008
+ constructor(message, statusCode) {
30009
+ super(message), this.statusCode = statusCode;
30032
30010
  }
30033
- static resolveBackendHost(name) {
30034
- let host;
30035
- try {
30036
- host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);
30037
- } catch {
30038
- host = `${name}.root.shopify.dev.internal`;
30039
- }
30040
- try {
30041
- return _DevServerUtils.getIpFromHosts(host);
30042
- } catch {
30043
- return host;
30044
- }
30011
+ }, GraphQLClientError = class extends RequestClientError {
30012
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30013
+ constructor(message, statusCode, errors) {
30014
+ super(message, statusCode), this.errors = errors, this.stack = void 0;
30045
30015
  }
30046
30016
  };
30047
- DevServerUtils.INFERENCE_MODE_SENTINEL = "/opt/dev/misc/dev-server-inference-mode";
30048
- DevServerUtils.BACKEND_PORT = 8080;
30049
- DevServerUtils.CONNECT_TIMEOUT = 100;
30050
- DevServerUtils.HOSTS_FILE = "/etc/hosts";
30051
- var DevServer = class {
30052
- constructor(name) {
30053
- if (!process.env.SPIN && !process.env.USING_DEV)
30054
- throw new Error("DevServer is not supported in this environment");
30055
- if (name === "shopify")
30056
- throw new Error("Use DevServer.core for the 'shopify' project");
30057
- this.name = name;
30058
- }
30059
- url({ nonstandardHostPrefix } = {}) {
30060
- return `https://${this.host({ nonstandardHostPrefix })}`;
30061
- }
30062
- host({ nonstandardHostPrefix } = {}) {
30063
- let prefix = nonstandardHostPrefix || this.name;
30064
- if (process.env.SPIN === "1") {
30065
- let services = fs.readdirSync("/run/ports2").filter((file) => file.endsWith(`--${this.name}`));
30066
- if (services.length === 0)
30067
- throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
30068
- let match = new RegExp(`^(.+)${this.name}$`).exec(services[0]), organization = match ? match[1] : "";
30069
- return `${organization !== "shopify--" ? `${organization}` : ""}${this.name}.${process.env.SPIN_FQDN}`;
30070
- } else return DevServerUtils.inferenceModeAndProjectIsEdition2016(this.name) ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.shop.dev`);
30071
- }
30072
- assertRunningLocally2024() {
30073
- let [addr, port] = DevServerUtils.getAddrPort2024(this.name);
30074
- DevServerUtils.assertConnectable(this.name, addr, port);
30075
- }
30076
- assertRunningLocally2016() {
30077
- let [addr, port] = DevServerUtils.getAddrPort2016(this.name);
30078
- DevServerUtils.assertConnectable(this.name, addr, port);
30079
- }
30080
- }, DevServerCore = class {
30081
- constructor() {
30082
- this.name = "shopify";
30083
- }
30084
- url(prefix) {
30085
- return `https://${this.host(prefix)}`;
30086
- }
30087
- host(prefix) {
30088
- if (process.env.SPIN === "1") {
30089
- if (!fs.readdirSync("/run/ports2").find((file) => file.endsWith(`--${this.name}`)))
30090
- throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
30091
- return `${prefix}.${this.name}.${process.env.SPIN_FQDN}`;
30092
- } else return DevServerUtils.inferenceModeAndProjectIsEdition2016("shopify") ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.my.shop.dev`);
30093
- }
30094
- assertRunningLocally2024() {
30095
- let [addr, port] = DevServerUtils.getAddrPort2024("shopify");
30096
- DevServerUtils.assertConnectable("shopify", addr, port);
30097
- }
30098
- assertRunningLocally2016() {
30099
- let [addr, port] = DevServerUtils.getAddrPort2016("shopify");
30100
- DevServerUtils.assertConnectable("shopify", addr, port);
30101
- }
30102
- };
30103
-
30104
- // ../cli-kit/dist/public/node/context/fqdn.js
30105
- var CouldntObtainPartnersSpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment."), CouldntObtainIdentitySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment."), CouldntObtainShopifySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment."), NotProvidedStoreFQDNError = new AbortError("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
30106
- async function partnersFqdn() {
30107
- if (blockPartnersAccess())
30108
- throw new BugError("Partners API is blocked by the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable.");
30109
- let environment = serviceEnvironment(), productionFqdn = "partners.shopify.com";
30110
- switch (environment) {
30111
- case "local":
30112
- return new DevServer("partners").host();
30113
- case "spin":
30114
- return `partners.${await spinFqdn()}`;
30115
- default:
30116
- return productionFqdn;
30117
- }
30118
- }
30119
- async function appManagementFqdn() {
30120
- let environment = serviceEnvironment(), productionFqdn = "app.shopify.com";
30121
- switch (environment) {
30122
- case "local":
30123
- return new DevServerCore().host("app");
30124
- case "spin":
30125
- return `app.shopify.${await spinFqdn()}`;
30126
- default:
30127
- return productionFqdn;
30128
- }
30129
- }
30130
- async function developerDashboardFqdn() {
30131
- let environment = serviceEnvironment(), productionFqdn = "dev.shopify.com";
30132
- switch (environment) {
30133
- case "local":
30134
- return new DevServerCore().host("dev");
30135
- case "spin":
30136
- return `dev.shopify.${await spinFqdn()}`;
30137
- default:
30138
- return productionFqdn;
30139
- }
30140
- }
30141
- async function businessPlatformFqdn() {
30142
- let environment = serviceEnvironment(), productionFqdn = "destinations.shopifysvc.com";
30143
- switch (environment) {
30144
- case "local":
30145
- return new DevServer("business-platform").host();
30146
- case "spin":
30147
- return `business-platform.${await spinFqdn()}`;
30148
- default:
30149
- return productionFqdn;
30150
- }
30151
- }
30152
- async function identityFqdn() {
30153
- let environment = serviceEnvironment(), productionFqdn = "accounts.shopify.com";
30154
- switch (environment) {
30155
- case "local":
30156
- return new DevServer("identity").host();
30157
- case "spin":
30158
- return `identity.${await spinFqdn()}`;
30159
- default:
30160
- return productionFqdn;
30161
- }
30162
- }
30163
- async function normalizeStoreFqdn(store2) {
30164
- let storeFqdn = store2.replace(/^https?:\/\//, "").replace(/\/$/, ""), addDomain = async (storeFqdn2) => {
30165
- switch (serviceEnvironment()) {
30166
- case "local":
30167
- return new DevServerCore().host(storeFqdn2);
30168
- case "spin":
30169
- return `${storeFqdn2}.shopify.${await spinFqdn()}`;
30170
- default:
30171
- return `${storeFqdn2}.myshopify.com`;
30172
- }
30173
- };
30174
- return ((storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev") || storeFqdn2.includes("shopify.io") || storeFqdn2.includes(".shop.dev"))(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
30175
- }
30176
-
30177
- // ../cli-kit/dist/public/node/http.js
30178
- init_cjs_shims();
30179
-
30180
- // ../cli-kit/dist/private/node/api/headers.js
30181
- init_cjs_shims();
30182
- import https from "https";
30183
- var RequestClientError = class extends import_ts_error.ExtendableError {
30184
- constructor(message, statusCode) {
30185
- super(message), this.statusCode = statusCode;
30186
- }
30187
- }, GraphQLClientError = class extends RequestClientError {
30188
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30189
- constructor(message, statusCode, errors) {
30190
- super(message, statusCode), this.errors = errors, this.stack = void 0;
30191
- }
30192
- };
30193
- function sanitizedHeadersOutput(headers) {
30194
- let sanitized = {}, keywords = ["token", "authorization", "subject_token"];
30195
- return Object.keys(headers).forEach((header) => {
30196
- keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === void 0 && (sanitized[header] = headers[header]);
30197
- }), Object.keys(sanitized).map((header) => ` - ${header}: ${sanitized[header]}`).join(`
30198
- `);
30199
- }
30200
- function buildHeaders(token) {
30201
- let headers = {
30202
- "User-Agent": `Shopify CLI; v=${CLI_KIT_VERSION}`,
30203
- "Keep-Alive": "timeout=30",
30204
- // 'Sec-CH-UA': secCHUA, This header requires the Git sha.
30205
- "Sec-CH-UA-PLATFORM": process.platform,
30206
- "Content-Type": "application/json",
30207
- ...firstPartyDev() && { "X-Shopify-Cli-Employee": "1" }
30208
- };
30209
- if (token) {
30210
- let authString = token.match(/^shp(at|ua|ca|tka)/) ? token : `Bearer ${token}`;
30211
- headers.authorization = authString, headers["X-Shopify-Access-Token"] = authString;
30017
+ function sanitizedHeadersOutput(headers) {
30018
+ let sanitized = {}, keywords = ["token", "authorization", "subject_token"];
30019
+ return Object.keys(headers).forEach((header) => {
30020
+ keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === void 0 && (sanitized[header] = headers[header]);
30021
+ }), Object.keys(sanitized).map((header) => ` - ${header}: ${sanitized[header]}`).join(`
30022
+ `);
30023
+ }
30024
+ function buildHeaders(token) {
30025
+ let headers = {
30026
+ "User-Agent": `Shopify CLI; v=${CLI_KIT_VERSION}`,
30027
+ "Keep-Alive": "timeout=30",
30028
+ // 'Sec-CH-UA': secCHUA, This header requires the Git sha.
30029
+ "Sec-CH-UA-PLATFORM": process.platform,
30030
+ "Content-Type": "application/json",
30031
+ ...firstPartyDev() && { "X-Shopify-Cli-Employee": "1" }
30032
+ };
30033
+ if (token) {
30034
+ let authString = token.match(/^shp(at|ua|ca|tka)/) ? token : `Bearer ${token}`;
30035
+ headers.authorization = authString, headers["X-Shopify-Access-Token"] = authString;
30212
30036
  }
30213
30037
  return headers;
30214
30038
  }
@@ -30229,9 +30053,6 @@ function sanitizeURL(url) {
30229
30053
  return parsedUrl.searchParams.has("subject_token") && parsedUrl.searchParams.set("subject_token", "****"), parsedUrl.searchParams.has("token") && parsedUrl.searchParams.set("token", "****"), parsedUrl.toString();
30230
30054
  }
30231
30055
 
30232
- // ../cli-kit/dist/private/node/api.js
30233
- init_cjs_shims();
30234
-
30235
30056
  // ../../node_modules/.pnpm/graphql-request@6.1.0_graphql@16.10.0/node_modules/graphql-request/build/esm/index.js
30236
30057
  init_cjs_shims();
30237
30058
 
@@ -30659,70 +30480,330 @@ async function makeVerboseRequest({ request, url }) {
30659
30480
  requestId: responseHeaders["x-request-id"]
30660
30481
  };
30661
30482
  }
30662
- let t1 = performance.now();
30663
- return duration = Math.round(t1 - t0), {
30664
- status: "ok",
30665
- response,
30666
- duration,
30667
- sanitizedHeaders: sanitizedHeadersOutput(responseHeaders),
30668
- sanitizedUrl,
30669
- requestId: responseHeaders["x-request-id"]
30670
- };
30483
+ let t1 = performance.now();
30484
+ return duration = Math.round(t1 - t0), {
30485
+ status: "ok",
30486
+ response,
30487
+ duration,
30488
+ sanitizedHeaders: sanitizedHeadersOutput(responseHeaders),
30489
+ sanitizedUrl,
30490
+ requestId: responseHeaders["x-request-id"]
30491
+ };
30492
+ }
30493
+ function errorsIncludeStatus429(error) {
30494
+ return error.response.status === 429 ? !0 : typeof error.response.errors == "string" ? !1 : error.response.errors?.some((error2) => error2.extensions?.code === "429") ?? !1;
30495
+ }
30496
+ async function simpleRequestWithDebugLog({ request, url }, errorHandler) {
30497
+ let result = await makeVerboseRequest({ request, url });
30498
+ switch (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
30499
+ With response headers:
30500
+ ${result.sanitizedHeaders}
30501
+ `), result.status) {
30502
+ case "ok":
30503
+ return result.response;
30504
+ case "client-error":
30505
+ throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30506
+ case "unknown-error":
30507
+ throw errorHandler ? errorHandler(result.error, result.requestId) : result.error;
30508
+ case "can-retry":
30509
+ throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30510
+ case "unauthorized":
30511
+ throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30512
+ }
30513
+ }
30514
+ async function retryAwareRequest({ request, url }, errorHandler, unauthorizedHandler, retryOptions = {
30515
+ scheduleDelay: setTimeout
30516
+ }) {
30517
+ let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest({ request, url });
30518
+ for (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
30519
+ With response headers:
30520
+ ${result.sanitizedHeaders}
30521
+ `); ; ) {
30522
+ if (result.status === "ok")
30523
+ return retriesUsed > 0 && outputDebug(`Request to ${result.sanitizedUrl} succeeded after ${retriesUsed} retries`), result.response;
30524
+ if (result.status === "client-error")
30525
+ throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30526
+ if (result.status === "unknown-error")
30527
+ throw errorHandler ? errorHandler(result.error, result.requestId) : result.error;
30528
+ if (result.status === "unauthorized")
30529
+ if (unauthorizedHandler)
30530
+ await unauthorizedHandler();
30531
+ else
30532
+ throw result.clientError;
30533
+ if (limitRetriesTo <= retriesUsed)
30534
+ throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30535
+ retriesUsed += 1;
30536
+ let retryDelayMs = result.delayMs ?? retryOptions.defaultDelayMs ?? DEFAULT_RETRY_DELAY_MS;
30537
+ outputDebug(`Scheduling retry request #${retriesUsed} to ${result.sanitizedUrl} in ${retryDelayMs} ms`), result = await new Promise((resolve) => {
30538
+ retryOptions.scheduleDelay(() => {
30539
+ resolve(makeVerboseRequest({ request, url }));
30540
+ }, retryDelayMs);
30541
+ });
30542
+ }
30543
+ }
30544
+
30545
+ // ../cli-kit/dist/private/node/session/scopes.js
30546
+ function allDefaultScopes(extraScopes = []) {
30547
+ let scopes = allAPIs.map((api) => defaultApiScopes(api)).flat();
30548
+ return scopes = ["openid", ...scopes, ...extraScopes].map(scopeTransform), Array.from(new Set(scopes));
30549
+ }
30550
+ function apiScopes(api, extraScopes = []) {
30551
+ let scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform);
30552
+ return Array.from(new Set(scopes));
30553
+ }
30554
+ function defaultApiScopes(api) {
30555
+ switch (api) {
30556
+ case "admin":
30557
+ return ["graphql", "themes", "collaborator"];
30558
+ case "storefront-renderer":
30559
+ return ["devtools"];
30560
+ case "partners":
30561
+ return ["cli"];
30562
+ case "business-platform":
30563
+ return ["destinations", "store-management"];
30564
+ case "app-management":
30565
+ return ["app-management"];
30566
+ default:
30567
+ throw new BugError(`Unknown API: ${api}`);
30568
+ }
30569
+ }
30570
+ function scopeTransform(scope) {
30571
+ switch (scope) {
30572
+ case "graphql":
30573
+ return "https://api.shopify.com/auth/shop.admin.graphql";
30574
+ case "themes":
30575
+ return "https://api.shopify.com/auth/shop.admin.themes";
30576
+ case "collaborator":
30577
+ return "https://api.shopify.com/auth/partners.collaborator-relationships.readonly";
30578
+ case "cli":
30579
+ return "https://api.shopify.com/auth/partners.app.cli.access";
30580
+ case "devtools":
30581
+ return "https://api.shopify.com/auth/shop.storefront-renderer.devtools";
30582
+ case "destinations":
30583
+ return "https://api.shopify.com/auth/destinations.readonly";
30584
+ case "store-management":
30585
+ return "https://api.shopify.com/auth/organization.store-management";
30586
+ case "app-management":
30587
+ return "https://api.shopify.com/auth/organization.apps.manage";
30588
+ default:
30589
+ return scope;
30590
+ }
30591
+ }
30592
+
30593
+ // ../cli-kit/dist/private/node/session/exchange.js
30594
+ init_cjs_shims();
30595
+
30596
+ // ../cli-kit/dist/public/node/context/fqdn.js
30597
+ init_cjs_shims();
30598
+
30599
+ // ../cli-kit/dist/public/node/vendor/dev_server/DevServer.js
30600
+ init_cjs_shims();
30601
+ var ni = __toESM(require_network_interfaces(), 1);
30602
+ import fs from "fs";
30603
+ import * as os from "os";
30604
+ import { execSync } from "child_process";
30605
+ var DevServerUtils = class _DevServerUtils {
30606
+ static assertConnectable(name, addr, port) {
30607
+ try {
30608
+ execSync(`nc -z -v -w 1 ${addr} ${port}`, {
30609
+ timeout: _DevServerUtils.CONNECT_TIMEOUT,
30610
+ stdio: "ignore"
30611
+ });
30612
+ } catch {
30613
+ throw new Error(`NET FAILED DevServer for '${name}' is not running on ${port} / ${addr}: \`dev up ${name}\` to start it.`);
30614
+ }
30615
+ }
30616
+ static inferenceModeAndProjectIsEdition2016(name) {
30617
+ try {
30618
+ fs.accessSync(_DevServerUtils.INFERENCE_MODE_SENTINEL);
30619
+ try {
30620
+ return fs.accessSync(`/opt/nginx/etc/manifest/${name}/current/edition-2024`), !1;
30621
+ } catch {
30622
+ return !0;
30623
+ }
30624
+ } catch {
30625
+ return !1;
30626
+ }
30627
+ }
30628
+ static getIpFromHosts(hostname) {
30629
+ try {
30630
+ let lines = fs.readFileSync(_DevServerUtils.HOSTS_FILE, "utf8").split(/\r?\n/);
30631
+ for (let line of lines) {
30632
+ let matches = /^\s*?([^#]+?)\s+([^#]+?)$/.exec(line);
30633
+ if (matches && matches.length === 3 && matches[2] === hostname)
30634
+ return matches[1];
30635
+ }
30636
+ } catch (error) {
30637
+ console.error("Error reading hosts file:", error);
30638
+ }
30639
+ throw new Error(`No IP found for hostname: ${hostname}`);
30640
+ }
30641
+ static getAddrPort2024(name) {
30642
+ try {
30643
+ let backendIp = _DevServerUtils.resolveBackendHost(name), interfaceName = ni.fromIp(backendIp, {
30644
+ internal: !0,
30645
+ ipVersion: 4
30646
+ });
30647
+ return [backendIp, _DevServerUtils.BACKEND_PORT];
30648
+ } catch {
30649
+ throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30650
+ }
30651
+ }
30652
+ static getAddrPort2016(name) {
30653
+ try {
30654
+ let portContent = fs.readFileSync(`${os.homedir()}/.local/run/services/${name}/server/port`, "utf-8");
30655
+ return ["localhost", parseInt(portContent, 10)];
30656
+ } catch {
30657
+ throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30658
+ }
30659
+ }
30660
+ static resolveBackendHost(name) {
30661
+ let host;
30662
+ try {
30663
+ host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);
30664
+ } catch {
30665
+ host = `${name}.root.shopify.dev.internal`;
30666
+ }
30667
+ try {
30668
+ return _DevServerUtils.getIpFromHosts(host);
30669
+ } catch {
30670
+ return host;
30671
+ }
30672
+ }
30673
+ };
30674
+ DevServerUtils.INFERENCE_MODE_SENTINEL = "/opt/dev/misc/dev-server-inference-mode";
30675
+ DevServerUtils.BACKEND_PORT = 8080;
30676
+ DevServerUtils.CONNECT_TIMEOUT = 100;
30677
+ DevServerUtils.HOSTS_FILE = "/etc/hosts";
30678
+ var DevServer = class {
30679
+ constructor(name) {
30680
+ if (!process.env.SPIN && !process.env.USING_DEV)
30681
+ throw new Error("DevServer is not supported in this environment");
30682
+ if (name === "shopify")
30683
+ throw new Error("Use DevServer.core for the 'shopify' project");
30684
+ this.name = name;
30685
+ }
30686
+ url({ nonstandardHostPrefix } = {}) {
30687
+ return `https://${this.host({ nonstandardHostPrefix })}`;
30688
+ }
30689
+ host({ nonstandardHostPrefix } = {}) {
30690
+ let prefix = nonstandardHostPrefix || this.name;
30691
+ if (process.env.SPIN === "1") {
30692
+ let services = fs.readdirSync("/run/ports2").filter((file) => file.endsWith(`--${this.name}`));
30693
+ if (services.length === 0)
30694
+ throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
30695
+ let match = new RegExp(`^(.+)${this.name}$`).exec(services[0]), organization = match ? match[1] : "";
30696
+ return `${organization !== "shopify--" ? `${organization}` : ""}${this.name}.${process.env.SPIN_FQDN}`;
30697
+ } else return DevServerUtils.inferenceModeAndProjectIsEdition2016(this.name) ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.shop.dev`);
30698
+ }
30699
+ assertRunningLocally2024() {
30700
+ let [addr, port] = DevServerUtils.getAddrPort2024(this.name);
30701
+ DevServerUtils.assertConnectable(this.name, addr, port);
30702
+ }
30703
+ assertRunningLocally2016() {
30704
+ let [addr, port] = DevServerUtils.getAddrPort2016(this.name);
30705
+ DevServerUtils.assertConnectable(this.name, addr, port);
30706
+ }
30707
+ }, DevServerCore = class {
30708
+ constructor() {
30709
+ this.name = "shopify";
30710
+ }
30711
+ url(prefix) {
30712
+ return `https://${this.host(prefix)}`;
30713
+ }
30714
+ host(prefix) {
30715
+ if (process.env.SPIN === "1") {
30716
+ if (!fs.readdirSync("/run/ports2").find((file) => file.endsWith(`--${this.name}`)))
30717
+ throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
30718
+ return `${prefix}.${this.name}.${process.env.SPIN_FQDN}`;
30719
+ } else return DevServerUtils.inferenceModeAndProjectIsEdition2016("shopify") ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.my.shop.dev`);
30720
+ }
30721
+ assertRunningLocally2024() {
30722
+ let [addr, port] = DevServerUtils.getAddrPort2024("shopify");
30723
+ DevServerUtils.assertConnectable("shopify", addr, port);
30724
+ }
30725
+ assertRunningLocally2016() {
30726
+ let [addr, port] = DevServerUtils.getAddrPort2016("shopify");
30727
+ DevServerUtils.assertConnectable("shopify", addr, port);
30728
+ }
30729
+ };
30730
+
30731
+ // ../cli-kit/dist/public/node/context/fqdn.js
30732
+ var CouldntObtainPartnersSpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment."), CouldntObtainIdentitySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment."), CouldntObtainShopifySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment."), NotProvidedStoreFQDNError = new AbortError("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
30733
+ async function partnersFqdn() {
30734
+ if (blockPartnersAccess())
30735
+ throw new BugError("Partners API is blocked by the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable.");
30736
+ let environment = serviceEnvironment(), productionFqdn = "partners.shopify.com";
30737
+ switch (environment) {
30738
+ case "local":
30739
+ return new DevServer("partners").host();
30740
+ case "spin":
30741
+ return `partners.${await spinFqdn()}`;
30742
+ default:
30743
+ return productionFqdn;
30744
+ }
30671
30745
  }
30672
- function errorsIncludeStatus429(error) {
30673
- return error.response.status === 429 ? !0 : typeof error.response.errors == "string" ? !1 : error.response.errors?.some((error2) => error2.extensions?.code === "429") ?? !1;
30746
+ async function appManagementFqdn() {
30747
+ let environment = serviceEnvironment(), productionFqdn = "app.shopify.com";
30748
+ switch (environment) {
30749
+ case "local":
30750
+ return new DevServerCore().host("app");
30751
+ case "spin":
30752
+ return `app.shopify.${await spinFqdn()}`;
30753
+ default:
30754
+ return productionFqdn;
30755
+ }
30674
30756
  }
30675
- async function simpleRequestWithDebugLog({ request, url }, errorHandler) {
30676
- let result = await makeVerboseRequest({ request, url });
30677
- switch (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
30678
- With response headers:
30679
- ${result.sanitizedHeaders}
30680
- `), result.status) {
30681
- case "ok":
30682
- return result.response;
30683
- case "client-error":
30684
- throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30685
- case "unknown-error":
30686
- throw errorHandler ? errorHandler(result.error, result.requestId) : result.error;
30687
- case "can-retry":
30688
- throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30689
- case "unauthorized":
30690
- throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30757
+ async function developerDashboardFqdn() {
30758
+ let environment = serviceEnvironment(), productionFqdn = "dev.shopify.com";
30759
+ switch (environment) {
30760
+ case "local":
30761
+ return new DevServerCore().host("dev");
30762
+ case "spin":
30763
+ return `dev.shopify.${await spinFqdn()}`;
30764
+ default:
30765
+ return productionFqdn;
30691
30766
  }
30692
30767
  }
30693
- async function retryAwareRequest({ request, url }, errorHandler, unauthorizedHandler, retryOptions = {
30694
- scheduleDelay: setTimeout
30695
- }) {
30696
- let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest({ request, url });
30697
- for (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
30698
- With response headers:
30699
- ${result.sanitizedHeaders}
30700
- `); ; ) {
30701
- if (result.status === "ok")
30702
- return retriesUsed > 0 && outputDebug(`Request to ${result.sanitizedUrl} succeeded after ${retriesUsed} retries`), result.response;
30703
- if (result.status === "client-error")
30704
- throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30705
- if (result.status === "unknown-error")
30706
- throw errorHandler ? errorHandler(result.error, result.requestId) : result.error;
30707
- if (result.status === "unauthorized")
30708
- if (unauthorizedHandler)
30709
- await unauthorizedHandler();
30710
- else
30711
- throw result.clientError;
30712
- if (limitRetriesTo <= retriesUsed)
30713
- throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30714
- retriesUsed += 1;
30715
- let retryDelayMs = result.delayMs ?? retryOptions.defaultDelayMs ?? DEFAULT_RETRY_DELAY_MS;
30716
- outputDebug(`Scheduling retry request #${retriesUsed} to ${result.sanitizedUrl} in ${retryDelayMs} ms`), result = await new Promise((resolve) => {
30717
- retryOptions.scheduleDelay(() => {
30718
- resolve(makeVerboseRequest({ request, url }));
30719
- }, retryDelayMs);
30720
- });
30768
+ async function businessPlatformFqdn() {
30769
+ let environment = serviceEnvironment(), productionFqdn = "destinations.shopifysvc.com";
30770
+ switch (environment) {
30771
+ case "local":
30772
+ return new DevServer("business-platform").host();
30773
+ case "spin":
30774
+ return `business-platform.${await spinFqdn()}`;
30775
+ default:
30776
+ return productionFqdn;
30777
+ }
30778
+ }
30779
+ async function identityFqdn() {
30780
+ let environment = serviceEnvironment(), productionFqdn = "accounts.shopify.com";
30781
+ switch (environment) {
30782
+ case "local":
30783
+ return new DevServer("identity").host();
30784
+ case "spin":
30785
+ return `identity.${await spinFqdn()}`;
30786
+ default:
30787
+ return productionFqdn;
30721
30788
  }
30722
30789
  }
30790
+ async function normalizeStoreFqdn(store2) {
30791
+ let storeFqdn = store2.replace(/^https?:\/\//, "").replace(/\/$/, ""), addDomain = async (storeFqdn2) => {
30792
+ switch (serviceEnvironment()) {
30793
+ case "local":
30794
+ return new DevServerCore().host(storeFqdn2);
30795
+ case "spin":
30796
+ return `${storeFqdn2}.shopify.${await spinFqdn()}`;
30797
+ default:
30798
+ return `${storeFqdn2}.myshopify.com`;
30799
+ }
30800
+ };
30801
+ return ((storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev") || storeFqdn2.includes("shopify.io") || storeFqdn2.includes(".shop.dev"))(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
30802
+ }
30723
30803
 
30724
30804
  // ../cli-kit/dist/public/node/http.js
30725
- var import_form_data = __toESM(require_form_data(), 1);
30805
+ init_cjs_shims();
30806
+ var import_form_data = __toESM(require_form_data());
30726
30807
 
30727
30808
  // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
30728
30809
  init_cjs_shims();
@@ -31719,139 +31800,6 @@ var ok = (value) => new Ok(value), err = (err2) => new Err(err2), Ok = class {
31719
31800
  }
31720
31801
  };
31721
31802
 
31722
- // ../cli-kit/dist/private/node/session/identity-token-validation.js
31723
- async function validateIdentityToken(token) {
31724
- if (isSpin() && firstPartyDev())
31725
- return !0;
31726
- try {
31727
- return withIntrospectionURL(async (introspectionURL) => {
31728
- let options = {
31729
- method: "POST",
31730
- headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
31731
- body: JSON.stringify({ token })
31732
- };
31733
- outputDebug(`Sending Identity Introspection request to URL: ${introspectionURL}`);
31734
- let response = await shopifyFetch(introspectionURL, options);
31735
- if (response.ok && response.headers.get("content-type")?.includes("json")) {
31736
- let json = await response.json();
31737
- return outputDebug(`The identity token is valid: ${json.valid}`), ok(json.valid);
31738
- } else {
31739
- if (response.status === 404 || response.status > 500)
31740
- return err(new AbortError(`The introspection endpoint returned a ${response.status}: ${introspectionURL}`));
31741
- {
31742
- let text = await response.text();
31743
- return outputDebug(`The Introspection request failed with:
31744
- - status: ${response.status}
31745
- - www-authenticate header: ${JSON.stringify(response.headers.get("www-authenticate"))}
31746
- - body: ${JSON.stringify(text)}`), ok(!1);
31747
- }
31748
- }
31749
- });
31750
- } catch (error) {
31751
- return outputDebug(`The identity token is invalid: ${error}`), !1;
31752
- }
31753
- }
31754
- async function withIntrospectionURL(fn) {
31755
- let cacheKey = `identity-introspection-url-${await identityFqdn()}`, introspectionURL = await cacheRetrieveOrRepopulate(cacheKey, getIntrospectionURL, 6048e5), result = await fn(introspectionURL);
31756
- if (result.isErr() && (introspectionURL = await cacheRetrieveOrRepopulate(cacheKey, getIntrospectionURL, 0), result = await fn(introspectionURL)), result.isErr())
31757
- throw result.error;
31758
- return result.value;
31759
- }
31760
- async function getIntrospectionURL() {
31761
- return (await (await shopifyFetch(`https://${await identityFqdn()}/.well-known/openid-configuration.json`)).json()).introspection_endpoint;
31762
- }
31763
-
31764
- // ../cli-kit/dist/private/node/session/validate.js
31765
- function validateScopes(requestedScopes, identity) {
31766
- let currentScopes = identity.scopes;
31767
- return firstPartyDev() !== currentScopes.includes("employee") ? !1 : requestedScopes.every((scope) => currentScopes.includes(scope));
31768
- }
31769
- async function validateSession(scopes, applications, session) {
31770
- if (!session || !validateScopes(scopes, session.identity))
31771
- return "needs_full_auth";
31772
- let tokensAreExpired = isTokenExpired(session.identity);
31773
- if (applications.partnersApi) {
31774
- let appId = applicationId("partners"), token = session.applications[appId];
31775
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
31776
- }
31777
- if (applications.appManagementApi) {
31778
- let appId = applicationId("app-management"), token = session.applications[appId];
31779
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
31780
- }
31781
- if (applications.storefrontRendererApi) {
31782
- let appId = applicationId("storefront-renderer"), token = session.applications[appId];
31783
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
31784
- }
31785
- if (applications.adminApi) {
31786
- let appId = applicationId("admin"), realAppId = `${applications.adminApi.storeFqdn}-${appId}`, token = session.applications[realAppId];
31787
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
31788
- }
31789
- if (outputDebug(`- Token validation -> It's expired: ${tokensAreExpired}`), !validateCachedIdentityTokenStructure(session.identity))
31790
- return "needs_full_auth";
31791
- if (tokensAreExpired)
31792
- return "needs_refresh";
31793
- let identityIsValid = await validateIdentityToken(session.identity.accessToken);
31794
- return outputDebug(`- Token validation -> It's invalid in identity: ${!identityIsValid}`), identityIsValid ? "ok" : "needs_full_auth";
31795
- }
31796
- function isTokenExpired(token) {
31797
- return token ? token.expiresAt < expireThreshold() : !0;
31798
- }
31799
- function expireThreshold() {
31800
- return new Date(Date.now() + sessionConstants.expirationTimeMarginInMinutes * 60 * 1e3);
31801
- }
31802
-
31803
- // ../cli-kit/dist/private/node/session/scopes.js
31804
- init_cjs_shims();
31805
- function allDefaultScopes(extraScopes = []) {
31806
- let scopes = allAPIs.map((api) => defaultApiScopes(api)).flat();
31807
- return scopes = ["openid", ...scopes, ...extraScopes].map(scopeTransform), Array.from(new Set(scopes));
31808
- }
31809
- function apiScopes(api, extraScopes = []) {
31810
- let scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform);
31811
- return Array.from(new Set(scopes));
31812
- }
31813
- function defaultApiScopes(api) {
31814
- switch (api) {
31815
- case "admin":
31816
- return ["graphql", "themes", "collaborator"];
31817
- case "storefront-renderer":
31818
- return ["devtools"];
31819
- case "partners":
31820
- return ["cli"];
31821
- case "business-platform":
31822
- return ["destinations", "store-management"];
31823
- case "app-management":
31824
- return ["app-management"];
31825
- default:
31826
- throw new BugError(`Unknown API: ${api}`);
31827
- }
31828
- }
31829
- function scopeTransform(scope) {
31830
- switch (scope) {
31831
- case "graphql":
31832
- return "https://api.shopify.com/auth/shop.admin.graphql";
31833
- case "themes":
31834
- return "https://api.shopify.com/auth/shop.admin.themes";
31835
- case "collaborator":
31836
- return "https://api.shopify.com/auth/partners.collaborator-relationships.readonly";
31837
- case "cli":
31838
- return "https://api.shopify.com/auth/partners.app.cli.access";
31839
- case "devtools":
31840
- return "https://api.shopify.com/auth/shop.storefront-renderer.devtools";
31841
- case "destinations":
31842
- return "https://api.shopify.com/auth/destinations.readonly";
31843
- case "store-management":
31844
- return "https://api.shopify.com/auth/organization.store-management";
31845
- case "app-management":
31846
- return "https://api.shopify.com/auth/organization.apps.manage";
31847
- default:
31848
- return scope;
31849
- }
31850
- }
31851
-
31852
- // ../cli-kit/dist/private/node/session/exchange.js
31853
- init_cjs_shims();
31854
-
31855
31803
  // ../../node_modules/.pnpm/jose@5.9.6/node_modules/jose/dist/node/esm/index.js
31856
31804
  init_cjs_shims();
31857
31805
 
@@ -32065,8 +32013,10 @@ async function requestDeviceAuthorization(scopes) {
32065
32013
  To run this command, log in to Shopify.`), !isTTY())
32066
32014
  throw new AbortError("Authorization is required to continue, but the current environment does not support interactive prompts.", "To resolve this, specify credentials in your environment, or run the command in an interactive environment such as your local terminal.");
32067
32015
  outputInfo(outputContent`User verification code: ${jsonResult.user_code}`);
32068
- let linkToken = outputToken.link(jsonResult.verification_uri_complete);
32069
- return isCloudEnvironment() ? outputInfo(outputContent`👉 Open this link to start the auth process: ${linkToken}`) : (outputInfo("\u{1F449} Press any key to open the login page on your browser"), await keypress(), await openURL(jsonResult.verification_uri_complete), outputInfo(outputContent`Opened link to start the auth process: ${linkToken}`)), {
32016
+ let linkToken = outputToken.link(jsonResult.verification_uri_complete), cloudMessage = () => {
32017
+ outputInfo(outputContent`👉 Open this link to start the auth process: ${linkToken}`);
32018
+ };
32019
+ return isCloudEnvironment() ? cloudMessage() : (outputInfo("\u{1F449} Press any key to open the login page on your browser"), await keypress(), await openURL(jsonResult.verification_uri_complete) ? outputInfo(outputContent`Opened link to start the auth process: ${linkToken}`) : cloudMessage()), {
32070
32020
  deviceCode: jsonResult.device_code,
32071
32021
  userCode: jsonResult.user_code,
32072
32022
  verificationUri: jsonResult.verification_uri,
@@ -32113,20 +32063,6 @@ function convertRequestToParams(queryParams) {
32113
32063
 
32114
32064
  // ../cli-kit/dist/private/node/api/rest.js
32115
32065
  init_cjs_shims();
32116
- function restRequestBody(requestBody) {
32117
- if (requestBody)
32118
- return JSON.stringify(requestBody);
32119
- }
32120
- function restRequestUrl(session, apiVersion, path, searchParams = {}) {
32121
- let url = new URL(isThemeAccessSession(session) ? `https://${themeKitAccessDomain}/cli/admin/api/${apiVersion}${path}.json` : `https://${session.storeFqdn}/admin/api/${apiVersion}${path}.json`);
32122
- return Object.entries(searchParams).forEach(([name, value]) => {
32123
- url.searchParams.set(name, value);
32124
- }), url.toString();
32125
- }
32126
- function restRequestHeaders(session) {
32127
- let store2 = session.storeFqdn, token = session.token, headers = buildHeaders(session.token);
32128
- return isThemeAccessSession(session) && (headers["X-Shopify-Shop"] = store2, headers["X-Shopify-Access-Token"] = token), headers;
32129
- }
32130
32066
  function isThemeAccessSession(session) {
32131
32067
  return session.token.startsWith("shptka_");
32132
32068
  }
@@ -32276,55 +32212,6 @@ function buildIdentityTokenFromEnv(scopes, identityTokenInformation) {
32276
32212
  };
32277
32213
  }
32278
32214
 
32279
- // ../cli-kit/dist/public/node/os.js
32280
- init_cjs_shims();
32281
- import { userInfo as osUserInfo } from "os";
32282
- async function username(platform = process.platform) {
32283
- outputDebug(outputContent`Obtaining user name...`);
32284
- let environmentVariable = getEnvironmentVariable();
32285
- if (environmentVariable)
32286
- return environmentVariable;
32287
- let userInfoUsername = getUsernameFromOsUserInfo();
32288
- if (userInfoUsername)
32289
- return userInfoUsername;
32290
- try {
32291
- if (platform === "win32") {
32292
- let { stdout } = await execa("whoami");
32293
- return cleanWindowsCommand(stdout);
32294
- }
32295
- let { stdout: userId2 } = await execa("id", ["-u"]);
32296
- try {
32297
- let { stdout } = await execa("id", ["-un", userId2]);
32298
- return stdout;
32299
- } catch {
32300
- }
32301
- return makeUsernameFromId(userId2);
32302
- } catch {
32303
- return null;
32304
- }
32305
- }
32306
- function platformAndArch(platform = process.platform, arch = process.arch) {
32307
- let archString;
32308
- return arch === "x64" ? archString = "amd64" : arch === "ia32" ? archString = "386" : archString = arch, { platform: platform.match(/^win.+/) ? "windows" : platform, arch: archString };
32309
- }
32310
- function getEnvironmentVariable() {
32311
- let { env } = process;
32312
- return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
32313
- }
32314
- function getUsernameFromOsUserInfo() {
32315
- try {
32316
- return osUserInfo().username;
32317
- } catch {
32318
- return null;
32319
- }
32320
- }
32321
- function cleanWindowsCommand(value) {
32322
- return value.replace(/^.*\\/, "");
32323
- }
32324
- function makeUsernameFromId(userId2) {
32325
- return `no-username-${userId2}`;
32326
- }
32327
-
32328
32215
  // ../cli-kit/dist/private/node/analytics.js
32329
32216
  async function startAnalytics({ commandContent, args, currentTime = (/* @__PURE__ */ new Date()).getTime(), commandClass }) {
32330
32217
  let startCommand = commandContent.command;
@@ -32403,16 +32290,11 @@ export {
32403
32290
  ok,
32404
32291
  err,
32405
32292
  exchangeCustomPartnerToken,
32406
- restRequestBody,
32407
- restRequestUrl,
32408
- restRequestHeaders,
32409
32293
  isThemeAccessSession,
32410
32294
  getLastSeenUserIdAfterAuth,
32411
32295
  setLastSeenUserIdAfterAuth,
32412
32296
  setLastSeenAuthMethod,
32413
32297
  ensureAuthenticated,
32414
- username,
32415
- platformAndArch,
32416
32298
  startAnalytics,
32417
32299
  getEnvironmentData,
32418
32300
  getSensitiveEnvironmentData
@@ -32435,4 +32317,4 @@ mime-types/index.js:
32435
32317
  * MIT Licensed
32436
32318
  *)
32437
32319
  */
32438
- //# sourceMappingURL=chunk-KVD7B3JW.js.map
32320
+ //# sourceMappingURL=chunk-BR3KKEPN.js.map