@telecrypt-io/storage 0.5.21 → 0.5.22
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.
|
@@ -123,6 +123,7 @@ export interface CreateFromOidcOptions {
|
|
|
123
123
|
* If cancellation arrives after the mutation starts, the outcome is explicitly
|
|
124
124
|
* unknown: the caller must reconcile and may safely retry idempotent work. */
|
|
125
125
|
export declare function withMatrixMutationAbort<T>(_client: MatrixClient, operation: () => Promise<T>, signal?: AbortSignal, operationName?: string): Promise<T>;
|
|
126
|
+
export declare function boundedMatrixFetch(fetchFn: typeof fetch): typeof fetch;
|
|
126
127
|
export interface MatrixRequestOptions {
|
|
127
128
|
signal?: AbortSignal;
|
|
128
129
|
timeoutMs?: number;
|
|
@@ -78,6 +78,23 @@ async function readBoundedMatrixResponse(response, maxBytes, signal, abortError)
|
|
|
78
78
|
throw new Error("Matrix response body is too large");
|
|
79
79
|
if (!response.body)
|
|
80
80
|
return response;
|
|
81
|
+
// Fetch forbids a response body for 204, 205, and 304 responses. Some
|
|
82
|
+
// browser implementations nevertheless expose an empty response stream for
|
|
83
|
+
// a 204 from a proxy. Reconstructing that response with even an empty
|
|
84
|
+
// Uint8Array then throws before matrix-js-sdk can accept the successful
|
|
85
|
+
// response. Preserve the bodyless status after boundedly consuming the
|
|
86
|
+
// stream so callers such as FetchHttpApi can still read an empty Blob.
|
|
87
|
+
const bodylessStatus = response.status === 204 || response.status === 205 || response.status === 304;
|
|
88
|
+
if (bodylessStatus) {
|
|
89
|
+
if (body.bytes.byteLength !== 0) {
|
|
90
|
+
throw new Error("Matrix response body is invalid for a bodyless status");
|
|
91
|
+
}
|
|
92
|
+
return new Response(null, {
|
|
93
|
+
status: response.status,
|
|
94
|
+
statusText: response.statusText,
|
|
95
|
+
headers: response.headers,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
81
98
|
return new Response(body.bytes, {
|
|
82
99
|
status: response.status,
|
|
83
100
|
statusText: response.statusText,
|
|
@@ -92,7 +109,7 @@ function isMatrixStateOrMembershipUrl(input) {
|
|
|
92
109
|
: new URL(input.url, "https://matrix.invalid");
|
|
93
110
|
return /\/rooms\/[^/]+\/(?:state|members)(?:\/|$)/.test(url.pathname);
|
|
94
111
|
}
|
|
95
|
-
function boundedMatrixFetch(fetchFn) {
|
|
112
|
+
export function boundedMatrixFetch(fetchFn) {
|
|
96
113
|
const wrapped = ((input, init) => {
|
|
97
114
|
const pending = (async () => {
|
|
98
115
|
const controller = new AbortController();
|