Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StardustDocumentMetadata, implement StardustDocument methods #951

Merged
merged 8 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions bindings/wasm/docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ publishing to the Tangle.
* [.createSignedData(fragment, data, options)](#Account+createSignedData) ⇒ <code>Promise.&lt;any&gt;</code>
* [.updateDocumentUnchecked(document)](#Account+updateDocumentUnchecked) ⇒ <code>Promise.&lt;void&gt;</code>
* [.fetchDocument()](#Account+fetchDocument) ⇒ <code>Promise.&lt;void&gt;</code>
* [.revokeCredentials(fragment, credentialIndices)](#Account+revokeCredentials) ⇒ <code>Promise.&lt;void&gt;</code>
* [.unrevokeCredentials(fragment, credentialIndices)](#Account+unrevokeCredentials) ⇒ <code>Promise.&lt;void&gt;</code>
* [.revokeCredentials(fragment, indices)](#Account+revokeCredentials) ⇒ <code>Promise.&lt;void&gt;</code>
* [.unrevokeCredentials(fragment, indices)](#Account+unrevokeCredentials) ⇒ <code>Promise.&lt;void&gt;</code>
* [.encryptData(plaintext, associated_data, encryption_algorithm, cek_algorithm, public_key)](#Account+encryptData) ⇒ [<code>Promise.&lt;EncryptedData&gt;</code>](#EncryptedData)
* [.decryptData(data, encryption_algorithm, cek_algorithm, fragment)](#Account+decryptData) ⇒ <code>Promise.&lt;Uint8Array&gt;</code>
* [.attachMethodRelationships(options)](#Account+attachMethodRelationships) ⇒ <code>Promise.&lt;void&gt;</code>
Expand Down Expand Up @@ -403,29 +403,29 @@ to the identity, to avoid publishing updates that would be ignored.
**Kind**: instance method of [<code>Account</code>](#Account)
<a name="Account+revokeCredentials"></a>

### account.revokeCredentials(fragment, credentialIndices) ⇒ <code>Promise.&lt;void&gt;</code>
### account.revokeCredentials(fragment, indices) ⇒ <code>Promise.&lt;void&gt;</code>
If the document has a `RevocationBitmap` service identified by `fragment`,
revoke all credentials with a `revocationBitmapIndex` in `credentialIndices`.
revoke all specified `indices`.

**Kind**: instance method of [<code>Account</code>](#Account)

| Param | Type |
| --- | --- |
| fragment | <code>string</code> |
| credentialIndices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |
| indices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |

<a name="Account+unrevokeCredentials"></a>

### account.unrevokeCredentials(fragment, credentialIndices) ⇒ <code>Promise.&lt;void&gt;</code>
### account.unrevokeCredentials(fragment, indices) ⇒ <code>Promise.&lt;void&gt;</code>
If the document has a `RevocationBitmap` service identified by `fragment`,
unrevoke all credentials with a `revocationBitmapIndex` in `credentialIndices`.
unrevoke all specified `indices`.

**Kind**: instance method of [<code>Account</code>](#Account)

| Param | Type |
| --- | --- |
| fragment | <code>string</code> |
| credentialIndices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |
| indices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |

<a name="Account+encryptData"></a>

Expand Down Expand Up @@ -1798,8 +1798,8 @@ Deserializes a `DiffMessage` from a JSON object.
* [.metadataPreviousMessageId()](#Document+metadataPreviousMessageId) ⇒ <code>string</code>
* [.setMetadataPreviousMessageId(value)](#Document+setMetadataPreviousMessageId)
* [.proof()](#Document+proof) ⇒ [<code>Proof</code>](#Proof) \| <code>undefined</code>
* [.revokeCredentials(serviceQuery, credentialIndices)](#Document+revokeCredentials)
* [.unrevokeCredentials(serviceQuery, credentialIndices)](#Document+unrevokeCredentials)
* [.revokeCredentials(serviceQuery, indices)](#Document+revokeCredentials)
* [.unrevokeCredentials(serviceQuery, indices)](#Document+unrevokeCredentials)
* [.toJSON()](#Document+toJSON) ⇒ <code>any</code>
* [.clone()](#Document+clone) ⇒ [<code>Document</code>](#Document)
* _static_
Expand Down Expand Up @@ -2280,29 +2280,29 @@ Returns a copy of the proof.
**Kind**: instance method of [<code>Document</code>](#Document)
<a name="Document+revokeCredentials"></a>

### document.revokeCredentials(serviceQuery, credentialIndices)
### document.revokeCredentials(serviceQuery, indices)
If the document has a `RevocationBitmap` service identified by `serviceQuery`,
revoke all credentials with a revocationBitmapIndex in `credentialIndices`.
revoke all specified `indices`.

**Kind**: instance method of [<code>Document</code>](#Document)

| Param | Type |
| --- | --- |
| serviceQuery | [<code>DIDUrl</code>](#DIDUrl) \| <code>string</code> |
| credentialIndices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |
| indices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |

<a name="Document+unrevokeCredentials"></a>

### document.unrevokeCredentials(serviceQuery, credentialIndices)
### document.unrevokeCredentials(serviceQuery, indices)
If the document has a `RevocationBitmap` service identified by `serviceQuery`,
unrevoke all credentials with a revocationBitmapIndex in `credentialIndices`.
unrevoke all specified `indices`.

**Kind**: instance method of [<code>Document</code>](#Document)

| Param | Type |
| --- | --- |
| serviceQuery | [<code>DIDUrl</code>](#DIDUrl) \| <code>string</code> |
| credentialIndices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |
| indices | <code>number</code> \| <code>Array.&lt;number&gt;</code> |

<a name="Document+toJSON"></a>

Expand Down
16 changes: 8 additions & 8 deletions bindings/wasm/src/account/wasm_account/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ impl WasmAccount {
}

/// If the document has a `RevocationBitmap` service identified by `fragment`,
/// revoke all credentials with a `revocationBitmapIndex` in `credentialIndices`.
/// revoke all specified `indices`.
#[wasm_bindgen(js_name = revokeCredentials)]
#[allow(non_snake_case)]
pub fn revoke_credentials(&mut self, fragment: String, credentialIndices: UOneOrManyNumber) -> PromiseVoid {
pub fn revoke_credentials(&mut self, fragment: String, indices: UOneOrManyNumber) -> PromiseVoid {
let account = self.0.clone();
future_to_promise(async move {
let credentials_indices: OneOrMany<u32> = credentialIndices.into_serde().wasm_result()?;
let indices: OneOrMany<u32> = indices.into_serde().wasm_result()?;

account
.as_ref()
.borrow_mut()
.revoke_credentials(&fragment, credentials_indices.as_slice())
.revoke_credentials(&fragment, indices.as_slice())
.await
.map(|_| JsValue::undefined())
.wasm_result()
Expand All @@ -296,18 +296,18 @@ impl WasmAccount {
}

/// If the document has a `RevocationBitmap` service identified by `fragment`,
/// unrevoke all credentials with a `revocationBitmapIndex` in `credentialIndices`.
/// unrevoke all specified `indices`.
#[wasm_bindgen(js_name = unrevokeCredentials)]
#[allow(non_snake_case)]
pub fn unrevoke_credentials(&mut self, fragment: String, credentialIndices: UOneOrManyNumber) -> PromiseVoid {
pub fn unrevoke_credentials(&mut self, fragment: String, indices: UOneOrManyNumber) -> PromiseVoid {
let account = self.0.clone();
future_to_promise(async move {
let credentials_indices: OneOrMany<u32> = credentialIndices.into_serde().wasm_result()?;
let indices: OneOrMany<u32> = indices.into_serde().wasm_result()?;

account
.as_ref()
.borrow_mut()
.unrevoke_credentials(&fragment, credentials_indices.as_slice())
.unrevoke_credentials(&fragment, indices.as_slice())
.await
.map(|_| JsValue::undefined())
.wasm_result()
Expand Down
26 changes: 8 additions & 18 deletions bindings/wasm/src/did/wasm_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,35 +640,25 @@ impl WasmDocument {
}

/// If the document has a `RevocationBitmap` service identified by `serviceQuery`,
/// revoke all credentials with a revocationBitmapIndex in `credentialIndices`.
/// revoke all specified `indices`.
#[wasm_bindgen(js_name = revokeCredentials)]
#[allow(non_snake_case)]
pub fn revoke_credentials(&mut self, serviceQuery: &UDIDUrlQuery, credentialIndices: UOneOrManyNumber) -> Result<()> {
pub fn revoke_credentials(&mut self, serviceQuery: &UDIDUrlQuery, indices: UOneOrManyNumber) -> Result<()> {
let query: String = serviceQuery.into_serde().wasm_result()?;
let credentials_indices: OneOrMany<u32> = credentialIndices.into_serde().wasm_result()?;
let indices: OneOrMany<u32> = indices.into_serde().wasm_result()?;

self
.0
.revoke_credentials(&query, credentials_indices.as_slice())
.wasm_result()
self.0.revoke_credentials(&query, indices.as_slice()).wasm_result()
}

/// If the document has a `RevocationBitmap` service identified by `serviceQuery`,
/// unrevoke all credentials with a revocationBitmapIndex in `credentialIndices`.
/// unrevoke all specified `indices`.
#[wasm_bindgen(js_name = unrevokeCredentials)]
#[allow(non_snake_case)]
pub fn unrevoke_credentials(
&mut self,
serviceQuery: &UDIDUrlQuery,
credentialIndices: UOneOrManyNumber,
) -> Result<()> {
pub fn unrevoke_credentials(&mut self, serviceQuery: &UDIDUrlQuery, indices: UOneOrManyNumber) -> Result<()> {
let query: String = serviceQuery.into_serde().wasm_result()?;
let credentials_indices: OneOrMany<u32> = credentialIndices.into_serde().wasm_result()?;
let indices: OneOrMany<u32> = indices.into_serde().wasm_result()?;

self
.0
.unrevoke_credentials(&query, credentials_indices.as_slice())
.wasm_result()
self.0.unrevoke_credentials(&query, indices.as_slice()).wasm_result()
}

// ===========================================================================
Expand Down
12 changes: 6 additions & 6 deletions identity_account/src/account/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,27 +566,27 @@ mod account_revocation {
C: SharedPtr<Client>,
{
/// If the document has a [`RevocationBitmap`][identity_did::revocation::RevocationBitmap] service identified by
/// `fragment`, revoke all credentials with a `revocationBitmapIndex` in `credential_indices`.
pub async fn revoke_credentials(&mut self, fragment: &str, credential_indices: &[u32]) -> Result<()> {
/// `fragment`, revoke all specified `indices`.
pub async fn revoke_credentials(&mut self, fragment: &str, indices: &[u32]) -> Result<()> {
// Find the service to be updated.
let mut service_id: IotaDIDUrl = self.did().to_url();
service_id.set_fragment(Some(fragment))?;

self.document.revoke_credentials(&service_id, credential_indices)?;
self.document.revoke_credentials(&service_id, indices)?;

self.increment_actions();
self.publish_internal(false, PublishOptions::default()).await?;
Ok(())
}

/// If the document has a [`RevocationBitmap`][identity_did::revocation::RevocationBitmap] service identified by
/// `fragment`, unrevoke all credentials with a `revocationBitmapIndex` in `credential_indices`.
pub async fn unrevoke_credentials(&mut self, fragment: &str, credential_indices: &[u32]) -> Result<()> {
/// `fragment`, unrevoke all specified `indices`.
pub async fn unrevoke_credentials(&mut self, fragment: &str, indices: &[u32]) -> Result<()> {
// Find the service to be updated.
let mut service_id: IotaDIDUrl = self.did().to_url();
service_id.set_fragment(Some(fragment))?;

self.document.unrevoke_credentials(&service_id, credential_indices)?;
self.document.unrevoke_credentials(&service_id, indices)?;

self.increment_actions();
self.publish_internal(false, PublishOptions::default()).await?;
Expand Down
2 changes: 1 addition & 1 deletion identity_account_storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ hashbrown = { version = "0.11", features = ["serde"] }
identity_core = { version = "=0.6.0", path = "../identity_core", default-features = false }
identity_did = { version = "=0.6.0", path = "../identity_did", default-features = false }
identity_iota_core = { version = "=0.6.0", path = "../identity_iota_core", default-features = false }
iota-crypto = { version = ">=0.7, <0.10", default-features = false, features = ["hmac", "pbkdf", "sha", "std", "aes", "aes-kw"] }
iota-crypto = { version = "0.12.1", default-features = false, features = ["hmac", "pbkdf", "sha", "std", "aes-gcm", "aes-kw"] }
iota_stronghold = { version = "0.6.4", default-features = false, features = ["std"], optional = true }
once_cell = { version = "1.7", default-features = false, features = ["std"], optional = true }
parking_lot = { version = "0.12" }
Expand Down
4 changes: 2 additions & 2 deletions identity_account_storage/src/storage/memstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::fmt::Formatter;

use async_trait::async_trait;
#[cfg(feature = "encryption")]
use crypto::ciphers::aes::Aes256Gcm;
use crypto::ciphers::aes_gcm::Aes256Gcm;
#[cfg(feature = "encryption")]
use crypto::ciphers::aes_kw::Aes256Kw;
#[cfg(feature = "encryption")]
Expand Down Expand Up @@ -419,7 +419,7 @@ mod memstore_encryption {
use crate::types::EncryptionAlgorithm;
use crate::Error;
use crate::Result;
use crypto::ciphers::aes::Aes256Gcm;
use crypto::ciphers::aes_gcm::Aes256Gcm;
use crypto::ciphers::traits::Aead;
use crypto::hashes::sha::Sha256;
use crypto::hashes::Digest;
Expand Down
2 changes: 1 addition & 1 deletion identity_account_storage/src/storage/stronghold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::collections::BTreeSet;

use async_trait::async_trait;
use crypto::ciphers::aes::Aes256Gcm;
use crypto::ciphers::aes_gcm::Aes256Gcm;
use crypto::ciphers::traits::Aead;
use futures::executor;
use identity_core::convert::FromJson;
Expand Down
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 crypto::ciphers::aes::Aes256Gcm;
use crypto::ciphers::aes_gcm::Aes256Gcm;
use crypto::ciphers::traits::Aead;
use serde::Deserialize;
use serde::Serialize;
Expand Down
2 changes: 1 addition & 1 deletion identity_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ url = { version = "2.2", default-features = false, features = ["serde"] }
zeroize = { version = "1.4", default-features = false }

[dependencies.iota-crypto]
version = ">=0.7, <0.10"
version = "0.12.1"
default-features = false
features = ["ed25519", "random", "sha", "x25519"]

Expand Down
Loading