@midwayjs/jwt 3.20.5 → 4.0.0-beta.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.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.20.5",
4
+ "version": "4.0.0-beta.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.20.4",
29
- "@midwayjs/express": "^3.20.4",
30
- "@midwayjs/koa": "^3.20.5",
31
- "@midwayjs/mock": "^3.20.4",
32
- "@midwayjs/web": "^3.20.4"
28
+ "@midwayjs/core": "^4.0.0-beta.1",
29
+ "@midwayjs/express": "^4.0.0-beta.1",
30
+ "@midwayjs/koa": "^4.0.0-beta.1",
31
+ "@midwayjs/mock": "^4.0.0-beta.1",
32
+ "@midwayjs/web": "^4.0.0-beta.1"
33
33
  },
34
34
  "dependencies": {
35
35
  "@types/jsonwebtoken": "9.0.9",
36
36
  "jsonwebtoken": "9.0.2"
37
37
  },
38
- "gitHead": "7ce57281bd3ef5d18dc50b47ff9bffb8a27c071e"
38
+ "gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
39
39
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2013 - Now midwayjs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.