@beam-network/sdk 0.5.3 → 0.5.4

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
@@ -98,7 +98,7 @@ For low-level raw transfer configs, use `createRawTransfer`; lifecycle transport
98
98
 
99
99
  Provider transfers use `transfer-client-control/v5`. Every reply carries Runtime and transport epochs; prepare and every route-stream message carry a UUID route generation. S3, R2, and S3-compatible destinations retain direct multipart UploadPart/ListParts/HEAD handling.
100
100
 
101
- The client signs up to 64 routes concurrently by default and emits 2,048-route logical batches, split only when encoded MessagePack requests exceed `maxPayloadBytes` (8 MiB by default; explicit positive overrides remain supported). A single route larger than the configured limit fails before publication with both sizes in the error. Multipart create and abort requests use a separate `multipartControlConcurrency` limit of 2 by default, with explicit positive overrides supported, and S3-compatible control requests make up to five attempts for transient provider failures. This keeps URL signing throughput independent from provider control-plane pressure.
101
+ The client signs up to 64 routes concurrently by default and emits 2,048-route logical batches, split only when encoded MessagePack requests approach `maxPayloadBytes` (8 MiB by default; explicit positive overrides remain supported). The splitter reserves control-envelope headroom for the live auth token and stable request identity so the final encoded request remains below the configured guard. A single route larger than the configured limit fails before publication with both sizes in the error. Multipart create and abort requests use a separate `multipartControlConcurrency` limit of 2 by default, with explicit positive overrides supported, and S3-compatible control requests make up to five attempts for transient provider failures. This keeps URL signing throughput independent from provider control-plane pressure.
102
102
 
103
103
  The stream ID derives from the transfer, selected flow, and immutable plan identity, and each ordered batch ID includes its route-coordinate checksum. Manual multi-destination attachment requires `delivery_index` on every route. Lifecycle mutations retry transient failures up to three times with the same request identity. A non-recoverable provider setup or route failure raises `BeamProviderTransferError`, whose `errors`, `transferCancelled`, and `multipartCleanupComplete` fields retain the original provider, cancellation, and cleanup outcomes. `waitForTransfer` subscribes to the API-key-owned, at-most-once terminal signal before its first status read and reconciles every signal through authoritative status; subscription failure degrades to the same jittered 15-to-30-second status fallback. Call `close()` when the client is no longer needed; it also closes outstanding terminal waiters.
104
104
 
@@ -6,6 +6,7 @@ export const BEAM_DEFAULT_NATS_WS_URL = "wss://nats.b1m.ai:443";
6
6
  // NATS enforces max_payload per message. This guard splits signed-route control
7
7
  // messages before the broker rejects them; transfer bytes never flow through NATS.
8
8
  export const BEAM_DEFAULT_MAX_PAYLOAD_BYTES = 8 * 1024 * 1024;
9
+ const ROUTE_BATCH_AUTH_TOKEN_ESTIMATE_BYTES = 64 * 1024;
9
10
  export function buildConnectionOptions(options) {
10
11
  const connectionOptions = {
11
12
  servers: options.natsUrl,
@@ -284,6 +285,7 @@ export class BeamTransferControl {
284
285
  }
285
286
  }
286
287
  splitRoutesForPayload(messageType, basePayload, routes) {
288
+ const authTokenEstimateBytes = Math.min(ROUTE_BATCH_AUTH_TOKEN_ESTIMATE_BYTES, Math.max(512, Math.floor(this.maxPayloadBytes / 128)));
287
289
  const encodedBytes = (candidate) => {
288
290
  const encoded = encode({
289
291
  schema_version: TRANSFER_CLIENT_CONTROL_SCHEMA_VERSION,
@@ -292,7 +294,10 @@ export class BeamTransferControl {
292
294
  shard_id: 0,
293
295
  message_type: messageType,
294
296
  request_id: "00000000-0000-4000-8000-000000000000",
295
- auth_token: "x".repeat(512),
297
+ // The live JWT is larger than the compact placeholder once claims and
298
+ // signatures are encoded. Reserve enough space for token and envelope
299
+ // growth so a batch accepted by the estimator stays below the guard.
300
+ auth_token: "x".repeat(authTokenEstimateBytes),
296
301
  occurred_at: new Date().toISOString(),
297
302
  producer: "sdk",
298
303
  payload: { ...basePayload, route_batch: compactSignedRoutes(candidate) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beam-network/sdk",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "TypeScript SDK for BEAM transfer creation and management.",
5
5
  "type": "module",
6
6
  "license": "MIT",