@pontive/pontkit-nextjs 1.3.0 → 1.4.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.
@@ -26,3 +26,5 @@ export type { AuthProxyRewritesOptions, NextRewrite } from './next';
26
26
  export { DEFAULT_BASE_PATH, DEFAULT_FORWARDED_PATHS } from '@pontive/pontkit-loader/proxy';
27
27
  export { pontiveAuth } from './auth';
28
28
  export type { MiddlewareDecision, PontiveAuth, ServerAuthConfig, Session, SessionUser } from './auth';
29
+ export { ORGANIZATION_ERROR_PARAM, switchOrganizationPath } from '@pontive/pontkit-server';
30
+ export type { Organization } from '@pontive/pontkit-server';
package/dist/server.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var w=Object.create;var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var P=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of m(e))!T.call(t,a)&&a!==o&&u(t,a,{get:()=>e[a],enumerable:!(n=g(e,a))||n.enumerable});return t};var f=(t,e,o)=>(o=t!=null?w(A(t)):{},P(e||!t||!t.__esModule?u(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@pontive/pontkit-loader/proxy"),y=require("@pontive/pontkit-server"),l=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade"];function x(t){const e=new Headers(t.headers);for(const n of l)e.delete(n);e.delete("host"),e.delete("content-length"),e.delete("accept-encoding");const o=new URL(t.url);return e.has("x-forwarded-proto")||e.set("x-forwarded-proto",o.protocol.replace(":","")),e.has("x-forwarded-host")||e.set("x-forwarded-host",o.host),e.set("x-forwarded-for",E(t)),e}function E(t){const e=t.headers.get("x-forwarded-for"),o=t.headers.get("x-real-ip");return e||(o??"")}function R(t){const e=new Headers;t.headers.forEach((o,n)=>{n.toLowerCase()!=="set-cookie"&&e.set(n,o)});for(const o of l)e.delete(o);e.delete("content-encoding"),e.delete("content-length");for(const o of H(t.headers))e.append("set-cookie",o);return e}function H(t){if(typeof t.getSetCookie=="function")return t.getSetCookie();const e=t.get("set-cookie");return e?[e]:[]}function k(t){const e=s.authOrigin(t.authHost),o=s.normaliseBasePath(t.basePath??s.DEFAULT_BASE_PATH),n=t.paths??s.DEFAULT_FORWARDED_PATHS,a=t.fetch??globalThis.fetch;function d(r){const c=new URL(r.url);if(!s.isUnder(c.pathname,o))return null;const h=c.pathname.slice(o.length)||"/",i=new URL(`${h}${c.search}`,e);return i.origin!==e?null:n.some(p=>s.isUnder(i.pathname,p))?i:null}return{basePath:o,origin:e,matcher:n.map(r=>`${o}${r}/:path*`),handles(r){return d(r)!==null},async forward(r){const c=d(r);if(!c)return new Response("Not Found",{status:404});const h=r.method==="GET"||r.method==="HEAD"?void 0:r.body;try{const i=await a(c,{method:r.method,headers:x(r),body:h,redirect:"manual",...h?{duplex:"half"}:{}});return new Response(i.body,{status:i.status,statusText:i.statusText,headers:R(i)})}catch(i){return console.warn(`Could not reach the auth server at ${e}:`,i),new Response("Bad Gateway",{status:502})}}}}function S(t){const e=s.authOrigin(t.authHost),o=s.normaliseBasePath(t.basePath??s.DEFAULT_BASE_PATH);return(t.paths??s.DEFAULT_FORWARDED_PATHS).map(a=>({source:`${o}${a}/:path*`,destination:`${e}${a}/:path*`}))}function _(t){if(t.method!=="GET"||t.headers.get("rsc")||t.headers.get("next-router-prefetch"))return!1;const e=t.headers.get("sec-fetch-mode");return e?e==="navigate":(t.headers.get("accept")??"").includes("text/html")}function D(t,e){if(e.length===0)return t;let o=t;try{for(const n of e)o.headers.append("set-cookie",n);return o}catch{o=new Response(t.body,{status:t.status,statusText:t.statusText,headers:new Headers(t.headers)})}for(const n of e)o.headers.append("set-cookie",n);return o}function b(t){const e=y.createServerAuth(t),o=async n=>await e.handle(n)??new Response("Not found",{status:404});return{handlers:{GET:o,POST:o},async auth(){const{cookies:n}=await import("next/headers"),a=await n();return e.getSession(a.toString())},async middleware(n,a){const{NextResponse:d}=await import("next/server"),r=await e.refresh(n);if(r.handshake&&_(n))return new Response(null,{status:302,headers:{location:new URL(r.handshake,n.url).toString(),"cache-control":"no-store"}});let c=a?await a(r.session,n):void 0;if(!c){const h=new Headers(n.headers);h.set("cookie",r.cookieHeader),c=d.next({request:{headers:h}})}return D(c,r.setCookies)}}}Object.defineProperty(exports,"DEFAULT_BASE_PATH",{enumerable:!0,get:()=>s.DEFAULT_BASE_PATH});Object.defineProperty(exports,"DEFAULT_FORWARDED_PATHS",{enumerable:!0,get:()=>s.DEFAULT_FORWARDED_PATHS});exports.authProxyRewrites=S;exports.createAuthProxy=k;exports.pontiveAuth=b;
1
+ "use strict";var g=Object.create;var f=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var T=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of m(e))!R.call(t,a)&&a!==r&&f(t,a,{get:()=>e[a],enumerable:!(n=A(e,a))||n.enumerable});return t};var l=(t,e,r)=>(r=t!=null?g(P(t)):{},T(e||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@pontive/pontkit-loader/proxy"),u=require("@pontive/pontkit-server"),p=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade"];function y(t){const e=new Headers(t.headers);for(const n of p)e.delete(n);e.delete("host"),e.delete("content-length"),e.delete("accept-encoding");const r=new URL(t.url);return e.has("x-forwarded-proto")||e.set("x-forwarded-proto",r.protocol.replace(":","")),e.has("x-forwarded-host")||e.set("x-forwarded-host",r.host),e.set("x-forwarded-for",E(t)),e}function E(t){const e=t.headers.get("x-forwarded-for"),r=t.headers.get("x-real-ip");return e||(r??"")}function x(t){const e=new Headers;t.headers.forEach((r,n)=>{n.toLowerCase()!=="set-cookie"&&e.set(n,r)});for(const r of p)e.delete(r);e.delete("content-encoding"),e.delete("content-length");for(const r of O(t.headers))e.append("set-cookie",r);return e}function O(t){if(typeof t.getSetCookie=="function")return t.getSetCookie();const e=t.get("set-cookie");return e?[e]:[]}function _(t){const e=s.authOrigin(t.authHost),r=s.normaliseBasePath(t.basePath??s.DEFAULT_BASE_PATH),n=t.paths??s.DEFAULT_FORWARDED_PATHS,a=t.fetch??globalThis.fetch;function d(o){const c=new URL(o.url);if(!s.isUnder(c.pathname,r))return null;const h=c.pathname.slice(r.length)||"/",i=new URL(`${h}${c.search}`,e);return i.origin!==e?null:n.some(w=>s.isUnder(i.pathname,w))?i:null}return{basePath:r,origin:e,matcher:n.map(o=>`${r}${o}/:path*`),handles(o){return d(o)!==null},async forward(o){const c=d(o);if(!c)return new Response("Not Found",{status:404});const h=o.method==="GET"||o.method==="HEAD"?void 0:o.body;try{const i=await a(c,{method:o.method,headers:y(o),body:h,redirect:"manual",...h?{duplex:"half"}:{}});return new Response(i.body,{status:i.status,statusText:i.statusText,headers:x(i)})}catch(i){return console.warn(`Could not reach the auth server at ${e}:`,i),new Response("Bad Gateway",{status:502})}}}}function H(t){const e=s.authOrigin(t.authHost),r=s.normaliseBasePath(t.basePath??s.DEFAULT_BASE_PATH);return(t.paths??s.DEFAULT_FORWARDED_PATHS).map(a=>({source:`${r}${a}/:path*`,destination:`${e}${a}/:path*`}))}function b(t){if(t.method!=="GET"||t.headers.get("rsc")||t.headers.get("next-router-prefetch"))return!1;const e=t.headers.get("sec-fetch-mode");return e?e==="navigate":(t.headers.get("accept")??"").includes("text/html")}function k(t,e){if(e.length===0)return t;let r=t;try{for(const n of e)r.headers.append("set-cookie",n);return r}catch{r=new Response(t.body,{status:t.status,statusText:t.statusText,headers:new Headers(t.headers)})}for(const n of e)r.headers.append("set-cookie",n);return r}function S(t){const e=u.createServerAuth(t),r=async n=>await e.handle(n)??new Response("Not found",{status:404});return{handlers:{GET:r,POST:r},async auth(){const{cookies:n}=await import("next/headers"),a=await n();return e.getSession(a.toString())},async middleware(n,a){const{NextResponse:d}=await import("next/server"),o=await e.refresh(n);if(o.handshake&&b(n))return new Response(null,{status:302,headers:{location:new URL(o.handshake,n.url).toString(),"cache-control":"no-store"}});let c=a?await a(o.session,n):void 0;if(!c){const h=new Headers(n.headers);h.set("cookie",o.cookieHeader),c=d.next({request:{headers:h}})}return k(c,o.setCookies)}}}Object.defineProperty(exports,"DEFAULT_BASE_PATH",{enumerable:!0,get:()=>s.DEFAULT_BASE_PATH});Object.defineProperty(exports,"DEFAULT_FORWARDED_PATHS",{enumerable:!0,get:()=>s.DEFAULT_FORWARDED_PATHS});Object.defineProperty(exports,"ORGANIZATION_ERROR_PARAM",{enumerable:!0,get:()=>u.ORGANIZATION_ERROR_PARAM});Object.defineProperty(exports,"switchOrganizationPath",{enumerable:!0,get:()=>u.switchOrganizationPath});exports.authProxyRewrites=H;exports.createAuthProxy=_;exports.pontiveAuth=S;
2
2
  //# sourceMappingURL=server.cjs.map
package/dist/server.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { authOrigin as u, normaliseBasePath as f, DEFAULT_BASE_PATH as l, DEFAULT_FORWARDED_PATHS as p, isUnder as d } from "@pontive/pontkit-loader/proxy";
2
- import { DEFAULT_BASE_PATH as F, DEFAULT_FORWARDED_PATHS as L } from "@pontive/pontkit-loader/proxy";
2
+ import { DEFAULT_BASE_PATH as D, DEFAULT_FORWARDED_PATHS as F } from "@pontive/pontkit-loader/proxy";
3
3
  import { createServerAuth as g } from "@pontive/pontkit-server";
4
+ import { ORGANIZATION_ERROR_PARAM as U, switchOrganizationPath as $ } from "@pontive/pontkit-server";
4
5
  const w = [
5
6
  "connection",
6
7
  "keep-alive",
@@ -17,13 +18,13 @@ function x(t) {
17
18
  e.delete(n);
18
19
  e.delete("host"), e.delete("content-length"), e.delete("accept-encoding");
19
20
  const o = new URL(t.url);
20
- return e.has("x-forwarded-proto") || e.set("x-forwarded-proto", o.protocol.replace(":", "")), e.has("x-forwarded-host") || e.set("x-forwarded-host", o.host), e.set("x-forwarded-for", k(t)), e;
21
+ return e.has("x-forwarded-proto") || e.set("x-forwarded-proto", o.protocol.replace(":", "")), e.has("x-forwarded-host") || e.set("x-forwarded-host", o.host), e.set("x-forwarded-for", R(t)), e;
21
22
  }
22
- function k(t) {
23
+ function R(t) {
23
24
  const e = t.headers.get("x-forwarded-for"), o = t.headers.get("x-real-ip");
24
25
  return e || (o ?? "");
25
26
  }
26
- function T(t) {
27
+ function A(t) {
27
28
  const e = new Headers();
28
29
  t.headers.forEach((o, n) => {
29
30
  n.toLowerCase() !== "set-cookie" && e.set(n, o);
@@ -31,11 +32,11 @@ function T(t) {
31
32
  for (const o of w)
32
33
  e.delete(o);
33
34
  e.delete("content-encoding"), e.delete("content-length");
34
- for (const o of y(t.headers))
35
+ for (const o of T(t.headers))
35
36
  e.append("set-cookie", o);
36
37
  return e;
37
38
  }
38
- function y(t) {
39
+ function T(t) {
39
40
  if (typeof t.getSetCookie == "function")
40
41
  return t.getSetCookie();
41
42
  const e = t.get("set-cookie");
@@ -76,7 +77,7 @@ function E(t) {
76
77
  return new Response(s.body, {
77
78
  status: s.status,
78
79
  statusText: s.statusText,
79
- headers: T(s)
80
+ headers: A(s)
80
81
  });
81
82
  } catch (s) {
82
83
  return console.warn(`Could not reach the auth server at ${e}:`, s), new Response("Bad Gateway", { status: 502 });
@@ -84,19 +85,19 @@ function E(t) {
84
85
  }
85
86
  };
86
87
  }
87
- function S(t) {
88
+ function _(t) {
88
89
  const e = u(t.authHost), o = f(t.basePath ?? l);
89
90
  return (t.paths ?? p).map((c) => ({
90
91
  source: `${o}${c}/:path*`,
91
92
  destination: `${e}${c}/:path*`
92
93
  }));
93
94
  }
94
- function A(t) {
95
+ function k(t) {
95
96
  if (t.method !== "GET" || t.headers.get("rsc") || t.headers.get("next-router-prefetch")) return !1;
96
97
  const e = t.headers.get("sec-fetch-mode");
97
98
  return e ? e === "navigate" : (t.headers.get("accept") ?? "").includes("text/html");
98
99
  }
99
- function H(t, e) {
100
+ function P(t, e) {
100
101
  if (e.length === 0) return t;
101
102
  let o = t;
102
103
  try {
@@ -112,7 +113,7 @@ function H(t, e) {
112
113
  for (const n of e) o.headers.append("set-cookie", n);
113
114
  return o;
114
115
  }
115
- function _(t) {
116
+ function S(t) {
116
117
  const e = g(t), o = async (n) => await e.handle(n) ?? new Response("Not found", { status: 404 });
117
118
  return {
118
119
  handlers: { GET: o, POST: o },
@@ -122,7 +123,7 @@ function _(t) {
122
123
  },
123
124
  async middleware(n, c) {
124
125
  const { NextResponse: h } = await import("next/server"), r = await e.refresh(n);
125
- if (r.handshake && A(n))
126
+ if (r.handshake && k(n))
126
127
  return new Response(null, {
127
128
  status: 302,
128
129
  // Absolute: Next parses a middleware redirect's Location as a URL and
@@ -135,15 +136,17 @@ function _(t) {
135
136
  const i = new Headers(n.headers);
136
137
  i.set("cookie", r.cookieHeader), a = h.next({ request: { headers: i } });
137
138
  }
138
- return H(a, r.setCookies);
139
+ return P(a, r.setCookies);
139
140
  }
140
141
  };
141
142
  }
142
143
  export {
143
- F as DEFAULT_BASE_PATH,
144
- L as DEFAULT_FORWARDED_PATHS,
145
- S as authProxyRewrites,
144
+ D as DEFAULT_BASE_PATH,
145
+ F as DEFAULT_FORWARDED_PATHS,
146
+ U as ORGANIZATION_ERROR_PARAM,
147
+ _ as authProxyRewrites,
146
148
  E as createAuthProxy,
147
- _ as pontiveAuth
149
+ S as pontiveAuth,
150
+ $ as switchOrganizationPath
148
151
  };
149
152
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sources":["../src/server/headers.ts","../src/server/proxy.ts","../src/server/next.ts","../src/server/auth.ts"],"sourcesContent":["/**\n * What a proxy is allowed to change about the headers passing through it.\n *\n * Almost nothing, is the answer, and the exceptions are all cases where passing\n * a header on unchanged would be a lie about the hop it describes.\n */\n\n/**\n * Headers that describe the connection rather than the message (RFC 9110 §7.6.1).\n *\n * They belong to the hop they arrived on and mean nothing on the next one. The\n * one that actually bites is `transfer-encoding`: forwarded onto a body the\n * runtime has already dechunked, it describes an encoding that is no longer\n * there and the response is truncated or rejected.\n */\nconst HOP_BY_HOP = [\n \"connection\",\n \"keep-alive\",\n \"proxy-authenticate\",\n \"proxy-authorization\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n];\n\n/**\n * The headers to send upstream, given the ones that arrived.\n *\n * `cookie` is passed through untouched, which is the entire point of the\n * exercise: the browser attached it because the endpoints are on the app's own\n * origin, and this hop is what carries it to the server that can read it.\n */\nexport function upstreamHeaders(request: Request): Headers {\n const headers = new Headers(request.headers);\n\n for (const name of HOP_BY_HOP) {\n headers.delete(name);\n }\n\n // Set from the upstream URL by the runtime. Carrying the app's own Host would\n // be worse than useless: the authorization server resolves which project it is\n // answering as from Host, so the app's hostname reaches it as \"no such\n // project\" — a CORS refusal and an empty issuer, with nothing saying why.\n headers.delete(\"host\");\n\n // Recomputed from the body that is actually sent.\n headers.delete(\"content-length\");\n\n // Left to the runtime. Requesting an encoding here and then handing the caller\n // a body the runtime has already decoded is how a proxy ends up serving\n // gzip-labelled plaintext.\n headers.delete(\"accept-encoding\");\n\n const url = new URL(request.url);\n\n // The scheme the BROWSER used, which is the only one that matters to a cookie.\n // auth-api reads this and defaults to https when it is missing, so the case it\n // has to be right for is local development over http — where getting it wrong\n // mints an http:// issuer and every __Host- cookie is dropped on the floor.\n if (!headers.has(\"x-forwarded-proto\")) {\n headers.set(\"x-forwarded-proto\", url.protocol.replace(\":\", \"\"));\n }\n\n // Where the browser thinks it is. Nothing upstream routes on it — the point of\n // this proxy is that Host is the canonical auth host — but it is what makes a\n // proxied request identifiable in a log.\n if (!headers.has(\"x-forwarded-host\")) {\n headers.set(\"x-forwarded-host\", url.host);\n }\n\n headers.set(\"x-forwarded-for\", forwardedFor(request));\n\n return headers;\n}\n\n/**\n * The client IP chain.\n *\n * Passed through rather than replaced. A proxy that sets this to its immediate\n * peer forwards the address of whatever CDN or load balancer sits in front of\n * it — so rate limiting and audit logs upstream see one address for every user,\n * which is worse than the header being absent. Clerk documents the same trap.\n *\n * Where nothing has set it, there is nothing honest to put: a Web `Request`\n * carries no socket address, and inventing one is the failure above. Callers\n * that can see the peer pass it in with `clientIp`.\n */\nfunction forwardedFor(request: Request): string {\n const chain = request.headers.get(\"x-forwarded-for\");\n const ip = request.headers.get(\"x-real-ip\");\n\n if (chain) {\n return chain;\n }\n\n return ip ?? \"\";\n}\n\n/**\n * The headers to send back, given what the auth server answered with.\n *\n * `set-cookie` is the load-bearing one, in two ways. It is copied header by\n * header rather than through the bulk copy, because `new Headers(...)` folds\n * repeated headers into one comma-joined value — and a cookie with an `Expires`\n * date contains a comma, so the fold produces two cookies where the browser can\n * only parse one. That is the classic proxy bug, and it presents as a session\n * that works until the first rotation.\n *\n * And its attributes are passed on untouched. The server wrote the cookie with\n * no `Domain`, which makes it host-only — on THIS origin, because that is where\n * the browser thinks it came from. Rewriting or scoping it here would undo the\n * only thing this proxy exists to achieve.\n */\nexport function downstreamHeaders(response: Response): Headers {\n const headers = new Headers();\n\n // forEach rather than iteration, because this package's `lib` does not include\n // DOM.Iterable. It walks the same entries, and folds repeated headers the same\n // way — which is why set-cookie is skipped here and appended below.\n response.headers.forEach((value, name) => {\n if (name.toLowerCase() !== \"set-cookie\") {\n headers.set(name, value);\n }\n });\n\n for (const name of HOP_BY_HOP) {\n headers.delete(name);\n }\n\n // The body handed on has already been decoded, so both of these now describe\n // something that is not true of it.\n headers.delete(\"content-encoding\");\n headers.delete(\"content-length\");\n\n for (const cookie of setCookies(response.headers)) {\n headers.append(\"set-cookie\", cookie);\n }\n\n return headers;\n}\n\n/**\n * Every `set-cookie` as its own string.\n *\n * `getSetCookie` is the only API that can express this — everything else on\n * `Headers` joins repeated values — and it is present on every runtime this\n * proxy targets. The fallback is for the ones that are not: one joined value is\n * wrong for multiple cookies, but it is what the header already said, and the\n * common case of a single cookie survives it.\n */\nfunction setCookies(headers: Headers): string[] {\n if (typeof headers.getSetCookie === \"function\") {\n return headers.getSetCookie();\n }\n\n const joined = headers.get(\"set-cookie\");\n\n return joined ? [joined] : [];\n}\n","import { downstreamHeaders, upstreamHeaders } from \"./headers\";\nimport {\n DEFAULT_BASE_PATH,\n DEFAULT_FORWARDED_PATHS,\n authOrigin,\n isUnder,\n normaliseBasePath,\n} from \"@pontive/pontkit-loader/proxy\";\n\nexport interface AuthProxyOptions {\n /**\n * The auth server, as a hostname or an origin — the value the SDK's `domain`\n * used to hold, e.g. `tenant.idp.us.pontive.app`.\n */\n authHost: string;\n /**\n * Where the endpoints hang off this app's origin. Defaults to `/__auth`; `\"/\"`\n * mounts them at the root, which is the shape a dev server uses.\n *\n * Whatever this is, it is also what the SDK's `domain` must be set to.\n */\n basePath?: string;\n /** Which upstream prefixes may be forwarded. Defaults to the SDK's surface. */\n paths?: readonly string[];\n /** The fetch to send upstream requests with. For tests and custom agents. */\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface AuthProxy {\n /** Whether this request is one the proxy should carry. */\n handles(request: Request): boolean;\n /** Carries it, and answers with whatever the auth server said. */\n forward(request: Request): Promise<Response>;\n /** The normalised base path, for building the SDK's `domain`. */\n readonly basePath: string;\n /** The upstream origin. */\n readonly origin: string;\n /** Path patterns for a framework that routes by them, e.g. Next's matcher. */\n readonly matcher: string[];\n}\n\n/**\n * A reverse proxy for the auth endpoints, as a Web-standard request handler.\n *\n * Why an app would run one: a browser only treats a cookie as first-party when\n * it comes from the origin the page is on. An app on `app.acme.com` talking to\n * an auth server on another hostname is cross-site, so the refresh cookie is a\n * third-party cookie — blocked outright in Safari, and on borrowed time\n * everywhere else. Proxying the endpoints under the app's own origin makes them\n * first-party, and `SameSite=Lax` holds with no DNS record, no certificate, and\n * nothing to verify.\n *\n * What it deliberately does NOT do is rewrite anything. It does not touch the\n * cookies in either direction, does not follow redirects, and does not present\n * the app's own Host upstream — the auth server resolves which project it is\n * answering as from Host, so the canonical one has to arrive intact. That is\n * also why this needs no secret: unlike Clerk's equivalent, whose Frontend API\n * is multi-tenant on one hostname and must be told which instance to be, the\n * hostname here already says it.\n *\n * Runs anywhere `Request` and `Response` do: Next.js middleware and route\n * handlers, Cloudflare Workers, Hono, Deno, Bun. A Vite dev server does not need\n * it — see `viteAuthProxy`, which configures Vite's own proxy instead.\n */\nexport function createAuthProxy(options: AuthProxyOptions): AuthProxy {\n const origin = authOrigin(options.authHost);\n const basePath = normaliseBasePath(options.basePath ?? DEFAULT_BASE_PATH);\n const paths = options.paths ?? DEFAULT_FORWARDED_PATHS;\n const send = options.fetch ?? globalThis.fetch;\n\n /**\n * The upstream URL, or null when this is not a request to carry.\n *\n * Resolved through `URL` before the prefix check, not after, so a path that\n * climbs out of the base — `/__auth/../admin` — is tested as what it actually\n * addresses rather than as what it looks like. It cannot leave the origin;\n * this is what stops it reaching a path the caller did not open up.\n */\n function upstreamFor(request: Request): URL | null {\n const url = new URL(request.url);\n\n if (!isUnder(url.pathname, basePath)) {\n return null;\n }\n\n const rest = url.pathname.slice(basePath.length) || \"/\";\n const upstream = new URL(`${rest}${url.search}`, origin);\n\n if (upstream.origin !== origin) {\n return null;\n }\n\n return paths.some((prefix) => isUnder(upstream.pathname, prefix)) ? upstream : null;\n }\n\n return {\n basePath,\n origin,\n\n matcher: paths.map((prefix) => `${basePath}${prefix}/:path*`),\n\n handles(request: Request): boolean {\n return upstreamFor(request) !== null;\n },\n\n async forward(request: Request): Promise<Response> {\n const upstream = upstreamFor(request);\n\n if (!upstream) {\n // The caller routed something here that this proxy does not carry.\n // Answered rather than passed through, because passing it through would\n // mean the app's own router handling a URL under a prefix it has\n // otherwise given away.\n return new Response(\"Not Found\", { status: 404 });\n }\n\n // A GET or HEAD has no body to stream, and `duplex` is required by the\n // fetch spec for the ones that do.\n const body = request.method === \"GET\" || request.method === \"HEAD\" ? undefined : request.body;\n\n try {\n const response = await send(upstream, {\n method: request.method,\n headers: upstreamHeaders(request),\n body,\n // Passed to the browser as-is. Followed here, a 302 from /authorize\n // would be resolved server-side and the browser would never see the\n // navigation it is supposed to make.\n redirect: \"manual\",\n ...(body ? { duplex: \"half\" } : {}),\n } as RequestInit);\n\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: downstreamHeaders(response),\n });\n } catch (error) {\n // The auth server is unreachable from here. 502 rather than 500: the\n // failure is upstream, and the distinction is the first thing anyone\n // debugging a proxy wants to know.\n console.warn(`Could not reach the auth server at ${origin}:`, error);\n\n return new Response(\"Bad Gateway\", { status: 502 });\n }\n },\n };\n}\n","import {\n DEFAULT_BASE_PATH,\n DEFAULT_FORWARDED_PATHS,\n authOrigin,\n normaliseBasePath,\n} from \"@pontive/pontkit-loader/proxy\";\n\nexport interface NextRewrite {\n source: string;\n destination: string;\n}\n\nexport interface AuthProxyRewritesOptions {\n authHost: string;\n basePath?: string;\n paths?: readonly string[];\n}\n\n/**\n * The auth endpoints, proxied by Next's own rewrites.\n *\n * ```js\n * // next.config.js\n * rewrites: async () => authProxyRewrites({ authHost: process.env.SB_AUTH_DOMAIN })\n * ```\n *\n * The cheapest Next integration there is, and the one to reach for first: a\n * rewrite to an external destination sends the destination's Host upstream,\n * which is exactly what the auth server needs, so there is no header to\n * configure and nothing to get wrong. Middleware (`createAuthProxy`) is for when\n * something else has to happen on the way through — a client IP to resolve, a\n * header to add, a path to decide at runtime.\n */\nexport function authProxyRewrites(options: AuthProxyRewritesOptions): NextRewrite[] {\n const origin = authOrigin(options.authHost);\n const basePath = normaliseBasePath(options.basePath ?? DEFAULT_BASE_PATH);\n const paths = options.paths ?? DEFAULT_FORWARDED_PATHS;\n\n return paths.map((prefix) => ({\n source: `${basePath}${prefix}/:path*`,\n destination: `${origin}${prefix}/:path*`,\n }));\n}\n","import { createServerAuth, type ServerAuthConfig, type Session } from \"@pontive/pontkit-server\";\n\n/**\n * Server-side sessions for a Next.js app.\n *\n * ```ts\n * // lib/pontive.ts\n * export const pontive = pontiveAuth({ issuer, clientId, clientSecret, sessionSecret, baseUrl });\n *\n * // app/api/auth/[...pontive]/route.ts\n * export const { GET, POST } = pontive.handlers;\n *\n * // proxy.ts (middleware.ts before Next 16)\n * export function proxy(req: NextRequest) {\n * return pontive.middleware(req);\n * }\n *\n * // any server component, route handler or server action\n * const session = await pontive.auth();\n * ```\n *\n * The middleware is what keeps the session current: it refreshes before the\n * request is handled, where the new cookie can always be written, and passes\n * the refreshed cookie on to the page rendered for that same request. `auth()`\n * only reads — which is why it works in a server component, where cookies are\n * read-only.\n */\n\nexport type { Session, SessionUser, ServerAuthConfig } from \"@pontive/pontkit-server\";\n\n/**\n * Decides what to do with a request once its session is known: return a\n * response (a redirect to sign in, say) or nothing to let it through. The SDK\n * adds its cookies to whichever response goes out.\n */\nexport type MiddlewareDecision = (session: Session | null, request: Request) => Response | undefined | Promise<Response | undefined>;\n\nexport interface PontiveAuth {\n /** Route handlers for `app/api/auth/[...pontive]/route.ts` (or wherever `basePath` points). */\n handlers: { GET: (request: Request) => Promise<Response>; POST: (request: Request) => Promise<Response> };\n /** The signed-in session, or null. Read-only; safe in any server context. */\n auth(): Promise<Session | null>;\n /** Refreshes the session ahead of the request. Call it from `proxy.ts` / `middleware.ts`. */\n middleware(request: Request, decide?: MiddlewareDecision): Promise<Response>;\n}\n\n/**\n * Whether a request is the browser loading a page, the one kind of request a\n * redirect through the handshake can serve. A fetch, a form post or a Next\n * client-side navigation (an RSC request) would receive the handshake's HTML\n * redirect chain instead of what it asked for; those proceed without a session\n * while the browser SDK renews the token on its own.\n */\nfunction isPageNavigation(request: Request): boolean {\n if (request.method !== \"GET\") return false;\n if (request.headers.get(\"rsc\") || request.headers.get(\"next-router-prefetch\")) return false;\n\n const mode = request.headers.get(\"sec-fetch-mode\");\n if (mode) return mode === \"navigate\";\n\n return (request.headers.get(\"accept\") ?? \"\").includes(\"text/html\");\n}\n\n/**\n * Adds `Set-Cookie` values to a response. Some responses have immutable\n * headers — `Response.redirect()`'s, for one — so those are copied into one\n * that can take them. A NextResponse keeps its instructions (next, rewrite) in\n * headers too, so the copy carries them over.\n */\nfunction withCookies(response: Response, setCookies: string[]): Response {\n if (setCookies.length === 0) return response;\n\n let target = response;\n try {\n for (const cookie of setCookies) target.headers.append(\"set-cookie\", cookie);\n return target;\n } catch {\n target = new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: new Headers(response.headers),\n });\n }\n\n for (const cookie of setCookies) target.headers.append(\"set-cookie\", cookie);\n\n return target;\n}\n\nexport function pontiveAuth(config: ServerAuthConfig): PontiveAuth {\n const core = createServerAuth(config);\n\n const route = async (request: Request) =>\n (await core.handle(request)) ?? new Response(\"Not found\", { status: 404 });\n\n return {\n handlers: { GET: route, POST: route },\n\n async auth() {\n // Imported here, not at the top: next/headers only exists inside a\n // request, and this module is also loaded by middleware.\n const { cookies } = await import(\"next/headers\");\n const store = await cookies();\n\n return core.getSession(store.toString());\n },\n\n async middleware(request, decide) {\n const { NextResponse } = await import(\"next/server\");\n const outcome = await core.refresh(request);\n\n // Browser mode: a signed-in page navigation whose access token lapsed\n // goes through the auth server's handshake and comes straight back.\n if (outcome.handshake && isPageNavigation(request)) {\n return new Response(null, {\n status: 302,\n // Absolute: Next parses a middleware redirect's Location as a URL and\n // refuses a bare path. It relativizes it again on the way out, so the\n // browser still gets a path on the origin it asked.\n headers: { location: new URL(outcome.handshake, request.url).toString(), \"cache-control\": \"no-store\" },\n });\n }\n\n let response = decide ? await decide(outcome.session, request) : undefined;\n if (!response) {\n // Pass the refreshed cookie on to whatever handles this request, so a\n // page rendered now reads the new token rather than the one the\n // browser sent.\n const headers = new Headers(request.headers);\n headers.set(\"cookie\", outcome.cookieHeader);\n response = NextResponse.next({ request: { headers } });\n }\n\n return withCookies(response, outcome.setCookies);\n },\n };\n}\n"],"names":["HOP_BY_HOP","upstreamHeaders","request","headers","name","url","forwardedFor","chain","ip","downstreamHeaders","response","value","cookie","setCookies","joined","createAuthProxy","options","origin","authOrigin","basePath","normaliseBasePath","DEFAULT_BASE_PATH","paths","DEFAULT_FORWARDED_PATHS","send","upstreamFor","isUnder","rest","upstream","prefix","body","error","authProxyRewrites","isPageNavigation","mode","withCookies","target","pontiveAuth","config","core","createServerAuth","route","cookies","store","decide","NextResponse","outcome"],"mappings":";;;AAeA,MAAMA,IAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,SAASC,EAAgBC,GAA2B;AACzD,QAAMC,IAAU,IAAI,QAAQD,EAAQ,OAAO;AAE3C,aAAWE,KAAQJ;AACjB,IAAAG,EAAQ,OAAOC,CAAI;AAOrB,EAAAD,EAAQ,OAAO,MAAM,GAGrBA,EAAQ,OAAO,gBAAgB,GAK/BA,EAAQ,OAAO,iBAAiB;AAEhC,QAAME,IAAM,IAAI,IAAIH,EAAQ,GAAG;AAM/B,SAAKC,EAAQ,IAAI,mBAAmB,KAClCA,EAAQ,IAAI,qBAAqBE,EAAI,SAAS,QAAQ,KAAK,EAAE,CAAC,GAM3DF,EAAQ,IAAI,kBAAkB,KACjCA,EAAQ,IAAI,oBAAoBE,EAAI,IAAI,GAG1CF,EAAQ,IAAI,mBAAmBG,EAAaJ,CAAO,CAAC,GAE7CC;AACT;AAcA,SAASG,EAAaJ,GAA0B;AAC9C,QAAMK,IAAQL,EAAQ,QAAQ,IAAI,iBAAiB,GAC7CM,IAAKN,EAAQ,QAAQ,IAAI,WAAW;AAE1C,SAAIK,MAIGC,KAAM;AACf;AAiBO,SAASC,EAAkBC,GAA6B;AAC7D,QAAMP,IAAU,IAAI,QAAA;AAKpB,EAAAO,EAAS,QAAQ,QAAQ,CAACC,GAAOP,MAAS;AACxC,IAAIA,EAAK,YAAA,MAAkB,gBACzBD,EAAQ,IAAIC,GAAMO,CAAK;AAAA,EAE3B,CAAC;AAED,aAAWP,KAAQJ;AACjB,IAAAG,EAAQ,OAAOC,CAAI;AAKrB,EAAAD,EAAQ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AOE,EAAQ,SAAS5C,CAAO,IAAI;AACjE,UAAI,CAACQ,GAAU;AAIb,cAAMP,IAAU,IAAI,QAAQD,EAAQ,OAAO;AAC3C,QAAAC,EAAQ,IAAI,UAAU2C,EAAQ,YAAY,GAC1CpC,IAAWmC,EAAa,KAAK,EAAE,SAAS,EAAE,SAAA1C,EAAA,GAAW;AAAA,MACvD;AAEA,aAAOgC,EAAYzB,GAAUoC,EAAQ,UAAU;AAAA,IACjD;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"server.js","sources":["../src/server/headers.ts","../src/server/proxy.ts","../src/server/next.ts","../src/server/auth.ts"],"sourcesContent":["/**\n * What a proxy is allowed to change about the headers passing through it.\n *\n * Almost nothing, is the answer, and the exceptions are all cases where passing\n * a header on unchanged would be a lie about the hop it describes.\n */\n\n/**\n * Headers that describe the connection rather than the message (RFC 9110 §7.6.1).\n *\n * They belong to the hop they arrived on and mean nothing on the next one. The\n * one that actually bites is `transfer-encoding`: forwarded onto a body the\n * runtime has already dechunked, it describes an encoding that is no longer\n * there and the response is truncated or rejected.\n */\nconst HOP_BY_HOP = [\n \"connection\",\n \"keep-alive\",\n \"proxy-authenticate\",\n \"proxy-authorization\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n];\n\n/**\n * The headers to send upstream, given the ones that arrived.\n *\n * `cookie` is passed through untouched, which is the entire point of the\n * exercise: the browser attached it because the endpoints are on the app's own\n * origin, and this hop is what carries it to the server that can read it.\n */\nexport function upstreamHeaders(request: Request): Headers {\n const headers = new Headers(request.headers);\n\n for (const name of HOP_BY_HOP) {\n headers.delete(name);\n }\n\n // Set from the upstream URL by the runtime. Carrying the app's own Host would\n // be worse than useless: the authorization server resolves which project it is\n // answering as from Host, so the app's hostname reaches it as \"no such\n // project\" — a CORS refusal and an empty issuer, with nothing saying why.\n headers.delete(\"host\");\n\n // Recomputed from the body that is actually sent.\n headers.delete(\"content-length\");\n\n // Left to the runtime. Requesting an encoding here and then handing the caller\n // a body the runtime has already decoded is how a proxy ends up serving\n // gzip-labelled plaintext.\n headers.delete(\"accept-encoding\");\n\n const url = new URL(request.url);\n\n // The scheme the BROWSER used, which is the only one that matters to a cookie.\n // auth-api reads this and defaults to https when it is missing, so the case it\n // has to be right for is local development over http — where getting it wrong\n // mints an http:// issuer and every __Host- cookie is dropped on the floor.\n if (!headers.has(\"x-forwarded-proto\")) {\n headers.set(\"x-forwarded-proto\", url.protocol.replace(\":\", \"\"));\n }\n\n // Where the browser thinks it is. Nothing upstream routes on it — the point of\n // this proxy is that Host is the canonical auth host — but it is what makes a\n // proxied request identifiable in a log.\n if (!headers.has(\"x-forwarded-host\")) {\n headers.set(\"x-forwarded-host\", url.host);\n }\n\n headers.set(\"x-forwarded-for\", forwardedFor(request));\n\n return headers;\n}\n\n/**\n * The client IP chain.\n *\n * Passed through rather than replaced. A proxy that sets this to its immediate\n * peer forwards the address of whatever CDN or load balancer sits in front of\n * it — so rate limiting and audit logs upstream see one address for every user,\n * which is worse than the header being absent. Clerk documents the same trap.\n *\n * Where nothing has set it, there is nothing honest to put: a Web `Request`\n * carries no socket address, and inventing one is the failure above. Callers\n * that can see the peer pass it in with `clientIp`.\n */\nfunction forwardedFor(request: Request): string {\n const chain = request.headers.get(\"x-forwarded-for\");\n const ip = request.headers.get(\"x-real-ip\");\n\n if (chain) {\n return chain;\n }\n\n return ip ?? \"\";\n}\n\n/**\n * The headers to send back, given what the auth server answered with.\n *\n * `set-cookie` is the load-bearing one, in two ways. It is copied header by\n * header rather than through the bulk copy, because `new Headers(...)` folds\n * repeated headers into one comma-joined value — and a cookie with an `Expires`\n * date contains a comma, so the fold produces two cookies where the browser can\n * only parse one. That is the classic proxy bug, and it presents as a session\n * that works until the first rotation.\n *\n * And its attributes are passed on untouched. The server wrote the cookie with\n * no `Domain`, which makes it host-only — on THIS origin, because that is where\n * the browser thinks it came from. Rewriting or scoping it here would undo the\n * only thing this proxy exists to achieve.\n */\nexport function downstreamHeaders(response: Response): Headers {\n const headers = new Headers();\n\n // forEach rather than iteration, because this package's `lib` does not include\n // DOM.Iterable. It walks the same entries, and folds repeated headers the same\n // way — which is why set-cookie is skipped here and appended below.\n response.headers.forEach((value, name) => {\n if (name.toLowerCase() !== \"set-cookie\") {\n headers.set(name, value);\n }\n });\n\n for (const name of HOP_BY_HOP) {\n headers.delete(name);\n }\n\n // The body handed on has already been decoded, so both of these now describe\n // something that is not true of it.\n headers.delete(\"content-encoding\");\n headers.delete(\"content-length\");\n\n for (const cookie of setCookies(response.headers)) {\n headers.append(\"set-cookie\", cookie);\n }\n\n return headers;\n}\n\n/**\n * Every `set-cookie` as its own string.\n *\n * `getSetCookie` is the only API that can express this — everything else on\n * `Headers` joins repeated values — and it is present on every runtime this\n * proxy targets. The fallback is for the ones that are not: one joined value is\n * wrong for multiple cookies, but it is what the header already said, and the\n * common case of a single cookie survives it.\n */\nfunction setCookies(headers: Headers): string[] {\n if (typeof headers.getSetCookie === \"function\") {\n return headers.getSetCookie();\n }\n\n const joined = headers.get(\"set-cookie\");\n\n return joined ? [joined] : [];\n}\n","import { downstreamHeaders, upstreamHeaders } from \"./headers\";\nimport {\n DEFAULT_BASE_PATH,\n DEFAULT_FORWARDED_PATHS,\n authOrigin,\n isUnder,\n normaliseBasePath,\n} from \"@pontive/pontkit-loader/proxy\";\n\nexport interface AuthProxyOptions {\n /**\n * The auth server, as a hostname or an origin — the value the SDK's `domain`\n * used to hold, e.g. `tenant.idp.us.pontive.app`.\n */\n authHost: string;\n /**\n * Where the endpoints hang off this app's origin. Defaults to `/__auth`; `\"/\"`\n * mounts them at the root, which is the shape a dev server uses.\n *\n * Whatever this is, it is also what the SDK's `domain` must be set to.\n */\n basePath?: string;\n /** Which upstream prefixes may be forwarded. Defaults to the SDK's surface. */\n paths?: readonly string[];\n /** The fetch to send upstream requests with. For tests and custom agents. */\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface AuthProxy {\n /** Whether this request is one the proxy should carry. */\n handles(request: Request): boolean;\n /** Carries it, and answers with whatever the auth server said. */\n forward(request: Request): Promise<Response>;\n /** The normalised base path, for building the SDK's `domain`. */\n readonly basePath: string;\n /** The upstream origin. */\n readonly origin: string;\n /** Path patterns for a framework that routes by them, e.g. Next's matcher. */\n readonly matcher: string[];\n}\n\n/**\n * A reverse proxy for the auth endpoints, as a Web-standard request handler.\n *\n * Why an app would run one: a browser only treats a cookie as first-party when\n * it comes from the origin the page is on. An app on `app.acme.com` talking to\n * an auth server on another hostname is cross-site, so the refresh cookie is a\n * third-party cookie — blocked outright in Safari, and on borrowed time\n * everywhere else. Proxying the endpoints under the app's own origin makes them\n * first-party, and `SameSite=Lax` holds with no DNS record, no certificate, and\n * nothing to verify.\n *\n * What it deliberately does NOT do is rewrite anything. It does not touch the\n * cookies in either direction, does not follow redirects, and does not present\n * the app's own Host upstream — the auth server resolves which project it is\n * answering as from Host, so the canonical one has to arrive intact. That is\n * also why this needs no secret: unlike Clerk's equivalent, whose Frontend API\n * is multi-tenant on one hostname and must be told which instance to be, the\n * hostname here already says it.\n *\n * Runs anywhere `Request` and `Response` do: Next.js middleware and route\n * handlers, Cloudflare Workers, Hono, Deno, Bun. A Vite dev server does not need\n * it — see `viteAuthProxy`, which configures Vite's own proxy instead.\n */\nexport function createAuthProxy(options: AuthProxyOptions): AuthProxy {\n const origin = authOrigin(options.authHost);\n const basePath = normaliseBasePath(options.basePath ?? DEFAULT_BASE_PATH);\n const paths = options.paths ?? DEFAULT_FORWARDED_PATHS;\n const send = options.fetch ?? globalThis.fetch;\n\n /**\n * The upstream URL, or null when this is not a request to carry.\n *\n * Resolved through `URL` before the prefix check, not after, so a path that\n * climbs out of the base — `/__auth/../admin` — is tested as what it actually\n * addresses rather than as what it looks like. It cannot leave the origin;\n * this is what stops it reaching a path the caller did not open up.\n */\n function upstreamFor(request: Request): URL | null {\n const url = new URL(request.url);\n\n if (!isUnder(url.pathname, basePath)) {\n return null;\n }\n\n const rest = url.pathname.slice(basePath.length) || \"/\";\n const upstream = new URL(`${rest}${url.search}`, origin);\n\n if (upstream.origin !== origin) {\n return null;\n }\n\n return paths.some((prefix) => isUnder(upstream.pathname, prefix)) ? upstream : null;\n }\n\n return {\n basePath,\n origin,\n\n matcher: paths.map((prefix) => `${basePath}${prefix}/:path*`),\n\n handles(request: Request): boolean {\n return upstreamFor(request) !== null;\n },\n\n async forward(request: Request): Promise<Response> {\n const upstream = upstreamFor(request);\n\n if (!upstream) {\n // The caller routed something here that this proxy does not carry.\n // Answered rather than passed through, because passing it through would\n // mean the app's own router handling a URL under a prefix it has\n // otherwise given away.\n return new Response(\"Not Found\", { status: 404 });\n }\n\n // A GET or HEAD has no body to stream, and `duplex` is required by the\n // fetch spec for the ones that do.\n const body = request.method === \"GET\" || request.method === \"HEAD\" ? undefined : request.body;\n\n try {\n const response = await send(upstream, {\n method: request.method,\n headers: upstreamHeaders(request),\n body,\n // Passed to the browser as-is. Followed here, a 302 from /authorize\n // would be resolved server-side and the browser would never see the\n // navigation it is supposed to make.\n redirect: \"manual\",\n ...(body ? { duplex: \"half\" } : {}),\n } as RequestInit);\n\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: downstreamHeaders(response),\n });\n } catch (error) {\n // The auth server is unreachable from here. 502 rather than 500: the\n // failure is upstream, and the distinction is the first thing anyone\n // debugging a proxy wants to know.\n console.warn(`Could not reach the auth server at ${origin}:`, error);\n\n return new Response(\"Bad Gateway\", { status: 502 });\n }\n },\n };\n}\n","import {\n DEFAULT_BASE_PATH,\n DEFAULT_FORWARDED_PATHS,\n authOrigin,\n normaliseBasePath,\n} from \"@pontive/pontkit-loader/proxy\";\n\nexport interface NextRewrite {\n source: string;\n destination: string;\n}\n\nexport interface AuthProxyRewritesOptions {\n authHost: string;\n basePath?: string;\n paths?: readonly string[];\n}\n\n/**\n * The auth endpoints, proxied by Next's own rewrites.\n *\n * ```js\n * // next.config.js\n * rewrites: async () => authProxyRewrites({ authHost: process.env.SB_AUTH_DOMAIN })\n * ```\n *\n * The cheapest Next integration there is, and the one to reach for first: a\n * rewrite to an external destination sends the destination's Host upstream,\n * which is exactly what the auth server needs, so there is no header to\n * configure and nothing to get wrong. Middleware (`createAuthProxy`) is for when\n * something else has to happen on the way through — a client IP to resolve, a\n * header to add, a path to decide at runtime.\n */\nexport function authProxyRewrites(options: AuthProxyRewritesOptions): NextRewrite[] {\n const origin = authOrigin(options.authHost);\n const basePath = normaliseBasePath(options.basePath ?? DEFAULT_BASE_PATH);\n const paths = options.paths ?? DEFAULT_FORWARDED_PATHS;\n\n return paths.map((prefix) => ({\n source: `${basePath}${prefix}/:path*`,\n destination: `${origin}${prefix}/:path*`,\n }));\n}\n","import { createServerAuth, type ServerAuthConfig, type Session } from \"@pontive/pontkit-server\";\n\n/**\n * Server-side sessions for a Next.js app.\n *\n * ```ts\n * // lib/pontive.ts\n * export const pontive = pontiveAuth({ issuer, clientId, clientSecret, sessionSecret, baseUrl });\n *\n * // app/api/auth/[...pontive]/route.ts\n * export const { GET, POST } = pontive.handlers;\n *\n * // proxy.ts (middleware.ts before Next 16)\n * export function proxy(req: NextRequest) {\n * return pontive.middleware(req);\n * }\n *\n * // any server component, route handler or server action\n * const session = await pontive.auth();\n * ```\n *\n * The middleware is what keeps the session current: it refreshes before the\n * request is handled, where the new cookie can always be written, and passes\n * the refreshed cookie on to the page rendered for that same request. `auth()`\n * only reads — which is why it works in a server component, where cookies are\n * read-only.\n */\n\nexport type { Session, SessionUser, ServerAuthConfig } from \"@pontive/pontkit-server\";\n\n/**\n * Decides what to do with a request once its session is known: return a\n * response (a redirect to sign in, say) or nothing to let it through. The SDK\n * adds its cookies to whichever response goes out.\n */\nexport type MiddlewareDecision = (session: Session | null, request: Request) => Response | undefined | Promise<Response | undefined>;\n\nexport interface PontiveAuth {\n /** Route handlers for `app/api/auth/[...pontive]/route.ts` (or wherever `basePath` points). */\n handlers: { GET: (request: Request) => Promise<Response>; POST: (request: Request) => Promise<Response> };\n /** The signed-in session, or null. Read-only; safe in any server context. */\n auth(): Promise<Session | null>;\n /** Refreshes the session ahead of the request. Call it from `proxy.ts` / `middleware.ts`. */\n middleware(request: Request, decide?: MiddlewareDecision): Promise<Response>;\n}\n\n/**\n * Whether a request is the browser loading a page, the one kind of request a\n * redirect through the handshake can serve. A fetch, a form post or a Next\n * client-side navigation (an RSC request) would receive the handshake's HTML\n * redirect chain instead of what it asked for; those proceed without a session\n * while the browser SDK renews the token on its own.\n */\nfunction isPageNavigation(request: Request): boolean {\n if (request.method !== \"GET\") return false;\n if (request.headers.get(\"rsc\") || request.headers.get(\"next-router-prefetch\")) return false;\n\n const mode = request.headers.get(\"sec-fetch-mode\");\n if (mode) return mode === \"navigate\";\n\n return (request.headers.get(\"accept\") ?? \"\").includes(\"text/html\");\n}\n\n/**\n * Adds `Set-Cookie` values to a response. Some responses have immutable\n * headers — `Response.redirect()`'s, for one — so those are copied into one\n * that can take them. A NextResponse keeps its instructions (next, rewrite) in\n * headers too, so the copy carries them over.\n */\nfunction withCookies(response: Response, setCookies: string[]): Response {\n if (setCookies.length === 0) return response;\n\n let target = response;\n try {\n for (const cookie of setCookies) target.headers.append(\"set-cookie\", cookie);\n return target;\n } catch {\n target = new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: new Headers(response.headers),\n });\n }\n\n for (const cookie of setCookies) target.headers.append(\"set-cookie\", cookie);\n\n return target;\n}\n\nexport function pontiveAuth(config: ServerAuthConfig): PontiveAuth {\n const core = createServerAuth(config);\n\n const route = async (request: Request) =>\n (await core.handle(request)) ?? new Response(\"Not found\", { status: 404 });\n\n return {\n handlers: { GET: route, POST: route },\n\n async auth() {\n // Imported here, not at the top: next/headers only exists inside a\n // request, and this module is also loaded by middleware.\n const { cookies } = await import(\"next/headers\");\n const store = await cookies();\n\n return core.getSession(store.toString());\n },\n\n async middleware(request, decide) {\n const { NextResponse } = await import(\"next/server\");\n const outcome = await core.refresh(request);\n\n // Browser mode: a signed-in page navigation whose access token lapsed\n // goes through the auth server's handshake and comes straight back.\n if (outcome.handshake && isPageNavigation(request)) {\n return new Response(null, {\n status: 302,\n // Absolute: Next parses a middleware redirect's Location as a URL and\n // refuses a bare path. It relativizes it again on the way out, so the\n // browser still gets a path on the origin it asked.\n headers: { location: new URL(outcome.handshake, request.url).toString(), \"cache-control\": \"no-store\" },\n });\n }\n\n let response = decide ? await decide(outcome.session, request) : undefined;\n if (!response) {\n // Pass the refreshed cookie on to whatever handles this request, so a\n // page rendered now reads the new token rather than the one the\n // browser sent.\n const headers = new Headers(request.headers);\n headers.set(\"cookie\", outcome.cookieHeader);\n response = NextResponse.next({ request: { headers } });\n }\n\n return withCookies(response, outcome.setCookies);\n },\n };\n}\n"],"names":["HOP_BY_HOP","upstreamHeaders","request","headers","name","url","forwardedFor","chain","ip","downstreamHeaders","response","value","cookie","setCookies","joined","createAuthProxy","options","origin","authOrigin","basePath","normaliseBasePath","DEFAULT_BASE_PATH","paths","DEFAULT_FORWARDED_PATHS","send","upstreamFor","isUnder","rest","upstream","prefix","body","error","authProxyRewrites","isPageNavigation","mode","withCookies","target","pontiveAuth","config","core","createServerAuth","route","cookies","store","decide","NextResponse","outcome"],"mappings":";;;;AAeA,MAAMA,IAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,SAASC,EAAgBC,GAA2B;AACzD,QAAMC,IAAU,IAAI,QAAQD,EAAQ,OAAO;AAE3C,aAAWE,KAAQJ;AACjB,IAAAG,EAAQ,OAAOC,CAAI;AAOrB,EAAAD,EAAQ,OAAO,MAAM,GAGrBA,EAAQ,OAAO,gBAAgB,GAK/BA,EAAQ,OAAO,iBAAiB;AAEhC,QAAME,IAAM,IAAI,IAAIH,EAAQ,GAAG;AAM/B,SAAKC,EAAQ,IAAI,mBAAmB,KAClCA,EAAQ,IAAI,qBAAqBE,EAAI,SAAS,QAAQ,KAAK,EAAE,CAAC,GAM3DF,EAAQ,IAAI,kBAAkB,KACjCA,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AAA,IAAY,MAAM,OAAO,cAAc,GACzCC,IAAQ,MAAMD,EAAA;AAEpB,aAAOH,EAAK,WAAWI,EAAM,SAAA,CAAU;AAAA,IACzC;AAAA,IAEA,MAAM,WAAWzC,GAAS0C,GAAQ;AAChC,YAAM,EAAE,cAAAC,EAAA,IAAiB,MAAM,OAAO,aAAa,GAC7CC,IAAU,MAAMP,EAAK,QAAQrC,CAAO;AAI1C,UAAI4C,EAAQ,aAAab,EAAiB/B,CAAO;AAC/C,eAAO,IAAI,SAAS,MAAM;AAAA,UACxB,QAAQ;AAAA;AAAA;AAAA;AAAA,UAIR,SAAS,EAAE,UAAU,IAAI,IAAI4C,EAAQ,WAAW5C,EAAQ,GAAG,EAAE,SAAA,GAAY,iBAAiB,WAAA;AAAA,QAAW,CACtG;AAGH,UAAIQ,IAAWkC,IAAS,MAAMA,EAAOE,EAAQ,SAAS5C,CAAO,IAAI;AACjE,UAAI,CAACQ,GAAU;AAIb,cAAMP,IAAU,IAAI,QAAQD,EAAQ,OAAO;AAC3C,QAAAC,EAAQ,IAAI,UAAU2C,EAAQ,YAAY,GAC1CpC,IAAWmC,EAAa,KAAK,EAAE,SAAS,EAAE,SAAA1C,EAAA,GAAW;AAAA,MACvD;AAEA,aAAOgC,EAAYzB,GAAUoC,EAAQ,UAAU;AAAA,IACjD;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pontive/pontkit-nextjs",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "license": "MIT",
5
5
  "description": "The React bindings plus server-side sessions and the auth proxy for Next.js.",
6
6
  "type": "module",
@@ -37,8 +37,8 @@
37
37
  "react-dom": "^18 || ^19"
38
38
  },
39
39
  "dependencies": {
40
- "@pontive/pontkit-loader": "^1.3.0",
41
- "@pontive/pontkit-react": "^1.3.0",
42
- "@pontive/pontkit-server": "^1.3.0"
40
+ "@pontive/pontkit-loader": "^1.4.1",
41
+ "@pontive/pontkit-react": "^1.4.1",
42
+ "@pontive/pontkit-server": "^1.4.1"
43
43
  }
44
44
  }