diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3bfa034..9193661 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -Thank you for your interest in contributing to the HTTP Gateway Protocol monorepo for the Internet Computer. +Thank you for your interest in contributing to the Internet Computer HTTP Gateway Protocol monorepo. By participating in this project, you agree to abide by our [Code of Conduct](./CODE_OF_CONDUCT.md). As a member of the community, you are invited and encouraged to contribute by submitting issues, offering suggestions for improvements, adding review comments to existing pull requests, or creating new pull requests to fix issues. @@ -15,7 +15,7 @@ The contributor guidelines are intended to make the contribution process easy an Before contributing, consider the following: -- If you want to report an issue, click [issues](https://github.com/dfinity/http-gateway/issues). +- If you want to report an issue, click [issues](https://github.com/dfinity/ic-http-gateway-protocol/issues). - If you have more general questions related to this package and its use, post a message to the [community forum](https://forum.dfinity.org/). - If you are reporting a bug, provide as much information about the problem as possible. - If you want to contribute directly to this repository, typical fixes might include any of the following: @@ -40,7 +40,7 @@ This section describes the most common workflow scenarios: To open a new issue: -1. Click [create a new issue](https://github.com/dfinity/http-gateway/issues/new). +1. Click [create a new issue](https://github.com/dfinity/ic-http-gateway-protocol/issues/new). 2. Type a title and description, then click **Submit new issue**. - Be as clear and descriptive as possible. - For any problem, describe it in detail, including details about the crate, the version of the code you are using, the results you expected, and how the actual results differed from your expectations. @@ -50,7 +50,7 @@ To open a new issue: If you want to submit a pull request to fix an issue or add a feature, here's a summary of what you need to do: 1. Make sure you have a GitHub account, an internet connection, and access to a terminal shell or GitHub Desktop application for running commands. -2. Navigate to the [repository's homepage](https://github.com/dfinity/http-gateway) in a web browser. +2. Navigate to the [repository's homepage](https://github.com/dfinity/ic-http-gateway-protocol) in a web browser. 3. Click **Fork** to create a copy of the repository under your GitHub account or organization name. 4. Clone the forked repository to your local machine. 5. Create a new branch for your fix by running a command similar to the following: diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3f5a424..9f3a45f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -33,6 +33,10 @@ jobs: - name: Test Cargo crates run: cargo test --all-features + # TODO(NODE-1907): Remove once ic-http-gateway is fully deprecated. + - name: Check compatibility shim crate + run: cargo check -p ic-http-gateway --all-features + - name: Build Cargo docs run: cargo doc --no-deps diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c73fdf2..910c724 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,6 +27,11 @@ jobs: sed "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" Cargo.toml.orig > Cargo.toml rm -f Cargo.toml.orig + - run: cargo publish --package ic-http-gateway-protocol --allow-dirty + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + + # TODO(NODE-1907): Remove once ic-http-gateway is fully deprecated. - run: cargo publish --package ic-http-gateway --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} diff --git a/Cargo.lock b/Cargo.lock index 2bbabc7..af31caf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1393,7 +1393,7 @@ dependencies = [ "hyper", "hyper-util", "ic-agent", - "ic-http-gateway", + "ic-http-gateway-protocol", "pocket-ic", "tokio", ] @@ -1724,6 +1724,13 @@ dependencies = [ [[package]] name = "ic-http-gateway" version = "0.0.0-git" +dependencies = [ + "ic-http-gateway-protocol", +] + +[[package]] +name = "ic-http-gateway-protocol" +version = "0.0.0-git" dependencies = [ "assert_matches", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 23ddc06..bb632a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,19 +4,21 @@ resolver = "2" members = [ "examples/http-gateway/canister/src/custom_assets", "examples/http-gateway/rust", + "packages/ic-http-gateway-protocol", + # TODO(NODE-1907): Remove once ic-http-gateway is fully deprecated. "packages/ic-http-gateway", ] # https://github.com/rust-lang/cargo/issues/9406 # includes all members except those that must be compiled to WASM -default-members = ["packages/ic-http-gateway"] +default-members = ["packages/ic-http-gateway-protocol"] [workspace.package] version = "0.0.0-git" authors = ["DFINITY Stiftung"] edition = "2021" -repository = "https://github.com/dfinity/http-gateway" -homepage = "https://github.com/dfinity/http-gateway#readme" +repository = "https://github.com/dfinity/ic-http-gateway-protocol" +homepage = "https://github.com/dfinity/ic-http-gateway-protocol#readme" license = "Apache-2.0" [profile.release] @@ -57,4 +59,6 @@ ic-certification = ">=3.0.3, <4.0.0" ic-http-certification = ">=3.0.3, <4.0.0" ic-asset-certification = ">=3.0.3, <4.0.0" +ic-http-gateway-protocol = { path = "./packages/ic-http-gateway-protocol", version = "0.0.0-git" } +# TODO(NODE-1907): Remove once ic-http-gateway is fully deprecated. ic-http-gateway = { path = "./packages/ic-http-gateway", version = "0.0.0-git" } diff --git a/README.md b/README.md index eb0571f..fcf5080 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ -# HTTP Gateway Protocol +# Internet Computer HTTP Gateway Protocol ## Overview -The HTTP Gateway Protocol is an extension of the Internet Computer Protocol that allows conventional HTTP clients to interact with the Internet Computer network. This is important for software such as web browsers to be able to fetch and render client-side canister code, including HTML, CSS, and JavaScript as well as other static assets such as images or videos. The HTTP Gateway does this by translating between standard HTTP requests and API canister calls that the Internet Computer Protocol will understand. +The Internet Computer HTTP Gateway Protocol (HTTP Gateway Protocol) is an extension of the Internet Computer Protocol that allows conventional HTTP clients to interact with the Internet Computer network. This is important for software such as web browsers to be able to fetch and render client-side canister code, including HTML, CSS, and JavaScript as well as other static assets such as images or videos. The HTTP Gateway does this by translating between standard HTTP requests and API canister calls that the Internet Computer Protocol will understand. You can read more about this protocol in [the spec](https://github.com/dfinity/interface-spec/blob/master/spec/http-gateway-protocol-spec.md). + ## Projects ### HTTP Canister Client diff --git a/examples/http-gateway/rust/Cargo.toml b/examples/http-gateway/rust/Cargo.toml index 645b07a..851955d 100644 --- a/examples/http-gateway/rust/Cargo.toml +++ b/examples/http-gateway/rust/Cargo.toml @@ -13,7 +13,7 @@ hyper.workspace = true hyper-util.workspace = true http-body-util.workspace = true -ic-http-gateway.workspace = true +ic-http-gateway-protocol.workspace = true ic-agent.workspace = true pocket-ic.workspace = true diff --git a/examples/http-gateway/rust/src/main.rs b/examples/http-gateway/rust/src/main.rs index 7b3d327..3cb78ff 100644 --- a/examples/http-gateway/rust/src/main.rs +++ b/examples/http-gateway/rust/src/main.rs @@ -2,7 +2,9 @@ use http_body_util::BodyExt; use hyper::{body::Incoming, server::conn::http2, service::service_fn, Request, Response}; use hyper_util::rt::TokioIo; use ic_agent::Agent; -use ic_http_gateway::{HttpGatewayClient, HttpGatewayRequestArgs, HttpGatewayResponseBody}; +use ic_http_gateway_protocol::{ + HttpGatewayClient, HttpGatewayRequestArgs, HttpGatewayResponseBody, +}; use pocket_ic::PocketIcBuilder; use std::{convert::Infallible, net::SocketAddr, path::PathBuf, sync::Arc}; use tokio::{fs::File, io::AsyncReadExt, net::TcpListener, task}; diff --git a/package.json b/package.json index 8869f69..68e53ff 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "http-gateway", + "name": "ic-http-gateway-protocol", "private": true, "engines": { "node": "^20", diff --git a/packages/http-canister-client-js/package.json b/packages/http-canister-client-js/package.json index 44bdc18..bb6651f 100644 --- a/packages/http-canister-client-js/package.json +++ b/packages/http-canister-client-js/package.json @@ -4,14 +4,14 @@ "description": "A JavaScript client for Internet Computer canisters that implement the HTTP interface", "author": "DFINITY Stiftung", "license": "Apache-2.0", - "homepage": "https://github.com/dfinity/http-gateway#readme", + "homepage": "https://github.com/dfinity/ic-http-gateway-protocol#readme", "repository": { "type": "git", - "url": "https://github.com/dfinity/http-gateway.git", + "url": "https://github.com/dfinity/ic-http-gateway-protocol.git", "directory": "packages/http-canister-client" }, "bugs": { - "url": "https://github.com/dfinity/http-gateway/issues" + "url": "https://github.com/dfinity/ic-http-gateway-protocol/issues" }, "keywords": [ "internet", diff --git a/packages/ic-http-gateway-protocol/Cargo.toml b/packages/ic-http-gateway-protocol/Cargo.toml new file mode 100644 index 0000000..d36058f --- /dev/null +++ b/packages/ic-http-gateway-protocol/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "ic-http-gateway-protocol" +description = "An HTTP Gateway implementation for interfacing with the Internet Computer over HTTP" +readme = "README.md" +documentation = "https://docs.rs/ic-http-gateway-protocol" +categories = [ + "api-bindings", + "cryptography::cryptocurrencies", + "network-programming", + "wasm", +] +keywords = ["internet-computer", "http", "gateway", "icp", "dfinity"] +include = ["src", "Cargo.toml", "README.md"] + +version.workspace = true +authors.workspace = true +edition.workspace = true +repository.workspace = true +license.workspace = true +homepage.workspace = true + +[dependencies] +thiserror.workspace = true +futures.workspace = true +http.workspace = true +http-body.workspace = true +http-body-util.workspace = true +bytes.workspace = true + +ic-agent.workspace = true +ic-utils.workspace = true +candid.workspace = true + +ic-http-certification.workspace = true +ic-response-verification.workspace = true + +[dev-dependencies] +assert_matches.workspace = true +pocket-ic.workspace = true +reqwest.workspace = true +testcontainers.workspace = true +tokio.workspace = true +rand_chacha.workspace = true +rstest.workspace = true +sha2.workspace = true diff --git a/packages/ic-http-gateway-protocol/README.md b/packages/ic-http-gateway-protocol/README.md new file mode 100644 index 0000000..fffa248 --- /dev/null +++ b/packages/ic-http-gateway-protocol/README.md @@ -0,0 +1 @@ +# HTTP Gateway Protocol diff --git a/packages/ic-http-gateway/src/client/http_gateway_client.rs b/packages/ic-http-gateway-protocol/src/client/http_gateway_client.rs similarity index 100% rename from packages/ic-http-gateway/src/client/http_gateway_client.rs rename to packages/ic-http-gateway-protocol/src/client/http_gateway_client.rs diff --git a/packages/ic-http-gateway/src/client/http_gateway_client_builder.rs b/packages/ic-http-gateway-protocol/src/client/http_gateway_client_builder.rs similarity index 100% rename from packages/ic-http-gateway/src/client/http_gateway_client_builder.rs rename to packages/ic-http-gateway-protocol/src/client/http_gateway_client_builder.rs diff --git a/packages/ic-http-gateway/src/client/mod.rs b/packages/ic-http-gateway-protocol/src/client/mod.rs similarity index 100% rename from packages/ic-http-gateway/src/client/mod.rs rename to packages/ic-http-gateway-protocol/src/client/mod.rs diff --git a/packages/ic-http-gateway/src/consts.rs b/packages/ic-http-gateway-protocol/src/consts.rs similarity index 100% rename from packages/ic-http-gateway/src/consts.rs rename to packages/ic-http-gateway-protocol/src/consts.rs diff --git a/packages/ic-http-gateway/src/error.rs b/packages/ic-http-gateway-protocol/src/error.rs similarity index 100% rename from packages/ic-http-gateway/src/error.rs rename to packages/ic-http-gateway-protocol/src/error.rs diff --git a/packages/ic-http-gateway-protocol/src/lib.rs b/packages/ic-http-gateway-protocol/src/lib.rs new file mode 100644 index 0000000..3f13ac6 --- /dev/null +++ b/packages/ic-http-gateway-protocol/src/lib.rs @@ -0,0 +1,20 @@ +/*! +# HTTP Gateway Protocol +*/ + +mod client; +pub use client::*; + +mod protocol; + +mod request; +pub use request::*; + +mod response; +pub use response::*; + +mod consts; +pub(crate) use consts::*; + +mod error; +pub use error::*; diff --git a/packages/ic-http-gateway/src/protocol/handler.rs b/packages/ic-http-gateway-protocol/src/protocol/handler.rs similarity index 100% rename from packages/ic-http-gateway/src/protocol/handler.rs rename to packages/ic-http-gateway-protocol/src/protocol/handler.rs diff --git a/packages/ic-http-gateway/src/protocol/mod.rs b/packages/ic-http-gateway-protocol/src/protocol/mod.rs similarity index 100% rename from packages/ic-http-gateway/src/protocol/mod.rs rename to packages/ic-http-gateway-protocol/src/protocol/mod.rs diff --git a/packages/ic-http-gateway/src/protocol/validate.rs b/packages/ic-http-gateway-protocol/src/protocol/validate.rs similarity index 100% rename from packages/ic-http-gateway/src/protocol/validate.rs rename to packages/ic-http-gateway-protocol/src/protocol/validate.rs diff --git a/packages/ic-http-gateway/src/request/http_gateway_request_builder.rs b/packages/ic-http-gateway-protocol/src/request/http_gateway_request_builder.rs similarity index 100% rename from packages/ic-http-gateway/src/request/http_gateway_request_builder.rs rename to packages/ic-http-gateway-protocol/src/request/http_gateway_request_builder.rs diff --git a/packages/ic-http-gateway/src/request/mod.rs b/packages/ic-http-gateway-protocol/src/request/mod.rs similarity index 100% rename from packages/ic-http-gateway/src/request/mod.rs rename to packages/ic-http-gateway-protocol/src/request/mod.rs diff --git a/packages/ic-http-gateway/src/response/http_gateway_response.rs b/packages/ic-http-gateway-protocol/src/response/http_gateway_response.rs similarity index 100% rename from packages/ic-http-gateway/src/response/http_gateway_response.rs rename to packages/ic-http-gateway-protocol/src/response/http_gateway_response.rs diff --git a/packages/ic-http-gateway/src/response/mod.rs b/packages/ic-http-gateway-protocol/src/response/mod.rs similarity index 100% rename from packages/ic-http-gateway/src/response/mod.rs rename to packages/ic-http-gateway-protocol/src/response/mod.rs diff --git a/packages/ic-http-gateway/src/response/response_handler.rs b/packages/ic-http-gateway-protocol/src/response/response_handler.rs similarity index 100% rename from packages/ic-http-gateway/src/response/response_handler.rs rename to packages/ic-http-gateway-protocol/src/response/response_handler.rs diff --git a/packages/ic-http-gateway/test-container/Dockerfile b/packages/ic-http-gateway-protocol/test-container/Dockerfile similarity index 100% rename from packages/ic-http-gateway/test-container/Dockerfile rename to packages/ic-http-gateway-protocol/test-container/Dockerfile diff --git a/packages/ic-http-gateway/test-container/app.py b/packages/ic-http-gateway-protocol/test-container/app.py similarity index 100% rename from packages/ic-http-gateway/test-container/app.py rename to packages/ic-http-gateway-protocol/test-container/app.py diff --git a/packages/ic-http-gateway/test-container/requirements.txt b/packages/ic-http-gateway-protocol/test-container/requirements.txt similarity index 100% rename from packages/ic-http-gateway/test-container/requirements.txt rename to packages/ic-http-gateway-protocol/test-container/requirements.txt diff --git a/packages/ic-http-gateway/tests/custom_assets.rs b/packages/ic-http-gateway-protocol/tests/custom_assets.rs similarity index 97% rename from packages/ic-http-gateway/tests/custom_assets.rs rename to packages/ic-http-gateway-protocol/tests/custom_assets.rs index d15e516..6299a62 100644 --- a/packages/ic-http-gateway/tests/custom_assets.rs +++ b/packages/ic-http-gateway-protocol/tests/custom_assets.rs @@ -2,7 +2,9 @@ use bytes::Bytes; use http::Request; use http_body_util::BodyExt; use ic_agent::Agent; -use ic_http_gateway::{HttpGatewayClient, HttpGatewayRequestArgs, HttpGatewayResponseMetadata}; +use ic_http_gateway_protocol::{ + HttpGatewayClient, HttpGatewayRequestArgs, HttpGatewayResponseMetadata, +}; use pocket_ic::PocketIcBuilder; mod utils; diff --git a/packages/ic-http-gateway/tests/protocol_error_tests.rs b/packages/ic-http-gateway-protocol/tests/protocol_error_tests.rs similarity index 97% rename from packages/ic-http-gateway/tests/protocol_error_tests.rs rename to packages/ic-http-gateway-protocol/tests/protocol_error_tests.rs index 96d28f8..d8de278 100644 --- a/packages/ic-http-gateway/tests/protocol_error_tests.rs +++ b/packages/ic-http-gateway-protocol/tests/protocol_error_tests.rs @@ -1,7 +1,7 @@ use bytes::Bytes; use http::{status::StatusCode, Request}; use ic_agent::{export::Principal, Agent}; -use ic_http_gateway::{HttpGatewayClient, HttpGatewayRequestArgs}; +use ic_http_gateway_protocol::{HttpGatewayClient, HttpGatewayRequestArgs}; use reqwest::Client; use std::{env, error::Error, process::Command, str::FromStr}; use testcontainers::{ diff --git a/packages/ic-http-gateway/tests/range_request_stream.rs b/packages/ic-http-gateway-protocol/tests/range_request_stream.rs similarity index 99% rename from packages/ic-http-gateway/tests/range_request_stream.rs rename to packages/ic-http-gateway-protocol/tests/range_request_stream.rs index 71aa8a4..3c93d07 100644 --- a/packages/ic-http-gateway/tests/range_request_stream.rs +++ b/packages/ic-http-gateway-protocol/tests/range_request_stream.rs @@ -4,7 +4,9 @@ use http::Request; use http_body_util::BodyExt; use ic_agent::hash_tree::Hash; use ic_agent::Agent; -use ic_http_gateway::{HttpGatewayClient, HttpGatewayRequestArgs, HttpGatewayResponseMetadata}; +use ic_http_gateway_protocol::{ + HttpGatewayClient, HttpGatewayRequestArgs, HttpGatewayResponseMetadata, +}; use pocket_ic::PocketIcBuilder; use rand_chacha::rand_core::{RngCore, SeedableRng}; use rand_chacha::ChaCha20Rng; diff --git a/packages/ic-http-gateway/tests/utils/mod.rs b/packages/ic-http-gateway-protocol/tests/utils/mod.rs similarity index 100% rename from packages/ic-http-gateway/tests/utils/mod.rs rename to packages/ic-http-gateway-protocol/tests/utils/mod.rs diff --git a/packages/ic-http-gateway/Cargo.toml b/packages/ic-http-gateway/Cargo.toml index 70adb60..674730e 100644 --- a/packages/ic-http-gateway/Cargo.toml +++ b/packages/ic-http-gateway/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ic-http-gateway" -description = "An HTTP Gateway implementation for interfacing with the Internet Computer over HTTP" +description = "Compatibility crate for ic-http-gateway-protocol" readme = "README.md" documentation = "https://docs.rs/ic-http-gateway" categories = [ @@ -20,26 +20,4 @@ license.workspace = true homepage.workspace = true [dependencies] -thiserror.workspace = true -futures.workspace = true -http.workspace = true -http-body.workspace = true -http-body-util.workspace = true -bytes.workspace = true - -ic-agent.workspace = true -ic-utils.workspace = true -candid.workspace = true - -ic-http-certification.workspace = true -ic-response-verification.workspace = true - -[dev-dependencies] -assert_matches.workspace = true -pocket-ic.workspace = true -reqwest.workspace = true -testcontainers.workspace = true -tokio.workspace = true -rand_chacha.workspace = true -rstest.workspace = true -sha2.workspace = true +ic-http-gateway-protocol.workspace = true diff --git a/packages/ic-http-gateway/README.md b/packages/ic-http-gateway/README.md index 511659c..930fb1a 100644 --- a/packages/ic-http-gateway/README.md +++ b/packages/ic-http-gateway/README.md @@ -1 +1,5 @@ -# HTTP Gateway +# HTTP Gateway (Compatibility Crate) + +Use `ic-http-gateway-protocol` for new integrations. + +# TODO(NODE-1907): Remove once ic-http-gateway is fully deprecated. diff --git a/packages/ic-http-gateway/src/lib.rs b/packages/ic-http-gateway/src/lib.rs index 59874e8..97b3ff6 100644 --- a/packages/ic-http-gateway/src/lib.rs +++ b/packages/ic-http-gateway/src/lib.rs @@ -1,20 +1,5 @@ /*! -# HTTP Gateway +# HTTP Gateway (Compatibility Crate) */ -mod client; -pub use client::*; - -mod protocol; - -mod request; -pub use request::*; - -mod response; -pub use response::*; - -mod consts; -pub(crate) use consts::*; - -mod error; -pub use error::*; +pub use ic_http_gateway_protocol::*;