dsh-mobile 0.6.10 → 0.6.12

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 (41) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/CONTRIBUTORS.md +24 -6
  3. package/README.en.md +22 -19
  4. package/README.md +22 -19
  5. package/SECURITY.md +9 -0
  6. package/apps/mobile/README.md +71 -90
  7. package/apps/mobile/README.zh-CN.md +131 -0
  8. package/apps/mobile/release.json +3 -3
  9. package/docs/ATTACH_EXISTING_FRPS.en.md +1 -1
  10. package/docs/ATTACH_EXISTING_FRPS.md +1 -1
  11. package/docs/CADDY_MANAGED.en.md +7 -7
  12. package/docs/CADDY_MANAGED.md +7 -7
  13. package/docs/CLIENT_MODULES.en.md +2 -0
  14. package/docs/CLIENT_MODULES.md +2 -0
  15. package/docs/CLOUDFLARE_TUNNEL.en.md +1 -1
  16. package/docs/CLOUDFLARE_TUNNEL.md +1 -1
  17. package/docs/CPOLAR_SUBDOMAIN.en.md +1 -1
  18. package/docs/CPOLAR_SUBDOMAIN.md +1 -1
  19. package/docs/DSH_0.1.5_LAN.md +1 -1
  20. package/docs/EXTENSION_WORKERS.en.md +2 -2
  21. package/docs/EXTENSION_WORKERS.md +2 -2
  22. package/docs/MOBILE_COMPOSER_TOOLBAR.en.md +10 -4
  23. package/docs/MOBILE_COMPOSER_TOOLBAR.md +10 -4
  24. package/docs/README.md +4 -2
  25. package/docs/SELF_HOSTED_FRP.en.md +2 -2
  26. package/docs/SELF_HOSTED_FRP.md +2 -2
  27. package/docs/SELF_HOSTED_ORIGIN.en.md +3 -1
  28. package/docs/SELF_HOSTED_ORIGIN.md +3 -1
  29. package/docs/SKIN_COMPATIBILITY.en.md +1 -0
  30. package/docs/SKIN_COMPATIBILITY.md +1 -0
  31. package/docs/SLOW_CONNECTIONS.en.md +12 -0
  32. package/docs/SLOW_CONNECTIONS.md +12 -0
  33. package/lib/client.js +234 -37
  34. package/lib/client.js.map +1 -1
  35. package/lib/index.d.mts +34 -3
  36. package/lib/index.mjs +402 -209
  37. package/lib/index.mjs.map +1 -1
  38. package/lib/mobile-compat.js +5 -1
  39. package/lib/mobile-compat.js.map +1 -1
  40. package/package.json +6 -1
  41. package/packages/question-fixes/package.json +1 -1
package/lib/index.d.mts CHANGED
@@ -124,6 +124,8 @@ export declare class BoundedRateLimiter {
124
124
  constructor(limit: number, windowMs: number, maximumKeys: number);
125
125
  /** Consume one attempt; unknown keys fail closed when the bounded table is full. */
126
126
  take(key: string, now: number): boolean;
127
+ /** Discard entries that no longer identify an eligible key in a trusted, finite key set. */
128
+ retainKeys(eligible: ReadonlySet<string>): void;
127
129
  /** Current table size, exposed for bounded-state assertions. */
128
130
  get size(): number;
129
131
  }
