mirror of
https://github.com/tlsnotary/tlsn-plugin-boilerplate.git
synced 2026-01-08 04:23:52 -05:00
fix: twitter plugin
This commit is contained in:
@@ -25,10 +25,10 @@
|
||||
"notarize"
|
||||
],
|
||||
"cookies": [
|
||||
"api.x.com"
|
||||
"https://api.x.com/1.1/account/settings.json"
|
||||
],
|
||||
"headers": [
|
||||
"api.x.com"
|
||||
"https://api.x.com/1.1/account/settings.json"
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
|
||||
16
src/index.ts
16
src/index.ts
@@ -40,34 +40,38 @@ export function start() {
|
||||
* Note that the url needs to be specified in the `config` too, otherwise the request will be refused.
|
||||
*/
|
||||
export function two() {
|
||||
const cookies = getCookiesByHost('api.x.com');
|
||||
const headers = getHeadersByHost('api.x.com');
|
||||
const cookies = getCookiesByHost('https://api.x.com/1.1/account/settings.json');
|
||||
const headers = getHeadersByHost('https://api.x.com/1.1/account/settings.json');
|
||||
|
||||
if (
|
||||
!cookies.auth_token ||
|
||||
!cookies.ct0 ||
|
||||
!headers['x-csrf-token'] ||
|
||||
!headers['authorization']
|
||||
!headers['authorization'] ||
|
||||
!headers['x-client-transaction-id']
|
||||
) {
|
||||
outputJSON(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const cookieString = Object.entries(cookies).map(([name, value]) => `${name}=${value}`).join('; ')
|
||||
|
||||
outputJSON({
|
||||
url: 'https://api.x.com/1.1/account/settings.json',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'x-twitter-client-language': 'en',
|
||||
Cookie: cookieString,
|
||||
'x-csrf-token': headers['x-csrf-token'],
|
||||
'x-client-transaction-id': headers['x-client-transaction-id'],
|
||||
Host: 'api.x.com',
|
||||
authorization: headers.authorization,
|
||||
Cookie: `lang=en; auth_token=${cookies.auth_token}; ct0=${cookies.ct0}`,
|
||||
'Accept-Encoding': 'identity',
|
||||
Connection: 'close',
|
||||
},
|
||||
secretHeaders: [
|
||||
`x-csrf-token: ${headers['x-csrf-token']}`,
|
||||
`cookie: lang=en; auth_token=${cookies.auth_token}; ct0=${cookies.ct0}`,
|
||||
`x-client-transaction-id: ${headers['x-client-transaction-id']}`,
|
||||
`cookie: ${cookieString}`,
|
||||
`authorization: ${headers.authorization}`,
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user