@unicitylabs/sphere-sdk 0.1.8 → 0.1.9
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/dist/core/index.cjs +41 -7
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +25 -3
- package/dist/core/index.d.ts +25 -3
- package/dist/core/index.js +41 -7
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +9 -6
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +9 -6
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +23 -6
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +1 -0
- package/dist/impl/nodejs/index.d.ts +1 -0
- package/dist/impl/nodejs/index.js +23 -6
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +41 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -10
- package/dist/index.d.ts +66 -10
- package/dist/index.js +41 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -276,6 +276,7 @@ declare class FileTokenStorageProvider implements TokenStorageProvider<TxfStorag
|
|
|
276
276
|
load(): Promise<LoadResult<TxfStorageDataBase>>;
|
|
277
277
|
save(data: TxfStorageDataBase): Promise<SaveResult>;
|
|
278
278
|
sync(localData: TxfStorageDataBase): Promise<SyncResult<TxfStorageDataBase>>;
|
|
279
|
+
clear(): Promise<boolean>;
|
|
279
280
|
deleteToken(tokenId: string): Promise<void>;
|
|
280
281
|
saveToken(tokenId: string, tokenData: unknown): Promise<void>;
|
|
281
282
|
getToken(tokenId: string): Promise<unknown | null>;
|
|
@@ -276,6 +276,7 @@ declare class FileTokenStorageProvider implements TokenStorageProvider<TxfStorag
|
|
|
276
276
|
load(): Promise<LoadResult<TxfStorageDataBase>>;
|
|
277
277
|
save(data: TxfStorageDataBase): Promise<SaveResult>;
|
|
278
278
|
sync(localData: TxfStorageDataBase): Promise<SyncResult<TxfStorageDataBase>>;
|
|
279
|
+
clear(): Promise<boolean>;
|
|
279
280
|
deleteToken(tokenId: string): Promise<void>;
|
|
280
281
|
saveToken(tokenId: string, tokenData: unknown): Promise<void>;
|
|
281
282
|
getToken(tokenId: string): Promise<unknown | null>;
|
|
@@ -382,6 +382,20 @@ var FileTokenStorageProvider = class {
|
|
|
382
382
|
error: saveResult.error
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
+
async clear() {
|
|
386
|
+
try {
|
|
387
|
+
if (!fs2.existsSync(this.tokensDir)) {
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
const files = fs2.readdirSync(this.tokensDir).filter((f) => f.endsWith(".json"));
|
|
391
|
+
for (const file of files) {
|
|
392
|
+
fs2.unlinkSync(path2.join(this.tokensDir, file));
|
|
393
|
+
}
|
|
394
|
+
return true;
|
|
395
|
+
} catch {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
385
399
|
async deleteToken(tokenId) {
|
|
386
400
|
const filePath = path2.join(this.tokensDir, `${tokenId}.json`);
|
|
387
401
|
if (fs2.existsSync(filePath)) {
|
|
@@ -1443,15 +1457,17 @@ var NostrTransportProvider = class {
|
|
|
1443
1457
|
const bindingEvent = events[0];
|
|
1444
1458
|
try {
|
|
1445
1459
|
const content = JSON.parse(bindingEvent.content);
|
|
1460
|
+
const { ProxyAddress } = await import("@unicitylabs/state-transition-sdk/lib/address/ProxyAddress");
|
|
1461
|
+
const proxyAddr = await ProxyAddress.fromNameTag(nametag);
|
|
1462
|
+
const proxyAddress = proxyAddr.toString();
|
|
1446
1463
|
if (content.public_key && content.l1_address) {
|
|
1447
|
-
const l3Address = `PROXY:${hashedNametag}`;
|
|
1448
1464
|
return {
|
|
1449
1465
|
nametag,
|
|
1450
1466
|
transportPubkey: bindingEvent.pubkey,
|
|
1451
1467
|
chainPubkey: content.public_key,
|
|
1452
1468
|
l1Address: content.l1_address,
|
|
1453
1469
|
directAddress: content.direct_address || "",
|
|
1454
|
-
proxyAddress
|
|
1470
|
+
proxyAddress,
|
|
1455
1471
|
timestamp: bindingEvent.created_at * 1e3
|
|
1456
1472
|
};
|
|
1457
1473
|
}
|
|
@@ -1459,14 +1475,13 @@ var NostrTransportProvider = class {
|
|
|
1459
1475
|
const pubkeyTag = bindingEvent.tags.find((t) => t[0] === "pubkey");
|
|
1460
1476
|
const l1Tag = bindingEvent.tags.find((t) => t[0] === "l1");
|
|
1461
1477
|
if (pubkeyTag?.[1] && l1Tag?.[1]) {
|
|
1462
|
-
const l3Address = `PROXY:${hashedNametag}`;
|
|
1463
1478
|
return {
|
|
1464
1479
|
nametag,
|
|
1465
1480
|
transportPubkey: bindingEvent.pubkey,
|
|
1466
1481
|
chainPubkey: pubkeyTag[1],
|
|
1467
1482
|
l1Address: l1Tag[1],
|
|
1468
1483
|
directAddress: "",
|
|
1469
|
-
proxyAddress
|
|
1484
|
+
proxyAddress,
|
|
1470
1485
|
timestamp: bindingEvent.created_at * 1e3
|
|
1471
1486
|
};
|
|
1472
1487
|
}
|
|
@@ -1478,17 +1493,19 @@ var NostrTransportProvider = class {
|
|
|
1478
1493
|
l1Address: "",
|
|
1479
1494
|
// Cannot derive without 33-byte pubkey
|
|
1480
1495
|
directAddress: "",
|
|
1481
|
-
proxyAddress
|
|
1496
|
+
proxyAddress,
|
|
1482
1497
|
timestamp: bindingEvent.created_at * 1e3
|
|
1483
1498
|
};
|
|
1484
1499
|
} catch {
|
|
1500
|
+
const { ProxyAddress } = await import("@unicitylabs/state-transition-sdk/lib/address/ProxyAddress");
|
|
1501
|
+
const proxyAddr = await ProxyAddress.fromNameTag(nametag);
|
|
1485
1502
|
return {
|
|
1486
1503
|
nametag,
|
|
1487
1504
|
transportPubkey: bindingEvent.pubkey,
|
|
1488
1505
|
chainPubkey: "",
|
|
1489
1506
|
l1Address: "",
|
|
1490
1507
|
directAddress: "",
|
|
1491
|
-
proxyAddress:
|
|
1508
|
+
proxyAddress: proxyAddr.toString(),
|
|
1492
1509
|
timestamp: bindingEvent.created_at * 1e3
|
|
1493
1510
|
};
|
|
1494
1511
|
}
|