@vendit-dev/thirdparty-adapters 0.3.22 → 0.3.24
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.
|
@@ -51,7 +51,7 @@ export default class SmartAccessAdapter {
|
|
|
51
51
|
}) => Promise<boolean>;
|
|
52
52
|
getAccommodationAuthInfo: ({ accommodationId }: {
|
|
53
53
|
accommodationId: string;
|
|
54
|
-
}) => Promise<OAuthTokenResponse>;
|
|
54
|
+
}) => Promise<OAuthTokenResponse | boolean>;
|
|
55
55
|
getAccommodationAccessToken: (accommodationId: string) => Promise<string>;
|
|
56
56
|
callSmartAccessApi: ({ route, accommodationId, params, method, headers, }: {
|
|
57
57
|
route: string;
|
|
@@ -133,6 +133,7 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
133
133
|
case 0: return [4 /*yield*/, this.redis.get(SmartAccessAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
134
134
|
case 1:
|
|
135
135
|
existingAuth = _b.sent();
|
|
136
|
+
console.log('AUTH 0', existingAuth);
|
|
136
137
|
if (existingAuth) {
|
|
137
138
|
if (existingAuth === 'NOT_FOUND') {
|
|
138
139
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
@@ -147,24 +148,31 @@ var SmartAccessAdapter = /** @class */ (function () {
|
|
|
147
148
|
return [4 /*yield*/, this.redis.get(SmartAccessAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
148
149
|
case 3:
|
|
149
150
|
existingAuth = _b.sent();
|
|
151
|
+
console.log('AUTH 2', existingAuth);
|
|
150
152
|
_b.label = 4;
|
|
151
153
|
case 4:
|
|
152
154
|
_b.trys.push([4, 9, 10, 12]);
|
|
153
155
|
if (existingAuth) {
|
|
154
|
-
console.log('AUTH
|
|
156
|
+
console.log('AUTH 3', existingAuth);
|
|
155
157
|
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
156
158
|
}
|
|
157
159
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({ accommodationId: accommodationId, provider: this.PROVIDER_KEY })];
|
|
158
160
|
case 5:
|
|
159
161
|
newAuth = _b.sent();
|
|
160
|
-
|
|
162
|
+
console.log('AUTH 4', newAuth);
|
|
163
|
+
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/, 7];
|
|
161
164
|
return [4 /*yield*/, this.redis.set(SmartAccessAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 5)];
|
|
162
165
|
case 6:
|
|
163
166
|
_b.sent();
|
|
164
167
|
throw new Error('THIRDPARTY_AUTH_NOT_FOUND');
|
|
165
168
|
case 7:
|
|
166
|
-
console.log('AUTH
|
|
169
|
+
console.log('AUTH 5', existingAuth);
|
|
170
|
+
if (!existingAuth && !newAuth.credential && !newAuth.scope) {
|
|
171
|
+
console.log('AUTH 6', existingAuth);
|
|
172
|
+
return [2 /*return*/, false];
|
|
173
|
+
}
|
|
167
174
|
parsedCredential = this.parseJSONSafe(newAuth.credential);
|
|
175
|
+
console.log('AUTH 7', parsedCredential);
|
|
168
176
|
return [4 /*yield*/, this.redis.set(SmartAccessAdapter.indexAccommodation({ accommodationId: accommodationId }), newAuth.credential, 'EX', 60 * 5)];
|
|
169
177
|
case 8:
|
|
170
178
|
_b.sent();
|