@unicitylabs/sphere-sdk 0.1.2 → 0.1.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.
- package/dist/core/index.cjs +12 -16
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +12 -16
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +121 -677
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +121 -677
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs +673 -0
- package/dist/impl/browser/ipfs.cjs.map +1 -0
- package/dist/impl/browser/ipfs.js +640 -0
- package/dist/impl/browser/ipfs.js.map +1 -0
- package/dist/impl/nodejs/index.cjs +3 -0
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.js +3 -0
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +12 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -16
- package/dist/index.d.ts +12 -16
- package/dist/index.js +12 -16
- package/dist/index.js.map +1 -1
- package/package.json +11 -2
package/dist/core/index.cjs
CHANGED
|
@@ -5490,12 +5490,13 @@ var Sphere = class _Sphere {
|
|
|
5490
5490
|
*/
|
|
5491
5491
|
static async exists(storage) {
|
|
5492
5492
|
try {
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
5496
|
-
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
5497
|
-
return !!(mnemonic || masterKey);
|
|
5493
|
+
if (!storage.isConnected()) {
|
|
5494
|
+
await storage.connect();
|
|
5498
5495
|
}
|
|
5496
|
+
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
5497
|
+
if (mnemonic) return true;
|
|
5498
|
+
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
5499
|
+
if (masterKey) return true;
|
|
5499
5500
|
return false;
|
|
5500
5501
|
} catch {
|
|
5501
5502
|
return false;
|
|
@@ -5609,15 +5610,6 @@ var Sphere = class _Sphere {
|
|
|
5609
5610
|
await sphere.initializeProviders();
|
|
5610
5611
|
await sphere.initializeModules();
|
|
5611
5612
|
await sphere.syncNametagWithNostr();
|
|
5612
|
-
if (sphere._identity?.nametag && !sphere._payments.hasNametag()) {
|
|
5613
|
-
console.log(`[Sphere] Minting missing nametag token for @${sphere._identity.nametag}...`);
|
|
5614
|
-
const result = await sphere.mintNametag(sphere._identity.nametag);
|
|
5615
|
-
if (!result.success) {
|
|
5616
|
-
console.warn(`[Sphere] Failed to mint nametag token: ${result.error}`);
|
|
5617
|
-
} else {
|
|
5618
|
-
console.log(`[Sphere] Nametag token minted successfully`);
|
|
5619
|
-
}
|
|
5620
|
-
}
|
|
5621
5613
|
sphere._initialized = true;
|
|
5622
5614
|
_Sphere.instance = sphere;
|
|
5623
5615
|
return sphere;
|
|
@@ -6743,7 +6735,6 @@ var Sphere = class _Sphere {
|
|
|
6743
6735
|
const encryptedMasterKey = await this._storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
6744
6736
|
const chainCode = await this._storage.get(STORAGE_KEYS.CHAIN_CODE);
|
|
6745
6737
|
const derivationPath = await this._storage.get(STORAGE_KEYS.DERIVATION_PATH);
|
|
6746
|
-
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
6747
6738
|
const savedBasePath = await this._storage.get(STORAGE_KEYS.BASE_PATH);
|
|
6748
6739
|
const savedDerivationMode = await this._storage.get(STORAGE_KEYS.DERIVATION_MODE);
|
|
6749
6740
|
const savedSource = await this._storage.get(STORAGE_KEYS.WALLET_SOURCE);
|
|
@@ -6752,7 +6743,6 @@ var Sphere = class _Sphere {
|
|
|
6752
6743
|
this._derivationMode = savedDerivationMode ?? "bip32";
|
|
6753
6744
|
this._source = savedSource ?? "unknown";
|
|
6754
6745
|
this._currentAddressIndex = savedAddressIndex ? parseInt(savedAddressIndex, 10) : 0;
|
|
6755
|
-
await this.loadAddressNametags();
|
|
6756
6746
|
if (encryptedMnemonic) {
|
|
6757
6747
|
const mnemonic = this.decrypt(encryptedMnemonic);
|
|
6758
6748
|
if (!mnemonic) {
|
|
@@ -6778,6 +6768,11 @@ var Sphere = class _Sphere {
|
|
|
6778
6768
|
} else {
|
|
6779
6769
|
throw new Error("No wallet data found in storage");
|
|
6780
6770
|
}
|
|
6771
|
+
if (this._identity) {
|
|
6772
|
+
this._storage.setIdentity(this._identity);
|
|
6773
|
+
}
|
|
6774
|
+
await this.loadAddressNametags();
|
|
6775
|
+
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
6781
6776
|
if (this._currentAddressIndex > 0 && this._masterKey) {
|
|
6782
6777
|
const addressInfo = this.deriveAddress(this._currentAddressIndex, false);
|
|
6783
6778
|
const ipnsHash = sha256(addressInfo.publicKey, "hex").slice(0, 40);
|
|
@@ -6791,6 +6786,7 @@ var Sphere = class _Sphere {
|
|
|
6791
6786
|
ipnsName: "12D3KooW" + ipnsHash,
|
|
6792
6787
|
nametag
|
|
6793
6788
|
};
|
|
6789
|
+
this._storage.setIdentity(this._identity);
|
|
6794
6790
|
console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.address);
|
|
6795
6791
|
} else {
|
|
6796
6792
|
if (savedNametag && this._identity) {
|