@orpc/server 0.0.0-next.3636544 → 0.0.0-next.36cf381
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 +134 -14
- package/dist/adapters/aws-lambda/index.d.mts +7 -7
- package/dist/adapters/aws-lambda/index.d.ts +7 -7
- package/dist/adapters/aws-lambda/index.mjs +5 -7
- package/dist/adapters/bun-ws/index.d.mts +7 -7
- package/dist/adapters/bun-ws/index.d.ts +7 -7
- package/dist/adapters/bun-ws/index.mjs +12 -12
- package/dist/adapters/crossws/index.d.mts +7 -7
- package/dist/adapters/crossws/index.d.ts +7 -7
- package/dist/adapters/crossws/index.mjs +7 -9
- package/dist/adapters/fastify/index.d.mts +53 -0
- package/dist/adapters/fastify/index.d.ts +53 -0
- package/dist/adapters/fastify/index.mjs +52 -0
- package/dist/adapters/fetch/index.d.mts +57 -12
- package/dist/adapters/fetch/index.d.ts +57 -12
- package/dist/adapters/fetch/index.mjs +75 -6
- package/dist/adapters/message-port/index.d.mts +37 -11
- package/dist/adapters/message-port/index.d.ts +37 -11
- package/dist/adapters/message-port/index.mjs +31 -17
- package/dist/adapters/node/index.d.mts +34 -13
- package/dist/adapters/node/index.d.ts +34 -13
- package/dist/adapters/node/index.mjs +70 -16
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/standard-peer/index.d.mts +9 -5
- package/dist/adapters/standard-peer/index.d.ts +9 -5
- package/dist/adapters/standard-peer/index.mjs +21 -7
- package/dist/adapters/websocket/index.d.mts +12 -10
- package/dist/adapters/websocket/index.d.ts +12 -10
- package/dist/adapters/websocket/index.mjs +7 -9
- package/dist/adapters/ws/index.d.mts +7 -7
- package/dist/adapters/ws/index.d.ts +7 -7
- package/dist/adapters/ws/index.mjs +7 -9
- package/dist/helpers/index.d.mts +20 -1
- package/dist/helpers/index.d.ts +20 -1
- package/dist/helpers/index.mjs +17 -1
- package/dist/hibernation/index.d.mts +13 -13
- package/dist/hibernation/index.d.ts +13 -13
- package/dist/hibernation/index.mjs +8 -8
- package/dist/index.d.mts +103 -103
- package/dist/index.d.ts +103 -103
- package/dist/index.mjs +35 -32
- package/dist/plugins/index.d.mts +46 -11
- package/dist/plugins/index.d.ts +46 -11
- package/dist/plugins/index.mjs +110 -58
- package/dist/shared/{server.DVBSOxWU.d.ts → server.7cEtMB30.d.ts} +1 -1
- package/dist/shared/{server.Cu-7se50.d.mts → server.B8gYOD5g.d.mts} +2 -2
- package/dist/shared/{server.DHgXKx3q.d.mts → server.BqadksTP.d.mts} +1 -1
- package/dist/shared/{server.Cwq7K86l.d.mts → server.C8_sRzQB.d.mts} +1 -1
- package/dist/shared/{server.CC8z0B3U.d.mts → server.ChUyt5-i.d.mts} +3 -3
- package/dist/shared/{server.a_VzWVCm.d.ts → server.ChyoA9XY.d.ts} +1 -1
- package/dist/shared/{server.NeumLVdS.mjs → server.DEBcqOjg.mjs} +116 -68
- package/dist/shared/{server.CNZgPgce.d.ts → server.EfTOZ2Q7.d.ts} +2 -2
- package/dist/shared/{server.BW-nUGgA.mjs → server.TEVCLCFC.mjs} +3 -0
- package/dist/shared/{server.CIL9uKTN.mjs → server.ZxHCEN1h.mjs} +71 -39
- package/dist/shared/{server.wMv480px.d.mts → server.qKsRrdxW.d.mts} +13 -12
- package/dist/shared/{server.wMv480px.d.ts → server.qKsRrdxW.d.ts} +13 -12
- package/dist/shared/{server.DOwaI1le.d.ts → server.yoEB3Fx4.d.ts} +3 -3
- package/package.json +27 -17
- package/dist/shared/server.C6Q5sqYw.mjs +0 -20
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
|
3
|
-
import {
|
|
3
|
+
import { createServerPeerHandleRequestFn } from '../standard-peer/index.mjs';
|
|
4
|
+
import { b as StandardRPCHandler } from '../../shared/server.ZxHCEN1h.mjs';
|
|
5
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
|
6
|
+
import '@orpc/client/standard';
|
|
4
7
|
import '@orpc/client';
|
|
5
8
|
import '@orpc/standard-server';
|
|
9
|
+
import '../../shared/server.DEBcqOjg.mjs';
|
|
6
10
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.CIL9uKTN.mjs';
|
|
8
|
-
import '@orpc/client/standard';
|
|
9
|
-
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.NeumLVdS.mjs';
|
|
11
11
|
|
|
12
12
|
class WsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -17,11 +17,9 @@ class WsHandler {
|
|
|
17
17
|
const peer = new ServerPeer(ws.send.bind(ws));
|
|
18
18
|
ws.addEventListener("message", async (event) => {
|
|
19
19
|
const message = Array.isArray(event.data) ? await readAsBuffer(new Blob(event.data)) : event.data;
|
|
20
|
-
await
|
|
21
|
-
this.standardHandler,
|
|
22
|
-
peer,
|
|
20
|
+
await peer.message(
|
|
23
21
|
message,
|
|
24
|
-
resolveMaybeOptionalOptions(rest)
|
|
22
|
+
createServerPeerHandleRequestFn(this.standardHandler, resolveMaybeOptionalOptions(rest))
|
|
25
23
|
);
|
|
26
24
|
});
|
|
27
25
|
ws.addEventListener("close", () => {
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -68,6 +68,10 @@ interface GetCookieOptions extends ParseOptions {
|
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
declare function getCookie(headers: Headers | undefined, name: string, options?: GetCookieOptions): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Deletes a cookie by marking it expired.
|
|
73
|
+
*/
|
|
74
|
+
declare function deleteCookie(headers: Headers | undefined, name: string, options?: Omit<SetCookieOptions, 'maxAge'>): void;
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
77
|
* Encrypts a string using AES-GCM with a secret key.
|
|
@@ -125,6 +129,21 @@ declare function sign(value: string, secret: string): Promise<string>;
|
|
|
125
129
|
* ```
|
|
126
130
|
*/
|
|
127
131
|
declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Extracts the value part from a signed string without verification.
|
|
134
|
+
*
|
|
135
|
+
* This function simply extracts the original value from a signed string
|
|
136
|
+
* without performing any signature verification. It's useful when you need
|
|
137
|
+
* to access the value quickly without the overhead of cryptographic verification.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
142
|
+
* const value = getSignedValue(signedValue)
|
|
143
|
+
* expect(value).toEqual("user123")
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
|
|
128
147
|
|
|
129
|
-
export { decodeBase64url, decrypt, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
|
148
|
+
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
|
|
130
149
|
export type { GetCookieOptions, SetCookieOptions };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -68,6 +68,10 @@ interface GetCookieOptions extends ParseOptions {
|
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
declare function getCookie(headers: Headers | undefined, name: string, options?: GetCookieOptions): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Deletes a cookie by marking it expired.
|
|
73
|
+
*/
|
|
74
|
+
declare function deleteCookie(headers: Headers | undefined, name: string, options?: Omit<SetCookieOptions, 'maxAge'>): void;
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
77
|
* Encrypts a string using AES-GCM with a secret key.
|
|
@@ -125,6 +129,21 @@ declare function sign(value: string, secret: string): Promise<string>;
|
|
|
125
129
|
* ```
|
|
126
130
|
*/
|
|
127
131
|
declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Extracts the value part from a signed string without verification.
|
|
134
|
+
*
|
|
135
|
+
* This function simply extracts the original value from a signed string
|
|
136
|
+
* without performing any signature verification. It's useful when you need
|
|
137
|
+
* to access the value quickly without the overhead of cryptographic verification.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
142
|
+
* const value = getSignedValue(signedValue)
|
|
143
|
+
* expect(value).toEqual("user123")
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
|
|
128
147
|
|
|
129
|
-
export { decodeBase64url, decrypt, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
|
148
|
+
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
|
|
130
149
|
export type { GetCookieOptions, SetCookieOptions };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -50,6 +50,12 @@ function getCookie(headers, name, options = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
return parse(cookieHeader, options)[name];
|
|
52
52
|
}
|
|
53
|
+
function deleteCookie(headers, name, options = {}) {
|
|
54
|
+
return setCookie(headers, name, "", {
|
|
55
|
+
...options,
|
|
56
|
+
maxAge: 0
|
|
57
|
+
});
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
const PBKDF2_CONFIG = {
|
|
55
61
|
name: "PBKDF2",
|
|
@@ -178,5 +184,15 @@ async function unsign(signedValue, secret) {
|
|
|
178
184
|
);
|
|
179
185
|
return isValid ? value : void 0;
|
|
180
186
|
}
|
|
187
|
+
function getSignedValue(signedValue) {
|
|
188
|
+
if (typeof signedValue !== "string") {
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
const lastDotIndex = signedValue.lastIndexOf(".");
|
|
192
|
+
if (lastDotIndex === -1) {
|
|
193
|
+
return void 0;
|
|
194
|
+
}
|
|
195
|
+
return signedValue.slice(0, lastDotIndex);
|
|
196
|
+
}
|
|
181
197
|
|
|
182
|
-
export { decodeBase64url, decrypt, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
|
198
|
+
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
2
|
+
import { C as Context, R as Router } from '../shared/server.qKsRrdxW.mjs';
|
|
3
|
+
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
4
|
+
export { HibernationEventIterator, HibernationEventIteratorCallback } from '@orpc/standard-server';
|
|
5
|
+
import { g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.BqadksTP.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
import '@orpc/shared';
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
interface EncodeHibernationRPCEventOptions extends StandardRPCJsonSerializerOptions {
|
|
11
11
|
/**
|
|
12
12
|
* The type of event, each type corresponds a different operation
|
|
13
13
|
*
|
|
@@ -22,23 +22,23 @@ interface experimental_EncodeHibernationRPCEventOptions extends StandardRPCJsonS
|
|
|
22
22
|
/**
|
|
23
23
|
* Encodes a Hibernation RPC Event
|
|
24
24
|
*
|
|
25
|
-
* @see {@link https://orpc.
|
|
25
|
+
* @see {@link https://orpc.dev/docs/plugins/hibernation Hibernation Plugin}
|
|
26
26
|
*/
|
|
27
|
-
declare function
|
|
27
|
+
declare function encodeHibernationRPCEvent(id: string, payload: unknown, options?: EncodeHibernationRPCEventOptions): string;
|
|
28
28
|
|
|
29
|
-
interface
|
|
30
|
-
iterator?:
|
|
29
|
+
interface HibernationPluginContext {
|
|
30
|
+
iterator?: HibernationEventIterator<any>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Enable Hibernation APIs
|
|
34
34
|
*
|
|
35
|
-
* @see {@link https://orpc.
|
|
35
|
+
* @see {@link https://orpc.dev/docs/plugins/hibernation Hibernation Plugin}
|
|
36
36
|
*/
|
|
37
|
-
declare class
|
|
37
|
+
declare class HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
38
38
|
readonly CONTEXT_SYMBOL: symbol;
|
|
39
39
|
order: number;
|
|
40
40
|
init(options: StandardHandlerOptions<T>, _router: Router<any, T>): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export {
|
|
44
|
-
export type {
|
|
43
|
+
export { HibernationPlugin, encodeHibernationRPCEvent };
|
|
44
|
+
export type { EncodeHibernationRPCEventOptions, HibernationPluginContext };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
2
|
+
import { C as Context, R as Router } from '../shared/server.qKsRrdxW.js';
|
|
3
|
+
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
4
|
+
export { HibernationEventIterator, HibernationEventIteratorCallback } from '@orpc/standard-server';
|
|
5
|
+
import { g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.7cEtMB30.js';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
import '@orpc/shared';
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
interface EncodeHibernationRPCEventOptions extends StandardRPCJsonSerializerOptions {
|
|
11
11
|
/**
|
|
12
12
|
* The type of event, each type corresponds a different operation
|
|
13
13
|
*
|
|
@@ -22,23 +22,23 @@ interface experimental_EncodeHibernationRPCEventOptions extends StandardRPCJsonS
|
|
|
22
22
|
/**
|
|
23
23
|
* Encodes a Hibernation RPC Event
|
|
24
24
|
*
|
|
25
|
-
* @see {@link https://orpc.
|
|
25
|
+
* @see {@link https://orpc.dev/docs/plugins/hibernation Hibernation Plugin}
|
|
26
26
|
*/
|
|
27
|
-
declare function
|
|
27
|
+
declare function encodeHibernationRPCEvent(id: string, payload: unknown, options?: EncodeHibernationRPCEventOptions): string;
|
|
28
28
|
|
|
29
|
-
interface
|
|
30
|
-
iterator?:
|
|
29
|
+
interface HibernationPluginContext {
|
|
30
|
+
iterator?: HibernationEventIterator<any>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Enable Hibernation APIs
|
|
34
34
|
*
|
|
35
|
-
* @see {@link https://orpc.
|
|
35
|
+
* @see {@link https://orpc.dev/docs/plugins/hibernation Hibernation Plugin}
|
|
36
36
|
*/
|
|
37
|
-
declare class
|
|
37
|
+
declare class HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
38
38
|
readonly CONTEXT_SYMBOL: symbol;
|
|
39
39
|
order: number;
|
|
40
40
|
init(options: StandardHandlerOptions<T>, _router: Router<any, T>): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export {
|
|
44
|
-
export type {
|
|
43
|
+
export { HibernationPlugin, encodeHibernationRPCEvent };
|
|
44
|
+
export type { EncodeHibernationRPCEventOptions, HibernationPluginContext };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toORPCError } from '@orpc/client';
|
|
2
2
|
import { StandardRPCJsonSerializer } from '@orpc/client/standard';
|
|
3
3
|
import { stringifyJSON } from '@orpc/shared';
|
|
4
|
-
import { getEventMeta,
|
|
5
|
-
export {
|
|
4
|
+
import { getEventMeta, HibernationEventIterator } from '@orpc/standard-server';
|
|
5
|
+
export { HibernationEventIterator } from '@orpc/standard-server';
|
|
6
6
|
import { MessageType } from '@orpc/standard-server-peer';
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function encodeHibernationRPCEvent(id, payload, options = {}) {
|
|
9
9
|
const { event = "message", ...rest } = options;
|
|
10
10
|
const serializer = new StandardRPCJsonSerializer(rest);
|
|
11
11
|
const data = event === "error" ? toORPCError(payload).toJSON() : payload;
|
|
@@ -21,7 +21,7 @@ function experimental_encodeHibernationRPCEvent(id, payload, options = {}) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
class
|
|
24
|
+
class HibernationPlugin {
|
|
25
25
|
CONTEXT_SYMBOL = Symbol("ORPC_HIBERNATION_CONTEXT");
|
|
26
26
|
order = 2e6;
|
|
27
27
|
// make sure execute after the batch plugin
|
|
@@ -33,8 +33,8 @@ class experimental_HibernationPlugin {
|
|
|
33
33
|
const result = await options2.next({
|
|
34
34
|
...options2,
|
|
35
35
|
context: {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
...options2.context,
|
|
37
|
+
[this.CONTEXT_SYMBOL]: hibernationContext
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
if (!result.matched || !hibernationContext.iterator) {
|
|
@@ -54,7 +54,7 @@ class experimental_HibernationPlugin {
|
|
|
54
54
|
throw new TypeError("[HibernationPlugin] Hibernation context has been corrupted or modified by another plugin or interceptor");
|
|
55
55
|
}
|
|
56
56
|
const output = await options2.next();
|
|
57
|
-
if (output instanceof
|
|
57
|
+
if (output instanceof HibernationEventIterator) {
|
|
58
58
|
hibernationContext.iterator = output;
|
|
59
59
|
}
|
|
60
60
|
return output;
|
|
@@ -62,4 +62,4 @@ class experimental_HibernationPlugin {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export {
|
|
65
|
+
export { HibernationPlugin, encodeHibernationRPCEvent };
|