chromium/services/network/trust_tokens/trust_token_key_commitment_controller.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_NETWORK_TRUST_TOKENS_TRUST_TOKEN_KEY_COMMITMENT_CONTROLLER_H_
#define SERVICES_NETWORK_TRUST_TOKENS_TRUST_TOKEN_KEY_COMMITMENT_CONTROLLER_H_

#include <memory>
#include <string_view>
#include <vector>

#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/trust_tokens.mojom-forward.h"
#include "url/gurl.h"

namespace net {
struct NetworkTrafficAnnotationTag;
struct RedirectInfo;
class URLRequest;
}  // namespace net

namespace url {
class Origin;
}

namespace network {

namespace mojom {
class URLLoaderFactory;
class URLResponseHead;
}  // namespace mojom

namespace internal {

// Creates a key commitment request for the given issuance
// or redemption request:
// 1. sets the LOAD_BYPASS_CACHE and LOAD_DISABLE_CACHE flags,
// so that the result doesn't check the cache and isn't cached itself
// 2. sets the URL to kTrustTokenKeyCommitmentWellKnownPath, resolved
// relative to the issuance or redemption origin
// 3. sets the key commitment request to be uncredentialed
// 4. copies |request|'s initiator to the key commitment request
// 5. sets the key commitment request's Origin header to equal |request|'s
// top-level origin. (This is so servers can make a decision about whether to
// reject issuance or redemption early, by making a general decision about
// whether they want to issue/redeem on the provided top-level origin.)
std::unique_ptr<ResourceRequest> CreateTrustTokenKeyCommitmentRequest(
    const net::URLRequest& request,
    const url::Origin& top_level_origin);

}  // namespace internal

// TrustTokenKeyCommitmentController executes a single Trust Tokens key
// commitment request.
//
// This is an uncredentialed request to the above .well-known path
// relative to the origin of the Trust Tokens issuer involved in an issuance or
// redemption's origin; the request expects a key commitment response of the
// format defined in the Privacy Pass draft spec:
// https://github.com/alxdavids/draft-privacy-pass/blob/master/draft-privacy-pass.md.
//
// Lifetime: These are expected to be constructed when the client
// wishes to execute a request and destroyed immediately after the client
// receives its result.
class TrustTokenKeyCommitmentController final {};

}  // namespace network

#endif  // SERVICES_NETWORK_TRUST_TOKENS_TRUST_TOKEN_KEY_COMMITMENT_CONTROLLER_H_