Skip to content

Commit

Permalink
successful login
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Dec 13, 2024
1 parent 3146a14 commit be7ed86
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 16 deletions.
123 changes: 123 additions & 0 deletions .twitter-cookies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"test_curation": [
{
"key": "guest_id_marketing",
"value": "v1%3A173411156497448262",
"expires": "2026-12-13T17:39:24.000Z",
"maxAge": 63072000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:24.940Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
},
{
"key": "guest_id_ads",
"value": "v1%3A173411156497448262",
"expires": "2026-12-13T17:39:24.000Z",
"maxAge": 63072000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:24.940Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
},
{
"key": "personalization_id",
"value": "\"v1_diGrW+pVpR/ssMAngcgWSA==\"",
"expires": "2026-12-13T17:39:24.000Z",
"maxAge": 63072000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:24.940Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
},
{
"key": "guest_id",
"value": "v1%3A173411156497448262",
"expires": "2026-12-13T17:39:24.000Z",
"maxAge": 63072000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:24.940Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
},
{
"key": "kdt",
"value": "0p4rMjho9o97e4PUZO3xaUQK8FQTA4zxhd0rYRLk",
"expires": "2026-06-13T17:39:25.000Z",
"maxAge": 47260800,
"domain": "twitter.com",
"path": "/",
"secure": true,
"httpOnly": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:25.756Z",
"lastAccessed": "2024-12-13T17:39:26.028Z"
},
{
"key": "twid",
"value": "\"u=1867312511835414528\"",
"expires": "2029-12-12T17:39:25.000Z",
"maxAge": 157680000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:25.756Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
},
{
"key": "ct0",
"value": "b663b7bf057d3c93f8bb152b771623828817043839fc6690c9102eed68300459083078ccaff9297fa1089f35cc8a768aeb3e374b55a478d566b8eae1f3a6216248836c623b67452b51a74dc0cd0d5fe8",
"expires": "2029-12-12T17:39:25.000Z",
"maxAge": 157680000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:25.756Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "lax"
},
{
"key": "auth_token",
"value": "80fbaad906276362298e0eddfaa47b85f303e641",
"expires": "2029-12-12T17:39:25.000Z",
"maxAge": 157680000,
"domain": "twitter.com",
"path": "/",
"secure": true,
"httpOnly": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:25.757Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
},
{
"key": "att",
"value": "1-oY95via1STozr4kmdfAWOlTYQPi3VDX2R5RGaWl1",
"expires": "2024-12-14T17:39:25.000Z",
"maxAge": 86400,
"domain": "twitter.com",
"path": "/",
"secure": true,
"httpOnly": true,
"hostOnly": false,
"creation": "2024-12-13T17:39:25.842Z",
"lastAccessed": "2024-12-13T17:39:26.028Z",
"sameSite": "none"
}
]
}
4 changes: 3 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { AppConfig } from "../types";

const config: AppConfig = {
twitter: {
username: process.env.TWITTER_USERNAME!,
password: process.env.TWITTER_PASSWORD!,
email: process.env.TWITTER_EMAIL!,
apiKey: process.env.TWITTER_API_KEY || "",
apiSecret: process.env.TWITTER_API_SECRET || "",
accessToken: process.env.TWITTER_ACCESS_TOKEN || "",
accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET || "",
bearerToken: process.env.TWITTER_BEARER_TOKEN || "",
},
near: {
networkId: process.env.NEAR_NETWORK_ID || "testnet",
Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
startSpinner,
succeedSpinner,
failSpinner,
handleError,
cleanup
} from "./utils/logger";

Expand Down Expand Up @@ -38,7 +37,7 @@ async function main() {
process.exit(0);
} catch (error) {
failSpinner('shutdown', 'Error during shutdown');
handleError(error, 'Shutdown');
logger.error('Shutdown', error);
process.exit(1);
}
});
Expand All @@ -52,7 +51,7 @@ async function main() {
['env', 'near', 'twitter-init'].forEach(key => {
failSpinner(key, `Failed during ${key}`);
});
handleError(error, 'Startup');
logger.error('Startup', error);
cleanup();
process.exit(1);
}
Expand All @@ -61,6 +60,6 @@ async function main() {
// Start the application
logger.info('Starting Public Goods News Bot...');
main().catch((error) => {
handleError(error, 'Unhandled Exception');
logger.error('Unhandled Exception', error);
process.exit(1);
});
24 changes: 13 additions & 11 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const logger = winston.createLogger({
showMeta: true,
metaStrip: ['timestamp', 'service'],
inspectOptions: {
depth: 1,
depth: 4, // Increased depth for better error inspection
colors: true,
maxArrayLength: 10,
breakLength: 120,
Expand All @@ -42,7 +42,7 @@ export const startSpinner = (key: string, text: string): void => {
return;
}
spinners[key] = ora({
text,
text: `${text}\n`,
color: 'cyan',
spinner: 'dots',
}).start();
Expand Down Expand Up @@ -75,15 +75,17 @@ export const clearSpinner = (key: string): void => {
}
};

// Error handling
export const handleError = (error: unknown, context: string): void => {
const errorMessage = error instanceof Error ? error.message : String(error);
logger.error(`${context}: ${errorMessage}`, {
error,
context,
timestamp: new Date().toISOString(),
});
};
// Interface for error details
interface ErrorDetails {
name: string;
message: string;
stack?: string;
context: string;
timestamp: string;
type?: string;
possibleCause?: string;
[key: string]: unknown; // Index signature for additional properties
}

// Cleanup function to clear all spinners
export const cleanup = (): void => {
Expand Down

0 comments on commit be7ed86

Please sign in to comment.