sveltedfire 0.1.18 → 0.1.19
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/sveltedfire/auth/authState.d.ts +1 -1
- package/dist/sveltedfire/auth/authState.js +6 -5
- package/dist/sveltedfire/components/PromptSignIn.svelte +1 -1
- package/dist/sveltedfire/components/SignedIn.svelte +1 -1
- package/dist/sveltedfire/components/SignedOut.svelte +1 -1
- package/dist/sveltedfire/components/SveltedAuth.svelte +5 -19
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type AuthSig } from './AuthSig.js';
|
|
2
|
-
export declare const authState:
|
|
2
|
+
export declare const authState: AuthSig;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { signOut } from './signOut.js';
|
|
2
|
+
import { signInWithGoogle } from './signInWithGoogle.js';
|
|
2
3
|
import {} from './AuthSig.js';
|
|
3
|
-
export const authState =
|
|
4
|
+
export const authState = $state({
|
|
4
5
|
currentUser: null,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
initialized: false,
|
|
7
|
+
signInWithGoogle,
|
|
8
|
+
signOut
|
|
8
9
|
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getAuth, type User } from 'firebase/auth'
|
|
3
|
-
import { signOut } from '../auth/signOut.js'
|
|
4
|
-
import { signInWithGoogle } from '../auth/signInWithGoogle.js'
|
|
5
|
-
import { type AuthSig } from '../auth/AuthSig.js';
|
|
6
3
|
import { authState } from '../auth/authState.js'
|
|
7
4
|
|
|
8
5
|
const { children, ...rest } = $props()
|
|
@@ -17,35 +14,24 @@
|
|
|
17
14
|
|
|
18
15
|
const auth = getAuth()
|
|
19
16
|
|
|
20
|
-
let fullAuth = $state<AuthSig>({
|
|
21
|
-
currentUser: null,
|
|
22
|
-
initialized: false,
|
|
23
|
-
signOut,
|
|
24
|
-
signInWithGoogle
|
|
25
|
-
})
|
|
26
|
-
|
|
27
17
|
auth.authStateReady().then(() => {
|
|
28
18
|
console.log('Received authStateReady')
|
|
29
|
-
|
|
30
|
-
authState.set(fullAuth)
|
|
19
|
+
authState.initialized = true
|
|
31
20
|
})
|
|
32
21
|
|
|
33
22
|
auth.onAuthStateChanged(user => {
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
authState.initialized = true
|
|
24
|
+
authState.currentUser = user
|
|
36
25
|
Object.keys(additionalKeys).forEach((k: string) => {
|
|
37
|
-
|
|
26
|
+
authState[k] = rest[additionalKeys[k]](null, null)
|
|
38
27
|
})
|
|
39
28
|
user?.getIdTokenResult().then(token => {
|
|
40
29
|
Object.keys(additionalKeys).forEach((k: string) => {
|
|
41
|
-
|
|
30
|
+
authState[k] = rest[additionalKeys[k]](user, token)
|
|
42
31
|
})
|
|
43
32
|
})
|
|
44
|
-
authState.set(fullAuth)
|
|
45
33
|
})
|
|
46
34
|
|
|
47
|
-
authState.set(fullAuth)
|
|
48
|
-
|
|
49
35
|
</script>
|
|
50
36
|
|
|
51
37
|
{@render children()}
|