mailisk 2.2.1 → 2.2.3

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.
Files changed (151) hide show
  1. package/.github/workflows/test.yml +0 -1
  2. package/README.md +4 -0
  3. package/dist/index.d.mts +338 -0
  4. package/dist/index.js +96 -5
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +89 -2
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +9 -6
  9. package/private/dist/private/index.js +0 -28
  10. package/private/dist/private/index.js.map +0 -1
  11. package/private/dist/src/mailisk.interfaces.js +0 -3
  12. package/private/dist/src/mailisk.interfaces.js.map +0 -1
  13. package/private/dist/src/mailisk.js +0 -168
  14. package/private/dist/src/mailisk.js.map +0 -1
  15. package/private/index.ts +0 -17
  16. package/private/node_modules/.package-lock.json +0 -44
  17. package/private/node_modules/typescript/LICENSE.txt +0 -55
  18. package/private/node_modules/typescript/README.md +0 -50
  19. package/private/node_modules/typescript/SECURITY.md +0 -41
  20. package/private/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
  21. package/private/node_modules/typescript/bin/tsc +0 -2
  22. package/private/node_modules/typescript/bin/tsserver +0 -2
  23. package/private/node_modules/typescript/lib/_tsc.js +0 -133818
  24. package/private/node_modules/typescript/lib/_tsserver.js +0 -659
  25. package/private/node_modules/typescript/lib/_typingsInstaller.js +0 -222
  26. package/private/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
  27. package/private/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
  28. package/private/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
  29. package/private/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
  30. package/private/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
  31. package/private/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
  32. package/private/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
  33. package/private/node_modules/typescript/lib/lib.d.ts +0 -22
  34. package/private/node_modules/typescript/lib/lib.decorators.d.ts +0 -384
  35. package/private/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -22
  36. package/private/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -41
  37. package/private/node_modules/typescript/lib/lib.dom.d.ts +0 -39429
  38. package/private/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -571
  39. package/private/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -147
  40. package/private/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -597
  41. package/private/node_modules/typescript/lib/lib.es2015.d.ts +0 -28
  42. package/private/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -77
  43. package/private/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -605
  44. package/private/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -81
  45. package/private/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -128
  46. package/private/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -144
  47. package/private/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -46
  48. package/private/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
  49. package/private/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -116
  50. package/private/node_modules/typescript/lib/lib.es2016.d.ts +0 -21
  51. package/private/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -23
  52. package/private/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -31
  53. package/private/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -21
  54. package/private/node_modules/typescript/lib/lib.es2017.d.ts +0 -26
  55. package/private/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -31
  56. package/private/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -23
  57. package/private/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -44
  58. package/private/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -49
  59. package/private/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -135
  60. package/private/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -45
  61. package/private/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -53
  62. package/private/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -77
  63. package/private/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -53
  64. package/private/node_modules/typescript/lib/lib.es2018.d.ts +0 -24
  65. package/private/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -24
  66. package/private/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -83
  67. package/private/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -30
  68. package/private/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -37
  69. package/private/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -79
  70. package/private/node_modules/typescript/lib/lib.es2019.d.ts +0 -24
  71. package/private/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -24
  72. package/private/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -23
  73. package/private/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -33
  74. package/private/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -37
  75. package/private/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -24
  76. package/private/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -765
  77. package/private/node_modules/typescript/lib/lib.es2020.d.ts +0 -27
  78. package/private/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -42
  79. package/private/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -24
  80. package/private/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -474
  81. package/private/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -28
  82. package/private/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -47
  83. package/private/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -99
  84. package/private/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -44
  85. package/private/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
  86. package/private/node_modules/typescript/lib/lib.es2021.d.ts +0 -23
  87. package/private/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -24
  88. package/private/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -166
  89. package/private/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -48
  90. package/private/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -33
  91. package/private/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -78
  92. package/private/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -121
  93. package/private/node_modules/typescript/lib/lib.es2022.d.ts +0 -25
  94. package/private/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -75
  95. package/private/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -24
  96. package/private/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -145
  97. package/private/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -26
  98. package/private/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -39
  99. package/private/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -25
  100. package/private/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -924
  101. package/private/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -21
  102. package/private/node_modules/typescript/lib/lib.es2023.d.ts +0 -22
  103. package/private/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -24
  104. package/private/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -56
  105. package/private/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -65
  106. package/private/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -29
  107. package/private/node_modules/typescript/lib/lib.es2024.d.ts +0 -26
  108. package/private/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -24
  109. package/private/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -29
  110. package/private/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -35
  111. package/private/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -25
  112. package/private/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -68
  113. package/private/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -29
  114. package/private/node_modules/typescript/lib/lib.es5.d.ts +0 -4601
  115. package/private/node_modules/typescript/lib/lib.es6.d.ts +0 -23
  116. package/private/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -35
  117. package/private/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -96
  118. package/private/node_modules/typescript/lib/lib.esnext.d.ts +0 -29
  119. package/private/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -28
  120. package/private/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -193
  121. package/private/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -24
  122. package/private/node_modules/typescript/lib/lib.esnext.float16.d.ts +0 -445
  123. package/private/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -24
  124. package/private/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -21
  125. package/private/node_modules/typescript/lib/lib.esnext.iterator.d.ts +0 -148
  126. package/private/node_modules/typescript/lib/lib.esnext.promise.d.ts +0 -34
  127. package/private/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -25
  128. package/private/node_modules/typescript/lib/lib.scripthost.d.ts +0 -322
  129. package/private/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -41
  130. package/private/node_modules/typescript/lib/lib.webworker.d.ts +0 -13150
  131. package/private/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -23
  132. package/private/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -340
  133. package/private/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
  134. package/private/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
  135. package/private/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
  136. package/private/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
  137. package/private/node_modules/typescript/lib/tsc.js +0 -8
  138. package/private/node_modules/typescript/lib/tsserver.js +0 -8
  139. package/private/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
  140. package/private/node_modules/typescript/lib/tsserverlibrary.js +0 -21
  141. package/private/node_modules/typescript/lib/typesMap.json +0 -497
  142. package/private/node_modules/typescript/lib/typescript.d.ts +0 -11437
  143. package/private/node_modules/typescript/lib/typescript.js +0 -200276
  144. package/private/node_modules/typescript/lib/typingsInstaller.js +0 -8
  145. package/private/node_modules/typescript/lib/watchGuard.js +0 -53
  146. package/private/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
  147. package/private/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
  148. package/private/node_modules/typescript/package.json +0 -120
  149. package/private/package-lock.json +0 -53
  150. package/private/package.json +0 -17
  151. package/private/tsconfig.json +0 -103
