Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@replit/river

Package Overview
Dependencies
Maintainers
31
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@replit/river - npm Package Compare versions

Comparing version 0.23.3 to 0.23.4

dist/chunk-BHNINW7F.js

3

dist/logging/index.d.ts

@@ -1,5 +0,4 @@

export { q as LogFn, L as Logger, M as MessageMetadata, p as bindLogger, n as coloredStringLogger, o as jsonLogger, s as stringLogger } from '../index-a009d7f6.js';
export { k as LogFn, L as Logger, M as MessageMetadata, h as bindLogger, g as coloredStringLogger, j as jsonLogger, s as stringLogger } from '../index-926aea33.js';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';
import '../types-3e5768ec.js';

@@ -1,11 +0,11 @@

import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-ef89f5b0.js';
export { C as Client, E as Err, O as Ok, x as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, n as ProcedureMap, d as ProcedureResult, o as RPCProcedure, w as ResultUnwrapErr, v as ResultUnwrapOk, u as RiverErrorSchema, c as RiverUncaughtSchema, m as SerializedServerSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, q as StreamProcedure, p as SubscriptionProcedure, t as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, r as createClient, s as serializeSchema } from '../services-ef89f5b0.js';
import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-da250ed2.js';
export { C as Client, E as Err, O as Ok, x as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, n as ProcedureMap, d as ProcedureResult, o as RPCProcedure, w as ResultUnwrapErr, v as ResultUnwrapOk, u as RiverErrorSchema, c as RiverUncaughtSchema, m as SerializedServerSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, q as StreamProcedure, p as SubscriptionProcedure, t as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, r as createClient, s as serializeSchema } from '../services-da250ed2.js';
import { Static } from '@sinclair/typebox';
import { ServerTransport } from '../transport/index.js';
import { d as ServerTransport, C as Connection, f as ServerHandshakeOptions, a as ServiceContext } from '../transport-4a5e288a.js';
export { g as ParsedMetadata, h as ServiceContextWithState, i as ServiceContextWithTransportInfo } from '../transport-4a5e288a.js';
import { Pushable } from 'it-pushable';
import { C as Connection, c as ServerHandshakeOptions, a as ServiceContext } from '../index-a009d7f6.js';
export { d as ParsedMetadata, e as ServiceContextWithState, f as ServiceContextWithTransportInfo } from '../index-a009d7f6.js';
import '../types-3e5768ec.js';
import '../index-926aea33.js';
import '@sinclair/typebox/value';
import '@opentelemetry/api';
import '../types-3e5768ec.js';

