@unicitylabs/sphere-sdk 0.3.2 → 0.3.4
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 +21 -6
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +12 -3
- package/dist/core/index.d.ts +12 -3
- package/dist/core/index.js +21 -6
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +1 -3
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +1 -3
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +19 -7
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +6 -3
- package/dist/impl/nodejs/index.d.ts +6 -3
- package/dist/impl/nodejs/index.js +19 -7
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -2710,7 +2710,7 @@ declare const NETWORKS: {
|
|
|
2710
2710
|
readonly name: "Mainnet";
|
|
2711
2711
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
2712
2712
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
2713
|
-
readonly ipfsGateways: readonly ["https://
|
|
2713
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2714
2714
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
2715
2715
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2716
2716
|
};
|
|
@@ -2718,7 +2718,7 @@ declare const NETWORKS: {
|
|
|
2718
2718
|
readonly name: "Testnet";
|
|
2719
2719
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
2720
2720
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2721
|
-
readonly ipfsGateways: readonly ["https://
|
|
2721
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2722
2722
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
2723
2723
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2724
2724
|
};
|
|
@@ -2726,7 +2726,7 @@ declare const NETWORKS: {
|
|
|
2726
2726
|
readonly name: "Development";
|
|
2727
2727
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
2728
2728
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2729
|
-
readonly ipfsGateways: readonly ["https://
|
|
2729
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2730
2730
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
2731
2731
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2732
2732
|
};
|
|
@@ -2844,6 +2844,8 @@ interface SphereCreateOptions {
|
|
|
2844
2844
|
network?: NetworkType;
|
|
2845
2845
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
2846
2846
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2847
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
2848
|
+
password?: string;
|
|
2847
2849
|
}
|
|
2848
2850
|
/** Options for loading existing wallet */
|
|
2849
2851
|
interface SphereLoadOptions {
|
|
@@ -2867,6 +2869,8 @@ interface SphereLoadOptions {
|
|
|
2867
2869
|
network?: NetworkType;
|
|
2868
2870
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
2869
2871
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2872
|
+
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
2873
|
+
password?: string;
|
|
2870
2874
|
}
|
|
2871
2875
|
/** Options for importing a wallet */
|
|
2872
2876
|
interface SphereImportOptions {
|
|
@@ -2898,6 +2902,8 @@ interface SphereImportOptions {
|
|
|
2898
2902
|
price?: PriceProvider;
|
|
2899
2903
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
2900
2904
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2905
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
2906
|
+
password?: string;
|
|
2901
2907
|
}
|
|
2902
2908
|
/** L1 (ALPHA blockchain) configuration */
|
|
2903
2909
|
interface L1Config {
|
|
@@ -2943,6 +2949,8 @@ interface SphereInitOptions {
|
|
|
2943
2949
|
* - Omit/undefined: No groupchat module
|
|
2944
2950
|
*/
|
|
2945
2951
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2952
|
+
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
2953
|
+
password?: string;
|
|
2946
2954
|
}
|
|
2947
2955
|
/** Result of init operation */
|
|
2948
2956
|
interface SphereInitResult {
|
|
@@ -2959,6 +2967,7 @@ declare class Sphere {
|
|
|
2959
2967
|
private _identity;
|
|
2960
2968
|
private _masterKey;
|
|
2961
2969
|
private _mnemonic;
|
|
2970
|
+
private _password;
|
|
2962
2971
|
private _source;
|
|
2963
2972
|
private _derivationMode;
|
|
2964
2973
|
private _basePath;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -2710,7 +2710,7 @@ declare const NETWORKS: {
|
|
|
2710
2710
|
readonly name: "Mainnet";
|
|
2711
2711
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
2712
2712
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
2713
|
-
readonly ipfsGateways: readonly ["https://
|
|
2713
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2714
2714
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
2715
2715
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2716
2716
|
};
|
|
@@ -2718,7 +2718,7 @@ declare const NETWORKS: {
|
|
|
2718
2718
|
readonly name: "Testnet";
|
|
2719
2719
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
2720
2720
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2721
|
-
readonly ipfsGateways: readonly ["https://
|
|
2721
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2722
2722
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
2723
2723
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2724
2724
|
};
|
|
@@ -2726,7 +2726,7 @@ declare const NETWORKS: {
|
|
|
2726
2726
|
readonly name: "Development";
|
|
2727
2727
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
2728
2728
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2729
|
-
readonly ipfsGateways: readonly ["https://
|
|
2729
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2730
2730
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
2731
2731
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2732
2732
|
};
|
|
@@ -2844,6 +2844,8 @@ interface SphereCreateOptions {
|
|
|
2844
2844
|
network?: NetworkType;
|
|
2845
2845
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
2846
2846
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2847
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
2848
|
+
password?: string;
|
|
2847
2849
|
}
|
|
2848
2850
|
/** Options for loading existing wallet */
|
|
2849
2851
|
interface SphereLoadOptions {
|
|
@@ -2867,6 +2869,8 @@ interface SphereLoadOptions {
|
|
|
2867
2869
|
network?: NetworkType;
|
|
2868
2870
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
2869
2871
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2872
|
+
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
2873
|
+
password?: string;
|
|
2870
2874
|
}
|
|
2871
2875
|
/** Options for importing a wallet */
|
|
2872
2876
|
interface SphereImportOptions {
|
|
@@ -2898,6 +2902,8 @@ interface SphereImportOptions {
|
|
|
2898
2902
|
price?: PriceProvider;
|
|
2899
2903
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
2900
2904
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2905
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
2906
|
+
password?: string;
|
|
2901
2907
|
}
|
|
2902
2908
|
/** L1 (ALPHA blockchain) configuration */
|
|
2903
2909
|
interface L1Config {
|
|
@@ -2943,6 +2949,8 @@ interface SphereInitOptions {
|
|
|
2943
2949
|
* - Omit/undefined: No groupchat module
|
|
2944
2950
|
*/
|
|
2945
2951
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
2952
|
+
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
2953
|
+
password?: string;
|
|
2946
2954
|
}
|
|
2947
2955
|
/** Result of init operation */
|
|
2948
2956
|
interface SphereInitResult {
|
|
@@ -2959,6 +2967,7 @@ declare class Sphere {
|
|
|
2959
2967
|
private _identity;
|
|
2960
2968
|
private _masterKey;
|
|
2961
2969
|
private _mnemonic;
|
|
2970
|
+
private _password;
|
|
2962
2971
|
private _source;
|
|
2963
2972
|
private _derivationMode;
|
|
2964
2973
|
private _basePath;
|
package/dist/core/index.js
CHANGED
|
@@ -2410,9 +2410,7 @@ var DEFAULT_AGGREGATOR_URL = "https://aggregator.unicity.network/rpc";
|
|
|
2410
2410
|
var DEV_AGGREGATOR_URL = "https://dev-aggregator.dyndns.org/rpc";
|
|
2411
2411
|
var TEST_AGGREGATOR_URL = "https://goggregator-test.unicity.network";
|
|
2412
2412
|
var DEFAULT_IPFS_GATEWAYS = [
|
|
2413
|
-
"https://
|
|
2414
|
-
"https://dweb.link",
|
|
2415
|
-
"https://ipfs.io"
|
|
2413
|
+
"https://unicity-ipfs1.dyndns.org"
|
|
2416
2414
|
];
|
|
2417
2415
|
var DEFAULT_BASE_PATH = "m/44'/0'/0'";
|
|
2418
2416
|
var DEFAULT_DERIVATION_PATH2 = `${DEFAULT_BASE_PATH}/0/0`;
|
|
@@ -9714,6 +9712,7 @@ var Sphere = class _Sphere {
|
|
|
9714
9712
|
_identity = null;
|
|
9715
9713
|
_masterKey = null;
|
|
9716
9714
|
_mnemonic = null;
|
|
9715
|
+
_password = null;
|
|
9717
9716
|
_source = "unknown";
|
|
9718
9717
|
_derivationMode = "bip32";
|
|
9719
9718
|
_basePath = DEFAULT_BASE_PATH;
|
|
@@ -9813,7 +9812,8 @@ var Sphere = class _Sphere {
|
|
|
9813
9812
|
tokenStorage: options.tokenStorage,
|
|
9814
9813
|
l1: options.l1,
|
|
9815
9814
|
price: options.price,
|
|
9816
|
-
groupChat
|
|
9815
|
+
groupChat,
|
|
9816
|
+
password: options.password
|
|
9817
9817
|
});
|
|
9818
9818
|
return { sphere: sphere2, created: false };
|
|
9819
9819
|
}
|
|
@@ -9839,7 +9839,8 @@ var Sphere = class _Sphere {
|
|
|
9839
9839
|
nametag: options.nametag,
|
|
9840
9840
|
l1: options.l1,
|
|
9841
9841
|
price: options.price,
|
|
9842
|
-
groupChat
|
|
9842
|
+
groupChat,
|
|
9843
|
+
password: options.password
|
|
9843
9844
|
});
|
|
9844
9845
|
return { sphere, created: true, generatedMnemonic };
|
|
9845
9846
|
}
|
|
@@ -9886,6 +9887,7 @@ var Sphere = class _Sphere {
|
|
|
9886
9887
|
options.price,
|
|
9887
9888
|
groupChatConfig
|
|
9888
9889
|
);
|
|
9890
|
+
sphere._password = options.password ?? null;
|
|
9889
9891
|
await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
|
|
9890
9892
|
await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
|
|
9891
9893
|
await sphere.initializeProviders();
|
|
@@ -9919,6 +9921,7 @@ var Sphere = class _Sphere {
|
|
|
9919
9921
|
options.price,
|
|
9920
9922
|
groupChatConfig
|
|
9921
9923
|
);
|
|
9924
|
+
sphere._password = options.password ?? null;
|
|
9922
9925
|
await sphere.loadIdentityFromStorage();
|
|
9923
9926
|
await sphere.initializeProviders();
|
|
9924
9927
|
await sphere.initializeModules();
|
|
@@ -9971,6 +9974,7 @@ var Sphere = class _Sphere {
|
|
|
9971
9974
|
options.price,
|
|
9972
9975
|
groupChatConfig
|
|
9973
9976
|
);
|
|
9977
|
+
sphere._password = options.password ?? null;
|
|
9974
9978
|
if (options.mnemonic) {
|
|
9975
9979
|
if (!_Sphere.validateMnemonic(options.mnemonic)) {
|
|
9976
9980
|
throw new Error("Invalid mnemonic");
|
|
@@ -12149,9 +12153,20 @@ var Sphere = class _Sphere {
|
|
|
12149
12153
|
// Private: Encryption
|
|
12150
12154
|
// ===========================================================================
|
|
12151
12155
|
encrypt(data) {
|
|
12152
|
-
return
|
|
12156
|
+
if (!this._password) return data;
|
|
12157
|
+
return encryptSimple(data, this._password);
|
|
12153
12158
|
}
|
|
12154
12159
|
decrypt(encrypted) {
|
|
12160
|
+
if (this._password) {
|
|
12161
|
+
try {
|
|
12162
|
+
return decryptSimple(encrypted, this._password);
|
|
12163
|
+
} catch {
|
|
12164
|
+
return null;
|
|
12165
|
+
}
|
|
12166
|
+
}
|
|
12167
|
+
if (validateMnemonic2(encrypted) || /^[0-9a-f]{64}$/i.test(encrypted)) {
|
|
12168
|
+
return encrypted;
|
|
12169
|
+
}
|
|
12155
12170
|
try {
|
|
12156
12171
|
return decryptSimple(encrypted, DEFAULT_ENCRYPTION_KEY);
|
|
12157
12172
|
} catch {
|