@ruiapp/rapid-core 0.7.2 → 0.7.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/dist/helpers/licenseHelper.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +28 -18
- package/package.json +1 -1
- package/src/helpers/licenseHelper.ts +12 -3
- package/src/index.ts +2 -0
- package/src/plugins/auth/actionHandlers/createSession.ts +1 -1
- package/src/plugins/cronJob/CronJobPlugin.ts +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IRpdServer } from "../core/server";
|
|
2
2
|
import { Logger } from "../facilities/log/LogFacility";
|
|
3
|
-
export declare function validateLicense(
|
|
3
|
+
export declare function validateLicense(server: IRpdServer): void;
|
|
4
|
+
export declare function tryValidateLicense(logger: Logger, server: IRpdServer): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./utilities/accessControlUtility";
|
|
|
11
11
|
export * from "./utilities/entityUtility";
|
|
12
12
|
export * from "./utilities/jwtUtility";
|
|
13
13
|
export * from "./utilities/timeUtility";
|
|
14
|
+
export * from "./helpers/licenseHelper";
|
|
14
15
|
export * from "./deno-std/http/cookie";
|
|
15
16
|
export { mapDbRowToEntity } from "./dataAccess/entityMapper";
|
|
16
17
|
export * as bootstrapApplicationConfig from "./bootstrapApplicationConfig";
|
package/dist/index.js
CHANGED
|
@@ -4843,6 +4843,30 @@ async function generateJwtSecretKey() {
|
|
|
4843
4843
|
return encode(exportedKey);
|
|
4844
4844
|
}
|
|
4845
4845
|
|
|
4846
|
+
function validateLicense(server) {
|
|
4847
|
+
const licenseService = server.getService("licenseService");
|
|
4848
|
+
const license = licenseService.getLicense();
|
|
4849
|
+
if (!license) {
|
|
4850
|
+
const errorMessage = `无法获取系统授权信息。`;
|
|
4851
|
+
throw new Error(errorMessage);
|
|
4852
|
+
}
|
|
4853
|
+
if (licenseService.isExpired()) {
|
|
4854
|
+
const expireDate = lodash.get(license.authority, "expireDate");
|
|
4855
|
+
const errorMessage = `您的系统授权已于${expireDate}过期。`;
|
|
4856
|
+
throw new Error(errorMessage);
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
function tryValidateLicense(logger, server) {
|
|
4860
|
+
try {
|
|
4861
|
+
validateLicense(server);
|
|
4862
|
+
return true;
|
|
4863
|
+
}
|
|
4864
|
+
catch (err) {
|
|
4865
|
+
logger.error("授权验证失败:%s", err.message || "");
|
|
4866
|
+
}
|
|
4867
|
+
return false;
|
|
4868
|
+
}
|
|
4869
|
+
|
|
4846
4870
|
const values = new Map();
|
|
4847
4871
|
async function set(key, value, options) {
|
|
4848
4872
|
let expireAt = -1;
|
|
@@ -6652,28 +6676,12 @@ var changePassword$1 = /*#__PURE__*/Object.freeze({
|
|
|
6652
6676
|
handler: handler$e
|
|
6653
6677
|
});
|
|
6654
6678
|
|
|
6655
|
-
function validateLicense(logger, server) {
|
|
6656
|
-
const licenseService = server.getService("licenseService");
|
|
6657
|
-
const license = licenseService.getLicense();
|
|
6658
|
-
if (!license) {
|
|
6659
|
-
const errorMessage = `无法获取系统授权信息。`;
|
|
6660
|
-
logger.error(errorMessage);
|
|
6661
|
-
throw new Error(errorMessage);
|
|
6662
|
-
}
|
|
6663
|
-
if (licenseService.isExpired()) {
|
|
6664
|
-
const expireDate = lodash.get(license.authority, "expireDate");
|
|
6665
|
-
const errorMessage = `您的系统授权已于${expireDate}过期。`;
|
|
6666
|
-
logger.error(errorMessage);
|
|
6667
|
-
throw new Error(errorMessage);
|
|
6668
|
-
}
|
|
6669
|
-
}
|
|
6670
|
-
|
|
6671
6679
|
const code$d = "createSession";
|
|
6672
6680
|
async function handler$d(plugin, ctx, options) {
|
|
6673
6681
|
const { server, input, routerContext: routeContext, logger } = ctx;
|
|
6674
6682
|
const { response } = routeContext;
|
|
6675
6683
|
const { account, password } = input;
|
|
6676
|
-
validateLicense(
|
|
6684
|
+
validateLicense(server);
|
|
6677
6685
|
const userDataAccessor = server.getDataAccessor({
|
|
6678
6686
|
singularCode: "oc_user",
|
|
6679
6687
|
});
|
|
@@ -8516,7 +8524,7 @@ class CronJobPlugin {
|
|
|
8516
8524
|
async executeJob(server, job) {
|
|
8517
8525
|
const logger = server.getLogger();
|
|
8518
8526
|
try {
|
|
8519
|
-
validateLicense(
|
|
8527
|
+
validateLicense(server);
|
|
8520
8528
|
let handlerContext = {
|
|
8521
8529
|
logger,
|
|
8522
8530
|
routerContext: null,
|
|
@@ -8957,4 +8965,6 @@ exports.getSetCookies = getSetCookies;
|
|
|
8957
8965
|
exports.isAccessAllowed = isAccessAllowed;
|
|
8958
8966
|
exports.mapDbRowToEntity = mapDbRowToEntity;
|
|
8959
8967
|
exports.setCookie = setCookie;
|
|
8968
|
+
exports.tryValidateLicense = tryValidateLicense;
|
|
8969
|
+
exports.validateLicense = validateLicense;
|
|
8960
8970
|
exports.verifyJwt = verifyJwt;
|
package/package.json
CHANGED
|
@@ -3,18 +3,27 @@ import { IRpdServer } from "~/core/server";
|
|
|
3
3
|
import { Logger } from "~/facilities/log/LogFacility";
|
|
4
4
|
import LicenseService from "~/plugins/license/LicenseService";
|
|
5
5
|
|
|
6
|
-
export function validateLicense(
|
|
6
|
+
export function validateLicense(server: IRpdServer) {
|
|
7
7
|
const licenseService = server.getService<LicenseService>("licenseService");
|
|
8
8
|
const license = licenseService.getLicense();
|
|
9
9
|
if (!license) {
|
|
10
10
|
const errorMessage = `无法获取系统授权信息。`;
|
|
11
|
-
logger.error(errorMessage);
|
|
12
11
|
throw new Error(errorMessage);
|
|
13
12
|
}
|
|
14
13
|
if (licenseService.isExpired()) {
|
|
15
14
|
const expireDate = get(license.authority, "expireDate");
|
|
16
15
|
const errorMessage = `您的系统授权已于${expireDate}过期。`;
|
|
17
|
-
logger.error(errorMessage);
|
|
18
16
|
throw new Error(errorMessage);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
19
|
+
|
|
20
|
+
export function tryValidateLicense(logger: Logger, server: IRpdServer) {
|
|
21
|
+
try {
|
|
22
|
+
validateLicense(server);
|
|
23
|
+
return true;
|
|
24
|
+
} catch (err: any) {
|
|
25
|
+
logger.error("授权验证失败:%s", err.message || "");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return false;
|
|
29
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ export * from "./utilities/entityUtility";
|
|
|
17
17
|
export * from "./utilities/jwtUtility";
|
|
18
18
|
export * from "./utilities/timeUtility";
|
|
19
19
|
|
|
20
|
+
export * from "./helpers/licenseHelper";
|
|
21
|
+
|
|
20
22
|
export * from "./deno-std/http/cookie";
|
|
21
23
|
|
|
22
24
|
export { mapDbRowToEntity } from "./dataAccess/entityMapper";
|
|
@@ -12,7 +12,7 @@ export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, op
|
|
|
12
12
|
const { response } = routeContext;
|
|
13
13
|
const { account, password } = input;
|
|
14
14
|
|
|
15
|
-
validateLicense(
|
|
15
|
+
validateLicense(server);
|
|
16
16
|
|
|
17
17
|
const userDataAccessor = server.getDataAccessor({
|
|
18
18
|
singularCode: "oc_user",
|
|
@@ -91,7 +91,7 @@ class CronJobPlugin implements RapidPlugin {
|
|
|
91
91
|
async executeJob(server: IRpdServer, job: CronJobConfiguration) {
|
|
92
92
|
const logger = server.getLogger();
|
|
93
93
|
try {
|
|
94
|
-
validateLicense(
|
|
94
|
+
validateLicense(server);
|
|
95
95
|
|
|
96
96
|
let handlerContext: ActionHandlerContext = {
|
|
97
97
|
logger,
|