@t-0/provider-sdk 1.1.28 → 1.1.30
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 +52 -2
- package/lib/cjs/client/client.d.ts +4 -14
- package/lib/cjs/client/client.js +2 -38
- package/lib/cjs/client/signer.d.ts +1 -3
- package/lib/cjs/client/signer.js +7 -34
- package/lib/cjs/common/client/client.d.ts +14 -0
- package/lib/cjs/common/client/client.js +42 -0
- package/lib/cjs/common/client/signer.d.ts +3 -0
- package/lib/cjs/common/client/signer.js +36 -0
- package/lib/cjs/common/crypto/hash.d.ts +2 -0
- package/lib/cjs/common/crypto/hash.js +17 -0
- package/lib/cjs/common/crypto/index.d.ts +5 -0
- package/lib/cjs/common/crypto/index.js +14 -0
- package/lib/cjs/common/crypto/keys.d.ts +2 -0
- package/lib/cjs/common/crypto/keys.js +23 -0
- package/lib/cjs/common/crypto/request.d.ts +20 -0
- package/lib/cjs/common/crypto/request.js +51 -0
- package/lib/cjs/common/crypto/verify.d.ts +1 -0
- package/lib/cjs/common/crypto/verify.js +19 -0
- package/lib/cjs/common/health.d.ts +21 -0
- package/lib/cjs/common/health.js +45 -0
- package/lib/cjs/common/health_pb.d.ts +157 -0
- package/lib/cjs/common/health_pb.js +90 -0
- package/lib/cjs/common/node.d.ts +3 -0
- package/lib/cjs/common/node.js +15 -0
- package/lib/cjs/common/service.d.ts +37 -0
- package/lib/cjs/common/service.js +85 -0
- package/lib/cjs/common/validate.d.ts +25 -0
- package/lib/cjs/common/validate.js +42 -0
- package/lib/cjs/common/validation.d.ts +26 -0
- package/lib/cjs/common/validation.js +57 -0
- package/lib/cjs/crypto/hash.d.ts +1 -0
- package/lib/cjs/crypto/hash.js +17 -0
- package/lib/cjs/crypto/index.d.ts +1 -0
- package/lib/cjs/crypto/index.js +17 -0
- package/lib/cjs/crypto/keys.d.ts +1 -0
- package/lib/cjs/crypto/keys.js +17 -0
- package/lib/cjs/crypto/request.d.ts +1 -0
- package/lib/cjs/crypto/request.js +17 -0
- package/lib/cjs/crypto/verify.d.ts +1 -0
- package/lib/cjs/crypto/verify.js +17 -0
- package/lib/cjs/index.d.ts +4 -0
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/service/health.d.ts +4 -21
- package/lib/cjs/service/health.js +5 -41
- package/lib/cjs/service/health_pb.d.ts +1 -157
- package/lib/cjs/service/health_pb.js +15 -85
- package/lib/cjs/service/node.d.ts +1 -3
- package/lib/cjs/service/node.js +15 -13
- package/lib/cjs/service/service.d.ts +7 -10
- package/lib/cjs/service/service.js +5 -94
- package/lib/cjs/service/validate.d.ts +1 -0
- package/lib/cjs/service/validate.js +17 -0
- package/lib/cjs/service/validate_response.d.ts +11 -6
- package/lib/cjs/service/validate_response.js +19 -30
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/client/client.d.ts +3 -13
- package/lib/esm/client/client.js +2 -35
- package/lib/esm/client/signer.d.ts +1 -3
- package/lib/esm/client/signer.js +1 -32
- package/lib/esm/common/client/client.d.ts +14 -0
- package/lib/esm/common/client/client.js +36 -0
- package/lib/esm/common/client/signer.d.ts +3 -0
- package/lib/esm/common/client/signer.js +32 -0
- package/lib/esm/common/crypto/hash.d.ts +2 -0
- package/lib/esm/common/crypto/hash.js +13 -0
- package/lib/esm/common/crypto/index.d.ts +5 -0
- package/lib/esm/common/crypto/index.js +4 -0
- package/lib/esm/common/crypto/keys.d.ts +2 -0
- package/lib/esm/common/crypto/keys.js +19 -0
- package/lib/esm/common/crypto/request.d.ts +20 -0
- package/lib/esm/common/crypto/request.js +47 -0
- package/lib/esm/common/crypto/verify.d.ts +1 -0
- package/lib/esm/common/crypto/verify.js +16 -0
- package/lib/esm/common/health.d.ts +21 -0
- package/lib/esm/common/health.js +41 -0
- package/lib/esm/common/health_pb.d.ts +157 -0
- package/lib/esm/common/health_pb.js +87 -0
- package/lib/esm/common/node.d.ts +3 -0
- package/lib/esm/common/node.js +11 -0
- package/lib/esm/common/service.d.ts +37 -0
- package/lib/esm/common/service.js +78 -0
- package/lib/esm/common/validate.d.ts +25 -0
- package/lib/esm/common/validate.js +38 -0
- package/lib/esm/common/validation.d.ts +26 -0
- package/lib/esm/common/validation.js +54 -0
- package/lib/esm/crypto/hash.d.ts +1 -0
- package/lib/esm/crypto/hash.js +1 -0
- package/lib/esm/crypto/index.d.ts +1 -0
- package/lib/esm/crypto/index.js +1 -0
- package/lib/esm/crypto/keys.d.ts +1 -0
- package/lib/esm/crypto/keys.js +1 -0
- package/lib/esm/crypto/request.d.ts +1 -0
- package/lib/esm/crypto/request.js +1 -0
- package/lib/esm/crypto/verify.d.ts +1 -0
- package/lib/esm/crypto/verify.js +1 -0
- package/lib/esm/index.d.ts +4 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/service/health.d.ts +4 -21
- package/lib/esm/service/health.js +3 -41
- package/lib/esm/service/health_pb.d.ts +1 -157
- package/lib/esm/service/health_pb.js +1 -84
- package/lib/esm/service/node.d.ts +1 -3
- package/lib/esm/service/node.js +1 -11
- package/lib/esm/service/service.d.ts +7 -10
- package/lib/esm/service/service.js +4 -91
- package/lib/esm/service/validate.d.ts +1 -0
- package/lib/esm/service/validate.js +1 -0
- package/lib/esm/service/validate_response.d.ts +11 -6
- package/lib/esm/service/validate_response.js +15 -27
- 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 +15 -5
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// Source: buf.build/grpc/grpc, grpc/health/v1/health.proto
|
|
4
|
-
// Plugin: buf.build/bufbuild/es:v2.12.0 (kept in step with the root
|
|
5
|
-
// buf.gen.yaml pin -- plugin and @bufbuild/protobuf runtime must
|
|
6
|
-
// agree on major).
|
|
7
|
-
//
|
|
8
|
-
// Regenerate by overwriting this file:
|
|
9
|
-
//
|
|
10
|
-
// cd node/sdk
|
|
11
|
-
// buf generate buf.build/grpc/grpc --path grpc/health/v1/health.proto \
|
|
12
|
-
// --template '{"version":"v2","plugins":[{"remote":"buf.build/bufbuild/es:v2.12.0","out":"gen-health","opt":["target=ts","import_extension=js"]}]}'
|
|
13
|
-
// mv gen-health/grpc/health/v1/health_pb.ts src/service/health_pb.ts
|
|
14
|
-
// rm -rf gen-health
|
|
15
|
-
//
|
|
16
|
-
// Vendored rather than depended on: the equivalent package
|
|
17
|
-
// `@buf/grpc_grpc.bufbuild_es` is published only on the Buf Schema Registry, and
|
|
18
|
-
// reaching it needs registry config that a published npm package cannot hand its
|
|
19
|
-
// consumers -- so depending on it 404'd every downstream install. Rationale in
|
|
20
|
-
// docs/HEALTH_SERVICE.md.
|
|
21
|
-
//
|
|
22
|
-
// Lives under src/service/ rather than src/common/gen/ so the transport keeps
|
|
23
|
-
// importing nothing from common/gen.
|
|
24
|
-
import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
|
|
25
|
-
/**
|
|
26
|
-
* Describes the file grpc/health/v1/health.proto.
|
|
27
|
-
*/
|
|
28
|
-
export const file_grpc_health_v1_health = /*@__PURE__*/ fileDesc("ChtncnBjL2hlYWx0aC92MS9oZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYxIiUKEkhlYWx0aENoZWNrUmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIqkBChNIZWFsdGhDaGVja1Jlc3BvbnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVhbHRoLnYxLkhlYWx0aENoZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyJPCg1TZXJ2aW5nU3RhdHVzEgsKB1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9UX1NFUlZJTkcQAhITCg9TRVJWSUNFX1VOS05PV04QAyITChFIZWFsdGhMaXN0UmVxdWVzdCKuAQoSSGVhbHRoTGlzdFJlc3BvbnNlEkIKCHN0YXR1c2VzGAEgAygLMjAuZ3JwYy5oZWFsdGgudjEuSGVhbHRoTGlzdFJlc3BvbnNlLlN0YXR1c2VzRW50cnkaVAoNU3RhdHVzZXNFbnRyeRILCgNrZXkYASABKAkSMgoFdmFsdWUYAiABKAsyIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlOgI4ATL9AQoGSGVhbHRoElAKBUNoZWNrEiIuZ3JwYy5oZWFsdGgudjEuSGVhbHRoQ2hlY2tSZXF1ZXN0GiMuZ3JwYy5oZWFsdGgudjEuSGVhbHRoQ2hlY2tSZXNwb25zZRJNCgRMaXN0EiEuZ3JwYy5oZWFsdGgudjEuSGVhbHRoTGlzdFJlcXVlc3QaIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhMaXN0UmVzcG9uc2USUgoFV2F0Y2gSIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1JlcXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlMAFCcAoRaW8uZ3JwYy5oZWFsdGgudjFCC0hlYWx0aFByb3RvUAFaLGdvb2dsZS5nb2xhbmcub3JnL2dycGMvaGVhbHRoL2dycGNfaGVhbHRoX3YxogIMR3JwY0hlYWx0aFYxqgIOR3JwYy5IZWFsdGguVjFiBnByb3RvMw");
|
|
29
|
-
/**
|
|
30
|
-
* Describes the message grpc.health.v1.HealthCheckRequest.
|
|
31
|
-
* Use `create(HealthCheckRequestSchema)` to create a new message.
|
|
32
|
-
*/
|
|
33
|
-
export const HealthCheckRequestSchema = /*@__PURE__*/ messageDesc(file_grpc_health_v1_health, 0);
|
|
34
|
-
/**
|
|
35
|
-
* Describes the message grpc.health.v1.HealthCheckResponse.
|
|
36
|
-
* Use `create(HealthCheckResponseSchema)` to create a new message.
|
|
37
|
-
*/
|
|
38
|
-
export const HealthCheckResponseSchema = /*@__PURE__*/ messageDesc(file_grpc_health_v1_health, 1);
|
|
39
|
-
/**
|
|
40
|
-
* @generated from enum grpc.health.v1.HealthCheckResponse.ServingStatus
|
|
41
|
-
*/
|
|
42
|
-
export var HealthCheckResponse_ServingStatus;
|
|
43
|
-
(function (HealthCheckResponse_ServingStatus) {
|
|
44
|
-
/**
|
|
45
|
-
* @generated from enum value: UNKNOWN = 0;
|
|
46
|
-
*/
|
|
47
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["UNKNOWN"] = 0] = "UNKNOWN";
|
|
48
|
-
/**
|
|
49
|
-
* @generated from enum value: SERVING = 1;
|
|
50
|
-
*/
|
|
51
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["SERVING"] = 1] = "SERVING";
|
|
52
|
-
/**
|
|
53
|
-
* @generated from enum value: NOT_SERVING = 2;
|
|
54
|
-
*/
|
|
55
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["NOT_SERVING"] = 2] = "NOT_SERVING";
|
|
56
|
-
/**
|
|
57
|
-
* Used only by the Watch method.
|
|
58
|
-
*
|
|
59
|
-
* @generated from enum value: SERVICE_UNKNOWN = 3;
|
|
60
|
-
*/
|
|
61
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["SERVICE_UNKNOWN"] = 3] = "SERVICE_UNKNOWN";
|
|
62
|
-
})(HealthCheckResponse_ServingStatus || (HealthCheckResponse_ServingStatus = {}));
|
|
63
|
-
/**
|
|
64
|
-
* Describes the enum grpc.health.v1.HealthCheckResponse.ServingStatus.
|
|
65
|
-
*/
|
|
66
|
-
export const HealthCheckResponse_ServingStatusSchema = /*@__PURE__*/ enumDesc(file_grpc_health_v1_health, 1, 0);
|
|
67
|
-
/**
|
|
68
|
-
* Describes the message grpc.health.v1.HealthListRequest.
|
|
69
|
-
* Use `create(HealthListRequestSchema)` to create a new message.
|
|
70
|
-
*/
|
|
71
|
-
export const HealthListRequestSchema = /*@__PURE__*/ messageDesc(file_grpc_health_v1_health, 2);
|
|
72
|
-
/**
|
|
73
|
-
* Describes the message grpc.health.v1.HealthListResponse.
|
|
74
|
-
* Use `create(HealthListResponseSchema)` to create a new message.
|
|
75
|
-
*/
|
|
76
|
-
export const HealthListResponseSchema = /*@__PURE__*/ messageDesc(file_grpc_health_v1_health, 3);
|
|
77
|
-
/**
|
|
78
|
-
* Health is gRPC's mechanism for checking whether a server is able to handle
|
|
79
|
-
* RPCs. Its semantics are documented in
|
|
80
|
-
* https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
|
|
81
|
-
*
|
|
82
|
-
* @generated from service grpc.health.v1.Health
|
|
83
|
-
*/
|
|
84
|
-
export const Health = /*@__PURE__*/ serviceDesc(file_grpc_health_v1_health, 0);
|
|
1
|
+
export * from "../common/health_pb.js";
|
package/lib/esm/service/node.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const signatureValidation = (next) => (req, resp) => {
|
|
3
|
-
const hasher = keccak_256.create();
|
|
4
|
-
req.hasher = hasher;
|
|
5
|
-
req.on("data", (chunk) => {
|
|
6
|
-
if (chunk instanceof Buffer) {
|
|
7
|
-
hasher.update(chunk);
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
next(req, resp);
|
|
11
|
-
};
|
|
1
|
+
export * from "../common/node.js";
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { ServiceImpl } from "@connectrpc/connect";
|
|
5
|
-
export declare const REQUEST_VALIDITY_MILLIS = 60000;
|
|
1
|
+
import { type CreateServiceOptions } from "../common/service.js";
|
|
2
|
+
export type { CreateServiceOptions } from "../common/service.js";
|
|
3
|
+
export { REQUEST_VALIDITY_MILLIS } from "../common/service.js";
|
|
6
4
|
interface Router {
|
|
7
|
-
service: <T extends DescService, I extends ServiceImpl<T>>(service: T, implementation: I) => void;
|
|
5
|
+
service: <T extends import("@bufbuild/protobuf").DescService, I extends import("@connectrpc/connect").ServiceImpl<T>>(service: T, implementation: I) => void;
|
|
8
6
|
}
|
|
9
|
-
export declare const createService: (networkPublicKey: string | Buffer, registerRoutes: (router: Router) => void) => {
|
|
10
|
-
routes: (router: ConnectRouter) => void;
|
|
11
|
-
interceptors: Interceptor[];
|
|
7
|
+
export declare const createService: (networkPublicKey: string | Buffer, registerRoutes: (router: Router) => void, options?: CreateServiceOptions) => {
|
|
8
|
+
routes: (router: import("@connectrpc/connect").ConnectRouter) => void;
|
|
9
|
+
interceptors: import("@connectrpc/connect").Interceptor[];
|
|
12
10
|
grpcWeb: boolean;
|
|
13
11
|
contextValues: (req: any) => import("@connectrpc/connect").ContextValues;
|
|
14
12
|
};
|
|
15
|
-
export {};
|
|
@@ -1,91 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Health } from "./health_pb.js";
|
|
6
|
-
import { createHealthServiceImpl } from "./health.js";
|
|
7
|
-
export const REQUEST_VALIDITY_MILLIS = 60000;
|
|
8
|
-
const createSignatureVerification = (networkPublicKey) => (next) => async (req) => {
|
|
9
|
-
const ts = decodeNum(getHeader(req, NetworkHeaders.SignatureTimestamp));
|
|
10
|
-
if (Date.now() - ts > 60000) {
|
|
11
|
-
throw new ConnectError(`${NetworkHeaders.SignatureTimestamp} must be within ${REQUEST_VALIDITY_MILLIS} milliseconds from now`, Code.InvalidArgument);
|
|
12
|
-
}
|
|
13
|
-
const publicKey = decodeHex(getHeader(req, NetworkHeaders.PublicKey));
|
|
14
|
-
if (networkPublicKey.compare(publicKey) !== 0) {
|
|
15
|
-
throw new ConnectError(`${NetworkHeaders.PublicKey} value is not network public key`, Code.Unauthenticated);
|
|
16
|
-
}
|
|
17
|
-
let signature = decodeHex(getHeader(req, NetworkHeaders.Signature));
|
|
18
|
-
if (signature.length === 65) {
|
|
19
|
-
signature = signature.subarray(0, 64);
|
|
20
|
-
}
|
|
21
|
-
const hasher = req.contextValues.get(kHash);
|
|
22
|
-
const tsBuf = Buffer.alloc(8);
|
|
23
|
-
tsBuf.writeBigUInt64LE(BigInt(ts)); // 64‑bit little‑endian timestamp
|
|
24
|
-
const hash = hasher
|
|
25
|
-
.update(tsBuf)
|
|
26
|
-
.digest();
|
|
27
|
-
let signatureValid = false;
|
|
28
|
-
try {
|
|
29
|
-
signatureValid = secp256k1.verify(signature, hash, publicKey, { prehash: false });
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
throw new ConnectError(`${NetworkHeaders.Signature} has invalid signature or public key format: ${e}`, Code.Unauthenticated);
|
|
33
|
-
}
|
|
34
|
-
if (!signatureValid) {
|
|
35
|
-
throw new ConnectError(`${NetworkHeaders.Signature} has invalid signature`, Code.Unauthenticated);
|
|
36
|
-
}
|
|
37
|
-
return await next(req);
|
|
38
|
-
};
|
|
39
|
-
export const createService = (networkPublicKey, registerRoutes) => {
|
|
40
|
-
if (typeof networkPublicKey == "string") {
|
|
41
|
-
networkPublicKey = decodeHex(networkPublicKey);
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
routes: (router) => {
|
|
45
|
-
const collected = [];
|
|
46
|
-
const origService = router.service.bind(router);
|
|
47
|
-
const wrappedRouter = {
|
|
48
|
-
service: (desc, impl) => {
|
|
49
|
-
collected.push(desc.typeName);
|
|
50
|
-
origService(desc, impl);
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
registerRoutes(wrappedRouter);
|
|
54
|
-
// Health is the only service this transport mounts on its own — see
|
|
55
|
-
// docs/HEALTH_SERVICE.md. Same interceptors as everything else, so the
|
|
56
|
-
// probe is signed like any other call.
|
|
57
|
-
collected.push(Health.typeName);
|
|
58
|
-
origService(Health, createHealthServiceImpl(collected));
|
|
59
|
-
},
|
|
60
|
-
interceptors: [createSignatureVerification(networkPublicKey), createValidationInterceptor()],
|
|
61
|
-
grpcWeb: false,
|
|
62
|
-
contextValues: (req) => {
|
|
63
|
-
return createContextValues().set(kHash, req.hasher);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const kHash = createContextKey(undefined);
|
|
68
|
-
function getHeader(req, header) {
|
|
69
|
-
const raw = req.header.get(header);
|
|
70
|
-
if (!raw) {
|
|
71
|
-
throw new ConnectError(`missing required header '${header}'`, Code.InvalidArgument);
|
|
72
|
-
}
|
|
73
|
-
return raw;
|
|
74
|
-
}
|
|
75
|
-
function decodeHex(value) {
|
|
76
|
-
value = value.startsWith('0x') ? value.slice(2) : value;
|
|
77
|
-
try {
|
|
78
|
-
return Buffer.from(value, "hex");
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
throw new ConnectError(`invalid header format. '${value}' must be hex encoded`, Code.InvalidArgument);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function decodeNum(value) {
|
|
85
|
-
try {
|
|
86
|
-
return parseInt(value);
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
throw new ConnectError(`invalid header format. '${value}' must be a number`, Code.InvalidArgument);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
1
|
+
import { createService as createServiceCommon } from "../common/service.js";
|
|
2
|
+
import { SDK_VERSION } from "../version.js";
|
|
3
|
+
export { REQUEST_VALIDITY_MILLIS } from "../common/service.js";
|
|
4
|
+
export const createService = (networkPublicKey, registerRoutes, options) => createServiceCommon(networkPublicKey, registerRoutes, { ...options, version: options?.version ?? SDK_VERSION });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../common/validate.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../common/validate.js";
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { Interceptor } from "@connectrpc/connect";
|
|
2
|
+
import type { Logger } from "../common/validation.js";
|
|
3
|
+
import { createValidationInterceptor } from "../common/validation.js";
|
|
4
|
+
export { createValidationInterceptor, type Logger, type ValidationInterceptorOptions } from "../common/validation.js";
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Invalid requests return Code.InvalidArgument; invalid responses return Code.Internal.
|
|
6
|
+
* Registry covering the t-0 network provider contract protos. Leaf file
|
|
7
|
+
* descriptors pull in their full dependency graph, so adding new messages
|
|
8
|
+
* or fields to existing protos requires only `buf:generate`.
|
|
8
9
|
*/
|
|
9
|
-
export declare
|
|
10
|
+
export declare const networkRegistry: import("@bufbuild/protobuf").Registry;
|
|
11
|
+
/**
|
|
12
|
+
* Validation interceptor pre-configured for the t-0 network provider contract.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createNetworkValidationInterceptor(logger?: Logger): Interceptor;
|
|
10
15
|
/**
|
|
11
16
|
* @deprecated Use createValidationInterceptor instead.
|
|
12
17
|
*/
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { createRegistry } from "@bufbuild/protobuf";
|
|
2
|
+
import { file_tzero_v1_payment_provider } from "../common/gen/tzero/v1/payment/provider_pb.js";
|
|
3
|
+
import { file_tzero_v1_payment_network } from "../common/gen/tzero/v1/payment/network_pb.js";
|
|
4
|
+
import { createValidationInterceptor } from "../common/validation.js";
|
|
5
|
+
// Re-export everything from the common layer for backward compatibility.
|
|
6
|
+
export { createValidationInterceptor } from "../common/validation.js";
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Invalid requests return Code.InvalidArgument; invalid responses return Code.Internal.
|
|
8
|
+
* Registry covering the t-0 network provider contract protos. Leaf file
|
|
9
|
+
* descriptors pull in their full dependency graph, so adding new messages
|
|
10
|
+
* or fields to existing protos requires only `buf:generate`.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const schema = req.method.output;
|
|
19
|
-
const msg = resp.message;
|
|
20
|
-
const result = validator.validate(schema, msg);
|
|
21
|
-
if (result.kind === "invalid") {
|
|
22
|
-
const details = result.violations.map(v => `${v.field?.toString() ?? ""}: ${v.message}`).join("; ");
|
|
23
|
-
throw new ConnectError(`response validation failed: ${details}`, Code.Internal);
|
|
24
|
-
}
|
|
25
|
-
if (result.kind === "error") {
|
|
26
|
-
throw new ConnectError(`response validation error: ${result.error.message}`, Code.Internal);
|
|
27
|
-
}
|
|
28
|
-
return resp;
|
|
29
|
-
};
|
|
12
|
+
export const networkRegistry = createRegistry(file_tzero_v1_payment_provider, file_tzero_v1_payment_network);
|
|
13
|
+
/**
|
|
14
|
+
* Validation interceptor pre-configured for the t-0 network provider contract.
|
|
15
|
+
*/
|
|
16
|
+
export function createNetworkValidationInterceptor(logger) {
|
|
17
|
+
return createValidationInterceptor({ logger, registry: networkRegistry });
|
|
30
18
|
}
|
|
31
19
|
/**
|
|
32
20
|
* @deprecated Use createValidationInterceptor instead.
|
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.30";
|
package/lib/esm/version.js
CHANGED