Skip to content

Commit

Permalink
fix login bug + fs import
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvraj108c committed Dec 13, 2022
1 parent a1121c9 commit 45dd779
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/handlers/common/upload_photo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_URL } from '../../config';
import HTTP_CLIENT from '../../http';
import fs from 'fs';
import * as fs from 'fs';
import { Image, MediaUploadRes } from '../../types';
const sizeOf = require('image-size');

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/common/upload_video.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_URL } from '../../config';
import HTTP_CLIENT from '../../http';
import fs from 'fs';
import * as fs from 'fs';
import { MediaUploadRes } from '../../types';

async function uploadVideo({
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/common/upload_video_thumbnail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_URL } from '../../config';
import HTTP_CLIENT from '../../http';
import fs from 'fs';
import * as fs from 'fs';
import { MediaUploadRes } from '../../types';
const request = require('request-promise-native');

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/common/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
VIDEO_NOT_FOUND_ERR,
} from '../../errors';
import { Image } from '../../types';
import fs from 'fs';
import * as fs from 'fs';
const sizeOf = require('image-size');

export function validateCaption(caption: string) {
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/login.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import * as fs from 'fs';
import { LOGIN_ERR, LOGIN_ERR_COOKIES } from '../errors';
import HTTP_CLIENT from '../http';
import { COOKIES_FILE_PATH } from '../config';
Expand All @@ -18,9 +18,9 @@ async function login({
let value;
await HTTP_CLIENT.request('/', { resolveWithFullResponse: true }).then(
res => {
const pattern = new RegExp(/(csrf_token":")\w+/);
const matches = res.toJSON().body.match(pattern);
value = matches[0].substring(13);
const pattern = new RegExp(/(csrf_token\\":\\")[\w]+/);
const matches = res.body.match(pattern);
value = matches[0].substring(15);
}
);

Expand Down
2 changes: 1 addition & 1 deletion src/http.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OptionsWithUri, RequestPromiseAPI } from 'request-promise-native';
import fs from 'fs';
import * as fs from 'fs';
import { ICookie } from './types';
import { validateCookies } from './shared';
import { BASE_URL, COOKIES_FILE_PATH } from './config';
Expand Down
2 changes: 1 addition & 1 deletion src/shared.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import * as fs from 'fs';
import { COOKIES_FILE_PATH } from './config';

export function validateCookies(): Boolean {
Expand Down
11 changes: 4 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6702,13 +6702,10 @@
"resolved" "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz"
"version" "3.9.10"

"typescript@^4.6.4":
"integrity" "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA=="
"resolved" "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz"
"version" "4.7.3"

"typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta":
"version" "3.9.10"
"typescript@^4.6.4", "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta":
"integrity" "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg=="
"resolved" "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz"
"version" "4.9.4"

"unbox-primitive@^1.0.2":
"integrity" "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw=="
Expand Down

0 comments on commit 45dd779

Please sign in to comment.