[7.x] Add "legacy" Encrypted Saved Objects plugin typings. (#36128)

This commit is contained in:
Aleh Zasypkin 2019-05-06 21:53:01 +02:00 committed by GitHub
parent 69f562ce14
commit be8579ca3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View file

@ -12,6 +12,11 @@ import { AuditLogger } from '../../server/lib/audit_logger';
import { CONFIG_PREFIX, PLUGIN_ID, Plugin } from './server/plugin';
/**
* Public interface of the security plugin for the legacy plugin system.
*/
export type EncryptedSavedObjectsPlugin = ReturnType<Plugin['setup']>;
export const encryptedSavedObjects = (kibana: any) =>
new kibana.Plugin({
id: PLUGIN_ID,

View file

@ -7,7 +7,11 @@
import crypto from 'crypto';
import { Legacy, Server } from 'kibana';
import { SavedObjectsRepository } from 'src/legacy/server/saved_objects/service/lib';
import { BaseOptions } from 'src/legacy/server/saved_objects/service/saved_objects_client';
import {
BaseOptions,
SavedObject,
SavedObjectAttributes,
} from 'src/legacy/server/saved_objects/service/saved_objects_client';
import {
EncryptedSavedObjectsService,
EncryptedSavedObjectTypeRegistration,
@ -71,7 +75,11 @@ export class Plugin {
isEncryptionError: (error: Error) => error instanceof EncryptionError,
registerType: (typeRegistration: EncryptedSavedObjectTypeRegistration) =>
service.registerType(typeRegistration),
getDecryptedAsInternalUser: async (type: string, id: string, options?: BaseOptions) => {
getDecryptedAsInternalUser: async <T extends SavedObjectAttributes = any>(
type: string,
id: string,
options?: BaseOptions
): Promise<SavedObject<T>> => {
const savedObject = await internalRepository.get(type, id, options);
return {
...savedObject,

View file

@ -7,6 +7,7 @@
import 'hapi';
import { CloudPlugin } from '../plugins/cloud';
import { EncryptedSavedObjectsPlugin } from '../plugins/encrypted_saved_objects';
import { SecurityPlugin } from '../plugins/security';
import { XPackMainPlugin } from '../plugins/xpack_main/xpack_main';
@ -15,5 +16,6 @@ declare module 'hapi' {
cloud?: CloudPlugin;
xpack_main: XPackMainPlugin;
security?: SecurityPlugin;
encrypted_saved_objects?: EncryptedSavedObjectsPlugin;
}
}