@pofsis-nbt/pofsis-auth 0.1.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 (40) hide show
  1. package/API.md +166 -0
  2. package/README.md +236 -0
  3. package/dist/PofsisAuth.d.ts +7 -0
  4. package/dist/PofsisAuth.d.ts.map +1 -0
  5. package/dist/attachAuthInterceptor.d.ts +7 -0
  6. package/dist/attachAuthInterceptor.d.ts.map +1 -0
  7. package/dist/auth/api.d.ts +14 -0
  8. package/dist/auth/api.d.ts.map +1 -0
  9. package/dist/auth/authLaunch.d.ts +20 -0
  10. package/dist/auth/authLaunch.d.ts.map +1 -0
  11. package/dist/auth/config.d.ts +7 -0
  12. package/dist/auth/config.d.ts.map +1 -0
  13. package/dist/auth/pkce.d.ts +3 -0
  14. package/dist/auth/pkce.d.ts.map +1 -0
  15. package/dist/components/AuthErrorScreen.d.ts +4 -0
  16. package/dist/components/AuthErrorScreen.d.ts.map +1 -0
  17. package/dist/components/AuthLoadingScreen.d.ts +4 -0
  18. package/dist/components/AuthLoadingScreen.d.ts.map +1 -0
  19. package/dist/components/AuthPathShell.d.ts +11 -0
  20. package/dist/components/AuthPathShell.d.ts.map +1 -0
  21. package/dist/components/RequireAuth.d.ts +13 -0
  22. package/dist/components/RequireAuth.d.ts.map +1 -0
  23. package/dist/components/index.d.ts +5 -0
  24. package/dist/components/index.d.ts.map +1 -0
  25. package/dist/context/AuthComponentsContext.d.ts +3 -0
  26. package/dist/context/AuthComponentsContext.d.ts.map +1 -0
  27. package/dist/context/AuthContext.d.ts +3 -0
  28. package/dist/context/AuthContext.d.ts.map +1 -0
  29. package/dist/context/useAuth.d.ts +3 -0
  30. package/dist/context/useAuth.d.ts.map +1 -0
  31. package/dist/index.cjs +2 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.ts +9 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +624 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/style.css +2 -0
  38. package/dist/types.d.ts +95 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/package.json +59 -0
