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
4 changes: 2 additions & 2 deletions keeperapi/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.79",
"version": "16.0.80",
"browser": "dist/index.es.js",
"main": "dist/index.cjs.js",
"types": "dist/node/index.d.ts",
Expand Down
17 changes: 17 additions & 0 deletions keeperapi/src/browser/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ export const browserPlatform: Platform = class {
keyBytesCache = {}
}

static unloadNonUserKeys(): void {
cryptoKeysCache = {
cbc: {
data: cryptoKeysCache.cbc.data
},
gcm: {
data: cryptoKeysCache.gcm.data
},
ecc: {
pk_ecc: cryptoKeysCache.ecc.pk_ecc
},
}
keyBytesCache = {
pk_rsa: keyBytesCache.pk_rsa
}
}

static getStorageKeyId(keyId: string, keyType: EncryptionType): string {
switch (keyType) {
case 'cbc':
Expand Down
8 changes: 8 additions & 0 deletions keeperapi/src/node/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export const nodePlatform: Platform = class {
keyCache = {}
}

static unloadNonUserKeys(): void {
keyCache = {
data: keyCache.data,
pk_ecc: keyCache.pk_ecc,
pk_rsa: keyCache.pk_rsa,
}
}

static async unwrapKeys(keys: UnwrapKeyMap, storage?: KeyStorage): Promise<void> {
for (const task of Object.values(keys)) {
try {
Expand Down
6 changes: 6 additions & 0 deletions keeperapi/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ export interface Platform {

importKeyRSA(keyId: string, key: Uint8Array, storage?: KeyStorage, canExport?: boolean): Promise<void>

// Removes all keys stored in the local cache, including user keys, record keys, etc.
// A typical use case is during logout, when you want to completely clear the cached keys.
unloadKeys(): void

// Clears all cached keys except user keys.
// A good use case is a manual full sync while the user is still logged in.
unloadNonUserKeys(): void

unwrapKey(key: Uint8Array, keyId: string, unwrappingKeyId: string, encryptionType: EncryptionType, unwrappedType: UnwrappedKeyType, storage?: KeyStorage, canExport?: boolean): Promise<void>

unwrapKeys(keys: UnwrapKeyMap, storage?: KeyStorage): Promise<void>
Expand Down
1 change: 1 addition & 0 deletions keeperapi/src/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ export const syncDown = async (options: SyncDownOptions): Promise<SyncResult> =>
addCounts(totalCounts, counts)
logProtobuf(resp, options.logFormat || '!', result.pageCount, counts)
if (resp.cacheStatus == CacheStatus.CLEAR) {
platform.unloadNonUserKeys()
await storage.clear()
result.fullSync = true
}
Expand Down