@ex-machina/opencode-anthropic-auth 1.1.0 → 1.1.2

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 CHANGED
@@ -12,6 +12,19 @@ Add the plugin to your OpenCode configuration:
12
12
  }
13
13
  ```
14
14
 
15
+ > [!TIP]
16
+ > It is STRONGLY advised that you pin the plugin to a version. This will keep you from getting automatic updates; however, this will protect you from nefarious updates.
17
+ >
18
+ > This holds true for ANY OpenCode plugin. If you do not pin them, OpenCode will automatically update them on startup. It's a massive vulnerability waiting to happen.
19
+
20
+ #### Example of pinned version
21
+
22
+ ```json
23
+ {
24
+ "plugin": ["@ex-machina/opencode-anthropic-auth@1.1.1"]
25
+ }
26
+ ```
27
+
15
28
  ## Authentication Methods
16
29
 
17
30
  The plugin provides three authentication options:
@@ -8,3 +8,4 @@ export declare const TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
8
8
  export declare const OAUTH_SCOPES: string[];
9
9
  export declare const TOOL_PREFIX = "mcp_";
10
10
  export declare const REQUIRED_BETAS: string[];
11
+ export declare const USER_AGENT = "claude-cli/2.1.2 (external, cli)";
package/dist/constants.js CHANGED
@@ -18,3 +18,4 @@ export const REQUIRED_BETAS = [
18
18
  'oauth-2025-04-20',
19
19
  'interleaved-thinking-2025-05-14',
20
20
  ];
21
+ export const USER_AGENT = 'claude-cli/2.1.2 (external, cli)';
package/dist/index.js CHANGED
@@ -65,7 +65,8 @@ export const AnthropicAuthPlugin = async ({ client }) => {
65
65
  await response.body?.cancel();
66
66
  continue;
67
67
  }
68
- throw new Error(`Token refresh failed: ${response.status}`);
68
+ const body = await response.text().catch(() => '');
69
+ throw new Error(`Token refresh failed: ${response.status} — ${body}`);
69
70
  }
70
71
  const json = (await response.json());
71
72
  // biome-ignore lint/suspicious/noExplicitAny: SDK types don't expose auth.set
package/dist/transform.js CHANGED
@@ -1,4 +1,4 @@
1
- import { REQUIRED_BETAS, TOOL_PREFIX } from './constants';
1
+ import { REQUIRED_BETAS, TOOL_PREFIX, USER_AGENT } from './constants';
2
2
  /**
3
3
  * Merge headers from a Request object and/or a RequestInit headers value
4
4
  * into a single Headers instance.
@@ -53,7 +53,7 @@ export function mergeBetaHeaders(headers) {
53
53
  export function setOAuthHeaders(headers, accessToken) {
54
54
  headers.set('authorization', `Bearer ${accessToken}`);
55
55
  headers.set('anthropic-beta', mergeBetaHeaders(headers));
56
- headers.set('user-agent', 'claude-cli/2.1.2 (external, cli)');
56
+ headers.set('user-agent', USER_AGENT);
57
57
  headers.delete('x-api-key');
58
58
  return headers;
59
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ex-machina/opencode-anthropic-auth",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ex-machina-co/opencode-anthropic-auth"
@@ -11,6 +11,7 @@
11
11
  "dist"
12
12
  ],
13
13
  "scripts": {
14
+ "prepare": "tsc -p tsconfig.build.json",
14
15
  "build": "tsc -p tsconfig.build.json",
15
16
  "test": "bun test",
16
17
  "types": "tsc",