From 7fc919bec5b45b3281e252704a90546d8b7c94e3 Mon Sep 17 00:00:00 2001 From: Hoseong Lee Date: Wed, 27 May 2026 16:34:08 -0500 Subject: [PATCH] Ingest the securityScoreData, securitData, and breachWatchRecords from the keeperDriveData Updated the getCounts to count the data in the keeperDriveData --- keeperapi/src/vault.ts | 50 ++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/keeperapi/src/vault.ts b/keeperapi/src/vault.ts index 6545ffe7..81ac2bc1 100644 --- a/keeperapi/src/vault.ts +++ b/keeperapi/src/vault.ts @@ -89,7 +89,9 @@ type MappedCounts = { [Property in keyof Type]: number } -type SyncResponseCounts = MappedCounts +type SyncResponseCounts = Partial< + MappedCounts & Vault.IKeeperDriveData> +> export type SyncResult = { started: Date @@ -986,7 +988,8 @@ const processMetadata = async (recordMetaData: IRecordMetaData[], storage: Vault await platform.unwrapKeys(recordKeys, storage) } -const processBreachWatchRecords = async (bwRecords: IBreachWatchRecord[], storage: VaultStorage) => { +const processBreachWatchRecords = async (storage: VaultStorage, bwRecords?: IBreachWatchRecord[] | null) => { + if (!bwRecords) return for (const bwRecord of bwRecords as NN[]) { if (!bwRecord.recordUid) continue @@ -1014,7 +1017,11 @@ const processBreachWatchRecords = async (bwRecords: IBreachWatchRecord[], storag } } -const processBreachWatchSecurityData = async (securityData: IBreachWatchSecurityData[], storage: VaultStorage) => { +const processBreachWatchSecurityData = async ( + storage: VaultStorage, + securityData?: IBreachWatchSecurityData[] | null +) => { + if (!securityData) return for (const bwSecurityData of securityData as NN[]) { const uid = webSafe64FromBytes(bwSecurityData.recordUid) @@ -1030,7 +1037,11 @@ const processBreachWatchSecurityData = async (securityData: IBreachWatchSecurity } } -const processSecurityScoreData = async (securityScoreDataList: Vault.ISecurityScoreData[], storage: VaultStorage) => { +const processSecurityScoreData = async ( + storage: VaultStorage, + securityScoreDataList?: Vault.ISecurityScoreData[] | null +) => { + if (!securityScoreDataList) return for (const securityScoreData of securityScoreDataList) { if (!securityScoreData.recordUid || typeof securityScoreData.revision !== 'number') continue @@ -1467,15 +1478,20 @@ const logProtobuf = (data: any, format: SyncLogFormat, seqNo: number, counts: an } const getCounts = (obj: Vault.ISyncDownResponse): SyncResponseCounts => { - const results = {} - for (const prop in obj) { - if (['continuationToken', 'constructor'].includes(prop)) { - continue - } - if (obj[prop]?.length) { - results[prop] = obj[prop].length + const results: Record = {} + const collect = (source: any) => { + if (!source) return + for (const prop in source) { + if (['continuationToken', 'constructor', 'keeperDriveData'].includes(prop)) { + continue + } + if (source[prop]?.length) { + results[prop] = (results[prop] || 0) + source[prop].length + } } } + collect(obj) + collect(obj.keeperDriveData) return results } @@ -1612,11 +1628,11 @@ export const syncDown = async (options: SyncDownOptions): Promise => await processProfilePic(resp.profilePic, storage) - await processBreachWatchRecords(resp.breachWatchRecords, storage) + await processBreachWatchRecords(storage, resp.breachWatchRecords) - await processBreachWatchSecurityData(resp.breachWatchSecurityData, storage) + await processBreachWatchSecurityData(storage, resp.breachWatchSecurityData) - await processSecurityScoreData(resp.securityScoreData, storage) + await processSecurityScoreData(storage, resp.securityScoreData) await processKdFolderAccesses(storage, keeperDriveData.folderAccesses) @@ -1638,6 +1654,12 @@ export const syncDown = async (options: SyncDownOptions): Promise => await processKdRecordSharingStates(storage, keeperDriveData.recordSharingStates) + await processBreachWatchRecords(storage, keeperDriveData.breachWatchRecords) + + await processBreachWatchSecurityData(storage, keeperDriveData.breachWatchSecurityData) + + await processSecurityScoreData(storage, keeperDriveData.securityScoreData) + await storage.addDependencies(dependencies) const removedDependencies = {}