fca-phantom 1.0.0
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/LICENSE +58 -0
- package/README.md +534 -0
- package/index.js +35 -0
- package/package.json +101 -0
- package/phantom/core/builder/bootstrap.js +334 -0
- package/phantom/core/builder/config.js +78 -0
- package/phantom/core/builder/forge.js +113 -0
- package/phantom/core/builder/ignite.js +386 -0
- package/phantom/core/builder/options.js +61 -0
- package/phantom/core/engine.js +71 -0
- package/phantom/core/reactor.js +2 -0
- package/phantom/datastore/appState.js +2 -0
- package/phantom/datastore/appStateBackup.js +34 -0
- package/phantom/datastore/models/cipher/e2ee.js +48 -0
- package/phantom/datastore/models/cipher/vault.js +153 -0
- package/phantom/datastore/models/index.js +3 -0
- package/phantom/datastore/models/matrix/auth.js +151 -0
- package/phantom/datastore/models/matrix/cache.js +3 -0
- package/phantom/datastore/models/matrix/checker.js +2 -0
- package/phantom/datastore/models/matrix/clients.js +2 -0
- package/phantom/datastore/models/matrix/constants.js +2 -0
- package/phantom/datastore/models/matrix/credentials.js +2 -0
- package/phantom/datastore/models/matrix/cycle.js +2 -0
- package/phantom/datastore/models/matrix/gate.js +282 -0
- package/phantom/datastore/models/matrix/ghost.js +332 -0
- package/phantom/datastore/models/matrix/headers.js +193 -0
- package/phantom/datastore/models/matrix/heartbeat.js +298 -0
- package/phantom/datastore/models/matrix/identity.js +235 -0
- package/phantom/datastore/models/matrix/logger.js +271 -0
- package/phantom/datastore/models/matrix/monitor.js +2 -0
- package/phantom/datastore/models/matrix/net.js +316 -0
- package/phantom/datastore/models/matrix/response.js +193 -0
- package/phantom/datastore/models/matrix/revive.js +255 -0
- package/phantom/datastore/models/matrix/signals.js +2 -0
- package/phantom/datastore/models/matrix/store.js +263 -0
- package/phantom/datastore/models/matrix/telemetry.js +272 -0
- package/phantom/datastore/models/matrix/tools.js +93 -0
- package/phantom/datastore/models/matrix/transform/cookieParser.js +2 -0
- package/phantom/datastore/models/matrix/transform/cookies.js +114 -0
- package/phantom/datastore/models/matrix/transform/index.js +203 -0
- package/phantom/datastore/models/matrix/validator.js +157 -0
- package/phantom/datastore/models/types/index.d.ts +498 -0
- package/phantom/datastore/schema.js +167 -0
- package/phantom/datastore/session.js +129 -0
- package/phantom/datastore/threads.js +22 -0
- package/phantom/datastore/users.js +26 -0
- package/phantom/dispatch/addExternalModule.js +239 -0
- package/phantom/dispatch/addUserToGroup.js +161 -0
- package/phantom/dispatch/changeAdminStatus.js +142 -0
- package/phantom/dispatch/changeArchivedStatus.js +135 -0
- package/phantom/dispatch/changeAvatar.js +123 -0
- package/phantom/dispatch/changeBio.js +86 -0
- package/phantom/dispatch/changeBlockedStatus.js +86 -0
- package/phantom/dispatch/changeGroupImage.js +145 -0
- package/phantom/dispatch/changeThreadColor.js +172 -0
- package/phantom/dispatch/changeThreadEmoji.js +130 -0
- package/phantom/dispatch/comment.js +136 -0
- package/phantom/dispatch/createAITheme.js +333 -0
- package/phantom/dispatch/createNewGroup.js +99 -0
- package/phantom/dispatch/createPoll.js +148 -0
- package/phantom/dispatch/deleteMessage.js +131 -0
- package/phantom/dispatch/deleteThread.js +155 -0
- package/phantom/dispatch/e2ee.js +101 -0
- package/phantom/dispatch/editMessage.js +158 -0
- package/phantom/dispatch/emoji.js +143 -0
- package/phantom/dispatch/fetchThemeData.js +233 -0
- package/phantom/dispatch/follow.js +111 -0
- package/phantom/dispatch/forwardMessage.js +110 -0
- package/phantom/dispatch/friend.js +189 -0
- package/phantom/dispatch/gcmember.js +138 -0
- package/phantom/dispatch/gcname.js +131 -0
- package/phantom/dispatch/gcrule.js +111 -0
- package/phantom/dispatch/getAccess.js +109 -0
- package/phantom/dispatch/getBotInfo.js +81 -0
- package/phantom/dispatch/getBotInitialData.js +110 -0
- package/phantom/dispatch/getFriendsList.js +118 -0
- package/phantom/dispatch/getMessage.js +199 -0
- package/phantom/dispatch/getTheme.js +199 -0
- package/phantom/dispatch/getThemeInfo.js +160 -0
- package/phantom/dispatch/getThreadHistory.js +139 -0
- package/phantom/dispatch/getThreadInfo.js +153 -0
- package/phantom/dispatch/getThreadList.js +132 -0
- package/phantom/dispatch/getThreadPictures.js +93 -0
- package/phantom/dispatch/getUserID.js +147 -0
- package/phantom/dispatch/getUserInfo.js +513 -0
- package/phantom/dispatch/getUserInfoV2.js +146 -0
- package/phantom/dispatch/handleMessageRequest.js +50 -0
- package/phantom/dispatch/httpGet.js +63 -0
- package/phantom/dispatch/httpPost.js +89 -0
- package/phantom/dispatch/httpPostFormData.js +69 -0
- package/phantom/dispatch/listenMqtt.js +1236 -0
- package/phantom/dispatch/listenSpeed.js +179 -0
- package/phantom/dispatch/logout.js +93 -0
- package/phantom/dispatch/markAsDelivered.js +92 -0
- package/phantom/dispatch/markAsRead.js +119 -0
- package/phantom/dispatch/markAsReadAll.js +215 -0
- package/phantom/dispatch/markAsSeen.js +70 -0
- package/phantom/dispatch/mqttDeltaValue.js +278 -0
- package/phantom/dispatch/muteThread.js +253 -0
- package/phantom/dispatch/nickname.js +132 -0
- package/phantom/dispatch/notes.js +263 -0
- package/phantom/dispatch/pinMessage.js +238 -0
- package/phantom/dispatch/produceMetaTheme.js +335 -0
- package/phantom/dispatch/realtime.js +291 -0
- package/phantom/dispatch/removeUserFromGroup.js +248 -0
- package/phantom/dispatch/resolvePhotoUrl.js +217 -0
- package/phantom/dispatch/searchForThread.js +258 -0
- package/phantom/dispatch/sendMessage.js +354 -0
- package/phantom/dispatch/sendMessageMqtt.js +249 -0
- package/phantom/dispatch/sendTypingIndicator.js +206 -0
- package/phantom/dispatch/setMessageReaction.js +188 -0
- package/phantom/dispatch/setMessageReactionMqtt.js +248 -0
- package/phantom/dispatch/setThreadTheme.js +330 -0
- package/phantom/dispatch/setThreadThemeMqtt.js +207 -0
- package/phantom/dispatch/share.js +200 -0
- package/phantom/dispatch/shareContact.js +216 -0
- package/phantom/dispatch/stickers.js +395 -0
- package/phantom/dispatch/story.js +240 -0
- package/phantom/dispatch/theme.js +296 -0
- package/phantom/dispatch/unfriend.js +199 -0
- package/phantom/dispatch/unsendMessage.js +124 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../datastore/models/matrix/tools');
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function httpGet(url, form, customHeader, callback, notAPI) {
|
|
7
|
+
let resolveFunc = function () {};
|
|
8
|
+
let rejectFunc = function () {};
|
|
9
|
+
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (
|
|
16
|
+
utils.getType(form) == "Function" ||
|
|
17
|
+
utils.getType(form) == "AsyncFunction"
|
|
18
|
+
) {
|
|
19
|
+
callback = form;
|
|
20
|
+
form = {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
utils.getType(customHeader) == "Function" ||
|
|
25
|
+
utils.getType(customHeader) == "AsyncFunction"
|
|
26
|
+
) {
|
|
27
|
+
callback = customHeader;
|
|
28
|
+
customHeader = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
customHeader = customHeader || {};
|
|
32
|
+
|
|
33
|
+
callback =
|
|
34
|
+
callback ||
|
|
35
|
+
function (err, data) {
|
|
36
|
+
if (err) return rejectFunc(err);
|
|
37
|
+
resolveFunc(data);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (notAPI) {
|
|
41
|
+
utils
|
|
42
|
+
.get(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
|
43
|
+
.then(function (resData) {
|
|
44
|
+
callback(null, resData.body.toString());
|
|
45
|
+
})
|
|
46
|
+
.catch(function (err) {
|
|
47
|
+
utils.error("httpGet", err);
|
|
48
|
+
return callback(err);
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
defaultFuncs
|
|
52
|
+
.get(url, ctx.jar, form, ctx, customHeader)
|
|
53
|
+
.then(function (resData) {
|
|
54
|
+
callback(null, resData.body.toString());
|
|
55
|
+
})
|
|
56
|
+
.catch(function (err) {
|
|
57
|
+
utils.error("httpGet", err);
|
|
58
|
+
return callback(err);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return returnPromise;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../datastore/models/matrix/tools');
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function httpPost(url, form, customHeader, callback, notAPI) {
|
|
7
|
+
let resolveFunc = function () {};
|
|
8
|
+
let rejectFunc = function () {};
|
|
9
|
+
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (
|
|
16
|
+
utils.getType(form) == "Function" ||
|
|
17
|
+
utils.getType(form) == "AsyncFunction"
|
|
18
|
+
) {
|
|
19
|
+
callback = form;
|
|
20
|
+
form = {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
utils.getType(customHeader) == "Function" ||
|
|
25
|
+
utils.getType(customHeader) == "AsyncFunction"
|
|
26
|
+
) {
|
|
27
|
+
callback = customHeader;
|
|
28
|
+
customHeader = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
customHeader = customHeader || {};
|
|
32
|
+
|
|
33
|
+
callback =
|
|
34
|
+
callback ||
|
|
35
|
+
function (err, data) {
|
|
36
|
+
if (err) return rejectFunc(err);
|
|
37
|
+
resolveFunc(data);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const normalizeBody = function(body) {
|
|
41
|
+
if (body === null || body === undefined) {
|
|
42
|
+
return String(body);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (Buffer.isBuffer(body) || body instanceof Uint8Array) {
|
|
46
|
+
return body.toString('utf8');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (typeof body === 'string') {
|
|
50
|
+
return body;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof body === 'object') {
|
|
54
|
+
try {
|
|
55
|
+
return JSON.stringify(body);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
return String(body);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return String(body);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (notAPI) {
|
|
65
|
+
utils
|
|
66
|
+
.post(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
|
67
|
+
.then(function (resData) {
|
|
68
|
+
const body = normalizeBody(resData.body);
|
|
69
|
+
callback(null, body);
|
|
70
|
+
})
|
|
71
|
+
.catch(function (err) {
|
|
72
|
+
utils.error("httpPost", err);
|
|
73
|
+
return callback(err);
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
defaultFuncs
|
|
77
|
+
.post(url, ctx.jar, form, ctx, customHeader)
|
|
78
|
+
.then(function (resData) {
|
|
79
|
+
const body = normalizeBody(resData.body);
|
|
80
|
+
callback(null, body);
|
|
81
|
+
})
|
|
82
|
+
.catch(function (err) {
|
|
83
|
+
utils.error("httpPost", err);
|
|
84
|
+
return callback(err);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return returnPromise;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../datastore/models/matrix/tools');
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function httpPostFormData(url, form, customHeader, callback, notAPI) {
|
|
7
|
+
let resolveFunc = function () {};
|
|
8
|
+
let rejectFunc = function () {};
|
|
9
|
+
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (
|
|
16
|
+
utils.getType(form) == "Function" ||
|
|
17
|
+
utils.getType(form) == "AsyncFunction"
|
|
18
|
+
) {
|
|
19
|
+
callback = form;
|
|
20
|
+
form = {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
utils.getType(customHeader) == "Function" ||
|
|
25
|
+
utils.getType(customHeader) == "AsyncFunction"
|
|
26
|
+
) {
|
|
27
|
+
callback = customHeader;
|
|
28
|
+
customHeader = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
customHeader = customHeader || {};
|
|
32
|
+
|
|
33
|
+
if (utils.getType(callback) == "Boolean") {
|
|
34
|
+
notAPI = callback;
|
|
35
|
+
callback = null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
callback =
|
|
39
|
+
callback ||
|
|
40
|
+
function (err, data) {
|
|
41
|
+
if (err) return rejectFunc(err);
|
|
42
|
+
resolveFunc(data);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (notAPI) {
|
|
46
|
+
utils
|
|
47
|
+
.postFormData(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
|
|
48
|
+
.then(function (resData) {
|
|
49
|
+
callback(null, resData.body.toString());
|
|
50
|
+
})
|
|
51
|
+
.catch(function (err) {
|
|
52
|
+
utils.error("httpPostFormData", err);
|
|
53
|
+
return callback(err);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
defaultFuncs
|
|
57
|
+
.postFormData(url, ctx.jar, form, null, ctx)
|
|
58
|
+
.then(function (resData) {
|
|
59
|
+
callback(null, resData.body.toString());
|
|
60
|
+
})
|
|
61
|
+
.catch(function (err) {
|
|
62
|
+
utils.error("httpPostFormData", err);
|
|
63
|
+
return callback(err);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return returnPromise;
|
|
68
|
+
};
|
|
69
|
+
};
|