{"version":3,"file":"index.js","names":["_fetch","require","_prefix","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","utils","_interopRequireWildcard","callbacks","_method","_errors","_utils2","_interface","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","MatrixHttpApi","FetchHttpApi","constructor","args","_defineProperty2","uploadContent","file","opts","_opts$includeFilename","_opts$abortController","_ref","_opts$type","_opts$name","includeFilename","abortController","AbortController","contentType","type","fileName","name","upload","loaded","total","defer","global","XMLHttpRequest","xhr","timeoutFn","abort","reject","Error","timeoutTimer","setTimeout","onreadystatechange","readyState","DONE","clearTimeout","status","DOMException","statusText","responseText","parseErrorResponse","resolve","JSON","parse","err","ConnectionError","onprogress","ev","_opts$progressHandler","progressHandler","url","getUrl","undefined","MediaPrefix","R0","searchParams","encodeURIComponent","useAuthorizationHeader","accessToken","open","Method","Post","href","setRequestHeader","send","signal","addEventListener","queryParams","filename","headers","authedRequest","prefix","abortSignal","then","response","onlyData","json","promise","finally","removeElement","uploads","elem","push","cancelUpload","find","u","getCurrentUploads","getContentUri","base","baseUrl","path","params","access_token"],"sources":["../../src/http-api/index.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { FetchHttpApi } from \"./fetch\";\nimport { FileType, IContentUri, IHttpOpts, Upload, UploadOpts, UploadResponse } from \"./interface\";\nimport { MediaPrefix } from \"./prefix\";\nimport * as utils from \"../utils\";\nimport * as callbacks from \"../realtime-callbacks\";\nimport { Method } from \"./method\";\nimport { ConnectionError } from \"./errors\";\nimport { parseErrorResponse } from \"./utils\";\n\nexport * from \"./interface\";\nexport * from \"./prefix\";\nexport * from \"./errors\";\nexport * from \"./method\";\nexport * from \"./utils\";\n\nexport class MatrixHttpApi extends FetchHttpApi {\n private uploads: Upload[] = [];\n\n /**\n * Upload content to the homeserver\n *\n * @param file - The object to upload. On a browser, something that\n * can be sent to XMLHttpRequest.send (typically a File). Under node.js,\n * a Buffer, String or ReadStream.\n *\n * @param opts - options object\n *\n * @returns Promise which resolves to response object, as\n * determined by this.opts.onlyData, opts.rawResponse, and\n * opts.onlyContentUri. Rejects with an error (usually a MatrixError).\n */\n public uploadContent(file: FileType, opts: UploadOpts = {}): Promise {\n const includeFilename = opts.includeFilename ?? true;\n const abortController = opts.abortController ?? new AbortController();\n\n // If the file doesn't have a mime type, use a default since the HS errors if we don't supply one.\n const contentType = opts.type ?? (file as File).type ?? \"application/octet-stream\";\n const fileName = opts.name ?? (file as File).name;\n\n const upload = {\n loaded: 0,\n total: 0,\n abortController,\n } as Upload;\n const defer = utils.defer();\n\n if (global.XMLHttpRequest) {\n const xhr = new global.XMLHttpRequest();\n\n const timeoutFn = function (): void {\n xhr.abort();\n defer.reject(new Error(\"Timeout\"));\n };\n\n // set an initial timeout of 30s; we'll advance it each time we get a progress notification\n let timeoutTimer = callbacks.setTimeout(timeoutFn, 30000);\n\n xhr.onreadystatechange = function (): void {\n switch (xhr.readyState) {\n case global.XMLHttpRequest.DONE:\n callbacks.clearTimeout(timeoutTimer);\n try {\n if (xhr.status === 0) {\n throw new DOMException(xhr.statusText, \"AbortError\"); // mimic fetch API\n }\n if (!xhr.responseText) {\n throw new Error(\"No response body.\");\n }\n\n if (xhr.status >= 400) {\n defer.reject(parseErrorResponse(xhr, xhr.responseText));\n } else {\n defer.resolve(JSON.parse(xhr.responseText));\n }\n } catch (err) {\n if ((err).name === \"AbortError\") {\n defer.reject(err);\n return;\n }\n defer.reject(new ConnectionError(\"request failed\", err));\n }\n break;\n }\n };\n\n xhr.upload.onprogress = (ev: ProgressEvent): void => {\n callbacks.clearTimeout(timeoutTimer);\n upload.loaded = ev.loaded;\n upload.total = ev.total;\n timeoutTimer = callbacks.setTimeout(timeoutFn, 30000);\n opts.progressHandler?.({\n loaded: ev.loaded,\n total: ev.total,\n });\n };\n\n const url = this.getUrl(\"/upload\", undefined, MediaPrefix.R0);\n\n if (includeFilename && fileName) {\n url.searchParams.set(\"filename\", encodeURIComponent(fileName));\n }\n\n if (!this.opts.useAuthorizationHeader && this.opts.accessToken) {\n url.searchParams.set(\"access_token\", encodeURIComponent(this.opts.accessToken));\n }\n\n xhr.open(Method.Post, url.href);\n if (this.opts.useAuthorizationHeader && this.opts.accessToken) {\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + this.opts.accessToken);\n }\n xhr.setRequestHeader(\"Content-Type\", contentType);\n xhr.send(file);\n\n abortController.signal.addEventListener(\"abort\", () => {\n xhr.abort();\n });\n } else {\n const queryParams: utils.QueryDict = {};\n if (includeFilename && fileName) {\n queryParams.filename = fileName;\n }\n\n const headers: Record = { \"Content-Type\": contentType };\n\n this.authedRequest(Method.Post, \"/upload\", queryParams, file, {\n prefix: MediaPrefix.R0,\n headers,\n abortSignal: abortController.signal,\n })\n .then((response) => {\n return this.opts.onlyData ? response : response.json();\n })\n .then(defer.resolve, defer.reject);\n }\n\n // remove the upload from the list on completion\n upload.promise = defer.promise.finally(() => {\n utils.removeElement(this.uploads, (elem) => elem === upload);\n });\n abortController.signal.addEventListener(\"abort\", () => {\n utils.removeElement(this.uploads, (elem) => elem === upload);\n defer.reject(new DOMException(\"Aborted\", \"AbortError\"));\n });\n this.uploads.push(upload);\n return upload.promise;\n }\n\n public cancelUpload(promise: Promise): boolean {\n const upload = this.uploads.find((u) => u.promise === promise);\n if (upload) {\n upload.abortController.abort();\n return true;\n }\n return false;\n }\n\n public getCurrentUploads(): Upload[] {\n return this.uploads;\n }\n\n /**\n * Get the content repository url with query parameters.\n * @returns An object with a 'base', 'path' and 'params' for base URL,\n * path and query parameters respectively.\n */\n public getContentUri(): IContentUri {\n return {\n base: this.opts.baseUrl,\n path: MediaPrefix.R0 + \"/upload\",\n params: {\n access_token: this.opts.accessToken!,\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAQAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAPA,IAAAS,KAAA,GAAAC,uBAAA,CAAAf,OAAA;AACA,IAAAgB,SAAA,GAAAD,uBAAA,CAAAf,OAAA;AACA,IAAAiB,OAAA,GAAAjB,OAAA;AAOAE,MAAA,CAAAC,IAAA,CAAAc,OAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAY,OAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,OAAA,CAAAZ,GAAA;IA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