@cortexkit/pi-anthropic-auth 2.2.6 → 2.2.8
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/dist/stream.js +2 -2
- package/dist/transport.js +9 -23
- package/package.json +2 -2
package/dist/stream.js
CHANGED
|
@@ -1032,7 +1032,7 @@ async function executeWithFallback(options) {
|
|
|
1032
1032
|
type: 'error',
|
|
1033
1033
|
error: {
|
|
1034
1034
|
type: 'rate_limit_error',
|
|
1035
|
-
message: 'Sticky OAuth account
|
|
1035
|
+
message: 'Sticky OAuth account quota resets shortly; retaining session affinity.',
|
|
1036
1036
|
},
|
|
1037
1037
|
}), {
|
|
1038
1038
|
status: 429,
|
|
@@ -1083,7 +1083,7 @@ async function executeWithFallback(options) {
|
|
|
1083
1083
|
type: 'error',
|
|
1084
1084
|
error: {
|
|
1085
1085
|
type: 'rate_limit_error',
|
|
1086
|
-
message: 'Sticky OAuth account
|
|
1086
|
+
message: 'Sticky OAuth account quota resets shortly; retaining session affinity.',
|
|
1087
1087
|
},
|
|
1088
1088
|
}), { status: 429, headers }));
|
|
1089
1089
|
}
|
package/dist/transport.js
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { createAnthropicOAuthFetch, requireAnthropicOAuthOrigin, } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
// Pi keeps its own refusal wording; Core supplies the origin rule itself.
|
|
3
|
+
const PI_OAUTH_ORIGIN = {
|
|
4
|
+
refusal: (reason) => new Error(reason === 'unparseable'
|
|
5
|
+
? 'Native OAuth requires the official Anthropic HTTPS origin'
|
|
6
|
+
: 'Native OAuth requires the official Anthropic HTTPS origin without URL userinfo'),
|
|
7
|
+
};
|
|
2
8
|
/** Model base URLs and remembered cache-warm URLs must send OAuth tokens only to Anthropic’s HTTPS server. */
|
|
3
9
|
export function requirePiOAuthOrigin(value) {
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
url = new URL(value);
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
throw new Error('Native OAuth requires the official Anthropic HTTPS origin');
|
|
10
|
-
}
|
|
11
|
-
if (url.protocol !== 'https:' ||
|
|
12
|
-
url.origin !== ANTHROPIC_ORIGIN ||
|
|
13
|
-
url.username ||
|
|
14
|
-
url.password)
|
|
15
|
-
throw new Error('Native OAuth requires the official Anthropic HTTPS origin without URL userinfo');
|
|
16
|
-
return url;
|
|
10
|
+
return requireAnthropicOAuthOrigin(value, PI_OAUTH_ORIGIN);
|
|
17
11
|
}
|
|
18
12
|
export function buildPiOAuthMessagesUrl(baseUrl) {
|
|
19
13
|
return new URL('/v1/messages?beta=true', requirePiOAuthOrigin(baseUrl));
|
|
20
14
|
}
|
|
21
15
|
/** Reject redirects rather than letting an approved OAuth destination forward the request. */
|
|
22
|
-
export const fetchPiOAuth =
|
|
23
|
-
requirePiOAuthOrigin(input instanceof Request ? input.url : String(input));
|
|
24
|
-
return fetch(input, { ...init, redirect: 'error' });
|
|
25
|
-
}, {
|
|
26
|
-
preconnect: (...args) => {
|
|
27
|
-
requirePiOAuthOrigin(String(args[0]));
|
|
28
|
-
return fetch.preconnect(...args);
|
|
29
|
-
},
|
|
30
|
-
});
|
|
16
|
+
export const fetchPiOAuth = createAnthropicOAuthFetch(PI_OAUTH_ORIGIN);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/pi-anthropic-auth",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cortexkit/anthropic-auth-core": "2.2.
|
|
39
|
+
"@cortexkit/anthropic-auth-core": "2.2.8"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@earendil-works/pi-ai": ">=0.86.1 <2",
|