@sjawhar/claude-envoy 5.32.0 → 5.32.1
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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +10565 -10455
- package/dist/dispatch.js +9609 -9499
- package/dist/envoy-channel.js +152 -42
- package/dist/session-hook.js +149 -39
- package/package.json +1 -1
package/dist/session-hook.js
CHANGED
|
@@ -2925,6 +2925,23 @@ async function genericGrantRequest(config, grantType, parameters, options) {
|
|
|
2925
2925
|
return result;
|
|
2926
2926
|
}
|
|
2927
2927
|
|
|
2928
|
+
// ../cipher-client/src/oauth-refusal.ts
|
|
2929
|
+
var INVALID_GRANT = "invalid_grant";
|
|
2930
|
+
var REQUEST_TIMEOUT = 408;
|
|
2931
|
+
var TOO_MANY_REQUESTS = 429;
|
|
2932
|
+
function outage(status) {
|
|
2933
|
+
return status >= 500 || status === REQUEST_TIMEOUT || status === TOO_MANY_REQUESTS;
|
|
2934
|
+
}
|
|
2935
|
+
function refusalCode(error) {
|
|
2936
|
+
if (!(error instanceof ResponseBodyError))
|
|
2937
|
+
return "";
|
|
2938
|
+
const refuses = error.status >= 400 && error.status < 500 && !outage(error.status);
|
|
2939
|
+
return refuses ? error.error : "";
|
|
2940
|
+
}
|
|
2941
|
+
function endsGrant(error) {
|
|
2942
|
+
return error instanceof ResponseBodyError && error.error === INVALID_GRANT && (error.status === 400 || error.status === 401);
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2928
2945
|
// ../cipher-client/src/wire.ts
|
|
2929
2946
|
var TOKEN_PATH = "/v1/oauth/token";
|
|
2930
2947
|
var GRANT_TYPE_TOKEN_EXCHANGE = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
@@ -3272,10 +3289,9 @@ async function signInFlow(env) {
|
|
|
3272
3289
|
}
|
|
3273
3290
|
|
|
3274
3291
|
// ../cipher-client/src/token-errors.ts
|
|
3275
|
-
var TOO_MANY_REQUESTS = 429;
|
|
3276
3292
|
var INVALID_DPOP_PROOF = "invalid_dpop_proof";
|
|
3277
3293
|
var USE_DPOP_NONCE = "use_dpop_nonce";
|
|
3278
|
-
var
|
|
3294
|
+
var INVALID_GRANT2 = "invalid_grant";
|
|
3279
3295
|
var MEMBERSHIP_HELD = "membership_held";
|
|
3280
3296
|
var TOKEN_NOT_VALID = "Token is not valid or has expired.";
|
|
3281
3297
|
var MACHINE_LOGIN_ENDED = "The machine login the subject token belongs to has ended.";
|
|
@@ -3296,11 +3312,11 @@ class BrokerRefusedError extends Error {
|
|
|
3296
3312
|
this.code = KNOWN_OAUTH_ERROR_CODES.has(code) ? code : "";
|
|
3297
3313
|
this.shownCode = shownCode;
|
|
3298
3314
|
this.said = said;
|
|
3299
|
-
this.podSessionUnregistered = code ===
|
|
3300
|
-
this.subjectNotHonoured = status === 400 && (code === "invalid_request" && description.endsWith(TOKEN_NOT_VALID) || code ===
|
|
3315
|
+
this.podSessionUnregistered = code === INVALID_GRANT2 && description.startsWith(`${POD_SESSION_NOT_REGISTERED}:`);
|
|
3316
|
+
this.subjectNotHonoured = status === 400 && (code === "invalid_request" && description.endsWith(TOKEN_NOT_VALID) || code === INVALID_GRANT2 && description.endsWith(MACHINE_LOGIN_ENDED));
|
|
3301
3317
|
}
|
|
3302
3318
|
get permanent() {
|
|
3303
|
-
return this.status
|
|
3319
|
+
return !outage(this.status) && this.code !== INVALID_DPOP_PROOF && this.code !== USE_DPOP_NONCE && this.code !== MEMBERSHIP_HELD && !this.podSessionUnregistered;
|
|
3304
3320
|
}
|
|
3305
3321
|
}
|
|
3306
3322
|
|
|
@@ -3372,19 +3388,22 @@ function isFinalRefusal(error) {
|
|
|
3372
3388
|
|
|
3373
3389
|
// ../cipher-client/src/broker-request.ts
|
|
3374
3390
|
var BROKER_URL_SETTING = "the broker URL";
|
|
3375
|
-
function
|
|
3391
|
+
function responseOf(error) {
|
|
3376
3392
|
let cause = error;
|
|
3377
3393
|
for (let depth = 0;depth < 4; depth += 1) {
|
|
3378
3394
|
if (cause instanceof Response)
|
|
3379
|
-
return cause
|
|
3395
|
+
return cause;
|
|
3380
3396
|
if (cause instanceof ResponseBodyError || cause instanceof WWWAuthenticateChallengeError) {
|
|
3381
|
-
return cause.
|
|
3397
|
+
return cause.response;
|
|
3382
3398
|
}
|
|
3383
3399
|
if (typeof cause !== "object" || cause === null || !("cause" in cause))
|
|
3384
|
-
return
|
|
3400
|
+
return;
|
|
3385
3401
|
cause = cause.cause;
|
|
3386
3402
|
}
|
|
3387
|
-
return
|
|
3403
|
+
return;
|
|
3404
|
+
}
|
|
3405
|
+
function statusOf(error) {
|
|
3406
|
+
return responseOf(error)?.status ?? 0;
|
|
3388
3407
|
}
|
|
3389
3408
|
function brokerRefusal(doing, refused, endpoint, error, context = {}) {
|
|
3390
3409
|
if (error instanceof ResponseBodyError && error.status >= 400 && error.status < 500) {
|
|
@@ -32880,6 +32899,66 @@ async function calculateJwkThumbprint(key, digestAlgorithm) {
|
|
|
32880
32899
|
const data = encode(JSON.stringify(components));
|
|
32881
32900
|
return encode2(await digest(digestAlgorithm, data));
|
|
32882
32901
|
}
|
|
32902
|
+
// ../cipher-client/src/device-login-reach.ts
|
|
32903
|
+
var DEFAULT_POLL_SECONDS = 5;
|
|
32904
|
+
var LEAST_POLL_SECONDS = 1;
|
|
32905
|
+
var MOST_LIFETIME_SECONDS = 3600;
|
|
32906
|
+
function seconds(value) {
|
|
32907
|
+
const [mantissa = "", exponent] = String(value).split("e");
|
|
32908
|
+
if (exponent === undefined)
|
|
32909
|
+
return mantissa;
|
|
32910
|
+
const [whole = "", fraction = ""] = mantissa.split(".");
|
|
32911
|
+
const point = whole.length + Number(exponent);
|
|
32912
|
+
const digits = whole + fraction;
|
|
32913
|
+
return point <= 0 ? `0.${"0".repeat(-point)}${digits}` : digits.padEnd(point, "0");
|
|
32914
|
+
}
|
|
32915
|
+
function wholeMillisecondsOf(value) {
|
|
32916
|
+
const [whole = "", fraction = ""] = seconds(value).split(".");
|
|
32917
|
+
return Number(`${whole}${fraction.slice(0, 3).padEnd(3, "0")}`);
|
|
32918
|
+
}
|
|
32919
|
+
function waitMillisecondsOf(value) {
|
|
32920
|
+
return wholeMillisecondsOf(value) + (pastTheMillisecond(value) ? 1 : 0);
|
|
32921
|
+
}
|
|
32922
|
+
function pastTheMillisecond(value) {
|
|
32923
|
+
return /\.\d{3}\d*[1-9]/.test(seconds(value));
|
|
32924
|
+
}
|
|
32925
|
+
function codeLeft(expiresAt, intervalSeconds, now) {
|
|
32926
|
+
const named = expiresAt.getTime() - now;
|
|
32927
|
+
const left = Math.min(named, MOST_LIFETIME_SECONDS * 1000);
|
|
32928
|
+
return { named, left, reached: waitMillisecondsOf(intervalSeconds) < left };
|
|
32929
|
+
}
|
|
32930
|
+
function unpollableRemedy(named, intervalSeconds, lifetimeSeconds, left) {
|
|
32931
|
+
const outlivesLeast = left > LEAST_POLL_SECONDS * 1000;
|
|
32932
|
+
const wait = waitMillisecondsOf(intervalSeconds);
|
|
32933
|
+
const pastWait = pastTheMillisecond(intervalSeconds) ? `${seconds(wait / 1000)} s, its poll interval counted up to a whole millisecond` : "its poll interval";
|
|
32934
|
+
const underEnd = pastTheMillisecond(lifetimeSeconds) ? `${seconds(left / 1000)} s, its codes' lifetime counted down to a whole millisecond` : "its codes' lifetime";
|
|
32935
|
+
if (named === undefined) {
|
|
32936
|
+
return outlivesLeast ? `it names a poll interval a millisecond or more shorter than ${underEnd}, or its codes live a millisecond or more longer than ${DEFAULT_POLL_SECONDS} s` : `its codes live a millisecond or more longer than ${DEFAULT_POLL_SECONDS} s, or a millisecond or more longer than both ${LEAST_POLL_SECONDS} s and a poll interval it names, counted up to a whole millisecond`;
|
|
32937
|
+
}
|
|
32938
|
+
if (wait === LEAST_POLL_SECONDS * 1000) {
|
|
32939
|
+
return `its codes live a millisecond or more longer than ${LEAST_POLL_SECONDS} s, the least poll interval this machine keeps`;
|
|
32940
|
+
}
|
|
32941
|
+
if (outlivesLeast)
|
|
32942
|
+
return `its poll interval is a millisecond or more shorter than ${underEnd}`;
|
|
32943
|
+
return wait >= MOST_LIFETIME_SECONDS * 1000 ? `its poll interval is a millisecond or more shorter than an hour and its codes live a millisecond or more longer than both ${LEAST_POLL_SECONDS} s and that interval, counted up to a whole millisecond` : `its codes live a millisecond or more longer than ${pastWait}`;
|
|
32944
|
+
}
|
|
32945
|
+
function unpollableAnswer(answered, intervalSeconds, lifetimeSeconds, left) {
|
|
32946
|
+
const named = answered.interval;
|
|
32947
|
+
const interval = named === undefined ? `no poll interval, so one of ${DEFAULT_POLL_SECONDS} s` : named < intervalSeconds ? `a poll interval of ${seconds(named)} s, so one of ${LEAST_POLL_SECONDS} s` : `a poll interval of ${seconds(named)} s`;
|
|
32948
|
+
const lapses = "the code would lapse before its first poll";
|
|
32949
|
+
const verdict = "no device login works at that broker until";
|
|
32950
|
+
const hour = lifetimeSeconds < answered.expires_in;
|
|
32951
|
+
const remedy = hour ? "its poll interval is a millisecond or more shorter than an hour" : unpollableRemedy(named, intervalSeconds, lifetimeSeconds, left);
|
|
32952
|
+
if (lifetimeSeconds <= 0) {
|
|
32953
|
+
return `a device code that had already lapsed, with ${interval}; ${verdict} ${remedy}`;
|
|
32954
|
+
}
|
|
32955
|
+
const answer = hour ? `${interval}, and this machine polls a device code for an hour at most` : `a device code that lives ${seconds(lifetimeSeconds)} s, with ${interval}`;
|
|
32956
|
+
if (intervalSeconds < lifetimeSeconds) {
|
|
32957
|
+
return `${answer}, under two milliseconds apart: ${lapses}, as this machine counts a poll's wait up and a code's end down to a whole millisecond; ${verdict} ${remedy}`;
|
|
32958
|
+
}
|
|
32959
|
+
return `${answer}: ${lapses}; ${verdict} ${remedy}`;
|
|
32960
|
+
}
|
|
32961
|
+
|
|
32883
32962
|
// ../cipher-client/src/dpop.ts
|
|
32884
32963
|
import {
|
|
32885
32964
|
createHash,
|
|
@@ -32966,10 +33045,6 @@ function leastAccessLifeMs(leastLifeMs, lifeSeconds) {
|
|
|
32966
33045
|
return Math.max(ACCESS_MARGIN_MS, Math.min(leastLifeMs, lifeSeconds * 1000 / 2));
|
|
32967
33046
|
}
|
|
32968
33047
|
var BROKER_REQUEST_MS = TRADE_ATTEMPT_MS / 2;
|
|
32969
|
-
var DEFAULT_POLL_SECONDS = 5;
|
|
32970
|
-
var LEAST_POLL_SECONDS = 1;
|
|
32971
|
-
var MOST_POLL_SECONDS = 60;
|
|
32972
|
-
var MOST_LIFETIME_SECONDS = 3600;
|
|
32973
33048
|
var LOOPBACK_HOST = /^(localhost|127(\.\d{1,3}){3}|\[::1\])$/i;
|
|
32974
33049
|
var UNPRINTABLE = /[\p{Cc}\p{Cf}]/u;
|
|
32975
33050
|
function deviceLoginSessionName(thumbprint) {
|
|
@@ -33028,11 +33103,11 @@ function loginOf(key, broker, answered, now) {
|
|
|
33028
33103
|
const credentialId = typeof answered["credential_id"] === "string" ? answered["credential_id"] : "";
|
|
33029
33104
|
const expiresAt = new Date(typeof answered["credential_expires_at"] === "string" ? answered["credential_expires_at"] : "");
|
|
33030
33105
|
const refreshToken = answered.refresh_token ?? "";
|
|
33031
|
-
const
|
|
33032
|
-
if (credentialId === "" || Number.isNaN(expiresAt.getTime()) || refreshToken === "" || !(
|
|
33106
|
+
const accessSeconds = Math.min(answered.expires_in ?? 0, MOST_LIFETIME_SECONDS);
|
|
33107
|
+
if (credentialId === "" || Number.isNaN(expiresAt.getTime()) || refreshToken === "" || !(accessSeconds > 0) || answered.token_type.toLowerCase() !== TOKEN_TYPE_DPOP.toLowerCase()) {
|
|
33033
33108
|
throw new BrokerTradeFailedError(`the secrets broker at ${urlForText(endpoint, BROKER_URL_SETTING)} answered the device login without a credential_id, an RFC 3339 credential_expires_at, a refresh_token, a positive expires_in or a DPoP-bound token`);
|
|
33034
33109
|
}
|
|
33035
|
-
const accessExpiresAt = new Date(now +
|
|
33110
|
+
const accessExpiresAt = new Date(now + accessSeconds * 1000);
|
|
33036
33111
|
return {
|
|
33037
33112
|
key,
|
|
33038
33113
|
credentialId: printable(credentialId, "credential_id", endpoint),
|
|
@@ -33041,7 +33116,7 @@ function loginOf(key, broker, answered, now) {
|
|
|
33041
33116
|
broker,
|
|
33042
33117
|
accessToken: holdSecret(answered.access_token, accessExpiresAt),
|
|
33043
33118
|
accessExpiresAt,
|
|
33044
|
-
accessLifeSeconds:
|
|
33119
|
+
accessLifeSeconds: accessSeconds
|
|
33045
33120
|
};
|
|
33046
33121
|
}
|
|
33047
33122
|
async function startDeviceLogin(options) {
|
|
@@ -33073,7 +33148,15 @@ async function startDeviceLogin(options) {
|
|
|
33073
33148
|
} catch (error) {
|
|
33074
33149
|
throw brokerRefusal("ask for a code for", "this machine's device login", endpoint, error);
|
|
33075
33150
|
}
|
|
33076
|
-
const
|
|
33151
|
+
const intervalSeconds = Math.max(answered.interval ?? DEFAULT_POLL_SECONDS, LEAST_POLL_SECONDS);
|
|
33152
|
+
const lifetimeSeconds = Math.min(answered.expires_in, MOST_LIFETIME_SECONDS);
|
|
33153
|
+
const lifetimeMs = wholeMillisecondsOf(lifetimeSeconds);
|
|
33154
|
+
const now = Date.now();
|
|
33155
|
+
const expiresAt = new Date(now + lifetimeMs);
|
|
33156
|
+
const code = codeLeft(expiresAt, intervalSeconds, now);
|
|
33157
|
+
if (!code.reached) {
|
|
33158
|
+
throw new BrokerTradeFailedError(`the secrets broker at ${urlForText(endpoint, BROKER_URL_SETTING)} answered ${unpollableAnswer(answered, intervalSeconds, lifetimeSeconds, code.left)}`);
|
|
33159
|
+
}
|
|
33077
33160
|
return {
|
|
33078
33161
|
brokerUrl,
|
|
33079
33162
|
person,
|
|
@@ -33081,44 +33164,76 @@ async function startDeviceLogin(options) {
|
|
|
33081
33164
|
verificationUri: page(answered.verification_uri, endpoint),
|
|
33082
33165
|
verificationUriComplete: answered.verification_uri_complete === undefined ? undefined : page(answered.verification_uri_complete, endpoint),
|
|
33083
33166
|
expiresAt,
|
|
33084
|
-
intervalSeconds
|
|
33167
|
+
intervalSeconds,
|
|
33085
33168
|
deviceCode: holdSecret(answered.device_code, expiresAt),
|
|
33086
33169
|
key: privateKey
|
|
33087
33170
|
};
|
|
33088
33171
|
}
|
|
33172
|
+
function retryAfterMs2(error) {
|
|
33173
|
+
const value = responseOf(error)?.headers.get("retry-after")?.trim() ?? "";
|
|
33174
|
+
if (/^\d+$/.test(value))
|
|
33175
|
+
return Number(value) * 1000;
|
|
33176
|
+
const at = Date.parse(value);
|
|
33177
|
+
return Number.isFinite(at) ? Math.max(0, at - Date.now()) : 0;
|
|
33178
|
+
}
|
|
33089
33179
|
async function finishDeviceLogin(started, options) {
|
|
33180
|
+
if (!Number.isFinite(started.expiresAt.getTime()) || !Number.isFinite(started.intervalSeconds) || started.intervalSeconds < LEAST_POLL_SECONDS) {
|
|
33181
|
+
throw new TypeError(`finishDeviceLogin was handed a device authorization whose expiresAt is no date, or whose intervalSeconds is not a number of seconds, ${LEAST_POLL_SECONDS} or more`);
|
|
33182
|
+
}
|
|
33090
33183
|
const wait = options.sleep ?? ((ms) => sleep(ms, undefined, true));
|
|
33184
|
+
const clock = options.clock ?? (() => performance.now());
|
|
33091
33185
|
const config = brokerConfiguration(started.brokerUrl, options.fetch ?? fetch, {
|
|
33092
33186
|
key: loginDpopKey(started.key),
|
|
33093
33187
|
nonce: { value: "" }
|
|
33094
33188
|
});
|
|
33095
33189
|
const endpoint = started.brokerUrl + TOKEN_PATH;
|
|
33096
|
-
const expired =
|
|
33190
|
+
const expired = (outages) => {
|
|
33191
|
+
const unreached = outages === 0 ? "" : `; the broker was unreachable or busy for the last ${outages === 1 ? "poll" : `${outages} polls`}`;
|
|
33192
|
+
return new Error(`the code ${started.userCode} expired before ${started.person} approved this machine${unreached}; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
33193
|
+
};
|
|
33097
33194
|
let interval = started.intervalSeconds;
|
|
33195
|
+
let outages = 0;
|
|
33196
|
+
let waitMs = waitMillisecondsOf(interval);
|
|
33197
|
+
const { named, left: leftAtStart, reached } = codeLeft(started.expiresAt, interval, Date.now());
|
|
33198
|
+
if (!reached) {
|
|
33199
|
+
const first = `its first poll, ${seconds(pastTheMillisecond(interval) ? waitMs / 1000 : interval)} s on`;
|
|
33200
|
+
const lapse = leftAtStart <= 0 ? `had lapsed before ${first}` : named > leftAtStart ? `would lapse here before ${first}, as this machine polls a device code for an hour at most` : `lapses in ${seconds(leftAtStart / 1000)} s, no later than ${first}`;
|
|
33201
|
+
throw new Error(`the code ${started.userCode} ${lapse}, so no poll could reach it; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
33202
|
+
}
|
|
33203
|
+
const endsAt = clock() + leftAtStart;
|
|
33098
33204
|
while (true) {
|
|
33099
|
-
|
|
33100
|
-
|
|
33101
|
-
|
|
33205
|
+
const left = endsAt - clock();
|
|
33206
|
+
if (left <= 0)
|
|
33207
|
+
throw expired(outages);
|
|
33208
|
+
await wait(Math.min(waitMs, left));
|
|
33209
|
+
const lasts = endsAt - clock();
|
|
33210
|
+
if (lasts <= 0)
|
|
33211
|
+
throw expired(outages);
|
|
33212
|
+
holdSecret(started.deviceCode, Date.now() + lasts);
|
|
33102
33213
|
let answered;
|
|
33103
33214
|
try {
|
|
33104
33215
|
answered = await genericGrantRequest(config, GRANT_TYPE_DEVICE_CODE, {
|
|
33105
33216
|
device_code: started.deviceCode
|
|
33106
33217
|
});
|
|
33107
33218
|
} catch (error) {
|
|
33108
|
-
const code = error
|
|
33219
|
+
const code = refusalCode(error);
|
|
33109
33220
|
if (code === "access_denied") {
|
|
33110
33221
|
throw new Error(`this machine's device login was denied, not approved as ${started.person}; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
33111
33222
|
}
|
|
33112
33223
|
if (code === "expired_token" || code === "invalid_grant")
|
|
33113
|
-
throw expired;
|
|
33114
|
-
if (code === "slow_down")
|
|
33115
|
-
interval += 5;
|
|
33224
|
+
throw expired(0);
|
|
33116
33225
|
const status = statusOf(error);
|
|
33117
|
-
const
|
|
33226
|
+
const unanswered = status === 0 || outage(status);
|
|
33227
|
+
outages = unanswered ? outages + 1 : 0;
|
|
33228
|
+
if (code === "slow_down" || unanswered)
|
|
33229
|
+
interval += 5;
|
|
33230
|
+
const pollAgain = code === "authorization_pending" || code === "slow_down" || unanswered;
|
|
33118
33231
|
if (!pollAgain) {
|
|
33119
33232
|
const refusal = brokerRefusal("poll the code of", "this machine's device login", endpoint, error);
|
|
33120
33233
|
throw new Error(`${refusal.message}; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
33121
33234
|
}
|
|
33235
|
+
const asked = unanswered ? retryAfterMs2(error) : 0;
|
|
33236
|
+
waitMs = Math.max(waitMillisecondsOf(interval), asked);
|
|
33122
33237
|
continue;
|
|
33123
33238
|
}
|
|
33124
33239
|
const login = loginOf(started.key, started.brokerUrl, answered, Date.now());
|
|
@@ -33224,9 +33339,8 @@ async function refreshDeviceLogin(path, login, options) {
|
|
|
33224
33339
|
refresh_token: login.refreshToken
|
|
33225
33340
|
});
|
|
33226
33341
|
} catch (error) {
|
|
33227
|
-
if (error
|
|
33342
|
+
if (endsGrant(error))
|
|
33228
33343
|
throw new DeviceLoginEndedError(options.describe);
|
|
33229
|
-
}
|
|
33230
33344
|
if (sent === 0 && statusOf(error) === 0)
|
|
33231
33345
|
continue;
|
|
33232
33346
|
throw brokerRefusal("refresh", options.describe, endpoint, error);
|
|
@@ -33303,10 +33417,6 @@ function metadataIdentity(audience, env = process.env, options = {}) {
|
|
|
33303
33417
|
|
|
33304
33418
|
// ../cipher-client/src/person-identity.ts
|
|
33305
33419
|
var ISSUER_TIMEOUT_SECONDS = 30;
|
|
33306
|
-
var INVALID_GRANT2 = "invalid_grant";
|
|
33307
|
-
function grantRefused(error) {
|
|
33308
|
-
return error instanceof ResponseBodyError && error.error === INVALID_GRANT2 && (error.status === 400 || error.status === 401);
|
|
33309
|
-
}
|
|
33310
33420
|
function issuerSaid(error) {
|
|
33311
33421
|
if (error instanceof ResponseBodyError) {
|
|
33312
33422
|
const shown = shownOAuthCode(error.error);
|
|
@@ -33366,7 +33476,7 @@ function personIdentity(record, flow, options = {}) {
|
|
|
33366
33476
|
config[customFetch2] = through(signal);
|
|
33367
33477
|
answered = await refreshTokenGrant(config, refreshToken);
|
|
33368
33478
|
} catch (error) {
|
|
33369
|
-
if (
|
|
33479
|
+
if (endsGrant(error)) {
|
|
33370
33480
|
throw new SignInEndedError(issuer, person);
|
|
33371
33481
|
}
|
|
33372
33482
|
throw new Error(`renew ${person}'s sign-in at ${issuer}: ${issuerSaid(error)}`);
|
|
@@ -34495,7 +34605,7 @@ function keepNatsCredential(connection, credential, warn) {
|
|
|
34495
34605
|
}
|
|
34496
34606
|
var FOLLOW_RECONNECT_MS = 8000;
|
|
34497
34607
|
var FOLLOW_DEADLINE_MS = TRADE_DEADLINE_MS + FOLLOW_RECONNECT_MS;
|
|
34498
|
-
function
|
|
34608
|
+
function seconds2(ms) {
|
|
34499
34609
|
return Math.round(ms / 100) / 10;
|
|
34500
34610
|
}
|
|
34501
34611
|
async function followNatsCredential(connection, credential, boundMs = FOLLOW_DEADLINE_MS) {
|
|
@@ -34505,7 +34615,7 @@ async function followNatsCredential(connection, credential, boundMs = FOLLOW_DEA
|
|
|
34505
34615
|
try {
|
|
34506
34616
|
await credential.renew(AbortSignal.timeout(tradeMs), true);
|
|
34507
34617
|
} catch (error) {
|
|
34508
|
-
throw new LoggableError(isDeadline(error) ? `the NATS connection could not take the new session's token within ${
|
|
34618
|
+
throw new LoggableError(isDeadline(error) ? `the NATS connection could not take the new session's token within ${seconds2(tradeMs)} s` : `the NATS connection could not take the new session's token: ${tradeFailureReason(error)}`);
|
|
34509
34619
|
}
|
|
34510
34620
|
if (!credential.needsReconnect())
|
|
34511
34621
|
return;
|
|
@@ -34526,7 +34636,7 @@ async function followNatsCredential(connection, credential, boundMs = FOLLOW_DEA
|
|
|
34526
34636
|
throw new LoggableError("the NATS connection closed before it came back as the new session");
|
|
34527
34637
|
});
|
|
34528
34638
|
const late = Promise.withResolvers();
|
|
34529
|
-
const expire = () => late.reject(new LoggableError(`the NATS connection did not come back as the new session within ${
|
|
34639
|
+
const expire = () => late.reject(new LoggableError(`the NATS connection did not come back as the new session within ${seconds2(reconnectMs)} s`));
|
|
34530
34640
|
if (deadline.aborted)
|
|
34531
34641
|
expire();
|
|
34532
34642
|
else
|