node-ainzfb-new 1.6.2702-test → 1.6.2810-test

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ainzfb-new",
3
- "version": "1.6.2702-test",
3
+ "version": "1.6.2810-test",
4
4
  "description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.",
5
5
  "scripts": {
6
6
  "test": "mocha",
package/src/getUserID.js CHANGED
@@ -17,21 +17,19 @@ function formatData(data) {
17
17
  };
18
18
  }
19
19
 
20
- module.exports = function(defaultFuncs, api, ctx) {
20
+ module.exports = function (defaultFuncs, api, ctx) {
21
21
  return function getUserID(name, callback) {
22
- var resolveFunc = function(){};
23
- var rejectFunc = function(){};
22
+ var resolveFunc = function () { };
23
+ var rejectFunc = function () { };
24
24
  var returnPromise = new Promise(function (resolve, reject) {
25
25
  resolveFunc = resolve;
26
26
  rejectFunc = reject;
27
27
  });
28
28
 
29
29
  if (!callback) {
30
- callback = function (err, friendList) {
31
- if (err) {
32
- return rejectFunc(err);
33
- }
34
- resolveFunc(friendList);
30
+ callback = function (err, data) {
31
+ if (err) return rejectFunc(err);
32
+ resolveFunc(data);
35
33
  };
36
34
  }
37
35
 
@@ -45,22 +43,21 @@ module.exports = function(defaultFuncs, api, ctx) {
45
43
  };
46
44
 
47
45
  defaultFuncs
48
- .get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
46
+ .get2("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
49
47
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
50
- .then(function(resData) {
51
- if (resData.error) {
52
- throw resData;
53
- }
48
+ .then(function (resData) {
49
+ if (resData.error) throw resData;
54
50
 
55
51
  var data = resData.payload.entries;
56
52
 
57
53
  callback(null, data.map(formatData));
58
54
  })
59
- .catch(function(err) {
55
+ .catch(function (err) {
60
56
  log.error("getUserID", err);
57
+ console.log(err);
61
58
  return callback(err);
62
59
  });
63
60
 
64
61
  return returnPromise;
65
62
  };
66
- };
63
+ };
package/utils.js CHANGED
@@ -22,7 +22,8 @@ function getHeaders(url, options, ctx, customHeader) {
22
22
  Origin: "https://www.facebook.com",
23
23
  "User-Agent": options.userAgent,
24
24
  Connection: "keep-alive",
25
- 'sec-fetch-site': 'same-origin'
25
+ "sec-fetch-site": 'same-origin',
26
+ "sec-fetch-mode": 'cors'
26
27
  };
27
28
  if (customHeader) Object.assign(headers, customHeader);
28
29