From 21b4e656f61eed1678550814240b69a92e8d8dc9 Mon Sep 17 00:00:00 2001 From: KS Jannette Date: Fri, 20 Feb 2026 12:36:46 -0500 Subject: [PATCH] hotfix --- .gitignore | 10 +++++----- .../accounts.example.json | 0 accountsAndCredentials/credentials.example.json | 11 +++++++++++ accountsAndCredentials/token.example.json | 7 +++++++ src/auth.ts | 9 +++++---- src/loaders/prompt-config-loaders.ts | 7 ++++--- 6 files changed, 32 insertions(+), 12 deletions(-) rename accounts.example.json => accountsAndCredentials/accounts.example.json (100%) create mode 100644 accountsAndCredentials/credentials.example.json create mode 100644 accountsAndCredentials/token.example.json diff --git a/.gitignore b/.gitignore index b12319d..51771be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ node_modules/ build/ -# OAuth secrets -credentials.json -credentials.* -token*.json -accounts.json +# OAuth secrets (inside accountsAndCredentials/, example files are NOT ignored) +accountsAndCredentials/credentials.json +accountsAndCredentials/accounts.json +accountsAndCredentials/token*.json +!accountsAndCredentials/*.example.json # Runtime output mailSummaries/ diff --git a/accounts.example.json b/accountsAndCredentials/accounts.example.json similarity index 100% rename from accounts.example.json rename to accountsAndCredentials/accounts.example.json diff --git a/accountsAndCredentials/credentials.example.json b/accountsAndCredentials/credentials.example.json new file mode 100644 index 0000000..e3ac6d0 --- /dev/null +++ b/accountsAndCredentials/credentials.example.json @@ -0,0 +1,11 @@ +{ + "installed": { + "client_id": "", + "project_id": "", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_secret": "", + "redirect_uris": ["http://localhost"] + } +} diff --git a/accountsAndCredentials/token.example.json b/accountsAndCredentials/token.example.json new file mode 100644 index 0000000..edd2b4e --- /dev/null +++ b/accountsAndCredentials/token.example.json @@ -0,0 +1,7 @@ +{ + "access_token": "", + "refresh_token": "", + "scope": "https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/calendar.events", + "token_type": "Bearer", + "expiry_date": 0 +} diff --git a/src/auth.ts b/src/auth.ts index ba69ea5..45103ea 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -5,8 +5,9 @@ import readline from "readline"; const __dirname = path.dirname(new URL(import.meta.url).pathname); const PROJECT_ROOT = path.resolve(__dirname, ".."); -const CREDENTIALS_PATH = path.join(PROJECT_ROOT, "credentials.json"); -const ACCOUNTS_PATH = path.join(PROJECT_ROOT, "accounts.json"); +const SECRETS_DIR = path.join(PROJECT_ROOT, "accountsAndCredentials"); +const CREDENTIALS_PATH = path.join(SECRETS_DIR, "credentials.json"); +const ACCOUNTS_PATH = path.join(SECRETS_DIR, "accounts.json"); const SCOPES = [ "https://www.googleapis.com/auth/gmail.modify", @@ -26,7 +27,7 @@ function resolveTokenPath(accountKey: string): string { `Unknown account "${accountKey}". Available: ${available}` ); } - return path.join(PROJECT_ROOT, acct.tokenFile); + return path.join(SECRETS_DIR, acct.tokenFile); } async function authorize(): Promise { @@ -44,7 +45,7 @@ async function authorize(): Promise { "1. Go to https://console.cloud.google.com/\n" + "2. Create a project and enable the Gmail, Sheets, and Calendar APIs\n" + "3. Create OAuth 2.0 credentials (Desktop app type)\n" + - "4. Download the JSON and save it as credentials.json in the project root\n" + "4. Download the JSON and save it as credentials.json in the accountsAndCredentials/ folder\n" ); process.exit(1); } diff --git a/src/loaders/prompt-config-loaders.ts b/src/loaders/prompt-config-loaders.ts index 9252bc5..954ac60 100644 --- a/src/loaders/prompt-config-loaders.ts +++ b/src/loaders/prompt-config-loaders.ts @@ -9,8 +9,9 @@ import path from "path"; // --------------------------------------------------------------------------- const __dirname = path.dirname(new URL(import.meta.url).pathname); export const PROJECT_ROOT = path.resolve(__dirname, "..", ".."); -const CREDENTIALS_PATH = path.join(PROJECT_ROOT, "credentials.json"); -const ACCOUNTS_PATH = path.join(PROJECT_ROOT, "accounts.json"); +const SECRETS_DIR = path.join(PROJECT_ROOT, "accountsAndCredentials"); +const CREDENTIALS_PATH = path.join(SECRETS_DIR, "credentials.json"); +const ACCOUNTS_PATH = path.join(SECRETS_DIR, "accounts.json"); const CLASSIFY_PROMPT_PATH = path.join(PROJECT_ROOT, "classify-emails.txt"); const ACTION_PROMPT_PATH = path.join( PROJECT_ROOT, "src", "prompts", "take-action-on-emails.txt" @@ -46,7 +47,7 @@ export const getTokenPath = (account: string): string => { `Unknown account "${account}". Available accounts: ${available}` ); } - return path.join(PROJECT_ROOT, acct.tokenFile); + return path.join(SECRETS_DIR, acct.tokenFile); }; export const getSummaryPath = (account: string): string => {