import { AwsCredentialIdentityProvider, AwsCredentialIdentity, HttpResponse } from '@aws-sdk/types'; import { EventCache } from '../event-cache/EventCache'; import { DataPlaneClient, SigningConfig } from './DataPlaneClient'; import { Config } from '../orchestration/config'; export type ClientBuilder = (endpoint: URL, region: string, credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider, compressionStrategy?: { enabled: boolean; }) => DataPlaneClient; /** * A factory that creates a credential provider for Cognito authentication. * Injected by distribution packages (e.g., aws-rum-web) that include auth. */ export type CognitoCredentialProviderFactory = (config: Config, applicationId: string, identityPoolId: string, guestRoleArn?: string) => AwsCredentialIdentityProvider; /** * A factory that creates a SigningConfig for request signing. * Injected by distribution packages that include signing support. */ export type SigningConfigFactory = (credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider, region: string) => SigningConfig; export declare class Dispatch { private applicationId; private region; private endpoint; private eventCache; private rum; private enabled; private dispatchTimerId; private buildClient; private config; private disableCodes; private headers; private credentialProvider; private shouldPurgeCredentials; private credentialStorageKey; private identityStorageKey; private cognitoCredentialProviderFactory?; private signingConfigFactory?; private identityPoolId?; private guestRoleArn?; constructor(applicationId: string, region: string, endpoint: URL, eventCache: EventCache, config: Config); /** * Dispatch will send requests to data plane. */ enable(): void; /** * Dispatch will not send requests to data plane. */ disable(): void; /** * Set the authentication token that will be used to authenticate with the * data plane service (AWS auth). * * @param credentials A set of AWS credentials from the application's authflow. */ setAwsCredentials(credentialProvider: AwsCredentialIdentity | AwsCredentialIdentityProvider): void; /** * Set the factory used to create Cognito credential providers. * This is injected by distribution packages that include auth support. */ setCognitoCredentialProviderFactory(factory: CognitoCredentialProviderFactory): void; /** * Set the factory used to create signing configurations. * This is injected by distribution packages that include signing support. */ setSigningConfigFactory(factory: SigningConfigFactory): void; /** * Initialize Cognito credentials using the injected factory. * If no factory has been set, this is a no-op. */ setCognitoCredentials(identityPoolId: string, guestRoleArn?: string): void; /** * Send meta data and events to the AWS RUM data plane service via fetch. */ dispatchFetch: () => Promise<{ response: HttpResponse; } | undefined>; /** * Send meta data and events to the AWS RUM data plane service via beacon. */ dispatchBeacon: () => Promise<{ response: HttpResponse; } | undefined>; /** * Send meta data and events to the AWS RUM data plane service via fetch. * * Returns undefined on failure. */ dispatchFetchFailSilent: () => Promise<{ response: HttpResponse; } | void>; /** * Send meta data and events to the AWS RUM data plane service via beacon. * * Returns undefined on failure. */ dispatchBeaconFailSilent: () => Promise<{ response: HttpResponse; } | void>; private flushSync; /** * Automatically dispatch cached events. */ startDispatchTimer(): void; /** * Stop automatically dispatching cached events. */ stopDispatchTimer(): void; private doRequest; private createRequest; private handleReject; /** * The default method for creating data plane service clients. */ private defaultClientBuilder; /** * Purges the cached credentials and rebuilds the dataplane client. */ private forceRebuildClient; }