mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): 🚚 Use api/ for API routes instead of server/api/
This commit is contained in:
parent
dfc0bf4595
commit
3c1b330d4b
143 changed files with 5 additions and 5 deletions
43
api/well-known/jwks/index.ts
Normal file
43
api/well-known/jwks/index.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { exportJWK } from "jose";
|
||||
import { config } from "~/packages/config-manager";
|
||||
|
||||
export const meta = applyConfig({
|
||||
allowedMethods: ["GET"],
|
||||
auth: {
|
||||
required: false,
|
||||
},
|
||||
ratelimits: {
|
||||
duration: 30,
|
||||
max: 60,
|
||||
},
|
||||
route: "/.well-known/jwks",
|
||||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.on(meta.allowedMethods, meta.route, async (context) => {
|
||||
const publicKey = await crypto.subtle.importKey(
|
||||
"spki",
|
||||
Buffer.from(config.oidc.jwt_key.split(";")[1], "base64"),
|
||||
"Ed25519",
|
||||
true,
|
||||
["verify"],
|
||||
);
|
||||
|
||||
const jwk = await exportJWK(publicKey);
|
||||
|
||||
// Remove the private key
|
||||
jwk.d = undefined;
|
||||
|
||||
return context.json({
|
||||
keys: [
|
||||
{
|
||||
...jwk,
|
||||
use: "sig",
|
||||
alg: "EdDSA",
|
||||
kid: "1",
|
||||
},
|
||||
],
|
||||
});
|
||||
}),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue