@progressive-development/pd-spa-helper 0.8.22 → 0.9.1
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/LICENSE +2 -21
- package/dist/auth/AuthController.d.ts +37 -0
- package/dist/auth/AuthController.d.ts.map +1 -0
- package/dist/auth/AuthController.js +65 -0
- package/dist/auth/auth-directives.d.ts +59 -0
- package/dist/auth/auth-directives.d.ts.map +1 -0
- package/dist/auth/auth-directives.js +81 -0
- package/dist/auth/auth-utils.d.ts +45 -0
- package/dist/auth/auth-utils.d.ts.map +1 -0
- package/dist/auth/auth-utils.js +42 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/components/default-login/DefaultLogin.d.ts +15 -0
- package/dist/components/default-login/DefaultLogin.d.ts.map +1 -0
- package/dist/components/default-login/DefaultLogin.js +120 -0
- package/dist/components/default-not-found/DefaultNotFound.d.ts +6 -0
- package/dist/components/default-not-found/DefaultNotFound.d.ts.map +1 -0
- package/dist/{defaultpage/default-not-found.js → components/default-not-found/DefaultNotFound.js} +15 -8
- package/dist/components/pd-section-page/PdSectionPage.d.ts +55 -0
- package/dist/components/pd-section-page/PdSectionPage.d.ts.map +1 -0
- package/dist/components/pd-section-page/PdSectionPage.js +40 -0
- package/dist/components/pd-spa-helper/PdSpaHelper.d.ts +160 -0
- package/dist/components/pd-spa-helper/PdSpaHelper.d.ts.map +1 -0
- package/dist/components/pd-spa-helper/PdSpaHelper.js +651 -0
- package/dist/components/pd-spa-helper/controllers/ScrollController.d.ts +77 -0
- package/dist/components/pd-spa-helper/controllers/ScrollController.d.ts.map +1 -0
- package/dist/components/pd-spa-helper/controllers/ScrollController.js +102 -0
- package/dist/components/pd-spa-helper/spa-config.d.ts +87 -0
- package/dist/components/pd-spa-helper/spa-config.d.ts.map +1 -0
- package/dist/components/pd-spa-helper/spa-config.js +167 -0
- package/dist/components/pd-spa-helper/spa-events.d.ts +121 -0
- package/dist/components/pd-spa-helper/spa-events.d.ts.map +1 -0
- package/dist/components/pd-spa-helper/spa-events.js +18 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/{store → db}/indexDB.d.ts +9 -9
- package/dist/db/indexDB.d.ts.map +1 -0
- package/dist/{store → db}/indexDB.js +18 -27
- package/dist/generated/locale-wrapper/be-wrapper.js +10 -10
- package/dist/generated/locale-wrapper/de-wrapper.js +10 -10
- package/dist/generated/locale-wrapper/en-wrapper.js +10 -10
- package/dist/generated/locales/be.d.ts +1 -15
- package/dist/generated/locales/be.d.ts.map +1 -1
- package/dist/generated/locales/be.js +3 -18
- package/dist/generated/locales/de.d.ts +1 -15
- package/dist/generated/locales/de.d.ts.map +1 -1
- package/dist/generated/locales/de.js +3 -18
- package/dist/generated/locales/en.d.ts +1 -15
- package/dist/generated/locales/en.d.ts.map +1 -1
- package/dist/generated/locales/en.js +3 -18
- package/dist/helper/logger.d.ts +11 -12
- package/dist/helper/logger.d.ts.map +1 -1
- package/dist/helper/logger.js +12 -53
- package/dist/helper/offline-watcher-helper.js +5 -6
- package/dist/helper/refresh-id-token.d.ts.map +1 -1
- package/dist/helper/refresh-id-token.js +10 -8
- package/dist/index.d.ts +31 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -91
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/spa-model.d.ts +14 -15
- package/dist/model/spa-model.d.ts.map +1 -1
- package/dist/model/spa-model.js +2 -4
- package/dist/router/PdRouterService.d.ts +4 -1
- package/dist/router/PdRouterService.d.ts.map +1 -1
- package/dist/router/PdRouterService.js +48 -28
- package/dist/router/index.d.ts +3 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/screen-size/ScreenSizeController.d.ts +34 -0
- package/dist/screen-size/ScreenSizeController.d.ts.map +1 -0
- package/dist/screen-size/ScreenSizeController.js +58 -0
- package/dist/screen-size/ScreenSizeService.d.ts +49 -0
- package/dist/screen-size/ScreenSizeService.d.ts.map +1 -0
- package/dist/screen-size/ScreenSizeService.js +107 -0
- package/dist/screen-size/index.d.ts +13 -0
- package/dist/screen-size/index.d.ts.map +1 -0
- package/dist/screen-size/responsive-directives.d.ts +59 -0
- package/dist/screen-size/responsive-directives.d.ts.map +1 -0
- package/dist/screen-size/responsive-directives.js +71 -0
- package/dist/screen-size/types.d.ts +44 -0
- package/dist/screen-size/types.d.ts.map +1 -0
- package/dist/service-provider/ServiceRegistry.d.ts +67 -0
- package/dist/service-provider/ServiceRegistry.d.ts.map +1 -0
- package/dist/service-provider/ServiceRegistry.js +76 -0
- package/dist/service-provider/function-utils.d.ts +55 -0
- package/dist/service-provider/function-utils.d.ts.map +1 -0
- package/dist/service-provider/function-utils.js +30 -0
- package/dist/service-provider/index.d.ts +10 -0
- package/dist/service-provider/index.d.ts.map +1 -0
- package/dist/service-provider/interfaces/IAuthProvider.d.ts +68 -0
- package/dist/service-provider/interfaces/IAuthProvider.d.ts.map +1 -0
- package/dist/service-provider/interfaces/IDatabaseProvider.d.ts +75 -0
- package/dist/service-provider/interfaces/IDatabaseProvider.d.ts.map +1 -0
- package/dist/service-provider/interfaces/IFunctionProvider.d.ts +49 -0
- package/dist/service-provider/interfaces/IFunctionProvider.d.ts.map +1 -0
- package/dist/service-provider/interfaces/IStorageProvider.d.ts +118 -0
- package/dist/service-provider/interfaces/IStorageProvider.d.ts.map +1 -0
- package/dist/service-provider/interfaces/ServiceProvider.d.ts +24 -0
- package/dist/service-provider/interfaces/ServiceProvider.d.ts.map +1 -0
- package/dist/service-provider/interfaces/common.d.ts +5 -0
- package/dist/service-provider/interfaces/common.d.ts.map +1 -0
- package/dist/service-provider/service-provider-model.d.ts +26 -7
- package/dist/service-provider/service-provider-model.d.ts.map +1 -1
- package/dist/service-provider/service-provider-model.js +2 -5
- package/dist/services/fire-once-service.d.ts +35 -0
- package/dist/services/fire-once-service.d.ts.map +1 -0
- package/dist/services/fire-once-service.js +61 -0
- package/dist/store/async-action-effects.d.ts +179 -0
- package/dist/store/async-action-effects.d.ts.map +1 -0
- package/dist/store/async-action-effects.js +97 -0
- package/dist/store/async-action-utils.d.ts +151 -0
- package/dist/store/async-action-utils.d.ts.map +1 -0
- package/dist/store/async-action-utils.js +41 -0
- package/dist/store/index.d.ts +9 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/mini-rx.store.d.ts.map +1 -1
- package/dist/store/mini-rx.store.js +7 -10
- package/dist/store/spa-app-actions.d.ts +5 -22
- package/dist/store/spa-app-actions.d.ts.map +1 -1
- package/dist/store/spa-app-actions.js +7 -23
- package/dist/store/spa-app-effects.d.ts +0 -17
- package/dist/store/spa-app-effects.d.ts.map +1 -1
- package/dist/store/spa-app-effects.js +8 -49
- package/dist/store/spa-app-reducer.d.ts +5 -10
- package/dist/store/spa-app-reducer.d.ts.map +1 -1
- package/dist/store/spa-app-reducer.js +26 -21
- package/dist/store/spa-app-selector.d.ts +2 -2
- package/dist/store/spa-app-selector.d.ts.map +1 -1
- package/dist/store/spa-app-selector.js +5 -11
- package/dist/stories/introduction.stories.d.ts +11 -0
- package/dist/stories/introduction.stories.d.ts.map +1 -0
- package/package.json +36 -53
- package/dist/PdSpaHelper.d.ts +0 -83
- package/dist/PdSpaHelper.d.ts.map +0 -1
- package/dist/PdSpaHelper.js +0 -496
- package/dist/defaultpage/default-confirm-popup.d.ts +0 -19
- package/dist/defaultpage/default-confirm-popup.d.ts.map +0 -1
- package/dist/defaultpage/default-confirm-popup.js +0 -73
- package/dist/defaultpage/default-dialog-popup.d.ts +0 -19
- package/dist/defaultpage/default-dialog-popup.d.ts.map +0 -1
- package/dist/defaultpage/default-dialog-popup.js +0 -103
- package/dist/defaultpage/default-login.d.ts +0 -6
- package/dist/defaultpage/default-login.d.ts.map +0 -1
- package/dist/defaultpage/default-login.js +0 -33
- package/dist/defaultpage/default-not-found.d.ts +0 -6
- package/dist/defaultpage/default-not-found.d.ts.map +0 -1
- package/dist/defaultpage/default-popup.d.ts +0 -7
- package/dist/defaultpage/default-popup.d.ts.map +0 -1
- package/dist/defaultpage/default-popup.js +0 -23
- package/dist/defaultpage/default-step-address.d.ts +0 -14
- package/dist/defaultpage/default-step-address.d.ts.map +0 -1
- package/dist/defaultpage/default-step-address.js +0 -78
- package/dist/defaultpage/default-step-summary.d.ts +0 -28
- package/dist/defaultpage/default-step-summary.d.ts.map +0 -1
- package/dist/defaultpage/default-step-summary.js +0 -66
- package/dist/defaultpage/default-view-page.d.ts +0 -10
- package/dist/defaultpage/default-view-page.d.ts.map +0 -1
- package/dist/defaultpage/default-view-page.js +0 -67
- package/dist/defaultpage/default-wizard.d.ts +0 -37
- package/dist/defaultpage/default-wizard.d.ts.map +0 -1
- package/dist/defaultpage/default-wizard.js +0 -264
- package/dist/defaultpage/pd-default-wizard-step.d.ts +0 -58
- package/dist/defaultpage/pd-default-wizard-step.d.ts.map +0 -1
- package/dist/defaultpage/pd-default-wizard-step.js +0 -147
- package/dist/generated/locale-wrapper/be-wrapper.d.ts +0 -62
- package/dist/generated/locale-wrapper/be-wrapper.d.ts.map +0 -1
- package/dist/generated/locale-wrapper/de-wrapper.d.ts +0 -62
- package/dist/generated/locale-wrapper/de-wrapper.d.ts.map +0 -1
- package/dist/generated/locale-wrapper/en-wrapper.d.ts +0 -62
- package/dist/generated/locale-wrapper/en-wrapper.d.ts.map +0 -1
- package/dist/helper/blob-helper.d.ts +0 -3
- package/dist/helper/blob-helper.d.ts.map +0 -1
- package/dist/helper/blob-helper.js +0 -37
- package/dist/helper/date-helper.d.ts +0 -27
- package/dist/helper/date-helper.d.ts.map +0 -1
- package/dist/helper/date-helper.js +0 -138
- package/dist/helper/locale-format.d.ts +0 -4
- package/dist/helper/locale-format.d.ts.map +0 -1
- package/dist/helper/locale-format.js +0 -19
- package/dist/helper/number-helper.d.ts +0 -2
- package/dist/helper/number-helper.d.ts.map +0 -1
- package/dist/helper/number-helper.js +0 -14
- package/dist/helper/price-helper.d.ts +0 -5
- package/dist/helper/price-helper.d.ts.map +0 -1
- package/dist/helper/price-helper.js +0 -25
- package/dist/helper/text-helper.d.ts +0 -3
- package/dist/helper/text-helper.d.ts.map +0 -1
- package/dist/helper/text-helper.js +0 -6
- package/dist/popup/wizard-close-popup.d.ts +0 -11
- package/dist/popup/wizard-close-popup.d.ts.map +0 -1
- package/dist/popup/wizard-close-popup.js +0 -63
- package/dist/popup/wizard-reload-popup.d.ts +0 -14
- package/dist/popup/wizard-reload-popup.d.ts.map +0 -1
- package/dist/popup/wizard-reload-popup.js +0 -76
- package/dist/service-provider/firebase/auth.d.ts +0 -19
- package/dist/service-provider/firebase/auth.d.ts.map +0 -1
- package/dist/service-provider/firebase/auth.js +0 -69
- package/dist/service-provider/firebase/firestorage-client.d.ts +0 -22
- package/dist/service-provider/firebase/firestorage-client.d.ts.map +0 -1
- package/dist/service-provider/firebase/firestorage-client.js +0 -237
- package/dist/service-provider/firebase/firestore-client.d.ts +0 -12
- package/dist/service-provider/firebase/firestore-client.d.ts.map +0 -1
- package/dist/service-provider/firebase/firestore-client.js +0 -26
- package/dist/service-provider/firebase/functions-client.d.ts +0 -10
- package/dist/service-provider/firebase/functions-client.d.ts.map +0 -1
- package/dist/service-provider/firebase/functions-client.js +0 -64
- package/dist/service-provider/firebase/messagingFirebaseClient.d.ts +0 -9
- package/dist/service-provider/firebase/messagingFirebaseClient.d.ts.map +0 -1
- package/dist/service-provider/firebase/messagingFirebaseClient.js +0 -73
- package/dist/service-provider/mock/auth.d.ts +0 -6
- package/dist/service-provider/mock/auth.d.ts.map +0 -1
- package/dist/service-provider/mock/auth.js +0 -65
- package/dist/service-provider/mock/function-client.d.ts +0 -7
- package/dist/service-provider/mock/function-client.d.ts.map +0 -1
- package/dist/service-provider/mock/function-client.js +0 -32
- package/dist/service-provider/mock/storage-client.d.ts +0 -11
- package/dist/service-provider/mock/storage-client.d.ts.map +0 -1
- package/dist/service-provider/mock/storage-client.js +0 -110
- package/dist/service-provider/service-provider-impl.d.ts +0 -27
- package/dist/service-provider/service-provider-impl.d.ts.map +0 -1
- package/dist/service-provider/service-provider-impl.js +0 -241
- package/dist/store/indexDB.d.ts.map +0 -1
- package/dist/stories/address-edit.stories.d.ts +0 -27
- package/dist/stories/address-edit.stories.d.ts.map +0 -1
- package/dist/stories/address-new.stories.d.ts +0 -33
- package/dist/stories/address-new.stories.d.ts.map +0 -1
- package/dist/stories/default-confirm-popup.stories.d.ts +0 -24
- package/dist/stories/default-confirm-popup.stories.d.ts.map +0 -1
- package/dist/stories/default-dialog-popup.stories.d.ts +0 -23
- package/dist/stories/default-dialog-popup.stories.d.ts.map +0 -1
- package/dist/stories/default-login.stories.d.ts +0 -10
- package/dist/stories/default-login.stories.d.ts.map +0 -1
- package/dist/stories/default-popup.stories.d.ts +0 -9
- package/dist/stories/default-popup.stories.d.ts.map +0 -1
- package/dist/stories/pd-loading-state.stories.d.ts +0 -30
- package/dist/stories/pd-loading-state.stories.d.ts.map +0 -1
- package/dist/stories/pd-toast.stories.d.ts +0 -27
- package/dist/stories/pd-toast.stories.d.ts.map +0 -1
- package/dist/stories/routing.stories.d.ts +0 -24
- package/dist/stories/routing.stories.d.ts.map +0 -1
- package/dist/stories/test-impls/address-test.d.ts +0 -6
- package/dist/stories/test-impls/address-test.d.ts.map +0 -1
- package/dist/stories/test-impls/test-mock-app.d.ts +0 -15
- package/dist/stories/test-impls/test-mock-app.d.ts.map +0 -1
- package/dist/stories/test-impls/test-pages/test-home-page.d.ts +0 -7
- package/dist/stories/test-impls/test-pages/test-home-page.d.ts.map +0 -1
- package/dist/stories/test-impls/test-pages/test-not-found-page.d.ts +0 -5
- package/dist/stories/test-impls/test-pages/test-not-found-page.d.ts.map +0 -1
- package/dist/stories/test-impls/test-pages/test-wizard-step.d.ts +0 -17
- package/dist/stories/test-impls/test-pages/test-wizard-step.d.ts.map +0 -1
- package/dist/stories/test-impls/test-pages/test-wizard.d.ts +0 -16
- package/dist/stories/test-impls/test-pages/test-wizard.d.ts.map +0 -1
- package/dist/stories/test-impls/test-popups/default-confirm-popup-test-error.d.ts +0 -8
- package/dist/stories/test-impls/test-popups/default-confirm-popup-test-error.d.ts.map +0 -1
- package/dist/stories/test-impls/test-popups/default-confirm-popup-test-info.d.ts +0 -8
- package/dist/stories/test-impls/test-popups/default-confirm-popup-test-info.d.ts.map +0 -1
- package/dist/stories/test-impls/test-popups/default-confirm-popup-test-warn.d.ts +0 -8
- package/dist/stories/test-impls/test-popups/default-confirm-popup-test-warn.d.ts.map +0 -1
- package/dist/stories/test-impls/test-popups/default-dialog-popup-test.d.ts +0 -13
- package/dist/stories/test-impls/test-popups/default-dialog-popup-test.d.ts.map +0 -1
- package/dist/stories/test-impls/test-popups/default-popup-test.d.ts +0 -5
- package/dist/stories/test-impls/test-popups/default-popup-test.d.ts.map +0 -1
- package/dist/stories/test-wizard-step.stories.d.ts +0 -11
- package/dist/stories/test-wizard-step.stories.d.ts.map +0 -1
- package/dist/stories/test-wizard.stories.d.ts +0 -9
- package/dist/stories/test-wizard.stories.d.ts.map +0 -1
- package/dist/tmpown/pd-loading-state.d.ts +0 -9
- package/dist/tmpown/pd-loading-state.d.ts.map +0 -1
- package/dist/tmpown/pd-loading-state.js +0 -196
- package/dist/tmpown/pd-login.d.ts +0 -13
- package/dist/tmpown/pd-login.d.ts.map +0 -1
- package/dist/tmpown/pd-login.js +0 -165
- package/dist/tmpown/pd-toast.d.ts +0 -13
- package/dist/tmpown/pd-toast.d.ts.map +0 -1
- package/dist/tmpown/pd-toast.js +0 -128
package/LICENSE
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 pd-spa-helper
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
No License, all rights reserved
|
|
2
|
+
@2021 - PD Progressive Development UG
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import { AppUser } from '../model/spa-model.js';
|
|
3
|
+
export declare class AuthController implements ReactiveController {
|
|
4
|
+
private host;
|
|
5
|
+
private subscription?;
|
|
6
|
+
/** Current user or undefined if not logged in */
|
|
7
|
+
user: AppUser | undefined;
|
|
8
|
+
/** Whether the initial auth check is complete */
|
|
9
|
+
authCheckComplete: boolean;
|
|
10
|
+
constructor(host: ReactiveControllerHost);
|
|
11
|
+
hostConnected(): void;
|
|
12
|
+
hostDisconnected(): void;
|
|
13
|
+
/** Check if user is logged in */
|
|
14
|
+
get isLoggedIn(): boolean;
|
|
15
|
+
/** Get user's email */
|
|
16
|
+
get email(): string | null;
|
|
17
|
+
/** Get user's UID */
|
|
18
|
+
get uid(): string | null;
|
|
19
|
+
/** Get user's claims */
|
|
20
|
+
get claims(): Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if user has a specific role
|
|
23
|
+
* @param role - The role to check
|
|
24
|
+
*/
|
|
25
|
+
hasRole(role: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if user has at least one of the roles (OR logic)
|
|
28
|
+
* @param roles - Array of roles to check
|
|
29
|
+
*/
|
|
30
|
+
hasAnyRole(roles: string[]): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if user has all of the roles (AND logic)
|
|
33
|
+
* @param roles - Array of roles to check
|
|
34
|
+
*/
|
|
35
|
+
hasAllRoles(roles: string[]): boolean;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=AuthController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthController.d.ts","sourceRoot":"","sources":["../../src/auth/AuthController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAC;AAKtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,qBAAa,cAAe,YAAW,kBAAkB;IACvD,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,YAAY,CAAC,CAAe;IAEpC,iDAAiD;IACjD,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAE1B,iDAAiD;IACjD,iBAAiB,EAAE,OAAO,CAAS;gBAEvB,IAAI,EAAE,sBAAsB;IAKxC,aAAa,IAAI,IAAI;IAUrB,gBAAgB,IAAI,IAAI;IAQxB,iCAAiC;IACjC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,uBAAuB;IACvB,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,qBAAqB;IACrB,IAAI,GAAG,IAAI,MAAM,GAAG,IAAI,CAEvB;IAED,wBAAwB;IACxB,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEpC;IAED;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO;IAKpC;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO;CAItC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { pdStore } from '../store/mini-rx.store.js';
|
|
2
|
+
import { selectAuthUser } from '../store/spa-app-selector.js';
|
|
3
|
+
|
|
4
|
+
class AuthController {
|
|
5
|
+
constructor(host) {
|
|
6
|
+
/** Whether the initial auth check is complete */
|
|
7
|
+
this.authCheckComplete = false;
|
|
8
|
+
this.host = host;
|
|
9
|
+
host.addController(this);
|
|
10
|
+
}
|
|
11
|
+
hostConnected() {
|
|
12
|
+
this.subscription = pdStore().select(selectAuthUser).subscribe(({ user, loginCheckFinish }) => {
|
|
13
|
+
this.user = user;
|
|
14
|
+
this.authCheckComplete = loginCheckFinish;
|
|
15
|
+
this.host.requestUpdate();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
hostDisconnected() {
|
|
19
|
+
this.subscription?.unsubscribe();
|
|
20
|
+
}
|
|
21
|
+
// -------------------------------------------------------------------------
|
|
22
|
+
// Convenience getters and methods
|
|
23
|
+
// -------------------------------------------------------------------------
|
|
24
|
+
/** Check if user is logged in */
|
|
25
|
+
get isLoggedIn() {
|
|
26
|
+
return this.user !== void 0;
|
|
27
|
+
}
|
|
28
|
+
/** Get user's email */
|
|
29
|
+
get email() {
|
|
30
|
+
return this.user?.email ?? null;
|
|
31
|
+
}
|
|
32
|
+
/** Get user's UID */
|
|
33
|
+
get uid() {
|
|
34
|
+
return this.user?.uid ?? null;
|
|
35
|
+
}
|
|
36
|
+
/** Get user's claims */
|
|
37
|
+
get claims() {
|
|
38
|
+
return this.user?.claims ?? {};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if user has a specific role
|
|
42
|
+
* @param role - The role to check
|
|
43
|
+
*/
|
|
44
|
+
hasRole(role) {
|
|
45
|
+
return this.user?.claims?.[role] === true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if user has at least one of the roles (OR logic)
|
|
49
|
+
* @param roles - Array of roles to check
|
|
50
|
+
*/
|
|
51
|
+
hasAnyRole(roles) {
|
|
52
|
+
if (!this.user?.claims) return false;
|
|
53
|
+
return roles.some((role) => this.user?.claims?.[role] === true);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if user has all of the roles (AND logic)
|
|
57
|
+
* @param roles - Array of roles to check
|
|
58
|
+
*/
|
|
59
|
+
hasAllRoles(roles) {
|
|
60
|
+
if (!this.user?.claims) return false;
|
|
61
|
+
return roles.every((role) => this.user?.claims?.[role] === true);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { AuthController };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { noChange, TemplateResult } from 'lit';
|
|
2
|
+
import { AsyncDirective } from 'lit/async-directive.js';
|
|
3
|
+
import { AppUser } from '../model/spa-model.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for auth directives - handles store subscription
|
|
6
|
+
*/
|
|
7
|
+
declare abstract class AuthDirectiveBase extends AsyncDirective {
|
|
8
|
+
private subscription?;
|
|
9
|
+
protected user?: AppUser;
|
|
10
|
+
protected authCheckComplete: boolean;
|
|
11
|
+
disconnected(): void;
|
|
12
|
+
reconnected(): void;
|
|
13
|
+
protected subscribe(): void;
|
|
14
|
+
protected abstract computeValue(): TemplateResult | string | typeof noChange;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ifAuth - renders content only if user is logged in
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ${ifAuth(html`<user-menu></user-menu>`)}
|
|
21
|
+
* ${ifAuth(html`<profile-link></profile-link>`, html`<login-button></login-button>`)}
|
|
22
|
+
*/
|
|
23
|
+
declare class IfAuthDirective extends AuthDirectiveBase {
|
|
24
|
+
private content?;
|
|
25
|
+
private fallback?;
|
|
26
|
+
render(content: TemplateResult, fallback?: TemplateResult | string): string | TemplateResult;
|
|
27
|
+
protected computeValue(): TemplateResult | string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* ifRole - renders content only if user has at least one of the specified roles
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ${ifRole('admin', html`<admin-panel></admin-panel>`)}
|
|
34
|
+
* ${ifRole(['admin', 'editor'], html`<edit-btn></edit-btn>`, html`<span>Read only</span>`)}
|
|
35
|
+
*/
|
|
36
|
+
declare class IfRoleDirective extends AuthDirectiveBase {
|
|
37
|
+
private roles;
|
|
38
|
+
private content?;
|
|
39
|
+
private fallback?;
|
|
40
|
+
render(roles: string | string[], content: TemplateResult, fallback?: TemplateResult | string): string | TemplateResult;
|
|
41
|
+
protected computeValue(): TemplateResult | string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* ifNotAuth - renders content only if user is NOT logged in
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ${ifNotAuth(html`<login-button></login-button>`)}
|
|
48
|
+
*/
|
|
49
|
+
declare class IfNotAuthDirective extends AuthDirectiveBase {
|
|
50
|
+
private content?;
|
|
51
|
+
private fallback?;
|
|
52
|
+
render(content: TemplateResult, fallback?: TemplateResult | string): string | TemplateResult;
|
|
53
|
+
protected computeValue(): TemplateResult | string;
|
|
54
|
+
}
|
|
55
|
+
export declare const ifAuth: (content: TemplateResult, fallback?: string | TemplateResult | undefined) => import('lit/async-directive.js').DirectiveResult<typeof IfAuthDirective>;
|
|
56
|
+
export declare const ifRole: (roles: string | string[], content: TemplateResult, fallback?: string | TemplateResult | undefined) => import('lit/async-directive.js').DirectiveResult<typeof IfRoleDirective>;
|
|
57
|
+
export declare const ifNotAuth: (content: TemplateResult, fallback?: string | TemplateResult | undefined) => import('lit/async-directive.js').DirectiveResult<typeof IfNotAuthDirective>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=auth-directives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-directives.d.ts","sourceRoot":"","sources":["../../src/auth/auth-directives.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAa,MAAM,wBAAwB,CAAC;AAKnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD;;GAEG;AACH,uBAAe,iBAAkB,SAAQ,cAAc;IACrD,OAAO,CAAC,YAAY,CAAC,CAAe;IACpC,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,iBAAiB,UAAS;IAE3B,YAAY;IAIZ,WAAW;IAIpB,SAAS,CAAC,SAAS;IAgBnB,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,cAAc,GAAG,MAAM,GAAG,OAAO,QAAQ;CAC7E;AAED;;;;;;GAMG;AACH,cAAM,eAAgB,SAAQ,iBAAiB;IAC7C,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAAC,CAA0B;IAE3C,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM;cAO/C,YAAY,IAAI,cAAc,GAAG,MAAM;CAQ3D;AAED;;;;;;GAMG;AACH,cAAM,eAAgB,SAAQ,iBAAiB;IAC7C,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAAC,CAA0B;IAE3C,MAAM,CACJ,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,OAAO,EAAE,cAAc,EACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM;cASjB,YAAY,IAAI,cAAc,GAAG,MAAM;CAa3D;AAED;;;;;GAKG;AACH,cAAM,kBAAmB,SAAQ,iBAAiB;IAChD,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAAC,CAA0B;IAE3C,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM;cAO/C,YAAY,IAAI,cAAc,GAAG,MAAM;CAQ3D;AAGD,eAAO,MAAM,MAAM,uJAA6B,CAAC;AACjD,eAAO,MAAM,MAAM,iLAA6B,CAAC;AACjD,eAAO,MAAM,SAAS,0JAAgC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { directive, AsyncDirective } from 'lit/async-directive.js';
|
|
2
|
+
import { pdStore } from '../store/mini-rx.store.js';
|
|
3
|
+
import { selectAuthUser } from '../store/spa-app-selector.js';
|
|
4
|
+
|
|
5
|
+
class AuthDirectiveBase extends AsyncDirective {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.authCheckComplete = false;
|
|
9
|
+
}
|
|
10
|
+
disconnected() {
|
|
11
|
+
this.subscription?.unsubscribe();
|
|
12
|
+
}
|
|
13
|
+
reconnected() {
|
|
14
|
+
this.subscribe();
|
|
15
|
+
}
|
|
16
|
+
subscribe() {
|
|
17
|
+
if (this.subscription) return;
|
|
18
|
+
const store = pdStore();
|
|
19
|
+
if (!store) return;
|
|
20
|
+
this.subscription = store.select(selectAuthUser).subscribe(({ user, loginCheckFinish }) => {
|
|
21
|
+
this.user = user;
|
|
22
|
+
this.authCheckComplete = loginCheckFinish;
|
|
23
|
+
this.setValue(this.computeValue());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class IfAuthDirective extends AuthDirectiveBase {
|
|
28
|
+
render(content, fallback) {
|
|
29
|
+
this.content = content;
|
|
30
|
+
this.fallback = fallback ?? "";
|
|
31
|
+
this.subscribe();
|
|
32
|
+
return this.computeValue();
|
|
33
|
+
}
|
|
34
|
+
computeValue() {
|
|
35
|
+
if (!this.authCheckComplete) {
|
|
36
|
+
return this.fallback ?? "";
|
|
37
|
+
}
|
|
38
|
+
return this.user ? this.content ?? "" : this.fallback ?? "";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class IfRoleDirective extends AuthDirectiveBase {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.roles = [];
|
|
45
|
+
}
|
|
46
|
+
render(roles, content, fallback) {
|
|
47
|
+
this.roles = Array.isArray(roles) ? roles : [roles];
|
|
48
|
+
this.content = content;
|
|
49
|
+
this.fallback = fallback ?? "";
|
|
50
|
+
this.subscribe();
|
|
51
|
+
return this.computeValue();
|
|
52
|
+
}
|
|
53
|
+
computeValue() {
|
|
54
|
+
if (!this.authCheckComplete) {
|
|
55
|
+
return this.fallback ?? "";
|
|
56
|
+
}
|
|
57
|
+
const hasRequiredRole = this.roles.some(
|
|
58
|
+
(role) => this.user?.claims?.[role] === true
|
|
59
|
+
);
|
|
60
|
+
return hasRequiredRole ? this.content ?? "" : this.fallback ?? "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class IfNotAuthDirective extends AuthDirectiveBase {
|
|
64
|
+
render(content, fallback) {
|
|
65
|
+
this.content = content;
|
|
66
|
+
this.fallback = fallback ?? "";
|
|
67
|
+
this.subscribe();
|
|
68
|
+
return this.computeValue();
|
|
69
|
+
}
|
|
70
|
+
computeValue() {
|
|
71
|
+
if (!this.authCheckComplete) {
|
|
72
|
+
return this.fallback ?? "";
|
|
73
|
+
}
|
|
74
|
+
return !this.user ? this.content ?? "" : this.fallback ?? "";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const ifAuth = directive(IfAuthDirective);
|
|
78
|
+
const ifRole = directive(IfRoleDirective);
|
|
79
|
+
const ifNotAuth = directive(IfNotAuthDirective);
|
|
80
|
+
|
|
81
|
+
export { ifAuth, ifNotAuth, ifRole };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AppUser } from '../model/spa-model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the current user from the store
|
|
4
|
+
* @returns The current AppUser or undefined if not logged in
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCurrentUser(): Promise<AppUser | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a user is currently logged in
|
|
9
|
+
* @returns true if a user is logged in
|
|
10
|
+
*/
|
|
11
|
+
export declare function isLoggedIn(): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if the current user has a specific role/claim
|
|
14
|
+
* @param role - The role to check (e.g., "admin", "editor")
|
|
15
|
+
* @returns true if the user has the role
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasRole(role: string): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if the current user has at least one of the specified roles (OR logic)
|
|
20
|
+
* @param roles - Array of roles to check
|
|
21
|
+
* @returns true if the user has at least one of the roles
|
|
22
|
+
*/
|
|
23
|
+
export declare function hasAnyRole(roles: string[]): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if the current user has all of the specified roles (AND logic)
|
|
26
|
+
* @param roles - Array of roles to check
|
|
27
|
+
* @returns true if the user has all of the roles
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasAllRoles(roles: string[]): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the user's email
|
|
32
|
+
* @returns The user's email or null if not logged in
|
|
33
|
+
*/
|
|
34
|
+
export declare function getUserEmail(): Promise<string | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the user's UID
|
|
37
|
+
* @returns The user's UID or null if not logged in
|
|
38
|
+
*/
|
|
39
|
+
export declare function getUserId(): Promise<string | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Get all claims for the current user
|
|
42
|
+
* @returns Record of claims or empty object
|
|
43
|
+
*/
|
|
44
|
+
export declare function getUserClaims(): Promise<Record<string, unknown>>;
|
|
45
|
+
//# sourceMappingURL=auth-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/auth/auth-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAKnE;AAED;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAGnD;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG5D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAIlE;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAInE;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAG3D;AAED;;;GAGG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxD;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAGtE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { firstValueFrom, first } from 'rxjs';
|
|
2
|
+
import { pdStore } from '../store/mini-rx.store.js';
|
|
3
|
+
import { selectAuthUser } from '../store/spa-app-selector.js';
|
|
4
|
+
|
|
5
|
+
async function getCurrentUser() {
|
|
6
|
+
const { user } = await firstValueFrom(
|
|
7
|
+
pdStore().select(selectAuthUser).pipe(first())
|
|
8
|
+
);
|
|
9
|
+
return user;
|
|
10
|
+
}
|
|
11
|
+
async function isLoggedIn() {
|
|
12
|
+
const user = await getCurrentUser();
|
|
13
|
+
return user !== void 0;
|
|
14
|
+
}
|
|
15
|
+
async function hasRole(role) {
|
|
16
|
+
const user = await getCurrentUser();
|
|
17
|
+
return user?.claims?.[role] === true;
|
|
18
|
+
}
|
|
19
|
+
async function hasAnyRole(roles) {
|
|
20
|
+
const user = await getCurrentUser();
|
|
21
|
+
if (!user?.claims) return false;
|
|
22
|
+
return roles.some((role) => user.claims?.[role] === true);
|
|
23
|
+
}
|
|
24
|
+
async function hasAllRoles(roles) {
|
|
25
|
+
const user = await getCurrentUser();
|
|
26
|
+
if (!user?.claims) return false;
|
|
27
|
+
return roles.every((role) => user.claims?.[role] === true);
|
|
28
|
+
}
|
|
29
|
+
async function getUserEmail() {
|
|
30
|
+
const user = await getCurrentUser();
|
|
31
|
+
return user?.email ?? null;
|
|
32
|
+
}
|
|
33
|
+
async function getUserId() {
|
|
34
|
+
const user = await getCurrentUser();
|
|
35
|
+
return user?.uid ?? null;
|
|
36
|
+
}
|
|
37
|
+
async function getUserClaims() {
|
|
38
|
+
const user = await getCurrentUser();
|
|
39
|
+
return user?.claims ?? {};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { getCurrentUser, getUserClaims, getUserEmail, getUserId, hasAllRoles, hasAnyRole, hasRole, isLoggedIn };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth module - Utilities, controllers and directives for authentication
|
|
3
|
+
*/
|
|
4
|
+
export { getCurrentUser, isLoggedIn, hasRole, hasAnyRole, hasAllRoles, getUserEmail, getUserId, getUserClaims, } from './auth-utils.js';
|
|
5
|
+
export { AuthController } from './AuthController.js';
|
|
6
|
+
export { ifAuth, ifRole, ifNotAuth } from './auth-directives.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class DefaultLogin extends LitElement {
|
|
3
|
+
/**
|
|
4
|
+
* @event login-success fired when login was successful
|
|
5
|
+
*/
|
|
6
|
+
private _loading;
|
|
7
|
+
private _errorMessage;
|
|
8
|
+
private _successMessage;
|
|
9
|
+
static styles: import('lit').CSSResult[];
|
|
10
|
+
render(): import('lit').TemplateResult<1>;
|
|
11
|
+
private _handleLoginAttempt;
|
|
12
|
+
private _handleForgotPasswordAttempt;
|
|
13
|
+
private _mapErrorCode;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=DefaultLogin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultLogin.d.ts","sourceRoot":"","sources":["../../../src/components/default-login/DefaultLogin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAc5C,OAAO,2CAA2C,CAAC;AAKnD,qBACa,YAAa,SAAQ,UAAU;IAC1C;;OAEG;IAGH,OAAO,CAAC,QAAQ,CAAS;IAGzB,OAAO,CAAC,aAAa,CAAM;IAG3B,OAAO,CAAC,eAAe,CAAM;IAE7B,MAAM,CAAC,MAAM,4BASX;IAEF,MAAM;IAYN,OAAO,CAAC,mBAAmB;IAoC3B,OAAO,CAAC,4BAA4B;IA6BpC,OAAO,CAAC,aAAa;CAWtB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { css, LitElement, html } from 'lit';
|
|
2
|
+
import { state, customElement } from 'lit/decorators.js';
|
|
3
|
+
import { services } from '../../service-provider/ServiceRegistry.js';
|
|
4
|
+
import { pdStore } from '../../store/mini-rx.store.js';
|
|
5
|
+
import { addLoadingState, removeLoadingState } from '../../store/spa-app-actions.js';
|
|
6
|
+
import '@progressive-development/pd-page/pd-login';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
+
if (decorator = decorators[i])
|
|
14
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
15
|
+
if (kind && result) __defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
const LOGIN_LOADING_KEY = "login-attempt";
|
|
19
|
+
const PASSWORD_RESET_LOADING_KEY = "password-reset-attempt";
|
|
20
|
+
let DefaultLogin = class extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this._loading = false;
|
|
24
|
+
this._errorMessage = "";
|
|
25
|
+
this._successMessage = "";
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
return html`
|
|
29
|
+
<pd-login
|
|
30
|
+
?loading="${this._loading}"
|
|
31
|
+
errorMessage="${this._errorMessage}"
|
|
32
|
+
successMessage="${this._successMessage}"
|
|
33
|
+
@login-attempt="${this._handleLoginAttempt}"
|
|
34
|
+
@forgot-password-attempt="${this._handleForgotPasswordAttempt}"
|
|
35
|
+
></pd-login>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
_handleLoginAttempt(e) {
|
|
39
|
+
this._loading = true;
|
|
40
|
+
this._errorMessage = "";
|
|
41
|
+
this._successMessage = "";
|
|
42
|
+
pdStore().dispatch(
|
|
43
|
+
addLoadingState({
|
|
44
|
+
actionKey: LOGIN_LOADING_KEY,
|
|
45
|
+
isLoading: true,
|
|
46
|
+
modal: true,
|
|
47
|
+
loadingTxt: "Anmeldung..."
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
services.auth.login(e.detail.email, e.detail.password).then((user) => {
|
|
51
|
+
this.dispatchEvent(
|
|
52
|
+
new CustomEvent("login-success", {
|
|
53
|
+
detail: user,
|
|
54
|
+
bubbles: true,
|
|
55
|
+
composed: true
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
}).catch((error) => {
|
|
59
|
+
this._errorMessage = this._mapErrorCode(error.code || "unknown");
|
|
60
|
+
}).finally(() => {
|
|
61
|
+
this._loading = false;
|
|
62
|
+
pdStore().dispatch(removeLoadingState(LOGIN_LOADING_KEY));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
_handleForgotPasswordAttempt(e) {
|
|
66
|
+
this._loading = true;
|
|
67
|
+
this._errorMessage = "";
|
|
68
|
+
this._successMessage = "";
|
|
69
|
+
pdStore().dispatch(
|
|
70
|
+
addLoadingState({
|
|
71
|
+
actionKey: PASSWORD_RESET_LOADING_KEY,
|
|
72
|
+
isLoading: true,
|
|
73
|
+
modal: false,
|
|
74
|
+
smallBackground: true,
|
|
75
|
+
loadingTxt: "E-Mail wird gesendet..."
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
services.auth.sendPasswordResetEmail(e.detail.email).then(() => {
|
|
79
|
+
this._successMessage = "Wir haben Ihnen eine E-Mail zum Zurücksetzen des Passworts gesendet.";
|
|
80
|
+
}).finally(() => {
|
|
81
|
+
this._loading = false;
|
|
82
|
+
pdStore().dispatch(removeLoadingState(PASSWORD_RESET_LOADING_KEY));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
_mapErrorCode(code) {
|
|
86
|
+
switch (code) {
|
|
87
|
+
case "auth/invalid-email":
|
|
88
|
+
return "E-Mail Format für Benutzer ist ungültig.";
|
|
89
|
+
case "auth/wrong-password":
|
|
90
|
+
case "auth/user-not-found":
|
|
91
|
+
return "Anmeldung fehlgeschlagen, ungültige Benutzerdaten.";
|
|
92
|
+
default:
|
|
93
|
+
return "Technisches Problem aufgetreten, die Anmeldung kann leider aktuell nicht durchgeführt werden.";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
DefaultLogin.styles = [
|
|
98
|
+
css`
|
|
99
|
+
:host {
|
|
100
|
+
padding-top: 3em;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
}
|
|
105
|
+
`
|
|
106
|
+
];
|
|
107
|
+
__decorateClass([
|
|
108
|
+
state()
|
|
109
|
+
], DefaultLogin.prototype, "_loading", 2);
|
|
110
|
+
__decorateClass([
|
|
111
|
+
state()
|
|
112
|
+
], DefaultLogin.prototype, "_errorMessage", 2);
|
|
113
|
+
__decorateClass([
|
|
114
|
+
state()
|
|
115
|
+
], DefaultLogin.prototype, "_successMessage", 2);
|
|
116
|
+
DefaultLogin = __decorateClass([
|
|
117
|
+
customElement("default-login")
|
|
118
|
+
], DefaultLogin);
|
|
119
|
+
|
|
120
|
+
export { DefaultLogin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultNotFound.d.ts","sourceRoot":"","sources":["../../../src/components/default-not-found/DefaultNotFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,qBACa,eAAgB,SAAQ,UAAU;IAC7C,MAAM,CAAC,MAAM,4BAgBX;IAEF,MAAM;CAKP"}
|
package/dist/{defaultpage/default-not-found.js → components/default-not-found/DefaultNotFound.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { css, html } from
|
|
2
|
-
import { customElement } from
|
|
3
|
-
|
|
1
|
+
import { css, LitElement, html } from 'lit';
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
6
6
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
7
7
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8
8
|
if (decorator = decorators[i])
|
|
9
|
-
result = decorator(result) || result;
|
|
9
|
+
result = (decorator(result)) || result;
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
|
-
let DefaultNotFound = class extends
|
|
12
|
+
let DefaultNotFound = class extends LitElement {
|
|
13
13
|
render() {
|
|
14
14
|
return html`<h3>Keine passende Seite gefunden</h3>
|
|
15
15
|
<p>Zu der URL konnte keine passende Seite gefunden werden</p>
|
|
@@ -22,12 +22,19 @@ DefaultNotFound.styles = [
|
|
|
22
22
|
padding-top: 3em;
|
|
23
23
|
display: block;
|
|
24
24
|
text-align: center;
|
|
25
|
+
|
|
26
|
+
background: var(--pd-default-error-light-col);
|
|
27
|
+
border-radius: 15px;
|
|
28
|
+
justify-self: center;
|
|
29
|
+
padding: 2em;
|
|
30
|
+
margin-top: 5em;
|
|
31
|
+
|
|
32
|
+
border: 2px solid var(--pd-default-error-col);
|
|
25
33
|
}
|
|
26
34
|
`
|
|
27
35
|
];
|
|
28
36
|
DefaultNotFound = __decorateClass([
|
|
29
37
|
customElement("default-not-found")
|
|
30
38
|
], DefaultNotFound);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
39
|
+
|
|
40
|
+
export { DefaultNotFound };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { LitElement, CSSResultGroup } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Map of section IDs to their DOM element references.
|
|
4
|
+
* Keys must match the `sec` property in MenuElement configuration.
|
|
5
|
+
*/
|
|
6
|
+
export type SectionRefs = Record<string, HTMLElement | null | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Map of section IDs to action creator functions.
|
|
9
|
+
* Actions are dispatched when the section becomes visible (fired once per session).
|
|
10
|
+
*/
|
|
11
|
+
export type SectionActions = Record<string, () => any>;
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for menu sections.
|
|
14
|
+
* Returned by _getMenuSections() to register section elements with the menu.
|
|
15
|
+
*/
|
|
16
|
+
export interface SectionConfig {
|
|
17
|
+
/** Page name - should match the route name in NavigationConfig */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Map of section IDs to element references (keys match MenuElement.sec) */
|
|
20
|
+
menuRefs: SectionRefs;
|
|
21
|
+
/** Optional: Map of section IDs to action creators (dispatched when section becomes visible) */
|
|
22
|
+
sectionActions?: SectionActions;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Abstract base class for pages with section-based scroll navigation.
|
|
26
|
+
*
|
|
27
|
+
* Subclasses must implement _getMenuSections() to provide section references.
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class PdSectionPage extends LitElement {
|
|
30
|
+
/**
|
|
31
|
+
* Base styles providing scroll-margin-top for sections.
|
|
32
|
+
* Subclasses should include these styles:
|
|
33
|
+
*
|
|
34
|
+
* ```typescript
|
|
35
|
+
* static override styles = [
|
|
36
|
+
* PdSectionPage.styles,
|
|
37
|
+
* css`...own styles...`
|
|
38
|
+
* ];
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
static styles: CSSResultGroup;
|
|
42
|
+
/**
|
|
43
|
+
* Must be implemented by subclass to provide section configuration.
|
|
44
|
+
* Called in firstUpdated() to register sections with the menu.
|
|
45
|
+
*
|
|
46
|
+
* @returns SectionConfig with page name and section element references
|
|
47
|
+
*/
|
|
48
|
+
protected abstract _getMenuSections(): SectionConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Dispatches init-menu-sections event to register section elements.
|
|
51
|
+
* Subclasses can override but should call super.firstUpdated().
|
|
52
|
+
*/
|
|
53
|
+
firstUpdated(): void;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=PdSectionPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdSectionPage.d.ts","sourceRoot":"","sources":["../../../src/components/pd-section-page/PdSectionPage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAO,cAAc,EAAE,MAAM,KAAK,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEzE;;;GAGG;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,WAAW,CAAC;IACtB,gGAAgG;IAChG,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;GAIG;AACH,8BAAsB,aAAc,SAAQ,UAAU;IACpD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,EAAE,cAAc,CAO3B;IAEF;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,IAAI,aAAa;IAEpD;;;OAGG;IACM,YAAY,IAAI,IAAI;CAS9B"}
|