@3sixty/mailbox-models 0.0.0-stage → 0.20.0-next.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.
Files changed (175) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -2
  3. package/dist/es/factories/emailConsumerFactory.js +9 -0
  4. package/dist/es/factories/emailConsumerFactory.js.map +1 -0
  5. package/dist/es/factories/emailProtocolConnectorConfigSchemaFactory.js +9 -0
  6. package/dist/es/factories/emailProtocolConnectorConfigSchemaFactory.js.map +1 -0
  7. package/dist/es/factories/emailProtocolConnectorFactory.js +9 -0
  8. package/dist/es/factories/emailProtocolConnectorFactory.js.map +1 -0
  9. package/dist/es/factories/emailProtocolConnectorStateSchemaFactory.js +11 -0
  10. package/dist/es/factories/emailProtocolConnectorStateSchemaFactory.js.map +1 -0
  11. package/dist/es/index.js +44 -0
  12. package/dist/es/index.js.map +1 -0
  13. package/dist/es/models/IEmail.js +2 -0
  14. package/dist/es/models/IEmail.js.map +1 -0
  15. package/dist/es/models/IEmailAddress.js +4 -0
  16. package/dist/es/models/IEmailAddress.js.map +1 -0
  17. package/dist/es/models/IEmailAttachment.js +4 -0
  18. package/dist/es/models/IEmailAttachment.js.map +1 -0
  19. package/dist/es/models/IEmailConsumer.js +2 -0
  20. package/dist/es/models/IEmailConsumer.js.map +1 -0
  21. package/dist/es/models/IEmailHeader.js +4 -0
  22. package/dist/es/models/IEmailHeader.js.map +1 -0
  23. package/dist/es/models/IEmailProtocolConnector.js +2 -0
  24. package/dist/es/models/IEmailProtocolConnector.js.map +1 -0
  25. package/dist/es/models/IEmailProtocolConnectorAuthCallback.js +2 -0
  26. package/dist/es/models/IEmailProtocolConnectorAuthCallback.js.map +1 -0
  27. package/dist/es/models/IEmailProtocolConnectorAuthState.js +4 -0
  28. package/dist/es/models/IEmailProtocolConnectorAuthState.js.map +1 -0
  29. package/dist/es/models/IEmailProtocolConnectorOptions.js +4 -0
  30. package/dist/es/models/IEmailProtocolConnectorOptions.js.map +1 -0
  31. package/dist/es/models/IEmailProtocolConnectorRetrievalCallback.js +2 -0
  32. package/dist/es/models/IEmailProtocolConnectorRetrievalCallback.js.map +1 -0
  33. package/dist/es/models/IMailStorageComponent.js +2 -0
  34. package/dist/es/models/IMailStorageComponent.js.map +1 -0
  35. package/dist/es/models/IMailbox.js +2 -0
  36. package/dist/es/models/IMailbox.js.map +1 -0
  37. package/dist/es/models/IMailboxComponent.js +2 -0
  38. package/dist/es/models/IMailboxComponent.js.map +1 -0
  39. package/dist/es/models/IMailboxConfigField.js +2 -0
  40. package/dist/es/models/IMailboxConfigField.js.map +1 -0
  41. package/dist/es/models/IMailboxCreateResult.js +4 -0
  42. package/dist/es/models/IMailboxCreateResult.js.map +1 -0
  43. package/dist/es/models/IMailboxUpdateResult.js +4 -0
  44. package/dist/es/models/IMailboxUpdateResult.js.map +1 -0
  45. package/dist/es/models/IStoredEmail.js +2 -0
  46. package/dist/es/models/IStoredEmail.js.map +1 -0
  47. package/dist/es/models/api/IMailStorageGetRequest.js +4 -0
  48. package/dist/es/models/api/IMailStorageGetRequest.js.map +1 -0
  49. package/dist/es/models/api/IMailStorageGetResponse.js +2 -0
  50. package/dist/es/models/api/IMailStorageGetResponse.js.map +1 -0
  51. package/dist/es/models/api/IMailStorageListRequest.js +4 -0
  52. package/dist/es/models/api/IMailStorageListRequest.js.map +1 -0
  53. package/dist/es/models/api/IMailStorageListResponse.js +2 -0
  54. package/dist/es/models/api/IMailStorageListResponse.js.map +1 -0
  55. package/dist/es/models/api/IMailStorageRemoveRequest.js +4 -0
  56. package/dist/es/models/api/IMailStorageRemoveRequest.js.map +1 -0
  57. package/dist/es/models/api/IMailboxCompleteAuthRequest.js +4 -0
  58. package/dist/es/models/api/IMailboxCompleteAuthRequest.js.map +1 -0
  59. package/dist/es/models/api/IMailboxConnectorSchemaRequest.js +4 -0
  60. package/dist/es/models/api/IMailboxConnectorSchemaRequest.js.map +1 -0
  61. package/dist/es/models/api/IMailboxConnectorSchemaResponse.js +2 -0
  62. package/dist/es/models/api/IMailboxConnectorSchemaResponse.js.map +1 -0
  63. package/dist/es/models/api/IMailboxCreateRequest.js +2 -0
  64. package/dist/es/models/api/IMailboxCreateRequest.js.map +1 -0
  65. package/dist/es/models/api/IMailboxCreateResponse.js +2 -0
  66. package/dist/es/models/api/IMailboxCreateResponse.js.map +1 -0
  67. package/dist/es/models/api/IMailboxGetRequest.js +4 -0
  68. package/dist/es/models/api/IMailboxGetRequest.js.map +1 -0
  69. package/dist/es/models/api/IMailboxGetResponse.js +2 -0
  70. package/dist/es/models/api/IMailboxGetResponse.js.map +1 -0
  71. package/dist/es/models/api/IMailboxListRequest.js +4 -0
  72. package/dist/es/models/api/IMailboxListRequest.js.map +1 -0
  73. package/dist/es/models/api/IMailboxListResponse.js +2 -0
  74. package/dist/es/models/api/IMailboxListResponse.js.map +1 -0
  75. package/dist/es/models/api/IMailboxRemoveRequest.js +4 -0
  76. package/dist/es/models/api/IMailboxRemoveRequest.js.map +1 -0
  77. package/dist/es/models/api/IMailboxUpdateRequest.js +2 -0
  78. package/dist/es/models/api/IMailboxUpdateRequest.js.map +1 -0
  79. package/dist/es/models/api/IMailboxUpdateResponse.js +2 -0
  80. package/dist/es/models/api/IMailboxUpdateResponse.js.map +1 -0
  81. package/dist/es/models/mailboxMetricIds.js +13 -0
  82. package/dist/es/models/mailboxMetricIds.js.map +1 -0
  83. package/dist/es/models/mailboxMetrics.js +16 -0
  84. package/dist/es/models/mailboxMetrics.js.map +1 -0
  85. package/dist/es/utils/mailHelper.js +92 -0
  86. package/dist/es/utils/mailHelper.js.map +1 -0
  87. package/dist/types/factories/emailConsumerFactory.d.ts +6 -0
  88. package/dist/types/factories/emailProtocolConnectorConfigSchemaFactory.d.ts +6 -0
  89. package/dist/types/factories/emailProtocolConnectorFactory.d.ts +6 -0
  90. package/dist/types/factories/emailProtocolConnectorStateSchemaFactory.d.ts +8 -0
  91. package/dist/types/index.d.ts +41 -0
  92. package/dist/types/models/IEmail.d.ts +80 -0
  93. package/dist/types/models/IEmailAddress.d.ts +13 -0
  94. package/dist/types/models/IEmailAttachment.d.ts +17 -0
  95. package/dist/types/models/IEmailConsumer.d.ts +11 -0
  96. package/dist/types/models/IEmailHeader.d.ts +17 -0
  97. package/dist/types/models/IEmailProtocolConnector.d.ts +50 -0
  98. package/dist/types/models/IEmailProtocolConnectorAuthCallback.d.ts +12 -0
  99. package/dist/types/models/IEmailProtocolConnectorAuthState.d.ts +12 -0
  100. package/dist/types/models/IEmailProtocolConnectorOptions.d.ts +19 -0
  101. package/dist/types/models/IEmailProtocolConnectorRetrievalCallback.d.ts +10 -0
  102. package/dist/types/models/IMailStorageComponent.d.ts +39 -0
  103. package/dist/types/models/IMailbox.d.ts +46 -0
  104. package/dist/types/models/IMailboxComponent.d.ts +71 -0
  105. package/dist/types/models/IMailboxConfigField.d.ts +30 -0
  106. package/dist/types/models/IMailboxCreateResult.d.ts +15 -0
  107. package/dist/types/models/IMailboxUpdateResult.d.ts +11 -0
  108. package/dist/types/models/IStoredEmail.d.ts +18 -0
  109. package/dist/types/models/api/IMailStorageGetRequest.d.ts +14 -0
  110. package/dist/types/models/api/IMailStorageGetResponse.d.ts +10 -0
  111. package/dist/types/models/api/IMailStorageListRequest.d.ts +26 -0
  112. package/dist/types/models/api/IMailStorageListResponse.d.ts +19 -0
  113. package/dist/types/models/api/IMailStorageRemoveRequest.d.ts +14 -0
  114. package/dist/types/models/api/IMailboxCompleteAuthRequest.d.ts +16 -0
  115. package/dist/types/models/api/IMailboxConnectorSchemaRequest.d.ts +14 -0
  116. package/dist/types/models/api/IMailboxConnectorSchemaResponse.d.ts +10 -0
  117. package/dist/types/models/api/IMailboxCreateRequest.d.ts +10 -0
  118. package/dist/types/models/api/IMailboxCreateResponse.d.ts +29 -0
  119. package/dist/types/models/api/IMailboxGetRequest.d.ts +14 -0
  120. package/dist/types/models/api/IMailboxGetResponse.d.ts +10 -0
  121. package/dist/types/models/api/IMailboxListRequest.d.ts +18 -0
  122. package/dist/types/models/api/IMailboxListResponse.d.ts +19 -0
  123. package/dist/types/models/api/IMailboxRemoveRequest.d.ts +14 -0
  124. package/dist/types/models/api/IMailboxUpdateRequest.d.ts +19 -0
  125. package/dist/types/models/api/IMailboxUpdateResponse.d.ts +20 -0
  126. package/dist/types/models/mailboxMetricIds.d.ts +13 -0
  127. package/dist/types/models/mailboxMetrics.d.ts +5 -0
  128. package/dist/types/utils/mailHelper.d.ts +41 -0
  129. package/docs/changelog.md +0 -0
  130. package/docs/examples.md +145 -0
  131. package/docs/reference/classes/MailHelper.md +118 -0
  132. package/docs/reference/index.md +55 -0
  133. package/docs/reference/interfaces/IEmail.md +151 -0
  134. package/docs/reference/interfaces/IEmailAddress.md +19 -0
  135. package/docs/reference/interfaces/IEmailAttachment.md +27 -0
  136. package/docs/reference/interfaces/IEmailConsumer.md +21 -0
  137. package/docs/reference/interfaces/IEmailHeader.md +27 -0
  138. package/docs/reference/interfaces/IEmailProtocolConnector.md +154 -0
  139. package/docs/reference/interfaces/IEmailProtocolConnectorAuthState.md +14 -0
  140. package/docs/reference/interfaces/IEmailProtocolConnectorOptions.md +25 -0
  141. package/docs/reference/interfaces/IMailStorageComponent.md +119 -0
  142. package/docs/reference/interfaces/IMailStorageGetRequest.md +17 -0
  143. package/docs/reference/interfaces/IMailStorageGetResponse.md +11 -0
  144. package/docs/reference/interfaces/IMailStorageListRequest.md +35 -0
  145. package/docs/reference/interfaces/IMailStorageListResponse.md +23 -0
  146. package/docs/reference/interfaces/IMailStorageRemoveRequest.md +17 -0
  147. package/docs/reference/interfaces/IMailbox.md +97 -0
  148. package/docs/reference/interfaces/IMailboxCompleteAuthRequest.md +22 -0
  149. package/docs/reference/interfaces/IMailboxComponent.md +191 -0
  150. package/docs/reference/interfaces/IMailboxConfigField.md +51 -0
  151. package/docs/reference/interfaces/IMailboxConnectorSchemaRequest.md +17 -0
  152. package/docs/reference/interfaces/IMailboxConnectorSchemaResponse.md +11 -0
  153. package/docs/reference/interfaces/IMailboxCreateRequest.md +11 -0
  154. package/docs/reference/interfaces/IMailboxCreateResponse.md +40 -0
  155. package/docs/reference/interfaces/IMailboxCreateResult.md +21 -0
  156. package/docs/reference/interfaces/IMailboxGetRequest.md +17 -0
  157. package/docs/reference/interfaces/IMailboxGetResponse.md +11 -0
  158. package/docs/reference/interfaces/IMailboxListRequest.md +23 -0
  159. package/docs/reference/interfaces/IMailboxListResponse.md +23 -0
  160. package/docs/reference/interfaces/IMailboxRemoveRequest.md +17 -0
  161. package/docs/reference/interfaces/IMailboxUpdateRequest.md +25 -0
  162. package/docs/reference/interfaces/IMailboxUpdateResponse.md +26 -0
  163. package/docs/reference/interfaces/IMailboxUpdateResult.md +13 -0
  164. package/docs/reference/interfaces/IStoredEmail.md +247 -0
  165. package/docs/reference/type-aliases/IEmailProtocolConnectorAuthCallback.md +48 -0
  166. package/docs/reference/type-aliases/IEmailProtocolConnectorRetrievalCallback.md +35 -0
  167. package/docs/reference/type-aliases/MailboxMetricIds.md +5 -0
  168. package/docs/reference/variables/EmailConsumerFactory.md +5 -0
  169. package/docs/reference/variables/EmailProtocolConnectorConfigSchemaFactory.md +5 -0
  170. package/docs/reference/variables/EmailProtocolConnectorFactory.md +5 -0
  171. package/docs/reference/variables/EmailProtocolConnectorStateSchemaFactory.md +7 -0
  172. package/docs/reference/variables/MailboxMetricIds.md +13 -0
  173. package/docs/reference/variables/MailboxMetrics.md +5 -0
  174. package/locales/en.json +1 -0
  175. package/package.json +54 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxCompleteAuthRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxCompleteAuthRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Request to complete an authentication flow, sent by the external provider redirecting the\n * browser to the fixed callback route.\n */\nexport interface IMailboxCompleteAuthRequest {\n\t/**\n\t * The query parameters the provider appends to the callback URI.\n\t */\n\tquery: {\n\t\t[propertyKey: string]: string;\n\n\t\t/**\n\t\t * The correlating state the connector placed in the external flow.\n\t\t */\n\t\tstate: string;\n\t};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IMailboxConnectorSchemaRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxConnectorSchemaRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxConnectorSchemaRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Request to retrieve the configuration schema for a connector.\n */\nexport interface IMailboxConnectorSchemaRequest {\n\t/**\n\t * The path parameters.\n\t */\n\tpathParams: {\n\t\t/**\n\t\t * The connector type identifier.\n\t\t */\n\t\tconnectorType: string;\n\t};\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxConnectorSchemaResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxConnectorSchemaResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxConnectorSchemaResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IMailboxConfigField } from \"../IMailboxConfigField.js\";\n\n/**\n * Response from retrieving a connector configuration schema.\n */\nexport interface IMailboxConnectorSchemaResponse {\n\t/**\n\t * The schema fields for the connector.\n\t */\n\tbody: IMailboxConfigField[];\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxCreateRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxCreateRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxCreateRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IMailbox } from \"../IMailbox.js\";\n\n/**\n * Request to create a new mailbox.\n */\nexport interface IMailboxCreateRequest {\n\t/**\n\t * The mailbox to create.\n\t */\n\tbody: Pick<IMailbox, \"name\" | \"connectorType\" | \"config\" | \"enabled\">;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxCreateResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxCreateResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxCreateResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HeaderTypes, HttpStatusCode } from \"@3sixty/web\";\n\n/**\n * Response to creating a new mailbox.\n */\nexport interface IMailboxCreateResponse {\n\t/**\n\t * Response status code.\n\t */\n\tstatusCode: typeof HttpStatusCode.created;\n\n\t/**\n\t * Additional response headers.\n\t */\n\theaders: {\n\t\t/**\n\t\t * The location where the mailbox was created.\n\t\t */\n\t\t[HeaderTypes.Location]: string;\n\t};\n\n\t/**\n\t * The body of the response.\n\t */\n\tbody: {\n\t\t/**\n\t\t * The URL to open for the user when the mailbox must complete an external authentication\n\t\t * flow, such as an OAuth consent URL, before it can be polled.\n\t\t */\n\t\tauthUrl?: string;\n\t};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IMailboxGetRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxGetRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxGetRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Request to retrieve a mailbox by ID.\n */\nexport interface IMailboxGetRequest {\n\t/**\n\t * The path parameters.\n\t */\n\tpathParams: {\n\t\t/**\n\t\t * The identifier of the mailbox to retrieve.\n\t\t */\n\t\tid: string;\n\t};\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxGetResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxGetResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxGetResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IMailbox } from \"../IMailbox.js\";\n\n/**\n * Response from retrieving a mailbox.\n */\nexport interface IMailboxGetResponse {\n\t/**\n\t * The retrieved mailbox.\n\t */\n\tbody: IMailbox;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IMailboxListRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxListRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxListRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Request to list mailboxes with optional pagination.\n */\nexport interface IMailboxListRequest {\n\t/**\n\t * The query parameters.\n\t */\n\tquery?: {\n\t\t/**\n\t\t * The cursor for paginated results.\n\t\t */\n\t\tcursor?: string;\n\n\t\t/**\n\t\t * The maximum number of results to return.\n\t\t */\n\t\tlimit?: string;\n\t};\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxListResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxListResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxListResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IMailbox } from \"../IMailbox.js\";\n\n/**\n * Response from listing mailboxes.\n */\nexport interface IMailboxListResponse {\n\t/**\n\t * The result body.\n\t */\n\tbody: {\n\t\t/**\n\t\t * The list of mailboxes.\n\t\t */\n\t\tmailboxes: IMailbox[];\n\n\t\t/**\n\t\t * The cursor for the next page of results.\n\t\t */\n\t\tcursor?: string;\n\t};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IMailboxRemoveRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxRemoveRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxRemoveRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Request to remove a mailbox.\n */\nexport interface IMailboxRemoveRequest {\n\t/**\n\t * The path parameters.\n\t */\n\tpathParams: {\n\t\t/**\n\t\t * The identifier of the mailbox to remove.\n\t\t */\n\t\tid: string;\n\t};\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxUpdateRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxUpdateRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxUpdateRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IMailbox } from \"../IMailbox.js\";\n\n/**\n * Request to update an existing mailbox.\n */\nexport interface IMailboxUpdateRequest {\n\t/**\n\t * The path parameters.\n\t */\n\tpathParams: {\n\t\t/**\n\t\t * The identifier of the mailbox to update.\n\t\t */\n\t\tid: string;\n\t};\n\n\t/**\n\t * The updated mailbox configuration.\n\t */\n\tbody: IMailbox;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IMailboxUpdateResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMailboxUpdateResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IMailboxUpdateResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HttpStatusCode } from \"@3sixty/web\";\n\n/**\n * Response to updating a mailbox.\n */\nexport interface IMailboxUpdateResponse {\n\t/**\n\t * Response status code.\n\t */\n\tstatusCode: typeof HttpStatusCode.ok;\n\n\t/**\n\t * The body of the response.\n\t */\n\tbody: {\n\t\t/**\n\t\t * The URL to open for the user when the updated mailbox must complete an external\n\t\t * authentication flow, such as an OAuth consent URL, before it can be polled.\n\t\t */\n\t\tauthUrl?: string;\n\t};\n}\n"]}
