@ruiapp/rapid-core 0.9.4 → 0.9.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/dist/index.js +169 -123
- package/dist/plugins/license/LicenseService.d.ts +2 -0
- package/dist/plugins/license/actionHandlers/index.d.ts +2 -1
- package/dist/plugins/license/actionHandlers/updateLicense.d.ts +9 -0
- package/dist/plugins/license/routes/index.d.ts +12 -2
- package/dist/plugins/license/routes/updateLicense.d.ts +12 -0
- package/package.json +1 -1
- package/src/plugins/auth/AuthPlugin.ts +1 -1
- package/src/plugins/license/LicenseService.ts +25 -6
- package/src/plugins/license/actionHandlers/index.ts +2 -1
- package/src/plugins/license/actionHandlers/updateLicense.ts +24 -0
- package/src/plugins/license/routes/index.ts +2 -1
- package/src/plugins/license/routes/updateLicense.ts +15 -0
- package/src/utilities/passwordUtility.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -5066,7 +5066,7 @@ async function generatePasswordHash(password, salt) {
|
|
|
5066
5066
|
* @returns
|
|
5067
5067
|
*/
|
|
5068
5068
|
async function validatePassword(password, passwordHash) {
|
|
5069
|
-
const isMatch = await bcrypt__default["default"].compare(password, passwordHash);
|
|
5069
|
+
const isMatch = await bcrypt__default["default"].compare(password || "", passwordHash || "");
|
|
5070
5070
|
return isMatch;
|
|
5071
5071
|
}
|
|
5072
5072
|
|
|
@@ -5174,32 +5174,32 @@ class CacheFactory {
|
|
|
5174
5174
|
}
|
|
5175
5175
|
}
|
|
5176
5176
|
|
|
5177
|
-
const code$
|
|
5178
|
-
async function handler$
|
|
5177
|
+
const code$w = "listMetaModels";
|
|
5178
|
+
async function handler$w(plugin, ctx, options) {
|
|
5179
5179
|
const { applicationConfig } = ctx;
|
|
5180
5180
|
ctx.output = { list: applicationConfig.models };
|
|
5181
5181
|
}
|
|
5182
5182
|
|
|
5183
5183
|
var listMetaModels = /*#__PURE__*/Object.freeze({
|
|
5184
5184
|
__proto__: null,
|
|
5185
|
-
code: code$
|
|
5186
|
-
handler: handler$
|
|
5185
|
+
code: code$w,
|
|
5186
|
+
handler: handler$w
|
|
5187
5187
|
});
|
|
5188
5188
|
|
|
5189
|
-
const code$
|
|
5190
|
-
async function handler$
|
|
5189
|
+
const code$v = "listMetaRoutes";
|
|
5190
|
+
async function handler$v(plugin, ctx, options) {
|
|
5191
5191
|
const { applicationConfig } = ctx;
|
|
5192
5192
|
ctx.output = { list: applicationConfig.routes };
|
|
5193
5193
|
}
|
|
5194
5194
|
|
|
5195
5195
|
var listMetaRoutes = /*#__PURE__*/Object.freeze({
|
|
5196
5196
|
__proto__: null,
|
|
5197
|
-
code: code$
|
|
5198
|
-
handler: handler$
|
|
5197
|
+
code: code$v,
|
|
5198
|
+
handler: handler$v
|
|
5199
5199
|
});
|
|
5200
5200
|
|
|
5201
|
-
const code$
|
|
5202
|
-
async function handler$
|
|
5201
|
+
const code$u = "getMetaModelDetail";
|
|
5202
|
+
async function handler$u(plugin, ctx, options) {
|
|
5203
5203
|
const { server, input } = ctx;
|
|
5204
5204
|
const model = server.getModel(input);
|
|
5205
5205
|
ctx.output = model;
|
|
@@ -5207,8 +5207,8 @@ async function handler$t(plugin, ctx, options) {
|
|
|
5207
5207
|
|
|
5208
5208
|
var getMetaModelDetail = /*#__PURE__*/Object.freeze({
|
|
5209
5209
|
__proto__: null,
|
|
5210
|
-
code: code$
|
|
5211
|
-
handler: handler$
|
|
5210
|
+
code: code$u,
|
|
5211
|
+
handler: handler$u
|
|
5212
5212
|
});
|
|
5213
5213
|
|
|
5214
5214
|
function removeFiltersWithNullValue(filters) {
|
|
@@ -5797,9 +5797,9 @@ async function runCollectionEntityActionHandler(ctx, options, code, autoMergeInp
|
|
|
5797
5797
|
}
|
|
5798
5798
|
}
|
|
5799
5799
|
|
|
5800
|
-
const code$
|
|
5801
|
-
async function handler$
|
|
5802
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5800
|
+
const code$t = "findCollectionEntities";
|
|
5801
|
+
async function handler$t(plugin, ctx, options) {
|
|
5802
|
+
await runCollectionEntityActionHandler(ctx, options, code$t, true, false, async (entityManager, input) => {
|
|
5803
5803
|
const { routerContext: routeContext } = ctx;
|
|
5804
5804
|
input.filters = removeFiltersWithNullValue(input.filters);
|
|
5805
5805
|
input.routeContext = routeContext;
|
|
@@ -5816,13 +5816,13 @@ async function handler$s(plugin, ctx, options) {
|
|
|
5816
5816
|
|
|
5817
5817
|
var findCollectionEntities = /*#__PURE__*/Object.freeze({
|
|
5818
5818
|
__proto__: null,
|
|
5819
|
-
code: code$
|
|
5820
|
-
handler: handler$
|
|
5819
|
+
code: code$t,
|
|
5820
|
+
handler: handler$t
|
|
5821
5821
|
});
|
|
5822
5822
|
|
|
5823
|
-
const code$
|
|
5824
|
-
async function handler$
|
|
5825
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5823
|
+
const code$s = "findCollectionEntityById";
|
|
5824
|
+
async function handler$s(plugin, ctx, options) {
|
|
5825
|
+
await runCollectionEntityActionHandler(ctx, options, code$s, true, true, async (entityManager, input) => {
|
|
5826
5826
|
const { routerContext: routeContext } = ctx;
|
|
5827
5827
|
const { id } = input;
|
|
5828
5828
|
const entity = await entityManager.findById({
|
|
@@ -5844,13 +5844,13 @@ async function handler$r(plugin, ctx, options) {
|
|
|
5844
5844
|
|
|
5845
5845
|
var findCollectionEntityById = /*#__PURE__*/Object.freeze({
|
|
5846
5846
|
__proto__: null,
|
|
5847
|
-
code: code$
|
|
5848
|
-
handler: handler$
|
|
5847
|
+
code: code$s,
|
|
5848
|
+
handler: handler$s
|
|
5849
5849
|
});
|
|
5850
5850
|
|
|
5851
|
-
const code$
|
|
5852
|
-
async function handler$
|
|
5853
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5851
|
+
const code$r = "countCollectionEntities";
|
|
5852
|
+
async function handler$r(plugin, ctx, options) {
|
|
5853
|
+
await runCollectionEntityActionHandler(ctx, options, code$r, true, false, async (entityManager, input) => {
|
|
5854
5854
|
const { routerContext: routeContext } = ctx;
|
|
5855
5855
|
input.filters = removeFiltersWithNullValue(input.filters);
|
|
5856
5856
|
input.routeContext = routeContext;
|
|
@@ -5861,13 +5861,13 @@ async function handler$q(plugin, ctx, options) {
|
|
|
5861
5861
|
|
|
5862
5862
|
var countCollectionEntities = /*#__PURE__*/Object.freeze({
|
|
5863
5863
|
__proto__: null,
|
|
5864
|
-
code: code$
|
|
5865
|
-
handler: handler$
|
|
5864
|
+
code: code$r,
|
|
5865
|
+
handler: handler$r
|
|
5866
5866
|
});
|
|
5867
5867
|
|
|
5868
|
-
const code$
|
|
5869
|
-
async function handler$
|
|
5870
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5868
|
+
const code$q = "createCollectionEntity";
|
|
5869
|
+
async function handler$q(plugin, ctx, options) {
|
|
5870
|
+
await runCollectionEntityActionHandler(ctx, options, code$q, true, true, async (entityManager, input) => {
|
|
5871
5871
|
const { routerContext: routeContext } = ctx;
|
|
5872
5872
|
const output = await entityManager.createEntity({
|
|
5873
5873
|
entity: input,
|
|
@@ -5879,16 +5879,16 @@ async function handler$p(plugin, ctx, options) {
|
|
|
5879
5879
|
|
|
5880
5880
|
var createCollectionEntity = /*#__PURE__*/Object.freeze({
|
|
5881
5881
|
__proto__: null,
|
|
5882
|
-
code: code$
|
|
5883
|
-
handler: handler$
|
|
5882
|
+
code: code$q,
|
|
5883
|
+
handler: handler$q
|
|
5884
5884
|
});
|
|
5885
5885
|
|
|
5886
|
-
const code$
|
|
5887
|
-
async function handler$
|
|
5886
|
+
const code$p = "createCollectionEntitiesBatch";
|
|
5887
|
+
async function handler$p(plugin, ctx, options) {
|
|
5888
5888
|
const { input } = ctx;
|
|
5889
5889
|
const { noTransaction } = input;
|
|
5890
5890
|
const { defaultInput, fixedInput } = options;
|
|
5891
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5891
|
+
await runCollectionEntityActionHandler(ctx, options, code$p, false, !noTransaction, async (entityManager, input) => {
|
|
5892
5892
|
const { routerContext: routeContext } = ctx;
|
|
5893
5893
|
const { entities } = input;
|
|
5894
5894
|
if (!lodash.isArray(entities)) {
|
|
@@ -5926,13 +5926,13 @@ async function createEntities(options) {
|
|
|
5926
5926
|
|
|
5927
5927
|
var createCollectionEntitiesBatch = /*#__PURE__*/Object.freeze({
|
|
5928
5928
|
__proto__: null,
|
|
5929
|
-
code: code$
|
|
5930
|
-
handler: handler$
|
|
5929
|
+
code: code$p,
|
|
5930
|
+
handler: handler$p
|
|
5931
5931
|
});
|
|
5932
5932
|
|
|
5933
|
-
const code$
|
|
5934
|
-
async function handler$
|
|
5935
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5933
|
+
const code$o = "updateCollectionEntityById";
|
|
5934
|
+
async function handler$o(plugin, ctx, options) {
|
|
5935
|
+
await runCollectionEntityActionHandler(ctx, options, code$o, true, true, async (entityManager, input) => {
|
|
5936
5936
|
const { routerContext: routeContext } = ctx;
|
|
5937
5937
|
const operation = input.$operation;
|
|
5938
5938
|
if (operation) {
|
|
@@ -5961,15 +5961,15 @@ async function handler$n(plugin, ctx, options) {
|
|
|
5961
5961
|
|
|
5962
5962
|
var updateCollectionEntityById = /*#__PURE__*/Object.freeze({
|
|
5963
5963
|
__proto__: null,
|
|
5964
|
-
code: code$
|
|
5965
|
-
handler: handler$
|
|
5964
|
+
code: code$o,
|
|
5965
|
+
handler: handler$o
|
|
5966
5966
|
});
|
|
5967
5967
|
|
|
5968
|
-
const code$
|
|
5969
|
-
async function handler$
|
|
5968
|
+
const code$n = "deleteCollectionEntities";
|
|
5969
|
+
async function handler$n(plugin, ctx, options) {
|
|
5970
5970
|
const { input } = ctx;
|
|
5971
5971
|
const { noTransaction } = input;
|
|
5972
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5972
|
+
await runCollectionEntityActionHandler(ctx, options, code$n, true, !noTransaction, async (entityManager, input) => {
|
|
5973
5973
|
const { routerContext: routeContext } = ctx;
|
|
5974
5974
|
const { filters } = input;
|
|
5975
5975
|
if (!filters || !filters.length) {
|
|
@@ -5991,13 +5991,13 @@ async function handler$m(plugin, ctx, options) {
|
|
|
5991
5991
|
|
|
5992
5992
|
var deleteCollectionEntities = /*#__PURE__*/Object.freeze({
|
|
5993
5993
|
__proto__: null,
|
|
5994
|
-
code: code$
|
|
5995
|
-
handler: handler$
|
|
5994
|
+
code: code$n,
|
|
5995
|
+
handler: handler$n
|
|
5996
5996
|
});
|
|
5997
5997
|
|
|
5998
|
-
const code$
|
|
5999
|
-
async function handler$
|
|
6000
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
5998
|
+
const code$m = "deleteCollectionEntityById";
|
|
5999
|
+
async function handler$m(plugin, ctx, options) {
|
|
6000
|
+
await runCollectionEntityActionHandler(ctx, options, code$m, true, true, async (entityManager, input) => {
|
|
6001
6001
|
const { routerContext: routeContext } = ctx;
|
|
6002
6002
|
await entityManager.deleteById({
|
|
6003
6003
|
id: input.id,
|
|
@@ -6009,13 +6009,13 @@ async function handler$l(plugin, ctx, options) {
|
|
|
6009
6009
|
|
|
6010
6010
|
var deleteCollectionEntityById = /*#__PURE__*/Object.freeze({
|
|
6011
6011
|
__proto__: null,
|
|
6012
|
-
code: code$
|
|
6013
|
-
handler: handler$
|
|
6012
|
+
code: code$m,
|
|
6013
|
+
handler: handler$m
|
|
6014
6014
|
});
|
|
6015
6015
|
|
|
6016
|
-
const code$
|
|
6017
|
-
async function handler$
|
|
6018
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
6016
|
+
const code$l = "addEntityRelations";
|
|
6017
|
+
async function handler$l(plugin, ctx, options) {
|
|
6018
|
+
await runCollectionEntityActionHandler(ctx, options, code$l, true, true, async (entityManager, input) => {
|
|
6019
6019
|
const { routerContext: routeContext } = ctx;
|
|
6020
6020
|
input.routeContext = routeContext;
|
|
6021
6021
|
await entityManager.addRelations(input, plugin);
|
|
@@ -6025,13 +6025,13 @@ async function handler$k(plugin, ctx, options) {
|
|
|
6025
6025
|
|
|
6026
6026
|
var addEntityRelations = /*#__PURE__*/Object.freeze({
|
|
6027
6027
|
__proto__: null,
|
|
6028
|
-
code: code$
|
|
6029
|
-
handler: handler$
|
|
6028
|
+
code: code$l,
|
|
6029
|
+
handler: handler$l
|
|
6030
6030
|
});
|
|
6031
6031
|
|
|
6032
|
-
const code$
|
|
6033
|
-
async function handler$
|
|
6034
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
6032
|
+
const code$k = "removeEntityRelations";
|
|
6033
|
+
async function handler$k(plugin, ctx, options) {
|
|
6034
|
+
await runCollectionEntityActionHandler(ctx, options, code$k, true, true, async (entityManager, input) => {
|
|
6035
6035
|
const { routerContext: routeContext } = ctx;
|
|
6036
6036
|
input.routeContext = routeContext;
|
|
6037
6037
|
await entityManager.removeRelations(input, plugin);
|
|
@@ -6041,16 +6041,16 @@ async function handler$j(plugin, ctx, options) {
|
|
|
6041
6041
|
|
|
6042
6042
|
var removeEntityRelations = /*#__PURE__*/Object.freeze({
|
|
6043
6043
|
__proto__: null,
|
|
6044
|
-
code: code$
|
|
6045
|
-
handler: handler$
|
|
6044
|
+
code: code$k,
|
|
6045
|
+
handler: handler$k
|
|
6046
6046
|
});
|
|
6047
6047
|
|
|
6048
|
-
const code$
|
|
6049
|
-
async function handler$
|
|
6048
|
+
const code$j = "queryDatabase";
|
|
6049
|
+
async function handler$j(plugin, ctx, options) {
|
|
6050
6050
|
const { logger, server, input } = ctx;
|
|
6051
6051
|
const { sql, querySingle, defaultInput, fixedInput } = options;
|
|
6052
6052
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
6053
|
-
logger.debug(`Running ${code$
|
|
6053
|
+
logger.debug(`Running ${code$j} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
6054
6054
|
const result = await server.queryDatabaseObject(sql, mergedInput);
|
|
6055
6055
|
if (querySingle) {
|
|
6056
6056
|
ctx.output = lodash.first(result);
|
|
@@ -6062,8 +6062,8 @@ async function handler$i(plugin, ctx, options) {
|
|
|
6062
6062
|
|
|
6063
6063
|
var queryDatabase = /*#__PURE__*/Object.freeze({
|
|
6064
6064
|
__proto__: null,
|
|
6065
|
-
code: code$
|
|
6066
|
-
handler: handler$
|
|
6065
|
+
code: code$j,
|
|
6066
|
+
handler: handler$j
|
|
6067
6067
|
});
|
|
6068
6068
|
|
|
6069
6069
|
/**
|
|
@@ -6241,21 +6241,21 @@ async function sendSourceResponse(proxyCtx, targetRes) {
|
|
|
6241
6241
|
srcRes.body = targetRes.body;
|
|
6242
6242
|
}
|
|
6243
6243
|
|
|
6244
|
-
const code$
|
|
6245
|
-
async function handler$
|
|
6244
|
+
const code$i = "httpProxy";
|
|
6245
|
+
async function handler$i(plugin, ctx, options) {
|
|
6246
6246
|
const { logger } = ctx;
|
|
6247
|
-
logger.debug(`Running ${code$
|
|
6247
|
+
logger.debug(`Running ${code$i} handler...`);
|
|
6248
6248
|
await doProxy(ctx.routerContext, options);
|
|
6249
6249
|
}
|
|
6250
6250
|
|
|
6251
6251
|
var httpProxyActionHandler = /*#__PURE__*/Object.freeze({
|
|
6252
6252
|
__proto__: null,
|
|
6253
|
-
code: code$
|
|
6254
|
-
handler: handler$
|
|
6253
|
+
code: code$i,
|
|
6254
|
+
handler: handler$i
|
|
6255
6255
|
});
|
|
6256
6256
|
|
|
6257
|
-
const code$
|
|
6258
|
-
async function handler$
|
|
6257
|
+
const code$h = "mock";
|
|
6258
|
+
async function handler$h(plugin, ctx, options) {
|
|
6259
6259
|
const { logger, routerContext } = ctx;
|
|
6260
6260
|
const { response } = routerContext;
|
|
6261
6261
|
const { responseTime, responseStatus, responseHeaders, responseBody } = options;
|
|
@@ -6274,8 +6274,8 @@ function waitMilliseconds(ms) {
|
|
|
6274
6274
|
|
|
6275
6275
|
var mockActionHandler = /*#__PURE__*/Object.freeze({
|
|
6276
6276
|
__proto__: null,
|
|
6277
|
-
code: code$
|
|
6278
|
-
handler: handler$
|
|
6277
|
+
code: code$h,
|
|
6278
|
+
handler: handler$h
|
|
6279
6279
|
});
|
|
6280
6280
|
|
|
6281
6281
|
/**
|
|
@@ -6323,8 +6323,8 @@ class RouteManager {
|
|
|
6323
6323
|
}
|
|
6324
6324
|
}
|
|
6325
6325
|
|
|
6326
|
-
const code$
|
|
6327
|
-
async function handler$
|
|
6326
|
+
const code$g = "generateSn";
|
|
6327
|
+
async function handler$g(plugin, ctx, options) {
|
|
6328
6328
|
const { server, routerContext: routeContext } = ctx;
|
|
6329
6329
|
const input = ctx.input;
|
|
6330
6330
|
if (options?.ruleCode) {
|
|
@@ -6342,8 +6342,8 @@ async function handler$f(plugin, ctx, options) {
|
|
|
6342
6342
|
|
|
6343
6343
|
var generateSn$1 = /*#__PURE__*/Object.freeze({
|
|
6344
6344
|
__proto__: null,
|
|
6345
|
-
code: code$
|
|
6346
|
-
handler: handler$
|
|
6345
|
+
code: code$g,
|
|
6346
|
+
handler: handler$g
|
|
6347
6347
|
});
|
|
6348
6348
|
|
|
6349
6349
|
var pluginActionHandlers$8 = [generateSn$1];
|
|
@@ -6923,8 +6923,8 @@ class WebhooksPlugin {
|
|
|
6923
6923
|
}
|
|
6924
6924
|
}
|
|
6925
6925
|
|
|
6926
|
-
const code$
|
|
6927
|
-
async function handler$
|
|
6926
|
+
const code$f = "changePassword";
|
|
6927
|
+
async function handler$f(plugin, ctx, options) {
|
|
6928
6928
|
const { server, input, routerContext: routeContext } = ctx;
|
|
6929
6929
|
const { id, oldPassword, newPassword } = input;
|
|
6930
6930
|
const userId = routeContext.state.userId;
|
|
@@ -6966,12 +6966,12 @@ async function handler$e(plugin, ctx, options) {
|
|
|
6966
6966
|
|
|
6967
6967
|
var changePassword$1 = /*#__PURE__*/Object.freeze({
|
|
6968
6968
|
__proto__: null,
|
|
6969
|
-
code: code$
|
|
6970
|
-
handler: handler$
|
|
6969
|
+
code: code$f,
|
|
6970
|
+
handler: handler$f
|
|
6971
6971
|
});
|
|
6972
6972
|
|
|
6973
|
-
const code$
|
|
6974
|
-
async function handler$
|
|
6973
|
+
const code$e = "createSession";
|
|
6974
|
+
async function handler$e(plugin, ctx, options) {
|
|
6975
6975
|
const { server, input, routerContext: routeContext, logger } = ctx;
|
|
6976
6976
|
const { response } = routeContext;
|
|
6977
6977
|
const { account, password } = input;
|
|
@@ -7021,12 +7021,12 @@ async function handler$d(plugin, ctx, options) {
|
|
|
7021
7021
|
|
|
7022
7022
|
var createSession = /*#__PURE__*/Object.freeze({
|
|
7023
7023
|
__proto__: null,
|
|
7024
|
-
code: code$
|
|
7025
|
-
handler: handler$
|
|
7024
|
+
code: code$e,
|
|
7025
|
+
handler: handler$e
|
|
7026
7026
|
});
|
|
7027
7027
|
|
|
7028
|
-
const code$
|
|
7029
|
-
async function handler$
|
|
7028
|
+
const code$d = "deleteSession";
|
|
7029
|
+
async function handler$d(plugin, ctx, options) {
|
|
7030
7030
|
const { server, input, routerContext } = ctx;
|
|
7031
7031
|
const { response } = routerContext;
|
|
7032
7032
|
setCookie(response.headers, {
|
|
@@ -7039,12 +7039,12 @@ async function handler$c(plugin, ctx, options) {
|
|
|
7039
7039
|
|
|
7040
7040
|
var deleteSession = /*#__PURE__*/Object.freeze({
|
|
7041
7041
|
__proto__: null,
|
|
7042
|
-
code: code$
|
|
7043
|
-
handler: handler$
|
|
7042
|
+
code: code$d,
|
|
7043
|
+
handler: handler$d
|
|
7044
7044
|
});
|
|
7045
7045
|
|
|
7046
|
-
const code$
|
|
7047
|
-
async function handler$
|
|
7046
|
+
const code$c = "getMyProfile";
|
|
7047
|
+
async function handler$c(plugin, ctx, options) {
|
|
7048
7048
|
const { server, input, routerContext } = ctx;
|
|
7049
7049
|
const userId = routerContext.state.userId;
|
|
7050
7050
|
if (!userId) {
|
|
@@ -7076,12 +7076,12 @@ async function handler$b(plugin, ctx, options) {
|
|
|
7076
7076
|
|
|
7077
7077
|
var getMyProfile$2 = /*#__PURE__*/Object.freeze({
|
|
7078
7078
|
__proto__: null,
|
|
7079
|
-
code: code$
|
|
7080
|
-
handler: handler$
|
|
7079
|
+
code: code$c,
|
|
7080
|
+
handler: handler$c
|
|
7081
7081
|
});
|
|
7082
7082
|
|
|
7083
|
-
const code$
|
|
7084
|
-
async function handler$
|
|
7083
|
+
const code$b = "resetPassword";
|
|
7084
|
+
async function handler$b(plugin, ctx, options) {
|
|
7085
7085
|
const { server, input, routerContext: routeContext } = ctx;
|
|
7086
7086
|
const { userId, password } = input;
|
|
7087
7087
|
const userEntitySingularCode = plugin.options?.userEntitySingularCode || "oc_user";
|
|
@@ -7109,8 +7109,8 @@ async function handler$a(plugin, ctx, options) {
|
|
|
7109
7109
|
|
|
7110
7110
|
var resetPassword$1 = /*#__PURE__*/Object.freeze({
|
|
7111
7111
|
__proto__: null,
|
|
7112
|
-
code: code$
|
|
7113
|
-
handler: handler$
|
|
7112
|
+
code: code$b,
|
|
7113
|
+
handler: handler$b
|
|
7114
7114
|
});
|
|
7115
7115
|
|
|
7116
7116
|
var pluginActionHandlers$7 = [changePassword$1, createSession, deleteSession, getMyProfile$2, resetPassword$1];
|
|
@@ -7325,7 +7325,7 @@ class AuthPlugin {
|
|
|
7325
7325
|
try {
|
|
7326
7326
|
const secretKey = Buffer.from(server.config.jwtKey, "base64");
|
|
7327
7327
|
const tokenPayload = verifyJwt(token, secretKey);
|
|
7328
|
-
routeContext.state.userId = tokenPayload.aud;
|
|
7328
|
+
routeContext.state.userId = Number(tokenPayload.aud);
|
|
7329
7329
|
routeContext.state.userLogin = tokenPayload.act;
|
|
7330
7330
|
}
|
|
7331
7331
|
catch (error) {
|
|
@@ -7365,8 +7365,8 @@ function getFileBaseName(pathname) {
|
|
|
7365
7365
|
return path__default["default"].basename(pathname, extName);
|
|
7366
7366
|
}
|
|
7367
7367
|
|
|
7368
|
-
const code$
|
|
7369
|
-
async function handler$
|
|
7368
|
+
const code$a = "downloadDocument";
|
|
7369
|
+
async function handler$a(plugin, ctx, options) {
|
|
7370
7370
|
const { server, applicationConfig, routerContext: routeContext, input } = ctx;
|
|
7371
7371
|
const { request, response } = routeContext;
|
|
7372
7372
|
const documentDataAccessor = ctx.server.getDataAccessor({
|
|
@@ -7422,12 +7422,12 @@ async function handler$9(plugin, ctx, options) {
|
|
|
7422
7422
|
|
|
7423
7423
|
var downloadDocumentActionHandler = /*#__PURE__*/Object.freeze({
|
|
7424
7424
|
__proto__: null,
|
|
7425
|
-
code: code$
|
|
7426
|
-
handler: handler$
|
|
7425
|
+
code: code$a,
|
|
7426
|
+
handler: handler$a
|
|
7427
7427
|
});
|
|
7428
7428
|
|
|
7429
|
-
const code$
|
|
7430
|
-
async function handler$
|
|
7429
|
+
const code$9 = "downloadFile";
|
|
7430
|
+
async function handler$9(plugin, ctx, options) {
|
|
7431
7431
|
const { server, applicationConfig, routerContext: routeContext } = ctx;
|
|
7432
7432
|
const { request, response } = routeContext;
|
|
7433
7433
|
//TODO: only public files can download by this handler
|
|
@@ -7453,12 +7453,12 @@ async function handler$8(plugin, ctx, options) {
|
|
|
7453
7453
|
|
|
7454
7454
|
var downloadFileActionHandler = /*#__PURE__*/Object.freeze({
|
|
7455
7455
|
__proto__: null,
|
|
7456
|
-
code: code$
|
|
7457
|
-
handler: handler$
|
|
7456
|
+
code: code$9,
|
|
7457
|
+
handler: handler$9
|
|
7458
7458
|
});
|
|
7459
7459
|
|
|
7460
|
-
const code$
|
|
7461
|
-
async function handler$
|
|
7460
|
+
const code$8 = "uploadFile";
|
|
7461
|
+
async function handler$8(plugin, ctx, options) {
|
|
7462
7462
|
const { server, applicationConfig, routerContext, input } = ctx;
|
|
7463
7463
|
let file = input.file || input.files;
|
|
7464
7464
|
if (lodash.isArray(file)) {
|
|
@@ -7479,8 +7479,8 @@ async function handler$7(plugin, ctx, options) {
|
|
|
7479
7479
|
|
|
7480
7480
|
var uploadFileActionHandler = /*#__PURE__*/Object.freeze({
|
|
7481
7481
|
__proto__: null,
|
|
7482
|
-
code: code$
|
|
7483
|
-
handler: handler$
|
|
7482
|
+
code: code$8,
|
|
7483
|
+
handler: handler$8
|
|
7484
7484
|
});
|
|
7485
7485
|
|
|
7486
7486
|
var getMyProfile = {
|
|
@@ -7556,8 +7556,8 @@ class FileManager {
|
|
|
7556
7556
|
}
|
|
7557
7557
|
}
|
|
7558
7558
|
|
|
7559
|
-
const code$
|
|
7560
|
-
async function handler$
|
|
7559
|
+
const code$7 = "getLicense";
|
|
7560
|
+
async function handler$7(plugin, ctx, options) {
|
|
7561
7561
|
const { server, routerContext } = ctx;
|
|
7562
7562
|
const licenseService = server.getService("licenseService");
|
|
7563
7563
|
const license = licenseService.getLicense();
|
|
@@ -7565,12 +7565,27 @@ async function handler$6(plugin, ctx, options) {
|
|
|
7565
7565
|
}
|
|
7566
7566
|
|
|
7567
7567
|
var getLicense$1 = /*#__PURE__*/Object.freeze({
|
|
7568
|
+
__proto__: null,
|
|
7569
|
+
code: code$7,
|
|
7570
|
+
handler: handler$7
|
|
7571
|
+
});
|
|
7572
|
+
|
|
7573
|
+
const code$6 = "updateLicense";
|
|
7574
|
+
async function handler$6(plugin, ctx, options) {
|
|
7575
|
+
const { server, routerContext } = ctx;
|
|
7576
|
+
const input = ctx.input;
|
|
7577
|
+
const licenseService = server.getService("licenseService");
|
|
7578
|
+
const license = await licenseService.updateLicense(input.certText);
|
|
7579
|
+
ctx.output = license;
|
|
7580
|
+
}
|
|
7581
|
+
|
|
7582
|
+
var updateLicense$1 = /*#__PURE__*/Object.freeze({
|
|
7568
7583
|
__proto__: null,
|
|
7569
7584
|
code: code$6,
|
|
7570
7585
|
handler: handler$6
|
|
7571
7586
|
});
|
|
7572
7587
|
|
|
7573
|
-
var pluginActionHandlers$6 = [getLicense$1];
|
|
7588
|
+
var pluginActionHandlers$6 = [getLicense$1, updateLicense$1];
|
|
7574
7589
|
|
|
7575
7590
|
var pluginModels$5 = [];
|
|
7576
7591
|
|
|
@@ -7588,7 +7603,21 @@ var getLicense = {
|
|
|
7588
7603
|
],
|
|
7589
7604
|
};
|
|
7590
7605
|
|
|
7591
|
-
var
|
|
7606
|
+
var updateLicense = {
|
|
7607
|
+
namespace: "svc",
|
|
7608
|
+
name: "svc.updateLicense",
|
|
7609
|
+
code: "svc.updateLicense",
|
|
7610
|
+
type: "RESTful",
|
|
7611
|
+
method: "POST",
|
|
7612
|
+
endpoint: "/svc/license",
|
|
7613
|
+
actions: [
|
|
7614
|
+
{
|
|
7615
|
+
code: "updateLicense",
|
|
7616
|
+
},
|
|
7617
|
+
],
|
|
7618
|
+
};
|
|
7619
|
+
|
|
7620
|
+
var pluginRoutes$5 = [getLicense, updateLicense];
|
|
7592
7621
|
|
|
7593
7622
|
function getEncryptionIV(input) {
|
|
7594
7623
|
const hash = crypto__default["default"].createHash("sha512").update(input).digest("hex");
|
|
@@ -7644,16 +7673,13 @@ class LicenseService {
|
|
|
7644
7673
|
async loadLicense() {
|
|
7645
7674
|
const settingService = this.#server.getService("settingService");
|
|
7646
7675
|
const licenseSettings = await settingService.getSystemSettingValues("license");
|
|
7647
|
-
const { deployId } = licenseSettings;
|
|
7648
|
-
const certText = licenseSettings.cert;
|
|
7676
|
+
const { deployId, cert: certText } = licenseSettings;
|
|
7649
7677
|
if (!deployId || !certText) {
|
|
7650
7678
|
this.#server.getLogger().warn("License was not loaded properly.");
|
|
7651
7679
|
return;
|
|
7652
7680
|
}
|
|
7653
|
-
const certJSON = Buffer.from(certText, "base64").toString();
|
|
7654
|
-
const cert = JSON.parse(certJSON);
|
|
7655
7681
|
try {
|
|
7656
|
-
const license =
|
|
7682
|
+
const license = this.parseLicense(deployId, certText);
|
|
7657
7683
|
this.#license = license;
|
|
7658
7684
|
}
|
|
7659
7685
|
catch (error) {
|
|
@@ -7664,6 +7690,26 @@ class LicenseService {
|
|
|
7664
7690
|
getLicense() {
|
|
7665
7691
|
return this.#license;
|
|
7666
7692
|
}
|
|
7693
|
+
parseLicense(deployId, certText) {
|
|
7694
|
+
const certJSON = Buffer.from(certText, "base64").toString();
|
|
7695
|
+
const cert = JSON.parse(certJSON);
|
|
7696
|
+
return extractCertLicense(this.#encryptionKey, deployId, cert);
|
|
7697
|
+
}
|
|
7698
|
+
async updateLicense(certText) {
|
|
7699
|
+
const settingService = this.#server.getService("settingService");
|
|
7700
|
+
const deployId = await settingService.getSystemSettingValue("license", "deployId");
|
|
7701
|
+
let license;
|
|
7702
|
+
try {
|
|
7703
|
+
license = this.parseLicense(deployId, certText);
|
|
7704
|
+
}
|
|
7705
|
+
catch (error) {
|
|
7706
|
+
this.#server.getLogger().error("Parse license failed.", error);
|
|
7707
|
+
throw new Error("Parse license failed.");
|
|
7708
|
+
}
|
|
7709
|
+
await settingService.setSystemSettingValue("license", "cert", certText);
|
|
7710
|
+
this.#license = license;
|
|
7711
|
+
return license;
|
|
7712
|
+
}
|
|
7667
7713
|
isExpired() {
|
|
7668
7714
|
if (!this.#license) {
|
|
7669
7715
|
return true;
|
|
@@ -15,6 +15,8 @@ export default class LicenseService {
|
|
|
15
15
|
constructor(server: IRpdServer, encryptionKey: string);
|
|
16
16
|
loadLicense(): Promise<void>;
|
|
17
17
|
getLicense(): RpdLicense;
|
|
18
|
+
parseLicense(deployId: string, certText: string): RpdLicense;
|
|
19
|
+
updateLicense(certText: string): Promise<RpdLicense>;
|
|
18
20
|
isExpired(): boolean;
|
|
19
21
|
getQuota(name: string): any;
|
|
20
22
|
isOutOfQuota(name: string, currentAmount: number): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionHandlerContext } from "../../../core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "../../../core/server";
|
|
3
|
+
export interface UpdateLicenseOptions {
|
|
4
|
+
}
|
|
5
|
+
export interface UpdateLicenseInput {
|
|
6
|
+
certText: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const code = "updateLicense";
|
|
9
|
+
export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: UpdateLicenseOptions): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const _default: {
|
|
1
|
+
declare const _default: ({
|
|
2
2
|
namespace: string;
|
|
3
3
|
name: string;
|
|
4
4
|
code: string;
|
|
@@ -8,5 +8,15 @@ declare const _default: {
|
|
|
8
8
|
actions: {
|
|
9
9
|
code: string;
|
|
10
10
|
}[];
|
|
11
|
-
}
|
|
11
|
+
} | {
|
|
12
|
+
namespace: string;
|
|
13
|
+
name: string;
|
|
14
|
+
code: string;
|
|
15
|
+
type: "RESTful";
|
|
16
|
+
method: "POST";
|
|
17
|
+
endpoint: string;
|
|
18
|
+
actions: {
|
|
19
|
+
code: string;
|
|
20
|
+
}[];
|
|
21
|
+
})[];
|
|
12
22
|
export default _default;
|
package/package.json
CHANGED
|
@@ -91,7 +91,7 @@ class AuthPlugin implements RapidPlugin {
|
|
|
91
91
|
try {
|
|
92
92
|
const secretKey = Buffer.from(server.config.jwtKey, "base64");
|
|
93
93
|
const tokenPayload = verifyJwt(token, secretKey);
|
|
94
|
-
routeContext.state.userId = tokenPayload.aud as string;
|
|
94
|
+
routeContext.state.userId = Number(tokenPayload.aud as string);
|
|
95
95
|
routeContext.state.userLogin = tokenPayload.act as string;
|
|
96
96
|
} catch (error) {
|
|
97
97
|
const logger = server.getLogger();
|
|
@@ -37,19 +37,15 @@ export default class LicenseService {
|
|
|
37
37
|
async loadLicense(): Promise<void> {
|
|
38
38
|
const settingService = this.#server.getService<SettingService>("settingService");
|
|
39
39
|
const licenseSettings = await settingService.getSystemSettingValues("license");
|
|
40
|
-
const { deployId } = licenseSettings as LicenseSettings;
|
|
41
|
-
const certText = licenseSettings.cert;
|
|
40
|
+
const { deployId, cert: certText } = licenseSettings as LicenseSettings;
|
|
42
41
|
|
|
43
42
|
if (!deployId || !certText) {
|
|
44
43
|
this.#server.getLogger().warn("License was not loaded properly.");
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
const certJSON = Buffer.from(certText, "base64").toString();
|
|
49
|
-
const cert: RpdCert = JSON.parse(certJSON);
|
|
50
|
-
|
|
51
47
|
try {
|
|
52
|
-
const license =
|
|
48
|
+
const license = this.parseLicense(deployId, certText);
|
|
53
49
|
this.#license = license;
|
|
54
50
|
} catch (error) {
|
|
55
51
|
this.#server.getLogger().error("Loading license failed.", error);
|
|
@@ -61,6 +57,29 @@ export default class LicenseService {
|
|
|
61
57
|
return this.#license;
|
|
62
58
|
}
|
|
63
59
|
|
|
60
|
+
parseLicense(deployId: string, certText: string): RpdLicense {
|
|
61
|
+
const certJSON = Buffer.from(certText, "base64").toString();
|
|
62
|
+
const cert: RpdCert = JSON.parse(certJSON);
|
|
63
|
+
return extractCertLicense(this.#encryptionKey, deployId, cert);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async updateLicense(certText: string) {
|
|
67
|
+
const settingService = this.#server.getService<SettingService>("settingService");
|
|
68
|
+
const deployId: string = await settingService.getSystemSettingValue("license", "deployId");
|
|
69
|
+
|
|
70
|
+
let license: RpdLicense;
|
|
71
|
+
try {
|
|
72
|
+
license = this.parseLicense(deployId, certText);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
this.#server.getLogger().error("Parse license failed.", error);
|
|
75
|
+
throw new Error("Parse license failed.");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
await settingService.setSystemSettingValue("license", "cert", certText);
|
|
79
|
+
this.#license = license;
|
|
80
|
+
return license;
|
|
81
|
+
}
|
|
82
|
+
|
|
64
83
|
isExpired() {
|
|
65
84
|
if (!this.#license) {
|
|
66
85
|
return true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IPluginActionHandler } from "~/core/actionHandler";
|
|
2
2
|
import * as getLicense from "./getLicense";
|
|
3
|
+
import * as updateLicense from "./updateLicense";
|
|
3
4
|
|
|
4
|
-
export default [getLicense] satisfies IPluginActionHandler[];
|
|
5
|
+
export default [getLicense, updateLicense] satisfies IPluginActionHandler[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
2
|
+
import { RapidPlugin } from "~/core/server";
|
|
3
|
+
import LicenseService from "../LicenseService";
|
|
4
|
+
|
|
5
|
+
export interface UpdateLicenseOptions {}
|
|
6
|
+
|
|
7
|
+
export interface UpdateLicenseInput {
|
|
8
|
+
certText: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const code = "updateLicense";
|
|
12
|
+
|
|
13
|
+
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: UpdateLicenseOptions) {
|
|
14
|
+
const { server, routerContext } = ctx;
|
|
15
|
+
const { response } = routerContext;
|
|
16
|
+
|
|
17
|
+
const input: UpdateLicenseInput = ctx.input;
|
|
18
|
+
|
|
19
|
+
const licenseService = server.getService<LicenseService>("licenseService");
|
|
20
|
+
|
|
21
|
+
const license = await licenseService.updateLicense(input.certText);
|
|
22
|
+
|
|
23
|
+
ctx.output = license;
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RpdRoute } from "~/types";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespace: "svc",
|
|
5
|
+
name: "svc.updateLicense",
|
|
6
|
+
code: "svc.updateLicense",
|
|
7
|
+
type: "RESTful",
|
|
8
|
+
method: "POST",
|
|
9
|
+
endpoint: "/svc/license",
|
|
10
|
+
actions: [
|
|
11
|
+
{
|
|
12
|
+
code: "updateLicense",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
} satisfies RpdRoute;
|
|
@@ -21,6 +21,6 @@ export async function generatePasswordHash(password: string, salt?: number | str
|
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
23
|
export async function validatePassword(password: string, passwordHash: string): Promise<boolean> {
|
|
24
|
-
const isMatch = await bcrypt.compare(password, passwordHash);
|
|
24
|
+
const isMatch = await bcrypt.compare(password || "", passwordHash || "");
|
|
25
25
|
return isMatch;
|
|
26
26
|
}
|