propro-utils 1.3.13 → 1.3.14
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.
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var React = require("react");
|
|
8
|
+
var _require = require("@react-email/components"),
|
|
9
|
+
Button = _require.Button,
|
|
10
|
+
Container = _require.Container,
|
|
11
|
+
Head = _require.Head,
|
|
12
|
+
Html = _require.Html,
|
|
13
|
+
Img = _require.Img,
|
|
14
|
+
Section = _require.Section,
|
|
15
|
+
Text = _require.Text;
|
|
16
|
+
var NotifLocal = function NotifLocal(_ref) {
|
|
17
|
+
var body = _ref.body,
|
|
18
|
+
app = _ref.app,
|
|
19
|
+
label = _ref.label,
|
|
20
|
+
url = _ref.url;
|
|
21
|
+
var getLogoUrl = function getLogoUrl(app) {
|
|
22
|
+
switch (app) {
|
|
23
|
+
case "hubhub":
|
|
24
|
+
return "/assets/logos/hubhub.svg";
|
|
25
|
+
case "propro":
|
|
26
|
+
return "/assets/logos/propro.svg";
|
|
27
|
+
default:
|
|
28
|
+
return "/assets/logos/hubhub.svg";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/React.createElement(Html, null, /*#__PURE__*/React.createElement(Head, null), /*#__PURE__*/React.createElement(Section, {
|
|
32
|
+
style: main
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
34
|
+
style: container
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Img, {
|
|
36
|
+
src: getLogoUrl(app)
|
|
37
|
+
}), /*#__PURE__*/React.createElement(Section, null, /*#__PURE__*/React.createElement(Text, {
|
|
38
|
+
style: text
|
|
39
|
+
}, body || "Default body text here."), label && /*#__PURE__*/React.createElement(Button, {
|
|
40
|
+
href: url,
|
|
41
|
+
style: btn
|
|
42
|
+
}, label)))));
|
|
43
|
+
};
|
|
44
|
+
var main = {
|
|
45
|
+
backgroundColor: "#ffffff",
|
|
46
|
+
margin: "0 auto"
|
|
47
|
+
};
|
|
48
|
+
var container = {
|
|
49
|
+
border: "1px solid #eaeaea",
|
|
50
|
+
borderRadius: "5px",
|
|
51
|
+
margin: "40px auto",
|
|
52
|
+
padding: "20px",
|
|
53
|
+
width: "465px"
|
|
54
|
+
};
|
|
55
|
+
var h1 = {
|
|
56
|
+
color: "#000",
|
|
57
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
58
|
+
fontSize: "24px",
|
|
59
|
+
fontWeight: "normal",
|
|
60
|
+
textAlign: "center",
|
|
61
|
+
margin: "30px 0",
|
|
62
|
+
padding: "0"
|
|
63
|
+
};
|
|
64
|
+
var text = {
|
|
65
|
+
color: "#000",
|
|
66
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
67
|
+
fontSize: "14px",
|
|
68
|
+
lineHeight: "24px"
|
|
69
|
+
};
|
|
70
|
+
var btn = {
|
|
71
|
+
backgroundColor: "#000",
|
|
72
|
+
borderRadius: "5px",
|
|
73
|
+
color: "#fff",
|
|
74
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
75
|
+
fontSize: "12px",
|
|
76
|
+
fontWeight: 500,
|
|
77
|
+
lineHeight: "50px",
|
|
78
|
+
textDecoration: "none",
|
|
79
|
+
textAlign: "center"
|
|
80
|
+
};
|
|
81
|
+
var _default = exports["default"] = NotifLocal;
|
package/dist/emailStrategy.js
CHANGED
|
@@ -9,62 +9,87 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
9
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
10
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
11
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
require("dotenv").config();
|
|
13
20
|
var React = require("react");
|
|
14
21
|
var ReactDOMServer = require("react-dom/server");
|
|
15
22
|
var NotifLocal = require("./NotifLocal");
|
|
16
23
|
var nodemailer = require("nodemailer");
|
|
17
24
|
var mailgun = require("nodemailer-mailgun-transport");
|
|
18
|
-
var
|
|
25
|
+
var _require = require("./template.data"),
|
|
26
|
+
templateData = _require.templateData;
|
|
27
|
+
var _require2 = require("./baseStrategy"),
|
|
28
|
+
NotificationStrategy = _require2.NotificationStrategy;
|
|
29
|
+
var mailgunTransport = nodemailer.createTransport(mailgun({
|
|
30
|
+
host: process.env.SMTP_HOST,
|
|
31
|
+
auth: {
|
|
32
|
+
api_key: process.env.MAILGUN_API_KEY,
|
|
33
|
+
domain: process.env.EMAIL_DOMAIN
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
19
36
|
|
|
20
37
|
/**
|
|
21
38
|
* Represents a strategy for sending email notifications.
|
|
22
39
|
*/
|
|
23
|
-
var EmailNotificationStrategy = /*#__PURE__*/function () {
|
|
40
|
+
var EmailNotificationStrategy = /*#__PURE__*/function (_NotificationStrategy) {
|
|
41
|
+
_inherits(EmailNotificationStrategy, _NotificationStrategy);
|
|
42
|
+
var _super = _createSuper(EmailNotificationStrategy);
|
|
24
43
|
function EmailNotificationStrategy() {
|
|
25
44
|
_classCallCheck(this, EmailNotificationStrategy);
|
|
26
|
-
|
|
27
|
-
host: process.env.SMTP_HOST,
|
|
28
|
-
auth: {
|
|
29
|
-
// api_key: process.env.MAILGUN_API_KEY,
|
|
30
|
-
api_key: "3aa03bb5e30f28345ff12a46c7977b20-e438c741-e3e2e5ab",
|
|
31
|
-
domain: process.env.EMAIL_DOMAIN
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
45
|
+
return _super.apply(this, arguments);
|
|
34
46
|
}
|
|
35
47
|
_createClass(EmailNotificationStrategy, [{
|
|
36
48
|
key: "sendNotification",
|
|
37
49
|
value: function () {
|
|
38
50
|
var _sendNotification = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(to, templateName, templateArgs) {
|
|
39
|
-
var selectedTemplate, emailHTML, message, info;
|
|
51
|
+
var templates, selectedTemplate, emailHTML, message, info;
|
|
40
52
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
41
53
|
while (1) switch (_context.prev = _context.next) {
|
|
42
54
|
case 0:
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
templates = templateData(templateArgs || {});
|
|
56
|
+
selectedTemplate = templates[templateName];
|
|
57
|
+
if (selectedTemplate) {
|
|
58
|
+
_context.next = 4;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
throw new Error("Template '".concat(templateName, "' not found"));
|
|
62
|
+
case 4:
|
|
63
|
+
console.log("selectedTemplate", selectedTemplate);
|
|
64
|
+
console.log("templateData", templateData);
|
|
65
|
+
// const emailHTML = ReactDOMServer.renderToString(
|
|
66
|
+
// React.createElement(NotifLocal, selectedTemplate)
|
|
67
|
+
// );
|
|
68
|
+
emailHTML = "<h1>".concat(selectedTemplate.body, "</h1>");
|
|
45
69
|
message = {
|
|
46
70
|
from: process.env.EMAIL_FROM,
|
|
47
71
|
to: to,
|
|
48
|
-
subject: selectedTemplate.subject,
|
|
72
|
+
subject: selectedTemplate.subject || "New Notification",
|
|
49
73
|
html: emailHTML
|
|
50
74
|
};
|
|
51
|
-
_context.prev =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
_context.prev = 8;
|
|
76
|
+
console.log("Email Message Object:", message);
|
|
77
|
+
_context.next = 12;
|
|
78
|
+
return mailgunTransport.sendMail(message);
|
|
79
|
+
case 12:
|
|
55
80
|
info = _context.sent;
|
|
56
81
|
console.log("Message sent: %s", info.messageId);
|
|
57
|
-
_context.next =
|
|
82
|
+
_context.next = 19;
|
|
58
83
|
break;
|
|
59
|
-
case
|
|
60
|
-
_context.prev =
|
|
61
|
-
_context.t0 = _context["catch"](
|
|
84
|
+
case 16:
|
|
85
|
+
_context.prev = 16;
|
|
86
|
+
_context.t0 = _context["catch"](8);
|
|
62
87
|
console.error("Error sending email", _context.t0);
|
|
63
|
-
case
|
|
88
|
+
case 19:
|
|
64
89
|
case "end":
|
|
65
90
|
return _context.stop();
|
|
66
91
|
}
|
|
67
|
-
}, _callee,
|
|
92
|
+
}, _callee, null, [[8, 16]]);
|
|
68
93
|
}));
|
|
69
94
|
function sendNotification(_x, _x2, _x3) {
|
|
70
95
|
return _sendNotification.apply(this, arguments);
|
|
@@ -73,7 +98,7 @@ var EmailNotificationStrategy = /*#__PURE__*/function () {
|
|
|
73
98
|
}()
|
|
74
99
|
}]);
|
|
75
100
|
return EmailNotificationStrategy;
|
|
76
|
-
}();
|
|
101
|
+
}(NotificationStrategy);
|
|
77
102
|
module.exports = {
|
|
78
103
|
EmailNotificationStrategy: EmailNotificationStrategy
|
|
79
104
|
};
|
package/dist/mailjetStrategy.js
CHANGED
|
@@ -17,6 +17,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
17
17
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
18
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
19
|
var axios = require("axios");
|
|
20
|
+
var _require = require("./baseStrategy"),
|
|
21
|
+
NotificationStrategy = _require.NotificationStrategy;
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Mailjet SMS Notification Strategy.
|
package/dist/twilloStrategy.js
CHANGED
|
@@ -17,6 +17,8 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
17
17
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
18
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
19
|
var twilio = require("twilio");
|
|
20
|
+
var _require = require("./baseStrategy"),
|
|
21
|
+
NotificationStrategy = _require.NotificationStrategy;
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Twilio SMS Notification Strategy class.
|
package/package.json
CHANGED
|
@@ -24,23 +24,31 @@ const refreshLimiter = rateLimit({
|
|
|
24
24
|
* @returns {Promise<void>} - Promise object that represents the completion of the middleware function.
|
|
25
25
|
*/
|
|
26
26
|
const refreshTokenMiddleware = async (req, res, next) => {
|
|
27
|
+
console.log("refreshTokenMiddleware again");
|
|
27
28
|
// Apply rate limiting
|
|
28
29
|
refreshLimiter(req, res, async () => {
|
|
29
30
|
const refreshToken = req.headers["x-refresh-token"];
|
|
30
31
|
|
|
32
|
+
console.log("refreshToken", refreshToken);
|
|
31
33
|
if (!refreshToken) {
|
|
32
34
|
return res.status(401).json({ error: "No refresh token provided" });
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
console.log("isValidRefreshTokenFormat(refreshToken)", isValidRefreshTokenFormat(refreshToken));
|
|
38
|
+
|
|
35
39
|
if (!isValidRefreshTokenFormat(refreshToken)) {
|
|
36
40
|
return res.status(400).json({ error: "Invalid refresh token format" });
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
console.log("refreshTokenCache.has(refreshToken)", refreshTokenCache.has(refreshToken));
|
|
44
|
+
|
|
39
45
|
if (refreshTokenCache.has(refreshToken)) {
|
|
40
46
|
req.newAccessToken = refreshTokenCache.get(refreshToken);
|
|
41
47
|
return next();
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
console.log("process.env.AUTH_URL", process.env.AUTH_URL);
|
|
51
|
+
|
|
44
52
|
try {
|
|
45
53
|
const response = await axios.post(
|
|
46
54
|
`${process.env.AUTH_URL}/oauth/token`,
|
|
@@ -53,6 +61,8 @@ const refreshTokenMiddleware = async (req, res, next) => {
|
|
|
53
61
|
{ headers: { "Content-Type": "application/x-www-form-urlencoded" } }
|
|
54
62
|
);
|
|
55
63
|
|
|
64
|
+
console.log("response", response);
|
|
65
|
+
|
|
56
66
|
if (response.data && response.data.access_token) {
|
|
57
67
|
refreshTokenCache.set(refreshToken, response.data.access_token);
|
|
58
68
|
req.newAccessToken = response.data.access_token;
|