Skip to content

Commit 95d8146

Browse files
committed
Revert "Bump deps (#61)"
This reverts commit 750c038.
1 parent 6345e60 commit 95d8146

File tree

5 files changed

+31
-43
lines changed

5 files changed

+31
-43
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ isahc-client = ["isahc", "futures-lite/futures-io"] #futures are only used for
1818
hyper-client = ["hyper", "hyper-tls"] #use features = ["hyper-client"], default-features = false for about 300kb size decrease.
1919

2020
[dependencies]
21-
hyper = { version = "^1", features = ["client", "http1"], optional = true }
22-
hyper-tls = { version = "^0.6", optional = true }
21+
hyper = { version = "^0.14", features = ["client", "http1"], optional = true }
22+
hyper-tls = { version = "^0.5", optional = true }
2323
isahc = { version = "^1.4.0", optional = true }
24-
futures-lite = { version = "^2", optional = true }
24+
futures-lite = { version = "^1.12", optional = true }
2525
http = "^0.2"
2626
serde = "^1.0"
2727
serde_json = "^1.0"
2828
serde_derive = "^1.0"
29-
jwt-simple = "0.12"
29+
jwt-simple = "0.11.2"
3030
ece = "^2.2"
31-
pem = "3"
31+
pem = "1.1.0"
3232
sec1_decode = "^0.1.0"
33-
base64 = "^0.22"
33+
base64 = "^0.13"
3434
chrono = "^0.4"
3535
log = "^0.4"
3636
async-trait = "^0.1"

src/http_ece.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Payload encryption algorithm
22
3-
use base64::prelude::BASE64_URL_SAFE_NO_PAD;
4-
use base64::Engine;
53
use ece::encrypt;
64

