@c7-digital/ledger 0.0.11 → 0.0.13

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.
@@ -51,7 +51,7 @@ export interface TypedHttpClientConfig {
51
51
  openApiSchemaPath?: string;
52
52
  }
53
53
  export declare class TypedHttpClient {
54
- readonly token: string;
54
+ token: string;
55
55
  readonly baseUrl: string;
56
56
  private validator?;
57
57
  constructor(config: TypedHttpClientConfig);
@@ -81,6 +81,11 @@ export declare class Ledger {
81
81
  private httpBaseUrl;
82
82
  private options;
83
83
  constructor(options: LedgerOptions);
84
+ /**
85
+ * Update the authentication token used for HTTP requests.
86
+ * Active streams should be updated separately via stream.updateToken().
87
+ */
88
+ setToken(newToken: string): void;
84
89
  private generateCommandId;
85
90
  private resolveOffset;
86
91
  private getLedgerEnd;
package/lib/src/ledger.js CHANGED
@@ -506,6 +506,15 @@ export class Ledger {
506
506
  });
507
507
  this.options = options;
508
508
  }
509
+ /**
510
+ * Update the authentication token used for HTTP requests.
511
+ * Active streams should be updated separately via stream.updateToken().
512
+ */
513
+ setToken(newToken) {
514
+ logTokenExpiration(newToken, "Ledger setToken");
515
+ this.client.token = newToken;
516
+ this.options = { ...this.options, token: newToken };
517
+ }
509
518
  generateCommandId() {
510
519
  return createLedgerString(`cmd-${Date.now()}-${Math.random().toString(36).substring(2, 13)}`);
511
520
  }
@@ -82,7 +82,8 @@ export class WebSocketClient {
82
82
  onMessage(message);
83
83
  }
84
84
  catch (error) {
85
- onError?.(new Error(`Failed to parse message for ${endpoint}: ${error}`));
85
+ const errorDetail = error instanceof Error ? error.message : JSON.stringify(error);
86
+ onError?.(new Error(`Failed to parse message for ${endpoint}: ${errorDetail}`));
86
87
  }
87
88
  };
88
89
  ws.onerror = (event) => {