nodejs-insta-private-api-mqtt 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/README.md +1650 -0
- package/dist/constants/constants.js +280 -0
- package/dist/constants/index.js +41 -0
- package/dist/core/client.js +243 -0
- package/dist/core/repository.js +7 -0
- package/dist/core/request.js +212 -0
- package/dist/core/state.js +1456 -0
- package/dist/core/utils.js +786 -0
- package/dist/downloadMedia.js +381 -0
- package/dist/errors/index.d.ts +16 -0
- package/dist/errors/index.js +30 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/fbns/fbns.client.d.ts +32 -0
- package/dist/fbns/fbns.client.events.d.ts +41 -0
- package/dist/fbns/fbns.client.events.js +3 -0
- package/dist/fbns/fbns.client.events.js.map +1 -0
- package/dist/fbns/fbns.client.js +179 -0
- package/dist/fbns/fbns.client.js.map +1 -0
- package/dist/fbns/fbns.device-auth.d.ts +17 -0
- package/dist/fbns/fbns.device-auth.js +54 -0
- package/dist/fbns/fbns.device-auth.js.map +1 -0
- package/dist/fbns/fbns.types.d.ts +83 -0
- package/dist/fbns/fbns.types.js +3 -0
- package/dist/fbns/fbns.types.js.map +1 -0
- package/dist/fbns/fbns.utilities.d.ts +2 -0
- package/dist/fbns/fbns.utilities.js +79 -0
- package/dist/fbns/fbns.utilities.js.map +1 -0
- package/dist/fbns/index.d.ts +4 -0
- package/dist/fbns/index.js +21 -0
- package/dist/fbns/index.js.map +1 -0
- package/dist/index.js +39 -0
- package/dist/mqttot/index.d.ts +4 -0
- package/dist/mqttot/index.js +21 -0
- package/dist/mqttot/index.js.map +1 -0
- package/dist/mqttot/mqttot.client.d.ts +39 -0
- package/dist/mqttot/mqttot.client.js +120 -0
- package/dist/mqttot/mqttot.client.js.map +1 -0
- package/dist/mqttot/mqttot.connect.request.packet.d.ts +7 -0
- package/dist/mqttot/mqttot.connect.request.packet.js +9 -0
- package/dist/mqttot/mqttot.connect.request.packet.js.map +1 -0
- package/dist/mqttot/mqttot.connect.response.packet.d.ts +7 -0
- package/dist/mqttot/mqttot.connect.response.packet.js +24 -0
- package/dist/mqttot/mqttot.connect.response.packet.js.map +1 -0
- package/dist/mqttot/mqttot.connection.d.ts +57 -0
- package/dist/mqttot/mqttot.connection.js +56 -0
- package/dist/mqttot/mqttot.connection.js.map +1 -0
- package/dist/package.json +59 -0
- package/dist/realtime/commands/commands.d.ts +15 -0
- package/dist/realtime/commands/commands.js +21 -0
- package/dist/realtime/commands/commands.js.map +1 -0
- package/dist/realtime/commands/direct.commands.d.ts +75 -0
- package/dist/realtime/commands/direct.commands.js +186 -0
- package/dist/realtime/commands/direct.commands.js.map +1 -0
- package/dist/realtime/commands/enhanced.direct.commands.js +987 -0
- package/dist/realtime/commands/index.d.ts +2 -0
- package/dist/realtime/commands/index.js +19 -0
- package/dist/realtime/commands/index.js.map +1 -0
- package/dist/realtime/delta-sync.manager.js +293 -0
- package/dist/realtime/features/dm-sender.js +88 -0
- package/dist/realtime/features/error-handler.js +73 -0
- package/dist/realtime/features/gap-handler.js +61 -0
- package/dist/realtime/features/presence.manager.js +66 -0
- package/dist/realtime/index.js +30 -0
- package/dist/realtime/messages/app-presence.event.d.ts +9 -0
- package/dist/realtime/messages/app-presence.event.js +3 -0
- package/dist/realtime/messages/app-presence.event.js.map +1 -0
- package/dist/realtime/messages/index.d.ts +3 -0
- package/dist/realtime/messages/index.js +20 -0
- package/dist/realtime/messages/index.js.map +1 -0
- package/dist/realtime/messages/message-sync.message.d.ts +222 -0
- package/dist/realtime/messages/message-sync.message.js +43 -0
- package/dist/realtime/messages/message-sync.message.js.map +1 -0
- package/dist/realtime/messages/realtime-sub.direct.data.d.ts +11 -0
- package/dist/realtime/messages/realtime-sub.direct.data.js +3 -0
- package/dist/realtime/messages/realtime-sub.direct.data.js.map +1 -0
- package/dist/realtime/messages/thread-update.message.d.ts +68 -0
- package/dist/realtime/messages/thread-update.message.js +3 -0
- package/dist/realtime/messages/thread-update.message.js.map +1 -0
- package/dist/realtime/mixins/index.d.ts +3 -0
- package/dist/realtime/mixins/index.js +20 -0
- package/dist/realtime/mixins/index.js.map +1 -0
- package/dist/realtime/mixins/message-sync.mixin.d.ts +8 -0
- package/dist/realtime/mixins/message-sync.mixin.js +381 -0
- package/dist/realtime/mixins/message-sync.mixin.js.map +1 -0
- package/dist/realtime/mixins/mixin.d.ts +19 -0
- package/dist/realtime/mixins/mixin.js +41 -0
- package/dist/realtime/mixins/mixin.js.map +1 -0
- package/dist/realtime/mixins/presence-typing.mixin.js +33 -0
- package/dist/realtime/mixins/realtime-sub.mixin.d.ts +8 -0
- package/dist/realtime/mixins/realtime-sub.mixin.js +55 -0
- package/dist/realtime/mixins/realtime-sub.mixin.js.map +1 -0
- package/dist/realtime/parsers/graphql-parser.js +43 -0
- package/dist/realtime/parsers/graphql.parser.d.ts +15 -0
- package/dist/realtime/parsers/graphql.parser.js +22 -0
- package/dist/realtime/parsers/graphql.parser.js.map +1 -0
- package/dist/realtime/parsers/index.d.ts +6 -0
- package/dist/realtime/parsers/index.js +23 -0
- package/dist/realtime/parsers/index.js.map +1 -0
- package/dist/realtime/parsers/iris-parser.js +43 -0
- package/dist/realtime/parsers/iris.parser.d.ts +17 -0
- package/dist/realtime/parsers/iris.parser.js +10 -0
- package/dist/realtime/parsers/iris.parser.js.map +1 -0
- package/dist/realtime/parsers/json-parser.js +43 -0
- package/dist/realtime/parsers/json.parser.d.ts +6 -0
- package/dist/realtime/parsers/json.parser.js +10 -0
- package/dist/realtime/parsers/json.parser.js.map +1 -0
- package/dist/realtime/parsers/parser.d.ts +9 -0
- package/dist/realtime/parsers/parser.js +3 -0
- package/dist/realtime/parsers/parser.js.map +1 -0
- package/dist/realtime/parsers/region-hint-parser.js +43 -0
- package/dist/realtime/parsers/region-hint.parser.d.ts +12 -0
- package/dist/realtime/parsers/region-hint.parser.js +15 -0
- package/dist/realtime/parsers/region-hint.parser.js.map +1 -0
- package/dist/realtime/parsers/skywalker-parser.js +43 -0
- package/dist/realtime/parsers/skywalker.parser.d.ts +12 -0
- package/dist/realtime/parsers/skywalker.parser.js +15 -0
- package/dist/realtime/parsers/skywalker.parser.js.map +1 -0
- package/dist/realtime/parsers-advanced.js +158 -0
- package/dist/realtime/proto/common.proto +38 -0
- package/dist/realtime/proto/direct.proto +65 -0
- package/dist/realtime/proto/ig-messages.proto +83 -0
- package/dist/realtime/proto/iris.proto +188 -0
- package/dist/realtime/proto-parser.js +195 -0
- package/dist/realtime/protocols/iris.handshake.js +74 -0
- package/dist/realtime/protocols/proto-definitions.js +80 -0
- package/dist/realtime/protocols/skywalker.protocol.js +91 -0
- package/dist/realtime/realtime.client.events.js +3 -0
- package/dist/realtime/realtime.client.js +449 -0
- package/dist/realtime/realtime.service.js +462 -0
- package/dist/realtime/reconnect.manager.js +94 -0
- package/dist/realtime/session.manager.js +121 -0
- package/dist/realtime/subscriptions/graphql.subscription.d.ts +47 -0
- package/dist/realtime/subscriptions/graphql.subscription.js +99 -0
- package/dist/realtime/subscriptions/graphql.subscription.js.map +1 -0
- package/dist/realtime/subscriptions/index.d.ts +2 -0
- package/dist/realtime/subscriptions/index.js +19 -0
- package/dist/realtime/subscriptions/index.js.map +1 -0
- package/dist/realtime/subscriptions/skywalker.subscription.d.ts +4 -0
- package/dist/realtime/subscriptions/skywalker.subscription.js +13 -0
- package/dist/realtime/subscriptions/skywalker.subscription.js.map +1 -0
- package/dist/realtime/topic-map.js +71 -0
- package/dist/realtime/topic.js +80 -0
- package/dist/repositories/account.repository.js +261 -0
- package/dist/repositories/direct-thread.repository.js +247 -0
- package/dist/repositories/direct.repository.js +153 -0
- package/dist/repositories/feed.repository.js +233 -0
- package/dist/repositories/friendship.repository.js +190 -0
- package/dist/repositories/hashtag.repository.js +101 -0
- package/dist/repositories/highlights.repository.js +127 -0
- package/dist/repositories/location.repository.js +84 -0
- package/dist/repositories/media.repository.js +165 -0
- package/dist/repositories/story.repository.js +156 -0
- package/dist/repositories/upload.repository.js +167 -0
- package/dist/repositories/user.repository.js +94 -0
- package/dist/sendmedia/index.js +11 -0
- package/dist/sendmedia/sendFile.js +154 -0
- package/dist/sendmedia/sendPhoto.js +145 -0
- package/dist/sendmedia/uploadPhoto.js +175 -0
- package/dist/sendmedia/uploadfFile.js +264 -0
- package/dist/services/live.service.js +147 -0
- package/dist/services/search.service.js +116 -0
- package/dist/shared/index.js +35 -0
- package/dist/shared/shared.js +86 -0
- package/dist/thrift/index.d.ts +3 -0
- package/dist/thrift/index.js +20 -0
- package/dist/thrift/index.js.map +1 -0
- package/dist/thrift/thrift.d.ts +59 -0
- package/dist/thrift/thrift.js +101 -0
- package/dist/thrift/thrift.js.map +1 -0
- package/dist/thrift/thrift.reading.d.ts +41 -0
- package/dist/thrift/thrift.reading.js +327 -0
- package/dist/thrift/thrift.reading.js.map +1 -0
- package/dist/thrift/thrift.writing.d.ts +44 -0
- package/dist/thrift/thrift.writing.js +342 -0
- package/dist/thrift/thrift.writing.js.map +1 -0
- package/dist/types/index.js +285 -0
- package/dist/useMultiFileAuthState.js +437 -0
- package/dist/utils/helper-1.js +1 -0
- package/dist/utils/helper-10.js +1 -0
- package/dist/utils/helper-11.js +1 -0
- package/dist/utils/helper-12.js +1 -0
- package/dist/utils/helper-13.js +1 -0
- package/dist/utils/helper-14.js +1 -0
- package/dist/utils/helper-15.js +1 -0
- package/dist/utils/helper-16.js +1 -0
- package/dist/utils/helper-17.js +1 -0
- package/dist/utils/helper-18.js +1 -0
- package/dist/utils/helper-19.js +1 -0
- package/dist/utils/helper-2.js +1 -0
- package/dist/utils/helper-20.js +1 -0
- package/dist/utils/helper-21.js +1 -0
- package/dist/utils/helper-22.js +1 -0
- package/dist/utils/helper-23.js +1 -0
- package/dist/utils/helper-24.js +1 -0
- package/dist/utils/helper-25.js +1 -0
- package/dist/utils/helper-26.js +1 -0
- package/dist/utils/helper-27.js +1 -0
- package/dist/utils/helper-28.js +1 -0
- package/dist/utils/helper-29.js +1 -0
- package/dist/utils/helper-3.js +1 -0
- package/dist/utils/helper-30.js +1 -0
- package/dist/utils/helper-4.js +1 -0
- package/dist/utils/helper-5.js +1 -0
- package/dist/utils/helper-6.js +1 -0
- package/dist/utils/helper-7.js +1 -0
- package/dist/utils/helper-8.js +1 -0
- package/dist/utils/helper-9.js +1 -0
- package/dist/utils/index.js +280 -0
- package/examples/listen-to-messages.js +86 -0
- package/package.json +79 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./graphql.parser"), exports);
|
|
18
|
+
__exportStar(require("./iris.parser"), exports);
|
|
19
|
+
__exportStar(require("./json.parser"), exports);
|
|
20
|
+
__exportStar(require("./parser"), exports);
|
|
21
|
+
__exportStar(require("./region-hint.parser"), exports);
|
|
22
|
+
__exportStar(require("./skywalker.parser"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/realtime/parsers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B;AAC9B,gDAA8B;AAC9B,2CAAyB;AACzB,uDAAqC;AACrC,qDAAmC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iris Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses Iris messages from Instagram's realtime system.
|
|
5
|
+
* Iris is Instagram's internal messaging system for real-time updates.
|
|
6
|
+
*/
|
|
7
|
+
class IrisParser {
|
|
8
|
+
/**
|
|
9
|
+
* Parse an Iris message
|
|
10
|
+
* @param {Buffer|string} data - The raw message data
|
|
11
|
+
* @returns {Object} Parsed Iris data
|
|
12
|
+
*/
|
|
13
|
+
parse(data) {
|
|
14
|
+
try {
|
|
15
|
+
const message = Buffer.isBuffer(data) ? data.toString() : data;
|
|
16
|
+
|
|
17
|
+
// Try to parse as JSON first
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(message);
|
|
20
|
+
return {
|
|
21
|
+
type: 'iris',
|
|
22
|
+
data: parsed,
|
|
23
|
+
raw: message
|
|
24
|
+
};
|
|
25
|
+
} catch (jsonError) {
|
|
26
|
+
// If not JSON, treat as plain text
|
|
27
|
+
return {
|
|
28
|
+
type: 'iris',
|
|
29
|
+
data: { message: message },
|
|
30
|
+
raw: message
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'iris',
|
|
36
|
+
data: { error: error.message },
|
|
37
|
+
raw: data.toString()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = IrisParser;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParsedMessage, Parser } from './parser';
|
|
3
|
+
import { Topic } from '../../topic';
|
|
4
|
+
export declare class IrisParser implements Parser<IrisParserData> {
|
|
5
|
+
parseMessage(topic: Topic, payload: Buffer): ParsedMessage<IrisParserData>[];
|
|
6
|
+
}
|
|
7
|
+
export interface IrisParserData {
|
|
8
|
+
event: 'patch' | string;
|
|
9
|
+
data?: any[];
|
|
10
|
+
message_type: number;
|
|
11
|
+
seq_id: number;
|
|
12
|
+
mutation_token: null | string;
|
|
13
|
+
realtime: boolean;
|
|
14
|
+
op?: 'add' | 'replace' | string;
|
|
15
|
+
path?: string;
|
|
16
|
+
sampled?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IrisParser = void 0;
|
|
4
|
+
class IrisParser {
|
|
5
|
+
parseMessage(topic, payload) {
|
|
6
|
+
return JSON.parse(payload.toString('utf8')).map((x) => ({ topic, data: x }));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.IrisParser = IrisParser;
|
|
10
|
+
//# sourceMappingURL=iris.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iris.parser.js","sourceRoot":"","sources":["../../../src/realtime/parsers/iris.parser.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IACb,YAAY,CAAC,KAAY,EAAE,OAAe;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChG,CAAC;CACH;AAJD,gCAIC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses JSON messages from Instagram's realtime system.
|
|
5
|
+
* This is a general-purpose parser for JSON-formatted messages.
|
|
6
|
+
*/
|
|
7
|
+
class JsonParser {
|
|
8
|
+
/**
|
|
9
|
+
* Parse a JSON message
|
|
10
|
+
* @param {Buffer|string} data - The raw message data
|
|
11
|
+
* @returns {Object} Parsed JSON data
|
|
12
|
+
*/
|
|
13
|
+
parse(data) {
|
|
14
|
+
try {
|
|
15
|
+
const message = Buffer.isBuffer(data) ? data.toString() : data;
|
|
16
|
+
|
|
17
|
+
// Try to parse as JSON
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(message);
|
|
20
|
+
return {
|
|
21
|
+
type: 'json',
|
|
22
|
+
data: parsed,
|
|
23
|
+
raw: message
|
|
24
|
+
};
|
|
25
|
+
} catch (jsonError) {
|
|
26
|
+
// If not valid JSON, return as plain text
|
|
27
|
+
return {
|
|
28
|
+
type: 'json',
|
|
29
|
+
data: { text: message },
|
|
30
|
+
raw: message
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'json',
|
|
36
|
+
data: { error: error.message },
|
|
37
|
+
raw: data.toString()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = JsonParser;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonParser = void 0;
|
|
4
|
+
class JsonParser {
|
|
5
|
+
parseMessage(topic, payload) {
|
|
6
|
+
return { topic, data: payload.length > 0 ? JSON.parse(payload.toString()) : {} };
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.JsonParser = JsonParser;
|
|
10
|
+
//# sourceMappingURL=json.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.parser.js","sourceRoot":"","sources":["../../../src/realtime/parsers/json.parser.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IACb,YAAY,CAAC,KAAY,EAAE,OAAe;QAC9C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpF,CAAC;CACH;AAJD,gCAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/realtime/parsers/parser.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Region Hint Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses region hint messages from Instagram's realtime system.
|
|
5
|
+
* These messages contain information about the user's region/location.
|
|
6
|
+
*/
|
|
7
|
+
class RegionHintParser {
|
|
8
|
+
/**
|
|
9
|
+
* Parse a region hint message
|
|
10
|
+
* @param {Buffer|string} data - The raw message data
|
|
11
|
+
* @returns {Object} Parsed region hint data
|
|
12
|
+
*/
|
|
13
|
+
parse(data) {
|
|
14
|
+
try {
|
|
15
|
+
const message = Buffer.isBuffer(data) ? data.toString() : data;
|
|
16
|
+
|
|
17
|
+
// Try to parse as JSON first
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(message);
|
|
20
|
+
return {
|
|
21
|
+
type: 'region_hint',
|
|
22
|
+
data: parsed,
|
|
23
|
+
raw: message
|
|
24
|
+
};
|
|
25
|
+
} catch (jsonError) {
|
|
26
|
+
// If not JSON, treat as plain text
|
|
27
|
+
return {
|
|
28
|
+
type: 'region_hint',
|
|
29
|
+
data: { hint: message },
|
|
30
|
+
raw: message
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'region_hint',
|
|
36
|
+
data: { error: error.message },
|
|
37
|
+
raw: data.toString()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = RegionHintParser;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParsedMessage, Parser } from './parser';
|
|
3
|
+
import { Topic } from '../../topic';
|
|
4
|
+
import { ThriftToObjectResult } from '../../thrift';
|
|
5
|
+
export declare class RegionHintParser implements Parser<ThriftToObjectResult<{
|
|
6
|
+
hint: string;
|
|
7
|
+
}>> {
|
|
8
|
+
static descriptors: import("../../thrift").ThriftPacketDescriptor[];
|
|
9
|
+
parseMessage: (topic: Topic, payload: Buffer) => ParsedMessage<ThriftToObjectResult<{
|
|
10
|
+
hint: string;
|
|
11
|
+
}>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegionHintParser = void 0;
|
|
4
|
+
const thrift_1 = require("../../thrift");
|
|
5
|
+
class RegionHintParser {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.parseMessage = (topic, payload) => ({
|
|
8
|
+
topic,
|
|
9
|
+
data: (0, thrift_1.thriftReadToObject)(payload, RegionHintParser.descriptors),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.RegionHintParser = RegionHintParser;
|
|
14
|
+
RegionHintParser.descriptors = [thrift_1.ThriftDescriptors.binary('hint', 1)];
|
|
15
|
+
//# sourceMappingURL=region-hint.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"region-hint.parser.js","sourceRoot":"","sources":["../../../src/realtime/parsers/region-hint.parser.ts"],"names":[],"mappings":";;;AAEA,yCAA2F;AAE3F,MAAa,gBAAgB;IAA7B;QAGU,iBAAY,GAAG,CAAC,KAAY,EAAE,OAAe,EAAyD,EAAE,CAAC,CAAC;YAC9G,KAAK;YACL,IAAI,EAAE,IAAA,2BAAkB,EAAC,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC;SACjE,CAAC,CAAC;IACN,CAAC;;AAPD,4CAOC;AANgB,4BAAW,GAAG,CAAC,0BAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,AAAxC,CAAyC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skywalker Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses Skywalker messages from Instagram's realtime system.
|
|
5
|
+
* Skywalker is Instagram's pub/sub system for real-time updates.
|
|
6
|
+
*/
|
|
7
|
+
class SkywalkerParser {
|
|
8
|
+
/**
|
|
9
|
+
* Parse a Skywalker message
|
|
10
|
+
* @param {Buffer|string} data - The raw message data
|
|
11
|
+
* @returns {Object} Parsed Skywalker data
|
|
12
|
+
*/
|
|
13
|
+
parse(data) {
|
|
14
|
+
try {
|
|
15
|
+
const message = Buffer.isBuffer(data) ? data.toString() : data;
|
|
16
|
+
|
|
17
|
+
// Try to parse as JSON first
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(message);
|
|
20
|
+
return {
|
|
21
|
+
type: 'skywalker',
|
|
22
|
+
data: parsed,
|
|
23
|
+
raw: message
|
|
24
|
+
};
|
|
25
|
+
} catch (jsonError) {
|
|
26
|
+
// If not JSON, treat as plain text
|
|
27
|
+
return {
|
|
28
|
+
type: 'skywalker',
|
|
29
|
+
data: { message: message },
|
|
30
|
+
raw: message
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'skywalker',
|
|
36
|
+
data: { error: error.message },
|
|
37
|
+
raw: data.toString()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = SkywalkerParser;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParsedMessage, Parser } from './parser';
|
|
3
|
+
import { Topic } from '../../topic';
|
|
4
|
+
import { ThriftToObjectResult } from '../../thrift';
|
|
5
|
+
export declare class SkywalkerParser implements Parser<ThriftToObjectResult<SkywalkerResult>> {
|
|
6
|
+
static descriptors: import("../../thrift").ThriftPacketDescriptor[];
|
|
7
|
+
parseMessage(topic: Topic, payload: Buffer): ParsedMessage<ThriftToObjectResult<SkywalkerResult>>;
|
|
8
|
+
}
|
|
9
|
+
export interface SkywalkerResult {
|
|
10
|
+
topic: number;
|
|
11
|
+
payload: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkywalkerParser = void 0;
|
|
4
|
+
const thrift_1 = require("../../thrift");
|
|
5
|
+
class SkywalkerParser {
|
|
6
|
+
parseMessage(topic, payload) {
|
|
7
|
+
return {
|
|
8
|
+
topic,
|
|
9
|
+
data: (0, thrift_1.thriftReadToObject)(payload, SkywalkerParser.descriptors),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SkywalkerParser = SkywalkerParser;
|
|
14
|
+
SkywalkerParser.descriptors = [thrift_1.ThriftDescriptors.int32('topic', 1), thrift_1.ThriftDescriptors.binary('payload', 2)];
|
|
15
|
+
//# sourceMappingURL=skywalker.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skywalker.parser.js","sourceRoot":"","sources":["../../../src/realtime/parsers/skywalker.parser.ts"],"names":[],"mappings":";;;AAEA,yCAA2F;AAE3F,MAAa,eAAe;IAGlB,YAAY,CAAC,KAAY,EAAE,OAAe;QAC9C,OAAO;YACJ,KAAK;YACL,IAAI,EAAE,IAAA,2BAAkB,EAAC,OAAO,EAAE,eAAe,CAAC,WAAW,CAAC;SAChE,CAAC;IACL,CAAC;;AARJ,0CASC;AARgB,2BAAW,GAAG,CAAC,0BAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,0BAAiB,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const debug = require('debug')('ig:parsers');
|
|
2
|
+
const ProtoParser = require('./proto-parser');
|
|
3
|
+
|
|
4
|
+
const protoParser = new ProtoParser();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Advanced Topic-Specific Parsers
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Parse Iris (Direct Messages)
|
|
11
|
+
function parseIris(topicId, payload) {
|
|
12
|
+
const result = protoParser.decode(topicId, payload);
|
|
13
|
+
|
|
14
|
+
if (result.success && result.messages) {
|
|
15
|
+
return {
|
|
16
|
+
type: 'iris',
|
|
17
|
+
messages: result.messages.filter(m => m.type === 'message' || !m.type),
|
|
18
|
+
threads: result.messages.filter(m => m.type === 'thread').map(m => m.thread),
|
|
19
|
+
typing: result.messages.filter(m => m.type === 'typing').map(m => m.typing)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return { type: 'iris', error: result.error, raw: result.raw };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Parse GraphQL (Presence, Typing)
|
|
27
|
+
function parseGraphQL(topicId, payload) {
|
|
28
|
+
const result = protoParser.decode(topicId, payload);
|
|
29
|
+
|
|
30
|
+
if (result.success) {
|
|
31
|
+
return {
|
|
32
|
+
type: 'graphql',
|
|
33
|
+
data: result.decoded,
|
|
34
|
+
messages: result.messages
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return { type: 'graphql', error: result.error };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Parse Delta (Sync updates)
|
|
42
|
+
function parseDelta(topicId, payload) {
|
|
43
|
+
const result = protoParser.decode(topicId, payload);
|
|
44
|
+
|
|
45
|
+
if (result.success && result.decoded) {
|
|
46
|
+
return {
|
|
47
|
+
type: 'delta',
|
|
48
|
+
seqId: result.decoded.seq_id,
|
|
49
|
+
action: result.decoded.action,
|
|
50
|
+
items: result.messages,
|
|
51
|
+
metadata: result.decoded.metadata
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return { type: 'delta', error: result.error };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Parse Presence
|
|
59
|
+
function parsePresence(topicId, payload) {
|
|
60
|
+
const result = protoParser.decode(topicId, payload);
|
|
61
|
+
|
|
62
|
+
if (result.success) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'presence',
|
|
65
|
+
items: result.messages.map(m => ({
|
|
66
|
+
userId: m.id,
|
|
67
|
+
status: m.typing?.state || 'unknown',
|
|
68
|
+
timestamp: m.timestamp
|
|
69
|
+
}))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { type: 'presence', error: result.error };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Parse Feed
|
|
77
|
+
function parseFeed(topicId, payload) {
|
|
78
|
+
const result = protoParser.decode(topicId, payload);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
type: 'feed',
|
|
82
|
+
decoded: result.decoded,
|
|
83
|
+
items: result.messages,
|
|
84
|
+
error: result.error
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Parse Live
|
|
89
|
+
function parseLive(topicId, payload) {
|
|
90
|
+
const result = protoParser.decode(topicId, payload);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
type: 'live',
|
|
94
|
+
decoded: result.decoded,
|
|
95
|
+
items: result.messages,
|
|
96
|
+
error: result.error
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Parse Region Hint
|
|
101
|
+
function parseRegionHint(topicId, payload) {
|
|
102
|
+
try {
|
|
103
|
+
const text = payload.toString('utf-8');
|
|
104
|
+
const hint = JSON.parse(text);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
type: 'region-hint',
|
|
108
|
+
region: hint.region,
|
|
109
|
+
endpoint: hint.endpoint,
|
|
110
|
+
data: hint
|
|
111
|
+
};
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return {
|
|
114
|
+
type: 'region-hint',
|
|
115
|
+
raw: payload.toString('utf-8', 0, 200),
|
|
116
|
+
error: e.message
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Unified router
|
|
122
|
+
const PARSERS = {
|
|
123
|
+
iris: parseIris,
|
|
124
|
+
graphql: parseGraphQL,
|
|
125
|
+
delta: parseDelta,
|
|
126
|
+
presence: parsePresence,
|
|
127
|
+
feed: parseFeed,
|
|
128
|
+
live: parseLive,
|
|
129
|
+
'region-hint': parseRegionHint
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
function parseByType(topicType, topicId, payload) {
|
|
133
|
+
const parser = PARSERS[topicType];
|
|
134
|
+
|
|
135
|
+
if (!parser) {
|
|
136
|
+
debug(`⚠️ Unknown topic type: ${topicType}`);
|
|
137
|
+
return { type: topicType, error: 'Unknown parser', raw: payload.toString('utf-8', 0, 200) };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
return parser(topicId, payload);
|
|
142
|
+
} catch (e) {
|
|
143
|
+
debug(`Parse error for ${topicType}:`, e.message);
|
|
144
|
+
return { type: topicType, error: e.message };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
module.exports = {
|
|
149
|
+
parseIris,
|
|
150
|
+
parseGraphQL,
|
|
151
|
+
parseDelta,
|
|
152
|
+
parsePresence,
|
|
153
|
+
parseFeed,
|
|
154
|
+
parseLive,
|
|
155
|
+
parseRegionHint,
|
|
156
|
+
parseByType,
|
|
157
|
+
ProtoParser
|
|
158
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package ig.common;
|
|
4
|
+
|
|
5
|
+
// Shared message types used across Instagram
|
|
6
|
+
|
|
7
|
+
message Timestamp {
|
|
8
|
+
int64 unix_time_ms = 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message UserId {
|
|
12
|
+
int64 id = 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message ThreadId {
|
|
16
|
+
int64 id = 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message Reaction {
|
|
20
|
+
string emoji = 1;
|
|
21
|
+
int32 count = 2;
|
|
22
|
+
int64 created_at = 3;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
message MediaAttachment {
|
|
26
|
+
int64 media_id = 1;
|
|
27
|
+
string type = 2; // image, video, carousel
|
|
28
|
+
string url = 3;
|
|
29
|
+
int32 width = 4;
|
|
30
|
+
int32 height = 5;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message Link {
|
|
34
|
+
string url = 1;
|
|
35
|
+
string title = 2;
|
|
36
|
+
string description = 3;
|
|
37
|
+
string image_url = 4;
|
|
38
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package ig.direct;
|
|
4
|
+
|
|
5
|
+
import "common.proto";
|
|
6
|
+
|
|
7
|
+
// Direct message protocol - Specific implementation for DMs
|
|
8
|
+
|
|
9
|
+
message DirectInboxMessageContent {
|
|
10
|
+
string text = 1;
|
|
11
|
+
repeated ig.common.MediaAttachment media = 2;
|
|
12
|
+
repeated ig.common.Link links = 3;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message DirectInboxMessage {
|
|
16
|
+
string id = 1;
|
|
17
|
+
int64 user_id = 2;
|
|
18
|
+
int64 timestamp = 3;
|
|
19
|
+
|
|
20
|
+
string item_type = 4; // text, media_share, animated_media, etc
|
|
21
|
+
DirectInboxMessageContent content = 5;
|
|
22
|
+
|
|
23
|
+
map<string, string> reactions = 6;
|
|
24
|
+
|
|
25
|
+
bool is_sent = 7;
|
|
26
|
+
bool is_delivered = 8;
|
|
27
|
+
bool is_seen = 9;
|
|
28
|
+
|
|
29
|
+
int32 is_forward = 10;
|
|
30
|
+
int32 forwarded_from_id = 11;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message DirectInboxThread {
|
|
34
|
+
int64 thread_id = 1;
|
|
35
|
+
repeated int64 user_ids = 2;
|
|
36
|
+
|
|
37
|
+
string thread_title = 3;
|
|
38
|
+
int64 last_activity_at = 4;
|
|
39
|
+
|
|
40
|
+
DirectInboxMessage last_message = 5;
|
|
41
|
+
|
|
42
|
+
int32 unfollowers_count = 6;
|
|
43
|
+
int32 thread_v2_id = 7;
|
|
44
|
+
|
|
45
|
+
bool is_pin = 8;
|
|
46
|
+
bool is_muted = 9;
|
|
47
|
+
bool is_archived = 10;
|
|
48
|
+
bool has_newer = 11;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
message DirectInbox {
|
|
52
|
+
repeated DirectInboxThread threads = 1;
|
|
53
|
+
string cursor = 2;
|
|
54
|
+
bool has_older = 3;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
message DirectSync {
|
|
58
|
+
int64 seq_id = 1;
|
|
59
|
+
int64 timestamp = 2;
|
|
60
|
+
|
|
61
|
+
repeated DirectInboxMessage messages = 3;
|
|
62
|
+
repeated DirectInboxThread threads = 4;
|
|
63
|
+
|
|
64
|
+
map<string, int64> seq_ids = 5; // per-thread seq tracking
|
|
65
|
+
}
|