Skip to main content
Module

x/jose/runtime/subtle_dsa.ts

"JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK, JWKS with no dependencies using runtime's native crypto in Node.js, Browser, Cloudflare Workers, Electron, and Deno.
Extremely Popular
Go to Latest
File
import { isCloudflareWorkers, isNodeJs } from './env.ts'import { JOSENotSupported } from '../util/errors.ts'
export default function subtleDsa(alg: string, namedCurve?: string) { const length = parseInt(alg.substr(-3), 10) switch (alg) { case 'HS256': case 'HS384': case 'HS512': return { hash: `SHA-${length}`, name: 'HMAC' } case 'PS256': case 'PS384': case 'PS512': return { hash: `SHA-${length}`, name: 'RSA-PSS', saltLength: length >> 3 } case 'RS256': case 'RS384': case 'RS512': return { hash: `SHA-${length}`, name: 'RSASSA-PKCS1-v1_5' } case 'ES256': case 'ES384': case 'ES512': return { hash: `SHA-${length}`, name: 'ECDSA', namedCurve } case (isCloudflareWorkers() || isNodeJs()) && 'EdDSA': return <EcKeyAlgorithm>{ name: namedCurve, namedCurve } default: throw new JOSENotSupported( `alg ${alg} is not supported either by JOSE or your javascript runtime`, ) }}