@relai-fi/x402 0.5.37 → 0.5.39

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.
@@ -43,12 +43,12 @@ interface RelaiPlugin {
43
43
  enrich402Response?(response: any, ctx: PluginContext): any;
44
44
  }
45
45
  interface FreeTierPluginConfig {
46
- /** Service key (sk_live_...) for authenticating with RelAI API */
47
- serviceKey: string;
46
+ /** Service key (sk_live_...) for syncing with RelAI backend. If omitted, runs in local in-memory mode. */
47
+ serviceKey?: string;
48
48
  /** Max free calls per buyer per period */
49
49
  perBuyerLimit: number;
50
50
  /** Reset period for per-buyer counters */
51
- resetPeriod?: 'never' | 'daily' | 'monthly';
51
+ resetPeriod?: 'none' | 'daily' | 'monthly';
52
52
  /** Optional global cap across all buyers */
53
53
  globalCap?: number;
54
54
  /** Specific paths to apply free tier to (default: '*' = all) */
@@ -90,6 +90,8 @@ interface FreeTierPluginConfig {
90
90
  * ```
91
91
  */
92
92
  interface BridgePluginConfig {
93
+ /** Service key (sk_live_...) for tracking bridge usage per API owner */
94
+ serviceKey?: string;
93
95
  /** RelAI API base URL (default: https://api.relai.fi) */
94
96
  baseUrl?: string;
95
97
  /** Override settle endpoint (auto-discovered from /bridge/info if not set) */
@@ -137,7 +139,35 @@ interface BridgePluginConfig {
137
139
  * ```
138
140
  */
139
141
  declare function bridge(config?: BridgePluginConfig): RelaiPlugin;
140
- declare function freeTier(config: FreeTierPluginConfig): RelaiPlugin;
142
+ /**
143
+ * Extended plugin interface with data export for free tier.
144
+ */
145
+ interface FreeTierPlugin extends RelaiPlugin {
146
+ /** Export all in-memory usage data (local mode only). Returns null when using cloud mode. */
147
+ getUsageData(): FreeTierUsageExport | null;
148
+ /** Whether plugin is running in local (in-memory) or cloud (RelAI backend) mode. */
149
+ readonly mode: 'local' | 'cloud';
150
+ }
151
+ interface FreeTierUsageExport {
152
+ mode: 'local';
153
+ config: {
154
+ perBuyerLimit: number;
155
+ resetPeriod: string;
156
+ globalCap: number | null;
157
+ paths: string[];
158
+ };
159
+ /** Per-buyer usage entries */
160
+ usage: Array<{
161
+ buyerId: string;
162
+ path: string;
163
+ count: number;
164
+ periodStart: string;
165
+ lastCall: string;
166
+ }>;
167
+ globalCount: number;
168
+ exportedAt: string;
169
+ }
170
+ declare function freeTier(config: FreeTierPluginConfig): FreeTierPlugin;
141
171
 
142
172
  interface RelaiServerConfig {
143
173
  /** Network to accept payments on */
@@ -279,4 +309,4 @@ declare class Relai {
279
309
  protect(options: ProtectOptions): (req: any, res: any, next: any) => Promise<any>;
280
310
  }
281
311
 
282
- export { type BridgePluginConfig as B, type DynamicPrice as D, type FreeTierPluginConfig as F, type ProtectOptions as P, Relai as R, type SettleResult as S, type RelaiServerConfig as a, type PaymentInfo as b, type StripePayTo as c, type RelaiIntegritasFlow as d, type RelaiIntegritasOptions as e, type RelaiPlugin as f, type PluginContext as g, type PluginResult as h, bridge as i, freeTier as j, stripePayTo as s };
312
+ export { type BridgePluginConfig as B, type DynamicPrice as D, type FreeTierPluginConfig as F, type ProtectOptions as P, Relai as R, type SettleResult as S, type RelaiServerConfig as a, type PaymentInfo as b, type StripePayTo as c, type RelaiIntegritasFlow as d, type RelaiIntegritasOptions as e, type RelaiPlugin as f, type PluginContext as g, type PluginResult as h, bridge as i, type FreeTierPlugin as j, type FreeTierUsageExport as k, freeTier as l, stripePayTo as s };
package/dist/server.d.cts CHANGED
@@ -1,2 +1,2 @@
1
1
  import './types-Y9ni5XwY.cjs';
2
- export { D as DynamicPrice, b as PaymentInfo, P as ProtectOptions, R as Relai, d as RelaiIntegritasFlow, e as RelaiIntegritasOptions, a as RelaiServerConfig, S as SettleResult, c as StripePayTo, R as default, s as stripePayTo } from './server-DPYBh7fy.cjs';
2
+ export { D as DynamicPrice, b as PaymentInfo, P as ProtectOptions, R as Relai, d as RelaiIntegritasFlow, e as RelaiIntegritasOptions, a as RelaiServerConfig, S as SettleResult, c as StripePayTo, R as default, s as stripePayTo } from './server-CyfEHW9D.cjs';
package/dist/server.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import './types-Y9ni5XwY.js';
2
- export { D as DynamicPrice, b as PaymentInfo, P as ProtectOptions, R as Relai, d as RelaiIntegritasFlow, e as RelaiIntegritasOptions, a as RelaiServerConfig, S as SettleResult, c as StripePayTo, R as default, s as stripePayTo } from './server-DJGM7dFH.js';
2
+ export { D as DynamicPrice, b as PaymentInfo, P as ProtectOptions, R as Relai, d as RelaiIntegritasFlow, e as RelaiIntegritasOptions, a as RelaiServerConfig, S as SettleResult, c as StripePayTo, R as default, s as stripePayTo } from './server-CaSmhDnd.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relai-fi/x402",
3
- "version": "0.5.37",
3
+ "version": "0.5.39",
4
4
  "description": "Unified x402 payment SDK for Solana, Base, Avalanche, SKALE Base, SKALE BITE, Polygon, and Ethereum. Automatic 402 handling with zero gas fees.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",