<commit_before>// Type definitions for sip.js 0.8
// Project: http://sipjs.com
// Definitions by: <NAME> <https://github.com/decyrus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

export as namespace sipjs;

export class URI {
    scheme?: string;
    user?: string;
    host?: string;
    port?: number;

    constructor(scheme?: string, user?: string, host?: string, port?: number, parameters?: string[], headers?: string[]);
    static parse(uri: string): sipjs.URI;

    setParam(key: string, value?: string): void;
    getParam(key: string): string;
    hasParam(key: string): string;
    deleteParam(key: string): string;
    clearParams(): void;
    setHeader(name: string, value: string): void;
    getHeader(name: string): string[];
    hasHeader(name: string): boolean;
    deleteHeader(name: string): string[];
    clearHeaders(): void;
    clone(): URI;
    toString(): string;
}

export namespace UA.EventArgs {
    interface ConnectedArgs { attempts: number; }
    interface UnregisteredArgs { response: string; cause: string; }
    interface RegistrationFailedArgs extends UnregisteredArgs { }
}

export class UA {
    constructor(configuration?: sipjs.ConfigurationParameters);

    start(): UA;
    stop(): UA;
    register(options?: ExtraHeadersOptions): UA;
    unregister(options?: UnregisterOptions): UA;
    isRegistered(): boolean;
    isConnected(): boolean;
    message(target: string | URI, body: string, options?: MessageOptions): Message;
    subscribe(target: string | URI, event: string, options?: SubscribeOptions): Subscription;
    invite(target: string | URI, element?: InviteOptions | HTMLAudioElement | HTMLVideoElement): Session;
    request(method: string, target: string | URI, options?: RequestOptions): ClientContext;

    on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void;
    on(name: 'disconnected' | 'registered' | string, callback: () => void): void;
    on(name: 'unregistered', callback: (args: UA.EventArgs.UnregisteredArgs) => void): void;
    on(name: 'registrationFailed', callback: (args: UA.EventArgs.RegistrationFailedArgs) => void): void;
    on(name: 'invite', callback: (session: Session) => void): void;
    on(name: 'message', callback: (message: Message) => void): void;
}

export namespace C {
    namespace supported {
        const REQUIRED: string;
        const SUPPORTED: string;
        const UNSUPPORTED: string;
    }

    namespace causes {
        const INVALID_TARGET: string;
        const CONNECTION_ERROR: string;
        const REQUEST_TIMEOUT: string;
        const SIP_FAILURE_CODE: string;
    }
}

export type DescriptionModifier = (description: RTCSessionDescription) => Promise<RTCSessionDescription>;

