@tern-secure/nextjs 1.9.6 → 1.9.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/auth.d.ts +6 -0
- package/dist/app-router/client/auth.js +7 -0
- package/dist/app-router/client/auth.js.map +1 -0
- package/dist/app-router/client/client-init.d.ts +3 -6
- package/dist/app-router/client/client-init.js +5 -5
- package/dist/app-router/client/client-init.js.map +1 -1
- package/dist/app-router/client/config.d.ts +1 -1
- package/dist/app-router/client/index.d.ts +6 -2
- package/dist/app-router/client/index.js +5 -2
- package/dist/app-router/client/index.js.map +1 -1
- package/dist/app-router/client/providers/ternSecureContext.d.ts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/sign-in.d.ts +15 -0
- package/dist/components/sign-in.js +54 -0
- package/dist/components/sign-in.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAuth.d.ts +1 -1
- package/dist/hooks/useAuth.js +6 -3
- package/dist/hooks/useAuth.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +47 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TernSecureAuth } from './index';
|
|
2
|
+
import { signInWithEmailAndPassword } from 'firebase/auth';
|
|
3
|
+
export async function signInWithEmail({ email, password }) {
|
|
4
|
+
const auth = TernSecureAuth();
|
|
5
|
+
return signInWithEmailAndPassword(auth, email, password);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/app-router/client/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,0BAA0B,EAAuB,MAAM,eAAe,CAAA;AAO/E,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACU;IAClB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,OAAO,0BAA0B,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;AAC1D,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const getTernSecureAuth: () => Auth;
|
|
5
|
-
export declare const getTernSecureFirestore: () => Firestore;
|
|
6
|
-
export declare const getTernSecureStorage: () => FirebaseStorage;
|
|
1
|
+
export declare const TernSecureAuth: () => import("@firebase/auth").Auth;
|
|
2
|
+
export declare const TernSecureFirestore: () => import("@firebase/firestore").Firestore;
|
|
3
|
+
export declare const TernSecureStorage: () => import("@firebase/storage").FirebaseStorage;
|
|
@@ -2,17 +2,17 @@ import { getApps, initializeApp } from 'firebase/app';
|
|
|
2
2
|
import { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';
|
|
3
3
|
import { getFirestore } from 'firebase/firestore';
|
|
4
4
|
import { getStorage } from 'firebase/storage';
|
|
5
|
-
import { loadFireConfig, validateConfig } from './
|
|
5
|
+
import { loadFireConfig, validateConfig } from './index';
|
|
6
6
|
// Initialize immediately
|
|
7
7
|
const app = (() => {
|
|
8
8
|
const config = validateConfig(loadFireConfig());
|
|
9
9
|
return getApps().length ? getApps()[0] : initializeApp(config);
|
|
10
10
|
})();
|
|
11
11
|
const auth = getAuth(app);
|
|
12
|
-
setPersistence(auth, browserSessionPersistence);
|
|
12
|
+
setPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance
|
|
13
13
|
const firestore = getFirestore(app);
|
|
14
14
|
const storage = getStorage(app);
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
15
|
+
export const TernSecureAuth = () => auth;
|
|
16
|
+
export const TernSecureFirestore = () => firestore;
|
|
17
|
+
export const TernSecureStorage = () => storage;
|
|
18
18
|
//# sourceMappingURL=client-init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-init.js","sourceRoot":"","sources":["../../../src/app-router/client/client-init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-init.js","sourceRoot":"","sources":["../../../src/app-router/client/client-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzD,yBAAyB;AACzB,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE;IAChB,MAAM,MAAM,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC;IAChD,OAAO,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAC1B,cAAc,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC,CAAC,2DAA2D;AAC5G,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { TernSecureAuth, TernSecureFirestore, TernSecureStorage } from './client-init';
|
|
2
|
+
export type { SignInCredentials } from './auth';
|
|
3
|
+
export { signInWithEmail } from './auth';
|
|
4
|
+
export { loadFireConfig, validateConfig } from './config';
|
|
5
|
+
export { TernSecureContext, useTernSecure } from './providers/ternSecureContext';
|
|
6
|
+
export { TernSecureClientProvider } from './providers/ternSecureClientProvider';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { TernSecureAuth, TernSecureFirestore, TernSecureStorage } from './client-init';
|
|
2
|
+
export { signInWithEmail } from './auth';
|
|
3
|
+
export { loadFireConfig, validateConfig } from './config';
|
|
4
|
+
export { TernSecureContext, useTernSecure } from './providers/ternSecureContext';
|
|
5
|
+
export { TernSecureClientProvider } from './providers/ternSecureClientProvider';
|
|
3
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app-router/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app-router/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,eAAe,EAAC,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TernSecureState } from '../../../types
|
|
2
|
+
import { TernSecureState } from '../../../types';
|
|
3
3
|
declare const TernSecureContext: React.Context<[TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>]>;
|
|
4
4
|
declare const useTernSecure: (hookname?: string) => [TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>];
|
|
5
5
|
export declare const initialState: TernSecureState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { SignIn } from './sign-in';
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { SignIn } from './sign-in';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SignInProps {
|
|
3
|
+
onSuccess?: () => void;
|
|
4
|
+
onError?: (error: Error) => void;
|
|
5
|
+
redirectUrl?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
customStyles?: {
|
|
8
|
+
form?: string;
|
|
9
|
+
input?: string;
|
|
10
|
+
button?: string;
|
|
11
|
+
errorText?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare function SignIn({ onSuccess, onError, redirectUrl, className, customStyles }: SignInProps): React.JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { signInWithEmail } from '../app-router/client';
|
|
5
|
+
export function SignIn({ onSuccess, onError, redirectUrl, className = '', customStyles = {} }) {
|
|
6
|
+
const [email, setEmail] = useState('');
|
|
7
|
+
const [password, setPassword] = useState('');
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const [error, setError] = useState('');
|
|
10
|
+
const handleSubmit = async (e) => {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
setLoading(true);
|
|
13
|
+
setError('');
|
|
14
|
+
try {
|
|
15
|
+
await signInWithEmail({ email, password });
|
|
16
|
+
onSuccess?.();
|
|
17
|
+
if (redirectUrl) {
|
|
18
|
+
window.location.href = redirectUrl;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
const errorMessage = err instanceof Error ? err.message : 'Failed to sign in';
|
|
23
|
+
setError(errorMessage);
|
|
24
|
+
onError?.(err instanceof Error ? err : new Error('Failed to sign in'));
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
setLoading(false);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const defaultStyles = {
|
|
31
|
+
form: 'space-y-4',
|
|
32
|
+
label: 'block text-sm font-medium text-gray-700',
|
|
33
|
+
input: 'mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary',
|
|
34
|
+
button: 'w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary disabled:opacity-50',
|
|
35
|
+
errorText: 'text-red-500 text-sm'
|
|
36
|
+
};
|
|
37
|
+
const styles = {
|
|
38
|
+
form: customStyles.form || defaultStyles.form,
|
|
39
|
+
label: customStyles.label || defaultStyles.label,
|
|
40
|
+
input: customStyles.input || defaultStyles.input,
|
|
41
|
+
button: customStyles.button || defaultStyles.button,
|
|
42
|
+
errorText: customStyles.errorText || defaultStyles.errorText
|
|
43
|
+
};
|
|
44
|
+
return (React.createElement("form", { onSubmit: handleSubmit, className: `${styles.form} ${className}`, role: "form", "aria-label": "Sign in form" },
|
|
45
|
+
error && (React.createElement("div", { className: styles.errorText, role: "alert", "aria-live": "polite" }, error)),
|
|
46
|
+
React.createElement("div", null,
|
|
47
|
+
React.createElement("label", { htmlFor: "email", className: styles.label }, "Email"),
|
|
48
|
+
React.createElement("input", { id: "email", type: "email", value: email, onChange: (e) => setEmail(e.target.value), placeholder: "Enter your email", required: true, className: styles.input, disabled: loading, "aria-required": "true", "aria-invalid": !!error })),
|
|
49
|
+
React.createElement("div", null,
|
|
50
|
+
React.createElement("label", { htmlFor: "password", className: styles.label }, "Password"),
|
|
51
|
+
React.createElement("input", { id: "password", type: "password", value: password, onChange: (e) => setPassword(e.target.value), placeholder: "Enter your password", required: true, className: styles.input, disabled: loading, "aria-required": "true", "aria-invalid": !!error })),
|
|
52
|
+
React.createElement("button", { type: "submit", disabled: loading, className: styles.button, "data-testid": "sign-in-submit" }, loading ? 'Signing in...' : 'Sign in')));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=sign-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../src/components/sign-in.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAgBtD,MAAM,UAAU,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAS,GAAG,EAAE,EACd,YAAY,GAAG,EAAE,EACL;IACZ,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IACtC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GA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C,KAAK,EACvB,QAAQ,EAAE,OAAO,mBACH,MAAM,kBACN,CAAC,CAAC,KAAK,GACrB,CACE;QACN,gCACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,MAAM,CAAC,MAAM,iBACZ,gBAAgB,IAE3B,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAC/B,CACJ,CACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAuth } from './useAuth';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA"}
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useAuth(): import("../types
|
|
1
|
+
export declare function useAuth(): import("../types").AuthState;
|
package/dist/hooks/useAuth.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { useTernSecure } from '../app-router/client/
|
|
3
|
+
import { signInWithEmail, TernSecureAuth } from '../app-router/client';
|
|
4
|
+
import { useTernSecure } from '../app-router/client/';
|
|
5
5
|
export function useAuth() {
|
|
6
6
|
const [state, setState] = useTernSecure('useAuth');
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
try {
|
|
9
|
-
const auth =
|
|
9
|
+
const auth = TernSecureAuth(); // This initializes Firebase
|
|
10
10
|
setState(prev => ({
|
|
11
11
|
...prev,
|
|
12
12
|
firebase: {
|
|
@@ -15,6 +15,9 @@ export function useAuth() {
|
|
|
15
15
|
}
|
|
16
16
|
}));
|
|
17
17
|
const unsubscribe = auth.onAuthStateChanged((user) => {
|
|
18
|
+
if (!user) {
|
|
19
|
+
return signInWithEmail;
|
|
20
|
+
}
|
|
18
21
|
setState(prev => ({
|
|
19
22
|
...prev,
|
|
20
23
|
auth: {
|
|
@@ -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,
|
|
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,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD,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,cAAc,EAAE,CAAA,CAAC,4BAA4B;YAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,GAAG,IAAI;gBACP,QAAQ,EAAE;oBACR,WAAW,EAAE,IAAI;oBACjB,KAAK,EAAE,IAAI;iBACZ;aACF,CAAC,CAAC,CAAA;YAEH,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CACzC,CAAC,IAAI,EAAE,EAAE;gBACL,IAAI,CAAC,IAAI,EAAE,CAAC;oBACR,OAAO,eAAe,CAAA;gBAC1B,CAAC;gBACH,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAChB,GAAG,IAAI;oBACP,IAAI,EAAE;wBACJ,IAAI;wBACJ,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,IAAI;wBACX,UAAU,EAAE,CAAC,CAAC,IAAI;qBACnB;iBACF,CAAC,CAAC,CAAA;YACL,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;gBACR,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAChB,GAAG,IAAI;oBACP,IAAI,EAAE;wBACJ,IAAI,EAAE,IAAI;wBACV,OAAO,EAAE,KAAK;wBACd,KAAK;wBACL,UAAU,EAAE,KAAK;qBAClB;iBACF,CAAC,CAAC,CAAA;YACL,CAAC,CACF,CAAA;YAED,OAAO,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,GAAG,IAAI;gBACP,QAAQ,EAAE;oBACR,WAAW,EAAE,KAAK;oBAClB,KAAK,EAAE,KAAc;iBACtB;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,KAAc;oBACrB,UAAU,EAAE,KAAK;iBAClB;aACF,CAAC,CAAC,CAAA;QACL,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,yBAAyB;IAEhC,OAAO,KAAK,CAAC,IAAI,CAAA;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TernSecureProvider } from "./app-router/server
|
|
3
|
-
import { useAuth } from "./hooks/
|
|
4
|
-
export { TernSecureProvider, useAuth,
|
|
1
|
+
import { TernSecureAuth, TernSecureFirestore, TernSecureStorage } from "./app-router/client";
|
|
2
|
+
import { TernSecureProvider } from "./app-router/server";
|
|
3
|
+
import { useAuth } from "./hooks/";
|
|
4
|
+
export { TernSecureProvider, useAuth, TernSecureAuth, TernSecureFirestore, TernSecureStorage };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TernSecureProvider } from "./app-router/server
|
|
3
|
-
import { useAuth } from "./hooks/
|
|
4
|
-
export { TernSecureProvider, useAuth,
|
|
1
|
+
import { TernSecureAuth, TernSecureFirestore, TernSecureStorage } from "./app-router/client";
|
|
2
|
+
import { TernSecureProvider } from "./app-router/server";
|
|
3
|
+
import { useAuth } from "./hooks/";
|
|
4
|
+
export { TernSecureProvider, useAuth, TernSecureAuth, TernSecureFirestore, TernSecureStorage };
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EACH,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACpB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { User } from 'firebase/auth';
|
|
3
|
+
export interface TernSecureConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
authDomain: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
storageBucket: string;
|
|
8
|
+
messagingSenderId: string;
|
|
9
|
+
appId: string;
|
|
10
|
+
measurementId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TernSecureOptions {
|
|
13
|
+
environment?: 'development' | 'production';
|
|
14
|
+
region?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FirebaseState {
|
|
17
|
+
initialized: boolean;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
}
|
|
20
|
+
export interface TernSecureState {
|
|
21
|
+
firebase: FirebaseState;
|
|
22
|
+
auth: AuthState;
|
|
23
|
+
}
|
|
24
|
+
export interface AuthState {
|
|
25
|
+
user: User | null;
|
|
26
|
+
loading: boolean;
|
|
27
|
+
error: Error | null;
|
|
28
|
+
isSignedIn: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface TernSecureContextValue {
|
|
31
|
+
_contextKey: symbol;
|
|
32
|
+
authState: AuthState;
|
|
33
|
+
auth: any;
|
|
34
|
+
}
|
|
35
|
+
export interface TernSecureContextType {
|
|
36
|
+
authState: AuthState;
|
|
37
|
+
}
|
|
38
|
+
export interface TernSecureProviderProps {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export interface UseAuthReturn {
|
|
42
|
+
user: User | null;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
error: Error | null;
|
|
45
|
+
signIn: (email: string, password: string) => Promise<User>;
|
|
46
|
+
signOut: () => Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|