@glance-networks/agent-plugin
Version:
Glance Networks Agent Plugin
128 lines (127 loc) • 6.04 kB
TypeScript
import { Dispatch, SetStateAction } from 'react';
import { BaseUrlEnvironment } from './Glance.constants';
export declare enum AuthMethod {
Loginkey = "LOGINKEY",
Saml = "SAML",
SamlWithLoginkey = "SAMLLOGINKEY",
SamlPopup = "SAMLPOPUP"
}
export interface AuthParams {
url: string;
puid: string;
groupId: string | number;
method?: AuthMethod | string;
headers?: Record<string, string | string[] | undefined>;
body?: URLSearchParams;
debug?: boolean;
glanceBaseUrl?: BaseUrlEnvironment;
errorHandler?: (message: string, hideError?: boolean, defaultValue?: string, severity?: string, replacement?: string) => void;
}
export interface LoginKey {
key: string;
expiration: number;
}
interface JoinParams {
cobrowseKey: string;
openLocation?: string;
debug?: boolean;
sessionStateHandler?: (activeSession: boolean) => void;
}
export interface PresenceParams {
presenceCallback: Dispatch<SetStateAction<boolean>>;
presenceEventDataCallback?: (data: unknown) => void;
permissionsCallback: () => void;
visitorId: string;
debug?: boolean;
endSessionCallback?: (data: any) => void;
startSessionCallback?: (data: any) => void;
}
interface EventListenerParams {
endSessionCallback?: (data: any) => void;
debug?: boolean;
}
export declare enum ErrorUserMessages {
LoginKeyError = "There are issues with authentication, please refresh the page.",
ConnectPresenceError = "There are issues with connecting to the presence service, please try again or refresh the page.",
PresenceAuthorizationError = "Partner User Id \"{0}\" not found or invalid, contact your administrator.",
PresenceDeclinedError = "The website visitor declined cobrowse session.",
LookupSessionNotFoundError = "Session not found. Check that the key is correct.",
LookupSessionError = "There are issues connecting cobrowse session, please try again or refresh the page.",
JoinSessionError = "There are issues with the visitor joining the cobrowse session, please try again or refresh the page.",
InviteSessionError = "There are issues with inviting the visitor to the mobile camera share session, please try again or refresh the page.",
InviteSessionBusinessError = "{0}, please try again or refresh the page.",
EndPresenceError = "There are issues with ending the presence session, please try again or refresh the page.",
EndCobrowseError = "There are issues with ending the cobrowse session, please try again or refresh the page.",
PopupError = "There was a problem opening the login window. Please make sure that pop-ups are enabled and refresh the page."
}
export declare enum Indices {
LoginKeyError = "integration-login-key-error",
ConnectPresenceError = "integration--presence-connection-error",
PresenceAuthorizationError = "integration-presence-authorization-error",
PresenceDeclinedError = "integration-presence-declined-error",
LookupSessionNotFoundError = "integration-session-not-found-error",
LookupSessionError = "integration-session-lookup-error",
JoinSessionError = "integration-join-session-error",
InviteSessionError = "integration-session-invite-error",
InviteSessionBusinessError = "integration-invite-business-error",
EndPresenceError = "integration-end-presence-error",
EndCobrowseError = "integration-end-cobrowse-error",
PopupError = "integration-popup-error"
}
export interface SessionLookupInfo {
agentjoinurl?: string;
}
export declare class AgentService {
protected Agent: any;
protected loginKeyParams: LoginKey;
protected auth: AuthParams;
protected sessionInfo: SessionLookupInfo | null;
protected scheduleLoginKeyRenewRef: number;
protected scheduleEndSessionCheck: number;
private openedWindow;
constructor(auth: AuthParams);
authWithLoginkey: (auth: AuthParams, regenerate?: boolean) => Promise<void>;
private defaultLogger;
defaultErrorHandler(error: Error, context?: string, userMessage?: string, defaultValue?: string, replacement?: string, hideError?: boolean): void;
getLoginkey: (auth: AuthParams) => Promise<LoginKey>;
get loginKey(): string;
get puid(): string;
get groupId(): string | number;
protected scheduleLoginKeyRenew: (regenerate?: boolean) => number;
handleEvents: () => void;
presenceFailedAuthorizationHandler: (payload: any) => Promise<boolean>;
getExpiration: (loginKey: string) => number;
authWithSaml: (idpid: string) => void;
private getEnvUrl;
private getSamlLoginKeyUrl;
private redirectToSamlLogin;
authWithSamlLoginKey: (idpid: string) => void;
authWithSamlPopup: (groupId: string, puid: string) => void;
setAgentListeners: (eventParams: EventListenerParams) => void;
connectPresence: (presence: PresenceParams) => Promise<void>;
disconnectPresence: () => Promise<void>;
cobrowseService: (join: JoinParams) => void;
cancelEndSessionCheck: () => void;
lookupService: (join: JoinParams) => Promise<string>;
lookupServiceCancel: () => void;
presenceStartSession: (sessionKey: string, acceptHandler: () => void, declineHandler: () => void) => Promise<void>;
presenceDisconnect: () => Promise<void>;
setPresenceVisitorId: (visitorId: string) => void;
registerEventsHandler: (handler: (eventName: string, eventData: unknown) => void) => void;
getBackendUrl: (path: string) => string;
checkSession: (sessionCode: string) => Promise<any>;
presenceEndSession: (visitorId: string) => Promise<void>;
cobrowseEndSession: (sessionCode: string) => Promise<void>;
hasAgentWindow: () => boolean;
closeAgentWindow: () => boolean;
openWindow: (url: string, params: string, closeHandler: (reason: {
reason: string;
}) => void) => void;
checkPermissions: (permissions: {
name: string;
expectedValue: unknown;
handler: (hasPermission: boolean) => void;
}[]) => void;
getPresenceJwtTokenClaims(): {};
}
export {};