@kushki/js 1.40.1-alpha.14317.3 → 1.40.2-alpha

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 (67) hide show
  1. package/README.md +1 -0
  2. package/lib/Kushki.d.ts +119 -23
  3. package/lib/Kushki.js +119 -20
  4. package/lib/KushkiInfo.js +3 -2
  5. package/lib/constant/Identifiers.d.ts +1 -3
  6. package/lib/constant/Identifiers.js +1 -3
  7. package/lib/gateway/KushkiGateway.d.ts +9 -14
  8. package/lib/gateway/KushkiGateway.js +19 -39
  9. package/lib/gateway/SiftScience.d.ts +1 -0
  10. package/lib/gateway/SiftScience.js +5 -0
  11. package/lib/infrastructure/CardBrandsEnum.d.ts +2 -1
  12. package/lib/infrastructure/CardBrandsEnum.js +1 -0
  13. package/lib/infrastructure/CardinalValidated.d.ts +10 -0
  14. package/lib/infrastructure/CardinalValidated.js +8 -0
  15. package/lib/infrastructure/Container.js +3 -7
  16. package/lib/infrastructure/EnvironmentEnum.d.ts +1 -1
  17. package/lib/infrastructure/EnvironmentEnum.js +1 -1
  18. package/lib/infrastructure/ErrorEnum.d.ts +4 -1
  19. package/lib/infrastructure/ErrorEnum.js +19 -1
  20. package/lib/infrastructure/PathEnum.d.ts +4 -6
  21. package/lib/infrastructure/PathEnum.js +3 -5
  22. package/lib/repository/IApplePayService.d.ts +40 -0
  23. package/lib/repository/ICardService.d.ts +3 -5
  24. package/lib/repository/IKushkiGateway.d.ts +23 -36
  25. package/lib/service/ApplePayService.d.ts +36 -0
  26. package/lib/service/ApplePayService.js +189 -0
  27. package/lib/service/CardService.d.ts +8 -9
  28. package/lib/service/CardService.js +103 -112
  29. package/lib/types/apple_pay_get_token_events.d.ts +46 -0
  30. package/lib/types/apple_pay_get_token_options.d.ts +12 -0
  31. package/lib/types/apple_pay_options.d.ts +25 -0
  32. package/lib/types/apple_pay_start_session_request.d.ts +8 -0
  33. package/lib/types/kushki_subscription_tokens_request.d.ts +0 -10
  34. package/lib/types/subscription_token_request.d.ts +0 -10
  35. package/package.json +5 -6
  36. package/lib/infrastructure/KPayUserPoolEnum.d.ts +0 -5
  37. package/lib/infrastructure/KPayUserPoolEnum.js +0 -8
  38. package/lib/infrastructure/KpayPaymentKind.d.ts +0 -6
  39. package/lib/infrastructure/KpayPaymentKind.js +0 -9
  40. package/lib/repository/IAuthService.d.ts +0 -20
  41. package/lib/repository/IKPayService.d.ts +0 -26
  42. package/lib/repository/IKPayService.js +0 -2
  43. package/lib/repository/IMobileProcessorService.d.ts +0 -16
  44. package/lib/repository/IMobileProcessorService.js +0 -2
  45. package/lib/service/AuthService.d.ts +0 -31
  46. package/lib/service/AuthService.js +0 -161
  47. package/lib/service/KPayService.d.ts +0 -19
  48. package/lib/service/KPayService.js +0 -45
  49. package/lib/service/MobileProcessorService.d.ts +0 -35
  50. package/lib/service/MobileProcessorService.js +0 -126
  51. package/lib/types/delete_payment_method_request.d.ts +0 -6
  52. package/lib/types/delete_payment_method_response.d.ts +0 -7
  53. package/lib/types/init_auth_request.d.ts +0 -6
  54. package/lib/types/init_auth_response.d.ts +0 -6
  55. package/lib/types/mobile_processor_charge_request.d.ts +0 -13
  56. package/lib/types/mobile_processor_charge_response.d.ts +0 -7
  57. package/lib/types/mobile_processor_token.d.ts +0 -66
  58. package/lib/types/mobile_processor_token_request.d.ts +0 -11
  59. package/lib/types/mobile_processor_token_response.d.ts +0 -15
  60. package/lib/types/payment_data_response.d.ts +0 -37
  61. package/lib/types/saved_payment_data_request.d.ts +0 -10
  62. package/lib/types/subscription_token_kpay_request.d.ts +0 -13
  63. package/lib/types/token_kpay_request.d.ts +0 -12
  64. package/lib/types/validate_session_response.d.ts +0 -6
  65. package/lib/types/verify_auth_request.d.ts +0 -7
  66. package/lib/types/verify_auth_response.d.ts +0 -7
  67. /package/lib/repository/{IAuthService.js → IApplePayService.js} +0 -0
