@rdlabo/ionic-angular-kit 22.0.1-0 → 22.0.1-beta.pr105.sha55308d6acf67

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 CHANGED
@@ -1,11 +1,51 @@
1
1
  # @rdlabo/ionic-angular-kit
2
2
 
3
- `@rdlabo/ionic-angular-kit` provides shared application infrastructure for Ionic Angular applications. It keeps product-specific screens, domain policy, and translations in the consuming app.
3
+ `@rdlabo/ionic-angular-kit` provides typed storage, typed overlays, and Ionic Signal Forms adapters for Ionic Angular applications. Product-specific screens, domain policy, and translations stay in the consuming app.
4
4
 
5
5
  ```sh
6
6
  npm install @rdlabo/ionic-angular-kit
7
7
  ```
8
8
 
9
+ ## First try: save a preference
10
+
11
+ In an existing Ionic Angular application, merge the Ionic Storage provider into your existing app config. Do not replace other providers.
12
+
13
+ ```ts
14
+ import { importProvidersFrom, type ApplicationConfig } from '@angular/core';
15
+ import { IonicStorageModule } from '@ionic/storage-angular';
16
+
17
+ export const appConfig: ApplicationConfig = {
18
+ providers: [importProvidersFrom(IonicStorageModule.forRoot({ name: '__mydb' }))],
19
+ };
20
+ ```
21
+
22
+ Then add this standalone component:
23
+
24
+ ```ts
25
+ import { Component, inject, signal } from '@angular/core';
26
+ import { IonButton } from '@ionic/angular';
27
+ import { disableHandler, KitStorageService } from '@rdlabo/ionic-angular-kit';
28
+
29
+ @Component({
30
+ selector: 'app-preferences-demo',
31
+ imports: [IonButton],
32
+ template: `<ion-button type="button" (click)="disableHandler($event, save())">Save preference</ion-button>
33
+ <p>{{ result() }}</p>`,
34
+ })
35
+ export class PreferencesDemo {
36
+ private readonly storage = inject(KitStorageService);
37
+ readonly result = signal('');
38
+ readonly disableHandler = disableHandler;
39
+
40
+ async save(): Promise<void> {
41
+ await this.storage.set('theme', 'dark');
42
+ this.result.set((await this.storage.get<string>('theme')) ?? '');
43
+ }
44
+ }
45
+ ```
46
+
47
+ Render `<app-preferences-demo>` on an existing page (import `PreferencesDemo` into that standalone page's `imports`). Click Save preference — `dark` appears. `KitStorageService` initializes storage automatically; no manual initialization is required.
48
+
9
49
  ## Requirements
10
50
 
11
51
  | Package | Supported version |
@@ -20,19 +60,23 @@ The core package declares `@ionic/storage-angular` and Capacitor Core, App, Hapt
20
60
 
21
61
  Firebase, social login, Live Update, Preferences, Status Bar, in-app review, and printer/PDF dependencies are optional feature peers. Install only the dependencies used by the selected secondary entry points and follow each plugin's own compatibility range; some optional plugins support only Capacitor 8.
22
62
 
63
+ The `/auth-firebase/google` entry point uses `@capawesome/capacitor-google-sign-in` 0.1.x and therefore requires Capacitor 8. Applications remaining on Capacitor 7 can continue to use the core Kit and other compatible entry points, but cannot use this Google entry point.
64
+
23
65
  ## Entry points
24
66
 
25
- | Import | Responsibility |
26
- | ----------------------------------------- | ---------------------------------------------------------------------------------- |
27
- | `@rdlabo/ionic-angular-kit` | Storage, overlays, guards, HTTP, realtime, directives, keyboard, and utilities |
28
- | `@rdlabo/ionic-angular-kit/offline` | **Experimental.** Scoped local replica, outbox, pull, replay, and request policies |
29
- | `@rdlabo/ionic-angular-kit/theme` | Persisted light/dark theme and native status bar sync |
30
- | `@rdlabo/ionic-angular-kit/forms` | Ionic error text and state classes for Angular Signal Forms |
31
- | `@rdlabo/ionic-angular-kit/review` | Throttled native in-app review requests |
32
- | `@rdlabo/ionic-angular-kit/printer` | DOM-to-PNG, Brother label, and PDF helpers |
33
- | `@rdlabo/ionic-angular-kit/auth-firebase` | Firebase dependency wiring and authentication flows |
34
- | `@rdlabo/ionic-angular-kit/app-update` | Atomic Angular service-worker update transitions |
35
- | `@rdlabo/ionic-angular-kit/live-update` | Capawesome Live Update readiness provider |
67
+ | Import | Responsibility |
68
+ | ------------------------------------------------ | ---------------------------------------------------------------------------------- |
69
+ | `@rdlabo/ionic-angular-kit` | Storage, overlays, guards, HTTP, realtime, directives, keyboard, and utilities |
70
+ | `@rdlabo/ionic-angular-kit/offline` | **Experimental.** Scoped local replica, outbox, pull, replay, and request policies |
71
+ | `@rdlabo/ionic-angular-kit/theme` | Persisted light/dark theme and native status bar sync |
72
+ | `@rdlabo/ionic-angular-kit/forms` | Ionic error text and state classes for Angular Signal Forms |
73
+ | `@rdlabo/ionic-angular-kit/review` | Throttled native in-app review requests |
74
+ | `@rdlabo/ionic-angular-kit/printer` | DOM-to-PNG, Brother label, and PDF helpers |
75
+ | `@rdlabo/ionic-angular-kit/auth-firebase` | Firebase dependency wiring and authentication flows |
76
+ | `@rdlabo/ionic-angular-kit/auth-firebase/google` | Google popup/native sign-in, Firebase session linking, and logout |
77
+ | `@rdlabo/ionic-angular-kit/auth-firebase/social` | Apple and Facebook Firebase social-auth helpers |
78
+ | `@rdlabo/ionic-angular-kit/app-update` | Atomic Angular service-worker update transitions |
79
+ | `@rdlabo/ionic-angular-kit/live-update` | Capawesome Live Update readiness provider |
36
80
 
37
81
  Secondary entry points isolate optional native and SDK dependencies from the core bundle.
38
82
 
@@ -40,11 +84,13 @@ The entire `/offline` entry point is experimental and is not covered by the kit'
40
84
 
41
85
  ## Configure only what you use
42
86
 
43
- Most features expose a provider whose callbacks keep routes, copy, credentials, and application side effects outside the kit. Start with [Storage and Overlays](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/storage-overlays), then add authentication, offline, or native features as your app needs them. The [Offline and Realtime](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/offline-realtime) guide includes the required SQLite connection, provider/interceptor order, read strategies, durable Outbox flow, and repository concurrency rules.
87
+ Most features expose a provider whose callbacks keep routes, copy, credentials, and application side effects outside the kit. Start with [Storage and Overlays](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/storage-overlays) and [Forms](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/forms).
44
88
 
45
89
  ## Documentation
46
90
 
47
91
  - [Storage and Overlays](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/storage-overlays)
92
+ - [Forms](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/forms)
93
+ - [Check your Kit integration with ESLint](./docs/eslint.md)
48
94
  - [Authentication and HTTP](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/auth-http)
49
95
  - [Offline and Realtime](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/offline-realtime)
50
96
  - [Optional Features](https://docs.rdlabo.dev/projects/ionic-angular-kit/docs/optional-features)
package/docs/auth-http.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Access capability
2
2
 
3
- `provideKitAuth()` configures functional route guards for `user`, `confirm`, `required`, `anonymous`, and `unavailable` authentication states. Redirect routes and application side effects remain in the app.
3
+ `provideKitAuth()` configures functional route guards for `user`, `confirm`, `required`, `anonymous`, and `unavailable` authentication states. Redirect routes and application side effects remain in the app. `AuthService` in the examples below is application-owned; supply your own `authState` observable and optional lifecycle callbacks.
4
4
 
5
5
  `KitAuthAccessService` publishes what the current session may do:
6
6
 
@@ -13,23 +13,74 @@
13
13
  An authoritative `required` result is signed out and must not become offline access. Only an `unavailable` transport result may activate a previously verified local session.
14
14
 
15
15
  ```ts
16
- provideKitAuth(() => ({
17
- authState: () => inject(AuthService).state$,
18
- redirects: {
19
- whenAuthorized: '/home',
20
- whenConfirming: '/auth/confirm',
21
- whenNotConfirming: '/auth/signin',
22
- whenUnauthorized: '/auth',
23
- },
24
- isUnavailableError: (error) => isOfflineFallbackError(error),
25
- }));
16
+ import { inject } from '@angular/core';
17
+ import type { Routes } from '@angular/router';
18
+ import {
19
+ kitRequireAuthorizedGuard,
20
+ kitRequireConfirmingGuard,
21
+ kitRequiredUnauthorizedGuard,
22
+ provideKitAuth,
23
+ } from '@rdlabo/ionic-angular-kit';
24
+ import { AuthService } from './auth.service';
25
+
26
+ provideKitAuth(() => {
27
+ const auth = inject(AuthService);
28
+ return {
29
+ authState: () => auth.state$,
30
+ redirects: {
31
+ whenAuthorized: '/home',
32
+ whenConfirming: '/auth/confirm',
33
+ whenNotConfirming: '/auth/signin',
34
+ whenUnauthorized: '/auth',
35
+ },
36
+ };
37
+ });
38
+
39
+ export const routes: Routes = [
40
+ { path: 'auth/signin', canActivate: [kitRequiredUnauthorizedGuard], loadComponent: () => import('./signin.page').then((m) => m.SigninPage) },
41
+ { path: 'auth/confirm', canActivate: [kitRequireConfirmingGuard], loadComponent: () => import('./confirm.page').then((m) => m.ConfirmPage) },
42
+ { path: 'home', canActivate: [kitRequireAuthorizedGuard], loadComponent: () => import('./home.page').then((m) => m.HomePage) },
43
+ ];
26
44
  ```
27
45
 
28
46
  Use `kitRequiredUnauthorizedGuard`, `kitRequireConfirmingGuard`, and `kitRequireAuthorizedGuard` in route definitions. A protected asynchronous decision suspends previously published remote capability until the current authorization lease succeeds.
29
47
 
30
48
  ## HTTP policy
31
49
 
32
- `provideKitHttp()` configures `kitAuthInterceptor` for credential injection, bypass rules, transient failure handling, and application error hooks.
50
+ `provideKitHttp()` configures `kitAuthInterceptor` for credential injection, bypass rules, transient failure handling, and application error hooks. Register the interceptor separately with `provideHttpClient`. Only `getAuthHeaders` is required; every other hook is optional and application-owned.
51
+
52
+ ```ts
53
+ import { provideHttpClient, withInterceptors } from '@angular/common/http';
54
+ import { inject } from '@angular/core';
55
+ import type { ApplicationConfig } from '@angular/core';
56
+ import { kitAuthInterceptor, provideKitAuth, provideKitHttp } from '@rdlabo/ionic-angular-kit';
57
+ import { AuthService } from './auth.service';
58
+
59
+ export const appConfig: ApplicationConfig = {
60
+ providers: [
61
+ provideHttpClient(withInterceptors([kitAuthInterceptor])),
62
+ provideKitAuth(() => {
63
+ const auth = inject(AuthService);
64
+ return {
65
+ authState: () => auth.state$,
66
+ redirects: {
67
+ whenAuthorized: '/home',
68
+ whenConfirming: '/auth/confirm',
69
+ whenNotConfirming: '/auth/signin',
70
+ whenUnauthorized: '/auth',
71
+ },
72
+ };
73
+ }),
74
+ provideKitHttp(() => {
75
+ const auth = inject(AuthService);
76
+ return {
77
+ getAuthHeaders: async () => ({ Authorization: `Bearer ${await auth.token()}` }),
78
+ onUnauthorized: () => auth.signOut(),
79
+ };
80
+ }),
81
+ ],
82
+ };
83
+ ```
33
84
 
34
85
  Automatic retry is limited to `GET`, `HEAD`, `OPTIONS`, or requests carrying an `Idempotency-Key`. Ordinary writes are never retried automatically. Retries cover transient statuses `0`, `408`, `429`, `502`, `503`, and `504`, and honor `Retry-After`.
35
86
 
package/docs/eslint.md ADDED
@@ -0,0 +1,113 @@
1
+ ---
2
+ title: Check your Kit integration with ESLint
3
+ ---
4
+
5
+ Keep modal launchers, async action handlers, and form errors consistent as your Ionic Angular app grows. `@rdlabo/eslint-plugin-rules` checks the call patterns that work with `@rdlabo/ionic-angular-kit`.
6
+
7
+ ## Enable the checks you use
8
+
9
+ In an Ionic Angular 9 app with Angular / Angular ESLint 21–22 configured:
10
+
11
+ ```sh
12
+ npm install --save-dev @rdlabo/eslint-plugin-rules@22
13
+ ```
14
+
15
+ Merge these entries into `eslint.config.mjs`, retaining your existing checks. They enable four focused rules; choose the ones that match the Kit features in your app.
16
+
17
+ ```js
18
+ import tseslint from 'typescript-eslint';
19
+ import angular from 'angular-eslint';
20
+ import rdlabo from '@rdlabo/eslint-plugin-rules';
21
+
22
+ export default tseslint.config(
23
+ {
24
+ files: ['**/*.ts'],
25
+ languageOptions: { parser: tseslint.parser },
26
+ processor: angular.processInlineTemplates,
27
+ plugins: { '@rdlabo/rules': rdlabo },
28
+ rules: {
29
+ '@rdlabo/rules/deny-overlay-create': 'error',
30
+ '@rdlabo/rules/prefer-modal-launcher': 'error',
31
+ },
32
+ },
33
+ {
34
+ files: ['**/*.html'],
35
+ languageOptions: { parser: angular.templateParser },
36
+ plugins: { '@rdlabo/rules': rdlabo },
37
+ rules: {
38
+ '@rdlabo/rules/prefer-disable-handler': 'error',
39
+ '@rdlabo/rules/require-ion-error-text': 'error',
40
+ },
41
+ },
42
+ );
43
+ ```
44
+
45
+ These rules are also included in `rdlabo.configs.recommended`.
46
+
47
+ ## Keep modal creation in a launcher
48
+
49
+ `deny-overlay-create` reports `.create()` calls on `ModalController` and `PopoverController`. `prefer-modal-launcher` checks that `presentModal` calls live in `launch*` functions.
50
+
51
+ With `overlay` and `DetailPage` from your [overlay setup](./storage-overlays.md), this is reported:
52
+
53
+ ```ts
54
+ export const openDetail = () => overlay.presentModal(DetailPage);
55
+ ```
56
+
57
+ Use a launcher:
58
+
59
+ ```ts
60
+ export const launchDetail = () => overlay.presentModal(DetailPage);
61
+ ```
62
+
63
+ ## Keep async actions wrapped
64
+
65
+ `prefer-disable-handler` reports an unwrapped action:
66
+
67
+ ```html
68
+ <ion-button type="button" (click)="vm.refresh()">Refresh</ion-button>
69
+ ```
70
+
71
+ Expose the Kit's `disableHandler` helper on your component or ViewModel, then pass the event and async work:
72
+
73
+ ```ts
74
+ import { disableHandler } from '@rdlabo/ionic-angular-kit';
75
+
76
+ // Inside the component or ViewModel:
77
+ readonly disableHandler = disableHandler;
78
+ ```
79
+
80
+ ```html
81
+ <ion-button type="button" (click)="vm.disableHandler($event, vm.refresh())">Refresh</ion-button>
82
+ ```
83
+
84
+ The rule checks the wrapper call, not the async work's behavior. Keep submit actions on the form's `(submit)` with `ion-button type="submit"`.
85
+
86
+ ## Match the Signal Forms adapter
87
+
88
+ By default, `require-ion-error-text` requires an error text source on Ionic controls with `[formField]`.
89
+
90
+ For Angular 22 apps using [Kit Signal Forms](./forms.md), import `FormField` and `KitIonicFormField` in each relevant component and install `provideKitIonicSignalForms()`. Then override this entry in the HTML config's `rules`:
91
+
92
+ ```js
93
+ '@rdlabo/rules/require-ion-error-text': [
94
+ 'error',
95
+ { formFieldProvidesErrorText: true },
96
+ ],
97
+ ```
98
+
99
+ This option declares that the adapter supplies error text; ESLint does not verify the adapter's imports or providers.
100
+
101
+ ## Add ViewModel policy when you use it
102
+
103
+ If your app uses a `ViewModelStore` architecture, add [require-viewmodel](https://docs.rdlabo.dev/projects/eslint-plugin-rules/docs/rules/require-viewmodel) and [no-component-writable-signal](https://docs.rdlabo.dev/projects/eslint-plugin-rules/docs/rules/no-component-writable-signal). Configure them around your app's ViewModel base; `ViewModelStore` is not a Kit export.
104
+
105
+ ## Run it in CI
106
+
107
+ After installing dependencies, run locally and in CI:
108
+
109
+ ```sh
110
+ npx eslint 'src/**/*.{ts,html}' --max-warnings 0
111
+ ```
112
+
113
+ Adjust the source path for your app. See [ESLint configuration](https://docs.rdlabo.dev/projects/eslint-plugin-rules/docs/configuration) for the complete recommended policy and [rule options](https://docs.rdlabo.dev/projects/eslint-plugin-rules/docs/rules) for other conventions.
package/docs/forms.md CHANGED
@@ -2,27 +2,38 @@
2
2
 
3
3
  This entry point targets Angular 22 Signal Forms.
4
4
 
5
- Import Angular's `FormField` together with the kit adapter in each standalone component that binds Signal Forms to Ionic controls.
5
+ Register the adapter once at bootstrap, then bind Signal Forms to Ionic controls with Angular's `FormField` and `KitIonicFormField`:
6
6
 
7
7
  ```ts
8
- import { FormField } from '@angular/forms/signals';
9
- import { KitIonicFormField } from '@rdlabo/ionic-angular-kit/forms';
8
+ import { Component, signal } from '@angular/core';
9
+ import type { ApplicationConfig } from '@angular/core';
10
+ import { FormField, form, required, email, maxLength } from '@angular/forms/signals';
11
+ import { IonInput } from '@ionic/angular';
12
+ import { KitIonicFormField, provideKitIonicSignalForms } from '@rdlabo/ionic-angular-kit/forms';
13
+
14
+ export const appConfig: ApplicationConfig = {
15
+ providers: [provideKitIonicSignalForms()],
16
+ };
10
17
 
11
18
  @Component({
12
- imports: [FormField, KitIonicFormField],
19
+ selector: 'app-profile',
20
+ imports: [FormField, KitIonicFormField, IonInput],
21
+ template: `
22
+ <ion-input label="Name" [formField]="profileForm.name"></ion-input>
23
+ <ion-input label="Email" type="email" [formField]="profileForm.email"></ion-input>
24
+ `,
13
25
  })
14
- export class ProfilePage {}
26
+ export class ProfilePage {
27
+ readonly profile = signal({ name: '', email: '' });
28
+ readonly profileForm = form(this.profile, (path) => {
29
+ required(path.name);
30
+ email(path.email);
31
+ maxLength(path.name, 200);
32
+ });
33
+ }
15
34
  ```
16
35
 
17
- The adapter copies the first non-empty explicit validation message to Ionic's `errorText` property for `ion-input`, `ion-textarea`, `ion-select`, `ion-checkbox`, `ion-radio-group`, and `ion-toggle`. When Angular's validator does not provide a message, the adapter derives a generic English message from the validation error `kind` and its constraint metadata. Built-in validators therefore need no message configuration:
18
-
19
- ```ts
20
- readonly profileForm = form(this.profile, (path) => {
21
- required(path.name);
22
- email(path.email);
23
- maxLength(path.name, 200);
24
- });
25
- ```
36
+ Leave a required field empty and blur it — Ionic shows `errorText`, and the control becomes invalid and touched. The adapter copies the first non-empty explicit validation message to `errorText` for `ion-input`, `ion-textarea`, `ion-select`, `ion-checkbox`, `ion-radio-group`, and `ion-toggle`. When Angular's validator does not provide a message, the adapter derives a generic English message from the validation error `kind` and its constraint metadata. Built-in validators therefore need no message configuration.
26
37
 
27
38
  Unknown custom error kinds fall back to `Enter a valid value.`. Keep business-rule failures outside field validation. An explicit validation message still takes precedence for compatibility, and an explicit `errorText` or `[errorText]` binding prevents the adapter from being instantiated.
28
39
 
@@ -34,6 +45,7 @@ import { KIT_SIGNAL_FORM_ERROR_MESSAGE_RESOLVER } from '@rdlabo/ionic-angular-ki
34
45
 
35
46
  export const appConfig: ApplicationConfig = {
36
47
  providers: [
48
+ provideKitIonicSignalForms(),
37
49
  {
38
50
  provide: KIT_SIGNAL_FORM_ERROR_MESSAGE_RESOLVER,
39
51
  useValue: (error: ValidationError) => localizedMessageFor(error),
@@ -42,25 +54,6 @@ export const appConfig: ApplicationConfig = {
42
54
  };
43
55
  ```
44
56
 
45
- Install the state-class configuration once at application bootstrap:
46
-
47
- ```ts
48
- import { provideKitIonicSignalForms } from '@rdlabo/ionic-angular-kit/forms';
49
-
50
- export const appConfig: ApplicationConfig = {
51
- providers: [provideKitIonicSignalForms()],
52
- };
53
- ```
54
-
55
57
  Angular does not merge multiple `provideSignalFormsConfig` class configurations. If the application provides its own configuration, combine all required class mappings in one provider instead of registering both providers and relying on their order.
56
58
 
57
- When using `@rdlabo/eslint-plugin-rules`, enable its adapter-aware mode only after every relevant standalone component has imported the adapter:
58
-
59
- ```js
60
- {
61
- files: ['**/*.html'],
62
- rules: {
63
- '@rdlabo/rules/require-ion-error-text': ['error', { formFieldProvidesErrorText: true }],
64
- },
65
- }
66
- ```
59
+ For the matching lint configuration, see [Check your Kit integration with ESLint](./eslint.md).
@@ -157,8 +157,9 @@ import type { CanActivateFn, Routes } from '@angular/router';
157
157
  import { OfflineRouteInitializerService, provideRouteScopedOffline } from '@rdlabo/ionic-angular-kit/offline';
158
158
 
159
159
  const offlineReadyGuard: CanActivateFn = async () => {
160
+ const offlineRouteInitializer = inject(OfflineRouteInitializerService);
160
161
  await recoverProductOwnedLocalReset();
161
- await inject(OfflineRouteInitializerService).initialize();
162
+ await offlineRouteInitializer.initialize();
162
163
  return true;
163
164
  };
164
165
 
@@ -0,0 +1,125 @@
1
+ import { GoogleSignIn, ErrorCode } from '@capawesome/capacitor-google-sign-in';
2
+ import { Capacitor } from '@capacitor/core';
3
+ import { GoogleAuthProvider, reauthenticateWithPopup, linkWithCredential, EmailAuthProvider, signInWithPopup, linkWithPopup, signInWithCredential, reauthenticateWithCredential } from 'firebase/auth';
4
+
5
+ let initialization;
6
+ const initialize = (clientId) => {
7
+ if (!clientId) {
8
+ return Promise.reject(new Error('kit Google login: client ID is not configured'));
9
+ }
10
+ if (initialization?.clientId === clientId)
11
+ return initialization.promise;
12
+ const promise = GoogleSignIn.initialize({ clientId }).catch((error) => {
13
+ if (initialization?.promise === promise)
14
+ initialization = undefined;
15
+ throw error;
16
+ });
17
+ initialization = { clientId, promise };
18
+ return promise;
19
+ };
20
+ const requireUser = (auth) => {
21
+ if (!auth.currentUser)
22
+ throw new Error('kit Google login: no signed-in Firebase user');
23
+ return auth.currentUser;
24
+ };
25
+ const assertCurrentUser = (auth, user) => {
26
+ if (auth.currentUser !== user) {
27
+ throw new Error('kit Google login: Firebase user changed');
28
+ }
29
+ };
30
+ const classify = (error) => {
31
+ const code = error?.code;
32
+ if (code === 'auth/credential-already-in-use')
33
+ return 'already-in-use';
34
+ if (code === ErrorCode.SignInCanceled ||
35
+ code === 'auth/user-cancelled' ||
36
+ code === 'auth/popup-closed-by-user' ||
37
+ code === 'auth/cancelled-popup-request')
38
+ return 'cancelled';
39
+ return 'other';
40
+ };
41
+ const kitGoogleLogin = async (auth, options) => {
42
+ const execute = async () => {
43
+ await options.before?.();
44
+ const expectedUser = auth.currentUser;
45
+ let idToken;
46
+ let user;
47
+ if (Capacitor.getPlatform() === 'web') {
48
+ const provider = new GoogleAuthProvider();
49
+ if (options.mode === 'reauthenticate') {
50
+ user = requireUser(auth);
51
+ const result = await reauthenticateWithPopup(user, provider);
52
+ idToken = GoogleAuthProvider.credentialFromResult(result)?.idToken ?? '';
53
+ assertCurrentUser(auth, user);
54
+ await options.success?.({ idToken, mode: options.mode, user });
55
+ assertCurrentUser(auth, user);
56
+ return;
57
+ }
58
+ if (options.mode === 'credential') {
59
+ user = requireUser(auth);
60
+ await reauthenticateWithPopup(user, provider);
61
+ assertCurrentUser(auth, user);
62
+ await linkWithCredential(user, EmailAuthProvider.credential(options.emailLogin.email, options.emailLogin.password));
63
+ assertCurrentUser(auth, user);
64
+ await options.success?.({ idToken: '', mode: options.mode, user });
65
+ assertCurrentUser(auth, user);
66
+ return;
67
+ }
68
+ const result = options.mode === 'new' ? await signInWithPopup(auth, provider) : await linkWithPopup(requireUser(auth), provider);
69
+ const credential = GoogleAuthProvider.credentialFromResult(result);
70
+ if (!credential?.idToken)
71
+ throw new Error('kit Google login: ID token is missing');
72
+ idToken = credential.idToken;
73
+ user = result.user;
74
+ }
75
+ else {
76
+ await initialize(options.clientId);
77
+ idToken = (await GoogleSignIn.signIn()).idToken;
78
+ const credential = GoogleAuthProvider.credential(idToken);
79
+ if (options.mode === 'new')
80
+ user = (await signInWithCredential(auth, credential)).user;
81
+ else {
82
+ user = requireUser(auth);
83
+ if (user !== expectedUser)
84
+ throw new Error('kit Google login: Firebase user changed');
85
+ if (options.mode === 'link')
86
+ await linkWithCredential(user, credential);
87
+ else if (options.mode === 'reauthenticate') {
88
+ await reauthenticateWithCredential(user, credential);
89
+ assertCurrentUser(auth, user);
90
+ await options.success?.({ idToken, mode: options.mode, user });
91
+ assertCurrentUser(auth, user);
92
+ return;
93
+ }
94
+ else {
95
+ await reauthenticateWithCredential(user, credential);
96
+ assertCurrentUser(auth, user);
97
+ await linkWithCredential(user, EmailAuthProvider.credential(options.emailLogin.email, options.emailLogin.password));
98
+ assertCurrentUser(auth, user);
99
+ await options.success?.({ idToken, mode: options.mode, user });
100
+ assertCurrentUser(auth, user);
101
+ return;
102
+ }
103
+ }
104
+ }
105
+ assertCurrentUser(auth, user);
106
+ await options.exchange?.(idToken, user);
107
+ assertCurrentUser(auth, user);
108
+ await options.success?.({ idToken, mode: options.mode, user });
109
+ assertCurrentUser(auth, user);
110
+ };
111
+ return execute()
112
+ .then(() => ({ status: true }), async (error) => {
113
+ await options.error?.(classify(error), error);
114
+ return { status: false };
115
+ })
116
+ .finally(() => options.finally?.());
117
+ };
118
+ const kitGoogleLogout = () => GoogleSignIn.signOut().catch(() => undefined);
119
+
120
+ /**
121
+ * Generated bundle index. Do not edit.
122
+ */
123
+
124
+ export { kitGoogleLogin, kitGoogleLogout };
125
+ //# sourceMappingURL=rdlabo-ionic-angular-kit-auth-firebase-google.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rdlabo-ionic-angular-kit-auth-firebase-google.mjs","sources":["../../../projects/kit/auth-firebase/google/src/kit-google.ts","../../../projects/kit/auth-firebase/google/src/rdlabo-ionic-angular-kit-auth-firebase-google.ts"],"sourcesContent":["import { ErrorCode, GoogleSignIn } from '@capawesome/capacitor-google-sign-in';\nimport { Capacitor } from '@capacitor/core';\nimport type { Auth, User } from 'firebase/auth';\nimport {\n EmailAuthProvider,\n GoogleAuthProvider,\n linkWithCredential,\n linkWithPopup,\n reauthenticateWithCredential,\n reauthenticateWithPopup,\n signInWithCredential,\n signInWithPopup,\n} from 'firebase/auth';\n\nexport type KitGoogleLoginMode =\n | { mode: 'new' }\n | { mode: 'link' }\n | { mode: 'reauthenticate' }\n | { mode: 'credential'; emailLogin: { email: string; password: string } };\nexport type KitGoogleErrorCategory = 'already-in-use' | 'cancelled' | 'other';\nexport type KitGoogleLoginOptions = KitGoogleLoginMode & {\n clientId: string;\n before?: () => void | Promise<unknown>;\n exchange?: (idToken: string, user: User) => void | Promise<unknown>;\n success?: (info: { idToken: string; mode: KitGoogleLoginMode['mode']; user: User }) => void | Promise<unknown>;\n error?: (category: KitGoogleErrorCategory, error: unknown) => void | Promise<unknown>;\n finally?: () => void | Promise<unknown>;\n};\n\nlet initialization: { clientId: string; promise: Promise<void> } | undefined;\nconst initialize = (clientId: string): Promise<void> => {\n if (!clientId) {\n return Promise.reject(new Error('kit Google login: client ID is not configured'));\n }\n if (initialization?.clientId === clientId) return initialization.promise;\n const promise = GoogleSignIn.initialize({ clientId }).catch((error: unknown) => {\n if (initialization?.promise === promise) initialization = undefined;\n throw error;\n });\n initialization = { clientId, promise };\n return promise;\n};\n\nconst requireUser = (auth: Auth): User => {\n if (!auth.currentUser) throw new Error('kit Google login: no signed-in Firebase user');\n return auth.currentUser;\n};\n\nconst assertCurrentUser = (auth: Auth, user: User): void => {\n if (auth.currentUser !== user) {\n throw new Error('kit Google login: Firebase user changed');\n }\n};\n\nconst classify = (error: unknown): KitGoogleErrorCategory => {\n const code = (error as { code?: string } | null)?.code;\n if (code === 'auth/credential-already-in-use') return 'already-in-use';\n if (\n code === ErrorCode.SignInCanceled ||\n code === 'auth/user-cancelled' ||\n code === 'auth/popup-closed-by-user' ||\n code === 'auth/cancelled-popup-request'\n )\n return 'cancelled';\n return 'other';\n};\n\nexport const kitGoogleLogin = async (auth: Auth, options: KitGoogleLoginOptions): Promise<{ status: boolean }> => {\n const execute = async (): Promise<void> => {\n await options.before?.();\n const expectedUser = auth.currentUser;\n let idToken: string;\n let user: User;\n if (Capacitor.getPlatform() === 'web') {\n const provider = new GoogleAuthProvider();\n if (options.mode === 'reauthenticate') {\n user = requireUser(auth);\n const result = await reauthenticateWithPopup(user, provider);\n idToken = GoogleAuthProvider.credentialFromResult(result)?.idToken ?? '';\n assertCurrentUser(auth, user);\n await options.success?.({ idToken, mode: options.mode, user });\n assertCurrentUser(auth, user);\n return;\n }\n if (options.mode === 'credential') {\n user = requireUser(auth);\n await reauthenticateWithPopup(user, provider);\n assertCurrentUser(auth, user);\n await linkWithCredential(user, EmailAuthProvider.credential(options.emailLogin.email, options.emailLogin.password));\n assertCurrentUser(auth, user);\n await options.success?.({ idToken: '', mode: options.mode, user });\n assertCurrentUser(auth, user);\n return;\n }\n const result = options.mode === 'new' ? await signInWithPopup(auth, provider) : await linkWithPopup(requireUser(auth), provider);\n const credential = GoogleAuthProvider.credentialFromResult(result);\n if (!credential?.idToken) throw new Error('kit Google login: ID token is missing');\n idToken = credential.idToken;\n user = result.user;\n } else {\n await initialize(options.clientId);\n idToken = (await GoogleSignIn.signIn()).idToken;\n const credential = GoogleAuthProvider.credential(idToken);\n if (options.mode === 'new') user = (await signInWithCredential(auth, credential)).user;\n else {\n user = requireUser(auth);\n if (user !== expectedUser) throw new Error('kit Google login: Firebase user changed');\n if (options.mode === 'link') await linkWithCredential(user, credential);\n else if (options.mode === 'reauthenticate') {\n await reauthenticateWithCredential(user, credential);\n assertCurrentUser(auth, user);\n await options.success?.({ idToken, mode: options.mode, user });\n assertCurrentUser(auth, user);\n return;\n } else {\n await reauthenticateWithCredential(user, credential);\n assertCurrentUser(auth, user);\n await linkWithCredential(user, EmailAuthProvider.credential(options.emailLogin.email, options.emailLogin.password));\n assertCurrentUser(auth, user);\n await options.success?.({ idToken, mode: options.mode, user });\n assertCurrentUser(auth, user);\n return;\n }\n }\n }\n assertCurrentUser(auth, user);\n await options.exchange?.(idToken, user);\n assertCurrentUser(auth, user);\n await options.success?.({ idToken, mode: options.mode, user });\n assertCurrentUser(auth, user);\n };\n return execute()\n .then(\n () => ({ status: true }),\n async (error: unknown) => {\n await options.error?.(classify(error), error);\n return { status: false };\n },\n )\n .finally(() => options.finally?.());\n};\n\nexport const kitGoogleLogout = (): Promise<void> => GoogleSignIn.signOut().catch(() => undefined);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AA6BA,IAAI,cAAwE;AAC5E,MAAM,UAAU,GAAG,CAAC,QAAgB,KAAmB;IACrD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnF;AACA,IAAA,IAAI,cAAc,EAAE,QAAQ,KAAK,QAAQ;QAAE,OAAO,cAAc,CAAC,OAAO;AACxE,IAAA,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,KAAI;AAC7E,QAAA,IAAI,cAAc,EAAE,OAAO,KAAK,OAAO;YAAE,cAAc,GAAG,SAAS;AACnE,QAAA,MAAM,KAAK;AACb,IAAA,CAAC,CAAC;AACF,IAAA,cAAc,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE;AACtC,IAAA,OAAO,OAAO;AAChB,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,IAAU,KAAU;IACvC,IAAI,CAAC,IAAI,CAAC,WAAW;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;IACtF,OAAO,IAAI,CAAC,WAAW;AACzB,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAU,EAAE,IAAU,KAAU;AACzD,IAAA,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE;AAC7B,QAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;IAC5D;AACF,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,KAAc,KAA4B;AAC1D,IAAA,MAAM,IAAI,GAAI,KAAkC,EAAE,IAAI;IACtD,IAAI,IAAI,KAAK,gCAAgC;AAA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B,QAAA,MAAM,OAAO,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9D,QAAA,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC;AAC/B,IAAA,CAAC;AACD,IAAA,OAAO,OAAO;AACX,SAAA,IAAI,CACH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EACxB,OAAO,KAAc,KAAI;AACvB,QAAA,MAAM,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;AAC7C,QAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;AAC1B,IAAA,CAAC;SAEF,OAAO,CAAC,MAAM,OAAO,CAAC,OAAO,IAAI,CAAC;AACvC;AAEO,MAAM,eAAe,GAAG,MAAqB,YAAY,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,MAAM,SAAS;;AC9IhG;;AAEG;;;;"}
@@ -17,7 +17,7 @@ const classifyOAuthError = (e) => {
17
17
  if (code === 'auth/credential-already-in-use') {
18
18
  return 'already-in-use';
19
19
  }
20
- if (code === 'auth/user-cancelled') {
20
+ if (code === 'auth/user-cancelled' || code === 'auth/popup-closed-by-user' || code === 'auth/cancelled-popup-request') {
21
21
  return 'cancelled';
22
22
  }
23
23
  return 'other';
@@ -1 +1 @@
1
- {"version":3,"file":"rdlabo-ionic-angular-kit-auth-firebase-social.mjs","sources":["../../../projects/kit/auth-firebase/social/src/kit-social.ts","../../../projects/kit/auth-firebase/social/src/public-api.ts","../../../projects/kit/auth-firebase/social/src/rdlabo-ionic-angular-kit-auth-firebase-social.ts"],"sourcesContent":["import type { Auth, AuthCredential } from 'firebase/auth';\nimport {\n EmailAuthProvider,\n FacebookAuthProvider,\n linkWithCredential,\n linkWithPopup,\n OAuthProvider,\n reauthenticateWithCredential,\n reauthenticateWithPopup,\n signInWithCredential,\n signInWithPopup,\n} from 'firebase/auth';\nimport { Capacitor } from '@capacitor/core';\nimport { FacebookLogin } from '@capacitor-community/facebook-login';\nimport { SignInWithApple } from '@capacitor-community/apple-sign-in';\n\n/** How a social-credential failure is classified for the app's error hook. */\nexport type KitOAuthErrorCategory = 'already-in-use' | 'cancelled' | 'other';\n\n/** The mode a social login runs in. */\nexport type KitOAuthModeName = 'new' | 'link' | 'credential';\n\n/**\n * The mode discriminator. `'credential'` links an email/password to the (re-authenticated) social\n * account, so it requires the new email/password; `'new'` / `'link'` do not.\n */\nexport type KitOAuthMode = { mode: 'new' } | { mode: 'link' } | { mode: 'credential'; emailLogin: { email: string; password: string } };\n\n/**\n * The apple identity payload handed to the `success` hook for the backend call. Populated from the\n * native plugin on device, or synthesized from the popup result on the web.\n */\nexport interface KitAppleResponse {\n user: string | null;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n identityToken: string | null;\n authorizationCode: string | null;\n}\n\n/**\n * The uniform lifecycle hooks for a social flow — the same `before / success / error / finally`\n * shape as {@link KitFirebaseAuthService}'s hooks, so a call site reads the same everywhere. All are\n * optional; the kit renders nothing itself.\n *\n * @typeParam Info - the identity payload handed to {@link success} (Facebook access token / Apple\n * response), so an app can notify its backend and give feedback in one place.\n *\n * @remarks\n * `before` runs before the plugin login starts, `success` after the mode's Firebase op succeeds\n * (carrying the identity payload — do the backend call and the toast here), `error` on a classified\n * failure (`'cancelled'` is passed through so the app can stay silent on a user cancel), and\n * `finally` always. The kit swallows none of these errors.\n */\ninterface KitSocialHooks<Info> {\n before?: () => void | Promise<unknown>;\n success?: (info: Info) => void | Promise<unknown>;\n error?: (category: KitOAuthErrorCategory, error: unknown) => void | Promise<unknown>;\n finally?: () => void | Promise<unknown>;\n}\n\n/** Options for {@link kitFacebookLogin}. */\nexport type KitFacebookLoginOptions = KitOAuthMode &\n KitSocialHooks<{ accessToken: string; mode: KitOAuthModeName }> & {\n /** Facebook permissions to request. */\n permissions: string[];\n };\n\n/** Options for {@link kitAppleLogin}. */\nexport type KitAppleLoginOptions = KitOAuthMode & KitSocialHooks<{ response: KitAppleResponse; mode: KitOAuthModeName }>;\n\n/** Generate a random nonce for the Facebook OIDC (Limited Login) flow. */\nconst generateNonce = (length = 16): string => {\n const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let nonce = '';\n for (let i = 0; i < length; i++) {\n nonce += charset[Math.floor(Math.random() * charset.length)];\n }\n return nonce;\n};\n\nconst classifyOAuthError = (e: unknown): KitOAuthErrorCategory => {\n const code = (e as { code?: string } | undefined)?.code;\n if (code === 'auth/credential-already-in-use') {\n return 'already-in-use';\n }\n if (code === 'auth/user-cancelled') {\n return 'cancelled';\n }\n return 'other';\n};\n\ntype Settled<T> = { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown };\n\n/** Convert a possibly synchronously-throwing Promise producer into an explicit result. */\nconst settle = <T>(operation: () => Promise<T>): Promise<Settled<T>> => {\n const execute = async (): Promise<T> => operation();\n return execute().then(\n (value) => ({ status: 'fulfilled', value }),\n (reason: unknown) => ({ status: 'rejected', reason }),\n );\n};\n\n/**\n * The shared 3-mode credential state machine (internal).\n *\n * @remarks\n * `new` signs in with the credential, `link` links it, `credential` re-authenticates with the social\n * credential and then links an email/password. Any Firebase error is classified and handed to\n * `error` (returning `false`); on success the app's `success` hook (backend + feedback) runs with the\n * identity payload, and it returns `true`.\n */\nconst applyOAuthCredential = async (\n auth: Auth,\n credential: AuthCredential,\n mode: KitOAuthMode,\n effects: {\n success: () => void | Promise<unknown>;\n error: (category: KitOAuthErrorCategory, error: unknown) => void | Promise<unknown>;\n },\n): Promise<boolean> => {\n const result = await settle(async () => {\n if (mode.mode === 'new') {\n await signInWithCredential(auth, credential);\n } else {\n const user = auth.currentUser;\n if (!user) {\n throw new Error('kit social: no signed-in user to link/re-authenticate');\n }\n if (mode.mode === 'link') {\n await linkWithCredential(user, credential);\n } else {\n await reauthenticateWithCredential(user, credential);\n await linkWithCredential(user, EmailAuthProvider.credential(mode.emailLogin.email, mode.emailLogin.password));\n }\n }\n });\n if (result.status === 'rejected') {\n await effects.error(classifyOAuthError(result.reason), result.reason);\n return false;\n }\n await effects.success();\n return true;\n};\n\n/** Await one animation frame where available (iOS WebView crash workaround; no-op off-browser). */\nconst nextFrame = (): Promise<void> =>\n new Promise<void>((resolve) => {\n if (typeof requestAnimationFrame === 'function') {\n requestAnimationFrame(() => resolve());\n } else {\n resolve();\n }\n });\n\n/** Web plugin cancellation shape: the login promise rejects with a response whose token is null. */\nconst isFacebookCancellation = (error: unknown): boolean => {\n if (typeof error !== 'object' || error === null || !('accessToken' in error)) {\n return false;\n }\n const { accessToken } = error;\n if (typeof accessToken !== 'object' || accessToken === null || !('token' in accessToken)) {\n return false;\n }\n return accessToken.token === null;\n};\n\n/**\n * Facebook login / link, bundled: native plugin → credential → the shared 3-mode state machine.\n *\n * @remarks\n * On iOS the credential is built from the OIDC token with a nonce (`OAuthProvider('facebook.com')`);\n * elsewhere from the access token (`FacebookAuthProvider`). Returns `{ status: false }` on a\n * cancelled/failed plugin login or a handled Firebase error (the app was already notified via the\n * hooks).\n */\nexport const kitFacebookLogin = async (auth: Auth, options: KitFacebookLoginOptions): Promise<{ status: boolean }> => {\n const execute = async (): Promise<{ status: boolean }> => {\n await options.before?.();\n const nonce = generateNonce();\n const login = await settle(() => FacebookLogin.login({ permissions: options.permissions, nonce }));\n await nextFrame();\n if (login.status === 'rejected') {\n if (!isFacebookCancellation(login.reason)) await options.error?.('other', login.reason);\n return { status: false };\n }\n const event = login.value;\n if (!event?.accessToken?.token) return { status: false };\n const accessToken = event.accessToken.token;\n const credential: AuthCredential =\n Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'ios'\n ? new OAuthProvider('facebook.com').credential({ rawNonce: nonce, idToken: accessToken })!\n : FacebookAuthProvider.credential(accessToken);\n\n const status = await applyOAuthCredential(auth, credential, options, {\n success: () => options.success?.({ accessToken, mode: options.mode }),\n error: (category, error) => options.error?.(category, error),\n });\n return { status };\n };\n return execute().finally(() => options.finally?.());\n};\n\n/**\n * Log out of the Facebook SDK (best-effort; errors are ignored).\n *\n * @remarks\n * Apps that offer Facebook login typically call this alongside the Firebase sign-out, so it lives\n * here to keep the `@capacitor-community/facebook-login` import out of the app.\n * Skips the call when the Facebook SDK has no active session — otherwise `FB.logout()` logs\n * \"called without an access token\" on web and native rejects for email/password users.\n */\nexport const kitFacebookLogout = async (): Promise<void> => {\n const session = await FacebookLogin.getCurrentAccessToken().catch(() => null);\n if (!session?.accessToken?.token) {\n return;\n }\n await FacebookLogin.logout().catch(() => undefined);\n};\n\n/**\n * Sign in with Apple / link, bundled. Native uses the plugin; the web uses the Firebase popup.\n *\n * @remarks\n * - **Native**: `SignInWithApple.authorize()` → `OAuthProvider('apple.com')` credential → the shared\n * 3-mode state machine.\n * - **Web**: `signInWithPopup` / `linkWithPopup` (with `email`/`name` scopes), or, for `credential`,\n * `reauthenticateWithPopup` then link the email/password. The identity payload for the backend is\n * synthesized from the popup result.\n *\n * Every failure path (including popup errors) is routed through `onError`.\n */\nexport const kitAppleLogin = async (auth: Auth, options: KitAppleLoginOptions): Promise<{ status: boolean }> => {\n const execute = async (): Promise<{ status: boolean }> => {\n await options.before?.();\n if (Capacitor.isNativePlatform()) {\n const authorize = await SignInWithApple.authorize().catch(() => undefined);\n if (!authorize) return { status: false };\n const r = authorize.response;\n const response: KitAppleResponse = {\n user: r.user ?? null,\n email: r.email ?? null,\n givenName: r.givenName ?? null,\n familyName: r.familyName ?? null,\n identityToken: r.identityToken ?? null,\n authorizationCode: r.authorizationCode ?? null,\n };\n const credential = new OAuthProvider('apple.com').credential({ idToken: response.identityToken ?? undefined })!;\n const status = await applyOAuthCredential(auth, credential, options, {\n success: () => options.success?.({ response, mode: options.mode }),\n error: (category, error) => options.error?.(category, error),\n });\n return { status };\n }\n\n // Web: the popup performs the sign-in/link itself.\n const provider = new OAuthProvider('apple.com');\n provider.addScope('email');\n provider.addScope('name');\n\n if (options.mode === 'credential') {\n const operation = await settle(async () => {\n const user = requireUser(auth);\n await reauthenticateWithPopup(user, provider);\n await linkWithCredential(user, EmailAuthProvider.credential(options.emailLogin.email, options.emailLogin.password));\n });\n if (operation.status === 'rejected') {\n await options.error?.(classifyOAuthError(operation.reason), operation.reason);\n return { status: false };\n }\n await options.success?.({ response: emptyAppleResponse(), mode: 'credential' });\n return { status: true };\n }\n\n const popup = await settle(() =>\n options.mode === 'new' ? signInWithPopup(auth, provider) : linkWithPopup(requireUser(auth), provider),\n );\n if (popup.status === 'rejected') {\n await options.error?.(classifyOAuthError(popup.reason), popup.reason);\n return { status: false };\n }\n const result = popup.value;\n const credential = OAuthProvider.credentialFromResult(result);\n const response: KitAppleResponse = {\n ...emptyAppleResponse(),\n email: result.user?.email ?? null,\n identityToken: credential?.idToken ?? null,\n authorizationCode: credential?.accessToken ?? null,\n };\n await options.success?.({ response, mode: options.mode });\n return { status: true };\n };\n return execute().finally(() => options.finally?.());\n};\n\nconst emptyAppleResponse = (): KitAppleResponse => ({\n user: null,\n email: null,\n givenName: null,\n familyName: null,\n identityToken: null,\n authorizationCode: null,\n});\n\nconst requireUser = (auth: Auth) => {\n const user = auth.currentUser;\n if (!user) {\n throw new Error('kit social: no signed-in user to link');\n }\n return user;\n};\n","// Social login (Facebook / Apple). Its own entry point so only apps that use it pull in the native\n// plugins `@capacitor-community/facebook-login` and `@capacitor-community/apple-sign-in`; the core\n// `auth-firebase` entry stays free of them.\n//\n// Public surface is curated: two bundled flows plus their option types. The nonce util, the error\n// classifier and the 3-mode credential state machine are internal implementation details.\nexport * from './kit-social';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAwEA;AACA,MAAM,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,KAAY;IAC5C,MAAM,OAAO,GAAG,gEAAgE;IAChF,IAAI,KAAK,GAAG,EAAE;AACd,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,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AE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AACzD,QAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACzB,IAAA,CAAC;AACD,IAAA,OAAO,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,OAAO,IAAI,CAAC;AACrD;AAEA,MAAM,kBAAkB,GAAG,OAAyB;AAClD,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,iBAAiB,EAAE,IAAI;AACxB,CAAA,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAU,KAAI;AACjC,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW;IAC7B,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC;IAC1D;AACA,IAAA,OAAO,IAAI;AACb,CAAC;;ACvTD;AACA;AACA;AACA;AACA;AACA;;ACLA;;AAEG;;;;"}
1
+ {"version":3,"file":"rdlabo-ionic-angular-kit-auth-firebase-social.mjs","sources":["../../../projects/kit/auth-firebase/social/src/kit-social.ts","../../../projects/kit/auth-firebase/social/src/public-api.ts","../../../projects/kit/auth-firebase/social/src/rdlabo-ionic-angular-kit-auth-firebase-social.ts"],"sourcesContent":["import type { Auth, AuthCredential } from 'firebase/auth';\nimport {\n EmailAuthProvider,\n FacebookAuthProvider,\n linkWithCredential,\n linkWithPopup,\n OAuthProvider,\n reauthenticateWithCredential,\n reauthenticateWithPopup,\n signInWithCredential,\n signInWithPopup,\n} from 'firebase/auth';\nimport { Capacitor } from '@capacitor/core';\nimport { FacebookLogin } from '@capacitor-community/facebook-login';\nimport { SignInWithApple } from '@capacitor-community/apple-sign-in';\n\n/** How a social-credential failure is classified for the app's error hook. */\nexport type KitOAuthErrorCategory = 'already-in-use' | 'cancelled' | 'other';\n\n/** The mode a social login runs in. */\nexport type KitOAuthModeName = 'new' | 'link' | 'credential';\n\n/**\n * The mode discriminator. `'credential'` links an email/password to the (re-authenticated) social\n * account, so it requires the new email/password; `'new'` / `'link'` do not.\n */\nexport type KitOAuthMode = { mode: 'new' } | { mode: 'link' } | { mode: 'credential'; emailLogin: { email: string; password: string } };\n\n/**\n * The apple identity payload handed to the `success` hook for the backend call. Populated from the\n * native plugin on device, or synthesized from the popup result on the web.\n */\nexport interface KitAppleResponse {\n user: string | null;\n email: string | null;\n givenName: string | null;\n familyName: string | null;\n identityToken: string | null;\n authorizationCode: string | null;\n}\n\n/**\n * The uniform lifecycle hooks for a social flow — the same `before / success / error / finally`\n * shape as {@link KitFirebaseAuthService}'s hooks, so a call site reads the same everywhere. All are\n * optional; the kit renders nothing itself.\n *\n * @typeParam Info - the identity payload handed to {@link success} (Facebook access token / Apple\n * response), so an app can notify its backend and give feedback in one place.\n *\n * @remarks\n * `before` runs before the plugin login starts, `success` after the mode's Firebase op succeeds\n * (carrying the identity payload — do the backend call and the toast here), `error` on a classified\n * failure (`'cancelled'` is passed through so the app can stay silent on a user cancel), and\n * `finally` always. The kit swallows none of these errors.\n */\ninterface KitSocialHooks<Info> {\n before?: () => void | Promise<unknown>;\n success?: (info: Info) => void | Promise<unknown>;\n error?: (category: KitOAuthErrorCategory, error: unknown) => void | Promise<unknown>;\n finally?: () => void | Promise<unknown>;\n}\n\n/** Options for {@link kitFacebookLogin}. */\nexport type KitFacebookLoginOptions = KitOAuthMode &\n KitSocialHooks<{ accessToken: string; mode: KitOAuthModeName }> & {\n /** Facebook permissions to request. */\n permissions: string[];\n };\n\n/** Options for {@link kitAppleLogin}. */\nexport type KitAppleLoginOptions = KitOAuthMode & KitSocialHooks<{ response: KitAppleResponse; mode: KitOAuthModeName }>;\n\n/** Generate a random nonce for the Facebook OIDC (Limited Login) flow. */\nconst generateNonce = (length = 16): string => {\n const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let nonce = '';\n for (let i = 0; i < length; i++) {\n nonce += charset[Math.floor(Math.random() * charset.length)];\n }\n return nonce;\n};\n\nconst classifyOAuthError = (e: unknown): KitOAuthErrorCategory => {\n const code = (e as { code?: string } | undefined)?.code;\n if (code === 'auth/credential-already-in-use') {\n return 'already-in-use';\n }\n if (code === 'auth/user-cancelled' || code === 'auth/popup-closed-by-user' || code === 'auth/cancelled-popup-request') {\n return 'cancelled';\n }\n return 'other';\n};\n\ntype Settled<T> = { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown };\n\n/** Convert a possibly synchronously-throwing Promise producer into an explicit result. */\nconst settle = <T>(operation: () => Promise<T>): Promise<Settled<T>> => {\n const execute = async (): Promise<T> => operation();\n return execute().then(\n (value) => ({ status: 'fulfilled', value }),\n (reason: unknown) => ({ status: 'rejected', reason }),\n );\n};\n\n/**\n * The shared 3-mode credential state machine (internal).\n *\n * @remarks\n * `new` signs in with the credential, `link` links it, `credential` re-authenticates with the social\n * credential and then links an email/password. Any Firebase error is classified and handed to\n * `error` (returning `false`); on success the app's `success` hook (backend + feedback) runs with the\n * identity payload, and it returns `true`.\n */\nconst applyOAuthCredential = async (\n auth: Auth,\n credential: AuthCredential,\n mode: KitOAuthMode,\n effects: {\n success: () => void | Promise<unknown>;\n error: (category: KitOAuthErrorCategory, error: unknown) => void | Promise<unknown>;\n },\n): Promise<boolean> => {\n const result = await settle(async () => {\n if (mode.mode === 'new') {\n await signInWithCredential(auth, credential);\n } else {\n const user = auth.currentUser;\n if (!user) {\n throw new Error('kit social: no signed-in user to link/re-authenticate');\n }\n if (mode.mode === 'link') {\n await linkWithCredential(user, credential);\n } else {\n await reauthenticateWithCredential(user, credential);\n await linkWithCredential(user, EmailAuthProvider.credential(mode.emailLogin.email, mode.emailLogin.password));\n }\n }\n });\n if (result.status === 'rejected') {\n await effects.error(classifyOAuthError(result.reason), result.reason);\n return false;\n }\n await effects.success();\n return true;\n};\n\n/** Await one animation frame where available (iOS WebView crash workaround; no-op off-browser). */\nconst nextFrame = (): Promise<void> =>\n new Promise<void>((resolve) => {\n if (typeof requestAnimationFrame === 'function') {\n requestAnimationFrame(() => resolve());\n } else {\n resolve();\n }\n });\n\n/** Web plugin cancellation shape: the login promise rejects with a response whose token is null. */\nconst isFacebookCancellation = (error: unknown): boolean => {\n if (typeof error !== 'object' || error === null || !('accessToken' in error)) {\n return false;\n }\n const { accessToken } = error;\n if (typeof accessToken !== 'object' || accessToken === null || !('token' in accessToken)) {\n return false;\n }\n return accessToken.token === null;\n};\n\n/**\n * Facebook login / link, bundled: native plugin → credential → the shared 3-mode state machine.\n *\n * @remarks\n * On iOS the credential is built from the OIDC token with a nonce (`OAuthProvider('facebook.com')`);\n * elsewhere from the access token (`FacebookAuthProvider`). Returns `{ status: false }` on a\n * cancelled/failed plugin login or a handled Firebase error (the app was already notified via the\n * hooks).\n */\nexport const kitFacebookLogin = async (auth: Auth, options: KitFacebookLoginOptions): Promise<{ status: boolean }> => {\n const execute = async (): Promise<{ status: boolean }> => {\n await options.before?.();\n const nonce = generateNonce();\n const login = await settle(() => FacebookLogin.login({ permissions: options.permissions, nonce }));\n await nextFrame();\n if (login.status === 'rejected') {\n if (!isFacebookCancellation(login.reason)) await options.error?.('other', login.reason);\n return { status: false };\n }\n const event = login.value;\n if (!event?.accessToken?.token) return { status: false };\n const accessToken = event.accessToken.token;\n const credential: AuthCredential =\n Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'ios'\n ? new OAuthProvider('facebook.com').credential({ rawNonce: nonce, idToken: accessToken })!\n : FacebookAuthProvider.credential(accessToken);\n\n const status = await applyOAuthCredential(auth, credential, options, {\n success: () => options.success?.({ accessToken, mode: options.mode }),\n error: (category, error) => options.error?.(category, error),\n });\n return { status };\n };\n return execute().finally(() => options.finally?.());\n};\n\n/**\n * Log out of the Facebook SDK (best-effort; errors are ignored).\n *\n * @remarks\n * Apps that offer Facebook login typically call this alongside the Firebase sign-out, so it lives\n * here to keep the `@capacitor-community/facebook-login` import out of the app.\n * Skips the call when the Facebook SDK has no active session — otherwise `FB.logout()` logs\n * \"called without an access token\" on web and native rejects for email/password users.\n */\nexport const kitFacebookLogout = async (): Promise<void> => {\n const session = await FacebookLogin.getCurrentAccessToken().catch(() => null);\n if (!session?.accessToken?.token) {\n return;\n }\n await FacebookLogin.logout().catch(() => undefined);\n};\n\n/**\n * Sign in with Apple / link, bundled. Native uses the plugin; the web uses the Firebase popup.\n *\n * @remarks\n * - **Native**: `SignInWithApple.authorize()` → `OAuthProvider('apple.com')` credential → the shared\n * 3-mode state machine.\n * - **Web**: `signInWithPopup` / `linkWithPopup` (with `email`/`name` scopes), or, for `credential`,\n * `reauthenticateWithPopup` then link the email/password. The identity payload for the backend is\n * synthesized from the popup result.\n *\n * Every failure path (including popup errors) is routed through `onError`.\n */\nexport const kitAppleLogin = async (auth: Auth, options: KitAppleLoginOptions): Promise<{ status: boolean }> => {\n const execute = async (): Promise<{ status: boolean }> => {\n await options.before?.();\n if (Capacitor.isNativePlatform()) {\n const authorize = await SignInWithApple.authorize().catch(() => undefined);\n if (!authorize) return { status: false };\n const r = authorize.response;\n const response: KitAppleResponse = {\n user: r.user ?? null,\n email: r.email ?? null,\n givenName: r.givenName ?? null,\n familyName: r.familyName ?? null,\n identityToken: r.identityToken ?? null,\n authorizationCode: r.authorizationCode ?? null,\n };\n const credential = new OAuthProvider('apple.com').credential({ idToken: response.identityToken ?? undefined })!;\n const status = await applyOAuthCredential(auth, credential, options, {\n success: () => options.success?.({ response, mode: options.mode }),\n error: (category, error) => options.error?.(category, error),\n });\n return { status };\n }\n\n // Web: the popup performs the sign-in/link itself.\n const provider = new OAuthProvider('apple.com');\n provider.addScope('email');\n provider.addScope('name');\n\n if (options.mode === 'credential') {\n const operation = await settle(async () => {\n const user = requireUser(auth);\n await reauthenticateWithPopup(user, provider);\n await linkWithCredential(user, EmailAuthProvider.credential(options.emailLogin.email, options.emailLogin.password));\n });\n if (operation.status === 'rejected') {\n await options.error?.(classifyOAuthError(operation.reason), operation.reason);\n return { status: false };\n }\n await options.success?.({ response: emptyAppleResponse(), mode: 'credential' });\n return { status: true };\n }\n\n const popup = await settle(() =>\n options.mode === 'new' ? signInWithPopup(auth, provider) : linkWithPopup(requireUser(auth), provider),\n );\n if (popup.status === 'rejected') {\n await options.error?.(classifyOAuthError(popup.reason), popup.reason);\n return { status: false };\n }\n const result = popup.value;\n const credential = OAuthProvider.credentialFromResult(result);\n const response: KitAppleResponse = {\n ...emptyAppleResponse(),\n email: result.user?.email ?? null,\n identityToken: credential?.idToken ?? null,\n authorizationCode: credential?.accessToken ?? null,\n };\n await options.success?.({ response, mode: options.mode });\n return { status: true };\n };\n return execute().finally(() => options.finally?.());\n};\n\nconst emptyAppleResponse = (): KitAppleResponse => ({\n user: null,\n email: null,\n givenName: null,\n familyName: null,\n identityToken: null,\n authorizationCode: null,\n});\n\nconst requireUser = (auth: Auth) => {\n const user = auth.currentUser;\n if (!user) {\n throw new Error('kit social: no signed-in user to link');\n }\n return user;\n};\n","// Social login (Facebook / Apple). Its own entry point so only apps that use it pull in the native\n// plugins `@capacitor-community/facebook-login` and `@capacitor-community/apple-sign-in`; the core\n// `auth-firebase` entry stays free of them.\n//\n// Public surface is curated: two bundled flows plus their option types. The nonce util, the error\n// classifier and the 3-mode credential state machine are internal implementation details.\nexport * from './kit-social';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAwEA;AACA,MAAM,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,KAAY;IAC5C,MAAM,OAAO,GAAG,gEAAgE;IAChF,IAAI,KAAK,GAAG,EAAE;AACd,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/B,QAAA,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,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E,CAAC;AACzD,QAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACzB,IAAA,CAAC;AACD,IAAA,OAAO,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,OAAO,IAAI,CAAC;AACrD;AAEA,MAAM,kBAAkB,GAAG,OAAyB;AAClD,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,iBAAiB,EAAE,IAAI;AACxB,CAAA,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAU,KAAI;AACjC,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW;IAC7B,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC;IAC1D;AACA,IAAA,OAAO,IAAI;AACb,CAAC;;ACvTD;AACA;AACA;AACA;AACA;AACA;;ACLA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-kit",
3
- "version": "22.0.1-0",
3
+ "version": "22.0.1-beta.pr105.sha55308d6acf67",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rdlabo-dev/ionic-angular-library.git"
@@ -25,6 +25,7 @@
25
25
  "@capacitor-community/in-app-review": ">=7.0.0 <9.0.0",
26
26
  "@capacitor-community/facebook-login": ">=8.0.0 <9.0.0",
27
27
  "@capacitor-community/apple-sign-in": "*",
28
+ "@capawesome/capacitor-google-sign-in": "^0.1.4",
28
29
  "@rdlabo/capacitor-brotherprint": ">=7.0.0 <9.0.0",
29
30
  "dom-to-image-more": "^3.0.0",
30
31
  "pdf-lib": "^1.17.1",
@@ -56,6 +57,9 @@
56
57
  "@capacitor-community/apple-sign-in": {
57
58
  "optional": true
58
59
  },
60
+ "@capawesome/capacitor-google-sign-in": {
61
+ "optional": true
62
+ },
59
63
  "@rdlabo/capacitor-brotherprint": {
60
64
  "optional": true
61
65
  },
@@ -88,6 +92,10 @@
88
92
  "types": "./types/rdlabo-ionic-angular-kit-auth-firebase.d.ts",
89
93
  "default": "./fesm2022/rdlabo-ionic-angular-kit-auth-firebase.mjs"
90
94
  },
95
+ "./auth-firebase/google": {
96
+ "types": "./types/rdlabo-ionic-angular-kit-auth-firebase-google.d.ts",
97
+ "default": "./fesm2022/rdlabo-ionic-angular-kit-auth-firebase-google.mjs"
98
+ },
91
99
  "./auth-firebase/social": {
92
100
  "types": "./types/rdlabo-ionic-angular-kit-auth-firebase-social.d.ts",
93
101
  "default": "./fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs"
@@ -0,0 +1,35 @@
1
+ import { User, Auth } from 'firebase/auth';
2
+
3
+ type KitGoogleLoginMode = {
4
+ mode: 'new';
5
+ } | {
6
+ mode: 'link';
7
+ } | {
8
+ mode: 'reauthenticate';
9
+ } | {
10
+ mode: 'credential';
11
+ emailLogin: {
12
+ email: string;
13
+ password: string;
14
+ };
15
+ };
16
+ type KitGoogleErrorCategory = 'already-in-use' | 'cancelled' | 'other';
17
+ type KitGoogleLoginOptions = KitGoogleLoginMode & {
18
+ clientId: string;
19
+ before?: () => void | Promise<unknown>;
20
+ exchange?: (idToken: string, user: User) => void | Promise<unknown>;
21
+ success?: (info: {
22
+ idToken: string;
23
+ mode: KitGoogleLoginMode['mode'];
24
+ user: User;
25
+ }) => void | Promise<unknown>;
26
+ error?: (category: KitGoogleErrorCategory, error: unknown) => void | Promise<unknown>;
27
+ finally?: () => void | Promise<unknown>;
28
+ };
29
+ declare const kitGoogleLogin: (auth: Auth, options: KitGoogleLoginOptions) => Promise<{
30
+ status: boolean;
31
+ }>;
32
+ declare const kitGoogleLogout: () => Promise<void>;
33
+
34
+ export { kitGoogleLogin, kitGoogleLogout };
35
+ export type { KitGoogleErrorCategory, KitGoogleLoginMode, KitGoogleLoginOptions };