Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions keeperapi/src/syncDown/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ export type DKdRecordSharingState = {
isIndirectlyShared?: boolean
isShared?: boolean
}

export type DKdRecordLink = {
kind: 'keeper_drive_record_link'
parentRecordUid: string
childRecordUid: string
}
26 changes: 26 additions & 0 deletions keeperapi/src/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
DKdFolderAccess,
DKdFolderSharingState,
mapTeamKeyType,
DKdRecordLink,
} from './syncDown'

export type VaultStorage = KeyStorage & {
Expand Down Expand Up @@ -71,6 +72,7 @@ export type VaultStorageData =
| DKdFolder
| DKdFolderSharingState
| DKdFolderAccess
| DKdRecordLink

export type VaultStorageKind = VaultStorageData['kind']

Expand Down Expand Up @@ -1041,6 +1043,28 @@ const processSecurityScoreData = async (securityScoreDataList: Vault.ISecuritySc

// Keeper Drive Processors Start

const processKdRecordLinks = async (storage: VaultStorage, keeperDriveRecordLinks?: Vault.IRecordLink[] | null) => {
if (!keeperDriveRecordLinks) return
for (const link of keeperDriveRecordLinks) {
if (!link.childRecordUid || !link.parentRecordUid || !link.recordKey) continue
const childRecordUid = webSafe64FromBytes(link.childRecordUid)
const parentRecordUid = webSafe64FromBytes(link.parentRecordUid)

try {
await platform.unwrapKey(link.recordKey, childRecordUid, parentRecordUid, 'gcm', 'aes', storage, true)
await storage.put({
kind: 'keeper_drive_record_link',
childRecordUid,
parentRecordUid,
})
} catch (e: any) {
console.error(
`[ks] The record link for ${childRecordUid} cannot be decrypted by ${parentRecordUid} (${e.message})`
)
}
}
}

const processKdRevokedFolderAccesses = async (
storage: VaultStorage,
keeperDriveRevokedFolderAccesses?: Folder.IRevokedAccess[] | null
Expand Down Expand Up @@ -1565,6 +1589,8 @@ export const syncDown = async (options: SyncDownOptions): Promise<SyncResult> =>

await processKdFolderRecords(storage, dependencies, keeperDriveData.folderRecords)

await processKdRecordLinks(storage, keeperDriveData.recordLinks)

await processKdRecords(storage, keeperDriveData.recordData, keeperDriveData.records)

await processKdRecordSharingStates(storage, keeperDriveData.recordSharingStates)
Expand Down
Loading