mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Revert seed
This commit is contained in:
@@ -1,14 +1,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
||||||
// @ts-nocheck
|
|
||||||
|
|
||||||
import { Knex } from "knex";
|
import { Knex } from "knex";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
import { generateUserSrpKeys } from "@app/lib/crypto/srp";
|
|
||||||
|
|
||||||
import { AuthMethod } from "../../services/auth/auth-type";
|
import { AuthMethod } from "../../services/auth/auth-type";
|
||||||
import { TableName } from "../schemas";
|
import { TableName } from "../schemas";
|
||||||
import { seedData1 } from "../seed-data";
|
import { generateUserSrpKeys, seedData1 } from "../seed-data";
|
||||||
|
|
||||||
export async function seed(knex: Knex): Promise<void> {
|
export async function seed(knex: Knex): Promise<void> {
|
||||||
// Deletes ALL existing entries
|
// Deletes ALL existing entries
|
||||||
@@ -25,7 +19,6 @@ export async function seed(knex: Knex): Promise<void> {
|
|||||||
id: seedData1.id,
|
id: seedData1.id,
|
||||||
email: seedData1.email,
|
email: seedData1.email,
|
||||||
superAdmin: true,
|
superAdmin: true,
|
||||||
ghost: false,
|
|
||||||
firstName: "test",
|
firstName: "test",
|
||||||
lastName: "",
|
lastName: "",
|
||||||
authMethods: [AuthMethod.EMAIL],
|
authMethods: [AuthMethod.EMAIL],
|
||||||
@@ -37,7 +30,7 @@ export async function seed(knex: Knex): Promise<void> {
|
|||||||
])
|
])
|
||||||
.returning("*");
|
.returning("*");
|
||||||
|
|
||||||
const encKeys = await generateUserSrpKeys(seedData1.email, seedData1.password);
|
const encKeys = await generateUserSrpKeys(seedData1.password);
|
||||||
// password: testInfisical@1
|
// password: testInfisical@1
|
||||||
await knex(TableName.UserEncryptionKey).insert([
|
await knex(TableName.UserEncryptionKey).insert([
|
||||||
{
|
{
|
||||||
@@ -67,9 +60,4 @@ export async function seed(knex: Knex): Promise<void> {
|
|||||||
refreshVersion: 1,
|
refreshVersion: 1,
|
||||||
lastUsed: new Date()
|
lastUsed: new Date()
|
||||||
});
|
});
|
||||||
|
|
||||||
seedData1.encryptionKeys = {
|
|
||||||
publicKey: encKeys.publicKey,
|
|
||||||
privateKey: encKeys.plainPrivateKey
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
||||||
// @ts-nocheck
|
|
||||||
|
|
||||||
import { Knex } from "knex";
|
import { Knex } from "knex";
|
||||||
|
|
||||||
import { OrgMembershipRole, OrgMembershipStatus, TableName } from "../schemas";
|
import { OrgMembershipRole, OrgMembershipStatus, TableName } from "../schemas";
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ export const DEFAULT_PROJECT_ENVS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export async function seed(knex: Knex): Promise<void> {
|
export async function seed(knex: Knex): Promise<void> {
|
||||||
initEnvConfig(await initLogger());
|
|
||||||
const appCfg = getConfig();
|
|
||||||
// Deletes ALL existing entries
|
// Deletes ALL existing entries
|
||||||
await knex(TableName.Project).del();
|
await knex(TableName.Project).del();
|
||||||
await knex(TableName.Environment).del();
|
await knex(TableName.Environment).del();
|
||||||
@@ -27,38 +25,14 @@ export async function seed(knex: Knex): Promise<void> {
|
|||||||
orgId: seedData1.organization.id,
|
orgId: seedData1.organization.id,
|
||||||
slug: "first-project",
|
slug: "first-project",
|
||||||
// @ts-expect-error exluded type id needs to be inserted here to keep it testable
|
// @ts-expect-error exluded type id needs to be inserted here to keep it testable
|
||||||
id: seedData1.project.id,
|
id: seedData1.project.id
|
||||||
version: "v1"
|
|
||||||
})
|
})
|
||||||
.returning("*");
|
.returning("*");
|
||||||
|
|
||||||
const blindIndex = createSecretBlindIndex(appCfg.ROOT_ENCRYPTION_KEY, appCfg.ENCRYPTION_KEY);
|
// await knex(TableName.ProjectKeys).insert({
|
||||||
|
// projectId: project.id,
|
||||||
await knex(TableName.SecretBlindIndex).insert({
|
// senderId: seedData1.id
|
||||||
projectId: project.id,
|
// });
|
||||||
algorithm: blindIndex.algorithm,
|
|
||||||
keyEncoding: blindIndex.keyEncoding,
|
|
||||||
saltIV: blindIndex.iv,
|
|
||||||
encryptedSaltCipherText: blindIndex.ciphertext,
|
|
||||||
saltTag: blindIndex.tag
|
|
||||||
});
|
|
||||||
|
|
||||||
const randomBytes = crypto.randomBytes(16).toString("hex"); // Project key
|
|
||||||
// const encKeys = await generateUserSrpKeys(seedData1.email, seedData1.password); // User keys
|
|
||||||
|
|
||||||
const { ciphertext: encryptedProjectKey, nonce: encryptedProjectKeyIv } = encryptAsymmetric(
|
|
||||||
randomBytes,
|
|
||||||
seedData1.encryptionKeys.publicKey,
|
|
||||||
seedData1.encryptionKeys.privateKey
|
|
||||||
);
|
|
||||||
|
|
||||||
await knex(TableName.ProjectKeys).insert({
|
|
||||||
projectId: project.id,
|
|
||||||
senderId: seedData1.id,
|
|
||||||
receiverId: seedData1.id,
|
|
||||||
encryptedKey: encryptedProjectKey,
|
|
||||||
nonce: encryptedProjectKeyIv
|
|
||||||
});
|
|
||||||
|
|
||||||
await knex(TableName.ProjectMembership).insert({
|
await knex(TableName.ProjectMembership).insert({
|
||||||
projectId: project.id,
|
projectId: project.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user