dsh-auth-remote 0.1.9 → 0.2.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 (57) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CHANGELOG.zh-CN.md +32 -0
  3. package/CONTRIBUTING.md +3 -1
  4. package/CONTRIBUTING.zh-CN.md +3 -1
  5. package/README.md +49 -23
  6. package/README.zh-CN.md +37 -11
  7. package/cordis.patch.yml +4 -3
  8. package/dist/cli.js +91 -46
  9. package/dist/cli.js.map +2 -2
  10. package/dist/client.js +2880 -581
  11. package/dist/client.js.map +4 -4
  12. package/dist/index.js +201 -36
  13. package/dist/index.js.map +4 -4
  14. package/dist/login.css +2 -8
  15. package/dist/login.css.map +2 -2
  16. package/dist/login.js +80 -42
  17. package/dist/login.js.map +2 -2
  18. package/dist/types/adapters/dsh/account-callback.d.ts +3 -0
  19. package/dist/types/adapters/dsh/account-callback.d.ts.map +1 -1
  20. package/dist/types/adapters/dsh/hmr-context.d.ts +10 -0
  21. package/dist/types/adapters/dsh/hmr-context.d.ts.map +1 -0
  22. package/dist/types/auth/service.d.ts +2 -0
  23. package/dist/types/auth/service.d.ts.map +1 -1
  24. package/dist/types/auth/sessions.d.ts +2 -0
  25. package/dist/types/auth/sessions.d.ts.map +1 -1
  26. package/dist/types/config.d.ts +9 -3
  27. package/dist/types/config.d.ts.map +1 -1
  28. package/dist/types/http/account-login.d.ts +5 -3
  29. package/dist/types/http/account-login.d.ts.map +1 -1
  30. package/dist/types/index.d.ts +2 -2
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/shared/account-login.d.ts +2 -1
  33. package/dist/types/shared/account-login.d.ts.map +1 -1
  34. package/dist/types/shared/auth-contract.d.ts +2 -0
  35. package/dist/types/shared/auth-contract.d.ts.map +1 -1
  36. package/dist/types/shared/dsh-support.d.ts +38 -0
  37. package/dist/types/shared/dsh-support.d.ts.map +1 -0
  38. package/dist/types/shared/i18n.d.ts +78 -40
  39. package/dist/types/shared/i18n.d.ts.map +1 -1
  40. package/dist/types/shared/locales/en.d.ts +39 -20
  41. package/dist/types/shared/locales/en.d.ts.map +1 -1
  42. package/dist/types/shared/locales/zh.d.ts +39 -20
  43. package/dist/types/shared/locales/zh.d.ts.map +1 -1
  44. package/docs/deployment.md +26 -21
  45. package/docs/deployment.zh-CN.md +26 -21
  46. package/docs/development.md +74 -8
  47. package/docs/development.zh-CN.md +74 -8
  48. package/docs/legacy-compatibility.md +96 -64
  49. package/docs/legacy-compatibility.zh-CN.md +96 -64
  50. package/docs/releasing.md +40 -10
  51. package/docs/releasing.zh-CN.md +40 -10
  52. package/docs/support-history.md +97 -0
  53. package/docs/support-history.zh-CN.md +97 -0
  54. package/docs/support-policy.md +87 -0
  55. package/docs/support-policy.zh-CN.md +87 -0
  56. package/examples/web-profile-auth-remote.patch.yml +6 -3
  57. package/package.json +28 -17
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // src/index.ts
2
2
  import { Service } from "@deepseek-ai/cordis";
3
+ import { readFileSync as readFileSync3 } from "node:fs";
4
+ import { createRequire as createRequire2 } from "node:module";
3
5
  import { basename } from "node:path";
4
6
 
5
7
  // src/adapters/dsh/compatibility.ts
@@ -60,11 +62,12 @@ function assertConnectionCompatibility(connection, anchor) {
60
62
  }
61
63
 
62
64
  // src/shared/account-login.ts
65
+ import { satisfies } from "semver";
63
66
  var ACCOUNT_LOGIN_BASE = "/auth-remote/account";
64
67
  var ACCOUNT_CALLBACK_PATH = "/oauth/callback";
65
68
  var ACCOUNT_LOGIN_CAPABILITY = "__DSH_AUTH_REMOTE_MANUAL_ACCOUNT_LOGIN__";
