@pofsis-nbt/pofsis-auth 2.0.0 → 2.0.1

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 CHANGED
@@ -6,6 +6,10 @@ The repository also includes an interactive [POFSIS Auth documentation portal](.
6
6
 
7
7
  The [popup integration guide](./docs/popup-integration.md) is the canonical consumer reference for framework-neutral, React, and Web Component popup launches.
8
8
 
9
+ Use the [application-ID consumer migration guide](./docs/application-id-consumer-migration.md) to
10
+ upgrade existing tools from application names/codes and the vendored React package to v2 UUID
11
+ discovery, including environment configuration, protected-route changes, and consumer testing.
12
+
9
13
  ## Integration process
10
14
 
11
15
  1. Install `@pofsis-nbt/pofsis-auth` with its React, React DOM, and optional Axios peers.
package/README.md CHANGED
@@ -6,6 +6,9 @@ For guided setup and authentication scenarios, open the repository's interactive
6
6
 
7
7
  For hosted popup setup, parameters, callback handling, React usage, and the optional Web Component, see the [popup integration guide](./docs/popup-integration.md).
8
8
 
9
+ For migrating an existing POFSIS tool from application code/name discovery to immutable application
10
+ UUIDs, follow the [application-ID consumer migration guide](./docs/application-id-consumer-migration.md).
11
+
9
12
  ## Install
10
13
 
11
14
  ```bash
@@ -0,0 +1,180 @@
1
+ # Application-ID Integration Update
2
+
3
+ This guide covers only the frontend integration changes required to migrate an existing POFSIS tool
4
+ from the legacy `@pofsis/auth-react` package and application-name configuration to
5
+ `@pofsis-nbt/pofsis-auth` v2 and an immutable application UUID.
6
+
7
+ ## Required values
8
+
9
+ Obtain the correct `applications.id` UUID for each environment from the Auth application registry.
10
+ Do not reuse a development UUID in staging or production unless that environment has been verified
11
+ to use the same registration.
12
+
13
+ For Vite applications, configure:
14
+
15
+ ```env
16
+ VITE_POFSIS_APPLICATION_ID=<APPLICATION_UUID>
17
+ VITE_POFSIS_API_BASE_URL=https://dev-auth.pofsis.com/api
18
+ VITE_POFSIS_AUTH_URL=https://dev-auth.pofsis.com/authorize
19
+ VITE_POFSIS_SCOPE=openid profile email
20
+ ```
21
+
22
+ Remove:
23
+
24
+ ```env
25
+ VITE_POFSIS_APP_NAME=<LEGACY_APPLICATION_NAME>
26
+ ```
27
+
28
+ The application UUID is a public identifier, not a secret. Do not add `client_id`, redirect URI, or
29
+ logout URI to the frontend environment. The library discovers those values through Auth BE using
30
+ the UUID and the browser's exact origin.
31
+
32
+ ## Upgrade the package
33
+
34
+ Remove the old dependency:
35
+
36
+ ```powershell
37
+ npm uninstall @pofsis/auth-react
38
+ ```
39
+
40
+ Install v2:
41
+
42
+ ```powershell
43
+ npm install @pofsis-nbt/pofsis-auth@^2.0.0
44
+ ```
45
+
46
+ If the old package was vendored under `packages/pofsis-auth-react`, delete that directory after all
47
+ imports have been replaced. Remove any Vite `optimizeDeps.exclude` entry that existed only for the
48
+ vendored package.
49
+
50
+ Replace imports throughout the tool:
51
+
52
+ ```diff
53
+ - import { PofsisAuth, RequireAuth, useAuth } from '@pofsis/auth-react'
54
+ + import { PofsisAuth, RequireAuth, useAuth } from '@pofsis-nbt/pofsis-auth'
55
+ ```
56
+
57
+ Import the v2 stylesheet exactly once in the application entry point:
58
+
59
+ ```js
60
+ import '@pofsis-nbt/pofsis-auth/style.css'
61
+ ```
62
+
63
+ Check for remaining legacy references:
64
+
65
+ ```powershell
66
+ rg "@pofsis/auth-react|VITE_POFSIS_APP_NAME|appName|\?app=" src .envs package.json vite.config.*
67
+ ```
68
+
69
+ ## Configure the React provider
70
+
71
+ The library does not read environment variables directly. The consuming application must pass its
72
+ configuration to `PofsisAuth`:
73
+
74
+ ```jsx
75
+ import { PofsisAuth } from '@pofsis-nbt/pofsis-auth'
76
+
77
+ <PofsisAuth
78
+ applicationId={import.meta.env.VITE_POFSIS_APPLICATION_ID}
79
+ apiBaseUrl={import.meta.env.VITE_POFSIS_API_BASE_URL}
80
+ authUrl={import.meta.env.VITE_POFSIS_AUTH_URL}
81
+ scope={import.meta.env.VITE_POFSIS_SCOPE}
82
+ callbackPath="/auth/callback"
83
+ postLoginPath="/"
84
+ >
85
+ <App />
86
+ </PofsisAuth>
87
+ ```
88
+
89
+ `applicationId`, `apiBaseUrl`, and `authUrl` are required. Missing values fail during configuration
90
+ instead of silently selecting another application.
91
+
92
+ ## Update protected routes
93
+
94
+ The v2 `RequireAuth` contract is:
95
+
96
+ ```text
97
+ RequireAuth({ children, fallback?, onUnauthenticated? })
98
+ ```
99
+
100
+ Legacy `mode` and `returnTo` props are not supported. The basic integration is:
101
+
102
+ ```jsx
103
+ import { RequireAuth } from '@pofsis-nbt/pofsis-auth'
104
+
105
+ function ProtectedRoute({ children }) {
106
+ return (
107
+ <RequireAuth fallback={<LoadingScreen />}>
108
+ {children}
109
+ </RequireAuth>
110
+ )
111
+ }
112
+ ```
113
+
114
+ Without `onUnauthenticated`, `RequireAuth` starts its default redirect login. A tool that requires
115
+ different unauthenticated behavior can provide its own `onUnauthenticated` callback based on that
116
+ tool's product flow; this guide does not prescribe login, signup, popup, or return-path behavior.
117
+
118
+ ## Keep protected API calls connected
119
+
120
+ The Axios interceptor signature is unchanged:
121
+
122
+ ```js
123
+ import { attachAuthInterceptor } from '@pofsis-nbt/pofsis-auth'
124
+
125
+ attachAuthInterceptor(apiClient, auth.getAccessToken, auth.refreshSession)
126
+ ```
127
+
128
+ Attach it only once per Axios client. If it is attached from a component, retain and call the
129
+ returned cleanup function when that component unmounts.
130
+
131
+ ## Framework-neutral integration
132
+
133
+ Non-React applications can use the core client:
134
+
135
+ ```js
136
+ import { createPofsisAuth } from '@pofsis-nbt/pofsis-auth/core'
137
+
138
+ const auth = createPofsisAuth({
139
+ applicationId: runtimeConfig.applicationId,
140
+ apiBaseUrl: runtimeConfig.apiBaseUrl,
141
+ authUrl: runtimeConfig.authUrl,
142
+ scope: 'openid profile email',
143
+ callbackPath: '/auth/callback',
144
+ })
145
+ ```
146
+
147
+ ## Consumer validation
148
+
149
+ Run the tool's standard checks:
150
+
151
+ ```powershell
152
+ npm install
153
+ npm run test
154
+ npm run lint
155
+ npm run format:check
156
+ npm run build
157
+ ```
158
+
159
+ Run browser or E2E tests when available. Confirm that:
160
+
161
+ - Client discovery uses the configured application UUID and current browser origin.
162
+ - The generated authorization URL contains `client_id`, `state`, and PKCE fields.
163
+ - The authorization URL does not contain `app`, an application name/code, or `application_id`.
164
+ - The tool's existing authentication entry behavior remains correct for its product flow.
165
+ - `/auth/callback` returns to the requested safe local route.
166
+ - Refresh, logout, profile editing, and protected API calls still work.
167
+ - Invalid UUIDs and origins show an application error and do not start authentication.
168
+
169
+ ## Per-environment integration checklist
170
+
171
+ - [ ] Confirm the environment-specific application UUID with the Auth owner.
172
+ - [ ] Replace the old package and all imports.
173
+ - [ ] Remove the vendored package and Vite exclusion.
174
+ - [ ] Replace `VITE_POFSIS_APP_NAME` with `VITE_POFSIS_APPLICATION_ID`.
175
+ - [ ] Pass explicit provider configuration.
176
+ - [ ] Update protected routes that used legacy `mode` or `returnTo` props.
177
+ - [ ] Import the package stylesheet once.
178
+ - [ ] Run unit, lint, formatting, build, and E2E checks.
179
+ - [ ] Smoke-test login, signup, callback, refresh, logout, and protected API calls.
180
+ - [ ] Repeat separately for development, staging, and production.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pofsis-nbt/pofsis-auth",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "POFSIS OAuth/PKCE authentication SDK for browser applications.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",