forked from tsai/budibase
43 changed files with 1039 additions and 919 deletions
@ -1,43 +1,6 @@ |
|||||
|
node_modules/ |
||||
# Logs |
myapps/ |
||||
logs |
config.js |
||||
*.log |
/builder/* |
||||
|
!/builder/assets/ |
||||
# Runtime data |
public/ |
||||
pids |
|
||||
*.pid |
|
||||
*.seed |
|
||||
|
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover |
|
||||
lib-cov |
|
||||
|
|
||||
# Coverage directory used by tools like istanbul |
|
||||
coverage |
|
||||
|
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) |
|
||||
.grunt |
|
||||
|
|
||||
# node-waf configuration |
|
||||
.lock-wscript |
|
||||
|
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html) |
|
||||
build/Release |
|
||||
.eslintcache |
|
||||
|
|
||||
# Dependency directory |
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git |
|
||||
node_modules |
|
||||
node_modules_ubuntu |
|
||||
node_modules_windows |
|
||||
|
|
||||
# OSX |
|
||||
.DS_Store |
|
||||
|
|
||||
# flow-typed |
|
||||
flow-typed/npm/* |
|
||||
!flow-typed/npm/module_vx.x.x.js |
|
||||
|
|
||||
|
|
||||
.idea |
|
||||
npm-debug.log.* |
|
||||
dist |
|
||||
|
|||||
@ -1,22 +0,0 @@ |
|||||
MIT License |
|
||||
----------- |
|
||||
|
|
||||
Copyright (C) 2010-2014 Philipp Dunkel |
|
||||
|
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
of this software and associated documentation files (the "Software"), to deal |
|
||||
in the Software without restriction, including without limitation the rights |
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
copies of the Software, and to permit persons to whom the Software is |
|
||||
furnished to do so, subject to the following conditions: |
|
||||
|
|
||||
The above copyright notice and this permission notice shall be included in |
|
||||
all copies or substantial portions of the Software. |
|
||||
|
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
||||
THE SOFTWARE. |
|
||||
@ -1,78 +0,0 @@ |
|||||
# fsevents [](https://nodei.co/npm/fsevents/) |
|
||||
|
|
||||
Native access to OS X FSEvents in [Node.js](http://nodejs.org/) |
|
||||
|
|
||||
The FSEvents API in OS X allows applications to register for notifications of |
|
||||
changes to a given directory tree. It is a very fast and lightweight alternative |
|
||||
to kqueue. |
|
||||
|
|
||||
This is a low-level library. For a cross-compatible file watching module that |
|
||||
uses fsevents, check out [Chokidar](https://www.npmjs.com/package/chokidar). |
|
||||
|
|
||||
* [Module Site & GitHub](https://github.com/strongloop/fsevents) |
|
||||
* [NPM Page](https://npmjs.org/package/fsevents) |
|
||||
|
|
||||
## Installation |
|
||||
|
|
||||
$ npm install fsevents |
|
||||
|
|
||||
## Usage |
|
||||
|
|
||||
```js |
|
||||
var fsevents = require('fsevents'); |
|
||||
var watcher = fsevents(__dirname); |
|
||||
watcher.on('fsevent', function(path, flags, id) { }); // RAW Event as emitted by OS-X |
|
||||
watcher.on('change', function(path, info) { }); // Common Event for all changes |
|
||||
watcher.start() // To start observation |
|
||||
watcher.stop() // To end observation |
|
||||
``` |
|
||||
|
|
||||
### Events |
|
||||
|
|
||||
* *fsevent* - RAW Event as emitted by OS-X |
|
||||
* *change* - Common Event for all changes |
|
||||
* *created* - A File-System-Item has been created |
|
||||
* *deleted* - A File-System-Item has been deleted |
|
||||
* *modified* - A File-System-Item has been modified |
|
||||
* *moved-out* - A File-System-Item has been moved away from this location |
|
||||
* *moved-in* - A File-System-Item has been moved into this location |
|
||||
|
|
||||
All events except *fsevent* take an *info* object as the second parameter of the callback. The structure of this object is: |
|
||||
|
|
||||
```js |
|
||||
{ |
|
||||
"event": "<event-type>", |
|
||||
"id": <eventi-id>, |
|
||||
"path": "<path-that-this-is-about>", |
|
||||
"type": "<file|directory|symlink>", |
|
||||
"changes": { |
|
||||
"inode": true, // Has the iNode Meta-Information changed |
|
||||
"finder": false, // Has the Finder Meta-Data changed |
|
||||
"access": false, // Have the access permissions changed |
|
||||
"xattrs": false // Have the xAttributes changed |
|
||||
}, |
|
||||
"flags": <raw-flags> |
|
||||
} |
|
||||
``` |
|
||||
|
|
||||
## MIT License |
|
||||
|
|
||||
Copyright (C) 2010-2014 Philipp Dunkel |
|
||||
|
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
of this software and associated documentation files (the "Software"), to deal |
|
||||
in the Software without restriction, including without limitation the rights |
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
copies of the Software, and to permit persons to whom the Software is |
|
||||
furnished to do so, subject to the following conditions: |
|
||||
|
|
||||
The above copyright notice and this permission notice shall be included in |
|
||||
all copies or substantial portions of the Software. |
|
||||
|
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
||||
THE SOFTWARE. |
|
||||
@ -1,106 +0,0 @@ |
|||||
/* |
|
||||
** © 2014 by Philipp Dunkel <pip@pipobscure.com> |
|
||||
** Licensed under MIT License. |
|
||||
*/ |
|
||||
|
|
||||
/* jshint node:true */ |
|
||||
'use strict'; |
|
||||
|
|
||||
if (process.platform !== 'darwin') |
|
||||
throw new Error('Module \'fsevents\' is not compatible with platform \'' + process.platform + '\''); |
|
||||
|
|
||||
var Native = require("bindings")("fse"); |
|
||||
|
|
||||
var EventEmitter = require('events').EventEmitter; |
|
||||
var fs = require('fs'); |
|
||||
var inherits = require('util').inherits; |
|
||||
|
|
||||
function FSEvents(path, handler) { |
|
||||
EventEmitter.call(this); |
|
||||
|
|
||||
Object.defineProperty(this, '_impl', { |
|
||||
value: new Native.FSEvents(String(path || ''), handler), |
|
||||
enumerable: false, |
|
||||
writable: false |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
inherits(FSEvents, EventEmitter); |
|
||||
proxies(FSEvents, Native.FSEvents); |
|
||||
|
|
||||
module.exports = watch; |
|
||||
module.exports.getInfo = getInfo; |
|
||||
module.exports.FSEvents = Native.FSEvents; |
|
||||
module.exports.Constants = Native.Constants; |
|
||||
|
|
||||
var defer = global.setImmediate || process.nextTick; |
|
||||
|
|
||||
function watch(path) { |
|
||||
var fse = new FSEvents(String(path || ''), handler); |
|
||||
EventEmitter.call(fse); |
|
||||
return fse; |
|
||||
|
|
||||
function handler(path, flags, id) { |
|
||||
defer(function() { |
|
||||
fse.emit('fsevent', path, flags, id); |
|
||||
var info = getInfo(path, flags); |
|
||||
info.id = id; |
|
||||
if (info.event === 'moved') { |
|
||||
fs.stat(info.path, function(err, stat) { |
|
||||
info.event = (err || !stat) ? 'moved-out' : 'moved-in'; |
|
||||
fse.emit('change', path, info); |
|
||||
fse.emit(info.event, path, info); |
|
||||
}); |
|
||||
} else { |
|
||||
fse.emit('change', path, info); |
|
||||
fse.emit(info.event, path, info); |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
function proxies(ctor, target) { |
|
||||
Object.keys(target.prototype).filter(function(key) { |
|
||||
return typeof target.prototype[key] === 'function'; |
|
||||
}).forEach(function(key) { |
|
||||
ctor.prototype[key] = function() { |
|
||||
this._impl[key].apply(this._impl, arguments); |
|
||||
return this; |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
function getFileType(flags) { |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemIsFile & flags) return 'file'; |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemIsDir & flags) return 'directory'; |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemIsSymlink & flags) return 'symlink'; |
|
||||
} |
|
||||
|
|
||||
function getEventType(flags) { |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemRemoved & flags) return 'deleted'; |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemRenamed & flags) return 'moved'; |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemCreated & flags) return 'created'; |
|
||||
if (Native.Constants.kFSEventStreamEventFlagItemModified & flags) return 'modified'; |
|
||||
if (Native.Constants.kFSEventStreamEventFlagRootChanged & flags) return 'root-changed'; |
|
||||
|
|
||||
return 'unknown'; |
|
||||
} |
|
||||
|
|
||||
function getFileChanges(flags) { |
|
||||
return { |
|
||||
inode: !! (Native.Constants.kFSEventStreamEventFlagItemInodeMetaMod & flags), |
|
||||
finder: !! (Native.Constants.kFSEventStreamEventFlagItemFinderInfoMod & flags), |
|
||||
access: !! (Native.Constants.kFSEventStreamEventFlagItemChangeOwner & flags), |
|
||||
xattrs: !! (Native.Constants.kFSEventStreamEventFlagItemXattrMod & flags) |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function getInfo(path, flags) { |
|
||||
return { |
|
||||
path: path, |
|
||||
event: getEventType(flags), |
|
||||
type: getFileType(flags), |
|
||||
changes: getFileChanges(flags), |
|
||||
flags: flags |
|
||||
}; |
|
||||
} |
|
||||
@ -1,36 +0,0 @@ |
|||||
{ |
|
||||
"name": "fsevents", |
|
||||
"version": "1.2.12", |
|
||||
"description": "Native Access to Mac OS-X FSEvents", |
|
||||
"main": "fsevents.js", |
|
||||
"dependencies": { |
|
||||
"bindings": "^1.5.0", |
|
||||
"nan": "^2.12.1" |
|
||||
}, |
|
||||
"os": [ |
|
||||
"darwin" |
|
||||
], |
|
||||
"engines": { |
|
||||
"node": ">= 4.0" |
|
||||
}, |
|
||||
"scripts": { |
|
||||
"test": "node ./test/fsevents.js && node ./test/function.js 2> /dev/null" |
|
||||
}, |
|
||||
"repository": { |
|
||||
"type": "git", |
|
||||
"url": "https://github.com/strongloop/fsevents.git" |
|
||||
}, |
|
||||
"keywords": [ |
|
||||
"fsevents", |
|
||||
"mac" |
|
||||
], |
|
||||
"author": "Philipp Dunkel <pip@pipobscure.com>", |
|
||||
"license": "MIT", |
|
||||
"bugs": { |
|
||||
"url": "https://github.com/strongloop/fsevents/issues" |
|
||||
}, |
|
||||
"bundledDependencies": [ |
|
||||
"node-pre-gyp" |
|
||||
], |
|
||||
"homepage": "https://github.com/strongloop/fsevents" |
|
||||
} |
|
||||
Binary file not shown.
@ -0,0 +1 @@ |
|||||
|
MANIFEST-000004 |
||||
@ -0,0 +1,5 @@ |
|||||
|
2020/04/23-10:07:34.635926 70000d912000 Recovering log #3 |
||||
|
2020/04/23-10:07:34.636067 70000d912000 Level-0 table #5: started |
||||
|
2020/04/23-10:07:34.636467 70000d912000 Level-0 table #5: 629 bytes OK |
||||
|
2020/04/23-10:07:34.637440 70000d912000 Delete type=0 #3 |
||||
|
2020/04/23-10:07:34.637605 70000d912000 Delete type=3 #2 |
||||
@ -0,0 +1 @@ |
|||||
|
2020/04/23-10:07:12.630205 70000d6bd000 Delete type=3 #1 |
||||
Binary file not shown.
@ -0,0 +1 @@ |
|||||
|
MANIFEST-000002 |
||||
@ -0,0 +1 @@ |
|||||
|
2020/04/23-10:07:12.642112 70000dec0000 Delete type=3 #1 |
||||
Binary file not shown.
@ -1,6 +1,11 @@ |
|||||
const nano = require("nano") |
// const nano = require("nano")
|
||||
|
const PouchDB = require("pouchdb"); |
||||
|
|
||||
const COUCH_DB_URL = |
const COUCH_DB_URL = |
||||
process.env.COUCH_DB_URL || "http://admin:password@localhost:5984" |
process.env.COUCH_DB_URL || "http://admin:password@localhost:5984" |
||||
|
|
||||
module.exports = nano(COUCH_DB_URL) |
const CouchDB = PouchDB.defaults({ |
||||
|
prefix: COUCH_DB_URL |
||||
|
}); |
||||
|
|
||||
|
module.exports = CouchDB; |
||||
|
|||||
@ -0,0 +1,15 @@ |
|||||
|
const jwt = require("jsonwebtoken"); |
||||
|
|
||||
|
module.exports = async (ctx, next) => { |
||||
|
if (!ctx.headers.authorization) ctx.throw(403, "No token provided"); |
||||
|
|
||||
|
const [_, token] = ctx.headers.authorization.split(" "); |
||||
|
|
||||
|
try { |
||||
|
ctx.request.jwtPayload = jwt.verify(token, ctx.config.jwtSecret); |
||||
|
} catch (err) { |
||||
|
ctx.throw(err.status || 403, err.text); |
||||
|
} |
||||
|
|
||||
|
await next(); |
||||
|
}; |
||||
@ -1,30 +1,41 @@ |
|||||
const couchdb = require("../../db"); |
const jwt = require("jsonwebtoken"); |
||||
|
const CouchDB = require("../../db"); |
||||
|
const bcrypt = require("../../utilities/bcrypt"); |
||||
|
|
||||
const controller = { |
exports.forgotPassword = async ctx => { |
||||
forgotPassword: async ctx => { |
}; |
||||
|
|
||||
}, |
exports.setPassword = async ctx => { }; |
||||
setPassword: async ctx => { |
|
||||
|
|
||||
}, |
exports.changePassword = async ctx => { |
||||
changePassword: async ctx => { |
}; |
||||
|
|
||||
}, |
|
||||
authenticate: async ctx => { |
|
||||
// const user = await ctx.master.authenticate(
|
|
||||
// ctx.sessionId,
|
|
||||
// ctx.params.appname,
|
|
||||
// ctx.request.body.username,
|
|
||||
// ctx.request.body.password
|
|
||||
// )
|
|
||||
|
|
||||
// if (!user) {
|
exports.authenticate = async ctx => { |
||||
// ctx.throw(StatusCodes.UNAUTHORIZED, "invalid username or password")
|
const { username, password } = ctx.request.body; |
||||
// }
|
|
||||
|
|
||||
// ctx.body = user.user_json
|
if (!username) ctx.throw(400, "Username Required."); |
||||
// ctx.response.status = StatusCodes.OK
|
if (!password) ctx.throw(400, "Password Required"); |
||||
} |
|
||||
} |
|
||||
|
|
||||
module.exports = controller; |
// query couch for their username
|
||||
|
const db = new CouchDB(ctx.params.instanceId); |
||||
|
const dbUser = await db.query("database/by_username", { |
||||
|
include_docs: true, |
||||
|
key: username |
||||
|
}); |
||||
|
|
||||
|
if (await bcrypt.compare(password, dbUser.password)) { |
||||
|
const payload = { |
||||
|
userId: dbUser._id, |
||||
|
accessLevel: "", |
||||
|
instanceId: ctx.params.instanceId |
||||
|
}; |
||||
|
const token = jwt.sign(payload, ctx.config.secret, { |
||||
|
expiresIn: "1 day" |
||||
|
}); |
||||
|
|
||||
|
ctx.body = token; |
||||
|
} else { |
||||
|
ctx.throw(401, "Invalid credentials."); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
const bcrypt = require("bcryptjs"); |
||||
|
|
||||
|
const SALT_ROUNDS = process.env.SALT_ROUNDS || 10; |
||||
|
|
||||
|
exports.hash = async data => { |
||||
|
const salt = await bcrypt.genSalt(SALT_ROUNDS); |
||||
|
const result = await bcrypt.hash(data, salt); |
||||
|
return result; |
||||
|
}; |
||||
|
|
||||
|
exports.compare = async (data, encrypted) => await bcrypt.compare(data, encrypted); |
||||
File diff suppressed because it is too large
Loading…
Reference in new issue