@tern-secure/nextjs 1.5.8 → 1.6.0
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.
|
@@ -4,5 +4,7 @@ interface TernSecureClientProps {
|
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
initialState: AuthState;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare function TernSecureClientProvider({ children, initialState }: TernSecureClientProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const AuthStateContext: React.Context<AuthState | null>;
|
|
9
|
+
export declare function useAuthState(): AuthState;
|
|
8
10
|
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare function TernSecureProvider({ children }: {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import dynamic from 'next/dynamic';
|
|
3
|
-
import React, { useState, useEffect } from 'react';
|
|
4
1
|
import { getApps, initializeApp } from 'firebase/app';
|
|
5
2
|
import { getAuth } from 'firebase/auth';
|
|
6
3
|
import { getFirestore } from 'firebase/firestore';
|
|
7
4
|
import { getStorage } from 'firebase/storage';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
import React, { useState, useEffect } from 'react';
|
|
8
7
|
|
|
9
8
|
function getEnvVariable(name) {
|
|
10
9
|
const value = process.env[`NEXT_PUBLIC_FIREBASE_${name}`];
|
|
@@ -66,20 +65,7 @@ const getTernSecureStorage = () => {
|
|
|
66
65
|
return storage;
|
|
67
66
|
};
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
const TernSecureClientProvider$1 = dynamic(() => Promise.resolve().then(function () { return ternSecureClientProvider; }).then((mod) => mod.TernSecureClientProvider), { ssr: false });
|
|
71
|
-
function TernSecureProvider({ children }) {
|
|
72
|
-
const initialState = {
|
|
73
|
-
user: null,
|
|
74
|
-
loading: true,
|
|
75
|
-
error: null,
|
|
76
|
-
initialized: false
|
|
77
|
-
};
|
|
78
|
-
// Don't modify the HTML structure, just pass through
|
|
79
|
-
return (jsx(TernSecureClientProvider$1, { initialState: initialState, children: children }));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const TernSecureClientProvider = ({ children, initialState }) => {
|
|
68
|
+
function TernSecureClientProvider({ children, initialState }) {
|
|
83
69
|
const [authState, setAuthState] = useState(initialState);
|
|
84
70
|
useEffect(() => {
|
|
85
71
|
const auth = getTernSecureAuth();
|
|
@@ -90,23 +76,19 @@ const TernSecureClientProvider = ({ children, initialState }) => {
|
|
|
90
76
|
});
|
|
91
77
|
return () => unsubscribe();
|
|
92
78
|
}, []);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
// For other children, pass the authState
|
|
98
|
-
return React.Children.map(children, child => {
|
|
99
|
-
if (React.isValidElement(child)) {
|
|
100
|
-
return React.cloneElement(child, { authState });
|
|
101
|
-
}
|
|
102
|
-
return child;
|
|
103
|
-
});
|
|
104
|
-
};
|
|
79
|
+
return (jsx(AuthStateContext.Provider, { value: authState, children: children }));
|
|
80
|
+
}
|
|
81
|
+
const AuthStateContext = React.createContext(null);
|
|
105
82
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
83
|
+
function TernSecureProvider({ children }) {
|
|
84
|
+
const initialState = {
|
|
85
|
+
user: null,
|
|
86
|
+
loading: true,
|
|
87
|
+
error: null,
|
|
88
|
+
initialized: false
|
|
89
|
+
};
|
|
90
|
+
return (jsx(TernSecureClientProvider, { initialState: initialState, children: children }));
|
|
91
|
+
}
|
|
110
92
|
|
|
111
93
|
export { TernSecureProvider, getTernSecureAuth, getTernSecureFirestore, getTernSecureStorage, initializeTernSecure, loadFireConfig };
|
|
112
94
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/app-router/client/config.ts","../src/errors/index.ts","../src/app-router/client/client-init.ts","../src/app-router/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/app-router/client/config.ts","../src/errors/index.ts","../src/app-router/client/client-init.ts","../src/app-router/client/providers/ternSecureClientProvider.tsx","../src/app-router/server/providers/TernSecureServerProvider.tsx"],"sourcesContent":[null,null,null,null,null],"names":["_jsx"],"mappings":";;;;;;;AAEA,SAAS,cAAc,CAAC,IAAY,EAAA;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAwB,qBAAA,EAAA,IAAI,CAAE,CAAA,CAAC;IACzD,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,sDAAsD,IAAI,CAAA,CAAE,CAAC;;AAE/E,IAAA,OAAO,KAAK;AACd;AAEa,MAAA,cAAc,GAAqB;AAC9C,IAAA,MAAM,EAAE,cAAc,CAAC,SAAS,CAAC;AACjC,IAAA,UAAU,EAAE,cAAc,CAAC,aAAa,CAAC;AACzC,IAAA,SAAS,EAAE,cAAc,CAAC,YAAY,CAAC;AACvC,IAAA,aAAa,EAAE,cAAc,CAAC,gBAAgB,CAAC;AAC/C,IAAA,iBAAiB,EAAE,cAAc,CAAC,qBAAqB,CAAC;AACxD,IAAA,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC;;;AChB1B,MAAM,MAAM,GAAG;AAClB,IAAA,0BAA0B,EAAE,mDAAmD;AAC/E,IAAA,eAAe,EAAE,4EAA4E;IAC7F,YAAY,EAAE,CAAC,QAAgB,KAAK,CAAA,EAAG,QAAQ,CAAyC,uCAAA,CAAA;CAChF;AAEJ,MAAO,eAAgB,SAAQ,KAAK,CAAA;AACxC,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAA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