@@ -46,4 +46,4 @@ /**

var version = "0.23.3";
var version = "0.23.4";
export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };

@@ -11,6 +11,6 @@ import {

serializeSchema
} from "../chunk-JBRQNEBV.js";
} from "../chunk-WTJY7S3D.js";
import {
version
} from "../chunk-XZV3HOQW.js";
} from "../chunk-CHOAXTQF.js";
import "../chunk-SPP7ACQN.js";

@@ -17,0 +17,0 @@ export {

@@ -1,9 +0,9 @@

import { U as UdsConnection } from '../../../connection-89a66019.js';
import { ClientTransport, ClientTransportOptions as ProvidedClientTransportOptions } from '../../index.js';
import { T as TransportClientId } from '../../../index-a009d7f6.js';
import { U as UdsConnection } from '../../../connection-36e8bb12.js';
import { c as ClientTransport, P as ProvidedClientTransportOptions } from '../../../transport-4a5e288a.js';
import { T as TransportClientId } from '../../../index-926aea33.js';
import 'node:net';
import 'node:stream';
import '../../../types-3e5768ec.js';
import '@sinclair/typebox';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';

@@ -10,0 +10,0 @@

import {
UdsConnection
} from "../../../chunk-R3EG3FOP.js";
} from "../../../chunk-RWYW2BES.js";
import {
ClientTransport
} from "../../../chunk-IKT6A32W.js";
import "../../../chunk-XZV3HOQW.js";
} from "../../../chunk-BHNINW7F.js";
import "../../../chunk-CHOAXTQF.js";
import {

@@ -9,0 +9,0 @@ log

import { Server, Socket } from 'node:net';
import { ServerTransport, ServerTransportOptions as ProvidedServerTransportOptions } from '../../index.js';
import { T as TransportClientId } from '../../../index-a009d7f6.js';
import { U as UdsConnection } from '../../../connection-89a66019.js';
import { d as ServerTransport, e as ProvidedServerTransportOptions } from '../../../transport-4a5e288a.js';
import { T as TransportClientId } from '../../../index-926aea33.js';
import { U as UdsConnection } from '../../../connection-36e8bb12.js';
import '../../../types-3e5768ec.js';
import '@sinclair/typebox';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';

@@ -9,0 +9,0 @@ import 'node:stream';

import {
UdsConnection
} from "../../../chunk-R3EG3FOP.js";
} from "../../../chunk-RWYW2BES.js";
import {
ServerTransport
} from "../../../chunk-IKT6A32W.js";
import "../../../chunk-XZV3HOQW.js";
} from "../../../chunk-BHNINW7F.js";
import "../../../chunk-CHOAXTQF.js";
import "../../../chunk-SPP7ACQN.js";

@@ -9,0 +9,0 @@ import "../../../chunk-3AW3IXVD.js";

@@ -1,8 +0,8 @@

import { ClientTransport, ClientTransportOptions as ProvidedClientTransportOptions } from '../../index.js';
import { T as TransportClientId } from '../../../index-a009d7f6.js';
import { W as WebSocketConnection } from '../../../connection-4abad643.js';
import { c as ClientTransport, P as ProvidedClientTransportOptions } from '../../../transport-4a5e288a.js';
import { T as TransportClientId } from '../../../index-926aea33.js';
import { W as WebSocketConnection } from '../../../connection-a5bc5e9f.js';
import { W as WsLike } from '../../../wslike-e0b32dd5.js';
import '../../../types-3e5768ec.js';
import '@sinclair/typebox';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';

@@ -9,0 +9,0 @@

import {
WebSocketConnection
} from "../../../chunk-3U43VMW2.js";
} from "../../../chunk-PTX6DT5G.js";
import {
ClientTransport
} from "../../../chunk-IKT6A32W.js";
import "../../../chunk-XZV3HOQW.js";
} from "../../../chunk-BHNINW7F.js";
import "../../../chunk-CHOAXTQF.js";
import {

@@ -9,0 +9,0 @@ log

@@ -1,5 +0,5 @@

import { T as TransportClientId } from '../../../index-a009d7f6.js';
import { ServerTransport, ServerTransportOptions as ProvidedServerTransportOptions } from '../../index.js';
import { T as TransportClientId } from '../../../index-926aea33.js';
import { d as ServerTransport, e as ProvidedServerTransportOptions } from '../../../transport-4a5e288a.js';
import { WebSocketServer } from 'ws';
import { W as WebSocketConnection } from '../../../connection-4abad643.js';
import { W as WebSocketConnection } from '../../../connection-a5bc5e9f.js';
import { W as WsLike } from '../../../wslike-e0b32dd5.js';

@@ -6,0 +6,0 @@ import '@sinclair/typebox/value';

import {
WebSocketConnection
} from "../../../chunk-3U43VMW2.js";
} from "../../../chunk-PTX6DT5G.js";
import {
ServerTransport
} from "../../../chunk-IKT6A32W.js";
import "../../../chunk-XZV3HOQW.js";
} from "../../../chunk-BHNINW7F.js";
import "../../../chunk-CHOAXTQF.js";
import "../../../chunk-SPP7ACQN.js";

@@ -9,0 +9,0 @@ import "../../../chunk-3AW3IXVD.js";

@@ -1,309 +0,6 @@

import { C as Codec } from '../types-3e5768ec.js';
import { O as OpaqueTransportMessage, C as Connection, b as Session, T as TransportClientId, m as PropagationContext, P as PartialTransportMessage, g as ClientHandshakeOptions, c as ServerHandshakeOptions, d as ParsedMetadata, S as SessionOptions } from '../index-a009d7f6.js';
export { i as OpaqueTransportMessageSchema, j as TransportMessage, h as TransportMessageSchema, l as isStreamClose, k as isStreamOpen } from '../index-a009d7f6.js';
export { c as ClientTransport, P as ClientTransportOptions, C as Connection, n as EventHandler, E as EventMap, m as EventTypes, o as ProtocolError, p as ProtocolErrorType, d as ServerTransport, e as ServerTransportOptions, b as Session, T as Transport, k as TransportOptions, l as TransportStatus } from '../transport-4a5e288a.js';
export { O as OpaqueTransportMessage, e as OpaqueTransportMessageSchema, T as TransportClientId, c as TransportMessage, d as TransportMessageSchema, f as isStreamClose, i as isStreamOpen } from '../index-926aea33.js';
import '../types-3e5768ec.js';
import '@sinclair/typebox';
import '@sinclair/typebox/value';
import '@sinclair/typebox';
import '@opentelemetry/api';
type ConnectionStatus = 'connect' | 'disconnect';
declare const ProtocolError: {
readonly RetriesExceeded: "conn_retry_exceeded";
readonly HandshakeFailed: "handshake_failed";
readonly UseAfterDestroy: "use_after_destroy";
readonly MessageOrderingViolated: "message_ordering_violated";
};
type ProtocolErrorType = (typeof ProtocolError)[keyof typeof ProtocolError];
interface EventMap {
message: OpaqueTransportMessage;
connectionStatus: {
status: ConnectionStatus;
conn: Connection;
};
sessionStatus: {
status: ConnectionStatus;
session: Session<Connection>;
};
protocolError: {
type: ProtocolErrorType;
message: string;
};
}
type EventTypes = keyof EventMap;
type EventHandler<K extends EventTypes> = (event: EventMap[K]) => unknown;
declare class EventDispatcher<T extends EventTypes> {
private eventListeners;
numberOfListeners<K extends T>(eventType: K): number;
addEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
removeEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
dispatchEvent<K extends T>(eventType: K, event: EventMap[K]): void;
}
/**
* Options to control the backoff and retry behavior of the client transport's connection behaviour.
*
* River implements exponential backoff with jitter to prevent flooding the server
* when there's an issue with connection establishment.
*
* The backoff is calculated via the following:
* backOff = min(jitter + {@link baseIntervalMs} * 2 ^ budget_consumed, {@link maxBackoffMs})
*
* We use a leaky bucket rate limit with a budget of {@link attemptBudgetCapacity} reconnection attempts.
* Budget only starts to restore after a successful handshake at a rate of one budget per {@link budgetRestoreIntervalMs}.
*/
interface ConnectionRetryOptions {
/**
* The base interval to wait before retrying a connection.
*/
baseIntervalMs: number;
/**
* The maximum random jitter to add to the total backoff time.
*/
maxJitterMs: number;
/**
* The maximum amount of time to wait before retrying a connection.
* This does not include the jitter.
*/
maxBackoffMs: number;
/**
* The max number of times to attempt a connection before a successful handshake.
* This persists across connections but starts restoring budget after a successful handshake.
* The restoration interval depends on {@link budgetRestoreIntervalMs}
*/
attemptBudgetCapacity: number;
/**
* After a successful connection attempt, how long to wait before we restore a single budget.
*/
budgetRestoreIntervalMs: number;
}
declare class LeakyBucketRateLimit {
private budgetConsumed;
private intervalHandles;
private readonly options;
constructor(options: ConnectionRetryOptions);
getBackoffMs(user: TransportClientId): number;
get totalBudgetRestoreTime(): number;
consumeBudget(user: TransportClientId): void;
getBudgetConsumed(user: TransportClientId): number;
hasBudget(user: TransportClientId): boolean;
startRestoringBudget(user: TransportClientId): void;
private stopLeak;
close(): void;
}
/**
* Represents the possible states of a transport.
* @property {'open'} open - The transport is open and operational (note that this doesn't mean it is actively connected)
* @property {'closed'} closed - The transport is closed and not operational, but can be reopened.
* @property {'destroyed'} destroyed - The transport is permanently destroyed and cannot be reopened.
*/
type TransportStatus = 'open' | 'closed' | 'destroyed';
type TransportOptions = SessionOptions;
type ProvidedTransportOptions = Partial<TransportOptions>;
type ClientTransportOptions = TransportOptions & ConnectionRetryOptions;
type ProvidedClientTransportOptions = Partial<ClientTransportOptions>;
type ServerTransportOptions = TransportOptions;
type ProvidedServerTransportOptions = Partial<ServerTransportOptions>;
/**
* Transports manage the lifecycle (creation/deletion) of sessions and connections. Its responsibilities include:
*
* 1) Constructing a new {@link Session} and {@link Connection} on {@link TransportMessage}s from new clients.
* After constructing the {@link Connection}, {@link onConnect} is called which adds it to the connection map.
* 2) Delegating message listening of the connection to the newly created {@link Connection}.
* From this point on, the {@link Connection} is responsible for *reading* and *writing*
* messages from the connection.
* 3) When a connection is closed, the {@link Transport} calls {@link onDisconnect} which closes the
* connection via {@link Connection.close} and removes it from the {@link connections} map.
*
* ```plaintext
* ▲
* incoming │
* messages │
* ▼
* ┌─────────────┐ 1:N ┌───────────┐ 1:1* ┌────────────┐
* │ Transport │ ◄─────► │ Session │ ◄─────► │ Connection │
* └─────────────┘ └───────────┘ └────────────┘
* ▲ * (may or may not be initialized yet)
* │
* ▼
* ┌───────────┐
* │ Message │
* │ Listeners │
* └───────────┘
* ```
* @abstract
*/
declare abstract class Transport<ConnType extends Connection> {
/**
* A flag indicating whether the transport has been destroyed.
* A destroyed transport will not attempt to reconnect and cannot be used again.
*/
state: TransportStatus;
/**
* The {@link Codec} used to encode and decode messages.
*/
codec: Codec;
/**
* The client ID of this transport.
*/
clientId: TransportClientId;
/**
* The map of {@link Session}s managed by this transport.
*/
sessions: Map<TransportClientId, Session<ConnType>>;
/**
* The map of {@link Connection}s managed by this transport.
*/
get connections(): Map<string, ConnType>;
/**
* The event dispatcher for handling events of type EventTypes.
*/
eventDispatcher: EventDispatcher<EventTypes>;
/**
* The options for this transport.
*/
protected options: TransportOptions;
/**
* Creates a new Transport instance.
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
* @param codec The codec used to encode and decode messages.
* @param clientId The client ID of this transport.
*/
constructor(clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
/**
* This is called immediately after a new connection is established and we
* may or may not know the identity of the connected client.
* It should attach all the necessary listeners to the connection for lifecycle
* events (i.e. data, close, error)
*
* This method is implemented by {@link ClientTransport} and {@link ServerTransport}.
*/
protected abstract handleConnection(conn: ConnType, to: TransportClientId): void;
/**
* Called when a new connection is established
* and we know the identity of the connected client.
* @param conn The connection object.
*/
protected onConnect(conn: ConnType, connectedTo: TransportClientId, session: Session<ConnType>, isReconnect: boolean): void;
protected createSession(to: TransportClientId, conn?: ConnType, propagationCtx?: PropagationContext): Session<ConnType>;
protected getOrCreateSession(to: TransportClientId, conn?: ConnType, sessionId?: string, propagationCtx?: PropagationContext): {
session: Session<ConnType>;
isReconnect: boolean;
};
protected deleteSession(session: Session<ConnType>): void;
/**
* The downstream implementation needs to call this when a connection is closed.
* @param conn The connection object.
* @param connectedTo The peer we are connected to.
*/
protected onDisconnect(conn: ConnType, session: Session<ConnType>): void;
/**
* Parses a message from a Uint8Array into a {@link OpaqueTransportMessage}.
* @param msg The message to parse.
* @returns The parsed message, or null if the message is malformed or invalid.
*/
protected parseMsg(msg: Uint8Array): OpaqueTransportMessage | null;
/**
* Called when a message is received by this transport.
* You generally shouldn't need to override this in downstream transport implementations.
* @param msg The received message.
*/
protected handleMsg(msg: OpaqueTransportMessage): void;
/**
* Adds a listener to this transport.
* @param the type of event to listen for
* @param handler The message handler to add.
*/
addEventListener<K extends EventTypes, T extends EventHandler<K>>(type: K, handler: T): void;
/**
* Removes a listener from this transport.
* @param the type of event to un-listen on
* @param handler The message handler to remove.
*/
removeEventListener<K extends EventTypes, T extends EventHandler<K>>(type: K, handler: T): void;
/**
* Sends a message over this transport, delegating to the appropriate connection to actually
* send the message.
* @param msg The message to send.
* @returns The ID of the sent message or undefined if it wasn't sent
*/
send(to: TransportClientId, msg: PartialTransportMessage): string | undefined;
sendCloseStream(to: TransportClientId, streamId: string): string | undefined;
protected protocolError(type: ProtocolErrorType, message: string): void;
/**
* Default close implementation for transports. You should override this in the downstream
* implementation if you need to do any additional cleanup and call super.close() at the end.
* Closes the transport. Any messages sent while the transport is closed will be silently discarded.
*/
close(): void;
/**
* Default destroy implementation for transports. You should override this in the downstream
* implementation if you need to do any additional cleanup and call super.destroy() at the end.
* Destroys the transport. Any messages sent while the transport is destroyed will throw an error.
*/
destroy(): void;
}
declare abstract class ClientTransport<ConnType extends Connection> extends Transport<ConnType> {
/**
* The options for this transport.
*/
protected options: ClientTransportOptions;
/**
* The map of reconnect promises for each client ID.
*/
inflightConnectionPromises: Map<TransportClientId, Promise<ConnType>>;
retryBudget: LeakyBucketRateLimit;
/**
* A flag indicating whether the transport should automatically reconnect
* when a connection is dropped.
* Realistically, this should always be true for clients unless you are writing
* tests or a special case where you don't want to reconnect.
*/
reconnectOnConnectionDrop: boolean;
/**
* Optional handshake options for this client.
*/
handshakeExtensions?: ClientHandshakeOptions;
constructor(clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
extendHandshake(options: ClientHandshakeOptions): void;
protected handleConnection(conn: ConnType, to: TransportClientId): void;
receiveHandshakeResponseMessage(data: Uint8Array, conn: ConnType): Session<ConnType> | false;
/**
* Abstract method that creates a new {@link Connection} object.
* This should call {@link handleConnection} when the connection is created.
* The downstream client implementation needs to implement this.
*
* @param to The client ID of the node to connect to.
* @returns The new connection object.
*/
protected abstract createNewOutgoingConnection(to: TransportClientId): Promise<ConnType>;
/**
* Manually attempts to connect to a client.
* @param to The client ID of the node to connect to.
*/
connect(to: TransportClientId): Promise<void>;
protected deleteSession(session: Session<ConnType>): void;
protected sendHandshake(to: TransportClientId, conn: ConnType): Promise<boolean>;
close(): void;
}
declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> {
/**
* The options for this transport.
*/
protected options: ServerTransportOptions;
/**
* Optional handshake options for the server.
*/
handshakeExtensions?: ServerHandshakeOptions;
/**
* A map of session handshake data for each session.
*/
sessionHandshakeMetadata: WeakMap<Session<ConnType>, ParsedMetadata>;
constructor(clientId: TransportClientId, providedOptions?: ProvidedServerTransportOptions);
extendHandshake(options: ServerHandshakeOptions): void;
protected handleConnection(conn: ConnType): void;
private validateHandshakeMetadata;
receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): Promise<Session<ConnType> | false>;
}
export { ClientHandshakeOptions, ClientTransport, ProvidedClientTransportOptions as ClientTransportOptions, Connection, EventHandler, EventMap, EventTypes, OpaqueTransportMessage, ProtocolError, ProtocolErrorType, ServerHandshakeOptions, ServerTransport, ProvidedServerTransportOptions as ServerTransportOptions, Session, Transport, TransportClientId, ProvidedTransportOptions as TransportOptions, TransportStatus };

@@ -8,7 +8,7 @@ import {

Transport
} from "../chunk-IKT6A32W.js";
} from "../chunk-BHNINW7F.js";
import {
OpaqueTransportMessageSchema,
TransportMessageSchema
} from "../chunk-XZV3HOQW.js";
} from "../chunk-CHOAXTQF.js";
import "../chunk-SPP7ACQN.js";

