@routstr/sdk 0.2.5 → 0.2.6

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
@@ -70,10 +70,9 @@ await client.fetchAIResponse(fetchOptions, streamingCallbacks);
70
70
 
71
71
  ## Client Modes
72
72
 
73
- The `RoutstrClient` supports three modes via the constructor `mode` parameter (defaults to `"xcashu"` if unspecified):
73
+ The `RoutstrClient` supports two modes via the constructor `mode` parameter (defaults to `"xcashu"` if unspecified):
74
74
 
75
75
  - `"xcashu"` — Default mode. Uses standard Cashu token spending with refunds.
76
- - `"lazyrefund"` — Defers refund processing to reduce mint load; may retain tokens longer before refunding.
77
76
  - `"apikeys"` — Uses API key authentication instead of Cashu tokens; no token spending or refund flow.
78
77
 
79
78
  ```ts
@@ -1,8 +1,11 @@
1
1
  import { M as Model, a as Message, T as TransactionHistory, l as StreamingResult } from '../types-BYj_8c5c.mjs';
2
- import { P as ProviderRegistry, W as WalletAdapter, S as StorageAdapter, a as StreamingCallbacks } from '../interfaces-C6Dr6hKy.mjs';
2
+ import { P as ProviderRegistry, W as WalletAdapter, S as StorageAdapter, a as StreamingCallbacks } from '../interfaces-C5fLD3jB.mjs';
3
+ import { U as UsageTrackingDriver, S as SdkStore } from '../store-C5lnyX8k.mjs';
3
4
  import { ServerResponse } from 'http';
4
5
  import { CashuSpender, BalanceManager } from '../wallet/index.mjs';
5
6
  import { Transform } from 'stream';
7
+ import 'zustand/vanilla';
8
+ import '../interfaces-BWJJTCXO.mjs';
6
9
 
7
10
  /**
8
11
  * ProviderManager - Handles provider selection and failover logic
@@ -163,7 +166,7 @@ interface FetchOptions {
163
166
  * RoutstrClient is the main SDK entry point
164
167
  */
165
168
  type AlertLevel = "max" | "min";
166
- type RoutstrClientMode = "xcashu" | "lazyrefund" | "apikeys";
169
+ type RoutstrClientMode = "xcashu" | "apikeys";
167
170
  type DebugLevel = "DEBUG" | "WARN" | "ERROR";
168
171
  interface RouteRequestParams {
169
172
  path: string;
@@ -173,10 +176,15 @@ interface RouteRequestParams {
173
176
  baseUrl: string;
174
177
  mintUrl: string;
175
178
  modelId?: string;
179
+ clientApiKey?: string;
176
180
  }
177
181
  interface RouteRequestToNodeResponseParams extends RouteRequestParams {
178
182
  res: ServerResponse;
179
183
  }
184
+ interface RoutstrClientConfig {
185
+ usageTrackingDriver?: UsageTrackingDriver;
186
+ sdkStore?: SdkStore;
187
+ }
180
188
  declare class RoutstrClient {
181
189
  private walletAdapter;
182
190
  private storageAdapter;
@@ -188,7 +196,9 @@ declare class RoutstrClient {
188
196
  private alertLevel;
189
197
  private mode;
190
198
  private debugLevel;
191
- constructor(walletAdapter: WalletAdapter, storageAdapter: StorageAdapter, providerRegistry: ProviderRegistry, alertLevel: AlertLevel, mode?: RoutstrClientMode);
199
+ private usageTrackingDriver?;
200
+ private sdkStore?;
201
+ constructor(walletAdapter: WalletAdapter, storageAdapter: StorageAdapter, providerRegistry: ProviderRegistry, alertLevel: AlertLevel, mode?: RoutstrClientMode, options?: RoutstrClientConfig);
192
202
  /**
193
203
  * Get the current client mode
194
204
  */
@@ -223,6 +233,10 @@ declare class RoutstrClient {
223
233
  routeRequest(params: RouteRequestParams): Promise<Response>;
224
234
  routeRequestToNodeResponse(params: RouteRequestToNodeResponseParams): Promise<void>;
225
235
  private _prepareRoutedRequest;
236
+ /**
237
+ * Extract clientApiKey from Authorization Bearer token if present
238
+ */
239
+ private _extractClientApiKey;
226
240
  /**
227
241
  * Fetch AI response with streaming
228
242
  */
@@ -253,7 +267,7 @@ declare class RoutstrClient {
253
267
  */
254
268
  private _getEstimatedCosts;
255
269
  /**
256
- * Get pending cashu token amount
270
+ * Get pending API key amount
257
271
  */
258
272
  private _getPendingCashuTokenAmount;
259
273
  /**
@@ -346,4 +360,4 @@ interface UsageTrackingData {
346
360
 
347
361
  declare function createSSEParserTransform(onUsage: (usage: UsageTrackingData) => void, onResponseId?: (responseId: string) => void): Transform;
348
362
 
349
- export { type AlertLevel, type DebugLevel, type FetchOptions, type ModelProviderPrice, ProviderManager, type RouteRequestParams, type RouteRequestToNodeResponseParams, RoutstrClient, type RoutstrClientMode, type StreamCallbacks, StreamProcessor, createSSEParserTransform };
363
+ export { type AlertLevel, type DebugLevel, type FetchOptions, type ModelProviderPrice, ProviderManager, type RouteRequestParams, type RouteRequestToNodeResponseParams, RoutstrClient, type RoutstrClientConfig, type RoutstrClientMode, type StreamCallbacks, StreamProcessor, createSSEParserTransform };
@@ -1,8 +1,11 @@
1
1
  import { M as Model, a as Message, T as TransactionHistory, l as StreamingResult } from '../types-BYj_8c5c.js';
2
- import { P as ProviderRegistry, W as WalletAdapter, S as StorageAdapter, a as StreamingCallbacks } from '../interfaces-CluftN4z.js';
2
+ import { P as ProviderRegistry, W as WalletAdapter, S as StorageAdapter, a as StreamingCallbacks } from '../interfaces-B62Rw-dd.js';
3
+ import { U as UsageTrackingDriver, S as SdkStore } from '../store-BJlwiDX5.js';
3
4
  import { ServerResponse } from 'http';
4
5
  import { CashuSpender, BalanceManager } from '../wallet/index.js';
5
6
  import { Transform } from 'stream';
7
+ import 'zustand/vanilla';
8
+ import '../interfaces-BxDEka72.js';
6
9
 
7
10
  /**
8
11
  * ProviderManager - Handles provider selection and failover logic
@@ -163,7 +166,7 @@ interface FetchOptions {
163
166
  * RoutstrClient is the main SDK entry point
164
167
  */
165
168
  type AlertLevel = "max" | "min";
166
- type RoutstrClientMode = "xcashu" | "lazyrefund" | "apikeys";
169
+ type RoutstrClientMode = "xcashu" | "apikeys";
167
170
  type DebugLevel = "DEBUG" | "WARN" | "ERROR";
168
171
  interface RouteRequestParams {
169
172
  path: string;
@@ -173,10 +176,15 @@ interface RouteRequestParams {
173
176
  baseUrl: string;
174
177
  mintUrl: string;
175
178
  modelId?: string;
179
+ clientApiKey?: string;
176
180
  }
177
181
  interface RouteRequestToNodeResponseParams extends RouteRequestParams {
178
182
  res: ServerResponse;
179
183
  }
184
+ interface RoutstrClientConfig {
185
+ usageTrackingDriver?: UsageTrackingDriver;
186
+ sdkStore?: SdkStore;
187
+ }
180
188
  declare class RoutstrClient {
181
189
  private walletAdapter;
182
190
  private storageAdapter;
@@ -188,7 +196,9 @@ declare class RoutstrClient {
188
196
  private alertLevel;
189
197
  private mode;
190
198
  private debugLevel;
191
- constructor(walletAdapter: WalletAdapter, storageAdapter: StorageAdapter, providerRegistry: ProviderRegistry, alertLevel: AlertLevel, mode?: RoutstrClientMode);
199
+ private usageTrackingDriver?;
200
+ private sdkStore?;
201
+ constructor(walletAdapter: WalletAdapter, storageAdapter: StorageAdapter, providerRegistry: ProviderRegistry, alertLevel: AlertLevel, mode?: RoutstrClientMode, options?: RoutstrClientConfig);
192
202
  /**
193
203
  * Get the current client mode
194
204
  */
@@ -223,6 +233,10 @@ declare class RoutstrClient {
223
233
  routeRequest(params: RouteRequestParams): Promise<Response>;
224
234
  routeRequestToNodeResponse(params: RouteRequestToNodeResponseParams): Promise<void>;
225
235
  private _prepareRoutedRequest;
236
+ /**
237
+ * Extract clientApiKey from Authorization Bearer token if present
238
+ */
239
+ private _extractClientApiKey;
226
240
  /**
227
241
  * Fetch AI response with streaming
228
242
  */
@@ -253,7 +267,7 @@ declare class RoutstrClient {
253
267
  */
254
268
  private _getEstimatedCosts;
255
269
  /**
256
- * Get pending cashu token amount
270
+ * Get pending API key amount
257
271
  */
258
272
  private _getPendingCashuTokenAmount;
259
273
  /**
@@ -346,4 +360,4 @@ interface UsageTrackingData {
346
360
 
347
361
  declare function createSSEParserTransform(onUsage: (usage: UsageTrackingData) => void, onResponseId?: (responseId: string) => void): Transform;
348
362
 
349
- export { type AlertLevel, type DebugLevel, type FetchOptions, type ModelProviderPrice, ProviderManager, type RouteRequestParams, type RouteRequestToNodeResponseParams, RoutstrClient, type RoutstrClientMode, type StreamCallbacks, StreamProcessor, createSSEParserTransform };
363
+ export { type AlertLevel, type DebugLevel, type FetchOptions, type ModelProviderPrice, ProviderManager, type RouteRequestParams, type RouteRequestToNodeResponseParams, RoutstrClient, type RoutstrClientConfig, type RoutstrClientMode, type StreamCallbacks, StreamProcessor, createSSEParserTransform };