@orbserv-labs/orb-wallet 0.1.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.
@@ -0,0 +1,51 @@
1
+ import type { HttpClient } from "../utils/http.js";
2
+ import type { PolicyData, UpdatePolicyOptions } from "../types.js";
3
+ /**
4
+ * Manages spending-policy operations for a single wallet.
5
+ *
6
+ * Obtained via `agentWallet.policy`.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * await wallet.policy.update({ dailyLimit: 100 })
11
+ * await wallet.policy.pause()
12
+ * await wallet.policy.resume()
13
+ * ```
14
+ */
15
+ export declare class PolicyModule {
16
+ private readonly http;
17
+ private readonly walletId;
18
+ constructor(http: HttpClient, walletId: string);
19
+ /**
20
+ * Retrieve the current policy for this wallet.
21
+ *
22
+ * @returns The current {@link PolicyData}.
23
+ */
24
+ get(): Promise<PolicyData>;
25
+ /**
26
+ * Update one or more policy fields.
27
+ *
28
+ * @param options - Fields to update. Only the provided fields are changed.
29
+ * @returns The updated {@link PolicyData}.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * await wallet.policy.update({ dailyLimit: 100, maxPerTx: 25 })
34
+ * ```
35
+ */
36
+ update(options: UpdatePolicyOptions): Promise<PolicyData>;
37
+ /**
38
+ * Pause the spending policy, effectively blocking all outgoing transactions
39
+ * from this wallet until `resume()` is called.
40
+ *
41
+ * @returns The updated {@link PolicyData} with `status: "paused"`.
42
+ */
43
+ pause(): Promise<PolicyData>;
44
+ /**
45
+ * Resume a previously paused policy, re-enabling outgoing transactions.
46
+ *
47
+ * @returns The updated {@link PolicyData} with `status: "active"`.
48
+ */
49
+ resume(): Promise<PolicyData>;
50
+ }
51
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/modules/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM;IAS9C;;;;OAIG;IACG,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAMhC;;;;;;;;;;OAUG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAO/D;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC;IAMlC;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC;CAKpC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PolicyModule = void 0;
4
+ /**
5
+ * Manages spending-policy operations for a single wallet.
6
+ *
7
+ * Obtained via `agentWallet.policy`.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * await wallet.policy.update({ dailyLimit: 100 })
12
+ * await wallet.policy.pause()
13
+ * await wallet.policy.resume()
14
+ * ```
15
+ */
16
+ class PolicyModule {
17
+ constructor(http, walletId) {
18
+ this.http = http;
19
+ this.walletId = walletId;
20
+ }
21
+ // -------------------------------------------------------------------------
22
+ // Public API
23
+ // -------------------------------------------------------------------------
24
+ /**
25
+ * Retrieve the current policy for this wallet.
26
+ *
27
+ * @returns The current {@link PolicyData}.
28
+ */
29
+ async get() {
30
+ return this.http.get(`/wallets/${this.walletId}/policy`);
31
+ }
32
+ /**
33
+ * Update one or more policy fields.
34
+ *
35
+ * @param options - Fields to update. Only the provided fields are changed.
36
+ * @returns The updated {@link PolicyData}.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * await wallet.policy.update({ dailyLimit: 100, maxPerTx: 25 })
41
+ * ```
42
+ */
43
+ async update(options) {
44
+ return this.http.patch(`/wallets/${this.walletId}/policy`, options);
45
+ }
46
+ /**
47
+ * Pause the spending policy, effectively blocking all outgoing transactions
48
+ * from this wallet until `resume()` is called.
49
+ *
50
+ * @returns The updated {@link PolicyData} with `status: "paused"`.
51
+ */
52
+ async pause() {
53
+ return this.http.post(`/wallets/${this.walletId}/policy/pause`);
54
+ }
55
+ /**
56
+ * Resume a previously paused policy, re-enabling outgoing transactions.
57
+ *
58
+ * @returns The updated {@link PolicyData} with `status: "active"`.
59
+ */
60
+ async resume() {
61
+ return this.http.post(`/wallets/${this.walletId}/policy/resume`);
62
+ }
63
+ }
64
+ exports.PolicyModule = PolicyModule;
65
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/modules/policy.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;GAWG;AACH,MAAa,YAAY;IAIvB,YAAY,IAAgB,EAAE,QAAgB;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,4EAA4E;IAC5E,aAAa;IACb,4EAA4E;IAE5E;;;;OAIG;IACH,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,YAAY,IAAI,CAAC,QAAQ,SAAS,CACnC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM,CAAC,OAA4B;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CACpB,YAAY,IAAI,CAAC,QAAQ,SAAS,EAClC,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,YAAY,IAAI,CAAC,QAAQ,eAAe,CACzC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,YAAY,IAAI,CAAC,QAAQ,gBAAgB,CAC1C,CAAC;IACJ,CAAC;CACF;AAhED,oCAgEC"}
@@ -0,0 +1,70 @@
1
+ import type { HttpClient } from "../utils/http.js";
2
+ import type { CreateWalletOptions } from "../types.js";
3
+ import { AgentWallet } from "./agent-wallet.js";
4
+ /**
5
+ * Manages wallet lifecycle operations: create, retrieve, and list wallets.
6
+ *
7
+ * Exposed as `orb.wallet` on the top-level {@link OrbWallet} client.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const wallet = await orb.wallet.create({
12
+ * name: "my-agent",
13
+ * chains: ["solana", "base", "ethereum", "arbitrum"],
14
+ * policy: { dailyLimit: 50, maxPerTx: 10 }
15
+ * })
16
+ * ```
17
+ */
18
+ export declare class WalletModule {
19
+ private readonly http;
20
+ constructor(http: HttpClient);
21
+ /**
22
+ * Create a new agent wallet.
23
+ *
24
+ * @param options - Wallet creation parameters: name, chains, and optional policy.
25
+ * @returns A fully initialised {@link AgentWallet} instance.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const wallet = await orb.wallet.create({
30
+ * name: "my-agent",
31
+ * chains: ["solana", "base", "ethereum", "arbitrum"],
32
+ * policy: {
33
+ * dailyLimit: 50,
34
+ * maxPerTx: 10,
35
+ * whitelist: ["x402", "inference"],
36
+ * alertAbove: 20
37
+ * }
38
+ * })
39
+ *
40
+ * console.log(wallet.solana.address) // Sol address
41
+ * console.log(wallet.evm.address) // 0x address
42
+ * ```
43
+ */
44
+ create(options: CreateWalletOptions): Promise<AgentWallet>;
45
+ /**
46
+ * Retrieve an existing wallet by its ID.
47
+ *
48
+ * @param id - The wallet ID (e.g. `"wal_abc123"`).
49
+ * @returns The {@link AgentWallet} instance.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const wallet = await orb.wallet.get("wal_abc123")
54
+ * ```
55
+ */
56
+ get(id: string): Promise<AgentWallet>;
57
+ /**
58
+ * List all wallets associated with the current API key.
59
+ *
60
+ * @returns An array of {@link AgentWallet} instances.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const wallets = await orb.wallet.list()
65
+ * wallets.forEach(w => console.log(w.id, w.name))
66
+ * ```
67
+ */
68
+ list(): Promise<AgentWallet[]>;
69
+ }
70
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/modules/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAc,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAQ5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhE;;;;;;;;;;OAUG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAK3C;;;;;;;;;;OAUG;IACG,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAIrC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletModule = void 0;
4
+ const agent_wallet_js_1 = require("./agent-wallet.js");
5
+ /**
6
+ * Manages wallet lifecycle operations: create, retrieve, and list wallets.
7
+ *
8
+ * Exposed as `orb.wallet` on the top-level {@link OrbWallet} client.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const wallet = await orb.wallet.create({
13
+ * name: "my-agent",
14
+ * chains: ["solana", "base", "ethereum", "arbitrum"],
15
+ * policy: { dailyLimit: 50, maxPerTx: 10 }
16
+ * })
17
+ * ```
18
+ */
19
+ class WalletModule {
20
+ constructor(http) {
21
+ this.http = http;
22
+ }
23
+ // -------------------------------------------------------------------------
24
+ // Public API
25
+ // -------------------------------------------------------------------------
26
+ /**
27
+ * Create a new agent wallet.
28
+ *
29
+ * @param options - Wallet creation parameters: name, chains, and optional policy.
30
+ * @returns A fully initialised {@link AgentWallet} instance.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const wallet = await orb.wallet.create({
35
+ * name: "my-agent",
36
+ * chains: ["solana", "base", "ethereum", "arbitrum"],
37
+ * policy: {
38
+ * dailyLimit: 50,
39
+ * maxPerTx: 10,
40
+ * whitelist: ["x402", "inference"],
41
+ * alertAbove: 20
42
+ * }
43
+ * })
44
+ *
45
+ * console.log(wallet.solana.address) // Sol address
46
+ * console.log(wallet.evm.address) // 0x address
47
+ * ```
48
+ */
49
+ async create(options) {
50
+ const data = await this.http.post("/wallets", options);
51
+ return new agent_wallet_js_1.AgentWallet(data, this.http);
52
+ }
53
+ /**
54
+ * Retrieve an existing wallet by its ID.
55
+ *
56
+ * @param id - The wallet ID (e.g. `"wal_abc123"`).
57
+ * @returns The {@link AgentWallet} instance.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const wallet = await orb.wallet.get("wal_abc123")
62
+ * ```
63
+ */
64
+ async get(id) {
65
+ const data = await this.http.get(`/wallets/${id}`);
66
+ return new agent_wallet_js_1.AgentWallet(data, this.http);
67
+ }
68
+ /**
69
+ * List all wallets associated with the current API key.
70
+ *
71
+ * @returns An array of {@link AgentWallet} instances.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const wallets = await orb.wallet.list()
76
+ * wallets.forEach(w => console.log(w.id, w.name))
77
+ * ```
78
+ */
79
+ async list() {
80
+ const data = await this.http.get("/wallets");
81
+ return data.map((d) => new agent_wallet_js_1.AgentWallet(d, this.http));
82
+ }
83
+ }
84
+ exports.WalletModule = WalletModule;
85
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/modules/wallet.ts"],"names":[],"mappings":";;;AAEA,uDAAgD;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAY;IAGvB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,4EAA4E;IAC5E,aAAa;IACb,4EAA4E;IAE5E;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,MAAM,CAAC,OAA4B;QACvC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAa,UAAU,EAAE,OAAO,CAAC,CAAC;QACnE,OAAO,IAAI,6BAAW,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAa,YAAY,EAAE,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,6BAAW,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAe,UAAU,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,6BAAW,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAtED,oCAsEC"}
@@ -0,0 +1,45 @@
1
+ import type { HttpClient } from "../utils/http.js";
2
+ import type { X402DiscoverOptions, X402DiscoverResponse, X402FetchResult } from "../types.js";
3
+ /**
4
+ * Handles x402-protocol operations: service discovery and auto-pay HTTP fetch.
5
+ *
6
+ * Exposed as `orb.x402` on the top-level client.
7
+ * Also used internally by `AgentWallet.fetch()`.
8
+ */
9
+ export declare class X402Module {
10
+ private readonly http;
11
+ constructor(http: HttpClient);
12
+ /**
13
+ * Discover x402-compatible services registered in the orbserv marketplace.
14
+ *
15
+ * @param options - Optional filters: category, free-text query, limit.
16
+ * @returns A list of {@link X402Service} entries and a total count.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const services = await orb.x402.discover({ category: "inference" })
21
+ * console.log(services.services[0].baseUrl)
22
+ * ```
23
+ */
24
+ discover(options?: X402DiscoverOptions): Promise<X402DiscoverResponse>;
25
+ /**
26
+ * Perform an HTTP request, automatically handling x402 payment challenges.
27
+ *
28
+ * When the target URL returns `HTTP 402`, the SDK negotiates payment using
29
+ * the wallet associated with this SDK instance and retries the request.
30
+ *
31
+ * @param walletId - The wallet to charge for the request.
32
+ * @param url - The target URL.
33
+ * @param init - Optional fetch `RequestInit` options.
34
+ * @returns An {@link X402FetchResult} containing the raw Response and
35
+ * optional payment receipt information.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const result = await wallet.fetch("https://api.service.com/data")
40
+ * const json = await result.response.json()
41
+ * ```
42
+ */
43
+ fetch(walletId: string, url: string, init?: RequestInit): Promise<X402FetchResult>;
44
+ }
45
+ //# sourceMappingURL=x402.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402.d.ts","sourceRoot":"","sources":["../../src/modules/x402.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAQ5B;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgBhF;;;;;;;;;;;;;;;;;OAiBG;IACG,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,eAAe,CAAC;CA8B5B"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.X402Module = void 0;
4
+ /**
5
+ * Handles x402-protocol operations: service discovery and auto-pay HTTP fetch.
6
+ *
7
+ * Exposed as `orb.x402` on the top-level client.
8
+ * Also used internally by `AgentWallet.fetch()`.
9
+ */
10
+ class X402Module {
11
+ constructor(http) {
12
+ this.http = http;
13
+ }
14
+ // -------------------------------------------------------------------------
15
+ // Top-level discovery (orb.x402.discover)
16
+ // -------------------------------------------------------------------------
17
+ /**
18
+ * Discover x402-compatible services registered in the orbserv marketplace.
19
+ *
20
+ * @param options - Optional filters: category, free-text query, limit.
21
+ * @returns A list of {@link X402Service} entries and a total count.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const services = await orb.x402.discover({ category: "inference" })
26
+ * console.log(services.services[0].baseUrl)
27
+ * ```
28
+ */
29
+ async discover(options = {}) {
30
+ const params = new URLSearchParams();
31
+ if (options.category)
32
+ params.set("category", options.category);
33
+ if (options.query)
34
+ params.set("query", options.query);
35
+ if (options.limit !== undefined)
36
+ params.set("limit", String(options.limit));
37
+ const query = params.toString();
38
+ return this.http.get(`/x402/services${query ? `?${query}` : ""}`);
39
+ }
40
+ // -------------------------------------------------------------------------
41
+ // Auto-pay fetch (used by AgentWallet.fetch)
42
+ // -------------------------------------------------------------------------
43
+ /**
44
+ * Perform an HTTP request, automatically handling x402 payment challenges.
45
+ *
46
+ * When the target URL returns `HTTP 402`, the SDK negotiates payment using
47
+ * the wallet associated with this SDK instance and retries the request.
48
+ *
49
+ * @param walletId - The wallet to charge for the request.
50
+ * @param url - The target URL.
51
+ * @param init - Optional fetch `RequestInit` options.
52
+ * @returns An {@link X402FetchResult} containing the raw Response and
53
+ * optional payment receipt information.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const result = await wallet.fetch("https://api.service.com/data")
58
+ * const json = await result.response.json()
59
+ * ```
60
+ */
61
+ async fetch(walletId, url, init) {
62
+ // Delegate to the backend proxy endpoint so the server can handle
63
+ // x402 negotiation securely with the wallet's private key.
64
+ const response = await this.http.post("/x402/fetch", {
65
+ walletId,
66
+ url,
67
+ method: init?.method ?? "GET",
68
+ headers: init?.headers ?? {},
69
+ body: init?.body ?? null,
70
+ });
71
+ // Re-construct a Response from the proxied result so callers get a
72
+ // familiar interface.
73
+ const proxiedResponse = new Response(response.body, {
74
+ status: response.status,
75
+ headers: response.headers,
76
+ });
77
+ return {
78
+ response: proxiedResponse,
79
+ paymentReceipt: response.paymentReceipt,
80
+ amountCharged: response.amountCharged,
81
+ };
82
+ }
83
+ }
84
+ exports.X402Module = X402Module;
85
+ //# sourceMappingURL=x402.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402.js","sourceRoot":"","sources":["../../src/modules/x402.ts"],"names":[],"mappings":";;;AAOA;;;;;GAKG;AACH,MAAa,UAAU;IAGrB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,4EAA4E;IAC5E,0CAA0C;IAC1C,4EAA4E;IAE5E;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,UAA+B,EAAE;QAC9C,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,QAAQ;YAAE,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,OAAO,CAAC,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAE5E,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,iBAAiB,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,6CAA6C;IAC7C,4EAA4E;IAE5E;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,KAAK,CACT,QAAgB,EAChB,GAAW,EACX,IAAkB;QAElB,kEAAkE;QAClE,2DAA2D;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAMlC,aAAa,EAAE;YAChB,QAAQ;YACR,GAAG;YACH,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK;YAC7B,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,EAAE;YAC5B,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI;SACzB,CAAC,CAAC;QAEH,mEAAmE;QACnE,sBAAsB;QACtB,MAAM,eAAe,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;YAClD,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,QAAQ,EAAE,eAAe;YACzB,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,aAAa,EAAE,QAAQ,CAAC,aAAa;SACtC,CAAC;IACJ,CAAC;CACF;AA3FD,gCA2FC"}
@@ -0,0 +1,168 @@
1
+ /** Supported chain identifiers. */
2
+ export type Chain = "solana" | "base" | "ethereum" | "arbitrum";
3
+ /** Token identifiers. */
4
+ export type Token = "USDC" | "ETH" | "SOL" | "USDT";
5
+ /** Spending-policy configuration attached to a wallet. */
6
+ export interface PolicyConfig {
7
+ /** Maximum cumulative USDC spend per 24-hour rolling window. */
8
+ dailyLimit?: number;
9
+ /** Maximum USDC spend allowed in a single transaction. */
10
+ maxPerTx?: number;
11
+ /** Allow-list of service categories or tags (e.g. `"x402"`, `"inference"`). */
12
+ whitelist?: string[];
13
+ /** Trigger an alert when single-tx spend exceeds this threshold (USDC). */
14
+ alertAbove?: number;
15
+ }
16
+ /** Options passed to `WalletModule.create()`. */
17
+ export interface CreateWalletOptions {
18
+ /** Human-readable label for the wallet (used in logs and dashboards). */
19
+ name: string;
20
+ /** Chains to activate addresses on. */
21
+ chains: Chain[];
22
+ /** Optional initial spending policy. */
23
+ policy?: PolicyConfig;
24
+ }
25
+ /** Chain-specific address object returned by the API. */
26
+ export interface ChainAddress {
27
+ address: string;
28
+ chain: Chain;
29
+ }
30
+ /** Raw wallet object as returned by the REST API. */
31
+ export interface WalletData {
32
+ id: string;
33
+ name: string;
34
+ createdAt: string;
35
+ /** Present when Solana chain is active. */
36
+ solana?: ChainAddress;
37
+ /** Single EVM address shared across Base, Ethereum, Arbitrum. */
38
+ evm?: ChainAddress;
39
+ policy: PolicyConfig;
40
+ status: "active" | "paused" | "suspended";
41
+ }
42
+ /** Options for `AgentWallet.send()`. */
43
+ export interface SendOptions {
44
+ /** Recipient address (EVM `0x…` or Solana base58). */
45
+ to: string;
46
+ /** Amount in USDC (or the specified token's native units). */
47
+ amount: number;
48
+ /** Token to send. Defaults to `"USDC"`. */
49
+ token?: Token;
50
+ /** Chain to execute the transfer on. */
51
+ chain: Chain;
52
+ /**
53
+ * When `true`, the transfer is routed through a ZK shielded layer
54
+ * to obscure the on-chain trail.
55
+ */
56
+ privacy?: boolean;
57
+ }
58
+ /** Canonical transaction record. */
59
+ export interface Transaction {
60
+ id: string;
61
+ walletId: string;
62
+ type: "send" | "receive" | "x402";
63
+ chain: Chain;
64
+ token: Token;
65
+ amount: number;
66
+ to?: string;
67
+ from?: string;
68
+ txHash?: string;
69
+ status: "pending" | "confirmed" | "failed";
70
+ privacy: boolean;
71
+ createdAt: string;
72
+ confirmedAt?: string;
73
+ }
74
+ /** Options for `AgentWallet.history()`. */
75
+ export interface HistoryOptions {
76
+ /** Maximum number of records to return (default: 50, max: 200). */
77
+ limit?: number;
78
+ /** Cursor for pagination (opaque string from a previous response). */
79
+ cursor?: string;
80
+ /** Filter to a specific chain. */
81
+ chain?: Chain;
82
+ /** Filter to a specific token. */
83
+ token?: Token;
84
+ }
85
+ /** Paginated history response. */
86
+ export interface HistoryResponse {
87
+ transactions: Transaction[];
88
+ /** Present when there are more pages. */
89
+ nextCursor?: string;
90
+ total: number;
91
+ }
92
+ /** Per-chain, per-token balance entry. */
93
+ export interface BalanceEntry {
94
+ chain: Chain;
95
+ token: Token;
96
+ amount: number;
97
+ /** Amount denominated in USD using current market price. */
98
+ usdValue: number;
99
+ }
100
+ /** Aggregated balance response. */
101
+ export interface BalanceResponse {
102
+ walletId: string;
103
+ balances: BalanceEntry[];
104
+ /** Total USD value across all chains and tokens. */
105
+ totalUsdValue: number;
106
+ updatedAt: string;
107
+ }
108
+ /** Full policy resource as stored server-side. */
109
+ export interface PolicyData {
110
+ walletId: string;
111
+ dailyLimit: number;
112
+ maxPerTx: number;
113
+ whitelist: string[];
114
+ alertAbove: number;
115
+ status: "active" | "paused";
116
+ updatedAt: string;
117
+ }
118
+ /** Fields that can be updated via `policy.update()`. */
119
+ export type UpdatePolicyOptions = Partial<PolicyConfig>;
120
+ /** Options for `X402Module.discover()`. */
121
+ export interface X402DiscoverOptions {
122
+ /** Filter services by category (e.g. `"inference"`, `"data"`, `"storage"`). */
123
+ category?: string;
124
+ /** Free-text search query. */
125
+ query?: string;
126
+ /** Maximum number of results (default: 20). */
127
+ limit?: number;
128
+ }
129
+ /** A single x402-compatible service listing. */
130
+ export interface X402Service {
131
+ id: string;
132
+ name: string;
133
+ description: string;
134
+ category: string;
135
+ baseUrl: string;
136
+ /** Supported tokens for payment. */
137
+ tokens: Token[];
138
+ /** Supported chains for payment. */
139
+ chains: Chain[];
140
+ /** Typical price per API call in USDC. */
141
+ pricePerCall?: number;
142
+ tags: string[];
143
+ }
144
+ /** Discovery response. */
145
+ export interface X402DiscoverResponse {
146
+ services: X402Service[];
147
+ total: number;
148
+ }
149
+ /** x402 fetch response wrapping the raw Response. */
150
+ export interface X402FetchResult {
151
+ /** The raw fetch Response (body unconsumed). */
152
+ response: Response;
153
+ /** Payment receipt returned in the `X-Payment-Receipt` header, if any. */
154
+ paymentReceipt?: string;
155
+ /** Amount deducted from the wallet for this call (USDC). */
156
+ amountCharged?: number;
157
+ }
158
+ /** Options accepted by the `OrbWallet` constructor. */
159
+ export interface OrbWalletOptions {
160
+ /** Secret API key issued from the orbserv dashboard. */
161
+ apiKey: string;
162
+ /**
163
+ * Override the default API base URL.
164
+ * Defaults to `https://api.orbserv.co/v1`.
165
+ */
166
+ baseUrl?: string;
167
+ }
168
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,mCAAmC;AACnC,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAEhE,yBAAyB;AACzB,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpD,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,IAAI,E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,2CAA2C;AAC3C,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,oCAAoC;IACpC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,0BAA0B;AAC1B,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,QAAQ,EAAE,QAAQ,CAAC;IACnB,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // Wallet creation & representation
4
+ // =============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,gFAAgF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Base error class for all orb-wallet SDK errors.
3
+ */
4
+ export declare class OrbError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ /**
8
+ * Thrown when the API returns a non-2xx response.
9
+ * Contains the HTTP status code and the raw response body.
10
+ */
11
+ export declare class OrbApiError extends OrbError {
12
+ readonly statusCode: number;
13
+ readonly body: unknown;
14
+ constructor(statusCode: number, body: unknown);
15
+ }
16
+ /**
17
+ * Thrown when the request fails due to authentication issues (401 / 403).
18
+ */
19
+ export declare class OrbAuthError extends OrbApiError {
20
+ constructor(statusCode: number, body: unknown);
21
+ }
22
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAM5B;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,QAAQ;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAW9C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,WAAW;gBAC/B,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAK9C"}