@kushki/js 1.35.0 → 1.36.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/KushkiInfo.js CHANGED
@@ -13,7 +13,7 @@ var KInfo = /** @class */ (function () {
13
13
  function KInfo() {
14
14
  }
15
15
  KInfo.buildKushkiInfo = function (kushkiInfo) {
16
- var kushki_js_version = "1.35.0";
16
+ var kushki_js_version = "1.36.0";
17
17
  if (kushkiInfo) {
18
18
  if (UtilsService_1.UtilsService.sIsEmpty(kushkiInfo.platformVersion))
19
19
  kushkiInfo.platformVersion = kushki_js_version;
@@ -83,6 +83,7 @@ var SiftScience = /** @class */ (function () {
83
83
  };
84
84
  SiftScience.prototype._initSiftScience = function (regional) {
85
85
  try {
86
+ // istanbul ignore next
86
87
  if (!UtilsService_1.UtilsService.sIsEmpty(window)) {
87
88
  var e = window.document.createElement("script");
88
89
  e.src = regional
@@ -22,6 +22,7 @@ exports.AurusError = void 0;
22
22
  */
23
23
  var AurusError = /** @class */ (function (_super) {
24
24
  __extends(AurusError, _super);
25
+ // istanbul ignore next
25
26
  function AurusError(code, message) {
26
27
  var _this = _super.call(this, "AURUS" + code) /* istanbul ignore next: TODO: reporter is failing */ || this;
27
28
  _this.code = code;
@@ -79,4 +79,9 @@ export interface ICardService {
79
79
  * @param regional - Define if endpoint used regional URL
80
80
  */
81
81
  requestSecureInit(body: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
82
+ /**
83
+ *
84
+ * @param alreadyObtainedToken
85
+ */
86
+ setAlreadyObtainedToken(alreadyObtainedToken: boolean): any;
82
87
  }
@@ -39,6 +39,7 @@ export declare class CardService implements ICardService {
39
39
  private readonly _3Dsecure;
40
40
  private readonly _cardNumber;
41
41
  private _sandboxEnable;
42
+ private _alreadyObtainedToken;
42
43
  constructor(gateway: IKushkiGateway, authService: IAuthService, antiFraud: IAntiFraud);
43
44
  requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
44
45
  requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
@@ -47,6 +48,8 @@ export declare class CardService implements ICardService {
47
48
  requestBinInfo(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<BinInfoResponse>;
48
49
  validate3DS(body: Validate3DSRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
49
50
  requestSecureInit(request: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
51
+ setAlreadyObtainedToken(alreadyObtainedToken: boolean): void;
52
+ private _handleRetryRequestToken3DS;
50
53
  private _getCreateSubscriptionDataToTransform;
51
54
  private _request3DSToken;
52
55
  private _setupCompleteCardinal;
@@ -82,6 +82,7 @@ var CardService = /** @class */ (function () {
82
82
  this._3Dsecure = "active_3dsecure";
83
83
  this._cardNumber = "card.number";
84
84
  this._sandboxEnable = false;
85
+ this._alreadyObtainedToken = false;
85
86
  this._gateway = gateway;
86
87
  this._antiFraud = antiFraud;
87
88
  this._authService = authService;
@@ -143,10 +144,14 @@ var CardService = /** @class */ (function () {
143
144
  },
144
145
  next: function (_a) {
145
146
  var final_request = _a[0], authorization = _a[1], merchant = _a[2];
146
- if (final_request.jwt && !merchant.sandboxEnable)
147
+ if (final_request.jwt && !merchant.sandboxEnable) {
147
148
  _this._request3DSToken(isTest, function () {
149
+ window.Cardinal.off("payments.setupComplete");
150
+ // istanbul ignore next
148
151
  _this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
149
152
  });
153
+ _this._handleRetryRequestToken3DS(final_request, mid, isTest, regional, callback, authorization);
154
+ }
150
155
  else
151
156
  _this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
152
157
  }
@@ -278,6 +283,24 @@ var CardService = /** @class */ (function () {
278
283
  jwt: jwt
279
284
  }); }));
280
285
  };
286
+ CardService.prototype.setAlreadyObtainedToken = function (alreadyObtainedToken) {
287
+ this._alreadyObtainedToken = alreadyObtainedToken;
288
+ };
289
+ CardService.prototype._handleRetryRequestToken3DS = function (finalRequest, mid, isTest, regional, callback, authorization) {
290
+ var _this = this;
291
+ // istanbul ignore next
292
+ if (this._alreadyObtainedToken)
293
+ return;
294
+ window.Cardinal.complete({
295
+ Status: "Success"
296
+ })
297
+ .then(function () {
298
+ _this._requestTokenGateway(finalRequest, mid, isTest, regional, callback, authorization);
299
+ })["catch"](function () {
300
+ var error = ErrorEnum_1.ERRORS[ErrorEnum_1.ErrorCode.E002];
301
+ Kushki_1.Kushki.callbackError(new KushkiError_1.KushkiError(error, ""), callback);
302
+ });
303
+ };
281
304
  CardService.prototype._getCreateSubscriptionDataToTransform = function (siftObject, subscriptionTokenRequest) {
282
305
  if (siftObject.userId === null || siftObject.sessionId === null)
283
306
  return __assign({}, subscriptionTokenRequest);
@@ -306,6 +329,7 @@ var CardService = /** @class */ (function () {
306
329
  };
307
330
  // istanbul ignore next
308
331
  CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
332
+ var _this = this;
309
333
  var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
310
334
  return request_token.subscribe({
311
335
  error: function (err) {
@@ -313,6 +337,7 @@ var CardService = /** @class */ (function () {
313
337
  },
314
338
  next: function (response) {
315
339
  callback(response);
340
+ _this._alreadyObtainedToken = true;
316
341
  }
317
342
  });
318
343
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.35.0",
3
+ "version": "1.36.0",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",