@abtnode/blocklet-services 1.17.2-beta-20251111-010532-4bb3b162 → 1.17.2-beta-20251111-114226-13276e42

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.
@@ -75,7 +75,7 @@ const validateLocalPassport = async ({ vc, node, locale, blocklet, teamDid, user
75
75
  const appIdList = getBlockletAppIdList(blocklet);
76
76
  if (appIdList.includes(vc?.issuer.id)) {
77
77
  if (vc.credentialSubject.id !== userDid) {
78
- throw new CustomError(403, messages.actionForbidden[locale]);
78
+ throw new CustomError(403, messages.passportNotBelongToYou[locale]);
79
79
  }
80
80
 
81
81
  const passport = await node.getPassportById({ teamDid, passportId: vc.id });
@@ -136,12 +136,7 @@ const validateRole = async ({ role, securityConfig, locale, node, teamDid }) =>
136
136
  const roleList = await node.getRoles({ teamDid });
137
137
  if (!roleList.some((x) => x.name === role)) {
138
138
  // 事实上,这里表示的是通行证已经被删除了,也就是这个 role 不存在了
139
- throw new Error(
140
- {
141
- zh: '通行证已被应用撤销',
142
- en: 'Passport has been revoked by the app',
143
- }[locale]
144
- );
139
+ throw new Error(messages.passportHasBeenRevokedByTheApp[locale]);
145
140
  }
146
141
 
147
142
  if (accessRoles === null && accessReverse === false) {
@@ -836,8 +831,8 @@ module.exports = {
836
831
  }
837
832
 
838
833
  const serviceConfig = await request.getServiceConfig(NODE_SERVICES.AUTH);
839
- if (get(serviceConfig, 'allowSwitchProfile', true) === false) {
840
- throw new Error(messages.actionForbidden[locale]);
834
+ if (get(serviceConfig, 'allowSwitchProfile', false) === false) {
835
+ throw new Error(messages.notAllowedToSwitchProfile[locale]);
841
836
  }
842
837
 
843
838
  const blocklet = await request.getBlocklet();
@@ -855,7 +850,7 @@ module.exports = {
855
850
  throw new Error(messages.userNotFound[locale]);
856
851
  }
857
852
  if (!user.approved) {
858
- throw new Error(messages.notAuthorized[locale]);
853
+ throw new Error(messages.notAllowedAppUser[locale]);
859
854
  }
860
855
 
861
856
  const profileItems = getProfileItems(blocklet.settings?.session, request.context.didwallet);
@@ -892,7 +887,7 @@ module.exports = {
892
887
  throw new Error(messages.userNotFound[locale]);
893
888
  }
894
889
  if (!user.approved) {
895
- throw new Error(messages.notAuthorized[locale]);
890
+ throw new Error(messages.notAllowedAppUser[locale]);
896
891
  }
897
892
 
898
893
  // 兼容新版本和老版本的 DID Wallet之间来回切换 Profile
@@ -968,7 +963,7 @@ module.exports = {
968
963
  throw new Error(messages.userNotFound[locale]);
969
964
  }
970
965
  if (!user.approved) {
971
- throw new Error(messages.notAuthorized[locale]);
966
+ throw new Error(messages.notAllowedAppUser[locale]);
972
967
  }
973
968
 
974
969
  const { accessPolicyConfig } = await request.getSecurityConfig({ id: SECURITY_RULE_DEFAULT_ID });
@@ -1036,7 +1031,7 @@ module.exports = {
1036
1031
  throw new Error(messages.userNotFound[locale]);
1037
1032
  }
1038
1033
  if (!user.approved) {
1039
- throw new Error(messages.notAuthorized[locale]);
1034
+ throw new Error(messages.notAllowedAppUser[locale]);
1040
1035
  }
1041
1036
 
1042
1037
  // Get auth config
@@ -1188,12 +1183,7 @@ module.exports = {
1188
1183
 
1189
1184
  const role = await getRoleFromVC({ vc, appId, node, locale, blocklet, teamDid });
1190
1185
  if (role !== ROLES.OWNER) {
1191
- throw new Error(
1192
- {
1193
- zh: '只有应用所有者才能执行此操作',
1194
- en: 'Only the application owner can perform this action',
1195
- }[locale]
1196
- );
1186
+ throw new Error(messages.onlyOwnerCanPerformThisAction[locale]);
1197
1187
  }
1198
1188
 
1199
1189
  const keyPair = claims.find((x) => x.type === 'keyPair');
@@ -92,7 +92,7 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
92
92
  await updateSession(updates, true);
93
93
  } catch (err) {
94
94
  logger.error('Failed to destroy user', { teamDid, userDid, error: err.message });
95
- throw new Error(messages.failedToDestroyUser()[locale]);
95
+ throw new Error(messages.failedToDestroyUser[locale]);
96
96
  }
97
97
  },
98
98
  };
@@ -13,7 +13,7 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
13
13
  const { locale = 'en' } = extraParams;
14
14
  const blocklet = await request.getBlocklet();
15
15
  if (blocklet.trustedFactories.length === 0) {
16
- throw new Error(messages.notAllowed[locale]);
16
+ throw new Error(messages.noTrustedFactories[locale]);
17
17
  }
18
18
  },
19
19
 
@@ -1,7 +1,7 @@
1
1
  const { getSourceAppPid } = require('@blocklet/sdk/lib/util/login');
2
2
  const { messages } = require('@abtnode/auth/lib/auth');
3
3
  const { authenticateByVc } = require('@abtnode/auth/lib/server');
4
- const { PASSPORT_LOG_ACTION, SERVER_ROLES } = require('@abtnode/constant');
4
+ const { PASSPORT_LOG_ACTION, SERVER_ROLES, ROLES } = require('@abtnode/constant');
5
5
  const formatContext = require('@abtnode/util/lib/format-context');
6
6
  const { PASSPORT_VC_TYPES } = require('@abtnode/auth/lib/util/transfer-passport');
7
7
 
@@ -9,7 +9,7 @@ const logger = require('../../../libs/logger')('blocklet-service:connect-cli');
9
9
  const { utils } = require('../../../libs/connect/session');
10
10
  const { getTrustedIssuers } = require('../../../util/blocklet-utils');
11
11
 
12
- const allowedRoles = ['owner', 'admin'];
12
+ const allowedRoles = [ROLES.OWNER, ROLES.ADMIN];
13
13
 
14
14
  module.exports = function createRoutes(node) {
15
15
  return {
@@ -39,7 +39,7 @@ module.exports = function createRoutes(node) {
39
39
  });
40
40
 
41
41
  if (!allowedRoles.includes(role)) {
42
- throw new Error(messages.notAllowed[locale]);
42
+ throw new Error(messages.passportNotAllowedToUse({ passports: allowedRoles.join('/') })[locale]);
43
43
  }
44
44
 
45
45
  if (passport) {
@@ -39,10 +39,10 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
39
39
  options: { enableConnectedAccount: true },
40
40
  });
41
41
  if (!user) {
42
- throw new Error(messages.notAllowed[locale]);
42
+ throw new Error(messages.userNotExist({ did: userDid })[locale]);
43
43
  }
44
44
  if (!user.approved) {
45
- throw new Error(messages.notAuthorized[locale]);
45
+ throw new Error(messages.notAllowedAppUser[locale]);
46
46
  }
47
47
 
48
48
  const allowedRoles = user.passports
@@ -90,10 +90,10 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
90
90
  });
