@vendit-dev/thirdparty-adapters 0.4.0-beta.13 → 0.4.0-beta.14
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/lib/adapters/amanoKorea.js +23 -38
- package/package.json +1 -1
|
@@ -84,18 +84,18 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
84
84
|
this.getAccommodationAuthInfo = function (_a) {
|
|
85
85
|
var accommodationId = _a.accommodationId;
|
|
86
86
|
return __awaiter(_this, void 0, void 0, function () {
|
|
87
|
-
var existingAuth, parsedCredential, _b, authorization, apiHost, lockId, lockHash,
|
|
88
|
-
return __generator(this, function (
|
|
89
|
-
switch (
|
|
87
|
+
var existingAuth, parsedCredential, _b, authorization, apiHost, lockId, lockHash, newAuth, parsedCredential, err_1;
|
|
88
|
+
return __generator(this, function (_c) {
|
|
89
|
+
switch (_c.label) {
|
|
90
90
|
case 0: return [4 /*yield*/, this.redis.get(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }))];
|
|
91
91
|
case 1:
|
|
92
|
-
existingAuth =
|
|
92
|
+
existingAuth = _c.sent();
|
|
93
93
|
console.log('🚀 ~ file: amanoKorea.ts:113 ~ AmanoKoreaAdapter ~ existingAuth:', existingAuth);
|
|
94
94
|
if (existingAuth) {
|
|
95
95
|
parsedCredential = this.parseJSONSafe(existingAuth);
|
|
96
96
|
console.log('🚀 ~ file: amanoKorea.ts:111 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential);
|
|
97
|
-
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.
|
|
98
|
-
_b = this.parseJSONSafe(parsedCredential), authorization = _b.authorization, apiHost = _b.apiHost;
|
|
97
|
+
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.credential) {
|
|
98
|
+
_b = this.parseJSONSafe(parsedCredential.credential), authorization = _b.authorization, apiHost = _b.apiHost;
|
|
99
99
|
this.setAuthorization({
|
|
100
100
|
authorization: authorization,
|
|
101
101
|
});
|
|
@@ -106,37 +106,22 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
106
106
|
lockId = "AMANO-HKEY|" + accommodationId;
|
|
107
107
|
return [4 /*yield*/, this.mutexLock.getMutexLock(lockId)];
|
|
108
108
|
case 2:
|
|
109
|
-
lockHash =
|
|
110
|
-
|
|
109
|
+
lockHash = _c.sent();
|
|
110
|
+
_c.label = 3;
|
|
111
111
|
case 3:
|
|
112
|
-
|
|
113
|
-
_d.label = 4;
|
|
114
|
-
case 4:
|
|
115
|
-
_d.trys.push([4, 9, 10, 12]);
|
|
116
|
-
if (existingAuth) {
|
|
117
|
-
parsedCredential_1 = this.parseJSONSafe(existingAuth);
|
|
118
|
-
console.log('🚀 ~ file: amanoKorea.ts:124 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential_1);
|
|
119
|
-
if (parsedCredential_1) {
|
|
120
|
-
_c = this.parseJSONSafe(parsedCredential_1), authorization = _c.authorization, apiHost = _c.apiHost;
|
|
121
|
-
this.setAuthorization({
|
|
122
|
-
authorization: authorization,
|
|
123
|
-
});
|
|
124
|
-
this.API_HOST = apiHost;
|
|
125
|
-
}
|
|
126
|
-
return [2 /*return*/, this.parseJSONSafe(existingAuth)];
|
|
127
|
-
}
|
|
112
|
+
_c.trys.push([3, 8, 9, 11]);
|
|
128
113
|
return [4 /*yield*/, this.authenticator.getThirdPartyCredential({
|
|
129
114
|
accommodationId: accommodationId,
|
|
130
115
|
provider: this.PROVIDER_KEY,
|
|
131
116
|
})];
|
|
132
|
-
case
|
|
133
|
-
newAuth =
|
|
134
|
-
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/,
|
|
117
|
+
case 4:
|
|
118
|
+
newAuth = _c.sent();
|
|
119
|
+
if (!(!newAuth || !(newAuth === null || newAuth === void 0 ? void 0 : newAuth.credential))) return [3 /*break*/, 6];
|
|
135
120
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), 'NOT_FOUND', 'EX', 60 * 5)];
|
|
136
|
-
case
|
|
137
|
-
|
|
121
|
+
case 5:
|
|
122
|
+
_c.sent();
|
|
138
123
|
return [2 /*return*/, false];
|
|
139
|
-
case
|
|
124
|
+
case 6:
|
|
140
125
|
parsedCredential = this.parseJSONSafe(newAuth.credential);
|
|
141
126
|
console.log('🚀 ~ file: amanoKorea.ts:151 ~ AmanoKoreaAdapter ~ parsedCredential:', parsedCredential);
|
|
142
127
|
if (parsedCredential === null || parsedCredential === void 0 ? void 0 : parsedCredential.authorization) {
|
|
@@ -149,18 +134,18 @@ var AmanoKoreaAdapter = /** @class */ (function () {
|
|
|
149
134
|
throw new Error('Authorization is not found');
|
|
150
135
|
}
|
|
151
136
|
return [4 /*yield*/, this.redis.set(AmanoKoreaAdapter.indexAccommodation({ accommodationId: accommodationId }), JSON.stringify(newAuth), 'EX', 60 * 5)];
|
|
152
|
-
case
|
|
153
|
-
|
|
137
|
+
case 7:
|
|
138
|
+
_c.sent();
|
|
154
139
|
return [2 /*return*/, parsedCredential];
|
|
155
|
-
case
|
|
156
|
-
err_1 =
|
|
140
|
+
case 8:
|
|
141
|
+
err_1 = _c.sent();
|
|
157
142
|
console.log(err_1);
|
|
158
143
|
throw err_1;
|
|
159
|
-
case
|
|
160
|
-
case
|
|
161
|
-
|
|
144
|
+
case 9: return [4 /*yield*/, this.mutexLock.unlockMutexLock(lockId, lockHash)];
|
|
145
|
+
case 10:
|
|
146
|
+
_c.sent();
|
|
162
147
|
return [7 /*endfinally*/];
|
|
163
|
-
case
|
|
148
|
+
case 11: return [2 /*return*/];
|
|
164
149
|
}
|
|
165
150
|
});
|
|
166
151
|
});
|