Skip to content

Commit

Permalink
Merge pull request #99 from retoheusser/automatically-update-signatur…
Browse files Browse the repository at this point in the history
…e-each-week

Automatically update signature each week
  • Loading branch information
s-alad authored Apr 3, 2024
2 parents 845915d + 93f5b6b commit d847dec
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 150 deletions.
53 changes: 38 additions & 15 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"axios": "^1.4.0",
"file-saver": "^2.0.5",
"formidable": "^3.4.0",
"happy-headers": "^1.0.0",
"heic-convert": "^1.2.4",
"i18next": "^23.2.3",
"jimp": "^0.22.8",
Expand Down
27 changes: 5 additions & 22 deletions client/pages/api/add/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sharp from 'sharp';
import moment from 'moment';
// @ts-ignore
import * as convert from 'heic-convert';
import { BEREAL_SIGNATURE } from '@/utils/constants';
import { getAuthHeaders } from '@/utils/authHeaders';

export const config = {
api: {
Expand Down Expand Up @@ -134,18 +134,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// ============================================================================================
// upload url

let upload_headers = {
"authorization": "Bearer " + authorization_token,
'bereal-app-version-code': '14549',
'bereal-signature': BEREAL_SIGNATURE,
'bereal-timezone': 'Europe/Paris',
'bereal-device-id': '937v3jb942b0h6u9'
}

let upload_options = {
url: "https://mobile.bereal.com/api/content/posts/upload-url?mimeType=image/webp",
method: "GET",
headers: upload_headers,
headers: getAuthHeaders(authorization_token),
}

let upload_res = await axios.request(upload_options)
Expand All @@ -161,19 +153,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
let primary_url = primary_res.url;
let primary_path = primary_res.path;
let primary_bucket = primary_res.bucket;
primary_headers["Authorization"] = "Bearer " + authorization_token
primary_headers["bereal-app-version-code"] = "14549";
primary_headers["bereal-signature"] = "berealsignature";
primary_headers["bereal-device-id"] = "berealdeviceid";
Object.assign(primary_headers, getAuthHeaders(authorization_token))

let secondary_headers = secondary_res.headers;
let secondary_url = secondary_res.url;
let secondary_path = secondary_res.path;
let secondary_bucket = secondary_res.bucket;
secondary_headers["Authorization"] = "Bearer " + authorization_token
secondary_headers["bereal-app-version-code"] = "14549";
secondary_headers["bereal-signature"] = "berealsignature";
secondary_headers["bereal-device-id"] = "berealdeviceid";
Object.assign(secondary_headers, getAuthHeaders(authorization_token))

// ============================================================================================

Expand Down Expand Up @@ -225,16 +211,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
};
let post_headers = {
"content-type": "application/json",
"Authorization": "Bearer " + authorization_token,
'bereal-app-version-code': '14549',
'bereal-signature': BEREAL_SIGNATURE,
'bereal-timezone': 'Europe/Paris',
'bereal-device-id': '937v3jb942b0h6u9',
"bereal-os-version": "14.7.1",
"accept-language": "en-US;q=1.0",
"bereal-app-language": "en-US",
"user-agent": "BeReal/0.28.2 (AlexisBarreyat.BeReal; build:8425; iOS 14.7.1) 1.0.0/BRApiKit",
"bereal-device-language": "en",
...getAuthHeaders(authorization_token)
}
console.log("post data");
console.log(post_data);
Expand Down
21 changes: 4 additions & 17 deletions client/pages/api/add/realmoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Jimp from "jimp";
import fs from "fs";
import sharp from 'sharp';
import moment from 'moment';
import { getAuthHeaders } from '@/utils/authHeaders';

export const config = {
api: {
Expand Down Expand Up @@ -79,17 +80,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// ============================================================================================
// upload url

let upload_headers = {
"authorization": "Bearer " + authorization_token,
"bereal-app-version-code": "14549",
"bereal-signature": "berealsignature",
"bereal-device-id": "berealdeviceid",
}

let upload_options = {
url: "https://mobile.bereal.com/api/content/realmojis/upload-url?mimeType=image/webp",
method: "GET",
headers: upload_headers,
headers: getAuthHeaders(authorization_token),
}

let upload_res = await axios.request(upload_options)
Expand All @@ -104,10 +98,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
let primary_url = primary_res.url;
let primary_path = primary_res.path;
let primary_bucket = primary_res.bucket;
primary_headers["Authorization"] = "Bearer " + authorization_token;
primary_headers["bereal-app-version-code"] = "14549";
primary_headers["bereal-signature"] = "berealsignature";
primary_headers["bereal-device-id"] = "berealdeviceid";
Object.assign(primary_headers, getAuthHeaders(authorization_token))

// ============================================================================================

Expand Down Expand Up @@ -136,17 +127,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
};
let post_headers = {
"content-type": "application/json",
"Authorization": "Bearer " + authorization_token,
"bereal-app-version-code": "14549",
"bereal-signature": "berealsignature",
"bereal-device-id": "berealdeviceid",
"bereal-platform": "iOS",
"bereal-os-version": "14.7.1",
"accept-language": "en-US;q=1.0",
"bereal-app-language": "en-US",
"user-agent": "BeReal/0.28.2 (AlexisBarreyat.BeReal; build:8425; iOS 14.7.1) 1.0.0/BRApiKit",
"bereal-timezone": "America/Los_Angeles",
"bereal-device-language": "en",
...getAuthHeaders(authorization_token)
}
console.log("post data");
console.log(post_data);
Expand Down
14 changes: 2 additions & 12 deletions client/pages/api/all.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import { BEREAL_SIGNATURE } from '@/utils/constants';
import { getAuthHeaders } from '@/utils/authHeaders';

export const config = {
api: {
Expand All @@ -12,22 +12,12 @@ export const config = {

export default async function handler(req: NextApiRequest, res: NextApiResponse) {

let authorization_token = req.body.token;

let headers = {
"authorization": "Bearer " + authorization_token,
'bereal-app-version-code': '14549',
'bereal-signature': BEREAL_SIGNATURE,
'bereal-timezone': 'Europe/Paris',
'bereal-device-id': '937v3jb942b0h6u9'
}

console.log("FETCHING FEED")

return axios.request({
url: "https://mobile.bereal.com/api" + "/feeds/friends-v1",
method: "GET",
headers: headers,
headers: getAuthHeaders(req.body.token),
}).then(
(response) => {
console.log("------------------")
Expand Down
12 changes: 3 additions & 9 deletions client/pages/api/comment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import { BEREAL_SIGNATURE } from '@/utils/constants';
import { getAuthHeaders } from '@/utils/authHeaders';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {

Expand All @@ -11,20 +11,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
console.log("me");
console.log(authorization_token)
console.log(instance_id, comment);
let headers = {
"authorization": "Bearer " + authorization_token,
'bereal-app-version-code': '14549',
'bereal-signature': BEREAL_SIGNATURE,
'bereal-timezone': 'Europe/Paris',
'bereal-device-id': '937v3jb942b0h6u9',
}

let body = {
content: comment,
}
let options = {
url: "https://mobile.bereal.com/api" + "/content/comments" + "?postId=" + instance_id + "&postUserId=" + poster_user_id,
method: "POST",
headers: headers,
headers: getAuthHeaders(req.body.token),
data: body,
}

Expand Down
9 changes: 2 additions & 7 deletions client/pages/api/delete.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import { getAuthHeaders } from '@/utils/authHeaders';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {

let authorization_token = req.body.token;
console.log("me");
console.log(authorization_token);
let headers = {
"authorization": "Bearer " + authorization_token,
"bereal-app-version-code": "14549",
"bereal-signature": "berealsignature",
"bereal-device-id": "berealdeviceid",
}

return axios.request({
url: "https://mobile.bereal.com/api" + "/content/posts",
method: "DELETE",
headers: headers,
headers: getAuthHeaders(req.body.token),
}).then(
(response) => {
console.log("------------------")
Expand Down
14 changes: 2 additions & 12 deletions client/pages/api/feed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import { BEREAL_SIGNATURE } from '@/utils/constants';
import { getAuthHeaders } from '@/utils/authHeaders';

export const config = {
api: {
Expand All @@ -12,22 +12,12 @@ export const config = {

export default async function handler(req: NextApiRequest, res: NextApiResponse) {

let authorization_token = req.body.token;

let headers = {
"authorization": "Bearer " + authorization_token,
"bereal-app-version-code": "14549",
"bereal-signature": BEREAL_SIGNATURE,
'bereal-device-id': '937v3jb942b0h6u9',
'bereal-timezone': 'Europe/Paris',
}

console.log("FETCING FEED")

return axios.request({
url: "https://mobile.bereal.com/api" + "/feeds/friends",
method: "GET",
headers: headers,
headers: getAuthHeaders(req.body.token),
}).then(
(response) => {
console.log("------------------")
Expand Down
12 changes: 3 additions & 9 deletions client/pages/api/friends.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import { BEREAL_SIGNATURE } from '@/utils/constants';
import { getAuthHeaders } from '@/utils/authHeaders';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let authorization_token = req.body.token;
console.log("friends");
console.log(authorization_token);
let headers = {
"authorization": "Bearer " + authorization_token,
"bereal-app-version-code": "14549",
"bereal-signature": BEREAL_SIGNATURE,
'bereal-device-id': '937v3jb942b0h6u9',
'bereal-timezone': 'Europe/Paris',
}

return axios.request({
url: "https://mobile.bereal.com/api" + "/relationships/friends",
method: "GET",
headers: headers,
headers: getAuthHeaders(req.body.token),
}).then(
(response) => {
console.log("------------------")
Expand Down
Loading

0 comments on commit d847dec

Please sign in to comment.