import { AbortSignalLike } from '@azure/abort-controller';
import { AccessToken } from '@azure/core-auth';
import { KeyCredential } from '@azure/core-auth';
import { PipelinePolicy } from '@azure/core-rest-pipeline';
import { TokenCredential } from '@azure/core-auth';

/**
 * The CommunicationTokenCredential implementation with support for proactive token refresh.
 */
export declare class AzureCommunicationTokenCredential implements CommunicationTokenCredential {
    private readonly tokenCredential;
    private disposed;
    /**
     * Creates an instance of CommunicationTokenCredential with a static token and no proactive refreshing.
     * @param token - A user access token issued by Communication Services.
     */
    constructor(token: string);
    /**
     * Creates an instance of CommunicationTokenCredential with a lambda to get a token and options
     * to configure proactive refreshing.
     * @param refreshOptions - Options to configure refresh and opt-in to proactive refreshing.
     */
    constructor(refreshOptions: CommunicationTokenRefreshOptions);
    /**
     * Gets an `AccessToken` for the user. Throws if already disposed.
     * @param abortSignal - An implementation of `AbortSignalLike` to cancel the operation.
     */
    getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken>;
    /**
     * Disposes the CommunicationTokenCredential and cancels any internal auto-refresh operation.
     */
    dispose(): void;
    private throwIfDisposed;
}

/**
 * Options for `CommunicationTokenCredential`'s `getToken` function.
 */
export declare interface CommunicationGetTokenOptions {
    /**
     * An implementation of `AbortSignalLike` to cancel the operation.
     */
    abortSignal?: AbortSignalLike;
}

/**
 * Identifies a communication participant.
 */
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | MicrosoftTeamsAppIdentifier | UnknownIdentifier;

/**
 * The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.
 */
export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftTeamsAppKind | UnknownIdentifierKind;

/**
 * The Azure Communication Services token credential.
 */
export declare interface CommunicationTokenCredential {
    /**
     * Gets an `AccessToken` for the user. Throws if already disposed.
     * @param options - Additional options.
     */
    getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken>;
    /**
     * Disposes the CommunicationTokenCredential and cancels any internal auto-refresh operation.
     */
    dispose(): void;
}

/**
 * Options for auto-refreshing a Communication Token credential.
 */
export declare interface CommunicationTokenRefreshOptions {
    /**
     * Callback function that returns a string JWT token acquired from the Communication Identity API.
     * The returned token must be valid (expiration date must be in the future).
     */
    tokenRefresher: (abortSignal?: AbortSignalLike) => Promise<string>;
    /**
     * Optional token to initialize.
     */
    token?: string;
    /**
     * Indicates whether the token should be proactively renewed prior to expiry or only renew on demand.
     * By default false.
     */
    refreshProactively?: boolean;
}

/**
 * An Azure Communication user.
 */
export declare interface CommunicationUserIdentifier {
    /**
     * Id of the CommunicationUser as returned from the Communication Service.
     */
    communicationUserId: string;
}

/**
 * IdentifierKind for a CommunicationUserIdentifier.
 */
export declare interface CommunicationUserKind extends CommunicationUserIdentifier {
    /**
     * The identifier kind.
     */
    kind: "communicationUser";
}

/**
 * Creates an HTTP pipeline policy to authenticate a request using a `KeyCredential`.
 * @hidden
 *
 * @param credential - The key credential.
 */
export declare function createCommunicationAccessKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy;

/**
 * Creates a pipeline policy to authenticate request based
 * on the credential passed in.
 * @hidden
 *
 * @param credential - The KeyCredential or TokenCredential.
 */
export declare function createCommunicationAuthPolicy(credential: KeyCredential | TokenCredential): PipelinePolicy;

/**
 * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.
 *
 * @param rawId - The rawId to be translated to its identifier representation.
 */
export declare const createIdentifierFromRawId: (rawId: string) => CommunicationIdentifierKind;

/**
 * @hidden
 * Translates the serialized format of a communication identifier to CommunicationIdentifier.
 * @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.
 */
