alicezetion 1.8.5 → 1.8.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/index.js +1 -0
- package/leiamnash/token.js +112 -0
- package/package.json +1 -1
- package/utils.js +18 -2
@@ -1 +1 @@
|
|
1
|
-
{"nonce":
|
1
|
+
{"nonce":4223399807553276865,"last_updated":{"seconds":1697933034,"nanos":282743000}}
|
package/index.js
CHANGED
@@ -0,0 +1,112 @@
|
|
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
|
+
}
|
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
/* eslint-disable no-prototype-builtins */
|
2
1
|
"use strict";
|
3
2
|
|
4
3
|
const bluebird = require("bluebird");
|
@@ -1437,6 +1436,22 @@ function getAppState(jar) {
|
|
1437
1436
|
.concat(jar.getCookies("https://facebook.com"))
|
1438
1437
|
.concat(jar.getCookies("https://www.messenger.com"));
|
1439
1438
|
}
|
1439
|
+
|
1440
|
+
function createAccess_token(jar, globalOptions) {
|
1441
|
+
return function (res) {
|
1442
|
+
return get('https://business.facebook.com/business_locations', jar, null, globalOptions)
|
1443
|
+
.then(function (resp) {
|
1444
|
+
var accessToken = /"],\["(\S+)","436761779744620",{/g.exec(resp.body);
|
1445
|
+
if (accessToken) accessToken = accessToken[1].split('"],["').pop();
|
1446
|
+
else accessToken = 'NONE';
|
1447
|
+
return [(res || resp.body), accessToken];
|
1448
|
+
})
|
1449
|
+
.catch(() => {
|
1450
|
+
return [(res || null), 'NONE'];
|
1451
|
+
})
|
1452
|
+
}
|
1453
|
+
}
|
1454
|
+
|
1440
1455
|
module.exports = {
|
1441
1456
|
CustomError,
|
1442
1457
|
isReadableStream,
|
@@ -1477,5 +1492,6 @@ module.exports = {
|
|
1477
1492
|
getAppState,
|
1478
1493
|
getAdminTextMessageType,
|
1479
1494
|
setProxy,
|
1480
|
-
checkLiveCookie
|
1495
|
+
checkLiveCookie,
|
1496
|
+
createAccess_token
|
1481
1497
|
}
|