@pofsis-nbt/pofsis-auth 0.1.0 → 1.0.2
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/Documentation.md +141 -0
- package/README.md +39 -156
- package/dist/PofsisAuth.d.ts +1 -1
- package/dist/PofsisAuth.d.ts.map +1 -1
- package/dist/auth/authLaunch.d.ts +1 -1
- package/dist/auth/authLaunch.d.ts.map +1 -1
- package/dist/auth/config.d.ts +4 -2
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/components/AuthPathShell.d.ts +2 -4
- package/dist/components/AuthPathShell.d.ts.map +1 -1
- package/dist/components/RequireAuth.d.ts.map +1 -1
- package/dist/context/useAuth.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +205 -206
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +15 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -5
- package/API.md +0 -166
package/Documentation.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# POFSIS Auth Documentation
|
|
2
|
+
|
|
3
|
+
This is the complete public API and integration reference for `@pofsis-nbt/pofsis-auth@1.0.1`.
|
|
4
|
+
|
|
5
|
+
The repository also includes an interactive [POFSIS Auth documentation portal](./index.html) with required environment configuration, generated setup examples, and authentication scenario links. The portal does not persist or transmit entered values and is intentionally excluded from the npm package.
|
|
6
|
+
|
|
7
|
+
## Integration process
|
|
8
|
+
|
|
9
|
+
1. Install `@pofsis-nbt/pofsis-auth` with its React, React DOM, and optional Axios peers.
|
|
10
|
+
2. Import `@pofsis-nbt/pofsis-auth/style.css` once.
|
|
11
|
+
3. Wrap the application in `PofsisAuth` and supply runtime configuration.
|
|
12
|
+
4. Protect authenticated content with `RequireAuth` or use `useAuth` directly.
|
|
13
|
+
5. Register `/auth/callback` and the application origin with the POFSIS Auth service.
|
|
14
|
+
|
|
15
|
+
The consuming application owns environment lookup. The library never reads `import.meta.env`.
|
|
16
|
+
|
|
17
|
+
## Public components
|
|
18
|
+
|
|
19
|
+
### `PofsisAuth`
|
|
20
|
+
|
|
21
|
+
The provider restores the cookie-backed session, manages the in-memory access token, coordinates cross-tab logout, runs OAuth/PKCE, and handles fixed auth paths.
|
|
22
|
+
|
|
23
|
+
`PofsisAuthProps`:
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Required | Meaning |
|
|
26
|
+
| --------------- | ------------------------ | -------- | -------------------------------------- |
|
|
27
|
+
| `children` | `ReactNode` | yes | Application content |
|
|
28
|
+
| `appName` | `string` | yes | Registered POFSIS application identity |
|
|
29
|
+
| `apiBaseUrl` | `string` | yes | Auth API base URL |
|
|
30
|
+
| `authUrl` | `string` | yes | OAuth authorize URL |
|
|
31
|
+
| `scope` | `string` | no | Defaults to `openid profile email` |
|
|
32
|
+
| `postLoginPath` | `string` | no | Callback destination; defaults to `/` |
|
|
33
|
+
| `components` | `AuthComponentOverrides` | no | Custom loading and error screens |
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
<PofsisAuth
|
|
37
|
+
appName="ORBIT"
|
|
38
|
+
apiBaseUrl={runtimeConfig.authApi}
|
|
39
|
+
authUrl={runtimeConfig.authorizeUrl}
|
|
40
|
+
components={{ LoadingScreen: AppLoader, ErrorScreen: AppAuthError }}
|
|
41
|
+
>
|
|
42
|
+
<App />
|
|
43
|
+
</PofsisAuth>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### `RequireAuth`
|
|
47
|
+
|
|
48
|
+
`RequireAuth({ children, fallback?, onUnauthenticated? })` renders authenticated content. `fallback` overrides loading UI for that guard. Without `onUnauthenticated`, an unauthenticated visitor starts login; failures route to `/auth/error`.
|
|
49
|
+
|
|
50
|
+
### `AuthLoadingScreen`
|
|
51
|
+
|
|
52
|
+
The default full-screen loader. `AuthLoadingScreenProps.callback` changes the message for login/callback work.
|
|
53
|
+
|
|
54
|
+
### `AuthErrorScreen`
|
|
55
|
+
|
|
56
|
+
The default error page. `AuthErrorScreenProps.retryHref` defaults to `/login`. Its illustration is emitted into the compiled bundle as a data asset.
|
|
57
|
+
|
|
58
|
+
## `useAuth`
|
|
59
|
+
|
|
60
|
+
`useAuth(): AuthContextValue` must be called below `PofsisAuth`.
|
|
61
|
+
|
|
62
|
+
| Value or method | Meaning |
|
|
63
|
+
| --------------------------------------- | ----------------------------------------------------------------------------- |
|
|
64
|
+
| `user` | Current `PofsisUser`, or `null` |
|
|
65
|
+
| `session` | Current `SessionPayload`, or `null` |
|
|
66
|
+
| `isAuthenticated` | Whether a session is present |
|
|
67
|
+
| `isLoading` | Whether initial session restoration is running |
|
|
68
|
+
| `login(options?)` | Starts OAuth/PKCE login |
|
|
69
|
+
| `logout()` | Ends the remote session, clears local state, broadcasts logout, and redirects |
|
|
70
|
+
| `refreshSession()` | Exchanges the refresh cookie for a new access token |
|
|
71
|
+
| `getAccessToken()` | Returns the in-memory token or `null` |
|
|
72
|
+
| `getAccountProfile()` | Fetches and merges the current `AccountProfile` |
|
|
73
|
+
| `updateAccountProfile(profile)` | Updates first and/or last name |
|
|
74
|
+
| `uploadAccountProfileImage(kind, file)` | Uploads a `profile` or `cover` image |
|
|
75
|
+
| `deleteAccountProfileImage(kind)` | Removes a `profile` or `cover` image |
|
|
76
|
+
| `completeCallback(code, state)` | Completes PKCE callback; normally used internally |
|
|
77
|
+
|
|
78
|
+
## Login options and URL hints
|
|
79
|
+
|
|
80
|
+
`login(options)` accepts `AuthLaunchOptions`:
|
|
81
|
+
|
|
82
|
+
- `returnUrl`: accepted only when it starts with `/` and not `//`; unsafe or external values are discarded.
|
|
83
|
+
- `screen`: `login`, `signup`, or `reset`; legacy `register` is normalized to `signup`.
|
|
84
|
+
- `loginHint`: valid email or Philippine mobile number. Emails are trimmed/lowercased; mobile numbers normalize to `+63`; invalid or values over 320 characters are ignored.
|
|
85
|
+
- `method`: `password`, `passkey`, or `otp`. Login accepts all three methods. Signup accepts `password` or `otp`; OTP signup continues to the verification-code page after the identifier is submitted.
|
|
86
|
+
|
|
87
|
+
The `/login` route also reads `screen`, `login_hint`, and `method`. Legacy `email` is accepted only as an email hint and only when canonical `login_hint` is absent. Unknown values are ignored. Signup defaults to password when no method is supplied and preserves an explicit `otp`; reset does not forward a method.
|
|
88
|
+
|
|
89
|
+
Fixed paths are `/login`, `/auth/callback`, and `/auth/error`. Saved callback destinations are restricted to safe local paths.
|
|
90
|
+
|
|
91
|
+
## Axios interceptor
|
|
92
|
+
|
|
93
|
+
`attachAuthInterceptor(client, getToken, refresh)` adds the current bearer token and performs one refresh-and-retry after a 401. It returns a cleanup function that ejects both interceptors. Axios is optional unless this helper is used.
|
|
94
|
+
|
|
95
|
+
## Configuration helper
|
|
96
|
+
|
|
97
|
+
`resolveConfig(overrides: ConfigOverrides)` validates `appName`, `apiBaseUrl`, and `authUrl`, trims values, removes a trailing slash from URLs, and supplies the default scope. Missing required values throw synchronously.
|
|
98
|
+
|
|
99
|
+
## Exported types
|
|
100
|
+
|
|
101
|
+
- `PofsisAuthProps`, `PofsisAuthConfig`, `ConfigOverrides`, `AuthComponentOverrides`
|
|
102
|
+
- `AuthLoadingScreenProps`, `AuthErrorScreenProps`, `RequireAuthProps`
|
|
103
|
+
- `AuthContextValue`, `AuthLaunchOptions`, `AuthScreen`, `AuthMethod`
|
|
104
|
+
- `PofsisUser`, `AccountProfile`, `SessionPayload`, `TokenResponse`
|
|
105
|
+
- `OAuthClientConfig`
|
|
106
|
+
|
|
107
|
+
`SessionPayload` contains `token_type`, `expires_in`, and `user`. `TokenResponse` adds `access_token`. Access tokens remain in memory. `PofsisUser` exposes identity, display/profile media, and optional roles. `AccountProfile` represents the editable account profile and timestamps. `OAuthClientConfig` represents server-resolved client, redirect, and logout details.
|
|
108
|
+
|
|
109
|
+
## Module formats
|
|
110
|
+
|
|
111
|
+
ESM/JavaScript and TypeScript use the same package import:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { PofsisAuth, useAuth } from '@pofsis-nbt/pofsis-auth'
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
CommonJS uses:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
const { PofsisAuth, useAuth } = require('@pofsis-nbt/pofsis-auth')
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
TypeScript declarations resolve from `dist/index.d.ts`. No separate TypeScript package is needed.
|
|
124
|
+
|
|
125
|
+
## Build and verification process
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm run format:check
|
|
129
|
+
npm run typecheck
|
|
130
|
+
npm test
|
|
131
|
+
npm run build
|
|
132
|
+
npm run pack:check
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`dist/` contains ESM and CommonJS JavaScript, source maps, declaration files/maps, component declarations, and `style.css`. The npm package includes only `dist`, `package.json`, `README.md`, and `Documentation.md`.
|
|
136
|
+
|
|
137
|
+
## Public boundary and migration
|
|
138
|
+
|
|
139
|
+
Supported imports are the package root and `@pofsis-nbt/pofsis-auth/style.css`. Files under `auth/`, `components/`, `context/`, `src/`, and `dist/` are implementation details and are not exported.
|
|
140
|
+
|
|
141
|
+
Migrating from `@pofsis/auth-react` requires changing the package name, passing explicit provider configuration, and importing the stylesheet. OAuth paths, PKCE/session behavior, hooks, profile methods, UI overrides, and interceptor behavior remain available.
|
package/README.md
CHANGED
|
@@ -1,86 +1,43 @@
|
|
|
1
1
|
# @pofsis-nbt/pofsis-auth
|
|
2
2
|
|
|
3
|
-
React
|
|
3
|
+
React OAuth 2.0/PKCE authentication for POFSIS applications. One package serves JavaScript and TypeScript consumers through ESM, CommonJS, generated declarations, and extracted CSS.
|
|
4
4
|
|
|
5
|
-
|
|
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`
|
|
5
|
+
For guided setup and authentication scenarios, open the repository's interactive [POFSIS Auth documentation portal](./index.html). It validates consumer-supplied environment values and generates safe `/login` launch links without storing them.
|
|
17
6
|
|
|
18
7
|
## Install
|
|
19
8
|
|
|
20
9
|
```bash
|
|
21
|
-
npm install @pofsis-nbt/pofsis-auth react react-dom
|
|
10
|
+
npm install @pofsis-nbt/pofsis-auth axios react react-dom
|
|
22
11
|
```
|
|
23
12
|
|
|
24
|
-
Install Axios when using the optional interceptor helper:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install axios
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## JavaScript usage
|
|
31
|
-
|
|
32
13
|
Import the package stylesheet once in the application entry point:
|
|
33
14
|
|
|
34
|
-
```
|
|
15
|
+
```ts
|
|
35
16
|
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
17
|
```
|
|
52
18
|
|
|
53
|
-
##
|
|
54
|
-
|
|
55
|
-
The same imports provide bundled declarations; no separate type package is needed:
|
|
19
|
+
## Quick start
|
|
56
20
|
|
|
57
21
|
```tsx
|
|
22
|
+
import { PofsisAuth, RequireAuth } from '@pofsis-nbt/pofsis-auth'
|
|
58
23
|
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
24
|
|
|
68
25
|
export function App() {
|
|
69
26
|
return (
|
|
70
|
-
<PofsisAuth
|
|
27
|
+
<PofsisAuth
|
|
28
|
+
appName="ORBIT"
|
|
29
|
+
apiBaseUrl="https://auth-api.example.com"
|
|
30
|
+
authUrl="https://auth.example.com/authorize"
|
|
31
|
+
>
|
|
71
32
|
<RequireAuth>
|
|
72
|
-
<
|
|
33
|
+
<Dashboard />
|
|
73
34
|
</RequireAuth>
|
|
74
35
|
</PofsisAuth>
|
|
75
36
|
)
|
|
76
37
|
}
|
|
77
38
|
```
|
|
78
39
|
|
|
79
|
-
|
|
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
|
|
40
|
+
`appName`, `apiBaseUrl`, and `authUrl` are required. The library does not read environment variables. A Vite application may pass its own values:
|
|
84
41
|
|
|
85
42
|
```tsx
|
|
86
43
|
<PofsisAuth
|
|
@@ -89,148 +46,74 @@ The library never reads `import.meta.env`, `process.env`, or another environment
|
|
|
89
46
|
authUrl={import.meta.env.VITE_POFSIS_AUTH_URL}
|
|
90
47
|
scope={import.meta.env.VITE_POFSIS_SCOPE}
|
|
91
48
|
>
|
|
92
|
-
<
|
|
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 />
|
|
49
|
+
<App />
|
|
108
50
|
</PofsisAuth>
|
|
109
51
|
```
|
|
110
52
|
|
|
111
|
-
|
|
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.
|
|
53
|
+
The same props may come from server-injected runtime configuration or hardcoded deployment configuration. The default scope is `openid profile email`.
|
|
124
54
|
|
|
125
55
|
## Session and login
|
|
126
56
|
|
|
127
57
|
```tsx
|
|
128
58
|
import { useAuth } from '@pofsis-nbt/pofsis-auth'
|
|
129
59
|
|
|
130
|
-
|
|
131
|
-
const {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return <button onClick={() => void login()}>Sign in</button>
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return <button onClick={() => void logout()}>Sign out {user?.displayName}</button>
|
|
60
|
+
function AccountMenu() {
|
|
61
|
+
const { user, login, logout } = useAuth()
|
|
62
|
+
if (!user) return <button onClick={() => void login()}>Sign in</button>
|
|
63
|
+
return <button onClick={() => void logout()}>Sign out {user.displayName}</button>
|
|
138
64
|
}
|
|
139
65
|
```
|
|
140
66
|
|
|
141
|
-
|
|
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.
|
|
67
|
+
The provider handles `/login`, `/auth/callback`, and `/auth/error`. Login supports `screen`, `loginHint`, `method`, and a safe application-relative `returnUrl`. An OTP signup opens the signup page and continues to account verification after the identifier is submitted. See [Documentation.md](./Documentation.md) for the complete API.
|
|
160
68
|
|
|
161
|
-
##
|
|
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
|
-
}
|
|
69
|
+
## Axios
|
|
169
70
|
|
|
170
|
-
|
|
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'
|
|
71
|
+
```ts
|
|
185
72
|
import axios from 'axios'
|
|
186
73
|
import { attachAuthInterceptor, useAuth } from '@pofsis-nbt/pofsis-auth'
|
|
187
74
|
|
|
188
75
|
const api = axios.create({ baseURL: '/api' })
|
|
189
76
|
|
|
190
|
-
function
|
|
77
|
+
function ApiAuthBridge() {
|
|
191
78
|
const { getAccessToken, refreshSession } = useAuth()
|
|
192
|
-
|
|
193
|
-
useEffect(
|
|
79
|
+
React.useEffect(
|
|
194
80
|
() => attachAuthInterceptor(api, getAccessToken, refreshSession),
|
|
195
81
|
[getAccessToken, refreshSession],
|
|
196
82
|
)
|
|
197
|
-
|
|
198
83
|
return null
|
|
199
84
|
}
|
|
200
85
|
```
|
|
201
86
|
|
|
202
|
-
The returned cleanup function ejects both interceptors.
|
|
203
|
-
|
|
204
87
|
## CommonJS
|
|
205
88
|
|
|
206
|
-
Bundlers and Node-compatible tooling can use the CommonJS export:
|
|
207
|
-
|
|
208
89
|
```js
|
|
209
|
-
const { PofsisAuth, RequireAuth } = require('@pofsis-nbt/pofsis-auth')
|
|
90
|
+
const { PofsisAuth, RequireAuth, useAuth } = require('@pofsis-nbt/pofsis-auth')
|
|
91
|
+
require('@pofsis-nbt/pofsis-auth/style.css')
|
|
210
92
|
```
|
|
211
93
|
|
|
212
|
-
|
|
94
|
+
JavaScript consumers use the compiled JavaScript. TypeScript consumers use the same imports and automatically receive declarations.
|
|
213
95
|
|
|
214
|
-
|
|
215
|
-
require('@pofsis-nbt/pofsis-auth/style.css')
|
|
216
|
-
```
|
|
96
|
+
## Development
|
|
217
97
|
|
|
218
|
-
|
|
98
|
+
Requires Node `^20.19.0` or `>=22.12.0`.
|
|
219
99
|
|
|
220
100
|
```bash
|
|
101
|
+
npm install
|
|
102
|
+
npm run format:check
|
|
221
103
|
npm run typecheck
|
|
222
104
|
npm test
|
|
223
105
|
npm run build
|
|
224
106
|
npm run pack:check
|
|
225
107
|
```
|
|
226
108
|
|
|
227
|
-
|
|
109
|
+
Build output is written to `dist/` with ESM (`index.js`), CommonJS (`index.cjs`), source maps, declarations, and `style.css`.
|
|
110
|
+
|
|
111
|
+
## Migration
|
|
228
112
|
|
|
229
|
-
|
|
113
|
+
When migrating from `@pofsis/auth-react`:
|
|
230
114
|
|
|
231
|
-
1.
|
|
232
|
-
2.
|
|
233
|
-
3.
|
|
234
|
-
4. Remove Vite dependency-prebundle workarounds used for the source-only package.
|
|
115
|
+
1. Change imports to `@pofsis-nbt/pofsis-auth`.
|
|
116
|
+
2. Pass `appName`, `apiBaseUrl`, and `authUrl` to `PofsisAuth`.
|
|
117
|
+
3. Import `@pofsis-nbt/pofsis-auth/style.css` once.
|
|
235
118
|
|
|
236
|
-
|
|
119
|
+
Do not import `src/`, `dist/` internals, or internal auth helpers. Only the package-root exports and `style.css` are supported.
|
package/dist/PofsisAuth.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import type { PofsisAuthProps } from './types';
|
|
|
3
3
|
* Single integration surface for tool apps.
|
|
4
4
|
* Handles session restore, PKCE login, and fixed paths `/login`, `/auth/callback`, `/auth/error`.
|
|
5
5
|
*/
|
|
6
|
-
export declare function PofsisAuth({ children, appName, apiBaseUrl, authUrl,
|
|
6
|
+
export declare function PofsisAuth({ children, appName, apiBaseUrl, authUrl, scope, postLoginPath, components, }: PofsisAuthProps): import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=PofsisAuth.d.ts.map
|
package/dist/PofsisAuth.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,KAAK,EACL,aAAmB,EACnB,UAAU,GACb,EAAE,eAAe,+BA4BjB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AuthLaunchOptions, AuthMethod, AuthScreen } from '../types';
|
|
2
|
-
export declare function normalizeAuthLaunchOptions(value
|
|
2
|
+
export declare function normalizeAuthLaunchOptions(value?: AuthLaunchOptions | string | null, defaultScreen?: AuthScreen): {
|
|
3
3
|
returnUrl: string | undefined;
|
|
4
4
|
screen: AuthScreen;
|
|
5
5
|
loginHint: string | undefined;
|
|
@@ -1 +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,
|
|
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,CACtC,KAAK,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,EACzC,aAAa,GAAE,UAAoB;;;;;EAqBtC;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,UAsBA"}
|
package/dist/auth/config.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { PofsisAuthConfig } from '../types';
|
|
2
|
-
export type ConfigOverrides = Partial<PofsisAuthConfig
|
|
2
|
+
export type ConfigOverrides = Omit<Partial<PofsisAuthConfig>, 'scope'> & {
|
|
3
|
+
scope?: string;
|
|
4
|
+
};
|
|
3
5
|
/**
|
|
4
|
-
* Validate and normalize
|
|
6
|
+
* Validate and normalize explicitly supplied runtime configuration.
|
|
5
7
|
*/
|
|
6
8
|
export declare function resolveConfig(overrides?: ConfigOverrides): PofsisAuthConfig;
|
|
7
9
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +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;
|
|
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,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3F;;GAEG;AACH,wBAAgB,aAAa,CAAC,SAAS,GAAE,eAAoB,GAAG,gBAAgB,CAuB/E"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { AuthComponentOverrides } from '../types';
|
|
3
|
-
|
|
3
|
+
export declare function AuthPathShell({ children, components, postLoginPath, returnPathKey, }: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
components: Required<AuthComponentOverrides>;
|
|
6
6
|
postLoginPath: string;
|
|
7
7
|
returnPathKey: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function AuthPathShell({ children, components, postLoginPath, returnPathKey, }: AuthPathShellProps): import("react").JSX.Element | null;
|
|
10
|
-
export {};
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
11
9
|
//# sourceMappingURL=AuthPathShell.d.ts.map
|
|
@@ -1 +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;
|
|
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;AA6DxE,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,UAAU,EACV,aAAa,EACb,aAAa,GAChB,EAAE;IACC,QAAQ,EAAE,SAAS,CAAA;IACnB,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAA;IAC5C,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACxB,sCAqBA"}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"RequireAuth.d.ts","sourceRoot":"","sources":["../../src/components/RequireAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAI7D,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/context/useAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/context/useAuth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,wBAAgB,OAAO,IAAI,gBAAgB,CAI1C"}
|