rettiwt-api 1.0.4 → 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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +3 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/queries/RootQuery.js +11 -0
  6. package/dist/queries/RootQuery.js.map +1 -1
  7. package/dist/resolvers/AccountResolver.d.ts +12 -0
  8. package/dist/resolvers/AccountResolver.js +84 -0
  9. package/dist/resolvers/AccountResolver.js.map +1 -0
  10. package/dist/server.js +3 -1
  11. package/dist/server.js.map +1 -1
  12. package/dist/services/AccountsService.d.ts +17 -0
  13. package/dist/services/AccountsService.js +171 -0
  14. package/dist/services/AccountsService.js.map +1 -0
  15. package/dist/services/FetcherService.d.ts +11 -2
  16. package/dist/services/FetcherService.js +47 -23
  17. package/dist/services/FetcherService.js.map +1 -1
  18. package/dist/services/accounting/AccountsService.d.ts +20 -0
  19. package/dist/services/accounting/AccountsService.js +147 -0
  20. package/dist/services/accounting/AccountsService.js.map +1 -0
  21. package/dist/services/accounting/Flows.d.ts +0 -0
  22. package/dist/services/accounting/Flows.js +2 -0
  23. package/dist/services/accounting/Flows.js.map +1 -0
  24. package/dist/services/accounting/LoginFlows.d.ts +20 -0
  25. package/dist/services/accounting/LoginFlows.js +70 -0
  26. package/dist/services/accounting/LoginFlows.js.map +1 -0
  27. package/dist/services/accounts/AccountService.d.ts +42 -0
  28. package/dist/services/accounts/AccountService.js +291 -0
  29. package/dist/services/accounts/AccountService.js.map +1 -0
  30. package/dist/services/accounts/LoginFlows.d.ts +77 -0
  31. package/dist/services/accounts/LoginFlows.js +92 -0
  32. package/dist/services/accounts/LoginFlows.js.map +1 -0
  33. package/dist/services/helper/Headers.d.ts +11 -1
  34. package/dist/services/helper/Headers.js +28 -2
  35. package/dist/services/helper/Headers.js.map +1 -1
  36. package/dist/services/helper/Urls.js +8 -8
  37. package/dist/services/helper/Urls.js.map +1 -1
  38. package/dist/types/HTTP.d.ts +0 -7
  39. package/dist/types/HTTP.js +1 -10
  40. package/dist/types/HTTP.js.map +1 -1
  41. package/dist/types/Service.d.ts +2 -0
  42. package/dist/types/Service.js.map +1 -1
  43. package/package.json +4 -2
  44. package/src/index.ts +3 -1
  45. package/src/queries/RootQuery.ts +11 -0
  46. package/src/resolvers/AccountResolver.ts +22 -0
  47. package/src/server.ts +3 -1
  48. package/src/services/FetcherService.ts +26 -8
  49. package/src/services/accounts/AccountService.ts +156 -0
  50. package/src/services/accounts/LoginFlows.ts +90 -0
  51. package/src/services/helper/Headers.ts +27 -1
  52. package/src/services/helper/Urls.ts +8 -8
  53. package/src/types/HTTP.ts +0 -8
  54. package/src/types/Service.ts +3 -1
