Skip to content

Commit

Permalink
Add identity-iota-core, identity-account-storage crates (#693)
Browse files Browse the repository at this point in the history
* split iota-identity - add iota-identity-core

* fix tests, fix doc tests, fix imports in indentity-account

* add default impl for coredoc, remove doc clone from resolver

* fix wasm imports

* move bee_message::message to iota_core

* add set_previous_message_id and set_message_id for DiffMessage, move tangle ref back to identity-iota

* split identity-account, add identity-account-core

* move MessageId back to identity-iota

* remove old error variants

* remove nodejs bindings

* fix tom fmt, tests

* add default features false

* change network import

* Replace iota-client dependency with bee-message in identity-iota-core

* Combine message and types modules into tangle

* Remove unnecessary clone

* Improve identity-iota-core errors

* Fix Wasm compilation

* Fix Wasm bindings

* Remove dead code

* Fix bee-message features

* Remove dead code

* Feature-gate stronghold

* Make tokio optional in identity-account-storage

Co-authored-by: Craig Bester <[email protected]>
  • Loading branch information
Henrique Nogara and cycraig authored Mar 14, 2022
1 parent ade82b7 commit 34bb77a
Show file tree
Hide file tree
Showing 125 changed files with 805 additions and 529 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ members = [
"identity",
"identity-comm",
"identity-account",
"identity-account-storage",
"identity-core",
"identity-credential",
"identity-did",
"identity-diff",
"identity-iota",
"identity-iota-core",

"examples",
]
Expand Down
44 changes: 44 additions & 0 deletions bindings/wasm/docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ Serializes a `Credential` object as a JSON object.
<a name="Credential+clone"></a>

### credential.clone() ⇒ [<code>Credential</code>](#Credential)
Deep clones the object.

**Kind**: instance method of [<code>Credential</code>](#Credential)
<a name="Credential.extend"></a>

Expand Down Expand Up @@ -355,6 +357,8 @@ Serializes a `CredentialValidationOptions` as a JSON object.
<a name="CredentialValidationOptions+clone"></a>

### credentialValidationOptions.clone() ⇒ [<code>CredentialValidationOptions</code>](#CredentialValidationOptions)
Deep clones the object.

**Kind**: instance method of [<code>CredentialValidationOptions</code>](#CredentialValidationOptions)
<a name="CredentialValidationOptions.default"></a>

Expand Down Expand Up @@ -583,6 +587,8 @@ Serializes a `DID` as a JSON object.
<a name="DID+clone"></a>

### did.clone() ⇒ [<code>DID</code>](#DID)
Deep clones the object.

**Kind**: instance method of [<code>DID</code>](#DID)
<a name="DID.fromBase58"></a>

Expand Down Expand Up @@ -728,6 +734,8 @@ Serializes a `DIDUrl` as a JSON object.
<a name="DIDUrl+clone"></a>

### didUrl.clone() ⇒ [<code>DIDUrl</code>](#DIDUrl)
Deep clones the object.

**Kind**: instance method of [<code>DIDUrl</code>](#DIDUrl)
<a name="DIDUrl.parse"></a>

Expand Down Expand Up @@ -892,6 +900,8 @@ Serializes a `DiffMessage` as a JSON object.
<a name="DiffMessage+clone"></a>

### diffMessage.clone() ⇒ [<code>DiffMessage</code>](#DiffMessage)
Deep clones the object.

**Kind**: instance method of [<code>DiffMessage</code>](#DiffMessage)
<a name="DiffMessage.fromJSON"></a>

Expand Down Expand Up @@ -1419,6 +1429,8 @@ Serializes a `Document` as a JSON object.
<a name="Document+clone"></a>

### document.clone() ⇒ [<code>Document</code>](#Document)
Deep clones the object.

**Kind**: instance method of [<code>Document</code>](#Document)
<a name="Document.fromVerificationMethod"></a>

Expand Down Expand Up @@ -1545,6 +1557,8 @@ Serializes `DocumentHistory` as a JSON object.
<a name="DocumentHistory+clone"></a>

### documentHistory.clone() ⇒ [<code>DocumentHistory</code>](#DocumentHistory)
Deep clones the object.

**Kind**: instance method of [<code>DocumentHistory</code>](#DocumentHistory)
<a name="DocumentHistory.fromJSON"></a>

Expand Down Expand Up @@ -1596,6 +1610,8 @@ Returns a reference to the `proof`.
<a name="DocumentMetadata+clone"></a>

### documentMetadata.clone() ⇒ [<code>DocumentMetadata</code>](#DocumentMetadata)
Deep clones the object.

**Kind**: instance method of [<code>DocumentMetadata</code>](#DocumentMetadata)
<a name="Duration"></a>

Expand Down Expand Up @@ -1887,6 +1903,8 @@ Serializes a `KeyCollection` object as a JSON object.
<a name="KeyCollection+clone"></a>

### keyCollection.clone() ⇒ [<code>KeyCollection</code>](#KeyCollection)
Deep clones the object.

**Kind**: instance method of [<code>KeyCollection</code>](#KeyCollection)
<a name="KeyCollection.fromJSON"></a>

Expand Down Expand Up @@ -1953,6 +1971,8 @@ Serializes a `KeyPair` object as a JSON object.
<a name="KeyPair+clone"></a>

### keyPair.clone() ⇒ [<code>KeyPair</code>](#KeyPair)
Deep clones the object.

**Kind**: instance method of [<code>KeyPair</code>](#KeyPair)
<a name="KeyPair.fromBase58"></a>

Expand Down Expand Up @@ -2014,6 +2034,8 @@ Serializes a `MethodScope` object as a JSON object.
<a name="MethodScope+clone"></a>

### methodScope.clone() ⇒ [<code>MethodScope</code>](#MethodScope)
Deep clones the object.

**Kind**: instance method of [<code>MethodScope</code>](#MethodScope)
<a name="MethodScope.VerificationMethod"></a>

Expand Down Expand Up @@ -2075,6 +2097,8 @@ Serializes a `MethodType` object as a JSON object.
<a name="MethodType+clone"></a>

### methodType.clone() ⇒ [<code>MethodType</code>](#MethodType)
Deep clones the object.

**Kind**: instance method of [<code>MethodType</code>](#MethodType)
<a name="MethodType.Ed25519VerificationKey2018"></a>

Expand Down Expand Up @@ -2136,6 +2160,8 @@ Serializes a `Network` as a JSON object.
<a name="Network+clone"></a>

### network.clone() ⇒ [<code>Network</code>](#Network)
Deep clones the object.

**Kind**: instance method of [<code>Network</code>](#Network)
<a name="Network.tryFromName"></a>

Expand Down Expand Up @@ -2209,6 +2235,8 @@ Returns a copy of the credentials contained in the presentation.
<a name="Presentation+clone"></a>

### presentation.clone() ⇒ [<code>Presentation</code>](#Presentation)
Deep clones the object.

**Kind**: instance method of [<code>Presentation</code>](#Presentation)
<a name="Presentation.fromJSON"></a>

Expand Down Expand Up @@ -2258,6 +2286,8 @@ Serializes a `PresentationValidationOptions` as a JSON object.
<a name="PresentationValidationOptions+clone"></a>

### presentationValidationOptions.clone() ⇒ [<code>PresentationValidationOptions</code>](#PresentationValidationOptions)
Deep clones the object.

**Kind**: instance method of [<code>PresentationValidationOptions</code>](#PresentationValidationOptions)
<a name="PresentationValidationOptions.default"></a>

Expand Down Expand Up @@ -2384,6 +2414,8 @@ Serializes a `ProofPurpose` object as a JSON object.
<a name="ProofPurpose+clone"></a>

### proofPurpose.clone() ⇒ [<code>ProofPurpose</code>](#ProofPurpose)
Deep clones the object.

**Kind**: instance method of [<code>ProofPurpose</code>](#ProofPurpose)
<a name="ProofPurpose.assertionMethod"></a>

Expand Down Expand Up @@ -2459,6 +2491,8 @@ Serializes a `Receipt` as a JSON object.
<a name="Receipt+clone"></a>

### receipt.clone() ⇒ [<code>Receipt</code>](#Receipt)
Deep clones the object.

**Kind**: instance method of [<code>Receipt</code>](#Receipt)
<a name="Receipt.fromJSON"></a>

Expand Down Expand Up @@ -2573,6 +2607,8 @@ Serializes a `Document` object as a JSON object.
<a name="ResolvedDocument+clone"></a>

### resolvedDocument.clone() ⇒ [<code>ResolvedDocument</code>](#ResolvedDocument)
Deep clones the object.

**Kind**: instance method of [<code>ResolvedDocument</code>](#ResolvedDocument)
<a name="ResolvedDocument.fromJSON"></a>

Expand Down Expand Up @@ -2852,6 +2888,8 @@ Serializes a `Service` object as a JSON object.
<a name="Service+clone"></a>

### service.clone() ⇒ [<code>Service</code>](#Service)
Deep clones the object.

**Kind**: instance method of [<code>Service</code>](#Service)
<a name="Service.fromJSON"></a>

Expand Down Expand Up @@ -2894,6 +2932,8 @@ Throws an error if any of the options are invalid.
<a name="SignatureOptions+clone"></a>

### signatureOptions.clone() ⇒ [<code>SignatureOptions</code>](#SignatureOptions)
Deep clones the object.

**Kind**: instance method of [<code>SignatureOptions</code>](#SignatureOptions)
<a name="SignatureOptions.default"></a>

Expand Down Expand Up @@ -3060,6 +3100,8 @@ Serializes a `VerificationMethod` object as a JSON object.
<a name="VerificationMethod+clone"></a>

### verificationMethod.clone() ⇒ [<code>VerificationMethod</code>](#VerificationMethod)
Deep clones the object.

**Kind**: instance method of [<code>VerificationMethod</code>](#VerificationMethod)
<a name="VerificationMethod.newMerkleKey"></a>

Expand Down Expand Up @@ -3124,6 +3166,8 @@ Serializes a `VerifierOptions` as a JSON object.
<a name="VerifierOptions+clone"></a>

### verifierOptions.clone() ⇒ [<code>VerifierOptions</code>](#VerifierOptions)
Deep clones the object.

**Kind**: instance method of [<code>VerifierOptions</code>](#VerifierOptions)
<a name="VerifierOptions.default"></a>

Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/src/chain/document_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

use identity::iota::ChainHistory;
use identity::iota::DiffMessage;
use identity::iota::DocumentHistory;
use identity::iota::ResolvedIotaDocument;
use identity::iota_core::DiffMessage;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;

Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/src/did/wasm_did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use identity::core::decode_b58;
use identity::did::DID;
use identity::iota::IotaDID;
use identity::iota_core::IotaDID;
use wasm_bindgen::prelude::*;

use crate::crypto::WasmKeyPair;
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/src/did/wasm_did_url.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity::iota::IotaDIDUrl;
use identity::iota_core::IotaDIDUrl;
use wasm_bindgen::prelude::*;

use crate::did::WasmDID;
Expand Down
13 changes: 8 additions & 5 deletions bindings/wasm/src/did/wasm_diff_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
use std::str::FromStr;

use identity::core::ToJson;
use identity::iota::DiffMessage;
use identity::iota::MessageId;
use identity::iota::TangleRef;
use identity::iota_core::DiffMessage;
use identity::iota_core::MessageId;
use wasm_bindgen::prelude::*;

use crate::did::WasmDID;
Expand Down Expand Up @@ -51,7 +50,9 @@ impl WasmDiffMessage {
/// Sets the message_id of the DID Document diff.
#[wasm_bindgen(setter = messageId)]
pub fn set_message_id(&mut self, message_id: &str) -> Result<()> {
let message_id: MessageId = MessageId::from_str(message_id).wasm_result()?;
let message_id: MessageId = MessageId::from_str(message_id)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?;
self.0.set_message_id(message_id);
Ok(())
}
Expand All @@ -65,7 +66,9 @@ impl WasmDiffMessage {
/// Sets the Tangle message id of the previous DID Document diff.
#[wasm_bindgen(setter = previousMessageId)]
pub fn set_previous_message_id(&mut self, message_id: &str) -> Result<()> {
let previous_message_id: MessageId = MessageId::from_str(message_id).wasm_result()?;
let previous_message_id: MessageId = MessageId::from_str(message_id)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?;
self.0.set_previous_message_id(previous_message_id);
Ok(())
}
Expand Down
24 changes: 15 additions & 9 deletions bindings/wasm/src/did/wasm_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ use identity::crypto::PublicKey;
use identity::crypto::SignatureOptions;
use identity::did::verifiable::VerifiableProperties;
use identity::did::MethodScope;
use identity::iota::Error;
use identity::iota::IotaDID;
use identity::iota::IotaDocument;
use identity::iota::IotaVerificationMethod;
use identity::iota::MessageId;
use identity::iota::NetworkName;
use identity::iota_core::Error;
use identity::iota_core::IotaDID;
use identity::iota_core::IotaDocument;
use identity::iota_core::IotaVerificationMethod;
use identity::iota_core::MessageId;
use identity::iota_core::NetworkName;
use wasm_bindgen::prelude::*;

use crate::common::WasmTimestamp;
Expand Down Expand Up @@ -537,7 +537,9 @@ impl WasmDocument {
.0
.diff(
&other.0,
MessageId::from_str(message_id).wasm_result()?,
MessageId::from_str(message_id)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?,
key.0.private(),
&method_query,
)
Expand Down Expand Up @@ -583,7 +585,9 @@ impl WasmDocument {
/// This is the Base58-btc encoded SHA-256 digest of the hex-encoded message id.
#[wasm_bindgen(js_name = diffIndex)]
pub fn diff_index(message_id: &str) -> Result<String> {
let message_id = MessageId::from_str(message_id).wasm_result()?;
let message_id = MessageId::from_str(message_id)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?;
IotaDocument::diff_index(&message_id).wasm_result()
}

Expand Down Expand Up @@ -633,7 +637,9 @@ impl WasmDocument {
/// Sets the previous integration chain message id.
#[wasm_bindgen(setter = metadataPreviousMessageId)]
pub fn set_metadata_previous_message_id(&mut self, value: &str) -> Result<()> {
let message_id: MessageId = MessageId::from_str(value).wasm_result()?;
let message_id: MessageId = MessageId::from_str(value)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?;
self.0.metadata.previous_message_id = message_id;
Ok(())
}
Expand Down
7 changes: 3 additions & 4 deletions bindings/wasm/src/did/wasm_document_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright 2020-2021 IOTA Stiftung
// Copyright 2020-2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity::iota::IotaDocumentMetadata;

use crate::common::WasmTimestamp;
use identity::iota_core::IotaDocumentMetadata;
use wasm_bindgen::prelude::*;

use crate::common::WasmTimestamp;
use crate::error::Result;
use crate::error::WasmResult;

Expand Down
10 changes: 7 additions & 3 deletions bindings/wasm/src/did/wasm_resolved_document.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2020-2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity::iota::MessageId;
use identity::iota::ResolvedIotaDocument;
use identity::iota_core::MessageId;
use std::str::FromStr;

use crate::did::WasmDiffMessage;
Expand Down Expand Up @@ -86,7 +86,9 @@ impl WasmResolvedDocument {
/// Sets the diff chain message id.
#[wasm_bindgen(setter = diffMessageId)]
pub fn set_diff_message_id(&mut self, value: &str) -> Result<()> {
let message_id: MessageId = MessageId::from_str(value).wasm_result()?;
let message_id: MessageId = MessageId::from_str(value)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?;
self.0.diff_message_id = message_id;
Ok(())
}
Expand All @@ -100,7 +102,9 @@ impl WasmResolvedDocument {
/// Sets the integration chain message id.
#[wasm_bindgen(setter = integrationMessageId)]
pub fn set_integration_message_id(&mut self, value: &str) -> Result<()> {
let message_id: MessageId = MessageId::from_str(value).wasm_result()?;
let message_id: MessageId = MessageId::from_str(value)
.map_err(identity::iota_core::Error::InvalidMessage)
.wasm_result()?;
self.0.integration_message_id = message_id;
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions bindings/wasm/src/did/wasm_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use identity::did::ServiceEndpoint;
use identity::iota::IotaDIDUrl;
use identity::iota::IotaService;
use identity::iota_core::IotaDIDUrl;
use identity::iota_core::IotaService;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;

Expand Down
4 changes: 2 additions & 2 deletions bindings/wasm/src/did/wasm_verification_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use identity::core::decode_b58;
use identity::crypto::merkle_key::Blake2b256;
use identity::crypto::merkle_key::Sha256;
use identity::crypto::PublicKey;
use identity::iota::IotaDID;
use identity::iota::IotaVerificationMethod;
use identity::iota_core::IotaDID;
use identity::iota_core::IotaVerificationMethod;
use wasm_bindgen::prelude::*;

use crate::crypto::Digest;
Expand Down
Loading

0 comments on commit 34bb77a

Please sign in to comment.