@wtfalch/auth 0.11.0 → 0.11.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.
Files changed (2) hide show
  1. package/dist/auth.js +21 -10
  2. package/package.json +1 -1
package/dist/auth.js CHANGED
@@ -175,11 +175,21 @@ export function createAuth(input) {
175
175
  /**
176
176
  * Where a sign-out lands: the issuer's own logout, so its session ends and
177
177
  * the next sign-in asks who again, rather than straight back to
178
- * `afterLogout`. What this function can see fail -- no id token to hint
179
- * with, no `end_session_endpoint` published, the issuer not answering --
180
- * falls back to the plain redirect a sign-out has always ended with.
181
- * Losing the issuer's co-operation is never a reason to fail somebody's
182
- * sign-out.
178
+ * `afterLogout`. What this function can see fail -- no `end_session_endpoint`
179
+ * published, the issuer not answering -- falls back to the plain redirect a
180
+ * sign-out has always ended with. Losing the issuer's co-operation is never
181
+ * a reason to fail somebody's sign-out.
182
+ *
183
+ * Having no id token is the one failure that does not fall back, because the
184
+ * plain redirect leaves the issuer's session standing and the next sign-in is
185
+ * silent. `end_session` cannot rescue it either: without a hint the issuer
186
+ * takes its v1 branch and ends v1 user-agent sessions, of which a v2 sign-in
187
+ * has none. Routing a hint-less `end_session` to the hosted login instead
188
+ * needs the instance's `loginV2.required`, which overrides every app's own
189
+ * `loginVersion.loginV2.baseUri` with the instance's -- and each app here
190
+ * hosts its own sign-in at `/auth`, so that flag is not available to us.
191
+ * The hosted login's `/logout` sits at the issuer's origin, where
192
+ * `scripts/provision.mjs` points the instance's `loginV2.baseUri`.
183
193
  *
184
194
  * `afterLogout` not being a registered `post_logout_redirect_uri` is a
185
195
  * failure this function cannot see: that request reaches the issuer, which
@@ -191,11 +201,12 @@ export function createAuth(input) {
191
201
  */
192
202
  const endIssuerSession = async (idToken, cookies) => {
193
203
  const afterLogout = new URL(options().afterLogout, options().appUrl).href;
194
- const target = idToken
195
- ? await oidc()
196
- .endSessionUrl(idToken, afterLogout)
197
- .catch(() => null)
198
- : null;
204
+ if (!idToken) {
205
+ return redirect(new URL('/logout', options().issuer).href, cookies, 303);
206
+ }
207
+ const target = await oidc()
208
+ .endSessionUrl(idToken, afterLogout)
209
+ .catch(() => null);
199
210
  return redirect(target?.href ?? afterLogout, cookies, 303);
200
211
  };
201
212
  const logout = async (request) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/auth",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Sign in against auth.wtfalch.dev: a server session for a Next.js app, and a browser client with silent single sign-on across subdomains.",
5
5
  "repository": {
6
6
  "type": "git",