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

Release #345

Merged
merged 5 commits into from
Dec 1, 2023
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
77 changes: 49 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ on:
- master
pull_request:


jobs:
style:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check format
run: cargo fmt --check
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check format
run: cargo fmt --check

clippy:
name: Clippy
Expand All @@ -36,27 +35,49 @@ jobs:
matrix:
build: [pinned, stable, nightly]
include:
- build: pinned
os: ubuntu-20.04
rust: 1.67.0
- build: stable
os: ubuntu-20.04
rust: stable
- build: nightly
os: ubuntu-20.04
rust: nightly
- build: pinned
os: ubuntu-20.04
rust: 1.67.0
- build: stable
os: ubuntu-20.04
rust: stable
- build: nightly
os: ubuntu-20.04
rust: nightly
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Build System Info
run: rustc --version

- name: Run tests default features
run: cargo test

- name: Run tests no features
run: cargo test --no-default-features

wasm:
name: Run tests in wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- uses: actions/setup-node@v4

- name: Install wasm-pack
run: cargo install wasm-pack

- name: Build System Info
run: rustc --version
- name: Run tests default features
run: wasm-pack test --node

- name: Run tests default features
run: cargo test
- name: Run tests no features
run: wasm-pack test --node --no-default-features

- name: Run tests no features
run: cargo test --no-default-features
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 9.2.0 (2023-12-01)

- Add an option to not validate `aud` in the Validation struct
- Get the current timestamp in wasm without using std

## 9.1.0 (2023-10-21)

- Supports deserialization of unsupported algorithms for JWKs
Expand Down
26 changes: 20 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jsonwebtoken"
version = "9.1.0"
version = "9.2.0"
authors = ["Vincent Prouillet <[email protected]>"]
license = "MIT"
readme = "README.md"
Expand All @@ -9,30 +9,44 @@ homepage = "https://github.com/Keats/jsonwebtoken"
repository = "https://github.com/Keats/jsonwebtoken"
keywords = ["jwt", "api", "token", "jwk"]
edition = "2021"
include = ["src/**/*", "benches/**/*", "tests/**/*", "LICENSE", "README.md", "CHANGELOG.md"]
include = [
"src/**/*",
"benches/**/*",
"tests/**/*",
"LICENSE",
"README.md",
"CHANGELOG.md",
]
rust-version = "1.67.0"

[dependencies]
serde_json = "1.0"
serde = {version = "1.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
base64 = "0.21.0"
# For PEM decoding
pem = {version = "3", optional = true}
simple_asn1 = {version = "0.6", optional = true}
pem = { version = "3", optional = true }
simple_asn1 = { version = "0.6", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ring = { version = "0.17.4", features = ["std"] }


[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3"
ring = { version = "0.17.4", features = ["std", "wasm32_unknown_unknown_js"] }

[dev-dependencies]
wasm-bindgen-test = "0.3.1"

[target.'cfg(not(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi")))))'.dev-dependencies]
# For the custom time example
time = "0.3"
criterion = "0.4"

[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dev-dependencies]
# For the custom time example
time = { version = "0.3", features = ["wasm-bindgen"] }
criterion = { version = "0.4", default-features = false }

[features]
default = ["use_pem"]
use_pem = ["pem", "simple_asn1"]
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header,
struct Claims {
sub: String,
company: String,
exp: usize,
exp: u64,
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct Claims {
aud: String,
sub: String,
company: String,
exp: usize,
exp: u64,
}

fn main() {
Expand Down
3 changes: 3 additions & 0 deletions src/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ impl Algorithm {

#[cfg(test)]
mod tests {
use wasm_bindgen_test::wasm_bindgen_test;

use super::*;

#[test]
#[wasm_bindgen_test]
fn generate_algorithm_enum_from_str() {
assert!(Algorithm::from_str("HS256").is_ok());
assert!(Algorithm::from_str("HS384").is_ok());
Expand Down
3 changes: 3 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ impl From<ErrorKind> for Error {

#[cfg(test)]
mod tests {
use wasm_bindgen_test::wasm_bindgen_test;

use super::*;

#[test]
#[wasm_bindgen_test]
fn test_error_rendering() {
assert_eq!(
"InvalidAlgorithmName",
Expand Down
2 changes: 2 additions & 0 deletions src/jwk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,10 @@ mod tests {
use crate::serialization::b64_encode;
use crate::Algorithm;
use serde_json::json;
use wasm_bindgen_test::wasm_bindgen_test;

#[test]
#[wasm_bindgen_test]
fn check_hs256() {
let key = b64_encode("abcdefghijklmnopqrstuvwxyz012345");
let jwks_json = json!({
Expand Down
Loading