protonfile-auth 1.0.11 → 1.3.0
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/lib/Entities/TempToken.d.ts +5 -0
- package/lib/{entity/User.js → Entities/TempToken.js} +10 -15
- package/lib/controllers/change_password.d.ts +3 -0
- package/lib/controllers/change_password.js +58 -0
- package/lib/controllers/login.js +1 -53
- package/lib/controllers/logout.d.ts +1 -1
- package/lib/controllers/logout.js +7 -0
- package/lib/controllers/qr.d.ts +3 -0
- package/lib/controllers/qr.js +53 -0
- package/lib/controllers/register.js +3 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +11 -2
- package/lib/services/TempToken.d.ts +9 -0
- package/lib/services/TempToken.js +40 -0
- package/lib/services/auth.d.ts +7 -1
- package/lib/services/auth.js +62 -1
- package/lib/services/mail/index.d.ts +36 -0
- package/lib/services/mail/index.js +100 -0
- package/lib/services/mail/templates/default.d.ts +2 -0
- package/lib/services/mail/templates/default.js +268 -0
- package/lib/services/session.d.ts +1 -0
- package/lib/services/session.js +10 -1
- package/package.json +7 -2
- package/lib/db/index.js +0 -10
|
@@ -6,22 +6,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TempToken = void 0;
|
|
9
10
|
const typeorm_1 = require("typeorm");
|
|
10
|
-
let
|
|
11
|
+
let TempToken = class TempToken extends typeorm_1.BaseEntity {
|
|
11
12
|
};
|
|
12
13
|
__decorate([
|
|
13
|
-
typeorm_1.
|
|
14
|
-
],
|
|
14
|
+
(0, typeorm_1.PrimaryColumn)('text')
|
|
15
|
+
], TempToken.prototype, "token", void 0);
|
|
15
16
|
__decorate([
|
|
16
|
-
typeorm_1.Column()
|
|
17
|
-
],
|
|
18
|
-
__decorate([
|
|
19
|
-
typeorm_1.
|
|
20
|
-
],
|
|
21
|
-
|
|
22
|
-
typeorm_1.Column()
|
|
23
|
-
], User.prototype, "age", void 0);
|
|
24
|
-
User = __decorate([
|
|
25
|
-
typeorm_1.Entity()
|
|
26
|
-
], User);
|
|
27
|
-
exports.User = User;
|
|
17
|
+
(0, typeorm_1.Column)('bigint')
|
|
18
|
+
], TempToken.prototype, "expires", void 0);
|
|
19
|
+
TempToken = __decorate([
|
|
20
|
+
(0, typeorm_1.Entity)()
|
|
21
|
+
], TempToken);
|
|
22
|
+
exports.TempToken = TempToken;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
export declare const get: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
3
|
+
export declare const post: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.post = exports.get = void 0;
|
|
16
|
+
const User_1 = require("../Entities/User");
|
|
17
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
18
|
+
const mail_1 = require("../services/mail");
|
|
19
|
+
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
20
|
+
const Session_1 = require("../Entities/Session");
|
|
21
|
+
const TempToken_1 = require("../services/TempToken");
|
|
22
|
+
const get = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const user = yield User_1.User.findOne({ email: req.params.email });
|
|
24
|
+
if (!user) {
|
|
25
|
+
return res.sendStatus(404);
|
|
26
|
+
}
|
|
27
|
+
const token = jsonwebtoken_1.default.sign({ user_id: user.user_id }, process.env.CHANGE_PASSWORD_TOKEN_KEY, { expiresIn: '2h' });
|
|
28
|
+
const email = new mail_1.ChangePasswordMail(user, (process.env.PROTONFILE_AUTH_APP_URL || '') + '/change_password/' + token);
|
|
29
|
+
yield email.send();
|
|
30
|
+
res.sendStatus(200);
|
|
31
|
+
});
|
|
32
|
+
exports.get = get;
|
|
33
|
+
const post = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
try {
|
|
35
|
+
const token = jsonwebtoken_1.default.verify(req.body.token, process.env.CHANGE_PASSWORD_TOKEN_KEY);
|
|
36
|
+
if (typeof token === 'string') {
|
|
37
|
+
throw 'token malformed';
|
|
38
|
+
}
|
|
39
|
+
const temptoken = new TempToken_1.TempTokenService(req.body.token, token.exp || 0);
|
|
40
|
+
if (!(yield temptoken.isValid())) {
|
|
41
|
+
throw 'token expired';
|
|
42
|
+
}
|
|
43
|
+
const user = yield User_1.User.findOne({ user_id: token.user_id });
|
|
44
|
+
if (!user) {
|
|
45
|
+
return res.sendStatus(404);
|
|
46
|
+
}
|
|
47
|
+
User_1.User.update({ user_id: token.user_id }, { password: yield bcryptjs_1.default.hash(req.body.password, 10) });
|
|
48
|
+
if (req.body.revoke_all) {
|
|
49
|
+
yield Session_1.Session.delete({ user_id: user.user_id });
|
|
50
|
+
}
|
|
51
|
+
yield temptoken.invalidate();
|
|
52
|
+
res.sendStatus(200);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
res.sendStatus(500);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
exports.post = post;
|
package/lib/controllers/login.js
CHANGED
|
@@ -15,14 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
16
16
|
const auth_1 = require("../services/auth");
|
|
17
17
|
const User_1 = require("../Entities/User");
|
|
18
|
-
const Session_1 = require("../Entities/Session");
|
|
19
|
-
const session_1 = require("../services/session");
|
|
20
18
|
exports.default = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
19
|
try {
|
|
22
20
|
const { email, password } = req.body;
|
|
23
|
-
if (process.env.NODE_ENV === 'debug') {
|
|
24
|
-
console.debug(email, password, req.body);
|
|
25
|
-
}
|
|
26
21
|
if (!(email && password)) {
|
|
27
22
|
return res.status(400).send('All input is required');
|
|
28
23
|
}
|
|
@@ -32,56 +27,9 @@ exports.default = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
32
27
|
}
|
|
33
28
|
if (user && (yield bcryptjs_1.default.compare(password, user.password))) {
|
|
34
29
|
// Create token
|
|
35
|
-
const token = (0, auth_1.
|
|
36
|
-
(0, auth_1.setRefreshTokenCookie)(res, (0, auth_1.createRefreshToken)({
|
|
37
|
-
user_id: user.user_id,
|
|
38
|
-
}));
|
|
39
|
-
if (req.cookies.session_id) {
|
|
40
|
-
const session = JSON.parse(req.cookies.session_id);
|
|
41
|
-
try {
|
|
42
|
-
(0, session_1.verifySessionToken)(session.token);
|
|
43
|
-
const newSession = yield (0, session_1.bumpSessionToken)(session.session_id);
|
|
44
|
-
(0, session_1.setSessionCookie)(res, JSON.stringify(newSession));
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
yield (0, session_1.clearSessionCookie)(res);
|
|
48
|
-
yield (0, auth_1.clearRefreshTokenCookie)(res);
|
|
49
|
-
if (process.env.NODE_ENV === 'debug') {
|
|
50
|
-
console.debug(err);
|
|
51
|
-
}
|
|
52
|
-
const insert = yield Session_1.Session.insert({
|
|
53
|
-
token: (0, session_1.createSessionToken)({ user_id: user.user_id }),
|
|
54
|
-
user_id: user.user_id,
|
|
55
|
-
user_agent: req.headers['user-agent'] || 'Unknown',
|
|
56
|
-
});
|
|
57
|
-
const session = yield Session_1.Session.findOne({
|
|
58
|
-
session_id: insert.generatedMaps[0].session_id,
|
|
59
|
-
});
|
|
60
|
-
if (!session) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
(0, session_1.setSessionCookie)(res, JSON.stringify(session));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const insert = yield Session_1.Session.insert({
|
|
68
|
-
token: (0, session_1.createSessionToken)({ user_id: user.user_id }),
|
|
69
|
-
user_id: user.user_id,
|
|
70
|
-
user_agent: req.headers['user-agent'] || 'Unknown',
|
|
71
|
-
});
|
|
72
|
-
const session = yield Session_1.Session.findOne({
|
|
73
|
-
session_id: insert.generatedMaps[0].session_id,
|
|
74
|
-
});
|
|
75
|
-
if (!session) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
(0, session_1.setSessionCookie)(res, JSON.stringify(session));
|
|
79
|
-
}
|
|
30
|
+
const token = yield (0, auth_1.performLogin)(req, res, user);
|
|
80
31
|
return res.status(200).json(Object.assign(Object.assign({}, user), { token }));
|
|
81
32
|
}
|
|
82
|
-
if (process.env.NODE_ENV === 'debug') {
|
|
83
|
-
console.debug(user, yield bcryptjs_1.default.compare(password, user.password));
|
|
84
|
-
}
|
|
85
33
|
res.status(400).send('Invalid Credentials');
|
|
86
34
|
}
|
|
87
35
|
catch (err) {
|
|
@@ -14,5 +14,12 @@ const session_1 = require("../services/session");
|
|
|
14
14
|
exports.default = (_req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
yield (0, auth_1.clearRefreshTokenCookie)(res);
|
|
16
16
|
yield (0, session_1.clearSessionCookie)(res);
|
|
17
|
+
try {
|
|
18
|
+
const session_id = JSON.parse(_req.cookies.session_id).session_id;
|
|
19
|
+
yield (0, session_1.deleteSession)(session_id);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
return res.sendStatus(500);
|
|
23
|
+
}
|
|
17
24
|
res.sendStatus(200);
|
|
18
25
|
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
export declare const get: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
3
|
+
export declare const post: (req: Request, res: Response) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.post = exports.get = void 0;
|
|
16
|
+
const auth_1 = require("../services/auth");
|
|
17
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
18
|
+
const events_1 = __importDefault(require("events"));
|
|
19
|
+
const User_1 = require("../Entities/User");
|
|
20
|
+
const emitter = new events_1.default();
|
|
21
|
+
const get = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
if (!req.query.request_id) {
|
|
23
|
+
const request = yield (0, auth_1.generateQrAuth)();
|
|
24
|
+
return res.send(request);
|
|
25
|
+
}
|
|
26
|
+
const request_id = req.query.request_id;
|
|
27
|
+
if (typeof request_id !== 'string') {
|
|
28
|
+
return res.sendStatus(400);
|
|
29
|
+
}
|
|
30
|
+
emitter.on(request_id, (user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const token = yield (0, auth_1.performLogin)(req, res, user);
|
|
32
|
+
return res.status(200).json(Object.assign(Object.assign({}, user), { token }));
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
exports.get = get;
|
|
36
|
+
const post = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
try {
|
|
38
|
+
const token = jsonwebtoken_1.default.verify(req.body.qr_token, process.env.ACCESS_TOKEN_KEY);
|
|
39
|
+
if (typeof token === 'string') {
|
|
40
|
+
return res.sendStatus(500);
|
|
41
|
+
}
|
|
42
|
+
const user = yield User_1.User.findOne({ user_id: req.user.user_id });
|
|
43
|
+
if (!user) {
|
|
44
|
+
throw 'User not found';
|
|
45
|
+
}
|
|
46
|
+
emitter.emit(token.auth_id, user);
|
|
47
|
+
res.sendStatus(200);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
res.status(500).send(err);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
exports.post = post;
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
16
16
|
const auth_1 = require("../services/auth");
|
|
17
17
|
const User_1 = require("../Entities/User");
|
|
18
|
+
const mail_1 = require("../services/mail");
|
|
18
19
|
exports.default = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
20
|
try {
|
|
20
21
|
const { first_name, last_name, email, password } = req.body;
|
|
@@ -37,6 +38,8 @@ exports.default = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
const token = (0, auth_1.createAccessToken)({ user_id: user.user_id });
|
|
41
|
+
const mail = new mail_1.WelcomeMail(user);
|
|
42
|
+
mail.send();
|
|
40
43
|
res.status(201).json(Object.assign(Object.assign({}, user), { token }));
|
|
41
44
|
}
|
|
42
45
|
catch (err) {
|
package/lib/index.d.ts
CHANGED
|
@@ -4,12 +4,18 @@ import express from 'express';
|
|
|
4
4
|
import { ConnectionOptions } from 'typeorm';
|
|
5
5
|
import { User } from './Entities/User';
|
|
6
6
|
import { Session } from './Entities/Session';
|
|
7
|
+
import { TempToken } from './Entities/TempToken';
|
|
8
|
+
import { TempTokenService } from './services/TempToken';
|
|
7
9
|
declare const _default: {
|
|
8
10
|
router: (typeormConfig: ConnectionOptions) => import("express-serve-static-core").Router;
|
|
9
11
|
authMiddleware: (req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>, next: express.NextFunction) => Promise<void | express.Response<any, Record<string, any>>>;
|
|
10
12
|
entities: {
|
|
11
13
|
User: typeof User;
|
|
12
14
|
Session: typeof Session;
|
|
15
|
+
TempToken: typeof TempToken;
|
|
16
|
+
};
|
|
17
|
+
services: {
|
|
18
|
+
TempTokenService: typeof TempTokenService;
|
|
13
19
|
};
|
|
14
20
|
};
|
|
15
21
|
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -11,21 +11,30 @@ const login_1 = __importDefault(require("./controllers/login"));
|
|
|
11
11
|
const verifyToken_1 = __importDefault(require("./middlewares/verifyToken"));
|
|
12
12
|
const refresh_token_1 = __importDefault(require("./controllers/refresh_token"));
|
|
13
13
|
const logout_1 = __importDefault(require("./controllers/logout"));
|
|
14
|
+
const qr_1 = require("./controllers/qr");
|
|
15
|
+
const change_password_1 = require("./controllers/change_password");
|
|
14
16
|
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
15
17
|
const typeorm_1 = require("typeorm");
|
|
16
18
|
const User_1 = require("./Entities/User");
|
|
17
19
|
const Session_1 = require("./Entities/Session");
|
|
20
|
+
const TempToken_1 = require("./Entities/TempToken");
|
|
21
|
+
const TempToken_2 = require("./services/TempToken");
|
|
18
22
|
exports.default = {
|
|
19
23
|
router: (typeormConfig) => {
|
|
20
|
-
(0, typeorm_1.createConnection)(Object.assign(Object.assign({}, typeormConfig), { entities: [User_1.User, Session_1.Session] }));
|
|
24
|
+
(0, typeorm_1.createConnection)(Object.assign(Object.assign({}, typeormConfig), { entities: [User_1.User, Session_1.Session, TempToken_1.TempToken] }));
|
|
21
25
|
const router = express_1.default.Router();
|
|
22
26
|
router.use(body_parser_1.default.urlencoded({ extended: false }));
|
|
23
27
|
router.post('/register', register_1.default);
|
|
24
28
|
router.post('/login', (0, cookie_parser_1.default)(), login_1.default);
|
|
25
29
|
router.post('/refresh_token', (0, cookie_parser_1.default)(), refresh_token_1.default);
|
|
26
30
|
router.post('/logout', (0, cookie_parser_1.default)(), logout_1.default);
|
|
31
|
+
router.get('/qr', (0, cookie_parser_1.default)(), qr_1.get);
|
|
32
|
+
router.post('/qr', verifyToken_1.default, qr_1.post);
|
|
33
|
+
router.get('/change_password/:email', change_password_1.get);
|
|
34
|
+
router.post('/change_password', change_password_1.post);
|
|
27
35
|
return router;
|
|
28
36
|
},
|
|
29
37
|
authMiddleware: verifyToken_1.default,
|
|
30
|
-
entities: { User: User_1.User, Session: Session_1.Session },
|
|
38
|
+
entities: { User: User_1.User, Session: Session_1.Session, TempToken: TempToken_1.TempToken },
|
|
39
|
+
services: { TempTokenService: TempToken_2.TempTokenService },
|
|
31
40
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TempToken } from '../Entities/TempToken';
|
|
2
|
+
export declare class TempTokenService {
|
|
3
|
+
token: string;
|
|
4
|
+
expires: number;
|
|
5
|
+
private tempToken;
|
|
6
|
+
constructor(token: string, expires: number);
|
|
7
|
+
invalidate(): Promise<TempToken>;
|
|
8
|
+
isValid(): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TempTokenService = void 0;
|
|
13
|
+
const TempToken_1 = require("../Entities/TempToken");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
class TempTokenService {
|
|
16
|
+
constructor(token, expires) {
|
|
17
|
+
this.token = token;
|
|
18
|
+
this.expires = expires;
|
|
19
|
+
this.tempToken = new TempToken_1.TempToken();
|
|
20
|
+
this.tempToken.token = this.token;
|
|
21
|
+
this.tempToken.expires = this.expires;
|
|
22
|
+
setInterval(() => {
|
|
23
|
+
const timestamp = +new Date();
|
|
24
|
+
TempToken_1.TempToken.delete({ expires: (0, typeorm_1.LessThan)(timestamp) });
|
|
25
|
+
}, 600 * 1000);
|
|
26
|
+
}
|
|
27
|
+
invalidate() {
|
|
28
|
+
return this.tempToken.save();
|
|
29
|
+
}
|
|
30
|
+
isValid() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const found = yield TempToken_1.TempToken.findOne({ token: this.token });
|
|
33
|
+
if (found) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.TempTokenService = TempTokenService;
|
package/lib/services/auth.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { Response } from 'express';
|
|
1
|
+
import { Response, Request } from 'express';
|
|
2
|
+
import { User } from '../Entities/User';
|
|
2
3
|
export declare const createAccessToken: (payload: any) => string;
|
|
3
4
|
export declare const createRefreshToken: (payload: any) => string;
|
|
4
5
|
export declare const setRefreshTokenCookie: (res: Response, value: string) => Promise<void>;
|
|
5
6
|
export declare const clearRefreshTokenCookie: (res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
7
|
+
export declare const generateQrAuth: () => Promise<{
|
|
8
|
+
request_id: string;
|
|
9
|
+
token: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const performLogin: (req: Request, res: Response, user: User) => Promise<string>;
|
package/lib/services/auth.js
CHANGED
|
@@ -9,8 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.clearRefreshTokenCookie = exports.setRefreshTokenCookie = exports.createRefreshToken = exports.createAccessToken = void 0;
|
|
12
|
+
exports.performLogin = exports.generateQrAuth = exports.clearRefreshTokenCookie = exports.setRefreshTokenCookie = exports.createRefreshToken = exports.createAccessToken = void 0;
|
|
13
13
|
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
15
|
+
const Session_1 = require("../Entities/Session");
|
|
16
|
+
const session_1 = require("./session");
|
|
14
17
|
const createAccessToken = (payload) => {
|
|
15
18
|
return (0, jsonwebtoken_1.sign)({ user_id: payload.user_id }, process.env.ACCESS_TOKEN_KEY, {
|
|
16
19
|
expiresIn: '15m',
|
|
@@ -38,3 +41,61 @@ const clearRefreshTokenCookie = (res) => __awaiter(void 0, void 0, void 0, funct
|
|
|
38
41
|
return res.clearCookie('jid');
|
|
39
42
|
});
|
|
40
43
|
exports.clearRefreshTokenCookie = clearRefreshTokenCookie;
|
|
44
|
+
const generateQrAuth = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const id = (0, uuid_1.v4)();
|
|
46
|
+
return {
|
|
47
|
+
request_id: id,
|
|
48
|
+
token: (0, jsonwebtoken_1.sign)({ auth_id: id }, process.env.ACCESS_TOKEN_KEY, {
|
|
49
|
+
expiresIn: '5m',
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
exports.generateQrAuth = generateQrAuth;
|
|
54
|
+
const performLogin = (req, res, user) => {
|
|
55
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const token = (0, exports.createAccessToken)({ user_id: user.user_id });
|
|
57
|
+
(0, exports.setRefreshTokenCookie)(res, (0, exports.createRefreshToken)({
|
|
58
|
+
user_id: user.user_id,
|
|
59
|
+
}));
|
|
60
|
+
if (req.cookies.session_id) {
|
|
61
|
+
const session = JSON.parse(req.cookies.session_id);
|
|
62
|
+
try {
|
|
63
|
+
(0, session_1.verifySessionToken)(session.token);
|
|
64
|
+
const newSession = yield (0, session_1.bumpSessionToken)(session.session_id);
|
|
65
|
+
(0, session_1.setSessionCookie)(res, JSON.stringify(newSession));
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
yield (0, session_1.clearSessionCookie)(res);
|
|
69
|
+
yield (0, exports.clearRefreshTokenCookie)(res);
|
|
70
|
+
const insert = yield Session_1.Session.insert({
|
|
71
|
+
token: (0, session_1.createSessionToken)({ user_id: user.user_id }),
|
|
72
|
+
user_id: user.user_id,
|
|
73
|
+
user_agent: req.headers['user-agent'] || 'Unknown',
|
|
74
|
+
});
|
|
75
|
+
const session = yield Session_1.Session.findOne({
|
|
76
|
+
session_id: insert.generatedMaps[0].session_id,
|
|
77
|
+
});
|
|
78
|
+
if (!session) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
(0, session_1.setSessionCookie)(res, JSON.stringify(session));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const insert = yield Session_1.Session.insert({
|
|
86
|
+
token: (0, session_1.createSessionToken)({ user_id: user.user_id }),
|
|
87
|
+
user_id: user.user_id,
|
|
88
|
+
user_agent: req.headers['user-agent'] || 'Unknown',
|
|
89
|
+
});
|
|
90
|
+
const session = yield Session_1.Session.findOne({
|
|
91
|
+
session_id: insert.generatedMaps[0].session_id,
|
|
92
|
+
});
|
|
93
|
+
if (!session) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
(0, session_1.setSessionCookie)(res, JSON.stringify(session));
|
|
97
|
+
}
|
|
98
|
+
resolve(token);
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
exports.performLogin = performLogin;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { User } from '../../Entities/User';
|
|
2
|
+
interface mailOptions {
|
|
3
|
+
subject: string;
|
|
4
|
+
html: string;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
interface smtpConfig {
|
|
8
|
+
host: string;
|
|
9
|
+
auth: {
|
|
10
|
+
user: string;
|
|
11
|
+
pass: string;
|
|
12
|
+
};
|
|
13
|
+
dkim: {
|
|
14
|
+
domainName: string;
|
|
15
|
+
keySelector: string;
|
|
16
|
+
privateKey: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare class BaseMail {
|
|
20
|
+
poolConfig: object;
|
|
21
|
+
user: User;
|
|
22
|
+
mailOptions: mailOptions;
|
|
23
|
+
smtpConfig: smtpConfig;
|
|
24
|
+
constructor(user: User, mailOptions: mailOptions);
|
|
25
|
+
send(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare class NewAccessMail extends BaseMail {
|
|
28
|
+
constructor(user: User, location: string);
|
|
29
|
+
}
|
|
30
|
+
export declare class WelcomeMail extends BaseMail {
|
|
31
|
+
constructor(user: User);
|
|
32
|
+
}
|
|
33
|
+
export declare class ChangePasswordMail extends BaseMail {
|
|
34
|
+
constructor(user: User, link: string);
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ChangePasswordMail = exports.WelcomeMail = exports.NewAccessMail = void 0;
|
|
16
|
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
17
|
+
const default_1 = __importDefault(require("./templates/default"));
|
|
18
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
19
|
+
class BaseMail {
|
|
20
|
+
constructor(user, mailOptions) {
|
|
21
|
+
this.user = user;
|
|
22
|
+
this.mailOptions = mailOptions;
|
|
23
|
+
this.smtpConfig = JSON.parse(process.env.PROTONFILE_AUTH_SMTP_CONFIG || '');
|
|
24
|
+
this.poolConfig = {
|
|
25
|
+
pool: true,
|
|
26
|
+
host: this.smtpConfig.host,
|
|
27
|
+
secure: true,
|
|
28
|
+
auth: this.smtpConfig.auth,
|
|
29
|
+
tls: {
|
|
30
|
+
rejectUnauthorized: false,
|
|
31
|
+
},
|
|
32
|
+
dkim: Object.assign(Object.assign({}, this.smtpConfig.dkim), { cacheDir: '/tmp', cacheTreshold: 100 * 1024 }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
send() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const transporter = nodemailer_1.default.createTransport(this.poolConfig);
|
|
38
|
+
transporter.sendMail({
|
|
39
|
+
from: this.smtpConfig.auth.user,
|
|
40
|
+
to: this.user.email,
|
|
41
|
+
subject: this.mailOptions.subject,
|
|
42
|
+
html: this.mailOptions.html,
|
|
43
|
+
text: this.mailOptions.text,
|
|
44
|
+
}, (err, responseStatus) => {
|
|
45
|
+
if (err) {
|
|
46
|
+
return console.error(err);
|
|
47
|
+
}
|
|
48
|
+
transporter.close();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class NewAccessMail extends BaseMail {
|
|
54
|
+
constructor(user, location) {
|
|
55
|
+
const _template = handlebars_1.default.compile(default_1.default);
|
|
56
|
+
const mailBody = _template({
|
|
57
|
+
email: user.email,
|
|
58
|
+
body: `A new access to your account was detected from: ${location}`,
|
|
59
|
+
});
|
|
60
|
+
const mailOptions = {
|
|
61
|
+
subject: 'New access to your account',
|
|
62
|
+
html: mailBody,
|
|
63
|
+
text: mailBody,
|
|
64
|
+
};
|
|
65
|
+
super(user, mailOptions);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.NewAccessMail = NewAccessMail;
|
|
69
|
+
class WelcomeMail extends BaseMail {
|
|
70
|
+
constructor(user) {
|
|
71
|
+
const _template = handlebars_1.default.compile(default_1.default);
|
|
72
|
+
const mailBody = _template({
|
|
73
|
+
email: user.email,
|
|
74
|
+
body: 'Welcome to Protonfile, we hope you enjoy using our service',
|
|
75
|
+
});
|
|
76
|
+
const mailOptions = {
|
|
77
|
+
subject: 'Welcome to Protonfile',
|
|
78
|
+
html: mailBody,
|
|
79
|
+
text: mailBody,
|
|
80
|
+
};
|
|
81
|
+
super(user, mailOptions);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.WelcomeMail = WelcomeMail;
|
|
85
|
+
class ChangePasswordMail extends BaseMail {
|
|
86
|
+
constructor(user, link) {
|
|
87
|
+
const _template = handlebars_1.default.compile(default_1.default);
|
|
88
|
+
const mailBody = _template({
|
|
89
|
+
email: user.email,
|
|
90
|
+
body: `You just asked for a password reset, here is the link: ${link}<br>If this wasn't you, just ignore this email`,
|
|
91
|
+
});
|
|
92
|
+
const mailOptions = {
|
|
93
|
+
subject: 'Password Reset',
|
|
94
|
+
html: mailBody,
|
|
95
|
+
text: mailBody,
|
|
96
|
+
};
|
|
97
|
+
super(user, mailOptions);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.ChangePasswordMail = ChangePasswordMail;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional //EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">\n<head>\n<!--[if gte mso 9]>\n<xml>\n <o:OfficeDocumentSettings>\n <o:AllowPNG/>\n <o:PixelsPerInch>96</o:PixelsPerInch>\n </o:OfficeDocumentSettings>\n</xml>\n<![endif]-->\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta name=\"x-apple-disable-message-reformatting\">\n <!--[if !mso]><!--><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><!--<![endif]-->\n <title></title>\n \n <style type=\"text/css\">\n table, td { color: #000000; } a { color: #0000ee; text-decoration: underline; }\n@media only screen and (min-width: 520px) {\n .u-row {\n width: 500px !important;\n }\n .u-row .u-col {\n vertical-align: top;\n }\n\n .u-row .u-col-100 {\n width: 500px !important;\n }\n\n}\n\n@media (max-width: 520px) {\n .u-row-container {\n max-width: 100% !important;\n padding-left: 0px !important;\n padding-right: 0px !important;\n }\n .u-row .u-col {\n min-width: 320px !important;\n max-width: 100% !important;\n display: block !important;\n }\n .u-row {\n width: calc(100% - 40px) !important;\n }\n .u-col {\n width: 100% !important;\n }\n .u-col > div {\n margin: 0 auto;\n }\n}\nbody {\n margin: 0;\n padding: 0;\n}\n\ntable,\ntr,\ntd {\n vertical-align: top;\n border-collapse: collapse;\n}\n\np {\n margin: 0;\n}\n\n.ie-container table,\n.mso-container table {\n table-layout: fixed;\n}\n\n* {\n line-height: inherit;\n}\n\na[x-apple-data-detectors='true'] {\n color: inherit !important;\n text-decoration: none !important;\n}\n\n</style>\n \n \n\n</head>\n\n<body class=\"clean-body u_body\" style=\"margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #ffffff;color: #000000\">\n <!--[if IE]><div class=\"ie-container\"><![endif]-->\n <!--[if mso]><div class=\"mso-container\"><![endif]-->\n <table style=\"border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #ffffff;width:100%\" cellpadding=\"0\" cellspacing=\"0\">\n <tbody>\n <tr style=\"vertical-align: top\">\n <td style=\"word-break: break-word;border-collapse: collapse !important;vertical-align: top\">\n <!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"center\" style=\"background-color: #ffffff;\"><![endif]-->\n \n\n<div class=\"u-row-container\" style=\"padding: 0px;background-color: transparent\">\n <div class=\"u-row\" style=\"Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;\">\n <div style=\"border-collapse: collapse;display: table;width: 100%;background-color: transparent;\">\n <!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding: 0px;background-color: transparent;\" align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:500px;\"><tr style=\"background-color: transparent;\"><![endif]-->\n \n<!--[if (mso)|(IE)]><td align=\"center\" width=\"500\" style=\"width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;\" valign=\"top\"><![endif]-->\n<div class=\"u-col u-col-100\" style=\"max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;\">\n <div style=\"width: 100% !important;\">\n <!--[if (!mso)&(!IE)]><!--><div style=\"padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;\"><!--<![endif]-->\n \n<table style=\"font-family:arial,helvetica,sans-serif;\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">\n <tbody>\n <tr>\n <td style=\"overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;\" align=\"left\">\n \n<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tr>\n <td style=\"padding-right: 0px;padding-left: 0px;\" align=\"left\">\n \n <img align=\"left\" border=\"0\" src=\"https://www.jz-software.com/archive/protonfile-logo.png\" alt=\"\" title=\"\" style=\"outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 100px;\" width=\"100\"/>\n \n </td>\n </tr>\n</table>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n <!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->\n </div>\n</div>\n<!--[if (mso)|(IE)]></td><![endif]-->\n <!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->\n </div>\n </div>\n</div>\n\n\n\n<div class=\"u-row-container\" style=\"padding: 0px;background-color: transparent\">\n <div class=\"u-row\" style=\"Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;\">\n <div style=\"border-collapse: collapse;display: table;width: 100%;background-color: transparent;\">\n <!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding: 0px;background-color: transparent;\" align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:500px;\"><tr style=\"background-color: transparent;\"><![endif]-->\n \n<!--[if (mso)|(IE)]><td align=\"center\" width=\"500\" style=\"width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;\" valign=\"top\"><![endif]-->\n<div class=\"u-col u-col-100\" style=\"max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;\">\n <div style=\"width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;\">\n <!--[if (!mso)&(!IE)]><!--><div style=\"padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;\"><!--<![endif]-->\n \n<table style=\"font-family:arial,helvetica,sans-serif;\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">\n <tbody>\n <tr>\n <td style=\"overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;\" align=\"left\">\n \n <table height=\"0px\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;border-top: 1px solid #BBBBBB;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%\">\n <tbody>\n <tr style=\"vertical-align: top\">\n <td style=\"word-break: break-word;border-collapse: collapse !important;vertical-align: top;font-size: 0px;line-height: 0px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%\">\n <span> </span>\n </td>\n </tr>\n </tbody>\n </table>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n <!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->\n </div>\n</div>\n<!--[if (mso)|(IE)]></td><![endif]-->\n <!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->\n </div>\n </div>\n</div>\n\n\n\n<div class=\"u-row-container\" style=\"padding: 0px;background-color: transparent\">\n <div class=\"u-row\" style=\"Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;\">\n <div style=\"border-collapse: collapse;display: table;width: 100%;background-color: transparent;\">\n <!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding: 0px;background-color: transparent;\" align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:500px;\"><tr style=\"background-color: transparent;\"><![endif]-->\n \n<!--[if (mso)|(IE)]><td align=\"center\" width=\"500\" style=\"width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;\" valign=\"top\"><![endif]-->\n<div class=\"u-col u-col-100\" style=\"max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;\">\n <div style=\"width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;\">\n <!--[if (!mso)&(!IE)]><!--><div style=\"padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;\"><!--<![endif]-->\n \n<table style=\"font-family:arial,helvetica,sans-serif;\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">\n <tbody>\n <tr>\n <td style=\"overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;\" align=\"left\">\n \n <div style=\"line-height: 140%; text-align: left; word-wrap: break-word;\">\n <p style=\"font-size: 14px; line-height: 140%;\">Dear <a rel=\"noopener\" href=\"mailto:{{email}}\" target=\"_blank\">{{email}}</a>,</p>\n<p style=\"font-size: 14px; line-height: 140%;\"> </p>\n<p style=\"font-size: 14px; line-height: 140%;\">{{body}}</p>\n<p style=\"font-size: 14px; line-height: 140%;\"> </p>\n<p style=\"font-size: 14px; line-height: 140%;\">For any questions email us at info@jz-software.com</p>\n </div>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n<table style=\"font-family:arial,helvetica,sans-serif;\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">\n <tbody>\n <tr>\n <td style=\"overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;\" align=\"left\">\n \n <table height=\"0px\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;border-top: 1px solid #BBBBBB;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%\">\n <tbody>\n <tr style=\"vertical-align: top\">\n <td style=\"word-break: break-word;border-collapse: collapse !important;vertical-align: top;font-size: 0px;line-height: 0px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%\">\n <span> </span>\n </td>\n </tr>\n </tbody>\n </table>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n<table style=\"font-family:arial,helvetica,sans-serif;\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">\n <tbody>\n <tr>\n <td style=\"overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;\" align=\"left\">\n \n <div style=\"line-height: 140%; text-align: left; word-wrap: break-word;\">\n <p style=\"font-size: 14px; line-height: 140%;\">JZ-Software</p>\n </div>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n <!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->\n </div>\n</div>\n<!--[if (mso)|(IE)]></td><![endif]-->\n <!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->\n </div>\n </div>\n</div>\n\n\n <!--[if (mso)|(IE)]></td></tr></table><![endif]-->\n </td>\n </tr>\n </tbody>\n </table>\n <!--[if mso]></div><![endif]-->\n <!--[if IE]></div><![endif]-->\n</body>\n\n</html>\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = `
|
|
4
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
|
6
|
+
<head>
|
|
7
|
+
<!--[if gte mso 9]>
|
|
8
|
+
<xml>
|
|
9
|
+
<o:OfficeDocumentSettings>
|
|
10
|
+
<o:AllowPNG/>
|
|
11
|
+
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
12
|
+
</o:OfficeDocumentSettings>
|
|
13
|
+
</xml>
|
|
14
|
+
<![endif]-->
|
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
16
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
17
|
+
<meta name="x-apple-disable-message-reformatting">
|
|
18
|
+
<!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]-->
|
|
19
|
+
<title></title>
|
|
20
|
+
|
|
21
|
+
<style type="text/css">
|
|
22
|
+
table, td { color: #000000; } a { color: #0000ee; text-decoration: underline; }
|
|
23
|
+
@media only screen and (min-width: 520px) {
|
|
24
|
+
.u-row {
|
|
25
|
+
width: 500px !important;
|
|
26
|
+
}
|
|
27
|
+
.u-row .u-col {
|
|
28
|
+
vertical-align: top;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.u-row .u-col-100 {
|
|
32
|
+
width: 500px !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@media (max-width: 520px) {
|
|
38
|
+
.u-row-container {
|
|
39
|
+
max-width: 100% !important;
|
|
40
|
+
padding-left: 0px !important;
|
|
41
|
+
padding-right: 0px !important;
|
|
42
|
+
}
|
|
43
|
+
.u-row .u-col {
|
|
44
|
+
min-width: 320px !important;
|
|
45
|
+
max-width: 100% !important;
|
|
46
|
+
display: block !important;
|
|
47
|
+
}
|
|
48
|
+
.u-row {
|
|
49
|
+
width: calc(100% - 40px) !important;
|
|
50
|
+
}
|
|
51
|
+
.u-col {
|
|
52
|
+
width: 100% !important;
|
|
53
|
+
}
|
|
54
|
+
.u-col > div {
|
|
55
|
+
margin: 0 auto;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
body {
|
|
59
|
+
margin: 0;
|
|
60
|
+
padding: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
table,
|
|
64
|
+
tr,
|
|
65
|
+
td {
|
|
66
|
+
vertical-align: top;
|
|
67
|
+
border-collapse: collapse;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
p {
|
|
71
|
+
margin: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ie-container table,
|
|
75
|
+
.mso-container table {
|
|
76
|
+
table-layout: fixed;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
* {
|
|
80
|
+
line-height: inherit;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
a[x-apple-data-detectors='true'] {
|
|
84
|
+
color: inherit !important;
|
|
85
|
+
text-decoration: none !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
</style>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
</head>
|
|
93
|
+
|
|
94
|
+
<body class="clean-body u_body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #ffffff;color: #000000">
|
|
95
|
+
<!--[if IE]><div class="ie-container"><![endif]-->
|
|
96
|
+
<!--[if mso]><div class="mso-container"><![endif]-->
|
|
97
|
+
<table style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #ffffff;width:100%" cellpadding="0" cellspacing="0">
|
|
98
|
+
<tbody>
|
|
99
|
+
<tr style="vertical-align: top">
|
|
100
|
+
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top">
|
|
101
|
+
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #ffffff;"><![endif]-->
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
<div class="u-row-container" style="padding: 0px;background-color: transparent">
|
|
105
|
+
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
|
|
106
|
+
<div style="border-collapse: collapse;display: table;width: 100%;background-color: transparent;">
|
|
107
|
+
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: transparent;"><![endif]-->
|
|
108
|
+
|
|
109
|
+
<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;" valign="top"><![endif]-->
|
|
110
|
+
<div class="u-col u-col-100" style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
|
|
111
|
+
<div style="width: 100% !important;">
|
|
112
|
+
<!--[if (!mso)&(!IE)]><!--><div style="padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;"><!--<![endif]-->
|
|
113
|
+
|
|
114
|
+
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
|
|
115
|
+
<tbody>
|
|
116
|
+
<tr>
|
|
117
|
+
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
|
|
118
|
+
|
|
119
|
+
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
120
|
+
<tr>
|
|
121
|
+
<td style="padding-right: 0px;padding-left: 0px;" align="left">
|
|
122
|
+
|
|
123
|
+
<img align="left" border="0" src="https://www.jz-software.com/archive/protonfile-logo.png" alt="" title="" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 100px;" width="100"/>
|
|
124
|
+
|
|
125
|
+
</td>
|
|
126
|
+
</tr>
|
|
127
|
+
</table>
|
|
128
|
+
|
|
129
|
+
</td>
|
|
130
|
+
</tr>
|
|
131
|
+
</tbody>
|
|
132
|
+
</table>
|
|
133
|
+
|
|
134
|
+
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
<!--[if (mso)|(IE)]></td><![endif]-->
|
|
138
|
+
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<div class="u-row-container" style="padding: 0px;background-color: transparent">
|
|
146
|
+
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
|
|
147
|
+
<div style="border-collapse: collapse;display: table;width: 100%;background-color: transparent;">
|
|
148
|
+
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: transparent;"><![endif]-->
|
|
149
|
+
|
|
150
|
+
<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;" valign="top"><![endif]-->
|
|
151
|
+
<div class="u-col u-col-100" style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
|
|
152
|
+
<div style="width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;">
|
|
153
|
+
<!--[if (!mso)&(!IE)]><!--><div style="padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;"><!--<![endif]-->
|
|
154
|
+
|
|
155
|
+
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
|
|
156
|
+
<tbody>
|
|
157
|
+
<tr>
|
|
158
|
+
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
|
|
159
|
+
|
|
160
|
+
<table height="0px" align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;border-top: 1px solid #BBBBBB;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
|
|
161
|
+
<tbody>
|
|
162
|
+
<tr style="vertical-align: top">
|
|
163
|
+
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top;font-size: 0px;line-height: 0px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
|
|
164
|
+
<span> </span>
|
|
165
|
+
</td>
|
|
166
|
+
</tr>
|
|
167
|
+
</tbody>
|
|
168
|
+
</table>
|
|
169
|
+
|
|
170
|
+
</td>
|
|
171
|
+
</tr>
|
|
172
|
+
</tbody>
|
|
173
|
+
</table>
|
|
174
|
+
|
|
175
|
+
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
<!--[if (mso)|(IE)]></td><![endif]-->
|
|
179
|
+
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<div class="u-row-container" style="padding: 0px;background-color: transparent">
|
|
187
|
+
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
|
|
188
|
+
<div style="border-collapse: collapse;display: table;width: 100%;background-color: transparent;">
|
|
189
|
+
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: transparent;"><![endif]-->
|
|
190
|
+
|
|
191
|
+
<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;" valign="top"><![endif]-->
|
|
192
|
+
<div class="u-col u-col-100" style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
|
|
193
|
+
<div style="width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;">
|
|
194
|
+
<!--[if (!mso)&(!IE)]><!--><div style="padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;"><!--<![endif]-->
|
|
195
|
+
|
|
196
|
+
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
|
|
197
|
+
<tbody>
|
|
198
|
+
<tr>
|
|
199
|
+
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
|
|
200
|
+
|
|
201
|
+
<div style="line-height: 140%; text-align: left; word-wrap: break-word;">
|
|
202
|
+
<p style="font-size: 14px; line-height: 140%;">Dear <a rel="noopener" href="mailto:{{email}}" target="_blank">{{email}}</a>,</p>
|
|
203
|
+
<p style="font-size: 14px; line-height: 140%;"> </p>
|
|
204
|
+
<p style="font-size: 14px; line-height: 140%;">{{body}}</p>
|
|
205
|
+
<p style="font-size: 14px; line-height: 140%;"> </p>
|
|
206
|
+
<p style="font-size: 14px; line-height: 140%;">For any questions email us at info@jz-software.com</p>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
</td>
|
|
210
|
+
</tr>
|
|
211
|
+
</tbody>
|
|
212
|
+
</table>
|
|
213
|
+
|
|
214
|
+
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
|
|
215
|
+
<tbody>
|
|
216
|
+
<tr>
|
|
217
|
+
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
|
|
218
|
+
|
|
219
|
+
<table height="0px" align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;border-top: 1px solid #BBBBBB;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
|
|
220
|
+
<tbody>
|
|
221
|
+
<tr style="vertical-align: top">
|
|
222
|
+
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top;font-size: 0px;line-height: 0px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
|
|
223
|
+
<span> </span>
|
|
224
|
+
</td>
|
|
225
|
+
</tr>
|
|
226
|
+
</tbody>
|
|
227
|
+
</table>
|
|
228
|
+
|
|
229
|
+
</td>
|
|
230
|
+
</tr>
|
|
231
|
+
</tbody>
|
|
232
|
+
</table>
|
|
233
|
+
|
|
234
|
+
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
|
|
235
|
+
<tbody>
|
|
236
|
+
<tr>
|
|
237
|
+
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
|
|
238
|
+
|
|
239
|
+
<div style="line-height: 140%; text-align: left; word-wrap: break-word;">
|
|
240
|
+
<p style="font-size: 14px; line-height: 140%;">JZ-Software</p>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
</td>
|
|
244
|
+
</tr>
|
|
245
|
+
</tbody>
|
|
246
|
+
</table>
|
|
247
|
+
|
|
248
|
+
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
<!--[if (mso)|(IE)]></td><![endif]-->
|
|
252
|
+
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
|
|
259
|
+
</td>
|
|
260
|
+
</tr>
|
|
261
|
+
</tbody>
|
|
262
|
+
</table>
|
|
263
|
+
<!--[if mso]></div><![endif]-->
|
|
264
|
+
<!--[if IE]></div><![endif]-->
|
|
265
|
+
</body>
|
|
266
|
+
|
|
267
|
+
</html>
|
|
268
|
+
`;
|
|
@@ -6,3 +6,4 @@ export declare const bumpSessionToken: (session_id: string) => Promise<Session>;
|
|
|
6
6
|
export declare const compareSessionTokenVersion: (session_id: string, token: string) => Promise<import("jsonwebtoken").JwtPayload>;
|
|
7
7
|
export declare const setSessionCookie: (res: Response, value: string) => Promise<void>;
|
|
8
8
|
export declare const clearSessionCookie: (res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
9
|
+
export declare const deleteSession: (session_id: string) => Promise<Session>;
|
package/lib/services/session.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.clearSessionCookie = exports.setSessionCookie = exports.compareSessionTokenVersion = exports.bumpSessionToken = exports.verifySessionToken = exports.createSessionToken = void 0;
|
|
12
|
+
exports.deleteSession = exports.clearSessionCookie = exports.setSessionCookie = exports.compareSessionTokenVersion = exports.bumpSessionToken = exports.verifySessionToken = exports.createSessionToken = void 0;
|
|
13
13
|
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
14
14
|
const Session_1 = require("../Entities/Session");
|
|
15
15
|
const createSessionToken = (payload, version) => {
|
|
@@ -80,3 +80,12 @@ const clearSessionCookie = (res) => __awaiter(void 0, void 0, void 0, function*
|
|
|
80
80
|
return res.clearCookie('session_id');
|
|
81
81
|
});
|
|
82
82
|
exports.clearSessionCookie = clearSessionCookie;
|
|
83
|
+
const deleteSession = (session_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const session = yield Session_1.Session.findOne({ session_id });
|
|
85
|
+
if (!session) {
|
|
86
|
+
throw 'Session not found';
|
|
87
|
+
}
|
|
88
|
+
session.remove();
|
|
89
|
+
return session;
|
|
90
|
+
});
|
|
91
|
+
exports.deleteSession = deleteSession;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "protonfile-auth",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "protonfile-auth",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
"@types/bcryptjs": "^2.4.2",
|
|
17
17
|
"@types/express": "^4.17.13",
|
|
18
18
|
"@types/jsonwebtoken": "^8.5.5",
|
|
19
|
+
"@types/nodemailer": "^6.4.4",
|
|
19
20
|
"@types/pg": "^8.6.1",
|
|
21
|
+
"@types/uuid": "^8.3.1",
|
|
20
22
|
"typescript": "^4.4.4"
|
|
21
23
|
},
|
|
22
24
|
"files": [
|
|
@@ -30,8 +32,11 @@
|
|
|
30
32
|
"cors": "^2.8.5",
|
|
31
33
|
"dotenv": "^10.0.0",
|
|
32
34
|
"express": "^4.17.1",
|
|
35
|
+
"handlebars": "^4.7.7",
|
|
33
36
|
"jsonwebtoken": "^8.5.1",
|
|
37
|
+
"nodemailer": "^6.7.0",
|
|
34
38
|
"pg": "^8.7.1",
|
|
35
|
-
"typeorm": "^0.2.38"
|
|
39
|
+
"typeorm": "^0.2.38",
|
|
40
|
+
"uuid": "^8.3.2"
|
|
36
41
|
}
|
|
37
42
|
}
|
package/lib/db/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const pg_1 = require("pg");
|
|
4
|
-
const pool = new pg_1.Pool({
|
|
5
|
-
connectionString: process.env.DATABASE_URL,
|
|
6
|
-
ssl: {
|
|
7
|
-
rejectUnauthorized: false,
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
exports.default = pool;
|