Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

feat(webauthn): parse JSON credential options with native WebIDL conversion

ldm0f11e3ecb3ffe
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials.rs
index f70c040ba..8ee84ab2d 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials.rs
@@ -6,6 +6,11 @@
use moli_webapi_declare::WebApiFunctionTemplate;
+mod base64url;
+mod json_options;
+mod schema;
+mod value;
+
use crate::{native_bridge::throw_dom_exception, util::v8str, web_api_interfaces};
#[derive(WebApiFunctionTemplate)]
@@ -38,6 +43,10 @@ struct PublicKeyCredentialDeclaration {
is_user_verifying_platform_authenticator_available: (),
#[webapi(static_method, returns_promise, length = 0, callback = client_capabilities)]
get_client_capabilities: (),
+ #[webapi(static_method = "parseCreationOptionsFromJSON", length = 1, callback = json_options::parse_creation)]
+ parse_creation_options_from_json: (),
+ #[webapi(static_method = "parseRequestOptionsFromJSON", length = 1, callback = json_options::parse_request)]
+ parse_request_options_from_json: (),
}
#[derive(WebApiFunctionTemplate)]
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/base64url.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/base64url.rs
new file mode 100644
index 000000000..5fd0cb9af
--- /dev/null
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/base64url.rs
@@ -0,0 +1,26 @@
+use base64::{
+ Engine as _, alphabet,
+ engine::{DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig},
+};
+
+use super::value::Text;
+
+// WebAuthn base64url has no padding. Unused bits in the last digit need not be
+// zero, but whitespace and the ordinary base64 alphabet are invalid. Callers
+// supply the API-specific exception: JSON uses EncodingError, signals TypeError.
+const BASE64URL: GeneralPurpose = GeneralPurpose::new(
+ &alphabet::URL_SAFE,
+ GeneralPurposeConfig::new()
+ .with_decode_padding_mode(DecodePaddingMode::RequireNone)
+ .with_decode_allow_trailing_bits(true),
+);
+
+pub(super) fn decode(text: &Text) -> Option<Vec<u8>> {
+ let ascii = text
+ .0
+ .0
+ .iter()
+ .map(|&unit| (unit <= 0x7f).then_some(unit as u8))
+ .collect::<Option<Vec<_>>>()?;
+ BASE64URL.decode(ascii).ok()
+}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options.rs
new file mode 100644
index 000000000..2d3896892
--- /dev/null
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options.rs
@@ -0,0 +1,53 @@
+//! WebAuthn JSON option conversion is independent of authenticator availability.
+//!
+//! Finish WebIDL conversion (including nested getters and iterable/record
+//! conversion) before decoding any base64url values. Conversion errors retain
+//! their TypeError/original JavaScript exception; decoding errors are EncodingError.
+
+mod encode;
+mod schema;
+
+use crate::webidl;
+
+use super::value::Dictionary;
+use schema::{CreationJson, RequestJson};
+
+#[derive(webidl::WebIdlArgs)]
+#[webidl(prefix = "PublicKeyCredential.parseCreationOptionsFromJSON")]
+struct CreationArgs {
+ #[webidl(required, converter = "raw")]
+ options: Dictionary<CreationJson>,
+}
+
+#[derive(webidl::WebIdlArgs)]
+#[webidl(prefix = "PublicKeyCredential.parseRequestOptionsFromJSON")]
+struct RequestArgs {
+ #[webidl(required, converter = "raw")]
+ options: Dictionary<RequestJson>,
+}
+
+pub(super) fn parse_creation<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ args: v8::FunctionCallbackArguments<'s>,
+ mut rv: v8::ReturnValue<'s>,
+) {
+ let Some(parsed) = webidl::parse_args::<CreationArgs>(scope, &args) else {
+ return;
+ };
+ if let Some(result) = encode::creation(scope, &parsed.options.0) {
+ rv.set(result.into());
+ }
+}
+
+pub(super) fn parse_request<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ args: v8::FunctionCallbackArguments<'s>,
+ mut rv: v8::ReturnValue<'s>,
+) {
+ let Some(parsed) = webidl::parse_args::<RequestArgs>(scope, &args) else {
+ return;
+ };
+ if let Some(result) = encode::request(scope, &parsed.options.0) {
+ rv.set(result.into());
+ }
+}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options/encode.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options/encode.rs
new file mode 100644
index 000000000..17ab248a1
--- /dev/null
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options/encode.rs
@@ -0,0 +1,292 @@
+use moli_webapi_declare::WebApiValue;
+
+use crate::{native_bridge::throw_dom_exception, webidl};
+
+use super::super::{
+ base64url,
+ value::{Dictionary, Text},
+};
+use super::schema::{
+ CreationJson, DescriptorJson, ExtensionsJson, LargeBlobJson, Parameters, PrfJson,
+ PrfValuesJson, RelyingParty, RequestJson, Selection, UserJson,
+};
+
+fn member<'s, T: WebApiValue<'s> + ?Sized>(
+ scope: &mut v8::PinScope<'s, '_>,
+ object: v8::Local<'s, v8::Object>,
+ name: &str,
+ value: &T,
+) -> Option<()> {
+ let name = v8::String::new(scope, name)?;
+ let value = value.to_v8_value(scope)?;
+ object
+ .create_data_property(scope, name.into(), value)?
+ .then_some(())
+}
+
+fn optional<'s, T: WebApiValue<'s>>(
+ scope: &mut v8::PinScope<'s, '_>,
+ object: v8::Local<'s, v8::Object>,
+ name: &str,
+ value: &Option<T>,
+) -> Option<()> {
+ if let Some(value) = value {
+ member(scope, object, name, value)?;
+ }
+ Some(())
+}
+
+fn invalid_base64url<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+) -> Option<v8::Local<'s, v8::ArrayBuffer>> {
+ throw_dom_exception(scope, "EncodingError", 0, "Invalid base64url data.");
+ None
+}
+
+fn buffer<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ text: &Text,
+) -> Option<v8::Local<'s, v8::ArrayBuffer>> {
+ let Some(bytes) = base64url::decode(text) else {
+ return invalid_base64url(scope);
+ };
+ let backing_store = v8::ArrayBuffer::new_backing_store_from_vec(bytes).make_shared();
+ Some(v8::ArrayBuffer::with_backing_store(scope, &backing_store))
+}
+
+fn optional_buffer<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ object: v8::Local<'s, v8::Object>,
+ name: &str,
+ value: &Option<Text>,
+) -> Option<()> {
+ if let Some(value) = value {
+ let decoded = buffer(scope, value)?;
+ member(scope, object, name, &decoded)?;
+ }
+ Some(())
+}
+
+fn sequence<'s, T>(
+ scope: &mut v8::PinScope<'s, '_>,
+ values: &webidl::Sequence<Dictionary<T>>,
+ encode: fn(&mut v8::PinScope<'s, '_>, &T) -> Option<v8::Local<'s, v8::Object>>,
+) -> Option<v8::Local<'s, v8::Value>> {
+ let mut result = Vec::with_capacity(values.0.len());
+ for value in &values.0 {
+ result.push(encode(scope, &value.0)?);
+ }
+ result.to_v8_value(scope)
+}
+
+pub(super) fn creation<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ options: &CreationJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ member(scope, result, "attestation", &options.attestation)?;
+ member(
+ scope,
+ result,
+ "attestationFormats",
+ &options.attestation_formats.0,
+ )?;
+ if let Some(value) = &options.authenticator_selection {
+ let value = selection(scope, &value.0)?;
+ member(scope, result, "authenticatorSelection", &value)?;
+ }
+ let challenge = buffer(scope, &options.challenge)?;
+ member(scope, result, "challenge", &challenge)?;
+ let excluded = sequence(scope, &options.exclude_credentials, descriptor)?;
+ member(scope, result, "excludeCredentials", &excluded)?;
+ if let Some(value) = &options.extensions {
+ let value = extensions(scope, &value.0)?;
+ member(scope, result, "extensions", &value)?;
+ }
+ member(scope, result, "hints", &options.hints.0)?;
+ let parameters = sequence(scope, &options.pub_key_cred_params, parameters)?;
+ member(scope, result, "pubKeyCredParams", &parameters)?;
+ let rp = relying_party(scope, &options.rp.0)?;
+ member(scope, result, "rp", &rp)?;
+ optional(scope, result, "timeout", &options.timeout)?;
+ let user = user(scope, &options.user.0)?;
+ member(scope, result, "user", &user)?;
+ Some(result)
+}
+
+pub(super) fn request<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ options: &RequestJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ let allowed = sequence(scope, &options.allow_credentials, descriptor)?;
+ member(scope, result, "allowCredentials", &allowed)?;
+ let challenge = buffer(scope, &options.challenge)?;
+ member(scope, result, "challenge", &challenge)?;
+ if let Some(value) = &options.extensions {
+ let value = extensions(scope, &value.0)?;
+ member(scope, result, "extensions", &value)?;
+ }
+ member(scope, result, "hints", &options.hints.0)?;
+ optional(scope, result, "rpId", &options.rp_id)?;
+ optional(scope, result, "timeout", &options.timeout)?;
+ member(
+ scope,
+ result,
+ "userVerification",
+ &options.user_verification,
+ )?;
+ Some(result)
+}
+
+fn relying_party<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &RelyingParty,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ member(scope, result, "name", &value.base.name)?;
+ optional(scope, result, "id", &value.id)?;
+ Some(result)
+}
+
+fn user<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &UserJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ // The output is PublicKeyCredentialUserEntity, whose name is inherited.
+ member(scope, result, "name", &value.name)?;
+ member(scope, result, "displayName", &value.display_name)?;
+ let id = buffer(scope, &value.id)?;
+ member(scope, result, "id", &id)?;
+ Some(result)
+}
+
+fn parameters<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &Parameters,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ member(scope, result, "alg", &value.alg)?;
+ member(scope, result, "type", &value.credential_type)?;
+ Some(result)
+}
+
+fn descriptor<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &DescriptorJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ let id = buffer(scope, &value.id)?;
+ member(scope, result, "id", &id)?;
+ if let Some(transports) = &value.transports {
+ member(scope, result, "transports", &transports.0)?;
+ }
+ member(scope, result, "type", &value.credential_type)?;
+ Some(result)
+}
+
+fn selection<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &Selection,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ optional(
+ scope,
+ result,
+ "authenticatorAttachment",
+ &value.authenticator_attachment,
+ )?;
+ member(
+ scope,
+ result,
+ "requireResidentKey",
+ &value.require_resident_key,
+ )?;
+ optional(scope, result, "residentKey", &value.resident_key)?;
+ member(scope, result, "userVerification", &value.user_verification)?;
+ Some(result)
+}
+
+fn extensions<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &ExtensionsJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ optional(scope, result, "appid", &value.appid)?;
+ optional(scope, result, "appidExclude", &value.appid_exclude)?;
+ optional_buffer(scope, result, "credBlob", &value.cred_blob)?;
+ optional(scope, result, "credProps", &value.cred_props)?;
+ optional(
+ scope,
+ result,
+ "credentialProtectionPolicy",
+ &value.credential_protection_policy,
+ )?;
+ member(
+ scope,
+ result,
+ "enforceCredentialProtectionPolicy",
+ &value.enforce_credential_protection_policy,
+ )?;
+ optional(scope, result, "getCredBlob", &value.get_cred_blob)?;
+ optional(scope, result, "hmacCreateSecret", &value.hmac_create_secret)?;
+ if let Some(value) = &value.large_blob {
+ let value = large_blob(scope, &value.0)?;
+ member(scope, result, "largeBlob", &value)?;
+ }
+ optional(scope, result, "minPinLength", &value.min_pin_length)?;
+ if let Some(value) = &value.prf {
+ let value = prf(scope, &value.0)?;
+ member(scope, result, "prf", &value)?;
+ }
+ optional(
+ scope,
+ result,
+ "remoteClientDataJSON",
+ &value.remote_client_data_json,
+ )?;
+ Some(result)
+}
+
+fn large_blob<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &LargeBlobJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ optional(scope, result, "read", &value.read)?;
+ optional(scope, result, "support", &value.support)?;
+ optional_buffer(scope, result, "write", &value.write)?;
+ Some(result)
+}
+
+fn prf<'s>(scope: &mut v8::PinScope<'s, '_>, value: &PrfJson) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ if let Some(value) = &value.eval {
+ let value = prf_values(scope, &value.0)?;
+ member(scope, result, "eval", &value)?;
+ }
+ if let Some(record) = &value.eval_by_credential {
+ let entries = v8::Object::new(scope);
+ for (key, value) in &record.0 {
+ let key = v8::Local::<v8::Name>::try_from(key.to_v8_value(scope)?).ok()?;
+ let value = prf_values(scope, &value.0)?;
+ if entries.create_data_property(scope, key, value.into()) != Some(true) {
+ return None;
+ }
+ }
+ member(scope, result, "evalByCredential", &entries)?;
+ }
+ Some(result)
+}
+
+fn prf_values<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: &PrfValuesJson,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let result = v8::Object::new(scope);
+ let first = buffer(scope, &value.first)?;
+ member(scope, result, "first", &first)?;
+ optional_buffer(scope, result, "second", &value.second)?;
+ Some(result)
+}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options/schema.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options/schema.rs
new file mode 100644
index 000000000..756b42109
--- /dev/null
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/json_options/schema.rs
@@ -0,0 +1,125 @@
+use crate::webidl;
+
+pub(super) use super::super::schema::{Parameters, RelyingParty, Selection};
+use super::super::value::{Dictionary, Text};
+
+// The derive orders each dictionary's final member names lexicographically;
+// inherited dictionaries such as RelyingParty declare their base explicitly.
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialCreationOptionsJSON")]
+pub(super) struct CreationJson {
+ #[webidl(converter = "raw", default = Text::from("none"))]
+ pub(super) attestation: Text,
+ #[webidl(converter = "raw", default = webidl::Sequence(Vec::new()))]
+ pub(super) attestation_formats: webidl::Sequence<Text>,
+ #[webidl(converter = "raw")]
+ pub(super) authenticator_selection: Option<Dictionary<Selection>>,
+ #[webidl(required, converter = "raw")]
+ pub(super) challenge: Text,
+ #[webidl(converter = "raw", default = webidl::Sequence(Vec::new()))]
+ pub(super) exclude_credentials: webidl::Sequence<Dictionary<DescriptorJson>>,
+ #[webidl(converter = "raw")]
+ pub(super) extensions: Option<Dictionary<ExtensionsJson>>,
+ #[webidl(converter = "raw", default = webidl::Sequence(Vec::new()))]
+ pub(super) hints: webidl::Sequence<Text>,
+ #[webidl(required, converter = "raw")]
+ pub(super) pub_key_cred_params: webidl::Sequence<Dictionary<Parameters>>,
+ #[webidl(required, converter = "raw")]
+ pub(super) rp: Dictionary<RelyingParty>,
+ pub(super) timeout: Option<u32>,
+ #[webidl(required, converter = "raw")]
+ pub(super) user: Dictionary<UserJson>,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialRequestOptionsJSON")]
+pub(super) struct RequestJson {
+ #[webidl(converter = "raw", default = webidl::Sequence(Vec::new()))]
+ pub(super) allow_credentials: webidl::Sequence<Dictionary<DescriptorJson>>,
+ #[webidl(required, converter = "raw")]
+ pub(super) challenge: Text,
+ #[webidl(converter = "raw")]
+ pub(super) extensions: Option<Dictionary<ExtensionsJson>>,
+ #[webidl(converter = "raw", default = webidl::Sequence(Vec::new()))]
+ pub(super) hints: webidl::Sequence<Text>,
+ #[webidl(converter = "raw")]
+ pub(super) rp_id: Option<Text>,
+ pub(super) timeout: Option<u32>,
+ #[webidl(converter = "raw", default = Text::from("preferred"))]
+ pub(super) user_verification: Text,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialUserEntityJSON")]
+pub(super) struct UserJson {
+ #[webidl(required, converter = "raw")]
+ pub(super) display_name: Text,
+ #[webidl(required, converter = "raw")]
+ pub(super) id: Text,
+ #[webidl(required, converter = "raw")]
+ pub(super) name: Text,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialDescriptorJSON")]
+pub(super) struct DescriptorJson {
+ #[webidl(required, converter = "raw")]
+ pub(super) id: Text,
+ #[webidl(converter = "raw")]
+ pub(super) transports: Option<webidl::Sequence<Text>>,
+ #[webidl(required, name = "type", converter = "raw")]
+ pub(super) credential_type: Text,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "AuthenticationExtensionsClientInputsJSON")]
+pub(super) struct ExtensionsJson {
+ #[webidl(converter = "raw")]
+ pub(super) appid: Option<Text>,
+ #[webidl(converter = "raw")]
+ pub(super) appid_exclude: Option<Text>,
+ #[webidl(converter = "raw")]
+ pub(super) cred_blob: Option<Text>,
+ pub(super) cred_props: Option<bool>,
+ #[webidl(converter = "usv_string")]
+ pub(super) credential_protection_policy: Option<String>,
+ #[webidl(default = false)]
+ pub(super) enforce_credential_protection_policy: bool,
+ pub(super) get_cred_blob: Option<bool>,
+ pub(super) hmac_create_secret: Option<bool>,
+ #[webidl(converter = "raw")]
+ pub(super) large_blob: Option<Dictionary<LargeBlobJson>>,
+ pub(super) min_pin_length: Option<bool>,
+ #[webidl(converter = "raw")]
+ pub(super) prf: Option<Dictionary<PrfJson>>,
+ #[webidl(name = "remoteClientDataJSON", converter = "raw")]
+ pub(super) remote_client_data_json: Option<Text>,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "AuthenticationExtensionsLargeBlobInputsJSON")]
+pub(super) struct LargeBlobJson {
+ pub(super) read: Option<bool>,
+ #[webidl(converter = "raw")]
+ pub(super) support: Option<Text>,
+ #[webidl(converter = "raw")]
+ pub(super) write: Option<Text>,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "AuthenticationExtensionsPRFInputsJSON")]
+pub(super) struct PrfJson {
+ #[webidl(converter = "raw")]
+ pub(super) eval: Option<Dictionary<PrfValuesJson>>,
+ #[webidl(converter = "raw")]
+ pub(super) eval_by_credential: Option<webidl::Record<Text, Dictionary<PrfValuesJson>>>,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "AuthenticationExtensionsPRFValuesJSON")]
+pub(super) struct PrfValuesJson {
+ #[webidl(required, converter = "raw")]
+ pub(super) first: Text,
+ #[webidl(converter = "raw")]
+ pub(super) second: Option<Text>,
+}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/schema.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/schema.rs
new file mode 100644
index 000000000..550f69570
--- /dev/null
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/schema.rs
@@ -0,0 +1,43 @@
+//! WebAuthn dictionaries whose member types are identical for binary and JSON inputs.
+
+use crate::webidl;
+
+use super::value::Text;
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialEntity")]
+pub(super) struct Entity {
+ #[webidl(required, converter = "raw")]
+ pub(super) name: Text,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialRpEntity")]
+pub(super) struct RelyingParty {
+ #[webidl(inherit)]
+ pub(super) base: Entity,
+ #[webidl(converter = "raw")]
+ pub(super) id: Option<Text>,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "PublicKeyCredentialParameters")]
+pub(super) struct Parameters {
+ #[webidl(required)]
+ pub(super) alg: i32,
+ #[webidl(required, name = "type", converter = "raw")]
+ pub(super) credential_type: Text,
+}
+
+#[derive(webidl::WebIdlDictionary)]
+#[webidl(prefix = "AuthenticatorSelectionCriteria")]
+pub(super) struct Selection {
+ #[webidl(converter = "raw")]
+ pub(super) authenticator_attachment: Option<Text>,
+ #[webidl(default = false)]
+ pub(super) require_resident_key: bool,
+ #[webidl(converter = "raw")]
+ pub(super) resident_key: Option<Text>,
+ #[webidl(converter = "raw", default = Text::from("preferred"))]
+ pub(super) user_verification: Text,
+}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/value.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/value.rs
new file mode 100644
index 000000000..cd2809014
--- /dev/null
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/credentials/value.rs
@@ -0,0 +1,64 @@
+use moli_webapi_declare::WebApiValue;
+
+use crate::{util::new_null_prototype_object, webidl};
+
+/// Preserve every DOMString code unit, including lone surrogates in labels and
+/// PRF record keys and signal user details. Base64url values must still be ASCII
+/// when they are decoded.
+#[derive(Clone, PartialEq)]
+pub(super) struct Text(pub(super) webidl::DomString16);
+
+impl From<&str> for Text {
+ fn from(value: &str) -> Self {
+ Self(webidl::DomString16(value.encode_utf16().collect()))
+ }
+}
+
+impl<'s> webidl::WebIdlConverter<'s> for Text {
+ type Options = ();
+
+ fn convert(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: v8::Local<'s, v8::Value>,
+ context: webidl::Context,
+ _options: &Self::Options,
+ ) -> Result<Self, webidl::WebIdlError> {
+ webidl::convert::<webidl::DomString16>(scope, value, context).map(Self)
+ }
+}
+
+impl<'s> WebApiValue<'s> for Text {
+ fn to_v8_value(&self, scope: &mut v8::PinScope<'s, '_>) -> Option<v8::Local<'s, v8::Value>> {
+ v8::String::new_from_two_byte(scope, &self.0.0, v8::NewStringType::Normal).map(Into::into)
+ }
+}
+
+pub(super) struct Dictionary<T>(pub(super) T);
+
+impl<T> Dictionary<T> {
+ pub(super) fn empty<'s>(scope: &mut v8::PinScope<'s, '_>) -> Result<Self, webidl::WebIdlError>
+ where
+ T: webidl::WebIdlDictionary<'s>,
+ {
+ let object = new_null_prototype_object(scope);
+ T::parse_dictionary(scope, object).map(Self)
+ }
+}
+
+impl<'s, T: webidl::WebIdlDictionary<'s>> webidl::WebIdlConverter<'s> for Dictionary<T> {
+ type Options = ();
+
+ fn convert(
+ scope: &mut v8::PinScope<'s, '_>,
+ value: v8::Local<'s, v8::Value>,
+ context: webidl::Context,
+ _options: &Self::Options,
+ ) -> Result<Self, webidl::WebIdlError> {
+ match webidl::dictionary_value(value, context)? {
+ Some(object) => T::parse_dictionary(scope, object).map(Self),
+ // null/undefined mean an empty dictionary, not an Object whose
+ // prototype could contribute author-installed dictionary members.
+ None => Self::empty(scope),
+ }
+ }
+}
diff --git a/moli-renderer-v8/src/script_vm/tests/credential_json_options.js b/moli-renderer-v8/src/script_vm/tests/credential_json_options.js
new file mode 100644
index 000000000..8735fdb7e
--- /dev/null
+++ b/moli-renderer-v8/src/script_vm/tests/credential_json_options.js
@@ -0,0 +1,236 @@
+(() => {
+ const facts = {complete: false, checks: [], traces: [], versionShapes: []};
+ const assert = (ok, message) => { if (!ok) throw Error(message); };
+ const same = (actual, expected) => assert(JSON.stringify(actual) === JSON.stringify(expected), JSON.stringify({actual, expected}));
+ const minimal = () => ({challenge: 'dGVzdA', rp: {name: 'rp'}, user: {id: 'AA', name: 'user', displayName: 'User'}, pubKeyCredParams: [{alg: -7, type: 'public-key'}]});
+ const bytes = value => [...new Uint8Array(value)];
+ const worlds = [['main', globalThis], ['iframe', document.getElementById('child').contentWindow]];
+ for (const [realm, w] of worlds) {
+ const create = w.PublicKeyCredential.parseCreationOptionsFromJSON;
+ const request = w.PublicKeyCredential.parseRequestOptionsFromJSON;
+ const run = (name, fn) => {
+ try {
+ assert(typeof create === 'function' && typeof request === 'function', 'Missing JSON conversion methods');
+ fn(); facts.checks.push({realm, name, passed: true});
+ } catch (error) {
+ facts.checks.push({realm, name, passed: false, error: error.name, message: error.message});
+ }
+ };
+ const throws = (fn, Constructor, name) => {
+ let error; try { fn(); } catch (caught) { error = caught; }
+ assert(error instanceof Constructor, 'Wrong exception constructor or realm');
+ if (name) { assert(error.name === name && error.code === 0, 'Wrong DOMException name or code'); }
+ return error;
+ };
+ run('native descriptors and static receivers', () => {
+ let traps = 0;
+ const trap = () => { traps++; throw Error('Author receiver or extra argument'); };
+ const revoked = Proxy.revocable({}, {}); revoked.revoke();
+ for (const [name, fn] of [['parseCreationOptionsFromJSON', create], ['parseRequestOptionsFromJSON', request]]) {
+ const descriptor = Object.getOwnPropertyDescriptor(w.PublicKeyCredential, name);
+ assert(descriptor.enumerable && descriptor.configurable && descriptor.writable && fn.length === 1 && fn.name === name, 'Method descriptor');
+ assert(Function.prototype.toString.call(fn).includes('[native code]'), 'Native function');
+ for (const receiver of [null, {}, revoked.proxy, new Proxy({}, {get: trap, getPrototypeOf: trap})]) {
+ fn.call(receiver, fn === create ? minimal() : {challenge: 'AA'}, {toString: trap});
+ }
+ }
+ assert(traps === 0, 'Static receivers and excess arguments are ignored');
+ });
+ run('request defaults and dictionary data properties', () => {
+ const result = request({challenge: 'AA'});
+ same(Object.keys(result), ['allowCredentials', 'challenge', 'hints', 'userVerification']);
+ same(bytes(result.challenge), [0]);
+ assert(result.challenge instanceof w.ArrayBuffer && Object.getPrototypeOf(result) === w.Object.prototype, 'Callee objects');
+ assert(result.allowCredentials instanceof w.Array && result.hints instanceof w.Array, 'Callee arrays');
+ assert(result.userVerification === 'preferred', 'Verification default');
+ for (const key of Object.keys(result)) {
+ const d = Object.getOwnPropertyDescriptor(result, key);
+ assert(d.enumerable && d.configurable && d.writable && !d.get && !d.set, 'Own data property');
+ }
+ });
+ run('creation buffers, required entities and defaults', () => {
+ const result = create(minimal());
+ same(bytes(result.challenge), [116, 101, 115, 116]); same(bytes(result.user.id), [0]);
+ same(Object.keys(result.rp), ['name']); same(Object.keys(result.user), ['name', 'displayName', 'id']);
+ same(result.excludeCredentials, []); same(result.hints, []);
+ assert(result.attestation === 'none' && result.pubKeyCredParams[0].alg === -7, 'Defaults and parameters');
+ assert(result.user.id instanceof w.ArrayBuffer && Object.getPrototypeOf(result.user) === w.Object.prototype, 'Nested callee values');
+ facts.versionShapes.push({realm, creationKeys: Object.keys(result), selection: create({...minimal(), authenticatorSelection: {}}).authenticatorSelection, emptyExtensions: request({challenge: 'AA', extensions: {}}).extensions});
+ });
+ run('current-idl/attestationFormats default and conversion', () => {
+ same(create(minimal()).attestationFormats, []);
+ same(create({...minimal(), attestationFormats: new Set(['packed', 'future', 'packed'])}).attestationFormats, ['packed', 'future']);
+ });
+ run('current-idl/selection verification default', () => {
+ const result = create({...minimal(), authenticatorSelection: null}).authenticatorSelection;
+ assert(result.requireResidentKey === false && result.userVerification === 'preferred', 'Selection defaults');
+ });
+ run('current-idl/optional credProps is absent', () => {
+ const result = request({challenge: 'AA', extensions: null}).extensions;
+ assert(!Object.hasOwn(result, 'credProps') && result.enforceCredentialProtectionPolicy === false, 'Optional and default extension fields');
+ });
+ run('current-idl/remoteClientDataJSON is DOMString', () => {
+ const result = request({challenge: 'AA', extensions: {remoteClientDataJSON: 'not base64\ud800'}});
+ assert(result.extensions.remoteClientDataJSON === 'not base64\ud800', 'Remote client data string');
+ });
+ const valid = [['', []], ['Zg', [102]], ['Zh', [102]], ['-w', [251]], ['_w', [255]], ['AA', [0]], ['null', [158, 233, 101]], ['AAEC_w', [0, 1, 2, 255]]];
+ for (const [input, expected] of valid) run('base64url accepts/' + JSON.stringify(input), () => {
+ same(bytes(request({challenge: input}).challenge), expected);
+ same(bytes(create({...minimal(), challenge: input}).challenge), expected);
+ });
+ for (const input of ['Zg==', 'Zh==', 'Zg=', 'Zg===', 'Zg====', 'Z', 'Zg ', ' Zg', 'Zg\n', '+w', '/w', 'AA==', 'AA=', 'A===', '====', 'a\ud800']) run('base64url rejects/' + JSON.stringify(input), () => {
+ throws(() => request({challenge: input}), w.DOMException, 'EncodingError');
+ throws(() => create({...minimal(), challenge: input}), w.DOMException, 'EncodingError');
+ });
+ const invalidPaths = [
+ ['user.id', () => create({...minimal(), user: {id: '=', name: 'N', displayName: 'D'}})],
+ ['excludeCredentials.id', () => create({...minimal(), excludeCredentials: [{id: '=', type: 'public-key'}]})],
+ ['allowCredentials.id', () => request({challenge: 'AA', allowCredentials: [{id: '=', type: 'public-key'}]})],
+ ['credBlob', () => request({challenge: 'AA', extensions: {credBlob: '='}})],
+ ['largeBlob.write', () => request({challenge: 'AA', extensions: {largeBlob: {write: '='}}})],
+ ['prf.eval.first', () => request({challenge: 'AA', extensions: {prf: {eval: {first: '='}}}})],
+ ['prf.eval.second', () => request({challenge: 'AA', extensions: {prf: {eval: {first: 'AA', second: '='}}}})],
+ ['prf.record.first', () => request({challenge: 'AA', extensions: {prf: {evalByCredential: {key: {first: '='}}}}})],
+ ['prf.record.second', () => request({challenge: 'AA', extensions: {prf: {evalByCredential: {key: {first: 'AA', second: '='}}}}})]
+ ];
+ for (const [path, fn] of invalidPaths) run('nested EncodingError/' + path, () => throws(fn, w.DOMException, 'EncodingError'));
+ run('all recognized binary extension fields', () => {
+ const extensions = {appid: 'app', appidExclude: 'exclude', credProps: true, credBlob: '-w', getCredBlob: true, hmacCreateSecret: true, minPinLength: true, credentialProtectionPolicy: 'future', enforceCredentialProtectionPolicy: true, largeBlob: {read: true, support: 'future', write: 'AA'}, prf: {eval: {first: 'Zg', second: ''}, evalByCredential: {key: {first: '_w', second: 'Zh'}}}};
+ for (const result of [create({...minimal(), extensions}), request({challenge: 'AA', extensions})]) {
+ const e = result.extensions;
+ same(bytes(e.credBlob), [251]); same(bytes(e.largeBlob.write), [0]);
+ same(bytes(e.prf.eval.first), [102]); same(bytes(e.prf.eval.second), []);
+ same(bytes(e.prf.evalByCredential.key.first), [255]); same(bytes(e.prf.evalByCredential.key.second), [102]);
+ assert(e.appid === 'app' && e.appidExclude === 'exclude' && e.credProps && e.getCredBlob && e.hmacCreateSecret && e.minPinLength && e.enforceCredentialProtectionPolicy, 'Recognized scalars');
+ assert(e.credentialProtectionPolicy === 'future' && e.largeBlob.support === 'future', 'Future string values');
+ }
+ });
+ run('DOMString code units and unknown future string values', () => {
+ const s = '\ud800X\udfff';
+ const result = create({...minimal(), attestation: s, hints: [s, s], rp: {name: s, id: s}, user: {id: 'AA', name: s, displayName: s}, pubKeyCredParams: [{alg: -7, type: s}], authenticatorSelection: {authenticatorAttachment: s, residentKey: s, userVerification: s}, excludeCredentials: [{id: '', type: s, transports: [s]}], extensions: {appid: s, credentialProtectionPolicy: s}});
+ assert(result.attestation === s && result.rp.name === s && result.rp.id === s && result.user.name === s && result.user.displayName === s && result.pubKeyCredParams[0].type === s, 'Lossless DOMString');
+ same(result.hints, [s, s]); same(result.excludeCredentials[0].transports, [s]);
+ assert(result.authenticatorSelection.residentKey === s && result.extensions.appid === s, 'Nested lossless DOMString');
+ assert(result.extensions.credentialProtectionPolicy === '\ufffdX\ufffd', 'USVString FIDO field');
+ });
+ run('integer modulo, null strings and optional absence', () => {
+ const r = request({challenge: null, rpId: null, timeout: -1, userVerification: 'future'});
+ same(bytes(r.challenge), [158, 233, 101]);
+ assert(r.rpId === 'null' && r.timeout === 4294967295 && r.userVerification === 'future', 'WebIDL scalar conversions');
+ const c = create({...minimal(), timeout: 4294967297, pubKeyCredParams: [{alg: 4294967289, type: 'future'}], excludeCredentials: [{id: '', type: 'future'}]});
+ assert(c.timeout === 1 && c.pubKeyCredParams[0].alg === -7 && !Object.hasOwn(c.excludeCredentials[0], 'transports'), 'Integer modulo and optional fields');
+ });
+ run('arity, primitive dictionaries and required nested fields', () => {
+ for (const fn of [create, request]) {
+ throws(() => fn(), w.TypeError);
+ for (const value of [undefined, null, {}, 1, 'string', true, Symbol('dict')]) throws(() => fn(value), w.TypeError);
+ }
+ for (const options of [{...minimal(), rp: null}, {...minimal(), user: {}}, {...minimal(), pubKeyCredParams: [{}]}, {...minimal(), excludeCredentials: [{type: 'public-key'}]}]) throws(() => create(options), w.TypeError);
+ throws(() => request({challenge: Symbol('string')}), w.TypeError);
+ throws(() => request({challenge: 'AA', timeout: 1n}), w.TypeError);
+ throws(() => request({challenge: 'AA', extensions: {prf: {eval: {}}}}), w.TypeError);
+ });
+ run('iterable sequences and conversion once', () => {
+ let iterators = 0, strings = 0;
+ const hints = {[Symbol.iterator]() { iterators++; return [ {toString() { strings++; return 'hint'; }} ][Symbol.iterator](); }};
+ const result = create({...minimal(), hints, pubKeyCredParams: new Set([{alg: -7, type: 'public-key'}]), excludeCredentials: new Set([{id: 'AA', type: 'public-key', transports: new Set(['usb', 'nfc'])}])});
+ same(result.hints, ['hint']); same(result.excludeCredentials[0].transports, ['usb', 'nfc']);
+ assert(iterators === 1 && strings === 1, 'One iterable and DOMString conversion');
+ for (const key of ['hints', 'excludeCredentials', 'pubKeyCredParams']) throws(() => create({...minimal(), [key]: null}), w.TypeError);
+ throws(() => request({challenge: 'AA', hints: 'string'}), w.TypeError);
+ });
+ run('sequence conversion preserves abrupt completion without iterator close', () => {
+ const marker = {marker: true}; let closes = 0;
+ const iterable = {[Symbol.iterator]() {return {next() {return {done: false, value: {toString() {throw marker;}}};}, return() {closes++; return {};}};}};
+ let caught; try { request({challenge: 'AA', hints: iterable}); } catch (error) {caught = error;}
+ assert(caught === marker && closes === 0, 'Original exception and WebIDL iteration behavior');
+ });
+ run('getters finish before any base64url decoding', () => {
+ const marker = {marker: true}; let calls = 0;
+ let caught; try { create({...minimal(), challenge: '=', user: {displayName: 'D', id: '=', get name() {calls++; throw marker;}}}); } catch (error) {caught = error;}
+ assert(caught === marker && calls === 1, 'Last getter error precedes invalid decoding');
+ caught = undefined;
+ try {request({challenge: '=', get userVerification() {throw marker;}});} catch (error) {caught = error;}
+ assert(caught === marker, 'Request conversion finishes before decoding');
+ });
+ run('inherited dictionary getters, no unknown reads and no input mutations', () => {
+ let calls = 0;
+ const proto = {get challenge() {calls++; return 'AA';}};
+ const input = Object.create(proto);
+ Object.defineProperty(input, 'unknown', {get() {throw Error('Unknown member accessed');}});
+ input.extensions = {prf: {eval: {first: 'AA'}}};
+ Object.defineProperty(input.extensions, 'unknown', {get() {throw Error('Unknown extension accessed');}});
+ const result = request(input);
+ assert(calls === 1 && !Object.hasOwn(result, 'unknown') && !Object.hasOwn(result.extensions, 'unknown'), 'Known dictionary members only');
+ assert(!Object.hasOwn(input, 'challenge') && input.extensions.prf.eval.first === 'AA', 'Input dictionaries preserved');
+ });
+ run('PRF records use own enumerable keys and preserve UTF-16', () => {
+ const record = Object.create({inherited: {first: '='}});
+ Object.defineProperty(record, 'nonEnumerable', {get() {throw Error('Non-enumerable getter');}});
+ Object.defineProperty(record, '__proto__', {value: {first: 'AA'}, enumerable: true});
+ record['\ud800'] = {first: 'Zh'};
+ const result = request({challenge: 'AA', extensions: {prf: {evalByCredential: record}}}).extensions.prf.evalByCredential;
+ same(Object.keys(result), ['__proto__', '\ud800']);
+ assert(Object.getPrototypeOf(result) === w.Object.prototype && Object.hasOwn(result, '__proto__'), 'Record data properties');
+ same(bytes(result.__proto__.first), [0]); same(bytes(result['\ud800'].first), [102]);
+ record[Symbol('enumerable')] = {first: 'AA'};
+ throws(() => request({challenge: 'AA', extensions: {prf: {evalByCredential: record}}}), w.TypeError);
+ });
+ run('fresh independent dictionaries and ArrayBuffers', () => {
+ const options = {...minimal(), extensions: {prf: {eval: {first: 'AA'}}}};
+ const first = create(options), second = create(options);
+ new Uint8Array(first.challenge)[0] = 0; new Uint8Array(first.extensions.prf.eval.first)[0] = 255;
+ first.hints.push('mutated'); first.user.name = 'changed';
+ same(bytes(second.challenge), [116, 101, 115, 116]); same(bytes(second.extensions.prf.eval.first), [0]);
+ same(second.hints, []); assert(second.user.name === 'user' && first.user.id !== second.user.id && first !== second, 'No mutable sharing');
+ });
+ run('output bypasses inherited object and array setters', () => {
+ const input = {...minimal(), hints: ['hint'], extensions: {appid: 'app'}};
+ let traps = 0; let result;
+ const setter = () => {traps++; throw Error('Inherited setter');};
+ const entries = [[w.Object.prototype, 'challenge'], [w.Object.prototype, 'appid'], [w.Array.prototype, '0']];
+ const saved = entries.map(([object, key]) => Object.getOwnPropertyDescriptor(object, key));
+ try {
+ for (const [object, key] of entries) Object.defineProperty(object, key, {set: setter, configurable: true});
+ result = create(input);
+ } finally {
+ entries.forEach(([object, key], i) => {if (saved[i]) Object.defineProperty(object, key, saved[i]); else delete object[key];});
+ }
+ assert(traps === 0 && result.extensions.appid === 'app' && result.hints[0] === 'hint', 'CreateDataProperty output');
+ });
+ run('dictionary getter order', () => {
+ const trace = [];
+ const track = (prefix, target) => new Proxy(target, {get(object, key, receiver) {trace.push(prefix + String(key)); return Reflect.get(object, key, receiver);}});
+ const input = track('top.', {...minimal(), rp: track('rp.', {name: 'R'}), user: track('user.', {id: 'AA', name: 'N', displayName: 'D'}), pubKeyCredParams: [track('param.', {alg: -7, type: 'public-key'})], excludeCredentials: [track('exclude.', {id: 'AA', type: 'public-key'})], authenticatorSelection: track('selection.', {}), extensions: track('extensions.', {largeBlob: track('largeBlob.', {}), prf: track('prf.', {eval: track('eval.', {first: 'AA'})})})});
+ create(input);
+ facts.traces.push({realm, trace});
+ const common = trace.filter(key => key !== 'top.attestationFormats' && key !== 'extensions.remoteClientDataJSON');
+ same(common, ['top.attestation','top.authenticatorSelection','selection.authenticatorAttachment','selection.requireResidentKey','selection.residentKey','selection.userVerification','top.challenge','top.excludeCredentials','exclude.id','exclude.transports','exclude.type','top.extensions','extensions.appid','extensions.appidExclude','extensions.credBlob','extensions.credProps','extensions.credentialProtectionPolicy','extensions.enforceCredentialProtectionPolicy','extensions.getCredBlob','extensions.hmacCreateSecret','extensions.largeBlob','largeBlob.read','largeBlob.support','largeBlob.write','extensions.minPinLength','extensions.prf','prf.eval','eval.first','eval.second','prf.evalByCredential','top.hints','top.pubKeyCredParams','param.alg','param.type','top.rp','rp.name','rp.id','top.timeout','top.user','user.displayName','user.id','user.name']);
+ });
+ run('current-idl/additional JSON dictionary member order', () => {
+ const trace = facts.traces.find(row => row.realm === realm).trace;
+ assert(trace[1] === 'top.attestationFormats' && trace[trace.indexOf('extensions.prf') + 5] === 'extensions.remoteClientDataJSON', 'Current dictionary members included in order');
+ });
+ }
+ const foreign = worlds[1][1];
+ try {
+ const request = foreign.PublicKeyCredential.parseRequestOptionsFromJSON;
+ assert(typeof request === 'function', 'Missing foreign parser');
+ const ObjectCtor = foreign.Object, ArrayCtor = foreign.Array, BufferCtor = foreign.ArrayBuffer;
+ const keys = ['Object', 'Array', 'ArrayBuffer', 'PublicKeyCredential', 'DOMException', 'TypeError'];
+ const originals = keys.map(key => foreign[key]);
+ let result, encodingError, typeError;
+ try {
+ for (const key of keys) foreign[key] = function AuthorConstructor() {throw Error('Author constructor');};
+ result = request({challenge: 'AA', hints: ['hint'], extensions: {prf: {eval: {first: 'Zh'}}}});
+ try {request({challenge: '='});} catch (error) {encodingError = error;}
+ try {request({});} catch (error) {typeError = error;}
+ } finally { keys.forEach((key, i) => foreign[key] = originals[i]); }
+ assert(Object.getPrototypeOf(result) === ObjectCtor.prototype && result.hints instanceof ArrayCtor && result.challenge instanceof BufferCtor, 'Intrinsic callee output constructors');
+ assert(encodingError instanceof originals[4] && encodingError.name === 'EncodingError' && typeError instanceof originals[5], 'Intrinsic callee exception constructors');
+ facts.checks.push({realm: 'cross-realm', name: 'overwritten public constructors', passed: true});
+ } catch (error) {facts.checks.push({realm: 'cross-realm', name: 'overwritten public constructors', passed: false, error: error.name, message: error.message});}
+ facts.complete = true;
+ globalThis.__uiEventResults = facts;
+ return facts.checks.every(row => row.passed);
+})()
diff --git a/moli-renderer-v8/src/script_vm/tests/credential_json_options.rs b/moli-renderer-v8/src/script_vm/tests/credential_json_options.rs
new file mode 100644
index 000000000..a1a9c7c14
--- /dev/null
+++ b/moli-renderer-v8/src/script_vm/tests/credential_json_options.rs
@@ -0,0 +1,15 @@
+use super::*;
+
+#[test]
+fn credential_json_options_preserve_dictionary_conversion_and_binary_error_realms() {
+ let mut vm = new_storage_page_task_executor_test_vm("https://credential-json.test/");
+ vm.eval("document.body.innerHTML = '<iframe id=child></iframe>'")
+ .unwrap();
+ vm.eval(include_str!("credential_json_options.js")).unwrap();
+ assert_eq!(
+ vm.eval("JSON.stringify(__uiEventResults.checks.filter(row => !row.passed))")
+ .unwrap(),
+ "[]"
+ );
+ assert_eq!(vm.eval("__uiEventResults.complete").unwrap(), "true");
+}
diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rs
index 6ef2bcd44..13dfeed3a 100644
--- a/moli-renderer-v8/src/script_vm/tests/mod.rs
+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs
@@ -1,3 +1,4 @@
+mod credential_json_options;
use super::post_parse::dynamic_script_execute_is_runnable_before_dom_content_loaded;
use super::{
PostParseDriverStep, PostParseLifecycleAdvance, PostParseLifecycleCompletionAction,