package/dist/index.mjs CHANGED
@@ -5,6 +5,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
5
5
  import axios from "axios";
6
6
  import nodemailer from "nodemailer";
7
7
  var MailiskClient = class {
8
+ static {
9
+ __name(this, "MailiskClient");
10
+ }
8
11
  constructor({ apiKey, baseUrl, auth }) {
9
12
  this.axiosInstance = axios.create({
10
13
  headers: {
@@ -15,6 +18,15 @@ var MailiskClient = class {
15
18
  });
16
19
  }
17
20
  axiosInstance;
21
+ /**
22
+ * Search SMS messages sent to a phone number.
23
+ *
24
+ * @example
25
+ * Search for SMS messages sent to a phone number
26
+ * ```typescript
27
+ * const { data: smsMessages } = await client.searchSmsMessages("1234567890");
28
+ * ```
29
+ */
18
30
  async searchSmsMessages(phoneNumber, params, config) {
19
31
  let _params = { ...params };
20
32
  if (params?.from_date === void 0 || params?.from_date === null) {
@@ -40,15 +52,43 @@ var MailiskClient = class {
40
52
  params: requestParams
41
53
  })).data;
42
54
  }
55
+ /**
56
+ * List all SMS phone numbers associated with the current account.
57
+ *
58
+ * @example
59
+ * List all SMS phone numbers
60
+ * ```typescript
61
+ * const { data: smsNumbers } = await client.listSmsNumbers();
62
+ * ```
63
+ */
43
64
  async listSmsNumbers() {
44
65
  return (await this.axiosInstance.get("api/sms/numbers")).data;
45
66
  }
46
67
  async sendVirtualSms(params) {
47
68
  return (await this.axiosInstance.post("api/sms/virtual", params)).data;
48
69
  }
70
+ /**
71
+ * List all namespaces that belong to the current account (API key).
72
+ */
49
73
  async listNamespaces() {
50
74
  return (await this.axiosInstance.get("api/namespaces")).data;
51
75
  }
76
+ /**
77
+ * Send an email using the Virtual SMTP.
78
+ *
79
+ * These emails can only be sent to valid Mailisk namespaces, i.e. emails that end in @mynamespace.mailisk.net
80
+ *
81
+ * @example
82
+ * For example, sending a test email:
83
+ * ```typescript
84
+ * client.sendVirtualEmail(namespace, {
85
+ * from: "test@example.com",
86
+ * to: `john@${namespace}.mailisk.net`,
87
+ * subject: "This is a test",
88
+ * text: "Testing",
89
+ * });
90
+ * ```
91
+ */
52
92
  async sendVirtualEmail(namespace, params) {
53
93
  const smtpSettings = await this.getSmtpSettings(namespace);
54
94
  const transport = nodemailer.createTransport({
@@ -72,10 +112,42 @@ var MailiskClient = class {
72
112
  });
73
113
  transport.close();
74
114
  }
115
+ /**
116
+ * Search inbox of a namespace.
117
+ *
118
+ * By default, this calls the api using the `wait` flag. This means the call won't timeout until at least one email is received or 5 minutes pass.
119
+ * It also uses a default `from_timestamp` of **current timestamp - 15 minutes**. This means that older emails will be ignored.
120
+ *
121
+ * Both of these settings can be overriden by passing them in the `params` object.
122
+ *
123
+ * @example
124
+ * Get the latest emails
125
+ * ```typescript
126
+ * const { data: emails } = await client.searchInbox(namespace);
127
+ * ```
128
+ *
129
+ * @example
130
+ * Get the latest emails for a specific email address
131
+ * ```typescript
132
+ * const { data: emails } = await client.searchInbox(namespace, {
133
+ * to_addr_prefix: 'john@mynamespace.mailisk.net'
134
+ * });
135
+ * ```
136
+ *
137
+ * @example
138
+ * Get the last 20 emails in the namespace
139
+ * ```typescript
140
+ * const { data: emails } = await mailisk.searchInbox(namespace, {
141
+ * wait: false,
142
+ * from_timestamp: 0,
143
+ * limit: 20
144
+ * });
145
+ * ```
146
+ */
75
147
  async searchInbox(namespace, params, config) {
76
148
  let _params = { ...params };
77
149
  if (params?.from_timestamp === void 0 || params?.from_timestamp === null) {
78
- _params.from_timestamp = Math.floor(new Date().getTime() / 1e3) - 15 * 60;
150
+ _params.from_timestamp = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - 15 * 60;
79
151
  }
80
152
  if (params?.wait !== false) {
81
153
  _params.wait = true;
@@ -92,6 +164,9 @@ var MailiskClient = class {
92
164
  params: _params
93
165
  })).data;
94
166
  }
167
+ /**
168
+ * Get the SMTP settings for a namespace.
169
+ */
95
170
  async getSmtpSettings(namespace) {
96
171
  const result = await this.axiosInstance.get(`api/smtp/${namespace}`);
97
172
  return result.data;
@@ -100,13 +175,25 @@ var MailiskClient = class {
100
175
  const result = await this.axiosInstance.get(`api/attachments/${attachmentId}`);
101
176
  return result.data;
102
177
  }
178
+ /**
179
+ * Download an attachment from an attachment ID.
180
+ *
181
+ * @example
182
+ * Download an attachment from an email
183
+ * ```typescript
184
+ * const attachment = email.attachments[0];
185
+ * const attachmentBuffer = await client.downloadAttachment(attachment.id);
186
+ *
187
+ * // save to file
188
+ * fs.writeFileSync(attachment.filename, attachmentBuffer);
189
+ * ```
190
+ */
103
191
  async downloadAttachment(attachmentId) {
104
192
  const result = await this.getAttachment(attachmentId);
105
193
  const response = await axios.get(result.data.download_url, { responseType: "arraybuffer" });
106
194
  return Buffer.from(response.data);
107
195
  }
108
196
  };
109
- __name(MailiskClient, "MailiskClient");
110
197
  export {
111
198
  MailiskClient
112
199
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mailisk.ts"],"sourcesContent":["import axios, { AxiosBasicCredentials, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport {\n GetAttachmentResponse,\n ListNamespacesResponse,\n ListSmsNumbersResponse,\n SearchInboxParams,\n SearchInboxResponse,\n SearchSmsMessagesParams,\n SearchSmsMessagesResponse,\n SendVirtualEmailParams,\n SendVirtualSmsParams,\n SmtpSettings,\n} from \"./mailisk.interfaces\";\nimport nodemailer from \"nodemailer\";\n\nexport class MailiskClient {\n constructor({ apiKey, baseUrl, auth }: { apiKey: string; baseUrl?: string; auth?: AxiosBasicCredentials }) {\n this.axiosInstance = axios.create({\n headers: {\n \"X-Api-Key\": apiKey,\n },\n baseURL: baseUrl || \"https://api.mailisk.com/\",\n auth,\n });\n }\n\n private readonly axiosInstance: AxiosInstance;\n\n /**\n * Search SMS messages sent to a phone number.\n *\n * @example\n * Search for SMS messages sent to a phone number\n * ```typescript\n * const { data: smsMessages } = await client.searchSmsMessages(\"1234567890\");\n * ```\n */\n async searchSmsMessages(\n phoneNumber: string,\n params?: SearchSmsMessagesParams,\n config?: AxiosRequestConfig\n ): Promise<SearchSmsMessagesResponse> {\n let _params: SearchSmsMessagesParams = { ...params };\n\n // default from timestamp, 15 minutes before starting this request\n if (params?.from_date === undefined || params?.from_date === null) {\n _params.from_date = new Date(Date.now() - 15 * 60 * 1000).toISOString();\n }\n\n // by default wait for sms\n if (params?.wait !== false) {\n _params.wait = true;\n }\n\n let _config = { ...config };\n\n if (config?.maxRedirects === undefined) {\n _config.maxRedirects = 99999;\n }\n\n // by default, wait 5 minutes for emails before timing out\n if (_params.wait && config?.timeout === undefined) {\n _config.timeout = 1000 * 60 * 5;\n }\n\n const requestParams = {\n ..._params,\n from_date: _params.from_date ?? undefined,\n to_date: _params.to_date ?? undefined,\n };\n\n return (\n await this.axiosInstance.get(`api/sms/${phoneNumber}/messages`, {\n ..._config,\n params: requestParams,\n })\n ).data;\n }\n\n /**\n * List all SMS phone numbers associated with the current account.\n *\n * @example\n * List all SMS phone numbers\n * ```typescript\n * const { data: smsNumbers } = await client.listSmsNumbers();\n * ```\n */\n async listSmsNumbers(): Promise<ListSmsNumbersResponse> {\n return (await this.axiosInstance.get(\"api/sms/numbers\")).data;\n }\n\n async sendVirtualSms(params: SendVirtualSmsParams): Promise<void> {\n return (await this.axiosInstance.post(\"api/sms/virtual\", params)).data;\n }\n\n /**\n * List all namespaces that belong to the current account (API key).\n */\n async listNamespaces(): Promise<ListNamespacesResponse> {\n return (await this.axiosInstance.get(\"api/namespaces\")).data;\n }\n\n /**\n * Send an email using the Virtual SMTP.\n *\n * These emails can only be sent to valid Mailisk namespaces, i.e. emails that end in @mynamespace.mailisk.net\n *\n * @example\n * For example, sending a test email:\n * ```typescript\n * client.sendVirtualEmail(namespace, {\n * from: \"test@example.com\",\n * to: `john@${namespace}.mailisk.net`,\n * subject: \"This is a test\",\n * text: \"Testing\",\n * });\n * ```\n */\n async sendVirtualEmail(namespace: string, params: SendVirtualEmailParams): Promise<void> {\n const smtpSettings = await this.getSmtpSettings(namespace);\n\n const transport = nodemailer.createTransport({\n host: smtpSettings.data.host,\n port: smtpSettings.data.port,\n secure: false,\n auth: {\n user: smtpSettings.data.username,\n pass: smtpSettings.data.password,\n },\n });\n\n const { from, to, subject, text, html, headers, attachments } = params;\n\n await transport.sendMail({\n from,\n to,\n subject,\n text,\n html,\n headers,\n attachments,\n });\n\n transport.close();\n }\n\n /**\n * Search inbox of a namespace.\n *\n * By default, this calls the api using the `wait` flag. This means the call won't timeout until at least one email is received or 5 minutes pass.\n * It also uses a default `from_timestamp` of **current timestamp - 15 minutes**. This means that older emails will be ignored.\n *\n * Both of these settings can be overriden by passing them in the `params` object.\n *\n * @example\n * Get the latest emails\n * ```typescript\n * const { data: emails } = await client.searchInbox(namespace);\n * ```\n *\n * @example\n * Get the latest emails for a specific email address\n * ```typescript\n * const { data: emails } = await client.searchInbox(namespace, {\n * to_addr_prefix: 'john@mynamespace.mailisk.net'\n * });\n * ```\n *\n * @example\n * Get the last 20 emails in the namespace\n * ```typescript\n * const { data: emails } = await mailisk.searchInbox(namespace, {\n * wait: false,\n * from_timestamp: 0,\n * limit: 20\n * });\n * ```\n */\n async searchInbox(\n namespace: string,\n params?: SearchInboxParams,\n config?: AxiosRequestConfig\n ): Promise<SearchInboxResponse> {\n let _params = { ...params };\n\n // default from timestamp, 15 minutes before starting this request\n if (params?.from_timestamp === undefined || params?.from_timestamp === null) {\n _params.from_timestamp = Math.floor(new Date().getTime() / 1000) - 15 * 60;\n }\n\n // by default wait for email\n if (params?.wait !== false) {\n _params.wait = true;\n }\n\n let _config = { ...config };\n\n if (config?.maxRedirects === undefined) {\n _config.maxRedirects = 99999;\n }\n\n // by default, wait 5 minutes for emails before timing out\n if (_params.wait && config?.timeout === undefined) {\n _config.timeout = 1000 * 60 * 5;\n }\n\n return (\n await this.axiosInstance.get(`api/emails/${namespace}/inbox`, {\n ..._config,\n params: _params,\n })\n ).data;\n }\n\n /**\n * Get the SMTP settings for a namespace.\n */\n async getSmtpSettings(namespace: string): Promise<SmtpSettings> {\n const result = await this.axiosInstance.get(`api/smtp/${namespace}`);\n return result.data;\n }\n\n async getAttachment(attachmentId: string): Promise<GetAttachmentResponse> {\n const result = await this.axiosInstance.get(`api/attachments/${attachmentId}`);\n return result.data;\n }\n\n /**\n * Download an attachment from an attachment ID.\n *\n * @example\n * Download an attachment from an email\n * ```typescript\n * const attachment = email.attachments[0];\n * const attachmentBuffer = await client.downloadAttachment(attachment.id);\n *\n * // save to file\n * fs.writeFileSync(attachment.filename, attachmentBuffer);\n * ```\n */\n async downloadAttachment(attachmentId: string): Promise<Buffer> {\n const result = await this.getAttachment(attachmentId);\n\n const response = await axios.get(result.data.download_url, { responseType: \"arraybuffer\" });\n return Buffer.from(response.data);\n }\n}\n"],"mappings":";;;;AAAA,OAAO,WAAyE;AAahF,OAAO,gBAAgB;AAEhB,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAAY,EAAE,QAAQ,SAAS,KAAK,GAAuE;AACzG,SAAK,gBAAgB,MAAM,OAAO;AAAA,MAChC,SAAS;AAAA,QACP,aAAa;AAAA,MACf;AAAA,MACA,SAAS,WAAW;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEiB;AAAA,EAWjB,MAAM,kBACJ,aACA,QACA,QACoC;AAC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AAc,CAAC;AAC1F,WAAO,OAAO,KAAK,SAAS,IAAI;AAAA,EAClC;AACF;AAxOa;","names":[]}
1
+ {"version":3,"sources":["../src/mailisk.ts"],"sourcesContent":["import axios, { AxiosBasicCredentials, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport {\n GetAttachmentResponse,\n ListNamespacesResponse,\n ListSmsNumbersResponse,\n SearchInboxParams,\n SearchInboxResponse,\n SearchSmsMessagesParams,\n SearchSmsMessagesResponse,\n SendVirtualEmailParams,\n SendVirtualSmsParams,\n SmtpSettings,\n} from \"./mailisk.interfaces\";\nimport nodemailer from \"nodemailer\";\n\nexport class MailiskClient {\n constructor({ apiKey, baseUrl, auth }: { apiKey: string; baseUrl?: string; auth?: AxiosBasicCredentials }) {\n this.axiosInstance = axios.create({\n headers: {\n \"X-Api-Key\": apiKey,\n },\n baseURL: baseUrl || \"https://api.mailisk.com/\",\n auth,\n });\n }\n\n private readonly axiosInstance: AxiosInstance;\n\n /**\n * Search SMS messages sent to a phone number.\n *\n * @example\n * Search for SMS messages sent to a phone number\n * ```typescript\n * const { data: smsMessages } = await client.searchSmsMessages(\"1234567890\");\n * ```\n */\n async searchSmsMessages(\n phoneNumber: string,\n params?: SearchSmsMessagesParams,\n config?: AxiosRequestConfig\n ): Promise<SearchSmsMessagesResponse> {\n let _params: SearchSmsMessagesParams = { ...params };\n\n // default from timestamp, 15 minutes before starting this request\n if (params?.from_date === undefined || params?.from_date === null) {\n _params.from_date = new Date(Date.now() - 15 * 60 * 1000).toISOString();\n }\n\n // by default wait for sms\n if (params?.wait !== false) {\n _params.wait = true;\n }\n\n let _config = { ...config };\n\n if (config?.maxRedirects === undefined) {\n _config.maxRedirects = 99999;\n }\n\n // by default, wait 5 minutes for emails before timing out\n if (_params.wait && config?.timeout === undefined) {\n _config.timeout = 1000 * 60 * 5;\n }\n\n const requestParams = {\n ..._params,\n from_date: _params.from_date ?? undefined,\n to_date: _params.to_date ?? undefined,\n };\n\n return (\n await this.axiosInstance.get(`api/sms/${phoneNumber}/messages`, {\n ..._config,\n params: requestParams,\n })\n ).data;\n }\n\n /**\n * List all SMS phone numbers associated with the current account.\n *\n * @example\n * List all SMS phone numbers\n * ```typescript\n * const { data: smsNumbers } = await client.listSmsNumbers();\n * ```\n */\n async listSmsNumbers(): Promise<ListSmsNumbersResponse> {\n return (await this.axiosInstance.get(\"api/sms/numbers\")).data;\n }\n\n async sendVirtualSms(params: SendVirtualSmsParams): Promise<void> {\n return (await this.axiosInstance.post(\"api/sms/virtual\", params)).data;\n }\n\n /**\n * List all namespaces that belong to the current account (API key).\n */\n async listNamespaces(): Promise<ListNamespacesResponse> {\n return (await this.axiosInstance.get(\"api/namespaces\")).data;\n }\n\n /**\n * Send an email using the Virtual SMTP.\n *\n * These emails can only be sent to valid Mailisk namespaces, i.e. emails that end in @mynamespace.mailisk.net\n *\n * @example\n * For example, sending a test email:\n * ```typescript\n * client.sendVirtualEmail(namespace, {\n * from: \"test@example.com\",\n * to: `john@${namespace}.mailisk.net`,\n * subject: \"This is a test\",\n * text: \"Testing\",\n * });\n * ```\n */\n async sendVirtualEmail(namespace: string, params: SendVirtualEmailParams): Promise<void> {\n const smtpSettings = await this.getSmtpSettings(namespace);\n\n const transport = nodemailer.createTransport({\n host: smtpSettings.data.host,\n port: smtpSettings.data.port,\n secure: false,\n auth: {\n user: smtpSettings.data.username,\n pass: smtpSettings.data.password,\n },\n });\n\n const { from, to, subject, text, html, headers, attachments } = params;\n\n await transport.sendMail({\n from,\n to,\n subject,\n text,\n html,\n headers,\n attachments,\n });\n\n transport.close();\n }\n\n /**\n * Search inbox of a namespace.\n *\n * By default, this calls the api using the `wait` flag. This means the call won't timeout until at least one email is received or 5 minutes pass.\n * It also uses a default `from_timestamp` of **current timestamp - 15 minutes**. This means that older emails will be ignored.\n *\n * Both of these settings can be overriden by passing them in the `params` object.\n *\n * @example\n * Get the latest emails\n * ```typescript\n * const { data: emails } = await client.searchInbox(namespace);\n * ```\n *\n * @example\n * Get the latest emails for a specific email address\n * ```typescript\n * const { data: emails } = await client.searchInbox(namespace, {\n * to_addr_prefix: 'john@mynamespace.mailisk.net'\n * });\n * ```\n *\n * @example\n * Get the last 20 emails in the namespace\n * ```typescript\n * const { data: emails } = await mailisk.searchInbox(namespace, {\n * wait: false,\n * from_timestamp: 0,\n * limit: 20\n * });\n * ```\n */\n async searchInbox(\n namespace: string,\n params?: SearchInboxParams,\n config?: AxiosRequestConfig\n ): Promise<SearchInboxResponse> {\n let _params = { ...params };\n\n // default from timestamp, 15 minutes before starting this request\n if (params?.from_timestamp === undefined || params?.from_timestamp === null) {\n _params.from_timestamp = Math.floor(new Date().getTime() / 1000) - 15 * 60;\n }\n\n // by default wait for email\n if (params?.wait !== false) {\n _params.wait = true;\n }\n\n let _config = { ...config };\n\n if (config?.maxRedirects === undefined) {\n _config.maxRedirects = 99999;\n }\n\n // by default, wait 5 minutes for emails before timing out\n if (_params.wait && config?.timeout === undefined) {\n _config.timeout = 1000 * 60 * 5;\n }\n\n return (\n await this.axiosInstance.get(`api/emails/${namespace}/inbox`, {\n ..._config,\n params: _params,\n })\n ).data;\n }\n\n /**\n * Get the SMTP settings for a namespace.\n */\n async getSmtpSettings(namespace: string): Promise<SmtpSettings> {\n const result = await this.axiosInstance.get(`api/smtp/${namespace}`);\n return result.data;\n }\n\n async getAttachment(attachmentId: string): Promise<GetAttachmentResponse> {\n const result = await this.axiosInstance.get(`api/attachments/${attachmentId}`);\n return result.data;\n }\n\n /**\n * Download an attachment from an attachment ID.\n *\n * @example\n * Download an attachment from an email\n * ```typescript\n * const attachment = email.attachments[0];\n * const attachmentBuffer = await client.downloadAttachment(attachment.id);\n *\n * // save to file\n * fs.writeFileSync(attachment.filename, attachmentBuffer);\n * ```\n */\n async downloadAttachment(attachmentId: string): Promise<Buffer> {\n const result = await this.getAttachment(attachmentId);\n\n const response = await axios.get(result.data.download_url, { responseType: \"arraybuffer\" });\n return Buffer.from(response.data);\n }\n}\n"],"mappings":";;;;AAAA,O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E;AAGA,QAAI,QAAQ,SAAS,OAAO;AAC1B,cAAQ,OAAO;AAAA,IACjB;AAEA,QAAI,UAAU,EAAE,GAAG,OAAO;AAE1B,QAAI,QAAQ,iBAAiB,QAAW;AACtC,cAAQ,eAAe;AAAA,IACzB;AAGA,QAAI,QAAQ,QAAQ,QAAQ,YAAY,QAAW;AACjD,cAAQ,UAAU,MAAO,KAAK;AAAA,IAChC;AAEA,YACE,MAAM,KAAK,cAAc,IAAI,cAAc,SAAS,UAAU;AAAA,MAC5D,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC,GACD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBAAgB,WAA0C;AAC9D,UAAM,SAAS,MAAM,KAAK,cAAc,IAAI,YAAY,SAAS,EAAE;AACnE,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,cAAc,cAAsD;AACxE,UAAM,SAAS,MAAM,KAAK,cAAc,IAAI,mBAAmB,YAAY,EAAE;AAC7E,WAAO,OAAO;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,mBAAmB,cAAuC;AAC9D,UAAM,SAAS,MAAM,KAAK,cAAc,YAAY;AAEpD,UAAM,WAAW,MAAM,MAAM,IAAI,OAAO,KAAK,cAAc,EAAE,cAAc,cAAc,CAAC;AAC1F,WAAO,OAAO,KAAK,SAAS,IAAI;AAAA,EAClC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailisk",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "Mailisk library for NodeJS",
5
5
  "keywords": [
6
6
  "mailisk",
@@ -18,18 +18,21 @@
18
18
  },
19
19
  "author": "",
20
20
  "license": "ISC",
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
21
24
  "devDependencies": {
22
25
  "@types/jest": "^29.5.14",
23
- "@types/nodemailer": "^6.4.6",
26
+ "@types/nodemailer": "^8.0.0",
24
27
  "dotenv": "^16.4.7",
25
28
  "jest": "^29.7.0",
26
29
  "jest-mock-axios": "^4.8.0",
27
- "ts-jest": "^29.2.6",
28
- "tsup": "^6.2.3",
30
+ "ts-jest": "^29.4.9",
31
+ "tsup": "^8.5.1",
29
32
  "typescript": "^4.9.5"
30
33
  },
31
34
  "dependencies": {
32
- "axios": "^1.1.2",
33
- "nodemailer": "^6.8.0"
35
+ "axios": "^1.14.0",
36
+ "nodemailer": "^8.0.4"
34
37
  }
35
38
  }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const mailisk_1 = require("../src/mailisk");
13
- const mailisk = new mailisk_1.MailiskClient({ apiKey: "3vJHvcSDCowy0DDrXEs2DLrwJB0nSbw4PxGG_3370EI" });
14
- function main() {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- // const namespaces = await mailisk.listNamespaces();
17
- // console.log(namespaces);
18
- // const response = await mailisk.searchInbox("test", { wait: false, from_timestamp: 0 });
19
- // console.log(response);
20
- const response = yield mailisk.getAttachment("0005b397-b313-4771-b543-298aac5cb19e");
21
- console.log(response);
22
- });
23
- }
24
- main().then(() => {
25
- console.log("done");
26
- process.exit(0);
27
- });
28
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4CAA+C;AAE/C,MAAM,OAAO,GAAG,IAAI,uBAAa,CAAC,EAAE,MAAM,EAAE,6CAA6C,EAAE,CAAC,CAAC;AAE7F,SAAe,IAAI;;QACjB,qDAAqD;QACrD,2BAA2B;QAC3B,0FAA0F;QAC1F,yBAAyB;QACzB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,sCAAsC,CAAC,CAAC;QACrF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;CAAA;AAED,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;IACf,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=mailisk.interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mailisk.interfaces.js","sourceRoot":"","sources":["../../../src/mailisk.interfaces.ts"],"names":[],"mappings":""}
@@ -1,168 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.MailiskClient = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const nodemailer_1 = __importDefault(require("nodemailer"));
18
- class MailiskClient {
19
- constructor({ apiKey, baseUrl, auth }) {
20
- this.axiosInstance = axios_1.default.create({
21
- headers: {
22
- "X-Api-Key": apiKey,
23
- },
24
- baseURL: baseUrl || "https://api.mailisk.com/",
25
- auth,
26
- });
27
- }
28
- /**
29
- * List all namespaces that belong to the current account (API key).
30
- */
31
- listNamespaces() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return (yield this.axiosInstance.get("api/namespaces")).data;
34
- });
35
- }
36
- /**
37
- * Send an email using the Virtual SMTP.
38
- *
39
- * These emails can only be sent to valid Mailisk namespaces, i.e. emails that end in @mynamespace.mailisk.net
40
- *
41
- * @example
42
- * For example, sending a test email:
43
- * ```typescript
44
- * client.sendVirtualEmail(namespace, {
45
- * from: "test@example.com",
46
- * to: `john@${namespace}.mailisk.net`,
47
- * subject: "This is a test",
48
- * text: "Testing",
49
- * });
50
- * ```
51
- */
52
- sendVirtualEmail(namespace, params) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const smtpSettings = yield this.getSmtpSettings(namespace);
55
- const transport = nodemailer_1.default.createTransport({
56
- host: smtpSettings.data.host,
57
- port: smtpSettings.data.port,
58
- secure: false,
59
- auth: {
60
- user: smtpSettings.data.username,
61
- pass: smtpSettings.data.password,
62
- },
63
- });
64
- const { from, to, subject, text, html, headers, attachments } = params;
65
- yield transport.sendMail({
66
- from,
67
- to,
68
- subject,
69
- text,
70
- html,
71
- headers,
72
- attachments,
73
- });
74
- transport.close();
75
- });
76
- }
77
- /**
78
- * Search inbox of a namespace.
79
- *
80
- * By default, this calls the api using the `wait` flag. This means the call won't timeout until at least one email is received or 5 minutes pass.
81
- * It also uses a default `from_timestamp` of **current timestamp - 15 minutes**. This means that older emails will be ignored.
82
- *
83
- * Both of these settings can be overriden by passing them in the `params` object.
84
- *
85
- * @example
86
- * Get the latest emails
87
- * ```typescript
88
- * const { data: emails } = await client.searchInbox(namespace);
89
- * ```
90
- *
91
- * @example
92
- * Get the latest emails for a specific email address
93
- * ```typescript
94
- * const { data: emails } = await client.searchInbox(namespace, {
95
- * to_addr_prefix: 'john@mynamespace.mailisk.net'
96
- * });
97
- * ```
98
- *
99
- * @example
100
- * Get the last 20 emails in the namespace
101
- * ```typescript
102
- * const { data: emails } = await mailisk.searchInbox(namespace, {
103
- * wait: false,
104
- * from_timestamp: 0,
105
- * limit: 20
106
- * });
107
- * ```
108
- */
109
- searchInbox(namespace, params, config) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- let _params = Object.assign({}, params);
112
- // default from timestamp, 15 minutes before starting this request
113
- if ((params === null || params === void 0 ? void 0 : params.from_timestamp) === undefined || (params === null || params === void 0 ? void 0 : params.from_timestamp) === null) {
114
- _params.from_timestamp = Math.floor(new Date().getTime() / 1000) - 15 * 60;
115
- }
116
- // by default wait for email
117
- if ((params === null || params === void 0 ? void 0 : params.wait) !== false) {
118
- _params.wait = true;
119
- }
120
- let _config = Object.assign({}, config);
121
- if (!(config === null || config === void 0 ? void 0 : config.maxRedirects)) {
122
- _config.maxRedirects = 99999;
123
- }
124
- // by default, wait 5 minutes for emails before timing out
125
- if (_params.wait && !(config === null || config === void 0 ? void 0 : config.timeout)) {
126
- _config.timeout = 1000 * 60 * 5;
127
- }
128
- return (yield this.axiosInstance.get(`api/emails/${namespace}/inbox`, Object.assign(Object.assign({}, _config), { params: _params }))).data;
129
- });
130
- }
131
- /**
132
- * Get the SMTP settings for a namespace.
133
- */
134
- getSmtpSettings(namespace) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- const result = yield this.axiosInstance.get(`api/smtp/${namespace}`);
137
- return result.data;
138
- });
139
- }
140
- getAttachment(attachmentId) {
141
- return __awaiter(this, void 0, void 0, function* () {
142
- const result = yield this.axiosInstance.get(`api/attachments/${attachmentId}`);
143
- return result.data;
144
- });
145
- }
146
- /**
147
- * Download an attachment from an attachment ID.
148
- *
149
- * @example
150
- * Download an attachment from an email
151
- * ```typescript
152
- * const attachment = email.attachments[0];
153
- * const attachmentBuffer = await client.downloadAttachment(attachment.id);
154
- *
155
- * // save to file
156
- * fs.writeFileSync(attachment.filename, attachmentBuffer);
157
- * ```
158
- */
159
- downloadAttachment(attachmentId) {
160
- return __awaiter(this, void 0, void 0, function* () {
161
- const result = yield this.getAttachment(attachmentId);
162
- const response = yield axios_1.default.get(result.data.download_url, { responseType: "arraybuffer" });
163
- return Buffer.from(response.data);
164
- });
165
- }
166
- }
167
- exports.MailiskClient = MailiskClient;
168
- //# sourceMappingURL=mailisk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mailisk.js","sourceRoot":"","sources":["../../../src/mailisk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAyE;AASzE,4DAAoC;AAEpC,MAAa,aAAa;IACxB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAsE;QACvG,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE;gBACP,WAAW,EAAE,MAAM;aACpB;YACD,OAAO,EAAE,OAAO,IAAI,0BAA0B;YAC9C,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAID;;OAEG;IACG,cAAc;;YAClB,OAAO,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/D,CAAC;KAAA;IAED;;;;;;;;;;;;;;;OAeG;IACG,gBAAgB,CAAC,SAAiB,EAAE,MAA8B;;YACtE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAE3D,MAAM,SAAS,GAAG,oBAAU,CAAC,eAAe,CAAC;gBAC3C,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI;gBAC5B,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI;gBAC5B,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE;oBACJ,IAAI,EAAE,YAAY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PxGG_3370EI" });
4
-
5
- async function main() {
6
- // const namespaces = await mailisk.listNamespaces();
7
- // console.log(namespaces);
8
- // const response = await mailisk.searchInbox("test", { wait: false, from_timestamp: 0 });
9
- // console.log(response);
10
- const response = await mailisk.getAttachment("0005b397-b313-4771-b543-298aac5cb19e");
11
- console.log(response);
12
- }
13
-
14
- main().then(() => {
15
- console.log("done");
16
- process.exit(0);
17
- });
@@ -1,44 +0,0 @@
1
- {
2
- "name": "private",
3
- "version": "1.0.0",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "..": {
8
- "name": "mailisk",
9
- "version": "2.1.1",
10
- "license": "ISC",
11
- "dependencies": {
12
- "axios": "^1.1.2",
13
- "nodemailer": "^6.8.0"
14
- },
15
- "devDependencies": {
16
- "@types/jest": "^29.5.14",
17
- "@types/nodemailer": "^6.4.6",
18
- "dotenv": "^16.4.7",
19
- "jest": "^29.7.0",
20
- "jest-mock-axios": "^4.8.0",
21
- "ts-jest": "^29.2.6",
22
- "tsup": "^6.2.3",
23
- "typescript": "^4.9.5"
24
- }
25
- },
26
- "node_modules/mailisk": {
27
- "resolved": "..",
28
- "link": true
29
- },
30
- "node_modules/typescript": {
31
- "version": "5.9.3",
32
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
33
- "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
34
- "license": "Apache-2.0",
35
- "bin": {
36
- "tsc": "bin/tsc",
37
- "tsserver": "bin/tsserver"
38
- },
39
- "engines": {
40
- "node": ">=14.17"
41
- }
42
- }
43
- }
44
- }
@@ -1,55 +0,0 @@
1
- Apache License
2
-
3
- Version 2.0, January 2004
4
-
5
- http://www.apache.org/licenses/
6
-
7
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
-
9
- 1. Definitions.
10
-
11
- "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
-
17
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
-
19
- "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
-
21
- "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
-
23
- "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
-
25
- "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
-
27
- "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
-
29
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
-
31
- 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
-
33
- 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
-
35
- 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
-
37
- You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
-
39
- You must cause any modified files to carry prominent notices stating that You changed the files; and
40
-
41
- You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
-
43
- If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
-
45
- 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
-
47
- 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
-
49
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
-
51
- 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
-
53
- 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
-
55
- END OF TERMS AND CONDITIONS
@@ -1,50 +0,0 @@
1
-
2
- # TypeScript
3
-
4
- [![CI](https://github.com/microsoft/TypeScript/actions/workflows/ci.yml/badge.svg)](https://github.com/microsoft/TypeScript/actions/workflows/ci.yml)
5
- [![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
6
- [![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript)
7
- [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/microsoft/TypeScript/badge)](https://securityscorecards.dev/viewer/?uri=github.com/microsoft/TypeScript)
8
-
9
-
10
- [TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescript).
11
-
12
- Find others who are using TypeScript at [our community page](https://www.typescriptlang.org/community/).
13
-
14
- ## Installing
15
-
16
- For the latest stable version:
17
-
18
- ```bash
19
- npm install -D typescript
20
- ```
21
-
22
- For our nightly builds:
23
-
24
- ```bash
25
- npm install -D typescript@next
26
- ```
27
-
28
- ## Contribute
29
-
30
- There are many ways to [contribute](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md) to TypeScript.
31
- * [Submit bugs](https://github.com/microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
32
- * Review the [source code changes](https://github.com/microsoft/TypeScript/pulls).
33
- * Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript).
34
- * Help each other in the [TypeScript Community Discord](https://discord.gg/typescript).
35
- * Join the [#typescript](https://twitter.com/search?q=%23TypeScript) discussion on Twitter.
36
- * [Contribute bug fixes](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md).
37
-
38
- This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see
39
- the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com)
40
- with any additional questions or comments.
41
-
42
- ## Documentation
43
-
44
- * [TypeScript in 5 minutes](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html)
45
- * [Programming handbook](https://www.typescriptlang.org/docs/handbook/intro.html)
46
- * [Homepage](https://www.typescriptlang.org/)
47
-
48
- ## Roadmap
49
-
50
- For details on our planned features and future direction, please refer to our [roadmap](https://github.com/microsoft/TypeScript/wiki/Roadmap).