@xyo-network/dapp-kit-port 0.1.2

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 (30) hide show
  1. package/README.md +23 -0
  2. package/dist/browser/applicationPortClient.d.ts +6 -0
  3. package/dist/browser/applicationPortClient.d.ts.map +1 -0
  4. package/dist/browser/applicationPortHost.d.ts +10 -0
  5. package/dist/browser/applicationPortHost.d.ts.map +1 -0
  6. package/dist/browser/applicationPortModel.d.ts +154 -0
  7. package/dist/browser/applicationPortModel.d.ts.map +1 -0
  8. package/dist/browser/applicationPortWire.d.ts +327 -0
  9. package/dist/browser/applicationPortWire.d.ts.map +1 -0
  10. package/dist/browser/index.d.ts +6 -0
  11. package/dist/browser/index.d.ts.map +1 -0
  12. package/dist/browser/index.mjs +1180 -0
  13. package/dist/browser/index.mjs.map +7 -0
  14. package/dist/browser/webSocketApplicationPortClient.d.ts +46 -0
  15. package/dist/browser/webSocketApplicationPortClient.d.ts.map +1 -0
  16. package/dist/node/applicationPortClient.d.ts +6 -0
  17. package/dist/node/applicationPortClient.d.ts.map +1 -0
  18. package/dist/node/applicationPortHost.d.ts +10 -0
  19. package/dist/node/applicationPortHost.d.ts.map +1 -0
  20. package/dist/node/applicationPortModel.d.ts +154 -0
  21. package/dist/node/applicationPortModel.d.ts.map +1 -0
  22. package/dist/node/applicationPortWire.d.ts +327 -0
  23. package/dist/node/applicationPortWire.d.ts.map +1 -0
  24. package/dist/node/index.d.ts +6 -0
  25. package/dist/node/index.d.ts.map +1 -0
  26. package/dist/node/index.mjs +1180 -0
  27. package/dist/node/index.mjs.map +7 -0
  28. package/dist/node/webSocketApplicationPortClient.d.ts +46 -0
  29. package/dist/node/webSocketApplicationPortClient.d.ts.map +1 -0
  30. package/package.json +74 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # `@xyo-network/dapp-kit-port`
