acebase-server 1.18.0 → 1.18.2

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 CHANGED
@@ -93,7 +93,7 @@ The following `authentication` settings are available:
93
93
 
94
94
  ### Setup authorization rules
95
95
 
96
- If you enabled authentication, you can also define access rules for your data. Using rules, you can allow or deny specific (or anonymous) users _read_ and/or _write_ access to your data. These rules are identical to those used by [Firebase](https://firebase.google.com/docs/database/security/), but reading current data in the db works a little differently. In addition, ".schema" rules allow for an easy and clean way to validate data being written, while ".validate" rules allow you to check existing data and use more advanced business logic. The rules are saved in a file called _rules.json_ in your database directory, but can be overridden and extended programmatically (see [Coding your rules](#coding-your-rules)). The default rules written to the file are determined by the `defaultAccessRule` authentication setting at the first server launch with `authentication` enabled.
96
+ If you enabled authentication, you can also define access rules for your data. Using rules, you can allow or deny specific (or anonymous) users _read_ and/or _write_ access to your data. These rules are similar to those used by [Firebase](https://firebase.google.com/docs/database/security/), but they are not identical. AceBase has easy ".schema" rules allow for an easy and clean way to validate data being written, while ".validate" rules allow you to check existing data and use more advanced business logic. The rules can be saved to the _rules.json_ file in your database directory, and can be overridden and extended programmatically from within your own code: ".validate" rules are coded in JavaScript (see [Coding your rules](#coding-your-rules)). The default rules written to the file are determined by the `defaultAccessRule` authentication setting at the first server launch with `authentication` enabled.
97
97
 
98
98
  The default _rules.json_ file content is based on the value of the `defaultAccessRule` setting, possible values are:
99
99
  * `"auth"`: Only allow authenticated users read/write access to the database
@@ -336,7 +336,7 @@ _(NEW v1.17.0+)_
336
336
  Instead of writing your rules into the `rules.json` file on your server, it is also possible to configure them in your code. Any rule you set with code will override or augment existing rules found in the `rules.json` file, so can use both. Coding your rules has a number of advantages:
337
337
  * You can use the same rule definitions and functions on multiple paths without copy/pasting
338
338
  * You can code them in your favorite editor
339
- * You can use running server values and cached data in your rules, such as `process.env` and vars like `maintanceMode`
339
+ * You can use running server values and cached data in your rules, such as `process.env` and vars like `maintenanceMode`
340
340
  * Rules become debuggable!
341
341
 
342
342
  To add a rule in your code, use the following syntax:
package/build-vars.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // Executed by npm "version" hook
2
2
  const { readFileSync, writeFileSync } = require('fs');
3
- const { execSync } = require('child_process');
4
3
  const packageInfo = require('./package.json');
5
4
 
6
5
  const sources = ['routes/meta-info', 'routes/docs'];
@@ -13,5 +12,3 @@ files.forEach(file => {
13
12
  console.log(`Replaced variable %SERVER_VERSION% with ${packageInfo.version} in ${file}`);
14
13
  }
15
14
  });
16
-
17
- execSync(`git add dist`);
@@ -37,7 +37,7 @@ class DropboxAuthProvider extends oauth_provider_1.OAuth2Provider {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
38
  // Return url to get authorization code with
39
39
  const options = info.options || {};
40
- const authUrl = `https://www.dropbox.com/oauth2/authorize?response_type=code&token_access_type=offline&client_id=${this.settings.client_id}&scope=${encodeURIComponent(this.settings.scopes.join(' '))}&redirect_uri=${encodeURIComponent(info.redirect_url)}&locale=${options.locale || ''}&require_role=${options.require_role || ''}&force_reauthentication=${options.force_reauthentication === true}&force_reapprove=${options.force_reapprove === true}&disable_signup=${options.disable_signup === true}&state=${encodeURIComponent(info.state)}`;
40
+ const authUrl = `https://www.dropbox.com/oauth2/authorize?response_type=code&token_access_type=offline&client_id=${this.settings.client_id}&scope=${encodeURIComponent(this.settings.scopes.join(' '))}&redirect_uri=${encodeURIComponent(info.redirect_url)}${options.locale ? `&locale=${options.locale}` : ''}${options.require_role ? `&require_role=${options.require_role}` : ''}&force_reauthentication=${options.force_reauthentication === true}&force_reapprove=${options.force_reapprove === true}&disable_signup=${options.disable_signup === true}&state=${encodeURIComponent(info.state)}`;
41
41
  return authUrl;
42
42
  });
43
43
  }
