@rtsdk/topia 0.2.0 → 0.2.2
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
CHANGED
|
@@ -39751,24 +39751,31 @@ const {
|
|
|
39751
39751
|
*/
|
|
39752
39752
|
class SDKController {
|
|
39753
39753
|
constructor(topia, credentials = {}) {
|
|
39754
|
-
const { assetId = null, interactiveNonce = null, visitorId = null, apiKey = null } = credentials;
|
|
39754
|
+
const { assetId = null, interactiveNonce = null, visitorId = null, apiKey = null, profileId = null } = credentials;
|
|
39755
39755
|
this.topia = topia;
|
|
39756
39756
|
this.credentials = credentials;
|
|
39757
39757
|
this.requestOptions = {};
|
|
39758
39758
|
let payload = {};
|
|
39759
39759
|
const headers = {};
|
|
39760
|
-
|
|
39761
|
-
|
|
39762
|
-
|
|
39763
|
-
|
|
39764
|
-
|
|
39765
|
-
|
|
39766
|
-
|
|
39767
|
-
|
|
39768
|
-
|
|
39769
|
-
|
|
39760
|
+
try {
|
|
39761
|
+
if (topia.interactiveSecret && (profileId || assetId)) {
|
|
39762
|
+
payload = {
|
|
39763
|
+
interactiveNonce,
|
|
39764
|
+
visitorId,
|
|
39765
|
+
assetId,
|
|
39766
|
+
date: new Date(),
|
|
39767
|
+
};
|
|
39768
|
+
this.jwt = jwt.sign(payload, topia.interactiveSecret);
|
|
39769
|
+
headers.InteractiveJWT = this.jwt;
|
|
39770
|
+
}
|
|
39771
|
+
if (apiKey) {
|
|
39772
|
+
headers.Authorization = apiKey;
|
|
39773
|
+
}
|
|
39774
|
+
this.requestOptions = { headers };
|
|
39775
|
+
}
|
|
39776
|
+
catch (error) {
|
|
39777
|
+
this.errorHandler({ error });
|
|
39770
39778
|
}
|
|
39771
|
-
this.requestOptions = { headers };
|
|
39772
39779
|
}
|
|
39773
39780
|
topiaPublicApi() {
|
|
39774
39781
|
return this.topia.axios;
|
|
@@ -40581,7 +40588,7 @@ var _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
40581
40588
|
*/
|
|
40582
40589
|
class User extends SDKController {
|
|
40583
40590
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
40584
|
-
super(topia, options.credentials);
|
|
40591
|
+
super(topia, Object.assign({ profileId: options.profileId }, options.credentials));
|
|
40585
40592
|
_User_assetsMap.set(this, void 0);
|
|
40586
40593
|
_User_scenesMap.set(this, void 0);
|
|
40587
40594
|
_User_worldsMap.set(this, void 0);
|
|
@@ -40794,7 +40801,7 @@ class Visitor extends User {
|
|
|
40794
40801
|
* Returns details for a visitor in a world by id and urlSlug
|
|
40795
40802
|
*/
|
|
40796
40803
|
fetchVisitor() {
|
|
40797
|
-
var _a;
|
|
40804
|
+
var _a, _b;
|
|
40798
40805
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40799
40806
|
try {
|
|
40800
40807
|
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
|
|
@@ -40807,6 +40814,8 @@ class Visitor extends User {
|
|
|
40807
40814
|
else {
|
|
40808
40815
|
throw "This visitor is not active";
|
|
40809
40816
|
}
|
|
40817
|
+
if ((_b = this.profile) === null || _b === void 0 ? void 0 : _b.profileId)
|
|
40818
|
+
this.profileId = this.profile.profileId;
|
|
40810
40819
|
}
|
|
40811
40820
|
catch (error) {
|
|
40812
40821
|
throw this.errorHandler({ error });
|
|
@@ -40858,7 +40867,7 @@ class Visitor extends User {
|
|
|
40858
40867
|
fetchVisitorDataObject() {
|
|
40859
40868
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40860
40869
|
try {
|
|
40861
|
-
const response = yield this.topiaPublicApi().get(`/
|
|
40870
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-data-object`, this.requestOptions);
|
|
40862
40871
|
this.dataObject = response.data;
|
|
40863
40872
|
}
|
|
40864
40873
|
catch (error) {
|
|
@@ -40884,7 +40893,7 @@ class Visitor extends User {
|
|
|
40884
40893
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40885
40894
|
try {
|
|
40886
40895
|
const { lock = {} } = options;
|
|
40887
|
-
yield this.topiaPublicApi().put(`/
|
|
40896
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/set-data-object`, { dataObject, lock }, this.requestOptions);
|
|
40888
40897
|
this.dataObject = dataObject;
|
|
40889
40898
|
}
|
|
40890
40899
|
catch (error) {
|
|
@@ -40910,7 +40919,7 @@ class Visitor extends User {
|
|
|
40910
40919
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40911
40920
|
try {
|
|
40912
40921
|
const { lock = {} } = options;
|
|
40913
|
-
yield this.topiaPublicApi().put(`/
|
|
40922
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-data-object`, { dataObject, lock }, this.requestOptions);
|
|
40914
40923
|
this.dataObject = dataObject;
|
|
40915
40924
|
}
|
|
40916
40925
|
catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -39749,24 +39749,31 @@ const {
|
|
|
39749
39749
|
*/
|
|
39750
39750
|
class SDKController {
|
|
39751
39751
|
constructor(topia, credentials = {}) {
|
|
39752
|
-
const { assetId = null, interactiveNonce = null, visitorId = null, apiKey = null } = credentials;
|
|
39752
|
+
const { assetId = null, interactiveNonce = null, visitorId = null, apiKey = null, profileId = null } = credentials;
|
|
39753
39753
|
this.topia = topia;
|
|
39754
39754
|
this.credentials = credentials;
|
|
39755
39755
|
this.requestOptions = {};
|
|
39756
39756
|
let payload = {};
|
|
39757
39757
|
const headers = {};
|
|
39758
|
-
|
|
39759
|
-
|
|
39760
|
-
|
|
39761
|
-
|
|
39762
|
-
|
|
39763
|
-
|
|
39764
|
-
|
|
39765
|
-
|
|
39766
|
-
|
|
39767
|
-
|
|
39758
|
+
try {
|
|
39759
|
+
if (topia.interactiveSecret && (profileId || assetId)) {
|
|
39760
|
+
payload = {
|
|
39761
|
+
interactiveNonce,
|
|
39762
|
+
visitorId,
|
|
39763
|
+
assetId,
|
|
39764
|
+
date: new Date(),
|
|
39765
|
+
};
|
|
39766
|
+
this.jwt = jwt.sign(payload, topia.interactiveSecret);
|
|
39767
|
+
headers.InteractiveJWT = this.jwt;
|
|
39768
|
+
}
|
|
39769
|
+
if (apiKey) {
|
|
39770
|
+
headers.Authorization = apiKey;
|
|
39771
|
+
}
|
|
39772
|
+
this.requestOptions = { headers };
|
|
39773
|
+
}
|
|
39774
|
+
catch (error) {
|
|
39775
|
+
this.errorHandler({ error });
|
|
39768
39776
|
}
|
|
39769
|
-
this.requestOptions = { headers };
|
|
39770
39777
|
}
|
|
39771
39778
|
topiaPublicApi() {
|
|
39772
39779
|
return this.topia.axios;
|
|
@@ -40579,7 +40586,7 @@ var _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
40579
40586
|
*/
|
|
40580
40587
|
class User extends SDKController {
|
|
40581
40588
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
40582
|
-
super(topia, options.credentials);
|
|
40589
|
+
super(topia, Object.assign({ profileId: options.profileId }, options.credentials));
|
|
40583
40590
|
_User_assetsMap.set(this, void 0);
|
|
40584
40591
|
_User_scenesMap.set(this, void 0);
|
|
40585
40592
|
_User_worldsMap.set(this, void 0);
|
|
@@ -40792,7 +40799,7 @@ class Visitor extends User {
|
|
|
40792
40799
|
* Returns details for a visitor in a world by id and urlSlug
|
|
40793
40800
|
*/
|
|
40794
40801
|
fetchVisitor() {
|
|
40795
|
-
var _a;
|
|
40802
|
+
var _a, _b;
|
|
40796
40803
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40797
40804
|
try {
|
|
40798
40805
|
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
|
|
@@ -40805,6 +40812,8 @@ class Visitor extends User {
|
|
|
40805
40812
|
else {
|
|
40806
40813
|
throw "This visitor is not active";
|
|
40807
40814
|
}
|
|
40815
|
+
if ((_b = this.profile) === null || _b === void 0 ? void 0 : _b.profileId)
|
|
40816
|
+
this.profileId = this.profile.profileId;
|
|
40808
40817
|
}
|
|
40809
40818
|
catch (error) {
|
|
40810
40819
|
throw this.errorHandler({ error });
|
|
@@ -40856,7 +40865,7 @@ class Visitor extends User {
|
|
|
40856
40865
|
fetchVisitorDataObject() {
|
|
40857
40866
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40858
40867
|
try {
|
|
40859
|
-
const response = yield this.topiaPublicApi().get(`/
|
|
40868
|
+
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}/get-data-object`, this.requestOptions);
|
|
40860
40869
|
this.dataObject = response.data;
|
|
40861
40870
|
}
|
|
40862
40871
|
catch (error) {
|
|
@@ -40882,7 +40891,7 @@ class Visitor extends User {
|
|
|
40882
40891
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40883
40892
|
try {
|
|
40884
40893
|
const { lock = {} } = options;
|
|
40885
|
-
yield this.topiaPublicApi().put(`/
|
|
40894
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/set-data-object`, { dataObject, lock }, this.requestOptions);
|
|
40886
40895
|
this.dataObject = dataObject;
|
|
40887
40896
|
}
|
|
40888
40897
|
catch (error) {
|
|
@@ -40908,7 +40917,7 @@ class Visitor extends User {
|
|
|
40908
40917
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40909
40918
|
try {
|
|
40910
40919
|
const { lock = {} } = options;
|
|
40911
|
-
yield this.topiaPublicApi().put(`/
|
|
40920
|
+
yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/update-data-object`, { dataObject, lock }, this.requestOptions);
|
|
40912
40921
|
this.dataObject = dataObject;
|
|
40913
40922
|
}
|
|
40914
40923
|
catch (error) {
|
|
@@ -15,6 +15,7 @@ export declare class Visitor extends User implements VisitorInterface {
|
|
|
15
15
|
readonly id: number;
|
|
16
16
|
urlSlug: string;
|
|
17
17
|
user?: User;
|
|
18
|
+
profile?: any;
|
|
18
19
|
constructor(topia: Topia, id: number, urlSlug: string, options?: VisitorOptionalInterface);
|
|
19
20
|
/**
|
|
20
21
|
* @summary
|
package/package.json
CHANGED