Skip to content

Commit

Permalink
Remove old Presentation type (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulmth authored Jun 28, 2023
1 parent 58fced1 commit 182190e
Show file tree
Hide file tree
Showing 42 changed files with 395 additions and 4,174 deletions.
518 changes: 1 addition & 517 deletions bindings/wasm/docs/api-reference.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/wasm/src/credential/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl WasmCredential {
.map(|value| value.unchecked_into::<ArrayEvidence>())
}

/// Returns whether or not the `Credential` must only be contained within a {@link Presentation}
/// Returns whether or not the `Credential` must only be contained within a `Presentation`
/// with a proof issued from the `Credential` subject.
#[wasm_bindgen(js_name = "nonTransferable")]
pub fn non_transferable(&self) -> Option<bool> {
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/src/credential/credential_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct ICredentialHelper {
/// Human-readable evidence used to support the claims within the `Credential`.
#[typescript(type = "Evidence | Array<Evidence>")]
evidence: Option<OneOrMany<Evidence>>,
/// Indicates that the `Credential` must only be contained within a {@link Presentation} with a proof issued from the
/// Indicates that the `Credential` must only be contained within a `Presentation` with a proof issued from the
/// `Credential` subject.
#[typescript(name = "nonTransferable", type = "boolean")]
non_transferable: Option<bool>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity_iota::credential::vc_jwt_validation::DecodedJwtCredential;
use identity_iota::credential::DecodedJwtCredential;
use wasm_bindgen::prelude::*;

use crate::credential::WasmCredential;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

use identity_iota::core::Object;
use identity_iota::core::Url;
use identity_iota::credential::vc_jwt_validation::CredentialValidator as JwtCredentialValidator;
use identity_iota::credential::CredentialValidator as JwtCredentialValidator;
use identity_iota::credential::StatusCheck;
use identity_iota::did::CoreDID;

use super::options::WasmJwtCredentialValidationOptions;
use crate::common::ImportedDocumentLock;
use crate::common::ImportedDocumentReadGuard;
use crate::common::WasmTimestamp;
use crate::credential::validation_options::WasmStatusCheck;
use crate::credential::options::WasmStatusCheck;
use crate::credential::WasmCredential;
use crate::credential::WasmDecodedJwtCredential;
use crate::credential::WasmFailFast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::error::Result;
use crate::error::WasmResult;
use wasm_bindgen::prelude::*;

use identity_iota::credential::vc_jwt_validation::CredentialValidationOptions as JwtCredentialValidationOptions;
use identity_iota::credential::CredentialValidationOptions as JwtCredentialValidationOptions;

/// Options to declare validation criteria when validating credentials.
#[wasm_bindgen(js_name = JwtCredentialValidationOptions)]
Expand Down
16 changes: 3 additions & 13 deletions bindings/wasm/src/credential/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@

pub use self::credential::WasmCredential;
pub use self::credential_builder::*;
pub use self::credential_validator::WasmCredentialValidator;
pub use self::domain_linkage_configuration::WasmDomainLinkageConfiguration;
pub use self::jws::WasmJws;
pub use self::jwt::WasmJwt;
pub use self::jwt_credential_validation::*;
pub use self::jwt_presentation::*;
pub use self::jwt_presentation_validation::*;
pub use self::presentation::WasmPresentation;
pub use self::presentation_builder::*;
pub use self::presentation_validator::WasmPresentationValidator;
pub use self::options::WasmFailFast;
pub use self::options::WasmSubjectHolderRelationship;
pub use self::types::*;
pub use self::validation_options::WasmCredentialValidationOptions;
pub use self::validation_options::WasmFailFast;
pub use self::validation_options::WasmPresentationValidationOptions;
pub use self::validation_options::WasmSubjectHolderRelationship;

mod credential;
mod credential_builder;
mod credential_validator;
mod domain_linkage_configuration;
mod domain_linkage_credential_builder;
mod domain_linkage_validator;
Expand All @@ -33,8 +26,5 @@ mod jwt_credential_validation;
mod jwt_presentation;
mod jwt_presentation_validation;
mod linked_domain_service;
mod presentation;
mod presentation_builder;
mod presentation_validator;
mod options;
mod types;
mod validation_options;
86 changes: 86 additions & 0 deletions bindings/wasm/src/credential/options.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2020-2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity_iota::credential::FailFast;
use identity_iota::credential::StatusCheck;
use identity_iota::credential::SubjectHolderRelationship;
use serde_repr::Deserialize_repr;
use serde_repr::Serialize_repr;
use wasm_bindgen::prelude::*;

/// Controls validation behaviour when checking whether or not a credential has been revoked by its
/// [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status).
#[wasm_bindgen(js_name = StatusCheck)]
#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum WasmStatusCheck {
/// Validate the status if supported, reject any unsupported
/// [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types.
///
/// Only `RevocationBitmap2022` is currently supported.
///
/// This is the default.
Strict = 0,
/// Validate the status if supported, skip any unsupported
/// [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types.
SkipUnsupported = 1,
/// Skip all status checks.
SkipAll = 2,
}

impl From<WasmStatusCheck> for StatusCheck {
fn from(status_check: WasmStatusCheck) -> Self {
match status_check {
WasmStatusCheck::Strict => Self::Strict,
WasmStatusCheck::SkipUnsupported => Self::SkipUnsupported,
WasmStatusCheck::SkipAll => Self::SkipAll,
}
}
}

/// Declares how credential subjects must relate to the presentation holder during validation.
/// See `PresentationValidationOptions::subject_holder_relationship`.
///
/// See also the [Subject-Holder Relationship](https://www.w3.org/TR/vc-data-model/#subject-holder-relationships) section of the specification.
#[wasm_bindgen(js_name = SubjectHolderRelationship)]
#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum WasmSubjectHolderRelationship {
/// The holder must always match the subject on all credentials, regardless of their [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property.
/// This variant is the default used if no other variant is specified when constructing a new
/// `PresentationValidationOptions`.
AlwaysSubject = 0,
/// The holder must match the subject only for credentials where the [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property is `true`.
SubjectOnNonTransferable = 1,
/// The holder is not required to have any kind of relationship to any credential subject.
Any = 2,
}

impl From<WasmSubjectHolderRelationship> for SubjectHolderRelationship {
fn from(subject_holder_relationship: WasmSubjectHolderRelationship) -> Self {
match subject_holder_relationship {
WasmSubjectHolderRelationship::AlwaysSubject => Self::AlwaysSubject,
WasmSubjectHolderRelationship::SubjectOnNonTransferable => Self::SubjectOnNonTransferable,
WasmSubjectHolderRelationship::Any => Self::Any,
}
}
}

/// Declares when validation should return if an error occurs.
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[wasm_bindgen(js_name = FailFast)]
pub enum WasmFailFast {
/// Return all errors that occur during validation.
AllErrors = 0,
/// Return after the first error occurs.
FirstError = 1,
}

impl From<WasmFailFast> for FailFast {
fn from(fail_fast: WasmFailFast) -> Self {
match fail_fast {
WasmFailFast::AllErrors => Self::AllErrors,
WasmFailFast::FirstError => Self::FirstError,
}
}
}
148 changes: 0 additions & 148 deletions bindings/wasm/src/credential/presentation.rs

This file was deleted.

Loading

0 comments on commit 182190e

Please sign in to comment.