66
69
  function supportsManualAccountLogin(version) {
67
- return version === "0.2.1-alpha.3";
70
+ return satisfies(version, ">=0.2.1-alpha.3", { includePrerelease: true });
68
71
  }
69
72
  function isActiveAccountLogin(phase) {
70
73
  return ["initializing", "waiting-browser", "exchanging", "committing"].includes(phase);
@@ -504,6 +507,17 @@ function listenerTransport(actual, capabilities) {
504
507
  };
505
508
  }
506
509
 
510
+ // src/adapters/dsh/hmr-context.ts
511
+ import { AsyncLocalStorage } from "node:async_hooks";
512
+ function outsideHmrTransaction(ctx, initialize) {
513
+ const hmr = ctx.get("hmr");
514
+ const scope = hmr?.executing;
515
+ if (typeof hmr?.runExclusive === "function" && scope instanceof AsyncLocalStorage && scope.getStore() === true) {
516
+ return scope.exit(initialize);
517
+ }
518
+ return initialize();
519
+ }
520
+
507
521
  // src/adapters/dsh/webserver.ts
508
522
  import WebServer2 from "@deepseek-ai/dsh-host-webserver";
509
523
  var READY_PATH = "/auth-remote/ready";
@@ -1091,10 +1105,11 @@ function issueSession(draft, now, sessionHours) {
1091
1105
  function sessionFor(state, token, now, requireTotp) {
1092
1106
  if (typeof token !== "string" || !/^[A-Za-z0-9_-]{43}$/u.test(token)) return null;
1093
1107
  const session = state.sessions[sessionHash(token)];
1108
+ return session && isActiveSession(state, session, now, requireTotp) ? session : null;
1109
+ }
1110
+ function isActiveSession(state, session, now, requireTotp) {
1094
1111
  const account = state.account;
1095
- if (!session || !account || session.accountId !== account.id || session.securityVersion !== account.securityVersion || session.expiresAt <= now || requireTotp && !account.totp)
1096
- return null;
1097
- return session;
1112
+ return !!(account && session.accountId === account.id && session.securityVersion === account.securityVersion && session.expiresAt > now && (!requireTotp || account.totp));
1098
1113
  }
1099
1114
 
1100
1115
  // src/auth/totp.ts
@@ -1220,11 +1235,12 @@ var AuthService = class {
1220
1235
  }
1221
1236
  status() {
1222
1237
  const state = this.store.current();
1238
+ const now = this.now();
1223
1239
  return {
1224
1240
  initialized: state.account !== null,
1225
1241
  totpEnabled: state.account?.totp !== null && state.account?.totp !== void 0,
1226
1242
  activeSessions: Object.values(state.sessions).filter(
1227
- (session) => state.account && session.accountId === state.account.id && session.securityVersion === state.account.securityVersion && session.expiresAt > this.now() && (!this.policy.requireTotp || state.account.totp)
1243
+ (session) => isActiveSession(state, session, now, this.policy.requireTotp)
1228
1244
  ).length
1229
1245
  };
1230
1246
  }
@@ -1236,12 +1252,17 @@ var AuthService = class {
1236
1252
  }
1237
1253
  me(token) {
1238
1254
  const state = this.store.current();
1239
- const session = sessionFor(state, token, this.now(), this.policy.requireTotp);
1255
+ const now = this.now();
1256
+ const session = sessionFor(state, token, now, this.policy.requireTotp);
1240
1257
  if (!session || !state.account) throw new AuthError("unauthorized");
1241
1258
  return {
1242
1259
  username: state.account.username,
1243
1260
  totpEnabled: state.account.totp !== null,
1244
- expiresAt: session.expiresAt
1261
+ createdAt: session.createdAt,
1262
+ expiresAt: session.expiresAt,
1263
+ activeSessions: Object.values(state.sessions).filter(
1264
+ (entry) => isActiveSession(state, entry, now, this.policy.requireTotp)
1265
+ ).length
1245
1266
  };
1246
1267
  }
1247
1268
  bindingDetails(id) {
@@ -1607,17 +1628,18 @@ var AuthService = class {
1607
1628
  import z from "@deepseek-ai/schemastery";
1608
1629
  import { isIP as isIP3 } from "node:net";
1609
1630
  import { resolve } from "node:path";
1610
- var DEFAULT_REQUIRE_TOTP = true;
1631
+ var DEFAULT_REQUIRE_TOTP = false;
1611
1632
  var DEFAULT_SESSION_HOURS = 168;
1612
1633
  var DEFAULT_WEB_HOST = "127.0.0.1";
1613
1634
  var DEFAULT_WEB_PORT = 3080;
1614
1635
  var AUTH_CONFIG_KEYS = /* @__PURE__ */ new Set([
1615
1636
  "allowedOrigins",
1616
1637
  "requireTotp",
1638
+ "manualAccountLogin",
1617
1639
  "sessionHours",
1618
1640
  "preserveOriginPaths"
1619
1641
  ]);
1620
- var Config = z.object({
1642
+ var StaticConfig = z.object({
1621
1643
  publicUrl: z.string(),
1622
1644
  host: z.string(),
1623
1645
  port: z.number().step(1).min(0).max(65535),
@@ -1628,6 +1650,11 @@ var Config = z.object({
1628
1650
  sessionHours: z.number().step(1).min(1).default(DEFAULT_SESSION_HOURS),
1629
1651
  preserveOriginPaths: z.array(z.string()).default([])
1630
1652
  });
1653
+ var ManualAccountLoginConfig = z.boolean().default(true).volatile();
1654
+ var Config = z.object({
1655
+ ...StaticConfig.dict,
1656
+ manualAccountLogin: ManualAccountLoginConfig
1657
+ });
1631
1658
  function resolveStartupConfig(input, startup, context) {
1632
1659
  if (typeof input !== "object" || input === null || Array.isArray(input))
1633
1660
  throw new Error("auth-remote: config is required");
@@ -1638,7 +1665,16 @@ function resolveStartupConfig(input, startup, context) {
1638
1665
  const explicitUrl = startup.publicUrl !== void 0 || Object.hasOwn(input, "publicUrl");
1639
1666
  if (legacyWarning && explicitUrl)
1640
1667
  throw new Error("auth-remote: publicUrl and allowedOrigins cannot be supplied together");
1641
- const config = Config(input);
1668
+ const { manualAccountLogin: manual, ...ordinary } = input;
1669
+ const config = StaticConfig(ordinary);
1670
+ let manualAccountLogin;
1671
+ if (typeof manual === "object" && manual !== null) {
1672
+ if (typeof manual.get !== "function") throw new Error("auth-remote: invalid manualAccountLogin");
1673
+ z.boolean().required()(manual.get());
1674
+ manualAccountLogin = manual;
1675
+ } else {
1676
+ manualAccountLogin = ManualAccountLoginConfig(manual);
1677
+ }
1642
1678
  const capabilities = getRuntimeCapabilities(context.version);
1643
1679
  let publicUrl;
1644
1680
  let publicUrlSource = "derived";
@@ -1698,6 +1734,7 @@ function resolveStartupConfig(input, startup, context) {
1698
1734
  tlsSource,
1699
1735
  legacyWarning,
1700
1736
  requireTotp: config.requireTotp ?? DEFAULT_REQUIRE_TOTP,
1737
+ manualAccountLogin,
1701
1738
  sessionHours,
1702
1739
  preserveOriginPaths: Object.freeze([...paths])
1703
1740
  };
@@ -2259,7 +2296,7 @@ var AuthRoutes = class {
2259
2296
  "referrer-policy": "no-referrer"
2260
2297
  });
2261
2298
  res.end(
2262
- '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sign in to DSH</title><link rel="manifest" href="/manifest.webmanifest"><link rel="stylesheet" href="/auth-remote/login.css"><script defer src="/auth-remote/login.js"></script></head><body><main id="login-root" aria-live="polite">Checking sign-in status\u2026</main></body></html>'
2299
+ '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sign in</title><link rel="manifest" href="/manifest.webmanifest"><link rel="stylesheet" href="/auth-remote/login.css"><script defer src="/auth-remote/login.js"></script></head><body><main id="login-root" aria-live="polite">Checking sign-in status\u2026</main></body></html>'
2263
2300
  );
2264
2301
  return;
2265
2302
  }
@@ -2555,14 +2592,22 @@ import { IncomingMessage, ServerResponse } from "node:http";
2555
2592
  import { Duplex } from "node:stream";
2556
2593
  import { finished } from "node:stream/promises";
2557
2594
  var AccountCallbackBridge = class {
2595
+ constructor(ownsCallback = () => true) {
2596
+ this.ownsCallback = ownsCallback;
2597
+ }
2598
+ ownsCallback;
2558
2599
  handler;
2600
+ get available() {
2601
+ return this.handler !== void 0;
2602
+ }
2559
2603
  capture(route) {
2560
2604
  if (route.kind !== "exact" || route.path !== ACCOUNT_CALLBACK_PATH) return;
2561
2605
  const handler = route.handler;
2562
2606
  this.handler = handler;
2563
2607
  return {
2564
- handler: (_req, res) => {
2565
- res.writeHead(403, { "cache-control": "no-store" }).end();
2608
+ handler: async (req, res) => {
2609
+ if (await this.ownsCallback()) res.writeHead(403, { "cache-control": "no-store" }).end();
2610
+ else return handler(req, res);
2566
2611
  },
2567
2612
  dispose: () => {
2568
2613
  if (this.handler === handler) this.handler = void 0;
@@ -2601,9 +2646,10 @@ var AccountCallbackBridge = class {
2601
2646
 
2602
2647
  // src/http/account-login.ts
2603
2648
  var ManualAccountLogin = class {
2604
- constructor(ctx, auth, store, version) {
2649
+ constructor(ctx, auth, store, version, enabled = () => true) {
2605
2650
  this.auth = auth;
2606
2651
  this.version = version;
2652
+ this.enabled = enabled;
2607
2653
  this.unsubscribe = store.subscribe((_before, after) => this.reconcile(after));
2608
2654
  if (!supportsManualAccountLogin(version)) return;
2609
2655
  ctx.inject(["deepseekAccount"], (accountCtx) => {
@@ -2619,7 +2665,8 @@ var ManualAccountLogin = class {
2619
2665
  }
2620
2666
  auth;
2621
2667
  version;
2622
- bridge = new AccountCallbackBridge();
2668
+ enabled;
2669
+ bridge = new AccountCallbackBridge(() => this.ownsNativeCallback());
2623
2670
  unsubscribe;
2624
2671
  active;
2625
2672
  starting = false;
@@ -2639,6 +2686,21 @@ var ManualAccountLogin = class {
2639
2686
  const provider = this.currentProvider;
2640
2687
  return provider && typeof provider.getState === "function" && typeof provider.startSignIn === "function" && typeof provider.cancelSignIn === "function" ? provider : void 0;
2641
2688
  }
2689
+ async ownsNativeCallback() {
2690
+ const active = this.active;
2691
+ if (!active?.ownsCallback) return false;
2692
+ if (!active.id) return true;
2693
+ try {
2694
+ const view = await active.provider.getState();
2695
+ if (this.active !== active) return this.active?.ownsCallback === true;
2696
+ if (!active.ownsCallback) return false;
2697
+ if (view.attempt?.id === active.id && isActiveAccountLogin(view.attempt.phase)) return true;
2698
+ active.ownsCallback = false;
2699
+ return false;
2700
+ } catch {
2701
+ return true;
2702
+ }
2703
+ }
2642
2704
  session(token) {
2643
2705
  const session = token && !this.disposed ? this.auth.session(token) : null;
2644
2706
  if (!token || !session) throw new AuthError("unauthorized");
@@ -2666,33 +2728,41 @@ var ManualAccountLogin = class {
2666
2728
  async state(token) {
2667
2729
  const { hash } = this.session(token);
2668
2730
  const provider = this.provider();
2669
- if (!provider) return { supported: false, status: "signed-out", attempt: null };
2731
+ if (!provider)
2732
+ return { supported: false, enabled: this.enabled(), status: "signed-out", attempt: null };
2670
2733
  const view = await provider.getState();
2671
2734
  this.session(token);
2672
2735
  const active = this.active;
2673
2736
  if (!active || active.owner !== hash || active.provider !== provider || active.id !== view.attempt?.id)
2674
- return { supported: true, status: view.status, attempt: null };
2737
+ return { supported: true, enabled: this.enabled(), status: view.status, attempt: null };
2675
2738
  const attempt = view.attempt;
2739
+ if (attempt?.phase === "waiting-browser" && !this.bridge.available)
2740
+ throw new HttpFailure(503, "account_unavailable");
2676
2741
  if (attempt?.expiresAt !== void 0 && attempt.expiresAt < active.deadline) {
2677
2742
  active.deadline = attempt.expiresAt;
2678
2743
  this.schedule(active);
2679
2744
  }
2680
- if (attempt && !isActiveAccountLogin(attempt.phase) && active.timer) clearTimeout(active.timer);
2745
+ if (attempt && !isActiveAccountLogin(attempt.phase)) {
2746
+ if (active.timer) clearTimeout(active.timer);
2747
+ active.ownsCallback = false;
2748
+ }
2681
2749
  return {
2682
2750
  supported: true,
2751
+ enabled: this.enabled(),
2683
2752
  status: view.status,
2684
2753
  attempt: attempt && { ...attempt, expiresAt: active.deadline }
2685
2754
  };
2686
2755
  }
2687
2756
  async start(token, body) {
2688
2757
  const owner = this.session(token);
2758
+ const provider = this.provider();
2759
+ if (!provider) throw new HttpFailure(503, "account_unavailable");
2760
+ if (!this.enabled()) throw new HttpFailure(403, "account_disabled");
2689
2761
  const locale = stringField(body, "locale");
2690
2762
  const offset = body.timezoneOffsetSeconds;
2691
2763
  if (locale.length > 64 || !/^[a-z][a-z0-9_-]*$/iu.test(locale) || !Number.isInteger(offset) || Math.abs(offset) > 86400)
2692
2764
  throw new HttpFailure(400, "invalid_input");
2693
2765
  if (this.starting) throw new HttpFailure(409, "account_busy");
2694
- const provider = this.provider();
2695
- if (!provider) throw new HttpFailure(503, "account_unavailable");
2696
2766
  this.starting = true;
2697
2767
  let entry;
2698
2768
  try {
@@ -2700,7 +2770,7 @@ var ManualAccountLogin = class {
2700
2770
  if (previous.attempt && isActiveAccountLogin(previous.attempt.phase))
2701
2771
  throw new HttpFailure(409, "account_busy");
2702
2772
  if (previous.status === "credential-stored")
2703
- return { ...previous, supported: true, attempt: null };
2773
+ return { ...previous, supported: true, enabled: this.enabled(), attempt: null };
2704
2774
  if (this.active?.timer) clearTimeout(this.active.timer);
2705
2775
  entry = {
2706
2776
  owner: owner.hash,
@@ -2708,7 +2778,8 @@ var ManualAccountLogin = class {
2708
2778
  callbackOrigin: `http://127.0.0.1:${randomInt(49152, 65536)}`,
2709
2779
  deadline: Math.min(Date.now() + 6e5, owner.session.expiresAt),
2710
2780
  cancelled: false,
2711
- submitting: false
2781
+ submitting: false,
2782
+ ownsCallback: true
2712
2783
  };
2713
2784
  this.active = entry;
2714
2785
  this.schedule(entry);
@@ -2729,6 +2800,7 @@ var ManualAccountLogin = class {
2729
2800
  throw error;
2730
2801
  } finally {
2731
2802
  this.starting = false;
2803
+ if (entry?.cancelled && !entry.id) entry.ownsCallback = false;
2732
2804
  }
2733
2805
  }
2734
2806
  callback(value, active) {
@@ -2754,6 +2826,7 @@ var ManualAccountLogin = class {
2754
2826
  if (!before.attempt || before.attempt.id !== active.id || before.attempt.phase !== "waiting-browser")
2755
2827
  throw new HttpFailure(409, "account_attempt_mismatch");
2756
2828
  this.owned(token, active.id);
2829
+ if (!this.bridge.available) throw new HttpFailure(503, "account_unavailable");
2757
2830
  const status = await this.bridge.submit(query);
2758
2831
  if (status === 400) throw new HttpFailure(400, "account_invalid_callback");
2759
2832
  const state = await this.state(token);
@@ -2771,10 +2844,15 @@ var ManualAccountLogin = class {
2771
2844
  attempt.cancelled = true;
2772
2845
  if (attempt.timer) clearTimeout(attempt.timer);
2773
2846
  if (attempt.id) {
2774
- attempt.cancellation ??= Promise.resolve().then(async () => {
2847
+ const cancellation = attempt.cancellation ??= Promise.resolve().then(async () => {
2775
2848
  await attempt.provider.cancelSignIn(attempt.id);
2776
2849
  });
2777
- await attempt.cancellation;
2850
+ try {
2851
+ await cancellation;
2852
+ } catch (error) {
2853
+ if (attempt.cancellation === cancellation) delete attempt.cancellation;
2854
+ throw error;
2855
+ }
2778
2856
  }
2779
2857
  }
2780
2858
  async reconcile(state) {
@@ -2828,8 +2906,84 @@ var ManualAccountLogin = class {
2828
2906
  }
2829
2907
  };
2830
2908
 
2909
+ // src/shared/dsh-support.ts
2910
+ function legacy(version, windowDays, eligibleRetirement) {
2911
+ return {
2912
+ state: "legacy",
2913
+ version,
2914
+ legacySince: "2026-10-19",
2915
+ windowDays,
2916
+ eligibleRetirement,
2917
+ migrationTarget: "0.2.1-rc.2"
2918
+ };
2919
+ }
2920
+ var LEGACY_DSH_RELEASES = [
2921
+ legacy("0.1.7-rc.1", 14, "2026-11-02"),
2922
+ legacy("0.1.7-rc.2", 14, "2026-11-02"),
2923
+ legacy("0.2.0-rc.1", 21, "2026-11-09"),
2924
+ legacy("0.2.0-rc.2", 21, "2026-11-09"),
2925
+ legacy("0.2.1-alpha.1", 21, "2026-11-09"),
2926
+ legacy("0.2.1-alpha.2", 21, "2026-11-09")
2927
+ ];
2928
+ var RETIRED_DSH_RELEASES = [];
2929
+ var lifecycle = [...LEGACY_DSH_RELEASES, ...RETIRED_DSH_RELEASES];
2930
+ function classifyDshSupport(version, declared, records = lifecycle) {
2931
+ if (declared.has(version)) {
2932
+ const record3 = records.find(
2933
+ (item) => item.version === version && item.state === "legacy"
2934
+ );
2935
+ return record3 ? { state: "legacy", version, record: record3 } : { state: "supported", version };
2936
+ }
2937
+ const record2 = records.find(
2938
+ (item) => item.version === version && item.state === "retired"
2939
+ );
2940
+ return record2 ? { state: "retired", version, record: record2 } : { state: "unverified", version };
2941
+ }
2942
+ function dshSupportWarning(support) {
2943
+ const guides = "See docs/support-policy.md and docs/support-history.md.";
2944
+ if (support.state === "supported") return;
2945
+ if (support.state === "legacy") {
2946
+ const record2 = support.record;
2947
+ return `auth-remote: DSH ${support.version} is legacy since ${record2.legacySince}; earliest eligible retirement ${record2.eligibleRetirement} (Asia/Shanghai, ${record2.windowDays} calendar days). Support continues until an explicit retirement release. Migrate to DSH ${record2.migrationTarget} with a supporting plugin release. ${guides}`;
2948
+ }
2949
+ if (support.state === "retired") {
2950
+ const record2 = support.record;
2951
+ return `auth-remote: DSH ${support.version} retired on ${record2.retiredOn} in plugin ${record2.effectivePlugin}; last supported plugin ${record2.lastSupportedPlugin}. No current compatibility commitment; technical checks still apply. Upgrade to DSH ${record2.migrationTarget} with a supporting plugin release, or consult the historical installation guidance. ${guides}`;
2952
+ }
2953
+ return `auth-remote: DSH ${support.version} has no current exact-version support commitment. Technical admission does not establish verified compatibility. Select a declared DSH release and a supporting plugin release. ${guides}`;
2954
+ }
2955
+ var warningKey = /* @__PURE__ */ Symbol.for("dsh-auth-remote.support-warnings");
2956
+ function warnDshSupport(support, write = console.warn) {
2957
+ const message = dshSupportWarning(support);
2958
+ if (!message) return false;
2959
+ const processState = globalThis;
2960
+ const warned = processState[warningKey] ??= /* @__PURE__ */ new Set();
2961
+ const key = `${support.version}:${support.state}`;
2962
+ if (warned.has(key)) return false;
2963
+ warned.add(key);
2964
+ write(message);
2965
+ return true;
2966
+ }
2967
+
2831
2968
  // src/index.ts
2969
+ var ownManifest = JSON.parse(
2970
+ readFileSync3(createRequire2(import.meta.url).resolve("dsh-auth-remote/package.json"), "utf8")
2971
+ );
2972
+ var declaredDshReleases = new Set(
2973
+ Object.entries(ownManifest.dsh.compatibility.dshReleases).filter(([, state]) => state === "compatible").map(([version]) => version)
2974
+ );
2832
2975
  var name = "auth-remote";
2976
+ async function disposeResources(disposers) {
2977
+ const errors = [];
2978
+ for (const dispose of disposers) {
2979
+ try {
2980
+ await dispose();
2981
+ } catch (error) {
2982
+ errors.push(error);
2983
+ }
2984
+ }
2985
+ if (errors.length) throw new AggregateError(errors, "auth-remote: resource cleanup failed");
2986
+ }
2833
2987
  var AuthRemoteWebServer = class extends GuardedWebServer {
2834
2988
  static Config = Config;
2835
2989
  stateStore;
@@ -2851,6 +3005,7 @@ var AuthRemoteWebServer = class extends GuardedWebServer {
2851
3005
  super(ctx, config, gate);
2852
3006
  this.pending = config;
2853
3007
  this.switchGate = gate;
3008
+ warnDshSupport(classifyDshSupport(config.capabilities.version, declaredDshReleases));
2854
3009
  installAuthenticatedHostCapability(ctx, config.capabilities.version);
2855
3010
  if (config.legacyWarning)
2856
3011
  console.warn("auth-remote: allowedOrigins is deprecated; use publicUrl with one root URL");
@@ -2880,7 +3035,7 @@ var AuthRemoteWebServer = class extends GuardedWebServer {
2880
3035
  await auth.enforceCurrentPolicy();
2881
3036
  this.stateStore = store;
2882
3037
  this.authService = auth;
2883
- await super[Service.init]();
3038
+ await outsideHmrTransaction(this.ctx, () => super[Service.init]());
2884
3039
  const port = this.port;
2885
3040
  if (port === void 0) throw new Error("auth-remote: listener has not bound a port");
2886
3041
  this.resolvedConfig = finalizeAuthConfig(this.pending, {
@@ -2899,7 +3054,8 @@ var AuthRemoteWebServer = class extends GuardedWebServer {
2899
3054
  this.ctx,
2900
3055
  auth,
2901
3056
  store,
2902
- this.pending.capabilities.version
3057
+ this.pending.capabilities.version,
3058
+ () => this.pending.manualAccountLogin.get()
2903
3059
  );
2904
3060
  accountLogin.install(this);
2905
3061
  admin = new AdminSocket(
@@ -2921,11 +3077,13 @@ var AuthRemoteWebServer = class extends GuardedWebServer {
2921
3077
  () => async () => {
2922
3078
  this.switchGate.set(new DenyGate());
2923
3079
  activeReadiness.detach();
2924
- await activeAccountLogin.dispose();
2925
- await activeAdmin.dispose();
2926
- await activeConnections.dispose();
2927
- auth.dispose();
2928
- await store.close();
3080
+ await disposeResources([
3081
+ () => activeAccountLogin.dispose(),
3082
+ () => activeAdmin.dispose(),
3083
+ () => activeConnections.dispose(),
3084
+ () => auth.dispose(),
3085
+ () => store.close()
3086
+ ]);
2929
3087
  },
2930
3088
  "auth-remote.storage-and-gate"
2931
3089
  );
@@ -2951,11 +3109,18 @@ var AuthRemoteWebServer = class extends GuardedWebServer {
2951
3109
  );
2952
3110
  } catch (error) {
2953
3111
  this.switchGate.set(new DenyGate());
2954
- await admin?.dispose();
2955
- await accountLogin?.dispose();
2956
- await connections?.dispose();
2957
- this.authService?.dispose();
2958
- await store.close();
3112
+ readiness?.detach();
3113
+ try {
3114
+ await disposeResources([
3115
+ () => accountLogin?.dispose(),
3116
+ () => admin?.dispose(),
3117
+ () => connections?.dispose(),
3118
+ () => this.authService?.dispose(),
3119
+ () => store.close()
3120
+ ]);
3121
+ } catch (cleanupError) {
3122
+ throw new AggregateError([error, cleanupError], "auth-remote: startup and cleanup failed");
3123
+ }
2959
3124
  throw error;
2960
3125
  }
2961
3126
  }