@kushki/js 1.28.1 → 1.29.0-alpha.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.d.ts +3 -0
- package/lib/Kushki.js +4 -0
- package/lib/constant/Identifiers.d.ts +1 -0
- package/lib/constant/Identifiers.js +1 -0
- package/lib/gateway/SiftScience.d.ts +4 -0
- package/lib/gateway/SiftScience.js +34 -10
- package/lib/infrastructure/Container.js +4 -0
- package/lib/infrastructure/ErrorEnum.d.ts +2 -1
- package/lib/infrastructure/ErrorEnum.js +6 -0
- package/lib/repository/IAntiFraud.d.ts +2 -0
- package/lib/repository/ISiftScienceService.d.ts +16 -0
- package/lib/repository/ISiftScienceService.js +2 -0
- package/lib/service/SiftScienceService.d.ts +16 -0
- package/lib/service/SiftScienceService.js +47 -0
- package/lib/types/sift_science_session.d.ts +6 -0
- package/package.json +1 -1
package/lib/Kushki.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { ResponseStatusValidator } from "./../lib/types/response_status_validato
|
|
|
32
32
|
import { SavedPaymentMethodRequest } from "./../lib/types/saved_payment_data_request";
|
|
33
33
|
import { SecureOtpRequest } from "./../lib/types/secure_otp_request";
|
|
34
34
|
import { SecureOtpResponse } from "./../lib/types/secure_otp_response";
|
|
35
|
+
import { SiftScienceAntiFraudSessionResponse } from "./../lib/types/sift_science_session";
|
|
35
36
|
import { SubscriptionCardAsyncTokenRequest } from "./../lib/types/subscription_card_async_token_request";
|
|
36
37
|
import { SubscriptionCardAsyncTokenResponse } from "./../lib/types/subscription_card_async_token_response";
|
|
37
38
|
import { SubscriptionTokenKPayRequest } from "./../lib/types/subscription_token_kpay_request";
|
|
@@ -68,12 +69,14 @@ export declare class Kushki {
|
|
|
68
69
|
private readonly _authService;
|
|
69
70
|
private readonly _cardDynamicService;
|
|
70
71
|
private readonly _cardSubscriptionDynamicService;
|
|
72
|
+
private readonly _siftScience;
|
|
71
73
|
constructor(body: {
|
|
72
74
|
merchantId: string;
|
|
73
75
|
inTestEnvironment?: boolean;
|
|
74
76
|
regional?: boolean;
|
|
75
77
|
});
|
|
76
78
|
requestToken(body: TokenRequest | TokenKPayRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
79
|
+
requestInitAntiFraud(userId: string, callback: (value: SiftScienceAntiFraudSessionResponse | ErrorResponse) => void): void;
|
|
77
80
|
/**
|
|
78
81
|
* @deprecated use requestDeviceToken instead
|
|
79
82
|
* @param {Function} body with value
|
package/lib/Kushki.js
CHANGED
|
@@ -19,6 +19,7 @@ var Kushki = /** @class */ (function () {
|
|
|
19
19
|
this._inTestEnvironment = body.inTestEnvironment;
|
|
20
20
|
this._regional = body.regional;
|
|
21
21
|
this._cardService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardService)(this._regional);
|
|
22
|
+
this._siftScience = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.SiftScienceService)(this._regional);
|
|
22
23
|
this._transferService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.TransferService)(this._regional);
|
|
23
24
|
this._cashService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CashService)(this._regional);
|
|
24
25
|
this._multiMerchantInfoService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.MultiMerchantService)(this._regional);
|
|
@@ -38,6 +39,9 @@ var Kushki = /** @class */ (function () {
|
|
|
38
39
|
Kushki.prototype.requestToken = function (body, callback) {
|
|
39
40
|
this._resolve(this._cardService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
40
41
|
};
|
|
42
|
+
Kushki.prototype.requestInitAntiFraud = function (userId, callback) {
|
|
43
|
+
this._resolve(this._siftScience.requestInitAntiFraud(userId, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
44
|
+
};
|
|
41
45
|
/**
|
|
42
46
|
* @deprecated use requestDeviceToken instead
|
|
43
47
|
* @param {Function} body with value
|
|
@@ -21,6 +21,7 @@ var IDENTIFIERS = {
|
|
|
21
21
|
PayoutsCashService: Symbol["for"]("PayoutsCashService"),
|
|
22
22
|
PayoutsTransferService: Symbol["for"]("PayoutsTransferService"),
|
|
23
23
|
SecureService: Symbol["for"]("SecureService"),
|
|
24
|
+
SiftScienceService: Symbol["for"]("SiftScienceService"),
|
|
24
25
|
TransferService: Symbol["for"]("TransferService"),
|
|
25
26
|
TransferSubscriptionService: Symbol["for"]("TransferSubscriptionsService")
|
|
26
27
|
};
|
|
@@ -7,6 +7,7 @@ import { IAntiFraud } from "./../../lib/repository/IAntiFraud";
|
|
|
7
7
|
import { Observable } from "rxjs";
|
|
8
8
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
9
9
|
import { SiftScienceObject } from "./../../lib/types/sift_science_object";
|
|
10
|
+
import { SiftScienceAntiFraudSessionResponse } from "./../../lib/types/sift_science_session";
|
|
10
11
|
/**
|
|
11
12
|
* Kushki SiftScience Implementation
|
|
12
13
|
*/
|
|
@@ -15,5 +16,8 @@ export declare class SiftScience implements IAntiFraud {
|
|
|
15
16
|
private _sift;
|
|
16
17
|
constructor(regional: boolean);
|
|
17
18
|
createSiftScienceSession(processor: string, clientIdentification: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse, userId?: string): Observable<SiftScienceObject>;
|
|
19
|
+
createSiftScienceAntiFraudSession(userId: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse): Observable<SiftScienceAntiFraudSessionResponse>;
|
|
20
|
+
private _validateMerchantSettings;
|
|
21
|
+
private _setSiftProperties;
|
|
18
22
|
private _initSiftScience;
|
|
19
23
|
}
|
|
@@ -13,6 +13,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
13
13
|
};
|
|
14
14
|
exports.__esModule = true;
|
|
15
15
|
exports.SiftScience = void 0;
|
|
16
|
+
var KushkiError_1 = require("./../../lib/generic/KushkiError");
|
|
17
|
+
var ErrorEnum_1 = require("./../../lib/infrastructure/ErrorEnum");
|
|
16
18
|
var SiftScienceEnum_1 = require("./../../lib/infrastructure/SiftScienceEnum");
|
|
17
19
|
var inversify_1 = require("inversify");
|
|
18
20
|
require("reflect-metadata");
|
|
@@ -35,28 +37,50 @@ var SiftScience = /** @class */ (function () {
|
|
|
35
37
|
var sift_environment = isTest
|
|
36
38
|
? SiftScienceEnum_1.SiftScienceEnum.siftScienceTest
|
|
37
39
|
: SiftScienceEnum_1.SiftScienceEnum.siftScienceProd;
|
|
38
|
-
if (
|
|
39
|
-
merchantSettings[sift_environment] === null)
|
|
40
|
+
if (_this._validateMerchantSettings(sift_environment, merchantSettings))
|
|
40
41
|
return {
|
|
41
42
|
sessionId: null,
|
|
42
43
|
userId: null
|
|
43
44
|
};
|
|
44
45
|
var user_id = userId || "" + mid + processor + clientIdentification;
|
|
45
46
|
var session_id = uuid_1.v4();
|
|
46
|
-
_this.
|
|
47
|
-
window[_this._siftProperty] === undefined
|
|
48
|
-
? []
|
|
49
|
-
: window[_this._siftProperty];
|
|
50
|
-
_this._sift.push(["_setAccount", merchantSettings[sift_environment]]);
|
|
51
|
-
_this._sift.push(["_setUserId", user_id]);
|
|
52
|
-
_this._sift.push(["_setSessionId", session_id]);
|
|
53
|
-
_this._sift.push(["_trackPageview"]);
|
|
47
|
+
_this._setSiftProperties(merchantSettings, sift_environment, user_id, session_id);
|
|
54
48
|
return {
|
|
55
49
|
sessionId: session_id,
|
|
56
50
|
userId: user_id
|
|
57
51
|
};
|
|
58
52
|
}));
|
|
59
53
|
};
|
|
54
|
+
SiftScience.prototype.createSiftScienceAntiFraudSession = function (userId, mid, isTest, merchantSettingsResponse) {
|
|
55
|
+
var _this = this;
|
|
56
|
+
return rxjs_1.of(merchantSettingsResponse).pipe(operators_1.map(function (merchantSettings) {
|
|
57
|
+
var sift_environment = isTest
|
|
58
|
+
? SiftScienceEnum_1.SiftScienceEnum.siftScienceTest
|
|
59
|
+
: SiftScienceEnum_1.SiftScienceEnum.siftScienceProd;
|
|
60
|
+
if (_this._validateMerchantSettings(sift_environment, merchantSettings))
|
|
61
|
+
throw new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013);
|
|
62
|
+
var user_id = "" + userId + mid;
|
|
63
|
+
var session_id = uuid_1.v4();
|
|
64
|
+
_this._setSiftProperties(merchantSettings, sift_environment, user_id, session_id);
|
|
65
|
+
return {
|
|
66
|
+
sessionId: session_id
|
|
67
|
+
};
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
SiftScience.prototype._validateMerchantSettings = function (siftEnvironment, merchantSettings) {
|
|
71
|
+
return (merchantSettings[siftEnvironment] === "" ||
|
|
72
|
+
merchantSettings[siftEnvironment] === null);
|
|
73
|
+
};
|
|
74
|
+
SiftScience.prototype._setSiftProperties = function (merchantSettings, siftEnvironment, userId, sessionId) {
|
|
75
|
+
this._sift =
|
|
76
|
+
window[this._siftProperty] === undefined
|
|
77
|
+
? []
|
|
78
|
+
: window[this._siftProperty];
|
|
79
|
+
this._sift.push(["_setAccount", merchantSettings[siftEnvironment]]);
|
|
80
|
+
this._sift.push(["_setUserId", userId]);
|
|
81
|
+
this._sift.push(["_setSessionId", sessionId]);
|
|
82
|
+
this._sift.push(["_trackPageview"]);
|
|
83
|
+
};
|
|
60
84
|
SiftScience.prototype._initSiftScience = function (regional) {
|
|
61
85
|
try {
|
|
62
86
|
if (!UtilsService_1.UtilsService.sIsEmpty(window)) {
|
|
@@ -22,6 +22,7 @@ var MultiMerchantService_1 = require("./../../lib/service/MultiMerchantService")
|
|
|
22
22
|
var PayoutsCashService_1 = require("./../../lib/service/PayoutsCashService");
|
|
23
23
|
var PayoutsTransferService_1 = require("./../../lib/service/PayoutsTransferService");
|
|
24
24
|
var SecureService_1 = require("./../../lib/service/SecureService");
|
|
25
|
+
var SiftScienceService_1 = require("./../../lib/service/SiftScienceService");
|
|
25
26
|
var TransferService_1 = require("./../../lib/service/TransferService");
|
|
26
27
|
var TransferSubscriptionsService_1 = require("./../../lib/service/TransferSubscriptionsService");
|
|
27
28
|
var CONTAINER = new inversify_1.Container();
|
|
@@ -75,6 +76,9 @@ CONTAINER.bind(Identifiers_1.IDENTIFIERS.PayoutsTransferService).toFactory(funct
|
|
|
75
76
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.KPayService).toFactory(function (context) { return function (regional) {
|
|
76
77
|
return new KPayService_1.KPayService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AuthService)(regional));
|
|
77
78
|
}; });
|
|
79
|
+
CONTAINER.bind(Identifiers_1.IDENTIFIERS.SiftScienceService).toFactory(function (context) { return function (regional) {
|
|
80
|
+
return new SiftScienceService_1.SiftScienceService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional));
|
|
81
|
+
}; });
|
|
78
82
|
// Gateway
|
|
79
83
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.KushkiGateway).to(KushkiGateway_1.KushkiGateway);
|
|
80
84
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.AntiFraud).toFactory(function () { return function (regional) { return new SiftScience_1.SiftScience(regional); }; });
|
|
@@ -17,6 +17,7 @@ var ErrorCode;
|
|
|
17
17
|
ErrorCode["E010"] = "E010";
|
|
18
18
|
ErrorCode["E011"] = "E011";
|
|
19
19
|
ErrorCode["E012"] = "E012";
|
|
20
|
+
ErrorCode["E013"] = "E013";
|
|
20
21
|
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
|
21
22
|
exports.ERRORS = (_a = {},
|
|
22
23
|
_a[ErrorCode.E001] = {
|
|
@@ -79,4 +80,9 @@ exports.ERRORS = (_a = {},
|
|
|
79
80
|
message: "Campos 3DS inválidos",
|
|
80
81
|
statusCode: StatusCodeEnum_1.StatusCodeEnum.BadRequest
|
|
81
82
|
},
|
|
83
|
+
_a[ErrorCode.E013] = {
|
|
84
|
+
code: ErrorCode.E013,
|
|
85
|
+
message: "Configuración de credenciales Sift inválidas",
|
|
86
|
+
statusCode: StatusCodeEnum_1.StatusCodeEnum.BadRequest
|
|
87
|
+
},
|
|
82
88
|
_a);
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
import { Observable } from "rxjs";
|
|
6
6
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
7
7
|
import { SiftScienceObject } from "./../../lib/types/sift_science_object";
|
|
8
|
+
import { SiftScienceAntiFraudSessionResponse } from "./../../lib/types/sift_science_session";
|
|
8
9
|
export interface IAntiFraud {
|
|
9
10
|
/**
|
|
10
11
|
* create anti-fraud identification
|
|
11
12
|
*/
|
|
12
13
|
createSiftScienceSession(processor: string, clientIdentification: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse, userId?: string): Observable<SiftScienceObject>;
|
|
14
|
+
createSiftScienceAntiFraudSession(userId: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse): Observable<SiftScienceAntiFraudSessionResponse>;
|
|
13
15
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* tslint:disable:all */
|
|
2
|
+
/**
|
|
3
|
+
* Interface Sift Science Service file.
|
|
4
|
+
*/
|
|
5
|
+
import { Observable } from "rxjs";
|
|
6
|
+
import { SiftScienceAntiFraudSessionResponse } from "./../../lib/types/sift_science_session";
|
|
7
|
+
export interface ISiftScienceService {
|
|
8
|
+
/**
|
|
9
|
+
* Sift Science session id
|
|
10
|
+
* @param userId - id user
|
|
11
|
+
* @param mid - public merchant id
|
|
12
|
+
* @param isTest - is test environment
|
|
13
|
+
* @param regional - Define if endpoint used regional URL
|
|
14
|
+
*/
|
|
15
|
+
requestInitAntiFraud(userId: string, mid: string, isTest: boolean, regional: boolean): Observable<SiftScienceAntiFraudSessionResponse>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* tslint:disable:all */
|
|
2
|
+
import "reflect-metadata";
|
|
3
|
+
import { IAntiFraud } from "./../../lib/repository/IAntiFraud";
|
|
4
|
+
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
5
|
+
import { ISiftScienceService } from "./../../lib/repository/ISiftScienceService";
|
|
6
|
+
import { Observable } from "rxjs";
|
|
7
|
+
import { SiftScienceAntiFraudSessionResponse } from "./../../lib/types/sift_science_session";
|
|
8
|
+
/**
|
|
9
|
+
* Implementation
|
|
10
|
+
*/
|
|
11
|
+
export declare class SiftScienceService implements ISiftScienceService {
|
|
12
|
+
private readonly _gateway;
|
|
13
|
+
private readonly _antiFraud;
|
|
14
|
+
constructor(gateway: IKushkiGateway, antiFraud: IAntiFraud);
|
|
15
|
+
requestInitAntiFraud(userId: string, mid: string, isTest: boolean, regional: boolean): Observable<SiftScienceAntiFraudSessionResponse>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
exports.__esModule = true;
|
|
15
|
+
exports.SiftScienceService = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* SiftScience Service file
|
|
18
|
+
*/
|
|
19
|
+
var Identifiers_1 = require("./../../lib/constant/Identifiers");
|
|
20
|
+
var inversify_1 = require("inversify");
|
|
21
|
+
require("reflect-metadata");
|
|
22
|
+
var operators_1 = require("rxjs/operators");
|
|
23
|
+
/**
|
|
24
|
+
* Implementation
|
|
25
|
+
*/
|
|
26
|
+
var SiftScienceService = /** @class */ (function () {
|
|
27
|
+
function SiftScienceService(gateway, antiFraud) {
|
|
28
|
+
this._gateway = gateway;
|
|
29
|
+
this._antiFraud = antiFraud;
|
|
30
|
+
}
|
|
31
|
+
SiftScienceService.prototype.requestInitAntiFraud = function (userId, mid, isTest, regional) {
|
|
32
|
+
var _this = this;
|
|
33
|
+
return this._gateway
|
|
34
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
35
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
36
|
+
return _this._antiFraud.createSiftScienceAntiFraudSession(userId, mid, isTest, merchant);
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
SiftScienceService = __decorate([
|
|
40
|
+
inversify_1.injectable(),
|
|
41
|
+
__param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
|
|
42
|
+
__param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.AntiFraud)),
|
|
43
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
44
|
+
], SiftScienceService);
|
|
45
|
+
return SiftScienceService;
|
|
46
|
+
}());
|
|
47
|
+
exports.SiftScienceService = SiftScienceService;
|