@@ -0,0 +1,156 @@
1
+ // PACKAGES
2
+ import { curly, CurlyResult } from 'node-libcurl';
3
+
4
+ // SERVICES
5
+ import { AuthService } from '../AuthService';
6
+
7
+ // TYPES
8
+ import { GuestCredentials } from '../../types/Authentication';
9
+
10
+ // HELPERS
11
+ import LoginFlows from './LoginFlows';
12
+ import { loginHeader } from '../helper/Headers';
13
+ import { Cookie, CookieJar } from 'cookiejar';
14
+
15
+ export class AccountService {
16
+ // MEMBER DATA
17
+ private auth: AuthService; // To store the auth service instance to use
18
+ private guestCreds: GuestCredentials; // To store the guest credentials to use
19
+ private cookies: Cookie[]; // To store the cookies received from twitter
20
+ private flowToken: string; // To store the flow token received from current flow
21
+
22
+ // MEMBER METHODS
23
+ constructor() {
24
+ this.auth = new AuthService();
25
+ this.guestCreds = { authToken: '', guestToken: '' };
26
+ this.cookies = [];
27
+ this.flowToken = '';
28
+ }
29
+
30
+ /**
31
+ * @returns The current guest credentials to use. If if does not exists, then a new one is created
32
+ */
33
+ private async getGuestCredentials(): Promise<GuestCredentials> {
34
+ // If a guest credential has not been already set, get a new one
35
+ if (!this.guestCreds.guestToken) {
36
+ this.guestCreds = await this.auth.getGuestCredentials();
37
+ }
38
+
39
+ return this.guestCreds;
40
+ }
41
+
42
+ /**
43
+ * @summary Step 1: Initiates login
44
+ */
45
+ private async initiateLogin(): Promise<void> {
46
+ // Initiating the login process
47
+ const res: CurlyResult = await curly.post(LoginFlows.InitiateLogin.url, {
48
+ httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.toString()),
49
+ sslVerifyPeer: false,
50
+ postFields: ''
51
+ });
52
+
53
+ // Storing cookies received
54
+ this.cookies = new CookieJar().setCookies(res.headers[0]['Set-Cookie'] as string[]);
55
+
56
+ // Getting the flow token
57
+ this.flowToken = res.data['flow_token'];
58
+ }
59
+
60
+ /**
61
+ * @summary Step 2: Does something
62
+ */
63
+ private async jsInstrumentationSubtask(): Promise<void> {
64
+ // Executing the flow
65
+ const res: CurlyResult = await curly.post(LoginFlows.JsInstrumentationSubtask.url, {
66
+ httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
67
+ sslVerifyPeer: false,
68
+ postFields: JSON.stringify(LoginFlows.JsInstrumentationSubtask.body(this.flowToken))
69
+ });
70
+
71
+ // Getting the flow token
72
+ this.flowToken = res.data['flow_token'];
73
+ }
74
+
75
+ /**
76
+ * @summary Step 3: Takes the email for login
77
+ */
78
+ private async enterUserIdentifier(email: string): Promise<void> {
79
+ // Executing the flow
80
+ const res: CurlyResult = await curly.post(LoginFlows.EnterUserIdentifier.url, {
81
+ httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
82
+ sslVerifyPeer: false,
83
+ postFields: JSON.stringify(LoginFlows.EnterUserIdentifier.body(this.flowToken, email))
84
+ });
85
+
86
+ // Getting the flow token
87
+ this.flowToken = res.data['flow_token'];
88
+ }
89
+
90
+ /**
91
+ * @summary Step 4: Takes the username for login
92
+ */
93
+ private async enterAlternateUserIdentifier(userName: string): Promise<void> {
94
+ // Executing the flow
95
+ const res: CurlyResult = await curly.post(LoginFlows.EnterAlternateUserIdentifier.url, {
96
+ httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
97
+ sslVerifyPeer: false,
98
+ postFields: JSON.stringify(LoginFlows.EnterAlternateUserIdentifier.body(this.flowToken, userName))
99
+ });
100
+
101
+ // Getting the flow token
102
+ this.flowToken = res.data['flow_token'];
103
+ }
104
+
105
+ /**
106
+ * @summary Step 5: Takes the password for login
107
+ */
108
+ private async enterPassword(password: string): Promise<void> {
109
+ // Executing the flow
110
+ const res: CurlyResult = await curly.post(LoginFlows.EnterPassword.url, {
111
+ httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
112
+ sslVerifyPeer: false,
113
+ postFields: JSON.stringify(LoginFlows.EnterPassword.body(this.flowToken, password))
114
+ });
115
+
116
+ // Getting the flow token
117
+ this.flowToken = res.data['flow_token'];
118
+ }
119
+
120
+ /**
121
+ * @summary Step 6: Gets the actual cookies
122
+ */
123
+ private async accountDuplicationCheck(): Promise<void> {
124
+ // Executing the flow
125
+ const res: CurlyResult = await curly.post(LoginFlows.AccountDuplicationCheck.url, {
126
+ httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
127
+ sslVerifyPeer: false,
128
+ postFields: JSON.stringify(LoginFlows.AccountDuplicationCheck.body(this.flowToken))
129
+ });
130
+
131
+ // Storing cookies received
132
+ this.cookies = new CookieJar().setCookies(res.headers[0]['Set-Cookie'] as string[]);
133
+
134
+ // Getting the flow token
135
+ this.flowToken = res.data['flow_token'];
136
+ }
137
+
138
+ /**
139
+ * @param email The email of the account to be logged into
140
+ * @param userName The username associated with the given account
141
+ * @param password The password to the account
142
+ * @returns The cookies for authenticating with the given account
143
+ */
144
+ public async login(email: string, userName: string, password: string): Promise<string> {
145
+ // Executing each step of login flow
146
+ await this.initiateLogin();
147
+ await this.jsInstrumentationSubtask();
148
+ await this.enterUserIdentifier(email);
149
+ await this.enterAlternateUserIdentifier(userName);
150
+ await this.enterPassword(password);
151
+ await this.accountDuplicationCheck();
152
+
153
+ // Returning the final cookies
154
+ return this.cookies.join(';');
155
+ }
156
+ }
@@ -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
  }
