From cec3efdf60a62465454cc8f3538e4ba98310b5b7 Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Thu, 9 Jun 2022 16:42:56 +0200
Subject: [PATCH 01/20] Started creating crate description
---
identity-credential/README.md | 43 ++++++++++++++++++-
.../src/credential/credential.rs | 2 +-
identity-credential/tests/readme_tests.rs | 42 ++++++++++++++++++
3 files changed, 85 insertions(+), 2 deletions(-)
create mode 100644 identity-credential/tests/readme_tests.rs
diff --git a/identity-credential/README.md b/identity-credential/README.md
index f70148d684..8b50e417c8 100644
--- a/identity-credential/README.md
+++ b/identity-credential/README.md
@@ -1 +1,42 @@
-Types and traits for working with Verifiable Credentials/Presentations.
+# Iota Identity: Credentials
+
+This crate contains types representing [Verifiable credentials](https://www.w3.org/TR/vc-data-model/#dfn-credential) and [Verifiable presentations](https://www.w3.org/TR/vc-data-model/#dfn-verifiable-presentations). An overview of Verifiable Credentials and how they can be used with the Iota Identity Framework can be found in [the Iota Identity Framework Wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview).
+
+
+# Example
+Constructing a `Credential` using the `CredentialBuilder`.
+
+```rust
+ use identity_credential::credential::{Credential, CredentialBuilder, Subject, Issuer};
+ use serde_json::json;
+ use serde_json::Value;
+
+ // Construct a `Subject` from json
+ let json_subject: Value = json!({
+ "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+ "degree": {
+ "type": "BachelorDegree",
+ "name": "Bachelor of Science and Arts"
+ }
+ });
+ let subject: Subject = serde_json::from_value(json_subject).unwrap();
+
+ // Construct an `Issuer` from json
+ let json_issuer: Value = json!({
+ "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
+ "name": "Example University"
+ });
+
+ let issuer: Issuer = serde_json::from_value(json_issuer).unwrap();
+
+ let credential: Credential = CredentialBuilder::default()
+ .context(Url::parse("https://www.w3.org/2018/credentials/examples/v1").unwrap())
+ .id(Url::parse("http://example.edu/credentials/3732").unwrap())
+ .type_("UniversityDegreeCredential")
+ .subject(subject)
+ .issuer(issuer)
+ .issuance_date(Timestamp::parse("2010-01-01T00:00:00Z").unwrap())
+ .build()
+ .unwrap();
+
+```
diff --git a/identity-credential/src/credential/credential.rs b/identity-credential/src/credential/credential.rs
index 2d9a94809b..beaf7600b2 100644
--- a/identity-credential/src/credential/credential.rs
+++ b/identity-credential/src/credential/credential.rs
@@ -40,7 +40,7 @@ pub struct Credential {
/// The JSON-LD context(s) applicable to the `Credential`.
#[serde(rename = "@context")]
pub context: OneOrMany,
- /// A unique `URI` referencing the subject of the `Credential`.
+ /// A unique `URI` that may be used to identify the credential.
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option,
/// One or more URIs defining the type of the `Credential`.
diff --git a/identity-credential/tests/readme_tests.rs b/identity-credential/tests/readme_tests.rs
new file mode 100644
index 0000000000..aff14f4da8
--- /dev/null
+++ b/identity-credential/tests/readme_tests.rs
@@ -0,0 +1,42 @@
+// Copyright 2020-2022 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+use identity_core::common::Timestamp;
+use identity_core::common::Url;
+use identity_credential::credential::Credential;
+use identity_credential::credential::CredentialBuilder;
+use identity_credential::credential::Issuer;
+use identity_credential::credential::Subject;
+use serde_json::json;
+use serde_json::Value;
+
+#[test]
+fn doc_test() {
+ // Construct a `Subject` from json
+ let json_subject: Value = json!({
+ "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+ "degree": {
+ "type": "BachelorDegree",
+ "name": "Bachelor of Science and Arts"
+ }
+ });
+ let subject: Subject = serde_json::from_value(json_subject).unwrap();
+
+ // Construct an `Issuer` from json
+ let json_issuer: Value = json!({
+ "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
+ "name": "Example University"
+ });
+
+ let issuer: Issuer = serde_json::from_value(json_issuer).unwrap();
+
+ let credential: Credential = CredentialBuilder::default()
+ .context(Url::parse("https://www.w3.org/2018/credentials/examples/v1").unwrap())
+ .id(Url::parse("http://example.edu/credentials/3732").unwrap())
+ .type_("UniversityDegreeCredential")
+ .subject(subject)
+ .issuer(issuer)
+ .issuance_date(Timestamp::parse("2010-01-01T00:00:00Z").unwrap())
+ .build()
+ .unwrap();
+}
From db2b6aab7c442bd3c2c8cc7a720e47c53a640b2b Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Fri, 10 Jun 2022 12:02:11 +0200
Subject: [PATCH 02/20] Updated readme
---
identity-credential/README.md | 6 +++++-
identity-credential/tests/readme_tests.rs | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/identity-credential/README.md b/identity-credential/README.md
index 8b50e417c8..7935a37137 100644
--- a/identity-credential/README.md
+++ b/identity-credential/README.md
@@ -1,6 +1,6 @@
# Iota Identity: Credentials
-This crate contains types representing [Verifiable credentials](https://www.w3.org/TR/vc-data-model/#dfn-credential) and [Verifiable presentations](https://www.w3.org/TR/vc-data-model/#dfn-verifiable-presentations). An overview of Verifiable Credentials and how they can be used with the Iota Identity Framework can be found in [the Iota Identity Framework Wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview).
+This crate contains types representing *credentials* and *presentations* defined in the [W3C VC-Data model]((https://www.w3.org/TR/vc-data-model/). An overview of these concepts and how to work with them in the context of the Iota Identity Framework can be found [in the wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview).
# Example
@@ -40,3 +40,7 @@ Constructing a `Credential` using the `CredentialBuilder`.
.unwrap();
```
+# Important
+Although the `CredentialBuilder` generates a `Credential` it cannot be considered a *verifiable credential* until it has been signed by the issuer. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full example explaining how to create a credential with the corresponding issuer's signature.
+
+
diff --git a/identity-credential/tests/readme_tests.rs b/identity-credential/tests/readme_tests.rs
index aff14f4da8..9ea357193a 100644
--- a/identity-credential/tests/readme_tests.rs
+++ b/identity-credential/tests/readme_tests.rs
@@ -7,11 +7,12 @@ use identity_credential::credential::Credential;
use identity_credential::credential::CredentialBuilder;
use identity_credential::credential::Issuer;
use identity_credential::credential::Subject;
+use identity_credential::presentation::Presentation;
use serde_json::json;
use serde_json::Value;
#[test]
-fn doc_test() {
+fn doc_test_build_credential() {
// Construct a `Subject` from json
let json_subject: Value = json!({
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
From 5915210af536cf0d7dde93492136854b752e7d6c Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Fri, 10 Jun 2022 14:19:26 +0200
Subject: [PATCH 03/20] updated and moved README.md
---
identity-credential/src/README.md | 80 +++++++++++++++++++
.../src/presentation/presentation.rs | 2 +-
identity-credential/tests/readme_tests.rs | 13 +++
3 files changed, 94 insertions(+), 1 deletion(-)
create mode 100644 identity-credential/src/README.md
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
new file mode 100644
index 0000000000..d5ccabadf9
--- /dev/null
+++ b/identity-credential/src/README.md
@@ -0,0 +1,80 @@
+# Iota Identity: Credentials
+
+This crate contains types representing *credentials* and *presentations* defined in the [W3C VC-Data model]((https://www.w3.org/TR/vc-data-model/). An overview of these concepts and how to create *verifiable* credentials and presentations from the building blocks in this crate is explained in [the project's wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview).
+
+## Using the builders
+This crate enables creation of [`Credential`s](crate::credential::Credential) and [`Presentation`s](crate::presentation::Presentation) using the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html).
+### Example
+Constructing a [`Credential`](crate::credential::Credential) using the [`CredentialBuilder`](crate::credential::CredentialBuilder).
+
+```rust
+use identity_credential::credential::{Credential, CredentialBuilder, Subject, Issuer};
+use serde_json::json;
+use serde_json::Value;
+
+// Construct a `Subject` from json
+let json_subject: Value = json!({
+ "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+ "degree": {
+ "type": "BachelorDegree",
+ "name": "Bachelor of Science and Arts"
+ }
+});
+let subject: Subject = serde_json::from_value(json_subject).unwrap();
+
+// Construct an `Issuer` from json
+let json_issuer: Value = json!({
+ "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
+ "name": "Example University"
+});
+
+let issuer: Issuer = serde_json::from_value(json_issuer).unwrap();
+
+let credential: Credential = CredentialBuilder::default()
+ .context(Url::parse("https://www.w3.org/2018/credentials/examples/v1").unwrap())
+ .id(Url::parse("http://example.edu/credentials/3732").unwrap())
+ .type_("UniversityDegreeCredential")
+ .subject(subject)
+ .issuer(issuer)
+ .issuance_date(Timestamp::parse("2010-01-01T00:00:00Z").unwrap())
+ .build()
+ .unwrap();
+
+```
+#### Important
+Although the `CredentialBuilder` generates a `Credential` it cannot be considered a *verifiable credential* until it has been signed by the issuer. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full example explaining how to create a credential with the corresponding issuer's signature.
+
+### Example
+Constructing a [`Presentation`](crate::presentation::Presentation) using the [`PresentationBuilder`](crate::presentation::PresentationBuilder).
+
+```rust
+use identity_credential::credential::Credential;
+use identity_credential::presentation::Presentation;
+use identity_credential::presentation::PresentationBuilder;
+use identity_core::common::Url;
+
+// Build a presentation for the given holder and iterator of credentials
+fn build_presentation(credentials: impl Iterator- , holder: Url) -> Presentation {
+ let presentation_builder: PresentationBuilder = PresentationBuilder::default();
+ credentials
+ .fold(
+ presentation_builder,
+ |builder: PresentationBuilder, credential: Credential| builder.credential(credential),
+ )
+ .holder(holder)
+ .build()
+ .unwrap()
+}
+```
+#### Important
+A `Presentation` constructed from a `PresentationBuilder` is not automatically a *verifiable presentation*. In order to obtain a verifiable presentation the holder must sign the presentation. All `Credential`s contained in the presentation must also be signed by their respective issuers. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vp.rs) for a full example explaining how to create a verifiable presentation.
+
+## Credentials and Presentations from JSON
+The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde) hence one can use (for instance) the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
+
+### Example
+Deserializing a `Credential` from JSON.
+
+
+### Example
+Deserializing a `Presentation` from JSON.
diff --git a/identity-credential/src/presentation/presentation.rs b/identity-credential/src/presentation/presentation.rs
index 1eeaa791c6..1b555a2a94 100644
--- a/identity-credential/src/presentation/presentation.rs
+++ b/identity-credential/src/presentation/presentation.rs
@@ -31,7 +31,7 @@ pub struct Presentation {
/// The JSON-LD context(s) applicable to the `Presentation`.
#[serde(rename = "@context")]
pub context: OneOrMany,
- /// A unique `URI` referencing the subject of the `Presentation`.
+ /// A unique `URI` that may be used to identify the `Presentation`.
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option,
/// One or more URIs defining the type of the `Presentation`.
diff --git a/identity-credential/tests/readme_tests.rs b/identity-credential/tests/readme_tests.rs
index 9ea357193a..8baff710c3 100644
--- a/identity-credential/tests/readme_tests.rs
+++ b/identity-credential/tests/readme_tests.rs
@@ -8,6 +8,7 @@ use identity_credential::credential::CredentialBuilder;
use identity_credential::credential::Issuer;
use identity_credential::credential::Subject;
use identity_credential::presentation::Presentation;
+use identity_credential::presentation::PresentationBuilder;
use serde_json::json;
use serde_json::Value;
@@ -41,3 +42,15 @@ fn doc_test_build_credential() {
.build()
.unwrap();
}
+
+fn build_presentation(credentials: impl Iterator
- , holder: Url) -> Presentation {
+ let presentation_builder: PresentationBuilder = PresentationBuilder::default();
+ credentials
+ .fold(
+ presentation_builder,
+ |builder: PresentationBuilder, credential: Credential| builder.credential(credential),
+ )
+ .holder(holder)
+ .build()
+ .unwrap()
+}
From 5fa939a7080216860b773edb1d31dc09910fa90b Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Fri, 10 Jun 2022 15:41:15 +0200
Subject: [PATCH 04/20] Updated crate level documentation
---
identity-credential/src/README.md | 99 +++++++++++++++++++++--
identity-credential/src/lib.rs | 4 +-
identity-credential/tests/readme_tests.rs | 56 -------------
3 files changed, 93 insertions(+), 66 deletions(-)
delete mode 100644 identity-credential/tests/readme_tests.rs
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index d5ccabadf9..0efa525ef6 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -1,17 +1,24 @@
-# Iota Identity: Credentials
+Iota Identity Credentials
+===
-This crate contains types representing *credentials* and *presentations* defined in the [W3C VC-Data model]((https://www.w3.org/TR/vc-data-model/). An overview of these concepts and how to create *verifiable* credentials and presentations from the building blocks in this crate is explained in [the project's wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview).
+This crate contains types representing *credentials* and *presentations* defined in the [W3C VC-Data model](https://www.w3.org/TR/vc-data-model/). The [Iota Identity Framework Wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview) gives a conceptual explanation of *verifiable credentials* and *verifiable presentations* and demonstrates how they may be constructed from the building blocks provided by this crate.
## Using the builders
-This crate enables creation of [`Credential`s](crate::credential::Credential) and [`Presentation`s](crate::presentation::Presentation) using the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html).
+This crate enables creation of [`Credentials`](crate::credential::Credential) and [`Presentations`](crate::presentation::Presentation) using the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html).
### Example
Constructing a [`Credential`](crate::credential::Credential) using the [`CredentialBuilder`](crate::credential::CredentialBuilder).
```rust
-use identity_credential::credential::{Credential, CredentialBuilder, Subject, Issuer};
+use identity_credential::credential::Credential;
+use identity_credential::credential::CredentialBuilder;
+use identity_credential::credential::Subject;
+use identity_credential::credential::Issuer;
+use identity_core::common::Url;
+use identity_core::common::Timestamp;
use serde_json::json;
use serde_json::Value;
+
// Construct a `Subject` from json
let json_subject: Value = json!({
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
@@ -70,11 +77,89 @@ fn build_presentation(credentials: impl Iterator
- , holder: Url
A `Presentation` constructed from a `PresentationBuilder` is not automatically a *verifiable presentation*. In order to obtain a verifiable presentation the holder must sign the presentation. All `Credential`s contained in the presentation must also be signed by their respective issuers. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vp.rs) for a full example explaining how to create a verifiable presentation.
## Credentials and Presentations from JSON
-The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde) hence one can use (for instance) the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
+The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
### Example
-Deserializing a `Credential` from JSON.
+Deserializing a (verifiable) `Credential` from JSON.
+```rust
+use identity_credential::credential::Credential;
+use serde_json::json;
+
+let credential_json: &'static str = r#"{
+ "@context": [
+ "https://www.w3.org/2018/credentials/v1",
+ "https://www.w3.org/2018/credentials/examples/v1"
+ ],
+ "id": "http://example.gov/credentials/3732",
+ "type": ["VerifiableCredential", "UniversityDegreeCredential"],
+ "issuer": "https://example.edu",
+ "issuanceDate": "2017-06-18T21:19:00Z",
+ "credentialSubject": {
+ "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+ "degree": {
+ "type": "BachelorDegree",
+ "name": "Bachelor of Science in Mechanical Engineering"
+ }
+ },
+ "proof": {
+ "type": "RsaSignature2018",
+ "created": "2017-06-18T21:19:10Z",
+ "proofPurpose": "assertionMethod",
+ "verificationMethod": "https://example.com/jdoe/keys/1",
+ "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
+ }
+}"#;
+let credential: Credential = serde_json::from_str(credential_json).unwrap();
+
+```
### Example
-Deserializing a `Presentation` from JSON.
+Deserializing a (verifiable) `Presentation` from JSON.
+
+```rust
+use identity_credential::presentation::Presentation;
+use serde_json;
+
+let presentation_json: &'static str = r#"{
+ "@context": [
+ "https://www.w3.org/2018/credentials/v1",
+ "https://www.w3.org/2018/credentials/examples/v1"
+ ],
+ "id": "urn:uuid:3978344f-8596-4c3a-a978-8fcaba3903c5",
+ "type": ["VerifiablePresentation", "CredentialManagerPresentation"],
+ "verifiableCredential": [{
+ "@context": [
+ "https://www.w3.org/2018/credentials/v1",
+ "https://www.w3.org/2018/credentials/examples/v1"
+ ],
+ "id": "http://example.edu/credentials/3732",
+ "type": ["VerifiableCredential", "UniversityDegreeCredential"],
+ "issuer": "https://example.edu/issuers/14",
+ "issuanceDate": "2010-01-01T19:23:24Z",
+ "credentialSubject": {
+ "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+ "degree": {
+ "type": "BachelorDegree",
+ "name": "Bachelor of Science in Mechanical Engineering"
+ }
+ },
+ "proof": {
+ "type": "RsaSignature2018",
+ "created": "2017-06-18T21:19:10Z",
+ "proofPurpose": "assertionMethod",
+ "verificationMethod": "https://example.com/jdoe/keys/1",
+ "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
+ }
+ }],
+ "proof": {
+ "type": "RsaSignature2018",
+ "created": "2017-06-18T21:19:10Z",
+ "proofPurpose": "assertionMethod",
+ "verificationMethod": "https://example.com/jdoe/keys/1",
+ "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
+ }
+ }"#;
+
+let presentation: Presentation = serde_json::from_str(presentation_json).unwrap();
+ ```
\ No newline at end of file
diff --git a/identity-credential/src/lib.rs b/identity-credential/src/lib.rs
index 7a29ed9472..e9ba890d6f 100644
--- a/identity-credential/src/lib.rs
+++ b/identity-credential/src/lib.rs
@@ -2,9 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
-#![cfg_attr(docsrs, feature(doc_cfg, extended_key_value_attributes))]
-#![cfg_attr(docsrs, cfg_attr(docsrs, doc = include_str!("../README.md")))]
-#![cfg_attr(not(docsrs), doc = "")]
+#![doc = include_str!("README.md")]
#![allow(clippy::upper_case_acronyms)]
#![warn(
rust_2018_idioms,
diff --git a/identity-credential/tests/readme_tests.rs b/identity-credential/tests/readme_tests.rs
deleted file mode 100644
index 8baff710c3..0000000000
--- a/identity-credential/tests/readme_tests.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2020-2022 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-use identity_core::common::Timestamp;
-use identity_core::common::Url;
-use identity_credential::credential::Credential;
-use identity_credential::credential::CredentialBuilder;
-use identity_credential::credential::Issuer;
-use identity_credential::credential::Subject;
-use identity_credential::presentation::Presentation;
-use identity_credential::presentation::PresentationBuilder;
-use serde_json::json;
-use serde_json::Value;
-
-#[test]
-fn doc_test_build_credential() {
- // Construct a `Subject` from json
- let json_subject: Value = json!({
- "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
- "degree": {
- "type": "BachelorDegree",
- "name": "Bachelor of Science and Arts"
- }
- });
- let subject: Subject = serde_json::from_value(json_subject).unwrap();
-
- // Construct an `Issuer` from json
- let json_issuer: Value = json!({
- "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
- "name": "Example University"
- });
-
- let issuer: Issuer = serde_json::from_value(json_issuer).unwrap();
-
- let credential: Credential = CredentialBuilder::default()
- .context(Url::parse("https://www.w3.org/2018/credentials/examples/v1").unwrap())
- .id(Url::parse("http://example.edu/credentials/3732").unwrap())
- .type_("UniversityDegreeCredential")
- .subject(subject)
- .issuer(issuer)
- .issuance_date(Timestamp::parse("2010-01-01T00:00:00Z").unwrap())
- .build()
- .unwrap();
-}
-
-fn build_presentation(credentials: impl Iterator
- , holder: Url) -> Presentation {
- let presentation_builder: PresentationBuilder = PresentationBuilder::default();
- credentials
- .fold(
- presentation_builder,
- |builder: PresentationBuilder, credential: Credential| builder.credential(credential),
- )
- .holder(holder)
- .build()
- .unwrap()
-}
From 19cd4aab4388aa38a634e16b51af432cea4b87e3 Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:29:13 +0200
Subject: [PATCH 05/20] Update identity-credential/src/credential/credential.rs
Co-authored-by: cycraig
---
identity-credential/src/credential/credential.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/credential/credential.rs b/identity-credential/src/credential/credential.rs
index beaf7600b2..8298d86327 100644
--- a/identity-credential/src/credential/credential.rs
+++ b/identity-credential/src/credential/credential.rs
@@ -40,7 +40,7 @@ pub struct Credential {
/// The JSON-LD context(s) applicable to the `Credential`.
#[serde(rename = "@context")]
pub context: OneOrMany,
- /// A unique `URI` that may be used to identify the credential.
+ /// A unique `URI` that may be used to identify the `Credential`.
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option,
/// One or more URIs defining the type of the `Credential`.
From 7526d6e431dda834cc2fca2d3e520af6e0318423 Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:45:24 +0200
Subject: [PATCH 06/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 0efa525ef6..70f6b5bb62 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -1,7 +1,9 @@
Iota Identity Credentials
===
-This crate contains types representing *credentials* and *presentations* defined in the [W3C VC-Data model](https://www.w3.org/TR/vc-data-model/). The [Iota Identity Framework Wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview) gives a conceptual explanation of *verifiable credentials* and *verifiable presentations* and demonstrates how they may be constructed from the building blocks provided by this crate.
+This crate contains types representing verifiable credentials and verifiable presentations as defined in the [W3C Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/).
+
+The [IOTA Identity Framework Wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview) provides an overview of verifiable credentials and demonstrates how they may be constructed using the building blocks from this crate.
## Using the builders
This crate enables creation of [`Credentials`](crate::credential::Credential) and [`Presentations`](crate::presentation::Presentation) using the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html).
From e1c491735fbf1ea67fc0d4e3e744a35d3f1edf7a Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:45:58 +0200
Subject: [PATCH 07/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 70f6b5bb62..28596285c9 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -5,9 +5,10 @@ This crate contains types representing verifiable credentials and verifiable pre
The [IOTA Identity Framework Wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview) provides an overview of verifiable credentials and demonstrates how they may be constructed using the building blocks from this crate.
-## Using the builders
-This crate enables creation of [`Credentials`](crate::credential::Credential) and [`Presentations`](crate::presentation::Presentation) using the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html).
-### Example
+## Construction
+This crate follows the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html) for the creation of [`Credentials`](crate::credential::Credential) and [`Presentations`](crate::presentation::Presentation).
+
+### Example - Credential
Constructing a [`Credential`](crate::credential::Credential) using the [`CredentialBuilder`](crate::credential::CredentialBuilder).
```rust
From 4856cf7064bc4f1c736333503b851d13ac902486 Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:46:17 +0200
Subject: [PATCH 08/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 28596285c9..74a095ee41 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -118,7 +118,7 @@ let credential: Credential = serde_json::from_str(credential_json).unwrap();
```
### Example
-Deserializing a (verifiable) `Presentation` from JSON.
+Deserializing a `Presentation` from JSON.
```rust
use identity_credential::presentation::Presentation;
From 2d50d090775b6a684f31eb31a93ab13f0310152f Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:46:29 +0200
Subject: [PATCH 09/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 74a095ee41..5679787bab 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -1,4 +1,4 @@
-Iota Identity Credentials
+IOTA Identity - Credentials
===
This crate contains types representing verifiable credentials and verifiable presentations as defined in the [W3C Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/).
From 4792e4315e853017ccca650aee5ac946cd0ad8e0 Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:46:50 +0200
Subject: [PATCH 10/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 5679787bab..d5c0d38704 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -52,7 +52,8 @@ let credential: Credential = CredentialBuilder::default()
```
#### Important
-Although the `CredentialBuilder` generates a `Credential` it cannot be considered a *verifiable credential* until it has been signed by the issuer. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full example explaining how to create a credential with the corresponding issuer's signature.
+
+The generated `Credential` is not verifiable until it has been signed by the issuer's DID Document. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full demonstration of issuing and signing a verifiable credential.
### Example
Constructing a [`Presentation`](crate::presentation::Presentation) using the [`PresentationBuilder`](crate::presentation::PresentationBuilder).
From 0cba4c06148d17b7f2d40fab7c75c0e3ec0a9d1a Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:48:52 +0200
Subject: [PATCH 11/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index d5c0d38704..807d8cd0a6 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -55,7 +55,7 @@ let credential: Credential = CredentialBuilder::default()
The generated `Credential` is not verifiable until it has been signed by the issuer's DID Document. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full demonstration of issuing and signing a verifiable credential.
-### Example
+### Example - Presentation
Constructing a [`Presentation`](crate::presentation::Presentation) using the [`PresentationBuilder`](crate::presentation::PresentationBuilder).
```rust
From 168a80f4ef429fb6b6e77a36b83d90daaefea076 Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:49:20 +0200
Subject: [PATCH 12/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 807d8cd0a6..21a843850a 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -78,7 +78,7 @@ fn build_presentation(credentials: impl Iterator
- , holder: Url
}
```
#### Important
-A `Presentation` constructed from a `PresentationBuilder` is not automatically a *verifiable presentation*. In order to obtain a verifiable presentation the holder must sign the presentation. All `Credential`s contained in the presentation must also be signed by their respective issuers. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vp.rs) for a full example explaining how to create a verifiable presentation.
+A `Presentation` is not verifiable until signed by the holder's DID Document. All `Credentials` contained in the presentation must also be signed by their respective issuers. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vp.rs) for a full demonstration of constructing and validating a verifiable presentation.
## Credentials and Presentations from JSON
The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
From 8db33e81b840baf063a4149691e11d54234645fd Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:49:33 +0200
Subject: [PATCH 13/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 21a843850a..04a3c73850 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -84,7 +84,7 @@ A `Presentation` is not verifiable until signed by the holder's DID Document. Al
The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
### Example
-Deserializing a (verifiable) `Credential` from JSON.
+Deserializing a `Credential` from JSON.
```rust
use identity_credential::credential::Credential;
use serde_json::json;
From 37bd07064849657b66172ad233566dcce6a8d2fe Mon Sep 17 00:00:00 2001
From: "Oliver E. Anderson"
Date: Mon, 13 Jun 2022 09:50:21 +0200
Subject: [PATCH 14/20] Update identity-credential/src/README.md
Co-authored-by: cycraig
---
identity-credential/src/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index 04a3c73850..bd23d90919 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -80,7 +80,7 @@ fn build_presentation(credentials: impl Iterator
- , holder: Url
#### Important
A `Presentation` is not verifiable until signed by the holder's DID Document. All `Credentials` contained in the presentation must also be signed by their respective issuers. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vp.rs) for a full demonstration of constructing and validating a verifiable presentation.
-## Credentials and Presentations from JSON
+## JSON Serialization
The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
### Example
From 219dc9a4d6b6126b8a6ead7425bc1cc66c48f5d0 Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Mon, 13 Jun 2022 10:31:08 +0200
Subject: [PATCH 15/20] Updated wasm credential docs. Changed example in
credential README
---
bindings/wasm/docs/api-reference.md | 28 ++--
bindings/wasm/src/credential/credential.rs | 2 +-
.../wasm/src/credential/credential_builder.rs | 2 +-
bindings/wasm/src/credential/presentation.rs | 2 +-
.../src/credential/presentation_builder.rs | 2 +-
identity-credential/README.md | 46 -------
identity-credential/src/README.md | 124 ++++++++----------
7 files changed, 76 insertions(+), 130 deletions(-)
delete mode 100644 identity-credential/README.md
diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md
index 14baa5b0da..eee09e98f9 100644
--- a/bindings/wasm/docs/api-reference.md
+++ b/bindings/wasm/docs/api-reference.md
@@ -202,6 +202,7 @@ publishing to the Tangle.
**Kind**: global class
* [Account](#Account)
+ * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒
Promise.<void>
* [.did()](#Account+did) ⇒ [DID
](#DID)
* [.autopublish()](#Account+autopublish) ⇒ boolean
* [.autosave()](#Account+autosave) ⇒ [AutoSave
](#AutoSave)
@@ -224,7 +225,17 @@ publishing to the Tangle.
* [.createService(options)](#Account+createService) ⇒ Promise.<void>
* [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ Promise.<void>
* [.createMethod(options)](#Account+createMethod) ⇒ Promise.<void>
- * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
+
+
+
+### account.detachMethodRelationships(options) ⇒ Promise.<void>
+Detaches the given relationship from the given method, if the method exists.
+
+**Kind**: instance method of [Account
](#Account)
+
+| Param | Type |
+| --- | --- |
+| options | DetachMethodRelationshipOptions
|
@@ -471,17 +482,6 @@ Adds a new verification method to the DID document.
| --- | --- |
| options | CreateMethodOptions
|
-
-
-### account.detachMethodRelationships(options) ⇒ Promise.<void>
-Detaches the given relationship from the given method, if the method exists.
-
-**Kind**: instance method of [Account
](#Account)
-
-| Param | Type |
-| --- | --- |
-| options | DetachMethodRelationshipOptions
|
-
## AccountBuilder
@@ -929,7 +929,7 @@ Returns a copy of the JSON-LD context(s) applicable to the `Credential`.
### credential.id() ⇒ string
\| undefined
-Returns a copy of the unique `URI` referencing the subject of the `Credential`.
+Returns a copy of the unique `URI` identifying the `Credential` .
**Kind**: instance method of [Credential
](#Credential)
@@ -3330,7 +3330,7 @@ Returns a copy of the JSON-LD context(s) applicable to the `Presentation`.
### presentation.id() ⇒ string
\| undefined
-Returns a copy of the unique `URI` of the `Presentation`.
+Returns a copy of the unique `URI` identifying the `Presentation`.
**Kind**: instance method of [Presentation
](#Presentation)
diff --git a/bindings/wasm/src/credential/credential.rs b/bindings/wasm/src/credential/credential.rs
index 2a3f381b8f..55d217c67c 100644
--- a/bindings/wasm/src/credential/credential.rs
+++ b/bindings/wasm/src/credential/credential.rs
@@ -65,7 +65,7 @@ impl WasmCredential {
.map(|value| value.unchecked_into::())
}
- /// Returns a copy of the unique `URI` referencing the subject of the `Credential`.
+ /// Returns a copy of the unique `URI` identifying the `Credential` .
#[wasm_bindgen]
pub fn id(&self) -> Option {
self.0.id.as_ref().map(|url| url.to_string())
diff --git a/bindings/wasm/src/credential/credential_builder.rs b/bindings/wasm/src/credential/credential_builder.rs
index 38095d6f9e..5c983d9168 100644
--- a/bindings/wasm/src/credential/credential_builder.rs
+++ b/bindings/wasm/src/credential/credential_builder.rs
@@ -117,7 +117,7 @@ struct ICredentialHelper {
/// The JSON-LD context(s) applicable to the `Credential`.
#[typescript(type = "string | Record | Array>")]
context: Option>,
- /// A unique URI referencing the subject of the `Credential`.
+ /// A unique URI that may be used to identify the `Credential`.
#[typescript(type = "string")]
id: Option,
/// One or more URIs defining the type of the `Credential`. Contains the base context by default.
diff --git a/bindings/wasm/src/credential/presentation.rs b/bindings/wasm/src/credential/presentation.rs
index 215859febe..8e642e5717 100644
--- a/bindings/wasm/src/credential/presentation.rs
+++ b/bindings/wasm/src/credential/presentation.rs
@@ -67,7 +67,7 @@ impl WasmPresentation {
.map(|value| value.unchecked_into::())
}
- /// Returns a copy of the unique `URI` of the `Presentation`.
+ /// Returns a copy of the unique `URI` identifying the `Presentation`.
#[wasm_bindgen]
pub fn id(&self) -> Option {
self.0.id.as_ref().map(|url| url.to_string())
diff --git a/bindings/wasm/src/credential/presentation_builder.rs b/bindings/wasm/src/credential/presentation_builder.rs
index 8966e1a163..71156a879b 100644
--- a/bindings/wasm/src/credential/presentation_builder.rs
+++ b/bindings/wasm/src/credential/presentation_builder.rs
@@ -81,7 +81,7 @@ struct IPresentationHelper {
/// The JSON-LD context(s) applicable to the `Presentation`.
#[typescript(type = "string | Record | Array>")]
context: Option>,
- /// A unique URI of the `Presentation`.
+ /// A unique URI that may be used to identify the `Presentation`.
#[typescript(type = "string")]
id: Option,
/// One or more URIs defining the type of the `Presentation`. Contains the base context by default.
diff --git a/identity-credential/README.md b/identity-credential/README.md
deleted file mode 100644
index 7935a37137..0000000000
--- a/identity-credential/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Iota Identity: Credentials
-
-This crate contains types representing *credentials* and *presentations* defined in the [W3C VC-Data model]((https://www.w3.org/TR/vc-data-model/). An overview of these concepts and how to work with them in the context of the Iota Identity Framework can be found [in the wiki](https://wiki.iota.org/identity.rs/concepts/verifiable_credentials/overview).
-
-
-# Example
-Constructing a `Credential` using the `CredentialBuilder`.
-
-```rust
- use identity_credential::credential::{Credential, CredentialBuilder, Subject, Issuer};
- use serde_json::json;
- use serde_json::Value;
-
- // Construct a `Subject` from json
- let json_subject: Value = json!({
- "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
- "degree": {
- "type": "BachelorDegree",
- "name": "Bachelor of Science and Arts"
- }
- });
- let subject: Subject = serde_json::from_value(json_subject).unwrap();
-
- // Construct an `Issuer` from json
- let json_issuer: Value = json!({
- "id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
- "name": "Example University"
- });
-
- let issuer: Issuer = serde_json::from_value(json_issuer).unwrap();
-
- let credential: Credential = CredentialBuilder::default()
- .context(Url::parse("https://www.w3.org/2018/credentials/examples/v1").unwrap())
- .id(Url::parse("http://example.edu/credentials/3732").unwrap())
- .type_("UniversityDegreeCredential")
- .subject(subject)
- .issuer(issuer)
- .issuance_date(Timestamp::parse("2010-01-01T00:00:00Z").unwrap())
- .build()
- .unwrap();
-
-```
-# Important
-Although the `CredentialBuilder` generates a `Credential` it cannot be considered a *verifiable credential* until it has been signed by the issuer. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full example explaining how to create a credential with the corresponding issuer's signature.
-
-
diff --git a/identity-credential/src/README.md b/identity-credential/src/README.md
index bd23d90919..5f3bd57678 100644
--- a/identity-credential/src/README.md
+++ b/identity-credential/src/README.md
@@ -83,41 +83,6 @@ A `Presentation` is not verifiable until signed by the holder's DID Document. Al
## JSON Serialization
The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
-### Example
-Deserializing a `Credential` from JSON.
-```rust
-use identity_credential::credential::Credential;
-use serde_json::json;
-
-let credential_json: &'static str = r#"{
- "@context": [
- "https://www.w3.org/2018/credentials/v1",
- "https://www.w3.org/2018/credentials/examples/v1"
- ],
- "id": "http://example.gov/credentials/3732",
- "type": ["VerifiableCredential", "UniversityDegreeCredential"],
- "issuer": "https://example.edu",
- "issuanceDate": "2017-06-18T21:19:00Z",
- "credentialSubject": {
- "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
- "degree": {
- "type": "BachelorDegree",
- "name": "Bachelor of Science in Mechanical Engineering"
- }
- },
- "proof": {
- "type": "RsaSignature2018",
- "created": "2017-06-18T21:19:10Z",
- "proofPurpose": "assertionMethod",
- "verificationMethod": "https://example.com/jdoe/keys/1",
- "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
- }
-}"#;
-
-let credential: Credential = serde_json::from_str(credential_json).unwrap();
-
-```
-
### Example
Deserializing a `Presentation` from JSON.
@@ -126,44 +91,71 @@ use identity_credential::presentation::Presentation;
use serde_json;
let presentation_json: &'static str = r#"{
- "@context": [
- "https://www.w3.org/2018/credentials/v1",
- "https://www.w3.org/2018/credentials/examples/v1"
- ],
- "id": "urn:uuid:3978344f-8596-4c3a-a978-8fcaba3903c5",
- "type": ["VerifiablePresentation", "CredentialManagerPresentation"],
- "verifiableCredential": [{
- "@context": [
- "https://www.w3.org/2018/credentials/v1",
- "https://www.w3.org/2018/credentials/examples/v1"
+ "@context": "https://www.w3.org/2018/credentials/v1",
+ "id": "http://example.org/credentials/3732",
+ "type": "VerifiablePresentation",
+ "verifiableCredential": [
+ {
+ "@context": "https://www.w3.org/2018/credentials/v1",
+ "id": "https://example.edu/credentials/3732",
+ "type": [
+ "VerifiableCredential",
+ "UniversityDegreeCredential"
],
- "id": "http://example.edu/credentials/3732",
- "type": ["VerifiableCredential", "UniversityDegreeCredential"],
- "issuer": "https://example.edu/issuers/14",
- "issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
- "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+ "id": "did:iota:4LCrrVYFQkYYn9VPejhebmMhNnCq24pYPao8yvVLwVje",
+ "GPA": "4.0",
"degree": {
- "type": "BachelorDegree",
- "name": "Bachelor of Science in Mechanical Engineering"
- }
+ "name": "Bachelor of Science and Arts",
+ "type": "BachelorDegree"
+ },
+ "name": "Alice"
},
+ "issuer": "did:iota:H3PBNPtLYkVaPpMQVz1R3LeT5zW1Hd6BXQmdtFptaGLR",
+ "issuanceDate": "2019-01-01T00:00:00Z",
+ "expirationDate": "2024-01-01T00:00:00Z",
+ "nonTransferable": true,
"proof": {
- "type": "RsaSignature2018",
- "created": "2017-06-18T21:19:10Z",
- "proofPurpose": "assertionMethod",
- "verificationMethod": "https://example.com/jdoe/keys/1",
- "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
+ "type": "JcsEd25519Signature2020",
+ "verificationMethod": "did:iota:H3PBNPtLYkVaPpMQVz1R3LeT5zW1Hd6BXQmdtFptaGLR#sign-0",
+ "signatureValue": "5H2TSAG3cHnVEt7HZgg6aeYqmzKRQr9BTaP6mgHSE9uH9iLy7pK7TC2A5NHaiiFMGGaY3hJS5WUhfqCW3APxFhSP"
+ }
+ },
+ {
+ "@context": "https://www.w3.org/2018/credentials/v1",
+ "id": "https://example.edu/credentials/3732",
+ "type": [
+ "VerifiableCredential",
+ "UniversityDegreeCredential"
+ ],
+ "credentialSubject": {
+ "id": "did:iota:b5DtNBzvJfz8jrX1FYYxgvHqvsoFofy1hxzPRMM5iH1",
+ "GPA": "4.0",
+ "degree": {
+ "name": "Bachelor of Science and Arts",
+ "type": "BachelorDegree"
+ },
+ "name": "Alice"
+ },
+ "issuer": "did:iota:7RD6LT5aSNuKMLJJYorGzhktpTG2TrxGSLmHnWW1Dbb",
+ "issuanceDate": "2020-01-01T00:00:00Z",
+ "expirationDate": "2023-01-01T00:00:00Z",
+ "proof": {
+ "type": "JcsEd25519Signature2020",
+ "verificationMethod": "did:iota:7RD6LT5aSNuKMLJJYorGzhktpTG2TrxGSLmHnWW1Dbb#sign-0",
+ "signatureValue": "4QYkkDLDCZxfa6mymhGTGvG4NRgzdx5Txst7dM6jtfDpBV3Mif8hWH93RzR2MoVCtMgZf3ed7qoZsqepWkp4x9oU"
}
- }],
- "proof": {
- "type": "RsaSignature2018",
- "created": "2017-06-18T21:19:10Z",
- "proofPurpose": "assertionMethod",
- "verificationMethod": "https://example.com/jdoe/keys/1",
- "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM"
}
- }"#;
+ ],
+ "holder": "did:iota:4LCrrVYFQkYYn9VPejhebmMhNnCq24pYPao8yvVLwVje",
+ "proof": {
+ "type": "JcsEd25519Signature2020",
+ "verificationMethod": "did:iota:4LCrrVYFQkYYn9VPejhebmMhNnCq24pYPao8yvVLwVje#sign-0",
+ "signatureValue": "47YLi81cr8atfiyydTe4o989V8GBWZk6rVtvE5bAydhbd8HCK5c3wrNXRbBDAF8PDUBGGGqn8ZjA3jxGDFpQwGAW",
+ "challenge": "475a7984-1bb5-4c4c-a56f-822bccd46440"
+ }
+}
+"#;
let presentation: Presentation = serde_json::from_str(presentation_json).unwrap();
```
\ No newline at end of file
From ece4a3aa1a5f5a6b5dc86349a8a3558694db27c4 Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Mon, 13 Jun 2022 10:46:26 +0200
Subject: [PATCH 16/20] moved REAMDE
---
identity-credential/{src => }/README.md | 0
identity-credential/src/lib.rs | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename identity-credential/{src => }/README.md (100%)
diff --git a/identity-credential/src/README.md b/identity-credential/README.md
similarity index 100%
rename from identity-credential/src/README.md
rename to identity-credential/README.md
diff --git a/identity-credential/src/lib.rs b/identity-credential/src/lib.rs
index e9ba890d6f..454447edf7 100644
--- a/identity-credential/src/lib.rs
+++ b/identity-credential/src/lib.rs
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
-#![doc = include_str!("README.md")]
+#![doc = include_str!("./../README.md")]
#![allow(clippy::upper_case_acronyms)]
#![warn(
rust_2018_idioms,
From 536224ca6238a06726a6007f69642ab7d71e9bee Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Mon, 13 Jun 2022 10:55:04 +0200
Subject: [PATCH 17/20] resolving merge conflicts
---
bindings/wasm/docs/api-reference.md | 58 +++++++++++++++--------------
1 file changed, 31 insertions(+), 27 deletions(-)
diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md
index eee09e98f9..940d5773ab 100644
--- a/bindings/wasm/docs/api-reference.md
+++ b/bindings/wasm/docs/api-reference.md
@@ -152,8 +152,6 @@ See IVerifierOptions
.
- DIDMessageEncoding
-- MethodRelationship
-
- SubjectHolderRelationship
Declares how credential subjects must relate to the presentation holder during validation.
See PresentationValidationOptions::subject_holder_relationship
.
@@ -181,6 +179,8 @@ This variant is the default used if no other variant is specified when construct
- KeyType
+- MethodRelationship
+
## Functions
@@ -202,7 +202,7 @@ publishing to the Tangle.
**Kind**: global class
* [Account](#Account)
- * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
+ * [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ Promise.<void>
* [.did()](#Account+did) ⇒ [DID
](#DID)
* [.autopublish()](#Account+autopublish) ⇒ boolean
* [.autosave()](#Account+autosave) ⇒ [AutoSave
](#AutoSave)
@@ -223,19 +223,22 @@ publishing to the Tangle.
* [.setAlsoKnownAs(options)](#Account+setAlsoKnownAs) ⇒ Promise.<void>
* [.setController(options)](#Account+setController) ⇒ Promise.<void>
* [.createService(options)](#Account+createService) ⇒ Promise.<void>
- * [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ Promise.<void>
* [.createMethod(options)](#Account+createMethod) ⇒ Promise.<void>
+ * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
-
+
-### account.detachMethodRelationships(options) ⇒ Promise.<void>
-Detaches the given relationship from the given method, if the method exists.
+### account.attachMethodRelationships(options) ⇒ Promise.<void>
+Attach one or more verification relationships to a method.
+
+Note: the method must exist and be in the set of verification methods;
+it cannot be an embedded method.
**Kind**: instance method of [Account
](#Account)
| Param | Type |
| --- | --- |
-| options | DetachMethodRelationshipOptions
|
+| options | AttachMethodRelationshipOptions
|
@@ -457,30 +460,27 @@ Adds a new Service to the DID Document.
| --- | --- |
| options | CreateServiceOptions
|
-
-
-### account.attachMethodRelationships(options) ⇒ Promise.<void>
-Attach one or more verification relationships to a method.
+
-Note: the method must exist and be in the set of verification methods;
-it cannot be an embedded method.
+### account.createMethod(options) ⇒ Promise.<void>
+Adds a new verification method to the DID document.
**Kind**: instance method of [Account
](#Account)
| Param | Type |
| --- | --- |
-| options | AttachMethodRelationshipOptions
|
+| options | CreateMethodOptions
|
-
+
-### account.createMethod(options) ⇒ Promise.<void>
-Adds a new verification method to the DID document.
+### account.detachMethodRelationships(options) ⇒ Promise.<void>
+Detaches the given relationship from the given method, if the method exists.
**Kind**: instance method of [Account
](#Account)
| Param | Type |
| --- | --- |
-| options | CreateMethodOptions
|
+| options | DetachMethodRelationshipOptions
|
@@ -929,7 +929,7 @@ Returns a copy of the JSON-LD context(s) applicable to the `Credential`.
### credential.id() ⇒ string
\| undefined
-Returns a copy of the unique `URI` identifying the `Credential` .
+Returns a copy of the unique `URI` referencing the subject of the `Credential`.
**Kind**: instance method of [Credential
](#Credential)
@@ -1678,7 +1678,7 @@ Deserializes a `DiffMessage` from a JSON object.
* [.properties()](#Document+properties) ⇒ Map.<string, any>
* [.service()](#Document+service) ⇒ [Array.<Service>
](#Service)
* [.insertService(service)](#Document+insertService) ⇒ boolean
- * [.removeService(did)](#Document+removeService)
+ * [.removeService(did)](#Document+removeService) ⇒ boolean
* [.methods()](#Document+methods) ⇒ [Array.<VerificationMethod>
](#VerificationMethod)
* [.insertMethod(method, scope)](#Document+insertMethod)
* [.removeMethod(did)](#Document+removeMethod)
@@ -1817,6 +1817,8 @@ Return a set of all [Services](#Service) in the document.
### document.insertService(service) ⇒ boolean
Add a new [Service](#Service) to the document.
+Returns `true` if the service was added.
+
**Kind**: instance method of [Document
](#Document)
| Param | Type |
@@ -1825,9 +1827,11 @@ Add a new [Service](#Service) to the document.
-### document.removeService(did)
+### document.removeService(did) ⇒ boolean
Remove a [Service](#Service) identified by the given [DIDUrl](#DIDUrl) from the document.
+Returns `true` if a service was removed.
+
**Kind**: instance method of [Document
](#Document)
| Param | Type |
@@ -3330,7 +3334,7 @@ Returns a copy of the JSON-LD context(s) applicable to the `Presentation`.
### presentation.id() ⇒ string
\| undefined
-Returns a copy of the unique `URI` identifying the `Presentation`.
+Returns a copy of the unique `URI` of the `Presentation`.
**Kind**: instance method of [Presentation
](#Presentation)
@@ -4657,10 +4661,6 @@ This is possible because Ed25519 is birationally equivalent to Curve25519 used b
## DIDMessageEncoding
**Kind**: global variable
-
-
-## MethodRelationship
-**Kind**: global variable
## SubjectHolderRelationship
@@ -4712,6 +4712,10 @@ Return after the first error occurs.
## KeyType
**Kind**: global variable
+
+
+## MethodRelationship
+**Kind**: global variable
## start()
From cfb27b7ad3b2144f47d8304aa3f33aa737e16eed Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Mon, 13 Jun 2022 12:01:30 +0200
Subject: [PATCH 18/20] relative links. Fix merge conflicts
---
bindings/wasm/docs/api-reference.md | 58 ++++++++++++++---------------
identity-credential/Cargo.toml | 4 +-
identity-credential/README.md | 4 +-
3 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md
index 940d5773ab..eee09e98f9 100644
--- a/bindings/wasm/docs/api-reference.md
+++ b/bindings/wasm/docs/api-reference.md
@@ -152,6 +152,8 @@ See IVerifierOptions
.
- DIDMessageEncoding
+- MethodRelationship
+
- SubjectHolderRelationship
Declares how credential subjects must relate to the presentation holder during validation.
See PresentationValidationOptions::subject_holder_relationship
.
@@ -179,8 +181,6 @@ This variant is the default used if no other variant is specified when construct
- KeyType
-- MethodRelationship
-
## Functions
@@ -202,7 +202,7 @@ publishing to the Tangle.
**Kind**: global class
* [Account](#Account)
- * [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ Promise.<void>
+ * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
* [.did()](#Account+did) ⇒ [DID
](#DID)
* [.autopublish()](#Account+autopublish) ⇒ boolean
* [.autosave()](#Account+autosave) ⇒ [AutoSave
](#AutoSave)
@@ -223,22 +223,19 @@ publishing to the Tangle.
* [.setAlsoKnownAs(options)](#Account+setAlsoKnownAs) ⇒ Promise.<void>
* [.setController(options)](#Account+setController) ⇒ Promise.<void>
* [.createService(options)](#Account+createService) ⇒ Promise.<void>
+ * [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ Promise.<void>
* [.createMethod(options)](#Account+createMethod) ⇒ Promise.<void>
- * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
-
-
-### account.attachMethodRelationships(options) ⇒ Promise.<void>
-Attach one or more verification relationships to a method.
+
-Note: the method must exist and be in the set of verification methods;
-it cannot be an embedded method.
+### account.detachMethodRelationships(options) ⇒ Promise.<void>
+Detaches the given relationship from the given method, if the method exists.
**Kind**: instance method of [Account
](#Account)
| Param | Type |
| --- | --- |
-| options | AttachMethodRelationshipOptions
|
+| options | DetachMethodRelationshipOptions
|
@@ -460,27 +457,30 @@ Adds a new Service to the DID Document.
| --- | --- |
| options | CreateServiceOptions
|
-
+
-### account.createMethod(options) ⇒ Promise.<void>
-Adds a new verification method to the DID document.
+### account.attachMethodRelationships(options) ⇒ Promise.<void>
+Attach one or more verification relationships to a method.
+
+Note: the method must exist and be in the set of verification methods;
+it cannot be an embedded method.
**Kind**: instance method of [Account
](#Account)
| Param | Type |
| --- | --- |
-| options | CreateMethodOptions
|
+| options | AttachMethodRelationshipOptions
|
-
+
-### account.detachMethodRelationships(options) ⇒ Promise.<void>
-Detaches the given relationship from the given method, if the method exists.
+### account.createMethod(options) ⇒ Promise.<void>
+Adds a new verification method to the DID document.
**Kind**: instance method of [Account
](#Account)
| Param | Type |
| --- | --- |
-| options | DetachMethodRelationshipOptions
|
+| options | CreateMethodOptions
|
@@ -929,7 +929,7 @@ Returns a copy of the JSON-LD context(s) applicable to the `Credential`.
### credential.id() ⇒ string
\| undefined
-Returns a copy of the unique `URI` referencing the subject of the `Credential`.
+Returns a copy of the unique `URI` identifying the `Credential` .
**Kind**: instance method of [Credential
](#Credential)
@@ -1678,7 +1678,7 @@ Deserializes a `DiffMessage` from a JSON object.
* [.properties()](#Document+properties) ⇒ Map.<string, any>
* [.service()](#Document+service) ⇒ [Array.<Service>
](#Service)
* [.insertService(service)](#Document+insertService) ⇒ boolean
- * [.removeService(did)](#Document+removeService) ⇒ boolean
+ * [.removeService(did)](#Document+removeService)
* [.methods()](#Document+methods) ⇒ [Array.<VerificationMethod>
](#VerificationMethod)
* [.insertMethod(method, scope)](#Document+insertMethod)
* [.removeMethod(did)](#Document+removeMethod)
@@ -1817,8 +1817,6 @@ Return a set of all [Services](#Service) in the document.
### document.insertService(service) ⇒ boolean
Add a new [Service](#Service) to the document.
-Returns `true` if the service was added.
-
**Kind**: instance method of [Document
](#Document)
| Param | Type |
@@ -1827,11 +1825,9 @@ Returns `true` if the service was added.
-### document.removeService(did) ⇒ boolean
+### document.removeService(did)
Remove a [Service](#Service) identified by the given [DIDUrl](#DIDUrl) from the document.
-Returns `true` if a service was removed.
-
**Kind**: instance method of [Document
](#Document)
| Param | Type |
@@ -3334,7 +3330,7 @@ Returns a copy of the JSON-LD context(s) applicable to the `Presentation`.
### presentation.id() ⇒ string
\| undefined
-Returns a copy of the unique `URI` of the `Presentation`.
+Returns a copy of the unique `URI` identifying the `Presentation`.
**Kind**: instance method of [Presentation
](#Presentation)
@@ -4661,6 +4657,10 @@ This is possible because Ed25519 is birationally equivalent to Curve25519 used b
## DIDMessageEncoding
**Kind**: global variable
+
+
+## MethodRelationship
+**Kind**: global variable
## SubjectHolderRelationship
@@ -4712,10 +4712,6 @@ Return after the first error occurs.
## KeyType
**Kind**: global variable
-
-
-## MethodRelationship
-**Kind**: global variable
## start()
diff --git a/identity-credential/Cargo.toml b/identity-credential/Cargo.toml
index dda5e611b1..7e9321c1f4 100644
--- a/identity-credential/Cargo.toml
+++ b/identity-credential/Cargo.toml
@@ -6,9 +6,9 @@ edition = "2021"
homepage = "https://www.iota.org"
keywords = ["iota", "tangle", "identity"]
license = "Apache-2.0"
-readme = "../README.md"
+readme = "./README.md"
repository = "https://github.com/iotaledger/identity.rs"
-description = "An implementation of the Verfiable Credentials standard."
+description = "An implementation of the Verifiable Credentials standard."
[dependencies]
identity-core = { version = "=0.5.0", path = "../identity-core" }
diff --git a/identity-credential/README.md b/identity-credential/README.md
index 5f3bd57678..29058f47f0 100644
--- a/identity-credential/README.md
+++ b/identity-credential/README.md
@@ -53,7 +53,7 @@ let credential: Credential = CredentialBuilder::default()
```
#### Important
-The generated `Credential` is not verifiable until it has been signed by the issuer's DID Document. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vc.rs) for a full demonstration of issuing and signing a verifiable credential.
+The generated `Credential` is not verifiable until it has been signed by the issuer's DID Document. See [this example](./../examples/account/create_vc.rs) for a full demonstration of issuing and signing a verifiable credential.
### Example - Presentation
Constructing a [`Presentation`](crate::presentation::Presentation) using the [`PresentationBuilder`](crate::presentation::PresentationBuilder).
@@ -78,7 +78,7 @@ fn build_presentation(credentials: impl Iterator- , holder: Url
}
```
#### Important
-A `Presentation` is not verifiable until signed by the holder's DID Document. All `Credentials` contained in the presentation must also be signed by their respective issuers. See [this example](https://github.com/iotaledger/identity.rs/blob/support/v0.5/examples/account/create_vp.rs) for a full demonstration of constructing and validating a verifiable presentation.
+A `Presentation` is not verifiable until signed by the holder's DID Document. All `Credentials` contained in the presentation must also be signed by their respective issuers. See [this example](./../examples/account/create_vp.rs) for a full demonstration of constructing and validating a verifiable presentation.
## JSON Serialization
The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
From 3aafcc4cb4c3d1293071a9720ba8140cd6a69c23 Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Mon, 13 Jun 2022 13:20:57 +0200
Subject: [PATCH 19/20] Removed problematic links
---
identity-credential/README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/identity-credential/README.md b/identity-credential/README.md
index 29058f47f0..b7fa06a6d2 100644
--- a/identity-credential/README.md
+++ b/identity-credential/README.md
@@ -53,7 +53,7 @@ let credential: Credential = CredentialBuilder::default()
```
#### Important
-The generated `Credential` is not verifiable until it has been signed by the issuer's DID Document. See [this example](./../examples/account/create_vc.rs) for a full demonstration of issuing and signing a verifiable credential.
+The generated `Credential` is not verifiable until it has been signed by the issuer's DID Document.
### Example - Presentation
Constructing a [`Presentation`](crate::presentation::Presentation) using the [`PresentationBuilder`](crate::presentation::PresentationBuilder).
@@ -78,7 +78,7 @@ fn build_presentation(credentials: impl Iterator
- , holder: Url
}
```
#### Important
-A `Presentation` is not verifiable until signed by the holder's DID Document. All `Credentials` contained in the presentation must also be signed by their respective issuers. See [this example](./../examples/account/create_vp.rs) for a full demonstration of constructing and validating a verifiable presentation.
+A `Presentation` is not verifiable until signed by the holder's DID Document. All `Credentials` contained in the presentation must also be signed by their respective issuers.
## JSON Serialization
The `Credential` and `Presentation` types both implement the [`Serialize`](https://docs.serde.rs/serde/trait.Serialize.html) and [`Deserialize`](https://docs.serde.rs/serde/trait.Deserialize.html) traits from the [`serde` crate](https://crates.io/crates/serde). Hence one can use the [`serde_json` crate](https://crates.io/crates/serde_json) to obtain `Credential`s and `Presentation`s from JSON.
From 3ac657c846b5c8d92fa156e915f11e425c05da25 Mon Sep 17 00:00:00 2001
From: Oliver Anderson
Date: Mon, 13 Jun 2022 17:56:32 +0200
Subject: [PATCH 20/20] regenerated api-reference
---
bindings/wasm/docs/api-reference.md | 60 ++++++++++++++++++-----------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md
index 19d3b7733f..81d4124b69 100644
--- a/bindings/wasm/docs/api-reference.md
+++ b/bindings/wasm/docs/api-reference.md
@@ -222,12 +222,9 @@ publishing to the Tangle.
**Kind**: global class
* [Account](#Account)
-<<<<<<< HEAD
-=======
* [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒
Promise.<void>
* [.createMethod(options)](#Account+createMethod) ⇒ Promise.<void>
* [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
->>>>>>> origin/dev
* [.did()](#Account+did) ⇒ [DID
](#DID)
* [.autopublish()](#Account+autopublish) ⇒ boolean
* [.autosave()](#Account+autosave) ⇒ [AutoSave
](#AutoSave)
@@ -245,17 +242,11 @@ publishing to the Tangle.
* [.unrevokeCredentials(fragment, credentialIndices)](#Account+unrevokeCredentials) ⇒ Promise.<void>
* [.encryptData(plaintext, associated_data, encryption_algorithm, cek_algorithm, public_key)](#Account+encryptData) ⇒ [Promise.<EncryptedData>
](#EncryptedData)
* [.decryptData(data, encryption_algorithm, cek_algorithm, fragment)](#Account+decryptData) ⇒ Promise.<Uint8Array>
+ * [.setAlsoKnownAs(options)](#Account+setAlsoKnownAs) ⇒ Promise.<void>
* [.deleteMethod(options)](#Account+deleteMethod) ⇒ Promise.<void>
* [.deleteService(options)](#Account+deleteService) ⇒ Promise.<void>
- * [.setAlsoKnownAs(options)](#Account+setAlsoKnownAs) ⇒ Promise.<void>
* [.setController(options)](#Account+setController) ⇒ Promise.<void>
* [.createService(options)](#Account+createService) ⇒ Promise.<void>
-<<<<<<< HEAD
- * [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ Promise.<void>
- * [.createMethod(options)](#Account+createMethod) ⇒ Promise.<void>
- * [.detachMethodRelationships(options)](#Account+detachMethodRelationships) ⇒ Promise.<void>
-
-=======
@@ -293,7 +284,6 @@ Detaches the given relationship from the given method, if the method exists.
| --- | --- |
| options | DetachMethodRelationshipOptions
|
->>>>>>> origin/dev
### account.did() ⇒ [DID
](#DID)
@@ -485,6 +475,17 @@ Returns the decrypted text.
| cek_algorithm | [CekAlgorithm
](#CekAlgorithm) |
| fragment | string
|
+
+
+### account.setAlsoKnownAs(options) ⇒ Promise.<void>
+Sets the `alsoKnownAs` property in the DID document.
+
+**Kind**: instance method of [Account
](#Account)
+
+| Param | Type |
+| --- | --- |
+| options | SetAlsoKnownAsOptions
|
+
### account.deleteMethod(options) ⇒ Promise.<void>
@@ -507,17 +508,6 @@ Deletes a Service if it exists.
| --- | --- |
| options | DeleteServiceOptions
|
-
-
-### account.setAlsoKnownAs(options) ⇒ Promise.<void>
-Sets the `alsoKnownAs` property in the DID document.
-
-**Kind**: instance method of [Account
](#Account)
-
-| Param | Type |
-| --- | --- |
-| options | SetAlsoKnownAsOptions
|
-
### account.setController(options) ⇒ Promise.<void>
@@ -735,6 +725,7 @@ Supported algorithms used to determine and potentially encrypt the content encry
* [.toJSON()](#CekAlgorithm+toJSON) ⇒ any
* _static_
* [.EcdhEs(agreement)](#CekAlgorithm.EcdhEs) ⇒ [CekAlgorithm
](#CekAlgorithm)
+ * [.EcdhEsA256Kw(agreement)](#CekAlgorithm.EcdhEsA256Kw) ⇒ [CekAlgorithm
](#CekAlgorithm)
* [.fromJSON(json_value)](#CekAlgorithm.fromJSON) ⇒ [CekAlgorithm
](#CekAlgorithm)
@@ -754,6 +745,17 @@ Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF.
| --- | --- |
| agreement | [AgreementInfo
](#AgreementInfo) |
+
+
+### CekAlgorithm.EcdhEsA256Kw(agreement) ⇒ [CekAlgorithm
](#CekAlgorithm)
+Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF.
+
+**Kind**: static method of [CekAlgorithm
](#CekAlgorithm)
+
+| Param | Type |
+| --- | --- |
+| agreement | [AgreementInfo
](#AgreementInfo) |
+
### CekAlgorithm.fromJSON(json_value) ⇒ [CekAlgorithm
](#CekAlgorithm)
@@ -2687,11 +2689,18 @@ Supported content encryption algorithms.
* [EncryptionAlgorithm](#EncryptionAlgorithm)
* _instance_
+ * [.keyLength()](#EncryptionAlgorithm+keyLength) ⇒ number
* [.toJSON()](#EncryptionAlgorithm+toJSON) ⇒ any
* _static_
* [.A256GCM()](#EncryptionAlgorithm.A256GCM) ⇒ [EncryptionAlgorithm
](#EncryptionAlgorithm)
* [.fromJSON(json_value)](#EncryptionAlgorithm.fromJSON) ⇒ [EncryptionAlgorithm
](#EncryptionAlgorithm)
+
+
+### encryptionAlgorithm.keyLength() ⇒ number
+Returns the length of the cipher's key.
+
+**Kind**: instance method of [EncryptionAlgorithm
](#EncryptionAlgorithm)
### encryptionAlgorithm.toJSON() ⇒ any
@@ -4248,6 +4257,7 @@ A compressed bitmap for managing credential revocation.
* [.isRevoked(index)](#RevocationBitmap+isRevoked) ⇒ boolean
* [.revoke(index)](#RevocationBitmap+revoke) ⇒ boolean
* [.unrevoke(index)](#RevocationBitmap+unrevoke) ⇒ boolean
+ * [.len()](#RevocationBitmap+len) ⇒ number
* [.toEndpoint()](#RevocationBitmap+toEndpoint) ⇒ string
\| Array.<string>
\| Map.<string, Array.<string>>
* _static_
* [.type()](#RevocationBitmap.type) ⇒ string
@@ -4295,6 +4305,12 @@ Returns true if the index was present in the set.
| --- | --- |
| index | number
|
+
+
+### revocationBitmap.len() ⇒ number
+Returns the number of revoked credentials.
+
+**Kind**: instance method of [RevocationBitmap
](#RevocationBitmap)
### revocationBitmap.toEndpoint() ⇒ string
\| Array.<string>
\| Map.<string, Array.<string>>