@rtsdk/topia 0.11.12 → 0.12.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/dist/index.cjs +218 -44
- package/dist/index.d.ts +131 -5
- package/dist/index.js +217 -45
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -39637,7 +39637,7 @@ const {
|
|
|
39637
39637
|
*/
|
|
39638
39638
|
class SDKController {
|
|
39639
39639
|
constructor(topia, credentials = {}) {
|
|
39640
|
-
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, } = credentials;
|
|
39640
|
+
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, iframeId = null, gameEngineId = null, } = credentials;
|
|
39641
39641
|
this.topia = topia;
|
|
39642
39642
|
this.credentials = credentials;
|
|
39643
39643
|
this.requestOptions = {};
|
|
@@ -39657,6 +39657,12 @@ class SDKController {
|
|
|
39657
39657
|
if (apiKey) {
|
|
39658
39658
|
headers.Authorization = apiKey;
|
|
39659
39659
|
}
|
|
39660
|
+
if (iframeId) {
|
|
39661
|
+
headers.iframeId = iframeId;
|
|
39662
|
+
}
|
|
39663
|
+
if (gameEngineId) {
|
|
39664
|
+
headers.gameEngineId = gameEngineId;
|
|
39665
|
+
}
|
|
39660
39666
|
this.requestOptions = { headers };
|
|
39661
39667
|
}
|
|
39662
39668
|
catch (error) {
|
|
@@ -39717,7 +39723,7 @@ class SDKController {
|
|
|
39717
39723
|
*/
|
|
39718
39724
|
class Asset extends SDKController {
|
|
39719
39725
|
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
39720
|
-
var _a, _b, _c, _d, _e
|
|
39726
|
+
var _a, _b, _c, _d, _e;
|
|
39721
39727
|
// assetId and urlSlug should only be used when Asset is extended by DroppedAsset
|
|
39722
39728
|
super(topia, {
|
|
39723
39729
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
@@ -39727,7 +39733,6 @@ class Asset extends SDKController {
|
|
|
39727
39733
|
visitorId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.visitorId,
|
|
39728
39734
|
});
|
|
39729
39735
|
this.id = id;
|
|
39730
|
-
this.urlSlug = (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.urlSlug;
|
|
39731
39736
|
Object.assign(this, options.attributes);
|
|
39732
39737
|
}
|
|
39733
39738
|
/**
|
|
@@ -39743,7 +39748,8 @@ class Asset extends SDKController {
|
|
|
39743
39748
|
fetchAssetById() {
|
|
39744
39749
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39745
39750
|
try {
|
|
39746
|
-
const response = yield this.topiaPublicApi().get(`/assets/${this.
|
|
39751
|
+
const response = yield this.topiaPublicApi().get(`/assets/${this.id}`, this.requestOptions);
|
|
39752
|
+
Object.assign(this, response.data);
|
|
39747
39753
|
return response.data;
|
|
39748
39754
|
}
|
|
39749
39755
|
catch (error) {
|
|
@@ -39751,6 +39757,44 @@ class Asset extends SDKController {
|
|
|
39751
39757
|
}
|
|
39752
39758
|
});
|
|
39753
39759
|
}
|
|
39760
|
+
/**
|
|
39761
|
+
* @summary
|
|
39762
|
+
* Updates platform asset details.
|
|
39763
|
+
*
|
|
39764
|
+
* @usage
|
|
39765
|
+
* ```ts
|
|
39766
|
+
* await asset.updateAsset({
|
|
39767
|
+
* assetName: "exampleAsset",
|
|
39768
|
+
* bottomLayerURL: null,
|
|
39769
|
+
* creatorTags: { "decorations": true },
|
|
39770
|
+
* isPublic: true,
|
|
39771
|
+
* shouldUploadImages: true,
|
|
39772
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
39773
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
39774
|
+
* });
|
|
39775
|
+
* const { assetName } = asset;
|
|
39776
|
+
* ```
|
|
39777
|
+
*/
|
|
39778
|
+
updateAsset({ assetName, bottomLayerURL, creatorTags, isPublic, shouldUploadImages, tagJson, topLayerURL, }) {
|
|
39779
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39780
|
+
const params = {
|
|
39781
|
+
assetName,
|
|
39782
|
+
bottomLayerURL,
|
|
39783
|
+
creatorTags,
|
|
39784
|
+
isPublic,
|
|
39785
|
+
shouldUploadImages,
|
|
39786
|
+
tagJson,
|
|
39787
|
+
topLayerURL,
|
|
39788
|
+
};
|
|
39789
|
+
try {
|
|
39790
|
+
const response = yield this.topiaPublicApi().put(`/assets/${this.id}`, params, this.requestOptions);
|
|
39791
|
+
Object.assign(this, response.data);
|
|
39792
|
+
}
|
|
39793
|
+
catch (error) {
|
|
39794
|
+
throw this.errorHandler({ error, params, sdkMethod: "Asset.updateAsset" });
|
|
39795
|
+
}
|
|
39796
|
+
});
|
|
39797
|
+
}
|
|
39754
39798
|
}
|
|
39755
39799
|
|
|
39756
39800
|
var _DroppedAsset_updateDroppedAsset;
|
|
@@ -40395,6 +40439,44 @@ const scatterVisitors = (original, scatterBy) => {
|
|
|
40395
40439
|
return Math.floor(Math.random() * (max - min) + min);
|
|
40396
40440
|
};
|
|
40397
40441
|
|
|
40442
|
+
/**
|
|
40443
|
+
* @summary
|
|
40444
|
+
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
40445
|
+
*
|
|
40446
|
+
* @usage
|
|
40447
|
+
* ```ts
|
|
40448
|
+
* const topia = await new Topia({
|
|
40449
|
+
* apiDomain: "api.topia.io",
|
|
40450
|
+
* apiKey: "exampleKey",
|
|
40451
|
+
* interactiveKey: "key",
|
|
40452
|
+
* interactiveSecret: "secret",
|
|
40453
|
+
* });
|
|
40454
|
+
* ```
|
|
40455
|
+
*/
|
|
40456
|
+
class Topia {
|
|
40457
|
+
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, mcAuthorizationKey, }) {
|
|
40458
|
+
getBrowserWarning();
|
|
40459
|
+
this.apiDomain = apiDomain || "api.topia.io";
|
|
40460
|
+
this.apiKey = apiKey;
|
|
40461
|
+
this.apiProtocol = apiProtocol || "https";
|
|
40462
|
+
this.interactiveSecret = interactiveSecret;
|
|
40463
|
+
const headers = {
|
|
40464
|
+
"ApplicationId": "sdk-js-topia",
|
|
40465
|
+
"Content-Type": "application/json",
|
|
40466
|
+
};
|
|
40467
|
+
if (apiKey)
|
|
40468
|
+
headers.Authorization = apiKey;
|
|
40469
|
+
if (interactiveKey)
|
|
40470
|
+
headers.PublicKey = interactiveKey;
|
|
40471
|
+
if (mcAuthorizationKey)
|
|
40472
|
+
headers.MCAuthorizationKey = mcAuthorizationKey;
|
|
40473
|
+
this.axios = axios.create({
|
|
40474
|
+
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
40475
|
+
headers,
|
|
40476
|
+
});
|
|
40477
|
+
}
|
|
40478
|
+
}
|
|
40479
|
+
|
|
40398
40480
|
var _World_droppedAssetsMap;
|
|
40399
40481
|
/**
|
|
40400
40482
|
* @summary
|
|
@@ -41050,13 +41132,15 @@ var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
41050
41132
|
*/
|
|
41051
41133
|
class User extends SDKController {
|
|
41052
41134
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
41053
|
-
var _a, _b, _c, _d;
|
|
41135
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41054
41136
|
super(topia, {
|
|
41055
41137
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
41056
41138
|
interactiveNonce: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.interactiveNonce,
|
|
41057
41139
|
profileId: options === null || options === void 0 ? void 0 : options.profileId,
|
|
41058
41140
|
urlSlug: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.urlSlug,
|
|
41059
41141
|
visitorId: (_d = options === null || options === void 0 ? void 0 : options.credentials) === null || _d === void 0 ? void 0 : _d.visitorId,
|
|
41142
|
+
iframeId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.iframeId,
|
|
41143
|
+
gameEngineId: (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.gameEngineId,
|
|
41060
41144
|
});
|
|
41061
41145
|
_User_adminWorldsMap.set(this, void 0);
|
|
41062
41146
|
_User_assetsMap.set(this, void 0);
|
|
@@ -41959,6 +42043,75 @@ class Visitor extends User {
|
|
|
41959
42043
|
}
|
|
41960
42044
|
});
|
|
41961
42045
|
}
|
|
42046
|
+
/**
|
|
42047
|
+
* @summary
|
|
42048
|
+
* Setup signal to visitor
|
|
42049
|
+
*
|
|
42050
|
+
* @usage
|
|
42051
|
+
* ```ts
|
|
42052
|
+
* await visitor.sendSignalToVisitor(iceServers);
|
|
42053
|
+
* ```
|
|
42054
|
+
*/
|
|
42055
|
+
sendSignalToVisitor(signal) {
|
|
42056
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42057
|
+
try {
|
|
42058
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/send-signal-to-visitor`, { signal }, this.requestOptions);
|
|
42059
|
+
return response.data;
|
|
42060
|
+
}
|
|
42061
|
+
catch (error) {
|
|
42062
|
+
throw this.errorHandler({
|
|
42063
|
+
error,
|
|
42064
|
+
params: { signal },
|
|
42065
|
+
sdkMethod: "Visitor.sendSignalToVisitor",
|
|
42066
|
+
});
|
|
42067
|
+
}
|
|
42068
|
+
});
|
|
42069
|
+
}
|
|
42070
|
+
}
|
|
42071
|
+
|
|
42072
|
+
/**
|
|
42073
|
+
* @summary
|
|
42074
|
+
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
42075
|
+
*
|
|
42076
|
+
* @usage
|
|
42077
|
+
* ```ts
|
|
42078
|
+
* await new WebRTCConnector(topia, {
|
|
42079
|
+
* credentials: { interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
|
|
42080
|
+
* });
|
|
42081
|
+
* ```
|
|
42082
|
+
*/
|
|
42083
|
+
class WebRTCConnector extends SDKController {
|
|
42084
|
+
constructor(topia, urlSlug, options = { twilioConfig: {}, credentials: {} }) {
|
|
42085
|
+
var _a, _b, _c;
|
|
42086
|
+
super(topia, {
|
|
42087
|
+
interactiveNonce: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.interactiveNonce,
|
|
42088
|
+
urlSlug: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.urlSlug,
|
|
42089
|
+
visitorId: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.visitorId,
|
|
42090
|
+
});
|
|
42091
|
+
this.twilioConfig = options === null || options === void 0 ? void 0 : options.twilioConfig;
|
|
42092
|
+
this.urlSlug = urlSlug;
|
|
42093
|
+
}
|
|
42094
|
+
/**
|
|
42095
|
+
* @summary
|
|
42096
|
+
* Get twilio
|
|
42097
|
+
*
|
|
42098
|
+
* @usage
|
|
42099
|
+
* ```ts
|
|
42100
|
+
* await webRTCConnector.getTwilioConfig();
|
|
42101
|
+
* ```
|
|
42102
|
+
*/
|
|
42103
|
+
getTwilioConfig() {
|
|
42104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42105
|
+
try {
|
|
42106
|
+
const response = yield this.topiaPublicApi().get(`/webrtc/twilio-config`, this.requestOptions);
|
|
42107
|
+
this.twilioConfig = response.data.twilioConfig;
|
|
42108
|
+
return response.data;
|
|
42109
|
+
}
|
|
42110
|
+
catch (error) {
|
|
42111
|
+
throw this.errorHandler({ error, sdkMethod: "WebRTCConnector.getTwilioConfig" });
|
|
42112
|
+
}
|
|
42113
|
+
});
|
|
42114
|
+
}
|
|
41962
42115
|
}
|
|
41963
42116
|
|
|
41964
42117
|
var _WorldActivity_visitorsMap;
|
|
@@ -42138,52 +42291,15 @@ class WorldActivity extends SDKController {
|
|
|
42138
42291
|
}
|
|
42139
42292
|
_WorldActivity_visitorsMap = new WeakMap();
|
|
42140
42293
|
|
|
42141
|
-
/**
|
|
42142
|
-
* @summary
|
|
42143
|
-
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
42144
|
-
*
|
|
42145
|
-
* @usage
|
|
42146
|
-
* ```ts
|
|
42147
|
-
* const topia = await new Topia({
|
|
42148
|
-
* apiDomain: "api.topia.io",
|
|
42149
|
-
* apiKey: "exampleKey",
|
|
42150
|
-
* interactiveKey: "key",
|
|
42151
|
-
* interactiveSecret: "secret",
|
|
42152
|
-
* });
|
|
42153
|
-
* ```
|
|
42154
|
-
*/
|
|
42155
|
-
class Topia {
|
|
42156
|
-
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, }) {
|
|
42157
|
-
getBrowserWarning();
|
|
42158
|
-
this.apiDomain = apiDomain || "api.topia.io";
|
|
42159
|
-
this.apiKey = apiKey;
|
|
42160
|
-
this.apiProtocol = apiProtocol || "https";
|
|
42161
|
-
this.interactiveSecret = interactiveSecret;
|
|
42162
|
-
const headers = {
|
|
42163
|
-
"ApplicationId": "sdk-js-topia",
|
|
42164
|
-
"Content-Type": "application/json",
|
|
42165
|
-
};
|
|
42166
|
-
if (apiKey)
|
|
42167
|
-
headers.Authorization = apiKey;
|
|
42168
|
-
if (interactiveKey)
|
|
42169
|
-
headers.PublicKey = interactiveKey;
|
|
42170
|
-
this.axios = axios.create({
|
|
42171
|
-
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
42172
|
-
headers,
|
|
42173
|
-
});
|
|
42174
|
-
}
|
|
42175
|
-
}
|
|
42176
|
-
|
|
42177
42294
|
/**
|
|
42178
42295
|
* @usage
|
|
42179
42296
|
* ```ts
|
|
42180
42297
|
* const Asset = new AssetFactory(myTopiaInstance);
|
|
42181
42298
|
* ```
|
|
42182
42299
|
*/
|
|
42183
|
-
class AssetFactory {
|
|
42300
|
+
class AssetFactory extends SDKController {
|
|
42184
42301
|
constructor(topia) {
|
|
42185
|
-
|
|
42186
|
-
this.create;
|
|
42302
|
+
super(topia);
|
|
42187
42303
|
}
|
|
42188
42304
|
/**
|
|
42189
42305
|
* @summary
|
|
@@ -42197,6 +42313,38 @@ class AssetFactory {
|
|
|
42197
42313
|
create(id, options) {
|
|
42198
42314
|
return new Asset(this.topia, id, options);
|
|
42199
42315
|
}
|
|
42316
|
+
/**
|
|
42317
|
+
* @summary
|
|
42318
|
+
* Upload a new Asset and return a new instance of Asset class.
|
|
42319
|
+
*
|
|
42320
|
+
* @usage
|
|
42321
|
+
* ```
|
|
42322
|
+
* const assetPayload = {
|
|
42323
|
+
* assetName: "exampleAssetName"
|
|
42324
|
+
* bottomLayerURL: "https://example.bottomLayerURL"
|
|
42325
|
+
* creatorTags: { "decorations": true },
|
|
42326
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
42327
|
+
* isPublic: true,
|
|
42328
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
42329
|
+
* }
|
|
42330
|
+
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
42331
|
+
* ```
|
|
42332
|
+
*/
|
|
42333
|
+
upload(assetPayload, apiKey) {
|
|
42334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42335
|
+
try {
|
|
42336
|
+
if (!apiKey)
|
|
42337
|
+
throw "A valid API Key is required.";
|
|
42338
|
+
const headers = { Authorization: apiKey };
|
|
42339
|
+
const response = yield this.topiaPublicApi().post("/assets", assetPayload, { headers });
|
|
42340
|
+
const { assetId, asset } = response.data;
|
|
42341
|
+
return new Asset(this.topia, assetId, { attributes: asset });
|
|
42342
|
+
}
|
|
42343
|
+
catch (error) {
|
|
42344
|
+
throw this.errorHandler({ error, params: assetPayload, sdkMethod: "AssetFactory.upload" });
|
|
42345
|
+
}
|
|
42346
|
+
});
|
|
42347
|
+
}
|
|
42200
42348
|
}
|
|
42201
42349
|
|
|
42202
42350
|
/**
|
|
@@ -42431,6 +42579,30 @@ class VisitorFactory {
|
|
|
42431
42579
|
}
|
|
42432
42580
|
}
|
|
42433
42581
|
|
|
42582
|
+
/**
|
|
42583
|
+
* @usage
|
|
42584
|
+
* ```ts
|
|
42585
|
+
* const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
|
|
42586
|
+
* ```
|
|
42587
|
+
*/
|
|
42588
|
+
class WebRTCConnectorFactory {
|
|
42589
|
+
constructor(topia) {
|
|
42590
|
+
this.topia = topia;
|
|
42591
|
+
}
|
|
42592
|
+
/**
|
|
42593
|
+
* @summary
|
|
42594
|
+
* Instantiate a new instance of WebRTCConnector class.
|
|
42595
|
+
*
|
|
42596
|
+
* @usage
|
|
42597
|
+
* ```
|
|
42598
|
+
* const userInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, urlSlug, visitorId }, twilioConfig: {} });
|
|
42599
|
+
* ```
|
|
42600
|
+
*/
|
|
42601
|
+
create(urlSlug, options) {
|
|
42602
|
+
return new WebRTCConnector(this.topia, urlSlug, options);
|
|
42603
|
+
}
|
|
42604
|
+
}
|
|
42605
|
+
|
|
42434
42606
|
/**
|
|
42435
42607
|
* @usage
|
|
42436
42608
|
* ```ts
|
|
@@ -42547,6 +42719,8 @@ exports.User = User;
|
|
|
42547
42719
|
exports.UserFactory = UserFactory;
|
|
42548
42720
|
exports.Visitor = Visitor;
|
|
42549
42721
|
exports.VisitorFactory = VisitorFactory;
|
|
42722
|
+
exports.WebRTCConnector = WebRTCConnector;
|
|
42723
|
+
exports.WebRTCConnectorFactory = WebRTCConnectorFactory;
|
|
42550
42724
|
exports.World = World;
|
|
42551
42725
|
exports.WorldActivity = WorldActivity;
|
|
42552
42726
|
exports.WorldActivityFactory = WorldActivityFactory;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,17 @@ type AnalyticType = {
|
|
|
10
10
|
urlSlug?: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
type AssetType = {
|
|
14
|
+
assetName: string;
|
|
15
|
+
bottomLayerURL: string;
|
|
16
|
+
creatorTags: {
|
|
17
|
+
[key: string]: boolean;
|
|
18
|
+
};
|
|
19
|
+
tagJson: string;
|
|
20
|
+
isPublic: true;
|
|
21
|
+
topLayerURL: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
13
24
|
declare enum DroppedAssetClickType {
|
|
14
25
|
NONE = "none",
|
|
15
26
|
LINK = "link",
|
|
@@ -30,6 +41,8 @@ type InteractiveCredentials = {
|
|
|
30
41
|
profileId?: string | null;
|
|
31
42
|
urlSlug?: string;
|
|
32
43
|
visitorId?: number;
|
|
44
|
+
iframeId?: string;
|
|
45
|
+
gameEngineId?: string;
|
|
33
46
|
};
|
|
34
47
|
|
|
35
48
|
type AssetOptions = {
|
|
@@ -1375,6 +1388,18 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
1375
1388
|
* ```
|
|
1376
1389
|
*/
|
|
1377
1390
|
updatePublicKeyAnalytics(analytics?: AnalyticType[]): Promise<void | ResponseType$1>;
|
|
1391
|
+
/**
|
|
1392
|
+
* @summary
|
|
1393
|
+
* Setup signal to visitor
|
|
1394
|
+
*
|
|
1395
|
+
* @usage
|
|
1396
|
+
* ```ts
|
|
1397
|
+
* await visitor.sendSignalToVisitor(iceServers);
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
sendSignalToVisitor(signal: any): Promise<void | (ResponseType$1 & {
|
|
1401
|
+
answerSignal: any;
|
|
1402
|
+
})>;
|
|
1378
1403
|
}
|
|
1379
1404
|
|
|
1380
1405
|
type VisitorType = {
|
|
@@ -1702,6 +1727,14 @@ interface WebhookInterface {
|
|
|
1702
1727
|
urlSlug: string;
|
|
1703
1728
|
}
|
|
1704
1729
|
|
|
1730
|
+
interface WebRTCConnectorInterface {
|
|
1731
|
+
getTwilioConfig(): Promise<void | ResponseType$1>;
|
|
1732
|
+
}
|
|
1733
|
+
interface WebRTCConnectorOptionalInterface {
|
|
1734
|
+
credentials?: InteractiveCredentials;
|
|
1735
|
+
twilioConfig?: object;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1705
1738
|
interface WorldActivityOptionalInterface {
|
|
1706
1739
|
credentials?: InteractiveCredentials;
|
|
1707
1740
|
}
|
|
@@ -1790,12 +1823,14 @@ declare class Topia implements TopiaInterface {
|
|
|
1790
1823
|
apiProtocol?: string;
|
|
1791
1824
|
interactiveKey?: string;
|
|
1792
1825
|
interactiveSecret?: jwt.Secret;
|
|
1793
|
-
|
|
1826
|
+
mcAuthorizationKey?: string;
|
|
1827
|
+
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, mcAuthorizationKey, }: {
|
|
1794
1828
|
apiDomain?: string;
|
|
1795
1829
|
apiKey?: string;
|
|
1796
1830
|
apiProtocol?: string;
|
|
1797
1831
|
interactiveKey?: string;
|
|
1798
1832
|
interactiveSecret?: jwt.Secret;
|
|
1833
|
+
mcAuthorizationKey?: string;
|
|
1799
1834
|
});
|
|
1800
1835
|
}
|
|
1801
1836
|
|
|
@@ -1861,7 +1896,6 @@ declare abstract class SDKController implements SDKInterface {
|
|
|
1861
1896
|
*/
|
|
1862
1897
|
declare class Asset extends SDKController implements AssetInterface {
|
|
1863
1898
|
readonly id?: string;
|
|
1864
|
-
urlSlug?: string;
|
|
1865
1899
|
constructor(topia: Topia, id: string, options?: AssetOptionalInterface);
|
|
1866
1900
|
/**
|
|
1867
1901
|
* @summary
|
|
@@ -1874,6 +1908,60 @@ declare class Asset extends SDKController implements AssetInterface {
|
|
|
1874
1908
|
* ```
|
|
1875
1909
|
*/
|
|
1876
1910
|
fetchAssetById(): Promise<object | ResponseType$1>;
|
|
1911
|
+
/**
|
|
1912
|
+
* @summary
|
|
1913
|
+
* Updates platform asset details.
|
|
1914
|
+
*
|
|
1915
|
+
* @usage
|
|
1916
|
+
* ```ts
|
|
1917
|
+
* await asset.updateAsset({
|
|
1918
|
+
* assetName: "exampleAsset",
|
|
1919
|
+
* bottomLayerURL: null,
|
|
1920
|
+
* creatorTags: { "decorations": true },
|
|
1921
|
+
* isPublic: true,
|
|
1922
|
+
* shouldUploadImages: true,
|
|
1923
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
1924
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
1925
|
+
* });
|
|
1926
|
+
* const { assetName } = asset;
|
|
1927
|
+
* ```
|
|
1928
|
+
*/
|
|
1929
|
+
updateAsset({ assetName, bottomLayerURL, creatorTags, isPublic, shouldUploadImages, tagJson, topLayerURL, }: {
|
|
1930
|
+
assetName: string;
|
|
1931
|
+
bottomLayerURL?: string;
|
|
1932
|
+
creatorTags: object;
|
|
1933
|
+
isPublic: boolean;
|
|
1934
|
+
shouldUploadImages?: boolean;
|
|
1935
|
+
tagJson: string;
|
|
1936
|
+
topLayerURL?: string;
|
|
1937
|
+
}): Promise<void | ResponseType$1>;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* @summary
|
|
1942
|
+
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
1943
|
+
*
|
|
1944
|
+
* @usage
|
|
1945
|
+
* ```ts
|
|
1946
|
+
* await new WebRTCConnector(topia, {
|
|
1947
|
+
* credentials: { interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
|
|
1948
|
+
* });
|
|
1949
|
+
* ```
|
|
1950
|
+
*/
|
|
1951
|
+
declare class WebRTCConnector extends SDKController implements WebRTCConnectorInterface {
|
|
1952
|
+
twilioConfig?: object | null | undefined;
|
|
1953
|
+
urlSlug: string;
|
|
1954
|
+
constructor(topia: Topia, urlSlug: string, options?: WebRTCConnectorOptionalInterface);
|
|
1955
|
+
/**
|
|
1956
|
+
* @summary
|
|
1957
|
+
* Get twilio
|
|
1958
|
+
*
|
|
1959
|
+
* @usage
|
|
1960
|
+
* ```ts
|
|
1961
|
+
* await webRTCConnector.getTwilioConfig();
|
|
1962
|
+
* ```
|
|
1963
|
+
*/
|
|
1964
|
+
getTwilioConfig(): Promise<void | ResponseType$1>;
|
|
1877
1965
|
}
|
|
1878
1966
|
|
|
1879
1967
|
/**
|
|
@@ -1980,8 +2068,7 @@ declare class WorldActivity extends SDKController {
|
|
|
1980
2068
|
* const Asset = new AssetFactory(myTopiaInstance);
|
|
1981
2069
|
* ```
|
|
1982
2070
|
*/
|
|
1983
|
-
declare class AssetFactory {
|
|
1984
|
-
topia: Topia;
|
|
2071
|
+
declare class AssetFactory extends SDKController {
|
|
1985
2072
|
constructor(topia: Topia);
|
|
1986
2073
|
/**
|
|
1987
2074
|
* @summary
|
|
@@ -1993,6 +2080,24 @@ declare class AssetFactory {
|
|
|
1993
2080
|
* ```
|
|
1994
2081
|
*/
|
|
1995
2082
|
create(id: string, options?: AssetOptionalInterface): Asset;
|
|
2083
|
+
/**
|
|
2084
|
+
* @summary
|
|
2085
|
+
* Upload a new Asset and return a new instance of Asset class.
|
|
2086
|
+
*
|
|
2087
|
+
* @usage
|
|
2088
|
+
* ```
|
|
2089
|
+
* const assetPayload = {
|
|
2090
|
+
* assetName: "exampleAssetName"
|
|
2091
|
+
* bottomLayerURL: "https://example.bottomLayerURL"
|
|
2092
|
+
* creatorTags: { "decorations": true },
|
|
2093
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
2094
|
+
* isPublic: true,
|
|
2095
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
2096
|
+
* }
|
|
2097
|
+
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
2098
|
+
* ```
|
|
2099
|
+
*/
|
|
2100
|
+
upload(assetPayload: AssetType, apiKey: string): Promise<Asset>;
|
|
1996
2101
|
}
|
|
1997
2102
|
|
|
1998
2103
|
/**
|
|
@@ -2163,6 +2268,27 @@ declare class VisitorFactory {
|
|
|
2163
2268
|
get(id: number, urlSlug: string, options?: VisitorOptionalInterface): Promise<Visitor>;
|
|
2164
2269
|
}
|
|
2165
2270
|
|
|
2271
|
+
/**
|
|
2272
|
+
* @usage
|
|
2273
|
+
* ```ts
|
|
2274
|
+
* const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
|
|
2275
|
+
* ```
|
|
2276
|
+
*/
|
|
2277
|
+
declare class WebRTCConnectorFactory {
|
|
2278
|
+
topia: Topia;
|
|
2279
|
+
constructor(topia: Topia);
|
|
2280
|
+
/**
|
|
2281
|
+
* @summary
|
|
2282
|
+
* Instantiate a new instance of WebRTCConnector class.
|
|
2283
|
+
*
|
|
2284
|
+
* @usage
|
|
2285
|
+
* ```
|
|
2286
|
+
* const userInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, urlSlug, visitorId }, twilioConfig: {} });
|
|
2287
|
+
* ```
|
|
2288
|
+
*/
|
|
2289
|
+
create(urlSlug: string, options?: WebRTCConnectorOptionalInterface): WebRTCConnector;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2166
2292
|
/**
|
|
2167
2293
|
* @usage
|
|
2168
2294
|
* ```ts
|
|
@@ -2220,4 +2346,4 @@ declare class WorldFactory extends SDKController {
|
|
|
2220
2346
|
}>;
|
|
2221
2347
|
}
|
|
2222
2348
|
|
|
2223
|
-
export { Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetMediaType, DroppedAssetOptionalInterface, DroppedAssetOptions, FireToastInterface, InteractiveCredentials, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, ResponseType$1 as ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
|
|
2349
|
+
export { Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, AssetType, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetMediaType, DroppedAssetOptionalInterface, DroppedAssetOptions, FireToastInterface, InteractiveCredentials, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, ResponseType$1 as ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebRTCConnector, WebRTCConnectorFactory, WebRTCConnectorInterface, WebRTCConnectorOptionalInterface, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
|
package/dist/index.js
CHANGED
|
@@ -39635,7 +39635,7 @@ const {
|
|
|
39635
39635
|
*/
|
|
39636
39636
|
class SDKController {
|
|
39637
39637
|
constructor(topia, credentials = {}) {
|
|
39638
|
-
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, } = credentials;
|
|
39638
|
+
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, iframeId = null, gameEngineId = null, } = credentials;
|
|
39639
39639
|
this.topia = topia;
|
|
39640
39640
|
this.credentials = credentials;
|
|
39641
39641
|
this.requestOptions = {};
|
|
@@ -39655,6 +39655,12 @@ class SDKController {
|
|
|
39655
39655
|
if (apiKey) {
|
|
39656
39656
|
headers.Authorization = apiKey;
|
|
39657
39657
|
}
|
|
39658
|
+
if (iframeId) {
|
|
39659
|
+
headers.iframeId = iframeId;
|
|
39660
|
+
}
|
|
39661
|
+
if (gameEngineId) {
|
|
39662
|
+
headers.gameEngineId = gameEngineId;
|
|
39663
|
+
}
|
|
39658
39664
|
this.requestOptions = { headers };
|
|
39659
39665
|
}
|
|
39660
39666
|
catch (error) {
|
|
@@ -39715,7 +39721,7 @@ class SDKController {
|
|
|
39715
39721
|
*/
|
|
39716
39722
|
class Asset extends SDKController {
|
|
39717
39723
|
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
39718
|
-
var _a, _b, _c, _d, _e
|
|
39724
|
+
var _a, _b, _c, _d, _e;
|
|
39719
39725
|
// assetId and urlSlug should only be used when Asset is extended by DroppedAsset
|
|
39720
39726
|
super(topia, {
|
|
39721
39727
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
@@ -39725,7 +39731,6 @@ class Asset extends SDKController {
|
|
|
39725
39731
|
visitorId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.visitorId,
|
|
39726
39732
|
});
|
|
39727
39733
|
this.id = id;
|
|
39728
|
-
this.urlSlug = (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.urlSlug;
|
|
39729
39734
|
Object.assign(this, options.attributes);
|
|
39730
39735
|
}
|
|
39731
39736
|
/**
|
|
@@ -39741,7 +39746,8 @@ class Asset extends SDKController {
|
|
|
39741
39746
|
fetchAssetById() {
|
|
39742
39747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39743
39748
|
try {
|
|
39744
|
-
const response = yield this.topiaPublicApi().get(`/assets/${this.
|
|
39749
|
+
const response = yield this.topiaPublicApi().get(`/assets/${this.id}`, this.requestOptions);
|
|
39750
|
+
Object.assign(this, response.data);
|
|
39745
39751
|
return response.data;
|
|
39746
39752
|
}
|
|
39747
39753
|
catch (error) {
|
|
@@ -39749,6 +39755,44 @@ class Asset extends SDKController {
|
|
|
39749
39755
|
}
|
|
39750
39756
|
});
|
|
39751
39757
|
}
|
|
39758
|
+
/**
|
|
39759
|
+
* @summary
|
|
39760
|
+
* Updates platform asset details.
|
|
39761
|
+
*
|
|
39762
|
+
* @usage
|
|
39763
|
+
* ```ts
|
|
39764
|
+
* await asset.updateAsset({
|
|
39765
|
+
* assetName: "exampleAsset",
|
|
39766
|
+
* bottomLayerURL: null,
|
|
39767
|
+
* creatorTags: { "decorations": true },
|
|
39768
|
+
* isPublic: true,
|
|
39769
|
+
* shouldUploadImages: true,
|
|
39770
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
39771
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
39772
|
+
* });
|
|
39773
|
+
* const { assetName } = asset;
|
|
39774
|
+
* ```
|
|
39775
|
+
*/
|
|
39776
|
+
updateAsset({ assetName, bottomLayerURL, creatorTags, isPublic, shouldUploadImages, tagJson, topLayerURL, }) {
|
|
39777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39778
|
+
const params = {
|
|
39779
|
+
assetName,
|
|
39780
|
+
bottomLayerURL,
|
|
39781
|
+
creatorTags,
|
|
39782
|
+
isPublic,
|
|
39783
|
+
shouldUploadImages,
|
|
39784
|
+
tagJson,
|
|
39785
|
+
topLayerURL,
|
|
39786
|
+
};
|
|
39787
|
+
try {
|
|
39788
|
+
const response = yield this.topiaPublicApi().put(`/assets/${this.id}`, params, this.requestOptions);
|
|
39789
|
+
Object.assign(this, response.data);
|
|
39790
|
+
}
|
|
39791
|
+
catch (error) {
|
|
39792
|
+
throw this.errorHandler({ error, params, sdkMethod: "Asset.updateAsset" });
|
|
39793
|
+
}
|
|
39794
|
+
});
|
|
39795
|
+
}
|
|
39752
39796
|
}
|
|
39753
39797
|
|
|
39754
39798
|
var _DroppedAsset_updateDroppedAsset;
|
|
@@ -40393,6 +40437,44 @@ const scatterVisitors = (original, scatterBy) => {
|
|
|
40393
40437
|
return Math.floor(Math.random() * (max - min) + min);
|
|
40394
40438
|
};
|
|
40395
40439
|
|
|
40440
|
+
/**
|
|
40441
|
+
* @summary
|
|
40442
|
+
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
40443
|
+
*
|
|
40444
|
+
* @usage
|
|
40445
|
+
* ```ts
|
|
40446
|
+
* const topia = await new Topia({
|
|
40447
|
+
* apiDomain: "api.topia.io",
|
|
40448
|
+
* apiKey: "exampleKey",
|
|
40449
|
+
* interactiveKey: "key",
|
|
40450
|
+
* interactiveSecret: "secret",
|
|
40451
|
+
* });
|
|
40452
|
+
* ```
|
|
40453
|
+
*/
|
|
40454
|
+
class Topia {
|
|
40455
|
+
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, mcAuthorizationKey, }) {
|
|
40456
|
+
getBrowserWarning();
|
|
40457
|
+
this.apiDomain = apiDomain || "api.topia.io";
|
|
40458
|
+
this.apiKey = apiKey;
|
|
40459
|
+
this.apiProtocol = apiProtocol || "https";
|
|
40460
|
+
this.interactiveSecret = interactiveSecret;
|
|
40461
|
+
const headers = {
|
|
40462
|
+
"ApplicationId": "sdk-js-topia",
|
|
40463
|
+
"Content-Type": "application/json",
|
|
40464
|
+
};
|
|
40465
|
+
if (apiKey)
|
|
40466
|
+
headers.Authorization = apiKey;
|
|
40467
|
+
if (interactiveKey)
|
|
40468
|
+
headers.PublicKey = interactiveKey;
|
|
40469
|
+
if (mcAuthorizationKey)
|
|
40470
|
+
headers.MCAuthorizationKey = mcAuthorizationKey;
|
|
40471
|
+
this.axios = axios.create({
|
|
40472
|
+
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
40473
|
+
headers,
|
|
40474
|
+
});
|
|
40475
|
+
}
|
|
40476
|
+
}
|
|
40477
|
+
|
|
40396
40478
|
var _World_droppedAssetsMap;
|
|
40397
40479
|
/**
|
|
40398
40480
|
* @summary
|
|
@@ -41048,13 +41130,15 @@ var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
41048
41130
|
*/
|
|
41049
41131
|
class User extends SDKController {
|
|
41050
41132
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
41051
|
-
var _a, _b, _c, _d;
|
|
41133
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41052
41134
|
super(topia, {
|
|
41053
41135
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
41054
41136
|
interactiveNonce: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.interactiveNonce,
|
|
41055
41137
|
profileId: options === null || options === void 0 ? void 0 : options.profileId,
|
|
41056
41138
|
urlSlug: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.urlSlug,
|
|
41057
41139
|
visitorId: (_d = options === null || options === void 0 ? void 0 : options.credentials) === null || _d === void 0 ? void 0 : _d.visitorId,
|
|
41140
|
+
iframeId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.iframeId,
|
|
41141
|
+
gameEngineId: (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.gameEngineId,
|
|
41058
41142
|
});
|
|
41059
41143
|
_User_adminWorldsMap.set(this, void 0);
|
|
41060
41144
|
_User_assetsMap.set(this, void 0);
|
|
@@ -41957,6 +42041,75 @@ class Visitor extends User {
|
|
|
41957
42041
|
}
|
|
41958
42042
|
});
|
|
41959
42043
|
}
|
|
42044
|
+
/**
|
|
42045
|
+
* @summary
|
|
42046
|
+
* Setup signal to visitor
|
|
42047
|
+
*
|
|
42048
|
+
* @usage
|
|
42049
|
+
* ```ts
|
|
42050
|
+
* await visitor.sendSignalToVisitor(iceServers);
|
|
42051
|
+
* ```
|
|
42052
|
+
*/
|
|
42053
|
+
sendSignalToVisitor(signal) {
|
|
42054
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42055
|
+
try {
|
|
42056
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/send-signal-to-visitor`, { signal }, this.requestOptions);
|
|
42057
|
+
return response.data;
|
|
42058
|
+
}
|
|
42059
|
+
catch (error) {
|
|
42060
|
+
throw this.errorHandler({
|
|
42061
|
+
error,
|
|
42062
|
+
params: { signal },
|
|
42063
|
+
sdkMethod: "Visitor.sendSignalToVisitor",
|
|
42064
|
+
});
|
|
42065
|
+
}
|
|
42066
|
+
});
|
|
42067
|
+
}
|
|
42068
|
+
}
|
|
42069
|
+
|
|
42070
|
+
/**
|
|
42071
|
+
* @summary
|
|
42072
|
+
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
42073
|
+
*
|
|
42074
|
+
* @usage
|
|
42075
|
+
* ```ts
|
|
42076
|
+
* await new WebRTCConnector(topia, {
|
|
42077
|
+
* credentials: { interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
|
|
42078
|
+
* });
|
|
42079
|
+
* ```
|
|
42080
|
+
*/
|
|
42081
|
+
class WebRTCConnector extends SDKController {
|
|
42082
|
+
constructor(topia, urlSlug, options = { twilioConfig: {}, credentials: {} }) {
|
|
42083
|
+
var _a, _b, _c;
|
|
42084
|
+
super(topia, {
|
|
42085
|
+
interactiveNonce: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.interactiveNonce,
|
|
42086
|
+
urlSlug: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.urlSlug,
|
|
42087
|
+
visitorId: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.visitorId,
|
|
42088
|
+
});
|
|
42089
|
+
this.twilioConfig = options === null || options === void 0 ? void 0 : options.twilioConfig;
|
|
42090
|
+
this.urlSlug = urlSlug;
|
|
42091
|
+
}
|
|
42092
|
+
/**
|
|
42093
|
+
* @summary
|
|
42094
|
+
* Get twilio
|
|
42095
|
+
*
|
|
42096
|
+
* @usage
|
|
42097
|
+
* ```ts
|
|
42098
|
+
* await webRTCConnector.getTwilioConfig();
|
|
42099
|
+
* ```
|
|
42100
|
+
*/
|
|
42101
|
+
getTwilioConfig() {
|
|
42102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42103
|
+
try {
|
|
42104
|
+
const response = yield this.topiaPublicApi().get(`/webrtc/twilio-config`, this.requestOptions);
|
|
42105
|
+
this.twilioConfig = response.data.twilioConfig;
|
|
42106
|
+
return response.data;
|
|
42107
|
+
}
|
|
42108
|
+
catch (error) {
|
|
42109
|
+
throw this.errorHandler({ error, sdkMethod: "WebRTCConnector.getTwilioConfig" });
|
|
42110
|
+
}
|
|
42111
|
+
});
|
|
42112
|
+
}
|
|
41960
42113
|
}
|
|
41961
42114
|
|
|
41962
42115
|
var _WorldActivity_visitorsMap;
|
|
@@ -42136,52 +42289,15 @@ class WorldActivity extends SDKController {
|
|
|
42136
42289
|
}
|
|
42137
42290
|
_WorldActivity_visitorsMap = new WeakMap();
|
|
42138
42291
|
|
|
42139
|
-
/**
|
|
42140
|
-
* @summary
|
|
42141
|
-
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
42142
|
-
*
|
|
42143
|
-
* @usage
|
|
42144
|
-
* ```ts
|
|
42145
|
-
* const topia = await new Topia({
|
|
42146
|
-
* apiDomain: "api.topia.io",
|
|
42147
|
-
* apiKey: "exampleKey",
|
|
42148
|
-
* interactiveKey: "key",
|
|
42149
|
-
* interactiveSecret: "secret",
|
|
42150
|
-
* });
|
|
42151
|
-
* ```
|
|
42152
|
-
*/
|
|
42153
|
-
class Topia {
|
|
42154
|
-
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, }) {
|
|
42155
|
-
getBrowserWarning();
|
|
42156
|
-
this.apiDomain = apiDomain || "api.topia.io";
|
|
42157
|
-
this.apiKey = apiKey;
|
|
42158
|
-
this.apiProtocol = apiProtocol || "https";
|
|
42159
|
-
this.interactiveSecret = interactiveSecret;
|
|
42160
|
-
const headers = {
|
|
42161
|
-
"ApplicationId": "sdk-js-topia",
|
|
42162
|
-
"Content-Type": "application/json",
|
|
42163
|
-
};
|
|
42164
|
-
if (apiKey)
|
|
42165
|
-
headers.Authorization = apiKey;
|
|
42166
|
-
if (interactiveKey)
|
|
42167
|
-
headers.PublicKey = interactiveKey;
|
|
42168
|
-
this.axios = axios.create({
|
|
42169
|
-
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
42170
|
-
headers,
|
|
42171
|
-
});
|
|
42172
|
-
}
|
|
42173
|
-
}
|
|
42174
|
-
|
|
42175
42292
|
/**
|
|
42176
42293
|
* @usage
|
|
42177
42294
|
* ```ts
|
|
42178
42295
|
* const Asset = new AssetFactory(myTopiaInstance);
|
|
42179
42296
|
* ```
|
|
42180
42297
|
*/
|
|
42181
|
-
class AssetFactory {
|
|
42298
|
+
class AssetFactory extends SDKController {
|
|
42182
42299
|
constructor(topia) {
|
|
42183
|
-
|
|
42184
|
-
this.create;
|
|
42300
|
+
super(topia);
|
|
42185
42301
|
}
|
|
42186
42302
|
/**
|
|
42187
42303
|
* @summary
|
|
@@ -42195,6 +42311,38 @@ class AssetFactory {
|
|
|
42195
42311
|
create(id, options) {
|
|
42196
42312
|
return new Asset(this.topia, id, options);
|
|
42197
42313
|
}
|
|
42314
|
+
/**
|
|
42315
|
+
* @summary
|
|
42316
|
+
* Upload a new Asset and return a new instance of Asset class.
|
|
42317
|
+
*
|
|
42318
|
+
* @usage
|
|
42319
|
+
* ```
|
|
42320
|
+
* const assetPayload = {
|
|
42321
|
+
* assetName: "exampleAssetName"
|
|
42322
|
+
* bottomLayerURL: "https://example.bottomLayerURL"
|
|
42323
|
+
* creatorTags: { "decorations": true },
|
|
42324
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
42325
|
+
* isPublic: true,
|
|
42326
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
42327
|
+
* }
|
|
42328
|
+
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
42329
|
+
* ```
|
|
42330
|
+
*/
|
|
42331
|
+
upload(assetPayload, apiKey) {
|
|
42332
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42333
|
+
try {
|
|
42334
|
+
if (!apiKey)
|
|
42335
|
+
throw "A valid API Key is required.";
|
|
42336
|
+
const headers = { Authorization: apiKey };
|
|
42337
|
+
const response = yield this.topiaPublicApi().post("/assets", assetPayload, { headers });
|
|
42338
|
+
const { assetId, asset } = response.data;
|
|
42339
|
+
return new Asset(this.topia, assetId, { attributes: asset });
|
|
42340
|
+
}
|
|
42341
|
+
catch (error) {
|
|
42342
|
+
throw this.errorHandler({ error, params: assetPayload, sdkMethod: "AssetFactory.upload" });
|
|
42343
|
+
}
|
|
42344
|
+
});
|
|
42345
|
+
}
|
|
42198
42346
|
}
|
|
42199
42347
|
|
|
42200
42348
|
/**
|
|
@@ -42429,6 +42577,30 @@ class VisitorFactory {
|
|
|
42429
42577
|
}
|
|
42430
42578
|
}
|
|
42431
42579
|
|
|
42580
|
+
/**
|
|
42581
|
+
* @usage
|
|
42582
|
+
* ```ts
|
|
42583
|
+
* const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
|
|
42584
|
+
* ```
|
|
42585
|
+
*/
|
|
42586
|
+
class WebRTCConnectorFactory {
|
|
42587
|
+
constructor(topia) {
|
|
42588
|
+
this.topia = topia;
|
|
42589
|
+
}
|
|
42590
|
+
/**
|
|
42591
|
+
* @summary
|
|
42592
|
+
* Instantiate a new instance of WebRTCConnector class.
|
|
42593
|
+
*
|
|
42594
|
+
* @usage
|
|
42595
|
+
* ```
|
|
42596
|
+
* const userInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, urlSlug, visitorId }, twilioConfig: {} });
|
|
42597
|
+
* ```
|
|
42598
|
+
*/
|
|
42599
|
+
create(urlSlug, options) {
|
|
42600
|
+
return new WebRTCConnector(this.topia, urlSlug, options);
|
|
42601
|
+
}
|
|
42602
|
+
}
|
|
42603
|
+
|
|
42432
42604
|
/**
|
|
42433
42605
|
* @usage
|
|
42434
42606
|
* ```ts
|
|
@@ -42533,4 +42705,4 @@ process.on("uncaughtException", function (err) {
|
|
|
42533
42705
|
process.exit(1);
|
|
42534
42706
|
});
|
|
42535
42707
|
|
|
42536
|
-
export { Asset, AssetFactory, DroppedAsset, DroppedAssetFactory, SDKController, Scene, SceneFactory, Topia, User, UserFactory, Visitor, VisitorFactory, World, WorldActivity, WorldActivityFactory, WorldFactory };
|
|
42708
|
+
export { Asset, AssetFactory, DroppedAsset, DroppedAssetFactory, SDKController, Scene, SceneFactory, Topia, User, UserFactory, Visitor, VisitorFactory, WebRTCConnector, WebRTCConnectorFactory, World, WorldActivity, WorldActivityFactory, WorldFactory };
|
package/package.json
CHANGED
|
@@ -56,8 +56,9 @@
|
|
|
56
56
|
"lint": "eslint \"src/**\"",
|
|
57
57
|
"docs": "typedoc",
|
|
58
58
|
"pkg": "yarn && yarn build && yarn docs && npm publish",
|
|
59
|
-
"
|
|
59
|
+
"yalc-publish": "yarn build && yalc publish",
|
|
60
|
+
"yalc-push": "yarn build && yalc publish --push --dev --no-scripts"
|
|
60
61
|
},
|
|
61
62
|
"type": "module",
|
|
62
|
-
"version": "0.
|
|
63
|
+
"version": "0.12.00"
|
|
63
64
|
}
|