Home Reference Source

src/Sippo.ts

import 'webrtc-adapter';

import {Session} from './session/Session';
import {SessionConfig} from './session/SessionConfig';

/**
 * Factory method for session creation
 * @param {string} issuer The authorization token issuer identifier
 * @param {string} token The authorization token from the given issuer.
 * @param {Object} config Session configuration
 * @param {string} config.wacUri The address where the WAC is available
 * @param {string} config.applicationToken A token for the application
 * @param {string} config.deviceId string which identifies the device this session belongs to
 * @return {Promise<Session>} A promise of a new SippoJS session
 */
export async function createSession(issuer: string, token: string, config: SessionConfig): Promise<Session> {
	const session = Session.withOAuth2(issuer, token, config);
	return Promise.resolve(session);
}

/**
 * Factory method for anonymous user session creation
 * @param {string} issuer The authorization token issuer identifier
 * @param {Object} config Session configuration
 * @param {string} config.wacUri The address where the WAC is available
 * @param {string} config.applicationToken A token for the application
 * @param {string} config.deviceId string which identifies the device this session belongs to
 * @return {Promise<Session>} A promise of a new SippoJS session
 */
export async function createAnonymousSession(issuer: string, config: SessionConfig): Promise<Session> {
	const session = Session.withoutToken(issuer, config);
	return Promise.resolve(session);
}

/**
 * Factory method for session recovery
 * @param {string} token The authorization token
 * @param {Object} config Session configuration
 * @param {string} config.wacUri The address where the WAC is available
 * @param {string} config.applicationToken A token for the application
 * @param {string} config.deviceId string which identifies the device this session belongs to
 * @return {Promise<Session>} A promise of a new SippoJS session
 */
export async function recoverSession(token: string, config: SessionConfig): Promise<Session> {
	const session = Session.withSessionToken(token, config);
	return Promise.resolve(session);
}

/**
 * Allows obtaining the available providers enabled in the specified WAC instance
 * @param {string} wacUri The address where the WAC is available
 * @return {Promise<ProviderInfo[]>} A promise with an array with information for each provider
 */
export async function getAuthProviders(wacUri: string): Promise<AuthProvider[]> {
	return window.fetch(`${wacUri}/sapi/oauth2/providers`).then(async response => response.json());
}

export interface AuthProvider {
	authorization_endpoint: string;
	displayName: string;
	grant_type: string;
	id: string;
	revocation_endpoint: string;
	scope: string;
	signout_endpoint?: string;
	token_endpoint?: string;
	tokenInfo: string;
	uid: string;
	uidType: string;
}

export * from './calls/Call';
export * from './calls/CallDirection';
export * from './calls/CallEndReason';
export * from './calls/CallLog';
export * from './calls/CallLogEntry';
export * from './calls/CallManager';
export * from './calls/CallRemoteRecorder';
export * from './calls/CallStatus';
export * from './calls/RemoteCall';

export * from './chat/Chat';
export * from './chat/ChatManager';
export * from './chat/ChatMessage';
export * from './chat/ChatMessageDirection';
export * from './chat/ChatMessageFile';
export * from './chat/ChatMessageStatus';
export * from './chat/ChatMessageType';
export * from './chat/ChatParticipantRole';
export * from './chat/ChatParticipantState';
export * from './chat/ChatType';
export * from './chat/SupportChat';

export * from './conferences/Conference';
export * from './conferences/ConferenceEndReason';
export * from './conferences/ConferenceInvite';
export * from './conferences/ConferenceLog';
export * from './conferences/ConferenceLogEntry';
export * from './conferences/ConferenceManager';
export * from './conferences/ConferenceStatus';
export * from './conferences/Invitation';
export * from './conferences/errors/AccessBeforeTimeError';
export * from './conferences/errors/WrongPasswordError';

export * from './contacts/Contact';
export * from './contacts/ContactManager';
export * from './contacts/OwnPresence';
export * from './contacts/Presence';
export * from './contacts/PresenceActivity';
export * from './contacts/PresenceMood';

export * from './contacts-new/AddressType';
export type {Contact as ContactNg} from './contacts-new/Contact';
export * from './contacts-new/ContactRepository';
export * from './contacts-new/ContactType';
export * from './contacts-new/Email';
export * from './contacts-new/Phone';

export * from './datapipe/DataPipe';
export * from './datapipe/DataPipeStatus';
export * from './datapipe/DataPipeType';

export * from './file-sharing/FileManager';
export * from './file-sharing/FileUpload';
export * from './file-sharing/FileUploadManager';
export * from './file-sharing/FileUploadStatus';

export * from './groups/Group';
export * from './groups/GroupManager';

export * from './instant-messages/InstantMessage';
export * from './instant-messages/InstantMessageType';

export * from './media/ManagedStream';
export * from './media/LocalMediaHandler';
export * from './media/StreamRecorder';
export * from './media/StreamRecorderStatus';

export * from './meetings/Meeting';
export * from './meetings/MeetingManager';
export * from './meetings/MeetingParticipant';

export * from './permissions/PermissionManager';

export * from './session/RemoteSession';
export * from './session/Session';
export * from './session/SessionConfig';
export * from './session/SessionError';
export * from './session/SessionStatus';
export * from './session/User';

export * from './users/UserManager';

export {Presence as PresenceNg} from './users-new/Presence';
export type {PresenceActivity as PresenceActivityNg} from './users-new/PresenceActivity';
export type {PresenceMood as PresenceMoodNg} from './users-new/PresenceMood';
export * from './users-new/PresenceState';
export type {User as UserNg} from './users-new/User';
export * from './users-new/UserRepository';
export * from './users-new/UserRole';

export * from './utils/scaleImage';

export * from './voice-mail/VoiceMailManager';

export * from './whiteboard/Whiteboard';

export * from './types';