@snokam/auth 6.1.15 → 6.2.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.2.0](https://github.com/snokam/components/compare/%40snokam%2Fauth%406.1.16...%40snokam%2Fauth%406.2.0) (2026-11-12)
7
+
8
+ ### Features
9
+
10
+ - **native:** one bar, kept-alive tabs, back navigation and the web's icons in the app ([#3586](https://github.com/snokam/components/issues/3586)) ([1929ffc](https://github.com/snokam/components/commit/1929ffc44cfc1803134de665d6061cbd0b13f250))
11
+
12
+ ## [6.1.16](https://github.com/snokam/components/compare/%40snokam%2Fauth%406.1.15...%40snokam%2Fauth%406.1.16) (2026-11-11)
13
+
14
+ **Note:** Version bump only for package @snokam/auth
15
+
6
16
  ## [6.1.15](https://github.com/snokam/components/compare/%40snokam%2Fauth%406.1.14...%40snokam%2Fauth%406.1.15) (2026-11-11)
7
17
 
8
18
  **Note:** Version bump only for package @snokam/auth
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snokam/auth",
3
3
  "description": "Snøkam auth components",
4
- "version": "6.1.15",
4
+ "version": "6.2.0",
5
5
  "main": "src/index.ts",
6
6
  "sideEffects": false,
7
7
  "types": "src/index.ts",
@@ -28,10 +28,10 @@
28
28
  "path-to-regexp": "^9.0.0",
29
29
  "@snokam/api-client": "1.0.0",
30
30
  "@snokam/identity": "1.1.1",
31
- "@snokam/page-content": "6.9.23",
31
+ "@snokam/page-content": "6.10.1",
32
32
  "@snokam/react-query": "1.1.1",
33
- "@snokam/tenant": "4.5.7",
34
- "@snokam/ui": "7.7.0"
33
+ "@snokam/ui": "7.9.0",
34
+ "@snokam/tenant": "4.5.7"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "next": "16.4.5",
@@ -1,4 +1,5 @@
1
1
  import { match } from "path-to-regexp";
2
+ import { isAlwaysPublic } from "./public-paths";
2
3
  import { getToken } from "next-auth/jwt";
3
4
  import { type NextRequestWithAuth } from "next-auth/middleware";
4
5
  import { NextResponse, NextFetchEvent } from "next/server";
@@ -23,17 +24,11 @@ function withoutImpersonation(
23
24
  return response;
24
25
  }
25
26
 
26
- const LOGIN_FLOW_PATHS = [
27
- "/auth/",
28
- "/handoff/",
29
- "/api/password/",
30
- "/api/impersonation/adopt",
31
- ];
32
-
33
27
  export function buildAuthMiddleware({
34
28
  matcher = [],
35
29
  callbacks = {},
36
30
  protectAllRoutes,
31
+ publicPaths: appPublicPaths = [],
37
32
  cors = {},
38
33
  ...rest
39
34
  }: Auth.Middleware.Props = {}): Auth.Middleware.Builder {
@@ -43,15 +38,7 @@ export function buildAuthMiddleware({
43
38
  const { name } = getSessionCookieSettings(getAuthUrl());
44
39
 
45
40
  const shouldProtectPath = (pathname: string): boolean => {
46
- if (pathname.startsWith("/api/healthy")) {
47
- return false;
48
- }
49
-
50
- if (pathname.startsWith("/api/ready")) {
51
- return false;
52
- }
53
-
54
- if (LOGIN_FLOW_PATHS.some((path) => pathname.startsWith(path))) {
41
+ if (isAlwaysPublic(pathname, appPublicPaths)) {
55
42
  return false;
56
43
  }
57
44
 
@@ -0,0 +1,31 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import { isAlwaysPublic } from "./public-paths.ts";
4
+
5
+ describe("paths that never need a login", () => {
6
+ it("include health probes and the login flow", () => {
7
+ for (const path of [
8
+ "/api/healthy",
9
+ "/api/ready",
10
+ "/auth/login",
11
+ "/handoff/start",
12
+ "/api/password/login",
13
+ "/api/impersonation/adopt",
14
+ ]) {
15
+ assert.equal(isAlwaysPublic(path), true, path);
16
+ }
17
+ });
18
+
19
+ it("include the paths an app declares public, exactly", () => {
20
+ const appPaths = ["/api/menu", "/api/push/config"];
21
+ assert.equal(isAlwaysPublic("/api/menu", appPaths), true);
22
+ assert.equal(isAlwaysPublic("/api/push/config", appPaths), true);
23
+ assert.equal(isAlwaysPublic("/api/menu/admin", appPaths), false);
24
+ assert.equal(isAlwaysPublic("/oppgaver", appPaths), false);
25
+ });
26
+
27
+ it("exclude everything else", () => {
28
+ assert.equal(isAlwaysPublic("/api/menu"), false);
29
+ assert.equal(isAlwaysPublic("/"), false);
30
+ });
31
+ });
@@ -0,0 +1,17 @@
1
+ const PROBES = ["/api/healthy", "/api/ready"];
2
+
3
+ const LOGIN_FLOW_PATHS = [
4
+ "/auth/",
5
+ "/handoff/",
6
+ "/api/password/",
7
+ "/api/impersonation/adopt",
8
+ ];
9
+
10
+ export function isAlwaysPublic(
11
+ pathname: string,
12
+ appPublicPaths: readonly string[] = []
13
+ ): boolean {
14
+ if (PROBES.some((path) => pathname.startsWith(path))) return true;
15
+ if (LOGIN_FLOW_PATHS.some((path) => pathname.startsWith(path))) return true;
16
+ return appPublicPaths.includes(pathname);
17
+ }
package/src/types.ts CHANGED
@@ -45,6 +45,7 @@ export namespace Auth {
45
45
  matcher?: string[];
46
46
  callbacks?: NextAuthMiddlewareOptions["callbacks"];
47
47
  protectAllRoutes?: boolean;
48
+ publicPaths?: string[];
48
49
  cors?: CorsOptions;
49
50
  }
50
51
  }