91
91
 
92
92
  if (!userInfo) {
93
- throw new Error(messages.notAllowed[locale]);
93
+ throw new Error(messages.userNotExist({ did: userDid })[locale]);
94
94
  }
95
95
  if (!userInfo.approved) {
96
- throw new Error(messages.notAuthorized[locale]);
96
+ throw new Error(messages.notAllowedAppUser[locale]);
97
97
  }
98
98
 
99
99
  const parsed = JSON.parse(fromBase64(payload).toString());
@@ -120,7 +120,7 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
120
120
  });
121
121
 
122
122
  if (!userRoles.includes(role)) {
123
- throw new Error(messages.notAllowed[locale]);
123
+ throw new Error(messages.passportNotAllowedToUse({ passports: userRoles.join('/') })[locale]);
124
124
  }
125
125
 
126
126
  if (passport) {
@@ -33,10 +33,10 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
33
33
  options: { enableConnectedAccount: true },
34
34
  });
35
35
  if (!user) {
36
- throw new Error(messages.notAllowed[locale]);
36
+ throw new Error(messages.userNotExist({ did: userDid })[locale]);
37
37
  }
38
38
  if (!user.approved) {
39
- throw new Error(messages.notAuthorized[locale]);
39
+ throw new Error(messages.notAllowedAppUser[locale]);
40
40
  }
