@afterrealism/dendri-client 2.4.0 → 2.6.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 +35 -18
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/{chunk-MBMSG4EC.js → chunk-YLWDCKUW.js} +73 -44
- package/dist/chunk-YLWDCKUW.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 +3 -2
- package/dist/dendri.js.map +1 -1
- package/dist/dendri.min.global.js +7 -7
- package/dist/dendri.min.global.js.map +1 -1
- package/dist/react.cjs +16 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +25 -0
- package/dist/react.d.ts +25 -0
- package/dist/react.js +14 -0
- package/dist/react.js.map +1 -0
- 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 +2 -1
- package/dist/svelte.cjs +15 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +29 -0
- package/dist/svelte.d.ts +29 -0
- package/dist/svelte.js +15 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.cjs +19 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +25 -0
- package/dist/vue.d.ts +25 -0
- package/dist/vue.js +17 -0
- package/dist/vue.js.map +1 -0
- package/package.json +49 -2
- package/dist/chunk-MBMSG4EC.js.map +0 -1
|
@@ -3536,7 +3536,7 @@ var dendri = (() => {
|
|
|
3536
3536
|
var util = new Util();
|
|
3537
3537
|
|
|
3538
3538
|
// src/api.ts
|
|
3539
|
-
var version = "2.
|
|
3539
|
+
var version = "2.6.0";
|
|
3540
3540
|
var API = class _API {
|
|
3541
3541
|
constructor(_options) {
|
|
3542
3542
|
this._options = _options;
|
|
@@ -3549,6 +3549,7 @@ var dendri = (() => {
|
|
|
3549
3549
|
const url = new URL(`${protocol}://${host}:${port}${path}${key}/${method}`);
|
|
3550
3550
|
url.searchParams.set("ts", `${Date.now()}${Math.random()}`);
|
|
3551
3551
|
url.searchParams.set("version", version);
|
|
3552
|
+
if (this._options.apiKey) url.searchParams.set("api_key", this._options.apiKey);
|
|
3552
3553
|
const controller = new AbortController();
|
|
3553
3554
|
const timeoutId = setTimeout(() => controller.abort(), _API.FETCH_TIMEOUT);
|
|
3554
3555
|
return fetch(url.href, {
|
|
@@ -3577,11 +3578,12 @@ var dendri = (() => {
|
|
|
3577
3578
|
async getTurnCredentials() {
|
|
3578
3579
|
const protocol = this._options.secure ? "https" : "http";
|
|
3579
3580
|
const { host, port, path, key } = this._options;
|
|
3580
|
-
const url = `${protocol}://${host}:${port}${path}${key}/turn-credentials
|
|
3581
|
+
const url = new URL(`${protocol}://${host}:${port}${path}${key}/turn-credentials`);
|
|
3582
|
+
if (this._options.apiKey) url.searchParams.set("api_key", this._options.apiKey);
|
|
3581
3583
|
try {
|
|
3582
3584
|
const controller = new AbortController();
|
|
3583
3585
|
const timeoutId = setTimeout(() => controller.abort(), _API.FETCH_TIMEOUT);
|
|
3584
|
-
const response = await fetch(url, {
|
|
3586
|
+
const response = await fetch(url.href, {
|
|
3585
3587
|
referrerPolicy: this._options.referrerPolicy,
|
|
3586
3588
|
signal: controller.signal
|
|
3587
3589
|
}).finally(() => clearTimeout(timeoutId));
|
|
@@ -5307,17 +5309,29 @@ var dendri = (() => {
|
|
|
5307
5309
|
_heartbeatTimer;
|
|
5308
5310
|
_lastSeq = 0;
|
|
5309
5311
|
_baseUrl;
|
|
5312
|
+
_key;
|
|
5313
|
+
_jwt;
|
|
5314
|
+
_apiKey;
|
|
5310
5315
|
_pingInterval;
|
|
5311
5316
|
_abortController;
|
|
5312
5317
|
/** Backoff schedule base delays in milliseconds. */
|
|
5313
5318
|
static BACKOFF_SCHEDULE = [0, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
5314
5319
|
/** Random jitter range in milliseconds (applied as +/-). */
|
|
5315
5320
|
static BACKOFF_JITTER = 500;
|
|
5316
|
-
constructor(secure, host, port, path,
|
|
5321
|
+
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt, apiKey) {
|
|
5317
5322
|
super();
|
|
5318
5323
|
const protocol = secure ? "https://" : "http://";
|
|
5319
5324
|
this._baseUrl = `${protocol + host}:${port}${path}`;
|
|
5320
5325
|
this._pingInterval = pingInterval;
|
|
5326
|
+
this._key = key;
|
|
5327
|
+
this._jwt = jwt;
|
|
5328
|
+
this._apiKey = apiKey;
|
|
5329
|
+
}
|
|
5330
|
+
/** Append the shared auth params (key, jwt, api_key) so every HTTP call authenticates like the WS transport. */
|
|
5331
|
+
_applyAuthParams(params) {
|
|
5332
|
+
params.set("key", this._key);
|
|
5333
|
+
if (this._jwt) params.set("jwt", this._jwt);
|
|
5334
|
+
if (this._apiKey) params.set("api_key", this._apiKey);
|
|
5321
5335
|
}
|
|
5322
5336
|
get reconnectAttempt() {
|
|
5323
5337
|
return this._reconnectAttempt;
|
|
@@ -5345,6 +5359,7 @@ var dendri = (() => {
|
|
|
5345
5359
|
id: this._id,
|
|
5346
5360
|
token: this._token
|
|
5347
5361
|
});
|
|
5362
|
+
this._applyAuthParams(params);
|
|
5348
5363
|
if (this._lastSeq > 0) params.set("last_seq", String(this._lastSeq));
|
|
5349
5364
|
const response = await fetch(`${this._baseUrl}http/poll?${params}`, {
|
|
5350
5365
|
signal: this._abortController.signal
|
|
@@ -5383,6 +5398,7 @@ var dendri = (() => {
|
|
|
5383
5398
|
id: this._id,
|
|
5384
5399
|
token: this._token
|
|
5385
5400
|
});
|
|
5401
|
+
this._applyAuthParams(params);
|
|
5386
5402
|
try {
|
|
5387
5403
|
await fetch(`${this._baseUrl}http/send?${params}`, {
|
|
5388
5404
|
method: "POST",
|
|
@@ -5447,13 +5463,16 @@ var dendri = (() => {
|
|
|
5447
5463
|
};
|
|
5448
5464
|
|
|
5449
5465
|
// src/socket.ts
|
|
5450
|
-
var version2 = "2.
|
|
5466
|
+
var version2 = "2.6.0";
|
|
5451
5467
|
var Socket = class _Socket extends SignalingTransport {
|
|
5452
|
-
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt) {
|
|
5468
|
+
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt, apiKey) {
|
|
5453
5469
|
super();
|
|
5454
5470
|
this.pingInterval = pingInterval;
|
|
5455
5471
|
const wsProtocol = secure ? "wss://" : "ws://";
|
|
5456
5472
|
this._baseUrl = `${wsProtocol + host}:${port}${path}dendri?key=${key}`;
|
|
5473
|
+
if (apiKey) {
|
|
5474
|
+
this._baseUrl += `&api_key=${encodeURIComponent(apiKey)}`;
|
|
5475
|
+
}
|
|
5457
5476
|
this._jwt = jwt;
|
|
5458
5477
|
}
|
|
5459
5478
|
pingInterval;
|
|
@@ -5759,18 +5778,28 @@ var dendri = (() => {
|
|
|
5759
5778
|
_heartbeatTimer;
|
|
5760
5779
|
_lastSeq = 0;
|
|
5761
5780
|
_baseUrl;
|
|
5781
|
+
_key;
|
|
5762
5782
|
_jwt;
|
|
5783
|
+
_apiKey;
|
|
5763
5784
|
_pingInterval;
|
|
5764
5785
|
/** Backoff schedule base delays in milliseconds. */
|
|
5765
5786
|
static BACKOFF_SCHEDULE = [0, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
5766
5787
|
/** Random jitter range in milliseconds (applied as +/-). */
|
|
5767
5788
|
static BACKOFF_JITTER = 500;
|
|
5768
|
-
constructor(secure, host, port, path,
|
|
5789
|
+
constructor(secure, host, port, path, key, pingInterval = 5e3, jwt, apiKey) {
|
|
5769
5790
|
super();
|
|
5770
5791
|
const protocol = secure ? "https://" : "http://";
|
|
5771
5792
|
this._baseUrl = `${protocol + host}:${port}${path}`;
|
|
5772
5793
|
this._pingInterval = pingInterval;
|
|
5794
|
+
this._key = key;
|
|
5773
5795
|
this._jwt = jwt;
|
|
5796
|
+
this._apiKey = apiKey;
|
|
5797
|
+
}
|
|
5798
|
+
/** Append the shared auth params (key, jwt, api_key) so every HTTP call authenticates like the WS transport. */
|
|
5799
|
+
_applyAuthParams(params) {
|
|
5800
|
+
params.set("key", this._key);
|
|
5801
|
+
if (this._jwt) params.set("jwt", this._jwt);
|
|
5802
|
+
if (this._apiKey) params.set("api_key", this._apiKey);
|
|
5774
5803
|
}
|
|
5775
5804
|
get reconnectAttempt() {
|
|
5776
5805
|
return this._reconnectAttempt;
|
|
@@ -5788,10 +5817,9 @@ var dendri = (() => {
|
|
|
5788
5817
|
if (this._disconnected) return;
|
|
5789
5818
|
const params = new URLSearchParams({
|
|
5790
5819
|
id: this._id,
|
|
5791
|
-
token: this._token
|
|
5792
|
-
key: "dendri"
|
|
5820
|
+
token: this._token
|
|
5793
5821
|
});
|
|
5794
|
-
|
|
5822
|
+
this._applyAuthParams(params);
|
|
5795
5823
|
if (this._lastSeq > 0) params.set("last_seq", String(this._lastSeq));
|
|
5796
5824
|
const url = `${this._baseUrl}http/sse?${params}`;
|
|
5797
5825
|
try {
|
|
@@ -5865,6 +5893,7 @@ var dendri = (() => {
|
|
|
5865
5893
|
id: this._id,
|
|
5866
5894
|
token: this._token
|
|
5867
5895
|
});
|
|
5896
|
+
this._applyAuthParams(params);
|
|
5868
5897
|
try {
|
|
5869
5898
|
await fetch(`${this._baseUrl}http/send?${params}`, {
|
|
5870
5899
|
method: "POST",
|
|
@@ -5937,6 +5966,28 @@ var dendri = (() => {
|
|
|
5937
5966
|
};
|
|
5938
5967
|
|
|
5939
5968
|
// src/dendri.ts
|
|
5969
|
+
function parseServerUrl(url) {
|
|
5970
|
+
let parsed;
|
|
5971
|
+
try {
|
|
5972
|
+
parsed = new URL(url);
|
|
5973
|
+
} catch {
|
|
5974
|
+
throw new Error(
|
|
5975
|
+
`Invalid Dendri "url" option: "${url}". Expected a full URL like "wss://signal.example.com".`
|
|
5976
|
+
);
|
|
5977
|
+
}
|
|
5978
|
+
const secure = parsed.protocol === "wss:" || parsed.protocol === "https:";
|
|
5979
|
+
if (!secure && parsed.protocol !== "ws:" && parsed.protocol !== "http:") {
|
|
5980
|
+
throw new Error(
|
|
5981
|
+
`Invalid Dendri "url" protocol: "${parsed.protocol}". Use wss://, ws://, https://, or http://.`
|
|
5982
|
+
);
|
|
5983
|
+
}
|
|
5984
|
+
return {
|
|
5985
|
+
host: parsed.hostname,
|
|
5986
|
+
port: parsed.port ? Number(parsed.port) : secure ? 443 : 80,
|
|
5987
|
+
secure,
|
|
5988
|
+
path: parsed.pathname || "/"
|
|
5989
|
+
};
|
|
5990
|
+
}
|
|
5940
5991
|
var Dendri = class _Dendri extends EventEmitterWithError {
|
|
5941
5992
|
static DEFAULT_KEY = "dendri";
|
|
5942
5993
|
_serializers = {
|
|
@@ -6027,6 +6078,9 @@ var dendri = (() => {
|
|
|
6027
6078
|
} else if (id) {
|
|
6028
6079
|
userId = id.toString();
|
|
6029
6080
|
}
|
|
6081
|
+
if (providedOptions?.url) {
|
|
6082
|
+
providedOptions = { ...parseServerUrl(providedOptions.url), ...providedOptions };
|
|
6083
|
+
}
|
|
6030
6084
|
const normalizedOptions = {
|
|
6031
6085
|
debug: 0,
|
|
6032
6086
|
// 1: Errors, 2: Warnings, 3: All logs
|
|
@@ -6145,7 +6199,8 @@ var dendri = (() => {
|
|
|
6145
6199
|
this._options.path,
|
|
6146
6200
|
this._options.key,
|
|
6147
6201
|
this._options.pingInterval,
|
|
6148
|
-
this._options.jwt
|
|
6202
|
+
this._options.jwt,
|
|
6203
|
+
this._options.apiKey
|
|
6149
6204
|
) : transport === "polling" ? new PollingTransport(
|
|
6150
6205
|
this._options.secure ?? false,
|
|
6151
6206
|
this._options.host,
|
|
@@ -6153,7 +6208,8 @@ var dendri = (() => {
|
|
|
6153
6208
|
this._options.path,
|
|
6154
6209
|
this._options.key,
|
|
6155
6210
|
this._options.pingInterval,
|
|
6156
|
-
this._options.jwt
|
|
6211
|
+
this._options.jwt,
|
|
6212
|
+
this._options.apiKey
|
|
6157
6213
|
) : new Socket(
|
|
6158
6214
|
this._options.secure ?? false,
|
|
6159
6215
|
this._options.host,
|
|
@@ -6161,7 +6217,8 @@ var dendri = (() => {
|
|
|
6161
6217
|
this._options.path,
|
|
6162
6218
|
this._options.key,
|
|
6163
6219
|
this._options.pingInterval,
|
|
6164
|
-
this._options.jwt
|
|
6220
|
+
this._options.jwt,
|
|
6221
|
+
this._options.apiKey
|
|
6165
6222
|
);
|
|
6166
6223
|
socket.on("message" /* Message */, (data) => {
|
|
6167
6224
|
this._handleMessage(data);
|