load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("secure_pipes")

cpp_library(
    name = "delegated_credential",
    srcs = [
        "Types.cpp",
    ],
    headers = [
        "Types.h",
    ],
    deps = [
        "//folly:string",
        "//folly/io:iobuf",
    ],
    exported_deps = [
        "//fizz/record:record",
        "//folly:optional",
    ],
)

cpp_library(
    name = "delegated_credential_client_extension",
    srcs = [
        "DelegatedCredentialClientExtension.cpp",
    ],
    headers = [
        "DelegatedCredentialClientExtension.h",
    ],
    exported_deps = [
        ":delegated_credential",
        "//fizz/client:client_extensions",
    ],
)

cpp_library(
    name = "delegated_credential_utils",
    srcs = [
        "DelegatedCredentialUtils.cpp",
    ],
    headers = [
        "DelegatedCredentialUtils.h",
    ],
    deps = [
        "//fizz/backend:openssl",
        "//folly/ssl:openssl_cert_utils",
    ],
    exported_deps = [
        ":delegated_credential",
        "//fizz/protocol:certificate",
        "//fizz/protocol/clock:clock",
        "//folly/ssl:openssl_ptr_types",
    ],
)

cpp_library(
    name = "serialization",
    srcs = [
        "Serialization.cpp",
    ],
    headers = [
        "Serialization.h",
    ],
    deps = [
        ":delegated_credential_utils",
        "//folly:base64",
        "//folly:format",
        "//folly:range",
    ],
    exported_deps = [
        ":delegated_credential",
        ":self_delegated_credential",
    ],
)

cpp_library(
    name = "peer_delegated_credential",
    headers = [
        "PeerDelegatedCredential.h",
        "PeerDelegatedCredential-inl.h",
    ],
    exported_deps = [
        ":delegated_credential",
        ":delegated_credential_utils",
        "//fizz/backend:openssl",
        "//fizz/protocol/clock:system_clock",
        "//folly/ssl:openssl_cert_utils",
    ],
)

cpp_library(
    name = "self_delegated_credential",
    headers = [
        "SelfDelegatedCredential.h",
        "SelfDelegatedCredential-inl.h",
    ],
    exported_deps = [
        ":delegated_credential",
        ":delegated_credential_utils",
        "//fizz/backend:openssl",
        "//folly/ssl:openssl_cert_utils",
    ],
)

cpp_library(
    name = "delegated_credential_factory",
    srcs = [
        "DelegatedCredentialFactory.cpp",
    ],
    headers = [
        "DelegatedCredentialFactory.h",
    ],
    deps = [
        ":peer_delegated_credential",
        "//folly/portability:openssl",
    ],
    exported_deps = [
        ":delegated_credential",
        "//fizz/protocol:default_factory",
    ],
)

cpp_library(
    name = "delegated_credential_cert_manager",
    srcs = [
        "DelegatedCredentialCertManager.cpp",
    ],
    headers = [
        "DelegatedCredentialCertManager.h",
    ],
    deps = [
        ":delegated_credential_utils",
    ],
    exported_deps = [
        ":delegated_credential",
        ":self_delegated_credential",
        "//fizz/server:cert_manager",
    ],
)

cpp_library(
    name = "delegated_credential_client_cert_manager",
    srcs = [
        "DelegatedCredentialClientCertManager.cpp",
    ],
    headers = [
        "DelegatedCredentialClientCertManager.h",
    ],
    deps = [
        ":delegated_credential",
    ],
    exported_deps = [
        "//fizz/client:cert_manager",
    ],
)
