@volcanicminds/backend 0.2.28 → 0.2.29
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/README.md +0 -7
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/auth/controller/auth.js +136 -17
- package/dist/lib/api/auth/controller/auth.js.map +1 -1
- package/dist/lib/api/auth/routes.js +107 -13
- package/dist/lib/api/auth/routes.js.map +1 -1
- package/dist/lib/api/health/routes.js +2 -2
- package/dist/lib/api/health/routes.js.map +1 -1
- package/dist/lib/api/users/routes.js +12 -14
- package/dist/lib/api/users/routes.js.map +1 -1
- package/dist/lib/hooks/onRequest.js +13 -9
- package/dist/lib/hooks/onRequest.js.map +1 -1
- package/dist/lib/loader/plugins.js +0 -1
- package/dist/lib/loader/plugins.js.map +1 -1
- package/dist/lib/loader/router.js +66 -35
- package/dist/lib/loader/router.js.map +1 -1
- package/dist/lib/loader/schemas.js +8 -3
- package/dist/lib/loader/schemas.js.map +1 -1
- package/dist/lib/middleware/isAdmin.js +5 -4
- package/dist/lib/middleware/isAdmin.js.map +1 -1
- package/dist/lib/middleware/isAuthenticated.js +7 -6
- package/dist/lib/middleware/isAuthenticated.js.map +1 -1
- package/dist/lib/middleware/postAuth.js +19 -0
- package/dist/lib/middleware/postAuth.js.map +1 -0
- package/dist/lib/middleware/preAuth.js +17 -0
- package/dist/lib/middleware/preAuth.js.map +1 -0
- package/dist/lib/util/generate.js +10 -0
- package/dist/lib/util/generate.js.map +1 -0
- package/dist/lib/util/regexp.js +13 -13
- package/dist/lib/util/regexp.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.ts +50 -2
- package/lib/api/auth/controller/auth.ts +118 -23
- package/lib/api/auth/routes.ts +107 -14
- package/lib/api/health/routes.ts +2 -2
- package/lib/api/users/routes.ts +12 -14
- package/lib/hooks/onRequest.ts +13 -19
- package/lib/loader/plugins.ts +0 -1
- package/lib/loader/router.ts +71 -34
- package/lib/loader/schemas.ts +7 -3
- package/lib/middleware/isAdmin.ts +3 -3
- package/lib/middleware/isAuthenticated.ts +5 -5
- package/lib/middleware/postAuth.ts +5 -0
- package/lib/middleware/preAuth.ts +3 -0
- package/lib/util/generate.ts +6 -0
- package/lib/util/regexp.ts +34 -32
- package/package.json +1 -1
- package/types/global.d.ts +15 -1
- package/dist/lib/api/auth/controller/password.js +0 -23
- package/dist/lib/api/auth/controller/password.js.map +0 -1
- package/dist/lib/middleware/example.js +0 -13
- package/dist/lib/middleware/example.js.map +0 -1
- package/lib/api/auth/controller/password.ts +0 -21
- package/lib/middleware/example.ts +0 -12
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newAuthCode = exports.valid = exports.compare = exports.hash = void 0;
|
|
4
|
-
const { customAlphabet } = require('nanoid');
|
|
5
|
-
const nanoid = customAlphabet('AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789');
|
|
6
|
-
const bcrypt = require('bcrypt');
|
|
7
|
-
function hash(password) {
|
|
8
|
-
return bcrypt.hashSync(password, bcrypt.genSaltSync());
|
|
9
|
-
}
|
|
10
|
-
exports.hash = hash;
|
|
11
|
-
function compare(password, encryptedPassword) {
|
|
12
|
-
return bcrypt.compareSync(password, encryptedPassword);
|
|
13
|
-
}
|
|
14
|
-
exports.compare = compare;
|
|
15
|
-
function valid(password) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
exports.valid = valid;
|
|
19
|
-
function newAuthCode() {
|
|
20
|
-
return nanoid(Number(process.env.AUTH_CODE_SIZE) || 10);
|
|
21
|
-
}
|
|
22
|
-
exports.newAuthCode = newAuthCode;
|
|
23
|
-
//# sourceMappingURL=password.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../../../../lib/api/auth/controller/password.ts"],"names":[],"mappings":";;;AAAA,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC5C,MAAM,MAAM,GAAG,cAAc,CAAC,gEAAgE,CAAC,CAAA;AAE/F,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAGhC,SAAgB,IAAI,CAAC,QAAgB;IACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;AACxD,CAAC;AAFD,oBAEC;AAED,SAAgB,OAAO,CAAC,QAAgB,EAAE,iBAAyB;IACjE,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAA;AACxD,CAAC;AAFD,0BAEC;AAED,SAAgB,KAAK,CAAC,QAAgB;IACpC,OAAO,IAAI,CAAA;AACb,CAAC;AAFD,sBAEC;AAED,SAAgB,WAAW;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAA;AACzD,CAAC;AAFD,kCAEC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const log = global.log;
|
|
4
|
-
module.exports = (req, res, next) => {
|
|
5
|
-
try {
|
|
6
|
-
return next();
|
|
7
|
-
}
|
|
8
|
-
catch (err) {
|
|
9
|
-
log.e && log.error(`Upps, something just happened ${err}`);
|
|
10
|
-
res.code(403).send(err);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../../lib/middleware/example.ts"],"names":[],"mappings":";;AAEA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;AACtB,MAAM,CAAC,OAAO,GAAG,CAAC,GAAmB,EAAE,GAAiB,EAAE,IAAS,EAAE,EAAE;IACrE,IAAI;QAEF,OAAO,IAAI,EAAE,CAAA;KACd;IAAC,OAAO,GAAG,EAAE;QACZ,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAA;QAC1D,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;KACxB;AACH,CAAC,CAAA"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { customAlphabet } = require('nanoid')
|
|
2
|
-
const nanoid = customAlphabet('AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789')
|
|
3
|
-
|
|
4
|
-
const bcrypt = require('bcrypt')
|
|
5
|
-
// const validator = require('../../../loader/validator')
|
|
6
|
-
|
|
7
|
-
export function hash(password: string): string {
|
|
8
|
-
return bcrypt.hashSync(password, bcrypt.genSaltSync())
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function compare(password: string, encryptedPassword: string): boolean {
|
|
12
|
-
return bcrypt.compareSync(password, encryptedPassword)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function valid(password: string): boolean {
|
|
16
|
-
return true //password?.length > 7 && validator.password(password)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function newAuthCode() {
|
|
20
|
-
return nanoid(Number(process.env.AUTH_CODE_SIZE) || 10)
|
|
21
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FastifyReply, FastifyRequest } from 'fastify'
|
|
2
|
-
|
|
3
|
-
const log = global.log
|
|
4
|
-
module.exports = (req: FastifyRequest, res: FastifyReply, next: any) => {
|
|
5
|
-
try {
|
|
6
|
-
// TODO: do something and then you can throw an exception or call next()..
|
|
7
|
-
return next()
|
|
8
|
-
} catch (err) {
|
|
9
|
-
log.e && log.error(`Upps, something just happened ${err}`)
|
|
10
|
-
res.code(403).send(err)
|
|
11
|
-
}
|
|
12
|
-
}
|