@tern-secure/nextjs 1.9.2 → 1.9.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/dist/app-router/client/providers/ternSecureClientProvider.d.ts +2 -2
- package/dist/app-router/client/providers/ternSecureClientProvider.js +62 -35
- package/dist/app-router/client/providers/ternSecureClientProvider.js.map +1 -1
- package/dist/app-router/client/providers/ternSecureContext.d.ts +1 -6
- package/dist/app-router/client/providers/ternSecureContext.js +9 -4
- package/dist/app-router/client/providers/ternSecureContext.js.map +1 -1
- package/dist/app-router/server/providers/TernSecureServerProvider.js +1 -1
- package/dist/app-router/server/providers/TernSecureServerProvider.js.map +1 -1
- package/dist/hooks/useAuth.d.ts +0 -1
- package/dist/hooks/useAuth.js +0 -2
- package/dist/hooks/useAuth.js.map +1 -1
- package/dist/types/ternsecure.d.ts +8 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const useTernSecure: () =>
|
|
2
|
+
import { TernSecureState } from '../../../types/ternsecure';
|
|
3
|
+
export declare const useTernSecure: () => TernSecureState;
|
|
4
4
|
interface TernSecureClientProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
@@ -3,14 +3,19 @@ import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
|
3
3
|
import { getTernSecureAuth } from '../client-init';
|
|
4
4
|
// Move context creation inside the client component
|
|
5
5
|
const createTernSecureContext = () => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const initialState = {
|
|
7
|
+
firebase: {
|
|
8
|
+
initialized: false,
|
|
9
|
+
error: null
|
|
10
|
+
},
|
|
11
|
+
auth: {
|
|
12
|
+
user: null,
|
|
13
|
+
loading: true,
|
|
14
|
+
error: null,
|
|
15
|
+
isSignedIn: false
|
|
16
|
+
}
|
|
12
17
|
};
|
|
13
|
-
return createContext(
|
|
18
|
+
return createContext(initialState);
|
|
14
19
|
};
|
|
15
20
|
// Create context lazily only on client side
|
|
16
21
|
const TernSecureContext = createTernSecureContext();
|
|
@@ -25,45 +30,67 @@ export const useTernSecure = () => {
|
|
|
25
30
|
return context;
|
|
26
31
|
};
|
|
27
32
|
export function TernSecureClientProvider({ children }) {
|
|
28
|
-
const [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const [state, setState] = useState({
|
|
34
|
+
firebase: {
|
|
35
|
+
initialized: false,
|
|
36
|
+
error: null
|
|
37
|
+
},
|
|
38
|
+
auth: {
|
|
39
|
+
user: null,
|
|
40
|
+
loading: true,
|
|
41
|
+
error: null,
|
|
42
|
+
isSignedIn: false
|
|
43
|
+
}
|
|
34
44
|
});
|
|
35
45
|
useEffect(() => {
|
|
36
46
|
try {
|
|
37
47
|
const auth = getTernSecureAuth();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
loading: false,
|
|
42
|
-
error: null,
|
|
48
|
+
setState(prev => ({
|
|
49
|
+
...prev,
|
|
50
|
+
firebase: {
|
|
43
51
|
initialized: true,
|
|
44
|
-
|
|
45
|
-
}
|
|
52
|
+
error: null
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
const unsubscribe = auth.onAuthStateChanged((user) => {
|
|
56
|
+
setState(prev => ({
|
|
57
|
+
...prev,
|
|
58
|
+
auth: {
|
|
59
|
+
user,
|
|
60
|
+
loading: false,
|
|
61
|
+
error: null,
|
|
62
|
+
isSignedIn: !!user
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
46
65
|
}, (error) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
setState(prev => ({
|
|
67
|
+
...prev,
|
|
68
|
+
auth: {
|
|
69
|
+
user: null,
|
|
70
|
+
loading: false,
|
|
71
|
+
error,
|
|
72
|
+
isSignedIn: false
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
54
75
|
});
|
|
55
76
|
return () => unsubscribe();
|
|
56
77
|
}
|
|
57
78
|
catch (error) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
setState(prev => ({
|
|
80
|
+
...prev,
|
|
81
|
+
firebase: {
|
|
82
|
+
initialized: false,
|
|
83
|
+
error: error
|
|
84
|
+
},
|
|
85
|
+
auth: {
|
|
86
|
+
user: null,
|
|
87
|
+
loading: false,
|
|
88
|
+
error: error,
|
|
89
|
+
isSignedIn: false
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
65
92
|
}
|
|
66
93
|
}, []);
|
|
67
|
-
return (React.createElement(TernSecureContext.Provider, { value:
|
|
94
|
+
return (React.createElement(TernSecureContext.Provider, { value: state }, children));
|
|
68
95
|
}
|
|
69
96
|
//# 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,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGlD,oDAAoD;AACpD,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,MAAM,
|
|
1
|
+
{"version":3,"file":"ternSecureClientProvider.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,O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CACkB,CAC9B,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type TernSecureContextType = {
|
|
3
|
-
state: AuthState;
|
|
4
|
-
setState: React.Dispatch<React.SetStateAction<AuthState>>;
|
|
5
|
-
};
|
|
6
|
-
export declare const TernSecureContext: import("react").Context<TernSecureContextType | null>;
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
const TernSecureContext = React.createContext(null);
|
|
3
|
+
const useTernSecure = () => {
|
|
4
|
+
const context = React.useContext(TernSecureContext);
|
|
5
|
+
if (context === null) {
|
|
6
|
+
throw new Error('useAuthState must be used within a TernSecureClientProvider');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
5
10
|
//# sourceMappingURL=ternSecureContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternSecureContext.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ternSecureContext.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAA;AAErE,MAAO,aAAa,GAAG,GAAG,EAAE;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACnD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;IAChF,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import dynamic from 'next/dynamic';
|
|
3
3
|
// Dynamically import the client provider with no SSR
|
|
4
4
|
const TernSecureClientProvider = dynamic(() => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider), {
|
|
5
|
-
ssr: false,
|
|
5
|
+
//ssr: false,
|
|
6
6
|
loading: () => null // Return null or a loading indicator
|
|
7
7
|
});
|
|
8
8
|
export function TernSecureProvider({ children }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureServerProvider.js","sourceRoot":"","sources":["../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAA;AAMlC,qDAAqD;AACrD,MAAM,wBAAwB,GAAG,OAAO,CACtC,GAAG,EAAE,CAAC,MAAM,CAAC,iDAAiD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,wBAAwB,CAAC,EACzG;IACE,
|
|
1
|
+
{"version":3,"file":"TernSecureServerProvider.js","sourceRoot":"","sources":["../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAA;AAMlC,qDAAqD;AACrD,MAAM,wBAAwB,GAAG,OAAO,CACtC,GAAG,EAAE,CAAC,MAAM,CAAC,iDAAiD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,wBAAwB,CAAC,EACzG;IACE,aAAa;IACb,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,qCAAqC;CAC1D,CACF,CAAA;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAA2B;IACtE,+CAA+C;IAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CACxD,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAC9D,CAAC;IAEF,IAAI,YAAY,EAAE,CAAC;QACjB,qEAAqE;QACrE,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;YAC1C,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzD,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EACjC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE;oBACnD,IAAI,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;wBACjE,wCAAwC;wBACxC,MAAM,SAAS,GAAG,SAAS,CAAC,KAAgC,CAAC;wBAC7D,OAAO,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,EACrC,oBAAC,wBAAwB,QACtB,SAAS,CAAC,QAAQ,CACM,CAC5B,CAAC;oBACJ,CAAC;oBACD,OAAO,SAAS,CAAC;gBACnB,CAAC,CAAC,CACH,CAAC;YACJ,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,sCAAsC;IACtC,OAAO,oBAAC,wBAAwB,QAAE,QAAQ,CAA4B,CAAC;AACzE,CAAC"}
|
package/dist/hooks/useAuth.d.ts
CHANGED
package/dist/hooks/useAuth.js
CHANGED
|
@@ -5,14 +5,12 @@ export function useAuth() {
|
|
|
5
5
|
user: null,
|
|
6
6
|
loading: true,
|
|
7
7
|
error: null,
|
|
8
|
-
initialized: false,
|
|
9
8
|
isSignedIn: false,
|
|
10
9
|
});
|
|
11
10
|
return {
|
|
12
11
|
user: authState.user,
|
|
13
12
|
loading: authState.loading,
|
|
14
13
|
error: authState.error,
|
|
15
|
-
initialized: authState.initialized,
|
|
16
14
|
isSignedIn: authState.isSignedIn,
|
|
17
15
|
};
|
|
18
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,UAAU,OAAO;IACrB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAY;QACpD,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;QACX,
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,UAAU,OAAO;IACrB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAY;QACpD,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAGH,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,UAAU,EAAE,SAAS,CAAC,UAAU;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -13,11 +13,18 @@ export interface TernSecureOptions {
|
|
|
13
13
|
environment?: 'development' | 'production';
|
|
14
14
|
region?: string;
|
|
15
15
|
}
|
|
16
|
+
export interface FirebaseState {
|
|
17
|
+
initialized: boolean;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
}
|
|
20
|
+
export interface TernSecureState {
|
|
21
|
+
firebase: FirebaseState;
|
|
22
|
+
auth: AuthState;
|
|
23
|
+
}
|
|
16
24
|
export interface AuthState {
|
|
17
25
|
user: User | null;
|
|
18
26
|
loading: boolean;
|
|
19
27
|
error: Error | null;
|
|
20
|
-
initialized: boolean;
|
|
21
28
|
isSignedIn: boolean;
|
|
22
29
|
}
|
|
23
30
|
export interface TernSecureContextValue {
|