Skip to content

Commit b29973b

Browse files
Version 0.0.10
1 parent 928b382 commit b29973b

2 files changed

Lines changed: 118 additions & 42 deletions

File tree

README.md

Lines changed: 117 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,77 @@
1-
2-
# Siperb-Provisioning JavaScript Library
1+
![Siperb](https://cdn.siperb.com/images/SIPERB-Logo-onlight.webp)
2+
3+
# SIPERB Provisioning
4+
5+
Open‑source Browser Phone / Web Phone SDK for WebRTC and VoIP — securely provision SIP sessions, devices, and credentials for SIP.js, JsSIP, and custom softphones.
6+
7+
[![License](https://img.shields.io/github/license/Siperb/Siperb-Provisioning?color=4c1)](https://github.com/Siperb/Siperb-Provisioning/blob/main/LICENSE)
8+
![Module formats](https://img.shields.io/badge/module-ESM%20%2B%20UMD-4c1)
9+
![Minified](https://img.shields.io/badge/minified-yes-4c1)
10+
[![CDN](https://img.shields.io/badge/CDN-available-blue)](#in-the-browser)
11+
![Node](https://img.shields.io/badge/Node-%3E%3D%2016-3178c6)
12+
13+
## Contents
14+
15+
- Overview
16+
- Features
17+
- Who is this for?
18+
- Quick Start
19+
- In the Browser (global)
20+
- As a Module (ESM)
21+
- Typical Usage Sequence
22+
- API Reference
23+
- Full Example
24+
- SIP.js and JsSIP Integration
25+
- Testing locally
26+
- Troubleshooting & FAQ
27+
- Notes
28+
- License
329

430
## Overview
531

6-
Siperb-Provisioning is a JavaScript library for securely retrieving user session, device, and provisioning information from the Siperb API. It is designed for use in both browser and module environments, supporting modern workflows and caching for performance.
32+
Siperb‑Provisioning is a lightweight JavaScript SDK that powers open‑source Web Phone / Browser Phone applications. It securely retrieves user session, devices, and SIP provisioning (username, password, domain, WSS/WebSocket) from the Siperb API so you can bootstrap a WebRTC softphone in minutes. Use it to initialize SIP.js, JsSIP, or your own VoIP client with consistent, secure provisioning flows — in both browser and module environments, with optional caching for performance.
33+
34+
## Features
35+
36+
- Modern dual build: ESM and UMD (minified)
37+
- Works in both browser (global `window.SiperbAPI`) and module projects
38+
- Simple promise-based API: Login → Devices → Provisioning
39+
- Optional caching with localStorage
40+
- Battle-tested examples with SIP.js and JsSIP
41+
- CDN-ready for quick prototypes and demos
42+
43+
## Who is this for?
44+
45+
- Teams building an open‑source Browser Phone or embedded Web Phone in SaaS/CRM
46+
- Developers integrating a WebRTC softphone (VoIP) using SIP.js or JsSIP
47+
- Contact centers and PWAs that need secure SIP provisioning over WSS
48+
- Anyone who wants a simple SDK to automate device provisioning and login flows
49+
- Projects migrating desk phone provisioning into a modern, browser‑based softphone
50+
51+
## Quick Start
52+
53+
### In the Browser
54+
Include the minified bundle from the CDN in your HTML:
55+
56+
```html
57+
<script src="https://cdn.siperb.com/lib/Siperb-Provisioning/Siperb-Provisioning-0.0.8.umd.min.js"></script>
58+
<script>
59+
// Now you can use window.SiperbAPI
60+
SiperbAPI.Login('YOUR_ACCESS_TOKEN').then(session => {
61+
console.log('Session:', session);
62+
});
63+
// Or: await SiperbAPI.Login(...) inside an async IIFE
64+
</script>
65+
```
66+
67+
### As a Module (ESM)
68+
69+
```js
70+
import Siperb from './dist/Siperb-Provisioning.esm.min.js';
71+
72+
const session = await Siperb.Login('YOUR_ACCESS_TOKEN');
73+
console.log(session.SessionToken, session.UserId);
74+
```
775

876
## Typical Usage Sequence
977

@@ -91,7 +159,7 @@ const provisioning = await Siperb.GetProvisioning({
91159
EnableCache: true,
92160
ProvisioningKey: 'SiperbProvisioning'
93161
});
94-
console.log(provisioning.SIPUsername, provisioning.SIPPassword);
162+
console.log(provisioning.SipUsername, provisioning.SipPassword);
95163
```
96164

97165
## Full Example: End-to-End Usage
@@ -130,8 +198,8 @@ async function main() {
130198
});
131199
console.log('Provisioning:', provisioning);
132200
// Example: Use SIP credentials
133-
console.log('SIP Username:', provisioning.SIPUsername);
134-
console.log('SIP Password:', provisioning.SIPPassword);
201+
console.log('SIP Username:', provisioning.SipUsername);
202+
console.log('SIP Password:', provisioning.SipPassword);
135203
} else {
136204
console.log('No devices found for provisioning.');
137205
}
@@ -145,7 +213,7 @@ main();
145213

146214
## SIP.js and JsSIP Integration Examples
147215

148-
### SIP.js Example
216+
### SIP.js Example (Module projects)
149217

150218
Install SIP.js:
151219
```sh
@@ -160,7 +228,7 @@ async function main() {
160228
// ...get session and provisioning as shown above...
161229

162230
// Build WebSocket server URL
163-
const wsServer = `wss://${provisioning.wssServer}:443/ws/`;
231+
const wsServer = `wss://${provisioning.SipWssServer}:${provisioning.SipWebsocketPort}/${provisioning.SipServerPath}`;
164232
const sipConfig = {
165233
uri: `sip:${provisioning.SipUsername}@${provisioning.SipDomain}`,
166234
authorizationUsername: provisioning.SipUsername,
@@ -187,7 +255,7 @@ async function main() {
187255
}
188256
```
189257

190-
### JsSIP Example
258+
### JsSIP Example (Browser friendly)
191259

192260
Install JsSIP:
193261
```sh
@@ -202,7 +270,7 @@ async function main() {
202270
// ...get session and provisioning as shown above...
203271

204272
// Build WebSocket server URL
205-
const wsServer = `wss://${provisioning.wssServer}:443/ws/`;
273+
const wsServer = `wss://${provisioning.SipWssServer}:${provisioning.SipWebsocketPort}/${provisioning.SipServerPath}`;
206274
const socket = new JsSIP.WebSocketInterface(wsServer);
207275
const configuration = {
208276
sockets: [socket],
@@ -236,40 +304,52 @@ These examples show how to:
236304
- **Browser & Module Support**: Works in both browser and modern JS module environments.
237305
- **Extensible**: Easily add more API calls or extend caching logic as needed.
238306

239-
## Notes
240-
- Always keep your access tokens secure and never expose them in client-side code unless you trust the environment.
241-
- The provisioning object may contain sensitive SIP credentials—handle with care.
307+
## Testing locally
242308

243-
## License
244-
See LICENSE file.
245-
# Siperb-Provisioning
246-
This project show how to Provision a Siperb Device and load Browser Phone, SIP.js JsSIP.js or your own custom Web-based SIP client.
309+
You can quickly try the included demo/test files in a local static server:
247310

248-
## Usage
311+
```sh
312+
python3 -m http.server 7777
313+
```
249314

315+
Then open these in your browser:
250316

251-
### In the Browser
252-
Include the minified bundle from the CDN in your HTML:
317+
- `http://localhost:7777/test-SIPJS.html` — SIP.js via browser with global `SIP` if you bundle it yourself; otherwise see JsSIP example
318+
- `http://localhost:7777/test-SIPJS.js` — referenced by the HTML (adjust as needed)
319+
- `http://localhost:7777/test-JSSIP.js` — JsSIP module example (or load JsSIP from CDN and use `window.JsSIP`)
253320

254-
```html
255-
<script src="https://cdn.siperb.com/lib/Siperb-Provisioning/Siperb-Provisioning-0.0.8.umd.min.js"></script>
256-
<script>
257-
// Now you can use window.SiperbAPI.Login()
258-
SiperbAPI.Login(PAT);
259-
</script>
260-
```
321+
Notes:
322+
- JsSIP offers a CDN UMD build you can load in a `<script>` tag:
323+
```html
324+
<script src="https://cdn.jsdelivr.net/npm/jssip@3/dist/jssip.min.js"></script>
325+
<script>
326+
const JsSIP = window.JsSIP;
327+
// ... use JsSIP here ...
328+
</script>
329+
```
330+
- SIP.js does not currently provide a stable ES module on CDN. Use it in module projects via npm (`import { UserAgent } from 'sip.js'`) or bundle it for the browser.
261331

262-
### As a Module (ESM/CommonJS)
332+
## Troubleshooting & FAQ
263333

264-
```js
265-
// ESM
266-
import Siperb from './dist/Siperb-Provisioning.esm.min.js';
267-
Siperb.Login(PAT);
334+
- Browser error: `Failed to resolve module specifier "sip.js"`
335+
- Cause: Trying to import SIP.js directly in the browser without bundling.
336+
- Fix: Use JsSIP via CDN for browser tests, or bundle SIP.js (Rollup/Webpack) for `<script type="module">` usage.
268337

269-
// CommonJS (if you bundle for Node.js)
270-
// const Siperb = require('./dist//Siperb-Provisioning.umd.min.js');
271-
// Siperb.Login(PAT);
272-
```
338+
- Node error: `WebSocket is not defined` when using SIP.js in Node
339+
- Cause: SIP.js expects a browser-like WebSocket. Node needs a WebSocket implementation.
340+
- Fix: Add a WebSocket polyfill (e.g., `npm i ws`) and wire it before constructing the UserAgent, or run the test in a browser.
341+
342+
- Mixed provisioning field names (SIPUsername vs SipUsername)
343+
- Use `SipUsername`, `SipPassword`, `SipDomain`, `SipWssServer`, `SipWebsocketPort`, `SipServerPath`, and `ContactUserName` consistently.
344+
345+
## Notes
346+
- Always keep your access tokens secure and never expose them in client-side code unless you trust the environment.
347+
- The provisioning object may contain sensitive SIP credentials—handle with care.
348+
349+
## License
350+
See LICENSE file.
351+
# Siperb-Provisioning
352+
This project show how to Provision a Siperb Device and load Browser Phone, SIP.js JsSIP.js or your own custom Web-based SIP client.
273353

274354
## Building, Running, and Compiling the Library
275355

@@ -301,8 +381,4 @@ This will create:
301381
- `./dist/Siperb-Provisioning.umd.min.js` (UMD for browser and Node.js)
302382
- `./dist/Siperb-Provisioning.esm.min.js` (ES module)
303383

304-
## Testing:
305-
Preview the provided test files, and modify as needed:
306-
```
307-
python3 -m http.server 7777
308-
```
384+
---

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.9
1+
0.0.10

0 commit comments

Comments
 (0)