@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/index.cjs
CHANGED
|
@@ -5773,12 +5773,13 @@ var Sphere = class _Sphere {
|
|
|
5773
5773
|
*/
|
|
5774
5774
|
static async exists(storage) {
|
|
5775
5775
|
try {
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
5779
|
-
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
5780
|
-
return !!(mnemonic || masterKey);
|
|
5776
|
+
if (!storage.isConnected()) {
|
|
5777
|
+
await storage.connect();
|
|
5781
5778
|
}
|
|
5779
|
+
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
5780
|
+
if (mnemonic) return true;
|
|
5781
|
+
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
5782
|
+
if (masterKey) return true;
|
|
5782
5783
|
return false;
|
|
5783
5784
|
} catch {
|
|
5784
5785
|
return false;
|
|
@@ -5892,15 +5893,6 @@ var Sphere = class _Sphere {
|
|
|
5892
5893
|
await sphere.initializeProviders();
|
|
5893
5894
|
await sphere.initializeModules();
|
|
5894
5895
|
await sphere.syncNametagWithNostr();
|
|
5895
|
-
if (sphere._identity?.nametag && !sphere._payments.hasNametag()) {
|
|
5896
|
-
console.log(`[Sphere] Minting missing nametag token for @${sphere._identity.nametag}...`);
|
|
5897
|
-
const result = await sphere.mintNametag(sphere._identity.nametag);
|
|
5898
|
-
if (!result.success) {
|
|
5899
|
-
console.warn(`[Sphere] Failed to mint nametag token: ${result.error}`);
|
|
5900
|
-
} else {
|
|
5901
|
-
console.log(`[Sphere] Nametag token minted successfully`);
|
|
5902
|
-
}
|
|
5903
|
-
}
|
|
5904
5896
|
sphere._initialized = true;
|
|
5905
5897
|
_Sphere.instance = sphere;
|
|
5906
5898
|
return sphere;
|
|
@@ -7026,7 +7018,6 @@ var Sphere = class _Sphere {
|
|
|
7026
7018
|
const encryptedMasterKey = await this._storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
7027
7019
|
const chainCode = await this._storage.get(STORAGE_KEYS.CHAIN_CODE);
|
|
7028
7020
|
const derivationPath = await this._storage.get(STORAGE_KEYS.DERIVATION_PATH);
|
|
7029
|
-
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
7030
7021
|
const savedBasePath = await this._storage.get(STORAGE_KEYS.BASE_PATH);
|
|
7031
7022
|
const savedDerivationMode = await this._storage.get(STORAGE_KEYS.DERIVATION_MODE);
|
|
7032
7023
|
const savedSource = await this._storage.get(STORAGE_KEYS.WALLET_SOURCE);
|
|
@@ -7035,7 +7026,6 @@ var Sphere = class _Sphere {
|
|
|
7035
7026
|
this._derivationMode = savedDerivationMode ?? "bip32";
|
|
7036
7027
|
this._source = savedSource ?? "unknown";
|
|
7037
7028
|
this._currentAddressIndex = savedAddressIndex ? parseInt(savedAddressIndex, 10) : 0;
|
|
7038
|
-
await this.loadAddressNametags();
|
|
7039
7029
|
if (encryptedMnemonic) {
|
|
7040
7030
|
const mnemonic = this.decrypt(encryptedMnemonic);
|
|
7041
7031
|
if (!mnemonic) {
|
|
@@ -7061,6 +7051,11 @@ var Sphere = class _Sphere {
|
|
|
7061
7051
|
} else {
|
|
7062
7052
|
throw new Error("No wallet data found in storage");
|
|
7063
7053
|
}
|
|
7054
|
+
if (this._identity) {
|
|
7055
|
+
this._storage.setIdentity(this._identity);
|
|
7056
|
+
}
|
|
7057
|
+
await this.loadAddressNametags();
|
|
7058
|
+
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
7064
7059
|
if (this._currentAddressIndex > 0 && this._masterKey) {
|
|
7065
7060
|
const addressInfo = this.deriveAddress(this._currentAddressIndex, false);
|
|
7066
7061
|
const ipnsHash = sha256(addressInfo.publicKey, "hex").slice(0, 40);
|
|
@@ -7074,6 +7069,7 @@ var Sphere = class _Sphere {
|
|
|
7074
7069
|
ipnsName: "12D3KooW" + ipnsHash,
|
|
7075
7070
|
nametag
|
|
7076
7071
|
};
|
|
7072
|
+
this._storage.setIdentity(this._identity);
|
|
7077
7073
|
console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.address);
|
|
7078
7074
|
} else {
|
|
7079
7075
|
if (savedNametag && this._identity) {
|