mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 02:29:35 +00:00
More gohst user
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import crypto from "crypto";
|
||||
|
||||
import { ProjectMembershipRole, TProjectKeys } from "@app/db/schemas";
|
||||
|
||||
import { decryptAsymmetric, encryptAsymmetric } from "../crypto";
|
||||
@@ -37,3 +39,22 @@ export const createWsMembers = ({ members, decryptKey, userPrivateKey }: AddUser
|
||||
|
||||
return newWsMembers;
|
||||
};
|
||||
|
||||
type TCreateWorkspaceKeyDTO = {
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
};
|
||||
|
||||
export const createWorkspaceKey = ({ publicKey, privateKey }: TCreateWorkspaceKeyDTO) => {
|
||||
// 3. Create a random key that we'll use as the project key.
|
||||
const randomBytes = crypto.randomBytes(16).toString("hex");
|
||||
|
||||
// 4. Encrypt the project key with the users key pair.
|
||||
const { ciphertext: encryptedProjectKey, nonce: encryptedProjectKeyIv } = encryptAsymmetric(
|
||||
randomBytes,
|
||||
publicKey,
|
||||
privateKey
|
||||
);
|
||||
|
||||
return { key: encryptedProjectKey, iv: encryptedProjectKeyIv };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user