@kushki/js 1.30.0 → 1.30.1-alpha-3ds-setup-complete.1

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.js CHANGED
@@ -37,7 +37,7 @@ var Kushki = /** @class */ (function () {
37
37
  this._cardSubscriptionDynamicService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardSubscriptionDynamicService)();
38
38
  }
39
39
  Kushki.prototype.requestToken = function (body, callback) {
40
- this._resolve(this._cardService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
40
+ this._cardService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
41
41
  };
42
42
  Kushki.prototype.requestInitAntiFraud = function (userId, callback) {
43
43
  this._resolve(this._siftScience.requestInitAntiFraud(userId, this._merchantId, this._inTestEnvironment, this._regional), callback);
@@ -25,8 +25,9 @@ export interface ICardService {
25
25
  * @param mid - public merchant id
26
26
  * @param isTest - is test environment
27
27
  * @param regional - Define if endpoint used regional URL
28
+ * @param callback
28
29
  */
29
- requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
30
+ requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
30
31
  /**
31
32
  * Subscription Token
32
33
  * @param subscriptionTokenRequest - subscription tokens request body
@@ -17,5 +17,4 @@ export declare class CardDynamicService implements ICardDynamicService {
17
17
  constructor(cardService: ICardService, cardAsyncService: ICardAsyncService);
18
18
  requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<CardAsyncTokenResponse | TokenResponse>;
19
19
  private _requestCardAsyncToken;
20
- private _requestToken;
21
20
  }
@@ -34,7 +34,9 @@ var CardDynamicService = /** @class */ (function () {
34
34
  return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
35
35
  return _this._cardService.requestBinInfo(bin, mid, testEnv, regional);
36
36
  }), operators_1.concatMap(function (binInfo) {
37
- return rxjs_1.iif(function () { return binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit; }, _this._requestCardAsyncToken(body, mid, testEnv, regional), _this._requestToken(body, mid, testEnv, regional));
37
+ return rxjs_1.iif(function () { return binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit; }, _this._requestCardAsyncToken(body, mid, testEnv, regional), rxjs_1.of({
38
+ token: "12345"
39
+ }));
38
40
  }));
39
41
  };
40
42
  CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional) {
@@ -43,12 +45,6 @@ var CardDynamicService = /** @class */ (function () {
43
45
  return _this._cardAsyncService.requestCardAsyncToken(body, mid, testEnv, regional);
44
46
  }));
45
47
  };
46
- CardDynamicService.prototype._requestToken = function (body, mid, testEnv, regional) {
47
- var _this = this;
48
- return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
49
- return _this._cardService.requestToken(body, mid, testEnv, regional);
50
- }));
51
- };
52
48
  CardDynamicService = __decorate([
53
49
  inversify_1.injectable(),
54
50
  __param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.CardService)),
@@ -40,13 +40,16 @@ export declare class CardService implements ICardService {
40
40
  private readonly _cardNumber;
41
41
  private _sandboxEnable;
42
42
  constructor(gateway: IKushkiGateway, authService: IAuthService, antiFraud: IAntiFraud);
43
- requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
43
+ requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
44
44
  requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
45
45
  requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
46
46
  requestDeferred(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<IDeferredResponse[]>;
47
47
  requestBinInfo(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<BinInfoResponse>;
48
48
  validate3DS(body: Validate3DSRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
49
49
  requestSecureInit(request: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
50
+ private _requestToken;
51
+ private _request3DSToken;
52
+ private _requestTokenGateway;
50
53
  private _getMerchantSettings;
51
54
  private _validateParameters;
52
55
  private _getDeviceTokenSiftScienceObject;
@@ -103,36 +103,21 @@ var CardService = /** @class */ (function () {
103
103
  _a);
104
104
  }
105
105
  CardService_1 = CardService;
106
- CardService.prototype.requestToken = function (request, mid, isTest, regional) {
106
+ CardService.prototype.requestToken = function (request, mid, isTest, regional, callback) {
107
107
  var _this = this;
108
- return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap(function (merchant) {
109
- _this._setSandboxEnable(!!merchant.sandboxEnable);
110
- return rxjs_1.forkJoin([
111
- _this._getScienceSession(request, mid, isTest, merchant),
112
- _this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
113
- ? request.card.number
114
- : undefined),
115
- ]);
116
- }), operators_1.mergeMap(function (_a) {
117
- var sift_object = _a[0], jwt = _a[1];
118
- request.isDeferred =
119
- request.isDeferred === undefined ? false : request.isDeferred;
120
- if (Boolean(request.cvv))
121
- request.card = { cvc: request.cvv };
122
- _this._checkRequestBody(request);
123
- var data_to_transform = __assign(__assign({}, request), sift_object);
124
- if (jwt !== undefined)
125
- data_to_transform.jwt = jwt;
126
- return rxjs_1.forkJoin([
127
- rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
128
- request.walletId
129
- ? _this._authService.getAuthorizationToken()
130
- : rxjs_1.of(undefined),
131
- ]);
132
- }), operators_1.concatMap(function (_a) {
133
- var final_request = _a[0], jwt = _a[1];
134
- return _this._gateway.requestToken(final_request, mid, isTest, regional, jwt);
135
- }));
108
+ var request_token = this._requestToken(request, mid, isTest, regional);
109
+ request_token.subscribe({
110
+ error: function (err) {
111
+ return Kushki_1.Kushki.callbackError(err, callback);
112
+ },
113
+ next: function (_a) {
114
+ var final_request = _a[0], authorization = _a[1];
115
+ if (final_request.jwt)
116
+ _this._request3DSToken(final_request, mid, isTest, regional, callback, authorization);
117
+ else
118
+ _this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
119
+ }
120
+ });
136
121
  };
137
122
  CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
138
123
  var _this = this;
@@ -236,6 +221,53 @@ var CardService = /** @class */ (function () {
236
221
  jwt: jwt
237
222
  }); }));
238
223
  };
