@edsis/angular 22.0.38 → 22.0.40

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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@edsis/angular",
3
- "version": "22.0.38",
3
+ "version": "22.0.40",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=22.0.0",
6
6
  "@angular/core": ">=22.0.0",
7
7
  "@angular/forms": ">=22.0.0",
8
8
  "@angular/router": ">=22.0.0",
9
- "@edsis/navigation": "^22.0.38",
10
- "@edsis/sdk": "^22.0.38",
11
- "@edsis/theme": "^22.0.38",
12
- "@edsis/component": "^22.0.38",
9
+ "@edsis/navigation": "^22.0.40",
10
+ "@edsis/sdk": "^22.0.40",
11
+ "@edsis/theme": "^22.0.40",
12
+ "@edsis/component": "^22.0.40",
13
13
  "rxjs": ">=7.8.0"
14
14
  },
15
15
  "peerDependenciesMeta": {
@@ -2,9 +2,10 @@ import { HttpInterceptorFn, HttpContextToken } from '@angular/common/http';
2
2
  import * as _angular_core from '@angular/core';
3
3
  import { InjectionToken, EnvironmentProviders, OnInit } from '@angular/core';
4
4
  import { CanActivateFn, Routes } from '@angular/router';
5
- import * as _angular_forms from '@angular/forms';
6
- import * as _edsis_angular_module_auth from '@edsis/angular/module/auth';
7
5
  import { AuthTokenResponse, AuthSessionService } from '@edsis/sdk/auth';
6
+ import { Observable } from 'rxjs';
7
+ import * as _edsis_angular_module_auth from '@edsis/angular/module/auth';
8
+ import * as _angular_forms from '@angular/forms';
8
9
 
9
10
  /**
10
11
  * Seluruh teks yang tampil di halaman auth (login, logout, verify).
@@ -36,6 +37,25 @@ interface EdsisAuthMessages {
36
37
  readonly healthRetry: string;
37
38
  readonly healthChecking: string;
38
39
  };
40
+ readonly google: {
41
+ readonly title: string;
42
+ readonly intro: string;
43
+ readonly badge: string;
44
+ /** Aria tombol Google di halaman login saat sign-in aktif (config terisi). */
45
+ readonly signInAria: string;
46
+ /** Status di halaman login selama full-page redirect ke Google berlangsung. */
47
+ readonly googleRedirecting: string;
48
+ readonly googleExchangeInProgress: string;
49
+ readonly exchangeInProgressAria: string;
50
+ readonly googleStateMismatch: string;
51
+ readonly googleAccessDenied: string;
52
+ /** Error generik callback; juga fallback saat backend tidak mengirim pesan. */
53
+ readonly googleCallbackError: string;
54
+ readonly googleRetry: string;
55
+ readonly missingAccessToken: string;
56
+ readonly successRedirect: string;
57
+ readonly openDashboard: string;
58
+ };
39
59
  readonly logout: {
40
60
  readonly title: string;
41
61
  readonly intro: string;
@@ -70,6 +90,12 @@ type EdsisAuthMessagesOverride = {
70
90
  declare const EDSIS_AUTH_MESSAGES: InjectionToken<EdsisAuthMessages>;
71
91
  declare function mergeEdsisAuthMessages(override?: EdsisAuthMessagesOverride): EdsisAuthMessages;
72
92
 
93
+ /**
94
+ * Path route callback Google di dalam `authRoutes`; juga menjadi sumber
95
+ * derivasi `redirectUri` (`${appUrl}/auth/google/callback`), sehingga URL yang
96
+ * didaftarkan di Google Cloud Console selalu konsisten dengan route library.
97
+ */
98
+ declare const GOOGLE_OAUTH_CALLBACK_ROUTE_PATH: "auth/google/callback";
73
99
  /**
74
100
  * Health-check backend auth di halaman login (opt-in).
75
101
  * Sehat = HTTP 2xx dalam `timeoutMs`; body respons tidak diparse.
@@ -82,6 +108,22 @@ interface EdsisAuthHealthCheckConfig {
82
108
  /** Default 4000. */
83
109
  timeoutMs?: number;
84
110
  }
111
+ /**
112
+ * Google Sign-In dengan authorization-code flow. Exchange code dilakukan
113
+ * backend (`POST {apiUrl}/auth/google`) sehingga client secret tidak pernah
114
+ * menyentuh frontend.
115
+ */
116
+ interface EdsisAuthGoogleOauthConfig {
117
+ /**
118
+ * OAuth 2.0 client ID dari Google Cloud Console. String kosong dianggap
119
+ * tidak dikonfigurasi (tombol Google tetap placeholder), sehingga aman
120
+ * meneruskan nilai environment yang di-inject build-time apa adanya.
121
+ */
122
+ clientId: string;
123
+ }
124
+ interface EdsisAuthOauthConfig {
125
+ google?: EdsisAuthGoogleOauthConfig;
126
+ }
85
127
  interface EdsisAuthConfig {
86
128
  apiUrl: string;
87
129
  appUrl: string;
@@ -98,12 +140,27 @@ interface EdsisAuthConfig {
98
140
  */
99
141
  httpInterceptors?: readonly HttpInterceptorFn[];
100
142
  healthCheck?: EdsisAuthHealthCheckConfig;
143
+ /**
144
+ * Provider OAuth di halaman login (saat ini hanya Google). `redirectUri`
145
+ * tidak dikonfigurasi konsumer; library menurunkannya dari `appUrl`:
146
+ * `${appUrl}/auth/google/callback`.
147
+ */
148
+ oauth?: EdsisAuthOauthConfig;
101
149
  }
102
150
  interface ResolvedEdsisAuthHealthCheck {
103
151
  enabled: boolean;
104
152
  url: string;
105
153
  timeoutMs: number;
106
154
  }
155
+ interface ResolvedEdsisAuthGoogleOauth {
156
+ clientId: string;
157
+ /** Diturunkan dari `appUrl`: `${appUrl}/auth/google/callback`. */
158
+ redirectUri: string;
159
+ }
160
+ interface ResolvedEdsisAuthOauth {
161
+ /** `null` saat Google Sign-In tidak dikonfigurasi (perilaku placeholder lama). */
162
+ google: ResolvedEdsisAuthGoogleOauth | null;
163
+ }
107
164
  interface ResolvedEdsisAuthConfig {
108
165
  apiUrl: string;
109
166
  appUrl: string;
@@ -113,6 +170,7 @@ interface ResolvedEdsisAuthConfig {
113
170
  authenticatedHomePath: `/${string}`;
114
171
  guestHomePath: `/${string}`;
115
172
  healthCheck: ResolvedEdsisAuthHealthCheck;
173
+ oauth: ResolvedEdsisAuthOauth;
116
174
  }
117
175
  declare const EDSIS_AUTH_CONFIG: InjectionToken<ResolvedEdsisAuthConfig>;
118
176
  declare function resolveEdsisAuthConfig(config: EdsisAuthConfig): ResolvedEdsisAuthConfig;
@@ -127,6 +185,37 @@ declare const EDSIS_SKIP_AUTH: HttpContextToken<boolean>;
127
185
  declare const EDSIS_SKIP_SESSION_REFRESH: HttpContextToken<boolean>;
128
186
  declare const edsisAuthInterceptor: HttpInterceptorFn;
129
187
 
188
+ /**
189
+ * Menukar authorization code Google menjadi sesi lewat backend
190
+ * (`POST {apiUrl}/auth/google`): client secret hanya ada di server, backend
191
+ * men-set refresh cookie (karena itu `withCredentials`), dan respons berformat
192
+ * sama dengan verify magic-link sehingga bisa langsung ke `persistSession`.
193
+ */
194
+ declare class AuthGoogleOauthService {
195
+ private readonly http;
196
+ private readonly config;
197
+ exchangeAuthorizationCode(code: string): Observable<AuthTokenResponse>;
198
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthGoogleOauthService, never>;
199
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<AuthGoogleOauthService>;
200
+ }
201
+
202
+ declare const GOOGLE_OAUTH_STATE_STORAGE_KEY = "auth-google-state";
203
+ declare const GOOGLE_OAUTH_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth";
204
+ interface GoogleAuthorizeUrlOptions {
205
+ clientId: string;
206
+ redirectUri: string;
207
+ state: string;
208
+ }
209
+ /** Nilai `state` acak berbasis crypto (anti-CSRF untuk round-trip OAuth). */
210
+ declare function createGoogleOauthState(windowRef: Window): string;
211
+ declare function buildGoogleAuthorizeUrl(options: GoogleAuthorizeUrlOptions): string;
212
+ declare function storeGoogleOauthState(documentRef: Document, state: string): void;
213
+ /**
214
+ * Baca lalu hapus state dari sessionStorage. State sekali pakai: dikonsumsi di
215
+ * semua cabang callback agar tidak bocor ke percobaan login berikutnya.
216
+ */
217
+ declare function consumeGoogleOauthState(documentRef: Document): string;
218
+
130
219
  declare const authRoutes: Routes;
131
220
 
132
221
  declare class AuthShellPage {
@@ -134,6 +223,30 @@ declare class AuthShellPage {
134
223
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<AuthShellPage, "edsis-auth-shell-page", never, {}, {}, never, never, true, never>;
135
224
  }
136
225
 
226
+ declare class AuthGoogleCallbackPage {
227
+ private readonly documentRef;
228
+ private readonly destroyRef;
229
+ private readonly injector;
230
+ private readonly route;
231
+ private readonly router;
232
+ private readonly location;
233
+ private readonly authGoogleOauthService;
234
+ private readonly authConfig;
235
+ protected readonly messages: _edsis_angular_module_auth.EdsisAuthMessages;
236
+ protected readonly loginPath: `/${string}`;
237
+ protected readonly authenticatedHomePath: `/${string}`;
238
+ protected readonly state: _angular_core.WritableSignal<"pending" | "success" | "error">;
239
+ protected readonly message: _angular_core.WritableSignal<string>;
240
+ private readonly retryLink;
241
+ constructor();
242
+ private handleCallback;
243
+ private clearCallbackParamsFromAddressBar;
244
+ private exchange;
245
+ private fail;
246
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthGoogleCallbackPage, never>;
247
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AuthGoogleCallbackPage, "AuthGoogleCallbackPage", never, {}, {}, never, never, true, never>;
248
+ }
249
+
137
250
  type AuthHealthStatus = 'idle' | 'checking' | 'healthy' | 'unhealthy';
138
251
  /**
139
252
  * Health-check backend auth untuk `AuthLoginPage` (internal, di-provide oleh
@@ -155,6 +268,7 @@ declare class AuthHealthService {
155
268
  }
156
269
 
157
270
  declare class AuthLoginPage {
271
+ private readonly documentRef;
158
272
  private readonly destroyRef;
159
273
  private readonly formBuilder;
160
274
  private readonly injector;
@@ -162,6 +276,8 @@ declare class AuthLoginPage {
162
276
  private readonly authConfig;
163
277
  protected readonly messages: _edsis_angular_module_auth.EdsisAuthMessages;
164
278
  protected readonly health: AuthHealthService;
279
+ protected readonly googleOauth: _edsis_angular_module_auth.ResolvedEdsisAuthGoogleOauth | null;
280
+ protected readonly isGoogleRedirecting: _angular_core.WritableSignal<boolean>;
165
281
  protected readonly form: _angular_forms.FormGroup<{
166
282
  email: _angular_forms.FormControl<string>;
167
283
  }>;
@@ -181,6 +297,8 @@ declare class AuthLoginPage {
181
297
  protected readonly fieldTone: _angular_core.Signal<"success" | "error" | "idle">;
182
298
  protected readonly emailFieldClasses: _angular_core.Signal<"flex-nowrap bg-background/70 shadow-sm [&>[data-slot=input-group-control]]:h-12! [&>[data-slot=input-group-control]]:px-4! [&>[data-slot=input-group-control]]:text-base!" | "flex-nowrap bg-background/70 shadow-sm [&>[data-slot=input-group-control]]:h-12! [&>[data-slot=input-group-control]]:px-4! [&>[data-slot=input-group-control]]:text-base! border-destructive focus-within:border-destructive focus-within:ring-destructive/20" | "flex-nowrap bg-background/70 shadow-sm [&>[data-slot=input-group-control]]:h-12! [&>[data-slot=input-group-control]]:px-4! [&>[data-slot=input-group-control]]:text-base! border-emerald-500 focus-within:border-emerald-500 focus-within:ring-emerald-500/20">;
183
299
  protected retryHealth(): void;
300
+ protected signInWithGoogle(): void;
301
+ protected redirectTo(url: string): void;
184
302
  protected submit(): Promise<void>;
185
303
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<AuthLoginPage, never>;
186
304
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<AuthLoginPage, "edsis-auth-login-page", never, {}, {}, never, never, true, never>;
@@ -256,5 +374,5 @@ declare function injectSessionState(): Promise<boolean>;
256
374
  declare function injectSessionRefresh(): Promise<boolean>;
257
375
  declare function injectSessionClear(): void;
258
376
 
259
- export { AUTH_SESSION_CHANGE_EVENT, AuthLoginPage, AuthLogoutPage, AuthShellPage, AuthVerifyPage, DEFAULT_EDSIS_AUTH_MESSAGES, EDSIS_AUTH_CONFIG, EDSIS_AUTH_MESSAGES, EDSIS_SKIP_AUTH, EDSIS_SKIP_SESSION_REFRESH, authRoutes, authenticatedGuard, clearStoredSession, edsisAuthInterceptor, guestOnlyGuard, hasStoredSession, homeRedirectGuard, injectSessionClear, injectSessionRefresh, injectSessionState, mergeEdsisAuthMessages, persistSession, provideEdsisAuth, readStoredAccessToken, readStoredSession, resolveEdsisAuthConfig, shouldClearSessionAfterRefreshFailure, startAuthSessionMonitor, validateStoredSession, ɵresetAuthSessionModuleState };
260
- export type { EdsisAuthConfig, EdsisAuthHealthCheckConfig, EdsisAuthMessages, EdsisAuthMessagesOverride, ResolvedEdsisAuthConfig, ResolvedEdsisAuthHealthCheck, StoredAuthSession };
377
+ export { AUTH_SESSION_CHANGE_EVENT, AuthGoogleCallbackPage, AuthGoogleOauthService, AuthLoginPage, AuthLogoutPage, AuthShellPage, AuthVerifyPage, DEFAULT_EDSIS_AUTH_MESSAGES, EDSIS_AUTH_CONFIG, EDSIS_AUTH_MESSAGES, EDSIS_SKIP_AUTH, EDSIS_SKIP_SESSION_REFRESH, GOOGLE_OAUTH_AUTHORIZE_URL, GOOGLE_OAUTH_CALLBACK_ROUTE_PATH, GOOGLE_OAUTH_STATE_STORAGE_KEY, authRoutes, authenticatedGuard, buildGoogleAuthorizeUrl, clearStoredSession, consumeGoogleOauthState, createGoogleOauthState, edsisAuthInterceptor, guestOnlyGuard, hasStoredSession, homeRedirectGuard, injectSessionClear, injectSessionRefresh, injectSessionState, mergeEdsisAuthMessages, persistSession, provideEdsisAuth, readStoredAccessToken, readStoredSession, resolveEdsisAuthConfig, shouldClearSessionAfterRefreshFailure, startAuthSessionMonitor, storeGoogleOauthState, validateStoredSession, ɵresetAuthSessionModuleState };
378
+ export type { EdsisAuthConfig, EdsisAuthGoogleOauthConfig, EdsisAuthHealthCheckConfig, EdsisAuthMessages, EdsisAuthMessagesOverride, EdsisAuthOauthConfig, GoogleAuthorizeUrlOptions, ResolvedEdsisAuthConfig, ResolvedEdsisAuthGoogleOauth, ResolvedEdsisAuthHealthCheck, ResolvedEdsisAuthOauth, StoredAuthSession };