LibWeb: Stub for Credential Management API

Stub out basic Credential Management APIs and import IDL tests.

Spec: https://w3c.github.io/webappsec-credential-management/
This commit is contained in:
devgianlu 2025-01-30 22:29:26 +01:00 committed by Andrew Kaster
commit da9eaf8788
Notes: github-actions[bot] 2025-02-05 20:19:50 +00:00
20 changed files with 534 additions and 0 deletions

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Forward.h>
#include <LibWeb/Bindings/PasswordCredentialPrototype.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/CredentialManagement/Credential.h>
#include <LibWeb/HTML/HTMLFormElement.h>
namespace Web::CredentialManagement {
class PasswordCredential final : public Credential {
WEB_PLATFORM_OBJECT(PasswordCredential, Credential);
GC_DECLARE_ALLOCATOR(PasswordCredential);
public:
[[nodiscard]] static GC::Ref<PasswordCredential> create(JS::Realm&);
static WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> construct_impl(JS::Realm&, HTML::HTMLFormElement const&);
static WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> construct_impl(JS::Realm&, PasswordCredentialData const&);
virtual ~PasswordCredential() override;
String const& password() { return m_password; }
String type() override { return "password"_string; }
private:
explicit PasswordCredential(JS::Realm&);
virtual void initialize(JS::Realm&) override;
// TODO: Use Core::SecretString when it comes back
String m_password;
};
struct PasswordCredentialData : CredentialData {
Optional<String> name;
Optional<String> icon_url;
String origin;
String password;
};
using PasswordCredentialInit = Variant<PasswordCredentialData, GC::Root<HTML::HTMLFormElement>>;
}