blob: edae66e2e7391ae63fa84167095987e94c8aa18d [file] [log] [blame]
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_WEBID_EMAIL_VERIFIER_H_
#define CONTENT_PUBLIC_BROWSER_WEBID_EMAIL_VERIFIER_H_
#include "base/functional/callback.h"
#include "base/supports_user_data.h"
#include "content/public/browser/render_frame_host.h"
namespace content::webid {
// An implementation of an email verifier that follows the
// Email Verification Protocol as described here:
// https://github.com/dickhardt/email-verification-protocol
//
// EmailVerifier is associated with a valid and alive
// RenderFrameHost which has to outlive it.
class EmailVerifier : public base::SupportsUserData::Data {
public:
// The resulting `verification` is a signed SD-JWT+KB token as
// defined here:
// https://github.com/dickhardt/email-verification-protocol#6-token-verification
using OnEmailVerifiedCallback =
base::OnceCallback<void(std::optional<std::string> verification)>;
~EmailVerifier() override = default;
// Takes an `email` and a challenge `nonce` generated by an RP and returns,
// optionally, a signed verification token.
virtual void Verify(const std::string& email,
const std::string& nonce,
OnEmailVerifiedCallback callback) = 0;
// Returns the EmailVerifier associated with the given RenderFrameHost, or
// creates one if none exists yet.
// The RenderFrameHost must outlive it.
CONTENT_EXPORT static EmailVerifier* GetOrCreateForFrame(
content::RenderFrameHost* render_frame_host);
};
} // namespace content::webid
#endif // CONTENT_PUBLIC_BROWSER_WEBID_EMAIL_VERIFIER_H_