@openinc/parse-server-opendash 2.3.3 → 2.3.6
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/featuremap.json +2 -0
- package/dist/functions/openinc-auth-email-confirmation-request.js +9 -1
- package/dist/functions/openinc-auth-login-passwordless.js +9 -1
- package/dist/functions/openinc-auth-password-reset-request.js +9 -1
- package/dist/functions/openinc-auth-validate-token.js +12 -9
- package/dist/functions/openinc-auth.common.d.ts +4 -5
- package/dist/functions/openinc-auth.common.js +25 -17
- package/dist/hooks/Core_Email.d.ts +14 -0
- package/dist/hooks/Core_Email.js +110 -0
- package/dist/hooks/Core_Token.d.ts +1 -0
- package/dist/hooks/Core_Token.js +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -42
- package/dist/types/Core_Email.d.ts +26 -0
- package/dist/types/Core_Email.js +41 -0
- package/dist/types/Core_Token.d.ts +23 -0
- package/dist/types/Core_Token.js +35 -0
- package/dist/types/MIAAS_MDSEndpoint.d.ts +3 -0
- package/dist/types/MIAAS_MDSEndpoint.js +6 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +6 -2
- package/package.json +3 -1
- package/schema/AlarmAction.json +7 -1
- package/schema/Core_Email.json +35 -0
- package/schema/Core_Token.json +32 -0
- package/schema/MIAAS_MDSEndpoint.json +5 -0
- package/schema/Tenant.json +13 -13
package/dist/featuremap.json
CHANGED
|
@@ -13,7 +13,15 @@ async function init(name) {
|
|
|
13
13
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "No user was found with the given email.");
|
|
14
14
|
}
|
|
15
15
|
const { url } = await (0, openinc_auth_common_1.createToken)("verify-email", user.id, request.params.url);
|
|
16
|
-
await (0, __1.
|
|
16
|
+
await (0, __1.sendTemplateEmail)({
|
|
17
|
+
template: "openinc-auth-email-confirmation",
|
|
18
|
+
subject: "E-Mail Bestätigung / Email confirmation",
|
|
19
|
+
to: email,
|
|
20
|
+
fallback: url,
|
|
21
|
+
data: {
|
|
22
|
+
link: url,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
17
25
|
return {
|
|
18
26
|
success: true,
|
|
19
27
|
};
|
|
@@ -21,7 +21,15 @@ async function init(name) {
|
|
|
21
21
|
});
|
|
22
22
|
const url = urlTemplate.replace("{{token}}", sessionToken);
|
|
23
23
|
console.log(url);
|
|
24
|
-
await (0, __1.
|
|
24
|
+
await (0, __1.sendTemplateEmail)({
|
|
25
|
+
template: "openinc-auth-login-passwordless",
|
|
26
|
+
subject: "Passwordless Login",
|
|
27
|
+
to: email,
|
|
28
|
+
fallback: url,
|
|
29
|
+
data: {
|
|
30
|
+
link: url,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
25
33
|
return {
|
|
26
34
|
success: true,
|
|
27
35
|
};
|
|
@@ -13,7 +13,15 @@ async function init(name) {
|
|
|
13
13
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "No user was found with the given email.");
|
|
14
14
|
}
|
|
15
15
|
const { url } = await (0, openinc_auth_common_1.createToken)("password-reset", user.id, request.params.url);
|
|
16
|
-
await (0, __1.
|
|
16
|
+
await (0, __1.sendTemplateEmail)({
|
|
17
|
+
template: "openinc-auth-password-reset",
|
|
18
|
+
subject: "Passwort zurücksetzen / Password reset",
|
|
19
|
+
to: email,
|
|
20
|
+
fallback: url,
|
|
21
|
+
data: {
|
|
22
|
+
link: url,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
17
25
|
return {
|
|
18
26
|
success: true,
|
|
19
27
|
};
|
|
@@ -4,23 +4,26 @@ exports.init = void 0;
|
|
|
4
4
|
const openinc_auth_common_1 = require("./openinc-auth.common");
|
|
5
5
|
async function init(name) {
|
|
6
6
|
Parse.Cloud.define(name, async function (request) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
try {
|
|
8
|
+
const token = await (0, openinc_auth_common_1.consumeToken)(request.params.type, request.params.token, true);
|
|
9
9
|
return {
|
|
10
|
-
valid:
|
|
10
|
+
valid: true,
|
|
11
11
|
expired: false,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error instanceof Parse.Error &&
|
|
16
|
+
error.message === "Token expired.") {
|
|
17
|
+
return {
|
|
18
|
+
valid: false,
|
|
19
|
+
expired: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
15
22
|
return {
|
|
16
23
|
valid: false,
|
|
17
|
-
expired:
|
|
24
|
+
expired: false,
|
|
18
25
|
};
|
|
19
26
|
}
|
|
20
|
-
return {
|
|
21
|
-
valid: true,
|
|
22
|
-
expired: false,
|
|
23
|
-
};
|
|
24
27
|
}, {
|
|
25
28
|
requireUser: false,
|
|
26
29
|
fields: {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/// <reference types="parse" />
|
|
2
|
+
import { Core_Token } from "../types";
|
|
2
3
|
interface TokenPayload {
|
|
3
4
|
type: "verify-email" | "password-reset";
|
|
4
5
|
userId: string;
|
|
5
|
-
timestamp: number;
|
|
6
6
|
}
|
|
7
|
-
export declare const TOKENS: Map<string, TokenPayload>;
|
|
8
7
|
export declare function createToken(type: TokenPayload["type"], userId: string, url: string): Promise<{
|
|
9
|
-
token:
|
|
8
|
+
token: string;
|
|
10
9
|
url: string;
|
|
11
10
|
}>;
|
|
12
|
-
export declare function consumeToken(type: TokenPayload["type"],
|
|
13
|
-
export declare function isExpired(token:
|
|
11
|
+
export declare function consumeToken(type: TokenPayload["type"], key: string, doNotConsume?: boolean): Promise<TokenPayload>;
|
|
12
|
+
export declare function isExpired(token: Core_Token): boolean;
|
|
14
13
|
export declare function createSessionToken(user: Parse.User, installationId: string | undefined, createdWith: Record<string, any>): Promise<string>;
|
|
15
14
|
export {};
|
|
@@ -1,34 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSessionToken = exports.isExpired = exports.consumeToken = exports.createToken =
|
|
3
|
+
exports.createSessionToken = exports.isExpired = exports.consumeToken = exports.createToken = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
|
-
|
|
5
|
+
const types_1 = require("../types");
|
|
6
6
|
async function createToken(type, userId, url) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const key = (0, crypto_1.randomUUID)();
|
|
8
|
+
const token = new types_1.Core_Token({
|
|
9
|
+
key: key,
|
|
10
|
+
url: url.replace("{{token}}", key),
|
|
11
|
+
payload: {
|
|
12
|
+
type,
|
|
13
|
+
userId,
|
|
14
|
+
},
|
|
12
15
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return { token, url };
|
|
16
|
+
await token.save(null, { useMasterKey: true });
|
|
17
|
+
return { token: token.key, url: token.url };
|
|
16
18
|
}
|
|
17
19
|
exports.createToken = createToken;
|
|
18
|
-
async function consumeToken(type,
|
|
19
|
-
const
|
|
20
|
-
|
|
20
|
+
async function consumeToken(type, key, doNotConsume = false) {
|
|
21
|
+
const token = await new Parse.Query(types_1.Core_Token)
|
|
22
|
+
.equalTo("key", key)
|
|
23
|
+
.equalTo("used", false)
|
|
24
|
+
.first({ useMasterKey: true });
|
|
25
|
+
if (!token) {
|
|
21
26
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "Token not found.");
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
if (!doNotConsume) {
|
|
29
|
+
token.used = true;
|
|
30
|
+
await token.save({ used: true }, { useMasterKey: true });
|
|
31
|
+
}
|
|
32
|
+
if (isExpired(token)) {
|
|
25
33
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "Token expired.");
|
|
26
34
|
}
|
|
27
|
-
return payload;
|
|
35
|
+
return token.payload;
|
|
28
36
|
}
|
|
29
37
|
exports.consumeToken = consumeToken;
|
|
30
38
|
function isExpired(token) {
|
|
31
|
-
return token.
|
|
39
|
+
return token.createdAt.valueOf() + 1000 * 60 * 60 * 24 < Date.now();
|
|
32
40
|
}
|
|
33
41
|
exports.isExpired = isExpired;
|
|
34
42
|
async function createSessionToken(user, installationId, createdWith) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Transporter } from "nodemailer";
|
|
2
|
+
import type SMTPTransport from "nodemailer/lib/smtp-transport";
|
|
3
|
+
import { Core_Email } from "../types";
|
|
4
|
+
export declare let transport: Transporter<SMTPTransport.SentMessageInfo> | undefined;
|
|
5
|
+
export declare function initEmailTransport(): Promise<void>;
|
|
6
|
+
export declare function sendSimpleEmail(to: string, subject: string, text: string): Promise<Core_Email>;
|
|
7
|
+
export declare function sendTemplateEmail({ to, subject, fallback, template, data, }: {
|
|
8
|
+
to: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
fallback: string;
|
|
11
|
+
template: string;
|
|
12
|
+
data: any;
|
|
13
|
+
}): Promise<Core_Email>;
|
|
14
|
+
export declare function init(): Promise<void>;
|
|
@@ -0,0 +1,110 @@
|
|
|
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.init = exports.sendTemplateEmail = exports.sendSimpleEmail = exports.initEmailTransport = exports.transport = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
9
|
+
const nunjucks_1 = __importDefault(require("nunjucks"));
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const __1 = require("..");
|
|
12
|
+
const config_1 = require("../config");
|
|
13
|
+
const types_1 = require("../types");
|
|
14
|
+
const emailTemplateDir = (0, path_1.resolve)(process.cwd(), "views/emails");
|
|
15
|
+
exports.transport = undefined;
|
|
16
|
+
async function initEmailTransport() {
|
|
17
|
+
try {
|
|
18
|
+
if (config_1.config.getBoolean("SMTP_ENABLED")) {
|
|
19
|
+
exports.transport = nodemailer_1.default.createTransport({
|
|
20
|
+
host: config_1.config.get("SMTP_HOST"),
|
|
21
|
+
port: config_1.config.getNumber("SMTP_PORT"),
|
|
22
|
+
secure: config_1.config.getBoolean("SMTP_SECURE"),
|
|
23
|
+
ignoreTLS: config_1.config.getBoolean("SMTP_IGNORE_TLS"),
|
|
24
|
+
auth: {
|
|
25
|
+
user: config_1.config.get("SMTP_USER"),
|
|
26
|
+
pass: config_1.config.get("SMTP_PASS"),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
await exports.transport.verify();
|
|
30
|
+
nunjucks_1.default.configure(emailTemplateDir, { autoescape: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error(`Parse SMTP Adapter: Error when trying to establish the SMTP connection:`);
|
|
35
|
+
console.error(error);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.initEmailTransport = initEmailTransport;
|
|
40
|
+
async function sendSimpleEmail(to, subject, text) {
|
|
41
|
+
const email = new types_1.Core_Email({
|
|
42
|
+
payload: {
|
|
43
|
+
to,
|
|
44
|
+
subject,
|
|
45
|
+
text,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
await email.save(null, { useMasterKey: true });
|
|
49
|
+
return email;
|
|
50
|
+
}
|
|
51
|
+
exports.sendSimpleEmail = sendSimpleEmail;
|
|
52
|
+
async function sendTemplateEmail({ to, subject, fallback, template, data, }) {
|
|
53
|
+
const email = new types_1.Core_Email({
|
|
54
|
+
payload: {
|
|
55
|
+
to,
|
|
56
|
+
subject,
|
|
57
|
+
text: renderEmailTemplate("txt", template, data, fallback),
|
|
58
|
+
html: renderEmailTemplate("html", template, data, undefined),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
await email.save(null, { useMasterKey: true });
|
|
62
|
+
return email;
|
|
63
|
+
}
|
|
64
|
+
exports.sendTemplateEmail = sendTemplateEmail;
|
|
65
|
+
function validateEmailTemplate(templateDir, template) {
|
|
66
|
+
const templatePath = (0, path_1.join)(templateDir, template);
|
|
67
|
+
if (!fs_1.default.existsSync(templateDir)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!fs_1.default.existsSync(templatePath)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
function renderEmailTemplate(type, template, data, fallback) {
|
|
76
|
+
const fullTemplate = template + "." + type;
|
|
77
|
+
return validateEmailTemplate(emailTemplateDir, fullTemplate)
|
|
78
|
+
? nunjucks_1.default.render(fullTemplate, data)
|
|
79
|
+
: fallback;
|
|
80
|
+
}
|
|
81
|
+
async function init() {
|
|
82
|
+
(0, __1.beforeSaveHook)(types_1.Core_Email, async (request) => {
|
|
83
|
+
const { object } = request;
|
|
84
|
+
object.setACL(new Parse.ACL());
|
|
85
|
+
if (!exports.transport) {
|
|
86
|
+
object.sent = false;
|
|
87
|
+
object.success = false;
|
|
88
|
+
object.error = false;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
try {
|
|
92
|
+
const response = await exports.transport.sendMail({
|
|
93
|
+
...object.payload,
|
|
94
|
+
from: config_1.config.get("SMTP_FROM"),
|
|
95
|
+
});
|
|
96
|
+
object.response = response;
|
|
97
|
+
object.sent = true;
|
|
98
|
+
object.success = true;
|
|
99
|
+
object.error = false;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
object.response = JSON.parse(JSON.stringify(error));
|
|
103
|
+
object.sent = true;
|
|
104
|
+
object.success = false;
|
|
105
|
+
object.error = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
exports.init = init;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function init(): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.init = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
async function init() {
|
|
7
|
+
(0, __1.beforeSaveHook)(types_1.Core_Token, async (request) => {
|
|
8
|
+
request.object.setACL(new Parse.ACL());
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.init = init;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Cloud as ParseCloud } from "parse";
|
|
2
2
|
export { Config } from "./helper/Config";
|
|
3
|
+
export { sendSimpleEmail, sendTemplateEmail } from "./hooks/Core_Email";
|
|
3
4
|
export declare let PREFIX: string;
|
|
4
5
|
export interface ConfigInterface {
|
|
5
6
|
configPath?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function init(): Promise<void>;
|
|
8
|
-
export declare function sendSimpleEmail(to: string, subject: string, text: string): Promise<undefined>;
|
|
9
9
|
export declare function hasPermission(sessionToken: string, key: string): Promise<boolean>;
|
|
10
10
|
export declare function requirePermission(request: {
|
|
11
11
|
master?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -3,24 +3,25 @@ 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.initAutoload = exports.autoloadCloudCode = exports.afterDeleteHook = exports.beforeDeleteHook = exports.afterSaveHook = exports.beforeSaveHook = exports.defaultAclHandler = exports.defaultHandler = exports.immutableField = exports.ensureUserRole = exports.ensureRole = exports.getConfigBoolean = exports.getConfig = exports.requirePermission = exports.hasPermission = exports.
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const web_push_1 = __importDefault(require("web-push"));
|
|
6
|
+
exports.initAutoload = exports.autoloadCloudCode = exports.afterDeleteHook = exports.beforeDeleteHook = exports.afterSaveHook = exports.beforeSaveHook = exports.defaultAclHandler = exports.defaultHandler = exports.immutableField = exports.ensureUserRole = exports.ensureRole = exports.getConfigBoolean = exports.getConfig = exports.requirePermission = exports.hasPermission = exports.init = exports.PREFIX = exports.sendTemplateEmail = exports.sendSimpleEmail = exports.Config = void 0;
|
|
9
7
|
const parse_server_schema_1 = require("@openinc/parse-server-schema");
|
|
10
8
|
const fast_equals_1 = require("fast-equals");
|
|
11
9
|
const fs_1 = __importDefault(require("fs"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const web_push_1 = __importDefault(require("web-push"));
|
|
14
12
|
const config_1 = require("./config");
|
|
15
13
|
const featuremap_json_1 = __importDefault(require("./featuremap.json"));
|
|
16
14
|
const _init_1 = require("./functions/_init");
|
|
15
|
+
const Core_Email_1 = require("./hooks/Core_Email");
|
|
17
16
|
const _init_2 = require("./hooks/_init");
|
|
18
17
|
const types_1 = require("./types");
|
|
19
18
|
var Config_1 = require("./helper/Config");
|
|
20
19
|
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
|
|
20
|
+
var Core_Email_2 = require("./hooks/Core_Email");
|
|
21
|
+
Object.defineProperty(exports, "sendSimpleEmail", { enumerable: true, get: function () { return Core_Email_2.sendSimpleEmail; } });
|
|
22
|
+
Object.defineProperty(exports, "sendTemplateEmail", { enumerable: true, get: function () { return Core_Email_2.sendTemplateEmail; } });
|
|
21
23
|
exports.PREFIX = "OD3_";
|
|
22
24
|
let schema = {};
|
|
23
|
-
let transport = undefined;
|
|
24
25
|
async function init() {
|
|
25
26
|
try {
|
|
26
27
|
const pkg = require("../package.json");
|
|
@@ -28,7 +29,7 @@ async function init() {
|
|
|
28
29
|
}
|
|
29
30
|
catch (error) { }
|
|
30
31
|
await config_1.config.init(true);
|
|
31
|
-
await initEmailTransport();
|
|
32
|
+
await (0, Core_Email_1.initEmailTransport)();
|
|
32
33
|
await initWebPush();
|
|
33
34
|
await initSchema();
|
|
34
35
|
await initDefaultRoles();
|
|
@@ -38,28 +39,6 @@ async function init() {
|
|
|
38
39
|
await initAutoload();
|
|
39
40
|
}
|
|
40
41
|
exports.init = init;
|
|
41
|
-
async function initEmailTransport() {
|
|
42
|
-
try {
|
|
43
|
-
if (config_1.config.getBoolean("SMTP_ENABLED")) {
|
|
44
|
-
transport = nodemailer_1.default.createTransport({
|
|
45
|
-
host: config_1.config.get("SMTP_HOST"),
|
|
46
|
-
port: config_1.config.getNumber("SMTP_PORT"),
|
|
47
|
-
secure: config_1.config.getBoolean("SMTP_SECURE"),
|
|
48
|
-
ignoreTLS: config_1.config.getBoolean("SMTP_IGNORE_TLS"),
|
|
49
|
-
auth: {
|
|
50
|
-
user: config_1.config.get("SMTP_USER"),
|
|
51
|
-
pass: config_1.config.get("SMTP_PASS"),
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
await transport.verify();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error(`Parse SMTP Adapter: Error when trying to establish the SMTP connection:`);
|
|
59
|
-
console.error(error);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
42
|
async function initWebPush() {
|
|
64
43
|
try {
|
|
65
44
|
if (config_1.config.getBoolean("WEB_PUSH_ENABLED")) {
|
|
@@ -112,18 +91,6 @@ async function initDefaultData() {
|
|
|
112
91
|
console.error(error);
|
|
113
92
|
}
|
|
114
93
|
}
|
|
115
|
-
async function sendSimpleEmail(to, subject, text) {
|
|
116
|
-
if (!transport) {
|
|
117
|
-
return void console.error("E-Mails are not enabled.");
|
|
118
|
-
}
|
|
119
|
-
transport.sendMail({
|
|
120
|
-
from: config_1.config.get("SMTP_FROM"),
|
|
121
|
-
to,
|
|
122
|
-
subject,
|
|
123
|
-
text,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
exports.sendSimpleEmail = sendSimpleEmail;
|
|
127
94
|
async function hasPermission(sessionToken, key) {
|
|
128
95
|
const result = await new Parse.Query(types_1.Permission)
|
|
129
96
|
.equalTo("key", key)
|
|
@@ -388,7 +355,7 @@ async function autoloadCloudCode(path, regex = /^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$
|
|
|
388
355
|
.map((filename) => filename.replace(".js", ""))
|
|
389
356
|
.filter((name) => regex.test(name));
|
|
390
357
|
for (const name of fns) {
|
|
391
|
-
const { init } = require((0,
|
|
358
|
+
const { init } = require((0, path_1.join)(path, name));
|
|
392
359
|
await init(name).catch((e) => console.error(e));
|
|
393
360
|
}
|
|
394
361
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="parse" />
|
|
2
|
+
export interface Core_EmailAttributes {
|
|
3
|
+
id: string;
|
|
4
|
+
objectId: string;
|
|
5
|
+
createdAt: Date;
|
|
6
|
+
updatedAt: Date;
|
|
7
|
+
error: boolean;
|
|
8
|
+
payload: any;
|
|
9
|
+
response?: any;
|
|
10
|
+
sent: boolean;
|
|
11
|
+
success: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class Core_Email extends Parse.Object<Core_EmailAttributes> {
|
|
14
|
+
static className: string;
|
|
15
|
+
constructor(data?: Partial<Core_EmailAttributes>);
|
|
16
|
+
get error(): boolean;
|
|
17
|
+
set error(value: boolean);
|
|
18
|
+
get payload(): any;
|
|
19
|
+
set payload(value: any);
|
|
20
|
+
get response(): any | undefined;
|
|
21
|
+
set response(value: any | undefined);
|
|
22
|
+
get sent(): boolean;
|
|
23
|
+
set sent(value: boolean);
|
|
24
|
+
get success(): boolean;
|
|
25
|
+
set success(value: boolean);
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Core_Email = void 0;
|
|
4
|
+
class Core_Email extends Parse.Object {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
super("OD3_Core_Email", data);
|
|
7
|
+
}
|
|
8
|
+
get error() {
|
|
9
|
+
return super.get("error");
|
|
10
|
+
}
|
|
11
|
+
set error(value) {
|
|
12
|
+
super.set("error", value);
|
|
13
|
+
}
|
|
14
|
+
get payload() {
|
|
15
|
+
return super.get("payload");
|
|
16
|
+
}
|
|
17
|
+
set payload(value) {
|
|
18
|
+
super.set("payload", value);
|
|
19
|
+
}
|
|
20
|
+
get response() {
|
|
21
|
+
return super.get("response");
|
|
22
|
+
}
|
|
23
|
+
set response(value) {
|
|
24
|
+
super.set("response", value);
|
|
25
|
+
}
|
|
26
|
+
get sent() {
|
|
27
|
+
return super.get("sent");
|
|
28
|
+
}
|
|
29
|
+
set sent(value) {
|
|
30
|
+
super.set("sent", value);
|
|
31
|
+
}
|
|
32
|
+
get success() {
|
|
33
|
+
return super.get("success");
|
|
34
|
+
}
|
|
35
|
+
set success(value) {
|
|
36
|
+
super.set("success", value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Core_Email = Core_Email;
|
|
40
|
+
Core_Email.className = "OD3_Core_Email";
|
|
41
|
+
Parse.Object.registerSubclass("OD3_Core_Email", Core_Email);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="parse" />
|
|
2
|
+
export interface Core_TokenAttributes {
|
|
3
|
+
id: string;
|
|
4
|
+
objectId: string;
|
|
5
|
+
createdAt: Date;
|
|
6
|
+
updatedAt: Date;
|
|
7
|
+
key: string;
|
|
8
|
+
payload: any;
|
|
9
|
+
url: string;
|
|
10
|
+
used: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class Core_Token extends Parse.Object<Core_TokenAttributes> {
|
|
13
|
+
static className: string;
|
|
14
|
+
constructor(data?: Partial<Core_TokenAttributes>);
|
|
15
|
+
get key(): string;
|
|
16
|
+
set key(value: string);
|
|
17
|
+
get payload(): any;
|
|
18
|
+
set payload(value: any);
|
|
19
|
+
get url(): string;
|
|
20
|
+
set url(value: string);
|
|
21
|
+
get used(): boolean;
|
|
22
|
+
set used(value: boolean);
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Core_Token = void 0;
|
|
4
|
+
class Core_Token extends Parse.Object {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
super("OD3_Core_Token", data);
|
|
7
|
+
}
|
|
8
|
+
get key() {
|
|
9
|
+
return super.get("key");
|
|
10
|
+
}
|
|
11
|
+
set key(value) {
|
|
12
|
+
super.set("key", value);
|
|
13
|
+
}
|
|
14
|
+
get payload() {
|
|
15
|
+
return super.get("payload");
|
|
16
|
+
}
|
|
17
|
+
set payload(value) {
|
|
18
|
+
super.set("payload", value);
|
|
19
|
+
}
|
|
20
|
+
get url() {
|
|
21
|
+
return super.get("url");
|
|
22
|
+
}
|
|
23
|
+
set url(value) {
|
|
24
|
+
super.set("url", value);
|
|
25
|
+
}
|
|
26
|
+
get used() {
|
|
27
|
+
return super.get("used");
|
|
28
|
+
}
|
|
29
|
+
set used(value) {
|
|
30
|
+
super.set("used", value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Core_Token = Core_Token;
|
|
34
|
+
Core_Token.className = "OD3_Core_Token";
|
|
35
|
+
Parse.Object.registerSubclass("OD3_Core_Token", Core_Token);
|
|
@@ -4,6 +4,7 @@ export interface MIAAS_MDSEndpointAttributes {
|
|
|
4
4
|
objectId: string;
|
|
5
5
|
createdAt: Date;
|
|
6
6
|
updatedAt: Date;
|
|
7
|
+
enabled: boolean;
|
|
7
8
|
endpoint: string;
|
|
8
9
|
endpointSuffix?: string;
|
|
9
10
|
header: any;
|
|
@@ -13,6 +14,8 @@ export interface MIAAS_MDSEndpointAttributes {
|
|
|
13
14
|
export declare class MIAAS_MDSEndpoint extends Parse.Object<MIAAS_MDSEndpointAttributes> {
|
|
14
15
|
static className: string;
|
|
15
16
|
constructor(data?: Partial<MIAAS_MDSEndpointAttributes>);
|
|
17
|
+
get enabled(): boolean;
|
|
18
|
+
set enabled(value: boolean);
|
|
16
19
|
get endpoint(): string;
|
|
17
20
|
set endpoint(value: string);
|
|
18
21
|
get endpointSuffix(): string | undefined;
|
|
@@ -5,6 +5,12 @@ class MIAAS_MDSEndpoint extends Parse.Object {
|
|
|
5
5
|
constructor(data) {
|
|
6
6
|
super("OD3_MIAAS_MDSEndpoint", data);
|
|
7
7
|
}
|
|
8
|
+
get enabled() {
|
|
9
|
+
return super.get("enabled");
|
|
10
|
+
}
|
|
11
|
+
set enabled(value) {
|
|
12
|
+
super.set("enabled", value);
|
|
13
|
+
}
|
|
8
14
|
get endpoint() {
|
|
9
15
|
return super.get("endpoint");
|
|
10
16
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export { BDE_Unit } from "./BDE_Unit";
|
|
|
20
20
|
export type { BDE_UnitAttributes } from "./BDE_Unit";
|
|
21
21
|
export { Config } from "./Config";
|
|
22
22
|
export type { ConfigAttributes } from "./Config";
|
|
23
|
+
export { Core_Email } from "./Core_Email";
|
|
24
|
+
export type { Core_EmailAttributes } from "./Core_Email";
|
|
25
|
+
export { Core_Token } from "./Core_Token";
|
|
26
|
+
export type { Core_TokenAttributes } from "./Core_Token";
|
|
23
27
|
export { Dashboard } from "./Dashboard";
|
|
24
28
|
export type { DashboardAttributes } from "./Dashboard";
|
|
25
29
|
export { GTFS_Agency } from "./GTFS_Agency";
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.WidgetPreset = exports.Widget = exports.VirtualKPI = exports.UserData = exports.TenantTrustedDomain = exports.Tenant = exports.Source = exports.Share = exports.Report = exports.Push = exports.Permission = exports.Notification = exports.NavigationItem = exports.NavigationGroup = exports.Monitoring_Slideshow = exports.Maintenance_Ticket_Source = exports.Maintenance_Ticket_Kanban_State = exports.Maintenance_Ticket_Issuecategory = exports.Maintenance_Ticket = exports.Maintenance_SourceMeta = exports.Maintenance_Schedule_Step = void 0;
|
|
3
|
+
exports.Maintenance_Schedule = exports.Maintenance_Restriction = exports.Maintenance_Priority = exports.Maintenance_Order = exports.Maintenance_Message_Body = exports.Maintenance_Message = exports.Maintenance_Media = exports.Maintenance_Kanban_State = exports.Maintenance_Item = exports.Maintenance_Issuecategory = exports.Maintenance_Frequency = exports.Maintenance_Duedate = exports.Maintenance_Downtime = exports.Maintenance_Article = exports.MIAAS_MDSEndpoint = exports.Log = exports.Language = exports.Knowledge_Video = exports.Knowledge_DocumentPage = exports.Knowledge_Document = exports.Knowledge_Category = exports.Knowledge_Article = exports.Group = exports.GTFS_Wheelchair_Boarding = exports.GTFS_Wheelchair_Accessible = exports.GTFS_Trip = exports.GTFS_Stop_Times = exports.GTFS_Stop = exports.GTFS_Route_Type = exports.GTFS_Route = exports.GTFS_Location_Type = exports.GTFS_Level = exports.GTFS_Direction = exports.GTFS_Calendar = exports.GTFS_Bikes_Allowed = exports.GTFS_Agency = exports.Dashboard = exports.Core_Token = exports.Core_Email = exports.Config = exports.BDE_Unit = exports.BDE_Result = exports.BDE_Page = exports.BDE_ListEntry = exports.BDE_List = exports.BDE_Form = exports.Attachment = exports.AlarmWebhook = exports.AlarmAction = exports.Alarm = void 0;
|
|
4
|
+
exports.WidgetPreset = exports.Widget = exports.VirtualKPI = exports.UserData = exports.TenantTrustedDomain = exports.Tenant = exports.Source = exports.Share = exports.Report = exports.Push = exports.Permission = exports.Notification = exports.NavigationItem = exports.NavigationGroup = exports.Monitoring_Slideshow = exports.Maintenance_Ticket_Source = exports.Maintenance_Ticket_Kanban_State = exports.Maintenance_Ticket_Issuecategory = exports.Maintenance_Ticket = exports.Maintenance_SourceMeta = exports.Maintenance_Schedule_Step = exports.Maintenance_Schedule_Execution_Step = exports.Maintenance_Schedule_Execution = void 0;
|
|
5
5
|
var Alarm_1 = require("./Alarm");
|
|
6
6
|
Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.Alarm; } });
|
|
7
7
|
var AlarmAction_1 = require("./AlarmAction");
|
|
@@ -24,6 +24,10 @@ var BDE_Unit_1 = require("./BDE_Unit");
|
|
|
24
24
|
Object.defineProperty(exports, "BDE_Unit", { enumerable: true, get: function () { return BDE_Unit_1.BDE_Unit; } });
|
|
25
25
|
var Config_1 = require("./Config");
|
|
26
26
|
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
|
|
27
|
+
var Core_Email_1 = require("./Core_Email");
|
|
28
|
+
Object.defineProperty(exports, "Core_Email", { enumerable: true, get: function () { return Core_Email_1.Core_Email; } });
|
|
29
|
+
var Core_Token_1 = require("./Core_Token");
|
|
30
|
+
Object.defineProperty(exports, "Core_Token", { enumerable: true, get: function () { return Core_Token_1.Core_Token; } });
|
|
27
31
|
var Dashboard_1 = require("./Dashboard");
|
|
28
32
|
Object.defineProperty(exports, "Dashboard", { enumerable: true, get: function () { return Dashboard_1.Dashboard; } });
|
|
29
33
|
var GTFS_Agency_1 = require("./GTFS_Agency");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openinc/parse-server-opendash",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.6",
|
|
4
4
|
"description": "Parse Server Cloud Code for open.DASH",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"parse",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"jsonwebtoken": "^9.0.0",
|
|
25
25
|
"node-fetch": "^2.0.0",
|
|
26
26
|
"nodemailer": "^6.0.0",
|
|
27
|
+
"nunjucks": "^3.2.4",
|
|
27
28
|
"pdf-img-convert": "1.0.6",
|
|
28
29
|
"web-push": "^3.0.0"
|
|
29
30
|
},
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@types/node": "^18.0.0",
|
|
33
34
|
"@types/node-fetch": "^2.0.0",
|
|
34
35
|
"@types/nodemailer": "^6.0.0",
|
|
36
|
+
"@types/nunjucks": "^3.2.2",
|
|
35
37
|
"@types/parse": "^3.0.0",
|
|
36
38
|
"@types/web-push": "^3.0.0",
|
|
37
39
|
"typescript": "^5.0.0"
|
package/schema/AlarmAction.json
CHANGED
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
"supportedTypes": {
|
|
23
23
|
"type": "Array",
|
|
24
24
|
"required": false,
|
|
25
|
-
"defaultValue": [
|
|
25
|
+
"defaultValue": [
|
|
26
|
+
"Number",
|
|
27
|
+
"String",
|
|
28
|
+
"Boolean",
|
|
29
|
+
"Geo",
|
|
30
|
+
"Object"
|
|
31
|
+
]
|
|
26
32
|
},
|
|
27
33
|
"target": {
|
|
28
34
|
"type": "String",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fields": {
|
|
3
|
+
"error": {
|
|
4
|
+
"type": "Boolean",
|
|
5
|
+
"defaultValue": false
|
|
6
|
+
},
|
|
7
|
+
"payload": {
|
|
8
|
+
"type": "Object",
|
|
9
|
+
"required": true
|
|
10
|
+
},
|
|
11
|
+
"response": {
|
|
12
|
+
"type": "Object"
|
|
13
|
+
},
|
|
14
|
+
"sent": {
|
|
15
|
+
"type": "Boolean",
|
|
16
|
+
"defaultValue": false
|
|
17
|
+
},
|
|
18
|
+
"success": {
|
|
19
|
+
"type": "Boolean",
|
|
20
|
+
"defaultValue": false
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"classLevelPermissions": {
|
|
24
|
+
"find": {},
|
|
25
|
+
"count": {},
|
|
26
|
+
"get": {},
|
|
27
|
+
"create": {},
|
|
28
|
+
"update": {},
|
|
29
|
+
"delete": {},
|
|
30
|
+
"addField": {},
|
|
31
|
+
"protectedFields": {
|
|
32
|
+
"*": []
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fields": {
|
|
3
|
+
"key": {
|
|
4
|
+
"type": "String",
|
|
5
|
+
"required": true
|
|
6
|
+
},
|
|
7
|
+
"payload": {
|
|
8
|
+
"type": "Object",
|
|
9
|
+
"required": true
|
|
10
|
+
},
|
|
11
|
+
"url": {
|
|
12
|
+
"type": "String",
|
|
13
|
+
"required": true
|
|
14
|
+
},
|
|
15
|
+
"used": {
|
|
16
|
+
"type": "Boolean",
|
|
17
|
+
"defaultValue": false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"classLevelPermissions": {
|
|
21
|
+
"find": {},
|
|
22
|
+
"count": {},
|
|
23
|
+
"get": {},
|
|
24
|
+
"create": {},
|
|
25
|
+
"update": {},
|
|
26
|
+
"delete": {},
|
|
27
|
+
"addField": {},
|
|
28
|
+
"protectedFields": {
|
|
29
|
+
"*": []
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/schema/Tenant.json
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"fields": {
|
|
3
|
-
"
|
|
4
|
-
"type": "Pointer",
|
|
5
|
-
"targetClass": "{{PREFIX}}Source"
|
|
6
|
-
},
|
|
7
|
-
"description": {
|
|
3
|
+
"dataProtectionUrl": {
|
|
8
4
|
"type": "String",
|
|
9
5
|
"required": false,
|
|
10
6
|
"defaultValue": ""
|
|
11
7
|
},
|
|
12
|
-
"
|
|
13
|
-
"type": "
|
|
14
|
-
"
|
|
15
|
-
"defaultValue": ""
|
|
8
|
+
"dataSource": {
|
|
9
|
+
"type": "Pointer",
|
|
10
|
+
"targetClass": "{{PREFIX}}Source"
|
|
16
11
|
},
|
|
17
|
-
"
|
|
12
|
+
"description": {
|
|
18
13
|
"type": "String",
|
|
19
14
|
"required": false,
|
|
20
15
|
"defaultValue": ""
|
|
@@ -28,6 +23,11 @@
|
|
|
28
23
|
"type": "File",
|
|
29
24
|
"required": false
|
|
30
25
|
},
|
|
26
|
+
"imprintUrl": {
|
|
27
|
+
"type": "String",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": ""
|
|
30
|
+
},
|
|
31
31
|
"interactWithOtherTenants": {
|
|
32
32
|
"type": "Boolean",
|
|
33
33
|
"required": false,
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"type": "File",
|
|
42
42
|
"required": false
|
|
43
43
|
},
|
|
44
|
-
"tagPrefix": {
|
|
45
|
-
"type": "String"
|
|
46
|
-
},
|
|
47
44
|
"public": {
|
|
48
45
|
"type": "Boolean",
|
|
49
46
|
"required": false,
|
|
50
47
|
"defaultValue": false
|
|
48
|
+
},
|
|
49
|
+
"tagPrefix": {
|
|
50
|
+
"type": "String"
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"classLevelPermissions": {
|