@celljs/jwt 3.8.0 → 3.9.0

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.
@@ -0,0 +1,7 @@
1
+ import { CustomError } from '@celljs/core';
2
+ export declare class PublicKeyNotFoundError extends CustomError {
3
+ constructor();
4
+ }
5
+ export declare class PrivateKeyNotFoundError extends CustomError {
6
+ constructor();
7
+ }
@@ -0,0 +1,12 @@
1
+ import { CustomError } from '@celljs/core';
2
+ export class PublicKeyNotFoundError extends CustomError {
3
+ constructor() {
4
+ super('Public key not found');
5
+ }
6
+ }
7
+ export class PrivateKeyNotFoundError extends CustomError {
8
+ constructor() {
9
+ super('Private key not found');
10
+ }
11
+ }
12
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/node/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACnD;QACI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAClC,CAAC;CACJ;AAED,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACpD;QACI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACnC,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ export * from './jwt-protocol.js';
2
+ export * from './jwt-service.js';
3
+ export * from './errors.js';
4
+ export * from './jwt-secret-service.js';
@@ -0,0 +1,5 @@
1
+ export * from './jwt-protocol.js';
2
+ export * from './jwt-service.js';
3
+ export * from './errors.js';
4
+ export * from './jwt-secret-service.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import * as jwt from 'jsonwebtoken';
2
+ export declare const JwtService: unique symbol;
3
+ export declare const JwtSecretService: unique symbol;
4
+ export interface JwtOptions {
5
+ signOptions?: jwt.SignOptions;
6
+ secret?: string | Buffer;
7
+ publicKey?: string | Buffer;
8
+ privateKey?: jwt.Secret;
9
+ verifyOptions?: jwt.VerifyOptions;
10
+ }
11
+ export interface SignOptions extends jwt.SignOptions {
12
+ }
13
+ export interface VerifyOptions extends jwt.VerifyOptions {
14
+ }
15
+ export interface DecodeOptions extends jwt.DecodeOptions {
16
+ }
17
+ export interface Jwt extends jwt.Jwt {
18
+ }
19
+ export interface JwtPayload extends jwt.JwtPayload {
20
+ }
21
+ export type Secret = jwt.Secret;
22
+ export interface JwtService {
23
+ sign(payload: string | Buffer | object, options?: SignOptions, privateKey?: Secret): Promise<string>;
24
+ verify<T extends object = any>(token: string, options?: VerifyOptions, publicKey?: string | Buffer): Promise<T>;
25
+ decode(token: string, options?: DecodeOptions): Promise<JwtPayload | string | undefined>;
26
+ }
27
+ export interface JwtSecretService {
28
+ getPublicKey(): Promise<string | Buffer>;
29
+ getPrivateKey(): Promise<Secret>;
30
+ }
@@ -0,0 +1,3 @@
1
+ export const JwtService = Symbol('JwtService');
2
+ export const JwtSecretService = Symbol('JwtSecretService');
3
+ //# sourceMappingURL=jwt-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-protocol.js","sourceRoot":"","sources":["../../src/node/jwt-protocol.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { JwtOptions, JwtSecretService, Secret } from './jwt-protocol.js';
2
+ export declare class jwtSecretService implements JwtSecretService {
3
+ protected readonly jwtOptions?: JwtOptions;
4
+ getPublicKey(): Promise<string | Buffer>;
5
+ getPrivateKey(): Promise<Secret>;
6
+ }
@@ -0,0 +1,41 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Component, Value } from '@celljs/core';
11
+ import { PrivateKeyNotFoundError, PublicKeyNotFoundError } from './errors.js';
12
+ import { JwtSecretService } from './jwt-protocol.js';
13
+ let jwtSecretService = class jwtSecretService {
14
+ async getPublicKey() {
15
+ var _a, _b;
16
+ var _c;
17
+ const secret = (_c = (_a = this.jwtOptions) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _c !== void 0 ? _c : (_b = this.jwtOptions) === null || _b === void 0 ? void 0 : _b.secret;
18
+ if (secret) {
19
+ return secret;
20
+ }
21
+ throw new PublicKeyNotFoundError();
22
+ }
23
+ async getPrivateKey() {
24
+ var _a, _b;
25
+ var _c;
26
+ const secret = (_c = (_a = this.jwtOptions) === null || _a === void 0 ? void 0 : _a.privateKey) !== null && _c !== void 0 ? _c : (_b = this.jwtOptions) === null || _b === void 0 ? void 0 : _b.secret;
27
+ if (secret) {
28
+ return secret;
29
+ }
30
+ throw new PrivateKeyNotFoundError();
31
+ }
32
+ };
33
+ __decorate([
34
+ Value('cell.jwt'),
35
+ __metadata("design:type", Object)
36
+ ], jwtSecretService.prototype, "jwtOptions", void 0);
37
+ jwtSecretService = __decorate([
38
+ Component(JwtSecretService)
39
+ ], jwtSecretService);
40
+ export { jwtSecretService };
41
+ //# sourceMappingURL=jwt-secret-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-secret-service.js","sourceRoot":"","sources":["../../src/node/jwt-secret-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAc,gBAAgB,EAAU,MAAM,gBAAgB,CAAC;AAG/D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAKzB,KAAK,CAAC,YAAY;;;QACd,MAAM,MAAM,SAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,SAAS,mCAAI,MAAA,IAAI,CAAC,UAAU,0CAAE,MAAM,CAAC;QACrE,IAAI,MAAM,EAAE,CAAC;YACT,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,sBAAsB,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,aAAa;;;QACf,MAAM,MAAM,SAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,UAAU,mCAAI,MAAA,IAAI,CAAC,UAAU,0CAAE,MAAM,CAAC;QACtE,IAAI,MAAM,EAAE,CAAC;YACT,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,uBAAuB,EAAE,CAAC;IACxC,CAAC;CACJ,CAAA;AAjBsB;IADlB,KAAK,CAAC,UAAU,CAAC;;oDACyB;AAHlC,gBAAgB;IAD5B,SAAS,CAAC,gBAAgB,CAAC;GACf,gBAAgB,CAoB5B"}
@@ -0,0 +1,8 @@
1
+ import { DecodeOptions, JwtOptions, JwtPayload, JwtSecretService, JwtService, Secret, SignOptions, VerifyOptions } from './jwt-protocol.js';
2
+ export declare class JwtServiceImpl implements JwtService {
3
+ protected readonly jwtOptions?: JwtOptions;
4
+ protected readonly jwtSecretService: JwtSecretService;
5
+ sign(payload: string | object | Buffer, options?: SignOptions, privateKey?: Secret): Promise<string>;
6
+ verify<T extends object = any>(token: string, options?: VerifyOptions, publicKey?: string | Buffer): Promise<T>;
7
+ decode(token: string, options?: DecodeOptions): Promise<JwtPayload | string | undefined>;
8
+ }
@@ -0,0 +1,64 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Autowired, Component, Value } from '@celljs/core';
11
+ import { JwtSecretService, JwtService } from './jwt-protocol.js';
12
+ import jwt from 'jsonwebtoken';
13
+ let JwtServiceImpl = class JwtServiceImpl {
14
+ async sign(payload, options, privateKey) {
15
+ var _a;
16
+ const mergedOptions = { ...(_a = this.jwtOptions) === null || _a === void 0 ? void 0 : _a.signOptions, ...options };
17
+ const secret = privateKey !== null && privateKey !== void 0 ? privateKey : await this.jwtSecretService.getPrivateKey();
18
+ return new Promise((resolve, reject) => {
19
+ jwt.sign(payload, secret, mergedOptions, (err, token) => {
20
+ if (err) {
21
+ reject(err);
22
+ }
23
+ else {
24
+ resolve(token || '');
25
+ }
26
+ });
27
+ });
28
+ }
29
+ async verify(token, options, publicKey) {
30
+ var _a;
31
+ const mergedOptions = { ...(_a = this.jwtOptions) === null || _a === void 0 ? void 0 : _a.verifyOptions, ...options };
32
+ const secret = publicKey !== null && publicKey !== void 0 ? publicKey : await this.jwtSecretService.getPublicKey();
33
+ return new Promise((resolve, reject) => {
34
+ jwt.verify(token, secret, mergedOptions, (err, decoded) => {
35
+ if (err) {
36
+ reject(err);
37
+ }
38
+ else {
39
+ resolve(decoded);
40
+ }
41
+ });
42
+ });
43
+ }
44
+ async decode(token, options) {
45
+ const decoded = jwt.decode(token, options);
46
+ if (!decoded) {
47
+ return undefined;
48
+ }
49
+ return decoded;
50
+ }
51
+ };
52
+ __decorate([
53
+ Value('cell.jwt'),
54
+ __metadata("design:type", Object)
55
+ ], JwtServiceImpl.prototype, "jwtOptions", void 0);
56
+ __decorate([
57
+ Autowired(JwtSecretService),
58
+ __metadata("design:type", Object)
59
+ ], JwtServiceImpl.prototype, "jwtSecretService", void 0);
60
+ JwtServiceImpl = __decorate([
61
+ Component(JwtService)
62
+ ], JwtServiceImpl);
63
+ export { JwtServiceImpl };
64
+ //# sourceMappingURL=jwt-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-service.js","sourceRoot":"","sources":["../../src/node/jwt-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAyC,gBAAgB,EAAE,UAAU,EAAsC,MAAM,gBAAgB,CAAC;AACzI,OAAO,GAAG,MAAM,cAAc,CAAC;AAGxB,IAAM,cAAc,GAApB,MAAM,cAAc;IAQvB,KAAK,CAAC,IAAI,CAAC,OAAiC,EAAE,OAAqB,EAAE,UAAmB;;QACpF,MAAM,aAAa,GAAG,EAAE,GAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;QACtE,MAAM,MAAM,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC;QACzE,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,GAAG,CAAC,IAAI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yB;AAGxB;IADlB,SAAS,CAAC,gBAAgB,CAAC;;wDAC0B;AAN7C,cAAc;IAD1B,SAAS,CAAC,UAAU,CAAC;GACT,cAAc,CA4C1B"}
@@ -0,0 +1,3 @@
1
+ import './index.js';
2
+ declare const _default: import("inversify").interfaces.ContainerModule;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index.js';
3
+ export default autoBind();
4
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,CAAC;AAEjB,eAAe,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1,58 +1,28 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
8
  var __metadata = (this && this.__metadata) || function (k, v) {
42
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
44
14
  Object.defineProperty(exports, "__esModule", { value: true });
45
15
  exports.JwtServiceImpl = void 0;
46
16
  const core_1 = require("@celljs/core");
47
17
  const jwt_protocol_1 = require("./jwt-protocol");
48
- const jwt = __importStar(require("jsonwebtoken"));
18
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
49
19
  let JwtServiceImpl = class JwtServiceImpl {
50
20
  async sign(payload, options, privateKey) {
51
21
  var _a;
52
22
  const mergedOptions = { ...(_a = this.jwtOptions) === null || _a === void 0 ? void 0 : _a.signOptions, ...options };
53
23
  const secret = privateKey !== null && privateKey !== void 0 ? privateKey : await this.jwtSecretService.getPrivateKey();
54
24
  return new Promise((resolve, reject) => {
55
- jwt.sign(payload, secret, mergedOptions, (err, token) => {
25
+ jsonwebtoken_1.default.sign(payload, secret, mergedOptions, (err, token) => {
56
26
  if (err) {
57
27
  reject(err);
58
28
  }
@@ -67,7 +37,7 @@ let JwtServiceImpl = class JwtServiceImpl {
67
37
  const mergedOptions = { ...(_a = this.jwtOptions) === null || _a === void 0 ? void 0 : _a.verifyOptions, ...options };
68
38
  const secret = publicKey !== null && publicKey !== void 0 ? publicKey : await this.jwtSecretService.getPublicKey();
69
39
  return new Promise((resolve, reject) => {
70
- jwt.verify(token, secret, mergedOptions, (err, decoded) => {
40
+ jsonwebtoken_1.default.verify(token, secret, mergedOptions, (err, decoded) => {
71
41
  if (err) {
72
42
  reject(err);
73
43
  }
@@ -78,7 +48,7 @@ let JwtServiceImpl = class JwtServiceImpl {
78
48
  });
79
49
  }
80
50
  async decode(token, options) {
81
- const decoded = jwt.decode(token, options);
51
+ const decoded = jsonwebtoken_1.default.decode(token, options);
82
52
  if (!decoded) {
83
53
  return undefined;
84
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-service.js","sourceRoot":"","sources":["../../src/node/jwt-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA2D;AAC3D,iDAAyI;AACzI,MAAY,GAAG,yCAAqB;AAG7B,IAAM,cAAc,GAApB,MAAM,cAAc;IAQvB,KAAK,CAAC,IAAI,CAAC,OAAiC,EAAE,OAAqB,EAAE,UAAmB;;QACpF,MAAM,aAAa,GAAG,EAAE,GAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;QACtE,MAAM,MAAM,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC;QACzE,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBACpD,IAAI,GAAG,EAAE,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAA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E,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;gBACtD,IAAI,GAAG,EAAE,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACJ,OAAO,CAAC,OAAY,CAAC,CAAC;gBAC1B,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,OAAuB;QAC/C,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CAEJ,CAAA;;AAzCsB;IADlB,IAAA,YAAK,EAAC,UAAU,CAAC;;kDACyB;AAGxB;IADlB,IAAA,gBAAS,EAAC,+BAAgB,CAAC;;wDAC0B;yBAN7C,cAAc;IAD1B,IAAA,gBAAS,EAAC,yBAAU,CAAC;GACT,cAAc,CA4C1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/jwt",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -18,17 +18,18 @@
18
18
  "typings": "lib/node/index.d.ts",
19
19
  "files": [
20
20
  "lib",
21
+ "esm",
21
22
  "src",
22
23
  "cell.yml"
23
24
  ],
24
25
  "scripts": {
25
- "build": "tsc -b",
26
- "clean": "rm -rf lib *.tsbuildinfo",
26
+ "build": "tsc -b && bun ../../scripts/build-esm.ts",
27
+ "clean": "rm -rf lib esm *.tsbuildinfo",
27
28
  "test": "bun test --preload reflect-metadata ./lib",
28
29
  "watch": "tsc -b -w --preserveWatchOutput"
29
30
  },
30
31
  "dependencies": {
31
- "@celljs/core": "3.8.0",
32
+ "@celljs/core": "3.9.0",
32
33
  "jsonwebtoken": "^9.0.0",
33
34
  "tslib": "^2.8.0"
34
35
  },
@@ -37,5 +38,29 @@
37
38
  },
38
39
  "publishConfig": {
39
40
  "access": "public"
41
+ },
42
+ "exports": {
43
+ ".": {
44
+ "webpack": "./lib/node/index.js",
45
+ "import": "./esm/node/index.js",
46
+ "default": "./lib/node/index.js"
47
+ },
48
+ "./package.json": "./package.json",
49
+ "./lib/node": {
50
+ "webpack": "./lib/node/index.js",
51
+ "import": "./esm/node/index.js",
52
+ "default": "./lib/node/index.js"
53
+ },
54
+ "./lib/*.js": {
55
+ "webpack": "./lib/*.js",
56
+ "import": "./esm/*.js",
57
+ "default": "./lib/*.js"
58
+ },
59
+ "./lib/*": {
60
+ "webpack": "./lib/*.js",
61
+ "import": "./esm/*.js",
62
+ "default": "./lib/*.js"
63
+ },
64
+ "./*": "./*"
40
65
  }
41
66
  }
@@ -1,6 +1,6 @@
1
1
  import { Autowired, Component, Value } from '@celljs/core';
2
2
  import { DecodeOptions, JwtOptions, JwtPayload, JwtSecretService, JwtService, Secret, SignOptions, VerifyOptions } from './jwt-protocol';
3
- import * as jwt from 'jsonwebtoken';
3
+ import jwt from 'jsonwebtoken';
4
4
 
5
5
  @Component(JwtService)
6
6
  export class JwtServiceImpl implements JwtService {