@jayfong/x-server 2.45.1 → 2.45.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.
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  exports.__esModule = true;
5
5
  exports.JwtService = void 0;
6
6
  var _jsonwebtoken = _interopRequireDefault(require("jsonwebtoken"));
7
- var _date = require("vtils/date");
8
- var _http_error = require("../core/http_error");
9
7
  var _lruCache = require("lru-cache");
10
8
  var _vtils = require("vtils");
9
+ var _date = require("vtils/date");
10
+ var _http_error = require("../core/http_error");
11
11
  class JwtService {
12
12
  constructor(options) {
13
13
  this.options = options;
@@ -1,26 +1,28 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node/http" />
3
3
  /// <reference types="got/dist/source/core/utils/timed-out" />
4
+ import type { IncomingHttpHeaders } from 'http';
4
5
  import jwt from 'jsonwebtoken';
5
- import { BaseService } from './base';
6
6
  import { LRUCache } from 'lru-cache';
7
7
  import { MsValue } from 'vtils';
8
- import type { IncomingHttpHeaders } from 'http';
9
8
  import type { RequiredBy } from 'vtils/types';
9
+ import { BaseService } from './base';
10
+ export interface JwtServiceJwtPayload extends Record<string, any> {
11
+ }
10
12
  export interface JwtServiceOptions {
11
13
  secret: string;
12
14
  ttl: MsValue;
13
- cache?: LRUCache.Options<string, Record<string, any>, any>;
14
- onVerify?: (payload: RequiredBy<jwt.JwtPayload, 'iat' | 'exp'>) => any;
15
+ cache?: LRUCache.Options<string, JwtServiceJwtPayload, any>;
16
+ onVerify?: (payload: JwtServiceJwtPayload & RequiredBy<jwt.JwtPayload, 'iat' | 'exp'>) => any;
15
17
  }
16
18
  export declare class JwtService implements BaseService {
17
19
  private options;
18
20
  serviceName: string;
19
21
  private cache;
20
22
  constructor(options: JwtServiceOptions);
21
- sign<T extends Record<string, any>>(payload: T, ttl?: MsValue): string;
22
- verify<T extends Record<string, any>>(token: string): Promise<T>;
23
- verifyFromHttpHeaders<T extends Record<string, any>>(headers: IncomingHttpHeaders): Promise<T>;
23
+ sign<T extends JwtServiceJwtPayload>(payload: T, ttl?: MsValue): string;
24
+ verify<T extends JwtServiceJwtPayload>(token: string): Promise<T>;
25
+ verifyFromHttpHeaders<T extends JwtServiceJwtPayload>(headers: IncomingHttpHeaders): Promise<T>;
24
26
  }
25
27
  declare module '../x' {
26
28
  interface X {
@@ -1,8 +1,8 @@
1
1
  import jwt from 'jsonwebtoken';
2
- import { differenceInMilliseconds, fromUnixTime } from 'vtils/date';
3
- import { HttpError } from "../core/http_error";
4
2
  import { LRUCache } from 'lru-cache';
5
3
  import { ms } from 'vtils';
4
+ import { differenceInMilliseconds, fromUnixTime } from 'vtils/date';
5
+ import { HttpError } from "../core/http_error";
6
6
  export class JwtService {
7
7
  constructor(options) {
8
8
  this.options = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.45.1",
3
+ "version": "2.45.2",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",