@t-0/provider-sdk 1.1.38 → 1.1.40
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 +1 -1
- package/lib/cjs/common/service.d.ts +7 -0
- package/lib/cjs/common/service.js +3 -1
- package/lib/cjs/crypto/index.d.ts +1 -0
- package/lib/cjs/crypto/index.js +6 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/service.d.ts +7 -0
- package/lib/esm/common/service.js +2 -0
- package/lib/esm/crypto/index.d.ts +1 -0
- package/lib/esm/crypto/index.js +1 -0
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -148,7 +148,7 @@ For custom proto registries (e.g. non-network schemas with custom predefined rul
|
|
|
148
148
|
<details>
|
|
149
149
|
<summary>Lower-level primitives</summary>
|
|
150
150
|
|
|
151
|
-
The individual building blocks are also exported: `createRequestVerifier`, `rejectRequest`, `verifySignature`, `computeDigest`, `keccak256`, `parsePublicKey`, `publicKeysEqual
|
|
151
|
+
The individual building blocks are also exported: `createRequestVerifier`, `rejectRequest`, `verifySignature`, `computeDigest`, `keccak256`, `parsePublicKey`, `publicKeysEqual`, and the `NetworkHeaders` header-name enum. You can import just the crypto module via the `./crypto` subpath: `import { createRequestVerifier } from "@t-0/provider-sdk/crypto"`.
|
|
152
152
|
</details>
|
|
153
153
|
|
|
154
154
|
### Network Client
|
|
@@ -23,14 +23,21 @@ export interface CreateServiceOptions {
|
|
|
23
23
|
* header. Omit to suppress the header.
|
|
24
24
|
*/
|
|
25
25
|
version?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum request body size in bytes. Default: 10 MiB.
|
|
28
|
+
* Requests exceeding this limit are rejected before signature verification.
|
|
29
|
+
*/
|
|
30
|
+
maxBodySize?: number;
|
|
26
31
|
}
|
|
27
32
|
export declare const REQUEST_VALIDITY_MILLIS = 60000;
|
|
33
|
+
export declare const DEFAULT_MAX_BODY_SIZE: number;
|
|
28
34
|
export interface Router {
|
|
29
35
|
service: <T extends DescService, I extends ServiceImpl<T>>(service: T, implementation: I) => void;
|
|
30
36
|
}
|
|
31
37
|
export declare const createService: (networkPublicKey: string | Buffer, registerRoutes: (router: Router) => void, options?: CreateServiceOptions) => {
|
|
32
38
|
routes: (router: ConnectRouter) => void;
|
|
33
39
|
interceptors: Interceptor[];
|
|
40
|
+
readMaxBytes: number;
|
|
34
41
|
grpcWeb: boolean;
|
|
35
42
|
contextValues: (req: any) => import("@connectrpc/connect").ContextValues;
|
|
36
43
|
};
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createService = exports.REQUEST_VALIDITY_MILLIS = void 0;
|
|
6
|
+
exports.createService = exports.DEFAULT_MAX_BODY_SIZE = exports.REQUEST_VALIDITY_MILLIS = void 0;
|
|
7
7
|
const connect_1 = require("@connectrpc/connect");
|
|
8
8
|
const headers_js_1 = __importDefault(require("./headers.js"));
|
|
9
9
|
const verify_js_1 = require("./crypto/verify.js");
|
|
@@ -11,6 +11,7 @@ const validation_js_1 = require("./validation.js");
|
|
|
11
11
|
const health_pb_js_1 = require("./health_pb.js");
|
|
12
12
|
const health_js_1 = require("./health.js");
|
|
13
13
|
exports.REQUEST_VALIDITY_MILLIS = 60000;
|
|
14
|
+
exports.DEFAULT_MAX_BODY_SIZE = 10 * 1024 * 1024; // 10 MiB
|
|
14
15
|
const createSignatureVerification = (networkPublicKey) => (next) => async (req) => {
|
|
15
16
|
const ts = decodeNum(getHeader(req, headers_js_1.default.SignatureTimestamp));
|
|
16
17
|
if (!Number.isFinite(ts) || Math.abs(Date.now() - ts) > exports.REQUEST_VALIDITY_MILLIS) {
|
|
@@ -51,6 +52,7 @@ const createService = (networkPublicKey, registerRoutes, options) => {
|
|
|
51
52
|
origService(health_pb_js_1.Health, (0, health_js_1.createHealthServiceImpl)(collected, options?.version));
|
|
52
53
|
},
|
|
53
54
|
interceptors: [createSignatureVerification(networkPublicKey), (0, validation_js_1.createValidationInterceptor)({ logger: options?.logger, registry: options?.registry })],
|
|
55
|
+
readMaxBytes: options?.maxBodySize ?? exports.DEFAULT_MAX_BODY_SIZE,
|
|
54
56
|
grpcWeb: false,
|
|
55
57
|
contextValues: (req) => {
|
|
56
58
|
return (0, connect_1.createContextValues)().set(kHash, req.hasher);
|
package/lib/cjs/crypto/index.js
CHANGED
|
@@ -13,8 +13,13 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createRequestDecoder = void 0;
|
|
20
|
+
exports.NetworkHeaders = exports.createRequestDecoder = void 0;
|
|
18
21
|
__exportStar(require("../common/crypto/index.js"), exports);
|
|
19
22
|
var decode_js_1 = require("../common/crypto/decode.js");
|
|
20
23
|
Object.defineProperty(exports, "createRequestDecoder", { enumerable: true, get: function () { return decode_js_1.createRequestDecoder; } });
|
|
24
|
+
var headers_js_1 = require("../common/headers.js");
|
|
25
|
+
Object.defineProperty(exports, "NetworkHeaders", { enumerable: true, get: function () { return __importDefault(headers_js_1).default; } });
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.1.
|
|
1
|
+
export declare const SDK_VERSION = "1.1.40";
|
package/lib/cjs/version.js
CHANGED
|
@@ -23,14 +23,21 @@ export interface CreateServiceOptions {
|
|
|
23
23
|
* header. Omit to suppress the header.
|
|
24
24
|
*/
|
|
25
25
|
version?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum request body size in bytes. Default: 10 MiB.
|
|
28
|
+
* Requests exceeding this limit are rejected before signature verification.
|
|
29
|
+
*/
|
|
30
|
+
maxBodySize?: number;
|
|
26
31
|
}
|
|
27
32
|
export declare const REQUEST_VALIDITY_MILLIS = 60000;
|
|
33
|
+
export declare const DEFAULT_MAX_BODY_SIZE: number;
|
|
28
34
|
export interface Router {
|
|
29
35
|
service: <T extends DescService, I extends ServiceImpl<T>>(service: T, implementation: I) => void;
|
|
30
36
|
}
|
|
31
37
|
export declare const createService: (networkPublicKey: string | Buffer, registerRoutes: (router: Router) => void, options?: CreateServiceOptions) => {
|
|
32
38
|
routes: (router: ConnectRouter) => void;
|
|
33
39
|
interceptors: Interceptor[];
|
|
40
|
+
readMaxBytes: number;
|
|
34
41
|
grpcWeb: boolean;
|
|
35
42
|
contextValues: (req: any) => import("@connectrpc/connect").ContextValues;
|
|
36
43
|
};
|
|
@@ -5,6 +5,7 @@ import { createValidationInterceptor } from "./validation.js";
|
|
|
5
5
|
import { Health } from "./health_pb.js";
|
|
6
6
|
import { createHealthServiceImpl } from "./health.js";
|
|
7
7
|
export const REQUEST_VALIDITY_MILLIS = 60000;
|
|
8
|
+
export const DEFAULT_MAX_BODY_SIZE = 10 * 1024 * 1024; // 10 MiB
|
|
8
9
|
const createSignatureVerification = (networkPublicKey) => (next) => async (req) => {
|
|
9
10
|
const ts = decodeNum(getHeader(req, NetworkHeaders.SignatureTimestamp));
|
|
10
11
|
if (!Number.isFinite(ts) || Math.abs(Date.now() - ts) > REQUEST_VALIDITY_MILLIS) {
|
|
@@ -45,6 +46,7 @@ export const createService = (networkPublicKey, registerRoutes, options) => {
|
|
|
45
46
|
origService(Health, createHealthServiceImpl(collected, options?.version));
|
|
46
47
|
},
|
|
47
48
|
interceptors: [createSignatureVerification(networkPublicKey), createValidationInterceptor({ logger: options?.logger, registry: options?.registry })],
|
|
49
|
+
readMaxBytes: options?.maxBodySize ?? DEFAULT_MAX_BODY_SIZE,
|
|
48
50
|
grpcWeb: false,
|
|
49
51
|
contextValues: (req) => {
|
|
50
52
|
return createContextValues().set(kHash, req.hasher);
|
package/lib/esm/crypto/index.js
CHANGED
package/lib/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.1.
|
|
1
|
+
export declare const SDK_VERSION = "1.1.40";
|
package/lib/esm/version.js
CHANGED