@breeztech/breez-sdk-spark 0.15.1 → 0.17.0

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 (51) hide show
  1. package/breez-sdk-spark.tgz +0 -0
  2. package/bundler/breez_sdk_spark_wasm.d.ts +604 -237
  3. package/bundler/breez_sdk_spark_wasm.js +1 -1
  4. package/bundler/breez_sdk_spark_wasm_bg.js +729 -434
  5. package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
  6. package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +63 -49
  7. package/bundler/storage/index.js +356 -34
  8. package/deno/breez_sdk_spark_wasm.d.ts +604 -237
  9. package/deno/breez_sdk_spark_wasm.js +729 -434
  10. package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
  11. package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +63 -49
  12. package/nodejs/breez_sdk_spark_wasm.d.ts +604 -237
  13. package/nodejs/breez_sdk_spark_wasm.js +741 -441
  14. package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
  15. package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +63 -49
  16. package/nodejs/index.js +10 -10
  17. package/nodejs/index.mjs +13 -8
  18. package/nodejs/mysql-session-store/errors.cjs +13 -0
  19. package/nodejs/{mysql-session-manager → mysql-session-store}/index.cjs +24 -21
  20. package/nodejs/{mysql-session-manager → mysql-session-store}/migrations.cjs +17 -11
  21. package/nodejs/mysql-session-store/package.json +9 -0
  22. package/nodejs/mysql-storage/index.cjs +358 -125
  23. package/nodejs/mysql-storage/migrations.cjs +67 -2
  24. package/nodejs/mysql-token-store/index.cjs +99 -79
  25. package/nodejs/mysql-token-store/migrations.cjs +59 -2
  26. package/nodejs/mysql-tree-store/index.cjs +15 -9
  27. package/nodejs/mysql-tree-store/migrations.cjs +16 -2
  28. package/nodejs/package.json +2 -2
  29. package/nodejs/postgres-session-store/errors.cjs +13 -0
  30. package/nodejs/{postgres-session-manager → postgres-session-store}/index.cjs +23 -23
  31. package/nodejs/{postgres-session-manager → postgres-session-store}/migrations.cjs +14 -14
  32. package/nodejs/postgres-session-store/package.json +9 -0
  33. package/nodejs/postgres-storage/index.cjs +296 -119
  34. package/nodejs/postgres-storage/migrations.cjs +51 -0
  35. package/nodejs/postgres-token-store/index.cjs +89 -64
  36. package/nodejs/postgres-token-store/migrations.cjs +44 -0
  37. package/nodejs/storage/index.cjs +285 -125
  38. package/nodejs/storage/migrations.cjs +47 -0
  39. package/package.json +6 -1
  40. package/ssr/index.js +57 -28
  41. package/web/breez_sdk_spark_wasm.d.ts +667 -286
  42. package/web/breez_sdk_spark_wasm.js +729 -434
  43. package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
  44. package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +63 -49
  45. package/web/passkey-prf-provider/index.d.ts +203 -0
  46. package/web/passkey-prf-provider/index.js +733 -0
  47. package/web/storage/index.js +356 -34
  48. package/nodejs/mysql-session-manager/errors.cjs +0 -13
  49. package/nodejs/mysql-session-manager/package.json +0 -9
  50. package/nodejs/postgres-session-manager/errors.cjs +0 -13
  51. package/nodejs/postgres-session-manager/package.json +0 -9
@@ -1,7 +1,7 @@
1
1
  /**
2
- * CommonJS implementation for Node.js PostgreSQL Session Manager.
2
+ * CommonJS implementation for Node.js PostgreSQL Session Store.
3
3
  *
4
- * Implements the JS-side `SessionManager` interface consumed by the Breez
4
+ * Implements the JS-side `SessionStore` interface consumed by the Breez
5
5
  * SDK WASM bindings: `getSession(serviceIdentityKey)` returns the cached
6
6
  * session for the (tenant, service) pair or `null` when not found, and
7
7
  * `setSession(serviceIdentityKey, session)` upserts a session.
@@ -29,10 +29,10 @@ try {
29
29
  }
30
30
  }
31
31
 
32
- const { SessionManagerError } = require("./errors.cjs");
33
- const { SessionManagerMigrationManager } = require("./migrations.cjs");
32
+ const { SessionStoreError } = require("./errors.cjs");
33
+ const { SessionStoreMigrationManager } = require("./migrations.cjs");
34
34
 
35
- class PostgresSessionManager {
35
+ class PostgresSessionStore {
36
36
  /**
37
37
  * @param {import('pg').Pool} pool
38
38
  * @param {Buffer|Uint8Array} identity - 33-byte secp256k1 compressed pubkey
@@ -41,7 +41,7 @@ class PostgresSessionManager {
41
41
  */
