@edsis/angular 0.0.2 → 21.0.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.
Files changed (49) hide show
  1. package/README.md +77 -178
  2. package/fesm2022/edsis-angular-auth.mjs +992 -0
  3. package/fesm2022/edsis-angular-auth.mjs.map +1 -0
  4. package/fesm2022/edsis-angular-sdk-access.mjs +1365 -0
  5. package/fesm2022/edsis-angular-sdk-access.mjs.map +1 -0
  6. package/fesm2022/edsis-angular-sdk-approval.mjs +1259 -0
  7. package/fesm2022/edsis-angular-sdk-approval.mjs.map +1 -0
  8. package/fesm2022/edsis-angular-sdk-auth.mjs +254 -0
  9. package/fesm2022/edsis-angular-sdk-auth.mjs.map +1 -0
  10. package/fesm2022/edsis-angular-sdk-employee.mjs +284 -0
  11. package/fesm2022/edsis-angular-sdk-employee.mjs.map +1 -0
  12. package/fesm2022/edsis-angular-sdk-health.mjs +96 -0
  13. package/fesm2022/edsis-angular-sdk-health.mjs.map +1 -0
  14. package/fesm2022/edsis-angular-sdk-shared.mjs +2740 -0
  15. package/fesm2022/edsis-angular-sdk-shared.mjs.map +1 -0
  16. package/fesm2022/edsis-angular-sdk-storage.mjs +288 -0
  17. package/fesm2022/edsis-angular-sdk-storage.mjs.map +1 -0
  18. package/fesm2022/edsis-angular-sdk-user.mjs +489 -0
  19. package/fesm2022/edsis-angular-sdk-user.mjs.map +1 -0
  20. package/fesm2022/edsis-angular-sdk.mjs +75 -0
  21. package/fesm2022/edsis-angular-sdk.mjs.map +1 -0
  22. package/fesm2022/edsis-angular.mjs +0 -5707
  23. package/fesm2022/edsis-angular.mjs.map +1 -1
  24. package/package.json +51 -46
  25. package/types/edsis-angular-auth.d.ts +117 -0
  26. package/types/edsis-angular-sdk-access.d.ts +547 -0
  27. package/types/edsis-angular-sdk-approval.d.ts +638 -0
  28. package/types/edsis-angular-sdk-auth.d.ts +128 -0
  29. package/types/edsis-angular-sdk-employee.d.ts +159 -0
  30. package/types/edsis-angular-sdk-health.d.ts +35 -0
  31. package/types/edsis-angular-sdk-shared.d.ts +176 -0
  32. package/types/edsis-angular-sdk-storage.d.ts +102 -0
  33. package/types/edsis-angular-sdk-user.d.ts +189 -0
  34. package/types/edsis-angular-sdk.d.ts +26 -0
  35. package/types/edsis-angular.d.ts +1 -824
  36. package/src/lib/styles/USAGE.md +0 -238
  37. package/src/lib/styles/container.css +0 -38
  38. package/src/lib/styles/fonts/commit-mono/CommitMonoVariable.woff2 +0 -0
  39. package/src/lib/styles/fonts/commit-mono/commit-mono.css +0 -2
  40. package/src/lib/styles/fonts/inter/InterVariable-Italic.woff2 +0 -0
  41. package/src/lib/styles/fonts/inter/InterVariable.woff2 +0 -0
  42. package/src/lib/styles/fonts/inter/inter.css +0 -2
  43. package/src/lib/styles/icons/README.md +0 -313
  44. package/src/lib/styles/icons/lucide.svg +0 -9768
  45. package/src/lib/styles/icons/material-symbols.css +0 -48
  46. package/src/lib/styles/main.css +0 -24
  47. package/src/lib/styles/tailwind/component/card.css +0 -7
  48. package/src/lib/styles/tailwind/tailwind.css +0 -144
  49. package/src/lib/styles/theme.css +0 -406
