Skip to content

Commit

Permalink
Merge pull request #38 from Keeper-Security/process-profile-pics
Browse files Browse the repository at this point in the history
profile pic rebase
  • Loading branch information
ccslakey authored Nov 29, 2023
2 parents bc524f2 + 6edde9a commit 7039f51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion keeperapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@keeper-security/keeperapi",
"description": "Keeper API Javascript SDK",
"version": "16.0.48",
"version": "16.0.49",
"browser": "dist/index.es.js",
"main": "dist/index.cjs.js",
"types": "dist/node/index.d.ts",
Expand Down
30 changes: 28 additions & 2 deletions keeperapi/src/vaultx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export type VaultStorage = KeyStorage & {
delete(kind: VaultStorageKind, uid: string): Promise<void>
}

export type VaultStorageData = DContinuationToken | DRecord | DRecordMetadata | DRecordNonSharedData | DTeam | DSharedFolder | DSharedFolderUser | DSharedFolderTeam | DSharedFolderRecord | DSharedFolderFolder | DUserFolder | DProfile | DReusedPasswords | DBWRecord | DBWSecurityData
export type VaultStorageData = DProfilePic | DContinuationToken | DRecord | DRecordMetadata | DRecordNonSharedData | DTeam | DSharedFolder | DSharedFolderUser | DSharedFolderTeam | DSharedFolderRecord | DSharedFolderFolder | DUserFolder | DProfile | DReusedPasswords | DBWRecord | DBWSecurityData

export type VaultStorageKind = 'record' | 'metadata' | 'non_shared_data' | 'team' | 'shared_folder' | 'shared_folder_user' | 'shared_folder_team' | 'shared_folder_record' | 'shared_folder_folder' | 'user_folder' | 'profile' | 'continuationToken' | 'reused_passwords' | 'bw_record' | 'bw_security_data'
export type VaultStorageKind = 'profilePic' | 'record' | 'metadata' | 'non_shared_data' | 'team' | 'shared_folder' | 'shared_folder_user' | 'shared_folder_team' | 'shared_folder_record' | 'shared_folder_folder' | 'user_folder' | 'profile' | 'continuationToken' | 'reused_passwords' | 'bw_record' | 'bw_security_data'

export type VaultStorageResult<T extends VaultStorageKind> = (
T extends 'continuationToken' ? DContinuationToken :
Expand Down Expand Up @@ -166,6 +166,14 @@ export type DProfile = {
revision: number
}

export type DProfilePic = {
kind: 'profilePic'
data: {
url: string
revision: number
}
}

export type DBWRecord = {
kind: 'bw_record'
uid: string
Expand Down Expand Up @@ -664,6 +672,20 @@ const processProfile = async (profile: IProfile | null | undefined, storage: Vau
}
}

const processProfilePic = async (profilePic, storage) => {
try {
if (!profilePic)
return;
await storage.put({
kind: 'profilePic',
data: profilePic,
});
}
catch (e: any) {
console.error(`Profile picture cannot be decrypted (${e.message})`);
}
};

const processSharedFolderFolders = async (folders: ISharedFolderFolder[], storage: VaultStorage, dependencies: Dependencies) => {
for (const folder of folders as NN<ISharedFolderFolder>[]) {
const sharedFolderUid = webSafe64FromBytes(folder.sharedFolderUid)
Expand Down Expand Up @@ -1015,6 +1037,10 @@ export const syncDown = async (options: SyncDownOptions): Promise<SyncResult> =>
profiler?.time('processProfile')
await processProfile(resp.profile, storage)
profiler?.timeEnd('processProfile')

profiler?.time('processProfilePic')
await processProfilePic(resp.profilePic, storage);
profiler?.timeEnd('processProfilePic')

profiler?.time('processBreachWatchRecords')
await processBreachWatchRecords(resp.breachWatchRecords, storage)
Expand Down

0 comments on commit 7039f51

Please sign in to comment.