@@ -0,0 +1,46 @@
1
+ /* tslint:disable:all */
2
+ /* tslint:disable:all */
3
+
4
+ export interface ApplePaymentEvent {
5
+ payment: {
6
+ billingContact?: ApplePayPaymentContact;
7
+ shippingContact?: ApplePayPaymentContact;
8
+ token: {
9
+ paymentData: ApplePayGetTokenRequest;
10
+ };
11
+ };
12
+ validationURL: string;
13
+ appleTokenResponse?: AppleTokenResponse;
14
+ }
15
+ export interface ApplePayPaymentContact {
16
+ phoneNumber: string;
17
+ emailAddress: string;
18
+ givenName: string;
19
+ familyName: string;
20
+ phoneticGivenName: string;
21
+ phoneticFamilyName: string;
22
+ subLocality: string;
23
+ locality: string;
24
+ postalCode: string;
25
+ subAdministrativeArea: string;
26
+ administrativeArea: string;
27
+ country: string;
28
+ countryCode: string;
29
+ addressLines: string[];
30
+ }
31
+ export interface ApplePayGetTokenRequest {
32
+ data: string;
33
+ header: {
34
+ ephemeralPublicKey: string;
35
+ publicKeyHash: string;
36
+ transactionId: string;
37
+ [k: string]: any;
38
+ };
39
+ signature: string;
40
+ version: string;
41
+ }
42
+ export interface AppleTokenResponse {
43
+ token: string;
44
+ billingContact?: ApplePayPaymentContact;
45
+ shippingContact?: ApplePayPaymentContact;
46
+ }
@@ -0,0 +1,12 @@
1
+ /* tslint:disable:all */
2
+ /* tslint:disable:all */
3
+
4
+ export interface ApplePayGetTokenOptions {
5
+ countryCode: "BR" | "CL" | "CO" | "CR" | "EC" | "SV" | "GT" | "HN" | "MX" | "NI" | "PA" | "PE";
6
+ currencyCode: "USD" | "COP" | "CLP" | "UF" | "PEN" | "MXN" | "BRL" | "CRC" | "GTQ" | "HNL" | "NIO";
7
+ displayName: string;
8
+ amount: number;
9
+ optionalApplePayFields?: {
10
+ [k: string]: any;
11
+ };
12
+ }
@@ -0,0 +1,25 @@
1
+ /* tslint:disable:all */
2
+ /* tslint:disable:all */
3
+
4
+ export interface ApplePayOptions {
5
+ style: "black" | "white";
6
+ locale: "en-US" | "es-ES" | "es-MX" | "pt-BR";
7
+ type:
8
+ | "add-money"
9
+ | "book"
10
+ | "buy"
11
+ | "check-out"
12
+ | "continue"
13
+ | "contribute"
14
+ | "donate"
15
+ | "order"
16
+ | "pay"
17
+ | "plain"
18
+ | "reload"
19
+ | "rent"
20
+ | "set-up"
21
+ | "subscribe"
22
+ | "support"
23
+ | "tip"
24
+ | "top-up";
25
+ }
@@ -0,0 +1,8 @@
1
+ /* tslint:disable:all */
2
+ /* tslint:disable:all */
3
+
4
+ export interface ApplePayStartSessionRequest {
5
+ validationURL: string;
6
+ displayName: string;
7
+ clientDomain: string;
8
+ }
@@ -14,15 +14,5 @@ export interface KushkiSubscriptionTokensRequest {
14
14
  userId?: string;
15
15
  sessionId?: string;
16
16
  savePaymentData?: boolean;
17
- contactDetails?: {
18
- firstName?: string;
19
- lastName?: string;
20
- secondLastName?: string;
21
- email?: string;
22
- phoneNumber?: string;
23
- documentType?: string;
24
- documentNumber?: string;
25
- [k: string]: any;
26
- };
27
17
  [k: string]: any;
28
18
  }