@@ -15,0 +15,0 @@ import "../chunk-3AW3IXVD.js";

import { Static } from '@sinclair/typebox';
import { P as PayloadType, R as RiverError, a as Procedure, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../services-ef89f5b0.js';
import { Transport } from '../transport/index.js';
import { P as PayloadType, R as RiverError, a as Procedure, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../services-da250ed2.js';
import { T as Transport, C as Connection, S as SessionOptions, a as ServiceContext, b as Session } from '../transport-4a5e288a.js';
import * as it_pushable from 'it-pushable';
import { P as PartialTransportMessage, C as Connection, O as OpaqueTransportMessage, S as SessionOptions, a as ServiceContext, b as Session } from '../index-a009d7f6.js';
import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-926aea33.js';
import NodeWs from 'ws';

@@ -7,0 +7,0 @@ import http from 'node:http';

@@ -5,10 +5,10 @@ import {

pushable
} from "../chunk-JBRQNEBV.js";
} from "../chunk-WTJY7S3D.js";
import {
Session,
defaultTransportOptions
} from "../chunk-IKT6A32W.js";
} from "../chunk-BHNINW7F.js";
import {
coerceErrorString
} from "../chunk-XZV3HOQW.js";
} from "../chunk-CHOAXTQF.js";
import "../chunk-SPP7ACQN.js";

