as-services/libs/common/jwks/jwks.js
devthejo d5febb45c8
Some checks failed
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Failing after 1m25s
/ deploy (push) Has been skipped
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Failing after 1m34s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 2m9s
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Failing after 1m42s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Failing after 1m18s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Failing after 1m22s
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m3s
chore(init): available sources
2025-04-13 10:34:01 +02:00

24 lines
534 B
JavaScript

const fs = require("fs-extra")
const fnv = require("fnv-plus")
module.exports = async function createJwks(env) {
const { JWK_FILE, OLDJWK_FILE } = env
const loadJwkFile = async (file) => {
const rawJwk = await fs.readFile(file, { encoding: "utf-8" })
const jwk = JSON.parse(rawJwk)
if (!jwk.kid) {
jwk.kid = fnv.hash(rawJwk, 128).hex()
}
return jwk
}
const keys = []
keys.push(await loadJwkFile(JWK_FILE))
if (OLDJWK_FILE) {
keys.push(await loadJwkFile(OLDJWK_FILE))
}
return keys
}