@azteam/express 1.2.170 → 1.2.171

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.170",
3
+ "version": "1.2.171",
4
4
  "main": "src/index.js",
5
5
  "engines": {
6
6
  "node": ">= 12.0.0",
@@ -7,3 +7,4 @@ export {default as paginateMiddleware} from './paginateMiddleware';
7
7
  export {default as validateMiddleware} from './validateMiddleware';
8
8
  export {default as limitRequestMiddleware} from './limitRequestMiddleware';
9
9
  export {default as cacheMiddleware} from './cacheMiddleware';
10
+ export {default as verifyGoogleAppMiddleware} from './verifyGoogleAppMiddleware';
@@ -1,11 +1,11 @@
1
1
  import {isValidSign} from '@azteam/crypto';
2
2
  import {ErrorException, SIGNATURE_FAILED} from '@azteam/error';
3
3
 
4
- export default function (secretKey, mTimeout = 5) {
4
+ export default function (mTimeout = 5) {
5
5
  return async function (req, res, next) {
6
6
  if (req.query.sign) {
7
- let url = `${req.protocol}://${req.hostname}${req.originalUrl}`;
8
- if (isValidSign(url, secretKey, mTimeout)) {
7
+ const url = `${req.protocol}://${req.hostname}${req.originalUrl}`;
8
+ if (isValidSign(url, process.env.SECRET_KEY, mTimeout)) {
9
9
  return next();
10
10
  }
11
11
  }
@@ -0,0 +1,13 @@
1
+ import {decryptAES} from '@azteam/crypto';
2
+ import {ErrorException, USER_NOT_VERIFIED} from '@azteam/error';
3
+
4
+ export default function () {
5
+ return async function (req, res, next) {
6
+ if (!req.user.googleCredential) {
7
+ return next(new ErrorException(USER_NOT_VERIFIED));
8
+ }
9
+ req.user.google_token = JSON.parse(decryptAES(req.user.googleCredential, process.env.SECRET_KEY));
10
+
11
+ return next();
12
+ };
13
+ }