package/API.md ADDED
@@ -0,0 +1,166 @@
1
+ # @pofsis-nbt/pofsis-auth API
2
+
3
+ Import supported APIs from `@pofsis-nbt/pofsis-auth`. Import component CSS separately from `@pofsis-nbt/pofsis-auth/style.css`. Internal source paths are not public entry points.
4
+
5
+ ## `PofsisAuth`
6
+
7
+ Provides authentication state, restores refresh-cookie sessions, performs OAuth/PKCE redirects and callback exchange, coordinates cross-tab logout, and owns `/login`, `/auth/callback`, and `/auth/error`.
8
+
9
+ ```tsx
10
+ <PofsisAuth
11
+ appName="Orbit"
12
+ apiBaseUrl="https://auth.example.com/api"
13
+ authUrl="https://auth.example.com/authorize"
14
+ scope="openid profile email"
15
+ postLoginPath="/"
16
+ components={{ LoadingScreen, ErrorScreen }}
17
+ >
18
+ <App />
19
+ </PofsisAuth>
20
+ ```
21
+
22
+ ### `PofsisAuthProps`
23
+
24
+ | Property | Type | Default | Purpose |
25
+ | --------------- | ------------------------ | ---------------------- | ---------------------------------------- |
26
+ | `children` | `ReactNode` | Required | Application tree receiving auth context. |
27
+ | `appName` | `string` | Required | Auth identity/application label. |
28
+ | `apiBaseUrl` | `string` | Required | POFSIS Auth API base URL. |
29
+ | `authUrl` | `string` | Required | OAuth authorization endpoint. |
30
+ | `scope` | `string` | `openid profile email` | OAuth scopes. |
31
+ | `postLoginPath` | `string` | `/` | Fallback destination after callback. |
32
+ | `components` | `AuthComponentOverrides` | Built-in screens | Loading and error UI overrides. |
33
+
34
+ The package does not read environment variables. Consumers resolve environment or runtime settings before rendering this component.
35
+
36
+ ## `RequireAuth`
37
+
38
+ Renders authenticated children, displays a fallback while authentication is unresolved, and starts login when no session is available.
39
+
40
+ ### `RequireAuthProps`
41
+
42
+ | Property | Type | Default | Purpose |
43
+ | ------------------- | ------------ | ------------------------- | --------------------------------- |
44
+ | `children` | `ReactNode` | Required | Authenticated content. |
45
+ | `fallback` | `ReactNode` | Configured loading screen | Loading or redirecting content. |
46
+ | `onUnauthenticated` | `() => void` | Calls `login()` | Optional router-specific handler. |
47
+
48
+ ## `useAuth`
49
+
50
+ Returns `AuthContextValue` from the nearest `PofsisAuth` and throws when used outside the provider.
51
+
52
+ ### State
53
+
54
+ | Value | Type | Meaning |
55
+ | ----------------- | ------------------------ | --------------------------------------- |
56
+ | `user` | `PofsisUser \| null` | Current account identity. |
57
+ | `session` | `SessionPayload \| null` | Current non-token session data. |
58
+ | `isAuthenticated` | `boolean` | Whether a session is active. |
59
+ | `isLoading` | `boolean` | Whether initial restoration is running. |
60
+
61
+ ### `login(options?)`
62
+
63
+ Starts OAuth authorization. `AuthLaunchOptions` supports:
64
+
65
+ | Property | Type | Behavior |
66
+ | ----------- | ---------------------------------------------- | ----------------------------------------- |
67
+ | `screen` | `'login' \| 'signup' \| 'reset' \| 'register'` | Auth screen; `register` aliases `signup`. |
68
+ | `loginHint` | `string` | Valid email or Philippine mobile hint. |
69
+ | `method` | `'password' \| 'passkey' \| 'otp'` | Login-only method hint. |
70
+ | `returnUrl` | `string` | Safe local path restored after callback. |
71
+
72
+ The `/login` route maps `screen`, `login_hint`, `method`, and legacy `email` query parameters into these options. `login_hint` takes precedence over `email`. Invalid or oversized hints are ignored.
73
+
74
+ ### `logout()`
75
+
76
+ Posts to remote logout, clears local state, broadcasts logout to other tabs, and navigates to the registered logout URI or `/login`. Local cleanup still occurs if the remote request fails.
77
+
78
+ ### `refreshSession()`
79
+
80
+ Uses the registered OAuth client and refresh cookie to request an in-memory access token and session. Concurrent calls share one request.
81
+
82
+ ### `getAccessToken()`
83
+
84
+ Returns the current in-memory access token as `string | null` without triggering refresh.
85
+
86
+ ### `getAccountProfile()`
87
+
88
+ Returns `Promise<AccountProfile>`, refreshing authentication when required and synchronizing returned profile fields into the context user.
89
+
90
+ ### `updateAccountProfile(profile)`
91
+
92
+ Accepts `{ firstName?: string | null; lastName?: string | null }` and returns the synchronized `AccountProfile`.
93
+
94
+ ### `uploadAccountProfileImage(kind, file)`
95
+
96
+ Uploads a `File` for kind `'profile'` or `'cover'` and returns the synchronized `AccountProfile`.
97
+
98
+ ### `deleteAccountProfileImage(kind)`
99
+
100
+ Deletes the `'profile'` or `'cover'` image and returns the synchronized `AccountProfile`.
101
+
102
+ ### `completeCallback(code, state)`
103
+
104
+ Verifies OAuth state and the PKCE verifier, exchanges the authorization code, and accepts the session. `PofsisAuth` normally calls this automatically.
105
+
106
+ ## Components
107
+
108
+ ### `AuthLoadingScreen`
109
+
110
+ Default full-page loading UI. `AuthLoadingScreenProps.callback` selects callback-specific copy.
111
+
112
+ ### `AuthErrorScreen`
113
+
114
+ Default full-page error UI. `AuthErrorScreenProps.retryHref` defaults to `/login`.
115
+
116
+ ### `AuthComponentOverrides`
117
+
118
+ ```ts
119
+ type AuthComponentOverrides = {
120
+ LoadingScreen?: ComponentType<AuthLoadingScreenProps>
121
+ ErrorScreen?: ComponentType<AuthErrorScreenProps>
122
+ }
123
+ ```
124
+
125
+ ## `attachAuthInterceptor`
126
+
127
+ ```ts
128
+ const detach = attachAuthInterceptor(client, getToken, refresh)
129
+ ```
130
+
131
+ Adds a Bearer token to Axios requests and retries one failed request after a `401` refresh. The returned cleanup function ejects both interceptors.
132
+
133
+ ## `resolveConfig`
134
+
135
+ ```ts
136
+ const config = resolveConfig({
137
+ appName: 'Orbit',
138
+ apiBaseUrl: 'https://auth.example.com/api',
139
+ authUrl: 'https://auth.example.com/authorize',
140
+ })
141
+ ```
142
+
143
+ Validates caller-supplied configuration, removes one trailing slash from URL values, defaults the scope, and throws when required values are missing. `ConfigOverrides` remains the accepted input type for direct validation.
144
+
145
+ ## Exported types
146
+
147
+ - `PofsisAuthProps`
148
+ - `RequireAuthProps`
149
+ - `PofsisAuthConfig`
150
+ - `ConfigOverrides`
151
+ - `PofsisUser`
152
+ - `AccountProfile`
153
+ - `SessionPayload`
154
+ - `TokenResponse`
155
+ - `OAuthClientConfig`
156
+ - `AuthContextValue`
157
+ - `AuthLaunchOptions`
158
+ - `AuthScreen`
159
+ - `AuthMethod`
160
+ - `AuthComponentOverrides`
161
+ - `AuthLoadingScreenProps`
162
+ - `AuthErrorScreenProps`
163
+
164
+ ## Internal APIs
165
+
166
+ Raw requests, PKCE utilities, launch-option normalization, context construction, callback routing, and source assets are private. Consumers must not import from `src`, `dist/auth`, `dist/components`, or `dist/context`; only exported package subpaths are supported.
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # @pofsis-nbt/pofsis-auth
2
+
3
+ React integration for POFSIS OAuth 2.0 authorization-code authentication with PKCE, refresh-cookie session restoration, account profile management, reusable authentication UI, and Axios authorization support.
4
+
5
+ The package ships one implementation for JavaScript and TypeScript applications:
6
+
7
+ - ESM: `dist/index.js`
8
+ - CommonJS: `dist/index.cjs`
9
+ - TypeScript declarations: `dist/index.d.ts`
10
+ - Component styles: `dist/style.css`
11
+
12
+ ## Requirements
13
+
14
+ - Node.js `^20.19.0` or `>=22.12.0` for package development and builds
15
+ - React and React DOM 18 or newer
16
+ - Axios 1 or newer only when using `attachAuthInterceptor`
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @pofsis-nbt/pofsis-auth react react-dom
22
+ ```
23
+
24
+ Install Axios when using the optional interceptor helper:
25
+
26
+ ```bash
27
+ npm install axios
28
+ ```
29
+
30
+ ## JavaScript usage
31
+
32
+ Import the package stylesheet once in the application entry point:
33
+
34
+ ```jsx
35
+ import '@pofsis-nbt/pofsis-auth/style.css'
36
+ import { PofsisAuth, RequireAuth } from '@pofsis-nbt/pofsis-auth'
37
+
38
+ export function App() {
39
+ return (
40
+ <PofsisAuth
41
+ appName="Orbit"
42
+ apiBaseUrl="https://auth.example.com/api"
43
+ authUrl="https://auth.example.com/authorize"
44
+ >
45
+ <RequireAuth>
46
+ <YourApplication />
47
+ </RequireAuth>
48
+ </PofsisAuth>
49
+ )
50
+ }
51
+ ```
52
+
53
+ ## TypeScript usage
54
+
55
+ The same imports provide bundled declarations; no separate type package is needed:
56
+
57
+ ```tsx
58
+ import '@pofsis-nbt/pofsis-auth/style.css'
59
+ import { PofsisAuth, RequireAuth, type PofsisAuthProps } from '@pofsis-nbt/pofsis-auth'
60
+
61
+ const authConfig: Pick<PofsisAuthProps, 'appName' | 'apiBaseUrl' | 'authUrl' | 'scope'> = {
62
+ appName: 'Orbit',
63
+ apiBaseUrl: 'https://auth.example.com/api',
64
+ authUrl: 'https://auth.example.com/authorize',
65
+ scope: 'openid profile email',
66
+ }
67
+
68
+ export function App() {
69
+ return (
70
+ <PofsisAuth {...authConfig}>
71
+ <RequireAuth>
72
+ <YourApplication />
73
+ </RequireAuth>
74
+ </PofsisAuth>
75
+ )
76
+ }
77
+ ```
78
+
79
+ ## Supplying runtime configuration
80
+
81
+ The library never reads `import.meta.env`, `process.env`, or another environment system. The consuming application supplies configuration through `PofsisAuth`.
82
+
83
+ ### Vite consumer
84
+
85
+ ```tsx
86
+ <PofsisAuth
87
+ appName={import.meta.env.VITE_POFSIS_APP_NAME}
88
+ apiBaseUrl={import.meta.env.VITE_POFSIS_API_BASE_URL}
89
+ authUrl={import.meta.env.VITE_POFSIS_AUTH_URL}
90
+ scope={import.meta.env.VITE_POFSIS_SCOPE}
91
+ >
92
+ <AppRoutes />
93
+ </PofsisAuth>
94
+ ```
95
+
96
+ ### Framework-neutral runtime configuration
97
+
98
+ ```tsx
99
+ const runtimeConfig = window.applicationConfig.auth
100
+
101
+ <PofsisAuth
102
+ appName={runtimeConfig.appName}
103
+ apiBaseUrl={runtimeConfig.apiBaseUrl}
104
+ authUrl={runtimeConfig.authUrl}
105
+ scope={runtimeConfig.scope}
106
+ >
107
+ <AppRoutes />
108
+ </PofsisAuth>
109
+ ```
110
+
111
+ `appName`, `apiBaseUrl`, and `authUrl` are required. `scope` defaults to `openid profile email`.
112
+
113
+ ## Auth routes
114
+
115
+ `PofsisAuth` handles these browser paths before rendering application children:
116
+
117
+ | Path | Behavior |
118
+ | ---------------- | ----------------------------------------------------------------------------------------------------- |
119
+ | `/login` | Starts the PKCE authorization redirect. |
120
+ | `/auth/callback` | Verifies state, exchanges the authorization code, and redirects to the saved path or `postLoginPath`. |
121
+ | `/auth/error` | Renders the configured error screen. |
122
+
123
+ The consuming application must serve its SPA entry point for these paths and register the callback and logout URIs with POFSIS Auth.
124
+
125
+ ## Session and login
126
+
127
+ ```tsx
128
+ import { useAuth } from '@pofsis-nbt/pofsis-auth'
129
+
130
+ export function AccountMenu() {
131
+ const { isAuthenticated, login, logout, user } = useAuth()
132
+
133
+ if (!isAuthenticated) {
134
+ return <button onClick={() => void login()}>Sign in</button>
135
+ }
136
+
137
+ return <button onClick={() => void logout()}>Sign out {user?.displayName}</button>
138
+ }
139
+ ```
140
+
141
+ Access tokens remain in memory and are not persisted.
142
+
143
+ Login supports screens and editable hints:
144
+
145
+ ```tsx
146
+ void login({
147
+ screen: 'login',
148
+ loginHint: 'sample@example.com',
149
+ method: 'password',
150
+ returnUrl: '/requested-page',
151
+ })
152
+ ```
153
+
154
+ - `screen`: `login`, `signup`, or `reset`; `register` remains a compatibility alias for `signup`.
155
+ - `method`: `password`, `passkey`, or `otp`; applied only to the login screen.
156
+ - `loginHint`: a valid email or Philippine mobile number.
157
+ - `returnUrl`: a local path beginning with one `/`, never `//`.
158
+
159
+ The `/login` route accepts `screen`, `login_hint`, `method`, and legacy `email` query parameters. Hints are editable and untrusted; they never bypass authentication or authorization.
160
+
161
+ ## Custom auth UI
162
+
163
+ ```tsx
164
+ import type { AuthErrorScreenProps, AuthLoadingScreenProps } from '@pofsis-nbt/pofsis-auth'
165
+
166
+ function LoadingScreen({ callback }: AuthLoadingScreenProps) {
167
+ return <p>{callback ? 'Completing sign-in...' : 'Restoring session...'}</p>
168
+ }
169
+
170
+ function ErrorScreen({ retryHref }: AuthErrorScreenProps) {
171
+ return <a href={retryHref}>Try signing in again</a>
172
+ }
173
+
174
+ ;<PofsisAuth {...authConfig} components={{ LoadingScreen, ErrorScreen }}>
175
+ <YourApplication />
176
+ </PofsisAuth>
177
+ ```
178
+
179
+ `RequireAuth` also accepts a route-specific `fallback`.
180
+
181
+ ## Axios integration
182
+
183
+ ```tsx
184
+ import { useEffect } from 'react'
185
+ import axios from 'axios'
186
+ import { attachAuthInterceptor, useAuth } from '@pofsis-nbt/pofsis-auth'
187
+
188
+ const api = axios.create({ baseURL: '/api' })
189
+
190
+ function ApiBridge() {
191
+ const { getAccessToken, refreshSession } = useAuth()
192
+
193
+ useEffect(
194
+ () => attachAuthInterceptor(api, getAccessToken, refreshSession),
195
+ [getAccessToken, refreshSession],
196
+ )
197
+
198
+ return null
199
+ }
200
+ ```
201
+
202
+ The returned cleanup function ejects both interceptors.
203
+
204
+ ## CommonJS
205
+
206
+ Bundlers and Node-compatible tooling can use the CommonJS export:
207
+
208
+ ```js
209
+ const { PofsisAuth, RequireAuth } = require('@pofsis-nbt/pofsis-auth')
210
+ ```
211
+
212
+ Import the stylesheet through the consuming bundler:
213
+
214
+ ```js
215
+ require('@pofsis-nbt/pofsis-auth/style.css')
216
+ ```
217
+
218
+ ## Development and packaging
219
+
220
+ ```bash
221
+ npm run typecheck
222
+ npm test
223
+ npm run build
224
+ npm run pack:check
225
+ ```
226
+
227
+ `npm run build` creates ESM, CommonJS, declarations, source maps, and CSS under `dist/`. `npm run pack:check` performs an npm dry run only; it does not publish.
228
+
229
+ ## Migrating from `@pofsis/auth-react`
230
+
231
+ 1. Replace imports with `@pofsis-nbt/pofsis-auth`.
232
+ 2. Import `@pofsis-nbt/pofsis-auth/style.css` once.
233
+ 3. Pass `appName`, `apiBaseUrl`, and `authUrl` explicitly to `PofsisAuth`.
234
+ 4. Remove Vite dependency-prebundle workarounds used for the source-only package.
235
+
236
+ See [API.md](./API.md) for the complete supported public API. Files below package-internal source directories are not public entry points.
@@ -0,0 +1,7 @@
1
+ import type { PofsisAuthProps } from './types';
2
+ /**
3
+ * Single integration surface for tool apps.
4
+ * Handles session restore, PKCE login, and fixed paths `/login`, `/auth/callback`, `/auth/error`.
5
+ */
6
+ export declare function PofsisAuth({ children, appName, apiBaseUrl, authUrl, components, scope, postLoginPath, }: PofsisAuthProps): import("react").JSX.Element;
7
+ //# sourceMappingURL=PofsisAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PofsisAuth.d.ts","sourceRoot":"","sources":["../src/PofsisAuth.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAIR,eAAe,EAElB,MAAM,SAAS,CAAA;AAmVhB;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACvB,QAAQ,EACR,OAAO,EACP,UAAU,EACV,OAAO,EACP,UAAU,EACV,KAAK,EACL,aAAmB,GACtB,EAAE,eAAe,+BA4BjB"}
@@ -0,0 +1,7 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ /**
3
+ * Attach Bearer token + single 401 refresh/retry to an axios instance.
4
+ * Optional — only needed when the tool calls APIs with the access token.
5
+ */
6
+ export declare function attachAuthInterceptor(client: AxiosInstance, getToken: () => string | null, refresh: () => Promise<void>): () => void;
7
+ //# sourceMappingURL=attachAuthInterceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachAuthInterceptor.d.ts","sourceRoot":"","sources":["../src/attachAuthInterceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA0C,MAAM,OAAO,CAAA;AAIlF;;;GAGG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,EAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,cAoB/B"}
@@ -0,0 +1,14 @@
1
+ import type { AccountProfile, OAuthClientConfig, PofsisAuthConfig, TokenResponse } from '../types';
2
+ export declare function fetchOAuthClient(config: PofsisAuthConfig): Promise<OAuthClientConfig>;
3
+ export declare function exchangeCode(config: PofsisAuthConfig, code: string, verifier: string, client: Pick<OAuthClientConfig, 'client_id' | 'redirect_uri'>): Promise<TokenResponse>;
4
+ export declare function refresh(config: PofsisAuthConfig, clientId: string): Promise<TokenResponse | null>;
5
+ export declare function checkSession(config: PofsisAuthConfig): Promise<boolean>;
6
+ export declare function signOut(config: PofsisAuthConfig): Promise<void>;
7
+ export declare function getAccountProfile(config: PofsisAuthConfig, accessToken: string): Promise<AccountProfile>;
8
+ export declare function updateAccountProfile(config: PofsisAuthConfig, accessToken: string, profile: {
9
+ firstName?: string | null;
10
+ lastName?: string | null;
11
+ }): Promise<AccountProfile>;
12
+ export declare function uploadAccountProfileImage(config: PofsisAuthConfig, accessToken: string, kind: 'profile' | 'cover', file: File): Promise<AccountProfile>;
13
+ export declare function deleteAccountProfileImage(config: PofsisAuthConfig, accessToken: string, kind: 'profile' | 'cover'): Promise<AccountProfile>;
14
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/auth/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAiClG,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,8BAQ9D;AAED,wBAAsB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,cAAc,CAAC,0BAahE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iCASvE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,gBAAgB,oBAO1D;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,gBAAgB,iBAErD;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAKpF;AAED,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,2BAQnE;AAED,wBAAsB,yBAAyB,CAC3C,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,SAAS,GAAG,OAAO,EACzB,IAAI,EAAE,IAAI,2BAUb;AAED,wBAAsB,yBAAyB,CAC3C,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,SAAS,GAAG,OAAO,2BAO5B"}
@@ -0,0 +1,20 @@
1
+ import type { AuthLaunchOptions, AuthMethod, AuthScreen } from '../types';
2
+ export declare function normalizeAuthLaunchOptions(value: unknown, defaultScreen?: AuthScreen): {
3
+ returnUrl: string | undefined;
4
+ screen: AuthScreen;
5
+ loginHint: string | undefined;
6
+ method: AuthMethod | undefined;
7
+ };
8
+ export declare function authLaunchOptionsFromSearch(search: string): {
9
+ returnUrl: string | undefined;
10
+ screen: AuthScreen;
11
+ loginHint: string | undefined;
12
+ method: AuthMethod | undefined;
13
+ };
14
+ export declare function buildAuthDestination({ authUrl, appName, query, options, }: {
15
+ authUrl: string;
16
+ appName: string;
17
+ query: URLSearchParams;
18
+ options?: AuthLaunchOptions;
19
+ }): string;
20
+ //# sourceMappingURL=authLaunch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authLaunch.d.ts","sourceRoot":"","sources":["../../src/auth/authLaunch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAiBzE,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,GAAE,UAAoB;;;;;EAkB7F;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM;;;;;EAYzD;AAED,wBAAgB,oBAAoB,CAAC,EACjC,OAAO,EACP,OAAO,EACP,KAAK,EACL,OAAO,GACV,EAAE;IACC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,eAAe,CAAA;IACtB,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAC9B,UAoBA"}
@@ -0,0 +1,7 @@
1
+ import type { PofsisAuthConfig } from '../types';
2
+ export type ConfigOverrides = Partial<PofsisAuthConfig>;
3
+ /**
4
+ * Validate and normalize caller-supplied auth configuration.
5
+ */
6
+ export declare function resolveConfig(overrides?: ConfigOverrides): PofsisAuthConfig;
7
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/auth/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAMhD,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAEvD;;GAEG;AACH,wBAAgB,aAAa,CAAC,SAAS,GAAE,eAAoB,GAAG,gBAAgB,CAoB/E"}
@@ -0,0 +1,3 @@
1
+ export declare const randomValue: () => string;
2
+ export declare function pkceChallenge(verifier: string): Promise<string>;
3
+ //# sourceMappingURL=pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,cAA2D,CAAA;AAEnF,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,mBAInD"}
@@ -0,0 +1,4 @@
1
+ import './AuthErrorScreen.css';
2
+ import type { AuthErrorScreenProps } from '../types';
3
+ export declare function AuthErrorScreen({ retryHref }: AuthErrorScreenProps): import("react").JSX.Element;
4
+ //# sourceMappingURL=AuthErrorScreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthErrorScreen.d.ts","sourceRoot":"","sources":["../../src/components/AuthErrorScreen.tsx"],"names":[],"mappings":"AAEA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAqFpD,wBAAgB,eAAe,CAAC,EAAE,SAAoB,EAAE,EAAE,oBAAoB,+BAwB7E"}
@@ -0,0 +1,4 @@
1
+ import './AuthLoadingScreen.css';
2
+ import type { AuthLoadingScreenProps } from '../types';
3
+ export declare function AuthLoadingScreen({ callback }: AuthLoadingScreenProps): import("react").JSX.Element;
4
+ //# sourceMappingURL=AuthLoadingScreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthLoadingScreen.d.ts","sourceRoot":"","sources":["../../src/components/AuthLoadingScreen.tsx"],"names":[],"mappings":"AACA,OAAO,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAqCtD,wBAAgB,iBAAiB,CAAC,EAAE,QAAgB,EAAE,EAAE,sBAAsB,+BAU7E"}
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { AuthComponentOverrides } from '../types';
3
+ type AuthPathShellProps = {
4
+ children: ReactNode;
5
+ components: Required<AuthComponentOverrides>;
6
+ postLoginPath: string;
7
+ returnPathKey: string;
8
+ };
9
+ export declare function AuthPathShell({ children, components, postLoginPath, returnPathKey, }: AuthPathShellProps): import("react").JSX.Element | null;
10
+ export {};
11
+ //# sourceMappingURL=AuthPathShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthPathShell.d.ts","sourceRoot":"","sources":["../../src/components/AuthPathShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAGrE,OAAO,KAAK,EAAE,sBAAsB,EAAoB,MAAM,UAAU,CAAA;AAExE,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,SAAS,CAAA;IACnB,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAA;IAC5C,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACxB,CAAA;AAqED,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,UAAU,EACV,aAAa,EACb,aAAa,GAChB,EAAE,kBAAkB,sCA2BpB"}
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from 'react';
2
+ export type RequireAuthProps = {
3
+ children: ReactNode;
4
+ /** Rendered while session is restoring. */
5
+ fallback?: ReactNode;
6
+ /** Called when unauthenticated (default: redirect to /login). */
7
+ onUnauthenticated?: () => void;
8
+ };
9
+ /**
10
+ * Guard for authenticated UI. Router-agnostic — defaults to assigning /login.
11
+ */
12
+ export declare function RequireAuth({ children, fallback, onUnauthenticated }: RequireAuthProps): import("react").JSX.Element;
13
+ //# sourceMappingURL=RequireAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequireAuth.d.ts","sourceRoot":"","sources":["../../src/components/RequireAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK7D,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,EAAE,SAAS,CAAA;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;CACjC,CAAA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,gBAAgB,+BAmBtF"}
@@ -0,0 +1,5 @@
1
+ export { AuthErrorScreen } from './AuthErrorScreen';
2
+ export { AuthLoadingScreen } from './AuthLoadingScreen';
3
+ export { RequireAuth } from './RequireAuth';
4
+ export type { RequireAuthProps } from './RequireAuth';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AuthComponentOverrides } from '../types';
2
+ export declare const AuthComponentsContext: import("react").Context<Required<AuthComponentOverrides> | null>;
3
+ //# sourceMappingURL=AuthComponentsContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthComponentsContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthComponentsContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEtD,eAAO,MAAM,qBAAqB,kEAA+D,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AuthContextValue } from '../types';
2
+ export declare const AuthContext: import("react").Context<AuthContextValue | null>;
3
+ //# sourceMappingURL=AuthContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,eAAO,MAAM,WAAW,kDAA+C,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AuthContextValue } from '../types';
2
+ export declare function useAuth(): AuthContextValue;
3
+ //# sourceMappingURL=useAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/context/useAuth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAGhD,wBAAgB,OAAO,IAAI,gBAAgB,CAI1C"}