import { Plugin , CoreSetup , RequestHandlerContext , KibanaRequest , KibanaResponseFactory , IKibanaResponse , } from 'kibana/server' ; import { schema } from '@kbn/config-schema' ; import { EncryptedSavedObjectsPluginStart } from '../../../../../../../plugins/encrypted_saved_objects/server' ; import { SpacesPluginSetup } from '../../../../../../../plugins/spaces/server' ; interface FixtureSetupDeps { spaces ? : SpacesPluginSetup ; } interface FixtureStartDeps { encryptedSavedObjects : EncryptedSavedObjectsPluginStart ; } export class FixturePlugin implements Plugin < void , void , FixtureSetupDeps , FixtureStartDeps > { public setup ( core , { spaces } ) { core . http . createRouter ( ) . post ( { path : '/api/check_aad' , validate : { body : schema . object ( { spaceId : schema . maybe ( schema . string ( ) ) , type : schema . string ( ) , id : schema . string ( ) , } ) , } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { let namespace ; if ( spaces && req . body . spaceId ) { namespace = spaces . spacesService . spaceIdToNamespace ( req . body . spaceId ) ; } const [ , { encryptedSavedObjects } ] = await core . getStartServices ( ) ; await encryptedSavedObjects . getClient ( { includedHiddenTypes : [ 'alert' , 'action' ] , } ) . getDecryptedAsInternalUser ( req . body . type , req . body . id , { namespace , } ) ; return res . ok ( { body : { success : true } } ) ; } ) ; } public start ( ) { } public stop ( ) { } }