refactor(connection): add connection auth provider for remote connection (#8266)
* refactor(connection): extract peer authentication providers * test(connection): cover provider lifecycle and satisfy package gates * fix(packaging): publish authentication provider locale resources * test(auth): use runtime login output and cover gateway admission * fix(auth): preserve Worker requests and migrate Desktop fixtures * refactor(auth): centralize route admission with required policy * fix(release): align authentication providers with rc.2 * refactor(connection): keep peer lookup and source policy private * test(gateway): cover centralized upgrade rejections * fix(ci): authenticate homepage compression probe * refactor(auth): let Token own API socket lifecycle * fix(auth): prevent caching admission refusals and clarify ownership * refactor(web): collect provider entry URLs after readiness * refactor(webserver): name the shared entry URL event * refactor(connection): provide authentication as a nested service * fix(web-app): restore startup publication defaults * fix(auth): scope web events and preserve callback flows * docs(auth): record the implemented provider architecture * fix(auth): require owner access for administrative routes
This commit is contained in:
1 parent
98606fa09b
commit
71753fdf91
188 files changed
+6448
-1886
No files matched your search
@@ -72,7 +72,8 @@ export function contextKeyMap(body: ts.ModuleBlock, sf: ts.SourceFile): Map<stri
|
||||
if (!ts.isInterfaceDeclaration(stmt) || stmt.name.text !== 'Context') continue
|
||||
for (const member of stmt.members) {
|
||||
if (!ts.isPropertySignature(member) || !member.type) continue
|
||||
keyToType.set(member.name.getText(sf), member.type.getText(sf))
|
||||
const key = ts.isStringLiteral(member.name) || ts.isIdentifier(member.name) ? member.name.text : member.name.getText(sf)
|
||||
keyToType.set(key, member.type.getText(sf))
|
||||
}
|
||||
}
|
||||
return keyToType
|
||||
|
||||
@@ -187,7 +187,7 @@ describe('cordis-walk scan reach', () => {
|
||||
expect(events).toEqual(['second/changed'])
|
||||
})
|
||||
|
||||
it('reads string-literal and identifier member names from an Events merge', () => {
|
||||
it('reads string-literal and identifier service and event names', () => {
|
||||
const sf = ts.createSourceFile('x.ts', [
|
||||
"declare module '@deepseek-ai/cordis' {",
|
||||
' interface Events {',
|
||||
@@ -196,6 +196,8 @@ describe('cordis-walk scan reach', () => {
|
||||
' }',
|
||||
' interface Context {',
|
||||
' thing: ThingService',
|
||||
" 'connection.authentication': AuthenticationService",
|
||||
' "connection.other": OtherService',
|
||||
' }',
|
||||
'}',
|
||||
'',
|
||||
@@ -206,6 +208,10 @@ describe('cordis-walk scan reach', () => {
|
||||
: null
|
||||
if (!body) throw new Error('fixture did not parse to a module block')
|
||||
expect(eventNameList(body, sf)).toEqual(['scope/list', 'plain'])
|
||||
expect([...contextKeyMap(body, sf)]).toEqual([['thing', 'ThingService']])
|
||||
expect([...contextKeyMap(body, sf)]).toEqual([
|
||||
['thing', 'ThingService'],
|
||||
['connection.authentication', 'AuthenticationService'],
|
||||
['connection.other', 'OtherService'],
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -59,6 +59,7 @@ export const SERVICE_PAGE: Record<string, string> = {
|
||||
productTelemetry: 'product-telemetry.md',
|
||||
productAnalytics: 'product-telemetry.md',
|
||||
connection: 'web-server.md',
|
||||
'connection.authentication': 'web-server.md',
|
||||
pluginManager: 'boot.md',
|
||||
actionCards: 'boot.md',
|
||||
pluginRecommendations: 'boot.md',
|
||||
@@ -313,6 +314,8 @@ export const EVENT_WALK_EXEMPTIONS: Record<string, string> = {
|
||||
* appear on more than one page.
|
||||
*/
|
||||
export const LINK_MAP: Readonly<Record<string, string>> = {
|
||||
AuthenticationProvider: '../../packages/client/connection/README.md#browser-authentication-and-request-trust',
|
||||
PeerId: 'typert.md',
|
||||
Principal: 'typert.md',
|
||||
PrincipalMap: 'typert.md',
|
||||
RemoteAccessResource: 'typert.md',
|
||||
@@ -947,6 +950,12 @@ export const LINK_MAP: Readonly<Record<string, string>> = {
|
||||
PermissionCatalog: 'permission-presets.md',
|
||||
PresetOption: 'permission-presets.md',
|
||||
PresetSpec: 'permission-presets.md',
|
||||
WebEntryUrl: 'web-server.md',
|
||||
WebAdmission: 'web-server.md',
|
||||
WebAuthPolicy: 'web-server.md',
|
||||
WebAuthRequest: 'web-server.md',
|
||||
WebAuthenticationRule: 'web-server.md',
|
||||
WebFallback: 'web-server.md',
|
||||
WebRoute: 'web-server.md',
|
||||
WebResourceRoute: 'web-server.md',
|
||||
IndexInjection: 'web-server.md',
|
||||
@@ -1008,6 +1017,7 @@ export const FOUNDATION_TYPE_NAMES: ReadonlySet<string> = new Set([
|
||||
'Plugin',
|
||||
'AbortSignal',
|
||||
'Headers',
|
||||
'URL',
|
||||
'AsyncIterable',
|
||||
'Context',
|
||||
'Error',
|
||||
@@ -1028,6 +1038,8 @@ export const FOUNDATION_TYPE_NAMES: ReadonlySet<string> = new Set([
|
||||
'ReadonlySet',
|
||||
'Request',
|
||||
'Response',
|
||||
'Buffer',
|
||||
'Duplex',
|
||||
'IncomingMessage',
|
||||
'ServerResponse',
|
||||
'ReturnType',
|
||||
@@ -1043,18 +1055,14 @@ export const TYPE_LINK_EXEMPTIONS: Readonly<Record<string, string>> = {
|
||||
RecommendationDetails: 'packages/experimental/plugin-recommendations/README.md',
|
||||
ProductEvent: 'Desktop event fields are owned by packages/client/product-analytics/README.md and src/events.ts',
|
||||
ConnectionFetchHandler: 'shared Fetch dispatch is owned by packages/client/connection/src/rpc.ts',
|
||||
ConnectionRequestRejection: 'transport rejection status is owned by packages/client/connection/src/rpc.ts',
|
||||
ConnectionTrustRequest: 'transport authentication input is owned by packages/client/connection/src/rpc.ts',
|
||||
PeerAdmission: 'Peer admission outcome is owned by packages/client/connection/src/rpc.ts',
|
||||
ConnectionAdmission: 'physical socket admission and release are owned by packages/client/connection/src/rpc.ts',
|
||||
PeerScope: 'Peer scope contract is owned by packages/typert/protocol/src/types.ts',
|
||||
RemoteAccessPolicy: 'access policy contract is owned by packages/api/remote-access/README.md',
|
||||
RemoteAccessRequest: 'Gateway decision requests are owned by packages/api/remote-access/README.md',
|
||||
RemoteAccessDecision: 'Gateway decisions are owned by packages/api/remote-access/README.md',
|
||||
RemoteAccessFrame: 'access snapshot frames are owned by packages/api/remote-access/README.md',
|
||||
RemoteAccessBaseline: 'access snapshot frames are owned by packages/api/remote-access/README.md',
|
||||
ConnectionIndexRequest: 'frontend authentication request is owned by packages/client/connection/src/rpc.ts',
|
||||
ConnectionIndexResponse: 'frontend authentication response is owned by packages/client/connection/src/rpc.ts',
|
||||
Profile: 'resolved profile layers are owned by packages/boot/app-boot/README.md',
|
||||
PatchOptions: 'Include patch entries are owned by vendor/include (vendored upstream)',
|
||||
McpResourceProvider: 'scoped resource provider is owned by packages/mcp/mcp-resources/README.md',
|
||||
|
||||
@@ -27,7 +27,15 @@ const FIXTURE: Record<string, string> = {
|
||||
},
|
||||
include: ['vendor/**/*.ts', 'packages/**/*.ts'],
|
||||
}),
|
||||
'vendor/cordis/src/context.ts': 'export class Context { private brand!: void }\n',
|
||||
'vendor/cordis/src/context.ts': [
|
||||
'export class Context {',
|
||||
' private brand!: void',
|
||||
' bail(...args: unknown[]): void {}',
|
||||
' on(...args: unknown[]): void {}',
|
||||
' once(...args: unknown[]): void {}',
|
||||
'}',
|
||||
'',
|
||||
].join('\n'),
|
||||
'vendor/cordis/src/events.ts': [
|
||||
'export class EventsService {',
|
||||
' dispatch(type: string, args: unknown[]): unknown[] { return [type, args] }',
|
||||
@@ -63,6 +71,28 @@ const FIXTURE: Record<string, string> = {
|
||||
'packages/fix/pkgc/src/helper.ts':
|
||||
"function scriptFire(args: [string]): void { void gEvents.dispatch('emit', args) }\n",
|
||||
'packages/fix/pkgc/src/caller.ts': "scriptFire(['pkgc/script-event'])\n",
|
||||
'packages/fix/bailtypes/src/receiver.ts': [
|
||||
"import { Context } from '../../../../vendor/cordis/src/context.ts'",
|
||||
'export declare const application: Context',
|
||||
"export declare const event: 'bail/union-a' | 'bail/union-b'",
|
||||
'',
|
||||
].join('\n'),
|
||||
'packages/fix/bailcalls/src/index.ts': [
|
||||
"import { application as receiver, event } from '../../bailtypes/src/receiver.ts'",
|
||||
"receiver.bail('bail/direct')",
|
||||
"receiver.bail({}, 'bail/scoped')",
|
||||
'receiver.bail(event)',
|
||||
"receiver.on('bail/direct', () => {})",
|
||||
"receiver.once('bail/scoped', () => {})",
|
||||
'declare const widened: string',
|
||||
'receiver.bail(widened)',
|
||||
'const ctx = { bail(...args: unknown[]): void {} }',
|
||||
"ctx.bail('bail/unrelated')",
|
||||
'// An untyped receiver cannot establish event API ownership.',
|
||||
'declare const untyped: any',
|
||||
"untyped.bail('bail/untyped')",
|
||||
'',
|
||||
].join('\n'),
|
||||
}
|
||||
|
||||
const root = mkdtempSync(join(tmpdir(), 'gen-doc-graphs-'))
|
||||
@@ -99,6 +129,34 @@ describe('event relation call-site indexing', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('type-aware bail dispatch', () => {
|
||||
function collectBailRelations() {
|
||||
return new EventRelationCollector(project, sources.filter(source => source.pkg === 'bailcalls')).collect()
|
||||
}
|
||||
|
||||
it.each(['bail/direct', 'bail/scoped', 'bail/union-a', 'bail/union-b'])(
|
||||
'records %s from an imported Context receiver as a bail dispatcher',
|
||||
(event) => {
|
||||
expect(collectBailRelations().get(event)?.dispatchers).toEqual(new Map([
|
||||
['bailcalls', new Set(['bail'])],
|
||||
]))
|
||||
},
|
||||
)
|
||||
|
||||
it('keeps on and once registrations as listeners', () => {
|
||||
const relations = collectBailRelations()
|
||||
expect(relations.get('bail/direct')?.listeners).toEqual(new Set(['bailcalls']))
|
||||
expect(relations.get('bail/scoped')?.listeners).toEqual(new Set(['bailcalls']))
|
||||
expect(relations.get('bail/union-a')?.listeners.size).toBe(0)
|
||||
})
|
||||
|
||||
it('excludes unrelated and untyped receivers and widened event names', () => {
|
||||
expect([...collectBailRelations().keys()].sort()).toEqual([
|
||||
'bail/direct', 'bail/scoped', 'bail/union-a', 'bail/union-b',
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('memoized filesystem probes', () => {
|
||||
function countingSystem(): { system: ts.System; calls: string[] } {
|
||||
const calls: string[] = []
|
||||
|
||||
@@ -192,7 +192,16 @@ const SERVICE_ROLES: ServiceRole[] = [
|
||||
title: 'Authenticated browser transport',
|
||||
mode: 'core',
|
||||
consumers: ['api-gateway', 'host-frontend-static'],
|
||||
note: 'Owns browser authentication and shared HTTP request dispatch; API adapters register endpoints and streams.',
|
||||
note: 'Applies source policy and shared HTTP request dispatch; credential verification belongs to ConnectionAuthentication, and API adapters register endpoints and streams.',
|
||||
},
|
||||
{
|
||||
key: 'connection.authentication',
|
||||
pkg: 'client-connection',
|
||||
title: 'Connection authentication provider registry',
|
||||
mode: 'seam',
|
||||
implementations: ['host-authentication-token', 'host-authentication-desktop'],
|
||||
consumers: ['client-connection'],
|
||||
note: 'Tries scope-owned credential verifiers in registration order and returns the first live Peer; transport source policy and business authorization stay with their consumers.',
|
||||
},
|
||||
{
|
||||
key: 'forge',
|
||||
@@ -1178,7 +1187,7 @@ type CallSiteIndex = Map<ts.SignatureDeclaration | ts.JSDocSignature, ts.CallExp
|
||||
* must appear here — the prefilter drops non-members before any branch runs,
|
||||
* so a branch for an unlisted name is silently dead.
|
||||
*/
|
||||
const EVENT_API_METHODS = new Set(['on', 'once', 'emit', 'parallel', 'serial', 'waterfall', 'dispatch'])
|
||||
const EVENT_API_METHODS = new Set(['on', 'once', 'emit', 'parallel', 'serial', 'bail', 'waterfall', 'dispatch'])
|
||||
|
||||
/**
|
||||
* Collect event dispatch/listener relations from real cross-file receiver types.
|
||||
@@ -1336,7 +1345,7 @@ export class EventRelationCollector {
|
||||
const eventNames = this.eventNamesFromCall(node, receiverKind)
|
||||
if (method === 'on' || method === 'once') {
|
||||
for (const event of eventNames) this.ensure(event).listeners.add(source.pkg)
|
||||
} else if (method === 'emit' || method === 'parallel' || method === 'serial' || method === 'waterfall') {
|
||||
} else if (method === 'emit' || method === 'parallel' || method === 'serial' || method === 'bail' || method === 'waterfall') {
|
||||
for (const event of eventNames) this.addDispatcher(event, source.pkg, method)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,9 +340,6 @@
|
||||
"packages/bundle/headless/tests/startup.spec.ts": {
|
||||
"2e78263d16d54ccfd8d322bcdf1bf738bd8134e15c24063ece9a1d1b52f4ebd9": 1
|
||||
},
|
||||
"packages/bundle/web-app/tests/browser-open.spec.ts": {
|
||||
"2e78263d16d54ccfd8d322bcdf1bf738bd8134e15c24063ece9a1d1b52f4ebd9": 1
|
||||
},
|
||||
"packages/bundle/web-app/tests/document-conversion.e2e.ts": {
|
||||
"95057a87f4a7358284982d7c73febfe26aed9f37a4ceb5b8df724f2b6bc1084c": 1
|
||||
},
|
||||
@@ -358,9 +355,6 @@
|
||||
"e19d423d382674b8b4611741351c82f91680ea99c1b5423045df49d8be15855c": 1,
|
||||
"fdc5fcade0ba1abbc426ccccb07a1ad4998253799b8561815047d95178441cdf": 1
|
||||
},
|
||||
"packages/client/connection/tests/browser-auth.host.spec.ts": {
|
||||
"d7dc9c349af8699fefcaffed26377443dd73ef95f1dc985f4de542ec133869f5": 1
|
||||
},
|
||||
"packages/client/connection/tests/browser-credentials.ts": {
|
||||
"df59c4c68576e18a532f9a917fb70176726a28c8600e8909501e42b990e12857": 1
|
||||
},
|
||||
|
||||
@@ -52,7 +52,6 @@ const DUPLICATE_SAFE_PACKAGES: readonly string[] = [
|
||||
*/
|
||||
const SAFE_HOST_DEPENDENCY_EXPORTS = {
|
||||
'@deepseek-ai/dsh-atomic-write': ['withFileLock', 'writeFileAtomic'],
|
||||
'@deepseek-ai/dsh-credentials': ['credentialKey'],
|
||||
'@deepseek-ai/dsh-deque': ['Deque'],
|
||||
// Builds a dispatcher from the resolved proxy policy; the caller owns and closes it.
|
||||
'@deepseek-ai/dsh-http-proxy': ['createRouteDispatcher'],
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface ProductPackagePolicy {
|
||||
* Optional integrations may be reached by an optional bundle without becoming default capabilities.
|
||||
*/
|
||||
export const PRODUCT_PACKAGE_POLICY: Readonly<Record<string, ProductPackagePolicy>> = {
|
||||
'packages/host/authentication-desktop': { category: 'optional', reason: 'Mounted by the private Desktop Host with its parent-process credential, outside default Web profiles.' },
|
||||
'packages/core/agent-tool-presentation': { category: 'optional', reason: 'Deprecated selector retained for existing executor configurations.' },
|
||||
'packages/browser-use/browser-use': { category: 'optional', reason: 'Service definition used by explicitly selected browser providers.' },
|
||||
'packages/computer-use/computer-use': { category: 'optional', reason: 'Service definition used by explicitly selected computer providers.' },
|
||||
|
||||
@@ -69,6 +69,8 @@ const SENTENCE_MODEL_EXPERIENCE: Readonly<Record<string, SentenceContract>> = {
|
||||
'packages/experimental/voice-input-bundle': { kind: 'none', reason: 'Composes dictation and preparation plugins without adding any model-facing contribution.' },
|
||||
'packages/telemetry/otel': { kind: 'none', reason: 'The service delivers caller-selected records without changing model context.' },
|
||||
'packages/host/product-telemetry-otel': { kind: 'none', reason: 'The plugin exports explicit analytics records without contributing model context.' },
|
||||
'packages/host/authentication-token': { kind: 'none', reason: 'Launch-token exchange and Cookie verification authenticate HTTP callers without contributing model input.' },
|
||||
'packages/host/authentication-desktop': { kind: 'none', reason: 'Private Desktop credential verification authenticates HTTP callers without contributing model input.' },
|
||||
'packages/api/terminal-controller': { kind: 'indirect', reason: 'Working-directory recovery owns directory context; user terminal screens never enter model requests.' },
|
||||
'packages/client/ui-sidebar-terminal': { kind: 'none', reason: 'The browser renders user terminal screens without exposing them to the model.' },
|
||||
'packages/ssh/ssh-helper-runtime': { kind: 'none', reason: 'The private executable carrier registers no model-facing content; its providers and consumers own operation results.' },
|
||||
|
||||
Reference in new issue
Block a user