Skip to content

Commit

Permalink
Expose the request context for AuthVerifier and StreamAuthVerifier as…
Browse files Browse the repository at this point in the history
… distinct types
  • Loading branch information
matthieusieben committed Aug 13, 2024
1 parent 1e37951 commit 1592625
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-starfishes-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/xrpc-server": patch
---

Expose the request context for AuthVerifier and StreamAuthVerifier as distinct types
16 changes: 12 additions & 4 deletions packages/xrpc-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,22 @@ export type XRPCStreamHandler = (ctx: {

export type AuthOutput = HandlerAuth | HandlerError

export type AuthVerifier = (ctx: {
export interface AuthVerifierContext {
req: express.Request
res: express.Response
}) => Promise<AuthOutput> | AuthOutput
}

export type AuthVerifier = (
ctx: AuthVerifierContext,
) => Promise<AuthOutput> | AuthOutput

export type StreamAuthVerifier = (ctx: {
export interface StreamAuthVerifierContext {
req: IncomingMessage
}) => Promise<AuthOutput> | AuthOutput
}

export type StreamAuthVerifier = (
ctx: StreamAuthVerifierContext,
) => Promise<AuthOutput> | AuthOutput

export type CalcKeyFn = (ctx: XRPCReqContext) => string | null
export type CalcPointsFn = (ctx: XRPCReqContext) => number
Expand Down

0 comments on commit 1592625

Please sign in to comment.