@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/envoy-channel.js
CHANGED
|
@@ -42226,6 +42226,23 @@ async function genericGrantRequest(config, grantType, parameters, options) {
|
|
|
42226
42226
|
return result;
|
|
42227
42227
|
}
|
|
42228
42228
|
|
|
42229
|
+
// ../cipher-client/src/oauth-refusal.ts
|
|
42230
|
+
var INVALID_GRANT = "invalid_grant";
|
|
42231
|
+
var REQUEST_TIMEOUT = 408;
|
|
42232
|
+
var TOO_MANY_REQUESTS = 429;
|
|
42233
|
+
function outage(status) {
|
|
42234
|
+
return status >= 500 || status === REQUEST_TIMEOUT || status === TOO_MANY_REQUESTS;
|
|
42235
|
+
}
|
|
42236
|
+
function refusalCode(error) {
|
|
42237
|
+
if (!(error instanceof ResponseBodyError))
|
|
42238
|
+
return "";
|
|
42239
|
+
const refuses = error.status >= 400 && error.status < 500 && !outage(error.status);
|
|
42240
|
+
return refuses ? error.error : "";
|
|
42241
|
+
}
|
|
42242
|
+
function endsGrant(error) {
|
|
42243
|
+
return error instanceof ResponseBodyError && error.error === INVALID_GRANT && (error.status === 400 || error.status === 401);
|
|
42244
|
+
}
|
|
42245
|
+
|
|
42229
42246
|
// ../cipher-client/src/wire.ts
|
|
42230
42247
|
var TOKEN_PATH = "/v1/oauth/token";
|
|
42231
42248
|
var GRANT_TYPE_TOKEN_EXCHANGE = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
@@ -42585,10 +42602,9 @@ async function signInFlow(env) {
|
|
|
42585
42602
|
}
|
|
42586
42603
|
|
|
42587
42604
|
// ../cipher-client/src/token-errors.ts
|
|
42588
|
-
var TOO_MANY_REQUESTS = 429;
|
|
42589
42605
|
var INVALID_DPOP_PROOF = "invalid_dpop_proof";
|
|
42590
42606
|
var USE_DPOP_NONCE = "use_dpop_nonce";
|
|
42591
|
-
var
|
|
42607
|
+
var INVALID_GRANT2 = "invalid_grant";
|
|
42592
42608
|
var MEMBERSHIP_HELD = "membership_held";
|
|
42593
42609
|
var TOKEN_NOT_VALID = "Token is not valid or has expired.";
|
|
42594
42610
|
var MACHINE_LOGIN_ENDED = "The machine login the subject token belongs to has ended.";
|
|
@@ -42609,11 +42625,11 @@ class BrokerRefusedError extends Error {
|
|
|
42609
42625
|
this.code = KNOWN_OAUTH_ERROR_CODES.has(code) ? code : "";
|
|
42610
42626
|
this.shownCode = shownCode;
|
|
42611
42627
|
this.said = said;
|
|
42612
|
-
this.podSessionUnregistered = code ===
|
|
42613
|
-
this.subjectNotHonoured = status === 400 && (code === "invalid_request" && description.endsWith(TOKEN_NOT_VALID) || code ===
|
|
42628
|
+
this.podSessionUnregistered = code === INVALID_GRANT2 && description.startsWith(`${POD_SESSION_NOT_REGISTERED}:`);
|
|
42629
|
+
this.subjectNotHonoured = status === 400 && (code === "invalid_request" && description.endsWith(TOKEN_NOT_VALID) || code === INVALID_GRANT2 && description.endsWith(MACHINE_LOGIN_ENDED));
|
|
42614
42630
|
}
|
|
42615
42631
|
get permanent() {
|
|
42616
|
-
return this.status
|
|
42632
|
+
return !outage(this.status) && this.code !== INVALID_DPOP_PROOF && this.code !== USE_DPOP_NONCE && this.code !== MEMBERSHIP_HELD && !this.podSessionUnregistered;
|
|
42617
42633
|
}
|
|
42618
42634
|
}
|
|
42619
42635
|
|
|
@@ -42685,19 +42701,22 @@ function isFinalRefusal(error) {
|
|
|
42685
42701
|
|
|
42686
42702
|
// ../cipher-client/src/broker-request.ts
|
|
42687
42703
|
var BROKER_URL_SETTING = "the broker URL";
|
|
42688
|
-
function
|
|
42704
|
+
function responseOf(error) {
|
|
42689
42705
|
let cause = error;
|
|
42690
42706
|
for (let depth = 0;depth < 4; depth += 1) {
|
|
42691
42707
|
if (cause instanceof Response)
|
|
42692
|
-
return cause
|
|
42708
|
+
return cause;
|
|
42693
42709
|
if (cause instanceof ResponseBodyError || cause instanceof WWWAuthenticateChallengeError) {
|
|
42694
|
-
return cause.
|
|
42710
|
+
return cause.response;
|
|
42695
42711
|
}
|
|
42696
42712
|
if (typeof cause !== "object" || cause === null || !("cause" in cause))
|
|
42697
|
-
return
|
|
42713
|
+
return;
|
|
42698
42714
|
cause = cause.cause;
|
|
42699
42715
|
}
|
|
42700
|
-
return
|
|
42716
|
+
return;
|
|
42717
|
+
}
|
|
42718
|
+
function statusOf(error) {
|
|
42719
|
+
return responseOf(error)?.status ?? 0;
|
|
42701
42720
|
}
|
|
42702
42721
|
function brokerRefusal(doing, refused, endpoint, error, context = {}) {
|
|
42703
42722
|
if (error instanceof ResponseBodyError && error.status >= 400 && error.status < 500) {
|
|
@@ -43829,6 +43848,66 @@ async function saveDeviceLogin(path, login, held, keep = false) {
|
|
|
43829
43848
|
} catch {}
|
|
43830
43849
|
}
|
|
43831
43850
|
|
|
43851
|
+
// ../cipher-client/src/device-login-reach.ts
|
|
43852
|
+
var DEFAULT_POLL_SECONDS = 5;
|
|
43853
|
+
var LEAST_POLL_SECONDS = 1;
|
|
43854
|
+
var MOST_LIFETIME_SECONDS = 3600;
|
|
43855
|
+
function seconds(value) {
|
|
43856
|
+
const [mantissa = "", exponent] = String(value).split("e");
|
|
43857
|
+
if (exponent === undefined)
|
|
43858
|
+
return mantissa;
|
|
43859
|
+
const [whole = "", fraction = ""] = mantissa.split(".");
|
|
43860
|
+
const point = whole.length + Number(exponent);
|
|
43861
|
+
const digits = whole + fraction;
|
|
43862
|
+
return point <= 0 ? `0.${"0".repeat(-point)}${digits}` : digits.padEnd(point, "0");
|
|
43863
|
+
}
|
|
43864
|
+
function wholeMillisecondsOf(value) {
|
|
43865
|
+
const [whole = "", fraction = ""] = seconds(value).split(".");
|
|
43866
|
+
return Number(`${whole}${fraction.slice(0, 3).padEnd(3, "0")}`);
|
|
43867
|
+
}
|
|
43868
|
+
function waitMillisecondsOf(value) {
|
|
43869
|
+
return wholeMillisecondsOf(value) + (pastTheMillisecond(value) ? 1 : 0);
|
|
43870
|
+
}
|
|
43871
|
+
function pastTheMillisecond(value) {
|
|
43872
|
+
return /\.\d{3}\d*[1-9]/.test(seconds(value));
|
|
43873
|
+
}
|
|
43874
|
+
function codeLeft(expiresAt, intervalSeconds, now) {
|
|
43875
|
+
const named = expiresAt.getTime() - now;
|
|
43876
|
+
const left = Math.min(named, MOST_LIFETIME_SECONDS * 1000);
|
|
43877
|
+
return { named, left, reached: waitMillisecondsOf(intervalSeconds) < left };
|
|
43878
|
+
}
|
|
43879
|
+
function unpollableRemedy(named, intervalSeconds, lifetimeSeconds, left) {
|
|
43880
|
+
const outlivesLeast = left > LEAST_POLL_SECONDS * 1000;
|
|
43881
|
+
const wait = waitMillisecondsOf(intervalSeconds);
|
|
43882
|
+
const pastWait = pastTheMillisecond(intervalSeconds) ? `${seconds(wait / 1000)} s, its poll interval counted up to a whole millisecond` : "its poll interval";
|
|
43883
|
+
const underEnd = pastTheMillisecond(lifetimeSeconds) ? `${seconds(left / 1000)} s, its codes' lifetime counted down to a whole millisecond` : "its codes' lifetime";
|
|
43884
|
+
if (named === undefined) {
|
|
43885
|
+
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`;
|
|
43886
|
+
}
|
|
43887
|
+
if (wait === LEAST_POLL_SECONDS * 1000) {
|
|
43888
|
+
return `its codes live a millisecond or more longer than ${LEAST_POLL_SECONDS} s, the least poll interval this machine keeps`;
|
|
43889
|
+
}
|
|
43890
|
+
if (outlivesLeast)
|
|
43891
|
+
return `its poll interval is a millisecond or more shorter than ${underEnd}`;
|
|
43892
|
+
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}`;
|
|
43893
|
+
}
|
|
43894
|
+
function unpollableAnswer(answered, intervalSeconds, lifetimeSeconds, left) {
|
|
43895
|
+
const named = answered.interval;
|
|
43896
|
+
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`;
|
|
43897
|
+
const lapses = "the code would lapse before its first poll";
|
|
43898
|
+
const verdict = "no device login works at that broker until";
|
|
43899
|
+
const hour = lifetimeSeconds < answered.expires_in;
|
|
43900
|
+
const remedy = hour ? "its poll interval is a millisecond or more shorter than an hour" : unpollableRemedy(named, intervalSeconds, lifetimeSeconds, left);
|
|
43901
|
+
if (lifetimeSeconds <= 0) {
|
|
43902
|
+
return `a device code that had already lapsed, with ${interval}; ${verdict} ${remedy}`;
|
|
43903
|
+
}
|
|
43904
|
+
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}`;
|
|
43905
|
+
if (intervalSeconds < lifetimeSeconds) {
|
|
43906
|
+
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}`;
|
|
43907
|
+
}
|
|
43908
|
+
return `${answer}: ${lapses}; ${verdict} ${remedy}`;
|
|
43909
|
+
}
|
|
43910
|
+
|
|
43832
43911
|
// ../cipher-client/src/dpop.ts
|
|
43833
43912
|
import {
|
|
43834
43913
|
createHash,
|
|
@@ -43915,10 +43994,6 @@ function leastAccessLifeMs(leastLifeMs, lifeSeconds) {
|
|
|
43915
43994
|
return Math.max(ACCESS_MARGIN_MS, Math.min(leastLifeMs, lifeSeconds * 1000 / 2));
|
|
43916
43995
|
}
|
|
43917
43996
|
var BROKER_REQUEST_MS = TRADE_ATTEMPT_MS / 2;
|
|
43918
|
-
var DEFAULT_POLL_SECONDS = 5;
|
|
43919
|
-
var LEAST_POLL_SECONDS = 1;
|
|
43920
|
-
var MOST_POLL_SECONDS = 60;
|
|
43921
|
-
var MOST_LIFETIME_SECONDS = 3600;
|
|
43922
43997
|
var LOOPBACK_HOST = /^(localhost|127(\.\d{1,3}){3}|\[::1\])$/i;
|
|
43923
43998
|
var UNPRINTABLE = /[\p{Cc}\p{Cf}]/u;
|
|
43924
43999
|
function deviceLoginSessionName(thumbprint) {
|
|
@@ -43977,11 +44052,11 @@ function loginOf(key, broker, answered, now) {
|
|
|
43977
44052
|
const credentialId = typeof answered["credential_id"] === "string" ? answered["credential_id"] : "";
|
|
43978
44053
|
const expiresAt = new Date(typeof answered["credential_expires_at"] === "string" ? answered["credential_expires_at"] : "");
|
|
43979
44054
|
const refreshToken = answered.refresh_token ?? "";
|
|
43980
|
-
const
|
|
43981
|
-
if (credentialId === "" || Number.isNaN(expiresAt.getTime()) || refreshToken === "" || !(
|
|
44055
|
+
const accessSeconds = Math.min(answered.expires_in ?? 0, MOST_LIFETIME_SECONDS);
|
|
44056
|
+
if (credentialId === "" || Number.isNaN(expiresAt.getTime()) || refreshToken === "" || !(accessSeconds > 0) || answered.token_type.toLowerCase() !== TOKEN_TYPE_DPOP.toLowerCase()) {
|
|
43982
44057
|
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`);
|
|
43983
44058
|
}
|
|
43984
|
-
const accessExpiresAt = new Date(now +
|
|
44059
|
+
const accessExpiresAt = new Date(now + accessSeconds * 1000);
|
|
43985
44060
|
return {
|
|
43986
44061
|
key,
|
|
43987
44062
|
credentialId: printable(credentialId, "credential_id", endpoint),
|
|
@@ -43990,7 +44065,7 @@ function loginOf(key, broker, answered, now) {
|
|
|
43990
44065
|
broker,
|
|
43991
44066
|
accessToken: holdSecret(answered.access_token, accessExpiresAt),
|
|
43992
44067
|
accessExpiresAt,
|
|
43993
|
-
accessLifeSeconds:
|
|
44068
|
+
accessLifeSeconds: accessSeconds
|
|
43994
44069
|
};
|
|
43995
44070
|
}
|
|
43996
44071
|
async function startDeviceLogin(options) {
|
|
@@ -44022,7 +44097,15 @@ async function startDeviceLogin(options) {
|
|
|
44022
44097
|
} catch (error) {
|
|
44023
44098
|
throw brokerRefusal("ask for a code for", "this machine's device login", endpoint, error);
|
|
44024
44099
|
}
|
|
44025
|
-
const
|
|
44100
|
+
const intervalSeconds = Math.max(answered.interval ?? DEFAULT_POLL_SECONDS, LEAST_POLL_SECONDS);
|
|
44101
|
+
const lifetimeSeconds = Math.min(answered.expires_in, MOST_LIFETIME_SECONDS);
|
|
44102
|
+
const lifetimeMs = wholeMillisecondsOf(lifetimeSeconds);
|
|
44103
|
+
const now = Date.now();
|
|
44104
|
+
const expiresAt = new Date(now + lifetimeMs);
|
|
44105
|
+
const code = codeLeft(expiresAt, intervalSeconds, now);
|
|
44106
|
+
if (!code.reached) {
|
|
44107
|
+
throw new BrokerTradeFailedError(`the secrets broker at ${urlForText(endpoint, BROKER_URL_SETTING)} answered ${unpollableAnswer(answered, intervalSeconds, lifetimeSeconds, code.left)}`);
|
|
44108
|
+
}
|
|
44026
44109
|
return {
|
|
44027
44110
|
brokerUrl,
|
|
44028
44111
|
person,
|
|
@@ -44030,44 +44113,76 @@ async function startDeviceLogin(options) {
|
|
|
44030
44113
|
verificationUri: page(answered.verification_uri, endpoint),
|
|
44031
44114
|
verificationUriComplete: answered.verification_uri_complete === undefined ? undefined : page(answered.verification_uri_complete, endpoint),
|
|
44032
44115
|
expiresAt,
|
|
44033
|
-
intervalSeconds
|
|
44116
|
+
intervalSeconds,
|
|
44034
44117
|
deviceCode: holdSecret(answered.device_code, expiresAt),
|
|
44035
44118
|
key: privateKey
|
|
44036
44119
|
};
|
|
44037
44120
|
}
|
|
44121
|
+
function retryAfterMs(error) {
|
|
44122
|
+
const value = responseOf(error)?.headers.get("retry-after")?.trim() ?? "";
|
|
44123
|
+
if (/^\d+$/.test(value))
|
|
44124
|
+
return Number(value) * 1000;
|
|
44125
|
+
const at = Date.parse(value);
|
|
44126
|
+
return Number.isFinite(at) ? Math.max(0, at - Date.now()) : 0;
|
|
44127
|
+
}
|
|
44038
44128
|
async function finishDeviceLogin(started, options) {
|
|
44129
|
+
if (!Number.isFinite(started.expiresAt.getTime()) || !Number.isFinite(started.intervalSeconds) || started.intervalSeconds < LEAST_POLL_SECONDS) {
|
|
44130
|
+
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`);
|
|
44131
|
+
}
|
|
44039
44132
|
const wait = options.sleep ?? ((ms) => sleep2(ms, undefined, true));
|
|
44133
|
+
const clock = options.clock ?? (() => performance.now());
|
|
44040
44134
|
const config = brokerConfiguration(started.brokerUrl, options.fetch ?? fetch, {
|
|
44041
44135
|
key: loginDpopKey(started.key),
|
|
44042
44136
|
nonce: { value: "" }
|
|
44043
44137
|
});
|
|
44044
44138
|
const endpoint = started.brokerUrl + TOKEN_PATH;
|
|
44045
|
-
const expired =
|
|
44139
|
+
const expired = (outages) => {
|
|
44140
|
+
const unreached = outages === 0 ? "" : `; the broker was unreachable or busy for the last ${outages === 1 ? "poll" : `${outages} polls`}`;
|
|
44141
|
+
return new Error(`the code ${started.userCode} expired before ${started.person} approved this machine${unreached}; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
44142
|
+
};
|
|
44046
44143
|
let interval = started.intervalSeconds;
|
|
44144
|
+
let outages = 0;
|
|
44145
|
+
let waitMs = waitMillisecondsOf(interval);
|
|
44146
|
+
const { named, left: leftAtStart, reached } = codeLeft(started.expiresAt, interval, Date.now());
|
|
44147
|
+
if (!reached) {
|
|
44148
|
+
const first = `its first poll, ${seconds(pastTheMillisecond(interval) ? waitMs / 1000 : interval)} s on`;
|
|
44149
|
+
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}`;
|
|
44150
|
+
throw new Error(`the code ${started.userCode} ${lapse}, so no poll could reach it; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
44151
|
+
}
|
|
44152
|
+
const endsAt = clock() + leftAtStart;
|
|
44047
44153
|
while (true) {
|
|
44048
|
-
|
|
44049
|
-
|
|
44050
|
-
|
|
44154
|
+
const left = endsAt - clock();
|
|
44155
|
+
if (left <= 0)
|
|
44156
|
+
throw expired(outages);
|
|
44157
|
+
await wait(Math.min(waitMs, left));
|
|
44158
|
+
const lasts = endsAt - clock();
|
|
44159
|
+
if (lasts <= 0)
|
|
44160
|
+
throw expired(outages);
|
|
44161
|
+
holdSecret(started.deviceCode, Date.now() + lasts);
|
|
44051
44162
|
let answered;
|
|
44052
44163
|
try {
|
|
44053
44164
|
answered = await genericGrantRequest(config, GRANT_TYPE_DEVICE_CODE, {
|
|
44054
44165
|
device_code: started.deviceCode
|
|
44055
44166
|
});
|
|
44056
44167
|
} catch (error) {
|
|
44057
|
-
const code = error
|
|
44168
|
+
const code = refusalCode(error);
|
|
44058
44169
|
if (code === "access_denied") {
|
|
44059
44170
|
throw new Error(`this machine's device login was denied, not approved as ${started.person}; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
44060
44171
|
}
|
|
44061
44172
|
if (code === "expired_token" || code === "invalid_grant")
|
|
44062
|
-
throw expired;
|
|
44063
|
-
if (code === "slow_down")
|
|
44064
|
-
interval += 5;
|
|
44173
|
+
throw expired(0);
|
|
44065
44174
|
const status = statusOf(error);
|
|
44066
|
-
const
|
|
44175
|
+
const unanswered = status === 0 || outage(status);
|
|
44176
|
+
outages = unanswered ? outages + 1 : 0;
|
|
44177
|
+
if (code === "slow_down" || unanswered)
|
|
44178
|
+
interval += 5;
|
|
44179
|
+
const pollAgain = code === "authorization_pending" || code === "slow_down" || unanswered;
|
|
44067
44180
|
if (!pollAgain) {
|
|
44068
44181
|
const refusal = brokerRefusal("poll the code of", "this machine's device login", endpoint, error);
|
|
44069
44182
|
throw new Error(`${refusal.message}; ask again with: ${DEVICE_LOGIN_COMMAND}`);
|
|
44070
44183
|
}
|
|
44184
|
+
const asked = unanswered ? retryAfterMs(error) : 0;
|
|
44185
|
+
waitMs = Math.max(waitMillisecondsOf(interval), asked);
|
|
44071
44186
|
continue;
|
|
44072
44187
|
}
|
|
44073
44188
|
const login = loginOf(started.key, started.brokerUrl, answered, Date.now());
|
|
@@ -44173,9 +44288,8 @@ async function refreshDeviceLogin(path, login, options) {
|
|
|
44173
44288
|
refresh_token: login.refreshToken
|
|
44174
44289
|
});
|
|
44175
44290
|
} catch (error) {
|
|
44176
|
-
if (error
|
|
44291
|
+
if (endsGrant(error))
|
|
44177
44292
|
throw new DeviceLoginEndedError(options.describe);
|
|
44178
|
-
}
|
|
44179
44293
|
if (sent === 0 && statusOf(error) === 0)
|
|
44180
44294
|
continue;
|
|
44181
44295
|
throw brokerRefusal("refresh", options.describe, endpoint, error);
|
|
@@ -44252,10 +44366,6 @@ function metadataIdentity(audience, env = process.env, options = {}) {
|
|
|
44252
44366
|
|
|
44253
44367
|
// ../cipher-client/src/person-identity.ts
|
|
44254
44368
|
var ISSUER_TIMEOUT_SECONDS = 30;
|
|
44255
|
-
var INVALID_GRANT2 = "invalid_grant";
|
|
44256
|
-
function grantRefused(error) {
|
|
44257
|
-
return error instanceof ResponseBodyError && error.error === INVALID_GRANT2 && (error.status === 400 || error.status === 401);
|
|
44258
|
-
}
|
|
44259
44369
|
function issuerSaid(error) {
|
|
44260
44370
|
if (error instanceof ResponseBodyError) {
|
|
44261
44371
|
const shown = shownOAuthCode(error.error);
|
|
@@ -44315,7 +44425,7 @@ function personIdentity(record, flow, options = {}) {
|
|
|
44315
44425
|
config[customFetch2] = through(signal);
|
|
44316
44426
|
answered = await refreshTokenGrant(config, refreshToken);
|
|
44317
44427
|
} catch (error) {
|
|
44318
|
-
if (
|
|
44428
|
+
if (endsGrant(error)) {
|
|
44319
44429
|
throw new SignInEndedError(issuer, person);
|
|
44320
44430
|
}
|
|
44321
44431
|
throw new Error(`renew ${person}'s sign-in at ${issuer}: ${issuerSaid(error)}`);
|
|
@@ -46063,7 +46173,7 @@ function pauseFor(ms, signal) {
|
|
|
46063
46173
|
signal.addEventListener("abort", stop, { once: true });
|
|
46064
46174
|
return promise;
|
|
46065
46175
|
}
|
|
46066
|
-
function
|
|
46176
|
+
function retryAfterMs2(response) {
|
|
46067
46177
|
const value = response.headers.get("Retry-After")?.trim() ?? "";
|
|
46068
46178
|
if (/^\d+$/.test(value))
|
|
46069
46179
|
return Number(value) * 1000;
|
|
@@ -46913,7 +47023,7 @@ class DispatchClient {
|
|
|
46913
47023
|
sent
|
|
46914
47024
|
};
|
|
46915
47025
|
}
|
|
46916
|
-
const heard = { retryAfterMs:
|
|
47026
|
+
const heard = { retryAfterMs: retryAfterMs2(response) };
|
|
46917
47027
|
if (response.headers.get(IDEMPOTENCY_KEY_HEADER) === key)
|
|
46918
47028
|
progress.keyEchoed = true;
|
|
46919
47029
|
let answer;
|
|
@@ -57633,7 +57743,7 @@ function keepNatsCredential(connection, credential, warn) {
|
|
|
57633
57743
|
}
|
|
57634
57744
|
var FOLLOW_RECONNECT_MS = 8000;
|
|
57635
57745
|
var FOLLOW_DEADLINE_MS = TRADE_DEADLINE_MS + FOLLOW_RECONNECT_MS;
|
|
57636
|
-
function
|
|
57746
|
+
function seconds2(ms) {
|
|
57637
57747
|
return Math.round(ms / 100) / 10;
|
|
57638
57748
|
}
|
|
57639
57749
|
async function followNatsCredential(connection, credential, boundMs = FOLLOW_DEADLINE_MS) {
|
|
@@ -57643,7 +57753,7 @@ async function followNatsCredential(connection, credential, boundMs = FOLLOW_DEA
|
|
|
57643
57753
|
try {
|
|
57644
57754
|
await credential.renew(AbortSignal.timeout(tradeMs), true);
|
|
57645
57755
|
} catch (error) {
|
|
57646
|
-
throw new LoggableError(isDeadline(error) ? `the NATS connection could not take the new session's token within ${
|
|
57756
|
+
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)}`);
|
|
57647
57757
|
}
|
|
57648
57758
|
if (!credential.needsReconnect())
|
|
57649
57759
|
return;
|
|
@@ -57664,7 +57774,7 @@ async function followNatsCredential(connection, credential, boundMs = FOLLOW_DEA
|
|
|
57664
57774
|
throw new LoggableError("the NATS connection closed before it came back as the new session");
|
|
57665
57775
|
});
|
|
57666
57776
|
const late = Promise.withResolvers();
|
|
57667
|
-
const expire = () => late.reject(new LoggableError(`the NATS connection did not come back as the new session within ${
|
|
57777
|
+
const expire = () => late.reject(new LoggableError(`the NATS connection did not come back as the new session within ${seconds2(reconnectMs)} s`));
|
|
57668
57778
|
if (deadline.aborted)
|
|
57669
57779
|
expire();
|
|
57670
57780
|
else
|
|
@@ -63550,7 +63660,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
63550
63660
|
|
|
63551
63661
|
// package.json
|
|
63552
63662
|
var name2 = "@sjawhar/claude-envoy";
|
|
63553
|
-
var version2 = "5.32.
|
|
63663
|
+
var version2 = "5.32.1";
|
|
63554
63664
|
var package_default = {
|
|
63555
63665
|
name: name2,
|
|
63556
63666
|
version: version2,
|