From 89335208f8f390462893fa44bb3fcde66e4d0cff Mon Sep 17 00:00:00 2001
From: Enrico Marconi (&self, serializer: S) -> std::prelude::v1::Result
A custom verification method data format.
+A method agnostic DID Url.
Controls validation behaviour when checking whether or not a credential has been revoked by its
credentialStatus
.
Skip all status checks.
Purpose of a StatusList2021.
-Declares when validation should return if an error occurs.
The holder is not required to have any kind of relationship to any credential subject.
Purpose of a StatusList2021.
+Initializes the console error panic hook for better error messages
+string
Encode the given bytes in url-safe base64.
This function does not check whether alg = EdDSA
in the protected header. Callers are expected to assert this
prior to calling the function.
Initializes the console error panic hook for better error messages
-any
|
+
+
+## CustomMethodData
+A custom verification method data format.
+
+**Kind**: global class
+
+
+### new CustomMethodData(name, data)
+
+| Param | Type |
+| --- | --- |
+| name | string
|
+| data | any
|
+
## DIDUrl
@@ -4343,7 +4361,7 @@ Supported verification method data formats.
* [MethodData](#MethodData)
* _instance_
- * [.tryBlockchainAccountId()](#MethodData+tryBlockchainAccountId) ⇒ string
+ * [.tryCustom()](#MethodData+tryCustom) ⇒ [CustomMethodData
](#CustomMethodData)
* [.tryDecode()](#MethodData+tryDecode) ⇒ Uint8Array
* [.tryPublicKeyJwk()](#MethodData+tryPublicKeyJwk) ⇒ [Jwk
](#Jwk)
* [.toJSON()](#MethodData+toJSON) ⇒ any
@@ -4352,13 +4370,13 @@ 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)
+ * [.newCustom(name, data)](#MethodData.newCustom) ⇒ [MethodData
](#MethodData)
* [.fromJSON(json)](#MethodData.fromJSON) ⇒ [MethodData
](#MethodData)
-
+
-### methodData.tryBlockchainAccountId() ⇒ string
-Returns the wrapped blockchain account id if the format is `BlockchainAccountId`.
+### methodData.tryCustom() ⇒ [CustomMethodData
](#CustomMethodData)
+Returns the wrapped custom method data format is `Custom`.
**Kind**: instance method of [MethodData
](#MethodData)
@@ -4427,16 +4445,17 @@ An error is thrown if the given `key` contains any private components.
| --- | --- |
| key | [Jwk
](#Jwk) |
-
+
-### MethodData.newBlockchainAccountId(data) ⇒ [MethodData
](#MethodData)
+### MethodData.newCustom(name, data) ⇒ [MethodData
](#MethodData)
Creates a new [MethodData](#MethodData) variant in CAIP-10 format.
**Kind**: static method of [MethodData
](#MethodData)
| Param | Type |
| --- | --- |
-| data | string
|
+| name | string
|
+| data | any
|
@@ -5032,11 +5051,9 @@ Representation of an SD-JWT of the format
* [.jwt()](#SdJwt+jwt) ⇒ string
* [.disclosures()](#SdJwt+disclosures) ⇒ Array.<string>
* [.keyBindingJwt()](#SdJwt+keyBindingJwt) ⇒ string
\| undefined
- * [.toJSON()](#SdJwt+toJSON) ⇒ any
* [.clone()](#SdJwt+clone) ⇒ [SdJwt
](#SdJwt)
* _static_
* [.parse(sd_jwt)](#SdJwt.parse) ⇒ [SdJwt
](#SdJwt)
- * [.fromJSON(json)](#SdJwt.fromJSON) ⇒ [SdJwt
](#SdJwt)
@@ -5079,12 +5096,6 @@ The disclosures part.
### sdJwt.keyBindingJwt() ⇒ string
\| undefined
The optional key binding JWT.
-**Kind**: instance method of [SdJwt
](#SdJwt)
-
-
-### sdJwt.toJSON() ⇒ any
-Serializes this to a JSON object.
-
**Kind**: instance method of [SdJwt
](#SdJwt)
@@ -5106,17 +5117,6 @@ Returns `DeserializationError` if parsing fails.
| --- | --- |
| sd_jwt | string
|
-
-
-### SdJwt.fromJSON(json) ⇒ [SdJwt
](#SdJwt)
-Deserializes an instance from a JSON object.
-
-**Kind**: static method of [SdJwt
](#SdJwt)
-
-| Param | Type |
-| --- | --- |
-| json | any
|
-
## SdJwtCredentialValidator
@@ -6159,6 +6159,10 @@ Deserializes an instance from a JSON object.
| --- | --- |
| json | any
|
+
+
+## CredentialStatus
+**Kind**: global variable
## StatusCheck
@@ -6189,24 +6193,6 @@ Validate the status if supported, skip any unsupported
## SkipAll
Skip all status checks.
-**Kind**: global variable
-
-
-## StatusPurpose
-Purpose of a [StatusList2021](#StatusList2021).
-
-**Kind**: global variable
-
-
-## MethodRelationship
-**Kind**: global variable
-
-
-## CredentialStatus
-**Kind**: global variable
-
-
-## StateMetadataEncoding
**Kind**: global variable
@@ -6253,6 +6239,26 @@ The holder must match the subject only for credentials where the [`nonTransferab
The holder is not required to have any kind of relationship to any credential subject.
**Kind**: global variable
+
+
+## StatusPurpose
+Purpose of a [StatusList2021](#StatusList2021).
+
+**Kind**: global variable
+
+
+## MethodRelationship
+**Kind**: global variable
+
+
+## StateMetadataEncoding
+**Kind**: global variable
+
+
+## start()
+Initializes the console error panic hook for better error messages
+
+**Kind**: global function
## encodeB64(data) ⇒ string
@@ -6297,9 +6303,3 @@ prior to calling the function.
| decodedSignature | Uint8Array
|
| publicKey | [Jwk
](#Jwk) |
-
-
-## start()
-Initializes the console error panic hook for better error messages
-
-**Kind**: global function
diff --git a/bindings/wasm/src/verification/wasm_method_data.rs b/bindings/wasm/src/verification/wasm_method_data.rs
index 809eab22e4..ae63ec970f 100644
--- a/bindings/wasm/src/verification/wasm_method_data.rs
+++ b/bindings/wasm/src/verification/wasm_method_data.rs
@@ -1,6 +1,7 @@
// Copyright 2020-2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
+use identity_iota::verification::CustomMethodData;
use identity_iota::verification::MethodData;
use wasm_bindgen::prelude::*;
@@ -46,21 +47,22 @@ impl WasmMethodData {
}
/// 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))
+ #[wasm_bindgen(js_name = newCustom)]
+ pub fn new_custom(name: String, data: JsValue) -> ResultDeclares how credential subjects must relate to the presentation holder.
+See also the Subject-Holder Relationship section of the specification.
+The holder must always match the subject on all credentials, regardless of their nonTransferable
property.
+This variant is the default.
The holder must match the subject only for credentials where the nonTransferable
property is true
.
The holder is not required to have any kind of relationship to any credential subject.
+Purpose of a StatusList2021.
+Controls validation behaviour when checking whether or not a credential has been revoked by its @@ -218,26 +237,7 @@ working with storage backed DID documents.
Return after the first error occurs.
Declares how credential subjects must relate to the presentation holder.
-See also the Subject-Holder Relationship section of the specification.
-The holder must always match the subject on all credentials, regardless of their nonTransferable
property.
-This variant is the default.
The holder must match the subject only for credentials where the nonTransferable
property is true
.
The holder is not required to have any kind of relationship to any credential subject.
-Purpose of a StatusList2021.
-MethodType
](#MethodType)
* [.X25519KeyAgreementKey2019()](#MethodType.X25519KeyAgreementKey2019) ⇒ [MethodType
](#MethodType)
* [.JsonWebKey()](#MethodType.JsonWebKey) ⇒ [MethodType
](#MethodType)
- * [.EcdsaSecp256k1RecoverySignature2020()](#MethodType.EcdsaSecp256k1RecoverySignature2020) ⇒ [MethodType
](#MethodType)
+ * [.custom(type_)](#MethodType.custom) ⇒ [MethodType
](#MethodType)
* [.fromJSON(json)](#MethodType.fromJSON) ⇒ [MethodType
](#MethodType)
@@ -4644,12 +4644,17 @@ A verification method for use with JWT verification as prescribed by the [Jwk](#
in the `publicKeyJwk` entry.
**Kind**: static method of [MethodType
](#MethodType)
-
+
-### MethodType.EcdsaSecp256k1RecoverySignature2020() ⇒ [MethodType
](#MethodType)
-The `EcdsaSecp256k1RecoverySignature2020` method type.
+### MethodType.custom(type_) ⇒ [MethodType
](#MethodType)
+A custom method.
**Kind**: static method of [MethodType
](#MethodType)
+
+| Param | Type |
+| --- | --- |
+| type_ | string
|
+
### MethodType.fromJSON(json) ⇒ [MethodType
](#MethodType)
@@ -6159,9 +6164,46 @@ Deserializes an instance from a JSON object.
| --- | --- |
| json | any
|
-
+
+
+## MethodRelationship
+**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
+
+
+## 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
+
+
+## StatusPurpose
+Purpose of a [StatusList2021](#StatusList2021).
+
+**Kind**: global variable
+
+
+## StateMetadataEncoding
**Kind**: global variable
@@ -6212,46 +6254,9 @@ 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.
-
-**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.
-
-**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
-
-
-## StatusPurpose
-Purpose of a [StatusList2021](#StatusList2021).
-
-**Kind**: global variable
-
-
-## MethodRelationship
-**Kind**: global variable
-
+
-## StateMetadataEncoding
+## CredentialStatus
**Kind**: global variable
diff --git a/bindings/wasm/src/verification/wasm_method_type.rs b/bindings/wasm/src/verification/wasm_method_type.rs
index 850ba08890..4b7d297a62 100644
--- a/bindings/wasm/src/verification/wasm_method_type.rs
+++ b/bindings/wasm/src/verification/wasm_method_type.rs
@@ -27,10 +27,9 @@ 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)
+ /// A custom method.
+ pub fn custom(type_: String) -> WasmMethodType {
+ WasmMethodType(MethodType::custom(type_))
}
/// Returns the {@link MethodType} as a string.
diff --git a/identity_verification/src/verification_method/method_type.rs b/identity_verification/src/verification_method/method_type.rs
index aa80ef4580..ae3877948d 100644
--- a/identity_verification/src/verification_method/method_type.rs
+++ b/identity_verification/src/verification_method/method_type.rs
@@ -12,7 +12,6 @@ use crate::error::Result;
const ED25519_VERIFICATION_KEY_2018_STR: &str = "Ed25519VerificationKey2018";
const X25519_KEY_AGREEMENT_KEY_2019_STR: &str = "X25519KeyAgreementKey2019";
const JSON_WEB_KEY_METHOD_TYPE: &str = "JsonWebKey";
-const ECDSA_SECP256K1_RECOVERY_SIGNATURE_2020_STR: &str = "EcdsaSecp256k1RecoverySignature2020";
/// verification method types.
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
@@ -26,9 +25,10 @@ impl MethodType {
/// A verification method for use with JWT verification as prescribed by the [`Jwk`](::identity_jose::jwk::Jwk)
/// in the [`publicKeyJwk`](crate::MethodData::PublicKeyJwk) entry.
pub const JSON_WEB_KEY: Self = Self(Cow::Borrowed(JSON_WEB_KEY_METHOD_TYPE));
- /// The `EcdsaSecp256k1RecoverySignature2020` method type.
- pub const ECDSA_SECP256K1_RECOVERY_SIGNATURE_2020: Self =
- Self(Cow::Borrowed(ECDSA_SECP256K1_RECOVERY_SIGNATURE_2020_STR));
+ /// Construct a custom method type.
+ pub fn custom(type_: impl AsRefPurpose of a StatusList2021.
+Declares how credential subjects must relate to the presentation holder.
See also the Subject-Holder Relationship section of the specification.
@@ -206,11 +207,21 @@ This variant is the default.The holder is not required to have any kind of relationship to any credential subject.
Purpose of a StatusList2021.
-Declares when validation should return if an error occurs.
+Return all errors that occur during validation.
+Return after the first error occurs.
+Controls validation behaviour when checking whether or not a credential has been revoked by its
credentialStatus
.
Skip all status checks.
Declares when validation should return if an error occurs.
-Return all errors that occur during validation.
-Return after the first error occurs.
-Initializes the console error panic hook for better error messages
-string
Encode the given bytes in url-safe base64.
-Uint8Array
Decode the given url-safe base64-encoded slice into its raw bytes.
-Verify a JWS signature secured with the EdDSA
algorithm and curve Ed25519
.
This function is useful when one is composing a IJwsVerifier
that delegates
@@ -261,6 +252,15 @@ This variant is the default.
This function does not check whether alg = EdDSA
in the protected header. Callers are expected to assert this
prior to calling the function.
string
Encode the given bytes in url-safe base64.
+Uint8Array
Decode the given url-safe base64-encoded slice into its raw bytes.
+Initializes the console error panic hook for better error messages
+CustomMethodData
](#CustomMethodData)
+ * [.toJSON()](#CustomMethodData+toJSON) ⇒ any
+ * _static_
+ * [.fromJSON(json)](#CustomMethodData.fromJSON) ⇒ [CustomMethodData
](#CustomMethodData)
+
### new CustomMethodData(name, data)
@@ -1156,6 +1165,29 @@ A custom verification method data format.
| name | string
|
| data | any
|
+
+
+### customMethodData.clone() ⇒ [CustomMethodData
](#CustomMethodData)
+Deep clones the object.
+
+**Kind**: instance method of [CustomMethodData
](#CustomMethodData)
+
+
+### customMethodData.toJSON() ⇒ any
+Serializes this to a JSON object.
+
+**Kind**: instance method of [CustomMethodData
](#CustomMethodData)
+
+
+### CustomMethodData.fromJSON(json) ⇒ [CustomMethodData
](#CustomMethodData)
+Deserializes an instance from a JSON object.
+
+**Kind**: static method of [CustomMethodData
](#CustomMethodData)
+
+| Param | Type |
+| --- | --- |
+| json | any
|
+
## DIDUrl
@@ -4448,7 +4480,7 @@ An error is thrown if the given `key` contains any private components.
### MethodData.newCustom(name, data) ⇒ [MethodData
](#MethodData)
-Creates a new [MethodData](#MethodData) variant in CAIP-10 format.
+Creates a new custom [MethodData](#MethodData).
**Kind**: static method of [MethodData
](#MethodData)
@@ -6164,9 +6196,11 @@ Deserializes an instance from a JSON object.
| --- | --- |
| json | any
|
-
+
+
+## StatusPurpose
+Purpose of a [StatusList2021](#StatusList2021).
-## MethodRelationship
**Kind**: global variable
@@ -6195,15 +6229,35 @@ The holder must match the subject only for credentials where the [`nonTransferab
The holder is not required to have any kind of relationship to any credential subject.
**Kind**: global variable
-
+
-## StatusPurpose
-Purpose of a [StatusList2021](#StatusList2021).
+## StateMetadataEncoding
+**Kind**: global variable
+
+
+## FailFast
+Declares when validation should return if an error occurs.
**Kind**: global variable
-
+
+
+## AllErrors
+Return all errors that occur during validation.
-## StateMetadataEncoding
+**Kind**: global variable
+
+
+## FirstError
+Return after the first error occurs.
+
+**Kind**: global variable
+
+
+## MethodRelationship
+**Kind**: global variable
+
+
+## CredentialStatus
**Kind**: global variable
@@ -6236,34 +6290,28 @@ Validate the status if supported, skip any unsupported
Skip all status checks.
**Kind**: global variable
-
-
-## FailFast
-Declares when validation should return if an error occurs.
-
-**Kind**: global variable
-
+
-## AllErrors
-Return all errors that occur during validation.
+## verifyEd25519(alg, signingInput, decodedSignature, publicKey)
+Verify a JWS signature secured with the `EdDSA` algorithm and curve `Ed25519`.
-**Kind**: global variable
-
+This function is useful when one is composing a `IJwsVerifier` that delegates
+`EdDSA` verification with curve `Ed25519` to this function.
-## FirstError
-Return after the first error occurs.
+# Warning
-**Kind**: global variable
-
+This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this
+prior to calling the function.
-## CredentialStatus
-**Kind**: global variable
-
+**Kind**: global function
-## start()
-Initializes the console error panic hook for better error messages
+| Param | Type |
+| --- | --- |
+| alg | JwsAlgorithm
|
+| signingInput | Uint8Array
|
+| decodedSignature | Uint8Array
|
+| publicKey | [Jwk
](#Jwk) |
-**Kind**: global function
## encodeB64(data) ⇒ string
@@ -6286,25 +6334,9 @@ Decode the given url-safe base64-encoded slice into its raw bytes.
| --- | --- |
| data | Uint8Array
|
-
-
-## verifyEd25519(alg, signingInput, decodedSignature, publicKey)
-Verify a JWS signature secured with the `EdDSA` algorithm and curve `Ed25519`.
-
-This function is useful when one is composing a `IJwsVerifier` that delegates
-`EdDSA` verification with curve `Ed25519` to this function.
-
-# Warning
+
-This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this
-prior to calling the function.
+## start()
+Initializes the console error panic hook for better error messages
**Kind**: global function
-
-| Param | Type |
-| --- | --- |
-| alg | JwsAlgorithm
|
-| signingInput | Uint8Array
|
-| decodedSignature | Uint8Array
|
-| publicKey | [Jwk
](#Jwk) |
-
diff --git a/identity_verification/src/verification_method/method.rs b/identity_verification/src/verification_method/method.rs
index 5baa36f1b6..8c48e06893 100644
--- a/identity_verification/src/verification_method/method.rs
+++ b/identity_verification/src/verification_method/method.rs
@@ -20,6 +20,7 @@ use crate::verification_method::MethodBuilder;
use crate::verification_method::MethodData;
use crate::verification_method::MethodRef;
use crate::verification_method::MethodType;
+use crate::CustomMethodData;
use identity_did::CoreDID;
use identity_did::DIDUrl;
use identity_did::DID;
@@ -247,8 +248,8 @@ impl KeyComparable for VerificationMethod {
}
// Horrible workaround for a tracked serde issue https://github.com/serde-rs/serde/issues/2200. Serde doesn't "consume"
-// the input when deserializing flattened enums (MethodData in this case) cousing duplication of data (in this case
-// it ends up in the properties object). This workaround simply remove the duplication.
+// the input when deserializing flattened enums (MethodData in this case) causing duplication of data (in this case
+// it ends up in the properties object). This workaround simply removes the duplication.
#[derive(Deserialize)]
struct _VerificationMethod {
#[serde(deserialize_with = "deserialize_id_with_fragment")]
@@ -271,9 +272,13 @@ impl From<_VerificationMethod> for VerificationMethod {
data,
mut properties,
} = value;
- let data_json = serde_json::to_value(&data).unwrap();
- let data_type = data_json.as_object().unwrap().into_iter().next().unwrap().0;
- properties.remove(data_type);
+ let key = match &data {
+ MethodData::PublicKeyBase58(_) => "publicKeyBase58",
+ MethodData::PublicKeyJwk(_) => "publicKeyJwk",
+ MethodData::PublicKeyMultibase(_) => "publicKeyMultibase",
+ MethodData::Custom(CustomMethodData { name, .. }) => name.as_str(),
+ };
+ properties.remove(key);
VerificationMethod {
id,