2.8.3 • Published 9 months ago
@dstny/scp-sdk v2.8.3
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
Attribute | Type | Default | Notes |
---|---|---|---|
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) => void | Function 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 Name | Args | Returns | Notes |
---|---|---|---|
setStatus | status: SetStatusData | Promise<void> | |
setMood | mood: string | Promise<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 Name | Returns | Notes |
---|---|---|
ON_CONTACT_UPDATE | User | |
ON_PRESENCE_UPDATE | User |
Attributes
Name | type | Default | Notes |
---|---|---|---|
mood | string | ||
photo | string | ||
availableStatus | IStatusDefinition[] | [] | |
contact | Contact |
📱 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 Name | Args | Returns | Notes |
---|---|---|---|
placeCall | number: string, callerIdName = 'Unknown' | Promise<Call> | |
answerCall | uuid: string | Promise<void> | @deprecated Please use Call.answer |
endCall | uuid: string | Promise<void> | deprecated Please Use Call.hangup |
Events
Event Name | Args | Returns | Notes |
---|---|---|---|
onNewCall | cb: (call: Call) => void | () => void | |
onCallEstablished | cb: (call: Call) => void | () => void | |
onCallsUpdate | cb: (calls: Call[]) => void | () => void | |
onSipRegistered | cb: () => void | () => void | |
onSipUnRegistered | cb: () => void | () => void |
Attributes
Name | type | Default | Notes |
---|---|---|---|
calls | {[uuid: string]: Call} | [] | |
currentCall | Call | undefined | |
peopleInConference | Contact[] | [] | |
audioManager | AudioManager |
Call object
Methods
Methods Name | Args | Returns | Notes |
---|---|---|---|
answer | Promise<void> | ||
hangup | Promise<void> | ||
attendedTransfer | call: Call | Promise<void> | |
blindTransfer | number: string | Promise<void> | |
addToConference | Promise<void> | ||
hold | Promise<void> | ||
unHold | Promise<void> | ||
toggleMute | |||
sendDTMF | dtmf:DTMF | Promise<void> |
Events
.....
const unsubscribe = call.on(CALL_EVENT.ON_CALL_INFO_UPDATE,(call)=>{
})
// To remove subsciption on call events call unsubscribe function
unsubscribe()
Event Name | Returns | Notes |
---|---|---|
ON_CALL_ANSWER | Call | |
ON_CALL_HANGUP | Call | |
ON_CALL_INFO_UPDATE | Call | |
ON_CALL_HOLD | Call | |
ON_CALL_UNHOLD | Call | |
ON_CALL_MUTED | Call | |
ON_CALL_UNMUTED | Call | |
ON_CALL_ESTABLISHED | Call | |
ON_CALL_QUALITY_UPDATE | CallQuality |
Attributes
Name | type | Default | Notes |
---|---|---|---|
contact | Contact | undefined | |
isTransfert | booleab | false | |
isOutGoing | boolean | false | |
isRemote | boolean | false | |
callId | string | ||
channel | Channels | Channels | undefined |
callerName | string | ||
callerNum | string | ||
muted | boolean | false | |
transferable | boolean | ||
inConference | boolean | false | |
peopleInConference | Contact [] | [] |
🗂 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 Name | Args | Returns | Notes |
---|---|---|---|
search | query: string | Promise<Contact[]> | |
getSearchHistory | Promise<Contact[]> | ||
onContactSelectedFromSearch | uid: string | Promise<void> | |
getContact | uid: string | Promise<Contact | undefined> | |
getContactByNumber | phoneNumber: string | Promise<Contact | undefined> | |
getGroups | Promise<Group[]> | ||
getAllContact | Promise<Contact[]> | ||
getAvailableContactFirstLetter | Promise<ContactAlphabet> | ||
addToFavorite | contact: Contact | Promise<void> | |
getContactList | Promise<Contact[]> | ||
removeToFavorite | contact: Contact | Promise<void> | |
addToVip | contact: Contact | Promise<void> | |
removeFromVip | contact: Contact | Promise<void> | |
block | contact: Contact | Promise<void> | |
unBlock | contact: Contact | Promise<void> | |
deleteContact | uid: string | Promise<void> | |
reOrderGroups | groupId: string, fromIndex: number, toIndex: number | Promise<void> | |
addToFavorite | contact: Contact | Promise<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 Name | Returns | Notes |
---|---|---|
ON_CONTACT_UPDATE | Contact | |
ON_DIRECTORY_UPDATE | Contact[] | |
ON_CONTACT_DELETE | User | |
ON_GROUPS_UPDATE | Group[] |
Attributes
Name | type | Default | Notes |
---|---|---|---|
groups | Group[] | [] |
Contact object
Methods
Methods Name | Args | Returns | Notes |
---|---|---|---|
subscribe | cb: (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 Name | Returns | Notes |
---|---|---|
ON_CONTACT_UPDATE | Contact | |
ON_PRESENCE_UPDATE | Contact |
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