opencode-anthropic-fix 0.1.31 → 0.1.32
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/lib/config.mjs +9 -10
- package/lib/oauth.mjs +1 -1
- package/lib/oauth.test.mjs +8 -4
- package/package.json +1 -1
package/lib/config.mjs
CHANGED
|
@@ -435,18 +435,17 @@ export const DEFAULT_CONFIG = {
|
|
|
435
435
|
/** Also inject numeric length anchors (≤25 words between tool calls, ≤100 words final). */
|
|
436
436
|
length_anchors: true,
|
|
437
437
|
},
|
|
438
|
-
/** OAuth token-endpoint request fingerprint.
|
|
439
|
-
* validated against a live refresh. */
|
|
438
|
+
/** OAuth token-endpoint request fingerprint. */
|
|
440
439
|
oauth: {
|
|
441
|
-
/** When true, the OAuth token EXCHANGE/REFRESH POSTs use Claude
|
|
442
|
-
* 2.1.195's SDK-native-fetch fingerprint (`User-Agent:
|
|
440
|
+
/** When true (DEFAULT), the OAuth token EXCHANGE/REFRESH POSTs use Claude
|
|
441
|
+
* Code 2.1.195's SDK-native-fetch fingerprint (`User-Agent:
|
|
443
442
|
* anthropic-sdk-typescript/0.94.0 userOAuthProvider`, `anthropic-beta:
|
|
444
|
-
* oauth-2025-04-20`, no axios `Accept`). When false
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
* Default
|
|
448
|
-
*
|
|
449
|
-
sdk_token_useragent:
|
|
443
|
+
* oauth-2025-04-20`, no axios `Accept`). When false, the legacy axios
|
|
444
|
+
* fingerprint (`User-Agent: axios/1.13.6`, axios `Accept` header) is sent
|
|
445
|
+
* byte-for-byte as before.
|
|
446
|
+
* Default ON to match upstream CC 2.1.195's userOAuthProvider. Set to
|
|
447
|
+
* `false` to revert to the legacy axios/1.13.6 + `Accept` fingerprint. */
|
|
448
|
+
sdk_token_useragent: true,
|
|
450
449
|
},
|
|
451
450
|
};
|
|
452
451
|
|
package/lib/oauth.mjs
CHANGED
|
@@ -58,7 +58,7 @@ function generatePKCE() {
|
|
|
58
58
|
/**
|
|
59
59
|
* Resolve whether the SDK-native-fetch token fingerprint should be used.
|
|
60
60
|
* An explicit boolean override (used by callers/tests) wins; otherwise the
|
|
61
|
-
* live `oauth.sdk_token_useragent` config flag is read (default
|
|
61
|
+
* live `oauth.sdk_token_useragent` config flag is read (default true).
|
|
62
62
|
* @param {boolean | undefined} override
|
|
63
63
|
* @returns {boolean}
|
|
64
64
|
*/
|
package/lib/oauth.test.mjs
CHANGED
|
@@ -13,7 +13,7 @@ describe("oauth headers", () => {
|
|
|
13
13
|
vi.unstubAllGlobals();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it("sends
|
|
16
|
+
it("sends SDK native-fetch fingerprint by default on token exchange", async () => {
|
|
17
17
|
mockFetch.mockResolvedValueOnce({
|
|
18
18
|
ok: false,
|
|
19
19
|
status: 400,
|
|
@@ -23,10 +23,12 @@ describe("oauth headers", () => {
|
|
|
23
23
|
await exchange("code#state", "verifier");
|
|
24
24
|
|
|
25
25
|
const [, init] = mockFetch.mock.calls[0];
|
|
26
|
-
expect(init.headers["User-Agent"]).toBe("
|
|
26
|
+
expect(init.headers["User-Agent"]).toBe("anthropic-sdk-typescript/0.94.0 userOAuthProvider");
|
|
27
|
+
expect(init.headers["anthropic-beta"]).toBe("oauth-2025-04-20");
|
|
28
|
+
expect("Accept" in init.headers).toBe(false);
|
|
27
29
|
});
|
|
28
30
|
|
|
29
|
-
it("sends
|
|
31
|
+
it("sends SDK native-fetch fingerprint by default on token refresh", async () => {
|
|
30
32
|
mockFetch.mockResolvedValueOnce({
|
|
31
33
|
ok: true,
|
|
32
34
|
json: async () => ({ access_token: "a", refresh_token: "r", expires_in: 3600 }),
|
|
@@ -35,7 +37,9 @@ describe("oauth headers", () => {
|
|
|
35
37
|
await refreshToken("refresh-token");
|
|
36
38
|
|
|
37
39
|
const [, init] = mockFetch.mock.calls[0];
|
|
38
|
-
expect(init.headers["User-Agent"]).toBe("
|
|
40
|
+
expect(init.headers["User-Agent"]).toBe("anthropic-sdk-typescript/0.94.0 userOAuthProvider");
|
|
41
|
+
expect(init.headers["anthropic-beta"]).toBe("oauth-2025-04-20");
|
|
42
|
+
expect("Accept" in init.headers).toBe(false);
|
|
39
43
|
});
|
|
40
44
|
|
|
41
45
|
it("sends Claude Code user-agent on token revoke", async () => {
|