@fonoster/identity 0.8.0 → 0.8.4
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/db.js +2 -0
- package/dist/envs.d.ts +0 -1
- package/dist/envs.js +1 -17
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/createGetUserByWorkspaceAccessKeyId.d.ts +16 -0
- package/dist/utils/createGetUserByWorkspaceAccessKeyId.js +24 -0
- package/dist/utils/getUserByEmail.d.ts +1 -0
- package/dist/utils/getUserByEmail.js +1 -5
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/workspaces/inviteUserToWorkspace.js +1 -0
- package/dist/workspaces/resendWorkspaceMembershipInvitation.js +1 -0
- package/package.json +5 -5
package/dist/db.js
CHANGED
|
@@ -22,6 +22,8 @@ exports.prisma = void 0;
|
|
|
22
22
|
const identity_client_1 = require("@prisma/identity-client");
|
|
23
23
|
const prisma_field_encryption_1 = require("prisma-field-encryption");
|
|
24
24
|
const envs_1 = require("./envs");
|
|
25
|
+
const common_1 = require("@fonoster/common");
|
|
26
|
+
(0, common_1.assertEnvsAreSet)(["DATABASE_URL", "CLOAK_ENCRYPTION_KEY"]);
|
|
25
27
|
// Check the link for details on dmff:
|
|
26
28
|
// https://www.npmjs.com/package/prisma-field-encryption#custom-prisma-client-location
|
|
27
29
|
const prisma = new identity_client_1.PrismaClient().$extends((0, prisma_field_encryption_1.fieldEncryptionExtension)({
|
package/dist/envs.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare const CLOAK_ENCRYPTION_KEY: string;
|
|
|
2
2
|
export declare const IDENTITY_MFA_REQUIRED: boolean;
|
|
3
3
|
export declare const IDENTITY_OAUTH2_GITHUB_CLIENT_ID: string;
|
|
4
4
|
export declare const IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET: string;
|
|
5
|
-
export declare const IDENTITY_OAUTH2_GITHUB_ENABLED: boolean;
|
|
6
5
|
export declare const IDENTITY_USER_VERIFICATION_REQUIRED: boolean;
|
|
7
6
|
export declare const IDENTITY_WORKSPACE_INVITATION_URL: string;
|
|
8
7
|
export declare const IDENTITY_WORKSPACE_INVITE_EXPIRATION: string;
|
package/dist/envs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = exports.IDENTITY_WORKSPACE_INVITATION_URL = exports.IDENTITY_USER_VERIFICATION_REQUIRED = exports.
|
|
3
|
+
exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = exports.IDENTITY_WORKSPACE_INVITATION_URL = exports.IDENTITY_USER_VERIFICATION_REQUIRED = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = exports.IDENTITY_MFA_REQUIRED = exports.CLOAK_ENCRYPTION_KEY = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -19,27 +19,11 @@ exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = exports.IDENTITY_WORKSPACE_INVITA
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
const common_1 = require("@fonoster/common");
|
|
23
22
|
const e = process.env;
|
|
24
23
|
exports.CLOAK_ENCRYPTION_KEY = e.CLOAK_ENCRYPTION_KEY;
|
|
25
24
|
exports.IDENTITY_MFA_REQUIRED = e.IDENTITY_MFA_REQUIRED === "true";
|
|
26
25
|
exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = e.IDENTITY_OAUTH2_GITHUB_CLIENT_ID;
|
|
27
26
|
exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = e.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET;
|
|
28
|
-
exports.IDENTITY_OAUTH2_GITHUB_ENABLED = e.IDENTITY_OAUTH2_GITHUB_ENABLED === "true";
|
|
29
27
|
exports.IDENTITY_USER_VERIFICATION_REQUIRED = e.IDENTITY_USER_VERIFICATION_REQUIRED === "true";
|
|
30
28
|
exports.IDENTITY_WORKSPACE_INVITATION_URL = e.IDENTITY_WORKSPACE_INVITATION_URL;
|
|
31
29
|
exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = e.IDENTITY_WORKSPACE_INVITE_EXPIRATION || "1d";
|
|
32
|
-
(0, common_1.assertEnvsAreSet)(["CLOAK_ENCRYPTION_KEY", "IDENTITY_WORKSPACE_INVITATION_URL"]);
|
|
33
|
-
if (exports.IDENTITY_USER_VERIFICATION_REQUIRED) {
|
|
34
|
-
(0, common_1.assertEnvsAreSet)([
|
|
35
|
-
"TWILIO_ACCOUNT_SID",
|
|
36
|
-
"TWILIO_AUTH_TOKEN",
|
|
37
|
-
"TWILIO_PHONE_NUMBER"
|
|
38
|
-
]);
|
|
39
|
-
}
|
|
40
|
-
if (exports.IDENTITY_OAUTH2_GITHUB_ENABLED) {
|
|
41
|
-
(0, common_1.assertEnvsAreSet)([
|
|
42
|
-
"IDENTITY_OAUTH2_GITHUB_CLIENT_ID",
|
|
43
|
-
"IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET"
|
|
44
|
-
]);
|
|
45
|
-
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Prisma } from "../db";
|
|
2
|
+
declare function createGetUserByWorkspaceAccessKeyId(prisma: Prisma): (accessKeyId: string) => Promise<{
|
|
3
|
+
name: string;
|
|
4
|
+
ref: string;
|
|
5
|
+
accessKeyId: string;
|
|
6
|
+
createdAt: Date;
|
|
7
|
+
updatedAt: Date;
|
|
8
|
+
email: string;
|
|
9
|
+
emailVerified: boolean;
|
|
10
|
+
password: string;
|
|
11
|
+
phoneNumber: string | null;
|
|
12
|
+
phoneNumberVerified: boolean;
|
|
13
|
+
avatar: string | null;
|
|
14
|
+
extended: import("@prisma/identity-client/runtime/library").JsonValue | null;
|
|
15
|
+
}>;
|
|
16
|
+
export { createGetUserByWorkspaceAccessKeyId };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createGetUserByWorkspaceAccessKeyId = createGetUserByWorkspaceAccessKeyId;
|
|
13
|
+
function createGetUserByWorkspaceAccessKeyId(prisma) {
|
|
14
|
+
return (accessKeyId) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const workspace = yield prisma.workspace.findFirst({
|
|
16
|
+
where: { accessKeyId }
|
|
17
|
+
});
|
|
18
|
+
if (!workspace)
|
|
19
|
+
return null;
|
|
20
|
+
return prisma.user.findFirst({
|
|
21
|
+
where: { ref: workspace.ownerRef }
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -11,5 +11,6 @@ declare function getUserByEmail(prisma: Prisma): (email: string) => Promise<{
|
|
|
11
11
|
phoneNumber: string | null;
|
|
12
12
|
phoneNumberVerified: boolean;
|
|
13
13
|
avatar: string | null;
|
|
14
|
+
extended: import("@prisma/identity-client/runtime/library").JsonValue | null;
|
|
14
15
|
}>;
|
|
15
16
|
export { getUserByEmail };
|
|
@@ -12,14 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getUserByEmail = getUserByEmail;
|
|
13
13
|
function getUserByEmail(prisma) {
|
|
14
14
|
return (email) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
|
|
15
|
+
return yield prisma.user.findFirst({
|
|
16
16
|
where: {
|
|
17
17
|
email
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
if (!user) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return user;
|
|
24
20
|
});
|
|
25
21
|
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -34,6 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
*/
|
|
35
35
|
__exportStar(require("./createCallAccessToken"), exports);
|
|
36
36
|
__exportStar(require("./createSendEmail"), exports);
|
|
37
|
+
__exportStar(require("./createGetUserByWorkspaceAccessKeyId"), exports);
|
|
37
38
|
__exportStar(require("./decodeToken"), exports);
|
|
38
39
|
__exportStar(require("./generateAccessKeyId"), exports);
|
|
39
40
|
__exportStar(require("./getAccessKeyIdFromCall"), exports);
|
|
@@ -41,6 +41,7 @@ const createWorkspaceInviteToken_1 = require("../utils/createWorkspaceInviteToke
|
|
|
41
41
|
const getTokenFromCall_1 = require("../utils/getTokenFromCall");
|
|
42
42
|
const getUserRefFromToken_1 = require("../utils/getUserRefFromToken");
|
|
43
43
|
const logger = (0, logger_1.getLogger)({ service: "identity", filePath: __filename });
|
|
44
|
+
(0, common_1.assertEnvsAreSet)(["IDENTITY_WORKSPACE_INVITATION_URL"]);
|
|
44
45
|
const userIsMemberError = {
|
|
45
46
|
code: grpc_js_1.status.ALREADY_EXISTS,
|
|
46
47
|
message: "User is already a member of this workspace"
|
|
@@ -38,6 +38,7 @@ const createWorkspaceInviteToken_1 = require("../utils/createWorkspaceInviteToke
|
|
|
38
38
|
const getTokenFromCall_1 = require("../utils/getTokenFromCall");
|
|
39
39
|
const getUserRefFromToken_1 = require("../utils/getUserRefFromToken");
|
|
40
40
|
const logger = (0, logger_1.getLogger)({ service: "identity", filePath: __filename });
|
|
41
|
+
(0, common_1.assertEnvsAreSet)(["IDENTITY_WORKSPACE_INVITATION_URL"]);
|
|
41
42
|
function resendWorkspaceMembershipInvitation(prisma, identityConfig, sendInvite) {
|
|
42
43
|
const fn = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
43
44
|
const token = (0, getTokenFromCall_1.getTokenFromCall)(call);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/identity",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
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,9 +20,9 @@
|
|
|
20
20
|
"fonoster": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@fonoster/common": "^0.8.
|
|
24
|
-
"@fonoster/logger": "^0.8.
|
|
25
|
-
"@fonoster/types": "^0.8.
|
|
23
|
+
"@fonoster/common": "^0.8.4",
|
|
24
|
+
"@fonoster/logger": "^0.8.4",
|
|
25
|
+
"@fonoster/types": "^0.8.4",
|
|
26
26
|
"@grpc/grpc-js": "~1.10.6",
|
|
27
27
|
"@prisma/client": "^6.0.1",
|
|
28
28
|
"jsonwebtoken": "^9.0.2",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/jsonwebtoken": "^9.0.6"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "230bf0c9b793e5de49ffeb30ee1bd62226f55cba"
|
|
52
52
|
}
|