@orpc/server 0.0.0-next.eaf61c7 → 0.0.0-next.eb3d98a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/adapters/aws-lambda/index.d.mts +7 -6
- package/dist/adapters/aws-lambda/index.d.ts +7 -6
- package/dist/adapters/aws-lambda/index.mjs +5 -4
- package/dist/adapters/bun-ws/index.d.mts +12 -11
- package/dist/adapters/bun-ws/index.d.ts +12 -11
- package/dist/adapters/bun-ws/index.mjs +14 -13
- package/dist/adapters/crossws/index.d.mts +8 -5
- package/dist/adapters/crossws/index.d.ts +8 -5
- package/dist/adapters/crossws/index.mjs +11 -10
- package/dist/adapters/fetch/index.d.mts +5 -4
- package/dist/adapters/fetch/index.d.ts +5 -4
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/message-port/index.d.mts +11 -8
- package/dist/adapters/message-port/index.d.ts +11 -8
- package/dist/adapters/message-port/index.mjs +13 -13
- package/dist/adapters/node/index.d.mts +5 -4
- package/dist/adapters/node/index.d.ts +5 -4
- package/dist/adapters/node/index.mjs +3 -2
- package/dist/adapters/standard/index.d.mts +8 -13
- package/dist/adapters/standard/index.d.ts +8 -13
- package/dist/adapters/standard/index.mjs +3 -2
- package/dist/adapters/standard-peer/index.d.mts +14 -0
- package/dist/adapters/standard-peer/index.d.ts +14 -0
- package/dist/adapters/standard-peer/index.mjs +7 -0
- package/dist/adapters/websocket/index.d.mts +15 -12
- package/dist/adapters/websocket/index.d.ts +15 -12
- package/dist/adapters/websocket/index.mjs +15 -15
- package/dist/adapters/ws/index.d.mts +11 -8
- package/dist/adapters/ws/index.d.ts +11 -8
- package/dist/adapters/ws/index.mjs +15 -15
- package/dist/helpers/index.d.mts +130 -0
- package/dist/helpers/index.d.ts +130 -0
- package/dist/helpers/index.mjs +182 -0
- package/dist/hibernation/index.d.mts +6 -6
- package/dist/hibernation/index.d.ts +6 -6
- package/dist/hibernation/index.mjs +3 -3
- package/dist/index.d.mts +16 -47
- package/dist/index.d.ts +16 -47
- package/dist/index.mjs +7 -6
- package/dist/plugins/index.d.mts +17 -4
- package/dist/plugins/index.d.ts +17 -4
- package/dist/plugins/index.mjs +27 -4
- package/dist/shared/server.B7b2w3_i.d.ts +12 -0
- package/dist/shared/server.BEFBl-Cb.d.mts +12 -0
- package/dist/shared/server.BU4WI18A.d.mts +32 -0
- package/dist/shared/{server.-ACo36I0.d.ts → server.Bmh5xd4n.d.ts} +3 -3
- package/dist/shared/server.C6Q5sqYw.mjs +20 -0
- package/dist/shared/{server.CHvOkcM3.mjs → server.CIL9uKTN.mjs} +12 -4
- package/dist/shared/{server.DD2C4ujN.d.mts → server.CYNGeoCm.d.mts} +6 -4
- package/dist/shared/{server.DD2C4ujN.d.ts → server.CYNGeoCm.d.ts} +6 -4
- package/dist/shared/server.D0H-iaY3.d.ts +32 -0
- package/dist/shared/server.DhJj-1X9.d.mts +42 -0
- package/dist/shared/{server.DG7Tamti.mjs → server.NeumLVdS.mjs} +13 -10
- package/dist/shared/{server.Dq8xr7PQ.d.mts → server.gqRxT-yN.d.mts} +3 -3
- package/dist/shared/server.jMTkVNIb.d.ts +42 -0
- package/package.json +23 -12
- package/dist/shared/server.BPAWobQg.d.ts +0 -12
- package/dist/shared/server.Bd52nNaH.d.mts +0 -12
- package/dist/shared/server.BliFSTnG.d.mts +0 -10
- package/dist/shared/server.IG2MjhrD.d.ts +0 -10
@@ -1,12 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
export { C as CompositeStandardHandlerPlugin,
|
3
|
-
import { ORPCError
|
1
|
+
import { S as StandardCodec, a as StandardParams } from '../../shared/server.gqRxT-yN.mjs';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, c as StandardHandleResult, f as StandardHandler, d as StandardHandlerInterceptorOptions, e as StandardHandlerOptions, g as StandardHandlerPlugin, h as StandardMatchResult, i as StandardMatcher } from '../../shared/server.gqRxT-yN.mjs';
|
3
|
+
import { ORPCError } from '@orpc/client';
|
4
4
|
import { StandardRPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import {
|
7
|
-
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure } from '../../shared/server.CYNGeoCm.mjs';
|
7
|
+
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions, c as StandardRPCMatcher, b as StandardRPCMatcherOptions } from '../../shared/server.BU4WI18A.mjs';
|
8
|
+
export { F as FriendlyStandardHandleOptions, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.BEFBl-Cb.mjs';
|
8
9
|
import '@orpc/contract';
|
9
10
|
import '@orpc/shared';
|
11
|
+
import '../../shared/server.DhJj-1X9.mjs';
|
10
12
|
|
11
13
|
declare class StandardRPCCodec implements StandardCodec {
|
12
14
|
private readonly serializer;
|
@@ -16,11 +18,4 @@ declare class StandardRPCCodec implements StandardCodec {
|
|
16
18
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
17
19
|
}
|
18
20
|
|
19
|
-
|
20
|
-
private readonly tree;
|
21
|
-
private pendingRouters;
|
22
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
23
|
-
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
24
|
-
}
|
25
|
-
|
26
|
-
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
21
|
+
export { StandardCodec, StandardParams, StandardRPCCodec };
|
@@ -1,12 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
export { C as CompositeStandardHandlerPlugin,
|
3
|
-
import { ORPCError
|
1
|
+
import { S as StandardCodec, a as StandardParams } from '../../shared/server.Bmh5xd4n.js';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, c as StandardHandleResult, f as StandardHandler, d as StandardHandlerInterceptorOptions, e as StandardHandlerOptions, g as StandardHandlerPlugin, h as StandardMatchResult, i as StandardMatcher } from '../../shared/server.Bmh5xd4n.js';
|
3
|
+
import { ORPCError } from '@orpc/client';
|
4
4
|
import { StandardRPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import {
|
7
|
-
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure } from '../../shared/server.CYNGeoCm.js';
|
7
|
+
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions, c as StandardRPCMatcher, b as StandardRPCMatcherOptions } from '../../shared/server.D0H-iaY3.js';
|
8
|
+
export { F as FriendlyStandardHandleOptions, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.B7b2w3_i.js';
|
8
9
|
import '@orpc/contract';
|
9
10
|
import '@orpc/shared';
|
11
|
+
import '../../shared/server.jMTkVNIb.js';
|
10
12
|
|
11
13
|
declare class StandardRPCCodec implements StandardCodec {
|
12
14
|
private readonly serializer;
|
@@ -16,11 +18,4 @@ declare class StandardRPCCodec implements StandardCodec {
|
|
16
18
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
17
19
|
}
|
18
20
|
|
19
|
-
|
20
|
-
private readonly tree;
|
21
|
-
private pendingRouters;
|
22
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
23
|
-
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
24
|
-
}
|
25
|
-
|
26
|
-
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
21
|
+
export { StandardCodec, StandardParams, StandardRPCCodec };
|
@@ -1,7 +1,8 @@
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.
|
1
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.CIL9uKTN.mjs';
|
2
|
+
export { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
2
3
|
import '@orpc/client/standard';
|
3
4
|
import '@orpc/client';
|
4
5
|
import '@orpc/shared';
|
5
6
|
import '@orpc/standard-server';
|
6
|
-
import '../../shared/server.
|
7
|
+
import '../../shared/server.NeumLVdS.mjs';
|
7
8
|
import '@orpc/contract';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ServerPeer, EncodedMessage } from '@orpc/standard-server-peer';
|
2
|
+
import { C as Context } from '../../shared/server.CYNGeoCm.mjs';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.gqRxT-yN.mjs';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.BEFBl-Cb.mjs';
|
5
|
+
import '@orpc/client';
|
6
|
+
import '@orpc/contract';
|
7
|
+
import '@orpc/shared';
|
8
|
+
import '@orpc/standard-server';
|
9
|
+
|
10
|
+
type HandleStandardServerPeerMessageOptions<T extends Context> = Omit<FriendlyStandardHandleOptions<T>, 'prefix'>;
|
11
|
+
declare function handleStandardServerPeerMessage<T extends Context>(handler: StandardHandler<T>, peer: ServerPeer, message: EncodedMessage, options: HandleStandardServerPeerMessageOptions<T>): Promise<void>;
|
12
|
+
|
13
|
+
export { handleStandardServerPeerMessage };
|
14
|
+
export type { HandleStandardServerPeerMessageOptions };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ServerPeer, EncodedMessage } from '@orpc/standard-server-peer';
|
2
|
+
import { C as Context } from '../../shared/server.CYNGeoCm.js';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.Bmh5xd4n.js';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.B7b2w3_i.js';
|
5
|
+
import '@orpc/client';
|
6
|
+
import '@orpc/contract';
|
7
|
+
import '@orpc/shared';
|
8
|
+
import '@orpc/standard-server';
|
9
|
+
|
10
|
+
type HandleStandardServerPeerMessageOptions<T extends Context> = Omit<FriendlyStandardHandleOptions<T>, 'prefix'>;
|
11
|
+
declare function handleStandardServerPeerMessage<T extends Context>(handler: StandardHandler<T>, peer: ServerPeer, message: EncodedMessage, options: HandleStandardServerPeerMessageOptions<T>): Promise<void>;
|
12
|
+
|
13
|
+
export { handleStandardServerPeerMessage };
|
14
|
+
export type { HandleStandardServerPeerMessageOptions };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
2
|
+
import '@orpc/client';
|
3
|
+
import '@orpc/shared';
|
4
|
+
import '@orpc/standard-server';
|
5
|
+
import '@orpc/contract';
|
6
|
+
import '@orpc/client/standard';
|
7
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
@@ -1,15 +1,18 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.CYNGeoCm.mjs';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.gqRxT-yN.mjs';
|
4
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BU4WI18A.mjs';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '@orpc/contract';
|
8
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/standard-server-peer';
|
10
|
+
import '../../shared/server.BEFBl-Cb.mjs';
|
9
11
|
import '@orpc/client/standard';
|
12
|
+
import '../../shared/server.DhJj-1X9.mjs';
|
10
13
|
|
11
|
-
type
|
12
|
-
declare class
|
14
|
+
type MinimalWebsocket = Pick<WebSocket, 'addEventListener' | 'send'>;
|
15
|
+
declare class WebsocketHandler<T extends Context> {
|
13
16
|
#private;
|
14
17
|
constructor(standardHandler: StandardHandler<T>);
|
15
18
|
/**
|
@@ -19,7 +22,7 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
19
22
|
*
|
20
23
|
* @warning Do not use this method if you're using `.message()` or `.close()`
|
21
24
|
*/
|
22
|
-
upgrade(ws:
|
25
|
+
upgrade(ws: MinimalWebsocket, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
23
26
|
/**
|
24
27
|
* Handles a single message received from a WebSocket.
|
25
28
|
*
|
@@ -28,13 +31,13 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
28
31
|
* @param ws The WebSocket instance
|
29
32
|
* @param data The message payload, usually place in `event.data`
|
30
33
|
*/
|
31
|
-
message(ws:
|
34
|
+
message(ws: MinimalWebsocket, data: string | ArrayBuffer | Blob, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
32
35
|
/**
|
33
36
|
* Closes the WebSocket peer and cleans up.
|
34
37
|
*
|
35
38
|
* @warning Avoid calling this directly if `.upgrade()` is used.
|
36
39
|
*/
|
37
|
-
close(ws:
|
40
|
+
close(ws: MinimalWebsocket): void;
|
38
41
|
}
|
39
42
|
|
40
43
|
/**
|
@@ -43,9 +46,9 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
43
46
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
44
47
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
45
48
|
*/
|
46
|
-
declare class
|
49
|
+
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
47
50
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
48
51
|
}
|
49
52
|
|
50
|
-
export {
|
51
|
-
export type {
|
53
|
+
export { RPCHandler, WebsocketHandler };
|
54
|
+
export type { MinimalWebsocket };
|
@@ -1,15 +1,18 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.CYNGeoCm.js';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.Bmh5xd4n.js';
|
4
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.D0H-iaY3.js';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '@orpc/contract';
|
8
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/standard-server-peer';
|
10
|
+
import '../../shared/server.B7b2w3_i.js';
|
9
11
|
import '@orpc/client/standard';
|
12
|
+
import '../../shared/server.jMTkVNIb.js';
|
10
13
|
|
11
|
-
type
|
12
|
-
declare class
|
14
|
+
type MinimalWebsocket = Pick<WebSocket, 'addEventListener' | 'send'>;
|
15
|
+
declare class WebsocketHandler<T extends Context> {
|
13
16
|
#private;
|
14
17
|
constructor(standardHandler: StandardHandler<T>);
|
15
18
|
/**
|
@@ -19,7 +22,7 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
19
22
|
*
|
20
23
|
* @warning Do not use this method if you're using `.message()` or `.close()`
|
21
24
|
*/
|
22
|
-
upgrade(ws:
|
25
|
+
upgrade(ws: MinimalWebsocket, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
23
26
|
/**
|
24
27
|
* Handles a single message received from a WebSocket.
|
25
28
|
*
|
@@ -28,13 +31,13 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
28
31
|
* @param ws The WebSocket instance
|
29
32
|
* @param data The message payload, usually place in `event.data`
|
30
33
|
*/
|
31
|
-
message(ws:
|
34
|
+
message(ws: MinimalWebsocket, data: string | ArrayBuffer | Blob, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
32
35
|
/**
|
33
36
|
* Closes the WebSocket peer and cleans up.
|
34
37
|
*
|
35
38
|
* @warning Avoid calling this directly if `.upgrade()` is used.
|
36
39
|
*/
|
37
|
-
close(ws:
|
40
|
+
close(ws: MinimalWebsocket): void;
|
38
41
|
}
|
39
42
|
|
40
43
|
/**
|
@@ -43,9 +46,9 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
43
46
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
44
47
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
45
48
|
*/
|
46
|
-
declare class
|
49
|
+
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
47
50
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
48
51
|
}
|
49
52
|
|
50
|
-
export {
|
51
|
-
export type {
|
53
|
+
export { RPCHandler, WebsocketHandler };
|
54
|
+
export type { MinimalWebsocket };
|
@@ -1,14 +1,15 @@
|
|
1
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
3
|
-
import {
|
3
|
+
import { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.CIL9uKTN.mjs';
|
8
8
|
import '@orpc/client/standard';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
10
|
+
import '../../shared/server.NeumLVdS.mjs';
|
10
11
|
|
11
|
-
class
|
12
|
+
class WebsocketHandler {
|
12
13
|
#peers = /* @__PURE__ */ new WeakMap();
|
13
14
|
#handler;
|
14
15
|
constructor(standardHandler) {
|
@@ -38,14 +39,13 @@ class experimental_WebsocketHandler {
|
|
38
39
|
if (!peer) {
|
39
40
|
this.#peers.set(ws, peer = new ServerPeer(ws.send.bind(ws)));
|
40
41
|
}
|
41
|
-
const message = data instanceof Blob ? await data
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
await peer.response(id, response ?? { status: 404, headers: {}, body: "No procedure matched" });
|
42
|
+
const message = data instanceof Blob ? await readAsBuffer(data) : data;
|
43
|
+
await handleStandardServerPeerMessage(
|
44
|
+
this.#handler,
|
45
|
+
peer,
|
46
|
+
message,
|
47
|
+
resolveMaybeOptionalOptions(rest)
|
48
|
+
);
|
49
49
|
}
|
50
50
|
/**
|
51
51
|
* Closes the WebSocket peer and cleans up.
|
@@ -60,10 +60,10 @@ class experimental_WebsocketHandler {
|
|
60
60
|
}
|
61
61
|
}
|
62
62
|
|
63
|
-
class
|
63
|
+
class RPCHandler extends WebsocketHandler {
|
64
64
|
constructor(router, options = {}) {
|
65
65
|
super(new StandardRPCHandler(router, options));
|
66
66
|
}
|
67
67
|
}
|
68
68
|
|
69
|
-
export {
|
69
|
+
export { RPCHandler, WebsocketHandler };
|
@@ -1,18 +1,21 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { WebSocket } from 'ws';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.CYNGeoCm.mjs';
|
4
|
+
import { f as StandardHandler } from '../../shared/server.gqRxT-yN.mjs';
|
5
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BU4WI18A.mjs';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/standard-server-peer';
|
11
|
+
import '../../shared/server.BEFBl-Cb.mjs';
|
10
12
|
import '@orpc/client/standard';
|
13
|
+
import '../../shared/server.DhJj-1X9.mjs';
|
11
14
|
|
12
|
-
declare class
|
15
|
+
declare class WsHandler<T extends Context> {
|
13
16
|
private readonly standardHandler;
|
14
17
|
constructor(standardHandler: StandardHandler<T>);
|
15
|
-
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<
|
18
|
+
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
16
19
|
}
|
17
20
|
|
18
21
|
/**
|
@@ -21,8 +24,8 @@ declare class experimental_WsHandler<T extends Context> {
|
|
21
24
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
22
25
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
23
26
|
*/
|
24
|
-
declare class
|
27
|
+
declare class RPCHandler<T extends Context> extends WsHandler<T> {
|
25
28
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
26
29
|
}
|
27
30
|
|
28
|
-
export {
|
31
|
+
export { RPCHandler, WsHandler };
|
@@ -1,18 +1,21 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { WebSocket } from 'ws';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.CYNGeoCm.js';
|
4
|
+
import { f as StandardHandler } from '../../shared/server.Bmh5xd4n.js';
|
5
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.D0H-iaY3.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/standard-server-peer';
|
11
|
+
import '../../shared/server.B7b2w3_i.js';
|
10
12
|
import '@orpc/client/standard';
|
13
|
+
import '../../shared/server.jMTkVNIb.js';
|
11
14
|
|
12
|
-
declare class
|
15
|
+
declare class WsHandler<T extends Context> {
|
13
16
|
private readonly standardHandler;
|
14
17
|
constructor(standardHandler: StandardHandler<T>);
|
15
|
-
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<
|
18
|
+
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
16
19
|
}
|
17
20
|
|
18
21
|
/**
|
@@ -21,8 +24,8 @@ declare class experimental_WsHandler<T extends Context> {
|
|
21
24
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
22
25
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
23
26
|
*/
|
24
|
-
declare class
|
27
|
+
declare class RPCHandler<T extends Context> extends WsHandler<T> {
|
25
28
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
26
29
|
}
|
27
30
|
|
28
|
-
export {
|
31
|
+
export { RPCHandler, WsHandler };
|
@@ -1,28 +1,28 @@
|
|
1
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
3
|
-
import {
|
3
|
+
import { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.CIL9uKTN.mjs';
|
8
8
|
import '@orpc/client/standard';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
10
|
+
import '../../shared/server.NeumLVdS.mjs';
|
10
11
|
|
11
|
-
class
|
12
|
+
class WsHandler {
|
12
13
|
constructor(standardHandler) {
|
13
14
|
this.standardHandler = standardHandler;
|
14
15
|
}
|
15
16
|
async upgrade(ws, ...rest) {
|
16
17
|
const peer = new ServerPeer(ws.send.bind(ws));
|
17
18
|
ws.addEventListener("message", async (event) => {
|
18
|
-
const message = Array.isArray(event.data) ? await new Blob(event.data)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
await peer.response(id, response ?? { status: 404, headers: {}, body: "No procedure matched" });
|
19
|
+
const message = Array.isArray(event.data) ? await readAsBuffer(new Blob(event.data)) : event.data;
|
20
|
+
await handleStandardServerPeerMessage(
|
21
|
+
this.standardHandler,
|
22
|
+
peer,
|
23
|
+
message,
|
24
|
+
resolveMaybeOptionalOptions(rest)
|
25
|
+
);
|
26
26
|
});
|
27
27
|
ws.addEventListener("close", () => {
|
28
28
|
peer.close();
|
@@ -30,10 +30,10 @@ class experimental_WsHandler {
|
|
30
30
|
}
|
31
31
|
}
|
32
32
|
|
33
|
-
class
|
33
|
+
class RPCHandler extends WsHandler {
|
34
34
|
constructor(router, options = {}) {
|
35
35
|
super(new StandardRPCHandler(router, options));
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
-
export {
|
39
|
+
export { RPCHandler, WsHandler };
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import { SerializeOptions, ParseOptions } from 'cookie';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Encodes a Uint8Array to base64url format
|
5
|
+
* Base64url is URL-safe and doesn't use padding
|
6
|
+
*
|
7
|
+
* @example
|
8
|
+
* ```ts
|
9
|
+
* const text = "Hello World"
|
10
|
+
* const encoded = encodeBase64url(new TextEncoder().encode(text))
|
11
|
+
* const decoded = decodeBase64url(encoded)
|
12
|
+
* expect(new TextDecoder().decode(decoded)).toEqual(text)
|
13
|
+
* ```
|
14
|
+
*/
|
15
|
+
declare function encodeBase64url(data: Uint8Array): string;
|
16
|
+
/**
|
17
|
+
* Decodes a base64url string to Uint8Array
|
18
|
+
* Returns undefined if the input is invalid
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```ts
|
22
|
+
* const text = "Hello World"
|
23
|
+
* const encoded = encodeBase64url(new TextEncoder().encode(text))
|
24
|
+
* const decoded = decodeBase64url(encoded)
|
25
|
+
* expect(new TextDecoder().decode(decoded)).toEqual(text)
|
26
|
+
* ```
|
27
|
+
*/
|
28
|
+
declare function decodeBase64url(base64url: string | undefined | null): Uint8Array | undefined;
|
29
|
+
|
30
|
+
interface SetCookieOptions extends SerializeOptions {
|
31
|
+
/**
|
32
|
+
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
33
|
+
*
|
34
|
+
* @default '/'
|
35
|
+
*/
|
36
|
+
path?: string;
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Sets a cookie in the response headers,
|
40
|
+
*
|
41
|
+
* Does nothing if `headers` is `undefined`.
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* ```ts
|
45
|
+
* const headers = new Headers()
|
46
|
+
*
|
47
|
+
* setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
|
48
|
+
*
|
49
|
+
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; HttpOnly; Max-Age=3600')
|
50
|
+
* ```
|
51
|
+
*
|
52
|
+
*/
|
53
|
+
declare function setCookie(headers: Headers | undefined, name: string, value: string, options?: SetCookieOptions): void;
|
54
|
+
interface GetCookieOptions extends ParseOptions {
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Gets a cookie value from request headers
|
58
|
+
*
|
59
|
+
* Returns `undefined` if the cookie is not found or headers are `undefined`.
|
60
|
+
*
|
61
|
+
* @example
|
62
|
+
* ```ts
|
63
|
+
* const headers = new Headers({ 'Cookie': 'sessionId=abc123; theme=dark' })
|
64
|
+
*
|
65
|
+
* const sessionId = getCookie(headers, 'sessionId')
|
66
|
+
*
|
67
|
+
* expect(sessionId).toEqual('abc123')
|
68
|
+
* ```
|
69
|
+
*/
|
70
|
+
declare function getCookie(headers: Headers | undefined, name: string, options?: GetCookieOptions): string | undefined;
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Encrypts a string using AES-GCM with a secret key.
|
74
|
+
* The output is base64url encoded to be URL-safe.
|
75
|
+
*
|
76
|
+
* @example
|
77
|
+
* ```ts
|
78
|
+
* const encrypted = await encrypt("Hello, World!", "test-secret-key")
|
79
|
+
* const decrypted = await decrypt(encrypted, "test-secret-key")
|
80
|
+
* expect(decrypted).toBe("Hello, World!")
|
81
|
+
* ```
|
82
|
+
*/
|
83
|
+
declare function encrypt(value: string, secret: string): Promise<string>;
|
84
|
+
/**
|
85
|
+
* Decrypts a base64url encoded string using AES-GCM with a secret key.
|
86
|
+
* Returns the original string if decryption is successful, or undefined if it fails.
|
87
|
+
*
|
88
|
+
* @example
|
89
|
+
* ```ts
|
90
|
+
* const encrypted = await encrypt("Hello, World!", "test-secret-key")
|
91
|
+
* const decrypted = await decrypt(encrypted, "test-secret-key")
|
92
|
+
* expect(decrypted).toBe("Hello, World!")
|
93
|
+
* ```
|
94
|
+
*/
|
95
|
+
declare function decrypt(encrypted: string | undefined | null, secret: string): Promise<string | undefined>;
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Signs a string value using HMAC-SHA256 with a secret key.
|
99
|
+
*
|
100
|
+
* This function creates a cryptographic signature that can be used to verify
|
101
|
+
* the integrity and authenticity of the data. The signature is appended to
|
102
|
+
* the original value, separated by a dot, using base64url encoding (no padding).
|
103
|
+
*
|
104
|
+
*
|
105
|
+
* @example
|
106
|
+
* ```ts
|
107
|
+
* const signedValue = await sign("user123", "my-secret-key")
|
108
|
+
* expect(signedValue).toEqual("user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA")
|
109
|
+
* ```
|
110
|
+
*/
|
111
|
+
declare function sign(value: string, secret: string): Promise<string>;
|
112
|
+
/**
|
113
|
+
* Verifies and extracts the original value from a signed string.
|
114
|
+
*
|
115
|
+
* This function validates the signature of a previously signed value using the same
|
116
|
+
* secret key. If the signature is valid, it returns the original value. If the
|
117
|
+
* signature is invalid or the format is incorrect, it returns undefined.
|
118
|
+
*
|
119
|
+
*
|
120
|
+
* @example
|
121
|
+
* ```ts
|
122
|
+
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
123
|
+
* const originalValue = await unsign(signedValue, "my-secret-key")
|
124
|
+
* expect(originalValue).toEqual("user123")
|
125
|
+
* ```
|
126
|
+
*/
|
127
|
+
declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
128
|
+
|
129
|
+
export { decodeBase64url, decrypt, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
130
|
+
export type { GetCookieOptions, SetCookieOptions };
|