UNPKG

oidc-client-rx

Version:

ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications

63 lines (62 loc) 1.66 kB
function getVerifyAlg(alg) { switch(alg.charAt(0)){ case "R": return { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }; case "E": if (alg.includes("256")) return { name: "ECDSA", hash: "SHA-256" }; if (alg.includes("384")) return { name: "ECDSA", hash: "SHA-384" }; return null; default: return null; } } function alg2kty(alg) { switch(alg.charAt(0)){ case "R": return "RSA"; case "E": return "EC"; default: throw new Error(`Cannot infer kty from alg: ${alg}`); } } function getImportAlg(alg) { switch(alg.charAt(0)){ case "R": if (alg.includes("256")) return { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }; if (alg.includes("384")) return { name: "RSASSA-PKCS1-v1_5", hash: "SHA-384" }; if (alg.includes("512")) return { name: "RSASSA-PKCS1-v1_5", hash: "SHA-512" }; return null; case "E": if (alg.includes("256")) return { name: "ECDSA", namedCurve: "P-256" }; if (alg.includes("384")) return { name: "ECDSA", namedCurve: "P-384" }; return null; default: return null; } } export { alg2kty, getImportAlg, getVerifyAlg };