From 0af2cc02798a568c300624f37aa3bdaf1032da9a Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 17 Jul 2023 15:40:07 +0200 Subject: [PATCH 01/11] Use `new Options()` over `Options.default()` --- bindings/wasm/examples/src/0_basic/5_create_vc.ts | 2 +- bindings/wasm/examples/src/0_basic/6_create_vp.ts | 2 +- bindings/wasm/examples/src/0_basic/7_revoke_vc.ts | 6 +++--- .../wasm/examples/src/1_advanced/5_domain_linkage.ts | 4 ++-- .../credential/jwt_credential_validation/options.rs | 9 +-------- .../credential/jwt_presentation_validation/options.rs | 9 +-------- bindings/wasm/src/error.rs | 2 +- bindings/wasm/src/storage/jwt_presentation_options.rs | 7 ------- bindings/wasm/tests/storage.ts | 10 +++++----- 9 files changed, 15 insertions(+), 36 deletions(-) diff --git a/bindings/wasm/examples/src/0_basic/5_create_vc.ts b/bindings/wasm/examples/src/0_basic/5_create_vc.ts index d7a90de3ad..c98ab2fc25 100644 --- a/bindings/wasm/examples/src/0_basic/5_create_vc.ts +++ b/bindings/wasm/examples/src/0_basic/5_create_vc.ts @@ -83,7 +83,7 @@ export async function createVC() { const decoded_credential = new JwtCredentialValidator().validate( credentialJwt, issuerDocument, - new JwtCredentialValidationOptions({}), + new JwtCredentialValidationOptions(), FailFast.FirstError, ); diff --git a/bindings/wasm/examples/src/0_basic/6_create_vp.ts b/bindings/wasm/examples/src/0_basic/6_create_vp.ts index deb43a8476..b5952cc887 100644 --- a/bindings/wasm/examples/src/0_basic/6_create_vp.ts +++ b/bindings/wasm/examples/src/0_basic/6_create_vp.ts @@ -101,7 +101,7 @@ export async function createVP() { const res = new JwtCredentialValidator().validate( credentialJwt, issuerDocument, - new JwtCredentialValidationOptions({}), + new JwtCredentialValidationOptions(), FailFast.FirstError, ); console.log("credentialjwt validation", res.intoCredential()); diff --git a/bindings/wasm/examples/src/0_basic/7_revoke_vc.ts b/bindings/wasm/examples/src/0_basic/7_revoke_vc.ts index 06fdcc7701..6410eb9675 100644 --- a/bindings/wasm/examples/src/0_basic/7_revoke_vc.ts +++ b/bindings/wasm/examples/src/0_basic/7_revoke_vc.ts @@ -136,7 +136,7 @@ export async function revokeVC() { jwtCredentialValidator.validate( credentialJwt, issuerDocument, - new JwtCredentialValidationOptions({}), + new JwtCredentialValidationOptions(), FailFast.FirstError, ); @@ -165,7 +165,7 @@ export async function revokeVC() { jwtCredentialValidator.validate( credentialJwt, issuerDocument, - new JwtCredentialValidationOptions({}), + new JwtCredentialValidationOptions(), FailFast.FirstError, ); console.log("Revocation Failed!"); @@ -206,7 +206,7 @@ export async function revokeVC() { jwtCredentialValidator.validate( credentialJwt, resolvedIssuerDoc, - new JwtCredentialValidationOptions({}), + new JwtCredentialValidationOptions(), FailFast.FirstError, ); diff --git a/bindings/wasm/examples/src/1_advanced/5_domain_linkage.ts b/bindings/wasm/examples/src/1_advanced/5_domain_linkage.ts index 347caa3319..c8e1302f9e 100644 --- a/bindings/wasm/examples/src/1_advanced/5_domain_linkage.ts +++ b/bindings/wasm/examples/src/1_advanced/5_domain_linkage.ts @@ -129,7 +129,7 @@ export async function domainLinkage() { issuerDocument, fetchedConfigurationResource, domainFoo, - JwtCredentialValidationOptions.default(), + new JwtCredentialValidationOptions(), ); // ===================================================== @@ -163,7 +163,7 @@ export async function domainLinkage() { didDocument, fetchedConfigurationResource, domains[0], - JwtCredentialValidationOptions.default(), + new JwtCredentialValidationOptions(), ); console.log("Successfully validated Domain Linkage!"); diff --git a/bindings/wasm/src/credential/jwt_credential_validation/options.rs b/bindings/wasm/src/credential/jwt_credential_validation/options.rs index 1b12183279..b89b673132 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/options.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/options.rs @@ -19,16 +19,9 @@ impl WasmJwtCredentialValidationOptions { let options: JwtCredentialValidationOptions = opts.into_serde().wasm_result()?; Ok(WasmJwtCredentialValidationOptions::from(options)) } else { - Ok(Self::default()) + Ok(WasmJwtCredentialValidationOptions::from(JwtCredentialValidationOptions::default())) } } - - /// Creates a new `JwtCredentialValidationOptions` with defaults. - #[allow(clippy::should_implement_trait)] - #[wasm_bindgen] - pub fn default() -> WasmJwtCredentialValidationOptions { - WasmJwtCredentialValidationOptions::from(JwtCredentialValidationOptions::default()) - } } impl_wasm_json!(WasmJwtCredentialValidationOptions, JwtCredentialValidationOptions); diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/options.rs b/bindings/wasm/src/credential/jwt_presentation_validation/options.rs index e654bcd1e5..54ffd7a01f 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/options.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/options.rs @@ -21,16 +21,9 @@ impl WasmJwtPresentationValidationOptions { let options: JwtPresentationValidationOptions = opts.into_serde().wasm_result()?; Ok(WasmJwtPresentationValidationOptions::from(options)) } else { - Ok(Self::default()) + Ok(WasmJwtPresentationValidationOptions::from(JwtPresentationValidationOptions::default())) } } - - /// Creates a new `JwtPresentationValidationOptions` with defaults. - #[allow(clippy::should_implement_trait)] - #[wasm_bindgen] - pub fn default() -> WasmJwtPresentationValidationOptions { - WasmJwtPresentationValidationOptions::from(JwtPresentationValidationOptions::default()) - } } impl_wasm_json!(WasmJwtPresentationValidationOptions, JwtPresentationValidationOptions); diff --git a/bindings/wasm/src/error.rs b/bindings/wasm/src/error.rs index 3bf961895d..9dcf89b65b 100644 --- a/bindings/wasm/src/error.rs +++ b/bindings/wasm/src/error.rs @@ -171,7 +171,7 @@ impl From for WasmError<'_> { impl From for WasmError<'_> { fn from(error: identity_iota::iota::block::Error) -> Self { Self { - name: Cow::Borrowed("iota_types::block::Error"), + name: Cow::Borrowed("iota_sdk::types::block::Error"), message: Cow::Owned(error.to_string()), } } diff --git a/bindings/wasm/src/storage/jwt_presentation_options.rs b/bindings/wasm/src/storage/jwt_presentation_options.rs index ef41c6ff3a..dde85493f1 100644 --- a/bindings/wasm/src/storage/jwt_presentation_options.rs +++ b/bindings/wasm/src/storage/jwt_presentation_options.rs @@ -23,13 +23,6 @@ impl WasmJwtPresentationOptions { Ok(WasmJwtPresentationOptions::from(JwtPresentationOptions::default())) } } - - /// Creates a new `JwtPresentationOptions` with defaults. - #[allow(clippy::should_implement_trait)] - #[wasm_bindgen] - pub fn default() -> WasmJwtPresentationOptions { - WasmJwtPresentationOptions::from(JwtPresentationOptions::default()) - } } impl_wasm_json!(WasmJwtPresentationOptions, JwtPresentationOptions); diff --git a/bindings/wasm/tests/storage.ts b/bindings/wasm/tests/storage.ts index 6efa266d78..7a3f39a6b6 100644 --- a/bindings/wasm/tests/storage.ts +++ b/bindings/wasm/tests/storage.ts @@ -143,7 +143,7 @@ describe("#JwkStorageDocument", function() { .validate( credentialJwt, doc, - JwtCredentialValidationOptions.default(), + new JwtCredentialValidationOptions(), FailFast.FirstError, ) .credential(); @@ -155,7 +155,7 @@ describe("#JwkStorageDocument", function() { .validate( credentialJwt, doc, - JwtCredentialValidationOptions.default(), + new JwtCredentialValidationOptions(), FailFast.AllErrors, ) .credential(); @@ -253,7 +253,7 @@ describe("#JwkStorageDocument", function() { .validate( credentialJwt, doc, - JwtCredentialValidationOptions.default(), + new JwtCredentialValidationOptions(), FailFast.FirstError, ) .credential(); @@ -265,7 +265,7 @@ describe("#JwkStorageDocument", function() { .validate( credentialJwt, doc, - JwtCredentialValidationOptions.default(), + new JwtCredentialValidationOptions(), FailFast.AllErrors, ) .credential(); @@ -361,7 +361,7 @@ describe("#JwkStorageDocument", function() { let decoded: DecodedJwtPresentation = validator.validate( presentationJwt, holderDoc, - JwtPresentationValidationOptions.default(), + new JwtPresentationValidationOptions(), ); assert.equal( From 6d7b548dcfc55b18d2a497febae7e7a9eaf2cc03 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 17 Jul 2023 15:43:39 +0200 Subject: [PATCH 02/11] Remove commented modules --- bindings/wasm/src/account/mod.rs | 7 -- .../wasm/src/account/types/agreement_info.rs | 56 --------- .../wasm/src/account/types/cek_algorithm.rs | 40 ------- .../wasm/src/account/types/encrypted_data.rs | 50 -------- .../src/account/types/encryption_algorithm.rs | 38 ------ bindings/wasm/src/crypto/key_pair.rs | 110 ------------------ bindings/wasm/src/crypto/key_type.rs | 32 ----- bindings/wasm/src/crypto/mod.rs | 18 --- bindings/wasm/src/crypto/wasm_ed25519.rs | 63 ---------- bindings/wasm/src/crypto/wasm_proof.rs | 81 ------------- .../wasm/src/crypto/wasm_proof_options.rs | 74 ------------ .../wasm/src/crypto/wasm_proof_purpose.rs | 37 ------ bindings/wasm/src/crypto/wasm_x25519.rs | 59 ---------- bindings/wasm/src/lib.rs | 7 +- 14 files changed, 2 insertions(+), 670 deletions(-) delete mode 100644 bindings/wasm/src/account/mod.rs delete mode 100644 bindings/wasm/src/account/types/agreement_info.rs delete mode 100644 bindings/wasm/src/account/types/cek_algorithm.rs delete mode 100644 bindings/wasm/src/account/types/encrypted_data.rs delete mode 100644 bindings/wasm/src/account/types/encryption_algorithm.rs delete mode 100644 bindings/wasm/src/crypto/key_pair.rs delete mode 100644 bindings/wasm/src/crypto/key_type.rs delete mode 100644 bindings/wasm/src/crypto/mod.rs delete mode 100644 bindings/wasm/src/crypto/wasm_ed25519.rs delete mode 100644 bindings/wasm/src/crypto/wasm_proof.rs delete mode 100644 bindings/wasm/src/crypto/wasm_proof_options.rs delete mode 100644 bindings/wasm/src/crypto/wasm_proof_purpose.rs delete mode 100644 bindings/wasm/src/crypto/wasm_x25519.rs diff --git a/bindings/wasm/src/account/mod.rs b/bindings/wasm/src/account/mod.rs deleted file mode 100644 index 92f71e2689..0000000000 --- a/bindings/wasm/src/account/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -pub mod identity; -pub mod storage; -pub mod types; -pub mod wasm_account; diff --git a/bindings/wasm/src/account/types/agreement_info.rs b/bindings/wasm/src/account/types/agreement_info.rs deleted file mode 100644 index 7d6f6ad08a..0000000000 --- a/bindings/wasm/src/account/types/agreement_info.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::account_storage::AgreementInfo; -use wasm_bindgen::prelude::*; - -/// Agreement information used as the input for the concat KDF. -#[wasm_bindgen(js_name = AgreementInfo, inspectable)] -pub struct WasmAgreementInfo(pub(crate) AgreementInfo); - -#[wasm_bindgen(js_class = AgreementInfo)] -impl WasmAgreementInfo { - /// Creates an `AgreementInfo` Object. - #[wasm_bindgen(constructor)] - pub fn new(apu: Vec, apv: Vec, pub_info: Vec, priv_info: Vec) -> WasmAgreementInfo { - WasmAgreementInfo(AgreementInfo::new(apu, apv, pub_info, priv_info)) - } - - /// Returns a copy of `apu' - #[wasm_bindgen(js_name = apu)] - pub fn apu(&self) -> Vec { - self.0.apu.clone() - } - - /// Returns a copy of `apv' - #[wasm_bindgen(js_name = apv)] - pub fn apv(&self) -> Vec { - self.0.apv.clone() - } - - /// Returns a copy of `pubInfo' - #[wasm_bindgen(js_name = pubInfo)] - pub fn pub_info(&self) -> Vec { - self.0.pub_info.clone() - } - - /// Returns a copy of `privInfo' - #[wasm_bindgen(js_name = privInfo)] - pub fn priv_info(&self) -> Vec { - self.0.priv_info.clone() - } -} - -impl_wasm_json!(WasmAgreementInfo, AgreementInfo); - -impl From for AgreementInfo { - fn from(wasm_agreement_info: WasmAgreementInfo) -> Self { - wasm_agreement_info.0 - } -} - -impl From for WasmAgreementInfo { - fn from(agreement_info: AgreementInfo) -> Self { - WasmAgreementInfo(agreement_info) - } -} diff --git a/bindings/wasm/src/account/types/cek_algorithm.rs b/bindings/wasm/src/account/types/cek_algorithm.rs deleted file mode 100644 index b4e5f38049..0000000000 --- a/bindings/wasm/src/account/types/cek_algorithm.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::account_storage::CekAlgorithm; -use wasm_bindgen::prelude::*; - -use crate::account::types::WasmAgreementInfo; - -/// Supported algorithms used to determine and potentially encrypt the content encryption key (CEK). -#[wasm_bindgen(js_name = CekAlgorithm, inspectable)] -pub struct WasmCekAlgorithm(pub(crate) CekAlgorithm); - -#[wasm_bindgen(js_class = CekAlgorithm)] -impl WasmCekAlgorithm { - /// Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF. - #[wasm_bindgen(js_name = EcdhEs)] - pub fn ecdh_es(agreement: &WasmAgreementInfo) -> WasmCekAlgorithm { - Self(CekAlgorithm::ECDH_ES(agreement.0.clone())) - } - - /// Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF. - #[wasm_bindgen(js_name = EcdhEsA256Kw)] - pub fn ecdh_es_a256kw(agreement: &WasmAgreementInfo) -> WasmCekAlgorithm { - Self(CekAlgorithm::ECDH_ES_A256KW(agreement.0.clone())) - } -} - -impl_wasm_json!(WasmCekAlgorithm, CekAlgorithm); - -impl From for CekAlgorithm { - fn from(wasm_cek_algorithm: WasmCekAlgorithm) -> Self { - wasm_cek_algorithm.0 - } -} - -impl From for WasmCekAlgorithm { - fn from(cek_algorithm: CekAlgorithm) -> Self { - WasmCekAlgorithm(cek_algorithm) - } -} diff --git a/bindings/wasm/src/account/types/encrypted_data.rs b/bindings/wasm/src/account/types/encrypted_data.rs deleted file mode 100644 index 17b81588ba..0000000000 --- a/bindings/wasm/src/account/types/encrypted_data.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::account_storage::EncryptedData; -use wasm_bindgen::prelude::*; - -/// The structure returned after encrypting data -#[wasm_bindgen(js_name = EncryptedData, inspectable)] -pub struct WasmEncryptedData(pub(crate) EncryptedData); - -#[wasm_bindgen(js_class = EncryptedData)] -impl WasmEncryptedData { - /// Returns a copy of the nonce - #[wasm_bindgen(js_name = nonce)] - pub fn nonce(&self) -> Vec { - self.0.nonce.clone() - } - - /// Returns a copy of the associated data - #[wasm_bindgen(js_name = associatedData)] - pub fn associated_data(&self) -> Vec { - self.0.associated_data.clone() - } - - /// Returns a copy of the ciphertext - #[wasm_bindgen(js_name = ciphertext)] - pub fn ciphertext(&self) -> Vec { - self.0.ciphertext.clone() - } - - /// Returns a copy of the tag - #[wasm_bindgen(js_name = tag)] - pub fn tag(&self) -> Vec { - self.0.tag.clone() - } -} - -impl_wasm_json!(WasmEncryptedData, EncryptedData); - -impl From for EncryptedData { - fn from(wasm_encrypted_data: WasmEncryptedData) -> Self { - wasm_encrypted_data.0 - } -} - -impl From for WasmEncryptedData { - fn from(encrypted_data: EncryptedData) -> Self { - WasmEncryptedData(encrypted_data) - } -} diff --git a/bindings/wasm/src/account/types/encryption_algorithm.rs b/bindings/wasm/src/account/types/encryption_algorithm.rs deleted file mode 100644 index 6cc2695bd3..0000000000 --- a/bindings/wasm/src/account/types/encryption_algorithm.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::account_storage::EncryptionAlgorithm; -use wasm_bindgen::prelude::*; - -/// Supported content encryption algorithms. -#[wasm_bindgen(js_name = EncryptionAlgorithm, inspectable)] -pub struct WasmEncryptionAlgorithm(pub(crate) EncryptionAlgorithm); - -#[wasm_bindgen(js_class = EncryptionAlgorithm)] -impl WasmEncryptionAlgorithm { - /// AES GCM using 256-bit key. - #[wasm_bindgen(js_name = A256GCM)] - pub fn aes256gcm() -> WasmEncryptionAlgorithm { - Self(EncryptionAlgorithm::AES256GCM) - } - - /// Returns the length of the cipher's key. - #[wasm_bindgen(js_name = keyLength)] - pub fn key_length(&self) -> usize { - self.0.key_length() - } -} - -impl_wasm_json!(WasmEncryptionAlgorithm, EncryptionAlgorithm); - -impl From for EncryptionAlgorithm { - fn from(wasm_encryption_algorithm: WasmEncryptionAlgorithm) -> Self { - wasm_encryption_algorithm.0 - } -} - -impl From for WasmEncryptionAlgorithm { - fn from(encryption_algorithm: EncryptionAlgorithm) -> Self { - WasmEncryptionAlgorithm(encryption_algorithm) - } -} diff --git a/bindings/wasm/src/crypto/key_pair.rs b/bindings/wasm/src/crypto/key_pair.rs deleted file mode 100644 index 4c20bf3259..0000000000 --- a/bindings/wasm/src/crypto/key_pair.rs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::KeyPair; -use identity_iota::crypto::KeyType; -use wasm_bindgen::prelude::*; - -use crate::crypto::WasmKeyType; -use crate::error::Result; -use crate::error::WasmResult; - -#[derive(Deserialize, Serialize)] -struct JsonData { - #[serde(rename = "type")] - type_: WasmKeyType, - public: Vec, - private: Vec, -} - -// ============================================================================= -// ============================================================================= - -#[wasm_bindgen(inspectable, js_name = KeyPair)] -pub struct WasmKeyPair(pub(crate) KeyPair); - -#[wasm_bindgen(js_class = KeyPair)] -impl WasmKeyPair { - /// Generates a new `KeyPair` object. - #[wasm_bindgen(constructor)] - pub fn new(type_: WasmKeyType) -> Result { - KeyPair::new(type_.into()).map(Self).wasm_result() - } - - /// Parses a `KeyPair` object from the public/private keys. - #[wasm_bindgen(js_name = fromKeys)] - pub fn from_keys(type_: WasmKeyType, public_key: Vec, private_key: Vec) -> Result { - Ok(Self((type_.into(), public_key.into(), private_key.into()).into())) - } - - /// Reconstructs a `KeyPair` from the bytes of a private key. - /// - /// The private key for `Ed25519` must be a 32-byte seed in compliance - /// with [RFC 8032](https://datatracker.ietf.org/doc/html/rfc8032#section-3.2). - /// Other implementations often use another format. See [this blog post](https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/) for further explanation. - #[allow(non_snake_case)] - #[wasm_bindgen(js_name = tryFromPrivateKeyBytes)] - pub fn try_from_private_key_bytes(keyType: WasmKeyType, privateKeyBytes: &[u8]) -> Result { - KeyPair::try_from_private_key_bytes(KeyType::from(keyType), privateKeyBytes) - .map(Self) - .wasm_result() - } - - /// Returns the `KeyType` of the `KeyPair` object. - #[wasm_bindgen(js_name = type)] - pub fn type_(&self) -> WasmKeyType { - WasmKeyType::from(self.0.type_()) - } - - /// Returns a copy of the public key as a `Uint8Array`. - #[wasm_bindgen] - pub fn public(&self) -> Vec { - self.0.public().as_ref().to_vec() - } - - /// Returns a copy of the private key as a `Uint8Array`. - #[wasm_bindgen] - pub fn private(&self) -> Vec { - self.0.private().as_ref().to_vec() - } - - /// Serializes a `KeyPair` object as a JSON object. - #[wasm_bindgen(js_name = toJSON)] - pub fn to_json(&self) -> Result { - let data: JsonData = JsonData { - type_: self.0.type_().into(), - public: self.public(), - private: self.private(), - }; - - JsValue::from_serde(&data).wasm_result() - } - - /// Deserializes a `KeyPair` object from a JSON object. - #[wasm_bindgen(js_name = fromJSON)] - pub fn from_json(json: &JsValue) -> Result { - let data: JsonData = json.into_serde().wasm_result()?; - Ok(data.into()) - } -} - -impl From for WasmKeyPair { - fn from(json_data: JsonData) -> Self { - Self( - ( - json_data.type_.into(), - json_data.public.into(), - json_data.private.into(), - ) - .into(), - ) - } -} - -impl From for WasmKeyPair { - fn from(key_pair: KeyPair) -> Self { - WasmKeyPair(key_pair) - } -} - -impl_wasm_clone!(WasmKeyPair, KeyPair); diff --git a/bindings/wasm/src/crypto/key_type.rs b/bindings/wasm/src/crypto/key_type.rs deleted file mode 100644 index 66faca7d7d..0000000000 --- a/bindings/wasm/src/crypto/key_type.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::KeyType; -use wasm_bindgen::prelude::*; - -#[wasm_bindgen(js_name = KeyType)] -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum WasmKeyType { - #[serde(rename = "ed25519")] - Ed25519 = 1, - #[serde(rename = "x25519")] - X25519 = 2, -} - -impl From for KeyType { - fn from(other: WasmKeyType) -> Self { - match other { - WasmKeyType::Ed25519 => KeyType::Ed25519, - WasmKeyType::X25519 => KeyType::X25519, - } - } -} - -impl From for WasmKeyType { - fn from(other: KeyType) -> Self { - match other { - KeyType::Ed25519 => WasmKeyType::Ed25519, - KeyType::X25519 => WasmKeyType::X25519, - } - } -} diff --git a/bindings/wasm/src/crypto/mod.rs b/bindings/wasm/src/crypto/mod.rs deleted file mode 100644 index 53d9e9198b..0000000000 --- a/bindings/wasm/src/crypto/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -pub use self::key_pair::WasmKeyPair; -pub use self::key_type::WasmKeyType; -pub use self::wasm_ed25519::WasmEd25519; -pub use self::wasm_proof::WasmProof; -pub use self::wasm_proof_options::WasmProofOptions; -pub use self::wasm_proof_purpose::WasmProofPurpose; -pub use self::wasm_x25519::WasmX25519; - -mod key_pair; -mod key_type; -mod wasm_ed25519; -mod wasm_proof; -mod wasm_proof_options; -mod wasm_proof_purpose; -mod wasm_x25519; diff --git a/bindings/wasm/src/crypto/wasm_ed25519.rs b/bindings/wasm/src/crypto/wasm_ed25519.rs deleted file mode 100644 index 0021add624..0000000000 --- a/bindings/wasm/src/crypto/wasm_ed25519.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::Ed25519; -use identity_iota::crypto::PrivateKey; -use identity_iota::crypto::PublicKey; -use identity_iota::crypto::Sign; -use identity_iota::crypto::Verify; -use wasm_bindgen::prelude::*; - -use crate::error::Result; -use crate::error::WasmResult; - -#[wasm_bindgen(js_name = Ed25519, inspectable)] -pub struct WasmEd25519(pub(crate) Ed25519); - -#[wasm_bindgen(js_class = Ed25519)] -impl WasmEd25519 { - /// Length in bytes of an Ed25519 private key. - #[wasm_bindgen(js_name = PRIVATE_KEY_LENGTH)] - pub fn private_key_length() -> usize { - Ed25519::PRIVATE_KEY_LENGTH - } - - /// Length in bytes of an Ed25519 public key. - #[wasm_bindgen(js_name = PUBLIC_KEY_LENGTH)] - pub fn public_key_length() -> usize { - Ed25519::PUBLIC_KEY_LENGTH - } - - /// Length in bytes of an Ed25519 signature. - #[wasm_bindgen(js_name = SIGNATURE_LENGTH)] - pub fn signature_length() -> usize { - Ed25519::SIGNATURE_LENGTH - } - - /// Computes an EdDSA signature using an Ed25519 private key. - /// - /// NOTE: this differs from [Document.signData](#Document+signData) which uses JCS - /// to canonicalize JSON messages. - /// - /// The private key must be a 32-byte seed in compliance with [RFC 8032](https://datatracker.ietf.org/doc/html/rfc8032#section-3.2). - /// Other implementations often use another format. See [this blog post](https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/) for further explanation. - #[allow(non_snake_case)] - #[wasm_bindgen] - pub fn sign(message: &[u8], privateKey: Vec) -> Result> { - let key: PrivateKey = privateKey.into(); - Ed25519::sign(message, &key) - .map(|signature| signature.to_vec()) - .wasm_result() - } - - /// Verifies an EdDSA signature against an Ed25519 public key. - /// - /// NOTE: this differs from [Document.verifyData](#Document+verifyData) which uses JCS - /// to canonicalize JSON messages. - #[allow(non_snake_case)] - #[wasm_bindgen] - pub fn verify(message: &[u8], signature: &[u8], publicKey: Vec) -> Result<()> { - let key: PublicKey = publicKey.into(); - Ed25519::verify(message, signature, &key).wasm_result() - } -} diff --git a/bindings/wasm/src/crypto/wasm_proof.rs b/bindings/wasm/src/crypto/wasm_proof.rs deleted file mode 100644 index 3ad177317a..0000000000 --- a/bindings/wasm/src/crypto/wasm_proof.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::Proof; -use wasm_bindgen::prelude::*; -use wasm_bindgen::JsValue; - -use crate::common::WasmTimestamp; -use crate::crypto::WasmProofPurpose; - -/// A digital signature. -/// -/// For field definitions see: https://w3c-ccg.github.io/security-vocab/ -#[wasm_bindgen(js_name = Proof, inspectable)] -pub struct WasmProof(pub(crate) Proof); - -#[wasm_bindgen(js_class = Proof)] -impl WasmProof { - /// Returns a copy of the proof type. - #[wasm_bindgen(js_name = type)] - pub fn type_(&self) -> String { - self.0.type_().to_owned() - } - - /// Returns a copy of the proof value string. - #[wasm_bindgen] - pub fn value(&self) -> String { - self.0.value().as_str().to_owned() - } - - /// Returns a copy of the identifier of the DID method used to create this proof. - #[wasm_bindgen(js_name = verificationMethod)] - pub fn verification_method(&self) -> String { - self.0.verification_method().to_owned() - } - - /// When the proof was generated. - #[wasm_bindgen] - pub fn created(&self) -> Option { - self.0.created.map(WasmTimestamp::from) - } - - /// When the proof expires. - #[wasm_bindgen] - pub fn expires(&self) -> Option { - self.0.expires.map(WasmTimestamp::from) - } - - /// Challenge from a proof requester to mitigate replay attacks. - #[wasm_bindgen] - pub fn challenge(&self) -> Option { - self.0.challenge.clone() - } - - /// Domain for which a proof is valid to mitigate replay attacks. - #[wasm_bindgen] - pub fn domain(&self) -> Option { - self.0.domain.clone() - } - - /// Purpose for which the proof was generated. - #[wasm_bindgen] - pub fn purpose(&self) -> Option { - self.0.purpose.map(WasmProofPurpose::from) - } -} - -impl_wasm_json!(WasmProof, Proof); -impl_wasm_clone!(WasmProof, Proof); - -impl From for WasmProof { - fn from(proof: Proof) -> Self { - WasmProof(proof) - } -} - -impl From for Proof { - fn from(proof: WasmProof) -> Self { - proof.0 - } -} diff --git a/bindings/wasm/src/crypto/wasm_proof_options.rs b/bindings/wasm/src/crypto/wasm_proof_options.rs deleted file mode 100644 index 3262ca77e4..0000000000 --- a/bindings/wasm/src/crypto/wasm_proof_options.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2020-2023 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::ProofOptions; -use wasm_bindgen::prelude::*; - -use crate::error::Result; -use crate::error::WasmResult; - -/// Holds additional options for creating signatures. -/// See `IProofOptions`. -#[wasm_bindgen(js_name = ProofOptions)] -pub struct WasmProofOptions(pub(crate) ProofOptions); - -#[wasm_bindgen(js_class = ProofOptions)] -impl WasmProofOptions { - /// Creates a new `ProofOptions` from the given fields. - /// - /// Throws an error if any of the options are invalid. - #[wasm_bindgen(constructor)] - pub fn new(options: IProofOptions) -> Result { - let proof_options: ProofOptions = options.into_serde().wasm_result()?; - Ok(WasmProofOptions::from(proof_options)) - } - - /// Creates a new `ProofOptions` with default options. - #[allow(clippy::should_implement_trait)] - #[wasm_bindgen] - pub fn default() -> WasmProofOptions { - WasmProofOptions::from(ProofOptions::default()) - } -} - -impl_wasm_json!(WasmProofOptions, ProofOptions); -impl_wasm_clone!(WasmProofOptions, ProofOptions); - -impl From for WasmProofOptions { - fn from(options: ProofOptions) -> Self { - WasmProofOptions(options) - } -} - -impl From for ProofOptions { - fn from(options: WasmProofOptions) -> Self { - options.0 - } -} - -/// Interface to allow creating `ProofOptions` easily. -#[wasm_bindgen] -extern "C" { - #[wasm_bindgen(typescript_type = "IProofOptions")] - pub type IProofOptions; -} - -#[wasm_bindgen(typescript_custom_section)] -const I_PROOF_OPTIONS: &'static str = r#" -/** Holds options to create a new `ProofOptions`. */ -interface IProofOptions { - /** When the proof was generated. */ - readonly created?: Timestamp; - - /** When the proof expires. */ - readonly expires?: Timestamp; - - /** Challenge from a proof requester to mitigate replay attacks. */ - readonly challenge?: string; - - /** Domain for which a proof is valid to mitigate replay attacks. */ - readonly domain?: string; - - /** Purpose for which the proof was generated. */ - readonly purpose?: ProofPurpose; -}"#; diff --git a/bindings/wasm/src/crypto/wasm_proof_purpose.rs b/bindings/wasm/src/crypto/wasm_proof_purpose.rs deleted file mode 100644 index cd6807d64e..0000000000 --- a/bindings/wasm/src/crypto/wasm_proof_purpose.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::ProofPurpose; -use wasm_bindgen::prelude::*; - -/// Associates a purpose with a {@link Proof}. -/// -/// See https://w3c-ccg.github.io/security-vocab/#proofPurpose -#[wasm_bindgen(js_name = ProofPurpose, inspectable)] -pub struct WasmProofPurpose(pub(crate) ProofPurpose); - -#[wasm_bindgen(js_class = ProofPurpose)] -impl WasmProofPurpose { - /// Purpose is to assert a claim. - /// See https://www.w3.org/TR/did-core/#assertion - #[wasm_bindgen(js_name = assertionMethod)] - pub fn assertion_method() -> WasmProofPurpose { - WasmProofPurpose(ProofPurpose::AssertionMethod) - } - - /// Purpose is to authenticate the signer. - /// See https://www.w3.org/TR/did-core/#authentication - #[wasm_bindgen(js_name = authentication)] - pub fn authentication() -> WasmProofPurpose { - WasmProofPurpose(ProofPurpose::Authentication) - } -} - -impl_wasm_json!(WasmProofPurpose, ProofPurpose); -impl_wasm_clone!(WasmProofPurpose, ProofPurpose); - -impl From for WasmProofPurpose { - fn from(purpose: ProofPurpose) -> Self { - WasmProofPurpose(purpose) - } -} diff --git a/bindings/wasm/src/crypto/wasm_x25519.rs b/bindings/wasm/src/crypto/wasm_x25519.rs deleted file mode 100644 index b2cdeb4e1f..0000000000 --- a/bindings/wasm/src/crypto/wasm_x25519.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::crypto::X25519; -use wasm_bindgen::prelude::*; - -use crate::error::Result; -use crate::error::WasmResult; - -/// An implementation of `X25519` Elliptic-curve Diffie-Hellman (ECDH) cryptographic key exchange. -#[wasm_bindgen(js_name = X25519)] -pub struct WasmX25519; - -#[wasm_bindgen(js_class = X25519)] -impl WasmX25519 { - /// Length in bytes of an X25519 private key. - #[wasm_bindgen(js_name = PRIVATE_KEY_LENGTH)] - pub fn private_key_length() -> usize { - X25519::PRIVATE_KEY_LENGTH - } - - /// Length in bytes of an X25519 public key. - #[wasm_bindgen(js_name = PUBLIC_KEY_LENGTH)] - pub fn public_key_length() -> usize { - X25519::PUBLIC_KEY_LENGTH - } - - /// Performs Diffie-Hellman key exchange using the private key of the first party with the - /// public key of the second party, resulting in a shared secret. - #[allow(non_snake_case)] - #[wasm_bindgen(js_name = keyExchange)] - pub fn key_exchange(privateKey: Vec, publicKey: Vec) -> Result> { - X25519::key_exchange(&privateKey, &publicKey) - .map(|bytes| bytes.to_vec()) - .wasm_result() - } - - /// Transforms an `Ed25519` private key to an `X25519` private key. - /// - /// This is possible because Ed25519 is birationally equivalent to Curve25519 used by X25519. - #[allow(non_snake_case)] - #[wasm_bindgen(js_name = Ed25519toX25519Private)] - pub fn ed25519_to_x25519_private(privateKey: &[u8]) -> Result> { - X25519::ed25519_to_x25519_private(privateKey) - .map(|key| key.as_ref().to_vec()) - .wasm_result() - } - - /// Transforms an `Ed25519` public key to an `X25519` public key. - /// - /// This is possible because Ed25519 is birationally equivalent to Curve25519 used by X25519. - #[allow(non_snake_case)] - #[wasm_bindgen(js_name = Ed25519toX25519Public)] - pub fn ed25519_to_x25519_public(publicKey: &[u8]) -> Result> { - X25519::ed25519_to_x25519_public(publicKey) - .map(|key| key.as_ref().to_vec()) - .wasm_result() - } -} diff --git a/bindings/wasm/src/lib.rs b/bindings/wasm/src/lib.rs index 94f420a37b..6cb051ed8a 100644 --- a/bindings/wasm/src/lib.rs +++ b/bindings/wasm/src/lib.rs @@ -7,7 +7,8 @@ // wasm_bindgen calls drop on non-Drop types. When/If this is fixed, this can be removed (no issue to link here yet). #![allow(clippy::drop_non_drop)] #![allow(clippy::unused_unit)] -#![allow(clippy::await_holding_refcell_ref)] // complains about RefCell in future_to_promise, should only panic in multithreaded code/web workers +// complains about RefCell in future_to_promise, should only panic in multithreaded code/web workers +#![allow(clippy::await_holding_refcell_ref)] #[macro_use] extern crate serde; @@ -17,12 +18,8 @@ use wasm_bindgen::prelude::*; #[macro_use] mod macros; -// Deactivated legacy packages. -// pub mod account; - pub mod common; pub mod credential; -// pub mod crypto; pub mod did; pub mod error; pub mod iota; From c4508669044f7ea5a08a932e49188da0bf3ea0f3 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 17 Jul 2023 15:50:27 +0200 Subject: [PATCH 03/11] Remove outdated TODOs --- bindings/wasm/src/did/wasm_core_document.rs | 1 - bindings/wasm/src/iota/iota_document.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/bindings/wasm/src/did/wasm_core_document.rs b/bindings/wasm/src/did/wasm_core_document.rs index 43cefa603d..3a40b38953 100644 --- a/bindings/wasm/src/did/wasm_core_document.rs +++ b/bindings/wasm/src/did/wasm_core_document.rs @@ -641,7 +641,6 @@ impl WasmCoreDocument { /// /// Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. /// See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - // TODO: Perhaps this should be called `signData` (and the old `signData` method would have to be updated or removed)? #[wasm_bindgen(js_name = createJws)] pub fn create_jws( &self, diff --git a/bindings/wasm/src/iota/iota_document.rs b/bindings/wasm/src/iota/iota_document.rs index 160dbbbd7f..97a5bdeda6 100644 --- a/bindings/wasm/src/iota/iota_document.rs +++ b/bindings/wasm/src/iota/iota_document.rs @@ -707,9 +707,6 @@ impl WasmIotaDocument { /// /// Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. /// See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - // TODO: Should payload be of type `string`, or should we take Uint8Array to match Rust? I chose String here as they - // are much easier to obtain in JS. Perhaps we need both and possibly also a third convenience method for using JSON - // as the payload type? #[wasm_bindgen(js_name = createJwt)] pub fn create_jws( &self, From 1f3fcd940111258ee7f426ccaf95ff9fca4c5af4 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 17 Jul 2023 15:50:45 +0200 Subject: [PATCH 04/11] Remove wontfix TODO --- bindings/wasm/examples/src/util.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/wasm/examples/src/util.ts b/bindings/wasm/examples/src/util.ts index cac9f909e4..a1fb083bf6 100644 --- a/bindings/wasm/examples/src/util.ts +++ b/bindings/wasm/examples/src/util.ts @@ -81,7 +81,6 @@ export async function ensureAddressHasFunds(client: Client, addressBech32: strin /** Returns the balance of the given Bech32-encoded address. */ async function getAddressBalance(client: Client, addressBech32: string): Promise { - // TODO: use the `addresses/ed25519/` API to get the balance? const outputIds = await client.basicOutputIds([ { address: addressBech32 }, { hasExpiration: false }, From a9926419fa33d4d04fef614156b5cd5fb1341fc5 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 17 Jul 2023 15:51:03 +0200 Subject: [PATCH 05/11] Format --- .../wasm/src/credential/jwt_credential_validation/options.rs | 4 +++- .../src/credential/jwt_presentation_validation/options.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bindings/wasm/src/credential/jwt_credential_validation/options.rs b/bindings/wasm/src/credential/jwt_credential_validation/options.rs index b89b673132..c1b7311346 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/options.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/options.rs @@ -19,7 +19,9 @@ impl WasmJwtCredentialValidationOptions { let options: JwtCredentialValidationOptions = opts.into_serde().wasm_result()?; Ok(WasmJwtCredentialValidationOptions::from(options)) } else { - Ok(WasmJwtCredentialValidationOptions::from(JwtCredentialValidationOptions::default())) + Ok(WasmJwtCredentialValidationOptions::from( + JwtCredentialValidationOptions::default(), + )) } } } diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/options.rs b/bindings/wasm/src/credential/jwt_presentation_validation/options.rs index 54ffd7a01f..ff7255d2e9 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/options.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/options.rs @@ -21,7 +21,9 @@ impl WasmJwtPresentationValidationOptions { let options: JwtPresentationValidationOptions = opts.into_serde().wasm_result()?; Ok(WasmJwtPresentationValidationOptions::from(options)) } else { - Ok(WasmJwtPresentationValidationOptions::from(JwtPresentationValidationOptions::default())) + Ok(WasmJwtPresentationValidationOptions::from( + JwtPresentationValidationOptions::default(), + )) } } } From ff94cd8857b4639b00dac8d940fd154897b43a4f Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 17 Jul 2023 17:26:19 +0200 Subject: [PATCH 06/11] Polish docs and signatures, remove old cred valid. --- .../src/credential/credential_validator.rs | 156 ------------------ .../domain_linkage_configuration.rs | 5 +- .../credential/domain_linkage_validator.rs | 5 +- bindings/wasm/src/credential/jwt.rs | 1 + .../jwt_credential_validator.rs | 2 - .../unknown_credential.rs | 2 +- .../jwt_presentation/presentation_builder.rs | 2 +- .../jwt_presentation_validator.rs | 14 +- .../src/credential/linked_domain_service.rs | 12 +- .../wasm/src/did/jws_verification_options.rs | 1 + bindings/wasm/src/did/wasm_core_did.rs | 2 +- bindings/wasm/src/did/wasm_core_document.rs | 4 +- bindings/wasm/src/iota/iota_did.rs | 2 +- bindings/wasm/src/storage/key_id_storage.rs | 6 +- bindings/wasm/src/storage/method_digest.rs | 4 +- 15 files changed, 36 insertions(+), 182 deletions(-) delete mode 100644 bindings/wasm/src/credential/credential_validator.rs diff --git a/bindings/wasm/src/credential/credential_validator.rs b/bindings/wasm/src/credential/credential_validator.rs deleted file mode 100644 index 9760d0210b..0000000000 --- a/bindings/wasm/src/credential/credential_validator.rs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2020-2023 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use identity_iota::core::Object; -use identity_iota::core::Url; -use identity_iota::credential::CredentialValidator; -use identity_iota::credential::StatusCheck; -use identity_iota::credential::ValidationError; -use identity_iota::did::CoreDID; -use wasm_bindgen::prelude::*; - -use crate::common::ImportedDocumentLock; -use crate::common::ImportedDocumentReadGuard; -use crate::common::WasmTimestamp; -use crate::credential::validation_options::WasmFailFast; -use crate::credential::validation_options::WasmStatusCheck; -use crate::did::ArrayIToCoreDocument; -use crate::did::IToCoreDocument; -use crate::did::WasmCoreDID; -use crate::did::WasmVerifierOptions; -use crate::error::Result; -use crate::error::WasmResult; - -use super::WasmCredential; -use super::WasmCredentialValidationOptions; -use super::WasmSubjectHolderRelationship; - -#[wasm_bindgen(js_name = CredentialValidator, inspectable)] -pub struct WasmCredentialValidator; - -#[wasm_bindgen(js_class = CredentialValidator)] -impl WasmCredentialValidator { - /// Validates a `Credential`. - /// - /// The following properties are validated according to `options`: - /// - the issuer's signature, - /// - the expiration date, - /// - the issuance date, - /// - the semantic structure. - /// - /// ### Warning - /// The lack of an error returned from this method is in of itself not enough to conclude that the credential can be - /// trusted. This section contains more information on additional checks that should be carried out before and after - /// calling this method. - /// - /// #### The state of the issuer's DID Document - /// The caller must ensure that `issuer` represents an up-to-date DID Document. The convenience method - /// `Resolver::resolveCredentialIssuer` can help extract the latest available state of the issuer's DID Document. - /// - /// #### Properties that are not validated - /// There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: - /// `credentialStatus`, `type`, `credentialSchema`, `refreshService`, **and more**. - /// These should be manually checked after validation, according to your requirements. - /// - /// ### Errors - /// An error is returned whenever a validated condition is not satisfied. - #[wasm_bindgen] - pub fn validate( - credential: &WasmCredential, - issuer: &IToCoreDocument, - options: &WasmCredentialValidationOptions, - fail_fast: WasmFailFast, - ) -> Result<()> { - let issuer_lock = ImportedDocumentLock::from(issuer); - let issuer_guard = issuer_lock.blocking_read(); - //let issuer: RustSupportedDocument = issuer.into_serde::().wasm_result()?; - CredentialValidator::validate(&credential.0, &issuer_guard, &options.0, fail_fast.into()).wasm_result() - } - - /// Validates the semantic structure of the `Credential`. - /// - /// ### Warning - /// This does not validate against the credential's schema nor the structure of the subject claims. - #[wasm_bindgen(js_name = checkStructure)] - pub fn check_structure(credential: &WasmCredential) -> Result<()> { - credential - .0 - .check_structure() - .map_err(ValidationError::CredentialStructure) - .wasm_result() - } - - /// Validate that the credential expires on or after the specified timestamp. - #[wasm_bindgen(js_name = checkExpiresOnOrAfter)] - pub fn check_expires_on_or_after(credential: &WasmCredential, timestamp: &WasmTimestamp) -> Result<()> { - CredentialValidator::check_expires_on_or_after(&credential.0, timestamp.0).wasm_result() - } - - /// Validate that the credential is issued on or before the specified timestamp. - #[wasm_bindgen(js_name = checkIssuedOnOrBefore)] - pub fn check_issued_on_or_before(credential: &WasmCredential, timestamp: &WasmTimestamp) -> Result<()> { - CredentialValidator::check_issued_on_or_before(&credential.0, timestamp.0).wasm_result() - } - - /// Verify the signature using the DID Document of a trusted issuer. - /// - /// # Warning - /// The caller must ensure that the DID Documents of the trusted issuers are up-to-date. - /// ### Errors - /// This method immediately returns an error if - /// the credential issuer' url cannot be parsed to a DID belonging to one of the trusted issuers. Otherwise an attempt - /// to verify the credential's signature will be made and an error is returned upon failure. - #[wasm_bindgen(js_name = verifySignature)] - #[allow(non_snake_case)] - pub fn verify_signature( - credential: &WasmCredential, - trustedIssuers: &ArrayIToCoreDocument, - options: &WasmVerifierOptions, - ) -> Result<()> { - let issuer_locks: Vec = trustedIssuers.into(); - let trusted_issuers: Vec> = - issuer_locks.iter().map(ImportedDocumentLock::blocking_read).collect(); - CredentialValidator::verify_signature(&credential.0, &trusted_issuers, &options.0).wasm_result() - } - - /// Validate that the relationship between the `holder` and the credential subjects is in accordance with - /// `relationship`. The `holder` parameter is expected to be the URL of the holder. - #[wasm_bindgen(js_name = checkSubjectHolderRelationship)] - pub fn check_subject_holder_relationship( - credential: &WasmCredential, - holder: &str, - relationship: WasmSubjectHolderRelationship, - ) -> Result<()> { - let holder: Url = Url::parse(holder).wasm_result()?; - CredentialValidator::check_subject_holder_relationship(&credential.0, &holder, relationship.into()).wasm_result() - } - - /// Checks whether the credential status has been revoked. - /// - /// Only supports `BitmapRevocation2022`. - #[wasm_bindgen(js_name = checkStatus)] - #[allow(non_snake_case)] - pub fn check_status( - credential: &WasmCredential, - trustedIssuers: &ArrayIToCoreDocument, - statusCheck: WasmStatusCheck, - ) -> Result<()> { - let issuer_locks: Vec = trustedIssuers.into(); - let trusted_issuers: Vec> = - issuer_locks.iter().map(ImportedDocumentLock::blocking_read).collect(); - let status_check: StatusCheck = StatusCheck::from(statusCheck); - CredentialValidator::check_status(&credential.0, &trusted_issuers, status_check).wasm_result() - } - - /// Utility for extracting the issuer field of a `Credential` as a DID. - /// - /// ### Errors - /// - /// Fails if the issuer field is not a valid DID. - #[wasm_bindgen(js_name = extractIssuer)] - pub fn extract_issuer(credential: &WasmCredential) -> Result { - CredentialValidator::extract_issuer::(&credential.0) - .map(WasmCoreDID::from) - .wasm_result() - } -} diff --git a/bindings/wasm/src/credential/domain_linkage_configuration.rs b/bindings/wasm/src/credential/domain_linkage_configuration.rs index 77cfb59e8a..f777eedc88 100644 --- a/bindings/wasm/src/credential/domain_linkage_configuration.rs +++ b/bindings/wasm/src/credential/domain_linkage_configuration.rs @@ -28,8 +28,9 @@ pub struct WasmDomainLinkageConfiguration(pub(crate) DomainLinkageConfiguration) impl WasmDomainLinkageConfiguration { /// Constructs a new `DomainLinkageConfiguration`. #[wasm_bindgen(constructor)] - pub fn new(linked_dids: &ArrayJwt) -> Result { - let wasm_credentials: Vec = linked_dids.into_serde().wasm_result()?; + #[allow(non_snake_case)] + pub fn new(linkedDids: &ArrayJwt) -> Result { + let wasm_credentials: Vec = linkedDids.into_serde().wasm_result()?; Ok(Self(DomainLinkageConfiguration::new(wasm_credentials))) } diff --git a/bindings/wasm/src/credential/domain_linkage_validator.rs b/bindings/wasm/src/credential/domain_linkage_validator.rs index c553f830de..00dc645d6c 100644 --- a/bindings/wasm/src/credential/domain_linkage_validator.rs +++ b/bindings/wasm/src/credential/domain_linkage_validator.rs @@ -36,15 +36,17 @@ impl WasmDomainLinkageValidator { } /// Validates the linkage between a domain and a DID. - /// [`DomainLinkageConfiguration`] is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). + /// `DomainLinkageConfiguration` is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). /// /// Linkage is valid if no error is thrown. /// /// # Note: /// - Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) + /// is supported. /// - Only the Credential issued by `issuer` is verified. /// /// # Errors + /// /// - Semantic structure of `configuration` is invalid. /// - `configuration` includes multiple credentials issued by `issuer`. /// - Validation of the matched Domain Linkage Credential fails. @@ -66,6 +68,7 @@ impl WasmDomainLinkageValidator { } /// Validates a [Domain Linkage Credential](https://identity.foundation/.well-known/resources/did-configuration/#domain-linkage-credential). + /// /// Error will be thrown in case the validation fails. #[wasm_bindgen(js_name = validateCredential)] #[allow(non_snake_case)] diff --git a/bindings/wasm/src/credential/jwt.rs b/bindings/wasm/src/credential/jwt.rs index 270963fe5e..25a599a011 100644 --- a/bindings/wasm/src/credential/jwt.rs +++ b/bindings/wasm/src/credential/jwt.rs @@ -13,6 +13,7 @@ impl WasmJwt { pub(crate) fn new(jwt: Jwt) -> Self { WasmJwt(jwt) } + /// Creates a new `Jwt` from the given string. #[wasm_bindgen(constructor)] pub fn constructor(jwt_string: String) -> Self { diff --git a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs index af0e9d5d54..c8ef08c08a 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs @@ -29,8 +29,6 @@ use crate::verification::WasmJwsVerifier; use wasm_bindgen::prelude::*; /// A type for decoding and validating `Credentials`. -// NOTE: The methods that take `&Credential` have been copied over from the old `CredentialValidator`. The old -// `CredentialValidator` either needs to be updated or removed. #[wasm_bindgen(js_name = JwtCredentialValidator)] pub struct WasmJwtCredentialValidator(JwtCredentialValidator); diff --git a/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs b/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs index e6df6770ed..d42cbea359 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs @@ -45,7 +45,7 @@ impl WasmUnknownCredentialContainer { } } - /// Returns the contained value as JSON, if it can be converted, `undefined` otherwise. + /// Returns the contained value as an Object, if it can be converted, `undefined` otherwise. #[wasm_bindgen(js_name = tryIntoRaw)] pub fn try_into_raw(&self) -> Option { match &self.0 { diff --git a/bindings/wasm/src/credential/jwt_presentation/presentation_builder.rs b/bindings/wasm/src/credential/jwt_presentation/presentation_builder.rs index c5ea298710..ff1c550d7e 100644 --- a/bindings/wasm/src/credential/jwt_presentation/presentation_builder.rs +++ b/bindings/wasm/src/credential/jwt_presentation/presentation_builder.rs @@ -91,7 +91,7 @@ struct IPresentationHelper { )] verifiable_credential: OneOrMany, /// The entity that generated the presentation. - #[typescript(optional = false, type = "string | CoreDID | IotaDID ")] + #[typescript(optional = false, type = "string | CoreDID | IotaDID")] holder: String, /// Service(s) used to refresh an expired {@link Credential} in the presentation. #[typescript(name = "refreshService", type = "RefreshService | Array")] diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs index b1db11c3cb..182376076e 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs @@ -21,16 +21,17 @@ pub struct WasmJwtPresentationValidator(JwtPresentationValidator) -> WasmJwtPresentationValidator { - let signature_verifier = WasmJwsVerifier::new(signature_verifier); + #[allow(non_snake_case)] + pub fn new(signatureVerifier: Option) -> WasmJwtPresentationValidator { + let signature_verifier = WasmJwsVerifier::new(signatureVerifier); WasmJwtPresentationValidator(JwtPresentationValidator::with_signature_verifier(signature_verifier)) } - /// Validates a [`JwtPresentation`]. + /// Validates a `JwtPresentation`. /// /// The following properties are validated according to `options`: /// - the JWT can be decoded into a semantically valid presentation. @@ -55,9 +56,10 @@ impl WasmJwtPresentationValidator { /// /// An error is returned whenever a validated condition is not satisfied or when decoding fails. #[wasm_bindgen] + #[allow(non_snake_case)] pub fn validate( &self, - presentation_jwt: &WasmJwt, + presentationJwt: &WasmJwt, holder: &IToCoreDocument, validation_options: &WasmJwtPresentationValidationOptions, ) -> Result { @@ -66,7 +68,7 @@ impl WasmJwtPresentationValidator { self .0 - .validate(&presentation_jwt.0, &holder_guard, &validation_options.0) + .validate(&presentationJwt.0, &holder_guard, &validation_options.0) .map(WasmDecodedJwtPresentation::from) .wasm_result() } diff --git a/bindings/wasm/src/credential/linked_domain_service.rs b/bindings/wasm/src/credential/linked_domain_service.rs index 74ca98dbfa..84f19cf5be 100644 --- a/bindings/wasm/src/credential/linked_domain_service.rs +++ b/bindings/wasm/src/credential/linked_domain_service.rs @@ -19,10 +19,12 @@ use wasm_bindgen::JsCast; #[wasm_bindgen(js_name = LinkedDomainService, inspectable)] pub struct WasmLinkedDomainService(LinkedDomainService); -/// A service wrapper for a [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). +/// A service wrapper for a +/// [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). #[wasm_bindgen(js_class = LinkedDomainService)] impl WasmLinkedDomainService { - /// Constructs a new `LinkedDomainService` that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint) + /// Constructs a new `LinkedDomainService` that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). + /// /// Domain URLs must include the `https` scheme in order to pass the domain linkage validation. #[wasm_bindgen(constructor)] pub fn new(options: ILinkedDomainService) -> Result { @@ -54,15 +56,17 @@ impl WasmLinkedDomainService { WasmService(service) } - /// Creates a new @link{LinkedDomainService} from a @link{Service}. + /// Creates a new {@link LinkedDomainService} from a {@link Service}. + /// /// # Error + /// /// Errors if `service` is not a valid Linked Domain Service. #[wasm_bindgen(js_name = fromService)] pub fn from_service(service: &WasmService) -> Result { Ok(Self(LinkedDomainService::try_from(service.0.clone()).wasm_result()?)) } - /// Returns `true` if a @link{Service} is a valid Linked Domain Service. + /// Returns `true` if a {@link Service} is a valid Linked Domain Service. #[wasm_bindgen(js_name = isValid)] pub fn is_valid(service: &WasmService) -> bool { LinkedDomainService::check_structure(&service.0).is_ok() diff --git a/bindings/wasm/src/did/jws_verification_options.rs b/bindings/wasm/src/did/jws_verification_options.rs index a69d0ae066..6d5d861389 100644 --- a/bindings/wasm/src/did/jws_verification_options.rs +++ b/bindings/wasm/src/did/jws_verification_options.rs @@ -12,6 +12,7 @@ pub struct WasmJwsVerificationOptions(pub(crate) JwsVerificationOptions); #[wasm_bindgen(js_class = JwsVerificationOptions)] impl WasmJwsVerificationOptions { + /// Creates a new `JwsVerificationOptions` from the given fields. #[wasm_bindgen(constructor)] pub fn new(options: Option) -> Result { if let Some(options) = options { diff --git a/bindings/wasm/src/did/wasm_core_did.rs b/bindings/wasm/src/did/wasm_core_did.rs index b636d0b592..528dbef322 100644 --- a/bindings/wasm/src/did/wasm_core_did.rs +++ b/bindings/wasm/src/did/wasm_core_did.rs @@ -118,8 +118,8 @@ impl WasmCoreDID { self.0.to_string() } - #[wasm_bindgen(js_name = toCoreDid, skip_typescript)] // Only intended to be called internally. + #[wasm_bindgen(js_name = toCoreDid, skip_typescript)] pub fn to_core_did(&self) -> WasmCoreDID { WasmCoreDID(self.0.clone()) } diff --git a/bindings/wasm/src/did/wasm_core_document.rs b/bindings/wasm/src/did/wasm_core_document.rs index e4f79ef8d4..c6bbb16eb6 100644 --- a/bindings/wasm/src/did/wasm_core_document.rs +++ b/bindings/wasm/src/did/wasm_core_document.rs @@ -112,8 +112,8 @@ impl WasmCoreDocument { /// ### Warning /// /// Changing the identifier can drastically alter the results of - /// [`Self::resolve_method`](CoreDocument::resolve_method()), - /// [`Self::resolve_service`](CoreDocument::resolve_service()) and the related [DID URL dereferencing](https://w3c-ccg.github.io/did-resolution/#dereferencing) algorithm. + /// `resolve_method`, `resolve_service` and the related + /// [DID URL dereferencing](https://w3c-ccg.github.io/did-resolution/#dereferencing) algorithm. #[wasm_bindgen(js_name = setId)] pub fn set_id(&mut self, id: &WasmCoreDID) { *self.0.blocking_write().id_mut_unchecked() = id.0.clone(); diff --git a/bindings/wasm/src/iota/iota_did.rs b/bindings/wasm/src/iota/iota_did.rs index 93a1b35431..cbcd30bc13 100644 --- a/bindings/wasm/src/iota/iota_did.rs +++ b/bindings/wasm/src/iota/iota_did.rs @@ -60,7 +60,7 @@ impl WasmIotaDID { Ok(Self::from(IotaDID::from_alias_id(aliasId.as_ref(), &network_name))) } - /// Creates a new placeholder [`IotaDID`] with the given network name. + /// Creates a new placeholder `IotaDID` with the given network name. /// /// E.g. `did:iota:smr:0x0000000000000000000000000000000000000000000000000000000000000000`. #[wasm_bindgen] diff --git a/bindings/wasm/src/storage/key_id_storage.rs b/bindings/wasm/src/storage/key_id_storage.rs index 4969fbe6e0..977e90d36d 100644 --- a/bindings/wasm/src/storage/key_id_storage.rs +++ b/bindings/wasm/src/storage/key_id_storage.rs @@ -61,7 +61,7 @@ impl KeyIdStorage for WasmKeyIdStorage { #[wasm_bindgen(typescript_custom_section)] const JWK_STORAGE: &'static str = r#" /** - * Key value Storage for key ids under [`MethodDigest`]. + * Key value Storage for key ids under `MethodDigest`. */ interface KeyIdStorage { /** @@ -73,12 +73,12 @@ interface KeyIdStorage { insertKeyId: (methodDigest: MethodDigest, keyId: string) => Promise; /** - * Obtain the key id associated with the given [`MethodDigest`]. + * Obtain the key id associated with the given `MethodDigest`. */ getKeyId: (methodDigest: MethodDigest) => Promise; /** - * Delete the [`KeyId`] associated with the given [`MethodDigest`] from the [`KeyIdStorage`]. + * Delete the `KeyId` associated with the given `MethodDigest` from the `KeyIdStorage`. * * If `key` is not found in storage, an Error must be returned. */ diff --git a/bindings/wasm/src/storage/method_digest.rs b/bindings/wasm/src/storage/method_digest.rs index 3f1cde1a04..6f0643d04f 100644 --- a/bindings/wasm/src/storage/method_digest.rs +++ b/bindings/wasm/src/storage/method_digest.rs @@ -9,7 +9,7 @@ use crate::error::Result; use crate::error::WasmResult; use crate::verification::WasmVerificationMethod; -/// Unique identifier of a [`VerificationMethod`]. +/// Unique identifier of a `VerificationMethod`. /// /// NOTE: /// This class does not have a JSON representation, @@ -31,7 +31,7 @@ impl WasmMethodDigest { bytes.into() } - /// Unpacks bytes into [`MethodDigest`]. + /// Unpacks bytes into `MethodDigest`. #[wasm_bindgen] pub fn unpack(bytes: &Uint8Array) -> Result { let bytes: Vec = bytes.to_vec(); From d8123c474a248f1e401ba7100e18e5c3774f9ec6 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 20 Jul 2023 08:58:24 +0200 Subject: [PATCH 07/11] Replace some doc links --- bindings/wasm/src/credential/credential.rs | 34 +++++++++---------- .../wasm/src/credential/credential_builder.rs | 28 +++++++-------- .../domain_linkage_credential_builder.rs | 8 ++--- .../credential/domain_linkage_validator.rs | 2 +- .../jwt_credential_validator.rs | 12 +++---- .../unknown_credential.rs | 2 +- .../jwt_presentation_validator.rs | 2 +- .../src/credential/linked_domain_service.rs | 2 +- bindings/wasm/src/credential/types.rs | 2 +- bindings/wasm/src/did/wasm_core_did.rs | 28 +++++++-------- bindings/wasm/src/did/wasm_core_document.rs | 6 ++-- bindings/wasm/src/did/wasm_did_url.rs | 2 +- bindings/wasm/src/iota/iota_did.rs | 14 ++++---- bindings/wasm/src/iota/iota_document.rs | 4 +-- 14 files changed, 73 insertions(+), 73 deletions(-) diff --git a/bindings/wasm/src/credential/credential.rs b/bindings/wasm/src/credential/credential.rs index 43e1a99c93..b8eea8cc9f 100644 --- a/bindings/wasm/src/credential/credential.rs +++ b/bindings/wasm/src/credential/credential.rs @@ -45,7 +45,7 @@ impl WasmCredential { Credential::::base_type().to_owned() } - /// Constructs a new `Credential`. + /// Constructs a new {@link Credential}. #[wasm_bindgen(constructor)] pub fn new(values: ICredential) -> Result { let builder: CredentialBuilder = CredentialBuilder::try_from(values)?; @@ -58,7 +58,7 @@ impl WasmCredential { builder.build().map(Self).wasm_result() } - /// Returns a copy of the JSON-LD context(s) applicable to the `Credential`. + /// Returns a copy of the JSON-LD context(s) applicable to the {@link Credential}. #[wasm_bindgen] pub fn context(&self) -> Result { self @@ -71,13 +71,13 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns a copy of the unique `URI` identifying the `Credential` . + /// Returns a copy of the unique `URI` identifying the {@link Credential} . #[wasm_bindgen] pub fn id(&self) -> Option { self.0.id.as_ref().map(|url| url.to_string()) } - /// Returns a copy of the URIs defining the type of the `Credential`. + /// Returns a copy of the URIs defining the type of the {@link Credential}. #[wasm_bindgen(js_name = "type")] pub fn types(&self) -> ArrayString { self @@ -90,7 +90,7 @@ impl WasmCredential { .unchecked_into::() } - /// Returns a copy of the `Credential` subject(s). + /// Returns a copy of the {@link Credential} subject(s). #[wasm_bindgen(js_name = credentialSubject)] pub fn credential_subject(&self) -> Result { self @@ -103,7 +103,7 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns a copy of the issuer of the `Credential`. + /// Returns a copy of the issuer of the {@link Credential}. #[wasm_bindgen] pub fn issuer(&self) -> Result { JsValue::from_serde(&self.0.issuer) @@ -111,19 +111,19 @@ impl WasmCredential { .wasm_result() } - /// Returns a copy of the timestamp of when the `Credential` becomes valid. + /// Returns a copy of the timestamp of when the {@link Credential} becomes valid. #[wasm_bindgen(js_name = "issuanceDate")] pub fn issuance_date(&self) -> WasmTimestamp { WasmTimestamp::from(self.0.issuance_date) } - /// Returns a copy of the timestamp of when the `Credential` should no longer be considered valid. + /// Returns a copy of the timestamp of when the {@link Credential} should no longer be considered valid. #[wasm_bindgen(js_name = "expirationDate")] pub fn expiration_date(&self) -> Option { self.0.expiration_date.map(WasmTimestamp::from) } - /// Returns a copy of the information used to determine the current status of the `Credential`. + /// Returns a copy of the information used to determine the current status of the {@link Credential}. #[wasm_bindgen(js_name = "credentialStatus")] pub fn credential_status(&self) -> Result { self @@ -136,7 +136,7 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns a copy of the information used to assist in the enforcement of a specific `Credential` structure. + /// Returns a copy of the information used to assist in the enforcement of a specific {@link Credential} structure. #[wasm_bindgen(js_name = "credentialSchema")] pub fn credential_schema(&self) -> Result { self @@ -149,7 +149,7 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns a copy of the service(s) used to refresh an expired `Credential`. + /// Returns a copy of the service(s) used to refresh an expired {@link Credential}. #[wasm_bindgen(js_name = "refreshService")] pub fn refresh_service(&self) -> Result { self @@ -162,7 +162,7 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns a copy of the terms-of-use specified by the `Credential` issuer. + /// Returns a copy of the terms-of-use specified by the {@link Credential} issuer. #[wasm_bindgen(js_name = "termsOfUse")] pub fn terms_of_use(&self) -> Result { self @@ -175,7 +175,7 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns a copy of the human-readable evidence used to support the claims within the `Credential`. + /// Returns a copy of the human-readable evidence used to support the claims within the {@link Credential}. #[wasm_bindgen] pub fn evidence(&self) -> Result { self @@ -188,21 +188,21 @@ impl WasmCredential { .map(|value| value.unchecked_into::()) } - /// Returns whether or not the `Credential` must only be contained within a `Presentation` - /// with a proof issued from the `Credential` subject. + /// Returns whether or not the {@link Credential} must only be contained within a {@link Presentation} + /// with a proof issued from the {@link Credential} subject. #[wasm_bindgen(js_name = "nonTransferable")] pub fn non_transferable(&self) -> Option { self.0.non_transferable } - /// Returns a copy of the proof used to verify the `Credential`. + /// Returns a copy of the proof used to verify the {@link Credential}. #[wasm_bindgen] pub fn proof(&self) -> Result { // TODO: Update with proof. JsValue::from_serde(&self.0.proof).wasm_result() } - /// Returns a copy of the miscellaneous properties on the `Credential`. + /// Returns a copy of the miscellaneous properties on the {@link Credential}. #[wasm_bindgen] pub fn properties(&self) -> Result { MapStringAny::try_from(&self.0.properties) diff --git a/bindings/wasm/src/credential/credential_builder.rs b/bindings/wasm/src/credential/credential_builder.rs index 1713fc1168..e04fd57574 100644 --- a/bindings/wasm/src/credential/credential_builder.rs +++ b/bindings/wasm/src/credential/credential_builder.rs @@ -112,44 +112,44 @@ extern "C" { #[serde(rename_all = "camelCase")] #[typescript(name = "ICredential", readonly, optional)] struct ICredentialHelper { - /// The JSON-LD context(s) applicable to the `Credential`. + /// The JSON-LD context(s) applicable to the {@link Credential}. #[typescript(type = "string | Record | Array>")] context: Option>, - /// A unique URI that may be used to identify the `Credential`. + /// A unique URI that may be used to identify the {@link Credential}. #[typescript(type = "string")] id: Option, - /// One or more URIs defining the type of the `Credential`. Contains the base context by default. + /// One or more URIs defining the type of the {@link Credential}. Contains the base context by default. #[typescript(name = "type", type = "string | Array")] r#type: Option>, - /// One or more objects representing the `Credential` subject(s). + /// One or more objects representing the {@link Credential} subject(s). #[typescript(optional = false, name = "credentialSubject", type = "Subject | Array")] credential_subject: Option>, - /// A reference to the issuer of the `Credential`. + /// A reference to the issuer of the {@link Credential}. #[typescript(optional = false, type = "string | CoreDID | IotaDID | Issuer")] issuer: Option, - /// A timestamp of when the `Credential` becomes valid. Defaults to the current datetime. + /// A timestamp of when the {@link Credential} becomes valid. Defaults to the current datetime. #[typescript(name = "issuanceDate", type = "Timestamp")] issuance_date: Option, - /// A timestamp of when the `Credential` should no longer be considered valid. + /// A timestamp of when the {@link Credential} should no longer be considered valid. #[typescript(name = "expirationDate", type = "Timestamp")] expiration_date: Option, - /// Information used to determine the current status of the `Credential`. + /// Information used to determine the current status of the {@link Credential}. #[typescript(name = "credentialStatus", type = "Status")] credential_status: Option, - /// Information used to assist in the enforcement of a specific `Credential` structure. + /// Information used to assist in the enforcement of a specific {@link Credential} structure. #[typescript(name = "credentialSchema", type = "Schema | Array")] credential_schema: Option>, - /// Service(s) used to refresh an expired `Credential`. + /// Service(s) used to refresh an expired {@link Credential}. #[typescript(name = "refreshService", type = "RefreshService | Array")] refresh_service: Option>, - /// Terms-of-use specified by the `Credential` issuer. + /// Terms-of-use specified by the {@link Credential} issuer. #[typescript(name = "termsOfUse", type = "Policy | Array")] terms_of_use: Option>, - /// Human-readable evidence used to support the claims within the `Credential`. + /// Human-readable evidence used to support the claims within the {@link Credential}. #[typescript(type = "Evidence | Array")] evidence: Option>, - /// Indicates that the `Credential` must only be contained within a `Presentation` with a proof issued from the - /// `Credential` subject. + /// Indicates that the {@link Credential} must only be contained within a {@link Presentation} with a proof issued + /// from the {@link Credential} subject. #[typescript(name = "nonTransferable", type = "boolean")] non_transferable: Option, /// Miscellaneous properties. diff --git a/bindings/wasm/src/credential/domain_linkage_credential_builder.rs b/bindings/wasm/src/credential/domain_linkage_credential_builder.rs index 562d7977f5..4f3f9a6028 100644 --- a/bindings/wasm/src/credential/domain_linkage_credential_builder.rs +++ b/bindings/wasm/src/credential/domain_linkage_credential_builder.rs @@ -48,16 +48,16 @@ extern "C" { #[serde(rename_all = "camelCase")] #[typescript(name = "IDomainLinkageCredential", readonly, optional)] struct IDomainLinkageCredentialHelper { - /// A reference to the issuer of the `Credential`. + /// A reference to the issuer of the {@link Credential}. #[typescript(optional = false, type = "CoreDID | IotaDID")] issuer: Option, - /// A timestamp of when the `Credential` becomes valid. Defaults to the current datetime. + /// A timestamp of when the {@link Credential} becomes valid. Defaults to the current datetime. #[typescript(name = "issuanceDate", type = "Timestamp")] issuance_date: Option, - /// A timestamp of when the `Credential` should no longer be considered valid. + /// A timestamp of when the {@link Credential} should no longer be considered valid. #[typescript(optional = false, name = "expirationDate", type = "Timestamp")] expiration_date: Option, - /// The origin, on which the `Credential` is issued. + /// The origin, on which the {@link Credential} is issued. #[typescript(optional = false, name = "origin", type = "string")] origin: Option, } diff --git a/bindings/wasm/src/credential/domain_linkage_validator.rs b/bindings/wasm/src/credential/domain_linkage_validator.rs index 00dc645d6c..39a39353c7 100644 --- a/bindings/wasm/src/credential/domain_linkage_validator.rs +++ b/bindings/wasm/src/credential/domain_linkage_validator.rs @@ -23,7 +23,7 @@ pub struct WasmDomainLinkageValidator { #[wasm_bindgen(js_class = DomainLinkageValidator)] impl WasmDomainLinkageValidator { - /// Creates a new `DomainLinkageValidator`. If a `signatureVerifier` is provided it will be used when + /// Creates a new {@link DomainLinkageValidator}. If a `signatureVerifier` is provided it will be used when /// verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` /// algorithm will be used. #[wasm_bindgen(constructor)] diff --git a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs index c8ef08c08a..b065bc7e5a 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs @@ -34,7 +34,7 @@ pub struct WasmJwtCredentialValidator(JwtCredentialValidator); #[wasm_bindgen(js_class = JwtCredentialValidator)] impl WasmJwtCredentialValidator { - /// Creates a new `JwtCredentialValidator`. If a `signatureVerifier` is provided it will be used when + /// Creates a new {@link JwtCredentialValidator}. If a `signatureVerifier` is provided it will be used when /// verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` /// algorithm will be used. #[wasm_bindgen(constructor)] @@ -44,7 +44,7 @@ impl WasmJwtCredentialValidator { WasmJwtCredentialValidator(JwtCredentialValidator::with_signature_verifier(signature_verifier)) } - /// Decodes and validates a `Credential` issued as a JWS. A `DecodedJwtCredential` is returned upon success. + /// Decodes and validates a {@link Credential} issued as a JWS. A `DecodedJwtCredential` is returned upon success. /// /// The following properties are validated according to `options`: /// - the issuer's signature on the JWS, @@ -85,7 +85,7 @@ impl WasmJwtCredentialValidator { .map(WasmDecodedJwtCredential) } - /// Decode and verify the JWS signature of a `Credential` issued as a JWT using the DID Document of a trusted + /// Decode and verify the JWS signature of a {@link Credential} issued as a JWT using the DID Document of a trusted /// issuer. /// /// A `DecodedJwtCredential` is returned upon success. @@ -94,8 +94,8 @@ impl WasmJwtCredentialValidator { /// The caller must ensure that the DID Documents of the trusted issuers are up-to-date. /// /// ## Proofs - /// Only the JWS signature is verified. If the `Credential` contains a `proof` property this will not be verified - /// by this method. + /// Only the JWS signature is verified. If the {@link Credential} contains a `proof` property this will not be + /// verified by this method. /// /// # Errors /// This method immediately returns an error if @@ -160,7 +160,7 @@ impl WasmJwtCredentialValidator { JwtCredentialValidator::check_status(&credential.0, &trusted_issuers, status_check).wasm_result() } - /// Utility for extracting the issuer field of a `Credential` as a DID. + /// Utility for extracting the issuer field of a {@link Credential} as a DID. /// /// ### Errors /// diff --git a/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs b/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs index d42cbea359..d307080bac 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs @@ -36,7 +36,7 @@ impl WasmUnknownCredentialContainer { } } - /// Returns a `Credential` if the credential is of said type, `undefined` otherwise. + /// Returns a {@link Credential} if the credential is of said type, `undefined` otherwise. #[wasm_bindgen(js_name = tryIntoCredential)] pub fn try_into_credential(&self) -> Option { match &self.0 { diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs index 182376076e..7fc69072ce 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs @@ -21,7 +21,7 @@ pub struct WasmJwtPresentationValidator(JwtPresentationValidator, /// Miscellaneous properties. diff --git a/bindings/wasm/src/credential/types.rs b/bindings/wasm/src/credential/types.rs index 8ed2a93b44..4255bb75df 100644 --- a/bindings/wasm/src/credential/types.rs +++ b/bindings/wasm/src/credential/types.rs @@ -73,7 +73,7 @@ interface Issuer { #[wasm_bindgen(typescript_custom_section)] const I_POLICY: &'static str = r#" -/** Information used to express obligations, prohibitions, and permissions about a `Credential` or `Presentation`. +/** Information used to express obligations, prohibitions, and permissions about a {@link Credential} or {@link Presentation}. [More Info](https://www.w3.org/TR/vc-data-model/#terms-of-use) */ interface Policy { diff --git a/bindings/wasm/src/did/wasm_core_did.rs b/bindings/wasm/src/did/wasm_core_did.rs index 528dbef322..630cdb6096 100644 --- a/bindings/wasm/src/did/wasm_core_did.rs +++ b/bindings/wasm/src/did/wasm_core_did.rs @@ -15,17 +15,17 @@ pub struct WasmCoreDID(pub(crate) CoreDID); #[wasm_bindgen(js_class = CoreDID)] impl WasmCoreDID { - /// Parses a `CoreDID` from the given `input`. + /// Parses a {@link CoreDID} from the given `input`. /// /// ### Errors /// - /// Throws an error if the input is not a valid `CoreDID`. + /// Throws an error if the input is not a valid {@link CoreDID}. #[wasm_bindgen] pub fn parse(input: &str) -> Result { CoreDID::parse(input).wasm_result().map(Self) } - /// Set the method name of the `CoreDID`. + /// Set the method name of the {@link CoreDID}. #[wasm_bindgen(js_name = "setMethodName")] pub fn set_method_name(&mut self, value: String) -> Result<()> { self.0.set_method_name(&value).wasm_result() @@ -53,7 +53,7 @@ impl WasmCoreDID { // DID trait // =========================================================================== - /// Returns the `CoreDID` scheme. + /// Returns the {@link CoreDID} scheme. /// /// E.g. /// - `"did:example:12345678" -> "did"` @@ -63,7 +63,7 @@ impl WasmCoreDID { self.0.scheme().to_owned() } - /// Returns the `CoreDID` authority: the method name and method-id. + /// Returns the {@link CoreDID} authority: the method name and method-id. /// /// E.g. /// - `"did:example:12345678" -> "example:12345678"` @@ -73,7 +73,7 @@ impl WasmCoreDID { self.0.authority().to_owned() } - /// Returns the `CoreDID` method name. + /// Returns the {@link CoreDID} method name. /// /// E.g. /// - `"did:example:12345678" -> "example"` @@ -83,7 +83,7 @@ impl WasmCoreDID { self.0.method().to_owned() } - /// Returns the `CoreDID` method-specific ID. + /// Returns the {@link CoreDID} method-specific ID. /// /// E.g. /// - `"did:example:12345678" -> "12345678"` @@ -99,19 +99,19 @@ impl WasmCoreDID { self.0.clone().join(segment).wasm_result().map(WasmDIDUrl) } - /// Clones the `CoreDID` into a `DIDUrl`. + /// Clones the {@link CoreDID} into a `DIDUrl`. #[wasm_bindgen(js_name = toUrl)] pub fn to_url(&self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.to_url()) } - /// Converts the `CoreDID` into a `DIDUrl`, consuming it. + /// Converts the {@link CoreDID} into a `DIDUrl`, consuming it. #[wasm_bindgen(js_name = intoUrl)] pub fn into_url(self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.into_url()) } - /// Returns the `CoreDID` as a string. + /// Returns the {@link CoreDID} as a string. #[allow(clippy::inherent_to_string)] #[wasm_bindgen(js_name = toString)] pub fn to_string(&self) -> String { @@ -146,9 +146,9 @@ extern "C" { pub type IToCoreDID; // Specially crafted JS function called internally that ensures - // Custom DID implementations built on `CoreDID` don't get nulled - // out by Rust. Also avoids double clones when passing an instance of `CoreDID` - // or `IotaDID`. + // Custom DID implementations built on {@link CoreDID} don't get nulled + // out by Rust. Also avoids double clones when passing an instance of {@link CoreDID} + // or {@link IotaDID}. #[wasm_bindgen(js_name = _getCoreDidCloneInternal, skip_typescript)] pub fn get_core_did_clone(input: &IToCoreDID) -> WasmCoreDID; @@ -158,6 +158,6 @@ extern "C" { pub const TS_AS_REF_CORE_DID: &'static str = r#" interface IToCoreDID { - /** Returns a `CoreDID` representation of this DID. */ + /** Returns a {@link CoreDID} representation of this DID. */ toCoreDid(): CoreDID; }"#; diff --git a/bindings/wasm/src/did/wasm_core_document.rs b/bindings/wasm/src/did/wasm_core_document.rs index c6bbb16eb6..9fc86a16a9 100644 --- a/bindings/wasm/src/did/wasm_core_document.rs +++ b/bindings/wasm/src/did/wasm_core_document.rs @@ -94,7 +94,7 @@ pub struct WasmCoreDocument(pub(crate) Rc); #[wasm_bindgen(js_class = CoreDocument)] impl WasmCoreDocument { - /// Creates a new `CoreDocument` with the given properties. + /// Creates a new {@link CoreDocument} with the given properties. #[wasm_bindgen(constructor)] pub fn new(values: ICoreDocument) -> Result { let core_doc: CoreDocument = values.into_serde().wasm_result()?; @@ -540,7 +540,7 @@ impl WasmCoreDocument { // Cloning // =========================================================================== - /// Deep clones the `CoreDocument`. + /// Deep clones the {@link CoreDocument}. #[wasm_bindgen(js_name = clone)] pub fn deep_clone(&self) -> WasmCoreDocument { WasmCoreDocument(Rc::new(CoreDocumentLock::new(self.0.blocking_read().clone()))) @@ -808,6 +808,6 @@ extern "C" { pub const TS_AS_REF_CORE_Document: &'static str = r#" interface IToCoreDocument { - /** Returns a `CoreDocument` representation of this Document. */ + /** Returns a {@link CoreDocument} representation of this Document. */ toCoreDocument(): CoreDocument; }"#; diff --git a/bindings/wasm/src/did/wasm_did_url.rs b/bindings/wasm/src/did/wasm_did_url.rs index 856250904a..bb39f41ee8 100644 --- a/bindings/wasm/src/did/wasm_did_url.rs +++ b/bindings/wasm/src/did/wasm_did_url.rs @@ -19,7 +19,7 @@ impl WasmDIDUrl { DIDUrl::parse(input).map(WasmDIDUrl).wasm_result() } - /// Return a copy of the `CoreDID` section of the `DIDUrl`. + /// Return a copy of the {@link CoreDID} section of the `DIDUrl`. #[wasm_bindgen] pub fn did(&self) -> WasmCoreDID { WasmCoreDID::from(self.0.did().clone()) diff --git a/bindings/wasm/src/iota/iota_did.rs b/bindings/wasm/src/iota/iota_did.rs index cbcd30bc13..092b6685a0 100644 --- a/bindings/wasm/src/iota/iota_did.rs +++ b/bindings/wasm/src/iota/iota_did.rs @@ -37,7 +37,7 @@ impl WasmIotaDID { // Constructors // =========================================================================== - /// Constructs a new `IotaDID` from a byte representation of the tag and the given + /// Constructs a new {@link IotaDID} from a byte representation of the tag and the given /// network name. /// /// See also {@link IotaDID.placeholder}. @@ -51,7 +51,7 @@ impl WasmIotaDID { Ok(Self::from(IotaDID::new(tag_bytes, &network_name))) } - /// Constructs a new `IotaDID` from a hex representation of an Alias Id and the given + /// Constructs a new {@link IotaDID} from a hex representation of an Alias Id and the given /// network name. #[wasm_bindgen(js_name = fromAliasId)] #[allow(non_snake_case)] @@ -60,7 +60,7 @@ impl WasmIotaDID { Ok(Self::from(IotaDID::from_alias_id(aliasId.as_ref(), &network_name))) } - /// Creates a new placeholder `IotaDID` with the given network name. + /// Creates a new placeholder {@link IotaDID} with the given network name. /// /// E.g. `did:iota:smr:0x0000000000000000000000000000000000000000000000000000000000000000`. #[wasm_bindgen] @@ -69,7 +69,7 @@ impl WasmIotaDID { Ok(Self::from(IotaDID::placeholder(&network_name))) } - /// Parses a `IotaDID` from the input string. + /// Parses a {@link IotaDID} from the input string. #[wasm_bindgen] pub fn parse(input: &str) -> Result { IotaDID::parse(input).map(Self).wasm_result() @@ -79,20 +79,20 @@ impl WasmIotaDID { // Properties // =========================================================================== - /// Returns the Tangle network name of the `IotaDID`. + /// Returns the Tangle network name of the {@link IotaDID}. #[wasm_bindgen] pub fn network(&self) -> String { self.0.network_str().to_owned() } - /// Returns a copy of the unique tag of the `IotaDID`. + /// Returns a copy of the unique tag of the {@link IotaDID}. #[wasm_bindgen] pub fn tag(&self) -> String { self.0.tag_str().to_owned() } #[wasm_bindgen(js_name = toCoreDid)] - /// Returns the DID represented as a `CoreDID`. + /// Returns the DID represented as a {@link CoreDID}. pub fn as_core_did(&self) -> WasmCoreDID { WasmCoreDID(self.0.as_ref().clone()) } diff --git a/bindings/wasm/src/iota/iota_document.rs b/bindings/wasm/src/iota/iota_document.rs index e82e5def86..afa0b8500d 100644 --- a/bindings/wasm/src/iota/iota_document.rs +++ b/bindings/wasm/src/iota/iota_document.rs @@ -596,7 +596,7 @@ impl WasmIotaDocument { // =========================================================================== #[wasm_bindgen(js_name = clone)] - /// Returns a deep clone of the `IotaDocument`. + /// Returns a deep clone of the {@link IotaDocument}. pub fn deep_clone(&self) -> WasmIotaDocument { WasmIotaDocument(Rc::new(IotaDocumentLock::new(self.0.blocking_read().clone()))) } @@ -637,7 +637,7 @@ impl WasmIotaDocument { // =========================================================================== // "AsRef" // =========================================================================== - /// Transforms the `IotaDocument` to its `CoreDocument` representation. + /// Transforms the {@link IotaDocument} to its {@link CoreDocument} representation. #[wasm_bindgen(js_name = toCoreDocument)] pub fn as_core_document(&self) -> WasmCoreDocument { WasmCoreDocument(Rc::new(CoreDocumentLock::new( From 2dc7ee65aa69a293171d43fa6ee4050399c3ed77 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 20 Jul 2023 09:26:39 +0200 Subject: [PATCH 08/11] Fix some docs --- .../jwt_credential_validation/decoded_jwt_credential.rs | 3 ++- .../jwt_credential_validation/jwt_credential_validator.rs | 4 ++-- .../jwt_presentation_validator.rs | 4 ++-- bindings/wasm/src/credential/options.rs | 6 ++---- bindings/wasm/src/iota/iota_document.rs | 2 +- bindings/wasm/src/jose/jwk.rs | 2 +- bindings/wasm/src/resolver/wasm_resolver.rs | 3 ++- bindings/wasm/src/storage/jwk_gen_output.rs | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs b/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs index b317a8ae6f..3a20a60e7d 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs @@ -31,7 +31,8 @@ impl WasmDecodedJwtCredential { /// Consumes the object and returns the decoded credential. /// /// ### Warning - /// This destroys the `DecodedCredential` object. + /// + /// This destroys the `DecodedJwtCredential` object. #[wasm_bindgen(js_name = intoCredential)] pub fn into_credential(self) -> WasmCredential { WasmCredential(self.0.credential) diff --git a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs index b065bc7e5a..751c3c1dab 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs @@ -28,7 +28,7 @@ use crate::verification::WasmJwsVerifier; use wasm_bindgen::prelude::*; -/// A type for decoding and validating `Credentials`. +/// A type for decoding and validating `Credential`. #[wasm_bindgen(js_name = JwtCredentialValidator)] pub struct WasmJwtCredentialValidator(JwtCredentialValidator); @@ -145,7 +145,7 @@ impl WasmJwtCredentialValidator { /// Checks whether the credential status has been revoked. /// - /// Only supports `BitmapRevocation2022`. + /// Only supports `RevocationBitmap2022`. #[wasm_bindgen(js_name = checkStatus)] #[allow(non_snake_case)] pub fn check_status( diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs index 7fc69072ce..087a977dc7 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs @@ -31,7 +31,7 @@ impl WasmJwtPresentationValidator { WasmJwtPresentationValidator(JwtPresentationValidator::with_signature_verifier(signature_verifier)) } - /// Validates a `JwtPresentation`. + /// Validates a `Presentation` encoded as a `Jwt`. /// /// The following properties are validated according to `options`: /// - the JWT can be decoded into a semantically valid presentation. @@ -73,7 +73,7 @@ impl WasmJwtPresentationValidator { .wasm_result() } - /// Validates the semantic structure of the `JwtPresentation`. + /// Validates the semantic structure of the `Presentation`. #[wasm_bindgen(js_name = checkStructure)] pub fn check_structure(presentation: &WasmPresentation) -> Result<()> { JwtPresentationValidator::check_structure(&presentation.0).wasm_result()?; diff --git a/bindings/wasm/src/credential/options.rs b/bindings/wasm/src/credential/options.rs index 469d7a0b46..db5c613527 100644 --- a/bindings/wasm/src/credential/options.rs +++ b/bindings/wasm/src/credential/options.rs @@ -38,8 +38,7 @@ impl From for StatusCheck { } } -/// Declares how credential subjects must relate to the presentation holder during validation. -/// See `PresentationValidationOptions::subject_holder_relationship`. +/// Declares how credential subjects must relate to the presentation holder. /// /// 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)] @@ -47,8 +46,7 @@ impl From for StatusCheck { #[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`. + /// This variant is the default. 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, diff --git a/bindings/wasm/src/iota/iota_document.rs b/bindings/wasm/src/iota/iota_document.rs index afa0b8500d..8045d7f8c4 100644 --- a/bindings/wasm/src/iota/iota_document.rs +++ b/bindings/wasm/src/iota/iota_document.rs @@ -107,7 +107,7 @@ impl WasmIotaDocument { // Constructors // =========================================================================== - /// Constructs an empty DID Document with a {@link IotaDID.placeholder} identifier + /// Constructs an empty IOTA DID Document with a {@link IotaDID.placeholder} identifier /// for the given `network`. #[wasm_bindgen(constructor)] pub fn new(network: String) -> Result { diff --git a/bindings/wasm/src/jose/jwk.rs b/bindings/wasm/src/jose/jwk.rs index 1b8d6fe7c8..83072cb07a 100644 --- a/bindings/wasm/src/jose/jwk.rs +++ b/bindings/wasm/src/jose/jwk.rs @@ -164,7 +164,7 @@ impl WasmJwk { } } - /// Returns a clone of the Jwk with _all_ private key components unset. + /// Returns a clone of the `Jwk` with _all_ private key components unset. /// Nothing is returned when `kty = oct` as this key type is not considered public by this library. #[wasm_bindgen(js_name = toPublic)] pub fn to_public(&self) -> Option { diff --git a/bindings/wasm/src/resolver/wasm_resolver.rs b/bindings/wasm/src/resolver/wasm_resolver.rs index 62f1017dd8..06c117c6ef 100644 --- a/bindings/wasm/src/resolver/wasm_resolver.rs +++ b/bindings/wasm/src/resolver/wasm_resolver.rs @@ -38,9 +38,10 @@ type JsDocumentResolver = SingleThreadedResolver; /// Convenience type for resolving DID documents from different DID methods. /// /// Also provides methods for resolving DID Documents associated with -/// verifiable `Credentials` and `Presentations`. +/// verifiable `Credential`s and `Presentation`s. /// /// # Configuration +/// /// The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor. #[wasm_bindgen(js_name = Resolver)] pub struct WasmResolver(Rc); diff --git a/bindings/wasm/src/storage/jwk_gen_output.rs b/bindings/wasm/src/storage/jwk_gen_output.rs index dfcc71ac74..a43574a313 100644 --- a/bindings/wasm/src/storage/jwk_gen_output.rs +++ b/bindings/wasm/src/storage/jwk_gen_output.rs @@ -19,13 +19,13 @@ impl WasmJwkGenOutput { Self(JwkGenOutput::new(KeyId::new(key_id), jwk.clone().into())) } - /// Returns the generated public JWK. + /// Returns the generated public `Jwk`. #[wasm_bindgen] pub fn jwk(&self) -> WasmJwk { WasmJwk(self.0.jwk.clone()) } - /// Returns the key id of the generated jwk. + /// Returns the key id of the generated `Jwk`. #[wasm_bindgen(js_name = keyId)] pub fn key_id(&self) -> String { self.0.key_id.clone().into() From fa25248c0f8e07bbbe65ca0b6e7bb9b66e2d86e2 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 20 Jul 2023 09:28:40 +0200 Subject: [PATCH 09/11] Replace `Class` with `{@link Class}` --- bindings/wasm/src/common/timestamp.rs | 16 +++++++-------- .../domain_linkage_configuration.rs | 2 +- .../credential/domain_linkage_validator.rs | 2 +- bindings/wasm/src/credential/jws.rs | 2 +- bindings/wasm/src/credential/jwt.rs | 2 +- .../decoded_jwt_credential.rs | 2 +- .../jwt_credential_validator.rs | 6 +++--- .../jwt_credential_validation/options.rs | 8 ++++---- .../unknown_credential.rs | 2 +- .../decoded_jwt_presentation.rs | 2 +- .../jwt_presentation_validator.rs | 6 +++--- .../jwt_presentation_validation/options.rs | 8 ++++---- .../src/credential/linked_domain_service.rs | 2 +- .../wasm/src/did/jws_verification_options.rs | 6 +++--- bindings/wasm/src/did/service.rs | 10 +++++----- bindings/wasm/src/did/wasm_core_did.rs | 6 +++--- bindings/wasm/src/did/wasm_core_document.rs | 4 ++-- bindings/wasm/src/did/wasm_did_url.rs | 20 +++++++++---------- bindings/wasm/src/iota/iota_did.rs | 6 +++--- bindings/wasm/src/iota/iota_document.rs | 4 ++-- bindings/wasm/src/jose/jwk.rs | 2 +- bindings/wasm/src/jose/jws_header.rs | 2 +- bindings/wasm/src/resolver/wasm_resolver.rs | 4 ++-- bindings/wasm/src/revocation/bitmap.rs | 4 ++-- bindings/wasm/src/storage/jwk_gen_output.rs | 6 +++--- .../src/storage/jwt_presentation_options.rs | 2 +- bindings/wasm/src/storage/key_id_storage.rs | 8 ++++---- bindings/wasm/src/storage/method_digest.rs | 6 +++--- .../wasm/src/storage/signature_options.rs | 4 ++-- bindings/wasm/src/storage/wasm_storage.rs | 6 +++--- .../wasm/src/verification/wasm_method_data.rs | 14 ++++++------- .../src/verification/wasm_method_scope.rs | 2 +- .../wasm/src/verification/wasm_method_type.rs | 4 ++-- .../verification/wasm_verification_method.rs | 20 +++++++++---------- 34 files changed, 100 insertions(+), 100 deletions(-) diff --git a/bindings/wasm/src/common/timestamp.rs b/bindings/wasm/src/common/timestamp.rs index 8c396ec9cd..9421d4f065 100644 --- a/bindings/wasm/src/common/timestamp.rs +++ b/bindings/wasm/src/common/timestamp.rs @@ -19,19 +19,19 @@ pub struct WasmTimestamp(pub(crate) Timestamp); #[wasm_bindgen(js_class = Timestamp)] impl WasmTimestamp { - /// Parses a `Timestamp` from the provided input string. + /// Parses a {@link Timestamp} from the provided input string. #[wasm_bindgen] pub fn parse(input: &str) -> Result { Ok(Self(Timestamp::parse(input).wasm_result()?)) } - /// Creates a new `Timestamp` with the current date and time. + /// Creates a new {@link Timestamp} with the current date and time. #[wasm_bindgen(js_name = nowUTC)] pub fn now_utc() -> Self { Self(Timestamp::now_utc()) } - /// Returns the `Timestamp` as an RFC 3339 `String`. + /// Returns the {@link Timestamp} as an RFC 3339 `String`. #[wasm_bindgen(js_name = toRFC3339)] #[allow(clippy::wrong_self_convention)] pub fn to_rfc3339(&self) -> String { @@ -69,30 +69,30 @@ pub struct WasmDuration(pub(crate) Duration); #[wasm_bindgen(js_class = Duration)] impl WasmDuration { - /// Create a new `Duration` with the given number of seconds. + /// Create a new {@link Duration} with the given number of seconds. #[wasm_bindgen] pub fn seconds(seconds: u32) -> WasmDuration { Self(Duration::seconds(seconds)) } - /// Create a new `Duration` with the given number of minutes. + /// Create a new {@link Duration} with the given number of minutes. #[wasm_bindgen] pub fn minutes(minutes: u32) -> WasmDuration { Self(Duration::minutes(minutes)) } - /// Create a new `Duration` with the given number of hours. + /// Create a new {@link Duration} with the given number of hours. #[wasm_bindgen] pub fn hours(hours: u32) -> WasmDuration { Self(Duration::hours(hours)) } - /// Create a new `Duration` with the given number of days. + /// Create a new {@link Duration} with the given number of days. #[wasm_bindgen] pub fn days(days: u32) -> WasmDuration { Self(Duration::days(days)) } - /// Create a new `Duration` with the given number of weeks. + /// Create a new {@link Duration} with the given number of weeks. #[wasm_bindgen] pub fn weeks(weeks: u32) -> WasmDuration { Self(Duration::weeks(weeks)) diff --git a/bindings/wasm/src/credential/domain_linkage_configuration.rs b/bindings/wasm/src/credential/domain_linkage_configuration.rs index f777eedc88..b154dda3cb 100644 --- a/bindings/wasm/src/credential/domain_linkage_configuration.rs +++ b/bindings/wasm/src/credential/domain_linkage_configuration.rs @@ -26,7 +26,7 @@ pub struct WasmDomainLinkageConfiguration(pub(crate) DomainLinkageConfiguration) #[wasm_bindgen(js_class = DomainLinkageConfiguration)] impl WasmDomainLinkageConfiguration { - /// Constructs a new `DomainLinkageConfiguration`. + /// Constructs a new {@link DomainLinkageConfiguration}. #[wasm_bindgen(constructor)] #[allow(non_snake_case)] pub fn new(linkedDids: &ArrayJwt) -> Result { diff --git a/bindings/wasm/src/credential/domain_linkage_validator.rs b/bindings/wasm/src/credential/domain_linkage_validator.rs index 39a39353c7..9f29cb0505 100644 --- a/bindings/wasm/src/credential/domain_linkage_validator.rs +++ b/bindings/wasm/src/credential/domain_linkage_validator.rs @@ -36,7 +36,7 @@ impl WasmDomainLinkageValidator { } /// Validates the linkage between a domain and a DID. - /// `DomainLinkageConfiguration` is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). + /// {@link DomainLinkageConfiguration} is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). /// /// Linkage is valid if no error is thrown. /// diff --git a/bindings/wasm/src/credential/jws.rs b/bindings/wasm/src/credential/jws.rs index a83a2f2d38..a3768a3a83 100644 --- a/bindings/wasm/src/credential/jws.rs +++ b/bindings/wasm/src/credential/jws.rs @@ -13,7 +13,7 @@ impl WasmJws { pub(crate) fn new(jws: Jws) -> Self { WasmJws(jws) } - /// Creates a new `Jws` from the given string. + /// Creates a new {@link Jws} from the given string. #[wasm_bindgen(constructor)] pub fn constructor(jws_string: String) -> Self { Self(Jws::new(jws_string)) diff --git a/bindings/wasm/src/credential/jwt.rs b/bindings/wasm/src/credential/jwt.rs index 25a599a011..49477fb9df 100644 --- a/bindings/wasm/src/credential/jwt.rs +++ b/bindings/wasm/src/credential/jwt.rs @@ -14,7 +14,7 @@ impl WasmJwt { WasmJwt(jwt) } - /// Creates a new `Jwt` from the given string. + /// Creates a new {@link Jwt} from the given string. #[wasm_bindgen(constructor)] pub fn constructor(jwt_string: String) -> Self { Self(Jwt::new(jwt_string)) diff --git a/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs b/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs index 3a20a60e7d..e14198c2b9 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/decoded_jwt_credential.rs @@ -32,7 +32,7 @@ impl WasmDecodedJwtCredential { /// /// ### Warning /// - /// This destroys the `DecodedJwtCredential` object. + /// This destroys the {@link DecodedJwtCredential} object. #[wasm_bindgen(js_name = intoCredential)] pub fn into_credential(self) -> WasmCredential { WasmCredential(self.0.credential) diff --git a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs index 751c3c1dab..cf8873b583 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs @@ -28,7 +28,7 @@ use crate::verification::WasmJwsVerifier; use wasm_bindgen::prelude::*; -/// A type for decoding and validating `Credential`. +/// A type for decoding and validating {@link Credential}. #[wasm_bindgen(js_name = JwtCredentialValidator)] pub struct WasmJwtCredentialValidator(JwtCredentialValidator); @@ -44,7 +44,7 @@ impl WasmJwtCredentialValidator { WasmJwtCredentialValidator(JwtCredentialValidator::with_signature_verifier(signature_verifier)) } - /// Decodes and validates a {@link Credential} issued as a JWS. A `DecodedJwtCredential` is returned upon success. + /// Decodes and validates a {@link Credential} issued as a JWS. A {@link DecodedJwtCredential} is returned upon success. /// /// The following properties are validated according to `options`: /// - the issuer's signature on the JWS, @@ -88,7 +88,7 @@ impl WasmJwtCredentialValidator { /// Decode and verify the JWS signature of a {@link Credential} issued as a JWT using the DID Document of a trusted /// issuer. /// - /// A `DecodedJwtCredential` is returned upon success. + /// A {@link DecodedJwtCredential} is returned upon success. /// /// # Warning /// The caller must ensure that the DID Documents of the trusted issuers are up-to-date. diff --git a/bindings/wasm/src/credential/jwt_credential_validation/options.rs b/bindings/wasm/src/credential/jwt_credential_validation/options.rs index c1b7311346..ac326fb157 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/options.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/options.rs @@ -41,7 +41,7 @@ impl From for JwtCredentialValidationOptions } } -// Interface to allow creating `JwtCredentialValidationOptions` easily. +// Interface to allow creating {@link JwtCredentialValidationOptions} easily. #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "IJwtCredentialValidationOptions")] @@ -50,13 +50,13 @@ extern "C" { #[wasm_bindgen(typescript_custom_section)] const I_JWT_CREDENTIAL_VALIDATION_OPTIONS: &'static str = r#" -/** Holds options to create a new `JwtCredentialValidationOptions`. */ +/** Holds options to create a new {@link JwtCredentialValidationOptions}. */ interface IJwtCredentialValidationOptions { - /** Declare that the credential is **not** considered valid if it expires before this `Timestamp`. + /** Declare that the credential is **not** considered valid if it expires before this {@link Timestamp}. * Uses the current datetime during validation if not set. */ readonly earliestExpiryDate?: Timestamp; - /** Declare that the credential is **not** considered valid if it was issued later than this `Timestamp`. + /** Declare that the credential is **not** considered valid if it was issued later than this {@link Timestamp}. * Uses the current datetime during validation if not set. */ readonly latestIssuanceDate?: Timestamp; diff --git a/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs b/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs index d307080bac..1bf8e89bc3 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/unknown_credential.rs @@ -27,7 +27,7 @@ impl WasmUnknownCredentialContainer { WasmUnknownCredentialContainer(inner) } - /// Returns a `Jwt` if the credential is of type string, `undefined` otherwise. + /// Returns a {@link Jwt} if the credential is of type string, `undefined` otherwise. #[wasm_bindgen(js_name = tryIntoJwt)] pub fn try_into_jwt(&self) -> Option { match &self.0 { diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/decoded_jwt_presentation.rs b/bindings/wasm/src/credential/jwt_presentation_validation/decoded_jwt_presentation.rs index aa2447f22e..ee1e63f495 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/decoded_jwt_presentation.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/decoded_jwt_presentation.rs @@ -32,7 +32,7 @@ impl WasmDecodedJwtPresentation { /// Consumes the object and returns the decoded presentation. /// /// ### Warning - /// This destroys the `DecodedJwtPresentation` object. + /// This destroys the {@link DecodedJwtPresentation} object. #[wasm_bindgen(js_name = intoPresentation)] pub fn into_presentation(self) -> WasmPresentation { WasmPresentation(self.0.presentation) diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs index 087a977dc7..7e076c2d63 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/jwt_presentation_validator.rs @@ -31,7 +31,7 @@ impl WasmJwtPresentationValidator { WasmJwtPresentationValidator(JwtPresentationValidator::with_signature_verifier(signature_verifier)) } - /// Validates a `Presentation` encoded as a `Jwt`. + /// Validates a {@link Presentation} encoded as a {@link Jwt}. /// /// The following properties are validated according to `options`: /// - the JWT can be decoded into a semantically valid presentation. @@ -43,7 +43,7 @@ impl WasmJwtPresentationValidator { /// # Warning /// /// * This method does NOT validate the constituent credentials and therefore also not the relationship between the - /// credentials' subjects and the presentation holder. This can be done with `JwtCredentialValidationOptions`. + /// credentials' subjects and the presentation holder. This can be done with {@link JwtCredentialValidationOptions}. /// * The lack of an error returned from this method is in of itself not enough to conclude that the presentation can /// be trusted. This section contains more information on additional checks that should be carried out before and /// after calling this method. @@ -73,7 +73,7 @@ impl WasmJwtPresentationValidator { .wasm_result() } - /// Validates the semantic structure of the `Presentation`. + /// Validates the semantic structure of the {@link Presentation}. #[wasm_bindgen(js_name = checkStructure)] pub fn check_structure(presentation: &WasmPresentation) -> Result<()> { JwtPresentationValidator::check_structure(&presentation.0).wasm_result()?; diff --git a/bindings/wasm/src/credential/jwt_presentation_validation/options.rs b/bindings/wasm/src/credential/jwt_presentation_validation/options.rs index ff7255d2e9..46fdf78429 100644 --- a/bindings/wasm/src/credential/jwt_presentation_validation/options.rs +++ b/bindings/wasm/src/credential/jwt_presentation_validation/options.rs @@ -12,7 +12,7 @@ pub struct WasmJwtPresentationValidationOptions(pub(crate) JwtPresentationValida #[wasm_bindgen(js_class = JwtPresentationValidationOptions)] impl WasmJwtPresentationValidationOptions { - /// Creates a new `JwtPresentationValidationOptions` from the given fields. + /// Creates a new {@link JwtPresentationValidationOptions} from the given fields. /// /// Throws an error if any of the options are invalid. #[wasm_bindgen(constructor)] @@ -51,7 +51,7 @@ extern "C" { #[wasm_bindgen(typescript_custom_section)] const I_JWT_PRESENTATION_VALIDATION_OPTIONS: &'static str = r#" -/** Holds options to create a new `JwtPresentationValidationOptions`. */ +/** Holds options to create a new {@link JwtPresentationValidationOptions}. */ interface IJwtPresentationValidationOptions { /** * Options which affect the verification of the signature on the presentation. @@ -59,13 +59,13 @@ interface IJwtPresentationValidationOptions { readonly presentationVerifierOptions?: JwsVerificationOptions; /** - * Declare that the presentation is **not** considered valid if it expires before this `Timestamp`. + * Declare that the presentation is **not** considered valid if it expires before this {@link Timestamp}. * Uses the current datetime during validation if not set. */ readonly earliestExpiryDate?: Timestamp; /** - * Declare that the presentation is **not** considered valid if it was issued later than this `Timestamp`. + * Declare that the presentation is **not** considered valid if it was issued later than this {@link Timestamp}. * Uses the current datetime during validation if not set. */ readonly latestIssuanceDate?: Timestamp; diff --git a/bindings/wasm/src/credential/linked_domain_service.rs b/bindings/wasm/src/credential/linked_domain_service.rs index 7f3bb89a20..8bdf5bf0c4 100644 --- a/bindings/wasm/src/credential/linked_domain_service.rs +++ b/bindings/wasm/src/credential/linked_domain_service.rs @@ -23,7 +23,7 @@ pub struct WasmLinkedDomainService(LinkedDomainService); /// [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). #[wasm_bindgen(js_class = LinkedDomainService)] impl WasmLinkedDomainService { - /// Constructs a new `LinkedDomainService` that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). + /// Constructs a new {@link LinkedDomainService} that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). /// /// Domain URLs must include the `https` scheme in order to pass the domain linkage validation. #[wasm_bindgen(constructor)] diff --git a/bindings/wasm/src/did/jws_verification_options.rs b/bindings/wasm/src/did/jws_verification_options.rs index 6d5d861389..1ed292ddb4 100644 --- a/bindings/wasm/src/did/jws_verification_options.rs +++ b/bindings/wasm/src/did/jws_verification_options.rs @@ -12,7 +12,7 @@ pub struct WasmJwsVerificationOptions(pub(crate) JwsVerificationOptions); #[wasm_bindgen(js_class = JwsVerificationOptions)] impl WasmJwsVerificationOptions { - /// Creates a new `JwsVerificationOptions` from the given fields. + /// Creates a new {@link JwsVerificationOptions} from the given fields. #[wasm_bindgen(constructor)] pub fn new(options: Option) -> Result { if let Some(options) = options { @@ -39,7 +39,7 @@ impl WasmJwsVerificationOptions { impl_wasm_json!(WasmJwsVerificationOptions, JwsVerificationOptions); impl_wasm_clone!(WasmJwsVerificationOptions, JwsVerificationOptions); -/// Duck-typed interface to allow creating `JwsVerificationOptions` easily. +/// Duck-typed interface to allow creating {@link JwsVerificationOptions} easily. #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "IJwsVerificationOptions")] @@ -48,7 +48,7 @@ extern "C" { #[wasm_bindgen(typescript_custom_section)] const I_JWS_SIGNATURE_OPTIONS: &'static str = r#" -/** Holds options to create `JwsVerificationOptions`. */ +/** Holds options to create {@link JwsVerificationOptions}. */ interface IJwsVerificationOptions { /** * A list of permitted extension parameters. diff --git a/bindings/wasm/src/did/service.rs b/bindings/wasm/src/did/service.rs index fae17c6694..eb89f52096 100644 --- a/bindings/wasm/src/did/service.rs +++ b/bindings/wasm/src/did/service.rs @@ -39,13 +39,13 @@ impl WasmService { .wasm_result() } - /// Returns a copy of the `Service` id. + /// Returns a copy of the {@link Service} id. #[wasm_bindgen] pub fn id(&self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.id().clone()) } - /// Returns a copy of the `Service` type. + /// Returns a copy of the {@link Service} type. #[wasm_bindgen(js_name = type)] pub fn type_(&self) -> ArrayString { self @@ -58,13 +58,13 @@ impl WasmService { .unchecked_into::() } - /// Returns a copy of the `Service` endpoint. + /// Returns a copy of the {@link Service} endpoint. #[wasm_bindgen(js_name = serviceEndpoint)] pub fn service_endpoint(&self) -> UServiceEndpoint { UServiceEndpoint::from(self.0.service_endpoint()) } - /// Returns a copy of the custom properties on the `Service`. + /// Returns a copy of the custom properties on the {@link Service}. #[wasm_bindgen] pub fn properties(&self) -> Result { MapStringAny::try_from(self.0.properties()) @@ -142,7 +142,7 @@ extern "C" { #[wasm_bindgen(typescript_custom_section)] const I_SERVICE: &'static str = r#" /** - * Base `Service` properties. + * Base {@link Service} properties. */ interface IService { /** diff --git a/bindings/wasm/src/did/wasm_core_did.rs b/bindings/wasm/src/did/wasm_core_did.rs index 630cdb6096..292cb0bb93 100644 --- a/bindings/wasm/src/did/wasm_core_did.rs +++ b/bindings/wasm/src/did/wasm_core_did.rs @@ -93,19 +93,19 @@ impl WasmCoreDID { self.0.method_id().to_owned() } - /// Construct a new `DIDUrl` by joining with a relative DID Url string. + /// Construct a new {@link DIDUrl} by joining with a relative DID Url string. #[wasm_bindgen] pub fn join(&self, segment: &str) -> Result { self.0.clone().join(segment).wasm_result().map(WasmDIDUrl) } - /// Clones the {@link CoreDID} into a `DIDUrl`. + /// Clones the {@link CoreDID} into a {@link DIDUrl}. #[wasm_bindgen(js_name = toUrl)] pub fn to_url(&self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.to_url()) } - /// Converts the {@link CoreDID} into a `DIDUrl`, consuming it. + /// Converts the {@link CoreDID} into a {@link DIDUrl}, consuming it. #[wasm_bindgen(js_name = intoUrl)] pub fn into_url(self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.into_url()) diff --git a/bindings/wasm/src/did/wasm_core_document.rs b/bindings/wasm/src/did/wasm_core_document.rs index 9fc86a16a9..9dee8c688e 100644 --- a/bindings/wasm/src/did/wasm_core_document.rs +++ b/bindings/wasm/src/did/wasm_core_document.rs @@ -506,7 +506,7 @@ impl WasmCoreDocument { // Revocation // =========================================================================== - /// If the document has a `RevocationBitmap` service identified by `serviceQuery`, + /// If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, /// revoke all specified `indices`. #[wasm_bindgen(js_name = revokeCredentials)] #[allow(non_snake_case)] @@ -521,7 +521,7 @@ impl WasmCoreDocument { .wasm_result() } - /// If the document has a `RevocationBitmap` service identified by `serviceQuery`, + /// If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, /// unrevoke all specified `indices`. #[wasm_bindgen(js_name = unrevokeCredentials)] #[allow(non_snake_case)] diff --git a/bindings/wasm/src/did/wasm_did_url.rs b/bindings/wasm/src/did/wasm_did_url.rs index bb39f41ee8..9a6ccba683 100644 --- a/bindings/wasm/src/did/wasm_did_url.rs +++ b/bindings/wasm/src/did/wasm_did_url.rs @@ -13,13 +13,13 @@ pub struct WasmDIDUrl(pub(crate) DIDUrl); #[wasm_bindgen(js_class = DIDUrl)] impl WasmDIDUrl { - /// Parses a `DIDUrl` from the input string. + /// Parses a {@link DIDUrl} from the input string. #[wasm_bindgen] pub fn parse(input: &str) -> Result { DIDUrl::parse(input).map(WasmDIDUrl).wasm_result() } - /// Return a copy of the {@link CoreDID} section of the `DIDUrl`. + /// Return a copy of the {@link CoreDID} section of the {@link DIDUrl}. #[wasm_bindgen] pub fn did(&self) -> WasmCoreDID { WasmCoreDID::from(self.0.did().clone()) @@ -31,43 +31,43 @@ impl WasmDIDUrl { self.0.url().to_string() } - /// Returns a copy of the `DIDUrl` method fragment, if any. Excludes the leading '#'. + /// Returns a copy of the {@link DIDUrl} method fragment, if any. Excludes the leading '#'. #[wasm_bindgen] pub fn fragment(&self) -> Option { self.0.fragment().map(str::to_owned) } - /// Sets the `fragment` component of the `DIDUrl`. + /// Sets the `fragment` component of the {@link DIDUrl}. #[wasm_bindgen(js_name = setFragment)] pub fn set_fragment(&mut self, value: Option) -> Result<()> { self.0.set_fragment(value.as_deref()).wasm_result() } - /// Returns a copy of the `DIDUrl` path. + /// Returns a copy of the {@link DIDUrl} path. #[wasm_bindgen] pub fn path(&self) -> Option { self.0.path().map(str::to_owned) } - /// Sets the `path` component of the `DIDUrl`. + /// Sets the `path` component of the {@link DIDUrl}. #[wasm_bindgen(js_name = setPath)] pub fn set_path(&mut self, value: Option) -> Result<()> { self.0.set_path(value.as_deref()).wasm_result() } - /// Returns a copy of the `DIDUrl` method query, if any. Excludes the leading '?'. + /// Returns a copy of the {@link DIDUrl} method query, if any. Excludes the leading '?'. #[wasm_bindgen] pub fn query(&self) -> Option { self.0.query().map(str::to_owned) } - /// Sets the `query` component of the `DIDUrl`. + /// Sets the `query` component of the {@link DIDUrl}. #[wasm_bindgen(js_name = setQuery)] pub fn set_query(&mut self, value: Option) -> Result<()> { self.0.set_query(value.as_deref()).wasm_result() } - /// Append a string representing a path, query, and/or fragment, returning a new `DIDUrl`. + /// Append a string representing a path, query, and/or fragment, returning a new {@link DIDUrl}. /// /// Must begin with a valid delimiter character: '/', '?', '#'. Overwrites the existing URL /// segment and any following segments in order of path, query, then fragment. @@ -81,7 +81,7 @@ impl WasmDIDUrl { self.0.join(segment).map(WasmDIDUrl::from).wasm_result() } - /// Returns the `DIDUrl` as a string. + /// Returns the {@link DIDUrl} as a string. #[allow(clippy::inherent_to_string)] #[wasm_bindgen(js_name = toString)] pub fn to_string(&self) -> String { diff --git a/bindings/wasm/src/iota/iota_did.rs b/bindings/wasm/src/iota/iota_did.rs index 092b6685a0..cbf126b80d 100644 --- a/bindings/wasm/src/iota/iota_did.rs +++ b/bindings/wasm/src/iota/iota_did.rs @@ -141,13 +141,13 @@ impl WasmIotaDID { self.0.method_id().to_owned() } - /// Construct a new `DIDUrl` by joining with a relative DID Url string. + /// Construct a new {@link DIDUrl} by joining with a relative DID Url string. #[wasm_bindgen] pub fn join(&self, segment: &str) -> Result { self.0.clone().join(segment).wasm_result().map(WasmDIDUrl) } - /// Clones the `DID` into a `DIDUrl`. + /// Clones the `DID` into a {@link DIDUrl}. #[wasm_bindgen(js_name = toUrl)] pub fn to_url(&self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.to_url()) @@ -159,7 +159,7 @@ impl WasmIotaDID { AliasId::from(&self.0).to_string() } - /// Converts the `DID` into a `DIDUrl`, consuming it. + /// Converts the `DID` into a {@link DIDUrl}, consuming it. #[wasm_bindgen(js_name = intoUrl)] pub fn into_url(self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.into_url()) diff --git a/bindings/wasm/src/iota/iota_document.rs b/bindings/wasm/src/iota/iota_document.rs index 8045d7f8c4..871cb6f327 100644 --- a/bindings/wasm/src/iota/iota_document.rs +++ b/bindings/wasm/src/iota/iota_document.rs @@ -561,7 +561,7 @@ impl WasmIotaDocument { // Revocation // =========================================================================== - /// If the document has a `RevocationBitmap` service identified by `serviceQuery`, + /// If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, /// revoke all specified `indices`. #[wasm_bindgen(js_name = revokeCredentials)] #[allow(non_snake_case)] @@ -576,7 +576,7 @@ impl WasmIotaDocument { .wasm_result() } - /// If the document has a `RevocationBitmap` service identified by `serviceQuery`, + /// If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, /// unrevoke all specified `indices`. #[wasm_bindgen(js_name = unrevokeCredentials)] #[allow(non_snake_case)] diff --git a/bindings/wasm/src/jose/jwk.rs b/bindings/wasm/src/jose/jwk.rs index 83072cb07a..877ee30481 100644 --- a/bindings/wasm/src/jose/jwk.rs +++ b/bindings/wasm/src/jose/jwk.rs @@ -164,7 +164,7 @@ impl WasmJwk { } } - /// Returns a clone of the `Jwk` with _all_ private key components unset. + /// Returns a clone of the {@link Jwk} with _all_ private key components unset. /// Nothing is returned when `kty = oct` as this key type is not considered public by this library. #[wasm_bindgen(js_name = toPublic)] pub fn to_public(&self) -> Option { diff --git a/bindings/wasm/src/jose/jws_header.rs b/bindings/wasm/src/jose/jws_header.rs index 47cbd9701c..a4791e2604 100644 --- a/bindings/wasm/src/jose/jws_header.rs +++ b/bindings/wasm/src/jose/jws_header.rs @@ -23,7 +23,7 @@ pub struct WasmJwsHeader(pub(crate) JwsHeader); #[wasm_bindgen(js_class = JwsHeader)] impl WasmJwsHeader { - /// Create a new empty `JwsHeader`. + /// Create a new empty {@link JwsHeader}. #[wasm_bindgen(constructor)] #[allow(clippy::new_without_default)] pub fn new() -> WasmJwsHeader { diff --git a/bindings/wasm/src/resolver/wasm_resolver.rs b/bindings/wasm/src/resolver/wasm_resolver.rs index 06c117c6ef..9c15857aec 100644 --- a/bindings/wasm/src/resolver/wasm_resolver.rs +++ b/bindings/wasm/src/resolver/wasm_resolver.rs @@ -38,7 +38,7 @@ type JsDocumentResolver = SingleThreadedResolver; /// Convenience type for resolving DID documents from different DID methods. /// /// Also provides methods for resolving DID Documents associated with -/// verifiable `Credential`s and `Presentation`s. +/// verifiable {@link Credential}s and {@link Presentation}s. /// /// # Configuration /// @@ -48,7 +48,7 @@ pub struct WasmResolver(Rc); #[wasm_bindgen(js_class = Resolver)] impl WasmResolver { - /// Constructs a new `Resolver`. + /// Constructs a new {@link Resolver}. /// /// # Errors /// If both a `client` is given and the `handlers` map contains the "iota" key the construction process diff --git a/bindings/wasm/src/revocation/bitmap.rs b/bindings/wasm/src/revocation/bitmap.rs index 4c20ca4e57..69cf9fe67b 100644 --- a/bindings/wasm/src/revocation/bitmap.rs +++ b/bindings/wasm/src/revocation/bitmap.rs @@ -19,7 +19,7 @@ pub struct WasmRevocationBitmap(pub(crate) RevocationBitmap); #[allow(clippy::new_without_default)] #[wasm_bindgen(js_class = RevocationBitmap)] impl WasmRevocationBitmap { - /// Creates a new `RevocationBitmap` instance. + /// Creates a new {@link RevocationBitmap} instance. #[wasm_bindgen(constructor)] pub fn new() -> Self { WasmRevocationBitmap(RevocationBitmap::new()) @@ -67,7 +67,7 @@ impl WasmRevocationBitmap { self.0.to_endpoint().map(UServiceEndpoint::from).wasm_result() } - /// Construct a `RevocationBitmap` from a data `url`. + /// Construct a {@link RevocationBitmap} from a data `url`. #[wasm_bindgen(js_name = fromEndpoint)] pub fn from_endpoint(endpoint: UServiceEndpoint) -> Result { let endpoint: ServiceEndpoint = endpoint.into_serde().wasm_result()?; diff --git a/bindings/wasm/src/storage/jwk_gen_output.rs b/bindings/wasm/src/storage/jwk_gen_output.rs index a43574a313..2a9a63e112 100644 --- a/bindings/wasm/src/storage/jwk_gen_output.rs +++ b/bindings/wasm/src/storage/jwk_gen_output.rs @@ -7,7 +7,7 @@ use wasm_bindgen::prelude::*; use crate::jose::WasmJwk; -/// The result of a key generation in `JwkStorage`. +/// The result of a key generation in {@link JwkStorage}. #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[wasm_bindgen(js_name = JwkGenOutput, inspectable)] pub struct WasmJwkGenOutput(pub(crate) JwkGenOutput); @@ -19,13 +19,13 @@ impl WasmJwkGenOutput { Self(JwkGenOutput::new(KeyId::new(key_id), jwk.clone().into())) } - /// Returns the generated public `Jwk`. + /// Returns the generated public {@link Jwk}. #[wasm_bindgen] pub fn jwk(&self) -> WasmJwk { WasmJwk(self.0.jwk.clone()) } - /// Returns the key id of the generated `Jwk`. + /// Returns the key id of the generated {@link Jwk}. #[wasm_bindgen(js_name = keyId)] pub fn key_id(&self) -> String { self.0.key_id.clone().into() diff --git a/bindings/wasm/src/storage/jwt_presentation_options.rs b/bindings/wasm/src/storage/jwt_presentation_options.rs index dde85493f1..56a1581414 100644 --- a/bindings/wasm/src/storage/jwt_presentation_options.rs +++ b/bindings/wasm/src/storage/jwt_presentation_options.rs @@ -11,7 +11,7 @@ pub struct WasmJwtPresentationOptions(pub(crate) JwtPresentationOptions); #[wasm_bindgen(js_class = JwtPresentationOptions)] impl WasmJwtPresentationOptions { - /// Creates a new `JwtPresentationOptions` from the given fields. + /// Creates a new {@link JwtPresentationOptions} from the given fields. /// /// Throws an error if any of the options are invalid. #[wasm_bindgen(constructor)] diff --git a/bindings/wasm/src/storage/key_id_storage.rs b/bindings/wasm/src/storage/key_id_storage.rs index 977e90d36d..7ba5689634 100644 --- a/bindings/wasm/src/storage/key_id_storage.rs +++ b/bindings/wasm/src/storage/key_id_storage.rs @@ -61,11 +61,11 @@ impl KeyIdStorage for WasmKeyIdStorage { #[wasm_bindgen(typescript_custom_section)] const JWK_STORAGE: &'static str = r#" /** - * Key value Storage for key ids under `MethodDigest`. + * Key value Storage for key ids under {@link MethodDigest}. */ interface KeyIdStorage { /** - * Insert a key id into the `KeyIdStorage` under the given `MethodDigest`. + * Insert a key id into the {@link KeyIdStorage} under the given {@link MethodDigest}. * * If an entry for `key` already exists in the storage an error must be returned * immediately without altering the state of the storage. @@ -73,12 +73,12 @@ interface KeyIdStorage { insertKeyId: (methodDigest: MethodDigest, keyId: string) => Promise; /** - * Obtain the key id associated with the given `MethodDigest`. + * Obtain the key id associated with the given {@link MethodDigest}. */ getKeyId: (methodDigest: MethodDigest) => Promise; /** - * Delete the `KeyId` associated with the given `MethodDigest` from the `KeyIdStorage`. + * Delete the `KeyId` associated with the given {@link MethodDigest} from the {@link KeyIdStorage}. * * If `key` is not found in storage, an Error must be returned. */ diff --git a/bindings/wasm/src/storage/method_digest.rs b/bindings/wasm/src/storage/method_digest.rs index 6f0643d04f..6712ae8a12 100644 --- a/bindings/wasm/src/storage/method_digest.rs +++ b/bindings/wasm/src/storage/method_digest.rs @@ -9,7 +9,7 @@ use crate::error::Result; use crate::error::WasmResult; use crate::verification::WasmVerificationMethod; -/// Unique identifier of a `VerificationMethod`. +/// Unique identifier of a {@link VerificationMethod}. /// /// NOTE: /// This class does not have a JSON representation, @@ -24,14 +24,14 @@ impl WasmMethodDigest { Ok(Self(MethodDigest::new(&verification_method.0).wasm_result()?)) } - /// Packs `MethodDigest` into bytes. + /// Packs {@link MethodDigest} into bytes. #[wasm_bindgen] pub fn pack(&self) -> Uint8Array { let bytes: &[u8] = &self.0.pack(); bytes.into() } - /// Unpacks bytes into `MethodDigest`. + /// Unpacks bytes into {@link MethodDigest}. #[wasm_bindgen] pub fn unpack(bytes: &Uint8Array) -> Result { let bytes: Vec = bytes.to_vec(); diff --git a/bindings/wasm/src/storage/signature_options.rs b/bindings/wasm/src/storage/signature_options.rs index 51c95e9162..239e797593 100644 --- a/bindings/wasm/src/storage/signature_options.rs +++ b/bindings/wasm/src/storage/signature_options.rs @@ -69,7 +69,7 @@ impl WasmJwsSignatureOptions { impl_wasm_json!(WasmJwsSignatureOptions, JwsSignatureOptions); impl_wasm_clone!(WasmJwsSignatureOptions, JwsSignatureOptions); -/// Duck-typed interface to allow creating `JwsSignatureOptions` easily. +/// Duck-typed interface to allow creating {@link JwsSignatureOptions} easily. #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "IJwsSignatureOptions")] @@ -78,7 +78,7 @@ extern "C" { #[wasm_bindgen(typescript_custom_section)] const I_JWS_SIGNATURE_OPTIONS: &'static str = r#" -/** Holds options to create `JwsSignatureOptions`. */ +/** Holds options to create {@link JwsSignatureOptions}. */ interface IJwsSignatureOptions { /** Whether to attach the public key in the corresponding method * to the JWS header. diff --git a/bindings/wasm/src/storage/wasm_storage.rs b/bindings/wasm/src/storage/wasm_storage.rs index 72d2657950..eaf821334b 100644 --- a/bindings/wasm/src/storage/wasm_storage.rs +++ b/bindings/wasm/src/storage/wasm_storage.rs @@ -11,7 +11,7 @@ use wasm_bindgen::prelude::*; pub(crate) type WasmStorageInner = Storage; -/// A type wrapping a `JwkStorage` and `KeyIdStorage` that should always be used together when +/// A type wrapping a {@link JwkStorage} and {@link KeyIdStorage} that should always be used together when /// working with storage backed DID documents. #[wasm_bindgen(js_name = Storage)] pub struct WasmStorage(pub(crate) Rc); @@ -25,13 +25,13 @@ impl WasmStorage { WasmStorage(Rc::new(Storage::new(jwkStorage, keyIdStorage))) } - /// Obtain the wrapped `KeyIdStorage`. + /// Obtain the wrapped {@link KeyIdStorage}. #[wasm_bindgen(js_name = keyIdStorage)] pub fn key_id_storage(&self) -> WasmKeyIdStorage { JsValue::from(self.0.key_id_storage()).unchecked_into() } - /// Obtain the wrapped `JwkStorage`. + /// Obtain the wrapped {@link JwkStorage}. #[wasm_bindgen(js_name = keyStorage)] pub fn key_storage(&self) -> WasmJwkStorage { JsValue::from(self.0.key_storage()).unchecked_into() diff --git a/bindings/wasm/src/verification/wasm_method_data.rs b/bindings/wasm/src/verification/wasm_method_data.rs index efbd98f63a..5bba4aa5a9 100644 --- a/bindings/wasm/src/verification/wasm_method_data.rs +++ b/bindings/wasm/src/verification/wasm_method_data.rs @@ -16,19 +16,19 @@ pub struct WasmMethodData(pub(crate) MethodData); #[wasm_bindgen(js_class = MethodData)] impl WasmMethodData { - /// Creates a new `MethodData` variant with Base58-BTC encoded content. + /// Creates a new {@link MethodData} variant with Base58-BTC encoded content. #[wasm_bindgen(js_name = newBase58)] pub fn new_base58(data: Vec) -> Self { Self(MethodData::new_base58(data)) } - /// Creates a new `MethodData` variant with Multibase-encoded content. + /// Creates a new {@link MethodData} variant with Multibase-encoded content. #[wasm_bindgen(js_name = newMultibase)] pub fn new_multibase(data: Vec) -> Self { Self(MethodData::new_multibase(data)) } - /// Creates a new `MethodData` variant consisting of the given `key`. + /// Creates a new {@link MethodData} variant consisting of the given `key`. /// /// ### Errors /// An error is thrown if the given `key` contains any private components. @@ -45,19 +45,19 @@ impl WasmMethodData { Ok(Self(MethodData::PublicKeyJwk(key.0.clone()))) } - /// Returns a `Uint8Array` containing the decoded bytes of the `MethodData`. + /// Returns a `Uint8Array` containing the decoded bytes of the {@link MethodData}. /// - /// This is generally a public key identified by a `MethodData` value. + /// This is generally a public key identified by a {@link MethodData} value. /// /// ### Errors - /// Decoding can fail if `MethodData` has invalid content or cannot be + /// Decoding can fail if {@link MethodData} has invalid content or cannot be /// represented as a vector of bytes. #[wasm_bindgen(js_name = tryDecode)] pub fn try_decode(&self) -> Result> { self.0.try_decode().wasm_result() } - /// Returns the wrapped `Jwk` if the format is `PublicKeyJwk`. + /// Returns the wrapped {@link Jwk} if the format is `PublicKeyJwk`. #[wasm_bindgen(js_name = tryPublicKeyJwk)] pub fn try_public_key_jwk(&self) -> Result { self.0.try_public_key_jwk().cloned().map(WasmJwk::from).wasm_result() diff --git a/bindings/wasm/src/verification/wasm_method_scope.rs b/bindings/wasm/src/verification/wasm_method_scope.rs index a7c775dc0b..b0bbcdf72c 100644 --- a/bindings/wasm/src/verification/wasm_method_scope.rs +++ b/bindings/wasm/src/verification/wasm_method_scope.rs @@ -50,7 +50,7 @@ impl WasmMethodScope { Self(MethodScope::capability_invocation()) } - /// Returns the `MethodScope` as a string. + /// Returns the {@link MethodScope} as a string. #[allow(clippy::inherent_to_string)] #[wasm_bindgen(js_name = toString)] pub fn to_string(&self) -> String { diff --git a/bindings/wasm/src/verification/wasm_method_type.rs b/bindings/wasm/src/verification/wasm_method_type.rs index 28d185ddb0..9fb1fff660 100644 --- a/bindings/wasm/src/verification/wasm_method_type.rs +++ b/bindings/wasm/src/verification/wasm_method_type.rs @@ -20,14 +20,14 @@ impl WasmMethodType { WasmMethodType(MethodType::X25519_KEY_AGREEMENT_KEY_2019) } - /// A verification method for use with JWT verification as prescribed by the `Jwk` + /// A verification method for use with JWT verification as prescribed by the {@link Jwk} /// in the `publicKeyJwk` entry. #[wasm_bindgen(js_name = JsonWebKey)] pub fn json_web_key() -> WasmMethodType { WasmMethodType(MethodType::JSON_WEB_KEY) } - /// Returns the `MethodType` as a string. + /// Returns the {@link MethodType} as a string. #[allow(clippy::inherent_to_string)] #[wasm_bindgen(js_name = toString)] pub fn to_string(&self) -> String { diff --git a/bindings/wasm/src/verification/wasm_verification_method.rs b/bindings/wasm/src/verification/wasm_verification_method.rs index e3dff6a09b..62b5103c9d 100644 --- a/bindings/wasm/src/verification/wasm_verification_method.rs +++ b/bindings/wasm/src/verification/wasm_verification_method.rs @@ -21,7 +21,7 @@ pub struct WasmVerificationMethod(pub(crate) VerificationMethod); #[wasm_bindgen(js_class = VerificationMethod)] impl WasmVerificationMethod { - /// Creates a new `VerificationMethod` from the given `did` and `Jwk`. If `fragment` is not given + /// Creates a new {@link VerificationMethod} from the given `did` and {@link Jwk}. If `fragment` is not given /// the `kid` value of the given `key` will be used, if present, otherwise an error is returned. /// /// ### Recommendations @@ -29,7 +29,7 @@ impl WasmVerificationMethod { /// - It is recommended that verification methods that use `Jwks` to represent their public keys use the value of /// `kid` as their fragment identifier. This is /// done automatically if `None` is passed in as the fragment. - /// - It is recommended that `Jwk` kid values are set to the public key fingerprint. + /// - It is recommended that {@link Jwk} kid values are set to the public key fingerprint. #[wasm_bindgen(js_name = newFromJwk)] pub fn new_from_jwk(did: &IToCoreDID, key: &WasmJwk, fragment: Option) -> Result { VerificationMethod::new_from_jwk(CoreDID::from(did), key.0.clone(), fragment.as_deref()) @@ -37,50 +37,50 @@ impl WasmVerificationMethod { .wasm_result() } - /// Returns a copy of the `DIDUrl` of the `VerificationMethod`'s `id`. + /// Returns a copy of the {@link DIDUrl} of the {@link VerificationMethod}'s `id`. #[wasm_bindgen] pub fn id(&self) -> WasmDIDUrl { WasmDIDUrl::from(self.0.id().clone()) } - /// Sets the id of the `VerificationMethod`. + /// Sets the id of the {@link VerificationMethod}. #[wasm_bindgen(js_name = setId)] pub fn set_id(&mut self, id: &WasmDIDUrl) -> Result<()> { self.0.set_id(id.0.clone()).wasm_result()?; Ok(()) } - /// Returns a copy of the `controller` `DID` of the `VerificationMethod`. + /// Returns a copy of the `controller` `DID` of the {@link VerificationMethod}. #[wasm_bindgen] pub fn controller(&self) -> WasmCoreDID { WasmCoreDID::from(self.0.controller().clone()) } - /// Sets the `controller` `DID` of the `VerificationMethod` object. + /// Sets the `controller` `DID` of the {@link VerificationMethod} object. #[wasm_bindgen(js_name = setController)] pub fn set_controller(&mut self, did: &WasmCoreDID) { *self.0.controller_mut() = did.0.clone(); } - /// Returns a copy of the `VerificationMethod` type. + /// Returns a copy of the {@link VerificationMethod} type. #[wasm_bindgen(js_name = type)] pub fn type_(&self) -> WasmMethodType { WasmMethodType::from(self.0.type_().clone()) } - /// Sets the `VerificationMethod` type. + /// Sets the {@link VerificationMethod} type. #[wasm_bindgen(js_name = setType)] pub fn set_type(&mut self, type_: &WasmMethodType) { *self.0.type_mut() = type_.0.clone(); } - /// Returns a copy of the `VerificationMethod` public key data. + /// Returns a copy of the {@link VerificationMethod} public key data. #[wasm_bindgen] pub fn data(&self) -> WasmMethodData { WasmMethodData::from(self.0.data().clone()) } - /// Sets `VerificationMethod` public key data. + /// Sets {@link VerificationMethod} public key data. #[wasm_bindgen(js_name = setData)] pub fn set_data(&mut self, data: &WasmMethodData) { *self.0.data_mut() = data.0.clone(); From cbc0f9e9f97d483e4f7734f32978dfd436d4a7c6 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 20 Jul 2023 10:09:21 +0200 Subject: [PATCH 10/11] Improve mod names --- .../jwt_credential_validation/jwt_credential_validator.rs | 3 ++- bindings/wasm/src/resolver/mod.rs | 6 +++--- .../resolver/{constructor_input.rs => resolver_config.rs} | 3 +-- .../src/resolver/{type_definitions.rs => resolver_types.rs} | 0 bindings/wasm/src/resolver/wasm_resolver.rs | 6 +++--- bindings/wasm/src/storage/wasm_storage.rs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) rename bindings/wasm/src/resolver/{constructor_input.rs => resolver_config.rs} (96%) rename bindings/wasm/src/resolver/{type_definitions.rs => resolver_types.rs} (100%) diff --git a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs index cf8873b583..eecad85afd 100644 --- a/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs +++ b/bindings/wasm/src/credential/jwt_credential_validation/jwt_credential_validator.rs @@ -44,7 +44,8 @@ impl WasmJwtCredentialValidator { WasmJwtCredentialValidator(JwtCredentialValidator::with_signature_verifier(signature_verifier)) } - /// Decodes and validates a {@link Credential} issued as a JWS. A {@link DecodedJwtCredential} is returned upon success. + /// Decodes and validates a {@link Credential} issued as a JWS. A {@link DecodedJwtCredential} is returned upon + /// success. /// /// The following properties are validated according to `options`: /// - the issuer's signature on the JWS, diff --git a/bindings/wasm/src/resolver/mod.rs b/bindings/wasm/src/resolver/mod.rs index 88bf771a05..28d622e26f 100644 --- a/bindings/wasm/src/resolver/mod.rs +++ b/bindings/wasm/src/resolver/mod.rs @@ -1,8 +1,8 @@ // Copyright 2020-2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -mod constructor_input; -mod type_definitions; +mod resolver_config; +mod resolver_types; mod wasm_resolver; -pub use type_definitions::*; +pub use resolver_types::*; diff --git a/bindings/wasm/src/resolver/constructor_input.rs b/bindings/wasm/src/resolver/resolver_config.rs similarity index 96% rename from bindings/wasm/src/resolver/constructor_input.rs rename to bindings/wasm/src/resolver/resolver_config.rs index dfadf81db9..a5ff9a74de 100644 --- a/bindings/wasm/src/resolver/constructor_input.rs +++ b/bindings/wasm/src/resolver/resolver_config.rs @@ -30,10 +30,9 @@ const HANDLERS: &'static str = #[wasm_bindgen(typescript_custom_section)] const TS_RESOLVER_CONFIG: &'static str = r#" /** - * Configurations for the new {@link Resolver}. + * Configurations for the {@link Resolver}. */ export type ResolverConfig = { - /** * Client for resolving DIDs of the iota method. */ diff --git a/bindings/wasm/src/resolver/type_definitions.rs b/bindings/wasm/src/resolver/resolver_types.rs similarity index 100% rename from bindings/wasm/src/resolver/type_definitions.rs rename to bindings/wasm/src/resolver/resolver_types.rs diff --git a/bindings/wasm/src/resolver/wasm_resolver.rs b/bindings/wasm/src/resolver/wasm_resolver.rs index 9c15857aec..ff0782b2f2 100644 --- a/bindings/wasm/src/resolver/wasm_resolver.rs +++ b/bindings/wasm/src/resolver/wasm_resolver.rs @@ -23,11 +23,11 @@ use crate::iota::IotaDocumentLock; use crate::iota::WasmIotaDID; use crate::iota::WasmIotaDocument; use crate::iota::WasmIotaIdentityClient; -use crate::resolver::constructor_input::MapResolutionHandler; -use crate::resolver::constructor_input::ResolverConfig; +use crate::resolver::resolver_config::MapResolutionHandler; +use crate::resolver::resolver_config::ResolverConfig; use crate::resolver::PromiseArrayIToCoreDocument; -use super::type_definitions::PromiseIToCoreDocument; +use super::resolver_types::PromiseIToCoreDocument; use crate::error::Result; use crate::error::WasmResult; use wasm_bindgen::prelude::*; diff --git a/bindings/wasm/src/storage/wasm_storage.rs b/bindings/wasm/src/storage/wasm_storage.rs index eaf821334b..e23bb62dac 100644 --- a/bindings/wasm/src/storage/wasm_storage.rs +++ b/bindings/wasm/src/storage/wasm_storage.rs @@ -18,7 +18,7 @@ pub struct WasmStorage(pub(crate) Rc); #[wasm_bindgen(js_class = Storage)] impl WasmStorage { - /// Constructs a new `Storage`. + /// Constructs a new {@link Storage}. #[wasm_bindgen(constructor)] #[allow(non_snake_case)] pub fn new(jwkStorage: WasmJwkStorage, keyIdStorage: WasmKeyIdStorage) -> WasmStorage { From 6dd629ac9eca9552b4307f216f6fb7f29096b090 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 20 Jul 2023 13:03:52 +0200 Subject: [PATCH 11/11] Add hidden lifetime params --- bindings/wasm/src/error.rs | 2 +- bindings/wasm/src/iota/identity_client.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/wasm/src/error.rs b/bindings/wasm/src/error.rs index 9dcf89b65b..c433edea79 100644 --- a/bindings/wasm/src/error.rs +++ b/bindings/wasm/src/error.rs @@ -26,7 +26,7 @@ pub fn wasm_error<'a, E>(error: E) -> JsValue where E: Into>, { - let wasm_err: WasmError = error.into(); + let wasm_err: WasmError<'_> = error.into(); JsValue::from(wasm_err) } diff --git a/bindings/wasm/src/iota/identity_client.rs b/bindings/wasm/src/iota/identity_client.rs index 4b9bb8e4cf..d83e37b558 100644 --- a/bindings/wasm/src/iota/identity_client.rs +++ b/bindings/wasm/src/iota/identity_client.rs @@ -44,7 +44,7 @@ impl IotaIdentityClient for WasmIotaIdentityClient { let result: JsValueResult = JsFuture::from(promise).await.into(); let tuple: js_sys::Array = js_sys::Array::from(&result.to_iota_core_error()?); - let mut iter: js_sys::ArrayIter = tuple.iter(); + let mut iter: js_sys::ArrayIter<'_> = tuple.iter(); let output_id: OutputId = iter .next()