42
42
  constructor(pool, identity, logger = null, runMigration = true) {
43
43
  if (!identity || identity.length !== 33) {
44
- throw new SessionManagerError(
44
+ throw new SessionStoreError(
45
45
  "tenant identity (33-byte secp256k1 pubkey) is required"
46
46
  );
47
47
  }
@@ -54,13 +54,13 @@ class PostgresSessionManager {
54
54
  async initialize() {
55
55
  try {
56
56
  if (this.runMigration) {
57
- const migrationManager = new SessionManagerMigrationManager(this.logger);
57
+ const migrationManager = new SessionStoreMigrationManager(this.logger);
58
58
  await migrationManager.migrate(this.pool);
59
59
  }
60
60
  return this;
61
61
  } catch (error) {
62
- throw new SessionManagerError(
63
- `Failed to initialize PostgreSQL session manager: ${error.message}`,
62
+ throw new SessionStoreError(
63
+ `Failed to initialize PostgreSQL session store: ${error.message}`,
64
64
  error
65
65
  );
66
66
  }
@@ -76,7 +76,7 @@ class PostgresSessionManager {
76
76
  /**
77
77
  * Returns the cached session for the given service identity key, or `null`
78
78
  * if no session is cached. The Rust adapter maps `null` to
79
- * `SessionManagerError::NotFound`.
79
+ * `SessionStoreError::NotFound`.
80
80
  * @param {string} serviceIdentityKey - hex-encoded 33-byte secp256k1 pubkey
81
81
  * @returns {Promise<{token: string, expiration: number} | null>}
82
82
  */
@@ -97,7 +97,7 @@ class PostgresSessionManager {
97
97
  expiration: Number(row.expiration),
98
98
  };
99
99
  } catch (error) {
100
- throw new SessionManagerError(
100
+ throw new SessionStoreError(
101
101
  `Failed to read session: ${error.message}`,
102
102
  error
103
103
  );
@@ -120,7 +120,7 @@ class PostgresSessionManager {
120
120
  [this.identity, serviceKey, session.token, session.expiration]
121
121
  );
122
122
  } catch (error) {
123
- throw new SessionManagerError(
123
+ throw new SessionStoreError(
124
124
  `Failed to write session: ${error.message}`,
125
125
  error
126
126
  );
@@ -130,7 +130,7 @@ class PostgresSessionManager {
130
130
 
131
131
  function _decodePubkey(hex) {
132
132
  if (typeof hex !== "string" || hex.length !== 66) {
133
- throw new SessionManagerError(
133
+ throw new SessionStoreError(
134
134
  "service_identity_key must be a 66-character hex-encoded 33-byte pubkey"
135
135
  );
136
136
  }
@@ -139,13 +139,13 @@ function _decodePubkey(hex) {
139
139
 
140
140
  /**
141
141
  * Convenience factory: creates a pool from a Pool config and returns an
142
- * initialized `PostgresSessionManager`. Most callers should use
143
- * `createPostgresSessionManagerWithPool` instead so the pool can be shared
142
+ * initialized `PostgresSessionStore`. Most callers should use
143
+ * `createPostgresSessionStoreWithPool` instead so the pool can be shared
144
144
  * across stores.
145
145
  */
146
- async function createPostgresSessionManager(poolConfig, identity, logger = null) {
146
+ async function createPostgresSessionStore(poolConfig, identity, logger = null) {
147
147
  const pool = new pg.Pool(poolConfig);
148
- const manager = new PostgresSessionManager(
148
+ const manager = new PostgresSessionStore(
149
149
  pool,
150
150
  identity,
151
151
  logger,
@@ -159,13 +159,13 @@ async function createPostgresSessionManager(poolConfig, identity, logger = null)
159
159
  * Wraps an existing pool — useful when sharing the pool with the storage,
160
160
  * tree store, and token store implementations.
161
161
  */
162
- async function createPostgresSessionManagerWithPool(
162
+ async function createPostgresSessionStoreWithPool(
163
163
  pool,
164
164
  identity,
165
165
  logger = null,
166
166
  runMigration = true
167
167
  ) {
168
- const manager = new PostgresSessionManager(
168
+ const manager = new PostgresSessionStore(
169
169
  pool,
170
170
  identity,
171
171
  logger,
@@ -176,8 +176,8 @@ async function createPostgresSessionManagerWithPool(
176
176
  }
177
177
 
178
178
  module.exports = {
179
- PostgresSessionManager,
180
- createPostgresSessionManager,
181
- createPostgresSessionManagerWithPool,
182
- SessionManagerError,
179
+ PostgresSessionStore,
180
+ createPostgresSessionStore,
181
+ createPostgresSessionStoreWithPool,
182
+ SessionStoreError,
183
183
  };
@@ -1,22 +1,22 @@
1
1
  /**
2
- * Database Migration Manager for Breez SDK PostgreSQL Session Manager.
2
+ * Database Migration Manager for Breez SDK PostgreSQL Session Store.
3
3
  *
4
4
  * Uses a brz_session_schema_migrations table + pg_advisory_xact_lock to safely
5
5
  * run migrations from concurrent processes. Mirrors the schema produced by
6
- * the Rust `PostgresSessionManager`.
6
+ * the Rust `PostgresSessionStore`.
7
7
  */
8
8
 
9
- const { SessionManagerError } = require("./errors.cjs");
9
+ const { SessionStoreError } = require("./errors.cjs");
10
10
 
11
11
  /**
12
- * Advisory lock ID for session-manager migrations.
12
+ * Advisory lock ID for session-store migrations.
13
13
  * Uses a different lock ID from the storage / tree store / token store
14
14
  * migrations to avoid contention. Derived from ASCII bytes of "SESN"
15
15
  * (0x5345534E).
16
16
  */
17
17
  const MIGRATION_LOCK_ID = "1397245774"; // 0x5345534E as decimal string
18
18
 
19
- class SessionManagerMigrationManager {
19
+ class SessionStoreMigrationManager {
20
20
  constructor(logger = null) {
21
21
  this.logger = logger;
22
22
  }
@@ -51,7 +51,7 @@ class SessionManagerMigrationManager {
51
51
  if (currentVersion >= migrations.length) {
52
52
  this._log(
53
53
  "info",
54
- `Session manager database is up to date (version ${currentVersion})`
54
+ `Session store database is up to date (version ${currentVersion})`
55
55
  );
56
56
  await client.query("COMMIT");
57
57
  return;
@@ -59,7 +59,7 @@ class SessionManagerMigrationManager {
59
59
 
60
60
  this._log(
61
61
  "info",
62
- `Migrating session manager database from version ${currentVersion} to ${migrations.length}`
62
+ `Migrating session store database from version ${currentVersion} to ${migrations.length}`
63
63
  );
64
64
 
65
65
  for (let i = currentVersion; i < migrations.length; i++) {
@@ -67,7 +67,7 @@ class SessionManagerMigrationManager {
67
67
  const version = i + 1;
68
68
  this._log(
69
69
  "debug",
70
- `Running session manager migration ${version}: ${migration.name}`
70
+ `Running session store migration ${version}: ${migration.name}`
71
71
  );
72
72
 
73
73
  for (const sql of migration.sql) {
@@ -83,12 +83,12 @@ class SessionManagerMigrationManager {
83
83
  await client.query("COMMIT");
84
84
  this._log(
85
85
  "info",
86
- "Session manager database migration completed successfully"
86
+ "Session store database migration completed successfully"
87
87
  );
88
88
  } catch (error) {
89
89
  await client.query("ROLLBACK").catch(() => {});
90
- throw new SessionManagerError(
91
- `Session manager migration failed: ${error.message}`,
90
+ throw new SessionStoreError(
91
+ `Session store migration failed: ${error.message}`,
92
92
  error
93
93
  );
94
94
  } finally {
@@ -137,12 +137,12 @@ class SessionManagerMigrationManager {
137
137
  if (this.logger && typeof this.logger.log === "function") {
138
138
  this.logger.log({ line: message, level });
139
139
  } else if (level === "error") {
140
- console.error(`[SessionManagerMigrationManager] ${message}`);
140
+ console.error(`[SessionStoreMigrationManager] ${message}`);
141
141
  }
142
142
  }
143
143
 
144
144
  /**
145
- * Migrations matching the Rust PostgresSessionManager schema exactly.
145
+ * Migrations matching the Rust PostgresSessionStore schema exactly.
146
146
  */
147
147
  _getMigrations() {
148
148
  return [
@@ -162,4 +162,4 @@ class SessionManagerMigrationManager {
162
162
  }
163
163
  }
164
164
 
165
- module.exports = { SessionManagerMigrationManager };
165
+ module.exports = { SessionStoreMigrationManager };
@@ -0,0 +1,9 @@
1
+ {
2
+ "dependencies": {
3
+ "pg": "^8.18.0"
4
+ },
5
+ "description": "Node.js PostgreSQL session store implementation for Breez SDK WASM (CommonJS)",
6
+ "main": "index.cjs",
7
+ "name": "@breez-sdk/postgres-session-store",
8
+ "version": "1.0.0"
9
+ }