diff --git a/.pubnub.yml b/.pubnub.yml index 5a898846..59a84afa 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,10 @@ --- changelog: + - date: 2024-01-22 + version: v4.3.2 + changes: + - type: bug + text: "Fixes issue of getting signature mismatch exception while publishing encrypted data." - date: 2023-11-27 version: v4.3.1 changes: @@ -437,7 +442,7 @@ supported-platforms: platforms: - "Dart SDK >=2.6.0 <3.0.0" version: "PubNub Dart SDK" -version: "4.3.1" +version: "4.3.2" sdks: - full-name: PubNub Dart SDK diff --git a/pubnub/CHANGELOG.md b/pubnub/CHANGELOG.md index f16f60e4..0568a024 100644 --- a/pubnub/CHANGELOG.md +++ b/pubnub/CHANGELOG.md @@ -1,3 +1,9 @@ +## v4.3.2 +January 22 2024 + +#### Fixed +- Fixes issue of getting signature mismatch exception while publishing encrypted data. + ## v4.3.1 November 27 2023 diff --git a/pubnub/README.md b/pubnub/README.md index 3f108c7a..47d3a3e4 100644 --- a/pubnub/README.md +++ b/pubnub/README.md @@ -14,7 +14,7 @@ To add the package to your Dart or Flutter project, add `pubnub` as a dependency ```yaml dependencies: - pubnub: ^4.3.1 + pubnub: ^4.3.2 ``` After adding the dependency to `pubspec.yaml`, run the `dart pub get` command in the root directory of your project (the same that the `pubspec.yaml` is in). diff --git a/pubnub/lib/src/core/core.dart b/pubnub/lib/src/core/core.dart index e142b422..e2459e02 100644 --- a/pubnub/lib/src/core/core.dart +++ b/pubnub/lib/src/core/core.dart @@ -21,7 +21,7 @@ class Core { /// Internal module responsible for supervising. SupervisorModule supervisor = SupervisorModule(); - static String version = '4.3.1'; + static String version = '4.3.2'; Core( {Keyset? defaultKeyset, diff --git a/pubnub/lib/src/dx/_utils/signature.dart b/pubnub/lib/src/dx/_utils/signature.dart index da017c0a..f90b268a 100644 --- a/pubnub/lib/src/dx/_utils/signature.dart +++ b/pubnub/lib/src/dx/_utils/signature.dart @@ -38,7 +38,7 @@ String computeV2Signature( var encodedPathSegments = []; pathSegments.forEach( - (component) => encodedPathSegments.add(Uri.encodeFull(component))); + (component) => encodedPathSegments.add(encodePathSegament(component))); var plaintext = '''${type.method.toUpperCase()} ${keyset.publishKey} @@ -55,3 +55,6 @@ ${'$body' == 'null' ? '' : '$body'}'''; .replaceAll(RegExp(r'\/'), '_') .replaceAll(RegExp(r'\=*$'), ''); } + +String encodePathSegament(String pathSegment) => + Uri.encodeFull(pathSegment).replaceAll('/', '%2F').replaceAll('#', '%23'); diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index 8c730b00..bb48377b 100644 --- a/pubnub/pubspec.yaml +++ b/pubnub/pubspec.yaml @@ -1,6 +1,6 @@ name: pubnub description: PubNub SDK v5 for Dart lang (with Flutter support) that allows you to create real-time applications -version: 4.3.1 +version: 4.3.2 homepage: https://www.pubnub.com/docs/sdks/dart environment: diff --git a/pubnub/test/unit/dx/utils_test.dart b/pubnub/test/unit/dx/utils_test.dart index 8d28d4cd..abd44265 100644 --- a/pubnub/test/unit/dx/utils_test.dart +++ b/pubnub/test/unit/dx/utils_test.dart @@ -40,6 +40,25 @@ void main() { var body = 'test'; var expectedSign = 'v2.GtlYbLJgz5DjClB2Z2o47BbJngI7uQ3E07HUnL1NN3Q'; + var response = + computeV2Signature(keyset, requestType, path, queryParams, body); + expect(response, equals(expectedSign)); + }); + test('computeV2Signature should return valid signature when special characters included', () { + PubNub.version = '1.0.0'; + Core.version = '1.0.0'; + Time.mock(DateTime.fromMillisecondsSinceEpoch(1234567890000)); + var keyset = Keyset( + subscribeKey: 'test', + publishKey: 'test', + secretKey: 'test', + userId: UserId('test')); + var requestType = RequestType.post; + var queryParams = {'b': 'second', 'c': 'third', 'a': 'first'}; + var path = ['test', 'UE5FROJRyR0JX/51v9ktWH4ybF{}()*&^%@#a\$WReE3@#\$']; + var body = 'test'; + var expectedSign = 'v2.d-_yEq5ZA_T8GseWOKTWr8XS4suakWKTnESmfxMLw-E'; + var response = computeV2Signature(keyset, requestType, path, queryParams, body); expect(response, equals(expectedSign));