@friggframework/core 2.0.0--canary.623.ce8e6ae.0 → 2.0.0--canary.623.9b7cdf7.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,6 +4,7 @@ const { FetchError } = require('../../errors');
4
4
  const { get } = require('../../assertions');
5
5
 
6
6
  const DEFAULT_REQUEST_TIMEOUT_MS = 60_000;
7
+ const MAX_AUTH_RETRIES = 3;
7
8
 
8
9
  class Requester extends Delegate {
9
10
  constructor(params) {
@@ -61,6 +62,11 @@ class Requester extends Delegate {
61
62
  return resp.text();
62
63
  };
63
64
 
65
+ /**
66
+ * @param {number} attempt - 0-based count of retries already made for
67
+ * this call. Indexes `this.backOff` for the next delay and is passed
68
+ * back in on each recursive retry.
69
+ */
64
70
  async _request(url, options, attempt = 0) {
65
71
  let encodedUrl = encodeURI(url);
66
72
  if (options.query) {
@@ -158,12 +164,13 @@ class Requester extends Delegate {
158
164
 
159
165
  if (status === 401) {
160
166
  if (!this.isRefreshable) {
161
- // One grace retry before invalidating — a single 401
162
- // isn't proof the credential is bad.
163
- if (this.authGraceRetryCount === 0) {
167
+ // Up to MAX_AUTH_RETRIES grace retries before invalidating
168
+ // — a 401 alone isn't proof the credential is bad.
169
+ if (this.authGraceRetryCount < MAX_AUTH_RETRIES) {
170
+ const delay =
171
+ this.backOff[this.authGraceRetryCount] * 1000;
164
172
  this.authGraceRetryCount++;
165
173
  clearRequestTimer();
166
- const delay = this.backOff[0] * 1000;
167
174
  await new Promise((resolve) =>
168
175
  setTimeout(resolve, delay)
169
176
  );
@@ -177,7 +184,7 @@ class Requester extends Delegate {
177
184
  );
178
185
  }
179
186
 
180
- if (this.refreshCount === 0) {
187
+ if (this.refreshCount < MAX_AUTH_RETRIES) {
181
188
  this.refreshCount++;
182
189
  const refreshSucceeded = await this.refreshAuth();
183
190
  if (refreshSucceeded) {
@@ -191,6 +198,8 @@ class Requester extends Delegate {
191
198
  response
192
199
  );
193
200
  }
201
+
202
+ throw await this._invalidateAuth(encodedUrl, options, response);
194
203
  }
195
204
 
196
205
  // If the error wasn't retried, throw. FetchError.create reads
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.623.ce8e6ae.0",
4
+ "version": "2.0.0--canary.623.9b7cdf7.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0--canary.623.ce8e6ae.0",
42
- "@friggframework/prettier-config": "2.0.0--canary.623.ce8e6ae.0",
43
- "@friggframework/test": "2.0.0--canary.623.ce8e6ae.0",
41
+ "@friggframework/eslint-config": "2.0.0--canary.623.9b7cdf7.0",
42
+ "@friggframework/prettier-config": "2.0.0--canary.623.9b7cdf7.0",
43
+ "@friggframework/test": "2.0.0--canary.623.9b7cdf7.0",
44
44
  "@prisma/client": "^6.19.3",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "ce8e6ae7f60121290cc48fd3f36653fd18790204"
83
+ "gitHead": "9b7cdf7b3bcdcd7746a50c30519d2eebe16db23d"
84
84
  }