imapkit 5.1.0 → 5.3.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 (48) hide show
  1. package/README.md +41 -23
  2. package/bin/help.txt +29 -3
  3. package/bin/imapkit.js +43 -0
  4. package/dist/browser/imapkit.js +99 -35
  5. package/dist/cjs/control.d.ts +16 -5
  6. package/dist/cjs/control.js +36 -5
  7. package/dist/cjs/oauth/http.d.ts +28 -0
  8. package/dist/cjs/oauth/http.js +216 -0
  9. package/dist/cjs/oauth/jwt.d.ts +33 -0
  10. package/dist/cjs/oauth/jwt.js +58 -0
  11. package/dist/cjs/oauth/pages.d.ts +47 -0
  12. package/dist/cjs/oauth/pages.js +310 -0
  13. package/dist/cjs/oauth/policy.d.ts +48 -0
  14. package/dist/cjs/oauth/policy.js +66 -0
  15. package/dist/cjs/oauth/provider.d.ts +455 -0
  16. package/dist/cjs/oauth/provider.js +1422 -0
  17. package/dist/cjs/plugins/oauthbearer.js +10 -15
  18. package/dist/cjs/plugins/xoauth2.js +4 -3
  19. package/dist/cjs/rest.d.ts +18 -1
  20. package/dist/cjs/rest.js +63 -35
  21. package/dist/cjs/server.d.ts +49 -1
  22. package/dist/cjs/server.js +126 -12
  23. package/dist/cjs/smtp-listener.d.ts +3 -2
  24. package/dist/cjs/smtp-listener.js +15 -3
  25. package/dist/cjs/types.d.ts +16 -0
  26. package/dist/esm/control.d.ts +16 -5
  27. package/dist/esm/control.js +36 -6
  28. package/dist/esm/oauth/http.d.ts +28 -0
  29. package/dist/esm/oauth/http.js +211 -0
  30. package/dist/esm/oauth/jwt.d.ts +33 -0
  31. package/dist/esm/oauth/jwt.js +50 -0
  32. package/dist/esm/oauth/pages.d.ts +47 -0
  33. package/dist/esm/oauth/pages.js +305 -0
  34. package/dist/esm/oauth/policy.d.ts +48 -0
  35. package/dist/esm/oauth/policy.js +59 -0
  36. package/dist/esm/oauth/provider.d.ts +455 -0
  37. package/dist/esm/oauth/provider.js +1415 -0
  38. package/dist/esm/plugins/oauthbearer.js +10 -15
  39. package/dist/esm/plugins/xoauth2.js +4 -3
  40. package/dist/esm/rest.d.ts +18 -1
  41. package/dist/esm/rest.js +62 -36
  42. package/dist/esm/server.d.ts +49 -1
  43. package/dist/esm/server.js +127 -13
  44. package/dist/esm/smtp-listener.d.ts +3 -2
  45. package/dist/esm/smtp-listener.js +15 -3
  46. package/dist/esm/types.d.ts +16 -0
  47. package/dist/plugin-help.json +2 -2
  48. package/package.json +7 -7
@@ -1,5 +1,7 @@
1
1
  import type { IMAPServer, IMAPConnection } from './server.js';
2
2
  import type { ScriptRule } from './script.js';
3
+ import type { OAuthOptions } from './oauth/provider.js';
4
+ import type { ConsentPolicy } from './oauth/policy.js';
3
5
  export type { IMAPServer, IMAPConnection };
4
6
  /**
5
7
  * A value of the parsed command or of a response, as imap-handler parses and compiles it: an
@@ -210,6 +212,12 @@ export interface MailboxStatus {
210
212
  }
211
213
  export interface UserData {
212
214
  password?: string | undefined;
215
+ /** the display name, the `name` claim of the OAuth provider */
216
+ displayName?: string | undefined;
217
+ /** OAuth provider settings of the user: the consent policy of sign-ins that name the user in login_hint */
218
+ oauth?: {
219
+ consent?: ConsentPolicy | undefined;
220
+ } | undefined;
213
221
  xoauth2?: {
214
222
  accessToken?: string | undefined;
215
223
  /**
@@ -228,6 +236,12 @@ export interface IMAPServerOptions {
228
236
  plugins?: (string | Plugin)[] | string | Plugin | undefined;
229
237
  users?: Record<string, UserData> | undefined;
230
238
  secureConnection?: boolean | undefined;
239
+ /** starts a second IMAP listener for implicit TLS (IMAPS) with `server.start()`, its sessions share the storage
240
+ * with the main listener. Without a host it listens on the host given to `start()` */
241
+ tls?: {
242
+ port?: number | undefined;
243
+ host?: string | undefined;
244
+ } | undefined;
231
245
  /** starts an SMTP server with `server.start()` that appends every received message to INBOX, needs the optional
232
246
  * smtp-server package */
233
247
  smtp?: {
@@ -240,6 +254,8 @@ export interface IMAPServerOptions {
240
254
  host?: string | undefined;
241
255
  token?: string | undefined;
242
256
  } | undefined;
257
+ /** starts the OAuth 2.0 / OpenID Connect provider with `server.start()`, see src/oauth/provider.ts */
258
+ oauth?: OAuthOptions | undefined;
243
259
  credentials?: {
244
260
  key: string | Buffer;
245
261
  cert: string | Buffer;
@@ -144,7 +144,7 @@
144
144
  "Works with and without SASL-IR [RFC4959]",
145
145
  "Valid login info, same as for XOAUTH2:",
146
146
  " Username (authzid, optional): testuser",
147
- " Access Token: testtoken"
147
+ " Access Token: testtoken, or a token of the OAuth provider"
148
148
  ],
149
149
  "OBJECTID": [
150
150
  "Adds OBJECTID [RFC8474] capability",
@@ -280,6 +280,6 @@
280
280
  "SASL-IR enabled and used while Gmail does not",
281
281
  "Valid login info:",
282
282
  " Username: testuser",
283
- " Access Token: testtoken"
283
+ " Access Token: testtoken, or a token of the OAuth provider"
284
284
  ]
285
285
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapkit",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Scriptable, strictly RFC compliant in-memory IMAP server for testing IMAP clients",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -95,16 +95,16 @@
95
95
  "@types/smtp-server": "3.5.13",
96
96
  "buffer": "6.0.3",
97
97
  "esbuild": "0.28.2",
98
- "eslint": "10.12.0",
98
+ "eslint": "10.14.0",
99
99
  "eslint-config-prettier": "10.1.8",
100
100
  "events": "3.3.0",
101
- "globals": "17.13.0",
102
- "imapflow": "2.2.9",
103
- "prettier": "3.9.9",
104
- "smtp-server": "3.19.17",
101
+ "globals": "17.14.0",
102
+ "imapflow": "2.10.0",
103
+ "prettier": "3.9.10",
104
+ "smtp-server": "3.21.3",
105
105
  "tsx": "4.23.15",
106
106
  "typescript": "6.0.3",
107
- "typescript-eslint": "8.71.1"
107
+ "typescript-eslint": "8.72.1"
108
108
  },
109
109
  "engines": {
110
110
  "node": ">=20.0.0"