@abraca/mcp 1.1.2 → 1.3.1

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.
@@ -19452,6 +19452,7 @@ var AbracadabraMCPServer = class {
19452
19452
  this._statusClearTimer = null;
19453
19453
  this._typingInterval = null;
19454
19454
  this._lastChatChannel = null;
19455
+ this._signFn = null;
19455
19456
  this.config = config;
19456
19457
  this.client = new _abraca_dabra.AbracadabraClient({
19457
19458
  url: config.url,
@@ -19487,6 +19488,7 @@ var AbracadabraMCPServer = class {
19487
19488
  const keypair = await loadOrCreateKeypair(this.config.keyFile);
19488
19489
  this._userId = keypair.publicKeyB64;
19489
19490
  const signFn = (challenge) => Promise.resolve(signChallenge(challenge, keypair.privateKey));
19491
+ this._signFn = signFn;
19490
19492
  try {
19491
19493
  await this.client.loginWithKey(keypair.publicKeyB64, signFn);
19492
19494
  } catch (err) {
@@ -19547,6 +19549,11 @@ var AbracadabraMCPServer = class {
19547
19549
  this._rootDocId = docId;
19548
19550
  return existing;
19549
19551
  }
19552
+ if (!this.client.isTokenValid() && this._signFn && this._userId) {
19553
+ console.error("[abracadabra-mcp] JWT expired, re-authenticating...");
19554
+ await this.client.loginWithKey(this._userId, this._signFn);
19555
+ console.error("[abracadabra-mcp] Re-authenticated successfully");
19556
+ }
19550
19557
  const doc = new yjs.Doc({ guid: docId });
19551
19558
  const provider = new _abraca_dabra.AbracadabraProvider({
19552
19559
  name: docId,
@@ -19611,6 +19618,11 @@ var AbracadabraMCPServer = class {
19611
19618
  }
19612
19619
  const activeProvider = this._activeConnection?.provider;
19613
19620
  if (!activeProvider) throw new Error("Not connected. Call connect() first.");
19621
+ if (!this.client.isTokenValid() && this._signFn && this._userId) {
19622
+ console.error("[abracadabra-mcp] JWT expired, re-authenticating...");
19623
+ await this.client.loginWithKey(this._userId, this._signFn);
19624
+ console.error("[abracadabra-mcp] Re-authenticated successfully");
19625
+ }
19614
19626
  const childProvider = await activeProvider.loadChild(docId);
19615
19627
  await waitForSync(childProvider);
19616
19628
  childProvider.awareness.setLocalStateField("user", {