@1sat/wallet-toolbox 0.0.57 → 0.0.58

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.
@@ -378,7 +378,18 @@ export const transferOrdinals = {
378
378
  if (!ordinal.customInstructions) {
379
379
  return { error: `missing-custom-instructions-for-${ordinal.outpoint}` };
380
380
  }
381
- const { protocolID, keyID } = JSON.parse(ordinal.customInstructions);
381
+ // Parse and validate customInstructions
382
+ let parsed;
383
+ try {
384
+ parsed = JSON.parse(ordinal.customInstructions);
385
+ }
386
+ catch {
387
+ return { error: `invalid-custom-instructions-not-json-for-${ordinal.outpoint}` };
388
+ }
389
+ const { protocolID, keyID } = parsed;
390
+ if (!protocolID || !keyID) {
391
+ return { error: `invalid-custom-instructions-missing-protocol-or-key-for-${ordinal.outpoint}` };
392
+ }
382
393
  console.log(`[transferOrdinals] Input ${i}: protocolID=${JSON.stringify(protocolID)}, keyID=${keyID}`);
383
394
  const unlocking = await signP2PKHInput(ctx, tx, i, protocolID, keyID);
384
395
  if (typeof unlocking !== "string")
@@ -28,6 +28,8 @@ export interface WebWalletConfig {
28
28
  };
29
29
  /** Remote storage URL. If provided, attempts to connect for cloud backup. */
30
30
  remoteStorageUrl?: string;
31
+ /** Device ID for sync isolation. Each device should have a unique ID to prevent sync corruption. */
32
+ deviceId?: string;
31
33
  /** Callback when a transaction is broadcasted (called after remote sync if connected) */
32
34
  onTransactionBroadcasted?: (txid: string) => void;
33
35
  /** Callback when a transaction is proven (called after remote sync if connected) */
@@ -89,7 +89,8 @@ export async function createWebWallet(config) {
89
89
  try {
90
90
  // Create StorageClient with the REAL wallet (not a temp wallet)
91
91
  // StorageClient captures the wallet at construction for signing requests
92
- remoteClient = new StorageClient(underlyingWallet, config.remoteStorageUrl);
92
+ // deviceId isolates sync state per device to prevent ID mapping corruption
93
+ remoteClient = new StorageClient(underlyingWallet, config.remoteStorageUrl, config.deviceId);
93
94
  const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error("Remote storage connection timeout")), DEFAULT_REMOTE_STORAGE_TIMEOUT));
94
95
  await Promise.race([remoteClient.makeAvailable(), timeoutPromise]);
95
96
  // Add remote storage to the existing storage manager using public API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.57",
3
+ "version": "0.0.58",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",
@@ -38,14 +38,14 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@1sat/wallet-toolbox": "0.0.52",
41
- "@bopen-io/templates": "^1.1.6",
42
- "@bsv/sdk": "^1.10.1",
41
+ "@bopen-io/templates": "^1.1.7",
42
+ "@bsv/sdk": "^1.10.2",
43
43
  "@msgpack/msgpack": "^3.1.3",
44
44
  "buffer": "^6.0.3",
45
45
  "fflate": "^0.8.2"
46
46
  },
47
47
  "peerDependencies": {
48
- "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.30"
48
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.22-idb-fix.1"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "@bsv/wallet-toolbox-mobile": {
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@biomejs/biome": "^1.9.4",
57
- "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.30",
58
- "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.30",
57
+ "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.22-idb-fix.1",
58
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.22-idb-fix.1",
59
59
  "@types/bun": "^1.3.4",
60
60
  "@types/chrome": "^0.1.32",
61
61
  "typescript": "^5.9.3"