From 5ed2b67312fdb77b43b3b5dfd96bc83a9242d391 Mon Sep 17 00:00:00 2001 From: balzack Date: Wed, 30 Oct 2024 17:00:13 -0700 Subject: [PATCH] more content api cleanup --- app/sdk/README.md | 2 +- app/sdk/src/api.ts | 2 +- app/sdk/src/content.ts | 4 ++-- app/sdk/src/stream.ts | 9 +++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/sdk/README.md b/app/sdk/README.md index 3f6a2379..eb5679cb 100644 --- a/app/sdk/README.md +++ b/app/sdk/README.md @@ -339,7 +339,7 @@ Automate allocates the Bot interface for ia specific communication channel Update the subject on specified channel - ```Content::setChannelSubject(channelId: string, subject: string): Promise``` + ```Content::setChannelSubject(channelId: string, type: string, subject: any): Promise``` Add member to specified channel diff --git a/app/sdk/src/api.ts b/app/sdk/src/api.ts index 01551474..c83186fc 100644 --- a/app/sdk/src/api.ts +++ b/app/sdk/src/api.ts @@ -90,7 +90,7 @@ export interface Contact { export interface Content { addChannel(sealed: boolean, type: string, subject: any, cardIds: string[]): Promise; removeChannel(channelId: string): Promise; - setChannelSubject(channelId: string, subject: string): Promise; + setChannelSubject(channelId: string, type: string, subject: any): Promise; setChannelCard(channelId: string, cardId: string): Promise; clearChannelCard(channelId: string, cardId: string): Promise; diff --git a/app/sdk/src/content.ts b/app/sdk/src/content.ts index 737b8b23..1b5fb841 100644 --- a/app/sdk/src/content.ts +++ b/app/sdk/src/content.ts @@ -40,8 +40,8 @@ export class ContentModule implements Content { return await this.stream.removeChannel(channelId); } - public async setChannelSubject(channelId: string, subject: string): Promise { - return await this.stream.setChannelSubject(channelId, subject); + public async setChannelSubject(channelId: string, type: string, subject: any): Promise { + return await this.stream.setChannelSubject(channelId, type, subject); } public async setChannelCard(channelId: string, cardId: string): Promise { diff --git a/app/sdk/src/stream.ts b/app/sdk/src/stream.ts index 4c94ae8e..14ebb6f4 100644 --- a/app/sdk/src/stream.ts +++ b/app/sdk/src/stream.ts @@ -251,7 +251,7 @@ export class StreamModule { return await removeChannel(node, secure, token); } - public async setChannelSubject(channelId: string, subject: string): Promise { + public async setChannelSubject(channelId: string, type: string, subject: any): Promise { const channel = this.channelEntries.get(channelId); if (!channel) { throw new Error('channel not found'); @@ -269,12 +269,13 @@ export class StreamModule { if (!item.channelKey) { item.channelKey = await this.getChannelKey(seals); } - const { encryptedDataB64 } = await crypto.aesEncrypt(subject, subjectIv, item.channelKey); + const subjectData = JSON.stringify(subject); + const { encryptedDataB64 } = await crypto.aesEncrypt(subjectData, subjectIv, item.channelKey); const sealedSubject = { subjectEncrypted, encryptedDataB64, subjectIv, seals }; - await setChannelSubject(node, secure, token, channelId, item.dataType, sealedSubject); + await setChannelSubject(node, secure, token, channelId, type, sealedSubject); } else { - await setChannelSubject(node, secure, token, channelId, item.dataType, { subject }); + await setChannelSubject(node, secure, token, channelId, type, subject); } }