@xopcai/xopc 0.0.162 → 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/README.md +4 -2
- package/README.zh-CN.md +4 -2
- 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-hpcNv9MZ.js → activity-store-DkALQFJT.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Zf9UQEmQ.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-Dnatri09.js → api-DPIXEcIq.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BBTR9wJP.js → app-management-settings-panel-DLdjfMXB.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C2zpLCHD.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-9eR_ODY1.js → archive-plugin-CqbH5geE.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DPuWYUeX.js → attachment-load-CeU4Qiot.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Dw49OJRl.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-BdkJpDFm.js → binary-plugins-C5TdzrhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CAi7SXYU.js → block-editor-BjvWhphG.js} +39 -39
- package/dist/gateway/static/root/assets/browser-settings-page-GsVTGfGs.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-Dx6wkGz1.js → browser-workflow-inputs-DXmzQ3nk.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Skertc-A.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-CNFl7dM3.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-DYQyGDw4.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-Bng6kxYF.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-Bpf6oegd.js → desktop-pet-BvG8vDXZ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BVUyefSd.js → desktop-pet-settings-CR__kZ8C.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DjSZAPz_.js → directory-picker-path-field-BblWMz3e.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CAZk2AM4.js → dreaming-settings-DHMPugDE.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-C2F6vTTd.js → extension-debug-page-ByVY1gZg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-AnIt4bn4.js → extension-page-DLCKKtbK.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-M-rhlFBC.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-DLFyZv33.js → gateway-config-api-DZHqhbXH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DnQAA-qq.js → gateway-settings-CZswIehx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DbzLyJ3R.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-REmr3QCr.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-Dz0F3uRO.js → goals-settings-G-w1gCYD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CQFY5gYs.js → heartbeat-settings-Csb90R59.js} +1 -1
- package/dist/gateway/static/root/assets/index-BXtJvaQl.css +1 -0
- package/dist/gateway/static/root/assets/{index-C8JkTS6d.js → index-CGwuxvzr.js} +70 -70
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BnOQXU5k.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-KsOtWOyM.js → local-apps-page-_8Rv-tSk.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-0lpYdNDr.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-D5GRg10r.js → markdown-split-CZnZS6gq.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C1ryULGs.js → media-plugins-C2XLYC6G.js} +1 -1
- package/dist/gateway/static/root/assets/messages-C96Zjb0V.js +5 -0
- package/dist/gateway/static/root/assets/{notes-page-CIeZ1_DT.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-Caj1-E_X.js → page-tabs-DR2FGC4E.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DKwEce-9.js → preview-open-alternatives-B65O8wBL.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B90ZskkN.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-BDYt53uQ.js → save-bar-controls-DCWpFnPc.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-ClacZdvE.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-D7oCARF7.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-CARTHCxH.js → settings-form-section-GSNlQWSW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DEwYqESe.js → settings-loading-skeleton-08Ae5sB_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B6vVdHeQ.js → settings-page-BseJD4I-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-D3srt5Bi.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-Ck9SxiXw.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-DLBUQSk2.js → system-settings-panel-El8cDcTY.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-C1oaqeD2.js → theme-store-D37XLD_C.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-CU7hhD8T.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-Divbg_C4.js → typed-models-lib-kToxD7Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CP9a_rAf.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-DzEpwYaU.js +1 -0
- 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-DbDPYQwB.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 +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/client-error-format.d.ts +1 -1
- package/dist/src/agent/client-error-format.js +6 -2
- 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/run-for-session.js +38 -31
- package/dist/src/agent/embedded/session-runner.d.ts +1 -0
- package/dist/src/agent/embedded/session-runner.js +13 -5
- package/dist/src/agent/failover-error.d.ts +1 -1
- package/dist/src/agent/image/generation/openai-compatible-image-provider.d.ts +2 -6
- package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -3
- package/dist/src/agent/image/generation/provider-registry.d.ts +5 -46
- package/dist/src/agent/image/generation/provider-registry.js +24 -73
- package/dist/{extensions/dashscope/src/image-generation-provider.d.ts → src/agent/image/generation/providers/dashscope.d.ts} +3 -6
- package/dist/{extensions/dashscope/src/image-generation-provider.js → src/agent/image/generation/providers/dashscope.js} +36 -59
- package/dist/{extensions/fal/src/image-generation-provider.d.ts → src/agent/image/generation/providers/fal.d.ts} +1 -1
- package/dist/{extensions/fal/src/image-generation-provider.js → src/agent/image/generation/providers/fal.js} +19 -29
- package/dist/{extensions/google/src/image-generation-provider.d.ts → src/agent/image/generation/providers/google.d.ts} +2 -2
- package/dist/{extensions/google/src/image-generation-provider.js → src/agent/image/generation/providers/google.js} +23 -30
- package/dist/{extensions/minimax/src/image-generation-provider.d.ts → src/agent/image/generation/providers/minimax.d.ts} +2 -5
- package/dist/{extensions/minimax/src/image-generation-provider.js → src/agent/image/generation/providers/minimax.js} +35 -51
- package/dist/{extensions/openai/src/image-generation-provider.d.ts → src/agent/image/generation/providers/openai.d.ts} +2 -2
- package/dist/{extensions/openai/src/image-generation-provider.js → src/agent/image/generation/providers/openai.js} +13 -38
- package/dist/src/agent/image/generation/runtime-types.d.ts +1 -0
- package/dist/src/agent/image/generation/runtime.d.ts +1 -3
- package/dist/src/agent/image/generation/runtime.js +6 -6
- package/dist/src/agent/image/generation/types.d.ts +23 -3
- package/dist/src/agent/image/index.d.ts +1 -1
- package/dist/src/agent/image/index.js +2 -2
- package/dist/src/agent/media-generation/runtime-shared.d.ts +2 -0
- package/dist/src/agent/media-generation/runtime-shared.js +1 -0
- package/dist/src/agent/tools/factory.js +4 -1
- package/dist/src/agent/tools/image-generate-tool.d.ts +2 -0
- package/dist/src/agent/tools/image-generate-tool.js +14 -7
- 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.d.ts +3 -0
- package/dist/src/auth/sync-provider-auth.js +17 -1
- package/dist/src/cli/commands/models.js +2 -5
- package/dist/src/cli/commands/onboard/model.js +3 -2
- package/dist/src/cli/commands/setup-shared/types.d.ts +1 -1
- 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/index.js +2 -2
- package/dist/src/config/models-json.d.ts +6 -0
- package/dist/src/config/models-json.js +10 -6
- package/dist/src/config/schema.d.ts +26 -15
- package/dist/src/config/schema.js +23 -12
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/app.js +12 -6
- package/dist/src/gateway/hono/lib/safe-providers-config.d.ts +0 -3
- package/dist/src/gateway/hono/lib/safe-providers-config.js +1 -3
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -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/config-patch/misc.js +2 -11
- package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -2
- package/dist/src/gateway/hono/routes/models.js +96 -128
- package/dist/src/gateway/image-generation-setup.d.ts +40 -0
- package/dist/src/gateway/image-generation-setup.js +130 -0
- package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
- package/dist/src/gateway/rate-limit/buckets.js +12 -0
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +10 -0
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/media-shared/http/private-network.d.ts +1 -1
- package/dist/src/media-shared/http/private-network.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-api-key.d.ts +2 -4
- package/dist/src/providers/auth-runtime/resolve-api-key.js +2 -4
- package/dist/src/providers/auth-runtime/resolve-auth.d.ts +3 -4
- package/dist/src/providers/auth-runtime/resolve-auth.js +18 -18
- package/dist/src/providers/domestic-presets.d.ts +2 -0
- package/dist/src/providers/index.js +9 -0
- package/dist/src/providers/model-catalog-store.d.ts +33 -0
- package/dist/src/providers/model-catalog-store.js +63 -0
- package/dist/src/providers/model-catalog-sync-service.d.ts +40 -0
- package/dist/src/providers/model-catalog-sync-service.js +132 -0
- package/dist/src/providers/model-reference-auditor.d.ts +14 -0
- package/dist/src/providers/model-reference-auditor.js +71 -0
- package/dist/src/providers/model-registry.d.ts +4 -1
- package/dist/src/providers/model-registry.js +33 -2
- package/dist/src/providers/presentation.js +2 -0
- 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/session/index.d.ts +1 -1
- package/dist/src/session/index.js +2 -2
- package/dist/src/session/session-title.d.ts +2 -0
- package/dist/src/session/session-title.js +24 -3
- package/dist/src/work-discovery/analyzer.js +27 -14
- package/package.json +5 -7
- package/dist/extensions/dashscope/src/index.d.ts +0 -4
- package/dist/extensions/dashscope/src/index.js +0 -2
- package/dist/extensions/dashscope/xopc.extension.json +0 -15
- package/dist/extensions/fal/src/index.d.ts +0 -4
- package/dist/extensions/fal/src/index.js +0 -2
- package/dist/extensions/fal/xopc.extension.json +0 -14
- package/dist/extensions/google/src/index.d.ts +0 -4
- package/dist/extensions/google/src/index.js +0 -2
- package/dist/extensions/google/xopc.extension.json +0 -14
- package/dist/extensions/minimax/src/index.d.ts +0 -4
- package/dist/extensions/minimax/src/index.js +0 -2
- package/dist/extensions/minimax/xopc.extension.json +0 -15
- package/dist/extensions/openai/src/index.d.ts +0 -4
- package/dist/extensions/openai/src/index.js +0 -2
- package/dist/extensions/openai/xopc.extension.json +0 -14
- package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +0 -2
- package/dist/gateway/static/root/assets/extension-settings-page-CLSc6682.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +0 -2
- package/dist/gateway/static/root/assets/index-hmrG55qg.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-CwLPgrWh.js +0 -7
- package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +0 -5
- package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-Bcdni4Pj.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +0 -1
- package/dist/gateway/static/root/assets/settings-collapsible-section-6eNF8Jey.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.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/agent/image/generation/bundled-registry.d.ts +0 -18
- package/dist/src/agent/image/generation/bundled-registry.js +0 -35
- package/dist/src/agent/image/generation/bundled.d.ts +0 -10
- package/dist/src/agent/image/generation/bundled.js +0 -15
- package/dist/src/agent/image/generation/image-provider-ui.d.ts +0 -20
- package/dist/src/agent/image/generation/image-provider-ui.js +0 -1
- package/dist/src/gateway/image-capabilities.d.ts +0 -28
- package/dist/src/gateway/image-capabilities.js +0 -78
- package/dist/src/generated/bundled-image-generation-providers.d.ts +0 -14
- package/dist/src/generated/bundled-image-generation-providers.js +0 -17
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { init_oauth_page, oauthErrorHtml, oauthSuccessHtml } from "./oauth-page.js";
|
|
3
|
+
import { generatePKCE, init_pkce } from "./pkce.js";
|
|
3
4
|
//#region src/auth/oauth/google-oauth/google-gemini-cli.ts
|
|
4
|
-
let _createServer = null;
|
|
5
|
-
let _httpImportPromise = null;
|
|
6
|
-
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) _httpImportPromise = import("node:http").then((m) => {
|
|
7
|
-
_createServer = m.createServer;
|
|
8
|
-
});
|
|
9
|
-
const GEMINI_CLI_CLIENT_ID_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_ID";
|
|
10
|
-
const GEMINI_CLI_CLIENT_SECRET_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_SECRET";
|
|
11
5
|
function getGeminiCliOAuthClient() {
|
|
12
6
|
const clientId = process.env[GEMINI_CLI_CLIENT_ID_ENV]?.trim();
|
|
13
7
|
const clientSecret = process.env[GEMINI_CLI_CLIENT_SECRET_ENV]?.trim();
|
|
@@ -17,15 +11,6 @@ function getGeminiCliOAuthClient() {
|
|
|
17
11
|
clientSecret
|
|
18
12
|
};
|
|
19
13
|
}
|
|
20
|
-
const REDIRECT_URI = "http://localhost:8085/oauth2callback";
|
|
21
|
-
const SCOPES = [
|
|
22
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
|
23
|
-
"https://www.googleapis.com/auth/userinfo.email",
|
|
24
|
-
"https://www.googleapis.com/auth/userinfo.profile"
|
|
25
|
-
];
|
|
26
|
-
const AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
27
|
-
const TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
28
|
-
const CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|
29
14
|
/**
|
|
30
15
|
* Start a local HTTP server to receive the OAuth callback
|
|
31
16
|
*/
|
|
@@ -104,8 +89,6 @@ function parseRedirectUrl(input) {
|
|
|
104
89
|
return {};
|
|
105
90
|
}
|
|
106
91
|
}
|
|
107
|
-
const TIER_FREE = "free-tier";
|
|
108
|
-
const TIER_STANDARD = "standard-tier";
|
|
109
92
|
/**
|
|
110
93
|
* Wait helper for onboarding retries
|
|
111
94
|
*/
|
|
@@ -358,25 +341,49 @@ async function loginGeminiCli(onAuth, onProgress, onManualCodeInput) {
|
|
|
358
341
|
server.server.close();
|
|
359
342
|
}
|
|
360
343
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
344
|
+
var _createServer, _httpImportPromise, GEMINI_CLI_CLIENT_ID_ENV, GEMINI_CLI_CLIENT_SECRET_ENV, REDIRECT_URI, SCOPES, AUTH_URL, TOKEN_URL, CODE_ASSIST_ENDPOINT, TIER_FREE, TIER_STANDARD, geminiCliOAuthProvider;
|
|
345
|
+
var init_google_gemini_cli = __esmMin((() => {
|
|
346
|
+
init_oauth_page();
|
|
347
|
+
init_pkce();
|
|
348
|
+
_createServer = null;
|
|
349
|
+
_httpImportPromise = null;
|
|
350
|
+
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) _httpImportPromise = import("node:http").then((m) => {
|
|
351
|
+
_createServer = m.createServer;
|
|
352
|
+
});
|
|
353
|
+
GEMINI_CLI_CLIENT_ID_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_ID";
|
|
354
|
+
GEMINI_CLI_CLIENT_SECRET_ENV = "XOPC_GOOGLE_GEMINI_CLI_OAUTH_CLIENT_SECRET";
|
|
355
|
+
REDIRECT_URI = "http://localhost:8085/oauth2callback";
|
|
356
|
+
SCOPES = [
|
|
357
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
|
358
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
|
359
|
+
"https://www.googleapis.com/auth/userinfo.profile"
|
|
360
|
+
];
|
|
361
|
+
AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
362
|
+
TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
363
|
+
CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|
364
|
+
TIER_FREE = "free-tier";
|
|
365
|
+
TIER_STANDARD = "standard-tier";
|
|
366
|
+
geminiCliOAuthProvider = {
|
|
367
|
+
id: "google-gemini-cli",
|
|
368
|
+
name: "Google Cloud Code Assist (Gemini CLI)",
|
|
369
|
+
usesCallbackServer: true,
|
|
370
|
+
async login(callbacks) {
|
|
371
|
+
return loginGeminiCli(callbacks.onAuth, callbacks.onProgress, callbacks.onManualCodeInput);
|
|
372
|
+
},
|
|
373
|
+
async refreshToken(credentials) {
|
|
374
|
+
const creds = credentials;
|
|
375
|
+
if (!creds.projectId) throw new Error("Google Cloud credentials missing projectId");
|
|
376
|
+
return refreshGoogleCloudToken(creds.refresh, creds.projectId);
|
|
377
|
+
},
|
|
378
|
+
getApiKey(credentials) {
|
|
379
|
+
const creds = credentials;
|
|
380
|
+
return JSON.stringify({
|
|
381
|
+
token: creds.access,
|
|
382
|
+
projectId: creds.projectId
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}));
|
|
381
387
|
//#endregion
|
|
382
|
-
|
|
388
|
+
init_google_gemini_cli();
|
|
389
|
+
export { geminiCliOAuthProvider, init_google_gemini_cli, loginGeminiCli, refreshGoogleCloudToken };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/google-oauth/oauth-page.ts
|
|
2
|
-
const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72 72" aria-hidden="true"><rect width="72" height="72" rx="20" fill="#2563eb"/><path d="M22 22l28 28M50 22L22 50" stroke="#fff" stroke-width="8" stroke-linecap="round"/></svg>`;
|
|
3
3
|
function escapeHtml(value) {
|
|
4
4
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
5
5
|
}
|
|
@@ -106,5 +106,10 @@ function oauthErrorHtml(message, details) {
|
|
|
106
106
|
details
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
var LOGO_SVG;
|
|
110
|
+
var init_oauth_page = __esmMin((() => {
|
|
111
|
+
LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 72 72" aria-hidden="true"><rect width="72" height="72" rx="20" fill="#2563eb"/><path d="M22 22l28 28M50 22L22 50" stroke="#fff" stroke-width="8" stroke-linecap="round"/></svg>`;
|
|
112
|
+
}));
|
|
109
113
|
//#endregion
|
|
110
|
-
|
|
114
|
+
init_oauth_page();
|
|
115
|
+
export { init_oauth_page, oauthErrorHtml, oauthSuccessHtml };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
1
2
|
//#region src/auth/oauth/google-oauth/pkce.ts
|
|
2
3
|
/**
|
|
3
4
|
* PKCE utilities using Web Crypto API.
|
|
@@ -26,5 +27,7 @@ async function generatePKCE() {
|
|
|
26
27
|
challenge: base64urlEncode(new Uint8Array(hashBuffer))
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
var init_pkce = __esmMin((() => {}));
|
|
29
31
|
//#endregion
|
|
30
|
-
|
|
32
|
+
init_pkce();
|
|
33
|
+
export { generatePKCE, init_pkce };
|
|
@@ -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 };
|