Symmetric encryption: `PresenceMessage.fromEncoded` and `Message.fromEncoded`
PR https://github.com/ably/ably-flutter/pull/192 does not yet include decryption of messages which are passed to PresenceMessage.fromEncoded and Message.fromEncoded, as per TP4 and TM3. This is intended for when messages are persisted to disk, or received outside of the Ably clients.
┆Issue is synchronized with this Jira Story by Unito
Internal slack discussion on this issue: https://ably-real-time.slack.com/archives/C0178QGC093/p1645099695085259
A couple of additional notes that we’ve collected together with @ikbalkaya :
- Flutter SDK does not encrypt or decrypt messages - they’re encrypted and decrypted on native platform side, so it’s not really possible to save or do anything with encrypted message on Flutter side. The only use for Message.fromEncrypted seems to be a case, where message is provided to Flutter application from source other that our SDK, f.e. REST API. If message comes from our SDK, it’s automatically decrypted before it reaches Flutter SDK
- Since the whole encryption is done on native platforms, the implementation shouldn’t probably be done on Flutter side, but rather it should be a proxy to native methods
- Encryption implementation in sample app doesn't seem to work - see #334
If we are going to implement this, even if the implementation is delegated away to the platform native layer (most appropriate), then we should test with: https://github.com/ably/ably-common/tree/main/test-resources
I'll admit that I'm struggling a little bit to work out what the original use case for these methods was, however having discussed with @ikurek and @ikbalkaya we have concluded that - on balance - we should probably implement this. Igor has pointed out that we may need present a slightly different API to that presented in the spec, due to idiomatic constraints in Flutter/Dart.
I'll admit that I'm struggling a little bit to work out what the original use case for these methods was
Imagine consuming messages via some mechanism that doesn't involve an Ably library - for example taking them from a Kinesis queue, or being passed a message on invocation of a lambda. You need to be able to decode those messages to get the original payload.
I've discussed this with @maratal and ably-cocoa doesn't have a public implementation of Message.fromEncoded so for now there's nothing that I can use to bridge from Dart to iOS SDK
https://github.com/ably/ably-cocoa/issues/1305 @ikurek
https://github.com/ably/ably-cocoa/pull/1307
This is also not fully implemented on ably-java, see:https://github.com/ably/ably-java/issues/752