Add OAuth-protected MCP server with generated API client packages
This commit is contained in:
1 parent
26e236c95c
commit
65bf19e067
235 files changed
+33755
-3199
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { getItem, removeItem, setItem } from '@/lib/storage';
|
||||
|
||||
const RETURN_URL = 'umami.return-url';
|
||||
|
||||
/** Only same-origin relative paths are accepted to prevent open redirects. */
|
||||
export function isSafeReturnUrl(value: unknown): value is string {
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
value.startsWith('/') &&
|
||||
!value.startsWith('//') &&
|
||||
!value.startsWith('/\\') &&
|
||||
!/[\r\n]/.test(value)
|
||||
);
|
||||
}
|
||||
|
||||
export function setReturnUrl(url: string) {
|
||||
if (isSafeReturnUrl(url)) {
|
||||
setItem(RETURN_URL, url, true);
|
||||
}
|
||||
}
|
||||
|
||||
export function consumeReturnUrl(): string | null {
|
||||
const value = getItem(RETURN_URL, true);
|
||||
|
||||
removeItem(RETURN_URL, true);
|
||||
|
||||
return isSafeReturnUrl(value) ? value : null;
|
||||
}
|
||||
Reference in new issue
Block a user