kopia lustrzana https://github.com/cloudflare/wildebeest
add lint:functions script and make it pass
rodzic
bc2c5d7ef5
commit
920df83cad
|
@ -1,13 +1,9 @@
|
|||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import { getFollowers } from 'wildebeest/backend/src/mastodon/follow'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Activity } from 'wildebeest/backend/src/activitypub/activities'
|
||||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { actorURL } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { Note } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import * as activityCreate from 'wildebeest/backend/src/activitypub/activities/create'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, params }) => {
|
||||
const domain = new URL(request.url).hostname
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import { getFollowingId } from 'wildebeest/backend/src/mastodon/follow'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Activity } from 'wildebeest/backend/src/activitypub/activities'
|
||||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { actorURL } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { Note } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import * as activityCreate from 'wildebeest/backend/src/activitypub/activities/create'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, params }) => {
|
||||
const domain = new URL(request.url).hostname
|
||||
|
|
|
@ -3,7 +3,6 @@ import * as activityHandler from 'wildebeest/backend/src/activitypub/activities/
|
|||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import * as actors from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { Activity } from 'wildebeest/backend/src/activitypub/activities'
|
||||
import * as activities from 'wildebeest/backend/src/activitypub/activities'
|
||||
import { actorURL } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { parseRequest } from 'wildebeest/backend/src/utils/httpsigjs/parser'
|
||||
import { fetchKey, verifySignature } from 'wildebeest/backend/src/utils/httpsigjs/verifier'
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Activity } from 'wildebeest/backend/src/activitypub/activities'
|
||||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { actorURL } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { Note } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import * as activityCreate from 'wildebeest/backend/src/activitypub/activities/create'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, params }) => {
|
||||
const domain = new URL(request.url).hostname
|
||||
|
@ -17,6 +13,7 @@ const headers = {
|
|||
'content-type': 'application/json; charset=utf-8',
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO: use userKEK
|
||||
export async function handleRequest(domain: string, db: D1Database, id: string, userKEK: string): Promise<Response> {
|
||||
const handle = parseHandle(id)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ const headers = {
|
|||
|
||||
const DEFAULT_LIMIT = 20
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO: use userKEK
|
||||
export async function handleRequest(domain: string, db: D1Database, id: string, userKEK: string): Promise<Response> {
|
||||
const handle = parseHandle(id)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import { actorURL } from 'wildebeest/backend/src/activitypub/actors'
|
|||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { MastodonAccount } from 'wildebeest/backend/src/types/account'
|
||||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import type { Handle } from 'wildebeest/backend/src/utils/parse'
|
||||
import { queryAcct } from 'wildebeest/backend/src/webfinger/index'
|
||||
|
|
|
@ -2,13 +2,12 @@ import type { Env } from 'wildebeest/backend/src/types/env'
|
|||
import type { Activity } from 'wildebeest/backend/src/activitypub/activities'
|
||||
import type { Note } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import { loadExternalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
|
||||
import type { Object } from 'wildebeest/backend/src/activitypub/objects'
|
||||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { makeGetActorAsId, makeGetObjectAsId } from 'wildebeest/backend/src/activitypub/activities/handle'
|
||||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import type { Handle } from 'wildebeest/backend/src/utils/parse'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { MastodonAccount, MastodonStatus } from 'wildebeest/backend/src/types'
|
||||
import type { MastodonStatus } from 'wildebeest/backend/src/types'
|
||||
import { toMastodonStatusFromObject } from 'wildebeest/backend/src/mastodon/status'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects'
|
||||
import { actorURL } from 'wildebeest/backend/src/activitypub/actors'
|
||||
|
@ -41,6 +40,7 @@ export async function handleRequest(request: Request, db: D1Database, id: string
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO: use userKEK
|
||||
async function getRemoteStatuses(request: Request, handle: Handle, db: D1Database, userKEK: string): Promise<Response> {
|
||||
const url = new URL(request.url)
|
||||
const domain = url.hostname
|
||||
|
@ -61,6 +61,7 @@ async function getRemoteStatuses(request: Request, handle: Handle, db: D1Databas
|
|||
|
||||
const activities = await outbox.get(actor)
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO: use account
|
||||
const account = await loadExternalMastodonAccount(acct, actor)
|
||||
|
||||
const promises = activities.items.map(async (activity: Activity) => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import type { Env } from 'wildebeest/backend/src/types/env'
|
|||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { getFollowingAcct, getFollowingRequestedAcct } from 'wildebeest/backend/src/mastodon/follow'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, params, data }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, data }) => {
|
||||
return handleRequest(request, env.DATABASE, data.connectedActor)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import * as images from 'wildebeest/backend/src/media/image'
|
|||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { Actor } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { updateActorProperty } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { CredentialAccount, MastodonAccount } from 'wildebeest/backend/src/types/account'
|
||||
import type { CredentialAccount } from 'wildebeest/backend/src/types/account'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { loadLocalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { b64ToUrlEncoded, exportPublicKeyPair } from 'wildebeest/backend/src/webpush/util'
|
||||
import type { JWK } from 'wildebeest/backend/src/webpush/jwk'
|
||||
import { Env } from 'wildebeest/backend/src/types/env'
|
||||
import { createClient } from 'wildebeest/backend/src/mastodon/client'
|
||||
import { getVAPIDKeys, VAPIDPublicKey } from 'wildebeest/backend/src/mastodon/subscription'
|
||||
|
@ -12,7 +10,7 @@ type AppsPost = {
|
|||
scopes: string
|
||||
}
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, data }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env }) => {
|
||||
return handleRequest(env.DATABASE, request)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
// https://docs.joinmastodon.org/methods/notifications/#get
|
||||
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Person } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { getNotifications } from 'wildebeest/backend/src/mastodon/notification'
|
||||
import type { MastodonStatus } from 'wildebeest/backend/src/types'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, data }) => {
|
||||
return handleRequest(request, env.KV_CACHE, data.connectedActor)
|
||||
|
|
|
@ -4,7 +4,6 @@ import type { Notification } from 'wildebeest/backend/src/types/notification'
|
|||
import { urlToHandle } from 'wildebeest/backend/src/utils/handle'
|
||||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { loadExternalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Person } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
|
|
|
@ -5,10 +5,6 @@ import type { CreateRequest } from 'wildebeest/backend/src/mastodon/subscription
|
|||
import { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { Env } from 'wildebeest/backend/src/types/env'
|
||||
import * as errors from 'wildebeest/backend/src/errors'
|
||||
import type { JWK } from 'wildebeest/backend/src/webpush/jwk'
|
||||
import type { WebPushInfos, WebPushMessage, WebPushResult } from 'wildebeest/backend/src/webpush/webpushinfos'
|
||||
import { b64ToUrlEncoded, exportPublicKeyPair } from 'wildebeest/backend/src/webpush/util'
|
||||
import { generateWebPushMessage } from 'wildebeest/backend/src/webpush'
|
||||
import { getVAPIDKeys, VAPIDPublicKey } from 'wildebeest/backend/src/mastodon/subscription'
|
||||
|
||||
export const onRequestGet: PagesFunction<Env, any, ContextData> = async ({ request, env, data }) => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// https://docs.joinmastodon.org/methods/statuses/#create
|
||||
|
||||
import { loadLocalMastodonAccount } from 'wildebeest/backend/src/mastodon/account'
|
||||
import type { MediaAttachment } from 'wildebeest/backend/src/types/media'
|
||||
import { createPublicNote } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import type { Document } from 'wildebeest/backend/src/activitypub/objects'
|
||||
import { getObjectByMastodonId } from 'wildebeest/backend/src/activitypub/objects'
|
||||
|
@ -9,8 +8,6 @@ import { getMentions } from 'wildebeest/backend/src/mastodon/status'
|
|||
import * as activities from 'wildebeest/backend/src/activitypub/activities/create'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { MastodonAccount } from 'wildebeest/backend/src/types/account'
|
||||
import type { MastodonStatus } from 'wildebeest/backend/src/types/status'
|
||||
import { queryAcct } from 'wildebeest/backend/src/webfinger'
|
||||
import { deliverFollowers, deliverToActor } from 'wildebeest/backend/src/activitypub/deliver'
|
||||
import { addObjectInOutbox } from 'wildebeest/backend/src/activitypub/actors/outbox'
|
||||
|
@ -47,7 +44,7 @@ export async function handleRequest(
|
|||
return new Response('', { status: 400 })
|
||||
}
|
||||
|
||||
let mediaAttachments: Array<Document> = []
|
||||
const mediaAttachments: Array<Document> = []
|
||||
if (body.media_ids && body.media_ids.length > 0) {
|
||||
for (let i = 0, len = body.media_ids.length; i < len; i++) {
|
||||
const id = body.media_ids[i]
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
// https://docs.joinmastodon.org/methods/statuses/#get
|
||||
|
||||
import type { UUID } from 'wildebeest/backend/src/types'
|
||||
import { urlToHandle } from 'wildebeest/backend/src/utils/handle'
|
||||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import type { Person } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { getFollowers } from 'wildebeest/backend/src/mastodon/follow'
|
||||
import { getMastodonStatusById } from 'wildebeest/backend/src/mastodon/status'
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ params, request, env, data }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ params, env }) => {
|
||||
return handleRequest(env.DATABASE, params.id as UUID)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// https://docs.joinmastodon.org/methods/statuses/#favourite
|
||||
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import { insertLike } from 'wildebeest/backend/src/mastodon/like'
|
||||
import { getSigningKey } from 'wildebeest/backend/src/mastodon/account'
|
||||
import { deliverToActor } from 'wildebeest/backend/src/activitypub/deliver'
|
||||
|
@ -11,10 +10,9 @@ import * as like from 'wildebeest/backend/src/activitypub/activities/like'
|
|||
import { getObjectByMastodonId } from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Note } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { queryAcct } from 'wildebeest/backend/src/webfinger'
|
||||
import { toMastodonStatusFromObject } from 'wildebeest/backend/src/mastodon/status'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, data, params }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ env, data, params }) => {
|
||||
return handleRequest(env.DATABASE, params.id as string, data.connectedActor, env.userKEK)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// https://docs.joinmastodon.org/methods/statuses/#boost
|
||||
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import { parseHandle } from 'wildebeest/backend/src/utils/parse'
|
||||
import { addObjectInOutbox } from 'wildebeest/backend/src/activitypub/actors/outbox'
|
||||
import { insertReblog } from 'wildebeest/backend/src/mastodon/reblog'
|
||||
import { getSigningKey } from 'wildebeest/backend/src/mastodon/account'
|
||||
|
@ -12,10 +11,9 @@ import * as announce from 'wildebeest/backend/src/activitypub/activities/announc
|
|||
import { getObjectByMastodonId } from 'wildebeest/backend/src/activitypub/objects'
|
||||
import type { Note } from 'wildebeest/backend/src/activitypub/objects/note'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import { queryAcct } from 'wildebeest/backend/src/webfinger'
|
||||
import { toMastodonStatusFromObject } from 'wildebeest/backend/src/mastodon/status'
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, data, params }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ env, data, params }) => {
|
||||
return handleRequest(env.DATABASE, params.id as string, data.connectedActor, env.userKEK)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Actor } from 'wildebeest/backend/src/activitypub/actors/'
|
||||
import * as objects from 'wildebeest/backend/src/activitypub/objects/'
|
||||
import { urlToHandle } from 'wildebeest/backend/src/utils/handle'
|
||||
import { getHomeTimeline } from 'wildebeest/backend/src/mastodon/timeline'
|
||||
import { getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { MastodonAccount, MastodonStatus } from 'wildebeest/backend/src/types/'
|
||||
import * as errors from 'wildebeest/backend/src/errors'
|
||||
|
||||
const headers = {
|
||||
|
@ -14,7 +9,7 @@ const headers = {
|
|||
'content-type': 'application/json; charset=utf-8',
|
||||
}
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, params, data }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, data }) => {
|
||||
return handleRequest(request, env.KV_CACHE, data.connectedActor)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ const headers = {
|
|||
'content-type': 'application/json; charset=utf-8',
|
||||
}
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env, params, data }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env }) => {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const local = searchParams.get('local') === 'true'
|
||||
const remote = searchParams.get('remote') === 'true'
|
||||
|
@ -21,6 +21,7 @@ export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request,
|
|||
export async function handleRequest(
|
||||
domain: string,
|
||||
db: D1Database,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO: use only_media
|
||||
{ local = false, remote = false, only_media = false, offset = 0 } = {}
|
||||
): Promise<Response> {
|
||||
let localParam = LocalPreference.NotSet
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
// especially)
|
||||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Person } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { createPerson } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import * as errors from 'wildebeest/backend/src/errors'
|
||||
|
||||
export const onRequestPost: PagesFunction<Env, any, ContextData> = async ({ request, env, data }) => {
|
||||
export const onRequestPost: PagesFunction<Env, any, ContextData> = async ({ request, env }) => {
|
||||
return handlePostRequest(request, env.DATABASE, env.userKEK)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { getPersonByEmail } from 'wildebeest/backend/src/activitypub/actors'
|
|||
// Extract the JWT token sent by Access (running before us).
|
||||
const extractJWTFromRequest = (request: Request) => request.headers.get('Cf-Access-Jwt-Assertion') || ''
|
||||
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ data, request, env }) => {
|
||||
export const onRequest: PagesFunction<Env, any, ContextData> = async ({ request, env }) => {
|
||||
return handleRequest(request, env.DATABASE, env.userKEK, env.ACCESS_AUTH_DOMAIN, env.ACCESS_AUD)
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,6 @@ export async function handleRequest(
|
|||
return new Response('', { status: 403 })
|
||||
}
|
||||
|
||||
const scope = url.searchParams.get('scope') || ''
|
||||
|
||||
const jwt = extractJWTFromRequest(request)
|
||||
const validate = access.generateValidator({ jwt, domain: accessDomain, aud: accessAud })
|
||||
await validate(request)
|
||||
|
|
|
@ -9,7 +9,7 @@ type Body = {
|
|||
code: string | null
|
||||
}
|
||||
|
||||
export const onRequest: PagesFunction<Env, any> = async ({ params, request, env }) => {
|
||||
export const onRequest: PagesFunction<Env, any> = async ({ request, env }) => {
|
||||
return handleRequest(env.DATABASE, request)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,14 @@ import * as access from 'wildebeest/backend/src/access'
|
|||
import * as errors from 'wildebeest/backend/src/errors'
|
||||
import { parse } from 'cookie'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { InstanceConfig } from 'wildebeest/backend/src/config'
|
||||
import { configure } from 'wildebeest/backend/src/config'
|
||||
|
||||
export const onRequestGet: PagesFunction<Env, any, ContextData> = async ({ request, data, env }) => {
|
||||
return handleGetRequest(env.DATABASE, request)
|
||||
export const onRequestGet: PagesFunction<Env, any, ContextData> = async ({ request, env }) => {
|
||||
return handleGetRequest(env, request)
|
||||
}
|
||||
|
||||
// Route to test if Access has been configured properly
|
||||
export async function handleGetRequest(db: D1Database, request: Request): Promise<Response> {
|
||||
export async function handleGetRequest(env: Env, request: Request): Promise<Response> {
|
||||
const db = env.DATABASE
|
||||
const query = `
|
||||
SELECT * FROM instance_config WHERE key IN ('accessDomain', 'accessAud')
|
||||
`
|
||||
|
@ -37,7 +36,7 @@ export async function handleGetRequest(db: D1Database, request: Request): Promis
|
|||
const domain = env.ACCESS_AUTH_DOMAIN
|
||||
|
||||
const validator = access.generateValidator({ jwt, domain, aud: env.ACCESS_AUD })
|
||||
const { payload } = await validator(request)
|
||||
await validator(request)
|
||||
|
||||
const identity = await access.getIdentity({ jwt, domain })
|
||||
if (!identity) {
|
||||
|
|
|
@ -3,7 +3,6 @@ import type { Env } from 'wildebeest/backend/src/types/env'
|
|||
import * as errors from 'wildebeest/backend/src/errors'
|
||||
import * as access from 'wildebeest/backend/src/access'
|
||||
import { parse } from 'cookie'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { InstanceConfig } from 'wildebeest/backend/src/config'
|
||||
import * as config from 'wildebeest/backend/src/config'
|
||||
|
||||
|
@ -12,11 +11,10 @@ export const onRequestPost: PagesFunction<Env, any> = async ({ request, env }) =
|
|||
}
|
||||
|
||||
export const onRequestGet: PagesFunction<Env, any> = async (ctx) => {
|
||||
const { request, env, next } = ctx
|
||||
const { request, env } = ctx
|
||||
const cookie = parse(request.headers.get('Cookie') || '')
|
||||
const jwt = cookie['CF_Authorization']
|
||||
if (!jwt) {
|
||||
const { hostname } = new URL(request.url)
|
||||
const url = access.generateLoginURL({
|
||||
redirectURL: new URL('/start-instance', 'https://' + env.DOMAIN),
|
||||
domain: env.ACCESS_AUTH_DOMAIN,
|
||||
|
@ -44,7 +42,7 @@ export async function handlePostRequest(
|
|||
}
|
||||
|
||||
const validator = access.generateValidator({ jwt, domain: accessDomain, aud: accessAud })
|
||||
const { payload } = await validator(request)
|
||||
await validator(request)
|
||||
|
||||
const identity = await access.getIdentity({ jwt, domain: accessDomain })
|
||||
if (!identity) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
"test": "NODE_OPTIONS=--experimental-vm-modules yarn jest",
|
||||
"lint": "npx eslint .",
|
||||
"lint:be": "npx eslint backend",
|
||||
"lint:functions": "npx eslint functions",
|
||||
"build": "yarn --cwd frontend install && yarn --cwd frontend build",
|
||||
"d1": "NO_D1_WARNING=true wrangler d1",
|
||||
"pages": "NO_D1_WARNING=true wrangler pages",
|
||||
|
|
Ładowanie…
Reference in New Issue