@openinc/parse-server-opendash 4.38.0 → 4.38.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.
- package/dist/features/notifications/index.d.ts +1 -0
- package/dist/features/notifications/index.js +3 -1
- package/dist/features/notifications/permissions.d.ts +10 -0
- package/dist/features/notifications/permissions.js +13 -0
- package/dist/functions/openinc-mail-config.js +6 -4
- package/dist/functions/openinc-mail-test.d.ts +5 -0
- package/dist/functions/openinc-mail-test.js +26 -6
- package/package.json +1 -1
|
@@ -3,5 +3,6 @@ export { Notifications } from "./types/Notifications.js";
|
|
|
3
3
|
export { getAllNotifications, default as initNotifications, } from "./services/registerNotification.js";
|
|
4
4
|
export { RegisteredNotification } from "./states/NotificationClass.js";
|
|
5
5
|
export { EmailState } from "./states/EmailState.js";
|
|
6
|
+
export { MAIL_ADMIN_PERMISSION } from "./permissions.js";
|
|
6
7
|
export { initEmailTransport } from "./services/initEmailTransport.js";
|
|
7
8
|
export { sendSimpleEmail, sendTemplateEmail } from "./services/sendMails.js";
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sendTemplateEmail = exports.sendSimpleEmail = exports.initEmailTransport = exports.EmailState = exports.RegisteredNotification = exports.initNotifications = exports.getAllNotifications = exports.Notifications = void 0;
|
|
6
|
+
exports.sendTemplateEmail = exports.sendSimpleEmail = exports.initEmailTransport = exports.MAIL_ADMIN_PERMISSION = exports.EmailState = exports.RegisteredNotification = exports.initNotifications = exports.getAllNotifications = exports.Notifications = void 0;
|
|
7
7
|
var Notifications_js_1 = require("./types/Notifications.js");
|
|
8
8
|
Object.defineProperty(exports, "Notifications", { enumerable: true, get: function () { return Notifications_js_1.Notifications; } });
|
|
9
9
|
var registerNotification_js_1 = require("./services/registerNotification.js");
|
|
@@ -13,6 +13,8 @@ var NotificationClass_js_1 = require("./states/NotificationClass.js");
|
|
|
13
13
|
Object.defineProperty(exports, "RegisteredNotification", { enumerable: true, get: function () { return NotificationClass_js_1.RegisteredNotification; } });
|
|
14
14
|
var EmailState_js_1 = require("./states/EmailState.js");
|
|
15
15
|
Object.defineProperty(exports, "EmailState", { enumerable: true, get: function () { return EmailState_js_1.EmailState; } });
|
|
16
|
+
var permissions_js_1 = require("./permissions.js");
|
|
17
|
+
Object.defineProperty(exports, "MAIL_ADMIN_PERMISSION", { enumerable: true, get: function () { return permissions_js_1.MAIL_ADMIN_PERMISSION; } });
|
|
16
18
|
var initEmailTransport_js_1 = require("./services/initEmailTransport.js");
|
|
17
19
|
Object.defineProperty(exports, "initEmailTransport", { enumerable: true, get: function () { return initEmailTransport_js_1.initEmailTransport; } });
|
|
18
20
|
var sendMails_js_1 = require("./services/sendMails.js");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access to the mail administration: reading the SMTP config and sending a
|
|
3
|
+
* test mail through the server's transport.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately not part of the `Permissions` namespace: everything listed
|
|
6
|
+
* there is registered for every tenant on start and handed to its roles. This
|
|
7
|
+
* key is registered by the frontend's setup dialog instead, so only whoever is
|
|
8
|
+
* granted it there holds it (see 46d064a4).
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAIL_ADMIN_PERMISSION = "parse-admin:can-access-mail-admin";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAIL_ADMIN_PERMISSION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Access to the mail administration: reading the SMTP config and sending a
|
|
6
|
+
* test mail through the server's transport.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately not part of the `Permissions` namespace: everything listed
|
|
9
|
+
* there is registered for every tenant on start and handed to its roles. This
|
|
10
|
+
* key is registered by the frontend's setup dialog instead, so only whoever is
|
|
11
|
+
* granted it there holds it (see 46d064a4).
|
|
12
|
+
*/
|
|
13
|
+
exports.MAIL_ADMIN_PERMISSION = "parse-admin:can-access-mail-admin";
|
|
@@ -5,12 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.init = init;
|
|
7
7
|
const node_1 = __importDefault(require("parse/node"));
|
|
8
|
+
const index_js_1 = require("../features/notifications/index.js");
|
|
9
|
+
const index_js_2 = require("../features/permissions/index.js");
|
|
8
10
|
async function init(name) {
|
|
9
11
|
node_1.default.Cloud.define(name, async (request) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
12
|
+
await (0, index_js_2.requirePermission)({
|
|
13
|
+
sessionToken: request.user?.getSessionToken(),
|
|
14
|
+
master: request.master,
|
|
15
|
+
}, index_js_1.MAIL_ADMIN_PERMISSION, "read the mail server config");
|
|
14
16
|
if (process.env.OPENINC_PARSE_SMTP_ENABLED !== undefined &&
|
|
15
17
|
/true/.test(process.env.OPENINC_PARSE_SMTP_ENABLED)) {
|
|
16
18
|
// Return your mail server config
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends a fixed test mail through the server's SMTP transport, so an admin can
|
|
3
|
+
* check the mail setup. Returns the saved `Core_Email` including the SMTP
|
|
4
|
+
* response — that is the diagnostic the caller is after.
|
|
5
|
+
*/
|
|
1
6
|
export declare function init(name: string): Promise<void>;
|
|
@@ -6,16 +6,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.init = init;
|
|
7
7
|
const node_1 = __importDefault(require("parse/node"));
|
|
8
8
|
const index_js_1 = require("../features/notifications/index.js");
|
|
9
|
+
const index_js_2 = require("../features/permissions/index.js");
|
|
10
|
+
// One plain address. nodemailer would also take a comma-separated list, an
|
|
11
|
+
// array or an address object with a free-text name — any of which turns a
|
|
12
|
+
// test mail into a relay to as many recipients as fit in the request.
|
|
13
|
+
const SINGLE_ADDRESS = /^[^\s@,;<>"()[\]\\]+@[^\s@,;<>"()[\]\\]+\.[^\s@,;<>"()[\]\\]+$/;
|
|
14
|
+
/**
|
|
15
|
+
* Sends a fixed test mail through the server's SMTP transport, so an admin can
|
|
16
|
+
* check the mail setup. Returns the saved `Core_Email` including the SMTP
|
|
17
|
+
* response — that is the diagnostic the caller is after.
|
|
18
|
+
*/
|
|
9
19
|
async function init(name) {
|
|
10
|
-
// sendTestEmail - Sends a test email
|
|
11
20
|
node_1.default.Cloud.define(name, async (request) => {
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
await (0, index_js_2.requirePermission)({
|
|
22
|
+
sessionToken: request.user?.getSessionToken(),
|
|
23
|
+
master: request.master,
|
|
24
|
+
}, index_js_1.MAIL_ADMIN_PERMISSION, "send a test mail");
|
|
25
|
+
const to = request.params.to;
|
|
26
|
+
if (typeof to !== "string" ||
|
|
27
|
+
to.length > 254 ||
|
|
28
|
+
!SINGLE_ADDRESS.test(to.trim())) {
|
|
29
|
+
throw new node_1.default.Error(node_1.default.Error.INVALID_EMAIL_ADDRESS, "Expected a single email address in `to`");
|
|
14
30
|
}
|
|
15
|
-
|
|
16
|
-
const mail = await (0, index_js_1.sendSimpleEmail)(to, "open.INC Test Mail", "This is a test email from open.INC Stack.");
|
|
17
|
-
return mail;
|
|
31
|
+
return await (0, index_js_1.sendSimpleEmail)(to.trim(), "open.INC Test Mail", "This is a test email from open.INC Stack.");
|
|
18
32
|
}, {
|
|
19
33
|
requireUser: true,
|
|
34
|
+
// Per client IP; the master key is exempt.
|
|
35
|
+
rateLimit: {
|
|
36
|
+
requestTimeWindow: 60 * 1000,
|
|
37
|
+
requestCount: 5,
|
|
38
|
+
errorResponseMessage: "Too many test mails, try again in a minute.",
|
|
39
|
+
},
|
|
20
40
|
});
|
|
21
41
|
}
|