export declare const deserializeCommunicationIdentifier: (serializedIdentifier: SerializedCommunicationIdentifier) => CommunicationIdentifierKind;

/**
 * Represents different properties of connection string
 * using format "/endpoint=(.*);accesskey=(.*)".
 * @hidden
 */
export declare interface EndpointCredential {
    /**
     * The endpoint as string
     */
    endpoint: string;
    /**
     * The access key represented as a KeyCredential object
     */
    credential: KeyCredential;
}

/**
 * Returns the CommunicationIdentifierKind for a given CommunicationIdentifier. Returns undefined if the kind couldn't be inferred.
 *
 * @param identifier - The identifier whose kind is to be inferred.
 */
export declare const getIdentifierKind: (identifier: CommunicationIdentifier) => CommunicationIdentifierKind;

/**
 * Returns the rawId for a given CommunicationIdentifier. You can use the rawId for encoding the identifier and then use it as a key in a database.
 *
 * @param identifier - The identifier to be translated to its rawId.
 */
export declare const getIdentifierRawId: (identifier: CommunicationIdentifier) => string;

/**
 * Tests an Identifier to determine whether it implements CommunicationUserIdentifier.
 *
 * @param identifier - The assumed CommunicationUserIdentifier to be tested.
 */
export declare const isCommunicationUserIdentifier: (identifier: CommunicationIdentifier) => identifier is CommunicationUserIdentifier;

/**
 * Checks whether a value is a KeyCredential.
 *
 * @param credential - The credential being checked.
 */
export declare const isKeyCredential: (credential: unknown) => credential is KeyCredential;

/**
 * Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
 *
 * @param identifier - The assumed available to be tested.
 */
export declare const isMicrosoftTeamsAppIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftTeamsAppIdentifier;

/**
 * Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.
 *
 * @param identifier - The assumed available to be tested.
 */
export declare const isMicrosoftTeamsUserIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftTeamsUserIdentifier;

/**
 * Tests an Identifier to determine whether it implements PhoneNumberIdentifier.
 *
 * @param identifier - The assumed PhoneNumberIdentifier to be tested.
 */
export declare const isPhoneNumberIdentifier: (identifier: CommunicationIdentifier) => identifier is PhoneNumberIdentifier;

/**
 * Tests an Identifier to determine whether it implements UnknownIdentifier.
 *
 * @param identifier - The assumed UnknownIdentifier to be tested.
 */
export declare const isUnknownIdentifier: (identifier: CommunicationIdentifier) => identifier is UnknownIdentifier;

/**
 * A Microsoft Teams App.
 */
export declare interface MicrosoftTeamsAppIdentifier {
    /**
     * Optional raw id of the Microsoft Teams App.
     */
    rawId?: string;
    /**
     * The unique Microsoft Teams app ID.
     */
    teamsAppId: string;
    /**
     * The cloud that the Microsoft Temas App belongs to. If missing, the cloud is "public".
     */
    cloud?: "public" | "dod" | "gcch";
}

/**
 * IdentifierKind for a MicrosoftTeamsAppIdentifier.
 */
export declare interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {
    /**
     * The identifier kind.
     */
    kind: "microsoftTeamsApp";
}

/**
 * A Microsoft Teams user.
 */
export declare interface MicrosoftTeamsUserIdentifier {
    /**
     * Optional raw id of the Microsoft Teams user.
     */
    rawId?: string;
    /**
     * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.
     */
    microsoftTeamsUserId: string;
    /**
     * True if the user is anonymous, for example when joining a meeting with a share link. If missing, the user is not anonymous.
     */
    isAnonymous?: boolean;
    /**
     * The cloud that the Microsoft Teams user belongs to. If missing, the cloud is "public".
     */
    cloud?: "public" | "dod" | "gcch";
}

/**
 * IdentifierKind for a MicrosoftTeamsUserIdentifier.
 */
export declare interface MicrosoftTeamsUserKind extends MicrosoftTeamsUserIdentifier {
    /**
     * The identifier kind.
     */
    kind: "microsoftTeamsUser";
}

/**
 * Parses arguments passed to a communication client.
 * @hidden
 */
