UNPKG

telegram-mtproto

Version:
129 lines (110 loc) 7.53 kB
//@flow /* eslint-disable max-len */ /* import { type RawInput } from '../../src/task/index.h' */ import { toBuffer8 } from './fixtures' const { NetMessage, NetContainer } = require('../../src/service/networker/net-message') const mockNetMessage = (data, Construct = NetMessage) => { let msg if (Construct === NetMessage) //$FlowIssue msg = new Construct(data.uid, data.seq_no, data.body, data.type) else //$FlowIssue msg = new Construct(data.uid, data.seq_no, data.body, data.type, data.inner, data.innerAPI) //$FlowIssue Object.assign(msg, data) return msg } const uid = '45803d12-e871-4315-9620-b5af69656271' const message = mockNetMessage({ acked : false, container : true, notContentRelated: false, createNetworker : false, longPoll : false, type : 'container', uid, msg_id : '6451324639598852836', seq_no : 4, dc : 2, body : new Uint8Array([ 220, 248, 241, 115, 2, 0, 0, 0, 228, 224, 2, 64, 148, 181, 135, 89, 1, 0, 0, 0, 132, 0, 0, 0, 13, 13, 155, 218, 57, 0, 0, 0, 233, 109, 121, 105, 223, 193, 0, 0, 17, 85, 110, 107, 110, 111, 119, 110, 32, 85, 115, 101, 114, 65, 103, 101, 110, 116, 0, 0, 16, 85, 110, 107, 110, 111, 119, 110, 32, 80, 108, 97, 116, 102, 111, 114, 109, 0, 0, 0, 5, 49, 46, 48, 46, 49, 0, 0, 2, 101, 110, 0, 236, 240, 174, 134, 1, 0, 0, 0, 11, 43, 57, 57, 57, 54, 54, 50, 48, 48, 48, 48, 55, 151, 121, 188, 223, 193, 0, 0, 32, 102, 98, 48, 53, 48, 98, 56, 102, 54, 55, 55, 49, 101, 49, 53, 98, 102, 100, 97, 53, 100, 102, 50, 52, 48, 57, 57, 51, 49, 53, 54, 57, 0, 0, 0, 52, 232, 161, 64, 148, 181, 135, 89, 3, 0, 0, 0, 16, 0, 0, 0, 159, 53, 153, 146, 232, 3, 0, 0, 38, 2, 0, 0, 184, 11, 0, 0 ]), inner : ['6451324639565242596', '6451324639575664692'], innerAPI: ['76dea7e3-92f9-4932-9beb-8c1b9c9586f5', false] }, NetContainer) const threadState = new Map([ [ '6451324639565242596', mockNetMessage({ acked : false, container : false, notContentRelated: false, createNetworker : false, isAPI : true, longPoll : false, type : 'api', uid, msg_id : '6451324639565242596', seq_no : 1, dc : 2, noResponse : false, body : new Uint8Array([13, 13, 155, 218, 57, 0, 0, 0, 233, 109, 121, 105, 223, 193, 0, 0, 17, 85, 110, 107, 110, 111, 119, 110, 32, 85, 115, 101, 114, 65, 103, 101, 110, 116, 0, 0, 16, 85, 110, 107, 110, 111, 119, 110, 32, 80, 108, 97, 116, 102, 111, 114, 109, 0, 0, 0, 5, 49, 46, 48, 46, 49, 0, 0, 2, 101, 110, 0, 236, 240, 174, 134, 1, 0, 0, 0, 11, 43, 57, 57, 57, 54, 54, 50, 48, 48, 48, 48, 55, 151, 121, 188, 223, 193, 0, 0, 32, 102, 98, 48, 53, 48, 98, 56, 102, 54, 55, 55, 49, 101, 49, 53, 98, 102, 100, 97, 53, 100, 102, 50, 52, 48, 57, 57, 51, 49, 53, 54, 57, 0, 0, 0]), }) ], [ message.msg_id, message ] ]) const responseBuffer = toBuffer8([ 244, 102, 46, 77, 156, 70, 37, 27, 32, 132, 157, 95, 233, 195, 9, 116, 224, 40, 213, 84, 69, 226, 172, 15, 184, 49, 205, 11, 175, 154, 181, 97, 197, 207, 94, 220, 209, 30, 125, 183, 18, 67, 163, 108, 51, 89, 209, 7, 182, 228, 81, 61, 143, 102, 202, 44, 118, 98, 115, 222, 146, 130, 32, 180, 152, 33, 24, 245, 202, 61, 34, 136, 160, 30, 140, 117, 240, 102, 178, 118, 82, 69, 129, 55, 219, 114, 142, 189, 244, 146, 184, 183, 103, 156, 185, 105, 109, 173, 5, 150, 255, 162, 156, 122, 64, 93, 153, 33, 34, 209, 61, 60, 83, 191, 254, 128, 123, 153, 196, 162, 38, 73, 125, 64, 56, 251, 5, 72, 140, 204, 43, 153, 247, 59, 133, 75, 223, 28, 225, 168, 246, 73, 136, 68, 144, 48, 222, 234, 111, 167, 70, 48, 161, 75, 65, 154, 126, 75, 234, 32, 252, 145, 133, 86, 180, 127, 226, 56, 210, 65, 76, 62, 234, 121, 246, 146, 105, 254, 177, 230, 154, 77, 162, 73 ]) const authKeyUint8 = new Uint8Array([ 117, 128, 199, 78, 228, 57, 140, 41, 97, 249, 19, 44, 29, 235, 69, 94, 100, 59, 226, 116, 193, 206, 98, 170, 138, 201, 199, 66, 76, 164, 157, 241, 223, 172, 67, 231, 159, 106, 230, 237, 206, 245, 128, 179, 31, 199, 174, 58, 197, 183, 74, 10, 113, 163, 37, 200, 160, 126, 119, 140, 88, 32, 243, 26, 109, 25, 102, 114, 212, 32, 83, 77, 243, 39, 112, 11, 3, 34, 249, 158, 169, 109, 134, 242, 186, 19, 174, 176, 185, 236, 164, 84, 147, 69, 162, 8, 238, 88, 24, 152, 246, 83, 127, 175, 37, 104, 57, 34, 66, 196, 2, 101, 86, 99, 151, 15, 114, 230, 173, 225, 233, 237, 219, 33, 188, 224, 151, 84, 184, 209, 210, 10, 127, 212, 195, 0, 131, 213, 85, 100, 12, 255, 110, 56, 234, 187, 76, 139, 166, 190, 92, 120, 41, 116, 211, 235, 52, 117, 63, 78, 91, 94, 7, 55, 5, 90, 131, 55, 94, 194, 111, 246, 203, 221, 51, 79, 43, 3, 120, 163, 50, 191, 249, 68, 255, 30, 232, 190, 7, 77, 28, 44, 151, 250, 78, 168, 209, 33, 39, 230, 93, 132, 32, 239, 189, 90, 180, 106, 5, 152, 12, 165, 90, 76, 94, 45, 137, 57, 194, 140, 52, 211, 183, 66, 242, 200, 10, 91, 146, 211, 230, 227, 79, 232, 32, 102, 199, 167, 108, 250, 164, 197, 27, 245, 95, 90, 48, 232, 181, 255, 6, 80, 64, 172, 7, 66 ]) export const sessionID = [104, 253, 6, 5, 166, 213, 190, 141] export const getMsgById = ({ req_msg_id }: { req_msg_id: string }) => threadState.get(req_msg_id) const fullConfig = { responseBuffer, uid, authKeyID : [244, 102, 46, 77, 156, 70, 37, 27], authKeyUint8, thisSessionID: sessionID, prevSessionID: void 0, getMsgById, } export const rawData = { noResponseMsgs: [], message, result : { status : 200, statusText: 'OK', data : responseBuffer } } export const authKey = [ 117, 128, 199, 78, 228, 57, 140, 41, 97, 249, 19, 44, 29, 235, 69, 94, 100, 59, 226, 116, 193, 206, 98, 170, 138, 201, 199, 66, 76, 164, 157, 241, 223, 172, 67, 231, 159, 106, 230, 237, 206, 245, 128, 179, 31, 199, 174, 58, 197, 183, 74, 10, 113, 163, 37, 200, 160, 126, 119, 140, 88, 32, 243, 26, 109, 25, 102, 114, 212, 32, 83, 77, 243, 39, 112, 11, 3, 34, 249, 158, 169, 109, 134, 242, 186, 19, 174, 176, 185, 236, 164, 84, 147, 69, 162, 8, 238, 88, 24, 152, 246, 83, 127, 175, 37, 104, 57, 34, 66, 196, 2, 101, 86, 99, 151, 15, 114, 230, 173, 225, 233, 237, 219, 33, 188, 224, 151, 84, 184, 209, 210, 10, 127, 212, 195, 0, 131, 213, 85, 100, 12, 255, 110, 56, 234, 187, 76, 139, 166, 190, 92, 120, 41, 116, 211, 235, 52, 117, 63, 78, 91, 94, 7, 55, 5, 90, 131, 55, 94, 194, 111, 246, 203, 221, 51, 79, 43, 3, 120, 163, 50, 191, 249, 68, 255, 30, 232, 190, 7, 77, 28, 44, 151, 250, 78, 168, 209, 33, 39, 230, 93, 132, 32, 239, 189, 90, 180, 106, 5, 152, 12, 165, 90, 76, 94, 45, 137, 57, 194, 140, 52, 211, 183, 66, 242, 200, 10, 91, 146, 211, 230, 227, 79, 232, 32, 102, 199, 167, 108, 250, 164, 197, 27, 245, 95, 90, 48, 232, 181, 255, 6, 80, 64, 172, 7, 66 ] export const serverSalt = [131, 212, 20, 140, 103, 98, 135, 139] const authKeyHex = '7580c74ee4398c2961f9132c1deb455e643be274c1ce62aa8ac9c7424ca49df1dfac43e79f6ae6edcef580b31fc7ae3ac5b74a0a71a325c8a07e778c5820f31a6d196672d420534df327700b0322f99ea96d86f2ba13aeb0b9eca4549345a208ee581898f6537faf2568392242c402655663970f72e6ade1e9eddb21bce09754b8d1d20a7fd4c30083d555640cff6e38eabb4c8ba6be5c782974d3eb34753f4e5b5e0737055a83375ec26ff6cbdd334f2b0378a332bff944ff1ee8be074d1c2c97fa4ea8d12127e65d8420efbd5ab46a05980ca55a4c5e2d8939c28c34d3b742f2c80a5b92d3e6e34fe82066c7a76cfaa4c51bf55f5a30e8b5ff065040ac0742' const serverSaltHex = '83d4148c6762878b' export default fullConfig