@midwayjs/jwt 3.19.2 → 4.0.0-alpha.1

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.
@@ -14,7 +14,8 @@ let JwtConfiguration = class JwtConfiguration {
14
14
  await container.getAsync(jwt_1.JwtService);
15
15
  }
16
16
  };
17
- JwtConfiguration = __decorate([
17
+ exports.JwtConfiguration = JwtConfiguration;
18
+ exports.JwtConfiguration = JwtConfiguration = __decorate([
18
19
  (0, core_1.Configuration)({
19
20
  namespace: 'jwt',
20
21
  importConfigs: [
@@ -26,5 +27,4 @@ JwtConfiguration = __decorate([
26
27
  ],
27
28
  })
28
29
  ], JwtConfiguration);
29
- exports.JwtConfiguration = JwtConfiguration;
30
30
  //# sourceMappingURL=configuration.js.map
package/dist/jwt.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { DecodeOptions, GetPublicKeyOrSecret, Jwt, Secret, SignOptions, VerifyOptions } from 'jsonwebtoken';
3
4
  type JwtPayload = string | Buffer | Record<string, any>;
4
5
  /**
package/dist/jwt.js CHANGED
@@ -19,10 +19,9 @@ const jwt = require("jsonwebtoken");
19
19
  */
20
20
  let JwtService = class JwtService {
21
21
  signSync(payload, secretOrPrivateKey, options) {
22
- var _a;
23
22
  if (!this.isSecret(secretOrPrivateKey)) {
24
23
  options = secretOrPrivateKey;
25
- secretOrPrivateKey = (_a = this.jwtConfig) === null || _a === void 0 ? void 0 : _a.secret;
24
+ secretOrPrivateKey = this.jwtConfig?.secret;
26
25
  }
27
26
  if (!secretOrPrivateKey) {
28
27
  throw new core_1.MidwayCommonError('[midway:jwt] jwt secret should be set');
@@ -31,10 +30,9 @@ let JwtService = class JwtService {
31
30
  return jwt.sign(payload, secretOrPrivateKey, options);
32
31
  }
33
32
  async sign(payload, secretOrPrivateKey, options) {
34
- var _a;
35
33
  if (!this.isSecret(secretOrPrivateKey)) {
36
34
  options = secretOrPrivateKey;
37
- secretOrPrivateKey = (_a = this.jwtConfig) === null || _a === void 0 ? void 0 : _a.secret;
35
+ secretOrPrivateKey = this.jwtConfig?.secret;
38
36
  }
39
37
  if (!secretOrPrivateKey) {
40
38
  throw new core_1.MidwayCommonError('[midway:jwt] provide the jwt secret please');
@@ -52,10 +50,9 @@ let JwtService = class JwtService {
52
50
  });
53
51
  }
54
52
  verifySync(token, secretOrPublicKey, options) {
55
- var _a;
56
53
  if (!this.isSecret(secretOrPublicKey)) {
57
54
  options = secretOrPublicKey;
58
- secretOrPublicKey = (_a = this.jwtConfig) === null || _a === void 0 ? void 0 : _a.secret;
55
+ secretOrPublicKey = this.jwtConfig?.secret;
59
56
  }
60
57
  if (!secretOrPublicKey) {
61
58
  throw new core_1.MidwayCommonError('[midway:jwt] provide the jwt secret please');
@@ -64,10 +61,9 @@ let JwtService = class JwtService {
64
61
  return jwt.verify(token, secretOrPublicKey, options);
65
62
  }
66
63
  async verify(token, secretOrPublicKey, options) {
67
- var _a;
68
64
  if (!this.isSecret(secretOrPublicKey)) {
69
65
  options = secretOrPublicKey;
70
- secretOrPublicKey = (_a = this.jwtConfig) === null || _a === void 0 ? void 0 : _a.secret;
66
+ secretOrPublicKey = this.jwtConfig?.secret;
71
67
  }
72
68
  if (!secretOrPublicKey) {
73
69
  throw new core_1.MidwayCommonError('[midway:jwt] provide the jwt secret please');
@@ -126,13 +122,13 @@ let JwtService = class JwtService {
126
122
  return false;
127
123
  }
128
124
  };
125
+ exports.JwtService = JwtService;
129
126
  __decorate([
130
127
  (0, core_1.Config)('jwt'),
131
128
  __metadata("design:type", Object)
132
129
  ], JwtService.prototype, "jwtConfig", void 0);
133
- JwtService = __decorate([
130
+ exports.JwtService = JwtService = __decorate([
134
131
  (0, core_1.Provide)(),
135
132
  (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
136
133
  ], JwtService);
137
- exports.JwtService = JwtService;
138
134
  //# sourceMappingURL=jwt.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/jwt",
3
3
  "description": "midway jwt component",
4
- "version": "3.19.2",
4
+ "version": "4.0.0-alpha.1",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "files": [
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "tsc",
14
14
  "test": "node --require=ts-node/register ../../node_modules/jest/bin/jest.js",
15
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit"
15
+ "cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit"
16
16
  },
17
17
  "keywords": [
18
18
  "midway",
@@ -25,15 +25,15 @@
25
25
  "author": "Nawbc",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@midwayjs/core": "^3.19.0",
29
- "@midwayjs/express": "^3.19.2",
30
- "@midwayjs/koa": "^3.19.2",
31
- "@midwayjs/mock": "^3.19.2",
32
- "@midwayjs/web": "^3.19.2"
28
+ "@midwayjs/core": "^4.0.0-alpha.1",
29
+ "@midwayjs/express": "^4.0.0-alpha.1",
30
+ "@midwayjs/koa": "^4.0.0-alpha.1",
31
+ "@midwayjs/mock": "^4.0.0-alpha.1",
32
+ "@midwayjs/web": "^4.0.0-alpha.1"
33
33
  },
34
34
  "dependencies": {
35
35
  "@types/jsonwebtoken": "9.0.7",
36
36
  "jsonwebtoken": "9.0.2"
37
37
  },
38
- "gitHead": "57fd034be94897fb819b0d9ef776de0b9923ab0f"
38
+ "gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
39
39
  }