@nice-code/action 0.8.0 → 0.10.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.
Files changed (145) hide show
  1. package/build/ActionDevtoolsCore-B4s6aGvI.d.ts +79 -0
  2. package/build/ActionDevtoolsCore-BLeY_N-3.js +159 -0
  3. package/build/ActionDevtoolsCore-BLeY_N-3.js.map +1 -0
  4. package/build/ActionDevtoolsCore-Pg7ERO3L.d.ts +79 -0
  5. package/build/ActionDevtoolsCore-yfJ9tkvl.js +154 -0
  6. package/build/ActionDevtoolsCore-yfJ9tkvl.js.map +1 -0
  7. package/build/ActionPayload.types-BN-rXFBK.d.ts +2328 -0
  8. package/build/ActionPayload.types-D28ELKXC.d.ts +2328 -0
  9. package/build/RunningAction.types-C176rqHG.js +22 -0
  10. package/build/RunningAction.types-C176rqHG.js.map +1 -0
  11. package/build/RunningAction.types-DjCX1xp5.js +39 -0
  12. package/build/RunningAction.types-DjCX1xp5.js.map +1 -0
  13. package/build/devtools/browser/index.d.ts +17 -0
  14. package/build/devtools/browser/index.js +3762 -5145
  15. package/build/devtools/browser/index.js.map +1 -0
  16. package/build/devtools/server/index.d.ts +35 -0
  17. package/build/devtools/server/index.js +97 -261
  18. package/build/devtools/server/index.js.map +1 -0
  19. package/build/index.d.ts +2 -0
  20. package/build/index.js +3872 -3870
  21. package/build/index.js.map +1 -0
  22. package/build/react-query/index.d.ts +17 -0
  23. package/build/react-query/index.js +60 -60
  24. package/build/react-query/index.js.map +1 -0
  25. package/package.json +10 -10
  26. package/build/types/ActionDefinition/Action/Action.combined.types.d.ts +0 -37
  27. package/build/types/ActionDefinition/Action/ActionBase.d.ts +0 -14
  28. package/build/types/ActionDefinition/Action/ActionBase.types.d.ts +0 -24
  29. package/build/types/ActionDefinition/Action/Context/ActionContext.d.ts +0 -25
  30. package/build/types/ActionDefinition/Action/Context/ActionContext.types.d.ts +0 -35
  31. package/build/types/ActionDefinition/Action/Core/ActionCore.d.ts +0 -19
  32. package/build/types/ActionDefinition/Action/Core/ActionCore.types.d.ts +0 -10
  33. package/build/types/ActionDefinition/Action/Payload/ActionPayload.d.ts +0 -14
  34. package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +0 -110
  35. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Progress.d.ts +0 -15
  36. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +0 -26
  37. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +0 -19
  38. package/build/types/ActionDefinition/Action/RunningAction.d.ts +0 -36
  39. package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +0 -73
  40. package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +0 -42
  41. package/build/types/ActionDefinition/Domain/ActionDomain.types.d.ts +0 -43
  42. package/build/types/ActionDefinition/Domain/ActionDomainBase.d.ts +0 -14
  43. package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +0 -24
  44. package/build/types/ActionDefinition/Domain/helpers/createRootActionDomain.d.ts +0 -5
  45. package/build/types/ActionDefinition/Schema/ActionSchema.d.ts +0 -68
  46. package/build/types/ActionDefinition/Schema/ActionSchema.types.d.ts +0 -28
  47. package/build/types/ActionRuntime/ActionDomainManager.d.ts +0 -13
  48. package/build/types/ActionRuntime/ActionRuntime.d.ts +0 -78
  49. package/build/types/ActionRuntime/ActionRuntime.types.d.ts +0 -22
  50. package/build/types/ActionRuntime/ActionRuntimeManager.d.ts +0 -20
  51. package/build/types/ActionRuntime/Handler/ActionHandler.d.ts +0 -16
  52. package/build/types/ActionRuntime/Handler/ActionHandler.types.d.ts +0 -65
  53. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +0 -45
  54. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts +0 -7
  55. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/ConnectionTransportManager.d.ts +0 -16
  56. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomConnection.d.ts +0 -7
  57. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomTransport.d.ts +0 -43
  58. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.types.d.ts +0 -11
  59. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpConnection.d.ts +0 -8
  60. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport.d.ts +0 -26
  61. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.types.d.ts +0 -16
  62. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.d.ts +0 -27
  63. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +0 -131
  64. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/TransportConnection.d.ts +0 -27
  65. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types.d.ts +0 -41
  66. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.d.ts +0 -34
  67. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.d.ts +0 -60
  68. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionFrameCrypto.d.ts +0 -31
  69. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWireCodec.d.ts +0 -41
  70. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake.d.ts +0 -187
  71. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter.d.ts +0 -20
  72. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory.d.ts +0 -31
  73. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/secureWsChannel.d.ts +0 -63
  74. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/ws_util.d.ts +0 -11
  75. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport.d.ts +0 -36
  76. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport_ws.d.ts +0 -18
  77. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/addTransportStatusMetadata.d.ts +0 -2
  78. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/createUnsetTransportResolvers.d.ts +0 -2
  79. package/build/types/ActionRuntime/Handler/ExternalClient/err_nice_external_client.d.ts +0 -5
  80. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.d.ts +0 -55
  81. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.types.d.ts +0 -7
  82. package/build/types/ActionRuntime/Handler/Server/ActionServerHandler.d.ts +0 -254
  83. package/build/types/ActionRuntime/Handler/Server/WsConnectionStateStore.d.ts +0 -61
  84. package/build/types/ActionRuntime/Handler/Server/createActionFetchHandler.d.ts +0 -40
  85. package/build/types/ActionRuntime/Handler/Server/createSecureActionServer.d.ts +0 -71
  86. package/build/types/ActionRuntime/HandlerCallStack.d.ts +0 -3
  87. package/build/types/ActionRuntime/Routing/ActionRouter.d.ts +0 -55
  88. package/build/types/ActionRuntime/Routing/ActionRouter.types.d.ts +0 -20
  89. package/build/types/ActionRuntime/RuntimeCoordinate.d.ts +0 -58
  90. package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +0 -207
  91. package/build/types/ActionRuntime/utils/runtimeCoordinateToStringIds.d.ts +0 -2
  92. package/build/types/devtools/browser/NiceActionDevtools.d.ts +0 -14
  93. package/build/types/devtools/browser/components/ActionErrorDisplay.d.ts +0 -5
  94. package/build/types/devtools/browser/components/CallStackSection.d.ts +0 -8
  95. package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +0 -6
  96. package/build/types/devtools/browser/components/Chip.d.ts +0 -22
  97. package/build/types/devtools/browser/components/DetailSection.d.ts +0 -5
  98. package/build/types/devtools/browser/components/DomainChip.d.ts +0 -8
  99. package/build/types/devtools/browser/components/HandlerChips.d.ts +0 -21
  100. package/build/types/devtools/browser/components/Icon.d.ts +0 -16
  101. package/build/types/devtools/browser/components/MetaSection.d.ts +0 -4
  102. package/build/types/devtools/browser/components/NiceErrorDisplay.d.ts +0 -19
  103. package/build/types/devtools/browser/components/OriginChip.d.ts +0 -15
  104. package/build/types/devtools/browser/components/RoutingSection.d.ts +0 -5
  105. package/build/types/devtools/browser/components/RunningTimer.d.ts +0 -7
  106. package/build/types/devtools/browser/components/SectionLabel.d.ts +0 -1
  107. package/build/types/devtools/browser/components/StackTraceSection.d.ts +0 -9
  108. package/build/types/devtools/browser/components/Tooltip.d.ts +0 -1
  109. package/build/types/devtools/browser/components/action_detail/ActionDetailPanel.d.ts +0 -7
  110. package/build/types/devtools/browser/components/action_list/ActionEntryRow.d.ts +0 -14
  111. package/build/types/devtools/browser/components/action_list/ActionInputAndOutputChip.d.ts +0 -11
  112. package/build/types/devtools/browser/components/action_list/ActionList.d.ts +0 -10
  113. package/build/types/devtools/browser/components/action_list/IoTooltipContent.d.ts +0 -3
  114. package/build/types/devtools/browser/components/action_list/action_list.types.d.ts +0 -4
  115. package/build/types/devtools/browser/components/sourceMapResolver.d.ts +0 -6
  116. package/build/types/devtools/browser/components/utils.d.ts +0 -20
  117. package/build/types/devtools/browser/devtools_storage.d.ts +0 -6
  118. package/build/types/devtools/browser/index.d.ts +0 -3
  119. package/build/types/devtools/browser/ui_util/size.d.ts +0 -6
  120. package/build/types/devtools/core/ActionDevtools.types.d.ts +0 -55
  121. package/build/types/devtools/core/ActionDevtoolsCore.d.ts +0 -17
  122. package/build/types/devtools/core/devtools_colors.d.ts +0 -38
  123. package/build/types/devtools/server/NiceActionServerDevtools.d.ts +0 -30
  124. package/build/types/devtools/server/index.d.ts +0 -3
  125. package/build/types/errors/err_nice_action.d.ts +0 -96
  126. package/build/types/index.d.ts +0 -43
  127. package/build/types/nice_action.static.d.ts +0 -3
  128. package/build/types/react-query/hooks/useActionMutation.d.ts +0 -10
  129. package/build/types/react-query/hooks/useActionQuery.d.ts +0 -17
  130. package/build/types/react-query/index.d.ts +0 -2
  131. package/build/types/utils/assertIsActionJson.d.ts +0 -2
  132. package/build/types/utils/decodeActionFrame.d.ts +0 -17
  133. package/build/types/utils/getAssumedRuntimeEnvironment.d.ts +0 -2
  134. package/build/types/utils/hashPayloadData.d.ts +0 -5
  135. package/build/types/utils/isActionPayload_Any_JsonObject.d.ts +0 -2
  136. package/build/types/utils/isActionPayload_Progress_JsonObject.d.ts +0 -2
  137. package/build/types/utils/isActionPayload_Request_JsonObject.d.ts +0 -2
  138. package/build/types/utils/isActionPayload_Result_JsonObject.d.ts +0 -2
  139. package/build/types/utils/isAction_Any_Instance.d.ts +0 -3
  140. package/build/types/utils/isAction_Any_JsonObject.d.ts +0 -2
  141. package/build/types/utils/isAction_Base_JsonObject.d.ts +0 -2
  142. package/build/types/utils/isAction_Context_JsonObject.d.ts +0 -2
  143. package/build/types/utils/isAction_Core_JsonObject.d.ts +0 -2
  144. package/build/types/utils/typescript/MaybePromise.d.ts +0 -1
  145. package/build/types/utils/wait.utils.d.ts +0 -13
