@sparkelf/dsh-plus 0.2.9-alpha.92 → 0.2.9-alpha.94
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/cordis.patch.yml +5 -7
- package/package.json +496 -620
- package/patches/composer-popover-boundaries.patch +7 -8
- package/patches/image-offload-hoist-replay.patch +34 -31
- package/patches/responses-reasoning-status.patch +7 -17
- package/patches/workspace-storage-restore.patch +18 -2
- package/patches/browser-auth-mode.patch +0 -127
- package/patches/diagram-preview.patch +0 -562
- package/patches/office-system-soffice.patch +0 -492
- package/patches/resource-ref-chip-mentions.patch +0 -379
- package/patches/session-envelope-ignorable.patch +0 -92
- package/patches/ui-schedule-plaza-tab.patch +0 -200
- package/patches/visibility-filters.patch +0 -646
- package/patches/web-runtime-compat.patch +0 -83
|
@@ -60,10 +60,9 @@ index 23e71c9c..50e1d3a9 100644
|
|
|
60
60
|
|
|
61
61
|
/** Subscribe to the main key without subscribing the column frame to each panel id. */
|
|
62
62
|
diff --git a/packages/client/ui-model-selection/src/client/ModelSelect.tsx b/packages/client/ui-model-selection/src/client/ModelSelect.tsx
|
|
63
|
-
index 3eea3e37..df98d1a4 100644
|
|
64
63
|
--- a/packages/client/ui-model-selection/src/client/ModelSelect.tsx
|
|
65
64
|
+++ b/packages/client/ui-model-selection/src/client/ModelSelect.tsx
|
|
66
|
-
@@ -
|
|
65
|
+
@@ -93,11 +93,19 @@
|
|
67
66
|
const lastActionRef = useRef<'load' | 'select'>('load')
|
|
68
67
|
const [toast, setToast] = useState<{ seq: number; text: string } | null>(null)
|
|
69
68
|
const toastSeq = useRef(0)
|
|
@@ -83,14 +82,14 @@ index 3eea3e37..df98d1a4 100644
|
|
|
83
82
|
const itemRefs = useRef<(HTMLButtonElement | null)[]>([])
|
|
84
83
|
const id = useId()
|
|
85
84
|
const anchorStyle: CSSProperties & Record<'--dsh-model-anchor', string> = {
|
|
86
|
-
@@ -
|
|
87
|
-
|
|
85
|
+
@@ -538,7 +546,9 @@
|
|
86
|
+
tabIndex={pane.kind === 'detail' ? -1 : undefined}
|
|
88
87
|
id={`${id}-menu`}
|
|
89
|
-
className={css.menu}
|
|
88
|
+
className={clsx(css.menu, (pane.kind === 'root' || pane.kind === 'detail') && css.settingsMenu)}
|
|
90
89
|
- style={anchorStyle}
|
|
91
90
|
+ style={{ ...anchorStyle, ...(columnWidth === null
|
|
92
91
|
+ ? {}
|
|
93
92
|
+ : { maxWidth: Math.max(0, columnWidth - 24) }) }}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
aria-
|
|
93
|
+
// A detail pane holds plugin controls and prose, not menu items.
|
|
94
|
+
role={pane.kind === 'model' || pane.kind === 'detail' ? 'group' : 'menu'}
|
|
95
|
+
aria-label={pane.kind === 'detail' ? pane.pane.title : t('menu.aria')}
|
|
@@ -118,10 +118,19 @@ index 1dd0e81b..ce88e9a4 100644
|
|
|
118
118
|
return messages
|
|
119
119
|
},
|
|
120
120
|
diff --git a/packages/compaction/compaction-image-offload/tests/projection.spec.ts b/packages/compaction/compaction-image-offload/tests/projection.spec.ts
|
|
121
|
-
index
|
|
121
|
+
index 3eaa2dc..246702a 100644
|
|
122
122
|
--- a/packages/compaction/compaction-image-offload/tests/projection.spec.ts
|
|
123
123
|
+++ b/packages/compaction/compaction-image-offload/tests/projection.spec.ts
|
|
124
|
-
@@ -
|
|
124
|
+
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
|
125
|
+
import { brandString } from '@deepseek-ai/dsh-brand'
|
|
126
|
+
import { createAssistantMessage, createToolResultMessage, createUserMessage, type ToolCallId } from '@deepseek-ai/dsh-llm'
|
|
127
|
+
import type { ContentBlock, ImageBlock } from '@deepseek-ai/dsh-llm'
|
|
128
|
+
-import { deriveEventMessage, foldSurface, Session, type SessionId, SessionLogOffset, SessionSeq } from '@deepseek-ai/dsh-session'
|
|
129
|
+
+import { deriveEventMessage, foldSurface, Session, SessionId, SessionLogOffset, SessionSeq } from '@deepseek-ai/dsh-session'
|
|
130
|
+
import type { SessionEvent, SessionEventMap } from '@deepseek-ai/dsh-session'
|
|
131
|
+
import { imageOffloadProjection } from '../src/projection.ts'
|
|
132
|
+
|
|
133
|
+
@@ -138,4 +138,49 @@ describe('durable image selections', () => {
|
|
125
134
|
}, { surfaceOp: 'append' })
|
|
126
135
|
expect(() => session.append('image/offload', { targets: [{ seq: assistant.seq, imageIndexes: [0] }] })).toThrow(/must be user\/message/)
|
|
127
136
|
})
|
|
@@ -172,12 +181,11 @@ index 0c82575d..e3217782 100644
|
|
|
172
181
|
+ })
|
|
173
182
|
})
|
|
174
183
|
diff --git a/packages/session-query/session-query-sqlite/src/index.ts b/packages/session-query/session-query-sqlite/src/index.ts
|
|
175
|
-
index 7c95afa2..97d1763e 100644
|
|
176
184
|
--- a/packages/session-query/session-query-sqlite/src/index.ts
|
|
177
185
|
+++ b/packages/session-query/session-query-sqlite/src/index.ts
|
|
178
|
-
@@ -
|
|
179
|
-
import type { DatabaseSync } from 'node:sqlite'
|
|
186
|
+
@@ -10,11 +10,12 @@
|
|
180
187
|
import { Context, Service, type Fiber } from '@deepseek-ai/cordis'
|
|
188
|
+
import { brandString } from '@deepseek-ai/dsh-brand'
|
|
181
189
|
import z from '@deepseek-ai/schemastery'
|
|
182
190
|
-import type { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
|
|
183
191
|
+import type { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset, SessionMessageProjection } from '@deepseek-ai/dsh-session'
|
|
@@ -192,7 +200,7 @@ index 7c95afa2..97d1763e 100644
|
|
|
192
200
|
} from '@deepseek-ai/dsh-session-persistence'
|
|
193
201
|
import SessionQueryEngine, {
|
|
194
202
|
SESSION_QUERY_DEFAULT_PERSISTED_INSPECT_CONCURRENCY,
|
|
195
|
-
@@ -24,6 +25,7 @@
|
|
203
|
+
@@ -24,6 +25,7 @@
|
|
196
204
|
assertSessionHeadersCompatible,
|
|
197
205
|
buildSessionEventSearchDocuments,
|
|
198
206
|
readColdSessionLog,
|
|
@@ -200,7 +208,7 @@ index 7c95afa2..97d1763e 100644
|
|
|
200
208
|
} from '@deepseek-ai/dsh-session-query'
|
|
201
209
|
import type {
|
|
202
210
|
Config as SessionQueryConfig,
|
|
203
|
-
@@ -
|
|
211
|
+
@@ -520,10 +522,27 @@
|
|
204
212
|
// live-preferred.
|
|
205
213
|
if (initiallyLive.has(entry.header.id) || this.ctx.sessions.get(entry.header.id) !== undefined) continue
|
|
206
214
|
assertNotAborted(signal)
|
|
@@ -230,7 +238,7 @@ index 7c95afa2..97d1763e 100644
|
|
|
230
238
|
}
|
|
231
239
|
assertNotAborted(signal)
|
|
232
240
|
const afterSnapshots = await persistence.list(listOptions)
|
|
233
|
-
@@ -
|
|
241
|
+
@@ -548,7 +567,7 @@
|
|
234
242
|
}
|
|
235
243
|
const live = new Map<SessionId, ObservedSession>()
|
|
236
244
|
for (const session of this.ctx.sessions.list()) {
|
|
@@ -239,7 +247,7 @@ index 7c95afa2..97d1763e 100644
|
|
|
239
247
|
const durable = persisted.get(session.id)
|
|
240
248
|
if (durable !== undefined) assertSessionHeadersCompatible(observed.header, durable.header)
|
|
241
249
|
live.set(session.id, observed)
|
|
242
|
-
@@ -
|
|
250
|
+
@@ -614,6 +633,34 @@
|
|
243
251
|
}
|
|
244
252
|
}
|
|
245
253
|
|
|
@@ -274,7 +282,7 @@ index 7c95afa2..97d1763e 100644
|
|
|
274
282
|
private _replaceLiveSession(entry: ObservedSession, generation: number, persisted: boolean): void {
|
|
275
283
|
this._deleteSession('live', entry.header.id)
|
|
276
284
|
const db = this._requireDb()
|
|
277
|
-
@@ -
|
|
285
|
+
@@ -869,22 +916,23 @@
|
|
278
286
|
]
|
|
279
287
|
}
|
|
280
288
|
|
|
@@ -365,18 +373,17 @@ index 8788c8ea..d191b9cc 100644
|
|
|
365
373
|
throw new SessionQueryError(
|
|
366
374
|
/* v8 ignore next -- foldSurface throws Error instances */
|
|
367
375
|
diff --git a/packages/session-query/session-query/src/index.ts b/packages/session-query/session-query/src/index.ts
|
|
368
|
-
index dfb11fec..2d1f095a 100644
|
|
369
376
|
--- a/packages/session-query/session-query/src/index.ts
|
|
370
377
|
+++ b/packages/session-query/session-query/src/index.ts
|
|
371
|
-
@@ -
|
|
372
|
-
SessionSeq,
|
|
378
|
+
@@ -12,6 +12,7 @@
|
|
373
379
|
snapshotSessionEvent,
|
|
380
|
+
validateSessionLog,
|
|
374
381
|
type SessionId,
|
|
375
382
|
+ type SessionMessageProjection,
|
|
376
383
|
type SessionSeq as SessionSeqType,
|
|
377
384
|
} from '@deepseek-ai/dsh-session'
|
|
378
|
-
import {
|
|
379
|
-
@@ -
|
|
385
|
+
import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
|
|
386
|
+
@@ -136,6 +137,23 @@
|
|
380
387
|
this._observations = new SessionObservationReader(ctx, preparedSessionCacheSize)
|
|
381
388
|
}
|
|
382
389
|
|
|
@@ -385,13 +392,9 @@ index dfb11fec..2d1f095a 100644
|
|
|
385
392
|
+ *
|
|
386
393
|
+ * A log is interpreted by whichever projections were mounted when its durable
|
|
387
394
|
+ * decisions were written, so a cold read must use the mounted set rather than
|
|
388
|
-
+ * the first-party catalog alone.
|
|
389
|
-
+ *
|
|
390
|
-
+ *
|
|
391
|
-
+ * earlier carrier, so the recorded depth-first indexes no longer resolve.
|
|
392
|
-
+ *
|
|
393
|
-
+ * Catalog definitions are kept first; a live contribution of the same event
|
|
394
|
-
+ * type is dropped because the fold rejects duplicate ownership anyway.
|
|
395
|
+
+ * the first-party catalog alone. Catalog definitions are kept first; a live
|
|
396
|
+
+ * contribution of the same event type is dropped because the fold rejects
|
|
397
|
+
+ * duplicate ownership anyway.
|
|
395
398
|
+ * @returns borrowed catalog definitions followed by live plugin contributions.
|
|
396
399
|
+ */
|
|
397
400
|
+ protected get replayMessageProjections(): readonly SessionMessageProjection[] {
|
|
@@ -401,19 +404,19 @@ index dfb11fec..2d1f095a 100644
|
|
|
401
404
|
+ return [...currentSessionMessageProjections, ...live.filter(projection => !seen.has(projection.type))]
|
|
402
405
|
+ }
|
|
403
406
|
+
|
|
404
|
-
/**
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
@@ -
|
|
407
|
+
/** Register the Session-list metadata projection for this service's lifetime. */
|
|
408
|
+
protected async [Service.init](): Promise<void> {
|
|
409
|
+
this._listMetadata = await this.ctx.sessionProjections.register(sessionListMetadataDefinition)
|
|
410
|
+
@@ -207,7 +225,7 @@
|
|
408
411
|
loaded.events,
|
|
409
|
-
loaded.header,
|
|
410
412
|
loaded.inheritedEventCount,
|
|
413
|
+
undefined,
|
|
411
414
|
- currentSessionMessageProjections,
|
|
412
415
|
+ this.replayMessageProjections,
|
|
413
416
|
)
|
|
414
417
|
return {
|
|
415
418
|
session: structuredClone(loaded.header),
|
|
416
|
-
@@ -
|
|
419
|
+
@@ -287,7 +305,7 @@
|
|
417
420
|
*/
|
|
418
421
|
async listEvents(sessionId: SessionId): Promise<SessionEventRecord[]> {
|
|
419
422
|
const loaded = await this._corpus.load(sessionId)
|
|
@@ -422,7 +425,7 @@ index dfb11fec..2d1f095a 100644
|
|
|
422
425
|
}
|
|
423
426
|
|
|
424
427
|
/**
|
|
425
|
-
@@ -
|
|
428
|
+
@@ -316,7 +334,7 @@
|
|
426
429
|
filters: readonly SessionEventResultFilter[],
|
|
427
430
|
): Promise<SessionEventSearchDocument[]> {
|
|
428
431
|
const loaded = await this._corpus.load(sessionId)
|
|
@@ -431,7 +434,7 @@ index dfb11fec..2d1f095a 100644
|
|
|
431
434
|
return filterSessionEventDocuments(documents, filters)
|
|
432
435
|
}
|
|
433
436
|
|
|
434
|
-
@@ -
|
|
437
|
+
@@ -332,7 +350,7 @@
|
|
435
438
|
session: structuredClone(loaded.header),
|
|
436
439
|
inheritedEventCount: loaded.inheritedEventCount,
|
|
437
440
|
capturedThroughSeq: loaded.events.at(-1)?.seq ?? null,
|
|
@@ -440,7 +443,7 @@ index dfb11fec..2d1f095a 100644
|
|
|
440
443
|
}
|
|
441
444
|
}
|
|
442
445
|
|
|
443
|
-
@@ -
|
|
446
|
+
@@ -361,7 +379,7 @@
|
|
444
447
|
signal?.throwIfAborted()
|
|
445
448
|
return {
|
|
446
449
|
session: loaded.header,
|
|
@@ -195,22 +195,21 @@ index 5dec1bda..f596cd47 100644
|
|
|
195
195
|
customBaseUrlInvalid: 'Insira um URL HTTP ou HTTPS válido.',
|
|
196
196
|
customNeedsModels: 'Um provedor personalizado precisa de pelo menos um modelo.',
|
|
197
197
|
diff --git a/packages/llm/llm-pi-ai/src/adapter.ts b/packages/llm/llm-pi-ai/src/adapter.ts
|
|
198
|
-
index f3f9ac00..f5ef95a1 100644
|
|
199
198
|
--- a/packages/llm/llm-pi-ai/src/adapter.ts
|
|
200
199
|
+++ b/packages/llm/llm-pi-ai/src/adapter.ts
|
|
201
|
-
@@ -58,7 +58,7 @@
|
|
202
|
-
} from '@deepseek-ai/dsh-llm'
|
|
200
|
+
@@ -58,7 +58,7 @@
|
|
203
201
|
import type { AttachmentStore, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'
|
|
202
|
+
import { brandString } from '@deepseek-ai/dsh-brand'
|
|
204
203
|
import { idleWatchdog, timeoutOf } from '@deepseek-ai/dsh-timeout'
|
|
205
204
|
-import type { ResolvedPiAiProviderProfile } from './config.ts'
|
|
206
205
|
+import type { PiAiReasoningSummary, ResolvedPiAiProviderProfile } from './config.ts'
|
|
207
206
|
import { requestImageTarget, toPiContext } from './context.ts'
|
|
207
|
+
import { resolveImageRequestBudget } from './image-policy.ts'
|
|
208
208
|
import { conversationUpdates, createModels, getSupportedThinkingLevels } from './models.ts'
|
|
209
|
-
|
|
210
|
-
@@ -145,9 +145,85 @@ export interface PiAiAuthInjection {
|
|
209
|
+
@@ -146,9 +146,76 @@
|
|
211
210
|
authContext: AuthContext
|
|
212
211
|
}
|
|
213
|
-
|
|
212
|
+
|
|
214
213
|
+/** Whether one Responses input item is replayed reasoning with response status metadata. */
|
|
215
214
|
+function hasReasoningInputStatus(item: unknown): boolean {
|
|
216
215
|
+ const inputItem = item as Record<string, unknown>
|
|
@@ -231,12 +230,6 @@ index f3f9ac00..f5ef95a1 100644
|
|
|
231
230
|
+
|
|
232
231
|
+/**
|
|
233
232
|
+ * Force one model's `reasoning.summary` to a chosen spelling, or drop it.
|
|
234
|
-
+ *
|
|
235
|
-
+ * pi-ai writes `summary: options?.reasoningSummary || 'auto'` whenever a
|
|
236
|
-
+ * Responses model reasons, so the field leaves even when nothing asked for it.
|
|
237
|
-
+ * A gateway that refuses the field therefore fails every reply from that model
|
|
238
|
-
+ * rather than merely omitting a summary, and only a payload hook can keep the
|
|
239
|
-
+ * field off the wire.
|
|
240
233
|
+ * @param payload - the request body pi-ai built.
|
|
241
234
|
+ * @param summary - the configured spelling, or `omit` to drop the field.
|
|
242
235
|
+ * @returns the adjusted body, or undefined to leave the request untouched.
|
|
@@ -253,9 +246,6 @@ index f3f9ac00..f5ef95a1 100644
|
|
|
253
246
|
+
|
|
254
247
|
+/**
|
|
255
248
|
+ * The payload hook a model needs, if any.
|
|
256
|
-
+ *
|
|
257
|
-
+ * One hook field is a function, so a model needing both adjustments gets a
|
|
258
|
-
+ * composition rather than one silently replacing the other.
|
|
259
249
|
+ * @param profile - the resolved route profile.
|
|
260
250
|
+ * @param model - the model being called, which may pin its own summary.
|
|
261
251
|
+ * @returns the `onPayload` option for this call, or an empty object.
|
|
@@ -293,7 +283,7 @@ index f3f9ac00..f5ef95a1 100644
|
|
|
293
283
|
reasoning: ModelThinkingLevel | undefined,
|
|
294
284
|
apiKey: string | undefined,
|
|
295
285
|
): SimpleStreamOptions {
|
|
296
|
-
@@ -
|
|
286
|
+
@@ -161,6 +228,7 @@
|
|
297
287
|
...profile.transport === undefined ? {} : { transport: profile.transport },
|
|
298
288
|
...profile.timeoutMs === undefined ? {} : { timeoutMs: profile.timeoutMs },
|
|
299
289
|
...profile.websocketConnectTimeoutMs === undefined ? {} : { websocketConnectTimeoutMs: profile.websocketConnectTimeoutMs },
|
|
@@ -301,7 +291,7 @@ index f3f9ac00..f5ef95a1 100644
|
|
|
301
291
|
// The agent recovery layer owns visible attempts; one adapter call is one SDK attempt.
|
|
302
292
|
maxRetries: 0,
|
|
303
293
|
}
|
|
304
|
-
@@ -
|
|
294
|
+
@@ -471,7 +539,7 @@
|
|
305
295
|
this.config.onThinkingOmitted?.({ provider: options.provider, model: options.model, count })
|
|
306
296
|
})
|
|
307
297
|
const events = snapshot.models.streamSimple(model, context, {
|
|
@@ -75,10 +75,26 @@ index 825cb049..e4dc7be7 100644
|
|
|
75
75
|
this.global = domain.global
|
|
76
76
|
this.state = domain.global.get()
|
|
77
77
|
diff --git a/packages/workspace/workspace/tests/workspace.spec.ts b/packages/workspace/workspace/tests/workspace.spec.ts
|
|
78
|
-
index
|
|
78
|
+
index 427e533..9cb84da 100644
|
|
79
79
|
--- a/packages/workspace/workspace/tests/workspace.spec.ts
|
|
80
80
|
+++ b/packages/workspace/workspace/tests/workspace.spec.ts
|
|
81
|
-
@@ -
|
|
81
|
+
@@ -9,13 +9,13 @@ import Storage from '@deepseek-ai/dsh-storage'
|
|
82
|
+
import type { StorageBackend } from '@deepseek-ai/dsh-storage'
|
|
83
|
+
import { DomainFacility } from '@deepseek-ai/dsh-storage-domain'
|
|
84
|
+
import type { DomainChanged } from '@deepseek-ai/dsh-storage-domain'
|
|
85
|
+
-import SessionStore, { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
|
|
86
|
+
+import SessionStore, { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
|
|
87
|
+
import type { SessionHeader } from '@deepseek-ai/dsh-session'
|
|
88
|
+
import type { SessionPersistenceRevision } from '@deepseek-ai/dsh-session-persistence'
|
|
89
|
+
import type { SessionPersistenceSnapshot } from '@deepseek-ai/dsh-session-persistence'
|
|
90
|
+
import { MemoryMediaPool, MemoryStorageBackend } from '../../../storage/storage-domain/tests/helpers/memory-backend.ts'
|
|
91
|
+
import WorkspaceRegistry, {
|
|
92
|
+
- type WorkspaceId,
|
|
93
|
+
+ WorkspaceId,
|
|
94
|
+
type workspaceDomainState,
|
|
95
|
+
WorkspaceMoveInvalidError,
|
|
96
|
+
WorkspaceOrderInvalidError,
|
|
97
|
+
@@ -1556,6 +1556,105 @@ describe('first-use Workspace preparation', () => {
|
|
82
98
|
})
|
|
83
99
|
})
|
|
84
100
|
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
diff --git a/packages/client/connection/src/browser-auth.ts b/packages/client/connection/src/browser-auth.ts
|
|
2
|
-
index 5c8594df..e5f5fa9f 100644
|
|
3
|
-
--- a/packages/client/connection/src/browser-auth.ts
|
|
4
|
-
+++ b/packages/client/connection/src/browser-auth.ts
|
|
5
|
-
@@ -198,12 +198,40 @@ async function initializeSecret(credentials: CredentialProvider): Promise<Buffer
|
|
6
|
-
return secret
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
+/** Browser-session policy selected once while Connection activates. */
|
|
10
|
-
+export interface BrowserAuthentication {
|
|
11
|
-
+ /** Add any authentication input to the clean application URL. */
|
|
12
|
-
+ authenticatedUrl(baseUrl: string): string
|
|
13
|
-
+ /** Authorize one frontend index request, owning the response when denied or redirected. */
|
|
14
|
-
+ authorizeIndex(req: ConnectionIndexRequest, res: ConnectionIndexResponse, secure?: boolean): boolean
|
|
15
|
-
+ /** Authorize one connect request, owning the response when denied or redirected. */
|
|
16
|
-
+ authorizeConnect(
|
|
17
|
-
+ req: ConnectionIndexRequest,
|
|
18
|
-
+ res: ConnectionIndexResponse,
|
|
19
|
-
+ secure: boolean,
|
|
20
|
-
+ publish: (interactions: ConnectionInteractions) => PeerId,
|
|
21
|
-
+ ): void
|
|
22
|
-
+ /** Decide whether a trusted Host request has the required browser identity. */
|
|
23
|
-
+ isAuthenticated(request: ConnectionTrustRequest, secure?: boolean): boolean
|
|
24
|
-
+ /** Resolve the peer identity of an authenticated API request, or undefined when it is not. */
|
|
25
|
-
+ authenticateApi(request: ConnectionTrustRequest, secure?: boolean): PeerId | undefined
|
|
26
|
-
+}
|
|
27
|
-
+
|
|
28
|
-
+/** Profile-selected policy that admits every request after the independent Host/Origin fence. */
|
|
29
|
-
+export const DISABLED_BROWSER_AUTHENTICATION: BrowserAuthentication = {
|
|
30
|
-
+ authenticatedUrl: baseUrl => new URL(baseUrl).href,
|
|
31
|
-
+ authorizeIndex: () => true,
|
|
32
|
-
+ authorizeConnect: () => undefined,
|
|
33
|
-
+ isAuthenticated: () => true,
|
|
34
|
-
+ authenticateApi: () => undefined,
|
|
35
|
-
+}
|
|
36
|
-
+
|
|
37
|
-
/**
|
|
38
|
-
* Process launch-token exchange and persistent signed-cookie verification.
|
|
39
|
-
* Connection loads the credential provider's signing secret during activation
|
|
40
|
-
* and retains it for synchronous request authentication.
|
|
41
|
-
*/
|
|
42
|
-
-export class BrowserAuth {
|
|
43
|
-
+export class BrowserAuth implements BrowserAuthentication {
|
|
44
|
-
private readonly launchToken: string
|
|
45
|
-
private readonly maxAgeMilliseconds: number
|
|
46
|
-
|
|
47
|
-
diff --git a/packages/client/connection/src/index.ts b/packages/client/connection/src/index.ts
|
|
48
|
-
index d563cd40..0c0d2279 100644
|
|
49
|
-
--- a/packages/client/connection/src/index.ts
|
|
50
|
-
+++ b/packages/client/connection/src/index.ts
|
|
51
|
-
@@ -10,7 +10,7 @@ import { API_PATH } from './api-path.ts'
|
|
52
|
-
import { CONNECT_PATH } from './connect-protocol.ts'
|
|
53
|
-
import { bridge, DEFAULT_MAX_REQUEST_BODY_BYTES } from './http-bridge.ts'
|
|
54
|
-
import { assertTrustedAuthority } from './api-request-trust.ts'
|
|
55
|
-
-import { BrowserAuth } from './browser-auth.ts'
|
|
56
|
-
+import { BrowserAuth, DISABLED_BROWSER_AUTHENTICATION } from './browser-auth.ts'
|
|
57
|
-
import { HostConnectionService } from './rpc-host.ts'
|
|
58
|
-
import { ConnectionRecoveryConfigSchema, resolveConnectionConfig, type ConnectionRecoveryConfig } from './recovery-config.ts'
|
|
59
|
-
|
|
60
|
-
@@ -103,6 +103,8 @@ export interface ConnectionConfig {
|
|
61
|
-
* an entry here. A non-canonical or non-bare authority fails plugin load.
|
|
62
|
-
*/
|
|
63
|
-
trustedHosts?: string[]
|
|
64
|
-
+ /** Host API browser identity policy; Host/Origin trust remains independent. Default: `required`. */
|
|
65
|
-
+ browserAuthentication?: 'required' | 'disabled'
|
|
66
|
-
/** Absolute browser and API cookie lifetime in days. Default: 30. */
|
|
67
|
-
cookieMaxAgeDays?: number
|
|
68
|
-
/** Maximum buffered JSON body for every `/api` request. Default: 300 MiB. */
|
|
69
|
-
@@ -112,6 +114,7 @@ export interface ConnectionConfig {
|
|
70
|
-
export const Config: z<ConnectionConfig> = z.object({
|
|
71
|
-
recovery: ConnectionRecoveryConfigSchema.default({}),
|
|
72
|
-
trustedHosts: z.array(String).default([]),
|
|
73
|
-
+ browserAuthentication: z.union(['required', 'disabled']).default('required'),
|
|
74
|
-
cookieMaxAgeDays: z.natural().min(1).default(30),
|
|
75
|
-
maxRequestBodyBytes: z.natural().min(1).default(DEFAULT_MAX_REQUEST_BODY_BYTES),
|
|
76
|
-
})
|
|
77
|
-
@@ -127,16 +130,21 @@ export async function apply(ctx: Context, config?: ConnectionConfig): Promise<vo
|
|
78
|
-
const recovery = resolveConnectionConfig(config?.recovery)
|
|
79
|
-
// The Loader resolves schema defaults; hand-built test contexts may pass none.
|
|
80
|
-
const trustedHosts = config?.trustedHosts ?? []
|
|
81
|
-
+ const browserAuthentication = config?.browserAuthentication ?? 'required'
|
|
82
|
-
const cookieMaxAgeDays = config?.cookieMaxAgeDays ?? 30
|
|
83
|
-
const maxRequestBodyBytes = config?.maxRequestBodyBytes ?? DEFAULT_MAX_REQUEST_BODY_BYTES
|
|
84
|
-
// Config boundary: a malformed entry fails the load loudly here rather than
|
|
85
|
-
// silently authorizing its hostname prefix at request time.
|
|
86
|
-
for (const entry of trustedHosts) assertTrustedAuthority(entry)
|
|
87
|
-
assertImageBodyCapacity(ctx, maxRequestBodyBytes)
|
|
88
|
-
+ // 配置在激活时只选择一次策略;disabled不会创建token或credential record。
|
|
89
|
-
+ const browserAuth = browserAuthentication === 'required'
|
|
90
|
-
+ ? await BrowserAuth.create(ctx.root, ctx.credentials, cookieMaxAgeDays)
|
|
91
|
-
+ : DISABLED_BROWSER_AUTHENTICATION
|
|
92
|
-
const connection = new HostConnectionService(
|
|
93
|
-
ctx,
|
|
94
|
-
trustedHosts,
|
|
95
|
-
- await BrowserAuth.create(ctx.root, ctx.credentials, cookieMaxAgeDays),
|
|
96
|
-
+ browserAuth,
|
|
97
|
-
)
|
|
98
|
-
ctx.inject(['webServer'], (webCtx) => {
|
|
99
|
-
assertImageBodyCapacity(webCtx, maxRequestBodyBytes)
|
|
100
|
-
diff --git a/packages/client/connection/src/rpc-host.ts b/packages/client/connection/src/rpc-host.ts
|
|
101
|
-
index 88e7b48b..43a3feb7 100644
|
|
102
|
-
--- a/packages/client/connection/src/rpc-host.ts
|
|
103
|
-
+++ b/packages/client/connection/src/rpc-host.ts
|
|
104
|
-
@@ -13,7 +13,7 @@ import { clientRequestSchema } from './rpc-schema.ts'
|
|
105
|
-
import { bridge } from './http-bridge.ts'
|
|
106
|
-
import { isRemoteAuthority, isTrustedApiRequest } from './api-request-trust.ts'
|
|
107
|
-
import { API_PATH } from './api-path.ts'
|
|
108
|
-
-import type { BrowserAuth } from './browser-auth.ts'
|
|
109
|
-
+import type { BrowserAuthentication } from './browser-auth.ts'
|
|
110
|
-
import { Peer } from './peer.ts'
|
|
111
|
-
import type {
|
|
112
|
-
PeerAdmission,
|
|
113
|
-
@@ -82,12 +82,12 @@ export class HostConnectionService extends Service implements HostConnectionHand
|
|
114
|
-
* Provide the Host half over the active HTTP server.
|
|
115
|
-
* @param ctx - owning Connection plugin context.
|
|
116
|
-
* @param trustedHosts - deployment authorities accepted by the Host/Origin fence.
|
|
117
|
-
- * @param browserAuth - process token and persistent browser-session owner.
|
|
118
|
-
+ * @param browserAuth - profile-selected browser-session policy.
|
|
119
|
-
*/
|
|
120
|
-
constructor(
|
|
121
|
-
ctx: Context,
|
|
122
|
-
private readonly trustedHosts: readonly string[],
|
|
123
|
-
- private readonly browserAuth: BrowserAuth,
|
|
124
|
-
+ private readonly browserAuth: BrowserAuthentication,
|
|
125
|
-
) {
|
|
126
|
-
super(ctx, 'connection')
|
|
127
|
-
this.owner = ctx
|