@breeztech/breez-sdk-spark 0.12.2 → 0.12.3

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/README.md +68 -69
  2. package/breez-sdk-spark.tgz +0 -0
  3. package/bundler/breez_sdk_spark_wasm.d.ts +734 -602
  4. package/bundler/breez_sdk_spark_wasm_bg.js +175 -78
  5. package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
  6. package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +8 -6
  7. package/bundler/storage/index.js +65 -43
  8. package/deno/breez_sdk_spark_wasm.d.ts +734 -602
  9. package/deno/breez_sdk_spark_wasm.js +165 -78
  10. package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
  11. package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +8 -6
  12. package/nodejs/breez_sdk_spark_wasm.d.ts +734 -602
  13. package/nodejs/breez_sdk_spark_wasm.js +175 -78
  14. package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
  15. package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +8 -6
  16. package/nodejs/index.js +16 -2
  17. package/nodejs/index.mjs +25 -0
  18. package/nodejs/package.json +3 -1
  19. package/nodejs/postgres-storage/index.cjs +42 -31
  20. package/nodejs/postgres-storage/migrations.cjs +24 -0
  21. package/nodejs/postgres-token-store/errors.cjs +13 -0
  22. package/nodejs/postgres-token-store/index.cjs +857 -0
  23. package/nodejs/postgres-token-store/migrations.cjs +163 -0
  24. package/nodejs/postgres-token-store/package.json +9 -0
  25. package/nodejs/postgres-tree-store/index.cjs +12 -2
  26. package/nodejs/storage/index.cjs +19 -28
  27. package/nodejs/storage/migrations.cjs +18 -0
  28. package/package.json +7 -2
  29. package/ssr/index.d.ts +2 -0
  30. package/ssr/index.js +126 -0
  31. package/web/breez_sdk_spark_wasm.d.ts +742 -608
  32. package/web/breez_sdk_spark_wasm.js +165 -78
  33. package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
  34. package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +8 -6
  35. package/web/storage/index.js +65 -43
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # Breez SDK - Nodeless (_Spark Implementation_)
1
+ # Breez SDK - Spark
2
2
 
3
- ## **What Is the Breez SDK?**
3
+ ## **What is the Breez SDK?**
4
4
 
5
5
  The Breez SDK provides developers with an end-to-end solution for integrating self-custodial Lightning into their apps and services. It eliminates the need for third parties, simplifies the complexities of Bitcoin and Lightning, and enables seamless onboarding for billions of users to the future of value transfer.
6
6
 
7
- ## **What Is the Breez SDK - Nodeless _(Spark Implementation)_?**
7
+ ## **What is the Breez SDK - Spark?**
8
8
 
9
9
  It’s a nodeless integration that offers a self-custodial, end-to-end solution for integrating Lightning payments, utilizing Spark with on-chain interoperability and third-party fiat on-ramps.
10
10
 
@@ -24,99 +24,98 @@ yarn add @breeztech/breez-sdk-spark
24
24
 
25
25
  ## Usage
26
26
 
