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 +20 -11
- package/dist/cli.jsc +0 -0
- package/dist/index.jsc +0 -0
- package/package.json +1 -1
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
|
|
422
|
-
|
|
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
|
|
461
|
+
if (err instanceof jwt.TokenExpiredError) {
|
|
452
462
|
throw new Error("License key has expired");
|
|
453
463
|
}
|
|
454
|
-
if (err instanceof
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|