react-native-email-imap-smtp 0.1.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/EmailImapSmtp.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +121 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +117 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/emailimapsmtp/EmailImapSmtp.kt +1533 -0
- package/android/src/main/java/com/margelo/nitro/emailimapsmtp/EmailImapSmtpPackage.kt +22 -0
- package/ios/EmailImapSmtp.swift +5 -0
- package/lib/module/EmailImapSmtp.nitro.js +4 -0
- package/lib/module/EmailImapSmtp.nitro.js.map +1 -0
- package/lib/module/NativeEmailImapSmtp.js +14 -0
- package/lib/module/NativeEmailImapSmtp.js.map +1 -0
- package/lib/module/index.js +64 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native.js +227 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/web.js +107 -0
- package/lib/module/web.js.map +1 -0
- package/lib/module/windows.js +156 -0
- package/lib/module/windows.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EmailImapSmtp.nitro.d.ts +268 -0
- package/lib/typescript/src/EmailImapSmtp.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NativeEmailImapSmtp.d.ts +36 -0
- package/lib/typescript/src/NativeEmailImapSmtp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +33 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts +32 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +261 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/web.d.ts +32 -0
- package/lib/typescript/src/web.d.ts.map +1 -0
- package/lib/typescript/src/windows.d.ts +32 -0
- package/lib/typescript/src/windows.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JAppendResult.hpp +65 -0
- package/nitrogen/generated/android/c++/JAttachmentInfo.hpp +96 -0
- package/nitrogen/generated/android/c++/JConnectionConfig.hpp +94 -0
- package/nitrogen/generated/android/c++/JConnectionResult.hpp +73 -0
- package/nitrogen/generated/android/c++/JDeleteResult.hpp +87 -0
- package/nitrogen/generated/android/c++/JEmailAddress.hpp +61 -0
- package/nitrogen/generated/android/c++/JEmailBody.hpp +84 -0
- package/nitrogen/generated/android/c++/JEmailMessage.hpp +273 -0
- package/nitrogen/generated/android/c++/JFetchEmailsOptions.hpp +110 -0
- package/nitrogen/generated/android/c++/JFolderInfo.hpp +126 -0
- package/nitrogen/generated/android/c++/JFunc_void_IdleNotification.hpp +79 -0
- package/nitrogen/generated/android/c++/JHybridEmailImapSmtpSpec.cpp +697 -0
- package/nitrogen/generated/android/c++/JHybridEmailImapSmtpSpec.hpp +92 -0
- package/nitrogen/generated/android/c++/JIdleNotification.hpp +78 -0
- package/nitrogen/generated/android/c++/JImapServerInfo.hpp +84 -0
- package/nitrogen/generated/android/c++/JMailboxInfo.hpp +134 -0
- package/nitrogen/generated/android/c++/JMailboxListItem.hpp +92 -0
- package/nitrogen/generated/android/c++/JQuotaInfo.hpp +78 -0
- package/nitrogen/generated/android/c++/JSearchCriteria.hpp +187 -0
- package/nitrogen/generated/android/c++/JSearchHeader.hpp +61 -0
- package/nitrogen/generated/android/c++/JSendMailOptions.hpp +229 -0
- package/nitrogen/generated/android/c++/JSendMailResult.hpp +88 -0
- package/nitrogen/generated/android/c++/JSmtpAttachment.hpp +80 -0
- package/nitrogen/generated/android/c++/JSmtpConnectionConfig.hpp +98 -0
- package/nitrogen/generated/android/c++/JSmtpServerInfo.hpp +102 -0
- package/nitrogen/generated/android/c++/JVariant_ImapServerInfo_SmtpServerInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_ImapServerInfo_SmtpServerInfo.hpp +73 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AttachmentInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AttachmentInfo.hpp +75 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_EmailMessage.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_EmailMessage.hpp +83 -0
- package/nitrogen/generated/android/emailimapsmtp+autolinking.cmake +84 -0
- package/nitrogen/generated/android/emailimapsmtp+autolinking.gradle +27 -0
- package/nitrogen/generated/android/emailimapsmtpOnLoad.cpp +56 -0
- package/nitrogen/generated/android/emailimapsmtpOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/AppendResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/AttachmentInfo.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ConnectionConfig.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ConnectionResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/DeleteResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailAddress.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailBody.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailMessage.kt +156 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/FetchEmailsOptions.kt +116 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/FolderInfo.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Func_void_IdleNotification.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/HybridEmailImapSmtpSpec.kt +178 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/IdleNotification.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ImapServerInfo.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/MailboxInfo.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/MailboxListItem.kt +71 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/QuotaInfo.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SearchCriteria.kt +196 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SearchHeader.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SendMailOptions.kt +126 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SendMailResult.kt +86 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpAttachment.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpConnectionConfig.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpServerInfo.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_ImapServerInfo_SmtpServerInfo.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_NullType_AttachmentInfo.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_NullType_EmailMessage.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/emailimapsmtpOnLoad.kt +35 -0
- package/nitrogen/generated/ios/EmailImapSmtp+autolinking.rb +62 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Bridge.cpp +161 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Bridge.hpp +1132 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Umbrella.hpp +118 -0
- package/nitrogen/generated/ios/EmailImapSmtpAutolinking.mm +33 -0
- package/nitrogen/generated/ios/EmailImapSmtpAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridEmailImapSmtpSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridEmailImapSmtpSpecSwift.hpp +390 -0
- package/nitrogen/generated/ios/swift/AppendResult.swift +39 -0
- package/nitrogen/generated/ios/swift/AttachmentInfo.swift +113 -0
- package/nitrogen/generated/ios/swift/ConnectionConfig.swift +87 -0
- package/nitrogen/generated/ios/swift/ConnectionResult.swift +84 -0
- package/nitrogen/generated/ios/swift/DeleteResult.swift +64 -0
- package/nitrogen/generated/ios/swift/EmailAddress.swift +34 -0
- package/nitrogen/generated/ios/swift/EmailBody.swift +45 -0
- package/nitrogen/generated/ios/swift/EmailMessage.swift +184 -0
- package/nitrogen/generated/ios/swift/FetchEmailsOptions.swift +198 -0
- package/nitrogen/generated/ios/swift/FolderInfo.swift +81 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_AppendResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ConnectionResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_DeleteResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_IdleNotification.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_MailboxInfo.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_QuotaInfo.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_SendMailResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__AttachmentInfo_.swift +58 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__EmailMessage_.swift +58 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_AttachmentInfo_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_EmailMessage_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_FolderInfo_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_MailboxListItem_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridEmailImapSmtpSpec.swift +84 -0
- package/nitrogen/generated/ios/swift/HybridEmailImapSmtpSpec_cxx.swift +759 -0
- package/nitrogen/generated/ios/swift/IdleNotification.swift +93 -0
- package/nitrogen/generated/ios/swift/ImapServerInfo.swift +45 -0
- package/nitrogen/generated/ios/swift/MailboxInfo.swift +91 -0
- package/nitrogen/generated/ios/swift/MailboxListItem.swift +55 -0
- package/nitrogen/generated/ios/swift/QuotaInfo.swift +80 -0
- package/nitrogen/generated/ios/swift/SearchCriteria.swift +485 -0
- package/nitrogen/generated/ios/swift/SearchHeader.swift +34 -0
- package/nitrogen/generated/ios/swift/SendMailOptions.swift +310 -0
- package/nitrogen/generated/ios/swift/SendMailResult.swift +155 -0
- package/nitrogen/generated/ios/swift/SmtpAttachment.swift +80 -0
- package/nitrogen/generated/ios/swift/SmtpConnectionConfig.swift +105 -0
- package/nitrogen/generated/ios/swift/SmtpServerInfo.swift +51 -0
- package/nitrogen/generated/ios/swift/Variant_ImapServerInfo_SmtpServerInfo.swift +30 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_AttachmentInfo.swift +30 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_EmailMessage.swift +30 -0
- package/nitrogen/generated/shared/c++/AppendResult.hpp +91 -0
- package/nitrogen/generated/shared/c++/AttachmentInfo.hpp +121 -0
- package/nitrogen/generated/shared/c++/ConnectionConfig.hpp +120 -0
- package/nitrogen/generated/shared/c++/ConnectionResult.hpp +98 -0
- package/nitrogen/generated/shared/c++/DeleteResult.hpp +93 -0
- package/nitrogen/generated/shared/c++/EmailAddress.hpp +87 -0
- package/nitrogen/generated/shared/c++/EmailBody.hpp +92 -0
- package/nitrogen/generated/shared/c++/EmailMessage.hpp +177 -0
- package/nitrogen/generated/shared/c++/FetchEmailsOptions.hpp +136 -0
- package/nitrogen/generated/shared/c++/FolderInfo.hpp +116 -0
- package/nitrogen/generated/shared/c++/HybridEmailImapSmtpSpec.cpp +50 -0
- package/nitrogen/generated/shared/c++/HybridEmailImapSmtpSpec.hpp +145 -0
- package/nitrogen/generated/shared/c++/IdleNotification.hpp +104 -0
- package/nitrogen/generated/shared/c++/ImapServerInfo.hpp +92 -0
- package/nitrogen/generated/shared/c++/MailboxInfo.hpp +124 -0
- package/nitrogen/generated/shared/c++/MailboxListItem.hpp +100 -0
- package/nitrogen/generated/shared/c++/QuotaInfo.hpp +104 -0
- package/nitrogen/generated/shared/c++/SearchCriteria.hpp +203 -0
- package/nitrogen/generated/shared/c++/SearchHeader.hpp +87 -0
- package/nitrogen/generated/shared/c++/SendMailOptions.hpp +151 -0
- package/nitrogen/generated/shared/c++/SendMailResult.hpp +113 -0
- package/nitrogen/generated/shared/c++/SmtpAttachment.hpp +105 -0
- package/nitrogen/generated/shared/c++/SmtpConnectionConfig.hpp +124 -0
- package/nitrogen/generated/shared/c++/SmtpServerInfo.hpp +92 -0
- package/package.json +196 -0
- package/react-native.config.js +27 -0
- package/src/EmailImapSmtp.nitro.ts +333 -0
- package/src/NativeEmailImapSmtp.ts +100 -0
- package/src/index.tsx +166 -0
- package/src/native.ts +305 -0
- package/src/types.ts +328 -0
- package/src/web.ts +196 -0
- package/src/windows.ts +304 -0
- package/windows/EmailImapSmtp.cpp +735 -0
- package/windows/EmailImapSmtp.h +137 -0
- package/windows/EmailImapSmtpModule.cpp +10 -0
- package/windows/EmailImapSmtpModule.h +139 -0
- package/windows/EmailImapSmtpPackage.cpp +15 -0
- package/windows/EmailImapSmtpPackage.h +13 -0
- package/windows/ImapProtocol.cpp +1382 -0
- package/windows/ImapProtocol.h +97 -0
- package/windows/ProtocolDefs.h +300 -0
- package/windows/SmtpProtocol.cpp +334 -0
- package/windows/SmtpProtocol.h +36 -0
- package/windows/TlsSocket.cpp +818 -0
- package/windows/TlsSocket.h +87 -0
package/src/native.ts
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Native bridge — iOS (Swift) / Android (Kotlin) / Windows (C++)
|
|
3
|
+
// ============================================================
|
|
4
|
+
|
|
5
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
6
|
+
import type { EmailImapSmtp } from './EmailImapSmtp.nitro';
|
|
7
|
+
import type {
|
|
8
|
+
IMAPConfig,
|
|
9
|
+
SMTPConfig,
|
|
10
|
+
IMAPConnectionResult,
|
|
11
|
+
SMTPConnectionResult,
|
|
12
|
+
Mailbox,
|
|
13
|
+
MailboxStatus,
|
|
14
|
+
Folder,
|
|
15
|
+
Email,
|
|
16
|
+
Attachment,
|
|
17
|
+
FetchEmailsOptions,
|
|
18
|
+
SearchCriteria,
|
|
19
|
+
BatchResult,
|
|
20
|
+
IMAPNotification,
|
|
21
|
+
QuotaInfo,
|
|
22
|
+
AppendResult,
|
|
23
|
+
SendMailOptions,
|
|
24
|
+
SendMailResult,
|
|
25
|
+
} from './types';
|
|
26
|
+
|
|
27
|
+
let hybridObject: EmailImapSmtp | null = null;
|
|
28
|
+
|
|
29
|
+
function getHybridObject(): EmailImapSmtp {
|
|
30
|
+
if (!hybridObject) {
|
|
31
|
+
hybridObject =
|
|
32
|
+
NitroModules.createHybridObject<EmailImapSmtp>('EmailImapSmtp');
|
|
33
|
+
}
|
|
34
|
+
return hybridObject;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ─── IMAP ────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
export async function imapConnect(
|
|
40
|
+
config: IMAPConfig
|
|
41
|
+
): Promise<IMAPConnectionResult> {
|
|
42
|
+
const h = getHybridObject();
|
|
43
|
+
return h.imapConnect({
|
|
44
|
+
host: config.host,
|
|
45
|
+
port: config.port,
|
|
46
|
+
username: config.username,
|
|
47
|
+
password: config.password,
|
|
48
|
+
tls: config.tls ?? true,
|
|
49
|
+
authType: config.authType ?? 'password',
|
|
50
|
+
accessToken: config.accessToken,
|
|
51
|
+
timeout: config.timeout ?? 30000,
|
|
52
|
+
checkCertificate: config.checkCertificate ?? true,
|
|
53
|
+
debug: config.debug ?? false,
|
|
54
|
+
}) as Promise<IMAPConnectionResult>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function imapDisconnect(): Promise<void> {
|
|
58
|
+
return getHybridObject().imapDisconnect();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function imapListMailboxes(): Promise<Mailbox[]> {
|
|
62
|
+
return getHybridObject().imapListMailboxes() as unknown as Promise<Mailbox[]>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function imapSelectMailbox(
|
|
66
|
+
mailbox: string,
|
|
67
|
+
readOnly?: boolean
|
|
68
|
+
): Promise<MailboxStatus> {
|
|
69
|
+
return getHybridObject().imapSelectMailbox(
|
|
70
|
+
mailbox,
|
|
71
|
+
readOnly ?? false
|
|
72
|
+
) as unknown as Promise<MailboxStatus>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function imapRefreshMailbox(): Promise<MailboxStatus> {
|
|
76
|
+
return getHybridObject().imapRefreshMailbox() as unknown as Promise<MailboxStatus>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function imapFetchFolders(): Promise<Folder[]> {
|
|
80
|
+
return getHybridObject().imapFetchFolders() as unknown as Promise<Folder[]>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function imapCreateFolder(folderName: string): Promise<void> {
|
|
84
|
+
return getHybridObject().imapCreateFolder(folderName);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function imapDeleteFolder(folderName: string): Promise<void> {
|
|
88
|
+
return getHybridObject().imapDeleteFolder(folderName);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function imapRenameFolder(
|
|
92
|
+
oldName: string,
|
|
93
|
+
newName: string
|
|
94
|
+
): Promise<void> {
|
|
95
|
+
return getHybridObject().imapRenameFolder(oldName, newName);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function imapSubscribeFolder(folderName: string): Promise<void> {
|
|
99
|
+
return getHybridObject().imapSubscribeFolder(folderName);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function imapUnsubscribeFolder(folderName: string): Promise<void> {
|
|
103
|
+
return getHybridObject().imapUnsubscribeFolder(folderName);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function imapFetchEmails(
|
|
107
|
+
options: FetchEmailsOptions
|
|
108
|
+
): Promise<Email[]> {
|
|
109
|
+
const h = getHybridObject();
|
|
110
|
+
return h.imapFetchEmails({
|
|
111
|
+
from: options.from,
|
|
112
|
+
to: options.to,
|
|
113
|
+
rangeType: options.rangeType,
|
|
114
|
+
page: options.page,
|
|
115
|
+
pageSize: options.pageSize ?? 20,
|
|
116
|
+
since: options.since,
|
|
117
|
+
before: options.before,
|
|
118
|
+
mailbox: options.mailbox,
|
|
119
|
+
fetchBody: options.fetchBody ?? true,
|
|
120
|
+
fetchAttachments: options.fetchAttachments ?? false,
|
|
121
|
+
fetchFlags: options.fetchFlags ?? true,
|
|
122
|
+
fetchHeaders: options.fetchHeaders ?? true,
|
|
123
|
+
fetchFullContent: options.fetchFullContent ?? false,
|
|
124
|
+
maxBodySize: options.maxBodySize ?? 0,
|
|
125
|
+
}) as unknown as Promise<Email[]>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function imapFetchEmailByUID(uid: number): Promise<Email | null> {
|
|
129
|
+
return getHybridObject().imapFetchEmailByUID(
|
|
130
|
+
uid
|
|
131
|
+
) as unknown as Promise<Email | null>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function imapSearchEmails(
|
|
135
|
+
criteria: SearchCriteria
|
|
136
|
+
): Promise<Email[]> {
|
|
137
|
+
const h = getHybridObject();
|
|
138
|
+
return h.imapSearchEmails({
|
|
139
|
+
text: criteria.text,
|
|
140
|
+
subject: criteria.subject,
|
|
141
|
+
from: criteria.from,
|
|
142
|
+
to: criteria.to,
|
|
143
|
+
body: criteria.body,
|
|
144
|
+
since: criteria.since,
|
|
145
|
+
before: criteria.before,
|
|
146
|
+
on: criteria.on,
|
|
147
|
+
sentSince: criteria.sentSince,
|
|
148
|
+
sentBefore: criteria.sentBefore,
|
|
149
|
+
flagged: criteria.flagged,
|
|
150
|
+
seen: criteria.seen,
|
|
151
|
+
answered: criteria.answered,
|
|
152
|
+
draft: criteria.draft,
|
|
153
|
+
deleted: criteria.deleted,
|
|
154
|
+
junk: criteria.junk,
|
|
155
|
+
hasAttachment: criteria.hasAttachment,
|
|
156
|
+
uids: criteria.uids,
|
|
157
|
+
header: criteria.header,
|
|
158
|
+
larger: criteria.larger,
|
|
159
|
+
smaller: criteria.smaller,
|
|
160
|
+
mailbox: criteria.mailbox,
|
|
161
|
+
sortOrder: criteria.sortOrder ?? 'desc',
|
|
162
|
+
limit: criteria.limit ?? 0,
|
|
163
|
+
fetchBody: criteria.fetchBody ?? true,
|
|
164
|
+
fetchAttachments: criteria.fetchAttachments ?? false,
|
|
165
|
+
fetchFlags: criteria.fetchFlags ?? true,
|
|
166
|
+
fetchHeaders: criteria.fetchHeaders ?? true,
|
|
167
|
+
fetchFullContent: criteria.fetchFullContent ?? false,
|
|
168
|
+
maxBodySize: criteria.maxBodySize ?? 0,
|
|
169
|
+
}) as unknown as Promise<Email[]>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export async function imapMarkAsRead(
|
|
173
|
+
uids: number[],
|
|
174
|
+
silent?: boolean
|
|
175
|
+
): Promise<void> {
|
|
176
|
+
return getHybridObject().imapMarkAsRead(uids, silent ?? true);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export async function imapMarkAsFlagged(
|
|
180
|
+
uids: number[],
|
|
181
|
+
flagged: boolean
|
|
182
|
+
): Promise<void> {
|
|
183
|
+
return getHybridObject().imapMarkAsFlagged(uids, flagged);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export async function imapMoveEmails(
|
|
187
|
+
uids: number[],
|
|
188
|
+
destinationMailbox: string
|
|
189
|
+
): Promise<void> {
|
|
190
|
+
return getHybridObject().imapMoveEmails(uids, destinationMailbox);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export async function imapCopyEmails(
|
|
194
|
+
uids: number[],
|
|
195
|
+
destinationMailbox: string
|
|
196
|
+
): Promise<void> {
|
|
197
|
+
return getHybridObject().imapCopyEmails(uids, destinationMailbox);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function imapDeleteEmails(uids: number[]): Promise<BatchResult> {
|
|
201
|
+
return getHybridObject().imapDeleteEmails(
|
|
202
|
+
uids
|
|
203
|
+
) as unknown as Promise<BatchResult>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export async function imapExpunge(): Promise<void> {
|
|
207
|
+
return getHybridObject().imapExpunge();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export async function imapFetchAttachments(
|
|
211
|
+
uid: number,
|
|
212
|
+
partId: string
|
|
213
|
+
): Promise<Attachment | null> {
|
|
214
|
+
return getHybridObject().imapFetchAttachments(uid, partId);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export async function imapFetchAllAttachments(
|
|
218
|
+
uid: number
|
|
219
|
+
): Promise<Attachment[]> {
|
|
220
|
+
return getHybridObject().imapFetchAllAttachments(uid);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function imapIdle(
|
|
224
|
+
callback: (notification: IMAPNotification) => void
|
|
225
|
+
): Promise<void> {
|
|
226
|
+
return getHybridObject().imapIdle(callback as any);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export async function imapStopIdle(): Promise<void> {
|
|
230
|
+
return getHybridObject().imapStopIdle();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export async function imapGetQuota(root?: string): Promise<QuotaInfo> {
|
|
234
|
+
return getHybridObject().imapGetQuota(root);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export async function imapAppendMessage(
|
|
238
|
+
mailbox: string,
|
|
239
|
+
rawMimeData: ArrayBuffer,
|
|
240
|
+
flags?: string[]
|
|
241
|
+
): Promise<AppendResult> {
|
|
242
|
+
return getHybridObject().imapAppendMessage(mailbox, rawMimeData, flags);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ─── SMTP ────────────────────────────────────────────────────
|
|
246
|
+
|
|
247
|
+
export async function smtpConnect(
|
|
248
|
+
config: SMTPConfig
|
|
249
|
+
): Promise<SMTPConnectionResult> {
|
|
250
|
+
const h = getHybridObject();
|
|
251
|
+
return h.smtpConnect({
|
|
252
|
+
host: config.host,
|
|
253
|
+
port: config.port,
|
|
254
|
+
username: config.username,
|
|
255
|
+
password: config.password,
|
|
256
|
+
tls: config.tls ?? true,
|
|
257
|
+
authType: config.authType ?? 'password',
|
|
258
|
+
accessToken: config.accessToken,
|
|
259
|
+
timeout: config.timeout ?? 30000,
|
|
260
|
+
checkCertificate: config.checkCertificate ?? true,
|
|
261
|
+
helloName: config.helloName,
|
|
262
|
+
debug: config.debug ?? false,
|
|
263
|
+
}) as Promise<SMTPConnectionResult>;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export async function smtpDisconnect(): Promise<void> {
|
|
267
|
+
return getHybridObject().smtpDisconnect();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export async function smtpSendMail(
|
|
271
|
+
options: SendMailOptions
|
|
272
|
+
): Promise<SendMailResult> {
|
|
273
|
+
const h = getHybridObject();
|
|
274
|
+
return h.smtpSendMail({
|
|
275
|
+
from: { name: options.from.name, email: options.from.email },
|
|
276
|
+
to: options.to.map((a) => ({ name: a.name, email: a.email })),
|
|
277
|
+
cc: options.cc?.map((a) => ({ name: a.name, email: a.email })),
|
|
278
|
+
bcc: options.bcc?.map((a) => ({ name: a.name, email: a.email })),
|
|
279
|
+
replyTo: options.replyTo?.map((a) => ({ name: a.name, email: a.email })),
|
|
280
|
+
subject: options.subject,
|
|
281
|
+
textBody: options.textBody,
|
|
282
|
+
htmlBody: options.htmlBody,
|
|
283
|
+
attachments: options.attachments?.map((a) => ({
|
|
284
|
+
filename: a.filename,
|
|
285
|
+
mimeType: a.mimeType,
|
|
286
|
+
data: a.data,
|
|
287
|
+
inline: a.inline ?? false,
|
|
288
|
+
contentId: a.contentId,
|
|
289
|
+
disposition: a.disposition,
|
|
290
|
+
})),
|
|
291
|
+
priority: options.priority,
|
|
292
|
+
headers: options.headers,
|
|
293
|
+
inReplyTo: options.inReplyTo,
|
|
294
|
+
references: options.references,
|
|
295
|
+
readReceiptTo: options.readReceiptTo
|
|
296
|
+
? { name: options.readReceiptTo.name, email: options.readReceiptTo.email }
|
|
297
|
+
: undefined,
|
|
298
|
+
charset: options.charset ?? 'UTF-8',
|
|
299
|
+
encoding: options.encoding,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export async function smtpVerifyConnection(): Promise<boolean> {
|
|
304
|
+
return getHybridObject().smtpVerifyConnection();
|
|
305
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// react-native-email-imap-smtp — Shared Type Definitions
|
|
3
|
+
// ============================================================
|
|
4
|
+
|
|
5
|
+
// ─── Auth & Connection ───────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
export type AuthType = 'password' | 'oauth2' | 'none';
|
|
8
|
+
export type ConnectionType = 'tls' | 'starttls' | 'plain';
|
|
9
|
+
|
|
10
|
+
export interface IMAPConfig {
|
|
11
|
+
host: string;
|
|
12
|
+
port: number;
|
|
13
|
+
username: string;
|
|
14
|
+
password: string;
|
|
15
|
+
tls?: boolean;
|
|
16
|
+
authType?: AuthType;
|
|
17
|
+
accessToken?: string;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
checkCertificate?: boolean;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SMTPConfig {
|
|
24
|
+
host: string;
|
|
25
|
+
port: number;
|
|
26
|
+
username: string;
|
|
27
|
+
password: string;
|
|
28
|
+
tls?: boolean;
|
|
29
|
+
authType?: AuthType;
|
|
30
|
+
accessToken?: string;
|
|
31
|
+
timeout?: number;
|
|
32
|
+
checkCertificate?: boolean;
|
|
33
|
+
helloName?: string;
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface IMAPConnectionResult {
|
|
38
|
+
success: boolean;
|
|
39
|
+
serverInfo?: {
|
|
40
|
+
serverName: string;
|
|
41
|
+
capabilities: string[];
|
|
42
|
+
isCompressed: boolean;
|
|
43
|
+
};
|
|
44
|
+
error?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface SMTPConnectionResult {
|
|
48
|
+
success: boolean;
|
|
49
|
+
serverInfo?: {
|
|
50
|
+
serverName: string;
|
|
51
|
+
capabilities: string[];
|
|
52
|
+
supportedAuthMethods: string[];
|
|
53
|
+
};
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ─── Mailbox / Folder ───────────────────────────────────────
|
|
58
|
+
|
|
59
|
+
export type MailboxFlag = string;
|
|
60
|
+
|
|
61
|
+
export interface Mailbox {
|
|
62
|
+
name: string;
|
|
63
|
+
path: string;
|
|
64
|
+
delimiter: string;
|
|
65
|
+
flags: MailboxFlag[];
|
|
66
|
+
subscribed: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface Folder {
|
|
70
|
+
name: string;
|
|
71
|
+
path: string;
|
|
72
|
+
delimiter: string;
|
|
73
|
+
parent: string;
|
|
74
|
+
children: string[];
|
|
75
|
+
flags: MailboxFlag[];
|
|
76
|
+
subscribed: boolean;
|
|
77
|
+
messageCount: number;
|
|
78
|
+
unseenCount: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ─── Mailbox Status ─────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
export interface MailboxStatus {
|
|
84
|
+
name: string;
|
|
85
|
+
path: string;
|
|
86
|
+
uidNext: number;
|
|
87
|
+
uidValidity: number;
|
|
88
|
+
messageCount: number;
|
|
89
|
+
recentCount: number;
|
|
90
|
+
unseenCount: number;
|
|
91
|
+
firstUnseenUid: number;
|
|
92
|
+
highestModSeq?: number;
|
|
93
|
+
flags: string[];
|
|
94
|
+
permanentFlags: string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ─── Email ──────────────────────────────────────────────────
|
|
98
|
+
|
|
99
|
+
export type EmailFlag =
|
|
100
|
+
| 'seen'
|
|
101
|
+
| 'answered'
|
|
102
|
+
| 'flagged'
|
|
103
|
+
| 'deleted'
|
|
104
|
+
| 'draft'
|
|
105
|
+
| 'recent'
|
|
106
|
+
| 'junk'
|
|
107
|
+
| 'forwarded';
|
|
108
|
+
|
|
109
|
+
export type EmailPriority = 'low' | 'normal' | 'high';
|
|
110
|
+
|
|
111
|
+
export interface EmailAddress {
|
|
112
|
+
name: string;
|
|
113
|
+
email: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface Attachment {
|
|
117
|
+
filename: string;
|
|
118
|
+
mimeType: string;
|
|
119
|
+
partId: string;
|
|
120
|
+
size: number;
|
|
121
|
+
data: ArrayBuffer;
|
|
122
|
+
contentId?: string;
|
|
123
|
+
inline: boolean;
|
|
124
|
+
charset?: string;
|
|
125
|
+
contentDisposition: string;
|
|
126
|
+
/** 附件缓存在本地的文件路径(如果有),避免大附件全部加载到内存 */
|
|
127
|
+
localPath?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface EmailBody {
|
|
131
|
+
text?: string;
|
|
132
|
+
html?: string;
|
|
133
|
+
embeddedAttachments: Attachment[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ThreadInfo {
|
|
137
|
+
threadId: string;
|
|
138
|
+
parentMessageId: string | null;
|
|
139
|
+
depth: number;
|
|
140
|
+
children: ThreadInfo[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface Email {
|
|
144
|
+
uid: number;
|
|
145
|
+
sequenceNumber: number;
|
|
146
|
+
subject: string;
|
|
147
|
+
from: EmailAddress;
|
|
148
|
+
to: EmailAddress[];
|
|
149
|
+
cc: EmailAddress[];
|
|
150
|
+
bcc: EmailAddress[];
|
|
151
|
+
replyTo: EmailAddress[];
|
|
152
|
+
date: string;
|
|
153
|
+
receivedDate: string;
|
|
154
|
+
body: EmailBody;
|
|
155
|
+
attachments: Attachment[];
|
|
156
|
+
flags: EmailFlag[];
|
|
157
|
+
headers: Record<string, string>;
|
|
158
|
+
size: number;
|
|
159
|
+
messageId: string;
|
|
160
|
+
inReplyTo?: string;
|
|
161
|
+
references?: string;
|
|
162
|
+
priority: EmailPriority;
|
|
163
|
+
isEncrypted: boolean;
|
|
164
|
+
mimeType: string;
|
|
165
|
+
charset: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ─── Fetch Options ──────────────────────────────────────────
|
|
169
|
+
|
|
170
|
+
export interface FetchOptions {
|
|
171
|
+
fetchBody?: boolean;
|
|
172
|
+
fetchAttachments?: boolean;
|
|
173
|
+
fetchFlags?: boolean;
|
|
174
|
+
fetchHeaders?: boolean;
|
|
175
|
+
fetchFullContent?: boolean;
|
|
176
|
+
maxBodySize?: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface FetchEmailsOptions {
|
|
180
|
+
// 范围模式
|
|
181
|
+
from?: number;
|
|
182
|
+
to?: number;
|
|
183
|
+
rangeType?: 'uid' | 'sequence';
|
|
184
|
+
// 分页模式
|
|
185
|
+
page?: number;
|
|
186
|
+
pageSize?: number;
|
|
187
|
+
// 时间模式
|
|
188
|
+
since?: string;
|
|
189
|
+
before?: string;
|
|
190
|
+
// 通用
|
|
191
|
+
mailbox?: string;
|
|
192
|
+
// 获取选项(扁平化)
|
|
193
|
+
fetchBody?: boolean;
|
|
194
|
+
fetchAttachments?: boolean;
|
|
195
|
+
fetchFlags?: boolean;
|
|
196
|
+
fetchHeaders?: boolean;
|
|
197
|
+
fetchFullContent?: boolean;
|
|
198
|
+
maxBodySize?: number;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ─── Search ─────────────────────────────────────────────────
|
|
202
|
+
|
|
203
|
+
export interface SearchCriteria {
|
|
204
|
+
text?: string;
|
|
205
|
+
subject?: string;
|
|
206
|
+
from?: string;
|
|
207
|
+
to?: string;
|
|
208
|
+
body?: string;
|
|
209
|
+
since?: string;
|
|
210
|
+
before?: string;
|
|
211
|
+
on?: string;
|
|
212
|
+
sentSince?: string;
|
|
213
|
+
sentBefore?: string;
|
|
214
|
+
flagged?: boolean;
|
|
215
|
+
seen?: boolean;
|
|
216
|
+
answered?: boolean;
|
|
217
|
+
draft?: boolean;
|
|
218
|
+
deleted?: boolean;
|
|
219
|
+
junk?: boolean;
|
|
220
|
+
hasAttachment?: boolean;
|
|
221
|
+
uids?: number[];
|
|
222
|
+
header?: { key: string; value: string };
|
|
223
|
+
larger?: number;
|
|
224
|
+
smaller?: number;
|
|
225
|
+
mailbox?: string;
|
|
226
|
+
sortOrder?: 'asc' | 'desc';
|
|
227
|
+
limit?: number;
|
|
228
|
+
// 获取选项(扁平化)
|
|
229
|
+
fetchBody?: boolean;
|
|
230
|
+
fetchAttachments?: boolean;
|
|
231
|
+
fetchFlags?: boolean;
|
|
232
|
+
fetchHeaders?: boolean;
|
|
233
|
+
fetchFullContent?: boolean;
|
|
234
|
+
maxBodySize?: number;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ─── Send Mail ──────────────────────────────────────────────
|
|
238
|
+
|
|
239
|
+
export interface SendAttachment {
|
|
240
|
+
filename: string;
|
|
241
|
+
mimeType: string;
|
|
242
|
+
data: ArrayBuffer;
|
|
243
|
+
inline?: boolean;
|
|
244
|
+
contentId?: string;
|
|
245
|
+
disposition?: 'attachment' | 'inline';
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface SendMailOptions {
|
|
249
|
+
from: EmailAddress;
|
|
250
|
+
to: EmailAddress[];
|
|
251
|
+
cc?: EmailAddress[];
|
|
252
|
+
bcc?: EmailAddress[];
|
|
253
|
+
replyTo?: EmailAddress[];
|
|
254
|
+
subject: string;
|
|
255
|
+
textBody?: string;
|
|
256
|
+
htmlBody?: string;
|
|
257
|
+
attachments?: SendAttachment[];
|
|
258
|
+
priority?: EmailPriority;
|
|
259
|
+
headers?: Record<string, string>;
|
|
260
|
+
inReplyTo?: string;
|
|
261
|
+
references?: string;
|
|
262
|
+
readReceiptTo?: EmailAddress;
|
|
263
|
+
charset?: string;
|
|
264
|
+
encoding?: '7bit' | '8bit' | 'base64' | 'quoted-printable';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface SendMailResult {
|
|
268
|
+
success: boolean;
|
|
269
|
+
messageId?: string;
|
|
270
|
+
date?: string;
|
|
271
|
+
serverResponseCode?: number;
|
|
272
|
+
rawMimeData?: ArrayBuffer;
|
|
273
|
+
queueId?: string;
|
|
274
|
+
error?: string;
|
|
275
|
+
retryable?: boolean;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ─── IDLE ───────────────────────────────────────────────────
|
|
279
|
+
|
|
280
|
+
export interface IMAPNotification {
|
|
281
|
+
type:
|
|
282
|
+
| 'newMessage'
|
|
283
|
+
| 'messageDeleted'
|
|
284
|
+
| 'messageFlagged'
|
|
285
|
+
| 'mailboxChanged'
|
|
286
|
+
| 'connectionLost';
|
|
287
|
+
mailbox: string;
|
|
288
|
+
uid?: number;
|
|
289
|
+
flag?: string;
|
|
290
|
+
messageCount?: number;
|
|
291
|
+
timestamp: number;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// ─── Quota ──────────────────────────────────────────────────
|
|
295
|
+
|
|
296
|
+
export interface QuotaInfo {
|
|
297
|
+
storageUsed: number;
|
|
298
|
+
storageLimit: number;
|
|
299
|
+
storageUnit: string;
|
|
300
|
+
messagesUsed?: number;
|
|
301
|
+
messagesLimit?: number;
|
|
302
|
+
root: string;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ─── Batch & Append Results ─────────────────────────────────
|
|
306
|
+
|
|
307
|
+
export interface BatchResult {
|
|
308
|
+
success: number[];
|
|
309
|
+
failed: number[];
|
|
310
|
+
error?: string;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface AppendResult {
|
|
314
|
+
uid: number;
|
|
315
|
+
uidValidity: number;
|
|
316
|
+
date: string;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ─── Error ──────────────────────────────────────────────────
|
|
320
|
+
|
|
321
|
+
export interface EmailError {
|
|
322
|
+
code: string;
|
|
323
|
+
message: string;
|
|
324
|
+
retryable: boolean;
|
|
325
|
+
serverResponse?: string;
|
|
326
|
+
originalResponse?: string;
|
|
327
|
+
details?: any;
|
|
328
|
+
}
|