@photon-ai/advanced-imessage-kit 1.0.2 → 1.0.4
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 +615 -200
- package/dist/modules/attachment.d.ts +0 -1
- package/dist/modules/attachment.d.ts.map +1 -1
- package/dist/modules/attachment.js +7 -6
- package/dist/modules/attachment.js.map +1 -1
- package/dist/types/attachment.d.ts +1 -0
- package/dist/types/attachment.d.ts.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -16,14 +16,14 @@ Advanced iMessage Kit is a comprehensive iMessage SDK for **reading**, **sending
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
19
|
+
- ** Type Safe** - Complete TypeScript support with full type definitions
|
|
20
|
+
- ** Real-time Communication** - WebSocket-based event system for instant message updates
|
|
21
|
+
- ** Complete API** - Send text, attachments, reactions, edit messages, and more
|
|
22
|
+
- ** Group Management** - Create groups, manage members, set group icons
|
|
23
|
+
- ** Rich Attachments** - Send images, files, voice messages, stickers, and contact cards
|
|
24
|
+
- ** Advanced Querying** - Powerful message filtering and search capabilities
|
|
25
|
+
- ** Analytics** - Message counts, delivery status, and chat statistics
|
|
26
|
+
- ** Event-driven** - Listen for new messages, typing indicators, and status changes
|
|
27
27
|
|
|
28
28
|
## Quick Start
|
|
29
29
|
|
|
@@ -38,28 +38,28 @@ bun add @photon-ai/advanced-imessage-kit
|
|
|
38
38
|
### Basic Usage
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
|
-
import {
|
|
41
|
+
import { SDK } from "@photon-ai/advanced-imessage-kit";
|
|
42
42
|
|
|
43
|
-
const sdk =
|
|
44
|
-
|
|
45
|
-
})
|
|
43
|
+
const sdk = SDK({
|
|
44
|
+
serverUrl: "{your-subdomain}.imsgd.photon.codes", // Your subdomain is the unique link address assigned to you
|
|
45
|
+
});
|
|
46
46
|
|
|
47
47
|
// Connect to the server
|
|
48
|
-
await sdk.connect()
|
|
48
|
+
await sdk.connect();
|
|
49
49
|
|
|
50
50
|
// Listen for new messages
|
|
51
|
-
sdk.on(
|
|
52
|
-
|
|
53
|
-
})
|
|
51
|
+
sdk.on("new-message", (message) => {
|
|
52
|
+
console.log("New message:", message.text);
|
|
53
|
+
});
|
|
54
54
|
|
|
55
55
|
// Send a message
|
|
56
56
|
await sdk.messages.sendMessage({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
57
|
+
chatGuid: "any;-;+1234567890",
|
|
58
|
+
message: "Hello World!",
|
|
59
|
+
});
|
|
60
60
|
|
|
61
61
|
// Disconnect when done
|
|
62
|
-
await sdk.disconnect()
|
|
62
|
+
await sdk.disconnect();
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
## Core API
|
|
@@ -67,31 +67,31 @@ await sdk.disconnect()
|
|
|
67
67
|
### Initialization & Connection
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
|
-
import {
|
|
70
|
+
import { SDK } from "@photon-ai/advanced-imessage-kit";
|
|
71
71
|
|
|
72
|
-
const sdk =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
72
|
+
const sdk = SDK({
|
|
73
|
+
serverUrl: "{your-subdomain}.imsgd.photon.codes", // Your subdomain is the unique link address assigned to you
|
|
74
|
+
logLevel: "info", // Log level: 'debug' | 'info' | 'warn' | 'error'
|
|
75
|
+
});
|
|
76
76
|
|
|
77
77
|
// Connect to server
|
|
78
|
-
await sdk.connect()
|
|
78
|
+
await sdk.connect();
|
|
79
79
|
|
|
80
80
|
// Check connection status
|
|
81
|
-
sdk.on(
|
|
82
|
-
|
|
83
|
-
})
|
|
81
|
+
sdk.on("ready", () => {
|
|
82
|
+
console.log("SDK is ready!");
|
|
83
|
+
});
|
|
84
84
|
|
|
85
85
|
// Graceful disconnect
|
|
86
|
-
await sdk.disconnect()
|
|
86
|
+
await sdk.disconnect();
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
### Connection Management
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
// Message deduplication (prevents duplicate processing)
|
|
93
|
-
sdk.clearProcessedMessages(1000)
|
|
94
|
-
const count = sdk.getProcessedMessageCount()
|
|
93
|
+
sdk.clearProcessedMessages(1000); // Clear old processed message records
|
|
94
|
+
const count = sdk.getProcessedMessageCount(); // Get processed message count
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
## Message Operations
|
|
@@ -101,24 +101,24 @@ const count = sdk.getProcessedMessageCount() // Get processed message count
|
|
|
101
101
|
```typescript
|
|
102
102
|
// Send text message
|
|
103
103
|
const message = await sdk.messages.sendMessage({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
})
|
|
104
|
+
chatGuid: "any;-;+1234567890",
|
|
105
|
+
message: "Hello World!",
|
|
106
|
+
});
|
|
107
107
|
|
|
108
108
|
// Send message with options
|
|
109
109
|
await sdk.messages.sendMessage({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
})
|
|
110
|
+
chatGuid: "any;-;+1234567890",
|
|
111
|
+
message: "Important message",
|
|
112
|
+
subject: "Subject line",
|
|
113
|
+
effectId: "com.apple.messages.effect.CKConfettiEffect",
|
|
114
|
+
});
|
|
115
115
|
|
|
116
116
|
// Reply to message
|
|
117
117
|
await sdk.messages.sendMessage({
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})
|
|
118
|
+
chatGuid: "any;-;+1234567890",
|
|
119
|
+
message: "This is a reply",
|
|
120
|
+
selectedMessageGuid: "original-message-guid",
|
|
121
|
+
});
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
### Message Querying
|
|
@@ -126,19 +126,19 @@ await sdk.messages.sendMessage({
|
|
|
126
126
|
```typescript
|
|
127
127
|
// Get messages with filters
|
|
128
128
|
const messages = await sdk.messages.getMessages({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})
|
|
129
|
+
chatGuid: "any;-;+1234567890",
|
|
130
|
+
limit: 50,
|
|
131
|
+
offset: 0,
|
|
132
|
+
});
|
|
133
133
|
|
|
134
134
|
// Get message counts
|
|
135
135
|
const totalCount = await sdk.messages.getMessageCount({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
})
|
|
136
|
+
chatGuid: "any;-;+1234567890",
|
|
137
|
+
after: 1640995200000, // Timestamp
|
|
138
|
+
before: 1641081600000, // Timestamp
|
|
139
|
+
});
|
|
140
140
|
|
|
141
|
-
const sentCount = await sdk.messages.getSentMessageCount()
|
|
141
|
+
const sentCount = await sdk.messages.getSentMessageCount();
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
### Message Actions
|
|
@@ -146,23 +146,23 @@ const sentCount = await sdk.messages.getSentMessageCount()
|
|
|
146
146
|
```typescript
|
|
147
147
|
// Edit message
|
|
148
148
|
await sdk.messages.editMessage({
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})
|
|
149
|
+
messageGuid: "message-guid",
|
|
150
|
+
editedMessage: "Updated text",
|
|
151
|
+
backwardsCompatibilityMessage: "Updated text",
|
|
152
|
+
});
|
|
153
153
|
|
|
154
154
|
// Add reaction
|
|
155
155
|
await sdk.messages.sendReaction({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
})
|
|
156
|
+
chatGuid: "any;-;+1234567890",
|
|
157
|
+
messageGuid: "message-guid",
|
|
158
|
+
reaction: "love", // Options: love, like, dislike, laugh, emphasize, question, -love, -like, etc.
|
|
159
|
+
partIndex: 0, // Optional: defaults to 0
|
|
160
|
+
});
|
|
161
161
|
|
|
162
162
|
// Unsend message
|
|
163
163
|
await sdk.messages.unsendMessage({
|
|
164
|
-
|
|
165
|
-
})
|
|
164
|
+
messageGuid: "message-guid",
|
|
165
|
+
});
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
## Chat Management
|
|
@@ -171,70 +171,70 @@ await sdk.messages.unsendMessage({
|
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
173
|
// Get all chats
|
|
174
|
-
const chats = await sdk.chats.getChats()
|
|
174
|
+
const chats = await sdk.chats.getChats();
|
|
175
175
|
|
|
176
176
|
// Get specific chat
|
|
177
|
-
const chat = await sdk.chats.getChat(
|
|
178
|
-
|
|
179
|
-
})
|
|
177
|
+
const chat = await sdk.chats.getChat("chat-guid", {
|
|
178
|
+
with: ["participants", "lastMessage"],
|
|
179
|
+
});
|
|
180
180
|
|
|
181
181
|
// Create new chat
|
|
182
182
|
const newChat = await sdk.chats.createChat({
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
})
|
|
183
|
+
addresses: ["+1234567890", "+0987654321"],
|
|
184
|
+
message: "Hello everyone!",
|
|
185
|
+
service: "iMessage", // 'iMessage' or 'SMS'
|
|
186
|
+
method: "private-api", // 'apple-script' or 'private-api'
|
|
187
|
+
});
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
### Group Management
|
|
191
191
|
|
|
192
192
|
```typescript
|
|
193
193
|
// Update group name
|
|
194
|
-
await sdk.chats.updateChat(
|
|
195
|
-
|
|
196
|
-
})
|
|
194
|
+
await sdk.chats.updateChat("chat-guid", {
|
|
195
|
+
displayName: "My Group Chat",
|
|
196
|
+
});
|
|
197
197
|
|
|
198
198
|
// Add participant
|
|
199
|
-
await sdk.chats.addParticipant(
|
|
199
|
+
await sdk.chats.addParticipant("chat-guid", "+1234567890");
|
|
200
200
|
|
|
201
201
|
// Remove participant
|
|
202
|
-
await sdk.chats.removeParticipant(
|
|
202
|
+
await sdk.chats.removeParticipant("chat-guid", "+1234567890");
|
|
203
203
|
|
|
204
204
|
// Leave group
|
|
205
|
-
await sdk.chats.leaveChat(
|
|
205
|
+
await sdk.chats.leaveChat("chat-guid");
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
### Group Icons
|
|
209
209
|
|
|
210
210
|
```typescript
|
|
211
211
|
// Set group icon
|
|
212
|
-
await sdk.chats.setGroupIcon(
|
|
212
|
+
await sdk.chats.setGroupIcon("chat-guid", "/path/to/image.jpg");
|
|
213
213
|
|
|
214
214
|
// Get group icon
|
|
215
|
-
const iconBuffer = await sdk.chats.getGroupIcon(
|
|
215
|
+
const iconBuffer = await sdk.chats.getGroupIcon("chat-guid");
|
|
216
216
|
|
|
217
217
|
// Remove group icon
|
|
218
|
-
await sdk.chats.removeGroupIcon(
|
|
218
|
+
await sdk.chats.removeGroupIcon("chat-guid");
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
### Chat Status
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
224
|
// Mark as read/unread
|
|
225
|
-
await sdk.chats.markChatRead(
|
|
226
|
-
await sdk.chats.markChatUnread(
|
|
225
|
+
await sdk.chats.markChatRead("chat-guid");
|
|
226
|
+
await sdk.chats.markChatUnread("chat-guid");
|
|
227
227
|
|
|
228
228
|
// Typing indicators
|
|
229
|
-
await sdk.chats.startTyping(
|
|
230
|
-
await sdk.chats.stopTyping(
|
|
229
|
+
await sdk.chats.startTyping("chat-guid");
|
|
230
|
+
await sdk.chats.stopTyping("chat-guid");
|
|
231
231
|
|
|
232
232
|
// Get chat messages
|
|
233
|
-
const messages = await sdk.chats.getChatMessages(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
})
|
|
233
|
+
const messages = await sdk.chats.getChatMessages("chat-guid", {
|
|
234
|
+
limit: 100,
|
|
235
|
+
offset: 0,
|
|
236
|
+
sort: "DESC",
|
|
237
|
+
});
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
## Attachments & Media
|
|
@@ -244,27 +244,54 @@ const messages = await sdk.chats.getChatMessages('chat-guid', {
|
|
|
244
244
|
```typescript
|
|
245
245
|
// Send file attachment
|
|
246
246
|
const message = await sdk.attachments.sendAttachment({
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
})
|
|
247
|
+
chatGuid: "any;-;+1234567890",
|
|
248
|
+
filePath: "/path/to/file.jpg",
|
|
249
|
+
fileName: "custom-name.jpg", // Optional
|
|
250
|
+
});
|
|
251
251
|
|
|
252
252
|
// Send sticker
|
|
253
253
|
await sdk.attachments.sendSticker({
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
})
|
|
254
|
+
chatGuid: "any;-;+1234567890",
|
|
255
|
+
filePath: "/path/to/sticker.png",
|
|
256
|
+
selectedMessageGuid: "message-to-reply-to", // Optional
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Voice Messages
|
|
261
|
+
|
|
262
|
+
Voice messages differ from regular audio attachments. Ensure the audio file path exists and use common formats like `.m4a` or `.mp3`. In the example script, you can also supply the path via the `AUDIO_FILE_PATH` environment variable.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// Send voice message
|
|
266
|
+
const message = await sdk.attachments.sendAttachment({
|
|
267
|
+
chatGuid: "any;-;+1234567890",
|
|
268
|
+
filePath: "/path/to/audio.mp3",
|
|
269
|
+
isAudioMessage: true,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Detect and handle incoming audio messages
|
|
273
|
+
sdk.on("new-message", async (msg) => {
|
|
274
|
+
if (msg.isAudioMessage) {
|
|
275
|
+
const att = msg.attachments?.[0];
|
|
276
|
+
if (att) {
|
|
277
|
+
// Download original audio attachment
|
|
278
|
+
const audioBuffer = await sdk.attachments.downloadAttachment(att.guid, {
|
|
279
|
+
original: true,
|
|
280
|
+
});
|
|
281
|
+
// Save or process audioBuffer
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
258
285
|
```
|
|
259
286
|
|
|
260
287
|
### Attachment Info
|
|
261
288
|
|
|
262
289
|
```typescript
|
|
263
290
|
// Get attachment details
|
|
264
|
-
const attachment = await sdk.attachments.getAttachment(
|
|
291
|
+
const attachment = await sdk.attachments.getAttachment("attachment-guid");
|
|
265
292
|
|
|
266
293
|
// Get attachment count
|
|
267
|
-
const count = await sdk.attachments.getAttachmentCount()
|
|
294
|
+
const count = await sdk.attachments.getAttachmentCount();
|
|
268
295
|
```
|
|
269
296
|
|
|
270
297
|
## Contacts & Handles
|
|
@@ -273,16 +300,16 @@ const count = await sdk.attachments.getAttachmentCount()
|
|
|
273
300
|
|
|
274
301
|
```typescript
|
|
275
302
|
// Get all contacts
|
|
276
|
-
const contacts = await sdk.contacts.getContacts()
|
|
303
|
+
const contacts = await sdk.contacts.getContacts();
|
|
277
304
|
|
|
278
305
|
// Get contact card
|
|
279
|
-
const contactCard = await sdk.contacts.getContactCard(
|
|
306
|
+
const contactCard = await sdk.contacts.getContactCard("+1234567890");
|
|
280
307
|
|
|
281
308
|
// Share contact card
|
|
282
|
-
await sdk.contacts.shareContactCard(
|
|
309
|
+
await sdk.contacts.shareContactCard("chat-guid");
|
|
283
310
|
|
|
284
311
|
// Check if should share contact
|
|
285
|
-
const shouldShare = await sdk.contacts.shouldShareContact(
|
|
312
|
+
const shouldShare = await sdk.contacts.shouldShareContact("chat-guid");
|
|
286
313
|
```
|
|
287
314
|
|
|
288
315
|
### Handle Operations
|
|
@@ -290,46 +317,274 @@ const shouldShare = await sdk.contacts.shouldShareContact('chat-guid')
|
|
|
290
317
|
```typescript
|
|
291
318
|
// Query handles
|
|
292
319
|
const result = await sdk.handles.queryHandles({
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
})
|
|
320
|
+
address: "+1234567890",
|
|
321
|
+
with: ["chats"],
|
|
322
|
+
limit: 50,
|
|
323
|
+
});
|
|
297
324
|
|
|
298
325
|
// Get handle availability
|
|
299
|
-
const isAvailable = await sdk.handles.getHandleAvailability(
|
|
326
|
+
const isAvailable = await sdk.handles.getHandleAvailability(
|
|
327
|
+
"handle-guid",
|
|
328
|
+
"imessage"
|
|
329
|
+
);
|
|
300
330
|
|
|
301
331
|
// Get focus status
|
|
302
|
-
const focusStatus = await sdk.handles.getHandleFocusStatus(
|
|
332
|
+
const focusStatus = await sdk.handles.getHandleFocusStatus("handle-guid");
|
|
303
333
|
```
|
|
304
334
|
|
|
305
335
|
## Real-time Events
|
|
306
336
|
|
|
337
|
+
The SDK emits various events for real-time updates. All events can be listened to using the `on()` method.
|
|
338
|
+
|
|
339
|
+
### Core Events
|
|
340
|
+
|
|
341
|
+
#### `ready`
|
|
342
|
+
|
|
343
|
+
Emitted when the SDK is fully connected and ready to use.
|
|
344
|
+
|
|
307
345
|
```typescript
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
346
|
+
sdk.on("ready", () => {
|
|
347
|
+
console.log("SDK connected and ready");
|
|
348
|
+
});
|
|
349
|
+
```
|
|
312
350
|
|
|
313
|
-
|
|
314
|
-
console.log('Message updated:', message.guid)
|
|
315
|
-
})
|
|
351
|
+
#### `connect`
|
|
316
352
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
353
|
+
Emitted when Socket.IO connection is established.
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
sdk.on("connect", () => {
|
|
357
|
+
console.log("Socket.IO connected");
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### `disconnect`
|
|
362
|
+
|
|
363
|
+
Emitted when Socket.IO connection is lost.
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
sdk.on("disconnect", () => {
|
|
367
|
+
console.log("Socket.IO disconnected");
|
|
368
|
+
});
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
#### `error`
|
|
372
|
+
|
|
373
|
+
Emitted when an error occurs.
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
sdk.on("error", (error) => {
|
|
377
|
+
console.error("SDK error:", error);
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Message Events
|
|
382
|
+
|
|
383
|
+
#### `new-message`
|
|
384
|
+
|
|
385
|
+
Emitted when a new message is received or sent.
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
sdk.on("new-message", (message) => {
|
|
389
|
+
console.log("New message received:", message.text);
|
|
390
|
+
console.log("From:", message.handle?.address);
|
|
391
|
+
console.log("GUID:", message.guid);
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
#### `updated-message` / `message-updated`
|
|
396
|
+
|
|
397
|
+
Emitted when a message status changes (delivered, read, etc.).
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
sdk.on("updated-message", (message) => {
|
|
401
|
+
const status = message.dateRead
|
|
402
|
+
? "read"
|
|
403
|
+
: message.dateDelivered
|
|
404
|
+
? "delivered"
|
|
405
|
+
: "sent";
|
|
406
|
+
console.log(`Message ${message.guid} is now ${status}`);
|
|
407
|
+
});
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
#### `message-send-error`
|
|
411
|
+
|
|
412
|
+
Emitted when sending a message fails.
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
sdk.on("message-send-error", (data) => {
|
|
416
|
+
console.error("Failed to send message:", data);
|
|
417
|
+
});
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Chat Events
|
|
421
|
+
|
|
422
|
+
#### `chat-read-status-changed`
|
|
423
|
+
|
|
424
|
+
Emitted when a chat is marked as read or unread.
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
sdk.on("chat-read-status-changed", ({ chatGuid, read }) => {
|
|
428
|
+
console.log(`Chat ${chatGuid} marked as ${read ? "read" : "unread"}`);
|
|
429
|
+
});
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Group Chat Events
|
|
433
|
+
|
|
434
|
+
#### `group-name-change`
|
|
435
|
+
|
|
436
|
+
Emitted when a group chat name is changed.
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
sdk.on("group-name-change", (data) => {
|
|
440
|
+
console.log(`Group renamed to: ${data.message.groupTitle}`);
|
|
441
|
+
});
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### `participant-added`
|
|
445
|
+
|
|
446
|
+
Emitted when someone is added to a group chat.
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
sdk.on("participant-added", (data) => {
|
|
450
|
+
console.log(`Participant added to ${data.chat.displayName}`);
|
|
451
|
+
});
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
#### `participant-removed`
|
|
455
|
+
|
|
456
|
+
Emitted when someone is removed from a group chat.
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
sdk.on("participant-removed", (data) => {
|
|
460
|
+
console.log(`Participant removed from ${data.chat.displayName}`);
|
|
461
|
+
});
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
#### `participant-left`
|
|
465
|
+
|
|
466
|
+
Emitted when someone leaves a group chat.
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
sdk.on("participant-left", (data) => {
|
|
470
|
+
console.log(`Participant left ${data.chat.displayName}`);
|
|
471
|
+
});
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
#### `group-icon-changed`
|
|
475
|
+
|
|
476
|
+
Emitted when a group chat icon is changed.
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
sdk.on("group-icon-changed", (data) => {
|
|
480
|
+
console.log("Group icon changed");
|
|
481
|
+
});
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
#### `group-icon-removed`
|
|
485
|
+
|
|
486
|
+
Emitted when a group chat icon is removed.
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
sdk.on("group-icon-removed", (data) => {
|
|
490
|
+
console.log("Group icon removed");
|
|
491
|
+
});
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Private API Events
|
|
495
|
+
|
|
496
|
+
#### `typing-indicator`
|
|
497
|
+
|
|
498
|
+
Emitted when someone is typing. Requires Private API.
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
sdk.on("typing-indicator", (data) => {
|
|
502
|
+
console.log("Typing status changed:", data);
|
|
503
|
+
});
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
#### `ft-call-status-changed`
|
|
507
|
+
|
|
508
|
+
Emitted when FaceTime call status changes.
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
sdk.on("ft-call-status-changed", ({ callUuid, status }) => {
|
|
512
|
+
console.log(`FaceTime call ${callUuid}: ${status}`);
|
|
513
|
+
});
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### Find My Events
|
|
517
|
+
|
|
518
|
+
#### `new-findmy-location`
|
|
519
|
+
|
|
520
|
+
Emitted when a Find My friend's location updates.
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
sdk.on("new-findmy-location", ({ name, friendId, location }) => {
|
|
524
|
+
console.log(`${name} location: ${location.latitude}, ${location.longitude}`);
|
|
525
|
+
});
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### Scheduled Message Events
|
|
529
|
+
|
|
530
|
+
#### `scheduled-message-sent`
|
|
531
|
+
|
|
532
|
+
Emitted when a scheduled message is sent.
|
|
533
|
+
|
|
534
|
+
```typescript
|
|
535
|
+
sdk.on("scheduled-message-sent", (data) => {
|
|
536
|
+
console.log("Scheduled message sent:", data);
|
|
537
|
+
});
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
#### `scheduled-message-error`
|
|
541
|
+
|
|
542
|
+
Emitted when a scheduled message fails.
|
|
543
|
+
|
|
544
|
+
```typescript
|
|
545
|
+
sdk.on("scheduled-message-error", (data) => {
|
|
546
|
+
console.error("Scheduled message error:", data);
|
|
547
|
+
});
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
#### `scheduled-message-created`
|
|
551
|
+
|
|
552
|
+
Emitted when a scheduled message is created.
|
|
553
|
+
|
|
554
|
+
```typescript
|
|
555
|
+
sdk.on("scheduled-message-created", (data) => {
|
|
556
|
+
console.log("Scheduled message created:", data);
|
|
557
|
+
});
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
#### `scheduled-message-updated`
|
|
561
|
+
|
|
562
|
+
Emitted when a scheduled message is updated.
|
|
563
|
+
|
|
564
|
+
```typescript
|
|
565
|
+
sdk.on("scheduled-message-updated", (data) => {
|
|
566
|
+
console.log("Scheduled message updated:", data);
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
#### `scheduled-message-deleted`
|
|
321
571
|
|
|
322
|
-
|
|
323
|
-
sdk.on('ready', () => {
|
|
324
|
-
console.log('SDK connected and ready')
|
|
325
|
-
})
|
|
572
|
+
Emitted when a scheduled message is deleted.
|
|
326
573
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
574
|
+
```typescript
|
|
575
|
+
sdk.on("scheduled-message-deleted", (data) => {
|
|
576
|
+
console.log("Scheduled message deleted:", data);
|
|
577
|
+
});
|
|
578
|
+
```
|
|
330
579
|
|
|
580
|
+
### Event Management
|
|
581
|
+
|
|
582
|
+
```typescript
|
|
331
583
|
// Remove event listeners
|
|
332
|
-
sdk.off(
|
|
584
|
+
sdk.off("new-message", messageHandler);
|
|
585
|
+
|
|
586
|
+
// Remove all listeners for an event
|
|
587
|
+
sdk.removeAllListeners("new-message");
|
|
333
588
|
```
|
|
334
589
|
|
|
335
590
|
## Advanced Features
|
|
@@ -338,27 +593,27 @@ sdk.off('new-message', messageHandler)
|
|
|
338
593
|
|
|
339
594
|
```typescript
|
|
340
595
|
// Create FaceTime link
|
|
341
|
-
const link = await sdk.facetime.createFaceTimeLink()
|
|
342
|
-
console.log(
|
|
596
|
+
const link = await sdk.facetime.createFaceTimeLink();
|
|
597
|
+
console.log("FaceTime link:", link);
|
|
343
598
|
|
|
344
599
|
// Listen for FaceTime status changes
|
|
345
|
-
sdk.on(
|
|
346
|
-
|
|
347
|
-
})
|
|
600
|
+
sdk.on("facetime-status-change", (data) => {
|
|
601
|
+
console.log("FaceTime status:", data.status);
|
|
602
|
+
});
|
|
348
603
|
```
|
|
349
604
|
|
|
350
605
|
### iCloud Services
|
|
351
606
|
|
|
352
607
|
```typescript
|
|
353
608
|
// Get Find My Friends
|
|
354
|
-
const friends = await sdk.icloud.getFindMyFriends()
|
|
609
|
+
const friends = await sdk.icloud.getFindMyFriends();
|
|
355
610
|
|
|
356
611
|
// Get Find My Devices
|
|
357
|
-
const devices = await sdk.icloud.getFindMyDevices()
|
|
612
|
+
const devices = await sdk.icloud.getFindMyDevices();
|
|
358
613
|
|
|
359
614
|
// Refresh data
|
|
360
|
-
await sdk.icloud.refreshFindMyFriends()
|
|
361
|
-
await sdk.icloud.refreshFindMyDevices()
|
|
615
|
+
await sdk.icloud.refreshFindMyFriends();
|
|
616
|
+
await sdk.icloud.refreshFindMyDevices();
|
|
362
617
|
```
|
|
363
618
|
|
|
364
619
|
### Scheduled Messages
|
|
@@ -366,57 +621,57 @@ await sdk.icloud.refreshFindMyDevices()
|
|
|
366
621
|
```typescript
|
|
367
622
|
// Create scheduled message
|
|
368
623
|
const scheduled = await sdk.scheduledMessages.createScheduledMessage({
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
})
|
|
624
|
+
chatGuid: "any;-;+1234567890",
|
|
625
|
+
message: "This message was scheduled!",
|
|
626
|
+
scheduledFor: new Date(Date.now() + 60000), // 1 minute from now
|
|
627
|
+
schedule: { type: "once" },
|
|
628
|
+
});
|
|
374
629
|
|
|
375
630
|
// Get all scheduled messages
|
|
376
|
-
const allScheduled = await sdk.scheduledMessages.getScheduledMessages()
|
|
631
|
+
const allScheduled = await sdk.scheduledMessages.getScheduledMessages();
|
|
377
632
|
|
|
378
633
|
// Update scheduled message
|
|
379
|
-
await sdk.scheduledMessages.updateScheduledMessage(
|
|
380
|
-
|
|
381
|
-
})
|
|
634
|
+
await sdk.scheduledMessages.updateScheduledMessage("schedule-id", {
|
|
635
|
+
message: "Updated message",
|
|
636
|
+
});
|
|
382
637
|
|
|
383
638
|
// Delete scheduled message
|
|
384
|
-
await sdk.scheduledMessages.deleteScheduledMessage(
|
|
639
|
+
await sdk.scheduledMessages.deleteScheduledMessage("schedule-id");
|
|
385
640
|
```
|
|
386
641
|
|
|
387
642
|
### Server Information
|
|
388
643
|
|
|
389
644
|
```typescript
|
|
390
645
|
// Get server info
|
|
391
|
-
const serverInfo = await sdk.server.getServerInfo()
|
|
646
|
+
const serverInfo = await sdk.server.getServerInfo();
|
|
392
647
|
|
|
393
648
|
// Get message statistics
|
|
394
|
-
const stats = await sdk.server.getMessageStats()
|
|
649
|
+
const stats = await sdk.server.getMessageStats();
|
|
395
650
|
|
|
396
651
|
// Get server logs
|
|
397
|
-
const logs = await sdk.server.getServerLogs(100)
|
|
652
|
+
const logs = await sdk.server.getServerLogs(100);
|
|
398
653
|
|
|
399
654
|
// Get alerts
|
|
400
|
-
const alerts = await sdk.server.getAlerts()
|
|
655
|
+
const alerts = await sdk.server.getAlerts();
|
|
401
656
|
|
|
402
657
|
// Mark alerts as read
|
|
403
|
-
await sdk.server.markAlertAsRead([
|
|
658
|
+
await sdk.server.markAlertAsRead(["alert-id-1", "alert-id-2"]);
|
|
404
659
|
```
|
|
405
660
|
|
|
406
661
|
## Error Handling
|
|
407
662
|
|
|
408
663
|
```typescript
|
|
409
664
|
try {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
665
|
+
await sdk.messages.sendMessage({
|
|
666
|
+
chatGuid: "invalid-guid",
|
|
667
|
+
message: "Test",
|
|
668
|
+
});
|
|
414
669
|
} catch (error) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
670
|
+
if (error.response?.status === 404) {
|
|
671
|
+
console.error("Chat not found");
|
|
672
|
+
} else {
|
|
673
|
+
console.error("Send failed:", error.message);
|
|
674
|
+
}
|
|
420
675
|
}
|
|
421
676
|
```
|
|
422
677
|
|
|
@@ -424,8 +679,8 @@ try {
|
|
|
424
679
|
|
|
425
680
|
```typescript
|
|
426
681
|
interface ClientConfig {
|
|
427
|
-
|
|
428
|
-
|
|
682
|
+
serverUrl?: string; // Your subdomain: '{your-subdomain}.imsgd.photon.codes'
|
|
683
|
+
logLevel?: "debug" | "info" | "warn" | "error"; // Default: 'info'
|
|
429
684
|
}
|
|
430
685
|
```
|
|
431
686
|
|
|
@@ -435,21 +690,21 @@ interface ClientConfig {
|
|
|
435
690
|
|
|
436
691
|
```typescript
|
|
437
692
|
// Always disconnect when done
|
|
438
|
-
process.on(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
})
|
|
693
|
+
process.on("SIGINT", async () => {
|
|
694
|
+
await sdk.disconnect();
|
|
695
|
+
process.exit(0);
|
|
696
|
+
});
|
|
442
697
|
```
|
|
443
698
|
|
|
444
699
|
### Event Handling
|
|
445
700
|
|
|
446
701
|
```typescript
|
|
447
702
|
// Use specific event handlers
|
|
448
|
-
sdk.on(
|
|
449
|
-
sdk.on(
|
|
703
|
+
sdk.on("new-message", handleNewMessage);
|
|
704
|
+
sdk.on("error", handleError);
|
|
450
705
|
|
|
451
706
|
// Remove listeners when needed
|
|
452
|
-
sdk.off(
|
|
707
|
+
sdk.off("new-message", handleNewMessage);
|
|
453
708
|
```
|
|
454
709
|
|
|
455
710
|
### Performance Optimization
|
|
@@ -457,42 +712,202 @@ sdk.off('new-message', handleNewMessage)
|
|
|
457
712
|
```typescript
|
|
458
713
|
// Use pagination for large queries
|
|
459
714
|
const messages = await sdk.messages.getMessages({
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
})
|
|
715
|
+
chatGuid: "any;-;+1234567890",
|
|
716
|
+
limit: 100,
|
|
717
|
+
offset: 0,
|
|
718
|
+
});
|
|
464
719
|
|
|
465
720
|
// Clear processed message records (prevents memory leaks)
|
|
466
|
-
sdk.clearProcessedMessages(1000)
|
|
721
|
+
sdk.clearProcessedMessages(1000);
|
|
467
722
|
|
|
468
723
|
// Get processed message count
|
|
469
|
-
const processedCount = sdk.getProcessedMessageCount()
|
|
724
|
+
const processedCount = sdk.getProcessedMessageCount();
|
|
470
725
|
```
|
|
471
726
|
|
|
472
727
|
## Examples
|
|
473
728
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
729
|
+
The SDK includes comprehensive examples in the `examples/` directory. All examples can be run using Bun:
|
|
730
|
+
|
|
731
|
+
### Basic Examples
|
|
732
|
+
|
|
733
|
+
#### `demo-basic.ts` - Listen for Messages
|
|
734
|
+
|
|
735
|
+
Simple message listener demonstrating event handling.
|
|
736
|
+
|
|
737
|
+
```bash
|
|
738
|
+
bun run examples/demo-basic.ts
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
#### `message-send.ts` - Send a Message
|
|
742
|
+
|
|
743
|
+
Send a text message to a contact or chat.
|
|
744
|
+
|
|
745
|
+
```bash
|
|
746
|
+
CHAT_GUID="+1234567890" bun run examples/message-send.ts
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
#### `message-attachment.ts` - Send Files
|
|
750
|
+
|
|
751
|
+
Send images, videos, or other files as attachments.
|
|
752
|
+
|
|
753
|
+
```bash
|
|
754
|
+
CHAT_GUID="+1234567890" bun run examples/message-attachment.ts
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
#### `message-audio.ts` - Send Voice Messages
|
|
758
|
+
|
|
759
|
+
Send voice messages (audio attachments with special handling).
|
|
760
|
+
|
|
761
|
+
```bash
|
|
762
|
+
CHAT_GUID="+1234567890" AUDIO_FILE_PATH="/path/to/audio.m4a" bun run examples/message-audio.ts
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
### Advanced Examples
|
|
766
|
+
|
|
767
|
+
#### `message-reaction.ts` - Reactions (Tapbacks)
|
|
768
|
+
|
|
769
|
+
Add and remove reactions to messages.
|
|
770
|
+
|
|
771
|
+
```bash
|
|
772
|
+
CHAT_GUID="chat-guid" MESSAGE_GUID="message-guid" bun run examples/message-reaction.ts
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
#### `message-edit.ts` - Edit Messages
|
|
776
|
+
|
|
777
|
+
Edit a sent message. Requires macOS Ventura (13.0) or newer and Private API.
|
|
778
|
+
|
|
779
|
+
```bash
|
|
780
|
+
CHAT_GUID="chat-guid" bun run examples/message-edit.ts
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
#### `message-unsend.ts` - Unsend Messages
|
|
784
|
+
|
|
785
|
+
Unsend a message within 2 minutes of sending. Requires macOS Ventura (13.0) or newer and Private API.
|
|
786
|
+
|
|
787
|
+
```bash
|
|
788
|
+
CHAT_GUID="chat-guid" bun run examples/message-unsend.ts
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
#### `message-typing.ts` - Typing Indicators
|
|
792
|
+
|
|
793
|
+
Start and stop typing indicators in a chat. Requires Private API.
|
|
794
|
+
|
|
795
|
+
```bash
|
|
796
|
+
CHAT_GUID="chat-guid" bun run examples/message-typing.ts
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
#### `message-contact-card.ts` - Share Contact Cards
|
|
800
|
+
|
|
801
|
+
Share contact cards in chats. Requires macOS Big Sur (11.0) or newer and Private API.
|
|
802
|
+
|
|
803
|
+
```bash
|
|
804
|
+
CHAT_GUID="chat-guid" CONTACT_ADDRESS="email-or-phone" bun run examples/message-contact-card.ts
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
#### `message-reply-sticker.ts` - Send Stickers
|
|
808
|
+
|
|
809
|
+
Send stickers and multipart messages. Requires Private API.
|
|
810
|
+
|
|
811
|
+
```bash
|
|
812
|
+
CHAT_GUID="chat-guid" STICKER_PATH="path/to/image.jpg" bun run examples/message-reply-sticker.ts
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
#### `message-effects.ts` - Message Effects
|
|
816
|
+
|
|
817
|
+
Send messages with visual effects (confetti, fireworks, balloons, etc.). Requires Private API.
|
|
818
|
+
|
|
819
|
+
```bash
|
|
820
|
+
CHAT_GUID="chat-guid" bun run examples/message-effects.ts
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
#### `message-reply.ts` - Reply to Messages
|
|
824
|
+
|
|
825
|
+
Reply to a specific message in a chat.
|
|
826
|
+
|
|
827
|
+
```bash
|
|
828
|
+
CHAT_GUID="chat-guid" MESSAGE_GUID="message-guid" bun run examples/message-reply.ts
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
#### `chat-fetch.ts` - Fetch Chats
|
|
832
|
+
|
|
833
|
+
Retrieve and filter chats from the database.
|
|
834
|
+
|
|
835
|
+
```bash
|
|
836
|
+
bun run examples/chat-fetch.ts
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
#### `chat-group.ts` - Group Chat Management
|
|
840
|
+
|
|
841
|
+
List and monitor group chats, track membership changes.
|
|
842
|
+
|
|
843
|
+
```bash
|
|
844
|
+
bun run examples/chat-group.ts
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
#### `message-search.ts` - Search Messages
|
|
848
|
+
|
|
849
|
+
Search through message history with filtering options.
|
|
850
|
+
|
|
851
|
+
```bash
|
|
852
|
+
bun run examples/message-search.ts
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
#### `message-stats.ts` - Message Statistics
|
|
856
|
+
|
|
857
|
+
View message statistics, chat activity, and analytics.
|
|
858
|
+
|
|
859
|
+
```bash
|
|
860
|
+
bun run examples/message-stats.ts
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
#### `message-scheduled.ts` - Schedule Messages
|
|
864
|
+
|
|
865
|
+
Schedule one-time and recurring messages.
|
|
866
|
+
|
|
867
|
+
```bash
|
|
868
|
+
CHAT_GUID="+1234567890" bun run examples/message-scheduled.ts
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
#### `facetime-link.ts` - FaceTime Links
|
|
872
|
+
|
|
873
|
+
Create FaceTime links programmatically. Requires macOS Monterey (12.0) or newer and Private API.
|
|
874
|
+
|
|
875
|
+
```bash
|
|
876
|
+
bun run examples/facetime-link.ts
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
#### `findmy-friends.ts` - Find My Integration
|
|
880
|
+
|
|
881
|
+
Track friends and devices via Find My network.
|
|
882
|
+
|
|
883
|
+
```bash
|
|
884
|
+
bun run examples/findmy-friends.ts
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
#### `contact-list.ts` - Contact Access
|
|
888
|
+
|
|
889
|
+
Access and search macOS Contacts database.
|
|
890
|
+
|
|
891
|
+
```bash
|
|
892
|
+
bun run examples/contact-list.ts
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
#### `demo-advanced.ts` - Advanced Features
|
|
896
|
+
|
|
897
|
+
Demonstrates permissions checking, chat retrieval, and event monitoring.
|
|
898
|
+
|
|
899
|
+
```bash
|
|
900
|
+
bun run examples/demo-advanced.ts
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
#### `auto-reply-hey.ts` - Auto-Reply Example
|
|
904
|
+
|
|
905
|
+
Automatic reply example that responds to incoming messages.
|
|
906
|
+
|
|
907
|
+
```bash
|
|
908
|
+
bun run examples/auto-reply-hey.ts
|
|
909
|
+
```
|
|
495
910
|
|
|
496
911
|
## License
|
|
497
912
|
|
|
498
|
-
MIT License
|
|
913
|
+
MIT License
|
|
@@ -19,7 +19,6 @@ export declare class AttachmentModule {
|
|
|
19
19
|
width?: number;
|
|
20
20
|
quality?: number;
|
|
21
21
|
}): Promise<string>;
|
|
22
|
-
private sendAttachmentBase;
|
|
23
22
|
sendAttachment(options: SendAttachmentOptions): Promise<Message>;
|
|
24
23
|
sendSticker(options: SendStickerOptions): Promise<Message>;
|
|
25
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../modules/attachment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE1E,qBAAa,gBAAgB;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKrC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAKzC,kBAAkB,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,GACF,OAAO,CAAC,MAAM,CAAC;IAeZ,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrD,qBAAqB,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../modules/attachment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE1E,qBAAa,gBAAgB;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKrC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAKzC,kBAAkB,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,GACF,OAAO,CAAC,MAAM,CAAC;IAeZ,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrD,qBAAqB,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,MAAM,CAAC;IAYZ,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBhE,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBnE"}
|
|
@@ -51,24 +51,25 @@ export class AttachmentModule {
|
|
|
51
51
|
});
|
|
52
52
|
return response.data.data.blurhash;
|
|
53
53
|
}
|
|
54
|
-
async
|
|
54
|
+
async sendAttachment(options) {
|
|
55
55
|
const fileBuffer = await readFile(options.filePath);
|
|
56
56
|
const fileName = options.fileName || path.basename(options.filePath);
|
|
57
57
|
const form = new FormData();
|
|
58
58
|
form.append("chatGuid", options.chatGuid);
|
|
59
59
|
form.append("attachment", fileBuffer, fileName);
|
|
60
|
+
form.append("name", fileName);
|
|
60
61
|
form.append("tempGuid", randomUUID());
|
|
61
|
-
if (
|
|
62
|
-
form.append("
|
|
62
|
+
if (options.isAudioMessage !== undefined) {
|
|
63
|
+
form.append("isAudioMessage", options.isAudioMessage.toString());
|
|
64
|
+
if (options.isAudioMessage) {
|
|
65
|
+
form.append("method", "private-api");
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
68
|
const response = await this.http.post("/api/v1/message/attachment", form, {
|
|
65
69
|
headers: form.getHeaders(),
|
|
66
70
|
});
|
|
67
71
|
return response.data.data;
|
|
68
72
|
}
|
|
69
|
-
async sendAttachment(options) {
|
|
70
|
-
return this.sendAttachmentBase(options);
|
|
71
|
-
}
|
|
72
73
|
async sendSticker(options) {
|
|
73
74
|
const fileName = options.fileName || path.basename(options.filePath);
|
|
74
75
|
const form = new FormData();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../modules/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,QAAQ,MAAM,WAAW,CAAC;AAIjC,MAAM,OAAO,gBAAgB;IACzB,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,kBAAkB;QACpB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACjE,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAY;QAC5B,MA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,GAAG,MAAM,CAAA;KAAE,CAAC;IACxD,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@photon-ai/advanced-imessage-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Powerful TypeScript iMessage SDK with real-time message processing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"imessage",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"LICENSE"
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@biomejs/biome": "^2.3.3",
|
|
49
50
|
"@types/bun": "latest"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
@@ -58,10 +59,10 @@
|
|
|
58
59
|
"publish:npm": "npm publish --access public"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
|
-
"typescript": "^5"
|
|
62
|
+
"typescript": "^5.9.3"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"axios": "^1.13.
|
|
65
|
+
"axios": "^1.13.2",
|
|
65
66
|
"form-data": "^4.0.4",
|
|
66
67
|
"reflect-metadata": "^0.2.2",
|
|
67
68
|
"socket.io-client": "^4.8.1"
|