@zudojs/rpc 1.4.2 → 1.5.0

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 (114) hide show
  1. package/README.md +22 -0
  2. package/dist/index.d.ts +1 -2
  3. package/dist/index.js +1 -2
  4. package/dist/rpc/client/index.d.ts +0 -1
  5. package/dist/rpc/client/index.js +0 -1
  6. package/dist/rpc/client/rpcClient.core.d.ts +0 -1
  7. package/dist/rpc/client/rpcClient.core.js +0 -1
  8. package/dist/rpc/client/rpcWireError.helper.d.ts +0 -1
  9. package/dist/rpc/client/rpcWireError.helper.js +0 -1
  10. package/dist/rpc/constants/index.d.ts +1 -2
  11. package/dist/rpc/constants/index.js +1 -2
  12. package/dist/rpc/constants/rpcConstants.core.d.ts +7 -1
  13. package/dist/rpc/constants/rpcConstants.core.js +7 -1
  14. package/dist/rpc/context/index.d.ts +0 -1
  15. package/dist/rpc/context/index.js +0 -1
  16. package/dist/rpc/context/rpcContext.type.d.ts +0 -1
  17. package/dist/rpc/context/rpcContext.type.js +0 -1
  18. package/dist/rpc/dispatcher/index.d.ts +0 -1
  19. package/dist/rpc/dispatcher/index.js +0 -1
  20. package/dist/rpc/dispatcher/rpcDispatcher.core.d.ts +0 -1
  21. package/dist/rpc/dispatcher/rpcDispatcher.core.js +10 -4
  22. package/dist/rpc/dispatcher/rpcDispatcher.downstream.d.ts +26 -0
  23. package/dist/rpc/dispatcher/rpcDispatcher.downstream.js +41 -0
  24. package/dist/rpc/errors/index.d.ts +0 -1
  25. package/dist/rpc/errors/index.js +0 -1
  26. package/dist/rpc/errors/rpc.errors.d.ts +0 -1
  27. package/dist/rpc/errors/rpc.errors.js +0 -1
  28. package/dist/rpc/errors/rpcErrorCause.helper.d.ts +10 -0
  29. package/dist/rpc/errors/rpcErrorCause.helper.js +18 -0
  30. package/dist/rpc/interceptor/index.d.ts +0 -1
  31. package/dist/rpc/interceptor/index.js +0 -1
  32. package/dist/rpc/interceptor/rpcInterceptor.type.d.ts +0 -1
  33. package/dist/rpc/interceptor/rpcInterceptor.type.js +0 -1
  34. package/dist/rpc/middleware/index.d.ts +0 -1
  35. package/dist/rpc/middleware/index.js +0 -1
  36. package/dist/rpc/middleware/rpcMiddleware.core.d.ts +0 -1
  37. package/dist/rpc/middleware/rpcMiddleware.core.js +0 -1
  38. package/dist/rpc/procedure/index.d.ts +0 -1
  39. package/dist/rpc/procedure/index.js +0 -1
  40. package/dist/rpc/procedure/rpcProcedure.type.d.ts +0 -1
  41. package/dist/rpc/procedure/rpcProcedure.type.js +0 -1
  42. package/dist/rpc/procedure/rpcProcedureRegistry.core.d.ts +0 -1
  43. package/dist/rpc/procedure/rpcProcedureRegistry.core.js +0 -1
  44. package/dist/rpc/procedure/rpcProcedureRouter.core.d.ts +0 -1
  45. package/dist/rpc/procedure/rpcProcedureRouter.core.js +0 -1
  46. package/dist/rpc/reliability/cancellation/rpcAbort.helper.d.ts +0 -1
  47. package/dist/rpc/reliability/cancellation/rpcAbort.helper.js +0 -1
  48. package/dist/rpc/reliability/cancellation/rpcCancellation.helper.d.ts +0 -1
  49. package/dist/rpc/reliability/cancellation/rpcCancellation.helper.js +0 -1
  50. package/dist/rpc/reliability/deadline/rpcDeadline.helper.d.ts +0 -1
  51. package/dist/rpc/reliability/deadline/rpcDeadline.helper.js +0 -1
  52. package/dist/rpc/reliability/index.d.ts +0 -1
  53. package/dist/rpc/reliability/index.js +0 -1
  54. package/dist/rpc/reliability/retry/rpcRetry.helper.d.ts +9 -1
  55. package/dist/rpc/reliability/retry/rpcRetry.helper.js +0 -1
  56. package/dist/rpc/reliability/timeout/rpcTimeout.helper.d.ts +0 -1
  57. package/dist/rpc/reliability/timeout/rpcTimeout.helper.js +0 -1
  58. package/dist/rpc/server/index.d.ts +0 -1
  59. package/dist/rpc/server/index.js +0 -1
  60. package/dist/rpc/server/rpcBaseErrorMapping.helper.d.ts +0 -1
  61. package/dist/rpc/server/rpcBaseErrorMapping.helper.js +0 -1
  62. package/dist/rpc/server/rpcDownstreamMapping.helper.d.ts +15 -0
  63. package/dist/rpc/server/rpcDownstreamMapping.helper.js +27 -0
  64. package/dist/rpc/server/rpcErrorMapping.helper.d.ts +2 -4
  65. package/dist/rpc/server/rpcErrorMapping.helper.js +6 -4
  66. package/dist/rpc/server/rpcServer.core.d.ts +0 -1
  67. package/dist/rpc/server/rpcServer.core.js +0 -1
  68. package/dist/rpc/streaming/index.d.ts +0 -1
  69. package/dist/rpc/streaming/index.js +0 -1
  70. package/dist/rpc/streaming/rpcStreaming.type.d.ts +0 -1
  71. package/dist/rpc/streaming/rpcStreaming.type.js +0 -1
  72. package/dist/rpc/transport/codec/index.d.ts +0 -1
  73. package/dist/rpc/transport/codec/index.js +0 -1
  74. package/dist/rpc/transport/codec/rpcBody.helper.d.ts +0 -1
  75. package/dist/rpc/transport/codec/rpcBody.helper.js +0 -1
  76. package/dist/rpc/transport/codec/rpcCodec.helper.d.ts +0 -1
  77. package/dist/rpc/transport/codec/rpcCodec.helper.js +0 -1
  78. package/dist/rpc/transport/http/index.d.ts +0 -1
  79. package/dist/rpc/transport/http/index.js +0 -1
  80. package/dist/rpc/transport/http/rpcFetchHandler.core.d.ts +0 -1
  81. package/dist/rpc/transport/http/rpcFetchHandler.core.js +0 -1
  82. package/dist/rpc/transport/http/rpcHttpExchange.helper.d.ts +0 -1
  83. package/dist/rpc/transport/http/rpcHttpExchange.helper.js +1 -10
  84. package/dist/rpc/transport/http/rpcHttpStatus.helper.d.ts +0 -1
  85. package/dist/rpc/transport/http/rpcHttpStatus.helper.js +0 -1
  86. package/dist/rpc/transport/http/rpcHttpTransport.core.d.ts +0 -1
  87. package/dist/rpc/transport/http/rpcHttpTransport.core.js +0 -1
  88. package/dist/rpc/transport/index.d.ts +0 -1
  89. package/dist/rpc/transport/index.js +0 -1
  90. package/dist/rpc/transport/memory/index.d.ts +0 -1
  91. package/dist/rpc/transport/memory/index.js +0 -1
  92. package/dist/rpc/transport/memory/rpcMemoryTransport.core.d.ts +0 -1
  93. package/dist/rpc/transport/memory/rpcMemoryTransport.core.js +0 -1
  94. package/dist/rpc/transport/rpcTransport.type.d.ts +0 -1
  95. package/dist/rpc/transport/rpcTransport.type.js +0 -1
  96. package/dist/rpc/types/index.d.ts +0 -1
  97. package/dist/rpc/types/index.js +0 -1
  98. package/dist/rpc/types/rpcMetadata.type.d.ts +0 -1
  99. package/dist/rpc/types/rpcMetadata.type.js +0 -1
  100. package/dist/rpc/types/rpcProcedureName.type.d.ts +0 -1
  101. package/dist/rpc/types/rpcProcedureName.type.js +0 -1
  102. package/dist/rpc/types/rpcRequest.type.d.ts +0 -1
  103. package/dist/rpc/types/rpcRequest.type.js +0 -1
  104. package/dist/rpc/types/rpcResponse.type.d.ts +0 -1
  105. package/dist/rpc/types/rpcResponse.type.js +0 -1
  106. package/dist/rpc/validation/index.d.ts +0 -1
  107. package/dist/rpc/validation/index.js +0 -1
  108. package/dist/rpc/validation/rpcValidation.core.d.ts +0 -1
  109. package/dist/rpc/validation/rpcValidation.core.js +0 -1
  110. package/dist/testing/index.d.ts +0 -1
  111. package/dist/testing/index.js +0 -1
  112. package/package.json +7 -7
  113. package/dist/rpc/validation/rpcUnsafeKey.helper.d.ts +0 -18
  114. package/dist/rpc/validation/rpcUnsafeKey.helper.js +0 -60
