muxed 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +17 -6
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -474,6 +474,7 @@ var AuthorizationCodeProvider = class {
474
474
  config;
475
475
  _redirectUrl;
476
476
  hadTokensBefore = false;
477
+ _state = crypto.randomBytes(32).toString("base64url");
477
478
  constructor(config, serverName) {
478
479
  this.serverName = serverName;
479
480
  this.config = config;
@@ -481,14 +482,14 @@ var AuthorizationCodeProvider = class {
481
482
  this.hadTokensBefore = this.store.hasTokens();
482
483
  }
483
484
  setRedirectUrl(port) {
484
- this._redirectUrl = `http://127.0.0.1:${port}/oauth/callback`;
485
+ this._redirectUrl = `http://localhost:${port}/callback`;
485
486
  }
486
487
  get redirectUrl() {
487
488
  return this._redirectUrl;
488
489
  }
489
490
  get clientMetadata() {
490
491
  return {
491
- redirect_uris: [this._redirectUrl ?? "http://127.0.0.1/oauth/callback"],
492
+ redirect_uris: [this._redirectUrl ?? "http://localhost/callback"],
492
493
  token_endpoint_auth_method: this.config.clientSecret ? "client_secret_basic" : "none",
493
494
  grant_types: ["authorization_code", "refresh_token"],
494
495
  response_types: ["code"],
@@ -501,7 +502,14 @@ var AuthorizationCodeProvider = class {
501
502
  client_id: this.config.clientId,
502
503
  ...this.config.clientSecret ? { client_secret: this.config.clientSecret } : {}
503
504
  };
504
- return this.store.getClientInformation();
505
+ const cached = this.store.getClientInformation();
506
+ if (cached && this._redirectUrl) {
507
+ if (!(cached.redirect_uris ?? []).includes(this._redirectUrl)) {
508
+ this.store.clearClientInformation();
509
+ return;
510
+ }
511
+ }
512
+ return cached;
505
513
  }
506
514
  saveClientInformation(info) {
507
515
  this.store.saveClientInformation(info);
@@ -522,6 +530,9 @@ var AuthorizationCodeProvider = class {
522
530
  openBrowser(url);
523
531
  }
524
532
  }
533
+ async state() {
534
+ return this._state;
535
+ }
525
536
  saveCodeVerifier(codeVerifier) {
526
537
  this.store.saveCodeVerifier(codeVerifier);
527
538
  }
@@ -580,8 +591,8 @@ var CallbackServer = class {
580
591
  res.end();
581
592
  return;
582
593
  }
583
- const url = new URL(req.url ?? "/", `http://127.0.0.1`);
584
- if (url.pathname !== "/oauth/callback") {
594
+ const url = new URL(req.url ?? "/", `http://localhost`);
595
+ if (url.pathname !== "/callback") {
585
596
  res.writeHead(404);
586
597
  res.end("Not found");
587
598
  return;
@@ -615,7 +626,7 @@ var CallbackServer = class {
615
626
  state
616
627
  });
617
628
  });
618
- this.server.listen(port, "127.0.0.1", () => {
629
+ this.server.listen(port, "localhost", () => {
619
630
  const addr = this.server.address();
620
631
  if (addr && typeof addr === "object") this._port = addr.port;
621
632
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muxed",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "MCP server daemon and aggregator CLI – aggregate all your Model Context Protocol servers behind a single background daemon with lazy start, auto-reconnect, and idle shutdown",
5
5
  "type": "module",
6
6
  "exports": {