@@ -13,15 +13,5 @@ export interface SubscriptionTokenRequest {
13
13
  currency?: "USD" | "COP" | "PEN" | "CLP" | "UF" | "MXN" | "CRC" | "GTQ" | "HNL" | "NIO" | "BRL";
14
14
  savePaymentData?: boolean;
15
15
  emailRequest?: string;
16
- contactDetails?: {
17
- firstName?: string;
18
- lastName?: string;
19
- secondLastName?: string;
20
- email?: string;
21
- phoneNumber?: string;
22
- documentType?: string;
23
- documentNumber?: string;
24
- [k: string]: any;
25
- };
26
16
  [k: string]: any;
27
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.40.1-alpha.14317.3",
3
+ "version": "1.40.2-alpha",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",
@@ -36,7 +36,7 @@
36
36
  "build:cdn": "webpack --optimize-minimize",
37
37
  "build:npm": "npm run tsc:interface && gulp",
38
38
  "postinstall": "echo postinstall",
39
- "depcheck": "depcheck . --ignores=\"serverless-*,@types/*,@kushki/*,rollbar,aws-lambda,prettier,chai,husky,express,lint-staged,ajv,ts-loader,tslint-config-prettier,infrastructure,constant,middleware,core,gateway,service,error,moment-timezone,moment,faker, numeral,dot-object,@aws-amplify/auth \""
39
+ "depcheck": "depcheck . --ignores=\"serverless-*,@types/*,@kushki/*,rollbar,aws-lambda,prettier,chai,husky,express,lint-staged,ajv,ts-loader,tslint-config-prettier,infrastructure,constant,middleware,core,gateway,service,error,moment-timezone,moment,faker, numeral,dot-object\""
40
40
  },
41
41
  "devDependencies": {
42
42
  "@kushki/cli": "1.4.1",
@@ -80,7 +80,7 @@
80
80
  "snyk": "1.303.1",
81
81
  "source-map-loader": "0.2.4",
82
82
  "source-map-support": "0.5.12",
83
- "string-replace-loader": "^3.1.0",
83
+ "string-replace-loader": "3.1.0",
84
84
  "terser-webpack-plugin": "^4.2.3",
85
85
  "thread-loader": "2.1.3",
86
86
  "ts-loader": "5.4.3",
@@ -97,11 +97,10 @@
97
97
  "webpack-dev-server": "3.3.1"
98
98
  },
