@abtnode/core 1.16.52-beta-20250909-073849-4e392ab1 → 1.16.52-beta-20250911-023851-d988be85
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/states/audit-log.js +111 -1
- package/package.json +24 -24
package/lib/states/audit-log.js
CHANGED
|
@@ -5,6 +5,11 @@ const get = require('lodash/get');
|
|
|
5
5
|
const uniq = require('lodash/uniq');
|
|
6
6
|
const isEqual = require('lodash/isEqual');
|
|
7
7
|
const isNil = require('lodash/isNil');
|
|
8
|
+
const isObject = require('lodash/isObject');
|
|
9
|
+
const isArray = require('lodash/isArray');
|
|
10
|
+
const isString = require('lodash/isString');
|
|
11
|
+
const mapValues = require('lodash/mapValues');
|
|
12
|
+
const map = require('lodash/map');
|
|
8
13
|
const { joinURL } = require('ufo');
|
|
9
14
|
const { Op } = require('sequelize');
|
|
10
15
|
const { getDisplayName } = require('@blocklet/meta/lib/util');
|
|
@@ -197,6 +202,36 @@ const getResponseHeaderPolicyInfo = (policy) => {
|
|
|
197
202
|
.join(', ');
|
|
198
203
|
};
|
|
199
204
|
|
|
205
|
+
/**
|
|
206
|
+
* 隐藏私密信息,主要字段有
|
|
207
|
+
* 1. email
|
|
208
|
+
*/
|
|
209
|
+
const hidePrivateInfo = (result) => {
|
|
210
|
+
const emailRegex =
|
|
211
|
+
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
212
|
+
|
|
213
|
+
const processValue = (value, key) => {
|
|
214
|
+
// 如果字段名包含 email 或值是邮箱格式,则隐藏
|
|
215
|
+
if ((key && /email/i.test(key)) || (isString(value) && emailRegex.test(value))) {
|
|
216
|
+
return '***';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 递归处理对象
|
|
220
|
+
if (isObject(value) && !isArray(value)) {
|
|
221
|
+
return mapValues(value, processValue);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// 递归处理数组
|
|
225
|
+
if (isArray(value)) {
|
|
226
|
+
return map(value, (item) => processValue(item));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return value;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return processValue(result);
|
|
233
|
+
};
|
|
234
|
+
|
|
200
235
|
/**
|
|
201
236
|
* Create log content in markdown format
|
|
202
237
|
*
|
|
@@ -211,7 +246,13 @@ const getResponseHeaderPolicyInfo = (policy) => {
|
|
|
211
246
|
const getLogContent = async (action, args, context, result, info, node) => {
|
|
212
247
|
const [site, [user, passport]] = await Promise.all([
|
|
213
248
|
expandSite(args.id, info, node),
|
|
214
|
-
expandUser(
|
|
249
|
+
expandUser(
|
|
250
|
+
args.teamDid,
|
|
251
|
+
args.userDid || get(args, 'user.did') || args.ownerDid || args.did,
|
|
252
|
+
args.passportId,
|
|
253
|
+
info,
|
|
254
|
+
node
|
|
255
|
+
),
|
|
215
256
|
]);
|
|
216
257
|
|
|
217
258
|
switch (action) {
|
|
@@ -369,6 +410,55 @@ const getLogContent = async (action, args, context, result, info, node) => {
|
|
|
369
410
|
return `${args.user.approved ? 'enabled' : 'disabled'} user ${user}`;
|
|
370
411
|
case 'updateUserTags':
|
|
371
412
|
return `set tags to ${args.tags} for user ${user}`;
|
|
413
|
+
case 'updateUserExtra':
|
|
414
|
+
let type = args.type || '';
|
|
415
|
+
const extraResult = result.extra || result;
|
|
416
|
+
let resultStr = '\n';
|
|
417
|
+
let isFormat = false;
|
|
418
|
+
if (type === 'privacy' || Object.prototype.hasOwnProperty.call(extraResult, 'privacy')) {
|
|
419
|
+
resultStr += Object.keys(extraResult.privacy)
|
|
420
|
+
.map((x) => {
|
|
421
|
+
const value = extraResult.privacy[x];
|
|
422
|
+
let v = value;
|
|
423
|
+
if (value === true || value === 'all') {
|
|
424
|
+
v = 'public';
|
|
425
|
+
} else if (value === false || value === 'private') {
|
|
426
|
+
v = 'private';
|
|
427
|
+
} else if (value === 'follower-only') {
|
|
428
|
+
v = 'follower-only';
|
|
429
|
+
} else {
|
|
430
|
+
v = value;
|
|
431
|
+
}
|
|
432
|
+
return `- ${x}: ${v}`;
|
|
433
|
+
})
|
|
434
|
+
.join('\n');
|
|
435
|
+
isFormat = true;
|
|
436
|
+
type = 'privacy';
|
|
437
|
+
}
|
|
438
|
+
if (type === 'notifications' || Object.prototype.hasOwnProperty.call(extraResult, 'notifications')) {
|
|
439
|
+
resultStr += Object.keys(extraResult?.notifications || {})
|
|
440
|
+
.map((x) => `- ${x}: ${extraResult.notifications[x]}`)
|
|
441
|
+
.join('\n');
|
|
442
|
+
isFormat = true;
|
|
443
|
+
type = 'notifications';
|
|
444
|
+
}
|
|
445
|
+
if (type === 'webhooks' || Object.prototype.hasOwnProperty.call(extraResult, 'webhooks')) {
|
|
446
|
+
resultStr += (extraResult?.webhooks || []).length
|
|
447
|
+
? extraResult.webhooks.map((x) => `- ${x.type}: ${x.url}`).join('\n')
|
|
448
|
+
: 'removed all webhooks';
|
|
449
|
+
isFormat = true;
|
|
450
|
+
type = 'webhooks';
|
|
451
|
+
}
|
|
452
|
+
if (!isFormat) {
|
|
453
|
+
resultStr = JSON.stringify(hidePrivateInfo(extraResult));
|
|
454
|
+
type = 'extra';
|
|
455
|
+
}
|
|
456
|
+
return `updated user ${type} for user ${user}: \n${resultStr}`;
|
|
457
|
+
case 'updateUserAddress':
|
|
458
|
+
const addressResult = Object.prototype.hasOwnProperty.call(result, 'address') ? result.address : result;
|
|
459
|
+
return `updated user address for user ${user}: \n${JSON.stringify(hidePrivateInfo(addressResult))}`;
|
|
460
|
+
case 'updateUserInfo':
|
|
461
|
+
return `update user info for user ${user}: \n\n${JSON.stringify(hidePrivateInfo(result))}`;
|
|
372
462
|
case 'deletePassportIssuance':
|
|
373
463
|
return `removed passport issuance ${args.sessionId}`;
|
|
374
464
|
case 'createMemberInvitation':
|
|
@@ -551,6 +641,19 @@ const getLogContent = async (action, args, context, result, info, node) => {
|
|
|
551
641
|
return `Update Blocklet Extras Settings:(${args.did} to ${changes.join(', ')})`;
|
|
552
642
|
}
|
|
553
643
|
|
|
644
|
+
// user follow
|
|
645
|
+
case 'followUser':
|
|
646
|
+
case 'unfollowUser':
|
|
647
|
+
const followerUser = await node.getUser({ teamDid: args.teamDid, user: { did: args.followerDid } });
|
|
648
|
+
const prefix = process.env.NODE_ENV === 'production' ? info.routing.adminPath : '';
|
|
649
|
+
return `[${followerUser.fullName}](${joinURL(prefix, '/team/members')}) ${action === 'followUser' ? 'followed' : 'unfollowed'} user ${user}`;
|
|
650
|
+
|
|
651
|
+
// connect to aigne
|
|
652
|
+
case 'connectToAigne':
|
|
653
|
+
return `Connect to Aigne(${args.baseUrl})`;
|
|
654
|
+
case 'disconnectToAigne':
|
|
655
|
+
return `Disconnect to Aigne(${args.url})`;
|
|
656
|
+
|
|
554
657
|
default:
|
|
555
658
|
return action;
|
|
556
659
|
}
|
|
@@ -599,6 +702,8 @@ const getLogCategory = (action) => {
|
|
|
599
702
|
case 'createOAuthClient':
|
|
600
703
|
case 'updateOAuthClient':
|
|
601
704
|
case 'updateBlockletSettings':
|
|
705
|
+
case 'connectToAigne':
|
|
706
|
+
case 'disconnectToAigne':
|
|
602
707
|
return 'blocklet';
|
|
603
708
|
|
|
604
709
|
case 'addUploadEndpoint':
|
|
@@ -648,6 +753,11 @@ const getLogCategory = (action) => {
|
|
|
648
753
|
case 'loginFederatedMaster':
|
|
649
754
|
case 'migrateFederatedAccount':
|
|
650
755
|
case 'destroySelf':
|
|
756
|
+
case 'updateUserExtra':
|
|
757
|
+
case 'updateUserAddress':
|
|
758
|
+
case 'updateUserInfo':
|
|
759
|
+
case 'followUser':
|
|
760
|
+
case 'unfollowUser':
|
|
651
761
|
return 'team';
|
|
652
762
|
|
|
653
763
|
// accessKeys
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.52-beta-
|
|
6
|
+
"version": "1.16.52-beta-20250911-023851-d988be85",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.52-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.52-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.52-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.52-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.52-beta-
|
|
27
|
-
"@abtnode/db-cache": "1.16.52-beta-
|
|
28
|
-
"@abtnode/docker-utils": "1.16.52-beta-
|
|
29
|
-
"@abtnode/logger": "1.16.52-beta-
|
|
30
|
-
"@abtnode/models": "1.16.52-beta-
|
|
31
|
-
"@abtnode/queue": "1.16.52-beta-
|
|
32
|
-
"@abtnode/rbac": "1.16.52-beta-
|
|
33
|
-
"@abtnode/router-provider": "1.16.52-beta-
|
|
34
|
-
"@abtnode/static-server": "1.16.52-beta-
|
|
35
|
-
"@abtnode/timemachine": "1.16.52-beta-
|
|
36
|
-
"@abtnode/util": "1.16.52-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.52-beta-20250911-023851-d988be85",
|
|
23
|
+
"@abtnode/auth": "1.16.52-beta-20250911-023851-d988be85",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.52-beta-20250911-023851-d988be85",
|
|
25
|
+
"@abtnode/constant": "1.16.52-beta-20250911-023851-d988be85",
|
|
26
|
+
"@abtnode/cron": "1.16.52-beta-20250911-023851-d988be85",
|
|
27
|
+
"@abtnode/db-cache": "1.16.52-beta-20250911-023851-d988be85",
|
|
28
|
+
"@abtnode/docker-utils": "1.16.52-beta-20250911-023851-d988be85",
|
|
29
|
+
"@abtnode/logger": "1.16.52-beta-20250911-023851-d988be85",
|
|
30
|
+
"@abtnode/models": "1.16.52-beta-20250911-023851-d988be85",
|
|
31
|
+
"@abtnode/queue": "1.16.52-beta-20250911-023851-d988be85",
|
|
32
|
+
"@abtnode/rbac": "1.16.52-beta-20250911-023851-d988be85",
|
|
33
|
+
"@abtnode/router-provider": "1.16.52-beta-20250911-023851-d988be85",
|
|
34
|
+
"@abtnode/static-server": "1.16.52-beta-20250911-023851-d988be85",
|
|
35
|
+
"@abtnode/timemachine": "1.16.52-beta-20250911-023851-d988be85",
|
|
36
|
+
"@abtnode/util": "1.16.52-beta-20250911-023851-d988be85",
|
|
37
37
|
"@aigne/aigne-hub": "^0.8.10",
|
|
38
38
|
"@arcblock/did": "1.24.0",
|
|
39
39
|
"@arcblock/did-connect-js": "1.24.0",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"@arcblock/pm2-events": "^0.0.5",
|
|
46
46
|
"@arcblock/validator": "1.24.0",
|
|
47
47
|
"@arcblock/vc": "1.24.0",
|
|
48
|
-
"@blocklet/constant": "1.16.52-beta-
|
|
48
|
+
"@blocklet/constant": "1.16.52-beta-20250911-023851-d988be85",
|
|
49
49
|
"@blocklet/did-space-js": "^1.1.23",
|
|
50
|
-
"@blocklet/env": "1.16.52-beta-
|
|
50
|
+
"@blocklet/env": "1.16.52-beta-20250911-023851-d988be85",
|
|
51
51
|
"@blocklet/error": "^0.2.5",
|
|
52
|
-
"@blocklet/meta": "1.16.52-beta-
|
|
53
|
-
"@blocklet/resolver": "1.16.52-beta-
|
|
54
|
-
"@blocklet/sdk": "1.16.52-beta-
|
|
55
|
-
"@blocklet/server-js": "1.16.52-beta-
|
|
56
|
-
"@blocklet/store": "1.16.52-beta-
|
|
52
|
+
"@blocklet/meta": "1.16.52-beta-20250911-023851-d988be85",
|
|
53
|
+
"@blocklet/resolver": "1.16.52-beta-20250911-023851-d988be85",
|
|
54
|
+
"@blocklet/sdk": "1.16.52-beta-20250911-023851-d988be85",
|
|
55
|
+
"@blocklet/server-js": "1.16.52-beta-20250911-023851-d988be85",
|
|
56
|
+
"@blocklet/store": "1.16.52-beta-20250911-023851-d988be85",
|
|
57
57
|
"@blocklet/theme": "^3.1.37",
|
|
58
58
|
"@fidm/x509": "^1.2.1",
|
|
59
59
|
"@ocap/mcrypto": "1.24.0",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"jest": "^29.7.0",
|
|
119
119
|
"unzipper": "^0.10.11"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "90c5cf74138797733868312beb5e509c9db3a8f8"
|
|
122
122
|
}
|