@go-avro/avro-js 0.0.108 → 0.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/QueryClient.d.ts +2 -0
- package/dist/client/QueryClient.js +15 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -678,6 +678,8 @@ export declare class AvroQueryClient {
|
|
|
678
678
|
/** The install identity sent with sockets and location pings, if any. */
|
|
679
679
|
get device(): DeviceInfo | undefined;
|
|
680
680
|
setDevice(device: DeviceInfo | undefined): void;
|
|
681
|
+
/** Tell the server which install this live socket belongs to. */
|
|
682
|
+
private registerDevice;
|
|
681
683
|
emit(eventName: string, data: unknown): void;
|
|
682
684
|
on<T>(eventName: string, callback: (data: T) => void): void;
|
|
683
685
|
off(eventName: string, callback?: Function): void;
|
|
@@ -400,6 +400,7 @@ export class AvroQueryClient {
|
|
|
400
400
|
autoConnect: false,
|
|
401
401
|
transports: ['websocket'],
|
|
402
402
|
});
|
|
403
|
+
this.socket.on('connect', () => this.registerDevice());
|
|
403
404
|
config.authManager.isAuthenticated().then((isAuth) => {
|
|
404
405
|
this.setAuthState(isAuth);
|
|
405
406
|
if (!this.socket.connected && isAuth === AuthState.AUTHENTICATED) {
|
|
@@ -455,11 +456,17 @@ export class AvroQueryClient {
|
|
|
455
456
|
setDevice(device) {
|
|
456
457
|
this.config.device = device;
|
|
457
458
|
const auth = this.socket.auth;
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
459
|
+
if (auth?.token)
|
|
460
|
+
this.socket.auth = this.socketAuth(auth.token);
|
|
461
|
+
// Don't reconnect: a restart mid-handshake leaks the original
|
|
462
|
+
// connection. Declare the device on whatever socket is live now;
|
|
463
|
+
// the 'connect' handler repeats it on every (re)connect.
|
|
464
|
+
this.registerDevice();
|
|
465
|
+
}
|
|
466
|
+
/** Tell the server which install this live socket belongs to. */
|
|
467
|
+
registerDevice() {
|
|
468
|
+
if (this.config.device && this.socket.connected) {
|
|
469
|
+
this.socket.emit('register_device', this.config.device);
|
|
463
470
|
}
|
|
464
471
|
}
|
|
465
472
|
emit(eventName, data) {
|
|
@@ -618,7 +625,7 @@ export class AvroQueryClient {
|
|
|
618
625
|
}
|
|
619
626
|
loginSuccess(tokens) {
|
|
620
627
|
this.setAuthState(AuthState.AUTHENTICATED);
|
|
621
|
-
this.socket.auth =
|
|
628
|
+
this.socket.auth = this.socketAuth(tokens.access_token);
|
|
622
629
|
if (!this.socket.connected) {
|
|
623
630
|
this.socket.connect();
|
|
624
631
|
}
|
|
@@ -706,7 +713,7 @@ export class AvroQueryClient {
|
|
|
706
713
|
throw new StandardError(401, 'Invalid Google login response');
|
|
707
714
|
}
|
|
708
715
|
this.setAuthState(AuthState.AUTHENTICATED);
|
|
709
|
-
this.socket.auth =
|
|
716
|
+
this.socket.auth = this.socketAuth(resp.access_token);
|
|
710
717
|
if (!this.socket.connected) {
|
|
711
718
|
this.socket.connect();
|
|
712
719
|
}
|
|
@@ -737,7 +744,7 @@ export class AvroQueryClient {
|
|
|
737
744
|
throw new StandardError(401, 'Invalid Apple login response');
|
|
738
745
|
}
|
|
739
746
|
this.setAuthState(AuthState.AUTHENTICATED);
|
|
740
|
-
this.socket.auth =
|
|
747
|
+
this.socket.auth = this.socketAuth(resp.access_token);
|
|
741
748
|
if (!this.socket.connected) {
|
|
742
749
|
this.socket.connect();
|
|
743
750
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "0.0.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.0.109";
|
package/dist/version.js
CHANGED