@eddyskywalker/dsh-chatgpt-subscription 0.88.2 → 0.89.0

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.
Files changed (31) hide show
  1. package/README.md +1 -1
  2. package/lib/client.js +67 -10
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +306 -61
  5. package/lib/types/client/locales-ru/hub.d.ts.map +1 -1
  6. package/lib/types/client/providers/codex-chatgpt/CodexSubscriptionSection.d.ts +1 -1
  7. package/lib/types/client/providers/codex-chatgpt/CodexSubscriptionSection.d.ts.map +1 -1
  8. package/lib/types/client/providers/codex-chatgpt/api.d.ts +3 -1
  9. package/lib/types/client/providers/codex-chatgpt/api.d.ts.map +1 -1
  10. package/lib/types/client/providers/codex-chatgpt/locales.d.ts +9 -1
  11. package/lib/types/client/providers/codex-chatgpt/locales.d.ts.map +1 -1
  12. package/lib/types/client/providers/codex-chatgpt/styles.d.ts.map +1 -1
  13. package/lib/types/compat.d.ts +1 -1
  14. package/lib/types/host/common/account-pool.d.ts +3 -0
  15. package/lib/types/host/common/account-pool.d.ts.map +1 -1
  16. package/lib/types/host/providers/antigravity-acp/adapter.d.ts.map +1 -1
  17. package/lib/types/host/providers/antigravity-acp/binary.d.ts +1 -1
  18. package/lib/types/host/providers/antigravity-acp/binary.d.ts.map +1 -1
  19. package/lib/types/host/providers/antigravity-acp/errors.d.ts +4 -2
  20. package/lib/types/host/providers/antigravity-acp/errors.d.ts.map +1 -1
  21. package/lib/types/host/providers/codex-chatgpt/codex-account-pool.d.ts +2 -0
  22. package/lib/types/host/providers/codex-chatgpt/codex-account-pool.d.ts.map +1 -1
  23. package/lib/types/host/providers/codex-chatgpt/codex-file-import.d.ts +12 -0
  24. package/lib/types/host/providers/codex-chatgpt/codex-file-import.d.ts.map +1 -0
  25. package/lib/types/host/providers/codex-chatgpt/codex-identity.d.ts +1 -0
  26. package/lib/types/host/providers/codex-chatgpt/codex-identity.d.ts.map +1 -1
  27. package/lib/types/host/providers/codex-chatgpt/routes.d.ts.map +1 -1
  28. package/lib/types/host/providers/opendesign/mapper.d.ts.map +1 -1
  29. package/lib/types/shared/contracts.d.ts +6 -0
  30. package/lib/types/shared/contracts.d.ts.map +1 -1
  31. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  | 线路 | Provider ID | 登录方式 |
18
18
  | --- | --- | --- |
19
- | ChatGPT / Codex | `codex-chatgpt` | 浏览器登录 / 设备码 / 导入 Codex CLI |
19
+ | ChatGPT / Codex | `codex-chatgpt` | 浏览器登录 / 设备码 / 导入 Codex CLI、CPA / sub2api 文件 |
20
20
  | Claude 订阅 | `claude-subscription` | 浏览器授权 / 导入 Claude Code |
21
21
  | Claude API | `claude-api` | API Key |
22
22
  | Kimi Code | `kimi-code` | 设备码授权 / API Key |
