Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed May 14, 2024
1 parent 8db1dc5 commit 7b45726
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion functions/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ export {
} from "https://dev.zaubrik.com/[email protected]/type.js";
export {
type AuthInput,
} from "https://dev.zaubrik.com/[email protected].3/server/response.ts";
} from "https://dev.zaubrik.com/[email protected].4/server/mod.ts";
11 changes: 0 additions & 11 deletions functions/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
type AuthInput,
create,
decodeJwt,
isObject,
Expand Down Expand Up @@ -87,16 +86,6 @@ export async function createJwt(
}
}

export function ensureVerifyFunction(authInput: AuthInput) {
const verification = authInput.verification;
return {
...authInput,
verification: typeof verification === "function"
? verification
: verifyJwt(verification),
};
}

export function verifyJwt(input: CryptoKeyOrUpdateInput) {
const cryptoKeyPromiseOrNull = isUpdateInput(input)
? fetchRsaCryptoKey(input.url, input.algorithm)
Expand Down
3 changes: 2 additions & 1 deletion middlewares/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ export {
} from "https://dev.zaubrik.com/[email protected]/mod.ts";
export {
type AuthInput,
ensureVerify,
type Methods,
type Options,
respond,
} from "https://dev.zaubrik.com/[email protected].3/server/response.ts";
} from "https://dev.zaubrik.com/[email protected].4/server/response.ts";

export {
mergeUrl,
Expand Down
4 changes: 2 additions & 2 deletions middlewares/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
type AuthInput,
type Context,
ensureVerify,
type Methods,
type Options,
respond,
} from "./deps.ts";
import { ensureVerifyFunction } from "../functions/jwt.ts";

export function rpcRespond(
methods: Methods,
options: Options & { methodsUrl?: URL } = {},
authInput?: AuthInput | AuthInput[],
) {
const authInputArray = authInput
? [authInput].flat().map(ensureVerifyFunction)
? [authInput].flat().map(ensureVerify)
: undefined;
return async <C extends Context>(ctx: C) => {
const rpcMethods = options.methodsUrl
Expand Down

0 comments on commit 7b45726

Please sign in to comment.