From 3138f33fee8803d324a3ee213f588697995aafda Mon Sep 17 00:00:00 2001 From: tapframe Date: Mon, 15 Sep 2025 18:09:20 +0530 Subject: [PATCH] changes --- .env.example | 13 +++++++ .gitignore | 1 + package-lock.json | 57 +++++++++++++++++++++++++++-- package.json | 1 + src/services/localScraperService.ts | 9 +++-- src/services/supabaseClient.ts | 8 +++- src/services/traktService.ts | 12 ++++-- 7 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..baa6552 --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +# Supabase Configuration +# Get these values from your Supabase project settings +EXPO_PUBLIC_SUPABASE_URL=your_supabase_project_url +EXPO_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key + +# MovieBox (MoviesMod) Keys +EXPO_PUBLIC_MOVIEBOX_PRIMARY_KEY=your_moviebox_primary_key +EXPO_PUBLIC_MOVIEBOX_TMDB_API_KEY=your_tmdb_api_key_for_moviebox + +# Trakt +EXPO_PUBLIC_TRAKT_CLIENT_ID=your_trakt_client_id +EXPO_PUBLIC_TRAKT_CLIENT_SECRET=your_trakt_client_secret +EXPO_PUBLIC_TRAKT_REDIRECT_URI=stremioexpo://auth/trakt diff --git a/.gitignore b/.gitignore index 4f446fd..82e0522 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ yarn-error.* *.pem # local env files +.env .env*.local # typescript diff --git a/package-lock.json b/package-lock.json index 68de56f..f5c0497 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@adrianso/react-native-device-brightness": "^1.2.7", "@backpackapp-io/react-native-toast": "^0.14.0", + "@expo/env": "^2.0.7", "@expo/metro-runtime": "~4.0.1", "@expo/vector-icons": "~14.0.4", "@lottiefiles/dotlottie-react": "^0.6.5", @@ -2407,6 +2408,19 @@ "expo-internal": "build/bin/cli" } }, + "node_modules/@expo/cli/node_modules/@expo/env": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@expo/env/-/env-0.4.2.tgz", + "integrity": "sha512-TgbCgvSk0Kq0e2fLoqHwEBL4M0ztFjnBEz0YCDm5boc1nvkV1VMuIMteVdeBwnTh8Z0oPJTwHCD49vhMEt1I6A==", + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "debug": "^4.3.4", + "dotenv": "~16.4.5", + "dotenv-expand": "~11.0.6", + "getenv": "^1.0.0" + } + }, "node_modules/@expo/cli/node_modules/form-data": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.4.tgz", @@ -2577,16 +2591,25 @@ } }, "node_modules/@expo/env": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/@expo/env/-/env-0.4.2.tgz", - "integrity": "sha512-TgbCgvSk0Kq0e2fLoqHwEBL4M0ztFjnBEz0YCDm5boc1nvkV1VMuIMteVdeBwnTh8Z0oPJTwHCD49vhMEt1I6A==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@expo/env/-/env-2.0.7.tgz", + "integrity": "sha512-BNETbLEohk3HQ2LxwwezpG8pq+h7Fs7/vAMP3eAtFT1BCpprLYoBBFZH7gW4aqGfqOcVP4Lc91j014verrYNGg==", "license": "MIT", "dependencies": { "chalk": "^4.0.0", "debug": "^4.3.4", "dotenv": "~16.4.5", "dotenv-expand": "~11.0.6", - "getenv": "^1.0.0" + "getenv": "^2.0.0" + } + }, + "node_modules/@expo/env/node_modules/getenv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/getenv/-/getenv-2.0.0.tgz", + "integrity": "sha512-VilgtJj/ALgGY77fiLam5iD336eSWi96Q15JSAG1zi8NRBysm3LXKdGnHb4m5cuyxvOLQQKWpBZAT6ni4FI2iQ==", + "license": "MIT", + "engines": { + "node": ">=6" } }, "node_modules/@expo/fingerprint": { @@ -2751,6 +2774,19 @@ "@babel/highlight": "^7.10.4" } }, + "node_modules/@expo/metro-config/node_modules/@expo/env": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@expo/env/-/env-0.4.2.tgz", + "integrity": "sha512-TgbCgvSk0Kq0e2fLoqHwEBL4M0ztFjnBEz0YCDm5boc1nvkV1VMuIMteVdeBwnTh8Z0oPJTwHCD49vhMEt1I6A==", + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "debug": "^4.3.4", + "dotenv": "~16.4.5", + "dotenv-expand": "~11.0.6", + "getenv": "^1.0.0" + } + }, "node_modules/@expo/metro-config/node_modules/@expo/json-file": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/@expo/json-file/-/json-file-9.0.2.tgz", @@ -7698,6 +7734,19 @@ "react-native": "*" } }, + "node_modules/expo-constants/node_modules/@expo/env": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@expo/env/-/env-0.4.2.tgz", + "integrity": "sha512-TgbCgvSk0Kq0e2fLoqHwEBL4M0ztFjnBEz0YCDm5boc1nvkV1VMuIMteVdeBwnTh8Z0oPJTwHCD49vhMEt1I6A==", + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "debug": "^4.3.4", + "dotenv": "~16.4.5", + "dotenv-expand": "~11.0.6", + "getenv": "^1.0.0" + } + }, "node_modules/expo-crypto": { "version": "14.0.2", "resolved": "https://registry.npmjs.org/expo-crypto/-/expo-crypto-14.0.2.tgz", diff --git a/package.json b/package.json index f7c38c1..fcf5d9f 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dependencies": { "@adrianso/react-native-device-brightness": "^1.2.7", "@backpackapp-io/react-native-toast": "^0.14.0", + "@expo/env": "^2.0.7", "@expo/metro-runtime": "~4.0.1", "@expo/vector-icons": "~14.0.4", "@lottiefiles/dotlottie-react": "^0.6.5", diff --git a/src/services/localScraperService.ts b/src/services/localScraperService.ts index 48ac54b..76325cf 100644 --- a/src/services/localScraperService.ts +++ b/src/services/localScraperService.ts @@ -1044,9 +1044,12 @@ class LocalScraperService { } } - // MovieBox constants - hardcoded for security - const MOVIEBOX_PRIMARY_KEY = '76iRl07s0xSN9jqmEWAt79EBJZulIQIsV64FZr2O'; - const MOVIEBOX_TMDB_API_KEY = '439c478a771f35c05022f9feabcca01c'; + // MovieBox constants - read from Expo public envs so they bundle in builds + const MOVIEBOX_PRIMARY_KEY = process.env.EXPO_PUBLIC_MOVIEBOX_PRIMARY_KEY; + const MOVIEBOX_TMDB_API_KEY = process.env.EXPO_PUBLIC_MOVIEBOX_TMDB_API_KEY || '439c478a771f35c05022f9feabcca01c'; + if (!MOVIEBOX_PRIMARY_KEY) { + throw new Error('Missing EXPO_PUBLIC_MOVIEBOX_PRIMARY_KEY'); + } const sandbox = { console: { diff --git a/src/services/supabaseClient.ts b/src/services/supabaseClient.ts index e4548bf..bf3949b 100644 --- a/src/services/supabaseClient.ts +++ b/src/services/supabaseClient.ts @@ -4,8 +4,12 @@ import { createClient } from '@supabase/supabase-js'; import AsyncStorage from '@react-native-async-storage/async-storage'; -const SUPABASE_URL = 'https://utypxyhwcekefvhyguxp.supabase.co'; -const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV0eXB4eWh3Y2VrZWZ2aHlndXhwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ2NjE4NTksImV4cCI6MjA3MDIzNzg1OX0.kc76fjHLjq6a5tNLsQh6KxS4uGp0ngl_ipQBte6KZuA'; +const SUPABASE_URL = process.env.EXPO_PUBLIC_SUPABASE_URL; +const SUPABASE_ANON_KEY = process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY; + +if (!SUPABASE_URL || !SUPABASE_ANON_KEY) { + throw new Error('Missing Supabase environment variables. Please check your .env file.'); +} export const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, { auth: { diff --git a/src/services/traktService.ts b/src/services/traktService.ts index 43f308c..ce903f4 100644 --- a/src/services/traktService.ts +++ b/src/services/traktService.ts @@ -10,9 +10,13 @@ export const TRAKT_TOKEN_EXPIRY_KEY = 'trakt_token_expiry'; // Trakt API configuration const TRAKT_API_URL = 'https://api.trakt.tv'; -const TRAKT_CLIENT_ID = 'd7271f7dd57d8aeff63e99408610091a6b1ceac3b3a541d1031a48f429b7942c'; -const TRAKT_CLIENT_SECRET = '0abf42c39aaad72c74696fb5229b558a6ac4b747caf3d380d939e950e8a5449c'; -const TRAKT_REDIRECT_URI = 'stremioexpo://auth/trakt'; // This should match your registered callback URL +const TRAKT_CLIENT_ID = process.env.EXPO_PUBLIC_TRAKT_CLIENT_ID as string; +const TRAKT_CLIENT_SECRET = process.env.EXPO_PUBLIC_TRAKT_CLIENT_SECRET as string; +const TRAKT_REDIRECT_URI = process.env.EXPO_PUBLIC_TRAKT_REDIRECT_URI || 'stremioexpo://auth/trakt'; // Must match registered callback URL + +if (!TRAKT_CLIENT_ID || !TRAKT_CLIENT_SECRET) { + throw new Error('Missing Trakt env vars. Set EXPO_PUBLIC_TRAKT_CLIENT_ID and EXPO_PUBLIC_TRAKT_CLIENT_SECRET'); +} // Types export interface TraktUser { @@ -712,7 +716,7 @@ export class TraktService { const headers: HeadersInit = { 'Content-Type': 'application/json', 'trakt-api-version': '2', - 'trakt-api-key': TRAKT_CLIENT_ID, + 'trakt-api-key': TRAKT_CLIENT_ID as string, 'Authorization': `Bearer ${this.accessToken}` };