@astrale-os/shell 0.1.1 → 0.3.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.
- package/LICENSE +202 -0
- package/dist/application/apps.d.ts +18 -0
- package/dist/application/apps.d.ts.map +1 -0
- package/dist/application/apps.js +35 -0
- package/dist/application/namespaces.d.ts +21 -0
- package/dist/application/namespaces.d.ts.map +1 -0
- package/dist/application/namespaces.js +12 -0
- package/dist/application/session/open.d.ts +19 -0
- package/dist/application/session/open.d.ts.map +1 -0
- package/dist/application/session/open.js +46 -0
- package/dist/application/session/session.d.ts +41 -0
- package/dist/application/session/session.d.ts.map +1 -0
- package/dist/application/session/session.js +9 -0
- package/dist/application/session/token.d.ts +24 -0
- package/dist/application/session/token.d.ts.map +1 -0
- package/dist/application/session/token.js +51 -0
- package/dist/application/spaces.d.ts +17 -0
- package/dist/application/spaces.d.ts.map +1 -0
- package/dist/application/spaces.js +30 -0
- package/dist/application/user.d.ts +20 -0
- package/dist/application/user.d.ts.map +1 -0
- package/dist/application/user.js +26 -0
- package/dist/application/view.d.ts +20 -0
- package/dist/application/view.d.ts.map +1 -0
- package/dist/application/view.js +18 -0
- package/dist/{application/channels/children-channel.d.ts → channel/children.d.ts} +4 -4
- package/dist/channel/children.d.ts.map +1 -0
- package/dist/channel/listeners.d.ts +8 -0
- package/dist/channel/listeners.d.ts.map +1 -0
- package/dist/{adapters/message-port.transport.d.ts → channel/message-port.d.ts} +2 -2
- package/dist/channel/message-port.d.ts.map +1 -0
- package/dist/{application/channels → channel}/observer.d.ts +2 -1
- package/dist/channel/observer.d.ts.map +1 -0
- package/dist/{application/channels/parent-channel.d.ts → channel/parent.d.ts} +4 -4
- package/dist/channel/parent.d.ts.map +1 -0
- package/dist/{application/channels/parent-channel.js → channel/parent.js} +1 -1
- package/dist/channel/transport.d.ts +8 -0
- package/dist/channel/transport.d.ts.map +1 -0
- package/dist/index.d.ts +56 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -20
- package/dist/{domain/intent → intent}/middleware/capabilities.d.ts +2 -2
- package/dist/intent/middleware/capabilities.d.ts.map +1 -0
- package/dist/intent/middleware/logging.d.ts.map +1 -0
- package/dist/{domain/intent → intent}/middleware/rate-limit.d.ts +1 -1
- package/dist/intent/middleware/rate-limit.d.ts.map +1 -0
- package/dist/{application/intent/pipeline-runner.d.ts → intent/pipeline.d.ts} +3 -3
- package/dist/intent/pipeline.d.ts.map +1 -0
- package/dist/intent/policy.d.ts +40 -0
- package/dist/intent/policy.d.ts.map +1 -0
- package/dist/intent/policy.js +15 -0
- package/dist/{application/intent → intent}/request.d.ts +5 -14
- package/dist/intent/request.d.ts.map +1 -0
- package/dist/{application/intent → intent}/request.js +6 -20
- package/dist/intent/router.d.ts +31 -0
- package/dist/intent/router.d.ts.map +1 -0
- package/dist/{application/intent → intent}/router.js +1 -15
- package/dist/kernel/client.d.ts +33 -0
- package/dist/kernel/client.d.ts.map +1 -0
- package/dist/kernel/credential.d.ts +35 -0
- package/dist/kernel/credential.d.ts.map +1 -0
- package/dist/kernel/credential.js +43 -0
- package/dist/kernel/delegated.d.ts +17 -0
- package/dist/kernel/delegated.d.ts.map +1 -0
- package/dist/kernel/delegated.js +29 -0
- package/dist/{application/windowing/token-refresh.d.ts → kernel/delegation/refresh.d.ts} +2 -2
- package/dist/kernel/delegation/refresh.d.ts.map +1 -0
- package/dist/{application/windowing/token-refresh.js → kernel/delegation/refresh.js} +1 -1
- package/dist/{domain/identity/delegation.d.ts → kernel/delegation/token.d.ts} +1 -1
- package/dist/kernel/delegation/token.d.ts.map +1 -0
- package/dist/{adapters/kernel-client.adapter.d.ts → kernel/session.d.ts} +15 -12
- package/dist/kernel/session.d.ts.map +1 -0
- package/dist/{adapters/kernel-client.adapter.js → kernel/session.js} +10 -15
- package/dist/message/ctrl.d.ts +34 -0
- package/dist/message/ctrl.d.ts.map +1 -0
- package/dist/message/error.d.ts +9 -0
- package/dist/message/error.d.ts.map +1 -0
- package/dist/{application/windowing/protocol.d.ts → message/init.d.ts} +1 -1
- package/dist/message/init.d.ts.map +1 -0
- package/dist/{domain/message/registries.d.ts → message/intent.d.ts} +45 -37
- package/dist/message/intent.d.ts.map +1 -0
- package/dist/message/message.d.ts +10 -0
- package/dist/message/message.d.ts.map +1 -0
- package/dist/shell/access.d.ts +10 -0
- package/dist/shell/access.d.ts.map +1 -0
- package/dist/shell/access.js +19 -0
- package/dist/shell/build.d.ts +28 -0
- package/dist/shell/build.d.ts.map +1 -0
- package/dist/shell/build.js +58 -0
- package/dist/shell/config.d.ts +29 -0
- package/dist/shell/config.d.ts.map +1 -0
- package/dist/shell/create.d.ts +4 -0
- package/dist/shell/create.d.ts.map +1 -0
- package/dist/shell/create.js +5 -0
- package/dist/{application/windowing/child-init.d.ts → shell/sandboxed/boot.d.ts} +5 -5
- package/dist/shell/sandboxed/boot.d.ts.map +1 -0
- package/dist/{application/windowing/child-init.js → shell/sandboxed/boot.js} +5 -6
- package/dist/shell/sandboxed/guarded.d.ts +13 -0
- package/dist/shell/sandboxed/guarded.d.ts.map +1 -0
- package/dist/shell/sandboxed/guarded.js +28 -0
- package/dist/shell/sandboxed/pending.d.ts +14 -0
- package/dist/shell/sandboxed/pending.d.ts.map +1 -0
- package/dist/shell/sandboxed/pending.js +30 -0
- package/dist/shell/sandboxed/sandboxed.d.ts +4 -0
- package/dist/shell/sandboxed/sandboxed.d.ts.map +1 -0
- package/dist/shell/sandboxed/sandboxed.js +100 -0
- package/dist/shell/shell.d.ts +36 -0
- package/dist/shell/shell.d.ts.map +1 -0
- package/dist/shell/standalone.d.ts +4 -0
- package/dist/shell/standalone.d.ts.map +1 -0
- package/dist/shell/standalone.js +85 -0
- package/dist/{domain/window/config.d.ts → window/capabilities.d.ts} +3 -3
- package/dist/window/capabilities.d.ts.map +1 -0
- package/dist/{ports/shell-adapter.d.ts → window/embed/adapter.d.ts} +3 -2
- package/dist/window/embed/adapter.d.ts.map +1 -0
- package/dist/{adapters/iframe.shell-adapter.d.ts → window/embed/iframe.d.ts} +2 -2
- package/dist/window/embed/iframe.d.ts.map +1 -0
- package/dist/{application/windowing/lifecycle-controller.d.ts → window/lifecycle/states.d.ts} +4 -3
- package/dist/window/lifecycle/states.d.ts.map +1 -0
- package/dist/{application/windowing/lifecycle-controller.js → window/lifecycle/states.js} +1 -1
- package/dist/{domain/window/lifecycle.d.ts → window/lifecycle/transition.d.ts} +3 -3
- package/dist/window/lifecycle/transition.d.ts.map +1 -0
- package/dist/{domain/window/lifecycle.js → window/lifecycle/transition.js} +1 -1
- package/dist/window/mount/close.d.ts +27 -0
- package/dist/window/mount/close.d.ts.map +1 -0
- package/dist/window/mount/close.js +74 -0
- package/dist/window/mount/credential.d.ts +41 -0
- package/dist/window/mount/credential.d.ts.map +1 -0
- package/dist/window/mount/credential.js +74 -0
- package/dist/window/mount/handshake.d.ts.map +1 -0
- package/dist/{application/windowing → window/mount}/handshake.js +1 -1
- package/dist/{application/windowing/mount-controller.d.ts → window/mount/mount.d.ts} +7 -7
- package/dist/window/mount/mount.d.ts.map +1 -0
- package/dist/window/mount/mount.js +143 -0
- package/dist/window/mount/params.d.ts +73 -0
- package/dist/window/mount/params.d.ts.map +1 -0
- package/dist/window/mount/params.js +1 -0
- package/dist/window/mount/plain.d.ts +20 -0
- package/dist/window/mount/plain.d.ts.map +1 -0
- package/dist/window/mount/plain.js +46 -0
- package/dist/{domain/window → window}/window.d.ts +1 -1
- package/dist/window/window.d.ts.map +1 -0
- package/dist/window/window.js +1 -0
- package/package.json +15 -7
- package/src/application/apps.ts +60 -0
- package/src/application/namespaces.ts +38 -0
- package/src/application/session/open.ts +73 -0
- package/src/application/session/session.ts +46 -0
- package/src/application/session/token.ts +87 -0
- package/src/application/spaces.ts +52 -0
- package/src/application/user.ts +54 -0
- package/src/application/view.ts +42 -0
- package/src/{application/channels/children-channel.ts → channel/children.ts} +3 -3
- package/src/{application/channels/types.ts → channel/listeners.ts} +2 -7
- package/src/{adapters/message-port.transport.ts → channel/message-port.ts} +2 -2
- package/src/{application/channels → channel}/observer.ts +2 -1
- package/src/{application/channels/parent-channel.ts → channel/parent.ts} +4 -4
- package/src/{ports → channel}/transport.ts +2 -1
- package/src/index.ts +80 -88
- package/src/{domain/intent → intent}/middleware/capabilities.ts +2 -3
- package/src/{domain/intent → intent}/middleware/logging.ts +1 -1
- package/src/{domain/intent → intent}/middleware/rate-limit.ts +1 -1
- package/src/{application/intent/pipeline-runner.ts → intent/pipeline.ts} +3 -2
- package/src/intent/policy.ts +46 -0
- package/src/{application/intent → intent}/request.ts +14 -34
- package/src/{application/intent → intent}/router.ts +12 -49
- package/src/kernel/client.ts +33 -0
- package/src/kernel/credential.ts +78 -0
- package/src/kernel/delegated.ts +49 -0
- package/src/{application/windowing/token-refresh.ts → kernel/delegation/refresh.ts} +2 -2
- package/src/{adapters/kernel-client.adapter.ts → kernel/session.ts} +26 -33
- package/src/message/ctrl.ts +25 -0
- package/src/{domain/message/errors.ts → message/error.ts} +8 -0
- package/src/message/intent.ts +98 -0
- package/src/message/message.ts +11 -0
- package/src/shell/access.ts +26 -0
- package/src/shell/build.ts +95 -0
- package/src/shell/config.ts +32 -0
- package/src/shell/create.ts +9 -0
- package/src/{application/windowing/child-init.ts → shell/sandboxed/boot.ts} +10 -11
- package/src/shell/sandboxed/guarded.ts +32 -0
- package/src/shell/sandboxed/pending.ts +52 -0
- package/src/shell/sandboxed/sandboxed.ts +131 -0
- package/src/shell/shell.ts +37 -0
- package/src/shell/standalone.ts +97 -0
- package/src/{domain/window/config.ts → window/capabilities.ts} +2 -2
- package/src/{ports/shell-adapter.ts → window/embed/adapter.ts} +2 -1
- package/src/{adapters/iframe.shell-adapter.ts → window/embed/iframe.ts} +2 -2
- package/src/{application/windowing/lifecycle-controller.ts → window/lifecycle/states.ts} +3 -2
- package/src/{domain/window/lifecycle.ts → window/lifecycle/transition.ts} +2 -2
- package/src/window/mount/close.ts +111 -0
- package/src/window/mount/credential.ts +101 -0
- package/src/{application/windowing → window/mount}/handshake.ts +3 -2
- package/src/window/mount/mount.ts +185 -0
- package/src/window/mount/params.ts +64 -0
- package/src/window/mount/plain.ts +68 -0
- package/src/{domain/window → window}/window.ts +1 -1
- package/dist/adapters/iframe.shell-adapter.d.ts.map +0 -1
- package/dist/adapters/kernel-client.adapter.d.ts.map +0 -1
- package/dist/adapters/message-port.transport.d.ts.map +0 -1
- package/dist/application/channels/children-channel.d.ts.map +0 -1
- package/dist/application/channels/observer.d.ts.map +0 -1
- package/dist/application/channels/parent-channel.d.ts.map +0 -1
- package/dist/application/channels/types.d.ts +0 -12
- package/dist/application/channels/types.d.ts.map +0 -1
- package/dist/application/intent/pipeline-runner.d.ts.map +0 -1
- package/dist/application/intent/request.d.ts.map +0 -1
- package/dist/application/intent/router.d.ts +0 -56
- package/dist/application/intent/router.d.ts.map +0 -1
- package/dist/application/kernel-facade.d.ts +0 -33
- package/dist/application/kernel-facade.d.ts.map +0 -1
- package/dist/application/kernel-facade.js +0 -77
- package/dist/application/shell.d.ts +0 -100
- package/dist/application/shell.d.ts.map +0 -1
- package/dist/application/shell.js +0 -256
- package/dist/application/windowing/child-init.d.ts.map +0 -1
- package/dist/application/windowing/handshake.d.ts.map +0 -1
- package/dist/application/windowing/lifecycle-controller.d.ts.map +0 -1
- package/dist/application/windowing/mount-controller.d.ts.map +0 -1
- package/dist/application/windowing/mount-controller.js +0 -277
- package/dist/application/windowing/protocol.d.ts.map +0 -1
- package/dist/application/windowing/token-refresh.d.ts.map +0 -1
- package/dist/domain/identity/delegation.d.ts.map +0 -1
- package/dist/domain/identity/path.d.ts +0 -11
- package/dist/domain/identity/path.d.ts.map +0 -1
- package/dist/domain/identity/path.js +0 -13
- package/dist/domain/identity/resolve-self.d.ts +0 -21
- package/dist/domain/identity/resolve-self.d.ts.map +0 -1
- package/dist/domain/identity/resolve-self.js +0 -36
- package/dist/domain/intent/middleware/capabilities.d.ts.map +0 -1
- package/dist/domain/intent/middleware/logging.d.ts.map +0 -1
- package/dist/domain/intent/middleware/rate-limit.d.ts.map +0 -1
- package/dist/domain/intent/pipeline.d.ts +0 -3
- package/dist/domain/intent/pipeline.d.ts.map +0 -1
- package/dist/domain/intent/router.d.ts +0 -6
- package/dist/domain/intent/router.d.ts.map +0 -1
- package/dist/domain/message/errors.d.ts +0 -2
- package/dist/domain/message/errors.d.ts.map +0 -1
- package/dist/domain/message/registries.d.ts.map +0 -1
- package/dist/domain/message/types.d.ts +0 -30
- package/dist/domain/message/types.d.ts.map +0 -1
- package/dist/domain/window/config.d.ts.map +0 -1
- package/dist/domain/window/lifecycle.d.ts.map +0 -1
- package/dist/domain/window/window.d.ts.map +0 -1
- package/dist/ports/kernel-client.d.ts +0 -33
- package/dist/ports/kernel-client.d.ts.map +0 -1
- package/dist/ports/shell-adapter.d.ts.map +0 -1
- package/dist/ports/transport.d.ts +0 -7
- package/dist/ports/transport.d.ts.map +0 -1
- package/src/application/kernel-facade.ts +0 -143
- package/src/application/shell.ts +0 -433
- package/src/application/windowing/mount-controller.ts +0 -335
- package/src/domain/identity/path.ts +0 -14
- package/src/domain/identity/resolve-self.ts +0 -38
- package/src/domain/intent/pipeline.ts +0 -3
- package/src/domain/intent/router.ts +0 -6
- package/src/domain/message/registries.ts +0 -76
- package/src/domain/message/types.ts +0 -32
- package/src/ports/kernel-client.ts +0 -32
- /package/dist/{application/channels/children-channel.js → channel/children.js} +0 -0
- /package/dist/{application/channels/types.js → channel/listeners.js} +0 -0
- /package/dist/{adapters/message-port.transport.js → channel/message-port.js} +0 -0
- /package/dist/{application/channels → channel}/observer.js +0 -0
- /package/dist/{ports → channel}/transport.js +0 -0
- /package/dist/{domain/intent → intent}/middleware/capabilities.js +0 -0
- /package/dist/{domain/intent → intent}/middleware/logging.d.ts +0 -0
- /package/dist/{domain/intent → intent}/middleware/logging.js +0 -0
- /package/dist/{domain/intent → intent}/middleware/rate-limit.js +0 -0
- /package/dist/{application/intent/pipeline-runner.js → intent/pipeline.js} +0 -0
- /package/dist/{domain/intent/pipeline.js → kernel/client.js} +0 -0
- /package/dist/{domain/identity/delegation.js → kernel/delegation/token.js} +0 -0
- /package/dist/{domain/intent/router.js → message/ctrl.js} +0 -0
- /package/dist/{domain/message/errors.js → message/error.js} +0 -0
- /package/dist/{application/windowing/protocol.js → message/init.js} +0 -0
- /package/dist/{domain/message/registries.js → message/intent.js} +0 -0
- /package/dist/{domain/message/types.js → message/message.js} +0 -0
- /package/dist/{domain/window → shell}/config.js +0 -0
- /package/dist/{domain/window/window.js → shell/shell.js} +0 -0
- /package/dist/{ports/kernel-client.js → window/capabilities.js} +0 -0
- /package/dist/{ports/shell-adapter.js → window/embed/adapter.js} +0 -0
- /package/dist/{adapters/iframe.shell-adapter.js → window/embed/iframe.js} +0 -0
- /package/dist/{application/windowing → window/mount}/handshake.d.ts +0 -0
- /package/src/{domain/identity/delegation.ts → kernel/delegation/token.ts} +0 -0
- /package/src/{application/windowing/protocol.ts → message/init.ts} +0 -0
package/src/index.ts
CHANGED
|
@@ -1,103 +1,95 @@
|
|
|
1
|
-
// ───
|
|
2
|
-
export type { ErrorCode } from './domain/message/errors'
|
|
3
|
-
export type { IntentRegistry, CtrlRegistry, ViewRef } from './domain/message/registries'
|
|
1
|
+
// ─── message ────────────────────────────────────────────────────────────────
|
|
4
2
|
export type {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
IntentRegistry,
|
|
4
|
+
ViewRef,
|
|
5
|
+
PayloadOf,
|
|
6
|
+
ReplyOf,
|
|
7
7
|
IntentEnvelope,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from './
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export type {
|
|
20
|
-
export type { IntentRouter } from './domain/intent/router'
|
|
21
|
-
export { loggingMiddleware } from './domain/intent/middleware/logging'
|
|
22
|
-
export type { LoggingConfig, LoggingEntry, LoggingSink } from './domain/intent/middleware/logging'
|
|
23
|
-
export { capabilitiesMiddleware } from './domain/intent/middleware/capabilities'
|
|
24
|
-
export type {
|
|
25
|
-
CapabilitiesConfig,
|
|
26
|
-
CapabilityLookup,
|
|
27
|
-
CapabilityViolation,
|
|
28
|
-
} from './domain/intent/middleware/capabilities'
|
|
29
|
-
export { rateLimitMiddleware } from './domain/intent/middleware/rate-limit'
|
|
30
|
-
export type { RateLimitConfig, RateLimitViolation } from './domain/intent/middleware/rate-limit'
|
|
8
|
+
IntentMessage,
|
|
9
|
+
} from './message/intent'
|
|
10
|
+
export type { CtrlRegistry, CtrlMessage } from './message/ctrl'
|
|
11
|
+
export type { ErrorCode, ErrorMessage } from './message/error'
|
|
12
|
+
export type { ShellMessage, MessageHandler } from './message/message'
|
|
13
|
+
export {
|
|
14
|
+
INIT_REQUEST_TYPE,
|
|
15
|
+
INIT_RESPONSE_TYPE,
|
|
16
|
+
isInitRequest,
|
|
17
|
+
isInitResponse,
|
|
18
|
+
} from './message/init'
|
|
19
|
+
export type { InitRequestMessage, InitResponseMessage } from './message/init'
|
|
31
20
|
|
|
32
|
-
// ───
|
|
33
|
-
export type {
|
|
34
|
-
export {
|
|
21
|
+
// ─── kernel ─────────────────────────────────────────────────────────────────
|
|
22
|
+
export type { KernelClient } from './kernel/client'
|
|
23
|
+
export { createKernelClientAdapter } from './kernel/session'
|
|
24
|
+
export type { KernelClientAdapter, CreateKernelClientAdapterOpts } from './kernel/session'
|
|
25
|
+
export type { DelegationScope, DelegationToken, TokenState } from './kernel/delegation/token'
|
|
26
|
+
export { stateOf, isExpired } from './kernel/delegation/token'
|
|
27
|
+
export { createTokenRefresher } from './kernel/delegation/refresh'
|
|
28
|
+
export type { TokenRefreshConfig, TokenRefresher } from './kernel/delegation/refresh'
|
|
35
29
|
|
|
36
|
-
// ───
|
|
37
|
-
export type { Transport } from './
|
|
38
|
-
export
|
|
39
|
-
export type {
|
|
30
|
+
// ─── channel ────────────────────────────────────────────────────────────────
|
|
31
|
+
export type { Transport } from './channel/transport'
|
|
32
|
+
export { createMessagePortTransport } from './channel/message-port'
|
|
33
|
+
export type { MessagePortTransportConfig } from './channel/message-port'
|
|
34
|
+
export type { ParentChannel } from './channel/parent'
|
|
35
|
+
export type { ChildrenChannel } from './channel/children'
|
|
36
|
+
export type { MessageDirection, ObserverHandler } from './channel/observer'
|
|
40
37
|
|
|
41
|
-
// ───
|
|
42
|
-
export {
|
|
38
|
+
// ─── window ─────────────────────────────────────────────────────────────────
|
|
39
|
+
export type { Window, WindowState } from './window/window'
|
|
40
|
+
export type { WindowConfig, WindowCapabilities, SandboxProfile } from './window/capabilities'
|
|
41
|
+
export { transition as lifecycleTransition } from './window/lifecycle/transition'
|
|
42
|
+
export type { LifecycleEvent, TransitionResult } from './window/lifecycle/transition'
|
|
43
|
+
export type { ShellAdapter, WindowHandle } from './window/embed/adapter'
|
|
44
|
+
export { createIframeShellAdapter } from './window/embed/iframe'
|
|
45
|
+
export type { IframeShellAdapterConfig } from './window/embed/iframe'
|
|
43
46
|
export type {
|
|
44
|
-
KernelClientAdapter,
|
|
45
|
-
CreateKernelClientAdapterOpts,
|
|
46
|
-
} from './adapters/kernel-client.adapter'
|
|
47
|
-
export { createMessagePortTransport } from './adapters/message-port.transport'
|
|
48
|
-
export type { MessagePortTransportConfig } from './adapters/message-port.transport'
|
|
49
|
-
export { createIframeShellAdapter } from './adapters/iframe.shell-adapter'
|
|
50
|
-
export type { IframeShellAdapterConfig } from './adapters/iframe.shell-adapter'
|
|
51
|
-
|
|
52
|
-
// ─── application ────────────────────────────────────────────────────────────
|
|
53
|
-
export type {
|
|
54
|
-
Shell,
|
|
55
|
-
ShellConfig,
|
|
56
|
-
StandaloneConfig,
|
|
57
|
-
SandboxedConfig,
|
|
58
47
|
MountParams,
|
|
48
|
+
MountCredential,
|
|
59
49
|
MountedWindow,
|
|
60
50
|
CloseResult,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
MessageHandler,
|
|
65
|
-
ObserverHandler,
|
|
66
|
-
} from './application/shell'
|
|
67
|
-
export { createShell } from './application/shell'
|
|
68
|
-
|
|
69
|
-
// ─── application/windowing (advanced / testing) ─────────────────────────────
|
|
70
|
-
export { runParentHandshake } from './application/windowing/handshake'
|
|
71
|
-
export type {
|
|
72
|
-
HandshakeParams,
|
|
73
|
-
HandshakeError,
|
|
74
|
-
HandshakeResult,
|
|
75
|
-
} from './application/windowing/handshake'
|
|
76
|
-
export { performChildInit } from './application/windowing/child-init'
|
|
77
|
-
export type { ChildInitParams, ChildInitResult } from './application/windowing/child-init'
|
|
78
|
-
export { createTokenRefresher } from './application/windowing/token-refresh'
|
|
79
|
-
export type { TokenRefreshConfig, TokenRefresher } from './application/windowing/token-refresh'
|
|
51
|
+
} from './window/mount/params'
|
|
52
|
+
export { runParentHandshake } from './window/mount/handshake'
|
|
53
|
+
export type { HandshakeParams, HandshakeError, HandshakeResult } from './window/mount/handshake'
|
|
80
54
|
|
|
81
|
-
// ───
|
|
82
|
-
export { createIntentPipeline } from './
|
|
83
|
-
export type { IntentPipeline } from './
|
|
84
|
-
export {
|
|
55
|
+
// ─── intent ─────────────────────────────────────────────────────────────────
|
|
56
|
+
export { createIntentPipeline } from './intent/pipeline'
|
|
57
|
+
export type { IntentMiddleware, IntentPipeline } from './intent/pipeline'
|
|
58
|
+
export type { IntentDecision, IntentOrigin, IntentPolicy, IntentContext } from './intent/policy'
|
|
59
|
+
export { createIntentRouter } from './intent/router'
|
|
85
60
|
export type {
|
|
61
|
+
IntentRouter,
|
|
86
62
|
IntentRouterController,
|
|
87
63
|
IntentRouterConfig,
|
|
88
|
-
IntentDecision,
|
|
89
|
-
IntentOrigin,
|
|
90
|
-
IntentPolicy,
|
|
91
|
-
IntentContext,
|
|
92
64
|
LocalIntentHandler,
|
|
93
|
-
} from './
|
|
94
|
-
export { requestIntent, replyToIntent
|
|
65
|
+
} from './intent/router'
|
|
66
|
+
export { requestIntent, replyToIntent } from './intent/request'
|
|
67
|
+
export { loggingMiddleware } from './intent/middleware/logging'
|
|
68
|
+
export type { LoggingConfig, LoggingEntry, LoggingSink } from './intent/middleware/logging'
|
|
69
|
+
export { capabilitiesMiddleware } from './intent/middleware/capabilities'
|
|
70
|
+
export type {
|
|
71
|
+
CapabilitiesConfig,
|
|
72
|
+
CapabilityLookup,
|
|
73
|
+
CapabilityViolation,
|
|
74
|
+
} from './intent/middleware/capabilities'
|
|
75
|
+
export { rateLimitMiddleware } from './intent/middleware/rate-limit'
|
|
76
|
+
export type { RateLimitConfig, RateLimitViolation } from './intent/middleware/rate-limit'
|
|
95
77
|
|
|
96
|
-
// ───
|
|
97
|
-
export {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} from './application/
|
|
103
|
-
export type {
|
|
78
|
+
// ─── application (OS plane: shell.user / .spaces / .apps) ───────────────────
|
|
79
|
+
export { createOsNamespaces } from './application/namespaces'
|
|
80
|
+
export type { OsNamespaces, CreateOsNamespacesDeps } from './application/namespaces'
|
|
81
|
+
export type { UserNamespace, UserNode, RoleNode } from './application/user'
|
|
82
|
+
export type { SpacesNamespace, SpaceNode } from './application/spaces'
|
|
83
|
+
export type { AppsNamespace, ApplicationNode } from './application/apps'
|
|
84
|
+
export { openAppSession } from './application/session/open'
|
|
85
|
+
export type { OpenAppSessionDeps } from './application/session/open'
|
|
86
|
+
export { AppSessionRefreshError } from './application/session/session'
|
|
87
|
+
export type { AppSession, AppView, RefreshStep } from './application/session/session'
|
|
88
|
+
|
|
89
|
+
// ─── shell ──────────────────────────────────────────────────────────────────
|
|
90
|
+
export { createShell } from './shell/create'
|
|
91
|
+
export type { Shell } from './shell/shell'
|
|
92
|
+
export type { ShellConfig, StandaloneConfig, SandboxedConfig } from './shell/config'
|
|
93
|
+
export { requestAccess } from './shell/access'
|
|
94
|
+
export { performChildInit } from './shell/sandboxed/boot'
|
|
95
|
+
export type { ChildInitParams, ChildInitResult } from './shell/sandboxed/boot'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { IntentRegistry } from '../../message/
|
|
2
|
-
import type {
|
|
3
|
-
import type { WindowCapabilities } from '../../window/config'
|
|
1
|
+
import type { IntentMessage, IntentRegistry } from '../../message/intent'
|
|
2
|
+
import type { WindowCapabilities } from '../../window/capabilities'
|
|
4
3
|
import type { IntentMiddleware } from '../pipeline'
|
|
5
4
|
|
|
6
5
|
export type CapabilityLookup = (sender: string) => WindowCapabilities | undefined
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { IntentMessage } from '../message/intent'
|
|
2
|
+
|
|
3
|
+
export type IntentMiddleware = (message: IntentMessage, next: () => Promise<void>) => Promise<void>
|
|
3
4
|
|
|
4
5
|
export interface IntentPipeline {
|
|
5
6
|
use(middleware: IntentMiddleware): void
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IntentMessage, IntentRegistry } from '../message/intent'
|
|
2
|
+
import type { Window } from '../window/window'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Decision produced by a routing policy: where an inbound intent should go.
|
|
6
|
+
*
|
|
7
|
+
* - `local`: the shell (entry point or sandboxed parent) handles it itself.
|
|
8
|
+
* - `parent`: forward upstream (only valid for sandboxed children).
|
|
9
|
+
* - `child`: forward to a specific child window.
|
|
10
|
+
* - `drop`: discard silently (e.g., handled fully by a middleware).
|
|
11
|
+
*/
|
|
12
|
+
export type IntentDecision<K extends keyof IntentRegistry = keyof IntentRegistry> =
|
|
13
|
+
| { kind: 'local'; message: IntentMessage<K> }
|
|
14
|
+
| { kind: 'parent'; message: IntentMessage<K> }
|
|
15
|
+
| { kind: 'child'; windowId: string; message: IntentMessage<K> }
|
|
16
|
+
| { kind: 'drop' }
|
|
17
|
+
|
|
18
|
+
export type IntentOrigin = 'parent' | 'child' | 'self'
|
|
19
|
+
|
|
20
|
+
export type IntentPolicy = (
|
|
21
|
+
message: IntentMessage,
|
|
22
|
+
ctx: IntentContext,
|
|
23
|
+
) => IntentDecision | Promise<IntentDecision>
|
|
24
|
+
|
|
25
|
+
export interface IntentContext {
|
|
26
|
+
readonly selfWindowId: string
|
|
27
|
+
readonly origin: IntentOrigin
|
|
28
|
+
readonly windows: ReadonlyMap<string, Window>
|
|
29
|
+
readonly hasParent: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Default policy:
|
|
34
|
+
* - intent arrives from a child → handle locally
|
|
35
|
+
* - intent arrives from the parent → handle locally
|
|
36
|
+
* - intent initiated locally (self) → send up to parent if we have one,
|
|
37
|
+
* otherwise keep it local
|
|
38
|
+
*/
|
|
39
|
+
export function defaultPolicy(): IntentPolicy {
|
|
40
|
+
return (message, ctx) => {
|
|
41
|
+
if (ctx.origin === 'self') {
|
|
42
|
+
return ctx.hasParent ? { kind: 'parent', message } : { kind: 'local', message }
|
|
43
|
+
}
|
|
44
|
+
return { kind: 'local', message }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import type { IntentRegistry } from '
|
|
4
|
-
import type { IntentMessage } from '../../domain/message/types'
|
|
5
|
-
import type { ChildrenChannel } from '../channels/children-channel'
|
|
6
|
-
import type { ParentChannel } from '../channels/parent-channel'
|
|
7
|
-
import type { Shell } from '../shell'
|
|
1
|
+
import type { ChildrenChannel } from '../channel/children'
|
|
2
|
+
import type { ParentChannel } from '../channel/parent'
|
|
3
|
+
import type { IntentMessage, IntentRegistry, PayloadOf, ReplyOf } from '../message/intent'
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* Request/reply over the otherwise fire-and-forget intent transport.
|
|
@@ -22,22 +18,26 @@ import type { Shell } from '../shell'
|
|
|
22
18
|
export function requestIntent<K extends keyof IntentRegistry>(
|
|
23
19
|
parent: ParentChannel,
|
|
24
20
|
name: K,
|
|
25
|
-
payload:
|
|
26
|
-
): Promise<
|
|
21
|
+
payload: PayloadOf<K>,
|
|
22
|
+
): Promise<ReplyOf<K>> {
|
|
27
23
|
const correlationId = crypto.randomUUID()
|
|
28
24
|
return new Promise((resolve) => {
|
|
29
25
|
const off = parent.on('intent', (message) => {
|
|
30
26
|
if (message.envelope.name !== 'intentReply') return
|
|
31
|
-
const reply = message.envelope.payload as
|
|
27
|
+
const reply = message.envelope.payload as PayloadOf<'intentReply'>
|
|
32
28
|
if (reply.correlationId !== correlationId) return
|
|
33
29
|
off()
|
|
34
|
-
resolve(reply.result as
|
|
30
|
+
resolve(reply.result as ReplyOf<K>)
|
|
35
31
|
})
|
|
36
|
-
|
|
32
|
+
// `PayloadOf<K>` is a deferred conditional TS can't reconcile with the
|
|
33
|
+
// `ShellMessage` union across a generic `K`; the payload is exact, so assert
|
|
34
|
+
// the concrete message shape.
|
|
35
|
+
const message: IntentMessage<K> = {
|
|
37
36
|
type: 'intent',
|
|
38
37
|
version: 1,
|
|
39
38
|
envelope: { name, payload, sender: { windowId: 'self' }, correlationId },
|
|
40
|
-
}
|
|
39
|
+
}
|
|
40
|
+
parent.send(message as IntentMessage)
|
|
41
41
|
})
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -51,7 +51,7 @@ export function replyToIntent<K extends keyof IntentRegistry>(
|
|
|
51
51
|
children: ChildrenChannel,
|
|
52
52
|
windowId: string,
|
|
53
53
|
request: IntentMessage<K>,
|
|
54
|
-
result:
|
|
54
|
+
result: ReplyOf<K>,
|
|
55
55
|
): void {
|
|
56
56
|
const correlationId = request.envelope.correlationId
|
|
57
57
|
if (!correlationId) return
|
|
@@ -65,23 +65,3 @@ export function replyToIntent<K extends keyof IntentRegistry>(
|
|
|
65
65
|
},
|
|
66
66
|
})
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* View SDK convenience: ask the user (via the root shell) to grant `perms` on
|
|
71
|
-
* `node` to `identity`. Resolves with the bitmask actually granted (0 if the
|
|
72
|
-
* user declined or there was no parent to ask). The view typically passes its
|
|
73
|
-
* own identity (from `whoami`) as `identity`.
|
|
74
|
-
*/
|
|
75
|
-
export function requestAccess(
|
|
76
|
-
shell: Shell,
|
|
77
|
-
opts: IntentRegistry['requestAccess']['payload'],
|
|
78
|
-
): Promise<IntentRegistry['requestAccess']['response']> {
|
|
79
|
-
if (!shell.parent) return Promise.resolve({ granted: false, perms: NO_PERMS })
|
|
80
|
-
// A sandboxed shell's `parent` is a proxy that throws until `init()` resolves;
|
|
81
|
-
// honour the documented "no parent to ask" fallback instead of surfacing that
|
|
82
|
-
// opaque rejection to the caller.
|
|
83
|
-
return requestIntent(shell.parent, 'requestAccess', opts).catch(() => ({
|
|
84
|
-
granted: false,
|
|
85
|
-
perms: NO_PERMS,
|
|
86
|
-
}))
|
|
87
|
-
}
|
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* - `child`: forward to a specific child window.
|
|
14
|
-
* - `drop`: discard silently (e.g., handled fully by a middleware).
|
|
15
|
-
*/
|
|
16
|
-
export type IntentDecision<K extends keyof IntentRegistry = keyof IntentRegistry> =
|
|
17
|
-
| { kind: 'local'; message: IntentMessage<K> }
|
|
18
|
-
| { kind: 'parent'; message: IntentMessage<K> }
|
|
19
|
-
| { kind: 'child'; windowId: string; message: IntentMessage<K> }
|
|
20
|
-
| { kind: 'drop' }
|
|
21
|
-
|
|
22
|
-
export type IntentOrigin = 'parent' | 'child' | 'self'
|
|
23
|
-
|
|
24
|
-
export type IntentPolicy = (
|
|
25
|
-
message: IntentMessage,
|
|
26
|
-
ctx: IntentContext,
|
|
27
|
-
) => IntentDecision | Promise<IntentDecision>
|
|
28
|
-
|
|
29
|
-
export interface IntentContext {
|
|
30
|
-
readonly selfWindowId: string
|
|
31
|
-
readonly origin: IntentOrigin
|
|
32
|
-
readonly windows: ReadonlyMap<string, Window>
|
|
33
|
-
readonly hasParent: boolean
|
|
1
|
+
import type { ChildrenChannelController } from '../channel/children'
|
|
2
|
+
import type { ParentChannel } from '../channel/parent'
|
|
3
|
+
import type { IntentMessage, IntentRegistry } from '../message/intent'
|
|
4
|
+
import type { Window } from '../window/window'
|
|
5
|
+
import type { IntentPipeline } from './pipeline'
|
|
6
|
+
import type { IntentDecision, IntentOrigin, IntentPolicy } from './policy'
|
|
7
|
+
|
|
8
|
+
import { defaultPolicy } from './policy'
|
|
9
|
+
|
|
10
|
+
/** Minimal dispatch-only router surface (no current in-package implementer). */
|
|
11
|
+
export interface IntentRouter {
|
|
12
|
+
dispatch<K extends keyof IntentRegistry>(message: IntentMessage<K>): Promise<void>
|
|
34
13
|
}
|
|
35
14
|
|
|
36
15
|
export type LocalIntentHandler<K extends keyof IntentRegistry = keyof IntentRegistry> = (
|
|
@@ -61,22 +40,6 @@ export type IntentRouterConfig = {
|
|
|
61
40
|
windows: ReadonlyMap<string, Window>
|
|
62
41
|
}
|
|
63
42
|
|
|
64
|
-
/**
|
|
65
|
-
* Default policy:
|
|
66
|
-
* - intent arrives from a child → handle locally
|
|
67
|
-
* - intent arrives from the parent → handle locally
|
|
68
|
-
* - intent initiated locally (self) → send up to parent if we have one,
|
|
69
|
-
* otherwise keep it local
|
|
70
|
-
*/
|
|
71
|
-
function defaultPolicy(): IntentPolicy {
|
|
72
|
-
return (message, ctx) => {
|
|
73
|
-
if (ctx.origin === 'self') {
|
|
74
|
-
return ctx.hasParent ? { kind: 'parent', message } : { kind: 'local', message }
|
|
75
|
-
}
|
|
76
|
-
return { kind: 'local', message }
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
43
|
/** Return a copy of `message` with a trusted `sender.windowId`. */
|
|
81
44
|
function withSender(message: IntentMessage, windowId: string): IntentMessage {
|
|
82
45
|
return { ...message, envelope: { ...message.envelope, sender: { windowId } } }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FnMap } from '@astrale-os/kernel-client'
|
|
2
|
+
import type { BoundClientSessionView } from '@astrale-os/kernel-client/session'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The shell's kernel handle — the kernel-client `BoundClientSessionView` bound
|
|
6
|
+
* to this shell's credential. The bound view IS the surface: the graph sugar
|
|
7
|
+
* (`.get/.node/.children/.query/.mutate/…` over the two kernel doors), dispatch
|
|
8
|
+
* (`.call/.stream/.as/…`) and the `auth` control plane
|
|
9
|
+
* (`.auth.mint/.credential/.whoami/…`). The extras below are the deprecated
|
|
10
|
+
* iframe ABI, kept working until Views adopt `.auth.*`.
|
|
11
|
+
*/
|
|
12
|
+
export type KernelClient = BoundClientSessionView<FnMap> & {
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated iframe ABI — use `shell.kernel.auth.mint()`. Despite the name,
|
|
15
|
+
* mints an *identity* credential for the current principal (v1 misnomer).
|
|
16
|
+
*/
|
|
17
|
+
mintDelegation(): Promise<string>
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated iframe ABI — use `shell.kernel.auth.credential()`. The current
|
|
20
|
+
* JWT for a raw `fetch()`; auto-refreshed, so read fresh per request.
|
|
21
|
+
*/
|
|
22
|
+
authToken(): string
|
|
23
|
+
/**
|
|
24
|
+
* Kernel envelope endpoint this shell talks to. In same-origin GUI shells this
|
|
25
|
+
* may be the resolved `/api/` route; direct instance/dev shells usually pass a
|
|
26
|
+
* full instance endpoint such as `https://example.eu.astrale.ai/api/`.
|
|
27
|
+
*
|
|
28
|
+
* Worker REST routes are different audiences. Do not assume `url` is the right
|
|
29
|
+
* target for a raw stream just because the source credential came from the
|
|
30
|
+
* kernel.
|
|
31
|
+
*/
|
|
32
|
+
readonly url: string
|
|
33
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { KernelClient } from './client'
|
|
2
|
+
import type { KernelClientAdapter } from './session'
|
|
3
|
+
|
|
4
|
+
export type KernelFacadeConfig = {
|
|
5
|
+
adapter: KernelClientAdapter
|
|
6
|
+
credential?: string
|
|
7
|
+
getCredential?: () => string
|
|
8
|
+
/** Kernel URL — exposed to consumers via `KernelClient.url`. */
|
|
9
|
+
url: string
|
|
10
|
+
/**
|
|
11
|
+
* Explicit identity node to use as the mint subject. When omitted, the mint
|
|
12
|
+
* resolves the AUTHENTICATED caller via `whoami` (so a cookie-fronted GUI mints
|
|
13
|
+
* as the logged-in user, not the kernel root). Set this only to pin a subject.
|
|
14
|
+
*/
|
|
15
|
+
mintIdentity?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface KernelFacadeController extends KernelClient {
|
|
19
|
+
dispose(): void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createKernelFacade(config: KernelFacadeConfig): KernelFacadeController {
|
|
23
|
+
const getCredential =
|
|
24
|
+
config.getCredential ??
|
|
25
|
+
(() => {
|
|
26
|
+
if (config.credential === undefined) {
|
|
27
|
+
throw new Error('KernelFacade requires credential or getCredential')
|
|
28
|
+
}
|
|
29
|
+
return config.credential
|
|
30
|
+
})
|
|
31
|
+
return buildCredentialFacade({
|
|
32
|
+
adapter: config.adapter,
|
|
33
|
+
getCredential,
|
|
34
|
+
url: config.url,
|
|
35
|
+
mintIdentity: config.mintIdentity,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type FacadeParams = {
|
|
40
|
+
adapter: KernelClientAdapter
|
|
41
|
+
getCredential: () => string
|
|
42
|
+
url: string
|
|
43
|
+
/** Explicit mint subject. When omitted, the authenticated caller is resolved via `whoami`. */
|
|
44
|
+
mintIdentity?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Bind the unified kernel surface to a credential thunk and attach the shell
|
|
49
|
+
* extras. The bound view IS the kernel surface (`.get/.node/.query/.mutate/
|
|
50
|
+
* .call/…` plus the `auth` control plane), credential-bound via `getCredential`
|
|
51
|
+
* (invoked per dispatch); `mintDelegation`/`authToken`/`url` layer on top as
|
|
52
|
+
* the deprecated iframe-ABI aliases over the view's `auth` namespace.
|
|
53
|
+
*/
|
|
54
|
+
export function buildCredentialFacade(params: FacadeParams): KernelFacadeController {
|
|
55
|
+
const { adapter, getCredential, mintIdentity, url } = params
|
|
56
|
+
const view = adapter.boundView(getCredential)
|
|
57
|
+
|
|
58
|
+
// @deprecated iframe ABI — use `shell.kernel.auth.mint()`. Mints an identity
|
|
59
|
+
// credential for the pinned `mintIdentity`, else the whoami-resolved caller.
|
|
60
|
+
// No implicit `__system__` fallback — an unresolved principal throws rather
|
|
61
|
+
// than silently minting a child credential as kernel root.
|
|
62
|
+
async function mintDelegation(): Promise<string> {
|
|
63
|
+
return view.auth.mint(mintIdentity !== undefined ? { subject: mintIdentity } : undefined)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// @deprecated iframe ABI — use `shell.kernel.auth.credential()`. Shell
|
|
67
|
+
// credentials are JWT strings; decode the `Uint8Array` arm defensively.
|
|
68
|
+
function authToken(): string {
|
|
69
|
+
const credential = view.auth.credential()
|
|
70
|
+
return typeof credential === 'string' ? credential : new TextDecoder().decode(credential)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function dispose() {
|
|
74
|
+
// adapter lifetime is owned by the caller
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return Object.assign(view, { mintDelegation, authToken, url, dispose })
|
|
78
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { KernelFacadeController } from './credential'
|
|
2
|
+
import type { DelegationToken } from './delegation/token'
|
|
3
|
+
import type { KernelClientAdapter } from './session'
|
|
4
|
+
|
|
5
|
+
import { buildCredentialFacade } from './credential'
|
|
6
|
+
|
|
7
|
+
export type DelegationKernelFacadeConfig = {
|
|
8
|
+
adapter: KernelClientAdapter
|
|
9
|
+
initialToken: DelegationToken
|
|
10
|
+
url: string
|
|
11
|
+
onTokenChange?: (token: DelegationToken) => void
|
|
12
|
+
mintIdentity?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DelegationKernelFacadeController extends KernelFacadeController {
|
|
16
|
+
token(): DelegationToken
|
|
17
|
+
setToken(next: DelegationToken): void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The sandboxed-mode kernel: bound to a delegation token the parent refreshes. */
|
|
21
|
+
export function createDelegationKernelFacade(
|
|
22
|
+
config: DelegationKernelFacadeConfig,
|
|
23
|
+
): DelegationKernelFacadeController {
|
|
24
|
+
let token = config.initialToken
|
|
25
|
+
const base = buildCredentialFacade({
|
|
26
|
+
adapter: config.adapter,
|
|
27
|
+
getCredential: () => token.credential,
|
|
28
|
+
url: config.url,
|
|
29
|
+
mintIdentity: config.mintIdentity,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...base,
|
|
34
|
+
token() {
|
|
35
|
+
return token
|
|
36
|
+
},
|
|
37
|
+
setToken(next) {
|
|
38
|
+
if (next.credential === token.credential && next.expiresAt === token.expiresAt) return
|
|
39
|
+
token = next
|
|
40
|
+
config.onTokenChange?.(next)
|
|
41
|
+
},
|
|
42
|
+
// The delegation facade owns its adapter exclusively (created per child in
|
|
43
|
+
// `performChildInit`), so disposing it must tear the adapter down — unlike
|
|
44
|
+
// the standalone facade, where the caller owns the adapter's lifetime.
|
|
45
|
+
dispose() {
|
|
46
|
+
config.adapter.disconnect()
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DelegationToken } from '
|
|
1
|
+
import type { DelegationToken } from './token'
|
|
2
2
|
|
|
3
|
-
import { REFRESH_WINDOW_MS } from '
|
|
3
|
+
import { REFRESH_WINDOW_MS } from './token'
|
|
4
4
|
|
|
5
5
|
export type TokenRefreshConfig = {
|
|
6
6
|
readonly token: () => DelegationToken
|