@usertour/helpers 0.0.3 → 0.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/{chunk-JQ4E3IDB.js → chunk-HWWIAVVP.js} +1 -1
- package/dist/{chunk-KJJ6UD5L.js → chunk-Y5PCSFVZ.js} +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.js +2 -2
- package/dist/jwt-license-signer.cjs +5 -5
- package/dist/jwt-license-signer.d.cts +1 -1
- package/dist/jwt-license-signer.d.ts +1 -1
- package/dist/jwt-license-signer.js +1 -1
- package/dist/jwt-license-validator.cjs +5 -5
- package/dist/jwt-license-validator.js +1 -1
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
// src/jwt-license-signer.ts
|
|
6
6
|
import * as fs from "fs";
|
|
7
7
|
import * as path from "path";
|
|
8
|
-
import
|
|
8
|
+
import jwt from "jsonwebtoken";
|
|
9
9
|
var JWTLicenseSigner = class {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
__publicField(this, "privateKey");
|
package/dist/index.cjs
CHANGED
|
@@ -1092,7 +1092,7 @@ var getRandomColor = () => {
|
|
|
1092
1092
|
// src/jwt-license-signer.ts
|
|
1093
1093
|
var fs = __toESM(require("fs"), 1);
|
|
1094
1094
|
var path = __toESM(require("path"), 1);
|
|
1095
|
-
var
|
|
1095
|
+
var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
|
|
1096
1096
|
var JWTLicenseSigner = class {
|
|
1097
1097
|
constructor(options) {
|
|
1098
1098
|
__publicField(this, "privateKey");
|
|
@@ -1129,7 +1129,7 @@ var JWTLicenseSigner = class {
|
|
|
1129
1129
|
features: options.features
|
|
1130
1130
|
};
|
|
1131
1131
|
try {
|
|
1132
|
-
return
|
|
1132
|
+
return import_jsonwebtoken.default.sign(payload, this.privateKey, {
|
|
1133
1133
|
algorithm: this.algorithm,
|
|
1134
1134
|
issuer: this.issuer
|
|
1135
1135
|
});
|
|
@@ -1152,7 +1152,7 @@ var JWTLicenseSigner = class {
|
|
|
1152
1152
|
issuer: options.issuer || this.issuer,
|
|
1153
1153
|
features: options.features
|
|
1154
1154
|
};
|
|
1155
|
-
const token =
|
|
1155
|
+
const token = import_jsonwebtoken.default.sign(payload, this.privateKey, {
|
|
1156
1156
|
algorithm: this.algorithm,
|
|
1157
1157
|
issuer: this.issuer
|
|
1158
1158
|
});
|
|
@@ -1167,7 +1167,7 @@ var JWTLicenseSigner = class {
|
|
|
1167
1167
|
*/
|
|
1168
1168
|
decodeToken(token) {
|
|
1169
1169
|
try {
|
|
1170
|
-
return
|
|
1170
|
+
return import_jsonwebtoken.default.decode(token);
|
|
1171
1171
|
} catch (error) {
|
|
1172
1172
|
console.error("Failed to decode JWT token:", error);
|
|
1173
1173
|
return null;
|
|
@@ -1178,7 +1178,7 @@ var JWTLicenseSigner = class {
|
|
|
1178
1178
|
*/
|
|
1179
1179
|
getTokenInfo(token) {
|
|
1180
1180
|
try {
|
|
1181
|
-
const decoded =
|
|
1181
|
+
const decoded = import_jsonwebtoken.default.decode(token, { complete: true });
|
|
1182
1182
|
if (!decoded || typeof decoded === "string") {
|
|
1183
1183
|
return null;
|
|
1184
1184
|
}
|
|
@@ -1195,7 +1195,7 @@ var JWTLicenseSigner = class {
|
|
|
1195
1195
|
};
|
|
1196
1196
|
|
|
1197
1197
|
// src/jwt-license-validator.ts
|
|
1198
|
-
var
|
|
1198
|
+
var import_jsonwebtoken2 = __toESM(require("jsonwebtoken"), 1);
|
|
1199
1199
|
var JWTLicenseValidator = {
|
|
1200
1200
|
/**
|
|
1201
1201
|
* Validate a JWT license
|
|
@@ -1207,7 +1207,7 @@ var JWTLicenseValidator = {
|
|
|
1207
1207
|
validateLicense(license, publicKey, options = {}) {
|
|
1208
1208
|
try {
|
|
1209
1209
|
const { checkExpiration = true, currentTime = /* @__PURE__ */ new Date() } = options;
|
|
1210
|
-
const decoded =
|
|
1210
|
+
const decoded = import_jsonwebtoken2.default.verify(license, publicKey, {
|
|
1211
1211
|
algorithms: ["RS256"],
|
|
1212
1212
|
ignoreExpiration: !checkExpiration
|
|
1213
1213
|
});
|
|
@@ -1231,13 +1231,13 @@ var JWTLicenseValidator = {
|
|
|
1231
1231
|
hasFeature
|
|
1232
1232
|
};
|
|
1233
1233
|
} catch (error) {
|
|
1234
|
-
if (error instanceof
|
|
1234
|
+
if (error instanceof import_jsonwebtoken2.default.JsonWebTokenError) {
|
|
1235
1235
|
return {
|
|
1236
1236
|
isValid: false,
|
|
1237
1237
|
error: `JWT validation failed: ${error.message}`
|
|
1238
1238
|
};
|
|
1239
1239
|
}
|
|
1240
|
-
if (error instanceof
|
|
1240
|
+
if (error instanceof import_jsonwebtoken2.default.TokenExpiredError) {
|
|
1241
1241
|
return {
|
|
1242
1242
|
isValid: false,
|
|
1243
1243
|
error: `License expired: ${error.message}`,
|
|
@@ -1366,7 +1366,7 @@ var JWTLicenseValidator = {
|
|
|
1366
1366
|
*/
|
|
1367
1367
|
decodeLicense(license) {
|
|
1368
1368
|
try {
|
|
1369
|
-
const decoded =
|
|
1369
|
+
const decoded = import_jsonwebtoken2.default.decode(license);
|
|
1370
1370
|
return decoded;
|
|
1371
1371
|
} catch {
|
|
1372
1372
|
return null;
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
} from "./chunk-ZNFXGN3M.js";
|
|
18
18
|
import {
|
|
19
19
|
JWTLicenseSigner
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-HWWIAVVP.js";
|
|
21
21
|
import {
|
|
22
22
|
JWTLicenseValidator
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-Y5PCSFVZ.js";
|
|
24
24
|
import {
|
|
25
25
|
defaultStep
|
|
26
26
|
} from "./chunk-FW54TSA3.js";
|
|
@@ -40,7 +40,7 @@ __export(jwt_license_signer_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(jwt_license_signer_exports);
|
|
41
41
|
var fs = __toESM(require("fs"), 1);
|
|
42
42
|
var path = __toESM(require("path"), 1);
|
|
43
|
-
var
|
|
43
|
+
var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
|
|
44
44
|
var JWTLicenseSigner = class {
|
|
45
45
|
constructor(options) {
|
|
46
46
|
__publicField(this, "privateKey");
|
|
@@ -77,7 +77,7 @@ var JWTLicenseSigner = class {
|
|
|
77
77
|
features: options.features
|
|
78
78
|
};
|
|
79
79
|
try {
|
|
80
|
-
return
|
|
80
|
+
return import_jsonwebtoken.default.sign(payload, this.privateKey, {
|
|
81
81
|
algorithm: this.algorithm,
|
|
82
82
|
issuer: this.issuer
|
|
83
83
|
});
|
|
@@ -100,7 +100,7 @@ var JWTLicenseSigner = class {
|
|
|
100
100
|
issuer: options.issuer || this.issuer,
|
|
101
101
|
features: options.features
|
|
102
102
|
};
|
|
103
|
-
const token =
|
|
103
|
+
const token = import_jsonwebtoken.default.sign(payload, this.privateKey, {
|
|
104
104
|
algorithm: this.algorithm,
|
|
105
105
|
issuer: this.issuer
|
|
106
106
|
});
|
|
@@ -115,7 +115,7 @@ var JWTLicenseSigner = class {
|
|
|
115
115
|
*/
|
|
116
116
|
decodeToken(token) {
|
|
117
117
|
try {
|
|
118
|
-
return
|
|
118
|
+
return import_jsonwebtoken.default.decode(token);
|
|
119
119
|
} catch (error) {
|
|
120
120
|
console.error("Failed to decode JWT token:", error);
|
|
121
121
|
return null;
|
|
@@ -126,7 +126,7 @@ var JWTLicenseSigner = class {
|
|
|
126
126
|
*/
|
|
127
127
|
getTokenInfo(token) {
|
|
128
128
|
try {
|
|
129
|
-
const decoded =
|
|
129
|
+
const decoded = import_jsonwebtoken.default.decode(token, { complete: true });
|
|
130
130
|
if (!decoded || typeof decoded === "string") {
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
@@ -33,7 +33,7 @@ __export(jwt_license_validator_exports, {
|
|
|
33
33
|
JWTLicenseValidator: () => JWTLicenseValidator
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(jwt_license_validator_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
|
|
37
37
|
var JWTLicenseValidator = {
|
|
38
38
|
/**
|
|
39
39
|
* Validate a JWT license
|
|
@@ -45,7 +45,7 @@ var JWTLicenseValidator = {
|
|
|
45
45
|
validateLicense(license, publicKey, options = {}) {
|
|
46
46
|
try {
|
|
47
47
|
const { checkExpiration = true, currentTime = /* @__PURE__ */ new Date() } = options;
|
|
48
|
-
const decoded =
|
|
48
|
+
const decoded = import_jsonwebtoken.default.verify(license, publicKey, {
|
|
49
49
|
algorithms: ["RS256"],
|
|
50
50
|
ignoreExpiration: !checkExpiration
|
|
51
51
|
});
|
|
@@ -69,13 +69,13 @@ var JWTLicenseValidator = {
|
|
|
69
69
|
hasFeature
|
|
70
70
|
};
|
|
71
71
|
} catch (error) {
|
|
72
|
-
if (error instanceof
|
|
72
|
+
if (error instanceof import_jsonwebtoken.default.JsonWebTokenError) {
|
|
73
73
|
return {
|
|
74
74
|
isValid: false,
|
|
75
75
|
error: `JWT validation failed: ${error.message}`
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
if (error instanceof
|
|
78
|
+
if (error instanceof import_jsonwebtoken.default.TokenExpiredError) {
|
|
79
79
|
return {
|
|
80
80
|
isValid: false,
|
|
81
81
|
error: `License expired: ${error.message}`,
|
|
@@ -204,7 +204,7 @@ var JWTLicenseValidator = {
|
|
|
204
204
|
*/
|
|
205
205
|
decodeLicense(license) {
|
|
206
206
|
try {
|
|
207
|
-
const decoded =
|
|
207
|
+
const decoded = import_jsonwebtoken.default.decode(license);
|
|
208
208
|
return decoded;
|
|
209
209
|
} catch {
|
|
210
210
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usertour/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utility functions and helpers shared across the UserTour project",
|
|
6
6
|
"homepage": "https://www.usertour.io",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"clsx": "^1.2.1",
|
|
36
36
|
"tailwind-merge": "^1.13.2",
|
|
37
37
|
"jsonwebtoken": "^9.0.2",
|
|
38
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
38
39
|
"uuid": "^9.0.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
"@types/chroma-js": "^3.1.1",
|
|
44
45
|
"@types/uuid": "^9.0.6",
|
|
45
46
|
"eslint": "^8.38.0",
|
|
46
|
-
"@types/jsonwebtoken": "^9.0.10",
|
|
47
47
|
"typescript": "^5.0.2"
|
|
48
48
|
},
|
|
49
49
|
"tsup": {
|