|
|
@ -1,6 +1,6 @@ |
|
|
|
import process from 'process'; |
|
|
|
import process from 'process'; |
|
|
|
import Noco from '~/Noco'; |
|
|
|
import Noco from '~/Noco'; |
|
|
|
import { MetaTable } from '~/utils/globals'; |
|
|
|
import { MetaTable, RootScopes } from '~/utils/globals'; |
|
|
|
import { encryptPropIfRequired } from '~/utils'; |
|
|
|
import { encryptPropIfRequired } from '~/utils'; |
|
|
|
|
|
|
|
|
|
|
|
export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) { |
|
|
|
export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) { |
|
|
@ -28,13 +28,11 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) { |
|
|
|
qb.where('is_local', false).orWhereNull('is_local'); |
|
|
|
qb.where('is_local', false).orWhereNull('is_local'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const isAtleastOneSourceEncrypted = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const source of sources) { |
|
|
|
for (const source of sources) { |
|
|
|
// encrypt the data source
|
|
|
|
// encrypt the data source
|
|
|
|
await ncMeta.metaUpdate( |
|
|
|
await ncMeta.metaUpdate( |
|
|
|
source.fk_workspace_id, |
|
|
|
source.fk_workspace_id, |
|
|
|
source.id, |
|
|
|
source.base_id, |
|
|
|
MetaTable.SOURCES, |
|
|
|
MetaTable.SOURCES, |
|
|
|
{ |
|
|
|
{ |
|
|
|
config: encryptPropIfRequired({ |
|
|
|
config: encryptPropIfRequired({ |
|
|
@ -43,6 +41,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) { |
|
|
|
}), |
|
|
|
}), |
|
|
|
is_encrypted: true, |
|
|
|
is_encrypted: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
source.id, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -55,8 +54,8 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) { |
|
|
|
for (const integration of integrations) { |
|
|
|
for (const integration of integrations) { |
|
|
|
// encrypt the data source
|
|
|
|
// encrypt the data source
|
|
|
|
await ncMeta.metaUpdate( |
|
|
|
await ncMeta.metaUpdate( |
|
|
|
integration.fk_workspace_id, |
|
|
|
RootScopes.WORKSPACE, |
|
|
|
integration.id, |
|
|
|
RootScopes.WORKSPACE, |
|
|
|
MetaTable.INTEGRATIONS, |
|
|
|
MetaTable.INTEGRATIONS, |
|
|
|
{ |
|
|
|
{ |
|
|
|
config: encryptPropIfRequired({ |
|
|
|
config: encryptPropIfRequired({ |
|
|
@ -65,9 +64,9 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) { |
|
|
|
}), |
|
|
|
}), |
|
|
|
is_encrypted: true, |
|
|
|
is_encrypted: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
integration.id, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await ncMeta.commit(); |
|
|
|
await ncMeta.commit(); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
await ncMeta.rollback(); |
|
|
|
await ncMeta.rollback(); |
|
|
|