From 75ec0131560c7d1e03a0775949010c490c6ad447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chuck=20LeDuc=20D=C3=ADaz?= Date: Wed, 15 Apr 2020 12:01:43 +0200 Subject: [PATCH] memberOfConfirm returns a boolean or throws an error, like memberOf --- .vscode/settings.json | 1 + README.md | 4 ++-- package.json | 2 +- src/main.js | 7 ++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0b82146..5cb8d3e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "Dspace", "GMVZE", "Puig", "Tqnl", diff --git a/README.md b/README.md index 876e5f5..0c61e4b 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Throws an error and emits `error` if fails. #### `connect(connectionstring)` -Connect to Lorena IDSpace. +Connect to Lorena IDspace. `connectionstring` is a concatenation of username-password-did Returns true if the connection is success @@ -72,7 +72,7 @@ Throws an error and emits `error` if fails. #### `handshake()` -Establishes a connection with the idspace, checking public-key signatures. +Establishes a connection with the IDspace, checking public-key signatures. #### `callRecipe(recipe, { payloadText: 'text', payloadETC: 'ETC'})` diff --git a/package.json b/package.json index b1f12c6..cf59cbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lorena-ssi/lorena-sdk", - "version": "1.0.4", + "version": "1.0.5", "description": "Lorena Client", "author": "Alex Puig ", "license": "MIT", diff --git a/src/main.js b/src/main.js index 7a4f488..b7f8e0c 100644 --- a/src/main.js +++ b/src/main.js @@ -191,6 +191,7 @@ export default class Lorena extends EventEmitter { * * @param {string} roomId Contact Identifier * @param {string} secretCode secret Code + * @returns {Promise} result boolean true or thrown error */ async memberOfConfirm (roomId, secretCode) { return new Promise((resolve) => { @@ -207,9 +208,9 @@ export default class Lorena extends EventEmitter { if (result.payload.msg === 'member verified') { this.wallet.update('contacts', { roomId: roomId }, { status: 'verified' }) this.wallet.add('credentials', result.payload.credential) - resolve(result.payload.msg) + resolve(true) } else { - resolve(result.payload.msg) + throw new Error(`memberOf: ${result.payload.message}`) } }) } @@ -217,7 +218,7 @@ export default class Lorena extends EventEmitter { } /** - * Connect to Lorena IDSpace. + * Connect to Lorena IDspace. */ async connect () { if (this.ready === true) return true