From 0c68421d6ab0307beaf6254173de3da3678cfbd4 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 15:57:17 +0100 Subject: [PATCH 01/13] introduce error --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index 3268406..a899ec9 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: &str = "_sd"; +pub(crate) const DIGESTS_KEY: str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From 0755db2ab8c388c19663095763df78ab11d6d932 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:02:28 +0100 Subject: [PATCH 02/13] fix --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index a899ec9..3268406 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: str = "_sd"; +pub(crate) const DIGESTS_KEY: &str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From 955c43d7700437088b10c109658a685e11717ef5 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:11:53 +0100 Subject: [PATCH 03/13] error --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index 3268406..a899ec9 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: &str = "_sd"; +pub(crate) const DIGESTS_KEY: str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From 9e7aa1e8e37b27d4d33ffd84f098b029366a1ba9 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:31:27 +0100 Subject: [PATCH 04/13] fix --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index a899ec9..3268406 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: str = "_sd"; +pub(crate) const DIGESTS_KEY: &str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From 77728ab0f330caead98390aca1c44db566d936a7 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:32:39 +0100 Subject: [PATCH 05/13] error --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index 3268406..a899ec9 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: &str = "_sd"; +pub(crate) const DIGESTS_KEY: str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From 1417af2cfbe8f4d0198ac16275613311f0fa071b Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:37:52 +0100 Subject: [PATCH 06/13] error --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index a899ec9..3268406 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: str = "_sd"; +pub(crate) const DIGESTS_KEY: &str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From 4d32c15acb648b10cd4d590d74be1e055a018506 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:38:38 +0100 Subject: [PATCH 07/13] error --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index 3268406..a899ec9 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,7 +15,7 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: &str = "_sd"; +pub(crate) const DIGESTS_KEY: str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From f1a9b42c30f7c7871e24be6e83a94d699ade8916 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 17:29:04 +0100 Subject: [PATCH 08/13] error --- src/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index a899ec9..23d3cea 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -16,7 +16,7 @@ use serde_json::Map; use serde_json::Value; pub(crate) const DIGESTS_KEY: str = "_sd"; -pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; +pub(crate) const ARRAY_DIGEST_KEY: str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; /// Transforms a JSON object into an SD-JWT object by substituting selected values From 41cb724f4231915ebaa67b372ce25be8d1712e8e Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 18:02:30 +0100 Subject: [PATCH 09/13] error --- src/encoder.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/encoder.rs b/src/encoder.rs index 23d3cea..e41a0d9 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -15,8 +15,9 @@ use serde_json::json; use serde_json::Map; use serde_json::Value; -pub(crate) const DIGESTS_KEY: str = "_sd"; -pub(crate) const ARRAY_DIGEST_KEY: str = "..."; +pub(crate) const DIGESTS_KEY: &str = "_sd"; + +pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; /// Transforms a JSON object into an SD-JWT object by substituting selected values From 5fdfb1b3c34175cd2b9e8a2b26c597c56a097d2f Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 18:09:28 +0100 Subject: [PATCH 10/13] error --- src/encoder.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/encoder.rs b/src/encoder.rs index e41a0d9..a33e16a 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -18,6 +18,7 @@ use serde_json::Value; pub(crate) const DIGESTS_KEY: &str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; + pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; /// Transforms a JSON object into an SD-JWT object by substituting selected values From 5b809de3644c5a1e4e979b9d9d42f980efd46318 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 18:12:06 +0100 Subject: [PATCH 11/13] fix --- src/disclosure.rs | 2 +- src/encoder.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/disclosure.rs b/src/disclosure.rs index 25a1a23..4d91979 100644 --- a/src/disclosure.rs +++ b/src/disclosure.rs @@ -1,9 +1,9 @@ // Copyright 2020-2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::fmt::Display; use crate::Error; use serde_json::Value; +use std::fmt::Display; /// Represents an elements constructing a disclosure. /// Object properties and array elements disclosures are supported. diff --git a/src/encoder.rs b/src/encoder.rs index a33e16a..e043ad1 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -16,7 +16,6 @@ use serde_json::Map; use serde_json::Value; pub(crate) const DIGESTS_KEY: &str = "_sd"; - pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; From adf05d3305ea9ac26e05ec5e722dcf2cf94d8f18 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 16:27:35 +0100 Subject: [PATCH 12/13] Action build and test + audit --- .../actions/publish/publish-rust/action.yml | 31 +++++++++++ .github/workflows/audit.yml | 28 ++++++++++ .github/workflows/build-and-test.yml | 53 +++++++++++++++++++ .github/workflows/build-windows.yml | 45 ++++++++++++++++ .github/workflows/format.yml | 43 +++++++++++++++ .license_template | 2 + Cargo.toml | 4 +- 7 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 .github/actions/publish/publish-rust/action.yml create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/build-windows.yml create mode 100644 .github/workflows/format.yml create mode 100644 .license_template diff --git a/.github/actions/publish/publish-rust/action.yml b/.github/actions/publish/publish-rust/action.yml new file mode 100644 index 0000000..4e02fd6 --- /dev/null +++ b/.github/actions/publish/publish-rust/action.yml @@ -0,0 +1,31 @@ +name: 'publish-rust' +description: 'Publishes Rust library to crates.io' +inputs: + crates-token: + description: 'used for authenticating towards crates.io' + required: true + version: + description: 'the version to release under (e.g. `1.2.3-dev.1`)' + required: true + dry-run: + description: "'true' = only log potential result; 'false' = publish'" + required: true +runs: + using: "composite" + steps: + - name: Setup Rust + uses: './.github/actions/rust/rust-setup' + with: + os: ${{ runner.os }} + job: ${{ github.job }} + + - name: Install cargo-release + shell: bash + run: cargo install cargo-release + + - name: Publish library to crates.io + shell: bash + run: | + echo "dry-run: '${{ inputs.dry-run }}'" + echo "version: '${{ inputs.version }}'" + cargo release --workspace --token ${{ inputs.crates-token }} --isolated --no-dev-version --no-push --no-tag --dependent-version error --verbose $(if [ "${{ inputs.dry-run }}" = "false" ]; then echo --execute --no-confirm; fi) ${{ inputs.version }} diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..ba2412e --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,28 @@ +name: Audit + +on: + push: + branches: + - main + paths: + - "**/Cargo.lock" + - "**/Cargo.toml" + - ".github/workflows/audit.yml" + - ".cargo/audit.toml" + pull_request: + branches: + - main + paths: + - "**/Cargo.lock" + - "**/Cargo.toml" + - ".github/workflows/audit.yml" + - ".cargo/audit.toml" + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..45d94e8 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,53 @@ +name: Build and run tests Ubuntu + +on: + push: + branches: + - main + pull_request: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - main + - 'epic/**' + - 'support/**' + paths: + - '.github/workflows/build-and-test.yml' + - '.github/actions/**' + - '**.rs' + - '**.toml' + +env: + RUST_BACKTRACE: full + +jobs: + check-for-run-condition: + runs-on: ubuntu-latest + outputs: + should-run: ${{ !github.event.pull_request || github.event.pull_request.draft == false }} + steps: + - run: | + # this run step does nothing, but is needed to get the job output + + build-and-test: + runs-on: ubuntu-latest + needs: [ check-for-run-condition ] + if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Setup Rust + uses: './.github/actions/rust/rust-setup' + + - name: Build + run: cargo build --workspace --tests --examples --all-features --release + + - name: Run tests + run: cargo test --workspace --all-features --release + + - name: Run Rust example + run: cargo run --example sd_jwt diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 0000000..3c7c2b1 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,45 @@ +name: Build and run tests Windows + +on: + push: + branches: + - main + pull_request: + types: [ opened, synchronize, reopened, ready_for_review ] + branches: + - main + - 'epic/**' + - 'support/**' + paths: + - '.github/workflows/build-and-test.yml' + - '.github/actions/**' + - '**.rs' + - '**.toml' + +env: + RUST_BACKTRACE: full + +jobs: + check-for-run-condition: + runs-on: ubuntu-latest + outputs: + should-run: ${{ !github.event.pull_request || github.event.pull_request.draft == false }} + steps: + - run: | + # this run step does nothing, but is needed to get the job output + + build-and-test: + runs-on: windows-latest + needs: [ check-for-run-condition ] + if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - name: Setup Rust + uses: './.github/actions/rust/rust-setup' + + - name: Build + run: cargo build --workspace --all-features --release diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..d3ddb49 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,43 @@ +name: Format + +on: + push: + branches: + - main + pull_request: + branches: + - main + - 'epic/**' + - 'support/**' + paths: + - '.github/workflows/format.yml' + - '**.rs' + - '**.toml' + - '**.ts' + - '**.js' + - '**.json' + +jobs: + format: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + # we use nightly to get access to advanced format capabilities + - name: Setup Rust + uses: './.github/actions/rust/rust-setup' + with: + toolchain: nightly + components: rustfmt + + - name: Install cargo-license-template + run: cargo install cargo-license-template + + - name: core fmt check + run: cargo +nightly fmt --all -- --check + + - name: cargo-license-template check + run: cargo +nightly license-template --template .license_template --ignore .license_template_ignore --verbose diff --git a/.license_template b/.license_template new file mode 100644 index 0000000..30334dd --- /dev/null +++ b/.license_template @@ -0,0 +1,2 @@ +// Copyright {20\d{2}(-20\d{2})?} IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 diff --git a/Cargo.toml b/Cargo.toml index d84fa84..30bcfac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,8 @@ edition = "2021" authors = ["IOTA Stiftung"] homepage = "https://www.iota.org" license = "Apache-2.0" +repository = "https://github.com/iotaledger/sd-jwt" +rust-version = "1.65" [dependencies] multibase = { version = "0.9", default-features = false, features = ["std"] } @@ -12,7 +14,7 @@ serde_json = { version = "1.0", default-features = false, features = ["std" ] } rand = { version = "0.8.5", default-features = false, features = ["std", "std_rng"] } thiserror = { version = "1.0", default-features = false } strum = { version = "0.25", default-features = false, features = ["std", "derive"] } -itertools = { version = "0.11", default-features = false, features = ["use_std"] } +itertools = { version = "0.12", default-features = false, features = ["use_std"] } iota-crypto = { version = "0.23", default-features = false, features = ["std", "sha"] } serde = { version = "1.0", default-features = false, features = ["derive"] } From e84e45cfa8d5761b7a955e94604ff07d69c70932 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 30 Nov 2023 18:37:21 +0100 Subject: [PATCH 13/13] fix --- src/encoder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index e043ad1..3268406 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -17,7 +17,6 @@ use serde_json::Value; pub(crate) const DIGESTS_KEY: &str = "_sd"; pub(crate) const ARRAY_DIGEST_KEY: &str = "..."; - pub(crate) const DEFAULT_SALT_RANGE: Range = 24..34; /// Transforms a JSON object into an SD-JWT object by substituting selected values