diff --git a/source/core/VaultManager.ts b/source/core/VaultManager.ts index b6593865..9eb6f851 100644 --- a/source/core/VaultManager.ts +++ b/source/core/VaultManager.ts @@ -165,6 +165,7 @@ export class VaultManager extends EventEmitter { /** * Fetch all currently available Live Snapshots of vaults * @returns An array of snapshot objects + * @deprecated Will be removed in next major - insecure */ getLiveSnapshots(): Array { return this.unlockedSources.map((source) => source.getLiveSnapshot()); @@ -353,6 +354,7 @@ export class VaultManager extends EventEmitter { /** * Restore all sources from snapshots that were taken previously * @param snapshots An array of snapshot objects + * @deprecated Will be removed in next major - insecure */ async restoreLiveSnapshots(snapshots: Array) { await Promise.all( diff --git a/source/core/VaultSource.ts b/source/core/VaultSource.ts index 12167367..15d21ed9 100644 --- a/source/core/VaultSource.ts +++ b/source/core/VaultSource.ts @@ -3,7 +3,8 @@ import { ChannelQueue } from "@buttercup/channel-queue"; import { Layerr } from "layerr"; import { Vault } from "./Vault.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials, setCredentials } from "../credentials/channel.js"; +import { getCredentials, setCredentials } from "../credentials/memory/credentials.js"; +import { getMasterPassword, setMasterPassword } from "../credentials/memory/password.js"; import { getUniqueID } from "../tools/encoding.js"; import { getSourceOfflineArchive, @@ -17,8 +18,8 @@ import { TextDatasource } from "../datasources/TextDatasource.js"; import { VaultManager } from "./VaultManager.js"; import { convertFormatAVault } from "../io/formatB/conversion.js"; import { VaultFormatB } from "../index.common.js"; -import { VaultFormatID, VaultLiveSnapshot, VaultSourceID, VaultSourceStatus } from "../types.js"; import { getFormatForID } from "../io/formatRouter.js"; +import { VaultFormatID, VaultLiveSnapshot, VaultSourceID, VaultSourceStatus } from "../types.js"; interface StateChangeEnqueuedFunction { (): void | Promise; @@ -272,8 +273,8 @@ export class VaultSource extends EventEmitter { await this.unlock(Credentials.fromPassword(oldPassword)); } else { // Unlocked, so check password.. - const credentials = getCredentials((this._credentials).id); - if (credentials.masterPassword !== oldPassword) { + const masterPassword = getMasterPassword((this._credentials).id); + if (masterPassword !== oldPassword) { throw new Error("Old password does not match current unlocked instance value"); } // ..and then update @@ -296,8 +297,7 @@ export class VaultSource extends EventEmitter { this._credentials as Credentials, oldPassword ); - const newCreds = getCredentials(newCredentials.id); - newCreds.masterPassword = newPassword; + setMasterPassword(newCredentials.id, newPassword); await this._updateVaultCredentials(newCredentials); // Re-lock if it was locked earlier if (wasLocked) { @@ -385,19 +385,23 @@ export class VaultSource extends EventEmitter { /** * Get a live snapshot of the current unlocked state * @returns A snapshot object + * @deprecated Will be removed in next major - insecure */ getLiveSnapshot(): VaultLiveSnapshot { if (this.status !== VaultSourceStatus.Unlocked) { throw new Layerr("Not possible to fetch live snapshot: Vault is not unlocked"); } - const credentials = getCredentials((this._credentials as Credentials).id); + const credentialsID = (this._credentials as Credentials).id; + const credentials = getCredentials(credentialsID); if (!credentials) { throw new Layerr("Failed fetching live snapshot: Invalid credentials data"); } + const masterPassword = getMasterPassword(credentialsID); return { credentials, formatID: this.vault._format.getFormat().getFormatID(), formatSource: this.vault._format.source, + masterPassword, sourceID: this.id, version: "1a" }; @@ -533,6 +537,7 @@ export class VaultSource extends EventEmitter { /** * Restore unlocked state from a live snapshot * @param snapshot The snapshot taken previously + * @deprecated Will be removed in next major - insecure */ async restoreFromLiveSnapshot(snapshot: VaultLiveSnapshot): Promise { if (this.status !== VaultSourceStatus.Locked) { @@ -546,12 +551,12 @@ export class VaultSource extends EventEmitter { // Setup credentials and datasource const credentials = (this._credentials = new Credentials( snapshot.credentials.data, - snapshot.credentials.masterPassword + snapshot.masterPassword )); setCredentials(credentials.id, snapshot.credentials); // Initialise datasource const datasource = (this._datasource = credentialsToDatasource( - Credentials.fromCredentials(credentials, snapshot.credentials.masterPassword) + Credentials.fromCredentials(credentials, snapshot.masterPassword) )); datasource.sourceID = this.id; // Setup vault @@ -650,7 +655,7 @@ export class VaultSource extends EventEmitter { `Failed unlocking source: Source in invalid state (${this.status}): ${this.id}` ); } - const { masterPassword } = getCredentials(vaultCredentials.id); + const masterPassword = getMasterPassword(vaultCredentials.id); const originalCredentials = this._credentials; this._status = VaultSource.STATUS_PENDING; await this._enqueueStateChange(async () => { @@ -813,7 +818,7 @@ export class VaultSource extends EventEmitter { `Failed updating source credentials: Source is not unlocked: ${this.id}` ); } - const { masterPassword } = getCredentials((this._credentials).id); + const masterPassword = getMasterPassword((this._credentials).id); this._credentials = Credentials.fromCredentials( this._datasource.credentials, masterPassword diff --git a/source/credentials/Credentials.ts b/source/credentials/Credentials.ts index 02910446..165ae385 100644 --- a/source/credentials/Credentials.ts +++ b/source/credentials/Credentials.ts @@ -1,6 +1,7 @@ import { generateUUID } from "../tools/uuid.js"; -import { credentialsAllowsPurpose, getCredentials, setCredentials } from "./channel.js"; +import { credentialsAllowsPurpose, getCredentials, setCredentials } from "./memory/credentials.js"; import { getSharedAppEnv } from "../env/appEnv.js"; +import { getMasterPassword, setMasterPassword } from "./memory/password.js"; import { CredentialsData, CredentialsPayload, DatasourceConfiguration } from "../types.js"; /** @@ -85,7 +86,8 @@ export class Credentials { throw new Error("Master password is required for credentials cloning"); } const credentialsData = getCredentials(credentials.id); - if (credentialsData.masterPassword !== masterPassword) { + const credentialsPassword = getMasterPassword(credentials.id); + if (credentialsPassword !== masterPassword) { throw new Error("Master password does not match that of the credentials to be cloned"); } const newData = JSON.parse(JSON.stringify(credentialsData.data)); @@ -134,29 +136,27 @@ export class Credentials { * @param masterPassword The password for decryption * @returns A promise that resolves with the new instance */ - static fromSecureString(content: string, masterPassword: string): Promise { + static async fromSecureString(content: string, masterPassword: string): Promise { const decrypt = getSharedAppEnv().getProperty("crypto/v1/decryptText"); - return decrypt(unsignEncryptedContent(content), masterPassword) - .then((decryptedContent: string) => JSON.parse(decryptedContent)) - .then((credentialsData: any) => { - // Handle compatibility updates for legacy credentials - if (credentialsData.datasource) { - if (typeof credentialsData.datasource === "string") { - credentialsData.datasource = JSON.parse(credentialsData.datasource); - } - // Move username and password INTO the datasource config, as - // they relate to the remote connection/source - if (credentialsData.username) { - credentialsData.datasource.username = credentialsData.username; - delete credentialsData.username; - } - if (credentialsData.password) { - credentialsData.datasource.password = credentialsData.password; - delete credentialsData.password; - } - } - return new Credentials(credentialsData, masterPassword); - }); + const decryptedContent = await decrypt(unsignEncryptedContent(content), masterPassword); + const credentialsData = JSON.parse(decryptedContent); + // Handle compatibility updates for legacy credentials + if (credentialsData.datasource) { + if (typeof credentialsData.datasource === "string") { + credentialsData.datasource = JSON.parse(credentialsData.datasource); + } + // Move username and password INTO the datasource config, as + // they relate to the remote connection/source + if (credentialsData.username) { + credentialsData.datasource.username = credentialsData.username; + delete credentialsData.username; + } + if (credentialsData.password) { + credentialsData.datasource.password = credentialsData.password; + delete credentialsData.password; + } + } + return new Credentials(credentialsData, masterPassword); } /** @@ -190,10 +190,10 @@ export class Credentials { }); setCredentials(id, { data: obj, - masterPassword, purposes: Credentials.allPurposes(), open: false }); + setMasterPassword(id, masterPassword); } /** @@ -279,7 +279,8 @@ export class Credentials { throw new Error("Credential purposes don't allow for secure exports"); } const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText"); - const { data, masterPassword } = getCredentials(this.id); + const { data } = getCredentials(this.id); + const masterPassword = getMasterPassword(this.id); if (typeof masterPassword !== "string") { throw new Error( "Cannot convert Credentials to string: master password was not set or is invalid" diff --git a/source/credentials/channel.ts b/source/credentials/memory/credentials.ts similarity index 80% rename from source/credentials/channel.ts rename to source/credentials/memory/credentials.ts index 5b1fd98a..37cbdfaf 100644 --- a/source/credentials/channel.ts +++ b/source/credentials/memory/credentials.ts @@ -1,6 +1,6 @@ -import { CredentialsPayload } from "../types.js"; +import { CredentialsPayload } from "../../types.js"; -const __store = {}; +const __store: Record = {}; export function credentialsAllowsPurpose(id: string, purpose: string): boolean { const { purposes } = getCredentials(id); diff --git a/source/credentials/memory/password.ts b/source/credentials/memory/password.ts new file mode 100644 index 00000000..7c4ae483 --- /dev/null +++ b/source/credentials/memory/password.ts @@ -0,0 +1,14 @@ +const __store: Record = {}; + +export function getMasterPassword(id: string): string | null { + return __store[id] || null; +} + +export function removeMasterPassword(id: string) { + __store[id] = null; + delete __store[id]; +} + +export function setMasterPassword(id: string, value: string) { + __store[id] = value; +} diff --git a/source/datasources/DropboxDatasource.ts b/source/datasources/DropboxDatasource.ts index 9b97cfd6..8ef0185f 100644 --- a/source/datasources/DropboxDatasource.ts +++ b/source/datasources/DropboxDatasource.ts @@ -1,7 +1,7 @@ import { TextDatasource } from "./TextDatasource.js"; import { fireInstantiationHandlers, registerDatasource } from "./register.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; import { getSharedAppEnv } from "../env/appEnv.js"; import { DatasourceConfigurationDropbox, diff --git a/source/datasources/FileDatasource.ts b/source/datasources/FileDatasource.ts index aa0f9b59..bde54d95 100644 --- a/source/datasources/FileDatasource.ts +++ b/source/datasources/FileDatasource.ts @@ -4,7 +4,7 @@ import pify from "pify"; import { TextDatasource } from "./TextDatasource.js"; import { fireInstantiationHandlers, registerDatasource } from "./register.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; import { ATTACHMENT_EXT } from "../tools/attachments.js"; import { AttachmentDetails, diff --git a/source/datasources/GoogleDriveDatasource.ts b/source/datasources/GoogleDriveDatasource.ts index d1fa13d8..3758bbf1 100644 --- a/source/datasources/GoogleDriveDatasource.ts +++ b/source/datasources/GoogleDriveDatasource.ts @@ -4,8 +4,8 @@ import DatasourceAuthManager from "./DatasourceAuthManager.js"; import { TextDatasource } from "./TextDatasource.js"; import { fireInstantiationHandlers, registerDatasource } from "./register.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials } from "../credentials/channel.js"; -import { DatasourceConfigurationGoogleDrive } from "../types.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; +import { DatasourceConfigurationGoogleDrive, DatasourceLoadedData, History } from "../types.js"; const DATASOURCE_TYPE = "googledrive"; @@ -23,7 +23,7 @@ export default class GoogleDriveDatasource extends TextDatasource { /** * Datasource for Google Drive connections - * @param {Credentials} credentials The credentials instance with which to + * @param credentials The credentials instance with which to * configure the datasource with */ constructor(credentials: Credentials) { @@ -57,11 +57,11 @@ export default class GoogleDriveDatasource extends TextDatasource { /** * Load an archive from the datasource - * @param {Credentials} credentials The credentials for decryption - * @returns {Promise.} A promise that resolves archive history + * @param credentials The credentials for decryption + * @returns A promise that resolves archive history * @memberof GoogleDriveDatasource */ - load(credentials, hasAuthed = false) { + load(credentials: Credentials, hasAuthed: boolean = false): Promise { if (this.hasContent) { return super.load(credentials); } @@ -89,12 +89,12 @@ export default class GoogleDriveDatasource extends TextDatasource { /** * Save an archive using the datasource - * @param {Array.} history The archive history to save - * @param {Credentials} credentials The credentials to save with - * @returns {Promise} A promise that resolves when saving has completed + * @param history The archive history to save + * @param credentials The credentials to save with + * @returns A promise that resolves when saving has completed * @memberof GoogleDriveDatasource */ - save(history, credentials, hasAuthed = false) { + save(history: History, credentials: Credentials, hasAuthed: boolean = false) { return super .save(history, credentials) .then((encryptedContent) => this.client.putFileContents(encryptedContent, this.fileID)) @@ -116,7 +116,7 @@ export default class GoogleDriveDatasource extends TextDatasource { /** * Whether or not the datasource supports bypassing remote fetch operations - * @returns {Boolean} True if content can be set to bypass fetch operations, + * @returns True if content can be set to bypass fetch operations, * false otherwise * @memberof GoogleDriveDatasource */ diff --git a/source/datasources/MemoryDatasource.ts b/source/datasources/MemoryDatasource.ts index eca4e874..d4476669 100644 --- a/source/datasources/MemoryDatasource.ts +++ b/source/datasources/MemoryDatasource.ts @@ -1,7 +1,7 @@ import { TextDatasource } from "./TextDatasource.js"; import { fireInstantiationHandlers, registerDatasource } from "./register.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; import { AttachmentDetails, BufferLike, diff --git a/source/datasources/TextDatasource.ts b/source/datasources/TextDatasource.ts index b92d4a4b..d4e8088a 100644 --- a/source/datasources/TextDatasource.ts +++ b/source/datasources/TextDatasource.ts @@ -1,7 +1,7 @@ import EventEmitter from "eventemitter3"; import hash from "hash.js"; import { Credentials } from "../credentials/Credentials.js"; -import { credentialsAllowsPurpose, getCredentials } from "../credentials/channel.js"; +import { credentialsAllowsPurpose, getCredentials } from "../credentials/memory/credentials.js"; import { detectFormat, getFormatForID } from "../io/formatRouter.js"; import { fireInstantiationHandlers, registerDatasource } from "./register.js"; import { diff --git a/source/datasources/WebDAVDatasource.ts b/source/datasources/WebDAVDatasource.ts index bfaf71b7..471aec24 100644 --- a/source/datasources/WebDAVDatasource.ts +++ b/source/datasources/WebDAVDatasource.ts @@ -4,7 +4,7 @@ import { TextDatasource } from "./TextDatasource.js"; import { fireInstantiationHandlers, registerDatasource } from "./register.js"; import { getSharedAppEnv } from "../env/appEnv.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; import { ATTACHMENT_EXT } from "../tools/attachments.js"; import { AttachmentDetails, diff --git a/source/datasources/register.ts b/source/datasources/register.ts index 342992ba..90a2fa6b 100644 --- a/source/datasources/register.ts +++ b/source/datasources/register.ts @@ -1,4 +1,5 @@ -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; +import { getMasterPassword } from "../credentials/memory/password.js"; import { Credentials } from "../credentials/Credentials.js"; import { TextDatasource } from "./TextDatasource.js"; @@ -61,9 +62,9 @@ export function prepareDatasourceCredentials( typeOverride: string = null ): Credentials { const { - data: { datasource }, - masterPassword + data: { datasource } } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); const datasourceType = typeOverride || datasource.type || ""; const { open = false } = __datasourceFlags[datasourceType] || {}; if (!open) { diff --git a/source/io/VaultFormatA.ts b/source/io/VaultFormatA.ts index 6a4dcf67..be12ea67 100644 --- a/source/io/VaultFormatA.ts +++ b/source/io/VaultFormatA.ts @@ -43,7 +43,7 @@ import VaultComparator from "./formatA/VaultComparator.js"; import { getSharedAppEnv } from "../env/appEnv.js"; import { decodeStringValue, isEncoded } from "../tools/encoding.js"; import { generateUUID } from "../tools/uuid.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getMasterPassword } from "../credentials/memory/password.js"; import { historyArrayToString, historyStringToArray } from "./common.js"; import { smartStripRemovedAssets } from "./formatA/merge.js"; import { @@ -99,7 +99,7 @@ export class VaultFormatA extends VaultFormat { static async encodeRaw(rawContent: History, credentials: Credentials): Promise { const compress = getSharedAppEnv().getProperty("compression/v1/compressText"); const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText"); - const { masterPassword } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); return Promise.resolve() .then(() => historyArrayToString(rawContent)) .then((history) => compress(history)) @@ -152,7 +152,7 @@ export class VaultFormatA extends VaultFormat { static parseEncrypted(encryptedContent: string, credentials: Credentials): Promise { const decompress = getSharedAppEnv().getProperty("compression/v1/decompressText"); const decrypt = getSharedAppEnv().getProperty("crypto/v1/decryptText"); - const { masterPassword } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); return Promise.resolve() .then(() => { if (!hasValidSignature(encryptedContent)) { diff --git a/source/io/VaultFormatB.ts b/source/io/VaultFormatB.ts index 65c99a19..81168d50 100644 --- a/source/io/VaultFormatB.ts +++ b/source/io/VaultFormatB.ts @@ -2,7 +2,7 @@ import { ORPHANS_GROUP_TITLE, VaultFormat } from "./VaultFormat.js"; import { Vault } from "../core/Vault.js"; import { generateUUID } from "../tools/uuid.js"; import { getSharedAppEnv } from "../env/appEnv.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getMasterPassword } from "../credentials/memory/password.js"; import { Credentials } from "../credentials/Credentials.js"; import { historyArrayToString, historyStringToArray } from "./common.js"; import { @@ -51,7 +51,7 @@ export class VaultFormatB extends VaultFormat { static encodeRaw(rawContent: History, credentials: Credentials): Promise { const compress = getSharedAppEnv().getProperty("compression/v2/compressText"); const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText"); - const { masterPassword } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); return Promise.resolve() .then(() => historyArrayToString(rawContent)) .then((history) => compress(history)) @@ -78,7 +78,7 @@ export class VaultFormatB extends VaultFormat { static parseEncrypted(encryptedContent: string, credentials: Credentials): Promise { const decompress = getSharedAppEnv().getProperty("compression/v2/decompressText"); const decrypt = getSharedAppEnv().getProperty("crypto/v1/decryptText"); - const { masterPassword } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); return Promise.resolve() .then(() => { if (!hasValidSignature(encryptedContent)) { diff --git a/source/tools/attachments.ts b/source/tools/attachments.ts index 54a7b2ae..7fafc991 100644 --- a/source/tools/attachments.ts +++ b/source/tools/attachments.ts @@ -1,18 +1,18 @@ import { getSharedAppEnv } from "../env/appEnv.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getMasterPassword } from "../credentials/memory/password.js"; import { Credentials } from "../credentials/Credentials.js"; import { BufferLike } from "../types.js"; export const ATTACHMENT_EXT = "bcatt"; export function decryptAttachment(buff: BufferLike, credentials: Credentials): Promise { - const { masterPassword } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); const decrypt = getSharedAppEnv().getProperty("crypto/v2/decryptBuffer"); return decrypt(buff, masterPassword); } export function encryptAttachment(buff: BufferLike, credentials: Credentials): Promise { - const { masterPassword } = getCredentials(credentials.id); + const masterPassword = getMasterPassword(credentials.id); const encrypt = getSharedAppEnv().getProperty("crypto/v2/encryptBuffer"); return encrypt(buff, masterPassword); } diff --git a/source/types.ts b/source/types.ts index f59a0c83..8f83c8d2 100644 --- a/source/types.ts +++ b/source/types.ts @@ -17,7 +17,6 @@ export interface CredentialsData { export interface CredentialsPayload { data: CredentialsData; - masterPassword: string | null; purposes: Array; open: boolean; } @@ -262,6 +261,7 @@ export interface VaultLiveSnapshot { credentials: CredentialsPayload; formatID: VaultFormatID; formatSource: FormatAVault | FormatBVault; + masterPassword: string; sourceID: VaultSourceID; version: "1a"; } diff --git a/source/web/LocalFileDatasource.ts b/source/web/LocalFileDatasource.ts index 3d0dfe51..b0ee5213 100644 --- a/source/web/LocalFileDatasource.ts +++ b/source/web/LocalFileDatasource.ts @@ -1,6 +1,6 @@ import { fireInstantiationHandlers, registerDatasource } from "../datasources/register.js"; import { TextDatasource } from "../datasources/TextDatasource.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; import { buildClient } from "./localFileClient.js"; import { Credentials } from "../credentials/Credentials.js"; import { diff --git a/source/web/LocalStorageDatasource.ts b/source/web/LocalStorageDatasource.ts index b134a488..fb1f1bf8 100644 --- a/source/web/LocalStorageDatasource.ts +++ b/source/web/LocalStorageDatasource.ts @@ -1,7 +1,7 @@ import { TextDatasource } from "../datasources/TextDatasource.js"; import { fireInstantiationHandlers, registerDatasource } from "../datasources/register.js"; import { Credentials } from "../credentials/Credentials.js"; -import { getCredentials } from "../credentials/channel.js"; +import { getCredentials } from "../credentials/memory/credentials.js"; import LocalStorageInterface from "./LocalStorageInterface.js"; import { CredentialsPayload, diff --git a/test/integration/core/VaultSource.spec.js b/test/integration/core/VaultSource.spec.js index 5c8cf5d8..3c74284b 100644 --- a/test/integration/core/VaultSource.spec.js +++ b/test/integration/core/VaultSource.spec.js @@ -93,8 +93,8 @@ describe("VaultSource", function () { it("can collect relevant data", function () { const snapshot = this.vaultSource.getLiveSnapshot(); expect(snapshot) - .to.have.nested.property("credentials.masterPassword") - .that.is.a("string"); + .to.have.nested.property("credentials.data") + .that.is.an("object"); expect(snapshot).to.have.property("formatID", Format.getFormatID()); expect(snapshot).to.have.property("version", "1a"); }); diff --git a/test/integration/openCredentials.spec.js b/test/integration/openCredentials.spec.js index ff37b52a..632c2bc2 100644 --- a/test/integration/openCredentials.spec.js +++ b/test/integration/openCredentials.spec.js @@ -67,14 +67,20 @@ describe("VaultSource with custom datasource", function () { it("provides open credentials on unlock", function () { const { _datasource: datasource } = this.vaultSourceOpen; - expect(datasource.initData).to.have.property("masterPassword", "test"); + expect(datasource.initData).to.have.nested.property( + "data.datasource.type", + this.datasourceTypeOpen + ); expect(datasource.initData).to.have.property("open", true); }); it("provides open credentials on load", async function () { await this.vaultSourceOpen.localDiffersFromRemote(); const { _datasource: datasource } = this.vaultSourceOpen; - expect(datasource.loadData).to.have.property("masterPassword", "test"); + expect(datasource.loadData).to.have.nested.property( + "data.datasource.type", + this.datasourceTypeOpen + ); expect(datasource.loadData).to.have.property("open", true); }); diff --git a/test/unit/datasources/GoogleDriveDatasource.spec.js b/test/unit/datasources/GoogleDriveDatasource.spec.js index a5001d12..0d270504 100644 --- a/test/unit/datasources/GoogleDriveDatasource.spec.js +++ b/test/unit/datasources/GoogleDriveDatasource.spec.js @@ -1,6 +1,6 @@ import { expect } from "chai"; import { Credentials, GoogleDriveDatasource } from "../../../dist/node/index.js"; -import { getCredentials } from "../../../dist/node/credentials/channel.js"; +import { getCredentials } from "../../../dist/node/credentials/memory/credentials.js"; describe("datasources/GoogleDriveDatasource", function () { beforeEach(function () {