@breeztech/breez-sdk-spark 0.13.11-dev1 → 0.13.12-dev1

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.
Files changed (35) hide show
  1. package/breez-sdk-spark.tgz +0 -0
  2. package/bundler/breez_sdk_spark_wasm.d.ts +124 -0
  3. package/bundler/breez_sdk_spark_wasm.js +1 -1
  4. package/bundler/breez_sdk_spark_wasm_bg.js +369 -33
  5. package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
  6. package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +25 -7
  7. package/deno/breez_sdk_spark_wasm.d.ts +124 -0
  8. package/deno/breez_sdk_spark_wasm.js +369 -33
  9. package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
  10. package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +25 -7
  11. package/nodejs/breez_sdk_spark_wasm.d.ts +124 -0
  12. package/nodejs/breez_sdk_spark_wasm.js +377 -33
  13. package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
  14. package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +25 -7
  15. package/nodejs/index.js +22 -0
  16. package/nodejs/index.mjs +8 -0
  17. package/nodejs/mysql-session-manager/errors.cjs +13 -0
  18. package/nodejs/mysql-session-manager/index.cjs +144 -0
  19. package/nodejs/mysql-session-manager/migrations.cjs +102 -0
  20. package/nodejs/mysql-session-manager/package.json +9 -0
  21. package/nodejs/mysql-storage/index.cjs +1 -0
  22. package/nodejs/mysql-token-store/index.cjs +4 -12
  23. package/nodejs/mysql-tree-store/index.cjs +2 -0
  24. package/nodejs/package.json +2 -0
  25. package/nodejs/postgres-session-manager/errors.cjs +13 -0
  26. package/nodejs/postgres-session-manager/index.cjs +165 -0
  27. package/nodejs/postgres-session-manager/migrations.cjs +126 -0
  28. package/nodejs/postgres-session-manager/package.json +9 -0
  29. package/nodejs/postgres-token-store/index.cjs +2 -13
  30. package/package.json +1 -1
  31. package/ssr/index.js +48 -0
  32. package/web/breez_sdk_spark_wasm.d.ts +149 -7
  33. package/web/breez_sdk_spark_wasm.js +369 -33
  34. package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
  35. package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +25 -7
@@ -1,11 +1,19 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const __wbg_bitcoinchainservicehandle_free: (a: number, b: number) => void;
4
5
  export const __wbg_breezsdk_free: (a: number, b: number) => void;
5
6
  export const __wbg_defaultsigner_free: (a: number, b: number) => void;
7
+ export const __wbg_mysqlconnectionpool_free: (a: number, b: number) => void;
6
8
  export const __wbg_passkey_free: (a: number, b: number) => void;
7
9
  export const __wbg_sdkbuilder_free: (a: number, b: number) => void;
10
+ export const __wbg_sspconnectionmanager_free: (a: number, b: number) => void;
8
11
  export const __wbg_tokenissuer_free: (a: number, b: number) => void;
12
+ export const bitcoinchainservicehandle_broadcastTransaction: (a: number, b: number, c: number) => any;
13
+ export const bitcoinchainservicehandle_getAddressUtxos: (a: number, b: number, c: number) => any;
14
+ export const bitcoinchainservicehandle_getTransactionHex: (a: number, b: number, c: number) => any;
15
+ export const bitcoinchainservicehandle_getTransactionStatus: (a: number, b: number, c: number) => any;
16
+ export const bitcoinchainservicehandle_recommendedFees: (a: number) => any;
9
17
  export const breezsdk_addContact: (a: number, b: any) => any;
10
18
  export const breezsdk_addEventListener: (a: number, b: any) => any;
11
19
  export const breezsdk_buyBitcoin: (a: number, b: any) => any;
@@ -52,6 +60,8 @@ export const breezsdk_updateContact: (a: number, b: any) => any;
52
60
  export const breezsdk_updateUserSettings: (a: number, b: any) => any;
