@@ -937,7 +937,7 @@ ScriptPromise CredentialsContainer::get(
937
937
938
938
auto required_origin_type = RequiredOriginType::kSecureAndSameWithAncestors ;
939
939
// hasPublicKey() implies that this is a WebAuthn request.
940
- if (( options->hasPublicKey () || options-> hasConditionalPublicKey () ) &&
940
+ if (options->hasPublicKey () &&
941
941
RuntimeEnabledFeatures::
942
942
WebAuthenticationGetAssertionFeaturePolicyEnabled ()) {
943
943
required_origin_type = RequiredOriginType::
@@ -951,17 +951,7 @@ ScriptPromise CredentialsContainer::get(
951
951
return promise;
952
952
}
953
953
954
- if (options->hasPublicKey () || options->hasConditionalPublicKey ()) {
955
- const PublicKeyCredentialRequestOptions* public_key_options;
956
- bool is_conditional_ui_request;
957
- if (options->hasPublicKey ()) {
958
- public_key_options = options->publicKey ();
959
- is_conditional_ui_request = false ;
960
- } else {
961
- public_key_options = options->conditionalPublicKey ();
962
- is_conditional_ui_request = true ;
963
- }
964
-
954
+ if (options->hasPublicKey ()) {
965
955
auto cryptotoken_origin = SecurityOrigin::Create (KURL (kCryptotokenOrigin ));
966
956
if (!cryptotoken_origin->IsSameOriginWith (
967
957
resolver->GetExecutionContext ()->GetSecurityOrigin ())) {
@@ -972,21 +962,21 @@ ScriptPromise CredentialsContainer::get(
972
962
}
973
963
974
964
#if defined(OS_ANDROID)
975
- if (public_key_options ->hasExtensions () &&
976
- public_key_options ->extensions ()->hasUvm ()) {
965
+ if (options-> publicKey () ->hasExtensions () &&
966
+ options-> publicKey () ->extensions ()->hasUvm ()) {
977
967
UseCounter::Count (resolver->GetExecutionContext (),
978
968
WebFeature::kCredentialManagerGetWithUVM );
979
969
}
980
970
#endif
981
- if (!IsArrayBufferOrViewBelowSizeLimit (public_key_options ->challenge ())) {
971
+ if (!IsArrayBufferOrViewBelowSizeLimit (options-> publicKey () ->challenge ())) {
982
972
resolver->Reject (DOMException::Create (
983
973
" The `challenge` attribute exceeds the maximum allowed size." ,
984
974
" RangeError" ));
985
975
return promise;
986
976
}
987
- if (public_key_options ->hasExtensions ()) {
988
- if (public_key_options ->extensions ()->hasAppid ()) {
989
- const auto & appid = public_key_options ->extensions ()->appid ();
977
+ if (options-> publicKey () ->hasExtensions ()) {
978
+ if (options-> publicKey () ->extensions ()->hasAppid ()) {
979
+ const auto & appid = options-> publicKey () ->extensions ()->appid ();
990
980
if (!appid.IsEmpty ()) {
991
981
KURL appid_url (appid);
992
982
if (!appid_url.IsValid ()) {
@@ -998,24 +988,24 @@ ScriptPromise CredentialsContainer::get(
998
988
}
999
989
}
1000
990
}
1001
- if (public_key_options ->extensions ()->hasCableRegistration ()) {
991
+ if (options-> publicKey () ->extensions ()->hasCableRegistration ()) {
1002
992
resolver->Reject (MakeGarbageCollected<DOMException>(
1003
993
DOMExceptionCode::kNotSupportedError ,
1004
994
" The 'cableRegistration' extension is only valid when creating "
1005
995
" a credential" ));
1006
996
return promise;
1007
997
}
1008
- if (public_key_options ->extensions ()->credProps ()) {
998
+ if (options-> publicKey () ->extensions ()->credProps ()) {
1009
999
resolver->Reject (MakeGarbageCollected<DOMException>(
1010
1000
DOMExceptionCode::kNotSupportedError ,
1011
1001
" The 'credProps' extension is only valid when creating "
1012
1002
" a credential" ));
1013
1003
return promise;
1014
1004
}
1015
- if (public_key_options ->extensions ()->hasLargeBlob ()) {
1005
+ if (options-> publicKey () ->extensions ()->hasLargeBlob ()) {
1016
1006
DCHECK (RuntimeEnabledFeatures::
1017
1007
WebAuthenticationLargeBlobExtensionEnabled ());
1018
- if (public_key_options ->extensions ()->largeBlob ()->hasSupport ()) {
1008
+ if (options-> publicKey () ->extensions ()->largeBlob ()->hasSupport ()) {
1019
1009
resolver->Reject (MakeGarbageCollected<DOMException>(
1020
1010
DOMExceptionCode::kNotSupportedError ,
1021
1011
" The 'largeBlob' extension's 'support' parameter is only valid "
@@ -1025,7 +1015,7 @@ ScriptPromise CredentialsContainer::get(
1025
1015
}
1026
1016
}
1027
1017
1028
- if (!public_key_options ->hasUserVerification ()) {
1018
+ if (!options-> publicKey () ->hasUserVerification ()) {
1029
1019
resolver->DomWindow ()->AddConsoleMessage (
1030
1020
MakeGarbageCollected<ConsoleMessage>(
1031
1021
mojom::blink::ConsoleMessageSource::kJavaScript ,
@@ -1050,17 +1040,19 @@ ScriptPromise CredentialsContainer::get(
1050
1040
WTF::Bind (&AbortPublicKeyRequest, WrapPersistent (script_state)));
1051
1041
}
1052
1042
1043
+ bool is_conditional_ui_request = conditionalMediationSupported () &&
1044
+ options->mediation () == " conditional" ;
1053
1045
if (is_conditional_ui_request &&
1054
- public_key_options ->hasAllowCredentials () &&
1055
- !public_key_options ->allowCredentials ().IsEmpty ()) {
1046
+ options-> publicKey () ->hasAllowCredentials () &&
1047
+ !options-> publicKey () ->allowCredentials ().IsEmpty ()) {
1056
1048
resolver->Reject (MakeGarbageCollected<DOMException>(
1057
1049
DOMExceptionCode::kNotAllowedError ,
1058
1050
" allowCredentials is not supported for conditionalPublicKey" ));
1059
1051
return promise;
1060
1052
}
1061
1053
1062
1054
auto mojo_options =
1063
- MojoPublicKeyCredentialRequestOptions::From (*public_key_options );
1055
+ MojoPublicKeyCredentialRequestOptions::From (*options-> publicKey () );
1064
1056
if (mojo_options) {
1065
1057
mojo_options->is_conditional = is_conditional_ui_request;
1066
1058
if (!mojo_options->relying_party_id ) {
@@ -1117,6 +1109,12 @@ ScriptPromise CredentialsContainer::get(
1117
1109
}
1118
1110
1119
1111
CredentialMediationRequirement requirement;
1112
+ if (options->mediation () == " conditional" ) {
1113
+ resolver->Reject (MakeGarbageCollected<DOMException>(
1114
+ DOMExceptionCode::kNotSupportedError ,
1115
+ " Conditional mediation is not supported for this credential type" ));
1116
+ return promise;
1117
+ }
1120
1118
if (options->mediation () == " silent" ) {
1121
1119
UseCounter::Count (ExecutionContext::From (script_state),
1122
1120
WebFeature::kCredentialManagerGetMediationSilent );
@@ -1419,6 +1417,10 @@ ScriptPromise CredentialsContainer::preventSilentAccess(
1419
1417
return promise;
1420
1418
}
1421
1419
1420
+ bool CredentialsContainer::conditionalMediationSupported () {
1421
+ return RuntimeEnabledFeatures::WebAuthenticationConditionalUIEnabled ();
1422
+ }
1423
+
1422
1424
void CredentialsContainer::Trace (Visitor* visitor) const {
1423
1425
ScriptWrappable::Trace (visitor);
1424
1426
Supplement<Navigator>::Trace (visitor);
0 commit comments