opencode-gemini-cli-oauth 1.1.8 → 1.1.10
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/plugin.d.ts +1 -6
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +27 -31
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -2
package/dist/plugin.d.ts
CHANGED
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
6
|
import type { PluginContext } from './types.js';
|
|
7
|
-
/**
|
|
8
|
-
* Custom fetch implementation with OAuth token injection
|
|
9
|
-
*/
|
|
10
|
-
declare function authenticatedFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
11
7
|
/**
|
|
12
8
|
* OpenCode Plugin for Gemini CLI OAuth Authentication
|
|
13
9
|
*/
|
|
@@ -19,7 +15,7 @@ export default function GeminiCLIOAuthPlugin({ client, directory }: PluginContex
|
|
|
19
15
|
*/
|
|
20
16
|
loader: (getAuth: any, provider: string) => Promise<{
|
|
21
17
|
apiKey: string;
|
|
22
|
-
fetch:
|
|
18
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
23
19
|
}>;
|
|
24
20
|
/**
|
|
25
21
|
* Auth methods for 'opencode auth login' menu
|
|
@@ -53,5 +49,4 @@ export declare const metadata: {
|
|
|
53
49
|
opencode: string;
|
|
54
50
|
};
|
|
55
51
|
};
|
|
56
|
-
export {};
|
|
57
52
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,YAAY,CAAC;AAK5D;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,YAAY,CAAC;AAK5D;;GAEG;AACH,wBAA8B,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,aAAa;;;QAOjF;;WAEG;0BACqB,GAAG,YAAY,MAAM;;yBAKtB,WAAW,GAAG,GAAG,SAAS,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;;QAgChF;;WAEG;;;;;;;;;;;;;;;;;;;;GA8BR;AAED,eAAO,MAAM,QAAQ;;;;;;;;CAQpB,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -6,40 +6,11 @@
|
|
|
6
6
|
import { OAuthManager } from './auth/oauth.js';
|
|
7
7
|
// Instantiate manager once
|
|
8
8
|
const oauthManager = new OAuthManager();
|
|
9
|
-
/**
|
|
10
|
-
* Custom fetch implementation with OAuth token injection
|
|
11
|
-
*/
|
|
12
|
-
async function authenticatedFetch(input, init) {
|
|
13
|
-
const urlStr = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
|
|
14
|
-
// Only intercept Gemini API requests
|
|
15
|
-
if (!urlStr.includes('generativelanguage.googleapis.com')) {
|
|
16
|
-
return fetch(input, init);
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
// Get OAuth token
|
|
20
|
-
const token = await oauthManager.getAccessToken();
|
|
21
|
-
// Inject Authorization header
|
|
22
|
-
const headers = new Headers(init?.headers);
|
|
23
|
-
headers.set('Authorization', `Bearer ${token}`);
|
|
24
|
-
// Remove API key from URL if present (OAuth doesn't need it)
|
|
25
|
-
const urlObj = new URL(urlStr);
|
|
26
|
-
urlObj.searchParams.delete('key');
|
|
27
|
-
return fetch(urlObj.toString(), {
|
|
28
|
-
...init,
|
|
29
|
-
headers
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error('❌ [Gemini OAuth] Token error:', error);
|
|
34
|
-
// Fallback to original request
|
|
35
|
-
return fetch(input, init);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
9
|
/**
|
|
39
10
|
* OpenCode Plugin for Gemini CLI OAuth Authentication
|
|
40
11
|
*/
|
|
41
12
|
export default async function GeminiCLIOAuthPlugin({ client, directory }) {
|
|
42
|
-
console.log('🚀 Loading Gemini CLI OAuth plugin (v1.1.
|
|
13
|
+
console.log('🚀 Loading Gemini CLI OAuth plugin (v1.1.10)...');
|
|
43
14
|
return {
|
|
44
15
|
auth: {
|
|
45
16
|
provider: 'gemini-cli-oauth',
|
|
@@ -49,7 +20,32 @@ export default async function GeminiCLIOAuthPlugin({ client, directory }) {
|
|
|
49
20
|
loader: async (getAuth, provider) => {
|
|
50
21
|
return {
|
|
51
22
|
apiKey: 'gemini-cli-oauth-placeholder',
|
|
52
|
-
fetch
|
|
23
|
+
// Inline fetch definition (Antigravity pattern)
|
|
24
|
+
async fetch(input, init) {
|
|
25
|
+
const urlStr = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
|
|
26
|
+
// Only intercept Gemini API requests
|
|
27
|
+
if (!urlStr.includes('generativelanguage.googleapis.com')) {
|
|
28
|
+
return fetch(input, init);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
// Get OAuth token
|
|
32
|
+
const token = await oauthManager.getAccessToken();
|
|
33
|
+
// Inject Authorization header
|
|
34
|
+
const headers = new Headers(init?.headers);
|
|
35
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
36
|
+
// Remove API key from URL if present (OAuth doesn't need it)
|
|
37
|
+
const urlObj = new URL(urlStr);
|
|
38
|
+
urlObj.searchParams.delete('key');
|
|
39
|
+
return fetch(urlObj.toString(), {
|
|
40
|
+
...init,
|
|
41
|
+
headers
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('❌ [Gemini OAuth] Token error:', error);
|
|
46
|
+
return fetch(input, init);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
53
49
|
};
|
|
54
50
|
},
|
|
55
51
|
/**
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,2BAA2B;AAC3B,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAAC,KAAwB,EAAE,IAAkB;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,2BAA2B;AAC3B,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAiB;IACrF,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI,EAAE;YACJ,QAAQ,EAAE,kBAAkB;YAE5B;;eAEG;YACH,MAAM,EAAE,KAAK,EAAE,OAAY,EAAE,QAAgB,EAAE,EAAE;gBAC/C,OAAO;oBACL,MAAM,EAAE,8BAA8B;oBAEtC,gDAAgD;oBAChD,KAAK,CAAC,KAAK,CAAC,KAAwB,EAAE,IAAkB;wBACtD,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;wBAEjG,qCAAqC;wBACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,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AK,EAAE,CAAC,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;oCAC9E,CAAC;gCACH,CAAC;gCAAC,MAAM,CAAC,CAAA,CAAC;gCAEV,OAAO;oCACL,IAAI,EAAE,QAAQ;oCACd,KAAK,EAAE,wEAAwE;iCAChF,CAAC;4BACJ,CAAC;yBACF,CAAC;oBACJ,CAAC;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,8CAA8C;IAC3D,MAAM,EAAE,OAAO;IACf,cAAc,EAAE;QACd,QAAQ,EAAE,QAAQ;KACnB;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-gemini-cli-oauth",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "OpenCode plugin for Gemini CLI OAuth authentication - use Google account quota without API keys",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index
|
|
6
|
+
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|