@afterrealism/dendri-client 2.4.0 → 2.5.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 +8 -17
- package/dist/{chunk-MBMSG4EC.js → chunk-3CE674DE.js} +72 -15
- package/dist/chunk-3CE674DE.js.map +1 -0
- package/dist/dendri.browser.global.js +70 -13
- package/dist/dendri.browser.global.js.map +1 -1
- package/dist/dendri.cjs +70 -13
- package/dist/dendri.cjs.map +1 -1
- package/dist/dendri.d.cts +13 -4
- package/dist/dendri.d.ts +13 -4
- package/dist/dendri.js +2 -2
- package/dist/dendri.min.global.js +7 -7
- package/dist/dendri.min.global.js.map +1 -1
- package/dist/serializer.msgpack.d.cts +14 -0
- package/dist/serializer.msgpack.d.ts +14 -0
- package/dist/{store-DVE0ih44.d.cts → store-C3Nwl62R.d.cts} +14 -0
- package/dist/{store-DVE0ih44.d.ts → store-C3Nwl62R.d.ts} +14 -0
- package/dist/store.cjs +70 -13
- package/dist/store.cjs.map +1 -1
- package/dist/store.d.cts +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-MBMSG4EC.js.map +0 -1
|
@@ -315,6 +315,13 @@ interface AnswerOption {
|
|
|
315
315
|
}
|
|
316
316
|
interface DendriOption {
|
|
317
317
|
key?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
320
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
321
|
+
*/
|
|
322
|
+
url?: string;
|
|
323
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
324
|
+
apiKey?: string;
|
|
318
325
|
host?: string;
|
|
319
326
|
port?: number;
|
|
320
327
|
path?: string;
|
|
@@ -623,6 +630,13 @@ declare class DendriOptions implements DendriOption {
|
|
|
623
630
|
* Prints log messages depending on the debug level passed in.
|
|
624
631
|
*/
|
|
625
632
|
debug?: LogLevel;
|
|
633
|
+
/**
|
|
634
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
635
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
636
|
+
*/
|
|
637
|
+
url?: string;
|
|
638
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
639
|
+
apiKey?: string;
|
|
626
640
|
/**
|
|
627
641
|
* Server host for your Dendri signaling server.
|
|
628
642
|
* Also accepts `'/'` to signify relative hostname.
|
|
@@ -315,6 +315,13 @@ interface AnswerOption {
|
|
|
315
315
|
}
|
|
316
316
|
interface DendriOption {
|
|
317
317
|
key?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
320
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
321
|
+
*/
|
|
322
|
+
url?: string;
|
|
323
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
324
|
+
apiKey?: string;
|
|
318
325
|
host?: string;
|
|
319
326
|
port?: number;
|
|
320
327
|
path?: string;
|
|
@@ -623,6 +630,13 @@ declare class DendriOptions implements DendriOption {
|
|
|
623
630
|
* Prints log messages depending on the debug level passed in.
|
|
624
631
|
*/
|
|
625
632
|
debug?: LogLevel;
|
|
633
|
+
/**
|
|
634
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
635
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
636
|
+
*/
|
|
637
|
+
url?: string;
|
|
638
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
639
|
+
apiKey?: string;
|
|
626
640
|
/**
|
|
627
641
|
* Server host for your Dendri signaling server.
|
|
628
642
|
* Also accepts `'/'` to signify relative hostname.
|
|
@@ -327,6 +327,13 @@ interface AnswerOption {
|
|
|
327
327
|
}
|
|
328
328
|
interface DendriOption {
|
|
329
329
|
key?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
332
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
333
|
+
*/
|
|
334
|
+
url?: string;
|
|
335
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
336
|
+
apiKey?: string;
|
|
330
337
|
host?: string;
|
|
331
338
|
port?: number;
|
|
332
339
|
path?: string;
|
|
@@ -635,6 +642,13 @@ declare class DendriOptions implements DendriOption {
|
|
|
635
642
|
* Prints log messages depending on the debug level passed in.
|
|
636
643
|
*/
|
|
637
644
|
debug?: LogLevel;
|
|
645
|
+
/**
|
|
646
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
647
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
648
|
+
*/
|
|
649
|
+
url?: string;
|
|
650
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
651
|
+
apiKey?: string;
|
|
638
652
|
/**
|
|
639
653
|
* Server host for your Dendri signaling server.
|
|
640
654
|
* Also accepts `'/'` to signify relative hostname.
|
|
@@ -327,6 +327,13 @@ interface AnswerOption {
|
|
|
327
327
|
}
|
|
328
328
|
interface DendriOption {
|
|
329
329
|
key?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
332
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
333
|
+
*/
|
|
334
|
+
url?: string;
|
|
335
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
336
|
+
apiKey?: string;
|
|
330
337
|
host?: string;
|
|
331
338
|
port?: number;
|
|
332
339
|
path?: string;
|
|
@@ -635,6 +642,13 @@ declare class DendriOptions implements DendriOption {
|
|
|
635
642
|
* Prints log messages depending on the debug level passed in.
|
|
636
643
|
*/
|
|
637
644
|
debug?: LogLevel;
|
|
645
|
+
/**
|
|
646
|
+
* Full server URL, e.g. `"wss://signal.example.com"` or `"http://127.0.0.1:9876"`.
|
|
647
|
+
* Shorthand for host/port/secure/path; any of those passed explicitly win.
|
|
648
|
+
*/
|
|
649
|
+
url?: string;
|
|
650
|
+
/** API key for hosted / multi-tenant Dendri deployments. Sent with every signaling and REST request. */
|
|
651
|
+
apiKey?: string;
|
|
638
652
|
/**
|
|
639
653
|
* Server host for your Dendri signaling server.
|
|
640
654
|
* Also accepts `'/'` to signify relative hostname.
|
package/dist/store.cjs
CHANGED
|
@@ -3531,7 +3531,7 @@ var Util = class extends BinaryPackChunker {
|
|
|
3531
3531
|
var util = new Util();
|
|
3532
3532
|
|
|
3533
3533
|
// src/api.ts
|
|
3534
|
-
var version = "2.
|
|
3534
|
+
var version = "2.5.0";
|
|
3535
3535
|
var API = class _API {
|
|
3536
3536
|
constructor(_options) {
|
|
3537
3537
|
this._options = _options;
|
|
@@ -3544,6 +3544,7 @@ var API = class _API {
|
|
|
3544
3544
|
const url = new URL(`${protocol}://${host}:${port}${path}${key}/${method}`);
|
|
3545
3545
|
url.searchParams.set("ts", `${Date.now()}${Math.random()}`);
|
|
3546
3546
|
url.searchParams.set("version", version);
|
|
3547
|
+
if (this._options.apiKey) url.searchParams.set("api_key", this._options.apiKey);
|
|
3547
3548
|
const controller = new AbortController();
|
|
3548
3549
|
const timeoutId = setTimeout(() => controller.abort(), _API.FETCH_TIMEOUT);
|
|
3549
3550
|
return fetch(url.href, {
|
|
@@ -3572,11 +3573,12 @@ var API = class _API {
|
|
|
3572
3573
|
async getTurnCredentials() {
|
|
3573
3574
|
const protocol = this._options.secure ? "https" : "http";
|
|
3574
3575
|
const { host, port, path, key } = this._options;
|
|
3575
|
-
const url = `${protocol}://${host}:${port}${path}${key}/turn-credentials
|
|
3576
|
+
const url = new URL(`${protocol}://${host}:${port}${path}${key}/turn-credentials`);
|
|
3577
|
+
if (this._options.apiKey) url.searchParams.set("api_key", this._options.apiKey);
|
|
3576
3578
|
try {
|
|
3577
3579
|
const controller = new AbortController();
|
|
3578
3580
|
const timeoutId = setTimeout(() => controller.abort(), _API.FETCH_TIMEOUT);
|
|
3579
|
-
const response = await fetch(url, {
|
|
3581
|
+
const response = await fetch(url.href, {
|
|
3580
3582
|
referrerPolicy: this._options.referrerPolicy,
|
|
3581
3583
|
signal: controller.signal
|
|
3582
3584
|
}).finally(() => clearTimeout(timeoutId));
|
|
@@ -5302,17 +5304,29 @@ var PollingTransport = class _PollingTransport extends SignalingTransport {
|
|
|
5302
5304
|
_heartbeatTimer;
|
|
5303
5305
|
_lastSeq = 0;
|
|
5304
5306
|
_baseUrl;
|
|
5307
|
+
_key;
|
|
5308
|
+
_jwt;
|
|
5309
|
+
_apiKey;
|
|
5305
5310
|
_pingInterval;
|
|
5306
5311
|
_abortController;
|
|
5307
5312
|
/** Backoff schedule base delays in milliseconds. */
|
|
5308
5313
|
static BACKOFF_SCHEDULE = [0, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
5309
5314
|
/** Random jitter range in milliseconds (applied as +/-). */
|
|
5310
5315
|
static BACKOFF_JITTER = 500;
|
|
5311
|
-
constructor(secure, host, port, path,
|
|
5316
|
+
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt, apiKey) {
|
|
5312
5317
|
super();
|
|
5313
5318
|
const protocol = secure ? "https://" : "http://";
|
|
5314
5319
|
this._baseUrl = `${protocol + host}:${port}${path}`;
|
|
5315
5320
|
this._pingInterval = pingInterval;
|
|
5321
|
+
this._key = key;
|
|
5322
|
+
this._jwt = jwt;
|
|
5323
|
+
this._apiKey = apiKey;
|
|
5324
|
+
}
|
|
5325
|
+
/** Append the shared auth params (key, jwt, api_key) so every HTTP call authenticates like the WS transport. */
|
|
5326
|
+
_applyAuthParams(params) {
|
|
5327
|
+
params.set("key", this._key);
|
|
5328
|
+
if (this._jwt) params.set("jwt", this._jwt);
|
|
5329
|
+
if (this._apiKey) params.set("api_key", this._apiKey);
|
|
5316
5330
|
}
|
|
5317
5331
|
get reconnectAttempt() {
|
|
5318
5332
|
return this._reconnectAttempt;
|
|
@@ -5340,6 +5354,7 @@ var PollingTransport = class _PollingTransport extends SignalingTransport {
|
|
|
5340
5354
|
id: this._id,
|
|
5341
5355
|
token: this._token
|
|
5342
5356
|
});
|
|
5357
|
+
this._applyAuthParams(params);
|
|
5343
5358
|
if (this._lastSeq > 0) params.set("last_seq", String(this._lastSeq));
|
|
5344
5359
|
const response = await fetch(`${this._baseUrl}http/poll?${params}`, {
|
|
5345
5360
|
signal: this._abortController.signal
|
|
@@ -5378,6 +5393,7 @@ var PollingTransport = class _PollingTransport extends SignalingTransport {
|
|
|
5378
5393
|
id: this._id,
|
|
5379
5394
|
token: this._token
|
|
5380
5395
|
});
|
|
5396
|
+
this._applyAuthParams(params);
|
|
5381
5397
|
try {
|
|
5382
5398
|
await fetch(`${this._baseUrl}http/send?${params}`, {
|
|
5383
5399
|
method: "POST",
|
|
@@ -5442,13 +5458,16 @@ var PollingTransport = class _PollingTransport extends SignalingTransport {
|
|
|
5442
5458
|
};
|
|
5443
5459
|
|
|
5444
5460
|
// src/socket.ts
|
|
5445
|
-
var version2 = "2.
|
|
5461
|
+
var version2 = "2.5.0";
|
|
5446
5462
|
var Socket = class _Socket extends SignalingTransport {
|
|
5447
|
-
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt) {
|
|
5463
|
+
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt, apiKey) {
|
|
5448
5464
|
super();
|
|
5449
5465
|
this.pingInterval = pingInterval;
|
|
5450
5466
|
const wsProtocol = secure ? "wss://" : "ws://";
|
|
5451
5467
|
this._baseUrl = `${wsProtocol + host}:${port}${path}dendri?key=${key}`;
|
|
5468
|
+
if (apiKey) {
|
|
5469
|
+
this._baseUrl += `&api_key=${encodeURIComponent(apiKey)}`;
|
|
5470
|
+
}
|
|
5452
5471
|
this._jwt = jwt;
|
|
5453
5472
|
}
|
|
5454
5473
|
pingInterval;
|
|
@@ -5754,18 +5773,28 @@ var SSETransport = class _SSETransport extends SignalingTransport {
|
|
|
5754
5773
|
_heartbeatTimer;
|
|
5755
5774
|
_lastSeq = 0;
|
|
5756
5775
|
_baseUrl;
|
|
5776
|
+
_key;
|
|
5757
5777
|
_jwt;
|
|
5778
|
+
_apiKey;
|
|
5758
5779
|
_pingInterval;
|
|
5759
5780
|
/** Backoff schedule base delays in milliseconds. */
|
|
5760
5781
|
static BACKOFF_SCHEDULE = [0, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
5761
5782
|
/** Random jitter range in milliseconds (applied as +/-). */
|
|
5762
5783
|
static BACKOFF_JITTER = 500;
|
|
5763
|
-
constructor(secure, host, port, path,
|
|
5784
|
+
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt, apiKey) {
|
|
5764
5785
|
super();
|
|
5765
5786
|
const protocol = secure ? "https://" : "http://";
|
|
5766
5787
|
this._baseUrl = `${protocol + host}:${port}${path}`;
|
|
5767
5788
|
this._pingInterval = pingInterval;
|
|
5789
|
+
this._key = key;
|
|
5768
5790
|
this._jwt = jwt;
|
|
5791
|
+
this._apiKey = apiKey;
|
|
5792
|
+
}
|
|
5793
|
+
/** Append the shared auth params (key, jwt, api_key) so every HTTP call authenticates like the WS transport. */
|
|
5794
|
+
_applyAuthParams(params) {
|
|
5795
|
+
params.set("key", this._key);
|
|
5796
|
+
if (this._jwt) params.set("jwt", this._jwt);
|
|
5797
|
+
if (this._apiKey) params.set("api_key", this._apiKey);
|
|
5769
5798
|
}
|
|
5770
5799
|
get reconnectAttempt() {
|
|
5771
5800
|
return this._reconnectAttempt;
|
|
@@ -5783,10 +5812,9 @@ var SSETransport = class _SSETransport extends SignalingTransport {
|
|
|
5783
5812
|
if (this._disconnected) return;
|
|
5784
5813
|
const params = new URLSearchParams({
|
|
5785
5814
|
id: this._id,
|
|
5786
|
-
token: this._token
|
|
5787
|
-
key: "dendri"
|
|
5815
|
+
token: this._token
|
|
5788
5816
|
});
|
|
5789
|
-
|
|
5817
|
+
this._applyAuthParams(params);
|
|
5790
5818
|
if (this._lastSeq > 0) params.set("last_seq", String(this._lastSeq));
|
|
5791
5819
|
const url = `${this._baseUrl}http/sse?${params}`;
|
|
5792
5820
|
try {
|
|
@@ -5860,6 +5888,7 @@ var SSETransport = class _SSETransport extends SignalingTransport {
|
|
|
5860
5888
|
id: this._id,
|
|
5861
5889
|
token: this._token
|
|
5862
5890
|
});
|
|
5891
|
+
this._applyAuthParams(params);
|
|
5863
5892
|
try {
|
|
5864
5893
|
await fetch(`${this._baseUrl}http/send?${params}`, {
|
|
5865
5894
|
method: "POST",
|
|
@@ -5932,6 +5961,28 @@ var SSETransport = class _SSETransport extends SignalingTransport {
|
|
|
5932
5961
|
};
|
|
5933
5962
|
|
|
5934
5963
|
// src/dendri.ts
|
|
5964
|
+
function parseServerUrl(url) {
|
|
5965
|
+
let parsed;
|
|
5966
|
+
try {
|
|
5967
|
+
parsed = new URL(url);
|
|
5968
|
+
} catch {
|
|
5969
|
+
throw new Error(
|
|
5970
|
+
`Invalid Dendri "url" option: "${url}". Expected a full URL like "wss://signal.example.com".`
|
|
5971
|
+
);
|
|
5972
|
+
}
|
|
5973
|
+
const secure = parsed.protocol === "wss:" || parsed.protocol === "https:";
|
|
5974
|
+
if (!secure && parsed.protocol !== "ws:" && parsed.protocol !== "http:") {
|
|
5975
|
+
throw new Error(
|
|
5976
|
+
`Invalid Dendri "url" protocol: "${parsed.protocol}". Use wss://, ws://, https://, or http://.`
|
|
5977
|
+
);
|
|
5978
|
+
}
|
|
5979
|
+
return {
|
|
5980
|
+
host: parsed.hostname,
|
|
5981
|
+
port: parsed.port ? Number(parsed.port) : secure ? 443 : 80,
|
|
5982
|
+
secure,
|
|
5983
|
+
path: parsed.pathname || "/"
|
|
5984
|
+
};
|
|
5985
|
+
}
|
|
5935
5986
|
var Dendri = class _Dendri extends EventEmitterWithError {
|
|
5936
5987
|
static DEFAULT_KEY = "dendri";
|
|
5937
5988
|
_serializers = {
|
|
@@ -6022,6 +6073,9 @@ var Dendri = class _Dendri extends EventEmitterWithError {
|
|
|
6022
6073
|
} else if (id) {
|
|
6023
6074
|
userId = id.toString();
|
|
6024
6075
|
}
|
|
6076
|
+
if (providedOptions?.url) {
|
|
6077
|
+
providedOptions = { ...parseServerUrl(providedOptions.url), ...providedOptions };
|
|
6078
|
+
}
|
|
6025
6079
|
const normalizedOptions = {
|
|
6026
6080
|
debug: 0,
|
|
6027
6081
|
// 1: Errors, 2: Warnings, 3: All logs
|
|
@@ -6140,7 +6194,8 @@ var Dendri = class _Dendri extends EventEmitterWithError {
|
|
|
6140
6194
|
this._options.path,
|
|
6141
6195
|
this._options.key,
|
|
6142
6196
|
this._options.pingInterval,
|
|
6143
|
-
this._options.jwt
|
|
6197
|
+
this._options.jwt,
|
|
6198
|
+
this._options.apiKey
|
|
6144
6199
|
) : transport === "polling" ? new PollingTransport(
|
|
6145
6200
|
this._options.secure ?? false,
|
|
6146
6201
|
this._options.host,
|
|
@@ -6148,7 +6203,8 @@ var Dendri = class _Dendri extends EventEmitterWithError {
|
|
|
6148
6203
|
this._options.path,
|
|
6149
6204
|
this._options.key,
|
|
6150
6205
|
this._options.pingInterval,
|
|
6151
|
-
this._options.jwt
|
|
6206
|
+
this._options.jwt,
|
|
6207
|
+
this._options.apiKey
|
|
6152
6208
|
) : new Socket(
|
|
6153
6209
|
this._options.secure ?? false,
|
|
6154
6210
|
this._options.host,
|
|
@@ -6156,7 +6212,8 @@ var Dendri = class _Dendri extends EventEmitterWithError {
|
|
|
6156
6212
|
this._options.path,
|
|
6157
6213
|
this._options.key,
|
|
6158
6214
|
this._options.pingInterval,
|
|
6159
|
-
this._options.jwt
|
|
6215
|
+
this._options.jwt,
|
|
6216
|
+
this._options.apiKey
|
|
6160
6217
|
);
|
|
6161
6218
|
socket.on("message" /* Message */, (data) => {
|
|
6162
6219
|
this._handleMessage(data);
|