@friggframework/core 2.0.0--canary.623.0155fc6.0 → 2.0.0--canary.623.92936ad.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) {
@@ -11,8 +12,6 @@ class Requester extends Delegate {
11
12
  this.backOff = get(params, 'backOff', [1, 3, 10, 30, 60, 180]);
12
13
  this.isRefreshable = false;
13
14
  this.refreshCount = 0;
14
- // Deliberately separate from `i` — a 429/5xx retry must not consume
15
- // the 401 grace retry budget below.
16
15
  this.authGraceRetryCount = 0;
17
16
  this.DLGT_INVALID_AUTH = 'INVALID_AUTH';
18
17
  this.delegateTypes.push(this.DLGT_INVALID_AUTH);
@@ -62,6 +61,10 @@ class Requester extends Delegate {
62
61
  };
63
62
 
64
63
  /**
64
+ * @param {string} url - The request URL, relative or absolute.
65
+ * @param {Object} options - Fetch options (method, headers, body, query,
66
+ * returnFullRes, etc.) built by the `_get`/`_post`/`_patch`/`_put`/
67
+ * `_delete` wrappers.
65
68
  * @param {number} attempt - 0-based count of retries already made for
66
69
  * this call. Indexes `this.backOff` for the next delay and is passed
67
70
  * back in on each recursive retry.
@@ -163,12 +166,13 @@ class Requester extends Delegate {
163
166
 
164
167
  if (status === 401) {
165
168
  if (!this.isRefreshable) {
166
- // One grace retry before invalidating — a single 401
167
- // isn't proof the credential is bad.
168
- if (this.authGraceRetryCount === 0) {
169
+ // Up to MAX_AUTH_RETRIES grace retries before invalidating
170
+ // — a 401 alone isn't proof the credential is bad.
171
+ if (this.authGraceRetryCount < MAX_AUTH_RETRIES) {
172
+ const delay =
173
+ this.backOff[this.authGraceRetryCount] * 1000;
169
174
  this.authGraceRetryCount++;
170
175
  clearRequestTimer();
171
- const delay = this.backOff[0] * 1000;
172
176
  await new Promise((resolve) =>
173
177
  setTimeout(resolve, delay)
174
178
  );
@@ -182,7 +186,7 @@ class Requester extends Delegate {
182
186
  );
183
187
  }
184
188
 
185
- if (this.refreshCount === 0) {
189
+ if (this.refreshCount < MAX_AUTH_RETRIES) {
186
190
  this.refreshCount++;
187
191
  const refreshSucceeded = await this.refreshAuth();
188
192
  if (refreshSucceeded) {
@@ -196,6 +200,8 @@ class Requester extends Delegate {
196
200
  response
197
201
  );
198
202
  }
203
+
204
+ throw await this._invalidateAuth(encodedUrl, options, response);
199
205
  }
200
206
 
201
207
  // 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.0155fc6.0",
4
+ "version": "2.0.0--canary.623.92936ad.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.0155fc6.0",
42
- "@friggframework/prettier-config": "2.0.0--canary.623.0155fc6.0",
43
- "@friggframework/test": "2.0.0--canary.623.0155fc6.0",
41
+ "@friggframework/eslint-config": "2.0.0--canary.623.92936ad.0",
42
+ "@friggframework/prettier-config": "2.0.0--canary.623.92936ad.0",
43
+ "@friggframework/test": "2.0.0--canary.623.92936ad.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": "0155fc63dbd76e4e6fad4f53abdbbf9b18f7c6bd"
83
+ "gitHead": "92936ad4239d3ba8127bc1f5f1066deaf60ae62e"
84
84
  }