@shopify/create-app 3.91.1 → 3.92.1

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.
@@ -2,12 +2,12 @@ import {
2
2
  CLI_KIT_VERSION,
3
3
  jsonOutputEnabled,
4
4
  z
5
- } from "./chunk-XKZES4F6.js";
5
+ } from "./chunk-CCWLFNWN.js";
6
6
  import {
7
7
  cacheRetrieve,
8
8
  cacheStore,
9
9
  versionSatisfies
10
- } from "./chunk-7WLIB5CO.js";
10
+ } from "./chunk-QZMFOTZO.js";
11
11
  import {
12
12
  AbortSilentError,
13
13
  exec,
@@ -16,7 +16,7 @@ import {
16
16
  renderError,
17
17
  renderInfo,
18
18
  renderWarning
19
- } from "./chunk-NSOYPXEP.js";
19
+ } from "./chunk-RIXXPHKS.js";
20
20
  import {
21
21
  init_cjs_shims
22
22
  } from "./chunk-PKR7KJ6P.js";
@@ -84,7 +84,7 @@ async function showNotificationsIfNeeded(currentSurfaces, environment = process.
84
84
  throw new AbortSilentError();
85
85
  let errorMessage = `Error showing notifications: ${error.message}`;
86
86
  outputDebug(errorMessage);
87
- let { sendErrorToBugsnag } = await import("./error-handler-LIQZ7B4V.js");
87
+ let { sendErrorToBugsnag } = await import("./error-handler-SDB6N5WP.js");
88
88
  await sendErrorToBugsnag(errorMessage, "unexpected_error");
89
89
  }
90
90
  }
@@ -174,4 +174,4 @@ export {
174
174
  showNotificationsIfNeeded,
175
175
  fetchNotificationsInBackground
176
176
  };
177
- //# sourceMappingURL=chunk-NTSWA5QE.js.map
177
+ //# sourceMappingURL=chunk-6VIP6FXG.js.map
@@ -4,18 +4,21 @@ import {
4
4
  formDataToBlob
5
5
  } from "./chunk-VBBBCVMH.js";
6
6
  import {
7
+ Environment,
7
8
  cacheRetrieveOrRepopulate,
8
9
  getCurrentSessionId,
9
10
  getPackageManager,
10
11
  getSessions,
12
+ isLocalEnvironment,
11
13
  packageManagerFromUserAgent,
12
14
  removeCurrentSessionId,
13
15
  removeSessions,
14
16
  runWithRateLimit,
17
+ serviceEnvironment,
15
18
  setCurrentSessionId,
16
19
  setSessions,
17
20
  timeIntervalToMilliseconds
18
- } from "./chunk-7WLIB5CO.js";
21
+ } from "./chunk-QZMFOTZO.js";
19
22
  import {
20
23
  AbortError,
21
24
  AbortSilentError,
@@ -100,10 +103,10 @@ import {
100
103
  stringifyMessage,
101
104
  systemEnvironmentVariables,
102
105
  themeToken
103
- } from "./chunk-NSOYPXEP.js";
106
+ } from "./chunk-RIXXPHKS.js";
104
107
  import {
105
108
  require_lib
106
- } from "./chunk-D7M6DPGX.js";
109
+ } from "./chunk-Z4EMJFGP.js";
107
110
  import {
108
111
  cwd,
109
112
  isAbsolutePath,
@@ -111,7 +114,7 @@ import {
111
114
  normalizePath,
112
115
  relativePath,
113
116
  sniffForJson
114
- } from "./chunk-Y2JP6WFP.js";
117
+ } from "./chunk-CFNYEDC6.js";
115
118
  import {
116
119
  require_once
117
120
  } from "./chunk-SHWOPMLQ.js";
@@ -48071,12 +48074,19 @@ function maxRequestTimeForNetworkCallsMs(environment = getEnvironmentVariables()
48071
48074
  return maxRequestTime && !isNaN(Number(maxRequestTime)) ? Number(maxRequestTime) : 30 * 1e3;
48072
48075
  }
48073
48076
 
48077
+ // ../cli-kit/dist/private/node/api/urls.js
48078
+ init_cjs_shims();
48079
+ function sanitizeURL(url4) {
48080
+ let parsedUrl = new URL(url4);
48081
+ return parsedUrl.searchParams.has("subject_token") && parsedUrl.searchParams.set("subject_token", "****"), parsedUrl.searchParams.has("token") && parsedUrl.searchParams.set("token", "****"), parsedUrl.toString();
48082
+ }
48083
+
48074
48084
  // ../cli-kit/dist/private/node/api/headers.js
