@edsis/angular 22.0.71 → 22.0.73
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/README.md +51 -3
- package/fesm2022/edsis-angular-block-shell.mjs +15 -32
- package/fesm2022/edsis-angular-block-shell.mjs.map +1 -1
- package/fesm2022/edsis-angular-block-themes.mjs +17 -3
- package/fesm2022/edsis-angular-block-themes.mjs.map +1 -1
- package/fesm2022/edsis-angular-module-auth.mjs +297 -27
- package/fesm2022/edsis-angular-module-auth.mjs.map +1 -1
- package/fesm2022/edsis-angular-services-runtime.mjs +382 -0
- package/fesm2022/edsis-angular-services-runtime.mjs.map +1 -0
- package/package.json +13 -5
- package/types/edsis-angular-block-shell.d.ts +3 -2
- package/types/edsis-angular-block-themes.d.ts +5 -2
- package/types/edsis-angular-module-auth.d.ts +68 -11
- package/types/edsis-angular-services-runtime.d.ts +118 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, signal, computed,
|
|
2
|
+
import { InjectionToken, Injectable, inject, signal, computed, makeEnvironmentProviders, provideAppInitializer, Component, DestroyRef, Injector, viewChild, ElementRef, effect, afterNextRender, input } from '@angular/core';
|
|
3
3
|
import { HttpClient, HttpErrorResponse, HttpContextToken, HttpContext, provideHttpClient, withFetch, withInterceptors } from '@angular/common/http';
|
|
4
4
|
import { provideApiConfiguration } from '@edsis/sdk/shared';
|
|
5
5
|
import { Router, RouterOutlet, ActivatedRoute, RouterLink } from '@angular/router';
|
|
6
|
+
import { setNativeNotificationBadge, RuntimeContextService } from '@edsis/angular/services/runtime';
|
|
6
7
|
import { firstValueFrom, throwError, from, timeout, startWith, finalize } from 'rxjs';
|
|
7
8
|
import { catchError, switchMap } from 'rxjs/operators';
|
|
8
9
|
import { LayoutComponent, LayoutFluidComponent } from '@edsis/theme/layout';
|
|
@@ -57,9 +58,22 @@ function resolveEdsisAuthConfig(config) {
|
|
|
57
58
|
redirectUri: `${appUrl}/${GOOGLE_OAUTH_CALLBACK_ROUTE_PATH}`,
|
|
58
59
|
}
|
|
59
60
|
: null,
|
|
61
|
+
nativeGoogle: config.oauth?.nativeGoogle && config.oauth.nativeGoogle.enabled !== false
|
|
62
|
+
? { apiUrl: normalizeSameOriginPath(config.oauth.nativeGoogle.apiUrl ?? '/api') }
|
|
63
|
+
: null,
|
|
60
64
|
},
|
|
61
65
|
};
|
|
62
66
|
}
|
|
67
|
+
function normalizeSameOriginPath(value) {
|
|
68
|
+
const normalizedValue = value.trim().replace(/\/+$/u, '');
|
|
69
|
+
if (!normalizedValue.startsWith('/') ||
|
|
70
|
+
normalizedValue.startsWith('//') ||
|
|
71
|
+
normalizedValue.includes('?') ||
|
|
72
|
+
normalizedValue.includes('#')) {
|
|
73
|
+
throw new Error('Edsis native Google auth requires a same-origin apiUrl path.');
|
|
74
|
+
}
|
|
75
|
+
return (normalizedValue || '/');
|
|
76
|
+
}
|
|
63
77
|
function normalizeAbsoluteUrl(value, label) {
|
|
64
78
|
const normalizedValue = value.trim();
|
|
65
79
|
if (!normalizedValue) {
|
|
@@ -106,6 +120,9 @@ const DEFAULT_EDSIS_AUTH_MESSAGES = {
|
|
|
106
120
|
badge: 'GOOGLE',
|
|
107
121
|
signInAria: 'Login dengan Google',
|
|
108
122
|
googleRedirecting: 'Mengarahkan ke Google...',
|
|
123
|
+
nativeSignInInProgress: 'Menyelesaikan login Google di perangkat...',
|
|
124
|
+
nativeSignInUnavailable: 'Google Sign-In native tidak tersedia pada perangkat ini. Perbarui aplikasi atau hubungi administrator.',
|
|
125
|
+
nativeSignInFailed: 'Login Google pada perangkat gagal diproses.',
|
|
109
126
|
googleExchangeInProgress: 'Menukar kode otorisasi Google...',
|
|
110
127
|
exchangeInProgressAria: 'Menukar kode otorisasi Google',
|
|
111
128
|
googleStateMismatch: 'Verifikasi keamanan gagal: state OAuth tidak cocok atau hilang. Silakan ulangi login dari awal.',
|
|
@@ -158,10 +175,43 @@ function mergeEdsisAuthMessages(override) {
|
|
|
158
175
|
};
|
|
159
176
|
}
|
|
160
177
|
|
|
178
|
+
const EDSIS_NATIVE_GOOGLE_AUTH_ADAPTER = new InjectionToken('EDSIS_NATIVE_GOOGLE_AUTH_ADAPTER');
|
|
179
|
+
class TauriNativeGoogleAuthAdapter {
|
|
180
|
+
async signInWithGoogle(input) {
|
|
181
|
+
const { invoke } = await import('@tauri-apps/api/core');
|
|
182
|
+
const response = await invoke('plugin:edsis-google-auth|sign_in', {
|
|
183
|
+
nonce: input.nonce,
|
|
184
|
+
});
|
|
185
|
+
if (!isNativeGoogleSignInResult(response)) {
|
|
186
|
+
throw new Error('Native Google Sign-In returned an invalid response.');
|
|
187
|
+
}
|
|
188
|
+
return response;
|
|
189
|
+
}
|
|
190
|
+
async signOutFromGoogle() {
|
|
191
|
+
const { invoke } = await import('@tauri-apps/api/core');
|
|
192
|
+
await invoke('plugin:edsis-google-auth|sign_out');
|
|
193
|
+
}
|
|
194
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: TauriNativeGoogleAuthAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
195
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: TauriNativeGoogleAuthAdapter });
|
|
196
|
+
}
|
|
197
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: TauriNativeGoogleAuthAdapter, decorators: [{
|
|
198
|
+
type: Injectable
|
|
199
|
+
}] });
|
|
200
|
+
function isNativeGoogleSignInResult(value) {
|
|
201
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const result = value;
|
|
205
|
+
return ((result['platform'] === 'ios' || result['platform'] === 'android') &&
|
|
206
|
+
typeof result['idToken'] === 'string' &&
|
|
207
|
+
result['idToken'].trim().length > 0 &&
|
|
208
|
+
typeof result['clientInstanceId'] === 'string' &&
|
|
209
|
+
result['clientInstanceId'].trim().length > 0);
|
|
210
|
+
}
|
|
211
|
+
|
|
161
212
|
/** Native desktop features are optional; browser consumers have no bridge. */
|
|
162
213
|
async function setAuthNotificationBadge(unreadCount) {
|
|
163
|
-
|
|
164
|
-
await desktop?.setNotificationBadge(unreadCount);
|
|
214
|
+
await setNativeNotificationBadge(unreadCount);
|
|
165
215
|
}
|
|
166
216
|
/**
|
|
167
217
|
* Cookie-backed authentication state. The access token intentionally exists
|
|
@@ -172,12 +222,16 @@ class AuthService {
|
|
|
172
222
|
http = inject(HttpClient);
|
|
173
223
|
config = inject(EDSIS_AUTH_CONFIG);
|
|
174
224
|
router = inject(Router, { optional: true });
|
|
225
|
+
runtime = inject(RuntimeContextService, { optional: true });
|
|
226
|
+
nativeGoogleAdapter = inject(EDSIS_NATIVE_GOOGLE_AUTH_ADAPTER, {
|
|
227
|
+
optional: true,
|
|
228
|
+
});
|
|
175
229
|
accessTokenState = signal('', /* @ts-ignore */
|
|
176
230
|
...(ngDevMode ? [{ debugName: "accessTokenState" }] : /* istanbul ignore next */ []));
|
|
177
231
|
userState = signal(null, /* @ts-ignore */
|
|
178
232
|
...(ngDevMode ? [{ debugName: "userState" }] : /* istanbul ignore next */ []));
|
|
179
233
|
refreshInFlight = null;
|
|
180
|
-
|
|
234
|
+
initialization = null;
|
|
181
235
|
accessToken = this.accessTokenState.asReadonly();
|
|
182
236
|
user = this.userState.asReadonly();
|
|
183
237
|
isAuthenticated = computed(() => Boolean(this.accessTokenState()), /* @ts-ignore */
|
|
@@ -185,12 +239,23 @@ class AuthService {
|
|
|
185
239
|
get apiUrl() {
|
|
186
240
|
return this.config.apiUrl.replace(/\/+$/u, '');
|
|
187
241
|
}
|
|
242
|
+
get sessionApiUrl() {
|
|
243
|
+
const nativeApiUrl = this.config.oauth.nativeGoogle?.apiUrl;
|
|
244
|
+
return this.runtime?.isTabletShell() === true && nativeApiUrl
|
|
245
|
+
? nativeApiUrl.replace(/\/+$/u, '')
|
|
246
|
+
: this.apiUrl;
|
|
247
|
+
}
|
|
188
248
|
/** Restores an existing cookie session. A missing/expired cookie is normal. */
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
249
|
+
initialize() {
|
|
250
|
+
this.initialization ??= this.restoreSession();
|
|
251
|
+
return this.initialization;
|
|
252
|
+
}
|
|
253
|
+
async restoreSession() {
|
|
254
|
+
// Runtime selection must settle before choosing the cookie origin. Angular
|
|
255
|
+
// app initializers run concurrently, so auth cannot rely on provider order.
|
|
256
|
+
if (this.runtime) {
|
|
257
|
+
await this.runtime.initialize();
|
|
192
258
|
}
|
|
193
|
-
this.initialized = true;
|
|
194
259
|
if (await this.refresh()) {
|
|
195
260
|
try {
|
|
196
261
|
await this.loadCurrentUser();
|
|
@@ -212,7 +277,7 @@ class AuthService {
|
|
|
212
277
|
if (this.refreshInFlight) {
|
|
213
278
|
return this.refreshInFlight;
|
|
214
279
|
}
|
|
215
|
-
this.refreshInFlight = firstValueFrom(this.http.post(`${this.
|
|
280
|
+
this.refreshInFlight = firstValueFrom(this.http.post(`${this.sessionApiUrl}/v1/auth/refresh`, null, {
|
|
216
281
|
withCredentials: true,
|
|
217
282
|
}))
|
|
218
283
|
.then((response) => {
|
|
@@ -237,7 +302,7 @@ class AuthService {
|
|
|
237
302
|
if (!token) {
|
|
238
303
|
return null;
|
|
239
304
|
}
|
|
240
|
-
const response = await firstValueFrom(this.http.get(`${this.
|
|
305
|
+
const response = await firstValueFrom(this.http.get(`${this.sessionApiUrl}/v1/auth/me`, {
|
|
241
306
|
withCredentials: true,
|
|
242
307
|
headers: { Authorization: `Bearer ${token}` },
|
|
243
308
|
}));
|
|
@@ -247,10 +312,11 @@ class AuthService {
|
|
|
247
312
|
}
|
|
248
313
|
async logout() {
|
|
249
314
|
try {
|
|
250
|
-
await firstValueFrom(this.http.post(`${this.
|
|
315
|
+
await firstValueFrom(this.http.post(`${this.sessionApiUrl}/v1/auth/logout`, null, { withCredentials: true }));
|
|
251
316
|
}
|
|
252
317
|
finally {
|
|
253
318
|
this.clearSession();
|
|
319
|
+
await this.clearNativeGoogleSession();
|
|
254
320
|
}
|
|
255
321
|
}
|
|
256
322
|
clearSession() {
|
|
@@ -278,6 +344,20 @@ class AuthService {
|
|
|
278
344
|
this.userState.set(user);
|
|
279
345
|
}
|
|
280
346
|
}
|
|
347
|
+
async clearNativeGoogleSession() {
|
|
348
|
+
if (!this.nativeGoogleAdapter ||
|
|
349
|
+
this.runtime?.isTabletShell() !== true ||
|
|
350
|
+
!this.runtime.supports('google-native-sign-in')) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
await this.nativeGoogleAdapter.signOutFromGoogle();
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
// Backend logout and memory cleanup remain authoritative. A native SDK
|
|
358
|
+
// sign-out failure must not restore or persist the application session.
|
|
359
|
+
}
|
|
360
|
+
}
|
|
281
361
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
282
362
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
283
363
|
}
|
|
@@ -293,12 +373,21 @@ function apiPath(url, apiUrl) {
|
|
|
293
373
|
// A consumer may use Angular's same-origin dev/prod proxy (`/api/...`) even
|
|
294
374
|
// when `apiUrl` names the upstream origin. Such relative URLs are API calls.
|
|
295
375
|
if (url.startsWith('/')) {
|
|
296
|
-
|
|
376
|
+
const path = url.split(/[?#]/, 1)[0] ?? url;
|
|
377
|
+
return path === '/api' || path.startsWith('/api/') ? path : null;
|
|
297
378
|
}
|
|
298
379
|
try {
|
|
299
380
|
const resolved = new URL(url);
|
|
300
381
|
const api = new URL(apiUrl);
|
|
301
|
-
|
|
382
|
+
if (resolved.origin !== api.origin)
|
|
383
|
+
return null;
|
|
384
|
+
const apiBasePath = api.pathname.replace(/\/+$/u, '') || '/';
|
|
385
|
+
if (apiBasePath !== '/' &&
|
|
386
|
+
resolved.pathname !== apiBasePath &&
|
|
387
|
+
!resolved.pathname.startsWith(`${apiBasePath}/`)) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
return resolved.pathname;
|
|
302
391
|
}
|
|
303
392
|
catch {
|
|
304
393
|
return null;
|
|
@@ -320,7 +409,8 @@ const edsisAuthInterceptor = (request, next) => {
|
|
|
320
409
|
return next(request);
|
|
321
410
|
}
|
|
322
411
|
const path = apiPath(request.url, auth.apiUrl);
|
|
323
|
-
const
|
|
412
|
+
const normalizedAuthPath = path?.startsWith('/api/') ? path.slice(4) : path;
|
|
413
|
+
const isAuthEndpoint = AUTH_ENDPOINTS.has(normalizedAuthPath ?? '') || normalizedAuthPath?.startsWith('/v1/auth/');
|
|
324
414
|
const prepared = authorize(request, isAuthEndpoint ? '' : auth.accessToken());
|
|
325
415
|
if (isAuthEndpoint) {
|
|
326
416
|
return next(prepared);
|
|
@@ -396,6 +486,98 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
396
486
|
type: Injectable
|
|
397
487
|
}] });
|
|
398
488
|
|
|
489
|
+
class NativeGoogleAuthService {
|
|
490
|
+
http = inject(HttpClient);
|
|
491
|
+
auth = inject(AuthService);
|
|
492
|
+
config = inject(EDSIS_AUTH_CONFIG);
|
|
493
|
+
runtime = inject(RuntimeContextService, { optional: true });
|
|
494
|
+
adapter = inject(EDSIS_NATIVE_GOOGLE_AUTH_ADAPTER);
|
|
495
|
+
requiresNativeGoogle = computed(() => this.runtime?.isTabletShell() === true, /* @ts-ignore */
|
|
496
|
+
...(ngDevMode ? [{ debugName: "requiresNativeGoogle" }] : /* istanbul ignore next */ []));
|
|
497
|
+
isAvailable = computed(() => {
|
|
498
|
+
const runtime = this.runtime;
|
|
499
|
+
return (this.config.oauth.nativeGoogle !== null &&
|
|
500
|
+
runtime?.isTabletShell() === true &&
|
|
501
|
+
toNativePlatform(runtime.context().platform) !== null &&
|
|
502
|
+
runtime.supports('google-native-sign-in'));
|
|
503
|
+
}, /* @ts-ignore */
|
|
504
|
+
...(ngDevMode ? [{ debugName: "isAvailable" }] : /* istanbul ignore next */ []));
|
|
505
|
+
async signIn() {
|
|
506
|
+
const nativeConfig = this.config.oauth.nativeGoogle;
|
|
507
|
+
const platform = toNativePlatform(this.runtime?.context().platform);
|
|
508
|
+
if (!nativeConfig || !platform || !this.isAvailable()) {
|
|
509
|
+
throw new Error('Native Google Sign-In is not available in this runtime.');
|
|
510
|
+
}
|
|
511
|
+
const challengeResponse = await firstValueFrom(this.http.post(`${nativeConfig.apiUrl}/v1/auth/google/native/challenge`, { platform, deviceType: 'tablet' }, { withCredentials: true }));
|
|
512
|
+
const challenge = parseChallenge(challengeResponse);
|
|
513
|
+
const response = await this.exchangeNativeToken(nativeConfig.apiUrl, platform, challenge);
|
|
514
|
+
this.auth.acceptTokenResponse(response);
|
|
515
|
+
if (!this.auth.isAuthenticated()) {
|
|
516
|
+
throw new Error('Native Google Sign-In response did not contain an access token.');
|
|
517
|
+
}
|
|
518
|
+
try {
|
|
519
|
+
await this.auth.loadCurrentUser();
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
this.auth.clearSession();
|
|
523
|
+
throw error;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async exchangeNativeToken(apiUrl, platform, challenge) {
|
|
527
|
+
let nativeResult = await this.adapter.signInWithGoogle({
|
|
528
|
+
nonce: challenge.nonce,
|
|
529
|
+
});
|
|
530
|
+
if (nativeResult.platform !== platform) {
|
|
531
|
+
throw new Error('Native Google Sign-In platform does not match the runtime.');
|
|
532
|
+
}
|
|
533
|
+
const clientInstanceId = nativeResult.clientInstanceId;
|
|
534
|
+
let idToken = nativeResult.idToken;
|
|
535
|
+
nativeResult = null;
|
|
536
|
+
try {
|
|
537
|
+
return await firstValueFrom(this.http.post(`${apiUrl}/v1/auth/google/native`, {
|
|
538
|
+
platform,
|
|
539
|
+
idToken,
|
|
540
|
+
challengeId: challenge.challengeId,
|
|
541
|
+
clientInstanceId,
|
|
542
|
+
deviceType: 'tablet',
|
|
543
|
+
}, { withCredentials: true }));
|
|
544
|
+
}
|
|
545
|
+
finally {
|
|
546
|
+
// Strings cannot be zeroized in JavaScript, but dropping both local
|
|
547
|
+
// references immediately after the HTTPS exchange keeps the ID token
|
|
548
|
+
// outside application state and shortens its lifetime in the WebView.
|
|
549
|
+
idToken = '';
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NativeGoogleAuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
553
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NativeGoogleAuthService });
|
|
554
|
+
}
|
|
555
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: NativeGoogleAuthService, decorators: [{
|
|
556
|
+
type: Injectable
|
|
557
|
+
}] });
|
|
558
|
+
function toNativePlatform(platform) {
|
|
559
|
+
return platform === 'ios' || platform === 'android' ? platform : null;
|
|
560
|
+
}
|
|
561
|
+
function parseChallenge(value) {
|
|
562
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
563
|
+
throw new Error('Native Google challenge returned an invalid response.');
|
|
564
|
+
}
|
|
565
|
+
const challenge = value.data;
|
|
566
|
+
if (typeof challenge !== 'object' || challenge === null || Array.isArray(challenge)) {
|
|
567
|
+
throw new Error('Native Google challenge returned an invalid response.');
|
|
568
|
+
}
|
|
569
|
+
const challengeRecord = challenge;
|
|
570
|
+
const challengeId = challengeRecord['challengeId'];
|
|
571
|
+
const nonce = challengeRecord['nonce'];
|
|
572
|
+
if (typeof challengeId !== 'string' ||
|
|
573
|
+
!challengeId.trim() ||
|
|
574
|
+
typeof nonce !== 'string' ||
|
|
575
|
+
!nonce.trim()) {
|
|
576
|
+
throw new Error('Native Google challenge returned an invalid response.');
|
|
577
|
+
}
|
|
578
|
+
return { challengeId, nonce };
|
|
579
|
+
}
|
|
580
|
+
|
|
399
581
|
function provideEdsisAuth(config) {
|
|
400
582
|
const resolvedConfig = resolveEdsisAuthConfig(config);
|
|
401
583
|
return makeEnvironmentProviders([
|
|
@@ -412,6 +594,12 @@ function provideEdsisAuth(config) {
|
|
|
412
594
|
useValue: mergeEdsisAuthMessages(config.messages),
|
|
413
595
|
},
|
|
414
596
|
AuthHealthService,
|
|
597
|
+
NativeGoogleAuthService,
|
|
598
|
+
TauriNativeGoogleAuthAdapter,
|
|
599
|
+
{
|
|
600
|
+
provide: EDSIS_NATIVE_GOOGLE_AUTH_ADAPTER,
|
|
601
|
+
useExisting: TauriNativeGoogleAuthAdapter,
|
|
602
|
+
},
|
|
415
603
|
]);
|
|
416
604
|
}
|
|
417
605
|
|
|
@@ -830,11 +1018,30 @@ class AuthLoginPage {
|
|
|
830
1018
|
injector = inject(Injector);
|
|
831
1019
|
authMagicLinkService = inject(AuthMagicLinkService);
|
|
832
1020
|
authConfig = inject(EDSIS_AUTH_CONFIG);
|
|
1021
|
+
nativeGoogle = inject(NativeGoogleAuthService, { optional: true });
|
|
1022
|
+
router = inject(Router, { optional: true });
|
|
833
1023
|
messages = inject(EDSIS_AUTH_MESSAGES);
|
|
834
1024
|
health = inject(AuthHealthService);
|
|
835
1025
|
googleOauth = this.authConfig.oauth.google;
|
|
836
1026
|
isGoogleRedirecting = signal(false, /* @ts-ignore */
|
|
837
1027
|
...(ngDevMode ? [{ debugName: "isGoogleRedirecting" }] : /* istanbul ignore next */ []));
|
|
1028
|
+
googleErrorMessage = signal(null, /* @ts-ignore */
|
|
1029
|
+
...(ngDevMode ? [{ debugName: "googleErrorMessage" }] : /* istanbul ignore next */ []));
|
|
1030
|
+
requiresNativeGoogle = computed(() => this.nativeGoogle?.requiresNativeGoogle() === true, /* @ts-ignore */
|
|
1031
|
+
...(ngDevMode ? [{ debugName: "requiresNativeGoogle" }] : /* istanbul ignore next */ []));
|
|
1032
|
+
isNativeGoogle = computed(() => this.nativeGoogle?.isAvailable() === true, /* @ts-ignore */
|
|
1033
|
+
...(ngDevMode ? [{ debugName: "isNativeGoogle" }] : /* istanbul ignore next */ []));
|
|
1034
|
+
googleSignInAvailable = computed(() => this.isNativeGoogle() || (!this.requiresNativeGoogle() && this.googleOauth !== null), /* @ts-ignore */
|
|
1035
|
+
...(ngDevMode ? [{ debugName: "googleSignInAvailable" }] : /* istanbul ignore next */ []));
|
|
1036
|
+
googleFeedbackMessage = computed(() => this.googleErrorMessage() ??
|
|
1037
|
+
(this.requiresNativeGoogle() && !this.isNativeGoogle()
|
|
1038
|
+
? this.messages.google.nativeSignInUnavailable
|
|
1039
|
+
: null), /* @ts-ignore */
|
|
1040
|
+
...(ngDevMode ? [{ debugName: "googleFeedbackMessage" }] : /* istanbul ignore next */ []));
|
|
1041
|
+
googleProgressMessage = computed(() => this.isNativeGoogle()
|
|
1042
|
+
? this.messages.google.nativeSignInInProgress
|
|
1043
|
+
: this.messages.google.googleRedirecting, /* @ts-ignore */
|
|
1044
|
+
...(ngDevMode ? [{ debugName: "googleProgressMessage" }] : /* istanbul ignore next */ []));
|
|
838
1045
|
form = this.formBuilder.nonNullable.group({
|
|
839
1046
|
email: ['', [Validators.required, Validators.email, Validators.maxLength(255)]],
|
|
840
1047
|
});
|
|
@@ -919,11 +1126,24 @@ class AuthLoginPage {
|
|
|
919
1126
|
void this.health.check();
|
|
920
1127
|
}
|
|
921
1128
|
signInWithGoogle() {
|
|
1129
|
+
if (this.isGoogleRedirecting()) {
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
if (this.requiresNativeGoogle()) {
|
|
1133
|
+
if (this.isNativeGoogle()) {
|
|
1134
|
+
void this.signInWithNativeGoogle();
|
|
1135
|
+
}
|
|
1136
|
+
else {
|
|
1137
|
+
this.googleErrorMessage.set(this.messages.google.nativeSignInUnavailable);
|
|
1138
|
+
}
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
if (!this.googleSignInAvailable())
|
|
1142
|
+
return;
|
|
922
1143
|
const googleOauth = this.googleOauth;
|
|
923
1144
|
const windowRef = this.documentRef.defaultView;
|
|
924
|
-
if (!googleOauth || !windowRef
|
|
1145
|
+
if (!googleOauth || !windowRef)
|
|
925
1146
|
return;
|
|
926
|
-
}
|
|
927
1147
|
this.isGoogleRedirecting.set(true);
|
|
928
1148
|
const state = createGoogleOauthState(windowRef);
|
|
929
1149
|
storeGoogleOauthState(this.documentRef, state);
|
|
@@ -933,6 +1153,24 @@ class AuthLoginPage {
|
|
|
933
1153
|
state,
|
|
934
1154
|
}));
|
|
935
1155
|
}
|
|
1156
|
+
async signInWithNativeGoogle() {
|
|
1157
|
+
if (!this.nativeGoogle)
|
|
1158
|
+
return;
|
|
1159
|
+
this.isGoogleRedirecting.set(true);
|
|
1160
|
+
this.googleErrorMessage.set(null);
|
|
1161
|
+
try {
|
|
1162
|
+
await this.nativeGoogle.signIn();
|
|
1163
|
+
await this.router?.navigateByUrl(this.authConfig.authenticatedHomePath, {
|
|
1164
|
+
replaceUrl: true,
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
catch {
|
|
1168
|
+
this.googleErrorMessage.set(this.messages.google.nativeSignInFailed);
|
|
1169
|
+
}
|
|
1170
|
+
finally {
|
|
1171
|
+
this.isGoogleRedirecting.set(false);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
936
1174
|
// Full-page redirect keluar dari SPA (bukan Router). Method terpisah karena
|
|
937
1175
|
// jsdom tidak mengizinkan stub pada location.assign.
|
|
938
1176
|
redirectTo(url) {
|
|
@@ -1108,11 +1346,21 @@ class AuthLoginPage {
|
|
|
1108
1346
|
type="button"
|
|
1109
1347
|
variant="outline"
|
|
1110
1348
|
size="lg"
|
|
1111
|
-
[disabled]="!
|
|
1349
|
+
[disabled]="!googleSignInAvailable() || isGoogleRedirecting()"
|
|
1112
1350
|
[attr.aria-label]="
|
|
1113
|
-
|
|
1351
|
+
googleSignInAvailable()
|
|
1352
|
+
? messages.google.signInAria
|
|
1353
|
+
: requiresNativeGoogle()
|
|
1354
|
+
? messages.google.nativeSignInUnavailable
|
|
1355
|
+
: messages.login.oauthGoogleAria
|
|
1356
|
+
"
|
|
1357
|
+
[attr.title]="
|
|
1358
|
+
googleSignInAvailable()
|
|
1359
|
+
? null
|
|
1360
|
+
: requiresNativeGoogle()
|
|
1361
|
+
? messages.google.nativeSignInUnavailable
|
|
1362
|
+
: messages.login.oauthComingSoon
|
|
1114
1363
|
"
|
|
1115
|
-
[attr.title]="googleOauth ? null : messages.login.oauthComingSoon"
|
|
1116
1364
|
(click)="signInWithGoogle()"
|
|
1117
1365
|
class="h-12 gap-3 text-[0.74rem] font-medium uppercase tracking-[0.16em]"
|
|
1118
1366
|
>
|
|
@@ -1139,7 +1387,7 @@ class AuthLoginPage {
|
|
|
1139
1387
|
/>
|
|
1140
1388
|
</svg>
|
|
1141
1389
|
</span>
|
|
1142
|
-
{{ isGoogleRedirecting() ?
|
|
1390
|
+
{{ isGoogleRedirecting() ? googleProgressMessage() : 'Google' }}
|
|
1143
1391
|
</button>
|
|
1144
1392
|
<button
|
|
1145
1393
|
Button
|
|
@@ -1194,7 +1442,13 @@ class AuthLoginPage {
|
|
|
1194
1442
|
|
|
1195
1443
|
@if (isGoogleRedirecting()) {
|
|
1196
1444
|
<p class="sr-only" role="status" aria-live="polite">
|
|
1197
|
-
{{
|
|
1445
|
+
{{ googleProgressMessage() }}
|
|
1446
|
+
</p>
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
@if (googleFeedbackMessage(); as googleError) {
|
|
1450
|
+
<p class="text-sm text-destructive" role="alert" aria-live="assertive">
|
|
1451
|
+
{{ googleError }}
|
|
1198
1452
|
</p>
|
|
1199
1453
|
}
|
|
1200
1454
|
</form>
|
|
@@ -1364,11 +1618,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
1364
1618
|
type="button"
|
|
1365
1619
|
variant="outline"
|
|
1366
1620
|
size="lg"
|
|
1367
|
-
[disabled]="!
|
|
1621
|
+
[disabled]="!googleSignInAvailable() || isGoogleRedirecting()"
|
|
1368
1622
|
[attr.aria-label]="
|
|
1369
|
-
|
|
1623
|
+
googleSignInAvailable()
|
|
1624
|
+
? messages.google.signInAria
|
|
1625
|
+
: requiresNativeGoogle()
|
|
1626
|
+
? messages.google.nativeSignInUnavailable
|
|
1627
|
+
: messages.login.oauthGoogleAria
|
|
1628
|
+
"
|
|
1629
|
+
[attr.title]="
|
|
1630
|
+
googleSignInAvailable()
|
|
1631
|
+
? null
|
|
1632
|
+
: requiresNativeGoogle()
|
|
1633
|
+
? messages.google.nativeSignInUnavailable
|
|
1634
|
+
: messages.login.oauthComingSoon
|
|
1370
1635
|
"
|
|
1371
|
-
[attr.title]="googleOauth ? null : messages.login.oauthComingSoon"
|
|
1372
1636
|
(click)="signInWithGoogle()"
|
|
1373
1637
|
class="h-12 gap-3 text-[0.74rem] font-medium uppercase tracking-[0.16em]"
|
|
1374
1638
|
>
|
|
@@ -1395,7 +1659,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
1395
1659
|
/>
|
|
1396
1660
|
</svg>
|
|
1397
1661
|
</span>
|
|
1398
|
-
{{ isGoogleRedirecting() ?
|
|
1662
|
+
{{ isGoogleRedirecting() ? googleProgressMessage() : 'Google' }}
|
|
1399
1663
|
</button>
|
|
1400
1664
|
<button
|
|
1401
1665
|
Button
|
|
@@ -1450,7 +1714,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
1450
1714
|
|
|
1451
1715
|
@if (isGoogleRedirecting()) {
|
|
1452
1716
|
<p class="sr-only" role="status" aria-live="polite">
|
|
1453
|
-
{{
|
|
1717
|
+
{{ googleProgressMessage() }}
|
|
1718
|
+
</p>
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
@if (googleFeedbackMessage(); as googleError) {
|
|
1722
|
+
<p class="text-sm text-destructive" role="alert" aria-live="assertive">
|
|
1723
|
+
{{ googleError }}
|
|
1454
1724
|
</p>
|
|
1455
1725
|
}
|
|
1456
1726
|
</form>
|
|
@@ -1923,5 +2193,5 @@ const authRoutes = [
|
|
|
1923
2193
|
* Generated bundle index. Do not edit.
|
|
1924
2194
|
*/
|
|
1925
2195
|
|
|
1926
|
-
export { AuthGoogleCallbackPage, AuthLoginPage, AuthLogoutPage, AuthService, AuthShellPage, AuthVerifyPage, DEFAULT_EDSIS_AUTH_MESSAGES, EDSIS_AUTH_CONFIG, EDSIS_AUTH_MESSAGES, EDSIS_SKIP_AUTH, GOOGLE_OAUTH_AUTHORIZE_URL, GOOGLE_OAUTH_CALLBACK_ROUTE_PATH, GOOGLE_OAUTH_STATE_STORAGE_KEY, authRoutes, authenticatedGuard, buildGoogleAuthorizeUrl, consumeGoogleOauthState, createGoogleOauthState, edsisAuthInterceptor, guestOnlyGuard, homeRedirectGuard, mergeEdsisAuthMessages, provideEdsisAuth, resolveEdsisAuthConfig, setAuthNotificationBadge, storeGoogleOauthState };
|
|
2196
|
+
export { AuthGoogleCallbackPage, AuthLoginPage, AuthLogoutPage, AuthService, AuthShellPage, AuthVerifyPage, DEFAULT_EDSIS_AUTH_MESSAGES, EDSIS_AUTH_CONFIG, EDSIS_AUTH_MESSAGES, EDSIS_NATIVE_GOOGLE_AUTH_ADAPTER, EDSIS_SKIP_AUTH, GOOGLE_OAUTH_AUTHORIZE_URL, GOOGLE_OAUTH_CALLBACK_ROUTE_PATH, GOOGLE_OAUTH_STATE_STORAGE_KEY, NativeGoogleAuthService, TauriNativeGoogleAuthAdapter, authRoutes, authenticatedGuard, buildGoogleAuthorizeUrl, consumeGoogleOauthState, createGoogleOauthState, edsisAuthInterceptor, guestOnlyGuard, homeRedirectGuard, isNativeGoogleSignInResult, mergeEdsisAuthMessages, provideEdsisAuth, resolveEdsisAuthConfig, setAuthNotificationBadge, storeGoogleOauthState };
|
|
1927
2197
|
//# sourceMappingURL=edsis-angular-module-auth.mjs.map
|