@shopify/create-app 3.78.2 → 3.79.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.
@@ -9,7 +9,7 @@ import {
9
9
  packageManagerFromUserAgent,
10
10
  removeSession,
11
11
  setSession
12
- } from "./chunk-WHWAKQQY.js";
12
+ } from "./chunk-DOJFJSIT.js";
13
13
  import {
14
14
  AbortError,
15
15
  BugError,
@@ -17,24 +17,20 @@ import {
17
17
  FatalError,
18
18
  addPublicMetadata,
19
19
  addSensitiveMetadata,
20
- blockPartnersAccess,
21
20
  ciPlatform,
22
21
  cloudEnvironment,
23
22
  currentProcessIsGlobal,
23
+ environmentVariables,
24
24
  firstPartyDev,
25
- getIdentityTokenInformation,
26
- getPartnersToken,
27
- hashString,
28
25
  import_ts_error,
29
- isAppManagementDisabled,
30
26
  isCI,
31
27
  isCloudEnvironment,
32
28
  isSpin,
33
29
  isTTY,
30
+ isTruthy,
31
+ isWsl,
34
32
  keypress,
35
33
  macAddress,
36
- maxRequestTimeForNetworkCallsMs,
37
- nonRandomUUID,
38
34
  openURL,
39
35
  outputCompleted,
40
36
  outputContent,
@@ -45,13 +41,14 @@ import {
45
41
  runWithTimer,
46
42
  serviceEnvironment,
47
43
  sessionConstants,
48
- skipNetworkLevelRetry,
49
44
  sleep,
50
45
  spinFqdn,
46
+ systemEnvironmentVariables,
51
47
  themeToken
52
- } from "./chunk-NT557SK2.js";
48
+ } from "./chunk-HSB3QV4W.js";
53
49
  import {
54
- cwd
50
+ cwd,
51
+ sniffForJson
55
52
  } from "./chunk-ZUCWDIGE.js";
56
53
  import {
57
54
  __commonJS,
@@ -26951,7 +26948,7 @@ var require_form_data = __commonJS({
26951
26948
 
26952
26949
  // ../cli-kit/dist/public/common/version.js
26953
26950
  init_cjs_shims();
26954
- var CLI_KIT_VERSION = "3.78.2";
26951
+ var CLI_KIT_VERSION = "3.79.0";
26955
26952
 
26956
26953
  // ../cli-kit/dist/private/node/analytics.js
26957
26954
  init_cjs_shims();
@@ -30614,6 +30611,18 @@ function apiScopes(api, extraScopes = []) {
30614
30611
  let scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform);
30615
30612
  return Array.from(new Set(scopes));
30616
30613
  }
30614
+ function tokenExchangeScopes(api) {
30615
+ switch (api) {
30616
+ case "partners":
30617
+ return [scopeTransform("cli")];
30618
+ case "app-management":
30619
+ return [scopeTransform("app-management")];
30620
+ case "business-platform":
30621
+ return [scopeTransform("destinations")];
30622
+ default:
30623
+ throw new BugError(`API not supported for token exchange: ${api}`);
30624
+ }
30625
+ }
30617
30626
  function defaultApiScopes(api) {
30618
30627
  switch (api) {
30619
30628
  case "admin":
@@ -30883,6 +30892,60 @@ function inferenceModeAndProjectIsEdition2016(projectName) {
30883
30892
  }
30884
30893
  }
30885
30894
 
30895
+ // ../cli-kit/dist/public/node/environment.js
30896
+ init_cjs_shims();
30897
+
30898
+ // ../cli-kit/dist/public/node/crypto.js
30899
+ init_cjs_shims();
30900
+ import crypto from "crypto";
30901
+ function hashString(str) {
30902
+ return crypto.createHash("sha1").update(str).digest("hex");
30903
+ }
30904
+ function fileHash(buff) {
30905
+ return crypto.createHash("md5").update(buff).digest("hex");
30906
+ }
30907
+ function randomUUID() {
30908
+ return crypto.randomUUID();
30909
+ }
30910
+ function nonRandomUUID(subject) {
30911
+ return crypto.createHash("sha1").update(Buffer.from("6ba7b810-9dad-11d1-80b4-00c04fd430c8".replace(/-/g, ""), "hex")).update(subject).digest().toString("hex").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
30912
+ }
30913
+
30914
+ // ../cli-kit/dist/public/node/environment.js
30915
+ function getEnvironmentVariables() {
30916
+ return process.env;
30917
+ }
30918
+ function getPartnersToken() {
30919
+ return getEnvironmentVariables()[environmentVariables.partnersToken];
30920
+ }
30921
+ function getBackendPort() {
30922
+ let backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort];
30923
+ if (backendPort && !isNaN(Number(backendPort)))
30924
+ return Number(backendPort);
30925
+ }
30926
+ function getIdentityTokenInformation() {
30927
+ let identityToken = getEnvironmentVariables()[environmentVariables.identityToken], refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken];
30928
+ if (!(!identityToken || !refreshToken))
30929
+ return {
30930
+ accessToken: identityToken,
30931
+ refreshToken,
30932
+ userId: nonRandomUUID(identityToken)
30933
+ };
30934
+ }
30935
+ function jsonOutputEnabled(environment = getEnvironmentVariables()) {
30936
+ return sniffForJson() || isTruthy(environment[environmentVariables.json]);
30937
+ }
30938
+ function blockPartnersAccess() {
30939
+ return isTruthy(getEnvironmentVariables()[environmentVariables.neverUsePartnersApi]);
30940
+ }
30941
+ function skipNetworkLevelRetry(environment = getEnvironmentVariables()) {
30942
+ return isTruthy(environment[environmentVariables.skipNetworkLevelRetry]);
30943
+ }
30944
+ function maxRequestTimeForNetworkCallsMs(environment = getEnvironmentVariables()) {
30945
+ let maxRequestTime = environment[environmentVariables.maxRequestTimeForNetworkCalls];
30946
+ return maxRequestTime && !isNaN(Number(maxRequestTime)) ? Number(maxRequestTime) : 30 * 1e3;
30947
+ }
30948
+
30886
30949
  // ../cli-kit/dist/public/node/context/fqdn.js
30887
30950
  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.");
30888
30951
  async function partnersFqdn() {
@@ -32106,7 +32169,7 @@ async function exchangeAccessForApplicationTokens(identityToken, scopes, store2)
32106
32169
  requestAppToken("storefront-renderer", token, scopes.storefront),
32107
32170
  requestAppToken("business-platform", token, scopes.businessPlatform),
32108
32171
  store2 ? requestAppToken("admin", token, scopes.admin, store2) : {},
32109
- isAppManagementDisabled() ? {} : requestAppToken("app-management", token, scopes.appManagement)
32172
+ requestAppToken("app-management", token, scopes.appManagement)
32110
32173
  ]);
32111
32174
  return {
32112
32175
  ...partners,
@@ -32125,15 +32188,25 @@ async function refreshAccessToken(currentToken) {
32125
32188
  }, value = (await tokenRequest(params)).mapError(tokenRequestErrorHandler).valueOrBug();
32126
32189
  return buildIdentityToken(value, currentToken.userId);
32127
32190
  }
32128
- async function exchangeCustomPartnerToken(token) {
32129
- let appId = applicationId("partners");
32191
+ async function exchangeCliTokenForAccessToken(apiName, token, scopes) {
32192
+ let appId = applicationId(apiName);
32130
32193
  try {
32131
- let accessToken = (await requestAppToken("partners", token, ["https://api.shopify.com/auth/partners.app.cli.access"]))[appId].accessToken, userId2 = nonRandomUUID(token);
32194
+ let accessToken = (await requestAppToken(apiName, token, scopes))[appId].accessToken, userId2 = nonRandomUUID(token);
32132
32195
  return setLastSeenUserIdAfterAuth(userId2), setLastSeenAuthMethod("partners_token"), { accessToken, userId: userId2 };
32133
32196
  } catch {
32134
- throw new AbortError("The custom token provided is invalid.", "Ensure the token is correct and not expired.");
32197
+ let prettyName = apiName.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
32198
+ throw new AbortError(`The custom token provided can't be used for the ${prettyName} API.`, "Ensure the token is correct and not expired.");
32135
32199
  }
32136
32200
  }
32201
+ async function exchangeCustomPartnerToken(token) {
32202
+ return exchangeCliTokenForAccessToken("partners", token, tokenExchangeScopes("partners"));
32203
+ }
32204
+ async function exchangeCliTokenForAppManagementAccessToken(token) {
32205
+ return exchangeCliTokenForAccessToken("app-management", token, tokenExchangeScopes("app-management"));
32206
+ }
32207
+ async function exchangeCliTokenForBusinessPlatformAccessToken(token) {
32208
+ return exchangeCliTokenForAccessToken("business-platform", token, tokenExchangeScopes("business-platform"));
32209
+ }
32137
32210
  async function exchangeDeviceCodeForAccessToken(deviceCode) {
32138
32211
  let clientId2 = await clientId(), tokenResult = await tokenRequest({
32139
32212
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
@@ -32459,7 +32532,8 @@ async function getEnvironmentData(config) {
32459
32532
  env_cloud: cloudEnvironment().platform,
32460
32533
  env_package_manager: await getPackageManager(cwd()),
32461
32534
  env_is_global: currentProcessIsGlobal(),
32462
- env_auth_method: await getLastSeenAuthMethod()
32535
+ env_auth_method: await getLastSeenAuthMethod(),
32536
+ env_is_wsl: await isWsl()
32463
32537
  };
32464
32538
  }
32465
32539
  async function getSensitiveEnvironmentData(config) {
@@ -32478,6 +32552,15 @@ function flagIncluded(flag, commandClass) {
32478
32552
  }
32479
32553
 
32480
32554
  export {
32555
+ hashString,
32556
+ fileHash,
32557
+ randomUUID,
32558
+ nonRandomUUID,
32559
+ getEnvironmentVariables,
32560
+ getPartnersToken,
32561
+ getBackendPort,
32562
+ jsonOutputEnabled,
32563
+ blockPartnersAccess,
32481
32564
  CLI_KIT_VERSION,
32482
32565
  GraphQLClientError,
32483
32566
  sanitizedHeadersOutput,
@@ -32508,6 +32591,8 @@ export {
32508
32591
  ok,
32509
32592
  err,
32510
32593
  exchangeCustomPartnerToken,
32594
+ exchangeCliTokenForAppManagementAccessToken,
32595
+ exchangeCliTokenForBusinessPlatformAccessToken,
32511
32596
  isThemeAccessSession,
32512
32597
  getLastSeenUserIdAfterAuth,
32513
32598
  setLastSeenUserIdAfterAuth,
@@ -32535,4 +32620,4 @@ mime-types/index.js:
32535
32620
  * MIT Licensed
32536
32621
  *)
32537
32622
  */
32538
- //# sourceMappingURL=chunk-PS6NFRCK.js.map
32623
+ //# sourceMappingURL=chunk-7AOB653K.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  fanoutHooks,
3
3
  reportAnalyticsEvent
4
- } from "./chunk-KNEC3BRF.js";
4
+ } from "./chunk-SKROIF4Z.js";
5
5
  import {
6
6
  CLI_KIT_VERSION,
7
7
  getEnvironmentData
8
- } from "./chunk-PS6NFRCK.js";
8
+ } from "./chunk-7AOB653K.js";
9
9
  import {
10
10
  runWithRateLimit
11
- } from "./chunk-WHWAKQQY.js";
11
+ } from "./chunk-DOJFJSIT.js";
12
12
  import {
13
13
  AbortSilentError,
14
14
  CancelExecution,
@@ -23,7 +23,7 @@ import {
23
23
  reportingRateLimit,
24
24
  require_stacktracey,
25
25
  shouldReportErrorAsUnexpected
26
- } from "./chunk-NT557SK2.js";
26
+ } from "./chunk-HSB3QV4W.js";
27
27
  import {
28
28
  require_lib
29
29
  } from "./chunk-S3QEOIDU.js";
@@ -2121,7 +2121,11 @@ function initializeBugsnag() {
2121
2121
  appVersion: CLI_KIT_VERSION,
2122
2122
  autoTrackSessions: !1,
2123
2123
  autoDetectErrors: !1,
2124
- enabledReleaseStages: ["production"]
2124
+ enabledReleaseStages: ["production"],
2125
+ endpoints: {
2126
+ notify: "https://error-analytics-production.shopifysvc.com",
2127
+ sessions: "https://error-analytics-sessions-production.shopifysvc.com"
2128
+ }
2125
2129
  });
2126
2130
  }
2127
2131
 
@@ -2133,4 +2137,4 @@ export {
2133
2137
  registerCleanBugsnagErrorsFromWithinPlugins,
2134
2138
  addBugsnagMetadata
2135
2139
  };
2136
- //# sourceMappingURL=chunk-EQR72MUQ.js.map
2140
+ //# sourceMappingURL=chunk-BE7EA5HD.js.map