@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/index.d.cts
CHANGED
|
@@ -3443,7 +3443,7 @@ declare const TEST_AGGREGATOR_URL: "https://goggregator-test.unicity.network";
|
|
|
3443
3443
|
/** Default aggregator request timeout (ms) */
|
|
3444
3444
|
declare const DEFAULT_AGGREGATOR_TIMEOUT = 30000;
|
|
3445
3445
|
/** Default IPFS gateways */
|
|
3446
|
-
declare const DEFAULT_IPFS_GATEWAYS: readonly ["https://
|
|
3446
|
+
declare const DEFAULT_IPFS_GATEWAYS: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3447
3447
|
/** Unicity IPFS bootstrap peers */
|
|
3448
3448
|
declare const DEFAULT_IPFS_BOOTSTRAP_PEERS: readonly ["/dns4/unicity-ipfs2.dyndns.org/tcp/4001/p2p/12D3KooWLNi5NDPPHbrfJakAQqwBqymYTTwMQXQKEWuCrJNDdmfh", "/dns4/unicity-ipfs3.dyndns.org/tcp/4001/p2p/12D3KooWQ4aujVE4ShLjdusNZBdffq3TbzrwT2DuWZY9H1Gxhwn6", "/dns4/unicity-ipfs4.dyndns.org/tcp/4001/p2p/12D3KooWJ1ByPfUzUrpYvgxKU8NZrR8i6PU1tUgMEbQX9Hh2DEn1", "/dns4/unicity-ipfs5.dyndns.org/tcp/4001/p2p/12D3KooWB1MdZZGHN5B8TvWXntbycfe7Cjcz7n6eZ9eykZadvmDv"];
|
|
3449
3449
|
/** Default BIP32 derivation path (full path with chain/index) */
|
|
@@ -3469,7 +3469,7 @@ declare const NETWORKS: {
|
|
|
3469
3469
|
readonly name: "Mainnet";
|
|
3470
3470
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
3471
3471
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
3472
|
-
readonly ipfsGateways: readonly ["https://
|
|
3472
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3473
3473
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
3474
3474
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3475
3475
|
};
|
|
@@ -3477,7 +3477,7 @@ declare const NETWORKS: {
|
|
|
3477
3477
|
readonly name: "Testnet";
|
|
3478
3478
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
3479
3479
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3480
|
-
readonly ipfsGateways: readonly ["https://
|
|
3480
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3481
3481
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
3482
3482
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3483
3483
|
};
|
|
@@ -3485,7 +3485,7 @@ declare const NETWORKS: {
|
|
|
3485
3485
|
readonly name: "Development";
|
|
3486
3486
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
3487
3487
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3488
|
-
readonly ipfsGateways: readonly ["https://
|
|
3488
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3489
3489
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
3490
3490
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3491
3491
|
};
|
|
@@ -3667,6 +3667,8 @@ interface SphereCreateOptions {
|
|
|
3667
3667
|
network?: NetworkType;
|
|
3668
3668
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
3669
3669
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3670
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3671
|
+
password?: string;
|
|
3670
3672
|
}
|
|
3671
3673
|
/** Options for loading existing wallet */
|
|
3672
3674
|
interface SphereLoadOptions {
|
|
@@ -3690,6 +3692,8 @@ interface SphereLoadOptions {
|
|
|
3690
3692
|
network?: NetworkType;
|
|
3691
3693
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
3692
3694
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3695
|
+
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
3696
|
+
password?: string;
|
|
3693
3697
|
}
|
|
3694
3698
|
/** Options for importing a wallet */
|
|
3695
3699
|
interface SphereImportOptions {
|
|
@@ -3721,6 +3725,8 @@ interface SphereImportOptions {
|
|
|
3721
3725
|
price?: PriceProvider;
|
|
3722
3726
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
3723
3727
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3728
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
3729
|
+
password?: string;
|
|
3724
3730
|
}
|
|
3725
3731
|
/** L1 (ALPHA blockchain) configuration */
|
|
3726
3732
|
interface L1Config {
|
|
@@ -3766,6 +3772,8 @@ interface SphereInitOptions {
|
|
|
3766
3772
|
* - Omit/undefined: No groupchat module
|
|
3767
3773
|
*/
|
|
3768
3774
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3775
|
+
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3776
|
+
password?: string;
|
|
3769
3777
|
}
|
|
3770
3778
|
/** Result of init operation */
|
|
3771
3779
|
interface SphereInitResult {
|
|
@@ -3782,6 +3790,7 @@ declare class Sphere {
|
|
|
3782
3790
|
private _identity;
|
|
3783
3791
|
private _masterKey;
|
|
3784
3792
|
private _mnemonic;
|
|
3793
|
+
private _password;
|
|
3785
3794
|
private _source;
|
|
3786
3795
|
private _derivationMode;
|
|
3787
3796
|
private _basePath;
|
package/dist/index.d.ts
CHANGED
|
@@ -3443,7 +3443,7 @@ declare const TEST_AGGREGATOR_URL: "https://goggregator-test.unicity.network";
|
|
|
3443
3443
|
/** Default aggregator request timeout (ms) */
|
|
3444
3444
|
declare const DEFAULT_AGGREGATOR_TIMEOUT = 30000;
|
|
3445
3445
|
/** Default IPFS gateways */
|
|
3446
|
-
declare const DEFAULT_IPFS_GATEWAYS: readonly ["https://
|
|
3446
|
+
declare const DEFAULT_IPFS_GATEWAYS: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3447
3447
|
/** Unicity IPFS bootstrap peers */
|
|
3448
3448
|
declare const DEFAULT_IPFS_BOOTSTRAP_PEERS: readonly ["/dns4/unicity-ipfs2.dyndns.org/tcp/4001/p2p/12D3KooWLNi5NDPPHbrfJakAQqwBqymYTTwMQXQKEWuCrJNDdmfh", "/dns4/unicity-ipfs3.dyndns.org/tcp/4001/p2p/12D3KooWQ4aujVE4ShLjdusNZBdffq3TbzrwT2DuWZY9H1Gxhwn6", "/dns4/unicity-ipfs4.dyndns.org/tcp/4001/p2p/12D3KooWJ1ByPfUzUrpYvgxKU8NZrR8i6PU1tUgMEbQX9Hh2DEn1", "/dns4/unicity-ipfs5.dyndns.org/tcp/4001/p2p/12D3KooWB1MdZZGHN5B8TvWXntbycfe7Cjcz7n6eZ9eykZadvmDv"];
|
|
3449
3449
|
/** Default BIP32 derivation path (full path with chain/index) */
|
|
@@ -3469,7 +3469,7 @@ declare const NETWORKS: {
|
|
|
3469
3469
|
readonly name: "Mainnet";
|
|
3470
3470
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
3471
3471
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
3472
|
-
readonly ipfsGateways: readonly ["https://
|
|
3472
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3473
3473
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
3474
3474
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3475
3475
|
};
|
|
@@ -3477,7 +3477,7 @@ declare const NETWORKS: {
|
|
|
3477
3477
|
readonly name: "Testnet";
|
|
3478
3478
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
3479
3479
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3480
|
-
readonly ipfsGateways: readonly ["https://
|
|
3480
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3481
3481
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
3482
3482
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3483
3483
|
};
|
|
@@ -3485,7 +3485,7 @@ declare const NETWORKS: {
|
|
|
3485
3485
|
readonly name: "Development";
|
|
3486
3486
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
3487
3487
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3488
|
-
readonly ipfsGateways: readonly ["https://
|
|
3488
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3489
3489
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
3490
3490
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3491
3491
|
};
|
|
@@ -3667,6 +3667,8 @@ interface SphereCreateOptions {
|
|
|
3667
3667
|
network?: NetworkType;
|
|
3668
3668
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
3669
3669
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3670
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3671
|
+
password?: string;
|
|
3670
3672
|
}
|
|
3671
3673
|
/** Options for loading existing wallet */
|
|
3672
3674
|
interface SphereLoadOptions {
|
|
@@ -3690,6 +3692,8 @@ interface SphereLoadOptions {
|
|
|
3690
3692
|
network?: NetworkType;
|
|
3691
3693
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
3692
3694
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3695
|
+
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
3696
|
+
password?: string;
|
|
3693
3697
|
}
|
|
3694
3698
|
/** Options for importing a wallet */
|
|
3695
3699
|
interface SphereImportOptions {
|
|
@@ -3721,6 +3725,8 @@ interface SphereImportOptions {
|
|
|
3721
3725
|
price?: PriceProvider;
|
|
3722
3726
|
/** Group chat configuration (NIP-29). Omit to disable groupchat. */
|
|
3723
3727
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3728
|
+
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
3729
|
+
password?: string;
|
|
3724
3730
|
}
|
|
3725
3731
|
/** L1 (ALPHA blockchain) configuration */
|
|
3726
3732
|
interface L1Config {
|
|
@@ -3766,6 +3772,8 @@ interface SphereInitOptions {
|
|
|
3766
3772
|
* - Omit/undefined: No groupchat module
|
|
3767
3773
|
*/
|
|
3768
3774
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3775
|
+
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3776
|
+
password?: string;
|
|
3769
3777
|
}
|
|
3770
3778
|
/** Result of init operation */
|
|
3771
3779
|
interface SphereInitResult {
|
|
@@ -3782,6 +3790,7 @@ declare class Sphere {
|
|
|
3782
3790
|
private _identity;
|
|
3783
3791
|
private _masterKey;
|
|
3784
3792
|
private _mnemonic;
|
|
3793
|
+
private _password;
|
|
3785
3794
|
private _source;
|
|
3786
3795
|
private _derivationMode;
|
|
3787
3796
|
private _basePath;
|
package/dist/index.js
CHANGED
|
@@ -2580,9 +2580,7 @@ var DEV_AGGREGATOR_URL = "https://dev-aggregator.dyndns.org/rpc";
|
|
|
2580
2580
|
var TEST_AGGREGATOR_URL = "https://goggregator-test.unicity.network";
|
|
2581
2581
|
var DEFAULT_AGGREGATOR_TIMEOUT = 3e4;
|
|
2582
2582
|
var DEFAULT_IPFS_GATEWAYS = [
|
|
2583
|
-
"https://
|
|
2584
|
-
"https://dweb.link",
|
|
2585
|
-
"https://ipfs.io"
|
|
2583
|
+
"https://unicity-ipfs1.dyndns.org"
|
|
2586
2584
|
];
|
|
2587
2585
|
var DEFAULT_IPFS_BOOTSTRAP_PEERS = [
|
|
2588
2586
|
"/dns4/unicity-ipfs2.dyndns.org/tcp/4001/p2p/12D3KooWLNi5NDPPHbrfJakAQqwBqymYTTwMQXQKEWuCrJNDdmfh",
|
|
@@ -9921,6 +9919,7 @@ var Sphere = class _Sphere {
|
|
|
9921
9919
|
_identity = null;
|
|
9922
9920
|
_masterKey = null;
|
|
9923
9921
|
_mnemonic = null;
|
|
9922
|
+
_password = null;
|
|
9924
9923
|
_source = "unknown";
|
|
9925
9924
|
_derivationMode = "bip32";
|
|
9926
9925
|
_basePath = DEFAULT_BASE_PATH;
|
|
@@ -10020,7 +10019,8 @@ var Sphere = class _Sphere {
|
|
|
10020
10019
|
tokenStorage: options.tokenStorage,
|
|
10021
10020
|
l1: options.l1,
|
|
10022
10021
|
price: options.price,
|
|
10023
|
-
groupChat
|
|
10022
|
+
groupChat,
|
|
10023
|
+
password: options.password
|
|
10024
10024
|
});
|
|
10025
10025
|
return { sphere: sphere2, created: false };
|
|
10026
10026
|
}
|
|
@@ -10046,7 +10046,8 @@ var Sphere = class _Sphere {
|
|
|
10046
10046
|
nametag: options.nametag,
|
|
10047
10047
|
l1: options.l1,
|
|
10048
10048
|
price: options.price,
|
|
10049
|
-
groupChat
|
|
10049
|
+
groupChat,
|
|
10050
|
+
password: options.password
|
|
10050
10051
|
});
|
|
10051
10052
|
return { sphere, created: true, generatedMnemonic };
|
|
10052
10053
|
}
|
|
@@ -10093,6 +10094,7 @@ var Sphere = class _Sphere {
|
|
|
10093
10094
|
options.price,
|
|
10094
10095
|
groupChatConfig
|
|
10095
10096
|
);
|
|
10097
|
+
sphere._password = options.password ?? null;
|
|
10096
10098
|
await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
|
|
10097
10099
|
await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
|
|
10098
10100
|
await sphere.initializeProviders();
|
|
@@ -10126,6 +10128,7 @@ var Sphere = class _Sphere {
|
|
|
10126
10128
|
options.price,
|
|
10127
10129
|
groupChatConfig
|
|
10128
10130
|
);
|
|
10131
|
+
sphere._password = options.password ?? null;
|
|
10129
10132
|
await sphere.loadIdentityFromStorage();
|
|
10130
10133
|
await sphere.initializeProviders();
|
|
10131
10134
|
await sphere.initializeModules();
|
|
@@ -10178,6 +10181,7 @@ var Sphere = class _Sphere {
|
|
|
10178
10181
|
options.price,
|
|
10179
10182
|
groupChatConfig
|
|
10180
10183
|
);
|
|
10184
|
+
sphere._password = options.password ?? null;
|
|
10181
10185
|
if (options.mnemonic) {
|
|
10182
10186
|
if (!_Sphere.validateMnemonic(options.mnemonic)) {
|
|
10183
10187
|
throw new Error("Invalid mnemonic");
|
|
@@ -12356,9 +12360,20 @@ var Sphere = class _Sphere {
|
|
|
12356
12360
|
// Private: Encryption
|
|
12357
12361
|
// ===========================================================================
|
|
12358
12362
|
encrypt(data) {
|
|
12359
|
-
return
|
|
12363
|
+
if (!this._password) return data;
|
|
12364
|
+
return encryptSimple(data, this._password);
|
|
12360
12365
|
}
|
|
12361
12366
|
decrypt(encrypted) {
|
|
12367
|
+
if (this._password) {
|
|
12368
|
+
try {
|
|
12369
|
+
return decryptSimple(encrypted, this._password);
|
|
12370
|
+
} catch {
|
|
12371
|
+
return null;
|
|
12372
|
+
}
|
|
12373
|
+
}
|
|
12374
|
+
if (validateMnemonic2(encrypted) || /^[0-9a-f]{64}$/i.test(encrypted)) {
|
|
12375
|
+
return encrypted;
|
|
12376
|
+
}
|
|
12362
12377
|
try {
|
|
12363
12378
|
return decryptSimple(encrypted, DEFAULT_ENCRYPTION_KEY);
|
|
12364
12379
|
} catch {
|