mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1884466 - implement the PublicKeyCredential getClientCapabilities method. r=keeler,webidl,saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D229835
This commit is contained in:
parent
89e335919c
commit
4f6fb28e87
@ -126,6 +126,130 @@ PublicKeyCredential::IsUserVerifyingPlatformAuthenticatorAvailable(
|
||||
return manager->IsUVPAA(aGlobal, aError);
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<Promise> PublicKeyCredential::GetClientCapabilities(
|
||||
GlobalObject& aGlobal, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise =
|
||||
Promise::Create(xpc::CurrentNativeGlobal(aGlobal.Context()), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// From https://w3c.github.io/webauthn/#sctn-getClientCapabilities:
|
||||
// Keys in PublicKeyCredentialClientCapabilities MUST be sorted in
|
||||
// ascending lexicographical order. The set of keys SHOULD contain the set
|
||||
// of enumeration values of ClientCapability
|
||||
// (https://w3c.github.io/webauthn/#enumdef-clientcapability) but the
|
||||
// client MAY omit keys as it deems necessary. [...] The set of keys SHOULD
|
||||
// also contain a key for each extension implemented by the client, where
|
||||
// the key is formed by prefixing the string 'extension:' to the extension
|
||||
// identifier. The associated value for each implemented extension SHOULD
|
||||
// be true.
|
||||
//
|
||||
Record<nsString, bool> capabilities;
|
||||
|
||||
auto entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"conditionalCreate"_ns;
|
||||
entry->mValue = false;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"conditionalGet"_ns;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
entry->mValue = false;
|
||||
#else
|
||||
entry->mValue = StaticPrefs::security_webauthn_enable_conditional_mediation();
|
||||
#endif
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"extension:appid"_ns;
|
||||
entry->mValue = true;
|
||||
|
||||
// Bug 1570429: support the appidExclude extension.
|
||||
// entry = capabilities.Entries().AppendElement();
|
||||
// entry->mKey = u"extension:appidExclude"_ns;
|
||||
// entry->mValue = true;
|
||||
|
||||
// Bug 1844448: support the credBlob extension.
|
||||
// entry = capabilities.Entries().AppendElement();
|
||||
// entry->mKey = u"extension:credBlob"_ns;
|
||||
// entry->mValue = true;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"extension:credProps"_ns;
|
||||
entry->mValue = true;
|
||||
|
||||
// Bug 1844449: support the credProtect extension.
|
||||
// entry = capabilities.Entries().AppendElement();
|
||||
// entry->mKey = u"extension:credentialProtectionPolicy"_ns;
|
||||
// entry->mValue = true;
|
||||
|
||||
// Bug 1844449: support the credProtect extension.
|
||||
// entry = capabilities.Entries().AppendElement();
|
||||
// entry->mKey = u"extension:enforceCredentialProtectionPolicy"_ns;
|
||||
// entry->mValue = true;
|
||||
|
||||
// Bug 1844448: support the credBlob extension.
|
||||
// entry = capabilities.Entries().AppendElement();
|
||||
// entry->mKey = u"extension:getCredBlob"_ns;
|
||||
// entry->mValue = true;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"extension:hmacCreateSecret"_ns;
|
||||
entry->mValue = true;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"extension:minPinLength"_ns;
|
||||
entry->mValue = true;
|
||||
|
||||
// Bug 1863819: support the PRF extension
|
||||
// entry = capabilities.Entries().AppendElement();
|
||||
// entry->mKey = u"extension:prf"_ns;
|
||||
// entry->mValue = true;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"hybridTransport"_ns;
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
|
||||
entry->mValue = true;
|
||||
#else
|
||||
entry->mValue = false;
|
||||
#endif
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"passkeyPlatformAuthenticator"_ns;
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
|
||||
entry->mValue = true;
|
||||
#else
|
||||
entry->mValue = false;
|
||||
#endif
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"relatedOrigins"_ns;
|
||||
entry->mValue = false;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"signalAllAcceptedCredentials"_ns;
|
||||
entry->mValue = false;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"signalCurrentUserDetails"_ns;
|
||||
entry->mValue = false;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"signalUnknownCredential"_ns;
|
||||
entry->mValue = false;
|
||||
|
||||
entry = capabilities.Entries().AppendElement();
|
||||
entry->mKey = u"userVerifyingPlatformAuthenticator"_ns;
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
|
||||
entry->mValue = true;
|
||||
#else
|
||||
entry->mValue = false;
|
||||
#endif
|
||||
|
||||
promise->MaybeResolve(capabilities);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<Promise> PublicKeyCredential::IsConditionalMediationAvailable(
|
||||
GlobalObject& aGlobal, ErrorResult& aError) {
|
||||
|
@ -54,6 +54,9 @@ class PublicKeyCredential final : public Credential {
|
||||
IsUserVerifyingPlatformAuthenticatorAvailable(GlobalObject& aGlobal,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> GetClientCapabilities(GlobalObject& aGlobal,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> IsConditionalMediationAvailable(
|
||||
GlobalObject& aGlobal, ErrorResult& aError);
|
||||
|
||||
|
@ -83,6 +83,14 @@ partial interface PublicKeyCredential {
|
||||
[Throws, Pref="security.webauthn.enable_json_serialization_methods"] static PublicKeyCredentialCreationOptions parseCreationOptionsFromJSON(PublicKeyCredentialCreationOptionsJSON options);
|
||||
};
|
||||
|
||||
// https://w3c.github.io/webauthn/#sctn-getClientCapabilities
|
||||
[SecureContext]
|
||||
partial interface PublicKeyCredential {
|
||||
[Throws] static Promise<PublicKeyCredentialClientCapabilities> getClientCapabilities();
|
||||
};
|
||||
|
||||
typedef record<DOMString, boolean> PublicKeyCredentialClientCapabilities;
|
||||
|
||||
dictionary PublicKeyCredentialCreationOptionsJSON {
|
||||
required PublicKeyCredentialRpEntity rp;
|
||||
required PublicKeyCredentialUserEntityJSON user;
|
||||
|
@ -1,6 +0,0 @@
|
||||
[getclientcapabilities.https.html]
|
||||
[Capabilities object has sorted keys and boolean values]
|
||||
expected: FAIL
|
||||
|
||||
[Capabilities keys are known]
|
||||
expected: FAIL
|
@ -1,7 +1,4 @@
|
||||
[idlharness.https.window.html]
|
||||
[PublicKeyCredential interface: operation getClientCapabilities()]
|
||||
expected: FAIL
|
||||
|
||||
[PublicKeyCredential interface: operation signalUnknownCredential(UnknownCredentialOptions)]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user