@@ -20,9 +20,8 @@ export interface RPCMappedError {
20
20
  * `RPC_CONFLICT`, `RPC_VALIDATION_ERROR` …). Anything not built to be
21
21
  * exposed — an `RPCInternalError`, a non-exposed custom `RPCError` or
22
22
  * `BaseError`, or any other error — is answered with
23
- * {@link INTERNAL_ERROR_MESSAGE}, so exception text, stack traces and
24
- * causes never reach the remote side — nor does a non-exposed custom
25
- * code ({@link withheldRPCErrorCode}).
23
+ * {@link INTERNAL_ERROR_MESSAGE} and its custom code withheld
24
+ * ({@link withheldRPCErrorCode}), so no server detail reaches the peer.
26
25
  */
27
26
  export declare function mapRPCError(error: unknown): RPCMappedError;
28
27
  /**
@@ -33,4 +32,3 @@ export declare function mapRPCError(error: unknown): RPCMappedError;
33
32
  * reported by the server or raised locally (its own deadline, a cancel).
34
33
  */
35
34
  export declare function rpcWireCodeOf(error: unknown): string | undefined;
36
- //# sourceMappingURL=rpcErrorMapping.helper.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { isRPCError, RPCAuthenticationError, RPCCancelledError, RPCDeadlineExceededError, RPCDeserializationError, RPCForbiddenError, RPCInternalError, RPCInvalidRequestError, RPCProcedureNotFoundError, RPCRateLimitedError, RPCSerializationError, RPCTimeoutError, RPCTransportError, RPCUnavailableError, RPCValidationError, } from "../errors/rpc.errors.js";
2
2
  import { INTERNAL_ERROR_MESSAGE } from "../constants/rpcConstants.core.js";