export declare const parseClientArguments: (connectionStringOrUrl: string, credentialOrOptions?: unknown) => UrlWithCredential;

/**
 * Returns an EndpointCredential to easily access properties of the connection string.
 * @hidden
 *
 * @param connectionString - The connection string to parse
 * @returns Object to access the endpoint and the credentials
 */
export declare const parseConnectionString: (connectionString: string) => EndpointCredential;

/**
 * A phone number.
 */
export declare interface PhoneNumberIdentifier {
    /**
     * Optional raw id of the phone number.
     */
    rawId?: string;
    /**
     * The phone number in E.164 format.
     */
    phoneNumber: string;
}

/**
 * IdentifierKind for a PhoneNumberIdentifier.
 */
export declare interface PhoneNumberKind extends PhoneNumberIdentifier {
    /**
     * The identifier kind.
     */
    kind: "phoneNumber";
}

/**
 * @hidden
 * Translates a CommunicationIdentifier to its serialized format for sending a request.
 * @param identifier - The CommunicationIdentifier to be serialized.
 */
export declare const serializeCommunicationIdentifier: (identifier: CommunicationIdentifier) => SerializedCommunicationIdentifier;

/**
 * @hidden
 * Defines values for CommunicationCloudEnvironmentModel.
 */
export declare type SerializedCommunicationCloudEnvironment = "public" | "dod" | "gcch";

/**
 * @hidden
 * Identifies a participant in Azure Communication services. A participant is, for example, a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at most one further property may be set.
 */
export declare interface SerializedCommunicationIdentifier {
    /**
     * Kind of the identifier, optional.
     */
    kind?: string;
    /**
     * Raw Id of the identifier. Optional in requests, required in responses.
     */
    rawId?: string;
    /**
     * The communication user.
     */
    communicationUser?: SerializedCommunicationUserIdentifier;
    /**
     * The phone number.
     */
    phoneNumber?: SerializedPhoneNumberIdentifier;
    /**
     * The Microsoft Teams user.
     */
    microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;
    /**
     * The Microsoft Teams App.
     */
    microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
}

/**
 * @hidden
 * A user that got created with an Azure Communication Services resource.
 */
export declare interface SerializedCommunicationUserIdentifier {
    /**
     * The Id of the communication user.
     */
    id: string;
}

/**
 * @hidden
 * A Microsoft Teams App.
 */
export declare interface SerializedMicrosoftTeamsAppIdentifier {
    /**
     * Id of the Microsoft Teams App.
     */
    appId: string;
    /**
     * The cloud that the Microsoft Teams App belongs to. By default 'public' if missing.
     */
    cloud?: SerializedCommunicationCloudEnvironment;
}

/**
 * @hidden
 * A Microsoft Teams user.
 */
export declare interface SerializedMicrosoftTeamsUserIdentifier {
    /**
     * The Id of the Microsoft Teams user. If not anonymous, this is the AAD object Id of the user.
     */
    userId: string;
    /**
     * True if the Microsoft Teams user is anonymous. By default false if missing.
     */
    isAnonymous?: boolean;
    /**
     * The cloud that the Microsoft Teams user belongs to. By default 'public' if missing.
     */
    cloud?: SerializedCommunicationCloudEnvironment;
}

/**
 * @hidden
 * A phone number.
 */
export declare interface SerializedPhoneNumberIdentifier {
    /**
     * The phone number in E.164 format.
     */
    value: string;
}

/**
 * An unknown identifier that doesn't fit any of the other identifier types.
 */
export declare interface UnknownIdentifier {
    /**
     * Id of the UnknownIdentifier.
     */
    id: string;
}

/**
 * IdentifierKind for UnknownIdentifier.
 */
export declare interface UnknownIdentifierKind extends UnknownIdentifier {
    /**
     * The identifier kind.
     */
    kind: "unknown";
}

/**
 * The URL and credential from parsing the arguments of a communication client.
 * @hidden
 */
export declare type UrlWithCredential = {
    url: string;
    credential: TokenCredential | KeyCredential;
};

export { }
