@segmentstream-cloud/app 0.16.2 → 0.16.3

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/dist/neon.js CHANGED
@@ -8,19 +8,14 @@ import { NOT_INVITED, SIGN_IN_LINK_INVALID, SegmentStreamApiError, apiErrorFrom,
8
8
  import { parseMe } from "./me.js";
9
9
  import { createOntologyTransport } from "./ontology-transport.js";
10
10
  import { isAllowed } from "./permissions.js";
11
- import { matchesPathPrefix, normalizePublicPath } from "./proxy.js";
11
+ import { matchesPathPrefix, normalizePublicPath, wellKnownResponse } from "./proxy.js";
12
12
  import { isApiRequest, unauthenticatedResponse } from "./sign-in.js";
13
13
  /** The app's sign-in page, which renders `<SignIn />` from `@segmentstream-cloud/app/ui`. */
14
14
  export const SIGN_IN_PAGE = "/sign-in";
15
15
  /** Where `app/src/app/api/auth/[...path]/route.ts` serves the Neon Auth API. */
16
16
  export const AUTH_API_PATH = "/api/auth";
17
- /** The paths the ontology service answers: its HTTP API, its MCP server and its OAuth metadata. */
18
- const ONTOLOGY_PATHS = [
19
- "/api/ontology",
20
- "/mcp",
21
- "/.well-known/oauth-protected-resource",
22
- "/.well-known/oauth-authorization-server",
23
- ];
17
+ /** The ontology's HTTP API and MCP transport; metadata probes are handled separately. */
18
+ const ONTOLOGY_PATHS = ["/api/ontology", "/mcp"];
24
19
  /**
25
20
  * Paths every visitor may open: the Neon Auth API, the sign-in page, the health check, and the
26
21
  * Next.js assets and metadata files the sign-in page needs.
@@ -310,6 +305,10 @@ export function createNeonSession(dependencies) {
310
305
  const publicPaths = [...OPEN_PATHS, ...(options.publicPaths ?? [])].map(normalizePublicPath);
311
306
  return async function neonProxy(request) {
312
307
  const { pathname, search } = request.nextUrl;
308
+ const discovery = wellKnownResponse(request, settings.ontologyUrl);
309
+ if (discovery !== undefined) {
310
+ return discovery;
311
+ }
313
312
  if (settings.ontologyUrl !== undefined &&
314
313
  ONTOLOGY_PATHS.some((path) => matchesPathPrefix(pathname, path))) {
315
314
  // Local development: the service runs elsewhere; deployed, its paths never reach the app.
package/dist/proxy.d.ts CHANGED
@@ -11,5 +11,7 @@ export interface ProxyOptions {
11
11
  }
12
12
  export type SegmentStreamProxy = (request: NextRequest) => Promise<NextResponse>;
13
13
  export declare function createProxy(context: AppContext, options?: ProxyOptions): SegmentStreamProxy;
14
+ /** Discovery probes never start browser authentication, including probes for unsupported metadata. */
15
+ export declare function wellKnownResponse(request: NextRequest, ontologyUrl?: string): NextResponse | undefined;
14
16
  export declare function normalizePublicPath(path: string): string;
15
17
  export declare function matchesPathPrefix(pathname: string, prefix: string): boolean;
package/dist/proxy.js CHANGED
@@ -22,6 +22,10 @@ export function createProxy(context, options = {}) {
22
22
  }
23
23
  return async function proxy(request) {
24
24
  const pathname = request.nextUrl.pathname;
25
+ const discovery = wellKnownResponse(request);
26
+ if (discovery !== undefined) {
27
+ return discovery;
28
+ }
25
29
  if (matchesPathPrefix(pathname, SDK_ROUTE_PREFIX) ||
26
30
  publicPaths.some((path) => matchesPathPrefix(pathname, path))) {
27
31
  return NextResponse.next();
@@ -58,6 +62,26 @@ export function createProxy(context, options = {}) {
58
62
  return startSignIn(context, request, policy, true);
59
63
  };
60
64
  }
65
+ const ONTOLOGY_METADATA_PATHS = new Set([
66
+ "/.well-known/oauth-protected-resource",
67
+ "/.well-known/oauth-protected-resource/mcp",
68
+ "/.well-known/oauth-authorization-server",
69
+ ]);
70
+ /** Discovery probes never start browser authentication, including probes for unsupported metadata. */
71
+ export function wellKnownResponse(request, ontologyUrl) {
72
+ const { pathname, search } = request.nextUrl;
73
+ if (!matchesPathPrefix(pathname, "/.well-known")) {
74
+ return undefined;
75
+ }
76
+ if (ONTOLOGY_METADATA_PATHS.has(pathname)) {
77
+ return ontologyUrl === undefined
78
+ ? NextResponse.next()
79
+ : NextResponse.rewrite(new URL(`${pathname}${search}`, ontologyUrl));
80
+ }
81
+ // The issuer is the root origin, so RFC 8414 does not define an AS document suffixed by /mcp.
82
+ // This service also does not publish OpenID Connect discovery metadata.
83
+ return NextResponse.json({ error: "not_found" }, { status: 404 });
84
+ }
61
85
  /**
62
86
  * SegmentStream is unreachable. API requests get a retryable 503; pages restart sign-in,
63
87
  * which ends on the callback's error page rather than looping. Session cookies are kept.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream-cloud/app",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Sign-in, users, permissions, the ontology client and warehouse data access for SegmentStream workspace apps built with Next.js.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",