@hemia/jwt-manager 0.0.1 → 0.0.2

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.
@@ -25,7 +25,7 @@ var safeBuffer = {exports: {}};
25
25
 
26
26
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
27
27
 
28
- (function (module, exports) {
28
+ (function (module, exports$1) {
29
29
  /* eslint-disable node/no-deprecated-api */
30
30
  var buffer = require$$0;
31
31
  var Buffer = buffer.Buffer;
@@ -40,8 +40,8 @@ var safeBuffer = {exports: {}};
40
40
  module.exports = buffer;
41
41
  } else {
42
42
  // Copy properties from require('buffer')
43
- copyProps(buffer, exports);
44
- exports.Buffer = SafeBuffer;
43
+ copyProps(buffer, exports$1);
44
+ exports$1.Buffer = SafeBuffer;
45
45
  }
46
46
 
47
47
  function SafeBuffer (arg, encodingOrOffset, length) {
@@ -662,7 +662,7 @@ var jwa$2 = function jwa(algorithm) {
662
662
  es: createECDSAVerifer,
663
663
  none: createNoneVerifier,
664
664
  };
665
- var match = algorithm.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);
665
+ var match = algorithm.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);
666
666
  if (!match)
667
667
  throw typeError(MSG_INVALID_ALGORITHM, algorithm);
668
668
  var algo = (match[1] || match[3]).toLowerCase();
@@ -723,7 +723,12 @@ function jwsSign(opts) {
723
723
  }
724
724
 
725
725
  function SignStream$1(opts) {
726
- var secret = opts.secret||opts.privateKey||opts.key;
726
+ var secret = opts.secret;
727
+ secret = secret == null ? opts.privateKey : secret;
728
+ secret = secret == null ? opts.key : secret;
729
+ if (/^hs/i.test(opts.header.alg) === true && secret == null) {
730
+ throw new TypeError('secret must be a string or buffer or a KeyObject')
731
+ }
727
732
  var secretStream = new DataStream$1(secret);
728
733
  this.readable = true;
729
734
  this.header = opts.header;
@@ -848,7 +853,12 @@ function jwsDecode(jwsSig, opts) {
848
853
 
849
854
  function VerifyStream$1(opts) {
850
855
  opts = opts || {};
851
- var secretOrKey = opts.secret||opts.publicKey||opts.key;
856
+ var secretOrKey = opts.secret;
857
+ secretOrKey = secretOrKey == null ? opts.publicKey : secretOrKey;
858
+ secretOrKey = secretOrKey == null ? opts.key : secretOrKey;
859
+ if (/^hs/i.test(opts.algorithm) === true && secretOrKey == null) {
860
+ throw new TypeError('secret must be a string or buffer or a KeyObject')
861
+ }
852
862
  var secretStream = new DataStream(secretOrKey);
853
863
  this.readable = true;
854
864
  this.algorithm = opts.algorithm;
@@ -1216,7 +1226,7 @@ const debug$1 = (
1216
1226
 
1217
1227
  var debug_1 = debug$1;
1218
1228
 
1219
- (function (module, exports) {
1229
+ (function (module, exports$1) {
1220
1230
 
1221
1231
  const {
1222
1232
  MAX_SAFE_COMPONENT_LENGTH,
@@ -1224,14 +1234,14 @@ var debug_1 = debug$1;
1224
1234
  MAX_LENGTH,
1225
1235
  } = constants$1;
1226
1236
  const debug = debug_1;
1227
- exports = module.exports = {};
1237
+ exports$1 = module.exports = {};
1228
1238
 
1229
1239
  // The actual regexps go on exports.re
1230
- const re = exports.re = [];
1231
- const safeRe = exports.safeRe = [];
1232
- const src = exports.src = [];
1233
- const safeSrc = exports.safeSrc = [];
1234
- const t = exports.t = {};
1240
+ const re = exports$1.re = [];
1241
+ const safeRe = exports$1.safeRe = [];
1242
+ const src = exports$1.src = [];
1243
+ const safeSrc = exports$1.safeSrc = [];
1244
+ const t = exports$1.t = {};
1235
1245
  let R = 0;
1236
1246
 
1237
1247
  const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
@@ -1395,7 +1405,7 @@ var debug_1 = debug$1;
1395
1405
  createToken('LONETILDE', '(?:~>?)');
1396
1406
 
1397
1407
  createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
1398
- exports.tildeTrimReplace = '$1~';
1408
+ exports$1.tildeTrimReplace = '$1~';
1399
1409
 
1400
1410
  createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
1401
1411
  createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
@@ -1405,7 +1415,7 @@ var debug_1 = debug$1;
1405
1415
  createToken('LONECARET', '(?:\\^)');
1406
1416
 
1407
1417
  createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
1408
- exports.caretTrimReplace = '$1^';
1418
+ exports$1.caretTrimReplace = '$1^';
1409
1419
 
1410
1420
  createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
1411
1421
  createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
@@ -1418,7 +1428,7 @@ var debug_1 = debug$1;
1418
1428
  // it modifies, so that `> 1.2.3` ==> `>1.2.3`
1419
1429
  createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
1420
1430
  }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
1421
- exports.comparatorTrimReplace = '$1$2$3';
1431
+ exports$1.comparatorTrimReplace = '$1$2$3';
1422
1432
 
1423
1433
  // Something like `1.2.3 - 1.2.4`
1424
1434
  // Note that these all use the loose form, because they'll be
@@ -1461,6 +1471,10 @@ var parseOptions_1 = parseOptions$1;
1461
1471
 
1462
1472
  const numeric = /^[0-9]+$/;
1463
1473
  const compareIdentifiers$1 = (a, b) => {
1474
+ if (typeof a === 'number' && typeof b === 'number') {
1475
+ return a === b ? 0 : a < b ? -1 : 1
1476
+ }
1477
+
1464
1478
  const anum = numeric.test(a);
1465
1479
  const bnum = numeric.test(b);
1466
1480
 
@@ -1594,11 +1608,25 @@ let SemVer$d = class SemVer {
1594
1608
  other = new SemVer(other, this.options);
1595
1609
  }
1596
1610
 
1597
- return (
1598
- compareIdentifiers(this.major, other.major) ||
1599
- compareIdentifiers(this.minor, other.minor) ||
1600
- compareIdentifiers(this.patch, other.patch)
1601
- )
1611
+ if (this.major < other.major) {
1612
+ return -1
1613
+ }
1614
+ if (this.major > other.major) {
1615
+ return 1
1616
+ }
1617
+ if (this.minor < other.minor) {
1618
+ return -1
1619
+ }
1620
+ if (this.minor > other.minor) {
1621
+ return 1
1622
+ }
1623
+ if (this.patch < other.patch) {
1624
+ return -1
1625
+ }
1626
+ if (this.patch > other.patch) {
1627
+ return 1
1628
+ }
1629
+ return 0
1602
1630
  }
1603
1631
 
1604
1632
  comparePre (other) {
@@ -2410,6 +2438,7 @@ function requireRange () {
2410
2438
  // already replaced the hyphen ranges
2411
2439
  // turn into a set of JUST comparators.
2412
2440
  const parseComparator = (comp, options) => {
2441
+ comp = comp.replace(re[t.BUILD], '');
2413
2442
  debug('comp', comp, options);
2414
2443
  comp = replaceCarets(comp, options);
2415
2444
  debug('caret', comp);
@@ -5797,20 +5826,78 @@ var jwt = /*@__PURE__*/getDefaultExportFromCjs(jsonwebtoken);
5797
5826
 
5798
5827
  class Mixin {
5799
5828
  createBasicToken(payload, secret, expiresIn, options) {
5800
- const finalOptions = Object.assign(Object.assign({}, (options || {})), { expiresIn });
5829
+ const finalOptions = Object.assign(Object.assign({}, (options || {})), { expiresIn, issuer: (options === null || options === void 0 ? void 0 : options.issuer) || process.env.JWT_ISSUER || 'hemia-app', audience: (options === null || options === void 0 ? void 0 : options.audience) || process.env.JWT_AUDIENCE || 'hemia-api', algorithm: (options === null || options === void 0 ? void 0 : options.algorithm) || 'HS256' });
5801
5830
  return jwt.sign(payload, secret, finalOptions);
5802
5831
  }
5803
- validateTokenBase(token, secretKey) {
5832
+ validateTokenBase(token, secretKey, options) {
5804
5833
  try {
5805
- return jwt.verify(token, secretKey);
5834
+ const verifyOptions = Object.assign(Object.assign({}, options), { algorithms: ['HS256', 'RS256'], issuer: (options === null || options === void 0 ? void 0 : options.issuer) || process.env.JWT_ISSUER, audience: (options === null || options === void 0 ? void 0 : options.audience) || process.env.JWT_AUDIENCE, clockTolerance: 30 });
5835
+ return jwt.verify(token, secretKey, verifyOptions);
5806
5836
  }
5807
5837
  catch (error) {
5808
- console.error('Token inválido:', error);
5838
+ if (error instanceof jwt.TokenExpiredError) {
5839
+ console.error('Token expirado:', error.expiredAt);
5840
+ }
5841
+ else if (error instanceof jwt.JsonWebTokenError) {
5842
+ console.error('Token inválido:', error.message);
5843
+ }
5844
+ else if (error instanceof jwt.NotBeforeError) {
5845
+ console.error('Token no válido aún:', error.date);
5846
+ }
5847
+ else {
5848
+ console.error('Error de validación:', error);
5849
+ }
5809
5850
  return null;
5810
5851
  }
5811
5852
  }
5812
- decodeToken(token) {
5813
- return jwt.decode(token);
5853
+ validateTokenDetailed(token, secretKey, options) {
5854
+ try {
5855
+ const verifyOptions = Object.assign(Object.assign({}, options), { algorithms: ['HS256', 'RS256'], issuer: (options === null || options === void 0 ? void 0 : options.issuer) || process.env.JWT_ISSUER, audience: (options === null || options === void 0 ? void 0 : options.audience) || process.env.JWT_AUDIENCE, clockTolerance: 30 });
5856
+ const payload = jwt.verify(token, secretKey, verifyOptions);
5857
+ return {
5858
+ valid: true,
5859
+ payload
5860
+ };
5861
+ }
5862
+ catch (error) {
5863
+ if (error instanceof jwt.TokenExpiredError) {
5864
+ return {
5865
+ valid: false,
5866
+ error: `Token expirado en: ${error.expiredAt}`,
5867
+ errorType: 'expired'
5868
+ };
5869
+ }
5870
+ else if (error instanceof jwt.JsonWebTokenError) {
5871
+ return {
5872
+ valid: false,
5873
+ error: error.message,
5874
+ errorType: error.message.includes('signature') ? 'signature_invalid' : 'invalid'
5875
+ };
5876
+ }
5877
+ else if (error instanceof jwt.NotBeforeError) {
5878
+ return {
5879
+ valid: false,
5880
+ error: `Token no válido hasta: ${error.date}`,
5881
+ errorType: 'not_before'
5882
+ };
5883
+ }
5884
+ else {
5885
+ return {
5886
+ valid: false,
5887
+ error: 'Error desconocido al validar token',
5888
+ errorType: 'malformed'
5889
+ };
5890
+ }
5891
+ }
5892
+ }
5893
+ decodeToken(token, complete = false) {
5894
+ try {
5895
+ return jwt.decode(token, { complete });
5896
+ }
5897
+ catch (error) {
5898
+ console.error('Error al decodificar token:', error);
5899
+ return null;
5900
+ }
5814
5901
  }
5815
5902
  }
5816
5903
 
@@ -5818,30 +5905,133 @@ class JwtManager extends Mixin {
5818
5905
  constructor() {
5819
5906
  super();
5820
5907
  this._secretKey = '';
5908
+ this._issuer = '';
5909
+ this._audience = '';
5821
5910
  this._secretKey = process.env.JWT_SECRET || jwtConfig.cleanCredentialSecret;
5911
+ this._issuer = process.env.JWT_ISSUER || 'hemia-app';
5912
+ this._audience = process.env.JWT_AUDIENCE || 'hemia-api';
5822
5913
  if (!this._secretKey) {
5823
5914
  throw new Error("JWT secret key is required.");
5824
5915
  }
5825
5916
  }
5917
+ createToken(payload, expiresIn, options) {
5918
+ return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
5919
+ }
5920
+ createTokenWithSecret(payload, secretKey, expiresIn, options) {
5921
+ return this.createBasicToken(payload, secretKey, expiresIn || jwtConfig.expiresIn, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
5922
+ }
5923
+ createCleanCredentialsToken(operative = exports.Operatives.CATALOG, expiresIn) {
5924
+ const payload = { accessType: operative };
5925
+ return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn);
5926
+ }
5826
5927
  getTokenWithoutKey(payload, expiresIn, options) {
5827
- return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn, options);
5928
+ return this.createToken(payload, expiresIn, options);
5828
5929
  }
5829
5930
  getTokenWithKey(payload, secretKey, expiresIn, options) {
5830
- return this.createBasicToken(payload, secretKey, expiresIn || jwtConfig.expiresIn, options);
5931
+ return this.createTokenWithSecret(payload, secretKey, expiresIn, options);
5831
5932
  }
5832
5933
  getTokenCleanCredentials(operative = exports.Operatives.CATALOG, expiresIn) {
5833
- const payload = { accessType: operative };
5834
- return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn);
5934
+ return this.createCleanCredentialsToken(operative, expiresIn);
5835
5935
  }
5836
- validateToken(token, secretKey) {
5837
- return this.validateTokenBase(token, secretKey || this._secretKey);
5936
+ createIdToken(claims, expiresIn) {
5937
+ if (!claims.sub) {
5938
+ throw new Error('sub (subject) claim is required for ID tokens');
5939
+ }
5940
+ const payload = Object.assign(Object.assign({}, claims), { iss: this._issuer, aud: this._audience, iat: Math.floor(Date.now() / 1000) });
5941
+ return this.createBasicToken(payload, this._secretKey, expiresIn || jwtConfig.expiresIn, { issuer: this._issuer, audience: this._audience });
5838
5942
  }
5839
- decode(token) {
5840
- return this.decodeToken(token);
5943
+ createAccessToken(sub, scopes, expiresIn) {
5944
+ const payload = {
5945
+ sub,
5946
+ scope: scopes.join(' '),
5947
+ iss: this._issuer,
5948
+ aud: this._audience,
5949
+ iat: Math.floor(Date.now() / 1000),
5950
+ };
5951
+ return this.createBasicToken(payload, this._secretKey, expiresIn || '15m', { issuer: this._issuer, audience: this._audience });
5952
+ }
5953
+ createRefreshToken(sub, expiresIn) {
5954
+ const payload = {
5955
+ sub,
5956
+ type: 'refresh',
5957
+ iss: this._issuer,
5958
+ aud: this._audience,
5959
+ iat: Math.floor(Date.now() / 1000),
5960
+ };
5961
+ return this.createBasicToken(payload, this._secretKey, expiresIn || '30d', {
5962
+ issuer: this._issuer,
5963
+ audience: this._audience,
5964
+ jwtid: this.generateJti()
5965
+ });
5966
+ }
5967
+ verify(token, secretKey, options) {
5968
+ return this.validateTokenBase(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
5969
+ }
5970
+ verifyDetailed(token, secretKey, options) {
5971
+ return super.validateTokenDetailed(token, secretKey || this._secretKey, Object.assign(Object.assign({}, options), { issuer: (options === null || options === void 0 ? void 0 : options.issuer) || this._issuer, audience: (options === null || options === void 0 ? void 0 : options.audience) || this._audience }));
5972
+ }
5973
+ validateToken(token, secretKey, options) {
5974
+ return this.verify(token, secretKey, options);
5975
+ }
5976
+ validateTokenDetailed(token, secretKey, options) {
5977
+ return this.verifyDetailed(token, secretKey, options);
5978
+ }
5979
+ decode(token, complete = false) {
5980
+ return this.decodeToken(token, complete);
5981
+ }
5982
+ getClaims(token) {
5983
+ const decoded = this.decodeToken(token);
5984
+ if (!decoded)
5985
+ return null;
5986
+ const { sub, name, given_name, family_name, middle_name, nickname, preferred_username, profile, picture, website, gender, birthdate, zoneinfo, locale, updated_at, email, email_verified, phone_number, phone_number_verified, address } = decoded;
5987
+ return {
5988
+ sub,
5989
+ name,
5990
+ given_name,
5991
+ family_name,
5992
+ middle_name,
5993
+ nickname,
5994
+ preferred_username,
5995
+ profile,
5996
+ picture,
5997
+ website,
5998
+ gender,
5999
+ birthdate,
6000
+ zoneinfo,
6001
+ locale,
6002
+ updated_at,
6003
+ email,
6004
+ email_verified,
6005
+ phone_number,
6006
+ phone_number_verified,
6007
+ address
6008
+ };
6009
+ }
6010
+ getStandardClaims(token) {
6011
+ return this.getClaims(token);
6012
+ }
6013
+ hasScope(token, requiredScope) {
6014
+ const payload = this.verify(token);
6015
+ if (!payload || !payload.scope)
6016
+ return false;
6017
+ const scopes = typeof payload.scope === 'string'
6018
+ ? payload.scope.split(' ')
6019
+ : [];
6020
+ return scopes.includes(requiredScope);
6021
+ }
6022
+ generateJti() {
6023
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
5841
6024
  }
5842
6025
  getJwtKey() {
5843
6026
  return this._secretKey;
5844
6027
  }
5845
6028
  }
5846
6029
 
6030
+ exports.TokenType = void 0;
6031
+ (function (TokenType) {
6032
+ TokenType["ID_TOKEN"] = "id_token";
6033
+ TokenType["ACCESS_TOKEN"] = "access_token";
6034
+ TokenType["REFRESH_TOKEN"] = "refresh_token";
6035
+ })(exports.TokenType || (exports.TokenType = {}));
6036
+
5847
6037
  exports.JwtManager = JwtManager;
@@ -1,3 +1,5 @@
1
1
  export { JwtManager } from './services/jwt.service';
2
2
  export { Operatives } from './Enums/Enums';
3
- export { SignOptions, JwtPayload } from 'jsonwebtoken';
3
+ export { SignOptions, JwtPayload, VerifyOptions } from 'jsonwebtoken';
4
+ export { StandardClaims, JwtClaims, TokenPayload } from './interfaces/oidc-claims';
5
+ export { TokenType, TokenValidationResult } from './types/token-validation';
@@ -0,0 +1,42 @@
1
+ export interface StandardClaims {
2
+ sub: string;
3
+ name?: string;
4
+ given_name?: string;
5
+ family_name?: string;
6
+ middle_name?: string;
7
+ nickname?: string;
8
+ preferred_username?: string;
9
+ profile?: string;
10
+ picture?: string;
11
+ website?: string;
12
+ gender?: string;
13
+ birthdate?: string;
14
+ zoneinfo?: string;
15
+ locale?: string;
16
+ updated_at?: number;
17
+ email?: string;
18
+ email_verified?: boolean;
19
+ phone_number?: string;
20
+ phone_number_verified?: boolean;
21
+ address?: {
22
+ formatted?: string;
23
+ street_address?: string;
24
+ locality?: string;
25
+ region?: string;
26
+ postal_code?: string;
27
+ country?: string;
28
+ };
29
+ }
30
+ export interface JwtClaims {
31
+ iss?: string;
32
+ aud?: string | string[];
33
+ exp?: number;
34
+ nbf?: number;
35
+ iat?: number;
36
+ jti?: string;
37
+ }
38
+ export interface TokenPayload extends JwtClaims, Partial<StandardClaims> {
39
+ scope?: string;
40
+ type?: string;
41
+ [key: string]: any;
42
+ }
@@ -1,6 +1,8 @@
1
- import { SignOptions, JwtPayload } from 'jsonwebtoken';
1
+ import { SignOptions, JwtPayload, VerifyOptions } from 'jsonwebtoken';
2
+ import { TokenValidationResult } from '../types/token-validation';
2
3
  export declare class Mixin {
3
4
  protected createBasicToken(payload: string | Buffer | object, secret: string, expiresIn: any | number, options?: SignOptions): string;
4
- protected validateTokenBase(token: string, secretKey: string): JwtPayload | null;
5
- decodeToken(token: string): JwtPayload | null;
5
+ protected validateTokenBase(token: string, secretKey: string, options?: VerifyOptions): JwtPayload | null;
6
+ protected validateTokenDetailed(token: string, secretKey: string, options?: VerifyOptions): TokenValidationResult;
7
+ decodeToken(token: string, complete?: boolean): JwtPayload | null;
6
8
  }
@@ -1,13 +1,30 @@
1
- import { SignOptions, JwtPayload } from 'jsonwebtoken';
1
+ import { SignOptions, JwtPayload, VerifyOptions } from 'jsonwebtoken';
2
2
  import { Operatives } from '../Enums/Enums';
3
3
  import { Mixin } from '../mixin/jwt.mixin';
4
+ import { StandardClaims } from '../interfaces/oidc-claims';
5
+ import { TokenValidationResult } from '../types/token-validation';
4
6
  export declare class JwtManager extends Mixin {
5
7
  private _secretKey;
8
+ private _issuer;
9
+ private _audience;
6
10
  constructor();
11
+ createToken(payload: object, expiresIn?: string | number, options?: SignOptions): string;
12
+ createTokenWithSecret(payload: object, secretKey: string, expiresIn?: string | number, options?: SignOptions): string;
13
+ createCleanCredentialsToken(operative?: Operatives, expiresIn?: string | number): string;
7
14
  getTokenWithoutKey(payload: object, expiresIn?: string | number, options?: SignOptions): string;
8
15
  getTokenWithKey(payload: object, secretKey: string, expiresIn?: string | number, options?: SignOptions): string;
9
16
  getTokenCleanCredentials(operative?: Operatives, expiresIn?: string | number): string;
10
- validateToken(token: string, secretKey?: string): JwtPayload | null;
11
- decode(token: string): JwtPayload | null;
17
+ createIdToken(claims: StandardClaims, expiresIn?: string | number): string;
18
+ createAccessToken(sub: string, scopes: string[], expiresIn?: string | number): string;
19
+ createRefreshToken(sub: string, expiresIn?: string | number): string;
20
+ verify(token: string, secretKey?: string, options?: VerifyOptions): JwtPayload | null;
21
+ verifyDetailed(token: string, secretKey?: string, options?: VerifyOptions): TokenValidationResult;
22
+ validateToken(token: string, secretKey?: string, options?: VerifyOptions): JwtPayload | null;
23
+ validateTokenDetailed(token: string, secretKey?: string, options?: VerifyOptions): TokenValidationResult;
24
+ decode(token: string, complete?: boolean): JwtPayload | null;
25
+ getClaims(token: string): StandardClaims | null;
26
+ getStandardClaims(token: string): StandardClaims | null;
27
+ hasScope(token: string, requiredScope: string): boolean;
28
+ private generateJti;
12
29
  getJwtKey(): string;
13
30
  }
@@ -0,0 +1,11 @@
1
+ export declare enum TokenType {
2
+ ID_TOKEN = "id_token",
3
+ ACCESS_TOKEN = "access_token",
4
+ REFRESH_TOKEN = "refresh_token"
5
+ }
6
+ export interface TokenValidationResult {
7
+ valid: boolean;
8
+ payload?: any;
9
+ error?: string;
10
+ errorType?: 'expired' | 'invalid' | 'not_before' | 'malformed' | 'signature_invalid';
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/jwt-manager",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Gestor de JWT seguro y extensible para aplicaciones Node.js",
5
5
  "main": "dist/hemia-jwt-manager.js",
6
6
  "module": "dist/hemia-jwt-manager.esm.js",