@t-0/provider-sdk 1.1.26 → 1.1.27

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 CHANGED
@@ -14,7 +14,10 @@ See [starter README](../starter/README.md) for details on the generated project.
14
14
 
15
15
  ## Installation
16
16
 
17
+ The SDK depends on `@buf/grpc_grpc.bufbuild_es`, which is published on the Buf Schema Registry, not npmjs. Point the `@buf` scope at BSR before installing (the starter template already ships this `.npmrc`):
18
+
17
19
  ```bash
20
+ echo '@buf:registry=https://buf.build/gen/npm/v1/' >> .npmrc
18
21
  npm install @t-0/provider-sdk
19
22
  ```
20
23
 
@@ -192,7 +192,8 @@ export type GetQuoteResponse = Message<"tzero.v1.payment.GetQuoteResponse"> & {
192
192
  /**
193
193
  * *
194
194
  * All best quotes from providers with credit lines.
195
- * Each quote is the best rate for that provider for the requested amount.
195
+ * Each quote is that provider's best effective price for the requested amount:
196
+ * the lowest settlement amount, and on a tie the largest pay-out amount.
196
197
  * Each quote indicates whether it can be executed immediately.
197
198
  * Always returned alongside success/failure - providers can compare alternatives or see options when no executable quote exists.
198
199
  *
@@ -0,0 +1,21 @@
1
+ import { type ServiceImpl } from "@connectrpc/connect";
2
+ import { Health } from "@buf/grpc_grpc.bufbuild_es/grpc/health/v1/health_pb.js";
3
+ /**
4
+ * Headers carrying the identity of the SDK answering the probe. They ride on
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>>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHealthServiceImpl = exports.SDK_VERSION_HEADER = exports.SDK_ECOSYSTEM_HEADER = void 0;
4
+ const protobuf_1 = require("@bufbuild/protobuf");
5
+ const connect_1 = require("@connectrpc/connect");
6
+ const health_pb_js_1 = require("@buf/grpc_grpc.bufbuild_es/grpc/health/v1/health_pb.js");
7
+ const version_js_1 = require("../version.js");
8
+ /**
9
+ * Headers carrying the identity of the SDK answering the probe. They ride on
10
+ * the health response and nowhere else: `HealthCheckResponse` has a single
11
+ * status field and `check` names its service in the request, so the contract
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
+ // The schema comes from a published .d.ts, whose type brands do not
37
+ // survive ServiceImpl's generics — connect-es widens the request to
38
+ // Message<string>. The descriptor is still the real one at runtime, so
39
+ // this narrows back to what the wire actually carries.
40
+ const { service } = req;
41
+ // An empty service name asks about the process as a whole, which is up if
42
+ // this handler is running at all.
43
+ if (service !== "" && !registered.has(service)) {
44
+ throw new connect_1.ConnectError(`unknown service '${service}'`, connect_1.Code.NotFound);
45
+ }
46
+ return serving;
47
+ },
48
+ };
49
+ };
50
+ exports.createHealthServiceImpl = createHealthServiceImpl;
@@ -8,8 +8,8 @@ const connect_1 = require("@connectrpc/connect");
8
8
  const headers_js_1 = __importDefault(require("../common/headers.js"));
9
9
  const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
10
10
  const validate_response_js_1 = require("./validate_response.js");
11
- const system_pb_js_1 = require("../common/gen/tzero/v1/system/system_pb.js");
12
- const system_js_1 = require("./system.js");
11
+ const health_pb_js_1 = require("@buf/grpc_grpc.bufbuild_es/grpc/health/v1/health_pb.js");
12
+ const health_js_1 = require("./health.js");
13
13
  exports.REQUEST_VALIDITY_MILLIS = 60000;
14
14
  const createSignatureVerification = (networkPublicKey) => (next) => async (req) => {
15
15
  const ts = decodeNum(getHeader(req, headers_js_1.default.SignatureTimestamp));
@@ -57,8 +57,11 @@ const createService = (networkPublicKey, registerRoutes) => {
57
57
  },
58
58
  };
59
59
  registerRoutes(wrappedRouter);
60
- collected.push(system_pb_js_1.SystemService.typeName);
61
- origService(system_pb_js_1.SystemService, (0, system_js_1.createSystemServiceImpl)(collected));
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));
62
65
  },
63
66
  interceptors: [createSignatureVerification(networkPublicKey), (0, validate_response_js_1.createValidationInterceptor)()],
64
67
  grpcWeb: false,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.1.26";
1
+ export declare const SDK_VERSION = "1.1.27";
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // SDK semantic version. Bumped in lockstep with all other SDKs by the
5
5
  // release.yaml workflow.
6
- exports.SDK_VERSION = "1.1.26";
6
+ exports.SDK_VERSION = "1.1.27";
@@ -192,7 +192,8 @@ export type GetQuoteResponse = Message<"tzero.v1.payment.GetQuoteResponse"> & {
192
192
  /**
193
193
  * *
194
194
  * All best quotes from providers with credit lines.
195
- * Each quote is the best rate for that provider for the requested amount.
195
+ * Each quote is that provider's best effective price for the requested amount:
196
+ * the lowest settlement amount, and on a tie the largest pay-out amount.
196
197
  * Each quote indicates whether it can be executed immediately.
197
198
  * Always returned alongside success/failure - providers can compare alternatives or see options when no executable quote exists.
198
199
  *
@@ -0,0 +1,21 @@
1
+ import { type ServiceImpl } from "@connectrpc/connect";
2
+ import { Health } from "@buf/grpc_grpc.bufbuild_es/grpc/health/v1/health_pb.js";
3
+ /**
4
+ * Headers carrying the identity of the SDK answering the probe. They ride on
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>>;
@@ -0,0 +1,46 @@
1
+ import { create } from "@bufbuild/protobuf";
2
+ import { Code, ConnectError } from "@connectrpc/connect";
3
+ import { HealthCheckResponse_ServingStatus, HealthCheckResponseSchema, } from "@buf/grpc_grpc.bufbuild_es/grpc/health/v1/health_pb.js";
4
+ import { SDK_VERSION } from "../version.js";
5
+ /**
6
+ * Headers carrying the identity of the SDK answering the probe. They ride on
7
+ * the health response and nowhere else: `HealthCheckResponse` has a single
8
+ * status field and `check` names its service in the request, so the contract
9
+ * itself has no room for this — and taxing every callback with headers only the
10
+ * probe reads would be worse.
11
+ */
12
+ export const SDK_ECOSYSTEM_HEADER = "T0-Sdk-Ecosystem";
13
+ export const SDK_VERSION_HEADER = "T0-Sdk-Version";
14
+ const SDK_ECOSYSTEM = "node";
15
+ /**
16
+ * Reports SERVING for the services registered on this server and NOT_FOUND for
17
+ * anything else. The set is frozen at registration; nothing is computed per
18
+ * request.
19
+ *
20
+ * `watch` is absent on purpose: it is server-streaming, and the body-hash
21
+ * signature scheme these servers run behind has no story for streams. Omitting
22
+ * it from a partial `ServiceImpl` makes connect-es answer UNIMPLEMENTED.
23
+ */
24
+ export const createHealthServiceImpl = (services) => {
25
+ const registered = new Set(services);
26
+ const serving = create(HealthCheckResponseSchema, {
27
+ status: HealthCheckResponse_ServingStatus.SERVING,
28
+ });
29
+ return {
30
+ check(req, ctx) {
31
+ ctx.responseHeader.set(SDK_ECOSYSTEM_HEADER, SDK_ECOSYSTEM);
32
+ ctx.responseHeader.set(SDK_VERSION_HEADER, SDK_VERSION);
33
+ // The schema comes from a published .d.ts, whose type brands do not
34
+ // survive ServiceImpl's generics — connect-es widens the request to
35
+ // Message<string>. The descriptor is still the real one at runtime, so
36
+ // this narrows back to what the wire actually carries.
37
+ const { service } = req;
38
+ // An empty service name asks about the process as a whole, which is up if
39
+ // this handler is running at all.
40
+ if (service !== "" && !registered.has(service)) {
41
+ throw new ConnectError(`unknown service '${service}'`, Code.NotFound);
42
+ }
43
+ return serving;
44
+ },
45
+ };
46
+ };
@@ -2,8 +2,8 @@ import { Code, ConnectError, createContextKey, createContextValues } from "@conn
2
2
  import NetworkHeaders from "../common/headers.js";
3
3
  import { secp256k1 } from '@noble/curves/secp256k1.js';
4
4
  import { createValidationInterceptor } from "./validate_response.js";
5
- import { SystemService } from "../common/gen/tzero/v1/system/system_pb.js";
6
- import { createSystemServiceImpl } from "./system.js";
5
+ import { Health } from "@buf/grpc_grpc.bufbuild_es/grpc/health/v1/health_pb.js";
6
+ import { createHealthServiceImpl } from "./health.js";
7
7
  export const REQUEST_VALIDITY_MILLIS = 60000;
8
8
  const createSignatureVerification = (networkPublicKey) => (next) => async (req) => {
9
9
  const ts = decodeNum(getHeader(req, NetworkHeaders.SignatureTimestamp));
@@ -51,8 +51,11 @@ export const createService = (networkPublicKey, registerRoutes) => {
51
51
  },
52
52
  };
53
53
  registerRoutes(wrappedRouter);
54
- collected.push(SystemService.typeName);
55
- origService(SystemService, createSystemServiceImpl(collected));
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));
56
59
  },
57
60
  interceptors: [createSignatureVerification(networkPublicKey), createValidationInterceptor()],
58
61
  grpcWeb: false,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.1.26";
1
+ export declare const SDK_VERSION = "1.1.27";
@@ -1,3 +1,3 @@
1
1
  // SDK semantic version. Bumped in lockstep with all other SDKs by the
2
2
  // release.yaml workflow.
3
- export const SDK_VERSION = "1.1.26";
3
+ export const SDK_VERSION = "1.1.27";