fca-devnguyen 1.3.4
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.
Potentially problematic release.
This version of fca-devnguyen might be problematic. Click here for more details.
- package/.cache/replit/__replit_disk_meta.json +1 -0
- package/.config/configstore/update-notifier-npm.json +4 -0
- package/.config/configstore/update-notifier-npm.json.1735545094 +4 -0
- package/.gitattributes +2 -0
- package/.replit +89 -0
- package/.upm/store.json +1 -0
- package/Extra/Database/index.js +470 -0
- package/Extra/ExtraAddons.js +80 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +118 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +119 -0
- package/Extra/Html/Classic/style.css +8 -0
- package/Extra/Security/Index.js +146 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +66 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +83 -0
- package/Extra/Src/Release_Memory.js +41 -0
- package/Extra/Src/uuid.js +137 -0
- package/FastConfigFca.json +23 -0
- package/Func/AcceptAgreement.js +32 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/LICENSE +24 -0
- package/Language/index.json +206 -0
- package/Main.js +1098 -0
- package/README.md +140 -0
- package/SECURITY.md +17 -0
- package/broadcast.js +40 -0
- package/index.js +313 -0
- package/logger.js +66 -0
- package/package.json +102 -0
- package/replit.nix +8 -0
- package/src/Dev_Horizon_Data.js +125 -0
- package/src/Premium.js +30 -0
- package/src/Screenshot.js +85 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +79 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +32 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getMessage.js +80 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadInfo.js +355 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +220 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +141 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +36 -0
- package/src/getUserInfoV3.js +63 -0
- package/src/getUserInfoV4.js +55 -0
- package/src/getUserInfoV5.js +61 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +796 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +334 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/test/Database_Test.js +3 -0
- package/test/Db2.js +362 -0
- package/test/Horizon_Database/A_README.md +1 -0
- package/test/Horizon_Database/Database.db +0 -0
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/env/.env +0 -0
- package/test/example-config.json +18 -0
- package/test/example-db.db +0 -0
- package/test/memoryleak.js +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/test/testv2.js +18 -0
- package/utils.js +1644 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(_defaultFuncs, _api, _ctx) {
|
|
4
|
+
// Currently the only colors that can be passed to api.changeThreadColor(); may change if Facebook adds more
|
|
5
|
+
return {
|
|
6
|
+
////MessengerBlue: null,
|
|
7
|
+
////Viking: "#44bec7",
|
|
8
|
+
////GoldenPoppy: "#ffc300",
|
|
9
|
+
////RadicalRed: "#fa3c4c",
|
|
10
|
+
////Shocking: "#d696bb",
|
|
11
|
+
////PictonBlue: "#6699cc",
|
|
12
|
+
////FreeSpeechGreen: "#13cf13",
|
|
13
|
+
////Pumpkin: "#ff7e29",
|
|
14
|
+
////LightCoral: "#e68585",
|
|
15
|
+
////MediumSlateBlue: "#7646ff",
|
|
16
|
+
////DeepSkyBlue: "#20cef5",
|
|
17
|
+
////Fern: "#67b868",
|
|
18
|
+
////Cameo: "#d4a88c",
|
|
19
|
+
////BrilliantRose: "#ff5ca1",
|
|
20
|
+
////BilobaFlower: "#a695c7"
|
|
21
|
+
DefaultBlue: "196241301102133",
|
|
22
|
+
HotPink: "169463077092846",
|
|
23
|
+
AquaBlue: "2442142322678320",
|
|
24
|
+
BrightPurple: "234137870477637",
|
|
25
|
+
CoralPink: "980963458735625",
|
|
26
|
+
Orange: "175615189761153",
|
|
27
|
+
Green: "2136751179887052",
|
|
28
|
+
LavenderPurple: "2058653964378557",
|
|
29
|
+
Red: "2129984390566328",
|
|
30
|
+
Yellow: "174636906462322",
|
|
31
|
+
TealBlue: "1928399724138152",
|
|
32
|
+
Aqua: "417639218648241",
|
|
33
|
+
Mango: "930060997172551",
|
|
34
|
+
Berry: "164535220883264",
|
|
35
|
+
Citrus: "370940413392601",
|
|
36
|
+
Candy: "205488546921017",
|
|
37
|
+
StarWars: "809305022860427"
|
|
38
|
+
};
|
|
39
|
+
};
|
package/src/unfriend.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var utils = require("../utils");
|
|
4
|
+
var log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function unfriend(userID, callback) {
|
|
8
|
+
var resolveFunc = function () { };
|
|
9
|
+
var rejectFunc = function () { };
|
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function (err, friendList) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc(friendList);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var form = {
|
|
23
|
+
uid: userID,
|
|
24
|
+
unref: "bd_friends_tab",
|
|
25
|
+
floc: "friends_tab",
|
|
26
|
+
"nctr[_mod]": "pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
defaultFuncs
|
|
30
|
+
.post("https://www.facebook.com/ajax/profile/removefriendconfirm.php", ctx.jar, form)
|
|
31
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
32
|
+
.then(function (resData) {
|
|
33
|
+
if (resData.error) throw resData;
|
|
34
|
+
return callback();
|
|
35
|
+
})
|
|
36
|
+
.catch(function (err) {
|
|
37
|
+
log.error("unfriend", err);
|
|
38
|
+
return callback(err);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return returnPromise;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var utils = require("../utils");
|
|
4
|
+
var log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function unsendMessage(messageID, callback) {
|
|
8
|
+
var resolveFunc = function () { };
|
|
9
|
+
var rejectFunc = function () { };
|
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function (err, friendList) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc(friendList);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var form = {
|
|
23
|
+
message_id: messageID
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
defaultFuncs
|
|
27
|
+
.post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
|
|
28
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
29
|
+
.then(function (resData) {
|
|
30
|
+
if (resData.error) throw resData;
|
|
31
|
+
return callback();
|
|
32
|
+
})
|
|
33
|
+
.catch(function (err) {
|
|
34
|
+
log.error("unsendMessage", err);
|
|
35
|
+
return callback(err);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return returnPromise;
|
|
39
|
+
};
|
|
40
|
+
};
|
package/test/Db2.js
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
var get = require('lodash/get'),
|
|
2
|
+
set = require('lodash/set'),
|
|
3
|
+
fetch = require("node-fetch"),
|
|
4
|
+
fs = require("fs-extra"),
|
|
5
|
+
BetterDB = require("better-sqlite3");
|
|
6
|
+
if (!fs.existsSync(process.cwd() + "/Horizon_Database")) {
|
|
7
|
+
fs.mkdirSync(process.cwd() + "/Horizon_Database");
|
|
8
|
+
}
|
|
9
|
+
var db = new BetterDB(process.cwd() + "/Horizon_Database/SyntheticDatabase.sqlite");
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
get: function(key, ops,forceFuction) {
|
|
13
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
14
|
+
if (!key)
|
|
15
|
+
throw new TypeError(
|
|
16
|
+
"No key specified."
|
|
17
|
+
);
|
|
18
|
+
return arbitrate("fetch", { id: key, ops: ops || {} });
|
|
19
|
+
}
|
|
20
|
+
else return fetch(process.env.REPLIT_DB_URL + "/" + key)
|
|
21
|
+
.then((e) => e.text())
|
|
22
|
+
.then((strValue) => {
|
|
23
|
+
if (ops && ops.raw) return strValue;
|
|
24
|
+
if (!strValue) return null;
|
|
25
|
+
try {
|
|
26
|
+
var value = JSON.parse(strValue);
|
|
27
|
+
} catch (_err) {
|
|
28
|
+
throw new SyntaxError(
|
|
29
|
+
`Failed to parse value of ${key}, try passing a raw option to get the raw value`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (value === null || value === undefined) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
set: function(key, value,forceFuction) {
|
|
40
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
41
|
+
if (!key)
|
|
42
|
+
throw new TypeError(
|
|
43
|
+
"No key specified."
|
|
44
|
+
);
|
|
45
|
+
return arbitrate("set",{
|
|
46
|
+
stringify: false,
|
|
47
|
+
id: key,
|
|
48
|
+
data: value,
|
|
49
|
+
ops: {},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else return fetch(process.env.REPLIT_DB_URL, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
55
|
+
body: encodeURIComponent(key) + "=" + encodeURIComponent(JSON.stringify(value)),
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
has: function(key,forceFuction) {
|
|
59
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
60
|
+
if (!key)
|
|
61
|
+
throw new TypeError(
|
|
62
|
+
"No key specified."
|
|
63
|
+
);
|
|
64
|
+
return arbitrate("has", { id: key, ops: {} });
|
|
65
|
+
}
|
|
66
|
+
else return fetch(process.env.REPLIT_DB_URL + "/" + key)
|
|
67
|
+
.then((e) => e.text())
|
|
68
|
+
.then((strValue) => {
|
|
69
|
+
if (strValue === "") return false;
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
delete: function(key,forceFuction) {
|
|
74
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
75
|
+
if (!key)
|
|
76
|
+
throw new TypeError(
|
|
77
|
+
"No key specified."
|
|
78
|
+
);
|
|
79
|
+
return arbitrate("delete", { id: key, ops: {} });
|
|
80
|
+
}
|
|
81
|
+
else return fetch(process.env.REPLIT_DB_URL + "/" + key, {
|
|
82
|
+
method: "DELETE",
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
deleteMultiple: function(forceFuction,...args) {
|
|
87
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
88
|
+
if (!key)
|
|
89
|
+
throw new TypeError(
|
|
90
|
+
"No key specified."
|
|
91
|
+
);
|
|
92
|
+
try {
|
|
93
|
+
for (let i of args) {
|
|
94
|
+
arbitrate("delete", { id: i, ops: {} });
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const promises = [];
|
|
104
|
+
|
|
105
|
+
for (const arg of args) {
|
|
106
|
+
promises.push(this.delete(arg));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Promise.all(promises);
|
|
110
|
+
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
empty: async function(forceFuction) {
|
|
116
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
117
|
+
return arbitrate("clear");
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const promises = [];
|
|
121
|
+
for (const key of await this.list()) {
|
|
122
|
+
promises.push(this.delete(key));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Promise.all(promises);
|
|
126
|
+
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
list: async function(forceFuction) {
|
|
132
|
+
if (process.env["REPL_ID"] == undefined || forceFuction) {
|
|
133
|
+
return arbitrate("all",{ ops: {} });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return fetch(
|
|
137
|
+
this.key + `?encode=true&prefix=${encodeURIComponent(true)}`
|
|
138
|
+
)
|
|
139
|
+
.then((r) => r.text())
|
|
140
|
+
.then((t) => {
|
|
141
|
+
if (t.length === 0) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
return t.split("\n").map(decodeURIComponent);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var methods = {
|
|
151
|
+
fetch: function(db, params, options) {
|
|
152
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
153
|
+
if (!fetched) return null;
|
|
154
|
+
try {
|
|
155
|
+
fetched = JSON.parse(fetched.json)
|
|
156
|
+
} catch (e) {
|
|
157
|
+
fetched = fetched.json;
|
|
158
|
+
}
|
|
159
|
+
if (params.ops.target) fetched = get(fetched, params.ops.target);
|
|
160
|
+
return fetched;
|
|
161
|
+
},
|
|
162
|
+
set: function(db, params, options) {
|
|
163
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
164
|
+
if (!fetched) {
|
|
165
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
|
166
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
fetched = JSON.parse(fetched);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
fetched = fetched;
|
|
172
|
+
}
|
|
173
|
+
if (typeof fetched === 'object' && params.ops.target) {
|
|
174
|
+
params.data = JSON.parse(params.data);
|
|
175
|
+
params.data = set(fetched, params.ops.target, params.data);
|
|
176
|
+
}
|
|
177
|
+
else if (params.ops.target) throw new TypeError('Cannot target a non-object.');
|
|
178
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(JSON.stringify(params.data), params.id);
|
|
179
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
|
180
|
+
if (newData === '{}') return null;
|
|
181
|
+
else {
|
|
182
|
+
try { newData = JSON.parse(newData);
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
newData = newData;
|
|
186
|
+
}
|
|
187
|
+
return newData;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
add: function addDB(db, params, options) {
|
|
191
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
192
|
+
if (!fetched) {
|
|
193
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
|
194
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
195
|
+
}
|
|
196
|
+
if (params.ops.target) {
|
|
197
|
+
try {
|
|
198
|
+
fetched = JSON.parse(fetched)
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
fetched = fetched;
|
|
202
|
+
}
|
|
203
|
+
let oldValue = get(fetched, params.ops.target);
|
|
204
|
+
if (oldValue === undefined) oldValue = 0;
|
|
205
|
+
else if (isNaN(oldValue)) throw new Error(`Data @ ID: "${params.id}" IS NOT A number.\nFOUND: ${fetched}\nEXPECTED: number`);
|
|
206
|
+
params.data = set(fetched, params.ops.target, oldValue + JSON.parse(params.data));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
if (fetched.json === '{}') fetched.json = 0;
|
|
210
|
+
try {
|
|
211
|
+
fetched.json = JSON.parse(fetched)
|
|
212
|
+
} catch (e) {
|
|
213
|
+
fetched.json = fetched.json;
|
|
214
|
+
}
|
|
215
|
+
if (isNaN(fetched.json)) throw new Error(`Data @ ID: "${params.id}" IS NOT A number.\nFOUND: ${fetched.json}\nEXPECTED: number`);
|
|
216
|
+
params.data = parseInt(fetched.json, 10) + parseInt(params.data, 10);
|
|
217
|
+
}
|
|
218
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(JSON.stringify(params.data), params.id);
|
|
219
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
|
220
|
+
if (newData === '{}') return null;
|
|
221
|
+
else {
|
|
222
|
+
try {
|
|
223
|
+
newData = JSON.parse(newData);
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
newData = newData;
|
|
227
|
+
}
|
|
228
|
+
return newData;
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
subtract: function subtractDB(db, params, options) {
|
|
232
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
233
|
+
if (!fetched) {
|
|
234
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
|
235
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
236
|
+
}
|
|
237
|
+
if (params.ops.target) {
|
|
238
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
|
239
|
+
params.data = JSON.parse(params.data);
|
|
240
|
+
let oldValue = get(fetched, params.ops.target);
|
|
241
|
+
if (oldValue === undefined) oldValue = 0;
|
|
242
|
+
else if (isNaN(oldValue)) throw new Error('Target is not a number.');
|
|
243
|
+
params.data = set(fetched, params.ops.target, oldValue - params.data);
|
|
244
|
+
} else {
|
|
245
|
+
if (fetched.json === '{}') fetched.json = 0;
|
|
246
|
+
else fetched.json = JSON.parse(fetched.json);
|
|
247
|
+
try { fetched.json = JSON.parse(fetched); } catch (e) {}
|
|
248
|
+
if (isNaN(fetched.json)) throw new Error('Target is not a number.');
|
|
249
|
+
params.data = parseInt(fetched.json, 10) - parseInt(params.data, 10);
|
|
250
|
+
}
|
|
251
|
+
params.data = JSON.stringify(params.data);
|
|
252
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(params.data, params.id);
|
|
253
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
|
254
|
+
if (newData === '{}') return null;
|
|
255
|
+
else {
|
|
256
|
+
try { newData = JSON.parse(newData); } catch (e) {}
|
|
257
|
+
return newData;
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
push: function pushDB(db, params, options) {
|
|
261
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
262
|
+
if (!fetched) {
|
|
263
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
|
264
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
265
|
+
}
|
|
266
|
+
if (params.ops.target) {
|
|
267
|
+
fetched = JSON.parse(fetched.json);
|
|
268
|
+
try { fetched = JSON.parse(fetched) } catch (e) {}
|
|
269
|
+
params.data = JSON.parse(params.data);
|
|
270
|
+
if (typeof fetched !== 'object') throw new TypeError('Cannot push into a non-object.');
|
|
271
|
+
let oldArray = get(fetched, params.ops.target);
|
|
272
|
+
if (oldArray === undefined) oldArray = [];
|
|
273
|
+
else if (!Array.isArray(oldArray)) throw new TypeError('Target is not an array.');
|
|
274
|
+
oldArray.push(params.data);
|
|
275
|
+
params.data = set(fetched, params.ops.target, oldArray);
|
|
276
|
+
} else {
|
|
277
|
+
if (fetched.json === '{}') fetched.json = [];
|
|
278
|
+
else fetched.json = JSON.parse(fetched.json);
|
|
279
|
+
try { fetched.json = JSON.parse(fetched.json); } catch (e) {}
|
|
280
|
+
params.data = JSON.parse(params.data);
|
|
281
|
+
if (!Array.isArray(fetched.json)) throw new TypeError('Target is not an array.');
|
|
282
|
+
fetched.json.push(params.data);
|
|
283
|
+
params.data = fetched.json;
|
|
284
|
+
}
|
|
285
|
+
params.data = JSON.stringify(params.data);
|
|
286
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(params.data, params.id);
|
|
287
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
|
288
|
+
if (newData === '{}') return null;
|
|
289
|
+
else {
|
|
290
|
+
newData = JSON.parse(newData)
|
|
291
|
+
try { newData = JSON.parse(newData) } catch (e) {}
|
|
292
|
+
return newData
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
delete: function deleteDB(db, params, options) {
|
|
296
|
+
const unset = require('lodash/unset');
|
|
297
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
298
|
+
if (!fetched) return false;
|
|
299
|
+
else fetched = JSON.parse(fetched.json);
|
|
300
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
|
301
|
+
if (typeof fetched === 'object' && params.ops.target) {
|
|
302
|
+
unset(fetched, params.ops.target);
|
|
303
|
+
fetched = JSON.stringify(fetched);
|
|
304
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(fetched, params.id);
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
else if (params.ops.target) throw new TypeError('Target is not an object.');
|
|
308
|
+
else db.prepare(`DELETE FROM ${options.table} WHERE ID = (?)`).run(params.id);
|
|
309
|
+
return true;
|
|
310
|
+
},
|
|
311
|
+
has: function hasDB(db, params, options) {
|
|
312
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
313
|
+
if (!fetched) return false;
|
|
314
|
+
else fetched = JSON.parse(fetched.json);
|
|
315
|
+
try { fetched = JSON.parse(fetched) } catch (e) {}
|
|
316
|
+
if (params.ops.target) fetched = get(fetched, params.ops.target);
|
|
317
|
+
return (typeof fetched != 'undefined');
|
|
318
|
+
},
|
|
319
|
+
all: function allDB(db, params, options) {
|
|
320
|
+
var stmt = db.prepare(`SELECT * FROM ${options.table} WHERE ID IS NOT NULL`);
|
|
321
|
+
let resp = [];
|
|
322
|
+
for (var row of stmt.iterate()) {
|
|
323
|
+
try {
|
|
324
|
+
resp.push({
|
|
325
|
+
ID: row.ID,
|
|
326
|
+
data: JSON.parse(row.json)
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
return [];
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return resp;
|
|
334
|
+
},
|
|
335
|
+
type: function typeDB(db, params, options) {
|
|
336
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
|
337
|
+
if (!fetched) return null; // If empty, return null
|
|
338
|
+
fetched = JSON.parse(fetched.json);
|
|
339
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
|
340
|
+
if (params.ops.target) fetched = get(fetched, params.ops.target); // Get prop using dot notation
|
|
341
|
+
return typeof fetched;
|
|
342
|
+
},
|
|
343
|
+
clear: function clearDB(db, params, options) {
|
|
344
|
+
let fetched = db.prepare(`DELETE FROM ${options.table}`).run();
|
|
345
|
+
if(!fetched) return null;
|
|
346
|
+
return fetched.changes;
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
function arbitrate(method, params, tableName) {
|
|
352
|
+
let options = {table: "json"};
|
|
353
|
+
db.prepare(`CREATE TABLE IF NOT EXISTS ${options.table} (ID TEXT, json TEXT)`).run();
|
|
354
|
+
if (params.ops.target && params.ops.target[0] === ".") params.ops.target = params.ops.target.slice(1); // Remove prefix if necessary
|
|
355
|
+
if (params.data && params.data === Infinity) throw new TypeError(`You cannot set Infinity into the database @ ID: ${params.id}`);
|
|
356
|
+
if (params.id && typeof params.id == "string" && params.id.includes(".")) {
|
|
357
|
+
let unparsed = params.id.split(".");
|
|
358
|
+
params.id = unparsed.shift();
|
|
359
|
+
params.ops.target = unparsed.join(".");
|
|
360
|
+
}
|
|
361
|
+
return methods[method](db, params, options);
|
|
362
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This folder is used by ChernobyL(NANI =)) ) to store data. Do not delete this folder or any of the files in it.
|
|
Binary file
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"delta": {
|
|
3
|
+
"attachments": [
|
|
4
|
+
{
|
|
5
|
+
"fbid": "1522004821162174",
|
|
6
|
+
"id": "1522004821162174",
|
|
7
|
+
"mercury": {
|
|
8
|
+
"app_attribution": null,
|
|
9
|
+
"attach_type": "share",
|
|
10
|
+
"name": null,
|
|
11
|
+
"url": null,
|
|
12
|
+
"rel": null,
|
|
13
|
+
"preview_url": null,
|
|
14
|
+
"preview_width": null,
|
|
15
|
+
"preview_height": null,
|
|
16
|
+
"large_preview_url": null,
|
|
17
|
+
"large_preview_width": null,
|
|
18
|
+
"large_preview_height": null,
|
|
19
|
+
"icon_type": null,
|
|
20
|
+
"metadata": null,
|
|
21
|
+
"thumbnail_url": null,
|
|
22
|
+
"share": {
|
|
23
|
+
"description": null,
|
|
24
|
+
"media": {
|
|
25
|
+
"animated_image": null,
|
|
26
|
+
"animated_image_size": {
|
|
27
|
+
"height": null,
|
|
28
|
+
"width": null
|
|
29
|
+
},
|
|
30
|
+
"image": null,
|
|
31
|
+
"image_size": {
|
|
32
|
+
"height": null,
|
|
33
|
+
"width": null
|
|
34
|
+
},
|
|
35
|
+
"duration": null,
|
|
36
|
+
"playable": null,
|
|
37
|
+
"source": null
|
|
38
|
+
},
|
|
39
|
+
"source": "Dimon - testing",
|
|
40
|
+
"style_list": [
|
|
41
|
+
"business_message_items", "fallback"
|
|
42
|
+
],
|
|
43
|
+
"title": "search engines",
|
|
44
|
+
"properties": null,
|
|
45
|
+
"uri": null,
|
|
46
|
+
"subattachments": [],
|
|
47
|
+
"deduplication_key": "abcde",
|
|
48
|
+
"action_links": [],
|
|
49
|
+
"share_id": "1522004821162174",
|
|
50
|
+
"target": {
|
|
51
|
+
"call_to_actions": [],
|
|
52
|
+
"items": [
|
|
53
|
+
{
|
|
54
|
+
"id": "629934437209008",
|
|
55
|
+
"name": "search engines",
|
|
56
|
+
"desc": "",
|
|
57
|
+
"thumb_url": null,
|
|
58
|
+
"item_url": null,
|
|
59
|
+
"title": "search engines",
|
|
60
|
+
"text": "",
|
|
61
|
+
"source": null,
|
|
62
|
+
"metalines": {
|
|
63
|
+
"metaline_1": "click to get redirected",
|
|
64
|
+
"metaline_2": null,
|
|
65
|
+
"metaline_3": null
|
|
66
|
+
},
|
|
67
|
+
"location": 12314,
|
|
68
|
+
"category": 69,
|
|
69
|
+
"call_to_actions": [
|
|
70
|
+
{
|
|
71
|
+
"action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fgoogle.com%2F&h=ATNziCq_-6I3ZPYwwLluFdCrWMEwLLKvokFlXdEdS4LD2Lzsv2cR2SJYffJcDYBfB092Xeq8oRdftJk4husEYVduH24RnlP3HvVQOkOrciXDs2M7TkWYyNLBelvJ2Fc-mw8pbGy5NslGf_fkZ_A",
|
|
72
|
+
"action_type": 2,
|
|
73
|
+
"id": "FFD=",
|
|
74
|
+
"title": "Google",
|
|
75
|
+
"link_target_ids": [629934437209008],
|
|
76
|
+
"is_mutable_by_server": false,
|
|
77
|
+
"should_show_user_confirmation": false,
|
|
78
|
+
"confirmation_title": null,
|
|
79
|
+
"confirmation_message": null,
|
|
80
|
+
"confirmation_continue_label": null,
|
|
81
|
+
"confirmation_cancel_label": null,
|
|
82
|
+
"payment_metadata": {
|
|
83
|
+
"total_price": null,
|
|
84
|
+
"payment_module_config": null
|
|
85
|
+
},
|
|
86
|
+
"is_disabled": false
|
|
87
|
+
}, {
|
|
88
|
+
"action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fyahoo.com%2F&h=ATNIuTf7iDGP5xXTWOAdhaGhRFfDf4eS09t_G9CrR0MDiBKpqtCDzPf_9y5Bq7TXMgmo6RttztsgeO0ReSc0PDvJDTa1fLMMK2CjrpkqC91_m-yaMXfeQ4aI6MbhZrOPnK3YFnQP4XvRx3N1udE",
|
|
89
|
+
"action_type": 2,
|
|
90
|
+
"id": "CDE=",
|
|
91
|
+
"title": "Yahoo",
|
|
92
|
+
"link_target_ids": [629934437209008],
|
|
93
|
+
"is_mutable_by_server": false,
|
|
94
|
+
"should_show_user_confirmation": false,
|
|
95
|
+
"confirmation_title": null,
|
|
96
|
+
"confirmation_message": null,
|
|
97
|
+
"confirmation_continue_label": null,
|
|
98
|
+
"confirmation_cancel_label": null,
|
|
99
|
+
"payment_metadata": {
|
|
100
|
+
"total_price": null,
|
|
101
|
+
"payment_module_config": null
|
|
102
|
+
},
|
|
103
|
+
"is_disabled": false
|
|
104
|
+
}, {
|
|
105
|
+
"action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fbing.com%2F&h=ATMoMijAt6Da6WWIQ679DhZyZizWdxAViWwyl-RjKobFUG_x8GmB8LD6pPa3KP5K1-QTL9vuaFwjqB0itaMFWk4VwQ9uh56JgnbFnAo4qM_CrQufgLeHwwCnWSCnZt8IzYT4y6YULLLFA5bL1H4",
|
|
106
|
+
"action_type": 2,
|
|
107
|
+
"id": "ABC=",
|
|
108
|
+
"title": "Bing",
|
|
109
|
+
"link_target_ids": [629934437209008],
|
|
110
|
+
"is_mutable_by_server": false,
|
|
111
|
+
"should_show_user_confirmation": false,
|
|
112
|
+
"confirmation_title": null,
|
|
113
|
+
"confirmation_message": null,
|
|
114
|
+
"confirmation_continue_label": null,
|
|
115
|
+
"confirmation_cancel_label": null,
|
|
116
|
+
"payment_metadata": {
|
|
117
|
+
"total_price": null,
|
|
118
|
+
"payment_module_config": null
|
|
119
|
+
},
|
|
120
|
+
"is_disabled": false
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"location": 132145,
|
|
126
|
+
"category": 69,
|
|
127
|
+
"message": "Aaa: search engines"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"otherUserFbIds": ["1521994257829897"],
|
|
132
|
+
"titanType": 1
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"messageMetadata": {
|
|
136
|
+
"actorFbId": "1345",
|
|
137
|
+
"messageId": "mid.12345:asdv",
|
|
138
|
+
"offlineThreadingId": "1345v1345",
|
|
139
|
+
"tags": ["source:messenger:commerce"],
|
|
140
|
+
"threadKey": {
|
|
141
|
+
"otherUserFbId": "13451345"
|
|
142
|
+
},
|
|
143
|
+
"timestamp": "1487078180265"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut placerat risus massa, eu rutrum massa tempus id. Aenean aliquet turpis at risus gravida, id scelerisque sem vestibulum. Aliquam erat volutpat. Pellentesque ut justo a sapien fringilla tincidunt ornare ac arcu. Nam non finibus turpis, eget tincidunt turpis. Morbi sed tempus leo. Aliquam ut nunc sed ante efficitur tristique et sed eros.
|
|
2
|
+
|
|
3
|
+
In eu tincidunt libero, eget tincidunt mauris. Donec ultrices placerat tincidunt. Sed ultrices neque dui, id viverra ante porta sed. Suspendisse tincidunt malesuada finibus. Ut cursus dolor sem, eu mattis lectus euismod a. In porttitor maximus lacus, eget volutpat mauris pretium at. Nulla consequat ipsum id enim fermentum feugiat. Fusce convallis bibendum massa ac viverra.
|
|
4
|
+
|
|
5
|
+
Sed a vehicula diam, et sollicitudin nunc. Quisque nec libero sit amet nibh fringilla pretium at vel massa. In enim dolor, euismod sed sapien id, accumsan tempus lacus. Aenean dapibus nulla at libero ultricies, id sagittis erat pretium. Nam iaculis tellus est, lobortis lacinia dui egestas vitae. Phasellus elementum quis lectus nec tincidunt. Ut gravida vestibulum ipsum ut cursus.
|
|
6
|
+
|
|
7
|
+
Mauris quam est, dignissim sed quam at, vulputate scelerisque purus. Maecenas tortor turpis, venenatis non purus et, finibus venenatis augue. Etiam et fringilla enim. Suspendisse a leo sed ex aliquet feugiat vitae nec magna. Vestibulum id massa in orci dictum ultricies. Vestibulum vitae leo sed lacus tempor dapibus. Cras viverra lorem sit amet magna imperdiet sodales. In sollicitudin ex sed feugiat commodo. Maecenas ac arcu tristique quam euismod ultrices quis et mi. Nulla lacinia sit amet lacus nec ultrices. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst. Curabitur vehicula, enim at vulputate bibendum, lorem tortor pellentesque massa, nec aliquam lacus mi ac libero. In vel nibh in ante facilisis tristique. Aliquam sapien purus, lobortis quis ultricies nec, dictum a turpis. Aenean pharetra congue lacus, id cursus erat fringilla congue.
|
package/test/env/.env
ADDED
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Instructions: Copy this file to test-config.json, fill in your test data
|
|
2
|
+
// and remove all comments (JSON doesn't support comments).
|
|
3
|
+
// Run the test with `npm test` after installing the devDependencies (mocha).
|
|
4
|
+
{
|
|
5
|
+
// Test user login information
|
|
6
|
+
"user" : {
|
|
7
|
+
"id" : "00000000000000",
|
|
8
|
+
"email" : "example@test.com",
|
|
9
|
+
"password" : "qwerty"
|
|
10
|
+
},
|
|
11
|
+
// Array of at least 2 other user IDs (not the same as the test user)
|
|
12
|
+
"userIDs" : [
|
|
13
|
+
"11111111111111",
|
|
14
|
+
"22222222222222"
|
|
15
|
+
],
|
|
16
|
+
// Id of page to which test user is an admin
|
|
17
|
+
"pageID": "3333333333333"
|
|
18
|
+
}
|
|
File without changes
|