@cortexkit/opencode-openai-auth 0.1.4 → 0.2.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/README.md +6 -6
- package/dist/cli.js +10 -10
- package/dist/config.d.ts +3 -1
- package/dist/core/accounts.d.ts +17 -1
- package/dist/core/cachekeep.d.ts +3 -0
- package/dist/core/oauth.d.ts +10 -2
- package/dist/core/quota-manager.d.ts +21 -1
- package/dist/index-1gjhrsep.js +2 -0
- package/dist/index-5j7p33r8.js +2 -0
- package/dist/index-88b7ha2h.js +3 -0
- package/dist/{index-dz7tcrxb.js → index-nngfcx1x.js} +1 -1
- package/dist/{index-eks9xm6s.js → index-qqrj9za2.js} +1 -1
- package/dist/{index-6qjg8qfw.js → index-r68prrfg.js} +1 -1
- package/dist/{index-hrg6bdgb.js → index-vj00ztg7.js} +1 -1
- package/dist/index-xftpnva2.js +92 -0
- package/dist/index.js +64 -70
- package/dist/quota-normalize-s1bctr9a.js +1 -0
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/rpc/rpc-server.d.ts +1 -0
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-zzzp7w2y.js → token-c1q4pea2.js} +1 -1
- package/dist/token-util-ff59e4fw.js +1 -0
- package/dist/tui-preferences.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/ws-pool.d.ts +5 -1
- package/dist/ws.d.ts +9 -1
- package/package.json +3 -1
- package/src/logger.ts +140 -0
- package/src/rpc/rpc-server.ts +7 -0
- package/src/sidebar-state.ts +6 -2
- package/src/tui/command-dialogs.tsx +3 -61
- package/src/util/error.ts +9 -0
- package/src/util/open-url.ts +30 -0
- package/src/util/proxy-env.ts +42 -0
- package/src/util/record.ts +3 -0
- package/src/util/stable-json.ts +15 -0
- package/src/util/uuid-v7.ts +18 -0
- package/dist/index-0s5tftne.js +0 -3
- package/dist/index-jshhys8t.js +0 -2
- package/dist/index-m9dtkj3q.js +0 -92
- package/dist/index-sgfft5d3.js +0 -2
- package/dist/quota-normalize-qh5n0p7v.js +0 -1
- package/dist/token-util-sqwtzxz0.js +0 -1
package/dist/index-m9dtkj3q.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import{Y as y0}from"./index-0s5tftne.js";import{ea as K1}from"./index-hrg6bdgb.js";import{createHash as v0}from"node:crypto";var d0=86400000,l0=300000,g0=3600000,i0=60000,u0=900000,s0=300000;function r(B){return B instanceof Error?B.message:String(B)}function c0(B){let Z=B?.status;if(typeof Z==="number")return Z===429||Z>=500;if(!(B instanceof Error))return!1;return B.message.includes("fetch failed")||"code"in B&&(B.code==="ECONNRESET"||B.code==="ECONNREFUSED"||B.code==="ETIMEDOUT"||B.code==="UND_ERR_CONNECT_TIMEOUT")}function a(B){let Z=r(B),$=B?.status;if(typeof $==="number")return $===429||$>=500;if(!(B instanceof Error))return!1;let z=B.code;return Z.includes("fetch failed")||z==="ECONNRESET"||z==="ECONNREFUSED"||z==="ETIMEDOUT"||z==="UND_ERR_CONNECT_TIMEOUT"}function N0(B){return v0("sha256").update(B).digest("hex")}function V0(B){let Z=N0(B.refreshToken),z=(B.previous?.tokenHash===Z?B.previous.retryCount??0:0)+1,G,X=B.error?.retryAfter;if(typeof X==="number"&&X>0)G=X*1000;else if(c0(B.error))G=Math.min(g0,l0*2**Math.min(z-1,6));else G=d0;return{message:r(B.error),checkedAt:B.now,nextRetryAt:B.now+G,retryCount:z,tokenHash:Z}}function I(B,Z,$){if(!B?.nextRetryAt||B.nextRetryAt<=$)return!1;if(!Z)return!0;return B.tokenHash===N0(Z)}function d(B,Z){return`Codex OAuth refresh is backed off for ${Math.max(1,Math.ceil(((B.nextRetryAt??Z)-Z)/1000))}s after: ${B.message}`}function H0(B){let $=(B.previous?.retryCount??0)+1,z=a(B.error)?Math.min(u0,i0*2**Math.min($-1,6)):s0;return{message:r(B.error),checkedAt:B.now,nextRetryAt:B.now+z,retryCount:$}}function b0(B,Z){if(!B?.nextRetryAt||B.nextRetryAt<=Z)return!1;return!0}function o(B){if(!B)return;let Z=Number(B);if(Number.isFinite(Z)&&Z>0)return Math.ceil(Z);let $=Date.parse(B);if(Number.isFinite($)){let z=Math.ceil(($-Date.now())/1000);return z>0?z:void 0}return}import{createServer as n0}from"node:http";import{setTimeout as r0}from"node:timers/promises";var F0="0.1.4";var l="app_EMoamEEZ73f0CkXaXp7hrann",_="https://auth.openai.com",k=1455,a0=3000,M0=`cortexkit-opencode-openai-auth/${F0}`;function q0(B){let Z=new Uint8Array(B),$=String.fromCharCode(...Z);return btoa($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function o0(){let Z=Array.from(crypto.getRandomValues(new Uint8Array(43))).map((z)=>"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"[z%66]).join(""),$=q0(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(Z)));return{verifier:Z,challenge:$}}function D0(B){let Z=B.split(".");if(Z.length!==3)return;let $=Z[1];if(!$)return;try{return JSON.parse(Buffer.from($,"base64url").toString())}catch{return}}function L0(B){let Z=B.chatgpt_account_id;if(typeof Z==="string"&&Z.length>0)return Z;let $=B["https://api.openai.com/auth"];if($&&typeof $==="object"&&!Array.isArray($)&&typeof $.chatgpt_account_id==="string"&&$.chatgpt_account_id.length>0)return $.chatgpt_account_id;let z=B.organizations;if(Array.isArray(z)){let G=z[0];if(G&&typeof G==="object"&&!Array.isArray(G)&&typeof G.id==="string"&&G.id.length>0)return G.id}return}function R(B){if(B.id_token){let Z=D0(B.id_token),$=Z&&L0(Z);if($)return $}if(B.access_token){let Z=D0(B.access_token);return Z?L0(Z):void 0}return}function t0(B,Z,$){let z=new URLSearchParams({response_type:"code",client_id:l,redirect_uri:B,scope:"openid profile email offline_access",code_challenge:Z.challenge,code_challenge_method:"S256",id_token_add_organizations:"true",codex_cli_simplified_flow:"true",state:$,originator:"opencode"});return`${_}/oauth/authorize?${z.toString()}`}async function e0(B,Z,$){let z=await fetch(`${_}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:B,redirect_uri:Z,client_id:l,code_verifier:$.verifier}).toString()});if(!z.ok)throw Error(`Token exchange failed: ${z.status}`);return await z.json()}function B1(B){return B.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var Z1=`<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>CortexKit OpenAI Auth - Authorization Successful</title>
|
|
5
|
-
<style>
|
|
6
|
-
body {
|
|
7
|
-
font-family:
|
|
8
|
-
system-ui,
|
|
9
|
-
-apple-system,
|
|
10
|
-
sans-serif;
|
|
11
|
-
display: flex;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
align-items: center;
|
|
14
|
-
height: 100vh;
|
|
15
|
-
margin: 0;
|
|
16
|
-
background: #131010;
|
|
17
|
-
color: #f1ecec;
|
|
18
|
-
}
|
|
19
|
-
.container {
|
|
20
|
-
text-align: center;
|
|
21
|
-
padding: 2rem;
|
|
22
|
-
}
|
|
23
|
-
h1 {
|
|
24
|
-
color: #f1ecec;
|
|
25
|
-
margin-bottom: 1rem;
|
|
26
|
-
}
|
|
27
|
-
p {
|
|
28
|
-
color: #b7b1b1;
|
|
29
|
-
}
|
|
30
|
-
</style>
|
|
31
|
-
</head>
|
|
32
|
-
<body>
|
|
33
|
-
<div class="container">
|
|
34
|
-
<h1>Authorization Successful</h1>
|
|
35
|
-
<p>You can close this window and return to OpenCode.</p>
|
|
36
|
-
</div>
|
|
37
|
-
<script>
|
|
38
|
-
setTimeout(() => window.close(), 2000)
|
|
39
|
-
</script>
|
|
40
|
-
</body>
|
|
41
|
-
</html>`,t=(B)=>`<!doctype html>
|
|
42
|
-
<html>
|
|
43
|
-
<head>
|
|
44
|
-
<title>CortexKit OpenAI Auth - Authorization Failed</title>
|
|
45
|
-
<style>
|
|
46
|
-
body {
|
|
47
|
-
font-family:
|
|
48
|
-
system-ui,
|
|
49
|
-
-apple-system,
|
|
50
|
-
sans-serif;
|
|
51
|
-
display: flex;
|
|
52
|
-
justify-content: center;
|
|
53
|
-
align-items: center;
|
|
54
|
-
height: 100vh;
|
|
55
|
-
margin: 0;
|
|
56
|
-
background: #131010;
|
|
57
|
-
color: #f1ecec;
|
|
58
|
-
}
|
|
59
|
-
.container {
|
|
60
|
-
text-align: center;
|
|
61
|
-
padding: 2rem;
|
|
62
|
-
}
|
|
63
|
-
h1 {
|
|
64
|
-
color: #fc533a;
|
|
65
|
-
margin-bottom: 1rem;
|
|
66
|
-
}
|
|
67
|
-
p {
|
|
68
|
-
color: #b7b1b1;
|
|
69
|
-
}
|
|
70
|
-
.error {
|
|
71
|
-
color: #ff917b;
|
|
72
|
-
font-family: monospace;
|
|
73
|
-
margin-top: 1rem;
|
|
74
|
-
padding: 1rem;
|
|
75
|
-
background: #3c140d;
|
|
76
|
-
border-radius: 0.5rem;
|
|
77
|
-
}
|
|
78
|
-
</style>
|
|
79
|
-
</head>
|
|
80
|
-
<body>
|
|
81
|
-
<div class="container">
|
|
82
|
-
<h1>Authorization Failed</h1>
|
|
83
|
-
<p>An error occurred during authorization.</p>
|
|
84
|
-
<div class="error">${B1(B)}</div>
|
|
85
|
-
</div>
|
|
86
|
-
</body>
|
|
87
|
-
</html>`,f,m,L=new Map;function q(){return L.size}function y(B){if(L.delete(B),q()===0)O()}async function $1(){let B=`http://localhost:${k}/auth/callback`;if(f)return{port:k,redirectUri:B};if(m)return m;m=(async()=>{let Z=n0(($,z)=>{let G=new URL($.url||"/",`http://localhost:${k}`);if(G.pathname==="/auth/callback"){let X=G.searchParams.get("code"),K=G.searchParams.get("state"),J=G.searchParams.get("error"),W=G.searchParams.get("error_description");if(J){let Q=W||J;if(K){let V=L.get(K);if(V)V.reject(Error(Q)),y(K);else if(q()===0)O()}else if(q()===0)O();z.writeHead(200,{"Content-Type":"text/html"}),z.end(t(Q));return}if(!X||!K){let Q=!X?"Missing authorization code":"Missing state parameter";if(K){let V=L.get(K);if(V)V.reject(Error(Q)),y(K);else if(q()===0)O()}else if(q()===0)O();z.writeHead(400,{"Content-Type":"text/html"}),z.end(t(Q));return}let Y=L.get(K);if(!Y){if(q()===0)O();z.writeHead(400,{"Content-Type":"text/html"}),z.end(t("Unknown state — authorization may have expired"));return}y(K),e0(X,B,Y.pkce).then((Q)=>Y.resolve(Q)).catch((Q)=>Y.reject(Q)),z.writeHead(200,{"Content-Type":"text/html"}),z.end(Z1);return}if(G.pathname==="/cancel"){let X=G.searchParams.get("state"),K=X?[X]:[...L.keys()];z.writeHead(200),z.end("Login cancelled");for(let J of K){let W=L.get(J);if(!W)continue;W.reject(Error("Login cancelled")),y(J)}if(q()===0)O();return}z.writeHead(404),z.end("Not found")});return await new Promise(($,z)=>{Z.once("error",z),Z.listen(k,"127.0.0.1",()=>{Z.off("error",z),$()})}),f=Z,{port:k,redirectUri:B}})();try{return await m}finally{m=void 0}}function O(){if(f){let B=f;f=void 0,B.close(()=>{}),B.closeIdleConnections?.(),setTimeout(()=>{B.closeAllConnections?.()},25).unref?.()}}function z1(B,Z,$=300000){return new Promise((z,G)=>{let X=setTimeout(()=>{if(L.get(Z))y(Z),G(Error("OAuth callback timeout — authorization took too long"))},$);L.set(Z,{pkce:B,state:Z,resolve:(K)=>{clearTimeout(X),z(K)},reject:(K)=>{clearTimeout(X),G(K)}})})}async function X1(){let B=await fetch(`${_}/api/accounts/deviceauth/usercode`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":M0},body:JSON.stringify({client_id:l})});if(!B.ok)throw Error("Failed to initiate device authorization");let Z=await B.json();return{deviceData:Z,url:`${_}/codex/device`,instructions:`Enter code: ${Z.user_code}`}}async function G1(B,Z){let $=Math.max(parseInt(B.interval,10)||5,1)*1000;while(!0){if(Z?.aborted)throw Error("Device authorization cancelled");let z=await fetch(`${_}/api/accounts/deviceauth/token`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":M0},body:JSON.stringify({device_auth_id:B.device_auth_id,user_code:B.user_code})});if(z.ok){let G=await z.json(),X=await fetch(`${_}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:G.authorization_code,redirect_uri:`${_}/deviceauth/callback`,client_id:l,code_verifier:G.code_verifier}).toString()});if(!X.ok)throw Error(`Token exchange failed: ${X.status}`);return await X.json()}if(z.status!==403&&z.status!==404)throw Error(`Device authorization failed: ${z.status}`);await r0($+a0)}}function L4(B,Z){let $=-1;if(Z.accountId)$=B.findIndex((z)=>z.accountId&&z.accountId===Z.accountId);if($<0)$=B.findIndex((z)=>z.id===Z.id);if($<0&&Z.label&&!Z.accountId)$=B.findIndex((z)=>z.label===Z.label);if($>=0)return B[$]={...B[$],...Z,addedAt:B[$]?.addedAt??Z.addedAt},$;return B.push(Z),B.length-1}async function M4(B={}){let{label:Z,headless:$=!1,signal:z}=B;if($){let{deviceData:Y,url:Q,instructions:V}=await X1(),F=(async()=>{let N=await G1(Y,z),H=Date.now();return{id:Z||R(N)||crypto.randomUUID(),label:Z||void 0,type:"oauth",access:N.access_token,refresh:N.refresh_token,expires:H+(N.expires_in??3600)*1000,enabled:!0,addedAt:H,lastUsed:H,accountId:R(N)}})();return{url:Q,instructions:V,completion:F}}let{redirectUri:G}=await $1(),X=await o0(),K=q0(crypto.getRandomValues(new Uint8Array(32)).buffer),J=t0(G,X,K),W=(async()=>{try{if(z?.aborted)throw Error("Login cancelled");let Y=await z1(X,K),Q=Date.now();return{id:Z||R(Y)||crypto.randomUUID(),label:Z||void 0,type:"oauth",access:Y.access_token,refresh:Y.refresh_token,expires:Q+(Y.expires_in??3600)*1000,enabled:!0,addedAt:Q,lastUsed:Q,accountId:R(Y)}}finally{y(K)}})();return{url:J,instructions:"Complete authorization in your browser. This window will close automatically.",completion:W}}var g="primary",i="secondary",J1="app_EMoamEEZ73f0CkXaXp7hrann",W1="https://auth.openai.com";async function _4(B){let Z=await B.fetchImpl(`${W1}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:B.refreshToken,client_id:J1}).toString()});if(!Z.ok){let z=o(Z.headers.get("retry-after"));throw Object.assign(Error(`Token refresh failed: ${Z.status}`),{status:Z.status,retryAfter:z,isRefreshError:!0})}let $=await Z.json();return{access:$.access_token,refresh:$.refresh_token,expires:$.expires_in?B.now()+$.expires_in*1000:0,expiresIn:$.expires_in??3600}}var Y1="https://chatgpt.com/backend-api/wham/usage";async function U4(B){let Z=await B.fetchImpl(Y1,{headers:{authorization:`Bearer ${B.accessToken}`,"chatgpt-account-id":B.accountId??"","oai-client-platform":"web","oai-client-version":"0","x-openai-target-path":"/backend-api/wham/usage"}});if(!Z.ok){let z=o(Z.headers.get("retry-after"));throw Object.assign(Error(`wham usage check failed: ${Z.status}`),{status:Z.status,retryAfter:z})}let{normalizeWham:$}=await import("./quota-normalize-qh5n0p7v.js");return $(await Z.json())}import{randomUUID as e}from"node:crypto";import{mkdir as j1,readFile as B0,rename as Q1,rm as w,stat as O0,writeFile as Z0}from"node:fs/promises";import{homedir as N1}from"node:os";import{dirname as T4,join as h}from"node:path";var V1=globalThis.setTimeout.bind(globalThis),H1=globalThis.clearTimeout.bind(globalThis),b1="openai-auth.json";function F1(){if(process.env.OPENCODE_CONFIG_DIR?.trim())return process.env.OPENCODE_CONFIG_DIR.trim();return h(process.env.XDG_CONFIG_HOME||h(N1(),".config"),"opencode")}function D1(){return process.env.OPENCODE_OPENAI_AUTH_FILE?.trim()||h(F1(),b1)}async function u(B){let $=`${B.path??D1()}.${B.name}.lock`,z=h($,"owner.json"),G=e(),X=B.now??Date.now,K=null,J=!1;async function W(){try{return JSON.parse(await B0($,"utf8"))}catch(N){if(N.code!=="EISDIR")throw N;return JSON.parse(await B0(z,"utf8"))}}async function Y(){await Z0($,`${JSON.stringify({ownerId:G,expiresAt:X()+B.ttlMs})}
|
|
88
|
-
`,{encoding:"utf8",mode:384})}async function Q(){try{return await Z0($,`${JSON.stringify({ownerId:G,expiresAt:X()+B.ttlMs})}
|
|
89
|
-
`,{encoding:"utf8",mode:384,flag:"wx"}),!0}catch(N){let H=N.code;if(H==="EEXIST"||H==="EISDIR")return!1;throw N}}function V(){if(!B.renew||J)return;let N=B.renewIntervalMs??Math.max(1000,Math.floor(B.ttlMs/3));if(K=V1(()=>{(async()=>{try{let H=await W(),p=X();if(J||H?.ownerId!==G||Number(H?.expiresAt)<=p)return;await Y(),V()}catch{}})()},N),"unref"in K)K.unref()}let F=await Q();if(!F){let N=`${$}.evicting`,H=h(N,"owner.json"),p=e(),Y4=5000,j4=8;async function v(){await new Promise((D)=>setTimeout(D,Math.floor(Math.random()*4)))}async function J0(){try{let D=await W();return Number(D?.expiresAt)>X()}catch{try{return(await O0($)).mtimeMs+B.ttlMs>X()}catch{return!1}}}async function x(){try{return JSON.parse(await B0(H,"utf8"))?.ownerId===p}catch{return!1}}async function p0(){await j1(N);try{await Z0(H,`${JSON.stringify({ownerId:p,createdAt:X()})}
|
|
90
|
-
`,{encoding:"utf8",mode:384,flag:"wx"})}catch(D){if(D.code==="ENOENT")return!1;throw await W0(),D}return await B.onStep?.("eviction-marker-acquired"),!0}async function W0(){if(await x())await w(N,{recursive:!0,force:!0}).catch(()=>{})}for(let D=0;D<8;D++){if(F=await Q(),F)break;if(await J0())return null;try{if(!await p0()){await v();continue}}catch(Y0){if(Y0.code!=="EEXIST")throw Y0;let j0;try{j0=await O0(N)}catch(A){if(A.code==="ENOENT"){await v();continue}throw A}if(j0.mtimeMs+5000>X())return null;await B.onStep?.("stale-marker-stat");let Q0=`${N}.${e()}`;try{await Q1(N,Q0)}catch(A){if(A.code==="ENOENT"){await v();continue}throw A}await B.onStep?.("stale-marker-claimed"),await w(Q0,{recursive:!0,force:!0}).catch(()=>{}),await v();continue}try{if(await J0())return null;if(!await x())return null;if(await B.onStep?.("stale-lock-confirmed"),!await x())return null;if(await w($,{recursive:!0,force:!0}).catch(()=>{}),!await x())return null;if(F=await Q(),!F)return null;if(!await x())return await w($,{recursive:!0,force:!0}).catch(()=>{}),F=!1,null;break}finally{await W0()}}}if(!F)return null;return V(),{release:async()=>{if(J=!0,K)H1(K),K=null;try{if((await W())?.ownerId!==G)return}catch{return}await w($,{recursive:!0,force:!0}).catch(()=>{})}}}import{createHash as C1,randomUUID as P1}from"node:crypto";import{homedir as I1}from"node:os";import{dirname as R1,join as s}from"node:path";import{setTimeout as y1}from"node:timers/promises";import{randomUUID as L1}from"node:crypto";import{mkdir as M1,rename as q1,rm as O1,writeFile as _1}from"node:fs/promises";import{dirname as U1}from"node:path";async function T(B,Z){await M1(U1(B),{recursive:!0});let $=`${B}.${L1()}.tmp`;await _1($,`${JSON.stringify(Z,null,2)}
|
|
91
|
-
`,{encoding:"utf8",mode:384});try{await q1($,B)}catch(z){throw await O1($,{force:!0}).catch(()=>{}),z}}import{readFile as h1}from"node:fs/promises";var U=y0("refresh"),_0=1e4,T1=50,T0="openai-auth.json",E1="openai-auth-state.json";function S1(){if(process.env.OPENCODE_CONFIG_DIR?.trim())return process.env.OPENCODE_CONFIG_DIR.trim();return s(process.env.XDG_CONFIG_HOME||s(I1(),".config"),"opencode")}function S(){return process.env.OPENCODE_OPENAI_AUTH_FILE?.trim()||s(S1(),T0)}function n(B=S()){let Z=process.env.OPENCODE_OPENAI_AUTH_STATE_FILE?.trim();if(Z)return Z;return x1(B)}function x1(B){return B.endsWith(T0)?s(R1(B),E1):`${B}.state.json`}function C(B){return B.type==="oauth"}function A1(B){let Z=B?.trim();if(!Z)return!1;try{let $=new URL(Z);return($.protocol==="http:"||$.protocol==="https:")&&!$.username&&!$.password}catch{return!1}}function u4(B){return B.costZeroing?.enabled!==!1}var k1=[401,403,429],U0={primary:0,secondary:0},m1=!1,s4={primary:5,secondary:10};function j(B){return B!=null&&typeof B==="object"&&!Array.isArray(B)}function C0(B){return{id:typeof B.id==="string"&&B.id.trim()?B.id.trim():P1(),label:typeof B.label==="string"?B.label:void 0,enabled:typeof B.enabled==="boolean"?B.enabled:void 0,addedAt:typeof B.addedAt==="number"?B.addedAt:void 0,lastUsed:typeof B.lastUsed==="number"?B.lastUsed:void 0,accountId:typeof B.accountId==="string"?B.accountId:void 0}}function P0(B){if(!j(B))return;if(typeof B.message!=="string")return;let Z=Number(B.checkedAt);if(!Number.isFinite(Z))return;let $=Number(B.nextRetryAt),z=Number(B.retryCount);return{message:B.message,checkedAt:Z,nextRetryAt:Number.isFinite($)?$:void 0,retryCount:Number.isFinite(z)?z:void 0,tokenHash:typeof B.tokenHash==="string"?B.tokenHash:void 0}}function f1(B){if(!j(B))return;let Z={};for(let $ of["primary","secondary"]){let z=B[$];if(!j(z))continue;let G=Number(z.usedPercent),X=Number(z.remainingPercent),K=Number(z.checkedAt);if(!Number.isFinite(G)||!Number.isFinite(X)||!Number.isFinite(K))continue;Z[$]={usedPercent:G,remainingPercent:X,checkedAt:K,resetsAt:typeof z.resetsAt==="string"?z.resetsAt:void 0}}return Object.keys(Z).length?Z:void 0}function w1(B){if(!j(B))return null;if(B.type==="api"){let Z=typeof B.baseURL==="string"?B.baseURL.trim():"",$=typeof B.apiKey==="string"?B.apiKey.trim():"";if(!A1(Z))return null;let z=B.authHeader==="x-api-key"?"x-api-key":"authorization-bearer";return{...C0(B),type:"api",apiKey:$||void 0,baseURL:Z,authHeader:z}}if(B.type!=="oauth")return null;if(typeof B.refresh!=="string"||!B.refresh.trim())return null;return{...C0(B),type:"oauth",access:typeof B.access==="string"?B.access:void 0,refresh:B.refresh,expires:typeof B.expires==="number"?B.expires:void 0,lastRefreshedAt:typeof B.lastRefreshedAt==="number"?B.lastRefreshedAt:void 0,lastRefreshError:P0(B.lastRefreshError),lastQuotaRefreshError:P0(B.lastQuotaRefreshError),quota:f1(B.quota)}}function E0(B){if(!j(B)||!Array.isArray(B.accounts))return null;return{version:1,main:{type:"opencode",provider:"openai"},routing:j(B.routing)?B.routing:void 0,fallbackOn:Array.isArray(B.fallbackOn)?B.fallbackOn.filter((Z)=>Number.isInteger(Z)):void 0,refresh:j(B.refresh)?B.refresh:void 0,quota:j(B.quota)?B.quota:void 0,dump:j(B.dump)?B.dump:void 0,costZeroing:j(B.costZeroing)?B.costZeroing:void 0,killswitch:j(B.killswitch)?B.killswitch:void 0,logging:j(B.logging)?B.logging:void 0,cachekeep:j(B.cachekeep)?B.cachekeep:void 0,mainAccountId:typeof B.mainAccountId==="string"?B.mainAccountId:void 0,accounts:B.accounts.map(w1).filter((Z)=>Z!=null)}}async function E(B){try{return{exists:!0,value:JSON.parse(await h1(B,"utf8"))}}catch(Z){if(Z.code==="ENOENT")return{exists:!1,value:null};throw Z}}function M(B){return Object.fromEntries(Object.entries(B).filter(([,Z])=>Z!==void 0))}function S0(B,Z){if(!j(B))return B;let $=j(Z)?Z:{},z=j($.main)?$.main:void 0,G=j($.accounts)?$.accounts:{},X=j(B.quota)?B.quota:{},K=j(B.refresh)?B.refresh:{},J=z??X,W=z??K,Q=Array.isArray(B.accounts)?B.accounts.map((V)=>{if(!j(V))return V;let F=typeof V.id==="string"&&j(G[V.id])?G[V.id]:{};return{...V,...F}}):void 0;return x0({...B,refresh:M({...K,mainLastRefreshError:W.lastRefreshError,mainRefreshLeaseId:W.refreshLeaseId,mainRefreshLeaseUntil:W.refreshLeaseUntil,mainRefreshLeaseTokenHash:W.refreshLeaseTokenHash}),quota:M({...X,mainQuota:J.quota,mainQuotaCheckedAt:J.quotaCheckedAt,mainQuotaToken:J.quotaToken,mainLastQuotaApiError:J.lastQuotaApiError}),accounts:Q})}async function p1(B=S()){let Z=await E(B);if(!Z.exists)return null;let $=await E(n(B));return E0(S0(Z.value,$.value))}function x0(B){return Object.fromEntries(Object.entries(B).filter(([,Z])=>Z!==void 0))}function v1(B){return M({id:B.id,label:B.label,type:B.type,enabled:B.enabled,addedAt:B.addedAt,accountId:B.accountId,baseURL:B.type==="api"?B.baseURL:void 0,authHeader:B.type==="api"?B.authHeader:void 0})}function A0(B){if(B.type==="api")return M({apiKey:B.apiKey,lastUsed:B.lastUsed});return M({access:B.access,refresh:B.refresh,expires:B.expires,lastUsed:B.lastUsed,lastRefreshedAt:B.lastRefreshedAt,lastRefreshError:B.lastRefreshError,lastQuotaRefreshError:B.lastQuotaRefreshError,quota:B.quota})}function c(B){return Math.max(B?.primary?.checkedAt??0,B?.secondary?.checkedAt??0)}function d1(B,Z){if(!j(B))return Z;let $=B,z=c($.quota),G=c(Z.quota);if(z>G){let K=Boolean($.access&&Z.access&&$.access!==Z.access),J=$.lastRefreshedAt??0,W=Z.lastRefreshedAt??0;if(K&&W<=J){let Y={...$};if(typeof Z.lastUsed==="number"&&(typeof $.lastUsed!=="number"||Z.lastUsed>$.lastUsed))Y.lastUsed=Z.lastUsed;return Y}return{...$,...Z,quota:$.quota,lastQuotaRefreshError:$.lastQuotaRefreshError}}let X={...$,...Z};if(!("lastQuotaRefreshError"in Z))delete X.lastQuotaRefreshError;if(!("lastRefreshError"in Z))delete X.lastRefreshError;return X}function k0(B){let Z=B.refresh?M({enabled:B.refresh.enabled,intervalMinutes:B.refresh.intervalMinutes,refreshBeforeExpiryMinutes:B.refresh.refreshBeforeExpiryMinutes}):void 0,$=B.quota?M({enabled:B.quota.enabled,checkIntervalMinutes:B.quota.checkIntervalMinutes,refreshEveryNRequests:B.quota.refreshEveryNRequests,minimumRemaining:B.quota.minimumRemaining,failClosedOnUnknownQuota:B.quota.failClosedOnUnknownQuota,showToasts:B.quota.showToasts}):void 0;return x0({version:1,main:B.main,routing:B.routing,fallbackOn:B.fallbackOn,refresh:Z,quota:$,dump:B.dump,costZeroing:B.costZeroing,killswitch:B.killswitch,logging:B.logging,cachekeep:B.cachekeep,mainAccountId:B.mainAccountId,accounts:B.accounts.map(v1)})}function l1(B,Z){if(!B)return Z;let $=new Map;for(let z of B.accounts)$.set(z.id,z);for(let z of Z.accounts)$.set(z.id,z);return{...B,...Z,accounts:[...$.values()]}}async function X0(B){let Z=Date.now()+_0;while(Date.now()<=Z){let $=await u({name:"save",ttlMs:_0,path:B});if($)return $;let z=Z-Date.now();if(z<=0)break;await y1(Math.min(T1,z))}throw Error(`Timed out acquiring account store lock for ${B}; refusing to overwrite newer account data`)}function m0(B){let Z=Object.fromEntries(B.accounts.map(($)=>[$.id,A0($)]));return{version:1,main:M({quota:B.quota?.mainQuota,quotaCheckedAt:B.quota?.mainQuotaCheckedAt,quotaToken:B.quota?.mainQuotaToken,lastQuotaApiError:B.quota?.mainLastQuotaApiError,lastRefreshError:B.refresh?.mainLastRefreshError,refreshLeaseId:B.refresh?.mainRefreshLeaseId,refreshLeaseUntil:B.refresh?.mainRefreshLeaseUntil,refreshLeaseTokenHash:B.refresh?.mainRefreshLeaseTokenHash}),accounts:Z}}async function n4(B,Z=S()){let $=n(Z),z=await X0(Z);try{let G=await X0($);try{let X=await E(Z),K=await E($),J=X.exists?E0(S0(X.value,K.value)):null,W=l1(J,B),Q={...j(X.value)?X.value:{},...k0(W)};await T(Z,Q),await T($,m0(W))}finally{await G.release()}}finally{await z.release()}}function g1(B,Z){B.main=B.main??{};let $=typeof B.main.quotaCheckedAt==="number"?B.main.quotaCheckedAt:c(B.main.quota),z=typeof Z.quota?.mainQuotaCheckedAt==="number"?Z.quota.mainQuotaCheckedAt:c(Z.quota?.mainQuota);if($>z)return;B.main.quota=Z.quota?.mainQuota,B.main.quotaCheckedAt=Z.quota?.mainQuotaCheckedAt,B.main.quotaToken=Z.quota?.mainQuotaToken,B.main.lastQuotaApiError=Z.quota?.mainLastQuotaApiError}function i1(B,Z){B.main=B.main??{},B.main.lastRefreshError=Z.refresh?.mainLastRefreshError,B.main.refreshLeaseId=Z.refresh?.mainRefreshLeaseId,B.main.refreshLeaseUntil=Z.refresh?.mainRefreshLeaseUntil,B.main.refreshLeaseTokenHash=Z.refresh?.mainRefreshLeaseTokenHash}function G0(B){if(Array.isArray(B))return B.map(G0);if(!j(B))return B;return Object.fromEntries(Object.entries(B).filter(([,Z])=>Z!==void 0).map(([Z,$])=>[Z,G0($)]))}async function u1(B,Z=S(),$={mainQuota:!0,mainRefresh:!0,accounts:!0}){let z=n(Z),G=await X0(z);try{let X=(await E(z)).value,K=j(X)?{...X,version:1}:{version:1};if($.mainQuota)g1(K,B);if($.mainRefresh)i1(K,B);if($.accounts){let J=$.accounts===!0?null:new Set($.accounts);K.accounts={...j(K.accounts)?K.accounts:{}};for(let W of B.accounts){if(J&&!J.has(W.id))continue;K.accounts[W.id]=d1(K.accounts[W.id],A0(W))}if(J){for(let W of J)if(!B.accounts.some((Y)=>Y.id===W))delete K.accounts[W]}}await T(z,G0(K))}finally{await G.release()}}function s1(B){return B?.fallbackOn?.length?B.fallbackOn:k1}function r4(B,Z){return s1(Z).includes(B)}function c1(B){let Z=B?.quota?.minimumRemaining||{};return{primary:Z.primary??Z["5h"]??U0.primary,secondary:Z.secondary??Z["1w"]??U0.secondary}}function K0(B){return B?.quota?.enabled!==!1}function f0(B){return B?.quota?.failClosedOnUnknownQuota??m1}function w0(B,Z){if(!K0(Z))return!0;let $=c1(Z);for(let z of["primary","secondary"]){let G=B?.[z];if(!G)return!f0(Z);if(G.remainingPercent<$[z])return!1}return!0}function n1(B){return typeof B.version==="number"&&Array.isArray(B.accounts)}async function a4(B,Z=S()){let $=await u({name:"migrate",ttlMs:30000,path:Z});if(!$)return;try{let z=await E(Z);if(z.exists&&j(z.value)){if(n1(z.value))return}if(!B)return;let G={version:1,main:{type:"opencode",provider:"openai"},accounts:[]};if(B.access){let J=R({id_token:"",access_token:B.access,refresh_token:B.refresh});if(J)G.mainAccountId=J}let K={...z.exists&&j(z.value)?z.value:{},...k0(G)};await T(Z,K),await T(n(Z),m0(G))}finally{await $.release()}}function r1(B){return B?.refresh?.enabled!==!1}function a1(B){return(B?.refresh?.refreshBeforeExpiryMinutes??240)*60000}function o1(B){return Math.floor(Math.random()*(B+1))}function P(B,Z,$){return!B.access||!B.expires||B.expires-$<=a1(Z)}function b(B,Z){let $=B.accounts.findIndex((z)=>z.id===Z.id);if($!==-1)B.accounts[$]=Z}function $0(B){return B instanceof Error?B.message:String(B)}function h0(B,Z,$){B.lastRefreshError=V0({error:Z,now:$,refreshToken:B.refresh,previous:B.lastRefreshError})}function z0(B,Z,$){if(B.lastQuotaRefreshError=H0({error:Z,now:$,previous:B.lastQuotaRefreshError}),Z?.isRefreshError===!0)h0(B,Z,$)}function t1(B){return`fallback-oauth-refresh-${C1("sha256").update(B).digest("base64url").slice(0,16)}`}function I0(B,Z){if(!B)return!1;if(!B.resetsAt)return!0;let $=Date.parse(B.resetsAt);return Number.isFinite($)?$>Z:!0}function e1(B,Z){if(!B)return!1;return I0(B[g],Z)||I0(B[i],Z)}function B4(B,Z,$){if(!B)return!1;let z=Z?.quota?.checkIntervalMinutes??5,G=Math.max(1,z)*60000,X=Math.max(B[g]?.checkedAt??0,B[i]?.checkedAt??0);return $-X<G}function R0(B,Z,$){return!B4(B.quota,Z,$)}function Z4(B,Z,$,z){return a($)&&w0(B.quota,Z)&&e1(B.quota,z)}function $4(B){let Z=B?.quota?.checkIntervalMinutes??5;return Math.max(1,Z)*60000}var z4=60000,X4=60000,G4=600000,K4=1e4,J4=100;var o4=globalThis.setTimeout.bind(globalThis),t4=globalThis.clearTimeout.bind(globalThis);class W4{now;fetchImpl;configPath;refreshPromises=new Map;refreshTimer=null;quotaTimer=null;quotaManager;onFallbackStorageChanged;options;constructor(B={}){this.options=B,this.now=B.now??Date.now,this.fetchImpl=B.fetchImpl??fetch,this.configPath=B.configPath??S(),this.quotaManager=B.quotaManager??null,this.onFallbackStorageChanged=B.onFallbackStorageChanged}seedFallbackQuota(B,Z){if(!this.quotaManager)return;if(!B.quota)return;let $=Math.max(B.quota[g]?.checkedAt??0,B.quota[i]?.checkedAt??0);if($<=0)return;let z=this.quotaManager.getFallback(B.id,B.access);if(z&&z.checkedAt>=$)return;this.quotaManager.setFallback(B.id,{quota:B.quota,refreshAfter:$+$4(Z),checkedAt:$},B.access)}async load(){return p1(this.configPath)}async save(B,Z){await u1(B,this.configPath,{accounts:Z??!0})}startBackgroundRefresh(){let B=async()=>{if(await this.refreshDueAccounts(),this.options.fetchQuotaFn)await this.refreshQuotaForDueAccounts()};if(B().catch(()=>{}),!this.refreshTimer){if(this.refreshTimer=setInterval(()=>{B().catch(()=>{})},z4+o1(X4)),"unref"in this.refreshTimer)this.refreshTimer.unref()}}stopBackgroundRefresh(){if(this.refreshTimer)clearInterval(this.refreshTimer);if(this.quotaTimer)clearInterval(this.quotaTimer);this.refreshTimer=null,this.quotaTimer=null}async getUsableFallbackAccounts(B){let Z=B!==void 0?B:await this.load();if(!Z)return[];let $=[],z=!1;for(let G of Z.accounts){if(G.enabled===!1||!C(G))continue;try{let X=G;if(P(X,Z,this.now())){let K=X.lastRefreshError;if(K&&I(K,X.refresh,this.now()))throw Error(d(K,this.now()));X=await this.refreshAccount(X,Z),z=!0}if(this.seedFallbackQuota(X,Z),this.accountPassesQuotaPolicy(this.quotaPolicyAccount(X),Z))$.push(X)}catch(X){if(Z4(G,Z,X,this.now()))U.debug("fallback quota using cached quota after refresh error",{pid:process.pid,accountId:G.id,error:$0(X)}),$.push(G);else if(!f0(Z))$.push(G)}}if(z)await this.save(Z);return $}async markUsed(B){let Z=await this.load();if(!Z)return;let $=Z.accounts.find((z)=>z.id===B.id);if(!$)return;$.lastUsed=this.now(),await this.save(Z)}accountPassesQuotaPolicy(B,Z){return w0(B.quota,Z)}quotaPolicyAccount(B){if(!this.quotaManager)return B;let Z=this.quotaManager.getFallback(B.id,B.access)?.quota;return Z?{...B,quota:Z}:B}async refreshDueAccounts(){let B=await this.load();if(!B||!r1(B))return;let Z=!1;for(let $ of B.accounts){if($.enabled===!1||!C($))continue;if(!P($,B,this.now()))continue;if(I($.lastRefreshError,$.refresh,this.now()))continue;try{U.debug("fallback oauth background due",{pid:process.pid,accountId:$.id,expiresInMs:$.expires?$.expires-this.now():void 0}),await this.refreshAccount($,B),Z=!0}catch(z){U.warn("fallback oauth background failed",{pid:process.pid,accountId:$.id,error:$0(z)}),h0($,z,this.now()),b(B,$),Z=!0}}if(Z)await this.save(B)}async refreshQuotaForDueAccounts(){let B=await this.load();if(!B||!K0(B))return;if(!this.options.fetchQuotaFn)return;let Z=!1;for(let $ of B.accounts){if($.enabled===!1||!C($))continue;let z=$;try{if(P(z,B,this.now())){if(I(z.lastRefreshError,z.refresh,this.now()))continue;z=await this.refreshAccount(z,B),Z=!0}if(b0(z.lastQuotaRefreshError,this.now()))continue;if(this.seedFallbackQuota(z,B),!(this.quotaManager?this.quotaManager.isFallbackStale(z.id,z.access):R0(z,B,this.now())))continue;await this.refreshAccountQuota(z,B),Z=!0}catch(G){z0($,G,this.now()),b(B,$),Z=!0}}if(Z)await this.save(B),this.onFallbackStorageChanged?.()}async refreshQuotaForAllAccounts(B={}){let Z=await this.load(),$=[];if(!Z||!K0(Z))return{storage:Z,errors:$};if(!this.options.fetchQuotaFn)return{storage:Z,errors:$};let z=B.force??!1,G=!1;for(let X of Z.accounts){if(X.enabled===!1||!C(X))continue;let K=X;try{if(P(K,Z,this.now())){let J=K.lastRefreshError;if(J&&I(J,K.refresh,this.now()))throw Error(d(J,this.now()));K=await this.refreshAccount(K,Z),G=!0}if(!z&&!R0(K,Z,this.now())){if(K.lastQuotaRefreshError)K.lastQuotaRefreshError=void 0,b(Z,K),G=!0;continue}await this.refreshAccountQuota(K,Z),G=!0}catch(J){z0(X,J,this.now()),b(Z,X),G=!0,$.push({accountId:X.id,message:$0(J)})}}if(G)await this.save(Z);return{storage:Z,errors:$}}async refreshAccount(B,Z,$={}){let z=this.refreshPromises.get(B.id);if(z){let K=await z;return b(Z,K),K}let G=this.refreshAccountNow(B,Z,$).finally(()=>{this.refreshPromises.delete(B.id)});this.refreshPromises.set(B.id,G);let X=await G;return b(Z,X),X}async waitForConcurrentFallbackRefresh(B,Z,$,z){let G=Date.now()+K4;while(Date.now()<G){await new Promise((Y)=>setTimeout(Y,J4));let X=await this.load(),K=X?.accounts.find((Y)=>Y.id===B.id&&C(Y));if(!K)continue;if((K.access!==$.access||K.refresh!==$.refresh||(K.expires??0)>($.expires??0)+60000)&&(z.force||!P(K,X,this.now())))return b(Z,K),U.debug("fallback oauth joined concurrent refresh",{pid:process.pid,accountId:K.id,expiresInMs:K.expires?K.expires-this.now():void 0}),K;let W=K.lastRefreshError;if(W&&I(W,K.refresh,this.now()))throw b(Z,K),Error(d(W,this.now()))}return null}async refreshAccountNow(B,Z,$){let z=await this.load(),G=z?.accounts.find((J)=>J.id===B.id&&C(J));if(G&&!$.force&&!P(G,z,this.now()))return b(Z,G),G;let X=G??B,K=await u({name:t1(X.id),ttlMs:G4,path:this.configPath,now:this.now,renew:!0});if(!K){U.debug("fallback oauth refresh skipped file lock",{pid:process.pid,accountId:X.id});let J=await this.waitForConcurrentFallbackRefresh(B,Z,X,$);if(J)return J;throw Error("Fallback OAuth refresh is already in progress")}try{if(z=await this.load(),G=z?.accounts.find((Y)=>Y.id===B.id&&C(Y)),G&&!$.force&&!P(G,z,this.now()))return b(Z,G),G;X=G??X;let J=this.options.refreshFn??(async()=>{throw Error("No refreshFn injected into FallbackAccountManager")});U.debug("fallback oauth refresh request start",{pid:process.pid,accountId:X.id,force:$.force===!0,expiresInMs:X.expires?X.expires-this.now():void 0});let W=await J({refreshToken:X.refresh,fetchImpl:this.fetchImpl,now:this.now});return X.access=W.access,X.refresh=W.refresh,X.expires=W.expires,X.lastRefreshedAt=W.expires-W.expiresIn*1000,X.lastRefreshError=void 0,b(Z,X),await this.save(Z),U.debug("fallback oauth refresh succeeded",{pid:process.pid,accountId:X.id,expiresInMs:X.expires?X.expires-this.now():void 0}),X}finally{await K.release()}}async refreshAccountQuota(B,Z){let $=B;if(!$.access)throw Error(`Fallback account ${B.id} has no access token`);if(!this.options.fetchQuotaFn)throw Error("No fetchQuotaFn injected — wham/usage supplement is disabled");let z=this.options.fetchQuotaFn??(async()=>{throw Error("No fetchQuotaFn injected — wham/usage supplement is disabled")}),G=(X)=>this.quotaManager?this.quotaManager.refreshFallback($.id,X):z({accessToken:X,fetchImpl:this.fetchImpl,now:this.now});try{if(!$.access)throw Error(`Fallback account ${B.id} has no access token`);let X=await G($.access);$.quota=X,$.lastQuotaRefreshError=void 0,b(Z,$),await this.save(Z)}catch(X){throw z0(B,X,this.now()),b(Z,B),X}}}
|
|
92
|
-
export{N0 as g,V0 as h,I as i,d as j,H0 as k,b0 as l,M0 as m,q0 as n,o0 as o,D0 as p,L0 as q,R as r,t0 as s,y as t,$1 as u,z1 as v,X1 as w,G1 as x,L4 as y,M4 as z,_4 as A,U4 as B,u as C,S as D,C as E,u4 as F,s4 as G,p1 as H,n4 as I,r4 as J,a4 as K,W4 as L};
|
package/dist/index-sgfft5d3.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function A(b){if(b==null||b==="")return;let g=typeof b==="number"?b:Number(b);if(Number.isFinite(g)){let z=g<100000000000?g*1000:g,B=new Date(z);return Number.isNaN(B.getTime())?void 0:B.toISOString()}let q=new Date(b);return Number.isNaN(q.getTime())?void 0:q.toISOString()}function C(b,g){let q=b.get(g);if(q===null)return;let z=Number(q);if(!Number.isFinite(z))return;return{usedPercent:z,remainingPercent:100-z,resetsAt:A(b.get(`${g.slice(0,-13)}-reset-at`)??void 0),checkedAt:Date.now()}}function G(b){let g={},q=C(b,"x-codex-primary-used-percent");if(q)g.primary=q;let z=C(b,"x-codex-secondary-used-percent");if(z)g.secondary=z;return g}function D(b){if(!b)return;if(!Number.isFinite(b.used_percent))return;return{usedPercent:b.used_percent,remainingPercent:100-b.used_percent,resetsAt:A(b.reset_at),checkedAt:Date.now()}}function J(b){let g={},q=D(b.rate_limits?.primary);if(q)g.primary=q;let z=D(b.rate_limits?.secondary);if(z)g.secondary=z;return g}function E(b){if(!b)return;if(!Number.isFinite(b.used_percent))return;return{usedPercent:b.used_percent,remainingPercent:100-b.used_percent,resetsAt:A(b.reset_at),checkedAt:Date.now()}}function K(b){let g={},q=E(b.rate_limit?.primary_window);if(q)g.primary=q;let z=E(b.rate_limit?.secondary_window);if(z)g.secondary=z;return g}
|
|
2
|
-
export{A as c,G as d,J as e,K as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as a,d as b,e as c,f as d}from"./index-sgfft5d3.js";import"./index-hrg6bdgb.js";export{a as toResetIso,c as normalizeWsFrame,d as normalizeWham,b as normalizeQuotaHeaders};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as a}from"./index-6qjg8qfw.js";import"./index-hrg6bdgb.js";export default a();
|