@@ -15,0 +15,0 @@ import "../chunk-3AW3IXVD.js";

{
"name": "@replit/river",
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.23.3",
"version": "0.23.4",
"type": "module",

@@ -6,0 +6,0 @@ "exports": {

@@ -160,2 +160,11 @@ # River

You can then access the `ParsedMetadata` in your procedure handlers:
```ts
async handler(ctx, ...args) {
// this contains the parsed metadata
console.log(ctx.metadata)
}
```
### Logging

@@ -202,2 +211,41 @@

### Custom Handshake
River allows you to extend the protocol-level handshake so you can add additional logic to
validate incoming connections.
You can do this by passing extra options to `createClient` and `createServer` and extending the `ParsedMetadata` interface:
```ts
declare module '@replit/river' {
interface ParsedMetadata {
userId: number;
}
}
const schema = Type.Object({ token: Type.String() });
createClient<typeof services>(new MockClientTransport('client'), 'SERVER', {
eagerlyConnect: false,
handshakeOptions: createClientHandshakeOptions(schema, async () => ({
// the type of this function is
// () => Static<typeof schema> | Promise<Static<typeof schema>>
token: '123',
})),
});
createServer(new MockServerTransport('SERVER'), services, {
handshakeOptions: createServerHandshakeOptions(
schema,
(metadata, previousMetadata) => {
// the type of this function is
// (metadata: Static<typeof<schema>, previousMetadata?: ParsedMetadata) =>
// | false | Promise<false> (if you reject it)
// | ParsedMetadata | Promise<ParsedMetadata> (if you allow it)
// next time a connection happens on the same session, previousMetadata will
// be populated with the last returned value
},
),
});
```
### Further examples

@@ -204,0 +252,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc