@progressive-development/pd-spa-helper 0.8.1-b → 0.8.1-c

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PdSpaHelper.d.ts","sourceRoot":"","sources":["../src/PdSpaHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,cAAc,EACd,cAAc,EAEf,MAAM,KAAK,CAAC;AAGb,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,0CAA0C,CAAC;AAClD,OAAO,4CAA4C,CAAC;AACpD,OAAO,qDAAqD,CAAC;AAC7D,OAAO,8CAA8C,CAAC;AAUtD,OAAO,EACL,gBAAgB,EAChB,MAAM,EAGN,cAAc,EACf,MAAM,8CAA8C,CAAC;AAItD,OAAO,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpE,OAAO,gCAAgC,CAAC;AAExC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,8BAA8B,CAAC;AAQtC,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAkD3D;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,gBAAgB,SAmCjD,CAAC;AAIF;;GAEG;AACH,8BAAsB,WAAY,SAAQ,UAAU;IAGlD,KAAK,SAAe;IAEpB;;OAEG;IAEH,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAG3B,QAAQ,EAAE,GAAG,GAAG,SAAS,CAAC;IAG1B,aAAa,EAAE,YAAY,EAAE,CAAM;IAEnC;;;OAGG;IAEH,SAAS,CAAC,MAAM,SAAM;IAEtB;;OAEG;IAEH,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAE/C;;OAEG;IAEH,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAE9C;;OAEG;IAEH,OAAO,CAAC,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E,GAAG;IAexB,qBAAqB,CAAC,CAAC,EAAE,GAAG;IAgB5B,MAAM,CAAC,YAAY;IAUnB,gBAAgB,CAAC,EAAE,EAAE,WAAW;CAYjC"}
@@ -6,7 +6,7 @@ import "@progressive-development/pd-page/pd-footer";
6
6
  import "@progressive-development/pd-content/pd-panel-viewer";
7
7
  import "@progressive-development/pd-content/pd-panel";
8
8
  import { pdStore, initializeStore } from "./store/mini-rx.store.js";
9
- import { authStateChangedImpl, setServiceProvider, initAppImpl, isAuthenticatedWithSessionRedirect } from "./service-provider/service-provider-impl.js";
9
+ import { authStateChangedImpl, setServiceProvider, initAppImpl } from "./service-provider/service-provider-impl.js";
10
10
  import { getLoadingSelector } from "./store/spa-app-selector.js";
11
11
  import { setRouteElement } from "./store/spa-app-effects.js";
12
12
  import { APP_CONF_EVENT } from "./model/spa-model.js";
@@ -25,7 +25,6 @@ var __decorateClass = (decorators, target, key, kind) => {
25
25
  if (result) __defProp(target, key, result);
26
26
  return result;
27
27
  };
28
- const POST_LOGIN_REDIRECT_KEY = "postLoginRedirect";
29
28
  const MADE_BY = {
30
29
  txt: "made by PD Progressive Development",
31
30
  email: "info@progressive-development.com"
@@ -65,7 +64,6 @@ const startInit = (config) => {
65
64
  }
66
65
  navigationConfig = config.navigationConfigParam;
67
66
  transformedRoutes = transformRoutes();
68
- pdRouterService.isAuthenticatedWithSessionRedirect = isAuthenticatedWithSessionRedirect;
69
67
  pdRouterService.configureRoutes(transformedRoutes);
70
68
  document.dispatchEvent(new CustomEvent("init-app-event"));
71
69
  console.log("Init done, Event created");
@@ -162,7 +160,6 @@ const _PdSpaHelper = (_a = class extends LitElement {
162
160
  providerId: ((_a2 = user.providerData[0]) == null ? void 0 : _a2.providerId) ?? "firebase"
163
161
  })
164
162
  );
165
- this._loginSuccess(new CustomEvent("login-success"));
166
163
  } else {
167
164
  pdStore().dispatch(nologin());
168
165
  }
@@ -190,7 +187,7 @@ const _PdSpaHelper = (_a = class extends LitElement {
190
187
  (ls) => html`<pd-loading-state .loadingState="${ls}"></pd-loading-state>`
191
188
  )}
192
189
  ${this._renderRoutePages()}
193
- ${navigationConfig.includeLogin ? html`<default-login
190
+ ${this._route === "login" ? html` <default-login
194
191
  ?active="${this._route === "login"}"
195
192
  ></default-login>` : ""}
196
193
  </main>
@@ -274,17 +271,19 @@ const _PdSpaHelper = (_a = class extends LitElement {
274
271
  `;
275
272
  }
276
273
  _loginSuccess(e) {
277
- const redirectRoute = sessionStorage.getItem(POST_LOGIN_REDIRECT_KEY);
274
+ const redirectRoute = sessionStorage.getItem("postLoginRedirect");
275
+ if (redirectRoute) {
276
+ const routeToNavigate = redirectRoute && redirectRoute !== "/login" ? redirectRoute : "";
277
+ sessionStorage.removeItem("postLoginRedirect");
278
+ this.dispatchEvent(
279
+ new CustomEvent("route-event", {
280
+ detail: { route: routeToNavigate },
281
+ bubbles: true,
282
+ composed: true
283
+ })
284
+ );
285
+ }
278
286
  console.debug("Login Event: ", e, window.location.href, redirectRoute);
279
- const routeToNavigate = redirectRoute && redirectRoute !== "/login" ? redirectRoute : navigationConfig.defaultPostLoginRoute || "";
280
- sessionStorage.removeItem(POST_LOGIN_REDIRECT_KEY);
281
- this.dispatchEvent(
282
- new CustomEvent("route-event", {
283
- detail: { route: routeToNavigate },
284
- bubbles: true,
285
- composed: true
286
- })
287
- );
288
287
  }
289
288
  _localeChange(e) {
290
289
  const newLocale = e.detail;
@@ -466,7 +465,6 @@ __decorateClass([
466
465
  ], _PdSpaHelper.prototype, "_selectedLocale");
467
466
  let PdSpaHelper = _PdSpaHelper;
468
467
  export {
469
- POST_LOGIN_REDIRECT_KEY,
470
468
  PdSpaHelper,
471
469
  startInit
472
470
  };
@@ -5,7 +5,6 @@ declare class PdRouterService {
5
5
  private onChangeHandlers;
6
6
  private currentRoute;
7
7
  constructor();
8
- isAuthenticatedWithSessionRedirect: (routeName: string) => Promise<boolean>;
9
8
  /**
10
9
  * Setzt die Routen-Konfiguration. Muss vor Verwendung von navigate() aufgerufen werden.
11
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PdRouterService.d.ts","sourceRoot":"","sources":["../../src/router/PdRouterService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKnE,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;AAE1D,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAqC;IAEnD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,YAAY,CAAc;;IAS3B,kCAAkC,EAAE,CACzC,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,OAAO,CAAC,CAAoB;IAEzC;;OAEG;IACI,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE;IA8DrD;;OAEG;IACU,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ;IAejD;;OAEG;IACI,aAAa,CAAC,OAAO,EAAE,kBAAkB;IAIhD;;OAEG;YACW,OAAO;CAwDtB;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
1
+ {"version":3,"file":"PdRouterService.d.ts","sourceRoot":"","sources":["../../src/router/PdRouterService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMnE,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;AAE1D,cAAM,eAAe;IACnB,OAAO,CAAC,MAAM,CAAqC;IAEnD,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,YAAY,CAAc;;IAQlC;;OAEG;IACI,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE;IA0ErD;;OAEG;IACU,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAQ;IAejD;;OAEG;IACI,aAAa,CAAC,OAAO,EAAE,kBAAkB;IAIhD;;OAEG;YACW,OAAO;CAwDtB;AAaD,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
@@ -1,18 +1,16 @@
1
1
  import UniversalRouter from "universal-router";
2
2
  import { selectAuthUser } from "../store/spa-app-selector.js";
3
3
  import { pdStore } from "../store/mini-rx.store.js";
4
- import { firstValueFrom, first } from "rxjs";
4
+ import { firstValueFrom, first, filter } from "rxjs";
5
5
  class PdRouterService {
6
6
  constructor() {
7
7
  this.router = null;
8
8
  this.onChangeHandlers = [];
9
9
  this.currentRoute = "";
10
- this.isAuthenticatedWithSessionRedirect = async () => true;
11
10
  window.addEventListener("popstate", () => {
12
11
  this.resolve(location.pathname + location.search);
13
12
  });
14
13
  }
15
- // Default-Fallback, falls nicht überschrieben
16
14
  /**
17
15
  * Setzt die Routen-Konfiguration. Muss vor Verwendung von navigate() aufgerufen werden.
18
16
  */
@@ -36,14 +34,24 @@ class PdRouterService {
36
34
  return patterns.map((pattern) => ({
37
35
  path: pattern,
38
36
  action: async (context) => {
39
- if (def.auth && !context.user) {
40
- const fallbackRoute = def.authFallback ?? "/login";
41
- return { redirect: fallbackRoute };
37
+ var _a, _b;
38
+ if (def.auth) {
39
+ let authResult;
40
+ if (!((_a = context.userCheck) == null ? void 0 : _a.loginCheckFinish)) {
41
+ authResult = await waitForFinalAuthState();
42
+ context.userCheck = authResult;
43
+ }
44
+ if (!((_b = context.userCheck) == null ? void 0 : _b.user)) {
45
+ const fallbackRoute = def.authFallback ?? "/login";
46
+ return { redirect: fallbackRoute };
47
+ }
42
48
  }
43
- if (def.roles && !def.roles.some((role) => {
44
- var _a, _b;
45
- return ((_b = (_a = context.user) == null ? void 0 : _a.claims) == null ? void 0 : _b[role]) === true;
46
- })) {
49
+ if (def.roles && !def.roles.some(
50
+ (role) => {
51
+ var _a2;
52
+ return ((_a2 = context.userCheck.user.claims) == null ? void 0 : _a2[role]) === true;
53
+ }
54
+ )) {
47
55
  return { redirect: "/unauthorized" };
48
56
  }
49
57
  if (def.action) {
@@ -98,12 +106,12 @@ class PdRouterService {
98
106
  "[PdRouter] bevore resolve Current location:",
99
107
  location.pathname
100
108
  );
101
- const user = await firstValueFrom(
109
+ const userCheck = await firstValueFrom(
102
110
  pdStore().select(selectAuthUser).pipe(first())
103
111
  );
104
112
  const result = await this.router.resolve({
105
113
  pathname,
106
- user
114
+ userCheck
107
115
  });
108
116
  if (result.redirect) {
109
117
  history.replaceState({}, "", result.redirect);
@@ -127,6 +135,14 @@ class PdRouterService {
127
135
  }
128
136
  }
129
137
  }
138
+ async function waitForFinalAuthState() {
139
+ return await firstValueFrom(
140
+ pdStore().select(selectAuthUser).pipe(
141
+ filter((res) => res.loginCheckFinish === true),
142
+ first()
143
+ )
144
+ );
145
+ }
130
146
  const pdRouterService = new PdRouterService();
131
147
  export {
132
148
  pdRouterService
@@ -7,7 +7,7 @@ import { initMockResponse, callFunctionMock } from "./mock/function-client.js";
7
7
  import { initFirestorage, uploadFirestorageFile, getFirestorageFileList, getFirestorageFile, downloadFileFirestorage, deleteFirestorageDocument, getFirestorageConf } from "./firebase/firestorage-client.js";
8
8
  import { initStorageMock, uploadStorageFileMock, getMockFileList, downloadFileMock } from "./mock/storage-client.js";
9
9
  import { prepareMessaging, activateTokenChangeHandler, registerDevice, getFirebaseMessaging } from "./firebase/messagingFirebaseClient.js";
10
- import { POST_LOGIN_REDIRECT_KEY } from "../PdSpaHelper.js";
10
+ import "../PdSpaHelper.js";
11
11
  let provider;
12
12
  let app;
13
13
  const throwUndefinedProviderError = () => {
@@ -82,13 +82,6 @@ const isAuthenticatedImpl = () => {
82
82
  }
83
83
  return throwUndefinedProviderError();
84
84
  };
85
- const isAuthenticatedWithSessionRedirect = (routeName) => {
86
- const isAuth = isAuthenticatedImpl();
87
- if (!isAuth && routeName !== "login") {
88
- sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, routeName);
89
- }
90
- return Promise.resolve(isAuth);
91
- };
92
85
  const loginImpl = (user, sec) => {
93
86
  if (!user) {
94
87
  const returnError = new Error("empty user");
@@ -236,7 +229,6 @@ export {
236
229
  getUserIdToken,
237
230
  initAppImpl,
238
231
  isAuthenticatedImpl,
239
- isAuthenticatedWithSessionRedirect,
240
232
  loginImpl,
241
233
  logoutImpl,
242
234
  registerAppDeviceForNotification,
@@ -4,8 +4,15 @@ export interface SpaAppState {
4
4
  loadingState: LoadingState[];
5
5
  lastRoutes?: any[];
6
6
  initIndexDB?: boolean;
7
- userLogin: boolean;
7
+ userLoginDone: boolean;
8
8
  user: AppUser | undefined;
9
9
  }
10
- export declare const spaAppReducer: import('ts-action').Reducer<SpaAppState>;
10
+ export declare const spaAppReducer: import('ts-action').Reducer<{
11
+ userLoginDone: boolean;
12
+ offline?: boolean;
13
+ loadingState: LoadingState[];
14
+ lastRoutes?: any[];
15
+ initIndexDB?: boolean;
16
+ user: AppUser | undefined;
17
+ }>;
11
18
  //# sourceMappingURL=spa-app-reducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spa-app-reducer.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-reducer.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B;AAQD,eAAO,MAAM,aAAa,0CAoDzB,CAAC"}
1
+ {"version":3,"file":"spa-app-reducer.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-reducer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B;AAQD,eAAO,MAAM,aAAa;;cAdd,OAAO;kBACH,YAAY,EAAE;iBACf,GAAG,EAAE;kBACJ,OAAO;UAEf,OAAO,GAAG,SAAS;EAoE1B,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { reducer, on } from "ts-action";
2
- import { updateInternetOffline, addLoadingState, changeSubTask, removeLoadingState, routeAction, initIndexDBSucess, loginSucess, logoutSucess } from "./spa-app-actions.js";
2
+ import { updateInternetOffline, addLoadingState, changeSubTask, removeLoadingState, routeAction, initIndexDBSucess, loginSucess, nologin, logoutSucess } from "./spa-app-actions.js";
3
3
  const initialState = {
4
4
  loadingState: [],
5
- userLogin: false,
5
+ userLoginDone: false,
6
6
  user: void 0
7
7
  };
8
8
  const spaAppReducer = reducer(
@@ -47,10 +47,17 @@ const spaAppReducer = reducer(
47
47
  })),
48
48
  on(loginSucess, (state, { payload }) => ({
49
49
  ...state,
50
- userLogin: true,
50
+ userLoginDone: true,
51
51
  user: payload
52
52
  })),
53
- on(logoutSucess, () => initialState)
53
+ on(nologin, (state) => ({
54
+ ...state,
55
+ userLoginDone: true
56
+ })),
57
+ on(logoutSucess, () => ({
58
+ ...initialState,
59
+ userLoginDone: true
60
+ }))
54
61
  );
55
62
  export {
56
63
  spaAppReducer
@@ -4,5 +4,8 @@ export declare const getInitStatusSelector: import('mini-rx-store/lib/selector.j
4
4
  login: boolean;
5
5
  indexedDB: boolean | undefined;
6
6
  }>;
7
- export declare const selectAuthUser: import('mini-rx-store/lib/selector.js').Selector<object, import('../model/spa-model.js').AppUser | undefined>;
7
+ export declare const selectAuthUser: import('mini-rx-store/lib/selector.js').Selector<object, {
8
+ user: import('../model/spa-model.js').AppUser | undefined;
9
+ loginCheckFinish: boolean;
10
+ }>;
8
11
  //# sourceMappingURL=spa-app-selector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spa-app-selector.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-selector.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,0GAuB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,mEAG9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;EAMjC,CAAC;AAEF,eAAO,MAAM,cAAc,+GAG1B,CAAC"}
1
+ {"version":3,"file":"spa-app-selector.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-selector.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,0GAuB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,mEAG9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;EAMjC,CAAC;AAEF,eAAO,MAAM,cAAc;;;EAM1B,CAAC"}
@@ -28,13 +28,16 @@ const getOfflineSelector = createSelector(
28
28
  const getInitStatusSelector = createSelector(
29
29
  getSpaAppFeatureState,
30
30
  (state) => ({
31
- login: state.userLogin,
31
+ login: state.user !== void 0,
32
32
  indexedDB: state.initIndexDB
33
33
  })
34
34
  );
35
35
  const selectAuthUser = createSelector(
36
36
  getSpaAppFeatureState,
37
- (state) => state.user
37
+ (state) => ({
38
+ user: state.user,
39
+ loginCheckFinish: state.userLoginDone
40
+ })
38
41
  );
39
42
  export {
40
43
  getInitStatusSelector,
@@ -1 +1 @@
1
- {"version":3,"file":"routing.stories.d.ts","sourceRoot":"","sources":["../../src/stories/routing.stories.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,+BAA+B,CAAC;AAGvC,eAAO,MAAM,SAAS,EAAE,cAAc,EA4CrC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAe5B,CAAC;;;;AASF,wBAEE;AAEF,eAAO,MAAM,YAAY,4CAcxB,CAAC"}
1
+ {"version":3,"file":"routing.stories.d.ts","sourceRoot":"","sources":["../../src/stories/routing.stories.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,+BAA+B,CAAC;AAGvC,eAAO,MAAM,SAAS,EAAE,cAAc,EA4CrC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAe5B,CAAC;;;;AAOF,wBAEE;AAEF,eAAO,MAAM,YAAY,4CAcxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progressive-development/pd-spa-helper",
3
- "version": "0.8.1-b",
3
+ "version": "0.8.1-c",
4
4
  "description": "Webcomponent pd-spa-helper following open-wc recommendations",
5
5
  "author": "PD Progressive Development",
6
6
  "license": "SEE LICENSE IN LICENSE",