@authowl/next 0.2.26 → 0.3.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 CHANGED
@@ -84,6 +84,12 @@ honor project branding or an explicit `appearance.primaryColor` override.
84
84
  presence — it is a UX helper, **not** an authorization boundary. Always authorize
85
85
  on the server with `auth()`, which re-validates against the auth service.
86
86
 
87
+ For bearer-token route handlers, `@authowl/next/server` also re-exports
88
+ `requireAuth`, `requirePermission`, `requireGrant`, and `requireOrg`. They throw
89
+ a typed `AuthorizationError` with status 401 or 403 and never replace your own
90
+ tenant-scope and resource-ownership checks. Cookie-backed pages and route
91
+ handlers should continue to use `auth()`.
92
+
87
93
  See the [complete Next.js guide](https://authowl.dev/docs/sdks/next) for provider
88
94
  setup, server authorization, middleware boundaries, and environment variables.
89
95
 
@@ -38,7 +38,17 @@ function appSessionCookieNames(projectId) {
38
38
  }
39
39
 
40
40
  // src/middleware.ts
41
+ var warnedNotAnAuthorizationBoundary = false;
42
+ function warnNotAnAuthorizationBoundary() {
43
+ if (warnedNotAnAuthorizationBoundary) return;
44
+ if (process.env.NODE_ENV === "production") return;
45
+ warnedNotAnAuthorizationBoundary = true;
46
+ console.warn(
47
+ "[authowl] createAuthRedirectMiddleware is a UX redirect, not authorization. It checks that a cookie NAME is present and verifies nothing, so a client can forge it. Gate pages and route handlers with auth(); gate token-bearing API routes with requireAuth() or requirePermission() from @authowl/core/server. This warning is development-only and appears once."
48
+ );
49
+ }
41
50
  function createAuthRedirectMiddleware(opts) {
51
+ warnNotAnAuthorizationBoundary();
42
52
  const { projectId } = (0, import_core.decodePublishableKey)(opts.publishableKey);
43
53
  const bridgeNames = appSessionCookieNames(projectId);
44
54
  const cookieNames = [
@@ -6,7 +6,17 @@ import {
6
6
  import { NextResponse } from "next/server";
7
7
  import { decodePublishableKey } from "@authowl/core";
8
8
  import { sessionCookieName } from "@authowl/core/server";
9
+ var warnedNotAnAuthorizationBoundary = false;
10
+ function warnNotAnAuthorizationBoundary() {
11
+ if (warnedNotAnAuthorizationBoundary) return;
12
+ if (process.env.NODE_ENV === "production") return;
13
+ warnedNotAnAuthorizationBoundary = true;
14
+ console.warn(
15
+ "[authowl] createAuthRedirectMiddleware is a UX redirect, not authorization. It checks that a cookie NAME is present and verifies nothing, so a client can forge it. Gate pages and route handlers with auth(); gate token-bearing API routes with requireAuth() or requirePermission() from @authowl/core/server. This warning is development-only and appears once."
16
+ );
17
+ }
9
18
  function createAuthRedirectMiddleware(opts) {
19
+ warnNotAnAuthorizationBoundary();
10
20
  const { projectId } = decodePublishableKey(opts.publishableKey);
11
21
  const bridgeNames = appSessionCookieNames(projectId);
12
22
  const cookieNames = [
package/dist/server.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var server_exports = {};
22
22
  __export(server_exports, {
23
23
  AuthServiceError: () => AuthServiceError,
24
+ AuthorizationError: () => import_server5.AuthorizationError,
24
25
  TokenVerificationError: () => import_server4.TokenVerificationError,
25
26
  auth: () => auth,
26
27
  createAuthOwlSessionBridge: () => createAuthOwlSessionBridge,
@@ -28,6 +29,11 @@ __export(server_exports, {
28
29
  hasAuthOwlSessionCookie: () => hasAuthOwlSessionCookie,
29
30
  hasPermission: () => import_server4.hasPermission,
30
31
  initAuth: () => initAuth,
32
+ isAuthorizationError: () => import_server5.isAuthorizationError,
33
+ requireAuth: () => import_server5.requireAuth,
34
+ requireGrant: () => import_server5.requireGrant,
35
+ requireOrg: () => import_server5.requireOrg,
36
+ requirePermission: () => import_server5.requirePermission,
31
37
  verifyToken: () => import_server4.verifyToken
32
38
  });
33
39
  module.exports = __toCommonJS(server_exports);
@@ -203,6 +209,7 @@ function createAuthOwlSessionBridge(input) {
203
209
 
204
210
  // src/server.ts
205
211
  var import_server4 = require("@authowl/core/server");
212
+ var import_server5 = require("@authowl/core/server");
206
213
  var AUTH_FETCH_TIMEOUT_MS2 = 1e4;
207
214
  var AuthServiceError = class extends Error {
208
215
  status;
@@ -289,6 +296,7 @@ async function hasAuthOwlSessionCookie() {
289
296
  // Annotate the CommonJS export names for ESM import in node:
290
297
  0 && (module.exports = {
291
298
  AuthServiceError,
299
+ AuthorizationError,
292
300
  TokenVerificationError,
293
301
  auth,
294
302
  createAuthOwlSessionBridge,
@@ -296,5 +304,10 @@ async function hasAuthOwlSessionCookie() {
296
304
  hasAuthOwlSessionCookie,
297
305
  hasPermission,
298
306
  initAuth,
307
+ isAuthorizationError,
308
+ requireAuth,
309
+ requireGrant,
310
+ requireOrg,
311
+ requirePermission,
299
312
  verifyToken
300
313
  });
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AuthConfig } from '@authowl/core/server';
2
- export { HasParams, OrganizationMembership, TokenVerificationError, VerifiedProjectToken, VerifyTokenConfig, has, hasPermission, verifyToken } from '@authowl/core/server';
2
+ export { AuthorizationError, AuthorizationFailureReason, HasParams, OrganizationMembership, TokenVerificationError, VerifiedProjectToken, VerifyTokenConfig, has, hasPermission, isAuthorizationError, requireAuth, requireGrant, requireOrg, requirePermission, verifyToken } from '@authowl/core/server';
3
3
 
4
4
  type AuthOwlSessionBridgeOptions = AuthConfig;
5
5
  /**
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AuthConfig } from '@authowl/core/server';
2
- export { HasParams, OrganizationMembership, TokenVerificationError, VerifiedProjectToken, VerifyTokenConfig, has, hasPermission, verifyToken } from '@authowl/core/server';
2
+ export { AuthorizationError, AuthorizationFailureReason, HasParams, OrganizationMembership, TokenVerificationError, VerifiedProjectToken, VerifyTokenConfig, has, hasPermission, isAuthorizationError, requireAuth, requireGrant, requireOrg, requirePermission, verifyToken } from '@authowl/core/server';
3
3
 
4
4
  type AuthOwlSessionBridgeOptions = AuthConfig;
5
5
  /**
package/dist/server.js CHANGED
@@ -178,6 +178,14 @@ import {
178
178
  verifyToken,
179
179
  TokenVerificationError
180
180
  } from "@authowl/core/server";
181
+ import {
182
+ requireAuth,
183
+ requireGrant,
184
+ requireOrg,
185
+ requirePermission,
186
+ isAuthorizationError,
187
+ AuthorizationError
188
+ } from "@authowl/core/server";
181
189
  var AUTH_FETCH_TIMEOUT_MS2 = 1e4;
182
190
  var AuthServiceError = class extends Error {
183
191
  status;
@@ -263,6 +271,7 @@ async function hasAuthOwlSessionCookie() {
263
271
  }
264
272
  export {
265
273
  AuthServiceError,
274
+ AuthorizationError,
266
275
  TokenVerificationError,
267
276
  auth,
268
277
  createAuthOwlSessionBridge,
@@ -270,5 +279,10 @@ export {
270
279
  hasAuthOwlSessionCookie,
271
280
  hasPermission,
272
281
  initAuth,
282
+ isAuthorizationError,
283
+ requireAuth,
284
+ requireGrant,
285
+ requireOrg,
286
+ requirePermission,
273
287
  verifyToken
274
288
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authowl/next",
3
- "version": "0.2.26",
3
+ "version": "0.3.0",
4
4
  "description": "Next.js (App Router) server helpers for AuthOwl, the multi-tenant auth SaaS.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -61,7 +61,7 @@
61
61
  "LICENSE"
62
62
  ],
63
63
  "dependencies": {
64
- "@authowl/core": "0.21.0"
64
+ "@authowl/core": "0.22.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "next": ">=14"