Merge branch 'master' of github.com:Budibase/budibase

This commit is contained in:
Martin McKeaveney 2020-01-23 15:17:19 +00:00
commit 49ed9d0cd9
19 changed files with 14622 additions and 66 deletions

View File

@ -2,19 +2,11 @@
(For contributors - scroll down)
### 1. Prerequisites (for nodegyp)
We will try to make this bit easier, but for now:
- Windows - https://github.com/nodejs/node-gyp#on-windows
- Ubuntu `sudo apt-get install build-essentials`
- Mac: https://github.com/nodejs/node-gyp#on-macos
### 2. Global install budibase
### 1. Global install budibase
`npm install -g budibase`
### 3. Start using Budibase
### 2. Start using Budibase
Create a directory to store your Budibase apps

9064
packages/core/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@
},
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"build": "rollup -c rollup.config.js"
},
"keywords": [
@ -50,7 +51,6 @@
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/runtime": "^7.4.5",
"argon2": "^0.20.1",
"babel-eslint": "^10.0.2",
"babel-jest": "^23.6.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
@ -72,6 +72,7 @@
},
"dependencies": {
"@nx-js/compiler-util": "^2.0.0",
"bcryptjs": "^2.4.3",
"date-fns": "^1.29.0",
"lodash": "^4.17.13",
"lunr": "^2.3.5",

View File

@ -1,17 +1,6 @@
## Getting Started
Install requires [node-gyp](https://github.com/nodejs/node-gyp), due to a dependancy on [argon2](https://github.com/ranisalt/node-argon2)
### For node gyp on windows
`npm install --global --production windows-build-tools`
and this might help: https://github.com/nodejs/node-gyp/issues/1278
### For node gyp on ubuntu
`sudo apt-get install build-essentials`
Once you have this, try...
Install packages:
`npm install`

View File

@ -49,7 +49,7 @@ export const _authenticate = async (app, username, password) => {
const permissions = await buildUserPermissions(app, user.accessLevels);
const verified = await app.crypto.verify(
const verified = app.crypto.verify(
userAuth.passwordHash,
password,
);
@ -89,7 +89,7 @@ export const authenticateTemporaryAccess = app => async (tempAccessCode) => {
if (userAuth.temporaryAccessExpiryEpoch < await app.getEpochTime()) { user = notAUser; }
const tempCode = !temp.code ? generate() : temp.code;
const verified = await app.crypto.verify(
const verified = app.crypto.verify(
userAuth.temporaryAccessHash,
tempCode,
);

View File

@ -66,7 +66,7 @@ export const getTemporaryCode = async (app) => {
const tempId = generate();
return {
temporaryAccessHash: await app.crypto.hash(
temporaryAccessHash: app.crypto.hash(
tempCode,
),
temporaryAccessExpiryEpoch:

View File

@ -75,7 +75,7 @@ const getAccess = async (app, password) => {
if (isNonEmptyString(password)) {
if (isValidPassword(password)) {
auth.passwordHash = await app.crypto.hash(password);
auth.passwordHash = app.crypto.hash(password);
auth.temporaryAccessHash = '';
auth.temporaryAccessId = '';
auth.temporaryAccessExpiryEpoch = 0;

View File

@ -30,7 +30,7 @@ export const _changeMyPassword = async (app, currentPw, newpassword) => {
);
if (isSomething(existingAuth.passwordHash)) {
const verified = await app.crypto.verify(
const verified = app.crypto.verify(
existingAuth.passwordHash,
currentPw,
);
@ -73,7 +73,7 @@ export const _setPasswordFromTemporaryCode = async (app, tempCode, newpassword)
if (isSomething(existingAuth.temporaryAccessHash)
&& existingAuth.temporaryAccessExpiryEpoch > currentTime) {
const verified = await app.crypto.verify(
const verified = app.crypto.verify(
existingAuth.temporaryAccessHash,
temp.code,
);
@ -93,7 +93,7 @@ export const _setPasswordFromTemporaryCode = async (app, tempCode, newpassword)
const doSet = async (app, auth, username, newpassword) => {
auth.temporaryAccessHash = '';
auth.temporaryAccessExpiryEpoch = 0;
auth.passwordHash = await app.crypto.hash(
auth.passwordHash = app.crypto.hash(
newpassword,
);
await app.datastore.updateJson(

View File

@ -1,5 +1,4 @@
import {
head,
tail, findIndex, startsWith,
dropRight, flow, takeRight, trim,
@ -17,6 +16,7 @@ import {
getLock, NO_LOCK,
isNolock
} from './lock';
import crypto from "./nodeCrypto";
// this is the combinator function
export const $$ = (...funcs) => arg => flow(funcs)(arg);
@ -211,6 +211,7 @@ export {
getLock, NO_LOCK, releaseLock,
extendLock, isNolock,
} from './lock';
export { crypto };
export default {
ifExists,

View File

@ -0,0 +1,13 @@
import bcrypt from "bcryptjs";
function hash(password) {
return bcrypt.hashSync(password, 10);
}
function verify(hash, password) {
return bcrypt.compareSync(password, hash);
}
export default {
hash, verify
};

View File

@ -6,7 +6,7 @@ import getAuthApi from "./authApi";
import getActionsApi from "./actionsApi";
import {setupDatastore, createEventAggregator} from "./appInitialise";
import {initialiseActions} from "./actionsApi/initialise"
import {isSomething} from "./common";
import {isSomething, crypto} from "./common";
import {cleanup} from "./transactions/cleanup";
import {generateFullPermissions} from "./authApi/generateFullPermissions";
import {getApplicationDefinition} from "./templateApi/getApplicationDefinition";
@ -111,5 +111,6 @@ export {initialiseData} from "./appInitialise/initialiseData";
export {getDatabaseManager} from "./appInitialise/databaseManager";
export {hierarchy};
export {common};
export {crypto};
export default getAppApis;

View File

@ -7,7 +7,7 @@ import {permission} from "../src/authApi/permissions";
describe("authApi > authenticate", () => {
it("should return user + access when correct password supplied", async () => {
fit("should return user + access when correct password supplied", async () => {
const {authApi, app} = await setupApphierarchy(basicAppHierarchyCreator_WithFields);
const u = await validUser(app, authApi, "password");
const result = await authApi.authenticate(u.name, "password");

View File

@ -1,5 +0,0 @@
import {hash, verify} from "argon2";
export default {
hash, verify
};

View File

@ -6,7 +6,9 @@ import {setupDatastore} from "../src/appInitialise";
import {configFolder, fieldDefinitions,
templateDefinitions,
joinKey,
isSomething} from "../src/common";
isSomething,
crypto as nodeCrypto
} from "../src/common";
import { getNewIndexTemplate } from "../src/templateApi/createNodes";
import {indexTypes} from "../src/templateApi/indexes";
import getTemplateApi from "../src/templateApi";
@ -17,7 +19,6 @@ import {createBehaviourSources} from "../src/actionsApi/buildBehaviourSource";
import {createAction, createTrigger} from "../src/templateApi/createActions";
import {initialiseActions} from "../src/actionsApi/initialise";
import {cleanup} from "../src/transactions/cleanup";
import nodeCrypto from "./nodeCrypto";
import {permission} from "../src/authApi/permissions";
import {generateFullPermissions} from "../src/authApi/generateFullPermissions"
import {initialiseData} from "../src/appInitialise/initialiseData";

View File

@ -1,5 +0,0 @@
const {hash, verify} = require("argon2");
module.exports = {
hash, verify
};

5522
packages/server/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,6 @@
"@budibase/client": "^0.0.16",
"@budibase/core": "^0.0.16",
"@koa/router": "^8.0.0",
"argon2": "^0.23.0",
"fs-extra": "^8.1.0",
"koa": "^2.7.0",
"koa-body": "^4.1.0",

View File

@ -1,5 +1,4 @@
const crypto = require("../nodeCrypto");
const {getAppApis, getTemplateApi} = require("@budibase/core");
const {getAppApis, getTemplateApi, crypto } = require("@budibase/core");
const getDatastore = require("./datastore");
const { masterAppPackage } = require("../utilities/createAppPackage");
const getDatabaseManager = require("../utilities/databaseManager");

View File

@ -2,19 +2,11 @@
(For contributors - scroll down)
### 1. Prerequisites (for nodegyp)
We will try to make this bit easier, but for now:
- Windows - https://github.com/nodejs/node-gyp#on-windows
- Ubuntu `sudo apt-get install build-essentials`
- Mac: https://github.com/nodejs/node-gyp#on-macos
### 2. Global install budibase
### 1. Global install budibase
`npm install -g budibase`
### 3. Start using Budibase
### 2. Start using Budibase
Create a directory to store your Budibase apps
@ -44,16 +36,8 @@ Once you have created your app, you need to create yourself an instance of your
## Getting Started for Contributors
Install requires [node-gyp](https://github.com/nodejs/node-gyp), due to a dependancy on [argon2](https://github.com/ranisalt/node-argon2)
### 1. Prerequisites
*nodegyp -*
- Windows - https://github.com/nodejs/node-gyp#on-windows
- Ubuntu `sudo apt-get install build-essentials`
- Mac: https://github.com/nodejs/node-gyp#on-macos
*yarn -* `npm install -g yarn`
*jest* - `npm install -g jest`