opencode-qwen-cli-auth 2.2.1 → 2.2.3
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/index.js +235 -143
- package/dist/lib/auth/auth.js +338 -170
- package/dist/lib/auth/browser.js +2 -2
- package/dist/lib/config.d.ts +13 -1
- package/dist/lib/config.js +22 -4
- package/dist/lib/constants.d.ts +3 -3
- package/dist/lib/constants.js +4 -4
- package/dist/lib/types.d.ts +8 -2
- package/package.json +1 -1
package/dist/lib/auth/browser.js
CHANGED
|
@@ -30,8 +30,8 @@ export function openBrowserUrl(url) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
// Log
|
|
34
|
-
console.warn("[qwen-oauth-plugin]
|
|
33
|
+
// Log warning for debugging, user can still open URL manually
|
|
34
|
+
console.warn("[qwen-oauth-plugin] Unable to open browser:", error?.message || error);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=browser.js.map
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import type { PluginConfig } from "./types.js";
|
|
|
3
3
|
* Get plugin configuration directory
|
|
4
4
|
*/
|
|
5
5
|
export declare function getConfigDir(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Get Qwen CLI credential directory (~/.qwen)
|
|
8
|
+
*/
|
|
9
|
+
export declare function getQwenDir(): string;
|
|
6
10
|
/**
|
|
7
11
|
* Get plugin configuration file path
|
|
8
12
|
*/
|
|
@@ -21,8 +25,16 @@ export declare function getQwenMode(config: PluginConfig): boolean;
|
|
|
21
25
|
* Get token storage path
|
|
22
26
|
*/
|
|
23
27
|
export declare function getTokenPath(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get token lock path for multi-process refresh coordination
|
|
30
|
+
*/
|
|
31
|
+
export declare function getTokenLockPath(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get legacy token storage path used by old plugin versions
|
|
34
|
+
*/
|
|
35
|
+
export declare function getLegacyTokenPath(): string;
|
|
24
36
|
/**
|
|
25
37
|
* Get cache directory for prompts
|
|
26
38
|
*/
|
|
27
39
|
export declare function getCacheDir(): string;
|
|
28
|
-
//# sourceMappingURL=config.d.ts.map
|
|
40
|
+
//# sourceMappingURL=config.d.ts.map
|
package/dist/lib/config.js
CHANGED
|
@@ -7,6 +7,12 @@ import { readFileSync, existsSync } from "fs";
|
|
|
7
7
|
export function getConfigDir() {
|
|
8
8
|
return join(homedir(), ".opencode", "qwen");
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Get Qwen CLI credential directory (~/.qwen)
|
|
12
|
+
*/
|
|
13
|
+
export function getQwenDir() {
|
|
14
|
+
return join(homedir(), ".qwen");
|
|
15
|
+
}
|
|
10
16
|
/**
|
|
11
17
|
* Get plugin configuration file path
|
|
12
18
|
*/
|
|
@@ -20,7 +26,7 @@ export function getConfigPath() {
|
|
|
20
26
|
export function loadPluginConfig() {
|
|
21
27
|
const configPath = getConfigPath();
|
|
22
28
|
if (!existsSync(configPath)) {
|
|
23
|
-
return { qwenMode: true }; // Default
|
|
29
|
+
return { qwenMode: true }; // Default: QWEN_MODE enabled
|
|
24
30
|
}
|
|
25
31
|
try {
|
|
26
32
|
const content = readFileSync(configPath, "utf-8");
|
|
@@ -40,9 +46,9 @@ export function getQwenMode(config) {
|
|
|
40
46
|
if (envValue !== undefined) {
|
|
41
47
|
return envValue === "1" || envValue.toLowerCase() === "true";
|
|
42
48
|
}
|
|
43
|
-
//
|
|
49
|
+
// Ensure boolean type, avoid string "false" being truthy
|
|
44
50
|
const val = config.qwenMode;
|
|
45
|
-
if (val === undefined || val === null) return true; //
|
|
51
|
+
if (val === undefined || val === null) return true; // default: enabled
|
|
46
52
|
if (typeof val === "string") {
|
|
47
53
|
return val === "1" || val.toLowerCase() === "true";
|
|
48
54
|
}
|
|
@@ -52,6 +58,18 @@ export function getQwenMode(config) {
|
|
|
52
58
|
* Get token storage path
|
|
53
59
|
*/
|
|
54
60
|
export function getTokenPath() {
|
|
61
|
+
return join(getQwenDir(), "oauth_creds.json");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get token lock path for multi-process refresh coordination
|
|
65
|
+
*/
|
|
66
|
+
export function getTokenLockPath() {
|
|
67
|
+
return join(getQwenDir(), "oauth_creds.lock");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get legacy token storage path used by old plugin versions
|
|
71
|
+
*/
|
|
72
|
+
export function getLegacyTokenPath() {
|
|
55
73
|
return join(getConfigDir(), "oauth_token.json");
|
|
56
74
|
}
|
|
57
75
|
/**
|
|
@@ -60,4 +78,4 @@ export function getTokenPath() {
|
|
|
60
78
|
export function getCacheDir() {
|
|
61
79
|
return join(homedir(), ".opencode", "cache");
|
|
62
80
|
}
|
|
63
|
-
//# sourceMappingURL=config.js.map
|
|
81
|
+
//# sourceMappingURL=config.js.map
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const HTTP_STATUS: {
|
|
|
45
45
|
*/
|
|
46
46
|
export declare const PORTAL_HEADERS: {
|
|
47
47
|
readonly AUTH_TYPE: "X-DashScope-AuthType";
|
|
48
|
-
readonly AUTH_TYPE_VALUE: "
|
|
48
|
+
readonly AUTH_TYPE_VALUE: "qwen-oauth";
|
|
49
49
|
};
|
|
50
50
|
/** Device flow polling configuration */
|
|
51
51
|
export declare const DEVICE_FLOW: {
|
|
@@ -85,7 +85,7 @@ export declare const PLATFORM_OPENERS: {
|
|
|
85
85
|
};
|
|
86
86
|
/** OAuth authorization labels */
|
|
87
87
|
export declare const AUTH_LABELS: {
|
|
88
|
-
readonly OAUTH: "Qwen
|
|
88
|
+
readonly OAUTH: "Qwen Code (qwen.ai OAuth)";
|
|
89
89
|
readonly INSTRUCTIONS: "Visit the URL shown in your browser to complete authentication.";
|
|
90
90
|
};
|
|
91
91
|
/** OAuth verification URI parameters */
|
|
@@ -102,4 +102,4 @@ export declare const STREAM_CONFIG: {
|
|
|
102
102
|
/** Maximum buffer size for SSE pass-through mode (1MB) */
|
|
103
103
|
readonly MAX_BUFFER_SIZE: number;
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
105
|
+
//# sourceMappingURL=constants.d.ts.map
|
package/dist/lib/constants.js
CHANGED
|
@@ -45,7 +45,7 @@ export const HTTP_STATUS = {
|
|
|
45
45
|
*/
|
|
46
46
|
export const PORTAL_HEADERS = {
|
|
47
47
|
AUTH_TYPE: "X-DashScope-AuthType",
|
|
48
|
-
AUTH_TYPE_VALUE: "
|
|
48
|
+
AUTH_TYPE_VALUE: "qwen-oauth",
|
|
49
49
|
};
|
|
50
50
|
/** Device flow polling configuration */
|
|
51
51
|
export const DEVICE_FLOW = {
|
|
@@ -95,11 +95,11 @@ export const VERIFICATION_URI = {
|
|
|
95
95
|
/** Full query parameter for Qwen Code client */
|
|
96
96
|
CLIENT_PARAM_VALUE: "client=qwen-code",
|
|
97
97
|
};
|
|
98
|
-
/** Token refresh buffer (refresh
|
|
99
|
-
export const TOKEN_REFRESH_BUFFER_MS =
|
|
98
|
+
/** Token refresh buffer (refresh 30 seconds before expiry) */
|
|
99
|
+
export const TOKEN_REFRESH_BUFFER_MS = 30 * 1000; // 30 seconds
|
|
100
100
|
/** Stream processing configuration */
|
|
101
101
|
export const STREAM_CONFIG = {
|
|
102
102
|
/** Maximum buffer size for SSE pass-through mode (1MB) */
|
|
103
103
|
MAX_BUFFER_SIZE: 1024 * 1024,
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=constants.js.map
|
|
105
|
+
//# sourceMappingURL=constants.js.map
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -68,7 +68,9 @@ export interface QwenTokenResponse {
|
|
|
68
68
|
export interface StoredTokenData {
|
|
69
69
|
access_token: string;
|
|
70
70
|
refresh_token: string;
|
|
71
|
-
|
|
71
|
+
token_type?: string;
|
|
72
|
+
expiry_date: number;
|
|
73
|
+
expires?: number;
|
|
72
74
|
resource_url?: string;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
@@ -86,6 +88,10 @@ export interface TokenSuccess {
|
|
|
86
88
|
*/
|
|
87
89
|
export interface TokenFailure {
|
|
88
90
|
type: "failed";
|
|
91
|
+
status?: number;
|
|
92
|
+
error?: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
fatal?: boolean;
|
|
89
95
|
}
|
|
90
96
|
/**
|
|
91
97
|
* Token exchange pending result (device flow)
|
|
@@ -177,4 +183,4 @@ export interface ErrorResponse {
|
|
|
177
183
|
code?: string;
|
|
178
184
|
}
|
|
179
185
|
export type { Auth, Provider, Model };
|
|
180
|
-
//# sourceMappingURL=types.d.ts.map
|
|
186
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED