@iasiv5/dsh-skip-browser-auth 0.3.12 → 0.4.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.
@@ -67,6 +67,15 @@ export const COMPATIBILITY_PROFILES = [
67
67
  // a ModuleLoader chunk-hash rename whose 34 changed lines all sit in that CLI
68
68
  // area with resolveSync usage line-identical. rc17 keeps anchoring at
69
69
  // 0.1.7-rc.2; no second 0.2.x-line build input is introduced.
70
+ //
71
+ // 0.2.1-rc.1 does NOT join this generation (§5.8): unlike every rc.2-style
72
+ // republish it is a real contract change on the replacement face —
73
+ // OperatorPeer reworked into per-request Peer instances with principals,
74
+ // the shared-route bridge threading admission.peer into fetch, a new
75
+ // /connect exact channel (authorizeConnect), the client bundle split into
76
+ // browser/node entries, and the official patch's connection row moving
77
+ // from the webRuntime to the webStartup service. It therefore starts the
78
+ // carrier-neutral-v4 generation below (docs/COMPATIBILITY.md §5.2/§5.9).
70
79
  id: 'carrier-neutral-v3',
71
80
  pairs: [
72
81
  { runtime: '0.1.7-rc.1', connection: '0.1.7-rc.1' },
@@ -84,7 +93,37 @@ export const COMPATIBILITY_PROFILES = [
84
93
  // promotion evidence (docs/COMPATIBILITY.md §5.4, docs/DESIGN.md).
85
94
  status: 'active',
86
95
  },
96
+ {
97
+ // 0.2.1-rc.1 starts its own generation (§5.8 audit → §5.2 new generation):
98
+ // the official apply wiring it must replicate is admit() → waterfall →
99
+ // bridge(req, res, fetchHandler, admission.peer, maxRequestBodyBytes) plus
100
+ // the new exact /connect route (connection.authorizeConnect). The
101
+ // HostConnectionService constructor (ctx, trustedHosts, browserAuth) is
102
+ // unchanged, but the patch row serving this generation reads trustedHosts
103
+ // from the webStartup service (webRuntime is gone upstream; the official
104
+ // 0.2.1 patch row made the same move and narrows trustedHosts to the
105
+ // explicit invocation authorities). The rc21 client variant anchors at the
106
+ // official browser entry lib/client.browser.js of 0.2.1-rc.1 — no other
107
+ // generation shares this build input.
108
+ id: 'carrier-neutral-v4',
109
+ pairs: [
110
+ { runtime: '0.2.1-rc.1', connection: '0.2.1-rc.1' },
111
+ ],
112
+ hostAdapter: 'carrier-neutral-021',
113
+ clientVariant: 'rc21',
114
+ requiresRecoveryGlobal: true,
115
+ browserAuthSemantics: 'mount-preserving',
116
+ hostProfiles: ['web'],
117
+ status: 'active',
118
+ },
87
119
  ];
120
+ /**
121
+ * The §5.9 generation id: the only profile whose bundle patch row injects the
122
+ * `webStartup` service (upstream renamed webRuntime → webStartup in 0.2.1).
123
+ * The row-binding expressions in gate.ts partition the active profile ids by
124
+ * this constant so exactly one inserted row can activate per host generation.
125
+ */
126
+ export const CARRIER_NEUTRAL_V4_PROFILE_ID = 'carrier-neutral-v4';
88
127
  /** All exact versions represented by profiles, for diagnostics and fixtures. */
89
128
  export const GATE_VERSIONS = [...new Set(COMPATIBILITY_PROFILES.flatMap((profile) => profile.pairs.flatMap((pair) => [pair.runtime, pair.connection])))];
90
129
  /** Backward-compatible internal alias for the original 0.1.2 build/test pin. */
package/lib/gate.js CHANGED
@@ -66,7 +66,7 @@
66
66
  * docs/COMPATIBILITY.md §7.4/§7.6)。Node 侧镜像见 detectHostProfile;
67
67
  * 语义、事故记录与解冻条件见 docs/COMPATIBILITY.md §7。
68
68
  */