75
use crate::error::WebPushError;
@@ -92,7 +90,7 @@ impl<'a> HttpEce<'a> {
9290
self.add_vapid_headers(&mut headers);
9391

9492
// ECE library base64 encodes content in aesgcm, but not aes128gcm, so decode base64 here to match the 128 API
95-
let data = BASE64_URL_SAFE_NO_PAD.decode(data.body())
93+
let data = base64::decode_config(data.body(), base64::URL_SAFE_NO_PAD)
9694
.expect("ECE library should always base64 encode");
9795

9896
Ok(WebPushPayload {
@@ -113,7 +111,7 @@ impl<'a> HttpEce<'a> {
113111
format!(
114112
"vapid t={}, k={}",
115113
signature.auth_t,
116-
BASE64_URL_SAFE_NO_PAD.encode(&signature.auth_k)
114+
base64::encode_config(&signature.auth_k, base64::URL_SAFE_NO_PAD)
117115
),
118116
));
119117
}
@@ -129,8 +127,7 @@ impl<'a> HttpEce<'a> {
129127

130128
#[cfg(test)]
131129
mod tests {
132-
use base64::prelude::BASE64_URL_SAFE;
133-
use base64::Engine;
130+
use base64::{self, URL_SAFE};
134131
use regex::Regex;
135132

136133
use crate::error::WebPushError;
@@ -140,11 +137,12 @@ mod tests {
140137

141138
#[test]
142139
fn test_payload_too_big() {
143-
let p256dh = BASE64_URL_SAFE.decode(
140+
let p256dh = base64::decode_config(
144141
"BLMaF9ffKBiWQLCKvTHb6LO8Nb6dcUh6TItC455vu2kElga6PQvUmaFyCdykxY2nOSSL3yKgfbmFLRTUaGv4yV8",
145-
)
142+
URL_SAFE,
143+
)
146144
.unwrap();
147-
let auth = BASE64_URL_SAFE.decode("xS03Fj5ErfTNH_l9WHE9Ig").unwrap();
145+
let auth = base64::decode_config("xS03Fj5ErfTNH_l9WHE9Ig", URL_SAFE).unwrap();
148146
let http_ece = HttpEce::new(ContentEncoding::Aes128Gcm, &p256dh, &auth, None);
149147
//This content is one above limit.
150148
let content = [0u8; 3801];
@@ -193,11 +191,12 @@ mod tests {
193191
}
194192

195193
fn setup_payload(vapid_signature: Option<VapidSignature>, encoding: ContentEncoding) -> WebPushPayload {
196-
let p256dh = BASE64_URL_SAFE.decode(
194+
let p256dh = base64::decode_config(
197195
"BLMbF9ffKBiWQLCKvTHb6LO8Nb6dcUh6TItC455vu2kElga6PQvUmaFyCdykxY2nOSSL3yKgfbmFLRTUaGv4yV8",
198-
)
196+
URL_SAFE,
197+
)
199198
.unwrap();
200-
let auth = BASE64_URL_SAFE.decode("xS03Fi5ErfTNH_l9WHE9Ig").unwrap();
199+
let auth = base64::decode_config("xS03Fi5ErfTNH_l9WHE9Ig", URL_SAFE).unwrap();
201200

202201
let http_ece = HttpEce::new(encoding, &p256dh, &auth, vapid_signature);
203202
let content = "Hello, world!".as_bytes();

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ pub use crate::message::{
6262
};
6363
pub use crate::vapid::builder::PartialVapidSignatureBuilder;
6464
pub use crate::vapid::{VapidSignature, VapidSignatureBuilder};
65-
pub use base64::alphabet::{BCRYPT, BIN_HEX, CRYPT, IMAP_MUTF7, STANDARD, URL_SAFE};
66-
pub use base64::engine::GeneralPurposeConfig;
65+
pub use base64::{Config, BCRYPT, BINHEX, CRYPT, IMAP_MUTF7, STANDARD, STANDARD_NO_PAD, URL_SAFE, URL_SAFE_NO_PAD};
6766

6867
mod clients;
6968
mod error;

src/message.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use base64::prelude::BASE64_URL_SAFE;
2-
use base64::Engine;
31
use http::uri::Uri;
42
use std::fmt::{Display, Formatter};
53

@@ -185,8 +183,8 @@ impl<'a> WebPushMessageBuilder<'a> {
185183
.transpose()?;
186184

187185
if let Some(payload) = self.payload {
188-
let p256dh = BASE64_URL_SAFE.decode(&self.subscription_info.keys.p256dh)?;
189-
let auth = BASE64_URL_SAFE.decode(&self.subscription_info.keys.auth)?;
186+
let p256dh = base64::decode_config(&self.subscription_info.keys.p256dh, base64::URL_SAFE)?;
187+
let auth = base64::decode_config(&self.subscription_info.keys.auth, base64::URL_SAFE)?;
190188

191189
let http_ece = HttpEce::new(payload.encoding, &p256dh, &auth, self.vapid_signature);
192190

src/vapid/builder.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use std::collections::BTreeMap;
22
use std::io::Read;
33

4-
use base64::alphabet::Alphabet;
5-
use base64::engine::{GeneralPurpose, GeneralPurposeConfig};
6-
use base64::Engine;
74
use http::uri::Uri;
85
use jwt_simple::prelude::*;
96
use serde_json::Value;
@@ -76,6 +73,7 @@ use crate::vapid::{VapidKey, VapidSignature, VapidSigner};
7673
/// let signature = sig_builder.build().unwrap();
7774
/// # }
7875
/// ```
76+
7977
pub struct VapidSignatureBuilder<'a> {
8078
claims: Claims,
8179
key: VapidKey,
@@ -168,12 +166,11 @@ impl<'a> VapidSignatureBuilder<'a> {
168166
/// ```
169167
pub fn from_base64(
170168
encoded: &str,
171-
alphabet: &Alphabet,
172-
config: GeneralPurposeConfig,
169+
config: base64::Config,
173170
subscription_info: &'a SubscriptionInfo,
174171
) -> Result<VapidSignatureBuilder<'a>, WebPushError> {
175172
let pr_key = ES256KeyPair::from_bytes(
176-
&GeneralPurpose::new(alphabet, config).decode(encoded).map_err(|_| WebPushError::InvalidCryptoKeys)?,
173+
&base64::decode_config(encoded, config).map_err(|_| WebPushError::InvalidCryptoKeys)?,
177174
)
178175
.map_err(|_| WebPushError::InvalidCryptoKeys)?;
179176

@@ -184,11 +181,10 @@ impl<'a> VapidSignatureBuilder<'a> {
184181
/// allowing the reuse of one builder for multiple messages by cloning the resulting builder.
185182
pub fn from_base64_no_sub(
186183
encoded: &str,
187-
alphabet: &Alphabet,
188-
config: GeneralPurposeConfig,
184+
config: base64::Config,
189185
) -> Result<PartialVapidSignatureBuilder, WebPushError> {
190186
let pr_key = ES256KeyPair::from_bytes(
191-
&GeneralPurpose::new(alphabet, config).decode(encoded).map_err(|_| WebPushError::InvalidCryptoKeys)?,
187+
&base64::decode_config(encoded, config).map_err(|_| WebPushError::InvalidCryptoKeys)?,
192188
)
193189
.map_err(|_| WebPushError::InvalidCryptoKeys)?;
194190

@@ -234,8 +230,8 @@ impl<'a> VapidSignatureBuilder<'a> {
234230
//Parse many PEM in the assumption of extra unneeded sections.
235231
let parsed = pem::parse_many(&buffer).map_err(|_| WebPushError::InvalidCryptoKeys)?;
236232

237-
let found_pkcs8 = parsed.iter().any(|pem| pem.tag() == "PRIVATE KEY");
238-
let found_sec1 = parsed.iter().any(|pem| pem.tag() == "EC PRIVATE KEY");
233+
let found_pkcs8 = parsed.iter().any(|pem| pem.tag == "PRIVATE KEY");
234+
let found_sec1 = parsed.iter().any(|pem| pem.tag == "EC PRIVATE KEY");
239235

240236
//Handle each kind of PEM file differently, as EC keys can be in SEC1 or PKCS8 format.
241237
if found_sec1 {
@@ -300,10 +296,6 @@ impl PartialVapidSignatureBuilder {
300296
mod tests {
301297
use std::fs::File;
302298

303-
use base64::alphabet::STANDARD;
304-
use base64::engine::GeneralPurposeConfig;
305-
use base64::prelude::BASE64_URL_SAFE_NO_PAD;
306-
use base64::Engine;
307299
use ::lazy_static::lazy_static;
308300

309301
use crate::message::SubscriptionInfo;
@@ -336,7 +328,7 @@ mod tests {
336328

337329
assert_eq!(
338330
"BMo1HqKF6skMZYykrte9duqYwBD08mDQKTunRkJdD3sTJ9E-yyN6sJlPWTpKNhp-y2KeS6oANHF-q3w37bClb7U",
339-
BASE64_URL_SAFE_NO_PAD.encode(&signature.auth_k)
331+
base64::encode_config(&signature.auth_k, base64::URL_SAFE_NO_PAD)
340332
);
341333

342334
assert!(!signature.auth_t.is_empty());
@@ -349,7 +341,7 @@ mod tests {
349341

350342
assert_eq!(
351343
"BMo1HqKF6skMZYykrte9duqYwBD08mDQKTunRkJdD3sTJ9E-yyN6sJlPWTpKNhp-y2KeS6oANHF-q3w37bClb7U",
352-
BASE64_URL_SAFE_NO_PAD.encode(&signature.auth_k)
344+
base64::encode_config(&signature.auth_k, base64::URL_SAFE_NO_PAD)
353345
);
354346

355347
assert!(!signature.auth_t.is_empty());
@@ -358,12 +350,12 @@ mod tests {
358350
#[test]
359351
fn test_builder_from_base64() {
360352
let builder =
361-
VapidSignatureBuilder::from_base64(PRIVATE_BASE64, &STANDARD, GeneralPurposeConfig::new().with_encode_padding(false), &SUBSCRIPTION_INFO).unwrap();
353+
VapidSignatureBuilder::from_base64(PRIVATE_BASE64, base64::URL_SAFE_NO_PAD, &SUBSCRIPTION_INFO).unwrap();
362354
let signature = builder.build().unwrap();
363355

364356
assert_eq!(
365357
"BMjQIp55pdbU8pfCBKyXcZjlmER_mXt5LqNrN1hrXbdBS5EnhIbMu3Au-RV53iIpztzNXkGI56BFB1udQ8Bq_H4",
366-
BASE64_URL_SAFE_NO_PAD.encode(&signature.auth_k)
358+
base64::encode_config(&signature.auth_k, base64::URL_SAFE_NO_PAD)
367359
);
368360

369361
assert!(!signature.auth_t.is_empty());

0 commit comments

Comments
 (0)