emusks 0.0.2 → 2.0.0

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 (43) hide show
  1. package/README.md +4 -277
  2. package/build/graphql.js +24 -0
  3. package/build/v1.1.js +28 -0
  4. package/build/v2.js +28 -0
  5. package/package.json +16 -8
  6. package/src/clients.js +62 -0
  7. package/src/cycletls.js +26 -0
  8. package/src/flow.js +399 -0
  9. package/src/graphql.js +70 -0
  10. package/src/helpers/account.js +271 -0
  11. package/src/helpers/bookmarks.js +120 -0
  12. package/src/helpers/communities.js +271 -0
  13. package/src/helpers/dms.js +131 -0
  14. package/src/helpers/index.js +32 -0
  15. package/src/helpers/lists.js +229 -0
  16. package/src/helpers/media.js +290 -0
  17. package/src/helpers/notifications.js +49 -0
  18. package/src/helpers/search.js +129 -0
  19. package/src/helpers/spaces.js +55 -0
  20. package/src/helpers/syndication.js +33 -0
  21. package/src/helpers/timelines.js +84 -0
  22. package/src/helpers/topics.js +99 -0
  23. package/src/helpers/trends.js +86 -0
  24. package/src/helpers/tweets.js +405 -0
  25. package/src/helpers/users.js +321 -0
  26. package/src/index.js +125 -55
  27. package/src/parsers/timeline.js +141 -0
  28. package/src/parsers/tweet.js +9 -2
  29. package/src/static/graphql.js +1 -0
  30. package/src/static/v1.1.js +1 -0
  31. package/src/static/v2.js +1 -0
  32. package/src/v1.1.js +64 -0
  33. package/src/v2.js +64 -0
  34. package/src/methods/bookmarks.js +0 -91
  35. package/src/methods/follow.js +0 -88
  36. package/src/methods/like.js +0 -87
  37. package/src/methods/notifications.js +0 -121
  38. package/src/methods/retweet.js +0 -91
  39. package/src/methods/search.js +0 -124
  40. package/src/methods/timeline.js +0 -215
  41. package/src/methods/tweet.js +0 -396
  42. package/src/methods/users.js +0 -209
  43. package/src/utils/headers.js +0 -23