69
- import { ACTIVE_COMPATIBILITY_PROFILE_IDS, GATE_PROFILE_TABLE, } from './compatibility.js';
69
+ import { ACTIVE_COMPATIBILITY_PROFILE_IDS, CARRIER_NEUTRAL_V4_PROFILE_ID, GATE_PROFILE_TABLE, } from './compatibility.js';
70
70
  export { ACTIVE_COMPATIBILITY_PROFILE_IDS, COMPATIBILITY_PROFILES, GATE_VERSION, GATE_VERSIONS, isActiveCompatibilityProfileId, resolveActiveCompatibilityProfile, resolveCompatibilityProfile, } from './compatibility.js';
71
71
  export const CONNECTION_PACKAGE = '@deepseek-ai/dsh-client-connection';
72
72
  /** 宿主 runtime 本体包:探针的第一锚点,版本即宿主 dsh 版本。 */
@@ -99,10 +99,22 @@ export const GATE_PROFILE_EXPRESSION = `(() => { try { const internal = ctx.load
99
99
  // A known candidate profile remains dormant until its host/client adapter is
100
100
  // promoted, while the profile expression still exposes its exact pair id.
101
101
  export const GATE_PROBE_EXPRESSION = `(() => { try { const profile = (${GATE_PROFILE_EXPRESSION}); return profile !== null && ${JSON.stringify(ACTIVE_COMPATIBILITY_PROFILE_IDS)}.includes(profile); } catch (gateError) { return false; } })()`;
102
- // 行绑定放行:自身探针为真 + 同组 sibling 存在且名字匹配且其 effective disabled 为真。
102
+ // 行绑定放行表达式源(0.4.0 起按代际拆分):自身探针解析出的 profile 落在
103
+ // allowedProfileIds 内 + 同组 sibling 存在且名字匹配且其 effective disabled 为真。
103
104
  // sibling 必须从当前 entry(Symbol.for('cordis.entry'))所属子树解析,
104
105
  // 根 Loader 的 resolve 看不到 Include 子树内的行。
105
- export const GATE_ROW_ALLOWED_EXPRESSION = `(() => { try { const self = ctx[Symbol.for('cordis.entry')]; if (!self || !self.parent || !self.parent.tree) return false; const official = self.parent.tree.resolve('connection'); if (!official || official.parent !== self.parent) return false; if (official.options.id !== 'connection' || official.options.name !== '${CONNECTION_PACKAGE}') return false; const probeAllowed = (${GATE_PROBE_EXPRESSION}); if (probeAllowed !== true) return false; return official.disabled === true; } catch (gateError) { return false; } })()`;
106
+ //
107
+ // 为什么按代际拆分(§5.9):bundle patch 现在插入两行(webRuntime 行服务
108
+ // ≤0.2.0 代际、webStartup 行服务 0.2.1+ 代际),两个 id 集合必须互斥——否则
109
+ // 新代际宿主上旧行也会放行(其 inject 的 webRuntime 服务在上游已不存在)。
110
+ // 两个集合由 compatibility.ts 单表派生,不会漂移。
111
+ function rowAllowedExpressionSource(allowedProfileIds) {
112
+ return `(() => { try { const self = ctx[Symbol.for('cordis.entry')]; if (!self || !self.parent || !self.parent.tree) return false; const official = self.parent.tree.resolve('connection'); if (!official || official.parent !== self.parent) return false; if (official.options.id !== 'connection' || official.options.name !== '${CONNECTION_PACKAGE}') return false; const profile = (${GATE_PROFILE_EXPRESSION}); if (profile === null || !${JSON.stringify(allowedProfileIds)}.includes(profile)) return false; return official.disabled === true; } catch (gateError) { return false; } })()`;
113
+ }
114
+ /** ≤0.2.0 代际的行绑定(webRuntime 行):active 集合排除 v4。 */
115
+ export const GATE_ROW_ALLOWED_EXPRESSION = rowAllowedExpressionSource(ACTIVE_COMPATIBILITY_PROFILE_IDS.filter((id) => id !== CARRIER_NEUTRAL_V4_PROFILE_ID));
116
+ /** 0.2.1+ 代际(carrier-neutral-v4)的行绑定(webStartup 行):仅 v4。 */
117
+ export const GATE_ROW_ALLOWED_EXPRESSION_V4 = rowAllowedExpressionSource([CARRIER_NEUTRAL_V4_PROFILE_ID]);
106
118
  /**
107
119
  * Evaluate the activation probe against a loader context scope.
108
120
  * @param ctx - the `!!js` evaluation scope (same object the Loader passes).
package/lib/host.js CHANGED
@@ -2,7 +2,8 @@
2
2
  * @iasiv5/dsh-skip-browser-auth host half:trusted-network Connection Replacement。
3
3
  *
4
4
  * 兼容性按 profile 分代:0.1.2 使用 legacy-web adapter,0.1.5 使用
5
- * carrier-neutral adapter,0.1.7 使用 carrier-neutral-017 adapter。公共 apply
5
+ * carrier-neutral adapter,0.1.7–0.2.0 使用 carrier-neutral-017 adapter,
6
+ * 0.2.1 起使用 carrier-neutral-021 adapter。公共 apply
6
7
  * 只负责 profile/backstop、信任配置、生命周期和固定 warning;版本差异藏在
7
8
  * adapter 与 runtime connection loader。
8
9
  */
@@ -15,6 +16,7 @@ import { loadRuntimeConnectionModule } from './connection-runtime.js';
15
16
  import { createLegacyWebRuntime } from './adapters/legacy-web.js';
16
17
  import { createCarrierNeutralRuntime } from './adapters/carrier-neutral.js';
17
18
  import { createCarrierNeutral017Runtime } from './adapters/carrier-neutral-017.js';
19
+ import { createCarrierNeutral021Runtime } from './adapters/carrier-neutral-021.js';
18
20
  import { assertTrustedAuthority } from './trust-fence.js';
19
21
  import { createTrustedAuth } from './trusted-auth.js';
20
22
  import { DEFAULT_MAX_REQUEST_BODY_BYTES } from './bridge.js';
@@ -162,6 +164,8 @@ function createHostRuntime(profile, input) {
162
164
  return createCarrierNeutralRuntime(input);
163
165
  case 'carrier-neutral-017':
164
166
  return createCarrierNeutral017Runtime(input);
167
+ case 'carrier-neutral-021':
168
+ return createCarrierNeutral021Runtime(input);
165
169
  default:
166
170
  throw new Error('@iasiv5/dsh-skip-browser-auth: unsupported host adapter');
167
171
  }
@@ -202,6 +206,10 @@ export async function apply(ctx, config) {
202
206
  profileId: profile.id,
203
207
  });
204
208
  ctx.effect(() => ctx.webServer.register(runtime.route), `@iasiv5/dsh-skip-browser-auth: ${runtime.adapterId} ${runtime.route.path} route`);
209
+ // 代际附加路由(官方 apply 注册顺序照抄):0.2.1 的 /connect exact 通道。
210
+ for (const additionalRoute of runtime.additionalRoutes ?? []) {
211
+ ctx.effect(() => ctx.webServer.register(additionalRoute), `@iasiv5/dsh-skip-browser-auth: ${runtime.adapterId} ${additionalRoute.path} route`);
212
+ }
205
213
  installBrowserGlobals(ctx, profile);
206
214
  ctx.inject(['attachments'], (attachmentCtx) => {
207
215
  assertImageBodyCapacity(attachmentCtx, maxRequestBodyBytes);
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Trusted-network replacement for the official BrowserAuth stub.
3
3
  *
4
- * 官方 HostConnectionService 对认证的全部依赖只有三个方法:
5
- * isAuthenticated / authorizeIndex / authenticatedUrl。本模块以
6
- * trusted-network 语义提供三方法 stub:请求信任栅栏(Host/Origin/
4
+ * 官方 HostConnectionService 对认证的全部依赖(0.2.1 起)只有四个方法:
5
+ * isAuthenticated / authorizeIndex / authenticatedUrl / authorizeConnect。
6
+ * 本模块以 trusted-network 语义提供四方法 stub:请求信任栅栏(Host/Origin/
7
7
  * Fetch Metadata/trustedHosts)承担全部访问判定,身份层不存在。
8
8
  * 首页 fence 与 /api fence 消费同一个 trustedHosts 列表。
9
9
  */
@@ -62,5 +62,34 @@ export function createTrustedAuth(trustedHosts, semantics = 'root') {
62
62
  url.hash = '';
63
63
  return url.href;
64
64
  },
65
+ // 0.2.1 /connect 交换(trusted-network 语义):
66
+ // - interactions 声明校验逐字对齐官方(客户端协议契约,400 兜底);
67
+ // - 官方成功路径 = mint operator cookie + 302 ./api/remote.mux;本 stub
68
+ // 省略 cookie 与 operator 记录(无身份可铸造;publish 不调用,避免
69
+ // 生成无 cookie 引用的孤儿 operator 台账),其余响应形态逐字对齐。
70
+ // 后续 /api 请求由 admit() 恒准为 owner-principal browserPeer,mux
71
+ // 连接不依赖该 cookie。
72
+ // - 服务层已在 authorizeConnect 入口做过 isTrusted(evil host ⇒ 403,
73
+ // 不达本 stub);身份/token 校验路径在本模式恒通过(isAuthenticated
74
+ // 恒真),token 缺失不再 401。
75
+ authorizeConnect(req, res, _secure, _publish) {
76
+ const url = new URL(req.url ?? '/', 'http://dsh.invalid');
77
+ const declarations = url.searchParams.getAll('interactions');
78
+ const interactions = declarations[0] ?? 'none';
79
+ if (declarations.length > 1 || (interactions !== 'answer' && interactions !== 'none')) {
80
+ res.writeHead(400, {
81
+ 'cache-control': 'no-store',
82
+ 'content-type': 'text/plain; charset=utf-8',
83
+ });
84
+ res.end('interactions must be declared once as answer or none\n');
85
+ return;
86
+ }
87
+ res.writeHead(302, {
88
+ 'cache-control': 'no-store',
89
+ 'location': './api/remote.mux',
90
+ 'referrer-policy': 'no-referrer',
91
+ });
92
+ res.end();
93
+ },
65
94
  };
66
95
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iasiv5/dsh-skip-browser-auth",
3
- "version": "0.3.12",
4
- "description": "替换官方 Connection 提供方跳过 BrowserAuth,免输 Token;已适配 0.1.2-rc.1、0.1.5-rc.1/rc.2、0.1.7-rc.1/rc.2 与 0.2.0-rc.1/rc.2,详见仓库。仅支持 web(宿主二进制须为 node);desktop 宿主一律自动休眠(多进程树判别:安装槽位/启动器 argv/宿主二进制),属设计行为。",
3
+ "version": "0.4.0",
4
+ "description": "替换官方 Connection 提供方跳过 BrowserAuth,免输 Token;已适配 0.1.2-rc.1、0.1.5-rc.1/rc.2、0.1.7-rc.1/rc.2、0.2.0-rc.1/rc.2 与 0.2.1-rc.1,详见仓库。仅支持 web(宿主二进制须为 node);desktop 宿主一律自动休眠(多进程树判别:安装槽位/启动器 argv/宿主二进制),属设计行为。",
5
5
  "keywords": [
6
6
  "dsh",
7
7
  "deepseek-harness",
@@ -68,6 +68,7 @@
68
68
  "@deepseek-ai/dsh-client-connection": "0.1.2-rc.1",
69
69
  "dsh-client-connection-rc15": "npm:@deepseek-ai/dsh-client-connection@0.1.5-rc.1",
70
70
  "dsh-client-connection-rc17": "npm:@deepseek-ai/dsh-client-connection@0.1.7-rc.2",
71
+ "dsh-client-connection-rc21": "npm:@deepseek-ai/dsh-client-connection@0.2.1-rc.1",
71
72
  "@deepseek-ai/dsh-credentials": "0.1.2-rc.1",
72
73
  "@deepseek-ai/dsh-credentials-local": "0.1.2-rc.1",
73
74
  "@deepseek-ai/dsh-home-paths": "0.1.2-rc.1",