notherbase-fs 3.4.7 → 3.5.1

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.
@@ -1,4 +1,12 @@
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
1
3
  import nodemailer from "nodemailer";
4
+ import { google } from "googleapis";
5
+
6
+ const OAuth2 = google.auth.OAuth2;
7
+ const OAuth2Client = new OAuth2(process.env.CLIENTID, process.env.CLIENTSECRET);
8
+ OAuth2Client.setCredentials({ refresh_token: process.env.CLIENTREFRESH });
9
+
2
10
 
3
11
  /**
4
12
  * Sends an email with a password reset code. WIP
@@ -19,17 +27,23 @@ const passwordReset = async (toEmail, resetToken) => {
19
27
  * @param {String} html Body of the email.
20
28
  * @returns
21
29
  */
22
- const send = async (toEmail, subject, html) => {
23
- const transporter = nodemailer.createTransport({
30
+ const send = async (toEmail, subject, html, name = "NotherBase") => {
31
+ let accessToken = OAuth2Client.getAccessToken();
32
+
33
+ let transporter = nodemailer.createTransport({
24
34
  service: 'gmail',
25
35
  auth: {
26
- user: process.env.NOREPLY,
27
- pass: process.env.EMAILPW
36
+ type: 'OAuth2',
37
+ user: process.env.NOREPLY,
38
+ clientId: process.env.CLIENTID,
39
+ clientSecret: process.env.CLIENTSECRET,
40
+ refreshToken: process.env.CLIENTREFRESH,
41
+ accessToken: accessToken
28
42
  }
29
- });
43
+ });
30
44
 
31
- var mailOptions = {
32
- from: process.env.NOREPLY,
45
+ let mailOptions = {
46
+ from: name + " <" + process.env.NOREPLY +">",
33
47
  to: toEmail,
34
48
  subject: subject,
35
49
  html: html
package/notherbase-fs.js CHANGED
@@ -57,7 +57,11 @@ class NotherBaseFS {
57
57
  store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI }),
58
58
  secret: process.env.SECRET,
59
59
  resave: false,
60
- saveUninitialized: false
60
+ saveUninitialized: false,
61
+ cookie: {
62
+ secure: process.env.PRODUCTION === "true",
63
+ maxAge: 1000 * 60 * 60 * 24 * 28 // 28 days
64
+ }
61
65
  }));
62
66
 
63
67
  //provide database access and etc to use in routes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "3.4.7",
3
+ "version": "3.5.1",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  "googleapis": "^100.0.0",
29
29
  "method-override": "^3.0.0",
30
30
  "mongoose": "^6.1.7",
31
- "nodemailer": "^6.7.5",
31
+ "nodemailer": "^6.9.14",
32
32
  "serve-favicon": "^2.5.0",
33
33
  "socket.io": "^4.4.1",
34
34
  "string-strip-html": "^13.0.0"
@@ -2,7 +2,8 @@ export default async function emailTime(req, user) {
2
2
  await req.db.SendMail.send(
3
3
  'wyattsushi@gmail.com',
4
4
  'Test',
5
- 'sdntndtjln l'
5
+ 'sdntndtjln l',
6
+ "NB"
6
7
  );
7
8
 
8
9
  return "Sent";
@@ -8,7 +8,7 @@
8
8
 
9
9
  <button onclick="base.do('add-more-gold')">+3</button>
10
10
  <button onclick="base.do('subtract-gold')">-30</button>
11
- <button onclick="base.do('emailTime')">email</button>
11
+ <button onclick="base.do('emailTime', { route: '/the-front/check'})">email</button>
12
12
  <button class="switch" onclick="base.do('flip')">Flip Me</button>
13
13
  <input type="text" id="test" placeholder="Loading...">
14
14
  <button onclick="saveInput()">Save</button>