Skip to content

Commit

Permalink
as type for return value
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamieh committed Apr 3, 2020
1 parent 4e9c932 commit 5e44e78
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import nodeCrypto from '@elastic/node-crypto';
import nodeCrypto, { Crypto } from '@elastic/node-crypto';
import stringify from 'json-stable-stringify';
import typeDetect from 'type-detect';
import { Logger } from 'src/core/server';
Expand Down Expand Up @@ -48,10 +48,7 @@ export function descriptorToArray(descriptor: SavedObjectDescriptor) {
* attributes.
*/
export class EncryptedSavedObjectsService {
private readonly crypto: Readonly<{
encrypt<T>(valueToEncrypt: T, aad?: string): Promise<string>;
decrypt<T>(valueToDecrypt: string, aad?: string): Promise<T>;
}>;
private readonly crypto: Readonly<Crypto>;

/**
* Map of all registered saved object types where the `key` is saved object type and the `value`
Expand Down Expand Up @@ -228,10 +225,10 @@ export class EncryptedSavedObjectsService {
}

try {
decryptedAttributes[attributeName] = await this.crypto.decrypt(
decryptedAttributes[attributeName] = (await this.crypto.decrypt(
attributeValue,
encryptionAAD
);
)) as string;
} catch (err) {
this.logger.error(`Failed to decrypt "${attributeName}" attribute: ${err.message || err}`);
this.audit.decryptAttributeFailure(attributeName, descriptor);
Expand Down

0 comments on commit 5e44e78

Please sign in to comment.