Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change base64 crate to simple-base64 crate #356

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async-trait = "0.1.68"
axum = "0.6"
arrayvec = "0.7.2"
backtrace = "0.3.66"
base64 = "0.21.2"
simple-base64 = "0.23.0"
bitflags = "2.3.3"
byte-unit = "4.0.18"
bytes = "1.2.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spacetimedb-lib = { path = "../lib", version = "0.6.1", features = ["cli"] }
spacetimedb-standalone = { path = "../standalone", version = "0.6.1", optional = true }

anyhow.workspace = true
base64.workspace = true
simple-base64.workspace = true
cargo_metadata.workspace = true
clap = {workspace = true, features = ["derive", "env", "string"]}
colored.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions crates/cli/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Context;
use base64::{engine::general_purpose::STANDARD as BASE_64_STD, Engine as _};
use reqwest::RequestBuilder;
use serde::Deserialize;
use spacetimedb_lib::name::{is_address, DnsLookupResponse, RegisterTldResult, ReverseDNSResponse};
Expand Down Expand Up @@ -278,7 +277,7 @@ pub async fn get_auth_header(
auth_header.push_str(
format!(
"Basic {}",
BASE_64_STD.encode(format!("token:{}", identity_config.token))
simple_base64::encode(format!("token:{}", identity_config.token))
)
.as_str(),
);
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spacetimedb-client-api-messages = { path = "../client-api-messages", version = "
anyhow.workspace = true
async-trait.workspace = true
backtrace.workspace = true
base64.workspace = true
simple-base64.workspace = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

bytes.workspace = true
bytestring.workspace = true
clap.workspace = true
Expand Down
8 changes: 2 additions & 6 deletions crates/core/src/client/message_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::host::{EnergyDiff, ReducerArgs, Timestamp};
use crate::identity::Identity;
use crate::protobuf::client_api::{message, FunctionCall, Message, Subscribe};
use crate::worker_metrics::{WEBSOCKET_REQUESTS, WEBSOCKET_REQUEST_MSG_SIZE};
use base64::Engine;
use bytes::Bytes;
use bytestring::ByteString;
use prost::Message as _;
Expand All @@ -23,7 +22,7 @@ pub enum MessageHandleError {
#[error(transparent)]
TextDecode(#[from] serde_json::Error),
#[error(transparent)]
Base64Decode(#[from] base64::DecodeError),
Base64Decode(#[from] simple_base64::DecodeError),

#[error(transparent)]
Execution(#[from] MessageExecutionError),
Expand Down Expand Up @@ -104,10 +103,7 @@ async fn handle_text(client: &ClientConnection, message: String) -> Result<(), M
query_string: ref query,
message_id,
} => {
let _ = std::mem::replace(
&mut message_id_,
base64::engine::general_purpose::STANDARD.decode(&message_id[..])?,
);
let _ = std::mem::replace(&mut message_id_, simple_base64::decode(&message_id[..])?);
DecodedMessage::OneOffQuery {
query_string: &query[..],
message_id: &message_id_[..],
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/client/messages.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use base64::Engine;
use prost::Message as _;
use spacetimedb_client_api_messages::client_api::{OneOffQueryResponse, OneOffTable};
use spacetimedb_lib::{relation::MemTable, Address};
Expand Down Expand Up @@ -198,7 +197,7 @@ pub struct OneOffQueryResponseMessage {
impl ServerMessage for OneOffQueryResponseMessage {
fn serialize_text(self) -> MessageJson {
MessageJson::OneOffQueryResponse(OneOffQueryResponseJson {
message_id_base64: base64::engine::general_purpose::STANDARD.encode(self.message_id),
message_id_base64: simple_base64::encode(self.message_id),
error: self.error,
result: self
.results
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/host/module_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::protobuf::client_api::{table_row_operation, SubscriptionUpdate, Table
use crate::subscription::module_subscription_actor::ModuleSubscriptionManager;
use crate::util::lending_pool::{Closed, LendingPool, LentResource, PoolClosed};
use crate::util::notify_once::NotifyOnce;
use base64::{engine::general_purpose::STANDARD as BASE_64_STD, Engine as _};
use futures::{Future, FutureExt};
use indexmap::IndexMap;
use spacetimedb_lib::relation::MemTable;
Expand Down Expand Up @@ -128,7 +127,7 @@ impl DatabaseUpdate {
.ops
.into_iter()
.map(|op| {
let row_pk = BASE_64_STD.encode(&op.row_pk);
let row_pk = simple_base64::encode(&op.row_pk);
TableRowOperationJson {
op: if op.op_type == 1 {
"insert".into()
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spacetimedb-client-api-messages = { path = "../client-api-messages", version = "

anyhow.workspace = true
anymap.workspace = true
base64.workspace = true
simple-base64.workspace = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorder to alphabetical please.

futures.workspace = true
futures-channel.workspace = true
home.workspace = true
Expand Down
4 changes: 1 addition & 3 deletions crates/sdk/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ const AUTH_HEADER_KEY: &str = "Authorization";
fn request_insert_auth_header(req: &mut http::Request<()>, credentials: Option<&Credentials>) {
// TODO: figure out how the token is supposed to be encoded in the request
if let Some(Credentials { token, .. }) = credentials {
use base64::Engine;

let auth_bytes = format!("token:{}", token.string);
let encoded = base64::prelude::BASE64_STANDARD.encode(auth_bytes);
let encoded = simple_base64::encode(auth_bytes);
let auth_header_val = format!("Basic {}", encoded);
request_add_header(
req,
Expand Down
Loading