@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.d.cts
CHANGED
|
@@ -8670,12 +8670,13 @@ var Sphere = class _Sphere {
|
|
|
8670
8670
|
*/
|
|
8671
8671
|
static async exists(storage) {
|
|
8672
8672
|
try {
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
8676
|
-
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
8677
|
-
return !!(mnemonic || masterKey);
|
|
8673
|
+
if (!storage.isConnected()) {
|
|
8674
|
+
await storage.connect();
|
|
8678
8675
|
}
|
|
8676
|
+
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
8677
|
+
if (mnemonic) return true;
|
|
8678
|
+
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
8679
|
+
if (masterKey) return true;
|
|
8679
8680
|
return false;
|
|
8680
8681
|
} catch {
|
|
8681
8682
|
return false;
|
|
@@ -8789,15 +8790,6 @@ var Sphere = class _Sphere {
|
|
|
8789
8790
|
await sphere.initializeProviders();
|
|
8790
8791
|
await sphere.initializeModules();
|
|
8791
8792
|
await sphere.syncNametagWithNostr();
|
|
8792
|
-
if (sphere._identity?.nametag && !sphere._payments.hasNametag()) {
|
|
8793
|
-
console.log(`[Sphere] Minting missing nametag token for @${sphere._identity.nametag}...`);
|
|
8794
|
-
const result = await sphere.mintNametag(sphere._identity.nametag);
|
|
8795
|
-
if (!result.success) {
|
|
8796
|
-
console.warn(`[Sphere] Failed to mint nametag token: ${result.error}`);
|
|
8797
|
-
} else {
|
|
8798
|
-
console.log(`[Sphere] Nametag token minted successfully`);
|
|
8799
|
-
}
|
|
8800
|
-
}
|
|
8801
8793
|
sphere._initialized = true;
|
|
8802
8794
|
_Sphere.instance = sphere;
|
|
8803
8795
|
return sphere;
|
|
@@ -9923,7 +9915,6 @@ var Sphere = class _Sphere {
|
|
|
9923
9915
|
const encryptedMasterKey = await this._storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
9924
9916
|
const chainCode = await this._storage.get(STORAGE_KEYS.CHAIN_CODE);
|
|
9925
9917
|
const derivationPath = await this._storage.get(STORAGE_KEYS.DERIVATION_PATH);
|
|
9926
|
-
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
9927
9918
|
const savedBasePath = await this._storage.get(STORAGE_KEYS.BASE_PATH);
|
|
9928
9919
|
const savedDerivationMode = await this._storage.get(STORAGE_KEYS.DERIVATION_MODE);
|
|
9929
9920
|
const savedSource = await this._storage.get(STORAGE_KEYS.WALLET_SOURCE);
|
|
@@ -9932,7 +9923,6 @@ var Sphere = class _Sphere {
|
|
|
9932
9923
|
this._derivationMode = savedDerivationMode ?? "bip32";
|
|
9933
9924
|
this._source = savedSource ?? "unknown";
|
|
9934
9925
|
this._currentAddressIndex = savedAddressIndex ? parseInt(savedAddressIndex, 10) : 0;
|
|
9935
|
-
await this.loadAddressNametags();
|
|
9936
9926
|
if (encryptedMnemonic) {
|
|
9937
9927
|
const mnemonic = this.decrypt(encryptedMnemonic);
|
|
9938
9928
|
if (!mnemonic) {
|
|
@@ -9958,6 +9948,11 @@ var Sphere = class _Sphere {
|
|
|
9958
9948
|
} else {
|
|
9959
9949
|
throw new Error("No wallet data found in storage");
|
|
9960
9950
|
}
|
|
9951
|
+
if (this._identity) {
|
|
9952
|
+
this._storage.setIdentity(this._identity);
|
|
9953
|
+
}
|
|
9954
|
+
await this.loadAddressNametags();
|
|
9955
|
+
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
9961
9956
|
if (this._currentAddressIndex > 0 && this._masterKey) {
|
|
9962
9957
|
const addressInfo = this.deriveAddress(this._currentAddressIndex, false);
|
|
9963
9958
|
const ipnsHash = sha256(addressInfo.publicKey, "hex").slice(0, 40);
|
|
@@ -9971,6 +9966,7 @@ var Sphere = class _Sphere {
|
|
|
9971
9966
|
ipnsName: "12D3KooW" + ipnsHash,
|
|
9972
9967
|
nametag
|
|
9973
9968
|
};
|
|
9969
|
+
this._storage.setIdentity(this._identity);
|
|
9974
9970
|
console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.address);
|
|
9975
9971
|
} else {
|
|
9976
9972
|
if (savedNametag && this._identity) {
|
package/dist/index.d.ts
CHANGED
|
@@ -8670,12 +8670,13 @@ var Sphere = class _Sphere {
|
|
|
8670
8670
|
*/
|
|
8671
8671
|
static async exists(storage) {
|
|
8672
8672
|
try {
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
8676
|
-
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
8677
|
-
return !!(mnemonic || masterKey);
|
|
8673
|
+
if (!storage.isConnected()) {
|
|
8674
|
+
await storage.connect();
|
|
8678
8675
|
}
|
|
8676
|
+
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
8677
|
+
if (mnemonic) return true;
|
|
8678
|
+
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
8679
|
+
if (masterKey) return true;
|
|
8679
8680
|
return false;
|
|
8680
8681
|
} catch {
|
|
8681
8682
|
return false;
|
|
@@ -8789,15 +8790,6 @@ var Sphere = class _Sphere {
|
|
|
8789
8790
|
await sphere.initializeProviders();
|
|
8790
8791
|
await sphere.initializeModules();
|
|
8791
8792
|
await sphere.syncNametagWithNostr();
|
|
8792
|
-
if (sphere._identity?.nametag && !sphere._payments.hasNametag()) {
|
|
8793
|
-
console.log(`[Sphere] Minting missing nametag token for @${sphere._identity.nametag}...`);
|
|
8794
|
-
const result = await sphere.mintNametag(sphere._identity.nametag);
|
|
8795
|
-
if (!result.success) {
|
|
8796
|
-
console.warn(`[Sphere] Failed to mint nametag token: ${result.error}`);
|
|
8797
|
-
} else {
|
|
8798
|
-
console.log(`[Sphere] Nametag token minted successfully`);
|
|
8799
|
-
}
|
|
8800
|
-
}
|
|
8801
8793
|
sphere._initialized = true;
|
|
8802
8794
|
_Sphere.instance = sphere;
|
|
8803
8795
|
return sphere;
|
|
@@ -9923,7 +9915,6 @@ var Sphere = class _Sphere {
|
|
|
9923
9915
|
const encryptedMasterKey = await this._storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
9924
9916
|
const chainCode = await this._storage.get(STORAGE_KEYS.CHAIN_CODE);
|
|
9925
9917
|
const derivationPath = await this._storage.get(STORAGE_KEYS.DERIVATION_PATH);
|
|
9926
|
-
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
9927
9918
|
const savedBasePath = await this._storage.get(STORAGE_KEYS.BASE_PATH);
|
|
9928
9919
|
const savedDerivationMode = await this._storage.get(STORAGE_KEYS.DERIVATION_MODE);
|
|
9929
9920
|
const savedSource = await this._storage.get(STORAGE_KEYS.WALLET_SOURCE);
|
|
@@ -9932,7 +9923,6 @@ var Sphere = class _Sphere {
|
|
|
9932
9923
|
this._derivationMode = savedDerivationMode ?? "bip32";
|
|
9933
9924
|
this._source = savedSource ?? "unknown";
|
|
9934
9925
|
this._currentAddressIndex = savedAddressIndex ? parseInt(savedAddressIndex, 10) : 0;
|
|
9935
|
-
await this.loadAddressNametags();
|
|
9936
9926
|
if (encryptedMnemonic) {
|
|
9937
9927
|
const mnemonic = this.decrypt(encryptedMnemonic);
|
|
9938
9928
|
if (!mnemonic) {
|
|
@@ -9958,6 +9948,11 @@ var Sphere = class _Sphere {
|
|
|
9958
9948
|
} else {
|
|
9959
9949
|
throw new Error("No wallet data found in storage");
|
|
9960
9950
|
}
|
|
9951
|
+
if (this._identity) {
|
|
9952
|
+
this._storage.setIdentity(this._identity);
|
|
9953
|
+
}
|
|
9954
|
+
await this.loadAddressNametags();
|
|
9955
|
+
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
9961
9956
|
if (this._currentAddressIndex > 0 && this._masterKey) {
|
|
9962
9957
|
const addressInfo = this.deriveAddress(this._currentAddressIndex, false);
|
|
9963
9958
|
const ipnsHash = sha256(addressInfo.publicKey, "hex").slice(0, 40);
|
|
@@ -9971,6 +9966,7 @@ var Sphere = class _Sphere {
|
|
|
9971
9966
|
ipnsName: "12D3KooW" + ipnsHash,
|
|
9972
9967
|
nametag
|
|
9973
9968
|
};
|
|
9969
|
+
this._storage.setIdentity(this._identity);
|
|
9974
9970
|
console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.address);
|
|
9975
9971
|
} else {
|
|
9976
9972
|
if (savedNametag && this._identity) {
|
package/dist/index.js
CHANGED
|
@@ -5650,12 +5650,13 @@ var Sphere = class _Sphere {
|
|
|
5650
5650
|
*/
|
|
5651
5651
|
static async exists(storage) {
|
|
5652
5652
|
try {
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
5656
|
-
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
5657
|
-
return !!(mnemonic || masterKey);
|
|
5653
|
+
if (!storage.isConnected()) {
|
|
5654
|
+
await storage.connect();
|
|
5658
5655
|
}
|
|
5656
|
+
const mnemonic = await storage.get(STORAGE_KEYS.MNEMONIC);
|
|
5657
|
+
if (mnemonic) return true;
|
|
5658
|
+
const masterKey = await storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
5659
|
+
if (masterKey) return true;
|
|
5659
5660
|
return false;
|
|
5660
5661
|
} catch {
|
|
5661
5662
|
return false;
|
|
@@ -5769,15 +5770,6 @@ var Sphere = class _Sphere {
|
|
|
5769
5770
|
await sphere.initializeProviders();
|
|
5770
5771
|
await sphere.initializeModules();
|
|
5771
5772
|
await sphere.syncNametagWithNostr();
|
|
5772
|
-
if (sphere._identity?.nametag && !sphere._payments.hasNametag()) {
|
|
5773
|
-
console.log(`[Sphere] Minting missing nametag token for @${sphere._identity.nametag}...`);
|
|
5774
|
-
const result = await sphere.mintNametag(sphere._identity.nametag);
|
|
5775
|
-
if (!result.success) {
|
|
5776
|
-
console.warn(`[Sphere] Failed to mint nametag token: ${result.error}`);
|
|
5777
|
-
} else {
|
|
5778
|
-
console.log(`[Sphere] Nametag token minted successfully`);
|
|
5779
|
-
}
|
|
5780
|
-
}
|
|
5781
5773
|
sphere._initialized = true;
|
|
5782
5774
|
_Sphere.instance = sphere;
|
|
5783
5775
|
return sphere;
|
|
@@ -6903,7 +6895,6 @@ var Sphere = class _Sphere {
|
|
|
6903
6895
|
const encryptedMasterKey = await this._storage.get(STORAGE_KEYS.MASTER_KEY);
|
|
6904
6896
|
const chainCode = await this._storage.get(STORAGE_KEYS.CHAIN_CODE);
|
|
6905
6897
|
const derivationPath = await this._storage.get(STORAGE_KEYS.DERIVATION_PATH);
|
|
6906
|
-
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
6907
6898
|
const savedBasePath = await this._storage.get(STORAGE_KEYS.BASE_PATH);
|
|
6908
6899
|
const savedDerivationMode = await this._storage.get(STORAGE_KEYS.DERIVATION_MODE);
|
|
6909
6900
|
const savedSource = await this._storage.get(STORAGE_KEYS.WALLET_SOURCE);
|
|
@@ -6912,7 +6903,6 @@ var Sphere = class _Sphere {
|
|
|
6912
6903
|
this._derivationMode = savedDerivationMode ?? "bip32";
|
|
6913
6904
|
this._source = savedSource ?? "unknown";
|
|
6914
6905
|
this._currentAddressIndex = savedAddressIndex ? parseInt(savedAddressIndex, 10) : 0;
|
|
6915
|
-
await this.loadAddressNametags();
|
|
6916
6906
|
if (encryptedMnemonic) {
|
|
6917
6907
|
const mnemonic = this.decrypt(encryptedMnemonic);
|
|
6918
6908
|
if (!mnemonic) {
|
|
@@ -6938,6 +6928,11 @@ var Sphere = class _Sphere {
|
|
|
6938
6928
|
} else {
|
|
6939
6929
|
throw new Error("No wallet data found in storage");
|
|
6940
6930
|
}
|
|
6931
|
+
if (this._identity) {
|
|
6932
|
+
this._storage.setIdentity(this._identity);
|
|
6933
|
+
}
|
|
6934
|
+
await this.loadAddressNametags();
|
|
6935
|
+
const savedNametag = await this._storage.get(STORAGE_KEYS.NAMETAG);
|
|
6941
6936
|
if (this._currentAddressIndex > 0 && this._masterKey) {
|
|
6942
6937
|
const addressInfo = this.deriveAddress(this._currentAddressIndex, false);
|
|
6943
6938
|
const ipnsHash = sha256(addressInfo.publicKey, "hex").slice(0, 40);
|
|
@@ -6951,6 +6946,7 @@ var Sphere = class _Sphere {
|
|
|
6951
6946
|
ipnsName: "12D3KooW" + ipnsHash,
|
|
6952
6947
|
nametag
|
|
6953
6948
|
};
|
|
6949
|
+
this._storage.setIdentity(this._identity);
|
|
6954
6950
|
console.log(`[Sphere] Restored to address ${this._currentAddressIndex}:`, this._identity.address);
|
|
6955
6951
|
} else {
|
|
6956
6952
|
if (savedNametag && this._identity) {
|