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

Refactor StatusList2021 to use String for credential index #1422

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl WasmStatusList2021Entry {

/// Returns the index of this entry.
#[wasm_bindgen]
pub fn index(&self) -> usize {
self.0.index()
pub fn index(&self) -> String {
self.0.index().to_string()
}

/// Returns the referenced {@link StatusList2021Credential}'s url.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl StatusList2021Credential {
.id()
.cloned()
.ok_or(StatusList2021CredentialError::Unreferenceable)?;

let entry = StatusList2021Entry::new(id, self.purpose(), index, None);

self.set_entry(index, revoked_or_suspended)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ pub struct StatusList2021Entry {
#[serde(rename = "type", deserialize_with = "deserialize_status_entry_type")]
type_: String,
status_purpose: StatusPurpose,
#[serde(deserialize_with = "serde_aux::prelude::deserialize_number_from_string")]
status_list_index: usize,
status_list_index: String,
status_list_credential: Url,
}

Expand Down Expand Up @@ -79,7 +78,7 @@ impl StatusList2021Entry {
type_: CREDENTIAL_STATUS_TYPE.to_owned(),
status_purpose: purpose,
status_list_credential: status_list,
status_list_index: index,
status_list_index: index.to_string(),
}
}

Expand All @@ -94,8 +93,8 @@ impl StatusList2021Entry {
}

/// Returns the index of this entry.
pub const fn index(&self) -> usize {
self.status_list_index
pub fn index(&self) -> &str {
&self.status_list_index
}

/// Returns the referenced [`StatusList2021Credential`]'s [`Url`].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl JwtCredentialValidatorUtils {
&& status.purpose() == status_list_credential.purpose()
{
let entry_status = status_list_credential
.entry(status.index())
.entry(status.index().parse().expect("Failed to parse index"))
.map_err(|e| JwtValidationError::InvalidStatus(crate::Error::InvalidStatus(e.to_string())))?;
match entry_status {
CredentialStatus::Revoked => Err(JwtValidationError::Revoked),
Expand Down
Loading