@mixrpay/agent-sdk 0.7.0 → 0.8.1
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.
Potentially problematic release.
This version of @mixrpay/agent-sdk might be problematic. Click here for more details.
- package/dist/index.cjs +89 -4
- package/dist/index.d.cts +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +89 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -525,7 +525,7 @@ function getAmountUsd(requirements) {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
// src/agent-wallet.ts
|
|
528
|
-
var SDK_VERSION = "0.
|
|
528
|
+
var SDK_VERSION = "0.8.1";
|
|
529
529
|
var DEFAULT_BASE_URL = process.env.MIXRPAY_BASE_URL || "https://www.mixrpay.com";
|
|
530
530
|
var DEFAULT_TIMEOUT = 3e4;
|
|
531
531
|
var NETWORKS = {
|
|
@@ -1141,6 +1141,91 @@ var AgentWallet = class {
|
|
|
1141
1141
|
remainingBalanceUsd: data.remaining_balance_usd
|
|
1142
1142
|
};
|
|
1143
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Claim an agent invite code to receive a session key for the inviter's wallet.
|
|
1146
|
+
*
|
|
1147
|
+
* This allows an agent to get a pre-configured session key from a human wallet owner
|
|
1148
|
+
* without needing to register their own wallet or fund it. The human sets the budget
|
|
1149
|
+
* limits and merchant whitelist when creating the invite.
|
|
1150
|
+
*
|
|
1151
|
+
* @param options - Claim invite options including the invite code and agent's private key
|
|
1152
|
+
* @returns Claim result with the new session key
|
|
1153
|
+
* @throws {MixrPayError} If claiming fails (e.g., invalid code, already claimed, expired)
|
|
1154
|
+
*
|
|
1155
|
+
* @example
|
|
1156
|
+
* ```typescript
|
|
1157
|
+
* // Human creates invite at their dashboard, shares code "mixr-abc123"
|
|
1158
|
+
*
|
|
1159
|
+
* const result = await AgentWallet.claimInvite({
|
|
1160
|
+
* inviteCode: 'mixr-abc123',
|
|
1161
|
+
* privateKey: process.env.AGENT_WALLET_KEY as `0x${string}`,
|
|
1162
|
+
* });
|
|
1163
|
+
*
|
|
1164
|
+
* console.log(`Got session key: ${result.sessionKey}`);
|
|
1165
|
+
* console.log(`Budget: $${result.limits.budgetUsd}/${result.limits.budgetPeriod}`);
|
|
1166
|
+
* console.log(`Invited by: ${result.inviterName}`);
|
|
1167
|
+
*
|
|
1168
|
+
* // Use the session key to make payments
|
|
1169
|
+
* const wallet = new AgentWallet({ sessionKey: result.sessionKey });
|
|
1170
|
+
* const response = await wallet.fetch('https://api.example.com/endpoint');
|
|
1171
|
+
* ```
|
|
1172
|
+
*/
|
|
1173
|
+
static async claimInvite(options) {
|
|
1174
|
+
const { inviteCode, privateKey } = options;
|
|
1175
|
+
const baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
1176
|
+
const account = (0, import_accounts2.privateKeyToAccount)(privateKey);
|
|
1177
|
+
const walletAddress = account.address;
|
|
1178
|
+
const challengeResponse = await fetch(
|
|
1179
|
+
`${baseUrl}/api/v1/agent/challenge?wallet=${walletAddress}&action=claim-invite`
|
|
1180
|
+
);
|
|
1181
|
+
if (!challengeResponse.ok) {
|
|
1182
|
+
const error = await challengeResponse.json().catch(() => ({}));
|
|
1183
|
+
throw new MixrPayError(error.error || `Failed to get challenge: ${challengeResponse.status}`);
|
|
1184
|
+
}
|
|
1185
|
+
const { challenge, message } = await challengeResponse.json();
|
|
1186
|
+
const signature = await (0, import_accounts2.signMessage)({ message, privateKey });
|
|
1187
|
+
const claimResponse = await fetch(`${baseUrl}/api/v1/agent/claim-invite`, {
|
|
1188
|
+
method: "POST",
|
|
1189
|
+
headers: { "Content-Type": "application/json" },
|
|
1190
|
+
body: JSON.stringify({
|
|
1191
|
+
invite_code: inviteCode,
|
|
1192
|
+
challenge,
|
|
1193
|
+
agent_wallet_address: walletAddress,
|
|
1194
|
+
signature
|
|
1195
|
+
})
|
|
1196
|
+
});
|
|
1197
|
+
if (!claimResponse.ok) {
|
|
1198
|
+
const error = await claimResponse.json().catch(() => ({}));
|
|
1199
|
+
const errorMessage = error.error || `Failed to claim invite: ${claimResponse.status}`;
|
|
1200
|
+
let helpText = "";
|
|
1201
|
+
if (claimResponse.status === 404) {
|
|
1202
|
+
helpText = " The invite code may be invalid or misspelled.";
|
|
1203
|
+
} else if (claimResponse.status === 400) {
|
|
1204
|
+
if (errorMessage.includes("already claimed")) {
|
|
1205
|
+
helpText = " This invite has already been used by another agent.";
|
|
1206
|
+
} else if (errorMessage.includes("expired")) {
|
|
1207
|
+
helpText = " Ask the wallet owner to create a new invite.";
|
|
1208
|
+
} else if (errorMessage.includes("revoked")) {
|
|
1209
|
+
helpText = " The wallet owner has revoked this invite.";
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
throw new MixrPayError(`${errorMessage}${helpText}`);
|
|
1213
|
+
}
|
|
1214
|
+
const data = await claimResponse.json();
|
|
1215
|
+
return {
|
|
1216
|
+
sessionKey: data.session_key,
|
|
1217
|
+
address: data.address,
|
|
1218
|
+
sessionKeyId: data.session_key_id,
|
|
1219
|
+
expiresAt: new Date(data.expires_at),
|
|
1220
|
+
limits: {
|
|
1221
|
+
budgetUsd: data.limits.budget_usd,
|
|
1222
|
+
budgetPeriod: data.limits.budget_period,
|
|
1223
|
+
maxPerTxUsd: data.limits.max_per_tx_usd
|
|
1224
|
+
},
|
|
1225
|
+
allowedMerchants: data.allowed_merchants || [],
|
|
1226
|
+
inviterName: data.inviter_name || "Anonymous"
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1144
1229
|
// ===========================================================================
|
|
1145
1230
|
// Core Methods
|
|
1146
1231
|
// ===========================================================================
|
|
@@ -1364,7 +1449,7 @@ var AgentWallet = class {
|
|
|
1364
1449
|
async getBalance() {
|
|
1365
1450
|
this.logger.debug("Fetching wallet balance...");
|
|
1366
1451
|
try {
|
|
1367
|
-
const response = await fetch(`${this.baseUrl}/v1/wallet/balance`, {
|
|
1452
|
+
const response = await fetch(`${this.baseUrl}/api/v1/wallet/balance`, {
|
|
1368
1453
|
headers: {
|
|
1369
1454
|
"X-Session-Key": this.sessionKey.address
|
|
1370
1455
|
}
|
|
@@ -1431,7 +1516,7 @@ var AgentWallet = class {
|
|
|
1431
1516
|
}
|
|
1432
1517
|
this.logger.debug("Fetching session key info...");
|
|
1433
1518
|
try {
|
|
1434
|
-
const response = await fetch(`${this.baseUrl}/v1/session-key/info`, {
|
|
1519
|
+
const response = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
|
|
1435
1520
|
headers: {
|
|
1436
1521
|
"X-Session-Key": this.sessionKey.address
|
|
1437
1522
|
}
|
|
@@ -1486,7 +1571,7 @@ var AgentWallet = class {
|
|
|
1486
1571
|
async getSpendingStats() {
|
|
1487
1572
|
this.logger.debug("Fetching spending stats...");
|
|
1488
1573
|
try {
|
|
1489
|
-
const response = await fetch(`${this.baseUrl}/v1/session-key/stats`, {
|
|
1574
|
+
const response = await fetch(`${this.baseUrl}/api/v1/session-key/stats`, {
|
|
1490
1575
|
headers: {
|
|
1491
1576
|
"X-Session-Key": this.sessionKey.address
|
|
1492
1577
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -380,7 +380,7 @@ interface SessionStats {
|
|
|
380
380
|
*/
|
|
381
381
|
|
|
382
382
|
/** Current SDK version */
|
|
383
|
-
declare const SDK_VERSION = "0.
|
|
383
|
+
declare const SDK_VERSION = "0.8.1";
|
|
384
384
|
/** Supported networks */
|
|
385
385
|
declare const NETWORKS: {
|
|
386
386
|
readonly BASE_MAINNET: {
|
|
@@ -511,6 +511,43 @@ interface AgentWithdrawResult {
|
|
|
511
511
|
/** Remaining balance after withdrawal */
|
|
512
512
|
remainingBalanceUsd: number;
|
|
513
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Options for claiming an agent invite
|
|
516
|
+
*/
|
|
517
|
+
interface AgentClaimInviteOptions {
|
|
518
|
+
/** The invite code provided by the human wallet owner (e.g., "mixr-abc123") */
|
|
519
|
+
inviteCode: string;
|
|
520
|
+
/** The agent's external wallet private key (used for signing, NOT transmitted) */
|
|
521
|
+
privateKey: `0x${string}`;
|
|
522
|
+
/** MixrPay API base URL (default: https://www.mixrpay.com) */
|
|
523
|
+
baseUrl?: string;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Result from claiming an agent invite
|
|
527
|
+
*/
|
|
528
|
+
interface AgentClaimInviteResult {
|
|
529
|
+
/** The session key in sk_live_{hex} format - STORE SECURELY! */
|
|
530
|
+
sessionKey: string;
|
|
531
|
+
/** The derived public address of the session key */
|
|
532
|
+
address: string;
|
|
533
|
+
/** Session key database ID */
|
|
534
|
+
sessionKeyId: string;
|
|
535
|
+
/** When the session key expires */
|
|
536
|
+
expiresAt: Date;
|
|
537
|
+
/** Budget limits set by the inviter */
|
|
538
|
+
limits: {
|
|
539
|
+
/** Total budget in USD */
|
|
540
|
+
budgetUsd: number;
|
|
541
|
+
/** Budget period: 'daily', 'monthly', or 'total' */
|
|
542
|
+
budgetPeriod: string;
|
|
543
|
+
/** Maximum per transaction in USD (null = no limit) */
|
|
544
|
+
maxPerTxUsd: number | null;
|
|
545
|
+
};
|
|
546
|
+
/** Whitelisted merchants/tools (empty = allow all) */
|
|
547
|
+
allowedMerchants: string[];
|
|
548
|
+
/** Name of the person who created the invite */
|
|
549
|
+
inviterName: string;
|
|
550
|
+
}
|
|
514
551
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
515
552
|
/**
|
|
516
553
|
* A wallet wrapper for AI agents that handles x402 payments automatically.
|
|
@@ -760,6 +797,36 @@ declare class AgentWallet {
|
|
|
760
797
|
* ```
|
|
761
798
|
*/
|
|
762
799
|
static withdraw(options: AgentWithdrawOptions): Promise<AgentWithdrawResult>;
|
|
800
|
+
/**
|
|
801
|
+
* Claim an agent invite code to receive a session key for the inviter's wallet.
|
|
802
|
+
*
|
|
803
|
+
* This allows an agent to get a pre-configured session key from a human wallet owner
|
|
804
|
+
* without needing to register their own wallet or fund it. The human sets the budget
|
|
805
|
+
* limits and merchant whitelist when creating the invite.
|
|
806
|
+
*
|
|
807
|
+
* @param options - Claim invite options including the invite code and agent's private key
|
|
808
|
+
* @returns Claim result with the new session key
|
|
809
|
+
* @throws {MixrPayError} If claiming fails (e.g., invalid code, already claimed, expired)
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* ```typescript
|
|
813
|
+
* // Human creates invite at their dashboard, shares code "mixr-abc123"
|
|
814
|
+
*
|
|
815
|
+
* const result = await AgentWallet.claimInvite({
|
|
816
|
+
* inviteCode: 'mixr-abc123',
|
|
817
|
+
* privateKey: process.env.AGENT_WALLET_KEY as `0x${string}`,
|
|
818
|
+
* });
|
|
819
|
+
*
|
|
820
|
+
* console.log(`Got session key: ${result.sessionKey}`);
|
|
821
|
+
* console.log(`Budget: $${result.limits.budgetUsd}/${result.limits.budgetPeriod}`);
|
|
822
|
+
* console.log(`Invited by: ${result.inviterName}`);
|
|
823
|
+
*
|
|
824
|
+
* // Use the session key to make payments
|
|
825
|
+
* const wallet = new AgentWallet({ sessionKey: result.sessionKey });
|
|
826
|
+
* const response = await wallet.fetch('https://api.example.com/endpoint');
|
|
827
|
+
* ```
|
|
828
|
+
*/
|
|
829
|
+
static claimInvite(options: AgentClaimInviteOptions): Promise<AgentClaimInviteResult>;
|
|
763
830
|
/**
|
|
764
831
|
* Make an HTTP request, automatically handling x402 payment if required.
|
|
765
832
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -380,7 +380,7 @@ interface SessionStats {
|
|
|
380
380
|
*/
|
|
381
381
|
|
|
382
382
|
/** Current SDK version */
|
|
383
|
-
declare const SDK_VERSION = "0.
|
|
383
|
+
declare const SDK_VERSION = "0.8.1";
|
|
384
384
|
/** Supported networks */
|
|
385
385
|
declare const NETWORKS: {
|
|
386
386
|
readonly BASE_MAINNET: {
|
|
@@ -511,6 +511,43 @@ interface AgentWithdrawResult {
|
|
|
511
511
|
/** Remaining balance after withdrawal */
|
|
512
512
|
remainingBalanceUsd: number;
|
|
513
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Options for claiming an agent invite
|
|
516
|
+
*/
|
|
517
|
+
interface AgentClaimInviteOptions {
|
|
518
|
+
/** The invite code provided by the human wallet owner (e.g., "mixr-abc123") */
|
|
519
|
+
inviteCode: string;
|
|
520
|
+
/** The agent's external wallet private key (used for signing, NOT transmitted) */
|
|
521
|
+
privateKey: `0x${string}`;
|
|
522
|
+
/** MixrPay API base URL (default: https://www.mixrpay.com) */
|
|
523
|
+
baseUrl?: string;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Result from claiming an agent invite
|
|
527
|
+
*/
|
|
528
|
+
interface AgentClaimInviteResult {
|
|
529
|
+
/** The session key in sk_live_{hex} format - STORE SECURELY! */
|
|
530
|
+
sessionKey: string;
|
|
531
|
+
/** The derived public address of the session key */
|
|
532
|
+
address: string;
|
|
533
|
+
/** Session key database ID */
|
|
534
|
+
sessionKeyId: string;
|
|
535
|
+
/** When the session key expires */
|
|
536
|
+
expiresAt: Date;
|
|
537
|
+
/** Budget limits set by the inviter */
|
|
538
|
+
limits: {
|
|
539
|
+
/** Total budget in USD */
|
|
540
|
+
budgetUsd: number;
|
|
541
|
+
/** Budget period: 'daily', 'monthly', or 'total' */
|
|
542
|
+
budgetPeriod: string;
|
|
543
|
+
/** Maximum per transaction in USD (null = no limit) */
|
|
544
|
+
maxPerTxUsd: number | null;
|
|
545
|
+
};
|
|
546
|
+
/** Whitelisted merchants/tools (empty = allow all) */
|
|
547
|
+
allowedMerchants: string[];
|
|
548
|
+
/** Name of the person who created the invite */
|
|
549
|
+
inviterName: string;
|
|
550
|
+
}
|
|
514
551
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
515
552
|
/**
|
|
516
553
|
* A wallet wrapper for AI agents that handles x402 payments automatically.
|
|
@@ -760,6 +797,36 @@ declare class AgentWallet {
|
|
|
760
797
|
* ```
|
|
761
798
|
*/
|
|
762
799
|
static withdraw(options: AgentWithdrawOptions): Promise<AgentWithdrawResult>;
|
|
800
|
+
/**
|
|
801
|
+
* Claim an agent invite code to receive a session key for the inviter's wallet.
|
|
802
|
+
*
|
|
803
|
+
* This allows an agent to get a pre-configured session key from a human wallet owner
|
|
804
|
+
* without needing to register their own wallet or fund it. The human sets the budget
|
|
805
|
+
* limits and merchant whitelist when creating the invite.
|
|
806
|
+
*
|
|
807
|
+
* @param options - Claim invite options including the invite code and agent's private key
|
|
808
|
+
* @returns Claim result with the new session key
|
|
809
|
+
* @throws {MixrPayError} If claiming fails (e.g., invalid code, already claimed, expired)
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* ```typescript
|
|
813
|
+
* // Human creates invite at their dashboard, shares code "mixr-abc123"
|
|
814
|
+
*
|
|
815
|
+
* const result = await AgentWallet.claimInvite({
|
|
816
|
+
* inviteCode: 'mixr-abc123',
|
|
817
|
+
* privateKey: process.env.AGENT_WALLET_KEY as `0x${string}`,
|
|
818
|
+
* });
|
|
819
|
+
*
|
|
820
|
+
* console.log(`Got session key: ${result.sessionKey}`);
|
|
821
|
+
* console.log(`Budget: $${result.limits.budgetUsd}/${result.limits.budgetPeriod}`);
|
|
822
|
+
* console.log(`Invited by: ${result.inviterName}`);
|
|
823
|
+
*
|
|
824
|
+
* // Use the session key to make payments
|
|
825
|
+
* const wallet = new AgentWallet({ sessionKey: result.sessionKey });
|
|
826
|
+
* const response = await wallet.fetch('https://api.example.com/endpoint');
|
|
827
|
+
* ```
|
|
828
|
+
*/
|
|
829
|
+
static claimInvite(options: AgentClaimInviteOptions): Promise<AgentClaimInviteResult>;
|
|
763
830
|
/**
|
|
764
831
|
* Make an HTTP request, automatically handling x402 payment if required.
|
|
765
832
|
*
|
package/dist/index.js
CHANGED
|
@@ -488,7 +488,7 @@ function getAmountUsd(requirements) {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
// src/agent-wallet.ts
|
|
491
|
-
var SDK_VERSION = "0.
|
|
491
|
+
var SDK_VERSION = "0.8.1";
|
|
492
492
|
var DEFAULT_BASE_URL = process.env.MIXRPAY_BASE_URL || "https://www.mixrpay.com";
|
|
493
493
|
var DEFAULT_TIMEOUT = 3e4;
|
|
494
494
|
var NETWORKS = {
|
|
@@ -1104,6 +1104,91 @@ var AgentWallet = class {
|
|
|
1104
1104
|
remainingBalanceUsd: data.remaining_balance_usd
|
|
1105
1105
|
};
|
|
1106
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Claim an agent invite code to receive a session key for the inviter's wallet.
|
|
1109
|
+
*
|
|
1110
|
+
* This allows an agent to get a pre-configured session key from a human wallet owner
|
|
1111
|
+
* without needing to register their own wallet or fund it. The human sets the budget
|
|
1112
|
+
* limits and merchant whitelist when creating the invite.
|
|
1113
|
+
*
|
|
1114
|
+
* @param options - Claim invite options including the invite code and agent's private key
|
|
1115
|
+
* @returns Claim result with the new session key
|
|
1116
|
+
* @throws {MixrPayError} If claiming fails (e.g., invalid code, already claimed, expired)
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
* ```typescript
|
|
1120
|
+
* // Human creates invite at their dashboard, shares code "mixr-abc123"
|
|
1121
|
+
*
|
|
1122
|
+
* const result = await AgentWallet.claimInvite({
|
|
1123
|
+
* inviteCode: 'mixr-abc123',
|
|
1124
|
+
* privateKey: process.env.AGENT_WALLET_KEY as `0x${string}`,
|
|
1125
|
+
* });
|
|
1126
|
+
*
|
|
1127
|
+
* console.log(`Got session key: ${result.sessionKey}`);
|
|
1128
|
+
* console.log(`Budget: $${result.limits.budgetUsd}/${result.limits.budgetPeriod}`);
|
|
1129
|
+
* console.log(`Invited by: ${result.inviterName}`);
|
|
1130
|
+
*
|
|
1131
|
+
* // Use the session key to make payments
|
|
1132
|
+
* const wallet = new AgentWallet({ sessionKey: result.sessionKey });
|
|
1133
|
+
* const response = await wallet.fetch('https://api.example.com/endpoint');
|
|
1134
|
+
* ```
|
|
1135
|
+
*/
|
|
1136
|
+
static async claimInvite(options) {
|
|
1137
|
+
const { inviteCode, privateKey } = options;
|
|
1138
|
+
const baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
1139
|
+
const account = privateKeyToAccount2(privateKey);
|
|
1140
|
+
const walletAddress = account.address;
|
|
1141
|
+
const challengeResponse = await fetch(
|
|
1142
|
+
`${baseUrl}/api/v1/agent/challenge?wallet=${walletAddress}&action=claim-invite`
|
|
1143
|
+
);
|
|
1144
|
+
if (!challengeResponse.ok) {
|
|
1145
|
+
const error = await challengeResponse.json().catch(() => ({}));
|
|
1146
|
+
throw new MixrPayError(error.error || `Failed to get challenge: ${challengeResponse.status}`);
|
|
1147
|
+
}
|
|
1148
|
+
const { challenge, message } = await challengeResponse.json();
|
|
1149
|
+
const signature = await signMessage({ message, privateKey });
|
|
1150
|
+
const claimResponse = await fetch(`${baseUrl}/api/v1/agent/claim-invite`, {
|
|
1151
|
+
method: "POST",
|
|
1152
|
+
headers: { "Content-Type": "application/json" },
|
|
1153
|
+
body: JSON.stringify({
|
|
1154
|
+
invite_code: inviteCode,
|
|
1155
|
+
challenge,
|
|
1156
|
+
agent_wallet_address: walletAddress,
|
|
1157
|
+
signature
|
|
1158
|
+
})
|
|
1159
|
+
});
|
|
1160
|
+
if (!claimResponse.ok) {
|
|
1161
|
+
const error = await claimResponse.json().catch(() => ({}));
|
|
1162
|
+
const errorMessage = error.error || `Failed to claim invite: ${claimResponse.status}`;
|
|
1163
|
+
let helpText = "";
|
|
1164
|
+
if (claimResponse.status === 404) {
|
|
1165
|
+
helpText = " The invite code may be invalid or misspelled.";
|
|
1166
|
+
} else if (claimResponse.status === 400) {
|
|
1167
|
+
if (errorMessage.includes("already claimed")) {
|
|
1168
|
+
helpText = " This invite has already been used by another agent.";
|
|
1169
|
+
} else if (errorMessage.includes("expired")) {
|
|
1170
|
+
helpText = " Ask the wallet owner to create a new invite.";
|
|
1171
|
+
} else if (errorMessage.includes("revoked")) {
|
|
1172
|
+
helpText = " The wallet owner has revoked this invite.";
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
throw new MixrPayError(`${errorMessage}${helpText}`);
|
|
1176
|
+
}
|
|
1177
|
+
const data = await claimResponse.json();
|
|
1178
|
+
return {
|
|
1179
|
+
sessionKey: data.session_key,
|
|
1180
|
+
address: data.address,
|
|
1181
|
+
sessionKeyId: data.session_key_id,
|
|
1182
|
+
expiresAt: new Date(data.expires_at),
|
|
1183
|
+
limits: {
|
|
1184
|
+
budgetUsd: data.limits.budget_usd,
|
|
1185
|
+
budgetPeriod: data.limits.budget_period,
|
|
1186
|
+
maxPerTxUsd: data.limits.max_per_tx_usd
|
|
1187
|
+
},
|
|
1188
|
+
allowedMerchants: data.allowed_merchants || [],
|
|
1189
|
+
inviterName: data.inviter_name || "Anonymous"
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1107
1192
|
// ===========================================================================
|
|
1108
1193
|
// Core Methods
|
|
1109
1194
|
// ===========================================================================
|
|
@@ -1327,7 +1412,7 @@ var AgentWallet = class {
|
|
|
1327
1412
|
async getBalance() {
|
|
1328
1413
|
this.logger.debug("Fetching wallet balance...");
|
|
1329
1414
|
try {
|
|
1330
|
-
const response = await fetch(`${this.baseUrl}/v1/wallet/balance`, {
|
|
1415
|
+
const response = await fetch(`${this.baseUrl}/api/v1/wallet/balance`, {
|
|
1331
1416
|
headers: {
|
|
1332
1417
|
"X-Session-Key": this.sessionKey.address
|
|
1333
1418
|
}
|
|
@@ -1394,7 +1479,7 @@ var AgentWallet = class {
|
|
|
1394
1479
|
}
|
|
1395
1480
|
this.logger.debug("Fetching session key info...");
|
|
1396
1481
|
try {
|
|
1397
|
-
const response = await fetch(`${this.baseUrl}/v1/session-key/info`, {
|
|
1482
|
+
const response = await fetch(`${this.baseUrl}/api/v1/session-key/info`, {
|
|
1398
1483
|
headers: {
|
|
1399
1484
|
"X-Session-Key": this.sessionKey.address
|
|
1400
1485
|
}
|
|
@@ -1449,7 +1534,7 @@ var AgentWallet = class {
|
|
|
1449
1534
|
async getSpendingStats() {
|
|
1450
1535
|
this.logger.debug("Fetching spending stats...");
|
|
1451
1536
|
try {
|
|
1452
|
-
const response = await fetch(`${this.baseUrl}/v1/session-key/stats`, {
|
|
1537
|
+
const response = await fetch(`${this.baseUrl}/api/v1/session-key/stats`, {
|
|
1453
1538
|
headers: {
|
|
1454
1539
|
"X-Session-Key": this.sessionKey.address
|
|
1455
1540
|
}
|