@kushki/js 1.36.0 → 1.37.0
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/Kushki.d.ts +17 -2
- package/lib/Kushki.js +132 -113
- package/lib/KushkiInfo.js +11 -14
- package/lib/constant/CreditCardEspecifications.js +2 -2
- package/lib/constant/Identifiers.js +21 -21
- package/lib/gateway/KushkiGateway.js +161 -276
- package/lib/gateway/SiftScience.js +42 -45
- package/lib/generic/AurusError.js +12 -28
- package/lib/generic/KushkiError.js +15 -33
- package/lib/infrastructure/BinCardTypeEnum.js +1 -1
- package/lib/infrastructure/CardBrandsEnum.d.ts +5 -0
- package/lib/infrastructure/CardBrandsEnum.js +8 -0
- package/lib/infrastructure/CognitoErrorEnum.js +1 -1
- package/lib/infrastructure/Container.js +41 -75
- package/lib/infrastructure/EnvironmentEnum.js +1 -1
- package/lib/infrastructure/ErrorEnum.d.ts +2 -1
- package/lib/infrastructure/ErrorEnum.js +42 -37
- package/lib/infrastructure/HeadersEnum.js +1 -1
- package/lib/infrastructure/KPayUserPoolEnum.js +1 -1
- package/lib/infrastructure/KpayPaymentKind.js +1 -1
- package/lib/infrastructure/PathEnum.js +1 -1
- package/lib/infrastructure/PlatformCodeEnum.js +15 -15
- package/lib/infrastructure/SiftScienceEnum.js +1 -1
- package/lib/infrastructure/StatusCodeEnum.js +1 -1
- package/lib/infrastructure/ThreeDSEnum.js +1 -1
- package/lib/infrastructure/VisaBrandingResourceUrlEnum.d.ts +2 -2
- package/lib/infrastructure/VisaBrandingResourceUrlEnum.js +3 -3
- package/lib/lib.js +1 -1
- package/lib/libs/MCSensoryBranding/mastercard-sensory-branding.d.ts +21 -0
- package/lib/libs/MCSensoryBranding/mastercard-sensory-branding.js +781 -0
- package/lib/libs/VisaSensoryBranding/visa-sensory-branding.d.ts +1 -1
- package/lib/libs/VisaSensoryBranding/visa-sensory-branding.js +630 -158
- package/lib/libs/cardinal/prod.js +10 -10
- package/lib/libs/cardinal/staging.js +9 -9
- package/lib/repository/IAntiFraud.js +1 -1
- package/lib/repository/IAuthService.js +1 -1
- package/lib/repository/ICardAsyncService.js +1 -1
- package/lib/repository/ICardDynamicService.js +1 -1
- package/lib/repository/ICardService.js +1 -1
- package/lib/repository/ICardSubscriptionDynamicService.js +1 -1
- package/lib/repository/ICashService.js +1 -1
- package/lib/repository/ICommissionService.js +1 -1
- package/lib/repository/IKPayService.js +1 -1
- package/lib/repository/IKushkiGateway.js +1 -1
- package/lib/repository/IKushkiService.d.ts +9 -2
- package/lib/repository/IKushkiService.js +1 -1
- package/lib/repository/IMobileProcessorService.js +1 -1
- package/lib/repository/IMultiMerchantService.js +1 -1
- package/lib/repository/IPayoutsCashService.js +1 -1
- package/lib/repository/IPayoutsTransferService.js +1 -1
- package/lib/repository/ISecureService.js +1 -1
- package/lib/repository/ISiftScienceService.js +1 -1
- package/lib/repository/ITransferService.js +1 -1
- package/lib/repository/ITransferSubscriptionService.js +1 -1
- package/lib/service/AuthService.js +99 -161
- package/lib/service/CardAsyncService.js +19 -26
- package/lib/service/CardDynamicService.js +32 -43
- package/lib/service/CardService.js +271 -382
- package/lib/service/CardSubscriptionDynamicService.js +31 -40
- package/lib/service/CashService.js +15 -16
- package/lib/service/CommissionService.js +13 -14
- package/lib/service/KPayService.js +19 -23
- package/lib/service/KushkiService.d.ts +2 -1
- package/lib/service/KushkiService.js +48 -33
- package/lib/service/MobileProcessorService.js +59 -70
- package/lib/service/MultiMerchantService.js +13 -14
- package/lib/service/PayoutsCashService.js +15 -16
- package/lib/service/PayoutsTransferService.js +17 -18
- package/lib/service/SecureService.js +13 -14
- package/lib/service/SiftScienceService.js +16 -20
- package/lib/service/TransferService.js +21 -36
- package/lib/service/TransferSubscriptionsService.js +16 -17
- package/lib/service/UtilsService.js +51 -57
- package/lib/types/card_branding_request.d.ts +40 -0
- package/lib/types/visa_branding_request.d.ts +25 -3
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// istanbul ignore file
|
|
4
4
|
// tslint:disable
|
|
5
5
|
// @ts-nocheck
|
|
6
|
-
exports
|
|
6
|
+
exports.default = !(function (e) {
|
|
7
7
|
function n(i) {
|
|
8
8
|
if (t[i])
|
|
9
9
|
return t[i].exports;
|
|
@@ -58,7 +58,7 @@ exports["default"] = !(function (e) {
|
|
|
58
58
|
bin: void 0,
|
|
59
59
|
deviceFingerprinting: {
|
|
60
60
|
shouldRunFingerprinting: !1,
|
|
61
|
-
urls: { base: void 0, browser: void 0, profileBin: void 0 }
|
|
61
|
+
urls: { base: void 0, browser: void 0, profileBin: void 0 },
|
|
62
62
|
},
|
|
63
63
|
farnsworthLabs: {},
|
|
64
64
|
formFields: {},
|
|
@@ -73,7 +73,7 @@ exports["default"] = !(function (e) {
|
|
|
73
73
|
transactionFlow: void 0,
|
|
74
74
|
timers: { browserRender: null },
|
|
75
75
|
urls: { hostedFields: void 0, postMessageWhiteList: [] },
|
|
76
|
-
window: i
|
|
76
|
+
window: i,
|
|
77
77
|
};
|
|
78
78
|
},
|
|
79
79
|
46: function (e, n) {
|
|
@@ -153,7 +153,7 @@ exports["default"] = !(function (e) {
|
|
|
153
153
|
if (u.hasOwnProperty(e) && !u[e])
|
|
154
154
|
return !1;
|
|
155
155
|
t(s);
|
|
156
|
-
}
|
|
156
|
+
},
|
|
157
157
|
};
|
|
158
158
|
e.exports = a;
|
|
159
159
|
},
|
|
@@ -170,7 +170,7 @@ exports["default"] = !(function (e) {
|
|
|
170
170
|
start: function (e) {
|
|
171
171
|
p.push({ name: e, arguments: arguments });
|
|
172
172
|
},
|
|
173
|
-
|
|
173
|
+
continue: function (e) {
|
|
174
174
|
r.push({ name: e, arguments: arguments });
|
|
175
175
|
},
|
|
176
176
|
on: function (e) {
|
|
@@ -184,7 +184,7 @@ exports["default"] = !(function (e) {
|
|
|
184
184
|
},
|
|
185
185
|
complete: function (e) {
|
|
186
186
|
s.push({ name: e, arguments: arguments });
|
|
187
|
-
}
|
|
187
|
+
},
|
|
188
188
|
}),
|
|
189
189
|
(e.Cardinal = t),
|
|
190
190
|
(e.onerror !== n && null !== e.onerror) ||
|
|
@@ -197,7 +197,7 @@ exports["default"] = !(function (e) {
|
|
|
197
197
|
configurationQueue: o,
|
|
198
198
|
onQueue: a,
|
|
199
199
|
startQueue: p,
|
|
200
|
-
continueQueue: r
|
|
200
|
+
continueQueue: r,
|
|
201
201
|
};
|
|
202
202
|
E.addToLoggerCollection(s);
|
|
203
203
|
try {
|
|
@@ -214,7 +214,7 @@ exports["default"] = !(function (e) {
|
|
|
214
214
|
(arguments[0] = "start." + e.toUpperCase()),
|
|
215
215
|
f.publish.apply(this, arguments);
|
|
216
216
|
}),
|
|
217
|
-
(t
|
|
217
|
+
(t.continue = function (e) {
|
|
218
218
|
(arguments[0] = "continue." + e.toUpperCase()),
|
|
219
219
|
f.publish.apply(this, arguments);
|
|
220
220
|
}),
|
|
@@ -242,5 +242,5 @@ exports["default"] = !(function (e) {
|
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
})(window);
|
|
245
|
-
}
|
|
245
|
+
},
|
|
246
246
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// istanbul ignore file
|
|
4
4
|
// tslint:disable
|
|
5
5
|
// @ts-nocheck
|
|
6
|
-
exports
|
|
6
|
+
exports.default = !(function (e) {
|
|
7
7
|
function n(i) {
|
|
8
8
|
if (t[i])
|
|
9
9
|
return t[i].exports;
|
|
@@ -58,7 +58,7 @@ exports["default"] = !(function (e) {
|
|
|
58
58
|
start: function (e) {
|
|
59
59
|
p.push({ name: e, arguments: arguments });
|
|
60
60
|
},
|
|
61
|
-
|
|
61
|
+
continue: function (e) {
|
|
62
62
|
r.push({ name: e, arguments: arguments });
|
|
63
63
|
},
|
|
64
64
|
on: function (e) {
|
|
@@ -72,7 +72,7 @@ exports["default"] = !(function (e) {
|
|
|
72
72
|
},
|
|
73
73
|
complete: function (e) {
|
|
74
74
|
s.push({ name: e, arguments: arguments });
|
|
75
|
-
}
|
|
75
|
+
},
|
|
76
76
|
}),
|
|
77
77
|
(e.Cardinal = t),
|
|
78
78
|
(e.onerror !== n && null !== e.onerror) ||
|
|
@@ -85,7 +85,7 @@ exports["default"] = !(function (e) {
|
|
|
85
85
|
configurationQueue: o,
|
|
86
86
|
onQueue: u,
|
|
87
87
|
startQueue: p,
|
|
88
|
-
continueQueue: r
|
|
88
|
+
continueQueue: r,
|
|
89
89
|
};
|
|
90
90
|
E.addToLoggerCollection(s);
|
|
91
91
|
try {
|
|
@@ -102,7 +102,7 @@ exports["default"] = !(function (e) {
|
|
|
102
102
|
(arguments[0] = "start." + e.toUpperCase()),
|
|
103
103
|
f.publish.apply(this, arguments);
|
|
104
104
|
}),
|
|
105
|
-
(t
|
|
105
|
+
(t.continue = function (e) {
|
|
106
106
|
(arguments[0] = "continue." + e.toUpperCase()),
|
|
107
107
|
f.publish.apply(this, arguments);
|
|
108
108
|
}),
|
|
@@ -177,7 +177,7 @@ exports["default"] = !(function (e) {
|
|
|
177
177
|
if (a.hasOwnProperty(e) && !a[e])
|
|
178
178
|
return !1;
|
|
179
179
|
t(s);
|
|
180
|
-
}
|
|
180
|
+
},
|
|
181
181
|
};
|
|
182
182
|
e.exports = u;
|
|
183
183
|
},
|
|
@@ -194,7 +194,7 @@ exports["default"] = !(function (e) {
|
|
|
194
194
|
bin: void 0,
|
|
195
195
|
deviceFingerprinting: {
|
|
196
196
|
shouldRunFingerprinting: !1,
|
|
197
|
-
urls: { base: void 0, browser: void 0, profileBin: void 0 }
|
|
197
|
+
urls: { base: void 0, browser: void 0, profileBin: void 0 },
|
|
198
198
|
},
|
|
199
199
|
farnsworthLabs: {},
|
|
200
200
|
formFields: {},
|
|
@@ -209,7 +209,7 @@ exports["default"] = !(function (e) {
|
|
|
209
209
|
transactionFlow: void 0,
|
|
210
210
|
timers: { browserRender: null },
|
|
211
211
|
urls: { hostedFields: void 0, postMessageWhiteList: [] },
|
|
212
|
-
window: i
|
|
212
|
+
window: i,
|
|
213
213
|
};
|
|
214
214
|
},
|
|
215
215
|
function (e, n) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* ICardService file.
|
|
4
4
|
*/
|
|
5
5
|
import { Observable } from "rxjs";
|
|
6
|
+
import { MasterCardBrandingRequest, VisaBrandingRequest } from "./../../lib/types/card_branding_request";
|
|
6
7
|
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
7
8
|
import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
|
|
8
9
|
import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
|
|
9
|
-
import { VisaBrandingRequest } from "./../../lib/types/visa_branding_request";
|
|
10
10
|
export interface IKushkiService {
|
|
11
11
|
/**
|
|
12
12
|
* Get Status services
|
|
@@ -32,8 +32,15 @@ export interface IKushkiService {
|
|
|
32
32
|
requestBrandsLogosByMerchant(mid: string, isTest: boolean, regional: boolean): Observable<GetBrandsLogosByMerchantResponse[]>;
|
|
33
33
|
/**
|
|
34
34
|
* runVisaBrandingAnimation
|
|
35
|
+
* @param isTest
|
|
35
36
|
* @param callback - function to execute when animation ends
|
|
36
|
-
* @param body - Define properties of animation
|
|
37
|
+
* @param body - Define properties of animation for Visa
|
|
37
38
|
*/
|
|
38
39
|
initVisaBrandingAnimation(isTest: boolean, callback: (error?: ErrorResponse) => void, body?: VisaBrandingRequest): void;
|
|
40
|
+
/**
|
|
41
|
+
* runMasterCardBrandingAnimation
|
|
42
|
+
* @param callback - function to execute when animation ends
|
|
43
|
+
* @param body - Define properties of animation for MasterCard
|
|
44
|
+
*/
|
|
45
|
+
initMasterCardBrandingAnimation(callback: (error?: ErrorResponse) => void, body?: MasterCardBrandingRequest): void;
|
|
39
46
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -20,187 +20,127 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
-
function step(op) {
|
|
28
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
-
while (_) try {
|
|
30
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
-
switch (op[0]) {
|
|
33
|
-
case 0: case 1: t = op; break;
|
|
34
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
-
default:
|
|
38
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
-
if (t[2]) _.ops.pop();
|
|
43
|
-
_.trys.pop(); continue;
|
|
44
|
-
}
|
|
45
|
-
op = body.call(thisArg, _);
|
|
46
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.__esModule = true;
|
|
23
|
+
var AuthService_1;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
25
|
exports.AuthService = void 0;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
const aws_amplify_1 = require("aws-amplify");
|
|
27
|
+
const axios_1 = require("axios");
|
|
28
|
+
const Identifiers_1 = require("./../../lib/constant/Identifiers");
|
|
29
|
+
const KushkiError_1 = require("./../../lib/generic/KushkiError");
|
|
30
|
+
const CognitoErrorEnum_1 = require("./../../lib/infrastructure/CognitoErrorEnum");
|
|
31
|
+
const ErrorEnum_1 = require("./../../lib/infrastructure/ErrorEnum");
|
|
32
|
+
const KPayUserPoolEnum_1 = require("./../../lib/infrastructure/KPayUserPoolEnum");
|
|
33
|
+
const inversify_1 = require("inversify");
|
|
60
34
|
require("reflect-metadata");
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
const rxjs_1 = require("rxjs");
|
|
36
|
+
const operators_1 = require("rxjs/operators");
|
|
37
|
+
const UtilsService_1 = require("./../../lib/service/UtilsService");
|
|
64
38
|
/**
|
|
65
39
|
* Implementation
|
|
66
40
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
41
|
+
let AuthService = AuthService_1 = class AuthService {
|
|
42
|
+
constructor(gateway) {
|
|
69
43
|
this._gateway = gateway;
|
|
70
44
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return rxjs_1.from(aws_amplify_1.Auth.sendCustomChallengeAnswer(_this._cognitoUser, code));
|
|
86
|
-
}), operators_1.catchError(function () { return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E009)); }), operators_1.concatMap(function () { return _this._verifyCurrentSession(); }), operators_1.map(function (session) { return ({
|
|
87
|
-
authorization: session.getRefreshToken().getToken()
|
|
88
|
-
}); }));
|
|
89
|
-
};
|
|
90
|
-
AuthService.prototype.validateSession = function (isTestEnvironment) {
|
|
91
|
-
var _this = this;
|
|
92
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
|
|
93
|
-
return AuthService_1._configureAmplifyCredentials(isTestEnvironment);
|
|
94
|
-
}), operators_1.concatMap(function () { return _this._getCurrentUserEmail(); }));
|
|
95
|
-
};
|
|
96
|
-
AuthService.prototype.getAuthorizationToken = function () {
|
|
97
|
-
var _this = this;
|
|
98
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(function () { return _this._currentAuthenticatedUser(); }), operators_1.mergeMap(function (cognitoUser) {
|
|
99
|
-
var session = cognitoUser ? cognitoUser.getSignInUserSession() : null;
|
|
45
|
+
requestInitAuth(body, isTestEnvironment) {
|
|
46
|
+
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.mergeMap(() => this._validateCurrentSession(body.email)), operators_1.mergeMap(sessionJwt => rxjs_1.iif(() => !!sessionJwt, rxjs_1.of({ result: true }), this._handleInitAuth(body.email))));
|
|
47
|
+
}
|
|
48
|
+
requestVerifyAuth(code, isTestEnvironment) {
|
|
49
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.sendCustomChallengeAnswer(this._cognitoUser, code))), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E009))), operators_1.concatMap(() => this._verifyCurrentSession()), operators_1.map(session => ({
|
|
50
|
+
authorization: session.getRefreshToken().getToken(),
|
|
51
|
+
})));
|
|
52
|
+
}
|
|
53
|
+
validateSession(isTestEnvironment) {
|
|
54
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.concatMap(() => this._getCurrentUserEmail()));
|
|
55
|
+
}
|
|
56
|
+
getAuthorizationToken() {
|
|
57
|
+
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this._currentAuthenticatedUser()), operators_1.mergeMap((cognitoUser) => {
|
|
58
|
+
const session = cognitoUser ? cognitoUser.getSignInUserSession() : null;
|
|
100
59
|
if (!session)
|
|
101
60
|
return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011));
|
|
102
61
|
return rxjs_1.of(session.getAccessToken().getJwtToken());
|
|
103
|
-
}), operators_1.catchError(
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var user_attributes = {
|
|
62
|
+
}), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011))));
|
|
63
|
+
}
|
|
64
|
+
_currentAuthenticatedUser() {
|
|
65
|
+
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => rxjs_1.from(aws_amplify_1.Auth.currentAuthenticatedUser())));
|
|
66
|
+
}
|
|
67
|
+
_verifyCurrentSession() {
|
|
68
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.currentSession())), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E008))));
|
|
69
|
+
}
|
|
70
|
+
_handleInitAuth(email) {
|
|
71
|
+
const password = AuthService_1._getRandomString();
|
|
72
|
+
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => {
|
|
73
|
+
const user_attributes = {
|
|
116
74
|
"custom:merchant": email,
|
|
117
75
|
given_name: email,
|
|
118
|
-
preferred_username: email
|
|
76
|
+
preferred_username: email,
|
|
119
77
|
};
|
|
120
|
-
|
|
121
|
-
password
|
|
78
|
+
const params = {
|
|
79
|
+
password,
|
|
122
80
|
attributes: user_attributes,
|
|
123
|
-
username: email
|
|
81
|
+
username: email,
|
|
124
82
|
};
|
|
125
83
|
return rxjs_1.from(aws_amplify_1.Auth.signUp(params));
|
|
126
|
-
}), operators_1.concatMap(
|
|
127
|
-
|
|
84
|
+
}), operators_1.concatMap(() => this._userSignIn(email, password)), operators_1.concatMap((cognitoUser) => {
|
|
85
|
+
this._cognitoUser = cognitoUser;
|
|
128
86
|
return cognitoUser
|
|
129
87
|
.getSignInUserSession()
|
|
130
88
|
.getAccessToken()
|
|
131
89
|
.getJwtToken();
|
|
132
|
-
}), operators_1.concatMap(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var error_code = UtilsService_1.UtilsService.sGet(error, "code", "");
|
|
136
|
-
return rxjs_1.iif(function () { return error_code === CognitoErrorEnum_1.CognitoErrorEnum.UsernameExistsException; }, _this._userSignInPasswordles(email), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E007)));
|
|
90
|
+
}), operators_1.concatMap((authorization) => rxjs_1.iif(() => !!authorization, rxjs_1.of({ result: true }), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E001)))), operators_1.catchError((error) => {
|
|
91
|
+
const error_code = UtilsService_1.UtilsService.sGet(error, "code", "");
|
|
92
|
+
return rxjs_1.iif(() => error_code === CognitoErrorEnum_1.CognitoErrorEnum.UsernameExistsException, this._userSignInPasswordles(email), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E007)));
|
|
137
93
|
}));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(function () { return aws_amplify_1.Auth.currentSession(); }), operators_1.concatMap(function (session) {
|
|
142
|
-
return rxjs_1.forkJoin([rxjs_1.of(session), rxjs_1.from(aws_amplify_1.Auth.currentUserInfo())]);
|
|
143
|
-
}), operators_1.concatMap(function (_a) {
|
|
144
|
-
var session = _a[0], current_user_info = _a[1];
|
|
94
|
+
}
|
|
95
|
+
_validateCurrentSession(email) {
|
|
96
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.currentSession()), operators_1.concatMap(session => rxjs_1.forkJoin([rxjs_1.of(session), rxjs_1.from(aws_amplify_1.Auth.currentUserInfo())])), operators_1.concatMap(([session, current_user_info]) => {
|
|
145
97
|
if (email &&
|
|
146
98
|
current_user_info.attributes.email.toLowerCase() !==
|
|
147
99
|
email.toLowerCase())
|
|
148
|
-
return
|
|
100
|
+
return this._signOut();
|
|
149
101
|
return rxjs_1.of(session.getAccessToken().getJwtToken());
|
|
150
|
-
}), operators_1.catchError(
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var _this = this;
|
|
167
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(function () { return rxjs_1.from(aws_amplify_1.Auth.signIn(email)); }), operators_1.mergeMap(function (cognitoUser) {
|
|
168
|
-
_this._cognitoUser = cognitoUser;
|
|
102
|
+
}), operators_1.catchError(() => this._signOut()));
|
|
103
|
+
}
|
|
104
|
+
_getCurrentUserEmail() {
|
|
105
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.currentUserInfo()), operators_1.concatMap(currentInfo => rxjs_1.iif(() => !!currentInfo.attributes.email, rxjs_1.of({
|
|
106
|
+
email: currentInfo.attributes.email.toLowerCase(),
|
|
107
|
+
}), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011)))), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011))));
|
|
108
|
+
}
|
|
109
|
+
_signOut() {
|
|
110
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.signOut()), operators_1.mapTo(false));
|
|
111
|
+
}
|
|
112
|
+
_userSignIn(email, password) {
|
|
113
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.signIn(email, password))));
|
|
114
|
+
}
|
|
115
|
+
_userSignInPasswordles(email) {
|
|
116
|
+
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => rxjs_1.from(aws_amplify_1.Auth.signIn(email))), operators_1.mergeMap((cognitoUser) => {
|
|
117
|
+
this._cognitoUser = cognitoUser;
|
|
169
118
|
return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E010));
|
|
170
119
|
}));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
mandatorySignId: true,
|
|
192
|
-
region: auth.cognito.REGION,
|
|
193
|
-
storage: window.sessionStorage,
|
|
194
|
-
userPoolId: auth.cognito.USER_POOL_ID,
|
|
195
|
-
userPoolWebClientId: auth.cognito.APP_CLIENT_ID
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
return [2 /*return*/];
|
|
199
|
-
}
|
|
120
|
+
}
|
|
121
|
+
static _configureAmplifyCredentials(test) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const remote_kpay_user_pool_url = `${test ? KPayUserPoolEnum_1.KPayUserPoolEnum.uat : KPayUserPoolEnum_1.KPayUserPoolEnum.prod}`;
|
|
124
|
+
const { data: cognito_config } = yield axios_1.default.get(remote_kpay_user_pool_url);
|
|
125
|
+
const auth = {
|
|
126
|
+
cognito: {
|
|
127
|
+
APP_CLIENT_ID: cognito_config.appClientId,
|
|
128
|
+
REGION: cognito_config.region,
|
|
129
|
+
USER_POOL_ID: cognito_config.userPoolId,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
aws_amplify_1.Auth.configure({
|
|
133
|
+
Auth: {
|
|
134
|
+
mandatorySignId: true,
|
|
135
|
+
region: auth.cognito.REGION,
|
|
136
|
+
storage: window.sessionStorage,
|
|
137
|
+
userPoolId: auth.cognito.USER_POOL_ID,
|
|
138
|
+
userPoolWebClientId: auth.cognito.APP_CLIENT_ID,
|
|
139
|
+
},
|
|
200
140
|
});
|
|
201
141
|
});
|
|
202
|
-
}
|
|
203
|
-
|
|
142
|
+
}
|
|
143
|
+
static _getRandomString() {
|
|
204
144
|
return (
|
|
205
145
|
// tslint:disable-next-line:insecure-random
|
|
206
146
|
Math.random()
|
|
@@ -211,13 +151,11 @@ var AuthService = /** @class */ (function () {
|
|
|
211
151
|
.toString(36)
|
|
212
152
|
.toUpperCase()
|
|
213
153
|
.slice(2));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return AuthService;
|
|
222
|
-
}());
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
AuthService = AuthService_1 = __decorate([
|
|
157
|
+
inversify_1.injectable(),
|
|
158
|
+
__param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
|
|
159
|
+
__metadata("design:paramtypes", [Object])
|
|
160
|
+
], AuthService);
|
|
223
161
|
exports.AuthService = AuthService;
|