/** * Defines protocol messages for event-log remote clients and servers. * * This module is the shared boundary between `EventLogRemote` clients and * event-log servers. It defines store ids, protocol errors, the * hello/authenticate session handshake, remote calls for writes and changes, * and message formats for encrypted or plaintext journal entries. * * @stability unstable * @since 4.0.0 */ import type { NonEmptyReadonlyArray } from "../Array.ts"; import type { Brand } from "../Brand.ts"; import * as Effect from "../Effect.ts"; import * as SchemaBinary from "../encoding/SchemaBinary.ts"; import * as Rpc from "../rpc/Rpc.ts"; import * as RpcGroup from "../rpc/RpcGroup.ts"; import * as RpcMiddleware from "../rpc/RpcMiddleware.ts"; import * as Schema from "../Schema.ts"; import type * as SchemaAST from "../SchemaAST.ts"; import * as Transferable from "../workers/Transferable.ts"; import { Entry, RemoteEntry } from "./EventJournal.ts"; import type { Identity } from "./EventLog.ts"; /** * Type-level identifier used to brand event-log store ids. * * @stability unstable * @category type IDs * @since 4.0.0 */ export type StoreIdTypeId = "effect/eventlog/EventLog/StoreId"; /** * Runtime brand identifier for event-log store ids. * * @stability unstable * @category type IDs * @since 4.0.0 */ export declare const StoreIdTypeId: StoreIdTypeId; /** * Branded string identifying a logical event-log store. * * @stability unstable * @category models * @since 4.0.0 */ export type StoreId = string & Brand; /** * Schema for branded event-log store ids. * * @stability unstable * @category schemas * @since 4.0.0 */ export declare const StoreId: Schema.brand; declare const EventLogProtocolError_base: Schema.Class; readonly storeId: Schema.optional>; readonly code: Schema.Literals; readonly message: Schema.String; }>, import("../Cause.ts").YieldableError>; /** * Error returned by event-log remote RPCs. * * **Details** * * It records the request tag, optional identity and store information, a protocol * error code, and a human-readable message. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class EventLogProtocolError extends EventLogProtocolError_base { /** * Returns `true` when the value is an `EventLogProtocolError`. * * @stability unstable * @since 4.0.0 */ static is(u: unknown): u is EventLogProtocolError; } declare const EventLogAuthentication_base: RpcMiddleware.ServiceClass; /** * RPC middleware that authenticates event-log requests and provides the client * `Identity` to authenticated handlers. * * @stability unstable * @category middleware * @since 4.0.0 */ export declare class EventLogAuthentication extends EventLogAuthentication_base { } declare const HelloResponse_base: Schema.Class; readonly challenge: Transferable.Transferable, Uint8Array>>; readonly firstSequence: Schema.optional; }>, {}>; /** * Response sent by the remote server during the authentication handshake. * * **Details** * * Contains the remote id, a challenge for the client to sign, and the lowest * assigned sequence (default 0) for initializing acknowledgement cursors. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class HelloResponse extends HelloResponse_base { } declare const HelloRpc_base: Rpc.Rpc<"EventLog.Hello", Schema.Void, typeof HelloResponse, Schema.Never, never, never>; /** * RPC used to start an event-log remote session and receive a `HelloResponse`. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class HelloRpc extends HelloRpc_base { } declare const Authenticate_base: Schema.Class, Uint8Array>>; readonly signature: Transferable.Transferable, Uint8Array>>; readonly algorithm: Schema.Literal<"Ed25519">; }>, {}>; /** * Schema for an authentication request containing the client public key, * Ed25519 signing public key, signature over the session challenge payload, and * algorithm name. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class Authenticate extends Authenticate_base { } declare const AuthenticateRpc_base: Rpc.Rpc<"EventLog.Authenticate", typeof Authenticate, Schema.Void, typeof EventLogProtocolError, never, never>; /** * RPC used to authenticate a remote event-log session after `HelloRpc`. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class AuthenticateRpc extends AuthenticateRpc_base { } declare const SingleMessage_base: Schema.Class, Uint8Array>>; }>, {}>; /** * Represents an entire encoded event-log payload in one transport frame. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class SingleMessage extends SingleMessage_base { } declare const ChunkedMessage_base: Schema.Class; readonly data: Transferable.Transferable, Uint8Array>>; }>, {}>; /** * Represents one part of a large encoded event-log payload. * * **When to use** * * Use to divide data into chunks and `join` to reassemble all chunks with * the same id once every part has arrived. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class ChunkedMessage extends ChunkedMessage_base { static chunkSize: number; static initialJoinState(): Map; count: number; bytes: number; }>; /** * Splits binary event-log message data into numbered chunks. * * @stability unstable * @since 4.0.0 */ static split(id: number, data: Uint8Array): NonEmptyReadonlyArray; /** * Reassembles all chunks for a message id into the original binary payload. * * @stability unstable * @since 4.0.0 */ static join(map: Map; count: number; bytes: number; }>, part: ChunkedMessage): Uint8Array | undefined; } /** * Schema for a written entry's id and a sequence at which the server stores * it. Entries the server already held keep their stored sequence. When a write * stores an entry again, as part of a partly known batch, it is acknowledged at * its new position. * * @stability unstable * @category protocols * @since 4.0.6 */ export declare const WriteAck: Schema.Struct<{ readonly entryId: Schema.brand, Uint8Array>, "effect/eventlog/EventJournal/EntryId">; readonly sequence: Schema.Natural; }>; /** * Acknowledgement of one written entry. * * @stability unstable * @category protocols * @since 4.0.6 */ export type WriteAck = typeof WriteAck.Type; declare const WriteChunkedRpc_base: Rpc.Rpc<"EventLog.WriteChunked", typeof ChunkedMessage, Schema.$Array, Uint8Array>, "effect/eventlog/EventJournal/EntryId">; readonly sequence: Schema.Natural; }>>, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC used to send one chunk of a large encoded write payload. * * **Details** * * The completing chunk returns acknowledgements in request order; earlier * chunks return an empty array. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteChunkedRpc extends WriteChunkedRpc_base { } declare const WriteEntries_base: Schema.Class; readonly batches: Schema.$Array, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; readonly iv: Transferable.Transferable, Uint8Array>>; readonly encryptedBatch: Transferable.Transferable, Uint8Array>>; }>>; }>, {}>; /** * Schema for encrypted event-log write payloads sent to a remote store. * * **Details** * * It includes the client public key, target store id, and the entries * encrypted as batches. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteEntries extends WriteEntries_base { static FromSchemaBinary: SchemaBinary.toCodec; static encode: (input: WriteEntries, options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decode: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect; get encoded(): Effect.Effect, Schema.SchemaError, never>; } declare const WriteEntriesUnencrypted_base: Schema.Class; readonly entries: Schema.$Array; }>, {}>; /** * Schema for plaintext event-log write payloads sent to a remote store. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteEntriesUnencrypted extends WriteEntriesUnencrypted_base { static FromSchemaBinary: SchemaBinary.toCodec; static encode: (input: WriteEntriesUnencrypted, options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decode: (data: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect; get encoded(): Effect.Effect, Schema.SchemaError, never>; } declare const WriteSingleRpc_base: Rpc.Rpc<"EventLog.WriteSingle", Schema.Struct<{ data: Transferable.Transferable, Uint8Array>>; }>, Schema.$Array, Uint8Array>, "effect/eventlog/EventJournal/EntryId">; readonly sequence: Schema.Natural; }>>, typeof EventLogProtocolError, typeof EventLogAuthentication, never>; /** * RPC used to send an encoded write payload that fits in one message. * * **Details** * * The response acknowledges every written entry, in request order. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class WriteSingleRpc extends WriteSingleRpc_base { } declare const ChangesRpc_base: Rpc.Rpc<"EventLog.Changes", Schema.Struct<{ publicKey: Schema.String; storeId: Schema.brand; startSequence: Schema.Natural; }>, import("../rpc/RpcSchema.ts").Stream, typeof EventLogProtocolError>, Schema.Never, typeof EventLogAuthentication, never>; /** * RPC used to stream remote event-log changes for a public key and store id * starting at a sequence number. * * **Details** * * Responses are encoded as either `SingleMessage` values or `ChunkedMessage` * parts. Entries written on this connection are acknowledged, not echoed. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class ChangesRpc extends ChangesRpc_base { static EncryptedFromSchemaBinary: SchemaBinary.toCodec, Uint8Array>, "effect/eventlog/EventJournal/EntryId">>; readonly iv: Transferable.Transferable, Uint8Array>>; readonly encryptedBatch: Transferable.Transferable, Uint8Array>>; readonly sequence: Schema.Natural; }>>>; static UnencryptedFromSchemaBinary: SchemaBinary.toCodec>; static encodeEncrypted: (input: readonly [{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }, ...{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }[]], options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decodeEncrypted: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }, ...{ readonly entryIds: readonly [Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">, ...(Uint8Array & Brand<"effect/eventlog/EventJournal/EntryId">)[]]; readonly iv: Uint8Array; readonly encryptedBatch: Uint8Array; readonly sequence: number; }[]], Schema.SchemaError, never>; static encodeUnencrypted: (input: readonly [RemoteEntry, ...RemoteEntry[]], options?: SchemaAST.ParseOptions) => Effect.Effect, Schema.SchemaError, never>; static decodeUnencrypted: (input: Uint8Array, options?: SchemaAST.ParseOptions) => Effect.Effect; } declare const EventLogRemoteRpcs_base: RpcGroup.RpcGroup; /** * RPC group containing the event-log remote handshake, authentication, write, and * changes endpoints. * * @stability unstable * @category protocols * @since 4.0.0 */ export declare class EventLogRemoteRpcs extends EventLogRemoteRpcs_base { } export {}; //# sourceMappingURL=EventLogMessage.d.ts.map