package/lib/client.js CHANGED
@@ -840,6 +840,10 @@ window.__ModuleLoader__.load({
840
840
  hubUpdateCommandLabel: "手动更新命令",
841
841
  localCodexLoginImport: "导入本机登录",
842
842
  localCodexLoginImporting: "导入中…",
843
+ credentialFileImport: "导入 CPA / sub2api",
844
+ credentialFileImporting: "导入中…",
845
+ credentialFileImportDetail: "从 CPA ZIP 或 sub2api JSON 文件导入 ChatGPT 账号",
846
+ credentialFileImportResult: "已导入 {count} 个 {format} 账号,跳过 {skipped} 个。",
843
847
  deviceCodeLogin: "设备代码登录",
844
848
  deviceCodeLoginStarting: "获取代码…",
845
849
  deviceCodeLoginDetail: "用设备代码添加账号",
@@ -1114,6 +1118,10 @@ window.__ModuleLoader__.load({
1114
1118
  hubUpdateCommandLabel: "Manual update command",
1115
1119
  localCodexLoginImport: "Import local sign-in",
1116
1120
  localCodexLoginImporting: "Importing…",
1121
+ credentialFileImport: "Import CPA / sub2api",
1122
+ credentialFileImporting: "Importing…",
1123
+ credentialFileImportDetail: "Import ChatGPT accounts from a CPA ZIP or sub2api JSON file",
1124
+ credentialFileImportResult: "Imported {count} {format} accounts; skipped {skipped}.",
1117
1125
  deviceCodeLogin: "Device-code sign-in",
1118
1126
  deviceCodeLoginStarting: "Requesting code…",
1119
1127
  deviceCodeLoginDetail: "Add account with device code",
@@ -2129,6 +2137,14 @@ window.__ModuleLoader__.load({
2129
2137
  adoptLocalLogin(source) {
2130
2138
  return post$9(`${ROUTE_PREFIX}/adopt`, { source });
2131
2139
  }
2140
+ /** Import a CPA ZIP or sub2api JSON file without exposing its credentials in a DTO. */
2141
+ importCredentialFile(file) {
2142
+ return request$6(`${ROUTE_PREFIX}/accounts/import`, {
2143
+ method: "POST",
2144
+ headers: { "content-type": "application/octet-stream" },
2145
+ body: file
2146
+ });
2147
+ }
2132
2148
  /** Forget every imported snapshot. The CLIs' own files are never touched. */
2133
2149
  disableAdoptedLocalLogins() {
2134
2150
  return post$9(`${ROUTE_PREFIX}/adopt/disable`, {});
@@ -3300,6 +3316,7 @@ window.__ModuleLoader__.load({
3300
3316
  function CodexSubscriptionSection({ t }) {
3301
3317
  const apiRef = (0, react.useRef)(new SubscriptionApi());
3302
3318
  const eventSourceRef = (0, react.useRef)(null);
3319
+ const credentialFileInputRef = (0, react.useRef)(null);
3303
3320
  /**
3304
3321
  * The flow the card knows it started.
3305
3322
  *
@@ -3326,6 +3343,7 @@ window.__ModuleLoader__.load({
3326
3343
  /** Ticked once a second, so the panel's countdown is a clock and not a snapshot. */
3327
3344
  const [now, setNow] = (0, react.useState)(() => Date.now());
3328
3345
  const [resetCreditNotice, setResetCreditNotice] = (0, react.useState)(null);
3346
+ const [credentialImportNotice, setCredentialImportNotice] = (0, react.useState)(null);
3329
3347
  const [connection, setConnection] = (0, react.useState)(null);
3330
3348
  const [contextDrafts, setContextDrafts] = (0, react.useState)({});
3331
3349
  const load = (0, react.useCallback)(async (quiet = false) => {
@@ -3689,6 +3707,18 @@ window.__ModuleLoader__.load({
3689
3707
  await load(true);
3690
3708
  });
3691
3709
  };
3710
+ const importCredentialFile = async (file) => {
3711
+ setCredentialImportNotice(null);
3712
+ await run("file-import", async () => {
3713
+ const result = await apiRef.current.importCredentialFile(file);
3714
+ setStatus(result.status);
3715
+ setCredentialImportNotice(formatPoolLabel(t("credentialFileImportResult"), {
3716
+ format: result.format === "cpa" ? "CPA" : "sub2api",
3717
+ count: result.imported,
3718
+ skipped: result.skipped
3719
+ }));
3720
+ });
3721
+ };
3692
3722
  const setRotationStrategy = async (strategy) => {
3693
3723
  await run("strategy", async () => {
3694
3724
  const next = await apiRef.current.accountAction("strategy", { strategy });
@@ -3785,7 +3815,7 @@ window.__ModuleLoader__.load({
3785
3815
  onSetStrategy: (strategy) => void setRotationStrategy(strategy),
3786
3816
  showQuota: true,
3787
3817
  renderLoginActions: () => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3788
- className: "dsha-account-add-actions",
3818
+ className: "dsha-account-add-actions dsh-codex-login-actions",
3789
3819
  children: [
3790
3820
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3791
3821
  className: "dsha-btn dsha-btn-primary",
@@ -3808,6 +3838,26 @@ window.__ModuleLoader__.load({
3808
3838
  title: t("localCodexLoginImport"),
3809
3839
  onClick: () => void importLocalSignIn(),
3810
3840
  children: busy === "adopt" ? t("localCodexLoginImporting") : t("localCodexLoginImport")
3841
+ }),
3842
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3843
+ ref: credentialFileInputRef,
3844
+ type: "file",
3845
+ hidden: true,
3846
+ accept: ".zip,.json,application/zip,application/json",
3847
+ "aria-label": t("credentialFileImportDetail"),
3848
+ onChange: (event) => {
3849
+ const file = event.currentTarget.files?.[0];
3850
+ event.currentTarget.value = "";
3851
+ if (file !== void 0) importCredentialFile(file);
3852
+ }
3853
+ }),
3854
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3855
+ className: "dsha-btn",
3856
+ disabled: busy !== null,
3857
+ "aria-label": t("credentialFileImportDetail"),
3858
+ title: t("credentialFileImportDetail"),
3859
+ onClick: () => credentialFileInputRef.current?.click(),
3860
+ children: busy === "file-import" ? t("credentialFileImporting") : t("credentialFileImport")
3811
3861
  })
3812
3862
  ]
3813
3863
  }),
@@ -3817,6 +3867,11 @@ window.__ModuleLoader__.load({
3817
3867
  entry.planLabel
3818
3868
  ] }) }),
3819
3869
  children: [
3870
+ credentialImportNotice !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3871
+ className: "dsh-codex-success",
3872
+ role: "status",
3873
+ children: credentialImportNotice
3874
+ }) : null,
3820
3875
  login?.active && deviceLogin === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3821
3876
  className: "dsha-muted",
3822
3877
  role: "status",
@@ -28246,6 +28301,10 @@ window.__ModuleLoader__.load({
28246
28301
  hubUpdateCommandLabel: "Команда для ручного обновления",
28247
28302
  localCodexLoginImport: "Импорт локального входа",
28248
28303
  localCodexLoginImporting: "Импорт…",
28304
+ credentialFileImport: "Импорт CPA / sub2api",
28305
+ credentialFileImporting: "Импорт…",
28306
+ credentialFileImportDetail: "Импорт аккаунтов ChatGPT из CPA ZIP или sub2api JSON",
28307
+ credentialFileImportResult: "Импортировано аккаунтов {format}: {count}; пропущено: {skipped}.",
28249
28308
  deviceCodeLogin: "Вход по коду устройства",
28250
28309
  deviceCodeLoginStarting: "Получаем код…",
28251
28310
  deviceCodeLoginDetail: "Добавить аккаунт по коду устройства",
@@ -30023,15 +30082,13 @@ window.__ModuleLoader__.load({
30023
30082
  const CSS$6 = `
30024
30083
  .dsh-codex-page{box-sizing:border-box;color:var(--dsw-alias-label-primary);display:flex;flex-direction:column;gap:20px;max-width:780px;min-width:0;padding:2px 0 30px}
30025
30084
  .dsh-codex-page *{box-sizing:border-box}
30026
- /* The pool card's login row holds three entries. They must stay on ONE line: a
30027
- wrapped row stops reading as a set of alternatives, and the third entry is the
30028
- one that gets pushed out. .dsha-btn carries white-space:nowrap, so shrinking
30029
- the row means letting the buttons shrink and ellipsizing the label inside —
30030
- the accessible name stays whole in aria-label/title, which is where the full
30031
- sentence lives. flex-basis 0 keeps the three of them sharing the width evenly
30032
- instead of the longest one claiming it. */
30033
- .dsh-codex-page :where(.dsha-account-add-actions){flex-wrap:nowrap;min-width:0}
30034
- .dsh-codex-page :where(.dsha-account-add-actions) > .dsha-btn{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}
30085
+ .dsh-codex-page :where(.dsha-account-add-actions:not(.dsh-codex-login-actions)){flex-wrap:nowrap;min-width:0}
30086
+ .dsh-codex-page :where(.dsha-account-add-actions:not(.dsh-codex-login-actions)) > .dsha-btn{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}
30087
+ /* Wrap the heading and actions as units when the full labels need more room. */
30088
+ .dsha-grouphead:has(> .dsh-codex-login-actions){flex-wrap:wrap;gap:6px 8px}
30089
+ .dsha-grouphead:has(> .dsh-codex-login-actions) > h3 > .dsha-muted{font-size:12px}
30090
+ .dsh-codex-page .dsh-codex-login-actions{gap:4px;max-width:100%}
30091
+ .dsh-codex-login-actions > .dsha-btn{font-size:12px;padding-inline:6px}
30035
30092
  .dsh-codex-title{font-size:15px;font-weight:650;line-height:1.4;margin:0 0 5px}
30036
30093
  .dsh-codex-intro,.dsh-codex-muted{color:var(--dsw-alias-label-secondary);font-size:13px;line-height:1.55;margin:0}
30037
30094
  .dsh-codex-group{border-top:0.5px solid var(--dsw-alias-border-l2);min-width:0}