3
3
  import { mapExposedBaseError, withheldRPCErrorCode } from "./rpcBaseErrorMapping.helper.js";
4
+ import { mapDownstreamError } from "./rpcDownstreamMapping.helper.js";
4
5
  /**
5
6
  * Wire codes for the error types the server maps.
6
7
  *
@@ -33,14 +34,16 @@ const ERROR_CODES = [
33
34
  * `RPC_CONFLICT`, `RPC_VALIDATION_ERROR` …). Anything not built to be
34
35
  * exposed — an `RPCInternalError`, a non-exposed custom `RPCError` or
35
36
  * `BaseError`, or any other error — is answered with
36
- * {@link INTERNAL_ERROR_MESSAGE}, so exception text, stack traces and
37
- * causes never reach the remote side — nor does a non-exposed custom
38
- * code ({@link withheldRPCErrorCode}).
37
+ * {@link INTERNAL_ERROR_MESSAGE} and its custom code withheld
38
+ * ({@link withheldRPCErrorCode}), so no server detail reaches the peer.
39
39
  */
40
40
  export function mapRPCError(error) {
41
41
  if (error instanceof RPCInternalError || !(error instanceof Error)) {
42
42
  return internalFailure("RPC_INTERNAL_ERROR");
43
43
  }
44
+ const downstream = mapDownstreamError(error);
45
+ if (downstream !== undefined)
46
+ return downstream;
44
47
  for (const [type, code, internal] of ERROR_CODES) {
45
48
  if (error instanceof type) {
46
49
  return internal === true
@@ -99,4 +102,3 @@ function exposed(code, message, details) {
99
102
  function internalFailure(code) {
100
103
  return { payload: { code, message: INTERNAL_ERROR_MESSAGE }, internal: true };
101
104
  }
102
- //# sourceMappingURL=rpcErrorMapping.helper.js.map
@@ -62,4 +62,3 @@ export declare class RPCServer {
62
62
  */
63
63
  getRegistry(): RPCProcedureRegistry;
64
64
  }
65
- //# sourceMappingURL=rpcServer.core.d.ts.map
@@ -84,4 +84,3 @@ export class RPCServer {
84
84
  return this.registry;
85
85
  }
86
86
  }
87
- //# sourceMappingURL=rpcServer.core.js.map
@@ -1,3 +1,2 @@
1
1
  export type { RPCStreamingHandler, RPCStreamingProcedure, } from "./rpcStreaming.type.js";
2
2
  export { createRPCStreamingProcedure } from "./rpcStreaming.type.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export { createRPCStreamingProcedure } from "./rpcStreaming.type.js";
2
- //# sourceMappingURL=index.js.map
@@ -28,4 +28,3 @@ export interface RPCStreamingProcedure<TInput = unknown, TOutput = unknown> {
28
28
  * Creates a streaming RPC procedure.
29
29
  */
30
30
  export declare function createRPCStreamingProcedure<TInput = unknown, TOutput = unknown>(name: string, handler: RPCStreamingHandler<TInput, TOutput>): RPCStreamingProcedure<TInput, TOutput>;
31
- //# sourceMappingURL=rpcStreaming.type.d.ts.map
@@ -21,4 +21,3 @@ export function createRPCStreamingProcedure(name, handler) {
21
21
  handler,
22
22
  });
23
23
  }
24
- //# sourceMappingURL=rpcStreaming.type.js.map
@@ -7,4 +7,3 @@ export type { RPCFrameSerializer, RPCJsonSerializerOptions, } from "./rpcCodec.h
7
7
  export { createRPCJsonSerializer, isRPCResponseFrame } from "./rpcCodec.helper.js";
8
8
  export type { RPCBodyReadResult, RPCBodySource } from "./rpcBody.helper.js";
9
9
  export { readBoundedBody } from "./rpcBody.helper.js";
10
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { createRPCJsonSerializer, isRPCResponseFrame } from "./rpcCodec.helper.js";
7
7
  export { readBoundedBody } from "./rpcBody.helper.js";
8
- //# sourceMappingURL=index.js.map
@@ -33,4 +33,3 @@ export interface RPCBodySource {
33
33
  * @param maxBytes Limit in bytes; `0` or less disables the limit.
34
34
  */
35
35
  export declare function readBoundedBody(source: RPCBodySource, maxBytes: number): Promise<RPCBodyReadResult>;
36
- //# sourceMappingURL=rpcBody.helper.d.ts.map
@@ -61,4 +61,3 @@ function concat(chunks, total) {
61
61
  }
62
62
  return joined;
63
63
  }
64
- //# sourceMappingURL=rpcBody.helper.js.map
@@ -38,4 +38,3 @@ export declare function createRPCJsonSerializer(options?: RPCJsonSerializerOptio
38
38
  * transport failure instead of being read as a result.
39
39
  */
40
40
  export declare function isRPCResponseFrame(value: unknown): value is RPCResponse;
41
- //# sourceMappingURL=rpcCodec.helper.d.ts.map
@@ -37,4 +37,3 @@ export function isRPCResponseFrame(value) {
37
37
  typeof error.code === "string" &&
38
38
  typeof error.message === "string");
39
39
  }
40
- //# sourceMappingURL=rpcCodec.helper.js.map
@@ -9,4 +9,3 @@ export { createRPCHttpTransport } from "./rpcHttpTransport.core.js";
9
9
  export type { RPCFetchHandlerOptions } from "./rpcFetchHandler.core.js";
10
10
  export { createRPCFetchHandler } from "./rpcFetchHandler.core.js";
11
11
  export { RPC_HTTP_STATUS, rpcHttpStatus } from "./rpcHttpStatus.helper.js";
12
- //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,3 @@
7
7
  export { createRPCHttpTransport } from "./rpcHttpTransport.core.js";
8
8
  export { createRPCFetchHandler } from "./rpcFetchHandler.core.js";
9
9
  export { RPC_HTTP_STATUS, rpcHttpStatus } from "./rpcHttpStatus.helper.js";
10
- //# sourceMappingURL=index.js.map
@@ -33,4 +33,3 @@ export interface RPCFetchHandlerOptions {
33
33
  * disconnects cancels the procedure (its `context.signal` aborts).
34
34
  */
35
35
  export declare function createRPCFetchHandler(server: RPCFrameHandler, options?: RPCFetchHandlerOptions): (request: Request) => Promise<Response>;
36
- //# sourceMappingURL=rpcFetchHandler.core.d.ts.map
@@ -94,4 +94,3 @@ function readFrameId(frame) {
94
94
  const id = frame?.id;
95
95
  return typeof id === "string" && id.length <= MAX_RPC_REQUEST_ID_LENGTH && /^[\w.:-]+$/.test(id) ? id : "";
96
96
  }
97
- //# sourceMappingURL=rpcFetchHandler.core.js.map
@@ -24,4 +24,3 @@ export declare function fetchOrThrow(run: () => Promise<Response>, signal: Abort
24
24
  export declare function encode(serializer: RPCFrameSerializer, request: RPCRequest): string;
25
25
  /** Reads, parses and shape-checks the reply to `request`. */
26
26
  export declare function decode(serializer: RPCFrameSerializer, response: Response, maxBytes: number, request: RPCRequest): Promise<RPCResponse>;
27
- //# sourceMappingURL=rpcHttpExchange.helper.d.ts.map
@@ -8,6 +8,7 @@ import { RPCSerializationError, RPCTimeoutError, RPCTransportError, } from "../.
8
8
  import { combineSignals } from "../../reliability/cancellation/rpcCancellation.helper.js";
9
9
  import { abortReasonToRPCError } from "../../reliability/cancellation/rpcAbort.helper.js";
10
10
  import { MAX_TIMER_DELAY } from "../../constants/rpcConstants.core.js";
11
+ import { withCause } from "../../errors/rpcErrorCause.helper.js";
11
12
  /**
12
13
  * Links the caller signal and the deadline into one abort signal.
13
14
  *
@@ -66,13 +67,3 @@ export async function decode(serializer, response, maxBytes, request) {
66
67
  }
67
68
  return frame;
68
69
  }
69
- function withCause(error, cause) {
70
- Object.defineProperty(error, "cause", {
71
- value: cause,
72
- enumerable: false,
73
- configurable: true,
74
- writable: true,
75
- });
76
- return error;
77
- }
78
- //# sourceMappingURL=rpcHttpExchange.helper.js.map
@@ -13,4 +13,3 @@ export declare const RPC_HTTP_STATUS: Readonly<Record<string, number>>;
13
13
  * mapped status for a known error code, and 500 otherwise.
14
14
  */
15
15
  export declare function rpcHttpStatus(response: RPCResponse): number;
16
- //# sourceMappingURL=rpcHttpStatus.helper.d.ts.map
@@ -34,4 +34,3 @@ export function rpcHttpStatus(response) {
34
34
  const code = response.error?.code;
35
35
  return (code !== undefined ? RPC_HTTP_STATUS[code] : undefined) ?? 500;
36
36
  }
37
- //# sourceMappingURL=rpcHttpStatus.helper.js.map
@@ -33,4 +33,3 @@ export interface RPCHttpTransportOptions {
33
33
  * returned as a response for the client to rebuild into a typed error.
34
34
  */
35
35
  export declare function createRPCHttpTransport(options: RPCHttpTransportOptions): RPCTransport;
36
- //# sourceMappingURL=rpcHttpTransport.core.d.ts.map
@@ -42,4 +42,3 @@ export function createRPCHttpTransport(options) {
42
42
  },
43
43
  };
44
44
  }
45
- //# sourceMappingURL=rpcHttpTransport.core.js.map
@@ -11,4 +11,3 @@ export type { RPCFrameHandler, RPCMemoryTransportOptions, } from "./memory/index
11
11
  export { createRPCMemoryTransport } from "./memory/index.js";
12
12
  export type { RPCHttpHeaders, RPCHttpTransportOptions, RPCFetchHandlerOptions, } from "./http/index.js";
13
13
  export { createRPCHttpTransport, createRPCFetchHandler, RPC_HTTP_STATUS, rpcHttpStatus, } from "./http/index.js";
14
- //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,3 @@
7
7
  export { createRPCJsonSerializer, isRPCResponseFrame, readBoundedBody, } from "./codec/index.js";
8
8
  export { createRPCMemoryTransport } from "./memory/index.js";
9
9
  export { createRPCHttpTransport, createRPCFetchHandler, RPC_HTTP_STATUS, rpcHttpStatus, } from "./http/index.js";
10
- //# sourceMappingURL=index.js.map
@@ -4,4 +4,3 @@
4
4
  */
5
5
  export type { RPCFrameHandler, RPCMemoryTransportOptions, } from "./rpcMemoryTransport.core.js";
6
6
  export { createRPCMemoryTransport } from "./rpcMemoryTransport.core.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -3,4 +3,3 @@
3
3
  * same process, serializing frames across the boundary by default.
4
4
  */
5
5
  export { createRPCMemoryTransport } from "./rpcMemoryTransport.core.js";
6
- //# sourceMappingURL=index.js.map
@@ -39,4 +39,3 @@ export interface RPCMemoryTransportOptions {
39
39
  * with `RPCUnavailableError`.
40
40
  */
41
41
  export declare function createRPCMemoryTransport(server: RPCFrameHandler, options?: RPCMemoryTransportOptions): RPCTransport;
42
- //# sourceMappingURL=rpcMemoryTransport.core.d.ts.map
@@ -70,4 +70,3 @@ function copyResponse(serializer, response) {
70
70
  });
71
71
  }
72
72
  }
73
- //# sourceMappingURL=rpcMemoryTransport.core.js.map
@@ -22,4 +22,3 @@ export interface RPCTransport {
22
22
  send(request: RPCRequest, options?: RPCTransportRequestOptions): Promise<RPCResponse>;
23
23
  close?(): Promise<void>;
24
24
  }
25
- //# sourceMappingURL=rpcTransport.type.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=rpcTransport.type.js.map
@@ -10,4 +10,3 @@ export type { RPCRequest, RPCRequestOptions } from "./rpcRequest.type.js";
10
10
  export { createRPCRequest } from "./rpcRequest.type.js";
11
11
  export type { RPCErrorPayload, RPCResponse } from "./rpcResponse.type.js";
12
12
  export { createRPCErrorPayload, createRPCResponse, createRPCErrorResponse, } from "./rpcResponse.type.js";
13
- //# sourceMappingURL=index.d.ts.map
@@ -6,4 +6,3 @@
6
6
  export { createRPCMetadata } from "./rpcMetadata.type.js";
7
7
  export { createRPCRequest } from "./rpcRequest.type.js";
8
8
  export { createRPCErrorPayload, createRPCResponse, createRPCErrorResponse, } from "./rpcResponse.type.js";
9
- //# sourceMappingURL=index.js.map
@@ -28,4 +28,3 @@ export interface RPCMetadataOptions {
28
28
  * Creates RPC metadata from options.
29
29
  */
30
30
  export declare function createRPCMetadata(options?: RPCMetadataOptions): RPCMetadata;
31
- //# sourceMappingURL=rpcMetadata.type.d.ts.map
@@ -4,4 +4,3 @@
4
4
  export function createRPCMetadata(options = {}) {
5
5
  return Object.freeze({ ...options });
6
6
  }
7
- //# sourceMappingURL=rpcMetadata.type.js.map
@@ -9,4 +9,3 @@
9
9
  * Must be dot-separated lowercase identifiers, e.g. "users.getUser".
10
10
  */
11
11
  export type RPCProcedureName = string;
12
- //# sourceMappingURL=rpcProcedureName.type.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * Core types for the Zudojs RPC package.
5
5
  */
6
6
  export {};
7
- //# sourceMappingURL=rpcProcedureName.type.js.map
@@ -24,4 +24,3 @@ export interface RPCRequestOptions<TPayload = unknown> {
24
24
  * Creates an RPC request.
25
25
  */
26
26
  export declare function createRPCRequest<TPayload = unknown>(options: RPCRequestOptions<TPayload>): RPCRequest<TPayload>;
27
- //# sourceMappingURL=rpcRequest.type.d.ts.map
@@ -8,4 +8,3 @@ export function createRPCRequest(options) {
8
8
  timestamp: options.timestamp ?? Date.now(),
9
9
  });
10
10
  }
11
- //# sourceMappingURL=rpcRequest.type.js.map
@@ -29,4 +29,3 @@ export declare function createRPCResponse<TResult = unknown>(id: string, result:
29
29
  * Creates a failed RPC response.
30
30
  */
31
31
  export declare function createRPCErrorResponse(id: string, error: RPCErrorPayload, metadata?: RPCMetadata): RPCResponse<never>;
32
- //# sourceMappingURL=rpcResponse.type.d.ts.map
@@ -30,4 +30,3 @@ export function createRPCErrorResponse(id, error, metadata) {
30
30
  ...(metadata !== undefined ? { metadata } : {}),
31
31
  });
32
32
  }
