@kushki/js 1.31.0 → 1.31.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.
- package/lib/gateway/KushkiGateway.d.ts +2 -1
- package/lib/gateway/KushkiGateway.js +5 -3
- package/lib/repository/IKushkiGateway.d.ts +2 -1
- package/lib/service/CardService.d.ts +6 -0
- package/lib/service/CardService.js +49 -21
- package/lib/types/jwt_response.d.ts +1 -0
- package/lib/types/subscriptionId_request.d.ts +0 -1
- package/package.json +2 -2
|
@@ -10,6 +10,7 @@ import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
|
10
10
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
11
11
|
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
12
12
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
13
|
+
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
13
14
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
14
15
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
15
16
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -73,7 +74,7 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
73
74
|
chargeMobileProcessor(body: MobileProcessorChargeRequest, publicCredential: string, testEnv: boolean, regional: boolean): Observable<MobileProcessorChargeResponse>;
|
|
74
75
|
deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
|
|
75
76
|
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
|
|
76
|
-
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<
|
|
77
|
+
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
77
78
|
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
78
79
|
private _assignChannel;
|
|
79
80
|
private _buildHeader;
|
|
@@ -248,11 +248,13 @@ var KushkiGateway = /** @class */ (function () {
|
|
|
248
248
|
return _this.requestGet(path, testEnv, regional, mid);
|
|
249
249
|
}), operators_1.map(function (response) { return response; }));
|
|
250
250
|
};
|
|
251
|
-
KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional) {
|
|
251
|
+
KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional, subscriptionId) {
|
|
252
252
|
var _this = this;
|
|
253
253
|
return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
|
|
254
|
-
return _this.requestGet(
|
|
255
|
-
|
|
254
|
+
return _this.requestGet(subscriptionId
|
|
255
|
+
? PathEnum_1.PathEnum.cybersource_jwt + "?subscriptionId=" + subscriptionId
|
|
256
|
+
: PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
|
|
257
|
+
}), operators_1.map(function (response) { return response; }));
|
|
256
258
|
};
|
|
257
259
|
KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
|
|
258
260
|
var _this = this;
|
|
@@ -11,6 +11,7 @@ import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
|
11
11
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
12
12
|
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
13
13
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
14
|
+
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
14
15
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
15
16
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
16
17
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -161,7 +162,7 @@ export interface IKushkiGateway {
|
|
|
161
162
|
* @param testEnv - is test environment
|
|
162
163
|
* @param regional - Define if endpoint used regional URL
|
|
163
164
|
*/
|
|
164
|
-
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<
|
|
165
|
+
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
165
166
|
/**
|
|
166
167
|
* Get userId
|
|
167
168
|
* @param subscriptionId subscription id for the request
|
|
@@ -47,6 +47,7 @@ export declare class CardService implements ICardService {
|
|
|
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 _getCreateSubscriptionDataToTransform;
|
|
50
51
|
private _request3DSToken;
|
|
51
52
|
private _setupCompleteCardinal;
|
|
52
53
|
private _requestTokenGateway;
|
|
@@ -61,7 +62,12 @@ export declare class CardService implements ICardService {
|
|
|
61
62
|
private _checkAmount;
|
|
62
63
|
private _checkRequestBody;
|
|
63
64
|
private _getCybersourceJwt;
|
|
65
|
+
private _isSandboxEnabled;
|
|
66
|
+
private _getCybersourceJwtSubscription;
|
|
67
|
+
private _is3DSSecureEnabled;
|
|
64
68
|
private _initCybersource;
|
|
69
|
+
private _initializeCardinal;
|
|
70
|
+
private _initCybersourceSubscription;
|
|
65
71
|
private _completeCardinal;
|
|
66
72
|
private static _initCardinal;
|
|
67
73
|
private static _ccaCardinal;
|
|
@@ -157,9 +157,7 @@ var CardService = /** @class */ (function () {
|
|
|
157
157
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
158
158
|
return rxjs_1.forkJoin([
|
|
159
159
|
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
|
|
160
|
-
_this.
|
|
161
|
-
? request.cardNumber
|
|
162
|
-
: undefined),
|
|
160
|
+
_this._getCybersourceJwtSubscription(merchant, mid, isTest, regional, request.subscriptionId),
|
|
163
161
|
]);
|
|
164
162
|
}), operators_1.switchMap(function (_a) {
|
|
165
163
|
var sift_science_obj = _a[0], jwt = _a[1];
|
|
@@ -183,9 +181,7 @@ var CardService = /** @class */ (function () {
|
|
|
183
181
|
}), operators_1.concatMap(function (_a) {
|
|
184
182
|
var sift_object = _a[0], jwt = _a[1];
|
|
185
183
|
_this._checkRequestBody(subscriptionTokenRequest);
|
|
186
|
-
var data_to_transform =
|
|
187
|
-
if (sift_object.userId === null || sift_object.sessionId === null)
|
|
188
|
-
data_to_transform.siftObject = __assign({}, sift_object);
|
|
184
|
+
var data_to_transform = _this._getCreateSubscriptionDataToTransform(sift_object, subscriptionTokenRequest);
|
|
189
185
|
if (jwt !== undefined)
|
|
190
186
|
data_to_transform.jwt = jwt;
|
|
191
187
|
return rxjs_1.forkJoin([
|
|
@@ -243,13 +239,18 @@ var CardService = /** @class */ (function () {
|
|
|
243
239
|
CardService.prototype.requestSecureInit = function (request, mid, isTest, regional) {
|
|
244
240
|
var _this = this;
|
|
245
241
|
return rxjs_1.of(1).pipe(operators_1.map(function () { return _this._checkCardLength(request, ErrorEnum_1.ErrorCode.E014); }), operators_1.switchMap(function () { return _this._getMerchantSettings(mid, isTest, regional); }), operators_1.switchMap(function (merchantSettings) {
|
|
246
|
-
return rxjs_1.iif(function () { return
|
|
242
|
+
return rxjs_1.iif(function () { return _this._is3DSSecureEnabled(merchantSettings); }, rxjs_1.of(merchantSettings), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013)));
|
|
247
243
|
}), operators_1.switchMap(function (merchant) {
|
|
248
244
|
return _this._getCybersourceJwt(merchant, mid, isTest, regional, request.card.number);
|
|
249
245
|
}), operators_1.map(function (jwt) { return ({
|
|
250
246
|
jwt: jwt
|
|
251
247
|
}); }));
|
|
252
248
|
};
|
|
249
|
+
CardService.prototype._getCreateSubscriptionDataToTransform = function (siftObject, subscriptionTokenRequest) {
|
|
250
|
+
if (siftObject.userId === null || siftObject.sessionId === null)
|
|
251
|
+
return __assign({}, subscriptionTokenRequest);
|
|
252
|
+
return __assign(__assign({}, subscriptionTokenRequest), siftObject);
|
|
253
|
+
};
|
|
253
254
|
CardService.prototype._request3DSToken = function (body, mid, isTest, regional, callback, authorization) {
|
|
254
255
|
var _this = this;
|
|
255
256
|
if (isTest)
|
|
@@ -352,24 +353,51 @@ var CardService = /** @class */ (function () {
|
|
|
352
353
|
CardService.prototype._getCybersourceJwt = function (merchantSettings, mid, isTest, regional, cardNumber) {
|
|
353
354
|
var _this = this;
|
|
354
355
|
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
355
|
-
if (
|
|
356
|
+
if (_this._is3DSSecureEnabled(merchantSettings) &&
|
|
356
357
|
cardNumber !== undefined)
|
|
357
|
-
return rxjs_1.iif(function () { return
|
|
358
|
+
return rxjs_1.iif(function () { return _this._isSandboxEnabled(merchantSettings); }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersource(cardNumber, mid, isTest, regional));
|
|
359
|
+
return rxjs_1.of(undefined);
|
|
360
|
+
}));
|
|
361
|
+
};
|
|
362
|
+
CardService.prototype._isSandboxEnabled = function (merchantSettings) {
|
|
363
|
+
return !!merchantSettings.sandboxEnable;
|
|
364
|
+
};
|
|
365
|
+
CardService.prototype._getCybersourceJwtSubscription = function (merchantSettings, mid, isTest, regional, subscriptionId) {
|
|
366
|
+
var _this = this;
|
|
367
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
368
|
+
if (_this._is3DSSecureEnabled(merchantSettings))
|
|
369
|
+
return rxjs_1.iif(function () { return _this._isSandboxEnabled(merchantSettings); }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersourceSubscription(subscriptionId, mid, isTest, regional));
|
|
358
370
|
return rxjs_1.of(undefined);
|
|
359
371
|
}));
|
|
360
372
|
};
|
|
373
|
+
CardService.prototype._is3DSSecureEnabled = function (merchantSettings) {
|
|
374
|
+
return merchantSettings[this._3Dsecure] === true;
|
|
375
|
+
};
|
|
361
376
|
CardService.prototype._initCybersource = function (cardNumber, mid, isTest, regional) {
|
|
362
377
|
var _this = this;
|
|
363
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
378
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
379
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, cardNumber);
|
|
380
|
+
return jwtResponse.jwt;
|
|
381
|
+
}));
|
|
382
|
+
};
|
|
383
|
+
CardService.prototype._initializeCardinal = function (isTest, jwt, identifier) {
|
|
384
|
+
if (isTest)
|
|
385
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
386
|
+
CardService_1._initCardinal(jwt, identifier);
|
|
387
|
+
});
|
|
388
|
+
else
|
|
389
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
390
|
+
CardService_1._initCardinal(jwt, identifier);
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
CardService.prototype._initCybersourceSubscription = function (subscriptionId, mid, isTest, regional) {
|
|
394
|
+
var _this = this;
|
|
395
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
396
|
+
return _this._gateway.cybersourceJwt(mid, isTest, regional, subscriptionId);
|
|
397
|
+
}), operators_1.map(function (jwtResponse) {
|
|
398
|
+
var bin = Buffer.from(jwtResponse.identifier, "base64").toString("ascii");
|
|
399
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, bin);
|
|
400
|
+
return jwtResponse.jwt;
|
|
373
401
|
}));
|
|
374
402
|
};
|
|
375
403
|
// istanbul ignore next
|
|
@@ -431,9 +459,9 @@ var CardService = /** @class */ (function () {
|
|
|
431
459
|
};
|
|
432
460
|
CardService.prototype._initCybersourceSandbox = function (mid, isTest, regional) {
|
|
433
461
|
var _this = this;
|
|
434
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
462
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
435
463
|
cardinal_sandbox_js_1.KushkiCardinalSandbox.init();
|
|
436
|
-
return jwt;
|
|
464
|
+
return jwtResponse.jwt;
|
|
437
465
|
}));
|
|
438
466
|
};
|
|
439
467
|
CardService.prototype._ccaSandbox = function (body, mid, isTest, regional, callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kushki/js",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.3",
|
|
4
4
|
"description": "kushki-js",
|
|
5
5
|
"main": "lib/lib.js",
|
|
6
6
|
"types": "lib/lib.d.ts",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@aws-amplify/auth": "4.6.1",
|
|
99
|
-
"@kushki/cardinal-sandbox-js": "1.0.
|
|
99
|
+
"@kushki/cardinal-sandbox-js": "1.0.4",
|
|
100
100
|
"acorn": "6.4.1",
|
|
101
101
|
"aws-amplify": "4.3.30",
|
|
102
102
|
"axios": "0.21.1",
|