@fat-zebra/sdk 1.0.1 → 1.0.3

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.
Files changed (75) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +2 -5
  3. package/dist/react/VerifyCard.js +11 -17
  4. package/dist/react/index.js +2 -8
  5. package/dist/react/url.js +10 -14
  6. package/dist/react/useFatZebra.js +23 -63
  7. package/dist/sca/cardinal.d.ts +2 -1
  8. package/dist/sca/cardinal.js +22 -61
  9. package/dist/sca/eci-mappings.js +4 -8
  10. package/dist/sca/index.js +182 -296
  11. package/dist/sca/scenarios/enrollment.d.ts +2 -1
  12. package/dist/sca/scenarios/enrollment.js +25 -28
  13. package/dist/sca/scenarios/index.d.ts +4 -2
  14. package/dist/sca/scenarios/index.js +2 -7
  15. package/dist/sca/scenarios/validation.d.ts +2 -1
  16. package/dist/sca/scenarios/validation.js +16 -19
  17. package/dist/sca/types.d.ts +2 -1
  18. package/dist/sca/types.js +6 -8
  19. package/dist/shared/api-gateway-client.js +37 -81
  20. package/dist/shared/bridge-client.js +5 -8
  21. package/dist/shared/constants.js +6 -13
  22. package/dist/shared/event-manager.d.ts +2 -1
  23. package/dist/shared/event-manager.js +3 -9
  24. package/dist/shared/post-message-client.d.ts +2 -1
  25. package/dist/shared/post-message-client.js +38 -75
  26. package/dist/shared/types.d.ts +2 -1
  27. package/dist/shared/types.js +5 -7
  28. package/dist/shared/util.js +18 -31
  29. package/fat-zebra-sdk-1.0.2.tgz +0 -0
  30. package/package.json +2 -2
  31. package/tsconfig.json +6 -4
  32. package/dist/index.js.map +0 -1
  33. package/dist/react/VerifyCard.js.map +0 -1
  34. package/dist/react/index.js.map +0 -1
  35. package/dist/react/url.js.map +0 -1
  36. package/dist/react/useFatZebra.js.map +0 -1
  37. package/dist/sca/cardinal.js.map +0 -1
  38. package/dist/sca/eci-mappings.js.map +0 -1
  39. package/dist/sca/index.js.map +0 -1
  40. package/dist/sca/scenarios/enrollment.js.map +0 -1
  41. package/dist/sca/scenarios/index.js.map +0 -1
  42. package/dist/sca/scenarios/validation.js.map +0 -1
  43. package/dist/sca/types.js.map +0 -1
  44. package/dist/shared/api-gateway-client.js.map +0 -1
  45. package/dist/shared/bridge-client.js.map +0 -1
  46. package/dist/shared/constants.js.map +0 -1
  47. package/dist/shared/event-manager.js.map +0 -1
  48. package/dist/shared/post-message-client.js.map +0 -1
  49. package/dist/shared/types.js.map +0 -1
  50. package/dist/shared/util.js.map +0 -1
  51. package/src/index.ts +0 -9
  52. package/src/react/VerifyCard.tsx +0 -36
  53. package/src/react/index.ts +0 -3
  54. package/src/react/url.ts +0 -97
  55. package/src/react/useFatZebra.ts +0 -154
  56. package/src/sca/__tests__/eci-mappings.test.ts +0 -35
  57. package/src/sca/__tests__/index.test.ts +0 -514
  58. package/src/sca/cardinal.ts +0 -136
  59. package/src/sca/eci-mappings.ts +0 -63
  60. package/src/sca/index.ts +0 -329
  61. package/src/sca/scenarios/enrollment.ts +0 -164
  62. package/src/sca/scenarios/index.ts +0 -2
  63. package/src/sca/scenarios/validation.ts +0 -142
  64. package/src/sca/types.ts +0 -206
  65. package/src/shared/api-gateway-client.ts +0 -71
  66. package/src/shared/bridge-client.ts +0 -26
  67. package/src/shared/constants.ts +0 -19
  68. package/src/shared/event-manager.ts +0 -44
  69. package/src/shared/post-message-client.test.ts +0 -73
  70. package/src/shared/post-message-client.ts +0 -125
  71. package/src/shared/types.test.ts +0 -65
  72. package/src/shared/types.ts +0 -182
  73. package/src/shared/util.test.ts +0 -164
  74. package/src/shared/util.ts +0 -98
  75. package/tests/helpers/api-gateway-mock.ts +0 -46
