@photon-ai/advanced-imessage-kit 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 +21 -0
- package/README.md +497 -0
- package/dist/events.d.ts +32 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +32 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/lib/Loggable.d.ts +16 -0
- package/dist/lib/Loggable.d.ts.map +1 -0
- package/dist/lib/Loggable.js +34 -0
- package/dist/lib/Loggable.js.map +1 -0
- package/dist/lib/Logger.d.ts +18 -0
- package/dist/lib/Logger.d.ts.map +1 -0
- package/dist/lib/Logger.js +77 -0
- package/dist/lib/Logger.js.map +1 -0
- package/dist/mobai.d.ts +38 -0
- package/dist/mobai.d.ts.map +1 -0
- package/dist/mobai.js +150 -0
- package/dist/mobai.js.map +1 -0
- package/dist/modules/attachment.d.ts +26 -0
- package/dist/modules/attachment.d.ts.map +1 -0
- package/dist/modules/attachment.js +87 -0
- package/dist/modules/attachment.js.map +1 -0
- package/dist/modules/chat.d.ts +49 -0
- package/dist/modules/chat.d.ts.map +1 -0
- package/dist/modules/chat.js +100 -0
- package/dist/modules/chat.js.map +1 -0
- package/dist/modules/contact.d.ts +10 -0
- package/dist/modules/contact.d.ts.map +1 -0
- package/dist/modules/contact.js +23 -0
- package/dist/modules/contact.js.map +1 -0
- package/dist/modules/facetime.d.ts +7 -0
- package/dist/modules/facetime.d.ts.map +1 -0
- package/dist/modules/facetime.js +10 -0
- package/dist/modules/facetime.js.map +1 -0
- package/dist/modules/handle.d.ts +24 -0
- package/dist/modules/handle.d.ts.map +1 -0
- package/dist/modules/handle.js +40 -0
- package/dist/modules/handle.js.map +1 -0
- package/dist/modules/icloud.d.ts +10 -0
- package/dist/modules/icloud.d.ts.map +1 -0
- package/dist/modules/icloud.js +20 -0
- package/dist/modules/icloud.js.map +1 -0
- package/dist/modules/index.d.ts +10 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +10 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/message.d.ts +52 -0
- package/dist/modules/message.d.ts.map +1 -0
- package/dist/modules/message.js +104 -0
- package/dist/modules/message.js.map +1 -0
- package/dist/modules/scheduled.d.ts +10 -0
- package/dist/modules/scheduled.d.ts.map +1 -0
- package/dist/modules/scheduled.js +21 -0
- package/dist/modules/scheduled.js.map +1 -0
- package/dist/modules/server.d.ts +17 -0
- package/dist/modules/server.d.ts.map +1 -0
- package/dist/modules/server.js +46 -0
- package/dist/modules/server.js.map +1 -0
- package/dist/types/attachment.d.ts +36 -0
- package/dist/types/attachment.d.ts.map +1 -0
- package/dist/types/attachment.js +2 -0
- package/dist/types/attachment.js.map +1 -0
- package/dist/types/chat.d.ts +25 -0
- package/dist/types/chat.d.ts.map +1 -0
- package/dist/types/chat.js +2 -0
- package/dist/types/chat.js.map +1 -0
- package/dist/types/client.d.ts +5 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +2 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/handle.d.ts +16 -0
- package/dist/types/handle.d.ts.map +1 -0
- package/dist/types/handle.js +2 -0
- package/dist/types/handle.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/message.d.ts +100 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +2 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/server.d.ts +14 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/server.js +2 -0
- package/dist/types/server.js.map +1 -0
- package/dist/types/sticker.d.ts +7 -0
- package/dist/types/sticker.d.ts.map +1 -0
- package/dist/types/sticker.js +2 -0
- package/dist/types/sticker.js.map +1 -0
- package/dist/types/tapback.d.ts +3 -0
- package/dist/types/tapback.d.ts.map +1 -0
- package/dist/types/tapback.js +2 -0
- package/dist/types/tapback.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loggable.js","sourceRoot":"","sources":["../../lib/Loggable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAO,GAA2B,EAAE,CAAC;AAC3C,IAAI,cAAc,GAAa,MAAM,CAAC;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAe,EAAE,EAAE;IACjD,cAAc,GAAG,KAAK,CAAC;IACvB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACtC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IACrC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,OAAO,QAAS,SAAQ,iBAAiB;IAG3C,IAAI,GAAG;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAC/C,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,YAAY,GAAY;QACpB,KAAK,EAAE,CAAC;QAER,IAAI,GAAG,EAAE,CAAC;YACN,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACnB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAyE;QAC3E,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import EventEmitter from "node:events";
|
|
2
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
3
|
+
export declare class Logger extends EventEmitter {
|
|
4
|
+
tag: string;
|
|
5
|
+
private logLevel;
|
|
6
|
+
private logFile?;
|
|
7
|
+
constructor(tag: string, level?: LogLevel, logToFile?: boolean);
|
|
8
|
+
setLogLevel(level: LogLevel): void;
|
|
9
|
+
private shouldLog;
|
|
10
|
+
private formatMessage;
|
|
11
|
+
private writeLog;
|
|
12
|
+
info(message: string): void;
|
|
13
|
+
debug(message: string): void;
|
|
14
|
+
error(message: string | Error): void;
|
|
15
|
+
warn(message: string): void;
|
|
16
|
+
log(message: string, level?: LogLevel): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../lib/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAKvC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,qBAAa,MAAO,SAAQ,YAAY;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,OAAO,CAAC,CAAS;gBAEb,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,QAAiB,EAAE,SAAS,UAAO;IAcnE,WAAW,CAAC,KAAK,EAAE,QAAQ;IAI3B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,QAAQ;IA4BhB,IAAI,CAAC,OAAO,EAAE,MAAM;IAIpB,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK;IAQ7B,IAAI,CAAC,OAAO,EAAE,MAAM;IAIpB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,QAAiB;CAGhD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import EventEmitter from "node:events";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as os from "node:os";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
export class Logger extends EventEmitter {
|
|
6
|
+
constructor(tag, level = "info", logToFile = true) {
|
|
7
|
+
super();
|
|
8
|
+
this.logLevel = "info";
|
|
9
|
+
this.tag = tag;
|
|
10
|
+
this.logLevel = level;
|
|
11
|
+
if (logToFile) {
|
|
12
|
+
const logDir = path.join(os.homedir(), "Library", "Logs", "AdvancedIMessageKit");
|
|
13
|
+
if (!fs.existsSync(logDir)) {
|
|
14
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
this.logFile = path.join(logDir, "sdk.log");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
setLogLevel(level) {
|
|
20
|
+
this.logLevel = level;
|
|
21
|
+
}
|
|
22
|
+
shouldLog(level) {
|
|
23
|
+
const levels = ["debug", "info", "warn", "error"];
|
|
24
|
+
const currentIndex = levels.indexOf(this.logLevel);
|
|
25
|
+
const messageIndex = levels.indexOf(level);
|
|
26
|
+
return messageIndex >= currentIndex;
|
|
27
|
+
}
|
|
28
|
+
formatMessage(level, message) {
|
|
29
|
+
const timestamp = new Date().toISOString();
|
|
30
|
+
return `[${timestamp}][${level.toUpperCase()}][${this.tag}] ${message}`;
|
|
31
|
+
}
|
|
32
|
+
writeLog(level, message) {
|
|
33
|
+
if (!this.shouldLog(level))
|
|
34
|
+
return;
|
|
35
|
+
const formatted = this.formatMessage(level, message);
|
|
36
|
+
switch (level) {
|
|
37
|
+
case "error":
|
|
38
|
+
console.error(formatted);
|
|
39
|
+
break;
|
|
40
|
+
case "warn":
|
|
41
|
+
console.warn(formatted);
|
|
42
|
+
break;
|
|
43
|
+
case "debug":
|
|
44
|
+
console.debug(formatted);
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
console.log(formatted);
|
|
48
|
+
}
|
|
49
|
+
if (this.logFile) {
|
|
50
|
+
try {
|
|
51
|
+
fs.appendFileSync(this.logFile, `${formatted}\n`);
|
|
52
|
+
}
|
|
53
|
+
catch { }
|
|
54
|
+
}
|
|
55
|
+
this.emit("log", { level, message, tag: this.tag });
|
|
56
|
+
}
|
|
57
|
+
info(message) {
|
|
58
|
+
this.writeLog("info", message);
|
|
59
|
+
}
|
|
60
|
+
debug(message) {
|
|
61
|
+
this.writeLog("debug", message);
|
|
62
|
+
}
|
|
63
|
+
error(message) {
|
|
64
|
+
const msg = message instanceof Error ? message.message : message;
|
|
65
|
+
this.writeLog("error", msg);
|
|
66
|
+
if (message instanceof Error && message.stack) {
|
|
67
|
+
this.writeLog("error", message.stack);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
warn(message) {
|
|
71
|
+
this.writeLog("warn", message);
|
|
72
|
+
}
|
|
73
|
+
log(message, level = "info") {
|
|
74
|
+
this.writeLog(level, message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../lib/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KA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OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QACjE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC5B,IAAI,OAAO,YAAY,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAC5C,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED,IAAI,CAAC,OAAe;QAChB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,QAAkB,MAAM;QACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;CACJ"}
|
package/dist/mobai.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { type AxiosInstance } from "axios";
|
|
3
|
+
import io from "socket.io-client";
|
|
4
|
+
import { AttachmentModule, ChatModule, ContactModule, FaceTimeModule, HandleModule, ICloudModule, MessageModule, ScheduledMessageModule, ServerModule } from "./modules";
|
|
5
|
+
import type { ClientConfig } from "./types";
|
|
6
|
+
export declare class AdvancedIMessageKit extends EventEmitter {
|
|
7
|
+
private static getGlobalSdk;
|
|
8
|
+
private static setGlobalSdk;
|
|
9
|
+
static getInstance(config?: ClientConfig): AdvancedIMessageKit;
|
|
10
|
+
readonly config: ClientConfig;
|
|
11
|
+
readonly logger: import("./lib/Logger").Logger;
|
|
12
|
+
readonly http: AxiosInstance;
|
|
13
|
+
readonly socket: ReturnType<typeof io>;
|
|
14
|
+
readonly attachments: AttachmentModule;
|
|
15
|
+
readonly messages: MessageModule;
|
|
16
|
+
readonly chats: ChatModule;
|
|
17
|
+
readonly contacts: ContactModule;
|
|
18
|
+
readonly handles: HandleModule;
|
|
19
|
+
readonly facetime: FaceTimeModule;
|
|
20
|
+
readonly icloud: ICloudModule;
|
|
21
|
+
readonly scheduledMessages: ScheduledMessageModule;
|
|
22
|
+
readonly server: ServerModule;
|
|
23
|
+
private processedMessages;
|
|
24
|
+
private constructor();
|
|
25
|
+
connect(): Promise<void>;
|
|
26
|
+
disconnect(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Clear processed message records (prevent memory leaks)
|
|
29
|
+
* @param maxSize Maximum number of messages to retain, default 1000
|
|
30
|
+
*/
|
|
31
|
+
clearProcessedMessages(maxSize?: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the count of processed messages
|
|
34
|
+
*/
|
|
35
|
+
getProcessedMessageCount(): number;
|
|
36
|
+
}
|
|
37
|
+
export declare const SDK: typeof AdvancedIMessageKit.getInstance;
|
|
38
|
+
//# sourceMappingURL=mobai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobai.d.ts","sourceRoot":"","sources":["../mobai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGlC,OAAO,EACH,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,YAAY,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,mBAAoB,SAAQ,YAAY;IACjD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAyF;IACpH,OAAO,CAAC,MAAM,CAAC,YAAY,CAEzB;WAEY,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,mBAAmB;IAUrE,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,MAAM,gCAAoC;IAC1D,SAAgB,IAAI,EAAE,aAAa,CAAC;IACpC,SAAgB,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9C,SAAgB,WAAW,EAAE,gBAAgB,CAAC;IAC9C,SAAgB,QAAQ,EAAE,aAAa,CAAC;IACxC,SAAgB,KAAK,EAAE,UAAU,CAAC;IAElC,SAAgB,QAAQ,EAAE,aAAa,CAAC;IACxC,SAAgB,OAAO,EAAE,YAAY,CAAC;IAEtC,SAAgB,QAAQ,EAAE,cAAc,CAAC;IACzC,SAAgB,MAAM,EAAE,YAAY,CAAC;IAErC,SAAgB,iBAAiB,EAAE,sBAAsB,CAAC;IAC1D,SAAgB,MAAM,EAAE,YAAY,CAAC;IAOrC,OAAO,CAAC,iBAAiB,CAAqB;IAE9C,OAAO;IAkDD,OAAO;IAgEP,UAAU;IAIhB;;;OAGG;IACI,sBAAsB,CAAC,OAAO,GAAE,MAAa;IAYpD;;OAEG;IACI,wBAAwB,IAAI,MAAM;CAG5C;AAED,eAAO,MAAM,GAAG,wCAAkC,CAAC"}
|
package/dist/mobai.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import axios, {} from "axios";
|
|
3
|
+
import io from "socket.io-client";
|
|
4
|
+
import { getLogger, setGlobalLogLevel } from "./lib/Loggable";
|
|
5
|
+
import { AttachmentModule, ChatModule, ContactModule, FaceTimeModule, HandleModule, ICloudModule, MessageModule, ScheduledMessageModule, ServerModule, } from "./modules";
|
|
6
|
+
export class AdvancedIMessageKit extends EventEmitter {
|
|
7
|
+
static getInstance(config) {
|
|
8
|
+
const existing = AdvancedIMessageKit.getGlobalSdk();
|
|
9
|
+
if (existing)
|
|
10
|
+
return existing;
|
|
11
|
+
const instance = new AdvancedIMessageKit(config);
|
|
12
|
+
AdvancedIMessageKit.setGlobalSdk(instance);
|
|
13
|
+
return instance;
|
|
14
|
+
}
|
|
15
|
+
constructor(config = {}) {
|
|
16
|
+
super();
|
|
17
|
+
this.logger = getLogger("AdvancedIMessageKit");
|
|
18
|
+
// Message deduplication feature
|
|
19
|
+
//
|
|
20
|
+
// Purpose: Prevent message reply loops caused by server repeatedly pushing
|
|
21
|
+
// the same message content with different GUIDs due to unstable Socket.IO connections.
|
|
22
|
+
// This is especially problematic when the polling transport causes connection issues.
|
|
23
|
+
this.processedMessages = new Set();
|
|
24
|
+
this.config = {
|
|
25
|
+
serverUrl: "http://localhost:1234",
|
|
26
|
+
logLevel: "info",
|
|
27
|
+
...config,
|
|
28
|
+
};
|
|
29
|
+
if (this.config.logLevel) {
|
|
30
|
+
setGlobalLogLevel(this.config.logLevel);
|
|
31
|
+
}
|
|
32
|
+
this.http = axios.create({
|
|
33
|
+
baseURL: this.config.serverUrl,
|
|
34
|
+
});
|
|
35
|
+
this.socket = io(this.config.serverUrl, {
|
|
36
|
+
// 🚨 IMPORTANT: Polling transport configuration notes
|
|
37
|
+
//
|
|
38
|
+
// Root cause analysis:
|
|
39
|
+
// 1. Socket.IO 'polling' transport can cause unstable connections in certain network environments
|
|
40
|
+
// 2. When "xhr poll error" occurs, Socket.IO attempts to reconnect
|
|
41
|
+
// 3. During reconnection, the server may repeatedly push the same message with different GUIDs
|
|
42
|
+
// 4. This is not simple client-side duplicate processing, but server-side message duplication
|
|
43
|
+
//
|
|
44
|
+
// Solutions:
|
|
45
|
+
// - Prioritize WebSocket transport, fallback to polling as backup
|
|
46
|
+
// - Set reasonable timeout to avoid frequent reconnections
|
|
47
|
+
// - Use forceNew to ensure fresh connections and avoid state pollution
|
|
48
|
+
// - Implement client-side message deduplication as the last line of defense
|
|
49
|
+
transports: ["websocket"], // Only WebSocket - polling disabled to prevent message duplication
|
|
50
|
+
timeout: 10000, // 10 second timeout to avoid overly frequent reconnections
|
|
51
|
+
forceNew: true, // Force new connection to avoid connection state pollution
|
|
52
|
+
});
|
|
53
|
+
this.attachments = new AttachmentModule(this.http);
|
|
54
|
+
this.messages = new MessageModule(this.http);
|
|
55
|
+
this.chats = new ChatModule(this.http);
|
|
56
|
+
this.contacts = new ContactModule(this.http);
|
|
57
|
+
this.handles = new HandleModule(this.http);
|
|
58
|
+
this.facetime = new FaceTimeModule(this.http);
|
|
59
|
+
this.icloud = new ICloudModule(this.http);
|
|
60
|
+
this.scheduledMessages = new ScheduledMessageModule(this.http);
|
|
61
|
+
this.server = new ServerModule(this.http);
|
|
62
|
+
}
|
|
63
|
+
async connect() {
|
|
64
|
+
const serverEvents = [
|
|
65
|
+
"new-message",
|
|
66
|
+
"message-updated",
|
|
67
|
+
"updated-message",
|
|
68
|
+
"chat-read-status-changed",
|
|
69
|
+
"group-name-change",
|
|
70
|
+
"participant-added",
|
|
71
|
+
"participant-removed",
|
|
72
|
+
"participant-left",
|
|
73
|
+
"group-icon-changed",
|
|
74
|
+
"group-icon-removed",
|
|
75
|
+
"message-send-error",
|
|
76
|
+
"typing-indicator",
|
|
77
|
+
"new-server",
|
|
78
|
+
];
|
|
79
|
+
for (const eventName of serverEvents) {
|
|
80
|
+
this.socket.on(eventName, (...args) => {
|
|
81
|
+
// Message deduplication logic
|
|
82
|
+
//
|
|
83
|
+
// Problem: When Socket.IO connection is unstable (especially with polling transport),
|
|
84
|
+
// the server may repeatedly push the same message content with different GUIDs.
|
|
85
|
+
// This bypasses traditional GUID-based deduplication and causes message reply loops.
|
|
86
|
+
//
|
|
87
|
+
// Solution: Use GUID as unique identifier for deduplication
|
|
88
|
+
if (eventName === "new-message" && args.length > 0) {
|
|
89
|
+
const message = args[0];
|
|
90
|
+
if (message?.guid) {
|
|
91
|
+
// Check if this message has already been processed
|
|
92
|
+
if (this.processedMessages.has(message.guid)) {
|
|
93
|
+
this.logger.debug(`Message already processed, skipping duplicate: ${message.guid}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Mark message as processed
|
|
97
|
+
this.processedMessages.add(message.guid);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
this.emit(eventName, ...args);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
this.socket.on("disconnect", () => {
|
|
104
|
+
this.logger.info("Disconnected from iMessage server");
|
|
105
|
+
this.emit("disconnect");
|
|
106
|
+
});
|
|
107
|
+
if (this.socket.connected) {
|
|
108
|
+
this.logger.info("Already connected to iMessage server");
|
|
109
|
+
this.emit("ready");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.socket.once("connect", () => {
|
|
113
|
+
this.logger.info("Connected to iMessage server");
|
|
114
|
+
this.emit("ready");
|
|
115
|
+
});
|
|
116
|
+
if (!this.socket.connected) {
|
|
117
|
+
this.socket.connect();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async disconnect() {
|
|
121
|
+
this.socket.disconnect();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clear processed message records (prevent memory leaks)
|
|
125
|
+
* @param maxSize Maximum number of messages to retain, default 1000
|
|
126
|
+
*/
|
|
127
|
+
clearProcessedMessages(maxSize = 1000) {
|
|
128
|
+
if (this.processedMessages.size > maxSize) {
|
|
129
|
+
const messages = Array.from(this.processedMessages);
|
|
130
|
+
this.processedMessages.clear();
|
|
131
|
+
// Keep the most recent portion of messages
|
|
132
|
+
messages.slice(-Math.floor(maxSize / 2)).forEach((guid) => {
|
|
133
|
+
this.processedMessages.add(guid);
|
|
134
|
+
});
|
|
135
|
+
this.logger.debug(`Cleared processed message records, retained ${this.processedMessages.size} messages`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get the count of processed messages
|
|
140
|
+
*/
|
|
141
|
+
getProcessedMessageCount() {
|
|
142
|
+
return this.processedMessages.size;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
AdvancedIMessageKit.getGlobalSdk = () => globalThis.__AdvancedIMessageKit__ ?? null;
|
|
146
|
+
AdvancedIMessageKit.setGlobalSdk = (sdk) => {
|
|
147
|
+
globalThis.__AdvancedIMessageKit__ = sdk;
|
|
148
|
+
};
|
|
149
|
+
export const SDK = AdvancedIMessageK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C,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+CAA+C,IAAI,CAAC,iBAAiB,CAAC,IAAI,WAAW,CAAC,CAAC;QAC7G,CAAC;IACL,CAAC;IAED;;OAEG;IACI,wBAAwB;QAC3B,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;IACvC,CAAC;;AAnLc,gCAAY,GAAG,GAA+B,EAAE,CAAE,UAAkB,CAAC,uBAAuB,IAAI,IAAI,AAAxF,CAAyF;AACrG,gCAAY,GAAG,CAAC,GAAwB,EAAE,EAAE;IACtD,UAAkB,CAAC,uBAAuB,GAAG,GAAG,CAAC;AACtD,CAAC,AAF0B,CAEzB;AAmLN,MAAM,CAAC,MAAM,GAAG,GAAG,mBAAmB,CAAC,WAAW,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { Message } from "../interfaces";
|
|
3
|
+
import type { SendAttachmentOptions, SendStickerOptions } from "../types";
|
|
4
|
+
export declare class AttachmentModule {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: AxiosInstance);
|
|
7
|
+
getAttachmentCount(): Promise<number>;
|
|
8
|
+
getAttachment(guid: string): Promise<any>;
|
|
9
|
+
downloadAttachment(guid: string, options?: {
|
|
10
|
+
original?: boolean;
|
|
11
|
+
force?: boolean;
|
|
12
|
+
height?: number;
|
|
13
|
+
width?: number;
|
|
14
|
+
quality?: number;
|
|
15
|
+
}): Promise<Buffer>;
|
|
16
|
+
downloadAttachmentLive(guid: string): Promise<Buffer>;
|
|
17
|
+
getAttachmentBlurhash(guid: string, options?: {
|
|
18
|
+
height?: number;
|
|
19
|
+
width?: number;
|
|
20
|
+
quality?: number;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
private sendAttachmentBase;
|
|
23
|
+
sendAttachment(options: SendAttachmentOptions): Promise<Message>;
|
|
24
|
+
sendSticker(options: SendStickerOptions): Promise<Message>;
|
|
25
|
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,CAAC;CAiBnE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import FormData from "form-data";
|
|
5
|
+
export class AttachmentModule {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
async getAttachmentCount() {
|
|
10
|
+
const response = await this.http.get("/api/v1/attachment/count");
|
|
11
|
+
return response.data.data.total;
|
|
12
|
+
}
|
|
13
|
+
async getAttachment(guid) {
|
|
14
|
+
const response = await this.http.get(`/api/v1/attachment/${guid}`);
|
|
15
|
+
return response.data.data;
|
|
16
|
+
}
|
|
17
|
+
async downloadAttachment(guid, options) {
|
|
18
|
+
const params = {};
|
|
19
|
+
if (options?.original !== undefined)
|
|
20
|
+
params.original = options.original;
|
|
21
|
+
if (options?.force !== undefined)
|
|
22
|
+
params.force = options.force;
|
|
23
|
+
if (options?.height !== undefined)
|
|
24
|
+
params.height = options.height;
|
|
25
|
+
if (options?.width !== undefined)
|
|
26
|
+
params.width = options.width;
|
|
27
|
+
if (options?.quality !== undefined)
|
|
28
|
+
params.quality = options.quality;
|
|
29
|
+
const response = await this.http.get(`/api/v1/attachment/${guid}/download`, {
|
|
30
|
+
params,
|
|
31
|
+
responseType: "arraybuffer",
|
|
32
|
+
});
|
|
33
|
+
return Buffer.from(response.data);
|
|
34
|
+
}
|
|
35
|
+
async downloadAttachmentLive(guid) {
|
|
36
|
+
const response = await this.http.get(`/api/v1/attachment/${guid}/live`, {
|
|
37
|
+
responseType: "arraybuffer",
|
|
38
|
+
});
|
|
39
|
+
return Buffer.from(response.data);
|
|
40
|
+
}
|
|
41
|
+
async getAttachmentBlurhash(guid, options) {
|
|
42
|
+
const params = {};
|
|
43
|
+
if (options?.height !== undefined)
|
|
44
|
+
params.height = options.height;
|
|
45
|
+
if (options?.width !== undefined)
|
|
46
|
+
params.width = options.width;
|
|
47
|
+
if (options?.quality !== undefined)
|
|
48
|
+
params.quality = options.quality;
|
|
49
|
+
const response = await this.http.get(`/api/v1/attachment/${guid}/blurhash`, {
|
|
50
|
+
params,
|
|
51
|
+
});
|
|
52
|
+
return response.data.data.blurhash;
|
|
53
|
+
}
|
|
54
|
+
async sendAttachmentBase(options, isSticker = false) {
|
|
55
|
+
const fileBuffer = await readFile(options.filePath);
|
|
56
|
+
const fileName = options.fileName || path.basename(options.filePath);
|
|
57
|
+
const form = new FormData();
|
|
58
|
+
form.append("chatGuid", options.chatGuid);
|
|
59
|
+
form.append("attachment", fileBuffer, fileName);
|
|
60
|
+
form.append("tempGuid", randomUUID());
|
|
61
|
+
if (isSticker) {
|
|
62
|
+
form.append("isSticker", "true");
|
|
63
|
+
}
|
|
64
|
+
const response = await this.http.post("/api/v1/message/attachment", form, {
|
|
65
|
+
headers: form.getHeaders(),
|
|
66
|
+
});
|
|
67
|
+
return response.data.data;
|
|
68
|
+
}
|
|
69
|
+
async sendAttachment(options) {
|
|
70
|
+
return this.sendAttachmentBase(options);
|
|
71
|
+
}
|
|
72
|
+
async sendSticker(options) {
|
|
73
|
+
const fileName = options.fileName || path.basename(options.filePath);
|
|
74
|
+
const form = new FormData();
|
|
75
|
+
form.append("attachment", await readFile(options.filePath), fileName);
|
|
76
|
+
const { data } = await this.http.post("/api/v1/attachment/upload", form, {
|
|
77
|
+
headers: form.getHeaders(),
|
|
78
|
+
});
|
|
79
|
+
const response = await this.http.post("/api/v1/message/multipart", {
|
|
80
|
+
chatGuid: options.chatGuid,
|
|
81
|
+
selectedMessageGuid: options.selectedMessageGuid,
|
|
82
|
+
parts: [{ partIndex: 0, attachment: data.data.path, name: fileName }],
|
|
83
|
+
});
|
|
84
|
+
return response.data.data;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../modules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AE;SAC7B,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE;YAC/D,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;YAChD,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SACxE,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IAC9B,CAAC;CACJ"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { Chat, Message } from "../interfaces";
|
|
3
|
+
export declare class ChatModule {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
getChats(): Promise<Chat[]>;
|
|
7
|
+
createChat(options: {
|
|
8
|
+
addresses: string[];
|
|
9
|
+
message?: string;
|
|
10
|
+
method?: "apple-script" | "private-api";
|
|
11
|
+
service?: "iMessage" | "SMS";
|
|
12
|
+
tempGuid?: string;
|
|
13
|
+
subject?: string;
|
|
14
|
+
effectId?: string;
|
|
15
|
+
attributedBody?: Record<string, unknown>;
|
|
16
|
+
}): Promise<Chat>;
|
|
17
|
+
getChat(guid: string, options?: {
|
|
18
|
+
with?: string[];
|
|
19
|
+
}): Promise<Chat>;
|
|
20
|
+
updateChat(guid: string, options: {
|
|
21
|
+
displayName?: string;
|
|
22
|
+
}): Promise<Chat>;
|
|
23
|
+
deleteChat(guid: string): Promise<void>;
|
|
24
|
+
markChatRead(guid: string): Promise<void>;
|
|
25
|
+
markChatUnread(guid: string): Promise<void>;
|
|
26
|
+
leaveChat(guid: string): Promise<void>;
|
|
27
|
+
addParticipant(chatGuid: string, address: string): Promise<Chat>;
|
|
28
|
+
removeParticipant(chatGuid: string, address: string): Promise<Chat>;
|
|
29
|
+
getChatMessages(chatGuid: string, options?: {
|
|
30
|
+
offset?: number;
|
|
31
|
+
limit?: number;
|
|
32
|
+
sort?: "ASC" | "DESC";
|
|
33
|
+
before?: number;
|
|
34
|
+
after?: number;
|
|
35
|
+
with?: string[];
|
|
36
|
+
}): Promise<Message[]>;
|
|
37
|
+
setGroupIcon(chatGuid: string, filePath: string): Promise<void>;
|
|
38
|
+
removeGroupIcon(chatGuid: string): Promise<void>;
|
|
39
|
+
getGroupIcon(chatGuid: string): Promise<Buffer>;
|
|
40
|
+
getChatCount(options?: {
|
|
41
|
+
includeArchived?: boolean;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
total: number;
|
|
44
|
+
breakdown: Record<string, number>;
|
|
45
|
+
}>;
|
|
46
|
+
startTyping(chatGuid: string): Promise<void>;
|
|
47
|
+
stopTyping(chatGuid: string): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../modules/chat.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD,qBAAa,UAAU;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAK3B,UAAU,CAAC,OAAO,EAAE;QACtB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;QACxC,OAAO,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAA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AE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/D,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO/C,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;QACjE,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,CAAC;IAOI,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import FormData from "form-data";
|
|
4
|
+
export class ChatModule {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async getChats() {
|
|
9
|
+
const response = await this.http.post("/api/v1/chat/query", {});
|
|
10
|
+
return response.data.data;
|
|
11
|
+
}
|
|
12
|
+
async createChat(options) {
|
|
13
|
+
const response = await this.http.post("/api/v1/chat/new", options);
|
|
14
|
+
return response.data.data;
|
|
15
|
+
}
|
|
16
|
+
async getChat(guid, options) {
|
|
17
|
+
const response = await this.http.get(`/api/v1/chat/${guid}`, {
|
|
18
|
+
params: options?.with ? { with: options.with.join(",") } : {},
|
|
19
|
+
});
|
|
20
|
+
return response.data.data;
|
|
21
|
+
}
|
|
22
|
+
async updateChat(guid, options) {
|
|
23
|
+
const response = await this.http.put(`/api/v1/chat/${guid}`, options);
|
|
24
|
+
return response.data.data;
|
|
25
|
+
}
|
|
26
|
+
async deleteChat(guid) {
|
|
27
|
+
await this.http.delete(`/api/v1/chat/${guid}`);
|
|
28
|
+
}
|
|
29
|
+
async markChatRead(guid) {
|
|
30
|
+
await this.http.post(`/api/v1/chat/${guid}/read`);
|
|
31
|
+
}
|
|
32
|
+
async markChatUnread(guid) {
|
|
33
|
+
await this.http.post(`/api/v1/chat/${guid}/unread`);
|
|
34
|
+
}
|
|
35
|
+
async leaveChat(guid) {
|
|
36
|
+
await this.http.post(`/api/v1/chat/${guid}/leave`);
|
|
37
|
+
}
|
|
38
|
+
async addParticipant(chatGuid, address) {
|
|
39
|
+
const response = await this.http.post(`/api/v1/chat/${chatGuid}/participant`, {
|
|
40
|
+
address,
|
|
41
|
+
});
|
|
42
|
+
return response.data.data;
|
|
43
|
+
}
|
|
44
|
+
async removeParticipant(chatGuid, address) {
|
|
45
|
+
const response = await this.http.delete(`/api/v1/chat/${chatGuid}/participant`, {
|
|
46
|
+
data: { address },
|
|
47
|
+
});
|
|
48
|
+
return response.data.data;
|
|
49
|
+
}
|
|
50
|
+
async getChatMessages(chatGuid, options) {
|
|
51
|
+
const params = {};
|
|
52
|
+
if (options?.offset !== undefined)
|
|
53
|
+
params.offset = options.offset;
|
|
54
|
+
if (options?.limit !== undefined)
|
|
55
|
+
params.limit = options.limit;
|
|
56
|
+
if (options?.sort)
|
|
57
|
+
params.sort = options.sort;
|
|
58
|
+
if (options?.before !== undefined)
|
|
59
|
+
params.before = options.before;
|
|
60
|
+
if (options?.after !== undefined)
|
|
61
|
+
params.after = options.after;
|
|
62
|
+
if (options?.with)
|
|
63
|
+
params.with = options.with.join(",");
|
|
64
|
+
const response = await this.http.get(`/api/v1/chat/${chatGuid}/message`, {
|
|
65
|
+
params,
|
|
66
|
+
});
|
|
67
|
+
return response.data.data;
|
|
68
|
+
}
|
|
69
|
+
async setGroupIcon(chatGuid, filePath) {
|
|
70
|
+
const fileBuffer = await readFile(filePath);
|
|
71
|
+
const fileName = path.basename(filePath);
|
|
72
|
+
const form = new FormData();
|
|
73
|
+
form.append("icon", fileBuffer, fileName);
|
|
74
|
+
await this.http.post(`/api/v1/chat/${chatGuid}/icon`, form, {
|
|
75
|
+
headers: form.getHeaders(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async removeGroupIcon(chatGuid) {
|
|
79
|
+
await this.http.delete(`/api/v1/chat/${chatGuid}/icon`);
|
|
80
|
+
}
|
|
81
|
+
async getGroupIcon(chatGuid) {
|
|
82
|
+
const response = await this.http.get(`/api/v1/chat/${chatGuid}/icon`, {
|
|
83
|
+
responseType: "arraybuffer",
|
|
84
|
+
});
|
|
85
|
+
return Buffer.from(response.data);
|
|
86
|
+
}
|
|
87
|
+
async getChatCount(options) {
|
|
88
|
+
const response = await this.http.get("/api/v1/chat/count", {
|
|
89
|
+
params: options?.includeArchived !== undefined ? { includeArchived: options.includeArchived } : {},
|
|
90
|
+
});
|
|
91
|
+
return response.data.data;
|
|
92
|
+
}
|
|
93
|
+
async startTyping(chatGuid) {
|
|
94
|
+
await this.http.post(`/api/v1/chat/${chatGuid}/typing`);
|
|
95
|
+
}
|
|
96
|
+
async stopTyping(chatGuid) {
|
|
97
|
+
await this.http.delete(`/api/v1/chat/${chatGuid}/typing`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../modules/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,QAAQ,MAAM,WAAW,CAAC;AAGjC,MAAM,OAAO,UAAU;IACnB,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,QAAQ;QACV,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE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oB,EAAE;YACvD,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE;SACrG,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAgB;QAC9B,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,QAAQ,SAAS,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC7B,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,QAAQ,SAAS,CAAC,CAAC;IAC9D,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
export declare class ContactModule {
|
|
3
|
+
private readonly http;
|
|
4
|
+
constructor(http: AxiosInstance);
|
|
5
|
+
getContacts(): Promise<any[]>;
|
|
6
|
+
getContactCard(address: string): Promise<any>;
|
|
7
|
+
shareContactCard(chatGuid: string): Promise<void>;
|
|
8
|
+
shouldShareContact(chatGuid: string): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=contact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../modules/contact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,qBAAa,aAAa;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAK7B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAO7C,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAI/D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class ContactModule {
|
|
2
|
+
constructor(http) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
}
|
|
5
|
+
async getContacts() {
|
|
6
|
+
const response = await this.http.get("/api/v1/contact");
|
|
7
|
+
return response.data.data;
|
|
8
|
+
}
|
|
9
|
+
async getContactCard(address) {
|
|
10
|
+
const response = await this.http.get("/api/v1/icloud/contact", {
|
|
11
|
+
params: { address },
|
|
12
|
+
});
|
|
13
|
+
return response.data.data;
|
|
14
|
+
}
|
|
15
|
+
async shareContactCard(chatGuid) {
|
|
16
|
+
await this.http.post(`/api/v1/chat/${chatGuid}/share/contact`);
|
|
17
|
+
}
|
|
18
|
+
async shouldShareContact(chatGuid) {
|
|
19
|
+
const response = await this.http.get(`/api/v1/chat/${chatGuid}/share/contact/status`);
|
|
20
|
+
return response.data.data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=contact.js.map
|