@@ -22,6 +22,7 @@ const addRoute = (env) => {
22
22
  if (!access.allow) {
23
23
  return (0, error_1.sendUnauthorizedError)(res, access.code, access.message);
24
24
  }
25
+ // const options: { include?: string[]; exclude?: string[]; child_objects?: boolean } = {};
25
26
  const options = {};
26
27
  if (req.query.include) {
27
28
  options.include = req.query.include.split(',');
@@ -29,8 +30,8 @@ const addRoute = (env) => {
29
30
  if (req.query.exclude) {
30
31
  options.exclude = req.query.exclude.split(',');
31
32
  }
32
- if (typeof req.query.child_objects === 'boolean') {
33
- options.child_objects = req.query.child_objects;
33
+ if (['true', 'false'].includes(req.query.child_objects)) {
34
+ options.child_objects = req.query.child_objects === 'true';
34
35
  }
35
36
  if (path === '') {
36
37
  // If user has access to the root of database (NOT recommended for others than admin...)
@@ -19,7 +19,7 @@ const addRoute = (env) => {
19
19
  info: {
20
20
  title: 'AceBase Server',
21
21
  description: 'AceBase Server API endpoint documentation and test environment. This documentation is available on the server because it is running in development mode. To disable this, set your NODE_ENV environment variable to production. Many endpoints require you to authenticate using Bearer authentication. Use the _/auth/{dbname}/signin_ endpoint to obtain an access token, then click the _Authorize_ button and paste your token into the input field. For more information about AceBase, see GitHub',
22
- version: '1.18.0',
22
+ version: '1.18.2',
23
23
  contact: {
24
24
  name: 'AceBase API Support',
25
25
  email: 'me@appy.one',
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addRoute = void 0;
4
4
  const os = require("os");
5
- const SERVER_VERSION = '1.18.0'; // Loaded from package.json by npm scripts
5
+ const SERVER_VERSION = '1.18.2'; // Loaded from package.json by npm scripts
6
6
  const addRoute = (env) => {
7
7
  // Add info endpoint
8
8
  env.router.get(`/info/${env.db.name}`, (req, res) => {
@@ -24,7 +24,7 @@ export class DropboxAuthProvider extends OAuth2Provider {
24
24
  async init(info) {
25
25
  // Return url to get authorization code with
26
26
  const options = info.options || {};
27
- const authUrl = `https://www.dropbox.com/oauth2/authorize?response_type=code&token_access_type=offline&client_id=${this.settings.client_id}&scope=${encodeURIComponent(this.settings.scopes.join(' '))}&redirect_uri=${encodeURIComponent(info.redirect_url)}&locale=${options.locale || ''}&require_role=${options.require_role || ''}&force_reauthentication=${options.force_reauthentication === true}&force_reapprove=${options.force_reapprove === true}&disable_signup=${options.disable_signup === true}&state=${encodeURIComponent(info.state)}`;
27
+ const authUrl = `https://www.dropbox.com/oauth2/authorize?response_type=code&token_access_type=offline&client_id=${this.settings.client_id}&scope=${encodeURIComponent(this.settings.scopes.join(' '))}&redirect_uri=${encodeURIComponent(info.redirect_url)}${options.locale ? `&locale=${options.locale}` : ''}${options.require_role ? `&require_role=${options.require_role}` : ''}&force_reauthentication=${options.force_reauthentication === true}&force_reapprove=${options.force_reapprove === true}&disable_signup=${options.disable_signup === true}&state=${encodeURIComponent(info.state)}`;
28
28
  return authUrl;
29
29
  }
30
30
  async getAccessToken(params) {
@@ -9,6 +9,7 @@ export const addRoute = (env) => {
9
9
  if (!access.allow) {
10
10
  return sendUnauthorizedError(res, access.code, access.message);
11
11
  }
12
+ // const options: { include?: string[]; exclude?: string[]; child_objects?: boolean } = {};
12
13
  const options = {};
13
14
  if (req.query.include) {
14
15
  options.include = req.query.include.split(',');
@@ -16,8 +17,8 @@ export const addRoute = (env) => {
16
17
  if (req.query.exclude) {
17
18
  options.exclude = req.query.exclude.split(',');
18
19
  }
19
- if (typeof req.query.child_objects === 'boolean') {
20
- options.child_objects = req.query.child_objects;
20
+ if (['true', 'false'].includes(req.query.child_objects)) {
21
+ options.child_objects = req.query.child_objects === 'true';
21
22
  }
22
23
  if (path === '') {
23
24
  // If user has access to the root of database (NOT recommended for others than admin...)
@@ -14,7 +14,7 @@ export const addRoute = (env) => {
14
14
  info: {
15
15
  title: 'AceBase Server',
16
16
  description: 'AceBase Server API endpoint documentation and test environment. This documentation is available on the server because it is running in development mode. To disable this, set your NODE_ENV environment variable to production. Many endpoints require you to authenticate using Bearer authentication. Use the _/auth/{dbname}/signin_ endpoint to obtain an access token, then click the _Authorize_ button and paste your token into the input field. For more information about AceBase, see GitHub',
17
- version: '1.18.0',
17
+ version: '1.18.2',
18
18
  contact: {
19
19
  name: 'AceBase API Support',
20
20
  email: 'me@appy.one',
@@ -1,5 +1,5 @@
1
1
  import * as os from 'os';
2
- const SERVER_VERSION = '1.18.0'; // Loaded from package.json by npm scripts
2
+ const SERVER_VERSION = '1.18.2'; // Loaded from package.json by npm scripts
3
3
  export const addRoute = (env) => {
4
4
  // Add info endpoint
5
5
  env.router.get(`/info/${env.db.name}`, (req, res) => {
@@ -3,7 +3,7 @@ import { RouteInitEnvironment, RouteRequest } from '../shared/env';
3
3
  export type RequestQuery = {
4
4
  include?: string;
5
5
  exclude?: string;
6
- child_objects?: boolean;
6
+ child_objects?: 'true' | 'false';
7
7
  };
8
8
  export type RequestBody = null;
9
9
  export type ResponseBody = Transport.SerializedValue & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acebase-server",
3
- "version": "1.18.0",
3
+ "version": "1.18.2",
4
4
  "description": "AceBase realtime database server (webserver endpoint to allow remote connections)",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -19,6 +19,24 @@
19
19
  schema:
20
20
  type: string
21
21
  example: collection/child/property
22
+ - name: include
23
+ in: query
24
+ description: comma-separated list of child properties to include
25
+ required: false
26
+ schema:
27
+ type: string
28
+ - name: exclude
29
+ in: query
30
+ description: comma-separated list of child properties to exclude
31
+ required: false
32
+ schema:
33
+ type: string
34
+ - name: child_objects
35
+ in: query
36
+ description: whether to include child objects
37
+ required: false
38
+ schema:
39
+ type: boolean
22
40
  responses:
23
41
  200:
24
42
  description: Returns the serialized value of the target path, and whether it exists in the database