diff --git a/CHANGELOG.md b/CHANGELOG.md index f974a41..94b9c74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.25 + +* Fix ```sendFinishingSession``` method to not throw exception on timeout + ## 0.0.24 * Fix connection when the WebSocket URI prefix has ```_``` (underscore). diff --git a/lib/src/protocol/client/client_channel.dart b/lib/src/protocol/client/client_channel.dart index ac9075b..80018d6 100644 --- a/lib/src/protocol/client/client_channel.dart +++ b/lib/src/protocol/client/client_channel.dart @@ -8,7 +8,6 @@ import '../node.dart'; import '../notification.dart'; import '../security/authentication.dart'; import '../session.dart'; - import 'channel.dart'; /// Defines a communication channel between a node and a server. @@ -63,7 +62,7 @@ class ClientChannel extends Channel { } /// Send a [Session] type [Envelope] with state [SessionState.finishing] to end the communication - Future sendFinishingSession() async { + Future sendFinishingSession() async { if (state != SessionState.established) { throw Exception('Cannot finish a session in the $state state'); } @@ -84,10 +83,10 @@ class ClientChannel extends Channel { return c.future; }), Future(() { - final c = Completer(); + final c = Completer(); Future.delayed(const Duration(milliseconds: 6000), () { - return c.completeError('Timeout reached - sendFinishingSession'); + return c.complete(); }); return c.future; diff --git a/lib/src/protocol/network/web_socket_transport.dart b/lib/src/protocol/network/web_socket_transport.dart index c54e5f3..9df4884 100644 --- a/lib/src/protocol/network/web_socket_transport.dart +++ b/lib/src/protocol/network/web_socket_transport.dart @@ -88,7 +88,7 @@ class WebSocketTransport implements Transport { final response = jsonDecode(data); logger.info( - 'Envelope received: $uri \n' + prettyJson(response, indent: 2)); + 'Envelope received: $uri \n${prettyJson(response, indent: 2)}'); onEnvelope?.add(response); }, @@ -134,7 +134,7 @@ class WebSocketTransport implements Transport { socket?.add(encode); logger - .info('Envelope send: \n' + prettyJson(jsonDecode(encode), indent: 2)); + .info('Envelope send: \n${prettyJson(jsonDecode(encode), indent: 2)}'); } void ensureSocketOpen() { @@ -147,16 +147,16 @@ class WebSocketTransport implements Transport { get onEnvelope => onEnvelopeStream; @override - set onEnvelope(StreamController>? _onEnvelope) { - onEnvelopeStream = _onEnvelope; + set onEnvelope(StreamController>? onEnvelope) { + onEnvelopeStream = onEnvelope; } @override get onConnectionDone => onConnectionDoneStream; @override - set onConnectionDone(StreamController? _onConnectionDone) { - onConnectionDoneStream = _onConnectionDone; + set onConnectionDone(StreamController? onConnectionDone) { + onConnectionDoneStream = onConnectionDone; } Future> _getKeyBytes() async { diff --git a/lib/src/protocol/security/external_authentication.dart b/lib/src/protocol/security/external_authentication.dart index a597ccd..9927253 100644 --- a/lib/src/protocol/security/external_authentication.dart +++ b/lib/src/protocol/security/external_authentication.dart @@ -1,6 +1,6 @@ +import '../extensions/string.extension.dart'; import 'authentication.dart'; import 'enums/authentication_scheme.enum.dart'; -import '../extensions/string.extension.dart'; /// Defines a external authentication scheme, that uses third-party validation. class ExternalAuthentication extends Authentication { @@ -14,8 +14,10 @@ class ExternalAuthentication extends Authentication { String? issuer; /// Initializes a new instance of the [ExternalAuthentication] class. - ExternalAuthentication({this.token, this.issuer}) - : super(AuthenticationScheme.external); + ExternalAuthentication({ + this.token, + this.issuer, + }) : super(AuthenticationScheme.external); /// Set a plain token to a base64 representation void setToBase64Token(final String? password) { diff --git a/lib/src/protocol/security/key_authentication.dart b/lib/src/protocol/security/key_authentication.dart index 420cc5f..a9b93de 100644 --- a/lib/src/protocol/security/key_authentication.dart +++ b/lib/src/protocol/security/key_authentication.dart @@ -1,6 +1,6 @@ +import '../extensions/string.extension.dart'; import 'authentication.dart'; import 'enums/authentication_scheme.enum.dart'; -import '../extensions/string.extension.dart'; /// Defines a authentication scheme that uses a key for authentication. /// Should be used only with encrypted sessions. @@ -14,8 +14,8 @@ class KeyAuthentication extends Authentication { KeyAuthentication({this.key}) : super(AuthenticationScheme.key); /// Set a plain key to a Base64 representation. - void setToBase64Key(final String? _key) { - key = _key?.toBase64(); + void setToBase64Key(final String? key) { + this.key = key?.toBase64(); } /// Gets the plain key decoded from the Base64 representation. diff --git a/lib/src/protocol/security/plain_authentication.dart b/lib/src/protocol/security/plain_authentication.dart index a36b56e..5f30638 100644 --- a/lib/src/protocol/security/plain_authentication.dart +++ b/lib/src/protocol/security/plain_authentication.dart @@ -1,6 +1,6 @@ +import '../extensions/string.extension.dart'; import 'authentication.dart'; import 'enums/authentication_scheme.enum.dart'; -import '../extensions/string.extension.dart'; /// Defines a plain authentication scheme, that uses a password for authentication. /// Should be used only with encrypted sessions. @@ -14,8 +14,8 @@ class PlainAuthentication extends Authentication { PlainAuthentication({this.password}) : super(AuthenticationScheme.plain); /// Set a plain password to a Base64 representation - void setToBase64Password(final String? _password) { - password = _password?.toBase64(); + void setToBase64Password(final String? password) { + this.password = password?.toBase64(); } /// Gets the plain password decoded from the Base64 representation diff --git a/pubspec.lock b/pubspec.lock index 6bb494d..5934894 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: args - sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.2" async: dependency: transitive description: @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: build - sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.4.1" build_config: dependency: transitive description: @@ -61,34 +61,34 @@ packages: dependency: transitive description: name: build_daemon - sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf" + sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "4.0.0" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "7c35a3a7868626257d8aee47b51c26b9dba11eaddf3431117ed2744951416aab" + sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.2.1" build_runner: dependency: "direct dev" description: name: build_runner - sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 + sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b" url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.4.6" build_runner_core: dependency: transitive description: name: build_runner_core - sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292" + sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41" url: "https://pub.dev" source: hosted - version: "7.2.7" + version: "7.2.10" built_collection: dependency: transitive description: @@ -101,10 +101,10 @@ packages: dependency: transitive description: name: built_value - sha256: "169565c8ad06adb760c3645bf71f00bff161b00002cace266cad42c5d22a7725" + sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" url: "https://pub.dev" source: hosted - version: "8.4.3" + version: "8.6.1" characters: dependency: transitive description: @@ -117,10 +117,10 @@ packages: dependency: transitive description: name: checked_yaml - sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" clock: dependency: transitive description: @@ -133,10 +133,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189" url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.0" collection: dependency: transitive description: @@ -157,18 +157,18 @@ packages: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" dart_style: dependency: transitive description: name: dart_style - sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.3.2" fake_async: dependency: transitive description: @@ -181,18 +181,18 @@ packages: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted - version: "6.1.4" + version: "7.0.0" fixnum: dependency: transitive description: name: fixnum - sha256: "04be3e934c52e082558cc9ee21f42f5c1cd7a1262f4c63cd0357c08d5bba81ec" + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -202,10 +202,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -223,18 +223,18 @@ packages: dependency: transitive description: name: glob - sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" graphs: dependency: transitive description: name: graphs - sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.1" http_multi_server: dependency: transitive description: @@ -271,26 +271,26 @@ packages: dependency: transitive description: name: json_annotation - sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "4.8.1" lints: dependency: transitive description: name: lints - sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "2.1.1" logging: dependency: transitive description: name: logging - sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" matcher: dependency: transitive description: @@ -367,34 +367,34 @@ packages: dependency: transitive description: name: pub_semver - sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" pubspec_parse: dependency: transitive description: name: pubspec_parse - sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a" + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.3" shelf: dependency: transitive description: name: shelf - sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" simple_logger: dependency: "direct main" description: @@ -412,10 +412,10 @@ packages: dependency: transitive description: name: source_gen - sha256: c2bea18c95cfa0276a366270afaa2850b09b4a76db95d546f3d003dcc7011298 + sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16 url: "https://pub.dev" source: hosted - version: "1.2.7" + version: "1.4.0" source_span: dependency: transitive description: @@ -484,10 +484,10 @@ packages: dependency: transitive description: name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" uuid: dependency: "direct main" description: @@ -524,18 +524,18 @@ packages: dependency: transitive description: name: web_socket_channel - sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.4.0" yaml: dependency: transitive description: name: yaml - sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" sdks: dart: ">=3.1.0-185.0.dev <4.0.0" flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6775b22..f06d998 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: lime description: LIME Protocol for Dart/Flutter - A lightweight messaging library -version: 0.0.24 +version: 0.0.25 homepage: https://limeprotocol.org/ repository: https://github.com/takenet/lime-dart @@ -21,7 +21,7 @@ dev_dependencies: sdk: flutter mockito: ^5.1.0 build_runner: ^2.1.10 - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.2 # The following section is specific to Flutter packages. flutter: diff --git a/test/protocol/client/client_channel_test.dart b/test/protocol/client/client_channel_test.dart index 7c445e2..9b2c2a0 100644 --- a/test/protocol/client/client_channel_test.dart +++ b/test/protocol/client/client_channel_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:lime/lime.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; + import 'client_channel_test.mocks.dart'; @GenerateMocks( @@ -47,11 +48,13 @@ void main() { clientChannel.state = SessionState.authenticating; clientChannel.authenticateSession( - 'name@domain', - 'instance', - ExternalAuthentication( - token: 'eyJhbGciOiJSUzI1NiIsImtpZCI6IjRlY2RmZmV...', - issuer: 'account.blip.ai')); + 'name@domain', + 'instance', + ExternalAuthentication( + token: 'eyJhbGciOiJSUzI1NiIsImtpZCI6IjRlY2RmZmV...', + issuer: 'account.blip.ai', + ), + ); verify(mockWebSocketTransport.send(any)).called(1); }); });