Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@cortexkit/anthropic-auth-core

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cortexkit/anthropic-auth-core - npm Package Compare versions

Comparing version
1.2.4
to
1.2.5
+47
-2
dist/accounts.js

@@ -472,2 +472,31 @@ import { createHash, randomUUID } from 'node:crypto';

}
function cachedQuotaWindowStillRelevant(window, now) {
if (!window)
return false;
if (!window.resetsAt)
return true;
const resetTime = Date.parse(window.resetsAt);
return !Number.isFinite(resetTime) || resetTime > now;
}
function cachedQuotaSnapshotStillRelevant(quota, now) {
return ['five_hour', 'seven_day'].every((key) => cachedQuotaWindowStillRelevant(quota?.[key], now));
}
function isTransientQuotaError(error) {
const message = formatErrorMessage(error);
if (/Claude quota check failed: (429|5\d\d)\b/.test(message))
return true;
if (!(error instanceof Error))
return false;
const code = error.code;
return (message.includes('fetch failed') ||
code === 'ECONNRESET' ||
code === 'ECONNREFUSED' ||
code === 'ETIMEDOUT' ||
code === 'UND_ERR_CONNECT_TIMEOUT');
}
function canUseCachedQuotaAfterRefreshError(account, storage, error, now) {
return (isTransientQuotaError(error) &&
quotaSnapshotPassesPolicy(account.quota, storage) &&
cachedQuotaSnapshotStillRelevant(account.quota, now));
}
function clampPercent(value) {

@@ -614,5 +643,13 @@ if (!Number.isFinite(value))

}
catch {
if (!failClosedOnUnknownQuota(storage))
catch (error) {
if (canUseCachedQuotaAfterRefreshError(account, storage, error, this.now())) {
log('[refresh] fallback quota using cached quota after refresh error', {
accountId: account.id,
error: formatErrorMessage(error),
});
usable.push(account);
}
else if (!failClosedOnUnknownQuota(storage)) {
usable.push(account);
}
}

@@ -731,2 +768,10 @@ }

}
if (!quotaIsStale(next, storage, this.now())) {
if (next.lastQuotaRefreshError) {
next.lastQuotaRefreshError = undefined;
updateStoredAccount(storage, next);
changed = true;
}
continue;
}
await this.refreshAccountQuota(next, storage);

@@ -733,0 +778,0 @@ changed = true;

+1
-1
{
"name": "@cortexkit/anthropic-auth-core",
"version": "1.2.4",
"version": "1.2.5",
"type": "module",

@@ -5,0 +5,0 @@ "repository": {