@@ -1,187 +0,0 @@
1
- import { type ClientCryptoKeyLink, type StorageAdapter, type TSerializedCryptoKeyData_Ed25519_Raw, type TSerializedCryptoKeyData_X25519_Raw, type TTypeAndId } from "@nice-code/util";
2
- import * as v from "valibot";
3
- import { type IRuntimeCoordinate } from "../../../../RuntimeCoordinate";
4
- /** How much the channel protects after the handshake — chosen by the consumer (perf vs security). */
5
- export declare enum ESecurityLevel {
6
- /** No handshake; identity is self-asserted (fastest, dev / trusted networks). */
7
- none = "none",
8
- /** Handshake authenticates identity (sign/verify + key pin); frames stay plaintext over TLS. */
9
- authenticated = "authenticated",
10
- /** Authenticated handshake + every frame AES-GCM encrypted with the derived shared key. */
11
- encrypted = "encrypted"
12
- }
13
- export declare enum EHandshakeMessageType {
14
- hello = "hello",
15
- welcome = "welcome",
16
- prove = "prove",
17
- accept = "accept",
18
- reject = "reject"
19
- }
20
- declare const vHsHello: v.ObjectSchema<{
21
- readonly t: v.LiteralSchema<EHandshakeMessageType.hello, undefined>;
22
- readonly protocol: v.StringSchema<undefined>;
23
- readonly securityLevel: v.PicklistSchema<[ESecurityLevel.none, ESecurityLevel.authenticated, ESecurityLevel.encrypted], undefined>;
24
- readonly dictionaryVersion: v.StringSchema<undefined>;
25
- readonly client: v.ObjectSchema<{
26
- readonly envId: v.StringSchema<undefined>;
27
- readonly perId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
28
- readonly insId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
29
- }, undefined>;
30
- readonly clientNonce: v.StringSchema<undefined>;
31
- readonly verifyPublicKey: v.CustomSchema<`ed25519::raw_base64::${string}`, undefined>;
32
- readonly exchangePublicKey: v.OptionalSchema<v.CustomSchema<`x25519::raw_base64::${string}`, undefined>, undefined>;
33
- }, undefined>;
34
- declare const vHsWelcome: v.ObjectSchema<{
35
- readonly t: v.LiteralSchema<EHandshakeMessageType.welcome, undefined>;
36
- readonly securityLevel: v.PicklistSchema<[ESecurityLevel.none, ESecurityLevel.authenticated, ESecurityLevel.encrypted], undefined>;
37
- readonly dictionaryVersion: v.StringSchema<undefined>;
38
- readonly server: v.ObjectSchema<{
39
- readonly envId: v.StringSchema<undefined>;
40
- readonly perId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
41
- readonly insId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
42
- }, undefined>;
43
- readonly serverNonce: v.StringSchema<undefined>;
44
- readonly verifyPublicKey: v.CustomSchema<`ed25519::raw_base64::${string}`, undefined>;
45
- readonly exchangePublicKey: v.OptionalSchema<v.CustomSchema<`x25519::raw_base64::${string}`, undefined>, undefined>;
46
- }, undefined>;
47
- declare const vHsProve: v.ObjectSchema<{
48
- readonly t: v.LiteralSchema<EHandshakeMessageType.prove, undefined>;
49
- readonly signatureBase64: v.StringSchema<undefined>;
50
- }, undefined>;
51
- declare const vHsAccept: v.ObjectSchema<{
52
- readonly t: v.LiteralSchema<EHandshakeMessageType.accept, undefined>;
53
- readonly signatureBase64: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
54
- }, undefined>;
55
- declare const vHsReject: v.ObjectSchema<{
56
- readonly t: v.LiteralSchema<EHandshakeMessageType.reject, undefined>;
57
- readonly reason: v.StringSchema<undefined>;
58
- }, undefined>;
59
- declare const vHandshakeMessage: v.VariantSchema<"t", [v.ObjectSchema<{
60
- readonly t: v.LiteralSchema<EHandshakeMessageType.hello, undefined>;
61
- readonly protocol: v.StringSchema<undefined>;
62
- readonly securityLevel: v.PicklistSchema<[ESecurityLevel.none, ESecurityLevel.authenticated, ESecurityLevel.encrypted], undefined>;
63
- readonly dictionaryVersion: v.StringSchema<undefined>;
64
- readonly client: v.ObjectSchema<{
65
- readonly envId: v.StringSchema<undefined>;
66
- readonly perId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
67
- readonly insId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
68
- }, undefined>;
69
- readonly clientNonce: v.StringSchema<undefined>;
70
- readonly verifyPublicKey: v.CustomSchema<`ed25519::raw_base64::${string}`, undefined>;
71
- readonly exchangePublicKey: v.OptionalSchema<v.CustomSchema<`x25519::raw_base64::${string}`, undefined>, undefined>;
72
- }, undefined>, v.ObjectSchema<{
73
- readonly t: v.LiteralSchema<EHandshakeMessageType.welcome, undefined>;
74
- readonly securityLevel: v.PicklistSchema<[ESecurityLevel.none, ESecurityLevel.authenticated, ESecurityLevel.encrypted], undefined>;
75
- readonly dictionaryVersion: v.StringSchema<undefined>;
76
- readonly server: v.ObjectSchema<{
77
- readonly envId: v.StringSchema<undefined>;
78
- readonly perId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
79
- readonly insId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
80
- }, undefined>;
81
- readonly serverNonce: v.StringSchema<undefined>;
82
- readonly verifyPublicKey: v.CustomSchema<`ed25519::raw_base64::${string}`, undefined>;
83
- readonly exchangePublicKey: v.OptionalSchema<v.CustomSchema<`x25519::raw_base64::${string}`, undefined>, undefined>;
84
- }, undefined>, v.ObjectSchema<{
85
- readonly t: v.LiteralSchema<EHandshakeMessageType.prove, undefined>;
86
- readonly signatureBase64: v.StringSchema<undefined>;
87
- }, undefined>, v.ObjectSchema<{
88
- readonly t: v.LiteralSchema<EHandshakeMessageType.accept, undefined>;
89
- readonly signatureBase64: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
90
- }, undefined>, v.ObjectSchema<{
91
- readonly t: v.LiteralSchema<EHandshakeMessageType.reject, undefined>;
92
- readonly reason: v.StringSchema<undefined>;
93
- }, undefined>], undefined>;
94
- export type THsHello = v.InferOutput<typeof vHsHello>;
95
- export type THsWelcome = v.InferOutput<typeof vHsWelcome>;
96
- export type THsProve = v.InferOutput<typeof vHsProve>;
97
- export type THsAccept = v.InferOutput<typeof vHsAccept>;
98
- export type THsReject = v.InferOutput<typeof vHsReject>;
99
- export type THandshakeMessage = v.InferOutput<typeof vHandshakeMessage>;
100
- /** Serialize a handshake message for the wire (handshake frames are JSON — they aren't the hot path). */
101
- export declare function encodeHandshakeMessage(message: THandshakeMessage): string;
102
- /** Parse + structurally validate an incoming handshake frame; `undefined` if it isn't one. */
103
- export declare function decodeHandshakeMessage(raw: string): THandshakeMessage | undefined;
104
- /** Stable link id for a runtime coordinate — the key both the crypto link and the connection use. */
105
- export declare function runtimeLinkId(coordinate: IRuntimeCoordinate): TTypeAndId;
106
- /**
107
- * Everything needed to re-derive the shared AES-GCM key for an `encrypted` link after a restart —
108
- * the remote's public keys + the HKDF salt/info used at handshake time. The local (server) key pair is
109
- * recovered from its own persisted `ClientCryptoKeyLink` storage, so re-linking with this material
110
- * yields the identical shared key without a fresh handshake.
111
- */
112
- export interface IHandshakeEncryptionKeyMaterial {
113
- verifyPublicKey: TSerializedCryptoKeyData_Ed25519_Raw;
114
- exchangePublicKey: TSerializedCryptoKeyData_X25519_Raw;
115
- saltString: string;
116
- infoString: string;
117
- bindVerifyKeysIntoDerivation: boolean;
118
- }
119
- /** Outcome of a completed handshake — what the transport/handler needs to wire the channel. */
120
- export interface IHandshakeResult {
121
- /** The crypto-link id (and connection-registry key) for the authenticated remote. */
122
- linkedClientId: TTypeAndId;
123
- /** The remote's authenticated coordinate. */
124
- remote: IRuntimeCoordinate;
125
- securityLevel: ESecurityLevel;
126
- /** For the `encrypted` level: material to restore the shared key after eviction (persist it). */
127
- encryptionKeyMaterial?: IHandshakeEncryptionKeyMaterial;
128
- }
129
- export interface IClientVerifyKeyResolveInput {
130
- client: IRuntimeCoordinate;
131
- verifyPublicKey: TSerializedCryptoKeyData_Ed25519_Raw;
132
- }
133
- export interface IClientVerifyKeyResolver {
134
- /**
135
- * Decide whether a presented verify key is trusted for a client identity. The signature is already
136
- * verified by the time this runs, so this is purely the identity-pinning decision. Swap in a
137
- * persistent / pre-provisioned implementation without touching the protocol.
138
- */
139
- resolve(input: IClientVerifyKeyResolveInput): Promise<{
140
- trusted: boolean;
141
- reason?: string;
142
- }>;
143
- }
144
- /**
145
- * In-memory trust-on-first-use resolver: trusts (and pins) the first verify key seen for a client
146
- * identity, then rejects a different key for that identity. The default; replace with a storage-backed
147
- * resolver for cross-restart pinning (see Step 5).
148
- */
149
- export declare function createInMemoryTofuVerifyKeyResolver(): IClientVerifyKeyResolver;
150
- /**
151
- * Storage-backed trust-on-first-use resolver: pins survive process restarts / Durable Object eviction
152
- * (e.g. back it with `createDurableObjectStorageAdapter`). Same policy as the in-memory variant — trust
153
- * + pin the first verify key per client identity, reject a different one thereafter.
154
- */
155
- export declare function createStorageTofuVerifyKeyResolver(storageAdapter: StorageAdapter): IClientVerifyKeyResolver;
156
- export interface IClientHandshakeConfig {
157
- link: ClientCryptoKeyLink;
158
- localCoordinate: IRuntimeCoordinate;
159
- dictionaryVersion: string;
160
- securityLevel: ESecurityLevel;
161
- }
162
- export declare function createClientHandshake(config: IClientHandshakeConfig): {
163
- createHello(): Promise<THsHello>;
164
- onWelcome(welcome: THsWelcome): Promise<THsProve>;
165
- onAccept(accept: THsAccept): Promise<IHandshakeResult>;
166
- };
167
- export interface IServerHandshakeConfig {
168
- link: ClientCryptoKeyLink;
169
- localCoordinate: IRuntimeCoordinate;
170
- dictionaryVersion: string;
171
- /**
172
- * The level(s) this server accepts. A single level is strict (the client must match). An array is a
173
- * negotiable allowed set — the server adopts whichever level the client requests, as long as it's in
174
- * the set (lets one backend serve `authenticated` and `encrypted` clients at once). `none` in the set
175
- * is handled by the transport/handler (a `none` client never reaches the handshake).
176
- */
177
- securityLevel: ESecurityLevel | readonly ESecurityLevel[];
178
- /** Trust decision for a client's verify key. Defaults to in-memory TOFU. */
179
- verifyKeyResolver?: IClientVerifyKeyResolver;
180
- }
181
- export declare function createServerHandshake(config: IServerHandshakeConfig): {
182
- onHello(hello: THsHello): Promise<THsWelcome | THsReject>;
183
- onProve(prove: THsProve): Promise<THsAccept | THsReject>;
184
- /** The completed handshake result once `onProve` has accepted, else `undefined`. */
185
- getResult(): IHandshakeResult | undefined;
186
- };
187
- export {};
@@ -1,20 +0,0 @@
1
- import type { ActionDomain } from "../../../../../ActionDefinition/Domain/ActionDomain";
2
- import type { IActionTransportReadyData_Ws } from "./TransportWebSocket.types";
3
- /**
4
- * Builds a *stateless* `formatMessage` pipeline for {@link WebSocketTransport}, packing action
5
- * payloads into a compact msgpackr binary frame instead of JSON. The `domain`/`id` route collapses to
6
- * a single integer drawn from a shared dictionary; `form`/`type`, the recomputable
7
- * `inputHash`/`outputHash`, and the per-frame `context.routing`/`context.timeCreated` are all dropped
8
- * (see {@link ENVELOPE}).
9
- *
10
- * No validation runs here: `incoming` blindly reconstructs the wire JSON shape and hands it back to
11
- * the connection, which flows into `ActionRuntime` → `domain.hydrateAnyAction()` where the Valibot
12
- * schemas validate it exactly as they would for a JSON frame.
13
- *
14
- * Both ends of the socket MUST construct the adapter with the same domains in the same order — the
15
- * integer dictionary is positional. Mismatched dictionaries will route to the wrong action.
16
- *
17
- * Because `incoming` returns `undefined` for text frames, a binary server can still serve plain-JSON
18
- * clients on the same runtime (the connection falls back to its built-in JSON parser).
19
- */
20
- export declare function createBinaryWsAdapter(domains: ActionDomain<any>[]): NonNullable<IActionTransportReadyData_Ws["formatMessage"]>;
@@ -1,31 +0,0 @@
1
- import type { ActionDomain } from "../../../../../ActionDefinition/Domain/ActionDomain";
2
- import type { IActionTransportReadyData_Ws } from "./TransportWebSocket.types";
3
- type TFormatMessage = NonNullable<IActionTransportReadyData_Ws["formatMessage"]>;
4
- export interface IBinaryWsSessionOptions {
5
- /** Override how long an unresolved correlation is retained before being swept (ms). */
6
- correlationTtlMs?: number;
7
- }
8
- /**
9
- * Builds a factory of *stateful, per-connection* codecs for {@link WebSocketTransport} /
10
- * `ActionServerHandler` — the maximally compact binary wire. Call the returned factory once per live
11
- * connection (each socket on the client, each accepted connection on the server) so every channel
12
- * gets its own correlation + identity state.
13
- *
14
- * On top of everything {@link createBinaryWsAdapter} drops, a session also drops:
15
- * - **`cuid`** — replaced by a per-connection integer correlation id. The initiator maps it to its
16
- * real cuid; the responder echoes it; each side reconstructs the cuid from its own map. Correlation
17
- * only needs to be unique per socket, so a counter suffices.
18
- * - **`originClient` after the first request** — the first request each side sends carries its
19
- * identity; the peer remembers it and injects it into later frames. Replies omit it entirely (a
20
- * reply carries the initiator's own origin, which the initiator already knows).
21
- *
22
- * Both ends MUST build the factory from the same domains in the same order (positional dictionary).
23
- * Text frames still return `undefined` from `incoming`, so JSON clients remain interoperable.
24
- *
25
- * Hibernation note: after a server connection is evicted its session resets, so a still-connected
26
- * client (whose session persists) will keep omitting `originClient`. The server must therefore restore
27
- * the connection→client binding from its own store (see `ActionServerHandler.rehydrateConnection`) and
28
- * inject `originClient` from there — the session alone can't recover it.
29
- */
30
- export declare function createBinaryWsSessionFactory(domains: ActionDomain<any>[], options?: IBinaryWsSessionOptions): () => TFormatMessage;
31
- export {};
@@ -1,63 +0,0 @@
1
- import { type StorageAdapter } from "@nice-code/util";
2
- import type { ActionDomain } from "../../../../../ActionDefinition/Domain/ActionDomain";
3
- import type { ActionRuntime } from "../../../../ActionRuntime";
4
- import type { ITransportRouteActionParams, ITransportRouteInfo, TUpdateActionRunConfig } from "../Transport.types";
5
- import { ESecurityLevel } from "./actionWsHandshake";
6
- import { type IBinaryWsSessionOptions } from "./createBinaryWsSessionFactory";
7
- import type { IActionTransportReadyData_Ws } from "./TransportWebSocket.types";
8
- import { WebSocketTransport } from "./WebSocketTransport";
9
- /** The per-connection binary session codec — built once per socket from the channel's domains. */
10
- type TChannelCodec = NonNullable<IActionTransportReadyData_Ws["formatMessage"]>;
11
- /**
12
- * The shared identity of a secure WebSocket channel: the wire dictionary version both ends check
13
- * during the handshake, plus the per-connection codec factory both ends build from the *same* domain
14
- * list. Define it once (typically in code shared by client and server) and hand it to
15
- * {@link createSecureWebSocketTransport} on the client and `createSecureActionServerHandler` on the
16
- * server, so the codec and version can never drift apart.
17
- */
18
- export interface ISecureWsChannel {
19
- /** Wire dictionary version — derived from the domains by default; the handshake rejects a mismatch. */
20
- dictionaryVersion: string;
21
- /** Per-connection session codec factory (call once per live connection). */
22
- createCodec: () => TChannelCodec;
23
- }
24
- /**
25
- * Bundle a secure channel's shared identity from its transported domains. Both ends MUST call this
26
- * with the same domains in the same order (the binary wire dictionary is positional). The
27
- * `dictionaryVersion` is derived from those domains unless you pin an explicit one.
28
- */
29
- export declare function defineSecureWsChannel(options: {
30
- /** Domains transported over this channel, in a stable order. Add new ones to the *end*. */
31
- domains: ActionDomain<any>[];
32
- /** Pin a human-readable version instead of the derived hash (must match on both ends). */
33
- dictionaryVersion?: string;
34
- /** Tuning for the per-connection binary session (e.g. correlation TTL). */
35
- sessionOptions?: IBinaryWsSessionOptions;
36
- }): ISecureWsChannel;
37
- export interface ISecureWebSocketTransportOptions {
38
- /** The shared channel identity (codec + dictionary version). */
39
- channel: ISecureWsChannel;
40
- /** This client's runtime — its coordinate is the authenticated identity sent in the handshake. */
41
- runtime: ActionRuntime;
42
- /** Backing store for this client's crypto identity (a stable verify key across reloads). */
43
- storageAdapter: StorageAdapter;
44
- /** The level this client requests; the server must allow it. */
45
- securityLevel: ESecurityLevel;
46
- /** Endpoint URL — drives both the socket and the per-endpoint cache key. */
47
- url: string;
48
- /** Override socket creation (defaults to a `new WebSocket(url)` with `binaryType = "arraybuffer"`). */
49
- createWebSocket?: (input: ITransportRouteActionParams) => WebSocket;
50
- /** Override the reuse key (defaults to `[url]`, so one socket is shared per endpoint). */
51
- getTransportCacheKey?: (input: ITransportRouteActionParams) => string[];
52
- updateRunConfig?: TUpdateActionRunConfig;
53
- getRouteInfo?: (input: ITransportRouteActionParams) => ITransportRouteInfo;
54
- }
55
- /**
56
- * Build a {@link WebSocketTransport} for the secure binary channel with the boilerplate folded in: it
57
- * creates the {@link ClientCryptoKeyLink} from `storageAdapter`, opens an `arraybuffer` socket to
58
- * `url`, caches it per endpoint, installs the channel's per-connection codec, and assembles the
59
- * `security` block from the runtime coordinate + channel version. Pass `createWebSocket` /
60
- * `getTransportCacheKey` to take over those bits when you need to.
61
- */
62
- export declare function createSecureWebSocketTransport(options: ISecureWebSocketTransportOptions): WebSocketTransport;
63
- export {};
@@ -1,11 +0,0 @@
1
- /**
2
- * Send a text or binary frame over a socket. A binary formatter may hand back a `Uint8Array` whose
3
- * backing buffer is typed as `ArrayBufferLike` (msgpackr pools buffers / may be `SharedArrayBuffer`),
4
- * which `WebSocket.send`'s `BufferSource` parameter rejects — copy it into a fresh `ArrayBuffer`-backed
5
- * view so the type (and the bytes) are safe to send.
6
- */
7
- export declare function sendFrame(ws: WebSocket, data: string | Uint8Array | ArrayBuffer): void;
8
- /** Normalize any frame form to bytes (for the AES-GCM layer, which works on `Uint8Array`). */
9
- export declare function toFrameBytes(frame: string | Uint8Array | ArrayBuffer): Uint8Array;
10
- /** Compact a WebSocket URL to `host/pathname` for devtools display, falling back to the raw url. */
11
- export declare function shortWs(url: string): string;
@@ -1,36 +0,0 @@
1
- import type { ETransportType } from "./Transport.types";
2
- export declare enum EErrId_NiceTransport {
3
- timeout = "timeout",
4
- not_found = "not_found",
5
- unsupported = "unsupported",
6
- initialization_failed = "initialization_failed",
7
- send_failed = "send_failed",
8
- invalid_action_response = "invalid_action_response"
9
- }
10
- export declare const err_nice_transport: import("@nice-code/error").NiceErrorDomain<{
11
- domain: string;
12
- allDomains: [string, string, string, "err_nice"];
13
- schema: {
14
- timeout: import("@nice-code/error").INiceErrorIdMetadata<{
15
- timeout: number;
16
- }, import("@nice-code/error").JSONSerializableValue>;
17
- not_found: import("@nice-code/error").INiceErrorIdMetadata<{
18
- actionId: string;
19
- }, import("@nice-code/error").JSONSerializableValue>;
20
- unsupported: import("@nice-code/error").INiceErrorIdMetadata<{
21
- transportTypes: ETransportType[];
22
- }, import("@nice-code/error").JSONSerializableValue>;
23
- initialization_failed: import("@nice-code/error").INiceErrorIdMetadata<{
24
- actionId: string;
25
- }, import("@nice-code/error").JSONSerializableValue>;
26
- send_failed: import("@nice-code/error").INiceErrorIdMetadata<{
27
- actionState: string;
28
- actionId: string;
29
- httpStatusCode?: number;
30
- message?: string;
31
- }, import("@nice-code/error").JSONSerializableValue>;
32
- invalid_action_response: import("@nice-code/error").INiceErrorIdMetadata<{
33
- actionId: string;
34
- }, import("@nice-code/error").JSONSerializableValue>;
35
- };
36
- }>;
@@ -1,18 +0,0 @@
1
- export declare enum EErrId_NiceTransport_WebSocket {
2
- ws_disconnected = "ws_disconnected",
3
- ws_create_failed = "ws_create_failed",
4
- ws_error = "ws_error"
5
- }
6
- export declare const err_nice_transport_ws: import("@nice-code/error").NiceErrorDomain<{
7
- domain: string;
8
- allDomains: [string, string, string, string, "err_nice"];
9
- schema: {
10
- ws_disconnected: import("@nice-code/error").INiceErrorIdMetadata<Record<string, never>, import("@nice-code/error").JSONSerializableValue>;
11
- ws_create_failed: import("@nice-code/error").INiceErrorIdMetadata<{
12
- originalError?: Error;
13
- }, import("@nice-code/error").JSONSerializableValue>;
14
- ws_error: import("@nice-code/error").INiceErrorIdMetadata<{
15
- originalError?: Error;
16
- }, import("@nice-code/error").JSONSerializableValue>;
17
- };
18
- }>;
@@ -1,2 +0,0 @@
1
- import { type IActionTransportReadyData_Base, type TTransportStatusInfo, type TTransportStatusInfo_GetTransport_Output } from "../Transport.types";
2
- export declare function addTransportStatusMetadata<READY extends IActionTransportReadyData_Base>(transportStatus: TTransportStatusInfo_GetTransport_Output<READY>): TTransportStatusInfo<READY>;
@@ -1,2 +0,0 @@
1
- import type { ETransportType, IActionTransportResolvers } from "../Transport.types";
2
- export declare const createUnsetTransportResolvers: (type: ETransportType) => IActionTransportResolvers;
@@ -1,5 +0,0 @@
1
- export declare const err_nice_external_client: import("@nice-code/error").NiceErrorDomain<{
2
- domain: string;
3
- allDomains: [string, string, "err_nice"];
4
- schema: {};
5
- }>;
@@ -1,55 +0,0 @@
1
- import type { ActionCore } from "../../../ActionDefinition/Action/Core/ActionCore";
2
- import type { IActionRouteItemHandler } from "../../../ActionDefinition/Action/Payload/ActionPayload.types";
3
- import { ActionPayload_Request } from "../../../ActionDefinition/Action/Payload/ActionPayload_Request";
4
- import { RunningAction } from "../../../ActionDefinition/Action/RunningAction";
5
- import type { ActionDomain } from "../../../ActionDefinition/Domain/ActionDomain";
6
- import type { IActionDomain } from "../../../ActionDefinition/Domain/ActionDomain.types";
7
- import { ActionRouter } from "../../Routing/ActionRouter";
8
- import { ActionHandler } from "../ActionHandler";
9
- import { EActionHandlerType, type IActionHandler_Local, type IActionHandler_Local_Json, type IHandleActionOptions } from "../ActionHandler.types";
10
- import type { THandleActionExecutionFn } from "./ActionLocalHandler.types";
11
- export declare class ActionLocalHandler extends ActionHandler<EActionHandlerType.local> implements IActionHandler_Local {
12
- readonly handlerType = EActionHandlerType.local;
13
- readonly actionRouter: ActionRouter<THandleActionExecutionFn<any, any>>;
14
- constructor();
15
- /**
16
- * Register a handler for all actions in a domain.
17
- * Receives the full primed action — use `matchAction()` to narrow to a specific action id.
18
- * Useful for forwarding all domain actions to a remote endpoint.
19
- * Lower priority than `forAction`.
20
- */
21
- forDomain<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, handler: THandleActionExecutionFn<FOR_DOM>): this;
22
- /**
23
- * Register a handler for a base action instance. Takes priority over domain-wide handlers.
24
- * Receives the full primed action with narrowed input type.
25
- * Useful for handling specific actions locally while forwarding the rest of the domain. For example, a local "ping" action that checks connectivity without needing a round trip.
26
- */
27
- forAction<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actionSchema"] & string>(action: ActionCore<ACT_DOM, ID>, handler: THandleActionExecutionFn<ACT_DOM, ID>): this;
28
- /**
29
- * Register a handler for multiple action IDs (first-match-wins among cases).
30
- * Receives the full primed action narrowed to the union of those IDs.
31
- * Use `act.coreAction.id` to branch on which action was dispatched.
32
- */
33
- forActionIds<ACT_DOM extends IActionDomain, IDS extends ReadonlyArray<keyof ACT_DOM["actionSchema"] & string>>(domain: ActionDomain<ACT_DOM>, ids: IDS, handler: THandleActionExecutionFn<ACT_DOM, IDS[number]>): this;
34
- /**
35
- * Register per-action handlers for a domain using a single map, without needing
36
- * separate `forAction` calls. Unregistered action IDs are unaffected.
37
- *
38
- * @example
39
- * ```ts
40
- * handler.forDomainActionCases(userDomain, {
41
- * getUser: (primed) => db.getUser(primed.input.userId),
42
- * deleteUser: (primed) => db.deleteUser(primed.input.userId),
43
- * });
44
- * ```
45
- */
46
- forDomainActionCases<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, cases: {
47
- [ID in keyof FOR_DOM["actionSchema"] & string]?: THandleActionExecutionFn<FOR_DOM, ID>;
48
- }): this;
49
- handleActionRequest<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionPayload_Request<DOM, ID>, config?: IHandleActionOptions): Promise<RunningAction<DOM, ID>>;
50
- private _handleRunningAction;
51
- handlePayloadWireOrThrow(wire: unknown, config?: IHandleActionOptions): Promise<RunningAction<any, any>>;
52
- toJsonObject(): IActionHandler_Local_Json;
53
- toHandlerRouteItem(): IActionRouteItemHandler;
54
- }
55
- export declare const createLocalHandler: () => ActionLocalHandler;
@@ -1,7 +0,0 @@
1
- import type { MaybePromise } from "bun";
2
- import type { TDistributeActionPayload_Request } from "../../../ActionDefinition/Action/Action.combined.types";
3
- import type { IActionPayload_Result_JsonObject } from "../../../ActionDefinition/Action/Payload/ActionPayload.types";
4
- import type { ActionPayload_Result } from "../../../ActionDefinition/Action/Payload/ActionPayload_Result";
5
- import type { IActionDomain, TInferOutputFromSchema } from "../../../ActionDefinition/Domain/ActionDomain.types";
6
- export type { TDistributeActionPayload_Request };
7
- export type THandleActionExecutionFn<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = (action: TDistributeActionPayload_Request<DOM, ID>) => MaybePromise<ActionPayload_Result<DOM, ID> | IActionPayload_Result_JsonObject<DOM, ID> | TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"] | undefined>;