package/dist/sca/index.js CHANGED
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,286 +7,197 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- 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;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- var t = __importStar(require("./types"));
63
- var scenarios_1 = require("./scenarios");
64
- var types_1 = require("../shared/types");
65
- var cardinal_1 = require("./cardinal");
66
- var event_manager_1 = require("../shared/event-manager");
67
- var eci_mappings_1 = require("./eci-mappings");
68
- var Sca = /** @class */ (function () {
69
- function Sca(_a) {
70
- var gatewayClient = _a.gatewayClient;
10
+ import * as t from './types';
11
+ import { enrollmentScenarios, validationScenarios, } from './scenarios';
12
+ import { PublicEvent, } from '../shared/types';
13
+ import { CardinalManager, } from './cardinal';
14
+ import { emit, } from '../shared/event-manager';
15
+ import { toFzSli } from './eci-mappings';
16
+ class Sca {
17
+ constructor({ gatewayClient }) {
71
18
  this._eventEmitTarget = window;
72
19
  this.sessionId = null;
73
20
  this.gatewayClient = gatewayClient;
74
21
  this.loadScript();
75
22
  }
76
- Sca.prototype.loadScript = function () {
77
- var _this = this;
23
+ loadScript() {
78
24
  if (!document.getElementById("songbird-script")) {
79
- var script = document.createElement('script');
25
+ const script = document.createElement('script');
80
26
  script.type = 'text/javascript';
81
27
  script.id = "songbird-script";
82
28
  script.src = process.env.SONGBIRD_URL;
83
29
  script.async = true;
84
- script.onload = function () {
85
- _this._cardinal = new cardinal_1.CardinalManager();
30
+ script.onload = () => {
31
+ this._cardinal = new CardinalManager();
86
32
  };
87
33
  document.body.appendChild(script);
88
34
  }
89
35
  else {
90
- this._cardinal = new cardinal_1.CardinalManager();
36
+ this._cardinal = new CardinalManager();
91
37
  }
92
- };
93
- Object.defineProperty(Sca.prototype, "cardinal", {
94
- get: function () {
95
- return this._cardinal;
96
- },
97
- set: function (cardinal) {
98
- this._cardinal = cardinal;
99
- },
100
- enumerable: false,
101
- configurable: true
102
- });
103
- Object.defineProperty(Sca.prototype, "eventEmitTarget", {
104
- get: function () {
105
- return this._eventEmitTarget;
106
- },
107
- // Specify the DOM element to which the SCA results are outputted.
108
- set: function (target) {
109
- this._eventEmitTarget = target;
110
- },
111
- enumerable: false,
112
- configurable: true
113
- });
114
- Sca.prototype.run = function (config) {
115
- return __awaiter(this, void 0, void 0, function () {
116
- var cardinalJwt, error_1, message, paymentsSetupCompleteResponse, err_1, message, err_2, message;
117
- var _this = this;
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
120
- case 0:
121
- // Persist states until next 3DS run.
122
- this.paymentIntent = config.paymentIntent;
123
- this.bin = config.bin;
124
- this.cardToken = config.cardToken;
125
- this.customer = config.customer;
126
- this.challengeWindowSize = config.challengeWindowSize || t.ChallengeWindowSize.SIZE_FULL_PAGE;
127
- _a.label = 1;
128
- case 1:
129
- _a.trys.push([1, 3, , 4]);
130
- return [4 /*yield*/, this.createCardinalJWT()];
131
- case 2:
132
- cardinalJwt = _a.sent();
133
- return [3 /*break*/, 4];
134
- case 3:
135
- error_1 = _a.sent();
136
- message = 'FatZebra.3DS: JWT creation failed.';
137
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
38
+ }
39
+ get cardinal() {
40
+ return this._cardinal;
41
+ }
42
+ set cardinal(cardinal) {
43
+ this._cardinal = cardinal;
44
+ }
45
+ get eventEmitTarget() {
46
+ return this._eventEmitTarget;
47
+ }
48
+ // Specify the DOM element to which the SCA results are outputted.
49
+ set eventEmitTarget(target) {
50
+ this._eventEmitTarget = target;
51
+ }
52
+ run(config) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ // Persist states until next 3DS run.
55
+ this.paymentIntent = config.paymentIntent;
56
+ this.bin = config.bin;
57
+ this.cardToken = config.cardToken;
58
+ this.customer = config.customer;
59
+ this.challengeWindowSize = config.challengeWindowSize || t.ChallengeWindowSize.SIZE_FULL_PAGE;
60
+ let cardinalJwt;
61
+ // Generate Cardinal JWT
62
+ try {
63
+ cardinalJwt = yield this.createCardinalJWT();
64
+ }
65
+ catch (error) {
66
+ const message = 'FatZebra.3DS: JWT creation failed.';
67
+ emit(PublicEvent.SCA_ERROR, {
68
+ errors: [message],
69
+ data: null
70
+ });
71
+ console.log(message);
72
+ return;
73
+ }
74
+ // Init cardinal
75
+ this._cardinal.setup(cardinalJwt);
76
+ if (!this.sessionId) {
77
+ const paymentsSetupCompleteResponse = yield this._cardinal.onPaymentSetupComplete();
78
+ this.sessionId = paymentsSetupCompleteResponse.sessionId;
79
+ // Register handler. Called after OTP is entered on challenge prompt.
80
+ this._cardinal.onPaymentValidated((data, error) => __awaiter(this, void 0, void 0, function* () {
81
+ if (typeof error == 'string') {
82
+ const message = `FatZebra.3DS: Validation failed. ${error}.`;
83
+ emit(PublicEvent.SCA_ERROR, {
138
84
  errors: [message],
139
- data: null
85
+ data: null,
140
86
  });
141
87
  console.log(message);
142
- return [2 /*return*/];
143
- case 4:
144
- // Init cardinal
145
- this._cardinal.setup(cardinalJwt);
146
- if (!!this.sessionId) return [3 /*break*/, 6];
147
- return [4 /*yield*/, this._cardinal.onPaymentSetupComplete()];
148
- case 5:
149
- paymentsSetupCompleteResponse = _a.sent();
150
- this.sessionId = paymentsSetupCompleteResponse.sessionId;
151
- // Register handler. Called after OTP is entered on challenge prompt.
152
- this._cardinal.onPaymentValidated(function (data, error) { return __awaiter(_this, void 0, void 0, function () {
153
- var message, decodeSCASessionResponse, message, validateSCAResponse, requestParams, errorResponse_1, message, threedsData, scenario, message, message;
154
- return __generator(this, function (_a) {
155
- switch (_a.label) {
156
- case 0:
157
- if (typeof error == 'string') {
158
- message = "FatZebra.3DS: Validation failed. ".concat(error, ".");
159
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
160
- errors: [message],
161
- data: null,
162
- });
163
- console.log(message);
164
- return [2 /*return*/];
165
- }
166
- return [4 /*yield*/, this.gatewayClient.decodeSCASession({
167
- token: data.jwt
168
- })];
169
- case 1:
170
- decodeSCASessionResponse = (_a.sent()).data;
171
- if (data.processorTransactionId !== decodeSCASessionResponse.processor_transaction_id) {
172
- message = 'FatZebra.3DS: Validation failed. Invalid process transaction id.';
173
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
174
- errors: [message],
175
- data: null
176
- });
177
- console.log(message);
178
- }
179
- _a.label = 2;
180
- case 2:
181
- _a.trys.push([2, 4, , 5]);
182
- requestParams = {
183
- amount: this.paymentIntent.payment.amount,
184
- authentication_transaction_id: this.enrollmentResult.authentication_transaction_id,
185
- card_token: this.cardToken,
186
- currency: this.paymentIntent.payment.currency,
187
- pareq: this.enrollmentResult.pareq,
188
- reference: this.paymentIntent.payment.reference,
189
- };
190
- return [4 /*yield*/, this.gatewayClient.validateSCA(requestParams)];
191
- case 3:
192
- validateSCAResponse = (_a.sent()).data;
193
- return [3 /*break*/, 5];
194
- case 4:
195
- errorResponse_1 = _a.sent();
196
- message = 'FatZebra.3DS: Validation failed. Server error.';
197
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
198
- errors: [message],
199
- data: null,
200
- });
201
- console.log(message);
202
- return [2 /*return*/];
203
- case 5:
204
- threedsData = threedsResponseData(validateSCAResponse);
205
- scenario = getValidationResult(validateSCAResponse);
206
- if (scenario.outcome.success) {
207
- message = "FatZebra.3DS: 3DS success - ".concat(scenario.description, ".");
208
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_SUCCESS, {
209
- message: message,
210
- data: threedsData,
211
- });
212
- console.log(message);
213
- }
214
- else {
215
- message = "FatZebra.3DS: 3DS error - ".concat(scenario.description);
216
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
217
- errors: [message],
218
- data: {
219
- errorCode: scenario.outcome.errorCode
220
- },
221
- });
222
- console.log(message);
223
- }
224
- return [2 /*return*/];
225
- }
226
- });
227
- }); });
228
- _a.label = 6;
229
- case 6:
230
- _a.trys.push([6, 8, , 9]);
231
- return [4 /*yield*/, this._cardinal.processBin(this.bin)];
232
- case 7:
233
- _a.sent();
234
- return [3 /*break*/, 9];
235
- case 8:
236
- err_1 = _a.sent();
237
- message = 'FatZebra.3DS: BIN verification failed.';
238
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
88
+ return;
89
+ }
90
+ const decodeSCASessionResponse = (yield this.gatewayClient.decodeSCASession({
91
+ token: data.jwt
92
+ })).data;
93
+ if (data.processorTransactionId !== decodeSCASessionResponse.processor_transaction_id) {
94
+ const message = 'FatZebra.3DS: Validation failed. Invalid process transaction id.';
95
+ emit(PublicEvent.SCA_ERROR, {
239
96
  errors: [message],
240
97
  data: null
241
98
  });
242
99
  console.log(message);
243
- return [2 /*return*/];
244
- case 9:
245
- _a.trys.push([9, 11, , 12]);
246
- return [4 /*yield*/, this.check3DSEnrollment()];
247
- case 10:
248
- _a.sent();
249
- return [3 /*break*/, 12];
250
- case 11:
251
- err_2 = _a.sent();
252
- message = 'FatZebra.3DS: Enrollment failed. Server error.';
253
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
100
+ }
101
+ let validateSCAResponse;
102
+ try {
103
+ const requestParams = {
104
+ amount: this.paymentIntent.payment.amount,
105
+ authentication_transaction_id: this.enrollmentResult.authentication_transaction_id,
106
+ card_token: this.cardToken,
107
+ currency: this.paymentIntent.payment.currency,
108
+ pareq: this.enrollmentResult.pareq,
109
+ reference: this.paymentIntent.payment.reference,
110
+ };
111
+ validateSCAResponse = (yield this.gatewayClient.validateSCA(requestParams)).data;
112
+ }
113
+ catch (errorResponse) {
114
+ const message = 'FatZebra.3DS: Validation failed. Server error.';
115
+ emit(PublicEvent.SCA_ERROR, {
254
116
  errors: [message],
255
- data: null
117
+ data: null,
256
118
  });
257
119
  console.log(message);
258
- return [2 /*return*/];
259
- case 12:
260
- this.handleEnrollmentResult(this.enrollmentResult);
261
- return [2 /*return*/];
262
- }
263
- });
120
+ return;
121
+ }
122
+ const threedsData = threedsResponseData(validateSCAResponse);
123
+ const scenario = getValidationResult(validateSCAResponse);
124
+ if (scenario.outcome.success) {
125
+ const message = `FatZebra.3DS: 3DS success - ${scenario.description}.`;
126
+ emit(PublicEvent.SCA_SUCCESS, {
127
+ message,
128
+ data: threedsData,
129
+ });
130
+ console.log(message);
131
+ }
132
+ else {
133
+ const message = `FatZebra.3DS: 3DS error - ${scenario.description}`;
134
+ emit(PublicEvent.SCA_ERROR, {
135
+ errors: [message],
136
+ data: {
137
+ errorCode: scenario.outcome.errorCode
138
+ },
139
+ });
140
+ console.log(message);
141
+ }
142
+ }));
143
+ }
144
+ // Cardinal processs BIN using directory server. This determines the 3DS version used.
145
+ try {
146
+ yield this._cardinal.processBin(this.bin);
147
+ }
148
+ catch (err) {
149
+ const message = 'FatZebra.3DS: BIN verification failed.';
150
+ emit(PublicEvent.SCA_ERROR, {
151
+ errors: [message],
152
+ data: null
153
+ });
154
+ console.log(message);
155
+ return;
156
+ }
157
+ try {
158
+ yield this.check3DSEnrollment();
159
+ }
160
+ catch (err) {
161
+ const message = 'FatZebra.3DS: Enrollment failed. Server error.';
162
+ emit(PublicEvent.SCA_ERROR, {
163
+ errors: [message],
164
+ data: null
165
+ });
166
+ console.log(message);
167
+ return;
168
+ }
169
+ this.handleEnrollmentResult(this.enrollmentResult);
264
170
  });
