diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index 8eede47999..73ff47d4c6 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -204,6 +204,24 @@ working with storage backed DID documents.

SkipAll

Skip all status checks.

+
StatusPurpose
+

Purpose of a StatusList2021.

+
+
MethodRelationship
+
+
CredentialStatus
+
+
StateMetadataEncoding
+
+
FailFast
+

Declares when validation should return if an error occurs.

+
+
AllErrors
+

Return all errors that occur during validation.

+
+
FirstError
+

Return after the first error occurs.

+
SubjectHolderRelationship

Declares how credential subjects must relate to the presentation holder.

See also the Subject-Holder Relationship section of the specification.

@@ -218,24 +236,6 @@ This variant is the default.

Any

The holder is not required to have any kind of relationship to any credential subject.

-
StateMetadataEncoding
-
-
MethodRelationship
-
-
FailFast
-

Declares when validation should return if an error occurs.

-
-
AllErrors
-

Return all errors that occur during validation.

-
-
FirstError
-

Return after the first error occurs.

-
-
CredentialStatus
-
-
StatusPurpose
-

Purpose of a StatusList2021.

-
## Functions @@ -4343,6 +4343,7 @@ Supported verification method data formats. * [MethodData](#MethodData) * _instance_ + * [.tryBlockchainAccountId()](#MethodData+tryBlockchainAccountId) ⇒ string * [.tryDecode()](#MethodData+tryDecode) ⇒ Uint8Array * [.tryPublicKeyJwk()](#MethodData+tryPublicKeyJwk) ⇒ [Jwk](#Jwk) * [.toJSON()](#MethodData+toJSON) ⇒ any @@ -4351,8 +4352,15 @@ Supported verification method data formats. * [.newBase58(data)](#MethodData.newBase58) ⇒ [MethodData](#MethodData) * [.newMultibase(data)](#MethodData.newMultibase) ⇒ [MethodData](#MethodData) * [.newJwk(key)](#MethodData.newJwk) ⇒ [MethodData](#MethodData) + * [.newBlockchainAccountId(data)](#MethodData.newBlockchainAccountId) ⇒ [MethodData](#MethodData) * [.fromJSON(json)](#MethodData.fromJSON) ⇒ [MethodData](#MethodData) + + +### methodData.tryBlockchainAccountId() ⇒ string +Returns the wrapped blockchain account id if the format is `BlockchainAccountId`. + +**Kind**: instance method of [MethodData](#MethodData) ### methodData.tryDecode() ⇒ Uint8Array @@ -4419,6 +4427,17 @@ An error is thrown if the given `key` contains any private components. | --- | --- | | key | [Jwk](#Jwk) | + + +### MethodData.newBlockchainAccountId(data) ⇒ [MethodData](#MethodData) +Creates a new [MethodData](#MethodData) variant in CAIP-10 format. + +**Kind**: static method of [MethodData](#MethodData) + +| Param | Type | +| --- | --- | +| data | string | + ### MethodData.fromJSON(json) ⇒ [MethodData](#MethodData) @@ -4570,6 +4589,7 @@ Supported verification method types. * [.Ed25519VerificationKey2018()](#MethodType.Ed25519VerificationKey2018) ⇒ [MethodType](#MethodType) * [.X25519KeyAgreementKey2019()](#MethodType.X25519KeyAgreementKey2019) ⇒ [MethodType](#MethodType) * [.JsonWebKey()](#MethodType.JsonWebKey) ⇒ [MethodType](#MethodType) + * [.EcdsaSecp256k1RecoverySignature2020()](#MethodType.EcdsaSecp256k1RecoverySignature2020) ⇒ [MethodType](#MethodType) * [.fromJSON(json)](#MethodType.fromJSON) ⇒ [MethodType](#MethodType) @@ -4604,6 +4624,12 @@ Deep clones the object. A verification method for use with JWT verification as prescribed by the [Jwk](#Jwk) in the `publicKeyJwk` entry. +**Kind**: static method of [MethodType](#MethodType) + + +### MethodType.EcdsaSecp256k1RecoverySignature2020() ⇒ [MethodType](#MethodType) +The `EcdsaSecp256k1RecoverySignature2020` method type. + **Kind**: static method of [MethodType](#MethodType) @@ -6164,41 +6190,24 @@ Validate the status if supported, skip any unsupported Skip all status checks. **Kind**: global variable - - -## SubjectHolderRelationship -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. - -**Kind**: global variable - + -## AlwaysSubject -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. +## StatusPurpose +Purpose of a [StatusList2021](#StatusList2021). **Kind**: global variable - - -## SubjectOnNonTransferable -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`. + +## MethodRelationship **Kind**: global variable - - -## Any -The holder is not required to have any kind of relationship to any credential subject. + +## CredentialStatus **Kind**: global variable ## StateMetadataEncoding **Kind**: global variable - - -## MethodRelationship -**Kind**: global variable ## FailFast @@ -6217,14 +6226,31 @@ Return all errors that occur during validation. Return after the first error occurs. **Kind**: global variable - + + +## SubjectHolderRelationship +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. -## CredentialStatus **Kind**: global variable - + -## StatusPurpose -Purpose of a [StatusList2021](#StatusList2021). +## AlwaysSubject +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. + +**Kind**: global variable + + +## SubjectOnNonTransferable +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`. + +**Kind**: global variable + + +## Any +The holder is not required to have any kind of relationship to any credential subject. **Kind**: global variable diff --git a/bindings/wasm/src/verification/wasm_method_data.rs b/bindings/wasm/src/verification/wasm_method_data.rs index 5bba4aa5a9..809eab22e4 100644 --- a/bindings/wasm/src/verification/wasm_method_data.rs +++ b/bindings/wasm/src/verification/wasm_method_data.rs @@ -45,6 +45,26 @@ impl WasmMethodData { Ok(Self(MethodData::PublicKeyJwk(key.0.clone()))) } + /// Creates a new {@link MethodData} variant in CAIP-10 format. + #[wasm_bindgen(js_name = newBlockchainAccountId)] + pub fn new_blockchain_account_id(data: String) -> Self { + Self(MethodData::new_blockchain_account_id(data)) + } + + /// Returns the wrapped blockchain account id if the format is `BlockchainAccountId`. + #[wasm_bindgen(js_name = tryBlockchainAccountId)] + pub fn try_blockchain_account_id(&self) -> Result { + self + .0 + .blockchain_account_id() + .map(|id| id.to_string()) + .ok_or(WasmError::new( + Cow::Borrowed("MethodDataFormatError"), + Cow::Borrowed("method data format is not BlockchainAccountId"), + )) + .wasm_result() + } + /// Returns a `Uint8Array` containing the decoded bytes of the {@link MethodData}. /// /// This is generally a public key identified by a {@link MethodData} value. diff --git a/bindings/wasm/src/verification/wasm_method_type.rs b/bindings/wasm/src/verification/wasm_method_type.rs index 9fb1fff660..850ba08890 100644 --- a/bindings/wasm/src/verification/wasm_method_type.rs +++ b/bindings/wasm/src/verification/wasm_method_type.rs @@ -27,6 +27,12 @@ impl WasmMethodType { WasmMethodType(MethodType::JSON_WEB_KEY) } + /// The `EcdsaSecp256k1RecoverySignature2020` method type. + #[wasm_bindgen(js_name = EcdsaSecp256k1RecoverySignature2020)] + pub fn ecdsa_secp256k1_recovery_signature_2020() -> WasmMethodType { + WasmMethodType(MethodType::ECDSA_SECP256K1_RECOVERY_SIGNATURE_2020) + } + /// Returns the {@link MethodType} as a string. #[allow(clippy::inherent_to_string)] #[wasm_bindgen(js_name = toString)] diff --git a/identity_verification/src/verification_method/material.rs b/identity_verification/src/verification_method/material.rs index 4d5f5775aa..23a4843cc6 100644 --- a/identity_verification/src/verification_method/material.rs +++ b/identity_verification/src/verification_method/material.rs @@ -39,6 +39,11 @@ impl MethodData { Self::PublicKeyMultibase(BaseEncoding::encode_multibase(&data, None)) } + /// Verification Material in CAIP-10 format. + pub fn new_blockchain_account_id(data: String) -> Self { + Self::BlockchainAccountId(data) + } + /// Returns a `Vec` containing the decoded bytes of the `MethodData`. /// /// This is generally a public key identified by a `MethodType` value. @@ -71,6 +76,15 @@ impl MethodData { pub fn try_public_key_jwk(&self) -> Result<&Jwk> { self.public_key_jwk().ok_or(Error::NotPublicKeyJwk) } + + /// Returns the wrapped Blockchain Account Id if the format is [`MethodData::BlockchainAccountId`]. + pub fn blockchain_account_id(&self) -> Option<&str> { + if let Self::BlockchainAccountId(id) = self { + Some(id) + } else { + None + } + } } impl Debug for MethodData {