41
41
 
42
42
  const sourceAppPid = getSourceAppPid(request);
@@ -75,7 +75,7 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
75
75
  });
76
76
 
77
77
  if (!allowedRoles.includes(role)) {
78
- throw new Error(messages.notAllowed[locale]);
78
+ throw new Error(messages.passportNotAllowedToUse({ passports: allowedRoles.join('/') })[locale]);
79
79
  }
80
80
 
81
81
  if (passport) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.17.2-beta-20251111-010532-4bb3b162",
6
+ "version": "1.17.2-beta-20251111-114226-13276e42",
7
7
  "description": "Provide unified services for every blocklet",
8
8
  "main": "api/index.js",
9
9
  "files": [
@@ -32,17 +32,17 @@
32
32
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
33
33
  "license": "Apache-2.0",
34
34
  "dependencies": {
35
- "@abtnode/analytics": "1.17.2-beta-20251111-010532-4bb3b162",
36
- "@abtnode/auth": "1.17.2-beta-20251111-010532-4bb3b162",
37
- "@abtnode/connect-storage": "1.17.2-beta-20251111-010532-4bb3b162",
38
- "@abtnode/constant": "1.17.2-beta-20251111-010532-4bb3b162",
39
- "@abtnode/core": "1.17.2-beta-20251111-010532-4bb3b162",
40
- "@abtnode/cron": "1.17.2-beta-20251111-010532-4bb3b162",
41
- "@abtnode/db-cache": "1.17.2-beta-20251111-010532-4bb3b162",
42
- "@abtnode/logger": "1.17.2-beta-20251111-010532-4bb3b162",
43
- "@abtnode/models": "1.17.2-beta-20251111-010532-4bb3b162",
44
- "@abtnode/router-templates": "1.17.2-beta-20251111-010532-4bb3b162",
45
- "@abtnode/util": "1.17.2-beta-20251111-010532-4bb3b162",
35
+ "@abtnode/analytics": "1.17.2-beta-20251111-114226-13276e42",
36
+ "@abtnode/auth": "1.17.2-beta-20251111-114226-13276e42",
37
+ "@abtnode/connect-storage": "1.17.2-beta-20251111-114226-13276e42",
38
+ "@abtnode/constant": "1.17.2-beta-20251111-114226-13276e42",
39
+ "@abtnode/core": "1.17.2-beta-20251111-114226-13276e42",
40
+ "@abtnode/cron": "1.17.2-beta-20251111-114226-13276e42",
41
+ "@abtnode/db-cache": "1.17.2-beta-20251111-114226-13276e42",
42
+ "@abtnode/logger": "1.17.2-beta-20251111-114226-13276e42",
43
+ "@abtnode/models": "1.17.2-beta-20251111-114226-13276e42",
44
+ "@abtnode/router-templates": "1.17.2-beta-20251111-114226-13276e42",
45
+ "@abtnode/util": "1.17.2-beta-20251111-114226-13276e42",
46
46
  "@arcblock/did": "^1.27.4",
47
47
  "@arcblock/did-connect-js": "^1.27.4",
48
48
  "@arcblock/did-ext": "^1.27.4",
@@ -52,18 +52,18 @@
52
52
  "@arcblock/jwt": "^1.27.4",
53
53
  "@arcblock/validator": "^1.27.4",
54
54
  "@arcblock/ws": "^1.27.4",
55
- "@blocklet/constant": "1.17.2-beta-20251111-010532-4bb3b162",
55
+ "@blocklet/constant": "1.17.2-beta-20251111-114226-13276e42",
56
56
  "@blocklet/dbhub": "^0.2.9",
57
- "@blocklet/env": "1.17.2-beta-20251111-010532-4bb3b162",
57
+ "@blocklet/env": "1.17.2-beta-20251111-114226-13276e42",
58
58
  "@blocklet/error": "^0.3.2",
59
59
  "@blocklet/form-builder": "^0.1.12",
60
60
  "@blocklet/form-collector": "^0.1.8",
61
- "@blocklet/images": "1.17.2-beta-20251111-010532-4bb3b162",
62
- "@blocklet/js-sdk": "1.17.2-beta-20251111-010532-4bb3b162",
63
- "@blocklet/meta": "1.17.2-beta-20251111-010532-4bb3b162",
64
- "@blocklet/rate-limit": "1.17.2-beta-20251111-010532-4bb3b162",
65
- "@blocklet/sdk": "1.17.2-beta-20251111-010532-4bb3b162",
66
- "@blocklet/server-js": "1.17.2-beta-20251111-010532-4bb3b162",
61
+ "@blocklet/images": "1.17.2-beta-20251111-114226-13276e42",
62
+ "@blocklet/js-sdk": "1.17.2-beta-20251111-114226-13276e42",
63
+ "@blocklet/meta": "1.17.2-beta-20251111-114226-13276e42",
64
+ "@blocklet/rate-limit": "1.17.2-beta-20251111-114226-13276e42",
65
+ "@blocklet/sdk": "1.17.2-beta-20251111-114226-13276e42",
66
+ "@blocklet/server-js": "1.17.2-beta-20251111-114226-13276e42",
67
67
  "@blocklet/theme": "^3.2.2",
68
68
  "@blocklet/theme-builder": "0.4.8",
69
69
  "@blocklet/uploader-server": "^0.3.8",
@@ -123,7 +123,7 @@
123
123
  "whatwg-url": "14.0.0"
124
124
  },
125
125
  "devDependencies": {
126
- "@abtnode/ux": "1.17.2-beta-20251111-010532-4bb3b162",
126
+ "@abtnode/ux": "1.17.2-beta-20251111-114226-13276e42",
127
127
  "@arcblock/bridge": "^3.2.2",
128
128
  "@arcblock/did-connect-react": "^3.2.2",
129
129
  "@arcblock/icons": "^3.2.2",
@@ -133,7 +133,7 @@
133
133
  "@blocklet/did-space-react": "^1.2.2",
134
134
  "@blocklet/launcher-layout": "^3.2.2",
135
135
  "@blocklet/payment-react": "^1.22.9",
136
- "@blocklet/tracker": "1.17.2-beta-20251111-010532-4bb3b162",
136
+ "@blocklet/tracker": "1.17.2-beta-20251111-114226-13276e42",
137
137
  "@blocklet/ui-react": "^3.2.2",
138
138
  "@blocklet/uploader": "^0.3.8",
139
139
  "@emotion/react": "^11.14.0",
@@ -213,5 +213,5 @@
213
213
  "url": "https://github.com/ArcBlock/blocklet-server/issues",
214
214
  "email": "shijun@arcblock.io"
215
215
  },
216
- "gitHead": "59e53bd8b3b07701f258919b7349f162b895c8d2"
216
+ "gitHead": "3a85bab76a65b0f04427f9a7e74e8d4fcbcdd3f1"
217
217
  }