A decentralized music tracking and discovery platform built on AT Protocol 馃幍
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
1import type { AuthOutput } from "@atproto/xrpc-server";
2import type express from "express";
3import jwt from "jsonwebtoken";
4import { env } from "./env";
5
6type ReqCtx = {
7 req: express.Request;
8};
9
10export default function authVerifier(ctx: ReqCtx): AuthOutput {
11 if (!ctx.req.headers.authorization) {
12 return {};
13 }
14
15 const bearer = (ctx.req.headers.authorization || "").split(" ")[1]?.trim();
16
17 if (bearer && bearer !== "null") {
18 const credentials = jwt.verify(bearer, env.JWT_SECRET, {
19 ignoreExpiration: true,
20 });
21
22 return {
23 credentials,
24 };
25 }
26
27 return {};
28}