@1sat/client 0.0.2 → 0.0.3

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.
Files changed (53) hide show
  1. package/dist/errors.d.ts +8 -0
  2. package/dist/errors.d.ts.map +1 -0
  3. package/dist/errors.js +12 -0
  4. package/dist/errors.js.map +1 -0
  5. package/dist/index.d.ts +3 -12
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -16
  8. package/dist/index.js.map +1 -1
  9. package/dist/services/ArcadeClient.d.ts +46 -0
  10. package/dist/services/ArcadeClient.d.ts.map +1 -0
  11. package/dist/services/ArcadeClient.js +108 -0
  12. package/dist/services/ArcadeClient.js.map +1 -0
  13. package/dist/services/BaseClient.d.ts +33 -0
  14. package/dist/services/BaseClient.d.ts.map +1 -0
  15. package/dist/services/BaseClient.js +126 -0
  16. package/dist/services/BaseClient.js.map +1 -0
  17. package/dist/services/BeefClient.d.ts +27 -0
  18. package/dist/services/BeefClient.d.ts.map +1 -0
  19. package/dist/services/BeefClient.js +34 -0
  20. package/dist/services/BeefClient.js.map +1 -0
  21. package/dist/services/Bsv21Client.d.ts +110 -0
  22. package/dist/services/Bsv21Client.d.ts.map +1 -0
  23. package/dist/services/Bsv21Client.js +155 -0
  24. package/dist/services/Bsv21Client.js.map +1 -0
  25. package/dist/services/ChaintracksClient.d.ts +105 -0
  26. package/dist/services/ChaintracksClient.d.ts.map +1 -0
  27. package/dist/services/ChaintracksClient.js +227 -0
  28. package/dist/services/ChaintracksClient.js.map +1 -0
  29. package/dist/services/OneSatServices.d.ts +81 -0
  30. package/dist/services/OneSatServices.d.ts.map +1 -0
  31. package/dist/services/OneSatServices.js +401 -0
  32. package/dist/services/OneSatServices.js.map +1 -0
  33. package/dist/services/OrdfsClient.d.ts +48 -0
  34. package/dist/services/OrdfsClient.d.ts.map +1 -0
  35. package/dist/services/OrdfsClient.js +124 -0
  36. package/dist/services/OrdfsClient.js.map +1 -0
  37. package/dist/services/OverlayClient.d.ts +50 -0
  38. package/dist/services/OverlayClient.d.ts.map +1 -0
  39. package/dist/services/OverlayClient.js +48 -0
  40. package/dist/services/OverlayClient.js.map +1 -0
  41. package/dist/services/OwnerClient.d.ts +42 -0
  42. package/dist/services/OwnerClient.d.ts.map +1 -0
  43. package/dist/services/OwnerClient.js +128 -0
  44. package/dist/services/OwnerClient.js.map +1 -0
  45. package/dist/services/TxoClient.d.ts +42 -0
  46. package/dist/services/TxoClient.d.ts.map +1 -0
  47. package/dist/services/TxoClient.js +95 -0
  48. package/dist/services/TxoClient.js.map +1 -0
  49. package/dist/services/index.d.ts +11 -0
  50. package/dist/services/index.d.ts.map +1 -0
  51. package/dist/services/index.js +11 -0
  52. package/dist/services/index.js.map +1 -0
  53. package/package.json +5 -6
