bb-fca 2.0.3 → 2.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/dist/deltas/apis/create.js +22 -0
- package/dist/deltas/apis/create.js.map +1 -1
- package/dist/deltas/apis/posting/post.js +346 -1
- package/dist/deltas/apis/posting/post.js.map +1 -1
- package/dist/deltas/apis/posting/story.js +147 -0
- package/dist/deltas/apis/posting/story.js.map +1 -1
- package/dist/deltas/apis/users/getUserFriends.js +285 -0
- package/dist/deltas/apis/users/getUserFriends.js.map +1 -0
- package/dist/deltas/apis/users/searchCity.js +91 -0
- package/dist/deltas/apis/users/searchCity.js.map +1 -0
- package/dist/deltas/apis/users/searchCompany.js +86 -0
- package/dist/deltas/apis/users/searchCompany.js.map +1 -0
- package/dist/deltas/apis/users/searchJobTitle.js +85 -0
- package/dist/deltas/apis/users/searchJobTitle.js.map +1 -0
- package/dist/deltas/apis/users/updateCity.js +98 -0
- package/dist/deltas/apis/users/updateCity.js.map +1 -0
- package/dist/deltas/apis/users/updateHometown.js +97 -0
- package/dist/deltas/apis/users/updateHometown.js.map +1 -0
- package/dist/deltas/apis/users/updateWorkExperience.js +131 -0
- package/dist/deltas/apis/users/updateWorkExperience.js.map +1 -0
- package/dist/index.d.ts +128 -0
- package/dist/types/deltas/apis/create.d.ts +22 -0
- package/dist/types/deltas/apis/posting/post.d.ts +7 -0
- package/dist/types/deltas/apis/posting/story.d.ts +21 -0
- package/dist/types/deltas/apis/users/getUserFriends.d.ts +30 -0
- package/dist/types/deltas/apis/users/searchCity.d.ts +10 -0
- package/dist/types/deltas/apis/users/searchCompany.d.ts +10 -0
- package/dist/types/deltas/apis/users/searchJobTitle.d.ts +10 -0
- package/dist/types/deltas/apis/users/updateCity.d.ts +10 -0
- package/dist/types/deltas/apis/users/updateHometown.d.ts +10 -0
- package/dist/types/deltas/apis/users/updateWorkExperience.d.ts +30 -0
- package/dist/types/utils/axios.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/utils/axios.js +12 -0
- package/dist/utils/axios.js.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/examples/post.example.js +41 -1
- package/package.json +1 -1
- package/src/deltas/apis/create.ts +25 -0
- package/src/deltas/apis/posting/post.ts +439 -1
- package/src/deltas/apis/posting/story.ts +147 -0
- package/src/deltas/apis/users/getUserFriends.ts +373 -0
- package/src/deltas/apis/users/searchCity.ts +106 -0
- package/src/deltas/apis/users/searchCompany.ts +100 -0
- package/src/deltas/apis/users/searchJobTitle.ts +99 -0
- package/src/deltas/apis/users/updateCity.ts +113 -0
- package/src/deltas/apis/users/updateHometown.ts +112 -0
- package/src/deltas/apis/users/updateWorkExperience.ts +160 -0
- package/src/types/index.d.ts +128 -0
- package/src/utils/axios.ts +19 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = searchCompanyModule;
|
|
4
|
+
const utils = require("../../../utils");
|
|
5
|
+
/**
|
|
6
|
+
* @ChoruOfficial
|
|
7
|
+
* @description A module for searching companies/workplaces via Facebook's Directory Typeahead API.
|
|
8
|
+
* Calls useProfileCometDirectoryTypeaheadDataSourceQuery via /api/graphql/.
|
|
9
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper.
|
|
10
|
+
* @param {Object} api The full API object.
|
|
11
|
+
* @param {Object} ctx The context object containing the user's session state.
|
|
12
|
+
* @returns {Function} An async function that searches for companies by name.
|
|
13
|
+
*/
|
|
14
|
+
function searchCompanyModule(defaultFuncs, api, ctx) {
|
|
15
|
+
/**
|
|
16
|
+
* Searches for companies/workplaces matching the given query string.
|
|
17
|
+
* Uses Facebook's Directory Typeahead data source with WORKPLACE category.
|
|
18
|
+
* @async
|
|
19
|
+
* @param {string} query The search query (company name or partial name).
|
|
20
|
+
* @returns {Promise<Array<Object>>} A promise that resolves to an array of company objects.
|
|
21
|
+
* @throws {Error} If the query is missing or the API request fails.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const companies = await api.searchCompany('google');
|
|
25
|
+
* // companies[0] = { fbid: '...', title: 'Google', photoUri: '...', subtitle: '...', ... }
|
|
26
|
+
*/
|
|
27
|
+
return async function searchCompany(query) {
|
|
28
|
+
if (!query) {
|
|
29
|
+
throw new Error('query is required.');
|
|
30
|
+
}
|
|
31
|
+
const variables = {
|
|
32
|
+
search_category: 'WORKPLACE',
|
|
33
|
+
query: query,
|
|
34
|
+
};
|
|
35
|
+
const form = {
|
|
36
|
+
av: ctx.userID,
|
|
37
|
+
__user: ctx.userID,
|
|
38
|
+
__a: '1',
|
|
39
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
40
|
+
jazoest: ctx.jazoest,
|
|
41
|
+
lsd: ctx.lsd,
|
|
42
|
+
fb_api_caller_class: 'RelayModern',
|
|
43
|
+
fb_api_req_friendly_name: 'useProfileCometDirectoryTypeaheadDataSourceQuery',
|
|
44
|
+
variables: JSON.stringify(variables),
|
|
45
|
+
server_timestamps: 'true',
|
|
46
|
+
doc_id: '24825162803742896',
|
|
47
|
+
};
|
|
48
|
+
const customHeader = {
|
|
49
|
+
'x-fb-friendly-name': 'useProfileCometDirectoryTypeaheadDataSourceQuery',
|
|
50
|
+
'x-fb-lsd': ctx.lsd,
|
|
51
|
+
'x-asbd-id': '359341',
|
|
52
|
+
origin: 'https://www.facebook.com',
|
|
53
|
+
referer: `https://www.facebook.com/profile.php?id=${ctx.userID}&sk=directory_work`,
|
|
54
|
+
};
|
|
55
|
+
const resData = await utils.post('https://www.facebook.com/api/graphql/', ctx.jar, form, ctx.globalOptions, ctx, customHeader);
|
|
56
|
+
// Handle both parsed object and string/Buffer response
|
|
57
|
+
let data;
|
|
58
|
+
if (typeof resData.body === 'object' && resData.body !== null && !Buffer.isBuffer(resData.body)) {
|
|
59
|
+
data = resData.body;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const body = typeof resData.body === 'string' ? resData.body : resData.body.toString();
|
|
63
|
+
try {
|
|
64
|
+
data = JSON.parse(body);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
const lines = body.split('\n').filter((l) => l);
|
|
68
|
+
data = JSON.parse(lines[0]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (data.errors)
|
|
72
|
+
throw new Error(JSON.stringify(data.errors));
|
|
73
|
+
const suggestions = data?.data?.viewer?.profile_directory_typeahead_suggestions || [];
|
|
74
|
+
return suggestions
|
|
75
|
+
.filter((item) => item.fbid !== '-1')
|
|
76
|
+
.map((item) => ({
|
|
77
|
+
fbid: item.fbid,
|
|
78
|
+
title: item.title,
|
|
79
|
+
value: item.value,
|
|
80
|
+
photoUri: item.photo_uri,
|
|
81
|
+
subtitle: item.subtitle,
|
|
82
|
+
secondSubtitle: item.second_subtitle,
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=searchCompany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchCompany.js","sourceRoot":"","sources":["../../../../src/deltas/apis/users/searchCompany.ts"],"names":[],"mappings":";;AAWA,sCAwFC;AAnGD,wCAAyC;AAEzC;;;;;;;;GAQG;AACH,SAAwB,mBAAmB,CAAC,YAAiB,EAAE,GAAQ,EAAE,GAAQ;IAC/E;;;;;;;;;;;OAWG;IACH,OAAO,KAAK,UAAU,aAAa,CACjC,KAAa;QAEb,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,SAAS,GAAG;YAChB,eAAe,EAAE,WAAW;YAC5B,KAAK,EAAE,KAAK;SACb,CAAC;QAEF,MAAM,IAAI,GAAG;YACX,EAAE,EAAE,GAAG,CAAC,MAAM;YACd,MAAM,EAAE,GAAG,CAAC,MAAM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AC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAE9D,MAAM,WAAW,GACf,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,uCAAuC,IAAI,EAAE,CAAC;QAEpE,OAAO,WAAW;aACf,MAAM,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;aACzC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,eAAe;SACrC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = searchJobTitleModule;
|
|
4
|
+
const utils = require("../../../utils");
|
|
5
|
+
/**
|
|
6
|
+
* @ChoruOfficial
|
|
7
|
+
* @description A module for searching job titles via Facebook's Directory Typeahead API.
|
|
8
|
+
* Calls useProfileCometDirectoryTypeaheadDataSourceQuery via /api/graphql/.
|
|
9
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper.
|
|
10
|
+
* @param {Object} api The full API object.
|
|
11
|
+
* @param {Object} ctx The context object containing the user's session state.
|
|
12
|
+
* @returns {Function} An async function that searches for job titles by name.
|
|
13
|
+
*/
|
|
14
|
+
function searchJobTitleModule(defaultFuncs, api, ctx) {
|
|
15
|
+
/**
|
|
16
|
+
* Searches for job titles/positions matching the given query string.
|
|
17
|
+
* Uses Facebook's Directory Typeahead data source with JOB_TITLE category.
|
|
18
|
+
* @async
|
|
19
|
+
* @param {string} query The search query (job title or partial name).
|
|
20
|
+
* @returns {Promise<Array<Object>>} A promise that resolves to an array of job title objects.
|
|
21
|
+
* @throws {Error} If the query is missing or the API request fails.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const jobs = await api.searchJobTitle('developer');
|
|
25
|
+
* // jobs[0] = { fbid: '...', title: 'Software Developer', ... }
|
|
26
|
+
*/
|
|
27
|
+
return async function searchJobTitle(query) {
|
|
28
|
+
if (!query) {
|
|
29
|
+
throw new Error('query is required.');
|
|
30
|
+
}
|
|
31
|
+
const variables = {
|
|
32
|
+
search_category: 'JOB_TITLE',
|
|
33
|
+
query: query,
|
|
34
|
+
};
|
|
35
|
+
const form = {
|
|
36
|
+
av: ctx.userID,
|
|
37
|
+
__user: ctx.userID,
|
|
38
|
+
__a: '1',
|
|
39
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
40
|
+
jazoest: ctx.jazoest,
|
|
41
|
+
lsd: ctx.lsd,
|
|
42
|
+
fb_api_caller_class: 'RelayModern',
|
|
43
|
+
fb_api_req_friendly_name: 'useProfileCometDirectoryTypeaheadDataSourceQuery',
|
|
44
|
+
variables: JSON.stringify(variables),
|
|
45
|
+
server_timestamps: 'true',
|
|
46
|
+
doc_id: '24825162803742896',
|
|
47
|
+
};
|
|
48
|
+
const customHeader = {
|
|
49
|
+
'x-fb-friendly-name': 'useProfileCometDirectoryTypeaheadDataSourceQuery',
|
|
50
|
+
'x-fb-lsd': ctx.lsd,
|
|
51
|
+
'x-asbd-id': '359341',
|
|
52
|
+
origin: 'https://www.facebook.com',
|
|
53
|
+
referer: `https://www.facebook.com/profile.php?id=${ctx.userID}&sk=directory_work`,
|
|
54
|
+
};
|
|
55
|
+
const resData = await utils.post('https://www.facebook.com/api/graphql/', ctx.jar, form, ctx.globalOptions, ctx, customHeader);
|
|
56
|
+
let data;
|
|
57
|
+
if (typeof resData.body === 'object' && resData.body !== null && !Buffer.isBuffer(resData.body)) {
|
|
58
|
+
data = resData.body;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const body = typeof resData.body === 'string' ? resData.body : resData.body.toString();
|
|
62
|
+
try {
|
|
63
|
+
data = JSON.parse(body);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
const lines = body.split('\n').filter(Boolean);
|
|
67
|
+
data = JSON.parse(lines[0]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (data.errors)
|
|
71
|
+
throw new Error(JSON.stringify(data.errors));
|
|
72
|
+
const suggestions = data?.data?.viewer?.profile_directory_typeahead_suggestions || [];
|
|
73
|
+
return suggestions
|
|
74
|
+
.filter((item) => item.fbid !== '-1')
|
|
75
|
+
.map((item) => ({
|
|
76
|
+
fbid: item.fbid,
|
|
77
|
+
title: item.title,
|
|
78
|
+
value: item.value,
|
|
79
|
+
photoUri: item.photo_uri,
|
|
80
|
+
subtitle: item.subtitle,
|
|
81
|
+
secondSubtitle: item.second_subtitle,
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=searchJobTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchJobTitle.js","sourceRoot":"","sources":["../../../../src/deltas/apis/users/searchJobTitle.ts"],"names":[],"mappings":";;AAWA,uCAuFC;AAlGD,wCAAyC;AAEzC;;;;;;;;GAQG;AACH,SAAwB,oBAAoB,CAAC,YAAiB,EAAE,GAAQ,EAAE,GAAQ;IAChF;;;;;;;;;;;OAWG;IACH,OAAO,KAAK,UAAU,cAAc,CAClC,KAAa;QAEb,IAAI,C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AAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvF,IAAI,CAAC;gBACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC/C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAE9D,MAAM,WAAW,GACf,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,uCAAuC,IAAI,EAAE,CAAC;QAEpE,OAAO,WAAW;aACf,MAAM,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;aACzC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,eAAe;SACrC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const utils = require("../../../utils");
|
|
5
|
+
/**
|
|
6
|
+
* @ChoruOfficial
|
|
7
|
+
* @description A module for updating the current city on a Facebook profile.
|
|
8
|
+
* Calls ProfileCometCurrentCityProfileFieldSaveMutation via /api/graphql/.
|
|
9
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper.
|
|
10
|
+
* @param {Object} api The full API object.
|
|
11
|
+
* @param {Object} ctx The context object containing the user's session state.
|
|
12
|
+
* @returns {Function} An async function that updates the account's current city.
|
|
13
|
+
*/
|
|
14
|
+
function default_1(defaultFuncs, api, ctx) {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the current city on the logged-in user's profile.
|
|
17
|
+
* Use `api.searchCity()` to get the city `fbid` first.
|
|
18
|
+
* @async
|
|
19
|
+
* @param {string} cityId The Facebook ID of the city (from searchCity's `fbid` field).
|
|
20
|
+
* @param {string} [privacy='EVERYONE'] Privacy setting: 'EVERYONE', 'FRIENDS', or 'SELF'.
|
|
21
|
+
* @returns {Promise<any>} A promise that resolves to the API response data on success.
|
|
22
|
+
* @throws {Error} If the cityId is missing or the API request fails.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const cities = await api.searchCity('vinh');
|
|
26
|
+
* await api.updateCity(cities[0].fbid);
|
|
27
|
+
* await api.updateCity('112963075384670', 'FRIENDS');
|
|
28
|
+
*/
|
|
29
|
+
return async function updateCity(cityId, privacy = 'EVERYONE') {
|
|
30
|
+
if (!cityId) {
|
|
31
|
+
throw new Error('cityId is required. Use searchCity() to find the city fbid.');
|
|
32
|
+
}
|
|
33
|
+
// sectionToken = base64("app_section:<userID>:2327158227")
|
|
34
|
+
const sectionToken = Buffer.from(`app_section:${ctx.userID}:2327158227`).toString('base64');
|
|
35
|
+
const variables = {
|
|
36
|
+
collectionToken: 'UNKNOWN',
|
|
37
|
+
input: {
|
|
38
|
+
current_city_id: cityId,
|
|
39
|
+
life_event_publish_type: 'SUPPRESS_ALL',
|
|
40
|
+
logging_data: {
|
|
41
|
+
nav_chain: `ProfileCometAboutTabRoot.react,comet.profile.collection.directory_personal_details,unexpected,${Date.now()},0,,,`,
|
|
42
|
+
},
|
|
43
|
+
privacy: {
|
|
44
|
+
allow: [],
|
|
45
|
+
base_state: privacy,
|
|
46
|
+
deny: [],
|
|
47
|
+
tag_expansion_state: 'UNSPECIFIED',
|
|
48
|
+
},
|
|
49
|
+
actor_id: ctx.userID,
|
|
50
|
+
client_mutation_id: Math.floor(Math.random() * 10 + 1).toString(),
|
|
51
|
+
},
|
|
52
|
+
scale: 1,
|
|
53
|
+
sectionToken: sectionToken,
|
|
54
|
+
profileID: ctx.userID,
|
|
55
|
+
useDefaultActor: false,
|
|
56
|
+
};
|
|
57
|
+
const form = {
|
|
58
|
+
av: ctx.userID,
|
|
59
|
+
__user: ctx.userID,
|
|
60
|
+
__a: '1',
|
|
61
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
62
|
+
jazoest: ctx.jazoest,
|
|
63
|
+
lsd: ctx.lsd,
|
|
64
|
+
fb_api_caller_class: 'RelayModern',
|
|
65
|
+
fb_api_req_friendly_name: 'ProfileCometCurrentCityProfileFieldSaveMutation',
|
|
66
|
+
variables: JSON.stringify(variables),
|
|
67
|
+
server_timestamps: 'true',
|
|
68
|
+
doc_id: '24052423611121998',
|
|
69
|
+
};
|
|
70
|
+
const customHeader = {
|
|
71
|
+
'x-fb-friendly-name': 'ProfileCometCurrentCityProfileFieldSaveMutation',
|
|
72
|
+
'x-fb-lsd': ctx.lsd,
|
|
73
|
+
'x-asbd-id': '359341',
|
|
74
|
+
origin: 'https://www.facebook.com',
|
|
75
|
+
referer: `https://www.facebook.com/profile.php?id=${ctx.userID}&sk=directory_personal_details`,
|
|
76
|
+
};
|
|
77
|
+
const resData = await utils.post('https://www.facebook.com/api/graphql/', ctx.jar, form, ctx.globalOptions, ctx, customHeader);
|
|
78
|
+
// Handle both parsed object and string/Buffer response
|
|
79
|
+
let data;
|
|
80
|
+
if (typeof resData.body === 'object' && resData.body !== null && !Buffer.isBuffer(resData.body)) {
|
|
81
|
+
data = resData.body;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const body = typeof resData.body === 'string' ? resData.body : resData.body.toString();
|
|
85
|
+
try {
|
|
86
|
+
data = JSON.parse(body);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
const lines = body.split('\n').filter(Boolean);
|
|
90
|
+
data = JSON.parse(lines[0]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (data.errors)
|
|
94
|
+
throw new Error(JSON.stringify(data.errors));
|
|
95
|
+
return data.data || data;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=updateCity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCity.js","sourceRoot":"","sources":["../../../../src/deltas/apis/users/updateCity.ts"],"names":[],"mappings":";;AAWA,4BAqGC;AAhHD,wCAAyC;AAEzC;;;;;;;;GAQG;AACH,mBAAyB,YAAiB,EAAE,GAAQ,EAAE,GAAQ;IAC5D;;;;;;;;;;;;;OAaG;IACH,OAAO,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,UAAkB,UAAU;QAE5B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QAED,2DAA2D;QAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAC9B,eAAe,GAAG,CAAC,MAAM,aAAa,CACvC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAErB,MAAM,SAAS,GAAG;YAChB,eAAe,EAAE,SAAS;YAC1B,KAAK,EAAE;gBACL,eAAe,EAAE,MAAM;gBACvB,uBAAuB,EAAE,cAAc;gBACvC,YAAY,EAAE;oBACZ,SAAS,EAAE,iGAAiG,IAAI,CAAC,GAAG,EAAE,OAAO;iBAC9H;gBACD,OAAO,EAAE;oBACP,KAAK,EAAE,EAAE;oBACT,UAAU,EAAE,OAAO;oBACnB,IAAI,EAAE,EAAE;oBACR,mBAAm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,CAAC,IAAI,CAAC,EAAE,CAAC;YAChG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvF,IAAI,CAAC;gBACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC/C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const utils = require("../../../utils");
|
|
5
|
+
/**
|
|
6
|
+
* @ChoruOfficial
|
|
7
|
+
* @description A module for updating the hometown on a Facebook profile.
|
|
8
|
+
* Calls ProfileCometHometownProfileFieldSaveMutation via /api/graphql/.
|
|
9
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper.
|
|
10
|
+
* @param {Object} api The full API object.
|
|
11
|
+
* @param {Object} ctx The context object containing the user's session state.
|
|
12
|
+
* @returns {Function} An async function that updates the account's hometown.
|
|
13
|
+
*/
|
|
14
|
+
function default_1(defaultFuncs, api, ctx) {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the hometown on the logged-in user's profile.
|
|
17
|
+
* Use `api.searchCity(query, 'HOMETOWN')` to get the city `fbid` first.
|
|
18
|
+
* @async
|
|
19
|
+
* @param {string} cityId The Facebook ID of the city (from searchCity's `fbid` field).
|
|
20
|
+
* @param {string} [privacy='EVERYONE'] Privacy setting: 'EVERYONE', 'FRIENDS', or 'SELF'.
|
|
21
|
+
* @returns {Promise<any>} A promise that resolves to the API response data on success.
|
|
22
|
+
* @throws {Error} If the cityId is missing or the API request fails.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const cities = await api.searchCity('ha noi', 'HOMETOWN');
|
|
26
|
+
* await api.updateHometown(cities[0].fbid);
|
|
27
|
+
* await api.updateHometown('106388046062960', 'FRIENDS');
|
|
28
|
+
*/
|
|
29
|
+
return async function updateHometown(cityId, privacy = 'EVERYONE') {
|
|
30
|
+
if (!cityId) {
|
|
31
|
+
throw new Error('cityId is required. Use searchCity(query, "HOMETOWN") to find the city fbid.');
|
|
32
|
+
}
|
|
33
|
+
// sectionToken = base64("app_section:<userID>:2327158227")
|
|
34
|
+
const sectionToken = Buffer.from(`app_section:${ctx.userID}:2327158227`).toString('base64');
|
|
35
|
+
const variables = {
|
|
36
|
+
collectionToken: 'UNKNOWN',
|
|
37
|
+
input: {
|
|
38
|
+
hometown_city_id: cityId,
|
|
39
|
+
life_event_publish_type: 'SUPPRESS_ALL',
|
|
40
|
+
logging_data: {
|
|
41
|
+
nav_chain: `ProfileCometAboutTabRoot.react,comet.profile.collection.directory_personal_details,via_cold_start,${Date.now()},0,,,`,
|
|
42
|
+
},
|
|
43
|
+
privacy: {
|
|
44
|
+
allow: [],
|
|
45
|
+
base_state: privacy,
|
|
46
|
+
deny: [],
|
|
47
|
+
tag_expansion_state: 'UNSPECIFIED',
|
|
48
|
+
},
|
|
49
|
+
actor_id: ctx.userID,
|
|
50
|
+
client_mutation_id: Math.floor(Math.random() * 10 + 1).toString(),
|
|
51
|
+
},
|
|
52
|
+
scale: 1,
|
|
53
|
+
sectionToken: sectionToken,
|
|
54
|
+
useDefaultActor: false,
|
|
55
|
+
};
|
|
56
|
+
const form = {
|
|
57
|
+
av: ctx.userID,
|
|
58
|
+
__user: ctx.userID,
|
|
59
|
+
__a: '1',
|
|
60
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
61
|
+
jazoest: ctx.jazoest,
|
|
62
|
+
lsd: ctx.lsd,
|
|
63
|
+
fb_api_caller_class: 'RelayModern',
|
|
64
|
+
fb_api_req_friendly_name: 'ProfileCometHometownProfileFieldSaveMutation',
|
|
65
|
+
variables: JSON.stringify(variables),
|
|
66
|
+
server_timestamps: 'true',
|
|
67
|
+
doc_id: '26631736056430441',
|
|
68
|
+
};
|
|
69
|
+
const customHeader = {
|
|
70
|
+
'x-fb-friendly-name': 'ProfileCometHometownProfileFieldSaveMutation',
|
|
71
|
+
'x-fb-lsd': ctx.lsd,
|
|
72
|
+
'x-asbd-id': '359341',
|
|
73
|
+
origin: 'https://www.facebook.com',
|
|
74
|
+
referer: `https://www.facebook.com/profile.php?id=${ctx.userID}&sk=directory_personal_details`,
|
|
75
|
+
};
|
|
76
|
+
const resData = await utils.post('https://www.facebook.com/api/graphql/', ctx.jar, form, ctx.globalOptions, ctx, customHeader);
|
|
77
|
+
// Handle both parsed object and string/Buffer response
|
|
78
|
+
let data;
|
|
79
|
+
if (typeof resData.body === 'object' && resData.body !== null && !Buffer.isBuffer(resData.body)) {
|
|
80
|
+
data = resData.body;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const body = typeof resData.body === 'string' ? resData.body : resData.body.toString();
|
|
84
|
+
try {
|
|
85
|
+
data = JSON.parse(body);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
const lines = body.split('\n').filter(Boolean);
|
|
89
|
+
data = JSON.parse(lines[0]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (data.errors)
|
|
93
|
+
throw new Error(JSON.stringify(data.errors));
|
|
94
|
+
return data.data || data;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=updateHometown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateHometown.js","sourceRoot":"","sources":["../../../../src/deltas/apis/users/updateHometown.ts"],"names":[],"mappings":";;AAWA,4BAoGC;AA/GD,wCAAyC;AAEzC;;;;;;;;GAQG;AACH,mBAAyB,YAAiB,EAAE,GAAQ,EAAE,GAAQ;IAC5D;;;;;;;;;;;;;OAaG;IACH,OAAO,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,UAAkB,UAAU;QAE5B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAClG,CAAC;QAED,2DAA2D;QAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAC9B,eAAe,GAAG,CAAC,MAAM,aAAa,CACvC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAErB,MAAM,SAAS,GAAG;YAChB,eAAe,EAAE,SAAS;YAC1B,KAAK,EAAE;gBACL,gBAAgB,EAAE,MAAM;gBACxB,uBAAuB,EAAE,cAAc;gBACvC,YAAY,EAAE;oBACZ,SAAS,EAAE,qGAAqG,IAAI,CAAC,GAAG,EAAE,OAAO;iBAClI;gBACD,OAAO,EAAE;oBACP,KAAK,EAAE,EAAE;oBACT,UAAU,EAAE,OAAO;oBACnB,IAAI,EAAE,EAAE;oBACR,mBAAmB,EAAE,aAAa;iBACnC;gBACD,QAAQ,EAAE,GAAG,CAAC,MAAM;gBACpB,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;aAClE;YACD,KAAK,EAAE,CAAC;YACR,YAAY,EAAE,YAAY;YAC1B,eAAe,EAAE,KAAK;SACvB,CA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AC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC/C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = updateWorkExperienceModule;
|
|
4
|
+
const utils = require("../../../utils");
|
|
5
|
+
/**
|
|
6
|
+
* @ChoruOfficial
|
|
7
|
+
* @description A module for adding/updating work experience on a Facebook profile.
|
|
8
|
+
* Calls ProfileCometWorkExperienceSaveMutation via /api/graphql/.
|
|
9
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper.
|
|
10
|
+
* @param {Object} api The full API object.
|
|
11
|
+
* @param {Object} ctx The context object containing the user's session state.
|
|
12
|
+
* @returns {Function} An async function that updates work experience.
|
|
13
|
+
*/
|
|
14
|
+
function updateWorkExperienceModule(defaultFuncs, api, ctx) {
|
|
15
|
+
/**
|
|
16
|
+
* Adds or updates a work experience entry on the profile.
|
|
17
|
+
* Use `api.searchCompany()` and `api.searchJobTitle()` to get IDs first.
|
|
18
|
+
* @async
|
|
19
|
+
* @param {Object} options Work experience details.
|
|
20
|
+
* @param {string} options.companyName The company/employer name.
|
|
21
|
+
* @param {string} [options.companyId] The company fbid from searchCompany (optional, UUID generated if empty).
|
|
22
|
+
* @param {string} [options.positionName] The job title/position name.
|
|
23
|
+
* @param {string} [options.positionId] The job title fbid from searchJobTitle (optional, UUID generated if empty).
|
|
24
|
+
* @param {boolean} [options.isCurrent=true] Whether this is the current job.
|
|
25
|
+
* @param {Object} [options.startDate] Start date: { year, month?, day? }.
|
|
26
|
+
* @param {Object} [options.endDate] End date: { year?, month?, day? } (if not current).
|
|
27
|
+
* @param {string} [options.description] Job description text.
|
|
28
|
+
* @param {string} [options.locationId] City fbid for work location (from searchCity).
|
|
29
|
+
* @param {string} [options.privacy='EVERYONE'] Privacy: 'EVERYONE', 'FRIENDS', or 'SELF'.
|
|
30
|
+
* @param {string} [options.workExperienceID] Existing work experience ID to update (null for new).
|
|
31
|
+
* @returns {Promise<any>} A promise that resolves to the API response data.
|
|
32
|
+
* @throws {Error} If companyName is missing or the API request fails.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Add new work experience
|
|
36
|
+
* await api.updateWorkExperience({
|
|
37
|
+
* companyName: 'Google',
|
|
38
|
+
* companyId: '104958162837', // from searchCompany
|
|
39
|
+
* positionName: 'Software Engineer',
|
|
40
|
+
* positionId: '106154556093103', // from searchJobTitle
|
|
41
|
+
* isCurrent: true,
|
|
42
|
+
* startDate: { year: 2024 },
|
|
43
|
+
* });
|
|
44
|
+
*/
|
|
45
|
+
return async function updateWorkExperience(options) {
|
|
46
|
+
if (!options.companyName) {
|
|
47
|
+
throw new Error('companyName is required.');
|
|
48
|
+
}
|
|
49
|
+
const privacy = options.privacy || 'EVERYONE';
|
|
50
|
+
// Generate a UUID-like ID if not provided
|
|
51
|
+
const generateUUID = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
52
|
+
const r = (Math.random() * 16) | 0;
|
|
53
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
54
|
+
return v.toString(16);
|
|
55
|
+
});
|
|
56
|
+
// sectionToken = base64("app_section:<userID>:2327158227")
|
|
57
|
+
const sectionToken = Buffer.from(`app_section:${ctx.userID}:2327158227`).toString('base64');
|
|
58
|
+
const variables = {
|
|
59
|
+
collectionToken: 'UNKNOWN',
|
|
60
|
+
input: {
|
|
61
|
+
description: options.description || '',
|
|
62
|
+
employer_id: options.companyId || generateUUID(),
|
|
63
|
+
employer_name: options.companyName,
|
|
64
|
+
end_date: options.endDate || {},
|
|
65
|
+
is_current: options.isCurrent !== undefined ? options.isCurrent : true,
|
|
66
|
+
location_id: options.locationId || '',
|
|
67
|
+
logging_data: {
|
|
68
|
+
nav_chain: `ProfileCometAboutTabRoot.react,comet.profile.collection.directory_work,unexpected,${Date.now()},0,,,`,
|
|
69
|
+
},
|
|
70
|
+
mutation_surface: 'PROFILE',
|
|
71
|
+
position_id: options.positionId || generateUUID(),
|
|
72
|
+
position_name: options.positionName || '',
|
|
73
|
+
privacy: {
|
|
74
|
+
allow: [],
|
|
75
|
+
base_state: privacy,
|
|
76
|
+
deny: [],
|
|
77
|
+
tag_expansion_state: 'UNSPECIFIED',
|
|
78
|
+
},
|
|
79
|
+
start_date: options.startDate || {},
|
|
80
|
+
actor_id: ctx.userID,
|
|
81
|
+
client_mutation_id: Math.floor(Math.random() * 10 + 1).toString(),
|
|
82
|
+
},
|
|
83
|
+
scale: 1,
|
|
84
|
+
sectionToken: sectionToken,
|
|
85
|
+
profileID: ctx.userID,
|
|
86
|
+
workExperienceID: options.workExperienceID || null,
|
|
87
|
+
useDefaultActor: false,
|
|
88
|
+
isProfileDirectory: true,
|
|
89
|
+
shouldFetchPostClick: false,
|
|
90
|
+
};
|
|
91
|
+
const form = {
|
|
92
|
+
av: ctx.userID,
|
|
93
|
+
__user: ctx.userID,
|
|
94
|
+
__a: '1',
|
|
95
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
96
|
+
jazoest: ctx.jazoest,
|
|
97
|
+
lsd: ctx.lsd,
|
|
98
|
+
fb_api_caller_class: 'RelayModern',
|
|
99
|
+
fb_api_req_friendly_name: 'ProfileCometWorkExperienceSaveMutation',
|
|
100
|
+
variables: JSON.stringify(variables),
|
|
101
|
+
server_timestamps: 'true',
|
|
102
|
+
doc_id: '25132001056475784',
|
|
103
|
+
};
|
|
104
|
+
const customHeader = {
|
|
105
|
+
'x-fb-friendly-name': 'ProfileCometWorkExperienceSaveMutation',
|
|
106
|
+
'x-fb-lsd': ctx.lsd,
|
|
107
|
+
'x-asbd-id': '359341',
|
|
108
|
+
origin: 'https://www.facebook.com',
|
|
109
|
+
referer: `https://www.facebook.com/profile.php?id=${ctx.userID}&sk=directory_work`,
|
|
110
|
+
};
|
|
111
|
+
const resData = await utils.post('https://www.facebook.com/api/graphql/', ctx.jar, form, ctx.globalOptions, ctx, customHeader);
|
|
112
|
+
let data;
|
|
113
|
+
if (typeof resData.body === 'object' && resData.body !== null && !Buffer.isBuffer(resData.body)) {
|
|
114
|
+
data = resData.body;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const body = typeof resData.body === 'string' ? resData.body : resData.body.toString();
|
|
118
|
+
try {
|
|
119
|
+
data = JSON.parse(body);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
const lines = body.split('\n').filter(Boolean);
|
|
123
|
+
data = JSON.parse(lines[0]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (data.errors)
|
|
127
|
+
throw new Error(JSON.stringify(data.errors));
|
|
128
|
+
return data.data || data;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=updateWorkExperience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateWorkExperience.js","sourceRoot":"","sources":["../../../../src/deltas/apis/users/updateWorkExperience.ts"],"names":[],"mappings":";;AAWA,6CAoJC;AA/JD,wCAAyC;AAEzC;;;;;;;;GAQG;AACH,SAAwB,0BAA0B,CAAC,YAAiB,EAAE,GAAQ,EAAE,GAAQ;IACtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,OAAO,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