53
61
  export const connect: (a: any) => any;
54
62
  export const connectWithSigner: (a: any, b: any, c: number, d: number) => any;
63
+ export const createMysqlConnectionPool: (a: any) => [number, number, number];
64
+ export const createPostgresConnectionPool: (a: any) => [number, number, number];
55
65
  export const defaultConfig: (a: any) => any;
56
66
  export const defaultExternalSigner: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number];
57
67
  export const defaultMysqlStorageConfig: (a: number, b: number) => any;
@@ -77,6 +87,8 @@ export const defaultsigner_staticDepositSigningKey: (a: number, b: number) => an
77
87
  export const defaultsigner_subtractSecrets: (a: number, b: any, c: any) => any;
78
88
  export const getSparkStatus: () => any;
79
89
  export const initLogging: (a: any, b: number, c: number) => any;
90
+ export const newRestChainService: (a: number, b: number, c: any, d: any, e: number) => number;
91
+ export const newSspConnectionManager: (a: number, b: number) => number;
80
92
  export const passkey_getWallet: (a: number, b: number, c: number) => any;
81
93
  export const passkey_isAvailable: (a: number) => any;
82
94
  export const passkey_listLabels: (a: number) => any;
@@ -90,10 +102,14 @@ export const sdkbuilder_withDefaultStorage: (a: number, b: number, c: number) =>
90
102
  export const sdkbuilder_withFiatService: (a: number, b: any) => number;
91
103
  export const sdkbuilder_withKeySet: (a: number, b: any) => number;
92
104
  export const sdkbuilder_withLnurlClient: (a: number, b: any) => number;
93
- export const sdkbuilder_withMysqlBackend: (a: number, b: any) => number;
105
+ export const sdkbuilder_withMysqlBackend: (a: number, b: any) => [number, number, number];
106
+ export const sdkbuilder_withMysqlConnectionPool: (a: number, b: number) => number;
94
107
  export const sdkbuilder_withPaymentObserver: (a: number, b: any) => number;
95
- export const sdkbuilder_withPostgresBackend: (a: number, b: any) => number;
108
+ export const sdkbuilder_withPostgresBackend: (a: number, b: any) => [number, number, number];
109
+ export const sdkbuilder_withPostgresConnectionPool: (a: number, b: number) => number;
96
110
  export const sdkbuilder_withRestChainService: (a: number, b: number, c: number, d: any, e: number) => number;
111
+ export const sdkbuilder_withSessionManager: (a: number, b: any) => number;
112
+ export const sdkbuilder_withSspConnectionManager: (a: number, b: number) => number;
97
113
  export const sdkbuilder_withStorage: (a: number, b: any) => number;
98
114
  export const tokenissuer_burnIssuerToken: (a: number, b: any) => any;
99
115
  export const tokenissuer_createIssuerToken: (a: number, b: any) => any;
@@ -120,16 +136,18 @@ export const intounderlyingsink_close: (a: number) => any;
120
136
  export const intounderlyingsink_write: (a: number, b: any) => any;
121
137
  export const intounderlyingsource_cancel: (a: number) => void;
122
138
  export const intounderlyingsource_pull: (a: number, b: any) => any;
139
+ export const __wbg_postgresconnectionpool_free: (a: number, b: number) => void;
123
140
  export const defaultPostgresStorageConfig: (a: number, b: number) => any;
