@usertour/helpers 0.0.8 → 0.0.10

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/index.cjs CHANGED
@@ -37,8 +37,6 @@ var src_exports = {};
37
37
  __export(src_exports, {
38
38
  AbortController: () => AbortController,
39
39
  ArrayProto: () => ArrayProto,
40
- JWTLicenseSigner: () => JWTLicenseSigner,
41
- JWTLicenseValidator: () => JWTLicenseValidator,
42
40
  PRIORITIES: () => PRIORITIES,
43
41
  XMLHttpRequest: () => XMLHttpRequest,
44
42
  absoluteUrl: () => absoluteUrl,
@@ -473,8 +471,8 @@ var parseUrl = (url) => {
473
471
  if (!urlPatterns) {
474
472
  return null;
475
473
  }
476
- const [, , scheme = "", domain = "", path2 = "", , query = "", fragment = ""] = urlPatterns;
477
- return { scheme, domain, path: path2, query, fragment };
474
+ const [, , scheme = "", domain = "", path = "", , query = "", fragment = ""] = urlPatterns;
475
+ return { scheme, domain, path, query, fragment };
478
476
  };
479
477
  var replaceWildcard = (input, s1, s2) => {
480
478
  const withSpecialWords = replaceSpecialWords(input);
@@ -496,11 +494,11 @@ var parsePattern = (pattern) => {
496
494
  console.error("Invalid URL pattern:", pattern);
497
495
  return null;
498
496
  }
499
- const { scheme, domain, path: path2, query, fragment } = _pattern;
497
+ const { scheme, domain, path, query, fragment } = _pattern;
500
498
  const _scheme = scheme ? replaceSpecialWords(scheme) : "[a-z\\d]+";
501
499
  const _domain = domain ? replaceWildcard(domain, "[^/]", ".") : "[^/]*";
502
500
  const _fragment = fragment ? replaceWildcard(fragment, ".", "/") : "(#.*)?";
503
- const _path = path2 ? replaceWildcard(path2, "[^?#]", "/") : "/[^?#]*";
501
+ const _path = path ? replaceWildcard(path, "[^?#]", "/") : "/[^?#]*";
504
502
  let _query = "(\\?[^#]*)?";
505
503
  if (query) {
506
504
  new URLSearchParams(query).forEach((value, key) => {
@@ -1063,8 +1061,8 @@ function formatDate(input) {
1063
1061
  year: "numeric"
1064
1062
  });
1065
1063
  }
1066
- function absoluteUrl(path2) {
1067
- return `${path2}`;
1064
+ function absoluteUrl(path) {
1065
+ return `${path}`;
1068
1066
  }
1069
1067
  var uuidV4 = () => {
1070
1068
  return (0, import_uuid.v4)();
@@ -1112,291 +1110,6 @@ var getRandomColor = () => {
1112
1110
  return colors[Math.floor(Math.random() * colors.length)];
1113
1111
  };
1114
1112
 
1115
- // src/jwt-license-signer.ts
1116
- var fs = __toESM(require("fs"), 1);
1117
- var path = __toESM(require("path"), 1);
1118
- var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
1119
- var JWTLicenseSigner = class {
1120
- constructor(options) {
1121
- __publicField(this, "privateKey");
1122
- __publicField(this, "issuer");
1123
- __publicField(this, "algorithm");
1124
- this.privateKey = this.loadPrivateKey(options.privateKeyPath);
1125
- this.issuer = options.issuer || "https://www.usertour.io";
1126
- this.algorithm = options.algorithm || "RS256";
1127
- }
1128
- /**
1129
- * Load RSA private key from file
1130
- */
1131
- loadPrivateKey(keyPath) {
1132
- try {
1133
- const fullPath = path.resolve(keyPath);
1134
- return fs.readFileSync(fullPath, "utf8");
1135
- } catch (error) {
1136
- throw new Error(`Failed to load private key from ${keyPath}: ${error}`);
1137
- }
1138
- }
1139
- /**
1140
- * Generate a JWT license token
1141
- */
1142
- generateLicense(options) {
1143
- const now = Math.floor(Date.now() / 1e3);
1144
- const expiresAt = now + options.expiresInDays * 24 * 60 * 60;
1145
- const payload = {
1146
- plan: options.plan,
1147
- sub: options.subject,
1148
- projectId: options.projectId,
1149
- iat: now,
1150
- exp: expiresAt,
1151
- issuer: options.issuer || this.issuer,
1152
- features: options.features
1153
- };
1154
- try {
1155
- return import_jsonwebtoken.default.sign(payload, this.privateKey, {
1156
- algorithm: this.algorithm,
1157
- issuer: this.issuer
1158
- });
1159
- } catch (error) {
1160
- throw new Error(`Failed to generate JWT license: ${error}`);
1161
- }
1162
- }
1163
- /**
1164
- * Generate a license and return both token and payload info
1165
- */
1166
- generateLicenseWithInfo(options) {
1167
- const now = Math.floor(Date.now() / 1e3);
1168
- const expiresAt = now + options.expiresInDays * 24 * 60 * 60;
1169
- const payload = {
1170
- plan: options.plan,
1171
- sub: options.subject,
1172
- projectId: options.projectId,
1173
- iat: now,
1174
- exp: expiresAt,
1175
- issuer: options.issuer || this.issuer,
1176
- features: options.features
1177
- };
1178
- const token = import_jsonwebtoken.default.sign(payload, this.privateKey, {
1179
- algorithm: this.algorithm,
1180
- issuer: this.issuer
1181
- });
1182
- return {
1183
- token,
1184
- payload,
1185
- expiresAt: new Date(expiresAt * 1e3)
1186
- };
1187
- }
1188
- /**
1189
- * Decode a JWT token without verification (for debugging)
1190
- */
1191
- decodeToken(token) {
1192
- try {
1193
- return import_jsonwebtoken.default.decode(token);
1194
- } catch (error) {
1195
- console.error("Failed to decode JWT token:", error);
1196
- return null;
1197
- }
1198
- }
1199
- /**
1200
- * Get token information without verification
1201
- */
1202
- getTokenInfo(token) {
1203
- try {
1204
- const decoded = import_jsonwebtoken.default.decode(token, { complete: true });
1205
- if (!decoded || typeof decoded === "string") {
1206
- return null;
1207
- }
1208
- return {
1209
- header: decoded.header,
1210
- payload: decoded.payload,
1211
- signature: decoded.signature
1212
- };
1213
- } catch (error) {
1214
- console.error("Failed to get token info:", error);
1215
- return null;
1216
- }
1217
- }
1218
- };
1219
-
1220
- // src/jwt-license-validator.ts
1221
- var import_jsonwebtoken2 = __toESM(require("jsonwebtoken"), 1);
1222
- var JWTLicenseValidator = {
1223
- /**
1224
- * Validate a JWT license
1225
- * @param license - JWT license string
1226
- * @param publicKey - RSA public key in PEM format
1227
- * @param options - Validation options
1228
- * @returns Validation result
1229
- */
1230
- validateLicense(license, publicKey, options = {}) {
1231
- try {
1232
- const { checkExpiration = true, currentTime = /* @__PURE__ */ new Date() } = options;
1233
- const decoded = import_jsonwebtoken2.default.verify(license, publicKey, {
1234
- algorithms: ["RS256"],
1235
- ignoreExpiration: !checkExpiration
1236
- });
1237
- const fieldValidation = this.validateRequiredFields(decoded);
1238
- if (!fieldValidation.isValid) {
1239
- return fieldValidation;
1240
- }
1241
- if (checkExpiration) {
1242
- const expirationValidation = this.checkExpiration(decoded, currentTime);
1243
- if (!expirationValidation.isValid) {
1244
- return expirationValidation;
1245
- }
1246
- }
1247
- const hasFeature = (feature) => {
1248
- return decoded.features.includes("*") || decoded.features.includes(feature);
1249
- };
1250
- return {
1251
- isValid: true,
1252
- payload: decoded,
1253
- isExpired: false,
1254
- hasFeature
1255
- };
1256
- } catch (error) {
1257
- if (error instanceof import_jsonwebtoken2.default.JsonWebTokenError) {
1258
- return {
1259
- isValid: false,
1260
- error: `JWT validation failed: ${error.message}`
1261
- };
1262
- }
1263
- if (error instanceof import_jsonwebtoken2.default.TokenExpiredError) {
1264
- return {
1265
- isValid: false,
1266
- error: `License expired: ${error.message}`,
1267
- isExpired: true
1268
- };
1269
- }
1270
- return {
1271
- isValid: false,
1272
- error: `License validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
1273
- };
1274
- }
1275
- },
1276
- /**
1277
- * Validate that all required fields are present in license payload
1278
- * @param payload - License payload to validate
1279
- * @returns Validation result
1280
- */
1281
- validateRequiredFields(payload) {
1282
- const requiredFields = ["plan", "sub", "projectId", "iat", "exp", "issuer", "features"];
1283
- for (const field of requiredFields) {
1284
- if (!(field in payload)) {
1285
- return {
1286
- isValid: false,
1287
- error: `Missing required field: ${field}`
1288
- };
1289
- }
1290
- }
1291
- if (typeof payload.plan !== "string" || !payload.plan.trim()) {
1292
- return {
1293
- isValid: false,
1294
- error: "Invalid plan: must be a non-empty string"
1295
- };
1296
- }
1297
- if (typeof payload.sub !== "string" || !payload.sub.trim()) {
1298
- return {
1299
- isValid: false,
1300
- error: "Invalid sub: must be a non-empty string"
1301
- };
1302
- }
1303
- if (typeof payload.projectId !== "string" || !payload.projectId.trim()) {
1304
- return {
1305
- isValid: false,
1306
- error: "Invalid projectId: must be a non-empty string"
1307
- };
1308
- }
1309
- if (typeof payload.issuer !== "string" || !payload.issuer.trim()) {
1310
- return {
1311
- isValid: false,
1312
- error: "Invalid issuer: must be a non-empty string"
1313
- };
1314
- }
1315
- if (!Array.isArray(payload.features)) {
1316
- return {
1317
- isValid: false,
1318
- error: "Invalid features: must be an array"
1319
- };
1320
- }
1321
- if (typeof payload.iat !== "number" || payload.iat <= 0) {
1322
- return {
1323
- isValid: false,
1324
- error: "Invalid iat: must be a positive number"
1325
- };
1326
- }
1327
- if (typeof payload.exp !== "number" || payload.exp <= 0) {
1328
- return {
1329
- isValid: false,
1330
- error: "Invalid exp: must be a positive number"
1331
- };
1332
- }
1333
- if (payload.iat >= payload.exp) {
1334
- return {
1335
- isValid: false,
1336
- error: "Invalid timestamps: iat must be before exp"
1337
- };
1338
- }
1339
- return { isValid: true };
1340
- },
1341
- /**
1342
- * Check if license has expired
1343
- * @param payload - License payload
1344
- * @param currentTime - Current time to check against (defaults to now)
1345
- * @returns Validation result
1346
- */
1347
- checkExpiration(payload, currentTime = /* @__PURE__ */ new Date()) {
1348
- const now = Math.floor(currentTime.getTime() / 1e3);
1349
- const expiresAt = payload.exp;
1350
- if (now > expiresAt) {
1351
- return {
1352
- isValid: false,
1353
- error: `License expired on ${new Date(expiresAt * 1e3).toISOString()}`,
1354
- isExpired: true
1355
- };
1356
- }
1357
- return { isValid: true, isExpired: false };
1358
- },
1359
- /**
1360
- * Check if license has a specific feature
1361
- * @param payload - License payload
1362
- * @param feature - Feature to check
1363
- * @returns Whether the feature is available
1364
- */
1365
- hasFeature(payload, feature) {
1366
- return payload.features.includes("*") || payload.features.includes(feature);
1367
- },
1368
- /**
1369
- * Get license expiration status
1370
- * @param payload - License payload
1371
- * @param currentTime - Current time to check against (defaults to now)
1372
- * @returns Expiration information
1373
- */
1374
- getExpirationInfo(payload, currentTime = /* @__PURE__ */ new Date()) {
1375
- const now = Math.floor(currentTime.getTime() / 1e3);
1376
- const expiresAt = payload.exp;
1377
- const isExpired = now > expiresAt;
1378
- const daysUntilExpiration = Math.ceil((expiresAt - now) / (24 * 60 * 60));
1379
- return {
1380
- isExpired,
1381
- expiresAt: new Date(expiresAt * 1e3),
1382
- daysUntilExpiration: isExpired ? 0 : daysUntilExpiration
1383
- };
1384
- },
1385
- /**
1386
- * Decode JWT license without verification (for debugging)
1387
- * @param license - JWT license string
1388
- * @returns Decoded payload or null if invalid
1389
- */
1390
- decodeLicense(license) {
1391
- try {
1392
- const decoded = import_jsonwebtoken2.default.decode(license);
1393
- return decoded;
1394
- } catch {
1395
- return null;
1396
- }
1397
- }
1398
- };
1399
-
1400
1113
  // src/conditions.ts
1401
1114
  var import_dom = require("@floating-ui/dom");
1402
1115
 
@@ -2253,9 +1966,9 @@ var wait = (seconds) => {
2253
1966
  if (seconds === 0) {
2254
1967
  return Promise.resolve();
2255
1968
  }
2256
- return new Promise((resolve2, reject) => {
1969
+ return new Promise((resolve, reject) => {
2257
1970
  try {
2258
- setTimeout(resolve2, seconds * 1e3);
1971
+ setTimeout(resolve, seconds * 1e3);
2259
1972
  } catch (error) {
2260
1973
  reject(error);
2261
1974
  }
@@ -2265,8 +1978,6 @@ var wait = (seconds) => {
2265
1978
  0 && (module.exports = {
2266
1979
  AbortController,
2267
1980
  ArrayProto,
2268
- JWTLicenseSigner,
2269
- JWTLicenseValidator,
2270
1981
  PRIORITIES,
2271
1982
  XMLHttpRequest,
2272
1983
  absoluteUrl,
package/dist/index.d.cts CHANGED
@@ -11,8 +11,6 @@ export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from '
11
11
  export { deepClone } from './utils.cjs';
12
12
  export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.cjs';
13
13
  export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.cjs';
14
- export { GenerateLicenseOptions, JWTLicenseSigner, JWTLicenseSignerOptions } from './jwt-license-signer.cjs';
15
- export { JWTLicenseValidator } from './jwt-license-validator.cjs';
16
14
  export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isHasActivedContents, isSameContents, isValidContent, isVisible, parseUrlParams, wait } from './conditions.cjs';
17
15
  export { Options, Target, TargetResult, XData, XNode, XResult, finder, finderV2, finderX, parserV2, parserX } from './finderx.cjs';
18
16
  export { default as isEqual } from 'fast-deep-equal';
@@ -20,4 +18,3 @@ import '@usertour/types';
20
18
  import './storage.cjs';
21
19
  import '@usertour/types/';
22
20
  import 'clsx';
23
- import 'jsonwebtoken';
package/dist/index.d.ts CHANGED
@@ -11,8 +11,6 @@ export { isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments } from '
11
11
  export { deepClone } from './utils.js';
12
12
  export { generateAutoStateColors, hexToHSLString, hexToRGBStr } from './color.js';
13
13
  export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isDark, uuidV4 } from './helper.js';
14
- export { GenerateLicenseOptions, JWTLicenseSigner, JWTLicenseSignerOptions } from './jwt-license-signer.js';
15
- export { JWTLicenseValidator } from './jwt-license-validator.js';
16
14
  export { PRIORITIES, activedContentCondition, activedContentRulesConditions, activedRulesConditions, checklistIsDimissed, checklistIsSeen, filterAutoStartContent, findLatestEvent, flowIsDismissed, flowIsSeen, isActive, isActiveContent, isHasActivedContents, isSameContents, isValidContent, isVisible, parseUrlParams, wait } from './conditions.js';
17
15
  export { Options, Target, TargetResult, XData, XNode, XResult, finder, finderV2, finderX, parserV2, parserX } from './finderx.js';
18
16
  export { default as isEqual } from 'fast-deep-equal';
@@ -20,4 +18,3 @@ import '@usertour/types';
20
18
  import './storage.js';
21
19
  import '@usertour/types/';
22
20
  import 'clsx';
23
- import 'jsonwebtoken';
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import {
2
- defaultStep
3
- } from "./chunk-FW54TSA3.js";
4
1
  import {
5
2
  deepClone
6
3
  } from "./chunk-2AEGAICC.js";
@@ -19,11 +16,8 @@ import {
19
16
  isUrl
20
17
  } from "./chunk-ZNFXGN3M.js";
21
18
  import {
22
- JWTLicenseSigner
23
- } from "./chunk-HWWIAVVP.js";
24
- import {
25
- JWTLicenseValidator
26
- } from "./chunk-Y5PCSFVZ.js";
19
+ defaultStep
20
+ } from "./chunk-FW54TSA3.js";
27
21
  import {
28
22
  getAuthToken,
29
23
  removeAuthToken,
@@ -137,8 +131,6 @@ import "./chunk-XEO3YXBM.js";
137
131
  export {
138
132
  AbortController,
139
133
  ArrayProto,
140
- JWTLicenseSigner,
141
- JWTLicenseValidator,
142
134
  PRIORITIES,
143
135
  XMLHttpRequest,
144
136
  absoluteUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usertour/helpers",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "description": "Utility functions and helpers shared across the UserTour project",
6
6
  "homepage": "https://www.usertour.io",
@@ -29,7 +29,6 @@
29
29
  "@floating-ui/dom": "^1.4.4",
30
30
  "@medv/finder": "^3.1.0",
31
31
  "@paralleldrive/cuid2": "^2.2.2",
32
- "@types/jsonwebtoken": "^9.0.10",
33
32
  "@usertour/types": "^0.0.5",
34
33
  "chroma-js": "^3.1.2",
35
34
  "class-variance-authority": "^0.4.0",
@@ -37,7 +36,6 @@
37
36
  "date-fns": "^2.30.0",
38
37
  "deepmerge-ts": "^7.1.3",
39
38
  "fast-deep-equal": "^3.1.3",
40
- "jsonwebtoken": "^9.0.2",
41
39
  "tailwind-merge": "^1.13.2",
42
40
  "uuid": "^9.0.1"
43
41
  },
@@ -1,112 +0,0 @@
1
- import {
2
- __publicField
3
- } from "./chunk-XEO3YXBM.js";
4
-
5
- // src/jwt-license-signer.ts
6
- import * as fs from "fs";
7
- import * as path from "path";
8
- import jwt from "jsonwebtoken";
9
- var JWTLicenseSigner = class {
10
- constructor(options) {
11
- __publicField(this, "privateKey");
12
- __publicField(this, "issuer");
13
- __publicField(this, "algorithm");
14
- this.privateKey = this.loadPrivateKey(options.privateKeyPath);
15
- this.issuer = options.issuer || "https://www.usertour.io";
16
- this.algorithm = options.algorithm || "RS256";
17
- }
18
- /**
19
- * Load RSA private key from file
20
- */
21
- loadPrivateKey(keyPath) {
22
- try {
23
- const fullPath = path.resolve(keyPath);
24
- return fs.readFileSync(fullPath, "utf8");
25
- } catch (error) {
26
- throw new Error(`Failed to load private key from ${keyPath}: ${error}`);
27
- }
28
- }
29
- /**
30
- * Generate a JWT license token
31
- */
32
- generateLicense(options) {
33
- const now = Math.floor(Date.now() / 1e3);
34
- const expiresAt = now + options.expiresInDays * 24 * 60 * 60;
35
- const payload = {
36
- plan: options.plan,
37
- sub: options.subject,
38
- projectId: options.projectId,
39
- iat: now,
40
- exp: expiresAt,
41
- issuer: options.issuer || this.issuer,
42
- features: options.features
43
- };
44
- try {
45
- return jwt.sign(payload, this.privateKey, {
46
- algorithm: this.algorithm,
47
- issuer: this.issuer
48
- });
49
- } catch (error) {
50
- throw new Error(`Failed to generate JWT license: ${error}`);
51
- }
52
- }
53
- /**
54
- * Generate a license and return both token and payload info
55
- */
56
- generateLicenseWithInfo(options) {
57
- const now = Math.floor(Date.now() / 1e3);
58
- const expiresAt = now + options.expiresInDays * 24 * 60 * 60;
59
- const payload = {
60
- plan: options.plan,
61
- sub: options.subject,
62
- projectId: options.projectId,
63
- iat: now,
64
- exp: expiresAt,
65
- issuer: options.issuer || this.issuer,
66
- features: options.features
67
- };
68
- const token = jwt.sign(payload, this.privateKey, {
69
- algorithm: this.algorithm,
70
- issuer: this.issuer
71
- });
72
- return {
73
- token,
74
- payload,
75
- expiresAt: new Date(expiresAt * 1e3)
76
- };
77
- }
78
- /**
79
- * Decode a JWT token without verification (for debugging)
80
- */
81
- decodeToken(token) {
82
- try {
83
- return jwt.decode(token);
84
- } catch (error) {
85
- console.error("Failed to decode JWT token:", error);
86
- return null;
87
- }
88
- }
89
- /**
90
- * Get token information without verification
91
- */
92
- getTokenInfo(token) {
93
- try {
94
- const decoded = jwt.decode(token, { complete: true });
95
- if (!decoded || typeof decoded === "string") {
96
- return null;
97
- }
98
- return {
99
- header: decoded.header,
100
- payload: decoded.payload,
101
- signature: decoded.signature
102
- };
103
- } catch (error) {
104
- console.error("Failed to get token info:", error);
105
- return null;
106
- }
107
- }
108
- };
109
-
110
- export {
111
- JWTLicenseSigner
112
- };
@@ -1,183 +0,0 @@
1
- // src/jwt-license-validator.ts
2
- import jwt from "jsonwebtoken";
3
- var JWTLicenseValidator = {
4
- /**
5
- * Validate a JWT license
6
- * @param license - JWT license string
7
- * @param publicKey - RSA public key in PEM format
8
- * @param options - Validation options
9
- * @returns Validation result
10
- */
11
- validateLicense(license, publicKey, options = {}) {
12
- try {
13
- const { checkExpiration = true, currentTime = /* @__PURE__ */ new Date() } = options;
14
- const decoded = jwt.verify(license, publicKey, {
15
- algorithms: ["RS256"],
16
- ignoreExpiration: !checkExpiration
17
- });
18
- const fieldValidation = this.validateRequiredFields(decoded);
19
- if (!fieldValidation.isValid) {
20
- return fieldValidation;
21
- }
22
- if (checkExpiration) {
23
- const expirationValidation = this.checkExpiration(decoded, currentTime);
24
- if (!expirationValidation.isValid) {
25
- return expirationValidation;
26
- }
27
- }
28
- const hasFeature = (feature) => {
29
- return decoded.features.includes("*") || decoded.features.includes(feature);
30
- };
31
- return {
32
- isValid: true,
33
- payload: decoded,
34
- isExpired: false,
35
- hasFeature
36
- };
37
- } catch (error) {
38
- if (error instanceof jwt.JsonWebTokenError) {
39
- return {
40
- isValid: false,
41
- error: `JWT validation failed: ${error.message}`
42
- };
43
- }
44
- if (error instanceof jwt.TokenExpiredError) {
45
- return {
46
- isValid: false,
47
- error: `License expired: ${error.message}`,
48
- isExpired: true
49
- };
50
- }
51
- return {
52
- isValid: false,
53
- error: `License validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
54
- };
55
- }
56
- },
57
- /**
58
- * Validate that all required fields are present in license payload
59
- * @param payload - License payload to validate
60
- * @returns Validation result
61
- */
62
- validateRequiredFields(payload) {
63
- const requiredFields = ["plan", "sub", "projectId", "iat", "exp", "issuer", "features"];
64
- for (const field of requiredFields) {
65
- if (!(field in payload)) {
66
- return {
67
- isValid: false,
68
- error: `Missing required field: ${field}`
69
- };
70
- }
71
- }
72
- if (typeof payload.plan !== "string" || !payload.plan.trim()) {
73
- return {
74
- isValid: false,
75
- error: "Invalid plan: must be a non-empty string"
76
- };
77
- }
78
- if (typeof payload.sub !== "string" || !payload.sub.trim()) {
79
- return {
80
- isValid: false,
81
- error: "Invalid sub: must be a non-empty string"
82
- };
83
- }
84
- if (typeof payload.projectId !== "string" || !payload.projectId.trim()) {
85
- return {
86
- isValid: false,
87
- error: "Invalid projectId: must be a non-empty string"
88
- };
89
- }
90
- if (typeof payload.issuer !== "string" || !payload.issuer.trim()) {
91
- return {
92
- isValid: false,
93
- error: "Invalid issuer: must be a non-empty string"
94
- };
95
- }
96
- if (!Array.isArray(payload.features)) {
97
- return {
98
- isValid: false,
99
- error: "Invalid features: must be an array"
100
- };
101
- }
102
- if (typeof payload.iat !== "number" || payload.iat <= 0) {
103
- return {
104
- isValid: false,
105
- error: "Invalid iat: must be a positive number"
106
- };
107
- }
108
- if (typeof payload.exp !== "number" || payload.exp <= 0) {
109
- return {
110
- isValid: false,
111
- error: "Invalid exp: must be a positive number"
112
- };
113
- }
114
- if (payload.iat >= payload.exp) {
115
- return {
116
- isValid: false,
117
- error: "Invalid timestamps: iat must be before exp"
118
- };
119
- }
120
- return { isValid: true };
121
- },
122
- /**
123
- * Check if license has expired
124
- * @param payload - License payload
125
- * @param currentTime - Current time to check against (defaults to now)
126
- * @returns Validation result
127
- */
128
- checkExpiration(payload, currentTime = /* @__PURE__ */ new Date()) {
129
- const now = Math.floor(currentTime.getTime() / 1e3);
130
- const expiresAt = payload.exp;
131
- if (now > expiresAt) {
132
- return {
133
- isValid: false,
134
- error: `License expired on ${new Date(expiresAt * 1e3).toISOString()}`,
135
- isExpired: true
136
- };
137
- }
138
- return { isValid: true, isExpired: false };
139
- },
140
- /**
141
- * Check if license has a specific feature
142
- * @param payload - License payload
143
- * @param feature - Feature to check
144
- * @returns Whether the feature is available
145
- */
146
- hasFeature(payload, feature) {
147
- return payload.features.includes("*") || payload.features.includes(feature);
148
- },
149
- /**
150
- * Get license expiration status
151
- * @param payload - License payload
152
- * @param currentTime - Current time to check against (defaults to now)
153
- * @returns Expiration information
154
- */
155
- getExpirationInfo(payload, currentTime = /* @__PURE__ */ new Date()) {
156
- const now = Math.floor(currentTime.getTime() / 1e3);
157
- const expiresAt = payload.exp;
158
- const isExpired = now > expiresAt;
159
- const daysUntilExpiration = Math.ceil((expiresAt - now) / (24 * 60 * 60));
160
- return {
161
- isExpired,
162
- expiresAt: new Date(expiresAt * 1e3),
163
- daysUntilExpiration: isExpired ? 0 : daysUntilExpiration
164
- };
165
- },
166
- /**
167
- * Decode JWT license without verification (for debugging)
168
- * @param license - JWT license string
169
- * @returns Decoded payload or null if invalid
170
- */
171
- decodeLicense(license) {
172
- try {
173
- const decoded = jwt.decode(license);
174
- return decoded;
175
- } catch {
176
- return null;
177
- }
178
- }
179
- };
180
-
181
- export {
182
- JWTLicenseValidator
183
- };
@@ -1,147 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => {
31
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
- return value;
33
- };
34
-
35
- // src/jwt-license-signer.ts
36
- var jwt_license_signer_exports = {};
37
- __export(jwt_license_signer_exports, {
38
- JWTLicenseSigner: () => JWTLicenseSigner
39
- });
40
- module.exports = __toCommonJS(jwt_license_signer_exports);
41
- var fs = __toESM(require("fs"), 1);
42
- var path = __toESM(require("path"), 1);
43
- var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
44
- var JWTLicenseSigner = class {
45
- constructor(options) {
46
- __publicField(this, "privateKey");
47
- __publicField(this, "issuer");
48
- __publicField(this, "algorithm");
49
- this.privateKey = this.loadPrivateKey(options.privateKeyPath);
50
- this.issuer = options.issuer || "https://www.usertour.io";
51
- this.algorithm = options.algorithm || "RS256";
52
- }
53
- /**
54
- * Load RSA private key from file
55
- */
56
- loadPrivateKey(keyPath) {
57
- try {
58
- const fullPath = path.resolve(keyPath);
59
- return fs.readFileSync(fullPath, "utf8");
60
- } catch (error) {
61
- throw new Error(`Failed to load private key from ${keyPath}: ${error}`);
62
- }
63
- }
64
- /**
65
- * Generate a JWT license token
66
- */
67
- generateLicense(options) {
68
- const now = Math.floor(Date.now() / 1e3);
69
- const expiresAt = now + options.expiresInDays * 24 * 60 * 60;
70
- const payload = {
71
- plan: options.plan,
72
- sub: options.subject,
73
- projectId: options.projectId,
74
- iat: now,
75
- exp: expiresAt,
76
- issuer: options.issuer || this.issuer,
77
- features: options.features
78
- };
79
- try {
80
- return import_jsonwebtoken.default.sign(payload, this.privateKey, {
81
- algorithm: this.algorithm,
82
- issuer: this.issuer
83
- });
84
- } catch (error) {
85
- throw new Error(`Failed to generate JWT license: ${error}`);
86
- }
87
- }
88
- /**
89
- * Generate a license and return both token and payload info
90
- */
91
- generateLicenseWithInfo(options) {
92
- const now = Math.floor(Date.now() / 1e3);
93
- const expiresAt = now + options.expiresInDays * 24 * 60 * 60;
94
- const payload = {
95
- plan: options.plan,
96
- sub: options.subject,
97
- projectId: options.projectId,
98
- iat: now,
99
- exp: expiresAt,
100
- issuer: options.issuer || this.issuer,
101
- features: options.features
102
- };
103
- const token = import_jsonwebtoken.default.sign(payload, this.privateKey, {
104
- algorithm: this.algorithm,
105
- issuer: this.issuer
106
- });
107
- return {
108
- token,
109
- payload,
110
- expiresAt: new Date(expiresAt * 1e3)
111
- };
112
- }
113
- /**
114
- * Decode a JWT token without verification (for debugging)
115
- */
116
- decodeToken(token) {
117
- try {
118
- return import_jsonwebtoken.default.decode(token);
119
- } catch (error) {
120
- console.error("Failed to decode JWT token:", error);
121
- return null;
122
- }
123
- }
124
- /**
125
- * Get token information without verification
126
- */
127
- getTokenInfo(token) {
128
- try {
129
- const decoded = import_jsonwebtoken.default.decode(token, { complete: true });
130
- if (!decoded || typeof decoded === "string") {
131
- return null;
132
- }
133
- return {
134
- header: decoded.header,
135
- payload: decoded.payload,
136
- signature: decoded.signature
137
- };
138
- } catch (error) {
139
- console.error("Failed to get token info:", error);
140
- return null;
141
- }
142
- }
143
- };
144
- // Annotate the CommonJS export names for ESM import in node:
145
- 0 && (module.exports = {
146
- JWTLicenseSigner
147
- });
@@ -1,61 +0,0 @@
1
- import jwt from 'jsonwebtoken';
2
- import { JWTLicensePayload } from '@usertour/types';
3
-
4
- interface JWTLicenseSignerOptions {
5
- /** RSA private key path */
6
- privateKeyPath: string;
7
- /** JWT issuer */
8
- issuer?: string;
9
- /** JWT algorithm */
10
- algorithm?: jwt.Algorithm;
11
- }
12
- interface GenerateLicenseOptions {
13
- /** License plan type */
14
- plan: string;
15
- /** Subject (project name) */
16
- subject: string;
17
- /** Project identifier */
18
- projectId: string;
19
- /** Expiration days from now */
20
- expiresInDays: number;
21
- /** Array of enabled features, '*' means all features */
22
- features: string[];
23
- /** Custom issuer (optional) */
24
- issuer?: string;
25
- }
26
- declare class JWTLicenseSigner {
27
- private privateKey;
28
- private issuer;
29
- private algorithm;
30
- constructor(options: JWTLicenseSignerOptions);
31
- /**
32
- * Load RSA private key from file
33
- */
34
- private loadPrivateKey;
35
- /**
36
- * Generate a JWT license token
37
- */
38
- generateLicense(options: GenerateLicenseOptions): string;
39
- /**
40
- * Generate a license and return both token and payload info
41
- */
42
- generateLicenseWithInfo(options: GenerateLicenseOptions): {
43
- token: string;
44
- payload: JWTLicensePayload;
45
- expiresAt: Date;
46
- };
47
- /**
48
- * Decode a JWT token without verification (for debugging)
49
- */
50
- decodeToken(token: string): JWTLicensePayload | null;
51
- /**
52
- * Get token information without verification
53
- */
54
- getTokenInfo(token: string): {
55
- header: jwt.JwtHeader;
56
- payload: JWTLicensePayload;
57
- signature: string;
58
- } | null;
59
- }
60
-
61
- export { type GenerateLicenseOptions, JWTLicenseSigner, type JWTLicenseSignerOptions };
@@ -1,61 +0,0 @@
1
- import jwt from 'jsonwebtoken';
2
- import { JWTLicensePayload } from '@usertour/types';
3
-
4
- interface JWTLicenseSignerOptions {
5
- /** RSA private key path */
6
- privateKeyPath: string;
7
- /** JWT issuer */
8
- issuer?: string;
9
- /** JWT algorithm */
10
- algorithm?: jwt.Algorithm;
11
- }
12
- interface GenerateLicenseOptions {
13
- /** License plan type */
14
- plan: string;
15
- /** Subject (project name) */
16
- subject: string;
17
- /** Project identifier */
18
- projectId: string;
19
- /** Expiration days from now */
20
- expiresInDays: number;
21
- /** Array of enabled features, '*' means all features */
22
- features: string[];
23
- /** Custom issuer (optional) */
24
- issuer?: string;
25
- }
26
- declare class JWTLicenseSigner {
27
- private privateKey;
28
- private issuer;
29
- private algorithm;
30
- constructor(options: JWTLicenseSignerOptions);
31
- /**
32
- * Load RSA private key from file
33
- */
34
- private loadPrivateKey;
35
- /**
36
- * Generate a JWT license token
37
- */
38
- generateLicense(options: GenerateLicenseOptions): string;
39
- /**
40
- * Generate a license and return both token and payload info
41
- */
42
- generateLicenseWithInfo(options: GenerateLicenseOptions): {
43
- token: string;
44
- payload: JWTLicensePayload;
45
- expiresAt: Date;
46
- };
47
- /**
48
- * Decode a JWT token without verification (for debugging)
49
- */
50
- decodeToken(token: string): JWTLicensePayload | null;
51
- /**
52
- * Get token information without verification
53
- */
54
- getTokenInfo(token: string): {
55
- header: jwt.JwtHeader;
56
- payload: JWTLicensePayload;
57
- signature: string;
58
- } | null;
59
- }
60
-
61
- export { type GenerateLicenseOptions, JWTLicenseSigner, type JWTLicenseSignerOptions };
@@ -1,7 +0,0 @@
1
- import {
2
- JWTLicenseSigner
3
- } from "./chunk-HWWIAVVP.js";
4
- import "./chunk-XEO3YXBM.js";
5
- export {
6
- JWTLicenseSigner
7
- };
@@ -1,217 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/jwt-license-validator.ts
31
- var jwt_license_validator_exports = {};
32
- __export(jwt_license_validator_exports, {
33
- JWTLicenseValidator: () => JWTLicenseValidator
34
- });
35
- module.exports = __toCommonJS(jwt_license_validator_exports);
36
- var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
37
- var JWTLicenseValidator = {
38
- /**
39
- * Validate a JWT license
40
- * @param license - JWT license string
41
- * @param publicKey - RSA public key in PEM format
42
- * @param options - Validation options
43
- * @returns Validation result
44
- */
45
- validateLicense(license, publicKey, options = {}) {
46
- try {
47
- const { checkExpiration = true, currentTime = /* @__PURE__ */ new Date() } = options;
48
- const decoded = import_jsonwebtoken.default.verify(license, publicKey, {
49
- algorithms: ["RS256"],
50
- ignoreExpiration: !checkExpiration
51
- });
52
- const fieldValidation = this.validateRequiredFields(decoded);
53
- if (!fieldValidation.isValid) {
54
- return fieldValidation;
55
- }
56
- if (checkExpiration) {
57
- const expirationValidation = this.checkExpiration(decoded, currentTime);
58
- if (!expirationValidation.isValid) {
59
- return expirationValidation;
60
- }
61
- }
62
- const hasFeature = (feature) => {
63
- return decoded.features.includes("*") || decoded.features.includes(feature);
64
- };
65
- return {
66
- isValid: true,
67
- payload: decoded,
68
- isExpired: false,
69
- hasFeature
70
- };
71
- } catch (error) {
72
- if (error instanceof import_jsonwebtoken.default.JsonWebTokenError) {
73
- return {
74
- isValid: false,
75
- error: `JWT validation failed: ${error.message}`
76
- };
77
- }
78
- if (error instanceof import_jsonwebtoken.default.TokenExpiredError) {
79
- return {
80
- isValid: false,
81
- error: `License expired: ${error.message}`,
82
- isExpired: true
83
- };
84
- }
85
- return {
86
- isValid: false,
87
- error: `License validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
88
- };
89
- }
90
- },
91
- /**
92
- * Validate that all required fields are present in license payload
93
- * @param payload - License payload to validate
94
- * @returns Validation result
95
- */
96
- validateRequiredFields(payload) {
97
- const requiredFields = ["plan", "sub", "projectId", "iat", "exp", "issuer", "features"];
98
- for (const field of requiredFields) {
99
- if (!(field in payload)) {
100
- return {
101
- isValid: false,
102
- error: `Missing required field: ${field}`
103
- };
104
- }
105
- }
106
- if (typeof payload.plan !== "string" || !payload.plan.trim()) {
107
- return {
108
- isValid: false,
109
- error: "Invalid plan: must be a non-empty string"
110
- };
111
- }
112
- if (typeof payload.sub !== "string" || !payload.sub.trim()) {
113
- return {
114
- isValid: false,
115
- error: "Invalid sub: must be a non-empty string"
116
- };
117
- }
118
- if (typeof payload.projectId !== "string" || !payload.projectId.trim()) {
119
- return {
120
- isValid: false,
121
- error: "Invalid projectId: must be a non-empty string"
122
- };
123
- }
124
- if (typeof payload.issuer !== "string" || !payload.issuer.trim()) {
125
- return {
126
- isValid: false,
127
- error: "Invalid issuer: must be a non-empty string"
128
- };
129
- }
130
- if (!Array.isArray(payload.features)) {
131
- return {
132
- isValid: false,
133
- error: "Invalid features: must be an array"
134
- };
135
- }
136
- if (typeof payload.iat !== "number" || payload.iat <= 0) {
137
- return {
138
- isValid: false,
139
- error: "Invalid iat: must be a positive number"
140
- };
141
- }
142
- if (typeof payload.exp !== "number" || payload.exp <= 0) {
143
- return {
144
- isValid: false,
145
- error: "Invalid exp: must be a positive number"
146
- };
147
- }
148
- if (payload.iat >= payload.exp) {
149
- return {
150
- isValid: false,
151
- error: "Invalid timestamps: iat must be before exp"
152
- };
153
- }
154
- return { isValid: true };
155
- },
156
- /**
157
- * Check if license has expired
158
- * @param payload - License payload
159
- * @param currentTime - Current time to check against (defaults to now)
160
- * @returns Validation result
161
- */
162
- checkExpiration(payload, currentTime = /* @__PURE__ */ new Date()) {
163
- const now = Math.floor(currentTime.getTime() / 1e3);
164
- const expiresAt = payload.exp;
165
- if (now > expiresAt) {
166
- return {
167
- isValid: false,
168
- error: `License expired on ${new Date(expiresAt * 1e3).toISOString()}`,
169
- isExpired: true
170
- };
171
- }
172
- return { isValid: true, isExpired: false };
173
- },
174
- /**
175
- * Check if license has a specific feature
176
- * @param payload - License payload
177
- * @param feature - Feature to check
178
- * @returns Whether the feature is available
179
- */
180
- hasFeature(payload, feature) {
181
- return payload.features.includes("*") || payload.features.includes(feature);
182
- },
183
- /**
184
- * Get license expiration status
185
- * @param payload - License payload
186
- * @param currentTime - Current time to check against (defaults to now)
187
- * @returns Expiration information
188
- */
189
- getExpirationInfo(payload, currentTime = /* @__PURE__ */ new Date()) {
190
- const now = Math.floor(currentTime.getTime() / 1e3);
191
- const expiresAt = payload.exp;
192
- const isExpired = now > expiresAt;
193
- const daysUntilExpiration = Math.ceil((expiresAt - now) / (24 * 60 * 60));
194
- return {
195
- isExpired,
196
- expiresAt: new Date(expiresAt * 1e3),
197
- daysUntilExpiration: isExpired ? 0 : daysUntilExpiration
198
- };
199
- },
200
- /**
201
- * Decode JWT license without verification (for debugging)
202
- * @param license - JWT license string
203
- * @returns Decoded payload or null if invalid
204
- */
205
- decodeLicense(license) {
206
- try {
207
- const decoded = import_jsonwebtoken.default.decode(license);
208
- return decoded;
209
- } catch {
210
- return null;
211
- }
212
- }
213
- };
214
- // Annotate the CommonJS export names for ESM import in node:
215
- 0 && (module.exports = {
216
- JWTLicenseValidator
217
- });
@@ -1,54 +0,0 @@
1
- import { JWTLicenseValidationOptions, JWTLicenseValidationResult, JWTLicensePayload } from '@usertour/types';
2
-
3
- /**
4
- * JWT License validator
5
- */
6
- declare const JWTLicenseValidator: {
7
- /**
8
- * Validate a JWT license
9
- * @param license - JWT license string
10
- * @param publicKey - RSA public key in PEM format
11
- * @param options - Validation options
12
- * @returns Validation result
13
- */
14
- validateLicense(license: string, publicKey: string, options?: JWTLicenseValidationOptions): JWTLicenseValidationResult;
15
- /**
16
- * Validate that all required fields are present in license payload
17
- * @param payload - License payload to validate
18
- * @returns Validation result
19
- */
20
- validateRequiredFields(payload: JWTLicensePayload): JWTLicenseValidationResult;
21
- /**
22
- * Check if license has expired
23
- * @param payload - License payload
24
- * @param currentTime - Current time to check against (defaults to now)
25
- * @returns Validation result
26
- */
27
- checkExpiration(payload: JWTLicensePayload, currentTime?: Date): JWTLicenseValidationResult;
28
- /**
29
- * Check if license has a specific feature
30
- * @param payload - License payload
31
- * @param feature - Feature to check
32
- * @returns Whether the feature is available
33
- */
34
- hasFeature(payload: JWTLicensePayload, feature: string): boolean;
35
- /**
36
- * Get license expiration status
37
- * @param payload - License payload
38
- * @param currentTime - Current time to check against (defaults to now)
39
- * @returns Expiration information
40
- */
41
- getExpirationInfo(payload: JWTLicensePayload, currentTime?: Date): {
42
- isExpired: boolean;
43
- expiresAt: Date;
44
- daysUntilExpiration: number;
45
- };
46
- /**
47
- * Decode JWT license without verification (for debugging)
48
- * @param license - JWT license string
49
- * @returns Decoded payload or null if invalid
50
- */
51
- decodeLicense(license: string): JWTLicensePayload | null;
52
- };
53
-
54
- export { JWTLicenseValidator };
@@ -1,54 +0,0 @@
1
- import { JWTLicenseValidationOptions, JWTLicenseValidationResult, JWTLicensePayload } from '@usertour/types';
2
-
3
- /**
4
- * JWT License validator
5
- */
6
- declare const JWTLicenseValidator: {
7
- /**
8
- * Validate a JWT license
9
- * @param license - JWT license string
10
- * @param publicKey - RSA public key in PEM format
11
- * @param options - Validation options
12
- * @returns Validation result
13
- */
14
- validateLicense(license: string, publicKey: string, options?: JWTLicenseValidationOptions): JWTLicenseValidationResult;
15
- /**
16
- * Validate that all required fields are present in license payload
17
- * @param payload - License payload to validate
18
- * @returns Validation result
19
- */
20
- validateRequiredFields(payload: JWTLicensePayload): JWTLicenseValidationResult;
21
- /**
22
- * Check if license has expired
23
- * @param payload - License payload
24
- * @param currentTime - Current time to check against (defaults to now)
25
- * @returns Validation result
26
- */
27
- checkExpiration(payload: JWTLicensePayload, currentTime?: Date): JWTLicenseValidationResult;
28
- /**
29
- * Check if license has a specific feature
30
- * @param payload - License payload
31
- * @param feature - Feature to check
32
- * @returns Whether the feature is available
33
- */
34
- hasFeature(payload: JWTLicensePayload, feature: string): boolean;
35
- /**
36
- * Get license expiration status
37
- * @param payload - License payload
38
- * @param currentTime - Current time to check against (defaults to now)
39
- * @returns Expiration information
40
- */
41
- getExpirationInfo(payload: JWTLicensePayload, currentTime?: Date): {
42
- isExpired: boolean;
43
- expiresAt: Date;
44
- daysUntilExpiration: number;
45
- };
46
- /**
47
- * Decode JWT license without verification (for debugging)
48
- * @param license - JWT license string
49
- * @returns Decoded payload or null if invalid
50
- */
51
- decodeLicense(license: string): JWTLicensePayload | null;
52
- };
53
-
54
- export { JWTLicenseValidator };
@@ -1,7 +0,0 @@
1
- import {
2
- JWTLicenseValidator
3
- } from "./chunk-Y5PCSFVZ.js";
4
- import "./chunk-XEO3YXBM.js";
5
- export {
6
- JWTLicenseValidator
7
- };