48075
48085
  init_cjs_shims();
48076
48086
 
48077
48087
  // ../cli-kit/dist/public/common/version.js
48078
48088
  init_cjs_shims();
48079
- var CLI_KIT_VERSION = "3.91.1";
48089
+ var CLI_KIT_VERSION = "3.92.1";
48080
48090
 
48081
48091
  // ../cli-kit/dist/private/node/api/headers.js
48082
48092
  import https from "https";
@@ -48120,13 +48130,6 @@ async function httpsAgent() {
48120
48130
  });
48121
48131
  }
48122
48132
 
48123
- // ../cli-kit/dist/private/node/api/urls.js
48124
- init_cjs_shims();
48125
- function sanitizeURL(url4) {
48126
- let parsedUrl = new URL(url4);
48127
- return parsedUrl.searchParams.has("subject_token") && parsedUrl.searchParams.set("subject_token", "****"), parsedUrl.searchParams.has("token") && parsedUrl.searchParams.set("token", "****"), parsedUrl.toString();
48128
- }
48129
-
48130
48133
  // ../cli-kit/dist/private/node/api.js
48131
48134
  init_cjs_shims();
48132
48135
 
@@ -49839,52 +49842,6 @@ init_cjs_shims();
49839
49842
  // ../cli-kit/dist/private/node/session.js
49840
49843
  init_cjs_shims();
49841
49844
 
49842
- // ../cli-kit/dist/private/node/session/identity.js
49843
- init_cjs_shims();
49844
-
49845
- // ../cli-kit/dist/private/node/context/service.js
49846
- init_cjs_shims();
49847
- var Environment;
49848
- (function(Environment2) {
49849
- Environment2.Local = "local", Environment2.Production = "production";
49850
- })(Environment || (Environment = {}));
49851
- function serviceEnvironment(env = process.env) {
49852
- return env[environmentVariables.serviceEnv] === "local" ? Environment.Local : Environment.Production;
49853
- }
49854
- function isLocalEnvironment(env = process.env) {
49855
- return serviceEnvironment(env) === Environment.Local;
49856
- }
49857
-
49858
- // ../cli-kit/dist/private/node/session/identity.js
49859
- function clientId() {
49860
- let environment = serviceEnvironment();
49861
- return environment === Environment.Local ? "e5380e02-312a-7408-5718-e07017e9cf52" : environment === Environment.Production ? "fbdb2649-e327-4907-8f67-908d24cfd7e3" : "e5380e02-312a-7408-5718-e07017e9cf52";
49862
- }
49863
- function applicationId(api) {
49864
- switch (api) {
49865
- case "admin": {
49866
- let environment = serviceEnvironment();
49867
- return environment === Environment.Local ? "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52" : environment === Environment.Production ? "7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c" : "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
49868
- }
49869
- case "partners": {
49870
- let environment = serviceEnvironment();
49871
- return environment === Environment.Local ? "df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978" : environment === Environment.Production ? "271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6" : "df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978";
49872
- }
49873
- case "storefront-renderer": {
49874
- let environment = serviceEnvironment();
49875
- return environment === Environment.Local ? "46f603de-894f-488d-9471-5b721280ff49" : environment === Environment.Production ? "ee139b3d-5861-4d45-b387-1bc3ada7811c" : "46f603de-894f-488d-9471-5b721280ff49";
49876
- }
49877
- case "business-platform": {
49878
- let environment = serviceEnvironment();
49879
- return environment === Environment.Local ? "ace6dc89-b526-456d-a942-4b8ef6acda4b" : environment === Environment.Production ? "32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc" : "ace6dc89-b526-456d-a942-4b8ef6acda4b";
49880
- }
49881
- case "app-management":
49882
- return serviceEnvironment() === Environment.Production ? "7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c" : "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
49883
- default:
49884
- throw new BugError(`Application id for API of type: ${api}`);
49885
- }
49886
- }
49887
-
49888
49845
  // ../cli-kit/dist/private/node/session/validate.js
49889
49846
  init_cjs_shims();
49890
49847
 
@@ -52858,30 +52815,11 @@ function validateScopes(requestedScopes, identity) {
52858
52815
  let currentScopes = identity.scopes;
52859
52816
  return firstPartyDev() !== currentScopes.includes("employee") ? !1 : requestedScopes.every((scope) => currentScopes.includes(scope));
52860
52817
  }
