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

package org.chromium.components.environment_integrity;

import com.google.common.util.concurrent.ListenableFuture;

/**
 * Delegate interface for EnvironmentIntegrity service implementations.
 */
public interface IntegrityServiceBridgeDelegate {
    /**
     * Create a handle for issuing environment integrity tokens.
     *
     * @param bindAppIdentity Set to {@code true} if the handle should provide integrity tokens that
     *         embed the app identity.
     * @param timeoutMilliseconds Timeout for the call. Implementers should reject after this delay.
     * @return Future that resolves to the handle or rejects with an exception.
     */
    ListenableFuture<Long> createEnvironmentIntegrityHandle(
            boolean bindAppIdentity, int timeoutMilliseconds);

    /**
     * Override method to provide attestation tokens for the given hashed request and handle.
     *
     * @param handle A handle generated by {@link #createEnvironmentIntegrityHandle(boolean)}.
     * @param requestHash A byte array representing a hashed content binding.
     * @param timeoutMilliseconds Timeout for the call. Implementers should reject after this delay.
     * @return Future that resolves to an integrity token.
     */
    ListenableFuture<byte[]> getEnvironmentIntegrityToken(
            long handle, byte[] requestHash, int timeoutMilliseconds);

    /**
     * Shortcut method to determine if it is worth calling the other methods on this interface.
     * @return {@code true} if the client should attempt to call the other methods on this
     *         interface.
     */
    boolean canUseGms();
}
