@sardis/sdk 0.2.0
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/CHANGELOG.md +47 -0
- package/LICENSE +21 -0
- package/README.md +439 -0
- package/dist/browser/index.js +7049 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/sardis.umd.js +7071 -0
- package/dist/browser/sardis.umd.js.map +1 -0
- package/dist/cjs/client.js +644 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/demo.js +699 -0
- package/dist/cjs/demo.js.map +1 -0
- package/dist/cjs/errors.js +630 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +131 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/integrations/index.js +21 -0
- package/dist/cjs/integrations/index.js.map +1 -0
- package/dist/cjs/integrations/langchain.js +339 -0
- package/dist/cjs/integrations/langchain.js.map +1 -0
- package/dist/cjs/integrations/openai.js +505 -0
- package/dist/cjs/integrations/openai.js.map +1 -0
- package/dist/cjs/integrations/vercel-ai.js +198 -0
- package/dist/cjs/integrations/vercel-ai.js.map +1 -0
- package/dist/cjs/resources/a2a.js +158 -0
- package/dist/cjs/resources/a2a.js.map +1 -0
- package/dist/cjs/resources/agents.js +142 -0
- package/dist/cjs/resources/agents.js.map +1 -0
- package/dist/cjs/resources/base.js +124 -0
- package/dist/cjs/resources/base.js.map +1 -0
- package/dist/cjs/resources/cards.js +43 -0
- package/dist/cjs/resources/cards.js.map +1 -0
- package/dist/cjs/resources/holds.js +64 -0
- package/dist/cjs/resources/holds.js.map +1 -0
- package/dist/cjs/resources/index.js +31 -0
- package/dist/cjs/resources/index.js.map +1 -0
- package/dist/cjs/resources/ledger.js +43 -0
- package/dist/cjs/resources/ledger.js.map +1 -0
- package/dist/cjs/resources/marketplace.js +88 -0
- package/dist/cjs/resources/marketplace.js.map +1 -0
- package/dist/cjs/resources/payments.js +33 -0
- package/dist/cjs/resources/payments.js.map +1 -0
- package/dist/cjs/resources/policies.js +31 -0
- package/dist/cjs/resources/policies.js.map +1 -0
- package/dist/cjs/resources/transactions.js +37 -0
- package/dist/cjs/resources/transactions.js.map +1 -0
- package/dist/cjs/resources/ucp.js +133 -0
- package/dist/cjs/resources/ucp.js.map +1 -0
- package/dist/cjs/resources/wallets.js +109 -0
- package/dist/cjs/resources/wallets.js.map +1 -0
- package/dist/cjs/resources/webhooks.js +81 -0
- package/dist/cjs/resources/webhooks.js.map +1 -0
- package/dist/cjs/types.js +11 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/client.d.ts +419 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +637 -0
- package/dist/client.js.map +1 -0
- package/dist/demo.d.ts +335 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/demo.js +694 -0
- package/dist/demo.js.map +1 -0
- package/dist/errors.d.ts +522 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +612 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/index.d.ts +4 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +5 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/langchain.d.ts +68 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +335 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/integrations/openai.d.ts +97 -0
- package/dist/integrations/openai.d.ts.map +1 -0
- package/dist/integrations/openai.js +467 -0
- package/dist/integrations/openai.js.map +1 -0
- package/dist/integrations/vercel-ai.d.ts +180 -0
- package/dist/integrations/vercel-ai.d.ts.map +1 -0
- package/dist/integrations/vercel-ai.js +194 -0
- package/dist/integrations/vercel-ai.js.map +1 -0
- package/dist/resources/a2a.d.ts +254 -0
- package/dist/resources/a2a.d.ts.map +1 -0
- package/dist/resources/a2a.js +154 -0
- package/dist/resources/a2a.js.map +1 -0
- package/dist/resources/agents.d.ts +111 -0
- package/dist/resources/agents.d.ts.map +1 -0
- package/dist/resources/agents.js +138 -0
- package/dist/resources/agents.js.map +1 -0
- package/dist/resources/base.d.ts +115 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/base.js +120 -0
- package/dist/resources/base.js.map +1 -0
- package/dist/resources/cards.d.ts +19 -0
- package/dist/resources/cards.d.ts.map +1 -0
- package/dist/resources/cards.js +39 -0
- package/dist/resources/cards.js.map +1 -0
- package/dist/resources/holds.d.ts +44 -0
- package/dist/resources/holds.d.ts.map +1 -0
- package/dist/resources/holds.js +60 -0
- package/dist/resources/holds.js.map +1 -0
- package/dist/resources/index.d.ts +16 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +16 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/ledger.d.ts +38 -0
- package/dist/resources/ledger.d.ts.map +1 -0
- package/dist/resources/ledger.js +39 -0
- package/dist/resources/ledger.js.map +1 -0
- package/dist/resources/marketplace.d.ts +60 -0
- package/dist/resources/marketplace.d.ts.map +1 -0
- package/dist/resources/marketplace.js +84 -0
- package/dist/resources/marketplace.js.map +1 -0
- package/dist/resources/payments.d.ts +24 -0
- package/dist/resources/payments.d.ts.map +1 -0
- package/dist/resources/payments.js +29 -0
- package/dist/resources/payments.js.map +1 -0
- package/dist/resources/policies.d.ts +23 -0
- package/dist/resources/policies.d.ts.map +1 -0
- package/dist/resources/policies.js +27 -0
- package/dist/resources/policies.js.map +1 -0
- package/dist/resources/transactions.d.ts +32 -0
- package/dist/resources/transactions.d.ts.map +1 -0
- package/dist/resources/transactions.js +33 -0
- package/dist/resources/transactions.js.map +1 -0
- package/dist/resources/ucp.d.ts +218 -0
- package/dist/resources/ucp.d.ts.map +1 -0
- package/dist/resources/ucp.js +129 -0
- package/dist/resources/ucp.js.map +1 -0
- package/dist/resources/wallets.d.ts +71 -0
- package/dist/resources/wallets.d.ts.map +1 -0
- package/dist/resources/wallets.js +105 -0
- package/dist/resources/wallets.js.map +1 -0
- package/dist/resources/webhooks.d.ts +57 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +77 -0
- package/dist/resources/webhooks.js.map +1 -0
- package/dist/types.d.ts +1045 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cards Resource
|
|
4
|
+
*
|
|
5
|
+
* Virtual card issuance + simulated purchase demo flow.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CardsResource = void 0;
|
|
9
|
+
const base_js_1 = require("./base.js");
|
|
10
|
+
class CardsResource extends base_js_1.BaseResource {
|
|
11
|
+
async issue(input, options) {
|
|
12
|
+
return this._post('/api/v2/cards', input, options);
|
|
13
|
+
}
|
|
14
|
+
async list(wallet_id, options) {
|
|
15
|
+
const params = {};
|
|
16
|
+
if (wallet_id)
|
|
17
|
+
params.wallet_id = wallet_id;
|
|
18
|
+
return this._get('/api/v2/cards', params, options);
|
|
19
|
+
}
|
|
20
|
+
async get(card_id, options) {
|
|
21
|
+
return this._get(`/api/v2/cards/${card_id}`, undefined, options);
|
|
22
|
+
}
|
|
23
|
+
async freeze(card_id, options) {
|
|
24
|
+
return this._post(`/api/v2/cards/${card_id}/freeze`, {}, options);
|
|
25
|
+
}
|
|
26
|
+
async unfreeze(card_id, options) {
|
|
27
|
+
return this._post(`/api/v2/cards/${card_id}/unfreeze`, {}, options);
|
|
28
|
+
}
|
|
29
|
+
async cancel(card_id, options) {
|
|
30
|
+
await this._delete(`/api/v2/cards/${card_id}`, options);
|
|
31
|
+
}
|
|
32
|
+
async updateLimits(card_id, input, options) {
|
|
33
|
+
return this._patch(`/api/v2/cards/${card_id}/limits`, input, options);
|
|
34
|
+
}
|
|
35
|
+
async transactions(card_id, limit = 50, options) {
|
|
36
|
+
return this._get(`/api/v2/cards/${card_id}/transactions`, { limit }, options);
|
|
37
|
+
}
|
|
38
|
+
async simulatePurchase(card_id, input, options) {
|
|
39
|
+
return this._post(`/api/v2/cards/${card_id}/simulate-purchase`, input, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CardsResource = CardsResource;
|
|
43
|
+
//# sourceMappingURL=cards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cards.js","sourceRoot":"","sources":["../../../src/resources/cards.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAyC;AAWzC,MAAa,aAAc,SAAQ,sBAAY;IAC7C,KAAK,CAAC,KAAK,CAAC,KAAqB,EAAE,OAAwB;QACzD,OAAO,IAAI,CAAC,KAAK,CAAO,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,IAAI,CACR,SAAkB,EAClB,OAAwB;QAExB,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,IAAI,SAAS;YAAE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAS,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,IAAI,CAAO,iBAAiB,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,KAAK,CAAO,iBAAiB,OAAO,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,KAAK,CAAO,iBAAiB,OAAO,WAAW,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,OAAwB;QACpD,MAAM,IAAI,CAAC,OAAO,CAAO,iBAAiB,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,OAAe,EACf,KAA4B,EAC5B,OAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAO,iBAAiB,OAAO,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAAe,EAAE,QAAgB,EAAE,EAAE,OAAwB;QAC9E,OAAO,IAAI,CAAC,IAAI,CACd,iBAAiB,OAAO,eAAe,EACvC,EAAE,KAAK,EAAE,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,KAAgC,EAChC,OAAwB;QAExB,OAAO,IAAI,CAAC,KAAK,CACf,iBAAiB,OAAO,oBAAoB,EAC5C,KAAK,EACL,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAzDD,sCAyDC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Holds resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HoldsResource = void 0;
|
|
7
|
+
const base_js_1 = require("./base.js");
|
|
8
|
+
class HoldsResource extends base_js_1.BaseResource {
|
|
9
|
+
/**
|
|
10
|
+
* Create a hold (pre-authorization) on funds
|
|
11
|
+
*/
|
|
12
|
+
async create(input, options) {
|
|
13
|
+
return this._post('/api/v2/holds', input, options);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get a hold by ID
|
|
17
|
+
*
|
|
18
|
+
* @param holdId - The hold ID
|
|
19
|
+
* @param options - Request options (signal, timeout)
|
|
20
|
+
* @returns The hold object
|
|
21
|
+
*/
|
|
22
|
+
async get(holdId, options) {
|
|
23
|
+
return this._get(`/api/v2/holds/${holdId}`, undefined, options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get a hold by ID
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Use `get(holdId)` instead. This method will be removed in v1.0.0.
|
|
29
|
+
* @param holdId - The hold ID
|
|
30
|
+
* @returns The hold object
|
|
31
|
+
*/
|
|
32
|
+
async getById(holdId) {
|
|
33
|
+
return this.get(holdId);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Capture a hold (complete the payment)
|
|
37
|
+
*/
|
|
38
|
+
async capture(holdId, amount) {
|
|
39
|
+
const data = amount ? { amount } : {};
|
|
40
|
+
return this._post(`/api/v2/holds/${holdId}/capture`, data);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Void a hold (cancel without payment)
|
|
44
|
+
*/
|
|
45
|
+
async void(holdId) {
|
|
46
|
+
return this._post(`/api/v2/holds/${holdId}/void`, {});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* List all holds for a wallet
|
|
50
|
+
*/
|
|
51
|
+
async listByWallet(walletId) {
|
|
52
|
+
const response = await this._get(`/api/v2/holds/wallet/${walletId}`);
|
|
53
|
+
return response.holds || [];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* List all active holds
|
|
57
|
+
*/
|
|
58
|
+
async listActive() {
|
|
59
|
+
const response = await this._get('/api/v2/holds');
|
|
60
|
+
return response.holds || [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.HoldsResource = HoldsResource;
|
|
64
|
+
//# sourceMappingURL=holds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holds.js","sourceRoot":"","sources":["../../../src/resources/holds.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAyC;AAGzC,MAAa,aAAc,SAAQ,sBAAY;IAC7C;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB,EAAE,OAAwB;QAC3D,OAAO,IAAI,CAAC,KAAK,CAAqB,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,IAAI,CAAO,iBAAiB,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,MAAc;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,MAAe;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAO,iBAAiB,MAAM,UAAU,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,KAAK,CAAO,iBAAiB,MAAM,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAoB,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QACxF,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAoB,eAAe,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF;AA5DD,sCA4DC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Resource exports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.A2AResource = exports.UCPResource = exports.AgentsResource = exports.WalletsResource = exports.LedgerResource = exports.TransactionsResource = exports.MarketplaceResource = exports.WebhooksResource = exports.PoliciesResource = exports.CardsResource = exports.HoldsResource = exports.PaymentsResource = void 0;
|
|
7
|
+
var payments_js_1 = require("./payments.js");
|
|
8
|
+
Object.defineProperty(exports, "PaymentsResource", { enumerable: true, get: function () { return payments_js_1.PaymentsResource; } });
|
|
9
|
+
var holds_js_1 = require("./holds.js");
|
|
10
|
+
Object.defineProperty(exports, "HoldsResource", { enumerable: true, get: function () { return holds_js_1.HoldsResource; } });
|
|
11
|
+
var cards_js_1 = require("./cards.js");
|
|
12
|
+
Object.defineProperty(exports, "CardsResource", { enumerable: true, get: function () { return cards_js_1.CardsResource; } });
|
|
13
|
+
var policies_js_1 = require("./policies.js");
|
|
14
|
+
Object.defineProperty(exports, "PoliciesResource", { enumerable: true, get: function () { return policies_js_1.PoliciesResource; } });
|
|
15
|
+
var webhooks_js_1 = require("./webhooks.js");
|
|
16
|
+
Object.defineProperty(exports, "WebhooksResource", { enumerable: true, get: function () { return webhooks_js_1.WebhooksResource; } });
|
|
17
|
+
var marketplace_js_1 = require("./marketplace.js");
|
|
18
|
+
Object.defineProperty(exports, "MarketplaceResource", { enumerable: true, get: function () { return marketplace_js_1.MarketplaceResource; } });
|
|
19
|
+
var transactions_js_1 = require("./transactions.js");
|
|
20
|
+
Object.defineProperty(exports, "TransactionsResource", { enumerable: true, get: function () { return transactions_js_1.TransactionsResource; } });
|
|
21
|
+
var ledger_js_1 = require("./ledger.js");
|
|
22
|
+
Object.defineProperty(exports, "LedgerResource", { enumerable: true, get: function () { return ledger_js_1.LedgerResource; } });
|
|
23
|
+
var wallets_js_1 = require("./wallets.js");
|
|
24
|
+
Object.defineProperty(exports, "WalletsResource", { enumerable: true, get: function () { return wallets_js_1.WalletsResource; } });
|
|
25
|
+
var agents_js_1 = require("./agents.js");
|
|
26
|
+
Object.defineProperty(exports, "AgentsResource", { enumerable: true, get: function () { return agents_js_1.AgentsResource; } });
|
|
27
|
+
var ucp_js_1 = require("./ucp.js");
|
|
28
|
+
Object.defineProperty(exports, "UCPResource", { enumerable: true, get: function () { return ucp_js_1.UCPResource; } });
|
|
29
|
+
var a2a_js_1 = require("./a2a.js");
|
|
30
|
+
Object.defineProperty(exports, "A2AResource", { enumerable: true, get: function () { return a2a_js_1.A2AResource; } });
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,uCAA2C;AAAlC,yGAAA,aAAa,OAAA;AACtB,uCAA2C;AAAlC,yGAAA,aAAa,OAAA;AACtB,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,mDAAuD;AAA9C,qHAAA,mBAAmB,OAAA;AAC5B,qDAAyD;AAAhD,uHAAA,oBAAoB,OAAA;AAC7B,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,2CAA+C;AAAtC,6GAAA,eAAe,OAAA;AACxB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,mCAAuC;AAA9B,qGAAA,WAAW,OAAA;AACpB,mCAAuC;AAA9B,qGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ledger resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LedgerResource = void 0;
|
|
7
|
+
const base_js_1 = require("./base.js");
|
|
8
|
+
class LedgerResource extends base_js_1.BaseResource {
|
|
9
|
+
/**
|
|
10
|
+
* List ledger entries
|
|
11
|
+
*/
|
|
12
|
+
async listEntries(options) {
|
|
13
|
+
const response = await this._get('/api/v2/ledger/entries', options);
|
|
14
|
+
return response.entries || [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get a ledger entry by transaction ID
|
|
18
|
+
*
|
|
19
|
+
* @param txId - The transaction ID
|
|
20
|
+
* @returns The ledger entry
|
|
21
|
+
*/
|
|
22
|
+
async get(txId) {
|
|
23
|
+
return this._get(`/api/v2/ledger/entries/${txId}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get a ledger entry by transaction ID
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Use `get(txId)` instead. This method will be removed in v1.0.0.
|
|
29
|
+
* @param txId - The transaction ID
|
|
30
|
+
* @returns The ledger entry
|
|
31
|
+
*/
|
|
32
|
+
async getEntry(txId) {
|
|
33
|
+
return this.get(txId);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Verify a ledger entry's audit anchor
|
|
37
|
+
*/
|
|
38
|
+
async verifyEntry(txId) {
|
|
39
|
+
return this._get(`/api/v2/ledger/entries/${txId}/verify`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.LedgerResource = LedgerResource;
|
|
43
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/resources/ledger.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAyC;AAGzC,MAAa,cAAe,SAAQ,sBAAY;IAC9C;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,OAIjB;QACC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAA6B,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAChG,OAAO,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,IAAI,CAAc,0BAA0B,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,IAAY;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAsC,0BAA0B,IAAI,SAAS,CAAC,CAAC;IACjG,CAAC;CACF;AAxCD,wCAwCC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Marketplace resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MarketplaceResource = void 0;
|
|
7
|
+
const base_js_1 = require("./base.js");
|
|
8
|
+
class MarketplaceResource extends base_js_1.BaseResource {
|
|
9
|
+
// ==================== Categories ====================
|
|
10
|
+
/**
|
|
11
|
+
* List all service categories
|
|
12
|
+
*/
|
|
13
|
+
async listCategories() {
|
|
14
|
+
const response = await this._get('/api/v2/marketplace/categories');
|
|
15
|
+
return response.categories || [];
|
|
16
|
+
}
|
|
17
|
+
// ==================== Services ====================
|
|
18
|
+
/**
|
|
19
|
+
* Create a new service listing
|
|
20
|
+
*/
|
|
21
|
+
async createService(input) {
|
|
22
|
+
return this._post('/api/v2/marketplace/services', input);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* List services in the marketplace
|
|
26
|
+
*/
|
|
27
|
+
async listServices(options) {
|
|
28
|
+
const response = await this._get('/api/v2/marketplace/services', options);
|
|
29
|
+
return response.services || [];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get a service by ID
|
|
33
|
+
*/
|
|
34
|
+
async getService(serviceId) {
|
|
35
|
+
return this._get(`/api/v2/marketplace/services/${serviceId}`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Search for services
|
|
39
|
+
*/
|
|
40
|
+
async searchServices(input) {
|
|
41
|
+
const response = await this._post('/api/v2/marketplace/services/search', input);
|
|
42
|
+
return response.services || [];
|
|
43
|
+
}
|
|
44
|
+
// ==================== Offers ====================
|
|
45
|
+
/**
|
|
46
|
+
* Create an offer for a service
|
|
47
|
+
*/
|
|
48
|
+
async createOffer(input) {
|
|
49
|
+
return this._post('/api/v2/marketplace/offers', input);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List offers
|
|
53
|
+
*/
|
|
54
|
+
async listOffers(options) {
|
|
55
|
+
const response = await this._get('/api/v2/marketplace/offers', options);
|
|
56
|
+
return response.offers || [];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Accept an offer (as provider)
|
|
60
|
+
*/
|
|
61
|
+
async acceptOffer(offerId) {
|
|
62
|
+
return this._post(`/api/v2/marketplace/offers/${offerId}/accept`, {});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reject an offer (as provider)
|
|
66
|
+
*/
|
|
67
|
+
async rejectOffer(offerId) {
|
|
68
|
+
return this._post(`/api/v2/marketplace/offers/${offerId}/reject`, {});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Mark an offer as completed
|
|
72
|
+
*/
|
|
73
|
+
async completeOffer(offerId) {
|
|
74
|
+
return this._post(`/api/v2/marketplace/offers/${offerId}/complete`, {});
|
|
75
|
+
}
|
|
76
|
+
// ==================== Reviews ====================
|
|
77
|
+
/**
|
|
78
|
+
* Create a review for a completed offer
|
|
79
|
+
*/
|
|
80
|
+
async createReview(offerId, rating, comment) {
|
|
81
|
+
return this._post(`/api/v2/marketplace/offers/${offerId}/review`, {
|
|
82
|
+
rating,
|
|
83
|
+
comment,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.MarketplaceResource = MarketplaceResource;
|
|
88
|
+
//# sourceMappingURL=marketplace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marketplace.js","sourceRoot":"","sources":["../../../src/resources/marketplace.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAyC;AAYzC,MAAa,mBAAoB,SAAQ,sBAAY;IACnD,uDAAuD;IAEvD;;OAEG;IACH,KAAK,CAAC,cAAc;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAA2B,gCAAgC,CAAC,CAAC;QAC7F,OAAO,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,qDAAqD;IAErD;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,KAAyB;QAC3C,OAAO,IAAI,CAAC,KAAK,CAAU,8BAA8B,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,OAIlB;QACC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAA0B,8BAA8B,EAAE,OAAO,CAAC,CAAC;QACnG,OAAO,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,SAAiB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAU,gCAAgC,SAAS,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAC/B,qCAAqC,EACrC,KAAK,CACN,CAAC;QACF,OAAO,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,mDAAmD;IAEnD;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,KAAuB;QACvC,OAAO,IAAI,CAAC,KAAK,CAAe,4BAA4B,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,OAIhB;QACC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAA6B,4BAA4B,EAAE,OAAO,CAAC,CAAC;QACpG,OAAO,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAe,8BAA8B,OAAO,SAAS,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAe,8BAA8B,OAAO,SAAS,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,OAAe;QACjC,OAAO,IAAI,CAAC,KAAK,CAAe,8BAA8B,OAAO,WAAW,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,oDAAoD;IAEpD;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,OAAe,EAAE,MAAc,EAAE,OAAgB;QAClE,OAAO,IAAI,CAAC,KAAK,CAAgB,8BAA8B,OAAO,SAAS,EAAE;YAC/E,MAAM;YACN,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AAvGD,kDAuGC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Payments resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PaymentsResource = void 0;
|
|
7
|
+
const base_js_1 = require("./base.js");
|
|
8
|
+
class PaymentsResource extends base_js_1.BaseResource {
|
|
9
|
+
/**
|
|
10
|
+
* Execute a single payment mandate
|
|
11
|
+
*/
|
|
12
|
+
async executeMandate(mandate, options) {
|
|
13
|
+
return this._post('/api/v2/mandates/execute', { mandate }, options);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Execute a full AP2 payment bundle (Intent → Cart → Payment)
|
|
17
|
+
*/
|
|
18
|
+
async executeAP2(intent, cart, payment, options) {
|
|
19
|
+
return this._post('/api/v2/ap2/payments/execute', {
|
|
20
|
+
intent,
|
|
21
|
+
cart,
|
|
22
|
+
payment,
|
|
23
|
+
}, options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Execute a pre-built AP2 bundle
|
|
27
|
+
*/
|
|
28
|
+
async executeAP2Bundle(bundle) {
|
|
29
|
+
return this.executeAP2(bundle.intent, bundle.cart, bundle.payment);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.PaymentsResource = PaymentsResource;
|
|
33
|
+
//# sourceMappingURL=payments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../../src/resources/payments.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAyC;AAGzC,MAAa,gBAAiB,SAAQ,sBAAY;IAChD;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,OAAgC,EAAE,OAAwB;QAC7E,OAAO,IAAI,CAAC,KAAK,CAAyB,0BAA0B,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9F,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,MAA+B,EAC/B,IAA6B,EAC7B,OAAgC,EAChC,OAAwB;QAExB,OAAO,IAAI,CAAC,KAAK,CAAqB,8BAA8B,EAAE;YACpE,MAAM;YACN,IAAI;YACJ,OAAO;SACR,EAAE,OAAO,CAAC,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAItB;QACC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CACF;AAlCD,4CAkCC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Policies Resource
|
|
4
|
+
*
|
|
5
|
+
* Natural language policy parsing + deterministic enforcement helpers.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.PoliciesResource = void 0;
|
|
9
|
+
const base_js_1 = require("./base.js");
|
|
10
|
+
class PoliciesResource extends base_js_1.BaseResource {
|
|
11
|
+
async parse(natural_language, agent_id, options) {
|
|
12
|
+
return this._post('/api/v2/policies/parse', { natural_language, agent_id }, options);
|
|
13
|
+
}
|
|
14
|
+
async preview(natural_language, agent_id, options) {
|
|
15
|
+
return this._post('/api/v2/policies/preview', { natural_language, agent_id, confirm: false }, options);
|
|
16
|
+
}
|
|
17
|
+
async apply(natural_language, agent_id, options) {
|
|
18
|
+
return this._post('/api/v2/policies/apply', { natural_language, agent_id, confirm: true }, options);
|
|
19
|
+
}
|
|
20
|
+
async get(agent_id, options) {
|
|
21
|
+
return this._get(`/api/v2/policies/${agent_id}`, undefined, options);
|
|
22
|
+
}
|
|
23
|
+
async check(input, options) {
|
|
24
|
+
return this._post('/api/v2/policies/check', input, options);
|
|
25
|
+
}
|
|
26
|
+
async examples(options) {
|
|
27
|
+
return this._get('/api/v2/policies/examples', undefined, options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.PoliciesResource = PoliciesResource;
|
|
31
|
+
//# sourceMappingURL=policies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../../../src/resources/policies.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAyC;AASzC,MAAa,gBAAiB,SAAQ,sBAAY;IAChD,KAAK,CAAC,KAAK,CACT,gBAAwB,EACxB,QAAiB,EACjB,OAAwB;QAExB,OAAO,IAAI,CAAC,KAAK,CACf,wBAAwB,EACxB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAC9B,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CACX,gBAAwB,EACxB,QAAgB,EAChB,OAAwB;QAExB,OAAO,IAAI,CAAC,KAAK,CACf,0BAA0B,EAC1B,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAC9C,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK,CACT,gBAAwB,EACxB,QAAgB,EAChB,OAAwB;QAExB,OAAO,IAAI,CAAC,KAAK,CACf,wBAAwB,EACxB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAC7C,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,OAAwB;QAClD,OAAO,IAAI,CAAC,IAAI,CAA0B,oBAAoB,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAChG,CAAC;IAED,KAAK,CAAC,KAAK,CACT,KAOC,EACD,OAAwB;QAExB,OAAO,IAAI,CAAC,KAAK,CAAsB,wBAAwB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAwB;QACrC,OAAO,IAAI,CAAC,IAAI,CAA4B,2BAA2B,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/F,CAAC;CACF;AA1DD,4CA0DC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Transactions resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TransactionsResource = void 0;
|
|
7
|
+
const base_js_1 = require("./base.js");
|
|
8
|
+
class TransactionsResource extends base_js_1.BaseResource {
|
|
9
|
+
/**
|
|
10
|
+
* List supported blockchain networks
|
|
11
|
+
*/
|
|
12
|
+
async listChains() {
|
|
13
|
+
const response = await this._get('/api/v2/transactions/chains');
|
|
14
|
+
return response.chains || [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Estimate gas for a transaction
|
|
18
|
+
*/
|
|
19
|
+
async estimateGas(options) {
|
|
20
|
+
return this._post('/api/v2/transactions/estimate-gas', options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the status of a transaction
|
|
24
|
+
*/
|
|
25
|
+
async getStatus(txHash, chain) {
|
|
26
|
+
return this._get(`/api/v2/transactions/status/${txHash}`, { chain });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* List supported tokens on a chain
|
|
30
|
+
*/
|
|
31
|
+
async listTokens(chain) {
|
|
32
|
+
const response = await this._get(`/api/v2/transactions/tokens/${chain}`);
|
|
33
|
+
return response.tokens || [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.TransactionsResource = TransactionsResource;
|
|
37
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAyC;AAGzC,MAAa,oBAAqB,SAAQ,sBAAY;IACpD;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAA0B,6BAA6B,CAAC,CAAC;QACzF,OAAO,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,OAKjB;QACC,OAAO,IAAI,CAAC,KAAK,CAAc,mCAAmC,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,KAAa;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAoB,+BAA+B,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa;QAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAC9B,+BAA+B,KAAK,EAAE,CACvC,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IAC/B,CAAC;CACF;AArCD,oDAqCC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UCP (Universal Commerce Protocol) resource
|
|
4
|
+
*
|
|
5
|
+
* Provides checkout session management for structured commerce:
|
|
6
|
+
* - Create checkout sessions with cart items
|
|
7
|
+
* - Update sessions (add/remove items, discounts)
|
|
8
|
+
* - Complete checkout and generate payment mandates
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.UCPResource = void 0;
|
|
12
|
+
const base_js_1 = require("./base.js");
|
|
13
|
+
// ============ Resource ============
|
|
14
|
+
class UCPResource extends base_js_1.BaseResource {
|
|
15
|
+
/**
|
|
16
|
+
* Create a new checkout session
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const session = await client.ucp.createCheckout({
|
|
21
|
+
* merchant_id: 'merchant_123',
|
|
22
|
+
* merchant_name: 'Example Store',
|
|
23
|
+
* merchant_domain: 'store.example.com',
|
|
24
|
+
* customer_id: 'agent_abc',
|
|
25
|
+
* line_items: [{
|
|
26
|
+
* item_id: 'item_1',
|
|
27
|
+
* name: 'Widget',
|
|
28
|
+
* description: 'A useful widget',
|
|
29
|
+
* quantity: 2,
|
|
30
|
+
* unit_price_minor: 1000,
|
|
31
|
+
* }],
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
async createCheckout(input) {
|
|
36
|
+
return this._post('/api/v2/ucp/checkout', input);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a checkout session
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const session = await client.ucp.getCheckout('cs_abc123');
|
|
44
|
+
* console.log(session.status, session.total_minor);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
async getCheckout(sessionId) {
|
|
48
|
+
return this._get(`/api/v2/ucp/checkout/${sessionId}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Update a checkout session
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const updated = await client.ucp.updateCheckout('cs_abc123', {
|
|
56
|
+
* add_items: [{ item_id: 'item_2', name: 'Extra', quantity: 1, unit_price_minor: 500 }],
|
|
57
|
+
* add_discounts: [{
|
|
58
|
+
* discount_id: 'disc_1',
|
|
59
|
+
* name: '10% Off',
|
|
60
|
+
* discount_type: 'percentage',
|
|
61
|
+
* value: '10',
|
|
62
|
+
* }],
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
async updateCheckout(sessionId, input) {
|
|
67
|
+
return this._patch(`/api/v2/ucp/checkout/${sessionId}`, input);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Complete a checkout session and generate payment mandate
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const result = await client.ucp.completeCheckout('cs_abc123', {
|
|
75
|
+
* chain: 'base',
|
|
76
|
+
* token: 'USDC',
|
|
77
|
+
* destination: '0x...',
|
|
78
|
+
* subject: 'agent_abc',
|
|
79
|
+
* issuer: 'sardis.sh',
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* if (result.success) {
|
|
83
|
+
* console.log('Payment tx:', result.chain_tx_hash);
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
async completeCheckout(sessionId, input) {
|
|
88
|
+
return this._post(`/api/v2/ucp/checkout/${sessionId}/complete`, input);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Cancel a checkout session
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* await client.ucp.cancelCheckout('cs_abc123');
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
async cancelCheckout(sessionId) {
|
|
99
|
+
return this._post(`/api/v2/ucp/checkout/${sessionId}/cancel`, {});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get an order by ID
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const order = await client.ucp.getOrder('ord_abc123');
|
|
107
|
+
* console.log(order.status, order.chain_tx_hash);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
async getOrder(orderId) {
|
|
111
|
+
return this._get(`/api/v2/ucp/orders/${orderId}`);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* List orders
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const orders = await client.ucp.listOrders({
|
|
119
|
+
* customer_id: 'agent_abc',
|
|
120
|
+
* status: 'completed',
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
async listOrders(options) {
|
|
125
|
+
const response = await this._get('/api/v2/ucp/orders', options);
|
|
126
|
+
if (Array.isArray(response)) {
|
|
127
|
+
return response;
|
|
128
|
+
}
|
|
129
|
+
return response.orders || [];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.UCPResource = UCPResource;
|
|
133
|
+
//# sourceMappingURL=ucp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ucp.js","sourceRoot":"","sources":["../../../src/resources/ucp.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,uCAAyC;AAkHzC,qCAAqC;AAErC,MAAa,WAAY,SAAQ,sBAAY;IAC3C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAkB,sBAAsB,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CAAC,SAAiB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAkB,wBAAwB,SAAS,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,cAAc,CAAC,SAAiB,EAAE,KAA0B;QAChE,OAAO,IAAI,CAAC,MAAM,CAAkB,wBAAwB,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,gBAAgB,CAAC,SAAiB,EAAE,KAA4B;QACpE,OAAO,IAAI,CAAC,KAAK,CAAiB,wBAAwB,SAAS,WAAW,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAAC,SAAiB;QACpC,OAAO,IAAI,CAAC,KAAK,CAAkB,wBAAwB,SAAS,SAAS,EAAE,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAW,sBAAsB,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,UAAU,CAAC,OAMhB;QACC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAC9B,oBAAoB,EACpB,OAAO,CACR,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IAC/B,CAAC;CACF;AArID,kCAqIC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wallets Resource
|
|
4
|
+
*
|
|
5
|
+
* Manages non-custodial wallets for agents.
|
|
6
|
+
* Wallets never hold funds - they only sign transactions via MPC.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.WalletsResource = void 0;
|
|
10
|
+
const base_js_1 = require("./base.js");
|
|
11
|
+
class WalletsResource extends base_js_1.BaseResource {
|
|
12
|
+
_normalize(wallet) {
|
|
13
|
+
// Provide backwards-compatible alias: id := wallet_id
|
|
14
|
+
if (!wallet.id) {
|
|
15
|
+
wallet.id = wallet.wallet_id;
|
|
16
|
+
}
|
|
17
|
+
return wallet;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a new non-custodial wallet for an agent.
|
|
21
|
+
*
|
|
22
|
+
* @param input Wallet creation parameters
|
|
23
|
+
* @param options Request options (signal, timeout)
|
|
24
|
+
* @returns Created wallet
|
|
25
|
+
*/
|
|
26
|
+
async create(input, options) {
|
|
27
|
+
const wallet = await this._post('/api/v2/wallets', input, options);
|
|
28
|
+
return this._normalize(wallet);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get a wallet by ID.
|
|
32
|
+
*
|
|
33
|
+
* @param walletId Wallet ID
|
|
34
|
+
* @param options Request options (signal, timeout)
|
|
35
|
+
* @returns Wallet details
|
|
36
|
+
*/
|
|
37
|
+
async get(walletId, options) {
|
|
38
|
+
const wallet = await this._get(`/api/v2/wallets/${walletId}`, undefined, options);
|
|
39
|
+
return this._normalize(wallet);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* List wallets.
|
|
43
|
+
*
|
|
44
|
+
* @param agentId Optional agent ID filter
|
|
45
|
+
* @param limit Maximum number of wallets to return
|
|
46
|
+
* @param options Request options (signal, timeout)
|
|
47
|
+
* @returns List of wallets
|
|
48
|
+
*/
|
|
49
|
+
async list(agentId, limit = 100, options) {
|
|
50
|
+
const params = { limit };
|
|
51
|
+
if (agentId) {
|
|
52
|
+
params.agent_id = agentId;
|
|
53
|
+
}
|
|
54
|
+
const response = await this._get('/api/v2/wallets', params, options);
|
|
55
|
+
// Handle both array and object response formats
|
|
56
|
+
if (Array.isArray(response)) {
|
|
57
|
+
return response.map((w) => this._normalize(w));
|
|
58
|
+
}
|
|
59
|
+
return (response.wallets || []).map((w) => this._normalize(w));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get wallet balance from chain (non-custodial, read-only).
|
|
63
|
+
*
|
|
64
|
+
* @param walletId Wallet ID
|
|
65
|
+
* @param chain Chain identifier (e.g., "base", "polygon")
|
|
66
|
+
* @param token Token symbol (e.g., "USDC", "USDT")
|
|
67
|
+
* @param options Request options (signal, timeout)
|
|
68
|
+
* @returns Wallet balance from chain
|
|
69
|
+
*/
|
|
70
|
+
async getBalance(walletId, chain = 'base', token = 'USDC', options) {
|
|
71
|
+
return this._get(`/api/v2/wallets/${walletId}/balance`, {
|
|
72
|
+
chain,
|
|
73
|
+
token,
|
|
74
|
+
}, options);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get all wallet addresses (chain -> address mapping).
|
|
78
|
+
*
|
|
79
|
+
* @param walletId Wallet ID
|
|
80
|
+
* @param options Request options (signal, timeout)
|
|
81
|
+
* @returns Dictionary mapping chain names to addresses
|
|
82
|
+
*/
|
|
83
|
+
async getAddresses(walletId, options) {
|
|
84
|
+
return this._get(`/api/v2/wallets/${walletId}/addresses`, undefined, options);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Set wallet address for a chain.
|
|
88
|
+
*
|
|
89
|
+
* @param walletId Wallet ID
|
|
90
|
+
* @param input Address information
|
|
91
|
+
* @param options Request options (signal, timeout)
|
|
92
|
+
* @returns Updated wallet
|
|
93
|
+
*/
|
|
94
|
+
async setAddress(walletId, input, options) {
|
|
95
|
+
const wallet = await this._post(`/api/v2/wallets/${walletId}/addresses`, input, options);
|
|
96
|
+
return this._normalize(wallet);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Transfer stablecoins from a wallet (agent is sender).
|
|
100
|
+
*
|
|
101
|
+
* This endpoint is intended to be called by an agent process using an API key.
|
|
102
|
+
* Sardis enforces policy + compliance and signs via the agent MPC wallet.
|
|
103
|
+
*/
|
|
104
|
+
async transfer(walletId, input, options) {
|
|
105
|
+
return this._post(`/api/v2/wallets/${walletId}/transfer`, input, options);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.WalletsResource = WalletsResource;
|
|
109
|
+
//# sourceMappingURL=wallets.js.map
|