Skip to content

Commit

Permalink
Make v4.0.0 stable release (#72)
Browse files Browse the repository at this point in the history
feat: add PAM v3 support

Adds PAM v3 support with grantToken and setToken.

fix: change subscribe loop to no longer throw

Subscribe loop no longer throws on unrecoverable failure, instead waits for restart.

feat: add restore method to subscription

After subscribe loop fails, call restore to restart it.

fix: add more specific diagnostics

Adds more diagnostics for network module.

fix: change whenStarts to stream

WhenStarts future no longer throws and is now based on a stream.

fix: release resources on failure

Networking should now release all resources after a failure.

fix: Signature mismatch issue.

Fixes issue of Signature mismatch with PAM enabled keysets.

fix: Message decryption failure in subscribe.

Fixes issue of message decryption with subscription.
  • Loading branch information
are-pubnub authored Nov 22, 2021
1 parent 92599f2 commit 08af795
Show file tree
Hide file tree
Showing 40 changed files with 369 additions and 1,888 deletions.
21 changes: 20 additions & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
---
changelog:
- date: 2021-11-22
version: v4.0.0
changes:
- type: feature
text: "Adds PAM v3 support with `grantToken` and `setToken`."
- type: feature
text: "After subscribe loop fails, call restore to restart it."
- type: bug
text: "Subscribe loop no longer throws on unrecoverable failure, instead waits for restart."
- type: bug
text: "Adds more diagnostics for network module."
- type: bug
text: "WhenStarts future no longer throws and is now based on a stream."
- type: bug
text: "Networking should now release all resources after a failure."
- type: bug
text: "Fixes issue of Signature mismatch with PAM enabled keysets."
- type: bug
text: "Fixes issue of message decryption with subscription."
-
changes:
-
Expand Down Expand Up @@ -351,7 +370,7 @@ supported-platforms:
platforms:
- "Dart SDK >=2.6.0 <3.0.0"
version: "PubNub Dart SDK"
version: "3.1.0"
version: "4.0.0"
sdks:
-
full-name: PubNub Dart SDK
Expand Down
2 changes: 1 addition & 1 deletion acceptance_tests/bin/acceptance_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Future<void> main() async {
featureFiles:
env['FEATURES_PATH'] ?? '../../service-contract-mock/contract/features',
logger: logger,
tags: 'not @skip',
tags: 'not @skip and not @na=dart and not @beta',
);

var exitCode = 0;
Expand Down
15 changes: 15 additions & 0 deletions pubnub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## v4.0.0
November 22 2021

#### Added
- Adds PAM v3 support with `grantToken` and `setToken`.
- After subscribe loop fails, call restore to restart it.

#### Fixed
- Subscribe loop no longer throws on unrecoverable failure, instead waits for restart. Fixed the following issues reported by [@willbryant](https://github.com/willbryant): [#63](https://github.com/pubnub/dart/issues/63).
- Adds more diagnostics for network module. Fixed the following issues reported by [@willbryant](https://github.com/willbryant): [#65](https://github.com/pubnub/dart/issues/65).
- WhenStarts future no longer throws and is now based on a stream. Fixed the following issues reported by [@willbryant](https://github.com/willbryant): [#64](https://github.com/pubnub/dart/issues/64).
- Networking should now release all resources after a failure. Fixed the following issues reported by [@aadil058](https://github.com/aadil058): [#62](https://github.com/pubnub/dart/issues/62).
- Fixes issue of Signature mismatch with PAM enabled keysets. Fixed the following issues reported by [@mahmoudsalah37](https://github.com/mahmoudsalah37): [#50](https://github.com/pubnub/dart/issues/50).
- Fixes issue of message decryption with subscription. Fixed the following issues reported by [@TabooSun](https://github.com/TabooSun): [#46](https://github.com/pubnub/dart/issues/46).

## [v3.0.0](https://github.com/pubnub/dart/releases/tag/v3.0.0)
October 8 2020

Expand Down
3 changes: 2 additions & 1 deletion pubnub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To add the package to your Dart or Flutter project, add `pubnub` as a dependency

```yaml
dependencies:
pubnub: ^1.0.0
pubnub: ^4.0.0
```
After adding the dependency to `pubspec.yaml`, run the `pub get` command in the root directory of your project (the same that the `pubspec.yaml` is in).
Expand All @@ -27,6 +27,7 @@ If you want to use the latest, unreleased version of `pubnub`, you can add it to
dependencies:
pubnub:
git: git://github.com/pubnub/dart.git
path: pubnub
```

### Using a local copy of the repository
Expand Down
18 changes: 9 additions & 9 deletions pubnub/example/supervisor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:pubnub/logging.dart';
import 'package:pubnub/networking.dart';

void main() async {
var logger = StreamLogger.root('root', logLevel: Level.warning);
var logger = StreamLogger.root('root', logLevel: Level.all);

// Subscribe to messages with a default printer
logger.stream.listen(
Expand All @@ -18,27 +18,27 @@ void main() async {
);

print(
'Network reconnection test. Please wait few seconds for further instructions...');
'*\n*** Network reconnection test. Please wait few seconds for further instructions. You will see few diagnostic log lines in the meantime.\n*');

var sub = pubnub.subscribe(channels: {'test2'});
await provideLogger(logger, () async {
var sub = pubnub.subscribe(channels: {'test2'});

await Future.delayed(Duration(seconds: 5));
await Future.delayed(Duration(seconds: 5));

print('Subscribed. Disconnect your network for few seconds.');
print('*\n*** Subscribed. Disconnect your network for few seconds.\n*');

await Future.delayed(Duration(seconds: 5));
await Future.delayed(Duration(seconds: 5));

await provideLogger(logger, () async {
var f = pubnub.publish('test2', {'myMessage': 'it works!'});

print(
'Now reconnect your network again! If everything goes well, you should see the message. You will see few diagnostic log lines in the meantime.');
'*\n*** Now reconnect your network again! If everything goes well, you should see the message.\n*');

await f;

var message = await sub.messages.first;

print(message.payload);
print('*\n*** ${message.payload}\n*');

await sub.dispose();

Expand Down
2 changes: 1 addition & 1 deletion pubnub/lib/src/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Core {
/// Internal module responsible for supervising.
SupervisorModule supervisor = SupervisorModule();

static String version = '3.1.0';
static String version = '4.0.0';

Core(
{Keyset? defaultKeyset,
Expand Down
44 changes: 0 additions & 44 deletions pubnub/lib/src/networking/meta/diagnostics.dart

This file was deleted.

3 changes: 3 additions & 0 deletions pubnub/lib/src/networking/meta/diagnostics/diagnostics.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'stub.dart'
if (dart.library.io) 'io.dart'
if (dart.library.html) 'html.dart';
45 changes: 45 additions & 0 deletions pubnub/lib/src/networking/meta/diagnostics/html.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:pubnub/core.dart';

class HostIsDownDiagnostic extends Diagnostic {
final dynamic originalException;

const HostIsDownDiagnostic(this.originalException);
}

class HostLookupFailedDiagnostic extends Diagnostic {
final dynamic originalException;

const HostLookupFailedDiagnostic(this.originalException);
}

class UnknownHttpExceptionDiagnostic extends Diagnostic {
final dynamic originalException;

const UnknownHttpExceptionDiagnostic(this.originalException);
}

class TimeoutDiagnostic extends Diagnostic {
const TimeoutDiagnostic();
}

class AccessDeniedDiagnostic extends Diagnostic {
AccessDeniedDiagnostic();
}

Diagnostic? getNetworkDiagnostic(dynamic exception) {
if (exception is RequestOtherException) {
return UnknownHttpExceptionDiagnostic(exception);
}

if (exception is RequestTimeoutException) {
return TimeoutDiagnostic();
}

if (exception is RequestFailureException) {
var request = exception.response;

if (request.statusCode == 403) {
return AccessDeniedDiagnostic();
}
}
}
141 changes: 141 additions & 0 deletions pubnub/lib/src/networking/meta/diagnostics/io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import 'dart:io';
import 'package:pubnub/core.dart';

class HostIsDownDiagnostic extends Diagnostic {
final dynamic originalException;

const HostIsDownDiagnostic(this.originalException);
}

class HostLookupFailedDiagnostic extends Diagnostic {
final dynamic originalException;

const HostLookupFailedDiagnostic(this.originalException);
}

class UnknownHttpExceptionDiagnostic extends Diagnostic {
final dynamic originalException;

const UnknownHttpExceptionDiagnostic(this.originalException);
}

class TimeoutDiagnostic extends Diagnostic {
const TimeoutDiagnostic();
}

class AccessDeniedDiagnostic extends Diagnostic {
const AccessDeniedDiagnostic();
}

Diagnostic? getNetworkDiagnostic(dynamic exception) {
if (exception is RequestOtherException) {
var originalException = exception.additionalData;

if (originalException is SocketException) {
if (originalException.osError?.message ==
'nodename nor servname provided, or not known') {
return HostLookupFailedDiagnostic(originalException);
}

var errno = _getErrorCode(originalException.osError?.errorCode);

switch (errno) {
case _Errno.ECONNRESET:
case _Errno.ECONNABORTED:
case _Errno.ECONNREFUSED:
case _Errno.ETIMEOUT:
case _Errno.EHOSTUNREACH:
return HostIsDownDiagnostic(originalException);
case _Errno.EBADF:
case _Errno.ENETUNREACH:
case _Errno.unknown:
return UnknownHttpExceptionDiagnostic(originalException);
}
}

if (originalException is HttpException ||
originalException is HandshakeException) {
return UnknownHttpExceptionDiagnostic(originalException);
}
}

if (exception is RequestTimeoutException) {
return TimeoutDiagnostic();
}

if (exception is RequestFailureException) {
var request = exception.response;

if (request.statusCode == 403) {
return AccessDeniedDiagnostic();
}
}
}

enum _Errno {
unknown,
ECONNABORTED,
ECONNRESET,
ECONNREFUSED,
EHOSTUNREACH,
EBADF,
ETIMEOUT,
ENETUNREACH
}

_Errno _getErrorCode(int? errno) {
if (errno == null) {
return _Errno.unknown;
}

if (Platform.isLinux) {
return _linuxErrnoCodes[errno] ?? _Errno.unknown;
} else if (Platform.isWindows) {
return _winErrnoCodes[errno] ?? _Errno.unknown;
} else if (Platform.isMacOS || Platform.isIOS) {
return _macErrnoCodes[errno] ?? _Errno.unknown;
} else if (Platform.isAndroid) {
return _androidErrnoCodes[errno] ?? _Errno.unknown;
} else {
return _Errno.unknown;
}
}

const _linuxErrnoCodes = {
9: _Errno.EBADF,
101: _Errno.ENETUNREACH,
103: _Errno.ECONNABORTED,
104: _Errno.ECONNRESET,
110: _Errno.ETIMEOUT,
111: _Errno.ECONNREFUSED,
113: _Errno.EHOSTUNREACH,
};

const _winErrnoCodes = {
9: _Errno.EBADF,
106: _Errno.ECONNABORTED,
107: _Errno.ECONNREFUSED,
108: _Errno.ECONNRESET,
110: _Errno.EHOSTUNREACH,
118: _Errno.ENETUNREACH,
138: _Errno.ETIMEOUT
};

const _macErrnoCodes = {
9: _Errno.EBADF,
51: _Errno.ENETUNREACH,
53: _Errno.ECONNABORTED,
54: _Errno.ECONNRESET,
60: _Errno.ETIMEOUT,
61: _Errno.ECONNREFUSED,
65: _Errno.EHOSTUNREACH
};

const _androidErrnoCodes = {
9: _Errno.EBADF,
111: _Errno.ECONNREFUSED,
113: _Errno.ECONNABORTED,
114: _Errno.ENETUNREACH,
116: _Errno.ETIMEOUT,
118: _Errno.EHOSTUNREACH
};
Loading

0 comments on commit 08af795

Please sign in to comment.