Handle out of sync extension activations for encryption keys updated event (#22415)

This commit is contained in:
Cheena Malhotra
2023-03-22 22:23:03 -07:00
committed by GitHub
parent 0741e18533
commit 43f97f4f56
7 changed files with 63 additions and 16 deletions

View File

@@ -53,10 +53,18 @@ export class FileEncryptionHelper {
// Emit event with cache encryption keys to send notification to provider services.
if (this._authLibrary === AuthLibrary.MSAL && this._onEncryptionKeysUpdated) {
this._onEncryptionKeysUpdated.fire({
iv: this._ivBuffer.toString(this._bufferEncoding),
key: this._keyBuffer.toString(this._bufferEncoding)
});
this._onEncryptionKeysUpdated.fire(this.getEncryptionKeys());
Logger.verbose('FileEncryptionHelper: Fired encryption keys updated event.');
}
}
/**
* Provides encryption keys in use for instant access.
*/
public getEncryptionKeys(): CacheEncryptionKeys {
return {
iv: this._ivBuffer!.toString(this._bufferEncoding),
key: this._keyBuffer!.toString(this._bufferEncoding)
}
}

View File

@@ -33,6 +33,14 @@ export class MsalCachePluginProvider {
return this._msalFilePath + '.lockfile';
}
public async init(): Promise<void> {
await this._fileEncryptionHelper.init();
}
public getCacheEncryptionKeys(): CacheEncryptionKeys {
return this._fileEncryptionHelper.getEncryptionKeys();
}
public getCachePlugin(): ICachePlugin {
const lockFilePath = this.getLockfilePath();
const beforeCacheAccess = async (cacheContext: TokenCacheContext): Promise<void> => {