@tern-secure/nextjs 3.1.19 → 3.1.21
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 +7 -0
- package/dist/app-router/client/auth.d.ts.map +1 -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 +4 -0
- package/dist/app-router/client/client-init.d.ts.map +1 -0
- package/dist/app-router/client/client-init.js +18 -0
- package/dist/app-router/client/client-init.js.map +1 -0
- package/dist/app-router/client/config.d.ts +4 -0
- package/dist/app-router/client/config.d.ts.map +1 -0
- package/dist/app-router/client/config.js +18 -0
- package/dist/app-router/client/config.js.map +1 -0
- package/dist/app-router/client/index.d.ts +7 -0
- package/dist/app-router/client/index.d.ts.map +1 -0
- package/dist/app-router/client/index.js +6 -0
- package/dist/app-router/client/index.js.map +1 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.d.ts +5 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.d.ts.map +1 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.js +9 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.js.map +1 -0
- package/dist/app-router/client/providers/ternSecureContext.d.ts +7 -0
- package/dist/app-router/client/providers/ternSecureContext.d.ts.map +1 -0
- package/dist/app-router/client/providers/ternSecureContext.js +24 -0
- package/dist/app-router/client/providers/ternSecureContext.js.map +1 -0
- package/dist/app-router/server/index.d.ts +2 -0
- package/dist/app-router/server/index.d.ts.map +1 -0
- package/dist/app-router/server/index.js +2 -0
- package/dist/app-router/server/index.js.map +1 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.d.ts +7 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.d.ts.map +1 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.js +31 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/{esm/components/index.d.ts → components/sign-in.d.ts} +3 -6
- package/dist/components/sign-in.d.ts.map +1 -0
- package/dist/components/sign-in.js +32 -0
- package/dist/components/sign-in.js.map +1 -0
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +12 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAuth.d.ts +2 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/hooks/useAuth.js +58 -0
- package/dist/hooks/useAuth.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/create-styles.d.ts +99 -0
- package/dist/utils/create-styles.d.ts.map +1 -0
- package/dist/utils/create-styles.js +127 -0
- package/dist/utils/create-styles.js.map +1 -0
- package/package.json +2 -2
- package/dist/cjs/app-router/client/client-init.cjs +0 -47
- package/dist/cjs/app-router/client/client-init.cjs.map +0 -1
- package/dist/cjs/app-router/client/config.cjs +0 -27
- package/dist/cjs/app-router/client/config.cjs.map +0 -1
- package/dist/cjs/app-router/client/index.cjs +0 -93
- package/dist/cjs/app-router/client/index.cjs.map +0 -1
- package/dist/cjs/app-router/server/index.cjs +0 -96
- package/dist/cjs/app-router/server/index.cjs.map +0 -1
- package/dist/cjs/components/index.cjs +0 -288
- package/dist/cjs/components/index.cjs.map +0 -1
- package/dist/cjs/index.cjs +0 -434
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/app-router/client/client-init.d.ts +0 -9
- package/dist/esm/app-router/client/client-init.js +0 -4
- package/dist/esm/app-router/client/client-init.js.map +0 -1
- package/dist/esm/app-router/client/config.d.ts +0 -2
- package/dist/esm/app-router/client/config.js +0 -3
- package/dist/esm/app-router/client/config.js.map +0 -1
- package/dist/esm/app-router/client/index.d.ts +0 -24
- package/dist/esm/app-router/client/index.js +0 -6
- package/dist/esm/app-router/client/index.js.map +0 -1
- package/dist/esm/app-router/server/index.d.ts +0 -9
- package/dist/esm/app-router/server/index.js +0 -3
- package/dist/esm/app-router/server/index.js.map +0 -1
- package/dist/esm/chunk-2KTAGORW.js +0 -15
- package/dist/esm/chunk-2KTAGORW.js.map +0 -1
- package/dist/esm/chunk-4NSAJAO6.js +0 -227
- package/dist/esm/chunk-4NSAJAO6.js.map +0 -1
- package/dist/esm/chunk-56UNIYRZ.js +0 -45
- package/dist/esm/chunk-56UNIYRZ.js.map +0 -1
- package/dist/esm/chunk-EF3FO2UD.js +0 -24
- package/dist/esm/chunk-EF3FO2UD.js.map +0 -1
- package/dist/esm/chunk-PEBK7FQF.js +0 -36
- package/dist/esm/chunk-PEBK7FQF.js.map +0 -1
- package/dist/esm/chunk-YZ776Z4A.js +0 -22
- package/dist/esm/chunk-YZ776Z4A.js.map +0 -1
- package/dist/esm/components/index.js +0 -7
- package/dist/esm/components/index.js.map +0 -1
- package/dist/esm/config-CYswigMN.d.ts +0 -30
- package/dist/esm/index.d.ts +0 -16
- package/dist/esm/index.js +0 -70
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ternSecureClientProvider-NWI37OBT.js +0 -3
- package/dist/esm/ternSecureClientProvider-NWI37OBT.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type UserCredential } from 'firebase/auth';
|
|
2
|
+
export interface SignInCredentials {
|
|
3
|
+
email: string;
|
|
4
|
+
password: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function signInWithEmail({ email, password }: SignInCredentials): Promise<UserCredential>;
|
|
7
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAE/E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAsB,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACT,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAG7C"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
4
|
+
//# sourceMappingURL=client-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-init.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/client-init.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,cAAc,qCAAa,CAAC;AACzC,eAAO,MAAM,mBAAmB,+CAAkB,CAAC;AACnD,eAAO,MAAM,iBAAiB,mDAAgB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getApps, initializeApp } from 'firebase/app';
|
|
2
|
+
import { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';
|
|
3
|
+
import { getFirestore } from 'firebase/firestore';
|
|
4
|
+
import { getStorage } from 'firebase/storage';
|
|
5
|
+
import { loadFireConfig, validateConfig } from './config';
|
|
6
|
+
// Initialize immediately
|
|
7
|
+
const app = (() => {
|
|
8
|
+
const config = validateConfig(loadFireConfig());
|
|
9
|
+
return getApps().length ? getApps()[0] : initializeApp(config);
|
|
10
|
+
})();
|
|
11
|
+
const auth = getAuth(app);
|
|
12
|
+
setPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance
|
|
13
|
+
const firestore = getFirestore(app);
|
|
14
|
+
const storage = getStorage(app);
|
|
15
|
+
export const TernSecureAuth = () => auth;
|
|
16
|
+
export const TernSecureFirestore = () => firestore;
|
|
17
|
+
export const TernSecureStorage = () => storage;
|
|
18
|
+
//# sourceMappingURL=client-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,UAAU,CAAC;AAE1D,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,cAAc,QAAO,gBAQhC,CAAC;AAEH,eAAO,MAAM,cAAc,WAAY,gBAAgB,KAAG,gBAOzD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const loadFireConfig = () => ({
|
|
2
|
+
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
3
|
+
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
4
|
+
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
5
|
+
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
6
|
+
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
7
|
+
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
8
|
+
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
|
|
9
|
+
});
|
|
10
|
+
export const validateConfig = (config) => {
|
|
11
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
12
|
+
if (!value) {
|
|
13
|
+
throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/app-router/client/config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,GAAqB,EAAE,CAAC,CAAC;IACrD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,4BAAsC;IAC1D,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,gCAA0C;IAClE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,+BAAyC;IAChE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,mCAA6C;IACxE,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,wCAAkD;IACjF,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,2BAAqC;IACxD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,mCAA6C;CACzE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAwB,EAAoB,EAAE;IAC3E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,sDAAsD,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAE/C,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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
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';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAQnF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { TernSecureContext, initialState } from './ternSecureContext';
|
|
5
|
+
export function TernSecureClientProvider({ children }) {
|
|
6
|
+
const stateAndUpdater = useState(initialState);
|
|
7
|
+
return (_jsx(TernSecureContext.Provider, { value: stateAndUpdater, children: children }));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ternSecureClientProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternSecureClientProvider.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAErE,MAAM,UAAU,wBAAwB,CAAC,EAAE,QAAQ,EAAiC;IAClF,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAA;IAE9C,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YAC/C,QAAQ,GACkB,CAC9B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TernSecureState } from '../../../types';
|
|
3
|
+
declare const initialState: TernSecureState;
|
|
4
|
+
declare const TernSecureContext: React.Context<[TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>]>;
|
|
5
|
+
declare const useTernSecure: (hookname?: string) => [TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>];
|
|
6
|
+
export { TernSecureContext, useTernSecure, initialState };
|
|
7
|
+
//# sourceMappingURL=ternSecureContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternSecureContext.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,QAAA,MAAM,YAAY,EAAE,eAWnB,CAAA;AAED,QAAA,MAAM,iBAAiB,yFAA0H,CAAA;AAEjJ,QAAA,MAAM,aAAa,cAAe,MAAM,6EAOvC,CAAA;AAED,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const initialState = {
|
|
4
|
+
firebase: {
|
|
5
|
+
initialized: false,
|
|
6
|
+
error: null
|
|
7
|
+
},
|
|
8
|
+
auth: {
|
|
9
|
+
user: null,
|
|
10
|
+
loading: true,
|
|
11
|
+
error: null,
|
|
12
|
+
isSignedIn: false
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const TernSecureContext = React.createContext([initialState, () => { }]);
|
|
16
|
+
const useTernSecure = (hookname) => {
|
|
17
|
+
const context = React.useContext(TernSecureContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error(`${hookname} must be used within TernSecureProvider`);
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
23
|
+
export { TernSecureContext, useTernSecure, initialState };
|
|
24
|
+
//# sourceMappingURL=ternSecureContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternSecureContext.js","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,YAAY,GAAoB;IACpC,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,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAA2E,CAAC,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAA;AAEjJ,MAAM,aAAa,GAAG,CAAC,QAAiB,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACnD,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,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app-router/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app-router/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface TernSecureProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare function TernSecureProvider({ children }: TernSecureProviderProps): import("react/jsx-runtime").JSX.Element | (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>)[] | null | undefined;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=TernSecureServerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAWD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,uBAAuB,qLA+BvE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import dynamic from 'next/dynamic';
|
|
4
|
+
// Dynamically import the client provider with no SSR
|
|
5
|
+
const TernSecureClientProvider = dynamic(() => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider), {
|
|
6
|
+
ssr: false
|
|
7
|
+
//loading: () => null // Return null or a loading indicator
|
|
8
|
+
});
|
|
9
|
+
export function TernSecureProvider({ children }) {
|
|
10
|
+
// Check if the children contain html/body tags
|
|
11
|
+
const isRootLayout = React.Children.toArray(children).some(child => React.isValidElement(child) && child.type === 'html');
|
|
12
|
+
if (isRootLayout) {
|
|
13
|
+
// If this is the root layout, inject our provider after the body tag
|
|
14
|
+
return React.Children.map(children, child => {
|
|
15
|
+
if (React.isValidElement(child) && child.type === 'html') {
|
|
16
|
+
return React.cloneElement(child, {}, React.Children.map(child.props.children, bodyChild => {
|
|
17
|
+
if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {
|
|
18
|
+
// Type assertion to access props safely
|
|
19
|
+
const bodyProps = bodyChild.props;
|
|
20
|
+
return React.cloneElement(bodyChild, {}, _jsx(TernSecureClientProvider, { children: bodyProps.children }));
|
|
21
|
+
}
|
|
22
|
+
return bodyChild;
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return child;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// For non-root layouts, wrap normally
|
|
29
|
+
return _jsx(TernSecureClientProvider, { children: children });
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=TernSecureServerProvider.js.map
|
|
@@ -0,0 +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,GAAG,EAAE,KAAK;IACV,2DAA2D;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sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
interface SignInProps {
|
|
2
|
+
export interface SignInProps {
|
|
5
3
|
onSuccess?: () => void;
|
|
6
4
|
onError?: (error: Error) => void;
|
|
7
5
|
redirectUrl?: string;
|
|
@@ -20,6 +18,5 @@ interface SignInProps {
|
|
|
20
18
|
label?: string;
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
declare function SignIn({ onSuccess, onError, redirectUrl, className, style, customStyles }: SignInProps):
|
|
24
|
-
|
|
25
|
-
export { SignIn };
|
|
21
|
+
export declare function SignIn({ onSuccess, onError, redirectUrl, className, style, customStyles }: SignInProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=sign-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../../src/components/sign-in.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAc,EACd,KAAK,EACL,YAAiB,EAClB,EAAE,WAAW,2CAmGb"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { signInWithEmail } from '../app-router/client';
|
|
4
|
+
import { styles } from '../utils/create-styles';
|
|
5
|
+
export function SignIn({ onSuccess, onError, redirectUrl, className = '', style, 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
|
+
return (_jsxs("div", { className: `${styles.container} ${customStyles.container || ''}`, style: style, children: [_jsx("div", { className: `${styles.header} ${customStyles.header || ''}`, children: _jsx("h2", { className: `${styles.title} ${customStyles.title || ''}`, children: "Sign in to your account" }) }), _jsx("div", { className: `${styles.formWrapper} ${customStyles.formWrapper || ''}`, children: _jsx("div", { className: `${styles.formContainer} ${customStyles.formContainer || ''}`, children: _jsxs("form", { onSubmit: handleSubmit, className: `${styles.form} ${customStyles.form || ''} ${className}`, role: "form", "aria-label": "Sign in form", children: [error && (_jsx("div", { className: `${styles.error} ${customStyles.errorText || ''}`, role: "alert", "aria-live": "polite", children: error })), _jsxs("div", { children: [_jsx("label", { htmlFor: "email", className: `${styles.label} ${customStyles.label || ''}`, children: "Email" }), _jsx("input", { id: "email", type: "email", value: email, onChange: (e) => setEmail(e.target.value), placeholder: "Enter your email", required: true, className: `${styles.input} ${customStyles.input || ''}`, disabled: loading, "aria-required": "true", "aria-invalid": !!error })] }), _jsxs("div", { children: [_jsx("label", { htmlFor: "password", className: `${styles.label} ${customStyles.label || ''}`, children: "Password" }), _jsx("input", { id: "password", type: "password", value: password, onChange: (e) => setPassword(e.target.value), placeholder: "Enter your password", required: true, className: `${styles.input} ${customStyles.input || ''}`, disabled: loading, "aria-required": "true", "aria-invalid": !!error })] }), _jsx("button", { type: "submit", disabled: loading, className: `${styles.button} ${customStyles.button || ''}`, "data-testid": "sign-in-submit", children: loading ? 'Signing in...' : 'Sign in' })] }) }) })] }));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sign-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../src/components/sign-in.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CA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Q,QACR,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,IAAI,EAAE,EAAE,EACxD,QAAQ,EAAE,OAAO,mBACH,MAAM,kBACN,CAAC,CAAC,KAAK,GACrB,IACE,EACN,0BACE,gBAAO,OAAO,EAAC,UAAU,EAAC,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,IAAI,EAAE,EAAE,yBAE1E,EACR,gBACE,EAAE,EAAC,UAAU,EACb,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,WAAW,EAAC,qBAAqB,EACjC,QAAQ,QACR,SAAS,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,IAAI,EAAE,EAAE,EACxD,QAAQ,EAAE,OAAO,mBACH,MAAM,kBACN,CAAC,CAAC,KAAK,GACrB,IACE,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,IAAI,EAAE,EAAE,iBAC9C,gBAAgB,YAE3B,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,GAC/B,IACJ,GACH,GACF,IACF,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ERRORS: {
|
|
2
|
+
readonly SERVER_SIDE_INITIALIZATION: "TernSecure must be initialized on the client side";
|
|
3
|
+
readonly NOT_INITIALIZED: "TernSecure services are not initialized. Call initializeTernSecure() first";
|
|
4
|
+
readonly HOOK_CONTEXT: (hookName: string) => string;
|
|
5
|
+
};
|
|
6
|
+
export declare class TernSecureError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;sCAGU,MAAM;CACvB,CAAC;AAEX,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const ERRORS = {
|
|
2
|
+
SERVER_SIDE_INITIALIZATION: 'TernSecure must be initialized on the client side',
|
|
3
|
+
NOT_INITIALIZED: 'TernSecure services are not initialized. Call initializeTernSecure() first',
|
|
4
|
+
HOOK_CONTEXT: (hookName) => `${hookName} must be used within TernSecureProvider`,
|
|
5
|
+
};
|
|
6
|
+
export class TernSecureError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'TernSecureError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,0BAA0B,EAAE,mDAAmD;IAC/E,eAAe,EAAE,4EAA4E;IAC7F,YAAY,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,GAAG,QAAQ,yCAAyC;CAChF,CAAC;AAEX,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA"}
|
|
@@ -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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAMA,wBAAgB,OAAO,iCA0DtB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { TernSecureAuth } from '../app-router/client';
|
|
4
|
+
import { useTernSecure } from '../app-router/client/';
|
|
5
|
+
export function useAuth() {
|
|
6
|
+
const [state, setState] = useTernSecure('useAuth');
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
try {
|
|
9
|
+
const auth = TernSecureAuth(); // This initializes Firebase
|
|
10
|
+
setState(prev => ({
|
|
11
|
+
...prev,
|
|
12
|
+
firebase: {
|
|
13
|
+
initialized: true,
|
|
14
|
+
error: null
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
const unsubscribe = auth.onAuthStateChanged((user) => {
|
|
18
|
+
setState(prev => ({
|
|
19
|
+
...prev,
|
|
20
|
+
auth: {
|
|
21
|
+
user,
|
|
22
|
+
loading: false,
|
|
23
|
+
error: null,
|
|
24
|
+
isSignedIn: !!user
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
}, (error) => {
|
|
28
|
+
setState(prev => ({
|
|
29
|
+
...prev,
|
|
30
|
+
auth: {
|
|
31
|
+
user: null,
|
|
32
|
+
loading: false,
|
|
33
|
+
error,
|
|
34
|
+
isSignedIn: false
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
return () => unsubscribe();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
setState(prev => ({
|
|
42
|
+
...prev,
|
|
43
|
+
firebase: {
|
|
44
|
+
initialized: false,
|
|
45
|
+
error: error
|
|
46
|
+
},
|
|
47
|
+
auth: {
|
|
48
|
+
user: null,
|
|
49
|
+
loading: false,
|
|
50
|
+
error: error,
|
|
51
|
+
isSignedIn: false
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}, []); // Only run once on mount
|
|
56
|
+
return state.auth;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=useAuth.js.map
|
|
@@ -0,0 +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,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,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;gBACP,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
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { TernSecureAuth, TernSecureFirestore, TernSecureStorage, signInWithEmail, loadFireConfig, validateConfig, TernSecureContext, useTernSecure, TernSecureClientProvider } from './app-router/client';
|
|
2
|
+
export { TernSecureProvider } from './app-router/server';
|
|
3
|
+
export { useAuth } from './hooks/useAuth';
|
|
4
|
+
export { SignIn } from './components/sign-in';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACzM,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { TernSecureAuth, TernSecureFirestore, TernSecureStorage, signInWithEmail, loadFireConfig, validateConfig, TernSecureContext, useTernSecure, TernSecureClientProvider } from './app-router/client';
|
|
2
|
+
export { TernSecureProvider } from './app-router/server';
|
|
3
|
+
export { useAuth } from './hooks/useAuth';
|
|
4
|
+
export { SignIn } from './components/sign-in';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACzM,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { User, Auth } 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: Auth;
|
|
34
|
+
}
|
|
35
|
+
export interface TernSecureContextType {
|
|
36
|
+
authState: AuthState;
|
|
37
|
+
}
|
|
38
|
+
export interface TernSecureProviderProps {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB;AAGD,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AACD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,SAAS,CAAC;CACjB;AACD,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACvB;AACD,MAAM,WAAW,sBAAsB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,IAAI,CAAC;CACd;AACD,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,SAAS,CAAC;CACtB;AACD,MAAM,WAAW,uBAAuB;IACpC,QAAQ,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|