capacitor-auth-manager 2.4.3 → 3.0.0
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/AI-INTEGRATION-GUIDE.md +174 -0
- package/CHANGELOG.md +127 -0
- package/CapacitorAuthManager.podspec +3 -3
- package/README.md +91 -73
- package/android/build.gradle +17 -25
- package/android/consumer-rules.pro +2 -0
- package/android/proguard-rules.pro +5 -30
- package/android/src/main/AndroidManifest.xml +4 -9
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthErrorCodes.java +32 -0
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthException.java +34 -0
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthStorage.java +46 -25
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManager.java +54 -38
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManagerPlugin.java +77 -54
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/GoogleAuthProvider.java +171 -41
- package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/ProviderFactory.java +5 -0
- package/dist/angular.cjs.js +421 -3376
- package/dist/core.cjs.js +589 -149
- package/dist/esm/angular/auth.guard.d.ts +1 -1
- package/dist/esm/angular/auth.module.d.ts +1 -1
- package/dist/esm/angular/auth.module.js +1 -1
- package/dist/esm/angular/auth.service.d.ts +2 -2
- package/dist/esm/angular/auth.service.js +1 -1
- package/dist/esm/angular/index.d.ts +4 -4
- package/dist/esm/angular/index.js +4 -4
- package/dist/esm/capacitor-plugin.d.ts +2 -3
- package/dist/esm/capacitor-plugin.js +14 -4
- package/dist/esm/core/auth-manager.d.ts +20 -2
- package/dist/esm/core/auth-manager.js +68 -12
- package/dist/esm/core/index.d.ts +5 -4
- package/dist/esm/core/index.js +5 -4
- package/dist/esm/core/provider-manifests.d.ts +1 -1
- package/dist/esm/core/provider-manifests.js +12 -13
- package/dist/esm/core/provider-registry.d.ts +8 -5
- package/dist/esm/core/provider-registry.js +41 -10
- package/dist/esm/core/types.d.ts +2 -2
- package/dist/esm/definitions.d.ts +26 -0
- package/dist/esm/index.d.ts +12 -12
- package/dist/esm/index.js +7 -7
- package/dist/esm/package.json +1 -0
- package/dist/esm/providers/base-provider.d.ts +7 -8
- package/dist/esm/providers/base-provider.js +7 -8
- package/dist/esm/providers/native/google-native-provider.d.ts +13 -2
- package/dist/esm/providers/native/google-native-provider.js +50 -6
- package/dist/esm/providers/oauth-provider.d.ts +2 -2
- package/dist/esm/providers/oauth-provider.js +3 -3
- package/dist/esm/providers/provider-factory.d.ts +5 -5
- package/dist/esm/providers/provider-factory.js +2 -2
- package/dist/esm/providers/web/google-provider.d.ts +74 -18
- package/dist/esm/providers/web/google-provider.js +391 -117
- package/dist/esm/providers/web/index.d.ts +1 -1
- package/dist/esm/providers/web/index.js +1 -1
- package/dist/esm/react/hooks.d.ts +2 -2
- package/dist/esm/react/hooks.js +2 -2
- package/dist/esm/react/index.d.ts +3 -3
- package/dist/esm/react/index.js +3 -3
- package/dist/esm/react/types.d.ts +1 -1
- package/dist/esm/utils/auth-error.d.ts +1 -1
- package/dist/esm/utils/auth-error.js +1 -1
- package/dist/esm/utils/event-emitter.d.ts +1 -1
- package/dist/esm/utils/event-emitter.js +1 -1
- package/dist/esm/utils/pending-verification-store.js +1 -1
- package/dist/esm/utils/storage.d.ts +2 -2
- package/dist/esm/utils/storage.js +31 -7
- package/dist/esm/vue/composables.d.ts +2 -2
- package/dist/esm/vue/composables.js +1 -1
- package/dist/esm/vue/index.d.ts +2 -2
- package/dist/esm/vue/index.js +2 -2
- package/dist/esm/web.d.ts +1 -1
- package/dist/esm/web.js +6 -6
- package/dist/plugin.cjs.js +291 -2771
- package/dist/plugin.js +585 -147
- package/dist/providers-web.cjs.js +1317 -0
- package/dist/react.cjs.js +310 -3265
- package/dist/vue.cjs.js +266 -3221
- package/ios/Plugin/AuthStorage.swift +3 -1
- package/ios/Plugin/GoogleAuthProvider.swift +7 -4
- package/ios/Plugin/Models.swift +28 -0
- package/ios/Plugin/Plugin.swift +64 -40
- package/package.json +55 -33
- package/scripts/configure.js +71 -325
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GoogleAuthProviderWeb } from './google-provider';
|
|
1
|
+
export { GoogleAuthProviderWeb } from './google-provider.js';
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
// folder but are excluded from the published build until each is re-enabled and verified. Re-add a
|
|
6
6
|
// provider's export below (and restore its registry loader + remove its tsconfig.build exclude) when
|
|
7
7
|
// its turn comes.
|
|
8
|
-
export { GoogleAuthProviderWeb } from './google-provider';
|
|
8
|
+
export { GoogleAuthProviderWeb } from './google-provider.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AuthUser } from '../definitions';
|
|
2
|
-
import type { UseAuthReturn, UseAuthStateReturn, UseAuthProviderReturn } from './types';
|
|
1
|
+
import type { AuthUser } from '../definitions.js';
|
|
2
|
+
import type { UseAuthReturn, UseAuthStateReturn, UseAuthProviderReturn } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for complete authentication functionality
|
|
5
5
|
* @example
|
package/dist/esm/react/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
2
|
-
import { auth } from '../core/auth-manager';
|
|
2
|
+
import { auth } from '../core/auth-manager.js';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for complete authentication functionality
|
|
5
5
|
* @example
|
|
@@ -204,7 +204,7 @@ export function useAuthState() {
|
|
|
204
204
|
*/
|
|
205
205
|
export function useAuthProvider(provider) {
|
|
206
206
|
const [isSupported, setIsSupported] = useState(false);
|
|
207
|
-
const [isConfigured, setIsConfigured] = useState(
|
|
207
|
+
const [isConfigured, setIsConfigured] = useState(() => auth.isProviderConfigured(provider));
|
|
208
208
|
const [error, setError] = useState(null);
|
|
209
209
|
const mountedRef = useRef(true);
|
|
210
210
|
useEffect(() => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './types';
|
|
3
|
-
export { AuthProvider, AuthErrorCode } from '../definitions';
|
|
1
|
+
export * from './hooks.js';
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export { AuthProvider, AuthErrorCode } from '../definitions.js';
|
package/dist/esm/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './types';
|
|
1
|
+
export * from './hooks.js';
|
|
2
|
+
export * from './types.js';
|
|
3
3
|
// Re-export the AuthProvider enum (+ error codes) so consumers get `useAuth().signIn(AuthProvider.GOOGLE)`
|
|
4
4
|
// with a single import. Using the enum is the recommended, typo-safe way to name a provider — plain
|
|
5
5
|
// strings like 'google' still work.
|
|
6
|
-
export { AuthProvider, AuthErrorCode } from '../definitions';
|
|
6
|
+
export { AuthProvider, AuthErrorCode } from '../definitions.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthUser, AuthResult, SignInOptions, SignOutOptions, LinkAccountOptions, UnlinkAccountOptions, GetIdTokenOptions, UpdateProfileOptions, DeleteAccountOptions } from '../definitions';
|
|
1
|
+
import type { AuthUser, AuthResult, SignInOptions, SignOutOptions, LinkAccountOptions, UnlinkAccountOptions, GetIdTokenOptions, UpdateProfileOptions, DeleteAccountOptions } from '../definitions.js';
|
|
2
2
|
export interface UseAuthReturn {
|
|
3
3
|
user: AuthUser | null;
|
|
4
4
|
isLoading: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthError as IAuthError, AuthProvider } from '../definitions';
|
|
1
|
+
import { AuthError as IAuthError, AuthProvider } from '../definitions.js';
|
|
2
2
|
export declare class AuthError extends Error implements IAuthError {
|
|
3
3
|
code: string;
|
|
4
4
|
details?: Record<string, unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthPersistence } from '../definitions';
|
|
2
|
-
import { Logger } from './logger';
|
|
1
|
+
import { AuthPersistence } from '../definitions.js';
|
|
2
|
+
import { Logger } from './logger.js';
|
|
3
3
|
export interface StorageInterface {
|
|
4
4
|
/**
|
|
5
5
|
* Read and JSON-deserialize a value. Pass the expected shape as `T` at the call site to get a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthPersistence } from '../definitions';
|
|
2
|
-
import { defaultLogger } from './logger';
|
|
1
|
+
import { AuthPersistence } from '../definitions.js';
|
|
2
|
+
import { defaultLogger } from './logger.js';
|
|
3
3
|
export class WebStorage {
|
|
4
4
|
/**
|
|
5
5
|
* @param persistence Where to persist values (local / session / in-memory).
|
|
@@ -12,17 +12,15 @@ export class WebStorage {
|
|
|
12
12
|
this.logger = logger;
|
|
13
13
|
switch (persistence) {
|
|
14
14
|
case AuthPersistence.SESSION:
|
|
15
|
-
this.storage =
|
|
16
|
-
break;
|
|
17
|
-
case AuthPersistence.LOCAL:
|
|
18
|
-
this.storage = window.localStorage;
|
|
15
|
+
this.storage = resolveBrowserStorage('sessionStorage');
|
|
19
16
|
break;
|
|
20
17
|
case AuthPersistence.NONE:
|
|
21
18
|
// Use in-memory storage
|
|
22
19
|
this.storage = new InMemoryStorage();
|
|
23
20
|
break;
|
|
21
|
+
case AuthPersistence.LOCAL:
|
|
24
22
|
default:
|
|
25
|
-
this.storage =
|
|
23
|
+
this.storage = resolveBrowserStorage('localStorage');
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
async get(key) {
|
|
@@ -130,6 +128,32 @@ export class CapacitorPreferencesStorage {
|
|
|
130
128
|
.map((k) => prefs.remove({ key: k })));
|
|
131
129
|
}
|
|
132
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns the requested browser storage when it exists AND is usable, otherwise an in-memory
|
|
133
|
+
* fallback. Two environments make the fallback necessary:
|
|
134
|
+
* - Node / SSR / test runners: `window` is undefined, so the old unguarded `window.localStorage`
|
|
135
|
+
* read threw `ReferenceError: window is not defined` at import time (ISSUE-002).
|
|
136
|
+
* - Browsers that expose the API but refuse it (Safari private mode, cookies disabled, sandboxed
|
|
137
|
+
* iframes): `getItem`/`setItem` throw, so the probe below catches that and degrades gracefully.
|
|
138
|
+
*/
|
|
139
|
+
function resolveBrowserStorage(kind) {
|
|
140
|
+
if (typeof window === 'undefined') {
|
|
141
|
+
return new InMemoryStorage();
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const candidate = window[kind];
|
|
145
|
+
if (!candidate) {
|
|
146
|
+
return new InMemoryStorage();
|
|
147
|
+
}
|
|
148
|
+
const probeKey = '__cap_auth_probe__';
|
|
149
|
+
candidate.setItem(probeKey, '1');
|
|
150
|
+
candidate.removeItem(probeKey);
|
|
151
|
+
return candidate;
|
|
152
|
+
}
|
|
153
|
+
catch (_a) {
|
|
154
|
+
return new InMemoryStorage();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
133
157
|
class InMemoryStorage {
|
|
134
158
|
constructor() {
|
|
135
159
|
this.data = new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref, ComputedRef } from 'vue';
|
|
2
|
-
import type { AuthManagerConfig } from '../core/types';
|
|
3
|
-
import type { AuthUser, AuthResult, SignInOptions, SignOutOptions, LinkAccountOptions, UnlinkAccountOptions, GetIdTokenOptions, UpdateProfileOptions, DeleteAccountOptions } from '../definitions';
|
|
2
|
+
import type { AuthManagerConfig } from '../core/types.js';
|
|
3
|
+
import type { AuthUser, AuthResult, SignInOptions, SignOutOptions, LinkAccountOptions, UnlinkAccountOptions, GetIdTokenOptions, UpdateProfileOptions, DeleteAccountOptions } from '../definitions.js';
|
|
4
4
|
interface UseAuthReturn {
|
|
5
5
|
user: Readonly<Ref<AuthUser | null>>;
|
|
6
6
|
isLoading: Readonly<Ref<boolean>>;
|
package/dist/esm/vue/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useAuth, useAuthState, useUser, useAuthProvider, useAuthConfig, } from './composables';
|
|
2
|
-
export { AuthProvider, AuthErrorCode } from '../definitions';
|
|
1
|
+
export { useAuth, useAuthState, useUser, useAuthProvider, useAuthConfig, } from './composables.js';
|
|
2
|
+
export { AuthProvider, AuthErrorCode } from '../definitions.js';
|
package/dist/esm/vue/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useAuth, useAuthState, useUser, useAuthProvider, useAuthConfig, } from './composables';
|
|
1
|
+
export { useAuth, useAuthState, useUser, useAuthProvider, useAuthConfig, } from './composables.js';
|
|
2
2
|
// Re-export the AuthProvider enum (+ error codes) so consumers get `useAuth().signIn(AuthProvider.GOOGLE)`
|
|
3
3
|
// with a single import. Using the enum is the recommended, typo-safe way to name a provider — plain
|
|
4
4
|
// strings like 'google' still work.
|
|
5
|
-
export { AuthProvider, AuthErrorCode } from '../definitions';
|
|
5
|
+
export { AuthProvider, AuthErrorCode } from '../definitions.js';
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
2
|
import type { PluginListenerHandle } from '@capacitor/core';
|
|
3
|
-
import type { CapacitorAuthManagerPlugin, AuthManagerInitOptions, SignInOptions, SignOutOptions, AuthResult, AuthUser, RefreshTokenOptions, AuthStateChangeCallback, IsSupportedOptions, IsSupportedResult, ConfigureOptions, LinkAccountOptions, UnlinkAccountOptions, PasswordResetOptions, EmailVerificationOptions, SendSmsCodeOptions, VerifySmsCodeOptions, SendEmailCodeOptions, VerifyEmailCodeOptions, UpdateProfileOptions, DeleteAccountOptions, GetIdTokenOptions, SetCustomParametersOptions, RevokeAccessOptions } from './definitions';
|
|
3
|
+
import type { CapacitorAuthManagerPlugin, AuthManagerInitOptions, SignInOptions, SignOutOptions, AuthResult, AuthUser, RefreshTokenOptions, AuthStateChangeCallback, IsSupportedOptions, IsSupportedResult, ConfigureOptions, LinkAccountOptions, UnlinkAccountOptions, PasswordResetOptions, EmailVerificationOptions, SendSmsCodeOptions, VerifySmsCodeOptions, SendEmailCodeOptions, VerifyEmailCodeOptions, UpdateProfileOptions, DeleteAccountOptions, GetIdTokenOptions, SetCustomParametersOptions, RevokeAccessOptions } from './definitions.js';
|
|
4
4
|
export declare class CapacitorAuthManagerWeb extends WebPlugin implements CapacitorAuthManagerPlugin {
|
|
5
5
|
private providers;
|
|
6
6
|
private storage;
|
package/dist/esm/web.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { AuthErrorCode, AuthPersistence, AuthProvider } from './definitions';
|
|
3
|
-
import { AuthError } from './utils/auth-error';
|
|
4
|
-
import { EventEmitter } from './utils/event-emitter';
|
|
5
|
-
import { WebStorage } from './utils/storage';
|
|
6
|
-
import { Logger } from './utils/logger';
|
|
7
|
-
import { ProviderFactory } from './providers/provider-factory';
|
|
2
|
+
import { AuthErrorCode, AuthPersistence, AuthProvider } from './definitions.js';
|
|
3
|
+
import { AuthError } from './utils/auth-error.js';
|
|
4
|
+
import { EventEmitter } from './utils/event-emitter.js';
|
|
5
|
+
import { WebStorage } from './utils/storage.js';
|
|
6
|
+
import { Logger } from './utils/logger.js';
|
|
7
|
+
import { ProviderFactory } from './providers/provider-factory.js';
|
|
8
8
|
export class CapacitorAuthManagerWeb extends WebPlugin {
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|