@leashmarket/sdk 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.
- package/README.md +125 -0
- package/dist/client.d.ts +167 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +479 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/sign.d.ts +47 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign.js +83 -0
- package/dist/sign.js.map +1 -0
- package/dist/types.d.ts +323 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +38 -0
package/dist/sign.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the canonical X-Leash-Sig envelope and ed25519 signature for
|
|
3
|
+
* authenticated agent requests.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `apps/api/src/auth/onchain.ts::buildSigningEnvelope` byte
|
|
6
|
+
* for byte. The two implementations are kept in deliberate sync:
|
|
7
|
+
* `packages/sdk` is browser/Bun/Deno-friendly (uses
|
|
8
|
+
* `@metaplex-foundation/umi` for the eddsa primitives + a pure-JS
|
|
9
|
+
* SHA-256 fallback), while the API uses Node's `node:crypto`.
|
|
10
|
+
*
|
|
11
|
+
* Callers shouldn't need to call this directly — `LeashClient`
|
|
12
|
+
* stamps the headers on every authenticated request — but it's
|
|
13
|
+
* exported for tests and tools that build their own request loop.
|
|
14
|
+
*/
|
|
15
|
+
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
|
|
16
|
+
import { base58 } from '@metaplex-foundation/umi/serializers';
|
|
17
|
+
const _umi = (() => {
|
|
18
|
+
// We only need the `eddsa` primitive; the RPC URL is a placeholder.
|
|
19
|
+
return createUmi('https://api.mainnet-beta.solana.com');
|
|
20
|
+
})();
|
|
21
|
+
/**
|
|
22
|
+
* Build the bytes the executive signs. Hashes the request body so we
|
|
23
|
+
* commit to it without copying it verbatim into the canonical string.
|
|
24
|
+
*/
|
|
25
|
+
export async function buildEnvelope(args) {
|
|
26
|
+
const bodyBytes = args.body == null
|
|
27
|
+
? new Uint8Array(0)
|
|
28
|
+
: typeof args.body === 'string'
|
|
29
|
+
? new TextEncoder().encode(args.body)
|
|
30
|
+
: args.body;
|
|
31
|
+
const bodyHashHex = await sha256Hex(bodyBytes);
|
|
32
|
+
const canonical = [
|
|
33
|
+
args.method.toUpperCase(),
|
|
34
|
+
args.pathWithQuery,
|
|
35
|
+
args.timestamp,
|
|
36
|
+
bodyHashHex,
|
|
37
|
+
args.agentMint,
|
|
38
|
+
].join('\n');
|
|
39
|
+
return new TextEncoder().encode(canonical);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sign an envelope and return the three headers the API verifier
|
|
43
|
+
* expects. `executiveSecretBase58` must decode to a 64-byte ed25519
|
|
44
|
+
* keypair (the same `solana-keygen output` format used by every
|
|
45
|
+
* other Leash surface).
|
|
46
|
+
*/
|
|
47
|
+
export async function signRequest(args) {
|
|
48
|
+
const timestamp = args.timestamp ?? new Date().toISOString();
|
|
49
|
+
const envelope = await buildEnvelope({
|
|
50
|
+
method: args.method,
|
|
51
|
+
pathWithQuery: args.pathWithQuery,
|
|
52
|
+
timestamp,
|
|
53
|
+
body: args.body,
|
|
54
|
+
agentMint: args.agentMint,
|
|
55
|
+
});
|
|
56
|
+
const secret = base58.serialize(args.executiveSecretBase58);
|
|
57
|
+
if (secret.length !== 64) {
|
|
58
|
+
throw new Error(`executive secret must decode to 64 bytes (got ${secret.length})`);
|
|
59
|
+
}
|
|
60
|
+
const keypair = _umi.eddsa.createKeypairFromSecretKey(secret);
|
|
61
|
+
const sig = _umi.eddsa.sign(envelope, keypair);
|
|
62
|
+
return {
|
|
63
|
+
'x-leash-agent': args.agentMint,
|
|
64
|
+
'x-leash-timestamp': timestamp,
|
|
65
|
+
'x-leash-sig': base58.deserialize(sig)[0],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function sha256Hex(bytes) {
|
|
69
|
+
// Browser, Bun, Deno, modern Node: use SubtleCrypto.
|
|
70
|
+
// `globalThis.crypto.subtle` is the cross-runtime entry point.
|
|
71
|
+
const subtle = globalThis.crypto?.subtle;
|
|
72
|
+
if (subtle) {
|
|
73
|
+
const buf = await subtle.digest('SHA-256', bytes);
|
|
74
|
+
return Array.from(new Uint8Array(buf))
|
|
75
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
76
|
+
.join('');
|
|
77
|
+
}
|
|
78
|
+
// Node ≤ 19 fallback. Importing inside the branch keeps the SDK
|
|
79
|
+
// tree-shakeable in browser bundles.
|
|
80
|
+
const { createHash } = await import('node:crypto');
|
|
81
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=sign.js.map
|
package/dist/sign.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAE9D,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE;IACjB,oEAAoE;IACpE,OAAO,SAAS,CAAC,qCAAqC,CAAC,CAAC;AAC1D,CAAC,CAAC,EAAE,CAAC;AAgBL;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAqB;IACvD,MAAM,SAAS,GACb,IAAI,CAAC,IAAI,IAAI,IAAI;QACf,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;YAC7B,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM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AE,SAAS;QAC9B,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,KAAiB;IACxC,qDAAqD;IACrD,+DAA+D;IAC/D,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;IACzC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;aACnC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IACD,gEAAgE;IAChE,qCAAqC;IACrC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared response types mirroring the public Leash API.
|
|
3
|
+
*
|
|
4
|
+
* These shapes are derived by hand from the OpenAPI doc the API
|
|
5
|
+
* already serves at `/openapi.json`. We could auto-generate from
|
|
6
|
+
* that source, but hand-rolling keeps the SDK runtime-light (zero
|
|
7
|
+
* extra deps) and lets us rename fields when ergonomics improve.
|
|
8
|
+
*
|
|
9
|
+
* The shapes here are a strict subset of what the API returns —
|
|
10
|
+
* fields you don't see are still present on the wire and reachable
|
|
11
|
+
* via `as unknown as` for forward-compat.
|
|
12
|
+
*/
|
|
13
|
+
export type SvmNetwork = 'solana-devnet' | 'solana-mainnet';
|
|
14
|
+
export type DiscoverSource = 'leash' | 'pay-skills';
|
|
15
|
+
export type DiscoverItem = {
|
|
16
|
+
/**
|
|
17
|
+
* Catalogue this entry came from. `'leash'` items are agents listed
|
|
18
|
+
* on the Leash marketplace; `'pay-skills'` items come from the
|
|
19
|
+
* Solana Foundation `pay-skills` registry
|
|
20
|
+
* (https://github.com/solana-foundation/pay-skills) and have no
|
|
21
|
+
* on-chain seller identity.
|
|
22
|
+
*/
|
|
23
|
+
source: DiscoverSource;
|
|
24
|
+
url: string;
|
|
25
|
+
title: string;
|
|
26
|
+
description: string;
|
|
27
|
+
slug: string;
|
|
28
|
+
category: string;
|
|
29
|
+
price_usdc: string | null;
|
|
30
|
+
pricing_type: 'free' | 'per_call' | 'variable';
|
|
31
|
+
seller_agent_mint: string | null;
|
|
32
|
+
/** Owner wallet for Leash entries; null for pay-skills entries. */
|
|
33
|
+
seller_wallet: string | null;
|
|
34
|
+
rating: number | null;
|
|
35
|
+
health_status: 'ok' | 'warn' | 'down' | null;
|
|
36
|
+
tags: string[];
|
|
37
|
+
tools: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
export type DiscoverResponse = {
|
|
43
|
+
items: DiscoverItem[];
|
|
44
|
+
next_cursor: string | null;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Per-endpoint pricing block as published by the pay-skills catalogue.
|
|
48
|
+
* Most endpoints today are simple flat-rate per-call (a single `tiers`
|
|
49
|
+
* entry with `price_usd`); usage-based and tiered pricing share the
|
|
50
|
+
* same shape so callers should always inspect `mode` first.
|
|
51
|
+
*/
|
|
52
|
+
export type PaySkillsEndpointPricing = {
|
|
53
|
+
mode?: string;
|
|
54
|
+
dimensions?: Array<{
|
|
55
|
+
direction?: string;
|
|
56
|
+
scale?: number;
|
|
57
|
+
unit?: string;
|
|
58
|
+
tiers?: Array<{
|
|
59
|
+
price_usd?: number;
|
|
60
|
+
threshold?: number;
|
|
61
|
+
}>;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
export type PaySkillsEndpoint = {
|
|
65
|
+
method: string;
|
|
66
|
+
/** Path relative to `service_url`. */
|
|
67
|
+
path: string;
|
|
68
|
+
/** Absolute URL (`service_url` + `path`) — what the buyer calls. */
|
|
69
|
+
url: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
resource?: string;
|
|
72
|
+
pricing?: PaySkillsEndpointPricing | null;
|
|
73
|
+
/** Payment protocols supported, e.g. `['x402']`. */
|
|
74
|
+
protocol?: string[];
|
|
75
|
+
/** Stablecoin symbols accepted, e.g. `['USDC']` or `['USDC','USDT']`. */
|
|
76
|
+
supported_usd?: string[];
|
|
77
|
+
/** `'ok'` when the catalogue's last live probe matched the expected challenge. */
|
|
78
|
+
probe_status?: string;
|
|
79
|
+
probe_description?: string;
|
|
80
|
+
};
|
|
81
|
+
export type PaySkillsProvider = {
|
|
82
|
+
/** Fully qualified name, e.g. `agentmail/email`. */
|
|
83
|
+
fqn: string;
|
|
84
|
+
title: string;
|
|
85
|
+
description: string;
|
|
86
|
+
use_case?: string;
|
|
87
|
+
category: string;
|
|
88
|
+
service_url: string;
|
|
89
|
+
version?: string;
|
|
90
|
+
endpoints: PaySkillsEndpoint[];
|
|
91
|
+
};
|
|
92
|
+
export type ReputationSnapshot = {
|
|
93
|
+
agent_mint: string;
|
|
94
|
+
network: SvmNetwork;
|
|
95
|
+
total_volume_usdc: string;
|
|
96
|
+
settled_calls: number;
|
|
97
|
+
denied_calls: number;
|
|
98
|
+
distinct_counterparties: number;
|
|
99
|
+
dispute_rate: number;
|
|
100
|
+
oldest_receipt_at: string | null;
|
|
101
|
+
newest_receipt_at: string | null;
|
|
102
|
+
rating: number;
|
|
103
|
+
};
|
|
104
|
+
export type Receipt = {
|
|
105
|
+
receipt_hash: string;
|
|
106
|
+
network: SvmNetwork;
|
|
107
|
+
agent: string;
|
|
108
|
+
nonce: number;
|
|
109
|
+
decision: string;
|
|
110
|
+
kind: 'spend' | 'earn' | 'denied';
|
|
111
|
+
tx_sig: string | null;
|
|
112
|
+
ingested_at: string;
|
|
113
|
+
raw: {
|
|
114
|
+
request?: {
|
|
115
|
+
url?: string;
|
|
116
|
+
method?: string;
|
|
117
|
+
};
|
|
118
|
+
price?: {
|
|
119
|
+
amount?: string;
|
|
120
|
+
currency?: string;
|
|
121
|
+
asset?: string;
|
|
122
|
+
network?: string;
|
|
123
|
+
};
|
|
124
|
+
} & Record<string, unknown>;
|
|
125
|
+
};
|
|
126
|
+
export type ReceiptsResponse = {
|
|
127
|
+
items: Receipt[];
|
|
128
|
+
next_cursor: string | null;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Per-day bucket emitted by {@link LeashClient.dailyTransactions}.
|
|
132
|
+
* Stable USD totals are summed at 1:1 across USDC/USDG/USDT.
|
|
133
|
+
*/
|
|
134
|
+
export type DailyTxBucket = {
|
|
135
|
+
date: string;
|
|
136
|
+
sent_count: number;
|
|
137
|
+
sent_usd: string;
|
|
138
|
+
received_count: number;
|
|
139
|
+
received_usd: string;
|
|
140
|
+
net_usd: string;
|
|
141
|
+
};
|
|
142
|
+
export type DailyTransactionsResponse = {
|
|
143
|
+
agent_mint: string;
|
|
144
|
+
network: SvmNetwork;
|
|
145
|
+
range: {
|
|
146
|
+
from: string;
|
|
147
|
+
to: string;
|
|
148
|
+
days: number;
|
|
149
|
+
};
|
|
150
|
+
daily: DailyTxBucket[];
|
|
151
|
+
totals: {
|
|
152
|
+
sent_count: number;
|
|
153
|
+
sent_usd: string;
|
|
154
|
+
received_count: number;
|
|
155
|
+
received_usd: string;
|
|
156
|
+
net_usd: string;
|
|
157
|
+
non_usd_count: number;
|
|
158
|
+
};
|
|
159
|
+
truncated: boolean;
|
|
160
|
+
};
|
|
161
|
+
export type TransactionHistoryItem = {
|
|
162
|
+
receipt_hash: string;
|
|
163
|
+
direction: 'outgoing' | 'incoming';
|
|
164
|
+
decision: string;
|
|
165
|
+
tx_signature: string | null;
|
|
166
|
+
url: string | null;
|
|
167
|
+
method: string | null;
|
|
168
|
+
amount: string | null;
|
|
169
|
+
currency: string | null;
|
|
170
|
+
timestamp: string;
|
|
171
|
+
};
|
|
172
|
+
export type TransactionHistoryResponse = {
|
|
173
|
+
agent_mint: string;
|
|
174
|
+
network: SvmNetwork;
|
|
175
|
+
range: {
|
|
176
|
+
from: string;
|
|
177
|
+
to: string;
|
|
178
|
+
days: number;
|
|
179
|
+
};
|
|
180
|
+
direction: 'both' | 'outgoing' | 'incoming';
|
|
181
|
+
count: number;
|
|
182
|
+
truncated: boolean;
|
|
183
|
+
total_sent_usd: string;
|
|
184
|
+
total_received_usd: string;
|
|
185
|
+
net_usd: string;
|
|
186
|
+
sent_count: number;
|
|
187
|
+
received_count: number;
|
|
188
|
+
non_usd_count: number;
|
|
189
|
+
items: TransactionHistoryItem[];
|
|
190
|
+
};
|
|
191
|
+
export type AgentWebhook = {
|
|
192
|
+
id: string;
|
|
193
|
+
agent_mint: string;
|
|
194
|
+
network: SvmNetwork;
|
|
195
|
+
url: string;
|
|
196
|
+
events: string[];
|
|
197
|
+
disabled_at: string | null;
|
|
198
|
+
created_at: string;
|
|
199
|
+
};
|
|
200
|
+
export type AgentWebhookWithSecret = AgentWebhook & {
|
|
201
|
+
secret: string;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Input for {@link LeashClient.recordAgent}. Mirrors `RecordMintBody`
|
|
205
|
+
* in `apps/api/src/routes/agent-self-register.ts`.
|
|
206
|
+
*
|
|
207
|
+
* Agent provisioning is fully client-side — generate (or import) an
|
|
208
|
+
* executive keypair, fund it with SOL, then mint the MPL Core asset
|
|
209
|
+
* locally with `@leashmarket/mcp::mintAgentLocally` (or your own Umi setup).
|
|
210
|
+
* Once the asset is on-chain, call `recordAgent` to write the
|
|
211
|
+
* platform row + receipts feed metadata.
|
|
212
|
+
*/
|
|
213
|
+
export type RecordAgentInput = {
|
|
214
|
+
/** MPL Core asset address. Must already exist on `network`. */
|
|
215
|
+
mint: string;
|
|
216
|
+
/** Caller-controlled ed25519 pubkey that owns the asset. */
|
|
217
|
+
executive_pubkey: string;
|
|
218
|
+
name: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
image_url?: string;
|
|
221
|
+
services?: {
|
|
222
|
+
name: string;
|
|
223
|
+
endpoint: string;
|
|
224
|
+
}[];
|
|
225
|
+
network?: SvmNetwork;
|
|
226
|
+
};
|
|
227
|
+
export type RecordAgentResponse = {
|
|
228
|
+
mint: string;
|
|
229
|
+
treasury: string;
|
|
230
|
+
executive_pubkey: string;
|
|
231
|
+
network: SvmNetwork;
|
|
232
|
+
receipts_service: string;
|
|
233
|
+
};
|
|
234
|
+
export type StableSymbol = 'USDC' | 'USDT' | 'USDG';
|
|
235
|
+
export type EndpointMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
236
|
+
export type PaymentLinkResponseTemplate = {
|
|
237
|
+
status: number;
|
|
238
|
+
mimeType: string;
|
|
239
|
+
body: string | Record<string, unknown>;
|
|
240
|
+
};
|
|
241
|
+
export type LeashFeeExtra = {
|
|
242
|
+
v: '1';
|
|
243
|
+
bps: number;
|
|
244
|
+
feeAuthority: string;
|
|
245
|
+
};
|
|
246
|
+
export type PaymentLinkAcceptsEntry = {
|
|
247
|
+
scheme: 'exact';
|
|
248
|
+
network: string;
|
|
249
|
+
pay_to: string;
|
|
250
|
+
asset: string;
|
|
251
|
+
amount: string;
|
|
252
|
+
currency: StableSymbol;
|
|
253
|
+
fee_amount: string;
|
|
254
|
+
gross_amount: string;
|
|
255
|
+
fee_bps: number;
|
|
256
|
+
fee_authority: string;
|
|
257
|
+
leash_fee: LeashFeeExtra;
|
|
258
|
+
};
|
|
259
|
+
export type PaymentLink = {
|
|
260
|
+
id: string;
|
|
261
|
+
network: SvmNetwork;
|
|
262
|
+
label: string;
|
|
263
|
+
description: string | null;
|
|
264
|
+
owner_agent: string;
|
|
265
|
+
owner_wallet: string | null;
|
|
266
|
+
pay_to: string;
|
|
267
|
+
method: EndpointMethod;
|
|
268
|
+
path: string;
|
|
269
|
+
price: string;
|
|
270
|
+
currency: StableSymbol;
|
|
271
|
+
accepts_currencies: StableSymbol[];
|
|
272
|
+
response: PaymentLinkResponseTemplate;
|
|
273
|
+
webhook_url: string | null;
|
|
274
|
+
wrap_receipt: boolean;
|
|
275
|
+
metadata: Record<string, unknown>;
|
|
276
|
+
facilitator: string;
|
|
277
|
+
share_url: string;
|
|
278
|
+
accepts: PaymentLinkAcceptsEntry[];
|
|
279
|
+
counters: {
|
|
280
|
+
call_count: number;
|
|
281
|
+
settled_count: number;
|
|
282
|
+
last_called_at: string | null;
|
|
283
|
+
last_settled_at: string | null;
|
|
284
|
+
last_tx_sig: string | null;
|
|
285
|
+
last_settled_amount_atomic: string | null;
|
|
286
|
+
last_settled_currency: string | null;
|
|
287
|
+
};
|
|
288
|
+
disabled_at: string | null;
|
|
289
|
+
created_at: string;
|
|
290
|
+
updated_at: string;
|
|
291
|
+
};
|
|
292
|
+
export type PaymentLinksListResponse = {
|
|
293
|
+
items: PaymentLink[];
|
|
294
|
+
next_cursor: string | null;
|
|
295
|
+
};
|
|
296
|
+
export type PaymentLinkCreateInput = {
|
|
297
|
+
id?: string;
|
|
298
|
+
label: string;
|
|
299
|
+
description?: string;
|
|
300
|
+
owner_agent: string;
|
|
301
|
+
owner_wallet?: string;
|
|
302
|
+
method?: EndpointMethod;
|
|
303
|
+
price: string;
|
|
304
|
+
currency?: StableSymbol;
|
|
305
|
+
accepts_currencies?: StableSymbol[];
|
|
306
|
+
response: PaymentLinkResponseTemplate;
|
|
307
|
+
webhook_url?: string;
|
|
308
|
+
wrap_receipt?: boolean;
|
|
309
|
+
metadata?: Record<string, unknown>;
|
|
310
|
+
};
|
|
311
|
+
export type PaymentLinkPatchInput = Partial<{
|
|
312
|
+
label: string;
|
|
313
|
+
description: string | null;
|
|
314
|
+
price: string;
|
|
315
|
+
currency: StableSymbol;
|
|
316
|
+
accepts_currencies: StableSymbol[];
|
|
317
|
+
response: PaymentLinkResponseTemplate;
|
|
318
|
+
webhook_url: string | null;
|
|
319
|
+
wrap_receipt: boolean;
|
|
320
|
+
metadata: Record<string, unknown>;
|
|
321
|
+
disabled: boolean;
|
|
322
|
+
}>;
|
|
323
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,YAAY,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;;OAMG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAC/C,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,mEAAmE;IACnE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM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WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,kBAAkB,CAAC,EAAE,YAAY,EAAE,CAAC;IACpC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,kBAAkB,EAAE,YAAY,EAAE,CAAC;IACnC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared response types mirroring the public Leash API.
|
|
3
|
+
*
|
|
4
|
+
* These shapes are derived by hand from the OpenAPI doc the API
|
|
5
|
+
* already serves at `/openapi.json`. We could auto-generate from
|
|
6
|
+
* that source, but hand-rolling keeps the SDK runtime-light (zero
|
|
7
|
+
* extra deps) and lets us rename fields when ergonomics improve.
|
|
8
|
+
*
|
|
9
|
+
* The shapes here are a strict subset of what the API returns —
|
|
10
|
+
* fields you don't see are still present on the wire and reachable
|
|
11
|
+
* via `as unknown as` for forward-compat.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"publishConfig": {
|
|
3
|
+
"access": "public"
|
|
4
|
+
},
|
|
5
|
+
"name": "@leashmarket/sdk",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"description": "Typed Leash API client for app developers. Discover services, vet counterparties, manage agent webhooks, and ingest receipts in any TypeScript runtime.",
|
|
8
|
+
"private": false,
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@metaplex-foundation/umi": "^1.5.1",
|
|
24
|
+
"@metaplex-foundation/umi-bundle-defaults": "^1.5.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.10.2",
|
|
28
|
+
"tsx": "^4.20.0",
|
|
29
|
+
"typescript": "^5.7.2",
|
|
30
|
+
"vitest": "^2.1.8"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p tsconfig.build.json",
|
|
34
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
35
|
+
"lint": "echo lint:sdk",
|
|
36
|
+
"test": "vitest run"
|
|
37
|
+
}
|
|
38
|
+
}
|