File tree 2 files changed +14
-26
lines changed
2 files changed +14
-26
lines changed Original file line number Diff line number Diff line change @@ -410,36 +410,18 @@ class RealtimeClient {
410
410
final tokenToSend =
411
411
token ?? (await customAccessToken? .call ()) ?? accessToken;
412
412
413
- if (tokenToSend != null ) {
414
- Map <String , dynamic >? parsed;
415
- try {
416
- final decoded =
417
- base64.decode (base64.normalize (tokenToSend.split ('.' )[1 ]));
418
- parsed = json.decode (utf8.decode (decoded));
419
- } catch (e) {
420
- // ignore parsing errors
421
- }
422
- if (parsed != null && parsed['exp' ] != null ) {
423
- final now = (DateTime .now ().millisecondsSinceEpoch / 1000 ).floor ();
424
- final valid = now - parsed['exp' ] < 0 ;
425
- if (! valid) {
426
- log (
427
- 'auth' ,
428
- 'InvalidJWTToken: Invalid value for JWT claim "exp" with value ${parsed ['exp' ]}' ,
429
- null ,
430
- Level .FINE ,
431
- );
432
- throw FormatException (
433
- 'InvalidJWTToken: Invalid value for JWT claim "exp" with value ${parsed ['exp' ]}' );
434
- }
435
- }
413
+ if (accessToken == tokenToSend) {
414
+ return ;
436
415
}
437
416
438
417
accessToken = tokenToSend;
439
418
440
419
for (final channel in channels) {
441
420
if (tokenToSend != null ) {
442
- channel.updateJoinPayload ({'access_token' : tokenToSend});
421
+ channel.updateJoinPayload ({
422
+ 'access_token' : tokenToSend,
423
+ 'version' : Constants .defaultHeaders['X-Client-Info' ],
424
+ });
443
425
}
444
426
if (channel.joinedOnce && channel.isJoined) {
445
427
channel.push (ChannelEvents .accessToken, {'access_token' : tokenToSend});
Original file line number Diff line number Diff line change @@ -453,7 +453,10 @@ void main() {
453
453
454
454
group ('setAuth' , () {
455
455
final token = generateJwt ();
456
- final updateJoinPayload = {'access_token' : token};
456
+ final updateJoinPayload = {
457
+ 'access_token' : token,
458
+ 'version' : Constants .defaultHeaders['X-Client-Info' ],
459
+ };
457
460
final pushPayload = {'access_token' : token};
458
461
459
462
test (
@@ -534,7 +537,10 @@ void main() {
534
537
535
538
const token = 'sb-key' ;
536
539
final pushPayload = {'access_token' : token};
537
- final updateJoinPayload = {'access_token' : token};
540
+ final updateJoinPayload = {
541
+ 'access_token' : token,
542
+ 'version' : Constants .defaultHeaders['X-Client-Info' ],
543
+ };
538
544
539
545
await mockedSocket.setAuth (token);
540
546
You can’t perform that action at this time.
0 commit comments