@abtnode/blocklet-services 1.16.14-beta-c308dc3b → 1.16.14-beta-963cb583

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.
Files changed (150) hide show
  1. package/api/libs/connect/session.js +20 -18
  2. package/api/libs/image.js +16 -6
  3. package/api/routes/oauth.js +15 -7
  4. package/api/routes/user.js +2 -2
  5. package/build/asset-manifest.json +141 -124
  6. package/build/index.html +1 -1
  7. package/build/service-worker.js +1 -1
  8. package/build/service-worker.js.map +1 -1
  9. package/build/static/css/{4603.dce369d5.chunk.css → 5355.c4fb5c4a.chunk.css} +1 -1
  10. package/build/static/css/{780.e3db6e49.chunk.css → 5982.ac464505.chunk.css} +1 -1
  11. package/build/static/css/{2130.b9437a64.chunk.css → 7272.0ae9f678.chunk.css} +1 -1
  12. package/build/static/js/1132.c008fe16.chunk.js +3 -0
  13. package/build/static/js/1480.f89236fc.chunk.js +2 -0
  14. package/build/static/js/1546.05fce5c0.chunk.js +2 -0
  15. package/build/static/js/1565.4331eeaf.chunk.js +2 -0
  16. package/build/static/js/1660.e2ff5a21.chunk.js +2 -0
  17. package/build/static/js/1760.0f19b880.chunk.js +2 -0
  18. package/build/static/js/1980.79862e88.chunk.js +2 -0
  19. package/build/static/js/2291.80adfd96.chunk.js +2 -0
  20. package/build/static/js/2393.9c045444.chunk.js +2 -0
  21. package/build/static/js/252.8dd19212.chunk.js +3 -0
  22. package/build/static/js/2653.58a5430b.chunk.js +2 -0
  23. package/build/static/js/2664.a42cbb96.chunk.js +2 -0
  24. package/build/static/js/2686.3a7c583a.chunk.js +2 -0
  25. package/build/static/js/3179.03c92dcb.chunk.js +2 -0
  26. package/build/static/js/3551.a3cfa6aa.chunk.js +2 -0
  27. package/build/static/js/3593.98d9341a.chunk.js +2 -0
  28. package/build/static/js/3595.d4510796.chunk.js +3 -0
  29. package/build/static/js/4023.f88d8f4b.chunk.js +2 -0
  30. package/build/static/js/4164.5adbbbba.chunk.js +2 -0
  31. package/build/static/js/4319.8d9e189e.chunk.js +2 -0
  32. package/build/static/js/{445.7ad42b19.chunk.js → 445.9fc4bb72.chunk.js} +3 -3
  33. package/build/static/js/4682.23dd054e.chunk.js +2 -0
  34. package/build/static/js/4716.58477c5c.chunk.js +2 -0
  35. package/build/static/js/4764.51208c0d.chunk.js +2 -0
  36. package/build/static/js/5176.9f08e927.chunk.js +2 -0
  37. package/build/static/js/5355.4b07ad55.chunk.js +2 -0
  38. package/build/static/js/5434.523d071d.chunk.js +2 -0
  39. package/build/static/js/5465.f32033e1.chunk.js +2 -0
  40. package/build/static/js/5541.1d065ac6.chunk.js +2 -0
  41. package/build/static/js/5645.3c5c0f93.chunk.js +2 -0
  42. package/build/static/js/5683.46331372.chunk.js +2 -0
  43. package/build/static/js/5848.487098c8.chunk.js +2 -0
  44. package/build/static/js/5859.9b88d959.chunk.js +2 -0
  45. package/build/static/js/5960.6c234993.chunk.js +2 -0
  46. package/build/static/js/5982.19c5663f.chunk.js +2 -0
  47. package/build/static/js/617.ecc73170.chunk.js +3 -0
  48. package/build/static/js/6186.cc8ce4a4.chunk.js +2 -0
  49. package/build/static/js/6326.3a3cb154.chunk.js +2 -0
  50. package/build/static/js/6378.29466d9e.chunk.js +2 -0
  51. package/build/static/js/6700.e22cc266.chunk.js +2 -0
  52. package/build/static/js/6711.38948be4.chunk.js +2 -0
  53. package/build/static/js/6737.5aef67e7.chunk.js +2 -0
  54. package/build/static/js/6771.583c16c9.chunk.js +3 -0
  55. package/build/static/js/6856.163537c7.chunk.js +2 -0
  56. package/build/static/js/6921.2f39f974.chunk.js +2 -0
  57. package/build/static/js/7.c01bf0f4.chunk.js +2 -0
  58. package/build/static/js/7006.b21fb368.chunk.js +2 -0
  59. package/build/static/js/7272.608c5875.chunk.js +3 -0
  60. package/build/static/js/7977.38c9fc34.chunk.js +2 -0
  61. package/build/static/js/8143.6b921364.chunk.js +2 -0
  62. package/build/static/js/8179.34de3f17.chunk.js +2 -0
  63. package/build/static/js/8365.9904e38d.chunk.js +3 -0
  64. package/build/static/js/8437.0d88b9db.chunk.js +2 -0
  65. package/build/static/js/8527.437a8769.chunk.js +2 -0
  66. package/build/static/js/861.a19bf499.chunk.js +2 -0
  67. package/build/static/js/878.4424e6e9.chunk.js +2 -0
  68. package/build/static/js/9102.7087c66c.chunk.js +2 -0
  69. package/build/static/js/9106.783701ea.chunk.js +2 -0
  70. package/build/static/js/9107.967c2ac1.chunk.js +2 -0
  71. package/build/static/js/926.d1421ce1.chunk.js +2 -0
  72. package/build/static/js/9260.d8f59a75.chunk.js +3 -0
  73. package/build/static/js/9260.d8f59a75.chunk.js.LICENSE.txt +7 -0
  74. package/build/static/js/9409.0d5d4de2.chunk.js +2 -0
  75. package/build/static/js/9620.4b7c9e8b.chunk.js +2 -0
  76. package/build/static/js/9657.e974d577.chunk.js +2 -0
  77. package/build/static/js/9899.18509ac9.chunk.js +2 -0
  78. package/build/static/js/main.081afde0.js +3 -0
  79. package/build/static/js/{main.3e42ffde.js.LICENSE.txt → main.081afde0.js.LICENSE.txt} +0 -6
  80. package/build/static/media/empty-space-nft.3878bc5c8ba6490ef5075fdda24be921.svg +59 -0
  81. package/build/static/media/space-connected.9a4e18fd2bc7d065191b0d241a131c28.svg +3 -0
  82. package/package.json +35 -35
  83. package/api/libs/translate.js +0 -12
  84. package/build/static/js/1162.ff3136ae.chunk.js +0 -2
  85. package/build/static/js/1210.b6221400.chunk.js +0 -2
  86. package/build/static/js/1255.0e8a8a45.chunk.js +0 -2
  87. package/build/static/js/1832.3ac49edc.chunk.js +0 -2
  88. package/build/static/js/1980.dc299167.chunk.js +0 -2
  89. package/build/static/js/2130.f123740e.chunk.js +0 -3
  90. package/build/static/js/2139.341406d2.chunk.js +0 -2
  91. package/build/static/js/3242.c54d8ce1.chunk.js +0 -2
  92. package/build/static/js/3464.12806bfe.chunk.js +0 -2
  93. package/build/static/js/3800.f5b8660e.chunk.js +0 -2
  94. package/build/static/js/3963.2e06f9bc.chunk.js +0 -3
  95. package/build/static/js/4056.7104fbed.chunk.js +0 -2
  96. package/build/static/js/4319.e99b5af9.chunk.js +0 -2
  97. package/build/static/js/4359.5ed52fe3.chunk.js +0 -2
  98. package/build/static/js/4492.97b0d4f6.chunk.js +0 -2
  99. package/build/static/js/4547.3692fa06.chunk.js +0 -2
  100. package/build/static/js/4603.7a55b2c4.chunk.js +0 -2
  101. package/build/static/js/4651.3fbbf7ac.chunk.js +0 -3
  102. package/build/static/js/4682.81053e18.chunk.js +0 -2
  103. package/build/static/js/4716.a1240199.chunk.js +0 -2
  104. package/build/static/js/5050.7feba723.chunk.js +0 -3
  105. package/build/static/js/5052.8d91917d.chunk.js +0 -2
  106. package/build/static/js/5176.68fd3fde.chunk.js +0 -2
  107. package/build/static/js/5233.faabaae9.chunk.js +0 -2
  108. package/build/static/js/5376.9c06ee1e.chunk.js +0 -3
  109. package/build/static/js/5430.6aa38ea1.chunk.js +0 -2
  110. package/build/static/js/5491.f227b5b4.chunk.js +0 -2
  111. package/build/static/js/5645.a17cd258.chunk.js +0 -2
  112. package/build/static/js/5711.aa17ef28.chunk.js +0 -2
  113. package/build/static/js/5813.3f792b20.chunk.js +0 -2
  114. package/build/static/js/6315.59e078f6.chunk.js +0 -2
  115. package/build/static/js/652.9c9e49fa.chunk.js +0 -2
  116. package/build/static/js/655.cdee65b4.chunk.js +0 -2
  117. package/build/static/js/6711.a62d0bcd.chunk.js +0 -2
  118. package/build/static/js/6737.4f37dd4a.chunk.js +0 -2
  119. package/build/static/js/6792.a534f860.chunk.js +0 -3
  120. package/build/static/js/6792.a534f860.chunk.js.LICENSE.txt +0 -21
  121. package/build/static/js/6891.6c7018ab.chunk.js +0 -2
  122. package/build/static/js/7006.0aa7d1b3.chunk.js +0 -2
  123. package/build/static/js/7291.5553195e.chunk.js +0 -2
  124. package/build/static/js/731.9f99f66f.chunk.js +0 -2
  125. package/build/static/js/7371.d13e6cd3.chunk.js +0 -2
  126. package/build/static/js/7518.5b02f3ba.chunk.js +0 -2
  127. package/build/static/js/766.ab730327.chunk.js +0 -2
  128. package/build/static/js/780.32bf1f5b.chunk.js +0 -2
  129. package/build/static/js/8031.9944bf3c.chunk.js +0 -2
  130. package/build/static/js/8395.b1ffb35e.chunk.js +0 -2
  131. package/build/static/js/8437.e4b47fc3.chunk.js +0 -2
  132. package/build/static/js/861.1e3923ec.chunk.js +0 -2
  133. package/build/static/js/8669.814198b8.chunk.js +0 -2
  134. package/build/static/js/868.60de5f6d.chunk.js +0 -2
  135. package/build/static/js/8960.2b3e5e40.chunk.js +0 -2
  136. package/build/static/js/9381.4be08f8a.chunk.js +0 -2
  137. package/build/static/js/9409.ce15e157.chunk.js +0 -2
  138. package/build/static/js/9476.bc480cfc.chunk.js +0 -2
  139. package/build/static/js/9506.d732d124.chunk.js +0 -2
  140. package/build/static/js/982.11dc355f.chunk.js +0 -3
  141. package/build/static/js/main.3e42ffde.js +0 -3
  142. package/build/static/media/iconify.212917dd32288c600255.cjs +0 -2
  143. /package/build/static/{media/iconify.212917dd32288c600255.cjs.LICENSE.txt → js/1132.c008fe16.chunk.js.LICENSE.txt} +0 -0
  144. /package/build/static/js/{982.11dc355f.chunk.js.LICENSE.txt → 252.8dd19212.chunk.js.LICENSE.txt} +0 -0
  145. /package/build/static/js/{4651.3fbbf7ac.chunk.js.LICENSE.txt → 3595.d4510796.chunk.js.LICENSE.txt} +0 -0
  146. /package/build/static/js/{445.7ad42b19.chunk.js.LICENSE.txt → 445.9fc4bb72.chunk.js.LICENSE.txt} +0 -0
  147. /package/build/static/js/{3963.2e06f9bc.chunk.js.LICENSE.txt → 617.ecc73170.chunk.js.LICENSE.txt} +0 -0
  148. /package/build/static/js/{5050.7feba723.chunk.js.LICENSE.txt → 6771.583c16c9.chunk.js.LICENSE.txt} +0 -0
  149. /package/build/static/js/{2130.f123740e.chunk.js.LICENSE.txt → 7272.608c5875.chunk.js.LICENSE.txt} +0 -0
  150. /package/build/static/js/{5376.9c06ee1e.chunk.js.LICENSE.txt → 8365.9904e38d.chunk.js.LICENSE.txt} +0 -0
