Skip to content

Commit

Permalink
fix: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderstabel committed Oct 3, 2023
1 parent 2324d26 commit d3a6724
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 44 deletions.
1 change: 1 addition & 0 deletions src-tauri/tests/common/credential_issuer/Cargo.lock

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

32 changes: 1 addition & 31 deletions src-tauri/tests/common/credential_issuer/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use anyhow::Result;
use async_trait::async_trait;
use derivative::{self, Derivative};
use ed25519_dalek::{Signature, Signer, SigningKey};
use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation};
use lazy_static::lazy_static;
use oid4vc_core::{authentication::sign::ExternalSign, JsonValue, Sign, Subject, Verify};
use oid4vc_core::{authentication::sign::ExternalSign, Sign, Subject, Verify};
use rand::rngs::OsRng;
use siopv2::{StandardClaimsRequests, StandardClaimsValues};

Expand All @@ -26,15 +25,6 @@ pub struct TestSubject {
pub key_id: String,
}

impl TestSubject {
pub fn new(did: String, key_id: String) -> Result<Self> {
Ok(TestSubject {
did: did_url::DID::parse(did)?,
key_id,
})
}
}

#[async_trait]
impl Sign for TestSubject {
fn key_id(&self) -> Option<String> {
Expand Down Expand Up @@ -66,12 +56,6 @@ impl Subject for TestSubject {

pub struct MockVerifier;

impl MockVerifier {
pub fn new() -> Self {
MockVerifier {}
}
}

#[async_trait]
impl Verify for MockVerifier {
async fn public_key(&self, _kid: &str) -> Result<Vec<u8>> {
Expand All @@ -88,12 +72,6 @@ pub struct MemoryStorage {
data: StandardClaimsValues,
}

impl MemoryStorage {
pub fn new(data: StandardClaimsValues) -> Self {
MemoryStorage { data }
}
}

impl Storage for MemoryStorage {
fn fetch_claims(&self, request_claims: &StandardClaimsRequests) -> StandardClaimsValues {
let mut present = StandardClaimsValues::default();
Expand Down Expand Up @@ -129,11 +107,3 @@ impl Storage for MemoryStorage {
present
}
}

// Get the claims from a JWT without performing validation.
pub fn get_jwt_claims(jwt: &JsonValue) -> JsonValue {
let key = DecodingKey::from_secret(&[]);
let mut validation = Validation::new(Algorithm::EdDSA);
validation.insecure_disable_signature_validation();
decode(jwt.as_str().unwrap(), &key, &validation).unwrap().claims
}
16 changes: 3 additions & 13 deletions src-tauri/tests/common/credential_issuer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
mod common;

use crate::common::{get_jwt_claims, memory_storage::MemoryStorage};
use crate::common::memory_storage::MemoryStorage;
use did_key::{generate, Ed25519KeyPair};
use oid4vc_core::Subject;
use oid4vc_manager::{
managers::credential_issuer::CredentialIssuerManager, methods::key_method::KeySubject,
servers::credential_issuer::Server,
};
use oid4vci::{
credential_format_profiles::CredentialFormats,
credential_offer::{CredentialOffer, CredentialOfferQuery, CredentialsObject, Grants},
credential_response::{BatchCredentialResponse, CredentialResponse, CredentialResponseType},
token_request::{PreAuthorizedCode, TokenRequest},
Wallet,
};
use oid4vci::credential_format_profiles::CredentialFormats;
use std::{net::TcpListener, sync::Arc};

#[tokio::main]
Expand All @@ -25,10 +18,7 @@ async fn main() {
MemoryStorage,
[Arc::new(KeySubject::from_keypair(
generate::<Ed25519KeyPair>(Some(
"this-is-a-very-UNSAFE-issuer-secret-key"
.as_bytes()
.try_into()
.unwrap(),
"this-is-a-very-UNSAFE-issuer-secret-key".as_bytes().try_into().unwrap(),
)),
None,
))],
Expand Down

0 comments on commit d3a6724

Please sign in to comment.