@lenne.tech/ng-base 0.3.10 → 0.3.11
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/bundles/lenne.tech-ng-base-src-lib-base.umd.js +15 -22
- package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
- package/bundles/lenne.tech-ng-base.umd.js +15 -22
- package/bundles/lenne.tech-ng-base.umd.js.map +1 -1
- package/esm2015/lib/base/factories/apollo-options.factory.js +13 -23
- package/esm2015/lib/base/services/auth.service.js +4 -1
- package/esm2015/src/lib/base/factories/apollo-options.factory.js +13 -23
- package/esm2015/src/lib/base/services/auth.service.js +4 -1
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js +15 -22
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
- package/fesm2015/lenne.tech-ng-base.js +15 -22
- package/fesm2015/lenne.tech-ng-base.js.map +1 -1
- package/lib/base/services/auth.service.d.ts +2 -0
- package/package.json +1 -1
- package/src/lib/base/lenne.tech-ng-base-src-lib-base.metadata.json +1 -1
- package/src/lib/base/services/auth.service.d.ts +2 -0
|
@@ -190,8 +190,11 @@ class AuthService {
|
|
|
190
190
|
return this._token.value;
|
|
191
191
|
}
|
|
192
192
|
set token(token) {
|
|
193
|
+
var _a, _b;
|
|
193
194
|
this._token.next(token);
|
|
194
195
|
this.storageService.save('token', token);
|
|
196
|
+
(_a = this.subscriptionClient) === null || _a === void 0 ? void 0 : _a.close();
|
|
197
|
+
(_b = this.subscriptionClient) === null || _b === void 0 ? void 0 : _b.connect();
|
|
195
198
|
}
|
|
196
199
|
get tokenObservable() {
|
|
197
200
|
return this._token.asObservable();
|
|
@@ -229,27 +232,17 @@ function apolloOptionsFactory(baseModuleConfig, httpLink, authService) {
|
|
|
229
232
|
return forward(operation);
|
|
230
233
|
});
|
|
231
234
|
if (baseModuleConfig.wsUrl) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
wsClient = new WebSocketLink({
|
|
247
|
-
uri: baseModuleConfig.wsUrl,
|
|
248
|
-
options: {
|
|
249
|
-
reconnect: true,
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
}
|
|
235
|
+
const wsLink = new WebSocketLink({
|
|
236
|
+
uri: baseModuleConfig.wsUrl,
|
|
237
|
+
options: {
|
|
238
|
+
reconnect: true,
|
|
239
|
+
connectionParams: () => ({
|
|
240
|
+
Authorization: authService.token ? 'Bearer ' + authService.token : undefined,
|
|
241
|
+
}),
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
// Set client for reconnection on logout/login
|
|
245
|
+
authService.subscriptionClient = wsLink.subscriptionClient;
|
|
253
246
|
// using the ability to split links, you can send data to each link
|
|
254
247
|
// depending on what kind of operation is being sent
|
|
255
248
|
links.push(split(
|
|
@@ -258,7 +251,7 @@ function apolloOptionsFactory(baseModuleConfig, httpLink, authService) {
|
|
|
258
251
|
// @ts-ignore
|
|
259
252
|
const { kind, operation } = getMainDefinition(query);
|
|
260
253
|
return kind === 'OperationDefinition' && operation === 'subscription';
|
|
261
|
-
},
|
|
254
|
+
}, wsLink, concat(authMiddleware, http)));
|
|
262
255
|
}
|
|
263
256
|
else {
|
|
264
257
|
links.push(http);
|