@bravophone/webphone 0.2.1 → 0.4.0
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/README.md +125 -14
- package/dist/bravophone.mjs +334 -295
- package/dist/bravophone.umd.js +38 -19
- package/host/js/bravophone-route-selector.js +1 -1
- package/host/popup.js +3 -3
- package/host/shim/guest-bridge.js +23 -7
- package/package.json +5 -3
- package/types/index.d.ts +23 -2
|
@@ -134,21 +134,37 @@
|
|
|
134
134
|
|
|
135
135
|
// --- comandos aceitos do site hospedeiro ---
|
|
136
136
|
var commands = {
|
|
137
|
+
// As chaves saem do bpSaveSession do bundle — é ele quem define os nomes.
|
|
138
|
+
// Gravar 'vxToken' não serve para nada: ninguém lê essa chave.
|
|
137
139
|
auth: function (p) {
|
|
138
|
-
|
|
139
|
-
if (!
|
|
140
|
+
var s = (p && p.session) || (p && p.token ? { vxToken: p.token } : null)
|
|
141
|
+
if (!s || !s.vxToken) throw new Error('sessão ausente (precisa ao menos de vxToken)')
|
|
142
|
+
|
|
143
|
+
var dados = {
|
|
144
|
+
bravophoneVxToken: s.vxToken,
|
|
145
|
+
bravophoneVxTokenExpiresAt: s.expiresIn
|
|
146
|
+
? Date.now() + 1000 * Number(s.expiresIn) : null,
|
|
147
|
+
bravophoneSip: s.sip || null,
|
|
148
|
+
bravophoneTenant: s.tenant || null,
|
|
149
|
+
bravophoneRamal: s.ramal || null,
|
|
150
|
+
bravophoneClienteId: s.clienteId || null,
|
|
151
|
+
bravophoneRamaisUrl: s.ramaisUrl || null,
|
|
152
|
+
}
|
|
153
|
+
Object.keys(dados).forEach(function (k) { if (dados[k] === null) delete dados[k] })
|
|
154
|
+
|
|
140
155
|
return new Promise(function (resolve) {
|
|
141
|
-
chrome.storage.local.set(
|
|
142
|
-
|
|
156
|
+
chrome.storage.local.set(dados, function () {
|
|
157
|
+
resolve({ ok: true, chaves: Object.keys(dados).length })
|
|
143
158
|
})
|
|
144
159
|
})
|
|
145
160
|
},
|
|
146
161
|
|
|
147
162
|
logout: function () {
|
|
163
|
+
var CHAVES = ['bravophoneVxToken', 'bravophoneVxTokenExpiresAt', 'bravophoneSip',
|
|
164
|
+
'bravophoneTenant', 'bravophoneRamal', 'bravophoneClienteId',
|
|
165
|
+
'bravophoneRamaisUrl']
|
|
148
166
|
return new Promise(function (resolve) {
|
|
149
|
-
chrome.storage.local.remove(
|
|
150
|
-
chrome.storage.sync.remove(['vxToken'], function () { resolve({ ok: true }) })
|
|
151
|
-
})
|
|
167
|
+
chrome.storage.local.remove(CHAVES, function () { resolve({ ok: true }) })
|
|
152
168
|
})
|
|
153
169
|
},
|
|
154
170
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bravophone/webphone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Webphone BRAVOPHONE embutível em qualquer página web. Renderiza uma janela flutuante arrastável com todas as funcionalidades do softphone.",
|
|
5
5
|
"main": "./dist/bravophone.umd.js",
|
|
6
6
|
"module": "./dist/bravophone.mjs",
|
|
@@ -27,11 +27,13 @@
|
|
|
27
27
|
"dev": "node scripts/dev-server.mjs",
|
|
28
28
|
"build": "vite build",
|
|
29
29
|
"build:host": "npm run sync && vite build --config vite.host.config.js",
|
|
30
|
-
"test": "node scripts/smoke-shim.mjs && node scripts/smoke-geometry.mjs && node scripts/smoke-launcher.mjs && node scripts/smoke-package.mjs",
|
|
30
|
+
"test": "node scripts/smoke-shim.mjs && node scripts/smoke-geometry.mjs && node scripts/smoke-launcher.mjs && node scripts/smoke-sessao.mjs && node scripts/smoke-package.mjs",
|
|
31
31
|
"start": "node scripts/dev-server.mjs",
|
|
32
32
|
"audit:theme": "node scripts/audit-theme.mjs",
|
|
33
33
|
"prepublishOnly": "npm run build && npm test",
|
|
34
|
-
"prepare:host": "node scripts/sync-from-extension.mjs --cdn"
|
|
34
|
+
"prepare:host": "node scripts/sync-from-extension.mjs --cdn",
|
|
35
|
+
"purge": "node scripts/purge-cdn.mjs",
|
|
36
|
+
"postpublish": "node scripts/purge-cdn.mjs"
|
|
35
37
|
},
|
|
36
38
|
"keywords": [
|
|
37
39
|
"webphone",
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
export type LauncherIcon = 'phone-waves' | 'waveform' | 'headset' | 'chat-phone'
|
|
2
2
|
|
|
3
|
+
/** Resposta do `/api/voxfree/login`, repassada como está. */
|
|
4
|
+
export interface BravophoneSession {
|
|
5
|
+
vxToken: string
|
|
6
|
+
/** Segundos até expirar; vira `bravophoneVxTokenExpiresAt`. */
|
|
7
|
+
expiresIn?: number
|
|
8
|
+
sip?: string
|
|
9
|
+
tenant?: string
|
|
10
|
+
ramal?: string
|
|
11
|
+
clienteId?: string
|
|
12
|
+
ramaisUrl?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export interface BravophoneOptions {
|
|
4
16
|
/** Origem do webphone hospedado. Só usado com `mode: 'hosted'`. */
|
|
5
17
|
hostUrl?: string
|
|
@@ -23,7 +35,16 @@ export interface BravophoneOptions {
|
|
|
23
35
|
* assets de um espelho próprio.
|
|
24
36
|
*/
|
|
25
37
|
hostBase?: string
|
|
26
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Sessão do `/api/voxfree/login`, repassada inteira. É o caminho correto:
|
|
40
|
+
* o webphone precisa de `sip` e `ramal` para registrar.
|
|
41
|
+
*/
|
|
42
|
+
session?: BravophoneSession
|
|
43
|
+
/**
|
|
44
|
+
* Atalho para `{ vxToken: token }`. **Sozinho não basta** — sem `sip` e
|
|
45
|
+
* `ramal` o webphone carrega, não registra, e o RouteSelector avisa
|
|
46
|
+
* "faça login pelo webphone".
|
|
47
|
+
*/
|
|
27
48
|
token?: string
|
|
28
49
|
/** Canto inicial da janela. Padrão: 'bottom-right'. */
|
|
29
50
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
|
|
@@ -155,7 +176,7 @@ export interface BravophoneAPI {
|
|
|
155
176
|
sendDTMF(tone: string): Promise<{ ok: true }>
|
|
156
177
|
transfer(to: string): Promise<{ ok: true }>
|
|
157
178
|
getStatus(): Promise<PhoneStatus>
|
|
158
|
-
setAuth(
|
|
179
|
+
setAuth(session: BravophoneSession | string): Promise<{ ok: true }>
|
|
159
180
|
logout(): Promise<{ ok: true }>
|
|
160
181
|
|
|
161
182
|
on<K extends keyof BravophoneEvents>(
|