@tern-secure/nextjs 1.9.5 → 1.9.6
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 +0 -2
- package/dist/app-router/client/providers/ternSecureClientProvider.js +3 -36
- package/dist/app-router/client/providers/ternSecureClientProvider.js.map +1 -1
- package/dist/app-router/client/providers/ternSecureContext.d.ts +5 -6
- package/dist/app-router/client/providers/ternSecureContext.js +37 -7
- package/dist/app-router/client/providers/ternSecureContext.js.map +1 -1
- package/dist/hooks/useAuth.js +2 -2
- package/dist/hooks/useAuth.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TernSecureState } from '../../../types/ternsecure';
|
|
3
|
-
export declare const useTernSecure: () => [TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>];
|
|
4
2
|
interface TernSecureClientProps {
|
|
5
3
|
children: React.ReactNode;
|
|
6
4
|
}
|
|
@@ -1,41 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React, {
|
|
3
|
-
|
|
4
|
-
const initialState = {
|
|
5
|
-
firebase: {
|
|
6
|
-
initialized: false,
|
|
7
|
-
error: null
|
|
8
|
-
},
|
|
9
|
-
auth: {
|
|
10
|
-
user: null,
|
|
11
|
-
loading: true,
|
|
12
|
-
error: null,
|
|
13
|
-
isSignedIn: false
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
return createContext([initialState, () => { }]);
|
|
17
|
-
};
|
|
18
|
-
const TernSecureContext = createTernSecureContext();
|
|
19
|
-
export const useTernSecure = () => {
|
|
20
|
-
const context = useContext(TernSecureContext);
|
|
21
|
-
if (!context) {
|
|
22
|
-
throw new Error('useTernSecure must be used within TernSecureClientProvider');
|
|
23
|
-
}
|
|
24
|
-
return context;
|
|
25
|
-
};
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { initialState, TernSecureContext } from './ternSecureContext';
|
|
26
4
|
export function TernSecureClientProvider({ children }) {
|
|
27
|
-
const stateAndUpdater = useState(
|
|
28
|
-
firebase: {
|
|
29
|
-
initialized: false,
|
|
30
|
-
error: null
|
|
31
|
-
},
|
|
32
|
-
auth: {
|
|
33
|
-
user: null,
|
|
34
|
-
loading: true,
|
|
35
|
-
error: null,
|
|
36
|
-
isSignedIn: false
|
|
37
|
-
}
|
|
38
|
-
});
|
|
5
|
+
const stateAndUpdater = useState(initialState);
|
|
39
6
|
return (React.createElement(TernSecureContext.Provider, { value: stateAndUpdater }, children));
|
|
40
7
|
}
|
|
41
8
|
//# 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,
|
|
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,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAQrE,MAAM,UAAU,wBAAwB,CAAC,EAAE,QAAQ,EAAyB;IAC1E,MAAM,eAAe,GAAG,QAAQ,CAAkB,YAAY,CAAC,CAAA;IAE/D,OAAO,CACL,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,IAC/C,QAAQ,CACkB,CAC9B,CAAA;AACH,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { TernSecureContextProvider, useTernSecure, };
|
|
2
|
+
import { TernSecureState } from '../../../types/ternsecure';
|
|
3
|
+
declare const TernSecureContext: React.Context<[TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>]>;
|
|
4
|
+
declare const useTernSecure: (hookname?: string) => [TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>];
|
|
5
|
+
export declare const initialState: TernSecureState;
|
|
6
|
+
export { TernSecureContext, useTernSecure };
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
const createTernSecureContext = () => {
|
|
4
|
+
const initialState = {
|
|
5
|
+
firebase: {
|
|
6
|
+
initialized: false,
|
|
7
|
+
error: null
|
|
8
|
+
},
|
|
9
|
+
auth: {
|
|
10
|
+
user: null,
|
|
11
|
+
loading: true,
|
|
12
|
+
error: null,
|
|
13
|
+
isSignedIn: false
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return createContext([initialState, () => { }]);
|
|
17
|
+
};
|
|
18
|
+
// Create context instance only when imported on client
|
|
19
|
+
const TernSecureContext = createTernSecureContext();
|
|
20
|
+
const useTernSecure = (hookname) => {
|
|
21
|
+
const context = useContext(TernSecureContext);
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw new Error(`${hookname} must be used within TernSecureProvider`);
|
|
24
|
+
}
|
|
5
25
|
return context;
|
|
6
26
|
};
|
|
7
|
-
|
|
8
|
-
|
|
27
|
+
// Export initial state for reuse
|
|
28
|
+
export const initialState = {
|
|
29
|
+
firebase: {
|
|
30
|
+
initialized: false,
|
|
31
|
+
error: null
|
|
32
|
+
},
|
|
33
|
+
auth: {
|
|
34
|
+
user: null,
|
|
35
|
+
loading: true,
|
|
36
|
+
error: null,
|
|
37
|
+
isSignedIn: false
|
|
38
|
+
}
|
|
9
39
|
};
|
|
10
|
-
export {
|
|
40
|
+
export { TernSecureContext, useTernSecure };
|
|
11
41
|
//# sourceMappingURL=ternSecureContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternSecureContext.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ternSecureContext.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGxD,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,MAAM,YAAY,GAAoB;QACpC,QAAQ,EAAE;YACR,WAAW,EAAE,KAAK;YAClB,KAAK,EAAE,IAAI;SACZ;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,KAAK;SAClB;KACF,CAAA;IAED,OAAO,aAAa,CAA2E,CAAC,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAA;AAC1H,CAAC,CAAA;AAED,uDAAuD;AACvD,MAAM,iBAAiB,GAAG,uBAAuB,EAAE,CAAA;AAEnD,MAAM,aAAa,GAAG,CAAC,QAAiB,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,GAAG,QAAQ,yCAAyC,CAAC,CAAA;IACzD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,iCAAiC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAoB;IAC3C,QAAQ,EAAE;QACR,WAAW,EAAE,KAAK;QAClB,KAAK,EAAE,IAAI;KACZ;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,KAAK;KAClB;CACF,CAAA;AAED,OAAO,EACL,iBAAiB,EACjB,aAAa,EACd,CAAA"}
|
package/dist/hooks/useAuth.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { getTernSecureAuth } from '../app-router/client';
|
|
4
|
-
import { useTernSecure } from '../app-router/client/providers/
|
|
4
|
+
import { useTernSecure } from '../app-router/client/providers/ternSecureContext';
|
|
5
5
|
export function useAuth() {
|
|
6
|
-
const [state, setState] = useTernSecure();
|
|
6
|
+
const [state, setState] = useTernSecure('useAuth');
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
try {
|
|
9
9
|
const auth = getTernSecureAuth(); // This initializes Firebase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAA;AAEhF,MAAM,UAAU,OAAO;IACrB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAA,CAAC,4BA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