biz-email-builder-shared 1.0.8 → 1.0.10
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/dist/entity/user.entity.d.ts +2 -0
- package/dist/entity/user.entity.d.ts.map +1 -1
- package/dist/entity/user.entity.js +4 -1
- package/dist/utilities/encryptionUtils.d.ts +1 -1
- package/dist/utilities/encryptionUtils.d.ts.map +1 -1
- package/dist/utilities/encryptionUtils.js +2 -5
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +1 -0
- package/dist/utilities/sendMailViaGmail.d.ts +6 -0
- package/dist/utilities/sendMailViaGmail.d.ts.map +1 -0
- package/dist/utilities/sendMailViaGmail.js +39 -0
- package/package.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../src/entity/user.entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../src/entity/user.entity.ts"],"names":[],"mappings":"AAGA,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAA;CAChB;AAgBD,eAAO,MAAM,SAAS;;eAAmC,CAAC"}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserModel = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
+
const utilities_1 = require("../utilities");
|
|
5
6
|
const UserSchema = new mongoose_1.Schema({
|
|
6
7
|
email: { type: String, unique: true, sparse: true },
|
|
7
8
|
password: { type: String, default: null },
|
|
8
|
-
role: { type: String, default:
|
|
9
|
+
role: { type: String, default: utilities_1.ROLES.USER },
|
|
10
|
+
isVerified: { type: Boolean, default: false },
|
|
11
|
+
verificationToken: { type: String },
|
|
9
12
|
deletedAt: { type: Date, default: null },
|
|
10
13
|
}, {
|
|
11
14
|
timestamps: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryptionUtils.d.ts","sourceRoot":"","sources":["../../src/utilities/encryptionUtils.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,OAAO,UAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"encryptionUtils.d.ts","sourceRoot":"","sources":["../../src/utilities/encryptionUtils.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,OAAO,UAAW,MAAM,YAAY,GAAG,WAK5C,CAAC;AAEF,QAAA,MAAM,SAAS,UAAiB,MAAM,KAAG,OAAO,CAAC,GAAG,CAenD,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -5,17 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.verifyUid = exports.signUid = void 0;
|
|
7
7
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
-
const signUid = (value) => {
|
|
9
|
-
return jsonwebtoken_1.default.sign({ value }, process.env.JWTSECRET || 'secret', {
|
|
10
|
-
expiresIn: '8h' // expires in 8 hours
|
|
11
|
-
});
|
|
8
|
+
const signUid = (value, options) => {
|
|
9
|
+
return jsonwebtoken_1.default.sign({ value }, process.env.JWTSECRET || 'secret', Object.assign({ expiresIn: '8h' }, options));
|
|
12
10
|
};
|
|
13
11
|
exports.signUid = signUid;
|
|
14
12
|
const verifyUid = async (token) => new Promise(resolve => {
|
|
15
13
|
const jwtToken = token.split(" ")[1] || token;
|
|
16
14
|
jsonwebtoken_1.default.verify(jwtToken, process.env.JWTSECRET || 'secret', (err, decoded) => {
|
|
17
15
|
if (err) {
|
|
18
|
-
// console.log("error verifyUid", err)
|
|
19
16
|
resolve(null);
|
|
20
17
|
}
|
|
21
18
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAEnC,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,oBAAY,QAAQ;CAEnB"}
|
package/dist/utilities/index.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.FEATURES = exports.ROLES = void 0;
|
|
|
18
18
|
__exportStar(require("./callWithRetries"), exports);
|
|
19
19
|
__exportStar(require("./createFolder"), exports);
|
|
20
20
|
__exportStar(require("./encryptionUtils"), exports);
|
|
21
|
+
__exportStar(require("./sendMailViaGmail"), exports);
|
|
21
22
|
var ROLES;
|
|
22
23
|
(function (ROLES) {
|
|
23
24
|
ROLES["ADMIN"] = "ADMIN";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMailViaGmail.d.ts","sourceRoot":"","sources":["../../src/utilities/sendMailViaGmail.ts"],"names":[],"mappings":"AAEA,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,MAAM,EAAE,OAAO,sBAkCrK"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sendMailViaGmail = sendMailViaGmail;
|
|
7
|
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
8
|
+
async function sendMailViaGmail(to, subject, text, attachments, isHtml) {
|
|
9
|
+
// Create a Nodemailer transporter using AWS SES SMTP credentials
|
|
10
|
+
const transporter = nodemailer_1.default.createTransport({
|
|
11
|
+
service: "gmail", // SES SMTP endpoint for your region
|
|
12
|
+
auth: {
|
|
13
|
+
user: process.env.GMAIL_ID, // Your Gmail address
|
|
14
|
+
pass: process.env.GMAIL_PASSWORD // App password generated from your Google account
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
// Define email options
|
|
18
|
+
const mailOptions = {
|
|
19
|
+
from: process.env.GMAIL_FROM_ID, // sender email address
|
|
20
|
+
to, // recipient email address
|
|
21
|
+
subject, // subject of the email
|
|
22
|
+
attachments: attachments || []
|
|
23
|
+
};
|
|
24
|
+
text = text.replace("${username}", process.env.GMAIL_FROM_USERNAME || "");
|
|
25
|
+
if (isHtml) {
|
|
26
|
+
mailOptions.html = text;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
mailOptions.text = text;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const info = await transporter.sendMail(mailOptions);
|
|
33
|
+
console.log('Email sent:', info.response);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error sending email: ', error);
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biz-email-builder-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"files": [
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
7
9
|
"scripts": {
|
|
8
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
11
|
"build": "tsc",
|
|
@@ -13,11 +15,13 @@
|
|
|
13
15
|
"express": "^4.18.2",
|
|
14
16
|
"joi": "^17.11.0",
|
|
15
17
|
"jsonwebtoken": "^9.0.2",
|
|
18
|
+
"nodemailer": "^6.10.0",
|
|
16
19
|
"typescript": "^5.3.3"
|
|
17
20
|
},
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@types/express": "^4.17.21",
|
|
20
|
-
"@types/jsonwebtoken": "^9.0.5"
|
|
23
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
24
|
+
"@types/nodemailer": "^6.4.17"
|
|
21
25
|
},
|
|
22
26
|
"keywords": [],
|
|
23
27
|
"author": "",
|