@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
|
@@ -239,6 +239,7 @@ declare class FileStorageProvider implements StorageProvider {
|
|
|
239
239
|
readonly type: "local";
|
|
240
240
|
private dataDir;
|
|
241
241
|
private filePath;
|
|
242
|
+
private isTxtMode;
|
|
242
243
|
private data;
|
|
243
244
|
private status;
|
|
244
245
|
private _identity;
|
|
@@ -1108,7 +1109,7 @@ declare const NETWORKS: {
|
|
|
1108
1109
|
readonly name: "Mainnet";
|
|
1109
1110
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
1110
1111
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
1111
|
-
readonly ipfsGateways: readonly ["https://
|
|
1112
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1112
1113
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
1113
1114
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1114
1115
|
};
|
|
@@ -1116,7 +1117,7 @@ declare const NETWORKS: {
|
|
|
1116
1117
|
readonly name: "Testnet";
|
|
1117
1118
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
1118
1119
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1119
|
-
readonly ipfsGateways: readonly ["https://
|
|
1120
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1120
1121
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1121
1122
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1122
1123
|
};
|
|
@@ -1124,7 +1125,7 @@ declare const NETWORKS: {
|
|
|
1124
1125
|
readonly name: "Development";
|
|
1125
1126
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
1126
1127
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1127
|
-
readonly ipfsGateways: readonly ["https://
|
|
1128
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1128
1129
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1129
1130
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1130
1131
|
};
|
|
@@ -1399,6 +1400,8 @@ interface NodeProvidersConfig {
|
|
|
1399
1400
|
network?: NetworkType;
|
|
1400
1401
|
/** Directory for wallet data storage */
|
|
1401
1402
|
dataDir?: string;
|
|
1403
|
+
/** Wallet file name (default: 'wallet.json') */
|
|
1404
|
+
walletFileName?: string;
|
|
1402
1405
|
/** Directory for token files */
|
|
1403
1406
|
tokensDir?: string;
|
|
1404
1407
|
/** Transport (Nostr) configuration */
|
|
@@ -239,6 +239,7 @@ declare class FileStorageProvider implements StorageProvider {
|
|
|
239
239
|
readonly type: "local";
|
|
240
240
|
private dataDir;
|
|
241
241
|
private filePath;
|
|
242
|
+
private isTxtMode;
|
|
242
243
|
private data;
|
|
243
244
|
private status;
|
|
244
245
|
private _identity;
|
|
@@ -1108,7 +1109,7 @@ declare const NETWORKS: {
|
|
|
1108
1109
|
readonly name: "Mainnet";
|
|
1109
1110
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
1110
1111
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
1111
|
-
readonly ipfsGateways: readonly ["https://
|
|
1112
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1112
1113
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
1113
1114
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1114
1115
|
};
|
|
@@ -1116,7 +1117,7 @@ declare const NETWORKS: {
|
|
|
1116
1117
|
readonly name: "Testnet";
|
|
1117
1118
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
1118
1119
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1119
|
-
readonly ipfsGateways: readonly ["https://
|
|
1120
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1120
1121
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1121
1122
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1122
1123
|
};
|
|
@@ -1124,7 +1125,7 @@ declare const NETWORKS: {
|
|
|
1124
1125
|
readonly name: "Development";
|
|
1125
1126
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
1126
1127
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1127
|
-
readonly ipfsGateways: readonly ["https://
|
|
1128
|
+
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1128
1129
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1129
1130
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1130
1131
|
};
|
|
@@ -1399,6 +1400,8 @@ interface NodeProvidersConfig {
|
|
|
1399
1400
|
network?: NetworkType;
|
|
1400
1401
|
/** Directory for wallet data storage */
|
|
1401
1402
|
dataDir?: string;
|
|
1403
|
+
/** Wallet file name (default: 'wallet.json') */
|
|
1404
|
+
walletFileName?: string;
|
|
1402
1405
|
/** Directory for token files */
|
|
1403
1406
|
tokensDir?: string;
|
|
1404
1407
|
/** Transport (Nostr) configuration */
|
|
@@ -94,9 +94,7 @@ var TEST_AGGREGATOR_URL = "https://goggregator-test.unicity.network";
|
|
|
94
94
|
var DEFAULT_AGGREGATOR_TIMEOUT = 3e4;
|
|
95
95
|
var DEFAULT_AGGREGATOR_API_KEY = "sk_06365a9c44654841a366068bcfc68986";
|
|
96
96
|
var DEFAULT_IPFS_GATEWAYS = [
|
|
97
|
-
"https://
|
|
98
|
-
"https://dweb.link",
|
|
99
|
-
"https://ipfs.io"
|
|
97
|
+
"https://unicity-ipfs1.dyndns.org"
|
|
100
98
|
];
|
|
101
99
|
var UNICITY_IPFS_NODES = [
|
|
102
100
|
{
|
|
@@ -167,6 +165,7 @@ var FileStorageProvider = class {
|
|
|
167
165
|
type = "local";
|
|
168
166
|
dataDir;
|
|
169
167
|
filePath;
|
|
168
|
+
isTxtMode;
|
|
170
169
|
data = {};
|
|
171
170
|
status = "disconnected";
|
|
172
171
|
_identity = null;
|
|
@@ -178,6 +177,7 @@ var FileStorageProvider = class {
|
|
|
178
177
|
this.dataDir = config.dataDir;
|
|
179
178
|
this.filePath = path.join(config.dataDir, config.fileName ?? "wallet.json");
|
|
180
179
|
}
|
|
180
|
+
this.isTxtMode = this.filePath.endsWith(".txt");
|
|
181
181
|
}
|
|
182
182
|
setIdentity(identity) {
|
|
183
183
|
this._identity = identity;
|
|
@@ -194,8 +194,14 @@ var FileStorageProvider = class {
|
|
|
194
194
|
}
|
|
195
195
|
if (fs.existsSync(this.filePath)) {
|
|
196
196
|
try {
|
|
197
|
-
const content = fs.readFileSync(this.filePath, "utf-8");
|
|
198
|
-
this.
|
|
197
|
+
const content = fs.readFileSync(this.filePath, "utf-8").trim();
|
|
198
|
+
if (this.isTxtMode) {
|
|
199
|
+
if (content) {
|
|
200
|
+
this.data = { [STORAGE_KEYS_GLOBAL.MNEMONIC]: content };
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
this.data = JSON.parse(content);
|
|
204
|
+
}
|
|
199
205
|
} catch {
|
|
200
206
|
this.data = {};
|
|
201
207
|
}
|
|
@@ -278,7 +284,12 @@ var FileStorageProvider = class {
|
|
|
278
284
|
if (!fs.existsSync(this.dataDir)) {
|
|
279
285
|
fs.mkdirSync(this.dataDir, { recursive: true });
|
|
280
286
|
}
|
|
281
|
-
|
|
287
|
+
if (this.isTxtMode) {
|
|
288
|
+
const mnemonic = this.data[STORAGE_KEYS_GLOBAL.MNEMONIC] ?? "";
|
|
289
|
+
fs.writeFileSync(this.filePath, mnemonic);
|
|
290
|
+
} else {
|
|
291
|
+
fs.writeFileSync(this.filePath, JSON.stringify(this.data, null, 2));
|
|
292
|
+
}
|
|
282
293
|
}
|
|
283
294
|
};
|
|
284
295
|
function createFileStorageProvider(config) {
|
|
@@ -4904,7 +4915,8 @@ function createNodeProviders(config) {
|
|
|
4904
4915
|
const l1Config = resolveL1Config(network, config?.l1);
|
|
4905
4916
|
const priceConfig = resolvePriceConfig(config?.price);
|
|
4906
4917
|
const storage = createFileStorageProvider({
|
|
4907
|
-
dataDir: config?.dataDir ?? "./sphere-data"
|
|
4918
|
+
dataDir: config?.dataDir ?? "./sphere-data",
|
|
4919
|
+
...config?.walletFileName ? { fileName: config.walletFileName } : {}
|
|
4908
4920
|
});
|
|
4909
4921
|
const ipfsSync = config?.tokenSync?.ipfs;
|
|
4910
4922
|
const ipfsTokenStorage = ipfsSync?.enabled ? createNodeIpfsStorageProvider(ipfsSync.config, storage) : void 0;
|