@citec-spbu/jwt 1.1.1 → 1.1.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.
@@ -77,18 +77,24 @@ let JwtService = class JwtService {
77
77
  const signOptions = this.mergeJwtOptions({ ...options }, "signOptions");
78
78
  const privateKey = this.getSecretKey(options, "privateKey");
79
79
  if (!privateKey) {
80
- throw new Error('"privateKey" must be provided for "sign" function');
80
+ throw new Error('"privateKey" must be provided for "signAsync" function');
81
81
  }
82
82
  return new Promise((resolve, reject) => jwt.sign(payload, privateKey, signOptions, (err, token) => err ? reject(err) : resolve(token)));
83
83
  }
84
84
  verify(token, options) {
85
85
  const verifyOptions = this.mergeJwtOptions({ ...options }, "verifyOptions");
86
86
  const publicKey = this.getSecretKey(options, "publicKey");
87
+ if (!publicKey) {
88
+ throw new Error('"publicKey" must be provided for "verify" function');
89
+ }
87
90
  return jwt.verify(token, publicKey, verifyOptions);
88
91
  }
89
92
  verifyAsync(token, options) {
90
93
  const verifyOptions = this.mergeJwtOptions({ ...options }, "verifyOptions");
91
94
  const publicKey = this.getSecretKey(options, "publicKey");
95
+ if (!publicKey) {
96
+ throw new Error('"publicKey" must be provided for "verifyAsync" function');
97
+ }
92
98
  return new Promise((resolve, reject) => jwt.verify(token, publicKey, verifyOptions, (err, decoded) => err ? reject(err) : resolve(decoded)));
93
99
  }
94
100
  decode(token, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citec-spbu/jwt",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Lightweight auth lib",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",