@calimero-network/mero-js 24.4.1 → 24.6.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.
package/dist/mero-js.d.ts CHANGED
@@ -174,7 +174,10 @@ export declare class MeroJs {
174
174
  * instance already rotated is adopted instead of replaying a stale token.
175
175
  */
176
176
  private performTokenRefresh;
177
- /** Run `fn` under the cross-tab refresh lock, or directly if Web Locks are unavailable. */
177
+ /**
178
+ * Run `fn` under the refresh lock: the token store's own (shared across
179
+ * processes), else the cross-tab Web Lock, else directly.
180
+ */
178
181
  private withRefreshLock;
179
182
  /**
180
183
  * Perform the actual token refresh. Runs with the refresh lock held.
package/dist/mero-js.js CHANGED
@@ -290,8 +290,13 @@ export class MeroJs {
290
290
  }
291
291
  }
292
292
  }
293
- /** Run `fn` under the cross-tab refresh lock, or directly if Web Locks are unavailable. */
293
+ /**
294
+ * Run `fn` under the refresh lock: the token store's own (shared across
295
+ * processes), else the cross-tab Web Lock, else directly.
296
+ */
294
297
  withRefreshLock(fn) {
298
+ if (this.tokenStore?.withLock)
299
+ return this.tokenStore.withLock(fn);
295
300
  const locks = getLockManager();
296
301
  return locks ? locks.request(REFRESH_LOCK_NAME, fn) : fn();
297
302
  }
@@ -65,8 +65,13 @@ import { type Signer } from '../signer/signer.js';
65
65
  * (calimero-network/core#4265). Neither is an op this module signs, so only
66
66
  * the version byte moves. Core signs and checks at 23 from 0.11.0-rc.81, the
67
67
  * first release with both 22 and 23.
68
+ *
69
+ * 24: no layout change. Only a subgroup's creator may open it - flip it to
70
+ * `Open` (calimero-network/core#4522) - an apply-time rule older peers
71
+ * disagree on, since they let any of its admins open it. A UI that offers
72
+ * "make public" should offer it to the creator alone.
68
73
  */
69
- export declare const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 23;
74
+ export declare const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 24;
70
75
  /**
71
76
  * Borsh-encode a `SignedGroupOpenInvitation`.
72
77
  *
@@ -51,8 +51,13 @@ import { resolveSigner } from '../signer/signer.js';
51
51
  * (calimero-network/core#4265). Neither is an op this module signs, so only
52
52
  * the version byte moves. Core signs and checks at 23 from 0.11.0-rc.81, the
53
53
  * first release with both 22 and 23.
54
+ *
55
+ * 24: no layout change. Only a subgroup's creator may open it - flip it to
56
+ * `Open` (calimero-network/core#4522) - an apply-time rule older peers
57
+ * disagree on, since they let any of its admins open it. A UI that offers
58
+ * "make public" should offer it to the creator alone.
54
59
  */
55
- export const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 23;
60
+ export const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 24;
56
61
  /** Domain prefixed to the signable bytes; core's `NAMESPACE_GOVERNANCE_SIGN_DOMAIN`. */
57
62
  const NAMESPACE_SIGN_DOMAIN = new TextEncoder().encode('calimero.namespace.v1');
58
63
  /** `NamespaceOp::Root` is the first variant. */
@@ -3,6 +3,14 @@ export interface TokenStore {
3
3
  getTokens(): TokenData | null;
4
4
  setTokens(data: TokenData): void;
5
5
  clear(): void;
6
+ /**
7
+ * Run `fn` holding a lock that every process sharing this store respects.
8
+ * MeroJs holds it around a token refresh, so two processes on one store never
9
+ * spend the same single-use refresh token. Web Locks cover tabs of one
10
+ * browser; a store shared across processes (a file read by several CLIs, say)
11
+ * needs its own lock, and implements this. Takes precedence over Web Locks.
12
+ */
13
+ withLock?<T>(fn: () => Promise<T>): Promise<T>;
6
14
  }
7
15
  export declare class MemoryTokenStore implements TokenStore {
8
16
  private tokens;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calimero-network/mero-js",
3
- "version": "24.4.1",
3
+ "version": "24.6.0",
4
4
  "description": "Pure JavaScript SDK for Calimero",
5
5
  "type": "module",
6
6
  "exports": {