99
99
  "dependencies": {
100
- "@aws-amplify/auth": "4.6.1",
101
- "@kushki/cardinal-sandbox-js": "1.0.4",
100
+ "@kushki/cardinal-sandbox-js": "1.0.6",
102
101
  "acorn": "6.4.1",
103
- "aws-amplify": "4.3.30",
104
102
  "axios": "0.21.3",
103
+ "buffer": "^6.0.3",
105
104
  "ci": "^2.1.1",
106
105
  "dot-object": "2.1.4",
107
106
  "inversify": "5.0.1",
@@ -1,5 +0,0 @@
1
- /* tslint:disable:all */
2
- export declare enum KPayUserPoolEnum {
3
- uat = "https://kushki-static-dev.s3.amazonaws.com/kpay/kpay_user_pool_dev.json",
4
- prod = "https://kushki-static.s3.amazonaws.com/kpay/kpay_user_pool_prod.json"
5
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KPayUserPoolEnum = void 0;
4
- var KPayUserPoolEnum;
5
- (function (KPayUserPoolEnum) {
6
- KPayUserPoolEnum["uat"] = "https://kushki-static-dev.s3.amazonaws.com/kpay/kpay_user_pool_dev.json";
7
- KPayUserPoolEnum["prod"] = "https://kushki-static.s3.amazonaws.com/kpay/kpay_user_pool_prod.json";
8
- })(KPayUserPoolEnum = exports.KPayUserPoolEnum || (exports.KPayUserPoolEnum = {}));
@@ -1,6 +0,0 @@
1
- /* tslint:disable:all */
2
- export declare enum KpayPaymentKind {
3
- CARD = "card",
4
- TRANSFER = "transfer",
5
- CASH = "cash"
6
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KpayPaymentKind = void 0;
4
- var KpayPaymentKind;
5
- (function (KpayPaymentKind) {
6
- KpayPaymentKind["CARD"] = "card";
7
- KpayPaymentKind["TRANSFER"] = "transfer";
8
- KpayPaymentKind["CASH"] = "cash";
9
- })(KpayPaymentKind = exports.KpayPaymentKind || (exports.KpayPaymentKind = {}));
@@ -1,20 +0,0 @@
1
- /* tslint:disable:all */
2
- /**
3
- * ICardService file.
4
- */
5
- import { Observable } from "rxjs";
6
- import { InitAuthRequest } from "./../../lib/types/init_auth_request";
7
- import { InitAuthResponse } from "./../../lib/types/init_auth_response";
8
- import { ValidateSessionResponse } from "./../../lib/types/validate_session_response";
9
- import { VerifyAuthResponse } from "./../../lib/types/verify_auth_response";
10
- export interface IAuthService {
11
- /**
12
- * Get Log in credentials
13
- * @param body - required mail from user and name as a optional value
14
- * @param isTestEnvironment
15
- */
16
- requestInitAuth(body: InitAuthRequest, isTestEnvironment: boolean): Observable<InitAuthResponse>;
17
- requestVerifyAuth(code: string, isTestEnvironment: boolean): Observable<VerifyAuthResponse>;
18
- validateSession(isTestEnvironment: boolean): Observable<ValidateSessionResponse>;
19
- getAuthorizationToken(): Observable<string>;
20
- }
@@ -1,26 +0,0 @@
1
- /* tslint:disable:all */
2
- /**
3
- * ICardService file.
4
- */
5
- import { Observable } from "rxjs";
6
- import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
7
- import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
8
- import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
9
- export interface IKPayService {
10
- /**
11
- * deletePaymentMethod from user
12
- * @param body - delete payment method id
13
- * @param mid - public merchant id
14
- * @param isTest - is test environment
15
- * @param regional - Define if endpoint used regional URL
16
- */
17
- deletePaymentMethod(body: DeletePaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<boolean>;
18
- /**
19
- * requestSavedPaymentMethods from user
20
- * @param body - user email and payment kind
21
- * @param mid - public merchant id
22
- * @param isTest - is test environment
23
- * @param regional - Define if endpoint used regional URL
24
- */
25
- requestSavedPaymentMethods(body: SavedPaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<PaymentDataResponse[]>;
26
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +0,0 @@
1
- /* tslint:disable:all */
2
- /**
3
- * MobileProcessorService file.
4
- */
5
- import { Observable } from "rxjs";
6
- import { MobileProcessorToken } from "./../../lib/types/mobile_processor_token";
7
- import { MobileProcessorTokenRequest } from "./../../lib/types/mobile_processor_token_request";
8
- export interface IMobileProcessorService {
9
- /**
10
- * @param request - MobileProcessor token request
11
- * @param mid - public credential for request
12
- * @param isTest - is test environment
13
- * @param regional - Define if endpoint used regional URL
14
- */
15
- requestToken(request: MobileProcessorTokenRequest, publicCredential: string, isTest: boolean, regional: boolean): Observable<MobileProcessorToken>;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,31 +0,0 @@
1
- /* tslint:disable:all */
2
- import "reflect-metadata";
3
- import { IAuthService } from "./../../lib/repository/IAuthService";
4
- import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
5
- import { Observable } from "rxjs";
6
- import { InitAuthRequest } from "./../../lib/types/init_auth_request";
7
- import { InitAuthResponse } from "./../../lib/types/init_auth_response";
8
- import { ValidateSessionResponse } from "./../../lib/types/validate_session_response";
9
- import { VerifyAuthResponse } from "./../../lib/types/verify_auth_response";
10
- /**
11
- * Implementation
12
- */
13
- export declare class AuthService implements IAuthService {
14
- private readonly _gateway;
15
- private _cognitoUser?;
16
- constructor(gateway: IKushkiGateway);
17
- requestInitAuth(body: InitAuthRequest, isTestEnvironment: boolean): Observable<InitAuthResponse>;
18
- requestVerifyAuth(code: string, isTestEnvironment: boolean): Observable<VerifyAuthResponse>;
19
- validateSession(isTestEnvironment: boolean): Observable<ValidateSessionResponse>;
20
- getAuthorizationToken(): Observable<string>;
21
- private _currentAuthenticatedUser;
22
- private _verifyCurrentSession;
23
- private _handleInitAuth;
24
- private _validateCurrentSession;
25
- private _getCurrentUserEmail;
26
- private _signOut;
27
- private _userSignIn;
28
- private _userSignInPasswordles;
29
- private static _configureAmplifyCredentials;
30
- private static _getRandomString;
31
- }
@@ -1,161 +0,0 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var AuthService_1;
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.AuthService = void 0;
26
- const aws_amplify_1 = require("aws-amplify");
27
- const axios_1 = require("axios");
28
- const Identifiers_1 = require("./../../lib/constant/Identifiers");
29
- const KushkiError_1 = require("./../../lib/generic/KushkiError");
30
- const CognitoErrorEnum_1 = require("./../../lib/infrastructure/CognitoErrorEnum");
31
- const ErrorEnum_1 = require("./../../lib/infrastructure/ErrorEnum");
32
- const KPayUserPoolEnum_1 = require("./../../lib/infrastructure/KPayUserPoolEnum");
33
- const inversify_1 = require("inversify");
34
- require("reflect-metadata");
35
- const rxjs_1 = require("rxjs");
36
- const operators_1 = require("rxjs/operators");
37
- const UtilsService_1 = require("./../../lib/service/UtilsService");
38
- /**
39
- * Implementation
40
- */
41
- let AuthService = AuthService_1 = class AuthService {
42
- constructor(gateway) {
43
- this._gateway = gateway;
44
- }
45
- requestInitAuth(body, isTestEnvironment) {
46
- return rxjs_1.of(1).pipe(operators_1.mergeMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.mergeMap(() => this._validateCurrentSession(body.email)), operators_1.mergeMap(sessionJwt => rxjs_1.iif(() => !!sessionJwt, rxjs_1.of({ result: true }), this._handleInitAuth(body.email))));
47
- }
48
- requestVerifyAuth(code, isTestEnvironment) {
49
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.sendCustomChallengeAnswer(this._cognitoUser, code))), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E009))), operators_1.concatMap(() => this._verifyCurrentSession()), operators_1.map(session => ({
50
- authorization: session.getRefreshToken().getToken(),
51
- })));
52
- }
53
- validateSession(isTestEnvironment) {
54
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.concatMap(() => this._getCurrentUserEmail()));
55
- }
56
- getAuthorizationToken() {
57
- return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this._currentAuthenticatedUser()), operators_1.mergeMap((cognitoUser) => {
58
- const session = cognitoUser ? cognitoUser.getSignInUserSession() : null;
59
- if (!session)
60
- return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011));
61
- return rxjs_1.of(session.getAccessToken().getJwtToken());
62
- }), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011))));
63
- }
64
- _currentAuthenticatedUser() {
65
- return rxjs_1.of(1).pipe(operators_1.mergeMap(() => rxjs_1.from(aws_amplify_1.Auth.currentAuthenticatedUser())));
66
- }
67
- _verifyCurrentSession() {
68
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.currentSession())), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E008))));
69
- }
70
- _handleInitAuth(email) {
71
- const password = AuthService_1._getRandomString();
72
- return rxjs_1.of(1).pipe(operators_1.mergeMap(() => {
73
- const user_attributes = {
74
- "custom:merchant": email,
75
- given_name: email,
76
- preferred_username: email,
77
- };
78
- const params = {
79
- password,
80
- attributes: user_attributes,
81
- username: email,
82
- };
83
- return rxjs_1.from(aws_amplify_1.Auth.signUp(params));
84
- }), operators_1.concatMap(() => this._userSignIn(email, password)), operators_1.concatMap((cognitoUser) => {
85
- this._cognitoUser = cognitoUser;
86
- return cognitoUser
87
- .getSignInUserSession()
88
- .getAccessToken()
89
- .getJwtToken();
90
- }), operators_1.concatMap((authorization) => rxjs_1.iif(() => !!authorization, rxjs_1.of({ result: true }), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E001)))), operators_1.catchError((error) => {
91
- const error_code = UtilsService_1.UtilsService.sGet(error, "code", "");
92
- return rxjs_1.iif(() => error_code === CognitoErrorEnum_1.CognitoErrorEnum.UsernameExistsException, this._userSignInPasswordles(email), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E007)));
93
- }));
94
- }
95
- _validateCurrentSession(email) {
96
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.currentSession()), operators_1.concatMap(session => rxjs_1.forkJoin([rxjs_1.of(session), rxjs_1.from(aws_amplify_1.Auth.currentUserInfo())])), operators_1.concatMap(([session, current_user_info]) => {
97
- if (email &&
98
- current_user_info.attributes.email.toLowerCase() !==
99
- email.toLowerCase())
100
- return this._signOut();
101
- return rxjs_1.of(session.getAccessToken().getJwtToken());
102
- }), operators_1.catchError(() => this._signOut()));
103
- }
104
- _getCurrentUserEmail() {
105
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.currentUserInfo()), operators_1.concatMap(currentInfo => rxjs_1.iif(() => !!currentInfo.attributes.email, rxjs_1.of({
106
- email: currentInfo.attributes.email.toLowerCase(),
107
- }), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011)))), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011))));
108
- }
109
- _signOut() {
110
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.signOut()), operators_1.mapTo(false));
111
- }
112
- _userSignIn(email, password) {
113
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.signIn(email, password))));
114
- }
115
- _userSignInPasswordles(email) {
116
- return rxjs_1.of(1).pipe(operators_1.mergeMap(() => rxjs_1.from(aws_amplify_1.Auth.signIn(email))), operators_1.mergeMap((cognitoUser) => {
117
- this._cognitoUser = cognitoUser;
118
- return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E010));
119
- }));
120
- }
121
- static _configureAmplifyCredentials(test) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- const remote_kpay_user_pool_url = `${test ? KPayUserPoolEnum_1.KPayUserPoolEnum.uat : KPayUserPoolEnum_1.KPayUserPoolEnum.prod}`;
124
- const { data: cognito_config } = yield axios_1.default.get(remote_kpay_user_pool_url);
125
- const auth = {
126
- cognito: {
127
- APP_CLIENT_ID: cognito_config.appClientId,
128
- REGION: cognito_config.region,
129
- USER_POOL_ID: cognito_config.userPoolId,
130
- },
131
- };
132
- aws_amplify_1.Auth.configure({
133
- Auth: {
134
- mandatorySignId: true,
135
- region: auth.cognito.REGION,
136
- storage: UtilsService_1.UtilsService.sIsEmpty(window) ? "" : window.sessionStorage,
137
- userPoolId: auth.cognito.USER_POOL_ID,
138
- userPoolWebClientId: auth.cognito.APP_CLIENT_ID,
139
- },
140
- });
141
- });
142
- }
143
- static _getRandomString() {
144
- return (
145
- // tslint:disable-next-line:insecure-random
146
- Math.random()
147
- .toString(36)
148
- .slice(2) +
149
- // tslint:disable-next-line:insecure-random
150
- Math.random()
151
- .toString(36)
152
- .toUpperCase()
153
- .slice(2));
154
- }
155
- };
156
- AuthService = AuthService_1 = __decorate([
157
- inversify_1.injectable(),
158
- __param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
159
- __metadata("design:paramtypes", [Object])
160
- ], AuthService);
161
- exports.AuthService = AuthService;
@@ -1,19 +0,0 @@
1
- /* tslint:disable:all */
2
- import "reflect-metadata";
3
- import { IAuthService } from "./../../lib/repository/IAuthService";
4
- import { IKPayService } from "./../../lib/repository/IKPayService";
5
- import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
6
- import { Observable } from "rxjs";
7
- import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
8
- import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
9
- import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
10
- /**
11
- * Implementation
12
- */
13
- export declare class KPayService implements IKPayService {
14
- private readonly _gateway;
15
- private readonly _authService;
16
- constructor(gateway: IKushkiGateway, authService: IAuthService);
17
- deletePaymentMethod(body: DeletePaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<boolean>;
18
- requestSavedPaymentMethods(body: SavedPaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<PaymentDataResponse[]>;
19
- }
@@ -1,45 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.KPayService = void 0;
16
- /**
17
- * Kushki Service file
18
- */
19
- const Identifiers_1 = require("./../../lib/constant/Identifiers");
20
- const inversify_1 = require("inversify");
21
- require("reflect-metadata");
22
- const rxjs_1 = require("rxjs");
23
- const operators_1 = require("rxjs/operators");
24
- /**
25
- * Implementation
26
- */
27
- let KPayService = class KPayService {
28
- constructor(gateway, authService) {
29
- this._gateway = gateway;
30
- this._authService = authService;
31
- }
32
- deletePaymentMethod(body, mid, isTest, regional) {
33
- return rxjs_1.of(1).pipe(operators_1.concatMap(() => this._authService.getAuthorizationToken()), operators_1.concatMap(jwt => this._gateway.deletePaymentMethod(body, isTest, regional, mid, jwt)));
34
- }
35
- requestSavedPaymentMethods(body, mid, isTest, regional) {
36
- return this._gateway.requestSavedPaymentMethods(body, isTest, regional, mid);
37
- }
38
- };
39
- KPayService = __decorate([
40
- inversify_1.injectable(),
41
- __param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
42
- __param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.AuthService)),
43
- __metadata("design:paramtypes", [Object, Object])
44
- ], KPayService);
45
- exports.KPayService = KPayService;
@@ -1,35 +0,0 @@
1
- /* tslint:disable:all */
2
- /**
3
- * MobileProcessor Service file
4
- */
5
- import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
6
- import { IMobileProcessorService } from "./../../lib/repository/IMobileProcessorService";
7
- import { Observable, Observer } from "rxjs";
8
- import { MobileProcessorChargeResponse } from "./../../lib/types/mobile_processor_charge_response";
9
- import { MobileProcessorToken } from "./../../lib/types/mobile_processor_token";
10
- import { MobileProcessorTokenRequest } from "./../../lib/types/mobile_processor_token_request";
11
- import { MobileProcessorTokenResponse } from "./../../lib/types/mobile_processor_token_response";
12
- /**
13
- * Implementation
14
- */
15
- export declare type Session = {
16
- session: any;
17
- validation_url?: string;
18
- current_url?: string;
19
- payment_token?: object;
20
- };
21
- export declare class MobileProcessorService implements IMobileProcessorService {
22
- private readonly _gateway;
23
- constructor(gateway: IKushkiGateway);
24
- requestToken(request: MobileProcessorTokenRequest, publicCredential: string, isTest: boolean, regional: boolean): Observable<MobileProcessorToken>;
25
- requestGatewayToken(request: MobileProcessorTokenRequest, session: Session, publicCredential: string, isTest: boolean, regional: boolean): Observable<[Session, MobileProcessorTokenResponse]>;
26
- requestGatewayCharge(token: string, publicCredential: string, isTest: boolean, regional: boolean, request: MobileProcessorTokenRequest, session: Session): Observable<[Session, MobileProcessorChargeResponse]>;
27
- createAppleRequest(request: MobileProcessorTokenRequest): object;
28
- completePayment(session: Session, response: MobileProcessorChargeResponse): Observable<MobileProcessorChargeResponse>;
29
- onvalidatemerchant(event: {
30
- validationURL: string;
31
- }, observer: Observer<Session>, session: any): void;
32
- paymentAuthorized(event: {
33
- payment: object;
34
- }, observer: Observer<Session>, session: Session): void;
35
- }