Skip to content

Commit

Permalink
add update inbox name in message builder and fix encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
paulclindo committed Nov 4, 2023
1 parent bbdd19b commit 7e557f8
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions libs/shinkai-message-ts/src/wasm/ShinkaiMessageBuilderWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}
}

0 comments on commit 7e557f8

Please sign in to comment.