closeclaw 3.0.4 → 3.0.5

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/cli.cjs CHANGED
@@ -417,10 +417,20 @@ function verifyLicense(key) {
417
417
  throw new Error("License key is required (set NODE_ENV=development to bypass)");
418
418
  }
419
419
  try {
420
+ const parts = key.split(".");
421
+ if (parts.length !== 3) throw new Error("Invalid JWT format");
422
+ const [headerB64, payloadB64, signatureB64] = parts;
423
+ const header = JSON.parse(Buffer.from(headerB64, "base64url").toString());
424
+ if (header.alg !== "EdDSA") throw new Error(`Unsupported algorithm: ${header.alg}`);
420
425
  const publicKey = (0, import_node_crypto2.createPublicKey)(ED25519_PUBLIC_KEY_PEM);
421
- const decoded = import_jsonwebtoken.default.verify(key, publicKey, {
422
- algorithms: ["EdDSA"]
423
- });
426
+ const signingInput = `${headerB64}.${payloadB64}`;
427
+ const signature = Buffer.from(signatureB64, "base64url");
428
+ const valid = (0, import_node_crypto2.verify)(null, Buffer.from(signingInput), publicKey, signature);
429
+ if (!valid) throw new Error("Invalid signature");
430
+ const decoded = JSON.parse(Buffer.from(payloadB64, "base64url").toString());
431
+ if (typeof decoded.exp === "number" && decoded.exp < Math.floor(Date.now() / 1e3)) {
432
+ throw new Error("License expired");
433
+ }
424
434
  if (!decoded.sub || typeof decoded.sub !== "string") {
425
435
  throw new Error("License missing 'sub' claim");
426
436
  }
@@ -448,10 +458,10 @@ function verifyLicense(key) {
448
458
  _devMode = false;
449
459
  return _license;
450
460
  } catch (err) {
451
- if (err instanceof import_jsonwebtoken.default.TokenExpiredError) {
461
+ if (err instanceof jwt.TokenExpiredError) {
452
462
  throw new Error("License key has expired");
453
463
  }
454
- if (err instanceof import_jsonwebtoken.default.JsonWebTokenError) {
464
+ if (err instanceof jwt.JsonWebTokenError) {
455
465
  throw new Error(`Invalid license key: ${err.message}`);
456
466
  }
457
467
  throw err;
@@ -480,11 +490,10 @@ function _resetLicense() {
480
490
  _license = null;
481
491
  _devMode = false;
482
492
  }
483
- var import_jsonwebtoken, import_node_crypto2, ED25519_PUBLIC_KEY_PEM, _license, _devMode, DEV_LICENSE;
493
+ var import_node_crypto2, ED25519_PUBLIC_KEY_PEM, _license, _devMode, DEV_LICENSE;
484
494
  var init_license = __esm({
485
495
  "src/license.ts"() {
486
496
  "use strict";
487
- import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
488
497
  import_node_crypto2 = require("crypto");
489
498
  init_connection();
490
499
  ED25519_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
@@ -960,13 +969,13 @@ function getSecret() {
960
969
  return _secret;
961
970
  }
962
971
  function signAccessToken(payload) {
963
- return import_jsonwebtoken2.default.sign(payload, getSecret(), {
972
+ return import_jsonwebtoken.default.sign(payload, getSecret(), {
964
973
  algorithm: "HS256",
965
974
  expiresIn: "15m"
966
975
  });
967
976
  }
968
977
  function verifyAccessToken(token) {
969
- return import_jsonwebtoken2.default.verify(token, getSecret(), {
978
+ return import_jsonwebtoken.default.verify(token, getSecret(), {
970
979
  algorithms: ["HS256"]
971
980
  });
972
981
  }
@@ -976,11 +985,11 @@ function generateRefreshToken() {
976
985
  function _resetSecret() {
977
986
  _secret = null;
978
987
  }
979
- var import_jsonwebtoken2, import_node_crypto4, import_node_fs2, import_node_path2, _secret;
988
+ var import_jsonwebtoken, import_node_crypto4, import_node_fs2, import_node_path2, _secret;
980
989
  var init_jwt = __esm({
981
990
  "src/auth/jwt.ts"() {
982
991
  "use strict";
983
- import_jsonwebtoken2 = __toESM(require("jsonwebtoken"), 1);
992
+ import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
984
993
  import_node_crypto4 = require("crypto");
985
994
  import_node_fs2 = require("fs");
986
995
  import_node_path2 = require("path");
package/dist/cli.jsc CHANGED
Binary file
package/dist/index.jsc CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "closeclaw",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "CloseClaw — AI-powered project management platform. One command, full stack.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",