@@ -38,6 +38,7 @@ const { fromAppDid } = require('@arcblock/did-ext');
38
38
  const { LOGIN_PROVIDER } = require('@blocklet/constant');
39
39
  const { signV2 } = require('@arcblock/jwt');
40
40
  const pick = require('lodash/pick');
41
+ const createTranslator = require('@abtnode/util/lib/translate');
41
42
 
42
43
  const { getRolesFromAuthConfig, getBlockletAppIdList } = require('@blocklet/meta/lib/util');
43
44
 
@@ -45,7 +46,6 @@ const logger = require('@abtnode/logger')(require('../../../package.json').name)
45
46
 
46
47
  const { isInvitedUserOnly, createTokenFn, getDidConnectVersion } = require('../../util');
47
48
  const { transferPassport } = require('../auth/utils');
48
- const { generateTranslate } = require('../translate');
49
49
  const { migrateAccount, declareAccount } = require('../../services/oauth');
50
50
  const { getTrustedIssuers, getLoginProvider, getFederatedTrustedIssuers } = require('../../util/blocklet-utils');
51
51
  const { getFederatedMaster, getUserAvatarUrl } = require('../../util/federated');
@@ -719,7 +719,7 @@ module.exports = {
719
719
  },
720
720
  },
721
721
 
