dsh-auth-remote 0.3.1 → 0.3.2
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 +12 -1
- package/CHANGELOG.zh-CN.md +12 -1
- package/CONTRIBUTING.md +1 -1
- package/CONTRIBUTING.zh-CN.md +1 -1
- package/README.md +26 -18
- package/README.zh-CN.md +26 -18
- package/dist/cli.js +63 -530
- package/dist/cli.js.map +4 -4
- package/dist/client.js +915 -133
- package/dist/client.js.map +3 -3
- package/dist/index.js +83 -22
- package/dist/index.js.map +3 -3
- package/dist/login.css +0 -21
- package/dist/login.css.map +2 -2
- package/dist/login.js +892 -155
- package/dist/login.js.map +3 -3
- package/dist/types/adapters/dsh/browser-capability.d.ts.map +1 -1
- package/dist/types/adapters/dsh/liveshare.d.ts +4 -0
- package/dist/types/adapters/dsh/liveshare.d.ts.map +1 -0
- package/dist/types/adapters/dsh/webserver.d.ts +8 -4
- package/dist/types/adapters/dsh/webserver.d.ts.map +1 -1
- package/dist/types/cli/ipc-client.d.ts.map +1 -1
- package/dist/types/cli/messages.d.ts +56 -0
- package/dist/types/cli/messages.d.ts.map +1 -0
- package/dist/types/cli/profile.d.ts.map +1 -1
- package/dist/types/cli/prompt.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/shared/i18n.d.ts +878 -105
- package/dist/types/shared/i18n.d.ts.map +1 -1
- package/dist/types/shared/locales/de.d.ts +145 -0
- package/dist/types/shared/locales/de.d.ts.map +1 -0
- package/dist/types/shared/locales/en.d.ts +0 -49
- package/dist/types/shared/locales/en.d.ts.map +1 -1
- package/dist/types/shared/locales/es.d.ts +145 -0
- package/dist/types/shared/locales/es.d.ts.map +1 -0
- package/dist/types/shared/locales/fr.d.ts +145 -0
- package/dist/types/shared/locales/fr.d.ts.map +1 -0
- package/dist/types/shared/locales/ja.d.ts +145 -0
- package/dist/types/shared/locales/ja.d.ts.map +1 -0
- package/dist/types/shared/locales/pt.d.ts +145 -0
- package/dist/types/shared/locales/pt.d.ts.map +1 -0
- package/dist/types/shared/locales/ru.d.ts +145 -0
- package/dist/types/shared/locales/ru.d.ts.map +1 -0
- package/dist/types/shared/locales/zh.d.ts +0 -49
- package/dist/types/shared/locales/zh.d.ts.map +1 -1
- package/docs/deployment.md +19 -13
- package/docs/deployment.zh-CN.md +19 -13
- package/docs/development.md +39 -28
- package/docs/development.zh-CN.md +39 -28
- package/docs/legacy-compatibility.md +119 -67
- package/docs/legacy-compatibility.zh-CN.md +117 -65
- package/docs/releasing.md +11 -11
- package/docs/releasing.zh-CN.md +11 -11
- package/docs/support-history.md +49 -48
- package/docs/support-history.zh-CN.md +49 -48
- package/examples/web-profile-auth-remote.patch.yml +1 -1
- package/package.json +15 -14
- package/dist/types/cli/language.d.ts +0 -14
- package/dist/types/cli/language.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function packageManifest(packageName, anchor) {
|
|
|
17
17
|
const manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
18
18
|
if (manifest.name !== packageName || !semver.satisfies(manifest.version, SUPPORTED_DSH_RANGE, { includePrerelease: true })) {
|
|
19
19
|
throw new Error(
|
|
20
|
-
`auth-remote: unsupported ${packageName} version ${manifest.version}; minimum DSH 0.2.1-alpha.3. Upgrade to DSH 0.2.
|
|
20
|
+
`auth-remote: unsupported ${packageName} version ${manifest.version}; minimum DSH 0.2.1-alpha.3. Upgrade to DSH 0.2.2-alpha.2; last supported plugin for older DSH: 0.2.0. See README.md and docs/support-history.md.`
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
return { path, manifest };
|
|
@@ -77,10 +77,44 @@ function isActiveAccountLogin(phase) {
|
|
|
77
77
|
|
|
78
78
|
// src/adapters/dsh/browser-capability.ts
|
|
79
79
|
function installAuthenticatedHostCapability(ctx, version) {
|
|
80
|
-
ctx.on(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
ctx.on(
|
|
81
|
+
"webserver/index-inject",
|
|
82
|
+
(table, peer) => {
|
|
83
|
+
if (peer !== void 0 && peer?.principal?.kind !== "owner") return;
|
|
84
|
+
table.push({ kind: "global", name: "__DSH_TRANSPORT__", value: { ownsHost: true } });
|
|
85
|
+
if (version && supportsManualAccountLogin(version))
|
|
86
|
+
table.push({ kind: "global", name: ACCOUNT_LOGIN_CAPABILITY, value: true });
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/http/request-context.ts
|
|
92
|
+
var contexts = /* @__PURE__ */ new WeakMap();
|
|
93
|
+
function setRequestContext(req, context) {
|
|
94
|
+
if (contexts.has(req)) throw new Error("auth-remote: request context already set");
|
|
95
|
+
contexts.set(req, context);
|
|
96
|
+
}
|
|
97
|
+
function requireRequestContext(req) {
|
|
98
|
+
const context = contexts.get(req);
|
|
99
|
+
if (!context) throw new Error("auth-remote: missing validated request context");
|
|
100
|
+
return context;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/adapters/dsh/liveshare.ts
|
|
104
|
+
function installLiveShareOrigin(ctx) {
|
|
105
|
+
ctx.on("connection/request", async (req, _res, next) => {
|
|
106
|
+
const path = req.url?.split("?", 1)[0];
|
|
107
|
+
if (req.method !== "POST" || path !== "/api/liveshare.ownerLoginStart" && path !== "/api/liveshare.ownerLoginRedeem")
|
|
108
|
+
return next();
|
|
109
|
+
const trusted = requireRequestContext(req);
|
|
110
|
+
const original = req.headers.origin;
|
|
111
|
+
if (original === void 0) return next();
|
|
112
|
+
try {
|
|
113
|
+
req.headers.origin = trusted.origin;
|
|
114
|
+
await next();
|
|
115
|
+
} finally {
|
|
116
|
+
req.headers.origin = original;
|
|
117
|
+
}
|
|
84
118
|
});
|
|
85
119
|
}
|
|
86
120
|
|
|
@@ -460,7 +494,7 @@ function listenerPublicUrl(host, port, protocol) {
|
|
|
460
494
|
function assertRuntimeVersion(version) {
|
|
461
495
|
if (!semver2.satisfies(version, SUPPORTED_DSH_RANGE, { includePrerelease: true }))
|
|
462
496
|
throw new Error(
|
|
463
|
-
`auth-remote: unsupported DSH version ${version}; minimum DSH 0.2.1-alpha.3. Upgrade to DSH 0.2.
|
|
497
|
+
`auth-remote: unsupported DSH version ${version}; minimum DSH 0.2.1-alpha.3. Upgrade to DSH 0.2.2-alpha.2; last supported plugin for older DSH: 0.2.0. See README.md and docs/support-history.md.`
|
|
464
498
|
);
|
|
465
499
|
}
|
|
466
500
|
function validateListenerConfig(config, native = NativeWebServer) {
|
|
@@ -539,6 +573,7 @@ var GuardedWebServer = class extends WebServer2 {
|
|
|
539
573
|
constructor(ctx, config, gate = new DenyGate()) {
|
|
540
574
|
super(ctx, config);
|
|
541
575
|
this.gate = gate;
|
|
576
|
+
this.resourceBoundaryInstalled = this.installResourceBoundary();
|
|
542
577
|
this.originPolicy = config.originPolicy;
|
|
543
578
|
super.register({
|
|
544
579
|
kind: "exact",
|
|
@@ -581,6 +616,35 @@ var GuardedWebServer = class extends WebServer2 {
|
|
|
581
616
|
gate;
|
|
582
617
|
originPolicy;
|
|
583
618
|
accountCallbackBridge;
|
|
619
|
+
resourceBoundaryInstalled;
|
|
620
|
+
/** DSH-RESOURCE-001: private native boundary; never replace its routing or stream bridge. */
|
|
621
|
+
installResourceBoundary() {
|
|
622
|
+
const native = Reflect.get(this, "serveResource");
|
|
623
|
+
if (typeof native !== "function") {
|
|
624
|
+
if (typeof Reflect.get(this, "readResource") === "function") {
|
|
625
|
+
throw new Error(
|
|
626
|
+
"auth-remote: WebServer resource HTTP boundary serveResource is unavailable"
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
const serve = native;
|
|
632
|
+
Object.defineProperty(this, "serveResource", {
|
|
633
|
+
value: (req, res, _target, resource) => this.gate.http(
|
|
634
|
+
req,
|
|
635
|
+
res,
|
|
636
|
+
() => serve.call(this, req, res, new URL(req.url ?? "/", "http://x"), resource)
|
|
637
|
+
)
|
|
638
|
+
});
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
requireResourceBoundary() {
|
|
642
|
+
if (!this.resourceBoundaryInstalled) {
|
|
643
|
+
throw new Error(
|
|
644
|
+
"auth-remote: WebServer resource registration requires a guarded serveResource"
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
584
648
|
/** Ready and the authenticated gate consume the same listener-finalized policy. */
|
|
585
649
|
setOriginPolicy(policy) {
|
|
586
650
|
this.originPolicy = policy;
|
|
@@ -589,6 +653,10 @@ var GuardedWebServer = class extends WebServer2 {
|
|
|
589
653
|
this.accountCallbackBridge = bridge;
|
|
590
654
|
}
|
|
591
655
|
register(route) {
|
|
656
|
+
if ("resource" in route) {
|
|
657
|
+
this.requireResourceBoundary();
|
|
658
|
+
return super.register(route);
|
|
659
|
+
}
|
|
592
660
|
const callback = this.accountCallbackBridge?.capture(route);
|
|
593
661
|
const handler = callback?.handler ?? route.handler;
|
|
594
662
|
try {
|
|
@@ -605,9 +673,13 @@ var GuardedWebServer = class extends WebServer2 {
|
|
|
605
673
|
throw error;
|
|
606
674
|
}
|
|
607
675
|
}
|
|
608
|
-
registerFallback(
|
|
676
|
+
registerFallback(fallback) {
|
|
677
|
+
if (typeof fallback !== "function") {
|
|
678
|
+
this.requireResourceBoundary();
|
|
679
|
+
return super.registerFallback(fallback);
|
|
680
|
+
}
|
|
609
681
|
return super.registerFallback(
|
|
610
|
-
(req, res) => this.gate.http(req, res, () => Promise.resolve(
|
|
682
|
+
(req, res) => this.gate.http(req, res, () => Promise.resolve(fallback(req, res)))
|
|
611
683
|
);
|
|
612
684
|
}
|
|
613
685
|
registerUpgrade(route) {
|
|
@@ -2053,18 +2125,6 @@ function stripRootToken(req) {
|
|
|
2053
2125
|
req.url = url.pathname + url.search + url.hash;
|
|
2054
2126
|
}
|
|
2055
2127
|
|
|
2056
|
-
// src/http/request-context.ts
|
|
2057
|
-
var contexts = /* @__PURE__ */ new WeakMap();
|
|
2058
|
-
function setRequestContext(req, context) {
|
|
2059
|
-
if (contexts.has(req)) throw new Error("auth-remote: request context already set");
|
|
2060
|
-
contexts.set(req, context);
|
|
2061
|
-
}
|
|
2062
|
-
function requireRequestContext(req) {
|
|
2063
|
-
const context = contexts.get(req);
|
|
2064
|
-
if (!context) throw new Error("auth-remote: missing validated request context");
|
|
2065
|
-
return context;
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
2128
|
// src/http/routes.ts
|
|
2069
2129
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2070
2130
|
var policies = {
|
|
@@ -2899,7 +2959,7 @@ function legacy(version, windowDays, eligibleRetirement) {
|
|
|
2899
2959
|
legacySince: "2026-10-28",
|
|
2900
2960
|
windowDays,
|
|
2901
2961
|
eligibleRetirement,
|
|
2902
|
-
migrationTarget: "0.2.
|
|
2962
|
+
migrationTarget: "0.2.2-alpha.2"
|
|
2903
2963
|
};
|
|
2904
2964
|
}
|
|
2905
2965
|
var LEGACY_DSH_RELEASES = [
|
|
@@ -2920,7 +2980,7 @@ var RETIRED_DSH_RELEASES = [
|
|
|
2920
2980
|
retiredOn: "2026-10-28",
|
|
2921
2981
|
effectivePlugin: "0.3.1",
|
|
2922
2982
|
lastSupportedPlugin: "0.2.0",
|
|
2923
|
-
migrationTarget: "0.2.
|
|
2983
|
+
migrationTarget: "0.2.2-alpha.2"
|
|
2924
2984
|
}));
|
|
2925
2985
|
var lifecycle = [...LEGACY_DSH_RELEASES, ...RETIRED_DSH_RELEASES];
|
|
2926
2986
|
function classifyDshSupport(version, declared, records = lifecycle) {
|
|
@@ -3003,6 +3063,7 @@ var AuthRemoteWebServer = class extends GuardedWebServer {
|
|
|
3003
3063
|
this.switchGate = gate;
|
|
3004
3064
|
warnDshSupport(classifyDshSupport(config.version, declaredDshReleases));
|
|
3005
3065
|
installAuthenticatedHostCapability(ctx, config.version);
|
|
3066
|
+
installLiveShareOrigin(ctx);
|
|
3006
3067
|
if (config.legacyWarning)
|
|
3007
3068
|
console.warn("auth-remote: allowedOrigins is deprecated; use publicUrl with one root URL");
|
|
3008
3069
|
}
|