@usertour/helpers 0.0.9 → 0.0.11
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/globals.d.cts +1 -1
- package/dist/globals.d.ts +1 -1
- package/dist/index.cjs +2 -913
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +20 -71
- package/package.json +7 -17
- package/dist/chunk-7IK5Q5N2.js +0 -591
- package/dist/chunk-DEG6MTU7.js +0 -318
- package/dist/chunk-HWWIAVVP.js +0 -112
- package/dist/chunk-Y5PCSFVZ.js +0 -183
- package/dist/chunk-Y6FPPOKF.js +0 -28
- package/dist/conditions.cjs +0 -1001
- package/dist/conditions.d.cts +0 -23
- package/dist/conditions.d.ts +0 -23
- package/dist/conditions.js +0 -45
- package/dist/finderx.cjs +0 -346
- package/dist/finderx.d.cts +0 -47
- package/dist/finderx.d.ts +0 -47
- package/dist/finderx.js +0 -15
- package/dist/jwt-license-signer.cjs +0 -147
- package/dist/jwt-license-signer.d.cts +0 -61
- package/dist/jwt-license-signer.d.ts +0 -61
- package/dist/jwt-license-signer.js +0 -7
- package/dist/jwt-license-validator.cjs +0 -217
- package/dist/jwt-license-validator.d.cts +0 -54
- package/dist/jwt-license-validator.d.ts +0 -54
- package/dist/jwt-license-validator.js +0 -7
- package/dist/listener.cjs +0 -68
- package/dist/listener.d.cts +0 -7
- package/dist/listener.d.ts +0 -7
- package/dist/listener.js +0 -16
- package/dist/server.cjs +0 -331
- package/dist/server.d.cts +0 -4
- package/dist/server.d.ts +0 -4
- package/dist/server.js +0 -11
|
@@ -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,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 };
|
package/dist/listener.cjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/listener.ts
|
|
21
|
-
var listener_exports = {};
|
|
22
|
-
__export(listener_exports, {
|
|
23
|
-
isBrowser: () => isBrowser,
|
|
24
|
-
isNavigator: () => isNavigator,
|
|
25
|
-
noop: () => noop,
|
|
26
|
-
off: () => off,
|
|
27
|
-
on: () => on
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(listener_exports);
|
|
30
|
-
|
|
31
|
-
// src/globals.ts
|
|
32
|
-
var win = typeof window !== "undefined" ? window : void 0;
|
|
33
|
-
var global = typeof globalThis !== "undefined" ? globalThis : win;
|
|
34
|
-
var ArrayProto = Array.prototype;
|
|
35
|
-
var nativeForEach = ArrayProto.forEach;
|
|
36
|
-
var nativeIndexOf = ArrayProto.indexOf;
|
|
37
|
-
var navigator = global == null ? void 0 : global.navigator;
|
|
38
|
-
var document = global == null ? void 0 : global.document;
|
|
39
|
-
var location = global == null ? void 0 : global.location;
|
|
40
|
-
var fetch = global == null ? void 0 : global.fetch;
|
|
41
|
-
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
42
|
-
var AbortController = global == null ? void 0 : global.AbortController;
|
|
43
|
-
var userAgent = navigator == null ? void 0 : navigator.userAgent;
|
|
44
|
-
var assignableWindow = win != null ? win : {};
|
|
45
|
-
|
|
46
|
-
// src/listener.ts
|
|
47
|
-
var noop = () => {
|
|
48
|
-
};
|
|
49
|
-
function on(obj, ...args) {
|
|
50
|
-
if (obj == null ? void 0 : obj.addEventListener) {
|
|
51
|
-
obj.addEventListener(...args);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function off(obj, ...args) {
|
|
55
|
-
if (obj == null ? void 0 : obj.removeEventListener) {
|
|
56
|
-
obj.removeEventListener(...args);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
var isBrowser = typeof win !== "undefined";
|
|
60
|
-
var isNavigator = typeof navigator !== "undefined";
|
|
61
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
isBrowser,
|
|
64
|
-
isNavigator,
|
|
65
|
-
noop,
|
|
66
|
-
off,
|
|
67
|
-
on
|
|
68
|
-
});
|
package/dist/listener.d.cts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
declare const noop: () => void;
|
|
2
|
-
declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, (...args: any[]) => void, ...any]): void;
|
|
3
|
-
declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, (...args: any[]) => void, ...any]): void;
|
|
4
|
-
declare const isBrowser: boolean;
|
|
5
|
-
declare const isNavigator: boolean;
|
|
6
|
-
|
|
7
|
-
export { isBrowser, isNavigator, noop, off, on };
|
package/dist/listener.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
declare const noop: () => void;
|
|
2
|
-
declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, (...args: any[]) => void, ...any]): void;
|
|
3
|
-
declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, (...args: any[]) => void, ...any]): void;
|
|
4
|
-
declare const isBrowser: boolean;
|
|
5
|
-
declare const isNavigator: boolean;
|
|
6
|
-
|
|
7
|
-
export { isBrowser, isNavigator, noop, off, on };
|
package/dist/listener.js
DELETED