mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 07:28:50 +00:00
Begin frontend for blinded indices
This commit is contained in:
@@ -4,6 +4,8 @@ import {
|
||||
Secret
|
||||
} from '../../models';
|
||||
import crypto from 'crypto';
|
||||
import { SecretService } from '../../services';
|
||||
|
||||
|
||||
// TODO: modularize argon2id
|
||||
import * as argon2 from 'argon2';
|
||||
@@ -50,30 +52,47 @@ export const createSecret = async (req: Request, res: Response) => {
|
||||
workspaceId,
|
||||
environment,
|
||||
value,
|
||||
type
|
||||
type,
|
||||
secretKeyCiphertext,
|
||||
secretKeyIV,
|
||||
secretKeyTag,
|
||||
secretValueCiphertext,
|
||||
secretValueIV,
|
||||
secretValueTag
|
||||
} = req.body;
|
||||
|
||||
// use workspace salt
|
||||
const randomBytes = crypto.randomBytes(16);
|
||||
const secretBlindIndex = await SecretService.createSecretBlindIndex({
|
||||
secretName,
|
||||
workspaceId: new Types.ObjectId(workspaceId)
|
||||
});
|
||||
|
||||
// generate blind index
|
||||
// TODO 1: abstract away into create blind index function
|
||||
// TODO 2: create a get blind index function
|
||||
const secretBlindIndex = (await argon2.hash(secretName, {
|
||||
type: argon2.argon2id,
|
||||
salt: randomBytes,
|
||||
saltLength: 16, // default 16 bytes
|
||||
memoryCost: 65536, // default pool of 64 MiB per thread.
|
||||
hashLength: 32,
|
||||
parallelism: 1,
|
||||
raw: true
|
||||
})).toString('base64');
|
||||
// // use workspace salt
|
||||
// const randomBytes = crypto.randomBytes(16);
|
||||
|
||||
// // generate blind index
|
||||
// // TODO 1: abstract away into create blind index function
|
||||
// // TODO 2: create a get blind index function
|
||||
// const secretBlindIndex = (await argon2.hash(secretName, {
|
||||
// type: argon2.argon2id,
|
||||
// salt: randomBytes,
|
||||
// saltLength: 16, // default 16 bytes
|
||||
// memoryCost: 65536, // default pool of 64 MiB per thread.
|
||||
// hashLength: 32,
|
||||
// parallelism: 1,
|
||||
// raw: true
|
||||
// })).toString('base64');
|
||||
|
||||
// const secret = await new Secret({
|
||||
// workspace: new Types.ObjectId(workspaceId),
|
||||
// environment,
|
||||
// type,
|
||||
// secretBlindIndex
|
||||
// secretBlindIndex,
|
||||
// secretKeyCiphertext,
|
||||
// secretKeyIV,
|
||||
// secretKeyTag,
|
||||
// secretValueCiphertext,
|
||||
// secretValueIV,
|
||||
// secretValueTag
|
||||
// }).save();
|
||||
|
||||
return res.status(200).send({
|
||||
|
||||
Reference in New Issue
Block a user