dhomie-app 0.0.4 → 0.0.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.
Files changed (68) hide show
  1. package/README.md +250 -250
  2. package/fesm2022/dhomie-app-all-polls.page-X6CnLaDS.mjs +125 -0
  3. package/fesm2022/dhomie-app-all-polls.page-X6CnLaDS.mjs.map +1 -0
  4. package/fesm2022/dhomie-app-all-polls.routes-CFeBf4Kg.mjs +18 -0
  5. package/fesm2022/dhomie-app-all-polls.routes-CFeBf4Kg.mjs.map +1 -0
  6. package/fesm2022/dhomie-app-all-schedules.page-5PkaLPYK.mjs +219 -0
  7. package/fesm2022/dhomie-app-all-schedules.page-5PkaLPYK.mjs.map +1 -0
  8. package/fesm2022/dhomie-app-all-schedules.routes-BOn6nXxi.mjs +18 -0
  9. package/fesm2022/dhomie-app-all-schedules.routes-BOn6nXxi.mjs.map +1 -0
  10. package/fesm2022/dhomie-app-apartment.page-BLXw6HpX.mjs +720 -0
  11. package/fesm2022/dhomie-app-apartment.page-BLXw6HpX.mjs.map +1 -0
  12. package/fesm2022/dhomie-app-apartment.service-Dt7ypzWP.mjs +78 -0
  13. package/fesm2022/dhomie-app-apartment.service-Dt7ypzWP.mjs.map +1 -0
  14. package/fesm2022/dhomie-app-chat-create.page-BzEHFsuG.mjs +282 -0
  15. package/fesm2022/dhomie-app-chat-create.page-BzEHFsuG.mjs.map +1 -0
  16. package/fesm2022/dhomie-app-chat.page-I_NppD6M.mjs +421 -0
  17. package/fesm2022/dhomie-app-chat.page-I_NppD6M.mjs.map +1 -0
  18. package/fesm2022/dhomie-app-construction-updates.page-Cu59baDz.mjs +170 -0
  19. package/fesm2022/dhomie-app-construction-updates.page-Cu59baDz.mjs.map +1 -0
  20. package/fesm2022/dhomie-app-construction-updates.routes-BolqsuUv.mjs +18 -0
  21. package/fesm2022/dhomie-app-construction-updates.routes-BolqsuUv.mjs.map +1 -0
  22. package/fesm2022/dhomie-app-construction-updates.service-BElPwLY0.mjs +21 -0
  23. package/fesm2022/dhomie-app-construction-updates.service-BElPwLY0.mjs.map +1 -0
  24. package/fesm2022/dhomie-app-dhomie-app-DZZOuYtS.mjs +3612 -0
  25. package/fesm2022/dhomie-app-dhomie-app-DZZOuYtS.mjs.map +1 -0
  26. package/fesm2022/dhomie-app-documents.page-C3DvisjR.mjs +173 -0
  27. package/fesm2022/dhomie-app-documents.page-C3DvisjR.mjs.map +1 -0
  28. package/fesm2022/dhomie-app-documents.routes-ChFhwRbQ.mjs +18 -0
  29. package/fesm2022/dhomie-app-documents.routes-ChFhwRbQ.mjs.map +1 -0
  30. package/fesm2022/dhomie-app-edit-profile.page-3NQG_6xB.mjs +116 -0
  31. package/fesm2022/dhomie-app-edit-profile.page-3NQG_6xB.mjs.map +1 -0
  32. package/fesm2022/dhomie-app-edit-profile.routes-OYc7WVC5.mjs +18 -0
  33. package/fesm2022/dhomie-app-edit-profile.routes-OYc7WVC5.mjs.map +1 -0
  34. package/fesm2022/dhomie-app-language-selection.page-C5FySCDO.mjs +104 -0
  35. package/fesm2022/dhomie-app-language-selection.page-C5FySCDO.mjs.map +1 -0
  36. package/fesm2022/dhomie-app-language-selection.routes-DqcyVIvn.mjs +18 -0
  37. package/fesm2022/dhomie-app-language-selection.routes-DqcyVIvn.mjs.map +1 -0
  38. package/fesm2022/dhomie-app-layout-action.service-FCahocPH.mjs +23 -0
  39. package/fesm2022/dhomie-app-layout-action.service-FCahocPH.mjs.map +1 -0
  40. package/fesm2022/dhomie-app-layout-title.service-sNCGba1f.mjs +23 -0
  41. package/fesm2022/dhomie-app-layout-title.service-sNCGba1f.mjs.map +1 -0
  42. package/fesm2022/dhomie-app-main-layout.component-CpFuoMhF.mjs +152 -0
  43. package/fesm2022/dhomie-app-main-layout.component-CpFuoMhF.mjs.map +1 -0
  44. package/fesm2022/dhomie-app-new-request.page-MIFfwn6f.mjs +114 -0
  45. package/fesm2022/dhomie-app-new-request.page-MIFfwn6f.mjs.map +1 -0
  46. package/fesm2022/dhomie-app-new-request.routes-BQPJ1W6X.mjs +18 -0
  47. package/fesm2022/dhomie-app-new-request.routes-BQPJ1W6X.mjs.map +1 -0
  48. package/fesm2022/dhomie-app-notifications.page-C9HeFpXt.mjs +170 -0
  49. package/fesm2022/dhomie-app-notifications.page-C9HeFpXt.mjs.map +1 -0
  50. package/fesm2022/dhomie-app-notifications.routes-CktjlrWD.mjs +18 -0
  51. package/fesm2022/dhomie-app-notifications.routes-CktjlrWD.mjs.map +1 -0
  52. package/fesm2022/dhomie-app-pdf-viewer.page-Cx56qfsm.mjs +62 -0
  53. package/fesm2022/dhomie-app-pdf-viewer.page-Cx56qfsm.mjs.map +1 -0
  54. package/fesm2022/dhomie-app-pdf-viewer.routes-jSkMeSRV.mjs +18 -0
  55. package/fesm2022/dhomie-app-pdf-viewer.routes-jSkMeSRV.mjs.map +1 -0
  56. package/fesm2022/dhomie-app-profile.page-BrNrFgJ6.mjs +156 -0
  57. package/fesm2022/dhomie-app-profile.page-BrNrFgJ6.mjs.map +1 -0
  58. package/fesm2022/dhomie-app-request-detail.page-YTIzcbbF.mjs +197 -0
  59. package/fesm2022/dhomie-app-request-detail.page-YTIzcbbF.mjs.map +1 -0
  60. package/fesm2022/dhomie-app-request-detail.routes-BSsr7O-u.mjs +18 -0
  61. package/fesm2022/dhomie-app-request-detail.routes-BSsr7O-u.mjs.map +1 -0
  62. package/fesm2022/dhomie-app-requests.page-0tUAO39k.mjs +314 -0
  63. package/fesm2022/dhomie-app-requests.page-0tUAO39k.mjs.map +1 -0
  64. package/fesm2022/dhomie-app-requests.service-C4TCnstH.mjs +77 -0
  65. package/fesm2022/dhomie-app-requests.service-C4TCnstH.mjs.map +1 -0
  66. package/fesm2022/dhomie-app.mjs +2 -608
  67. package/index.d.ts +681 -7
  68. package/package.json +3 -2
