MCPcopy Create free account
hub / github.com/awslabs/llrt / from_js

Method from_js

modules/llrt_crypto/src/subtle/sign_algorithm.rs:22–42  ·  view source on GitHub ↗
(ctx: &Ctx<'js>, value: Value<'js>)

Source from the content-addressed store, hash-verified

20}
21
22impl<'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}

Callers

nothing calls this directly

Calls 6

to_name_and_maybe_objectFunction · 0.85
extract_sha_hashFunction · 0.85
or_throwMethod · 0.80
get_requiredMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected