@wazo/sdk 0.43.13 → 0.43.15
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 +84 -57
- package/dist/wazo-sdk.js +2 -2
- package/esm/api-client.js +7 -132
- package/esm/base-api-client.js +125 -0
- package/esm/constants.js +11 -0
- package/esm/domain/CallLog.js +4 -1
- package/esm/domain/__tests__/CallLog.test.js +11 -0
- package/esm/index.js +1 -0
- package/esm/service/__tests__/getApiclient.test.js +37 -0
- package/esm/service/getApiClient.js +8 -6
- package/esm/types/api-client.d.ts +3 -41
- package/esm/types/api-client.d.ts.map +1 -1
- package/esm/types/base-api-client.d.ts +43 -0
- package/esm/types/base-api-client.d.ts.map +1 -0
- package/esm/types/constants.d.ts +12 -0
- package/esm/types/constants.d.ts.map +1 -0
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/service/__tests__/getApiclient.test.d.ts +2 -0
- package/esm/types/service/__tests__/getApiclient.test.d.ts.map +1 -0
- package/esm/types/service/getApiClient.d.ts +5 -2
- package/esm/types/service/getApiClient.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/utils/api-requester.js +0 -1
- package/lib/api-client.js +17 -144
- package/lib/base-api-client.js +133 -0
- package/lib/constants.js +14 -0
- package/lib/domain/CallLog.js +4 -1
- package/lib/domain/__tests__/CallLog.test.js +3 -0
- package/lib/index.js +3 -1
- package/lib/service/__tests__/getApiclient.test.js +42 -0
- package/lib/service/getApiClient.js +8 -6
- package/lib/types/api-client.d.ts +3 -41
- package/lib/types/api-client.d.ts.map +1 -1
- package/lib/types/base-api-client.d.ts +43 -0
- package/lib/types/base-api-client.d.ts.map +1 -0
- package/lib/types/constants.d.ts +12 -0
- package/lib/types/constants.d.ts.map +1 -0
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/service/__tests__/getApiclient.test.d.ts +2 -0
- package/lib/types/service/__tests__/getApiclient.test.d.ts.map +1 -0
- package/lib/types/service/getApiClient.d.ts +5 -2
- package/lib/types/service/getApiClient.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/utils/api-requester.js +0 -1
- package/package.json +1 -1
- package/src/api-client.ts +20 -188
- package/src/base-api-client.ts +184 -0
- package/src/constants.ts +11 -0
- package/src/domain/CallLog.ts +4 -1
- package/src/domain/__tests__/CallLog.test.ts +12 -0
- package/src/index.ts +1 -0
- package/src/service/__tests__/getApiclient.test.ts +46 -0
- package/src/service/getApiClient.ts +15 -8
- package/src/utils/api-requester.ts +0 -1
package/README.md
CHANGED
|
@@ -146,9 +146,9 @@ Wazo's Javascript SDK allows you to use these features :
|
|
|
146
146
|
- [Listening for event](#listening-for-event)
|
|
147
147
|
- [Updating the user token](#updating-the-user-token)
|
|
148
148
|
- [Closing the socket](#closing-the-socket)
|
|
149
|
-
|
|
150
|
-
## Install
|
|
151
|
-
|
|
149
|
+
|
|
150
|
+
## Install
|
|
151
|
+
|
|
152
152
|
### Install / Add
|
|
153
153
|
**`Voice`** **`Video`** **`Chat`** **`Fax`** **`Status`** **`Config`** **`Misc`**
|
|
154
154
|
|
|
@@ -181,7 +181,7 @@ import Wazo from '@wazo/sdk';
|
|
|
181
181
|
// Browser
|
|
182
182
|
// You can access the `Wazo` object directly on the browser, simply include it in the html :
|
|
183
183
|
<script src="https://unpkg.com/@wazo/sdk/dist/wazo-sdk.js"></script>
|
|
184
|
-
or
|
|
184
|
+
or
|
|
185
185
|
<script src="https://cdn.jsdelivr.net/npm/@wazo/sdk"></script>
|
|
186
186
|
```
|
|
187
187
|
|
|
@@ -193,17 +193,17 @@ Wazo.Auth.init(clientId, tokenExpiration, minSubscriptionType, authorizationName
|
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
- `clientId`: string (optional)
|
|
196
|
-
- An identifier of your application that will be used to refresh users token
|
|
197
|
-
|
|
196
|
+
- An identifier of your application that will be used to refresh users token
|
|
197
|
+
|
|
198
198
|
- `tokenExpiration`: number (optional, default 3600 seconds)
|
|
199
|
-
- Duration before token expiration (in seconds)
|
|
200
|
-
|
|
199
|
+
- Duration before token expiration (in seconds)
|
|
200
|
+
|
|
201
201
|
- `minSubscriptionType`: number (optional)
|
|
202
202
|
- Defines the minimum user subscription type that allows access to your application.
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
- `authorizationName`: string (optional)
|
|
205
205
|
- Defines the name of the authorization the user should have to ba able to login.
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
#### Setting the engine host
|
|
208
208
|
|
|
209
209
|
```js
|
|
@@ -289,7 +289,7 @@ const session = await Wazo.Auth.validateToken(token, refreshToken);
|
|
|
289
289
|
|
|
290
290
|
- `token`: string
|
|
291
291
|
- User's token to validate (eg: makes sure the token is valid and not expired).
|
|
292
|
-
|
|
292
|
+
|
|
293
293
|
- `refreshToken`: string (optional)
|
|
294
294
|
- User's refresh token, used to generate a new token if expired.
|
|
295
295
|
|
|
@@ -328,10 +328,10 @@ Wazo.Room.connect(options);
|
|
|
328
328
|
- `options`: Object
|
|
329
329
|
- `extension`: string
|
|
330
330
|
The room extension (number) you want to join
|
|
331
|
-
- `audio`: boolean|Object
|
|
331
|
+
- `audio`: boolean|Object
|
|
332
332
|
A boolean, if you want to send the user audio or not; or an Object, if you want to specify the audio input, etc...
|
|
333
|
-
See [getUserMedia arguments](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) for more information.
|
|
334
|
-
- `video`: boolean|Object
|
|
333
|
+
See [getUserMedia arguments](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) for more information.
|
|
334
|
+
- `video`: boolean|Object
|
|
335
335
|
A boolean, if you want to send the user video or not; or an Object, if you want to specify the audio input, etc...
|
|
336
336
|
See [getUserMedia arguments](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) for more information.
|
|
337
337
|
- `extra`: Object
|
|
@@ -347,7 +347,7 @@ room.sendChat(content);
|
|
|
347
347
|
|
|
348
348
|
- `content`: string
|
|
349
349
|
The chat message content you want to send to all participants in the room.
|
|
350
|
-
|
|
350
|
+
|
|
351
351
|
#### Sending a custom message to all participants
|
|
352
352
|
|
|
353
353
|
```js
|
|
@@ -356,15 +356,15 @@ room.sendSignal(content);
|
|
|
356
356
|
|
|
357
357
|
- `content`: string
|
|
358
358
|
The message content you want to send to all participants in the room.
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
#### Sharing the user screen
|
|
361
361
|
|
|
362
362
|
```js
|
|
363
363
|
room.startScreenSharing(constraints);
|
|
364
364
|
```
|
|
365
365
|
|
|
366
|
-
- `constraints`: Object
|
|
367
|
-
See [getUserMedia arguments](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) for more information.
|
|
366
|
+
- `constraints`: Object
|
|
367
|
+
See [getUserMedia arguments](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) for more information.
|
|
368
368
|
|
|
369
369
|
#### Stopping the screen share
|
|
370
370
|
|
|
@@ -469,9 +469,9 @@ Triggered when a participant is talking or stops talking.
|
|
|
469
469
|
- `channel`: Object containing information about the event.
|
|
470
470
|
- `participant`: `Wazo.RemoteParticipant` or `Wazo.LocalParticipant`.
|
|
471
471
|
The participant instance, you can access the `participant.isTalking` attribute to know the status.
|
|
472
|
-
|
|
472
|
+
|
|
473
473
|
### Ad hoc Conference features
|
|
474
|
-
**`Voice`** **`Video`**
|
|
474
|
+
**`Voice`** **`Video`**
|
|
475
475
|
|
|
476
476
|
#### Merging sessions in one conference
|
|
477
477
|
Use this method to merge multiple calls in a new ad hoc conference.
|
|
@@ -497,7 +497,7 @@ Use this method to terminate a conference.
|
|
|
497
497
|
```js
|
|
498
498
|
adHocConference.hangup();
|
|
499
499
|
```
|
|
500
|
-
|
|
500
|
+
|
|
501
501
|
### Accessing the current WebRtc phone
|
|
502
502
|
|
|
503
503
|
You can access the current [webRtcPhone instance](#WebRTCPhone) via `Wazo.Phone.phone`.
|
|
@@ -512,32 +512,32 @@ You can access all Wazo's domain objects in `Wazo.domain.*`, like `Wazo.domain.S
|
|
|
512
512
|
|
|
513
513
|
- `uuid`: string
|
|
514
514
|
The participant uuid.
|
|
515
|
-
|
|
515
|
+
|
|
516
516
|
- `name`: string
|
|
517
517
|
The participant name, retrieved from the sip configuration.
|
|
518
|
-
|
|
518
|
+
|
|
519
519
|
- `isTalking`: boolean
|
|
520
520
|
Indicates if the participant is currently talking.
|
|
521
|
-
|
|
521
|
+
|
|
522
522
|
- `streams`: Array of `Wazo.Stream`
|
|
523
523
|
List all streams that the participant is sending.
|
|
524
|
-
|
|
524
|
+
|
|
525
525
|
- `videoStreams`: Array of `Wazo.Stream`
|
|
526
526
|
List all video streams that the participant is sending.
|
|
527
|
-
|
|
527
|
+
|
|
528
528
|
- `audioMuted`: boolean
|
|
529
529
|
Indicates if the participant has muted his microphone.
|
|
530
|
-
|
|
530
|
+
|
|
531
531
|
- `videoMuted`: boolean
|
|
532
532
|
Indicates if the participant has muted his camera.
|
|
533
|
-
|
|
533
|
+
|
|
534
534
|
- `screensharing`: boolean
|
|
535
535
|
Indicates if the participant is currently sharing his screen.
|
|
536
|
-
|
|
536
|
+
|
|
537
537
|
- `extra`: Object
|
|
538
538
|
extra information related to a participant.
|
|
539
|
-
|
|
540
|
-
|
|
539
|
+
|
|
540
|
+
|
|
541
541
|
#### Participant events
|
|
542
542
|
|
|
543
543
|
```js
|
|
@@ -572,7 +572,7 @@ Triggered when the participant sends a stream.
|
|
|
572
572
|
|
|
573
573
|
- `stream`: `Wazo.Stream`
|
|
574
574
|
A Wazo stream that is sent by the participant.
|
|
575
|
-
|
|
575
|
+
|
|
576
576
|
```js
|
|
577
577
|
participant.on(participant.ON_STREAM_UNSUBSCRIBED, (stream) => {});
|
|
578
578
|
```
|
|
@@ -581,42 +581,42 @@ Triggered when the participant stops sending a stream.
|
|
|
581
581
|
|
|
582
582
|
- `stream`: `Wazo.Stream`
|
|
583
583
|
A Wazo stream that is no longer sent by the participant.
|
|
584
|
-
|
|
584
|
+
|
|
585
585
|
```js
|
|
586
586
|
participant.on(participant.ON_AUDIO_MUTED, () => {});
|
|
587
587
|
```
|
|
588
588
|
|
|
589
589
|
Triggered when the participant has disabled his microphone.
|
|
590
|
-
|
|
590
|
+
|
|
591
591
|
```js
|
|
592
592
|
participant.on(participant.ON_AUDIO_UNMUTED, () => {});
|
|
593
593
|
```
|
|
594
594
|
|
|
595
|
-
Triggered when the participant has enabled his microphone.
|
|
596
|
-
|
|
595
|
+
Triggered when the participant has enabled his microphone.
|
|
596
|
+
|
|
597
597
|
```js
|
|
598
598
|
participant.on(participant.ON_VIDEO_MUTED, () => {});
|
|
599
599
|
```
|
|
600
600
|
|
|
601
|
-
Triggered when the participant has disabled his camera.
|
|
602
|
-
|
|
601
|
+
Triggered when the participant has disabled his camera.
|
|
602
|
+
|
|
603
603
|
```js
|
|
604
604
|
participant.on(participant.ON_VIDEO_UNMUTED, () => {});
|
|
605
605
|
```
|
|
606
606
|
|
|
607
|
-
Triggered when the participant has enabled his camera.
|
|
608
|
-
|
|
607
|
+
Triggered when the participant has enabled his camera.
|
|
608
|
+
|
|
609
609
|
```js
|
|
610
610
|
participant.on(participant.ON_SCREENSHARING, () => {});
|
|
611
611
|
```
|
|
612
612
|
|
|
613
|
-
Triggered when the participant is sharing his screen.
|
|
614
|
-
|
|
613
|
+
Triggered when the participant is sharing his screen.
|
|
614
|
+
|
|
615
615
|
```js
|
|
616
616
|
participant.on(participant.ON_STOP_SCREENSHARING, () => {});
|
|
617
617
|
```
|
|
618
618
|
|
|
619
|
-
Triggered when the participant stops sharing his screen.
|
|
619
|
+
Triggered when the participant stops sharing his screen.
|
|
620
620
|
|
|
621
621
|
#### Stream
|
|
622
622
|
|
|
@@ -664,7 +664,7 @@ import { WebRTCClient } from '@wazo/sdk';
|
|
|
664
664
|
import { WazoWebSocketClient } from '@wazo/sdk';
|
|
665
665
|
```
|
|
666
666
|
|
|
667
|
-
### Authentication
|
|
667
|
+
### Authentication
|
|
668
668
|
#### Initialization
|
|
669
669
|
**`Voice`** **`Video`** **`Chat`** **`Fax`** **`Status`** **`Config`** **`Misc`**
|
|
670
670
|
|
|
@@ -809,7 +809,7 @@ logger(logger.TRACE, 'my log');
|
|
|
809
809
|
Wazo.IssueReporter.log(Wazo.IssueReporter.INFO, 'my log');
|
|
810
810
|
```
|
|
811
811
|
|
|
812
|
-
### Interact with the engine
|
|
812
|
+
### Interact with the engine
|
|
813
813
|
#### Applicationd
|
|
814
814
|
**`Voice`** **`Video`** **`Chat`** **`Fax`** **`Status`** **`Config`**
|
|
815
815
|
|
|
@@ -934,12 +934,12 @@ client.chatd.getMessages(options: GetMessagesOptions);
|
|
|
934
934
|
```
|
|
935
935
|
|
|
936
936
|
#### Calling an API endpoint without WazoApiClient
|
|
937
|
-
**`
|
|
937
|
+
**`Config`** **`Misc`**
|
|
938
938
|
|
|
939
939
|
Use this generic method to request endpoints directly.
|
|
940
940
|
|
|
941
941
|
```js
|
|
942
|
-
const requester = new ApiRequester({
|
|
942
|
+
const requester = new ApiRequester({
|
|
943
943
|
server: 'stack.example.com', // Engine server
|
|
944
944
|
refreshTokenCallback: () => {}, // Called when the token is refreshed
|
|
945
945
|
clientId: 'my-id', // ClientId used for refreshToken
|
|
@@ -949,7 +949,34 @@ const requester = new ApiRequester({
|
|
|
949
949
|
|
|
950
950
|
// Retrieve personal contacts
|
|
951
951
|
const results = await requester.call('dird/0.1/personal');
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
#### Extending BaseApiClient with you own methods
|
|
955
|
+
**`Config`** **`Misc`**
|
|
956
|
+
|
|
957
|
+
WazoApiClient is an extended version of BaseApiClient with needed APIs for softphone users. If you want to add new endpoints and methods it is also possible.
|
|
952
958
|
|
|
959
|
+
```js
|
|
960
|
+
const myEndpointMethods = (client: ApiRequester, baseUrl: string) => ({
|
|
961
|
+
getFoo: () => client.get(`${baseUrl}/foo`),
|
|
962
|
+
postFoo: () => client.post(`${baseUrl}/foo`, { /* body */ }),
|
|
963
|
+
putFoo: (uuid: string) => client.post(`${baseUrl}/foo/${uuid}`, { /* body */ }),
|
|
964
|
+
deleteFoo: (uuid: string) => client.delete(`${baseUrl}/foo/${uuid}`),
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
class CustomApiClient extends BaseApiClient {
|
|
968
|
+
public myEndpoint;
|
|
969
|
+
|
|
970
|
+
constructor(args: ConstructorParams) {
|
|
971
|
+
super(args);
|
|
972
|
+
this.initializeEndpoints(); // Reinitialize sdk endpoints
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
initializeEndpoints() {
|
|
976
|
+
super.initializeEndpoints(); // Include default `auth` methods for token and refresh token mecanism
|
|
977
|
+
this.myEndpoint = myEndpointMethods(this.client, `confd/1.1`);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
953
980
|
```
|
|
954
981
|
|
|
955
982
|
### WebRTCClient
|
|
@@ -971,7 +998,7 @@ const client = new WebRTCClient({
|
|
|
971
998
|
}
|
|
972
999
|
}, session);
|
|
973
1000
|
|
|
974
|
-
// eventName can be on the of events :
|
|
1001
|
+
// eventName can be on the of events :
|
|
975
1002
|
// - transport: `connected`, `disconnected`, `transportError`, `message`, `closed`, `keepAliveDebounceTimeout`
|
|
976
1003
|
// - webrtc: `registered`, `unregistered`, `registrationFailed`, `invite`, `inviteSent`, `transportCreated`, `newTransaction`, `transactionDestroyed`, `notify`, `outOfDialogReferRequested`, `message`.
|
|
977
1004
|
client.on('invite', (sipSession: SipSession, hasVideo: boolean, shouldAutoAnswer: boolean) => {
|
|
@@ -1004,7 +1031,7 @@ const config = {
|
|
|
1004
1031
|
heartbeatDelay: 1000, // Duration in ms between 2 heartbeat (default to 2000)
|
|
1005
1032
|
heartbeatTimeout: 5000, // Duration in ms when to consider that the Asterisk server is not responding (default to 5000)
|
|
1006
1033
|
maxHeartbeats: 4, // Number of heatbeat send each time we want to check connection (default to 3)
|
|
1007
|
-
|
|
1034
|
+
|
|
1008
1035
|
// When not passing session as second argument:
|
|
1009
1036
|
authorizationUser: '', // The SIP username
|
|
1010
1037
|
password: '', // The SIP user password
|
|
@@ -1168,7 +1195,7 @@ Use this method to dial a number.
|
|
|
1168
1195
|
const callSession = await phone.makeCall(
|
|
1169
1196
|
number: string, // The number to dial
|
|
1170
1197
|
line: // Not used
|
|
1171
|
-
enableVideo: boolean // Optional (default to false) when we want to make a video call
|
|
1198
|
+
enableVideo: boolean // Optional (default to false) when we want to make a video call
|
|
1172
1199
|
);
|
|
1173
1200
|
```
|
|
1174
1201
|
|
|
@@ -1279,10 +1306,10 @@ phone.indirectTransfer(
|
|
|
1279
1306
|
##### Start screen sharing
|
|
1280
1307
|
|
|
1281
1308
|
```js
|
|
1282
|
-
const screenShareStream: MediaStream = await phone.startScreenSharing({
|
|
1283
|
-
audio: true,
|
|
1284
|
-
video: true,
|
|
1285
|
-
/* See webRtc media constraints */
|
|
1309
|
+
const screenShareStream: MediaStream = await phone.startScreenSharing({
|
|
1310
|
+
audio: true,
|
|
1311
|
+
video: true,
|
|
1312
|
+
/* See webRtc media constraints */
|
|
1286
1313
|
});
|
|
1287
1314
|
```
|
|
1288
1315
|
|
|
@@ -1293,7 +1320,7 @@ phone.stopScreenSharing();
|
|
|
1293
1320
|
```
|
|
1294
1321
|
|
|
1295
1322
|
#### Conference phone features
|
|
1296
|
-
**`Voice`** **`Video`** **`Chat`**
|
|
1323
|
+
**`Voice`** **`Video`** **`Chat`**
|
|
1297
1324
|
|
|
1298
1325
|
##### Starting a conference
|
|
1299
1326
|
Use this method to start an ad-hoc conference.
|
|
@@ -1402,8 +1429,8 @@ phone.callCount(): number;
|
|
|
1402
1429
|
```
|
|
1403
1430
|
|
|
1404
1431
|
##### Sending a SIP message
|
|
1405
|
-
Sends a SIP MESSAGE in a session.
|
|
1406
|
-
Use `phone.currentSipSession` to retrieve the current `sipSession`.
|
|
1432
|
+
Sends a SIP MESSAGE in a session.
|
|
1433
|
+
Use `phone.currentSipSession` to retrieve the current `sipSession`.
|
|
1407
1434
|
|
|
1408
1435
|
```js
|
|
1409
1436
|
phone.sendMessage(
|