@@ -28,7 +28,7 @@ export function userAccountByIdUrl(restId: string): string {
28
28
  * @param cursor The cursor to next batch
29
29
  */
30
30
  export function userFollowingUrl(userId: string, count: number, cursor: string): string {
31
- return `https://api.twitter.com/graphql/mSnjZc5CTm2Z5Lu_i4XsPQ/Following?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
31
+ return `https://api.twitter.com/graphql/mSnjZc5CTm2Z5Lu_i4XsPQ/Following?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
32
32
  }
33
33
 
34
34
  /**
@@ -38,7 +38,7 @@ export function userFollowingUrl(userId: string, count: number, cursor: string):
38
38
  * @param cursor The cusor to next batch
39
39
  */
40
40
  export function userFollowersUrl(userId: string, count: number, cursor: string): string {
41
- return `https://api.twitter.com/graphql/nwlAnaw7oKXcVLi91ehy7Q/Followers?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
41
+ return `https://api.twitter.com/graphql/nwlAnaw7oKXcVLi91ehy7Q/Followers?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
42
42
  }
43
43
 
44
44
  /**
@@ -48,7 +48,7 @@ export function userFollowersUrl(userId: string, count: number, cursor: string):
48
48
  * @param cursor The cusor to next batch
49
49
  */
50
50
  export function userLikesUrl(userId: string, count: number, cursor: string): string {
51
- return `https://api.twitter.com/graphql/gP4ZKghLd4tpILgS6VudAQ/Likes?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withClientEventToken%22%3Afalse%2C%22withBirdwatchNotes%22%3Afalse%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
51
+ return `https://api.twitter.com/graphql/gP4ZKghLd4tpILgS6VudAQ/Likes?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withClientEventToken%22%3Afalse%2C%22withBirdwatchNotes%22%3Afalse%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
52
52
  }
53
53
 
54
54
  /**
@@ -58,7 +58,7 @@ export function userLikesUrl(userId: string, count: number, cursor: string): str
58
58
  * @param cursor The cursor to next batch
59
59
  */
60
60
  export function userTweetsUrl(userId: string, count: number, cursor: string): string {
61
- return `https://api.twitter.com/graphql/MsEBEnQjKQCsRlAbC6qKcA/UserTweets?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
61
+ return `https://api.twitter.com/graphql/MsEBEnQjKQCsRlAbC6qKcA/UserTweets?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
62
62
  }
63
63
 
64
64
  /**
@@ -68,7 +68,7 @@ export function userTweetsUrl(userId: string, count: number, cursor: string): st
68
68
  * @param cursor The cusor to next batch *
69
69
  */
70
70
  export function tweetsUrl(query: string, count: number, cursor: string): string {
71
- return `https://api.twitter.com/2/search/adaptive.json?include_want_retweets=1&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_entities=true&include_user_entities=true&simple_quoted_tweet=true&q=${query}&tweet_search_mode=live&count=${count}&query_source=typed_query&cursor=${cursor}`;
71
+ return `https://api.twitter.com/2/search/adaptive.json?include_want_retweets=1&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_entities=true&include_user_entities=true&simple_quoted_tweet=true&q=${query}&tweet_search_mode=live&count=${count}&query_source=typed_query&cursor=${encodeURIComponent(cursor)}`;
72
72
  }
73
73
 
74
74
  /**
@@ -85,7 +85,7 @@ export function tweetDetailsUrl(tweetId: string): string {
85
85
  * @param cursor The curor to next batch
86
86
  */
87
87
  export function tweetRepliesUrl(tweetId: string, cursor: string): string {
88
- return `https://api.twitter.com/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail?variables=%7B%22focalTweetId%22%3A%22${tweetId}%22%2C%22cursor%22%3A%22${cursor}%22%2C%22referrer%22%3A%22tweet%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
88
+ return `https://api.twitter.com/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail?variables=%7B%22focalTweetId%22%3A%22${tweetId}%22%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22referrer%22%3A%22tweet%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
89
89
  }
90
90
 
91
91
  /**
@@ -95,7 +95,7 @@ export function tweetRepliesUrl(tweetId: string, cursor: string): string {
95
95
  * @param cursor The curor to next batch
96
96
  */
97
97
  export function tweetLikesUrl(tweetId: string, count: number, cursor: string): string {
98
- return `https://api.twitter.com/graphql/56ZwFC3Vui31fF8IYX8EGA/Favoriters?variables=%7B%22tweetId%22%3A%22${tweetId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
98
+ return `https://api.twitter.com/graphql/56ZwFC3Vui31fF8IYX8EGA/Favoriters?variables=%7B%22tweetId%22%3A%22${tweetId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
99
99
  }
100
100
 
101
101
  /**
@@ -105,5 +105,5 @@ export function tweetLikesUrl(tweetId: string, count: number, cursor: string): s
105
105
  * @param cursor The curor to next batch
106
106
  */
107
107
  export function tweetRetweetUrl(tweetId: string, count: number, cursor: string): string {
108
- return `https://api.twitter.com/graphql/Wd7DVeLqMj_JQiTL0tjJwQ/Retweeters?variables=%7B%22tweetId%22%3A%22${tweetId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
108
+ return `https://api.twitter.com/graphql/Wd7DVeLqMj_JQiTL0tjJwQ/Retweeters?variables=%7B%22tweetId%22%3A%22${tweetId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
109
109
  }
package/src/types/HTTP.ts CHANGED
@@ -1,11 +1,3 @@
1
- /**
2
- * @summary Stores all the different type of http requests
3
- */
4
- export enum HttpMethods {
5
- POST = "POST",
6
- GET = "GET"
7
- };
8
-
9
1
  /**
10
2
  * @summary Stores the different types of http status codes
11
3
  */
@@ -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 // To store the source for fetching tweet data
37
+ tweets: TweetService, // To store the source for fetching tweet data
38
+ account: AccountService // To store the source for account related operations
37
39
  }