@reactor-team/js-sdk 3.1.0 → 3.2.0

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.
@@ -59,9 +59,17 @@ export interface ConnectOptions {
59
59
  maxAttempts?: number;
60
60
  }
61
61
 
62
- /** A token, or a resolver called before every authenticated request.
63
- * Returning "" sends no Authorization header. */
64
- export type JwtSource = string | (() => string | Promise<string>);
62
+ /** What a token is being resolved for. `sessionId` is set for every request
63
+ * that targets an existing session and unset for session creation. A
64
+ * resolver that mints a replacement token must bind it to that session
65
+ * (`resources.sessions.bind`), or the token cannot reach the session. */
66
+ export interface JwtRequestContext {
67
+ sessionId?: string;
68
+ }
69
+
70
+ /** A token, or a resolver called before every authenticated request with a
71
+ * `JwtRequestContext`. Returning "" sends no Authorization header. */
72
+ export type JwtSource = string | ((context?: JwtRequestContext) => string | Promise<string>);
65
73
 
66
74
  export interface TrackCapability {
67
75
  name: string;
@@ -249,9 +257,10 @@ export class ReactorClient {
249
257
  * Create a client.
250
258
  *
251
259
  * * `options` — see the `ClientOptions` fields; `modelName` is required.
252
- * * `jwt` — a token string, a `() => string | Promise<string>` resolver
253
- * called before every authenticated request, or `null` for an
254
- * unauthenticated local runtime. Replaceable later with `setJwt`.
260
+ * * `jwt` — a token string, a `(context) => string | Promise<string>`
261
+ * resolver called before every authenticated request with the session
262
+ * it is for, or `null` for an unauthenticated local runtime.
263
+ * Replaceable later with `setJwt`.
255
264
  */
256
265
  constructor(options: ClientOptions, jwt?: JwtSource | null);
257
266
  /**