@xsolla/payment-client-core 0.2.83 → 0.2.84
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/esm2022/lib/core/payment/form/converters/cvv/cvv.converter.mjs +3 -3
- package/esm2022/lib/core/payment/form/converters/zip/zip.converter.mjs +25 -9
- package/esm2022/lib/core/payment/requests/initialize/initialize.service.mjs +7 -4
- package/esm2022/lib/core/payment/requests/sync/sync.service.mjs +7 -4
- package/fesm2022/xsolla-payment-client-core.mjs +105 -85
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/form/converters/zip/zip.converter.d.ts +4 -1
- package/lib/core/payment/requests/initialize/initialize.service.d.ts +3 -1
- package/lib/core/payment/requests/sync/sync.service.d.ts +3 -1
- package/package.json +1 -1
- package/src/i18n/ar.json +3 -1
- package/src/i18n/bg.json +3 -1
- package/src/i18n/cs.json +3 -1
- package/src/i18n/de.json +3 -1
- package/src/i18n/en.json +3 -1
- package/src/i18n/es.json +3 -1
- package/src/i18n/fil.json +3 -1
- package/src/i18n/fr.json +3 -1
- package/src/i18n/he.json +3 -1
- package/src/i18n/id.json +3 -1
- package/src/i18n/it.json +3 -1
- package/src/i18n/ja.json +3 -1
- package/src/i18n/km.json +3 -1
- package/src/i18n/ko.json +3 -1
- package/src/i18n/lo.json +3 -1
- package/src/i18n/ms.json +3 -1
- package/src/i18n/my.json +3 -1
- package/src/i18n/ne.json +3 -1
- package/src/i18n/nl.json +3 -1
- package/src/i18n/pl.json +4 -2
- package/src/i18n/pt.json +3 -1
- package/src/i18n/ro.json +3 -1
- package/src/i18n/ru.json +3 -1
- package/src/i18n/th.json +3 -1
- package/src/i18n/tr.json +3 -1
- package/src/i18n/vi.json +3 -1
- package/src/i18n/zh_HANS.json +3 -1
- package/src/i18n/zh_HANT.json +3 -1
- package/xsolla-payment-client-core-0.2.84.tgz +0 -0
- package/xsolla-payment-client-core-0.2.83.tgz +0 -0
|
@@ -2978,8 +2978,67 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
2978
2978
|
}]
|
|
2979
2979
|
}] });
|
|
2980
2980
|
|
|
2981
|
+
function isNull(value) {
|
|
2982
|
+
return value === null;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
function isUndefined(value) {
|
|
2986
|
+
return typeof value === 'undefined';
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
class SessionService {
|
|
2990
|
+
constructor(window, settingsService) {
|
|
2991
|
+
this.window = window;
|
|
2992
|
+
this.settingsService = settingsService;
|
|
2993
|
+
this.cache = {};
|
|
2994
|
+
}
|
|
2995
|
+
/**
|
|
2996
|
+
* @param {string} key must be uniq entire all app
|
|
2997
|
+
* @param {unknown} value can be anything
|
|
2998
|
+
*/
|
|
2999
|
+
set(key, value) {
|
|
3000
|
+
this.cache[key] = value;
|
|
3001
|
+
try {
|
|
3002
|
+
this.window.sessionStorage.setItem(this.getStorageKey(key), JSON.stringify(value));
|
|
3003
|
+
}
|
|
3004
|
+
catch (error) {
|
|
3005
|
+
console.warn('Session storage not available.');
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
get(key) {
|
|
3009
|
+
const cacheValue = this.cache[key];
|
|
3010
|
+
if (!isUndefined(cacheValue)) {
|
|
3011
|
+
return cacheValue;
|
|
3012
|
+
}
|
|
3013
|
+
try {
|
|
3014
|
+
const storageValue = this.window.sessionStorage.getItem(this.getStorageKey(key));
|
|
3015
|
+
if (isNull(storageValue)) {
|
|
3016
|
+
return null;
|
|
3017
|
+
}
|
|
3018
|
+
return JSON.parse(storageValue);
|
|
3019
|
+
}
|
|
3020
|
+
catch (error) {
|
|
3021
|
+
return null;
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
getStorageKey(key) {
|
|
3025
|
+
return `${key}${this.settingsService.token}`;
|
|
3026
|
+
}
|
|
3027
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SessionService, deps: [{ token: windowToken }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3028
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SessionService, providedIn: 'root' }); }
|
|
3029
|
+
}
|
|
3030
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SessionService, decorators: [{
|
|
3031
|
+
type: Injectable,
|
|
3032
|
+
args: [{
|
|
3033
|
+
providedIn: 'root',
|
|
3034
|
+
}]
|
|
3035
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3036
|
+
type: Inject,
|
|
3037
|
+
args: [windowToken]
|
|
3038
|
+
}] }, { type: SettingsService }] });
|
|
3039
|
+
|
|
2981
3040
|
class InitializeService {
|
|
2982
|
-
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService, paymentSettingsService) {
|
|
3041
|
+
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService, paymentSettingsService, sessionService) {
|
|
2983
3042
|
this.responseFactory = responseFactory;
|
|
2984
3043
|
this.xpsApiService = xpsApiService;
|
|
2985
3044
|
this.settingsService = settingsService;
|
|
@@ -2990,9 +3049,11 @@ class InitializeService {
|
|
|
2990
3049
|
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
2991
3050
|
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
2992
3051
|
this.paymentSettingsService = paymentSettingsService;
|
|
3052
|
+
this.sessionService = sessionService;
|
|
2993
3053
|
}
|
|
2994
3054
|
async request(config) {
|
|
2995
3055
|
const paymentSettingsParams = this.paymentSettingsService.getPaymentSettingsParams(config);
|
|
3056
|
+
this.sessionService.set('cardNumberCountry', null);
|
|
2996
3057
|
const requestParams = {
|
|
2997
3058
|
access_token: this.settingsService.token,
|
|
2998
3059
|
pid: String(config.paymentMethodId),
|
|
@@ -3039,7 +3100,7 @@ class InitializeService {
|
|
|
3039
3100
|
}
|
|
3040
3101
|
this.encryptCreditCardService.setPublicKey(atob(publicKeyField.value));
|
|
3041
3102
|
}
|
|
3042
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3103
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }, { token: SessionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3043
3104
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, providedIn: 'root' }); }
|
|
3044
3105
|
}
|
|
3045
3106
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, decorators: [{
|
|
@@ -3050,7 +3111,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3050
3111
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3051
3112
|
type: Inject,
|
|
3052
3113
|
args: [initializeResponseFactoryToken]
|
|
3053
|
-
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }] });
|
|
3114
|
+
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }, { type: SessionService }] });
|
|
3054
3115
|
|
|
3055
3116
|
class XpsApiPartRequest {
|
|
3056
3117
|
addXpsParameters(parameters) {
|
|
@@ -3321,7 +3382,7 @@ const syncResponseFactoryProvider = {
|
|
|
3321
3382
|
};
|
|
3322
3383
|
|
|
3323
3384
|
class SyncService extends EmitDataService {
|
|
3324
|
-
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService, paymentSettingsService) {
|
|
3385
|
+
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService, paymentSettingsService, sessionService) {
|
|
3325
3386
|
super();
|
|
3326
3387
|
this.requestFactory = requestFactory;
|
|
3327
3388
|
this.responseFactory = responseFactory;
|
|
@@ -3333,6 +3394,7 @@ class SyncService extends EmitDataService {
|
|
|
3333
3394
|
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
3334
3395
|
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
3335
3396
|
this.paymentSettingsService = paymentSettingsService;
|
|
3397
|
+
this.sessionService = sessionService;
|
|
3336
3398
|
this.prevFieldSyncStates = {};
|
|
3337
3399
|
this.form = new UntypedFormGroup({});
|
|
3338
3400
|
this.paymentConfiguration = null;
|
|
@@ -3436,6 +3498,7 @@ class SyncService extends EmitDataService {
|
|
|
3436
3498
|
.directPaymentRequest(encryptedRequest)
|
|
3437
3499
|
.then((xpsResponse) => {
|
|
3438
3500
|
const response = this.xpsResponseErrorsMappingService.mapErrors(xpsResponse);
|
|
3501
|
+
this.sessionService.set('cardNumberCountry', response.cardBinCountry);
|
|
3439
3502
|
this.emitFormErrors(response);
|
|
3440
3503
|
this.emit(response);
|
|
3441
3504
|
return this.responseFactory(field, response);
|
|
@@ -3471,7 +3534,7 @@ class SyncService extends EmitDataService {
|
|
|
3471
3534
|
}
|
|
3472
3535
|
this.fieldSyncTimers[field.name] = timerId;
|
|
3473
3536
|
}
|
|
3474
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3537
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }, { token: SessionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3475
3538
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, providedIn: 'root' }); }
|
|
3476
3539
|
}
|
|
3477
3540
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, decorators: [{
|
|
@@ -3485,7 +3548,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3485
3548
|
}] }, { type: undefined, decorators: [{
|
|
3486
3549
|
type: Inject,
|
|
3487
3550
|
args: [syncResponseFactoryToken]
|
|
3488
|
-
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }] });
|
|
3551
|
+
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }, { type: SessionService }] });
|
|
3489
3552
|
|
|
3490
3553
|
function isObject(value) {
|
|
3491
3554
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -3640,18 +3703,6 @@ class TextControlConfig extends ControlConfig {
|
|
|
3640
3703
|
}
|
|
3641
3704
|
}
|
|
3642
3705
|
|
|
3643
|
-
function minLengthValidator(minLength) {
|
|
3644
|
-
return convert(Validators.minLength(minLength), TranslateHelper.t('errors.validation.min-length', `Enter at least ${minLength} characters`, { minLength }), {
|
|
3645
|
-
minLength,
|
|
3646
|
-
});
|
|
3647
|
-
}
|
|
3648
|
-
|
|
3649
|
-
function maxLengthValidator(maxLength) {
|
|
3650
|
-
return convert(Validators.maxLength(maxLength), TranslateHelper.t('errors.validation.max-length', `Enter no more than ${maxLength} characters`, { maxLength }), {
|
|
3651
|
-
maxLength,
|
|
3652
|
-
});
|
|
3653
|
-
}
|
|
3654
|
-
|
|
3655
3706
|
const restrictedValueValidator = (restrictedValue) => {
|
|
3656
3707
|
return ({ value }) => {
|
|
3657
3708
|
return value !== restrictedValue
|
|
@@ -3666,24 +3717,38 @@ const restrictedValueValidator = (restrictedValue) => {
|
|
|
3666
3717
|
};
|
|
3667
3718
|
|
|
3668
3719
|
class ZipConverter extends Converter {
|
|
3669
|
-
constructor(syncService, countryService) {
|
|
3720
|
+
constructor(syncService, countryService, sessionService) {
|
|
3670
3721
|
super(syncService);
|
|
3671
3722
|
this.countryService = countryService;
|
|
3723
|
+
this.sessionService = sessionService;
|
|
3672
3724
|
this.minLength = 3;
|
|
3673
3725
|
this.maxLength = 10;
|
|
3674
3726
|
this.usCountryLength = 5;
|
|
3675
3727
|
}
|
|
3676
3728
|
get isUsCountry() {
|
|
3677
|
-
|
|
3729
|
+
const currentCountry = this.countryService.getCountry().toUpperCase();
|
|
3730
|
+
const cardNumberCountry = this.sessionService.get('cardNumberCountry');
|
|
3731
|
+
return (cardNumberCountry ?? currentCountry) === 'US';
|
|
3732
|
+
}
|
|
3733
|
+
get isCanadaCountry() {
|
|
3734
|
+
const currentCountry = this.countryService.getCountry().toUpperCase();
|
|
3735
|
+
const cardNumberCountry = this.sessionService.get('cardNumberCountry');
|
|
3736
|
+
return (cardNumberCountry ?? currentCountry) === 'CA';
|
|
3678
3737
|
}
|
|
3679
3738
|
getValidators(field) {
|
|
3680
3739
|
const minLength = this.isUsCountry ? this.usCountryLength : this.minLength;
|
|
3681
3740
|
const maxLength = this.isUsCountry ? this.usCountryLength : this.maxLength;
|
|
3682
3741
|
const validators = super
|
|
3683
3742
|
.getValidators(field)
|
|
3684
|
-
.concat([
|
|
3743
|
+
.concat([
|
|
3744
|
+
convert(Validators.minLength(minLength), TranslateHelper.t('errors.validation.min-length', `Enter at least ${minLength} characters`, { minLength })),
|
|
3745
|
+
convert(Validators.maxLength(maxLength), TranslateHelper.t('errors.validation.max-length', `Enter no more than ${maxLength} characters`, { maxLength })),
|
|
3746
|
+
]);
|
|
3685
3747
|
if (this.isUsCountry) {
|
|
3686
|
-
validators.push(convert(restrictedValueValidator('00000'), TranslateHelper.t('errors.validation.zip-pattern', 'Enter a valid ZIP code')
|
|
3748
|
+
validators.push(convert(restrictedValueValidator('00000'), TranslateHelper.t('errors.validation.zip-pattern', 'Enter a valid ZIP code')));
|
|
3749
|
+
}
|
|
3750
|
+
if (this.isCanadaCountry) {
|
|
3751
|
+
validators.push(convert(Validators.pattern(/^[A-Za-z0-9]{3}\s?[A-Za-z0-9]{0,3}$/), TranslateHelper.t('errors.validation.zip-pattern-non-us', 'Enter a valid postal code')));
|
|
3687
3752
|
}
|
|
3688
3753
|
return validators;
|
|
3689
3754
|
}
|
|
@@ -3698,10 +3763,12 @@ class ZipConverter extends Converter {
|
|
|
3698
3763
|
unmaskModelValue: true,
|
|
3699
3764
|
showMask: true,
|
|
3700
3765
|
};
|
|
3766
|
+
config.placeholder = TranslateHelper.t('zip.converter.placeholder', 'ZIP code');
|
|
3701
3767
|
config.inputMode = 'numeric';
|
|
3702
3768
|
}
|
|
3703
3769
|
else {
|
|
3704
3770
|
config.maxLength = this.maxLength;
|
|
3771
|
+
config.placeholder = TranslateHelper.t('zip.converter.placeholder-non-us', 'Postal code');
|
|
3705
3772
|
}
|
|
3706
3773
|
return config;
|
|
3707
3774
|
}
|
|
@@ -3711,12 +3778,12 @@ class ZipConverter extends Converter {
|
|
|
3711
3778
|
getDataType() {
|
|
3712
3779
|
return 'text';
|
|
3713
3780
|
}
|
|
3714
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ZipConverter, deps: [{ token: SyncService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3781
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ZipConverter, deps: [{ token: SyncService }, { token: CountryService }, { token: SessionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3715
3782
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ZipConverter }); }
|
|
3716
3783
|
}
|
|
3717
3784
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ZipConverter, decorators: [{
|
|
3718
3785
|
type: Injectable
|
|
3719
|
-
}], ctorParameters: () => [{ type: SyncService }, { type: CountryService }] });
|
|
3786
|
+
}], ctorParameters: () => [{ type: SyncService }, { type: CountryService }, { type: SessionService }] });
|
|
3720
3787
|
|
|
3721
3788
|
function isEmptyInputValue(value) {
|
|
3722
3789
|
return value == null || value.length === 0;
|
|
@@ -3964,8 +4031,8 @@ class CvvConverter extends Converter {
|
|
|
3964
4031
|
break;
|
|
3965
4032
|
}
|
|
3966
4033
|
case CreditCardTypes.MAESTRO: {
|
|
3967
|
-
this.maxFieldLength =
|
|
3968
|
-
validators.push(getPatternValidator(
|
|
4034
|
+
this.maxFieldLength = 4;
|
|
4035
|
+
validators.push(getPatternValidator(/^(?:\d{3,4})?$/));
|
|
3969
4036
|
break;
|
|
3970
4037
|
}
|
|
3971
4038
|
default: {
|
|
@@ -4473,6 +4540,18 @@ function phoneValidator() {
|
|
|
4473
4540
|
return convert(Validators.pattern(/^\d*$/), TranslateHelper.t('errors.validation.phone-pattern', 'Enter a valid phone'));
|
|
4474
4541
|
}
|
|
4475
4542
|
|
|
4543
|
+
function minLengthValidator(minLength) {
|
|
4544
|
+
return convert(Validators.minLength(minLength), TranslateHelper.t('errors.validation.min-length', `Enter at least ${minLength} characters`, { minLength }), {
|
|
4545
|
+
minLength,
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
|
|
4549
|
+
function maxLengthValidator(maxLength) {
|
|
4550
|
+
return convert(Validators.maxLength(maxLength), TranslateHelper.t('errors.validation.max-length', `Enter no more than ${maxLength} characters`, { maxLength }), {
|
|
4551
|
+
maxLength,
|
|
4552
|
+
});
|
|
4553
|
+
}
|
|
4554
|
+
|
|
4476
4555
|
class PhoneControlConfig extends ControlConfig {
|
|
4477
4556
|
constructor() {
|
|
4478
4557
|
super(...arguments);
|
|
@@ -4938,65 +5017,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
4938
5017
|
args: [statusResponseFactoryToken]
|
|
4939
5018
|
}] }] });
|
|
4940
5019
|
|
|
4941
|
-
function isNull(value) {
|
|
4942
|
-
return value === null;
|
|
4943
|
-
}
|
|
4944
|
-
|
|
4945
|
-
function isUndefined(value) {
|
|
4946
|
-
return typeof value === 'undefined';
|
|
4947
|
-
}
|
|
4948
|
-
|
|
4949
|
-
class SessionService {
|
|
4950
|
-
constructor(window, settingsService) {
|
|
4951
|
-
this.window = window;
|
|
4952
|
-
this.settingsService = settingsService;
|
|
4953
|
-
this.cache = {};
|
|
4954
|
-
}
|
|
4955
|
-
/**
|
|
4956
|
-
* @param {string} key must be uniq entire all app
|
|
4957
|
-
* @param {unknown} value can be anything
|
|
4958
|
-
*/
|
|
4959
|
-
set(key, value) {
|
|
4960
|
-
this.cache[key] = value;
|
|
4961
|
-
try {
|
|
4962
|
-
this.window.sessionStorage.setItem(this.getStorageKey(key), JSON.stringify(value));
|
|
4963
|
-
}
|
|
4964
|
-
catch (error) {
|
|
4965
|
-
console.warn('Session storage not available.');
|
|
4966
|
-
}
|
|
4967
|
-
}
|
|
4968
|
-
get(key) {
|
|
4969
|
-
const cacheValue = this.cache[key];
|
|
4970
|
-
if (!isUndefined(cacheValue)) {
|
|
4971
|
-
return cacheValue;
|
|
4972
|
-
}
|
|
4973
|
-
try {
|
|
4974
|
-
const storageValue = this.window.sessionStorage.getItem(this.getStorageKey(key));
|
|
4975
|
-
if (isNull(storageValue)) {
|
|
4976
|
-
return null;
|
|
4977
|
-
}
|
|
4978
|
-
return JSON.parse(storageValue);
|
|
4979
|
-
}
|
|
4980
|
-
catch (error) {
|
|
4981
|
-
return null;
|
|
4982
|
-
}
|
|
4983
|
-
}
|
|
4984
|
-
getStorageKey(key) {
|
|
4985
|
-
return `${key}${this.settingsService.token}`;
|
|
4986
|
-
}
|
|
4987
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SessionService, deps: [{ token: windowToken }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4988
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SessionService, providedIn: 'root' }); }
|
|
4989
|
-
}
|
|
4990
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SessionService, decorators: [{
|
|
4991
|
-
type: Injectable,
|
|
4992
|
-
args: [{
|
|
4993
|
-
providedIn: 'root',
|
|
4994
|
-
}]
|
|
4995
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
4996
|
-
type: Inject,
|
|
4997
|
-
args: [windowToken]
|
|
4998
|
-
}] }, { type: SettingsService }] });
|
|
4999
|
-
|
|
5000
5020
|
function extractMoneyCurrency(money, allowZero = true) {
|
|
5001
5021
|
return {
|
|
5002
5022
|
amount: money?.amount ?? (allowZero ? 0 : null),
|