2024-10-24 17:54:08 +02:00
|
|
|
import { LoginMethod, UserCtx } from "@budibase/types"
|
2022-11-16 18:24:13 +01:00
|
|
|
|
2021-11-03 15:08:47 +01:00
|
|
|
const WEBHOOK_ENDPOINTS = new RegExp(
|
|
|
|
["webhooks/trigger", "webhooks/schema"].join("|")
|
|
|
|
)
|
|
|
|
|
2024-10-24 17:54:08 +02:00
|
|
|
export function isWebhookEndpoint(ctx: UserCtx) {
|
2021-11-03 15:08:47 +01:00
|
|
|
return WEBHOOK_ENDPOINTS.test(ctx.request.url)
|
|
|
|
}
|
2024-10-24 17:54:08 +02:00
|
|
|
|
|
|
|
export function isBrowser(ctx: UserCtx) {
|
2024-10-24 19:08:49 +02:00
|
|
|
const browser = ctx.userAgent?.browser
|
|
|
|
return browser && browser !== "unknown"
|
2024-10-24 17:54:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function isApiKey(ctx: UserCtx) {
|
|
|
|
return ctx.loginMethod === LoginMethod.API_KEY
|
|
|
|
}
|