52861
- async function validateSession(scopes, applications, session) {
52862
- if (!session || !validateScopes(scopes, session.identity))
52818
+ async function validateSession(scopes, session) {
52819
+ if (!session || !validateScopes(scopes, session.identity) || !validateCachedIdentityTokenStructure(session.identity))
52863
52820
  return "needs_full_auth";
52864
- let tokensAreExpired = isTokenExpired(session.identity);
52865
- if (applications.partnersApi) {
52866
- let appId = applicationId("partners"), token = session.applications[appId];
52867
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
52868
- }
52869
- if (applications.appManagementApi) {
52870
- let appId = applicationId("app-management"), token = session.applications[appId];
52871
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
52872
- }
52873
- if (applications.storefrontRendererApi) {
52874
- let appId = applicationId("storefront-renderer"), token = session.applications[appId];
52875
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
52876
- }
52877
- if (applications.adminApi) {
52878
- let appId = applicationId("admin"), realAppId = `${applications.adminApi.storeFqdn}-${appId}`, token = session.applications[realAppId];
52879
- tokensAreExpired = tokensAreExpired || isTokenExpired(token);
52880
- }
52881
- return outputDebug(`- Token validation -> It's expired: ${tokensAreExpired}`), validateCachedIdentityTokenStructure(session.identity) ? tokensAreExpired ? "needs_refresh" : "ok" : "needs_full_auth";
52882
- }
52883
- function isTokenExpired(token) {
52884
- return token ? token.expiresAt < expireThreshold() : !0;
52821
+ let expired = session.identity.expiresAt < expireThreshold();
52822
+ return outputDebug(`- Token validation -> It's expired: ${expired}`), expired ? "needs_refresh" : "ok";
52885
52823
  }
52886
52824
  function expireThreshold() {
52887
52825
  return new Date(Date.now() + sessionConstants.expirationTimeMarginInMinutes * 60 * 1e3);
@@ -52893,10 +52831,6 @@ function allDefaultScopes(extraScopes = []) {
52893
52831
  let scopes = allAPIs.map((api) => defaultApiScopes(api)).flat();
52894
52832
  return scopes = ["openid", ...scopes, ...extraScopes].map(scopeTransform), Array.from(new Set(scopes));
52895
52833
  }
52896
- function apiScopes(api, extraScopes = []) {
52897
- let scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform);
52898
- return Array.from(new Set(scopes));
52899
- }
52900
52834
  function tokenExchangeScopes(api) {
52901
52835
  switch (api) {
52902
52836
  case "partners":
@@ -52953,6 +52887,37 @@ function scopeTransform(scope) {
52953
52887
  // ../cli-kit/dist/private/node/session/exchange.js
52954
52888
  init_cjs_shims();
52955
52889
 
52890
+ // ../cli-kit/dist/private/node/session/identity.js
52891
+ init_cjs_shims();
52892
+ function clientId() {
52893
+ let environment = serviceEnvironment();
52894
+ return environment === Environment.Local ? "e5380e02-312a-7408-5718-e07017e9cf52" : environment === Environment.Production ? "fbdb2649-e327-4907-8f67-908d24cfd7e3" : "e5380e02-312a-7408-5718-e07017e9cf52";
52895
+ }
52896
+ function applicationId(api) {
52897
+ switch (api) {
52898
+ case "admin": {
52899
+ let environment = serviceEnvironment();
52900
+ return environment === Environment.Local ? "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52" : environment === Environment.Production ? "7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c" : "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
52901
+ }
52902
+ case "partners": {
52903
+ let environment = serviceEnvironment();
52904
+ return environment === Environment.Local ? "df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978" : environment === Environment.Production ? "271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6" : "df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978";
52905
+ }
52906
+ case "storefront-renderer": {
52907
+ let environment = serviceEnvironment();
52908
+ return environment === Environment.Local ? "46f603de-894f-488d-9471-5b721280ff49" : environment === Environment.Production ? "ee139b3d-5861-4d45-b387-1bc3ada7811c" : "46f603de-894f-488d-9471-5b721280ff49";
52909
+ }
52910
+ case "business-platform": {
52911
+ let environment = serviceEnvironment();
52912
+ return environment === Environment.Local ? "ace6dc89-b526-456d-a942-4b8ef6acda4b" : environment === Environment.Production ? "32ff8ee5-82b8-4d93-9f8a-c6997cefb7dc" : "ace6dc89-b526-456d-a942-4b8ef6acda4b";
52913
+ }
52914
+ case "app-management":
52915
+ return serviceEnvironment() === Environment.Production ? "7ee65a63608843c577db8b23c4d7316ea0a01bd2f7594f8a9c06ea668c1b775c" : "e92482cebb9bfb9fb5a0199cc770fde3de6c8d16b798ee73e36c9d815e070e52";
52916
+ default:
52917
+ throw new BugError(`Application id for API of type: ${api}`);
52918
+ }
52919
+ }
52920
+
52956
52921
  // ../cli-kit/dist/public/node/context/fqdn.js
52957
52922
  init_cjs_shims();
52958
52923
 
@@ -52969,12 +52934,9 @@ function assertCompatibleEnvironment() {
52969
52934
 
52970
52935
  // ../cli-kit/dist/public/node/vendor/dev_server/dev-server.js
52971
52936
  init_cjs_shims();
52972
- import fs4 from "node:fs";
52973
52937
 
52974
52938
  // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-2024.js
52975
52939
  init_cjs_shims();
52976
- var ni = __toESM(require_network_interfaces(), 1);
52977
- import fs2 from "node:fs";
52978
52940
 
52979
52941
  // ../cli-kit/dist/public/node/vendor/dev_server/network/index.js
52980
52942
  init_cjs_shims();
@@ -53036,6 +52998,8 @@ function fallbackCheckPort(address, port, timeout) {
53036
52998
  }
53037
52999
 
53038
53000
  // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-2024.js
53001
+ var ni = __toESM(require_network_interfaces(), 1);
53002
+ import fs2 from "node:fs";
53039
53003
  var NON_SHOP_PREFIXES = ["app", "dev", "shopify"], BACKEND_PORT = 8080;
53040
53004
  function createServer(projectName) {
53041
53005
  return {
@@ -53089,8 +53053,8 @@ var assertRunningOverride;
53089
53053
 
53090
53054
  // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-2016.js
53091
53055
  init_cjs_shims();
53092
- import fs3 from "fs";
53093
53056
  import * as os from "node:os";
53057
+ import fs3 from "fs";
53094
53058
  function createServer2(projectName) {
53095
53059
  return {
53096
53060
  host: (options2 = {}) => host2(projectName, options2),
@@ -53118,6 +53082,7 @@ function getAddrPort(name) {
53118
53082
  var assertRunningOverride2;
53119
53083
 
53120
53084
  // ../cli-kit/dist/public/node/vendor/dev_server/dev-server.js
53085
+ import fs4 from "node:fs";
53121
53086
  var DevServer = class {
53122
53087
  constructor(projectName) {
53123
53088
  if (this.projectName = projectName, projectName === "shopify")
@@ -53249,7 +53214,7 @@ var ok = (value) => new Ok(value), err = (err2) => new Err(err2), Ok = class {
53249
53214
  return ok(this.value);
53250
53215
  }
53251
53216
  }, Err = class {
53252
- // eslint-disable-next-line node/handle-callback-err
53217
+ // eslint-disable-next-line n/handle-callback-err
53253
53218
  constructor(error) {
53254
53219
  this.error = error;
53255
53220
  }
@@ -53394,22 +53359,6 @@ var InvalidGrantError = class extends import_ts_error.ExtendableError {
53394
53359
  }, InvalidRequestError = class extends import_ts_error.ExtendableError {
53395
53360
  }, InvalidTargetError = class extends AbortError {
53396
53361
  };
53397
- async function exchangeAccessForApplicationTokens(identityToken, scopes, store2) {
53398
- let token = identityToken.accessToken, [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([
53399
- requestAppToken("partners", token, scopes.partners),
53400
- requestAppToken("storefront-renderer", token, scopes.storefront),
53401
- requestAppToken("business-platform", token, scopes.businessPlatform),
53402
- store2 ? requestAppToken("admin", token, scopes.admin, store2) : {},
53403
- requestAppToken("app-management", token, scopes.appManagement)
53404
- ]);
53405
- return {
53406
- ...partners,
53407
- ...storefront,
53408
- ...businessPlatform,
53409
- ...admin,
53410
- ...appManagement
53411
- };
53412
- }
53413
53362
  async function refreshAccessToken(currentToken) {
53414
53363
  let clientId2 = clientId(), params = {
53415
53364
  grant_type: "refresh_token",
@@ -53475,8 +53424,13 @@ function tokenRequestErrorHandler({ error, store: store2 }) {
53475
53424
  async function tokenRequest(params) {
53476
53425
  let fqdn = await identityFqdn(), url4 = new URL(`https://${fqdn}/oauth/token`);
53477
53426
  url4.search = new URLSearchParams(Object.entries(params)).toString();
53478
- let res = await shopifyFetch(url4.href, { method: "POST" }), payload = await res.json();
53479
- return res.ok ? ok(payload) : err({ error: payload.error, store: params.store });
53427
+ let res = await shopifyFetch(url4.href, { method: "POST" });
53428
+ try {
53429
+ let responseText = await res.text(), payload = JSON.parse(responseText);
53430
+ return res.ok ? ok(payload) : err({ error: payload.error, store: params.store });
53431
+ } catch (error) {
53432
+ throw error instanceof SyntaxError ? new AbortError(`Received invalid response from authentication service (HTTP ${res.status}).`, "The response could not be parsed as JSON. The service may be temporarily unavailable. Please try again.") : error;
53433
+ }
53480
53434
  }
53481
53435
  function buildIdentityToken(result, existingUserId, existingAlias) {
53482
53436
  let userId2 = existingUserId ?? (result.id_token ? decodeJwt(result.id_token).sub : void 0);
@@ -53704,10 +53658,14 @@ async function ensureAuthenticatedAdminAsApp(storeFqdn, clientId2, clientSecret)
53704
53658
  "Content-Type": "application/json"
53705
53659
  },
53706
53660
  body: JSON.stringify(bodyData)
53707
- }, "slow-request");
53661
+ }, "slow-request"), body = await tokenResponse.text();
53708
53662
  if (tokenResponse.status === 400)
53709
- throw (await tokenResponse.text()).includes("app_not_installed") ? new AbortError(outputContent`App is not installed on ${outputToken.green(storeFqdn)}. Try running ${outputToken.genericShellCommand("shopify app dev")} to connect your app to the shop.`) : new AbortError(`Failed to get access token for app ${clientId2} on store ${storeFqdn}: ${tokenResponse.statusText}`);
53710
- return { token: (await tokenResponse.json()).access_token, storeFqdn };
53663
+ throw body.includes("app_not_installed") ? new AbortError(outputContent`App is not installed on ${outputToken.green(storeFqdn)}. Try running ${outputToken.genericShellCommand("shopify app dev")} to connect your app to the shop.`) : new AbortError(`Failed to get access token for app ${clientId2} on store ${storeFqdn}: ${tokenResponse.statusText}`);
53664
+ try {
53665
+ return { token: JSON.parse(body).access_token, storeFqdn };
53666
+ } catch (error) {
53667
+ throw error instanceof SyntaxError ? new AbortError(`Received invalid response from admin authentication service (HTTP ${tokenResponse.status}).`, "The response could not be parsed as JSON. The service may be temporarily unavailable. Please try again.") : error;
53668
+ }
53711
53669
  }
53712
53670
 
53713
53671
  // ../cli-kit/dist/public/common/object.js
@@ -53720,7 +53678,7 @@ function unionArrayStrategy(destinationArray, sourceArray) {
53720
53678
  }
53721
53679
 
53722
53680
  // ../cli-kit/dist/public/common/object.js
53723
- var import_deepmerge = __toESM(require_cjs()), import_pickBy = __toESM(require_pickBy()), import_mapValues = __toESM(require_mapValues()), import_isEqual = __toESM(require_isEqual()), import_differenceWith = __toESM(require_differenceWith()), import_fromPairs = __toESM(require_fromPairs()), import_toPairs = __toESM(require_toPairs()), import_get = __toESM(require_get()), import_set = __toESM(require_set()), import_unset = __toESM(require_unset()), import_isEmpty = __toESM(require_isEmpty());
53681
+ var import_deepmerge = __toESM(require_cjs(), 1), import_pickBy = __toESM(require_pickBy(), 1), import_mapValues = __toESM(require_mapValues(), 1), import_isEqual = __toESM(require_isEqual(), 1), import_differenceWith = __toESM(require_differenceWith(), 1), import_fromPairs = __toESM(require_fromPairs(), 1), import_toPairs = __toESM(require_toPairs(), 1), import_get = __toESM(require_get(), 1), import_set = __toESM(require_set(), 1), import_unset = __toESM(require_unset(), 1), import_isEmpty = __toESM(require_isEmpty(), 1);
53724
53682
  function deepMergeObjects(lhs, rhs, arrayMergeStrategy = unionArrayStrategy) {
53725
53683
  return (0, import_deepmerge.default)(lhs, rhs, { arrayMerge: arrayMergeStrategy });
53726
53684
  }
@@ -53973,7 +53931,7 @@ function earliestDateTimeAfter(afterTime, dates) {
53973
53931
  }
53974
53932
 
53975
53933
  // ../cli-kit/dist/public/node/api/partners.js
53976
- var import_bottleneck = __toESM(require_lib4()), limiter = new import_bottleneck.default({
53934
+ var import_bottleneck = __toESM(require_lib4(), 1), limiter = new import_bottleneck.default({
53977
53935
  minTime: 150,
53978
53936
  maxConcurrent: 10
53979
53937
  });
@@ -54138,7 +54096,7 @@ ${outputToken.json(scopes)}
54138
54096
  For applications:
54139
54097
  ${outputToken.json(applications)}
54140
54098
  `);
54141
- let validationResult = await validateSession(scopes, applications, currentSession), newSession = {};
54099
+ let validationResult = await validateSession(scopes, currentSession), newSession = {};
54142
54100
  if (validationResult === "needs_full_auth")
54143
54101
  await throwOnNoPrompt(noPrompt), outputDebug(outputContent`Initiating the full authentication flow...`), newSession = await executeCompleteFlow(applications);
54144
54102
  else if (validationResult === "needs_refresh" || forceRefresh) {
@@ -54167,7 +54125,7 @@ async function throwOnNoPrompt(noPrompt) {
54167
54125
  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.");
54168
54126
  }
54169
54127
  async function executeCompleteFlow(applications) {
54170
- let scopes = getFlattenScopes(applications), exchangeScopes = getExchangeScopes(applications), store2 = applications.adminApi?.storeFqdn;
54128
+ let scopes = getFlattenScopes(applications);
54171
54129
  firstPartyDev() && (outputDebug(outputContent`Authenticating as Shopify Employee...`), scopes.push("employee"));
54172
54130
  let identityToken, identityTokenInformation = getIdentityTokenInformation();
54173
54131
  if (identityTokenInformation)
@@ -54177,63 +54135,37 @@ async function executeCompleteFlow(applications) {
54177
54135
  let deviceAuth = await requestDeviceAuthorization(scopes);
54178
54136
  outputDebug(outputContent`Starting polling for the identity token...`), identityToken = await pollForDeviceAuthorization(deviceAuth.deviceCode, deviceAuth.interval);
54179
54137
  }
54180
- outputDebug(outputContent`CLI token received. Exchanging it for application tokens...`);
54181
- let result = await exchangeAccessForApplicationTokens(identityToken, exchangeScopes, store2), businessPlatformToken = result[applicationId("business-platform")]?.accessToken, alias = await fetchEmail(businessPlatformToken) ?? identityToken.userId, session = {
54138
+ outputDebug(outputContent`CLI token received (PCAT). Using it directly for API access...`);
54139
+ let alias = await fetchEmail(identityToken.accessToken) ?? identityToken.userId, session = {
54182
54140
  identity: {
54183
54141
  ...identityToken,
54184
54142
  alias
54185
54143
  },
54186
- applications: result
54144
+ applications: {}
54187
54145
  };
54188
54146
  return outputCompleted("Logged in."), session;
54189
54147
  }
54190
- async function refreshTokens(session, applications) {
54191
- let identityToken = await refreshAccessToken(session.identity), exchangeScopes = getExchangeScopes(applications), applicationTokens = await exchangeAccessForApplicationTokens(identityToken, exchangeScopes, applications.adminApi?.storeFqdn);
54148
+ async function refreshTokens(session, _applications) {
54192
54149
  return {
54193
- identity: identityToken,
54194
- applications: applicationTokens
54150
+ identity: await refreshAccessToken(session.identity),
54151
+ applications: {}
54195
54152
  };
54196
54153
  }
54197
54154
  async function tokensFor(applications, session) {
54198
- let tokens = {
54199
- userId: session.identity.userId
54155
+ let token = session.identity.accessToken;
54156
+ return {
54157
+ userId: session.identity.userId,
54158
+ admin: applications.adminApi ? { token, storeFqdn: applications.adminApi.storeFqdn } : void 0,
54159
+ partners: applications.partnersApi ? token : void 0,
54160
+ storefront: applications.storefrontRendererApi ? token : void 0,
54161
+ businessPlatform: applications.businessPlatformApi ? token : void 0,
54162
+ appManagement: applications.appManagementApi ? token : void 0
54200
54163
  };
54201
- if (applications.adminApi) {
54202
- let appId = applicationId("admin"), realAppId = `${applications.adminApi.storeFqdn}-${appId}`, token = session.applications[realAppId]?.accessToken;
54203
- token && (tokens.admin = { token, storeFqdn: applications.adminApi.storeFqdn });
54204
- }
54205
- if (applications.partnersApi) {
54206
- let appId = applicationId("partners");
54207
- tokens.partners = session.applications[appId]?.accessToken;
54208
- }
54209
- if (applications.storefrontRendererApi) {
54210
- let appId = applicationId("storefront-renderer");
54211
- tokens.storefront = session.applications[appId]?.accessToken;
54212
- }
54213
- if (applications.businessPlatformApi) {
54214
- let appId = applicationId("business-platform");
54215
- tokens.businessPlatform = session.applications[appId]?.accessToken;
54216
- }
54217
- if (applications.appManagementApi) {
54218
- let appId = applicationId("app-management");
54219
- tokens.appManagement = session.applications[appId]?.accessToken;
54220
- }
54221
- return tokens;
54222
54164
  }
54223
54165
  function getFlattenScopes(apps) {
54224
54166
  let admin = apps.adminApi?.scopes ?? [], partner = apps.partnersApi?.scopes ?? [], storefront = apps.storefrontRendererApi?.scopes ?? [], businessPlatform = apps.businessPlatformApi?.scopes ?? [], appManagement = apps.appManagementApi?.scopes ?? [], requestedScopes = [...admin, ...partner, ...storefront, ...businessPlatform, ...appManagement];
54225
54167
  return allDefaultScopes(requestedScopes);
54226
54168
  }
54227
- function getExchangeScopes(apps) {
54228
- let adminScope = apps.adminApi?.scopes ?? [], partnerScope = apps.partnersApi?.scopes ?? [], storefrontScopes = apps.storefrontRendererApi?.scopes ?? [], businessPlatformScopes = apps.businessPlatformApi?.scopes ?? [], appManagementScopes = apps.appManagementApi?.scopes ?? [];
54229
- return {
54230
- admin: apiScopes("admin", adminScope),
54231
- partners: apiScopes("partners", partnerScope),
54232
- storefront: apiScopes("storefront-renderer", storefrontScopes),
54233
- businessPlatform: apiScopes("business-platform", businessPlatformScopes),
54234
- appManagement: apiScopes("app-management", appManagementScopes)
54235
- };
54236
- }
54237
54169
  function buildIdentityTokenFromEnv(scopes, identityTokenInformation) {
54238
54170
  return {
54239
54171
  ...identityTokenInformation,
@@ -54318,8 +54250,6 @@ init_cjs_shims();
54318
54250
 
54319
54251
  // ../cli-kit/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js
54320
54252
  init_cjs_shims();
54321
- var import_sdk_metrics = __toESM(require_src3(), 1), import_core = __toESM(require_src(), 1);
54322
- init_esm();
54323
54253
 
54324
54254
  // ../cli-kit/dist/public/node/vendor/otel-js/utils/throttle.js
54325
54255
  init_cjs_shims();
@@ -54338,16 +54268,14 @@ function throttle(func, wait, { leading = !0, trailing = !0 } = {}) {
54338
54268
  }
54339
54269
 
54340
54270
  // ../cli-kit/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js
54271
+ var import_sdk_metrics = __toESM(require_src3(), 1), import_core = __toESM(require_src(), 1);
54272
+ init_esm();
54341
54273
  var InstantaneousMetricReader = class extends import_sdk_metrics.MetricReader {
54342
54274
  constructor({ exporter, throttleLimit }) {
54343
54275
  super({
54344
54276
  aggregationSelector: exporter.selectAggregation?.bind(exporter),
54345
54277
  aggregationTemporalitySelector: exporter.selectAggregationTemporality?.bind(exporter)
54346
- }), this._exporter = exporter, this.onForceFlush = throttle(
54347
- // eslint-disable-next-line @typescript-eslint/unbound-method
54348
- this.onForceFlush,
54349
- throttleLimit
54350
- );
54278
+ }), this._exporter = exporter, this.onForceFlush = throttle(this.onForceFlush, throttleLimit);
54351
54279
  }
54352
54280
  async onForceFlush() {
54353
54281
  let { resourceMetrics, errors } = await this.collect({});
@@ -54392,7 +54320,6 @@ var DefaultMeterProvider = class extends import_sdk_metrics2.MeterProvider {
54392
54320
 
54393
54321
  // ../cli-kit/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js
54394
54322
  init_cjs_shims();
54395
- var import_sdk_metrics3 = __toESM(require_src3(), 1);
54396
54323
 
54397
54324
  // ../cli-kit/dist/public/node/vendor/otel-js/utils/validators.js
54398
54325
  init_cjs_shims();
@@ -54404,9 +54331,16 @@ function isValidMetricName(value) {
54404
54331
  }
54405
54332
 
54406
54333
  // ../cli-kit/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js
54407
- var instrumentationScope = "opentelemetry-js-shopify-web", BaseOtelService = class {
54334
+ var import_sdk_metrics3 = __toESM(require_src3(), 1), instrumentationScope = "opentelemetry-js-shopify-web", BaseOtelService = class {
54408
54335
  /**
54409
54336
  * Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.
54337
+ *
54338
+ * @param root0
54339
+ * @param root0.serviceName
54340
+ * @param root0.prefixMetric
54341
+ * @param root0.metrics
54342
+ * @param root0.onRecord
54343
+ * @param root0.meterProvider
54410
54344
  */
54411
54345
  constructor({ serviceName, prefixMetric = !1, metrics: metrics2 = {}, onRecord, meterProvider }) {
54412
54346
  if (this.metrics = /* @__PURE__ */ new Map(), this.recordListeners = /* @__PURE__ */ new Set(), !serviceName)
@@ -54486,6 +54420,17 @@ init_esm();
54486
54420
  var DefaultOtelService = class extends BaseOtelService {
54487
54421
  /**
54488
54422
  * Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.
54423
+ *
54424
+ * @param root0
54425
+ * @param root0.throttleLimit
54426
+ * @param root0.env
54427
+ * @param root0.serviceName
54428
+ * @param root0.prefixMetric
54429
+ * @param root0.metrics
54430
+ * @param root0.onRecord
54431
+ * @param root0.meterProvider
54432
+ * @param root0.useXhr
54433
+ * @param root0.otelEndpoint
54489
54434
  */
54490
54435
  constructor({
54491
54436
  throttleLimit = 5e3,
@@ -54878,7 +54823,6 @@ export {
54878
54823
  shopifyFetch,
54879
54824
  fanoutHooks,
54880
54825
  getListOfTunnelPlugins,
54881
- serviceEnvironment,
54882
54826
  z,
54883
54827
  DevServerCore,
54884
54828
  partnersFqdn,
@@ -54955,4 +54899,4 @@ mime-types/index.js:
54955
54899
  * MIT Licensed
54956
54900
  *)
54957
54901
  */
54958
- //# sourceMappingURL=chunk-XKZES4F6.js.map
54902
+ //# sourceMappingURL=chunk-CCWLFNWN.js.map
@@ -122,6 +122,15 @@ var _EXTNAME_RE = /.(\.[^./]+)$/, extname = function(p) {
122
122
  var basename = function(p, extension) {
123
123
  let lastSegment = normalizeWindowsPath(p).split("/").pop();
124
124
  return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
125
+ }, parse = function(p) {
126
+ let root = normalizeWindowsPath(p).split("/").shift() || "/", base = basename(p), extension = extname(base);
127
+ return {
128
+ root,
129
+ dir: dirname(p),
130
+ base,
131
+ ext: extension,
132
+ name: base.slice(0, base.length - extension.length)
133
+ };
125
134
  };
126
135
 
127
136
  // ../cli-kit/dist/public/node/path.js
@@ -150,6 +159,9 @@ function basename2(path2, ext) {
150
159
  function extname2(path2) {
151
160
  return extname(path2);
152
161
  }
162
+ function parsePath(path2) {
163
+ return parse(path2);
164
+ }
153
165
  function relativizePath(path2, dir = cwd2()) {
154
166
  let result = (0, import_commondir.default)([path2, dir]), relativePath2 = relative(dir, path2), relativeComponents = relativePath2.split("/").filter((component) => component === "..").length;
155
167
  return result === "/" || relativePath2 === "" || relativeComponents > 2 ? path2 : relativePath2;
@@ -186,6 +198,7 @@ export {
186
198
  dirname2 as dirname,
187
199
  basename2 as basename,
188
200
  extname2 as extname,
201
+ parsePath,
189
202
  relativizePath,
190
203
  isSubpath,
191
204
  moduleDirectory,
@@ -193,4 +206,4 @@ export {
193
206
  sniffForPath,
194
207
  sniffForJson
195
208
  };
196
- //# sourceMappingURL=chunk-Y2JP6WFP.js.map
209
+ //# sourceMappingURL=chunk-CFNYEDC6.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getNextDeprecationDate,
3
3
  reportAnalyticsEvent
4
- } from "./chunk-XKZES4F6.js";
4
+ } from "./chunk-CCWLFNWN.js";
5
5
  import {
6
6
  addSensitiveMetadata,
7
7
  getAllSensitiveMetadata,
8
8
  outputDebug,
9
9
  renderWarning
10
- } from "./chunk-NSOYPXEP.js";
10
+ } from "./chunk-RIXXPHKS.js";
11
11
  import {
12
12
  init_cjs_shims
13
13
  } from "./chunk-PKR7KJ6P.js";
@@ -75,4 +75,4 @@ export {
75
75
  postRunHookHasCompleted,
76
76
  hook
77
77
  };
78
- //# sourceMappingURL=chunk-VGSXEE45.js.map
78
+ //# sourceMappingURL=chunk-QYFBWGDH.js.map