2
+
3
+ Shared application-port client and host peers for browser and Node transports.
4
+
5
+ The package owns protocol state for unary requests, acknowledged cancellation,
6
+ bounded-credit streams, exact redelivery checks, and durable resume cursors.
7
+ Every frame is validated against its attachment grant, plan, system
8
+ incarnation, host session, request, port, operation, and deadline before domain
9
+ delivery.
10
+
11
+ The peers depend only on a small message-endpoint interface. Platform packages
12
+ adapt `MessagePort`, WebSocket, or future native transports to that interface;
13
+ they do not duplicate the protocol state machine. Actor and provider locators
14
+ never cross the endpoint.
15
+
16
+ The package also owns the transport-neutral WebSocket wire mapping. Frames are
17
+ strict I-JSON text messages with canonical serialization, a negotiated byte
18
+ limit, and an attachment `hello` that carries the existing grant. The shared
19
+ `connectWebSocketApplicationPort()` client works with browser `WebSocket` and
20
+ compatible Node implementations. It verifies the expected dApp, plan, protocol
21
+ version, and grant lifetime before publishing an `ApplicationPortClient`.
22
+ Transport loss rejects pending unary and streaming work; reconnecting creates a
23
+ new attachment and resumes only through the existing cursor protocol.
@@ -0,0 +1,6 @@
1
+ import type { ApplicationPortClient, ApplicationPortPeerOptions } from './applicationPortModel.ts';
2
+ export interface CreateApplicationPortClientOptions extends ApplicationPortPeerOptions {
3
+ readonly nextRequestId: () => string;
4
+ }
5
+ export declare function createApplicationPortClient(options: CreateApplicationPortClientOptions): ApplicationPortClient;
6
+ //# sourceMappingURL=applicationPortClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicationPortClient.d.ts","sourceRoot":"","sources":["../../src/applicationPortClient.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,qBAAqB,EACrB,0BAA0B,EAO3B,MAAM,2BAA2B,CAAA;AAWlC,MAAM,WAAW,kCAAmC,SAAQ,0BAA0B;IACpF,QAAQ,CAAC,aAAa,EAAE,MAAM,MAAM,CAAA;CACrC;AA+cD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,kCAAkC,GAAG,qBAAqB,CAE9G"}
@@ -0,0 +1,10 @@
1
+ import type { ApplicationPortErrorData, ApplicationPortOperation, ApplicationPortPeerOptions } from './applicationPortModel.ts';
2
+ export interface CreateApplicationPortHostOptions extends ApplicationPortPeerOptions {
3
+ readonly mapError: (error: unknown) => ApplicationPortErrorData;
4
+ readonly operations: readonly ApplicationPortOperation[];
5
+ }
6
+ export interface ApplicationPortHost {
7
+ close(): Promise<void>;
8
+ }
9
+ export declare function createApplicationPortHost(options: CreateApplicationPortHostOptions): ApplicationPortHost;
10
+ //# sourceMappingURL=applicationPortHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicationPortHost.d.ts","sourceRoot":"","sources":["../../src/applicationPortHost.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAI3B,MAAM,2BAA2B,CAAA;AAWlC,MAAM,WAAW,gCAAiC,SAAQ,0BAA0B;IAClF,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,wBAAwB,CAAA;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,wBAAwB,EAAE,CAAA;CACzD;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAmbD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gCAAgC,GAAG,mBAAmB,CAExG"}
@@ -0,0 +1,154 @@
1
+ import type { JsonValue, PortAttachmentGrant, PortConsistencyEvidence, PortFrame, PortFrameIssue, PortOperationGrant } from '@xyo-network/dapp-kit';
2
+ export interface ApplicationPortMessageEndpoint {
3
+ addMessageListener(listener: (message: unknown) => void): void;
4
+ removeMessageListener(listener: (message: unknown) => void): void;
5
+ send(message: unknown): void;
6
+ start?(): void;
7
+ }
8
+ export declare const ApplicationPortProxyErrorCode: {
9
+ readonly cancelled: "port.cancelled";
10
+ readonly detached: "port.detached";
11
+ readonly directionInvalid: "port.direction-invalid";
12
+ readonly duplicateRequest: "port.duplicate-request";
13
+ readonly hostFailure: "port.host-failure";
14
+ readonly operationKindMismatch: "port.operation-kind-mismatch";
15
+ readonly operationUnavailable: "port.operation-unavailable";
16
+ readonly requestUnknown: "port.request-unknown";
17
+ readonly streamStateInvalid: "port.stream-state-invalid";
18
+ };
19
+ export type ApplicationPortProxyErrorCode = typeof ApplicationPortProxyErrorCode[keyof typeof ApplicationPortProxyErrorCode];
20
+ export interface ApplicationPortErrorData {
21
+ readonly code: string;
22
+ readonly details?: JsonValue;
23
+ readonly retriable: boolean;
24
+ }
25
+ export declare class ApplicationPortProxyError extends Error {
26
+ readonly code: ApplicationPortProxyErrorCode;
27
+ readonly issues?: readonly PortFrameIssue[];
28
+ constructor(code: ApplicationPortProxyErrorCode, message: string, issues?: readonly PortFrameIssue[]);
29
+ }
30
+ export declare class ApplicationPortRemoteError extends Error {
31
+ readonly code: string;
32
+ readonly details?: JsonValue;
33
+ readonly retriable: boolean;
34
+ constructor(error: ApplicationPortErrorData);
35
+ }
36
+ export declare class ApplicationPortCancelledError extends Error {
37
+ readonly code: "port.cancelled";
38
+ readonly reasonCode: string;
39
+ constructor(reasonCode: string);
40
+ }
41
+ export interface ApplicationPortProtocolErrorContext {
42
+ readonly cause: ApplicationPortProxyError;
43
+ readonly value: unknown;
44
+ }
45
+ export interface ApplicationPortPeerOptions {
46
+ readonly authenticatedPrincipalId: string;
47
+ readonly endpoint: ApplicationPortMessageEndpoint;
48
+ readonly grant: PortAttachmentGrant;
49
+ readonly now: () => number;
50
+ readonly onProtocolError: (context: ApplicationPortProtocolErrorContext) => void;
51
+ }
52
+ export interface ApplicationPortRequestContext {
53
+ readonly body: JsonValue;
54
+ readonly grant: PortAttachmentGrant;
55
+ readonly requestId: string;
56
+ readonly signal: AbortSignal;
57
+ }
58
+ export interface ApplicationPortUnaryResult {
59
+ readonly body: JsonValue;
60
+ readonly consistency: PortConsistencyEvidence;
61
+ }
62
+ export interface ApplicationPortUnaryOperation {
63
+ readonly operationId: string;
64
+ readonly portId: string;
65
+ readonly streaming: false;
66
+ handle(context: ApplicationPortRequestContext): Promise<ApplicationPortUnaryResult>;
67
+ }
68
+ export interface ApplicationPortStreamItem {
69
+ readonly body: JsonValue;
70
+ readonly consistency: PortConsistencyEvidence;
71
+ readonly resumeCursor?: string;
72
+ }
73
+ export type ApplicationPortStreamRead = {
74
+ readonly done: false;
75
+ readonly value: ApplicationPortStreamItem;
76
+ } | {
77
+ readonly done: true;
78
+ readonly resumeCursor?: string;
79
+ };
80
+ export interface ApplicationPortStreamSource {
81
+ readonly nextSequence: number;
82
+ readonly resumable: boolean;
83
+ readonly resumeCursor?: string;
84
+ readonly streamId: string;
85
+ cancel?(reasonCode: string): Promise<void>;
86
+ next(signal: AbortSignal): Promise<ApplicationPortStreamRead>;
87
+ }
88
+ export interface ApplicationPortStreamResumeContext extends ApplicationPortRequestContext {
89
+ readonly lastAcceptedSequence: number;
90
+ readonly resumeCursor: string;
91
+ readonly streamId: string;
92
+ }
93
+ export interface ApplicationPortStreamOperation {
94
+ readonly operationId: string;
95
+ readonly portId: string;
96
+ readonly streaming: true;
97
+ open(context: ApplicationPortRequestContext): Promise<ApplicationPortStreamSource>;
98
+ resume?(context: ApplicationPortStreamResumeContext): Promise<ApplicationPortStreamSource>;
99
+ }
100
+ export type ApplicationPortOperation = ApplicationPortStreamOperation | ApplicationPortUnaryOperation;
101
+ export interface ApplicationPortRequestOptions {
102
+ readonly body: JsonValue;
103
+ readonly deadlineUnixMs: number;
104
+ readonly operationId: string;
105
+ readonly portId: string;
106
+ readonly signal?: AbortSignal;
107
+ }
108
+ export interface ApplicationPortStreamRequestOptions extends ApplicationPortRequestOptions {
109
+ readonly initialCredit: number;
110
+ }
111
+ export interface ApplicationPortStreamResumeOptions {
112
+ readonly credit: number;
113
+ readonly deadlineUnixMs: number;
114
+ readonly lastAcceptedSequence: number;
115
+ readonly operationId: string;
116
+ readonly portId: string;
117
+ readonly resumeCursor: string;
118
+ readonly signal?: AbortSignal;
119
+ readonly streamId: string;
120
+ }
121
+ export interface ApplicationPortStreamValue extends ApplicationPortStreamItem {
122
+ readonly sequence: number;
123
+ }
124
+ export interface ApplicationPortStream extends AsyncIterableIterator<ApplicationPortStreamValue> {
125
+ readonly requestId: string;
126
+ readonly streamId: string;
127
+ cancel(reasonCode?: string): void;
128
+ credit(value: number): void;
129
+ }
130
+ export interface ApplicationPortClient {
131
+ close(): void;
132
+ request(options: ApplicationPortRequestOptions): Promise<ApplicationPortUnaryResult>;
133
+ resumeStream(options: ApplicationPortStreamResumeOptions): Promise<ApplicationPortStream>;
134
+ stream(options: ApplicationPortStreamRequestOptions): Promise<ApplicationPortStream>;
135
+ }
136
+ export declare function applicationPortOperationKey(portId: string, operationId: string): string;
137
+ export declare function applicationPortOperationGrant(grant: PortAttachmentGrant, portId: string, operationId: string): PortOperationGrant | undefined;
138
+ export declare function applicationPortFrameBase(grant: PortAttachmentGrant, frame: Pick<PortFrame, 'deadlineUnixMs' | 'operationId' | 'portId' | 'requestId'>): {
139
+ schema: "network.xyo.dapp.port.frame";
140
+ schemaVersion: 1;
141
+ dappId: string;
142
+ protocolVersion: string;
143
+ planId: string;
144
+ systemInstanceId: string;
145
+ hostSessionId: string;
146
+ attachmentId: string;
147
+ requestId: string;
148
+ deadlineUnixMs: number;
149
+ portId: string;
150
+ operationId: string;
151
+ };
152
+ export declare function parseApplicationPortFrame(value: unknown): PortFrame;
153
+ export declare function applicationPortErrorFrame(grant: PortAttachmentGrant, frame: PortFrame, error: ApplicationPortErrorData): PortFrame;
154
+ //# sourceMappingURL=applicationPortModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicationPortModel.d.ts","sourceRoot":"","sources":["../../src/applicationPortModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,SAAS,EACT,cAAc,EACd,kBAAkB,EACnB,MAAM,uBAAuB,CAAA;AAG9B,MAAM,WAAW,8BAA8B;IAC7C,kBAAkB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAA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gB,6BAA6B,CAC3C,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,kBAAkB,GAAG,SAAS,CAEhC;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAC;;;;;;;;;;;;;EAgBlF;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAEnE;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,wBAAwB,GAC9B,SAAS,CAMX"}
@@ -0,0 +1,327 @@
1
+ import type { PortFrame } from '@xyo-network/dapp-kit';
2
+ import { z } from 'zod';
3
+ export declare const ApplicationPortTransportSchema: "network.xyo.dapp.port.transport";
4
+ export declare const ApplicationPortTransportHelloZod: z.ZodObject<{
5
+ schema: z.ZodLiteral<"network.xyo.dapp.port.transport">;
6
+ schemaVersion: z.ZodLiteral<1>;
7
+ messageKind: z.ZodLiteral<"hello">;
8
+ maximumFrameBytes: z.ZodNumber;
9
+ grant: z.ZodObject<{
10
+ attachmentId: z.ZodString;
11
+ principalId: z.ZodString;
12
+ dappId: z.ZodString;
13
+ protocolVersion: z.ZodString;
14
+ planId: z.ZodString;
15
+ systemInstanceId: z.ZodString;
16
+ hostSessionId: z.ZodString;
17
+ createdAt: z.ZodNumber;
18
+ lastSeenAt: z.ZodNumber;
19
+ expiresAt: z.ZodNumber;
20
+ leasePolicy: z.ZodEnum<{
21
+ "fixed-expiry": "fixed-expiry";
22
+ "disconnect-expiry": "disconnect-expiry";
23
+ }>;
24
+ operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
25
+ portId: z.ZodString;
26
+ operationId: z.ZodString;
27
+ streaming: z.ZodLiteral<false>;
28
+ }, z.core.$strict>, z.ZodObject<{
29
+ portId: z.ZodString;
30
+ operationId: z.ZodString;
31
+ streaming: z.ZodLiteral<true>;
32
+ resumable: z.ZodBoolean;
33
+ maximumCredit: z.ZodNumber;
34
+ }, z.core.$strict>], "streaming">>;
35
+ }, z.core.$strict>;
36
+ }, z.core.$strict>;
37
+ export type ApplicationPortTransportHello = z.infer<typeof ApplicationPortTransportHelloZod>;
38
+ export declare const ApplicationPortTransportErrorZod: z.ZodObject<{
39
+ schema: z.ZodLiteral<"network.xyo.dapp.port.transport">;
40
+ schemaVersion: z.ZodLiteral<1>;
41
+ messageKind: z.ZodLiteral<"error">;
42
+ code: z.ZodString;
43
+ retriable: z.ZodBoolean;
44
+ }, z.core.$strict>;
45
+ export type ApplicationPortTransportError = z.infer<typeof ApplicationPortTransportErrorZod>;
46
+ export declare const ApplicationPortWireMessageZod: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
47
+ frameKind: z.ZodLiteral<"request">;
48
+ body: z.ZodType<import("@xyo-network/dapp-kit").JsonValue, unknown, z.core.$ZodTypeInternals<import("@xyo-network/dapp-kit").JsonValue, unknown>>;
49
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
50
+ schemaVersion: z.ZodLiteral<1>;
51
+ dappId: z.ZodString;
52
+ protocolVersion: z.ZodString;
53
+ planId: z.ZodString;
54
+ systemInstanceId: z.ZodString;
55
+ hostSessionId: z.ZodString;
56
+ attachmentId: z.ZodString;
57
+ requestId: z.ZodString;
58
+ deadlineUnixMs: z.ZodNumber;
59
+ portId: z.ZodString;
60
+ operationId: z.ZodString;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ frameKind: z.ZodLiteral<"response">;
63
+ consistency: z.ZodDiscriminatedUnion<[z.ZodObject<{
64
+ mode: z.ZodLiteral<"not-applicable">;
65
+ }, z.core.$strict>, z.ZodObject<{
66
+ mode: z.ZodLiteral<"finalized-through">;
67
+ blockNumber: z.ZodNumber;
68
+ blockHash: z.ZodString;
69
+ }, z.core.$strict>, z.ZodObject<{
70
+ mode: z.ZodLiteral<"projection-through">;
71
+ blockNumber: z.ZodNumber;
72
+ blockHash: z.ZodString;
73
+ projectionId: z.ZodString;
74
+ projectionVersion: z.ZodString;
75
+ }, z.core.$strict>, z.ZodObject<{
76
+ mode: z.ZodLiteral<"provisional">;
77
+ blockNumber: z.ZodNumber;
78
+ blockHash: z.ZodString;
79
+ transactionHash: z.ZodString;
80
+ }, z.core.$strict>, z.ZodObject<{
81
+ mode: z.ZodLiteral<"local-ephemeral">;
82
+ }, z.core.$strict>], "mode">;
83
+ body: z.ZodType<import("@xyo-network/dapp-kit").JsonValue, unknown, z.core.$ZodTypeInternals<import("@xyo-network/dapp-kit").JsonValue, unknown>>;
84
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
85
+ schemaVersion: z.ZodLiteral<1>;
86
+ dappId: z.ZodString;
87
+ protocolVersion: z.ZodString;
88
+ planId: z.ZodString;
89
+ systemInstanceId: z.ZodString;
90
+ hostSessionId: z.ZodString;
91
+ attachmentId: z.ZodString;
92
+ requestId: z.ZodString;
93
+ deadlineUnixMs: z.ZodNumber;
94
+ portId: z.ZodString;
95
+ operationId: z.ZodString;
96
+ }, z.core.$strict>, z.ZodObject<{
97
+ frameKind: z.ZodLiteral<"error">;
98
+ error: z.ZodObject<{
99
+ code: z.ZodString;
100
+ retriable: z.ZodBoolean;
101
+ details: z.ZodOptional<z.ZodType<import("@xyo-network/dapp-kit").JsonValue, unknown, z.core.$ZodTypeInternals<import("@xyo-network/dapp-kit").JsonValue, unknown>>>;
102
+ }, z.core.$strict>;
103
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
104
+ schemaVersion: z.ZodLiteral<1>;
105
+ dappId: z.ZodString;
106
+ protocolVersion: z.ZodString;
107
+ planId: z.ZodString;
108
+ systemInstanceId: z.ZodString;
109
+ hostSessionId: z.ZodString;
110
+ attachmentId: z.ZodString;
111
+ requestId: z.ZodString;
112
+ deadlineUnixMs: z.ZodNumber;
113
+ portId: z.ZodString;
114
+ operationId: z.ZodString;
115
+ }, z.core.$strict>, z.ZodObject<{
116
+ frameKind: z.ZodLiteral<"cancel">;
117
+ reasonCode: z.ZodString;
118
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
119
+ schemaVersion: z.ZodLiteral<1>;
120
+ dappId: z.ZodString;
121
+ protocolVersion: z.ZodString;
122
+ planId: z.ZodString;
123
+ systemInstanceId: z.ZodString;
124
+ hostSessionId: z.ZodString;
125
+ attachmentId: z.ZodString;
126
+ requestId: z.ZodString;
127
+ deadlineUnixMs: z.ZodNumber;
128
+ portId: z.ZodString;
129
+ operationId: z.ZodString;
130
+ }, z.core.$strict>, z.ZodObject<{
131
+ frameKind: z.ZodLiteral<"cancel-ack">;
132
+ willEmitNoNewWork: z.ZodLiteral<true>;
133
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
134
+ schemaVersion: z.ZodLiteral<1>;
135
+ dappId: z.ZodString;
136
+ protocolVersion: z.ZodString;
137
+ planId: z.ZodString;
138
+ systemInstanceId: z.ZodString;
139
+ hostSessionId: z.ZodString;
140
+ attachmentId: z.ZodString;
141
+ requestId: z.ZodString;
142
+ deadlineUnixMs: z.ZodNumber;
143
+ portId: z.ZodString;
144
+ operationId: z.ZodString;
145
+ }, z.core.$strict>, z.ZodObject<{
146
+ frameKind: z.ZodLiteral<"stream-open">;
147
+ streamId: z.ZodString;
148
+ delivery: z.ZodLiteral<"at-least-once">;
149
+ resumable: z.ZodBoolean;
150
+ nextSequence: z.ZodNumber;
151
+ resumeCursor: z.ZodOptional<z.ZodString>;
152
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
153
+ schemaVersion: z.ZodLiteral<1>;
154
+ dappId: z.ZodString;
155
+ protocolVersion: z.ZodString;
156
+ planId: z.ZodString;
157
+ systemInstanceId: z.ZodString;
158
+ hostSessionId: z.ZodString;
159
+ attachmentId: z.ZodString;
160
+ requestId: z.ZodString;
161
+ deadlineUnixMs: z.ZodNumber;
162
+ portId: z.ZodString;
163
+ operationId: z.ZodString;
164
+ }, z.core.$strict>, z.ZodObject<{
165
+ frameKind: z.ZodLiteral<"stream-item">;
166
+ streamId: z.ZodString;
167
+ sequence: z.ZodNumber;
168
+ resumeCursor: z.ZodOptional<z.ZodString>;
169
+ consistency: z.ZodDiscriminatedUnion<[z.ZodObject<{
170
+ mode: z.ZodLiteral<"not-applicable">;
171
+ }, z.core.$strict>, z.ZodObject<{
172
+ mode: z.ZodLiteral<"finalized-through">;
173
+ blockNumber: z.ZodNumber;
174
+ blockHash: z.ZodString;
175
+ }, z.core.$strict>, z.ZodObject<{
176
+ mode: z.ZodLiteral<"projection-through">;
177
+ blockNumber: z.ZodNumber;
178
+ blockHash: z.ZodString;
179
+ projectionId: z.ZodString;
180
+ projectionVersion: z.ZodString;
181
+ }, z.core.$strict>, z.ZodObject<{
182
+ mode: z.ZodLiteral<"provisional">;
183
+ blockNumber: z.ZodNumber;
184
+ blockHash: z.ZodString;
185
+ transactionHash: z.ZodString;
186
+ }, z.core.$strict>, z.ZodObject<{
187
+ mode: z.ZodLiteral<"local-ephemeral">;
188
+ }, z.core.$strict>], "mode">;
189
+ body: z.ZodType<import("@xyo-network/dapp-kit").JsonValue, unknown, z.core.$ZodTypeInternals<import("@xyo-network/dapp-kit").JsonValue, unknown>>;
190
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
191
+ schemaVersion: z.ZodLiteral<1>;
192
+ dappId: z.ZodString;
193
+ protocolVersion: z.ZodString;
194
+ planId: z.ZodString;
195
+ systemInstanceId: z.ZodString;
196
+ hostSessionId: z.ZodString;
197
+ attachmentId: z.ZodString;
198
+ requestId: z.ZodString;
199
+ deadlineUnixMs: z.ZodNumber;
200
+ portId: z.ZodString;
201
+ operationId: z.ZodString;
202
+ }, z.core.$strict>, z.ZodObject<{
203
+ frameKind: z.ZodLiteral<"stream-credit">;
204
+ streamId: z.ZodString;
205
+ credit: z.ZodNumber;
206
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
207
+ schemaVersion: z.ZodLiteral<1>;
208
+ dappId: z.ZodString;
209
+ protocolVersion: z.ZodString;
210
+ planId: z.ZodString;
211
+ systemInstanceId: z.ZodString;
212
+ hostSessionId: z.ZodString;
213
+ attachmentId: z.ZodString;
214
+ requestId: z.ZodString;
215
+ deadlineUnixMs: z.ZodNumber;
216
+ portId: z.ZodString;
217
+ operationId: z.ZodString;
218
+ }, z.core.$strict>, z.ZodObject<{
219
+ frameKind: z.ZodLiteral<"stream-close">;
220
+ streamId: z.ZodString;
221
+ lastSequence: z.ZodNumber;
222
+ resumeCursor: z.ZodOptional<z.ZodString>;
223
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
224
+ schemaVersion: z.ZodLiteral<1>;
225
+ dappId: z.ZodString;
226
+ protocolVersion: z.ZodString;
227
+ planId: z.ZodString;
228
+ systemInstanceId: z.ZodString;
229
+ hostSessionId: z.ZodString;
230
+ attachmentId: z.ZodString;
231
+ requestId: z.ZodString;
232
+ deadlineUnixMs: z.ZodNumber;
233
+ portId: z.ZodString;
234
+ operationId: z.ZodString;
235
+ }, z.core.$strict>, z.ZodObject<{
236
+ frameKind: z.ZodLiteral<"stream-error">;
237
+ streamId: z.ZodString;
238
+ lastSequence: z.ZodNumber;
239
+ resumeCursor: z.ZodOptional<z.ZodString>;
240
+ error: z.ZodObject<{
241
+ code: z.ZodString;
242
+ retriable: z.ZodBoolean;
243
+ details: z.ZodOptional<z.ZodType<import("@xyo-network/dapp-kit").JsonValue, unknown, z.core.$ZodTypeInternals<import("@xyo-network/dapp-kit").JsonValue, unknown>>>;
244
+ }, z.core.$strict>;
245
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
246
+ schemaVersion: z.ZodLiteral<1>;
247
+ dappId: z.ZodString;
248
+ protocolVersion: z.ZodString;
249
+ planId: z.ZodString;
250
+ systemInstanceId: z.ZodString;
251
+ hostSessionId: z.ZodString;
252
+ attachmentId: z.ZodString;
253
+ requestId: z.ZodString;
254
+ deadlineUnixMs: z.ZodNumber;
255
+ portId: z.ZodString;
256
+ operationId: z.ZodString;
257
+ }, z.core.$strict>, z.ZodObject<{
258
+ frameKind: z.ZodLiteral<"stream-resume">;
259
+ streamId: z.ZodString;
260
+ lastAcceptedSequence: z.ZodNumber;
261
+ resumeCursor: z.ZodString;
262
+ credit: z.ZodNumber;
263
+ schema: z.ZodLiteral<"network.xyo.dapp.port.frame">;
264
+ schemaVersion: z.ZodLiteral<1>;
265
+ dappId: z.ZodString;
266
+ protocolVersion: z.ZodString;
267
+ planId: z.ZodString;
268
+ systemInstanceId: z.ZodString;
269
+ hostSessionId: z.ZodString;
270
+ attachmentId: z.ZodString;
271
+ requestId: z.ZodString;
272
+ deadlineUnixMs: z.ZodNumber;
273
+ portId: z.ZodString;
274
+ operationId: z.ZodString;
275
+ }, z.core.$strict>], "frameKind">, z.ZodObject<{
276
+ schema: z.ZodLiteral<"network.xyo.dapp.port.transport">;
277
+ schemaVersion: z.ZodLiteral<1>;
278
+ messageKind: z.ZodLiteral<"hello">;
279
+ maximumFrameBytes: z.ZodNumber;
280
+ grant: z.ZodObject<{
281
+ attachmentId: z.ZodString;
282
+ principalId: z.ZodString;
283
+ dappId: z.ZodString;
284
+ protocolVersion: z.ZodString;
285
+ planId: z.ZodString;
286
+ systemInstanceId: z.ZodString;
287
+ hostSessionId: z.ZodString;
288
+ createdAt: z.ZodNumber;
289
+ lastSeenAt: z.ZodNumber;
290
+ expiresAt: z.ZodNumber;
291
+ leasePolicy: z.ZodEnum<{
292
+ "fixed-expiry": "fixed-expiry";
293
+ "disconnect-expiry": "disconnect-expiry";
294
+ }>;
295
+ operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
296
+ portId: z.ZodString;
297
+ operationId: z.ZodString;
298
+ streaming: z.ZodLiteral<false>;
299
+ }, z.core.$strict>, z.ZodObject<{
300
+ portId: z.ZodString;
301
+ operationId: z.ZodString;
302
+ streaming: z.ZodLiteral<true>;
303
+ resumable: z.ZodBoolean;
304
+ maximumCredit: z.ZodNumber;
305
+ }, z.core.$strict>], "streaming">>;
306
+ }, z.core.$strict>;
307
+ }, z.core.$strict>, z.ZodObject<{
308
+ schema: z.ZodLiteral<"network.xyo.dapp.port.transport">;
309
+ schemaVersion: z.ZodLiteral<1>;
310
+ messageKind: z.ZodLiteral<"error">;
311
+ code: z.ZodString;
312
+ retriable: z.ZodBoolean;
313
+ }, z.core.$strict>]>;
314
+ export type ApplicationPortWireMessage = z.infer<typeof ApplicationPortWireMessageZod>;
315
+ export declare const ApplicationPortWireErrorCode: {
316
+ readonly frameTooLarge: "port.wire-frame-too-large";
317
+ readonly invalidMessage: "port.wire-invalid-message";
318
+ };
319
+ export type ApplicationPortWireErrorCode = typeof ApplicationPortWireErrorCode[keyof typeof ApplicationPortWireErrorCode];
320
+ export declare class ApplicationPortWireError extends Error {
321
+ readonly code: ApplicationPortWireErrorCode;
322
+ constructor(code: ApplicationPortWireErrorCode, message: string, options?: ErrorOptions);
323
+ }
324
+ export declare function isApplicationPortFrame(message: ApplicationPortWireMessage): message is PortFrame;
325
+ export declare function parseApplicationPortWireText(source: string, maximumFrameBytes: number): ApplicationPortWireMessage;
326
+ export declare function serializeApplicationPortWireMessage(message: ApplicationPortWireMessage, maximumFrameBytes: number): string;
327
+ //# sourceMappingURL=applicationPortWire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applicationPortWire.d.ts","sourceRoot":"","sources":["../../src/applicationPortWire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAQtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,8BAA8B,EAAG,iCAA0C,CAAA;AAExF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAM3C,CAAA;AAEF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CA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
2
+ export * from './applicationPortHost.ts';
3
+ export * from './applicationPortModel.ts';
4
+ export * from './applicationPortWire.ts';
5
+ export * from './webSocketApplicationPortClient.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qCAAqC,CAAA"}