@tern-secure/nextjs 1.8.6 → 1.8.7
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/app-router/client/providers/ternSecureClientProvider.d.ts +4 -4
- package/dist/app-router/client/providers/ternSecureClientProvider.js +4 -20
- package/dist/app-router/client/providers/ternSecureClientProvider.js.map +1 -1
- package/dist/hooks/useAuth.js +1 -5
- package/dist/hooks/useAuth.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
interface TernSecureClientProviderProps {
|
|
2
|
+
import { AuthState } from '../../../types/ternsecure';
|
|
3
|
+
interface TernSecureClientProps {
|
|
5
4
|
children: React.ReactNode;
|
|
5
|
+
initialState: AuthState;
|
|
6
6
|
}
|
|
7
|
-
export declare function TernSecureClientProvider({ children }:
|
|
7
|
+
export declare function TernSecureClientProvider({ children, initialState }: TernSecureClientProps): React.ReactNode;
|
|
8
8
|
export {};
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import { getTernSecureAuth } from '../client-init';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const context = useContext(TernSecureContext);
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw new Error('useTernSecure must be used within a TernSecureClientProvider');
|
|
9
|
-
}
|
|
10
|
-
return context;
|
|
11
|
-
};
|
|
12
|
-
export function TernSecureClientProvider({ children }) {
|
|
13
|
-
const [authState, setAuthState] = useState({
|
|
14
|
-
user: null,
|
|
15
|
-
loading: true,
|
|
16
|
-
error: null,
|
|
17
|
-
initialized: false
|
|
18
|
-
});
|
|
4
|
+
export function TernSecureClientProvider({ children, initialState }) {
|
|
5
|
+
const [authState, setAuthState] = useState(initialState);
|
|
19
6
|
useEffect(() => {
|
|
20
7
|
const auth = getTernSecureAuth();
|
|
21
8
|
const unsubscribe = auth.onAuthStateChanged((user) => {
|
|
@@ -25,9 +12,6 @@ export function TernSecureClientProvider({ children }) {
|
|
|
25
12
|
});
|
|
26
13
|
return () => unsubscribe();
|
|
27
14
|
}, []);
|
|
28
|
-
|
|
29
|
-
authState
|
|
30
|
-
};
|
|
31
|
-
return (React.createElement(TernSecureContext.Provider, { value: contextValue }, children));
|
|
15
|
+
return children;
|
|
32
16
|
}
|
|
33
17
|
//# sourceMappingURL=ternSecureClientProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternSecureClientProvider.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,
|
|
1
|
+
{"version":3,"file":"ternSecureClientProvider.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAQlD,MAAM,UAAU,wBAAwB,CAAC,EACvC,QAAQ,EACR,YAAY,EACU;IACtB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAY,YAAY,CAAC,CAAA;IAEnE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAA;QAChC,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CACzC,CAAC,IAAI,EAAE,EAAE;YACP,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QACxE,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACR,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QACxE,CAAC,CACF,CAAA;QAED,OAAO,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/hooks/useAuth.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useState
|
|
3
|
-
import { subscribeToAuthState } from '../app-router/client/ClientProvider';
|
|
2
|
+
import { useState } from 'react';
|
|
4
3
|
import { getTernSecureAuth } from '../app-router/client/client-init';
|
|
5
4
|
import { signInWithEmailAndPassword } from 'firebase/auth';
|
|
6
5
|
export function useAuth() {
|
|
@@ -10,9 +9,6 @@ export function useAuth() {
|
|
|
10
9
|
error: null,
|
|
11
10
|
initialized: false
|
|
12
11
|
});
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
return subscribeToAuthState(setAuthState);
|
|
15
|
-
}, []);
|
|
16
12
|
const auth = getTernSecureAuth();
|
|
17
13
|
const signIn = async (email, password) => {
|
|
18
14
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,QAAQ,EAAa,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,UAAU,OAAO;IACrB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAY;QACpD,IAAI,EAAE,IAAI;QACV,OA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