Skip to content

Commit

Permalink
Bump to 0.3.8 for @iota/identity-wasm@dev, add set_message_id (#373)
Browse files Browse the repository at this point in the history
* Add set_message_id to WasmDocument

Allow setting the message_id on DID documents in the wasm bindings.

* Bump version to 0.3.8 for @iota/identity-wasm@dev

* Fix messageId in create_did Wasm examples
  • Loading branch information
cycraig committed Aug 30, 2021
1 parent 729da54 commit 0974493
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
14 changes: 14 additions & 0 deletions bindings/wasm/docs/api-reference.md
Expand Up @@ -715,6 +715,7 @@ Parses a `DID` from the input string.
* [.updated](#Document+updated)
* [.proof](#Document+proof) ⇒ <code>any</code>
* [.messageId](#Document+messageId) ⇒ <code>string</code>
* [.messageId](#Document+messageId)
* [.previousMessageId](#Document+previousMessageId) ⇒ <code>string</code>
* [.previousMessageId](#Document+previousMessageId)
* [.authentication()](#Document+authentication)[<code>VerificationMethod</code>](#VerificationMethod)
Expand Down Expand Up @@ -801,7 +802,20 @@ Returns the DID Document `proof` object.
<a name="Document+messageId"></a>

### document.messageId ⇒ <code>string</code>
Get the message_id of the DID Document.

**Kind**: instance property of [<code>Document</code>](#Document)
<a name="Document+messageId"></a>

### document.messageId
Set the message_id of the DID Document.

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

| Param | Type |
| --- | --- |
| message_id | <code>string</code> |

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

### document.previousMessageId ⇒ <code>string</code>
Expand Down
1 change: 1 addition & 0 deletions bindings/wasm/examples/browser/create_did.js
Expand Up @@ -37,6 +37,7 @@ export async function createIdentity(clientConfig, log = true) {

// Publish the Identity to the IOTA Network, this may take a few seconds to complete Proof-of-Work.
const receipt = await client.publishDocument(doc.toJSON());
doc.messageId = receipt.messageId;

const explorerUrl = getExplorerUrl(doc, receipt.messageId);

Expand Down
1 change: 1 addition & 0 deletions bindings/wasm/examples/node/create_did.js
Expand Up @@ -27,6 +27,7 @@ async function createIdentity(clientConfig) {

// Publish the Identity to the IOTA Network, this may take a few seconds to complete Proof-of-Work.
const receipt = await client.publishDocument(doc.toJSON());
doc.messageId = receipt.messageId;

// Log the results.
logExplorerUrl("Identity Creation:", clientConfig.network.toString(), receipt.messageId);
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/wasm/package.json
@@ -1,6 +1,6 @@
{
"name": "@iota/identity-wasm",
"version": "0.3.7",
"version": "0.3.8",
"description": "WASM bindings for IOTA Identity - A Self Sovereign Identity Framework implementing the DID and VC standards from W3C. To be used in Javascript/Typescript",
"repository": {
"type": "git",
Expand Down
11 changes: 9 additions & 2 deletions bindings/wasm/src/did/wasm_document.rs
Expand Up @@ -151,11 +151,20 @@ impl WasmDocument {
WasmVerificationMethod(self.0.authentication().clone())
}

/// Get the message_id of the DID Document.
#[wasm_bindgen(getter = messageId)]
pub fn message_id(&self) -> String {
self.0.message_id().to_string()
}

/// Set the message_id of the DID Document.
#[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()?;
self.0.set_message_id(message_id);
Ok(())
}

#[wasm_bindgen(getter = previousMessageId)]
pub fn previous_message_id(&self) -> String {
self.0.previous_message_id().to_string()
Expand All @@ -164,9 +173,7 @@ impl WasmDocument {
#[wasm_bindgen(setter = previousMessageId)]
pub fn set_previous_message_id(&mut self, value: &str) -> Result<()> {
let message: MessageId = MessageId::from_str(value).wasm_result()?;

self.0.set_previous_message_id(message);

Ok(())
}

Expand Down

0 comments on commit 0974493

Please sign in to comment.