@eventuras/fides-auth 0.4.0 → 0.5.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.
- package/README.md +40 -0
- package/dist/build-nL2--iMi.js +1014 -0
- package/dist/oauth.d.ts +29 -2
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +69 -56
- package/dist/providers/vipps/index.js +10 -10
- package/dist/silent-login.js +1 -1
- package/package.json +1 -1
- package/dist/build-BnXr85C9.js +0 -977
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Framework-agnostic OAuth 2.0 / OpenID Connect library with PKCE, encrypted sessi
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **OAuth 2.0 + OIDC** — Authorization Code with PKCE, token refresh, client credentials
|
|
8
|
+
- **Pushed Authorization Requests** — Opt-in RFC 9126 support (`usePar`) when the provider advertises it
|
|
8
9
|
- **Dual environment** — Node.js (`openid-client`) and browser (Web Crypto) entry points
|
|
9
10
|
- **Encrypted sessions** — AES-256-GCM encrypted JWTs for secure session storage
|
|
10
11
|
- **Rate limiting** — Generic token-bucket algorithm, ready for login protection
|
|
@@ -123,6 +124,8 @@ Full OIDC flows using `openid-client`:
|
|
|
123
124
|
import {
|
|
124
125
|
buildPKCEOptions,
|
|
125
126
|
buildAuthorizationUrl,
|
|
127
|
+
buildAuthorizationUrlWithPAR,
|
|
128
|
+
discoverAndBuildAuthorizationUrl,
|
|
126
129
|
exchangeAuthorizationCode,
|
|
127
130
|
refreshAccessToken,
|
|
128
131
|
extractUserFromTokens,
|
|
@@ -133,6 +136,43 @@ import {
|
|
|
133
136
|
} from "@eventuras/fides-auth/oauth";
|
|
134
137
|
```
|
|
135
138
|
|
|
139
|
+
#### Pushed Authorization Requests (PAR, RFC 9126)
|
|
140
|
+
|
|
141
|
+
Opt in by setting `usePar: true` on your `OAuthConfig`. The convenience
|
|
142
|
+
helper `discoverAndBuildAuthorizationUrl` then posts the authorization
|
|
143
|
+
parameters to the provider's PAR endpoint and returns a URL containing
|
|
144
|
+
only `client_id` and `request_uri`:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const oauthConfig = {
|
|
148
|
+
issuer: "https://auth.example.com",
|
|
149
|
+
clientId: "your-client-id",
|
|
150
|
+
clientSecret: "your-client-secret",
|
|
151
|
+
redirect_uri: "https://app.example.com/callback",
|
|
152
|
+
scope: "openid profile email offline_access",
|
|
153
|
+
usePar: true,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const pkce = await buildPKCEOptions(oauthConfig);
|
|
157
|
+
const authUrl = await discoverAndBuildAuthorizationUrl(oauthConfig, pkce);
|
|
158
|
+
// redirect user to authUrl
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Behaviour:
|
|
162
|
+
|
|
163
|
+
- `usePar: true` + provider advertises `pushed_authorization_request_endpoint` → uses PAR.
|
|
164
|
+
- `usePar: true` + provider does **not** advertise PAR → throws.
|
|
165
|
+
- `usePar` unset/false + provider advertises PAR → standard flow, with a
|
|
166
|
+
one-line `info` log noting that PAR is available but not enabled.
|
|
167
|
+
- `usePar` unset/false + no PAR endpoint → standard flow, no advisory.
|
|
168
|
+
|
|
169
|
+
If you already have a discovered `Configuration` you can call the
|
|
170
|
+
low-level wrapper directly:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const authUrl = await buildAuthorizationUrlWithPAR(config, pkce);
|
|
174
|
+
```
|
|
175
|
+
|
|
136
176
|
### OAuth — Browser (`/oauth-browser`)
|
|
137
177
|
|
|
138
178
|
Lightweight browser-only flows using Web Crypto:
|