@push.rocks/smartjmap 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,10 @@
1
- import { type IJmapMailBackend, type TJmapPrincipal } from './interfaces.backend.js';
1
+ import { type IJmapMailBackend, type TJmapPrincipal } from "./interfaces.backend.js";
2
+ /**
3
+ * Semantic capability marker for the bounded streaming-upload server surface.
4
+ * Consumers must check this exact value before relying on streaming backend
5
+ * uploads, upload concurrency limits, Bearer-only challenges, or error mapping.
6
+ */
7
+ export declare const JMAP_SERVER_STREAMING_API_VERSION: 1;
2
8
  /** Options for constructing a JmapServer. */
3
9
  export interface IJmapServerOptions {
4
10
  /** The storage backend; defaults to a fresh in-memory `MemoryMailBackend`. */
@@ -9,15 +15,29 @@ export interface IJmapServerOptions {
9
15
  * `addUser`/`addBearerToken`.
10
16
  */
11
17
  authenticate?: (request: Request) => Promise<TJmapPrincipal | null>;
18
+ /**
19
+ * WWW-Authenticate challenges advertised on a 401 response. Defaults to
20
+ * Bearer and Basic for the built-in registry. Custom authenticators should
21
+ * list only the schemes they actually accept.
22
+ */
23
+ authenticationChallenges?: string[];
12
24
  /**
13
25
  * Absolute base URL (e.g. `https://mail.example.com`) prefixed to the URLs
14
26
  * advertised in the session object. Defaults to relative URLs, which JMAP
15
27
  * clients resolve against the session resource URL.
16
28
  */
17
29
  baseUrl?: string;
30
+ /** Overrides for the limits advertised in the JMAP session and enforced by this server. */
31
+ limits?: Partial<IJmapServerLimits>;
32
+ /**
33
+ * Process-wide upload ceiling across authenticated principals. Must be at
34
+ * least the advertised per-principal maxConcurrentUpload value.
35
+ */
36
+ maxConcurrentUploadServer?: number;
37
+ /** Maps backend upload failures to an RFC 7807 response instead of a generic 500. */
38
+ mapUploadError?: (error: unknown) => IJmapUploadProblem | null | undefined;
18
39
  }
19
- /** The advertised — and enforced — RFC 8620 core limits. */
20
- export declare const JMAP_SERVER_LIMITS: {
40
+ export interface IJmapServerLimits {
21
41
  maxSizeUpload: number;
22
42
  maxConcurrentUpload: number;
23
43
  maxSizeRequest: number;
@@ -25,7 +45,16 @@ export declare const JMAP_SERVER_LIMITS: {
25
45
  maxCallsInRequest: number;
26
46
  maxObjectsInGet: number;
27
47
  maxObjectsInSet: number;
28
- };
48
+ }
49
+ export interface IJmapUploadProblem {
50
+ status: number;
51
+ type?: string;
52
+ detail: string;
53
+ limit?: string;
54
+ retryAfterSeconds?: number;
55
+ }
56
+ /** The advertised — and enforced — RFC 8620 core limits. */
57
+ export declare const JMAP_SERVER_LIMITS: IJmapServerLimits;
29
58
  /**
30
59
  * A JMAP server core (RFC 8620) with the RFC 8621 mail method surface,
31
60
  * dispatching all storage into a pluggable `IJmapMailBackend`.
@@ -45,12 +74,21 @@ export declare const JMAP_SERVER_LIMITS: {
45
74
  export declare class JmapServer {
46
75
  readonly backend: IJmapMailBackend;
47
76
  private options;
77
+ private readonly limits;
78
+ private readonly maxConcurrentUploadServer;
48
79
  private registry;
49
80
  private httpServer;
50
81
  private sockets;
51
82
  private eventStreams;
52
83
  private changeFeedUnsubscribe;
84
+ private cleanupErrors;
53
85
  private activeApiRequests;
86
+ private activeUploadRequests;
87
+ private activeUploadsByPrincipal;
88
+ private activeNodeRequests;
89
+ private nodeRequestControllers;
90
+ private stopping;
91
+ private authenticationChallenges;
54
92
  constructor(options?: IJmapServerOptions);
55
93
  /**
56
94
  * Registers Basic credentials in the default authenticator's registry.
@@ -105,6 +143,12 @@ export declare class JmapServer {
105
143
  private methodEmailSubmissionSet;
106
144
  /** Uses the client-provided envelope or derives it from the email's addresses. */
107
145
  private resolveEnvelope;
146
+ private cancelRequestBody;
147
+ private readRequestBodyBounded;
148
+ private createExactUploadBody;
149
+ private mappedUploadErrorResponse;
150
+ private requestBodyErrorResponse;
151
+ private handleStreamingUpload;
108
152
  private handleUpload;
109
153
  private handleDownload;
110
154
  private handleEventSource;
@@ -124,6 +168,7 @@ export declare class JmapServer {
124
168
  * against feed-driven pushes via the per-stream state tracking.
125
169
  */
126
170
  private pushAfterMutation;
171
+ private nodeRequestBody;
127
172
  private handleNodeRequest;
128
173
  private validateProperties;
129
174
  private projectObject;