@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
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
export * from "./crypto/index.js";
|
|
1
2
|
export * from "./client/client.js";
|
|
2
3
|
export * from "./service/service.js";
|
|
4
|
+
export * from "./common/validation.js";
|
|
3
5
|
export * from "./service/validate_response.js";
|
|
6
|
+
export * from "./service/validate.js";
|
|
4
7
|
export * from "./service/node.js";
|
|
8
|
+
export { default as NetworkHeaders } from "./common/headers.js";
|
|
5
9
|
export { connectNodeAdapter as nodeAdapter } from "@connectrpc/connect-node";
|
|
6
10
|
export type { Client, HandlerContext } from "@connectrpc/connect";
|
|
7
11
|
export * from './common/gen/tzero/v1/common/common_pb.js';
|
package/lib/cjs/index.js
CHANGED
|
@@ -35,12 +35,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
return result;
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.PaymentIntentRecipient = exports.PaymentIntentProvider = exports.PaymentIntentBeneficiary = exports.PaymentIntentPayInProvider = exports.PaymentIntentNetwork = exports.nodeAdapter = void 0;
|
|
42
|
+
exports.PaymentIntentRecipient = exports.PaymentIntentProvider = exports.PaymentIntentBeneficiary = exports.PaymentIntentPayInProvider = exports.PaymentIntentNetwork = exports.nodeAdapter = exports.NetworkHeaders = void 0;
|
|
43
|
+
__exportStar(require("./crypto/index.js"), exports);
|
|
40
44
|
__exportStar(require("./client/client.js"), exports);
|
|
41
45
|
__exportStar(require("./service/service.js"), exports);
|
|
46
|
+
__exportStar(require("./common/validation.js"), exports);
|
|
42
47
|
__exportStar(require("./service/validate_response.js"), exports);
|
|
48
|
+
__exportStar(require("./service/validate.js"), exports);
|
|
43
49
|
__exportStar(require("./service/node.js"), exports);
|
|
50
|
+
var headers_js_1 = require("./common/headers.js");
|
|
51
|
+
Object.defineProperty(exports, "NetworkHeaders", { enumerable: true, get: function () { return __importDefault(headers_js_1).default; } });
|
|
44
52
|
var connect_node_1 = require("@connectrpc/connect-node");
|
|
45
53
|
Object.defineProperty(exports, "nodeAdapter", { enumerable: true, get: function () { return connect_node_1.connectNodeAdapter; } });
|
|
46
54
|
__exportStar(require("./common/gen/tzero/v1/common/common_pb.js"), exports);
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Health } from "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* the health response and nowhere else: `HealthCheckResponse` has a single
|
|
6
|
-
* status field and `check` names its service in the request, so the contract
|
|
7
|
-
* itself has no room for this — and taxing every callback with headers only the
|
|
8
|
-
* probe reads would be worse.
|
|
9
|
-
*/
|
|
10
|
-
export declare const SDK_ECOSYSTEM_HEADER = "T0-Sdk-Ecosystem";
|
|
11
|
-
export declare const SDK_VERSION_HEADER = "T0-Sdk-Version";
|
|
12
|
-
/**
|
|
13
|
-
* Reports SERVING for the services registered on this server and NOT_FOUND for
|
|
14
|
-
* anything else. The set is frozen at registration; nothing is computed per
|
|
15
|
-
* request.
|
|
16
|
-
*
|
|
17
|
-
* `watch` is absent on purpose: it is server-streaming, and the body-hash
|
|
18
|
-
* signature scheme these servers run behind has no story for streams. Omitting
|
|
19
|
-
* it from a partial `ServiceImpl` makes connect-es answer UNIMPLEMENTED.
|
|
20
|
-
*/
|
|
21
|
-
export declare const createHealthServiceImpl: (services: string[]) => Partial<ServiceImpl<typeof Health>>;
|
|
1
|
+
import type { ServiceImpl } from "@connectrpc/connect";
|
|
2
|
+
import type { Health } from "../common/health_pb.js";
|
|
3
|
+
export { SDK_ECOSYSTEM_HEADER, SDK_VERSION_HEADER } from "../common/health.js";
|
|
4
|
+
export declare const createHealthServiceImpl: (services: string[], version?: string) => Partial<ServiceImpl<typeof Health>>;
|
|
@@ -1,46 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createHealthServiceImpl = exports.SDK_VERSION_HEADER = exports.SDK_ECOSYSTEM_HEADER = void 0;
|
|
4
|
-
const
|
|
5
|
-
const connect_1 = require("@connectrpc/connect");
|
|
6
|
-
const health_pb_js_1 = require("./health_pb.js");
|
|
4
|
+
const health_js_1 = require("../common/health.js");
|
|
7
5
|
const version_js_1 = require("../version.js");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* itself has no room for this — and taxing every callback with headers only the
|
|
13
|
-
* probe reads would be worse.
|
|
14
|
-
*/
|
|
15
|
-
exports.SDK_ECOSYSTEM_HEADER = "T0-Sdk-Ecosystem";
|
|
16
|
-
exports.SDK_VERSION_HEADER = "T0-Sdk-Version";
|
|
17
|
-
const SDK_ECOSYSTEM = "node";
|
|
18
|
-
/**
|
|
19
|
-
* Reports SERVING for the services registered on this server and NOT_FOUND for
|
|
20
|
-
* anything else. The set is frozen at registration; nothing is computed per
|
|
21
|
-
* request.
|
|
22
|
-
*
|
|
23
|
-
* `watch` is absent on purpose: it is server-streaming, and the body-hash
|
|
24
|
-
* signature scheme these servers run behind has no story for streams. Omitting
|
|
25
|
-
* it from a partial `ServiceImpl` makes connect-es answer UNIMPLEMENTED.
|
|
26
|
-
*/
|
|
27
|
-
const createHealthServiceImpl = (services) => {
|
|
28
|
-
const registered = new Set(services);
|
|
29
|
-
const serving = (0, protobuf_1.create)(health_pb_js_1.HealthCheckResponseSchema, {
|
|
30
|
-
status: health_pb_js_1.HealthCheckResponse_ServingStatus.SERVING,
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
check(req, ctx) {
|
|
34
|
-
ctx.responseHeader.set(exports.SDK_ECOSYSTEM_HEADER, SDK_ECOSYSTEM);
|
|
35
|
-
ctx.responseHeader.set(exports.SDK_VERSION_HEADER, version_js_1.SDK_VERSION);
|
|
36
|
-
const { service } = req;
|
|
37
|
-
// An empty service name asks about the process as a whole, which is up if
|
|
38
|
-
// this handler is running at all.
|
|
39
|
-
if (service !== "" && !registered.has(service)) {
|
|
40
|
-
throw new connect_1.ConnectError(`unknown service '${service}'`, connect_1.Code.NotFound);
|
|
41
|
-
}
|
|
42
|
-
return serving;
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
};
|
|
6
|
+
var health_js_2 = require("../common/health.js");
|
|
7
|
+
Object.defineProperty(exports, "SDK_ECOSYSTEM_HEADER", { enumerable: true, get: function () { return health_js_2.SDK_ECOSYSTEM_HEADER; } });
|
|
8
|
+
Object.defineProperty(exports, "SDK_VERSION_HEADER", { enumerable: true, get: function () { return health_js_2.SDK_VERSION_HEADER; } });
|
|
9
|
+
const createHealthServiceImpl = (services, version) => (0, health_js_1.createHealthServiceImpl)(services, version ?? version_js_1.SDK_VERSION);
|
|
46
10
|
exports.createHealthServiceImpl = createHealthServiceImpl;
|
|
@@ -1,157 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Message } from "@bufbuild/protobuf";
|
|
3
|
-
/**
|
|
4
|
-
* Describes the file grpc/health/v1/health.proto.
|
|
5
|
-
*/
|
|
6
|
-
export declare const file_grpc_health_v1_health: GenFile;
|
|
7
|
-
/**
|
|
8
|
-
* @generated from message grpc.health.v1.HealthCheckRequest
|
|
9
|
-
*/
|
|
10
|
-
export type HealthCheckRequest = Message<"grpc.health.v1.HealthCheckRequest"> & {
|
|
11
|
-
/**
|
|
12
|
-
* @generated from field: string service = 1;
|
|
13
|
-
*/
|
|
14
|
-
service: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Describes the message grpc.health.v1.HealthCheckRequest.
|
|
18
|
-
* Use `create(HealthCheckRequestSchema)` to create a new message.
|
|
19
|
-
*/
|
|
20
|
-
export declare const HealthCheckRequestSchema: GenMessage<HealthCheckRequest>;
|
|
21
|
-
/**
|
|
22
|
-
* @generated from message grpc.health.v1.HealthCheckResponse
|
|
23
|
-
*/
|
|
24
|
-
export type HealthCheckResponse = Message<"grpc.health.v1.HealthCheckResponse"> & {
|
|
25
|
-
/**
|
|
26
|
-
* @generated from field: grpc.health.v1.HealthCheckResponse.ServingStatus status = 1;
|
|
27
|
-
*/
|
|
28
|
-
status: HealthCheckResponse_ServingStatus;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Describes the message grpc.health.v1.HealthCheckResponse.
|
|
32
|
-
* Use `create(HealthCheckResponseSchema)` to create a new message.
|
|
33
|
-
*/
|
|
34
|
-
export declare const HealthCheckResponseSchema: GenMessage<HealthCheckResponse>;
|
|
35
|
-
/**
|
|
36
|
-
* @generated from enum grpc.health.v1.HealthCheckResponse.ServingStatus
|
|
37
|
-
*/
|
|
38
|
-
export declare enum HealthCheckResponse_ServingStatus {
|
|
39
|
-
/**
|
|
40
|
-
* @generated from enum value: UNKNOWN = 0;
|
|
41
|
-
*/
|
|
42
|
-
UNKNOWN = 0,
|
|
43
|
-
/**
|
|
44
|
-
* @generated from enum value: SERVING = 1;
|
|
45
|
-
*/
|
|
46
|
-
SERVING = 1,
|
|
47
|
-
/**
|
|
48
|
-
* @generated from enum value: NOT_SERVING = 2;
|
|
49
|
-
*/
|
|
50
|
-
NOT_SERVING = 2,
|
|
51
|
-
/**
|
|
52
|
-
* Used only by the Watch method.
|
|
53
|
-
*
|
|
54
|
-
* @generated from enum value: SERVICE_UNKNOWN = 3;
|
|
55
|
-
*/
|
|
56
|
-
SERVICE_UNKNOWN = 3
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Describes the enum grpc.health.v1.HealthCheckResponse.ServingStatus.
|
|
60
|
-
*/
|
|
61
|
-
export declare const HealthCheckResponse_ServingStatusSchema: GenEnum<HealthCheckResponse_ServingStatus>;
|
|
62
|
-
/**
|
|
63
|
-
* @generated from message grpc.health.v1.HealthListRequest
|
|
64
|
-
*/
|
|
65
|
-
export type HealthListRequest = Message<"grpc.health.v1.HealthListRequest"> & {};
|
|
66
|
-
/**
|
|
67
|
-
* Describes the message grpc.health.v1.HealthListRequest.
|
|
68
|
-
* Use `create(HealthListRequestSchema)` to create a new message.
|
|
69
|
-
*/
|
|
70
|
-
export declare const HealthListRequestSchema: GenMessage<HealthListRequest>;
|
|
71
|
-
/**
|
|
72
|
-
* @generated from message grpc.health.v1.HealthListResponse
|
|
73
|
-
*/
|
|
74
|
-
export type HealthListResponse = Message<"grpc.health.v1.HealthListResponse"> & {
|
|
75
|
-
/**
|
|
76
|
-
* statuses contains all the services and their respective status.
|
|
77
|
-
*
|
|
78
|
-
* @generated from field: map<string, grpc.health.v1.HealthCheckResponse> statuses = 1;
|
|
79
|
-
*/
|
|
80
|
-
statuses: {
|
|
81
|
-
[key: string]: HealthCheckResponse;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Describes the message grpc.health.v1.HealthListResponse.
|
|
86
|
-
* Use `create(HealthListResponseSchema)` to create a new message.
|
|
87
|
-
*/
|
|
88
|
-
export declare const HealthListResponseSchema: GenMessage<HealthListResponse>;
|
|
89
|
-
/**
|
|
90
|
-
* Health is gRPC's mechanism for checking whether a server is able to handle
|
|
91
|
-
* RPCs. Its semantics are documented in
|
|
92
|
-
* https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
|
|
93
|
-
*
|
|
94
|
-
* @generated from service grpc.health.v1.Health
|
|
95
|
-
*/
|
|
96
|
-
export declare const Health: GenService<{
|
|
97
|
-
/**
|
|
98
|
-
* Check gets the health of the specified service. If the requested service
|
|
99
|
-
* is unknown, the call will fail with status NOT_FOUND. If the caller does
|
|
100
|
-
* not specify a service name, the server should respond with its overall
|
|
101
|
-
* health status.
|
|
102
|
-
*
|
|
103
|
-
* Clients should set a deadline when calling Check, and can declare the
|
|
104
|
-
* server unhealthy if they do not receive a timely response.
|
|
105
|
-
*
|
|
106
|
-
* @generated from rpc grpc.health.v1.Health.Check
|
|
107
|
-
*/
|
|
108
|
-
check: {
|
|
109
|
-
methodKind: "unary";
|
|
110
|
-
input: typeof HealthCheckRequestSchema;
|
|
111
|
-
output: typeof HealthCheckResponseSchema;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* List provides a non-atomic snapshot of the health of all the available
|
|
115
|
-
* services.
|
|
116
|
-
*
|
|
117
|
-
* The server may respond with a RESOURCE_EXHAUSTED error if too many services
|
|
118
|
-
* exist.
|
|
119
|
-
*
|
|
120
|
-
* Clients should set a deadline when calling List, and can declare the server
|
|
121
|
-
* unhealthy if they do not receive a timely response.
|
|
122
|
-
*
|
|
123
|
-
* Clients should keep in mind that the list of health services exposed by an
|
|
124
|
-
* application can change over the lifetime of the process.
|
|
125
|
-
*
|
|
126
|
-
* @generated from rpc grpc.health.v1.Health.List
|
|
127
|
-
*/
|
|
128
|
-
list: {
|
|
129
|
-
methodKind: "unary";
|
|
130
|
-
input: typeof HealthListRequestSchema;
|
|
131
|
-
output: typeof HealthListResponseSchema;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Performs a watch for the serving status of the requested service.
|
|
135
|
-
* The server will immediately send back a message indicating the current
|
|
136
|
-
* serving status. It will then subsequently send a new message whenever
|
|
137
|
-
* the service's serving status changes.
|
|
138
|
-
*
|
|
139
|
-
* If the requested service is unknown when the call is received, the
|
|
140
|
-
* server will send a message setting the serving status to
|
|
141
|
-
* SERVICE_UNKNOWN but will *not* terminate the call. If at some
|
|
142
|
-
* future point, the serving status of the service becomes known, the
|
|
143
|
-
* server will send a new message with the service's serving status.
|
|
144
|
-
*
|
|
145
|
-
* If the call terminates with status UNIMPLEMENTED, then clients
|
|
146
|
-
* should assume this method is not supported and should not retry the
|
|
147
|
-
* call. If the call terminates with any other status (including OK),
|
|
148
|
-
* clients should retry the call with appropriate exponential backoff.
|
|
149
|
-
*
|
|
150
|
-
* @generated from rpc grpc.health.v1.Health.Watch
|
|
151
|
-
*/
|
|
152
|
-
watch: {
|
|
153
|
-
methodKind: "server_streaming";
|
|
154
|
-
input: typeof HealthCheckRequestSchema;
|
|
155
|
-
output: typeof HealthCheckResponseSchema;
|
|
156
|
-
};
|
|
157
|
-
}>;
|
|
1
|
+
export * from "../common/health_pb.js";
|
|
@@ -1,87 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
// Vendored rather than depended on: the equivalent package
|
|
18
|
-
// `@buf/grpc_grpc.bufbuild_es` is published only on the Buf Schema Registry, and
|
|
19
|
-
// reaching it needs registry config that a published npm package cannot hand its
|
|
20
|
-
// consumers -- so depending on it 404'd every downstream install. Rationale in
|
|
21
|
-
// docs/HEALTH_SERVICE.md.
|
|
22
|
-
//
|
|
23
|
-
// Lives under src/service/ rather than src/common/gen/ so the transport keeps
|
|
24
|
-
// importing nothing from common/gen.
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
25
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
const codegenv2_1 = require("@bufbuild/protobuf/codegenv2");
|
|
28
|
-
/**
|
|
29
|
-
* Describes the file grpc/health/v1/health.proto.
|
|
30
|
-
*/
|
|
31
|
-
exports.file_grpc_health_v1_health = (0, codegenv2_1.fileDesc)("ChtncnBjL2hlYWx0aC92MS9oZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYxIiUKEkhlYWx0aENoZWNrUmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIqkBChNIZWFsdGhDaGVja1Jlc3BvbnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVhbHRoLnYxLkhlYWx0aENoZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyJPCg1TZXJ2aW5nU3RhdHVzEgsKB1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9UX1NFUlZJTkcQAhITCg9TRVJWSUNFX1VOS05PV04QAyITChFIZWFsdGhMaXN0UmVxdWVzdCKuAQoSSGVhbHRoTGlzdFJlc3BvbnNlEkIKCHN0YXR1c2VzGAEgAygLMjAuZ3JwYy5oZWFsdGgudjEuSGVhbHRoTGlzdFJlc3BvbnNlLlN0YXR1c2VzRW50cnkaVAoNU3RhdHVzZXNFbnRyeRILCgNrZXkYASABKAkSMgoFdmFsdWUYAiABKAsyIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlOgI4ATL9AQoGSGVhbHRoElAKBUNoZWNrEiIuZ3JwYy5oZWFsdGgudjEuSGVhbHRoQ2hlY2tSZXF1ZXN0GiMuZ3JwYy5oZWFsdGgudjEuSGVhbHRoQ2hlY2tSZXNwb25zZRJNCgRMaXN0EiEuZ3JwYy5oZWFsdGgudjEuSGVhbHRoTGlzdFJlcXVlc3QaIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhMaXN0UmVzcG9uc2USUgoFV2F0Y2gSIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1JlcXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlMAFCcAoRaW8uZ3JwYy5oZWFsdGgudjFCC0hlYWx0aFByb3RvUAFaLGdvb2dsZS5nb2xhbmcub3JnL2dycGMvaGVhbHRoL2dycGNfaGVhbHRoX3YxogIMR3JwY0hlYWx0aFYxqgIOR3JwYy5IZWFsdGguVjFiBnByb3RvMw");
|
|
32
|
-
/**
|
|
33
|
-
* Describes the message grpc.health.v1.HealthCheckRequest.
|
|
34
|
-
* Use `create(HealthCheckRequestSchema)` to create a new message.
|
|
35
|
-
*/
|
|
36
|
-
exports.HealthCheckRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_grpc_health_v1_health, 0);
|
|
37
|
-
/**
|
|
38
|
-
* Describes the message grpc.health.v1.HealthCheckResponse.
|
|
39
|
-
* Use `create(HealthCheckResponseSchema)` to create a new message.
|
|
40
|
-
*/
|
|
41
|
-
exports.HealthCheckResponseSchema = (0, codegenv2_1.messageDesc)(exports.file_grpc_health_v1_health, 1);
|
|
42
|
-
/**
|
|
43
|
-
* @generated from enum grpc.health.v1.HealthCheckResponse.ServingStatus
|
|
44
|
-
*/
|
|
45
|
-
var HealthCheckResponse_ServingStatus;
|
|
46
|
-
(function (HealthCheckResponse_ServingStatus) {
|
|
47
|
-
/**
|
|
48
|
-
* @generated from enum value: UNKNOWN = 0;
|
|
49
|
-
*/
|
|
50
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["UNKNOWN"] = 0] = "UNKNOWN";
|
|
51
|
-
/**
|
|
52
|
-
* @generated from enum value: SERVING = 1;
|
|
53
|
-
*/
|
|
54
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["SERVING"] = 1] = "SERVING";
|
|
55
|
-
/**
|
|
56
|
-
* @generated from enum value: NOT_SERVING = 2;
|
|
57
|
-
*/
|
|
58
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["NOT_SERVING"] = 2] = "NOT_SERVING";
|
|
59
|
-
/**
|
|
60
|
-
* Used only by the Watch method.
|
|
61
|
-
*
|
|
62
|
-
* @generated from enum value: SERVICE_UNKNOWN = 3;
|
|
63
|
-
*/
|
|
64
|
-
HealthCheckResponse_ServingStatus[HealthCheckResponse_ServingStatus["SERVICE_UNKNOWN"] = 3] = "SERVICE_UNKNOWN";
|
|
65
|
-
})(HealthCheckResponse_ServingStatus || (exports.HealthCheckResponse_ServingStatus = HealthCheckResponse_ServingStatus = {}));
|
|
66
|
-
/**
|
|
67
|
-
* Describes the enum grpc.health.v1.HealthCheckResponse.ServingStatus.
|
|
68
|
-
*/
|
|
69
|
-
exports.HealthCheckResponse_ServingStatusSchema = (0, codegenv2_1.enumDesc)(exports.file_grpc_health_v1_health, 1, 0);
|
|
70
|
-
/**
|
|
71
|
-
* Describes the message grpc.health.v1.HealthListRequest.
|
|
72
|
-
* Use `create(HealthListRequestSchema)` to create a new message.
|
|
73
|
-
*/
|
|
74
|
-
exports.HealthListRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_grpc_health_v1_health, 2);
|
|
75
|
-
/**
|
|
76
|
-
* Describes the message grpc.health.v1.HealthListResponse.
|
|
77
|
-
* Use `create(HealthListResponseSchema)` to create a new message.
|
|
78
|
-
*/
|
|
79
|
-
exports.HealthListResponseSchema = (0, codegenv2_1.messageDesc)(exports.file_grpc_health_v1_health, 3);
|
|
80
|
-
/**
|
|
81
|
-
* Health is gRPC's mechanism for checking whether a server is able to handle
|
|
82
|
-
* RPCs. Its semantics are documented in
|
|
83
|
-
* https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
|
|
84
|
-
*
|
|
85
|
-
* @generated from service grpc.health.v1.Health
|
|
86
|
-
*/
|
|
87
|
-
exports.Health = (0, codegenv2_1.serviceDesc)(exports.file_grpc_health_v1_health, 0);
|
|
17
|
+
__exportStar(require("../common/health_pb.js"), exports);
|
package/lib/cjs/service/node.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
15
|
};
|
|
15
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../common/node.js"), exports);
|
|
@@ -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,98 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.createService = exports.REQUEST_VALIDITY_MILLIS = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const health_js_1 = require("./health.js");
|
|
13
|
-
exports.REQUEST_VALIDITY_MILLIS = 60000;
|
|
14
|
-
const createSignatureVerification = (networkPublicKey) => (next) => async (req) => {
|
|
15
|
-
const ts = decodeNum(getHeader(req, headers_js_1.default.SignatureTimestamp));
|
|
16
|
-
if (Date.now() - ts > 60000) {
|
|
17
|
-
throw new connect_1.ConnectError(`${headers_js_1.default.SignatureTimestamp} must be within ${exports.REQUEST_VALIDITY_MILLIS} milliseconds from now`, connect_1.Code.InvalidArgument);
|
|
18
|
-
}
|
|
19
|
-
const publicKey = decodeHex(getHeader(req, headers_js_1.default.PublicKey));
|
|
20
|
-
if (networkPublicKey.compare(publicKey) !== 0) {
|
|
21
|
-
throw new connect_1.ConnectError(`${headers_js_1.default.PublicKey} value is not network public key`, connect_1.Code.Unauthenticated);
|
|
22
|
-
}
|
|
23
|
-
let signature = decodeHex(getHeader(req, headers_js_1.default.Signature));
|
|
24
|
-
if (signature.length === 65) {
|
|
25
|
-
signature = signature.subarray(0, 64);
|
|
26
|
-
}
|
|
27
|
-
const hasher = req.contextValues.get(kHash);
|
|
28
|
-
const tsBuf = Buffer.alloc(8);
|
|
29
|
-
tsBuf.writeBigUInt64LE(BigInt(ts)); // 64‑bit little‑endian timestamp
|
|
30
|
-
const hash = hasher
|
|
31
|
-
.update(tsBuf)
|
|
32
|
-
.digest();
|
|
33
|
-
let signatureValid = false;
|
|
34
|
-
try {
|
|
35
|
-
signatureValid = secp256k1_js_1.secp256k1.verify(signature, hash, publicKey, { prehash: false });
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
throw new connect_1.ConnectError(`${headers_js_1.default.Signature} has invalid signature or public key format: ${e}`, connect_1.Code.Unauthenticated);
|
|
39
|
-
}
|
|
40
|
-
if (!signatureValid) {
|
|
41
|
-
throw new connect_1.ConnectError(`${headers_js_1.default.Signature} has invalid signature`, connect_1.Code.Unauthenticated);
|
|
42
|
-
}
|
|
43
|
-
return await next(req);
|
|
44
|
-
};
|
|
45
|
-
const createService = (networkPublicKey, registerRoutes) => {
|
|
46
|
-
if (typeof networkPublicKey == "string") {
|
|
47
|
-
networkPublicKey = decodeHex(networkPublicKey);
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
routes: (router) => {
|
|
51
|
-
const collected = [];
|
|
52
|
-
const origService = router.service.bind(router);
|
|
53
|
-
const wrappedRouter = {
|
|
54
|
-
service: (desc, impl) => {
|
|
55
|
-
collected.push(desc.typeName);
|
|
56
|
-
origService(desc, impl);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
registerRoutes(wrappedRouter);
|
|
60
|
-
// Health is the only service this transport mounts on its own — see
|
|
61
|
-
// docs/HEALTH_SERVICE.md. Same interceptors as everything else, so the
|
|
62
|
-
// probe is signed like any other call.
|
|
63
|
-
collected.push(health_pb_js_1.Health.typeName);
|
|
64
|
-
origService(health_pb_js_1.Health, (0, health_js_1.createHealthServiceImpl)(collected));
|
|
65
|
-
},
|
|
66
|
-
interceptors: [createSignatureVerification(networkPublicKey), (0, validate_response_js_1.createValidationInterceptor)()],
|
|
67
|
-
grpcWeb: false,
|
|
68
|
-
contextValues: (req) => {
|
|
69
|
-
return (0, connect_1.createContextValues)().set(kHash, req.hasher);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
4
|
+
const service_js_1 = require("../common/service.js");
|
|
5
|
+
const version_js_1 = require("../version.js");
|
|
6
|
+
var service_js_2 = require("../common/service.js");
|
|
7
|
+
Object.defineProperty(exports, "REQUEST_VALIDITY_MILLIS", { enumerable: true, get: function () { return service_js_2.REQUEST_VALIDITY_MILLIS; } });
|
|
8
|
+
const createService = (networkPublicKey, registerRoutes, options) => (0, service_js_1.createService)(networkPublicKey, registerRoutes, { ...options, version: options?.version ?? version_js_1.SDK_VERSION });
|
|
73
9
|
exports.createService = createService;
|
|
74
|
-
const kHash = (0, connect_1.createContextKey)(undefined);
|
|
75
|
-
function getHeader(req, header) {
|
|
76
|
-
const raw = req.header.get(header);
|
|
77
|
-
if (!raw) {
|
|
78
|
-
throw new connect_1.ConnectError(`missing required header '${header}'`, connect_1.Code.InvalidArgument);
|
|
79
|
-
}
|
|
80
|
-
return raw;
|
|
81
|
-
}
|
|
82
|
-
function decodeHex(value) {
|
|
83
|
-
value = value.startsWith('0x') ? value.slice(2) : value;
|
|
84
|
-
try {
|
|
85
|
-
return Buffer.from(value, "hex");
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
throw new connect_1.ConnectError(`invalid header format. '${value}' must be hex encoded`, connect_1.Code.InvalidArgument);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function decodeNum(value) {
|
|
92
|
-
try {
|
|
93
|
-
return parseInt(value);
|
|
94
|
-
}
|
|
95
|
-
catch (e) {
|
|
96
|
-
throw new connect_1.ConnectError(`invalid header format. '${value}' must be a number`, connect_1.Code.InvalidArgument);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../common/validate.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../common/validate.js"), exports);
|
|
@@ -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
|
*/
|