favalib 0.0.3 → 0.0.4
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/build/TwoFaLib.d.mts
CHANGED
|
@@ -75,11 +75,6 @@ declare class TwoFaLib extends TypedEventTarget<TwoFaLibEventMapEvents> {
|
|
|
75
75
|
* @param force - Force setting the sync server url, even if no connection can be made
|
|
76
76
|
*/
|
|
77
77
|
setSyncServerUrl(serverUrl: string, force?: boolean): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Sets the sync state, this will initiate the sync manager instance.
|
|
80
|
-
* @param syncState - The state of the sync.
|
|
81
|
-
*/
|
|
82
|
-
private setSyncState;
|
|
83
78
|
/**
|
|
84
79
|
* Dispatches a library event.
|
|
85
80
|
* @param eventType - The type of the event to dispatch, uses the TwoFaLibEvent enum.
|
package/build/TwoFaLib.mjs
CHANGED
|
@@ -72,7 +72,8 @@ class TwoFaLib extends TypedEventTarget {
|
|
|
72
72
|
this.mediator.getComponent('vaultDataManager').replaceVault(vault);
|
|
73
73
|
}
|
|
74
74
|
if (syncState?.serverUrl) {
|
|
75
|
-
|
|
75
|
+
// Initiate the syncManager
|
|
76
|
+
this.mediator.registerComponent('syncManager', new SyncManager(this.mediator, this.deviceType, this.publicKey, this.privateKey, syncState, this.deviceId));
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
79
|
// If no syncmanager we're ready now, otherwise the syncmanager is responsible for emitting the ready event
|
|
@@ -180,13 +181,6 @@ class TwoFaLib extends TypedEventTarget {
|
|
|
180
181
|
this.mediator.registerComponent('syncManager', newSyncManager);
|
|
181
182
|
await this.forceSave();
|
|
182
183
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Sets the sync state, this will initiate the sync manager instance.
|
|
185
|
-
* @param syncState - The state of the sync.
|
|
186
|
-
*/
|
|
187
|
-
setSyncState(syncState) {
|
|
188
|
-
this.mediator.registerComponent('syncManager', new SyncManager(this.mediator, this.deviceType, this.publicKey, this.privateKey, syncState, this.deviceId));
|
|
189
|
-
}
|
|
190
184
|
/**
|
|
191
185
|
* Dispatches a library event.
|
|
192
186
|
* @param eventType - The type of the event to dispatch, uses the TwoFaLibEvent enum.
|
|
@@ -61,7 +61,7 @@ class SyncManager {
|
|
|
61
61
|
this.serverUrl = serverUrl;
|
|
62
62
|
this.initServerConnection();
|
|
63
63
|
// if not yet connected after 2 tries, emit ready event so we can continue
|
|
64
|
-
setTimeout(() => {
|
|
64
|
+
this.connectionFailedTimeout = setTimeout(() => {
|
|
65
65
|
if (!this.readyEventEmitted && !this.webSocketConnected) {
|
|
66
66
|
this.log('warning', 'Failed to connect to sync backend');
|
|
67
67
|
this.dispatchLibEvent(TwoFaLibEvent.Ready);
|
|
@@ -142,6 +142,8 @@ class SyncManager {
|
|
|
142
142
|
this.dispatchLibEvent(TwoFaLibEvent.ConnectionToSyncServerStatusChanged, {
|
|
143
143
|
newStatus: ConnectionStatus.CONNECTED,
|
|
144
144
|
});
|
|
145
|
+
clearTimeout(this.connectionFailedTimeout);
|
|
146
|
+
this.connectionFailedTimeout = undefined;
|
|
145
147
|
// send any commands that were done while offline
|
|
146
148
|
void this.processCommandSendQueue();
|
|
147
149
|
});
|