@@ -0,0 +1,992 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, makeEnvironmentProviders, ChangeDetectionStrategy, Component, DestroyRef, signal } from '@angular/core';
3
+ import { HttpContextToken, HttpErrorResponse, provideHttpClient, withInterceptors } from '@angular/common/http';
4
+ import { ApiConfiguration, provideApiConfiguration } from '@edsis/angular/sdk/shared';
5
+ import { DOCUMENT, Location } from '@angular/common';
6
+ import { AuthService } from '@edsis/angular/sdk/auth';
7
+ import { firstValueFrom, throwError, from, finalize, combineLatest } from 'rxjs';
8
+ import { switchMap, catchError } from 'rxjs/operators';
9
+ import { Router, RouterOutlet, RouterLink, ActivatedRoute } from '@angular/router';
10
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
+ import * as i1 from '@angular/forms';
12
+ import { FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
13
+
14
+ const DEFAULT_LOGIN_PATH = '/login';
15
+ const DEFAULT_LOGOUT_PATH = '/logout';
16
+ const DEFAULT_VERIFY_PATH = '/verify';
17
+ const DEFAULT_AUTHENTICATED_HOME_PATH = '/dashboard';
18
+ const EDSIS_AUTH_CONFIG = new InjectionToken('EDSIS_AUTH_CONFIG');
19
+ function resolveEdsisAuthConfig(config) {
20
+ const loginPath = normalizePath(config.loginPath, DEFAULT_LOGIN_PATH);
21
+ return {
22
+ apiUrl: normalizeAbsoluteUrl(config.apiUrl, 'apiUrl'),
23
+ appUrl: normalizeAbsoluteUrl(config.appUrl, 'appUrl'),
24
+ loginPath,
25
+ logoutPath: normalizePath(config.logoutPath, DEFAULT_LOGOUT_PATH),
26
+ verifyPath: normalizePath(config.verifyPath, DEFAULT_VERIFY_PATH),
27
+ authenticatedHomePath: normalizePath(config.authenticatedHomePath, DEFAULT_AUTHENTICATED_HOME_PATH),
28
+ guestHomePath: normalizePath(config.guestHomePath, loginPath),
29
+ };
30
+ }
31
+ function normalizeAbsoluteUrl(value, label) {
32
+ const normalizedValue = value.trim();
33
+ if (!normalizedValue) {
34
+ throw new Error(`Edsis auth requires a non-empty ${label}.`);
35
+ }
36
+ const normalizedUrl = new URL(normalizedValue);
37
+ return normalizedUrl.toString().replace(/\/$/, '');
38
+ }
39
+ function normalizePath(value, fallback) {
40
+ const normalizedValue = value?.trim();
41
+ if (!normalizedValue) {
42
+ return fallback;
43
+ }
44
+ return (normalizedValue.startsWith('/') ? normalizedValue : `/${normalizedValue}`);
45
+ }
46
+
47
+ const AUTH_SESSION_STORAGE_KEYS = ['access_token', 'user_id', 'role'];
48
+ const EMPTY_SESSION_FINGERPRINT = '__empty_session__';
49
+ const JWT_PART_COUNT = 3;
50
+ const TOKEN_EXPIRY_SKEW_MS = 30_000;
51
+ let validatedAccessToken = '';
52
+ let validatedUntilEpochMs = 0;
53
+ let failedSessionFingerprint = null;
54
+ let pendingSessionValidation = null;
55
+ function getSessionStorage(documentRef) {
56
+ return documentRef.defaultView?.sessionStorage ?? null;
57
+ }
58
+ function readSessionStorageValue(documentRef, storageKey) {
59
+ return getSessionStorage(documentRef)?.getItem(storageKey)?.trim() ?? '';
60
+ }
61
+ function readSessionDataValue(sessionData, storageKey) {
62
+ const value = sessionData?.[storageKey];
63
+ return typeof value === 'string' ? value.trim() : '';
64
+ }
65
+ function clearValidatedSession() {
66
+ validatedAccessToken = '';
67
+ validatedUntilEpochMs = 0;
68
+ }
69
+ function clearFailedSessionFingerprint() {
70
+ failedSessionFingerprint = null;
71
+ }
72
+ function readSessionFingerprint(documentRef) {
73
+ return readStoredAccessToken(documentRef) || EMPTY_SESSION_FINGERPRINT;
74
+ }
75
+ function hasFailedSessionFingerprint(documentRef) {
76
+ return failedSessionFingerprint === readSessionFingerprint(documentRef);
77
+ }
78
+ function markFailedSessionFingerprint(documentRef) {
79
+ failedSessionFingerprint = readSessionFingerprint(documentRef);
80
+ }
81
+ function getTokenExpiryEpochMs(documentRef, accessToken) {
82
+ const windowRef = documentRef.defaultView;
83
+ const tokenParts = accessToken.split('.');
84
+ if (!windowRef?.atob || tokenParts.length !== JWT_PART_COUNT) {
85
+ return null;
86
+ }
87
+ const normalizedPayload = tokenParts[1].replace(/-/g, '+').replace(/_/g, '/');
88
+ const paddedPayload = normalizedPayload.padEnd(Math.ceil(normalizedPayload.length / 4) * 4, '=');
89
+ try {
90
+ const parsedPayload = JSON.parse(windowRef.atob(paddedPayload));
91
+ return typeof parsedPayload.exp === 'number' ? parsedPayload.exp * 1000 : null;
92
+ }
93
+ catch {
94
+ return null;
95
+ }
96
+ }
97
+ function markValidatedSession(documentRef) {
98
+ const accessToken = readStoredAccessToken(documentRef);
99
+ if (!accessToken) {
100
+ clearValidatedSession();
101
+ return;
102
+ }
103
+ const tokenExpiryEpochMs = getTokenExpiryEpochMs(documentRef, accessToken);
104
+ if (!tokenExpiryEpochMs) {
105
+ clearValidatedSession();
106
+ return;
107
+ }
108
+ validatedAccessToken = accessToken;
109
+ validatedUntilEpochMs = tokenExpiryEpochMs;
110
+ }
111
+ function hasValidatedSession(documentRef) {
112
+ const accessToken = readStoredAccessToken(documentRef);
113
+ if (!accessToken) {
114
+ clearValidatedSession();
115
+ return false;
116
+ }
117
+ if (accessToken !== validatedAccessToken) {
118
+ markValidatedSession(documentRef);
119
+ }
120
+ if (!validatedAccessToken) {
121
+ clearValidatedSession();
122
+ return false;
123
+ }
124
+ return validatedUntilEpochMs > Date.now() + TOKEN_EXPIRY_SKEW_MS;
125
+ }
126
+ function hasStoredSession(documentRef) {
127
+ return Boolean(readStoredAccessToken(documentRef));
128
+ }
129
+ function readStoredAccessToken(documentRef) {
130
+ return readSessionStorageValue(documentRef, 'access_token');
131
+ }
132
+ function readStoredSession(documentRef) {
133
+ const accessToken = readStoredAccessToken(documentRef);
134
+ if (!accessToken) {
135
+ return null;
136
+ }
137
+ const userId = readSessionStorageValue(documentRef, 'user_id');
138
+ const role = readSessionStorageValue(documentRef, 'role');
139
+ return {
140
+ accessToken,
141
+ userId: userId || undefined,
142
+ role: role || undefined,
143
+ };
144
+ }
145
+ function persistSession(documentRef, sessionData) {
146
+ const sessionStorageRef = getSessionStorage(documentRef);
147
+ if (!sessionStorageRef) {
148
+ clearValidatedSession();
149
+ return null;
150
+ }
151
+ for (const storageKey of AUTH_SESSION_STORAGE_KEYS) {
152
+ const nextValue = readSessionDataValue(sessionData, storageKey);
153
+ if (nextValue) {
154
+ sessionStorageRef.setItem(storageKey, nextValue);
155
+ continue;
156
+ }
157
+ sessionStorageRef.removeItem(storageKey);
158
+ }
159
+ markValidatedSession(documentRef);
160
+ clearFailedSessionFingerprint();
161
+ return readStoredSession(documentRef);
162
+ }
163
+ function clearStoredSession(documentRef, options) {
164
+ const sessionStorageRef = getSessionStorage(documentRef);
165
+ for (const storageKey of AUTH_SESSION_STORAGE_KEYS) {
166
+ sessionStorageRef?.removeItem(storageKey);
167
+ }
168
+ clearValidatedSession();
169
+ if (!options?.preserveFailedSessionFingerprint) {
170
+ clearFailedSessionFingerprint();
171
+ }
172
+ }
173
+ async function validateStoredSession(documentRef, authService, options) {
174
+ if (!options?.forceRefresh && hasValidatedSession(documentRef)) {
175
+ return true;
176
+ }
177
+ if (hasFailedSessionFingerprint(documentRef)) {
178
+ return false;
179
+ }
180
+ if (pendingSessionValidation) {
181
+ return pendingSessionValidation;
182
+ }
183
+ pendingSessionValidation = (async () => {
184
+ try {
185
+ const response = await firstValueFrom(authService.refreshAuthToken());
186
+ persistSession(documentRef, response.data);
187
+ return hasValidatedSession(documentRef);
188
+ }
189
+ catch {
190
+ clearStoredSession(documentRef, { preserveFailedSessionFingerprint: true });
191
+ markFailedSessionFingerprint(documentRef);
192
+ return false;
193
+ }
194
+ finally {
195
+ pendingSessionValidation = null;
196
+ }
197
+ })();
198
+ return pendingSessionValidation;
199
+ }
200
+ function injectSessionState() {
201
+ const documentRef = inject(DOCUMENT);
202
+ const authService = inject(AuthService);
203
+ return validateStoredSession(documentRef, authService);
204
+ }
205
+ function injectSessionRefresh() {
206
+ const documentRef = inject(DOCUMENT);
207
+ const authService = inject(AuthService);
208
+ return validateStoredSession(documentRef, authService, { forceRefresh: true });
209
+ }
210
+ function injectSessionClear() {
211
+ clearStoredSession(inject(DOCUMENT));
212
+ }
213
+
214
+ const PROTECTED_API_PATH_PREFIX = '/v1/';
215
+ const AUTH_PATH_PREFIX = '/v1/auth/';
216
+ const HEALTH_PATH = '/health';
217
+ const EDSIS_SKIP_AUTH = new HttpContextToken(() => false);
218
+ const EDSIS_AUTH_RETRY = new HttpContextToken(() => false);
219
+ function normalizeUrl(url) {
220
+ try {
221
+ return new URL(url);
222
+ }
223
+ catch {
224
+ return null;
225
+ }
226
+ }
227
+ function resolveApiPath(url, rootUrl) {
228
+ const normalizedUrl = normalizeUrl(url);
229
+ const normalizedRootUrl = normalizeUrl(rootUrl);
230
+ if (normalizedUrl && normalizedRootUrl) {
231
+ if (normalizedUrl.origin !== normalizedRootUrl.origin) {
232
+ return null;
233
+ }
234
+ if (!normalizedUrl.pathname.startsWith(normalizedRootUrl.pathname)) {
235
+ return null;
236
+ }
237
+ const apiPath = normalizedUrl.pathname.slice(normalizedRootUrl.pathname.length) || '/';
238
+ return apiPath.startsWith('/') ? apiPath : `/${apiPath}`;
239
+ }
240
+ if (url.startsWith(rootUrl)) {
241
+ const apiPath = url.slice(rootUrl.length).split(/[?#]/, 1)[0] ?? '/';
242
+ return apiPath.startsWith('/') ? apiPath : `/${apiPath}`;
243
+ }
244
+ if (url.startsWith('/')) {
245
+ return url.split(/[?#]/, 1)[0] ?? url;
246
+ }
247
+ return null;
248
+ }
249
+ function isAuthRequest(apiPath) {
250
+ return apiPath.startsWith(AUTH_PATH_PREFIX);
251
+ }
252
+ function isProtectedApiRequest(apiPath) {
253
+ return apiPath.startsWith(PROTECTED_API_PATH_PREFIX) && !isAuthRequest(apiPath);
254
+ }
255
+ function isHealthRequest(apiPath) {
256
+ return apiPath === HEALTH_PATH;
257
+ }
258
+ function isHandledRequest(apiPath) {
259
+ return isProtectedApiRequest(apiPath) || isAuthRequest(apiPath) || isHealthRequest(apiPath);
260
+ }
261
+ function applyCookieCredentials(request, apiPath) {
262
+ return isAuthRequest(apiPath) && !request.withCredentials
263
+ ? request.clone({ withCredentials: true })
264
+ : request;
265
+ }
266
+ function applyBearerToken(request, accessToken, isRetry = false) {
267
+ return request.clone({
268
+ context: isRetry ? request.context.set(EDSIS_AUTH_RETRY, true) : request.context,
269
+ setHeaders: {
270
+ Authorization: `Bearer ${accessToken}`,
271
+ },
272
+ });
273
+ }
274
+ async function resolveAccessToken(documentRef, authService, options) {
275
+ const isSessionValid = await validateStoredSession(documentRef, authService, options);
276
+ return isSessionValid ? readStoredAccessToken(documentRef) : '';
277
+ }
278
+ function handleUnauthorizedError(error, request, next, documentRef, authService) {
279
+ if (!(error instanceof HttpErrorResponse) ||
280
+ error.status !== 401 ||
281
+ request.context.get(EDSIS_AUTH_RETRY)) {
282
+ return throwError(() => error);
283
+ }
284
+ return from(resolveAccessToken(documentRef, authService, { forceRefresh: true })).pipe(switchMap((refreshedAccessToken) => {
285
+ if (!refreshedAccessToken) {
286
+ clearStoredSession(documentRef);
287
+ return throwError(() => error);
288
+ }
289
+ return next(applyBearerToken(request, refreshedAccessToken, true));
290
+ }), catchError(() => {
291
+ clearStoredSession(documentRef);
292
+ return throwError(() => error);
293
+ }));
294
+ }
295
+ const edsisAuthInterceptor = (request, next) => {
296
+ const documentRef = inject(DOCUMENT);
297
+ const apiConfiguration = inject(ApiConfiguration);
298
+ const authService = inject(AuthService);
299
+ if (request.context.get(EDSIS_SKIP_AUTH)) {
300
+ return next(request);
301
+ }
302
+ const apiPath = resolveApiPath(request.url, apiConfiguration.rootUrl);
303
+ if (!apiPath || !isHandledRequest(apiPath)) {
304
+ return next(request);
305
+ }
306
+ const preparedRequest = applyCookieCredentials(request, apiPath);
307
+ if (isAuthRequest(apiPath) || isHealthRequest(apiPath)) {
308
+ return next(preparedRequest);
309
+ }
310
+ return from(resolveAccessToken(documentRef, authService)).pipe(switchMap((accessToken) => {
311
+ const authorizedRequest = accessToken
312
+ ? applyBearerToken(preparedRequest, accessToken)
313
+ : preparedRequest;
314
+ return next(authorizedRequest).pipe(catchError((error) => handleUnauthorizedError(error, preparedRequest, next, documentRef, authService)));
315
+ }));
316
+ };
317
+
318
+ function provideEdsisAuth(config) {
319
+ const resolvedConfig = resolveEdsisAuthConfig(config);
320
+ return makeEnvironmentProviders([
321
+ provideApiConfiguration(resolvedConfig.apiUrl),
322
+ provideHttpClient(withInterceptors([edsisAuthInterceptor])),
323
+ {
324
+ provide: EDSIS_AUTH_CONFIG,
325
+ useValue: resolvedConfig,
326
+ },
327
+ ]);
328
+ }
329
+
330
+ const authenticatedGuard = async () => {
331
+ const router = inject(Router);
332
+ const authConfig = inject(EDSIS_AUTH_CONFIG);
333
+ if (await injectSessionState()) {
334
+ return true;
335
+ }
336
+ return router.parseUrl(authConfig.guestHomePath);
337
+ };
338
+ const homeRedirectGuard = async () => {
339
+ const router = inject(Router);
340
+ const authConfig = inject(EDSIS_AUTH_CONFIG);
341
+ return router.parseUrl((await injectSessionState()) ? authConfig.authenticatedHomePath : authConfig.guestHomePath);
342
+ };
343
+ const guestOnlyGuard = async () => {
344
+ const router = inject(Router);
345
+ const authConfig = inject(EDSIS_AUTH_CONFIG);
346
+ if (!(await injectSessionState())) {
347
+ return true;
348
+ }
349
+ return router.parseUrl(authConfig.authenticatedHomePath);
350
+ };
351
+
352
+ class AuthShellPage {
353
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthShellPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
354
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.9", type: AuthShellPage, isStandalone: true, selector: "edsis-auth-shell-page", host: { classAttribute: "block min-h-screen bg-background text-foreground" }, ngImport: i0, template: `
355
+ <section class="relative flex min-h-screen items-center justify-center overflow-hidden px-4 py-10 sm:px-6 lg:px-8">
356
+ <div
357
+ aria-hidden="true"
358
+ class="absolute inset-0 bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_38%),radial-gradient(circle_at_bottom_right,rgba(34,197,94,0.14),transparent_34%)]"></div>
359
+
360
+ <div class="relative grid w-full max-w-5xl gap-8 lg:grid-cols-[1.05fr_0.95fr]">
361
+ <div
362
+ class="hidden rounded-4xl border border-border/70 bg-card/85 p-8 shadow-xl backdrop-blur lg:flex lg:flex-col lg:justify-between">
363
+ <div class="space-y-6">
364
+ <div
365
+ class="inline-flex items-center gap-3 rounded-full border border-border/70 bg-background/70 px-4 py-2 text-sm font-medium text-muted-foreground">
366
+ <span
367
+ class="flex h-9 w-9 items-center justify-center rounded-full bg-primary text-sm font-semibold tracking-[0.2em] text-background">
368
+ ED
369
+ </span>
370
+ Edsis Access Flow
371
+ </div>
372
+
373
+ <div class="space-y-3">
374
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Magic Link Access</p>
375
+ <h1 class="max-w-md text-4xl font-semibold tracking-tight text-balance">
376
+ Masuk ke workspace Edsis tanpa password statis.
377
+ </h1>
378
+ <p class="max-w-xl text-base leading-7 text-muted-foreground">
379
+ Entry point auth ini memusatkan flow login, verify, logout, guard, interceptor, dan session handling di
380
+ satu library yang bisa dipakai ulang.
381
+ </p>
382
+ </div>
383
+ </div>
384
+
385
+ <div class="grid gap-4 sm:grid-cols-3">
386
+ <article class="rounded-2xl border border-border/70 bg-background/70 p-4">
387
+ <p class="text-sm font-semibold">Login</p>
388
+ <p class="mt-2 text-sm leading-6 text-muted-foreground">
389
+ Mengirim ulang magic link melalui SDK auth dan memakai URL verify yang berasal dari konfigurasi
390
+ aplikasi.
391
+ </p>
392
+ </article>
393
+ <article class="rounded-2xl border border-border/70 bg-background/70 p-4">
394
+ <p class="text-sm font-semibold">Verify</p>
395
+ <p class="mt-2 text-sm leading-6 text-muted-foreground">
396
+ Memverifikasi token satu kali pakai, menyimpan access token, dan menyiapkan sesi refresh cookie.
397
+ </p>
398
+ </article>
399
+ <article class="rounded-2xl border border-border/70 bg-background/70 p-4">
400
+ <p class="text-sm font-semibold">Logout</p>
401
+ <p class="mt-2 text-sm leading-6 text-muted-foreground">
402
+ Menghapus sesi tersimpan dan merevoke refresh token pada backend.
403
+ </p>
404
+ </article>
405
+ </div>
406
+ </div>
407
+
408
+ <div class="rounded-4xl border border-border/80 bg-card/95 p-6 shadow-2xl backdrop-blur sm:p-8">
409
+ <router-outlet />
410
+ </div>
411
+ </div>
412
+ </section>
413
+ `, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
414
+ }
415
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthShellPage, decorators: [{
416
+ type: Component,
417
+ args: [{
418
+ selector: 'edsis-auth-shell-page',
419
+ imports: [RouterOutlet],
420
+ host: {
421
+ class: 'block min-h-screen bg-background text-foreground',
422
+ },
423
+ template: `
424
+ <section class="relative flex min-h-screen items-center justify-center overflow-hidden px-4 py-10 sm:px-6 lg:px-8">
425
+ <div
426
+ aria-hidden="true"
427
+ class="absolute inset-0 bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_38%),radial-gradient(circle_at_bottom_right,rgba(34,197,94,0.14),transparent_34%)]"></div>
428
+
429
+ <div class="relative grid w-full max-w-5xl gap-8 lg:grid-cols-[1.05fr_0.95fr]">
430
+ <div
431
+ class="hidden rounded-4xl border border-border/70 bg-card/85 p-8 shadow-xl backdrop-blur lg:flex lg:flex-col lg:justify-between">
432
+ <div class="space-y-6">
433
+ <div
434
+ class="inline-flex items-center gap-3 rounded-full border border-border/70 bg-background/70 px-4 py-2 text-sm font-medium text-muted-foreground">
435
+ <span
436
+ class="flex h-9 w-9 items-center justify-center rounded-full bg-primary text-sm font-semibold tracking-[0.2em] text-background">
437
+ ED
438
+ </span>
439
+ Edsis Access Flow
440
+ </div>
441
+
442
+ <div class="space-y-3">
443
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Magic Link Access</p>
444
+ <h1 class="max-w-md text-4xl font-semibold tracking-tight text-balance">
445
+ Masuk ke workspace Edsis tanpa password statis.
446
+ </h1>
447
+ <p class="max-w-xl text-base leading-7 text-muted-foreground">
448
+ Entry point auth ini memusatkan flow login, verify, logout, guard, interceptor, dan session handling di
449
+ satu library yang bisa dipakai ulang.
450
+ </p>
451
+ </div>
452
+ </div>
453
+
454
+ <div class="grid gap-4 sm:grid-cols-3">
455
+ <article class="rounded-2xl border border-border/70 bg-background/70 p-4">
456
+ <p class="text-sm font-semibold">Login</p>
457
+ <p class="mt-2 text-sm leading-6 text-muted-foreground">
458
+ Mengirim ulang magic link melalui SDK auth dan memakai URL verify yang berasal dari konfigurasi
459
+ aplikasi.
460
+ </p>
461
+ </article>
462
+ <article class="rounded-2xl border border-border/70 bg-background/70 p-4">
463
+ <p class="text-sm font-semibold">Verify</p>
464
+ <p class="mt-2 text-sm leading-6 text-muted-foreground">
465
+ Memverifikasi token satu kali pakai, menyimpan access token, dan menyiapkan sesi refresh cookie.
466
+ </p>
467
+ </article>
468
+ <article class="rounded-2xl border border-border/70 bg-background/70 p-4">
469
+ <p class="text-sm font-semibold">Logout</p>
470
+ <p class="mt-2 text-sm leading-6 text-muted-foreground">
471
+ Menghapus sesi tersimpan dan merevoke refresh token pada backend.
472
+ </p>
473
+ </article>
474
+ </div>
475
+ </div>
476
+
477
+ <div class="rounded-4xl border border-border/80 bg-card/95 p-6 shadow-2xl backdrop-blur sm:p-8">
478
+ <router-outlet />
479
+ </div>
480
+ </div>
481
+ </section>
482
+ `,
483
+ changeDetection: ChangeDetectionStrategy.OnPush,
484
+ }]
485
+ }] });
486
+
487
+ function buildVerifyUrl(config) {
488
+ const baseUrl = typeof window !== 'undefined' && window.location.origin ? window.location.origin : config.appUrl;
489
+ return new URL(config.verifyPath, `${baseUrl}/`).toString();
490
+ }
491
+ function extractMagicToken(queryToken, fragment) {
492
+ const tokenFromQuery = normalizeText(queryToken);
493
+ if (tokenFromQuery) {
494
+ return tokenFromQuery;
495
+ }
496
+ const normalizedFragment = normalizeText(fragment?.startsWith('#') ? fragment.slice(1) : fragment);
497
+ if (!normalizedFragment) {
498
+ return null;
499
+ }
500
+ const fragmentParams = new URLSearchParams(normalizedFragment);
501
+ const tokenFromFragment = normalizeText(fragmentParams.get('token')) ??
502
+ normalizeText(fragmentParams.get('magic_token')) ??
503
+ normalizeText(fragmentParams.get('value'));
504
+ if (tokenFromFragment) {
505
+ return tokenFromFragment;
506
+ }
507
+ return normalizedFragment.includes('=') ? null : normalizedFragment;
508
+ }
509
+ function getResponseMessage(response, fallback) {
510
+ if (!hasMessage(response)) {
511
+ return fallback;
512
+ }
513
+ return normalizeText(response.message) ?? fallback;
514
+ }
515
+ function getErrorMessage(error, fallback) {
516
+ if (error instanceof HttpErrorResponse) {
517
+ const errorBody = error.error;
518
+ if (typeof errorBody === 'string') {
519
+ return normalizeText(errorBody) ?? fallback;
520
+ }
521
+ if (hasMessage(errorBody)) {
522
+ return normalizeText(errorBody.message) ?? fallback;
523
+ }
524
+ return normalizeText(error.message) ?? fallback;
525
+ }
526
+ if (error instanceof Error) {
527
+ return normalizeText(error.message) ?? fallback;
528
+ }
529
+ return fallback;
530
+ }
531
+ function hasMessage(value) {
532
+ return typeof value === 'object' && value !== null && 'message' in value;
533
+ }
534
+ function normalizeText(value) {
535
+ if (typeof value !== 'string') {
536
+ return null;
537
+ }
538
+ const normalizedValue = value.trim();
539
+ return normalizedValue.length > 0 ? normalizedValue : null;
540
+ }
541
+
542
+ class AuthLoginPage {
543
+ destroyRef = inject(DestroyRef);
544
+ formBuilder = inject(FormBuilder);
545
+ authService = inject(AuthService);
546
+ authConfig = inject(EDSIS_AUTH_CONFIG);
547
+ form = this.formBuilder.nonNullable.group({
548
+ email: ['', [Validators.required, Validators.email, Validators.maxLength(255)]],
549
+ });
550
+ isSubmitting = signal(false, ...(ngDevMode ? [{ debugName: "isSubmitting" }] : /* istanbul ignore next */ []));
551
+ responseMessage = signal(null, ...(ngDevMode ? [{ debugName: "responseMessage" }] : /* istanbul ignore next */ []));
552
+ errorMessage = signal(null, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
553
+ verifyUrl = buildVerifyUrl(this.authConfig);
554
+ emailControl = this.form.controls.email;
555
+ submit() {
556
+ if (this.form.invalid) {
557
+ this.form.markAllAsTouched();
558
+ return;
559
+ }
560
+ this.isSubmitting.set(true);
561
+ this.responseMessage.set(null);
562
+ this.errorMessage.set(null);
563
+ const email = this.emailControl.getRawValue().trim().toLowerCase();
564
+ this.emailControl.setValue(email);
565
+ this.authService
566
+ .resendMagicLink({
567
+ body: {
568
+ email,
569
+ frontend_url: this.verifyUrl,
570
+ },
571
+ })
572
+ .pipe(takeUntilDestroyed(this.destroyRef), finalize(() => this.isSubmitting.set(false)))
573
+ .subscribe({
574
+ next: (response) => {
575
+ this.responseMessage.set(getResponseMessage(response, 'Magic link berhasil dikirim ulang.'));
576
+ },
577
+ error: (error) => {
578
+ this.errorMessage.set(getErrorMessage(error, 'Gagal mengirim magic link.'));
579
+ },
580
+ });
581
+ }
582
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthLoginPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
583
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AuthLoginPage, isStandalone: true, selector: "edsis-auth-login-page", host: { classAttribute: "block" }, ngImport: i0, template: `
584
+ <div class="space-y-8">
585
+ <header class="space-y-3">
586
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Login</p>
587
+ <div class="space-y-2">
588
+ <h2 class="text-3xl font-semibold tracking-tight">Kirim ulang magic link untuk masuk.</h2>
589
+ <p class="max-w-xl text-sm leading-6 text-muted-foreground">
590
+ Masukkan email yang terdaftar. Modul auth akan memanggil endpoint resend dari SDK dan mengarahkan magic link ke halaman verify.
591
+ </p>
592
+ </div>
593
+ </header>
594
+
595
+ <form class="space-y-5" [formGroup]="form" (ngSubmit)="submit()">
596
+ <div class="space-y-2">
597
+ <label class="text-sm font-medium" for="email">Email</label>
598
+ <input
599
+ id="email"
600
+ type="email"
601
+ inputmode="email"
602
+ autocomplete="email"
603
+ formControlName="email"
604
+ placeholder="nama@edsis.local"
605
+ class="w-full rounded-2xl border border-border bg-background px-4 py-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/15" />
606
+
607
+ @if (emailControl.invalid && (emailControl.dirty || emailControl.touched)) {
608
+ <p class="text-sm text-destructive">
609
+ @if (emailControl.hasError('required')) {
610
+ Email wajib diisi.
611
+ } @else {
612
+ Gunakan format email yang valid dengan panjang maksimal 255 karakter.
613
+ }
614
+ </p>
615
+ } @else {
616
+ <p class="text-sm text-muted-foreground">Link verifikasi akan diarahkan ke {{ verifyUrl }}.</p>
617
+ }
618
+ </div>
619
+
620
+ @if (responseMessage()) {
621
+ <div class="rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800">
622
+ {{ responseMessage() }}
623
+ </div>
624
+ }
625
+
626
+ @if (errorMessage()) {
627
+ <div class="rounded-2xl border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive">
628
+ {{ errorMessage() }}
629
+ </div>
630
+ }
631
+
632
+ <button
633
+ type="submit"
634
+ [disabled]="form.invalid || isSubmitting()"
635
+ class="inline-flex w-full items-center justify-center rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-background transition hover:opacity-95 focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-60">
636
+ {{ isSubmitting() ? 'Mengirim magic link...' : 'Kirim magic link' }}
637
+ </button>
638
+ </form>
639
+ </div>
640
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
641
+ }
642
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthLoginPage, decorators: [{
643
+ type: Component,
644
+ args: [{
645
+ selector: 'edsis-auth-login-page',
646
+ imports: [ReactiveFormsModule],
647
+ host: {
648
+ class: 'block',
649
+ },
650
+ template: `
651
+ <div class="space-y-8">
652
+ <header class="space-y-3">
653
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Login</p>
654
+ <div class="space-y-2">
655
+ <h2 class="text-3xl font-semibold tracking-tight">Kirim ulang magic link untuk masuk.</h2>
656
+ <p class="max-w-xl text-sm leading-6 text-muted-foreground">
657
+ Masukkan email yang terdaftar. Modul auth akan memanggil endpoint resend dari SDK dan mengarahkan magic link ke halaman verify.
658
+ </p>
659
+ </div>
660
+ </header>
661
+
662
+ <form class="space-y-5" [formGroup]="form" (ngSubmit)="submit()">
663
+ <div class="space-y-2">
664
+ <label class="text-sm font-medium" for="email">Email</label>
665
+ <input
666
+ id="email"
667
+ type="email"
668
+ inputmode="email"
669
+ autocomplete="email"
670
+ formControlName="email"
671
+ placeholder="nama@edsis.local"
672
+ class="w-full rounded-2xl border border-border bg-background px-4 py-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/15" />
673
+
674
+ @if (emailControl.invalid && (emailControl.dirty || emailControl.touched)) {
675
+ <p class="text-sm text-destructive">
676
+ @if (emailControl.hasError('required')) {
677
+ Email wajib diisi.
678
+ } @else {
679
+ Gunakan format email yang valid dengan panjang maksimal 255 karakter.
680
+ }
681
+ </p>
682
+ } @else {
683
+ <p class="text-sm text-muted-foreground">Link verifikasi akan diarahkan ke {{ verifyUrl }}.</p>
684
+ }
685
+ </div>
686
+
687
+ @if (responseMessage()) {
688
+ <div class="rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800">
689
+ {{ responseMessage() }}
690
+ </div>
691
+ }
692
+
693
+ @if (errorMessage()) {
694
+ <div class="rounded-2xl border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive">
695
+ {{ errorMessage() }}
696
+ </div>
697
+ }
698
+
699
+ <button
700
+ type="submit"
701
+ [disabled]="form.invalid || isSubmitting()"
702
+ class="inline-flex w-full items-center justify-center rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-background transition hover:opacity-95 focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-60">
703
+ {{ isSubmitting() ? 'Mengirim magic link...' : 'Kirim magic link' }}
704
+ </button>
705
+ </form>
706
+ </div>
707
+ `,
708
+ changeDetection: ChangeDetectionStrategy.OnPush,
709
+ }]
710
+ }] });
711
+
712
+ class AuthLogoutPage {
713
+ destroyRef = inject(DestroyRef);
714
+ documentRef = inject(DOCUMENT);
715
+ authService = inject(AuthService);
716
+ authConfig = inject(EDSIS_AUTH_CONFIG);
717
+ guestHomePath = this.authConfig.guestHomePath;
718
+ authenticatedHomePath = this.authConfig.authenticatedHomePath;
719
+ state = signal('pending', ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
720
+ message = signal('Mengakhiri sesi...', ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
721
+ ngOnInit() {
722
+ clearStoredSession(this.documentRef);
723
+ this.authService
724
+ .logoutAuthSession()
725
+ .pipe(takeUntilDestroyed(this.destroyRef), finalize(() => {
726
+ if (this.state() === 'pending') {
727
+ this.state.set('success');
728
+ }
729
+ }))
730
+ .subscribe({
731
+ next: (response) => {
732
+ this.state.set('success');
733
+ this.message.set(getResponseMessage(response, 'Sesi berhasil diakhiri.'));
734
+ },
735
+ error: (error) => {
736
+ this.state.set('error');
737
+ this.message.set(getErrorMessage(error, 'Sesi lokal sudah dihapus, tetapi request logout gagal.'));
738
+ },
739
+ });
740
+ }
741
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthLogoutPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
742
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AuthLogoutPage, isStandalone: true, selector: "edsis-auth-logout-page", host: { classAttribute: "block" }, ngImport: i0, template: `
743
+ <div class="space-y-6">
744
+ <header class="space-y-3">
745
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Logout</p>
746
+ <h2 class="text-3xl font-semibold tracking-tight">Mengakhiri sesi Edsis.</h2>
747
+ <p class="max-w-xl text-sm leading-6 text-muted-foreground">
748
+ Halaman ini membersihkan sesi lokal lalu memanggil endpoint logout untuk merevoke refresh-token cookie pada backend.
749
+ </p>
750
+ </header>
751
+
752
+ <div class="rounded-2xl border border-border bg-background/80 px-5 py-4 text-sm leading-6 text-foreground">
753
+ {{ message() }}
754
+ </div>
755
+
756
+ @if (state() === 'error') {
757
+ <div class="rounded-2xl border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive">
758
+ Backend tidak mengonfirmasi logout, tetapi sesi lokal sudah dihapus.
759
+ </div>
760
+ }
761
+
762
+ <div class="flex flex-wrap gap-3">
763
+ <a
764
+ [routerLink]="guestHomePath"
765
+ class="inline-flex items-center justify-center rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-background transition hover:opacity-95 focus:outline-none focus:ring-2 focus:ring-primary/20">
766
+ Kembali ke login
767
+ </a>
768
+ <a
769
+ [routerLink]="authenticatedHomePath"
770
+ class="inline-flex items-center justify-center rounded-2xl border border-border px-4 py-3 text-sm font-semibold text-foreground transition hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary/20">
771
+ Buka dashboard
772
+ </a>
773
+ </div>
774
+ </div>
775
+ `, isInline: true, dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
776
+ }
777
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthLogoutPage, decorators: [{
778
+ type: Component,
779
+ args: [{
780
+ selector: 'edsis-auth-logout-page',
781
+ imports: [RouterLink],
782
+ host: {
783
+ class: 'block',
784
+ },
785
+ template: `
786
+ <div class="space-y-6">
787
+ <header class="space-y-3">
788
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Logout</p>
789
+ <h2 class="text-3xl font-semibold tracking-tight">Mengakhiri sesi Edsis.</h2>
790
+ <p class="max-w-xl text-sm leading-6 text-muted-foreground">
791
+ Halaman ini membersihkan sesi lokal lalu memanggil endpoint logout untuk merevoke refresh-token cookie pada backend.
792
+ </p>
793
+ </header>
794
+
795
+ <div class="rounded-2xl border border-border bg-background/80 px-5 py-4 text-sm leading-6 text-foreground">
796
+ {{ message() }}
797
+ </div>
798
+
799
+ @if (state() === 'error') {
800
+ <div class="rounded-2xl border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive">
801
+ Backend tidak mengonfirmasi logout, tetapi sesi lokal sudah dihapus.
802
+ </div>
803
+ }
804
+
805
+ <div class="flex flex-wrap gap-3">
806
+ <a
807
+ [routerLink]="guestHomePath"
808
+ class="inline-flex items-center justify-center rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-background transition hover:opacity-95 focus:outline-none focus:ring-2 focus:ring-primary/20">
809
+ Kembali ke login
810
+ </a>
811
+ <a
812
+ [routerLink]="authenticatedHomePath"
813
+ class="inline-flex items-center justify-center rounded-2xl border border-border px-4 py-3 text-sm font-semibold text-foreground transition hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary/20">
814
+ Buka dashboard
815
+ </a>
816
+ </div>
817
+ </div>
818
+ `,
819
+ changeDetection: ChangeDetectionStrategy.OnPush,
820
+ }]
821
+ }] });
822
+
823
+ class AuthVerifyPage {
824
+ destroyRef = inject(DestroyRef);
825
+ documentRef = inject(DOCUMENT);
826
+ route = inject(ActivatedRoute);
827
+ router = inject(Router);
828
+ location = inject(Location);
829
+ authService = inject(AuthService);
830
+ authConfig = inject(EDSIS_AUTH_CONFIG);
831
+ guestHomePath = this.authConfig.guestHomePath;
832
+ authenticatedHomePath = this.authConfig.authenticatedHomePath;
833
+ state = signal('pending', ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
834
+ message = signal('Memverifikasi magic link...', ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
835
+ ngOnInit() {
836
+ combineLatest([this.route.queryParamMap, this.route.fragment])
837
+ .pipe(takeUntilDestroyed(this.destroyRef))
838
+ .subscribe(([queryParamMap, fragment]) => {
839
+ const token = extractMagicToken(queryParamMap.get('token'), fragment);
840
+ this.clearTokenFromAddressBar();
841
+ if (!token) {
842
+ this.state.set('error');
843
+ this.message.set('Token magic link tidak ditemukan pada URL yang dibuka.');
844
+ return;
845
+ }
846
+ this.verify(token);
847
+ });
848
+ }
849
+ clearTokenFromAddressBar() {
850
+ this.location.replaceState(this.authConfig.verifyPath);
851
+ }
852
+ verify(token) {
853
+ this.authService
854
+ .verifyMagicLink({
855
+ body: {
856
+ token,
857
+ device_type: 'web',
858
+ },
859
+ })
860
+ .pipe(takeUntilDestroyed(this.destroyRef))
861
+ .subscribe({
862
+ next: (response) => {
863
+ const session = persistSession(this.documentRef, response.data);
864
+ if (!session) {
865
+ this.state.set('error');
866
+ this.message.set('Verifikasi berhasil, tetapi access token tidak ditemukan di respons backend.');
867
+ return;
868
+ }
869
+ this.state.set('success');
870
+ this.message.set(getResponseMessage(response, 'Verifikasi berhasil. Mengarahkan ke dashboard...'));
871
+ void this.router.navigateByUrl(this.authenticatedHomePath, { replaceUrl: true });
872
+ },
873
+ error: (error) => {
874
+ this.state.set('error');
875
+ this.message.set(getErrorMessage(error, 'Magic link tidak valid atau sudah kedaluwarsa.'));
876
+ },
877
+ });
878
+ }
879
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthVerifyPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
880
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AuthVerifyPage, isStandalone: true, selector: "edsis-auth-verify-page", host: { classAttribute: "block" }, ngImport: i0, template: `
881
+ <div class="space-y-6">
882
+ <header class="space-y-3">
883
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Verify</p>
884
+ <h2 class="text-3xl font-semibold tracking-tight">Memverifikasi magic link.</h2>
885
+ <p class="max-w-xl text-sm leading-6 text-muted-foreground">
886
+ Token akan dikonsumsi satu kali, sesi refresh cookie dibentuk di backend, lalu access token disimpan secara lokal untuk aplikasi.
887
+ </p>
888
+ </header>
889
+
890
+ <div class="rounded-2xl border border-border bg-background/80 px-5 py-4 text-sm leading-6 text-foreground">
891
+ {{ message() }}
892
+ </div>
893
+
894
+ @if (state() === 'error') {
895
+ <div class="rounded-2xl border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive">
896
+ Pastikan Anda membuka link terbaru dari email dan token belum pernah dipakai sebelumnya.
897
+ </div>
898
+ }
899
+
900
+ <div class="flex flex-wrap gap-3">
901
+ <a
902
+ [routerLink]="guestHomePath"
903
+ class="inline-flex items-center justify-center rounded-2xl border border-border px-4 py-3 text-sm font-semibold text-foreground transition hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary/20">
904
+ Minta link baru
905
+ </a>
906
+ <a
907
+ [routerLink]="authenticatedHomePath"
908
+ class="inline-flex items-center justify-center rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-background transition hover:opacity-95 focus:outline-none focus:ring-2 focus:ring-primary/20">
909
+ Buka dashboard
910
+ </a>
911
+ </div>
912
+ </div>
913
+ `, isInline: true, dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
914
+ }
915
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AuthVerifyPage, decorators: [{
916
+ type: Component,
917
+ args: [{
918
+ selector: 'edsis-auth-verify-page',
919
+ imports: [RouterLink],
920
+ host: {
921
+ class: 'block',
922
+ },
923
+ template: `
924
+ <div class="space-y-6">
925
+ <header class="space-y-3">
926
+ <p class="text-sm font-medium uppercase tracking-[0.24em] text-muted-foreground">Verify</p>
927
+ <h2 class="text-3xl font-semibold tracking-tight">Memverifikasi magic link.</h2>
928
+ <p class="max-w-xl text-sm leading-6 text-muted-foreground">
929
+ Token akan dikonsumsi satu kali, sesi refresh cookie dibentuk di backend, lalu access token disimpan secara lokal untuk aplikasi.
930
+ </p>
931
+ </header>
932
+
933
+ <div class="rounded-2xl border border-border bg-background/80 px-5 py-4 text-sm leading-6 text-foreground">
934
+ {{ message() }}
935
+ </div>
936
+
937
+ @if (state() === 'error') {
938
+ <div class="rounded-2xl border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive">
939
+ Pastikan Anda membuka link terbaru dari email dan token belum pernah dipakai sebelumnya.
940
+ </div>
941
+ }
942
+
943
+ <div class="flex flex-wrap gap-3">
944
+ <a
945
+ [routerLink]="guestHomePath"
946
+ class="inline-flex items-center justify-center rounded-2xl border border-border px-4 py-3 text-sm font-semibold text-foreground transition hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary/20">
947
+ Minta link baru
948
+ </a>
949
+ <a
950
+ [routerLink]="authenticatedHomePath"
951
+ class="inline-flex items-center justify-center rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-background transition hover:opacity-95 focus:outline-none focus:ring-2 focus:ring-primary/20">
952
+ Buka dashboard
953
+ </a>
954
+ </div>
955
+ </div>
956
+ `,
957
+ changeDetection: ChangeDetectionStrategy.OnPush,
958
+ }]
959
+ }] });
960
+
961
+ const authRoutes = [
962
+ {
963
+ path: '',
964
+ component: AuthShellPage,
965
+ children: [
966
+ {
967
+ path: 'login',
968
+ title: 'Login',
969
+ canActivate: [guestOnlyGuard],
970
+ component: AuthLoginPage,
971
+ },
972
+ {
973
+ path: 'logout',
974
+ title: 'Logout',
975
+ component: AuthLogoutPage,
976
+ },
977
+ {
978
+ path: 'verify',
979
+ title: 'Verify',
980
+ canActivate: [guestOnlyGuard],
981
+ component: AuthVerifyPage,
982
+ },
983
+ ],
984
+ },
985
+ ];
986
+
987
+ /**
988
+ * Generated bundle index. Do not edit.
989
+ */
990
+
991
+ export { AuthLoginPage, AuthLogoutPage, AuthShellPage, AuthVerifyPage, EDSIS_AUTH_CONFIG, EDSIS_SKIP_AUTH, authRoutes, authenticatedGuard, clearStoredSession, edsisAuthInterceptor, guestOnlyGuard, hasStoredSession, homeRedirectGuard, injectSessionClear, injectSessionRefresh, injectSessionState, persistSession, provideEdsisAuth, readStoredAccessToken, readStoredSession, resolveEdsisAuthConfig, validateStoredSession };
992
+ //# sourceMappingURL=edsis-angular-auth.mjs.map