124
- export const wasm_bindgen__convert__closures_____invoke__h27d08ee20b1285c7: (a: number, b: number, c: any) => [number, number];
125
- export const wasm_bindgen__convert__closures_____invoke__h27d08ee20b1285c7_4: (a: number, b: number, c: any) => [number, number];
126
- export const wasm_bindgen__convert__closures_____invoke__h27d08ee20b1285c7_5: (a: number, b: number, c: any) => [number, number];
127
- export const wasm_bindgen__convert__closures_____invoke__h27d08ee20b1285c7_6: (a: number, b: number, c: any) => [number, number];
141
+ export const wasm_bindgen__convert__closures_____invoke__h459c42c6ffe5f52c: (a: number, b: number, c: any) => [number, number];
142
+ export const wasm_bindgen__convert__closures_____invoke__h459c42c6ffe5f52c_4: (a: number, b: number, c: any) => [number, number];
143
+ export const wasm_bindgen__convert__closures_____invoke__h459c42c6ffe5f52c_5: (a: number, b: number, c: any) => [number, number];
144
+ export const wasm_bindgen__convert__closures_____invoke__h459c42c6ffe5f52c_6: (a: number, b: number, c: any) => [number, number];
145
+ export const wasm_bindgen__convert__closures_____invoke__h459c42c6ffe5f52c_7: (a: number, b: number, c: any) => [number, number];
128
146
  export const wasm_bindgen__convert__closures_____invoke__h41057d61edf43a32: (a: number, b: number, c: any, d: any) => void;
129
147
  export const wasm_bindgen__convert__closures_____invoke__h4819aba3eed2db57: (a: number, b: number, c: any) => void;
130
148
  export const wasm_bindgen__convert__closures_____invoke__h4819aba3eed2db57_2: (a: number, b: number, c: any) => void;
131
149
  export const wasm_bindgen__convert__closures_____invoke__h4819aba3eed2db57_3: (a: number, b: number, c: any) => void;
132
- export const wasm_bindgen__convert__closures_____invoke__h484cd36e13f37bd7: (a: number, b: number) => void;
150
+ export const wasm_bindgen__convert__closures_____invoke__h124479769cd429fd: (a: number, b: number) => void;
133
151
  export const __wbindgen_malloc: (a: number, b: number) => number;
134
152
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
135
153
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -1068,6 +1068,16 @@ export interface SendPaymentResponse {
1068
1068
  payment: Payment;
1069
1069
  }
1070
1070
 
