@abtnode/blocklet-services 1.16.32-beta-76103be3 → 1.16.32-beta-820e4cfa

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/api/libs/kyc.js CHANGED
@@ -2,6 +2,7 @@ const get = require('lodash/get');
2
2
  const uniq = require('lodash/uniq');
3
3
  const pick = require('lodash/pick');
4
4
  const trim = require('lodash/trim');
5
+ const lowerCase = require('lodash/lowerCase');
5
6
  const semver = require('semver');
6
7
  const { messages, getVCFromClaims } = require('@abtnode/auth/lib/auth');
7
8
  const { getPassportClaimUrl, getKycAcquireUrl } = require('@abtnode/auth/lib/passport');
@@ -159,6 +160,20 @@ function getKycClaims(blocklet, user, locale, baseUrl, trustedIssuers) {
159
160
  return claims;
160
161
  }
161
162
 
163
+ const isSameEmail = (email1, email2) => {
164
+ if (!email1 || !email2) {
165
+ return false;
166
+ }
167
+ return lowerCase(email1) === lowerCase(email2);
168
+ };
169
+
170
+ const isSamePhone = (phone1, phone2) => {
171
+ if (!phone1 || !phone2) {
172
+ return false;
173
+ }
174
+ return phone1.replace(/\s+/g, '').replace(/[()-]/g, '') === phone2.replace(/\s+/g, '').replace(/[()-]/g, '');
175
+ };
176
+
162
177
  async function verifyKycClaims({ node, blocklet, teamDid, claims, challenge, locale, sourceAppPid, user }) {
163
178
  const profile = claims.find((claim) => claim.type === 'profile');
164
179
  const kycUpdates = pick(user || {}, ['emailVerified', 'phoneVerified']);
@@ -177,7 +192,7 @@ async function verifyKycClaims({ node, blocklet, teamDid, claims, challenge, loc
177
192
  throw new Error(messages.missingEmailKyc[locale]);
178
193
  }
179
194
  const email = get(emailKyc, 'credentialSubject.kyc.subject');
180
- if (profile?.email && profile.email !== email) {
195
+ if (profile?.email && !isSameEmail(profile.email, email)) {
181
196
  throw new Error(messages.emailMismatch[locale]);
182
197
  }
183
198
 
@@ -232,7 +247,7 @@ async function verifyKycClaims({ node, blocklet, teamDid, claims, challenge, loc
232
247
  throw new Error(messages.missingPhoneKyc[locale]);
233
248
  }
234
249
  const phone = get(phoneKyc, 'credentialSubject.kyc.subject');
235
- if (profile?.phone && profile.phone !== phone) {
250
+ if (profile?.phone && !isSamePhone(profile.phone, phone)) {
236
251
  throw new Error(messages.phoneMismatch[locale]);
237
252
  }
238
253
  if (!user && isPhoneUniqueRequired(blocklet)) {
@@ -267,4 +282,6 @@ module.exports = {
267
282
  getPassportVc,
268
283
  isEmailBlocked,
269
284
  isEmailAllowed,
285
+ isSameEmail,
286
+ isSamePhone,
270
287
  };
@@ -31,7 +31,7 @@ const { sendToUser } = require('../libs/notification');
31
31
  const { isInvitedUserOnly, createTokenFn, getDidConnectVersion } = require('../util');
32
32
  const { ApiError } = require('../util/error');
33
33
  const federatedUtil = require('../util/federated');
34
- const { isOAuthEmailVerified, isEmailUniqueRequired, isEmailKycRequired } = require('../libs/kyc');
34
+ const { isOAuthEmailVerified, isEmailUniqueRequired, isEmailKycRequired, isSameEmail } = require('../libs/kyc');
35
35
 
36
36
  const PREFIX = WELLKNOWN_SERVICE_PATH_PREFIX;
37
37
 
@@ -438,7 +438,7 @@ async function invite(req, node, options) {
438
438
  fullName: oauthInfo.name,
439
439
  avatar: getUserAvatarUrl(baseUrl, avatar),
440
440
  };
441
- if (profile.email === oauthInfo.email && isOAuthEmailVerified(blocklet, oauthInfo)) {
441
+ if (isSameEmail(profile.email, oauthInfo.email) && isOAuthEmailVerified(blocklet, oauthInfo)) {
442
442
  profile.emailVerified = true;
443
443
  }
444
444
  }
@@ -644,7 +644,7 @@ async function bind(req, node, options) {
644
644
  avatar,
645
645
  };
646
646
 
647
- if (mergeProfile.email === oauthInfo.email && isOAuthEmailVerified(blocklet, oauthInfo)) {
647
+ if (isSameEmail(mergeProfile.email, oauthInfo.email) && isOAuthEmailVerified(blocklet, oauthInfo)) {
648
648
  mergeProfile.emailVerified = true;
649
649
  }
650
650
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.32-beta-76103be3",
6
+ "version": "1.16.32-beta-820e4cfa",
7
7
  "description": "Provide unified services for every blocklet",
8
8
  "main": "api/index.js",
9
9
  "files": [
@@ -33,17 +33,17 @@
33
33
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
- "@abtnode/analytics": "1.16.32-beta-76103be3",
37
- "@abtnode/auth": "1.16.32-beta-76103be3",
38
- "@abtnode/client": "1.16.32-beta-76103be3",
39
- "@abtnode/connect-storage": "1.16.32-beta-76103be3",
40
- "@abtnode/constant": "1.16.32-beta-76103be3",
41
- "@abtnode/core": "1.16.32-beta-76103be3",
42
- "@abtnode/cron": "1.16.32-beta-76103be3",
43
- "@abtnode/logger": "1.16.32-beta-76103be3",
44
- "@abtnode/models": "1.16.32-beta-76103be3",
45
- "@abtnode/router-templates": "1.16.32-beta-76103be3",
46
- "@abtnode/util": "1.16.32-beta-76103be3",
36
+ "@abtnode/analytics": "1.16.32-beta-820e4cfa",
37
+ "@abtnode/auth": "1.16.32-beta-820e4cfa",
38
+ "@abtnode/client": "1.16.32-beta-820e4cfa",
39
+ "@abtnode/connect-storage": "1.16.32-beta-820e4cfa",
40
+ "@abtnode/constant": "1.16.32-beta-820e4cfa",
41
+ "@abtnode/core": "1.16.32-beta-820e4cfa",
42
+ "@abtnode/cron": "1.16.32-beta-820e4cfa",
43
+ "@abtnode/logger": "1.16.32-beta-820e4cfa",
44
+ "@abtnode/models": "1.16.32-beta-820e4cfa",
45
+ "@abtnode/router-templates": "1.16.32-beta-820e4cfa",
46
+ "@abtnode/util": "1.16.32-beta-820e4cfa",
47
47
  "@arcblock/did": "^1.18.135",
48
48
  "@arcblock/did-auth": "1.18.135",
49
49
  "@arcblock/did-ext": "^1.18.135",
@@ -52,11 +52,11 @@
52
52
  "@arcblock/jwt": "1.18.135",
53
53
  "@arcblock/validator": "^1.18.135",
54
54
  "@arcblock/ws": "1.18.135",
55
- "@blocklet/constant": "1.16.32-beta-76103be3",
55
+ "@blocklet/constant": "1.16.32-beta-820e4cfa",
56
56
  "@blocklet/form-builder": "^0.1.11",
57
57
  "@blocklet/form-collector": "^0.1.8",
58
- "@blocklet/meta": "1.16.32-beta-76103be3",
59
- "@blocklet/sdk": "1.16.32-beta-76103be3",
58
+ "@blocklet/meta": "1.16.32-beta-820e4cfa",
59
+ "@blocklet/sdk": "1.16.32-beta-820e4cfa",
60
60
  "@did-connect/authenticator": "^2.2.4",
61
61
  "@did-connect/relay-adapter-express": "^2.2.4",
62
62
  "@ocap/client": "1.18.135",
@@ -101,14 +101,14 @@
101
101
  "minimatch": "9.0.4"
102
102
  },
103
103
  "devDependencies": {
104
- "@abtnode/ux": "1.16.32-beta-76103be3",
104
+ "@abtnode/ux": "1.16.32-beta-820e4cfa",
105
105
  "@arcblock/bridge": "^2.10.33",
106
106
  "@arcblock/did-connect": "^2.10.33",
107
107
  "@arcblock/icons": "^2.10.33",
108
108
  "@arcblock/react-hooks": "^2.10.33",
109
109
  "@arcblock/ux": "^2.10.33",
110
110
  "@blocklet/launcher-layout": "2.10.33",
111
- "@blocklet/tracker": "1.16.32-beta-76103be3",
111
+ "@blocklet/tracker": "1.16.32-beta-820e4cfa",
112
112
  "@blocklet/ui-react": "^2.10.33",
113
113
  "@emotion/react": "^11.11.4",
114
114
  "@emotion/styled": "^11.11.5",
@@ -182,5 +182,5 @@
182
182
  "url": "https://github.com/ArcBlock/blocklet-server/issues",
183
183
  "email": "shijun@arcblock.io"
184
184
  },
185
- "gitHead": "6d7afe107a349b1267b29e7f2216db9997085015"
185
+ "gitHead": "5d9721ea660974e75815a6b74de4dd233459ec58"
186
186
  }