Skip to content
Merged
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
63 changes: 13 additions & 50 deletions svix-cli/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 svix-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ http = "1.2.0"
idna_adapter = "=1.1.0"
indoc = "2.0.5"
open = "5.3.1"
rand = "0.8.5"
rand = "0.9"
reqwest = { version = "0.13.2", features = ["rustls", "json", "charset", "http2"], default-features = false }
rustls = "0.23.34"
serde = { version = "1.0.215", features = ["derive"] }
Expand Down
6 changes: 2 additions & 4 deletions svix-cli/src/cmds/seed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Context;
use clap::Args;
use rand::{rngs::StdRng, seq::SliceRandom, SeedableRng};
use rand::prelude::*;
use serde::{Deserialize, Serialize};
use serde_json::json;
use svix::api::*;
Expand Down Expand Up @@ -162,10 +162,8 @@ async fn create_endpoint(client: Svix, app_id: String) -> anyhow::Result<Endpoin
}

async fn create_message(client: Svix, app_id: String) -> anyhow::Result<MessageOut> {
let mut rng = StdRng::from_entropy();

let event_type = USER_EVENT_TYPES
.choose(&mut rng)
.choose(&mut rand::rng())
.context("Couldn't pick a random event type while creating a message")?;

let message_in = MessageIn {
Expand Down
16 changes: 8 additions & 8 deletions svix-cli/src/relay/token.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use anyhow::Result;
use rand::distributions::{Distribution, Uniform};
use rand::distr::Distribution;

const BASE62: &[u8; 62] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

pub fn generate_token() -> Result<String> {
let between = Uniform::from(0..BASE62.len());
let mut rng = rand::thread_rng();
let mut bytes = [0_u8; 27];
for b in &mut bytes {
*b = BASE62[between.sample(&mut rng)];
}
Ok(String::from_utf8(bytes.to_vec())?)
let distribution = rand::distr::slice::Choose::new(BASE62)?;
let mut rng = rand::rng();
Ok(distribution
.sample_iter(&mut rng)
.take(10)
.map(|c| *c as char)
.collect::<String>())
}

#[cfg(test)]
Expand Down
Loading