@thestatic-tv/dcl-sdk 2.5.27 → 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 +17 -7
- package/dist/index.d.mts +54 -10
- package/dist/index.d.ts +54 -10
- package/dist/index.js +133 -93
- package/dist/index.mjs +133 -93
- package/package.json +10 -4
package/dist/index.js
CHANGED
|
@@ -64,6 +64,9 @@ async function request(url, options = {}) {
|
|
|
64
64
|
return response.json();
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// src/StaticTVClient.ts
|
|
68
|
+
var import_SignedFetch3 = require("~system/SignedFetch");
|
|
69
|
+
|
|
67
70
|
// src/modules/guide.ts
|
|
68
71
|
var GuideModule = class {
|
|
69
72
|
// 30 seconds
|
|
@@ -256,6 +259,7 @@ var import_ecs2 = require("@dcl/sdk/ecs");
|
|
|
256
259
|
var import_Runtime = require("~system/Runtime");
|
|
257
260
|
var PARCEL_SIZE = 16;
|
|
258
261
|
var cachedBounds = null;
|
|
262
|
+
var cachedParcelRects = [];
|
|
259
263
|
var boundsInitialized = false;
|
|
260
264
|
var boundsError = false;
|
|
261
265
|
function parseParcel(parcel) {
|
|
@@ -291,6 +295,16 @@ async function getSceneBounds() {
|
|
|
291
295
|
boundsError = true;
|
|
292
296
|
return null;
|
|
293
297
|
}
|
|
298
|
+
const base = baseParcel ? parseParcel(baseParcel) : coords[0];
|
|
299
|
+
if (!base) {
|
|
300
|
+
boundsError = true;
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
cachedParcelRects = coords.map((c) => {
|
|
304
|
+
const minX = (c.x - base.x) * PARCEL_SIZE;
|
|
305
|
+
const minZ = (c.z - base.z) * PARCEL_SIZE;
|
|
306
|
+
return { minX, maxX: minX + PARCEL_SIZE, minZ, maxZ: minZ + PARCEL_SIZE };
|
|
307
|
+
});
|
|
294
308
|
const worldMinX = Math.min(...coords.map((c) => c.x));
|
|
295
309
|
const worldMaxX = Math.max(...coords.map((c) => c.x));
|
|
296
310
|
const worldMinZ = Math.min(...coords.map((c) => c.z));
|
|
@@ -313,13 +327,15 @@ async function getSceneBounds() {
|
|
|
313
327
|
return null;
|
|
314
328
|
}
|
|
315
329
|
}
|
|
316
|
-
function isPlayerInBounds(
|
|
330
|
+
function isPlayerInBounds(_bounds) {
|
|
317
331
|
try {
|
|
318
332
|
const transform = import_ecs2.Transform.getOrNull(import_ecs2.engine.PlayerEntity);
|
|
319
333
|
if (!transform) return false;
|
|
320
|
-
const
|
|
334
|
+
const { x, z } = transform.position;
|
|
321
335
|
const buffer = 0.5;
|
|
322
|
-
return
|
|
336
|
+
return cachedParcelRects.some(
|
|
337
|
+
(r) => x >= r.minX - buffer && x <= r.maxX + buffer && z >= r.minZ - buffer && z <= r.maxZ + buffer
|
|
338
|
+
);
|
|
323
339
|
} catch {
|
|
324
340
|
return false;
|
|
325
341
|
}
|
|
@@ -366,9 +382,12 @@ var SessionModule = class {
|
|
|
366
382
|
return this._bounds;
|
|
367
383
|
}
|
|
368
384
|
/**
|
|
369
|
-
* Check if player is currently within scene bounds
|
|
385
|
+
* Check if player is currently within scene bounds.
|
|
386
|
+
* Uses customBoundsCheck from config if provided, otherwise falls back to auto-detected parcel bounds.
|
|
370
387
|
*/
|
|
371
388
|
isPlayerInScene() {
|
|
389
|
+
const customCheck = this.client.getConfig().customBoundsCheck;
|
|
390
|
+
if (customCheck) return customCheck();
|
|
372
391
|
if (!this._bounds) return true;
|
|
373
392
|
return isPlayerInBounds(this._bounds);
|
|
374
393
|
}
|
|
@@ -621,13 +640,6 @@ var HeartbeatModule = class {
|
|
|
621
640
|
this.currentChannel = null;
|
|
622
641
|
this.isWatching = false;
|
|
623
642
|
}
|
|
624
|
-
/**
|
|
625
|
-
* Get player wallet - prioritize config, fallback to runtime detection
|
|
626
|
-
*/
|
|
627
|
-
getWallet() {
|
|
628
|
-
const config = this.client.getConfig();
|
|
629
|
-
return config.player?.wallet || getPlayerWallet();
|
|
630
|
-
}
|
|
631
643
|
/**
|
|
632
644
|
* Send a watching heartbeat (1 heartbeat = 1 minute watched)
|
|
633
645
|
* Only sends if player is within scene bounds
|
|
@@ -639,14 +651,9 @@ var HeartbeatModule = class {
|
|
|
639
651
|
return;
|
|
640
652
|
}
|
|
641
653
|
try {
|
|
642
|
-
|
|
643
|
-
await this.client.request("/heartbeat", {
|
|
654
|
+
await this.client.signedRequest("/heartbeat", {
|
|
644
655
|
method: "POST",
|
|
645
|
-
body: JSON.stringify({
|
|
646
|
-
channelSlug: this.currentChannel,
|
|
647
|
-
walletAddress: this.getWallet(),
|
|
648
|
-
sessionId
|
|
649
|
-
})
|
|
656
|
+
body: JSON.stringify({ channelSlug: this.currentChannel })
|
|
650
657
|
});
|
|
651
658
|
this.client.log(`Heartbeat sent for ${this.currentChannel}`);
|
|
652
659
|
} catch (error) {
|
|
@@ -686,13 +693,9 @@ var InteractionsModule = class {
|
|
|
686
693
|
return null;
|
|
687
694
|
}
|
|
688
695
|
try {
|
|
689
|
-
const response = await this.client.
|
|
696
|
+
const response = await this.client.signedRequest("/interact", {
|
|
690
697
|
method: "POST",
|
|
691
|
-
body: JSON.stringify({
|
|
692
|
-
action: "like",
|
|
693
|
-
channelSlug,
|
|
694
|
-
walletAddress
|
|
695
|
-
})
|
|
698
|
+
body: JSON.stringify({ action: "like", channelSlug })
|
|
696
699
|
});
|
|
697
700
|
if (response.alreadyExists) {
|
|
698
701
|
this.client.log(`Already liked ${channelSlug}`);
|
|
@@ -719,13 +722,9 @@ var InteractionsModule = class {
|
|
|
719
722
|
return null;
|
|
720
723
|
}
|
|
721
724
|
try {
|
|
722
|
-
const response = await this.client.
|
|
725
|
+
const response = await this.client.signedRequest("/interact", {
|
|
723
726
|
method: "POST",
|
|
724
|
-
body: JSON.stringify({
|
|
725
|
-
action: "follow",
|
|
726
|
-
channelSlug,
|
|
727
|
-
walletAddress
|
|
728
|
-
})
|
|
727
|
+
body: JSON.stringify({ action: "follow", channelSlug })
|
|
729
728
|
});
|
|
730
729
|
if (response.alreadyExists) {
|
|
731
730
|
this.client.log(`Already following ${channelSlug}`);
|
|
@@ -1663,7 +1662,6 @@ var import_math4 = require("@dcl/sdk/math");
|
|
|
1663
1662
|
var import_SignedFetch = require("~system/SignedFetch");
|
|
1664
1663
|
var import_players = require("@dcl/sdk/players");
|
|
1665
1664
|
var import_RestrictedActions2 = require("~system/RestrictedActions");
|
|
1666
|
-
var FIREBASE_API_KEY = "AIzaSyCX5jViDWUSagUmAX7S4OXgXyJZ9shaC5Y";
|
|
1667
1665
|
var POLL_INTERVAL_ACTIVE = 5e3;
|
|
1668
1666
|
var POLL_INTERVAL_PASSIVE = 3e4;
|
|
1669
1667
|
var ChatUIModule = class {
|
|
@@ -1671,8 +1669,10 @@ var ChatUIModule = class {
|
|
|
1671
1669
|
// Visibility state
|
|
1672
1670
|
this._isVisible = false;
|
|
1673
1671
|
this._unreadCount = 0;
|
|
1674
|
-
// Authentication state
|
|
1675
|
-
|
|
1672
|
+
// Authentication state. There is no login token (thestatic.tv STATIC-01, 2026-10-07): the old
|
|
1673
|
+
// flow got a Firebase custom token from /api/auth/dcl, which any scene could ask for on a
|
|
1674
|
+
// visitor's behalf. Status and sends are now DCL signed requests bound to this scene.
|
|
1675
|
+
this.authChecked = false;
|
|
1676
1676
|
this.isSigningIn = false;
|
|
1677
1677
|
this.isRegisteredUser = false;
|
|
1678
1678
|
this.currentUsername = "Guest";
|
|
@@ -1832,7 +1832,12 @@ var ChatUIModule = class {
|
|
|
1832
1832
|
return baseUrl.replace("/api/v1/dcl", "");
|
|
1833
1833
|
}
|
|
1834
1834
|
async performAuth() {
|
|
1835
|
-
if (this.isSigningIn || this.
|
|
1835
|
+
if (this.isSigningIn || this.authChecked) return;
|
|
1836
|
+
const sceneId = this.client.getSceneId();
|
|
1837
|
+
if (!sceneId) {
|
|
1838
|
+
this.client.log("Chat: no sceneId - signed chat needs the scene this SDK is registered as");
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1836
1841
|
this.isSigningIn = true;
|
|
1837
1842
|
try {
|
|
1838
1843
|
const baseUrl = this.getBaseUrl();
|
|
@@ -1841,29 +1846,18 @@ var ChatUIModule = class {
|
|
|
1841
1846
|
init: {
|
|
1842
1847
|
method: "POST",
|
|
1843
1848
|
headers: { "Content-Type": "application/json" },
|
|
1844
|
-
body: JSON.stringify({})
|
|
1849
|
+
body: JSON.stringify({ sceneId })
|
|
1845
1850
|
}
|
|
1846
1851
|
});
|
|
1847
|
-
if (!response.ok) throw new Error("Backend refused
|
|
1852
|
+
if (!response.ok) throw new Error("Backend refused the signed status check");
|
|
1848
1853
|
const authData = JSON.parse(response.body);
|
|
1849
1854
|
if (authData.username) this.currentUsername = authData.username;
|
|
1850
1855
|
this.isRegisteredUser = !!authData.isRegistered;
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
method: "POST",
|
|
1855
|
-
headers: { "Content-Type": "application/json" },
|
|
1856
|
-
body: JSON.stringify({ token: authData.token, returnSecureToken: true })
|
|
1857
|
-
}
|
|
1858
|
-
);
|
|
1859
|
-
const exchangeData = await exchangeRes.json();
|
|
1860
|
-
if (exchangeData.idToken) {
|
|
1861
|
-
this.idToken = exchangeData.idToken;
|
|
1862
|
-
if (this.inputText && this.isRegisteredUser) {
|
|
1863
|
-
this.handleSend();
|
|
1864
|
-
}
|
|
1856
|
+
this.authChecked = true;
|
|
1857
|
+
if (this.inputText && this.isRegisteredUser) {
|
|
1858
|
+
this.handleSend();
|
|
1865
1859
|
}
|
|
1866
|
-
this.client.log("Chat
|
|
1860
|
+
this.client.log("Chat status checked");
|
|
1867
1861
|
} catch (e) {
|
|
1868
1862
|
this.client.log(`Chat auth failed: ${e}`);
|
|
1869
1863
|
} finally {
|
|
@@ -1932,11 +1926,13 @@ var ChatUIModule = class {
|
|
|
1932
1926
|
}
|
|
1933
1927
|
async handleSend() {
|
|
1934
1928
|
if (!this.inputText.trim()) return;
|
|
1935
|
-
if (!this.
|
|
1929
|
+
if (!this.authChecked) {
|
|
1936
1930
|
await this.performAuth();
|
|
1937
1931
|
return;
|
|
1938
1932
|
}
|
|
1939
1933
|
if (!this.isRegisteredUser) return;
|
|
1934
|
+
const sceneId = this.client.getSceneId();
|
|
1935
|
+
if (!sceneId) return;
|
|
1940
1936
|
const message = this.inputText.trim();
|
|
1941
1937
|
this.inputText = "";
|
|
1942
1938
|
try {
|
|
@@ -1945,18 +1941,15 @@ var ChatUIModule = class {
|
|
|
1945
1941
|
url: `${baseUrl}/api/chat/send`,
|
|
1946
1942
|
init: {
|
|
1947
1943
|
method: "POST",
|
|
1948
|
-
headers: {
|
|
1949
|
-
|
|
1950
|
-
Authorization: `Bearer ${this.idToken}`
|
|
1951
|
-
},
|
|
1952
|
-
body: JSON.stringify({ channelId: this.currentChannelId, text: message })
|
|
1944
|
+
headers: { "Content-Type": "application/json" },
|
|
1945
|
+
body: JSON.stringify({ channelId: this.currentChannelId, text: message, sceneId })
|
|
1953
1946
|
}
|
|
1954
1947
|
});
|
|
1955
1948
|
if (response.ok) {
|
|
1956
1949
|
await this.fetchMessages();
|
|
1957
1950
|
this.resetChatTimer();
|
|
1958
|
-
} else if (response.status === 401) {
|
|
1959
|
-
this.
|
|
1951
|
+
} else if (response.status === 401 || response.status === 403) {
|
|
1952
|
+
this.authChecked = false;
|
|
1960
1953
|
this.performAuth();
|
|
1961
1954
|
}
|
|
1962
1955
|
} catch (e) {
|
|
@@ -2460,6 +2453,7 @@ var import_react_ecs5 = __toESM(require("@dcl/sdk/react-ecs"));
|
|
|
2460
2453
|
var import_math5 = require("@dcl/sdk/math");
|
|
2461
2454
|
var import_players2 = require("@dcl/sdk/players");
|
|
2462
2455
|
var import_RestrictedActions3 = require("~system/RestrictedActions");
|
|
2456
|
+
var import_SignedFetch2 = require("~system/SignedFetch");
|
|
2463
2457
|
|
|
2464
2458
|
// src/ui/ui-renderer.tsx
|
|
2465
2459
|
var import_react_ecs4 = __toESM(require("@dcl/sdk/react-ecs"));
|
|
@@ -3225,8 +3219,8 @@ var AdminPanelUIModule = class {
|
|
|
3225
3219
|
return;
|
|
3226
3220
|
}
|
|
3227
3221
|
try {
|
|
3228
|
-
const res = await
|
|
3229
|
-
`${this.baseUrl}/scene/${this.config.sceneId}/admin-check
|
|
3222
|
+
const res = await this.signedRequest(
|
|
3223
|
+
`${this.baseUrl}/scene/${this.config.sceneId}/admin-check`
|
|
3230
3224
|
);
|
|
3231
3225
|
if (res.ok) {
|
|
3232
3226
|
const data = await res.json();
|
|
@@ -3327,6 +3321,20 @@ var AdminPanelUIModule = class {
|
|
|
3327
3321
|
this.log("Command polling stopped");
|
|
3328
3322
|
}
|
|
3329
3323
|
}
|
|
3324
|
+
/**
|
|
3325
|
+
* Every gated admin call is a DCL signed fetch (thestatic.tv STATIC-01, 2026-10-07): the
|
|
3326
|
+
* explorer signs it with the player's identity, and the server checks the signature and that it
|
|
3327
|
+
* came from the scene deployed at this scene's registered location. A wallet named in a query or
|
|
3328
|
+
* body proved nothing and is no longer sent. Returns a fetch-like shape for the call sites.
|
|
3329
|
+
*/
|
|
3330
|
+
async signedRequest(url, init = {}) {
|
|
3331
|
+
const res = await (0, import_SignedFetch2.signedFetch)({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
|
|
3332
|
+
return {
|
|
3333
|
+
ok: res.ok,
|
|
3334
|
+
status: res.status,
|
|
3335
|
+
json: async () => res.body ? JSON.parse(res.body) : {}
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3330
3338
|
async pollCommands() {
|
|
3331
3339
|
try {
|
|
3332
3340
|
const res = await fetch(`${this.baseUrl}/scene/${this.config.sceneId}/commands`);
|
|
@@ -3370,8 +3378,8 @@ var AdminPanelUIModule = class {
|
|
|
3370
3378
|
async fetchStreamData() {
|
|
3371
3379
|
if (this.streamFetched || !this.playerWallet) return;
|
|
3372
3380
|
try {
|
|
3373
|
-
const res = await
|
|
3374
|
-
`${this.baseUrl}/scene/${this.config.sceneId}/stream
|
|
3381
|
+
const res = await this.signedRequest(
|
|
3382
|
+
`${this.baseUrl}/scene/${this.config.sceneId}/stream`
|
|
3375
3383
|
);
|
|
3376
3384
|
if (res.ok) {
|
|
3377
3385
|
this.streamData = await res.json();
|
|
@@ -3385,8 +3393,8 @@ var AdminPanelUIModule = class {
|
|
|
3385
3393
|
async refreshStreamStatus() {
|
|
3386
3394
|
if (!this.playerWallet) return;
|
|
3387
3395
|
try {
|
|
3388
|
-
const res = await
|
|
3389
|
-
`${this.baseUrl}/scene/${this.config.sceneId}/stream
|
|
3396
|
+
const res = await this.signedRequest(
|
|
3397
|
+
`${this.baseUrl}/scene/${this.config.sceneId}/stream`
|
|
3390
3398
|
);
|
|
3391
3399
|
if (res.ok) {
|
|
3392
3400
|
this.streamData = await res.json();
|
|
@@ -3445,12 +3453,12 @@ var AdminPanelUIModule = class {
|
|
|
3445
3453
|
this.channelCreateError = "";
|
|
3446
3454
|
try {
|
|
3447
3455
|
this.log("Creating channel for scene...");
|
|
3448
|
-
const res = await
|
|
3456
|
+
const res = await this.signedRequest(
|
|
3449
3457
|
`${this.baseUrl}/scene/${this.config.sceneId}/stream/create`,
|
|
3450
3458
|
{
|
|
3451
3459
|
method: "POST",
|
|
3452
3460
|
headers: { "Content-Type": "application/json" },
|
|
3453
|
-
body: JSON.stringify({
|
|
3461
|
+
body: JSON.stringify({})
|
|
3454
3462
|
}
|
|
3455
3463
|
);
|
|
3456
3464
|
const data = await res.json();
|
|
@@ -3475,12 +3483,12 @@ var AdminPanelUIModule = class {
|
|
|
3475
3483
|
this.trialClaimError = "";
|
|
3476
3484
|
try {
|
|
3477
3485
|
this.log("Claiming streaming trial...");
|
|
3478
|
-
const res = await
|
|
3486
|
+
const res = await this.signedRequest(
|
|
3479
3487
|
`${this.baseUrl}/scene/${this.config.sceneId}/stream/claim-trial`,
|
|
3480
3488
|
{
|
|
3481
3489
|
method: "POST",
|
|
3482
3490
|
headers: { "Content-Type": "application/json" },
|
|
3483
|
-
body: JSON.stringify({
|
|
3491
|
+
body: JSON.stringify({})
|
|
3484
3492
|
}
|
|
3485
3493
|
);
|
|
3486
3494
|
const data = await res.json();
|
|
@@ -3505,12 +3513,12 @@ var AdminPanelUIModule = class {
|
|
|
3505
3513
|
this.channelDeleteError = "";
|
|
3506
3514
|
try {
|
|
3507
3515
|
this.log("Deleting channel for scene...");
|
|
3508
|
-
const res = await
|
|
3516
|
+
const res = await this.signedRequest(
|
|
3509
3517
|
`${this.baseUrl}/scene/${this.config.sceneId}/stream/delete`,
|
|
3510
3518
|
{
|
|
3511
3519
|
method: "POST",
|
|
3512
3520
|
headers: { "Content-Type": "application/json" },
|
|
3513
|
-
body: JSON.stringify({
|
|
3521
|
+
body: JSON.stringify({})
|
|
3514
3522
|
}
|
|
3515
3523
|
);
|
|
3516
3524
|
const data = await res.json();
|
|
@@ -3540,12 +3548,12 @@ var AdminPanelUIModule = class {
|
|
|
3540
3548
|
this.streamControlStatus = "";
|
|
3541
3549
|
try {
|
|
3542
3550
|
this.log("Starting stream...");
|
|
3543
|
-
const res = await
|
|
3551
|
+
const res = await this.signedRequest(
|
|
3544
3552
|
`${this.baseUrl}/scene/${this.config.sceneId}/stream`,
|
|
3545
3553
|
{
|
|
3546
3554
|
method: "POST",
|
|
3547
3555
|
headers: { "Content-Type": "application/json" },
|
|
3548
|
-
body: JSON.stringify({ action: "start"
|
|
3556
|
+
body: JSON.stringify({ action: "start" })
|
|
3549
3557
|
}
|
|
3550
3558
|
);
|
|
3551
3559
|
const data = await res.json();
|
|
@@ -3572,12 +3580,12 @@ var AdminPanelUIModule = class {
|
|
|
3572
3580
|
this.streamControlStatus = "";
|
|
3573
3581
|
try {
|
|
3574
3582
|
this.log("Stopping stream...");
|
|
3575
|
-
const res = await
|
|
3583
|
+
const res = await this.signedRequest(
|
|
3576
3584
|
`${this.baseUrl}/scene/${this.config.sceneId}/stream`,
|
|
3577
3585
|
{
|
|
3578
3586
|
method: "POST",
|
|
3579
3587
|
headers: { "Content-Type": "application/json" },
|
|
3580
|
-
body: JSON.stringify({ action: "stop"
|
|
3588
|
+
body: JSON.stringify({ action: "stop" })
|
|
3581
3589
|
}
|
|
3582
3590
|
);
|
|
3583
3591
|
const data = await res.json();
|
|
@@ -3603,12 +3611,12 @@ var AdminPanelUIModule = class {
|
|
|
3603
3611
|
this.keyRotateStatus = "";
|
|
3604
3612
|
try {
|
|
3605
3613
|
this.log("Rotating stream key...");
|
|
3606
|
-
const res = await
|
|
3614
|
+
const res = await this.signedRequest(
|
|
3607
3615
|
`${this.baseUrl}/scene/${this.config.sceneId}/stream`,
|
|
3608
3616
|
{
|
|
3609
3617
|
method: "POST",
|
|
3610
3618
|
headers: { "Content-Type": "application/json" },
|
|
3611
|
-
body: JSON.stringify({ action: "rotateKey"
|
|
3619
|
+
body: JSON.stringify({ action: "rotateKey" })
|
|
3612
3620
|
}
|
|
3613
3621
|
);
|
|
3614
3622
|
const data = await res.json();
|
|
@@ -3631,8 +3639,8 @@ var AdminPanelUIModule = class {
|
|
|
3631
3639
|
if (!this.playerWallet) return;
|
|
3632
3640
|
this.modStatus = "loading";
|
|
3633
3641
|
try {
|
|
3634
|
-
const res = await
|
|
3635
|
-
`${this.baseUrl}/scene/${this.config.sceneId}/config
|
|
3642
|
+
const res = await this.signedRequest(
|
|
3643
|
+
`${this.baseUrl}/scene/${this.config.sceneId}/config`,
|
|
3636
3644
|
{ headers: { "Content-Type": "application/json" } }
|
|
3637
3645
|
);
|
|
3638
3646
|
if (res.ok) {
|
|
@@ -3660,14 +3668,13 @@ var AdminPanelUIModule = class {
|
|
|
3660
3668
|
if (this.sceneAdmins.includes(normalized)) return;
|
|
3661
3669
|
this.modStatus = "loading";
|
|
3662
3670
|
try {
|
|
3663
|
-
const res = await
|
|
3671
|
+
const res = await this.signedRequest(
|
|
3664
3672
|
`${this.baseUrl}/scene/${this.config.sceneId}/config`,
|
|
3665
3673
|
{
|
|
3666
3674
|
method: "POST",
|
|
3667
3675
|
headers: { "Content-Type": "application/json" },
|
|
3668
3676
|
body: JSON.stringify({
|
|
3669
|
-
sceneAdmins: [...this.sceneAdmins, normalized]
|
|
3670
|
-
wallet: this.playerWallet
|
|
3677
|
+
sceneAdmins: [...this.sceneAdmins, normalized]
|
|
3671
3678
|
})
|
|
3672
3679
|
}
|
|
3673
3680
|
);
|
|
@@ -3688,14 +3695,13 @@ var AdminPanelUIModule = class {
|
|
|
3688
3695
|
if (!wallet || !this.playerWallet) return;
|
|
3689
3696
|
this.modStatus = "loading";
|
|
3690
3697
|
try {
|
|
3691
|
-
const res = await
|
|
3698
|
+
const res = await this.signedRequest(
|
|
3692
3699
|
`${this.baseUrl}/scene/${this.config.sceneId}/config`,
|
|
3693
3700
|
{
|
|
3694
3701
|
method: "POST",
|
|
3695
3702
|
headers: { "Content-Type": "application/json" },
|
|
3696
3703
|
body: JSON.stringify({
|
|
3697
|
-
sceneAdmins: this.sceneAdmins.filter((w) => w !== wallet)
|
|
3698
|
-
wallet: this.playerWallet
|
|
3704
|
+
sceneAdmins: this.sceneAdmins.filter((w) => w !== wallet)
|
|
3699
3705
|
})
|
|
3700
3706
|
}
|
|
3701
3707
|
);
|
|
@@ -3721,14 +3727,13 @@ var AdminPanelUIModule = class {
|
|
|
3721
3727
|
if (this.bannedWallets.includes(normalized)) return;
|
|
3722
3728
|
this.modStatus = "loading";
|
|
3723
3729
|
try {
|
|
3724
|
-
const res = await
|
|
3730
|
+
const res = await this.signedRequest(
|
|
3725
3731
|
`${this.baseUrl}/scene/${this.config.sceneId}/config`,
|
|
3726
3732
|
{
|
|
3727
3733
|
method: "POST",
|
|
3728
3734
|
headers: { "Content-Type": "application/json" },
|
|
3729
3735
|
body: JSON.stringify({
|
|
3730
|
-
bannedWallets: [...this.bannedWallets, normalized]
|
|
3731
|
-
wallet: this.playerWallet
|
|
3736
|
+
bannedWallets: [...this.bannedWallets, normalized]
|
|
3732
3737
|
})
|
|
3733
3738
|
}
|
|
3734
3739
|
);
|
|
@@ -3750,14 +3755,13 @@ var AdminPanelUIModule = class {
|
|
|
3750
3755
|
if (!wallet || !this.playerWallet) return;
|
|
3751
3756
|
this.modStatus = "loading";
|
|
3752
3757
|
try {
|
|
3753
|
-
const res = await
|
|
3758
|
+
const res = await this.signedRequest(
|
|
3754
3759
|
`${this.baseUrl}/scene/${this.config.sceneId}/config`,
|
|
3755
3760
|
{
|
|
3756
3761
|
method: "POST",
|
|
3757
3762
|
headers: { "Content-Type": "application/json" },
|
|
3758
3763
|
body: JSON.stringify({
|
|
3759
|
-
bannedWallets: this.bannedWallets.filter((w) => w !== wallet)
|
|
3760
|
-
wallet: this.playerWallet
|
|
3764
|
+
bannedWallets: this.bannedWallets.filter((w) => w !== wallet)
|
|
3761
3765
|
})
|
|
3762
3766
|
}
|
|
3763
3767
|
);
|
|
@@ -3957,6 +3961,7 @@ var StaticTVClient = class {
|
|
|
3957
3961
|
...config
|
|
3958
3962
|
};
|
|
3959
3963
|
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
3964
|
+
this.apiUrl = config.apiUrl || DEFAULT_BASE_URL;
|
|
3960
3965
|
if (!config.apiKey) {
|
|
3961
3966
|
this._disabled = true;
|
|
3962
3967
|
this._keyType = null;
|
|
@@ -4009,7 +4014,7 @@ var StaticTVClient = class {
|
|
|
4009
4014
|
}
|
|
4010
4015
|
/** Get the API base URL (for internal module use) */
|
|
4011
4016
|
getBaseUrl() {
|
|
4012
|
-
return this.
|
|
4017
|
+
return this.apiUrl;
|
|
4013
4018
|
}
|
|
4014
4019
|
/**
|
|
4015
4020
|
* Get the key type (channel, scene, or null if disabled)
|
|
@@ -4076,7 +4081,7 @@ var StaticTVClient = class {
|
|
|
4076
4081
|
* @internal
|
|
4077
4082
|
*/
|
|
4078
4083
|
async request(endpoint, options = {}) {
|
|
4079
|
-
const url = `${this.
|
|
4084
|
+
const url = `${this.apiUrl}${endpoint}`;
|
|
4080
4085
|
return request(url, {
|
|
4081
4086
|
...options,
|
|
4082
4087
|
headers: {
|
|
@@ -4086,6 +4091,33 @@ var StaticTVClient = class {
|
|
|
4086
4091
|
}
|
|
4087
4092
|
});
|
|
4088
4093
|
}
|
|
4094
|
+
/**
|
|
4095
|
+
* Make an API request the explorer signs as the player (DCL signed fetch): thestatic.tv credits
|
|
4096
|
+
* it to that proven wallet and checks it came from this scene - never a wallet the request names.
|
|
4097
|
+
* @internal
|
|
4098
|
+
*/
|
|
4099
|
+
async signedRequest(endpoint, init = {}) {
|
|
4100
|
+
const response = await (0, import_SignedFetch3.signedFetch)({
|
|
4101
|
+
url: `${this.apiUrl}${endpoint}`,
|
|
4102
|
+
init: {
|
|
4103
|
+
method: init.method || "POST",
|
|
4104
|
+
headers: {
|
|
4105
|
+
"Content-Type": "application/json",
|
|
4106
|
+
"x-dcl-api-key": this.config.apiKey
|
|
4107
|
+
},
|
|
4108
|
+
body: init.body
|
|
4109
|
+
}
|
|
4110
|
+
});
|
|
4111
|
+
let data = {};
|
|
4112
|
+
try {
|
|
4113
|
+
data = response.body ? JSON.parse(response.body) : {};
|
|
4114
|
+
} catch {
|
|
4115
|
+
}
|
|
4116
|
+
if (!response.ok) {
|
|
4117
|
+
throw new Error(data.error || `HTTP ${response.status}`);
|
|
4118
|
+
}
|
|
4119
|
+
return data;
|
|
4120
|
+
}
|
|
4089
4121
|
/**
|
|
4090
4122
|
* Log a debug message (only when debug: true)
|
|
4091
4123
|
* @internal
|
|
@@ -4463,6 +4495,14 @@ var StaticTVClient = class {
|
|
|
4463
4495
|
* Enables modules based on tier level
|
|
4464
4496
|
* @internal
|
|
4465
4497
|
*/
|
|
4498
|
+
/**
|
|
4499
|
+
* The TheStatic scene this SDK runs as - config.sceneId, else the API key's id (they are the same
|
|
4500
|
+
* dcl_scenes doc for unified keys). In-world signed requests name it, and the server checks the
|
|
4501
|
+
* request came from the scene deployed at that scene's registered location.
|
|
4502
|
+
*/
|
|
4503
|
+
getSceneId() {
|
|
4504
|
+
return this._pendingProConfig?.sceneId || this.config.sceneId || this._keyId || void 0;
|
|
4505
|
+
}
|
|
4466
4506
|
_enableFeaturesForTier(tier, keyId) {
|
|
4467
4507
|
this._tier = tier;
|
|
4468
4508
|
if (keyId) {
|