hfs 0.26.5 → 0.26.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/README.md +1 -0
- package/package.json +1 -1
- package/src/index.js +3 -1
- package/src/misc.js +2 -2
- package/src/vfs.js +0 -11
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ Other than that, you can also consider:
|
|
|
83
83
|
|
|
84
84
|
- it's more robust: it was designed to be an always-running server, while HFS 1-2 was designed for occasional usage (transfer and quit)
|
|
85
85
|
- passwords are never really stored, just a non-reversible hash is
|
|
86
|
+
- faster search (up to 12x)
|
|
86
87
|
- more flexible permissions
|
|
87
88
|
|
|
88
89
|
But you may still want to stay with HFS 2.x (so far) for the following reasons
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
|
+
var _a;
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.app = void 0;
|
|
9
10
|
const koa_1 = __importDefault(require("koa"));
|
|
@@ -21,8 +22,9 @@ const adminApis_1 = require("./adminApis");
|
|
|
21
22
|
const config_1 = require("./config");
|
|
22
23
|
const assert_1 = require("assert");
|
|
23
24
|
const lodash_1 = __importDefault(require("lodash"));
|
|
25
|
+
const misc_1 = require("./misc");
|
|
24
26
|
(0, assert_1.ok)(lodash_1.default.intersection(Object.keys(frontEndApis_1.frontEndApis), Object.keys(adminApis_1.adminApis)).length === 0); // they share same endpoints
|
|
25
|
-
const keys =
|
|
27
|
+
const keys = ((_a = process.env.COOKIE_SIGN_KEYS) === null || _a === void 0 ? void 0 : _a.split(',')) || [(0, misc_1.randomId)(30)];
|
|
26
28
|
exports.app = new koa_1.default({ keys });
|
|
27
29
|
exports.app.use(middlewares_1.someSecurity)
|
|
28
30
|
.use((0, middlewares_1.sessions)(exports.app))
|
package/src/misc.js
CHANGED
|
@@ -60,10 +60,10 @@ function getOrSet(o, k, creator) {
|
|
|
60
60
|
: (o[k] = creator());
|
|
61
61
|
}
|
|
62
62
|
exports.getOrSet = getOrSet;
|
|
63
|
+
// 10 chars is 51+bits, 8 is 41+bits
|
|
63
64
|
function randomId(len = 10) {
|
|
64
|
-
// 10 chars is 51+bits, the max we can give. 8 is 41+bits
|
|
65
65
|
if (len > 10)
|
|
66
|
-
|
|
66
|
+
return randomId(10) + randomId(len - 10);
|
|
67
67
|
return Math.random()
|
|
68
68
|
.toString(36)
|
|
69
69
|
.substring(2, 2 + len)
|
package/src/vfs.js
CHANGED
|
@@ -114,17 +114,6 @@ function hasPermission(node, perm, ctx) {
|
|
|
114
114
|
&& (perm !== 'can_see' || hasPermission(node, 'can_read', ctx)); // for can_see you must also can_read
|
|
115
115
|
}
|
|
116
116
|
exports.hasPermission = hasPermission;
|
|
117
|
-
/* redev: 1322k716 8.6s
|
|
118
|
-
-temp 6.43s
|
|
119
|
-
*/
|
|
120
|
-
setTimeout(async () => {
|
|
121
|
-
let n = 0;
|
|
122
|
-
console.time('asd');
|
|
123
|
-
for await (const x of walkNode({ source: '/Users/rejetto/redev' }, undefined, Infinity))
|
|
124
|
-
++n;
|
|
125
|
-
console.timeEnd('asd');
|
|
126
|
-
console.log({ n });
|
|
127
|
-
}, 3000);
|
|
128
117
|
async function* walkNode(parent, ctx, depth = 0, prefixPath = '') {
|
|
129
118
|
var _a;
|
|
130
119
|
const { children, source } = parent;
|