@breeztech/breez-sdk-spark 0.10.0 → 0.11.0-dev2
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/breez-sdk-spark.tgz +0 -0
- package/bundler/breez_sdk_spark_wasm.d.ts +629 -565
- package/bundler/breez_sdk_spark_wasm_bg.js +130 -29
- package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +9 -3
- package/bundler/storage/index.js +166 -35
- package/deno/breez_sdk_spark_wasm.d.ts +629 -565
- package/deno/breez_sdk_spark_wasm.js +125 -29
- package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +9 -3
- package/nodejs/breez_sdk_spark_wasm.d.ts +629 -565
- package/nodejs/breez_sdk_spark_wasm.js +130 -29
- package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +9 -3
- package/nodejs/index.js +12 -2
- package/nodejs/package.json +1 -0
- package/nodejs/postgres-storage/errors.cjs +19 -0
- package/nodejs/postgres-storage/index.cjs +1379 -0
- package/nodejs/postgres-storage/migrations.cjs +241 -0
- package/nodejs/postgres-storage/package.json +9 -0
- package/nodejs/storage/index.cjs +82 -3
- package/nodejs/storage/migrations.cjs +14 -0
- package/package.json +3 -2
- package/web/breez_sdk_spark_wasm.d.ts +638 -568
- package/web/breez_sdk_spark_wasm.js +125 -29
- package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +9 -3
- package/web/storage/index.js +166 -35
|
@@ -217,6 +217,43 @@ function debugString(val) {
|
|
|
217
217
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
218
218
|
return className;
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Creates a default PostgreSQL storage configuration with sensible defaults.
|
|
222
|
+
*
|
|
223
|
+
* Default values (from pg.Pool):
|
|
224
|
+
* - `maxPoolSize`: 10
|
|
225
|
+
* - `createTimeoutSecs`: 0 (no timeout)
|
|
226
|
+
* - `recycleTimeoutSecs`: 10 (10 seconds idle before disconnect)
|
|
227
|
+
* @param {string} connection_string
|
|
228
|
+
* @returns {PostgresStorageConfig}
|
|
229
|
+
*/
|
|
230
|
+
module.exports.defaultPostgresStorageConfig = function(connection_string) {
|
|
231
|
+
const ptr0 = passStringToWasm0(connection_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len0 = WASM_VECTOR_LEN;
|
|
233
|
+
const ret = wasm.defaultPostgresStorageConfig(ptr0, len0);
|
|
234
|
+
return ret;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Creates a default external signer from a mnemonic phrase.
|
|
239
|
+
*
|
|
240
|
+
* This creates a signer that can be used with `connectWithSigner` or `SdkBuilder.newWithSigner`.
|
|
241
|
+
* @returns {Promise<SparkStatus>}
|
|
242
|
+
*/
|
|
243
|
+
module.exports.getSparkStatus = function() {
|
|
244
|
+
const ret = wasm.getSparkStatus();
|
|
245
|
+
return ret;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @param {Network} network
|
|
250
|
+
* @returns {Config}
|
|
251
|
+
*/
|
|
252
|
+
module.exports.defaultConfig = function(network) {
|
|
253
|
+
const ret = wasm.defaultConfig(network);
|
|
254
|
+
return ret;
|
|
255
|
+
};
|
|
256
|
+
|
|
220
257
|
/**
|
|
221
258
|
* @param {Logger} logger
|
|
222
259
|
* @param {string | null} [filter]
|
|
@@ -253,15 +290,6 @@ module.exports.defaultExternalSigner = function(mnemonic, passphrase, network, k
|
|
|
253
290
|
return DefaultSigner.__wrap(ret[0]);
|
|
254
291
|
};
|
|
255
292
|
|
|
256
|
-
/**
|
|
257
|
-
* @param {Network} network
|
|
258
|
-
* @returns {Config}
|
|
259
|
-
*/
|
|
260
|
-
module.exports.defaultConfig = function(network) {
|
|
261
|
-
const ret = wasm.defaultConfig(network);
|
|
262
|
-
return ret;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
293
|
/**
|
|
266
294
|
* @param {ConnectRequest} request
|
|
267
295
|
* @returns {Promise<BreezSdk>}
|
|
@@ -284,17 +312,6 @@ module.exports.connectWithSigner = function(config, signer, storage_dir) {
|
|
|
284
312
|
return ret;
|
|
285
313
|
};
|
|
286
314
|
|
|
287
|
-
/**
|
|
288
|
-
* Creates a default external signer from a mnemonic phrase.
|
|
289
|
-
*
|
|
290
|
-
* This creates a signer that can be used with `connectWithSigner` or `SdkBuilder.newWithSigner`.
|
|
291
|
-
* @returns {Promise<SparkStatus>}
|
|
292
|
-
*/
|
|
293
|
-
module.exports.getSparkStatus = function() {
|
|
294
|
-
const ret = wasm.getSparkStatus();
|
|
295
|
-
return ret;
|
|
296
|
-
};
|
|
297
|
-
|
|
298
315
|
function passArray8ToWasm0(arg, malloc) {
|
|
299
316
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
300
317
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -313,15 +330,15 @@ module.exports.task_worker_entry_point = function(ptr) {
|
|
|
313
330
|
};
|
|
314
331
|
|
|
315
332
|
function __wbg_adapter_64(arg0, arg1) {
|
|
316
|
-
wasm.
|
|
333
|
+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2ac8515d28de5817(arg0, arg1);
|
|
317
334
|
}
|
|
318
335
|
|
|
319
336
|
function __wbg_adapter_67(arg0, arg1, arg2) {
|
|
320
|
-
wasm.
|
|
337
|
+
wasm.closure1068_externref_shim(arg0, arg1, arg2);
|
|
321
338
|
}
|
|
322
339
|
|
|
323
|
-
function
|
|
324
|
-
wasm.
|
|
340
|
+
function __wbg_adapter_301(arg0, arg1, arg2, arg3) {
|
|
341
|
+
wasm.closure651_externref_shim(arg0, arg1, arg2, arg3);
|
|
325
342
|
}
|
|
326
343
|
|
|
327
344
|
const __wbindgen_enum_ReadableStreamType = ["bytes"];
|
|
@@ -376,6 +393,14 @@ class BreezSdk {
|
|
|
376
393
|
const ret = wasm.breezsdk_lnurlAuth(this.__wbg_ptr, request_data);
|
|
377
394
|
return ret;
|
|
378
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* @param {AddContactRequest} request
|
|
398
|
+
* @returns {Promise<Contact>}
|
|
399
|
+
*/
|
|
400
|
+
addContact(request) {
|
|
401
|
+
const ret = wasm.breezsdk_addContact(this.__wbg_ptr, request);
|
|
402
|
+
return ret;
|
|
403
|
+
}
|
|
379
404
|
/**
|
|
380
405
|
* @param {BuyBitcoinRequest} request
|
|
381
406
|
* @returns {Promise<BuyBitcoinResponse>}
|
|
@@ -432,6 +457,14 @@ class BreezSdk {
|
|
|
432
457
|
const ret = wasm.breezsdk_claimDeposit(this.__wbg_ptr, request);
|
|
433
458
|
return ret;
|
|
434
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* @param {ListContactsRequest} request
|
|
462
|
+
* @returns {Promise<Contact[]>}
|
|
463
|
+
*/
|
|
464
|
+
listContacts(request) {
|
|
465
|
+
const ret = wasm.breezsdk_listContacts(this.__wbg_ptr, request);
|
|
466
|
+
return ret;
|
|
467
|
+
}
|
|
435
468
|
/**
|
|
436
469
|
* @param {ListPaymentsRequest} request
|
|
437
470
|
* @returns {Promise<ListPaymentsResponse>}
|
|
@@ -440,6 +473,16 @@ class BreezSdk {
|
|
|
440
473
|
const ret = wasm.breezsdk_listPayments(this.__wbg_ptr, request);
|
|
441
474
|
return ret;
|
|
442
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* @param {string} id
|
|
478
|
+
* @returns {Promise<void>}
|
|
479
|
+
*/
|
|
480
|
+
deleteContact(id) {
|
|
481
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
482
|
+
const len0 = WASM_VECTOR_LEN;
|
|
483
|
+
const ret = wasm.breezsdk_deleteContact(this.__wbg_ptr, ptr0, len0);
|
|
484
|
+
return ret;
|
|
485
|
+
}
|
|
443
486
|
/**
|
|
444
487
|
* @param {LnurlWithdrawRequest} request
|
|
445
488
|
* @returns {Promise<LnurlWithdrawResponse>}
|
|
@@ -456,6 +499,14 @@ class BreezSdk {
|
|
|
456
499
|
const ret = wasm.breezsdk_refundDeposit(this.__wbg_ptr, request);
|
|
457
500
|
return ret;
|
|
458
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* @param {UpdateContactRequest} request
|
|
504
|
+
* @returns {Promise<Contact>}
|
|
505
|
+
*/
|
|
506
|
+
updateContact(request) {
|
|
507
|
+
const ret = wasm.breezsdk_updateContact(this.__wbg_ptr, request);
|
|
508
|
+
return ret;
|
|
509
|
+
}
|
|
459
510
|
/**
|
|
460
511
|
* @returns {Promise<ListFiatRatesResponse>}
|
|
461
512
|
*/
|
|
@@ -1100,6 +1151,15 @@ class SdkBuilder {
|
|
|
1100
1151
|
const ret = wasm.sdkbuilder_withPaymentObserver(ptr, payment_observer);
|
|
1101
1152
|
return SdkBuilder.__wrap(ret);
|
|
1102
1153
|
}
|
|
1154
|
+
/**
|
|
1155
|
+
* @param {PostgresStorageConfig} config
|
|
1156
|
+
* @returns {SdkBuilder}
|
|
1157
|
+
*/
|
|
1158
|
+
withPostgresStorage(config) {
|
|
1159
|
+
const ptr = this.__destroy_into_raw();
|
|
1160
|
+
const ret = wasm.sdkbuilder_withPostgresStorage(ptr, config);
|
|
1161
|
+
return SdkBuilder.__wrap(ret);
|
|
1162
|
+
}
|
|
1103
1163
|
/**
|
|
1104
1164
|
* @param {string} url
|
|
1105
1165
|
* @param {ChainApiType} api_type
|
|
@@ -1356,6 +1416,11 @@ module.exports.__wbg_createDefaultStorage_458aa01b5eaead27 = function() { return
|
|
|
1356
1416
|
return ret;
|
|
1357
1417
|
}, arguments) };
|
|
1358
1418
|
|
|
1419
|
+
module.exports.__wbg_createPostgresStorage_46770cbf8e947f9e = function() { return handleError(function (arg0, arg1) {
|
|
1420
|
+
const ret = createPostgresStorage(arg0, arg1);
|
|
1421
|
+
return ret;
|
|
1422
|
+
}, arguments) };
|
|
1423
|
+
|
|
1359
1424
|
module.exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
1360
1425
|
const ret = arg0.crypto;
|
|
1361
1426
|
return ret;
|
|
@@ -1374,6 +1439,19 @@ module.exports.__wbg_deleteCachedItem_ff3c84380e94360b = function() { return han
|
|
|
1374
1439
|
}
|
|
1375
1440
|
}, arguments) };
|
|
1376
1441
|
|
|
1442
|
+
module.exports.__wbg_deleteContact_04d635b32c469d83 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1443
|
+
let deferred0_0;
|
|
1444
|
+
let deferred0_1;
|
|
1445
|
+
try {
|
|
1446
|
+
deferred0_0 = arg1;
|
|
1447
|
+
deferred0_1 = arg2;
|
|
1448
|
+
const ret = arg0.deleteContact(getStringFromWasm0(arg1, arg2));
|
|
1449
|
+
return ret;
|
|
1450
|
+
} finally {
|
|
1451
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1452
|
+
}
|
|
1453
|
+
}, arguments) };
|
|
1454
|
+
|
|
1377
1455
|
module.exports.__wbg_deleteDeposit_72ec826e7c3c3ccf = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
1378
1456
|
let deferred0_0;
|
|
1379
1457
|
let deferred0_1;
|
|
@@ -1537,6 +1615,19 @@ module.exports.__wbg_getCachedItem_de40d6348815c7b9 = function() { return handle
|
|
|
1537
1615
|
}
|
|
1538
1616
|
}, arguments) };
|
|
1539
1617
|
|
|
1618
|
+
module.exports.__wbg_getContact_b7300737e5dee01b = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1619
|
+
let deferred0_0;
|
|
1620
|
+
let deferred0_1;
|
|
1621
|
+
try {
|
|
1622
|
+
deferred0_0 = arg1;
|
|
1623
|
+
deferred0_1 = arg2;
|
|
1624
|
+
const ret = arg0.getContact(getStringFromWasm0(arg1, arg2));
|
|
1625
|
+
return ret;
|
|
1626
|
+
} finally {
|
|
1627
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1628
|
+
}
|
|
1629
|
+
}, arguments) };
|
|
1630
|
+
|
|
1540
1631
|
module.exports.__wbg_getPaymentById_c23144bfc404b2fc = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1541
1632
|
let deferred0_0;
|
|
1542
1633
|
let deferred0_1;
|
|
@@ -1702,6 +1793,11 @@ module.exports.__wbg_identityPublicKey_c8b35005055a3df0 = function() { return ha
|
|
|
1702
1793
|
return ret;
|
|
1703
1794
|
}, arguments) };
|
|
1704
1795
|
|
|
1796
|
+
module.exports.__wbg_insertContact_33c214012213409d = function() { return handleError(function (arg0, arg1) {
|
|
1797
|
+
const ret = arg0.insertContact(arg1);
|
|
1798
|
+
return ret;
|
|
1799
|
+
}, arguments) };
|
|
1800
|
+
|
|
1705
1801
|
module.exports.__wbg_insertPaymentMetadata_0c4ebdcde694d29b = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
1706
1802
|
let deferred0_0;
|
|
1707
1803
|
let deferred0_1;
|
|
@@ -1822,6 +1918,11 @@ module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
|
1822
1918
|
return ret;
|
|
1823
1919
|
};
|
|
1824
1920
|
|
|
1921
|
+
module.exports.__wbg_listContacts_5b4d38a57743b713 = function() { return handleError(function (arg0, arg1) {
|
|
1922
|
+
const ret = arg0.listContacts(arg1);
|
|
1923
|
+
return ret;
|
|
1924
|
+
}, arguments) };
|
|
1925
|
+
|
|
1825
1926
|
module.exports.__wbg_listDeposits_7ca6e22afc06d560 = function() { return handleError(function (arg0) {
|
|
1826
1927
|
const ret = arg0.listDeposits();
|
|
1827
1928
|
return ret;
|
|
@@ -1879,7 +1980,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
|
|
|
1879
1980
|
const a = state0.a;
|
|
1880
1981
|
state0.a = 0;
|
|
1881
1982
|
try {
|
|
1882
|
-
return
|
|
1983
|
+
return __wbg_adapter_301(a, state0.b, arg0, arg1);
|
|
1883
1984
|
} finally {
|
|
1884
1985
|
state0.a = a;
|
|
1885
1986
|
}
|
|
@@ -2404,13 +2505,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
2404
2505
|
return ret;
|
|
2405
2506
|
};
|
|
2406
2507
|
|
|
2407
|
-
module.exports.
|
|
2408
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2508
|
+
module.exports.__wbindgen_closure_wrapper11838 = function(arg0, arg1, arg2) {
|
|
2509
|
+
const ret = makeMutClosure(arg0, arg1, 828, __wbg_adapter_64);
|
|
2409
2510
|
return ret;
|
|
2410
2511
|
};
|
|
2411
2512
|
|
|
2412
|
-
module.exports.
|
|
2413
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2513
|
+
module.exports.__wbindgen_closure_wrapper13801 = function(arg0, arg1, arg2) {
|
|
2514
|
+
const ret = makeMutClosure(arg0, arg1, 1069, __wbg_adapter_67);
|
|
2414
2515
|
return ret;
|
|
2415
2516
|
};
|
|
2416
2517
|
|
|
Binary file
|
|
@@ -5,6 +5,7 @@ export const __wbg_breezsdk_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_defaultsigner_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_sdkbuilder_free: (a: number, b: number) => void;
|
|
7
7
|
export const __wbg_tokenissuer_free: (a: number, b: number) => void;
|
|
8
|
+
export const breezsdk_addContact: (a: number, b: any) => any;
|
|
8
9
|
export const breezsdk_addEventListener: (a: number, b: any) => any;
|
|
9
10
|
export const breezsdk_buyBitcoin: (a: number, b: any) => any;
|
|
10
11
|
export const breezsdk_cancelLeafOptimization: (a: number) => any;
|
|
@@ -12,6 +13,7 @@ export const breezsdk_checkLightningAddressAvailable: (a: number, b: any) => any
|
|
|
12
13
|
export const breezsdk_checkMessage: (a: number, b: any) => any;
|
|
13
14
|
export const breezsdk_claimDeposit: (a: number, b: any) => any;
|
|
14
15
|
export const breezsdk_claimHtlcPayment: (a: number, b: any) => any;
|
|
16
|
+
export const breezsdk_deleteContact: (a: number, b: number, c: number) => any;
|
|
15
17
|
export const breezsdk_deleteLightningAddress: (a: number) => any;
|
|
16
18
|
export const breezsdk_disconnect: (a: number) => any;
|
|
17
19
|
export const breezsdk_fetchConversionLimits: (a: number, b: any) => any;
|
|
@@ -22,6 +24,7 @@ export const breezsdk_getPayment: (a: number, b: any) => any;
|
|
|
22
24
|
export const breezsdk_getTokenIssuer: (a: number) => number;
|
|
23
25
|
export const breezsdk_getTokensMetadata: (a: number, b: any) => any;
|
|
24
26
|
export const breezsdk_getUserSettings: (a: number) => any;
|
|
27
|
+
export const breezsdk_listContacts: (a: number, b: any) => any;
|
|
25
28
|
export const breezsdk_listFiatCurrencies: (a: number) => any;
|
|
26
29
|
export const breezsdk_listFiatRates: (a: number) => any;
|
|
27
30
|
export const breezsdk_listPayments: (a: number, b: any) => any;
|
|
@@ -41,11 +44,13 @@ export const breezsdk_sendPayment: (a: number, b: any) => any;
|
|
|
41
44
|
export const breezsdk_signMessage: (a: number, b: any) => any;
|
|
42
45
|
export const breezsdk_startLeafOptimization: (a: number) => void;
|
|
43
46
|
export const breezsdk_syncWallet: (a: number, b: any) => any;
|
|
47
|
+
export const breezsdk_updateContact: (a: number, b: any) => any;
|
|
44
48
|
export const breezsdk_updateUserSettings: (a: number, b: any) => any;
|
|
45
49
|
export const connect: (a: any) => any;
|
|
46
50
|
export const connectWithSigner: (a: any, b: any, c: number, d: number) => any;
|
|
47
51
|
export const defaultConfig: (a: any) => any;
|
|
48
52
|
export const defaultExternalSigner: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number];
|
|
53
|
+
export const defaultPostgresStorageConfig: (a: number, b: number) => any;
|
|
49
54
|
export const defaultsigner_aggregateFrost: (a: number, b: any) => any;
|
|
50
55
|
export const defaultsigner_decryptEcies: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
51
56
|
export const defaultsigner_derivePublicKey: (a: number, b: number, c: number) => any;
|
|
@@ -77,6 +82,7 @@ export const sdkbuilder_withFiatService: (a: number, b: any) => number;
|
|
|
77
82
|
export const sdkbuilder_withKeySet: (a: number, b: any) => number;
|
|
78
83
|
export const sdkbuilder_withLnurlClient: (a: number, b: any) => number;
|
|
79
84
|
export const sdkbuilder_withPaymentObserver: (a: number, b: any) => number;
|
|
85
|
+
export const sdkbuilder_withPostgresStorage: (a: number, b: any) => number;
|
|
80
86
|
export const sdkbuilder_withRestChainService: (a: number, b: number, c: number, d: any, e: number) => number;
|
|
81
87
|
export const sdkbuilder_withStorage: (a: number, b: any) => number;
|
|
82
88
|
export const tokenissuer_burnIssuerToken: (a: number, b: any) => any;
|
|
@@ -113,7 +119,7 @@ export const __wbindgen_export_5: WebAssembly.Table;
|
|
|
113
119
|
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
114
120
|
export const __wbindgen_export_7: WebAssembly.Table;
|
|
115
121
|
export const __externref_table_dealloc: (a: number) => void;
|
|
116
|
-
export const
|
|
117
|
-
export const
|
|
118
|
-
export const
|
|
122
|
+
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2ac8515d28de5817: (a: number, b: number) => void;
|
|
123
|
+
export const closure1068_externref_shim: (a: number, b: number, c: any) => void;
|
|
124
|
+
export const closure651_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
119
125
|
export const __wbindgen_start: () => void;
|
package/nodejs/index.js
CHANGED
|
@@ -4,15 +4,25 @@ const wasmModule = require('./breez_sdk_spark_wasm.js');
|
|
|
4
4
|
// Automatically import and set up the storage for Node.js
|
|
5
5
|
try {
|
|
6
6
|
const { createDefaultStorage } = require('./storage/index.cjs');
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
// Make createDefaultStorage available globally for WASM to find
|
|
9
9
|
global.createDefaultStorage = createDefaultStorage;
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
console.log('Breez SDK: Node.js storage automatically enabled');
|
|
12
12
|
} catch (error) {
|
|
13
13
|
console.warn('Breez SDK: Failed to load Node.js storage:', error.message);
|
|
14
14
|
console.warn('Breez SDK: Storage operations may not work properly. Ignore this warning if you are not using the default storage.');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// Automatically import and set up the PostgreSQL storage for Node.js
|
|
18
|
+
try {
|
|
19
|
+
const { createPostgresStorage } = require('./postgres-storage/index.cjs');
|
|
20
|
+
global.createPostgresStorage = createPostgresStorage;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error.code !== 'MODULE_NOT_FOUND') {
|
|
23
|
+
console.warn('Breez SDK: Failed to load PostgreSQL storage:', error.message);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
// Export all WASM functions
|
|
18
28
|
module.exports = wasmModule;
|
package/nodejs/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Error Classes for Breez SDK PostgreSQL Storage
|
|
3
|
+
* CommonJS version
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
class StorageError extends Error {
|
|
7
|
+
constructor(message, cause = null) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'StorageError';
|
|
10
|
+
this.cause = cause;
|
|
11
|
+
|
|
12
|
+
// Maintain proper stack trace for where our error was thrown (only available on V8)
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, StorageError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = { StorageError };
|