dsh-sub2api 0.10.0 → 0.10.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ - **A key without a group is replaced instead of reused.** After the domain move
6
+ an account could hold a `dsh` key with no group; the plugin matched it by name,
7
+ reported "复用已有密钥" as a success, and then every request failed with 403
8
+ "API Key is not assigned to any group". The stale key is now deleted and a
9
+ grouped one created, so the login actually produces a working key.
10
+ - The check normalises `group_id: null` — the gateway sends null, not undefined,
11
+ and a bare `=== undefined` test would have missed exactly this case.
12
+
3
13
  ## 0.10.0
4
14
 
5
15
  - **The gateway and the pay centre moved.** Defaults are now
@@ -55,9 +55,17 @@ export async function provisionAccount(deps) {
55
55
  );
56
56
 
57
57
  let key = existing?.key;
58
- let groupId = existing?.group_id ?? undefined;
58
+ // `?? undefined` normalises both null and undefined; the gateway sends null.
59
+ const rawGroup = existing?.group_id;
60
+ let groupId = rawGroup === null || rawGroup === undefined ? undefined : rawGroup;
59
61
 
60
- if (typeof key === "string" && key !== "") {
62
+ // A key that exists but carries no group is unusable: the gateway answers
63
+ // every request with 403 "API Key is not assigned to any group". Reusing it
64
+ // because the name matches would look like a successful login and fail on the
65
+ // first message, so an ungrouped key is treated as one that needs replacing.
66
+ const ungrouped = typeof key === "string" && key !== "" && groupId === undefined;
67
+
68
+ if (typeof key === "string" && key !== "" && !ungrouped) {
61
69
  steps.push(step("key", "API 密钥", true, `复用已有密钥 ${keyName}`));
62
70
  } else {
63
71
  const chosenGroup = chooseGroup({
@@ -65,6 +73,12 @@ export async function provisionAccount(deps) {
65
73
  groups,
66
74
  allowed: profile.ok ? profile.value?.allowed_groups : undefined,
67
75
  });
76
+ if (ungrouped) {
77
+ // Keep the account tidy: the old key cannot be used, and leaving it means
78
+ // the next login picks the same broken one again.
79
+ await attempt(() => api.deleteKey?.(accessToken, existing.id));
80
+ steps.push(step("key", "API 密钥", true, `已替换未分组的旧密钥 ${keyName}`));
81
+ }
68
82
  const created = await attempt(() =>
69
83
  api.createKey(accessToken, { name: keyName, groupId: chosenGroup }),
70
84
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sub2api",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Official Psapi provider for DeepSeek Harness: email sign-in or sign-up, automatic key and model provisioning, one panel for balance and recharge",
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-only",