export interface SessionDescriptionHandler {
    getDescription(options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise<any>;
    setDescription(sessionDescription: string, options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise<any>;
    hasDescription: (contentType: string) => boolean;
    close: () => void;
    holdModifier: (description: RTCSessionDescription) => Promise<RTCSessionDescription>;

    on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void;
    on(name: 'userMedia', callback: (stream: MediaStream) => void): void;
    on(name: 'userMediaFailed', callback: (error: string) => void): void;
    on(name: 'iceCandidate', callback: (candidate: any) => void): void;
    on(
        name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' |
            'iceConnectionDisconnected' | 'iceConnectionClosed' | string,
        callback: () => void): void;
    on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void;
    on(name: 'addTrack', callback: (track: any) => void): void;
}

export interface Session {
    startTime?: Date;
    endTime?: Date;
    ua?: UA;
    method?: string;
    mediaHandler?: WebRTC.MediaHandler;
    request?: IncomingRequest | OutgoingRequest;
    localIdentity?: NameAddrHeader;
    remoteIdentity?: NameAddrHeader;
    data: ClientContext | ServerContext;
    sessionDescriptionHandler: SessionDescriptionHandler;

    dtmf(tone: string | number, options?: Session.DtmfOptions): Session;
    terminate(options?: Session.CommonOptions): Session;
    bye(options?: Session.CommonOptions): Session;
    getLocalStreams(): any[];
    getRemoteStreams(): any[];
    refer(target: string | Session, options?: ExtraHeadersOptions): Session;
    mute(options?: ExtraHeadersOptions): void;
    unmute(options?: ExtraHeadersOptions): void;
    cancel(options?: Session.CommonOptions): void;
    progress(options?: Session.ProgressOptions): void;
    accept(options?: Session.AcceptOptions): void;
    reject(options?: Session.CommonOptions): void;
    reply(options?: Session.CommonOptions): void;
    hold(options?: Session.HoldOptions): void;
    unhold(options?: Session.HoldOptions): void;
    isOnHold(): Session.Held;
    followRefer(callback: () => void): void;

    on(name: 'progress', callback: (response: IncomingResponse) => void): void;
    on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void;
    on(name: 'failed' | 'rejected', callback: (response: IncomingResponse, cause: string) => void): void;
    on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void;
    on(name: 'cancel' | string, callback: () => void): void;
    on(name: 'replaced', callback: (newSession: Session) => void): void;
    on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void;
    on(name: 'muted' | 'unmuted', callback: (data: Session.Muted) => void): void;<commit_msg>sip.js: Add P-Asserted-Identity property<commit_after>// Type definitions for sip.js 0.8
// Project: http://sipjs.com
// Definitions by: <NAME> <https://github.com/decyrus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

export as namespace sipjs;

export class URI {
    scheme?: string;
    user?: string;
    host?: string;
    port?: number;

    constructor(scheme?: string, user?: string, host?: string, port?: number, parameters?: string[], headers?: string[]);
    static parse(uri: string): sipjs.URI;

    setParam(key: string, value?: string): void;
    getParam(key: string): string;
    hasParam(key: string): string;
    deleteParam(key: string): string;
    clearParams(): void;
    setHeader(name: string, value: string): void;
    getHeader(name: string): string[];
    hasHeader(name: string): boolean;
    deleteHeader(name: string): string[];
    clearHeaders(): void;
    clone(): URI;
    toString(): string;
}

export namespace UA.EventArgs {
    interface ConnectedArgs { attempts: number; }
    interface UnregisteredArgs { response: string; cause: string; }
    interface RegistrationFailedArgs extends UnregisteredArgs { }
}

export class UA {
    constructor(configuration?: sipjs.ConfigurationParameters);

    start(): UA;
    stop(): UA;
    register(options?: ExtraHeadersOptions): UA;
    unregister(options?: UnregisterOptions): UA;
    isRegistered(): boolean;
    isConnected(): boolean;
    message(target: string | URI, body: string, options?: MessageOptions): Message;
    subscribe(target: string | URI, event: string, options?: SubscribeOptions): Subscription;
    invite(target: string | URI, element?: InviteOptions | HTMLAudioElement | HTMLVideoElement): Session;
    request(method: string, target: string | URI, options?: RequestOptions): ClientContext;

    on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void;
    on(name: 'disconnected' | 'registered' | string, callback: () => void): void;
    on(name: 'unregistered', callback: (args: UA.EventArgs.UnregisteredArgs) => void): void;
    on(name: 'registrationFailed', callback: (args: UA.EventArgs.RegistrationFailedArgs) => void): void;
    on(name: 'invite', callback: (session: Session) => void): void;
    on(name: 'message', callback: (message: Message) => void): void;
}

export namespace C {
    namespace supported {
        const REQUIRED: string;
        const SUPPORTED: string;
        const UNSUPPORTED: string;
    }

    namespace causes {
        const INVALID_TARGET: string;
        const CONNECTION_ERROR: string;
        const REQUEST_TIMEOUT: string;
        const SIP_FAILURE_CODE: string;
    }
}

export type DescriptionModifier = (description: RTCSessionDescription) => Promise<RTCSessionDescription>;

export interface SessionDescriptionHandler {
    getDescription(options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise<any>;
    setDescription(sessionDescription: string, options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise<any>;
    hasDescription: (contentType: string) => boolean;
    close: () => void;
    holdModifier: (description: RTCSessionDescription) => Promise<RTCSessionDescription>;

    on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void;
    on(name: 'userMedia', callback: (stream: MediaStream) => void): void;
    on(name: 'userMediaFailed', callback: (error: string) => void): void;
    on(name: 'iceCandidate', callback: (candidate: any) => void): void;
    on(
        name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' |
            'iceConnectionDisconnected' | 'iceConnectionClosed' | string,
        callback: () => void): void;
    on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void;
    on(name: 'addTrack', callback: (track: any) => void): void;
}

export interface Session {
    startTime?: Date;
    endTime?: Date;
    ua?: UA;
    method?: string;
    mediaHandler?: WebRTC.MediaHandler;
    request?: IncomingRequest | OutgoingRequest;
    localIdentity?: NameAddrHeader;
    remoteIdentity?: NameAddrHeader;
    assertedIdentity?: NameAddrHeader;
    data: ClientContext | ServerContext;
    sessionDescriptionHandler: SessionDescriptionHandler;

    dtmf(tone: string | number, options?: Session.DtmfOptions): Session;
    terminate(options?: Session.CommonOptions): Session;
    bye(options?: Session.CommonOptions): Session;
    getLocalStreams(): any[];
    getRemoteStreams(): any[];
    refer(target: string | Session, options?: ExtraHeadersOptions): Session;
    mute(options?: ExtraHeadersOptions): void;
    unmute(options?: ExtraHeadersOptions): void;
    cancel(options?: Session.CommonOptions): void;
    progress(options?: Session.ProgressOptions): void;
    accept(options?: Session.AcceptOptions): void;
    reject(options?: Session.CommonOptions): void;
    reply(options?: Session.CommonOptions): void;
    hold(options?: Session.HoldOptions): void;
    unhold(options?: Session.HoldOptions): void;
    isOnHold(): Session.Held;
    followRefer(callback: () => void): void;

    on(name: 'progress', callback: (response: IncomingResponse) => void): void;
    on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void;
    on(name: 'failed' | 'rejected', callback: (response: IncomingResponse, cause: string) => void): void;
    on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void;
    on(name: 'cancel' | string, callback: () => void): void;
    on(name: 'replaced', callback: (newSession: Session) => void): void;
    on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void;
    on(name: 'muted' | 'unmuted', callback: (data: Session.Muted) => void): void;
{'fraction_non_alphanumeric': 0.13900933955970646, 'fraction_numerical': 0.00066711140760507, 'mean_word_length': 4.675816374822527, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 67, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5595622', 'n_tokens_mistral': 3407, 'n_tokens_neox': 3371, 'n_words': 924}