@@ -135,6 +137,7 @@ export declare class AccessController {
135
137
  private readonly pairLimiter;
136
138
  private devices;
137
139
  private pairingWindow;
140
+ private pairPending;
138
141
  private readonly sessions;
139
142
  private readonly sessionEndedListeners;
140
143
  private mutation;
@@ -157,6 +160,8 @@ export declare class AccessController {
157
160
  token: string;
158
161
  expiresAt: number;
159
162
  }>;
163
+ /** Limit invalid guesses by peer without letting them consume a valid one-time secret's admission. */
164
+ private rejectPairingAttempt;
160
165
  /** Consume the pairing window exactly once and persist only the device-token digest. */
161
166
  pair(sourceKey: string, token: string, label?: string): Promise<PairingResult>;
162
167
  /** Exchange a valid persistent device credential for a new short Session. */
@@ -516,6 +521,25 @@ export declare class MobileAccessGatewayController {
516
521
  private enqueue;
517
522
  }
518
523
  //#endregion
524
+ //#region src/auth-failure-log.d.ts
525
+ /** One rejected HTTP request, with presence/count fields instead of credential values. */
526
+ interface AuthFailureEntry {
527
+ readonly kind: 'authorize' | 'csrf';
528
+ readonly status: number;
529
+ readonly method: string;
530
+ /** A fixed public endpoint or route category; never an arbitrary request pathname. */
531
+ readonly path: string;
532
+ readonly sessionCookie: boolean;
533
+ readonly csrfHeader: boolean;
534
+ /** Number of occurrences of the two actual CSRF cookie names, including empty values. */
535
+ readonly csrfCookies: number;
536
+ readonly origin?: string;
537
+ readonly site?: 'same-origin' | 'same-site' | 'cross-site' | 'none';
538
+ readonly device?: string;
539
+ /** Earlier failures of this kind suppressed since its preceding recorded request. */
540
+ readonly suppressed?: number;
541
+ }
542
+ //#endregion
519
543
  //#region src/http-security.d.ts
520
544
  export declare const DEVICE_COOKIE = "dsh_ma_device";
521
545
  export declare const SESSION_COOKIE = "dsh_ma_session";
@@ -967,15 +991,20 @@ export declare class MobileAccessGateway {
967
991
  private closeTask;
968
992
  private readonly removeSessionListener;
969
993
  private readonly removeExtensionContentListener;
970
- private readonly renewLimiter;
971
- private readonly probeLimiter;
994
+ private readonly renewFailureLimiter;
995
+ private readonly renewDeviceLimiter;
996
+ private readonly renewInFlight;
997
+ private readonly probeFailureLimiter;
998
+ private readonly probeDeviceLimiter;
999
+ private readonly probeInFlight;
972
1000
  private readonly clientModulePreferences;
973
1001
  private readonly clientModuleOperations;
974
1002
  private readonly clientModuleTasks;
975
1003
  private readonly clientModuleRevocations;
1004
+ private readonly authFailures;
976
1005
  constructor(config: ResolvedGatewayConfig, store: DeviceStore, extensions?: MobileAccessService | undefined, upstreamAuthenticatedUrl?: string | undefined, extraWebSocketPaths?: {
977
1006
  has(pathname: string): boolean;
978
- } | undefined, blockedUpgradeLog?: BlockedUpgradePathLog | undefined, onDiscoveryDegraded?: ((source: 'broadcast' | 'mdns', code: string) => void) | undefined, clientModulePreferences?: ClientModulePreferenceStore);
1007
+ } | undefined, blockedUpgradeLog?: BlockedUpgradePathLog | undefined, onDiscoveryDegraded?: ((source: 'broadcast' | 'mdns', code: string) => void) | undefined, clientModulePreferences?: ClientModulePreferenceStore, authFailureLog?: (entry: AuthFailureEntry) => void);
979
1008
  /** Initialize durable state, validate TLS, and bind the externally reachable listener. */
980
1009
  start(): Promise<void>;
981
1010
  /** Install a newly signed provided leaf for future TLS handshakes without dropping sessions. */
@@ -1012,6 +1041,8 @@ export declare class MobileAccessGateway {
1012
1041
  private requireCsrf;
1013
1042
  private setSessionCookies;
1014
1043
  private setBrowserDeviceBinding;
1044
+ /** Separate malformed or invalid requests from device-authenticated work without trusting forwarded addresses. */
1045
+ private withDeviceRequest;
1015
1046
  private handlePair;
1016
1047
  private handleRenew;
1017
1048
  /** CA-backed entries retain their pin; public entries project the authenticated credential's identity. */