@chipmobilesdk/rn-auth 0.3.0 → 0.4.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.
@@ -1,61 +1,72 @@
1
- /**
2
- * Stable, localizable message keys with English default copy (UX-006 / LIB-011).
3
- * The library takes no i18n runtime dependency: consuming apps map these keys to
4
- * localized strings via their own i18n system. User-actionable copy and
5
- * developer/tenant-configuration copy are kept separate (UX-005).
6
- */
7
-
8
- export interface AuthMessageMap {
9
- // User-facing actions and states
10
- 'auth.action.continueGoogle': string;
11
- 'auth.action.continueApple': string;
12
- 'auth.action.continueFacebook': string;
13
- 'auth.state.signedOut': string;
14
- 'auth.state.authenticating': string;
15
- 'auth.state.signedIn': string;
16
- 'auth.state.signingOut': string;
17
- // Access tier (user-facing)
18
- 'auth.tier.free': string;
19
- 'auth.tier.premium': string;
20
- 'auth.tier.unverified': string;
21
- // User-actionable errors
22
- 'auth.error.cancelled': string;
23
- 'auth.error.sessionExpired': string;
24
- 'auth.error.entitlement': string;
25
- 'auth.error.network': string;
26
- // Developer / tenant-configuration errors
27
- 'auth.error.configuration': string;
28
- 'auth.error.redirectMismatch': string;
29
- 'auth.error.token': string;
30
- 'auth.error.consentDenied': string;
31
- }
32
-
33
- export type AuthMessageKey = keyof AuthMessageMap;
34
-
35
- export const DEFAULT_MESSAGES: AuthMessageMap = {
36
- 'auth.action.continueGoogle': 'Continue with Google',
37
- 'auth.action.continueApple': 'Continue with Apple',
38
- 'auth.action.continueFacebook': 'Continue with Facebook',
39
- 'auth.state.signedOut': 'Sign in to continue',
40
- 'auth.state.authenticating': 'Signing you in…',
41
- 'auth.state.signedIn': 'You are signed in',
42
- 'auth.state.signingOut': 'Signing out…',
43
- 'auth.tier.free': 'Free',
44
- 'auth.tier.premium': 'Premium',
45
- 'auth.tier.unverified': 'Membership could not be verified',
46
- 'auth.error.cancelled': 'Sign-in was cancelled. You can try again.',
47
- 'auth.error.sessionExpired': 'Your session expired. Please sign in again.',
48
- 'auth.error.entitlement': 'This feature requires a verified premium membership.',
49
- 'auth.error.network': 'No connection. Some features are limited until you reconnect.',
50
- 'auth.error.configuration': 'Authentication is not configured correctly.',
51
- 'auth.error.redirectMismatch': 'The sign-in redirect does not match the app configuration.',
52
- 'auth.error.token': 'We could not complete the request. Please try again.',
53
- 'auth.error.consentDenied': 'Access to this resource was denied.',
54
- };
55
-
56
- /** Resolve a message, preferring app overrides over the English defaults. */
57
- export function resolveMessages(
58
- overrides?: Partial<AuthMessageMap>,
59
- ): AuthMessageMap {
60
- return { ...DEFAULT_MESSAGES, ...(overrides ?? {}) };
61
- }
1
+ /**
2
+ * Stable, localizable message keys with English default copy (UX-006 / LIB-011).
3
+ * The library takes no i18n runtime dependency: consuming apps map these keys to
4
+ * localized strings via their own i18n system. User-actionable copy and
5
+ * developer/tenant-configuration copy are kept separate (UX-005).
6
+ */
7
+
8
+ import { defineMessages } from '@chipmobilesdk/rn-core';
9
+
10
+ export interface AuthMessageMap {
11
+ // User-facing actions and states
12
+ 'auth.action.continueGoogle': string;
13
+ 'auth.action.continueApple': string;
14
+ 'auth.action.continueFacebook': string;
15
+ 'auth.state.signedOut': string;
16
+ 'auth.state.authenticating': string;
17
+ 'auth.state.signedIn': string;
18
+ 'auth.state.signingOut': string;
19
+ // Access tier (user-facing)
20
+ 'auth.tier.free': string;
21
+ 'auth.tier.premium': string;
22
+ 'auth.tier.unverified': string;
23
+ // User-actionable errors
24
+ 'auth.error.cancelled': string;
25
+ 'auth.error.sessionExpired': string;
26
+ 'auth.error.entitlement': string;
27
+ 'auth.error.network': string;
28
+ // Developer / tenant-configuration errors
29
+ 'auth.error.configuration': string;
30
+ 'auth.error.redirectMismatch': string;
31
+ 'auth.error.token': string;
32
+ 'auth.error.consentDenied': string;
33
+ }
34
+
35
+ export type AuthMessageKey = keyof AuthMessageMap;
36
+
37
+ /**
38
+ * The catalog, as an rn-core message set: `user` copy may reach an end user,
39
+ * `developer` copy describes a tenant or configuration fault (UX-005). Register
40
+ * `authMessages.user` with rn-i18n to translate it like app copy.
41
+ */
42
+ export const authMessages = defineMessages({
43
+ user: {
44
+ 'auth.action.continueGoogle': 'Continue with Google',
45
+ 'auth.action.continueApple': 'Continue with Apple',
46
+ 'auth.action.continueFacebook': 'Continue with Facebook',
47
+ 'auth.state.signedOut': 'Sign in to continue',
48
+ 'auth.state.authenticating': 'Signing you in…',
49
+ 'auth.state.signedIn': 'You are signed in',
50
+ 'auth.state.signingOut': 'Signing out…',
51
+ 'auth.tier.free': 'Free',
52
+ 'auth.tier.premium': 'Premium',
53
+ 'auth.tier.unverified': 'Membership could not be verified',
54
+ 'auth.error.cancelled': 'Sign-in was cancelled. You can try again.',
55
+ 'auth.error.sessionExpired': 'Your session expired. Please sign in again.',
56
+ 'auth.error.entitlement': 'This feature requires a verified premium membership.',
57
+ 'auth.error.network': 'No connection. Some features are limited until you reconnect.',
58
+ },
59
+ developer: {
60
+ 'auth.error.configuration': 'Authentication is not configured correctly.',
61
+ 'auth.error.redirectMismatch': 'The sign-in redirect does not match the app configuration.',
62
+ 'auth.error.token': 'We could not complete the request. Please try again.',
63
+ 'auth.error.consentDenied': 'Access to this resource was denied.',
64
+ },
65
+ });
66
+
67
+ export const DEFAULT_MESSAGES: AuthMessageMap = authMessages.defaults;
68
+
69
+ /** Resolve a message, preferring app overrides over the English defaults. */
70
+ export function resolveMessages(overrides?: Partial<AuthMessageMap>): AuthMessageMap {
71
+ return authMessages.resolve(overrides);
72
+ }
package/src/index.ts CHANGED
@@ -1,83 +1,72 @@
1
- /**
2
- * @chipmobilesdk/rn-auth — reusable Microsoft Entra External ID authentication
3
- * for ChipMobileSdk-family React Native apps (public OIDC/PKCE client, no
4
- * backend). This is the single public entrypoint (LIB-003); modules under
5
- * `core/`, `tokens/`, `oidc/`, `access/`, and `diagnostics/` are private.
6
- */
7
-
8
- import { createAuthMachine } from './core/authMachine';
9
- import type { Auth, AuthConfig, CreateAuthOptions } from './config/types';
10
-
11
- /** Create the auth controller. Throws AuthConfigError on invalid config (FR-005). */
12
- export function createAuth(config: AuthConfig, options?: CreateAuthOptions): Auth {
13
- return createAuthMachine(config, options);
14
- }
15
-
16
- // Public types
17
- export type {
18
- Auth,
19
- AuthConfig,
20
- CreateAuthOptions,
21
- AuthState,
22
- AuthStatus,
23
- RestoreStatus,
24
- Profile,
25
- ProviderIdentity,
26
- ProviderConfig,
27
- ProviderId,
28
- DevicePlatform,
29
- ResourceConfig,
30
- ClaimMatcher,
31
- AccessTierMapping,
32
- AccessTier,
33
- AccessTokenResult,
34
- AccessTokenStatus,
35
- PremiumGateResult,
36
- GlobalSignOutResult,
37
- } from './config/types';
38
-
39
- // Ports + default adapters
40
- export type { SecureTokenStore } from './tokens/secureStore';
41
- export { createKeychainSecureStore, AUTH_STORAGE_KEY } from './tokens/secureStore';
42
- export type {
43
- OidcAuthClient,
44
- OidcTokens,
45
- AuthorizeParams,
46
- RefreshParams,
47
- EndSessionParams,
48
- } from './oidc/authClient';
49
- export { createAppAuthClient } from './oidc/authClient';
50
-
51
- // Access-tier evaluation (also exported for app-side reuse/testing)
52
- export { evaluateAccessTier, failClosedTier } from './access/accessTier';
53
-
54
- // Diagnostics
55
- export {
56
- AuthError,
57
- AuthConfigError,
58
- isAuthError,
59
- redact,
60
- } from './diagnostics/errors';
61
- export type { AuthErrorCode, AuthErrorAudience } from './diagnostics/errors';
62
- export {
63
- DEFAULT_MESSAGES,
64
- resolveMessages,
65
- } from './diagnostics/messageKeys';
66
- export type { AuthMessageMap, AuthMessageKey } from './diagnostics/messageKeys';
67
-
68
- // React bindings
69
- export { AuthProvider } from './react/AuthProvider';
70
- export type { AuthProviderProps } from './react/AuthProvider';
71
- export {
72
- useAuth,
73
- useProfile,
74
- useAccessTier,
75
- useAccessToken,
76
- useSignInProvider,
77
- useSignInProviders,
78
- } from './react/hooks';
79
- export type {
80
- UseAuthResult,
81
- UseAccessTokenResult,
82
- UseAccessTokenStatus,
83
- } from './react/hooks';
1
+ /**
2
+ * @chipmobilesdk/rn-auth — reusable Microsoft Entra External ID authentication
3
+ * for ChipMobileSdk-family React Native apps (public OIDC/PKCE client, no
4
+ * backend). This is the single public entrypoint (LIB-003); modules under
5
+ * `core/`, `tokens/`, `oidc/`, `access/`, and `diagnostics/` are private.
6
+ */
7
+
8
+ import { createAuthMachine } from './core/authMachine';
9
+ import type { Auth, AuthConfig, CreateAuthOptions } from './config/types';
10
+
11
+ /** Create the auth controller. Throws AuthConfigError on invalid config (FR-005). */
12
+ export function createAuth(config: AuthConfig, options?: CreateAuthOptions): Auth {
13
+ return createAuthMachine(config, options);
14
+ }
15
+
16
+ // Public types
17
+ export type {
18
+ Auth,
19
+ AuthConfig,
20
+ CreateAuthOptions,
21
+ AuthState,
22
+ AuthStatus,
23
+ RestoreStatus,
24
+ Profile,
25
+ ProviderIdentity,
26
+ ProviderConfig,
27
+ ProviderId,
28
+ DevicePlatform,
29
+ ResourceConfig,
30
+ ClaimMatcher,
31
+ AccessTierMapping,
32
+ AccessTier,
33
+ AccessTokenResult,
34
+ AccessTokenStatus,
35
+ PremiumGateResult,
36
+ GlobalSignOutResult,
37
+ } from './config/types';
38
+
39
+ // Ports + default adapters
40
+ export type { SecureTokenStore } from './tokens/secureStore';
41
+ export { createKeychainSecureStore, AUTH_STORAGE_KEY } from './tokens/secureStore';
42
+ export type {
43
+ OidcAuthClient,
44
+ OidcTokens,
45
+ AuthorizeParams,
46
+ RefreshParams,
47
+ EndSessionParams,
48
+ } from './oidc/authClient';
49
+ export { createAppAuthClient } from './oidc/authClient';
50
+
51
+ // Access-tier evaluation (also exported for app-side reuse/testing)
52
+ export { evaluateAccessTier, failClosedTier } from './access/accessTier';
53
+
54
+ // Diagnostics
55
+ export { AuthError, AuthConfigError, isAuthError, redact } from './diagnostics/errors';
56
+ export type { AuthErrorCode, AuthErrorAudience } from './diagnostics/errors';
57
+ export { DEFAULT_MESSAGES, authMessages, resolveMessages } from './diagnostics/messageKeys';
58
+ export type { AuthMessageMap, AuthMessageKey } from './diagnostics/messageKeys';
59
+
60
+ // React bindings
61
+ export { AuthProvider } from './react/AuthProvider';
62
+ export { useAuthSelector } from './react/hooks';
63
+ export type { AuthProviderProps } from './react/AuthProvider';
64
+ export {
65
+ useAuth,
66
+ useProfile,
67
+ useAccessTier,
68
+ useAccessToken,
69
+ useSignInProvider,
70
+ useSignInProviders,
71
+ } from './react/hooks';
72
+ export type { UseAuthResult, UseAccessTokenResult, UseAccessTokenStatus } from './react/hooks';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `@chipmobilesdk/rn-auth/keychain`: the default secure token store over
3
+ * react-native-keychain (AUTH-09). Its own entrypoint, so an app with its own
4
+ * secure storage never reaches this module.
5
+ */
6
+ export { createKeychainSecureStore, type KeychainSecureStoreOptions } from './tokens/secureStore';