@fonoster/identity 0.9.24 → 0.9.28
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/dist/exchanges/createExchangeCredentials.js +2 -3
- package/dist/exchanges/createExchangeOauth2Code.js +7 -0
- package/dist/users/createCreateUserWithOauth2Code.js +1 -1
- package/dist/utils/createGetUserByEmail.js +3 -0
- package/dist/utils/verificationRequiredButNotProvided.d.ts +24 -0
- package/dist/utils/verificationRequiredButNotProvided.js +7 -0
- package/package.json +2 -2
|
@@ -68,9 +68,8 @@ const createGetUserByEmail_1 = require("../utils/createGetUserByEmail");
|
|
|
68
68
|
const createIsValidVerificationCode_1 = require("../utils/createIsValidVerificationCode");
|
|
69
69
|
const verification_1 = require("../verification");
|
|
70
70
|
const exchangeTokens_1 = require("./exchangeTokens");
|
|
71
|
+
const verificationRequiredButNotProvided_1 = require("../utils/verificationRequiredButNotProvided");
|
|
71
72
|
const logger = (0, logger_1.getLogger)({ service: "identity", filePath: __filename });
|
|
72
|
-
const verificationRequiredButNotProvided = (identityConfig, user) => identityConfig.contactVerificationRequired &&
|
|
73
|
-
(!user.emailVerified || !user.phoneNumberVerified);
|
|
74
73
|
function createExchangeCredentials(prisma, identityConfig) {
|
|
75
74
|
const isValidVerificationCode = (0, createIsValidVerificationCode_1.createIsValidVerificationCode)(prisma);
|
|
76
75
|
const exchangeCredentials = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -84,7 +83,7 @@ function createExchangeCredentials(prisma, identityConfig) {
|
|
|
84
83
|
message: "Invalid credentials"
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
|
-
if (verificationRequiredButNotProvided(identityConfig, user)) {
|
|
86
|
+
if ((0, verificationRequiredButNotProvided_1.verificationRequiredButNotProvided)(identityConfig, user)) {
|
|
88
87
|
return callback({
|
|
89
88
|
code: grpc.status.PERMISSION_DENIED,
|
|
90
89
|
message: "User contact information not verified"
|
|
@@ -67,6 +67,7 @@ const grpc = __importStar(require("@grpc/grpc-js"));
|
|
|
67
67
|
const createGetUserByEmail_1 = require("../utils/createGetUserByEmail");
|
|
68
68
|
const getGitHubUserWithOauth2Code_1 = require("../utils/getGitHubUserWithOauth2Code");
|
|
69
69
|
const exchangeTokens_1 = require("./exchangeTokens");
|
|
70
|
+
const verificationRequiredButNotProvided_1 = require("../utils/verificationRequiredButNotProvided");
|
|
70
71
|
const logger = (0, logger_1.getLogger)({ service: "identity", filePath: __filename });
|
|
71
72
|
function createExchangeOauth2Code(prisma, identityConfig) {
|
|
72
73
|
const exchangeOauth2Code = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -85,6 +86,12 @@ function createExchangeOauth2Code(prisma, identityConfig) {
|
|
|
85
86
|
message: "Invalid credentials"
|
|
86
87
|
});
|
|
87
88
|
}
|
|
89
|
+
if ((0, verificationRequiredButNotProvided_1.verificationRequiredButNotProvided)(identityConfig, user)) {
|
|
90
|
+
return callback({
|
|
91
|
+
code: grpc.status.PERMISSION_DENIED,
|
|
92
|
+
message: "User contact information not verified"
|
|
93
|
+
});
|
|
94
|
+
}
|
|
88
95
|
callback(null, yield (0, exchangeTokens_1.exchangeTokens)(prisma, identityConfig)(user.accessKeyId));
|
|
89
96
|
});
|
|
90
97
|
return (0, common_1.withErrorHandlingAndValidation)(exchangeOauth2Code, common_1.exchangeOauth2RequestSchema);
|
|
@@ -86,7 +86,7 @@ function createCreateUserWithOauth2Code(prisma, identityConfig) {
|
|
|
86
86
|
message: "Failed to get user data from GitHub"
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
const userFromDB = yield (0, createGetUserByEmail_1.createGetUserByEmail)(prisma)(userData
|
|
89
|
+
const userFromDB = yield (0, createGetUserByEmail_1.createGetUserByEmail)(prisma)(userData.email);
|
|
90
90
|
if (userFromDB) {
|
|
91
91
|
return callback({
|
|
92
92
|
code: grpc.status.ALREADY_EXISTS,
|
|
@@ -13,6 +13,9 @@ exports.createGetUserByEmail = createGetUserByEmail;
|
|
|
13
13
|
function createGetUserByEmail(prisma) {
|
|
14
14
|
return function getUserByEmail(email) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
if (!email) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
16
19
|
return yield prisma.user.findFirst({
|
|
17
20
|
where: {
|
|
18
21
|
email
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { IdentityConfig } from "../exchanges/types";
|
|
20
|
+
declare function verificationRequiredButNotProvided(identityConfig: IdentityConfig, user: {
|
|
21
|
+
emailVerified: boolean;
|
|
22
|
+
phoneNumberVerified: boolean;
|
|
23
|
+
}): boolean;
|
|
24
|
+
export { verificationRequiredButNotProvided };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verificationRequiredButNotProvided = verificationRequiredButNotProvided;
|
|
4
|
+
function verificationRequiredButNotProvided(identityConfig, user) {
|
|
5
|
+
return (identityConfig.contactVerificationRequired &&
|
|
6
|
+
(!user.emailVerified || !user.phoneNumberVerified));
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/identity",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.28",
|
|
4
4
|
"description": "Identity service for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/jsonwebtoken": "^9.0.6"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "2670941d018a5470efd4b835a3a31954585afc39"
|
|
52
52
|
}
|