@xopcai/xopc 0.0.163 → 0.0.164
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-Xj95LzTv.js → activity-store-DkALQFJT.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C-QeUFwU.js → agent-avatar-dicebear-RpxkQtQ3.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CxpwxMPE.js +2 -0
- package/dist/gateway/static/root/assets/{api-BTLmAm1_.js → api-DPIXEcIq.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-zc6Gf-S5.js → app-management-settings-panel-DLdjfMXB.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-0fMLnOWn.js → appearance-settings-C89-uxkq.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-k-tZbaRB.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DOiR_E21.js → archive-plugin-CqbH5geE.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BxmYl1D1.js → attachment-load-CeU4Qiot.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BhZOirad.js → automation-suggestion-card-WiOuqXq9.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Bdn3dgC_.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DTTKsvgk.js → binary-plugins-C5TdzrhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C7se7iqg.js → block-editor-BjvWhphG.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-GsVTGfGs.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-kxmStCcv.js → browser-workflow-inputs-DXmzQ3nk.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CwYf9OM_.js → browser-workflows-page-C1-ptRe4.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6d4kVjzl.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BZKh2cWX.js → capability-presets-api-C0pVlUyc.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DCxy5Ls_.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-r7tdbnJE.js → channel-recipient-api-B5rLegwk.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Bg3P8k0f.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BpnQYAxA.js → connector-logo-CuI5w4qM.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-6UR7yhIZ.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-BvG8vDXZ.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-uv8Grtgk.js → desktop-pet-settings-CR__kZ8C.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-C4TTvf7p.js → directory-picker-path-field-BblWMz3e.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CzJAUPvM.js → dreaming-settings-DHMPugDE.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-Ci2mOYUt.js → extension-debug-page-ByVY1gZg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DeXdmhXQ.js → extension-page-DLCKKtbK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-C93vaOsU.js → extension-settings-page-M-rhlFBC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-C31Hlblp.js → gateway-config-api-DZHqhbXH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-D3zS6RZh.js → gateway-settings-CZswIehx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CSRvCqxh.js → gateway-startup-retry-ulwTJovP.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-TbyRfDas.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-B-QBVOf2.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-D4wYNRrf.js → goals-config-api-DMxG6f0N.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BGxki8BR.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Bx2jVvhQ.js → goals-settings-G-w1gCYD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-BEIF1eXy.js → heartbeat-settings-Csb90R59.js} +1 -1
- package/dist/gateway/static/root/assets/{index-HZdBKfk_.js → index-CGwuxvzr.js} +70 -70
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DOEDpvTM.js → keyboard-shortcuts-settings-C_Bl3YOr.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BR2tBhO3.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-B0OpGpxv.js → local-apps-page-_8Rv-tSk.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Ys6RP7Be.js → locale-store-C_ax27uc.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CwF0C_Z2.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CEZwysCH.js → markdown-split-CZnZS6gq.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CpGKE7B0.js → media-plugins-C2XLYC6G.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BzI9Wx30.js → messages-C96Zjb0V.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-CdiuDZ5a.js → notes-page-BkuZxTFo.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CD4FADi7.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BkH5AVV2.js → page-tabs-DR2FGC4E.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CQai8f9D.js → preview-open-alternatives-B65O8wBL.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2kSdB2b.js → product-open-page-Cag-utLH.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-COKtUblD.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-QYmqanBN.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BU_gBU0f.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-NGYnO7n7.js → save-bar-controls-DCWpFnPc.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-nLOphnv3.js → schedule-field-ClacZdvE.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-D0e90ndE.js → schema-form-BVlbEipU.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-u-Pjbzfm.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-X2Sl-EAk.js → settings-form-section-GSNlQWSW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DOnUabm7.js → settings-loading-skeleton-08Ae5sB_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C4UUNi1n.js → settings-page-BseJD4I-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-C1yYqbT6.js → settings-page-layout-bSliH-Y3.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGRhJVlt.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Cfy_pH7V.js → share-preview-page-C114OpTx.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BRFpWFgI.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-cVjU2GnN.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CoMTjtRT.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Da81RJ6G.js → system-settings-panel-El8cDcTY.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DflSp9o4.js → theme-store-D37XLD_C.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-BIkOW-2L.js → time-picker-CU7hhD8T.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib--HptwFcD.js → typed-models-lib-kToxD7Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CMHY4ZfW.js → use-channel-catalog-DBh0dOC9.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-C0xYCSXB.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-nvIZerol.js → voice-api-key-field-DzEpwYaU.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DakZqR85.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CswqPbTT.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DYRXEk8m.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D96MHABy.js → workflow-run-setup-panel-BwSxyVMM.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CiLSYGuN.js +11 -0
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/model-runtime.d.ts +4 -0
- package/dist/src/agent/embedded/model-runtime.js +49 -0
- package/dist/src/agent/embedded/session-runner.js +3 -3
- package/dist/src/auth/credentials.js +45 -2
- package/dist/src/auth/index.js +2 -1
- package/dist/src/auth/oauth/anthropic.js +27 -24
- package/dist/src/auth/oauth/github-copilot.js +20 -15
- package/dist/src/auth/oauth/google-antigravity.js +9 -2
- package/dist/src/auth/oauth/google-gemini-cli.js +9 -2
- package/dist/src/auth/oauth/google-oauth/google-antigravity.js +47 -40
- package/dist/src/auth/oauth/google-oauth/google-gemini-cli.js +48 -41
- package/dist/src/auth/oauth/google-oauth/oauth-page.js +7 -2
- package/dist/src/auth/oauth/google-oauth/pkce.js +4 -1
- package/dist/src/auth/oauth/index.d.ts +2 -0
- package/dist/src/auth/oauth/index.js +24 -10
- package/dist/src/auth/oauth/kimi-coding.js +76 -71
- package/dist/src/auth/oauth/minimax-cn.js +78 -73
- package/dist/src/auth/oauth/minimax.js +78 -73
- package/dist/src/auth/oauth/openai-codex.js +31 -25
- package/dist/src/auth/oauth/pkce.js +4 -1
- package/dist/src/auth/oauth/registry.d.ts +13 -0
- package/dist/src/auth/oauth/registry.js +65 -0
- package/dist/src/auth/oauth/xopc-cloud.d.ts +2 -0
- package/dist/src/auth/oauth/xopc-cloud.js +101 -0
- package/dist/src/auth/sync-provider-auth.js +5 -0
- package/dist/src/cli/utils/oauth-providers.d.ts +3 -26
- package/dist/src/cli/utils/oauth-providers.js +6 -80
- package/dist/src/config/models-json.js +8 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/oauth-async.js +3 -19
- package/dist/src/gateway/hono/oauth.js +3 -19
- package/dist/src/gateway/hono/routes/models.js +1 -55
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/providers/domestic-presets.d.ts +0 -20
- package/dist/src/providers/domestic-presets.js +0 -25
- package/dist/src/providers/index.js +9 -0
- package/dist/src/providers/model-catalog-store.d.ts +20 -58
- package/dist/src/providers/model-catalog-store.js +18 -57
- package/dist/src/providers/model-catalog-sync-service.d.ts +3 -4
- package/dist/src/providers/model-catalog-sync-service.js +3 -13
- package/dist/src/providers/model-registry.js +0 -2
- package/dist/src/providers/xopc-cloud-model-source.d.ts +30 -0
- package/dist/src/providers/xopc-cloud-model-source.js +68 -0
- package/dist/src/work-discovery/analyzer.js +27 -14
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-DVKlWKJE.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BZXEJDIV.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-B8CnkoXv.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BCPWKI9V.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C7lr_mX2.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Ble9kHRu.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-CtQQQHrv.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-_VirfMKW.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BXWJSJeY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-B86W4a5c.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CWp2b7__.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Dtm29FxD.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-jMzBJs6e.js +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-CseW9jD3.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DVqPbth5.js +0 -7
- package/dist/gateway/static/root/assets/notes-workbench-mrc3xtpn.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CfhPJLkH.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BfMoKjdm.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CrDtcsZ9.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-D3DbF3dV.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BZp0O2dH.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-84iao4DZ.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DtcwQvRG.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-L7j5Gc8Z.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-1Ps8PjsP.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BYAAs2iW.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-J35JkJ7_.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-C4wYDYqV.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DMvitV6c.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-JMN0nMbM.js +0 -11
- package/dist/src/agent/embedded/xopc-auth-storage.d.ts +0 -19
- package/dist/src/agent/embedded/xopc-auth-storage.js +0 -40
- package/dist/src/providers/xopc-cloud-connection.d.ts +0 -51
- package/dist/src/providers/xopc-cloud-connection.js +0 -196
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { anthropicOAuthProvider, loginAnthropic, refreshAnthropicToken } from "./anthropic.js";
|
|
2
|
-
import {
|
|
3
|
-
import { minimaxCnOAuthProvider } from "./minimax-cn.js";
|
|
4
|
-
import { kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
5
|
-
import { githubCopilotOAuthProvider } from "./github-copilot.js";
|
|
6
|
-
import { geminiCliOAuthProvider, loginGeminiCli, refreshGoogleCloudToken } from "./google-oauth/google-gemini-cli.js";
|
|
7
|
-
import "./google-gemini-cli.js";
|
|
1
|
+
import { anthropicOAuthProvider, init_anthropic, loginAnthropic, refreshAnthropicToken } from "./anthropic.js";
|
|
2
|
+
import { githubCopilotOAuthProvider, init_github_copilot } from "./github-copilot.js";
|
|
8
3
|
import { antigravityOAuthProvider, loginAntigravity, refreshAntigravityToken } from "./google-oauth/google-antigravity.js";
|
|
9
|
-
import "./google-antigravity.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
4
|
+
import { init_google_antigravity } from "./google-antigravity.js";
|
|
5
|
+
import { geminiCliOAuthProvider, loginGeminiCli, refreshGoogleCloudToken } from "./google-oauth/google-gemini-cli.js";
|
|
6
|
+
import { init_google_gemini_cli } from "./google-gemini-cli.js";
|
|
7
|
+
import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
|
|
8
|
+
import { init_minimax_cn, minimaxCnOAuthProvider } from "./minimax-cn.js";
|
|
9
|
+
import { init_minimax, minimaxOAuthProvider } from "./minimax.js";
|
|
10
|
+
import { init_openai_codex, loginOpenAICodex, openaiCodexOAuthProvider, refreshOpenAICodexToken } from "./openai-codex.js";
|
|
11
|
+
import { init_xopc_cloud, xopcCloudOAuthProvider } from "./xopc-cloud.js";
|
|
12
|
+
import { OAUTH_PROVIDER_DEFINITIONS, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, init_registry, isOAuthOnlyProvider } from "./registry.js";
|
|
13
|
+
//#region src/auth/oauth/index.ts
|
|
14
|
+
init_anthropic();
|
|
15
|
+
init_minimax();
|
|
16
|
+
init_minimax_cn();
|
|
17
|
+
init_kimi_coding();
|
|
18
|
+
init_github_copilot();
|
|
19
|
+
init_google_gemini_cli();
|
|
20
|
+
init_google_antigravity();
|
|
21
|
+
init_openai_codex();
|
|
22
|
+
init_xopc_cloud();
|
|
23
|
+
init_registry();
|
|
24
|
+
//#endregion
|
|
25
|
+
export { OAUTH_PROVIDER_DEFINITIONS, anthropicOAuthProvider, getOAuthProviderDefinition, getOAuthProviderIds, getOAuthProviderInterfaces, githubCopilotOAuthProvider, antigravityOAuthProvider as googleAntigravityOAuthProvider, geminiCliOAuthProvider as googleGeminiCliOAuthProvider, isOAuthOnlyProvider, kimiCodingOAuthProvider, loginAnthropic, loginAntigravity, loginGeminiCli, loginOpenAICodex, minimaxCnOAuthProvider, minimaxOAuthProvider, openaiCodexOAuthProvider, refreshAnthropicToken, refreshAntigravityToken, refreshGoogleCloudToken, refreshOpenAICodexToken, xopcCloudOAuthProvider };
|
|
@@ -1,81 +1,86 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/kimi-coding.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
body: new URLSearchParams({
|
|
15
|
-
client_id: KIMI_OAUTH_CLIENT_ID,
|
|
16
|
-
scope: "kimi-code"
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
if (!deviceResponse.ok) {
|
|
20
|
-
const error = await deviceResponse.text();
|
|
21
|
-
throw new Error(`Device code request failed: ${error}`);
|
|
22
|
-
}
|
|
23
|
-
const deviceData = await deviceResponse.json();
|
|
24
|
-
callbacks.onAuth({
|
|
25
|
-
url: deviceData.verification_uri_complete || deviceData.verification_uri,
|
|
26
|
-
instructions: `Please visit ${deviceData.verification_uri} and enter code: ${deviceData.user_code}`
|
|
27
|
-
});
|
|
28
|
-
const expiresAt = Date.now() + deviceData.expires_in * 1e3;
|
|
29
|
-
const pollInterval = (deviceData.interval || 5) * 1e3;
|
|
30
|
-
while (Date.now() < expiresAt) {
|
|
31
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
32
|
-
const tokenResponse = await fetch(KIMI_OAUTH_TOKEN_URL, {
|
|
3
|
+
var KIMI_OAUTH_BASE_URL, KIMI_OAUTH_DEVICE_URL, KIMI_OAUTH_TOKEN_URL, KIMI_OAUTH_CLIENT_ID, kimiCodingOAuthProvider;
|
|
4
|
+
var init_kimi_coding = __esmMin((() => {
|
|
5
|
+
KIMI_OAUTH_BASE_URL = "https://auth.kimi.com";
|
|
6
|
+
KIMI_OAUTH_DEVICE_URL = `${KIMI_OAUTH_BASE_URL}/api/oauth/device_authorization`;
|
|
7
|
+
KIMI_OAUTH_TOKEN_URL = `${KIMI_OAUTH_BASE_URL}/api/oauth/token`;
|
|
8
|
+
KIMI_OAUTH_CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
9
|
+
kimiCodingOAuthProvider = {
|
|
10
|
+
id: "kimi-coding",
|
|
11
|
+
name: "Kimi For Coding (月之暗面)",
|
|
12
|
+
usesCallbackServer: false,
|
|
13
|
+
async login(callbacks) {
|
|
14
|
+
const deviceResponse = await fetch(KIMI_OAUTH_DEVICE_URL, {
|
|
33
15
|
method: "POST",
|
|
34
16
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
35
17
|
body: new URLSearchParams({
|
|
36
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
37
18
|
client_id: KIMI_OAUTH_CLIENT_ID,
|
|
38
|
-
|
|
19
|
+
scope: "kimi-code"
|
|
39
20
|
})
|
|
40
21
|
});
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
access: tokenData.access_token,
|
|
45
|
-
refresh: tokenData.refresh_token,
|
|
46
|
-
expires: Date.now() + tokenData.expires_in * 1e3
|
|
47
|
-
};
|
|
22
|
+
if (!deviceResponse.ok) {
|
|
23
|
+
const error = await deviceResponse.text();
|
|
24
|
+
throw new Error(`Device code request failed: ${error}`);
|
|
48
25
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
26
|
+
const deviceData = await deviceResponse.json();
|
|
27
|
+
callbacks.onAuth({
|
|
28
|
+
url: deviceData.verification_uri_complete || deviceData.verification_uri,
|
|
29
|
+
instructions: `Please visit ${deviceData.verification_uri} and enter code: ${deviceData.user_code}`
|
|
30
|
+
});
|
|
31
|
+
const expiresAt = Date.now() + deviceData.expires_in * 1e3;
|
|
32
|
+
const pollInterval = (deviceData.interval || 5) * 1e3;
|
|
33
|
+
while (Date.now() < expiresAt) {
|
|
34
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
35
|
+
const tokenResponse = await fetch(KIMI_OAUTH_TOKEN_URL, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
38
|
+
body: new URLSearchParams({
|
|
39
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
40
|
+
client_id: KIMI_OAUTH_CLIENT_ID,
|
|
41
|
+
device_code: deviceData.device_code
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
if (tokenResponse.ok) {
|
|
45
|
+
const tokenData = await tokenResponse.json();
|
|
46
|
+
return {
|
|
47
|
+
access: tokenData.access_token,
|
|
48
|
+
refresh: tokenData.refresh_token,
|
|
49
|
+
expires: Date.now() + tokenData.expires_in * 1e3
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if ((await tokenResponse.json()).error === "expired_token") throw new Error("Device code expired. Please try again.");
|
|
53
|
+
}
|
|
54
|
+
throw new Error("Device code expired. Please try again.");
|
|
55
|
+
},
|
|
56
|
+
async refreshToken(credentials) {
|
|
57
|
+
if (!credentials.refresh) throw new Error("Kimi OAuth refresh token missing. Re-authenticate.");
|
|
58
|
+
const response = await fetch(KIMI_OAUTH_TOKEN_URL, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
61
|
+
body: new URLSearchParams({
|
|
62
|
+
grant_type: "refresh_token",
|
|
63
|
+
client_id: KIMI_OAUTH_CLIENT_ID,
|
|
64
|
+
refresh_token: credentials.refresh
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const text = await response.text();
|
|
69
|
+
throw new Error(`Kimi OAuth refresh failed: ${text}`);
|
|
70
|
+
}
|
|
71
|
+
const payload = await response.json();
|
|
72
|
+
return {
|
|
73
|
+
...credentials,
|
|
74
|
+
access: payload.access_token,
|
|
75
|
+
refresh: payload.refresh_token || credentials.refresh,
|
|
76
|
+
expires: Date.now() + payload.expires_in * 1e3
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
getApiKey(credentials) {
|
|
80
|
+
return credentials.access;
|
|
67
81
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
...credentials,
|
|
71
|
-
access: payload.access_token,
|
|
72
|
-
refresh: payload.refresh_token || credentials.refresh,
|
|
73
|
-
expires: Date.now() + payload.expires_in * 1e3
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
getApiKey(credentials) {
|
|
77
|
-
return credentials.access;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
82
|
+
};
|
|
83
|
+
}));
|
|
80
84
|
//#endregion
|
|
81
|
-
|
|
85
|
+
init_kimi_coding();
|
|
86
|
+
export { init_kimi_coding, kimiCodingOAuthProvider };
|
|
@@ -1,76 +1,5 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/minimax-cn.ts
|
|
2
|
-
const MINIMAX_CN_OAUTH_BASE_URL = "https://platform.minimax.chat";
|
|
3
|
-
const MINIMAX_CN_OAUTH_AUTHORIZE_URL = `${MINIMAX_CN_OAUTH_BASE_URL}/oauth/authorize`;
|
|
4
|
-
const MINIMAX_CN_OAUTH_TOKEN_URL = `${MINIMAX_CN_OAUTH_BASE_URL}/oauth/token`;
|
|
5
|
-
const MINIMAX_CN_OAUTH_CLIENT_ID = "your_client_id";
|
|
6
|
-
const minimaxCnOAuthProvider = {
|
|
7
|
-
id: "minimax-cn",
|
|
8
|
-
name: "MiniMax 国内版",
|
|
9
|
-
usesCallbackServer: false,
|
|
10
|
-
async login(callbacks) {
|
|
11
|
-
const codeVerifier = generateCodeVerifier();
|
|
12
|
-
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
13
|
-
const authUrl = new URL(MINIMAX_CN_OAUTH_AUTHORIZE_URL);
|
|
14
|
-
authUrl.searchParams.set("client_id", MINIMAX_CN_OAUTH_CLIENT_ID);
|
|
15
|
-
authUrl.searchParams.set("redirect_uri", "http://localhost:3000/callback");
|
|
16
|
-
authUrl.searchParams.set("response_type", "code");
|
|
17
|
-
authUrl.searchParams.set("scope", "api");
|
|
18
|
-
authUrl.searchParams.set("code_challenge", codeChallenge);
|
|
19
|
-
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
20
|
-
callbacks.onAuth({
|
|
21
|
-
url: authUrl.toString(),
|
|
22
|
-
instructions: "请在浏览器中授权应用,然后输入返回的授权码。"
|
|
23
|
-
});
|
|
24
|
-
const code = await callbacks.onPrompt({ message: "请输入授权码:" });
|
|
25
|
-
const tokenResponse = await fetch(MINIMAX_CN_OAUTH_TOKEN_URL, {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
28
|
-
body: new URLSearchParams({
|
|
29
|
-
grant_type: "authorization_code",
|
|
30
|
-
client_id: MINIMAX_CN_OAUTH_CLIENT_ID,
|
|
31
|
-
code,
|
|
32
|
-
redirect_uri: "http://localhost:3000/callback",
|
|
33
|
-
code_verifier: codeVerifier
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
if (!tokenResponse.ok) {
|
|
37
|
-
const error = await tokenResponse.text();
|
|
38
|
-
throw new Error(`Token exchange failed: ${error}`);
|
|
39
|
-
}
|
|
40
|
-
const tokenData = await tokenResponse.json();
|
|
41
|
-
return {
|
|
42
|
-
access: tokenData.access_token,
|
|
43
|
-
refresh: tokenData.refresh_token,
|
|
44
|
-
expires: Date.now() + tokenData.expires_in * 1e3
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
async refreshToken(credentials) {
|
|
48
|
-
if (!credentials.refresh) throw new Error("MiniMax CN OAuth refresh token missing. Re-authenticate.");
|
|
49
|
-
const response = await fetch(MINIMAX_CN_OAUTH_TOKEN_URL, {
|
|
50
|
-
method: "POST",
|
|
51
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
52
|
-
body: new URLSearchParams({
|
|
53
|
-
grant_type: "refresh_token",
|
|
54
|
-
client_id: MINIMAX_CN_OAUTH_CLIENT_ID,
|
|
55
|
-
refresh_token: credentials.refresh
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
if (!response.ok) {
|
|
59
|
-
const text = await response.text();
|
|
60
|
-
throw new Error(`MiniMax CN OAuth refresh failed: ${text}`);
|
|
61
|
-
}
|
|
62
|
-
const payload = await response.json();
|
|
63
|
-
return {
|
|
64
|
-
...credentials,
|
|
65
|
-
access: payload.access_token,
|
|
66
|
-
refresh: payload.refresh_token || credentials.refresh,
|
|
67
|
-
expires: Date.now() + payload.expires_in * 1e3
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
getApiKey(credentials) {
|
|
71
|
-
return credentials.access;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
3
|
function generateCodeVerifier() {
|
|
75
4
|
const array = new Uint8Array(32);
|
|
76
5
|
crypto.getRandomValues(array);
|
|
@@ -86,5 +15,81 @@ function base64UrlEncode(buffer) {
|
|
|
86
15
|
buffer.forEach((b) => str += String.fromCharCode(b));
|
|
87
16
|
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
88
17
|
}
|
|
18
|
+
var MINIMAX_CN_OAUTH_BASE_URL, MINIMAX_CN_OAUTH_AUTHORIZE_URL, MINIMAX_CN_OAUTH_TOKEN_URL, MINIMAX_CN_OAUTH_CLIENT_ID, minimaxCnOAuthProvider;
|
|
19
|
+
var init_minimax_cn = __esmMin((() => {
|
|
20
|
+
MINIMAX_CN_OAUTH_BASE_URL = "https://platform.minimax.chat";
|
|
21
|
+
MINIMAX_CN_OAUTH_AUTHORIZE_URL = `${MINIMAX_CN_OAUTH_BASE_URL}/oauth/authorize`;
|
|
22
|
+
MINIMAX_CN_OAUTH_TOKEN_URL = `${MINIMAX_CN_OAUTH_BASE_URL}/oauth/token`;
|
|
23
|
+
MINIMAX_CN_OAUTH_CLIENT_ID = "your_client_id";
|
|
24
|
+
minimaxCnOAuthProvider = {
|
|
25
|
+
id: "minimax-cn",
|
|
26
|
+
name: "MiniMax 国内版",
|
|
27
|
+
usesCallbackServer: false,
|
|
28
|
+
async login(callbacks) {
|
|
29
|
+
const codeVerifier = generateCodeVerifier();
|
|
30
|
+
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
31
|
+
const authUrl = new URL(MINIMAX_CN_OAUTH_AUTHORIZE_URL);
|
|
32
|
+
authUrl.searchParams.set("client_id", MINIMAX_CN_OAUTH_CLIENT_ID);
|
|
33
|
+
authUrl.searchParams.set("redirect_uri", "http://localhost:3000/callback");
|
|
34
|
+
authUrl.searchParams.set("response_type", "code");
|
|
35
|
+
authUrl.searchParams.set("scope", "api");
|
|
36
|
+
authUrl.searchParams.set("code_challenge", codeChallenge);
|
|
37
|
+
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
38
|
+
callbacks.onAuth({
|
|
39
|
+
url: authUrl.toString(),
|
|
40
|
+
instructions: "请在浏览器中授权应用,然后输入返回的授权码。"
|
|
41
|
+
});
|
|
42
|
+
const code = await callbacks.onPrompt({ message: "请输入授权码:" });
|
|
43
|
+
const tokenResponse = await fetch(MINIMAX_CN_OAUTH_TOKEN_URL, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
46
|
+
body: new URLSearchParams({
|
|
47
|
+
grant_type: "authorization_code",
|
|
48
|
+
client_id: MINIMAX_CN_OAUTH_CLIENT_ID,
|
|
49
|
+
code,
|
|
50
|
+
redirect_uri: "http://localhost:3000/callback",
|
|
51
|
+
code_verifier: codeVerifier
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
if (!tokenResponse.ok) {
|
|
55
|
+
const error = await tokenResponse.text();
|
|
56
|
+
throw new Error(`Token exchange failed: ${error}`);
|
|
57
|
+
}
|
|
58
|
+
const tokenData = await tokenResponse.json();
|
|
59
|
+
return {
|
|
60
|
+
access: tokenData.access_token,
|
|
61
|
+
refresh: tokenData.refresh_token,
|
|
62
|
+
expires: Date.now() + tokenData.expires_in * 1e3
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
async refreshToken(credentials) {
|
|
66
|
+
if (!credentials.refresh) throw new Error("MiniMax CN OAuth refresh token missing. Re-authenticate.");
|
|
67
|
+
const response = await fetch(MINIMAX_CN_OAUTH_TOKEN_URL, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
70
|
+
body: new URLSearchParams({
|
|
71
|
+
grant_type: "refresh_token",
|
|
72
|
+
client_id: MINIMAX_CN_OAUTH_CLIENT_ID,
|
|
73
|
+
refresh_token: credentials.refresh
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
const text = await response.text();
|
|
78
|
+
throw new Error(`MiniMax CN OAuth refresh failed: ${text}`);
|
|
79
|
+
}
|
|
80
|
+
const payload = await response.json();
|
|
81
|
+
return {
|
|
82
|
+
...credentials,
|
|
83
|
+
access: payload.access_token,
|
|
84
|
+
refresh: payload.refresh_token || credentials.refresh,
|
|
85
|
+
expires: Date.now() + payload.expires_in * 1e3
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
getApiKey(credentials) {
|
|
89
|
+
return credentials.access;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}));
|
|
89
93
|
//#endregion
|
|
90
|
-
|
|
94
|
+
init_minimax_cn();
|
|
95
|
+
export { init_minimax_cn, minimaxCnOAuthProvider };
|
|
@@ -1,76 +1,5 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/minimax.ts
|
|
2
|
-
const MINIMAX_OAUTH_BASE_URL = "https://platform.minimaxi.com";
|
|
3
|
-
const MINIMAX_OAUTH_AUTHORIZE_URL = `${MINIMAX_OAUTH_BASE_URL}/oauth/authorize`;
|
|
4
|
-
const MINIMAX_OAUTH_TOKEN_URL = `${MINIMAX_OAUTH_BASE_URL}/oauth/token`;
|
|
5
|
-
const MINIMAX_OAUTH_CLIENT_ID = "your_client_id";
|
|
6
|
-
const minimaxOAuthProvider = {
|
|
7
|
-
id: "minimax",
|
|
8
|
-
name: "MiniMax",
|
|
9
|
-
usesCallbackServer: false,
|
|
10
|
-
async login(callbacks) {
|
|
11
|
-
const codeVerifier = generateCodeVerifier();
|
|
12
|
-
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
13
|
-
const authUrl = new URL(MINIMAX_OAUTH_AUTHORIZE_URL);
|
|
14
|
-
authUrl.searchParams.set("client_id", MINIMAX_OAUTH_CLIENT_ID);
|
|
15
|
-
authUrl.searchParams.set("redirect_uri", "http://localhost:3000/callback");
|
|
16
|
-
authUrl.searchParams.set("response_type", "code");
|
|
17
|
-
authUrl.searchParams.set("scope", "api");
|
|
18
|
-
authUrl.searchParams.set("code_challenge", codeChallenge);
|
|
19
|
-
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
20
|
-
callbacks.onAuth({
|
|
21
|
-
url: authUrl.toString(),
|
|
22
|
-
instructions: "Please authorize the application and enter the code shown."
|
|
23
|
-
});
|
|
24
|
-
const code = await callbacks.onPrompt({ message: "Enter the authorization code:" });
|
|
25
|
-
const tokenResponse = await fetch(MINIMAX_OAUTH_TOKEN_URL, {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
28
|
-
body: new URLSearchParams({
|
|
29
|
-
grant_type: "authorization_code",
|
|
30
|
-
client_id: MINIMAX_OAUTH_CLIENT_ID,
|
|
31
|
-
code,
|
|
32
|
-
redirect_uri: "http://localhost:3000/callback",
|
|
33
|
-
code_verifier: codeVerifier
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
if (!tokenResponse.ok) {
|
|
37
|
-
const error = await tokenResponse.text();
|
|
38
|
-
throw new Error(`Token exchange failed: ${error}`);
|
|
39
|
-
}
|
|
40
|
-
const tokenData = await tokenResponse.json();
|
|
41
|
-
return {
|
|
42
|
-
access: tokenData.access_token,
|
|
43
|
-
refresh: tokenData.refresh_token,
|
|
44
|
-
expires: Date.now() + tokenData.expires_in * 1e3
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
async refreshToken(credentials) {
|
|
48
|
-
if (!credentials.refresh) throw new Error("MiniMax OAuth refresh token missing. Re-authenticate.");
|
|
49
|
-
const response = await fetch(MINIMAX_OAUTH_TOKEN_URL, {
|
|
50
|
-
method: "POST",
|
|
51
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
52
|
-
body: new URLSearchParams({
|
|
53
|
-
grant_type: "refresh_token",
|
|
54
|
-
client_id: MINIMAX_OAUTH_CLIENT_ID,
|
|
55
|
-
refresh_token: credentials.refresh
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
if (!response.ok) {
|
|
59
|
-
const text = await response.text();
|
|
60
|
-
throw new Error(`MiniMax OAuth refresh failed: ${text}`);
|
|
61
|
-
}
|
|
62
|
-
const payload = await response.json();
|
|
63
|
-
return {
|
|
64
|
-
...credentials,
|
|
65
|
-
access: payload.access_token,
|
|
66
|
-
refresh: payload.refresh_token || credentials.refresh,
|
|
67
|
-
expires: Date.now() + payload.expires_in * 1e3
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
getApiKey(credentials) {
|
|
71
|
-
return credentials.access;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
3
|
function generateCodeVerifier() {
|
|
75
4
|
const array = new Uint8Array(32);
|
|
76
5
|
crypto.getRandomValues(array);
|
|
@@ -86,5 +15,81 @@ function base64UrlEncode(buffer) {
|
|
|
86
15
|
buffer.forEach((b) => str += String.fromCharCode(b));
|
|
87
16
|
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
88
17
|
}
|
|
18
|
+
var MINIMAX_OAUTH_BASE_URL, MINIMAX_OAUTH_AUTHORIZE_URL, MINIMAX_OAUTH_TOKEN_URL, MINIMAX_OAUTH_CLIENT_ID, minimaxOAuthProvider;
|
|
19
|
+
var init_minimax = __esmMin((() => {
|
|
20
|
+
MINIMAX_OAUTH_BASE_URL = "https://platform.minimaxi.com";
|
|
21
|
+
MINIMAX_OAUTH_AUTHORIZE_URL = `${MINIMAX_OAUTH_BASE_URL}/oauth/authorize`;
|
|
22
|
+
MINIMAX_OAUTH_TOKEN_URL = `${MINIMAX_OAUTH_BASE_URL}/oauth/token`;
|
|
23
|
+
MINIMAX_OAUTH_CLIENT_ID = "your_client_id";
|
|
24
|
+
minimaxOAuthProvider = {
|
|
25
|
+
id: "minimax",
|
|
26
|
+
name: "MiniMax",
|
|
27
|
+
usesCallbackServer: false,
|
|
28
|
+
async login(callbacks) {
|
|
29
|
+
const codeVerifier = generateCodeVerifier();
|
|
30
|
+
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
31
|
+
const authUrl = new URL(MINIMAX_OAUTH_AUTHORIZE_URL);
|
|
32
|
+
authUrl.searchParams.set("client_id", MINIMAX_OAUTH_CLIENT_ID);
|
|
33
|
+
authUrl.searchParams.set("redirect_uri", "http://localhost:3000/callback");
|
|
34
|
+
authUrl.searchParams.set("response_type", "code");
|
|
35
|
+
authUrl.searchParams.set("scope", "api");
|
|
36
|
+
authUrl.searchParams.set("code_challenge", codeChallenge);
|
|
37
|
+
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
38
|
+
callbacks.onAuth({
|
|
39
|
+
url: authUrl.toString(),
|
|
40
|
+
instructions: "Please authorize the application and enter the code shown."
|
|
41
|
+
});
|
|
42
|
+
const code = await callbacks.onPrompt({ message: "Enter the authorization code:" });
|
|
43
|
+
const tokenResponse = await fetch(MINIMAX_OAUTH_TOKEN_URL, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
46
|
+
body: new URLSearchParams({
|
|
47
|
+
grant_type: "authorization_code",
|
|
48
|
+
client_id: MINIMAX_OAUTH_CLIENT_ID,
|
|
49
|
+
code,
|
|
50
|
+
redirect_uri: "http://localhost:3000/callback",
|
|
51
|
+
code_verifier: codeVerifier
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
if (!tokenResponse.ok) {
|
|
55
|
+
const error = await tokenResponse.text();
|
|
56
|
+
throw new Error(`Token exchange failed: ${error}`);
|
|
57
|
+
}
|
|
58
|
+
const tokenData = await tokenResponse.json();
|
|
59
|
+
return {
|
|
60
|
+
access: tokenData.access_token,
|
|
61
|
+
refresh: tokenData.refresh_token,
|
|
62
|
+
expires: Date.now() + tokenData.expires_in * 1e3
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
async refreshToken(credentials) {
|
|
66
|
+
if (!credentials.refresh) throw new Error("MiniMax OAuth refresh token missing. Re-authenticate.");
|
|
67
|
+
const response = await fetch(MINIMAX_OAUTH_TOKEN_URL, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
70
|
+
body: new URLSearchParams({
|
|
71
|
+
grant_type: "refresh_token",
|
|
72
|
+
client_id: MINIMAX_OAUTH_CLIENT_ID,
|
|
73
|
+
refresh_token: credentials.refresh
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
const text = await response.text();
|
|
78
|
+
throw new Error(`MiniMax OAuth refresh failed: ${text}`);
|
|
79
|
+
}
|
|
80
|
+
const payload = await response.json();
|
|
81
|
+
return {
|
|
82
|
+
...credentials,
|
|
83
|
+
access: payload.access_token,
|
|
84
|
+
refresh: payload.refresh_token || credentials.refresh,
|
|
85
|
+
expires: Date.now() + payload.expires_in * 1e3
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
getApiKey(credentials) {
|
|
89
|
+
return credentials.access;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}));
|
|
89
93
|
//#endregion
|
|
90
|
-
|
|
94
|
+
init_minimax();
|
|
95
|
+
export { init_minimax, minimaxOAuthProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { generatePKCE, init_pkce } from "./pkce.js";
|
|
2
3
|
import { randomBytes } from "node:crypto";
|
|
3
4
|
import http from "node:http";
|
|
4
5
|
//#region src/auth/oauth/openai-codex.ts
|
|
@@ -7,15 +8,6 @@ import http from "node:http";
|
|
|
7
8
|
*
|
|
8
9
|
* Owns callback validation, manual prompt handling, and success/error pages.
|
|
9
10
|
*/
|
|
10
|
-
const CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
11
|
-
const AUTHORIZE_URL = "https://auth.openai.com/oauth/authorize";
|
|
12
|
-
const TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
13
|
-
const CALLBACK_PORT = 1455;
|
|
14
|
-
const CALLBACK_PATH = "/auth/callback";
|
|
15
|
-
const REDIRECT_URI = `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
16
|
-
const SCOPE = "openid profile email offline_access";
|
|
17
|
-
const MANUAL_PROMPT_DELAY_MS = 15e3;
|
|
18
|
-
const TOKEN_REQUEST_TIMEOUT_MS = 3e4;
|
|
19
11
|
function xopcOAuthHtml(params) {
|
|
20
12
|
const color = params.tone === "success" ? "#2563eb" : "#dc2626";
|
|
21
13
|
const escapedTitle = escapeHtml(params.title);
|
|
@@ -299,19 +291,33 @@ async function loginOpenAICodex(callbacks) {
|
|
|
299
291
|
async function refreshOpenAICodexToken(refreshToken) {
|
|
300
292
|
return refreshAccessToken(refreshToken);
|
|
301
293
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
294
|
+
var CLIENT_ID, AUTHORIZE_URL, TOKEN_URL, CALLBACK_PORT, CALLBACK_PATH, REDIRECT_URI, SCOPE, MANUAL_PROMPT_DELAY_MS, TOKEN_REQUEST_TIMEOUT_MS, openaiCodexOAuthProvider;
|
|
295
|
+
var init_openai_codex = __esmMin((() => {
|
|
296
|
+
init_pkce();
|
|
297
|
+
CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
298
|
+
AUTHORIZE_URL = "https://auth.openai.com/oauth/authorize";
|
|
299
|
+
TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
300
|
+
CALLBACK_PORT = 1455;
|
|
301
|
+
CALLBACK_PATH = "/auth/callback";
|
|
302
|
+
REDIRECT_URI = `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
303
|
+
SCOPE = "openid profile email offline_access";
|
|
304
|
+
MANUAL_PROMPT_DELAY_MS = 15e3;
|
|
305
|
+
TOKEN_REQUEST_TIMEOUT_MS = 3e4;
|
|
306
|
+
openaiCodexOAuthProvider = {
|
|
307
|
+
id: "openai-codex",
|
|
308
|
+
name: "OpenAI Codex",
|
|
309
|
+
usesCallbackServer: true,
|
|
310
|
+
async login(callbacks) {
|
|
311
|
+
return loginOpenAICodex(callbacks);
|
|
312
|
+
},
|
|
313
|
+
async refreshToken(credentials) {
|
|
314
|
+
return refreshOpenAICodexToken(credentials.refresh);
|
|
315
|
+
},
|
|
316
|
+
getApiKey(credentials) {
|
|
317
|
+
return credentials.access;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}));
|
|
316
321
|
//#endregion
|
|
317
|
-
|
|
322
|
+
init_openai_codex();
|
|
323
|
+
export { init_openai_codex, loginOpenAICodex, openaiCodexOAuthProvider, refreshOpenAICodexToken };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/pkce.ts
|
|
2
3
|
/**
|
|
3
4
|
* PKCE utilities using Web Crypto API.
|
|
@@ -19,5 +20,7 @@ async function generatePKCE() {
|
|
|
19
20
|
challenge: base64urlEncode(new Uint8Array(hashBuffer))
|
|
20
21
|
};
|
|
21
22
|
}
|
|
23
|
+
var init_pkce = __esmMin((() => {}));
|
|
22
24
|
//#endregion
|
|
23
|
-
|
|
25
|
+
init_pkce();
|
|
26
|
+
export { generatePKCE, init_pkce };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OAuthProviderInterface } from './types.js';
|
|
2
|
+
export interface OAuthProviderDefinition {
|
|
3
|
+
displayName: string;
|
|
4
|
+
oauthOnly?: boolean;
|
|
5
|
+
provider: OAuthProviderInterface;
|
|
6
|
+
profileId: string;
|
|
7
|
+
urlPrompt: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const OAUTH_PROVIDER_DEFINITIONS: Readonly<Record<string, OAuthProviderDefinition>>;
|
|
10
|
+
export declare function getOAuthProviderDefinition(provider: string): OAuthProviderDefinition | undefined;
|
|
11
|
+
export declare function getOAuthProviderInterfaces(): Record<string, OAuthProviderInterface>;
|
|
12
|
+
export declare function getOAuthProviderIds(): string[];
|
|
13
|
+
export declare function isOAuthOnlyProvider(provider: string): boolean;
|