@@ -0,0 +1,13 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * Metric IDs for the mailbox service.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export const MailboxMetricIds = {
8
+ /**
9
+ * Number of emails received across all mailboxes.
10
+ */
11
+ EmailsReceived: "mailbox_emails_received"
12
+ };
13
+ //# sourceMappingURL=mailboxMetricIds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailboxMetricIds.js","sourceRoot":"","sources":["../../../src/models/mailboxMetricIds.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B;;OAEG;IACH,cAAc,EAAE,yBAAyB;CAChC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Metric IDs for the mailbox service.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MailboxMetricIds = {\n\t/**\n\t * Number of emails received across all mailboxes.\n\t */\n\tEmailsReceived: \"mailbox_emails_received\"\n} as const;\n\n/**\n * Union type of all mailbox service metric ID string values.\n */\nexport type MailboxMetricIds = (typeof MailboxMetricIds)[keyof typeof MailboxMetricIds];\n"]}
@@ -0,0 +1,16 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { MetricType } from "@3sixty/telemetry-models";
4
+ import { MailboxMetricIds } from "./mailboxMetricIds.js";
5
+ /**
6
+ * Metrics registered by the mailbox service.
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
+ export const MailboxMetrics = [
10
+ {
11
+ id: MailboxMetricIds.EmailsReceived,
12
+ label: "Emails received",
13
+ type: MetricType.Counter
14
+ }
15
+ ];
16
+ //# sourceMappingURL=mailboxMetrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailboxMetrics.js","sourceRoot":"","sources":["../../../src/models/mailboxMetrics.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAyB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAuB;IACjD;QACC,EAAE,EAAE,gBAAgB,CAAC,cAAc;QACnC,KAAK,EAAE,iBAAiB;QACxB,IAAI,EAAE,UAAU,CAAC,OAAO;KACxB;CACD,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { type ITelemetryMetric, MetricType } from \"@3sixty/telemetry-models\";\nimport { MailboxMetricIds } from \"./mailboxMetricIds.js\";\n\n/**\n * Metrics registered by the mailbox service.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MailboxMetrics: ITelemetryMetric[] = [\n\t{\n\t\tid: MailboxMetricIds.EmailsReceived,\n\t\tlabel: \"Emails received\",\n\t\ttype: MetricType.Counter\n\t}\n];\n"]}
@@ -0,0 +1,92 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { Converter, Is } from "@3sixty/core";
4
+ import PostalMime from "postal-mime";
5
+ /**
6
+ * Shared utilities for parsing raw RFC822 email messages and mapping postal-mime address objects.
7
+ */
8
+ export class MailHelper {
9
+ /**
10
+ * Map a postal-mime address object to an IEmailAddress, or return undefined when no address is present.
11
+ * @param address The postal-mime address to map.
12
+ * @param address.name The display name of the email address.
13
+ * @param address.address The email address string.
14
+ * @returns The mapped address, or undefined.
15
+ */
16
+ static mapAddress(address) {
17
+ if (Is.stringValue(address?.address)) {
18
+ return { name: address?.name, address: address?.address };
19
+ }
20
+ return undefined;
21
+ }
22
+ /**
23
+ * Map an array of postal-mime address objects to IEmailAddress[], or return undefined when the input is empty.
24
+ * @param addresses The postal-mime addresses to map.
25
+ * @returns The mapped addresses, or undefined.
26
+ */
27
+ static mapAddresses(addresses) {
28
+ const mapped = (addresses ?? [])
29
+ .filter(addr => Is.stringValue(addr.address))
30
+ .map(addr => ({ name: addr.name, address: addr.address }));
31
+ return mapped.length > 0 ? mapped : undefined;
32
+ }
33
+ /**
34
+ * Parse a raw RFC822 email string into an IEmail object using postal-mime.
35
+ * @param raw The raw email string.
36
+ * @param flags Optional IMAP flags associated with the message.
37
+ * @returns The parsed email, or undefined if the input is empty.
38
+ */
39
+ static async parseEmail(raw, flags) {
40
+ if (!Is.stringValue(raw)) {
41
+ return undefined;
42
+ }
43
+ const parsed = await PostalMime.parse(raw);
44
+ const attachments = parsed.attachments.length > 0
45
+ ? parsed.attachments.map(a => ({
46
+ filename: a.filename ?? undefined,
47
+ contentType: a.mimeType,
48
+ data: MailHelper.attachmentToBase64(a.content)
49
+ }))
50
+ : undefined;
51
+ return {
52
+ headers: parsed.headers.map(h => ({
53
+ key: h.key,
54
+ originalKey: h.originalKey,
55
+ value: h.value
56
+ })),
57
+ messageId: parsed.messageId,
58
+ from: MailHelper.mapAddress(parsed.from),
59
+ sender: MailHelper.mapAddress(parsed.sender),
60
+ to: MailHelper.mapAddresses(parsed.to),
61
+ cc: MailHelper.mapAddresses(parsed.cc),
62
+ bcc: MailHelper.mapAddresses(parsed.bcc),
63
+ replyTo: MailHelper.mapAddresses(parsed.replyTo),
64
+ deliveredTo: parsed.deliveredTo,
65
+ returnPath: parsed.returnPath,
66
+ inReplyTo: parsed.inReplyTo,
67
+ references: parsed.references,
68
+ subject: parsed.subject,
69
+ date: parsed.date,
70
+ textContent: parsed.text,
71
+ htmlContent: parsed.html,
72
+ attachments,
73
+ flags
74
+ };
75
+ }
76
+ /**
77
+ * Convert postal-mime attachment content to a base64 string.
78
+ * Handles string (text), Uint8Array, and ArrayBuffer inputs.
79
+ * @param content The attachment content.
80
+ * @returns The base64-encoded content.
81
+ */
82
+ static attachmentToBase64(content) {
83
+ if (Is.stringValue(content)) {
84
+ return Converter.bytesToBase64(Converter.utf8ToBytes(content));
85
+ }
86
+ if (Is.uint8Array(content)) {
87
+ return Converter.bytesToBase64(content);
88
+ }
89
+ return Converter.bytesToBase64(new Uint8Array(content));
90
+ }
91
+ }
92
+ //# sourceMappingURL=mailHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailHelper.js","sourceRoot":"","sources":["../../../src/utils/mailHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;;;;;OAMG;IACI,MAAM,CAAC,UAAU,CACvB,OAAwD;QAExD,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAC3D,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CACzB,SAA2D;QAE3D,MAAM,MAAM,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;aAC9B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC5C,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAiB,EAAE,CAAC,CAAC,CAAC;QACtE,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAW,EAAE,KAAgB;QAC3D,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE3C,MAAM,WAAW,GAChB,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC7B,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,SAAS;gBACjC,WAAW,EAAE,CAAC,CAAC,QAAQ;gBACvB,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC;aAC9C,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO;YACN,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACjC,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,KAAK,EAAE,CAAC,CAAC,KAAK;aACd,CAAC,CAAC;YACH,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;YACxC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;YAC5C,EAAE,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,EAAE,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,GAAG,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC;YACxC,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC;YAChD,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,IAAI;YACxB,WAAW,EAAE,MAAM,CAAC,IAAI;YACxB,WAAW;YACX,KAAK;SACL,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,kBAAkB,CAAC,OAA0C;QAC1E,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,SAAS,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;CACD","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Is } from \"@3sixty/core\";\nimport PostalMime from \"postal-mime\";\nimport type { IEmail } from \"../models/IEmail.js\";\nimport type { IEmailAddress } from \"../models/IEmailAddress.js\";\n\n/**\n * Shared utilities for parsing raw RFC822 email messages and mapping postal-mime address objects.\n */\nexport class MailHelper {\n\t/**\n\t * Map a postal-mime address object to an IEmailAddress, or return undefined when no address is present.\n\t * @param address The postal-mime address to map.\n\t * @param address.name The display name of the email address.\n\t * @param address.address The email address string.\n\t * @returns The mapped address, or undefined.\n\t */\n\tpublic static mapAddress(\n\t\taddress?: { name: string; address?: string } | undefined\n\t): IEmailAddress | undefined {\n\t\tif (Is.stringValue(address?.address)) {\n\t\t\treturn { name: address?.name, address: address?.address };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Map an array of postal-mime address objects to IEmailAddress[], or return undefined when the input is empty.\n\t * @param addresses The postal-mime addresses to map.\n\t * @returns The mapped addresses, or undefined.\n\t */\n\tpublic static mapAddresses(\n\t\taddresses: { name: string; address?: string }[] | undefined\n\t): IEmailAddress[] | undefined {\n\t\tconst mapped = (addresses ?? [])\n\t\t\t.filter(addr => Is.stringValue(addr.address))\n\t\t\t.map(addr => ({ name: addr.name, address: addr.address as string }));\n\t\treturn mapped.length > 0 ? mapped : undefined;\n\t}\n\n\t/**\n\t * Parse a raw RFC822 email string into an IEmail object using postal-mime.\n\t * @param raw The raw email string.\n\t * @param flags Optional IMAP flags associated with the message.\n\t * @returns The parsed email, or undefined if the input is empty.\n\t */\n\tpublic static async parseEmail(raw: string, flags?: string[]): Promise<IEmail | undefined> {\n\t\tif (!Is.stringValue(raw)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parsed = await PostalMime.parse(raw);\n\n\t\tconst attachments =\n\t\t\tparsed.attachments.length > 0\n\t\t\t\t? parsed.attachments.map(a => ({\n\t\t\t\t\t\tfilename: a.filename ?? undefined,\n\t\t\t\t\t\tcontentType: a.mimeType,\n\t\t\t\t\t\tdata: MailHelper.attachmentToBase64(a.content)\n\t\t\t\t\t}))\n\t\t\t\t: undefined;\n\n\t\treturn {\n\t\t\theaders: parsed.headers.map(h => ({\n\t\t\t\tkey: h.key,\n\t\t\t\toriginalKey: h.originalKey,\n\t\t\t\tvalue: h.value\n\t\t\t})),\n\t\t\tmessageId: parsed.messageId,\n\t\t\tfrom: MailHelper.mapAddress(parsed.from),\n\t\t\tsender: MailHelper.mapAddress(parsed.sender),\n\t\t\tto: MailHelper.mapAddresses(parsed.to),\n\t\t\tcc: MailHelper.mapAddresses(parsed.cc),\n\t\t\tbcc: MailHelper.mapAddresses(parsed.bcc),\n\t\t\treplyTo: MailHelper.mapAddresses(parsed.replyTo),\n\t\t\tdeliveredTo: parsed.deliveredTo,\n\t\t\treturnPath: parsed.returnPath,\n\t\t\tinReplyTo: parsed.inReplyTo,\n\t\t\treferences: parsed.references,\n\t\t\tsubject: parsed.subject,\n\t\t\tdate: parsed.date,\n\t\t\ttextContent: parsed.text,\n\t\t\thtmlContent: parsed.html,\n\t\t\tattachments,\n\t\t\tflags\n\t\t};\n\t}\n\n\t/**\n\t * Convert postal-mime attachment content to a base64 string.\n\t * Handles string (text), Uint8Array, and ArrayBuffer inputs.\n\t * @param content The attachment content.\n\t * @returns The base64-encoded content.\n\t */\n\tpublic static attachmentToBase64(content: string | ArrayBuffer | Uint8Array): string {\n\t\tif (Is.stringValue(content)) {\n\t\t\treturn Converter.bytesToBase64(Converter.utf8ToBytes(content));\n\t\t}\n\t\tif (Is.uint8Array(content)) {\n\t\t\treturn Converter.bytesToBase64(content);\n\t\t}\n\t\treturn Converter.bytesToBase64(new Uint8Array(content));\n\t}\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { Factory } from "@3sixty/core";
2
+ import type { IEmailConsumer } from "../models/IEmailConsumer.js";
3
+ /**
4
+ * Factory for creating email consumer instances.
5
+ */
6
+ export declare const EmailConsumerFactory: Factory<IEmailConsumer>;
@@ -0,0 +1,6 @@
1
+ import { Factory } from "@3sixty/core";
2
+ import type { IMailboxConfigField } from "../models/IMailboxConfigField.js";
3
+ /**
4
+ * Factory for retrieving email protocol connector configuration field definitions.
5
+ */
6
+ export declare const EmailProtocolConnectorConfigSchemaFactory: Factory<IMailboxConfigField[]>;
@@ -0,0 +1,6 @@
1
+ import { Factory } from "@3sixty/core";
2
+ import type { IEmailProtocolConnector } from "../models/IEmailProtocolConnector.js";
3
+ /**
4
+ * Factory for creating email protocol connectors.
5
+ */
6
+ export declare const EmailProtocolConnectorFactory: Factory<IEmailProtocolConnector<unknown, import("../index.js").IEmailProtocolConnectorAuthState>>;
@@ -0,0 +1,8 @@
1
+ import { Factory } from "@3sixty/core";
2
+ import type { IMailboxConfigField } from "../models/IMailboxConfigField.js";
3
+ /**
4
+ * Factory for retrieving email protocol connector state field definitions.
5
+ * Only the properties a connector holds in its runtime state need registering here, and the ones
6
+ * marked secure are stored in the vault instead of alongside the rest of the state.
7
+ */
8
+ export declare const EmailProtocolConnectorStateSchemaFactory: Factory<IMailboxConfigField[]>;
@@ -0,0 +1,41 @@
1
+ export * from "./factories/emailConsumerFactory.js";
2
+ export * from "./factories/emailProtocolConnectorFactory.js";
3
+ export * from "./factories/emailProtocolConnectorConfigSchemaFactory.js";
4
+ export * from "./factories/emailProtocolConnectorStateSchemaFactory.js";
5
+ export * from "./models/api/IMailboxCompleteAuthRequest.js";
6
+ export * from "./models/api/IMailboxConnectorSchemaRequest.js";
7
+ export * from "./models/api/IMailboxConnectorSchemaResponse.js";
8
+ export * from "./models/api/IMailboxCreateRequest.js";
9
+ export * from "./models/api/IMailboxCreateResponse.js";
10
+ export * from "./models/api/IMailboxGetRequest.js";
11
+ export * from "./models/api/IMailboxGetResponse.js";
12
+ export * from "./models/api/IMailboxListRequest.js";
13
+ export * from "./models/api/IMailboxListResponse.js";
14
+ export * from "./models/api/IMailboxRemoveRequest.js";
15
+ export * from "./models/api/IMailboxUpdateRequest.js";
16
+ export * from "./models/api/IMailboxUpdateResponse.js";
17
+ export * from "./models/api/IMailStorageGetRequest.js";
18
+ export * from "./models/api/IMailStorageGetResponse.js";
19
+ export * from "./models/api/IMailStorageListRequest.js";
20
+ export * from "./models/api/IMailStorageListResponse.js";
21
+ export * from "./models/api/IMailStorageRemoveRequest.js";
22
+ export * from "./models/IEmail.js";
23
+ export * from "./models/IEmailAddress.js";
24
+ export * from "./models/IEmailAttachment.js";
25
+ export * from "./models/IEmailHeader.js";
26
+ export * from "./models/IEmailConsumer.js";
27
+ export * from "./models/IEmailProtocolConnector.js";
28
+ export * from "./models/IEmailProtocolConnectorAuthCallback.js";
29
+ export * from "./models/IEmailProtocolConnectorAuthState.js";
30
+ export * from "./models/IEmailProtocolConnectorOptions.js";
31
+ export * from "./models/IEmailProtocolConnectorRetrievalCallback.js";
32
+ export * from "./models/IMailbox.js";
33
+ export * from "./models/IMailboxCreateResult.js";
34
+ export * from "./models/IMailboxUpdateResult.js";
35
+ export * from "./models/IMailboxComponent.js";
36
+ export * from "./models/IMailboxConfigField.js";
37
+ export * from "./models/IMailStorageComponent.js";
38
+ export * from "./models/IStoredEmail.js";
39
+ export * from "./models/mailboxMetricIds.js";
40
+ export * from "./models/mailboxMetrics.js";
41
+ export * from "./utils/mailHelper.js";
@@ -0,0 +1,80 @@
1
+ import type { IEmailAddress } from "./IEmailAddress.js";
2
+ import type { IEmailAttachment } from "./IEmailAttachment.js";
3
+ import type { IEmailHeader } from "./IEmailHeader.js";
4
+ /**
5
+ * Interface describing a normalised email message at the connector boundary.
6
+ */
7
+ export interface IEmail {
8
+ /**
9
+ * The parsed message headers.
10
+ */
11
+ headers?: IEmailHeader[];
12
+ /**
13
+ * The unique message identifier.
14
+ */
15
+ messageId?: string;
16
+ /**
17
+ * The sender address (From header).
18
+ */
19
+ from?: IEmailAddress;
20
+ /**
21
+ * The Sender header address, when different from From.
22
+ */
23
+ sender?: IEmailAddress;
24
+ /**
25
+ * The primary recipient addresses.
26
+ */
27
+ to?: IEmailAddress[];
28
+ /**
29
+ * The carbon-copy recipient addresses.
30
+ */
31
+ cc?: IEmailAddress[];
32
+ /**
33
+ * The blind carbon-copy recipient addresses.
34
+ */
35
+ bcc?: IEmailAddress[];
36
+ /**
37
+ * The reply-to addresses.
38
+ */
39
+ replyTo?: IEmailAddress[];
40
+ /**
41
+ * The final delivery address from the Delivered-To header.
42
+ */
43
+ deliveredTo?: string;
44
+ /**
45
+ * The Return-Path address.
46
+ */
47
+ returnPath?: string;
48
+ /**
49
+ * The Message-ID this message is a reply to.
50
+ */
51
+ inReplyTo?: string;
52
+ /**
53
+ * The space-separated list of related message identifiers.
54
+ */
55
+ references?: string;
56
+ /**
57
+ * The message subject.
58
+ */
59
+ subject?: string;
60
+ /**
61
+ * The message date as an ISO 8601 string.
62
+ */
63
+ date?: string;
64
+ /**
65
+ * The plain-text body of the message.
66
+ */
67
+ textContent?: string;
68
+ /**
69
+ * The HTML body of the message.
70
+ */
71
+ htmlContent?: string;
72
+ /**
73
+ * The attachments included with the message.
74
+ */
75
+ attachments?: IEmailAttachment[];
76
+ /**
77
+ * Protocol-level flags on the message, for example \\Seen.
78
+ */
79
+ flags?: string[];
80
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Interface describing an email address with an optional display name.
3
+ */
4
+ export interface IEmailAddress {
5
+ /**
6
+ * The display name for the address.
7
+ */
8
+ name?: string;
9
+ /**
10
+ * The email address.
11
+ */
12
+ address: string;
13
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Interface describing an email attachment.
3
+ */
4
+ export interface IEmailAttachment {
5
+ /**
6
+ * The filename of the attachment.
7
+ */
8
+ filename?: string;
9
+ /**
10
+ * The MIME content type of the attachment.
11
+ */
12
+ contentType: string;
13
+ /**
14
+ * The attachment data encoded as a base64 string.
15
+ */
16
+ data: string;
17
+ }
@@ -0,0 +1,11 @@
1
+ import type { IComponent } from "@3sixty/core";
2
+ /**
3
+ * Interface describing a consumer that is notified when new emails are available.
4
+ */
5
+ export interface IEmailConsumer extends IComponent {
6
+ /**
7
+ * Called when new emails have been stored, prompting the consumer to query for them.
8
+ * @returns A promise that resolves when the consumer has processed the notification.
9
+ */
10
+ onNewMessages(): Promise<void>;
11
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Interface describing a single parsed email header.
3
+ */
4
+ export interface IEmailHeader {
5
+ /**
6
+ * The lowercase header name.
7
+ */
8
+ key: string;
9
+ /**
10
+ * The original header name preserving case.
11
+ */
12
+ originalKey: string;
13
+ /**
14
+ * The header value.
15
+ */
16
+ value: string;
17
+ }
@@ -0,0 +1,50 @@
1
+ import type { IComponent } from "@3sixty/core";
2
+ import type { IEmailProtocolConnectorAuthCallback } from "./IEmailProtocolConnectorAuthCallback.js";
3
+ import type { IEmailProtocolConnectorAuthState } from "./IEmailProtocolConnectorAuthState.js";
4
+ import type { IEmailProtocolConnectorOptions } from "./IEmailProtocolConnectorOptions.js";
5
+ import type { IEmailProtocolConnectorRetrievalCallback } from "./IEmailProtocolConnectorRetrievalCallback.js";
6
+ /**
7
+ * Interface describing an email protocol connector that handles message retrieval.
8
+ */
9
+ export interface IEmailProtocolConnector<TState = unknown, TAuthState extends IEmailProtocolConnectorAuthState = IEmailProtocolConnectorAuthState> extends IComponent {
10
+ /**
11
+ * Start the internal polling loop for the given instance.
12
+ * @param instanceId The identifier of the mailbox instance being polled.
13
+ * @param state The current connector state for the instance.
14
+ * @param authCallback Callback invoked when authentication fails during a poll cycle.
15
+ * @param retrievalCallback Callback invoked with retrieved messages after each poll cycle.
16
+ * @param options Options supplied by the owning component.
17
+ * @returns A promise that resolves when the polling loop has been started.
18
+ */
19
+ retrieve(instanceId: string, state: TState, authCallback: IEmailProtocolConnectorAuthCallback<TAuthState>, retrievalCallback: IEmailProtocolConnectorRetrievalCallback, options: IEmailProtocolConnectorOptions): Promise<void>;
20
+ /**
21
+ * Stop the internal polling loop.
22
+ * @returns A promise that resolves when the polling loop has been stopped.
23
+ */
24
+ retrieveStop(): Promise<void>;
25
+ /**
26
+ * Start an authentication flow for a mailbox before it is polled for the first time.
27
+ * Only implemented by connectors whose credentials are issued by an external flow, such as
28
+ * an OAuth consent redirect, so the caller can hand the flow straight to the operator who
29
+ * created the mailbox rather than waiting for the first poll to report it.
30
+ * @param instanceId The identifier of the mailbox instance being authenticated.
31
+ * @param state The current connector state for the instance, which may already hold credentials.
32
+ * @param options Options supplied by the owning component, carrying the callback URI the flow
33
+ * must return to and the state which correlates it back to the mailbox.
34
+ * @returns The auth state carrying the URL to open for the user, or undefined when the
35
+ * mailbox is already able to authenticate itself.
36
+ */
37
+ initiateAuth?(instanceId: string, state: TState, options: IEmailProtocolConnectorOptions): Promise<TAuthState | undefined>;
38
+ /**
39
+ * Complete an authentication flow the connector reported through its auth callback.
40
+ * Only implemented by connectors whose credentials are issued by an external flow, such as
41
+ * an OAuth consent redirect. The outcome is reported back through the auth callback the
42
+ * connector was given by retrieve, so nothing is returned here.
43
+ * @param instanceId The identifier of the mailbox instance being authenticated.
44
+ * @param authPayload The protocol-specific data handed to the redirect, such as an OAuth code.
45
+ * @param options Options supplied by the owning component, carrying the same callback URI the
46
+ * flow was started with.
47
+ * @returns A promise that resolves when the flow has been completed.
48
+ */
49
+ completeAuth?(instanceId: string, authPayload: unknown, options: IEmailProtocolConnectorOptions): Promise<void>;
50
+ }
@@ -0,0 +1,12 @@
1
+ import type { IError } from "@3sixty/core";
2
+ import type { IEmailProtocolConnectorAuthState } from "./IEmailProtocolConnectorAuthState.js";
3
+ /**
4
+ * Callback invoked by a protocol connector to report the outcome of an authentication attempt.
5
+ * @param mailboxId The identifier of the mailbox this authentication attempt belongs to.
6
+ * @param updatedState Optional connector state to persist on the mailbox entity, carrying any
7
+ * credentials the flow issued in the properties the connector state schema marks as secure.
8
+ * @param requiresAuth True if authentication failed due to invalid or expired credentials.
9
+ * @param authState Optional state produced during the auth flow, carrying the URL to open.
10
+ * @param authError Optional structured error covering all failure types (auth, connection, timeout, etc.).
11
+ */
12
+ export type IEmailProtocolConnectorAuthCallback<TAuthState extends IEmailProtocolConnectorAuthState = IEmailProtocolConnectorAuthState> = (mailboxId: string, updatedState: unknown | undefined, requiresAuth: boolean, authState?: TAuthState, authError?: IError) => Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The state a protocol connector produces when a mailbox has to be authenticated by an
3
+ * external flow. Connectors which carry more through the flow extend this with their own
4
+ * properties, but the URL is named here so callers can open it without knowing the protocol.
5
+ */
6
+ export interface IEmailProtocolConnectorAuthState {
7
+ /**
8
+ * The URL to open for the user to authenticate the mailbox, such as an OAuth consent URL.
9
+ * Absent when the connector has no URL to send the user to.
10
+ */
11
+ authUrl?: string;
12
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Options supplied to a protocol connector by the component which owns it.
3
+ */
4
+ export interface IEmailProtocolConnectorOptions {
5
+ /**
6
+ * The fixed URI an external authentication flow returns to, which correlates the response
7
+ * back to the mailbox it belongs to. Connectors which start such a flow must send the
8
+ * external service to this URI rather than one of their own.
9
+ * Absent when the owning component has no public origin recorded for the mailbox, which
10
+ * leaves a connector able to poll with the credentials it has but unable to start a flow.
11
+ */
12
+ callbackUri?: string;
13
+ /**
14
+ * The opaque value a connector must carry through an external authentication flow so the
15
+ * response returns to the owning component identifying both the partition and the mailbox.
16
+ * It is passed back verbatim, so the component needs no search to correlate the callback.
17
+ */
18
+ correlationState: string;
19
+ }
@@ -0,0 +1,10 @@
1
+ import type { IError } from "@3sixty/core";
2
+ import type { IEmail } from "./IEmail.js";
3
+ /**
4
+ * Callback invoked by a protocol connector to persist a single retrieved message.
5
+ * @param mailboxId The identifier of the mailbox this retrieval belongs to.
6
+ * @param message The message to persist.
7
+ * @param updatedState The connector state to persist on the mailbox entity after this message.
8
+ * @returns True if the message was persisted successfully; false causes the connector to exit the polling loop.
9
+ */
10
+ export type IEmailProtocolConnectorRetrievalCallback = (mailboxId: string, message: IEmail | undefined, updatedState: unknown, retrievalError?: IError) => Promise<boolean>;
@@ -0,0 +1,39 @@
1
+ import type { IComponent } from "@3sixty/core";
2
+ import type { IEmail } from "./IEmail.js";
3
+ import type { IStoredEmail } from "./IStoredEmail.js";
4
+ /**
5
+ * Interface describing the mail storage component for persisting and querying received emails.
6
+ */
7
+ export interface IMailStorageComponent extends IComponent {
8
+ /**
9
+ * Store an email received from a mailbox.
10
+ * @param mailboxId The identifier of the mailbox that received the email.
11
+ * @param email The email to store.
12
+ * @returns The identifier assigned to the stored email.
13
+ */
14
+ store(mailboxId: string, email: IEmail): Promise<string>;
15
+ /**
16
+ * Retrieve a stored email by its identifier.
17
+ * @param id The identifier of the stored email.
18
+ * @returns The stored email.
19
+ */
20
+ get(id: string): Promise<IStoredEmail>;
21
+ /**
22
+ * Remove a stored email by its identifier.
23
+ * @param id The identifier of the stored email to remove.
24
+ * @returns A promise that resolves when the email has been removed.
25
+ */
26
+ remove(id: string): Promise<void>;
27
+ /**
28
+ * Query stored emails received at or after a given epoch.
29
+ * @param sinceEpoch The ISO 8601 timestamp to filter emails received at or after.
30
+ * @param mailboxId An optional mailbox identifier to restrict results to.
31
+ * @param cursor An optional cursor for paginated results.
32
+ * @param limit An optional maximum number of results to return.
33
+ * @returns A page of stored emails and an optional cursor for the next page.
34
+ */
35
+ query(sinceEpoch: string, mailboxId?: string, cursor?: string, limit?: number): Promise<{
36
+ emails: IStoredEmail[];
37
+ cursor?: string;
38
+ }>;
39
+ }