@terminal3/t3n-sdk 3.4.1 → 3.4.3

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/dist/index.d.ts CHANGED
@@ -1057,9 +1057,44 @@ declare class HttpTransport implements Transport {
1057
1057
  private timeout;
1058
1058
  private lastSetCookie;
1059
1059
  private lastResponseHeaders;
1060
+ /**
1061
+ * Cookie jar (`name -> value`) for non-browser callers. The session is
1062
+ * node-local in-memory state, so once the load balancer pins a client
1063
+ * to a node via its `GCLB` session-affinity cookie, every later request
1064
+ * in the session must carry that cookie back or it gets re-balanced to
1065
+ * a node that has never seen the handshake → `401 session not found`.
1066
+ * Browsers replay the cookie automatically from their own jar (via
1067
+ * `credentials: "include"`); plain `fetch` callers (Node demos, tests,
1068
+ * server-side SDK usage) have no jar, so we keep one here. Empty in
1069
+ * browsers — there `getSetCookie()` is unavailable and a script-set
1070
+ * `Cookie` header is forbidden, so this stays inert.
1071
+ */
1072
+ private cookieJar;
1060
1073
  constructor(baseUrl: string, timeout?: number);
1061
1074
  getLastSetCookie(): string | null;
1062
1075
  getLastResponseHeaders(): Record<string, string>;
1076
+ /**
1077
+ * Record response headers and merge any `Set-Cookie` into the jar.
1078
+ *
1079
+ * undici's `Headers` exposes `getSetCookie()` (one entry per cookie);
1080
+ * the DOM `Headers` type doesn't declare it, so cast structurally. In
1081
+ * browsers neither `getSetCookie()` nor reading `set-cookie` is
1082
+ * permitted, so `setCookies` is empty and the jar is left untouched.
1083
+ */
1084
+ private captureResponseMetadata;
1085
+ /**
1086
+ * Build a `Cookie` request header from the jar so non-browser callers
1087
+ * stay pinned to the node holding their session. Returns `{}` when the
1088
+ * jar is empty — always the case in browsers, leaving their native
1089
+ * cookie handling untouched.
1090
+ *
1091
+ * `callerHeaders` is checked case-insensitively: if the caller already
1092
+ * supplied a `Cookie`/`cookie` header, the jar yields to it entirely.
1093
+ * (Object spread keys are case-sensitive, but `fetch`'s `Headers` are
1094
+ * not — emitting `Cookie` here while the caller passed `cookie` would
1095
+ * make the two coexist and get comma-combined instead of overridden.)
1096
+ */
1097
+ private cookieHeader;
1063
1098
  send(request: JsonRpcRequest, headers: Record<string, string>): Promise<JsonRpcResponse>;
1064
1099
  sendMultipart(request: JsonRpcRequest, headers: Record<string, string>, blob: Blob): Promise<JsonRpcResponse>;
1065
1100
  }