@nocobase/server 1.6.0-beta.2 → 1.6.0-beta.4
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/lib/aes-encryptor.d.ts +20 -0
- package/lib/aes-encryptor.js +126 -0
- package/lib/application.d.ts +7 -1
- package/lib/application.js +17 -2
- package/lib/environment.d.ts +18 -0
- package/lib/environment.js +80 -0
- package/lib/helper.js +2 -0
- package/lib/helpers/application-version.js +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -2
- package/lib/middlewares/extract-client-ip.d.ts +10 -0
- package/lib/middlewares/extract-client-ip.js +46 -0
- package/lib/middlewares/index.d.ts +1 -0
- package/lib/middlewares/index.js +3 -1
- package/lib/plugin-manager/options/collection.js +1 -0
- package/package.json +15 -15
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
/// <reference types="node" />
|
|
10
|
+
import Application from './application';
|
|
11
|
+
export declare class AesEncryptor {
|
|
12
|
+
private key;
|
|
13
|
+
constructor(key: Buffer);
|
|
14
|
+
encrypt(text: string): Promise<string>;
|
|
15
|
+
decrypt(encryptedText: string): Promise<string>;
|
|
16
|
+
static getOrGenerateKey(keyFilePath: string): Promise<Buffer>;
|
|
17
|
+
static getKeyPath(appName: string): Promise<string>;
|
|
18
|
+
static create(app: Application): Promise<AesEncryptor>;
|
|
19
|
+
}
|
|
20
|
+
export default AesEncryptor;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var aes_encryptor_exports = {};
|
|
39
|
+
__export(aes_encryptor_exports, {
|
|
40
|
+
AesEncryptor: () => AesEncryptor,
|
|
41
|
+
default: () => aes_encryptor_default
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(aes_encryptor_exports);
|
|
44
|
+
var import_crypto = __toESM(require("crypto"));
|
|
45
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
46
|
+
var import_path = __toESM(require("path"));
|
|
47
|
+
const _AesEncryptor = class _AesEncryptor {
|
|
48
|
+
key;
|
|
49
|
+
constructor(key) {
|
|
50
|
+
if (key.length !== 32) {
|
|
51
|
+
throw new Error("Key must be 32 bytes for AES-256 encryption.");
|
|
52
|
+
}
|
|
53
|
+
this.key = key;
|
|
54
|
+
}
|
|
55
|
+
async encrypt(text) {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
try {
|
|
58
|
+
const iv = import_crypto.default.randomBytes(16);
|
|
59
|
+
const cipher = import_crypto.default.createCipheriv("aes-256-cbc", this.key, iv);
|
|
60
|
+
const encrypted = Buffer.concat([cipher.update(Buffer.from(text, "utf8")), cipher.final()]);
|
|
61
|
+
resolve(iv.toString("hex") + encrypted.toString("hex"));
|
|
62
|
+
} catch (error) {
|
|
63
|
+
reject(error);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async decrypt(encryptedText) {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
try {
|
|
70
|
+
const iv = Buffer.from(encryptedText.slice(0, 32), "hex");
|
|
71
|
+
const encrypted = Buffer.from(encryptedText.slice(32), "hex");
|
|
72
|
+
const decipher = import_crypto.default.createDecipheriv("aes-256-cbc", this.key, iv);
|
|
73
|
+
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
74
|
+
resolve(decrypted.toString("utf8"));
|
|
75
|
+
} catch (error) {
|
|
76
|
+
reject(error);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
static async getOrGenerateKey(keyFilePath) {
|
|
81
|
+
try {
|
|
82
|
+
const key = await import_fs_extra.default.readFile(keyFilePath);
|
|
83
|
+
if (key.length !== 32) {
|
|
84
|
+
throw new Error("Invalid key length in file.");
|
|
85
|
+
}
|
|
86
|
+
return key;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error.code === "ENOENT") {
|
|
89
|
+
const key = import_crypto.default.randomBytes(32);
|
|
90
|
+
await import_fs_extra.default.mkdir(import_path.default.dirname(keyFilePath), { recursive: true });
|
|
91
|
+
await import_fs_extra.default.writeFile(keyFilePath, key);
|
|
92
|
+
return key;
|
|
93
|
+
} else {
|
|
94
|
+
throw new Error(`Failed to load key: ${error.message}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
static async getKeyPath(appName) {
|
|
99
|
+
const appKeyPath = import_path.default.resolve(process.cwd(), "storage", "apps", appName, "aes_key.dat");
|
|
100
|
+
const appKeyExists = await import_fs_extra.default.exists(appKeyPath);
|
|
101
|
+
if (appKeyExists) {
|
|
102
|
+
return appKeyPath;
|
|
103
|
+
}
|
|
104
|
+
const envKeyPath = import_path.default.resolve(process.cwd(), "storage", "environment-variables", appName, "aes_key.dat");
|
|
105
|
+
const envKeyExists = await import_fs_extra.default.exists(envKeyPath);
|
|
106
|
+
if (envKeyExists) {
|
|
107
|
+
return envKeyPath;
|
|
108
|
+
}
|
|
109
|
+
return appKeyPath;
|
|
110
|
+
}
|
|
111
|
+
static async create(app) {
|
|
112
|
+
let key = process.env.APP_AES_SECRET_KEY;
|
|
113
|
+
if (!key) {
|
|
114
|
+
const keyPath = await this.getKeyPath(app.name);
|
|
115
|
+
key = await _AesEncryptor.getOrGenerateKey(keyPath);
|
|
116
|
+
}
|
|
117
|
+
return new _AesEncryptor(key);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
__name(_AesEncryptor, "AesEncryptor");
|
|
121
|
+
let AesEncryptor = _AesEncryptor;
|
|
122
|
+
var aes_encryptor_default = AesEncryptor;
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
AesEncryptor
|
|
126
|
+
});
|
package/lib/application.d.ts
CHANGED
|
@@ -31,8 +31,10 @@ import { Plugin } from './plugin';
|
|
|
31
31
|
import { InstallOptions, PluginManager } from './plugin-manager';
|
|
32
32
|
import { PubSubManager, PubSubManagerOptions } from './pub-sub-manager';
|
|
33
33
|
import { SyncMessageManager } from './sync-message-manager';
|
|
34
|
-
import
|
|
34
|
+
import AesEncryptor from './aes-encryptor';
|
|
35
35
|
import { AuditManager } from './audit-manager';
|
|
36
|
+
import { Environment } from './environment';
|
|
37
|
+
import { ServiceContainer } from './service-container';
|
|
36
38
|
export type PluginType = string | typeof Plugin;
|
|
37
39
|
export type PluginConfiguration = PluginType | [PluginType, any];
|
|
38
40
|
export interface ResourceManagerOptions {
|
|
@@ -195,6 +197,8 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
195
197
|
* @internal
|
|
196
198
|
*/
|
|
197
199
|
get maintainingMessage(): string;
|
|
200
|
+
private _env;
|
|
201
|
+
get environment(): Environment;
|
|
198
202
|
protected _cronJobManager: CronJobManager;
|
|
199
203
|
get cronJobManager(): CronJobManager;
|
|
200
204
|
get mainDataSource(): SequelizeDataSource;
|
|
@@ -240,6 +244,8 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
240
244
|
get name(): string;
|
|
241
245
|
protected _dataSourceManager: DataSourceManager;
|
|
242
246
|
get dataSourceManager(): DataSourceManager;
|
|
247
|
+
protected _aesEncryptor: AesEncryptor;
|
|
248
|
+
get aesEncryptor(): AesEncryptor;
|
|
243
249
|
/**
|
|
244
250
|
* @internal
|
|
245
251
|
*/
|
package/lib/application.js
CHANGED
|
@@ -76,9 +76,11 @@ var import_plugin_manager = require("./plugin-manager");
|
|
|
76
76
|
var import_pub_sub_manager = require("./pub-sub-manager");
|
|
77
77
|
var import_sync_message_manager = require("./sync-message-manager");
|
|
78
78
|
var import_package = __toESM(require("../package.json"));
|
|
79
|
-
var import_service_container = require("./service-container");
|
|
80
79
|
var import_available_action = require("./acl/available-action");
|
|
80
|
+
var import_aes_encryptor = __toESM(require("./aes-encryptor"));
|
|
81
81
|
var import_audit_manager = require("./audit-manager");
|
|
82
|
+
var import_environment = require("./environment");
|
|
83
|
+
var import_service_container = require("./service-container");
|
|
82
84
|
const _Application = class _Application extends import_koa.default {
|
|
83
85
|
constructor(options) {
|
|
84
86
|
super();
|
|
@@ -164,6 +166,10 @@ const _Application = class _Application extends import_koa.default {
|
|
|
164
166
|
get maintainingMessage() {
|
|
165
167
|
return this._maintainingMessage;
|
|
166
168
|
}
|
|
169
|
+
_env;
|
|
170
|
+
get environment() {
|
|
171
|
+
return this._env;
|
|
172
|
+
}
|
|
167
173
|
_cronJobManager;
|
|
168
174
|
get cronJobManager() {
|
|
169
175
|
return this._cronJobManager;
|
|
@@ -253,6 +259,10 @@ const _Application = class _Application extends import_koa.default {
|
|
|
253
259
|
get dataSourceManager() {
|
|
254
260
|
return this._dataSourceManager;
|
|
255
261
|
}
|
|
262
|
+
_aesEncryptor;
|
|
263
|
+
get aesEncryptor() {
|
|
264
|
+
return this._aesEncryptor;
|
|
265
|
+
}
|
|
256
266
|
/**
|
|
257
267
|
* @internal
|
|
258
268
|
*/
|
|
@@ -373,7 +383,10 @@ const _Application = class _Application extends import_koa.default {
|
|
|
373
383
|
this._loaded = false;
|
|
374
384
|
}
|
|
375
385
|
async createCacheManager() {
|
|
376
|
-
this._cacheManager = await (0, import_cache2.createCacheManager)(this,
|
|
386
|
+
this._cacheManager = await (0, import_cache2.createCacheManager)(this, {
|
|
387
|
+
prefix: this.name,
|
|
388
|
+
...this.options.cacheManager
|
|
389
|
+
});
|
|
377
390
|
return this._cacheManager;
|
|
378
391
|
}
|
|
379
392
|
async load(options) {
|
|
@@ -396,6 +409,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
396
409
|
await oldDb.close();
|
|
397
410
|
}
|
|
398
411
|
}
|
|
412
|
+
this._aesEncryptor = await import_aes_encryptor.default.create(this);
|
|
399
413
|
if (this.cacheManager) {
|
|
400
414
|
await this.cacheManager.close();
|
|
401
415
|
}
|
|
@@ -833,6 +847,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
833
847
|
}
|
|
834
848
|
this.createMainDataSource(options);
|
|
835
849
|
this._cronJobManager = new import_cron_job_manager.CronJobManager(this);
|
|
850
|
+
this._env = new import_environment.Environment();
|
|
836
851
|
this._cli = this.createCLI();
|
|
837
852
|
this._i18n = (0, import_helper.createI18n)(options);
|
|
838
853
|
this.pubSubManager = (0, import_pub_sub_manager.createPubSubManager)(this, options.pubSubManager);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Environment {
|
|
10
|
+
private vars;
|
|
11
|
+
setVariable(key: string, value: string): void;
|
|
12
|
+
removeVariable(key: string): void;
|
|
13
|
+
getVariablesAndSecrets(): {};
|
|
14
|
+
getVariables(): {};
|
|
15
|
+
renderJsonTemplate(template: any, options?: {
|
|
16
|
+
omit?: string[];
|
|
17
|
+
}): any;
|
|
18
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var environment_exports = {};
|
|
39
|
+
__export(environment_exports, {
|
|
40
|
+
Environment: () => Environment
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(environment_exports);
|
|
43
|
+
var import_utils = require("@nocobase/utils");
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
const _Environment = class _Environment {
|
|
46
|
+
vars = {};
|
|
47
|
+
setVariable(key, value) {
|
|
48
|
+
this.vars[key] = value;
|
|
49
|
+
}
|
|
50
|
+
removeVariable(key) {
|
|
51
|
+
delete this.vars[key];
|
|
52
|
+
}
|
|
53
|
+
getVariablesAndSecrets() {
|
|
54
|
+
return this.vars;
|
|
55
|
+
}
|
|
56
|
+
getVariables() {
|
|
57
|
+
return this.vars;
|
|
58
|
+
}
|
|
59
|
+
renderJsonTemplate(template, options) {
|
|
60
|
+
if (options == null ? void 0 : options.omit) {
|
|
61
|
+
const omitTemplate = import_lodash.default.omit(template, options.omit);
|
|
62
|
+
const parsed = (0, import_utils.parse)(omitTemplate)({
|
|
63
|
+
$env: this.vars
|
|
64
|
+
});
|
|
65
|
+
for (const key of options.omit) {
|
|
66
|
+
import_lodash.default.set(parsed, key, import_lodash.default.get(template, key));
|
|
67
|
+
}
|
|
68
|
+
return parsed;
|
|
69
|
+
}
|
|
70
|
+
return (0, import_utils.parse)(template)({
|
|
71
|
+
$env: this.vars
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
__name(_Environment, "Environment");
|
|
76
|
+
let Environment = _Environment;
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
Environment
|
|
80
|
+
});
|
package/lib/helper.js
CHANGED
|
@@ -56,6 +56,7 @@ var import_i18next = __toESM(require("i18next"));
|
|
|
56
56
|
var import_koa_bodyparser = __toESM(require("koa-bodyparser"));
|
|
57
57
|
var import_perf_hooks = require("perf_hooks");
|
|
58
58
|
var import_data_wrapping = require("./middlewares/data-wrapping");
|
|
59
|
+
var import_extract_client_ip = require("./middlewares/extract-client-ip");
|
|
59
60
|
var import_i18n = require("./middlewares/i18n");
|
|
60
61
|
function createI18n(options) {
|
|
61
62
|
const instance = import_i18next.default.createInstance();
|
|
@@ -121,6 +122,7 @@ function registerMiddlewares(app, options) {
|
|
|
121
122
|
app.use((0, import_data_wrapping.dataWrapping)(), { tag: "dataWrapping", after: "cors" });
|
|
122
123
|
}
|
|
123
124
|
app.use(app.dataSourceManager.middleware(), { tag: "dataSource", after: "dataWrapping" });
|
|
125
|
+
app.use((0, import_extract_client_ip.extractClientIp)(), { tag: "extractClientIp", before: "cors" });
|
|
124
126
|
}
|
|
125
127
|
__name(registerMiddlewares, "registerMiddlewares");
|
|
126
128
|
const createAppProxy = /* @__PURE__ */ __name((app) => {
|
package/lib/index.d.ts
CHANGED
|
@@ -6,15 +6,16 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
export * from './aes-encryptor';
|
|
9
10
|
export * from './app-supervisor';
|
|
10
11
|
export * from './application';
|
|
11
12
|
export { Application as default } from './application';
|
|
13
|
+
export * from './audit-manager';
|
|
12
14
|
export * from './gateway';
|
|
13
15
|
export * as middlewares from './middlewares';
|
|
14
16
|
export * from './migration';
|
|
15
17
|
export * from './plugin';
|
|
16
18
|
export * from './plugin-manager';
|
|
17
|
-
export * from './audit-manager';
|
|
18
19
|
export * from './pub-sub-manager';
|
|
19
20
|
export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
20
21
|
export { appendToBuiltInPlugins, findAllPlugins, findBuiltInPlugins, findLocalPlugins, packageNameTrim, } from './plugin-manager/findPackageNames';
|
package/lib/index.js
CHANGED
|
@@ -48,15 +48,16 @@ __export(src_exports, {
|
|
|
48
48
|
runPluginStaticImports: () => import_run_plugin_static_imports.runPluginStaticImports
|
|
49
49
|
});
|
|
50
50
|
module.exports = __toCommonJS(src_exports);
|
|
51
|
+
__reExport(src_exports, require("./aes-encryptor"), module.exports);
|
|
51
52
|
__reExport(src_exports, require("./app-supervisor"), module.exports);
|
|
52
53
|
__reExport(src_exports, require("./application"), module.exports);
|
|
53
54
|
var import_application = require("./application");
|
|
55
|
+
__reExport(src_exports, require("./audit-manager"), module.exports);
|
|
54
56
|
__reExport(src_exports, require("./gateway"), module.exports);
|
|
55
57
|
var middlewares = __toESM(require("./middlewares"));
|
|
56
58
|
__reExport(src_exports, require("./migration"), module.exports);
|
|
57
59
|
__reExport(src_exports, require("./plugin"), module.exports);
|
|
58
60
|
__reExport(src_exports, require("./plugin-manager"), module.exports);
|
|
59
|
-
__reExport(src_exports, require("./audit-manager"), module.exports);
|
|
60
61
|
__reExport(src_exports, require("./pub-sub-manager"), module.exports);
|
|
61
62
|
var import_findPackageNames = require("./plugin-manager/findPackageNames");
|
|
62
63
|
var import_run_plugin_static_imports = require("./run-plugin-static-imports");
|
|
@@ -71,12 +72,13 @@ const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
|
71
72
|
middlewares,
|
|
72
73
|
packageNameTrim,
|
|
73
74
|
runPluginStaticImports,
|
|
75
|
+
...require("./aes-encryptor"),
|
|
74
76
|
...require("./app-supervisor"),
|
|
75
77
|
...require("./application"),
|
|
78
|
+
...require("./audit-manager"),
|
|
76
79
|
...require("./gateway"),
|
|
77
80
|
...require("./migration"),
|
|
78
81
|
...require("./plugin"),
|
|
79
82
|
...require("./plugin-manager"),
|
|
80
|
-
...require("./audit-manager"),
|
|
81
83
|
...require("./pub-sub-manager")
|
|
82
84
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Context, Next } from '@nocobase/actions';
|
|
10
|
+
export declare function extractClientIp(): (ctx: Context, next: Next) => Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var extract_client_ip_exports = {};
|
|
29
|
+
__export(extract_client_ip_exports, {
|
|
30
|
+
extractClientIp: () => extractClientIp
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(extract_client_ip_exports);
|
|
33
|
+
function extractClientIp() {
|
|
34
|
+
return /* @__PURE__ */ __name(async function extractClientIp2(ctx, next) {
|
|
35
|
+
const forwardedFor = ctx.get("X-Forwarded-For");
|
|
36
|
+
const ipArray = forwardedFor ? forwardedFor.split(",") : [];
|
|
37
|
+
const clientIp = ipArray.length > 0 ? ipArray[0].trim() : ctx.request.ip;
|
|
38
|
+
ctx.state.clientIp = clientIp;
|
|
39
|
+
await next();
|
|
40
|
+
}, "extractClientIp");
|
|
41
|
+
}
|
|
42
|
+
__name(extractClientIp, "extractClientIp");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
extractClientIp
|
|
46
|
+
});
|
package/lib/middlewares/index.js
CHANGED
|
@@ -31,9 +31,11 @@ __export(middlewares_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(middlewares_exports);
|
|
33
33
|
__reExport(middlewares_exports, require("./data-wrapping"), module.exports);
|
|
34
|
+
__reExport(middlewares_exports, require("./extract-client-ip"), module.exports);
|
|
34
35
|
var import_parse_variables = require("./parse-variables");
|
|
35
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
37
|
0 && (module.exports = {
|
|
37
38
|
parseVariables,
|
|
38
|
-
...require("./data-wrapping")
|
|
39
|
+
...require("./data-wrapping"),
|
|
40
|
+
...require("./extract-client-ip")
|
|
39
41
|
});
|
|
@@ -33,6 +33,7 @@ var import_database = require("@nocobase/database");
|
|
|
33
33
|
var collection_default = (0, import_database.defineCollection)({
|
|
34
34
|
name: "applicationPlugins",
|
|
35
35
|
dumpRules: "required",
|
|
36
|
+
migrationRules: ["overwrite", "schema-only"],
|
|
36
37
|
repository: "PluginManagerRepository",
|
|
37
38
|
origin: "@nocobase/server",
|
|
38
39
|
fields: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "1.6.0-beta.
|
|
3
|
+
"version": "1.6.0-beta.4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"@koa/cors": "^3.1.0",
|
|
11
11
|
"@koa/multer": "^3.0.2",
|
|
12
12
|
"@koa/router": "^9.4.0",
|
|
13
|
-
"@nocobase/acl": "1.6.0-beta.
|
|
14
|
-
"@nocobase/actions": "1.6.0-beta.
|
|
15
|
-
"@nocobase/auth": "1.6.0-beta.
|
|
16
|
-
"@nocobase/cache": "1.6.0-beta.
|
|
17
|
-
"@nocobase/data-source-manager": "1.6.0-beta.
|
|
18
|
-
"@nocobase/database": "1.6.0-beta.
|
|
19
|
-
"@nocobase/evaluators": "1.6.0-beta.
|
|
20
|
-
"@nocobase/lock-manager": "1.6.0-beta.
|
|
21
|
-
"@nocobase/logger": "1.6.0-beta.
|
|
22
|
-
"@nocobase/resourcer": "1.6.0-beta.
|
|
23
|
-
"@nocobase/sdk": "1.6.0-beta.
|
|
24
|
-
"@nocobase/telemetry": "1.6.0-beta.
|
|
25
|
-
"@nocobase/utils": "1.6.0-beta.
|
|
13
|
+
"@nocobase/acl": "1.6.0-beta.4",
|
|
14
|
+
"@nocobase/actions": "1.6.0-beta.4",
|
|
15
|
+
"@nocobase/auth": "1.6.0-beta.4",
|
|
16
|
+
"@nocobase/cache": "1.6.0-beta.4",
|
|
17
|
+
"@nocobase/data-source-manager": "1.6.0-beta.4",
|
|
18
|
+
"@nocobase/database": "1.6.0-beta.4",
|
|
19
|
+
"@nocobase/evaluators": "1.6.0-beta.4",
|
|
20
|
+
"@nocobase/lock-manager": "1.6.0-beta.4",
|
|
21
|
+
"@nocobase/logger": "1.6.0-beta.4",
|
|
22
|
+
"@nocobase/resourcer": "1.6.0-beta.4",
|
|
23
|
+
"@nocobase/sdk": "1.6.0-beta.4",
|
|
24
|
+
"@nocobase/telemetry": "1.6.0-beta.4",
|
|
25
|
+
"@nocobase/utils": "1.6.0-beta.4",
|
|
26
26
|
"@types/decompress": "4.2.7",
|
|
27
27
|
"@types/ini": "^1.3.31",
|
|
28
28
|
"@types/koa-send": "^4.1.3",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"@types/serve-handler": "^6.1.1",
|
|
57
57
|
"@types/ws": "^8.5.5"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "4419f433716dadf34886b261d9abe20e74551044"
|
|
60
60
|
}
|