@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.
@@ -71,7 +71,9 @@ class EsolveCookieService {
71
71
  const server_cookies = (_a = this.request.headers.cookie) !== null && _a !== void 0 ? _a : '';
72
72
  const regExp = this.getCookieRegExp(name);
73
73
  const result = regExp.exec(server_cookies);
74
- return result && result[1] ? this.safeDecodeURIComponent(result[1]) : '';
74
+ return result && result[1]
75
+ ? this.safeDecodeURIComponent(result[1])
76
+ : '';
75
77
  }
76
78
  set(name, value, expires, path, domain, secure) {
77
79
  if (this.is_browser) {
@@ -99,7 +101,9 @@ class EsolveCookieService {
99
101
  * @link https://github.com/stevermeister/ngx-cookie-service/blob/bcb6ac203487c487fcd126896bffaa14981c709c/projects/ngx-cookie-service/src/lib/cookie.service.ts#L31
100
102
  */
101
103
  getCookieRegExp(name) {
102
- const escapedName = name.replace(/([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/gi, '\\$1');
104
+ const escapedName = name.replace(
105
+ // eslint-disable-next-line no-useless-escape
106
+ /([\[\]\{\}\(\)\|\=\;\+\?\,\.\*\^\$])/gi, '\\$1');
103
107
  return new RegExp('(?:^' + escapedName + '|;\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');
104
108
  }
105
109
  /**
@@ -129,7 +133,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
129
133
  providedIn: 'root',
130
134
  }]
131
135
  }], ctorParameters: function () {
132
- return [{ type: i1.CookieService }, { type: Object, decorators: [{
136
+ return [{ type: i1.CookieService }, { type: undefined, decorators: [{
133
137
  type: Inject,
134
138
  args: [PLATFORM_ID]
135
139
  }] }, { type: undefined, decorators: [{
@@ -169,8 +173,8 @@ class EsolveSessionService {
169
173
  return;
170
174
  }
171
175
  let json_data = this.cookieService.get(this.storage_key);
172
- if (json_data === '' && localStorage) {
173
- let local_store_data = localStorage.getItem(this.storage_key);
176
+ if (json_data === '') {
177
+ const local_store_data = this.getBackup();
174
178
  if (local_store_data) {
175
179
  json_data = local_store_data;
176
180
  }
@@ -196,9 +200,7 @@ class EsolveSessionService {
196
200
  const session = new EsolveSession(user_id, location_id, key, expiration_date);
197
201
  const json_data = JSON.stringify(session);
198
202
  this.cookieService.set(this.storage_key, json_data, expiration_date, '/');
199
- if (localStorage) {
200
- localStorage.setItem(this.storage_key, json_data);
201
- }
203
+ this.setBackup(json_data);
202
204
  this._session.next(session);
203
205
  this.startTimer(expirationCallback, expires * 1000);
204
206
  }
@@ -212,9 +214,7 @@ class EsolveSessionService {
212
214
  }
213
215
  const json_data = JSON.stringify(current_session);
214
216
  this.cookieService.set(this.storage_key, json_data, current_session.expiration_date, '/');
215
- if (localStorage) {
216
- localStorage.setItem(this.storage_key, json_data);
217
- }
217
+ this.setBackup(json_data);
218
218
  this._session.next(current_session);
219
219
  if (typeof callback === 'function') {
220
220
  callback();
@@ -231,6 +231,24 @@ class EsolveSessionService {
231
231
  this.key_expiration_timer = setTimeout(callback, duration);
232
232
  }
233
233
  }
234
+ getBackup() {
235
+ if (!this.is_browser) {
236
+ return null;
237
+ }
238
+ if (!localStorage) {
239
+ return null;
240
+ }
241
+ return localStorage.getItem(this.storage_key);
242
+ }
243
+ setBackup(data) {
244
+ if (!this.is_browser) {
245
+ return;
246
+ }
247
+ if (!localStorage) {
248
+ return;
249
+ }
250
+ localStorage.setItem(this.storage_key, data);
251
+ }
234
252
  }
235
253
  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 });
236
254
  EsolveSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveSessionService, providedIn: 'root' });
@@ -240,7 +258,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
240
258
  providedIn: 'root',
241
259
  }]
242
260
  }], ctorParameters: function () {
243
- return [{ type: Object, decorators: [{
261
+ return [{ type: undefined, decorators: [{
244
262
  type: Inject,
245
263
  args: [PLATFORM_ID]
246
264
  }] }, { type: undefined, decorators: [{
@@ -1723,7 +1741,9 @@ class EsolveAuthService {
1723
1741
  }
1724
1742
  autoLogin() {
1725
1743
  this.session.restore(this.handleExpiration(), () => {
1726
- firstValueFrom(this.getAccessToken('', '', true)).then(() => { }, (error) => {
1744
+ firstValueFrom(this.getAccessToken('', '', true)).then(() => {
1745
+ // empty
1746
+ }, (error) => {
1727
1747
  console.error(error);
1728
1748
  });
1729
1749
  });
@@ -2603,7 +2623,8 @@ class EsolveCoupon {
2603
2623
  ;
2604
2624
 
2605
2625
  class EsolveCouponsService {
2606
- constructor(config, http, cookieService) {
2626
+ constructor(platformId, config, http, cookieService) {
2627
+ this.platformId = platformId;
2607
2628
  this.config = config;
2608
2629
  this.http = http;
2609
2630
  this.cookieService = cookieService;
@@ -2613,6 +2634,7 @@ class EsolveCouponsService {
2613
2634
  this.validation_error = new Subject();
2614
2635
  this.setStorageKey();
2615
2636
  this.coupons_cache = this.retrieveCache();
2637
+ this.is_browser = isPlatformBrowser(this.platformId);
2616
2638
  }
2617
2639
  onValidationError() {
2618
2640
  return this.validation_error.asObservable();
@@ -2692,11 +2714,10 @@ class EsolveCouponsService {
2692
2714
  this.deleteCoupons();
2693
2715
  }
2694
2716
  retrieveCache() {
2695
- if (this.cookieService.check(this.storage_key) ||
2696
- localStorage.getItem(this.storage_key)) {
2717
+ if (this.cookieService.check(this.storage_key) || this.getBackup()) {
2697
2718
  let coupons_json = this.cookieService.get(this.storage_key);
2698
- if (coupons_json === '' && localStorage) {
2699
- let local_store_data = localStorage.getItem(this.storage_key);
2719
+ if (coupons_json === '') {
2720
+ const local_store_data = this.getBackup();
2700
2721
  if (local_store_data) {
2701
2722
  coupons_json = local_store_data;
2702
2723
  }
@@ -2714,9 +2735,7 @@ class EsolveCouponsService {
2714
2735
  if (this.coupons_cache.size > 0) {
2715
2736
  const coupons_json = this.jsonEncodeMap(this.coupons_cache);
2716
2737
  this.cookieService.set(this.storage_key, coupons_json, undefined, '/');
2717
- if (localStorage) {
2718
- localStorage.setItem(this.storage_key, coupons_json);
2719
- }
2738
+ this.setBackup(coupons_json);
2720
2739
  }
2721
2740
  else {
2722
2741
  this.deleteCoupons();
@@ -2725,9 +2744,34 @@ class EsolveCouponsService {
2725
2744
  deleteCoupons() {
2726
2745
  this.coupons_cache.clear();
2727
2746
  this.cookieService.delete(this.storage_key, '/');
2728
- if (localStorage) {
2729
- localStorage.removeItem(this.storage_key);
2747
+ this.removeBackup();
2748
+ }
2749
+ getBackup() {
2750
+ if (!this.is_browser) {
2751
+ return null;
2730
2752
  }
2753
+ if (!localStorage) {
2754
+ return null;
2755
+ }
2756
+ return localStorage.getItem(this.storage_key);
2757
+ }
2758
+ setBackup(data) {
2759
+ if (!this.is_browser) {
2760
+ return;
2761
+ }
2762
+ if (!localStorage) {
2763
+ return;
2764
+ }
2765
+ localStorage.setItem(this.storage_key, data);
2766
+ }
2767
+ removeBackup() {
2768
+ if (!this.is_browser) {
2769
+ return;
2770
+ }
2771
+ if (!localStorage) {
2772
+ return;
2773
+ }
2774
+ localStorage.removeItem(this.storage_key);
2731
2775
  }
2732
2776
  addCoupon(id, key) {
2733
2777
  if (!this.coupons_cache.has(id)) {
@@ -2783,7 +2827,7 @@ class EsolveCouponsService {
2783
2827
  return coupons;
2784
2828
  }
2785
2829
  }
2786
- 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 });
2830
+ 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 });
2787
2831
  EsolveCouponsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, providedIn: 'root' });
2788
2832
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: EsolveCouponsService, decorators: [{
2789
2833
  type: Injectable,
@@ -2792,6 +2836,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
2792
2836
  }]
2793
2837
  }], ctorParameters: function () {
2794
2838
  return [{ type: undefined, decorators: [{
2839
+ type: Inject,
2840
+ args: [PLATFORM_ID]
2841
+ }] }, { type: undefined, decorators: [{
2795
2842
  type: Inject,
2796
2843
  args: [ESOLVE_CONNECT_CONFIG]
2797
2844
  }] }, { type: i1$2.HttpClient }, { type: EsolveCookieService }];
@@ -5676,3 +5723,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
5676
5723
 
5677
5724
  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 };
5678
5725
  //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
5726
+ //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map