@vendit-dev/thirdparty-adapters 0.3.16 → 0.3.18
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.
|
@@ -109,6 +109,14 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
109
109
|
var _this = this;
|
|
110
110
|
var authenticator = _a.authenticator, redis = _a.redis, apiHost = _a.apiHost;
|
|
111
111
|
this.PROVIDER_KEY = 'SamsungSmartAccess';
|
|
112
|
+
this.parseJSONSafe = function (str) {
|
|
113
|
+
try {
|
|
114
|
+
return JSON.parse(str);
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
112
120
|
this.checkSmartAccessIntegration = function (_a) {
|
|
113
121
|
var accommodationId = _a.accommodationId;
|
|
114
122
|
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
@@ -128,7 +136,7 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
128
136
|
if (existingAuth === 'NOT_FOUND') {
|
|
129
137
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
130
138
|
}
|
|
131
|
-
return [2 /*return*/,
|
|
139
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
132
140
|
}
|
|
133
141
|
lockId = "SMARTACCESS-HKEY|" + accommodationId;
|
|
134
142
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
@@ -141,7 +149,7 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
141
149
|
case 4:
|
|
142
150
|
_b.trys.push([4, 9, 10, 12]);
|
|
143
151
|
if (existingAuth) {
|
|
144
|
-
return [2 /*return*/,
|
|
152
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
145
153
|
}
|
|
146
154
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({ accommodationId: accommodationId, provider: this.PROVIDER_KEY })];
|
|
147
155
|
case 5:
|
|
@@ -110,6 +110,7 @@ export default class ThemrIoTAdapter {
|
|
|
110
110
|
static indexAccommodation: ({ accommodationId, }: {
|
|
111
111
|
accommodationId: string;
|
|
112
112
|
}) => string;
|
|
113
|
+
parseJSONSafe: (str: string) => any | boolean;
|
|
113
114
|
checkTheMRIoTIntegration: ({ accommodationId, }: {
|
|
114
115
|
accommodationId: string;
|
|
115
116
|
}) => Promise<boolean>;
|
package/lib/adapters/themrIoT.js
CHANGED
|
@@ -87,6 +87,14 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
|
+
this.parseJSONSafe = function (str) {
|
|
91
|
+
try {
|
|
92
|
+
return JSON.parse(str);
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
90
98
|
this.checkTheMRIoTIntegration = function (_a) {
|
|
91
99
|
var accommodationId = _a.accommodationId;
|
|
92
100
|
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
@@ -106,9 +114,8 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
106
114
|
if (existingAuth === 'NOT_FOUND') {
|
|
107
115
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
108
116
|
}
|
|
109
|
-
return [2 /*return*/,
|
|
117
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
110
118
|
}
|
|
111
|
-
console.log('SECOND', existingAuth);
|
|
112
119
|
lockId = "THEMR-HKEY|" + accommodationId;
|
|
113
120
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
114
121
|
case 2:
|
|
@@ -120,7 +127,7 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
120
127
|
case 4:
|
|
121
128
|
_b.trys.push([4, 9, 10, 12]);
|
|
122
129
|
if (existingAuth) {
|
|
123
|
-
return [2 /*return*/,
|
|
130
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
124
131
|
}
|
|
125
132
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
126
133
|
accommodationId: accommodationId,
|