@thzero/library_client_firebase 0.16.15 → 0.17.2
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/boot/starter.js +3 -3
- package/package.json +6 -8
- package/service/index.js +8 -8
package/boot/starter.js
CHANGED
|
@@ -2,9 +2,9 @@ import { initializeApp } from 'firebase/app';
|
|
|
2
2
|
import { getAuth } from "firebase/auth";
|
|
3
3
|
import { getAnalytics } from "firebase/analytics";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import LibraryClientConstants from '@thzero/library_client/constants';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import LibrartyClientUtility from '@thzero/library_client/utility/index';
|
|
8
8
|
|
|
9
9
|
import config from 'local-config';
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ export default (setup) => {
|
|
|
31
31
|
// eslint-disable-next-line
|
|
32
32
|
let init = false;
|
|
33
33
|
firebaseAuth.onAuthStateChanged(async function(user) {
|
|
34
|
-
const auth =
|
|
34
|
+
const auth = LibrartyClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_AUTH);
|
|
35
35
|
await auth.onAuthStateChanged(user);
|
|
36
36
|
if (!init) {
|
|
37
37
|
init = true;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_client_firebase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"version_major": 0,
|
|
5
|
-
"version_minor":
|
|
6
|
-
"version_patch":
|
|
7
|
-
"version_date": "
|
|
5
|
+
"version_minor": 17,
|
|
6
|
+
"version_patch": 2,
|
|
7
|
+
"version_date": "02/03/2023",
|
|
8
8
|
"author": "thZero",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -23,9 +23,7 @@
|
|
|
23
23
|
"firebase": "^9.16.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@thzero/library_client": "^0.
|
|
27
|
-
"@thzero/
|
|
28
|
-
"@thzero/library_client_vue3": "^0.16",
|
|
29
|
-
"@thzero/library_common": "^0.16"
|
|
26
|
+
"@thzero/library_client": "^0.17",
|
|
27
|
+
"@thzero/library_common": "^0.17"
|
|
30
28
|
}
|
|
31
29
|
}
|
package/service/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// import 'firebase/auth';
|
|
3
3
|
import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import LibraryClientConstants from '@thzero/library_client/constants';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import LibraryCommonUtility from '@thzero/library_common/utility';
|
|
8
8
|
|
|
9
9
|
import UserAuthService from '@thzero/library_client/service/auth/user';
|
|
10
10
|
|
|
@@ -36,12 +36,12 @@ class FirebaseAuthService extends UserAuthService {
|
|
|
36
36
|
async init(injector) {
|
|
37
37
|
await super.init(injector);
|
|
38
38
|
|
|
39
|
-
this._serviceRouter = this._injector.getService(
|
|
39
|
+
this._serviceRouter = this._injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_ROUTER);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
get externalUser() {
|
|
43
43
|
const user = getAuth().currentUser;
|
|
44
|
-
this._logger.debug('FirebaseAuthService', 'tokenUser', 'user', user,
|
|
44
|
+
this._logger.debug('FirebaseAuthService', 'tokenUser', 'user', user, LibraryCommonUtility.generateId());
|
|
45
45
|
return user;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -56,14 +56,14 @@ class FirebaseAuthService extends UserAuthService {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
async onAuthStateChanged(user) {
|
|
59
|
-
const correlationId =
|
|
59
|
+
const correlationId = LibraryCommonUtility.generateId();
|
|
60
60
|
try {
|
|
61
61
|
await this.updateExternalUser(correlationId, user, true);
|
|
62
62
|
// if (!user)
|
|
63
63
|
// return
|
|
64
64
|
|
|
65
65
|
await this._serviceUser.setAuthCompleted(correlationId, true);
|
|
66
|
-
this._serviceEvent.emit(
|
|
66
|
+
this._serviceEvent.emit(LibraryClientConstants.EventKeys.Auth.Refresh, user);
|
|
67
67
|
}
|
|
68
68
|
catch (err) {
|
|
69
69
|
this._logger.exception('FirebaseAuthService', 'onAuthStateChanged', err, correlationId);
|
|
@@ -212,8 +212,8 @@ class FirebaseAuthService extends UserAuthService {
|
|
|
212
212
|
|
|
213
213
|
this.announceToken(correlationId, user, token);
|
|
214
214
|
|
|
215
|
-
const expired =
|
|
216
|
-
const now =
|
|
215
|
+
const expired = LibraryCommonUtility.getDateParse(tokenResult.expirationTime);
|
|
216
|
+
const now = LibraryCommonUtility.getDate();
|
|
217
217
|
const diff = expired.diff(now);
|
|
218
218
|
const min = 5 * 60 * 1000;
|
|
219
219
|
if (diff <= min) {
|