From 7e557f84a4e6548901ff65e64b134e45d2b37203 Mon Sep 17 00:00:00 2001 From: paulclindo Date: Fri, 3 Nov 2023 22:17:18 -0500 Subject: [PATCH] add update inbox name in message builder and fix encryption --- .../src/wasm/ShinkaiMessageBuilderWrapper.ts | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/libs/shinkai-message-ts/src/wasm/ShinkaiMessageBuilderWrapper.ts b/libs/shinkai-message-ts/src/wasm/ShinkaiMessageBuilderWrapper.ts index e4274217f..bdd81cedf 100644 --- a/libs/shinkai-message-ts/src/wasm/ShinkaiMessageBuilderWrapper.ts +++ b/libs/shinkai-message-ts/src/wasm/ShinkaiMessageBuilderWrapper.ts @@ -278,7 +278,7 @@ export class ShinkaiMessageBuilderWrapper { ); builder.external_metadata(receiver, sender); builder.body_encryption( - 'None' // todo: change back to encrypted + 'DiffieHellmanChaChaPoly1305' ); const message = builder.build_to_string(); @@ -464,10 +464,7 @@ export class ShinkaiMessageBuilderWrapper { 'None' ); builder.external_metadata_with_intra(receiver, sender, sender_subidentity); - // TODO: At this point we are forcing unencrypted message until we implement message response in shinkai-node - builder.body_encryption( - 'None' - ); + builder.body_encryption('DiffieHellmanChaChaPoly1305'); const message = builder.build_to_string(); @@ -542,4 +539,36 @@ export class ShinkaiMessageBuilderWrapper { const message = builder.build_to_string(); return message; } + + static update_shinkai_inbox_name( + my_encryption_secret_key: string, + my_signature_secret_key: string, + receiver_public_key: string, + sender: string, + sender_subidentity: string, + receiver: string, + receiver_subidentity: string, + inbox: string, + inboxName: string + ): string { + const builder = new ShinkaiMessageBuilderWrapperWASM( + my_encryption_secret_key, + my_signature_secret_key, + receiver_public_key + ); + builder.message_raw_content(inboxName); + builder.message_schema_type(MessageSchemaType.TextContent.toString()); + builder.internal_metadata_with_inbox( + sender_subidentity, + receiver_subidentity, + inbox, + "None" + ); + builder.external_metadata_with_intra(receiver, sender, sender_subidentity); + builder.body_encryption('DiffieHellmanChaChaPoly1305'); + + const message = builder.build_to_string(); + + return message; + } }