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
24
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.2
to
1.2.3
+11
-3
dist/accounts.js

@@ -383,5 +383,13 @@ import { createHash, randomUUID } from 'node:crypto';

const retryCount = previousRetryCount + 1;
const delay = isTransientRefreshError(input.error)
? Math.min(MAX_REFRESH_RETRY_DELAY_MS, MIN_REFRESH_RETRY_DELAY_MS * 2 ** Math.min(retryCount - 1, 6))
: NON_TRANSIENT_REFRESH_RETRY_DELAY_MS;
let delay;
if (input.error instanceof ClaudeOAuthRefreshError &&
input.error.retryAfter) {
delay = input.error.retryAfter * 1000;
}
else if (isTransientRefreshError(input.error)) {
delay = Math.min(MAX_REFRESH_RETRY_DELAY_MS, MIN_REFRESH_RETRY_DELAY_MS * 2 ** Math.min(retryCount - 1, 6));
}
else {
delay = NON_TRANSIENT_REFRESH_RETRY_DELAY_MS;
}
return {

@@ -388,0 +396,0 @@ message: formatErrorMessage(input.error),

export declare class ClaudeOAuthRefreshError extends Error {
readonly status: number;
readonly body: string;
constructor(status: number, body: string);
/** Parsed Retry-After value in seconds, if the server provided one. */
readonly retryAfter: number | undefined;
constructor(status: number, body: string, retryAfterHeader?: string | null);
}

@@ -6,0 +8,0 @@ export type ClaudeOAuthRefreshResult = {

import { AUTHORIZE_URLS, CLIENT_ID, CODE_CALLBACK_URL, OAUTH_SCOPES, TOKEN_URL, } from "./constants.js";
import { generatePKCE } from "./pkce.js";
function parseRetryAfterHeader(value) {
if (!value)
return undefined;
const seconds = Number(value);
if (Number.isFinite(seconds) && seconds > 0)
return Math.ceil(seconds);
const date = Date.parse(value);
if (Number.isFinite(date)) {
const delta = Math.ceil((date - Date.now()) / 1000);
return delta > 0 ? delta : undefined;
}
return undefined;
}
export class ClaudeOAuthRefreshError extends Error {
status;
body;
constructor(status, body) {
/** Parsed Retry-After value in seconds, if the server provided one. */
retryAfter;
constructor(status, body, retryAfterHeader) {
super(`Claude OAuth refresh failed: ${status} — ${body}`);

@@ -11,2 +26,3 @@ this.status = status;

this.name = 'ClaudeOAuthRefreshError';
this.retryAfter = parseRetryAfterHeader(retryAfterHeader ?? undefined);
}

@@ -39,2 +55,3 @@ }

Accept: 'application/json',
'User-Agent': 'axios/1.13.6',
},

@@ -53,3 +70,3 @@ body: JSON.stringify({

const body = await response.text().catch(() => '');
throw new ClaudeOAuthRefreshError(response.status, body);
throw new ClaudeOAuthRefreshError(response.status, body, response.headers.get('retry-after'));
}

@@ -56,0 +73,0 @@ const json = (await response.json());

@@ -7,3 +7,3 @@ export declare const CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";

export declare const CODE_CALLBACK_URL = "https://platform.claude.com/oauth/code/callback";
export declare const TOKEN_URL = "https://api.anthropic.com/v1/oauth/token";
export declare const TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
export declare const OAUTH_SCOPES: string[];

@@ -10,0 +10,0 @@ export declare const TOOL_PREFIX = "mcp_";

@@ -7,3 +7,3 @@ export const CLIENT_ID = '9d1c250a-e61b-44d9-88ed-5944d1962f5e';

export const CODE_CALLBACK_URL = 'https://platform.claude.com/oauth/code/callback';
export const TOKEN_URL = 'https://api.anthropic.com/v1/oauth/token';
export const TOKEN_URL = 'https://platform.claude.com/v1/oauth/token';
export const OAUTH_SCOPES = [

@@ -10,0 +10,0 @@ 'org:create_api_key',

{
"name": "@cortexkit/anthropic-auth-core",
"version": "1.2.2",
"version": "1.2.3",
"type": "module",

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