@@ -0,0 +1,49 @@
1
+ export default (client) => ({
2
+ async timeline(opts = {}) {
3
+ return await client.graphql("NotificationsTimeline", {
4
+ variables: {
5
+ count: opts.count || 20,
6
+ cursor: opts.cursor,
7
+ includePromotedContent: false,
8
+ ...opts.variables,
9
+ },
10
+ fieldToggles: {
11
+ withArticlePlainText: false,
12
+ withArticleRichContentState: false,
13
+ withAuxiliaryUserLabels: false,
14
+ },
15
+ });
16
+ },
17
+
18
+ async enableWebNotifications() {
19
+ return await client.graphql("EnableLoggedOutWebNotifications", {
20
+ body: { variables: {} },
21
+ });
22
+ },
23
+
24
+ async saveSettings(params = {}) {
25
+ const res = await client.v1_1("notifications/settings/save", {
26
+ body: JSON.stringify(params),
27
+ });
28
+ return await res.json();
29
+ },
30
+
31
+ async loginSettings(params = {}) {
32
+ const res = await client.v1_1("notifications/settings/login", {
33
+ body: JSON.stringify(params),
34
+ });
35
+ return await res.json();
36
+ },
37
+
38
+ async checkin(params = {}) {
39
+ const res = await client.v1_1("notifications/settings/checkin", {
40
+ body: JSON.stringify(params),
41
+ });
42
+ return await res.json();
43
+ },
44
+
45
+ async badge(params = {}) {
46
+ const res = await client.v2("badge_count/badge_count", { params });
47
+ return await res.json();
48
+ },
49
+ });
@@ -0,0 +1,129 @@
1
+ import parseTimeline from "../parsers/timeline.js";
2
+
3
+ export default (client) => ({
4
+ async tweets(query, opts = {}) {
5
+ const raw = await client.graphql("SearchTimeline", {
6
+ variables: {
7
+ rawQuery: query,
8
+ count: opts.count || 20,
9
+ cursor: opts.cursor,
10
+ querySource: opts.querySource || "typed_query",
11
+ product: opts.product || "Top",
12
+ ...opts.variables,
13
+ },
14
+ fieldToggles: {
15
+ withArticlePlainText: false,
16
+ withArticleRichContentState: false,
17
+ withAuxiliaryUserLabels: false,
18
+ },
19
+ });
20
+ return parseTimeline(raw);
21
+ },
22
+
23
+ async users(query, opts = {}) {
24
+ const raw = await client.graphql("SearchTimeline", {
25
+ variables: {
26
+ rawQuery: query,
27
+ count: opts.count || 20,
28
+ cursor: opts.cursor,
29
+ querySource: opts.querySource || "typed_query",
30
+ product: "People",
31
+ ...opts.variables,
32
+ },
33
+ });
34
+ return parseTimeline(raw);
35
+ },
36
+
37
+ async media(query, opts = {}) {
38
+ const raw = await client.graphql("SearchTimeline", {
39
+ variables: {
40
+ rawQuery: query,
41
+ count: opts.count || 20,
42
+ cursor: opts.cursor,
43
+ querySource: opts.querySource || "typed_query",
44
+ product: "Media",
45
+ ...opts.variables,
46
+ },
47
+ });
48
+ return parseTimeline(raw);
49
+ },
50
+
51
+ async latest(query, opts = {}) {
52
+ const raw = await client.graphql("SearchTimeline", {
53
+ variables: {
54
+ rawQuery: query,
55
+ count: opts.count || 20,
56
+ cursor: opts.cursor,
57
+ querySource: opts.querySource || "typed_query",
58
+ product: "Latest",
59
+ ...opts.variables,
60
+ },
61
+ });
62
+ return parseTimeline(raw);
63
+ },
64
+
65
+ async lists(query, opts = {}) {
66
+ const raw = await client.graphql("SearchTimeline", {
67
+ variables: {
68
+ rawQuery: query,
69
+ count: opts.count || 20,
70
+ cursor: opts.cursor,
71
+ querySource: opts.querySource || "typed_query",
72
+ product: "Lists",
73
+ ...opts.variables,
74
+ },
75
+ });
76
+ return parseTimeline(raw);
77
+ },
78
+
79
+ async typeahead(query, params = {}) {
80
+ const res = await client.v1_1("search/typeahead", {
81
+ params: {
82
+ q: query,
83
+ src: params.src || "search_box",
84
+ result_type: params.result_type || "events,users,topics,lists",
85
+ ...params,
86
+ },
87
+ });
88
+ return await res.json();
89
+ },
90
+
91
+ async adaptive(query, params = {}) {
92
+ const res = await client.v2("search/adaptive", {
93
+ params: {
94
+ q: query,
95
+ count: params.count || 20,
96
+ query_source: params.query_source || "typed_query",
97
+ pc: params.pc || 1,
98
+ spelling_corrections: params.spelling_corrections || 1,
99
+ include_ext_edit_control: true,
100
+ ...params,
101
+ },
102
+ });
103
+ return await res.json();
104
+ },
105
+
106
+ async communities(query, opts = {}) {
107
+ const raw = await client.graphql("GlobalCommunitiesPostSearchTimeline", {
108
+ variables: {
109
+ rawQuery: query,
110
+ count: opts.count || 20,
111
+ cursor: opts.cursor,
112
+ ...opts.variables,
113
+ },
114
+ });
115
+ return parseTimeline(raw);
116
+ },
117
+
118
+ async communitiesLatest(query, opts = {}) {
119
+ const raw = await client.graphql("GlobalCommunitiesLatestPostSearchTimeline", {
120
+ variables: {
121
+ rawQuery: query,
122
+ count: opts.count || 20,
123
+ cursor: opts.cursor,
124
+ ...opts.variables,
125
+ },
126
+ });
127
+ return parseTimeline(raw);
128
+ },
129
+ });
@@ -0,0 +1,55 @@
1
+ export default (client) => ({
2
+ async get(spaceId) {
3
+ return await client.graphql("AudioSpaceById", {
4
+ variables: {
5
+ id: spaceId,
6
+ isMetatagsQuery: false,
7
+ withReplays: true,
8
+ withListeners: true,
9
+ },
10
+ });
11
+ },
12
+
13
+ async search(query, opts = {}) {
14
+ return await client.graphql("AudioSpaceSearch", {
15
+ variables: {
16
+ query,
17
+ count: opts.count || 20,
18
+ cursor: opts.cursor,
19
+ ...opts.variables,
20
+ },
21
+ });
22
+ },
23
+
24
+ async browseTopics(opts = {}) {
25
+ return await client.graphql("BrowseSpaceTopics", {
26
+ variables: {
27
+ ...opts.variables,
28
+ },
29
+ });
30
+ },
31
+
32
+ async subscribe(spaceId) {
33
+ return await client.graphql("SubscribeToScheduledSpace", {
34
+ body: { variables: { space_id: spaceId } },
35
+ });
36
+ },
37
+
38
+ async unsubscribe(spaceId) {
39
+ return await client.graphql("UnsubscribeFromScheduledSpace", {
40
+ body: { variables: { space_id: spaceId } },
41
+ });
42
+ },
43
+
44
+ async addSharing(spaceId) {
45
+ return await client.graphql("AudioSpaceAddSharing", {
46
+ body: { variables: { space_id: spaceId } },
47
+ });
48
+ },
49
+
50
+ async deleteSharing(spaceId) {
51
+ return await client.graphql("AudioSpaceDeleteSharing", {
52
+ body: { variables: { space_id: spaceId } },
53
+ });
54
+ },
55
+ });
@@ -0,0 +1,33 @@
1
+ import getCycleTLS from "../cycletls.js";
2
+
3
+ export default (client) => ({
4
+ async getTweet(tweetId) {
5
+ const token = ((Number(tweetId) / 1e15) * Math.PI).toString(36).replace(/(0+|\.)/g, "");
6
+
7
+ const features = `tfw_timeline_list:;tfw_tweet_edit_backend:on;tfw_refsrc_session:on;tfw_fosnr_soft_interventions_enabled:on;tfw_mixed_media_15897:treatment;tfw_experiments_cookie_expiration:1209600;tfw_show_birdwatch_pivots_enabled:on;tfw_duplicate_scribes_to_settings:on;tfw_use_profile_image_shape_enabled:on;tfw_video_hls_dynamic_manifests_15082:true_bitrate;tfw_tweet_edit_frontend:on`;
8
+
9
+ const url = `https://cdn.syndication.twimg.com/tweet-result?id=${tweetId}&lang=en&token=${token}&features=${encodeURIComponent(features)}`;
10
+
11
+ try {
12
+ const cycleTLS = await getCycleTLS();
13
+
14
+ const res = await cycleTLS(url, {
15
+ headers: {
16
+ accept: "application/json, text/plain, */*",
17
+ },
18
+ userAgent: client.fingerprints?.userAgent,
19
+ ja3: client.fingerprints?.ja3,
20
+ ja4r: client.fingerprints?.ja4r,
21
+ proxy: client.proxy || undefined,
22
+ timeout: 3000,
23
+ }, "GET");
24
+
25
+ if (!res || res.status !== 200) return null;
26
+
27
+ return await res.json();
28
+ } catch (e) {
29
+ console.warn(e);
30
+ return null;
31
+ }
32
+ },
33
+ });
@@ -0,0 +1,84 @@
1
+ import parseTimeline from "../parsers/timeline.js";
2
+
3
+ export default (client) => ({
4
+ async home(opts = {}) {
5
+ const raw = await client.graphql("HomeTimeline", {
6
+ variables: {
7
+ count: opts.count || 20,
8
+ cursor: opts.cursor,
9
+ includePromotedContent: true,
10
+ latestControlAvailable: true,
11
+ requestContext: "launch",
12
+ withCommunity: true,
13
+ ...opts.variables,
14
+ },
15
+ fieldToggles: {
16
+ withArticlePlainText: false,
17
+ withArticleRichContentState: false,
18
+ withAuxiliaryUserLabels: false,
19
+ },
20
+ });
21
+ return parseTimeline(raw);
22
+ },
23
+
24
+ async homeLatest(opts = {}) {
25
+ const raw = await client.graphql("HomeLatestTimeline", {
26
+ variables: {
27
+ count: opts.count || 20,
28
+ cursor: opts.cursor,
29
+ includePromotedContent: true,
30
+ latestControlAvailable: true,
31
+ requestContext: "launch",
32
+ withCommunity: true,
33
+ ...opts.variables,
34
+ },
35
+ fieldToggles: {
36
+ withArticlePlainText: false,
37
+ withArticleRichContentState: false,
38
+ withAuxiliaryUserLabels: false,
39
+ },
40
+ });
41
+ return parseTimeline(raw);
42
+ },
43
+
44
+ async connect(opts = {}) {
45
+ const raw = await client.graphql("ConnectTabTimeline", {
46
+ variables: {
47
+ count: opts.count || 20,
48
+ cursor: opts.cursor,
49
+ context: "{}",
50
+ ...opts.variables,
51
+ },
52
+ });
53
+ return parseTimeline(raw);
54
+ },
55
+
56
+ async moderated(opts = {}) {
57
+ const raw = await client.graphql("ModeratedTimeline", {
58
+ variables: {
59
+ count: opts.count || 20,
60
+ cursor: opts.cursor,
61
+ includePromotedContent: false,
62
+ ...opts.variables,
63
+ },
64
+ fieldToggles: {
65
+ withArticlePlainText: false,
66
+ withArticleRichContentState: false,
67
+ withAuxiliaryUserLabels: false,
68
+ },
69
+ });
70
+ return parseTimeline(raw);
71
+ },
72
+
73
+ async creatorSubscriptions(opts = {}) {
74
+ const raw = await client.graphql("CreatorSubscriptionsTimeline", {
75
+ variables: {
76
+ count: opts.count || 20,
77
+ cursor: opts.cursor,
78
+ includePromotedContent: false,
79
+ ...opts.variables,
80
+ },
81
+ });
82
+ return parseTimeline(raw);
83
+ },
84
+ });
@@ -0,0 +1,99 @@
1
+ export default (client) => ({
2
+ async follow(topicId) {
3
+ return await client.graphql("TopicFollow", {
4
+ body: { variables: { topic_id: topicId } },
5
+ });
6
+ },
7
+
8
+ async unfollow(topicId) {
9
+ return await client.graphql("TopicUnfollow", {
10
+ body: { variables: { topic_id: topicId } },
11
+ });
12
+ },
13
+
14
+ async notInterested(topicId) {
15
+ return await client.graphql("TopicNotInterested", {
16
+ body: { variables: { topic_id: topicId } },
17
+ });
18
+ },
19
+
20
+ async undoNotInterested(topicId) {
21
+ return await client.graphql("TopicUndoNotInterested", {
22
+ body: { variables: { topic_id: topicId } },
23
+ });
24
+ },
25
+
26
+ async get(topicId) {
27
+ return await client.graphql("TopicByRestId", {
28
+ variables: { topicId },
29
+ });
30
+ },
31
+
32
+ async landingPage(topicId, opts = {}) {
33
+ return await client.graphql("TopicLandingPage", {
34
+ variables: {
35
+ topicId,
36
+ count: opts.count || 20,
37
+ cursor: opts.cursor,
38
+ ...opts.variables,
39
+ },
40
+ fieldToggles: {
41
+ withArticlePlainText: false,
42
+ withArticleRichContentState: false,
43
+ withAuxiliaryUserLabels: false,
44
+ },
45
+ });
46
+ },
47
+
48
+ async toFollow(opts = {}) {
49
+ return await client.graphql("TopicToFollowSidebar", {
50
+ variables: {
51
+ count: opts.count || 20,
52
+ cursor: opts.cursor,
53
+ ...opts.variables,
54
+ },
55
+ });
56
+ },
57
+
58
+ async manage(opts = {}) {
59
+ return await client.graphql("TopicsManagementPage", {
60
+ variables: {
61
+ count: opts.count || 20,
62
+ cursor: opts.cursor,
63
+ ...opts.variables,
64
+ },
65
+ });
66
+ },
67
+
68
+ async picker(opts = {}) {
69
+ return await client.graphql("TopicsPickerPage", {
70
+ variables: {
71
+ count: opts.count || 20,
72
+ cursor: opts.cursor,
73
+ ...opts.variables,
74
+ },
75
+ });
76
+ },
77
+
78
+ async pickerById(topicId, opts = {}) {
79
+ return await client.graphql("TopicsPickerPageById", {
80
+ variables: {
81
+ topicId,
82
+ count: opts.count || 20,
83
+ cursor: opts.cursor,
84
+ ...opts.variables,
85
+ },
86
+ });
87
+ },
88
+
89
+ async viewing(userId, opts = {}) {
90
+ return await client.graphql("ViewingOtherUsersTopicsPage", {
91
+ variables: {
92
+ userId,
93
+ count: opts.count || 20,
94
+ cursor: opts.cursor,
95
+ ...opts.variables,
96
+ },
97
+ });
98
+ },
99
+ });
@@ -0,0 +1,86 @@
1
+ export default (client) => ({
2
+ async available() {
3
+ const res = await client.v1_1("trends/available", {});
4
+ return await res.json();
5
+ },
6
+
7
+ async history(opts = {}) {
8
+ return await client.graphql("TrendHistory", {
9
+ variables: {
10
+ count: opts.count || 20,
11
+ cursor: opts.cursor,
12
+ ...opts.variables,
13
+ },
14
+ });
15
+ },
16
+
17
+ async relevantUsers(trendName, opts = {}) {
18
+ return await client.graphql("TrendRelevantUsers", {
19
+ variables: {
20
+ trend_name: trendName,
21
+ ...opts.variables,
22
+ },
23
+ });
24
+ },
25
+
26
+ async explore(opts = {}) {
27
+ return await client.graphql("ExplorePage", {
28
+ variables: {
29
+ count: opts.count || 20,
30
+ cursor: opts.cursor,
31
+ ...opts.variables,
32
+ },
33
+ fieldToggles: {
34
+ withArticlePlainText: false,
35
+ withArticleRichContentState: false,
36
+ withAuxiliaryUserLabels: false,
37
+ },
38
+ });
39
+ },
40
+
41
+ async exploreSidebar(opts = {}) {
42
+ return await client.graphql("ExploreSidebar", {
43
+ variables: {
44
+ count: opts.count || 20,
45
+ cursor: opts.cursor,
46
+ ...opts.variables,
47
+ },
48
+ });
49
+ },
50
+
51
+ async report(trendId) {
52
+ return await client.graphql("ReportTrend", {
53
+ body: { variables: { trend_id: trendId } },
54
+ });
55
+ },
56
+
57
+ async save(trendId) {
58
+ return await client.graphql("SaveTrend", {
59
+ body: { variables: { trend_id: trendId } },
60
+ });
61
+ },
62
+
63
+ async action(trendId, action) {
64
+ return await client.graphql("ActionTrend", {
65
+ body: { variables: { trend_id: trendId, action } },
66
+ });
67
+ },
68
+
69
+ async getById(trendId) {
70
+ return await client.graphql("AiTrendByRestId", {
71
+ variables: { trendId },
72
+ });
73
+ },
74
+
75
+ async exploreSettings() {
76
+ const res = await client.v2("guide/get_explore_settings", {});
77
+ return await res.json();
78
+ },
79
+
80
+ async setExploreSettings(params = {}) {
81
+ const res = await client.v2("guide/set_explore_settings", {
82
+ body: JSON.stringify(params),
83
+ });
84
+ return await res.json();
85
+ },
86
+ });