265
- };
266
- Sca.prototype.createCardinalJWT = function () {
267
- return __awaiter(this, void 0, void 0, function () {
268
- var payment, response;
269
- return __generator(this, function (_a) {
270
- switch (_a.label) {
271
- case 0:
272
- payment = this.paymentIntent.payment;
273
- return [4 /*yield*/, this.gatewayClient.createSCASession({
274
- amount: payment.amount,
275
- currency: payment.currency,
276
- hide_card_holder: payment.hide_card_holder,
277
- })];
278
- case 1:
279
- response = (_a.sent()).data;
280
- return [2 /*return*/, response.jwt];
281
- }
282
- });
171
+ }
172
+ createCardinalJWT() {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const { payment } = this.paymentIntent;
175
+ const response = (yield this.gatewayClient.createSCASession({
176
+ amount: payment.amount,
177
+ currency: payment.currency,
178
+ hide_card_holder: payment.hide_card_holder,
179
+ })).data;
180
+ return response.jwt;
283
181
  });
284
- };
285
- Sca.prototype.check3DSEnrollment = function () {
286
- return __awaiter(this, void 0, void 0, function () {
287
- var _a;
288
- return __generator(this, function (_b) {
289
- switch (_b.label) {
290
- case 0:
291
- // Persist enrollResult state in memory for handlePaymentValidation handler
292
- _a = this;
293
- return [4 /*yield*/, this.gatewayClient.enrolSCA({
294
- amount: this.paymentIntent.payment.amount,
295
- card_token: this.cardToken,
296
- currency: this.paymentIntent.payment.currency,
297
- reference: this.paymentIntent.payment.reference,
298
- verification: this.paymentIntent.verification,
299
- session_id: this.sessionId,
300
- challenge_window_size: this.challengeWindowSize,
301
- hide_card_holder: this.paymentIntent.payment.hide_card_holder,
302
- customer: this.customerProperties(this.customer),
303
- })];
304
- case 1:
305
- // Persist enrollResult state in memory for handlePaymentValidation handler
306
- _a.enrollmentResult = (_b.sent()).data;
307
- return [2 /*return*/];
308
- }
309
- });
182
+ }
183
+ check3DSEnrollment() {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ // Persist enrollResult state in memory for handlePaymentValidation handler
186
+ this.enrollmentResult = (yield this.gatewayClient.enrolSCA({
187
+ amount: this.paymentIntent.payment.amount,
188
+ card_token: this.cardToken,
189
+ currency: this.paymentIntent.payment.currency,
190
+ reference: this.paymentIntent.payment.reference,
191
+ verification: this.paymentIntent.verification,
192
+ session_id: this.sessionId,
193
+ challenge_window_size: this.challengeWindowSize,
194
+ hide_card_holder: this.paymentIntent.payment.hide_card_holder,
195
+ customer: this.customerProperties(this.customer),
196
+ })).data;
310
197
  });
311
- };
312
- Sca.prototype.customerProperties = function (customer) {
313
- var properties = {};
198
+ }
199
+ customerProperties(customer) {
200
+ let properties = {};
314
201
  if (!customer)
315
202
  return properties;
316
203
  if (customer.firstName)
@@ -330,25 +217,25 @@ var Sca = /** @class */ (function () {
330
217
  if (customer.country)
331
218
  properties.country = customer.country;
332
219
  return properties;
333
- };
334
- Sca.prototype.handleEnrollmentResult = function (enrollSCAResponse) {
335
- var threedsData = threedsResponseData(enrollSCAResponse);
336
- var scenario = getEnrollmentResult(enrollSCAResponse);
220
+ }
221
+ handleEnrollmentResult(enrollSCAResponse) {
222
+ const threedsData = threedsResponseData(enrollSCAResponse);
223
+ const scenario = getEnrollmentResult(enrollSCAResponse);
337
224
  if (scenario.outcome.authenticationType === 'challenge') {
338
225
  this._cardinal.continue(enrollSCAResponse.acs_url, enrollSCAResponse.pareq, enrollSCAResponse.authentication_transaction_id);
339
226
  return;
340
227
  }
341
228
  if (scenario.outcome.success) {
342
- var message = "FatZebra.3DS: 3DS success - ".concat(scenario.description, ".");
343
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_SUCCESS, {
344
- message: message,
229
+ const message = `FatZebra.3DS: 3DS success - ${scenario.description}.`;
230
+ emit(PublicEvent.SCA_SUCCESS, {
231
+ message,
345
232
  data: threedsData,
346
233
  });
347
234
  console.log(message);
348
235
  }
349
236
  else {
350
- var message = "FatZebra.3DS: 3DS error - ".concat(scenario.description);
351
- (0, event_manager_1.emit)(types_1.PublicEvent.SCA_ERROR, {
237
+ const message = `FatZebra.3DS: 3DS error - ${scenario.description}`;
238
+ emit(PublicEvent.SCA_ERROR, {
352
239
  errors: [message],
353
240
  data: {
354
241
  errorCode: scenario.outcome.errorCode
@@ -356,39 +243,38 @@ var Sca = /** @class */ (function () {
356
243
  });
357
244
  console.log(message);
358
245
  }
359
- };
360
- return Sca;
361
- }());
362
- var threedsResponseData = function (response) {
246
+ }
247
+ }
248
+ const threedsResponseData = (response) => {
363
249
  return {
364
250
  // CAVV: Visa & Amex only
365
251
  // AAV: Mastercard only, known as UCAF
366
252
  cavv: response.cavv || response.aav,
367
253
  par: response.pares,
368
- sli: (0, eci_mappings_1.toFzSli)(response.eci),
254
+ sli: toFzSli(response.eci),
369
255
  xid: response.xid,
370
256
  ver: response.enrolled,
371
257
  directoryServerTxnId: response.directory_server_txn_id,
372
258
  threedsVersion: response.version,
373
259
  };
374
260
  };
375
- var getEnrollmentResult = function (enrollment) {
376
- return scenarios_1.enrollmentScenarios.find(function (item) {
261
+ const getEnrollmentResult = (enrollment) => {
262
+ return enrollmentScenarios.find((item) => {
377
263
  return item.reasonCode === enrollment.reason_code &&
378
264
  item.veresEnrolled === enrollment.enrolled &&
379
265
  item.pares === enrollment.pares &&
380
266
  item.threedsVersion === getMajor3dsVersion(enrollment.version);
381
267
  });
382
268
  };
383
- var getValidationResult = function (validation) {
384
- return scenarios_1.validationScenarios.find(function (item) {
269
+ const getValidationResult = (validation) => {
270
+ return validationScenarios.find((item) => {
385
271
  return item.reasonCode === validation.reason_code &&
386
272
  item.pares === validation.pares &&
387
273
  item.threedsVersion === getMajor3dsVersion(validation.version);
388
274
  });
389
275
  };
390
276
  // 3DS versioning follows SEMVER format. The first charactor is the major version number.
391
- var getMajor3dsVersion = function (original) {
277
+ const getMajor3dsVersion = (original) => {
392
278
  return original[0];
393
279
  };
394
- exports.default = Sca;
280
+ export default Sca;
@@ -12,4 +12,5 @@ interface EnrollmentScenario {
12
12
  };
13
13
  }
14
14
  declare const enrollmentScenarios: EnrollmentScenario[];
15
- export { EnrollmentScenario, enrollmentScenarios };
15
+ export { enrollmentScenarios };
16
+ export type { EnrollmentScenario };