@esolve/ng-esolve-connect 0.29.3 → 0.29.5
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/esm2020/lib/auth/esolve-auth.service.mjs +4 -2
- package/esm2020/lib/coupons/esolve-coupons.service.mjs +41 -13
- package/esm2020/lib/session/esolve-session.service.mjs +24 -10
- package/esm2020/lib/shared/cookie/esolve-cookie.service.mjs +8 -4
- package/fesm2015/esolve-ng-esolve-connect.mjs +72 -24
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +72 -24
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/coupons/esolve-coupons.service.d.ts +6 -1
- package/lib/session/esolve-session.service.d.ts +3 -1
- package/lib/shared/cookie/esolve-cookie.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -41,7 +41,9 @@ class EsolveCookieService {
|
|
|
41
41
|
const server_cookies = this.request.headers.cookie ?? '';
|
|
42
42
|
const regExp = this.getCookieRegExp(name);
|
|
43
43
|
const result = regExp.exec(server_cookies);
|
|
44
|
-
return result && result[1]
|
|
44
|
+
return result && result[1]
|
|
45
|
+
? this.safeDecodeURIComponent(result[1])
|
|
46
|
+
: '';
|
|
45
47
|
}
|
|
46
48
|
set(name, value, expires, path, domain, secure) {
|
|
47
49
|
if (this.is_browser) {
|
|
@@ -69,7 +71,9 @@ class EsolveCookieService {
|
|
|
69
71
|
* @link https://github.com/stevermeister/ngx-cookie-service/blob/bcb6ac203487c487fcd126896bffaa14981c709c/projects/ngx-cookie-service/src/lib/cookie.service.ts#L31
|
|
70
72
|
*/
|
|
71
73
|
getCookieRegExp(name) {
|
|
72
|
-
const escapedName = name.replace(
|
|
74
|
+
const escapedName = name.replace(
|
|
75
|
+
// eslint-disable-next-line no-useless-escape
|
|
76
|
+
/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/gi, '\\$1');
|
|
73
77
|
return new RegExp('(?:^' + escapedName + '|;\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
@@ -98,7 +102,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
98
102
|
args: [{
|
|
99
103
|
providedIn: 'root',
|
|
100
104
|
}]
|
|
101
|
-
}], ctorParameters: function () { return [{ type: i1.CookieService }, { type:
|
|
105
|
+
}], ctorParameters: function () { return [{ type: i1.CookieService }, { type: undefined, decorators: [{
|
|
102
106
|
type: Inject,
|
|
103
107
|
args: [PLATFORM_ID]
|
|
104
108
|
}] }, { type: undefined, decorators: [{
|
|
@@ -165,8 +169,8 @@ class EsolveSessionService {
|
|
|
165
169
|
return;
|
|
166
170
|
}
|
|
167
171
|
let json_data = this.cookieService.get(this.storage_key);
|
|
168
|
-
if (json_data === ''
|
|
169
|
-
|
|
172
|
+
if (json_data === '') {
|
|
173
|
+
const local_store_data = this.getBackup();
|
|
170
174
|
if (local_store_data) {
|
|
171
175
|
json_data = local_store_data;
|
|
172
176
|
}
|
|
@@ -192,9 +196,7 @@ class EsolveSessionService {
|
|
|
192
196
|
const session = new EsolveSession(user_id, location_id, key, expiration_date);
|
|
193
197
|
const json_data = JSON.stringify(session);
|
|
194
198
|
this.cookieService.set(this.storage_key, json_data, expiration_date, '/');
|
|
195
|
-
|
|
196
|
-
localStorage.setItem(this.storage_key, json_data);
|
|
197
|
-
}
|
|
199
|
+
this.setBackup(json_data);
|
|
198
200
|
this._session.next(session);
|
|
199
201
|
this.startTimer(expirationCallback, expires * 1000);
|
|
200
202
|
}
|
|
@@ -208,9 +210,7 @@ class EsolveSessionService {
|
|
|
208
210
|
}
|
|
209
211
|
const json_data = JSON.stringify(current_session);
|
|
210
212
|
this.cookieService.set(this.storage_key, json_data, current_session.expiration_date, '/');
|
|
211
|
-
|
|
212
|
-
localStorage.setItem(this.storage_key, json_data);
|
|
213
|
-
}
|
|
213
|
+
this.setBackup(json_data);
|
|
214
214
|
this._session.next(current_session);
|
|
215
215
|
if (typeof callback === 'function') {
|
|
216
216
|
callback();
|
|
@@ -227,6 +227,24 @@ class EsolveSessionService {
|
|
|
227
227
|
this.key_expiration_timer = setTimeout(callback, duration);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
+
getBackup() {
|
|
231
|
+
if (!this.is_browser) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
if (!localStorage) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return localStorage.getItem(this.storage_key);
|
|
238
|
+
}
|
|
239
|
+
setBackup(data) {
|
|
240
|
+
if (!this.is_browser) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (!localStorage) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
localStorage.setItem(this.storage_key, data);
|
|
247
|
+
}
|
|
230
248
|
}
|
|
231
249
|
EsolveSessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveSessionService, deps: [{ token: PLATFORM_ID }, { token: ESOLVE_CONNECT_CONFIG }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
232
250
|
EsolveSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveSessionService, providedIn: 'root' });
|
|
@@ -235,7 +253,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
235
253
|
args: [{
|
|
236
254
|
providedIn: 'root',
|
|
237
255
|
}]
|
|
238
|
-
}], ctorParameters: function () { return [{ type:
|
|
256
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
239
257
|
type: Inject,
|
|
240
258
|
args: [PLATFORM_ID]
|
|
241
259
|
}] }, { type: undefined, decorators: [{
|
|
@@ -1696,7 +1714,9 @@ class EsolveAuthService {
|
|
|
1696
1714
|
}
|
|
1697
1715
|
autoLogin() {
|
|
1698
1716
|
this.session.restore(this.handleExpiration(), () => {
|
|
1699
|
-
firstValueFrom(this.getAccessToken('', '', true)).then(() => {
|
|
1717
|
+
firstValueFrom(this.getAccessToken('', '', true)).then(() => {
|
|
1718
|
+
// empty
|
|
1719
|
+
}, (error) => {
|
|
1700
1720
|
console.error(error);
|
|
1701
1721
|
});
|
|
1702
1722
|
});
|
|
@@ -2559,7 +2579,8 @@ class EsolveCoupon {
|
|
|
2559
2579
|
;
|
|
2560
2580
|
|
|
2561
2581
|
class EsolveCouponsService {
|
|
2562
|
-
constructor(config, http, cookieService) {
|
|
2582
|
+
constructor(platformId, config, http, cookieService) {
|
|
2583
|
+
this.platformId = platformId;
|
|
2563
2584
|
this.config = config;
|
|
2564
2585
|
this.http = http;
|
|
2565
2586
|
this.cookieService = cookieService;
|
|
@@ -2569,6 +2590,7 @@ class EsolveCouponsService {
|
|
|
2569
2590
|
this.validation_error = new Subject();
|
|
2570
2591
|
this.setStorageKey();
|
|
2571
2592
|
this.coupons_cache = this.retrieveCache();
|
|
2593
|
+
this.is_browser = isPlatformBrowser(this.platformId);
|
|
2572
2594
|
}
|
|
2573
2595
|
onValidationError() {
|
|
2574
2596
|
return this.validation_error.asObservable();
|
|
@@ -2646,11 +2668,10 @@ class EsolveCouponsService {
|
|
|
2646
2668
|
this.deleteCoupons();
|
|
2647
2669
|
}
|
|
2648
2670
|
retrieveCache() {
|
|
2649
|
-
if (this.cookieService.check(this.storage_key) ||
|
|
2650
|
-
localStorage.getItem(this.storage_key)) {
|
|
2671
|
+
if (this.cookieService.check(this.storage_key) || this.getBackup()) {
|
|
2651
2672
|
let coupons_json = this.cookieService.get(this.storage_key);
|
|
2652
|
-
if (coupons_json === ''
|
|
2653
|
-
|
|
2673
|
+
if (coupons_json === '') {
|
|
2674
|
+
const local_store_data = this.getBackup();
|
|
2654
2675
|
if (local_store_data) {
|
|
2655
2676
|
coupons_json = local_store_data;
|
|
2656
2677
|
}
|
|
@@ -2668,9 +2689,7 @@ class EsolveCouponsService {
|
|
|
2668
2689
|
if (this.coupons_cache.size > 0) {
|
|
2669
2690
|
const coupons_json = this.jsonEncodeMap(this.coupons_cache);
|
|
2670
2691
|
this.cookieService.set(this.storage_key, coupons_json, undefined, '/');
|
|
2671
|
-
|
|
2672
|
-
localStorage.setItem(this.storage_key, coupons_json);
|
|
2673
|
-
}
|
|
2692
|
+
this.setBackup(coupons_json);
|
|
2674
2693
|
}
|
|
2675
2694
|
else {
|
|
2676
2695
|
this.deleteCoupons();
|
|
@@ -2679,9 +2698,34 @@ class EsolveCouponsService {
|
|
|
2679
2698
|
deleteCoupons() {
|
|
2680
2699
|
this.coupons_cache.clear();
|
|
2681
2700
|
this.cookieService.delete(this.storage_key, '/');
|
|
2682
|
-
|
|
2683
|
-
|
|
2701
|
+
this.removeBackup();
|
|
2702
|
+
}
|
|
2703
|
+
getBackup() {
|
|
2704
|
+
if (!this.is_browser) {
|
|
2705
|
+
return null;
|
|
2684
2706
|
}
|
|
2707
|
+
if (!localStorage) {
|
|
2708
|
+
return null;
|
|
2709
|
+
}
|
|
2710
|
+
return localStorage.getItem(this.storage_key);
|
|
2711
|
+
}
|
|
2712
|
+
setBackup(data) {
|
|
2713
|
+
if (!this.is_browser) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
if (!localStorage) {
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2719
|
+
localStorage.setItem(this.storage_key, data);
|
|
2720
|
+
}
|
|
2721
|
+
removeBackup() {
|
|
2722
|
+
if (!this.is_browser) {
|
|
2723
|
+
return;
|
|
2724
|
+
}
|
|
2725
|
+
if (!localStorage) {
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
localStorage.removeItem(this.storage_key);
|
|
2685
2729
|
}
|
|
2686
2730
|
addCoupon(id, key) {
|
|
2687
2731
|
if (!this.coupons_cache.has(id)) {
|
|
@@ -2737,7 +2781,7 @@ class EsolveCouponsService {
|
|
|
2737
2781
|
return coupons;
|
|
2738
2782
|
}
|
|
2739
2783
|
}
|
|
2740
|
-
EsolveCouponsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2784
|
+
EsolveCouponsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, deps: [{ token: PLATFORM_ID }, { token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2741
2785
|
EsolveCouponsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, providedIn: 'root' });
|
|
2742
2786
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, decorators: [{
|
|
2743
2787
|
type: Injectable,
|
|
@@ -2745,6 +2789,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
2745
2789
|
providedIn: 'root',
|
|
2746
2790
|
}]
|
|
2747
2791
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2792
|
+
type: Inject,
|
|
2793
|
+
args: [PLATFORM_ID]
|
|
2794
|
+
}] }, { type: undefined, decorators: [{
|
|
2748
2795
|
type: Inject,
|
|
2749
2796
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2750
2797
|
}] }, { type: i1$2.HttpClient }, { type: EsolveCookieService }]; } });
|
|
@@ -5591,3 +5638,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
5591
5638
|
|
|
5592
5639
|
export { ESOLVE_CONNECT_CONFIG, EsolveAccountConfirmationResult, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveCoupon, EsolveCouponsService, EsolveDependantItem, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveSupplier, EsolveSuppliersService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveVaultItem, EsolveVaultItemResult, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule };
|
|
5593
5640
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|
|
5641
|
+
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|