acebase-server 1.16.2 → 1.18.0
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/README.md +180 -10
- package/bin/acebase-server.js +8 -0
- package/build-vars.js +2 -1
- package/dist/cjs/auth.js +88 -88
- package/dist/cjs/cluster.js +6 -56
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +24 -24
- package/dist/cjs/logger.js +73 -73
- package/dist/cjs/middleware/404.js +14 -14
- package/dist/cjs/middleware/admin-only.js +28 -28
- package/dist/cjs/middleware/cache.js +14 -14
- package/dist/cjs/middleware/connection.js +49 -49
- package/dist/cjs/middleware/context.js +20 -20
- package/dist/cjs/middleware/cors.js +50 -50
- package/dist/cjs/middleware/swagger.js +17 -17
- package/dist/cjs/middleware/user.js +57 -57
- package/dist/cjs/oauth-providers/dropbox.js +109 -109
- package/dist/cjs/oauth-providers/facebook.js +85 -85
- package/dist/cjs/oauth-providers/google.js +119 -119
- package/dist/cjs/oauth-providers/index.js +26 -26
- package/dist/cjs/oauth-providers/instagram.js +80 -80
- package/dist/cjs/oauth-providers/oauth-provider.js +20 -20
- package/dist/cjs/oauth-providers/spotify.js +113 -113
- package/dist/cjs/routes/auth-change-password.js +87 -87
- package/dist/cjs/routes/auth-delete.js +52 -52
- package/dist/cjs/routes/auth-forgot-password.js +77 -77
- package/dist/cjs/routes/auth-reset-password.js +97 -97
- package/dist/cjs/routes/auth-signin.js +46 -46
- package/dist/cjs/routes/auth-signout.js +61 -61
- package/dist/cjs/routes/auth-signup.js +142 -142
- package/dist/cjs/routes/auth-state.js +25 -25
- package/dist/cjs/routes/auth-update.js +131 -131
- package/dist/cjs/routes/auth-verify-email.js +71 -71
- package/dist/cjs/routes/auth.js +57 -54
- package/dist/cjs/routes/data-exists.js +33 -33
- package/dist/cjs/routes/data-export.js +48 -48
- package/dist/cjs/routes/data-get.js +70 -66
- package/dist/cjs/routes/data-import.js +54 -54
- package/dist/cjs/routes/data-index-create.js +42 -42
- package/dist/cjs/routes/data-index-delete.js +33 -33
- package/dist/cjs/routes/data-index-list.js +31 -31
- package/dist/cjs/routes/data-query.js +80 -70
- package/dist/cjs/routes/data-reflect.js +97 -86
- package/dist/cjs/routes/data-schema-get.js +36 -36
- package/dist/cjs/routes/data-schema-set.js +30 -30
- package/dist/cjs/routes/data-schema-test.js +43 -43
- package/dist/cjs/routes/data-schemas-list.js +32 -32
- package/dist/cjs/routes/data-set.js +85 -75
- package/dist/cjs/routes/data-sync-changes.js +81 -67
- package/dist/cjs/routes/data-sync-mutations.js +81 -67
- package/dist/cjs/routes/data-transaction.js +159 -139
- package/dist/cjs/routes/data-update.js +86 -75
- package/dist/cjs/routes/data.js +62 -62
- package/dist/cjs/routes/docs.js +258 -251
- package/dist/cjs/routes/meta-info.js +63 -63
- package/dist/cjs/routes/meta-logs.js +49 -49
- package/dist/cjs/routes/meta-ping.js +11 -11
- package/dist/cjs/routes/meta-stats.js +27 -27
- package/dist/cjs/routes/meta.js +19 -19
- package/dist/cjs/routes/oauth2-init.js +54 -54
- package/dist/cjs/routes/oauth2-refresh.js +42 -42
- package/dist/cjs/routes/oauth2-signin.js +265 -265
- package/dist/cjs/routes/webmanager.js +26 -26
- package/dist/cjs/rules.js +380 -167
- package/dist/cjs/sandbox.js +28 -0
- package/dist/cjs/schema/user.js +24 -24
- package/dist/cjs/server.js +410 -407
- package/dist/cjs/settings/email.js +2 -2
- package/dist/cjs/settings/index.js +175 -172
- package/dist/cjs/shared/clients.js +26 -26
- package/dist/cjs/shared/email.js +2 -2
- package/dist/cjs/shared/env.js +2 -2
- package/dist/cjs/shared/error.js +33 -33
- package/dist/cjs/shared/http.js +28 -28
- package/dist/cjs/shared/password.js +45 -45
- package/dist/cjs/shared/rootpath.js +16 -16
- package/dist/cjs/shared/signin.js +143 -143
- package/dist/cjs/shared/simple-fetch.js +76 -76
- package/dist/cjs/shared/tokens.js +79 -79
- package/dist/cjs/shared/validate.js +61 -61
- package/dist/cjs/start.js +119 -53
- package/dist/cjs/test.js +10 -10
- package/dist/cjs/websocket/index.js +331 -319
- package/dist/cjs/websocket/manager.js +15 -15
- package/dist/cjs/websocket/socket.io.js +76 -76
- package/dist/esm/auth.js +75 -75
- package/dist/esm/cluster.js +6 -54
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/logger.js +51 -51
- package/dist/esm/middleware/404.js +10 -10
- package/dist/esm/middleware/admin-only.js +24 -24
- package/dist/esm/middleware/cache.js +10 -10
- package/dist/esm/middleware/connection.js +45 -45
- package/dist/esm/middleware/context.js +16 -16
- package/dist/esm/middleware/cors.js +44 -44
- package/dist/esm/middleware/swagger.js +13 -13
- package/dist/esm/middleware/user.js +44 -44
- package/dist/esm/oauth-providers/dropbox.js +90 -90
- package/dist/esm/oauth-providers/facebook.js +66 -66
- package/dist/esm/oauth-providers/google.js +96 -96
- package/dist/esm/oauth-providers/index.js +18 -18
- package/dist/esm/oauth-providers/instagram.js +61 -61
- package/dist/esm/oauth-providers/oauth-provider.js +16 -16
- package/dist/esm/oauth-providers/spotify.js +92 -92
- package/dist/esm/routes/auth-change-password.js +72 -72
- package/dist/esm/routes/auth-delete.js +37 -37
- package/dist/esm/routes/auth-forgot-password.js +62 -62
- package/dist/esm/routes/auth-reset-password.js +81 -81
- package/dist/esm/routes/auth-signin.js +33 -33
- package/dist/esm/routes/auth-signout.js +47 -47
- package/dist/esm/routes/auth-signup.js +127 -127
- package/dist/esm/routes/auth-state.js +12 -12
- package/dist/esm/routes/auth-update.js +116 -116
- package/dist/esm/routes/auth-verify-email.js +57 -57
- package/dist/esm/routes/auth.js +53 -50
- package/dist/esm/routes/data-exists.js +20 -20
- package/dist/esm/routes/data-export.js +35 -35
- package/dist/esm/routes/data-get.js +56 -52
- package/dist/esm/routes/data-import.js +41 -41
- package/dist/esm/routes/data-index-create.js +28 -28
- package/dist/esm/routes/data-index-delete.js +20 -20
- package/dist/esm/routes/data-index-list.js +18 -18
- package/dist/esm/routes/data-query.js +66 -56
- package/dist/esm/routes/data-reflect.js +83 -72
- package/dist/esm/routes/data-schema-get.js +23 -23
- package/dist/esm/routes/data-schema-set.js +17 -17
- package/dist/esm/routes/data-schema-test.js +29 -29
- package/dist/esm/routes/data-schemas-list.js +19 -19
- package/dist/esm/routes/data-set.js +70 -60
- package/dist/esm/routes/data-sync-changes.js +67 -53
- package/dist/esm/routes/data-sync-mutations.js +67 -53
- package/dist/esm/routes/data-transaction.js +142 -123
- package/dist/esm/routes/data-update.js +71 -60
- package/dist/esm/routes/data.js +58 -58
- package/dist/esm/routes/docs.js +252 -245
- package/dist/esm/routes/meta-info.js +59 -59
- package/dist/esm/routes/meta-logs.js +35 -35
- package/dist/esm/routes/meta-ping.js +7 -7
- package/dist/esm/routes/meta-stats.js +14 -14
- package/dist/esm/routes/meta.js +15 -15
- package/dist/esm/routes/oauth2-init.js +41 -41
- package/dist/esm/routes/oauth2-refresh.js +29 -29
- package/dist/esm/routes/oauth2-signin.js +251 -251
- package/dist/esm/routes/webmanager.js +22 -22
- package/dist/esm/rules.js +374 -163
- package/dist/esm/sandbox.js +12 -0
- package/dist/esm/schema/user.js +19 -19
- package/dist/esm/server.js +395 -387
- package/dist/esm/settings/email.js +1 -1
- package/dist/esm/settings/index.js +168 -165
- package/dist/esm/shared/clients.js +22 -22
- package/dist/esm/shared/email.js +1 -1
- package/dist/esm/shared/env.js +1 -1
- package/dist/esm/shared/error.js +25 -25
- package/dist/esm/shared/http.js +22 -22
- package/dist/esm/shared/password.js +38 -38
- package/dist/esm/shared/rootpath.js +13 -13
- package/dist/esm/shared/signin.js +128 -128
- package/dist/esm/shared/simple-fetch.js +59 -59
- package/dist/esm/shared/tokens.js +72 -72
- package/dist/esm/shared/validate.js +41 -41
- package/dist/esm/start.js +116 -50
- package/dist/esm/test.js +8 -8
- package/dist/esm/websocket/index.js +313 -302
- package/dist/esm/websocket/manager.js +11 -11
- package/dist/esm/websocket/socket.io.js +71 -71
- package/dist/types/auth.d.ts +3 -3
- package/dist/types/cluster.d.ts +6 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/logger.d.ts +35 -35
- package/dist/types/middleware/404.d.ts +7 -7
- package/dist/types/middleware/admin-only.d.ts +19 -19
- package/dist/types/middleware/cache.d.ts +3 -3
- package/dist/types/middleware/connection.d.ts +7 -7
- package/dist/types/middleware/context.d.ts +3 -3
- package/dist/types/middleware/cors.d.ts +25 -25
- package/dist/types/middleware/swagger.d.ts +3 -3
- package/dist/types/middleware/user.d.ts +2 -2
- package/dist/types/oauth-providers/dropbox.d.ts +52 -52
- package/dist/types/oauth-providers/facebook.d.ts +41 -41
- package/dist/types/oauth-providers/google.d.ts +43 -43
- package/dist/types/oauth-providers/index.d.ts +10 -10
- package/dist/types/oauth-providers/instagram.d.ts +50 -50
- package/dist/types/oauth-providers/oauth-provider.d.ts +74 -74
- package/dist/types/oauth-providers/spotify.d.ts +53 -53
- package/dist/types/routes/auth-change-password.d.ts +20 -20
- package/dist/types/routes/auth-delete.d.ts +16 -16
- package/dist/types/routes/auth-forgot-password.d.ts +16 -16
- package/dist/types/routes/auth-reset-password.d.ts +23 -23
- package/dist/types/routes/auth-signin.d.ts +24 -24
- package/dist/types/routes/auth-signout.d.ts +14 -14
- package/dist/types/routes/auth-signup.d.ts +32 -32
- package/dist/types/routes/auth-state.d.ts +13 -13
- package/dist/types/routes/auth-update.d.ts +33 -33
- package/dist/types/routes/auth-verify-email.d.ts +21 -21
- package/dist/types/routes/auth.d.ts +6 -6
- package/dist/types/routes/data-exists.d.ts +9 -9
- package/dist/types/routes/data-export.d.ts +10 -10
- package/dist/types/routes/data-get.d.ts +14 -14
- package/dist/types/routes/data-import.d.ts +13 -13
- package/dist/types/routes/data-index-create.d.ts +51 -51
- package/dist/types/routes/data-index-delete.d.ts +17 -17
- package/dist/types/routes/data-index-list.d.ts +21 -21
- package/dist/types/routes/data-query.d.ts +49 -49
- package/dist/types/routes/data-reflect.d.ts +29 -29
- package/dist/types/routes/data-schema-get.d.ts +11 -11
- package/dist/types/routes/data-schema-set.d.ts +20 -19
- package/dist/types/routes/data-schema-test.d.ts +19 -19
- package/dist/types/routes/data-schemas-list.d.ts +11 -11
- package/dist/types/routes/data-set.d.ts +27 -27
- package/dist/types/routes/data-sync-changes.d.ts +25 -28
- package/dist/types/routes/data-sync-mutations.d.ts +25 -28
- package/dist/types/routes/data-transaction.d.ts +34 -34
- package/dist/types/routes/data-update.d.ts +27 -27
- package/dist/types/routes/data.d.ts +3 -3
- package/dist/types/routes/docs.d.ts +3 -3
- package/dist/types/routes/meta-info.d.ts +11 -11
- package/dist/types/routes/meta-logs.d.ts +20 -20
- package/dist/types/routes/meta-ping.d.ts +7 -7
- package/dist/types/routes/meta-stats.d.ts +13 -13
- package/dist/types/routes/meta.d.ts +3 -3
- package/dist/types/routes/oauth2-init.d.ts +13 -13
- package/dist/types/routes/oauth2-refresh.d.ts +17 -17
- package/dist/types/routes/oauth2-signin.d.ts +15 -15
- package/dist/types/routes/webmanager.d.ts +3 -3
- package/dist/types/rules.d.ts +73 -34
- package/dist/types/sandbox.d.ts +3 -0
- package/dist/types/schema/user.d.ts +85 -85
- package/dist/types/server.d.ts +117 -111
- package/dist/types/settings/email.d.ts +14 -14
- package/dist/types/settings/index.d.ts +195 -187
- package/dist/types/shared/clients.d.ts +46 -46
- package/dist/types/shared/email.d.ts +34 -34
- package/dist/types/shared/env.d.ts +47 -44
- package/dist/types/shared/error.d.ts +15 -15
- package/dist/types/shared/http.d.ts +22 -21
- package/dist/types/shared/password.d.ts +19 -19
- package/dist/types/shared/rootpath.d.ts +2 -2
- package/dist/types/shared/signin.d.ts +31 -31
- package/dist/types/shared/simple-fetch.d.ts +21 -21
- package/dist/types/shared/tokens.d.ts +24 -24
- package/dist/types/shared/validate.d.ts +22 -22
- package/dist/types/start.d.ts +1 -1
- package/dist/types/test.d.ts +1 -1
- package/dist/types/websocket/index.d.ts +6 -6
- package/dist/types/websocket/manager.d.ts +99 -99
- package/dist/types/websocket/socket.io.d.ts +10 -10
- package/package.json +7 -4
- package/src/routes/data-schema-set.yaml +4 -0
- package/src/routes/data-set.yaml +5 -5
- package/src/routes/data-update.yaml +4 -4
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.invalidSettingsError = exports.invalidPictureError = exports.invalidPasswordError = exports.invalidDisplayNameError = exports.emailOrUsernameExistsError = exports.usernameExistsError = exports.emailExistsError = exports.invalidUsernameError = exports.invalidEmailError = exports.isValidSettings = exports.isValidPicture = exports.isValidPassword = exports.isValidDisplayName = exports.isValidUsername = exports.isValidNewUsername = exports.isValidNewEmailAddress = exports.isValidEmail = void 0;
|
|
13
|
-
const isValidEmail = (email) => {
|
|
14
|
-
return /[a-z0-9_.+]+@([a-z0-9\-]+\.)+[a-z]{2,}/i.test(email);
|
|
15
|
-
};
|
|
16
|
-
exports.isValidEmail = isValidEmail;
|
|
17
|
-
const isValidNewEmailAddress = (authRef, email) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const exists = yield authRef.query().filter('email', '==', email).exists();
|
|
19
|
-
return !exists;
|
|
20
|
-
});
|
|
21
|
-
exports.isValidNewEmailAddress = isValidNewEmailAddress;
|
|
22
|
-
const isValidNewUsername = (authRef, username) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const exists = yield authRef.query().filter('username', '==', username).exists();
|
|
24
|
-
return !exists;
|
|
25
|
-
});
|
|
26
|
-
exports.isValidNewUsername = isValidNewUsername;
|
|
27
|
-
const isValidUsername = (username) => {
|
|
28
|
-
return username !== 'admin' && typeof username === 'string' && username.length >= 5 && /^[a-z0-9]+$/.test(username);
|
|
29
|
-
};
|
|
30
|
-
exports.isValidUsername = isValidUsername;
|
|
31
|
-
const isValidDisplayName = (displayName) => {
|
|
32
|
-
return typeof displayName === 'string' && displayName.length >= 5;
|
|
33
|
-
};
|
|
34
|
-
exports.isValidDisplayName = isValidDisplayName;
|
|
35
|
-
const isValidPassword = (password) => {
|
|
36
|
-
// return typeof password === 'string' && password.length >= 8 && password.indexOf(' ') < 0 && /[0-9]/.test(password) && /[a-z]/.test(password) && /[A-Z]/.test(password);
|
|
37
|
-
return typeof password === 'string' && password.length >= 8 && password.indexOf(' ') < 0; // Let client application set their own password rules. Keep minimum length of 8 and no spaces requirement.
|
|
38
|
-
};
|
|
39
|
-
exports.isValidPassword = isValidPassword;
|
|
40
|
-
const isValidPicture = (picture) => {
|
|
41
|
-
return picture === null || (typeof picture === 'object' && typeof picture.url === 'string' && typeof picture.width === 'number' && typeof picture.height === 'number');
|
|
42
|
-
};
|
|
43
|
-
exports.isValidPicture = isValidPicture;
|
|
44
|
-
const isValidSettings = (settings) => {
|
|
45
|
-
return typeof settings === 'undefined'
|
|
46
|
-
|| (typeof settings === 'object'
|
|
47
|
-
&& Object.keys(settings).length <= 100 // max 100 settings
|
|
48
|
-
&& Object.keys(settings).map(key => typeof settings[key]).every(t => ['string', 'number', 'boolean'].indexOf(t) >= 0) // only string, number, boolean values
|
|
49
|
-
&& Object.keys(settings).filter(key => typeof settings[key] === 'string').every(key => settings[key].length <= 250) // strings values <= 250 chars
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
exports.isValidSettings = isValidSettings;
|
|
53
|
-
exports.invalidEmailError = { code: 'invalid_email', message: 'Invalid email address' };
|
|
54
|
-
exports.invalidUsernameError = { code: 'invalid_username', message: 'Invalid username, must be at least 5 characters and can only contain lowercase characters a-z and 0-9' };
|
|
55
|
-
exports.emailExistsError = { code: 'email_conflict', message: 'Account with email address exists already' };
|
|
56
|
-
exports.usernameExistsError = { code: 'username_conflict', message: 'Account with username exists already' };
|
|
57
|
-
exports.emailOrUsernameExistsError = { code: 'conflict', message: `Account with username and/or email already exists` };
|
|
58
|
-
exports.invalidDisplayNameError = { code: 'invalid_display_name', message: 'Invalid display_name, must be at least 5 characters' };
|
|
59
|
-
exports.invalidPasswordError = { code: 'invalid_password', message: 'Invalid password, must be at least 8 characters and cannot contain spaces' };
|
|
60
|
-
exports.invalidPictureError = { code: 'invalid_picture', message: 'Invalid picture, must be an object with url, width and height properties' };
|
|
61
|
-
exports.invalidSettingsError = { code: 'invalid_settings', message: 'Invalid settings, must be an object and contain only string, number and/or boolean values. Additionaly, string values can have a maximum length of 250, and a maximum of 100 settings can be added' };
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.invalidSettingsError = exports.invalidPictureError = exports.invalidPasswordError = exports.invalidDisplayNameError = exports.emailOrUsernameExistsError = exports.usernameExistsError = exports.emailExistsError = exports.invalidUsernameError = exports.invalidEmailError = exports.isValidSettings = exports.isValidPicture = exports.isValidPassword = exports.isValidDisplayName = exports.isValidUsername = exports.isValidNewUsername = exports.isValidNewEmailAddress = exports.isValidEmail = void 0;
|
|
13
|
+
const isValidEmail = (email) => {
|
|
14
|
+
return /[a-z0-9_.+]+@([a-z0-9\-]+\.)+[a-z]{2,}/i.test(email);
|
|
15
|
+
};
|
|
16
|
+
exports.isValidEmail = isValidEmail;
|
|
17
|
+
const isValidNewEmailAddress = (authRef, email) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const exists = yield authRef.query().filter('email', '==', email).exists();
|
|
19
|
+
return !exists;
|
|
20
|
+
});
|
|
21
|
+
exports.isValidNewEmailAddress = isValidNewEmailAddress;
|
|
22
|
+
const isValidNewUsername = (authRef, username) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const exists = yield authRef.query().filter('username', '==', username).exists();
|
|
24
|
+
return !exists;
|
|
25
|
+
});
|
|
26
|
+
exports.isValidNewUsername = isValidNewUsername;
|
|
27
|
+
const isValidUsername = (username) => {
|
|
28
|
+
return username !== 'admin' && typeof username === 'string' && username.length >= 5 && /^[a-z0-9]+$/.test(username);
|
|
29
|
+
};
|
|
30
|
+
exports.isValidUsername = isValidUsername;
|
|
31
|
+
const isValidDisplayName = (displayName) => {
|
|
32
|
+
return typeof displayName === 'string' && displayName.length >= 5;
|
|
33
|
+
};
|
|
34
|
+
exports.isValidDisplayName = isValidDisplayName;
|
|
35
|
+
const isValidPassword = (password) => {
|
|
36
|
+
// return typeof password === 'string' && password.length >= 8 && password.indexOf(' ') < 0 && /[0-9]/.test(password) && /[a-z]/.test(password) && /[A-Z]/.test(password);
|
|
37
|
+
return typeof password === 'string' && password.length >= 8 && password.indexOf(' ') < 0; // Let client application set their own password rules. Keep minimum length of 8 and no spaces requirement.
|
|
38
|
+
};
|
|
39
|
+
exports.isValidPassword = isValidPassword;
|
|
40
|
+
const isValidPicture = (picture) => {
|
|
41
|
+
return picture === null || (typeof picture === 'object' && typeof picture.url === 'string' && typeof picture.width === 'number' && typeof picture.height === 'number');
|
|
42
|
+
};
|
|
43
|
+
exports.isValidPicture = isValidPicture;
|
|
44
|
+
const isValidSettings = (settings) => {
|
|
45
|
+
return typeof settings === 'undefined'
|
|
46
|
+
|| (typeof settings === 'object'
|
|
47
|
+
&& Object.keys(settings).length <= 100 // max 100 settings
|
|
48
|
+
&& Object.keys(settings).map(key => typeof settings[key]).every(t => ['string', 'number', 'boolean'].indexOf(t) >= 0) // only string, number, boolean values
|
|
49
|
+
&& Object.keys(settings).filter(key => typeof settings[key] === 'string').every(key => settings[key].length <= 250) // strings values <= 250 chars
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
exports.isValidSettings = isValidSettings;
|
|
53
|
+
exports.invalidEmailError = { code: 'invalid_email', message: 'Invalid email address' };
|
|
54
|
+
exports.invalidUsernameError = { code: 'invalid_username', message: 'Invalid username, must be at least 5 characters and can only contain lowercase characters a-z and 0-9' };
|
|
55
|
+
exports.emailExistsError = { code: 'email_conflict', message: 'Account with email address exists already' };
|
|
56
|
+
exports.usernameExistsError = { code: 'username_conflict', message: 'Account with username exists already' };
|
|
57
|
+
exports.emailOrUsernameExistsError = { code: 'conflict', message: `Account with username and/or email already exists` };
|
|
58
|
+
exports.invalidDisplayNameError = { code: 'invalid_display_name', message: 'Invalid display_name, must be at least 5 characters' };
|
|
59
|
+
exports.invalidPasswordError = { code: 'invalid_password', message: 'Invalid password, must be at least 8 characters and cannot contain spaces' };
|
|
60
|
+
exports.invalidPictureError = { code: 'invalid_picture', message: 'Invalid picture, must be an object with url, width and height properties' };
|
|
61
|
+
exports.invalidSettingsError = { code: 'invalid_settings', message: 'Invalid settings, must be an object and contain only string, number and/or boolean values. Additionaly, string values can have a maximum length of 250, and a maximum of 100 settings can be added' };
|
|
62
62
|
//# sourceMappingURL=validate.js.map
|
package/dist/cjs/start.js
CHANGED
|
@@ -1,54 +1,120 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const server_1 = require("./server");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const server_1 = require("./server");
|
|
4
|
+
/*
|
|
5
|
+
|
|
6
|
+
Use environment variables or pass arguments to this script to start an AceBase server
|
|
7
|
+
instance from the command-line.
|
|
8
|
+
|
|
9
|
+
Command-line arguments format:
|
|
10
|
+
`npx acebase-server start DBNAME=mydb HOST=localhost PORT=3000`
|
|
11
|
+
You can use all variables mentioned below (without 'ACEBASE_' prefix)
|
|
12
|
+
|
|
13
|
+
All environment variables MUST be prefixed with 'ACEBASE_' (except for PORT if ACEBASE_PORT is not specified).
|
|
14
|
+
Currently available environment variables:
|
|
15
|
+
|
|
16
|
+
# File and network settings:
|
|
17
|
+
ACEBASE_DBNAME='mydb'
|
|
18
|
+
ACEBASE_DBPATH='.'
|
|
19
|
+
ACEBASE_HOST='localhost'
|
|
20
|
+
ACEBASE_PORT='3000'
|
|
21
|
+
ACEBASE_ROOT_PATH=''
|
|
22
|
+
|
|
23
|
+
# Transaction logging settings:
|
|
24
|
+
ACEBASE_TXLOG='true'
|
|
25
|
+
ACEBASE_TXDAYS='30'
|
|
26
|
+
|
|
27
|
+
# Auth settings:
|
|
28
|
+
ACEBASE_AUTH='true'
|
|
29
|
+
ACEBASE_AUTH_USER_SIGNUP='true'
|
|
30
|
+
ACEBASE_AUTH_DEFAULT_ACCESS_RULE='deny'
|
|
31
|
+
ACEBASE_AUTH_DEFAULT_ADMIN_PASSWORD=''
|
|
32
|
+
ACEBASE_AUTH_NEW_USER_RATE_LIMIT='0'
|
|
33
|
+
ACEBASE_AUTH_SEPARATE_DB='false'
|
|
34
|
+
ACEBASE_AUTH_TOKENS_EXPIRE='0'
|
|
35
|
+
|
|
36
|
+
# IPC configuration for single machine clusters
|
|
37
|
+
ACEBASE_IPC='socket'
|
|
38
|
+
|
|
39
|
+
# IPC configuration for multiple machine clusters (Make sure there is ONLY ONE 'master' instance)
|
|
40
|
+
ACEBASE_IPC_PORT='9163'
|
|
41
|
+
ACEBASE_IPC_HOST='ipc.example.com'
|
|
42
|
+
ACEBASE_IPC_ROLE='master'
|
|
43
|
+
ACEBASE_IPC_SSL='true'
|
|
44
|
+
ACEBASE_IPC_TOKEN='secret'
|
|
45
|
+
|
|
46
|
+
*/
|
|
47
|
+
// If one executes "node start.js [dbname=name] [host=ip] [port=nr]"
|
|
48
|
+
function getVariable(name, defaultValue) {
|
|
49
|
+
// Checks if an argument with the name was passed,
|
|
50
|
+
// or if an environment variable was set with that name,
|
|
51
|
+
// else it will return the default value
|
|
52
|
+
name = name.toUpperCase();
|
|
53
|
+
const arg = process.argv.find(arg => arg.toUpperCase().startsWith(`${name}=`));
|
|
54
|
+
if (arg) {
|
|
55
|
+
return arg.split('=')[1];
|
|
56
|
+
}
|
|
57
|
+
const envName = `ACEBASE_${name}`;
|
|
58
|
+
if (typeof process.env[envName] !== 'undefined') {
|
|
59
|
+
return process.env[envName];
|
|
60
|
+
}
|
|
61
|
+
if (name === 'PORT' && typeof process.env[name] !== 'undefined') {
|
|
62
|
+
return process.env[name];
|
|
63
|
+
}
|
|
64
|
+
return defaultValue;
|
|
65
|
+
}
|
|
66
|
+
const options = {
|
|
67
|
+
host: getVariable('HOST', 'localhost'),
|
|
68
|
+
port: +getVariable('PORT', 3000),
|
|
69
|
+
path: getVariable('DBPATH', '.'),
|
|
70
|
+
rootPath: getVariable('ROOT_PATH', ''),
|
|
71
|
+
};
|
|
72
|
+
// Check if we should use a remote IPC server, let AceBase use a local IPC socket otherwise
|
|
73
|
+
const ipcPort = +getVariable('IPC_PORT', 0);
|
|
74
|
+
if (ipcPort > 0) {
|
|
75
|
+
const role = getVariable('IPC_ROLE');
|
|
76
|
+
if (!['master', 'worker'].includes(role)) {
|
|
77
|
+
throw new Error('IPC_ROLE must be either "master" or "worker"');
|
|
78
|
+
}
|
|
79
|
+
options.ipc = {
|
|
80
|
+
host: getVariable('IPC_HOST'),
|
|
81
|
+
port: ipcPort,
|
|
82
|
+
ssl: +getVariable('IPC_SSL', 0) === 1,
|
|
83
|
+
token: getVariable('IPC_TOKEN'),
|
|
84
|
+
role,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else if (getVariable('IPC') === 'socket') {
|
|
88
|
+
// Use local IPC socket, will become default soon
|
|
89
|
+
options.ipc = 'socket';
|
|
90
|
+
}
|
|
91
|
+
// Check if transaction logging should be enabled (not enabled by default)
|
|
92
|
+
if (getVariable('TXLOG', 'false') === 'true' || +getVariable('TXLOG', 0) === 1) {
|
|
93
|
+
options.transactions = {
|
|
94
|
+
log: true,
|
|
95
|
+
maxAge: +getVariable('TXDAYS', 30),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Check if authentication should be enabled (default)
|
|
99
|
+
if (getVariable('AUTH', 'true') === 'true' || +getVariable('AUTH', 1) === 1) {
|
|
100
|
+
options.authentication = {
|
|
101
|
+
enabled: true,
|
|
102
|
+
allowUserSignup: +getVariable('AUTH_USER_SIGNUP', 1) === 1,
|
|
103
|
+
defaultAccessRule: getVariable('AUTH_DEFAULT_ACCESS_RULE'),
|
|
104
|
+
defaultAdminPassword: getVariable('AUTH_DEFAULT_ADMIN_PASSWORD'),
|
|
105
|
+
newUserRateLimit: +getVariable('AUTH_NEW_USER_RATE_LIMIT', 0),
|
|
106
|
+
separateDb: getVariable('AUTH_SEPARATE_DB', false),
|
|
107
|
+
tokensExpire: +getVariable('AUTH_TOKENS_EXPIRE', 0), // No implemented yet
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
options.authentication = { enabled: false };
|
|
112
|
+
}
|
|
113
|
+
const dbname = getVariable('DBNAME', 'default');
|
|
114
|
+
const server = new server_1.AceBaseServer(dbname, options);
|
|
115
|
+
server.once('ready', () => {
|
|
116
|
+
var _a;
|
|
117
|
+
server.debug.log(`AceBase server running`);
|
|
118
|
+
(_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready'); // When using pm2, you can use --wait-ready flag (see https://pm2.keymetrics.io/docs/usage/signals-clean-restart/)
|
|
119
|
+
});
|
|
54
120
|
//# sourceMappingURL=start.js.map
|
package/dist/cjs/test.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Starts a test server for debugging sessions
|
|
4
|
-
const server_1 = require("./server");
|
|
5
|
-
// Make sure development environment is set
|
|
6
|
-
process.env.NODE_ENV = 'development';
|
|
7
|
-
const server = new server_1.AceBaseServer('default', { logLevel: 'verbose', host: 'localhost', port: 3000, path: '.' });
|
|
8
|
-
server.once('ready', () => {
|
|
9
|
-
console.log(`Ready to debug!`);
|
|
10
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Starts a test server for debugging sessions
|
|
4
|
+
const server_1 = require("./server");
|
|
5
|
+
// Make sure development environment is set
|
|
6
|
+
process.env.NODE_ENV = 'development';
|
|
7
|
+
const server = new server_1.AceBaseServer('default', { logLevel: 'verbose', host: 'localhost', port: 3000, path: '.' });
|
|
8
|
+
server.once('ready', () => {
|
|
9
|
+
console.log(`Ready to debug!`);
|
|
10
|
+
});
|
|
11
11
|
//# sourceMappingURL=test.js.map
|