@shopify/cli-kit 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 1.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - df1c523: Re-authenticate if Identity returns an invalid grant error
8
+
3
9
  ## 1.0.8
4
10
 
5
11
  ### Patch Changes
@@ -45476,7 +45476,7 @@ function isTruthy(variable) {
45476
45476
  }
45477
45477
 
45478
45478
  var name = "@shopify/cli-kit";
45479
- var version$2 = "1.0.8";
45479
+ var version$2 = "1.0.9";
45480
45480
  var description$1 = "A set of utilities, interfaces, and models that are common across all the platform features";
45481
45481
  var keywords = [
45482
45482
  "shopify",
@@ -45578,9 +45578,9 @@ var cliKitPackageJson = {
45578
45578
  devDependencies: devDependencies
45579
45579
  };
45580
45580
 
45581
- var version$1 = "1.0.8";
45581
+ var version$1 = "1.0.9";
45582
45582
 
45583
- var version = "1.0.8";
45583
+ var version = "1.0.9";
45584
45584
 
45585
45585
  const constants = {
45586
45586
  environmentVariables: {
@@ -50737,7 +50737,7 @@ class Body$1 {
50737
50737
  return formData;
50738
50738
  }
50739
50739
 
50740
- const {toFormData} = await import('./multipart-parser-20740124.js');
50740
+ const {toFormData} = await import('./multipart-parser-305a2ce9.js');
50741
50741
  return toFormData(this.body, ct);
50742
50742
  }
50743
50743
 
@@ -52495,6 +52495,8 @@ var http$1 = /*#__PURE__*/Object.freeze({
52495
52495
  fetch: fetch$3
52496
52496
  });
52497
52497
 
52498
+ class InvalidGrantError extends Error {
52499
+ }
52498
52500
  async function exchangeCodeForAccessToken(codeData) {
52499
52501
  const clientId$1 = await clientId();
52500
52502
  const params = {
@@ -52560,10 +52562,15 @@ async function tokenRequest(params) {
52560
52562
  const url = new URL(`https://${fqdn}/oauth/token`);
52561
52563
  url.search = new URLSearchParams(Object.entries(params)).toString();
52562
52564
  const res = await fetch$3(url.href, { method: "POST" });
52565
+ const payload = await res.json();
52563
52566
  if (!res.ok) {
52564
- throw new Abort(`HTTP ${res.status}`);
52567
+ if (payload.error === "invalid_grant") {
52568
+ throw new InvalidGrantError(payload.error_description);
52569
+ } else {
52570
+ throw new Abort(payload.error_description);
52571
+ }
52565
52572
  }
52566
- return res.json();
52573
+ return payload;
52567
52574
  }
52568
52575
  function buildIdentityToken(result) {
52569
52576
  return {
@@ -55670,7 +55677,15 @@ async function ensureAuthenticated(applications, env = process.env) {
55670
55677
  if (needFullAuth) {
55671
55678
  newSession = await executeCompleteFlow(applications, fqdn);
55672
55679
  } else if (sessionIsInvalid) {
55673
- newSession = await refreshTokens(fqdnSession.identity, applications, fqdn);
55680
+ try {
55681
+ newSession = await refreshTokens(fqdnSession.identity, applications, fqdn);
55682
+ } catch (error) {
55683
+ if (error instanceof InvalidGrantError) {
55684
+ newSession = await executeCompleteFlow(applications, fqdn);
55685
+ } else {
55686
+ throw error;
55687
+ }
55688
+ }
55674
55689
  }
55675
55690
  const completeSession = { ...currentSession, ...newSession };
55676
55691
  await store$1(completeSession);
@@ -165713,4 +165728,4 @@ var checksum = /*#__PURE__*/Object.freeze({
165713
165728
  });
165714
165729
 
165715
165730
  export { FormData$2 as F, File$1 as a, string$2 as b, os$2 as c, dependency as d, error$k as e, file$1 as f, git as g, environment as h, session as i, schema$1 as j, toml as k, tunnel as l, store as m, api as n, output$1 as o, path$q as p, http$1 as q, checksum as r, system as s, template as t, ui as u, version$3 as v, constants as w };
165716
- //# sourceMappingURL=index-500e8461.js.map
165731
+ //# sourceMappingURL=index-73f2dc55.js.map