Skip to content

feat: add historySerialization with default behaviour - #214

Open
TiagoCerqueira wants to merge 1 commit into
theopenconversationkit:masterfrom
TiagoCerqueira:feat/BOTIV-9965-serialization-backend-message
Open

feat: add historySerialization with default behaviour#214
TiagoCerqueira wants to merge 1 commit into
theopenconversationkit:masterfrom
TiagoCerqueira:feat/BOTIV-9965-serialization-backend-message

Conversation

@TiagoCerqueira

Copy link
Copy Markdown

Resolves #213 by adding encryption support while allowing consumers to provide a custom encryption/decryption implementation, with the existing behaviour preserved by default.

@TiagoCerqueira
TiagoCerqueira force-pushed the feat/BOTIV-9965-serialization-backend-message branch from 75bf6c2 to 2bd3061 Compare September 3, 2026 14:11
* encryption).
* @param encryptionKey - optional function returning the raw encryption key
*/
export function createDefaultHistoryEncryption(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have createDefaultHistorySerialization, returning the basic {JSON.stringify, JSON.parse}, and a dedicated createEncryptedHistorySerialization(encryptionKey: () => string) returning {encrypt, decrypt}

Comment thread README.md
| `historyMaxAge` | `number?` | If set to a positive value, represents the number of seconds before the message history is cleared (the timeout is reset after each message received). |
| `maxMessageCount` | `number?` | When message history is enabled, sets the max number of messages to store. Defaults to 10. |
| `prefix` | `string?` | Prefix for local storage keys allowing communication with different bots from the same domain (used for both `userId` and message history). |
| `encryptionKey` | `(() => string)?` | A function returning the raw key used to AES-GCM-encrypt the persisted message history, using the library's default encryption. If omitted, the history is stored as plain (unencrypted) JSON. Ignored if `historyEncryption` is provided. |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a separate parameter, I am very much in favor of publicizing a dedicated createEncryptedHistorySerialization method (see other comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encrypt conversation history stored in localStorage

2 participants