@mixrpay/agent-sdk 0.9.1 → 0.9.2
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.cjs +5 -10
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1929,8 +1929,8 @@ var AgentWallet = class {
|
|
|
1929
1929
|
* ```typescript
|
|
1930
1930
|
* const session = await wallet.getOrCreateSession({
|
|
1931
1931
|
* merchantPublicKey: 'pk_live_abc123...',
|
|
1932
|
-
* spendingLimitUsd:
|
|
1933
|
-
* durationDays:
|
|
1932
|
+
* spendingLimitUsd: 100,
|
|
1933
|
+
* durationDays: 30,
|
|
1934
1934
|
* });
|
|
1935
1935
|
*
|
|
1936
1936
|
* console.log(`Session active: $${session.remainingLimitUsd} remaining`);
|
|
@@ -1938,7 +1938,7 @@ var AgentWallet = class {
|
|
|
1938
1938
|
*/
|
|
1939
1939
|
async getOrCreateSession(options) {
|
|
1940
1940
|
this.logger.debug("getOrCreateSession called", options);
|
|
1941
|
-
const { merchantPublicKey, spendingLimitUsd
|
|
1941
|
+
const { merchantPublicKey, spendingLimitUsd, durationDays } = options;
|
|
1942
1942
|
try {
|
|
1943
1943
|
const existingSession = await this.getSessionByMerchant(merchantPublicKey);
|
|
1944
1944
|
if (existingSession && existingSession.status === "active") {
|
|
@@ -2252,10 +2252,7 @@ var AgentWallet = class {
|
|
|
2252
2252
|
throw new SpendingLimitExceededError("client_max", this.maxPaymentUsd, priceUsd);
|
|
2253
2253
|
}
|
|
2254
2254
|
const session = await this.getOrCreateSession({
|
|
2255
|
-
merchantPublicKey
|
|
2256
|
-
spendingLimitUsd: 25,
|
|
2257
|
-
// Default limit
|
|
2258
|
-
durationDays: 7
|
|
2255
|
+
merchantPublicKey
|
|
2259
2256
|
});
|
|
2260
2257
|
const headers = {
|
|
2261
2258
|
"Content-Type": "application/json",
|
|
@@ -2300,9 +2297,7 @@ var AgentWallet = class {
|
|
|
2300
2297
|
if (errorCode === "session_expired") {
|
|
2301
2298
|
this.logger.info("Session expired, creating new one...");
|
|
2302
2299
|
const newSession = await this.getOrCreateSession({
|
|
2303
|
-
merchantPublicKey
|
|
2304
|
-
spendingLimitUsd: 25,
|
|
2305
|
-
durationDays: 7
|
|
2300
|
+
merchantPublicKey
|
|
2306
2301
|
});
|
|
2307
2302
|
headers["X-Mixr-Session"] = newSession.id;
|
|
2308
2303
|
return fetch(url, {
|
package/dist/index.d.cts
CHANGED
|
@@ -233,12 +233,12 @@ interface CreateSessionOptions {
|
|
|
233
233
|
merchantPublicKey: string;
|
|
234
234
|
/**
|
|
235
235
|
* Maximum spending limit for this session in USD.
|
|
236
|
-
*
|
|
236
|
+
* If omitted, the server applies its own default.
|
|
237
237
|
*/
|
|
238
238
|
spendingLimitUsd?: number;
|
|
239
239
|
/**
|
|
240
240
|
* Number of days this session should be valid.
|
|
241
|
-
*
|
|
241
|
+
* If omitted, the server applies its own default.
|
|
242
242
|
*/
|
|
243
243
|
durationDays?: number;
|
|
244
244
|
}
|
|
@@ -1201,8 +1201,8 @@ declare class AgentWallet {
|
|
|
1201
1201
|
* ```typescript
|
|
1202
1202
|
* const session = await wallet.getOrCreateSession({
|
|
1203
1203
|
* merchantPublicKey: 'pk_live_abc123...',
|
|
1204
|
-
* spendingLimitUsd:
|
|
1205
|
-
* durationDays:
|
|
1204
|
+
* spendingLimitUsd: 100,
|
|
1205
|
+
* durationDays: 30,
|
|
1206
1206
|
* });
|
|
1207
1207
|
*
|
|
1208
1208
|
* console.log(`Session active: $${session.remainingLimitUsd} remaining`);
|
package/dist/index.d.ts
CHANGED
|
@@ -233,12 +233,12 @@ interface CreateSessionOptions {
|
|
|
233
233
|
merchantPublicKey: string;
|
|
234
234
|
/**
|
|
235
235
|
* Maximum spending limit for this session in USD.
|
|
236
|
-
*
|
|
236
|
+
* If omitted, the server applies its own default.
|
|
237
237
|
*/
|
|
238
238
|
spendingLimitUsd?: number;
|
|
239
239
|
/**
|
|
240
240
|
* Number of days this session should be valid.
|
|
241
|
-
*
|
|
241
|
+
* If omitted, the server applies its own default.
|
|
242
242
|
*/
|
|
243
243
|
durationDays?: number;
|
|
244
244
|
}
|
|
@@ -1201,8 +1201,8 @@ declare class AgentWallet {
|
|
|
1201
1201
|
* ```typescript
|
|
1202
1202
|
* const session = await wallet.getOrCreateSession({
|
|
1203
1203
|
* merchantPublicKey: 'pk_live_abc123...',
|
|
1204
|
-
* spendingLimitUsd:
|
|
1205
|
-
* durationDays:
|
|
1204
|
+
* spendingLimitUsd: 100,
|
|
1205
|
+
* durationDays: 30,
|
|
1206
1206
|
* });
|
|
1207
1207
|
*
|
|
1208
1208
|
* console.log(`Session active: $${session.remainingLimitUsd} remaining`);
|
package/dist/index.js
CHANGED
|
@@ -1927,8 +1927,8 @@ var AgentWallet = class {
|
|
|
1927
1927
|
* ```typescript
|
|
1928
1928
|
* const session = await wallet.getOrCreateSession({
|
|
1929
1929
|
* merchantPublicKey: 'pk_live_abc123...',
|
|
1930
|
-
* spendingLimitUsd:
|
|
1931
|
-
* durationDays:
|
|
1930
|
+
* spendingLimitUsd: 100,
|
|
1931
|
+
* durationDays: 30,
|
|
1932
1932
|
* });
|
|
1933
1933
|
*
|
|
1934
1934
|
* console.log(`Session active: $${session.remainingLimitUsd} remaining`);
|
|
@@ -1936,7 +1936,7 @@ var AgentWallet = class {
|
|
|
1936
1936
|
*/
|
|
1937
1937
|
async getOrCreateSession(options) {
|
|
1938
1938
|
this.logger.debug("getOrCreateSession called", options);
|
|
1939
|
-
const { merchantPublicKey, spendingLimitUsd
|
|
1939
|
+
const { merchantPublicKey, spendingLimitUsd, durationDays } = options;
|
|
1940
1940
|
try {
|
|
1941
1941
|
const existingSession = await this.getSessionByMerchant(merchantPublicKey);
|
|
1942
1942
|
if (existingSession && existingSession.status === "active") {
|
|
@@ -2250,10 +2250,7 @@ var AgentWallet = class {
|
|
|
2250
2250
|
throw new SpendingLimitExceededError("client_max", this.maxPaymentUsd, priceUsd);
|
|
2251
2251
|
}
|
|
2252
2252
|
const session = await this.getOrCreateSession({
|
|
2253
|
-
merchantPublicKey
|
|
2254
|
-
spendingLimitUsd: 25,
|
|
2255
|
-
// Default limit
|
|
2256
|
-
durationDays: 7
|
|
2253
|
+
merchantPublicKey
|
|
2257
2254
|
});
|
|
2258
2255
|
const headers = {
|
|
2259
2256
|
"Content-Type": "application/json",
|
|
@@ -2298,9 +2295,7 @@ var AgentWallet = class {
|
|
|
2298
2295
|
if (errorCode === "session_expired") {
|
|
2299
2296
|
this.logger.info("Session expired, creating new one...");
|
|
2300
2297
|
const newSession = await this.getOrCreateSession({
|
|
2301
|
-
merchantPublicKey
|
|
2302
|
-
spendingLimitUsd: 25,
|
|
2303
|
-
durationDays: 7
|
|
2298
|
+
merchantPublicKey
|
|
2304
2299
|
});
|
|
2305
2300
|
headers["X-Mixr-Session"] = newSession.id;
|
|
2306
2301
|
return fetch(url, {
|