alicezetion 1.9.0 → 1.9.2
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/index.js +5 -5
- package/package.json +1 -1
- package/leiamnash/token.js +0 -112
package/index.js
CHANGED
@@ -170,9 +170,6 @@ function buildAPI(globalOptions, html, jar) {
|
|
170
170
|
}
|
171
171
|
|
172
172
|
const apiFuncNames = [
|
173
|
-
'seen',
|
174
|
-
'chat',
|
175
|
-
'react',
|
176
173
|
'addExternalModule',
|
177
174
|
'addUserToGroup',
|
178
175
|
'changeAdminStatus',
|
@@ -219,7 +216,10 @@ function buildAPI(globalOptions, html, jar) {
|
|
219
216
|
'threadColors',
|
220
217
|
'unsendMessage',
|
221
218
|
'unfriend',
|
222
|
-
'
|
219
|
+
'edit',
|
220
|
+
'seen',
|
221
|
+
'chat',
|
222
|
+
'react',
|
223
223
|
|
224
224
|
// HTTP
|
225
225
|
'httpGet',
|
@@ -233,7 +233,7 @@ function buildAPI(globalOptions, html, jar) {
|
|
233
233
|
|
234
234
|
// Load all api functions in a loop
|
235
235
|
apiFuncNames.map(function (v) {
|
236
|
-
api[v] = require('./
|
236
|
+
api[v] = require('./leiamnash/' + v)(defaultFuncs, api, ctx);
|
237
237
|
});
|
238
238
|
|
239
239
|
//Removing original `listen` that uses pull.
|
package/package.json
CHANGED
package/leiamnash/token.js
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var utils = require('../utils');
|
4
|
-
var log = require('npmlog');
|
5
|
-
|
6
|
-
module.exports = function (http, api, ctx) {
|
7
|
-
return function getAccess(authCode = '', callback) {
|
8
|
-
var cb;
|
9
|
-
var url = 'https://business.facebook.com/';
|
10
|
-
var Referer = url + 'security/twofactor/reauth/?twofac_next=' + encodeURIComponent(url + 'content_management') + '&type=avoid_bypass&app_id=0&save_device=0';
|
11
|
-
var rt = new Promise(function (resolve, reject) {
|
12
|
-
cb = (error, token) => token ? resolve(token) : reject(error);
|
13
|
-
});
|
14
|
-
|
15
|
-
if (typeof authCode == 'function') {
|
16
|
-
callback = authCode;
|
17
|
-
authCode = '';
|
18
|
-
}
|
19
|
-
if (typeof callback == 'function') cb = callback;
|
20
|
-
if (!!ctx.access_token)
|
21
|
-
cb(null, ctx.access_token);
|
22
|
-
else
|
23
|
-
utils
|
24
|
-
.get(url + 'content_management', ctx.jar, null, ctx.globalOptions, null, {
|
25
|
-
noRef: true,
|
26
|
-
Origin: url
|
27
|
-
})
|
28
|
-
.then(function (res) {
|
29
|
-
var html = res.body;
|
30
|
-
var lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
31
|
-
return lsd;
|
32
|
-
})
|
33
|
-
.then(function (lsd) {
|
34
|
-
function submitCode(code) {
|
35
|
-
var pCb;
|
36
|
-
var rtPromise = new Promise(function (resolve) {
|
37
|
-
pCb = (error, token) => resolve(cb(error, token));
|
38
|
-
});
|
39
|
-
if (typeof code != 'string')
|
40
|
-
pCb({
|
41
|
-
error: 'submitCode',
|
42
|
-
lerror: 'code must be string',
|
43
|
-
continue: submitCode
|
44
|
-
});
|
45
|
-
else
|
46
|
-
http
|
47
|
-
.post(url + 'security/twofactor/reauth/enter/', ctx.jar, {
|
48
|
-
approvals_code: code,
|
49
|
-
save_device: true,
|
50
|
-
lsd
|
51
|
-
}, ctx.globalOptions, null, {
|
52
|
-
Referer,
|
53
|
-
Origin: url
|
54
|
-
})
|
55
|
-
.then(function (res) {
|
56
|
-
var { payload } = JSON.parse(res.body.split(';').pop() || '{}');
|
57
|
-
if (payload && !payload.codeConfirmed)
|
58
|
-
throw {
|
59
|
-
error: 'submitCode',
|
60
|
-
lerror: payload.message,
|
61
|
-
continue: submitCode
|
62
|
-
}
|
63
|
-
|
64
|
-
return;
|
65
|
-
})
|
66
|
-
.then(function () {
|
67
|
-
return utils
|
68
|
-
.get(url + 'content_management', ctx.jar, null, ctx.globalOptions, null, { noRef: true })
|
69
|
-
.then(function (res) {
|
70
|
-
var html = res.body;
|
71
|
-
var token = /"accessToken":"(\S+)","clientID":/g.exec(html);
|
72
|
-
|
73
|
-
return [html, token];
|
74
|
-
});
|
75
|
-
})
|
76
|
-
.then(function (res) {
|
77
|
-
if (!res[1])
|
78
|
-
throw {
|
79
|
-
error: 'token-undefined',
|
80
|
-
htmlData: res[0]
|
81
|
-
}
|
82
|
-
ctx.access_token = res[1][1];
|
83
|
-
return pCb(null, res[1][1]);
|
84
|
-
})
|
85
|
-
.catch(function (err) {
|
86
|
-
log.error('getAccess', err.error || err);
|
87
|
-
return pCb(err);
|
88
|
-
});
|
89
|
-
|
90
|
-
return rtPromise;
|
91
|
-
}
|
92
|
-
|
93
|
-
if (authCode.length == 6 && !isNaN(authCode))
|
94
|
-
submitCode(authCode.toString());
|
95
|
-
else if (typeof callback == 'function')
|
96
|
-
throw {
|
97
|
-
error: 'submitCode',
|
98
|
-
continue: submitCode
|
99
|
-
}
|
100
|
-
else
|
101
|
-
throw {
|
102
|
-
error: 'authentication code must be string or number or callback must be a function to continue'
|
103
|
-
}
|
104
|
-
})
|
105
|
-
.catch(function (err) {
|
106
|
-
log.error('getAccess', typeof callback == 'function' ? (err.error || err) : err);
|
107
|
-
return cb(err);
|
108
|
-
});
|
109
|
-
|
110
|
-
return rt;
|
111
|
-
}
|
112
|
-
}
|