1071
+ export interface Session {
1072
+ token: string;
1073
+ expiration: number;
1074
+ }
1075
+
1076
+ export interface SessionManager {
1077
+ getSession: (serviceIdentityKey: string) => Promise<Session>;
1078
+ setSession: (serviceIdentityKey: string, session: Session) => Promise<void>;
1079
+ }
1080
+
1071
1081
  export interface SetLnurlMetadataItem {
1072
1082
  paymentHash: string;
1073
1083
  senderComment?: string;
@@ -1361,6 +1371,8 @@ export type SendPaymentOptions = { type: "bitcoinAddress"; confirmationSpeed: On
1361
1371
 
1362
1372
  export type ServiceStatus = "operational" | "degraded" | "partial" | "unknown" | "major";
1363
1373
 
1374
+ export type SessionManagerError = { type: "notFound" } | ({ type: "generic" } & string);
1375
+
1364
1376
  export type SparkHtlcStatus = "waitingForPreimage" | "preimageShared" | "returned";
1365
1377
 
1366
1378
  export type StableBalanceActiveLabel = { type: "set"; label: string } | { type: "unset" };
@@ -1378,6 +1390,25 @@ export type UpdateDepositPayload = { type: "claimError"; error: DepositClaimErro
1378
1390
  export type WebhookEventType = { type: "lightningReceiveFinished" } | { type: "lightningSendFinished" } | { type: "coopExitFinished" } | { type: "staticDepositFinished" } | ({ type: "unknown" } & string);
1379
1391
 
1380
1392
 
1393
+ /**
1394
+ * Rust-built implementation of the JS `BitcoinChainService` interface.
1395
+ *
1396
+ * Returned by factories like [`new_rest_chain_service`]; users see it as a
1397
+ * `BitcoinChainService` and pass it to `withChainService`. Pass the same
1398
+ * instance to multiple `SdkBuilder`s to share a single underlying HTTP
1399
+ * client (and its connection pool) across SDK instances.
1400
+ */
1401
+ export class BitcoinChainServiceHandle {
1402
+ private constructor();
1403
+ free(): void;
1404
+ [Symbol.dispose](): void;
1405
+ broadcastTransaction(tx: string): Promise<void>;
1406
+ getAddressUtxos(address: string): Promise<any>;
1407
+ getTransactionHex(txid: string): Promise<any>;
1408
+ getTransactionStatus(txid: string): Promise<any>;
1409
+ recommendedFees(): Promise<any>;
1410
+ }
1411
+
1381
1412
  export class BreezSdk {
1382
1413
  private constructor();
1383
1414
  free(): void;
@@ -1486,6 +1517,16 @@ export class IntoUnderlyingSource {
1486
1517
  pull(controller: ReadableStreamDefaultController): Promise<any>;
1487
1518
  }
1488
1519
 
1520
+ /**
1521
+ * A shareable MySQL connection pool. See [`PostgresConnectionPool`](super::postgres_pool::PostgresConnectionPool)
1522
+ * for sharing semantics and lifecycle.
1523
+ */
1524
+ export class MysqlConnectionPool {
1525
+ private constructor();
1526
+ free(): void;
1527
+ [Symbol.dispose](): void;
1528
+ }
1529
+
1489
1530
  /**
1490
1531
  * Passkey-based wallet operations using WebAuthn PRF extension.
1491
1532
  *
@@ -1529,6 +1570,22 @@ export class Passkey {
1529
1570
  storeLabel(label: string): Promise<void>;
1530
1571
  }
1531
1572
 
1573
+ /**
1574
+ * A shareable Postgres connection pool.
1575
+ *
1576
+ * Construct via [`create_postgres_connection_pool`] and pass the same handle to multiple
1577
+ * `SdkBuilder`s via `withPostgresConnectionPool` to share connections across SDKs.
1578
+ * Per-tenant scoping is derived from each SDK's seed.
1579
+ *
1580
+ * The pool's lifecycle is controlled by the integrator: it stays alive as
1581
+ * long as any reference is held. `disconnect()` does **not** close the pool.
1582
+ */
1583
+ export class PostgresConnectionPool {
1584
+ private constructor();
1585
+ free(): void;
1586
+ [Symbol.dispose](): void;
1587
+ }
1588
+
1532
1589
  export class SdkBuilder {
1533
1590
  private constructor();
1534
1591
  free(): void;
@@ -1541,13 +1598,57 @@ export class SdkBuilder {
1541
1598
  withFiatService(fiat_service: FiatService): SdkBuilder;
1542
1599
  withKeySet(config: KeySetConfig): SdkBuilder;
1543
1600
  withLnurlClient(lnurl_client: RestClient): SdkBuilder;
1601
+ /**
1602
+ * **Deprecated.** Call `withMysqlConnectionPool(config)` and `withMysqlConnectionPool(pool)` instead.
1603
+ */
1544
1604
  withMysqlBackend(config: MysqlStorageConfig): SdkBuilder;
1605
+ /**
1606
+ * Sets a shared `MySQL` connection pool as the backend for all stores.
1607
+ * Construct via `createMysqlConnectionPool` and pass the same handle to multiple
1608
+ * `SdkBuilder`s to share connections across SDKs.
1609
+ */
1610
+ withMysqlConnectionPool(pool: MysqlConnectionPool): SdkBuilder;
1545
1611
  withPaymentObserver(payment_observer: PaymentObserver): SdkBuilder;
1612
+ /**
1613
+ * **Deprecated.** Call `withPostgresConnectionPool(config)` and `withPostgresConnectionPool(pool)` instead.
1614
+ */
1546
1615
  withPostgresBackend(config: PostgresStorageConfig): SdkBuilder;
1616
+ /**
1617
+ * Sets a shared `PostgreSQL` connection pool as the backend for all
1618
+ * stores. Construct via `createPostgresConnectionPool` and pass the same handle
1619
+ * to multiple `SdkBuilder`s to share connections across SDKs.
1620
+ */
1621
+ withPostgresConnectionPool(pool: PostgresConnectionPool): SdkBuilder;
1547
1622
  withRestChainService(url: string, api_type: ChainApiType, credentials?: Credentials | null): SdkBuilder;
1623
+ /**
1624
+ * Sets a custom session manager used to persist authentication sessions.
1625
+ *
1626
+ * Provide a shared, persistent implementation (e.g. backed by `PostgreSQL`
1627
+ * or Redis) to let multiple SDK instances share authentication state and
1628
+ * bootstrap quickly. If not set, an in-memory session manager is used.
1629
+ */
1630
+ withSessionManager(session_manager: SessionManager): SdkBuilder;
1631
+ /**
1632
+ * Reuses a shared SSP connection across SDK instances. Pass the same
1633
+ * manager to every `SdkBuilder` whose SSP traffic should share an
1634
+ * underlying HTTP client.
1635
+ */
1636
+ withSspConnectionManager(manager: SspConnectionManager): SdkBuilder;
1548
1637
  withStorage(storage: Storage): SdkBuilder;
1549
1638
  }
1550
1639
 
1640
+ /**
1641
+ * Shared transport for SSP GraphQL traffic across SDK instances.
1642
+ *
1643
+ * All SDK instances built with the same `SspConnectionManager` share a single
1644
+ * underlying HTTP client (and its h2 connection pool) for SSP requests.
1645
+ */
1646
+ export class SspConnectionManager {
1647
+ private constructor();
1648
+ free(): void;
1649
+ [Symbol.dispose](): void;
1650
+ }
1651
+
1551
1652
  export class TokenIssuer {
1552
1653
  private constructor();
1553
1654
  free(): void;
@@ -1565,6 +1666,16 @@ export function connect(request: ConnectRequest): Promise<BreezSdk>;
1565
1666
 
1566
1667
  export function connectWithSigner(config: Config, signer: ExternalSigner, storage_dir: string): Promise<BreezSdk>;
1567
1668
 
1669
+ /**
1670
+ * Creates a shareable MySQL connection pool from the given config.
1671
+ */
1672
+ export function createMysqlConnectionPool(config: MysqlStorageConfig): MysqlConnectionPool;
1673
+
1674
+ /**
1675
+ * Creates a shareable Postgres connection pool from the given config.
1676
+ */
1677
+ export function createPostgresConnectionPool(config: PostgresStorageConfig): PostgresConnectionPool;
1678
+
1568
1679
  export function defaultConfig(network: Network): Config;
1569
1680
 
1570
1681
  export function defaultExternalSigner(mnemonic: string, passphrase: string | null | undefined, network: Network, key_set_config?: KeySetConfig | null): DefaultSigner;
@@ -1598,6 +1709,19 @@ export function getSparkStatus(): Promise<SparkStatus>;
1598
1709
 
1599
1710
  export function initLogging(logger: Logger, filter?: string | null): Promise<void>;
1600
1711
 
1712
+ /**
1713
+ * Constructs a shareable REST-based Bitcoin chain service.
1714
+ *
1715
+ * Pass the returned chain service to multiple `SdkBuilder`s via
1716
+ * `withChainService` to reuse one HTTP client across SDK instances. All
1717
+ * SDKs sharing the chain service must use the same `network`.
1718
+ *
1719
+ * For one-off, non-shared use, prefer `withRestChainService`.
1720
+ */
1721
+ export function newRestChainService(url: string, network: Network, api_type: ChainApiType, credentials?: Credentials | null): BitcoinChainService;
1722
+
1723
+ export function newSspConnectionManager(user_agent?: string | null): SspConnectionManager;
1724
+
1601
1725
  /**
1602
1726
  * Entry point invoked by JavaScript in a worker.
1603
1727
  */