33
- //# sourceMappingURL=rpcResponse.type.js.map
@@ -1,3 +1,2 @@
1
1
  export type { RPCRequestLimits, RPCSchema } from "./rpcValidation.core.js";
2
2
  export { assertValidProcedureName, assertValidRequest, measurePayloadBytes, toValidationIssues, parseInput, parseOutput, } from "./rpcValidation.core.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export { assertValidProcedureName, assertValidRequest, measurePayloadBytes, toValidationIssues, parseInput, parseOutput, } from "./rpcValidation.core.js";
2
- //# sourceMappingURL=index.js.map
@@ -106,4 +106,3 @@ export declare function parseInput<T>(schema: RPCSchema<T>, value: unknown, proc
106
106
  * @throws {RPCInternalError}
107
107
  */
108
108
  export declare function parseOutput<T>(schema: RPCSchema<T>, value: unknown, procedureName: string): T;
109
- //# sourceMappingURL=rpcValidation.core.d.ts.map
@@ -152,4 +152,3 @@ export function parseOutput(schema, value, procedureName) {
152
152
  .join(", ");
153
153
  throw new RPCInternalError(`Procedure "${procedureName}" produced a response that does not match its output schema at ${where}.`, procedureName);
154
154
  }
155
- //# sourceMappingURL=rpcValidation.core.js.map
@@ -8,4 +8,3 @@ export { createRPCRequest } from "../rpc/types/rpcRequest.type.js";
8
8
  export { createRPCProcedure } from "../rpc/procedure/rpcProcedure.type.js";
9
9
  export { RPCServer } from "../rpc/server/rpcServer.core.js";
10
10
  export { RPCClient } from "../rpc/client/rpcClient.core.js";
11
- //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,3 @@ export { createRPCRequest } from "../rpc/types/rpcRequest.type.js";
7
7
  export { createRPCProcedure } from "../rpc/procedure/rpcProcedure.type.js";
8
8
  export { RPCServer } from "../rpc/server/rpcServer.core.js";
9
9
  export { RPCClient } from "../rpc/client/rpcClient.core.js";
10
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/rpc",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Remote procedure call infrastructure for Zudojs applications.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -27,12 +27,12 @@
27
27
  "node": ">=24.0.0"
28
28
  },