224
+ CardService.prototype._requestToken = function (request, mid, isTest, regional) {
225
+ var _this = this;
226
+ return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap(function (merchant) {
227
+ _this._setSandboxEnable(!!merchant.sandboxEnable);
228
+ return rxjs_1.forkJoin([
229
+ _this._getScienceSession(request, mid, isTest, merchant),
230
+ _this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
231
+ ? request.card.number
232
+ : undefined),
233
+ ]);
234
+ }), operators_1.mergeMap(function (_a) {
235
+ var sift_object = _a[0], jwt = _a[1];
236
+ request.isDeferred =
237
+ request.isDeferred === undefined ? false : request.isDeferred;
238
+ if (Boolean(request.cvv))
239
+ request.card = { cvc: request.cvv };
240
+ _this._checkRequestBody(request);
241
+ var data_to_transform = __assign(__assign({}, request), sift_object);
242
+ if (jwt !== undefined)
243
+ data_to_transform.jwt = jwt;
244
+ return rxjs_1.forkJoin([
245
+ rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
246
+ request.walletId
247
+ ? _this._authService.getAuthorizationToken()
248
+ : rxjs_1.of(undefined),
249
+ ]);
250
+ }));
251
+ };
252
+ CardService.prototype._request3DSToken = function (body, mid, testEnv, regional, callback, authorization) {
253
+ var _this = this;
254
+ return window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
255
+ return __generator(this, function (_a) {
256
+ return [2 /*return*/, this._requestTokenGateway(body, mid, testEnv, regional, callback, authorization)];
257
+ });
258
+ }); });
259
+ };
260
+ CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
261
+ var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
262
+ return request_token.subscribe({
263
+ error: function (err) {
264
+ return Kushki_1.Kushki.callbackError(err, callback);
265
+ },
266
+ next: function (response) {
267
+ callback(response);
268
+ }
269
+ });
270
+ };
239
271
  CardService.prototype._getMerchantSettings = function (mid, isTest, regional) {
240
272
  var _this = this;
241
273
  return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.map(function (merchant) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.30.0",
3
+ "version": "1.30.1-alpha-3ds-setup-complete.1",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",
@@ -18,7 +18,7 @@
18
18
  "scripts": {
19
19
  "publish:latest": "npm run build && npm publish",
20
20
  "publish:alpha": "npm run build && npm publish --tag alpha",
21
- "prepare": "npm run tsc:interface && npm run test:unit && npm run test:coverage && npm run build:npm",
21
+ "prepare": "npm run tsc:interface",
22
22
  "tsc:interface": "kushki json2ts",
23
23
  "tsc:check": "tsc --project tsconfig.check.json --noEmit",
24
24
  "lint": "npm run lint:format && npm run lint:duplicate && npm run lint:check",
@@ -95,10 +95,10 @@
95
95
  "webpack-dev-server": "3.3.1"
96
96
  },
97
97
  "dependencies": {
98
- "@aws-amplify/auth": "3.4.22",
98
+ "@aws-amplify/auth": "4.6.1",
99
99
  "@kushki/cardinal-sandbox-js": "1.0.3",
100
100
  "acorn": "6.4.1",
101
- "aws-amplify": "3.3.19",
101
+ "aws-amplify": "4.3.30",
102
102
  "axios": "0.21.1",
103
103
  "ci": "^2.1.1",
104
104
  "dot-object": "2.1.4",