bump functions version

This commit is contained in:
Blake Kaufman
2025-02-20 12:14:13 -05:00
parent f7c824aef3
commit 17faba52ff
6 changed files with 61 additions and 60 deletions
@@ -421,7 +421,7 @@ export default function ChatGPTHome(props) {
requestAccount: globalContactsInformation.myProfile.uuid,
};
const response = await fetchBackend(
'generativeAIV2',
'generativeAIV3',
requestData,
contactsPrivateKey,
publicKey,
@@ -59,7 +59,7 @@ export default function ConfirmGiftCardPurchase(props) {
blitzUsername: blitzUsername,
};
const response = await fetchBackend(
'theBitcoinCompanyV2',
'theBitcoinCompanyV3',
postData,
contactsPrivateKey,
publicKey,
+1 -1
View File
@@ -110,7 +110,7 @@ export async function sendPushNotification({
console.log(JSON.stringify(requestData));
const response = await fetchBackend(
'contactsPushNotificationV2',
'contactsPushNotificationV3',
requestData,
privateKey,
myProfile.uuid,
+47 -47
View File
@@ -1,53 +1,53 @@
import {useEffect, useRef} from 'react';
import auth from '@react-native-firebase/auth'; // If using Firebase
import {setLocalStorageItem} from '../functions';
import fetchBackend from '../../db/handleBackend';
// import {useEffect, useRef} from 'react';
// import auth from '@react-native-firebase/auth'; // If using Firebase
// import {setLocalStorageItem} from '../functions';
// import fetchBackend from '../../db/handleBackend';
const useJWTSessionToken = (publicKey, privateKey, didGetToHomepage) => {
const isInitialLoad = useRef(true);
// const useJWTSessionToken = (publicKey, privateKey, didGetToHomepage) => {
// const isInitialLoad = useRef(true);
useEffect(() => {
if (!publicKey || !privateKey || !didGetToHomepage) return;
if (!isInitialLoad.current) return;
isInitialLoad.current = false;
// Listen for auth state changes
// useEffect(() => {
// if (!publicKey || !privateKey || !didGetToHomepage) return;
// if (!isInitialLoad.current) return;
// isInitialLoad.current = false;
// // Listen for auth state changes
let interval;
(async () => {
try {
const token = await fetchBackend(
'login',
{userAuth: auth().currentUser.uid},
privateKey,
publicKey,
);
if (!token) return;
await setLocalStorageItem('session-token', JSON.stringify(token));
} catch (err) {
console.log('fetch jwt error', err);
}
})();
// let interval;
// (async () => {
// try {
// const token = await fetchBackend(
// 'login',
// {userAuth: auth().currentUser.uid},
// privateKey,
// publicKey,
// );
// if (!token) return;
// await setLocalStorageItem('session-token', JSON.stringify(token));
// } catch (err) {
// console.log('fetch jwt error', err);
// }
// })();
// Check session token periodically
interval = setInterval(async () => {
try {
const token = await fetchBackend(
'login',
{userAuth: auth().currentUser.uid},
privateKey,
publicKey,
);
if (!token) return;
await setLocalStorageItem('session-token', JSON.stringify(token));
} catch (error) {
console.error('Error fetching session token:', error);
}
}, 1000 * 60 * 50); // 50-minute interval
// // Check session token periodically
// interval = setInterval(async () => {
// try {
// const token = await fetchBackend(
// 'login',
// {userAuth: auth().currentUser.uid},
// privateKey,
// publicKey,
// );
// if (!token) return;
// await setLocalStorageItem('session-token', JSON.stringify(token));
// } catch (error) {
// console.error('Error fetching session token:', error);
// }
// }, 1000 * 60 * 50); // 50-minute interval
return () => {
clearInterval(interval);
};
}, [publicKey, privateKey, didGetToHomepage]);
};
// return () => {
// clearInterval(interval);
// };
// }, [publicKey, privateKey, didGetToHomepage]);
// };
export default useJWTSessionToken;
// export default useJWTSessionToken;
+4 -4
View File
@@ -8,15 +8,15 @@ import {
} from 'react';
import {useTranslation} from 'react-i18next';
import {sendDataToDB} from '../db/interactionManager';
import useJWTSessionToken from '../app/hooks/jwtSessionToken';
import {useAppStatus} from './appStatus';
// import useJWTSessionToken from '../app/hooks/jwtSessionToken';
// import {useAppStatus} from './appStatus';
import {useKeysContext} from './keys';
// Initiate context
const GlobalContextManger = createContext(null);
const GlobalContextProvider = ({children}) => {
const {didGetToHomepage} = useAppStatus();
// const {didGetToHomepage} = useAppStatus();
const {contactsPrivateKey, publicKey} = useKeysContext();
const [deepLinkContent, setDeepLinkContent] = useState({type: '', data: ''});
@@ -37,7 +37,7 @@ const GlobalContextProvider = ({children}) => {
[i18n, publicKey],
);
useJWTSessionToken(publicKey, contactsPrivateKey, didGetToHomepage);
// useJWTSessionToken(publicKey, contactsPrivateKey, didGetToHomepage);
const contextValue = useMemo(
() => ({
+7 -6
View File
@@ -12,15 +12,16 @@ export default async function fetchBackend(
) {
try {
const message = encodeRequest(privateKey, data);
const token =
method === 'customToken' ||
method === 'login' ||
JSON.parse(await getLocalStorageItem('session-token'));
if (!message || !token) throw new Error('Unable to encode request');
// const token =
// method === 'customToken' ||
// method === 'login' ||
// JSON.parse(await getLocalStorageItem('session-token'));
// if (!message || !token) throw new Error('Unable to encode request');
if (!message) throw new Error('Unable to encode request');
const responseData = {
em: message,
publicKey,
token,
// token,
};
console.log('function call data', responseData);
const response = await functions().httpsCallable(method)(responseData);