@vendit-dev/thirdparty-adapters 0.3.17 → 0.3.19
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,15 @@ 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
|
+
console.log('parseJSONSafe', e);
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
112
121
|
this.checkSmartAccessIntegration = function (_a) {
|
|
113
122
|
var accommodationId = _a.accommodationId;
|
|
114
123
|
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
@@ -128,7 +137,7 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
128
137
|
if (existingAuth === 'NOT_FOUND') {
|
|
129
138
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
130
139
|
}
|
|
131
|
-
return [2 /*return*/,
|
|
140
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
132
141
|
}
|
|
133
142
|
lockId = "SMARTACCESS-HKEY|" + accommodationId;
|
|
134
143
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
@@ -141,7 +150,7 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
141
150
|
case 4:
|
|
142
151
|
_b.trys.push([4, 9, 10, 12]);
|
|
143
152
|
if (existingAuth) {
|
|
144
|
-
return [2 /*return*/,
|
|
153
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
145
154
|
}
|
|
146
155
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({ accommodationId: accommodationId, provider: this.PROVIDER_KEY })];
|
|
147
156
|
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,15 @@ 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
|
+
console.log('parseJSONSafe', e);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
90
99
|
this.checkTheMRIoTIntegration = function (_a) {
|
|
91
100
|
var accommodationId = _a.accommodationId;
|
|
92
101
|
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
|
|
@@ -106,9 +115,8 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
106
115
|
if (existingAuth === 'NOT_FOUND') {
|
|
107
116
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
108
117
|
}
|
|
109
|
-
return [2 /*return*/,
|
|
118
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
110
119
|
}
|
|
111
|
-
console.log('SECOND', existingAuth);
|
|
112
120
|
lockId = "THEMR-HKEY|" + accommodationId;
|
|
113
121
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
114
122
|
case 2:
|
|
@@ -120,7 +128,7 @@ var ThemrIoTAdapter = /** @class */ (function () {
|
|
|
120
128
|
case 4:
|
|
121
129
|
_b.trys.push([4, 9, 10, 12]);
|
|
122
130
|
if (existingAuth) {
|
|
123
|
-
return [2 /*return*/,
|
|
131
|
+
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
124
132
|
}
|
|
125
133
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
126
134
|
accommodationId: accommodationId,
|