@mtkruto/node 0.1.201 → 0.1.300
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/esm/0_deps.d.ts +1 -1
- package/esm/0_deps.js +2 -1
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/4_errors.js +3 -3
- package/esm/client/0_markdown.js +5 -5
- package/esm/client/0_utilities.d.ts +6 -0
- package/esm/client/0_utilities.js +35 -4
- package/esm/client/1_account_manager.js +4 -4
- package/esm/client/1_client_encrypted.js +4 -4
- package/esm/client/1_client_plain.js +3 -3
- package/esm/client/1_file_manager.js +6 -5
- package/esm/client/1_reaction_manager.js +2 -2
- package/esm/client/1_update_manager.js +9 -8
- package/esm/client/2_message_manager.js +47 -24
- package/esm/client/3_callback_query_manager.js +2 -0
- package/esm/client/3_chat_list_manager.js +13 -12
- package/esm/client/3_inline_query_manager.js +4 -2
- package/esm/client/3_story_manager.js +7 -5
- package/esm/client/4_client.js +14 -13
- package/esm/connection/1_connection_web_socket.js +3 -2
- package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.d.ts +0 -1
- package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +0 -11
- package/esm/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +308 -0
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.js +6 -5
- package/esm/storage/1_utilities.d.ts +0 -1
- package/esm/storage/1_utilities.js +2 -3
- package/esm/storage/2_storage_local_storage.js +1 -4
- package/esm/storage/2_storage_session_storage.js +1 -4
- package/esm/tl/3_utilities.js +5 -4
- package/esm/transport/2_transport_provider.js +4 -4
- package/esm/types/0_message_entity.js +3 -3
- package/esm/types/0_message_search_filter.js +2 -2
- package/esm/types/0_reaction.js +2 -2
- package/esm/types/1_bot_command_scope.js +3 -3
- package/esm/types/1_chat_p.js +3 -2
- package/esm/types/1_keyboard_button.js +3 -3
- package/esm/types/1_message_reaction.js +2 -2
- package/esm/types/1_story_privacy.js +3 -3
- package/esm/types/2_chat_member.js +6 -5
- package/esm/types/2_chosen_inline_result.js +3 -2
- package/esm/types/2_inactive_chat.js +3 -2
- package/esm/types/2_inline_keyboard_button.js +3 -3
- package/esm/types/2_inline_query.js +3 -3
- package/esm/types/2_invite_link.js +3 -2
- package/esm/types/2_story_content.js +5 -5
- package/esm/types/2_story_interactive_area.js +5 -5
- package/esm/types/3_chat_member_updated.js +4 -3
- package/esm/types/3_reply_markup.js +4 -3
- package/esm/types/3_story.js +3 -2
- package/esm/types/4_inline_query_result.js +5 -5
- package/esm/types/4_message.js +17 -16
- package/esm/types/5_callback_query.js +4 -3
- package/esm/types/5_chat.js +8 -7
- package/esm/types/_file_id.js +9 -8
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +25 -0
- package/esm/utilities/0_logger.d.ts +8 -0
- package/esm/utilities/0_logger.js +9 -5
- package/esm/utilities/1_math.d.ts +1 -0
- package/esm/utilities/1_math.js +51 -0
- package/esm/utilities/1_misc.js +2 -2
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -1
- package/script/0_deps.js +3 -3
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/4_errors.js +3 -3
- package/script/client/0_markdown.js +5 -5
- package/script/client/0_utilities.d.ts +6 -0
- package/script/client/0_utilities.js +41 -4
- package/script/client/1_account_manager.js +4 -4
- package/script/client/1_client_encrypted.js +2 -2
- package/script/client/1_client_plain.js +2 -2
- package/script/client/1_file_manager.js +5 -4
- package/script/client/1_reaction_manager.js +2 -2
- package/script/client/1_update_manager.js +8 -7
- package/script/client/2_message_manager.js +51 -28
- package/script/client/3_callback_query_manager.js +2 -0
- package/script/client/3_chat_list_manager.js +12 -11
- package/script/client/3_inline_query_manager.js +4 -2
- package/script/client/3_story_manager.js +4 -2
- package/script/client/4_client.js +13 -12
- package/script/connection/1_connection_web_socket.js +2 -1
- package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.d.ts +0 -1
- package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +1 -13
- package/script/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +310 -0
- package/script/mod.d.ts +1 -1
- package/script/mod.js +2 -1
- package/script/storage/0_storage.js +5 -4
- package/script/storage/1_utilities.d.ts +0 -1
- package/script/storage/1_utilities.js +3 -4
- package/script/storage/2_storage_local_storage.js +0 -3
- package/script/storage/2_storage_session_storage.js +0 -3
- package/script/tl/3_utilities.js +4 -3
- package/script/transport/2_transport_provider.js +4 -4
- package/script/types/0_message_entity.js +3 -3
- package/script/types/0_message_search_filter.js +2 -2
- package/script/types/0_reaction.js +2 -2
- package/script/types/1_bot_command_scope.js +3 -3
- package/script/types/1_chat_p.js +2 -1
- package/script/types/1_keyboard_button.js +3 -3
- package/script/types/1_message_reaction.js +2 -2
- package/script/types/1_story_privacy.js +3 -3
- package/script/types/2_chat_member.js +5 -4
- package/script/types/2_chosen_inline_result.js +2 -1
- package/script/types/2_inactive_chat.js +2 -1
- package/script/types/2_inline_keyboard_button.js +3 -3
- package/script/types/2_inline_query.js +3 -3
- package/script/types/2_invite_link.js +2 -1
- package/script/types/2_story_content.js +5 -5
- package/script/types/2_story_interactive_area.js +5 -5
- package/script/types/3_chat_member_updated.js +3 -2
- package/script/types/3_reply_markup.js +3 -2
- package/script/types/3_story.js +2 -1
- package/script/types/4_inline_query_result.js +5 -5
- package/script/types/4_message.js +16 -15
- package/script/types/5_callback_query.js +3 -2
- package/script/types/5_chat.js +7 -6
- package/script/types/_file_id.js +8 -7
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +27 -1
- package/script/utilities/0_logger.d.ts +8 -0
- package/script/utilities/0_logger.js +11 -6
- package/script/utilities/1_math.d.ts +1 -0
- package/script/utilities/1_math.js +55 -0
- package/script/utilities/1_misc.js +2 -2
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -324
- package/esm/utilities/0_control.d.ts +0 -1
- package/esm/utilities/0_control.js +0 -3
- package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -326
- package/script/utilities/0_control.d.ts +0 -1
- package/script/utilities/0_control.js +0 -7
- /package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
package/script/types/5_chat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.constructChat4 = exports.constructChat3 = exports.constructChat2 = exports.constructChat = exports.getChatOrder = void 0;
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
4
5
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
6
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
6
7
|
const _0_chat_photo_js_1 = require("./0_chat_photo.js");
|
|
@@ -21,7 +22,7 @@ function getChatPAlsoPhoto(entity) {
|
|
|
21
22
|
also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
(0,
|
|
25
|
+
(0, _0_deps_js_1.unreachable)();
|
|
25
26
|
}
|
|
26
27
|
let photo = undefined;
|
|
27
28
|
if (entity.photo instanceof _2_tl_js_1.types.UserProfilePhoto) {
|
|
@@ -43,7 +44,7 @@ exports.getChatOrder = getChatOrder;
|
|
|
43
44
|
async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage, getStickerSetName) {
|
|
44
45
|
const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id == dialog.top_message);
|
|
45
46
|
if (!topMessage_) {
|
|
46
|
-
(0,
|
|
47
|
+
(0, _0_deps_js_1.unreachable)();
|
|
47
48
|
}
|
|
48
49
|
const pinned = pinnedChats.indexOf((0, _2_tl_js_1.peerToChatId)(dialog.peer));
|
|
49
50
|
const lastMessage = await (0, _4_message_js_1.constructMessage)(topMessage_, getEntity, getMessage, getStickerSetName, false);
|
|
@@ -51,9 +52,9 @@ async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage
|
|
|
51
52
|
const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
|
|
52
53
|
const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
|
|
53
54
|
const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
|
|
54
|
-
const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof _2_tl_js_1.types.User && v.id == userId) : (0,
|
|
55
|
+
const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof _2_tl_js_1.types.User && v.id == userId) : (0, _0_deps_js_1.unreachable)();
|
|
55
56
|
if (!chat__) {
|
|
56
|
-
(0,
|
|
57
|
+
(0, _0_deps_js_1.unreachable)();
|
|
57
58
|
}
|
|
58
59
|
const chat_ = chat__;
|
|
59
60
|
const { chatP, also, photo } = getChatPAlsoPhoto(chat_);
|
|
@@ -70,7 +71,7 @@ async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage
|
|
|
70
71
|
return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo: photo, pinned });
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
(0,
|
|
74
|
+
(0, _0_deps_js_1.unreachable)();
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
exports.constructChat = constructChat;
|
|
@@ -91,7 +92,7 @@ function constructChat2(entity, pinned, lastMessage) {
|
|
|
91
92
|
return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo: photo, pinned });
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
94
|
-
(0,
|
|
95
|
+
(0, _0_deps_js_1.unreachable)();
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
exports.constructChat2 = constructChat2;
|
package/script/types/_file_id.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toUniqueFileId = exports.serializeFileId = exports.deserializeFileId = exports.PhotoSourceType = exports.FileType = void 0;
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
4
5
|
const _0_errors_js_1 = require("../0_errors.js");
|
|
5
6
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
6
7
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
@@ -125,7 +126,7 @@ function serializePhotoSource(photoSource, writer) {
|
|
|
125
126
|
writer.writeInt32(photoSource.version);
|
|
126
127
|
break;
|
|
127
128
|
default:
|
|
128
|
-
(0,
|
|
129
|
+
(0, _0_deps_js_1.unreachable)();
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
function getPhotoSourceCompareType(source) {
|
|
@@ -135,7 +136,7 @@ function getPhotoSourceCompareType(source) {
|
|
|
135
136
|
case PhotoSourceType.Thumbnail: {
|
|
136
137
|
const type = source.thumbnailType;
|
|
137
138
|
if (!(0 <= type && type <= 127)) {
|
|
138
|
-
(0,
|
|
139
|
+
(0, _0_deps_js_1.unreachable)();
|
|
139
140
|
}
|
|
140
141
|
if (type == "a".charCodeAt(0)) {
|
|
141
142
|
return 0;
|
|
@@ -161,7 +162,7 @@ function getPhotoSourceCompareType(source) {
|
|
|
161
162
|
default:
|
|
162
163
|
break;
|
|
163
164
|
}
|
|
164
|
-
(0,
|
|
165
|
+
(0, _0_deps_js_1.unreachable)();
|
|
165
166
|
}
|
|
166
167
|
function writePhotoSourceUniqueId(photoSource, writer) {
|
|
167
168
|
const compareType = getPhotoSourceCompareType(photoSource);
|
|
@@ -172,8 +173,8 @@ function writePhotoSourceUniqueId(photoSource, writer) {
|
|
|
172
173
|
if (compareType == 2) {
|
|
173
174
|
writer.write(new Uint8Array([0x02]));
|
|
174
175
|
}
|
|
175
|
-
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : (0,
|
|
176
|
-
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : (0,
|
|
176
|
+
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : (0, _0_deps_js_1.unreachable)());
|
|
177
|
+
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : (0, _0_deps_js_1.unreachable)());
|
|
177
178
|
}
|
|
178
179
|
function getFileTypeClass(fileType) {
|
|
179
180
|
switch (fileType) {
|
|
@@ -207,7 +208,7 @@ function getFileTypeClass(fileType) {
|
|
|
207
208
|
case FileType.None:
|
|
208
209
|
case FileType.Size:
|
|
209
210
|
default:
|
|
210
|
-
(0,
|
|
211
|
+
(0, _0_deps_js_1.unreachable)();
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
function isWeb(fileType) {
|
|
@@ -284,7 +285,7 @@ function toUniqueFileId(fileId) {
|
|
|
284
285
|
switch (fileId.location.source.type) {
|
|
285
286
|
case PhotoSourceType.Legacy:
|
|
286
287
|
case PhotoSourceType.StickerSetThumbnail:
|
|
287
|
-
(0,
|
|
288
|
+
(0, _0_deps_js_1.unreachable)();
|
|
288
289
|
/* falls through */
|
|
289
290
|
case PhotoSourceType.FullLegacy:
|
|
290
291
|
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
@@ -5,3 +5,4 @@ export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, s
|
|
|
5
5
|
export declare function getRandomBigInt(byteLength: number, little?: boolean, signed?: boolean): bigint;
|
|
6
6
|
/** Get a random ID. Useful when calling API functions directly. */
|
|
7
7
|
export declare function getRandomId(): bigint;
|
|
8
|
+
export declare function gcd(a: bigint, b: bigint): bigint;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getRandomId = exports.getRandomBigInt = exports.bigIntFromBuffer = exports.mod = exports.modExp = void 0;
|
|
26
|
+
exports.gcd = exports.getRandomId = exports.getRandomBigInt = exports.bigIntFromBuffer = exports.mod = exports.modExp = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
28
28
|
function modExp(a, b, n) {
|
|
29
29
|
a %= n;
|
|
@@ -72,3 +72,29 @@ function getRandomId() {
|
|
|
72
72
|
return getRandomBigInt(8, true, true);
|
|
73
73
|
}
|
|
74
74
|
exports.getRandomId = getRandomId;
|
|
75
|
+
function gcd(a, b) {
|
|
76
|
+
if (a == 0n) {
|
|
77
|
+
return b;
|
|
78
|
+
}
|
|
79
|
+
while ((a & 1n) == 0n) {
|
|
80
|
+
a >>= 1n;
|
|
81
|
+
}
|
|
82
|
+
while (true) {
|
|
83
|
+
if (a > b) {
|
|
84
|
+
a = (a - b) >> 1n;
|
|
85
|
+
while ((a & 1n) == 0n) {
|
|
86
|
+
a >>= 1n;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (b > a) {
|
|
90
|
+
b = (b - a) >> 1n;
|
|
91
|
+
while ((b & 1n) == 0n) {
|
|
92
|
+
b >>= 1n;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return a;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.gcd = gcd;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export declare function setLogVerbosity(verbosity_: number): void;
|
|
2
|
+
export interface LoggingProvider {
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
warn(...args: any[]): void;
|
|
5
|
+
info(...args: any[]): void;
|
|
6
|
+
debug(...args: any[]): void;
|
|
7
|
+
log(...args: any[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function setLoggingProvider(provider_: LoggingProvider): void;
|
|
2
10
|
export declare const ERROR = 1;
|
|
3
11
|
export declare const WARNING = 2;
|
|
4
12
|
export declare const INFO = 3;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getLogger = exports.OUT_BIN = exports.IN_BIN = exports.OUT = exports.IN = exports.TRACE = exports.DEBUG = exports.INFO = exports.WARNING = exports.ERROR = exports.setLogVerbosity = void 0;
|
|
26
|
+
exports.getLogger = exports.OUT_BIN = exports.IN_BIN = exports.OUT = exports.IN = exports.TRACE = exports.DEBUG = exports.INFO = exports.WARNING = exports.ERROR = exports.setLoggingProvider = exports.setLogVerbosity = void 0;
|
|
27
27
|
// deno-lint-ignore-file no-explicit-any
|
|
28
28
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
29
29
|
let verbosity = Number("LOG_VERBOSITY" in dntShim.dntGlobalThis ? dntShim.dntGlobalThis.LOG_VERBOSITY : "Deno" in dntShim.dntGlobalThis ? dntShim.dntGlobalThis.Deno.env.get("LOG_VERBOSITY") : "process" in dntShim.dntGlobalThis ? dntShim.dntGlobalThis.process.env.LOG : "") || 0;
|
|
@@ -31,6 +31,11 @@ function setLogVerbosity(verbosity_) {
|
|
|
31
31
|
verbosity = verbosity_;
|
|
32
32
|
}
|
|
33
33
|
exports.setLogVerbosity = setLogVerbosity;
|
|
34
|
+
let provider = console;
|
|
35
|
+
function setLoggingProvider(provider_) {
|
|
36
|
+
provider = provider_;
|
|
37
|
+
}
|
|
38
|
+
exports.setLoggingProvider = setLoggingProvider;
|
|
34
39
|
exports.ERROR = 1;
|
|
35
40
|
exports.WARNING = 2;
|
|
36
41
|
exports.INFO = 3;
|
|
@@ -97,19 +102,19 @@ function getLogger(scope) {
|
|
|
97
102
|
let fn;
|
|
98
103
|
switch (verbosity_) {
|
|
99
104
|
case exports.ERROR:
|
|
100
|
-
fn =
|
|
105
|
+
fn = provider.error;
|
|
101
106
|
break;
|
|
102
107
|
case exports.WARNING:
|
|
103
|
-
fn =
|
|
108
|
+
fn = provider.warn;
|
|
104
109
|
break;
|
|
105
110
|
case exports.INFO:
|
|
106
|
-
fn =
|
|
111
|
+
fn = provider.info;
|
|
107
112
|
break;
|
|
108
113
|
case exports.DEBUG:
|
|
109
|
-
fn =
|
|
114
|
+
fn = provider.debug;
|
|
110
115
|
break;
|
|
111
116
|
default:
|
|
112
|
-
fn =
|
|
117
|
+
fn = provider.log;
|
|
113
118
|
}
|
|
114
119
|
fn(`[${verbosity_} ${scope}]`, ...args);
|
|
115
120
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function factorize(pq: bigint): [bigint, bigint];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.factorize = void 0;
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
|
+
const _0_bigint_js_1 = require("./0_bigint.js");
|
|
6
|
+
function getRandomNumberInRange(min, max) {
|
|
7
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
8
|
+
}
|
|
9
|
+
function factorize(pq) {
|
|
10
|
+
let a;
|
|
11
|
+
let b;
|
|
12
|
+
let p = 0n;
|
|
13
|
+
let q;
|
|
14
|
+
const one = 1n;
|
|
15
|
+
let found = false;
|
|
16
|
+
for (let i = 0, iter = 0; !found && (i < 3 || iter < 1000); i++) {
|
|
17
|
+
const t = BigInt(getRandomNumberInRange(17, 32)) % (pq - 1n);
|
|
18
|
+
a = (0, _0_bigint_js_1.getRandomId)();
|
|
19
|
+
b = a;
|
|
20
|
+
const lim = 1 << (i + 23);
|
|
21
|
+
for (let j = 1; j < lim; j++) {
|
|
22
|
+
iter++;
|
|
23
|
+
a = (0, _0_bigint_js_1.mod)(a * a, pq);
|
|
24
|
+
a += t;
|
|
25
|
+
if (a >= pq) {
|
|
26
|
+
a = a - pq;
|
|
27
|
+
}
|
|
28
|
+
if (a > b) {
|
|
29
|
+
q = a - b;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
q = b - a;
|
|
33
|
+
}
|
|
34
|
+
p = (0, _0_bigint_js_1.gcd)(q, pq);
|
|
35
|
+
if (p != one) {
|
|
36
|
+
found = true;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if ((j & (j - 1)) == 0) {
|
|
40
|
+
b = a;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (found) {
|
|
45
|
+
q = pq / p;
|
|
46
|
+
if (p > q) {
|
|
47
|
+
return [q, p];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return [p, q];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
(0, _0_deps_js_1.unreachable)();
|
|
54
|
+
}
|
|
55
|
+
exports.factorize = factorize;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fromUnixTimestamp = exports.toUnixTimestamp = exports.VECTOR_CONSTRUCTOR = exports.ZERO_CHANNEL_ID = exports.mustPromptOneOf = exports.mustPromptNumber = exports.mustPrompt = exports.drop = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
5
|
function drop(promise) {
|
|
6
6
|
promise.catch(() => { });
|
|
7
7
|
}
|
|
@@ -9,7 +9,7 @@ exports.drop = drop;
|
|
|
9
9
|
function mustPrompt(message) {
|
|
10
10
|
const result = prompt(message);
|
|
11
11
|
if (result == null) {
|
|
12
|
-
throw (0,
|
|
12
|
+
throw (0, _0_deps_js_1.unreachable)();
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
return result;
|