@@ -0,0 +1,401 @@
1
+ import { ONESAT_MAINNET_URL, ONESAT_TESTNET_URL } from '@1sat/types';
2
+ import { Beef, Hash, MerklePath, Transaction, Utils, } from '@bsv/sdk';
3
+ import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OverlayClient, OwnerClient, TxoClient, } from './index';
4
+ /**
5
+ * Simple error class for WalletServices error responses.
6
+ */
7
+ class ServiceError extends Error {
8
+ code;
9
+ description;
10
+ isError = true;
11
+ constructor(code, description) {
12
+ super(description);
13
+ this.code = code;
14
+ this.description = description;
15
+ this.name = code;
16
+ }
17
+ }
18
+ /**
19
+ * WalletServices implementation for 1Sat ecosystem.
20
+ *
21
+ * Provides access to 1Sat API clients and implements the WalletServices
22
+ * interface required by wallet-toolbox.
23
+ *
24
+ * API Routes:
25
+ * - /1sat/chaintracks/* - Block headers and chain tracking
26
+ * - /1sat/beef/* - Raw transactions and proofs
27
+ * - /1sat/arcade/* - Transaction broadcasting
28
+ * - /1sat/bsv21/* - BSV21 token data
29
+ * - /1sat/txo/* - Transaction outputs
30
+ * - /1sat/owner/* - Address queries and sync
31
+ * - /1sat/ordfs/* - Content/inscription serving
32
+ * - /overlay/* - Overlay services (topic managers, lookups)
33
+ */
34
+ export class OneSatServices {
35
+ chain;
36
+ baseUrl;
37
+ // ===== API Clients =====
38
+ chaintracks;
39
+ beef;
40
+ arcade;
41
+ txo;
42
+ owner;
43
+ ordfs;
44
+ bsv21;
45
+ overlay;
46
+ // Optional fallback to wallet-toolbox Services for methods we don't implement
47
+ fallbackServices;
48
+ /**
49
+ * URL for wallet storage sync endpoint (BRC-100 JSON-RPC).
50
+ * Used by StorageClient for remote wallet backup/sync.
51
+ */
52
+ get storageUrl() {
53
+ return `${this.baseUrl}/1sat/wallet`;
54
+ }
55
+ constructor(chain, baseUrl, fallbackServices) {
56
+ this.fallbackServices = fallbackServices;
57
+ this.chain = chain;
58
+ this.baseUrl =
59
+ baseUrl || (chain === 'main' ? ONESAT_MAINNET_URL : ONESAT_TESTNET_URL);
60
+ const opts = { timeout: 30000 };
61
+ this.chaintracks = new ChaintracksClient(this.baseUrl, opts);
62
+ this.beef = new BeefClient(this.baseUrl, opts);
63
+ this.arcade = new ArcadeClient(this.baseUrl, opts);
64
+ this.txo = new TxoClient(this.baseUrl, opts);
65
+ this.owner = new OwnerClient(this.baseUrl, opts);
66
+ this.ordfs = new OrdfsClient(this.baseUrl, opts);
67
+ this.bsv21 = new Bsv21Client(this.baseUrl, opts);
68
+ this.overlay = new OverlayClient(this.baseUrl, opts);
69
+ }
70
+ // ===== Utility Methods =====
71
+ /**
72
+ * Get list of enabled capabilities from the server
73
+ */
74
+ async getCapabilities() {
75
+ const response = await fetch(`${this.baseUrl}/capabilities`);
76
+ if (!response.ok) {
77
+ throw new Error(`Failed to fetch capabilities: ${response.statusText}`);
78
+ }
79
+ return response.json();
80
+ }
81
+ /**
82
+ * Close all client connections
83
+ */
84
+ close() {
85
+ this.chaintracks.close();
86
+ }
87
+ // ===== WalletServices Interface (Required by wallet-toolbox) =====
88
+ async getRawTx(txid, _useNext) {
89
+ // This is a network-only call for the WalletServices interface.
90
+ // Wallet should check storage before calling this.
91
+ try {
92
+ const beefBytes = await this.beef.getBeef(txid);
93
+ const tx = Transaction.fromBEEF(Array.from(beefBytes));
94
+ return { txid, name: '1sat-api', rawTx: Array.from(tx.toBinary()) };
95
+ }
96
+ catch (error) {
97
+ return {
98
+ txid,
99
+ error: new ServiceError('NETWORK_ERROR', error instanceof Error ? error.message : 'Unknown error'),
100
+ };
101
+ }
102
+ }
103
+ async getChainTracker() {
104
+ return this.chaintracks;
105
+ }
106
+ async getHeaderForHeight(height) {
107
+ return this.chaintracks.getHeaderBytes(height);
108
+ }
109
+ async getHeight() {
110
+ return this.chaintracks.currentHeight();
111
+ }
112
+ async getMerklePath(txid, _useNext) {
113
+ console.log('[OneSatServices] getMerklePath called for txid:', txid);
114
+ try {
115
+ const proofBytes = await this.beef.getProof(txid);
116
+ const merklePath = MerklePath.fromBinary([...proofBytes]);
117
+ console.log('[OneSatServices] getMerklePath got proof, blockHeight:', merklePath.blockHeight);
118
+ // Fetch the block header for this merkle path
119
+ const header = await this.chaintracks.findHeaderForHeight(merklePath.blockHeight);
120
+ if (!header) {
121
+ console.log('[OneSatServices] getMerklePath header not found for height:', merklePath.blockHeight);
122
+ return {
123
+ name: '1sat-api',
124
+ error: new ServiceError('HEADER_NOT_FOUND', `Block header not found for height ${merklePath.blockHeight}`),
125
+ };
126
+ }
127
+ console.log('[OneSatServices] getMerklePath success, returning merklePath and header');
128
+ return { name: '1sat-api', merklePath, header };
129
+ }
130
+ catch (error) {
131
+ console.error('[OneSatServices] getMerklePath error:', error);
132
+ return {
133
+ name: '1sat-api',
134
+ error: new ServiceError('NETWORK_ERROR', error instanceof Error ? error.message : 'Unknown error'),
135
+ };
136
+ }
137
+ }
138
+ async postBeef(beef, txids, _logger) {
139
+ console.log('[OneSatServices] postBeef called with txids:', txids);
140
+ console.log(`[OneSatServices] BEEF structure:\n${beef.toLogString()}`);
141
+ const results = [];
142
+ for (const txid of txids) {
143
+ try {
144
+ // Submit as AtomicBEEF which includes all source transactions
145
+ console.log('[OneSatServices] Submitting tx to arcade:', txid);
146
+ const atomicBeef = beef.toBinaryAtomic(txid);
147
+ console.log('[OneSatServices] AtomicBEEF length:', atomicBeef.length, 'bytes');
148
+ // Parse back to verify structure
149
+ const verifyBeef = Beef.fromBinary(atomicBeef);
150
+ console.log(`[OneSatServices] AtomicBEEF parsed back:\n${verifyBeef.toLogString()}`);
151
+ // TODO: Remove hardcoded callback headers after server testing
152
+ const status = await this.arcade.submitTransaction(atomicBeef, {
153
+ callbackUrl: `${this.baseUrl}/1sat/arc/callback`,
154
+ callbackToken: 'test-callback-token',
155
+ });
156
+ console.log('[OneSatServices] Arcade response:', status);
157
+ if (status.txStatus === 'MINED' ||
158
+ status.txStatus === 'SEEN_ON_NETWORK' ||
159
+ status.txStatus === 'ACCEPTED_BY_NETWORK') {
160
+ results.push({
161
+ name: '1sat-api',
162
+ status: 'success',
163
+ txidResults: [{ txid: status.txid || txid, status: 'success' }],
164
+ });
165
+ }
166
+ else if (status.txStatus === 'REJECTED' ||
167
+ status.txStatus === 'DOUBLE_SPEND_ATTEMPTED') {
168
+ results.push({
169
+ name: '1sat-api',
170
+ status: 'error',
171
+ error: new ServiceError(status.txStatus, status.extraInfo || 'Transaction rejected'),
172
+ txidResults: [{ txid, status: 'error', data: status }],
173
+ });
174
+ }
175
+ else {
176
+ // Still processing - report as success since tx was accepted
177
+ results.push({
178
+ name: '1sat-api',
179
+ status: 'success',
180
+ txidResults: [{ txid: status.txid || txid, status: 'success' }],
181
+ });
182
+ }
183
+ }
184
+ catch (error) {
185
+ console.error('[OneSatServices] postBeef error:', error);
186
+ results.push({
187
+ name: '1sat-api',
188
+ status: 'error',
189
+ error: new ServiceError('NETWORK_ERROR', error instanceof Error ? error.message : 'Unknown error'),
190
+ txidResults: [{ txid, status: 'error' }],
191
+ });
192
+ }
193
+ }
194
+ return results;
195
+ }
196
+ async getBeefForTxid(txid) {
197
+ const beefBytes = await this.beef.getBeef(txid);
198
+ return Beef.fromBinary(Array.from(beefBytes));
199
+ }
200
+ hashOutputScript(script) {
201
+ const scriptBin = Utils.toArray(script, 'hex');
202
+ return Utils.toHex(Hash.hash256(scriptBin).reverse());
203
+ }
204
+ getServicesCallHistory(_reset) {
205
+ const emptyHistory = {
206
+ serviceName: '',
207
+ historyByProvider: {},
208
+ };
209
+ return {
210
+ version: 1,
211
+ getMerklePath: { ...emptyHistory, serviceName: 'getMerklePath' },
212
+ getRawTx: { ...emptyHistory, serviceName: 'getRawTx' },
213
+ postBeef: { ...emptyHistory, serviceName: 'postBeef' },
214
+ getUtxoStatus: { ...emptyHistory, serviceName: 'getUtxoStatus' },
215
+ getStatusForTxids: {
216
+ ...emptyHistory,
217
+ serviceName: 'getStatusForTxids',
218
+ },
219
+ getScriptHashHistory: {
220
+ ...emptyHistory,
221
+ serviceName: 'getScriptHashHistory',
222
+ },
223
+ updateFiatExchangeRates: {
224
+ ...emptyHistory,
225
+ serviceName: 'updateFiatExchangeRates',
226
+ },
227
+ };
228
+ }
229
+ // ===== WalletServices Interface (Delegated to fallback) =====
230
+ async getBsvExchangeRate() {
231
+ if (!this.fallbackServices) {
232
+ throw new Error('getBsvExchangeRate not implemented');
233
+ }
234
+ return this.fallbackServices.getBsvExchangeRate();
235
+ }
236
+ async getFiatExchangeRate(currency, base) {
237
+ if (!this.fallbackServices) {
238
+ throw new Error('getFiatExchangeRate not implemented');
239
+ }
240
+ return this.fallbackServices.getFiatExchangeRate(currency, base);
241
+ }
242
+ async getStatusForTxids(txids, _useNext) {
243
+ const results = [];
244
+ let currentHeight;
245
+ for (const txid of txids) {
246
+ try {
247
+ // Try Arcade first (only knows about txs broadcast through it)
248
+ const status = await this.arcade.getStatus(txid);
249
+ if (status.txStatus === 'MINED' || status.txStatus === 'IMMUTABLE') {
250
+ // Get current height for depth calculation if we haven't already
251
+ if (currentHeight === undefined) {
252
+ currentHeight = await this.getHeight();
253
+ }
254
+ const depth = status.blockHeight
255
+ ? currentHeight - status.blockHeight + 1
256
+ : 1;
257
+ results.push({ txid, status: 'mined', depth });
258
+ }
259
+ else if (status.txStatus === 'SEEN_ON_NETWORK' ||
260
+ status.txStatus === 'ACCEPTED_BY_NETWORK' ||
261
+ status.txStatus === 'SENT_TO_NETWORK' ||
262
+ status.txStatus === 'RECEIVED') {
263
+ results.push({ txid, status: 'known', depth: 0 });
264
+ }
265
+ else {
266
+ // REJECTED, DOUBLE_SPEND_ATTEMPTED, UNKNOWN - fall back to Beef
267
+ results.push(await this.getStatusFromBeef(txid));
268
+ }
269
+ }
270
+ catch {
271
+ // Arcade 404 or error - fall back to Beef storage
272
+ // NOTE: If Arcade's scope is too limited (only knows txs it broadcast),
273
+ // consider using Beef storage as the primary source instead.
274
+ results.push(await this.getStatusFromBeef(txid));
275
+ }
276
+ }
277
+ return {
278
+ name: '1sat-api',
279
+ status: 'success',
280
+ results,
281
+ };
282
+ }
283
+ /**
284
+ * Helper to get tx status from Beef storage (fallback when Arcade doesn't know the tx)
285
+ */
286
+ async getStatusFromBeef(txid) {
287
+ try {
288
+ const beefBytes = await this.beef.getBeef(txid);
289
+ const tx = Transaction.fromBEEF(Array.from(beefBytes));
290
+ if (tx.merklePath) {
291
+ // Has a valid merkle path = mined
292
+ const currentHeight = await this.getHeight();
293
+ const depth = currentHeight - tx.merklePath.blockHeight + 1;
294
+ return { txid, status: 'mined', depth };
295
+ }
296
+ // No merkle path = known but not yet mined
297
+ return { txid, status: 'known', depth: 0 };
298
+ }
299
+ catch {
300
+ // 404 or error from Beef = unknown
301
+ return { txid, status: 'unknown', depth: undefined };
302
+ }
303
+ }
304
+ async isUtxo(output) {
305
+ const outpoint = `${output.txid}_${output.vout}`;
306
+ const spendTxid = await this.txo.getSpend(outpoint);
307
+ return spendTxid === null;
308
+ }
309
+ async getUtxoStatus(_output, _outputFormat, outpoint, _useNext) {
310
+ // We ignore _output (script hash) since we look up directly by outpoint
311
+ if (!outpoint) {
312
+ return {
313
+ name: '1sat-api',
314
+ status: 'error',
315
+ error: new ServiceError('INVALID_PARAMETER', 'outpoint is required for getUtxoStatus'),
316
+ details: [],
317
+ };
318
+ }
319
+ try {
320
+ const txo = await this.txo.get(outpoint, {
321
+ sats: true,
322
+ spend: true,
323
+ block: true,
324
+ });
325
+ const isUtxo = !txo.spend;
326
+ const [txid, voutStr] = txo.outpoint.split('_');
327
+ const vout = Number.parseInt(voutStr, 10);
328
+ return {
329
+ name: '1sat-api',
330
+ status: 'success',
331
+ isUtxo,
332
+ details: isUtxo
333
+ ? [
334
+ {
335
+ txid,
336
+ index: vout,
337
+ satoshis: txo.satoshis,
338
+ height: txo.blockHeight,
339
+ },
340
+ ]
341
+ : [],
342
+ };
343
+ }
344
+ catch {
345
+ // TXO not found - treat as not a UTXO
346
+ return {
347
+ name: '1sat-api',
348
+ status: 'success',
349
+ isUtxo: false,
350
+ details: [],
351
+ };
352
+ }
353
+ }
354
+ async getScriptHashHistory(hash, useNext, logger) {
355
+ if (!this.fallbackServices) {
356
+ throw new Error('getScriptHashHistory not implemented');
357
+ }
358
+ return this.fallbackServices.getScriptHashHistory(hash, useNext, logger);
359
+ }
360
+ async hashToHeader(hash) {
361
+ const header = await this.chaintracks.findHeaderForBlockHash(hash);
362
+ if (!header) {
363
+ throw new Error(`Block header not found for hash: ${hash}`);
364
+ }
365
+ return header;
366
+ }
367
+ async nLockTimeIsFinal(txOrLockTime) {
368
+ const MAXINT = 0xffffffff;
369
+ const BLOCK_LIMIT = 500000000;
370
+ let nLockTime;
371
+ if (typeof txOrLockTime === 'number') {
372
+ nLockTime = txOrLockTime;
373
+ }
374
+ else {
375
+ let tx;
376
+ if (typeof txOrLockTime === 'string') {
377
+ tx = Transaction.fromHex(txOrLockTime);
378
+ }
379
+ else if (Array.isArray(txOrLockTime)) {
380
+ tx = Transaction.fromBinary(txOrLockTime);
381
+ }
382
+ else {
383
+ tx = txOrLockTime;
384
+ }
385
+ // If all inputs have max sequence, the transaction is final regardless of lockTime
386
+ if (tx.inputs.every((i) => i.sequence === MAXINT)) {
387
+ return true;
388
+ }
389
+ nLockTime = tx.lockTime;
390
+ }
391
+ // If lockTime >= BLOCK_LIMIT, it's a timestamp (seconds since epoch)
392
+ if (nLockTime >= BLOCK_LIMIT) {
393
+ const currentTime = Math.floor(Date.now() / 1000);
394
+ return nLockTime < currentTime;
395
+ }
396
+ // Otherwise, it's a block height
397
+ const height = await this.getHeight();
398
+ return nLockTime < height;
399
+ }
400
+ }
401
+ //# sourceMappingURL=OneSatServices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OneSatServices.js","sourceRoot":"","sources":["../../src/services/OneSatServices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EACN,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,WAAW,EACX,KAAK,GAEL,MAAM,UAAU,CAAA;AAEjB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,GACT,MAAM,SAAS,CAAA;AAgBhB;;GAEG;AACH,MAAM,YAAa,SAAQ,KAAK;IAIvB;IACA;IAJR,OAAO,GAAS,IAAI,CAAA;IAEpB,YACQ,IAAY,EACZ,WAAmB;QAE1B,KAAK,CAAC,WAAW,CAAC,CAAA;QAHX,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QAG1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;CACD;AAID;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IAC1B,KAAK,CAAO;IACH,OAAO,CAAQ;IAExB,0BAA0B;IACjB,WAAW,CAAmB;IAC9B,IAAI,CAAY;IAChB,MAAM,CAAc;IACpB,GAAG,CAAW;IACd,KAAK,CAAa;IAClB,KAAK,CAAa;IAClB,KAAK,CAAa;IAClB,OAAO,CAAe;IAE/B,8EAA8E;IACtE,gBAAgB,CAAiB;IAEzC;;;OAGG;IACH,IAAI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AC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxC,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;YAC1C,CAAC;iBAAM,CAAC;gBACP,EAAE,GAAG,YAAY,CAAA;YAClB,CAAC;YAED,mFAAmF;YACnF,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,CAAC;gBACnD,OAAO,IAAI,CAAA;YACZ,CAAC;YACD,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAA;QACxB,CAAC;QAED,qEAAqE;QACrE,IAAI,SAAS,IAAI,WAAW,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;YACjD,OAAO,SAAS,GAAG,WAAW,CAAA;QAC/B,CAAC;QAED,iCAAiC;QACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;QACrC,OAAO,SAAS,GAAG,MAAM,CAAA;IAC1B,CAAC;CACD"}
@@ -0,0 +1,48 @@
1
+ import type { ClientOptions, OrdfsContentOptions, OrdfsContentResponse, OrdfsMetadata } from '@1sat/types';
2
+ import { BaseClient } from './BaseClient';
3
+ /**
4
+ * Client for ordfs routes.
5
+ * Provides inscription content and metadata.
6
+ *
7
+ * Content is served from /content (e.g., https://1sat.shruggr.cloud/content/:outpoint)
8
+ * API routes use /1sat/ordfs (e.g., https://1sat.shruggr.cloud/1sat/ordfs/metadata/:outpoint)
9
+ */
10
+ export declare class OrdfsClient extends BaseClient {
11
+ private readonly contentBaseUrl;
12
+ constructor(baseUrl: string, options?: ClientOptions);
13
+ /**
14
+ * Get metadata for an inscription
15
+ * @param outpoint - Outpoint (txid_vout) or txid
16
+ * @param seq - Optional sequence number (-1 for latest)
17
+ */
18
+ getMetadata(outpoint: string, seq?: number): Promise<OrdfsMetadata>;
19
+ /**
20
+ * Get inscription content with full response headers
21
+ * @param outpoint - Outpoint (txid_vout) or txid
22
+ * @param options - Content request options
23
+ */
24
+ getContent(outpoint: string, options?: OrdfsContentOptions): Promise<OrdfsContentResponse>;
25
+ /**
26
+ * Preview base64-encoded HTML content
27
+ * @param b64HtmlData - Base64-encoded HTML
28
+ */
29
+ previewHtml(b64HtmlData: string): Promise<string>;
30
+ /**
31
+ * Preview content by posting it directly
32
+ * @param content - Content to preview
33
+ * @param contentType - Content type header
34
+ */
35
+ previewContent(content: Uint8Array, contentType: string): Promise<Uint8Array>;
36
+ /**
37
+ * Get the URL for fetching inscription content directly.
38
+ * Useful for displaying in img/video tags.
39
+ * @param outpoint - Outpoint (txid_vout) or txid
40
+ * @param options - Content request options
41
+ */
42
+ getContentUrl(outpoint: string, options?: OrdfsContentOptions): string;
43
+ /**
44
+ * Parse response headers into structured object
45
+ */
46
+ private parseResponseHeaders;
47
+ }
48
+ //# sourceMappingURL=OrdfsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrdfsClient.d.ts","sourceRoot":"","sources":["../../src/services/OrdfsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EAEb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,UAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;gBAE3B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAMxD;;;;OAIG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAKzE;;;;OAIG;IACG,UAAU,CACf,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,mBAAwB,GAC/B,OAAO,CAAC,oBAAoB,CAAC;IA0BhC;;;OAGG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKvD;;;;OAIG;IACG,cAAc,CACnB,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC;IAQtB;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM;IAe1E;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAgC5B"}
@@ -0,0 +1,124 @@
1
+ import { BaseClient } from './BaseClient';
2
+ /**
3
+ * Client for ordfs routes.
4
+ * Provides inscription content and metadata.
5
+ *
6
+ * Content is served from /content (e.g., https://1sat.shruggr.cloud/content/:outpoint)
7
+ * API routes use /1sat/ordfs (e.g., https://1sat.shruggr.cloud/1sat/ordfs/metadata/:outpoint)
8
+ */
9
+ export class OrdfsClient extends BaseClient {
10
+ contentBaseUrl;
11
+ constructor(baseUrl, options = {}) {
12
+ super(`${baseUrl}/1sat/ordfs`, options);
13
+ // Content is at root /content, not under /1sat/
14
+ this.contentBaseUrl = `${baseUrl.replace(/\/$/, '')}/content`;
15
+ }
16
+ /**
17
+ * Get metadata for an inscription
18
+ * @param outpoint - Outpoint (txid_vout) or txid
19
+ * @param seq - Optional sequence number (-1 for latest)
20
+ */
21
+ async getMetadata(outpoint, seq) {
22
+ const path = seq !== undefined ? `${outpoint}:${seq}` : outpoint;
23
+ return this.request(`/metadata/${path}`);
24
+ }
25
+ /**
26
+ * Get inscription content with full response headers
27
+ * @param outpoint - Outpoint (txid_vout) or txid
28
+ * @param options - Content request options
29
+ */
30
+ async getContent(outpoint, options = {}) {
31
+ const url = this.getContentUrl(outpoint, options);
32
+ const controller = new AbortController();
33
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
34
+ try {
35
+ const response = await this.fetchFn(url, {
36
+ signal: controller.signal,
37
+ });
38
+ if (!response.ok) {
39
+ throw new Error(`Failed to fetch content: ${response.statusText}`);
40
+ }
41
+ const headers = this.parseResponseHeaders(response);
42
+ const arrayBuffer = await response.arrayBuffer();
43
+ return {
44
+ data: new Uint8Array(arrayBuffer),
45
+ headers,
46
+ };
47
+ }
48
+ finally {
49
+ clearTimeout(timeoutId);
50
+ }
51
+ }
52
+ /**
53
+ * Preview base64-encoded HTML content
54
+ * @param b64HtmlData - Base64-encoded HTML
55
+ */
56
+ async previewHtml(b64HtmlData) {
57
+ const response = await this.requestRaw(`/preview/${b64HtmlData}`);
58
+ return response.text();
59
+ }
60
+ /**
61
+ * Preview content by posting it directly
62
+ * @param content - Content to preview
63
+ * @param contentType - Content type header
64
+ */
65
+ async previewContent(content, contentType) {
66
+ return this.requestBinary('/preview', {
67
+ method: 'POST',
68
+ headers: { 'Content-Type': contentType },
69
+ body: content,
70
+ });
71
+ }
72
+ /**
73
+ * Get the URL for fetching inscription content directly.
74
+ * Useful for displaying in img/video tags.
75
+ * @param outpoint - Outpoint (txid_vout) or txid
76
+ * @param options - Content request options
77
+ */
78
+ getContentUrl(outpoint, options = {}) {
79
+ let path = outpoint;
80
+ if (options.seq !== undefined) {
81
+ path = `${outpoint}:${options.seq}`;
82
+ }
83
+ const queryParams = this.buildQueryString({
84
+ map: options.map,
85
+ parent: options.parent,
86
+ raw: options.raw,
87
+ });
88
+ return `${this.contentBaseUrl}/${path}${queryParams}`;
89
+ }
90
+ /**
91
+ * Parse response headers into structured object
92
+ */
93
+ parseResponseHeaders(response) {
94
+ const headers = {
95
+ contentType: response.headers.get('content-type') || 'application/octet-stream',
96
+ };
97
+ const outpoint = response.headers.get('x-outpoint');
98
+ if (outpoint)
99
+ headers.outpoint = outpoint;
100
+ const origin = response.headers.get('x-origin');
101
+ if (origin)
102
+ headers.origin = origin;
103
+ const seq = response.headers.get('x-ord-seq');
104
+ if (seq)
105
+ headers.sequence = Number.parseInt(seq, 10);
106
+ const cacheControl = response.headers.get('cache-control');
107
+ if (cacheControl)
108
+ headers.cacheControl = cacheControl;
109
+ const mapData = response.headers.get('x-map');
110
+ if (mapData) {
111
+ try {
112
+ headers.map = JSON.parse(mapData);
113
+ }
114
+ catch {
115
+ // Invalid JSON, skip
116
+ }
117
+ }
118
+ const parent = response.headers.get('x-parent');
119
+ if (parent)
120
+ headers.parent = parent;
121
+ return headers;
122
+ }
123
+ }
124
+ //# sourceMappingURL=OrdfsClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrdfsClient.js","sourceRoot":"","sources":["../../src/services/OrdfsClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IACzB,cAAc,CAAQ;IAEvC,YAAY,OAAe,EAAE,UAAyB,EAAE;QACvD,KAAK,CAAC,GAAG,OAAO,aAAa,EAAE,OAAO,CAAC,CAAA;QACvC,gDAAgD;QAChD,IAAI,CAAC,cAAc,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAA;IAC9D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,QAAgB,EAAE,GAAY;QAC/C,MAAM,IAAI,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAA;QAChE,OAAO,IAAI,CAAC,OAAO,CAAgB,aAAa,IAAI,EAAE,CAAC,CAAA;IACxD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CACf,QAAgB,EAChB,UAA+B,EAAE;QAEjC,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACjD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;QACxC,MAAM,SAAS,GAAG,UAAU,CAAC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AAI,CAAC;gBACJ,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAClC,CAAC;YAAC,MAAM,CAAC;gBACR,qBAAqB;YACtB,CAAC;QACF,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC/C,IAAI,MAAM;YAAE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;QAEnC,OAAO,OAAO,CAAA;IACf,CAAC;CACD"}
@@ -0,0 +1,50 @@
1
+ import type { ClientOptions } from '@1sat/types';
2
+ import { BaseClient } from './BaseClient';
3
+ /** Topic manager metadata returned by listTopicManagers */
4
+ export interface TopicManagerInfo {
5
+ name?: string;
6
+ description?: string;
7
+ icon?: string;
8
+ [key: string]: unknown;
9
+ }
10
+ /** Lookup service provider metadata returned by listLookupServiceProviders */
11
+ export interface LookupServiceInfo {
12
+ [key: string]: unknown;
13
+ }
14
+ /**
15
+ * Client for overlay service routes.
16
+ * Handles topic manager queries and overlay lookups.
17
+ */
18
+ export declare class OverlayClient extends BaseClient {
19
+ constructor(baseUrl: string, options?: ClientOptions);
20
+ /**
21
+ * List all registered topic managers.
22
+ */
23
+ listTopicManagers(): Promise<Record<string, TopicManagerInfo>>;
24
+ /**
25
+ * List all registered lookup service providers.
26
+ */
27
+ listLookupServiceProviders(): Promise<Record<string, LookupServiceInfo>>;
28
+ /**
29
+ * Submit a transaction to the overlay service for indexing.
30
+ * @param beef - BEEF data as Uint8Array or number[]
31
+ * @param topics - Topic names to submit to (e.g., ["tm_tokenId"])
32
+ */
33
+ submit(beef: Uint8Array | number[], topics: string[]): Promise<{
34
+ status: string;
35
+ txid?: string;
36
+ message?: string;
37
+ }>;
38
+ /**
39
+ * Submit a BSV-21 token transaction to the overlay.
40
+ * Convenience method that formats the topic correctly.
41
+ * @param beef - BEEF data
42
+ * @param tokenId - Token ID (txid_vout format)
43
+ */
44
+ submitBsv21(beef: Uint8Array | number[], tokenId: string): Promise<{
45
+ status: string;
46
+ txid?: string;
47
+ message?: string;
48
+ }>;
49
+ }
50
+ //# sourceMappingURL=OverlayClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayClient.d.ts","sourceRoot":"","sources":["../../src/services/OverlayClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACtB;AAED,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACtB;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,UAAU;gBAChC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAIxD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAMpE;;OAEG;IACG,0BAA0B,IAAI,OAAO,CAC1C,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CACjC;IAMD;;;;OAIG;IACG,MAAM,CACX,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,EAC3B,MAAM,EAAE,MAAM,EAAE,GACd,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAgB/D;;;;;OAKG;IACG,WAAW,CAChB,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,EAC3B,OAAO,EAAE,MAAM,GACb,OAAO,CAAC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