arcadible 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/account.js +15 -5
package/package.json CHANGED
@@ -65,5 +65,5 @@
65
65
  "scripts": {
66
66
  "test": "node --test \"test/**/*.test.js\""
67
67
  },
68
- "version": "1.0.7"
68
+ "version": "1.0.8"
69
69
  }
package/src/account.js CHANGED
@@ -168,10 +168,13 @@ const get = function (onRefresh) {
168
168
  // [function]
169
169
 
170
170
  // a failed request's handler for commands that send the saved session's
171
- // token: the API refuses it (401) only when Supabase does, such as for a
172
- // deleted account, so the session is over. It's removed, and the error says
173
- // to log in, rather than api_refused. An ARC_TOKEN's refusal stays as it is,
174
- // since logging in doesn't change the token.
171
+ // token. The API refuses it (401) only when Supabase does: for a deleted
172
+ // account, or a token that expired by the server's clock though not by
173
+ // this one's. A refresh tells them apart: refused, the session is over, so
174
+ // it's removed and the error says to log in (session_expired); renewed, the
175
+ // session is kept, and the request's own error stands, so running the
176
+ // command again works. An ARC_TOKEN's refusal stays as it is, since logging
177
+ // in doesn't change the token.
175
178
  const ended = function (current) {
176
179
  return (ex) => {
177
180
  if (
@@ -182,7 +185,14 @@ const ended = function (current) {
182
185
  ) {
183
186
  throw ex;
184
187
  }
185
- return expire(ex);
188
+ return refresh(current).then(
189
+ () => {
190
+ throw ex;
191
+ },
192
+ (refreshEx) => {
193
+ throw refreshEx instanceof ArcError ? refreshEx : ex;
194
+ },
195
+ );
186
196
  };
187
197
  };
188
198