@fonoster/identity 0.9.22 → 0.9.24

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.
@@ -69,13 +69,13 @@ const createIsValidVerificationCode_1 = require("../utils/createIsValidVerificat
69
69
  const verification_1 = require("../verification");
70
70
  const exchangeTokens_1 = require("./exchangeTokens");
71
71
  const logger = (0, logger_1.getLogger)({ service: "identity", filePath: __filename });
72
- const verificationRequiredButNotProvided = (identityConfig, user) => identityConfig.userVerificationRequired &&
72
+ const verificationRequiredButNotProvided = (identityConfig, user) => identityConfig.contactVerificationRequired &&
73
73
  (!user.emailVerified || !user.phoneNumberVerified);
74
74
  function createExchangeCredentials(prisma, identityConfig) {
75
75
  const isValidVerificationCode = (0, createIsValidVerificationCode_1.createIsValidVerificationCode)(prisma);
76
76
  const exchangeCredentials = (call, callback) => __awaiter(this, void 0, void 0, function* () {
77
77
  const { request } = call;
78
- const { username: email, password, verificationCode } = request;
78
+ const { username: email, password, twoFactorCode } = request;
79
79
  logger.verbose("call to exchangeCredentials", { username: email });
80
80
  const user = yield (0, createGetUserByEmail_1.createGetUserByEmail)(prisma)(email);
81
81
  if (!user || user.password !== (password === null || password === void 0 ? void 0 : password.trim())) {
@@ -90,16 +90,18 @@ function createExchangeCredentials(prisma, identityConfig) {
90
90
  message: "User contact information not verified"
91
91
  });
92
92
  }
93
- if (identityConfig.userVerificationRequired) {
93
+ // TODO: Rename verifcation methods to be more generic
94
+ // At the moment name would suggest that 2FA and verification are the same thing
95
+ if (identityConfig.twoFactorAuthenticationRequired) {
94
96
  const isValid = yield isValidVerificationCode({
95
97
  type: verification_1.ContactType.EMAIL,
96
98
  value: email,
97
- code: verificationCode
99
+ code: twoFactorCode
98
100
  });
99
101
  if (!isValid) {
100
102
  return callback({
101
103
  code: grpc.status.PERMISSION_DENIED,
102
- message: "Invalid verification code"
104
+ message: "Invalid 2FA code"
103
105
  });
104
106
  }
105
107
  }
@@ -31,7 +31,8 @@ type IdentityConfig = {
31
31
  workspaceInviteExpiration: string;
32
32
  workspaceInviteUrl: string;
33
33
  workspaceInviteFailUrl: string;
34
- userVerificationRequired: boolean;
34
+ contactVerificationRequired: boolean;
35
+ twoFactorAuthenticationRequired: boolean;
35
36
  resetPasswordUrl: string;
36
37
  smtpConfig: {
37
38
  sender: string;
package/dist/service.js CHANGED
@@ -71,7 +71,8 @@ function buildIdentityService(identityConfig) {
71
71
  verifyCode: undefined
72
72
  }
73
73
  };
74
- if (identityConfig.userVerificationRequired) {
74
+ if (identityConfig.contactVerificationRequired ||
75
+ identityConfig.twoFactorAuthenticationRequired) {
75
76
  service.handlers.sendVerificationCode = (0, verification_1.createSendVerificationCode)(prisma, identityConfig);
76
77
  service.handlers.verifyCode = (0, verification_1.createVerifyCode)(prisma);
77
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/identity",
3
- "version": "0.9.22",
3
+ "version": "0.9.24",
4
4
  "description": "Identity service for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -20,7 +20,7 @@
20
20
  "fonoster": "./dist/index.js"
21
21
  },
22
22
  "dependencies": {
23
- "@fonoster/common": "^0.9.22",
23
+ "@fonoster/common": "^0.9.24",
24
24
  "@fonoster/logger": "^0.9.22",
25
25
  "@fonoster/types": "^0.9.22",
26
26
  "@grpc/grpc-js": "~1.10.6",
@@ -48,5 +48,5 @@
48
48
  "devDependencies": {
49
49
  "@types/jsonwebtoken": "^9.0.6"
50
50
  },
51
- "gitHead": "3c393362218ebfdd7ec672f18553953edf37e9e3"
51
+ "gitHead": "a6e16d9b8af8594e57d8b385b936cc2508546de1"
52
52
  }