2.8.3 • Published 9 months ago

@dstny/scp-sdk v2.8.3

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

SCP SDK

Install

npm i @dstny/scp-sdk

or

yarn add @dstny/scp-sdk

or

pnpm i @dstny/scp-sdk

🚀 Initialize

import { Connect } from '@dstny/scp-sdk'

const configuration = {
  mode: 'live',
  oauthUrl: 'https://oauth.connect.fuzer.net',
}

await Connect.init(configuration)

Configuration

AttributeTypeDefaultNotes
domain
loginMethod'oauth2' | 'smg'oauth2
smgAuthUrl
smgRealm
smgClientId
oauthUrl
oauthClientId
oauthAuthorizationRoute
oauthScope
apiUrl
secureStorage
mode'live' | 'mock' | 'dev'
logMode'silent' | 'info' | 'verbose'
softphone
auth
onError(error: unknown) => voidFunction is using for handling errors from SDK side.
It will receive string or Error object as parameter
export interface Configuration {
  defaultLogModule?: string
  defaultLoggerMetadata?: LoggerMetadata
  loggerFactory?: LoggerFactory
  domain?: string
  loginMethod?: LoginMethodType
  smgAuthUrl?: string
  smgRealm?: string
  smgClientId?: string
  oauthUrl?: string
  oauthClientId?: string
  oauthAuthorizationRoute?: string
  oauthScope?: string
  apiUrl?: string
  secureStorage?: () => SecureStorageHandler
  mode?: 'live' | 'mock' | 'dev'
  logMode?: LogLevel
  softphone?: SoftphoneOptions
  messaging?: MessagingOptions
  auth?: AuthOptions
  onError?: (error: unknown) => void
  gateways?: GatewayOptions
  apiOptions?: ApiOptions
}

🔐 Auth

Usage

import { Connect } from '@dstny/scp-sdk';

...

// Listen to authentication changes

const unsubscribe = Connect.auth.onAuthStateChanged((user: User) => {
  if(user){
    // Logged in
  } else {
    // Logged out
  }
})


// This will return oauth url to open in browser

Connect.auth.initOauth(returnUrl: string).then((url: string) => {

// open Url in browser > user login > get Authorization Code in the return url

})

...

const result = await Connect.auth.signIn("<authorizationCode>", "<redirectUri>")

...

Current user

import { Connect } from  '@dstny/scp-sdk';
...

const currentUser = Connect.auth.currentUser
await currentUser.setMood('Feeling good')

Methods

Methods NameArgsReturnsNotes
setStatusstatus: SetStatusDataPromise<void>
setMoodmood: stringPromise<void>

Events

import { Connect } from  '@dstny/scp-sdk';
...

const currentUser = Connect.auth.currentUser
const unsubscribe = currentUser.on(CONTACT_EVENT.ON_CONTACT_UPDATE, (user) => {

})

// To remove subsciption on current user contact events events call unsubscribe function

unsubscribe()
Event NameReturnsNotes
ON_CONTACT_UPDATEUser
ON_PRESENCE_UPDATEUser

Attributes

NametypeDefaultNotes
moodstring
photostring
availableStatusIStatusDefinition[][]
contactContact

📱 Softphone

import { Connect } from 'connect-sdk'

...

const softphone = Connect.softphone

...

const call = softphone.placeCall('+32494049494')

...

await call.hangup()

...

const unsub = softphone.onNewCall((call) => {
  await call.answer()
})

Softphone

Methods

Methods NameArgsReturnsNotes
placeCallnumber: string, callerIdName = 'Unknown'Promise<Call>
answerCalluuid: stringPromise<void>@deprecated Please use Call.answer
endCalluuid: stringPromise<void>deprecated Please Use Call.hangup

Events

Event NameArgsReturnsNotes
onNewCallcb: (call: Call) => void() => void
onCallEstablishedcb: (call: Call) => void() => void
onCallsUpdatecb: (calls: Call[]) => void() => void
onSipRegisteredcb: () => void() => void
onSipUnRegisteredcb: () => void() => void

Attributes

NametypeDefaultNotes
calls{[uuid: string]: Call}[]
currentCallCallundefined
peopleInConferenceContact[][]
audioManagerAudioManager

Call object

Methods