29
29
  "dependencies": {
30
- "@zudojs/constants": "1.1.3",
31
- "@zudojs/errors": "1.3.1",
32
- "@zudojs/schema": "1.2.2",
33
- "@zudojs/security": "1.3.2",
34
- "@zudojs/serialization": "1.2.2",
35
- "@zudojs/types": "1.2.0"
30
+ "@zudojs/constants": "1.2.0",
31
+ "@zudojs/errors": "1.4.0",
32
+ "@zudojs/schema": "1.3.0",
33
+ "@zudojs/security": "1.3.4",
34
+ "@zudojs/serialization": "1.3.0",
35
+ "@zudojs/types": "1.3.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "typescript": "7.0.2",
@@ -1,18 +0,0 @@
1
- /**
2
- * Detection of prototype-polluting keys in decoded, untrusted data.
3
- */
4
- /**
5
- * Returns the first `__proto__`, `constructor` or `prototype` key found
6
- * anywhere in `value`, or `undefined` when there is none.
7
- *
8
- * `JSON.parse` keeps such a key as an ordinary own property, so it reaches
9
- * handlers intact; the moment one is copied with `Object.assign`, a
10
- * `for…in` merge or a bracket assignment, it replaces the target's
11
- * prototype. Transports refuse a frame that carries one rather than
12
- * silently dropping it.
13
- *
14
- * Walks plain objects and arrays only, iteratively (no recursion limit)
15
- * and cycle-safe, so it is safe on any decoded or in-process value.
16
- */
17
- export declare function findUnsafeKey(value: unknown): string | undefined;
18
- //# sourceMappingURL=rpcUnsafeKey.helper.d.ts.map
@@ -1,60 +0,0 @@
1
- /**
2
- * Detection of prototype-polluting keys in decoded, untrusted data.
3
- */
4
- import { SCHEMA_FORBIDDEN_KEYS } from "@zudojs/constants";
5
- function isTraversable(value) {
6
- if (typeof value !== "object" || value === null) {
7
- return false;
8
- }
9
- if (Array.isArray(value)) {
10
- return true;
11
- }
12
- const prototype = Object.getPrototypeOf(value);
13
- return prototype === Object.prototype || prototype === null;
14
- }
15
- /**
16
- * Returns the first `__proto__`, `constructor` or `prototype` key found
17
- * anywhere in `value`, or `undefined` when there is none.
18
- *
19
- * `JSON.parse` keeps such a key as an ordinary own property, so it reaches
20
- * handlers intact; the moment one is copied with `Object.assign`, a
21
- * `for…in` merge or a bracket assignment, it replaces the target's
22
- * prototype. Transports refuse a frame that carries one rather than
23
- * silently dropping it.
24
- *
25
- * Walks plain objects and arrays only, iteratively (no recursion limit)
26
- * and cycle-safe, so it is safe on any decoded or in-process value.
27
- */
28
- export function findUnsafeKey(value) {
29
- if (!isTraversable(value)) {
30
- return undefined;
31
- }
32
- const seen = new WeakSet();
33
- const pending = [value];
34
- while (pending.length > 0) {
35
- const node = pending.pop();
36
- if (seen.has(node)) {
37
- continue;
38
- }
39
- seen.add(node);
40
- if (Array.isArray(node)) {
41
- for (const child of node) {
42
- if (isTraversable(child)) {
43
- pending.push(child);
44
- }
45
- }
46
- continue;
47
- }
48
- for (const key of Object.keys(node)) {
49
- if (SCHEMA_FORBIDDEN_KEYS.has(key)) {
50
- return key;
51
- }
52
- const child = node[key];
53
- if (isTraversable(child)) {
54
- pending.push(child);
55
- }
56
- }
57
- }
58
- return undefined;
59
- }
60
- //# sourceMappingURL=rpcUnsafeKey.helper.js.map