rettiwt-api 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/queries/RootQuery.js +11 -0
- package/dist/queries/RootQuery.js.map +1 -1
- package/dist/resolvers/AccountResolver.d.ts +12 -0
- package/dist/resolvers/AccountResolver.js +84 -0
- package/dist/resolvers/AccountResolver.js.map +1 -0
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/services/AccountsService.d.ts +17 -0
- package/dist/services/AccountsService.js +171 -0
- package/dist/services/AccountsService.js.map +1 -0
- package/dist/services/FetcherService.d.ts +11 -2
- package/dist/services/FetcherService.js +47 -23
- package/dist/services/FetcherService.js.map +1 -1
- package/dist/services/accounting/AccountsService.d.ts +20 -0
- package/dist/services/accounting/AccountsService.js +147 -0
- package/dist/services/accounting/AccountsService.js.map +1 -0
- package/dist/services/accounting/Flows.d.ts +0 -0
- package/dist/services/accounting/Flows.js +2 -0
- package/dist/services/accounting/Flows.js.map +1 -0
- package/dist/services/accounting/LoginFlows.d.ts +20 -0
- package/dist/services/accounting/LoginFlows.js +70 -0
- package/dist/services/accounting/LoginFlows.js.map +1 -0
- package/dist/services/accounts/AccountService.d.ts +42 -0
- package/dist/services/accounts/AccountService.js +291 -0
- package/dist/services/accounts/AccountService.js.map +1 -0
- package/dist/services/accounts/LoginFlows.d.ts +77 -0
- package/dist/services/accounts/LoginFlows.js +92 -0
- package/dist/services/accounts/LoginFlows.js.map +1 -0
- package/dist/services/helper/Headers.d.ts +11 -1
- package/dist/services/helper/Headers.js +28 -2
- package/dist/services/helper/Headers.js.map +1 -1
- package/dist/types/HTTP.d.ts +0 -7
- package/dist/types/HTTP.js +1 -10
- package/dist/types/HTTP.js.map +1 -1
- package/dist/types/Service.d.ts +2 -0
- package/dist/types/Service.js.map +1 -1
- package/package.json +4 -2
- package/src/index.ts +3 -1
- package/src/queries/RootQuery.ts +11 -0
- package/src/resolvers/AccountResolver.ts +22 -0
- package/src/server.ts +3 -1
- package/src/services/FetcherService.ts +26 -8
- package/src/services/accounts/AccountService.ts +156 -0
- package/src/services/accounts/LoginFlows.ts +90 -0
- package/src/services/helper/Headers.ts +27 -1
- package/src/types/HTTP.ts +0 -8
- package/src/types/Service.ts +3 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const LoginFlows = {
|
|
2
|
+
"InitiateLogin": {
|
|
3
|
+
url: 'https://api.twitter.com/1.1/onboarding/task.json?flow_name=login'
|
|
4
|
+
},
|
|
5
|
+
"JsInstrumentationSubtask": {
|
|
6
|
+
url: 'https://api.twitter.com/1.1/onboarding/task.json',
|
|
7
|
+
body: (flowToken: string) => ({
|
|
8
|
+
"flow_token": flowToken,
|
|
9
|
+
"subtask_inputs": [
|
|
10
|
+
{
|
|
11
|
+
"subtask_id": "LoginJsInstrumentationSubtask",
|
|
12
|
+
"js_instrumentation": {
|
|
13
|
+
"response": "{\"rf\":{\"a09453c7341fb1cbb7d51561f92d478fa0752bc77e7ca6b5703258680b2c51d7\":-4,\"bd26c6694e256b10766447d992deaf92bb220bc05e3b8205ba5c9a4f83302230\":0,\"abfa440376b8dc33ca518e1e2a998b3ac4200a8122ef09781eea2c1408717111\":-1,\"a4e87b66027f638a4634561275fab00f9f7446b81a180b5f03eda69fa32eb8f4\":-224},\"s\":\"yET9nlXrlGRAylCyyBKEsxOpUweMpjRz5RfKzTzQyVADnKE64gmpyILfKBK0-HIHWY8FbJPHGWr6QrCb5A-Z3q2SLRm4DReprZGXykJ111_ynet8kSjFkRjODKKDN2FzT1V6rx9FILnUuRCaMu9ewfPgPBi4wO1g7EUeEsSSHIiCwNc9URJr4c2xVTA3ibIfTbu8p2WhX7RZAk8LWRPpPPB21st8Z1j0LcLlR0bkZoF6LsN-7w75lGB0s4z1JKqus2MVuRcPMay0wWZbn8Qx9In_-tSTvEBLcxjUpDgwu29G0g0iCWoISFzLY4-LLvV7UBGklkByIcPtwYbDbREqRQAAAYYmXAsG\"}",
|
|
14
|
+
"link": "next_link"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
"EnterUserIdentifier": {
|
|
21
|
+
url: 'https://api.twitter.com/1.1/onboarding/task.json',
|
|
22
|
+
body: (flowToken: string, email: string) => ({
|
|
23
|
+
"flow_token": flowToken,
|
|
24
|
+
"subtask_inputs": [
|
|
25
|
+
{
|
|
26
|
+
"subtask_id": "LoginEnterUserIdentifierSSO",
|
|
27
|
+
"settings_list": {
|
|
28
|
+
"setting_responses": [
|
|
29
|
+
{
|
|
30
|
+
"key": "user_identifier",
|
|
31
|
+
"response_data": {
|
|
32
|
+
"text_data": {
|
|
33
|
+
"result": email
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"link": "next_link"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
"EnterAlternateUserIdentifier": {
|
|
45
|
+
url: 'https://api.twitter.com/1.1/onboarding/task.json',
|
|
46
|
+
body: (flowToken: string, userName: string) => ({
|
|
47
|
+
"flow_token": flowToken,
|
|
48
|
+
"subtask_inputs": [
|
|
49
|
+
{
|
|
50
|
+
"subtask_id": "LoginEnterAlternateIdentifierSubtask",
|
|
51
|
+
"enter_text": {
|
|
52
|
+
"text": userName,
|
|
53
|
+
"link": "next_link"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
"EnterPassword": {
|
|
60
|
+
url: 'https://api.twitter.com/1.1/onboarding/task.json',
|
|
61
|
+
body: (flowToken: string, password: string) => ({
|
|
62
|
+
"flow_token": flowToken,
|
|
63
|
+
"subtask_inputs": [
|
|
64
|
+
{
|
|
65
|
+
"subtask_id": "LoginEnterPassword",
|
|
66
|
+
"enter_password": {
|
|
67
|
+
"password": password,
|
|
68
|
+
"link": "next_link"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
"AccountDuplicationCheck": {
|
|
75
|
+
url: 'https://api.twitter.com/1.1/onboarding/task.json',
|
|
76
|
+
body: (flowToken: string) => ({
|
|
77
|
+
"flow_token": flowToken,
|
|
78
|
+
"subtask_inputs": [
|
|
79
|
+
{
|
|
80
|
+
"subtask_id": "AccountDuplicationCheck",
|
|
81
|
+
"check_logged_in_account": {
|
|
82
|
+
"link": "AccountDuplicationCheck_false"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default LoginFlows;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { GuestCredentials, AuthCredentials } from '../../types/Authentication';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @returns The header required for making authorized HTTP requests
|
|
6
5
|
* @param authToken The authentication token received from Twitter
|
|
7
6
|
* @param csrfToken The csrf token received from Twitter
|
|
8
7
|
* @param cookie The cookie associated with the logged in account
|
|
8
|
+
* @returns The header required for making authorized HTTP requests
|
|
9
9
|
*/
|
|
10
10
|
export function authorizedHeader(authCred: AuthCredentials): any {
|
|
11
11
|
return [
|
|
@@ -24,6 +24,10 @@ export function authorizedHeader(authCred: AuthCredentials): any {
|
|
|
24
24
|
];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @param guestCred The guest credentials to use
|
|
29
|
+
* @returns The header requred for making guest HTTP requests
|
|
30
|
+
*/
|
|
27
31
|
export function guestHeader(guestCred: GuestCredentials): any {
|
|
28
32
|
return [
|
|
29
33
|
'Accept: */*',
|
|
@@ -31,4 +35,26 @@ export function guestHeader(guestCred: GuestCredentials): any {
|
|
|
31
35
|
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.70',
|
|
32
36
|
`x-guest-token: ${guestCred.guestToken}`
|
|
33
37
|
];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param guestCred The guest credentials to use for making the login requests
|
|
42
|
+
* @param cookie The cookie to be used
|
|
43
|
+
* @returns The header for making HTTP request for logging in
|
|
44
|
+
*/
|
|
45
|
+
export function loginHeader(guestCred: GuestCredentials, cookie: string): any {
|
|
46
|
+
return [
|
|
47
|
+
`sec-ch-ua: "Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"`,
|
|
48
|
+
`x-twitter-client-language: en`,
|
|
49
|
+
`sec-ch-ua-mobile: ?0`,
|
|
50
|
+
`authorization: ${guestCred.authToken}`,
|
|
51
|
+
`User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.78`,
|
|
52
|
+
`content-type: application/json`,
|
|
53
|
+
`x-guest-token: ${guestCred.guestToken}`,
|
|
54
|
+
`x-twitter-active-user: yes`,
|
|
55
|
+
`sec-ch-ua-platform: "Windows"`,
|
|
56
|
+
`Accept: */*`,
|
|
57
|
+
`host: api.twitter.com`,
|
|
58
|
+
`Cookie: ${cookie}`
|
|
59
|
+
];
|
|
34
60
|
}
|
package/src/types/HTTP.ts
CHANGED
package/src/types/Service.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SERVICES
|
|
2
|
+
import { AccountService } from "../services/accounts/AccountService";
|
|
2
3
|
import { TweetService } from "../services/data/TweetService";
|
|
3
4
|
import { UserAccountService } from "../services/data/UserAccountService";
|
|
4
5
|
|
|
@@ -33,5 +34,6 @@ export interface CursoredData<Type> {
|
|
|
33
34
|
*/
|
|
34
35
|
export interface DataContext {
|
|
35
36
|
users: UserAccountService, // To store the source for fetching user account data
|
|
36
|
-
tweets: TweetService
|
|
37
|
+
tweets: TweetService, // To store the source for fetching tweet data
|
|
38
|
+
account: AccountService // To store the source for account related operations
|
|
37
39
|
}
|