27
- Head over to the Breez SDK - Nodeless _(Spark Implementation)_ [documentation](https://sdk-doc-spark.breez.technology/) to start implementing Lightning in your app.
27
+ Head over to the Breez SDK - Spark [documentation](https://sdk-doc-spark.breez.technology/) to start implementing Lightning in your app.
28
28
 
29
29
  ### Web
30
30
 
31
- When developing a browser application you should import `@breeztech/breez-sdk-spark` (or the explicit `@breeztech/breez-sdk-spark/web` submodule).
31
+ When developing a browser application, import from `@breeztech/breez-sdk-spark` (or the explicit `@breeztech/breez-sdk-spark/web` subpath).
32
32
 
33
- It's important to first initialise the WebAssembly module by using `await init()` before making any other calls to the module.
33
+ Call `await init()` to load the WebAssembly module before using any other SDK methods.
34
34
 
35
35
  ```js
36
36
  import init, {
37
- initLogging,
38
37
  defaultConfig,
39
- SdkBuilder,
38
+ connect,
40
39
  } from "@breeztech/breez-sdk-spark/web";
41
40
 
42
- // Initialise the WebAssembly module
43
41
  await init();
42
+
43
+ const config = defaultConfig("mainnet");
44
+ config.apiKey = "<your api key>";
45
+
46
+ const sdk = await connect({
47
+ config,
48
+ seed: { type: "mnemonic", mnemonic: "<words>", passphrase: undefined },
49
+ storageDir: "./.data",
50
+ });
51
+ ```
52
+
53
+ ### SSR Frameworks (Next.js, SvelteKit, Nuxt, Remix)
54
+
55
+ Use the `@breeztech/breez-sdk-spark/ssr` subpath in SSR applications. It can be imported during server-side rendering without errors — no WASM is loaded, no browser or Node.js APIs are touched. Call `init()` on the client to load the WASM module before using SDK functions.
56
+
57
+ ```tsx
58
+ "use client";
59
+ import { useEffect, useState } from "react";
60
+ import init, { connect, defaultConfig } from "@breeztech/breez-sdk-spark/ssr";
61
+
62
+ export default function Wallet() {
63
+ const [sdk, setSdk] = useState(null);
64
+
65
+ useEffect(() => {
66
+ (async () => {
67
+ await init(); // Loads WASM — client-side only
68
+ const config = defaultConfig("mainnet");
69
+ config.apiKey = "<your api key>";
70
+ const s = await connect({
71
+ config,
72
+ seed: { type: "mnemonic", mnemonic: "<words>", passphrase: undefined },
73
+ storageDir: "./.data",
74
+ });
75
+ setSdk(s);
76
+ })();
77
+ }, []);
78
+
79
+ return <div>{sdk ? "Connected" : "Loading..."}</div>;
80
+ }
44
81
  ```
45
82
 
46
83
  ### Node.js
47
84
 
48
85
  > **Note**: This package requires Node.js v22 or higher.
49
86
 
50
- When developing a node.js application you should require `@breeztech/breez-sdk-spark` (or the explicit `@breeztech/breez-sdk-spark/node` submodule).
87
+ When developing a Node.js application, use `require("@breeztech/breez-sdk-spark")` (or the explicit `@breeztech/breez-sdk-spark/nodejs` subpath). No `init()` call is needed — the WASM module loads automatically.
51
88
 
52
89
  ```js
53
90
  const {
54
- initLogging,
55
91
  defaultConfig,
56
- SdkBuilder,
57
- } = require("@breeztech/breez-sdk-spark/nodejs");
58
- const { Command } = require("commander");
59
- require("dotenv").config();
60
-
61
- class JsLogger {
62
- log = (logEntry) => {
63
- console.log(
64
- `[${new Date().toISOString()} ${logEntry.level}]: ${logEntry.line}`
65
- );
66
- };
67
- }
68
-
69
- const fileLogger = new JsLogger();
70
-
71
- class JsEventListener {
72
- onEvent = (event) => {
73
- fileLogger.log({
74
- level: "INFO",
75
- line: `Received event: ${JSON.stringify(event)}`,
76
- });
77
- };
78
- }
92
+ connect,
93
+ } = require("@breeztech/breez-sdk-spark");
79
94
 
80
- const eventListener = new JsEventListener();
81
- const program = new Command();
95
+ const config = defaultConfig("mainnet");
96
+ config.apiKey = process.env.BREEZ_API_KEY;
82
97
 
83
- const initSdk = async () => {
84
- // Set the logger to trace
85
- await initLogging(fileLogger);
86
-
87
- // Get the mnemonic
88
- const mnemonic = process.env.MNEMONIC;
89
-
90
- // Connect using the config
91
- let config = defaultConfig("regtest");
92
- config.apiKey = process.env.BREEZ_API_KEY;
93
- console.log(`defaultConfig: ${JSON.stringify(config)}`);
94
-
95
- let sdkBuilder = SdkBuilder.new(config, {
96
- type: "mnemonic",
97
- mnemonic: mnemonic,
98
- });
99
- sdkBuilder = await sdkBuilder.withDefaultStorage("./.data");
100
-
101
- const sdk = await sdkBuilder.build();
102
-
103
- await sdk.addEventListener(eventListener);
104
- return sdk;
105
- };
106
-
107
- program
108
- .name("breez-sdk-spark-wasm-cli")
109
- .description("CLI for Breez SDK Spark - Wasm");
110
-
111
- program.command("get-info").action(async () => {
112
- const sdk = await initSdk();
113
- const res = await sdk.getInfo({});
114
- console.log(`getInfo: ${JSON.stringify(res)}`);
98
+ const sdk = await connect({
99
+ config,
100
+ seed: { type: "mnemonic", mnemonic: process.env.MNEMONIC, passphrase: undefined },
101
+ storageDir: "./.data",
115
102
  });
116
103
 
117
- program.parse();
104
+ const info = await sdk.getInfo({});
105
+ console.log(`Balance: ${info.balanceSats} sats`);
118
106
  ```
119
107
 
108
+ ### Subpath Exports
109
+
110
+ | Subpath | Environment | Module Format |
111
+ |---------|-------------|---------------|
112
+ | `@breeztech/breez-sdk-spark` | Node.js / Browser (default) | CJS / ESM |
113
+ | `@breeztech/breez-sdk-spark/web` | Browser | ESM |
114
+ | `@breeztech/breez-sdk-spark/nodejs` | Node.js | CJS |
115
+ | `@breeztech/breez-sdk-spark/bundler` | Bundler (Webpack, Vite) | ESM |
116
+ | `@breeztech/breez-sdk-spark/deno` | Deno | ESM |
117
+ | `@breeztech/breez-sdk-spark/ssr` | SSR (explicit) | ESM |
118
+
120
119
  ## Pricing
121
120
 
122
121
  The Breez SDK is **free** for developers.
Binary file