(ctx: &Ctx<'js>, value: Value<'js>)
| 20 | } |
| 21 | |
| 22 | impl<'js> FromJs<'js> for SigningAlgorithm { |
| 23 | fn from_js(ctx: &Ctx<'js>, value: Value<'js>) -> Result<Self> { |
| 24 | let (name, obj) = to_name_and_maybe_object(ctx, value)?; |
| 25 | let name = normalize_algorithm_name(&name); |
| 26 | |
| 27 | let algorithm = match name.as_str() { |
| 28 | "Ed25519" => SigningAlgorithm::Ed25519, |
| 29 | "HMAC" => SigningAlgorithm::Hmac, |
| 30 | "RSASSA-PKCS1-v1_5" => SigningAlgorithm::RsassaPkcs1v15, |
| 31 | "ECDSA" => { |
| 32 | let obj = obj?; |
| 33 | let hash = extract_sha_hash(ctx, &obj)?; |
| 34 | SigningAlgorithm::Ecdsa { hash } |
| 35 | }, |
| 36 | "RSA-PSS" => { |
| 37 | let salt_length = obj?.get_required("saltLength", "algorithm")?; |
| 38 | |
| 39 | SigningAlgorithm::RsaPss { salt_length } |
| 40 | }, |
| 41 | _ => return algorithm_not_supported_error(ctx), |
| 42 | }; |
| 43 | Ok(algorithm) |
| 44 | } |
| 45 | } |
nothing calls this directly
no test coverage detected