not-node 6.5.44 → 6.5.46
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/package.json +1 -1
- package/src/auth/exceptions.js +10 -0
- package/src/cli/lib/args.mjs +2 -0
- package/src/cli/lib/fs.mjs +1 -1
- package/src/identity/providers/session.js +13 -2
- package/src/init/lib/static.js +3 -3
- package/test/identity/providers/session.js +1 -1
- package/tmpl/dirs/front.mjs +2 -2
- package/tmpl/dirs/project.mjs +27 -2
- package/tmpl/files/app/config/common.ejs +0 -2
- package/tmpl/files/app/front/index.!.ejs +53 -56
- package/tmpl/files/app/front/rollup.!.ejs +2 -3
- package/tmpl/files/project/env.ejs +9 -9
package/package.json
CHANGED
package/src/auth/exceptions.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
const { notError } = require("not-error");
|
|
2
2
|
|
|
3
|
+
class UserIdentityExceptionUserIdIsNotString extends notError {
|
|
4
|
+
constructor(typeofUserId) {
|
|
5
|
+
super("not-node:auth_user_identity_user_id_is_not_string", {
|
|
6
|
+
typeofUserId,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
module.exports.UserIdentityExceptionUserIdIsNotString =
|
|
11
|
+
UserIdentityExceptionUserIdIsNotString;
|
|
12
|
+
|
|
3
13
|
class RolesExceptionRoleSetIsNotValid extends notError {
|
|
4
14
|
constructor(name) {
|
|
5
15
|
super("not-node:auth_roles_role_set_is_not_valid", { name });
|
package/src/cli/lib/args.mjs
CHANGED
|
@@ -29,6 +29,8 @@ async function readArgs(structure, config) {
|
|
|
29
29
|
function isFilename(name, descr) {
|
|
30
30
|
if (descr.type === "file") {
|
|
31
31
|
return true;
|
|
32
|
+
} else if (descr.type === "dir") {
|
|
33
|
+
return false;
|
|
32
34
|
}
|
|
33
35
|
if (name.startsWith(VAR_PREFIX) && name.endsWith(VAR_PREFIX)) {
|
|
34
36
|
return false;
|
package/src/cli/lib/fs.mjs
CHANGED
|
@@ -103,7 +103,7 @@ async function createDirContent(dest, structure = {}, config = {}) {
|
|
|
103
103
|
entry = config[getVariableName(entry)];
|
|
104
104
|
}
|
|
105
105
|
if (isFilename(entry, subStructure)) {
|
|
106
|
-
|
|
106
|
+
console.log(dest, entry);
|
|
107
107
|
const filePath = join(dest, entry);
|
|
108
108
|
await createFileContent(filePath, subStructure, config);
|
|
109
109
|
} else {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const CONST = require("../../auth/const");
|
|
2
2
|
const ROLES = require("../../auth/roles");
|
|
3
|
+
const EXCEPTIONS = require("../../auth/exceptions");
|
|
3
4
|
|
|
4
5
|
module.exports = class IdentityProviderSession {
|
|
5
6
|
static #options = {};
|
|
6
7
|
|
|
7
8
|
static setOptions(options = {}) {
|
|
8
|
-
this.#options = {...this.#options, ...options};
|
|
9
|
+
this.#options = { ...this.#options, ...options };
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
static #getOptions() {
|
|
@@ -20,6 +21,15 @@ module.exports = class IdentityProviderSession {
|
|
|
20
21
|
IdentityProviderSession.#getOptions().secondaryRoles = [...list];
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
_idToString(_id) {
|
|
25
|
+
if (typeof _id === "string") {
|
|
26
|
+
return _id;
|
|
27
|
+
} else if (_id.toString && typeof _id.toString === "function") {
|
|
28
|
+
return _id.toString();
|
|
29
|
+
}
|
|
30
|
+
throw new EXCEPTIONS.UserIdentityExceptionUserIdIsNotString(typeof _id);
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
constructor(req) {
|
|
24
34
|
this.req = req;
|
|
25
35
|
return this;
|
|
@@ -93,7 +103,8 @@ module.exports = class IdentityProviderSession {
|
|
|
93
103
|
setUserId(_id) {
|
|
94
104
|
const req = this.req;
|
|
95
105
|
if (req && req.session) {
|
|
96
|
-
|
|
106
|
+
const stringId = this._idToString(_id);
|
|
107
|
+
req.session.user = stringId;
|
|
97
108
|
req.session.save();
|
|
98
109
|
}
|
|
99
110
|
}
|
package/src/init/lib/static.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = class InitStatic {
|
|
|
30
30
|
return (req, res, next) => {
|
|
31
31
|
try {
|
|
32
32
|
const frontApp = InitStatic.selectVersion(config, req, ext);
|
|
33
|
-
|
|
33
|
+
const pathTo = path.resolve(options.pathToApp, frontApp);
|
|
34
34
|
return InitStatic.serveStatic(pathTo)(req, res, next);
|
|
35
35
|
} catch (e) {
|
|
36
36
|
next(e);
|
|
@@ -41,7 +41,7 @@ module.exports = class InitStatic {
|
|
|
41
41
|
async run({ config, options, master, emit }) {
|
|
42
42
|
await emit("static.pre", { config, options, master });
|
|
43
43
|
master.getServer().use(
|
|
44
|
-
|
|
44
|
+
'/front/:"role".js',
|
|
45
45
|
InitStatic.createStaticFrontServer("js", {
|
|
46
46
|
config,
|
|
47
47
|
options,
|
|
@@ -49,7 +49,7 @@ module.exports = class InitStatic {
|
|
|
49
49
|
})
|
|
50
50
|
);
|
|
51
51
|
master.getServer().use(
|
|
52
|
-
|
|
52
|
+
'/front/:"role".css',
|
|
53
53
|
InitStatic.createStaticFrontServer("css", {
|
|
54
54
|
config,
|
|
55
55
|
options,
|
|
@@ -110,7 +110,7 @@ module.exports = ({ expect }) => {
|
|
|
110
110
|
};
|
|
111
111
|
const id = new mongoose.Types.ObjectId();
|
|
112
112
|
new Provider(t).setUserId(id);
|
|
113
|
-
expect(t.session.user).to.eql(id);
|
|
113
|
+
expect(t.session.user).to.eql(id.toString());
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
it("session not exist, set _id", function () {
|
package/tmpl/dirs/front.mjs
CHANGED
package/tmpl/dirs/project.mjs
CHANGED
|
@@ -12,14 +12,17 @@ export default {
|
|
|
12
12
|
ifArgs: ["pm2"],
|
|
13
13
|
},
|
|
14
14
|
".envs": {
|
|
15
|
+
type: "dir",
|
|
15
16
|
content: {
|
|
16
17
|
development: {
|
|
18
|
+
type: "file",
|
|
17
19
|
tmpl: "project/env.ejs",
|
|
18
20
|
args: [
|
|
19
21
|
"init_root_user",
|
|
20
22
|
"not_node_monitor",
|
|
21
23
|
"not_node_reporter",
|
|
22
24
|
"db",
|
|
25
|
+
"user",
|
|
23
26
|
"session",
|
|
24
27
|
"secret",
|
|
25
28
|
"modules",
|
|
@@ -27,12 +30,34 @@ export default {
|
|
|
27
30
|
],
|
|
28
31
|
},
|
|
29
32
|
stage: {
|
|
33
|
+
type: "file",
|
|
30
34
|
tmpl: "project/env.ejs",
|
|
31
|
-
args: [
|
|
35
|
+
args: [
|
|
36
|
+
"init_root_user",
|
|
37
|
+
"not_node_monitor",
|
|
38
|
+
"not_node_reporter",
|
|
39
|
+
"db",
|
|
40
|
+
"user",
|
|
41
|
+
"session",
|
|
42
|
+
"secret",
|
|
43
|
+
"modules",
|
|
44
|
+
"ws",
|
|
45
|
+
],
|
|
32
46
|
},
|
|
33
47
|
production: {
|
|
48
|
+
type: "file",
|
|
34
49
|
tmpl: "project/env.ejs",
|
|
35
|
-
args: [
|
|
50
|
+
args: [
|
|
51
|
+
"init_root_user",
|
|
52
|
+
"not_node_monitor",
|
|
53
|
+
"not_node_reporter",
|
|
54
|
+
"db",
|
|
55
|
+
"user",
|
|
56
|
+
"session",
|
|
57
|
+
"secret",
|
|
58
|
+
"modules",
|
|
59
|
+
"ws",
|
|
60
|
+
],
|
|
36
61
|
},
|
|
37
62
|
},
|
|
38
63
|
},
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
"mongoose": {
|
|
15
15
|
"uri": "mongodb://<%- db.mongoose.hostname %>/<%- db.mongoose.db %>?authSource=<%- db.mongoose.authSource %>",
|
|
16
16
|
"options": {
|
|
17
|
-
"useNewUrlParser": true,
|
|
18
|
-
"useUnifiedTopology": true,
|
|
19
17
|
"db": "<%- db.mongoose.db %>",
|
|
20
18
|
"host": "<%- db.mongoose.hostname %>",
|
|
21
19
|
"autoIndex": false
|
|
@@ -1,66 +1,63 @@
|
|
|
1
1
|
<% if (not_node_reporter) { %>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
window.NOT_NODE_ERROR_URL_BROWSER = '<%- not_node_reporter.url_browser %>';
|
|
3
|
+
<% } %>
|
|
4
|
+
|
|
5
|
+
import { Frame } from 'not-bulma';
|
|
6
|
+
|
|
7
|
+
const {notCommon, notApp, COMPONENTS} = Frame;
|
|
8
|
+
|
|
9
|
+
notCommon.register('backlog', true);
|
|
10
|
+
window.dumpBacklog = notCommon.dumpBacklog.bind(notCommon);
|
|
11
|
+
|
|
12
|
+
let appDefaultOptions = {
|
|
13
|
+
manifestURL: '/api/manifest',
|
|
14
|
+
router: {
|
|
15
|
+
root: '/',
|
|
16
|
+
manifest: [],
|
|
17
|
+
index: ''
|
|
18
|
+
},
|
|
19
|
+
language: 'ru',
|
|
20
|
+
crud: {
|
|
21
|
+
navigateBackAfter: ['create', 'update', 'delete']
|
|
22
|
+
},
|
|
23
|
+
modules: {
|
|
24
|
+
user: {
|
|
25
|
+
redirectTimout: 1000,
|
|
26
|
+
afterLoginURL: '/dashboard',
|
|
27
|
+
loginForm: {
|
|
28
|
+
modes: [
|
|
29
|
+
'login',
|
|
30
|
+
'requestLoginCodeOnEmail',
|
|
31
|
+
'loginByCode'
|
|
32
|
+
]
|
|
20
33
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'loginByCode'
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
loginFormContainerSelector: '.main-container',
|
|
37
|
-
restoreFormContainerSelector: '.main-container',
|
|
38
|
-
registerFormContainerSelector: '.main-container'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
let services = {}, uis = {}, wsc = {}, fields = {};
|
|
44
|
-
|
|
45
|
-
<%% for(var i = 0; i < mods.length; i++) { %%>
|
|
46
|
-
import * as mod_<%%= i %%>
|
|
47
|
-
from '<%%= mods[i] %%>';
|
|
48
|
-
appDefaultOptions = notCommon.absorbModule({
|
|
34
|
+
loginFormContainerSelector: '.main-container',
|
|
35
|
+
restoreFormContainerSelector: '.main-container',
|
|
36
|
+
registerFormContainerSelector: '.main-container'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let services = {}, uis = {}, wsc = {}, fields = {};
|
|
42
|
+
|
|
43
|
+
<%% for(var i = 0; i < mods.length; i++) { %%>
|
|
44
|
+
import * as mod_<%%= i %%> from '<%%= mods[i] %%>';
|
|
45
|
+
appDefaultOptions = notCommon.absorbModule({
|
|
49
46
|
defaultConf: appDefaultOptions,
|
|
50
47
|
mod: mod_<%%= i %%>,
|
|
51
48
|
services, uis, wsc, fields
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
});
|
|
50
|
+
<%% } %%>
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
COMPONENTS.import(uis);
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
import 'bulma';
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
<%% for(var i = 0; i < scss.length; i++) { %%>
|
|
57
|
+
import '<%%= scss[i] %%>';
|
|
58
|
+
<%% } %%>
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
appDefaultOptions.services = services;
|
|
61
|
+
appDefaultOptions.wsc = wsc;
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
notCommon.startApp(() => new notApp(appDefaultOptions));
|
|
@@ -8,7 +8,7 @@ import sizes from "rollup-plugin-sizes";
|
|
|
8
8
|
import postcss from "rollup-plugin-postcss";
|
|
9
9
|
import json from "@rollup/plugin-json";
|
|
10
10
|
|
|
11
|
-
import { babelOn } from "
|
|
11
|
+
import { babelOn } from "../build.env.js";
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
input: "<%%= inputPath %%>",
|
|
@@ -16,8 +16,7 @@ export default {
|
|
|
16
16
|
file: "<%%= outputPath %%>",
|
|
17
17
|
name: "<%%= appName %%>",
|
|
18
18
|
format: "iife",
|
|
19
|
-
sourcemap:
|
|
20
|
-
false && (process.env.NODE_ENV === "production" ? false : "inline"),
|
|
19
|
+
sourcemap:(process.env.NODE_ENV === "production" ? false : "inline"),
|
|
21
20
|
},
|
|
22
21
|
plugins: [
|
|
23
22
|
json(),
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
<% if (not_node_reporter) { %>
|
|
1
|
+
<% if (locals.not_node_reporter) { %>
|
|
2
2
|
NOT_NODE_ERROR_KEY=<%- not_node_reporter.key %>
|
|
3
3
|
NOT_NODE_ERROR_URL_NODE=<%- not_node_reporter.url_node %>
|
|
4
4
|
NOT_NODE_ERROR_URL_BROWSER=<%- not_node_reporter.url_browser %>
|
|
5
5
|
<% } %>
|
|
6
|
-
<% if (not_node_monitor) { %>
|
|
6
|
+
<% if (locals.not_node_monitor) { %>
|
|
7
7
|
NOT_NODE_MONITOR_INTERVAL=<%- not_node_monitor.interval %>
|
|
8
8
|
NOT_NODE_MONITOR_REPORT_INTERVAL=<%- not_node_monitor.report_interval %>
|
|
9
9
|
NOT_NODE_MONITOR_REPORT_KEY=<%- not_node_monitor.report_key %>
|
|
10
10
|
NOT_NODE_MONITOR_REPORT_URL=<%- not_node_monitor.report_url %>
|
|
11
11
|
<% } %>
|
|
12
|
-
<% if (init_root_user) { %>
|
|
12
|
+
<% if (locals.init_root_user) { %>
|
|
13
13
|
INIT_ROOT_USERNAME=<%- init_root_user.name %>
|
|
14
14
|
INIT_ROOT_EMAIL=<%- init_root_user.email %>
|
|
15
15
|
INIT_ROOT_PASSWORD=<%- init_root_user.password %>
|
|
16
16
|
<% } %>
|
|
17
17
|
|
|
18
|
-
<% if (db && db.mongoose) { %>
|
|
19
|
-
db__mongoose__uri=mongodb://<%- db.mongoose.
|
|
20
|
-
db__mongoose__options__host=<%- db.mongoose.
|
|
18
|
+
<% if (locals.db && db.mongoose) { %>
|
|
19
|
+
db__mongoose__uri=mongodb://<%- db.mongoose.hostname %>/<%- db.mongoose.db %>?authSource=<%- db.mongoose.authSource %>
|
|
20
|
+
db__mongoose__options__host=<%- db.mongoose.hostname %>
|
|
21
21
|
db__mongoose__options__user=<%- db.mongoose.user %>
|
|
22
22
|
db__mongoose__options__pass=<%- db.mongoose.pass %>
|
|
23
23
|
db__mongoose__options__db=<%- db.mongoose.db %>
|
|
24
24
|
<% } %>
|
|
25
25
|
|
|
26
|
-
<% if (modules.includes('not-ws')
|
|
26
|
+
<% if (locals.modules && modules.includes('not-ws')) { %>
|
|
27
27
|
modules__ws__servers__main__connection__secret=<%- secret %>
|
|
28
28
|
<% } %>
|
|
29
|
-
<% if (modules.includes('not-user')
|
|
29
|
+
<% if (locals.modules && modules.includes('not-user')) { %>
|
|
30
30
|
modules__user__secret=<%- secret %>
|
|
31
31
|
<% } %>
|
|
32
|
-
<% if (session) { %>
|
|
32
|
+
<% if (locals.session && session) { %>
|
|
33
33
|
session__secret=<%- session.secret %>
|
|
34
34
|
<% } %>
|