@sentry/junior-dashboard 0.183.0 → 0.184.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/dist/app.d.ts +2 -2
- package/dist/app.js +4 -7
- package/dist/authenticated-routes.d.ts +8 -2
- package/dist/index.js +4 -7
- package/package.json +3 -3
- package/src/app.ts +7 -13
- package/src/authenticated-routes.ts +10 -3
package/dist/app.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { type JuniorApiVariables } from "@sentry/junior/api";
|
|
3
|
-
import type { JuniorAuthenticatedRoute } from "@sentry/junior";
|
|
4
3
|
import type { PluginRouteApp } from "@sentry/junior-plugin-api";
|
|
5
4
|
import { type DashboardAuth, type DashboardSession } from "./auth";
|
|
5
|
+
import { type AuthenticatedRoute } from "./authenticated-routes";
|
|
6
6
|
export interface JuniorDashboardOptions {
|
|
7
7
|
agentName?: string;
|
|
8
8
|
basePath?: string;
|
|
@@ -18,7 +18,7 @@ export interface JuniorDashboardOptions {
|
|
|
18
18
|
mockConversations?: boolean;
|
|
19
19
|
}
|
|
20
20
|
interface DashboardRuntimeOptions extends JuniorDashboardOptions {
|
|
21
|
-
authenticatedRoutes?: readonly
|
|
21
|
+
authenticatedRoutes?: readonly AuthenticatedRoute[];
|
|
22
22
|
pluginRoutes?: DashboardPluginRoute[];
|
|
23
23
|
}
|
|
24
24
|
interface DashboardPluginRoute {
|
package/dist/app.js
CHANGED
|
@@ -204,7 +204,7 @@ function resolveGoogleHostedDomainHint(domains) {
|
|
|
204
204
|
function segments(path2) {
|
|
205
205
|
return path2.split("/").filter(Boolean);
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function isAuthPath(pathname, routes) {
|
|
208
208
|
const requestSegments = segments(pathname);
|
|
209
209
|
return routes.some((route) => {
|
|
210
210
|
const routeSegments = segments(route.path);
|
|
@@ -2810,7 +2810,7 @@ function isDashboardPagePath(pathname, basePath, options = {}) {
|
|
|
2810
2810
|
return false;
|
|
2811
2811
|
}
|
|
2812
2812
|
function dashboardReturnPath(url, basePath, options = {}) {
|
|
2813
|
-
if (!isDashboardPagePath(url.pathname, basePath, options) && !
|
|
2813
|
+
if (!isDashboardPagePath(url.pathname, basePath, options) && !isAuthPath(url.pathname, options.authenticatedRoutes ?? [])) {
|
|
2814
2814
|
return void 0;
|
|
2815
2815
|
}
|
|
2816
2816
|
const path2 = `${url.pathname}${url.search}`;
|
|
@@ -2822,10 +2822,7 @@ function requestedReturnPath(url, basePath, options = {}) {
|
|
|
2822
2822
|
return void 0;
|
|
2823
2823
|
}
|
|
2824
2824
|
const returnUrl = new URL(next, url.origin);
|
|
2825
|
-
if (returnUrl.origin !== url.origin || !isDashboardPagePath(returnUrl.pathname, basePath, options) && !
|
|
2826
|
-
returnUrl.pathname,
|
|
2827
|
-
options.authenticatedRoutes ?? []
|
|
2828
|
-
)) {
|
|
2825
|
+
if (returnUrl.origin !== url.origin || !isDashboardPagePath(returnUrl.pathname, basePath, options) && !isAuthPath(returnUrl.pathname, options.authenticatedRoutes ?? [])) {
|
|
2829
2826
|
return void 0;
|
|
2830
2827
|
}
|
|
2831
2828
|
return `${returnUrl.pathname}${returnUrl.search}`;
|
|
@@ -2996,7 +2993,7 @@ function createDashboardApp(rawOptions) {
|
|
|
2996
2993
|
app.get(DASHBOARD_INSTALL_ICON_PATH, () => renderInstallIcon());
|
|
2997
2994
|
const requireAuth = async (c, next) => {
|
|
2998
2995
|
const pathname = new URL(c.req.url).pathname;
|
|
2999
|
-
const appRoute =
|
|
2996
|
+
const appRoute = isAuthPath(pathname, authenticatedRoutes);
|
|
3000
2997
|
if (appRoute) {
|
|
3001
2998
|
const canonicalUrl = canonicalRequestUrl(c.req.raw, canonicalBaseURL);
|
|
3002
2999
|
if (canonicalUrl) return Response.redirect(canonicalUrl, 302);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginRouteMethod, User } from "@sentry/junior-plugin-api";
|
|
2
|
+
/** One host route that runs after dashboard user authentication. */
|
|
3
|
+
export type AuthenticatedRoute = {
|
|
4
|
+
handler(request: Request, user: User): Promise<Response> | Response;
|
|
5
|
+
method?: PluginRouteMethod | readonly PluginRouteMethod[];
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
2
8
|
/** Return whether a request path matches one app-owned authenticated route. */
|
|
3
|
-
export declare function
|
|
9
|
+
export declare function isAuthPath(pathname: string, routes: readonly AuthenticatedRoute[]): boolean;
|
package/dist/index.js
CHANGED
|
@@ -204,7 +204,7 @@ function resolveGoogleHostedDomainHint(domains) {
|
|
|
204
204
|
function segments(path2) {
|
|
205
205
|
return path2.split("/").filter(Boolean);
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function isAuthPath(pathname, routes) {
|
|
208
208
|
const requestSegments = segments(pathname);
|
|
209
209
|
return routes.some((route) => {
|
|
210
210
|
const routeSegments = segments(route.path);
|
|
@@ -2810,7 +2810,7 @@ function isDashboardPagePath(pathname, basePath, options = {}) {
|
|
|
2810
2810
|
return false;
|
|
2811
2811
|
}
|
|
2812
2812
|
function dashboardReturnPath(url, basePath, options = {}) {
|
|
2813
|
-
if (!isDashboardPagePath(url.pathname, basePath, options) && !
|
|
2813
|
+
if (!isDashboardPagePath(url.pathname, basePath, options) && !isAuthPath(url.pathname, options.authenticatedRoutes ?? [])) {
|
|
2814
2814
|
return void 0;
|
|
2815
2815
|
}
|
|
2816
2816
|
const path2 = `${url.pathname}${url.search}`;
|
|
@@ -2822,10 +2822,7 @@ function requestedReturnPath(url, basePath, options = {}) {
|
|
|
2822
2822
|
return void 0;
|
|
2823
2823
|
}
|
|
2824
2824
|
const returnUrl = new URL(next, url.origin);
|
|
2825
|
-
if (returnUrl.origin !== url.origin || !isDashboardPagePath(returnUrl.pathname, basePath, options) && !
|
|
2826
|
-
returnUrl.pathname,
|
|
2827
|
-
options.authenticatedRoutes ?? []
|
|
2828
|
-
)) {
|
|
2825
|
+
if (returnUrl.origin !== url.origin || !isDashboardPagePath(returnUrl.pathname, basePath, options) && !isAuthPath(returnUrl.pathname, options.authenticatedRoutes ?? [])) {
|
|
2829
2826
|
return void 0;
|
|
2830
2827
|
}
|
|
2831
2828
|
return `${returnUrl.pathname}${returnUrl.search}`;
|
|
@@ -2996,7 +2993,7 @@ function createDashboardApp(rawOptions) {
|
|
|
2996
2993
|
app.get(DASHBOARD_INSTALL_ICON_PATH, () => renderInstallIcon());
|
|
2997
2994
|
const requireAuth = async (c, next) => {
|
|
2998
2995
|
const pathname = new URL(c.req.url).pathname;
|
|
2999
|
-
const appRoute =
|
|
2996
|
+
const appRoute = isAuthPath(pathname, authenticatedRoutes);
|
|
3000
2997
|
if (appRoute) {
|
|
3001
2998
|
const canonicalUrl = canonicalRequestUrl(c.req.raw, canonicalBaseURL);
|
|
3002
2999
|
if (canonicalUrl) return Response.redirect(canonicalUrl, 302);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-dashboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.184.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"react-router": "^7.18.2",
|
|
35
35
|
"shiki": "4.1.0",
|
|
36
36
|
"zod": "^4.4.3",
|
|
37
|
-
"@sentry/junior": "0.
|
|
38
|
-
"@sentry/junior-plugin-api": "0.
|
|
37
|
+
"@sentry/junior": "0.184.0",
|
|
38
|
+
"@sentry/junior-plugin-api": "0.184.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@oxlint/plugins": "1.79.0",
|
package/src/app.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
import { apiErrorSchema } from "@sentry/junior/api/schema";
|
|
11
11
|
import { initSentry } from "@sentry/junior/instrumentation";
|
|
12
12
|
import { JUNIOR_VERSION } from "@sentry/junior/version";
|
|
13
|
-
import type { JuniorAuthenticatedRoute } from "@sentry/junior";
|
|
14
13
|
import type {
|
|
15
14
|
PluginApiRouteRequestContext,
|
|
16
15
|
PluginRouteApp,
|
|
@@ -32,7 +31,7 @@ import {
|
|
|
32
31
|
type DashboardAuth,
|
|
33
32
|
type DashboardSession,
|
|
34
33
|
} from "./auth";
|
|
35
|
-
import {
|
|
34
|
+
import { isAuthPath, type AuthenticatedRoute } from "./authenticated-routes";
|
|
36
35
|
import { createMockReportingApi } from "./mock-reporting/routes";
|
|
37
36
|
import {
|
|
38
37
|
DASHBOARD_AVATAR_HEADER_PATH,
|
|
@@ -73,7 +72,7 @@ export interface JuniorDashboardOptions {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
interface DashboardRuntimeOptions extends JuniorDashboardOptions {
|
|
76
|
-
authenticatedRoutes?: readonly
|
|
75
|
+
authenticatedRoutes?: readonly AuthenticatedRoute[];
|
|
77
76
|
pluginRoutes?: DashboardPluginRoute[];
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -82,9 +81,7 @@ interface DashboardPluginRoute {
|
|
|
82
81
|
pluginName: string;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
type Variables = JuniorApiVariables & {
|
|
86
|
-
authSession: DashboardSession;
|
|
87
|
-
};
|
|
84
|
+
type Variables = JuniorApiVariables & { authSession: DashboardSession };
|
|
88
85
|
|
|
89
86
|
function hasSentryConversationLinks(): boolean {
|
|
90
87
|
return Boolean(
|
|
@@ -182,7 +179,7 @@ function isDashboardPagePath(
|
|
|
182
179
|
}
|
|
183
180
|
|
|
184
181
|
interface DashboardReturnPathOptions {
|
|
185
|
-
authenticatedRoutes?: readonly
|
|
182
|
+
authenticatedRoutes?: readonly AuthenticatedRoute[];
|
|
186
183
|
componentGallery?: boolean;
|
|
187
184
|
}
|
|
188
185
|
|
|
@@ -193,7 +190,7 @@ function dashboardReturnPath(
|
|
|
193
190
|
): string | undefined {
|
|
194
191
|
if (
|
|
195
192
|
!isDashboardPagePath(url.pathname, basePath, options) &&
|
|
196
|
-
!
|
|
193
|
+
!isAuthPath(url.pathname, options.authenticatedRoutes ?? [])
|
|
197
194
|
) {
|
|
198
195
|
return undefined;
|
|
199
196
|
}
|
|
@@ -216,10 +213,7 @@ function requestedReturnPath(
|
|
|
216
213
|
if (
|
|
217
214
|
returnUrl.origin !== url.origin ||
|
|
218
215
|
(!isDashboardPagePath(returnUrl.pathname, basePath, options) &&
|
|
219
|
-
!
|
|
220
|
-
returnUrl.pathname,
|
|
221
|
-
options.authenticatedRoutes ?? [],
|
|
222
|
-
))
|
|
216
|
+
!isAuthPath(returnUrl.pathname, options.authenticatedRoutes ?? []))
|
|
223
217
|
) {
|
|
224
218
|
return undefined;
|
|
225
219
|
}
|
|
@@ -466,7 +460,7 @@ export function createDashboardApp(
|
|
|
466
460
|
next: Next,
|
|
467
461
|
) => {
|
|
468
462
|
const pathname = new URL(c.req.url).pathname;
|
|
469
|
-
const appRoute =
|
|
463
|
+
const appRoute = isAuthPath(pathname, authenticatedRoutes);
|
|
470
464
|
if (appRoute) {
|
|
471
465
|
const canonicalUrl = canonicalRequestUrl(c.req.raw, canonicalBaseURL);
|
|
472
466
|
if (canonicalUrl) return Response.redirect(canonicalUrl, 302);
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginRouteMethod, User } from "@sentry/junior-plugin-api";
|
|
2
|
+
|
|
3
|
+
/** One host route that runs after dashboard user authentication. */
|
|
4
|
+
export type AuthenticatedRoute = {
|
|
5
|
+
handler(request: Request, user: User): Promise<Response> | Response;
|
|
6
|
+
method?: PluginRouteMethod | readonly PluginRouteMethod[];
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
2
9
|
|
|
3
10
|
function segments(path: string): string[] {
|
|
4
11
|
return path.split("/").filter(Boolean);
|
|
5
12
|
}
|
|
6
13
|
|
|
7
14
|
/** Return whether a request path matches one app-owned authenticated route. */
|
|
8
|
-
export function
|
|
15
|
+
export function isAuthPath(
|
|
9
16
|
pathname: string,
|
|
10
|
-
routes: readonly
|
|
17
|
+
routes: readonly AuthenticatedRoute[],
|
|
11
18
|
): boolean {
|
|
12
19
|
const requestSegments = segments(pathname);
|
|
13
20
|
return routes.some((route) => {
|