@openzeppelin/defender-serverless
Version:
Configure your Defender environment via code
106 lines • 5.73 kB
TypeScript
import Serverless from 'serverless';
import { AutotaskClient } from '@openzeppelin/defender-autotask-client';
import { SentinelClient } from '@openzeppelin/defender-sentinel-client';
import { RelayClient } from '@openzeppelin/defender-relay-client';
import { AdminClient } from '@openzeppelin/defender-admin-client';
import { BlockExplorerApiKeyClient, DeploymentConfigClient } from '@openzeppelin/platform-deploy-client';
import { YSecret, YSentinel, YNotification, DefenderAutotask, DefenderNotification, DefenderBlockSentinel, DefenderFortaSentinel, TeamKey, YContract, ResourceType, DefenderBlockWatcher, YCategory, DefenderCategory } from '../types';
/**
* @dev this function retrieves the Defender equivalent object of the provided template resource
* This will not work for resources that do not have the stackResourceId property, ie. secrets and contracts
*/
export declare const getEquivalentResource: <Y, D>(context: Serverless, resource: Y, resources: Y[] | undefined, currentResources: D[]) => D | undefined;
export declare const validateTypesAndSanitise: (o: object) => object;
export declare const getEquivalentResourceByKey: <D>(resourceKey: string, currentResources: D[]) => D | undefined;
/**
* @dev returns both a list of consolidated secrets for both global and stack, where the latter will be preceded with the stack name.
* */
export declare const getConsolidatedSecrets: (context: Serverless) => YSecret[];
export declare const isTemplateResource: <Y, D>(context: Serverless, resource: D, resourceType: ResourceType, resources: Y[]) => boolean;
export declare const getResourceID: (stackName: string, resourceName: string) => string;
export declare const getStackName: (context: Serverless) => string;
export declare const isSSOT: (context: Serverless) => boolean;
export declare const getTeamAPIkeysOrThrow: (context: Serverless) => TeamKey;
export declare const getSentinelClient: (key: TeamKey) => SentinelClient;
export declare const getAutotaskClient: (key: TeamKey) => AutotaskClient;
export declare const getRelayClient: (key: TeamKey) => RelayClient;
export declare const getAdminClient: (key: TeamKey) => AdminClient;
export declare const getDeploymentConfigClient: (key: TeamKey) => DeploymentConfigClient;
export declare const getBlockExplorerApiKeyClient: (key: TeamKey) => BlockExplorerApiKeyClient;
export declare const constructNotification: (notification: YNotification, stackResourceId: string) => {
config: {
apiKey: string;
metricPrefix: string;
url?: undefined;
emails?: undefined;
botToken?: undefined;
chatId?: undefined;
};
type: import("@openzeppelin/defender-sentinel-client").NotificationType;
name: string;
paused: boolean;
stackResourceId: string;
} | {
config: {
url: string;
apiKey?: undefined;
metricPrefix?: undefined;
emails?: undefined;
botToken?: undefined;
chatId?: undefined;
};
type: import("@openzeppelin/defender-sentinel-client").NotificationType;
name: string;
paused: boolean;
stackResourceId: string;
} | {
config: {
emails: string[];
apiKey?: undefined;
metricPrefix?: undefined;
url?: undefined;
botToken?: undefined;
chatId?: undefined;
};
type: import("@openzeppelin/defender-sentinel-client").NotificationType;
name: string;
paused: boolean;
stackResourceId: string;
} | {
config: {
botToken: string;
chatId: string;
apiKey?: undefined;
metricPrefix?: undefined;
url?: undefined;
emails?: undefined;
};
type: import("@openzeppelin/defender-sentinel-client").NotificationType;
name: string;
paused: boolean;
stackResourceId: string;
} | {
config: import("@openzeppelin/defender-sentinel-client/lib/models/opsgenie").OpsgenieConfig;
type: import("@openzeppelin/defender-sentinel-client").NotificationType;
name: string;
paused: boolean;
stackResourceId: string;
} | {
config: import("@openzeppelin/defender-sentinel-client/lib/models/pager-duty").PagerDutyConfig;
type: import("@openzeppelin/defender-sentinel-client").NotificationType;
name: string;
paused: boolean;
stackResourceId: string;
};
export declare const constructNotificationCategory: (context: Serverless, category: YCategory, stackResourceId: string, notifications: DefenderNotification[]) => {
name: string;
description: string;
notificationIds: [] | [import("@openzeppelin/defender-sentinel-client/lib/models/subscriber").NotificationReference] | [import("@openzeppelin/defender-sentinel-client/lib/models/subscriber").NotificationReference, import("@openzeppelin/defender-sentinel-client/lib/models/subscriber").NotificationReference];
stackResourceId: string;
};
export declare const constructSentinel: (context: Serverless, stackResourceId: string, sentinel: YSentinel, notifications: DefenderNotification[], autotasks: DefenderAutotask[], blockwatchers: DefenderBlockWatcher[], categories: DefenderCategory[]) => DefenderBlockSentinel | DefenderFortaSentinel;
export declare const validateListPermissions: <T>(client: SentinelClient | AutotaskClient | DeploymentConfigClient | RelayClient | AdminClient | BlockExplorerApiKeyClient, resources: T[] | undefined, resourceType: ResourceType) => Promise<boolean>;
export declare const validateAdditionalPermissionsOrThrow: <T>(context: Serverless, resources: T[] | undefined, resourceType: ResourceType) => Promise<void>;
export declare const isUnauthorisedError: (e: any) => boolean;
export declare const formatABI: (abi: YContract['abi']) => string | undefined;
//# sourceMappingURL=index.d.ts.map