@94ai/softphone 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarnrc.yml +19 -0
- package/README.md +941 -0
- package/bin/index.js +50 -0
- package/html-softphone-demo/CryptoJS.js +3 -0
- package/html-softphone-demo/README.md +10 -0
- package/html-softphone-demo/RootCA.pem +20 -0
- package/html-softphone-demo/antique_phone.mp3 +0 -0
- package/html-softphone-demo/cert.pem +21 -0
- package/html-softphone-demo/fp.umd.min.js +9 -0
- package/html-softphone-demo/gg.xccjh.top.key +27 -0
- package/html-softphone-demo/gg.xccjh.top.pem +61 -0
- package/html-softphone-demo/index-test.html +867 -0
- package/html-softphone-demo/index.html +845 -0
- package/html-softphone-demo/localhost.crt +21 -0
- package/html-softphone-demo/localhost.key +28 -0
- package/html-softphone-demo/pcm-player.js +131 -0
- package/html-softphone-demo/private.key +28 -0
- package/html-softphone-demo/softphone.umd.min.js +2 -0
- package/html-softphone-demo/tapd_35238004_base64_1695010473_859.gif +0 -0
- package/html-softphone-demo/test.html +190 -0
- package/html-softphone-demo.7z +0 -0
- package/lib/index.d.ts +531 -0
- package/lib/softphone.cjs.min.cjs +1 -0
- package/lib/softphone.esm-bundler.min.mjs +1 -0
- package/lib/softphone.umd.min.js +2 -0
- package/package.json +88 -0
- package/src/const/index.ts +120 -0
- package/src/index.ts +123 -0
- package/src/sdk/index.ts +1986 -0
- package/src/types/index.ts +343 -0
- package/src/utils/index.ts +301 -0
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@94ai/softphone",
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "94 Intelligent Technology Co., Ltd softphone SDK",
|
|
5
|
+
"main": "lib/softphone.cjs.min.cjs",
|
|
6
|
+
"module": "lib/softphone.esm-bundler.min.mjs",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"softphone-cli": "bin/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build:common": "cross-env BABEL_ENV=runtime rollup -c",
|
|
13
|
+
"build:umd": "cross-env rollup -c",
|
|
14
|
+
"build": "npm run build:common && npm run build:umd",
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://gitee.com/xccjh/open-softphone-demo"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"registry": "https://registry.npmjs.org",
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"94ai, 94 Intelligent Technology Co., Ltd, softphone SDK"
|
|
27
|
+
],
|
|
28
|
+
"author": "xccjh",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@babel/runtime-corejs3": "^7.21.0",
|
|
32
|
+
"@fingerprintjs/fingerprintjs": "^4.2.1",
|
|
33
|
+
"crypto-js": "4.1.1",
|
|
34
|
+
"on-change": "^4.0.2",
|
|
35
|
+
"sip.js": "^0.21.15"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@babel/runtime-corejs3": "^7.21.0",
|
|
39
|
+
"@fingerprintjs/fingerprintjs": "^4.2.1",
|
|
40
|
+
"crypto-js": "^4.2.2",
|
|
41
|
+
"on-change": "^4.0.2",
|
|
42
|
+
"sip.js": "^0.21.15"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@babel/core": "^7.21.4",
|
|
46
|
+
"@babel/plugin-transform-runtime": "^7.21.4",
|
|
47
|
+
"@babel/preset-env": "^7.21.4",
|
|
48
|
+
"@babel/runtime-corejs3": "^7.21.0",
|
|
49
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
50
|
+
"@types/crypto-js": "^4.2.2",
|
|
51
|
+
"cross-env": "7.0.3",
|
|
52
|
+
"eslint-define-config": "^1.16.0",
|
|
53
|
+
"rollup": "^3.18.0",
|
|
54
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
55
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
56
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
57
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
58
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
59
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
60
|
+
"typescript": "^4.9.5"
|
|
61
|
+
},
|
|
62
|
+
"babel": {
|
|
63
|
+
"presets": [
|
|
64
|
+
[
|
|
65
|
+
"@babel/env",
|
|
66
|
+
{
|
|
67
|
+
"modules": false
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
],
|
|
71
|
+
"env": {
|
|
72
|
+
"runtime": {
|
|
73
|
+
"plugins": [
|
|
74
|
+
[
|
|
75
|
+
"@babel/plugin-transform-runtime",
|
|
76
|
+
{
|
|
77
|
+
"corejs": {
|
|
78
|
+
"version": 3,
|
|
79
|
+
"proposals": true
|
|
80
|
+
},
|
|
81
|
+
"useESModules": true
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
|
|
2
|
+
import { UserAgent } from 'sip.js'
|
|
3
|
+
import type { UserAgentOptions } from 'sip.js/lib/api/user-agent-options'
|
|
4
|
+
import type { UserAgentStatus } from '../types'
|
|
5
|
+
|
|
6
|
+
export const viaHost = ''
|
|
7
|
+
export const extensionNumber = ''
|
|
8
|
+
export const extPassword = ''
|
|
9
|
+
export const wsProtocol = ''
|
|
10
|
+
export const wsRegisterAddress = ''
|
|
11
|
+
export const sipServerHost = `sip:${extensionNumber}@${wsRegisterAddress}`
|
|
12
|
+
export const wsAddress = `${wsProtocol}://${wsRegisterAddress}`
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 默认连接配置
|
|
16
|
+
*/
|
|
17
|
+
export const userAgentDefault: Partial<UserAgentOptions> = {
|
|
18
|
+
authorizationPassword: extPassword,
|
|
19
|
+
authorizationUsername: extensionNumber,
|
|
20
|
+
viaHost,
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
uri: UserAgent.makeURI(sipServerHost),
|
|
23
|
+
logLevel: 'error',
|
|
24
|
+
transportOptions: {
|
|
25
|
+
server: wsAddress
|
|
26
|
+
},
|
|
27
|
+
contactName: extensionNumber
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const userAgentStatus: UserAgentStatus = {
|
|
31
|
+
connectStatus: false,
|
|
32
|
+
registerStatus: false,
|
|
33
|
+
invitatingStatus: false,
|
|
34
|
+
incomingStatus: false,
|
|
35
|
+
answerStatus: false,
|
|
36
|
+
reconnectStatus: false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export enum AutoAnswer {
|
|
40
|
+
NO = '0',
|
|
41
|
+
YES = '1',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export enum PopWindow {
|
|
45
|
+
NO = '0',
|
|
46
|
+
YES = '1',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 外呼类型 */
|
|
50
|
+
export enum AiTaskVoiceType {
|
|
51
|
+
/**
|
|
52
|
+
* AI外呼
|
|
53
|
+
*/
|
|
54
|
+
MULTI_AI = '1',
|
|
55
|
+
/**
|
|
56
|
+
* 语音通知
|
|
57
|
+
*/
|
|
58
|
+
MULTI_VOICE_NOTIFY = '2',
|
|
59
|
+
/**
|
|
60
|
+
* 预测式外呼
|
|
61
|
+
*/
|
|
62
|
+
MULTI_PRETEST = '3',
|
|
63
|
+
/**
|
|
64
|
+
* 坐席人工外呼(快速外呼)
|
|
65
|
+
*/
|
|
66
|
+
LABOUR = '4',
|
|
67
|
+
/**
|
|
68
|
+
* 坐席AI外呼
|
|
69
|
+
*/
|
|
70
|
+
AI = '5',
|
|
71
|
+
/**
|
|
72
|
+
* 新语音通知
|
|
73
|
+
*/
|
|
74
|
+
NEW_VOICE_NOTIFY = '6'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 接听类型 */
|
|
78
|
+
export enum AfterTransferLabour {
|
|
79
|
+
/** 直接接听 */
|
|
80
|
+
DIRECT_ANSWER= '1',
|
|
81
|
+
/** 先监听后手动接听 */
|
|
82
|
+
LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY = '2'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 软电话业务属性 */
|
|
86
|
+
export type SoftphoneBusinessAttribute = Partial<{
|
|
87
|
+
/** sip签入头 */
|
|
88
|
+
sipRegisterMessage: Record<string, any>
|
|
89
|
+
/** 历史id */
|
|
90
|
+
cid: string
|
|
91
|
+
/** 用户明文手机号 */
|
|
92
|
+
userPhone: string
|
|
93
|
+
/** 转接后人工类型 (1:直接接听 2:先监听后手动接听) */
|
|
94
|
+
afterTransferLabour: AfterTransferLabour
|
|
95
|
+
popWindow: PopWindow
|
|
96
|
+
/** 话术名称 */
|
|
97
|
+
templateTitle: string
|
|
98
|
+
/** 最新节点名称 */
|
|
99
|
+
nodeTitle: string
|
|
100
|
+
/** 外呼号码编号 */
|
|
101
|
+
numberId: string
|
|
102
|
+
/** 任务名称 */
|
|
103
|
+
taskName: string
|
|
104
|
+
/** 当前通话唯一标识 */
|
|
105
|
+
callId: string
|
|
106
|
+
/** 任务Id */
|
|
107
|
+
taskId: string
|
|
108
|
+
/** 任务类型 */
|
|
109
|
+
voiceType: AiTaskVoiceType
|
|
110
|
+
/** 来电号码 */
|
|
111
|
+
phoneNumber: string
|
|
112
|
+
/** 整理中 */
|
|
113
|
+
processTime: string
|
|
114
|
+
/** 自动接听 */
|
|
115
|
+
autoAnswer: string
|
|
116
|
+
}>
|
|
117
|
+
|
|
118
|
+
export const APPLICATION_JSON = 'application/json; charset=UTF-8'
|
|
119
|
+
export const MULTIPART_FORM_DATA = 'multipart/form-data'
|
|
120
|
+
export const APPLICATION_FORM_URLENCODED = 'application/x-www-form-urlencoded; charset=UTF-8'
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Inviter,
|
|
3
|
+
Registerer,
|
|
4
|
+
SessionState,
|
|
5
|
+
URI,
|
|
6
|
+
UserAgent
|
|
7
|
+
} from 'sip.js'
|
|
8
|
+
import type { Invitation } from 'sip.js/lib/api/invitation'
|
|
9
|
+
import type { UserAgentDelegate } from 'sip.js/lib/api/user-agent-delegate'
|
|
10
|
+
import type { SessionDescriptionHandler } from 'sip.js/lib/api/session-description-handler'
|
|
11
|
+
import type { SessionByeOptions } from 'sip.js/lib/api/session-bye-options'
|
|
12
|
+
import type { RegistererUnregisterOptions } from 'sip.js/lib/api/registerer-unregister-options'
|
|
13
|
+
import type { RegistererRegisterOptions } from 'sip.js/lib/api/registerer-register-options'
|
|
14
|
+
import type { InvitationAcceptOptions } from 'sip.js/lib/api/invitation-accept-options'
|
|
15
|
+
import type { InvitationRejectOptions } from 'sip.js/lib/api/invitation-reject-options'
|
|
16
|
+
import type { RegistererOptions } from 'sip.js/lib/api/registerer-options'
|
|
17
|
+
import type { OutgoingRequest } from 'sip.js/lib/core/messages/outgoing-request'
|
|
18
|
+
import type { IncomingResponse } from 'sip.js/lib/core/messages/incoming-response'
|
|
19
|
+
import { SimpleUser } from 'sip.js/lib/platform/web/index.js'
|
|
20
|
+
import onChange from 'on-change'
|
|
21
|
+
import {
|
|
22
|
+
userAgentDefault,
|
|
23
|
+
userAgentStatus
|
|
24
|
+
} from './const'
|
|
25
|
+
import type {
|
|
26
|
+
HandUpInviteOption,
|
|
27
|
+
InviterInviteOptionsExtend as InviterInviteOptions,
|
|
28
|
+
PrepareUserAgentOptions,
|
|
29
|
+
RegisterOptions,
|
|
30
|
+
SessionInfoOptionsExtend as SessionInfoOptions,
|
|
31
|
+
UserAgentDelegateKey,
|
|
32
|
+
UserAgentOptions,
|
|
33
|
+
UserAgentStatusKey
|
|
34
|
+
} from './types'
|
|
35
|
+
import { requestMicroPhonePermission } from './utils'
|
|
36
|
+
import { UserAgentManager } from './sdk'
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 代理实例工厂
|
|
40
|
+
*/
|
|
41
|
+
export class UserAgentFactory {
|
|
42
|
+
static #userAgentManager: InstanceType<typeof UserAgentManager> | undefined
|
|
43
|
+
|
|
44
|
+
static getUserAgentManager (options: Partial<UserAgentOptions> = {}) {
|
|
45
|
+
if (!this.#userAgentManager) {
|
|
46
|
+
this.#userAgentManager = new UserAgentManager(options)
|
|
47
|
+
}
|
|
48
|
+
return this.#userAgentManager
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static hasUserAgentManager () {
|
|
52
|
+
return !!this.#userAgentManager
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static newUserAgentManager (options: Partial<UserAgentOptions> = {}) {
|
|
56
|
+
return new UserAgentManager(options)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static dispose() {
|
|
60
|
+
if (this.#userAgentManager) {
|
|
61
|
+
try {
|
|
62
|
+
this.#userAgentManager.dispose()
|
|
63
|
+
} catch {} finally {
|
|
64
|
+
this.#userAgentManager = undefined
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
UserAgentManager
|
|
72
|
+
} from './sdk'
|
|
73
|
+
export {
|
|
74
|
+
userAgentStatus,
|
|
75
|
+
userAgentDefault
|
|
76
|
+
} from './const'
|
|
77
|
+
export type {
|
|
78
|
+
UserAgentStatus,
|
|
79
|
+
TransportOptions
|
|
80
|
+
} from './types'
|
|
81
|
+
export {
|
|
82
|
+
getMedia,
|
|
83
|
+
playMedia,
|
|
84
|
+
pauseMedia,
|
|
85
|
+
cleanupMedia,
|
|
86
|
+
getTimes,
|
|
87
|
+
getZeorTime,
|
|
88
|
+
accumulateSec,
|
|
89
|
+
accumulationTimer,
|
|
90
|
+
requestMicroPhonePermission,
|
|
91
|
+
getDevicePermission,
|
|
92
|
+
stopStreamTracks
|
|
93
|
+
} from './utils'
|
|
94
|
+
export {
|
|
95
|
+
Inviter,
|
|
96
|
+
Registerer,
|
|
97
|
+
SessionState,
|
|
98
|
+
UserAgent,
|
|
99
|
+
URI,
|
|
100
|
+
onChange,
|
|
101
|
+
SimpleUser
|
|
102
|
+
}
|
|
103
|
+
export type {
|
|
104
|
+
UserAgentDelegateKey,
|
|
105
|
+
UserAgentStatusKey,
|
|
106
|
+
UserAgentOptions,
|
|
107
|
+
UserAgentDelegate,
|
|
108
|
+
Invitation,
|
|
109
|
+
SessionDescriptionHandler,
|
|
110
|
+
OutgoingRequest,
|
|
111
|
+
IncomingResponse,
|
|
112
|
+
InvitationAcceptOptions,
|
|
113
|
+
InvitationRejectOptions,
|
|
114
|
+
SessionByeOptions,
|
|
115
|
+
InviterInviteOptions,
|
|
116
|
+
RegistererUnregisterOptions,
|
|
117
|
+
RegistererOptions,
|
|
118
|
+
RegistererRegisterOptions,
|
|
119
|
+
SessionInfoOptions,
|
|
120
|
+
HandUpInviteOption,
|
|
121
|
+
RegisterOptions,
|
|
122
|
+
PrepareUserAgentOptions
|
|
123
|
+
}
|