@usertour/helpers 0.0.4 → 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.
@@ -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 * as jwt from "jsonwebtoken";
8
+ import jwt from "jsonwebtoken";
9
9
  var JWTLicenseSigner = class {
10
10
  constructor(options) {
11
11
  __publicField(this, "privateKey");
@@ -1,5 +1,5 @@
1
1
  // src/jwt-license-validator.ts
2
- import * as jwt from "jsonwebtoken";
2
+ import jwt from "jsonwebtoken";
3
3
  var JWTLicenseValidator = {
4
4
  /**
5
5
  * Validate a JWT license
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 jwt = __toESM(require("jsonwebtoken"), 1);
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 jwt.sign(payload, this.privateKey, {
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 = jwt.sign(payload, this.privateKey, {
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 jwt.decode(token);
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 = jwt.decode(token, { complete: true });
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 jwt2 = __toESM(require("jsonwebtoken"), 1);
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 = jwt2.verify(license, publicKey, {
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 jwt2.JsonWebTokenError) {
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 jwt2.TokenExpiredError) {
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 = jwt2.decode(license);
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-JQ4E3IDB.js";
20
+ } from "./chunk-HWWIAVVP.js";
21
21
  import {
22
22
  JWTLicenseValidator
23
- } from "./chunk-KJJ6UD5L.js";
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 jwt = __toESM(require("jsonwebtoken"), 1);
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 jwt.sign(payload, this.privateKey, {
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 = jwt.sign(payload, this.privateKey, {
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 jwt.decode(token);
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 = jwt.decode(token, { complete: true });
129
+ const decoded = import_jsonwebtoken.default.decode(token, { complete: true });
130
130
  if (!decoded || typeof decoded === "string") {
131
131
  return null;
132
132
  }
@@ -1,4 +1,4 @@
1
- import * as jwt from 'jsonwebtoken';
1
+ import jwt from 'jsonwebtoken';
2
2
  import { JWTLicensePayload } from '@usertour/types';
3
3
 
4
4
  interface JWTLicenseSignerOptions {
@@ -1,4 +1,4 @@
1
- import * as jwt from 'jsonwebtoken';
1
+ import jwt from 'jsonwebtoken';
2
2
  import { JWTLicensePayload } from '@usertour/types';
3
3
 
4
4
  interface JWTLicenseSignerOptions {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JWTLicenseSigner
3
- } from "./chunk-JQ4E3IDB.js";
3
+ } from "./chunk-HWWIAVVP.js";
4
4
  import "./chunk-XEO3YXBM.js";
5
5
  export {
6
6
  JWTLicenseSigner
@@ -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 jwt = __toESM(require("jsonwebtoken"), 1);
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 = jwt.verify(license, publicKey, {
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 jwt.JsonWebTokenError) {
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 jwt.TokenExpiredError) {
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 = jwt.decode(license);
207
+ const decoded = import_jsonwebtoken.default.decode(license);
208
208
  return decoded;
209
209
  } catch {
210
210
  return null;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JWTLicenseValidator
3
- } from "./chunk-KJJ6UD5L.js";
3
+ } from "./chunk-Y5PCSFVZ.js";
4
4
  import "./chunk-XEO3YXBM.js";
5
5
  export {
6
6
  JWTLicenseValidator
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usertour/helpers",
3
- "version": "0.0.4",
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",