diff --git a/index.html b/index.html index 1d178c3..614dc2c 100644 --- a/index.html +++ b/index.html @@ -113,6 +113,12 @@ + + @@ -537,6 +543,20 @@ alert("Failed to get channels!"); } }, + async setChannel() { + try { + await this.connection.setChannel(1, "Test Channel", BufferUtils.base64ToBytes("RQKLcABJ8tLX+7yerzS9Rw==")); + } catch(e) { + alert("Failed to set channel!"); + } + }, + async deleteChannel() { + try { + await this.connection.deleteChannel(1); + } catch(e) { + alert("Failed to delete channel!"); + } + }, async login(contact) { // ask user for password diff --git a/src/buffer_utils.js b/src/buffer_utils.js index ee8b932..eaca13b 100644 --- a/src/buffer_utils.js +++ b/src/buffer_utils.js @@ -6,6 +6,12 @@ class BufferUtils { }).join(''); } + static base64ToBytes(base64) { + return Uint8Array.from(atob(base64), (c) => { + return c.charCodeAt(0); + }); + } + static areBuffersEqual(byteArray1, byteArray2) { // ensure length is the same