@chipmobilesdk/rn-auth 0.5.0 → 0.6.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.
Files changed (167) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +8 -5
  3. package/lib/commonjs/access/accessTier.js +111 -0
  4. package/lib/commonjs/access/accessTier.js.map +1 -0
  5. package/lib/commonjs/app-auth.js +13 -0
  6. package/lib/commonjs/app-auth.js.map +1 -0
  7. package/lib/commonjs/config/types.js +50 -0
  8. package/lib/commonjs/config/types.js.map +1 -0
  9. package/lib/commonjs/config/validateConfig.js +114 -0
  10. package/lib/commonjs/config/validateConfig.js.map +1 -0
  11. package/lib/commonjs/core/authMachine.js +406 -0
  12. package/lib/commonjs/core/authMachine.js.map +1 -0
  13. package/lib/commonjs/core/profile.js +59 -0
  14. package/lib/commonjs/core/profile.js.map +1 -0
  15. package/lib/commonjs/core/session.js +125 -0
  16. package/lib/commonjs/core/session.js.map +1 -0
  17. package/lib/commonjs/diagnostics/errors.js +83 -0
  18. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  19. package/lib/commonjs/diagnostics/messageKeys.js +51 -0
  20. package/lib/commonjs/diagnostics/messageKeys.js.map +1 -0
  21. package/lib/commonjs/index.js +175 -0
  22. package/lib/commonjs/index.js.map +1 -0
  23. package/lib/commonjs/keychain.js +13 -0
  24. package/lib/commonjs/keychain.js.map +1 -0
  25. package/lib/commonjs/oidc/authClient.js +157 -0
  26. package/lib/commonjs/oidc/authClient.js.map +1 -0
  27. package/lib/commonjs/oidc/classifyError.js +65 -0
  28. package/lib/commonjs/oidc/classifyError.js.map +1 -0
  29. package/lib/commonjs/oidc/socialRouting.js +58 -0
  30. package/lib/commonjs/oidc/socialRouting.js.map +1 -0
  31. package/lib/commonjs/package.json +1 -0
  32. package/lib/commonjs/react/AuthProvider.js +37 -0
  33. package/lib/commonjs/react/AuthProvider.js.map +1 -0
  34. package/lib/commonjs/react/hooks.js +122 -0
  35. package/lib/commonjs/react/hooks.js.map +1 -0
  36. package/lib/commonjs/testing/conformance.js +148 -0
  37. package/lib/commonjs/testing/conformance.js.map +1 -0
  38. package/lib/commonjs/testing/index.js +53 -0
  39. package/lib/commonjs/testing/index.js.map +1 -0
  40. package/lib/commonjs/tokens/accessToken.js +165 -0
  41. package/lib/commonjs/tokens/accessToken.js.map +1 -0
  42. package/lib/commonjs/tokens/secureStore.js +60 -0
  43. package/lib/commonjs/tokens/secureStore.js.map +1 -0
  44. package/lib/module/access/accessTier.js +106 -0
  45. package/lib/module/access/accessTier.js.map +1 -0
  46. package/lib/module/app-auth.js +9 -0
  47. package/lib/module/app-auth.js.map +1 -0
  48. package/lib/module/config/types.js +46 -0
  49. package/lib/module/config/types.js.map +1 -0
  50. package/lib/module/config/validateConfig.js +110 -0
  51. package/lib/module/config/validateConfig.js.map +1 -0
  52. package/lib/module/core/authMachine.js +402 -0
  53. package/lib/module/core/authMachine.js.map +1 -0
  54. package/lib/module/core/profile.js +54 -0
  55. package/lib/module/core/profile.js.map +1 -0
  56. package/lib/module/core/session.js +118 -0
  57. package/lib/module/core/session.js.map +1 -0
  58. package/lib/module/diagnostics/errors.js +74 -0
  59. package/lib/module/diagnostics/errors.js.map +1 -0
  60. package/lib/module/diagnostics/messageKeys.js +46 -0
  61. package/lib/module/diagnostics/messageKeys.js.map +1 -0
  62. package/lib/module/index.js +33 -0
  63. package/lib/module/index.js.map +1 -0
  64. package/lib/module/keychain.js +9 -0
  65. package/lib/module/keychain.js.map +1 -0
  66. package/lib/module/oidc/authClient.js +152 -0
  67. package/lib/module/oidc/authClient.js.map +1 -0
  68. package/lib/module/oidc/classifyError.js +60 -0
  69. package/lib/module/oidc/classifyError.js.map +1 -0
  70. package/lib/module/oidc/socialRouting.js +52 -0
  71. package/lib/module/oidc/socialRouting.js.map +1 -0
  72. package/lib/module/package.json +1 -0
  73. package/lib/module/react/AuthProvider.js +31 -0
  74. package/lib/module/react/AuthProvider.js.map +1 -0
  75. package/lib/module/react/hooks.js +111 -0
  76. package/lib/module/react/hooks.js.map +1 -0
  77. package/lib/module/testing/conformance.js +140 -0
  78. package/lib/module/testing/conformance.js.map +1 -0
  79. package/lib/module/testing/index.js +25 -0
  80. package/lib/module/testing/index.js.map +1 -0
  81. package/lib/module/tokens/accessToken.js +161 -0
  82. package/lib/module/tokens/accessToken.js.map +1 -0
  83. package/lib/module/tokens/secureStore.js +56 -0
  84. package/lib/module/tokens/secureStore.js.map +1 -0
  85. package/lib/typescript/commonjs/access/accessTier.d.ts +14 -0
  86. package/lib/typescript/commonjs/access/accessTier.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/app-auth.d.ts +7 -0
  88. package/lib/typescript/commonjs/app-auth.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/config/types.d.ts +171 -0
  90. package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
  91. package/lib/typescript/commonjs/config/validateConfig.d.ts +8 -0
  92. package/lib/typescript/commonjs/config/validateConfig.d.ts.map +1 -0
  93. package/lib/typescript/commonjs/core/authMachine.d.ts +14 -0
  94. package/lib/typescript/commonjs/core/authMachine.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/core/profile.d.ts +15 -0
  96. package/lib/typescript/commonjs/core/profile.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/core/session.d.ts +60 -0
  98. package/lib/typescript/commonjs/core/session.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/diagnostics/errors.d.ts +37 -0
  100. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts +57 -0
  102. package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/index.d.ts +27 -0
  104. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/keychain.d.ts +7 -0
  106. package/lib/typescript/commonjs/keychain.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/oidc/authClient.d.ts +75 -0
  108. package/lib/typescript/commonjs/oidc/authClient.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/oidc/classifyError.d.ts +28 -0
  110. package/lib/typescript/commonjs/oidc/classifyError.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/oidc/socialRouting.d.ts +22 -0
  112. package/lib/typescript/commonjs/oidc/socialRouting.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/package.json +1 -0
  114. package/lib/typescript/commonjs/react/AuthProvider.d.ts +17 -0
  115. package/lib/typescript/commonjs/react/AuthProvider.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/react/hooks.d.ts +42 -0
  117. package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/testing/conformance.d.ts +32 -0
  119. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/testing/index.d.ts +11 -0
  121. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/tokens/accessToken.d.ts +45 -0
  123. package/lib/typescript/commonjs/tokens/accessToken.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/tokens/secureStore.d.ts +26 -0
  125. package/lib/typescript/commonjs/tokens/secureStore.d.ts.map +1 -0
  126. package/lib/typescript/module/access/accessTier.d.ts +14 -0
  127. package/lib/typescript/module/access/accessTier.d.ts.map +1 -0
  128. package/lib/typescript/module/app-auth.d.ts +7 -0
  129. package/lib/typescript/module/app-auth.d.ts.map +1 -0
  130. package/lib/typescript/module/config/types.d.ts +171 -0
  131. package/lib/typescript/module/config/types.d.ts.map +1 -0
  132. package/lib/typescript/module/config/validateConfig.d.ts +8 -0
  133. package/lib/typescript/module/config/validateConfig.d.ts.map +1 -0
  134. package/lib/typescript/module/core/authMachine.d.ts +14 -0
  135. package/lib/typescript/module/core/authMachine.d.ts.map +1 -0
  136. package/lib/typescript/module/core/profile.d.ts +15 -0
  137. package/lib/typescript/module/core/profile.d.ts.map +1 -0
  138. package/lib/typescript/module/core/session.d.ts +60 -0
  139. package/lib/typescript/module/core/session.d.ts.map +1 -0
  140. package/lib/typescript/module/diagnostics/errors.d.ts +37 -0
  141. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  142. package/lib/typescript/module/diagnostics/messageKeys.d.ts +57 -0
  143. package/lib/typescript/module/diagnostics/messageKeys.d.ts.map +1 -0
  144. package/lib/typescript/module/index.d.ts +27 -0
  145. package/lib/typescript/module/index.d.ts.map +1 -0
  146. package/lib/typescript/module/keychain.d.ts +7 -0
  147. package/lib/typescript/module/keychain.d.ts.map +1 -0
  148. package/lib/typescript/module/oidc/authClient.d.ts +75 -0
  149. package/lib/typescript/module/oidc/authClient.d.ts.map +1 -0
  150. package/lib/typescript/module/oidc/classifyError.d.ts +28 -0
  151. package/lib/typescript/module/oidc/classifyError.d.ts.map +1 -0
  152. package/lib/typescript/module/oidc/socialRouting.d.ts +22 -0
  153. package/lib/typescript/module/oidc/socialRouting.d.ts.map +1 -0
  154. package/lib/typescript/module/package.json +1 -0
  155. package/lib/typescript/module/react/AuthProvider.d.ts +17 -0
  156. package/lib/typescript/module/react/AuthProvider.d.ts.map +1 -0
  157. package/lib/typescript/module/react/hooks.d.ts +42 -0
  158. package/lib/typescript/module/react/hooks.d.ts.map +1 -0
  159. package/lib/typescript/module/testing/conformance.d.ts +32 -0
  160. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  161. package/lib/typescript/module/testing/index.d.ts +11 -0
  162. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  163. package/lib/typescript/module/tokens/accessToken.d.ts +45 -0
  164. package/lib/typescript/module/tokens/accessToken.d.ts.map +1 -0
  165. package/lib/typescript/module/tokens/secureStore.d.ts +26 -0
  166. package/lib/typescript/module/tokens/secureStore.d.ts.map +1 -0
  167. package/package.json +68 -21
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Public type contracts for @chipmobilesdk/rn-auth. Shapes follow
3
+ * specs/003-mobile-entra-auth/data-model.md.
4
+ */
5
+ import type { AccessTokenRequestOptions } from '../tokens/accessToken.js';
6
+ import type { SecureTokenStore } from '../tokens/secureStore.js';
7
+ import type { OidcAuthClient } from '../oidc/authClient.js';
8
+ import type { AuthError, AuthErrorCode } from '../diagnostics/errors.js';
9
+ import type { AuthMessageKey, AuthMessageMap } from '../diagnostics/messageKeys.js';
10
+ /** The providers this package has copy for out of the box. */
11
+ export type KnownProviderId = 'google' | 'apple' | 'facebook';
12
+ /**
13
+ * A provider id. Open on purpose: routing is `domain_hint` and nothing else, so
14
+ * adding an IdP the tenant federates — Microsoft account, an email one-time
15
+ * code — is a change to an app's config, not a release of this package
16
+ * (AUTH-14). `KnownProviderId` keeps the three familiar ones in autocomplete.
17
+ */
18
+ export type ProviderId = KnownProviderId | (string & {});
19
+ export type DevicePlatform = 'ios' | 'android';
20
+ export declare const DEVICE_PLATFORMS: readonly DevicePlatform[];
21
+ /** Provider Setup Configuration — non-secret public values only (FR-016/FR-017). */
22
+ export interface ProviderConfig {
23
+ id: ProviderId;
24
+ platforms: DevicePlatform[];
25
+ /** External ID `domain_hint` routing the user flow to this IdP (R3). */
26
+ domainHint: string;
27
+ /**
28
+ * Message key for the button label (Continue with Google / Apple). A key of
29
+ * this package's catalogue, or one of the app's own for a provider it added.
30
+ */
31
+ labelKey: AuthMessageKey | (string & {});
32
+ available?: boolean;
33
+ /**
34
+ * Extra OIDC authorize parameters for this provider, merged after
35
+ * `domain_hint` — `prompt`, `login_hint`, whatever the tenant's user flow
36
+ * expects. `domain_hint` itself cannot be overridden here.
37
+ */
38
+ additionalParameters?: Record<string, string>;
39
+ }
40
+ /** One configured protected resource for delegated token requests (FR-007). */
41
+ export interface ResourceConfig {
42
+ key: string;
43
+ scopes: string[];
44
+ displayName?: string;
45
+ }
46
+ export interface ClaimMatcher {
47
+ claim: string;
48
+ equals: string | number | boolean;
49
+ }
50
+ /** App-specific mapping from tenant indicators to access tiers (FR-019/FR-020). */
51
+ export interface AccessTierMapping {
52
+ /** Stable group object ids granting premium — authoritative (FR-020). */
53
+ premiumGroupObjectIds: string[];
54
+ premiumRoleNames?: string[];
55
+ premiumClaimMatchers?: ClaimMatcher[];
56
+ /** Diagnostics-only object-id → name map; never used for decisions (FR-020). */
57
+ groupDisplayNames?: Record<string, string>;
58
+ }
59
+ /** App-supplied, public-only setup input (FR-015/FR-016/FR-017). */
60
+ export interface AuthConfig {
61
+ authority: string;
62
+ clientId: string;
63
+ redirectUrl: string;
64
+ scopes: string[];
65
+ providers: ProviderConfig[];
66
+ resources?: ResourceConfig[];
67
+ accessTierMapping: AccessTierMapping;
68
+ secureStore: SecureTokenStore;
69
+ authClient?: OidcAuthClient;
70
+ /**
71
+ * Copy overrides for this package's own message keys, resolved over the
72
+ * English defaults and readable through `auth.getMessages()` and
73
+ * `useAuthMessages()`.
74
+ */
75
+ messages?: Partial<AuthMessageMap>;
76
+ }
77
+ /** Advanced/testing options. `platform` overrides the detected device platform. */
78
+ export interface CreateAuthOptions {
79
+ platform?: DevicePlatform;
80
+ }
81
+ export type AuthStatus = 'loading' | 'signed-out' | 'authenticating' | 'authenticated' | 'token-refreshing' | 'access-denied' | 'cancelled' | 'error';
82
+ export type RestoreStatus = 'pending' | 'restored' | 'unavailable' | 'offline';
83
+ /** Customer User / app-visible profile (FR-006). */
84
+ export interface Profile {
85
+ tenantUserId: string;
86
+ displayName?: string | undefined;
87
+ email?: string | undefined;
88
+ provider: string;
89
+ /**
90
+ * The id-token claims this profile was mapped from. Empty after a restore
91
+ * that could not reach the provider: the stored artifact holds the identity,
92
+ * not the token (AUTH-23). Read `restore` on the state to tell the two apart.
93
+ */
94
+ claims: Record<string, unknown>;
95
+ }
96
+ export interface ProviderIdentity {
97
+ provider: string;
98
+ subject: string;
99
+ emailBehavior: 'direct' | 'private-relay' | 'none';
100
+ }
101
+ /** Access Tier — local interpretation of tenant indicators (FR-010). */
102
+ export interface AccessTier {
103
+ tier: 'free' | 'premium';
104
+ source: 'group' | 'role' | 'claim' | 'default';
105
+ verification: 'verified' | 'unverified';
106
+ lastRefreshAt?: number;
107
+ }
108
+ export type AccessTokenStatus = 'success' | 'denied' | 'unavailable' | 'error';
109
+ /** Access Token Request result (FR-007). */
110
+ export interface AccessTokenResult {
111
+ resourceKey: string;
112
+ status: AccessTokenStatus;
113
+ token?: string;
114
+ expiresAt?: number;
115
+ errorCode?: AuthErrorCode;
116
+ }
117
+ /** Single active app-visible authenticated state (FR-005/FR-022). */
118
+ export interface AuthState {
119
+ status: AuthStatus;
120
+ profile?: Profile | undefined;
121
+ accessTier?: AccessTier | undefined;
122
+ restore: RestoreStatus;
123
+ error?: AuthError | undefined;
124
+ }
125
+ /** Result of a premium-only gate check (US3). */
126
+ export interface PremiumGateResult {
127
+ allowed: boolean;
128
+ tier: AccessTier;
129
+ }
130
+ /**
131
+ * What `signOutGlobal` did beyond the device (added in 0.2.2). Local state is
132
+ * cleared either way; `failed` means the tenant session may still be alive, so
133
+ * the next interactive sign-in can complete without a password prompt.
134
+ */
135
+ export interface GlobalSignOutResult {
136
+ global: 'ended' | 'failed';
137
+ /** Present when `global` is `failed`. Redacted like every AuthError. */
138
+ error?: AuthError;
139
+ }
140
+ /** The auth controller returned by `createAuth` (single active account). */
141
+ export interface Auth {
142
+ getState(): AuthState;
143
+ subscribe(listener: (state: AuthState) => void): () => void;
144
+ restore(): Promise<AuthState>;
145
+ signIn(providerId: ProviderId): Promise<AuthState>;
146
+ signOut(): Promise<void>;
147
+ signOutGlobal(): Promise<GlobalSignOutResult>;
148
+ /**
149
+ * A delegated token for one configured resource. Answers from the in-memory
150
+ * cache while the token is unexpired; `forceRefresh` skips and drops that
151
+ * cache, which is what a caller whose token was just rejected needs.
152
+ */
153
+ requestAccessToken(resourceKey: string, options?: AccessTokenRequestOptions): Promise<AccessTokenResult>;
154
+ getAccessTier(): AccessTier;
155
+ /** Whether a premium-only path is open, and the tier behind the answer. Reads nothing else and changes nothing (FR-011). */
156
+ canAccessPremium(): PremiumGateResult;
157
+ /**
158
+ * @deprecated Use `canAccessPremium` and show the denial where it happened.
159
+ * This also moves the whole controller to `access-denied`, which every screen
160
+ * reading `status` then sees, and only a `restore` or a sign-in leaves
161
+ * (AUTH-12). Kept for 0.4.x.
162
+ */
163
+ requirePremium(): PremiumGateResult;
164
+ /** This package's copy: the English defaults with the app's `messages` over them. */
165
+ getMessages(): AuthMessageMap;
166
+ /** The first available provider to present on the current platform (UX-004), or undefined. */
167
+ getPlatformProvider(): ProviderConfig | undefined;
168
+ /** All available providers for the current platform, in configuration order (FR-003/FR-004). */
169
+ getPlatformProviders(): ProviderConfig[];
170
+ }
171
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA4B,CAAC;AAEjF,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AACzD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/C,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAAuB,CAAC;AAE9E,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,UAAU,CAAC;IACf,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,wEAAw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D,gGAAgG;IAChG,oBAAoB,IAAI,cAAc,EAAE,CAAC;CACzC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Deterministic configuration validation (FR-005 → configuration-error).
3
+ * Throws AuthConfigError before any provider flow can start (US4 scenario 2).
4
+ * Covers the auth-config.md Section A–F rules.
5
+ */
6
+ import { type AuthConfig } from './types.js';
7
+ export declare function validateConfig(config: AuthConfig): void;
8
+ //# sourceMappingURL=validateConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateConfig.d.ts","sourceRoot":"","sources":["../../../../src/config/validateConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,YAAS,CAAC;AAe5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CA2HvD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Auth state machine / orchestrator (FR-005, FR-022, R5, R7). Holds the single
3
+ * active session, wires the OidcAuthClient + SecureTokenStore ports, profile
4
+ * mapping, access-tier evaluation, per-resource tokens, restore, and sign-out.
5
+ *
6
+ * Every operation that starts or ends a session bumps `sessionEpoch`. Work that
7
+ * awaited across such a change — a token refresh, a restore, an authorize —
8
+ * compares the epoch it started with before writing anything back, so a sign-out
9
+ * can never be undone by a request that was already in flight.
10
+ */
11
+ import type { Auth, AuthConfig, CreateAuthOptions, Profile } from '../config/types.js';
12
+ export declare function createAuthMachine(config: AuthConfig, options?: CreateAuthOptions): Auth;
13
+ export type { Profile };
14
+ //# sourceMappingURL=authMachine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authMachine.d.ts","sourceRoot":"","sources":["../../../../src/core/authMachine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,OAAO,KAAK,EACX,IAAI,EACJ,UAAU,EAEV,iBAAiB,EAIjB,OAAO,EAEP,MAAM,oBAAiB,CAAC;AAwBzB,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,GAAG,IAAI,CAmW3F;AAED,YAAY,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Claims → Profile mapping (FR-006). Tolerant of Apple private-relay emails and
3
+ * missing display name / given name (edge cases).
4
+ */
5
+ import type { Profile, ProviderId, ProviderIdentity } from '../config/types.js';
6
+ /** Map id-token claims to the app-visible Profile. */
7
+ export declare function mapClaimsToProfile(claims: Record<string, unknown>, providerId?: ProviderId): Profile;
8
+ /**
9
+ * Describe the external provider identity behind the profile (FR-004 edge
10
+ * cases). `emailBehavior` is what a screen needs to explain an address the user
11
+ * did not choose: Apple's private relay forwards mail and is not the address
12
+ * they type anywhere else.
13
+ */
14
+ export declare function describeProviderIdentity(claims: Record<string, unknown>, providerId?: ProviderId): ProviderIdentity;
15
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../src/core/profile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAiB,CAAC;AAU7E,sDAAsD;AACtD,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,CAAC,EAAE,UAAU,GACrB,OAAO,CAsBT;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,CAAC,EAAE,UAAU,GACrB,gBAAgB,CASlB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Session restoration (FR-008, R5). Reads the persisted artifact, attempts a
3
+ * silent refresh, and classifies the outcome:
4
+ * - restored: fresh tokens + claims → authenticated
5
+ * - offline: the refresh could not complete for any reason other than the
6
+ * session being invalid — no network, a timeout, a 5xx, an error we
7
+ * cannot classify → cached profile read-only, tier unverified (fail
8
+ * closed) — clarify Q3
9
+ * - unavailable: no artifact, or the provider said the refresh token is no
10
+ * longer valid → signed-out reauth
11
+ *
12
+ * Only `unavailable` deletes the stored session, so it is reserved for a verdict
13
+ * the provider actually gave. Treating every unclassified error as expiry signed
14
+ * users out whenever the token endpoint had a bad moment.
15
+ */
16
+ import type { AccessTier, AccessTierMapping, Profile, RestoreStatus } from '../config/types.js';
17
+ import type { OidcAuthClient } from '../oidc/authClient.js';
18
+ import type { SecureTokenStore } from '../tokens/secureStore.js';
19
+ /**
20
+ * The identity in the stored artifact: who, not what the token said.
21
+ *
22
+ * The whole claim set used to be written to the Keychain on every launch — all
23
+ * of it, groups included — for a value nothing reads back: the access tier is
24
+ * recomputed from fresh claims, and a restore that cannot reach the provider
25
+ * fails closed anyway (AUTH-23).
26
+ */
27
+ export type StoredProfile = Omit<Profile, 'claims'>;
28
+ export interface PersistedSession {
29
+ refreshToken: string;
30
+ profile: StoredProfile;
31
+ /** The id token hint for end-session (AUTH-04). Absent in artifacts written before 0.2.2. */
32
+ idToken?: string | undefined;
33
+ }
34
+ /** The artifact's identity as a profile. Artifacts written before 0.4.0 carry claims; they are kept. */
35
+ export declare function profileFromStored(stored: StoredProfile | Profile): Profile;
36
+ /** What goes to the store: everything but the claims. */
37
+ export declare function storedProfileFrom(profile: Profile): StoredProfile;
38
+ /** True when the artifact would be byte-identical, so the write can be skipped. */
39
+ export declare function sameSession(a: PersistedSession, b: PersistedSession): boolean;
40
+ export interface RestoreDeps {
41
+ secureStore: SecureTokenStore;
42
+ authority: string;
43
+ clientId: string;
44
+ redirectUrl: string;
45
+ scopes: string[];
46
+ authClient: OidcAuthClient;
47
+ mapping: AccessTierMapping;
48
+ }
49
+ export interface RestoreResult {
50
+ outcome: RestoreStatus;
51
+ profile?: Profile;
52
+ /** The artifact this restore read, so a rewrite that changes nothing can be skipped. */
53
+ persisted?: PersistedSession;
54
+ accessTier?: AccessTier;
55
+ refreshToken?: string;
56
+ idToken?: string | undefined;
57
+ }
58
+ export declare function parsePersistedSession(raw: string | null): PersistedSession | null;
59
+ export declare function restoreSession(deps: RestoreDeps): Promise<RestoreResult>;
60
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAAuB,CAAC;AAM9D;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,wGAAwG;AACxG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,GAAG,OAAO,CAE1E;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAOjE;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAS7E;AAED,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wFAAwF;IACxF,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAajF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CA+C9E"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Developer-facing diagnostics. AuthError carries a stable machine-readable
3
+ * code, an audience (user vs developer/tenant), and a localizable message key.
4
+ * `detail` is always passed through `redact` so tokens and secrets never appear
5
+ * in logs or error objects (FR-014).
6
+ */
7
+ import { SdkError } from '@chipmobilesdk/rn-core';
8
+ import type { AuthMessageKey } from './messageKeys.js';
9
+ export type AuthErrorCode = 'configuration-error' | 'provider-cancelled' | 'redirect-mismatch' | 'token-acquisition-failed' | 'session-expired' | 'consent-denied' | 'network-unavailable';
10
+ export type AuthErrorAudience = 'user' | 'developer';
11
+ export interface AuthErrorArgs {
12
+ code: AuthErrorCode;
13
+ /** A key of this package's catalogue: the copy an app shows for this error. */
14
+ messageKey: AuthMessageKey;
15
+ audience?: AuthErrorAudience;
16
+ detail?: string | undefined;
17
+ }
18
+ /**
19
+ * Replace token-like substrings with a placeholder so diagnostics never leak
20
+ * secrets or token values (FR-014): JWTs become `[redacted-token]`; URLs, e-mail
21
+ * addresses, UUIDs and other opaque runs become `[redacted]` (rn-core's patterns).
22
+ */
23
+ export declare function redact(value: string | undefined): string | undefined;
24
+ /** The package's error; an `SdkError` (`@chipmobilesdk/rn-core`) with `pkg: 'rn-auth'`. */
25
+ export declare class AuthError extends SdkError<AuthErrorCode> {
26
+ readonly audience: AuthErrorAudience;
27
+ readonly messageKey: AuthMessageKey;
28
+ readonly detail?: string | undefined;
29
+ constructor(args: AuthErrorArgs);
30
+ }
31
+ export declare class AuthConfigError extends AuthError {
32
+ constructor(messageKey: AuthMessageKey, detail?: string);
33
+ }
34
+ export declare function isAuthError(value: unknown): value is AuthError;
35
+ /** Normalize any thrown value into an AuthError without leaking secrets. */
36
+ export declare function toAuthError(value: unknown, fallbackCode?: AuthErrorCode, fallbackMessageKey?: AuthMessageKey): AuthError;
37
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmB,QAAQ,EAAkB,MAAM,wBAAwB,CAAC;AAEnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAe,CAAC;AAEpD,MAAM,MAAM,aAAa,GACtB,qBAAqB,GACrB,oBAAoB,GACpB,mBAAmB,GACnB,0BAA0B,GAC1B,iBAAiB,GACjB,gBAAgB,GAChB,qBAAqB,CAAC;AAEzB,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,WAAW,CAAC;AAErD,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,+EAA+E;IAC/E,UAAU,EAAE,cAAc,CAAC;IAC3B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAOD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQpE;AAKD,2FAA2F;AAC3F,qBAAa,SAAU,SAAQ,QAAQ,CAAC,aAAa,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEzB,IAAI,EAAE,aAAa;CAY/B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBACjC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM;CAIvD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAC1B,KAAK,EAAE,OAAO,EACd,YAAY,GAAE,aAA0C,EACxD,kBAAkB,GAAE,cAAmC,GACrD,SAAS,CAWX"}
@@ -0,0 +1,57 @@
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
+ export interface AuthMessageMap {
8
+ 'auth.action.continueGoogle': string;
9
+ 'auth.action.continueApple': string;
10
+ 'auth.action.continueFacebook': string;
11
+ 'auth.state.signedOut': string;
12
+ 'auth.state.authenticating': string;
13
+ 'auth.state.signedIn': string;
14
+ 'auth.state.signingOut': string;
15
+ 'auth.tier.free': string;
16
+ 'auth.tier.premium': string;
17
+ 'auth.tier.unverified': string;
18
+ 'auth.error.cancelled': string;
19
+ 'auth.error.sessionExpired': string;
20
+ 'auth.error.entitlement': string;
21
+ 'auth.error.network': string;
22
+ 'auth.error.configuration': string;
23
+ 'auth.error.redirectMismatch': string;
24
+ 'auth.error.token': string;
25
+ 'auth.error.consentDenied': string;
26
+ }
27
+ export type AuthMessageKey = keyof AuthMessageMap;
28
+ /**
29
+ * The catalog, as an rn-core message set: `user` copy may reach an end user,
30
+ * `developer` copy describes a tenant or configuration fault (UX-005). Register
31
+ * `authMessages.user` with rn-i18n to translate it like app copy.
32
+ */
33
+ export declare const authMessages: import("@chipmobilesdk/rn-core").MessageSet<{
34
+ 'auth.action.continueGoogle': string;
35
+ 'auth.action.continueApple': string;
36
+ 'auth.action.continueFacebook': string;
37
+ 'auth.state.signedOut': string;
38
+ 'auth.state.authenticating': string;
39
+ 'auth.state.signedIn': string;
40
+ 'auth.state.signingOut': string;
41
+ 'auth.tier.free': string;
42
+ 'auth.tier.premium': string;
43
+ 'auth.tier.unverified': string;
44
+ 'auth.error.cancelled': string;
45
+ 'auth.error.sessionExpired': string;
46
+ 'auth.error.entitlement': string;
47
+ 'auth.error.network': string;
48
+ }, {
49
+ 'auth.error.configuration': string;
50
+ 'auth.error.redirectMismatch': string;
51
+ 'auth.error.token': string;
52
+ 'auth.error.consentDenied': string;
53
+ }>;
54
+ export declare const DEFAULT_MESSAGES: AuthMessageMap;
55
+ /** Resolve a message, preferring app overrides over the English defaults. */
56
+ export declare function resolveMessages(overrides?: Partial<AuthMessageMap>): AuthMessageMap;
57
+ //# sourceMappingURL=messageKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageKeys.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/messageKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,cAAc;IAE9B,4BAA4B,EAAE,MAAM,CAAC;IACrC,2BAA2B,EAAE,MAAM,CAAC;IACpC,8BAA8B,EAAE,MAAM,CAAC;IACvC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;IACpC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,uBAAuB,EAAE,MAAM,CAAC;IAEhC,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAE/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;IACpC,wBAAwB,EAAE,MAAM,CAAC;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAE7B,0BAA0B,EAAE,MAAM,CAAC;IACnC,6BAA6B,EAAE,MAAM,CAAC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;EAuBvB,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,cAAsC,CAAC;AAEtE,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAEnF"}
@@ -0,0 +1,27 @@
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
+ import type { Auth, AuthConfig, CreateAuthOptions } from './config/types.js';
8
+ /** Create the auth controller. Throws AuthConfigError on invalid config (FR-005). */
9
+ export declare function createAuth(config: AuthConfig, options?: CreateAuthOptions): Auth;
10
+ export type { Auth, AuthConfig, CreateAuthOptions, AuthState, AuthStatus, RestoreStatus, Profile, ProviderIdentity, ProviderConfig, ProviderId, KnownProviderId, DevicePlatform, ResourceConfig, ClaimMatcher, AccessTierMapping, AccessTier, AccessTokenResult, AccessTokenStatus, PremiumGateResult, GlobalSignOutResult, } from './config/types.js';
11
+ export { describeProviderIdentity, mapClaimsToProfile } from './core/profile.js';
12
+ export type { AccessTokenRequestOptions } from './tokens/accessToken.js';
13
+ export type { SecureTokenStore } from './tokens/secureStore.js';
14
+ export { createKeychainSecureStore, AUTH_STORAGE_KEY } from './tokens/secureStore.js';
15
+ export type { OidcAuthClient, OidcTokens, OidcServiceConfiguration, AppAuthClientOptions, AuthorizeParams, RefreshParams, EndSessionParams, } from './oidc/authClient.js';
16
+ export { createAppAuthClient } from './oidc/authClient.js';
17
+ export { evaluateAccessTier, failClosedTier } from './access/accessTier.js';
18
+ export { AuthError, AuthConfigError, isAuthError, redact } from './diagnostics/errors.js';
19
+ export type { AuthErrorCode, AuthErrorAudience } from './diagnostics/errors.js';
20
+ export { DEFAULT_MESSAGES, authMessages, resolveMessages } from './diagnostics/messageKeys.js';
21
+ export type { AuthMessageMap, AuthMessageKey } from './diagnostics/messageKeys.js';
22
+ export { AuthProvider } from './react/AuthProvider.js';
23
+ export { useAuthSelector } from './react/hooks.js';
24
+ export type { AuthProviderProps } from './react/AuthProvider.js';
25
+ export { useAuth, useAuthMessages, useProfile, useAccessTier, useAccessToken, useSignInProvider, useSignInProviders, } from './react/hooks.js';
26
+ export type { UseAuthResult, UseAccessTokenResult, UseAccessTokenStatus } from './react/hooks.js';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAE1E,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAEhF;AAGD,YAAY,EACX,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,mBAAgB,CAAC;AAGxB,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,mBAAgB,CAAC;AAE9E,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAsB,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAsB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,yBAAsB,CAAC;AACnF,YAAY,EACX,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,gBAAgB,GAChB,MAAM,sBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAmB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,wBAAqB,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,yBAAsB,CAAC;AACvF,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAsB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA2B,CAAC;AAC5F,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,8BAA2B,CAAC;AAGhF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAe,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAsB,CAAC;AAC9D,OAAO,EACN,OAAO,EACP,eAAe,EACf,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,kBAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAe,CAAC"}
@@ -0,0 +1,7 @@
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.js';
7
+ //# sourceMappingURL=keychain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../../src/keychain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,yBAAsB,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * OidcAuthClient port + default react-native-app-auth adapter (R1).
3
+ *
4
+ * The port abstracts the Authorization Code + PKCE public-client flow so the
5
+ * auth engine is testable without native code. The default adapter lazily
6
+ * requires react-native-app-auth and is validated on device.
7
+ */
8
+ export interface OidcTokens {
9
+ /** Resource/audience access token (present for authorize and resource refresh). */
10
+ accessToken?: string | undefined;
11
+ /**
12
+ * Refresh token used for silent acquisition and restore. Absent when the
13
+ * provider issued none — a refresh that does not rotate, or an authorize the
14
+ * tenant answered without `offline_access`.
15
+ */
16
+ refreshToken?: string | undefined;
17
+ /** Raw id token (JWT). Absent from a refresh requested without `openid`. */
18
+ idToken?: string | undefined;
19
+ /** Decoded id-token (or access-token) claims used for profile + access tier. */
20
+ claims: Record<string, unknown>;
21
+ /** Access-token expiry in epoch milliseconds, when available. */
22
+ accessTokenExpiresAt?: number | undefined;
23
+ }
24
+ export interface AuthorizeParams {
25
+ authority: string;
26
+ clientId: string;
27
+ redirectUrl: string;
28
+ scopes: string[];
29
+ /** Additional OIDC parameters, e.g. `domain_hint` for social routing. */
30
+ additionalParameters?: Record<string, string>;
31
+ }
32
+ export interface RefreshParams {
33
+ authority: string;
34
+ clientId: string;
35
+ redirectUrl: string;
36
+ refreshToken: string;
37
+ scopes: string[];
38
+ }
39
+ export interface EndSessionParams {
40
+ authority: string;
41
+ clientId: string;
42
+ redirectUrl: string;
43
+ idToken?: string | undefined;
44
+ }
45
+ export interface OidcAuthClient {
46
+ authorize(params: AuthorizeParams): Promise<OidcTokens>;
47
+ refresh(params: RefreshParams): Promise<OidcTokens>;
48
+ endSession(params: EndSessionParams): Promise<void>;
49
+ }
50
+ /** Decode the payload segment of a JWT without any dependency (device-safe). */
51
+ export declare function decodeJwtClaims(jwt: string | null | undefined): Record<string, unknown>;
52
+ /** The endpoints discovery would have returned, when an app already knows them. */
53
+ export interface OidcServiceConfiguration {
54
+ authorizationEndpoint: string;
55
+ tokenEndpoint: string;
56
+ endSessionEndpoint?: string;
57
+ revocationEndpoint?: string;
58
+ registrationEndpoint?: string;
59
+ }
60
+ export interface AppAuthClientOptions {
61
+ /** When true, the OIDC discovery document is fetched from `${authority}`. */
62
+ useDiscovery?: boolean;
63
+ /**
64
+ * Static endpoints, used instead of discovery. Every authorize, refresh and
65
+ * sign-out otherwise costs the native module one `.well-known` round-trip,
66
+ * including the refresh on the startup path (AUTH-08).
67
+ */
68
+ serviceConfiguration?: OidcServiceConfiguration;
69
+ }
70
+ /**
71
+ * Default OidcAuthClient adapter wrapping react-native-app-auth (PKCE public
72
+ * client). Validated on device (R8).
73
+ */
74
+ export declare function createAppAuthClient(options?: AppAuthClientOptions): OidcAuthClient;
75
+ //# sourceMappingURL=authClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authClient.d.ts","sourceRoot":"","sources":["../../../../src/oidc/authClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,WAAW,UAAU;IAC1B,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM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oBAAoB,CAAC,EAAE,wBAAwB,CAAC;CAChD;AAyCD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,cAAc,CAwEtF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Classifies a native OIDC error into an `AuthErrorCode`.
3
+ *
4
+ * The rules are an ordered table rather than a chain of substring checks, so a
5
+ * platform adapter (the iOS one, later) adds its own rows without touching the
6
+ * engine. Order matters: the first matching rule wins.
7
+ *
8
+ * The default is deliberately not "session expired". Restore clears the stored
9
+ * session only on `session-expired`, so anything this table cannot name — a
10
+ * timeout, a 5xx, a discovery failure, a localized message — must keep the
11
+ * session rather than sign the user out.
12
+ */
13
+ import { AuthError, type AuthErrorCode } from '../diagnostics/errors.js';
14
+ import type { AuthMessageKey } from '../diagnostics/messageKeys.js';
15
+ export interface ClassificationRule {
16
+ readonly code: AuthErrorCode;
17
+ readonly messageKey: AuthMessageKey;
18
+ /** Matched against the native error's `code` and `message`, case-insensitively. */
19
+ readonly pattern: RegExp;
20
+ }
21
+ /**
22
+ * OAuth error codes (RFC 6749 §5.2, OIDC Core §3.1.2.6) and the Entra ID AADSTS
23
+ * codes that mean the same thing, plus the transport failures app-auth reports.
24
+ */
25
+ export declare const DEFAULT_CLASSIFICATION_RULES: readonly ClassificationRule[];
26
+ /** Maps a native app-auth error to a classified AuthError without leaking tokens. */
27
+ export declare function classifyAppAuthError(error: unknown, rules?: readonly ClassificationRule[]): AuthError;
28
+ //# sourceMappingURL=classifyError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classifyError.d.ts","sourceRoot":"","sources":["../../../../src/oidc/classifyError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,0BAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA4B,CAAC;AAEjE,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,kBAAkB,EA8BrE,CAAC;AAEF,qFAAqF;AACrF,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,SAAS,kBAAkB,EAAiC,GACjE,SAAS,CAaX"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Social provider routing (FR-002/FR-003, R3). Google and Apple are federated
3
+ * inside the External ID tenant; the app presents the platform-correct action
4
+ * and starts the user flow with a per-provider `domain_hint`.
5
+ */
6
+ import type { AuthConfig, DevicePlatform, ProviderConfig, ProviderId } from '../config/types.js';
7
+ /** Find the configured provider, ensuring it is enabled for the platform. */
8
+ export declare function resolveProvider(config: AuthConfig, providerId: ProviderId, platform: DevicePlatform): ProviderConfig;
9
+ /** Build the OIDC additional parameters that route to the chosen IdP. */
10
+ export declare function buildAdditionalParameters(provider: ProviderConfig): Record<string, string>;
11
+ /**
12
+ * All providers to present on a given platform, in configuration array order
13
+ * (FR-003/FR-004). Filtered to providers enabled for the platform and not marked
14
+ * unavailable.
15
+ */
16
+ export declare function availableProvidersForPlatform(config: AuthConfig, platform: DevicePlatform): ProviderConfig[];
17
+ /**
18
+ * The first available provider for a platform (UX-004, back-compat). Equals
19
+ * `availableProvidersForPlatform(config, platform)[0]`.
20
+ */
21
+ export declare function defaultProviderForPlatform(config: AuthConfig, platform: DevicePlatform): ProviderConfig | undefined;
22
+ //# sourceMappingURL=socialRouting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socialRouting.d.ts","sourceRoot":"","sources":["../../../../src/oidc/socialRouting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAiB,CAAC;AAG9F,6EAA6E;AAC7E,wBAAgB,eAAe,CAC9B,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,cAAc,GACtB,cAAc,CAqBhB;AAED,yEAAyE;AACzE,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAI1F;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,cAAc,GACtB,cAAc,EAAE,CAIlB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,cAAc,GACtB,cAAc,GAAG,SAAS,CAE5B"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * React context boundary for the auth controller (LIB-002).
3
+ *
4
+ * The context carries the controller only, never its state: a context value that
5
+ * changed on every transition re-rendered every consumer on every transition
6
+ * (PERF-02). Hooks read the state through `useSyncExternalStore` with a selector,
7
+ * so a component re-renders only when the part it reads changes.
8
+ */
9
+ import React from 'react';
10
+ import type { Auth } from '../config/types.js';
11
+ export interface AuthProviderProps {
12
+ auth: Auth;
13
+ children: React.ReactNode;
14
+ }
15
+ export declare function AuthProvider({ auth, children }: AuthProviderProps): React.JSX.Element;
16
+ export declare function useAuthInstance(): Auth;
17
+ //# sourceMappingURL=AuthProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../src/react/AuthProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAiB,CAAC;AAI5C,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,iBAAiB,qBAEjE;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC"}