@esolve/ng-esolve-connect 0.11.1 → 0.12.0
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/account/esolve-account.service.mjs +26 -4
- package/esm2020/lib/account/esolve-forgot-password-response.mjs +1 -1
- package/esm2020/lib/account/esolve-location-update-result.mjs +8 -0
- package/esm2020/lib/account/esolve-registration-post-response-item.mjs +1 -1
- package/esm2020/lib/account/esolve-registration-result.mjs +2 -1
- package/esm2020/lib/auth/esolve-auth-response.mjs +4 -0
- package/esm2020/lib/auth/esolve-auth.service.mjs +22 -9
- package/esm2020/lib/auth/esolve-login-post-response-item.mjs +2 -0
- package/esm2020/lib/session/esolve-session-data.mjs +2 -0
- package/esm2020/lib/session/esolve-session.mjs +6 -2
- package/esm2020/lib/session/esolve-session.service.mjs +22 -18
- package/esm2020/lib/session/esolve-stored-session.mjs +1 -1
- package/fesm2015/esolve-ng-esolve-connect.mjs +78 -29
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +78 -29
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/account/esolve-account.service.d.ts +2 -0
- package/lib/account/esolve-forgot-password-response.d.ts +2 -0
- package/lib/account/esolve-location-update-result.d.ts +6 -0
- package/lib/account/esolve-registration-post-response-item.d.ts +2 -0
- package/lib/account/esolve-registration-result.d.ts +1 -0
- package/lib/auth/esolve-auth-response.d.ts +25 -0
- package/lib/auth/esolve-auth.service.d.ts +3 -15
- package/lib/auth/esolve-login-post-response-item.d.ts +6 -0
- package/lib/session/esolve-session-data.d.ts +3 -0
- package/lib/session/esolve-session.d.ts +5 -2
- package/lib/session/esolve-session.service.d.ts +9 -4
- package/lib/session/esolve-stored-session.d.ts +2 -1
- package/package.json +1 -1
|
@@ -19,8 +19,9 @@ const ESOLVE_CONNECT_CONFIG = new InjectionToken('esolve.connect.config');
|
|
|
19
19
|
// };
|
|
20
20
|
|
|
21
21
|
class EsolveSession {
|
|
22
|
-
constructor(id = -1, key = '', expiration_date) {
|
|
22
|
+
constructor(id = -1, location_id = 0, key = '', expiration_date) {
|
|
23
23
|
this.id = id;
|
|
24
|
+
this.location_id = location_id;
|
|
24
25
|
this.key = key;
|
|
25
26
|
this.expiration_date = expiration_date;
|
|
26
27
|
}
|
|
@@ -40,6 +41,9 @@ class EsolveSession {
|
|
|
40
41
|
updateUser(user_id) {
|
|
41
42
|
this.id = user_id;
|
|
42
43
|
}
|
|
44
|
+
updateLocation(location_id) {
|
|
45
|
+
this.location_id = location_id;
|
|
46
|
+
}
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
class EsolveCookieService {
|
|
@@ -144,7 +148,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
144
148
|
args: ['RESPONSE']
|
|
145
149
|
}] }]; } });
|
|
146
150
|
|
|
147
|
-
// TODO: Rewrite session manager to use a pure rxjs solution.
|
|
148
151
|
class EsolveSessionService {
|
|
149
152
|
constructor(platformId, config, cookieService) {
|
|
150
153
|
this.platformId = platformId;
|
|
@@ -159,17 +162,6 @@ class EsolveSessionService {
|
|
|
159
162
|
get currentSession() {
|
|
160
163
|
return this._session.value;
|
|
161
164
|
}
|
|
162
|
-
setStorageKey() {
|
|
163
|
-
if ((typeof this.config.user_session_storage_key === 'string') &&
|
|
164
|
-
(this.config.user_session_storage_key !== '')) {
|
|
165
|
-
this.storage_key = this.config.user_session_storage_key;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
startTimer(callback, duration) {
|
|
169
|
-
if (this.is_browser) {
|
|
170
|
-
this.key_expiration_timer = setTimeout(callback, duration);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
165
|
clearTimer() {
|
|
174
166
|
if (this.key_expiration_timer) {
|
|
175
167
|
clearTimeout(this.key_expiration_timer);
|
|
@@ -186,7 +178,7 @@ class EsolveSessionService {
|
|
|
186
178
|
return;
|
|
187
179
|
}
|
|
188
180
|
const expiration_date = new Date(stored_session.expiration_date);
|
|
189
|
-
const loaded_session = new EsolveSession(stored_session.id, stored_session.key, expiration_date);
|
|
181
|
+
const loaded_session = new EsolveSession(stored_session.id, stored_session.location_id, stored_session.key, expiration_date);
|
|
190
182
|
if (!loaded_session.expired) {
|
|
191
183
|
this._session.next(loaded_session);
|
|
192
184
|
const expiration_duration = expiration_date.getTime() - new Date().getTime();
|
|
@@ -196,22 +188,38 @@ class EsolveSessionService {
|
|
|
196
188
|
expirationCallback(loaded_session);
|
|
197
189
|
}
|
|
198
190
|
}
|
|
199
|
-
handleSession(user_id, key, expiry_time, expires, expirationCallback) {
|
|
191
|
+
handleSession(user_id, location_id, key, expiry_time, expires, expirationCallback) {
|
|
200
192
|
const expiration_date = new Date(expiry_time * 1000);
|
|
201
|
-
const session = new EsolveSession(user_id, key, expiration_date);
|
|
193
|
+
const session = new EsolveSession(user_id, location_id, key, expiration_date);
|
|
202
194
|
this.cookieService.set(this.storage_key, JSON.stringify(session), expiration_date, '/');
|
|
203
195
|
this._session.next(session);
|
|
204
196
|
this.startTimer(expirationCallback, expires * 1000);
|
|
205
197
|
}
|
|
206
|
-
handleUpdateSession(user_id, callback) {
|
|
198
|
+
handleUpdateSession({ user_id, location_id, }, callback) {
|
|
207
199
|
const current_session = this.currentSession;
|
|
208
|
-
|
|
200
|
+
if (typeof user_id !== 'undefined') {
|
|
201
|
+
current_session.updateUser(user_id);
|
|
202
|
+
}
|
|
203
|
+
if (typeof location_id !== 'undefined') {
|
|
204
|
+
current_session.updateLocation(location_id);
|
|
205
|
+
}
|
|
209
206
|
this.cookieService.set(this.storage_key, JSON.stringify(current_session), current_session.expiration_date, '/');
|
|
210
207
|
this._session.next(current_session);
|
|
211
208
|
if (typeof callback === 'function') {
|
|
212
209
|
callback();
|
|
213
210
|
}
|
|
214
211
|
}
|
|
212
|
+
setStorageKey() {
|
|
213
|
+
if ((typeof this.config.user_session_storage_key === 'string') &&
|
|
214
|
+
(this.config.user_session_storage_key !== '')) {
|
|
215
|
+
this.storage_key = this.config.user_session_storage_key;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
startTimer(callback, duration) {
|
|
219
|
+
if (this.is_browser) {
|
|
220
|
+
this.key_expiration_timer = setTimeout(callback, duration);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
215
223
|
}
|
|
216
224
|
EsolveSessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveSessionService, deps: [{ token: PLATFORM_ID }, { token: ESOLVE_CONNECT_CONFIG }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
217
225
|
EsolveSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveSessionService, providedIn: 'root' });
|
|
@@ -698,7 +706,7 @@ class EsolveAuthService {
|
|
|
698
706
|
throw responseData;
|
|
699
707
|
}
|
|
700
708
|
}), catchError(this.handleError), tap((responseData) => {
|
|
701
|
-
this.handleAuthentication(responseData);
|
|
709
|
+
this.handleAuthentication(responseData.additional_data);
|
|
702
710
|
}));
|
|
703
711
|
}
|
|
704
712
|
autoLogin() {
|
|
@@ -736,8 +744,14 @@ class EsolveAuthService {
|
|
|
736
744
|
for (const response_log of login_response.log) {
|
|
737
745
|
if ((response_log.type === 'success') &&
|
|
738
746
|
(response_log.message_code === 'login_success')) {
|
|
739
|
-
|
|
740
|
-
|
|
747
|
+
const session_data = login_response.session_data;
|
|
748
|
+
const user_id = +login_response.esolve_id;
|
|
749
|
+
const location_id = +session_data.location_id;
|
|
750
|
+
this.session.handleUpdateSession({
|
|
751
|
+
user_id: user_id,
|
|
752
|
+
location_id: location_id
|
|
753
|
+
});
|
|
754
|
+
return user_id;
|
|
741
755
|
}
|
|
742
756
|
}
|
|
743
757
|
throw login_response;
|
|
@@ -766,8 +780,15 @@ class EsolveAuthService {
|
|
|
766
780
|
(!responseData.additional_data.key_okay)) {
|
|
767
781
|
throw responseData;
|
|
768
782
|
}
|
|
769
|
-
|
|
770
|
-
|
|
783
|
+
const additional_data = responseData.additional_data;
|
|
784
|
+
const result = {
|
|
785
|
+
key: token,
|
|
786
|
+
expires: additional_data.expires,
|
|
787
|
+
expiry_time: additional_data.expiry_time,
|
|
788
|
+
location_id: additional_data.location_id,
|
|
789
|
+
user_id: additional_data.user_id,
|
|
790
|
+
};
|
|
791
|
+
return result;
|
|
771
792
|
}))
|
|
772
793
|
.toPromise();
|
|
773
794
|
}
|
|
@@ -781,11 +802,11 @@ class EsolveAuthService {
|
|
|
781
802
|
});
|
|
782
803
|
};
|
|
783
804
|
}
|
|
784
|
-
handleAuthentication(
|
|
785
|
-
if (!
|
|
805
|
+
handleAuthentication(result) {
|
|
806
|
+
if (!result.key) {
|
|
786
807
|
return;
|
|
787
808
|
}
|
|
788
|
-
this.session.handleSession(
|
|
809
|
+
this.session.handleSession(+result.user_id, +result.location_id, result.key, +result.expiry_time, +result.expires, this.handleExpiration());
|
|
789
810
|
}
|
|
790
811
|
handleError(errorRes) {
|
|
791
812
|
const error = {
|
|
@@ -1114,6 +1135,7 @@ class EsolveRegistrationResult extends EsolveResponseResult {
|
|
|
1114
1135
|
this.guest = response.guest;
|
|
1115
1136
|
this.auto_login = response.auto_login;
|
|
1116
1137
|
this.authentication_required = response.authentication_required;
|
|
1138
|
+
this.location_id = response.session_data.location_id;
|
|
1117
1139
|
}
|
|
1118
1140
|
}
|
|
1119
1141
|
|
|
@@ -1134,6 +1156,13 @@ class EsolveResetPasswordResult extends EsolveResponseResult {
|
|
|
1134
1156
|
}
|
|
1135
1157
|
}
|
|
1136
1158
|
|
|
1159
|
+
class EsolveLocationUpdateResult extends EsolveResponseResult {
|
|
1160
|
+
constructor(response) {
|
|
1161
|
+
super(response);
|
|
1162
|
+
this.location_updated = (response.esolve_id > 0);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1137
1166
|
class EsolveAccountService {
|
|
1138
1167
|
constructor(config, http, sessionService, errorHandler, responseHandler) {
|
|
1139
1168
|
this.config = config;
|
|
@@ -1251,7 +1280,10 @@ class EsolveAccountService {
|
|
|
1251
1280
|
})
|
|
1252
1281
|
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
1253
1282
|
if (response.auto_login) {
|
|
1254
|
-
this.sessionService.handleUpdateSession(
|
|
1283
|
+
this.sessionService.handleUpdateSession({
|
|
1284
|
+
user_id: +response.esolve_id,
|
|
1285
|
+
location_id: +response.session_data.location_id,
|
|
1286
|
+
});
|
|
1255
1287
|
}
|
|
1256
1288
|
return new EsolveRegistrationResult(response);
|
|
1257
1289
|
})), catchError((errorRes) => {
|
|
@@ -1304,13 +1336,31 @@ class EsolveAccountService {
|
|
|
1304
1336
|
})
|
|
1305
1337
|
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
1306
1338
|
if (!response.login_required) {
|
|
1307
|
-
this.sessionService.handleUpdateSession(
|
|
1339
|
+
this.sessionService.handleUpdateSession({
|
|
1340
|
+
user_id: +response.esolve_id,
|
|
1341
|
+
location_id: +response.session_data.location_id,
|
|
1342
|
+
});
|
|
1308
1343
|
}
|
|
1309
1344
|
return new EsolveResetPasswordResult(response);
|
|
1310
1345
|
})), catchError((errorRes) => {
|
|
1311
1346
|
return this.errorHandler.handleHttpPostError('set-forgot-password', errorRes);
|
|
1312
1347
|
}));
|
|
1313
1348
|
}
|
|
1349
|
+
updateLocation(location_id) {
|
|
1350
|
+
const body = { location_id };
|
|
1351
|
+
return this.http
|
|
1352
|
+
.post(`${this.config.api_url}/set-session-location.php`, body, {
|
|
1353
|
+
headers: {
|
|
1354
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
1355
|
+
},
|
|
1356
|
+
responseType: 'json',
|
|
1357
|
+
observe: 'body',
|
|
1358
|
+
})
|
|
1359
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
1360
|
+
this.sessionService.handleUpdateSession({ location_id });
|
|
1361
|
+
return new EsolveLocationUpdateResult(response);
|
|
1362
|
+
})));
|
|
1363
|
+
}
|
|
1314
1364
|
getTransactions(options = {}) {
|
|
1315
1365
|
try {
|
|
1316
1366
|
this.loginGuard();
|
|
@@ -3212,4 +3262,3 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
3212
3262
|
*/
|
|
3213
3263
|
|
|
3214
3264
|
export { EsolveAccountService, EsolveAddress, EsolveAddressResult, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveCookieService, EsolveErrorHandlerService, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHeading, EsolveHttpError, EsolveList, EsolveLocationsService, EsolveMediaArticle, EsolveMediaService, EsolveMenuItem, EsolveMenuService, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSEOInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveStockBadge, EsolveStockItem, EsolveStockItemList, EsolveStockLocation, EsolveStockLocationAddress, EsolveStockLocationContactInfo, EsolveStockLocationPOBoxAddress, EsolveStockLocationTradingTimes, EsolveStockLocationTradingTimesDay, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
3215
|
-
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|