package/README.md CHANGED
@@ -1,250 +1,250 @@
1
- # dhomie-app
2
-
3
- A self-contained Angular micro-app library that handles OIDC authentication (PKCE) and the DHomie feature set. It works in both a Capacitor native shell (iOS / Android) and a plain web shell.
4
-
5
- The library ships with OIDC credentials and API URLs **baked in** at publish time — no runtime configuration is required from the consumer.
6
-
7
- ---
8
-
9
- ## Table of Contents
10
-
11
- 1. [Requirements](#1-requirements)
12
- 2. [Installation](#2-installation)
13
- 3. [Register the micro route in the shell app](#3-register-the-micro-route-in-the-shell-app)
14
- 4. [Add the cold-start deep link handler (Capacitor only)](#4-add-the-cold-start-deep-link-handler-capacitor-only)
15
- 5. [Register the custom URL scheme (Capacitor native only)](#5-register-the-custom-url-scheme-capacitor-native-only)
16
- 6. [Making API requests inside micro components](#6-making-api-requests-inside-micro-components)
17
- 7. [How authentication works](#7-how-authentication-works)
18
- 8. [Baked-in configuration reference](#8-baked-in-configuration-reference)
19
- 9. [Publishing a new version](#9-publishing-a-new-version)
20
-
21
- ---
22
-
23
- ## 1. Requirements
24
-
25
- | Peer dependency | Version |
26
- |-------------------------|----------|
27
- | `@angular/common` | `^20.3.0` |
28
- | `@angular/core` | `^20.3.0` |
29
- | `@angular/router` | `^20.3.0` |
30
- | `@capacitor/app` | `^7.0.0` |
31
- | `@capacitor/browser` | `^7.0.0` |
32
- | `@capacitor/core` | `^7.0.0` |
33
- | `@capacitor/preferences`| `^7.0.0` |
34
- | `@ionic/angular` | `^8.0.0` |
35
- | `angular-oauth2-oidc` | `^20.0.0` |
36
-
37
- ---
38
-
39
- ## 2. Installation
40
-
41
- ```bash
42
- npm install dhomie-app
43
- ```
44
-
45
- Then install all peer dependencies that your shell app does not already have:
46
-
47
- ```bash
48
- npm install @angular/common @angular/core @angular/router \
49
- @capacitor/app @capacitor/browser @capacitor/core @capacitor/preferences \
50
- @ionic/angular angular-oauth2-oidc
51
- ```
52
-
53
- ---
54
-
55
- ## 3. Register the micro route in the shell app
56
-
57
- Add a lazy-loaded `micro` route that delegates to `MICRO_ROUTES`. The library self-registers all of its providers (HttpClient, OAuthService, storage, interceptors) inside a child `EnvironmentInjector` — no call to `provideMicroApp()` is needed in the shell.
58
-
59
- ```ts
60
- // src/app/app.routes.ts
61
- import { Routes } from '@angular/router';
62
- import { MICRO_ROUTES } from 'dhomie-app'; // ← named export from the library
63
-
64
- export const routes: Routes = [
65
- {
66
- path: 'home',
67
- loadComponent: () => import('./home/home.page').then((m) => m.HomePage),
68
- },
69
- {
70
- path: 'micro',
71
- loadChildren: () => import('dhomie-app').then((m) => m.MICRO_ROUTES),
72
- },
73
- {
74
- path: '',
75
- redirectTo: 'home',
76
- pathMatch: 'full',
77
- },
78
- ];
79
- ```
80
-
81
- That is all the routing setup you need. The library exposes these internal routes under `/micro`:
82
-
83
- | URL | Purpose |
84
- |---------------------|----------------------------------------------|
85
- | `/micro` | Redirects to `/micro/home` |
86
- | `/micro/home` | Main micro-app view (guarded — login required) |
87
- | `/micro/callback` | OAuth PKCE callback (no guard) |
88
-
89
- ---
90
-
91
- ## 4. Add the cold-start deep link handler (Capacitor only)
92
-
93
- When the OS kills the app while the in-app browser is open (cold-start scenario), the guard's `appUrlOpen` listener is gone. The shell's `AppComponent` must register its own listener to catch the returning callback URL and navigate to `/micro/callback`.
94
-
95
- ```ts
96
- // src/app/app.component.ts
97
- import { Component, inject, OnInit } from '@angular/core';
98
- import { Router } from '@angular/router';
99
- import { App } from '@capacitor/app';
100
- import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
101
-
102
- @Component({
103
- selector: 'app-root',
104
- templateUrl: 'app.component.html',
105
- imports: [IonApp, IonRouterOutlet],
106
- })
107
- export class AppComponent implements OnInit {
108
- private readonly router = inject(Router);
109
-
110
- ngOnInit(): void {
111
- App.addListener('appUrlOpen', (event) => {
112
- // Only handle the DHomie custom scheme.
113
- if (!event.url.startsWith('thehoodapp://')) {
114
- return;
115
- }
116
-
117
- // Parse query params from the custom-scheme callback URL.
118
- // e.g. com.thehood.app://micro/callback?code=abc&state=xyz
119
- const callbackUrl = new URL(event.url);
120
- const queryParams: Record<string, string> = {};
121
- callbackUrl.searchParams.forEach((value, key) => {
122
- queryParams[key] = value;
123
- });
124
-
125
- this.router.navigate(['/micro/callback'], { queryParams });
126
- });
127
- }
128
- }
129
- ```
130
-
131
- > **Note on cold-start**: if the OS killed the app during the browser session, the PKCE `code_verifier` stored in RAM is lost. The callback component's error handler catches the failed token exchange and redirects to `/micro/home`, which restarts the login flow from scratch. This is the expected and accepted behavior for cold-start.
132
-
133
- ---
134
-
135
- ## 5. Register the custom URL scheme (Capacitor native only)
136
-
137
- The mobile OAuth redirect URI is `com.thehood.app://micro/callback`. You must register this scheme in both native projects.
138
-
139
- ### iOS — `ios/App/App/Info.plist`
140
-
141
- ```xml
142
- <key>CFBundleURLTypes</key>
143
- <array>
144
- <dict>
145
- <key>CFBundleURLSchemes</key>
146
- <array>
147
- <string>com.thehood.app</string>
148
- </array>
149
- </dict>
150
- </array>
151
- ```
152
-
153
- ### Android — `android/app/src/main/AndroidManifest.xml`
154
-
155
- Inside the main `<activity>` tag:
156
-
157
- ```xml
158
- <intent-filter>
159
- <action android:name="android.intent.action.VIEW" />
160
- <category android:name="android.intent.category.DEFAULT" />
161
- <category android:name="android.intent.category.BROWSABLE" />
162
- <data android:scheme="com.thehood.app" />
163
- </intent-filter>
164
- ```
165
-
166
- ---
167
-
168
- ## 6. Making API requests inside micro components
169
-
170
- The library provides its own child-scoped `HttpClient`. Use the `IS_MICRO_API` context token on every request so the micro interceptor can:
171
-
172
- - Prepend the API base URL to relative paths.
173
- - Attach the Bearer token.
174
- - Handle 401 errors with an automatic token refresh.
175
-
176
- ```ts
177
- import { HttpClient, HttpContext } from '@angular/common/http';
178
- import { inject } from '@angular/core';
179
- import { IS_MICRO_API } from 'dhomie-app';
180
-
181
- // Inside a micro component or service:
182
- const http = inject(HttpClient);
183
-
184
- http.get('/properties', {
185
- context: new HttpContext().set(IS_MICRO_API, true),
186
- });
187
- // → sends GET https://api.dhomie.com/v1/properties
188
- // with Authorization: Bearer <current_token>
189
- ```
190
-
191
- > Requests made **without** `IS_MICRO_API` (or with it set to `false`) pass through unchanged — parent-app interceptors are not involved in micro-app calls, and vice versa.
192
-
193
- ---
194
-
195
- ## 7. How authentication works
196
-
197
- The guard (`microAuthGuard`) runs before every protected route under `/micro/home`.
198
-
199
- **Step-by-step sequence:**
200
-
201
- 1. **Hydrate storage** — token data is loaded from `@capacitor/preferences` into RAM. This is memoized and instant on repeat navigations.
202
- 2. **Check token** — if `hasValidAccessToken()` returns `true`, navigation is allowed immediately.
203
- 3. **Load discovery document** — the OIDC `.well-known` endpoint is fetched once and cached.
204
- 4. **Platform split:**
205
- - **Native (Capacitor)** — generates a PKCE authorization URL, registers an `appUrlOpen` listener, then opens the URL in the system browser via `@capacitor/browser`. Returns `false` (blocks navigation).
206
- - **Web** — calls `initCodeFlow()` which redirects `window.location` to the authorization endpoint. Returns `false`.
207
- 5. **Callback** — when the auth server redirects back, `MicroCallbackComponent` (at `/micro/callback`) calls `tryLoginCodeFlow()`, exchanges the code for tokens, and stores them via `CapacitorOAuthStorage`.
208
- 6. **Token refresh** — `MicroRefreshSchedulerService` proactively refreshes tokens before expiry. `MicroTokenRefreshService` handles concurrent 401s with a shared refresh lock.
209
-
210
- ---
211
-
212
- ## 8. Baked-in configuration reference
213
-
214
- All OIDC credentials and API URLs are inlined into the published FESM bundle at build time. No runtime configuration is needed. The values correspond to `env.prod.ts`:
215
-
216
- | Field | Baked-in value |
217
- |-----------------------------|---------------------------------------------|
218
- | `oidc.issuer` | `https://auth.dhomie.com` |
219
- | `oidc.clientId` | `dhomie-micro-client` |
220
- | `oidc.scope` | `openid profile email offline_access` |
221
- | `oidc.redirectUri` (web) | `https://app.dhomie.com/micro/callback` |
222
- | `oidc.mobileRedirectUri` | `com.thehood.app://micro/callback` |
223
- | `oidc.responseType` | `code` (PKCE) |
224
- | `microApiBaseUrl` | `https://api.dhomie.com/v1` |
225
-
226
- ---
227
-
228
- ## 9. Publishing a new version
229
-
230
- Run the publish script from the **project root**:
231
-
232
- ```bash
233
- # Without 2FA OTP
234
- npm run publish:dhomie-app
235
-
236
- # With 2FA OTP
237
- npm run publish:dhomie-app -- 123456
238
- ```
239
-
240
- The script performs these steps automatically:
241
-
242
- | Step | Action |
243
- |------|--------|
244
- | 0 | Bumps the **patch** version in `projects/dhomie-app/package.json` |
245
- | 1 | Builds the library in production mode (`ng build dhomie-app --configuration production`) |
246
- | 2 | Inlines the `env.prod.ts` values into the FESM bundle (replaces the `dhomie-env` virtual import) |
247
- | 3 | Removes the stale source map and any `.npmrc` copied into `dist/dhomie-app` |
248
- | 4 | Publishes `./dist/dhomie-app` to npm with `--access public` |
249
-
250
- To bump the **minor** or **major** version instead, edit `projects/dhomie-app/package.json` manually before running the script.
1
+ # dhomie-app
2
+
3
+ A self-contained Angular micro-app library that handles OIDC authentication (PKCE) and the DHomie feature set. It works in both a Capacitor native shell (iOS / Android) and a plain web shell.
4
+
5
+ The library ships with OIDC credentials and API URLs **baked in** at publish time — no runtime configuration is required from the consumer.
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [Requirements](#1-requirements)
12
+ 2. [Installation](#2-installation)
13
+ 3. [Register the micro route in the shell app](#3-register-the-micro-route-in-the-shell-app)
14
+ 4. [Add the cold-start deep link handler (Capacitor only)](#4-add-the-cold-start-deep-link-handler-capacitor-only)
15
+ 5. [Register the custom URL scheme (Capacitor native only)](#5-register-the-custom-url-scheme-capacitor-native-only)
16
+ 6. [Making API requests inside micro components](#6-making-api-requests-inside-micro-components)
17
+ 7. [How authentication works](#7-how-authentication-works)
18
+ 8. [Baked-in configuration reference](#8-baked-in-configuration-reference)
19
+ 9. [Publishing a new version](#9-publishing-a-new-version)
20
+
21
+ ---
22
+
23
+ ## 1. Requirements
24
+
25
+ | Peer dependency | Version |
26
+ |-------------------------|----------|
27
+ | `@angular/common` | `^20.3.0` |
28
+ | `@angular/core` | `^20.3.0` |
29
+ | `@angular/router` | `^20.3.0` |
30
+ | `@capacitor/app` | `^7.0.0` |
31
+ | `@capacitor/browser` | `^7.0.0` |
32
+ | `@capacitor/core` | `^7.0.0` |
33
+ | `@capacitor/preferences`| `^7.0.0` |
34
+ | `@ionic/angular` | `^8.0.0` |
35
+ | `angular-oauth2-oidc` | `^20.0.0` |
36
+
37
+ ---
38
+
39
+ ## 2. Installation
40
+
41
+ ```bash
42
+ npm install dhomie-app
43
+ ```
44
+
45
+ Then install all peer dependencies that your shell app does not already have:
46
+
47
+ ```bash
48
+ npm install @angular/common @angular/core @angular/router \
49
+ @capacitor/app @capacitor/browser @capacitor/core @capacitor/preferences \
50
+ @ionic/angular angular-oauth2-oidc
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 3. Register the micro route in the shell app
56
+
57
+ Add a lazy-loaded `micro` route that delegates to `MICRO_ROUTES`. The library self-registers all of its providers (HttpClient, OAuthService, storage, interceptors) inside a child `EnvironmentInjector` — no call to `provideMicroApp()` is needed in the shell.
58
+
59
+ ```ts
60
+ // src/app/app.routes.ts
61
+ import { Routes } from '@angular/router';
62
+ import { MICRO_ROUTES } from 'dhomie-app'; // ← named export from the library
63
+
64
+ export const routes: Routes = [
65
+ {
66
+ path: 'home',
67
+ loadComponent: () => import('./home/home.page').then((m) => m.HomePage),
68
+ },
69
+ {
70
+ path: 'micro',
71
+ loadChildren: () => import('dhomie-app').then((m) => m.MICRO_ROUTES),
72
+ },
73
+ {
74
+ path: '',
75
+ redirectTo: 'home',
76
+ pathMatch: 'full',
77
+ },
78
+ ];
79
+ ```
80
+
81
+ That is all the routing setup you need. The library exposes these internal routes under `/micro`:
82
+
83
+ | URL | Purpose |
84
+ |---------------------|----------------------------------------------|
85
+ | `/micro` | Redirects to `/micro/home` |
86
+ | `/micro/home` | Main micro-app view (guarded — login required) |
87
+ | `/micro/callback` | OAuth PKCE callback (no guard) |
88
+
89
+ ---
90
+
91
+ ## 4. Add the cold-start deep link handler (Capacitor only)
92
+
93
+ When the OS kills the app while the in-app browser is open (cold-start scenario), the guard's `appUrlOpen` listener is gone. The shell's `AppComponent` must register its own listener to catch the returning callback URL and navigate to `/micro/callback`.
94
+
95
+ ```ts
96
+ // src/app/app.component.ts
97
+ import { Component, inject, OnInit } from '@angular/core';
98
+ import { Router } from '@angular/router';
99
+ import { App } from '@capacitor/app';
100
+ import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
101
+
102
+ @Component({
103
+ selector: 'app-root',
104
+ templateUrl: 'app.component.html',
105
+ imports: [IonApp, IonRouterOutlet],
106
+ })
107
+ export class AppComponent implements OnInit {
108
+ private readonly router = inject(Router);
109
+
110
+ ngOnInit(): void {
111
+ App.addListener('appUrlOpen', (event) => {
112
+ // Only handle the DHomie custom scheme.
113
+ if (!event.url.startsWith('thehoodapp://')) {
114
+ return;
115
+ }
116
+
117
+ // Parse query params from the custom-scheme callback URL.
118
+ // e.g. com.thehood.app://micro/callback?code=abc&state=xyz
119
+ const callbackUrl = new URL(event.url);
120
+ const queryParams: Record<string, string> = {};
121
+ callbackUrl.searchParams.forEach((value, key) => {
122
+ queryParams[key] = value;
123
+ });
124
+
125
+ this.router.navigate(['/micro/callback'], { queryParams });
126
+ });
127
+ }
128
+ }
129
+ ```
130
+
131
+ > **Note on cold-start**: if the OS killed the app during the browser session, the PKCE `code_verifier` stored in RAM is lost. The callback component's error handler catches the failed token exchange and redirects to `/micro/home`, which restarts the login flow from scratch. This is the expected and accepted behavior for cold-start.
132
+
133
+ ---
134
+
135
+ ## 5. Register the custom URL scheme (Capacitor native only)
136
+
137
+ The mobile OAuth redirect URI is `com.thehood.app://micro/callback`. You must register this scheme in both native projects.
138
+
139
+ ### iOS — `ios/App/App/Info.plist`
140
+
141
+ ```xml
142
+ <key>CFBundleURLTypes</key>
143
+ <array>
144
+ <dict>
145
+ <key>CFBundleURLSchemes</key>
146
+ <array>
147
+ <string>com.thehood.app</string>
148
+ </array>
149
+ </dict>
150
+ </array>
151
+ ```
152
+
153
+ ### Android — `android/app/src/main/AndroidManifest.xml`
154
+
155
+ Inside the main `<activity>` tag:
156
+
157
+ ```xml
158
+ <intent-filter>
159
+ <action android:name="android.intent.action.VIEW" />
160
+ <category android:name="android.intent.category.DEFAULT" />
161
+ <category android:name="android.intent.category.BROWSABLE" />
162
+ <data android:scheme="com.thehood.app" />
163
+ </intent-filter>
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 6. Making API requests inside micro components
169
+
170
+ The library provides its own child-scoped `HttpClient`. Use the `IS_MICRO_API` context token on every request so the micro interceptor can:
171
+
172
+ - Prepend the API base URL to relative paths.
173
+ - Attach the Bearer token.
174
+ - Handle 401 errors with an automatic token refresh.
175
+
176
+ ```ts
177
+ import { HttpClient, HttpContext } from '@angular/common/http';
178
+ import { inject } from '@angular/core';
179
+ import { IS_MICRO_API } from 'dhomie-app';
180
+
181
+ // Inside a micro component or service:
182
+ const http = inject(HttpClient);
183
+
184
+ http.get('/properties', {
185
+ context: new HttpContext().set(IS_MICRO_API, true),
186
+ });
187
+ // → sends GET https://api.dhomie.com/v1/properties
188
+ // with Authorization: Bearer <current_token>
189
+ ```
190
+
191
+ > Requests made **without** `IS_MICRO_API` (or with it set to `false`) pass through unchanged — parent-app interceptors are not involved in micro-app calls, and vice versa.
192
+
193
+ ---
194
+
195
+ ## 7. How authentication works
196
+
197
+ The guard (`microAuthGuard`) runs before every protected route under `/micro/home`.
198
+
199
+ **Step-by-step sequence:**
200
+
201
+ 1. **Hydrate storage** — token data is loaded from `@capacitor/preferences` into RAM. This is memoized and instant on repeat navigations.
202
+ 2. **Check token** — if `hasValidAccessToken()` returns `true`, navigation is allowed immediately.
203
+ 3. **Load discovery document** — the OIDC `.well-known` endpoint is fetched once and cached.
204
+ 4. **Platform split:**
205
+ - **Native (Capacitor)** — generates a PKCE authorization URL, registers an `appUrlOpen` listener, then opens the URL in the system browser via `@capacitor/browser`. Returns `false` (blocks navigation).
206
+ - **Web** — calls `initCodeFlow()` which redirects `window.location` to the authorization endpoint. Returns `false`.
207
+ 5. **Callback** — when the auth server redirects back, `MicroCallbackComponent` (at `/micro/callback`) calls `tryLoginCodeFlow()`, exchanges the code for tokens, and stores them via `CapacitorOAuthStorage`.
208
+ 6. **Token refresh** — `MicroRefreshSchedulerService` proactively refreshes tokens before expiry. `MicroTokenRefreshService` handles concurrent 401s with a shared refresh lock.
209
+
210
+ ---
211
+
212
+ ## 8. Baked-in configuration reference
213
+
214
+ All OIDC credentials and API URLs are inlined into the published FESM bundle at build time. No runtime configuration is needed. The values correspond to `env.prod.ts`:
215
+
216
+ | Field | Baked-in value |
217
+ |-----------------------------|---------------------------------------------|
218
+ | `oidc.issuer` | `https://auth.dhomie.com` |
219
+ | `oidc.clientId` | `dhomie-micro-client` |
220
+ | `oidc.scope` | `openid profile email offline_access` |
221
+ | `oidc.redirectUri` (web) | `https://app.dhomie.com/micro/callback` |
222
+ | `oidc.mobileRedirectUri` | `com.thehood.app://micro/callback` |
223
+ | `oidc.responseType` | `code` (PKCE) |
224
+ | `microApiBaseUrl` | `https://api.dhomie.com/v1` |
225
+
226
+ ---
227
+
228
+ ## 9. Publishing a new version
229
+
230
+ Run the publish script from the **project root**:
231
+
232
+ ```bash
233
+ # Without 2FA OTP
234
+ npm run publish:dhomie-app
235
+
236
+ # With 2FA OTP
237
+ npm run publish:dhomie-app -- 123456
238
+ ```
239
+
240
+ The script performs these steps automatically:
241
+
242
+ | Step | Action |
243
+ |------|--------|
244
+ | 0 | Bumps the **patch** version in `projects/dhomie-app/package.json` |
245
+ | 1 | Builds the library in production mode (`ng build dhomie-app --configuration production`) |
246
+ | 2 | Inlines the `env.prod.ts` values into the FESM bundle (replaces the `dhomie-env` virtual import) |
247
+ | 3 | Removes the stale source map and any `.npmrc` copied into `dist/dhomie-app` |
248
+ | 4 | Publishes `./dist/dhomie-app` to npm with `--access public` |
249
+
250
+ To bump the **minor** or **major** version instead, edit `projects/dhomie-app/package.json` manually before running the script.
@@ -0,0 +1,125 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, DestroyRef, signal, computed, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
+ import { ActivatedRoute } from '@angular/router';
5
+ import { IonContent, IonInfiniteScroll, IonInfiniteScrollContent } from '@ionic/angular/standalone';
6
+ import { TranslatePipe } from '@ngx-translate/core';
7
+ import { catchError, of, map, switchMap } from 'rxjs';
8
+ import { q as AllPollsService, P as PollNotificationService, w as DhPollCardComponent, o as DhLoadingComponent } from './dhomie-app-dhomie-app-DZZOuYtS.mjs';
9
+
10
+ const PAGE_SIZE = 20;
11
+ class AllPollsPage {
12
+ constructor() {
13
+ this.activatedRoute = inject(ActivatedRoute);
14
+ this.destroyRef = inject(DestroyRef);
15
+ this.allPollsService = inject(AllPollsService);
16
+ this.pollNotification = inject(PollNotificationService);
17
+ this.currentCommunityId = signal('', ...(ngDevMode ? [{ debugName: "currentCommunityId" }] : []));
18
+ this.polls = signal(this.readSeedPolls() ?? [], ...(ngDevMode ? [{ debugName: "polls" }] : []));
19
+ this.status = signal(this.polls().length ? 'success' : 'idle', ...(ngDevMode ? [{ debugName: "status" }] : []));
20
+ this.isLoadingMore = signal(false, ...(ngDevMode ? [{ debugName: "isLoadingMore" }] : []));
21
+ this.hasMore = signal(false, ...(ngDevMode ? [{ debugName: "hasMore" }] : []));
22
+ this.isLoading = computed(() => this.status() === 'loading', ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
23
+ this.hasError = computed(() => this.status() === 'error', ...(ngDevMode ? [{ debugName: "hasError" }] : []));
24
+ this.hasCommunityContext = computed(() => !!this.currentCommunityId(), ...(ngDevMode ? [{ debugName: "hasCommunityContext" }] : []));
25
+ }
26
+ onVote(pollId, optionId) {
27
+ const communityId = this.currentCommunityId();
28
+ if (!communityId)
29
+ return;
30
+ this.allPollsService
31
+ .submitVote(pollId, optionId, communityId)
32
+ .pipe(catchError(() => of(null)), takeUntilDestroyed(this.destroyRef))
33
+ .subscribe((result) => {
34
+ if (result !== null) {
35
+ this.polls.update((items) => this.allPollsService.vote(items, pollId, optionId));
36
+ }
37
+ });
38
+ }
39
+ onChangeAnswer(pollId) {
40
+ this.polls.update((items) => this.allPollsService.resetVote(items, pollId));
41
+ }
42
+ onIonInfinite(event) {
43
+ const communityId = this.currentCommunityId();
44
+ if (!communityId || this.isLoadingMore())
45
+ return;
46
+ this.isLoadingMore.set(true);
47
+ this.allPollsService
48
+ .getPolls(communityId, { skip: this.polls().length, take: PAGE_SIZE })
49
+ .pipe(catchError(() => of([])), takeUntilDestroyed(this.destroyRef))
50
+ .subscribe((newPolls) => {
51
+ this.polls.update((current) => [...current, ...newPolls]);
52
+ this.hasMore.set(newPolls.length === PAGE_SIZE);
53
+ this.isLoadingMore.set(false);
54
+ event.target.complete();
55
+ });
56
+ }
57
+ ngOnInit() {
58
+ this.listenForNewPolls();
59
+ this.activatedRoute.queryParamMap
60
+ .pipe(map((params) => params.get('communityId') ?? ''), switchMap((communityId) => {
61
+ this.currentCommunityId.set(communityId);
62
+ if (!communityId) {
63
+ this.status.set('idle');
64
+ return of(null);
65
+ }
66
+ this.status.set('loading');
67
+ return this.allPollsService
68
+ .getPolls(communityId, { skip: 0, take: PAGE_SIZE })
69
+ .pipe(catchError(() => {
70
+ this.status.set('error');
71
+ return of([]);
72
+ }));
73
+ }), takeUntilDestroyed(this.destroyRef))
74
+ .subscribe((polls) => {
75
+ if (polls === null) {
76
+ this.polls.set([]);
77
+ this.hasMore.set(false);
78
+ return;
79
+ }
80
+ this.polls.set(polls);
81
+ this.hasMore.set(polls.length === PAGE_SIZE);
82
+ if (this.status() !== 'error') {
83
+ this.status.set('success');
84
+ }
85
+ });
86
+ }
87
+ listenForNewPolls() {
88
+ this.pollNotification.pollCreated$
89
+ .pipe(takeUntilDestroyed(this.destroyRef))
90
+ .subscribe(({ pollId }) => {
91
+ const communityId = this.currentCommunityId();
92
+ if (!communityId || !pollId) {
93
+ return;
94
+ }
95
+ this.allPollsService
96
+ .getPoll(communityId, pollId)
97
+ .pipe(catchError(() => of(null)), takeUntilDestroyed(this.destroyRef))
98
+ .subscribe((poll) => {
99
+ if (poll) {
100
+ this.polls.update((current) => [poll, ...current]);
101
+ }
102
+ });
103
+ });
104
+ }
105
+ readSeedPolls() {
106
+ const state = history.state;
107
+ return state?.polls ?? null;
108
+ }
109
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: AllPollsPage, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
110
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.17", type: AllPollsPage, isStandalone: true, selector: "dh-all-polls-page", ngImport: i0, template: "<dh-loading [isOpen]=\"isLoading()\" />\r\n\r\n<ion-content [fullscreen]=\"true\" class=\"dh-all-polls-content\">\r\n <div class=\"dh-all-polls-container\">\r\n @if (hasError()) {\r\n <p class=\"dh-all-polls-state-text\">{{ 'states.loadFailed' | translate }}</p>\r\n } @else if (polls().length > 0) {\r\n @for (poll of polls(); track poll.id) {\r\n <dh-poll-card\r\n [poll]=\"poll\"\r\n (vote)=\"onVote(poll.id, $event)\"\r\n (changeAnswer)=\"onChangeAnswer(poll.id)\"\r\n ></dh-poll-card>\r\n }\r\n } @else {\r\n <p class=\"dh-all-polls-state-text\">{{ 'polls.empty' | translate }}</p>\r\n }\r\n </div>\r\n\r\n <ion-infinite-scroll [disabled]=\"!hasMore()\" (ionInfinite)=\"onIonInfinite($event)\">\r\n <ion-infinite-scroll-content />\r\n </ion-infinite-scroll>\r\n</ion-content>\r\n", dependencies: [{ kind: "component", type: IonContent, selector: "ion-content", inputs: ["color", "fixedSlotPlacement", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"] }, { kind: "component", type: IonInfiniteScroll, selector: "ion-infinite-scroll", inputs: ["disabled", "position", "threshold"] }, { kind: "component", type: IonInfiniteScrollContent, selector: "ion-infinite-scroll-content", inputs: ["loadingSpinner", "loadingText"] }, { kind: "component", type: DhPollCardComponent, selector: "dh-poll-card", inputs: ["poll"], outputs: ["vote", "changeAnswer"] }, { kind: "component", type: DhLoadingComponent, selector: "dh-loading", inputs: ["trigger", "isOpen", "duration", "spinner", "inline"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
111
+ }
112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: AllPollsPage, decorators: [{
113
+ type: Component,
114
+ args: [{ selector: 'dh-all-polls-page', standalone: true, imports: [
115
+ IonContent,
116
+ IonInfiniteScroll,
117
+ IonInfiniteScrollContent,
118
+ TranslatePipe,
119
+ DhPollCardComponent,
120
+ DhLoadingComponent,
121
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<dh-loading [isOpen]=\"isLoading()\" />\r\n\r\n<ion-content [fullscreen]=\"true\" class=\"dh-all-polls-content\">\r\n <div class=\"dh-all-polls-container\">\r\n @if (hasError()) {\r\n <p class=\"dh-all-polls-state-text\">{{ 'states.loadFailed' | translate }}</p>\r\n } @else if (polls().length > 0) {\r\n @for (poll of polls(); track poll.id) {\r\n <dh-poll-card\r\n [poll]=\"poll\"\r\n (vote)=\"onVote(poll.id, $event)\"\r\n (changeAnswer)=\"onChangeAnswer(poll.id)\"\r\n ></dh-poll-card>\r\n }\r\n } @else {\r\n <p class=\"dh-all-polls-state-text\">{{ 'polls.empty' | translate }}</p>\r\n }\r\n </div>\r\n\r\n <ion-infinite-scroll [disabled]=\"!hasMore()\" (ionInfinite)=\"onIonInfinite($event)\">\r\n <ion-infinite-scroll-content />\r\n </ion-infinite-scroll>\r\n</ion-content>\r\n" }]
122
+ }] });
123
+
124
+ export { AllPollsPage };
125
+ //# sourceMappingURL=dhomie-app-all-polls.page-X6CnLaDS.mjs.map