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.
Files changed (121) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +534 -0
  3. package/index.js +35 -0
  4. package/package.json +101 -0
  5. package/phantom/core/builder/bootstrap.js +334 -0
  6. package/phantom/core/builder/config.js +78 -0
  7. package/phantom/core/builder/forge.js +113 -0
  8. package/phantom/core/builder/ignite.js +386 -0
  9. package/phantom/core/builder/options.js +61 -0
  10. package/phantom/core/engine.js +71 -0
  11. package/phantom/core/reactor.js +2 -0
  12. package/phantom/datastore/appState.js +2 -0
  13. package/phantom/datastore/appStateBackup.js +34 -0
  14. package/phantom/datastore/models/cipher/e2ee.js +48 -0
  15. package/phantom/datastore/models/cipher/vault.js +153 -0
  16. package/phantom/datastore/models/index.js +3 -0
  17. package/phantom/datastore/models/matrix/auth.js +151 -0
  18. package/phantom/datastore/models/matrix/cache.js +3 -0
  19. package/phantom/datastore/models/matrix/checker.js +2 -0
  20. package/phantom/datastore/models/matrix/clients.js +2 -0
  21. package/phantom/datastore/models/matrix/constants.js +2 -0
  22. package/phantom/datastore/models/matrix/credentials.js +2 -0
  23. package/phantom/datastore/models/matrix/cycle.js +2 -0
  24. package/phantom/datastore/models/matrix/gate.js +282 -0
  25. package/phantom/datastore/models/matrix/ghost.js +332 -0
  26. package/phantom/datastore/models/matrix/headers.js +193 -0
  27. package/phantom/datastore/models/matrix/heartbeat.js +298 -0
  28. package/phantom/datastore/models/matrix/identity.js +235 -0
  29. package/phantom/datastore/models/matrix/logger.js +271 -0
  30. package/phantom/datastore/models/matrix/monitor.js +2 -0
  31. package/phantom/datastore/models/matrix/net.js +316 -0
  32. package/phantom/datastore/models/matrix/response.js +193 -0
  33. package/phantom/datastore/models/matrix/revive.js +255 -0
  34. package/phantom/datastore/models/matrix/signals.js +2 -0
  35. package/phantom/datastore/models/matrix/store.js +263 -0
  36. package/phantom/datastore/models/matrix/telemetry.js +272 -0
  37. package/phantom/datastore/models/matrix/tools.js +93 -0
  38. package/phantom/datastore/models/matrix/transform/cookieParser.js +2 -0
  39. package/phantom/datastore/models/matrix/transform/cookies.js +114 -0
  40. package/phantom/datastore/models/matrix/transform/index.js +203 -0
  41. package/phantom/datastore/models/matrix/validator.js +157 -0
  42. package/phantom/datastore/models/types/index.d.ts +498 -0
  43. package/phantom/datastore/schema.js +167 -0
  44. package/phantom/datastore/session.js +129 -0
  45. package/phantom/datastore/threads.js +22 -0
  46. package/phantom/datastore/users.js +26 -0
  47. package/phantom/dispatch/addExternalModule.js +239 -0
  48. package/phantom/dispatch/addUserToGroup.js +161 -0
  49. package/phantom/dispatch/changeAdminStatus.js +142 -0
  50. package/phantom/dispatch/changeArchivedStatus.js +135 -0
  51. package/phantom/dispatch/changeAvatar.js +123 -0
  52. package/phantom/dispatch/changeBio.js +86 -0
  53. package/phantom/dispatch/changeBlockedStatus.js +86 -0
  54. package/phantom/dispatch/changeGroupImage.js +145 -0
  55. package/phantom/dispatch/changeThreadColor.js +172 -0
  56. package/phantom/dispatch/changeThreadEmoji.js +130 -0
  57. package/phantom/dispatch/comment.js +136 -0
  58. package/phantom/dispatch/createAITheme.js +333 -0
  59. package/phantom/dispatch/createNewGroup.js +99 -0
  60. package/phantom/dispatch/createPoll.js +148 -0
  61. package/phantom/dispatch/deleteMessage.js +131 -0
  62. package/phantom/dispatch/deleteThread.js +155 -0
  63. package/phantom/dispatch/e2ee.js +101 -0
  64. package/phantom/dispatch/editMessage.js +158 -0
  65. package/phantom/dispatch/emoji.js +143 -0
  66. package/phantom/dispatch/fetchThemeData.js +233 -0
  67. package/phantom/dispatch/follow.js +111 -0
  68. package/phantom/dispatch/forwardMessage.js +110 -0
  69. package/phantom/dispatch/friend.js +189 -0
  70. package/phantom/dispatch/gcmember.js +138 -0
  71. package/phantom/dispatch/gcname.js +131 -0
  72. package/phantom/dispatch/gcrule.js +111 -0
  73. package/phantom/dispatch/getAccess.js +109 -0
  74. package/phantom/dispatch/getBotInfo.js +81 -0
  75. package/phantom/dispatch/getBotInitialData.js +110 -0
  76. package/phantom/dispatch/getFriendsList.js +118 -0
  77. package/phantom/dispatch/getMessage.js +199 -0
  78. package/phantom/dispatch/getTheme.js +199 -0
  79. package/phantom/dispatch/getThemeInfo.js +160 -0
  80. package/phantom/dispatch/getThreadHistory.js +139 -0
  81. package/phantom/dispatch/getThreadInfo.js +153 -0
  82. package/phantom/dispatch/getThreadList.js +132 -0
  83. package/phantom/dispatch/getThreadPictures.js +93 -0
  84. package/phantom/dispatch/getUserID.js +147 -0
  85. package/phantom/dispatch/getUserInfo.js +513 -0
  86. package/phantom/dispatch/getUserInfoV2.js +146 -0
  87. package/phantom/dispatch/handleMessageRequest.js +50 -0
  88. package/phantom/dispatch/httpGet.js +63 -0
  89. package/phantom/dispatch/httpPost.js +89 -0
  90. package/phantom/dispatch/httpPostFormData.js +69 -0
  91. package/phantom/dispatch/listenMqtt.js +1236 -0
  92. package/phantom/dispatch/listenSpeed.js +179 -0
  93. package/phantom/dispatch/logout.js +93 -0
  94. package/phantom/dispatch/markAsDelivered.js +92 -0
  95. package/phantom/dispatch/markAsRead.js +119 -0
  96. package/phantom/dispatch/markAsReadAll.js +215 -0
  97. package/phantom/dispatch/markAsSeen.js +70 -0
  98. package/phantom/dispatch/mqttDeltaValue.js +278 -0
  99. package/phantom/dispatch/muteThread.js +253 -0
  100. package/phantom/dispatch/nickname.js +132 -0
  101. package/phantom/dispatch/notes.js +263 -0
  102. package/phantom/dispatch/pinMessage.js +238 -0
  103. package/phantom/dispatch/produceMetaTheme.js +335 -0
  104. package/phantom/dispatch/realtime.js +291 -0
  105. package/phantom/dispatch/removeUserFromGroup.js +248 -0
  106. package/phantom/dispatch/resolvePhotoUrl.js +217 -0
  107. package/phantom/dispatch/searchForThread.js +258 -0
  108. package/phantom/dispatch/sendMessage.js +354 -0
  109. package/phantom/dispatch/sendMessageMqtt.js +249 -0
  110. package/phantom/dispatch/sendTypingIndicator.js +206 -0
  111. package/phantom/dispatch/setMessageReaction.js +188 -0
  112. package/phantom/dispatch/setMessageReactionMqtt.js +248 -0
  113. package/phantom/dispatch/setThreadTheme.js +330 -0
  114. package/phantom/dispatch/setThreadThemeMqtt.js +207 -0
  115. package/phantom/dispatch/share.js +200 -0
  116. package/phantom/dispatch/shareContact.js +216 -0
  117. package/phantom/dispatch/stickers.js +395 -0
  118. package/phantom/dispatch/story.js +240 -0
  119. package/phantom/dispatch/theme.js +296 -0
  120. package/phantom/dispatch/unfriend.js +199 -0
  121. 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
+ };