Skip to content

Commit

Permalink
cleanup and doc change
Browse files Browse the repository at this point in the history
  • Loading branch information
KammererTob committed Jul 6, 2023
1 parent 8cfe783 commit ffe33ff
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ as binary data. The resulting `StompFrame` will have a `binaryBody`. The `body`
frame will be empty in this case. The same is true if the `content-type` header is
missing.

## Token Authentication (browser-based clients)

Browser clients can only use standard authentication headers (that is, basic HTTP authentication) or cookies and [cannot provide custom headers](https://github.com/whatwg/websockets/issues/16#issuecomment-332065542) (such as "Authorization" to use a Bearer token). Thus `webSocketConnectHeaders` will do nothing in a browser environment.
Alternatives are:
- Use the STOMP client to pass authentication headers at connect time. (recommended)
- Use `stompConnectHeaders` to pass your headers in the `CONNECT` frame. Parse those headers on the server (i.e. by using a `ChannelInterceptor` in Spring)
- Pass your authentication token/credentials as query parameter.

## Development

#### Running unit tests
Expand Down
3 changes: 1 addition & 2 deletions lib/stomp_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class StompParser implements Parser {
} else if (data is List<int>) {
byteList = Uint8List.fromList(data);
} else {
throw UnsupportedError(
'Input data type unsupported ${data.runtimeType}');
throw UnsupportedError('Input data type unsupported ${data.runtimeType}');
}

for (var i = 0; i < byteList.length; i++) {
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ homepage: https://github.com/blackhorse-one/stomp_dart
version: 0.4.4
description: Dart STOMP client for easy messaging interoperability. Build with flutter in mind, but should work for every dart application.
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"

dependencies:
web_socket_channel: ^2.0.0

dev_dependencies:
test: ^1.16.5
lints: ^2.0.0
stream_channel: ^2.1.0
test: ^1.23.1
lints: ^2.0.1
stream_channel: ^2.1.1
8 changes: 6 additions & 2 deletions test/stomp_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ void main() {
count: 2,
);

StompParser(onFrame)..parseData(msg)..parseData(msg2);
StompParser(onFrame)
..parseData(msg)
..parseData(msg2);
});

test('can parse multiple messages at once', () {
Expand Down Expand Up @@ -455,7 +457,9 @@ void main() {
count: 2,
);

StompParser(callback)..parseData(msg)..parseData(msg2);
StompParser(callback)
..parseData(msg)
..parseData(msg2);
});

group('when content-type is missing', () {
Expand Down
5 changes: 0 additions & 5 deletions test/stomp_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:test/test.dart';
void main() {
group('StompClient', () {
late StompConfig config;
StompHandler? handler;
late StreamChannel streamChannel;

setUpAll(() async {
Expand Down Expand Up @@ -78,10 +77,6 @@ void main() {
);
});

tearDown(() async {
handler?.dispose();
});

tearDownAll(() async {
await streamChannel.sink.close();
});
Expand Down

0 comments on commit ffe33ff

Please sign in to comment.