722
- // 基本流程与 login 一致,但在创建更新用户信息的逻辑不一样
722
+ // Auth0 绑定 DID Wallet 账户,基本流程与 login 一致,但在创建更新用户信息的逻辑不一样
723
723
  bindWallet: {
724
724
  authPrincipal: ({ email, locale, previousUserDid }) => {
725
725
  const user = email || previousUserDid;
@@ -734,24 +734,25 @@ module.exports = {
734
734
  onConnect: async ({ node, request, userDid, locale, componentId, previousUserDid }) => {
735
735
  const translations = {
736
736
  en: {
737
- notFound: "Can't get bind account information",
738
- alreadyBindOAuth: 'already bind with another account',
739
- alreadyBindWallet: 'Current account is already bind a wallet account',
740
- alreadyMainAccount: 'Current account is already a main account',
737
+ notFound: "Couldn't find account information.",
738
+ alreadyBindOAuth: 'Your wallet account ({did}) is already bond to another email.',
739
+ alreadyBindWallet: 'Your email is already bond to another wallet account {did}.',
740
+ alreadyMainAccount:
741
+ 'Your wallet account is already bond to this app. You cannot bind it again. Please use another wallet account or create a new one to try again.',
741
742
  },
742
743
  zh: {
743
- notFound: '获取绑定账户信息失败',
744
- alreadyBindOAuth: '已绑定 OAuth 账户',
745
- alreadyBindWallet: '该账户已绑定 Wallet 账户',
746
- alreadyMainAccount: '已给该账户分配一个主账户',
744
+ notFound: '无法获取账户信息。',
745
+ alreadyBindOAuth: '你的钱包账户 {did} 已经与其他账户绑定。',
746
+ alreadyBindWallet: '当前账户已经绑定过钱包账户 {did}。',
747
+ alreadyMainAccount: '你的钱包账户 {did} 已绑定过该应用,无法重复绑定,请切换或新建一个钱包账户再次尝试。',
747
748
  },
748
749
  };
749
- const t = generateTranslate({ translations });
750
+ const t = createTranslator({ translations });
750
751
  const { did: teamDid } = await request.getBlockletInfo();
751
752
 
752
753
  const walletUser = await node.getUser({ teamDid, user: { did: userDid } });
753
754
  if (walletUser) {
754
- throw new Error(t('alreadyMainAccount', locale));
755
+ throw new Error(t('alreadyMainAccount', locale, { did: userDid }));
755
756
  }
756
757
 
757
758
  const config = await request.getServiceConfig(NODE_SERVICES.AUTH, { componentId });
@@ -764,14 +765,15 @@ module.exports = {
764
765
  enableConnectedAccount: true,
765
766
  },
766
767
  });
767
-
768
768
  if (!oauthUser) {
769
- throw new Error(t('notFound', locale));
769
+ throw new Error(t('notFound', locale, { email: oauthUser.email }));
770
770
  }
771
- const oauthConnectedAccounts = oauthUser.connectedAccounts || [];
771
+
772
772
  const sourceProvider = oauthUser.sourceProvider || LOGIN_PROVIDER.WALLET;
773
- if (oauthConnectedAccounts.find((item) => item.provider === LOGIN_PROVIDER.WALLET)) {
774
- throw new Error(t('alreadyBindWallet', locale));
773
+ const oauthConnectedAccounts = oauthUser.connectedAccounts || [];
774
+ const exist = oauthConnectedAccounts.find((item) => item.provider === LOGIN_PROVIDER.WALLET);
775
+ if (exist) {
776
+ throw new Error(t('alreadyBindWallet', locale, { email: oauthUser.email, did: exist.did }));
775
777
  }
776
778
 
777
779
  const bindUser = await node.getUser({
@@ -787,7 +789,7 @@ module.exports = {
787
789
  if (bindUser) {
788
790
  const bindConnectedAccounts = bindUser.connectedAccounts || [];
789
791
  if (bindConnectedAccounts.find((item) => item.provider === sourceProvider)) {
790
- throw new Error(`${oauthUser.email} ${t('alreadyBindOAuth', locale)}`);
792
+ throw new Error(t('alreadyBindOAuth', locale, { email: oauthUser.email, did: userDid }));
791
793
  }
792
794
  }
793
795
 
package/api/libs/image.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
5
5
  const sharp = require('sharp');
6
+ const toLower = require('lodash/toLower');
6
7
  const { Joi } = require('@arcblock/validator');
7
8
  const stringify = require('json-stable-stringify');
8
9
  const md5 = require('@abtnode/util/lib/md5');
@@ -12,8 +13,9 @@ const logger = require('@abtnode/logger')('@abtnode/blocklet-services/image');
12
13
 
13
14
  const errorImage = path.resolve(__dirname, './error.svg');
14
15
 
15
- const FORMATS = ['png', 'jpeg', 'webp', 'avif', 'heif'];
16
+ const FORMATS = ['png', 'gif', 'jpeg', 'webp', 'avif', 'heif'];
16
17
  const OPERATIONS = ['convert', 'resize', 'crop'];
18
+ const MODES = ['cover', 'contain', 'fill', 'inside', 'outside'];
17
19
  const QUALITIES = {
18
20
  png: 100,
19
21
  jpeg: 80,
@@ -24,6 +26,7 @@ const QUALITIES = {
24
26
 
25
27
  const EXTENSIONS = {
26
28
  png: 'png',
29
+ gif: 'gif',
27
30
  jpeg: 'jpeg',
28
31
  jpg: 'jpeg',
29
32
  webp: 'webp',
@@ -33,6 +36,7 @@ const EXTENSIONS = {
33
36
 
34
37
  const schema = Joi.object({
35
38
  imageFilter: Joi.string()
39
+ .lowercase()
36
40
  .valid(...OPERATIONS)
37
41
  .required(),
38
42
 
@@ -68,6 +72,7 @@ const schema = Joi.object({
68
72
 
69
73
  // image format
70
74
  f: Joi.string()
75
+ .lowercase()
71
76
  .valid(...FORMATS)
72
77
  .when('imageFilter', {
73
78
  is: 'convert',
@@ -76,7 +81,11 @@ const schema = Joi.object({
76
81
  }),
77
82
 
78
83
  // resize positions
79
- m: Joi.string().valid('cover', 'contain', 'fill', 'inside', 'outside').optional().default('inside'),
84
+ m: Joi.string()
85
+ .lowercase()
86
+ .valid(...MODES)
87
+ .optional()
88
+ .default('inside'),
80
89
 
81
90
  // crop positions
82
91
  t: Joi.number().integer().min(0).max(2048).optional().default(0),
@@ -88,7 +97,7 @@ const schema = Joi.object({
88
97
  .options({ stripUnknown: true, allowUnknown: true, noDefaults: false });
89
98
 
90
99
  const isImageAccepted = (req) => {
91
- const extension = path.extname(req.path).slice(1);
100
+ const extension = toLower(path.extname(req.path).slice(1));
92
101
  return FORMATS.includes(EXTENSIONS[extension]) && FORMATS.some((x) => req.accepts(`image/${x}`));
93
102
  };
94
103
 
@@ -116,7 +125,7 @@ const processAndRespond = (req, res, cacheDir, getSrc) => {
116
125
  }
117
126
 
118
127
  const params = req.imageFilter;
119
- const extension = path.extname(req.path).slice(1);
128
+ const extension = toLower(path.extname(req.path).slice(1));
120
129
  if (!extension && !params.f) {
121
130
  res.status(400).send('Image filter failed: either extension or format must be specified');
122
131
  return;
@@ -132,7 +141,7 @@ const processAndRespond = (req, res, cacheDir, getSrc) => {
132
141
 
133
142
  // do the convert
134
143
  tasks[cacheKey] ??= getSrc(req)
135
- .then(([src, ext]) => processImage(src, ext, destPath, params))
144
+ .then(([src, ext]) => processImage(src, toLower(ext), destPath, params))
136
145
  .finally(() => {
137
146
  setTimeout(() => {
138
147
  delete tasks[cacheKey];
@@ -184,7 +193,7 @@ const processImage = (src, extension, dest, params) => {
184
193
  dimensions.height = height;
185
194
  }
186
195
 
187
- const pipeline = sharp().timeout({ seconds: 8 });
196
+ const pipeline = sharp({ animated: true }).timeout({ seconds: 8 });
188
197
  if (rotate) {
189
198
  pipeline.rotate(rotate);
190
199
  }
@@ -240,4 +249,5 @@ module.exports = {
240
249
  processAndRespond,
241
250
  processImage,
242
251
  EXTENSIONS,
252
+ MODES,
243
253
  };
@@ -13,6 +13,7 @@ const sortBy = require('lodash/sortBy');
13
13
  const joinUrl = require('url-join');
14
14
  const { getWalletDid } = require('@blocklet/meta/lib/did-utils');
15
15
  const formatContext = require('@abtnode/util/lib/format-context');
16
+ const createTranslator = require('@abtnode/util/lib/translate');
16
17
  const { LOGIN_PROVIDER } = require('@blocklet/constant');
17
18
  const logger = require('@abtnode/logger')('blocklet-services:oauth');
18
19
 
@@ -20,7 +21,6 @@ const { AuthenticationClient } = require('../libs/auth/adapters/auth0');
20
21
  const { getAvatarByEmail, transferPassport, getAvatarByUrl } = require('../libs/auth/utils');
21
22
  const initJwt = require('../libs/jwt');
22
23
  const { sendToUser } = require('../libs/notification');
23
- const { generateTranslate } = require('../libs/translate');
24
24
  const { isInvitedUserOnly, createTokenFn, getDidConnectVersion } = require('../util');
25
25
  const { ApiError } = require('../util/error');
26
26
 
@@ -31,19 +31,22 @@ const prefix = `${PREFIX}/oauth`;
31
31
  const translations = {
32
32
  zh: {
33
33
  needInviteToLogin: '你需要被邀请才可以登录此应用',
34
- alreadyMainAccount: '已给该账户分配一个主账户',
34
+ alreadyMainAccount: '当前邮箱已经绑定过该应用,不过你可以先以此邮箱登陆,然后再绑定钱包账户',
35
+ alreadyBindWallet: '当前邮箱已经绑定过钱包账户 {did}。',
35
36
  oauthCantBeOwner: '第三方登录的账户不能成为应用的拥有者',
36
37
  oauthCantBindOauth: '第三方登录的账户无法绑定另一个第三方登录的账户',
37
38
  },
38
39
  en: {
39
- needInviteToLogin: 'You need to be invited to sign in to this app',
40
- alreadyMainAccount: 'Current account is already a main account',
40
+ needInviteToLogin: 'You need to be invited to login in to this app',
41
+ alreadyMainAccount:
42
+ 'Your email has already logged in to the app, so binding cannot be completed. However, you can first log in with this email and then bind your wallet account.',
43
+ alreadyBindWallet: 'Your account is already bond to wallet account {did}, so binding can not be completed.',
41
44
  oauthCantBeOwner: "Can't login oauth account as owner",
42
- oauthCantBindOauth: "Current account can't bind a third party account",
45
+ oauthCantBindOauth: "Current account can't bind to a third party account",
43
46
  },
44
47
  };
45
48
 
46
- const t = generateTranslate({ translations });
49
+ const t = createTranslator({ translations });
47
50
 
48
51
  function getAuthClient(blocklet, provider) {
49
52
  const oauthConfig = blocklet?.settings?.oauth || {};
@@ -293,6 +296,7 @@ async function invite(req, node, options) {
293
296
  return { sessionToken, refreshToken };
294
297
  }
295
298
 
299
+ // 给 DID Wallet 绑定 Auth0 的流程
296
300
  // eslint-disable-next-line no-unused-vars
297
301
  async function bind(req, node, options) {
298
302
  const { token, locale = 'en', provider } = req.body;
@@ -311,7 +315,11 @@ async function bind(req, node, options) {
311
315
  },
312
316
  });
313
317
  if (oauthUser) {
314
- throw new ApiError(400, t('alreadyMainAccount', locale));
318
+ if (oauthUser.sourceProvider === LOGIN_PROVIDER.AUTH0) {
319
+ throw new ApiError(400, t('alreadyMainAccount', locale, { email: userInfo.email }));
320
+ }
321
+
322
+ throw new ApiError(400, t('alreadyBindWallet', locale, { email: userInfo.email, did: oauthUser.did }));
315
323
  }
316
324
 
317
325
  // NOTICE: 这里获得的 did 是当前登录用户的永久 did,无需再去查询 connectedAccount
@@ -3,11 +3,11 @@ const { getApplicationInfo } = require('@abtnode/auth/lib/auth');
3
3
  const { fromAppDid } = require('@arcblock/did-ext');
4
4
  const { extractUserAvatar } = require('@abtnode/util/lib/user');
5
5
  const formatContext = require('@abtnode/util/lib/format-context');
6
+ const createTranslator = require('@abtnode/util/lib/translate');
6
7
  const logger = require('@abtnode/logger')('blocklet-services:user');
7
8
  const { isFromPublicKey } = require('@arcblock/did');
8
9
  const { LOGIN_PROVIDER } = require('@blocklet/constant');
9
10
 
10
- const { generateTranslate } = require('../libs/translate');
11
11
  const { isInvitedUserOnly, createTokenFn, getDidConnectVersion } = require('../util');
12
12
  const initJwt = require('../libs/jwt');
13
13
  const { getAvatarByUrl } = require('../libs/auth/utils');
@@ -42,7 +42,7 @@ const translations = {
42
42
  },
43
43
  };
44
44
 
45
- const t = generateTranslate({ translations });
45
+ const t = createTranslator({ translations });
46
46
 
47
47
  async function checkNeedInvite({ req, node, teamDid, componentId, locale }) {
48
48
  const config = await req.getServiceConfig(NODE_SERVICES.AUTH, { componentId });