Methods NameArgsReturnsNotes
answerPromise<void>
hangupPromise<void>
attendedTransfercall: CallPromise<void>
blindTransfernumber: stringPromise<void>
addToConferencePromise<void>
holdPromise<void>
unHoldPromise<void>
toggleMute
sendDTMFdtmf:DTMFPromise<void>

Events

.....

const unsubscribe = call.on(CALL_EVENT.ON_CALL_INFO_UPDATE,(call)=>{

})

// To remove subsciption on call events call unsubscribe function

unsubscribe()
Event NameReturnsNotes
ON_CALL_ANSWERCall
ON_CALL_HANGUPCall
ON_CALL_INFO_UPDATECall
ON_CALL_HOLDCall
ON_CALL_UNHOLDCall
ON_CALL_MUTEDCall
ON_CALL_UNMUTEDCall
ON_CALL_ESTABLISHEDCall
ON_CALL_QUALITY_UPDATECallQuality

Attributes

NametypeDefaultNotes
contactContactundefined
isTransfertbooleabfalse
isOutGoingbooleanfalse
isRemotebooleanfalse
callIdstring
channelChannelsChannelsundefined
callerNamestring
callerNumstring
mutedbooleanfalse
transferableboolean
inConferencebooleanfalse
peopleInConferenceContact [][]

🗂 Directory

Usage

import { Connect } from 'connectme-sdk'

...

const directory = Connect.directory
const contactList = await directory.getContactList()

...

 await directory.onContactSelectedFromSearch(contactsResult[index].uid)

...

 const contacts = await directory.search(_query)

Methods

Methods NameArgsReturnsNotes
searchquery: stringPromise<Contact[]>
getSearchHistoryPromise<Contact[]>
onContactSelectedFromSearchuid: stringPromise<void>
getContactuid: stringPromise<Contact | undefined>
getContactByNumberphoneNumber: stringPromise<Contact | undefined>
getGroupsPromise<Group[]>
getAllContactPromise<Contact[]>
getAvailableContactFirstLetterPromise<ContactAlphabet>
addToFavoritecontact: ContactPromise<void>
getContactListPromise<Contact[]>
removeToFavoritecontact: ContactPromise<void>
addToVipcontact: ContactPromise<void>
removeFromVipcontact: ContactPromise<void>
blockcontact: ContactPromise<void>
unBlockcontact: ContactPromise<void>
deleteContactuid: stringPromise<void>
reOrderGroupsgroupId: string, fromIndex: number, toIndex: numberPromise<void>
addToFavoritecontact: ContactPromise<void>

Events

import { Connect } from  'connectme-sdk';
...

const directory = Connect.directory
const unsubscribe = directory.on(DIRECTORY_EVENT.ON_DIRECTORY_UPDATE, (user) => {

})

// To remove subsciption on directory events call unsubscribe function

unsubscribe()
Event NameReturnsNotes
ON_CONTACT_UPDATEContact
ON_DIRECTORY_UPDATEContact[]
ON_CONTACT_DELETEUser
ON_GROUPS_UPDATEGroup[]

Attributes

NametypeDefaultNotes
groupsGroup[][]

Contact object

Methods

Methods NameArgsReturnsNotes
subscribecb: (contact: Contact) => void() => void

Events

.....

const unsubscribe = contact.on(CONTACT_EVENT.ON_CONTACT_UPDATE, (contact) => {

})

// To remove subsciption on contact events call unsubscribe function
unsubscribe()
Event NameReturnsNotes
ON_CONTACT_UPDATEContact
ON_PRESENCE_UPDATEContact

Attributes

See => Contact source code

📣 Gateway

Gateway Documentation

📣 Application Storage

Application Storage

2.8.3

9 months ago

2.8.2

9 months ago

2.8.1

9 months ago

2.8.0

9 months ago

2.7.0

9 months ago

2.5.2

10 months ago

2.6.0

10 months ago

2.5.1

10 months ago

2.5.0

10 months ago

2.4.1

11 months ago

2.4.0

11 months ago

2.3.2

11 months ago

2.3.1

11 months ago

2.3.0

11 months ago

2.2.1

12 months ago

2.2.0

12 months ago

2.1.0

12 months ago

2.0.1

1 year ago

2.0.0

1 year ago