diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-16 19:08:29 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-16 19:08:29 +0800 |
| commit | 434aa8343fdcbb4d5002f934979913c099489bee (patch) | |
| tree | 55bab4ec5a6151be57797d34f61faf5ea744471b /frontend-old/node_modules/@firebase/storage | |
| parent | 893c388d4e99442a36005e5971a87730623f946e (diff) | |
sdk, del
Diffstat (limited to 'frontend-old/node_modules/@firebase/storage')
100 files changed, 0 insertions, 25792 deletions
diff --git a/frontend-old/node_modules/@firebase/storage/README.md b/frontend-old/node_modules/@firebase/storage/README.md deleted file mode 100644 index 7c1c82b..0000000 --- a/frontend-old/node_modules/@firebase/storage/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# @firebase/storage - -This is the Cloud Storage component of the Firebase JS SDK. - -**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.** diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.browser.cjs.js b/frontend-old/node_modules/@firebase/storage/dist/index.browser.cjs.js deleted file mode 100644 index 4653254..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.browser.cjs.js +++ /dev/null @@ -1,3685 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var app = require('@firebase/app'); -var util = require('@firebase/util'); -var component = require('@firebase/component'); - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -const DEFAULT_HOST = 'firebasestorage.googleapis.com'; -/** - * The key in Firebase config json for the storage bucket. - */ -const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket'; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000; -/** - * 10 minutes - * - * The timeout for upload. - */ -const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000; -/** - * 1 second - */ -const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -class StorageError extends util.FirebaseError { - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code, message, status_ = 0) { - super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`); - this.status_ = status_; - /** - * Stores custom error data unique to the `StorageError`. - */ - this.customData = { serverResponse: null }; - this._baseMessage = this.message; - // Without this, `instanceof StorageError`, in tests for example, - // returns false. - Object.setPrototypeOf(this, StorageError.prototype); - } - get status() { - return this.status_; - } - set status(status) { - this.status_ = status; - } - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code) { - return prependCode(code) === this.code; - } - /** - * Optional response message that was added by the server. - */ - get serverResponse() { - return this.customData.serverResponse; - } - set serverResponse(serverResponse) { - this.customData.serverResponse = serverResponse; - if (this.customData.serverResponse) { - this.message = `${this._baseMessage}\n${this.customData.serverResponse}`; - } - else { - this.message = this._baseMessage; - } - } -} -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -exports.StorageErrorCode = void 0; -(function (StorageErrorCode) { - // Shared between all platforms - StorageErrorCode["UNKNOWN"] = "unknown"; - StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found"; - StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found"; - StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found"; - StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded"; - StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated"; - StorageErrorCode["UNAUTHORIZED"] = "unauthorized"; - StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app"; - StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded"; - StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum"; - StorageErrorCode["CANCELED"] = "canceled"; - // JS specific - StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name"; - StorageErrorCode["INVALID_URL"] = "invalid-url"; - StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket"; - StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket"; - StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob"; - StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size"; - StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url"; - StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument"; - StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count"; - StorageErrorCode["APP_DELETED"] = "app-deleted"; - StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation"; - StorageErrorCode["INVALID_FORMAT"] = "invalid-format"; - StorageErrorCode["INTERNAL_ERROR"] = "internal-error"; - StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment"; -})(exports.StorageErrorCode || (exports.StorageErrorCode = {})); -function prependCode(code) { - return 'storage/' + code; -} -function unknown() { - const message = 'An unknown error occurred, please check the error payload for ' + - 'server response.'; - return new StorageError(exports.StorageErrorCode.UNKNOWN, message); -} -function objectNotFound(path) { - return new StorageError(exports.StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist."); -} -function quotaExceeded(bucket) { - return new StorageError(exports.StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + - bucket + - "' exceeded, please view quota on " + - 'https://firebase.google.com/pricing/.'); -} -function unauthenticated() { - const message = 'User is not authenticated, please authenticate using Firebase ' + - 'Authentication and try again.'; - return new StorageError(exports.StorageErrorCode.UNAUTHENTICATED, message); -} -function unauthorizedApp() { - return new StorageError(exports.StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.'); -} -function unauthorized(path) { - return new StorageError(exports.StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'."); -} -function retryLimitExceeded() { - return new StorageError(exports.StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.'); -} -function canceled() { - return new StorageError(exports.StorageErrorCode.CANCELED, 'User canceled the upload/download.'); -} -function invalidUrl(url) { - return new StorageError(exports.StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'."); -} -function invalidDefaultBucket(bucket) { - return new StorageError(exports.StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'."); -} -function noDefaultBucket() { - return new StorageError(exports.StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' + - "found. Did you set the '" + - CONFIG_STORAGE_BUCKET_KEY + - "' property when initializing the app?"); -} -function cannotSliceBlob() { - return new StorageError(exports.StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.'); -} -function serverFileWrongSize() { - return new StorageError(exports.StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.'); -} -function noDownloadURL() { - return new StorageError(exports.StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.'); -} -function missingPolyFill(polyFill) { - return new StorageError(exports.StorageErrorCode.UNSUPPORTED_ENVIRONMENT, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`); -} -/** - * @internal - */ -function invalidArgument(message) { - return new StorageError(exports.StorageErrorCode.INVALID_ARGUMENT, message); -} -function appDeleted() { - return new StorageError(exports.StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.'); -} -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -function invalidRootOperation(name) { - return new StorageError(exports.StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + - name + - "' cannot be performed on a root reference, create a non-root " + - "reference using child, such as .child('file.png')."); -} -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -function invalidFormat(format, message) { - return new StorageError(exports.StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message); -} -/** - * @param message - A message describing the internal error. - */ -function internalError(message) { - throw new StorageError(exports.StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -class Location { - constructor(bucket, path) { - this.bucket = bucket; - this.path_ = path; - } - get path() { - return this.path_; - } - get isRoot() { - return this.path.length === 0; - } - fullServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o/' + encode(this.path); - } - bucketOnlyServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o'; - } - static makeFromBucketSpec(bucketString, host) { - let bucketLocation; - try { - bucketLocation = Location.makeFromUrl(bucketString, host); - } - catch (e) { - // Not valid URL, use as-is. This lets you put bare bucket names in - // config. - return new Location(bucketString, ''); - } - if (bucketLocation.path === '') { - return bucketLocation; - } - else { - throw invalidDefaultBucket(bucketString); - } - } - static makeFromUrl(url, host) { - let location = null; - const bucketDomain = '([A-Za-z0-9.\\-_]+)'; - function gsModify(loc) { - if (loc.path.charAt(loc.path.length - 1) === '/') { - loc.path_ = loc.path_.slice(0, -1); - } - } - const gsPath = '(/(.*))?$'; - const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i'); - const gsIndices = { bucket: 1, path: 3 }; - function httpModify(loc) { - loc.path_ = decodeURIComponent(loc.path); - } - const version = 'v[A-Za-z0-9_]+'; - const firebaseStorageHost = host.replace(/[.]/g, '\\.'); - const firebaseStoragePath = '(/([^?#]*).*)?$'; - const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`, 'i'); - const firebaseStorageIndices = { bucket: 1, path: 3 }; - const cloudStorageHost = host === DEFAULT_HOST - ? '(?:storage.googleapis.com|storage.cloud.google.com)' - : host; - const cloudStoragePath = '([^?#]*)'; - const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, 'i'); - const cloudStorageIndices = { bucket: 1, path: 2 }; - const groups = [ - { regex: gsRegex, indices: gsIndices, postModify: gsModify }, - { - regex: firebaseStorageRegExp, - indices: firebaseStorageIndices, - postModify: httpModify - }, - { - regex: cloudStorageRegExp, - indices: cloudStorageIndices, - postModify: httpModify - } - ]; - for (let i = 0; i < groups.length; i++) { - const group = groups[i]; - const captures = group.regex.exec(url); - if (captures) { - const bucketValue = captures[group.indices.bucket]; - let pathValue = captures[group.indices.path]; - if (!pathValue) { - pathValue = ''; - } - location = new Location(bucketValue, pathValue); - group.postModify(location); - break; - } - } - if (location == null) { - throw invalidUrl(url); - } - return location; - } -} - -/** - * A request whose promise always fails. - */ -class FailRequest { - constructor(error) { - this.promise_ = Promise.reject(error); - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(_appDelete = false) { } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -function start(doRequest, -// eslint-disable-next-line @typescript-eslint/no-explicit-any -backoffCompleteCb, timeout) { - // TODO(andysoto): make this code cleaner (probably refactor into an actual - // type instead of a bunch of functions with state shared in the closure) - let waitSeconds = 1; - // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯ - // TODO: find a way to exclude Node type definition for storage because storage only works in browser - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let retryTimeoutId = null; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let globalTimeoutId = null; - let hitTimeout = false; - let cancelState = 0; - function canceled() { - return cancelState === 2; - } - let triggeredCallback = false; - function triggerCallback(...args) { - if (!triggeredCallback) { - triggeredCallback = true; - backoffCompleteCb.apply(null, args); - } - } - function callWithDelay(millis) { - retryTimeoutId = setTimeout(() => { - retryTimeoutId = null; - doRequest(responseHandler, canceled()); - }, millis); - } - function clearGlobalTimeout() { - if (globalTimeoutId) { - clearTimeout(globalTimeoutId); - } - } - function responseHandler(success, ...args) { - if (triggeredCallback) { - clearGlobalTimeout(); - return; - } - if (success) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - const mustStop = canceled() || hitTimeout; - if (mustStop) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - if (waitSeconds < 64) { - /* TODO(andysoto): don't back off so quickly if we know we're offline. */ - waitSeconds *= 2; - } - let waitMillis; - if (cancelState === 1) { - cancelState = 2; - waitMillis = 0; - } - else { - waitMillis = (waitSeconds + Math.random()) * 1000; - } - callWithDelay(waitMillis); - } - let stopped = false; - function stop(wasTimeout) { - if (stopped) { - return; - } - stopped = true; - clearGlobalTimeout(); - if (triggeredCallback) { - return; - } - if (retryTimeoutId !== null) { - if (!wasTimeout) { - cancelState = 2; - } - clearTimeout(retryTimeoutId); - callWithDelay(0); - } - else { - if (!wasTimeout) { - cancelState = 1; - } - } - } - callWithDelay(0); - globalTimeoutId = setTimeout(() => { - hitTimeout = true; - stop(true); - }, timeout); - return stop; -} -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -function stop(id) { - id(false); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isJustDef(p) { - return p !== void 0; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function isFunction(p) { - return typeof p === 'function'; -} -function isNonArrayObject(p) { - return typeof p === 'object' && !Array.isArray(p); -} -function isString(p) { - return typeof p === 'string' || p instanceof String; -} -function isNativeBlob(p) { - return isNativeBlobDefined() && p instanceof Blob; -} -function isNativeBlobDefined() { - return typeof Blob !== 'undefined'; -} -function validateNumber(argument, minValue, maxValue, value) { - if (value < minValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`); - } - if (value > maxValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function makeUrl(urlPart, host, protocol) { - let origin = host; - if (protocol == null) { - origin = `https://${host}`; - } - return `${protocol}://${origin}/v0${urlPart}`; -} -function makeQueryString(params) { - const encode = encodeURIComponent; - let queryPart = '?'; - for (const key in params) { - if (params.hasOwnProperty(key)) { - const nextPart = encode(key) + '=' + encode(params[key]); - queryPart = queryPart + nextPart + '&'; - } - } - // Chop off the extra '&' or '?' on the end - queryPart = queryPart.slice(0, -1); - return queryPart; -} - -/** - * Error codes for requests made by the XhrIo wrapper. - */ -var ErrorCode; -(function (ErrorCode) { - ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR"; - ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR"; - ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT"; -})(ErrorCode || (ErrorCode = {})); - -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -function isRetryStatusCode(status, additionalRetryCodes) { - // The codes for which to retry came from this page: - // https://cloud.google.com/storage/docs/exponential-backoff - const isFiveHundredCode = status >= 500 && status < 600; - const extraRetryCodes = [ - // Request Timeout: web server didn't receive full request in time. - 408, - // Too Many Requests: you're getting rate-limited, basically. - 429 - ]; - const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1; - const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1; - return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Handles network logic for all Storage Requests, including error reporting and - * retries with backoff. - * - * @param I - the type of the backend's network response. - * @param - O the output type used by the rest of the SDK. The conversion - * happens in the specified `callback_`. - */ -class NetworkRequest { - constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) { - this.url_ = url_; - this.method_ = method_; - this.headers_ = headers_; - this.body_ = body_; - this.successCodes_ = successCodes_; - this.additionalRetryCodes_ = additionalRetryCodes_; - this.callback_ = callback_; - this.errorCallback_ = errorCallback_; - this.timeout_ = timeout_; - this.progressCallback_ = progressCallback_; - this.connectionFactory_ = connectionFactory_; - this.retry = retry; - this.isUsingEmulator = isUsingEmulator; - this.pendingConnection_ = null; - this.backoffId_ = null; - this.canceled_ = false; - this.appDelete_ = false; - this.promise_ = new Promise((resolve, reject) => { - this.resolve_ = resolve; - this.reject_ = reject; - this.start_(); - }); - } - /** - * Actually starts the retry loop. - */ - start_() { - const doTheRequest = (backoffCallback, canceled) => { - if (canceled) { - backoffCallback(false, new RequestEndStatus(false, null, true)); - return; - } - const connection = this.connectionFactory_(); - this.pendingConnection_ = connection; - const progressListener = progressEvent => { - const loaded = progressEvent.loaded; - const total = progressEvent.lengthComputable ? progressEvent.total : -1; - if (this.progressCallback_ !== null) { - this.progressCallback_(loaded, total); - } - }; - if (this.progressCallback_ !== null) { - connection.addUploadProgressListener(progressListener); - } - // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - connection - .send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_) - .then(() => { - if (this.progressCallback_ !== null) { - connection.removeUploadProgressListener(progressListener); - } - this.pendingConnection_ = null; - const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR; - const status = connection.getStatus(); - if (!hitServer || - (isRetryStatusCode(status, this.additionalRetryCodes_) && - this.retry)) { - const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT; - backoffCallback(false, new RequestEndStatus(false, null, wasCanceled)); - return; - } - const successCode = this.successCodes_.indexOf(status) !== -1; - backoffCallback(true, new RequestEndStatus(successCode, connection)); - }); - }; - /** - * @param requestWentThrough - True if the request eventually went - * through, false if it hit the retry limit or was canceled. - */ - const backoffDone = (requestWentThrough, status) => { - const resolve = this.resolve_; - const reject = this.reject_; - const connection = status.connection; - if (status.wasSuccessCode) { - try { - const result = this.callback_(connection, connection.getResponse()); - if (isJustDef(result)) { - resolve(result); - } - else { - resolve(); - } - } - catch (e) { - reject(e); - } - } - else { - if (connection !== null) { - const err = unknown(); - err.serverResponse = connection.getErrorText(); - if (this.errorCallback_) { - reject(this.errorCallback_(connection, err)); - } - else { - reject(err); - } - } - else { - if (status.canceled) { - const err = this.appDelete_ ? appDeleted() : canceled(); - reject(err); - } - else { - const err = retryLimitExceeded(); - reject(err); - } - } - } - }; - if (this.canceled_) { - backoffDone(false, new RequestEndStatus(false, null, true)); - } - else { - this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_); - } - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(appDelete) { - this.canceled_ = true; - this.appDelete_ = appDelete || false; - if (this.backoffId_ !== null) { - stop(this.backoffId_); - } - if (this.pendingConnection_ !== null) { - this.pendingConnection_.abort(); - } - } -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -class RequestEndStatus { - constructor(wasSuccessCode, connection, canceled) { - this.wasSuccessCode = wasSuccessCode; - this.connection = connection; - this.canceled = !!canceled; - } -} -function addAuthHeader_(headers, authToken) { - if (authToken !== null && authToken.length > 0) { - headers['Authorization'] = 'Firebase ' + authToken; - } -} -function addVersionHeader_(headers, firebaseVersion) { - headers['X-Firebase-Storage-Version'] = - 'webjs/' + (firebaseVersion ?? 'AppManager'); -} -function addGmpidHeader_(headers, appId) { - if (appId) { - headers['X-Firebase-GMPID'] = appId; - } -} -function addAppCheckHeader_(headers, appCheckToken) { - if (appCheckToken !== null) { - headers['X-Firebase-AppCheck'] = appCheckToken; - } -} -function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) { - const queryPart = makeQueryString(requestInfo.urlParams); - const url = requestInfo.url + queryPart; - const headers = Object.assign({}, requestInfo.headers); - addGmpidHeader_(headers, appId); - addAuthHeader_(headers, authToken); - addVersionHeader_(headers, firebaseVersion); - addAppCheckHeader_(headers, appCheckToken); - return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function getBlobBuilder() { - if (typeof BlobBuilder !== 'undefined') { - return BlobBuilder; - } - else if (typeof WebKitBlobBuilder !== 'undefined') { - return WebKitBlobBuilder; - } - else { - return undefined; - } -} -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -function getBlob$1(...args) { - const BlobBuilder = getBlobBuilder(); - if (BlobBuilder !== undefined) { - const bb = new BlobBuilder(); - for (let i = 0; i < args.length; i++) { - bb.append(args[i]); - } - return bb.getBlob(); - } - else { - if (isNativeBlobDefined()) { - return new Blob(args); - } - else { - throw new StorageError(exports.StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs"); - } - } -} -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -function sliceBlob(blob, start, end) { - if (blob.webkitSlice) { - return blob.webkitSlice(start, end); - } - else if (blob.mozSlice) { - return blob.mozSlice(start, end); - } - else if (blob.slice) { - return blob.slice(start, end); - } - return null; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -function decodeBase64(encoded) { - if (typeof atob === 'undefined') { - throw missingPolyFill('base-64'); - } - return atob(encoded); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -const StringFormat = { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - RAW: 'raw', - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64: 'base64', - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64URL: 'base64url', - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - DATA_URL: 'data_url' -}; -class StringData { - constructor(data, contentType) { - this.data = data; - this.contentType = contentType || null; - } -} -/** - * @internal - */ -function dataFromString(format, stringData) { - switch (format) { - case StringFormat.RAW: - return new StringData(utf8Bytes_(stringData)); - case StringFormat.BASE64: - case StringFormat.BASE64URL: - return new StringData(base64Bytes_(format, stringData)); - case StringFormat.DATA_URL: - return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData)); - // do nothing - } - // assert(false); - throw unknown(); -} -function utf8Bytes_(value) { - const b = []; - for (let i = 0; i < value.length; i++) { - let c = value.charCodeAt(i); - if (c <= 127) { - b.push(c); - } - else { - if (c <= 2047) { - b.push(192 | (c >> 6), 128 | (c & 63)); - } - else { - if ((c & 64512) === 55296) { - // The start of a surrogate pair. - const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320; - if (!valid) { - // The second surrogate wasn't there. - b.push(239, 191, 189); - } - else { - const hi = c; - const lo = value.charCodeAt(++i); - c = 65536 | ((hi & 1023) << 10) | (lo & 1023); - b.push(240 | (c >> 18), 128 | ((c >> 12) & 63), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - else { - if ((c & 64512) === 56320) { - // Invalid low surrogate. - b.push(239, 191, 189); - } - else { - b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - } - } - } - return new Uint8Array(b); -} -function percentEncodedBytes_(value) { - let decoded; - try { - decoded = decodeURIComponent(value); - } - catch (e) { - throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.'); - } - return utf8Bytes_(decoded); -} -function base64Bytes_(format, value) { - switch (format) { - case StringFormat.BASE64: { - const hasMinus = value.indexOf('-') !== -1; - const hasUnder = value.indexOf('_') !== -1; - if (hasMinus || hasUnder) { - const invalidChar = hasMinus ? '-' : '_'; - throw invalidFormat(format, "Invalid character '" + - invalidChar + - "' found: is it base64url encoded?"); - } - break; - } - case StringFormat.BASE64URL: { - const hasPlus = value.indexOf('+') !== -1; - const hasSlash = value.indexOf('/') !== -1; - if (hasPlus || hasSlash) { - const invalidChar = hasPlus ? '+' : '/'; - throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?"); - } - value = value.replace(/-/g, '+').replace(/_/g, '/'); - break; - } - // do nothing - } - let bytes; - try { - bytes = decodeBase64(value); - } - catch (e) { - if (e.message.includes('polyfill')) { - throw e; - } - throw invalidFormat(format, 'Invalid character found'); - } - const array = new Uint8Array(bytes.length); - for (let i = 0; i < bytes.length; i++) { - array[i] = bytes.charCodeAt(i); - } - return array; -} -class DataURLParts { - constructor(dataURL) { - this.base64 = false; - this.contentType = null; - const matches = dataURL.match(/^data:([^,]+)?,/); - if (matches === null) { - throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>"); - } - const middle = matches[1] || null; - if (middle != null) { - this.base64 = endsWith(middle, ';base64'); - this.contentType = this.base64 - ? middle.substring(0, middle.length - ';base64'.length) - : middle; - } - this.rest = dataURL.substring(dataURL.indexOf(',') + 1); - } -} -function dataURLBytes_(dataUrl) { - const parts = new DataURLParts(dataUrl); - if (parts.base64) { - return base64Bytes_(StringFormat.BASE64, parts.rest); - } - else { - return percentEncodedBytes_(parts.rest); - } -} -function dataURLContentType_(dataUrl) { - const parts = new DataURLParts(dataUrl); - return parts.contentType; -} -function endsWith(s, end) { - const longEnough = s.length >= end.length; - if (!longEnough) { - return false; - } - return s.substring(s.length - end.length) === end; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -class FbsBlob { - constructor(data, elideCopy) { - let size = 0; - let blobType = ''; - if (isNativeBlob(data)) { - this.data_ = data; - size = data.size; - blobType = data.type; - } - else if (data instanceof ArrayBuffer) { - if (elideCopy) { - this.data_ = new Uint8Array(data); - } - else { - this.data_ = new Uint8Array(data.byteLength); - this.data_.set(new Uint8Array(data)); - } - size = this.data_.length; - } - else if (data instanceof Uint8Array) { - if (elideCopy) { - this.data_ = data; - } - else { - this.data_ = new Uint8Array(data.length); - this.data_.set(data); - } - size = data.length; - } - this.size_ = size; - this.type_ = blobType; - } - size() { - return this.size_; - } - type() { - return this.type_; - } - slice(startByte, endByte) { - if (isNativeBlob(this.data_)) { - const realBlob = this.data_; - const sliced = sliceBlob(realBlob, startByte, endByte); - if (sliced === null) { - return null; - } - return new FbsBlob(sliced); - } - else { - const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte); - return new FbsBlob(slice, true); - } - } - static getBlob(...args) { - if (isNativeBlobDefined()) { - const blobby = args.map((val) => { - if (val instanceof FbsBlob) { - return val.data_; - } - else { - return val; - } - }); - return new FbsBlob(getBlob$1.apply(null, blobby)); - } - else { - const uint8Arrays = args.map((val) => { - if (isString(val)) { - return dataFromString(StringFormat.RAW, val).data; - } - else { - // Blobs don't exist, so this has to be a Uint8Array. - return val.data_; - } - }); - let finalLength = 0; - uint8Arrays.forEach((array) => { - finalLength += array.byteLength; - }); - const merged = new Uint8Array(finalLength); - let index = 0; - uint8Arrays.forEach((array) => { - for (let i = 0; i < array.length; i++) { - merged[index++] = array[i]; - } - }); - return new FbsBlob(merged, true); - } - } - uploadData() { - return this.data_; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -function jsonObjectOrNull(s) { - let obj; - try { - obj = JSON.parse(s); - } - catch (e) { - return null; - } - if (isNonArrayObject(obj)) { - return obj; - } - else { - return null; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -function parent(path) { - if (path.length === 0) { - return null; - } - const index = path.lastIndexOf('/'); - if (index === -1) { - return ''; - } - const newPath = path.slice(0, index); - return newPath; -} -function child(path, childPath) { - const canonicalChildPath = childPath - .split('/') - .filter(component => component.length > 0) - .join('/'); - if (path.length === 0) { - return canonicalChildPath; - } - else { - return path + '/' + canonicalChildPath; - } -} -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -function lastComponent(path) { - const index = path.lastIndexOf('/', path.length - 2); - if (index === -1) { - return path; - } - else { - return path.slice(index + 1); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function noXform_(metadata, value) { - return value; -} -class Mapping { - constructor(server, local, writable, xform) { - this.server = server; - this.local = local || server; - this.writable = !!writable; - this.xform = xform || noXform_; - } -} -let mappings_ = null; -function xformPath(fullPath) { - if (!isString(fullPath) || fullPath.length < 2) { - return fullPath; - } - else { - return lastComponent(fullPath); - } -} -function getMappings() { - if (mappings_) { - return mappings_; - } - const mappings = []; - mappings.push(new Mapping('bucket')); - mappings.push(new Mapping('generation')); - mappings.push(new Mapping('metageneration')); - mappings.push(new Mapping('name', 'fullPath', true)); - function mappingsXformPath(_metadata, fullPath) { - return xformPath(fullPath); - } - const nameMapping = new Mapping('name'); - nameMapping.xform = mappingsXformPath; - mappings.push(nameMapping); - /** - * Coerces the second param to a number, if it is defined. - */ - function xformSize(_metadata, size) { - if (size !== undefined) { - return Number(size); - } - else { - return size; - } - } - const sizeMapping = new Mapping('size'); - sizeMapping.xform = xformSize; - mappings.push(sizeMapping); - mappings.push(new Mapping('timeCreated')); - mappings.push(new Mapping('updated')); - mappings.push(new Mapping('md5Hash', null, true)); - mappings.push(new Mapping('cacheControl', null, true)); - mappings.push(new Mapping('contentDisposition', null, true)); - mappings.push(new Mapping('contentEncoding', null, true)); - mappings.push(new Mapping('contentLanguage', null, true)); - mappings.push(new Mapping('contentType', null, true)); - mappings.push(new Mapping('metadata', 'customMetadata', true)); - mappings_ = mappings; - return mappings_; -} -function addRef(metadata, service) { - function generateRef() { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const loc = new Location(bucket, path); - return service._makeStorageReference(loc); - } - Object.defineProperty(metadata, 'ref', { get: generateRef }); -} -function fromResource(service, resource, mappings) { - const metadata = {}; - metadata['type'] = 'file'; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]); - } - addRef(metadata, service); - return metadata; -} -function fromResourceString(service, resourceString, mappings) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromResource(service, resource, mappings); -} -function downloadUrlFromResourceString(metadata, resourceString, host, protocol) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - if (!isString(obj['downloadTokens'])) { - // This can happen if objects are uploaded through GCS and retrieved - // through list, so we don't want to throw an Error. - return null; - } - const tokens = obj['downloadTokens']; - if (tokens.length === 0) { - return null; - } - const encode = encodeURIComponent; - const tokensList = tokens.split(','); - const urls = tokensList.map((token) => { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path); - const base = makeUrl(urlPart, host, protocol); - const queryString = makeQueryString({ - alt: 'media', - token - }); - return base + queryString; - }); - return urls[0]; -} -function toResourceString(metadata, mappings) { - const resource = {}; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - if (mapping.writable) { - resource[mapping.server] = metadata[mapping.local]; - } - } - return JSON.stringify(resource); -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const PREFIXES_KEY = 'prefixes'; -const ITEMS_KEY = 'items'; -function fromBackendResponse(service, bucket, resource) { - const listResult = { - prefixes: [], - items: [], - nextPageToken: resource['nextPageToken'] - }; - if (resource[PREFIXES_KEY]) { - for (const path of resource[PREFIXES_KEY]) { - const pathWithoutTrailingSlash = path.replace(/\/$/, ''); - const reference = service._makeStorageReference(new Location(bucket, pathWithoutTrailingSlash)); - listResult.prefixes.push(reference); - } - } - if (resource[ITEMS_KEY]) { - for (const item of resource[ITEMS_KEY]) { - const reference = service._makeStorageReference(new Location(bucket, item['name'])); - listResult.items.push(reference); - } - } - return listResult; -} -function fromResponseString(service, bucket, resourceString) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromBackendResponse(service, bucket, resource); -} - -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -class RequestInfo { - constructor(url, method, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler, timeout) { - this.url = url; - this.method = method; - this.handler = handler; - this.timeout = timeout; - this.urlParams = {}; - this.headers = {}; - this.body = null; - this.errorHandler = null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - this.progressCallback = null; - this.successCodes = [200]; - this.additionalRetryCodes = []; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -function handlerCheck(cndn) { - if (!cndn) { - throw unknown(); - } -} -function metadataHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return metadata; - } - return handler; -} -function listHandler(service, bucket) { - function handler(xhr, text) { - const listResult = fromResponseString(service, bucket, text); - handlerCheck(listResult !== null); - return listResult; - } - return handler; -} -function downloadUrlHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return downloadUrlFromResourceString(metadata, text, service.host, service._protocol); - } - return handler; -} -function sharedErrorHandler(location) { - function errorHandler(xhr, err) { - let newErr; - if (xhr.getStatus() === 401) { - if ( - // This exact message string is the only consistent part of the - // server's error response that identifies it as an App Check error. - xhr.getErrorText().includes('Firebase App Check token is invalid')) { - newErr = unauthorizedApp(); - } - else { - newErr = unauthenticated(); - } - } - else { - if (xhr.getStatus() === 402) { - newErr = quotaExceeded(location.bucket); - } - else { - if (xhr.getStatus() === 403) { - newErr = unauthorized(location.path); - } - else { - newErr = err; - } - } - } - newErr.status = xhr.getStatus(); - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function objectErrorHandler(location) { - const shared = sharedErrorHandler(location); - function errorHandler(xhr, err) { - let newErr = shared(xhr, err); - if (xhr.getStatus() === 404) { - newErr = objectNotFound(location.path); - } - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function getMetadata$2(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function list$2(service, location, delimiter, pageToken, maxResults) { - const urlParams = {}; - if (location.isRoot) { - urlParams['prefix'] = ''; - } - else { - urlParams['prefix'] = location.path + '/'; - } - if (delimiter && delimiter.length > 0) { - urlParams['delimiter'] = delimiter; - } - if (pageToken) { - urlParams['pageToken'] = pageToken; - } - if (maxResults) { - urlParams['maxResults'] = maxResults; - } - const urlPart = location.bucketOnlyServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, listHandler(service, location.bucket), timeout); - requestInfo.urlParams = urlParams; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -function getBytes$1(service, location, maxDownloadSizeBytes) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media'; - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout); - requestInfo.errorHandler = objectErrorHandler(location); - if (maxDownloadSizeBytes !== undefined) { - requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`; - requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */]; - } - return requestInfo; -} -function getDownloadUrl(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function updateMetadata$2(service, location, metadata, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'PATCH'; - const body = toResourceString(metadata, mappings); - const headers = { 'Content-Type': 'application/json; charset=utf-8' }; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function deleteObject$2(service, location) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'DELETE'; - const timeout = service.maxOperationRetryTime; - function handler(_xhr, _text) { } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.successCodes = [200, 204]; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function determineContentType_(metadata, blob) { - return ((metadata && metadata['contentType']) || - (blob && blob.type()) || - 'application/octet-stream'); -} -function metadataForUpload_(location, blob, metadata) { - const metadataClone = Object.assign({}, metadata); - metadataClone['fullPath'] = location.path; - metadataClone['size'] = blob.size(); - if (!metadataClone['contentType']) { - metadataClone['contentType'] = determineContentType_(null, blob); - } - return metadataClone; -} -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -function multipartUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const headers = { - 'X-Goog-Upload-Protocol': 'multipart' - }; - function genBoundary() { - let str = ''; - for (let i = 0; i < 2; i++) { - str = str + Math.random().toString().slice(2); - } - return str; - } - const boundary = genBoundary(); - headers['Content-Type'] = 'multipart/related; boundary=' + boundary; - const metadata_ = metadataForUpload_(location, blob, metadata); - const metadataString = toResourceString(metadata_, mappings); - const preBlobPart = '--' + - boundary + - '\r\n' + - 'Content-Type: application/json; charset=utf-8\r\n\r\n' + - metadataString + - '\r\n--' + - boundary + - '\r\n' + - 'Content-Type: ' + - metadata_['contentType'] + - '\r\n\r\n'; - const postBlobPart = '\r\n--' + boundary + '--'; - const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart); - if (body === null) { - throw cannotSliceBlob(); - } - const urlParams = { name: metadata_['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -class ResumableUploadStatus { - constructor(current, total, finalized, metadata) { - this.current = current; - this.total = total; - this.finalized = !!finalized; - this.metadata = metadata || null; - } -} -function checkResumeHeader_(xhr, allowed) { - let status = null; - try { - status = xhr.getResponseHeader('X-Goog-Upload-Status'); - } - catch (e) { - handlerCheck(false); - } - const allowedStatus = allowed || ['active']; - handlerCheck(!!status && allowedStatus.indexOf(status) !== -1); - return status; -} -function createResumableUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const metadataForUpload = metadataForUpload_(location, blob, metadata); - const urlParams = { name: metadataForUpload['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const headers = { - 'X-Goog-Upload-Protocol': 'resumable', - 'X-Goog-Upload-Command': 'start', - 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`, - 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType'], - 'Content-Type': 'application/json; charset=utf-8' - }; - const body = toResourceString(metadataForUpload, mappings); - const timeout = service.maxUploadRetryTime; - function handler(xhr) { - checkResumeHeader_(xhr); - let url; - try { - url = xhr.getResponseHeader('X-Goog-Upload-URL'); - } - catch (e) { - handlerCheck(false); - } - handlerCheck(isString(url)); - return url; - } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -function getResumableUploadStatus(service, location, url, blob) { - const headers = { 'X-Goog-Upload-Command': 'query' }; - function handler(xhr) { - const status = checkResumeHeader_(xhr, ['active', 'final']); - let sizeString = null; - try { - sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received'); - } - catch (e) { - handlerCheck(false); - } - if (!sizeString) { - // null or empty string - handlerCheck(false); - } - const size = Number(sizeString); - handlerCheck(!isNaN(size)); - return new ResumableUploadStatus(size, blob.size(), status === 'final'); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -const RESUMABLE_UPLOAD_CHUNK_SIZE = 256 * 1024; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -function continueResumableUpload(location, service, url, blob, chunkSize, mappings, status, progressCallback) { - // TODO(andysoto): standardize on internal asserts - // assert(!(opt_status && opt_status.finalized)); - const status_ = new ResumableUploadStatus(0, 0); - if (status) { - status_.current = status.current; - status_.total = status.total; - } - else { - status_.current = 0; - status_.total = blob.size(); - } - if (blob.size() !== status_.total) { - throw serverFileWrongSize(); - } - const bytesLeft = status_.total - status_.current; - let bytesToUpload = bytesLeft; - if (chunkSize > 0) { - bytesToUpload = Math.min(bytesToUpload, chunkSize); - } - const startByte = status_.current; - const endByte = startByte + bytesToUpload; - let uploadCommand = ''; - if (bytesToUpload === 0) { - uploadCommand = 'finalize'; - } - else if (bytesLeft === bytesToUpload) { - uploadCommand = 'upload, finalize'; - } - else { - uploadCommand = 'upload'; - } - const headers = { - 'X-Goog-Upload-Command': uploadCommand, - 'X-Goog-Upload-Offset': `${status_.current}` - }; - const body = blob.slice(startByte, endByte); - if (body === null) { - throw cannotSliceBlob(); - } - function handler(xhr, text) { - // TODO(andysoto): Verify the MD5 of each uploaded range: - // the 'x-range-md5' header comes back with status code 308 responses. - // We'll only be able to bail out though, because you can't re-upload a - // range that you previously uploaded. - const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']); - const newCurrent = status_.current + bytesToUpload; - const size = blob.size(); - let metadata; - if (uploadStatus === 'final') { - metadata = metadataHandler(service, mappings)(xhr, text); - } - else { - metadata = null; - } - return new ResumableUploadStatus(newCurrent, size, uploadStatus === 'final', metadata); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.progressCallback = progressCallback || null; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An event that is triggered on a task. - * @internal - */ -const TaskEvent = { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: 'state_changed' -}; -// type keys = keyof TaskState -/** - * Represents the current state of a running upload. - * @internal - */ -const TaskState = { - /** The task is currently transferring data. */ - RUNNING: 'running', - /** The task was paused by the user. */ - PAUSED: 'paused', - /** The task completed successfully. */ - SUCCESS: 'success', - /** The task was canceled. */ - CANCELED: 'canceled', - /** The task failed with an error. */ - ERROR: 'error' -}; -function taskStateFromInternalTaskState(state) { - switch (state) { - case "running" /* InternalTaskState.RUNNING */: - case "pausing" /* InternalTaskState.PAUSING */: - case "canceling" /* InternalTaskState.CANCELING */: - return TaskState.RUNNING; - case "paused" /* InternalTaskState.PAUSED */: - return TaskState.PAUSED; - case "success" /* InternalTaskState.SUCCESS */: - return TaskState.SUCCESS; - case "canceled" /* InternalTaskState.CANCELED */: - return TaskState.CANCELED; - case "error" /* InternalTaskState.ERROR */: - return TaskState.ERROR; - default: - // TODO(andysoto): assert(false); - return TaskState.ERROR; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -class Observer { - constructor(nextOrObserver, error, complete) { - const asFunctions = isFunction(nextOrObserver) || error != null || complete != null; - if (asFunctions) { - this.next = nextOrObserver; - this.error = error ?? undefined; - this.complete = complete ?? undefined; - } - else { - const observer = nextOrObserver; - this.next = observer.next; - this.error = observer.error; - this.complete = observer.complete; - } - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -// eslint-disable-next-line @typescript-eslint/ban-types -function async(f) { - return (...argsToForward) => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.resolve().then(() => f(...argsToForward)); - }; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** An override for the text-based Connection. Used in tests. */ -let textFactoryOverride = null; -/** - * Network layer for browsers. We use this instead of goog.net.XhrIo because - * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android. - */ -class XhrConnection { - constructor() { - this.sent_ = false; - this.xhr_ = new XMLHttpRequest(); - this.initXhr(); - this.errorCode_ = ErrorCode.NO_ERROR; - this.sendPromise_ = new Promise(resolve => { - this.xhr_.addEventListener('abort', () => { - this.errorCode_ = ErrorCode.ABORT; - resolve(); - }); - this.xhr_.addEventListener('error', () => { - this.errorCode_ = ErrorCode.NETWORK_ERROR; - resolve(); - }); - this.xhr_.addEventListener('load', () => { - resolve(); - }); - }); - } - send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - if (util.isCloudWorkstation(url) && isUsingEmulator) { - this.xhr_.withCredentials = true; - } - this.sent_ = true; - this.xhr_.open(method, url, true); - if (headers !== undefined) { - for (const key in headers) { - if (headers.hasOwnProperty(key)) { - this.xhr_.setRequestHeader(key, headers[key].toString()); - } - } - } - if (body !== undefined) { - this.xhr_.send(body); - } - else { - this.xhr_.send(); - } - return this.sendPromise_; - } - getErrorCode() { - if (!this.sent_) { - throw internalError('cannot .getErrorCode() before sending'); - } - return this.errorCode_; - } - getStatus() { - if (!this.sent_) { - throw internalError('cannot .getStatus() before sending'); - } - try { - return this.xhr_.status; - } - catch (e) { - return -1; - } - } - getResponse() { - if (!this.sent_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.xhr_.response; - } - getErrorText() { - if (!this.sent_) { - throw internalError('cannot .getErrorText() before sending'); - } - return this.xhr_.statusText; - } - /** Aborts the request. */ - abort() { - this.xhr_.abort(); - } - getResponseHeader(header) { - return this.xhr_.getResponseHeader(header); - } - addUploadProgressListener(listener) { - if (this.xhr_.upload != null) { - this.xhr_.upload.addEventListener('progress', listener); - } - } - removeUploadProgressListener(listener) { - if (this.xhr_.upload != null) { - this.xhr_.upload.removeEventListener('progress', listener); - } - } -} -class XhrTextConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'text'; - } -} -function newTextConnection() { - return textFactoryOverride ? textFactoryOverride() : new XhrTextConnection(); -} -class XhrBytesConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'arraybuffer'; - } -} -function newBytesConnection() { - return new XhrBytesConnection(); -} -class XhrBlobConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'blob'; - } -} -function newBlobConnection() { - return new XhrBlobConnection(); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -class UploadTask { - isExponentialBackoffExpired() { - return this.sleepTime > this.maxSleepTime; - } - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref, blob, metadata = null) { - /** - * Number of bytes transferred so far. - */ - this._transferred = 0; - this._needToFetchStatus = false; - this._needToFetchMetadata = false; - this._observers = []; - this._error = undefined; - this._uploadUrl = undefined; - this._request = undefined; - this._chunkMultiplier = 1; - this._resolve = undefined; - this._reject = undefined; - this._ref = ref; - this._blob = blob; - this._metadata = metadata; - this._mappings = getMappings(); - this._resumable = this._shouldDoResumable(this._blob); - this._state = "running" /* InternalTaskState.RUNNING */; - this._errorHandler = error => { - this._request = undefined; - this._chunkMultiplier = 1; - if (error._codeEquals(exports.StorageErrorCode.CANCELED)) { - this._needToFetchStatus = true; - this.completeTransitions_(); - } - else { - const backoffExpired = this.isExponentialBackoffExpired(); - if (isRetryStatusCode(error.status, [])) { - if (backoffExpired) { - error = retryLimitExceeded(); - } - else { - this.sleepTime = Math.max(this.sleepTime * 2, DEFAULT_MIN_SLEEP_TIME_MILLIS); - this._needToFetchStatus = true; - this.completeTransitions_(); - return; - } - } - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this._metadataErrorHandler = error => { - this._request = undefined; - if (error._codeEquals(exports.StorageErrorCode.CANCELED)) { - this.completeTransitions_(); - } - else { - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this.sleepTime = 0; - this.maxSleepTime = this._ref.storage.maxUploadRetryTime; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - this._start(); - }); - // Prevent uncaught rejections on the internal promise from bubbling out - // to the top level with a dummy handler. - this._promise.then(null, () => { }); - } - _makeProgressCallback() { - const sizeBefore = this._transferred; - return loaded => this._updateProgress(sizeBefore + loaded); - } - _shouldDoResumable(blob) { - return blob.size() > 256 * 1024; - } - _start() { - if (this._state !== "running" /* InternalTaskState.RUNNING */) { - // This can happen if someone pauses us in a resume callback, for example. - return; - } - if (this._request !== undefined) { - return; - } - if (this._resumable) { - if (this._uploadUrl === undefined) { - this._createResumable(); - } - else { - if (this._needToFetchStatus) { - this._fetchStatus(); - } - else { - if (this._needToFetchMetadata) { - // Happens if we miss the metadata on upload completion. - this._fetchMetadata(); - } - else { - this.pendingTimeout = setTimeout(() => { - this.pendingTimeout = undefined; - this._continueUpload(); - }, this.sleepTime); - } - } - } - } - else { - this._oneShotUpload(); - } - } - _resolveToken(callback) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.all([ - this._ref.storage._getAuthToken(), - this._ref.storage._getAppCheckToken() - ]).then(([authToken, appCheckToken]) => { - switch (this._state) { - case "running" /* InternalTaskState.RUNNING */: - callback(authToken, appCheckToken); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - } - }); - } - // TODO(andysoto): assert false - _createResumable() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = createRequest; - createRequest.getPromise().then((url) => { - this._request = undefined; - this._uploadUrl = url; - this._needToFetchStatus = false; - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _fetchStatus() { - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob); - const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = statusRequest; - statusRequest.getPromise().then(status => { - status = status; - this._request = undefined; - this._updateProgress(status.current); - this._needToFetchStatus = false; - if (status.finalized) { - this._needToFetchMetadata = true; - } - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _continueUpload() { - const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - const status = new ResumableUploadStatus(this._transferred, this._blob.size()); - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - let requestInfo; - try { - requestInfo = continueResumableUpload(this._ref._location, this._ref.storage, url, this._blob, chunkSize, this._mappings, status, this._makeProgressCallback()); - } - catch (e) { - this._error = e; - this._transition("error" /* InternalTaskState.ERROR */); - return; - } - const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken, - /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file. - ); - this._request = uploadRequest; - uploadRequest.getPromise().then((newStatus) => { - this._increaseMultiplier(); - this._request = undefined; - this._updateProgress(newStatus.current); - if (newStatus.finalized) { - this._metadata = newStatus.metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - } - else { - this.completeTransitions_(); - } - }, this._errorHandler); - }); - } - _increaseMultiplier() { - const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - // Max chunk size is 32M. - if (currentSize * 2 < 32 * 1024 * 1024) { - this._chunkMultiplier *= 2; - } - } - _fetchMetadata() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings); - const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = metadataRequest; - metadataRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._metadataErrorHandler); - }); - } - _oneShotUpload() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = multipartRequest; - multipartRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._updateProgress(this._blob.size()); - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._errorHandler); - }); - } - _updateProgress(transferred) { - const old = this._transferred; - this._transferred = transferred; - // A progress update can make the "transferred" value smaller (e.g. a - // partial upload not completed by server, after which the "transferred" - // value may reset to the value at the beginning of the request). - if (this._transferred !== old) { - this._notifyObservers(); - } - } - _transition(state) { - if (this._state === state) { - return; - } - switch (state) { - case "canceling" /* InternalTaskState.CANCELING */: - case "pausing" /* InternalTaskState.PAUSING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING); - this._state = state; - if (this._request !== undefined) { - this._request.cancel(); - } - else if (this.pendingTimeout) { - clearTimeout(this.pendingTimeout); - this.pendingTimeout = undefined; - this.completeTransitions_(); - } - break; - case "running" /* InternalTaskState.RUNNING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.PAUSING); - const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */; - this._state = state; - if (wasPaused) { - this._notifyObservers(); - this._start(); - } - break; - case "paused" /* InternalTaskState.PAUSED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSING); - this._state = state; - this._notifyObservers(); - break; - case "canceled" /* InternalTaskState.CANCELED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.CANCELING); - this._error = canceled(); - this._state = state; - this._notifyObservers(); - break; - case "error" /* InternalTaskState.ERROR */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - case "success" /* InternalTaskState.SUCCESS */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - } - } - completeTransitions_() { - switch (this._state) { - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "running" /* InternalTaskState.RUNNING */: - this._start(); - break; - } - } - /** - * A snapshot of the current task state. - */ - get snapshot() { - const externalState = taskStateFromInternalTaskState(this._state); - return { - bytesTransferred: this._transferred, - totalBytes: this._blob.size(), - state: externalState, - metadata: this._metadata, - task: this, - ref: this._ref - }; - } - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type, nextOrObserver, error, completed) { - // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string. - const observer = new Observer(nextOrObserver || undefined, error || undefined, completed || undefined); - this._addObserver(observer); - return () => { - this._removeObserver(observer); - }; - } - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled, onRejected) { - // These casts are needed so that TypeScript can infer the types of the - // resulting Promise. - return this._promise.then(onFulfilled, onRejected); - } - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected) { - return this.then(null, onRejected); - } - /** - * Adds the given observer. - */ - _addObserver(observer) { - this._observers.push(observer); - this._notifyObserver(observer); - } - /** - * Removes the given observer. - */ - _removeObserver(observer) { - const i = this._observers.indexOf(observer); - if (i !== -1) { - this._observers.splice(i, 1); - } - } - _notifyObservers() { - this._finishPromise(); - const observers = this._observers.slice(); - observers.forEach(observer => { - this._notifyObserver(observer); - }); - } - _finishPromise() { - if (this._resolve !== undefined) { - let triggered = true; - switch (taskStateFromInternalTaskState(this._state)) { - case TaskState.SUCCESS: - async(this._resolve.bind(null, this.snapshot))(); - break; - case TaskState.CANCELED: - case TaskState.ERROR: - const toCall = this._reject; - async(toCall.bind(null, this._error))(); - break; - default: - triggered = false; - break; - } - if (triggered) { - this._resolve = undefined; - this._reject = undefined; - } - } - } - _notifyObserver(observer) { - const externalState = taskStateFromInternalTaskState(this._state); - switch (externalState) { - case TaskState.RUNNING: - case TaskState.PAUSED: - if (observer.next) { - async(observer.next.bind(observer, this.snapshot))(); - } - break; - case TaskState.SUCCESS: - if (observer.complete) { - async(observer.complete.bind(observer))(); - } - break; - case TaskState.CANCELED: - case TaskState.ERROR: - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - break; - default: - // TODO(andysoto): assert(false); - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - } - } - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume() { - const valid = this._state === "paused" /* InternalTaskState.PAUSED */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("running" /* InternalTaskState.RUNNING */); - } - return valid; - } - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */; - if (valid) { - this._transition("pausing" /* InternalTaskState.PAUSING */); - } - return valid; - } - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("canceling" /* InternalTaskState.CANCELING */); - } - return valid; - } -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -class Reference { - constructor(_service, location) { - this._service = _service; - if (location instanceof Location) { - this._location = location; - } - else { - this._location = Location.makeFromUrl(location, _service.host); - } - } - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString() { - return 'gs://' + this._location.bucket + '/' + this._location.path; - } - _newRef(service, location) { - return new Reference(service, location); - } - /** - * A reference to the root of this object's bucket. - */ - get root() { - const location = new Location(this._location.bucket, ''); - return this._newRef(this._service, location); - } - /** - * The name of the bucket containing this reference's object. - */ - get bucket() { - return this._location.bucket; - } - /** - * The full path of this object. - */ - get fullPath() { - return this._location.path; - } - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name() { - return lastComponent(this._location.path); - } - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage() { - return this._service; - } - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent() { - const newPath = parent(this._location.path); - if (newPath === null) { - return null; - } - const location = new Location(this._location.bucket, newPath); - return new Reference(this._service, location); - } - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name) { - if (this._location.path === '') { - throw invalidRootOperation(name); - } - } -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -function getBytesInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBytes'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBytesConnection) - .then(bytes => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - bytes.slice(0, maxDownloadSizeBytes) - : bytes); -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded blob. - */ -function getBlobInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBlob'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBlobConnection) - .then(blob => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - blob.slice(0, maxDownloadSizeBytes) - : blob); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -function uploadBytes$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytes'); - const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(finalMetadata => { - return { - metadata: finalMetadata, - ref - }; - }); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -function uploadBytesResumable$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytesResumable'); - return new UploadTask(ref, new FbsBlob(data), metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -function uploadString$1(ref, value, format = StringFormat.RAW, metadata) { - ref._throwIfRoot('uploadString'); - const data = dataFromString(format, value); - const metadataClone = { ...metadata }; - if (metadataClone['contentType'] == null && data.contentType != null) { - metadataClone['contentType'] = data.contentType; - } - return uploadBytes$1(ref, data.data, metadataClone); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll$1(ref) { - const accumulator = { - prefixes: [], - items: [] - }; - return listAllHelper(ref, accumulator).then(() => accumulator); -} -/** - * Separated from listAll because async functions can't use "arguments". - * @param ref - * @param accumulator - * @param pageToken - */ -async function listAllHelper(ref, accumulator, pageToken) { - const opt = { - // maxResults is 1000 by default. - pageToken - }; - const nextPage = await list$1(ref, opt); - accumulator.prefixes.push(...nextPage.prefixes); - accumulator.items.push(...nextPage.items); - if (nextPage.nextPageToken != null) { - await listAllHelper(ref, accumulator, nextPage.nextPageToken); - } -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list$1(ref, options) { - if (options != null) { - if (typeof options.maxResults === 'number') { - validateNumber('options.maxResults', - /* minValue= */ 1, - /* maxValue= */ 1000, options.maxResults); - } - } - const op = options || {}; - const requestInfo = list$2(ref.storage, ref._location, - /*delimiter= */ '/', op.pageToken, op.maxResults); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -function getMetadata$1(ref) { - ref._throwIfRoot('getMetadata'); - const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -function updateMetadata$1(ref, metadata) { - ref._throwIfRoot('updateMetadata'); - const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL$1(ref) { - ref._throwIfRoot('getDownloadURL'); - const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings()); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(url => { - if (url === null) { - throw noDownloadURL(); - } - return url; - }); -} -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject$1(ref) { - ref._throwIfRoot('deleteObject'); - const requestInfo = deleteObject$2(ref.storage, ref._location); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -function _getChild$1(ref, childPath) { - const newPath = child(ref._location.path, childPath); - const location = new Location(ref._location.bucket, newPath); - return new Reference(ref.storage, location); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isUrl(path) { - return /^[A-Za-z]+:\/\//.test(path); -} -/** - * Returns a firebaseStorage.Reference for the given url. - */ -function refFromURL(service, url) { - return new Reference(service, url); -} -/** - * Returns a firebaseStorage.Reference for the given path in the default - * bucket. - */ -function refFromPath(ref, path) { - if (ref instanceof FirebaseStorageImpl) { - const service = ref; - if (service._bucket == null) { - throw noDefaultBucket(); - } - const reference = new Reference(service, service._bucket); - if (path != null) { - return refFromPath(reference, path); - } - else { - return reference; - } - } - else { - // ref is a Reference - if (path !== undefined) { - return _getChild$1(ref, path); - } - else { - return ref; - } - } -} -function ref$1(serviceOrRef, pathOrUrl) { - if (pathOrUrl && isUrl(pathOrUrl)) { - if (serviceOrRef instanceof FirebaseStorageImpl) { - return refFromURL(serviceOrRef, pathOrUrl); - } - else { - throw invalidArgument('To use ref(service, url), the first argument must be a Storage instance.'); - } - } - else { - return refFromPath(serviceOrRef, pathOrUrl); - } -} -function extractBucket(host, config) { - const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY]; - if (bucketString == null) { - return null; - } - return Location.makeFromBucketSpec(bucketString, host); -} -function connectStorageEmulator$1(storage, host, port, options = {}) { - storage.host = `${host}:${port}`; - const useSsl = util.isCloudWorkstation(host); - // Workaround to get cookies in Firebase Studio - if (useSsl) { - void util.pingServer(`https://${storage.host}/b`); - util.updateEmulatorBanner('Storage', true); - } - storage._isUsingEmulator = true; - storage._protocol = useSsl ? 'https' : 'http'; - const { mockUserToken } = options; - if (mockUserToken) { - storage._overrideAuthToken = - typeof mockUserToken === 'string' - ? mockUserToken - : util.createMockUserToken(mockUserToken, storage.app.options.projectId); - } -} -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -class FirebaseStorageImpl { - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app, _authProvider, - /** - * @internal - */ - _appCheckProvider, - /** - * @internal - */ - _url, _firebaseVersion, _isUsingEmulator = false) { - this.app = app; - this._authProvider = _authProvider; - this._appCheckProvider = _appCheckProvider; - this._url = _url; - this._firebaseVersion = _firebaseVersion; - this._isUsingEmulator = _isUsingEmulator; - this._bucket = null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - this._host = DEFAULT_HOST; - this._protocol = 'https'; - this._appId = null; - this._deleted = false; - this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME; - this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME; - this._requests = new Set(); - if (_url != null) { - this._bucket = Location.makeFromBucketSpec(_url, this._host); - } - else { - this._bucket = extractBucket(this._host, this.app.options); - } - } - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host() { - return this._host; - } - set host(host) { - this._host = host; - if (this._url != null) { - this._bucket = Location.makeFromBucketSpec(this._url, host); - } - else { - this._bucket = extractBucket(host, this.app.options); - } - } - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime() { - return this._maxUploadRetryTime; - } - set maxUploadRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxUploadRetryTime = time; - } - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime() { - return this._maxOperationRetryTime; - } - set maxOperationRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxOperationRetryTime = time; - } - async _getAuthToken() { - if (this._overrideAuthToken) { - return this._overrideAuthToken; - } - const auth = this._authProvider.getImmediate({ optional: true }); - if (auth) { - const tokenData = await auth.getToken(); - if (tokenData !== null) { - return tokenData.accessToken; - } - } - return null; - } - async _getAppCheckToken() { - if (app._isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) { - return this.app.settings.appCheckToken; - } - const appCheck = this._appCheckProvider.getImmediate({ optional: true }); - if (appCheck) { - const result = await appCheck.getToken(); - // TODO: What do we want to do if there is an error getting the token? - // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be - // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use - // the token (actual or dummy) to send requests. - return result.token; - } - return null; - } - /** - * Stop running requests and prevent more from being created. - */ - _delete() { - if (!this._deleted) { - this._deleted = true; - this._requests.forEach(request => request.cancel()); - this._requests.clear(); - } - return Promise.resolve(); - } - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc) { - return new Reference(this, loc); - } - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) { - if (!this._deleted) { - const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator); - this._requests.add(request); - // Request removes itself from set when complete. - request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request)); - return request; - } - else { - return new FailRequest(appDeleted()); - } - } - async makeRequestWithTokens(requestInfo, requestFactory) { - const [authToken, appCheckToken] = await Promise.all([ - this._getAuthToken(), - this._getAppCheckToken() - ]); - return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise(); - } -} - -const name = "@firebase/storage"; -const version = "0.14.0"; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -const STORAGE_TYPE = 'storage'; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -function getBytes(ref, maxDownloadSizeBytes) { - ref = util.getModularInstance(ref); - return getBytesInternal(ref, maxDownloadSizeBytes); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -function uploadBytes(ref, data, metadata) { - ref = util.getModularInstance(ref); - return uploadBytes$1(ref, data, metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -function uploadString(ref, value, format, metadata) { - ref = util.getModularInstance(ref); - return uploadString$1(ref, value, format, metadata); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -function uploadBytesResumable(ref, data, metadata) { - ref = util.getModularInstance(ref); - return uploadBytesResumable$1(ref, data, metadata); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -function getMetadata(ref) { - ref = util.getModularInstance(ref); - return getMetadata$1(ref); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -function updateMetadata(ref, metadata) { - ref = util.getModularInstance(ref); - return updateMetadata$1(ref, metadata); -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list(ref, options) { - ref = util.getModularInstance(ref); - return list$1(ref, options); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll(ref) { - ref = util.getModularInstance(ref); - return listAll$1(ref); -} -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL(ref) { - ref = util.getModularInstance(ref); - return getDownloadURL$1(ref); -} -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject(ref) { - ref = util.getModularInstance(ref); - return deleteObject$1(ref); -} -function ref(serviceOrRef, pathOrUrl) { - serviceOrRef = util.getModularInstance(serviceOrRef); - return ref$1(serviceOrRef, pathOrUrl); -} -/** - * @internal - */ -function _getChild(ref, childPath) { - return _getChild$1(ref, childPath); -} -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -function getStorage(app$1 = app.getApp(), bucketUrl) { - app$1 = util.getModularInstance(app$1); - const storageProvider = app._getProvider(app$1, STORAGE_TYPE); - const storageInstance = storageProvider.getImmediate({ - identifier: bucketUrl - }); - const emulator = util.getDefaultEmulatorHostnameAndPort('storage'); - if (emulator) { - connectStorageEmulator(storageInstance, ...emulator); - } - return storageInstance; -} -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -function connectStorageEmulator(storage, host, port, options = {}) { - connectStorageEmulator$1(storage, host, port, options); -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -function getBlob(ref, maxDownloadSizeBytes) { - ref = util.getModularInstance(ref); - return getBlobInternal(ref, maxDownloadSizeBytes); -} -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -function getStream(ref, maxDownloadSizeBytes) { - throw new Error('getStream() is only supported by NodeJS builds'); -} - -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -function factory(container, { instanceIdentifier: url }) { - const app$1 = container.getProvider('app').getImmediate(); - const authProvider = container.getProvider('auth-internal'); - const appCheckProvider = container.getProvider('app-check-internal'); - return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider, url, app.SDK_VERSION); -} -function registerStorage() { - app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); - //RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser - app.registerVersion(name, version, ''); - // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation - app.registerVersion(name, version, 'cjs2020'); -} -registerStorage(); - -exports.StorageError = StorageError; -exports.StringFormat = StringFormat; -exports._FbsBlob = FbsBlob; -exports._Location = Location; -exports._TaskEvent = TaskEvent; -exports._TaskState = TaskState; -exports._UploadTask = UploadTask; -exports._dataFromString = dataFromString; -exports._getChild = _getChild; -exports._invalidArgument = invalidArgument; -exports._invalidRootOperation = invalidRootOperation; -exports.connectStorageEmulator = connectStorageEmulator; -exports.deleteObject = deleteObject; -exports.getBlob = getBlob; -exports.getBytes = getBytes; -exports.getDownloadURL = getDownloadURL; -exports.getMetadata = getMetadata; -exports.getStorage = getStorage; -exports.getStream = getStream; -exports.list = list; -exports.listAll = listAll; -exports.ref = ref; -exports.updateMetadata = updateMetadata; -exports.uploadBytes = uploadBytes; -exports.uploadBytesResumable = uploadBytesResumable; -exports.uploadString = uploadString; -//# sourceMappingURL=index.browser.cjs.js.map diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.browser.cjs.js.map b/frontend-old/node_modules/@firebase/storage/dist/index.browser.cjs.js.map deleted file mode 100644 index fbbe7eb..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.browser.cjs.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.browser.cjs.js","sources":["../src/implementation/constants.ts","../src/implementation/error.ts","../src/implementation/location.ts","../src/implementation/failrequest.ts","../src/implementation/backoff.ts","../src/implementation/type.ts","../src/implementation/url.ts","../src/implementation/connection.ts","../src/implementation/utils.ts","../src/implementation/request.ts","../src/implementation/fs.ts","../src/platform/browser/base64.ts","../src/implementation/string.ts","../src/implementation/blob.ts","../src/implementation/json.ts","../src/implementation/path.ts","../src/implementation/metadata.ts","../src/implementation/list.ts","../src/implementation/requestinfo.ts","../src/implementation/requests.ts","../src/implementation/taskenums.ts","../src/implementation/observer.ts","../src/implementation/async.ts","../src/platform/browser/connection.ts","../src/task.ts","../src/reference.ts","../src/service.ts","../src/constants.ts","../src/api.ts","../src/api.browser.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Constants used in the Firebase Storage library.\n */\n\n/**\n * Domain name for firebase storage.\n */\nexport const DEFAULT_HOST = 'firebasestorage.googleapis.com';\n\n/**\n * The key in Firebase config json for the storage bucket.\n */\nexport const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket';\n\n/**\n * 2 minutes\n *\n * The timeout for all operations except upload.\n */\nexport const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000;\n\n/**\n * 10 minutes\n *\n * The timeout for upload.\n */\nexport const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000;\n\n/**\n * 1 second\n */\nexport const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;\n\n/**\n * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported\n * enough for us to use it directly.\n */\nexport const MIN_SAFE_INTEGER = -9007199254740991;\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseError } from '@firebase/util';\n\nimport { CONFIG_STORAGE_BUCKET_KEY } from './constants';\n\n/**\n * An error returned by the Firebase Storage SDK.\n * @public\n */\nexport class StorageError extends FirebaseError {\n private readonly _baseMessage: string;\n /**\n * Stores custom error data unique to the `StorageError`.\n */\n customData: { serverResponse: string | null } = { serverResponse: null };\n\n /**\n * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and\n * added to the end of the message.\n * @param message - Error message.\n * @param status_ - Corresponding HTTP Status Code\n */\n constructor(code: StorageErrorCode, message: string, private status_ = 0) {\n super(\n prependCode(code),\n `Firebase Storage: ${message} (${prependCode(code)})`\n );\n this._baseMessage = this.message;\n // Without this, `instanceof StorageError`, in tests for example,\n // returns false.\n Object.setPrototypeOf(this, StorageError.prototype);\n }\n\n get status(): number {\n return this.status_;\n }\n\n set status(status: number) {\n this.status_ = status;\n }\n\n /**\n * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.\n */\n _codeEquals(code: StorageErrorCode): boolean {\n return prependCode(code) === this.code;\n }\n\n /**\n * Optional response message that was added by the server.\n */\n get serverResponse(): null | string {\n return this.customData.serverResponse;\n }\n\n set serverResponse(serverResponse: string | null) {\n this.customData.serverResponse = serverResponse;\n if (this.customData.serverResponse) {\n this.message = `${this._baseMessage}\\n${this.customData.serverResponse}`;\n } else {\n this.message = this._baseMessage;\n }\n }\n}\n\nexport const errors = {};\n\n/**\n * @public\n * Error codes that can be attached to `StorageError` objects.\n */\nexport enum StorageErrorCode {\n // Shared between all platforms\n UNKNOWN = 'unknown',\n OBJECT_NOT_FOUND = 'object-not-found',\n BUCKET_NOT_FOUND = 'bucket-not-found',\n PROJECT_NOT_FOUND = 'project-not-found',\n QUOTA_EXCEEDED = 'quota-exceeded',\n UNAUTHENTICATED = 'unauthenticated',\n UNAUTHORIZED = 'unauthorized',\n UNAUTHORIZED_APP = 'unauthorized-app',\n RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',\n INVALID_CHECKSUM = 'invalid-checksum',\n CANCELED = 'canceled',\n // JS specific\n INVALID_EVENT_NAME = 'invalid-event-name',\n INVALID_URL = 'invalid-url',\n INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',\n NO_DEFAULT_BUCKET = 'no-default-bucket',\n CANNOT_SLICE_BLOB = 'cannot-slice-blob',\n SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',\n NO_DOWNLOAD_URL = 'no-download-url',\n INVALID_ARGUMENT = 'invalid-argument',\n INVALID_ARGUMENT_COUNT = 'invalid-argument-count',\n APP_DELETED = 'app-deleted',\n INVALID_ROOT_OPERATION = 'invalid-root-operation',\n INVALID_FORMAT = 'invalid-format',\n INTERNAL_ERROR = 'internal-error',\n UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'\n}\n\nexport function prependCode(code: StorageErrorCode): string {\n return 'storage/' + code;\n}\n\nexport function unknown(): StorageError {\n const message =\n 'An unknown error occurred, please check the error payload for ' +\n 'server response.';\n return new StorageError(StorageErrorCode.UNKNOWN, message);\n}\n\nexport function objectNotFound(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.OBJECT_NOT_FOUND,\n \"Object '\" + path + \"' does not exist.\"\n );\n}\n\nexport function bucketNotFound(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.BUCKET_NOT_FOUND,\n \"Bucket '\" + bucket + \"' does not exist.\"\n );\n}\n\nexport function projectNotFound(project: string): StorageError {\n return new StorageError(\n StorageErrorCode.PROJECT_NOT_FOUND,\n \"Project '\" + project + \"' does not exist.\"\n );\n}\n\nexport function quotaExceeded(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.QUOTA_EXCEEDED,\n \"Quota for bucket '\" +\n bucket +\n \"' exceeded, please view quota on \" +\n 'https://firebase.google.com/pricing/.'\n );\n}\n\nexport function unauthenticated(): StorageError {\n const message =\n 'User is not authenticated, please authenticate using Firebase ' +\n 'Authentication and try again.';\n return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);\n}\n\nexport function unauthorizedApp(): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED_APP,\n 'This app does not have permission to access Firebase Storage on this project.'\n );\n}\n\nexport function unauthorized(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED,\n \"User does not have permission to access '\" + path + \"'.\"\n );\n}\n\nexport function retryLimitExceeded(): StorageError {\n return new StorageError(\n StorageErrorCode.RETRY_LIMIT_EXCEEDED,\n 'Max retry time for operation exceeded, please try again.'\n );\n}\n\nexport function invalidChecksum(\n path: string,\n checksum: string,\n calculated: string\n): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_CHECKSUM,\n \"Uploaded/downloaded object '\" +\n path +\n \"' has checksum '\" +\n checksum +\n \"' which does not match '\" +\n calculated +\n \"'. Please retry the upload/download.\"\n );\n}\n\nexport function canceled(): StorageError {\n return new StorageError(\n StorageErrorCode.CANCELED,\n 'User canceled the upload/download.'\n );\n}\n\nexport function invalidEventName(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_EVENT_NAME,\n \"Invalid event name '\" + name + \"'.\"\n );\n}\n\nexport function invalidUrl(url: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_URL,\n \"Invalid URL '\" + url + \"'.\"\n );\n}\n\nexport function invalidDefaultBucket(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_DEFAULT_BUCKET,\n \"Invalid default bucket '\" + bucket + \"'.\"\n );\n}\n\nexport function noDefaultBucket(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DEFAULT_BUCKET,\n 'No default bucket ' +\n \"found. Did you set the '\" +\n CONFIG_STORAGE_BUCKET_KEY +\n \"' property when initializing the app?\"\n );\n}\n\nexport function cannotSliceBlob(): StorageError {\n return new StorageError(\n StorageErrorCode.CANNOT_SLICE_BLOB,\n 'Cannot slice blob for upload. Please retry the upload.'\n );\n}\n\nexport function serverFileWrongSize(): StorageError {\n return new StorageError(\n StorageErrorCode.SERVER_FILE_WRONG_SIZE,\n 'Server recorded incorrect upload file size, please retry the upload.'\n );\n}\n\nexport function noDownloadURL(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DOWNLOAD_URL,\n 'The given file does not have any download URLs.'\n );\n}\n\nexport function missingPolyFill(polyFill: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`\n );\n}\n\n/**\n * @internal\n */\nexport function invalidArgument(message: string): StorageError {\n return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);\n}\n\nexport function invalidArgumentCount(\n argMin: number,\n argMax: number,\n fnName: string,\n real: number\n): StorageError {\n let countPart;\n let plural;\n if (argMin === argMax) {\n countPart = argMin;\n plural = argMin === 1 ? 'argument' : 'arguments';\n } else {\n countPart = 'between ' + argMin + ' and ' + argMax;\n plural = 'arguments';\n }\n return new StorageError(\n StorageErrorCode.INVALID_ARGUMENT_COUNT,\n 'Invalid argument count in `' +\n fnName +\n '`: Expected ' +\n countPart +\n ' ' +\n plural +\n ', received ' +\n real +\n '.'\n );\n}\n\nexport function appDeleted(): StorageError {\n return new StorageError(\n StorageErrorCode.APP_DELETED,\n 'The Firebase app was deleted.'\n );\n}\n\n/**\n * @param name - The name of the operation that was invalid.\n *\n * @internal\n */\nexport function invalidRootOperation(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_ROOT_OPERATION,\n \"The operation '\" +\n name +\n \"' cannot be performed on a root reference, create a non-root \" +\n \"reference using child, such as .child('file.png').\"\n );\n}\n\n/**\n * @param format - The format that was not valid.\n * @param message - A message describing the format violation.\n */\nexport function invalidFormat(format: string, message: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_FORMAT,\n \"String does not match format '\" + format + \"': \" + message\n );\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function unsupportedEnvironment(message: string): StorageError {\n throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, message);\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function internalError(message: string): StorageError {\n throw new StorageError(\n StorageErrorCode.INTERNAL_ERROR,\n 'Internal error: ' + message\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functionality related to the parsing/composition of bucket/\n * object location.\n */\n\nimport { invalidDefaultBucket, invalidUrl } from './error';\nimport { DEFAULT_HOST } from './constants';\n\n/**\n * Firebase Storage location data.\n *\n * @internal\n */\nexport class Location {\n private path_: string;\n\n constructor(public readonly bucket: string, path: string) {\n this.path_ = path;\n }\n\n get path(): string {\n return this.path_;\n }\n\n get isRoot(): boolean {\n return this.path.length === 0;\n }\n\n fullServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o/' + encode(this.path);\n }\n\n bucketOnlyServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o';\n }\n\n static makeFromBucketSpec(bucketString: string, host: string): Location {\n let bucketLocation;\n try {\n bucketLocation = Location.makeFromUrl(bucketString, host);\n } catch (e) {\n // Not valid URL, use as-is. This lets you put bare bucket names in\n // config.\n return new Location(bucketString, '');\n }\n if (bucketLocation.path === '') {\n return bucketLocation;\n } else {\n throw invalidDefaultBucket(bucketString);\n }\n }\n\n static makeFromUrl(url: string, host: string): Location {\n let location: Location | null = null;\n const bucketDomain = '([A-Za-z0-9.\\\\-_]+)';\n\n function gsModify(loc: Location): void {\n if (loc.path.charAt(loc.path.length - 1) === '/') {\n loc.path_ = loc.path_.slice(0, -1);\n }\n }\n const gsPath = '(/(.*))?$';\n const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i');\n const gsIndices = { bucket: 1, path: 3 };\n\n function httpModify(loc: Location): void {\n loc.path_ = decodeURIComponent(loc.path);\n }\n const version = 'v[A-Za-z0-9_]+';\n const firebaseStorageHost = host.replace(/[.]/g, '\\\\.');\n const firebaseStoragePath = '(/([^?#]*).*)?$';\n const firebaseStorageRegExp = new RegExp(\n `^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`,\n 'i'\n );\n const firebaseStorageIndices = { bucket: 1, path: 3 };\n\n const cloudStorageHost =\n host === DEFAULT_HOST\n ? '(?:storage.googleapis.com|storage.cloud.google.com)'\n : host;\n const cloudStoragePath = '([^?#]*)';\n const cloudStorageRegExp = new RegExp(\n `^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`,\n 'i'\n );\n const cloudStorageIndices = { bucket: 1, path: 2 };\n\n const groups = [\n { regex: gsRegex, indices: gsIndices, postModify: gsModify },\n {\n regex: firebaseStorageRegExp,\n indices: firebaseStorageIndices,\n postModify: httpModify\n },\n {\n regex: cloudStorageRegExp,\n indices: cloudStorageIndices,\n postModify: httpModify\n }\n ];\n for (let i = 0; i < groups.length; i++) {\n const group = groups[i];\n const captures = group.regex.exec(url);\n if (captures) {\n const bucketValue = captures[group.indices.bucket];\n let pathValue = captures[group.indices.path];\n if (!pathValue) {\n pathValue = '';\n }\n location = new Location(bucketValue, pathValue);\n group.postModify(location);\n break;\n }\n }\n if (location == null) {\n throw invalidUrl(url);\n }\n return location;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Request } from './request';\n\n/**\n * A request whose promise always fails.\n */\nexport class FailRequest<T> implements Request<T> {\n promise_: Promise<T>;\n\n constructor(error: StorageError) {\n this.promise_ = Promise.reject<T>(error);\n }\n\n /** @inheritDoc */\n getPromise(): Promise<T> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(_appDelete = false): void {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Provides a method for running a function with exponential\n * backoff.\n */\ntype id = (p1: boolean) => void;\n\nexport { id };\n\n/**\n * Accepts a callback for an action to perform (`doRequest`),\n * and then a callback for when the backoff has completed (`backoffCompleteCb`).\n * The callback sent to start requires an argument to call (`onRequestComplete`).\n * When `start` calls `doRequest`, it passes a callback for when the request has\n * completed, `onRequestComplete`. Based on this, the backoff continues, with\n * another call to `doRequest` and the above loop continues until the timeout\n * is hit, or a successful response occurs.\n * @description\n * @param doRequest Callback to perform request\n * @param backoffCompleteCb Callback to call when backoff has been completed\n */\nexport function start(\n doRequest: (\n onRequestComplete: (success: boolean) => void,\n canceled: boolean\n ) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n backoffCompleteCb: (...args: any[]) => unknown,\n timeout: number\n): id {\n // TODO(andysoto): make this code cleaner (probably refactor into an actual\n // type instead of a bunch of functions with state shared in the closure)\n let waitSeconds = 1;\n // Would type this as \"number\" but that doesn't work for Node so ¯\\_(ツ)_/¯\n // TODO: find a way to exclude Node type definition for storage because storage only works in browser\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let retryTimeoutId: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let globalTimeoutId: any = null;\n let hitTimeout = false;\n let cancelState = 0;\n\n function canceled(): boolean {\n return cancelState === 2;\n }\n let triggeredCallback = false;\n\n function triggerCallback(...args: any[]): void {\n if (!triggeredCallback) {\n triggeredCallback = true;\n backoffCompleteCb.apply(null, args);\n }\n }\n\n function callWithDelay(millis: number): void {\n retryTimeoutId = setTimeout(() => {\n retryTimeoutId = null;\n doRequest(responseHandler, canceled());\n }, millis);\n }\n\n function clearGlobalTimeout(): void {\n if (globalTimeoutId) {\n clearTimeout(globalTimeoutId);\n }\n }\n\n function responseHandler(success: boolean, ...args: any[]): void {\n if (triggeredCallback) {\n clearGlobalTimeout();\n return;\n }\n if (success) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n const mustStop = canceled() || hitTimeout;\n if (mustStop) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n if (waitSeconds < 64) {\n /* TODO(andysoto): don't back off so quickly if we know we're offline. */\n waitSeconds *= 2;\n }\n let waitMillis;\n if (cancelState === 1) {\n cancelState = 2;\n waitMillis = 0;\n } else {\n waitMillis = (waitSeconds + Math.random()) * 1000;\n }\n callWithDelay(waitMillis);\n }\n let stopped = false;\n\n function stop(wasTimeout: boolean): void {\n if (stopped) {\n return;\n }\n stopped = true;\n clearGlobalTimeout();\n if (triggeredCallback) {\n return;\n }\n if (retryTimeoutId !== null) {\n if (!wasTimeout) {\n cancelState = 2;\n }\n clearTimeout(retryTimeoutId);\n callWithDelay(0);\n } else {\n if (!wasTimeout) {\n cancelState = 1;\n }\n }\n }\n callWithDelay(0);\n globalTimeoutId = setTimeout(() => {\n hitTimeout = true;\n stop(true);\n }, timeout);\n return stop;\n}\n\n/**\n * Stops the retry loop from repeating.\n * If the function is currently \"in between\" retries, it is invoked immediately\n * with the second parameter as \"true\". Otherwise, it will be invoked once more\n * after the current invocation finishes iff the current invocation would have\n * triggered another retry.\n */\nexport function stop(id: id): void {\n id(false);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { invalidArgument } from './error';\n\nexport function isJustDef<T>(p: T | null | undefined): p is T | null {\n return p !== void 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isFunction(p: unknown): p is Function {\n return typeof p === 'function';\n}\n\nexport function isNonArrayObject(p: unknown): boolean {\n return typeof p === 'object' && !Array.isArray(p);\n}\n\nexport function isString(p: unknown): p is string {\n return typeof p === 'string' || p instanceof String;\n}\n\nexport function isNativeBlob(p: unknown): p is Blob {\n return isNativeBlobDefined() && p instanceof Blob;\n}\n\nexport function isNativeBlobDefined(): boolean {\n return typeof Blob !== 'undefined';\n}\n\nexport function validateNumber(\n argument: string,\n minValue: number,\n maxValue: number,\n value: number\n): void {\n if (value < minValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${minValue} or greater.`\n );\n }\n if (value > maxValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${maxValue} or less.`\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functions to create and manipulate URLs for the server API.\n */\nimport { UrlParams } from './requestinfo';\n\nexport function makeUrl(\n urlPart: string,\n host: string,\n protocol: string\n): string {\n let origin = host;\n if (protocol == null) {\n origin = `https://${host}`;\n }\n return `${protocol}://${origin}/v0${urlPart}`;\n}\n\nexport function makeQueryString(params: UrlParams): string {\n const encode = encodeURIComponent;\n let queryPart = '?';\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const nextPart = encode(key) + '=' + encode(params[key]);\n queryPart = queryPart + nextPart + '&';\n }\n }\n\n // Chop off the extra '&' or '?' on the end\n queryPart = queryPart.slice(0, -1);\n return queryPart;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Network headers */\nexport type Headers = Record<string, string>;\n\n/** Response type exposed by the networking APIs. */\nexport type ConnectionType =\n | string\n | ArrayBuffer\n | Blob\n | ReadableStream<Uint8Array>;\n\n/**\n * A lightweight wrapper around XMLHttpRequest with a\n * goog.net.XhrIo-like interface.\n *\n * You can create a new connection by invoking `newTextConnection()`,\n * `newBytesConnection()` or `newStreamConnection()`.\n */\nexport interface Connection<T extends ConnectionType> {\n /**\n * Sends a request to the provided URL.\n *\n * This method never rejects its promise. In case of encountering an error,\n * it sets an error code internally which can be accessed by calling\n * getErrorCode() by callers.\n */\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string | null,\n headers?: Headers\n ): Promise<void>;\n\n getErrorCode(): ErrorCode;\n\n getStatus(): number;\n\n getResponse(): T;\n\n getErrorText(): string;\n\n /**\n * Abort the request.\n */\n abort(): void;\n\n getResponseHeader(header: string): string | null;\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n}\n\n/**\n * Error codes for requests made by the XhrIo wrapper.\n */\nexport enum ErrorCode {\n NO_ERROR = 0,\n NETWORK_ERROR = 1,\n ABORT = 2\n}\n","/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Checks the status code to see if the action should be retried.\n *\n * @param status Current HTTP status code returned by server.\n * @param additionalRetryCodes additional retry codes to check against\n */\nexport function isRetryStatusCode(\n status: number,\n additionalRetryCodes: number[]\n): boolean {\n // The codes for which to retry came from this page:\n // https://cloud.google.com/storage/docs/exponential-backoff\n const isFiveHundredCode = status >= 500 && status < 600;\n const extraRetryCodes = [\n // Request Timeout: web server didn't receive full request in time.\n 408,\n // Too Many Requests: you're getting rate-limited, basically.\n 429\n ];\n const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;\n const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;\n return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods used to actually send HTTP requests from\n * abstract representations.\n */\n\nimport { id as backoffId, start, stop } from './backoff';\nimport { appDeleted, canceled, retryLimitExceeded, unknown } from './error';\nimport { ErrorHandler, RequestHandler, RequestInfo } from './requestinfo';\nimport { isJustDef } from './type';\nimport { makeQueryString } from './url';\nimport { Connection, ErrorCode, Headers, ConnectionType } from './connection';\nimport { isRetryStatusCode } from './utils';\n\nexport interface Request<T> {\n getPromise(): Promise<T>;\n\n /**\n * Cancels the request. IMPORTANT: the promise may still be resolved with an\n * appropriate value (if the request is finished before you call this method,\n * but the promise has not yet been resolved), so don't just assume it will be\n * rejected if you call this function.\n * @param appDelete - True if the cancelation came from the app being deleted.\n */\n cancel(appDelete?: boolean): void;\n}\n\n/**\n * Handles network logic for all Storage Requests, including error reporting and\n * retries with backoff.\n *\n * @param I - the type of the backend's network response.\n * @param - O the output type used by the rest of the SDK. The conversion\n * happens in the specified `callback_`.\n */\nclass NetworkRequest<I extends ConnectionType, O> implements Request<O> {\n private pendingConnection_: Connection<I> | null = null;\n private backoffId_: backoffId | null = null;\n private resolve_!: (value?: O | PromiseLike<O>) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private reject_!: (reason?: any) => void;\n private canceled_: boolean = false;\n private appDelete_: boolean = false;\n private promise_: Promise<O>;\n\n constructor(\n private url_: string,\n private method_: string,\n private headers_: Headers,\n private body_: string | Blob | Uint8Array | null,\n private successCodes_: number[],\n private additionalRetryCodes_: number[],\n private callback_: RequestHandler<I, O>,\n private errorCallback_: ErrorHandler | null,\n private timeout_: number,\n private progressCallback_: ((p1: number, p2: number) => void) | null,\n private connectionFactory_: () => Connection<I>,\n private retry = true,\n private isUsingEmulator = false\n ) {\n this.promise_ = new Promise((resolve, reject) => {\n this.resolve_ = resolve as (value?: O | PromiseLike<O>) => void;\n this.reject_ = reject;\n this.start_();\n });\n }\n\n /**\n * Actually starts the retry loop.\n */\n private start_(): void {\n const doTheRequest: (\n backoffCallback: (success: boolean, ...p2: unknown[]) => void,\n canceled: boolean\n ) => void = (backoffCallback, canceled) => {\n if (canceled) {\n backoffCallback(false, new RequestEndStatus(false, null, true));\n return;\n }\n const connection = this.connectionFactory_();\n this.pendingConnection_ = connection;\n\n const progressListener: (\n progressEvent: ProgressEvent\n ) => void = progressEvent => {\n const loaded = progressEvent.loaded;\n const total = progressEvent.lengthComputable ? progressEvent.total : -1;\n if (this.progressCallback_ !== null) {\n this.progressCallback_(loaded, total);\n }\n };\n if (this.progressCallback_ !== null) {\n connection.addUploadProgressListener(progressListener);\n }\n\n // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n connection\n .send(\n this.url_,\n this.method_,\n this.isUsingEmulator,\n this.body_,\n this.headers_\n )\n .then(() => {\n if (this.progressCallback_ !== null) {\n connection.removeUploadProgressListener(progressListener);\n }\n this.pendingConnection_ = null;\n const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;\n const status = connection.getStatus();\n if (\n !hitServer ||\n (isRetryStatusCode(status, this.additionalRetryCodes_) &&\n this.retry)\n ) {\n const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;\n backoffCallback(\n false,\n new RequestEndStatus(false, null, wasCanceled)\n );\n return;\n }\n const successCode = this.successCodes_.indexOf(status) !== -1;\n backoffCallback(true, new RequestEndStatus(successCode, connection));\n });\n };\n\n /**\n * @param requestWentThrough - True if the request eventually went\n * through, false if it hit the retry limit or was canceled.\n */\n const backoffDone: (\n requestWentThrough: boolean,\n status: RequestEndStatus<I>\n ) => void = (requestWentThrough, status) => {\n const resolve = this.resolve_;\n const reject = this.reject_;\n const connection = status.connection as Connection<I>;\n if (status.wasSuccessCode) {\n try {\n const result = this.callback_(connection, connection.getResponse());\n if (isJustDef(result)) {\n resolve(result);\n } else {\n resolve();\n }\n } catch (e) {\n reject(e);\n }\n } else {\n if (connection !== null) {\n const err = unknown();\n err.serverResponse = connection.getErrorText();\n if (this.errorCallback_) {\n reject(this.errorCallback_(connection, err));\n } else {\n reject(err);\n }\n } else {\n if (status.canceled) {\n const err = this.appDelete_ ? appDeleted() : canceled();\n reject(err);\n } else {\n const err = retryLimitExceeded();\n reject(err);\n }\n }\n }\n };\n if (this.canceled_) {\n backoffDone(false, new RequestEndStatus(false, null, true));\n } else {\n this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);\n }\n }\n\n /** @inheritDoc */\n getPromise(): Promise<O> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(appDelete?: boolean): void {\n this.canceled_ = true;\n this.appDelete_ = appDelete || false;\n if (this.backoffId_ !== null) {\n stop(this.backoffId_);\n }\n if (this.pendingConnection_ !== null) {\n this.pendingConnection_.abort();\n }\n }\n}\n\n/**\n * A collection of information about the result of a network request.\n * @param opt_canceled - Defaults to false.\n */\nexport class RequestEndStatus<I extends ConnectionType> {\n /**\n * True if the request was canceled.\n */\n canceled: boolean;\n\n constructor(\n public wasSuccessCode: boolean,\n public connection: Connection<I> | null,\n canceled?: boolean\n ) {\n this.canceled = !!canceled;\n }\n}\n\nexport function addAuthHeader_(\n headers: Headers,\n authToken: string | null\n): void {\n if (authToken !== null && authToken.length > 0) {\n headers['Authorization'] = 'Firebase ' + authToken;\n }\n}\n\nexport function addVersionHeader_(\n headers: Headers,\n firebaseVersion?: string\n): void {\n headers['X-Firebase-Storage-Version'] =\n 'webjs/' + (firebaseVersion ?? 'AppManager');\n}\n\nexport function addGmpidHeader_(headers: Headers, appId: string | null): void {\n if (appId) {\n headers['X-Firebase-GMPID'] = appId;\n }\n}\n\nexport function addAppCheckHeader_(\n headers: Headers,\n appCheckToken: string | null\n): void {\n if (appCheckToken !== null) {\n headers['X-Firebase-AppCheck'] = appCheckToken;\n }\n}\n\nexport function makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n appId: string | null,\n authToken: string | null,\n appCheckToken: string | null,\n requestFactory: () => Connection<I>,\n firebaseVersion?: string,\n retry = true,\n isUsingEmulator = false\n): Request<O> {\n const queryPart = makeQueryString(requestInfo.urlParams);\n const url = requestInfo.url + queryPart;\n const headers = Object.assign({}, requestInfo.headers);\n addGmpidHeader_(headers, appId);\n addAuthHeader_(headers, authToken);\n addVersionHeader_(headers, firebaseVersion);\n addAppCheckHeader_(headers, appCheckToken);\n return new NetworkRequest<I, O>(\n url,\n requestInfo.method,\n headers,\n requestInfo.body,\n requestInfo.successCodes,\n requestInfo.additionalRetryCodes,\n requestInfo.handler,\n requestInfo.errorHandler,\n requestInfo.timeout,\n requestInfo.progressCallback,\n requestFactory,\n retry,\n isUsingEmulator\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Some methods copied from goog.fs.\n * We don't include goog.fs because it pulls in a bunch of Deferred code that\n * bloats the size of the released binary.\n */\nimport { isNativeBlobDefined } from './type';\nimport { StorageErrorCode, StorageError } from './error';\n\nfunction getBlobBuilder(): typeof IBlobBuilder | undefined {\n if (typeof BlobBuilder !== 'undefined') {\n return BlobBuilder;\n } else if (typeof WebKitBlobBuilder !== 'undefined') {\n return WebKitBlobBuilder;\n } else {\n return undefined;\n }\n}\n\n/**\n * Concatenates one or more values together and converts them to a Blob.\n *\n * @param args The values that will make up the resulting blob.\n * @return The blob.\n */\nexport function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob {\n const BlobBuilder = getBlobBuilder();\n if (BlobBuilder !== undefined) {\n const bb = new BlobBuilder();\n for (let i = 0; i < args.length; i++) {\n bb.append(args[i]);\n }\n return bb.getBlob();\n } else {\n if (isNativeBlobDefined()) {\n return new Blob(args);\n } else {\n throw new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n \"This browser doesn't seem to support creating Blobs\"\n );\n }\n }\n}\n\n/**\n * Slices the blob. The returned blob contains data from the start byte\n * (inclusive) till the end byte (exclusive). Negative indices cannot be used.\n *\n * @param blob The blob to be sliced.\n * @param start Index of the starting byte.\n * @param end Index of the ending byte.\n * @return The blob slice or null if not supported.\n */\nexport function sliceBlob(blob: Blob, start: number, end: number): Blob | null {\n if (blob.webkitSlice) {\n return blob.webkitSlice(start, end);\n } else if (blob.mozSlice) {\n return blob.mozSlice(start, end);\n } else if (blob.slice) {\n return blob.slice(start, end);\n }\n return null;\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { missingPolyFill } from '../../implementation/error';\n\n/** Converts a Base64 encoded string to a binary string. */\nexport function decodeBase64(encoded: string): string {\n if (typeof atob === 'undefined') {\n throw missingPolyFill('base-64');\n }\n return atob(encoded);\n}\n\nexport function decodeUint8Array(data: Uint8Array): string {\n return new TextDecoder().decode(data);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unknown, invalidFormat } from './error';\nimport { decodeBase64 } from '../platform/base64';\n\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport const StringFormat = {\n /**\n * Indicates the string should be interpreted \"raw\", that is, as normal text.\n * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte\n * sequence.\n * Example: The string 'Hello! \\\\ud83d\\\\ude0a' becomes the byte sequence\n * 48 65 6c 6c 6f 21 20 f0 9f 98 8a\n */\n RAW: 'raw',\n /**\n * Indicates the string should be interpreted as base64-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64: 'base64',\n /**\n * Indicates the string should be interpreted as base64url-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64URL: 'base64url',\n /**\n * Indicates the string is a data URL, such as one obtained from\n * canvas.toDataURL().\n * Example: the string 'data:application/octet-stream;base64,aaaa'\n * becomes the byte sequence\n * 69 a6 9a\n * (the content-type \"application/octet-stream\" is also applied, but can\n * be overridden in the metadata object).\n */\n DATA_URL: 'data_url'\n} as const;\n\nexport class StringData {\n contentType: string | null;\n\n constructor(public data: Uint8Array, contentType?: string | null) {\n this.contentType = contentType || null;\n }\n}\n\n/**\n * @internal\n */\nexport function dataFromString(\n format: StringFormat,\n stringData: string\n): StringData {\n switch (format) {\n case StringFormat.RAW:\n return new StringData(utf8Bytes_(stringData));\n case StringFormat.BASE64:\n case StringFormat.BASE64URL:\n return new StringData(base64Bytes_(format, stringData));\n case StringFormat.DATA_URL:\n return new StringData(\n dataURLBytes_(stringData),\n dataURLContentType_(stringData)\n );\n default:\n // do nothing\n }\n\n // assert(false);\n throw unknown();\n}\n\nexport function utf8Bytes_(value: string): Uint8Array {\n const b: number[] = [];\n for (let i = 0; i < value.length; i++) {\n let c = value.charCodeAt(i);\n if (c <= 127) {\n b.push(c);\n } else {\n if (c <= 2047) {\n b.push(192 | (c >> 6), 128 | (c & 63));\n } else {\n if ((c & 64512) === 55296) {\n // The start of a surrogate pair.\n const valid =\n i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;\n if (!valid) {\n // The second surrogate wasn't there.\n b.push(239, 191, 189);\n } else {\n const hi = c;\n const lo = value.charCodeAt(++i);\n c = 65536 | ((hi & 1023) << 10) | (lo & 1023);\n b.push(\n 240 | (c >> 18),\n 128 | ((c >> 12) & 63),\n 128 | ((c >> 6) & 63),\n 128 | (c & 63)\n );\n }\n } else {\n if ((c & 64512) === 56320) {\n // Invalid low surrogate.\n b.push(239, 191, 189);\n } else {\n b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63));\n }\n }\n }\n }\n }\n return new Uint8Array(b);\n}\n\nexport function percentEncodedBytes_(value: string): Uint8Array {\n let decoded;\n try {\n decoded = decodeURIComponent(value);\n } catch (e) {\n throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.');\n }\n return utf8Bytes_(decoded);\n}\n\nexport function base64Bytes_(format: StringFormat, value: string): Uint8Array {\n switch (format) {\n case StringFormat.BASE64: {\n const hasMinus = value.indexOf('-') !== -1;\n const hasUnder = value.indexOf('_') !== -1;\n if (hasMinus || hasUnder) {\n const invalidChar = hasMinus ? '-' : '_';\n throw invalidFormat(\n format,\n \"Invalid character '\" +\n invalidChar +\n \"' found: is it base64url encoded?\"\n );\n }\n break;\n }\n case StringFormat.BASE64URL: {\n const hasPlus = value.indexOf('+') !== -1;\n const hasSlash = value.indexOf('/') !== -1;\n if (hasPlus || hasSlash) {\n const invalidChar = hasPlus ? '+' : '/';\n throw invalidFormat(\n format,\n \"Invalid character '\" + invalidChar + \"' found: is it base64 encoded?\"\n );\n }\n value = value.replace(/-/g, '+').replace(/_/g, '/');\n break;\n }\n default:\n // do nothing\n }\n let bytes;\n try {\n bytes = decodeBase64(value);\n } catch (e) {\n if ((e as Error).message.includes('polyfill')) {\n throw e;\n }\n throw invalidFormat(format, 'Invalid character found');\n }\n const array = new Uint8Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n array[i] = bytes.charCodeAt(i);\n }\n return array;\n}\n\nclass DataURLParts {\n base64: boolean = false;\n contentType: string | null = null;\n rest: string;\n\n constructor(dataURL: string) {\n const matches = dataURL.match(/^data:([^,]+)?,/);\n if (matches === null) {\n throw invalidFormat(\n StringFormat.DATA_URL,\n \"Must be formatted 'data:[<mediatype>][;base64],<data>\"\n );\n }\n const middle = matches[1] || null;\n if (middle != null) {\n this.base64 = endsWith(middle, ';base64');\n this.contentType = this.base64\n ? middle.substring(0, middle.length - ';base64'.length)\n : middle;\n }\n this.rest = dataURL.substring(dataURL.indexOf(',') + 1);\n }\n}\n\nexport function dataURLBytes_(dataUrl: string): Uint8Array {\n const parts = new DataURLParts(dataUrl);\n if (parts.base64) {\n return base64Bytes_(StringFormat.BASE64, parts.rest);\n } else {\n return percentEncodedBytes_(parts.rest);\n }\n}\n\nexport function dataURLContentType_(dataUrl: string): string | null {\n const parts = new DataURLParts(dataUrl);\n return parts.contentType;\n}\n\nfunction endsWith(s: string, end: string): boolean {\n const longEnough = s.length >= end.length;\n if (!longEnough) {\n return false;\n }\n\n return s.substring(s.length - end.length) === end;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Provides a Blob-like wrapper for various binary types (including the\n * native Blob type). This makes it possible to upload types like ArrayBuffers,\n * making uploads possible in environments without the native Blob type.\n */\nimport { sliceBlob, getBlob } from './fs';\nimport { StringFormat, dataFromString } from './string';\nimport { isNativeBlob, isNativeBlobDefined, isString } from './type';\n\n/**\n * @param opt_elideCopy - If true, doesn't copy mutable input data\n * (e.g. Uint8Arrays). Pass true only if you know the objects will not be\n * modified after this blob's construction.\n *\n * @internal\n */\nexport class FbsBlob {\n private data_!: Blob | Uint8Array;\n private size_: number;\n private type_: string;\n\n constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean) {\n let size: number = 0;\n let blobType: string = '';\n if (isNativeBlob(data)) {\n this.data_ = data as Blob;\n size = (data as Blob).size;\n blobType = (data as Blob).type;\n } else if (data instanceof ArrayBuffer) {\n if (elideCopy) {\n this.data_ = new Uint8Array(data);\n } else {\n this.data_ = new Uint8Array(data.byteLength);\n this.data_.set(new Uint8Array(data));\n }\n size = this.data_.length;\n } else if (data instanceof Uint8Array) {\n if (elideCopy) {\n this.data_ = data as Uint8Array;\n } else {\n this.data_ = new Uint8Array(data.length);\n this.data_.set(data as Uint8Array);\n }\n size = data.length;\n }\n this.size_ = size;\n this.type_ = blobType;\n }\n\n size(): number {\n return this.size_;\n }\n\n type(): string {\n return this.type_;\n }\n\n slice(startByte: number, endByte: number): FbsBlob | null {\n if (isNativeBlob(this.data_)) {\n const realBlob = this.data_ as Blob;\n const sliced = sliceBlob(realBlob, startByte, endByte);\n if (sliced === null) {\n return null;\n }\n return new FbsBlob(sliced);\n } else {\n const slice = new Uint8Array(\n (this.data_ as Uint8Array).buffer,\n startByte,\n endByte - startByte\n );\n return new FbsBlob(slice, true);\n }\n }\n\n static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null {\n if (isNativeBlobDefined()) {\n const blobby: Array<Blob | Uint8Array | string> = args.map(\n (val: string | FbsBlob): Blob | Uint8Array | string => {\n if (val instanceof FbsBlob) {\n return val.data_;\n } else {\n return val;\n }\n }\n );\n return new FbsBlob(getBlob.apply(null, blobby));\n } else {\n const uint8Arrays: Uint8Array[] = args.map(\n (val: string | FbsBlob): Uint8Array => {\n if (isString(val)) {\n return dataFromString(StringFormat.RAW, val as string).data;\n } else {\n // Blobs don't exist, so this has to be a Uint8Array.\n return (val as FbsBlob).data_ as Uint8Array;\n }\n }\n );\n let finalLength = 0;\n uint8Arrays.forEach((array: Uint8Array): void => {\n finalLength += array.byteLength;\n });\n const merged = new Uint8Array(finalLength);\n let index = 0;\n uint8Arrays.forEach((array: Uint8Array) => {\n for (let i = 0; i < array.length; i++) {\n merged[index++] = array[i];\n }\n });\n return new FbsBlob(merged, true);\n }\n }\n\n uploadData(): Blob | Uint8Array {\n return this.data_;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isNonArrayObject } from './type';\n\n/**\n * Returns the Object resulting from parsing the given JSON, or null if the\n * given string does not represent a JSON object.\n */\nexport function jsonObjectOrNull(\n s: string\n): { [name: string]: unknown } | null {\n let obj;\n try {\n obj = JSON.parse(s);\n } catch (e) {\n return null;\n }\n if (isNonArrayObject(obj)) {\n return obj;\n } else {\n return null;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Contains helper methods for manipulating paths.\n */\n\n/**\n * @return Null if the path is already at the root.\n */\nexport function parent(path: string): string | null {\n if (path.length === 0) {\n return null;\n }\n const index = path.lastIndexOf('/');\n if (index === -1) {\n return '';\n }\n const newPath = path.slice(0, index);\n return newPath;\n}\n\nexport function child(path: string, childPath: string): string {\n const canonicalChildPath = childPath\n .split('/')\n .filter(component => component.length > 0)\n .join('/');\n if (path.length === 0) {\n return canonicalChildPath;\n } else {\n return path + '/' + canonicalChildPath;\n }\n}\n\n/**\n * Returns the last component of a path.\n * '/foo/bar' -> 'bar'\n * '/foo/bar/baz/' -> 'baz/'\n * '/a' -> 'a'\n */\nexport function lastComponent(path: string): string {\n const index = path.lastIndexOf('/', path.length - 2);\n if (index === -1) {\n return path;\n } else {\n return path.slice(index + 1);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the metadata format\n */\nimport { Metadata } from '../metadata';\n\nimport { jsonObjectOrNull } from './json';\nimport { Location } from './location';\nimport { lastComponent } from './path';\nimport { isString } from './type';\nimport { makeUrl, makeQueryString } from './url';\nimport { Reference } from '../reference';\nimport { FirebaseStorageImpl } from '../service';\n\nexport function noXform_<T>(metadata: Metadata, value: T): T {\n return value;\n}\n\nclass Mapping<T> {\n local: string;\n writable: boolean;\n xform: (p1: Metadata, p2?: T) => T | undefined;\n\n constructor(\n public server: string,\n local?: string | null,\n writable?: boolean,\n xform?: ((p1: Metadata, p2?: T) => T | undefined) | null\n ) {\n this.local = local || server;\n this.writable = !!writable;\n this.xform = xform || noXform_;\n }\n}\ntype Mappings = Array<Mapping<string> | Mapping<number>>;\n\nexport { Mappings };\n\nlet mappings_: Mappings | null = null;\n\nexport function xformPath(fullPath: string | undefined): string | undefined {\n if (!isString(fullPath) || fullPath.length < 2) {\n return fullPath;\n } else {\n return lastComponent(fullPath);\n }\n}\n\nexport function getMappings(): Mappings {\n if (mappings_) {\n return mappings_;\n }\n const mappings: Mappings = [];\n mappings.push(new Mapping<string>('bucket'));\n mappings.push(new Mapping<string>('generation'));\n mappings.push(new Mapping<string>('metageneration'));\n mappings.push(new Mapping<string>('name', 'fullPath', true));\n\n function mappingsXformPath(\n _metadata: Metadata,\n fullPath: string | undefined\n ): string | undefined {\n return xformPath(fullPath);\n }\n const nameMapping = new Mapping<string>('name');\n nameMapping.xform = mappingsXformPath;\n mappings.push(nameMapping);\n\n /**\n * Coerces the second param to a number, if it is defined.\n */\n function xformSize(\n _metadata: Metadata,\n size?: number | string\n ): number | undefined {\n if (size !== undefined) {\n return Number(size);\n } else {\n return size;\n }\n }\n const sizeMapping = new Mapping<number>('size');\n sizeMapping.xform = xformSize;\n mappings.push(sizeMapping);\n mappings.push(new Mapping<number>('timeCreated'));\n mappings.push(new Mapping<string>('updated'));\n mappings.push(new Mapping<string>('md5Hash', null, true));\n mappings.push(new Mapping<string>('cacheControl', null, true));\n mappings.push(new Mapping<string>('contentDisposition', null, true));\n mappings.push(new Mapping<string>('contentEncoding', null, true));\n mappings.push(new Mapping<string>('contentLanguage', null, true));\n mappings.push(new Mapping<string>('contentType', null, true));\n mappings.push(new Mapping<string>('metadata', 'customMetadata', true));\n mappings_ = mappings;\n return mappings_;\n}\n\nexport function addRef(metadata: Metadata, service: FirebaseStorageImpl): void {\n function generateRef(): Reference {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const loc = new Location(bucket, path);\n return service._makeStorageReference(loc);\n }\n Object.defineProperty(metadata, 'ref', { get: generateRef });\n}\n\nexport function fromResource(\n service: FirebaseStorageImpl,\n resource: { [name: string]: unknown },\n mappings: Mappings\n): Metadata {\n const metadata: Metadata = {} as Metadata;\n metadata['type'] = 'file';\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n metadata[mapping.local] = (mapping as Mapping<unknown>).xform(\n metadata,\n resource[mapping.server]\n );\n }\n addRef(metadata, service);\n return metadata;\n}\n\nexport function fromResourceString(\n service: FirebaseStorageImpl,\n resourceString: string,\n mappings: Mappings\n): Metadata | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as Metadata;\n return fromResource(service, resource, mappings);\n}\n\nexport function downloadUrlFromResourceString(\n metadata: Metadata,\n resourceString: string,\n host: string,\n protocol: string\n): string | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n if (!isString(obj['downloadTokens'])) {\n // This can happen if objects are uploaded through GCS and retrieved\n // through list, so we don't want to throw an Error.\n return null;\n }\n const tokens: string = obj['downloadTokens'] as string;\n if (tokens.length === 0) {\n return null;\n }\n const encode = encodeURIComponent;\n const tokensList = tokens.split(',');\n const urls = tokensList.map((token: string): string => {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path);\n const base = makeUrl(urlPart, host, protocol);\n const queryString = makeQueryString({\n alt: 'media',\n token\n });\n return base + queryString;\n });\n return urls[0];\n}\n\nexport function toResourceString(\n metadata: Partial<Metadata>,\n mappings: Mappings\n): string {\n const resource: {\n [prop: string]: unknown;\n } = {};\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n if (mapping.writable) {\n resource[mapping.server] = metadata[mapping.local];\n }\n }\n return JSON.stringify(resource);\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the listOptions and listResult format\n */\nimport { Location } from './location';\nimport { jsonObjectOrNull } from './json';\nimport { ListResult } from '../list';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Represents the simplified object metadata returned by List API.\n * Other fields are filtered because list in Firebase Rules does not grant\n * the permission to read the metadata.\n */\ninterface ListMetadataResponse {\n name: string;\n bucket: string;\n}\n\n/**\n * Represents the JSON response of List API.\n */\ninterface ListResultResponse {\n prefixes: string[];\n items: ListMetadataResponse[];\n nextPageToken?: string;\n}\n\nconst PREFIXES_KEY = 'prefixes';\nconst ITEMS_KEY = 'items';\n\nfunction fromBackendResponse(\n service: FirebaseStorageImpl,\n bucket: string,\n resource: ListResultResponse\n): ListResult {\n const listResult: ListResult = {\n prefixes: [],\n items: [],\n nextPageToken: resource['nextPageToken']\n };\n if (resource[PREFIXES_KEY]) {\n for (const path of resource[PREFIXES_KEY]) {\n const pathWithoutTrailingSlash = path.replace(/\\/$/, '');\n const reference = service._makeStorageReference(\n new Location(bucket, pathWithoutTrailingSlash)\n );\n listResult.prefixes.push(reference);\n }\n }\n\n if (resource[ITEMS_KEY]) {\n for (const item of resource[ITEMS_KEY]) {\n const reference = service._makeStorageReference(\n new Location(bucket, item['name'])\n );\n listResult.items.push(reference);\n }\n }\n return listResult;\n}\n\nexport function fromResponseString(\n service: FirebaseStorageImpl,\n bucket: string,\n resourceString: string\n): ListResult | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as unknown as ListResultResponse;\n return fromBackendResponse(service, bucket, resource);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Headers, Connection, ConnectionType } from './connection';\n\n/**\n * Type for url params stored in RequestInfo.\n */\nexport interface UrlParams {\n [name: string]: string | number;\n}\n\n/**\n * A function that converts a server response to the API type expected by the\n * SDK.\n *\n * @param I - the type of the backend's network response\n * @param O - the output response type used by the rest of the SDK.\n */\nexport type RequestHandler<I extends ConnectionType, O> = (\n connection: Connection<I>,\n response: I\n) => O;\n\n/** A function to handle an error. */\nexport type ErrorHandler = (\n connection: Connection<ConnectionType>,\n response: StorageError\n) => StorageError;\n\n/**\n * Contains a fully specified request.\n *\n * @param I - the type of the backend's network response.\n * @param O - the output response type used by the rest of the SDK.\n */\nexport class RequestInfo<I extends ConnectionType, O> {\n urlParams: UrlParams = {};\n headers: Headers = {};\n body: Blob | string | Uint8Array | null = null;\n errorHandler: ErrorHandler | null = null;\n\n /**\n * Called with the current number of bytes uploaded and total size (-1 if not\n * computable) of the request body (i.e. used to report upload progress).\n */\n progressCallback: ((p1: number, p2: number) => void) | null = null;\n successCodes: number[] = [200];\n additionalRetryCodes: number[] = [];\n\n constructor(\n public url: string,\n public method: string,\n /**\n * Returns the value with which to resolve the request's promise. Only called\n * if the request is successful. Throw from this function to reject the\n * returned Request's promise with the thrown error.\n * Note: The XhrIo passed to this function may be reused after this callback\n * returns. Do not keep a reference to it in any way.\n */\n public handler: RequestHandler<I, O>,\n public timeout: number\n ) {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods for interacting with the network.\n */\n\nimport { Metadata } from '../metadata';\nimport { ListResult } from '../list';\nimport { FbsBlob } from './blob';\nimport {\n StorageError,\n cannotSliceBlob,\n unauthenticated,\n quotaExceeded,\n unauthorized,\n objectNotFound,\n serverFileWrongSize,\n unknown,\n unauthorizedApp\n} from './error';\nimport { Location } from './location';\nimport {\n Mappings,\n fromResourceString,\n downloadUrlFromResourceString,\n toResourceString\n} from './metadata';\nimport { fromResponseString } from './list';\nimport { RequestInfo, UrlParams } from './requestinfo';\nimport { isString } from './type';\nimport { makeUrl } from './url';\nimport { Connection, ConnectionType } from './connection';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Throws the UNKNOWN StorageError if cndn is false.\n */\nexport function handlerCheck(cndn: boolean): void {\n if (!cndn) {\n throw unknown();\n }\n}\n\nexport function metadataHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => Metadata {\n function handler(xhr: Connection<string>, text: string): Metadata {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return metadata as Metadata;\n }\n return handler;\n}\n\nexport function listHandler(\n service: FirebaseStorageImpl,\n bucket: string\n): (p1: Connection<string>, p2: string) => ListResult {\n function handler(xhr: Connection<string>, text: string): ListResult {\n const listResult = fromResponseString(service, bucket, text);\n handlerCheck(listResult !== null);\n return listResult as ListResult;\n }\n return handler;\n}\n\nexport function downloadUrlHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => string | null {\n function handler(xhr: Connection<string>, text: string): string | null {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return downloadUrlFromResourceString(\n metadata as Metadata,\n text,\n service.host,\n service._protocol\n );\n }\n return handler;\n}\n\nexport function sharedErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr: StorageError;\n if (xhr.getStatus() === 401) {\n if (\n // This exact message string is the only consistent part of the\n // server's error response that identifies it as an App Check error.\n xhr.getErrorText().includes('Firebase App Check token is invalid')\n ) {\n newErr = unauthorizedApp();\n } else {\n newErr = unauthenticated();\n }\n } else {\n if (xhr.getStatus() === 402) {\n newErr = quotaExceeded(location.bucket);\n } else {\n if (xhr.getStatus() === 403) {\n newErr = unauthorized(location.path);\n } else {\n newErr = err;\n }\n }\n }\n newErr.status = xhr.getStatus();\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function objectErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n const shared = sharedErrorHandler(location);\n\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr = shared(xhr, err);\n if (xhr.getStatus() === 404) {\n newErr = objectNotFound(location.path);\n }\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function getMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function list(\n service: FirebaseStorageImpl,\n location: Location,\n delimiter?: string,\n pageToken?: string | null,\n maxResults?: number | null\n): RequestInfo<string, ListResult> {\n const urlParams: UrlParams = {};\n if (location.isRoot) {\n urlParams['prefix'] = '';\n } else {\n urlParams['prefix'] = location.path + '/';\n }\n if (delimiter && delimiter.length > 0) {\n urlParams['delimiter'] = delimiter;\n }\n if (pageToken) {\n urlParams['pageToken'] = pageToken;\n }\n if (maxResults) {\n urlParams['maxResults'] = maxResults;\n }\n const urlPart = location.bucketOnlyServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n listHandler(service, location.bucket),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\nexport function getBytes<I extends ConnectionType>(\n service: FirebaseStorageImpl,\n location: Location,\n maxDownloadSizeBytes?: number\n): RequestInfo<I, I> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n (_: Connection<I>, data: I) => data,\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n if (maxDownloadSizeBytes !== undefined) {\n requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;\n requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];\n }\n return requestInfo;\n}\n\nexport function getDownloadUrl(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, string | null> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n downloadUrlHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function updateMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n metadata: Partial<Metadata>,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'PATCH';\n const body = toResourceString(metadata, mappings);\n const headers = { 'Content-Type': 'application/json; charset=utf-8' };\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function deleteObject(\n service: FirebaseStorageImpl,\n location: Location\n): RequestInfo<string, void> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'DELETE';\n const timeout = service.maxOperationRetryTime;\n\n function handler(_xhr: Connection<string>, _text: string): void {}\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.successCodes = [200, 204];\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function determineContentType_(\n metadata: Metadata | null,\n blob: FbsBlob | null\n): string {\n return (\n (metadata && metadata['contentType']) ||\n (blob && blob.type()) ||\n 'application/octet-stream'\n );\n}\n\nexport function metadataForUpload_(\n location: Location,\n blob: FbsBlob,\n metadata?: Metadata | null\n): Metadata {\n const metadataClone = Object.assign({}, metadata);\n metadataClone['fullPath'] = location.path;\n metadataClone['size'] = blob.size();\n if (!metadataClone['contentType']) {\n metadataClone['contentType'] = determineContentType_(null, blob);\n }\n return metadataClone;\n}\n\n/**\n * Prepare RequestInfo for uploads as Content-Type: multipart.\n */\nexport function multipartUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, Metadata> {\n const urlPart = location.bucketOnlyServerUrl();\n const headers: { [prop: string]: string } = {\n 'X-Goog-Upload-Protocol': 'multipart'\n };\n\n function genBoundary(): string {\n let str = '';\n for (let i = 0; i < 2; i++) {\n str = str + Math.random().toString().slice(2);\n }\n return str;\n }\n const boundary = genBoundary();\n headers['Content-Type'] = 'multipart/related; boundary=' + boundary;\n const metadata_ = metadataForUpload_(location, blob, metadata);\n const metadataString = toResourceString(metadata_, mappings);\n const preBlobPart =\n '--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: application/json; charset=utf-8\\r\\n\\r\\n' +\n metadataString +\n '\\r\\n--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: ' +\n metadata_['contentType'] +\n '\\r\\n\\r\\n';\n const postBlobPart = '\\r\\n--' + boundary + '--';\n const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);\n if (body === null) {\n throw cannotSliceBlob();\n }\n const urlParams: UrlParams = { name: metadata_['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param current The number of bytes that have been uploaded so far.\n * @param total The total number of bytes in the upload.\n * @param opt_finalized True if the server has finished the upload.\n * @param opt_metadata The upload metadata, should\n * only be passed if opt_finalized is true.\n */\nexport class ResumableUploadStatus {\n finalized: boolean;\n metadata: Metadata | null;\n\n constructor(\n public current: number,\n public total: number,\n finalized?: boolean,\n metadata?: Metadata | null\n ) {\n this.finalized = !!finalized;\n this.metadata = metadata || null;\n }\n}\n\nexport function checkResumeHeader_(\n xhr: Connection<string>,\n allowed?: string[]\n): string {\n let status: string | null = null;\n try {\n status = xhr.getResponseHeader('X-Goog-Upload-Status');\n } catch (e) {\n handlerCheck(false);\n }\n const allowedStatus = allowed || ['active'];\n handlerCheck(!!status && allowedStatus.indexOf(status) !== -1);\n return status as string;\n}\n\nexport function createResumableUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, string> {\n const urlPart = location.bucketOnlyServerUrl();\n const metadataForUpload = metadataForUpload_(location, blob, metadata);\n const urlParams: UrlParams = { name: metadataForUpload['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const headers = {\n 'X-Goog-Upload-Protocol': 'resumable',\n 'X-Goog-Upload-Command': 'start',\n 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`,\n 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType']!,\n 'Content-Type': 'application/json; charset=utf-8'\n };\n const body = toResourceString(metadataForUpload, mappings);\n const timeout = service.maxUploadRetryTime;\n\n function handler(xhr: Connection<string>): string {\n checkResumeHeader_(xhr);\n let url;\n try {\n url = xhr.getResponseHeader('X-Goog-Upload-URL');\n } catch (e) {\n handlerCheck(false);\n }\n handlerCheck(isString(url));\n return url as string;\n }\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n */\nexport function getResumableUploadStatus(\n service: FirebaseStorageImpl,\n location: Location,\n url: string,\n blob: FbsBlob\n): RequestInfo<string, ResumableUploadStatus> {\n const headers = { 'X-Goog-Upload-Command': 'query' };\n\n function handler(xhr: Connection<string>): ResumableUploadStatus {\n const status = checkResumeHeader_(xhr, ['active', 'final']);\n let sizeString: string | null = null;\n try {\n sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received');\n } catch (e) {\n handlerCheck(false);\n }\n\n if (!sizeString) {\n // null or empty string\n handlerCheck(false);\n }\n\n const size = Number(sizeString);\n handlerCheck(!isNaN(size));\n return new ResumableUploadStatus(size, blob.size(), status === 'final');\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * Any uploads via the resumable upload API must transfer a number of bytes\n * that is a multiple of this number.\n */\nexport const RESUMABLE_UPLOAD_CHUNK_SIZE: number = 256 * 1024;\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n * @param chunkSize Number of bytes to upload.\n * @param status The previous status.\n * If not passed or null, we start from the beginning.\n * @throws fbs.Error If the upload is already complete, the passed in status\n * has a final size inconsistent with the blob, or the blob cannot be sliced\n * for upload.\n */\nexport function continueResumableUpload(\n location: Location,\n service: FirebaseStorageImpl,\n url: string,\n blob: FbsBlob,\n chunkSize: number,\n mappings: Mappings,\n status?: ResumableUploadStatus | null,\n progressCallback?: ((p1: number, p2: number) => void) | null\n): RequestInfo<string, ResumableUploadStatus> {\n // TODO(andysoto): standardize on internal asserts\n // assert(!(opt_status && opt_status.finalized));\n const status_ = new ResumableUploadStatus(0, 0);\n if (status) {\n status_.current = status.current;\n status_.total = status.total;\n } else {\n status_.current = 0;\n status_.total = blob.size();\n }\n if (blob.size() !== status_.total) {\n throw serverFileWrongSize();\n }\n const bytesLeft = status_.total - status_.current;\n let bytesToUpload = bytesLeft;\n if (chunkSize > 0) {\n bytesToUpload = Math.min(bytesToUpload, chunkSize);\n }\n const startByte = status_.current;\n const endByte = startByte + bytesToUpload;\n let uploadCommand = '';\n if (bytesToUpload === 0) {\n uploadCommand = 'finalize';\n } else if (bytesLeft === bytesToUpload) {\n uploadCommand = 'upload, finalize';\n } else {\n uploadCommand = 'upload';\n }\n const headers = {\n 'X-Goog-Upload-Command': uploadCommand,\n 'X-Goog-Upload-Offset': `${status_.current}`\n };\n const body = blob.slice(startByte, endByte);\n if (body === null) {\n throw cannotSliceBlob();\n }\n\n function handler(\n xhr: Connection<string>,\n text: string\n ): ResumableUploadStatus {\n // TODO(andysoto): Verify the MD5 of each uploaded range:\n // the 'x-range-md5' header comes back with status code 308 responses.\n // We'll only be able to bail out though, because you can't re-upload a\n // range that you previously uploaded.\n const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']);\n const newCurrent = status_.current + bytesToUpload;\n const size = blob.size();\n let metadata;\n if (uploadStatus === 'final') {\n metadata = metadataHandler(service, mappings)(xhr, text);\n } else {\n metadata = null;\n }\n return new ResumableUploadStatus(\n newCurrent,\n size,\n uploadStatus === 'final',\n metadata\n );\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.progressCallback = progressCallback || null;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Enumerations used for upload tasks.\n */\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport type TaskEvent = string;\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport const TaskEvent = {\n /**\n * For this event,\n * <ul>\n * <li>The `next` function is triggered on progress updates and when the\n * task is paused/resumed with an `UploadTaskSnapshot` as the first\n * argument.</li>\n * <li>The `error` function is triggered if the upload is canceled or fails\n * for another reason.</li>\n * <li>The `complete` function is triggered if the upload completes\n * successfully.</li>\n * </ul>\n */\n STATE_CHANGED: 'state_changed'\n};\n\n/**\n * Internal enum for task state.\n */\nexport const enum InternalTaskState {\n RUNNING = 'running',\n PAUSING = 'pausing',\n PAUSED = 'paused',\n SUCCESS = 'success',\n CANCELING = 'canceling',\n CANCELED = 'canceled',\n ERROR = 'error'\n}\n\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport type TaskState = (typeof TaskState)[keyof typeof TaskState];\n\n// type keys = keyof TaskState\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport const TaskState = {\n /** The task is currently transferring data. */\n RUNNING: 'running',\n\n /** The task was paused by the user. */\n PAUSED: 'paused',\n\n /** The task completed successfully. */\n SUCCESS: 'success',\n\n /** The task was canceled. */\n CANCELED: 'canceled',\n\n /** The task failed with an error. */\n ERROR: 'error'\n} as const;\n\nexport function taskStateFromInternalTaskState(\n state: InternalTaskState\n): TaskState {\n switch (state) {\n case InternalTaskState.RUNNING:\n case InternalTaskState.PAUSING:\n case InternalTaskState.CANCELING:\n return TaskState.RUNNING;\n case InternalTaskState.PAUSED:\n return TaskState.PAUSED;\n case InternalTaskState.SUCCESS:\n return TaskState.SUCCESS;\n case InternalTaskState.CANCELED:\n return TaskState.CANCELED;\n case InternalTaskState.ERROR:\n return TaskState.ERROR;\n default:\n // TODO(andysoto): assert(false);\n return TaskState.ERROR;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isFunction } from './type';\nimport { StorageError } from './error';\n\n/**\n * Function that is called once for each value in a stream of values.\n */\nexport type NextFn<T> = (value: T) => void;\n\n/**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\nexport type ErrorFn = (error: StorageError) => void;\n\n/**\n * A function that is called if the event stream ends normally.\n */\nexport type CompleteFn = () => void;\n\n/**\n * Unsubscribes from a stream.\n */\nexport type Unsubscribe = () => void;\n\n/**\n * An observer identical to the `Observer` defined in packages/util except the\n * error passed into the ErrorFn is specifically a `StorageError`.\n */\nexport interface StorageObserver<T> {\n /**\n * Function that is called once for each value in the event stream.\n */\n next?: NextFn<T>;\n /**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\n error?: ErrorFn;\n /**\n * A function that is called if the event stream ends normally.\n */\n complete?: CompleteFn;\n}\n\n/**\n * Subscribes to an event stream.\n */\nexport type Subscribe<T> = (\n next?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n) => Unsubscribe;\n\nexport class Observer<T> implements StorageObserver<T> {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n\n constructor(\n nextOrObserver?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n ) {\n const asFunctions =\n isFunction(nextOrObserver) || error != null || complete != null;\n if (asFunctions) {\n this.next = nextOrObserver as NextFn<T>;\n this.error = error ?? undefined;\n this.complete = complete ?? undefined;\n } else {\n const observer = nextOrObserver as {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n };\n this.next = observer.next;\n this.error = observer.error;\n this.complete = observer.complete;\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a function that invokes f with its arguments asynchronously as a\n * microtask, i.e. as soon as possible after the current script returns back\n * into browser code.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function async(f: Function): Function {\n return (...argsToForward: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => f(...argsToForward));\n };\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isCloudWorkstation } from '@firebase/util';\nimport {\n Connection,\n ConnectionType,\n ErrorCode,\n Headers\n} from '../../implementation/connection';\nimport { internalError } from '../../implementation/error';\n\n/** An override for the text-based Connection. Used in tests. */\nlet textFactoryOverride: (() => Connection<string>) | null = null;\n\n/**\n * Network layer for browsers. We use this instead of goog.net.XhrIo because\n * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.\n */\nabstract class XhrConnection<T extends ConnectionType>\n implements Connection<T>\n{\n protected xhr_: XMLHttpRequest;\n private errorCode_: ErrorCode;\n private sendPromise_: Promise<void>;\n protected sent_: boolean = false;\n\n constructor() {\n this.xhr_ = new XMLHttpRequest();\n this.initXhr();\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.sendPromise_ = new Promise(resolve => {\n this.xhr_.addEventListener('abort', () => {\n this.errorCode_ = ErrorCode.ABORT;\n resolve();\n });\n this.xhr_.addEventListener('error', () => {\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n resolve();\n });\n this.xhr_.addEventListener('load', () => {\n resolve();\n });\n });\n }\n\n abstract initXhr(): void;\n\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string,\n headers?: Headers\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n if (isCloudWorkstation(url) && isUsingEmulator) {\n this.xhr_.withCredentials = true;\n }\n this.sent_ = true;\n this.xhr_.open(method, url, true);\n if (headers !== undefined) {\n for (const key in headers) {\n if (headers.hasOwnProperty(key)) {\n this.xhr_.setRequestHeader(key, headers[key].toString());\n }\n }\n }\n if (body !== undefined) {\n this.xhr_.send(body);\n } else {\n this.xhr_.send();\n }\n return this.sendPromise_;\n }\n\n getErrorCode(): ErrorCode {\n if (!this.sent_) {\n throw internalError('cannot .getErrorCode() before sending');\n }\n return this.errorCode_;\n }\n\n getStatus(): number {\n if (!this.sent_) {\n throw internalError('cannot .getStatus() before sending');\n }\n try {\n return this.xhr_.status;\n } catch (e) {\n return -1;\n }\n }\n\n getResponse(): T {\n if (!this.sent_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.xhr_.response;\n }\n\n getErrorText(): string {\n if (!this.sent_) {\n throw internalError('cannot .getErrorText() before sending');\n }\n return this.xhr_.statusText;\n }\n\n /** Aborts the request. */\n abort(): void {\n this.xhr_.abort();\n }\n\n getResponseHeader(header: string): string | null {\n return this.xhr_.getResponseHeader(header);\n }\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n if (this.xhr_.upload != null) {\n this.xhr_.upload.addEventListener('progress', listener);\n }\n }\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n if (this.xhr_.upload != null) {\n this.xhr_.upload.removeEventListener('progress', listener);\n }\n }\n}\n\nexport class XhrTextConnection extends XhrConnection<string> {\n initXhr(): void {\n this.xhr_.responseType = 'text';\n }\n}\n\nexport function newTextConnection(): Connection<string> {\n return textFactoryOverride ? textFactoryOverride() : new XhrTextConnection();\n}\n\nexport class XhrBytesConnection extends XhrConnection<ArrayBuffer> {\n private data_?: ArrayBuffer;\n\n initXhr(): void {\n this.xhr_.responseType = 'arraybuffer';\n }\n}\n\nexport function newBytesConnection(): Connection<ArrayBuffer> {\n return new XhrBytesConnection();\n}\n\nexport class XhrBlobConnection extends XhrConnection<Blob> {\n initXhr(): void {\n this.xhr_.responseType = 'blob';\n }\n}\n\nexport function newBlobConnection(): Connection<Blob> {\n return new XhrBlobConnection();\n}\n\nexport function newStreamConnection(): Connection<ReadableStream> {\n throw new Error('Streams are only supported on Node');\n}\n\nexport function injectTestConnection(\n factory: (() => Connection<string>) | null\n): void {\n textFactoryOverride = factory;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Defines types for interacting with blob transfer tasks.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport {\n canceled,\n StorageErrorCode,\n StorageError,\n retryLimitExceeded\n} from './implementation/error';\nimport {\n InternalTaskState,\n TaskEvent,\n TaskState,\n taskStateFromInternalTaskState\n} from './implementation/taskenums';\nimport { Metadata } from './metadata';\nimport {\n Observer,\n Subscribe,\n Unsubscribe,\n StorageObserver as StorageObserverInternal,\n NextFn\n} from './implementation/observer';\nimport { Request } from './implementation/request';\nimport { UploadTaskSnapshot, StorageObserver } from './public-types';\nimport { async as fbsAsync } from './implementation/async';\nimport { Mappings, getMappings } from './implementation/metadata';\nimport {\n createResumableUpload,\n getResumableUploadStatus,\n RESUMABLE_UPLOAD_CHUNK_SIZE,\n ResumableUploadStatus,\n continueResumableUpload,\n getMetadata,\n multipartUpload\n} from './implementation/requests';\nimport { Reference } from './reference';\nimport { newTextConnection } from './platform/connection';\nimport { isRetryStatusCode } from './implementation/utils';\nimport { CompleteFn } from '@firebase/util';\nimport { DEFAULT_MIN_SLEEP_TIME_MILLIS } from './implementation/constants';\n\n/**\n * Represents a blob being uploaded. Can be used to pause/resume/cancel the\n * upload and manage callbacks for various events.\n * @internal\n */\nexport class UploadTask {\n private _ref: Reference;\n /**\n * The data to be uploaded.\n */\n _blob: FbsBlob;\n /**\n * Metadata related to the upload.\n */\n _metadata: Metadata | null;\n private _mappings: Mappings;\n /**\n * Number of bytes transferred so far.\n */\n _transferred: number = 0;\n private _needToFetchStatus: boolean = false;\n private _needToFetchMetadata: boolean = false;\n private _observers: Array<StorageObserverInternal<UploadTaskSnapshot>> = [];\n private _resumable: boolean;\n /**\n * Upload state.\n */\n _state: InternalTaskState;\n private _error?: StorageError = undefined;\n private _uploadUrl?: string = undefined;\n private _request?: Request<unknown> = undefined;\n private _chunkMultiplier: number = 1;\n private _errorHandler: (p1: StorageError) => void;\n private _metadataErrorHandler: (p1: StorageError) => void;\n private _resolve?: (p1: UploadTaskSnapshot) => void = undefined;\n private _reject?: (p1: StorageError) => void = undefined;\n private pendingTimeout?: ReturnType<typeof setTimeout>;\n private _promise: Promise<UploadTaskSnapshot>;\n\n private sleepTime: number;\n\n private maxSleepTime: number;\n\n isExponentialBackoffExpired(): boolean {\n return this.sleepTime > this.maxSleepTime;\n }\n\n /**\n * @param ref - The firebaseStorage.Reference object this task came\n * from, untyped to avoid cyclic dependencies.\n * @param blob - The blob to upload.\n */\n constructor(ref: Reference, blob: FbsBlob, metadata: Metadata | null = null) {\n this._ref = ref;\n this._blob = blob;\n this._metadata = metadata;\n this._mappings = getMappings();\n this._resumable = this._shouldDoResumable(this._blob);\n this._state = InternalTaskState.RUNNING;\n this._errorHandler = error => {\n this._request = undefined;\n this._chunkMultiplier = 1;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this._needToFetchStatus = true;\n this.completeTransitions_();\n } else {\n const backoffExpired = this.isExponentialBackoffExpired();\n if (isRetryStatusCode(error.status, [])) {\n if (backoffExpired) {\n error = retryLimitExceeded();\n } else {\n this.sleepTime = Math.max(\n this.sleepTime * 2,\n DEFAULT_MIN_SLEEP_TIME_MILLIS\n );\n this._needToFetchStatus = true;\n this.completeTransitions_();\n return;\n }\n }\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this._metadataErrorHandler = error => {\n this._request = undefined;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this.completeTransitions_();\n } else {\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this.sleepTime = 0;\n this.maxSleepTime = this._ref.storage.maxUploadRetryTime;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n this._start();\n });\n\n // Prevent uncaught rejections on the internal promise from bubbling out\n // to the top level with a dummy handler.\n this._promise.then(null, () => {});\n }\n\n private _makeProgressCallback(): (p1: number, p2: number) => void {\n const sizeBefore = this._transferred;\n return loaded => this._updateProgress(sizeBefore + loaded);\n }\n\n private _shouldDoResumable(blob: FbsBlob): boolean {\n return blob.size() > 256 * 1024;\n }\n\n private _start(): void {\n if (this._state !== InternalTaskState.RUNNING) {\n // This can happen if someone pauses us in a resume callback, for example.\n return;\n }\n if (this._request !== undefined) {\n return;\n }\n if (this._resumable) {\n if (this._uploadUrl === undefined) {\n this._createResumable();\n } else {\n if (this._needToFetchStatus) {\n this._fetchStatus();\n } else {\n if (this._needToFetchMetadata) {\n // Happens if we miss the metadata on upload completion.\n this._fetchMetadata();\n } else {\n this.pendingTimeout = setTimeout(() => {\n this.pendingTimeout = undefined;\n this._continueUpload();\n }, this.sleepTime);\n }\n }\n }\n } else {\n this._oneShotUpload();\n }\n }\n\n private _resolveToken(\n callback: (authToken: string | null, appCheckToken: string | null) => void\n ): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all([\n this._ref.storage._getAuthToken(),\n this._ref.storage._getAppCheckToken()\n ]).then(([authToken, appCheckToken]) => {\n switch (this._state) {\n case InternalTaskState.RUNNING:\n callback(authToken, appCheckToken);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n default:\n }\n });\n }\n\n // TODO(andysoto): assert false\n\n private _createResumable(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = createResumableUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const createRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = createRequest;\n createRequest.getPromise().then((url: string) => {\n this._request = undefined;\n this._uploadUrl = url;\n this._needToFetchStatus = false;\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _fetchStatus(): void {\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getResumableUploadStatus(\n this._ref.storage,\n this._ref._location,\n url,\n this._blob\n );\n const statusRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = statusRequest;\n statusRequest.getPromise().then(status => {\n status = status as ResumableUploadStatus;\n this._request = undefined;\n this._updateProgress(status.current);\n this._needToFetchStatus = false;\n if (status.finalized) {\n this._needToFetchMetadata = true;\n }\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _continueUpload(): void {\n const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n const status = new ResumableUploadStatus(\n this._transferred,\n this._blob.size()\n );\n\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n let requestInfo;\n try {\n requestInfo = continueResumableUpload(\n this._ref._location,\n this._ref.storage,\n url,\n this._blob,\n chunkSize,\n this._mappings,\n status,\n this._makeProgressCallback()\n );\n } catch (e) {\n this._error = e as StorageError;\n this._transition(InternalTaskState.ERROR);\n return;\n }\n const uploadRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken,\n /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file.\n );\n this._request = uploadRequest;\n uploadRequest.getPromise().then((newStatus: ResumableUploadStatus) => {\n this._increaseMultiplier();\n this._request = undefined;\n this._updateProgress(newStatus.current);\n if (newStatus.finalized) {\n this._metadata = newStatus.metadata;\n this._transition(InternalTaskState.SUCCESS);\n } else {\n this.completeTransitions_();\n }\n }, this._errorHandler);\n });\n }\n\n private _increaseMultiplier(): void {\n const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n\n // Max chunk size is 32M.\n if (currentSize * 2 < 32 * 1024 * 1024) {\n this._chunkMultiplier *= 2;\n }\n }\n\n private _fetchMetadata(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getMetadata(\n this._ref.storage,\n this._ref._location,\n this._mappings\n );\n const metadataRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = metadataRequest;\n metadataRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._transition(InternalTaskState.SUCCESS);\n }, this._metadataErrorHandler);\n });\n }\n\n private _oneShotUpload(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = multipartUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const multipartRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = multipartRequest;\n multipartRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._updateProgress(this._blob.size());\n this._transition(InternalTaskState.SUCCESS);\n }, this._errorHandler);\n });\n }\n\n private _updateProgress(transferred: number): void {\n const old = this._transferred;\n this._transferred = transferred;\n\n // A progress update can make the \"transferred\" value smaller (e.g. a\n // partial upload not completed by server, after which the \"transferred\"\n // value may reset to the value at the beginning of the request).\n if (this._transferred !== old) {\n this._notifyObservers();\n }\n }\n\n private _transition(state: InternalTaskState): void {\n if (this._state === state) {\n return;\n }\n switch (state) {\n case InternalTaskState.CANCELING:\n case InternalTaskState.PAUSING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n if (this._request !== undefined) {\n this._request.cancel();\n } else if (this.pendingTimeout) {\n clearTimeout(this.pendingTimeout);\n this.pendingTimeout = undefined;\n this.completeTransitions_();\n }\n break;\n case InternalTaskState.RUNNING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.PAUSING);\n const wasPaused = this._state === InternalTaskState.PAUSED;\n this._state = state;\n if (wasPaused) {\n this._notifyObservers();\n this._start();\n }\n break;\n case InternalTaskState.PAUSED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.CANCELED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.CANCELING);\n this._error = canceled();\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.ERROR:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.SUCCESS:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n default: // Ignore\n }\n }\n\n private completeTransitions_(): void {\n switch (this._state) {\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.RUNNING:\n this._start();\n break;\n default:\n // TODO(andysoto): assert(false);\n break;\n }\n }\n\n /**\n * A snapshot of the current task state.\n */\n get snapshot(): UploadTaskSnapshot {\n const externalState = taskStateFromInternalTaskState(this._state);\n return {\n bytesTransferred: this._transferred,\n totalBytes: this._blob.size(),\n state: externalState,\n metadata: this._metadata!,\n task: this,\n ref: this._ref\n };\n }\n\n /**\n * Adds a callback for an event.\n * @param type - The type of event to listen for.\n * @param nextOrObserver -\n * The `next` function, which gets called for each item in\n * the event stream, or an observer object with some or all of these three\n * properties (`next`, `error`, `complete`).\n * @param error - A function that gets called with a `StorageError`\n * if the event stream ends due to an error.\n * @param completed - A function that gets called if the\n * event stream ends normally.\n * @returns\n * If only the event argument is passed, returns a function you can use to\n * add callbacks (see the examples above). If more than just the event\n * argument is passed, returns a function you can call to unregister the\n * callbacks.\n */\n on(\n type: TaskEvent,\n nextOrObserver?:\n | StorageObserver<UploadTaskSnapshot>\n | null\n | ((snapshot: UploadTaskSnapshot) => unknown),\n error?: ((a: StorageError) => unknown) | null,\n completed?: CompleteFn | null\n ): Unsubscribe | Subscribe<UploadTaskSnapshot> {\n // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string.\n const observer = new Observer(\n (nextOrObserver as\n | StorageObserverInternal<UploadTaskSnapshot>\n | NextFn<UploadTaskSnapshot>) || undefined,\n error || undefined,\n completed || undefined\n );\n this._addObserver(observer);\n return () => {\n this._removeObserver(observer);\n };\n }\n\n /**\n * This object behaves like a Promise, and resolves with its snapshot data\n * when the upload completes.\n * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.\n * @param onRejected - The rejection callback.\n */\n then<U>(\n onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null,\n onRejected?: ((error: StorageError) => U | Promise<U>) | null\n ): Promise<U> {\n // These casts are needed so that TypeScript can infer the types of the\n // resulting Promise.\n return this._promise.then<U>(\n onFulfilled as (value: UploadTaskSnapshot) => U | Promise<U>,\n onRejected as ((error: unknown) => Promise<never>) | null\n );\n }\n\n /**\n * Equivalent to calling `then(null, onRejected)`.\n */\n catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T> {\n return this.then(null, onRejected);\n }\n\n /**\n * Adds the given observer.\n */\n private _addObserver(observer: Observer<UploadTaskSnapshot>): void {\n this._observers.push(observer);\n this._notifyObserver(observer);\n }\n\n /**\n * Removes the given observer.\n */\n private _removeObserver(observer: Observer<UploadTaskSnapshot>): void {\n const i = this._observers.indexOf(observer);\n if (i !== -1) {\n this._observers.splice(i, 1);\n }\n }\n\n private _notifyObservers(): void {\n this._finishPromise();\n const observers = this._observers.slice();\n observers.forEach(observer => {\n this._notifyObserver(observer);\n });\n }\n\n private _finishPromise(): void {\n if (this._resolve !== undefined) {\n let triggered = true;\n switch (taskStateFromInternalTaskState(this._state)) {\n case TaskState.SUCCESS:\n fbsAsync(this._resolve.bind(null, this.snapshot))();\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n const toCall = this._reject as (p1: StorageError) => void;\n fbsAsync(toCall.bind(null, this._error as StorageError))();\n break;\n default:\n triggered = false;\n break;\n }\n if (triggered) {\n this._resolve = undefined;\n this._reject = undefined;\n }\n }\n }\n\n private _notifyObserver(observer: Observer<UploadTaskSnapshot>): void {\n const externalState = taskStateFromInternalTaskState(this._state);\n switch (externalState) {\n case TaskState.RUNNING:\n case TaskState.PAUSED:\n if (observer.next) {\n fbsAsync(observer.next.bind(observer, this.snapshot))();\n }\n break;\n case TaskState.SUCCESS:\n if (observer.complete) {\n fbsAsync(observer.complete.bind(observer))();\n }\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n break;\n default:\n // TODO(andysoto): assert(false);\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n }\n }\n\n /**\n * Resumes a paused task. Has no effect on a currently running or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n resume(): boolean {\n const valid =\n this._state === InternalTaskState.PAUSED ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.RUNNING);\n }\n return valid;\n }\n\n /**\n * Pauses a currently running task. Has no effect on a paused or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n pause(): boolean {\n const valid = this._state === InternalTaskState.RUNNING;\n if (valid) {\n this._transition(InternalTaskState.PAUSING);\n }\n return valid;\n }\n\n /**\n * Cancels a currently running or paused task. Has no effect on a complete or\n * failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n cancel(): boolean {\n const valid =\n this._state === InternalTaskState.RUNNING ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.CANCELING);\n }\n return valid;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines the Firebase StorageReference class.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport { Location } from './implementation/location';\nimport { getMappings } from './implementation/metadata';\nimport { child, lastComponent, parent } from './implementation/path';\nimport {\n deleteObject as requestsDeleteObject,\n getBytes,\n getDownloadUrl as requestsGetDownloadUrl,\n getMetadata as requestsGetMetadata,\n list as requestsList,\n multipartUpload,\n updateMetadata as requestsUpdateMetadata\n} from './implementation/requests';\nimport { ListOptions, UploadResult } from './public-types';\nimport { dataFromString, StringFormat } from './implementation/string';\nimport { Metadata } from './metadata';\nimport { FirebaseStorageImpl } from './service';\nimport { ListResult } from './list';\nimport { UploadTask } from './task';\nimport { invalidRootOperation, noDownloadURL } from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport {\n newBlobConnection,\n newBytesConnection,\n newStreamConnection,\n newTextConnection\n} from './platform/connection';\nimport { RequestInfo } from './implementation/requestinfo';\n\n/**\n * Provides methods to interact with a bucket in the Firebase Storage service.\n * @internal\n * @param _location - An fbs.location, or the URL at\n * which to base this object, in one of the following forms:\n * gs://<bucket>/<object-path>\n * http[s]://firebasestorage.googleapis.com/\n * <api-version>/b/<bucket>/o/<object-path>\n * Any query or fragment strings will be ignored in the http[s]\n * format. If no value is passed, the storage object will use a URL based on\n * the project ID of the base firebase.App instance.\n */\nexport class Reference {\n _location: Location;\n\n constructor(\n private _service: FirebaseStorageImpl,\n location: string | Location\n ) {\n if (location instanceof Location) {\n this._location = location;\n } else {\n this._location = Location.makeFromUrl(location, _service.host);\n }\n }\n\n /**\n * Returns the URL for the bucket and path this object references,\n * in the form gs://<bucket>/<object-path>\n * @override\n */\n toString(): string {\n return 'gs://' + this._location.bucket + '/' + this._location.path;\n }\n\n protected _newRef(\n service: FirebaseStorageImpl,\n location: Location\n ): Reference {\n return new Reference(service, location);\n }\n\n /**\n * A reference to the root of this object's bucket.\n */\n get root(): Reference {\n const location = new Location(this._location.bucket, '');\n return this._newRef(this._service, location);\n }\n\n /**\n * The name of the bucket containing this reference's object.\n */\n get bucket(): string {\n return this._location.bucket;\n }\n\n /**\n * The full path of this object.\n */\n get fullPath(): string {\n return this._location.path;\n }\n\n /**\n * The short name of this object, which is the last component of the full path.\n * For example, if fullPath is 'full/path/image.png', name is 'image.png'.\n */\n get name(): string {\n return lastComponent(this._location.path);\n }\n\n /**\n * The `StorageService` instance this `StorageReference` is associated with.\n */\n get storage(): FirebaseStorageImpl {\n return this._service;\n }\n\n /**\n * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if\n * this reference is the root.\n */\n get parent(): Reference | null {\n const newPath = parent(this._location.path);\n if (newPath === null) {\n return null;\n }\n const location = new Location(this._location.bucket, newPath);\n return new Reference(this._service, location);\n }\n\n /**\n * Utility function to throw an error in methods that do not accept a root reference.\n */\n _throwIfRoot(name: string): void {\n if (this._location.path === '') {\n throw invalidRootOperation(name);\n }\n }\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded bytes.\n */\nexport function getBytesInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref._throwIfRoot('getBytes');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBytesConnection)\n .then(bytes =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (bytes as ArrayBuffer).slice(0, maxDownloadSizeBytes)\n : (bytes as ArrayBuffer)\n );\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded blob.\n */\nexport function getBlobInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref._throwIfRoot('getBlob');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBlobConnection)\n .then(blob =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (blob as Blob).slice(0, maxDownloadSizeBytes)\n : (blob as Blob)\n );\n}\n\n/** Stream the bytes at the object's location. */\nexport function getStreamInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref._throwIfRoot('getStream');\n const requestInfo: RequestInfo<ReadableStream, ReadableStream> = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n\n // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result\n const newMaxSizeTransform = (n: number): Transformer => {\n let missingBytes = n;\n return {\n transform(chunk, controller: TransformStreamDefaultController) {\n // GCS may not honor the Range header for small files\n if (chunk.length < missingBytes) {\n controller.enqueue(chunk);\n missingBytes -= chunk.length;\n } else {\n controller.enqueue(chunk.slice(0, missingBytes));\n controller.terminate();\n }\n }\n };\n };\n\n const result =\n maxDownloadSizeBytes !== undefined\n ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))\n : new TransformStream(); // The default transformer forwards all chunks to its readable side\n\n ref.storage\n .makeRequestWithTokens(requestInfo, newStreamConnection)\n .then(readableStream => readableStream.pipeThrough(result))\n .catch(err => result.writable.abort(err));\n\n return result.readable;\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n *\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadBytes');\n const requestInfo = multipartUpload(\n ref.storage,\n ref._location,\n getMappings(),\n new FbsBlob(data, true),\n metadata\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(finalMetadata => {\n return {\n metadata: finalMetadata,\n ref\n };\n });\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): UploadTask {\n ref._throwIfRoot('uploadBytesResumable');\n return new UploadTask(ref, new FbsBlob(data), metadata);\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - StorageReference where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the newly uploaded string.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: Reference,\n value: string,\n format: StringFormat = StringFormat.RAW,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadString');\n const data = dataFromString(format, value);\n const metadataClone = { ...metadata } as Metadata;\n if (metadataClone['contentType'] == null && data.contentType != null) {\n metadataClone['contentType'] = data.contentType!;\n }\n return uploadBytes(ref, data.data, metadataClone);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: listAll may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - StorageReference to get list from.\n *\n * @returns A Promise that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: Reference): Promise<ListResult> {\n const accumulator: ListResult = {\n prefixes: [],\n items: []\n };\n return listAllHelper(ref, accumulator).then(() => accumulator);\n}\n\n/**\n * Separated from listAll because async functions can't use \"arguments\".\n * @param ref\n * @param accumulator\n * @param pageToken\n */\nasync function listAllHelper(\n ref: Reference,\n accumulator: ListResult,\n pageToken?: string\n): Promise<void> {\n const opt: ListOptions = {\n // maxResults is 1000 by default.\n pageToken\n };\n const nextPage = await list(ref, opt);\n accumulator.prefixes.push(...nextPage.prefixes);\n accumulator.items.push(...nextPage.items);\n if (nextPage.nextPageToken != null) {\n await listAllHelper(ref, accumulator, nextPage.nextPageToken);\n }\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - StorageReference to get list from.\n * @param options - See ListOptions for details.\n * @returns A Promise that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: Reference,\n options?: ListOptions | null\n): Promise<ListResult> {\n if (options != null) {\n if (typeof options.maxResults === 'number') {\n validateNumber(\n 'options.maxResults',\n /* minValue= */ 1,\n /* maxValue= */ 1000,\n options.maxResults\n );\n }\n }\n const op = options || {};\n const requestInfo = requestsList(\n ref.storage,\n ref._location,\n /*delimiter= */ '/',\n op.pageToken,\n op.maxResults\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - StorageReference to get metadata from.\n */\nexport function getMetadata(ref: Reference): Promise<Metadata> {\n ref._throwIfRoot('getMetadata');\n const requestInfo = requestsGetMetadata(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - StorageReference to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves\n * with the new metadata for this object.\n * See `firebaseStorage.Reference.prototype.getMetadata`\n */\nexport function updateMetadata(\n ref: Reference,\n metadata: Partial<Metadata>\n): Promise<Metadata> {\n ref._throwIfRoot('updateMetadata');\n const requestInfo = requestsUpdateMetadata(\n ref.storage,\n ref._location,\n metadata,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns the download URL for the given Reference.\n * @public\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: Reference): Promise<string> {\n ref._throwIfRoot('getDownloadURL');\n const requestInfo = requestsGetDownloadUrl(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(url => {\n if (url === null) {\n throw noDownloadURL();\n }\n return url;\n });\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - StorageReference for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: Reference): Promise<void> {\n ref._throwIfRoot('deleteObject');\n const requestInfo = requestsDeleteObject(ref.storage, ref._location);\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns reference for object obtained by appending `childPath` to `ref`.\n *\n * @param ref - StorageReference to get child of.\n * @param childPath - Child path from provided ref.\n * @returns A reference to the object obtained by\n * appending childPath, removing any duplicate, beginning, or trailing\n * slashes.\n *\n */\nexport function _getChild(ref: Reference, childPath: string): Reference {\n const newPath = child(ref._location.path, childPath);\n const location = new Location(ref._location.bucket, newPath);\n return new Reference(ref.storage, location);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Location } from './implementation/location';\nimport { FailRequest } from './implementation/failrequest';\nimport { Request, makeRequest } from './implementation/request';\nimport { RequestInfo } from './implementation/requestinfo';\nimport { Reference, _getChild } from './reference';\nimport { Provider } from '@firebase/component';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n FirebaseApp,\n FirebaseOptions,\n _isFirebaseServerApp\n} from '@firebase/app';\nimport {\n CONFIG_STORAGE_BUCKET_KEY,\n DEFAULT_HOST,\n DEFAULT_MAX_OPERATION_RETRY_TIME,\n DEFAULT_MAX_UPLOAD_RETRY_TIME\n} from './implementation/constants';\nimport {\n invalidArgument,\n appDeleted,\n noDefaultBucket\n} from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport { FirebaseStorage } from './public-types';\nimport {\n createMockUserToken,\n EmulatorMockTokenOptions,\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\nimport { Connection, ConnectionType } from './implementation/connection';\n\nexport function isUrl(path?: string): boolean {\n return /^[A-Za-z]+:\\/\\//.test(path as string);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given url.\n */\nfunction refFromURL(service: FirebaseStorageImpl, url: string): Reference {\n return new Reference(service, url);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given path in the default\n * bucket.\n */\nfunction refFromPath(\n ref: FirebaseStorageImpl | Reference,\n path?: string\n): Reference {\n if (ref instanceof FirebaseStorageImpl) {\n const service = ref;\n if (service._bucket == null) {\n throw noDefaultBucket();\n }\n const reference = new Reference(service, service._bucket!);\n if (path != null) {\n return refFromPath(reference, path);\n } else {\n return reference;\n }\n } else {\n // ref is a Reference\n if (path !== undefined) {\n return _getChild(ref, path);\n } else {\n return ref;\n }\n }\n}\n\n/**\n * Returns a storage Reference for the given url.\n * @param storage - `Storage` instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorageImpl, url?: string): Reference;\n/**\n * Returns a storage Reference for the given path in the\n * default bucket.\n * @param storageOrRef - `Storage` service or storage `Reference`.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage\n * instance provided) or returns same reference (if Reference provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorageImpl | Reference,\n path?: string\n): Reference;\nexport function ref(\n serviceOrRef: FirebaseStorageImpl | Reference,\n pathOrUrl?: string\n): Reference | null {\n if (pathOrUrl && isUrl(pathOrUrl)) {\n if (serviceOrRef instanceof FirebaseStorageImpl) {\n return refFromURL(serviceOrRef, pathOrUrl);\n } else {\n throw invalidArgument(\n 'To use ref(service, url), the first argument must be a Storage instance.'\n );\n }\n } else {\n return refFromPath(serviceOrRef, pathOrUrl);\n }\n}\n\nfunction extractBucket(\n host: string,\n config?: FirebaseOptions\n): Location | null {\n const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY];\n if (bucketString == null) {\n return null;\n }\n return Location.makeFromBucketSpec(bucketString, host);\n}\n\nexport function connectStorageEmulator(\n storage: FirebaseStorageImpl,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n storage.host = `${host}:${port}`;\n const useSsl = isCloudWorkstation(host);\n // Workaround to get cookies in Firebase Studio\n if (useSsl) {\n void pingServer(`https://${storage.host}/b`);\n updateEmulatorBanner('Storage', true);\n }\n storage._isUsingEmulator = true;\n storage._protocol = useSsl ? 'https' : 'http';\n const { mockUserToken } = options;\n if (mockUserToken) {\n storage._overrideAuthToken =\n typeof mockUserToken === 'string'\n ? mockUserToken\n : createMockUserToken(mockUserToken, storage.app.options.projectId);\n }\n}\n\n/**\n * A service that provides Firebase Storage Reference instances.\n * @param opt_url - gs:// url to a custom Storage Bucket\n *\n * @internal\n */\nexport class FirebaseStorageImpl implements FirebaseStorage {\n _bucket: Location | null = null;\n /**\n * This string can be in the formats:\n * - host\n * - host:port\n */\n private _host: string = DEFAULT_HOST;\n _protocol: string = 'https';\n protected readonly _appId: string | null = null;\n private readonly _requests: Set<Request<unknown>>;\n private _deleted: boolean = false;\n private _maxOperationRetryTime: number;\n private _maxUploadRetryTime: number;\n _overrideAuthToken?: string;\n\n constructor(\n /**\n * FirebaseApp associated with this StorageService instance.\n */\n readonly app: FirebaseApp,\n readonly _authProvider: Provider<FirebaseAuthInternalName>,\n /**\n * @internal\n */\n readonly _appCheckProvider: Provider<AppCheckInternalComponentName>,\n /**\n * @internal\n */\n readonly _url?: string,\n readonly _firebaseVersion?: string,\n public _isUsingEmulator = false\n ) {\n this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;\n this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;\n this._requests = new Set();\n if (_url != null) {\n this._bucket = Location.makeFromBucketSpec(_url, this._host);\n } else {\n this._bucket = extractBucket(this._host, this.app.options);\n }\n }\n\n /**\n * The host string for this service, in the form of `host` or\n * `host:port`.\n */\n get host(): string {\n return this._host;\n }\n\n set host(host: string) {\n this._host = host;\n if (this._url != null) {\n this._bucket = Location.makeFromBucketSpec(this._url, host);\n } else {\n this._bucket = extractBucket(host, this.app.options);\n }\n }\n\n /**\n * The maximum time to retry uploads in milliseconds.\n */\n get maxUploadRetryTime(): number {\n return this._maxUploadRetryTime;\n }\n\n set maxUploadRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxUploadRetryTime = time;\n }\n\n /**\n * The maximum time to retry operations other than uploads or downloads in\n * milliseconds.\n */\n get maxOperationRetryTime(): number {\n return this._maxOperationRetryTime;\n }\n\n set maxOperationRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxOperationRetryTime = time;\n }\n\n async _getAuthToken(): Promise<string | null> {\n if (this._overrideAuthToken) {\n return this._overrideAuthToken;\n }\n const auth = this._authProvider.getImmediate({ optional: true });\n if (auth) {\n const tokenData = await auth.getToken();\n if (tokenData !== null) {\n return tokenData.accessToken;\n }\n }\n return null;\n }\n\n async _getAppCheckToken(): Promise<string | null> {\n if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) {\n return this.app.settings.appCheckToken;\n }\n const appCheck = this._appCheckProvider.getImmediate({ optional: true });\n if (appCheck) {\n const result = await appCheck.getToken();\n // TODO: What do we want to do if there is an error getting the token?\n // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be\n // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use\n // the token (actual or dummy) to send requests.\n return result.token;\n }\n return null;\n }\n\n /**\n * Stop running requests and prevent more from being created.\n */\n _delete(): Promise<void> {\n if (!this._deleted) {\n this._deleted = true;\n this._requests.forEach(request => request.cancel());\n this._requests.clear();\n }\n return Promise.resolve();\n }\n\n /**\n * Returns a new firebaseStorage.Reference object referencing this StorageService\n * at the given Location.\n */\n _makeStorageReference(loc: Location): Reference {\n return new Reference(this, loc);\n }\n\n /**\n * @param requestInfo - HTTP RequestInfo object\n * @param authToken - Firebase auth token\n */\n _makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>,\n authToken: string | null,\n appCheckToken: string | null,\n retry = true\n ): Request<O> {\n if (!this._deleted) {\n const request = makeRequest(\n requestInfo,\n this._appId,\n authToken,\n appCheckToken,\n requestFactory,\n this._firebaseVersion,\n retry,\n this._isUsingEmulator\n );\n this._requests.add(request);\n // Request removes itself from set when complete.\n request.getPromise().then(\n () => this._requests.delete(request),\n () => this._requests.delete(request)\n );\n return request;\n } else {\n return new FailRequest(appDeleted());\n }\n }\n\n async makeRequestWithTokens<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>\n ): Promise<O> {\n const [authToken, appCheckToken] = await Promise.all([\n this._getAuthToken(),\n this._getAppCheckToken()\n ]);\n\n return this._makeRequest(\n requestInfo,\n requestFactory,\n authToken,\n appCheckToken\n ).getPromise();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Type constant for Firebase Storage.\n */\nexport const STORAGE_TYPE = 'storage';\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { _getProvider, FirebaseApp, getApp } from '@firebase/app';\n\nimport {\n ref as refInternal,\n FirebaseStorageImpl,\n connectStorageEmulator as connectEmulatorInternal\n} from './service';\nimport { Provider } from '@firebase/component';\n\nimport {\n StorageReference,\n FirebaseStorage,\n UploadResult,\n ListOptions,\n ListResult,\n UploadTask,\n SettableMetadata,\n UploadMetadata,\n FullMetadata\n} from './public-types';\nimport { Metadata as MetadataInternal } from './metadata';\nimport {\n uploadBytes as uploadBytesInternal,\n uploadBytesResumable as uploadBytesResumableInternal,\n uploadString as uploadStringInternal,\n getMetadata as getMetadataInternal,\n updateMetadata as updateMetadataInternal,\n list as listInternal,\n listAll as listAllInternal,\n getDownloadURL as getDownloadURLInternal,\n deleteObject as deleteObjectInternal,\n Reference,\n _getChild as _getChildInternal,\n getBytesInternal\n} from './reference';\nimport { STORAGE_TYPE } from './constants';\nimport {\n EmulatorMockTokenOptions,\n getModularInstance,\n getDefaultEmulatorHostnameAndPort\n} from '@firebase/util';\nimport { StringFormat } from './implementation/string';\n\nexport { EmulatorMockTokenOptions } from '@firebase/util';\n\nexport { StorageError, StorageErrorCode } from './implementation/error';\n\n/**\n * Public types.\n */\nexport * from './public-types';\n\nexport { Location as _Location } from './implementation/location';\nexport { UploadTask as _UploadTask } from './task';\nexport type { Reference as _Reference } from './reference';\nexport type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';\nexport { FbsBlob as _FbsBlob } from './implementation/blob';\nexport { dataFromString as _dataFromString } from './implementation/string';\nexport {\n invalidRootOperation as _invalidRootOperation,\n invalidArgument as _invalidArgument\n} from './implementation/error';\nexport {\n TaskEvent as _TaskEvent,\n TaskState as _TaskState\n} from './implementation/taskenums';\nexport { StringFormat };\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise containing the object's bytes\n */\nexport function getBytes(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref = getModularInstance(ref);\n return getBytesInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadBytesInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the string to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: StorageReference,\n value: string,\n format?: StringFormat,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadStringInternal(\n ref as Reference,\n value,\n format,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): UploadTask {\n ref = getModularInstance(ref);\n return uploadBytesResumableInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n ) as UploadTask;\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - {@link StorageReference} to get metadata from.\n */\nexport function getMetadata(ref: StorageReference): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return getMetadataInternal(ref as Reference) as Promise<FullMetadata>;\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - {@link StorageReference} to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves with the new metadata for this object.\n */\nexport function updateMetadata(\n ref: StorageReference,\n metadata: SettableMetadata\n): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return updateMetadataInternal(\n ref as Reference,\n metadata as Partial<MetadataInternal>\n ) as Promise<FullMetadata>;\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - {@link StorageReference} to get list from.\n * @param options - See {@link ListOptions} for details.\n * @returns A `Promise` that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: StorageReference,\n options?: ListOptions\n): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listInternal(ref as Reference, options);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: `listAll` may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - {@link StorageReference} to get list from.\n *\n * @returns A `Promise` that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: StorageReference): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listAllInternal(ref as Reference);\n}\n\n/**\n * Returns the download URL for the given {@link StorageReference}.\n * @public\n * @param ref - {@link StorageReference} to get the download URL for.\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: StorageReference): Promise<string> {\n ref = getModularInstance(ref);\n return getDownloadURLInternal(ref as Reference);\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - {@link StorageReference} for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: StorageReference): Promise<void> {\n ref = getModularInstance(ref);\n return deleteObjectInternal(ref as Reference);\n}\n\n/**\n * Returns a {@link StorageReference} for the given url.\n * @param storage - {@link FirebaseStorage} instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorage, url?: string): StorageReference;\n/**\n * Returns a {@link StorageReference} for the given path in the\n * default bucket.\n * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}\n * instance provided) or returns same reference (if {@link StorageReference} provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorage | StorageReference,\n path?: string\n): StorageReference;\nexport function ref(\n serviceOrRef: FirebaseStorage | StorageReference,\n pathOrUrl?: string\n): StorageReference | null {\n serviceOrRef = getModularInstance(serviceOrRef);\n return refInternal(\n serviceOrRef as FirebaseStorageImpl | Reference,\n pathOrUrl\n );\n}\n\n/**\n * @internal\n */\nexport function _getChild(ref: StorageReference, childPath: string): Reference {\n return _getChildInternal(ref as Reference, childPath);\n}\n\n/**\n * Gets a {@link FirebaseStorage} instance for the given Firebase app.\n * @public\n * @param app - Firebase app to get {@link FirebaseStorage} instance for.\n * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.\n * If not passed, uses the app's default Storage Bucket.\n * @returns A {@link FirebaseStorage} instance.\n */\nexport function getStorage(\n app: FirebaseApp = getApp(),\n bucketUrl?: string\n): FirebaseStorage {\n app = getModularInstance(app);\n const storageProvider: Provider<'storage'> = _getProvider(app, STORAGE_TYPE);\n const storageInstance = storageProvider.getImmediate({\n identifier: bucketUrl\n });\n const emulator = getDefaultEmulatorHostnameAndPort('storage');\n if (emulator) {\n connectStorageEmulator(storageInstance, ...emulator);\n }\n return storageInstance;\n}\n\n/**\n * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.\n *\n * @param storage - The {@link FirebaseStorage} instance\n * @param host - The emulator host (ex: localhost)\n * @param port - The emulator port (ex: 5001)\n * @param options - Emulator options. `options.mockUserToken` is the mock auth\n * token to use for unit testing Security Rules.\n * @public\n */\nexport function connectStorageEmulator(\n storage: FirebaseStorage,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n connectEmulatorInternal(storage as FirebaseStorageImpl, host, port, options);\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StorageReference } from './public-types';\nimport { Reference, getBlobInternal } from './reference';\nimport { getModularInstance } from '@firebase/util';\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * This API is not available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise that resolves with a Blob containing the object's bytes\n */\nexport function getBlob(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref = getModularInstance(ref);\n return getBlobInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Downloads the data at the object's location. Raises an error event if the\n * object is not found.\n *\n * This API is only available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A stream with the object's data as bytes\n */\nexport function getStream(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n throw new Error('getStream() is only supported by NodeJS builds');\n}\n","/**\n * Cloud Storage for Firebase\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n _registerComponent,\n registerVersion,\n SDK_VERSION\n} from '@firebase/app';\n\nimport { FirebaseStorageImpl } from '../src/service';\nimport {\n Component,\n ComponentType,\n ComponentContainer,\n InstanceFactoryOptions\n} from '@firebase/component';\n\nimport { name, version } from '../package.json';\n\nimport { FirebaseStorage } from './public-types';\nimport { STORAGE_TYPE } from './constants';\n\nexport * from './api';\nexport * from './api.browser';\n\nfunction factory(\n container: ComponentContainer,\n { instanceIdentifier: url }: InstanceFactoryOptions\n): FirebaseStorage {\n const app = container.getProvider('app').getImmediate();\n const authProvider = container.getProvider('auth-internal');\n const appCheckProvider = container.getProvider('app-check-internal');\n\n return new FirebaseStorageImpl(\n app,\n authProvider,\n appCheckProvider,\n url,\n SDK_VERSION\n );\n}\n\nfunction registerStorage(): void {\n _registerComponent(\n new Component(\n STORAGE_TYPE,\n factory,\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n //RUNTIME_ENV will be replaced during the compilation to \"node\" for nodejs and an empty string for browser\n registerVersion(name, version, '__RUNTIME_ENV__');\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\nregisterStorage();\n"],"names":["FirebaseError","StorageErrorCode","getBlob","getMetadata","list","getBytes","updateMetadata","deleteObject","isCloudWorkstation","fbsAsync","uploadBytes","uploadBytesResumable","uploadString","listAll","requestsList","requestsGetMetadata","requestsUpdateMetadata","getDownloadURL","requestsGetDownloadUrl","requestsDeleteObject","_getChild","ref","connectStorageEmulator","pingServer","updateEmulatorBanner","createMockUserToken","_isFirebaseServerApp","getModularInstance","uploadBytesInternal","uploadStringInternal","uploadBytesResumableInternal","getMetadataInternal","updateMetadataInternal","listInternal","listAllInternal","getDownloadURLInternal","deleteObjectInternal","refInternal","_getChildInternal","app","getApp","_getProvider","getDefaultEmulatorHostnameAndPort","connectEmulatorInternal","SDK_VERSION","_registerComponent","Component","registerVersion"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AACH;;AAEG;AAEH;;AAEG;AACI,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAE7D;;AAEG;AACI,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAEzD;;;;AAIG;AACI,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9D;;;;AAIG;AACI,MAAM,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5D;;AAEG;AACI,MAAM,6BAA6B,GAAG,IAAI;;AC/CjD;;;;;;;;;;;;;;;AAeG;AAMH;;;AAGG;AACG,MAAO,YAAa,SAAQA,kBAAa,CAAA;AAO7C;;;;;AAKG;AACH,IAAA,WAAA,CAAY,IAAsB,EAAE,OAAe,EAAU,UAAU,CAAC,EAAA;AACtE,QAAA,KAAK,CACH,WAAW,CAAC,IAAI,CAAC,EACjB,CAAA,kBAAA,EAAqB,OAAO,CAAA,EAAA,EAAK,WAAW,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG,CACtD,CAAC;QAJyD,IAAO,CAAA,OAAA,GAAP,OAAO,CAAI;AAXxE;;AAEG;AACH,QAAA,IAAA,CAAA,UAAU,GAAsC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;AAavE,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;;;QAGjC,MAAM,CAAC,cAAc,CAAC,IAAI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;;;;;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.cjs.js b/frontend-old/node_modules/@firebase/storage/dist/index.cjs.js deleted file mode 100644 index 4418bd0..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.cjs.js +++ /dev/null @@ -1,3685 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var app = require('@firebase/app'); -var util = require('@firebase/util'); -var component = require('@firebase/component'); - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -const DEFAULT_HOST = 'firebasestorage.googleapis.com'; -/** - * The key in Firebase config json for the storage bucket. - */ -const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket'; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000; -/** - * 10 minutes - * - * The timeout for upload. - */ -const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000; -/** - * 1 second - */ -const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -class StorageError extends util.FirebaseError { - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code, message, status_ = 0) { - super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`); - this.status_ = status_; - /** - * Stores custom error data unique to the `StorageError`. - */ - this.customData = { serverResponse: null }; - this._baseMessage = this.message; - // Without this, `instanceof StorageError`, in tests for example, - // returns false. - Object.setPrototypeOf(this, StorageError.prototype); - } - get status() { - return this.status_; - } - set status(status) { - this.status_ = status; - } - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code) { - return prependCode(code) === this.code; - } - /** - * Optional response message that was added by the server. - */ - get serverResponse() { - return this.customData.serverResponse; - } - set serverResponse(serverResponse) { - this.customData.serverResponse = serverResponse; - if (this.customData.serverResponse) { - this.message = `${this._baseMessage}\n${this.customData.serverResponse}`; - } - else { - this.message = this._baseMessage; - } - } -} -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -exports.StorageErrorCode = void 0; -(function (StorageErrorCode) { - // Shared between all platforms - StorageErrorCode["UNKNOWN"] = "unknown"; - StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found"; - StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found"; - StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found"; - StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded"; - StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated"; - StorageErrorCode["UNAUTHORIZED"] = "unauthorized"; - StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app"; - StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded"; - StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum"; - StorageErrorCode["CANCELED"] = "canceled"; - // JS specific - StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name"; - StorageErrorCode["INVALID_URL"] = "invalid-url"; - StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket"; - StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket"; - StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob"; - StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size"; - StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url"; - StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument"; - StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count"; - StorageErrorCode["APP_DELETED"] = "app-deleted"; - StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation"; - StorageErrorCode["INVALID_FORMAT"] = "invalid-format"; - StorageErrorCode["INTERNAL_ERROR"] = "internal-error"; - StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment"; -})(exports.StorageErrorCode || (exports.StorageErrorCode = {})); -function prependCode(code) { - return 'storage/' + code; -} -function unknown() { - const message = 'An unknown error occurred, please check the error payload for ' + - 'server response.'; - return new StorageError(exports.StorageErrorCode.UNKNOWN, message); -} -function objectNotFound(path) { - return new StorageError(exports.StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist."); -} -function quotaExceeded(bucket) { - return new StorageError(exports.StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + - bucket + - "' exceeded, please view quota on " + - 'https://firebase.google.com/pricing/.'); -} -function unauthenticated() { - const message = 'User is not authenticated, please authenticate using Firebase ' + - 'Authentication and try again.'; - return new StorageError(exports.StorageErrorCode.UNAUTHENTICATED, message); -} -function unauthorizedApp() { - return new StorageError(exports.StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.'); -} -function unauthorized(path) { - return new StorageError(exports.StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'."); -} -function retryLimitExceeded() { - return new StorageError(exports.StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.'); -} -function canceled() { - return new StorageError(exports.StorageErrorCode.CANCELED, 'User canceled the upload/download.'); -} -function invalidUrl(url) { - return new StorageError(exports.StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'."); -} -function invalidDefaultBucket(bucket) { - return new StorageError(exports.StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'."); -} -function noDefaultBucket() { - return new StorageError(exports.StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' + - "found. Did you set the '" + - CONFIG_STORAGE_BUCKET_KEY + - "' property when initializing the app?"); -} -function cannotSliceBlob() { - return new StorageError(exports.StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.'); -} -function serverFileWrongSize() { - return new StorageError(exports.StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.'); -} -function noDownloadURL() { - return new StorageError(exports.StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.'); -} -function missingPolyFill(polyFill) { - return new StorageError(exports.StorageErrorCode.UNSUPPORTED_ENVIRONMENT, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`); -} -/** - * @internal - */ -function invalidArgument(message) { - return new StorageError(exports.StorageErrorCode.INVALID_ARGUMENT, message); -} -function appDeleted() { - return new StorageError(exports.StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.'); -} -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -function invalidRootOperation(name) { - return new StorageError(exports.StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + - name + - "' cannot be performed on a root reference, create a non-root " + - "reference using child, such as .child('file.png')."); -} -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -function invalidFormat(format, message) { - return new StorageError(exports.StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message); -} -/** - * @param message - A message describing the internal error. - */ -function internalError(message) { - throw new StorageError(exports.StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -class Location { - constructor(bucket, path) { - this.bucket = bucket; - this.path_ = path; - } - get path() { - return this.path_; - } - get isRoot() { - return this.path.length === 0; - } - fullServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o/' + encode(this.path); - } - bucketOnlyServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o'; - } - static makeFromBucketSpec(bucketString, host) { - let bucketLocation; - try { - bucketLocation = Location.makeFromUrl(bucketString, host); - } - catch (e) { - // Not valid URL, use as-is. This lets you put bare bucket names in - // config. - return new Location(bucketString, ''); - } - if (bucketLocation.path === '') { - return bucketLocation; - } - else { - throw invalidDefaultBucket(bucketString); - } - } - static makeFromUrl(url, host) { - let location = null; - const bucketDomain = '([A-Za-z0-9.\\-_]+)'; - function gsModify(loc) { - if (loc.path.charAt(loc.path.length - 1) === '/') { - loc.path_ = loc.path_.slice(0, -1); - } - } - const gsPath = '(/(.*))?$'; - const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i'); - const gsIndices = { bucket: 1, path: 3 }; - function httpModify(loc) { - loc.path_ = decodeURIComponent(loc.path); - } - const version = 'v[A-Za-z0-9_]+'; - const firebaseStorageHost = host.replace(/[.]/g, '\\.'); - const firebaseStoragePath = '(/([^?#]*).*)?$'; - const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`, 'i'); - const firebaseStorageIndices = { bucket: 1, path: 3 }; - const cloudStorageHost = host === DEFAULT_HOST - ? '(?:storage.googleapis.com|storage.cloud.google.com)' - : host; - const cloudStoragePath = '([^?#]*)'; - const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, 'i'); - const cloudStorageIndices = { bucket: 1, path: 2 }; - const groups = [ - { regex: gsRegex, indices: gsIndices, postModify: gsModify }, - { - regex: firebaseStorageRegExp, - indices: firebaseStorageIndices, - postModify: httpModify - }, - { - regex: cloudStorageRegExp, - indices: cloudStorageIndices, - postModify: httpModify - } - ]; - for (let i = 0; i < groups.length; i++) { - const group = groups[i]; - const captures = group.regex.exec(url); - if (captures) { - const bucketValue = captures[group.indices.bucket]; - let pathValue = captures[group.indices.path]; - if (!pathValue) { - pathValue = ''; - } - location = new Location(bucketValue, pathValue); - group.postModify(location); - break; - } - } - if (location == null) { - throw invalidUrl(url); - } - return location; - } -} - -/** - * A request whose promise always fails. - */ -class FailRequest { - constructor(error) { - this.promise_ = Promise.reject(error); - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(_appDelete = false) { } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -function start(doRequest, -// eslint-disable-next-line @typescript-eslint/no-explicit-any -backoffCompleteCb, timeout) { - // TODO(andysoto): make this code cleaner (probably refactor into an actual - // type instead of a bunch of functions with state shared in the closure) - let waitSeconds = 1; - // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯ - // TODO: find a way to exclude Node type definition for storage because storage only works in browser - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let retryTimeoutId = null; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let globalTimeoutId = null; - let hitTimeout = false; - let cancelState = 0; - function canceled() { - return cancelState === 2; - } - let triggeredCallback = false; - function triggerCallback(...args) { - if (!triggeredCallback) { - triggeredCallback = true; - backoffCompleteCb.apply(null, args); - } - } - function callWithDelay(millis) { - retryTimeoutId = setTimeout(() => { - retryTimeoutId = null; - doRequest(responseHandler, canceled()); - }, millis); - } - function clearGlobalTimeout() { - if (globalTimeoutId) { - clearTimeout(globalTimeoutId); - } - } - function responseHandler(success, ...args) { - if (triggeredCallback) { - clearGlobalTimeout(); - return; - } - if (success) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - const mustStop = canceled() || hitTimeout; - if (mustStop) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - if (waitSeconds < 64) { - /* TODO(andysoto): don't back off so quickly if we know we're offline. */ - waitSeconds *= 2; - } - let waitMillis; - if (cancelState === 1) { - cancelState = 2; - waitMillis = 0; - } - else { - waitMillis = (waitSeconds + Math.random()) * 1000; - } - callWithDelay(waitMillis); - } - let stopped = false; - function stop(wasTimeout) { - if (stopped) { - return; - } - stopped = true; - clearGlobalTimeout(); - if (triggeredCallback) { - return; - } - if (retryTimeoutId !== null) { - if (!wasTimeout) { - cancelState = 2; - } - clearTimeout(retryTimeoutId); - callWithDelay(0); - } - else { - if (!wasTimeout) { - cancelState = 1; - } - } - } - callWithDelay(0); - globalTimeoutId = setTimeout(() => { - hitTimeout = true; - stop(true); - }, timeout); - return stop; -} -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -function stop(id) { - id(false); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isJustDef(p) { - return p !== void 0; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function isFunction(p) { - return typeof p === 'function'; -} -function isNonArrayObject(p) { - return typeof p === 'object' && !Array.isArray(p); -} -function isString(p) { - return typeof p === 'string' || p instanceof String; -} -function isNativeBlob(p) { - return isNativeBlobDefined() && p instanceof Blob; -} -function isNativeBlobDefined() { - return typeof Blob !== 'undefined'; -} -function validateNumber(argument, minValue, maxValue, value) { - if (value < minValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`); - } - if (value > maxValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function makeUrl(urlPart, host, protocol) { - let origin = host; - if (protocol == null) { - origin = `https://${host}`; - } - return `${protocol}://${origin}/v0${urlPart}`; -} -function makeQueryString(params) { - const encode = encodeURIComponent; - let queryPart = '?'; - for (const key in params) { - if (params.hasOwnProperty(key)) { - const nextPart = encode(key) + '=' + encode(params[key]); - queryPart = queryPart + nextPart + '&'; - } - } - // Chop off the extra '&' or '?' on the end - queryPart = queryPart.slice(0, -1); - return queryPart; -} - -/** - * Error codes for requests made by the XhrIo wrapper. - */ -var ErrorCode; -(function (ErrorCode) { - ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR"; - ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR"; - ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT"; -})(ErrorCode || (ErrorCode = {})); - -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -function isRetryStatusCode(status, additionalRetryCodes) { - // The codes for which to retry came from this page: - // https://cloud.google.com/storage/docs/exponential-backoff - const isFiveHundredCode = status >= 500 && status < 600; - const extraRetryCodes = [ - // Request Timeout: web server didn't receive full request in time. - 408, - // Too Many Requests: you're getting rate-limited, basically. - 429 - ]; - const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1; - const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1; - return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Handles network logic for all Storage Requests, including error reporting and - * retries with backoff. - * - * @param I - the type of the backend's network response. - * @param - O the output type used by the rest of the SDK. The conversion - * happens in the specified `callback_`. - */ -class NetworkRequest { - constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) { - this.url_ = url_; - this.method_ = method_; - this.headers_ = headers_; - this.body_ = body_; - this.successCodes_ = successCodes_; - this.additionalRetryCodes_ = additionalRetryCodes_; - this.callback_ = callback_; - this.errorCallback_ = errorCallback_; - this.timeout_ = timeout_; - this.progressCallback_ = progressCallback_; - this.connectionFactory_ = connectionFactory_; - this.retry = retry; - this.isUsingEmulator = isUsingEmulator; - this.pendingConnection_ = null; - this.backoffId_ = null; - this.canceled_ = false; - this.appDelete_ = false; - this.promise_ = new Promise((resolve, reject) => { - this.resolve_ = resolve; - this.reject_ = reject; - this.start_(); - }); - } - /** - * Actually starts the retry loop. - */ - start_() { - const doTheRequest = (backoffCallback, canceled) => { - if (canceled) { - backoffCallback(false, new RequestEndStatus(false, null, true)); - return; - } - const connection = this.connectionFactory_(); - this.pendingConnection_ = connection; - const progressListener = progressEvent => { - const loaded = progressEvent.loaded; - const total = progressEvent.lengthComputable ? progressEvent.total : -1; - if (this.progressCallback_ !== null) { - this.progressCallback_(loaded, total); - } - }; - if (this.progressCallback_ !== null) { - connection.addUploadProgressListener(progressListener); - } - // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - connection - .send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_) - .then(() => { - if (this.progressCallback_ !== null) { - connection.removeUploadProgressListener(progressListener); - } - this.pendingConnection_ = null; - const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR; - const status = connection.getStatus(); - if (!hitServer || - (isRetryStatusCode(status, this.additionalRetryCodes_) && - this.retry)) { - const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT; - backoffCallback(false, new RequestEndStatus(false, null, wasCanceled)); - return; - } - const successCode = this.successCodes_.indexOf(status) !== -1; - backoffCallback(true, new RequestEndStatus(successCode, connection)); - }); - }; - /** - * @param requestWentThrough - True if the request eventually went - * through, false if it hit the retry limit or was canceled. - */ - const backoffDone = (requestWentThrough, status) => { - const resolve = this.resolve_; - const reject = this.reject_; - const connection = status.connection; - if (status.wasSuccessCode) { - try { - const result = this.callback_(connection, connection.getResponse()); - if (isJustDef(result)) { - resolve(result); - } - else { - resolve(); - } - } - catch (e) { - reject(e); - } - } - else { - if (connection !== null) { - const err = unknown(); - err.serverResponse = connection.getErrorText(); - if (this.errorCallback_) { - reject(this.errorCallback_(connection, err)); - } - else { - reject(err); - } - } - else { - if (status.canceled) { - const err = this.appDelete_ ? appDeleted() : canceled(); - reject(err); - } - else { - const err = retryLimitExceeded(); - reject(err); - } - } - } - }; - if (this.canceled_) { - backoffDone(false, new RequestEndStatus(false, null, true)); - } - else { - this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_); - } - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(appDelete) { - this.canceled_ = true; - this.appDelete_ = appDelete || false; - if (this.backoffId_ !== null) { - stop(this.backoffId_); - } - if (this.pendingConnection_ !== null) { - this.pendingConnection_.abort(); - } - } -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -class RequestEndStatus { - constructor(wasSuccessCode, connection, canceled) { - this.wasSuccessCode = wasSuccessCode; - this.connection = connection; - this.canceled = !!canceled; - } -} -function addAuthHeader_(headers, authToken) { - if (authToken !== null && authToken.length > 0) { - headers['Authorization'] = 'Firebase ' + authToken; - } -} -function addVersionHeader_(headers, firebaseVersion) { - headers['X-Firebase-Storage-Version'] = - 'webjs/' + (firebaseVersion ?? 'AppManager'); -} -function addGmpidHeader_(headers, appId) { - if (appId) { - headers['X-Firebase-GMPID'] = appId; - } -} -function addAppCheckHeader_(headers, appCheckToken) { - if (appCheckToken !== null) { - headers['X-Firebase-AppCheck'] = appCheckToken; - } -} -function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) { - const queryPart = makeQueryString(requestInfo.urlParams); - const url = requestInfo.url + queryPart; - const headers = Object.assign({}, requestInfo.headers); - addGmpidHeader_(headers, appId); - addAuthHeader_(headers, authToken); - addVersionHeader_(headers, firebaseVersion); - addAppCheckHeader_(headers, appCheckToken); - return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function getBlobBuilder() { - if (typeof BlobBuilder !== 'undefined') { - return BlobBuilder; - } - else if (typeof WebKitBlobBuilder !== 'undefined') { - return WebKitBlobBuilder; - } - else { - return undefined; - } -} -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -function getBlob$1(...args) { - const BlobBuilder = getBlobBuilder(); - if (BlobBuilder !== undefined) { - const bb = new BlobBuilder(); - for (let i = 0; i < args.length; i++) { - bb.append(args[i]); - } - return bb.getBlob(); - } - else { - if (isNativeBlobDefined()) { - return new Blob(args); - } - else { - throw new StorageError(exports.StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs"); - } - } -} -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -function sliceBlob(blob, start, end) { - if (blob.webkitSlice) { - return blob.webkitSlice(start, end); - } - else if (blob.mozSlice) { - return blob.mozSlice(start, end); - } - else if (blob.slice) { - return blob.slice(start, end); - } - return null; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -function decodeBase64(encoded) { - if (typeof atob === 'undefined') { - throw missingPolyFill('base-64'); - } - return atob(encoded); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -const StringFormat = { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - RAW: 'raw', - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64: 'base64', - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64URL: 'base64url', - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - DATA_URL: 'data_url' -}; -class StringData { - constructor(data, contentType) { - this.data = data; - this.contentType = contentType || null; - } -} -/** - * @internal - */ -function dataFromString(format, stringData) { - switch (format) { - case StringFormat.RAW: - return new StringData(utf8Bytes_(stringData)); - case StringFormat.BASE64: - case StringFormat.BASE64URL: - return new StringData(base64Bytes_(format, stringData)); - case StringFormat.DATA_URL: - return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData)); - // do nothing - } - // assert(false); - throw unknown(); -} -function utf8Bytes_(value) { - const b = []; - for (let i = 0; i < value.length; i++) { - let c = value.charCodeAt(i); - if (c <= 127) { - b.push(c); - } - else { - if (c <= 2047) { - b.push(192 | (c >> 6), 128 | (c & 63)); - } - else { - if ((c & 64512) === 55296) { - // The start of a surrogate pair. - const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320; - if (!valid) { - // The second surrogate wasn't there. - b.push(239, 191, 189); - } - else { - const hi = c; - const lo = value.charCodeAt(++i); - c = 65536 | ((hi & 1023) << 10) | (lo & 1023); - b.push(240 | (c >> 18), 128 | ((c >> 12) & 63), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - else { - if ((c & 64512) === 56320) { - // Invalid low surrogate. - b.push(239, 191, 189); - } - else { - b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - } - } - } - return new Uint8Array(b); -} -function percentEncodedBytes_(value) { - let decoded; - try { - decoded = decodeURIComponent(value); - } - catch (e) { - throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.'); - } - return utf8Bytes_(decoded); -} -function base64Bytes_(format, value) { - switch (format) { - case StringFormat.BASE64: { - const hasMinus = value.indexOf('-') !== -1; - const hasUnder = value.indexOf('_') !== -1; - if (hasMinus || hasUnder) { - const invalidChar = hasMinus ? '-' : '_'; - throw invalidFormat(format, "Invalid character '" + - invalidChar + - "' found: is it base64url encoded?"); - } - break; - } - case StringFormat.BASE64URL: { - const hasPlus = value.indexOf('+') !== -1; - const hasSlash = value.indexOf('/') !== -1; - if (hasPlus || hasSlash) { - const invalidChar = hasPlus ? '+' : '/'; - throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?"); - } - value = value.replace(/-/g, '+').replace(/_/g, '/'); - break; - } - // do nothing - } - let bytes; - try { - bytes = decodeBase64(value); - } - catch (e) { - if (e.message.includes('polyfill')) { - throw e; - } - throw invalidFormat(format, 'Invalid character found'); - } - const array = new Uint8Array(bytes.length); - for (let i = 0; i < bytes.length; i++) { - array[i] = bytes.charCodeAt(i); - } - return array; -} -class DataURLParts { - constructor(dataURL) { - this.base64 = false; - this.contentType = null; - const matches = dataURL.match(/^data:([^,]+)?,/); - if (matches === null) { - throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>"); - } - const middle = matches[1] || null; - if (middle != null) { - this.base64 = endsWith(middle, ';base64'); - this.contentType = this.base64 - ? middle.substring(0, middle.length - ';base64'.length) - : middle; - } - this.rest = dataURL.substring(dataURL.indexOf(',') + 1); - } -} -function dataURLBytes_(dataUrl) { - const parts = new DataURLParts(dataUrl); - if (parts.base64) { - return base64Bytes_(StringFormat.BASE64, parts.rest); - } - else { - return percentEncodedBytes_(parts.rest); - } -} -function dataURLContentType_(dataUrl) { - const parts = new DataURLParts(dataUrl); - return parts.contentType; -} -function endsWith(s, end) { - const longEnough = s.length >= end.length; - if (!longEnough) { - return false; - } - return s.substring(s.length - end.length) === end; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -class FbsBlob { - constructor(data, elideCopy) { - let size = 0; - let blobType = ''; - if (isNativeBlob(data)) { - this.data_ = data; - size = data.size; - blobType = data.type; - } - else if (data instanceof ArrayBuffer) { - if (elideCopy) { - this.data_ = new Uint8Array(data); - } - else { - this.data_ = new Uint8Array(data.byteLength); - this.data_.set(new Uint8Array(data)); - } - size = this.data_.length; - } - else if (data instanceof Uint8Array) { - if (elideCopy) { - this.data_ = data; - } - else { - this.data_ = new Uint8Array(data.length); - this.data_.set(data); - } - size = data.length; - } - this.size_ = size; - this.type_ = blobType; - } - size() { - return this.size_; - } - type() { - return this.type_; - } - slice(startByte, endByte) { - if (isNativeBlob(this.data_)) { - const realBlob = this.data_; - const sliced = sliceBlob(realBlob, startByte, endByte); - if (sliced === null) { - return null; - } - return new FbsBlob(sliced); - } - else { - const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte); - return new FbsBlob(slice, true); - } - } - static getBlob(...args) { - if (isNativeBlobDefined()) { - const blobby = args.map((val) => { - if (val instanceof FbsBlob) { - return val.data_; - } - else { - return val; - } - }); - return new FbsBlob(getBlob$1.apply(null, blobby)); - } - else { - const uint8Arrays = args.map((val) => { - if (isString(val)) { - return dataFromString(StringFormat.RAW, val).data; - } - else { - // Blobs don't exist, so this has to be a Uint8Array. - return val.data_; - } - }); - let finalLength = 0; - uint8Arrays.forEach((array) => { - finalLength += array.byteLength; - }); - const merged = new Uint8Array(finalLength); - let index = 0; - uint8Arrays.forEach((array) => { - for (let i = 0; i < array.length; i++) { - merged[index++] = array[i]; - } - }); - return new FbsBlob(merged, true); - } - } - uploadData() { - return this.data_; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -function jsonObjectOrNull(s) { - let obj; - try { - obj = JSON.parse(s); - } - catch (e) { - return null; - } - if (isNonArrayObject(obj)) { - return obj; - } - else { - return null; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -function parent(path) { - if (path.length === 0) { - return null; - } - const index = path.lastIndexOf('/'); - if (index === -1) { - return ''; - } - const newPath = path.slice(0, index); - return newPath; -} -function child(path, childPath) { - const canonicalChildPath = childPath - .split('/') - .filter(component => component.length > 0) - .join('/'); - if (path.length === 0) { - return canonicalChildPath; - } - else { - return path + '/' + canonicalChildPath; - } -} -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -function lastComponent(path) { - const index = path.lastIndexOf('/', path.length - 2); - if (index === -1) { - return path; - } - else { - return path.slice(index + 1); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function noXform_(metadata, value) { - return value; -} -class Mapping { - constructor(server, local, writable, xform) { - this.server = server; - this.local = local || server; - this.writable = !!writable; - this.xform = xform || noXform_; - } -} -let mappings_ = null; -function xformPath(fullPath) { - if (!isString(fullPath) || fullPath.length < 2) { - return fullPath; - } - else { - return lastComponent(fullPath); - } -} -function getMappings() { - if (mappings_) { - return mappings_; - } - const mappings = []; - mappings.push(new Mapping('bucket')); - mappings.push(new Mapping('generation')); - mappings.push(new Mapping('metageneration')); - mappings.push(new Mapping('name', 'fullPath', true)); - function mappingsXformPath(_metadata, fullPath) { - return xformPath(fullPath); - } - const nameMapping = new Mapping('name'); - nameMapping.xform = mappingsXformPath; - mappings.push(nameMapping); - /** - * Coerces the second param to a number, if it is defined. - */ - function xformSize(_metadata, size) { - if (size !== undefined) { - return Number(size); - } - else { - return size; - } - } - const sizeMapping = new Mapping('size'); - sizeMapping.xform = xformSize; - mappings.push(sizeMapping); - mappings.push(new Mapping('timeCreated')); - mappings.push(new Mapping('updated')); - mappings.push(new Mapping('md5Hash', null, true)); - mappings.push(new Mapping('cacheControl', null, true)); - mappings.push(new Mapping('contentDisposition', null, true)); - mappings.push(new Mapping('contentEncoding', null, true)); - mappings.push(new Mapping('contentLanguage', null, true)); - mappings.push(new Mapping('contentType', null, true)); - mappings.push(new Mapping('metadata', 'customMetadata', true)); - mappings_ = mappings; - return mappings_; -} -function addRef(metadata, service) { - function generateRef() { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const loc = new Location(bucket, path); - return service._makeStorageReference(loc); - } - Object.defineProperty(metadata, 'ref', { get: generateRef }); -} -function fromResource(service, resource, mappings) { - const metadata = {}; - metadata['type'] = 'file'; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]); - } - addRef(metadata, service); - return metadata; -} -function fromResourceString(service, resourceString, mappings) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromResource(service, resource, mappings); -} -function downloadUrlFromResourceString(metadata, resourceString, host, protocol) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - if (!isString(obj['downloadTokens'])) { - // This can happen if objects are uploaded through GCS and retrieved - // through list, so we don't want to throw an Error. - return null; - } - const tokens = obj['downloadTokens']; - if (tokens.length === 0) { - return null; - } - const encode = encodeURIComponent; - const tokensList = tokens.split(','); - const urls = tokensList.map((token) => { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path); - const base = makeUrl(urlPart, host, protocol); - const queryString = makeQueryString({ - alt: 'media', - token - }); - return base + queryString; - }); - return urls[0]; -} -function toResourceString(metadata, mappings) { - const resource = {}; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - if (mapping.writable) { - resource[mapping.server] = metadata[mapping.local]; - } - } - return JSON.stringify(resource); -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const PREFIXES_KEY = 'prefixes'; -const ITEMS_KEY = 'items'; -function fromBackendResponse(service, bucket, resource) { - const listResult = { - prefixes: [], - items: [], - nextPageToken: resource['nextPageToken'] - }; - if (resource[PREFIXES_KEY]) { - for (const path of resource[PREFIXES_KEY]) { - const pathWithoutTrailingSlash = path.replace(/\/$/, ''); - const reference = service._makeStorageReference(new Location(bucket, pathWithoutTrailingSlash)); - listResult.prefixes.push(reference); - } - } - if (resource[ITEMS_KEY]) { - for (const item of resource[ITEMS_KEY]) { - const reference = service._makeStorageReference(new Location(bucket, item['name'])); - listResult.items.push(reference); - } - } - return listResult; -} -function fromResponseString(service, bucket, resourceString) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromBackendResponse(service, bucket, resource); -} - -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -class RequestInfo { - constructor(url, method, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler, timeout) { - this.url = url; - this.method = method; - this.handler = handler; - this.timeout = timeout; - this.urlParams = {}; - this.headers = {}; - this.body = null; - this.errorHandler = null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - this.progressCallback = null; - this.successCodes = [200]; - this.additionalRetryCodes = []; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -function handlerCheck(cndn) { - if (!cndn) { - throw unknown(); - } -} -function metadataHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return metadata; - } - return handler; -} -function listHandler(service, bucket) { - function handler(xhr, text) { - const listResult = fromResponseString(service, bucket, text); - handlerCheck(listResult !== null); - return listResult; - } - return handler; -} -function downloadUrlHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return downloadUrlFromResourceString(metadata, text, service.host, service._protocol); - } - return handler; -} -function sharedErrorHandler(location) { - function errorHandler(xhr, err) { - let newErr; - if (xhr.getStatus() === 401) { - if ( - // This exact message string is the only consistent part of the - // server's error response that identifies it as an App Check error. - xhr.getErrorText().includes('Firebase App Check token is invalid')) { - newErr = unauthorizedApp(); - } - else { - newErr = unauthenticated(); - } - } - else { - if (xhr.getStatus() === 402) { - newErr = quotaExceeded(location.bucket); - } - else { - if (xhr.getStatus() === 403) { - newErr = unauthorized(location.path); - } - else { - newErr = err; - } - } - } - newErr.status = xhr.getStatus(); - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function objectErrorHandler(location) { - const shared = sharedErrorHandler(location); - function errorHandler(xhr, err) { - let newErr = shared(xhr, err); - if (xhr.getStatus() === 404) { - newErr = objectNotFound(location.path); - } - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function getMetadata$2(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function list$2(service, location, delimiter, pageToken, maxResults) { - const urlParams = {}; - if (location.isRoot) { - urlParams['prefix'] = ''; - } - else { - urlParams['prefix'] = location.path + '/'; - } - if (delimiter && delimiter.length > 0) { - urlParams['delimiter'] = delimiter; - } - if (pageToken) { - urlParams['pageToken'] = pageToken; - } - if (maxResults) { - urlParams['maxResults'] = maxResults; - } - const urlPart = location.bucketOnlyServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, listHandler(service, location.bucket), timeout); - requestInfo.urlParams = urlParams; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -function getBytes$1(service, location, maxDownloadSizeBytes) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media'; - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout); - requestInfo.errorHandler = objectErrorHandler(location); - if (maxDownloadSizeBytes !== undefined) { - requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`; - requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */]; - } - return requestInfo; -} -function getDownloadUrl(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function updateMetadata$2(service, location, metadata, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'PATCH'; - const body = toResourceString(metadata, mappings); - const headers = { 'Content-Type': 'application/json; charset=utf-8' }; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function deleteObject$2(service, location) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'DELETE'; - const timeout = service.maxOperationRetryTime; - function handler(_xhr, _text) { } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.successCodes = [200, 204]; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function determineContentType_(metadata, blob) { - return ((metadata && metadata['contentType']) || - (blob && blob.type()) || - 'application/octet-stream'); -} -function metadataForUpload_(location, blob, metadata) { - const metadataClone = Object.assign({}, metadata); - metadataClone['fullPath'] = location.path; - metadataClone['size'] = blob.size(); - if (!metadataClone['contentType']) { - metadataClone['contentType'] = determineContentType_(null, blob); - } - return metadataClone; -} -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -function multipartUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const headers = { - 'X-Goog-Upload-Protocol': 'multipart' - }; - function genBoundary() { - let str = ''; - for (let i = 0; i < 2; i++) { - str = str + Math.random().toString().slice(2); - } - return str; - } - const boundary = genBoundary(); - headers['Content-Type'] = 'multipart/related; boundary=' + boundary; - const metadata_ = metadataForUpload_(location, blob, metadata); - const metadataString = toResourceString(metadata_, mappings); - const preBlobPart = '--' + - boundary + - '\r\n' + - 'Content-Type: application/json; charset=utf-8\r\n\r\n' + - metadataString + - '\r\n--' + - boundary + - '\r\n' + - 'Content-Type: ' + - metadata_['contentType'] + - '\r\n\r\n'; - const postBlobPart = '\r\n--' + boundary + '--'; - const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart); - if (body === null) { - throw cannotSliceBlob(); - } - const urlParams = { name: metadata_['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -class ResumableUploadStatus { - constructor(current, total, finalized, metadata) { - this.current = current; - this.total = total; - this.finalized = !!finalized; - this.metadata = metadata || null; - } -} -function checkResumeHeader_(xhr, allowed) { - let status = null; - try { - status = xhr.getResponseHeader('X-Goog-Upload-Status'); - } - catch (e) { - handlerCheck(false); - } - const allowedStatus = allowed || ['active']; - handlerCheck(!!status && allowedStatus.indexOf(status) !== -1); - return status; -} -function createResumableUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const metadataForUpload = metadataForUpload_(location, blob, metadata); - const urlParams = { name: metadataForUpload['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const headers = { - 'X-Goog-Upload-Protocol': 'resumable', - 'X-Goog-Upload-Command': 'start', - 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`, - 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType'], - 'Content-Type': 'application/json; charset=utf-8' - }; - const body = toResourceString(metadataForUpload, mappings); - const timeout = service.maxUploadRetryTime; - function handler(xhr) { - checkResumeHeader_(xhr); - let url; - try { - url = xhr.getResponseHeader('X-Goog-Upload-URL'); - } - catch (e) { - handlerCheck(false); - } - handlerCheck(isString(url)); - return url; - } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -function getResumableUploadStatus(service, location, url, blob) { - const headers = { 'X-Goog-Upload-Command': 'query' }; - function handler(xhr) { - const status = checkResumeHeader_(xhr, ['active', 'final']); - let sizeString = null; - try { - sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received'); - } - catch (e) { - handlerCheck(false); - } - if (!sizeString) { - // null or empty string - handlerCheck(false); - } - const size = Number(sizeString); - handlerCheck(!isNaN(size)); - return new ResumableUploadStatus(size, blob.size(), status === 'final'); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -const RESUMABLE_UPLOAD_CHUNK_SIZE = 256 * 1024; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -function continueResumableUpload(location, service, url, blob, chunkSize, mappings, status, progressCallback) { - // TODO(andysoto): standardize on internal asserts - // assert(!(opt_status && opt_status.finalized)); - const status_ = new ResumableUploadStatus(0, 0); - if (status) { - status_.current = status.current; - status_.total = status.total; - } - else { - status_.current = 0; - status_.total = blob.size(); - } - if (blob.size() !== status_.total) { - throw serverFileWrongSize(); - } - const bytesLeft = status_.total - status_.current; - let bytesToUpload = bytesLeft; - if (chunkSize > 0) { - bytesToUpload = Math.min(bytesToUpload, chunkSize); - } - const startByte = status_.current; - const endByte = startByte + bytesToUpload; - let uploadCommand = ''; - if (bytesToUpload === 0) { - uploadCommand = 'finalize'; - } - else if (bytesLeft === bytesToUpload) { - uploadCommand = 'upload, finalize'; - } - else { - uploadCommand = 'upload'; - } - const headers = { - 'X-Goog-Upload-Command': uploadCommand, - 'X-Goog-Upload-Offset': `${status_.current}` - }; - const body = blob.slice(startByte, endByte); - if (body === null) { - throw cannotSliceBlob(); - } - function handler(xhr, text) { - // TODO(andysoto): Verify the MD5 of each uploaded range: - // the 'x-range-md5' header comes back with status code 308 responses. - // We'll only be able to bail out though, because you can't re-upload a - // range that you previously uploaded. - const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']); - const newCurrent = status_.current + bytesToUpload; - const size = blob.size(); - let metadata; - if (uploadStatus === 'final') { - metadata = metadataHandler(service, mappings)(xhr, text); - } - else { - metadata = null; - } - return new ResumableUploadStatus(newCurrent, size, uploadStatus === 'final', metadata); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.progressCallback = progressCallback || null; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An event that is triggered on a task. - * @internal - */ -const TaskEvent = { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: 'state_changed' -}; -// type keys = keyof TaskState -/** - * Represents the current state of a running upload. - * @internal - */ -const TaskState = { - /** The task is currently transferring data. */ - RUNNING: 'running', - /** The task was paused by the user. */ - PAUSED: 'paused', - /** The task completed successfully. */ - SUCCESS: 'success', - /** The task was canceled. */ - CANCELED: 'canceled', - /** The task failed with an error. */ - ERROR: 'error' -}; -function taskStateFromInternalTaskState(state) { - switch (state) { - case "running" /* InternalTaskState.RUNNING */: - case "pausing" /* InternalTaskState.PAUSING */: - case "canceling" /* InternalTaskState.CANCELING */: - return TaskState.RUNNING; - case "paused" /* InternalTaskState.PAUSED */: - return TaskState.PAUSED; - case "success" /* InternalTaskState.SUCCESS */: - return TaskState.SUCCESS; - case "canceled" /* InternalTaskState.CANCELED */: - return TaskState.CANCELED; - case "error" /* InternalTaskState.ERROR */: - return TaskState.ERROR; - default: - // TODO(andysoto): assert(false); - return TaskState.ERROR; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -class Observer { - constructor(nextOrObserver, error, complete) { - const asFunctions = isFunction(nextOrObserver) || error != null || complete != null; - if (asFunctions) { - this.next = nextOrObserver; - this.error = error ?? undefined; - this.complete = complete ?? undefined; - } - else { - const observer = nextOrObserver; - this.next = observer.next; - this.error = observer.error; - this.complete = observer.complete; - } - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -// eslint-disable-next-line @typescript-eslint/ban-types -function async(f) { - return (...argsToForward) => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.resolve().then(() => f(...argsToForward)); - }; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** An override for the text-based Connection. Used in tests. */ -let textFactoryOverride = null; -/** - * Network layer for browsers. We use this instead of goog.net.XhrIo because - * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android. - */ -class XhrConnection { - constructor() { - this.sent_ = false; - this.xhr_ = new XMLHttpRequest(); - this.initXhr(); - this.errorCode_ = ErrorCode.NO_ERROR; - this.sendPromise_ = new Promise(resolve => { - this.xhr_.addEventListener('abort', () => { - this.errorCode_ = ErrorCode.ABORT; - resolve(); - }); - this.xhr_.addEventListener('error', () => { - this.errorCode_ = ErrorCode.NETWORK_ERROR; - resolve(); - }); - this.xhr_.addEventListener('load', () => { - resolve(); - }); - }); - } - send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - if (util.isCloudWorkstation(url) && isUsingEmulator) { - this.xhr_.withCredentials = true; - } - this.sent_ = true; - this.xhr_.open(method, url, true); - if (headers !== undefined) { - for (const key in headers) { - if (headers.hasOwnProperty(key)) { - this.xhr_.setRequestHeader(key, headers[key].toString()); - } - } - } - if (body !== undefined) { - this.xhr_.send(body); - } - else { - this.xhr_.send(); - } - return this.sendPromise_; - } - getErrorCode() { - if (!this.sent_) { - throw internalError('cannot .getErrorCode() before sending'); - } - return this.errorCode_; - } - getStatus() { - if (!this.sent_) { - throw internalError('cannot .getStatus() before sending'); - } - try { - return this.xhr_.status; - } - catch (e) { - return -1; - } - } - getResponse() { - if (!this.sent_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.xhr_.response; - } - getErrorText() { - if (!this.sent_) { - throw internalError('cannot .getErrorText() before sending'); - } - return this.xhr_.statusText; - } - /** Aborts the request. */ - abort() { - this.xhr_.abort(); - } - getResponseHeader(header) { - return this.xhr_.getResponseHeader(header); - } - addUploadProgressListener(listener) { - if (this.xhr_.upload != null) { - this.xhr_.upload.addEventListener('progress', listener); - } - } - removeUploadProgressListener(listener) { - if (this.xhr_.upload != null) { - this.xhr_.upload.removeEventListener('progress', listener); - } - } -} -class XhrTextConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'text'; - } -} -function newTextConnection() { - return textFactoryOverride ? textFactoryOverride() : new XhrTextConnection(); -} -class XhrBytesConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'arraybuffer'; - } -} -function newBytesConnection() { - return new XhrBytesConnection(); -} -class XhrBlobConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'blob'; - } -} -function newBlobConnection() { - return new XhrBlobConnection(); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -class UploadTask { - isExponentialBackoffExpired() { - return this.sleepTime > this.maxSleepTime; - } - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref, blob, metadata = null) { - /** - * Number of bytes transferred so far. - */ - this._transferred = 0; - this._needToFetchStatus = false; - this._needToFetchMetadata = false; - this._observers = []; - this._error = undefined; - this._uploadUrl = undefined; - this._request = undefined; - this._chunkMultiplier = 1; - this._resolve = undefined; - this._reject = undefined; - this._ref = ref; - this._blob = blob; - this._metadata = metadata; - this._mappings = getMappings(); - this._resumable = this._shouldDoResumable(this._blob); - this._state = "running" /* InternalTaskState.RUNNING */; - this._errorHandler = error => { - this._request = undefined; - this._chunkMultiplier = 1; - if (error._codeEquals(exports.StorageErrorCode.CANCELED)) { - this._needToFetchStatus = true; - this.completeTransitions_(); - } - else { - const backoffExpired = this.isExponentialBackoffExpired(); - if (isRetryStatusCode(error.status, [])) { - if (backoffExpired) { - error = retryLimitExceeded(); - } - else { - this.sleepTime = Math.max(this.sleepTime * 2, DEFAULT_MIN_SLEEP_TIME_MILLIS); - this._needToFetchStatus = true; - this.completeTransitions_(); - return; - } - } - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this._metadataErrorHandler = error => { - this._request = undefined; - if (error._codeEquals(exports.StorageErrorCode.CANCELED)) { - this.completeTransitions_(); - } - else { - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this.sleepTime = 0; - this.maxSleepTime = this._ref.storage.maxUploadRetryTime; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - this._start(); - }); - // Prevent uncaught rejections on the internal promise from bubbling out - // to the top level with a dummy handler. - this._promise.then(null, () => { }); - } - _makeProgressCallback() { - const sizeBefore = this._transferred; - return loaded => this._updateProgress(sizeBefore + loaded); - } - _shouldDoResumable(blob) { - return blob.size() > 256 * 1024; - } - _start() { - if (this._state !== "running" /* InternalTaskState.RUNNING */) { - // This can happen if someone pauses us in a resume callback, for example. - return; - } - if (this._request !== undefined) { - return; - } - if (this._resumable) { - if (this._uploadUrl === undefined) { - this._createResumable(); - } - else { - if (this._needToFetchStatus) { - this._fetchStatus(); - } - else { - if (this._needToFetchMetadata) { - // Happens if we miss the metadata on upload completion. - this._fetchMetadata(); - } - else { - this.pendingTimeout = setTimeout(() => { - this.pendingTimeout = undefined; - this._continueUpload(); - }, this.sleepTime); - } - } - } - } - else { - this._oneShotUpload(); - } - } - _resolveToken(callback) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.all([ - this._ref.storage._getAuthToken(), - this._ref.storage._getAppCheckToken() - ]).then(([authToken, appCheckToken]) => { - switch (this._state) { - case "running" /* InternalTaskState.RUNNING */: - callback(authToken, appCheckToken); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - } - }); - } - // TODO(andysoto): assert false - _createResumable() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = createRequest; - createRequest.getPromise().then((url) => { - this._request = undefined; - this._uploadUrl = url; - this._needToFetchStatus = false; - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _fetchStatus() { - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob); - const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = statusRequest; - statusRequest.getPromise().then(status => { - status = status; - this._request = undefined; - this._updateProgress(status.current); - this._needToFetchStatus = false; - if (status.finalized) { - this._needToFetchMetadata = true; - } - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _continueUpload() { - const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - const status = new ResumableUploadStatus(this._transferred, this._blob.size()); - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - let requestInfo; - try { - requestInfo = continueResumableUpload(this._ref._location, this._ref.storage, url, this._blob, chunkSize, this._mappings, status, this._makeProgressCallback()); - } - catch (e) { - this._error = e; - this._transition("error" /* InternalTaskState.ERROR */); - return; - } - const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken, - /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file. - ); - this._request = uploadRequest; - uploadRequest.getPromise().then((newStatus) => { - this._increaseMultiplier(); - this._request = undefined; - this._updateProgress(newStatus.current); - if (newStatus.finalized) { - this._metadata = newStatus.metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - } - else { - this.completeTransitions_(); - } - }, this._errorHandler); - }); - } - _increaseMultiplier() { - const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - // Max chunk size is 32M. - if (currentSize * 2 < 32 * 1024 * 1024) { - this._chunkMultiplier *= 2; - } - } - _fetchMetadata() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings); - const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = metadataRequest; - metadataRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._metadataErrorHandler); - }); - } - _oneShotUpload() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = multipartRequest; - multipartRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._updateProgress(this._blob.size()); - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._errorHandler); - }); - } - _updateProgress(transferred) { - const old = this._transferred; - this._transferred = transferred; - // A progress update can make the "transferred" value smaller (e.g. a - // partial upload not completed by server, after which the "transferred" - // value may reset to the value at the beginning of the request). - if (this._transferred !== old) { - this._notifyObservers(); - } - } - _transition(state) { - if (this._state === state) { - return; - } - switch (state) { - case "canceling" /* InternalTaskState.CANCELING */: - case "pausing" /* InternalTaskState.PAUSING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING); - this._state = state; - if (this._request !== undefined) { - this._request.cancel(); - } - else if (this.pendingTimeout) { - clearTimeout(this.pendingTimeout); - this.pendingTimeout = undefined; - this.completeTransitions_(); - } - break; - case "running" /* InternalTaskState.RUNNING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.PAUSING); - const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */; - this._state = state; - if (wasPaused) { - this._notifyObservers(); - this._start(); - } - break; - case "paused" /* InternalTaskState.PAUSED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSING); - this._state = state; - this._notifyObservers(); - break; - case "canceled" /* InternalTaskState.CANCELED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.CANCELING); - this._error = canceled(); - this._state = state; - this._notifyObservers(); - break; - case "error" /* InternalTaskState.ERROR */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - case "success" /* InternalTaskState.SUCCESS */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - } - } - completeTransitions_() { - switch (this._state) { - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "running" /* InternalTaskState.RUNNING */: - this._start(); - break; - } - } - /** - * A snapshot of the current task state. - */ - get snapshot() { - const externalState = taskStateFromInternalTaskState(this._state); - return { - bytesTransferred: this._transferred, - totalBytes: this._blob.size(), - state: externalState, - metadata: this._metadata, - task: this, - ref: this._ref - }; - } - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type, nextOrObserver, error, completed) { - // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string. - const observer = new Observer(nextOrObserver || undefined, error || undefined, completed || undefined); - this._addObserver(observer); - return () => { - this._removeObserver(observer); - }; - } - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled, onRejected) { - // These casts are needed so that TypeScript can infer the types of the - // resulting Promise. - return this._promise.then(onFulfilled, onRejected); - } - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected) { - return this.then(null, onRejected); - } - /** - * Adds the given observer. - */ - _addObserver(observer) { - this._observers.push(observer); - this._notifyObserver(observer); - } - /** - * Removes the given observer. - */ - _removeObserver(observer) { - const i = this._observers.indexOf(observer); - if (i !== -1) { - this._observers.splice(i, 1); - } - } - _notifyObservers() { - this._finishPromise(); - const observers = this._observers.slice(); - observers.forEach(observer => { - this._notifyObserver(observer); - }); - } - _finishPromise() { - if (this._resolve !== undefined) { - let triggered = true; - switch (taskStateFromInternalTaskState(this._state)) { - case TaskState.SUCCESS: - async(this._resolve.bind(null, this.snapshot))(); - break; - case TaskState.CANCELED: - case TaskState.ERROR: - const toCall = this._reject; - async(toCall.bind(null, this._error))(); - break; - default: - triggered = false; - break; - } - if (triggered) { - this._resolve = undefined; - this._reject = undefined; - } - } - } - _notifyObserver(observer) { - const externalState = taskStateFromInternalTaskState(this._state); - switch (externalState) { - case TaskState.RUNNING: - case TaskState.PAUSED: - if (observer.next) { - async(observer.next.bind(observer, this.snapshot))(); - } - break; - case TaskState.SUCCESS: - if (observer.complete) { - async(observer.complete.bind(observer))(); - } - break; - case TaskState.CANCELED: - case TaskState.ERROR: - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - break; - default: - // TODO(andysoto): assert(false); - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - } - } - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume() { - const valid = this._state === "paused" /* InternalTaskState.PAUSED */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("running" /* InternalTaskState.RUNNING */); - } - return valid; - } - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */; - if (valid) { - this._transition("pausing" /* InternalTaskState.PAUSING */); - } - return valid; - } - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("canceling" /* InternalTaskState.CANCELING */); - } - return valid; - } -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -class Reference { - constructor(_service, location) { - this._service = _service; - if (location instanceof Location) { - this._location = location; - } - else { - this._location = Location.makeFromUrl(location, _service.host); - } - } - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString() { - return 'gs://' + this._location.bucket + '/' + this._location.path; - } - _newRef(service, location) { - return new Reference(service, location); - } - /** - * A reference to the root of this object's bucket. - */ - get root() { - const location = new Location(this._location.bucket, ''); - return this._newRef(this._service, location); - } - /** - * The name of the bucket containing this reference's object. - */ - get bucket() { - return this._location.bucket; - } - /** - * The full path of this object. - */ - get fullPath() { - return this._location.path; - } - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name() { - return lastComponent(this._location.path); - } - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage() { - return this._service; - } - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent() { - const newPath = parent(this._location.path); - if (newPath === null) { - return null; - } - const location = new Location(this._location.bucket, newPath); - return new Reference(this._service, location); - } - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name) { - if (this._location.path === '') { - throw invalidRootOperation(name); - } - } -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -function getBytesInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBytes'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBytesConnection) - .then(bytes => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - bytes.slice(0, maxDownloadSizeBytes) - : bytes); -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded blob. - */ -function getBlobInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBlob'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBlobConnection) - .then(blob => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - blob.slice(0, maxDownloadSizeBytes) - : blob); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -function uploadBytes$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytes'); - const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(finalMetadata => { - return { - metadata: finalMetadata, - ref - }; - }); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -function uploadBytesResumable$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytesResumable'); - return new UploadTask(ref, new FbsBlob(data), metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -function uploadString$1(ref, value, format = StringFormat.RAW, metadata) { - ref._throwIfRoot('uploadString'); - const data = dataFromString(format, value); - const metadataClone = { ...metadata }; - if (metadataClone['contentType'] == null && data.contentType != null) { - metadataClone['contentType'] = data.contentType; - } - return uploadBytes$1(ref, data.data, metadataClone); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll$1(ref) { - const accumulator = { - prefixes: [], - items: [] - }; - return listAllHelper(ref, accumulator).then(() => accumulator); -} -/** - * Separated from listAll because async functions can't use "arguments". - * @param ref - * @param accumulator - * @param pageToken - */ -async function listAllHelper(ref, accumulator, pageToken) { - const opt = { - // maxResults is 1000 by default. - pageToken - }; - const nextPage = await list$1(ref, opt); - accumulator.prefixes.push(...nextPage.prefixes); - accumulator.items.push(...nextPage.items); - if (nextPage.nextPageToken != null) { - await listAllHelper(ref, accumulator, nextPage.nextPageToken); - } -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list$1(ref, options) { - if (options != null) { - if (typeof options.maxResults === 'number') { - validateNumber('options.maxResults', - /* minValue= */ 1, - /* maxValue= */ 1000, options.maxResults); - } - } - const op = options || {}; - const requestInfo = list$2(ref.storage, ref._location, - /*delimiter= */ '/', op.pageToken, op.maxResults); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -function getMetadata$1(ref) { - ref._throwIfRoot('getMetadata'); - const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -function updateMetadata$1(ref, metadata) { - ref._throwIfRoot('updateMetadata'); - const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL$1(ref) { - ref._throwIfRoot('getDownloadURL'); - const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings()); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(url => { - if (url === null) { - throw noDownloadURL(); - } - return url; - }); -} -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject$1(ref) { - ref._throwIfRoot('deleteObject'); - const requestInfo = deleteObject$2(ref.storage, ref._location); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -function _getChild$1(ref, childPath) { - const newPath = child(ref._location.path, childPath); - const location = new Location(ref._location.bucket, newPath); - return new Reference(ref.storage, location); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isUrl(path) { - return /^[A-Za-z]+:\/\//.test(path); -} -/** - * Returns a firebaseStorage.Reference for the given url. - */ -function refFromURL(service, url) { - return new Reference(service, url); -} -/** - * Returns a firebaseStorage.Reference for the given path in the default - * bucket. - */ -function refFromPath(ref, path) { - if (ref instanceof FirebaseStorageImpl) { - const service = ref; - if (service._bucket == null) { - throw noDefaultBucket(); - } - const reference = new Reference(service, service._bucket); - if (path != null) { - return refFromPath(reference, path); - } - else { - return reference; - } - } - else { - // ref is a Reference - if (path !== undefined) { - return _getChild$1(ref, path); - } - else { - return ref; - } - } -} -function ref$1(serviceOrRef, pathOrUrl) { - if (pathOrUrl && isUrl(pathOrUrl)) { - if (serviceOrRef instanceof FirebaseStorageImpl) { - return refFromURL(serviceOrRef, pathOrUrl); - } - else { - throw invalidArgument('To use ref(service, url), the first argument must be a Storage instance.'); - } - } - else { - return refFromPath(serviceOrRef, pathOrUrl); - } -} -function extractBucket(host, config) { - const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY]; - if (bucketString == null) { - return null; - } - return Location.makeFromBucketSpec(bucketString, host); -} -function connectStorageEmulator$1(storage, host, port, options = {}) { - storage.host = `${host}:${port}`; - const useSsl = util.isCloudWorkstation(host); - // Workaround to get cookies in Firebase Studio - if (useSsl) { - void util.pingServer(`https://${storage.host}/b`); - util.updateEmulatorBanner('Storage', true); - } - storage._isUsingEmulator = true; - storage._protocol = useSsl ? 'https' : 'http'; - const { mockUserToken } = options; - if (mockUserToken) { - storage._overrideAuthToken = - typeof mockUserToken === 'string' - ? mockUserToken - : util.createMockUserToken(mockUserToken, storage.app.options.projectId); - } -} -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -class FirebaseStorageImpl { - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app, _authProvider, - /** - * @internal - */ - _appCheckProvider, - /** - * @internal - */ - _url, _firebaseVersion, _isUsingEmulator = false) { - this.app = app; - this._authProvider = _authProvider; - this._appCheckProvider = _appCheckProvider; - this._url = _url; - this._firebaseVersion = _firebaseVersion; - this._isUsingEmulator = _isUsingEmulator; - this._bucket = null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - this._host = DEFAULT_HOST; - this._protocol = 'https'; - this._appId = null; - this._deleted = false; - this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME; - this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME; - this._requests = new Set(); - if (_url != null) { - this._bucket = Location.makeFromBucketSpec(_url, this._host); - } - else { - this._bucket = extractBucket(this._host, this.app.options); - } - } - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host() { - return this._host; - } - set host(host) { - this._host = host; - if (this._url != null) { - this._bucket = Location.makeFromBucketSpec(this._url, host); - } - else { - this._bucket = extractBucket(host, this.app.options); - } - } - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime() { - return this._maxUploadRetryTime; - } - set maxUploadRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxUploadRetryTime = time; - } - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime() { - return this._maxOperationRetryTime; - } - set maxOperationRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxOperationRetryTime = time; - } - async _getAuthToken() { - if (this._overrideAuthToken) { - return this._overrideAuthToken; - } - const auth = this._authProvider.getImmediate({ optional: true }); - if (auth) { - const tokenData = await auth.getToken(); - if (tokenData !== null) { - return tokenData.accessToken; - } - } - return null; - } - async _getAppCheckToken() { - if (app._isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) { - return this.app.settings.appCheckToken; - } - const appCheck = this._appCheckProvider.getImmediate({ optional: true }); - if (appCheck) { - const result = await appCheck.getToken(); - // TODO: What do we want to do if there is an error getting the token? - // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be - // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use - // the token (actual or dummy) to send requests. - return result.token; - } - return null; - } - /** - * Stop running requests and prevent more from being created. - */ - _delete() { - if (!this._deleted) { - this._deleted = true; - this._requests.forEach(request => request.cancel()); - this._requests.clear(); - } - return Promise.resolve(); - } - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc) { - return new Reference(this, loc); - } - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) { - if (!this._deleted) { - const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator); - this._requests.add(request); - // Request removes itself from set when complete. - request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request)); - return request; - } - else { - return new FailRequest(appDeleted()); - } - } - async makeRequestWithTokens(requestInfo, requestFactory) { - const [authToken, appCheckToken] = await Promise.all([ - this._getAuthToken(), - this._getAppCheckToken() - ]); - return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise(); - } -} - -const name = "@firebase/storage"; -const version = "0.14.0"; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -const STORAGE_TYPE = 'storage'; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -function getBytes(ref, maxDownloadSizeBytes) { - ref = util.getModularInstance(ref); - return getBytesInternal(ref, maxDownloadSizeBytes); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -function uploadBytes(ref, data, metadata) { - ref = util.getModularInstance(ref); - return uploadBytes$1(ref, data, metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -function uploadString(ref, value, format, metadata) { - ref = util.getModularInstance(ref); - return uploadString$1(ref, value, format, metadata); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -function uploadBytesResumable(ref, data, metadata) { - ref = util.getModularInstance(ref); - return uploadBytesResumable$1(ref, data, metadata); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -function getMetadata(ref) { - ref = util.getModularInstance(ref); - return getMetadata$1(ref); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -function updateMetadata(ref, metadata) { - ref = util.getModularInstance(ref); - return updateMetadata$1(ref, metadata); -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list(ref, options) { - ref = util.getModularInstance(ref); - return list$1(ref, options); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll(ref) { - ref = util.getModularInstance(ref); - return listAll$1(ref); -} -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL(ref) { - ref = util.getModularInstance(ref); - return getDownloadURL$1(ref); -} -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject(ref) { - ref = util.getModularInstance(ref); - return deleteObject$1(ref); -} -function ref(serviceOrRef, pathOrUrl) { - serviceOrRef = util.getModularInstance(serviceOrRef); - return ref$1(serviceOrRef, pathOrUrl); -} -/** - * @internal - */ -function _getChild(ref, childPath) { - return _getChild$1(ref, childPath); -} -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -function getStorage(app$1 = app.getApp(), bucketUrl) { - app$1 = util.getModularInstance(app$1); - const storageProvider = app._getProvider(app$1, STORAGE_TYPE); - const storageInstance = storageProvider.getImmediate({ - identifier: bucketUrl - }); - const emulator = util.getDefaultEmulatorHostnameAndPort('storage'); - if (emulator) { - connectStorageEmulator(storageInstance, ...emulator); - } - return storageInstance; -} -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -function connectStorageEmulator(storage, host, port, options = {}) { - connectStorageEmulator$1(storage, host, port, options); -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -function getBlob(ref, maxDownloadSizeBytes) { - ref = util.getModularInstance(ref); - return getBlobInternal(ref, maxDownloadSizeBytes); -} -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -function getStream(ref, maxDownloadSizeBytes) { - throw new Error('getStream() is only supported by NodeJS builds'); -} - -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -function factory(container, { instanceIdentifier: url }) { - const app$1 = container.getProvider('app').getImmediate(); - const authProvider = container.getProvider('auth-internal'); - const appCheckProvider = container.getProvider('app-check-internal'); - return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider, url, app.SDK_VERSION); -} -function registerStorage() { - app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); - //RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser - app.registerVersion(name, version, ''); - // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation - app.registerVersion(name, version, 'cjs2020'); -} -registerStorage(); - -exports.StorageError = StorageError; -exports.StringFormat = StringFormat; -exports._FbsBlob = FbsBlob; -exports._Location = Location; -exports._TaskEvent = TaskEvent; -exports._TaskState = TaskState; -exports._UploadTask = UploadTask; -exports._dataFromString = dataFromString; -exports._getChild = _getChild; -exports._invalidArgument = invalidArgument; -exports._invalidRootOperation = invalidRootOperation; -exports.connectStorageEmulator = connectStorageEmulator; -exports.deleteObject = deleteObject; -exports.getBlob = getBlob; -exports.getBytes = getBytes; -exports.getDownloadURL = getDownloadURL; -exports.getMetadata = getMetadata; -exports.getStorage = getStorage; -exports.getStream = getStream; -exports.list = list; -exports.listAll = listAll; -exports.ref = ref; -exports.updateMetadata = updateMetadata; -exports.uploadBytes = uploadBytes; -exports.uploadBytesResumable = uploadBytesResumable; -exports.uploadString = uploadString; -//# sourceMappingURL=index.cjs.js.map diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.cjs.js.map b/frontend-old/node_modules/@firebase/storage/dist/index.cjs.js.map deleted file mode 100644 index 91f1bfa..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.cjs.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.cjs.js","sources":["../src/implementation/constants.ts","../src/implementation/error.ts","../src/implementation/location.ts","../src/implementation/failrequest.ts","../src/implementation/backoff.ts","../src/implementation/type.ts","../src/implementation/url.ts","../src/implementation/connection.ts","../src/implementation/utils.ts","../src/implementation/request.ts","../src/implementation/fs.ts","../src/platform/browser/base64.ts","../src/implementation/string.ts","../src/implementation/blob.ts","../src/implementation/json.ts","../src/implementation/path.ts","../src/implementation/metadata.ts","../src/implementation/list.ts","../src/implementation/requestinfo.ts","../src/implementation/requests.ts","../src/implementation/taskenums.ts","../src/implementation/observer.ts","../src/implementation/async.ts","../src/platform/browser/connection.ts","../src/task.ts","../src/reference.ts","../src/service.ts","../src/constants.ts","../src/api.ts","../src/api.browser.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Constants used in the Firebase Storage library.\n */\n\n/**\n * Domain name for firebase storage.\n */\nexport const DEFAULT_HOST = 'firebasestorage.googleapis.com';\n\n/**\n * The key in Firebase config json for the storage bucket.\n */\nexport const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket';\n\n/**\n * 2 minutes\n *\n * The timeout for all operations except upload.\n */\nexport const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000;\n\n/**\n * 10 minutes\n *\n * The timeout for upload.\n */\nexport const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000;\n\n/**\n * 1 second\n */\nexport const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;\n\n/**\n * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported\n * enough for us to use it directly.\n */\nexport const MIN_SAFE_INTEGER = -9007199254740991;\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseError } from '@firebase/util';\n\nimport { CONFIG_STORAGE_BUCKET_KEY } from './constants';\n\n/**\n * An error returned by the Firebase Storage SDK.\n * @public\n */\nexport class StorageError extends FirebaseError {\n private readonly _baseMessage: string;\n /**\n * Stores custom error data unique to the `StorageError`.\n */\n customData: { serverResponse: string | null } = { serverResponse: null };\n\n /**\n * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and\n * added to the end of the message.\n * @param message - Error message.\n * @param status_ - Corresponding HTTP Status Code\n */\n constructor(code: StorageErrorCode, message: string, private status_ = 0) {\n super(\n prependCode(code),\n `Firebase Storage: ${message} (${prependCode(code)})`\n );\n this._baseMessage = this.message;\n // Without this, `instanceof StorageError`, in tests for example,\n // returns false.\n Object.setPrototypeOf(this, StorageError.prototype);\n }\n\n get status(): number {\n return this.status_;\n }\n\n set status(status: number) {\n this.status_ = status;\n }\n\n /**\n * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.\n */\n _codeEquals(code: StorageErrorCode): boolean {\n return prependCode(code) === this.code;\n }\n\n /**\n * Optional response message that was added by the server.\n */\n get serverResponse(): null | string {\n return this.customData.serverResponse;\n }\n\n set serverResponse(serverResponse: string | null) {\n this.customData.serverResponse = serverResponse;\n if (this.customData.serverResponse) {\n this.message = `${this._baseMessage}\\n${this.customData.serverResponse}`;\n } else {\n this.message = this._baseMessage;\n }\n }\n}\n\nexport const errors = {};\n\n/**\n * @public\n * Error codes that can be attached to `StorageError` objects.\n */\nexport enum StorageErrorCode {\n // Shared between all platforms\n UNKNOWN = 'unknown',\n OBJECT_NOT_FOUND = 'object-not-found',\n BUCKET_NOT_FOUND = 'bucket-not-found',\n PROJECT_NOT_FOUND = 'project-not-found',\n QUOTA_EXCEEDED = 'quota-exceeded',\n UNAUTHENTICATED = 'unauthenticated',\n UNAUTHORIZED = 'unauthorized',\n UNAUTHORIZED_APP = 'unauthorized-app',\n RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',\n INVALID_CHECKSUM = 'invalid-checksum',\n CANCELED = 'canceled',\n // JS specific\n INVALID_EVENT_NAME = 'invalid-event-name',\n INVALID_URL = 'invalid-url',\n INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',\n NO_DEFAULT_BUCKET = 'no-default-bucket',\n CANNOT_SLICE_BLOB = 'cannot-slice-blob',\n SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',\n NO_DOWNLOAD_URL = 'no-download-url',\n INVALID_ARGUMENT = 'invalid-argument',\n INVALID_ARGUMENT_COUNT = 'invalid-argument-count',\n APP_DELETED = 'app-deleted',\n INVALID_ROOT_OPERATION = 'invalid-root-operation',\n INVALID_FORMAT = 'invalid-format',\n INTERNAL_ERROR = 'internal-error',\n UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'\n}\n\nexport function prependCode(code: StorageErrorCode): string {\n return 'storage/' + code;\n}\n\nexport function unknown(): StorageError {\n const message =\n 'An unknown error occurred, please check the error payload for ' +\n 'server response.';\n return new StorageError(StorageErrorCode.UNKNOWN, message);\n}\n\nexport function objectNotFound(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.OBJECT_NOT_FOUND,\n \"Object '\" + path + \"' does not exist.\"\n );\n}\n\nexport function bucketNotFound(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.BUCKET_NOT_FOUND,\n \"Bucket '\" + bucket + \"' does not exist.\"\n );\n}\n\nexport function projectNotFound(project: string): StorageError {\n return new StorageError(\n StorageErrorCode.PROJECT_NOT_FOUND,\n \"Project '\" + project + \"' does not exist.\"\n );\n}\n\nexport function quotaExceeded(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.QUOTA_EXCEEDED,\n \"Quota for bucket '\" +\n bucket +\n \"' exceeded, please view quota on \" +\n 'https://firebase.google.com/pricing/.'\n );\n}\n\nexport function unauthenticated(): StorageError {\n const message =\n 'User is not authenticated, please authenticate using Firebase ' +\n 'Authentication and try again.';\n return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);\n}\n\nexport function unauthorizedApp(): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED_APP,\n 'This app does not have permission to access Firebase Storage on this project.'\n );\n}\n\nexport function unauthorized(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED,\n \"User does not have permission to access '\" + path + \"'.\"\n );\n}\n\nexport function retryLimitExceeded(): StorageError {\n return new StorageError(\n StorageErrorCode.RETRY_LIMIT_EXCEEDED,\n 'Max retry time for operation exceeded, please try again.'\n );\n}\n\nexport function invalidChecksum(\n path: string,\n checksum: string,\n calculated: string\n): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_CHECKSUM,\n \"Uploaded/downloaded object '\" +\n path +\n \"' has checksum '\" +\n checksum +\n \"' which does not match '\" +\n calculated +\n \"'. Please retry the upload/download.\"\n );\n}\n\nexport function canceled(): StorageError {\n return new StorageError(\n StorageErrorCode.CANCELED,\n 'User canceled the upload/download.'\n );\n}\n\nexport function invalidEventName(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_EVENT_NAME,\n \"Invalid event name '\" + name + \"'.\"\n );\n}\n\nexport function invalidUrl(url: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_URL,\n \"Invalid URL '\" + url + \"'.\"\n );\n}\n\nexport function invalidDefaultBucket(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_DEFAULT_BUCKET,\n \"Invalid default bucket '\" + bucket + \"'.\"\n );\n}\n\nexport function noDefaultBucket(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DEFAULT_BUCKET,\n 'No default bucket ' +\n \"found. Did you set the '\" +\n CONFIG_STORAGE_BUCKET_KEY +\n \"' property when initializing the app?\"\n );\n}\n\nexport function cannotSliceBlob(): StorageError {\n return new StorageError(\n StorageErrorCode.CANNOT_SLICE_BLOB,\n 'Cannot slice blob for upload. Please retry the upload.'\n );\n}\n\nexport function serverFileWrongSize(): StorageError {\n return new StorageError(\n StorageErrorCode.SERVER_FILE_WRONG_SIZE,\n 'Server recorded incorrect upload file size, please retry the upload.'\n );\n}\n\nexport function noDownloadURL(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DOWNLOAD_URL,\n 'The given file does not have any download URLs.'\n );\n}\n\nexport function missingPolyFill(polyFill: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`\n );\n}\n\n/**\n * @internal\n */\nexport function invalidArgument(message: string): StorageError {\n return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);\n}\n\nexport function invalidArgumentCount(\n argMin: number,\n argMax: number,\n fnName: string,\n real: number\n): StorageError {\n let countPart;\n let plural;\n if (argMin === argMax) {\n countPart = argMin;\n plural = argMin === 1 ? 'argument' : 'arguments';\n } else {\n countPart = 'between ' + argMin + ' and ' + argMax;\n plural = 'arguments';\n }\n return new StorageError(\n StorageErrorCode.INVALID_ARGUMENT_COUNT,\n 'Invalid argument count in `' +\n fnName +\n '`: Expected ' +\n countPart +\n ' ' +\n plural +\n ', received ' +\n real +\n '.'\n );\n}\n\nexport function appDeleted(): StorageError {\n return new StorageError(\n StorageErrorCode.APP_DELETED,\n 'The Firebase app was deleted.'\n );\n}\n\n/**\n * @param name - The name of the operation that was invalid.\n *\n * @internal\n */\nexport function invalidRootOperation(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_ROOT_OPERATION,\n \"The operation '\" +\n name +\n \"' cannot be performed on a root reference, create a non-root \" +\n \"reference using child, such as .child('file.png').\"\n );\n}\n\n/**\n * @param format - The format that was not valid.\n * @param message - A message describing the format violation.\n */\nexport function invalidFormat(format: string, message: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_FORMAT,\n \"String does not match format '\" + format + \"': \" + message\n );\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function unsupportedEnvironment(message: string): StorageError {\n throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, message);\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function internalError(message: string): StorageError {\n throw new StorageError(\n StorageErrorCode.INTERNAL_ERROR,\n 'Internal error: ' + message\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functionality related to the parsing/composition of bucket/\n * object location.\n */\n\nimport { invalidDefaultBucket, invalidUrl } from './error';\nimport { DEFAULT_HOST } from './constants';\n\n/**\n * Firebase Storage location data.\n *\n * @internal\n */\nexport class Location {\n private path_: string;\n\n constructor(public readonly bucket: string, path: string) {\n this.path_ = path;\n }\n\n get path(): string {\n return this.path_;\n }\n\n get isRoot(): boolean {\n return this.path.length === 0;\n }\n\n fullServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o/' + encode(this.path);\n }\n\n bucketOnlyServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o';\n }\n\n static makeFromBucketSpec(bucketString: string, host: string): Location {\n let bucketLocation;\n try {\n bucketLocation = Location.makeFromUrl(bucketString, host);\n } catch (e) {\n // Not valid URL, use as-is. This lets you put bare bucket names in\n // config.\n return new Location(bucketString, '');\n }\n if (bucketLocation.path === '') {\n return bucketLocation;\n } else {\n throw invalidDefaultBucket(bucketString);\n }\n }\n\n static makeFromUrl(url: string, host: string): Location {\n let location: Location | null = null;\n const bucketDomain = '([A-Za-z0-9.\\\\-_]+)';\n\n function gsModify(loc: Location): void {\n if (loc.path.charAt(loc.path.length - 1) === '/') {\n loc.path_ = loc.path_.slice(0, -1);\n }\n }\n const gsPath = '(/(.*))?$';\n const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i');\n const gsIndices = { bucket: 1, path: 3 };\n\n function httpModify(loc: Location): void {\n loc.path_ = decodeURIComponent(loc.path);\n }\n const version = 'v[A-Za-z0-9_]+';\n const firebaseStorageHost = host.replace(/[.]/g, '\\\\.');\n const firebaseStoragePath = '(/([^?#]*).*)?$';\n const firebaseStorageRegExp = new RegExp(\n `^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`,\n 'i'\n );\n const firebaseStorageIndices = { bucket: 1, path: 3 };\n\n const cloudStorageHost =\n host === DEFAULT_HOST\n ? '(?:storage.googleapis.com|storage.cloud.google.com)'\n : host;\n const cloudStoragePath = '([^?#]*)';\n const cloudStorageRegExp = new RegExp(\n `^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`,\n 'i'\n );\n const cloudStorageIndices = { bucket: 1, path: 2 };\n\n const groups = [\n { regex: gsRegex, indices: gsIndices, postModify: gsModify },\n {\n regex: firebaseStorageRegExp,\n indices: firebaseStorageIndices,\n postModify: httpModify\n },\n {\n regex: cloudStorageRegExp,\n indices: cloudStorageIndices,\n postModify: httpModify\n }\n ];\n for (let i = 0; i < groups.length; i++) {\n const group = groups[i];\n const captures = group.regex.exec(url);\n if (captures) {\n const bucketValue = captures[group.indices.bucket];\n let pathValue = captures[group.indices.path];\n if (!pathValue) {\n pathValue = '';\n }\n location = new Location(bucketValue, pathValue);\n group.postModify(location);\n break;\n }\n }\n if (location == null) {\n throw invalidUrl(url);\n }\n return location;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Request } from './request';\n\n/**\n * A request whose promise always fails.\n */\nexport class FailRequest<T> implements Request<T> {\n promise_: Promise<T>;\n\n constructor(error: StorageError) {\n this.promise_ = Promise.reject<T>(error);\n }\n\n /** @inheritDoc */\n getPromise(): Promise<T> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(_appDelete = false): void {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Provides a method for running a function with exponential\n * backoff.\n */\ntype id = (p1: boolean) => void;\n\nexport { id };\n\n/**\n * Accepts a callback for an action to perform (`doRequest`),\n * and then a callback for when the backoff has completed (`backoffCompleteCb`).\n * The callback sent to start requires an argument to call (`onRequestComplete`).\n * When `start` calls `doRequest`, it passes a callback for when the request has\n * completed, `onRequestComplete`. Based on this, the backoff continues, with\n * another call to `doRequest` and the above loop continues until the timeout\n * is hit, or a successful response occurs.\n * @description\n * @param doRequest Callback to perform request\n * @param backoffCompleteCb Callback to call when backoff has been completed\n */\nexport function start(\n doRequest: (\n onRequestComplete: (success: boolean) => void,\n canceled: boolean\n ) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n backoffCompleteCb: (...args: any[]) => unknown,\n timeout: number\n): id {\n // TODO(andysoto): make this code cleaner (probably refactor into an actual\n // type instead of a bunch of functions with state shared in the closure)\n let waitSeconds = 1;\n // Would type this as \"number\" but that doesn't work for Node so ¯\\_(ツ)_/¯\n // TODO: find a way to exclude Node type definition for storage because storage only works in browser\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let retryTimeoutId: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let globalTimeoutId: any = null;\n let hitTimeout = false;\n let cancelState = 0;\n\n function canceled(): boolean {\n return cancelState === 2;\n }\n let triggeredCallback = false;\n\n function triggerCallback(...args: any[]): void {\n if (!triggeredCallback) {\n triggeredCallback = true;\n backoffCompleteCb.apply(null, args);\n }\n }\n\n function callWithDelay(millis: number): void {\n retryTimeoutId = setTimeout(() => {\n retryTimeoutId = null;\n doRequest(responseHandler, canceled());\n }, millis);\n }\n\n function clearGlobalTimeout(): void {\n if (globalTimeoutId) {\n clearTimeout(globalTimeoutId);\n }\n }\n\n function responseHandler(success: boolean, ...args: any[]): void {\n if (triggeredCallback) {\n clearGlobalTimeout();\n return;\n }\n if (success) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n const mustStop = canceled() || hitTimeout;\n if (mustStop) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n if (waitSeconds < 64) {\n /* TODO(andysoto): don't back off so quickly if we know we're offline. */\n waitSeconds *= 2;\n }\n let waitMillis;\n if (cancelState === 1) {\n cancelState = 2;\n waitMillis = 0;\n } else {\n waitMillis = (waitSeconds + Math.random()) * 1000;\n }\n callWithDelay(waitMillis);\n }\n let stopped = false;\n\n function stop(wasTimeout: boolean): void {\n if (stopped) {\n return;\n }\n stopped = true;\n clearGlobalTimeout();\n if (triggeredCallback) {\n return;\n }\n if (retryTimeoutId !== null) {\n if (!wasTimeout) {\n cancelState = 2;\n }\n clearTimeout(retryTimeoutId);\n callWithDelay(0);\n } else {\n if (!wasTimeout) {\n cancelState = 1;\n }\n }\n }\n callWithDelay(0);\n globalTimeoutId = setTimeout(() => {\n hitTimeout = true;\n stop(true);\n }, timeout);\n return stop;\n}\n\n/**\n * Stops the retry loop from repeating.\n * If the function is currently \"in between\" retries, it is invoked immediately\n * with the second parameter as \"true\". Otherwise, it will be invoked once more\n * after the current invocation finishes iff the current invocation would have\n * triggered another retry.\n */\nexport function stop(id: id): void {\n id(false);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { invalidArgument } from './error';\n\nexport function isJustDef<T>(p: T | null | undefined): p is T | null {\n return p !== void 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isFunction(p: unknown): p is Function {\n return typeof p === 'function';\n}\n\nexport function isNonArrayObject(p: unknown): boolean {\n return typeof p === 'object' && !Array.isArray(p);\n}\n\nexport function isString(p: unknown): p is string {\n return typeof p === 'string' || p instanceof String;\n}\n\nexport function isNativeBlob(p: unknown): p is Blob {\n return isNativeBlobDefined() && p instanceof Blob;\n}\n\nexport function isNativeBlobDefined(): boolean {\n return typeof Blob !== 'undefined';\n}\n\nexport function validateNumber(\n argument: string,\n minValue: number,\n maxValue: number,\n value: number\n): void {\n if (value < minValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${minValue} or greater.`\n );\n }\n if (value > maxValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${maxValue} or less.`\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functions to create and manipulate URLs for the server API.\n */\nimport { UrlParams } from './requestinfo';\n\nexport function makeUrl(\n urlPart: string,\n host: string,\n protocol: string\n): string {\n let origin = host;\n if (protocol == null) {\n origin = `https://${host}`;\n }\n return `${protocol}://${origin}/v0${urlPart}`;\n}\n\nexport function makeQueryString(params: UrlParams): string {\n const encode = encodeURIComponent;\n let queryPart = '?';\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const nextPart = encode(key) + '=' + encode(params[key]);\n queryPart = queryPart + nextPart + '&';\n }\n }\n\n // Chop off the extra '&' or '?' on the end\n queryPart = queryPart.slice(0, -1);\n return queryPart;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Network headers */\nexport type Headers = Record<string, string>;\n\n/** Response type exposed by the networking APIs. */\nexport type ConnectionType =\n | string\n | ArrayBuffer\n | Blob\n | ReadableStream<Uint8Array>;\n\n/**\n * A lightweight wrapper around XMLHttpRequest with a\n * goog.net.XhrIo-like interface.\n *\n * You can create a new connection by invoking `newTextConnection()`,\n * `newBytesConnection()` or `newStreamConnection()`.\n */\nexport interface Connection<T extends ConnectionType> {\n /**\n * Sends a request to the provided URL.\n *\n * This method never rejects its promise. In case of encountering an error,\n * it sets an error code internally which can be accessed by calling\n * getErrorCode() by callers.\n */\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string | null,\n headers?: Headers\n ): Promise<void>;\n\n getErrorCode(): ErrorCode;\n\n getStatus(): number;\n\n getResponse(): T;\n\n getErrorText(): string;\n\n /**\n * Abort the request.\n */\n abort(): void;\n\n getResponseHeader(header: string): string | null;\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n}\n\n/**\n * Error codes for requests made by the XhrIo wrapper.\n */\nexport enum ErrorCode {\n NO_ERROR = 0,\n NETWORK_ERROR = 1,\n ABORT = 2\n}\n","/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Checks the status code to see if the action should be retried.\n *\n * @param status Current HTTP status code returned by server.\n * @param additionalRetryCodes additional retry codes to check against\n */\nexport function isRetryStatusCode(\n status: number,\n additionalRetryCodes: number[]\n): boolean {\n // The codes for which to retry came from this page:\n // https://cloud.google.com/storage/docs/exponential-backoff\n const isFiveHundredCode = status >= 500 && status < 600;\n const extraRetryCodes = [\n // Request Timeout: web server didn't receive full request in time.\n 408,\n // Too Many Requests: you're getting rate-limited, basically.\n 429\n ];\n const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;\n const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;\n return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods used to actually send HTTP requests from\n * abstract representations.\n */\n\nimport { id as backoffId, start, stop } from './backoff';\nimport { appDeleted, canceled, retryLimitExceeded, unknown } from './error';\nimport { ErrorHandler, RequestHandler, RequestInfo } from './requestinfo';\nimport { isJustDef } from './type';\nimport { makeQueryString } from './url';\nimport { Connection, ErrorCode, Headers, ConnectionType } from './connection';\nimport { isRetryStatusCode } from './utils';\n\nexport interface Request<T> {\n getPromise(): Promise<T>;\n\n /**\n * Cancels the request. IMPORTANT: the promise may still be resolved with an\n * appropriate value (if the request is finished before you call this method,\n * but the promise has not yet been resolved), so don't just assume it will be\n * rejected if you call this function.\n * @param appDelete - True if the cancelation came from the app being deleted.\n */\n cancel(appDelete?: boolean): void;\n}\n\n/**\n * Handles network logic for all Storage Requests, including error reporting and\n * retries with backoff.\n *\n * @param I - the type of the backend's network response.\n * @param - O the output type used by the rest of the SDK. The conversion\n * happens in the specified `callback_`.\n */\nclass NetworkRequest<I extends ConnectionType, O> implements Request<O> {\n private pendingConnection_: Connection<I> | null = null;\n private backoffId_: backoffId | null = null;\n private resolve_!: (value?: O | PromiseLike<O>) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private reject_!: (reason?: any) => void;\n private canceled_: boolean = false;\n private appDelete_: boolean = false;\n private promise_: Promise<O>;\n\n constructor(\n private url_: string,\n private method_: string,\n private headers_: Headers,\n private body_: string | Blob | Uint8Array | null,\n private successCodes_: number[],\n private additionalRetryCodes_: number[],\n private callback_: RequestHandler<I, O>,\n private errorCallback_: ErrorHandler | null,\n private timeout_: number,\n private progressCallback_: ((p1: number, p2: number) => void) | null,\n private connectionFactory_: () => Connection<I>,\n private retry = true,\n private isUsingEmulator = false\n ) {\n this.promise_ = new Promise((resolve, reject) => {\n this.resolve_ = resolve as (value?: O | PromiseLike<O>) => void;\n this.reject_ = reject;\n this.start_();\n });\n }\n\n /**\n * Actually starts the retry loop.\n */\n private start_(): void {\n const doTheRequest: (\n backoffCallback: (success: boolean, ...p2: unknown[]) => void,\n canceled: boolean\n ) => void = (backoffCallback, canceled) => {\n if (canceled) {\n backoffCallback(false, new RequestEndStatus(false, null, true));\n return;\n }\n const connection = this.connectionFactory_();\n this.pendingConnection_ = connection;\n\n const progressListener: (\n progressEvent: ProgressEvent\n ) => void = progressEvent => {\n const loaded = progressEvent.loaded;\n const total = progressEvent.lengthComputable ? progressEvent.total : -1;\n if (this.progressCallback_ !== null) {\n this.progressCallback_(loaded, total);\n }\n };\n if (this.progressCallback_ !== null) {\n connection.addUploadProgressListener(progressListener);\n }\n\n // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n connection\n .send(\n this.url_,\n this.method_,\n this.isUsingEmulator,\n this.body_,\n this.headers_\n )\n .then(() => {\n if (this.progressCallback_ !== null) {\n connection.removeUploadProgressListener(progressListener);\n }\n this.pendingConnection_ = null;\n const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;\n const status = connection.getStatus();\n if (\n !hitServer ||\n (isRetryStatusCode(status, this.additionalRetryCodes_) &&\n this.retry)\n ) {\n const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;\n backoffCallback(\n false,\n new RequestEndStatus(false, null, wasCanceled)\n );\n return;\n }\n const successCode = this.successCodes_.indexOf(status) !== -1;\n backoffCallback(true, new RequestEndStatus(successCode, connection));\n });\n };\n\n /**\n * @param requestWentThrough - True if the request eventually went\n * through, false if it hit the retry limit or was canceled.\n */\n const backoffDone: (\n requestWentThrough: boolean,\n status: RequestEndStatus<I>\n ) => void = (requestWentThrough, status) => {\n const resolve = this.resolve_;\n const reject = this.reject_;\n const connection = status.connection as Connection<I>;\n if (status.wasSuccessCode) {\n try {\n const result = this.callback_(connection, connection.getResponse());\n if (isJustDef(result)) {\n resolve(result);\n } else {\n resolve();\n }\n } catch (e) {\n reject(e);\n }\n } else {\n if (connection !== null) {\n const err = unknown();\n err.serverResponse = connection.getErrorText();\n if (this.errorCallback_) {\n reject(this.errorCallback_(connection, err));\n } else {\n reject(err);\n }\n } else {\n if (status.canceled) {\n const err = this.appDelete_ ? appDeleted() : canceled();\n reject(err);\n } else {\n const err = retryLimitExceeded();\n reject(err);\n }\n }\n }\n };\n if (this.canceled_) {\n backoffDone(false, new RequestEndStatus(false, null, true));\n } else {\n this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);\n }\n }\n\n /** @inheritDoc */\n getPromise(): Promise<O> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(appDelete?: boolean): void {\n this.canceled_ = true;\n this.appDelete_ = appDelete || false;\n if (this.backoffId_ !== null) {\n stop(this.backoffId_);\n }\n if (this.pendingConnection_ !== null) {\n this.pendingConnection_.abort();\n }\n }\n}\n\n/**\n * A collection of information about the result of a network request.\n * @param opt_canceled - Defaults to false.\n */\nexport class RequestEndStatus<I extends ConnectionType> {\n /**\n * True if the request was canceled.\n */\n canceled: boolean;\n\n constructor(\n public wasSuccessCode: boolean,\n public connection: Connection<I> | null,\n canceled?: boolean\n ) {\n this.canceled = !!canceled;\n }\n}\n\nexport function addAuthHeader_(\n headers: Headers,\n authToken: string | null\n): void {\n if (authToken !== null && authToken.length > 0) {\n headers['Authorization'] = 'Firebase ' + authToken;\n }\n}\n\nexport function addVersionHeader_(\n headers: Headers,\n firebaseVersion?: string\n): void {\n headers['X-Firebase-Storage-Version'] =\n 'webjs/' + (firebaseVersion ?? 'AppManager');\n}\n\nexport function addGmpidHeader_(headers: Headers, appId: string | null): void {\n if (appId) {\n headers['X-Firebase-GMPID'] = appId;\n }\n}\n\nexport function addAppCheckHeader_(\n headers: Headers,\n appCheckToken: string | null\n): void {\n if (appCheckToken !== null) {\n headers['X-Firebase-AppCheck'] = appCheckToken;\n }\n}\n\nexport function makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n appId: string | null,\n authToken: string | null,\n appCheckToken: string | null,\n requestFactory: () => Connection<I>,\n firebaseVersion?: string,\n retry = true,\n isUsingEmulator = false\n): Request<O> {\n const queryPart = makeQueryString(requestInfo.urlParams);\n const url = requestInfo.url + queryPart;\n const headers = Object.assign({}, requestInfo.headers);\n addGmpidHeader_(headers, appId);\n addAuthHeader_(headers, authToken);\n addVersionHeader_(headers, firebaseVersion);\n addAppCheckHeader_(headers, appCheckToken);\n return new NetworkRequest<I, O>(\n url,\n requestInfo.method,\n headers,\n requestInfo.body,\n requestInfo.successCodes,\n requestInfo.additionalRetryCodes,\n requestInfo.handler,\n requestInfo.errorHandler,\n requestInfo.timeout,\n requestInfo.progressCallback,\n requestFactory,\n retry,\n isUsingEmulator\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Some methods copied from goog.fs.\n * We don't include goog.fs because it pulls in a bunch of Deferred code that\n * bloats the size of the released binary.\n */\nimport { isNativeBlobDefined } from './type';\nimport { StorageErrorCode, StorageError } from './error';\n\nfunction getBlobBuilder(): typeof IBlobBuilder | undefined {\n if (typeof BlobBuilder !== 'undefined') {\n return BlobBuilder;\n } else if (typeof WebKitBlobBuilder !== 'undefined') {\n return WebKitBlobBuilder;\n } else {\n return undefined;\n }\n}\n\n/**\n * Concatenates one or more values together and converts them to a Blob.\n *\n * @param args The values that will make up the resulting blob.\n * @return The blob.\n */\nexport function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob {\n const BlobBuilder = getBlobBuilder();\n if (BlobBuilder !== undefined) {\n const bb = new BlobBuilder();\n for (let i = 0; i < args.length; i++) {\n bb.append(args[i]);\n }\n return bb.getBlob();\n } else {\n if (isNativeBlobDefined()) {\n return new Blob(args);\n } else {\n throw new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n \"This browser doesn't seem to support creating Blobs\"\n );\n }\n }\n}\n\n/**\n * Slices the blob. The returned blob contains data from the start byte\n * (inclusive) till the end byte (exclusive). Negative indices cannot be used.\n *\n * @param blob The blob to be sliced.\n * @param start Index of the starting byte.\n * @param end Index of the ending byte.\n * @return The blob slice or null if not supported.\n */\nexport function sliceBlob(blob: Blob, start: number, end: number): Blob | null {\n if (blob.webkitSlice) {\n return blob.webkitSlice(start, end);\n } else if (blob.mozSlice) {\n return blob.mozSlice(start, end);\n } else if (blob.slice) {\n return blob.slice(start, end);\n }\n return null;\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { missingPolyFill } from '../../implementation/error';\n\n/** Converts a Base64 encoded string to a binary string. */\nexport function decodeBase64(encoded: string): string {\n if (typeof atob === 'undefined') {\n throw missingPolyFill('base-64');\n }\n return atob(encoded);\n}\n\nexport function decodeUint8Array(data: Uint8Array): string {\n return new TextDecoder().decode(data);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unknown, invalidFormat } from './error';\nimport { decodeBase64 } from '../platform/base64';\n\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport const StringFormat = {\n /**\n * Indicates the string should be interpreted \"raw\", that is, as normal text.\n * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte\n * sequence.\n * Example: The string 'Hello! \\\\ud83d\\\\ude0a' becomes the byte sequence\n * 48 65 6c 6c 6f 21 20 f0 9f 98 8a\n */\n RAW: 'raw',\n /**\n * Indicates the string should be interpreted as base64-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64: 'base64',\n /**\n * Indicates the string should be interpreted as base64url-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64URL: 'base64url',\n /**\n * Indicates the string is a data URL, such as one obtained from\n * canvas.toDataURL().\n * Example: the string 'data:application/octet-stream;base64,aaaa'\n * becomes the byte sequence\n * 69 a6 9a\n * (the content-type \"application/octet-stream\" is also applied, but can\n * be overridden in the metadata object).\n */\n DATA_URL: 'data_url'\n} as const;\n\nexport class StringData {\n contentType: string | null;\n\n constructor(public data: Uint8Array, contentType?: string | null) {\n this.contentType = contentType || null;\n }\n}\n\n/**\n * @internal\n */\nexport function dataFromString(\n format: StringFormat,\n stringData: string\n): StringData {\n switch (format) {\n case StringFormat.RAW:\n return new StringData(utf8Bytes_(stringData));\n case StringFormat.BASE64:\n case StringFormat.BASE64URL:\n return new StringData(base64Bytes_(format, stringData));\n case StringFormat.DATA_URL:\n return new StringData(\n dataURLBytes_(stringData),\n dataURLContentType_(stringData)\n );\n default:\n // do nothing\n }\n\n // assert(false);\n throw unknown();\n}\n\nexport function utf8Bytes_(value: string): Uint8Array {\n const b: number[] = [];\n for (let i = 0; i < value.length; i++) {\n let c = value.charCodeAt(i);\n if (c <= 127) {\n b.push(c);\n } else {\n if (c <= 2047) {\n b.push(192 | (c >> 6), 128 | (c & 63));\n } else {\n if ((c & 64512) === 55296) {\n // The start of a surrogate pair.\n const valid =\n i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;\n if (!valid) {\n // The second surrogate wasn't there.\n b.push(239, 191, 189);\n } else {\n const hi = c;\n const lo = value.charCodeAt(++i);\n c = 65536 | ((hi & 1023) << 10) | (lo & 1023);\n b.push(\n 240 | (c >> 18),\n 128 | ((c >> 12) & 63),\n 128 | ((c >> 6) & 63),\n 128 | (c & 63)\n );\n }\n } else {\n if ((c & 64512) === 56320) {\n // Invalid low surrogate.\n b.push(239, 191, 189);\n } else {\n b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63));\n }\n }\n }\n }\n }\n return new Uint8Array(b);\n}\n\nexport function percentEncodedBytes_(value: string): Uint8Array {\n let decoded;\n try {\n decoded = decodeURIComponent(value);\n } catch (e) {\n throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.');\n }\n return utf8Bytes_(decoded);\n}\n\nexport function base64Bytes_(format: StringFormat, value: string): Uint8Array {\n switch (format) {\n case StringFormat.BASE64: {\n const hasMinus = value.indexOf('-') !== -1;\n const hasUnder = value.indexOf('_') !== -1;\n if (hasMinus || hasUnder) {\n const invalidChar = hasMinus ? '-' : '_';\n throw invalidFormat(\n format,\n \"Invalid character '\" +\n invalidChar +\n \"' found: is it base64url encoded?\"\n );\n }\n break;\n }\n case StringFormat.BASE64URL: {\n const hasPlus = value.indexOf('+') !== -1;\n const hasSlash = value.indexOf('/') !== -1;\n if (hasPlus || hasSlash) {\n const invalidChar = hasPlus ? '+' : '/';\n throw invalidFormat(\n format,\n \"Invalid character '\" + invalidChar + \"' found: is it base64 encoded?\"\n );\n }\n value = value.replace(/-/g, '+').replace(/_/g, '/');\n break;\n }\n default:\n // do nothing\n }\n let bytes;\n try {\n bytes = decodeBase64(value);\n } catch (e) {\n if ((e as Error).message.includes('polyfill')) {\n throw e;\n }\n throw invalidFormat(format, 'Invalid character found');\n }\n const array = new Uint8Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n array[i] = bytes.charCodeAt(i);\n }\n return array;\n}\n\nclass DataURLParts {\n base64: boolean = false;\n contentType: string | null = null;\n rest: string;\n\n constructor(dataURL: string) {\n const matches = dataURL.match(/^data:([^,]+)?,/);\n if (matches === null) {\n throw invalidFormat(\n StringFormat.DATA_URL,\n \"Must be formatted 'data:[<mediatype>][;base64],<data>\"\n );\n }\n const middle = matches[1] || null;\n if (middle != null) {\n this.base64 = endsWith(middle, ';base64');\n this.contentType = this.base64\n ? middle.substring(0, middle.length - ';base64'.length)\n : middle;\n }\n this.rest = dataURL.substring(dataURL.indexOf(',') + 1);\n }\n}\n\nexport function dataURLBytes_(dataUrl: string): Uint8Array {\n const parts = new DataURLParts(dataUrl);\n if (parts.base64) {\n return base64Bytes_(StringFormat.BASE64, parts.rest);\n } else {\n return percentEncodedBytes_(parts.rest);\n }\n}\n\nexport function dataURLContentType_(dataUrl: string): string | null {\n const parts = new DataURLParts(dataUrl);\n return parts.contentType;\n}\n\nfunction endsWith(s: string, end: string): boolean {\n const longEnough = s.length >= end.length;\n if (!longEnough) {\n return false;\n }\n\n return s.substring(s.length - end.length) === end;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Provides a Blob-like wrapper for various binary types (including the\n * native Blob type). This makes it possible to upload types like ArrayBuffers,\n * making uploads possible in environments without the native Blob type.\n */\nimport { sliceBlob, getBlob } from './fs';\nimport { StringFormat, dataFromString } from './string';\nimport { isNativeBlob, isNativeBlobDefined, isString } from './type';\n\n/**\n * @param opt_elideCopy - If true, doesn't copy mutable input data\n * (e.g. Uint8Arrays). Pass true only if you know the objects will not be\n * modified after this blob's construction.\n *\n * @internal\n */\nexport class FbsBlob {\n private data_!: Blob | Uint8Array;\n private size_: number;\n private type_: string;\n\n constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean) {\n let size: number = 0;\n let blobType: string = '';\n if (isNativeBlob(data)) {\n this.data_ = data as Blob;\n size = (data as Blob).size;\n blobType = (data as Blob).type;\n } else if (data instanceof ArrayBuffer) {\n if (elideCopy) {\n this.data_ = new Uint8Array(data);\n } else {\n this.data_ = new Uint8Array(data.byteLength);\n this.data_.set(new Uint8Array(data));\n }\n size = this.data_.length;\n } else if (data instanceof Uint8Array) {\n if (elideCopy) {\n this.data_ = data as Uint8Array;\n } else {\n this.data_ = new Uint8Array(data.length);\n this.data_.set(data as Uint8Array);\n }\n size = data.length;\n }\n this.size_ = size;\n this.type_ = blobType;\n }\n\n size(): number {\n return this.size_;\n }\n\n type(): string {\n return this.type_;\n }\n\n slice(startByte: number, endByte: number): FbsBlob | null {\n if (isNativeBlob(this.data_)) {\n const realBlob = this.data_ as Blob;\n const sliced = sliceBlob(realBlob, startByte, endByte);\n if (sliced === null) {\n return null;\n }\n return new FbsBlob(sliced);\n } else {\n const slice = new Uint8Array(\n (this.data_ as Uint8Array).buffer,\n startByte,\n endByte - startByte\n );\n return new FbsBlob(slice, true);\n }\n }\n\n static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null {\n if (isNativeBlobDefined()) {\n const blobby: Array<Blob | Uint8Array | string> = args.map(\n (val: string | FbsBlob): Blob | Uint8Array | string => {\n if (val instanceof FbsBlob) {\n return val.data_;\n } else {\n return val;\n }\n }\n );\n return new FbsBlob(getBlob.apply(null, blobby));\n } else {\n const uint8Arrays: Uint8Array[] = args.map(\n (val: string | FbsBlob): Uint8Array => {\n if (isString(val)) {\n return dataFromString(StringFormat.RAW, val as string).data;\n } else {\n // Blobs don't exist, so this has to be a Uint8Array.\n return (val as FbsBlob).data_ as Uint8Array;\n }\n }\n );\n let finalLength = 0;\n uint8Arrays.forEach((array: Uint8Array): void => {\n finalLength += array.byteLength;\n });\n const merged = new Uint8Array(finalLength);\n let index = 0;\n uint8Arrays.forEach((array: Uint8Array) => {\n for (let i = 0; i < array.length; i++) {\n merged[index++] = array[i];\n }\n });\n return new FbsBlob(merged, true);\n }\n }\n\n uploadData(): Blob | Uint8Array {\n return this.data_;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isNonArrayObject } from './type';\n\n/**\n * Returns the Object resulting from parsing the given JSON, or null if the\n * given string does not represent a JSON object.\n */\nexport function jsonObjectOrNull(\n s: string\n): { [name: string]: unknown } | null {\n let obj;\n try {\n obj = JSON.parse(s);\n } catch (e) {\n return null;\n }\n if (isNonArrayObject(obj)) {\n return obj;\n } else {\n return null;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Contains helper methods for manipulating paths.\n */\n\n/**\n * @return Null if the path is already at the root.\n */\nexport function parent(path: string): string | null {\n if (path.length === 0) {\n return null;\n }\n const index = path.lastIndexOf('/');\n if (index === -1) {\n return '';\n }\n const newPath = path.slice(0, index);\n return newPath;\n}\n\nexport function child(path: string, childPath: string): string {\n const canonicalChildPath = childPath\n .split('/')\n .filter(component => component.length > 0)\n .join('/');\n if (path.length === 0) {\n return canonicalChildPath;\n } else {\n return path + '/' + canonicalChildPath;\n }\n}\n\n/**\n * Returns the last component of a path.\n * '/foo/bar' -> 'bar'\n * '/foo/bar/baz/' -> 'baz/'\n * '/a' -> 'a'\n */\nexport function lastComponent(path: string): string {\n const index = path.lastIndexOf('/', path.length - 2);\n if (index === -1) {\n return path;\n } else {\n return path.slice(index + 1);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the metadata format\n */\nimport { Metadata } from '../metadata';\n\nimport { jsonObjectOrNull } from './json';\nimport { Location } from './location';\nimport { lastComponent } from './path';\nimport { isString } from './type';\nimport { makeUrl, makeQueryString } from './url';\nimport { Reference } from '../reference';\nimport { FirebaseStorageImpl } from '../service';\n\nexport function noXform_<T>(metadata: Metadata, value: T): T {\n return value;\n}\n\nclass Mapping<T> {\n local: string;\n writable: boolean;\n xform: (p1: Metadata, p2?: T) => T | undefined;\n\n constructor(\n public server: string,\n local?: string | null,\n writable?: boolean,\n xform?: ((p1: Metadata, p2?: T) => T | undefined) | null\n ) {\n this.local = local || server;\n this.writable = !!writable;\n this.xform = xform || noXform_;\n }\n}\ntype Mappings = Array<Mapping<string> | Mapping<number>>;\n\nexport { Mappings };\n\nlet mappings_: Mappings | null = null;\n\nexport function xformPath(fullPath: string | undefined): string | undefined {\n if (!isString(fullPath) || fullPath.length < 2) {\n return fullPath;\n } else {\n return lastComponent(fullPath);\n }\n}\n\nexport function getMappings(): Mappings {\n if (mappings_) {\n return mappings_;\n }\n const mappings: Mappings = [];\n mappings.push(new Mapping<string>('bucket'));\n mappings.push(new Mapping<string>('generation'));\n mappings.push(new Mapping<string>('metageneration'));\n mappings.push(new Mapping<string>('name', 'fullPath', true));\n\n function mappingsXformPath(\n _metadata: Metadata,\n fullPath: string | undefined\n ): string | undefined {\n return xformPath(fullPath);\n }\n const nameMapping = new Mapping<string>('name');\n nameMapping.xform = mappingsXformPath;\n mappings.push(nameMapping);\n\n /**\n * Coerces the second param to a number, if it is defined.\n */\n function xformSize(\n _metadata: Metadata,\n size?: number | string\n ): number | undefined {\n if (size !== undefined) {\n return Number(size);\n } else {\n return size;\n }\n }\n const sizeMapping = new Mapping<number>('size');\n sizeMapping.xform = xformSize;\n mappings.push(sizeMapping);\n mappings.push(new Mapping<number>('timeCreated'));\n mappings.push(new Mapping<string>('updated'));\n mappings.push(new Mapping<string>('md5Hash', null, true));\n mappings.push(new Mapping<string>('cacheControl', null, true));\n mappings.push(new Mapping<string>('contentDisposition', null, true));\n mappings.push(new Mapping<string>('contentEncoding', null, true));\n mappings.push(new Mapping<string>('contentLanguage', null, true));\n mappings.push(new Mapping<string>('contentType', null, true));\n mappings.push(new Mapping<string>('metadata', 'customMetadata', true));\n mappings_ = mappings;\n return mappings_;\n}\n\nexport function addRef(metadata: Metadata, service: FirebaseStorageImpl): void {\n function generateRef(): Reference {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const loc = new Location(bucket, path);\n return service._makeStorageReference(loc);\n }\n Object.defineProperty(metadata, 'ref', { get: generateRef });\n}\n\nexport function fromResource(\n service: FirebaseStorageImpl,\n resource: { [name: string]: unknown },\n mappings: Mappings\n): Metadata {\n const metadata: Metadata = {} as Metadata;\n metadata['type'] = 'file';\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n metadata[mapping.local] = (mapping as Mapping<unknown>).xform(\n metadata,\n resource[mapping.server]\n );\n }\n addRef(metadata, service);\n return metadata;\n}\n\nexport function fromResourceString(\n service: FirebaseStorageImpl,\n resourceString: string,\n mappings: Mappings\n): Metadata | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as Metadata;\n return fromResource(service, resource, mappings);\n}\n\nexport function downloadUrlFromResourceString(\n metadata: Metadata,\n resourceString: string,\n host: string,\n protocol: string\n): string | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n if (!isString(obj['downloadTokens'])) {\n // This can happen if objects are uploaded through GCS and retrieved\n // through list, so we don't want to throw an Error.\n return null;\n }\n const tokens: string = obj['downloadTokens'] as string;\n if (tokens.length === 0) {\n return null;\n }\n const encode = encodeURIComponent;\n const tokensList = tokens.split(',');\n const urls = tokensList.map((token: string): string => {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path);\n const base = makeUrl(urlPart, host, protocol);\n const queryString = makeQueryString({\n alt: 'media',\n token\n });\n return base + queryString;\n });\n return urls[0];\n}\n\nexport function toResourceString(\n metadata: Partial<Metadata>,\n mappings: Mappings\n): string {\n const resource: {\n [prop: string]: unknown;\n } = {};\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n if (mapping.writable) {\n resource[mapping.server] = metadata[mapping.local];\n }\n }\n return JSON.stringify(resource);\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the listOptions and listResult format\n */\nimport { Location } from './location';\nimport { jsonObjectOrNull } from './json';\nimport { ListResult } from '../list';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Represents the simplified object metadata returned by List API.\n * Other fields are filtered because list in Firebase Rules does not grant\n * the permission to read the metadata.\n */\ninterface ListMetadataResponse {\n name: string;\n bucket: string;\n}\n\n/**\n * Represents the JSON response of List API.\n */\ninterface ListResultResponse {\n prefixes: string[];\n items: ListMetadataResponse[];\n nextPageToken?: string;\n}\n\nconst PREFIXES_KEY = 'prefixes';\nconst ITEMS_KEY = 'items';\n\nfunction fromBackendResponse(\n service: FirebaseStorageImpl,\n bucket: string,\n resource: ListResultResponse\n): ListResult {\n const listResult: ListResult = {\n prefixes: [],\n items: [],\n nextPageToken: resource['nextPageToken']\n };\n if (resource[PREFIXES_KEY]) {\n for (const path of resource[PREFIXES_KEY]) {\n const pathWithoutTrailingSlash = path.replace(/\\/$/, '');\n const reference = service._makeStorageReference(\n new Location(bucket, pathWithoutTrailingSlash)\n );\n listResult.prefixes.push(reference);\n }\n }\n\n if (resource[ITEMS_KEY]) {\n for (const item of resource[ITEMS_KEY]) {\n const reference = service._makeStorageReference(\n new Location(bucket, item['name'])\n );\n listResult.items.push(reference);\n }\n }\n return listResult;\n}\n\nexport function fromResponseString(\n service: FirebaseStorageImpl,\n bucket: string,\n resourceString: string\n): ListResult | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as unknown as ListResultResponse;\n return fromBackendResponse(service, bucket, resource);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Headers, Connection, ConnectionType } from './connection';\n\n/**\n * Type for url params stored in RequestInfo.\n */\nexport interface UrlParams {\n [name: string]: string | number;\n}\n\n/**\n * A function that converts a server response to the API type expected by the\n * SDK.\n *\n * @param I - the type of the backend's network response\n * @param O - the output response type used by the rest of the SDK.\n */\nexport type RequestHandler<I extends ConnectionType, O> = (\n connection: Connection<I>,\n response: I\n) => O;\n\n/** A function to handle an error. */\nexport type ErrorHandler = (\n connection: Connection<ConnectionType>,\n response: StorageError\n) => StorageError;\n\n/**\n * Contains a fully specified request.\n *\n * @param I - the type of the backend's network response.\n * @param O - the output response type used by the rest of the SDK.\n */\nexport class RequestInfo<I extends ConnectionType, O> {\n urlParams: UrlParams = {};\n headers: Headers = {};\n body: Blob | string | Uint8Array | null = null;\n errorHandler: ErrorHandler | null = null;\n\n /**\n * Called with the current number of bytes uploaded and total size (-1 if not\n * computable) of the request body (i.e. used to report upload progress).\n */\n progressCallback: ((p1: number, p2: number) => void) | null = null;\n successCodes: number[] = [200];\n additionalRetryCodes: number[] = [];\n\n constructor(\n public url: string,\n public method: string,\n /**\n * Returns the value with which to resolve the request's promise. Only called\n * if the request is successful. Throw from this function to reject the\n * returned Request's promise with the thrown error.\n * Note: The XhrIo passed to this function may be reused after this callback\n * returns. Do not keep a reference to it in any way.\n */\n public handler: RequestHandler<I, O>,\n public timeout: number\n ) {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods for interacting with the network.\n */\n\nimport { Metadata } from '../metadata';\nimport { ListResult } from '../list';\nimport { FbsBlob } from './blob';\nimport {\n StorageError,\n cannotSliceBlob,\n unauthenticated,\n quotaExceeded,\n unauthorized,\n objectNotFound,\n serverFileWrongSize,\n unknown,\n unauthorizedApp\n} from './error';\nimport { Location } from './location';\nimport {\n Mappings,\n fromResourceString,\n downloadUrlFromResourceString,\n toResourceString\n} from './metadata';\nimport { fromResponseString } from './list';\nimport { RequestInfo, UrlParams } from './requestinfo';\nimport { isString } from './type';\nimport { makeUrl } from './url';\nimport { Connection, ConnectionType } from './connection';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Throws the UNKNOWN StorageError if cndn is false.\n */\nexport function handlerCheck(cndn: boolean): void {\n if (!cndn) {\n throw unknown();\n }\n}\n\nexport function metadataHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => Metadata {\n function handler(xhr: Connection<string>, text: string): Metadata {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return metadata as Metadata;\n }\n return handler;\n}\n\nexport function listHandler(\n service: FirebaseStorageImpl,\n bucket: string\n): (p1: Connection<string>, p2: string) => ListResult {\n function handler(xhr: Connection<string>, text: string): ListResult {\n const listResult = fromResponseString(service, bucket, text);\n handlerCheck(listResult !== null);\n return listResult as ListResult;\n }\n return handler;\n}\n\nexport function downloadUrlHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => string | null {\n function handler(xhr: Connection<string>, text: string): string | null {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return downloadUrlFromResourceString(\n metadata as Metadata,\n text,\n service.host,\n service._protocol\n );\n }\n return handler;\n}\n\nexport function sharedErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr: StorageError;\n if (xhr.getStatus() === 401) {\n if (\n // This exact message string is the only consistent part of the\n // server's error response that identifies it as an App Check error.\n xhr.getErrorText().includes('Firebase App Check token is invalid')\n ) {\n newErr = unauthorizedApp();\n } else {\n newErr = unauthenticated();\n }\n } else {\n if (xhr.getStatus() === 402) {\n newErr = quotaExceeded(location.bucket);\n } else {\n if (xhr.getStatus() === 403) {\n newErr = unauthorized(location.path);\n } else {\n newErr = err;\n }\n }\n }\n newErr.status = xhr.getStatus();\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function objectErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n const shared = sharedErrorHandler(location);\n\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr = shared(xhr, err);\n if (xhr.getStatus() === 404) {\n newErr = objectNotFound(location.path);\n }\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function getMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function list(\n service: FirebaseStorageImpl,\n location: Location,\n delimiter?: string,\n pageToken?: string | null,\n maxResults?: number | null\n): RequestInfo<string, ListResult> {\n const urlParams: UrlParams = {};\n if (location.isRoot) {\n urlParams['prefix'] = '';\n } else {\n urlParams['prefix'] = location.path + '/';\n }\n if (delimiter && delimiter.length > 0) {\n urlParams['delimiter'] = delimiter;\n }\n if (pageToken) {\n urlParams['pageToken'] = pageToken;\n }\n if (maxResults) {\n urlParams['maxResults'] = maxResults;\n }\n const urlPart = location.bucketOnlyServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n listHandler(service, location.bucket),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\nexport function getBytes<I extends ConnectionType>(\n service: FirebaseStorageImpl,\n location: Location,\n maxDownloadSizeBytes?: number\n): RequestInfo<I, I> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n (_: Connection<I>, data: I) => data,\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n if (maxDownloadSizeBytes !== undefined) {\n requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;\n requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];\n }\n return requestInfo;\n}\n\nexport function getDownloadUrl(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, string | null> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n downloadUrlHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function updateMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n metadata: Partial<Metadata>,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'PATCH';\n const body = toResourceString(metadata, mappings);\n const headers = { 'Content-Type': 'application/json; charset=utf-8' };\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function deleteObject(\n service: FirebaseStorageImpl,\n location: Location\n): RequestInfo<string, void> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'DELETE';\n const timeout = service.maxOperationRetryTime;\n\n function handler(_xhr: Connection<string>, _text: string): void {}\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.successCodes = [200, 204];\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function determineContentType_(\n metadata: Metadata | null,\n blob: FbsBlob | null\n): string {\n return (\n (metadata && metadata['contentType']) ||\n (blob && blob.type()) ||\n 'application/octet-stream'\n );\n}\n\nexport function metadataForUpload_(\n location: Location,\n blob: FbsBlob,\n metadata?: Metadata | null\n): Metadata {\n const metadataClone = Object.assign({}, metadata);\n metadataClone['fullPath'] = location.path;\n metadataClone['size'] = blob.size();\n if (!metadataClone['contentType']) {\n metadataClone['contentType'] = determineContentType_(null, blob);\n }\n return metadataClone;\n}\n\n/**\n * Prepare RequestInfo for uploads as Content-Type: multipart.\n */\nexport function multipartUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, Metadata> {\n const urlPart = location.bucketOnlyServerUrl();\n const headers: { [prop: string]: string } = {\n 'X-Goog-Upload-Protocol': 'multipart'\n };\n\n function genBoundary(): string {\n let str = '';\n for (let i = 0; i < 2; i++) {\n str = str + Math.random().toString().slice(2);\n }\n return str;\n }\n const boundary = genBoundary();\n headers['Content-Type'] = 'multipart/related; boundary=' + boundary;\n const metadata_ = metadataForUpload_(location, blob, metadata);\n const metadataString = toResourceString(metadata_, mappings);\n const preBlobPart =\n '--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: application/json; charset=utf-8\\r\\n\\r\\n' +\n metadataString +\n '\\r\\n--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: ' +\n metadata_['contentType'] +\n '\\r\\n\\r\\n';\n const postBlobPart = '\\r\\n--' + boundary + '--';\n const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);\n if (body === null) {\n throw cannotSliceBlob();\n }\n const urlParams: UrlParams = { name: metadata_['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param current The number of bytes that have been uploaded so far.\n * @param total The total number of bytes in the upload.\n * @param opt_finalized True if the server has finished the upload.\n * @param opt_metadata The upload metadata, should\n * only be passed if opt_finalized is true.\n */\nexport class ResumableUploadStatus {\n finalized: boolean;\n metadata: Metadata | null;\n\n constructor(\n public current: number,\n public total: number,\n finalized?: boolean,\n metadata?: Metadata | null\n ) {\n this.finalized = !!finalized;\n this.metadata = metadata || null;\n }\n}\n\nexport function checkResumeHeader_(\n xhr: Connection<string>,\n allowed?: string[]\n): string {\n let status: string | null = null;\n try {\n status = xhr.getResponseHeader('X-Goog-Upload-Status');\n } catch (e) {\n handlerCheck(false);\n }\n const allowedStatus = allowed || ['active'];\n handlerCheck(!!status && allowedStatus.indexOf(status) !== -1);\n return status as string;\n}\n\nexport function createResumableUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, string> {\n const urlPart = location.bucketOnlyServerUrl();\n const metadataForUpload = metadataForUpload_(location, blob, metadata);\n const urlParams: UrlParams = { name: metadataForUpload['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const headers = {\n 'X-Goog-Upload-Protocol': 'resumable',\n 'X-Goog-Upload-Command': 'start',\n 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`,\n 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType']!,\n 'Content-Type': 'application/json; charset=utf-8'\n };\n const body = toResourceString(metadataForUpload, mappings);\n const timeout = service.maxUploadRetryTime;\n\n function handler(xhr: Connection<string>): string {\n checkResumeHeader_(xhr);\n let url;\n try {\n url = xhr.getResponseHeader('X-Goog-Upload-URL');\n } catch (e) {\n handlerCheck(false);\n }\n handlerCheck(isString(url));\n return url as string;\n }\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n */\nexport function getResumableUploadStatus(\n service: FirebaseStorageImpl,\n location: Location,\n url: string,\n blob: FbsBlob\n): RequestInfo<string, ResumableUploadStatus> {\n const headers = { 'X-Goog-Upload-Command': 'query' };\n\n function handler(xhr: Connection<string>): ResumableUploadStatus {\n const status = checkResumeHeader_(xhr, ['active', 'final']);\n let sizeString: string | null = null;\n try {\n sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received');\n } catch (e) {\n handlerCheck(false);\n }\n\n if (!sizeString) {\n // null or empty string\n handlerCheck(false);\n }\n\n const size = Number(sizeString);\n handlerCheck(!isNaN(size));\n return new ResumableUploadStatus(size, blob.size(), status === 'final');\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * Any uploads via the resumable upload API must transfer a number of bytes\n * that is a multiple of this number.\n */\nexport const RESUMABLE_UPLOAD_CHUNK_SIZE: number = 256 * 1024;\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n * @param chunkSize Number of bytes to upload.\n * @param status The previous status.\n * If not passed or null, we start from the beginning.\n * @throws fbs.Error If the upload is already complete, the passed in status\n * has a final size inconsistent with the blob, or the blob cannot be sliced\n * for upload.\n */\nexport function continueResumableUpload(\n location: Location,\n service: FirebaseStorageImpl,\n url: string,\n blob: FbsBlob,\n chunkSize: number,\n mappings: Mappings,\n status?: ResumableUploadStatus | null,\n progressCallback?: ((p1: number, p2: number) => void) | null\n): RequestInfo<string, ResumableUploadStatus> {\n // TODO(andysoto): standardize on internal asserts\n // assert(!(opt_status && opt_status.finalized));\n const status_ = new ResumableUploadStatus(0, 0);\n if (status) {\n status_.current = status.current;\n status_.total = status.total;\n } else {\n status_.current = 0;\n status_.total = blob.size();\n }\n if (blob.size() !== status_.total) {\n throw serverFileWrongSize();\n }\n const bytesLeft = status_.total - status_.current;\n let bytesToUpload = bytesLeft;\n if (chunkSize > 0) {\n bytesToUpload = Math.min(bytesToUpload, chunkSize);\n }\n const startByte = status_.current;\n const endByte = startByte + bytesToUpload;\n let uploadCommand = '';\n if (bytesToUpload === 0) {\n uploadCommand = 'finalize';\n } else if (bytesLeft === bytesToUpload) {\n uploadCommand = 'upload, finalize';\n } else {\n uploadCommand = 'upload';\n }\n const headers = {\n 'X-Goog-Upload-Command': uploadCommand,\n 'X-Goog-Upload-Offset': `${status_.current}`\n };\n const body = blob.slice(startByte, endByte);\n if (body === null) {\n throw cannotSliceBlob();\n }\n\n function handler(\n xhr: Connection<string>,\n text: string\n ): ResumableUploadStatus {\n // TODO(andysoto): Verify the MD5 of each uploaded range:\n // the 'x-range-md5' header comes back with status code 308 responses.\n // We'll only be able to bail out though, because you can't re-upload a\n // range that you previously uploaded.\n const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']);\n const newCurrent = status_.current + bytesToUpload;\n const size = blob.size();\n let metadata;\n if (uploadStatus === 'final') {\n metadata = metadataHandler(service, mappings)(xhr, text);\n } else {\n metadata = null;\n }\n return new ResumableUploadStatus(\n newCurrent,\n size,\n uploadStatus === 'final',\n metadata\n );\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.progressCallback = progressCallback || null;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Enumerations used for upload tasks.\n */\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport type TaskEvent = string;\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport const TaskEvent = {\n /**\n * For this event,\n * <ul>\n * <li>The `next` function is triggered on progress updates and when the\n * task is paused/resumed with an `UploadTaskSnapshot` as the first\n * argument.</li>\n * <li>The `error` function is triggered if the upload is canceled or fails\n * for another reason.</li>\n * <li>The `complete` function is triggered if the upload completes\n * successfully.</li>\n * </ul>\n */\n STATE_CHANGED: 'state_changed'\n};\n\n/**\n * Internal enum for task state.\n */\nexport const enum InternalTaskState {\n RUNNING = 'running',\n PAUSING = 'pausing',\n PAUSED = 'paused',\n SUCCESS = 'success',\n CANCELING = 'canceling',\n CANCELED = 'canceled',\n ERROR = 'error'\n}\n\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport type TaskState = (typeof TaskState)[keyof typeof TaskState];\n\n// type keys = keyof TaskState\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport const TaskState = {\n /** The task is currently transferring data. */\n RUNNING: 'running',\n\n /** The task was paused by the user. */\n PAUSED: 'paused',\n\n /** The task completed successfully. */\n SUCCESS: 'success',\n\n /** The task was canceled. */\n CANCELED: 'canceled',\n\n /** The task failed with an error. */\n ERROR: 'error'\n} as const;\n\nexport function taskStateFromInternalTaskState(\n state: InternalTaskState\n): TaskState {\n switch (state) {\n case InternalTaskState.RUNNING:\n case InternalTaskState.PAUSING:\n case InternalTaskState.CANCELING:\n return TaskState.RUNNING;\n case InternalTaskState.PAUSED:\n return TaskState.PAUSED;\n case InternalTaskState.SUCCESS:\n return TaskState.SUCCESS;\n case InternalTaskState.CANCELED:\n return TaskState.CANCELED;\n case InternalTaskState.ERROR:\n return TaskState.ERROR;\n default:\n // TODO(andysoto): assert(false);\n return TaskState.ERROR;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isFunction } from './type';\nimport { StorageError } from './error';\n\n/**\n * Function that is called once for each value in a stream of values.\n */\nexport type NextFn<T> = (value: T) => void;\n\n/**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\nexport type ErrorFn = (error: StorageError) => void;\n\n/**\n * A function that is called if the event stream ends normally.\n */\nexport type CompleteFn = () => void;\n\n/**\n * Unsubscribes from a stream.\n */\nexport type Unsubscribe = () => void;\n\n/**\n * An observer identical to the `Observer` defined in packages/util except the\n * error passed into the ErrorFn is specifically a `StorageError`.\n */\nexport interface StorageObserver<T> {\n /**\n * Function that is called once for each value in the event stream.\n */\n next?: NextFn<T>;\n /**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\n error?: ErrorFn;\n /**\n * A function that is called if the event stream ends normally.\n */\n complete?: CompleteFn;\n}\n\n/**\n * Subscribes to an event stream.\n */\nexport type Subscribe<T> = (\n next?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n) => Unsubscribe;\n\nexport class Observer<T> implements StorageObserver<T> {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n\n constructor(\n nextOrObserver?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n ) {\n const asFunctions =\n isFunction(nextOrObserver) || error != null || complete != null;\n if (asFunctions) {\n this.next = nextOrObserver as NextFn<T>;\n this.error = error ?? undefined;\n this.complete = complete ?? undefined;\n } else {\n const observer = nextOrObserver as {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n };\n this.next = observer.next;\n this.error = observer.error;\n this.complete = observer.complete;\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a function that invokes f with its arguments asynchronously as a\n * microtask, i.e. as soon as possible after the current script returns back\n * into browser code.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function async(f: Function): Function {\n return (...argsToForward: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => f(...argsToForward));\n };\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isCloudWorkstation } from '@firebase/util';\nimport {\n Connection,\n ConnectionType,\n ErrorCode,\n Headers\n} from '../../implementation/connection';\nimport { internalError } from '../../implementation/error';\n\n/** An override for the text-based Connection. Used in tests. */\nlet textFactoryOverride: (() => Connection<string>) | null = null;\n\n/**\n * Network layer for browsers. We use this instead of goog.net.XhrIo because\n * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.\n */\nabstract class XhrConnection<T extends ConnectionType>\n implements Connection<T>\n{\n protected xhr_: XMLHttpRequest;\n private errorCode_: ErrorCode;\n private sendPromise_: Promise<void>;\n protected sent_: boolean = false;\n\n constructor() {\n this.xhr_ = new XMLHttpRequest();\n this.initXhr();\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.sendPromise_ = new Promise(resolve => {\n this.xhr_.addEventListener('abort', () => {\n this.errorCode_ = ErrorCode.ABORT;\n resolve();\n });\n this.xhr_.addEventListener('error', () => {\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n resolve();\n });\n this.xhr_.addEventListener('load', () => {\n resolve();\n });\n });\n }\n\n abstract initXhr(): void;\n\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string,\n headers?: Headers\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n if (isCloudWorkstation(url) && isUsingEmulator) {\n this.xhr_.withCredentials = true;\n }\n this.sent_ = true;\n this.xhr_.open(method, url, true);\n if (headers !== undefined) {\n for (const key in headers) {\n if (headers.hasOwnProperty(key)) {\n this.xhr_.setRequestHeader(key, headers[key].toString());\n }\n }\n }\n if (body !== undefined) {\n this.xhr_.send(body);\n } else {\n this.xhr_.send();\n }\n return this.sendPromise_;\n }\n\n getErrorCode(): ErrorCode {\n if (!this.sent_) {\n throw internalError('cannot .getErrorCode() before sending');\n }\n return this.errorCode_;\n }\n\n getStatus(): number {\n if (!this.sent_) {\n throw internalError('cannot .getStatus() before sending');\n }\n try {\n return this.xhr_.status;\n } catch (e) {\n return -1;\n }\n }\n\n getResponse(): T {\n if (!this.sent_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.xhr_.response;\n }\n\n getErrorText(): string {\n if (!this.sent_) {\n throw internalError('cannot .getErrorText() before sending');\n }\n return this.xhr_.statusText;\n }\n\n /** Aborts the request. */\n abort(): void {\n this.xhr_.abort();\n }\n\n getResponseHeader(header: string): string | null {\n return this.xhr_.getResponseHeader(header);\n }\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n if (this.xhr_.upload != null) {\n this.xhr_.upload.addEventListener('progress', listener);\n }\n }\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n if (this.xhr_.upload != null) {\n this.xhr_.upload.removeEventListener('progress', listener);\n }\n }\n}\n\nexport class XhrTextConnection extends XhrConnection<string> {\n initXhr(): void {\n this.xhr_.responseType = 'text';\n }\n}\n\nexport function newTextConnection(): Connection<string> {\n return textFactoryOverride ? textFactoryOverride() : new XhrTextConnection();\n}\n\nexport class XhrBytesConnection extends XhrConnection<ArrayBuffer> {\n private data_?: ArrayBuffer;\n\n initXhr(): void {\n this.xhr_.responseType = 'arraybuffer';\n }\n}\n\nexport function newBytesConnection(): Connection<ArrayBuffer> {\n return new XhrBytesConnection();\n}\n\nexport class XhrBlobConnection extends XhrConnection<Blob> {\n initXhr(): void {\n this.xhr_.responseType = 'blob';\n }\n}\n\nexport function newBlobConnection(): Connection<Blob> {\n return new XhrBlobConnection();\n}\n\nexport function newStreamConnection(): Connection<ReadableStream> {\n throw new Error('Streams are only supported on Node');\n}\n\nexport function injectTestConnection(\n factory: (() => Connection<string>) | null\n): void {\n textFactoryOverride = factory;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Defines types for interacting with blob transfer tasks.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport {\n canceled,\n StorageErrorCode,\n StorageError,\n retryLimitExceeded\n} from './implementation/error';\nimport {\n InternalTaskState,\n TaskEvent,\n TaskState,\n taskStateFromInternalTaskState\n} from './implementation/taskenums';\nimport { Metadata } from './metadata';\nimport {\n Observer,\n Subscribe,\n Unsubscribe,\n StorageObserver as StorageObserverInternal,\n NextFn\n} from './implementation/observer';\nimport { Request } from './implementation/request';\nimport { UploadTaskSnapshot, StorageObserver } from './public-types';\nimport { async as fbsAsync } from './implementation/async';\nimport { Mappings, getMappings } from './implementation/metadata';\nimport {\n createResumableUpload,\n getResumableUploadStatus,\n RESUMABLE_UPLOAD_CHUNK_SIZE,\n ResumableUploadStatus,\n continueResumableUpload,\n getMetadata,\n multipartUpload\n} from './implementation/requests';\nimport { Reference } from './reference';\nimport { newTextConnection } from './platform/connection';\nimport { isRetryStatusCode } from './implementation/utils';\nimport { CompleteFn } from '@firebase/util';\nimport { DEFAULT_MIN_SLEEP_TIME_MILLIS } from './implementation/constants';\n\n/**\n * Represents a blob being uploaded. Can be used to pause/resume/cancel the\n * upload and manage callbacks for various events.\n * @internal\n */\nexport class UploadTask {\n private _ref: Reference;\n /**\n * The data to be uploaded.\n */\n _blob: FbsBlob;\n /**\n * Metadata related to the upload.\n */\n _metadata: Metadata | null;\n private _mappings: Mappings;\n /**\n * Number of bytes transferred so far.\n */\n _transferred: number = 0;\n private _needToFetchStatus: boolean = false;\n private _needToFetchMetadata: boolean = false;\n private _observers: Array<StorageObserverInternal<UploadTaskSnapshot>> = [];\n private _resumable: boolean;\n /**\n * Upload state.\n */\n _state: InternalTaskState;\n private _error?: StorageError = undefined;\n private _uploadUrl?: string = undefined;\n private _request?: Request<unknown> = undefined;\n private _chunkMultiplier: number = 1;\n private _errorHandler: (p1: StorageError) => void;\n private _metadataErrorHandler: (p1: StorageError) => void;\n private _resolve?: (p1: UploadTaskSnapshot) => void = undefined;\n private _reject?: (p1: StorageError) => void = undefined;\n private pendingTimeout?: ReturnType<typeof setTimeout>;\n private _promise: Promise<UploadTaskSnapshot>;\n\n private sleepTime: number;\n\n private maxSleepTime: number;\n\n isExponentialBackoffExpired(): boolean {\n return this.sleepTime > this.maxSleepTime;\n }\n\n /**\n * @param ref - The firebaseStorage.Reference object this task came\n * from, untyped to avoid cyclic dependencies.\n * @param blob - The blob to upload.\n */\n constructor(ref: Reference, blob: FbsBlob, metadata: Metadata | null = null) {\n this._ref = ref;\n this._blob = blob;\n this._metadata = metadata;\n this._mappings = getMappings();\n this._resumable = this._shouldDoResumable(this._blob);\n this._state = InternalTaskState.RUNNING;\n this._errorHandler = error => {\n this._request = undefined;\n this._chunkMultiplier = 1;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this._needToFetchStatus = true;\n this.completeTransitions_();\n } else {\n const backoffExpired = this.isExponentialBackoffExpired();\n if (isRetryStatusCode(error.status, [])) {\n if (backoffExpired) {\n error = retryLimitExceeded();\n } else {\n this.sleepTime = Math.max(\n this.sleepTime * 2,\n DEFAULT_MIN_SLEEP_TIME_MILLIS\n );\n this._needToFetchStatus = true;\n this.completeTransitions_();\n return;\n }\n }\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this._metadataErrorHandler = error => {\n this._request = undefined;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this.completeTransitions_();\n } else {\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this.sleepTime = 0;\n this.maxSleepTime = this._ref.storage.maxUploadRetryTime;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n this._start();\n });\n\n // Prevent uncaught rejections on the internal promise from bubbling out\n // to the top level with a dummy handler.\n this._promise.then(null, () => {});\n }\n\n private _makeProgressCallback(): (p1: number, p2: number) => void {\n const sizeBefore = this._transferred;\n return loaded => this._updateProgress(sizeBefore + loaded);\n }\n\n private _shouldDoResumable(blob: FbsBlob): boolean {\n return blob.size() > 256 * 1024;\n }\n\n private _start(): void {\n if (this._state !== InternalTaskState.RUNNING) {\n // This can happen if someone pauses us in a resume callback, for example.\n return;\n }\n if (this._request !== undefined) {\n return;\n }\n if (this._resumable) {\n if (this._uploadUrl === undefined) {\n this._createResumable();\n } else {\n if (this._needToFetchStatus) {\n this._fetchStatus();\n } else {\n if (this._needToFetchMetadata) {\n // Happens if we miss the metadata on upload completion.\n this._fetchMetadata();\n } else {\n this.pendingTimeout = setTimeout(() => {\n this.pendingTimeout = undefined;\n this._continueUpload();\n }, this.sleepTime);\n }\n }\n }\n } else {\n this._oneShotUpload();\n }\n }\n\n private _resolveToken(\n callback: (authToken: string | null, appCheckToken: string | null) => void\n ): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all([\n this._ref.storage._getAuthToken(),\n this._ref.storage._getAppCheckToken()\n ]).then(([authToken, appCheckToken]) => {\n switch (this._state) {\n case InternalTaskState.RUNNING:\n callback(authToken, appCheckToken);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n default:\n }\n });\n }\n\n // TODO(andysoto): assert false\n\n private _createResumable(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = createResumableUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const createRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = createRequest;\n createRequest.getPromise().then((url: string) => {\n this._request = undefined;\n this._uploadUrl = url;\n this._needToFetchStatus = false;\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _fetchStatus(): void {\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getResumableUploadStatus(\n this._ref.storage,\n this._ref._location,\n url,\n this._blob\n );\n const statusRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = statusRequest;\n statusRequest.getPromise().then(status => {\n status = status as ResumableUploadStatus;\n this._request = undefined;\n this._updateProgress(status.current);\n this._needToFetchStatus = false;\n if (status.finalized) {\n this._needToFetchMetadata = true;\n }\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _continueUpload(): void {\n const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n const status = new ResumableUploadStatus(\n this._transferred,\n this._blob.size()\n );\n\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n let requestInfo;\n try {\n requestInfo = continueResumableUpload(\n this._ref._location,\n this._ref.storage,\n url,\n this._blob,\n chunkSize,\n this._mappings,\n status,\n this._makeProgressCallback()\n );\n } catch (e) {\n this._error = e as StorageError;\n this._transition(InternalTaskState.ERROR);\n return;\n }\n const uploadRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken,\n /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file.\n );\n this._request = uploadRequest;\n uploadRequest.getPromise().then((newStatus: ResumableUploadStatus) => {\n this._increaseMultiplier();\n this._request = undefined;\n this._updateProgress(newStatus.current);\n if (newStatus.finalized) {\n this._metadata = newStatus.metadata;\n this._transition(InternalTaskState.SUCCESS);\n } else {\n this.completeTransitions_();\n }\n }, this._errorHandler);\n });\n }\n\n private _increaseMultiplier(): void {\n const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n\n // Max chunk size is 32M.\n if (currentSize * 2 < 32 * 1024 * 1024) {\n this._chunkMultiplier *= 2;\n }\n }\n\n private _fetchMetadata(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getMetadata(\n this._ref.storage,\n this._ref._location,\n this._mappings\n );\n const metadataRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = metadataRequest;\n metadataRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._transition(InternalTaskState.SUCCESS);\n }, this._metadataErrorHandler);\n });\n }\n\n private _oneShotUpload(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = multipartUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const multipartRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = multipartRequest;\n multipartRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._updateProgress(this._blob.size());\n this._transition(InternalTaskState.SUCCESS);\n }, this._errorHandler);\n });\n }\n\n private _updateProgress(transferred: number): void {\n const old = this._transferred;\n this._transferred = transferred;\n\n // A progress update can make the \"transferred\" value smaller (e.g. a\n // partial upload not completed by server, after which the \"transferred\"\n // value may reset to the value at the beginning of the request).\n if (this._transferred !== old) {\n this._notifyObservers();\n }\n }\n\n private _transition(state: InternalTaskState): void {\n if (this._state === state) {\n return;\n }\n switch (state) {\n case InternalTaskState.CANCELING:\n case InternalTaskState.PAUSING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n if (this._request !== undefined) {\n this._request.cancel();\n } else if (this.pendingTimeout) {\n clearTimeout(this.pendingTimeout);\n this.pendingTimeout = undefined;\n this.completeTransitions_();\n }\n break;\n case InternalTaskState.RUNNING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.PAUSING);\n const wasPaused = this._state === InternalTaskState.PAUSED;\n this._state = state;\n if (wasPaused) {\n this._notifyObservers();\n this._start();\n }\n break;\n case InternalTaskState.PAUSED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.CANCELED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.CANCELING);\n this._error = canceled();\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.ERROR:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.SUCCESS:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n default: // Ignore\n }\n }\n\n private completeTransitions_(): void {\n switch (this._state) {\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.RUNNING:\n this._start();\n break;\n default:\n // TODO(andysoto): assert(false);\n break;\n }\n }\n\n /**\n * A snapshot of the current task state.\n */\n get snapshot(): UploadTaskSnapshot {\n const externalState = taskStateFromInternalTaskState(this._state);\n return {\n bytesTransferred: this._transferred,\n totalBytes: this._blob.size(),\n state: externalState,\n metadata: this._metadata!,\n task: this,\n ref: this._ref\n };\n }\n\n /**\n * Adds a callback for an event.\n * @param type - The type of event to listen for.\n * @param nextOrObserver -\n * The `next` function, which gets called for each item in\n * the event stream, or an observer object with some or all of these three\n * properties (`next`, `error`, `complete`).\n * @param error - A function that gets called with a `StorageError`\n * if the event stream ends due to an error.\n * @param completed - A function that gets called if the\n * event stream ends normally.\n * @returns\n * If only the event argument is passed, returns a function you can use to\n * add callbacks (see the examples above). If more than just the event\n * argument is passed, returns a function you can call to unregister the\n * callbacks.\n */\n on(\n type: TaskEvent,\n nextOrObserver?:\n | StorageObserver<UploadTaskSnapshot>\n | null\n | ((snapshot: UploadTaskSnapshot) => unknown),\n error?: ((a: StorageError) => unknown) | null,\n completed?: CompleteFn | null\n ): Unsubscribe | Subscribe<UploadTaskSnapshot> {\n // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string.\n const observer = new Observer(\n (nextOrObserver as\n | StorageObserverInternal<UploadTaskSnapshot>\n | NextFn<UploadTaskSnapshot>) || undefined,\n error || undefined,\n completed || undefined\n );\n this._addObserver(observer);\n return () => {\n this._removeObserver(observer);\n };\n }\n\n /**\n * This object behaves like a Promise, and resolves with its snapshot data\n * when the upload completes.\n * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.\n * @param onRejected - The rejection callback.\n */\n then<U>(\n onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null,\n onRejected?: ((error: StorageError) => U | Promise<U>) | null\n ): Promise<U> {\n // These casts are needed so that TypeScript can infer the types of the\n // resulting Promise.\n return this._promise.then<U>(\n onFulfilled as (value: UploadTaskSnapshot) => U | Promise<U>,\n onRejected as ((error: unknown) => Promise<never>) | null\n );\n }\n\n /**\n * Equivalent to calling `then(null, onRejected)`.\n */\n catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T> {\n return this.then(null, onRejected);\n }\n\n /**\n * Adds the given observer.\n */\n private _addObserver(observer: Observer<UploadTaskSnapshot>): void {\n this._observers.push(observer);\n this._notifyObserver(observer);\n }\n\n /**\n * Removes the given observer.\n */\n private _removeObserver(observer: Observer<UploadTaskSnapshot>): void {\n const i = this._observers.indexOf(observer);\n if (i !== -1) {\n this._observers.splice(i, 1);\n }\n }\n\n private _notifyObservers(): void {\n this._finishPromise();\n const observers = this._observers.slice();\n observers.forEach(observer => {\n this._notifyObserver(observer);\n });\n }\n\n private _finishPromise(): void {\n if (this._resolve !== undefined) {\n let triggered = true;\n switch (taskStateFromInternalTaskState(this._state)) {\n case TaskState.SUCCESS:\n fbsAsync(this._resolve.bind(null, this.snapshot))();\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n const toCall = this._reject as (p1: StorageError) => void;\n fbsAsync(toCall.bind(null, this._error as StorageError))();\n break;\n default:\n triggered = false;\n break;\n }\n if (triggered) {\n this._resolve = undefined;\n this._reject = undefined;\n }\n }\n }\n\n private _notifyObserver(observer: Observer<UploadTaskSnapshot>): void {\n const externalState = taskStateFromInternalTaskState(this._state);\n switch (externalState) {\n case TaskState.RUNNING:\n case TaskState.PAUSED:\n if (observer.next) {\n fbsAsync(observer.next.bind(observer, this.snapshot))();\n }\n break;\n case TaskState.SUCCESS:\n if (observer.complete) {\n fbsAsync(observer.complete.bind(observer))();\n }\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n break;\n default:\n // TODO(andysoto): assert(false);\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n }\n }\n\n /**\n * Resumes a paused task. Has no effect on a currently running or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n resume(): boolean {\n const valid =\n this._state === InternalTaskState.PAUSED ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.RUNNING);\n }\n return valid;\n }\n\n /**\n * Pauses a currently running task. Has no effect on a paused or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n pause(): boolean {\n const valid = this._state === InternalTaskState.RUNNING;\n if (valid) {\n this._transition(InternalTaskState.PAUSING);\n }\n return valid;\n }\n\n /**\n * Cancels a currently running or paused task. Has no effect on a complete or\n * failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n cancel(): boolean {\n const valid =\n this._state === InternalTaskState.RUNNING ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.CANCELING);\n }\n return valid;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines the Firebase StorageReference class.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport { Location } from './implementation/location';\nimport { getMappings } from './implementation/metadata';\nimport { child, lastComponent, parent } from './implementation/path';\nimport {\n deleteObject as requestsDeleteObject,\n getBytes,\n getDownloadUrl as requestsGetDownloadUrl,\n getMetadata as requestsGetMetadata,\n list as requestsList,\n multipartUpload,\n updateMetadata as requestsUpdateMetadata\n} from './implementation/requests';\nimport { ListOptions, UploadResult } from './public-types';\nimport { dataFromString, StringFormat } from './implementation/string';\nimport { Metadata } from './metadata';\nimport { FirebaseStorageImpl } from './service';\nimport { ListResult } from './list';\nimport { UploadTask } from './task';\nimport { invalidRootOperation, noDownloadURL } from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport {\n newBlobConnection,\n newBytesConnection,\n newStreamConnection,\n newTextConnection\n} from './platform/connection';\nimport { RequestInfo } from './implementation/requestinfo';\n\n/**\n * Provides methods to interact with a bucket in the Firebase Storage service.\n * @internal\n * @param _location - An fbs.location, or the URL at\n * which to base this object, in one of the following forms:\n * gs://<bucket>/<object-path>\n * http[s]://firebasestorage.googleapis.com/\n * <api-version>/b/<bucket>/o/<object-path>\n * Any query or fragment strings will be ignored in the http[s]\n * format. If no value is passed, the storage object will use a URL based on\n * the project ID of the base firebase.App instance.\n */\nexport class Reference {\n _location: Location;\n\n constructor(\n private _service: FirebaseStorageImpl,\n location: string | Location\n ) {\n if (location instanceof Location) {\n this._location = location;\n } else {\n this._location = Location.makeFromUrl(location, _service.host);\n }\n }\n\n /**\n * Returns the URL for the bucket and path this object references,\n * in the form gs://<bucket>/<object-path>\n * @override\n */\n toString(): string {\n return 'gs://' + this._location.bucket + '/' + this._location.path;\n }\n\n protected _newRef(\n service: FirebaseStorageImpl,\n location: Location\n ): Reference {\n return new Reference(service, location);\n }\n\n /**\n * A reference to the root of this object's bucket.\n */\n get root(): Reference {\n const location = new Location(this._location.bucket, '');\n return this._newRef(this._service, location);\n }\n\n /**\n * The name of the bucket containing this reference's object.\n */\n get bucket(): string {\n return this._location.bucket;\n }\n\n /**\n * The full path of this object.\n */\n get fullPath(): string {\n return this._location.path;\n }\n\n /**\n * The short name of this object, which is the last component of the full path.\n * For example, if fullPath is 'full/path/image.png', name is 'image.png'.\n */\n get name(): string {\n return lastComponent(this._location.path);\n }\n\n /**\n * The `StorageService` instance this `StorageReference` is associated with.\n */\n get storage(): FirebaseStorageImpl {\n return this._service;\n }\n\n /**\n * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if\n * this reference is the root.\n */\n get parent(): Reference | null {\n const newPath = parent(this._location.path);\n if (newPath === null) {\n return null;\n }\n const location = new Location(this._location.bucket, newPath);\n return new Reference(this._service, location);\n }\n\n /**\n * Utility function to throw an error in methods that do not accept a root reference.\n */\n _throwIfRoot(name: string): void {\n if (this._location.path === '') {\n throw invalidRootOperation(name);\n }\n }\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded bytes.\n */\nexport function getBytesInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref._throwIfRoot('getBytes');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBytesConnection)\n .then(bytes =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (bytes as ArrayBuffer).slice(0, maxDownloadSizeBytes)\n : (bytes as ArrayBuffer)\n );\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded blob.\n */\nexport function getBlobInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref._throwIfRoot('getBlob');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBlobConnection)\n .then(blob =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (blob as Blob).slice(0, maxDownloadSizeBytes)\n : (blob as Blob)\n );\n}\n\n/** Stream the bytes at the object's location. */\nexport function getStreamInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref._throwIfRoot('getStream');\n const requestInfo: RequestInfo<ReadableStream, ReadableStream> = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n\n // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result\n const newMaxSizeTransform = (n: number): Transformer => {\n let missingBytes = n;\n return {\n transform(chunk, controller: TransformStreamDefaultController) {\n // GCS may not honor the Range header for small files\n if (chunk.length < missingBytes) {\n controller.enqueue(chunk);\n missingBytes -= chunk.length;\n } else {\n controller.enqueue(chunk.slice(0, missingBytes));\n controller.terminate();\n }\n }\n };\n };\n\n const result =\n maxDownloadSizeBytes !== undefined\n ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))\n : new TransformStream(); // The default transformer forwards all chunks to its readable side\n\n ref.storage\n .makeRequestWithTokens(requestInfo, newStreamConnection)\n .then(readableStream => readableStream.pipeThrough(result))\n .catch(err => result.writable.abort(err));\n\n return result.readable;\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n *\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadBytes');\n const requestInfo = multipartUpload(\n ref.storage,\n ref._location,\n getMappings(),\n new FbsBlob(data, true),\n metadata\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(finalMetadata => {\n return {\n metadata: finalMetadata,\n ref\n };\n });\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): UploadTask {\n ref._throwIfRoot('uploadBytesResumable');\n return new UploadTask(ref, new FbsBlob(data), metadata);\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - StorageReference where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the newly uploaded string.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: Reference,\n value: string,\n format: StringFormat = StringFormat.RAW,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadString');\n const data = dataFromString(format, value);\n const metadataClone = { ...metadata } as Metadata;\n if (metadataClone['contentType'] == null && data.contentType != null) {\n metadataClone['contentType'] = data.contentType!;\n }\n return uploadBytes(ref, data.data, metadataClone);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: listAll may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - StorageReference to get list from.\n *\n * @returns A Promise that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: Reference): Promise<ListResult> {\n const accumulator: ListResult = {\n prefixes: [],\n items: []\n };\n return listAllHelper(ref, accumulator).then(() => accumulator);\n}\n\n/**\n * Separated from listAll because async functions can't use \"arguments\".\n * @param ref\n * @param accumulator\n * @param pageToken\n */\nasync function listAllHelper(\n ref: Reference,\n accumulator: ListResult,\n pageToken?: string\n): Promise<void> {\n const opt: ListOptions = {\n // maxResults is 1000 by default.\n pageToken\n };\n const nextPage = await list(ref, opt);\n accumulator.prefixes.push(...nextPage.prefixes);\n accumulator.items.push(...nextPage.items);\n if (nextPage.nextPageToken != null) {\n await listAllHelper(ref, accumulator, nextPage.nextPageToken);\n }\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - StorageReference to get list from.\n * @param options - See ListOptions for details.\n * @returns A Promise that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: Reference,\n options?: ListOptions | null\n): Promise<ListResult> {\n if (options != null) {\n if (typeof options.maxResults === 'number') {\n validateNumber(\n 'options.maxResults',\n /* minValue= */ 1,\n /* maxValue= */ 1000,\n options.maxResults\n );\n }\n }\n const op = options || {};\n const requestInfo = requestsList(\n ref.storage,\n ref._location,\n /*delimiter= */ '/',\n op.pageToken,\n op.maxResults\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - StorageReference to get metadata from.\n */\nexport function getMetadata(ref: Reference): Promise<Metadata> {\n ref._throwIfRoot('getMetadata');\n const requestInfo = requestsGetMetadata(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - StorageReference to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves\n * with the new metadata for this object.\n * See `firebaseStorage.Reference.prototype.getMetadata`\n */\nexport function updateMetadata(\n ref: Reference,\n metadata: Partial<Metadata>\n): Promise<Metadata> {\n ref._throwIfRoot('updateMetadata');\n const requestInfo = requestsUpdateMetadata(\n ref.storage,\n ref._location,\n metadata,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns the download URL for the given Reference.\n * @public\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: Reference): Promise<string> {\n ref._throwIfRoot('getDownloadURL');\n const requestInfo = requestsGetDownloadUrl(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(url => {\n if (url === null) {\n throw noDownloadURL();\n }\n return url;\n });\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - StorageReference for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: Reference): Promise<void> {\n ref._throwIfRoot('deleteObject');\n const requestInfo = requestsDeleteObject(ref.storage, ref._location);\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns reference for object obtained by appending `childPath` to `ref`.\n *\n * @param ref - StorageReference to get child of.\n * @param childPath - Child path from provided ref.\n * @returns A reference to the object obtained by\n * appending childPath, removing any duplicate, beginning, or trailing\n * slashes.\n *\n */\nexport function _getChild(ref: Reference, childPath: string): Reference {\n const newPath = child(ref._location.path, childPath);\n const location = new Location(ref._location.bucket, newPath);\n return new Reference(ref.storage, location);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Location } from './implementation/location';\nimport { FailRequest } from './implementation/failrequest';\nimport { Request, makeRequest } from './implementation/request';\nimport { RequestInfo } from './implementation/requestinfo';\nimport { Reference, _getChild } from './reference';\nimport { Provider } from '@firebase/component';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n FirebaseApp,\n FirebaseOptions,\n _isFirebaseServerApp\n} from '@firebase/app';\nimport {\n CONFIG_STORAGE_BUCKET_KEY,\n DEFAULT_HOST,\n DEFAULT_MAX_OPERATION_RETRY_TIME,\n DEFAULT_MAX_UPLOAD_RETRY_TIME\n} from './implementation/constants';\nimport {\n invalidArgument,\n appDeleted,\n noDefaultBucket\n} from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport { FirebaseStorage } from './public-types';\nimport {\n createMockUserToken,\n EmulatorMockTokenOptions,\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\nimport { Connection, ConnectionType } from './implementation/connection';\n\nexport function isUrl(path?: string): boolean {\n return /^[A-Za-z]+:\\/\\//.test(path as string);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given url.\n */\nfunction refFromURL(service: FirebaseStorageImpl, url: string): Reference {\n return new Reference(service, url);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given path in the default\n * bucket.\n */\nfunction refFromPath(\n ref: FirebaseStorageImpl | Reference,\n path?: string\n): Reference {\n if (ref instanceof FirebaseStorageImpl) {\n const service = ref;\n if (service._bucket == null) {\n throw noDefaultBucket();\n }\n const reference = new Reference(service, service._bucket!);\n if (path != null) {\n return refFromPath(reference, path);\n } else {\n return reference;\n }\n } else {\n // ref is a Reference\n if (path !== undefined) {\n return _getChild(ref, path);\n } else {\n return ref;\n }\n }\n}\n\n/**\n * Returns a storage Reference for the given url.\n * @param storage - `Storage` instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorageImpl, url?: string): Reference;\n/**\n * Returns a storage Reference for the given path in the\n * default bucket.\n * @param storageOrRef - `Storage` service or storage `Reference`.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage\n * instance provided) or returns same reference (if Reference provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorageImpl | Reference,\n path?: string\n): Reference;\nexport function ref(\n serviceOrRef: FirebaseStorageImpl | Reference,\n pathOrUrl?: string\n): Reference | null {\n if (pathOrUrl && isUrl(pathOrUrl)) {\n if (serviceOrRef instanceof FirebaseStorageImpl) {\n return refFromURL(serviceOrRef, pathOrUrl);\n } else {\n throw invalidArgument(\n 'To use ref(service, url), the first argument must be a Storage instance.'\n );\n }\n } else {\n return refFromPath(serviceOrRef, pathOrUrl);\n }\n}\n\nfunction extractBucket(\n host: string,\n config?: FirebaseOptions\n): Location | null {\n const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY];\n if (bucketString == null) {\n return null;\n }\n return Location.makeFromBucketSpec(bucketString, host);\n}\n\nexport function connectStorageEmulator(\n storage: FirebaseStorageImpl,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n storage.host = `${host}:${port}`;\n const useSsl = isCloudWorkstation(host);\n // Workaround to get cookies in Firebase Studio\n if (useSsl) {\n void pingServer(`https://${storage.host}/b`);\n updateEmulatorBanner('Storage', true);\n }\n storage._isUsingEmulator = true;\n storage._protocol = useSsl ? 'https' : 'http';\n const { mockUserToken } = options;\n if (mockUserToken) {\n storage._overrideAuthToken =\n typeof mockUserToken === 'string'\n ? mockUserToken\n : createMockUserToken(mockUserToken, storage.app.options.projectId);\n }\n}\n\n/**\n * A service that provides Firebase Storage Reference instances.\n * @param opt_url - gs:// url to a custom Storage Bucket\n *\n * @internal\n */\nexport class FirebaseStorageImpl implements FirebaseStorage {\n _bucket: Location | null = null;\n /**\n * This string can be in the formats:\n * - host\n * - host:port\n */\n private _host: string = DEFAULT_HOST;\n _protocol: string = 'https';\n protected readonly _appId: string | null = null;\n private readonly _requests: Set<Request<unknown>>;\n private _deleted: boolean = false;\n private _maxOperationRetryTime: number;\n private _maxUploadRetryTime: number;\n _overrideAuthToken?: string;\n\n constructor(\n /**\n * FirebaseApp associated with this StorageService instance.\n */\n readonly app: FirebaseApp,\n readonly _authProvider: Provider<FirebaseAuthInternalName>,\n /**\n * @internal\n */\n readonly _appCheckProvider: Provider<AppCheckInternalComponentName>,\n /**\n * @internal\n */\n readonly _url?: string,\n readonly _firebaseVersion?: string,\n public _isUsingEmulator = false\n ) {\n this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;\n this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;\n this._requests = new Set();\n if (_url != null) {\n this._bucket = Location.makeFromBucketSpec(_url, this._host);\n } else {\n this._bucket = extractBucket(this._host, this.app.options);\n }\n }\n\n /**\n * The host string for this service, in the form of `host` or\n * `host:port`.\n */\n get host(): string {\n return this._host;\n }\n\n set host(host: string) {\n this._host = host;\n if (this._url != null) {\n this._bucket = Location.makeFromBucketSpec(this._url, host);\n } else {\n this._bucket = extractBucket(host, this.app.options);\n }\n }\n\n /**\n * The maximum time to retry uploads in milliseconds.\n */\n get maxUploadRetryTime(): number {\n return this._maxUploadRetryTime;\n }\n\n set maxUploadRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxUploadRetryTime = time;\n }\n\n /**\n * The maximum time to retry operations other than uploads or downloads in\n * milliseconds.\n */\n get maxOperationRetryTime(): number {\n return this._maxOperationRetryTime;\n }\n\n set maxOperationRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxOperationRetryTime = time;\n }\n\n async _getAuthToken(): Promise<string | null> {\n if (this._overrideAuthToken) {\n return this._overrideAuthToken;\n }\n const auth = this._authProvider.getImmediate({ optional: true });\n if (auth) {\n const tokenData = await auth.getToken();\n if (tokenData !== null) {\n return tokenData.accessToken;\n }\n }\n return null;\n }\n\n async _getAppCheckToken(): Promise<string | null> {\n if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) {\n return this.app.settings.appCheckToken;\n }\n const appCheck = this._appCheckProvider.getImmediate({ optional: true });\n if (appCheck) {\n const result = await appCheck.getToken();\n // TODO: What do we want to do if there is an error getting the token?\n // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be\n // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use\n // the token (actual or dummy) to send requests.\n return result.token;\n }\n return null;\n }\n\n /**\n * Stop running requests and prevent more from being created.\n */\n _delete(): Promise<void> {\n if (!this._deleted) {\n this._deleted = true;\n this._requests.forEach(request => request.cancel());\n this._requests.clear();\n }\n return Promise.resolve();\n }\n\n /**\n * Returns a new firebaseStorage.Reference object referencing this StorageService\n * at the given Location.\n */\n _makeStorageReference(loc: Location): Reference {\n return new Reference(this, loc);\n }\n\n /**\n * @param requestInfo - HTTP RequestInfo object\n * @param authToken - Firebase auth token\n */\n _makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>,\n authToken: string | null,\n appCheckToken: string | null,\n retry = true\n ): Request<O> {\n if (!this._deleted) {\n const request = makeRequest(\n requestInfo,\n this._appId,\n authToken,\n appCheckToken,\n requestFactory,\n this._firebaseVersion,\n retry,\n this._isUsingEmulator\n );\n this._requests.add(request);\n // Request removes itself from set when complete.\n request.getPromise().then(\n () => this._requests.delete(request),\n () => this._requests.delete(request)\n );\n return request;\n } else {\n return new FailRequest(appDeleted());\n }\n }\n\n async makeRequestWithTokens<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>\n ): Promise<O> {\n const [authToken, appCheckToken] = await Promise.all([\n this._getAuthToken(),\n this._getAppCheckToken()\n ]);\n\n return this._makeRequest(\n requestInfo,\n requestFactory,\n authToken,\n appCheckToken\n ).getPromise();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Type constant for Firebase Storage.\n */\nexport const STORAGE_TYPE = 'storage';\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { _getProvider, FirebaseApp, getApp } from '@firebase/app';\n\nimport {\n ref as refInternal,\n FirebaseStorageImpl,\n connectStorageEmulator as connectEmulatorInternal\n} from './service';\nimport { Provider } from '@firebase/component';\n\nimport {\n StorageReference,\n FirebaseStorage,\n UploadResult,\n ListOptions,\n ListResult,\n UploadTask,\n SettableMetadata,\n UploadMetadata,\n FullMetadata\n} from './public-types';\nimport { Metadata as MetadataInternal } from './metadata';\nimport {\n uploadBytes as uploadBytesInternal,\n uploadBytesResumable as uploadBytesResumableInternal,\n uploadString as uploadStringInternal,\n getMetadata as getMetadataInternal,\n updateMetadata as updateMetadataInternal,\n list as listInternal,\n listAll as listAllInternal,\n getDownloadURL as getDownloadURLInternal,\n deleteObject as deleteObjectInternal,\n Reference,\n _getChild as _getChildInternal,\n getBytesInternal\n} from './reference';\nimport { STORAGE_TYPE } from './constants';\nimport {\n EmulatorMockTokenOptions,\n getModularInstance,\n getDefaultEmulatorHostnameAndPort\n} from '@firebase/util';\nimport { StringFormat } from './implementation/string';\n\nexport { EmulatorMockTokenOptions } from '@firebase/util';\n\nexport { StorageError, StorageErrorCode } from './implementation/error';\n\n/**\n * Public types.\n */\nexport * from './public-types';\n\nexport { Location as _Location } from './implementation/location';\nexport { UploadTask as _UploadTask } from './task';\nexport type { Reference as _Reference } from './reference';\nexport type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';\nexport { FbsBlob as _FbsBlob } from './implementation/blob';\nexport { dataFromString as _dataFromString } from './implementation/string';\nexport {\n invalidRootOperation as _invalidRootOperation,\n invalidArgument as _invalidArgument\n} from './implementation/error';\nexport {\n TaskEvent as _TaskEvent,\n TaskState as _TaskState\n} from './implementation/taskenums';\nexport { StringFormat };\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise containing the object's bytes\n */\nexport function getBytes(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref = getModularInstance(ref);\n return getBytesInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadBytesInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the string to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: StorageReference,\n value: string,\n format?: StringFormat,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadStringInternal(\n ref as Reference,\n value,\n format,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): UploadTask {\n ref = getModularInstance(ref);\n return uploadBytesResumableInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n ) as UploadTask;\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - {@link StorageReference} to get metadata from.\n */\nexport function getMetadata(ref: StorageReference): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return getMetadataInternal(ref as Reference) as Promise<FullMetadata>;\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - {@link StorageReference} to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves with the new metadata for this object.\n */\nexport function updateMetadata(\n ref: StorageReference,\n metadata: SettableMetadata\n): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return updateMetadataInternal(\n ref as Reference,\n metadata as Partial<MetadataInternal>\n ) as Promise<FullMetadata>;\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - {@link StorageReference} to get list from.\n * @param options - See {@link ListOptions} for details.\n * @returns A `Promise` that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: StorageReference,\n options?: ListOptions\n): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listInternal(ref as Reference, options);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: `listAll` may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - {@link StorageReference} to get list from.\n *\n * @returns A `Promise` that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: StorageReference): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listAllInternal(ref as Reference);\n}\n\n/**\n * Returns the download URL for the given {@link StorageReference}.\n * @public\n * @param ref - {@link StorageReference} to get the download URL for.\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: StorageReference): Promise<string> {\n ref = getModularInstance(ref);\n return getDownloadURLInternal(ref as Reference);\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - {@link StorageReference} for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: StorageReference): Promise<void> {\n ref = getModularInstance(ref);\n return deleteObjectInternal(ref as Reference);\n}\n\n/**\n * Returns a {@link StorageReference} for the given url.\n * @param storage - {@link FirebaseStorage} instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorage, url?: string): StorageReference;\n/**\n * Returns a {@link StorageReference} for the given path in the\n * default bucket.\n * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}\n * instance provided) or returns same reference (if {@link StorageReference} provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorage | StorageReference,\n path?: string\n): StorageReference;\nexport function ref(\n serviceOrRef: FirebaseStorage | StorageReference,\n pathOrUrl?: string\n): StorageReference | null {\n serviceOrRef = getModularInstance(serviceOrRef);\n return refInternal(\n serviceOrRef as FirebaseStorageImpl | Reference,\n pathOrUrl\n );\n}\n\n/**\n * @internal\n */\nexport function _getChild(ref: StorageReference, childPath: string): Reference {\n return _getChildInternal(ref as Reference, childPath);\n}\n\n/**\n * Gets a {@link FirebaseStorage} instance for the given Firebase app.\n * @public\n * @param app - Firebase app to get {@link FirebaseStorage} instance for.\n * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.\n * If not passed, uses the app's default Storage Bucket.\n * @returns A {@link FirebaseStorage} instance.\n */\nexport function getStorage(\n app: FirebaseApp = getApp(),\n bucketUrl?: string\n): FirebaseStorage {\n app = getModularInstance(app);\n const storageProvider: Provider<'storage'> = _getProvider(app, STORAGE_TYPE);\n const storageInstance = storageProvider.getImmediate({\n identifier: bucketUrl\n });\n const emulator = getDefaultEmulatorHostnameAndPort('storage');\n if (emulator) {\n connectStorageEmulator(storageInstance, ...emulator);\n }\n return storageInstance;\n}\n\n/**\n * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.\n *\n * @param storage - The {@link FirebaseStorage} instance\n * @param host - The emulator host (ex: localhost)\n * @param port - The emulator port (ex: 5001)\n * @param options - Emulator options. `options.mockUserToken` is the mock auth\n * token to use for unit testing Security Rules.\n * @public\n */\nexport function connectStorageEmulator(\n storage: FirebaseStorage,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n connectEmulatorInternal(storage as FirebaseStorageImpl, host, port, options);\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StorageReference } from './public-types';\nimport { Reference, getBlobInternal } from './reference';\nimport { getModularInstance } from '@firebase/util';\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * This API is not available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise that resolves with a Blob containing the object's bytes\n */\nexport function getBlob(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref = getModularInstance(ref);\n return getBlobInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Downloads the data at the object's location. Raises an error event if the\n * object is not found.\n *\n * This API is only available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A stream with the object's data as bytes\n */\nexport function getStream(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n throw new Error('getStream() is only supported by NodeJS builds');\n}\n","/**\n * Cloud Storage for Firebase\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n _registerComponent,\n registerVersion,\n SDK_VERSION\n} from '@firebase/app';\n\nimport { FirebaseStorageImpl } from '../src/service';\nimport {\n Component,\n ComponentType,\n ComponentContainer,\n InstanceFactoryOptions\n} from '@firebase/component';\n\nimport { name, version } from '../package.json';\n\nimport { FirebaseStorage } from './public-types';\nimport { STORAGE_TYPE } from './constants';\n\nexport * from './api';\nexport * from './api.browser';\n\nfunction factory(\n container: ComponentContainer,\n { instanceIdentifier: url }: InstanceFactoryOptions\n): FirebaseStorage {\n const app = container.getProvider('app').getImmediate();\n const authProvider = container.getProvider('auth-internal');\n const appCheckProvider = container.getProvider('app-check-internal');\n\n return new FirebaseStorageImpl(\n app,\n authProvider,\n appCheckProvider,\n url,\n SDK_VERSION\n );\n}\n\nfunction registerStorage(): void {\n _registerComponent(\n new Component(\n STORAGE_TYPE,\n factory,\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n //RUNTIME_ENV will be replaced during the compilation to \"node\" for nodejs and an empty string for browser\n registerVersion(name, version, '__RUNTIME_ENV__');\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\nregisterStorage();\n"],"names":["FirebaseError","StorageErrorCode","getBlob","getMetadata","list","getBytes","updateMetadata","deleteObject","isCloudWorkstation","fbsAsync","uploadBytes","uploadBytesResumable","uploadString","listAll","requestsList","requestsGetMetadata","requestsUpdateMetadata","getDownloadURL","requestsGetDownloadUrl","requestsDeleteObject","_getChild","ref","connectStorageEmulator","pingServer","updateEmulatorBanner","createMockUserToken","_isFirebaseServerApp","getModularInstance","uploadBytesInternal","uploadStringInternal","uploadBytesResumableInternal","getMetadataInternal","updateMetadataInternal","listInternal","listAllInternal","getDownloadURLInternal","deleteObjectInternal","refInternal","_getChildInternal","app","getApp","_getProvider","getDefaultEmulatorHostnameAndPort","connectEmulatorInternal","SDK_VERSION","_registerComponent","Component","registerVersion"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AACH;;AAEG;AAEH;;AAEG;AACI,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAE7D;;AAEG;AACI,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAEzD;;;;AAIG;AACI,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9D;;;;AAIG;AACI,MAAM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AAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAErE,IAAA,OAAO,IAAI,mBAAmB,CAC5BA,KAAG,EACH,YAAY,EACZ,gBAAgB,EAChB,GAAG,EACHK,eAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,GAAA;AACtB,IAAAC,sBAAkB,CAChB,IAAIC,mBAAS,CACX,YAAY,EACZ,OAAO,EAER,QAAA,4BAAA,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAC7B,CAAC;;AAEF,IAAAC,mBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,EAAiB,CAAC,CAAC;;AAElD,IAAAA,mBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAkB,CAAC,CAAC;AACrD,CAAC;AAED,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.esm.js b/frontend-old/node_modules/@firebase/storage/dist/index.esm.js deleted file mode 100644 index 53113e6..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.esm.js +++ /dev/null @@ -1,3656 +0,0 @@ -import { _isFirebaseServerApp, _getProvider, getApp, _registerComponent, registerVersion, SDK_VERSION } from '@firebase/app'; -import { FirebaseError, isCloudWorkstation, pingServer, updateEmulatorBanner, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort } from '@firebase/util'; -import { Component } from '@firebase/component'; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -const DEFAULT_HOST = 'firebasestorage.googleapis.com'; -/** - * The key in Firebase config json for the storage bucket. - */ -const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket'; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000; -/** - * 10 minutes - * - * The timeout for upload. - */ -const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000; -/** - * 1 second - */ -const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -class StorageError extends FirebaseError { - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code, message, status_ = 0) { - super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`); - this.status_ = status_; - /** - * Stores custom error data unique to the `StorageError`. - */ - this.customData = { serverResponse: null }; - this._baseMessage = this.message; - // Without this, `instanceof StorageError`, in tests for example, - // returns false. - Object.setPrototypeOf(this, StorageError.prototype); - } - get status() { - return this.status_; - } - set status(status) { - this.status_ = status; - } - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code) { - return prependCode(code) === this.code; - } - /** - * Optional response message that was added by the server. - */ - get serverResponse() { - return this.customData.serverResponse; - } - set serverResponse(serverResponse) { - this.customData.serverResponse = serverResponse; - if (this.customData.serverResponse) { - this.message = `${this._baseMessage}\n${this.customData.serverResponse}`; - } - else { - this.message = this._baseMessage; - } - } -} -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -var StorageErrorCode; -(function (StorageErrorCode) { - // Shared between all platforms - StorageErrorCode["UNKNOWN"] = "unknown"; - StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found"; - StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found"; - StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found"; - StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded"; - StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated"; - StorageErrorCode["UNAUTHORIZED"] = "unauthorized"; - StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app"; - StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded"; - StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum"; - StorageErrorCode["CANCELED"] = "canceled"; - // JS specific - StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name"; - StorageErrorCode["INVALID_URL"] = "invalid-url"; - StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket"; - StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket"; - StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob"; - StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size"; - StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url"; - StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument"; - StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count"; - StorageErrorCode["APP_DELETED"] = "app-deleted"; - StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation"; - StorageErrorCode["INVALID_FORMAT"] = "invalid-format"; - StorageErrorCode["INTERNAL_ERROR"] = "internal-error"; - StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment"; -})(StorageErrorCode || (StorageErrorCode = {})); -function prependCode(code) { - return 'storage/' + code; -} -function unknown() { - const message = 'An unknown error occurred, please check the error payload for ' + - 'server response.'; - return new StorageError(StorageErrorCode.UNKNOWN, message); -} -function objectNotFound(path) { - return new StorageError(StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist."); -} -function quotaExceeded(bucket) { - return new StorageError(StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + - bucket + - "' exceeded, please view quota on " + - 'https://firebase.google.com/pricing/.'); -} -function unauthenticated() { - const message = 'User is not authenticated, please authenticate using Firebase ' + - 'Authentication and try again.'; - return new StorageError(StorageErrorCode.UNAUTHENTICATED, message); -} -function unauthorizedApp() { - return new StorageError(StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.'); -} -function unauthorized(path) { - return new StorageError(StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'."); -} -function retryLimitExceeded() { - return new StorageError(StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.'); -} -function canceled() { - return new StorageError(StorageErrorCode.CANCELED, 'User canceled the upload/download.'); -} -function invalidUrl(url) { - return new StorageError(StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'."); -} -function invalidDefaultBucket(bucket) { - return new StorageError(StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'."); -} -function noDefaultBucket() { - return new StorageError(StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' + - "found. Did you set the '" + - CONFIG_STORAGE_BUCKET_KEY + - "' property when initializing the app?"); -} -function cannotSliceBlob() { - return new StorageError(StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.'); -} -function serverFileWrongSize() { - return new StorageError(StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.'); -} -function noDownloadURL() { - return new StorageError(StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.'); -} -function missingPolyFill(polyFill) { - return new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`); -} -/** - * @internal - */ -function invalidArgument(message) { - return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message); -} -function appDeleted() { - return new StorageError(StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.'); -} -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -function invalidRootOperation(name) { - return new StorageError(StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + - name + - "' cannot be performed on a root reference, create a non-root " + - "reference using child, such as .child('file.png')."); -} -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -function invalidFormat(format, message) { - return new StorageError(StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message); -} -/** - * @param message - A message describing the internal error. - */ -function internalError(message) { - throw new StorageError(StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -class Location { - constructor(bucket, path) { - this.bucket = bucket; - this.path_ = path; - } - get path() { - return this.path_; - } - get isRoot() { - return this.path.length === 0; - } - fullServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o/' + encode(this.path); - } - bucketOnlyServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o'; - } - static makeFromBucketSpec(bucketString, host) { - let bucketLocation; - try { - bucketLocation = Location.makeFromUrl(bucketString, host); - } - catch (e) { - // Not valid URL, use as-is. This lets you put bare bucket names in - // config. - return new Location(bucketString, ''); - } - if (bucketLocation.path === '') { - return bucketLocation; - } - else { - throw invalidDefaultBucket(bucketString); - } - } - static makeFromUrl(url, host) { - let location = null; - const bucketDomain = '([A-Za-z0-9.\\-_]+)'; - function gsModify(loc) { - if (loc.path.charAt(loc.path.length - 1) === '/') { - loc.path_ = loc.path_.slice(0, -1); - } - } - const gsPath = '(/(.*))?$'; - const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i'); - const gsIndices = { bucket: 1, path: 3 }; - function httpModify(loc) { - loc.path_ = decodeURIComponent(loc.path); - } - const version = 'v[A-Za-z0-9_]+'; - const firebaseStorageHost = host.replace(/[.]/g, '\\.'); - const firebaseStoragePath = '(/([^?#]*).*)?$'; - const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`, 'i'); - const firebaseStorageIndices = { bucket: 1, path: 3 }; - const cloudStorageHost = host === DEFAULT_HOST - ? '(?:storage.googleapis.com|storage.cloud.google.com)' - : host; - const cloudStoragePath = '([^?#]*)'; - const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, 'i'); - const cloudStorageIndices = { bucket: 1, path: 2 }; - const groups = [ - { regex: gsRegex, indices: gsIndices, postModify: gsModify }, - { - regex: firebaseStorageRegExp, - indices: firebaseStorageIndices, - postModify: httpModify - }, - { - regex: cloudStorageRegExp, - indices: cloudStorageIndices, - postModify: httpModify - } - ]; - for (let i = 0; i < groups.length; i++) { - const group = groups[i]; - const captures = group.regex.exec(url); - if (captures) { - const bucketValue = captures[group.indices.bucket]; - let pathValue = captures[group.indices.path]; - if (!pathValue) { - pathValue = ''; - } - location = new Location(bucketValue, pathValue); - group.postModify(location); - break; - } - } - if (location == null) { - throw invalidUrl(url); - } - return location; - } -} - -/** - * A request whose promise always fails. - */ -class FailRequest { - constructor(error) { - this.promise_ = Promise.reject(error); - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(_appDelete = false) { } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -function start(doRequest, -// eslint-disable-next-line @typescript-eslint/no-explicit-any -backoffCompleteCb, timeout) { - // TODO(andysoto): make this code cleaner (probably refactor into an actual - // type instead of a bunch of functions with state shared in the closure) - let waitSeconds = 1; - // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯ - // TODO: find a way to exclude Node type definition for storage because storage only works in browser - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let retryTimeoutId = null; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let globalTimeoutId = null; - let hitTimeout = false; - let cancelState = 0; - function canceled() { - return cancelState === 2; - } - let triggeredCallback = false; - function triggerCallback(...args) { - if (!triggeredCallback) { - triggeredCallback = true; - backoffCompleteCb.apply(null, args); - } - } - function callWithDelay(millis) { - retryTimeoutId = setTimeout(() => { - retryTimeoutId = null; - doRequest(responseHandler, canceled()); - }, millis); - } - function clearGlobalTimeout() { - if (globalTimeoutId) { - clearTimeout(globalTimeoutId); - } - } - function responseHandler(success, ...args) { - if (triggeredCallback) { - clearGlobalTimeout(); - return; - } - if (success) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - const mustStop = canceled() || hitTimeout; - if (mustStop) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - if (waitSeconds < 64) { - /* TODO(andysoto): don't back off so quickly if we know we're offline. */ - waitSeconds *= 2; - } - let waitMillis; - if (cancelState === 1) { - cancelState = 2; - waitMillis = 0; - } - else { - waitMillis = (waitSeconds + Math.random()) * 1000; - } - callWithDelay(waitMillis); - } - let stopped = false; - function stop(wasTimeout) { - if (stopped) { - return; - } - stopped = true; - clearGlobalTimeout(); - if (triggeredCallback) { - return; - } - if (retryTimeoutId !== null) { - if (!wasTimeout) { - cancelState = 2; - } - clearTimeout(retryTimeoutId); - callWithDelay(0); - } - else { - if (!wasTimeout) { - cancelState = 1; - } - } - } - callWithDelay(0); - globalTimeoutId = setTimeout(() => { - hitTimeout = true; - stop(true); - }, timeout); - return stop; -} -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -function stop(id) { - id(false); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isJustDef(p) { - return p !== void 0; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function isFunction(p) { - return typeof p === 'function'; -} -function isNonArrayObject(p) { - return typeof p === 'object' && !Array.isArray(p); -} -function isString(p) { - return typeof p === 'string' || p instanceof String; -} -function isNativeBlob(p) { - return isNativeBlobDefined() && p instanceof Blob; -} -function isNativeBlobDefined() { - return typeof Blob !== 'undefined'; -} -function validateNumber(argument, minValue, maxValue, value) { - if (value < minValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`); - } - if (value > maxValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function makeUrl(urlPart, host, protocol) { - let origin = host; - if (protocol == null) { - origin = `https://${host}`; - } - return `${protocol}://${origin}/v0${urlPart}`; -} -function makeQueryString(params) { - const encode = encodeURIComponent; - let queryPart = '?'; - for (const key in params) { - if (params.hasOwnProperty(key)) { - const nextPart = encode(key) + '=' + encode(params[key]); - queryPart = queryPart + nextPart + '&'; - } - } - // Chop off the extra '&' or '?' on the end - queryPart = queryPart.slice(0, -1); - return queryPart; -} - -/** - * Error codes for requests made by the XhrIo wrapper. - */ -var ErrorCode; -(function (ErrorCode) { - ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR"; - ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR"; - ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT"; -})(ErrorCode || (ErrorCode = {})); - -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -function isRetryStatusCode(status, additionalRetryCodes) { - // The codes for which to retry came from this page: - // https://cloud.google.com/storage/docs/exponential-backoff - const isFiveHundredCode = status >= 500 && status < 600; - const extraRetryCodes = [ - // Request Timeout: web server didn't receive full request in time. - 408, - // Too Many Requests: you're getting rate-limited, basically. - 429 - ]; - const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1; - const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1; - return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Handles network logic for all Storage Requests, including error reporting and - * retries with backoff. - * - * @param I - the type of the backend's network response. - * @param - O the output type used by the rest of the SDK. The conversion - * happens in the specified `callback_`. - */ -class NetworkRequest { - constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) { - this.url_ = url_; - this.method_ = method_; - this.headers_ = headers_; - this.body_ = body_; - this.successCodes_ = successCodes_; - this.additionalRetryCodes_ = additionalRetryCodes_; - this.callback_ = callback_; - this.errorCallback_ = errorCallback_; - this.timeout_ = timeout_; - this.progressCallback_ = progressCallback_; - this.connectionFactory_ = connectionFactory_; - this.retry = retry; - this.isUsingEmulator = isUsingEmulator; - this.pendingConnection_ = null; - this.backoffId_ = null; - this.canceled_ = false; - this.appDelete_ = false; - this.promise_ = new Promise((resolve, reject) => { - this.resolve_ = resolve; - this.reject_ = reject; - this.start_(); - }); - } - /** - * Actually starts the retry loop. - */ - start_() { - const doTheRequest = (backoffCallback, canceled) => { - if (canceled) { - backoffCallback(false, new RequestEndStatus(false, null, true)); - return; - } - const connection = this.connectionFactory_(); - this.pendingConnection_ = connection; - const progressListener = progressEvent => { - const loaded = progressEvent.loaded; - const total = progressEvent.lengthComputable ? progressEvent.total : -1; - if (this.progressCallback_ !== null) { - this.progressCallback_(loaded, total); - } - }; - if (this.progressCallback_ !== null) { - connection.addUploadProgressListener(progressListener); - } - // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - connection - .send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_) - .then(() => { - if (this.progressCallback_ !== null) { - connection.removeUploadProgressListener(progressListener); - } - this.pendingConnection_ = null; - const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR; - const status = connection.getStatus(); - if (!hitServer || - (isRetryStatusCode(status, this.additionalRetryCodes_) && - this.retry)) { - const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT; - backoffCallback(false, new RequestEndStatus(false, null, wasCanceled)); - return; - } - const successCode = this.successCodes_.indexOf(status) !== -1; - backoffCallback(true, new RequestEndStatus(successCode, connection)); - }); - }; - /** - * @param requestWentThrough - True if the request eventually went - * through, false if it hit the retry limit or was canceled. - */ - const backoffDone = (requestWentThrough, status) => { - const resolve = this.resolve_; - const reject = this.reject_; - const connection = status.connection; - if (status.wasSuccessCode) { - try { - const result = this.callback_(connection, connection.getResponse()); - if (isJustDef(result)) { - resolve(result); - } - else { - resolve(); - } - } - catch (e) { - reject(e); - } - } - else { - if (connection !== null) { - const err = unknown(); - err.serverResponse = connection.getErrorText(); - if (this.errorCallback_) { - reject(this.errorCallback_(connection, err)); - } - else { - reject(err); - } - } - else { - if (status.canceled) { - const err = this.appDelete_ ? appDeleted() : canceled(); - reject(err); - } - else { - const err = retryLimitExceeded(); - reject(err); - } - } - } - }; - if (this.canceled_) { - backoffDone(false, new RequestEndStatus(false, null, true)); - } - else { - this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_); - } - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(appDelete) { - this.canceled_ = true; - this.appDelete_ = appDelete || false; - if (this.backoffId_ !== null) { - stop(this.backoffId_); - } - if (this.pendingConnection_ !== null) { - this.pendingConnection_.abort(); - } - } -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -class RequestEndStatus { - constructor(wasSuccessCode, connection, canceled) { - this.wasSuccessCode = wasSuccessCode; - this.connection = connection; - this.canceled = !!canceled; - } -} -function addAuthHeader_(headers, authToken) { - if (authToken !== null && authToken.length > 0) { - headers['Authorization'] = 'Firebase ' + authToken; - } -} -function addVersionHeader_(headers, firebaseVersion) { - headers['X-Firebase-Storage-Version'] = - 'webjs/' + (firebaseVersion ?? 'AppManager'); -} -function addGmpidHeader_(headers, appId) { - if (appId) { - headers['X-Firebase-GMPID'] = appId; - } -} -function addAppCheckHeader_(headers, appCheckToken) { - if (appCheckToken !== null) { - headers['X-Firebase-AppCheck'] = appCheckToken; - } -} -function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) { - const queryPart = makeQueryString(requestInfo.urlParams); - const url = requestInfo.url + queryPart; - const headers = Object.assign({}, requestInfo.headers); - addGmpidHeader_(headers, appId); - addAuthHeader_(headers, authToken); - addVersionHeader_(headers, firebaseVersion); - addAppCheckHeader_(headers, appCheckToken); - return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function getBlobBuilder() { - if (typeof BlobBuilder !== 'undefined') { - return BlobBuilder; - } - else if (typeof WebKitBlobBuilder !== 'undefined') { - return WebKitBlobBuilder; - } - else { - return undefined; - } -} -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -function getBlob$1(...args) { - const BlobBuilder = getBlobBuilder(); - if (BlobBuilder !== undefined) { - const bb = new BlobBuilder(); - for (let i = 0; i < args.length; i++) { - bb.append(args[i]); - } - return bb.getBlob(); - } - else { - if (isNativeBlobDefined()) { - return new Blob(args); - } - else { - throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs"); - } - } -} -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -function sliceBlob(blob, start, end) { - if (blob.webkitSlice) { - return blob.webkitSlice(start, end); - } - else if (blob.mozSlice) { - return blob.mozSlice(start, end); - } - else if (blob.slice) { - return blob.slice(start, end); - } - return null; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -function decodeBase64(encoded) { - if (typeof atob === 'undefined') { - throw missingPolyFill('base-64'); - } - return atob(encoded); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -const StringFormat = { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - RAW: 'raw', - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64: 'base64', - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64URL: 'base64url', - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - DATA_URL: 'data_url' -}; -class StringData { - constructor(data, contentType) { - this.data = data; - this.contentType = contentType || null; - } -} -/** - * @internal - */ -function dataFromString(format, stringData) { - switch (format) { - case StringFormat.RAW: - return new StringData(utf8Bytes_(stringData)); - case StringFormat.BASE64: - case StringFormat.BASE64URL: - return new StringData(base64Bytes_(format, stringData)); - case StringFormat.DATA_URL: - return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData)); - // do nothing - } - // assert(false); - throw unknown(); -} -function utf8Bytes_(value) { - const b = []; - for (let i = 0; i < value.length; i++) { - let c = value.charCodeAt(i); - if (c <= 127) { - b.push(c); - } - else { - if (c <= 2047) { - b.push(192 | (c >> 6), 128 | (c & 63)); - } - else { - if ((c & 64512) === 55296) { - // The start of a surrogate pair. - const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320; - if (!valid) { - // The second surrogate wasn't there. - b.push(239, 191, 189); - } - else { - const hi = c; - const lo = value.charCodeAt(++i); - c = 65536 | ((hi & 1023) << 10) | (lo & 1023); - b.push(240 | (c >> 18), 128 | ((c >> 12) & 63), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - else { - if ((c & 64512) === 56320) { - // Invalid low surrogate. - b.push(239, 191, 189); - } - else { - b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - } - } - } - return new Uint8Array(b); -} -function percentEncodedBytes_(value) { - let decoded; - try { - decoded = decodeURIComponent(value); - } - catch (e) { - throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.'); - } - return utf8Bytes_(decoded); -} -function base64Bytes_(format, value) { - switch (format) { - case StringFormat.BASE64: { - const hasMinus = value.indexOf('-') !== -1; - const hasUnder = value.indexOf('_') !== -1; - if (hasMinus || hasUnder) { - const invalidChar = hasMinus ? '-' : '_'; - throw invalidFormat(format, "Invalid character '" + - invalidChar + - "' found: is it base64url encoded?"); - } - break; - } - case StringFormat.BASE64URL: { - const hasPlus = value.indexOf('+') !== -1; - const hasSlash = value.indexOf('/') !== -1; - if (hasPlus || hasSlash) { - const invalidChar = hasPlus ? '+' : '/'; - throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?"); - } - value = value.replace(/-/g, '+').replace(/_/g, '/'); - break; - } - // do nothing - } - let bytes; - try { - bytes = decodeBase64(value); - } - catch (e) { - if (e.message.includes('polyfill')) { - throw e; - } - throw invalidFormat(format, 'Invalid character found'); - } - const array = new Uint8Array(bytes.length); - for (let i = 0; i < bytes.length; i++) { - array[i] = bytes.charCodeAt(i); - } - return array; -} -class DataURLParts { - constructor(dataURL) { - this.base64 = false; - this.contentType = null; - const matches = dataURL.match(/^data:([^,]+)?,/); - if (matches === null) { - throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>"); - } - const middle = matches[1] || null; - if (middle != null) { - this.base64 = endsWith(middle, ';base64'); - this.contentType = this.base64 - ? middle.substring(0, middle.length - ';base64'.length) - : middle; - } - this.rest = dataURL.substring(dataURL.indexOf(',') + 1); - } -} -function dataURLBytes_(dataUrl) { - const parts = new DataURLParts(dataUrl); - if (parts.base64) { - return base64Bytes_(StringFormat.BASE64, parts.rest); - } - else { - return percentEncodedBytes_(parts.rest); - } -} -function dataURLContentType_(dataUrl) { - const parts = new DataURLParts(dataUrl); - return parts.contentType; -} -function endsWith(s, end) { - const longEnough = s.length >= end.length; - if (!longEnough) { - return false; - } - return s.substring(s.length - end.length) === end; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -class FbsBlob { - constructor(data, elideCopy) { - let size = 0; - let blobType = ''; - if (isNativeBlob(data)) { - this.data_ = data; - size = data.size; - blobType = data.type; - } - else if (data instanceof ArrayBuffer) { - if (elideCopy) { - this.data_ = new Uint8Array(data); - } - else { - this.data_ = new Uint8Array(data.byteLength); - this.data_.set(new Uint8Array(data)); - } - size = this.data_.length; - } - else if (data instanceof Uint8Array) { - if (elideCopy) { - this.data_ = data; - } - else { - this.data_ = new Uint8Array(data.length); - this.data_.set(data); - } - size = data.length; - } - this.size_ = size; - this.type_ = blobType; - } - size() { - return this.size_; - } - type() { - return this.type_; - } - slice(startByte, endByte) { - if (isNativeBlob(this.data_)) { - const realBlob = this.data_; - const sliced = sliceBlob(realBlob, startByte, endByte); - if (sliced === null) { - return null; - } - return new FbsBlob(sliced); - } - else { - const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte); - return new FbsBlob(slice, true); - } - } - static getBlob(...args) { - if (isNativeBlobDefined()) { - const blobby = args.map((val) => { - if (val instanceof FbsBlob) { - return val.data_; - } - else { - return val; - } - }); - return new FbsBlob(getBlob$1.apply(null, blobby)); - } - else { - const uint8Arrays = args.map((val) => { - if (isString(val)) { - return dataFromString(StringFormat.RAW, val).data; - } - else { - // Blobs don't exist, so this has to be a Uint8Array. - return val.data_; - } - }); - let finalLength = 0; - uint8Arrays.forEach((array) => { - finalLength += array.byteLength; - }); - const merged = new Uint8Array(finalLength); - let index = 0; - uint8Arrays.forEach((array) => { - for (let i = 0; i < array.length; i++) { - merged[index++] = array[i]; - } - }); - return new FbsBlob(merged, true); - } - } - uploadData() { - return this.data_; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -function jsonObjectOrNull(s) { - let obj; - try { - obj = JSON.parse(s); - } - catch (e) { - return null; - } - if (isNonArrayObject(obj)) { - return obj; - } - else { - return null; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -function parent(path) { - if (path.length === 0) { - return null; - } - const index = path.lastIndexOf('/'); - if (index === -1) { - return ''; - } - const newPath = path.slice(0, index); - return newPath; -} -function child(path, childPath) { - const canonicalChildPath = childPath - .split('/') - .filter(component => component.length > 0) - .join('/'); - if (path.length === 0) { - return canonicalChildPath; - } - else { - return path + '/' + canonicalChildPath; - } -} -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -function lastComponent(path) { - const index = path.lastIndexOf('/', path.length - 2); - if (index === -1) { - return path; - } - else { - return path.slice(index + 1); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function noXform_(metadata, value) { - return value; -} -class Mapping { - constructor(server, local, writable, xform) { - this.server = server; - this.local = local || server; - this.writable = !!writable; - this.xform = xform || noXform_; - } -} -let mappings_ = null; -function xformPath(fullPath) { - if (!isString(fullPath) || fullPath.length < 2) { - return fullPath; - } - else { - return lastComponent(fullPath); - } -} -function getMappings() { - if (mappings_) { - return mappings_; - } - const mappings = []; - mappings.push(new Mapping('bucket')); - mappings.push(new Mapping('generation')); - mappings.push(new Mapping('metageneration')); - mappings.push(new Mapping('name', 'fullPath', true)); - function mappingsXformPath(_metadata, fullPath) { - return xformPath(fullPath); - } - const nameMapping = new Mapping('name'); - nameMapping.xform = mappingsXformPath; - mappings.push(nameMapping); - /** - * Coerces the second param to a number, if it is defined. - */ - function xformSize(_metadata, size) { - if (size !== undefined) { - return Number(size); - } - else { - return size; - } - } - const sizeMapping = new Mapping('size'); - sizeMapping.xform = xformSize; - mappings.push(sizeMapping); - mappings.push(new Mapping('timeCreated')); - mappings.push(new Mapping('updated')); - mappings.push(new Mapping('md5Hash', null, true)); - mappings.push(new Mapping('cacheControl', null, true)); - mappings.push(new Mapping('contentDisposition', null, true)); - mappings.push(new Mapping('contentEncoding', null, true)); - mappings.push(new Mapping('contentLanguage', null, true)); - mappings.push(new Mapping('contentType', null, true)); - mappings.push(new Mapping('metadata', 'customMetadata', true)); - mappings_ = mappings; - return mappings_; -} -function addRef(metadata, service) { - function generateRef() { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const loc = new Location(bucket, path); - return service._makeStorageReference(loc); - } - Object.defineProperty(metadata, 'ref', { get: generateRef }); -} -function fromResource(service, resource, mappings) { - const metadata = {}; - metadata['type'] = 'file'; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]); - } - addRef(metadata, service); - return metadata; -} -function fromResourceString(service, resourceString, mappings) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromResource(service, resource, mappings); -} -function downloadUrlFromResourceString(metadata, resourceString, host, protocol) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - if (!isString(obj['downloadTokens'])) { - // This can happen if objects are uploaded through GCS and retrieved - // through list, so we don't want to throw an Error. - return null; - } - const tokens = obj['downloadTokens']; - if (tokens.length === 0) { - return null; - } - const encode = encodeURIComponent; - const tokensList = tokens.split(','); - const urls = tokensList.map((token) => { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path); - const base = makeUrl(urlPart, host, protocol); - const queryString = makeQueryString({ - alt: 'media', - token - }); - return base + queryString; - }); - return urls[0]; -} -function toResourceString(metadata, mappings) { - const resource = {}; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - if (mapping.writable) { - resource[mapping.server] = metadata[mapping.local]; - } - } - return JSON.stringify(resource); -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const PREFIXES_KEY = 'prefixes'; -const ITEMS_KEY = 'items'; -function fromBackendResponse(service, bucket, resource) { - const listResult = { - prefixes: [], - items: [], - nextPageToken: resource['nextPageToken'] - }; - if (resource[PREFIXES_KEY]) { - for (const path of resource[PREFIXES_KEY]) { - const pathWithoutTrailingSlash = path.replace(/\/$/, ''); - const reference = service._makeStorageReference(new Location(bucket, pathWithoutTrailingSlash)); - listResult.prefixes.push(reference); - } - } - if (resource[ITEMS_KEY]) { - for (const item of resource[ITEMS_KEY]) { - const reference = service._makeStorageReference(new Location(bucket, item['name'])); - listResult.items.push(reference); - } - } - return listResult; -} -function fromResponseString(service, bucket, resourceString) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromBackendResponse(service, bucket, resource); -} - -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -class RequestInfo { - constructor(url, method, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler, timeout) { - this.url = url; - this.method = method; - this.handler = handler; - this.timeout = timeout; - this.urlParams = {}; - this.headers = {}; - this.body = null; - this.errorHandler = null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - this.progressCallback = null; - this.successCodes = [200]; - this.additionalRetryCodes = []; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -function handlerCheck(cndn) { - if (!cndn) { - throw unknown(); - } -} -function metadataHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return metadata; - } - return handler; -} -function listHandler(service, bucket) { - function handler(xhr, text) { - const listResult = fromResponseString(service, bucket, text); - handlerCheck(listResult !== null); - return listResult; - } - return handler; -} -function downloadUrlHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return downloadUrlFromResourceString(metadata, text, service.host, service._protocol); - } - return handler; -} -function sharedErrorHandler(location) { - function errorHandler(xhr, err) { - let newErr; - if (xhr.getStatus() === 401) { - if ( - // This exact message string is the only consistent part of the - // server's error response that identifies it as an App Check error. - xhr.getErrorText().includes('Firebase App Check token is invalid')) { - newErr = unauthorizedApp(); - } - else { - newErr = unauthenticated(); - } - } - else { - if (xhr.getStatus() === 402) { - newErr = quotaExceeded(location.bucket); - } - else { - if (xhr.getStatus() === 403) { - newErr = unauthorized(location.path); - } - else { - newErr = err; - } - } - } - newErr.status = xhr.getStatus(); - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function objectErrorHandler(location) { - const shared = sharedErrorHandler(location); - function errorHandler(xhr, err) { - let newErr = shared(xhr, err); - if (xhr.getStatus() === 404) { - newErr = objectNotFound(location.path); - } - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function getMetadata$2(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function list$2(service, location, delimiter, pageToken, maxResults) { - const urlParams = {}; - if (location.isRoot) { - urlParams['prefix'] = ''; - } - else { - urlParams['prefix'] = location.path + '/'; - } - if (delimiter && delimiter.length > 0) { - urlParams['delimiter'] = delimiter; - } - if (pageToken) { - urlParams['pageToken'] = pageToken; - } - if (maxResults) { - urlParams['maxResults'] = maxResults; - } - const urlPart = location.bucketOnlyServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, listHandler(service, location.bucket), timeout); - requestInfo.urlParams = urlParams; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -function getBytes$1(service, location, maxDownloadSizeBytes) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media'; - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout); - requestInfo.errorHandler = objectErrorHandler(location); - if (maxDownloadSizeBytes !== undefined) { - requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`; - requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */]; - } - return requestInfo; -} -function getDownloadUrl(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function updateMetadata$2(service, location, metadata, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'PATCH'; - const body = toResourceString(metadata, mappings); - const headers = { 'Content-Type': 'application/json; charset=utf-8' }; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function deleteObject$2(service, location) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'DELETE'; - const timeout = service.maxOperationRetryTime; - function handler(_xhr, _text) { } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.successCodes = [200, 204]; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function determineContentType_(metadata, blob) { - return ((metadata && metadata['contentType']) || - (blob && blob.type()) || - 'application/octet-stream'); -} -function metadataForUpload_(location, blob, metadata) { - const metadataClone = Object.assign({}, metadata); - metadataClone['fullPath'] = location.path; - metadataClone['size'] = blob.size(); - if (!metadataClone['contentType']) { - metadataClone['contentType'] = determineContentType_(null, blob); - } - return metadataClone; -} -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -function multipartUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const headers = { - 'X-Goog-Upload-Protocol': 'multipart' - }; - function genBoundary() { - let str = ''; - for (let i = 0; i < 2; i++) { - str = str + Math.random().toString().slice(2); - } - return str; - } - const boundary = genBoundary(); - headers['Content-Type'] = 'multipart/related; boundary=' + boundary; - const metadata_ = metadataForUpload_(location, blob, metadata); - const metadataString = toResourceString(metadata_, mappings); - const preBlobPart = '--' + - boundary + - '\r\n' + - 'Content-Type: application/json; charset=utf-8\r\n\r\n' + - metadataString + - '\r\n--' + - boundary + - '\r\n' + - 'Content-Type: ' + - metadata_['contentType'] + - '\r\n\r\n'; - const postBlobPart = '\r\n--' + boundary + '--'; - const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart); - if (body === null) { - throw cannotSliceBlob(); - } - const urlParams = { name: metadata_['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -class ResumableUploadStatus { - constructor(current, total, finalized, metadata) { - this.current = current; - this.total = total; - this.finalized = !!finalized; - this.metadata = metadata || null; - } -} -function checkResumeHeader_(xhr, allowed) { - let status = null; - try { - status = xhr.getResponseHeader('X-Goog-Upload-Status'); - } - catch (e) { - handlerCheck(false); - } - const allowedStatus = allowed || ['active']; - handlerCheck(!!status && allowedStatus.indexOf(status) !== -1); - return status; -} -function createResumableUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const metadataForUpload = metadataForUpload_(location, blob, metadata); - const urlParams = { name: metadataForUpload['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const headers = { - 'X-Goog-Upload-Protocol': 'resumable', - 'X-Goog-Upload-Command': 'start', - 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`, - 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType'], - 'Content-Type': 'application/json; charset=utf-8' - }; - const body = toResourceString(metadataForUpload, mappings); - const timeout = service.maxUploadRetryTime; - function handler(xhr) { - checkResumeHeader_(xhr); - let url; - try { - url = xhr.getResponseHeader('X-Goog-Upload-URL'); - } - catch (e) { - handlerCheck(false); - } - handlerCheck(isString(url)); - return url; - } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -function getResumableUploadStatus(service, location, url, blob) { - const headers = { 'X-Goog-Upload-Command': 'query' }; - function handler(xhr) { - const status = checkResumeHeader_(xhr, ['active', 'final']); - let sizeString = null; - try { - sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received'); - } - catch (e) { - handlerCheck(false); - } - if (!sizeString) { - // null or empty string - handlerCheck(false); - } - const size = Number(sizeString); - handlerCheck(!isNaN(size)); - return new ResumableUploadStatus(size, blob.size(), status === 'final'); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -const RESUMABLE_UPLOAD_CHUNK_SIZE = 256 * 1024; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -function continueResumableUpload(location, service, url, blob, chunkSize, mappings, status, progressCallback) { - // TODO(andysoto): standardize on internal asserts - // assert(!(opt_status && opt_status.finalized)); - const status_ = new ResumableUploadStatus(0, 0); - if (status) { - status_.current = status.current; - status_.total = status.total; - } - else { - status_.current = 0; - status_.total = blob.size(); - } - if (blob.size() !== status_.total) { - throw serverFileWrongSize(); - } - const bytesLeft = status_.total - status_.current; - let bytesToUpload = bytesLeft; - if (chunkSize > 0) { - bytesToUpload = Math.min(bytesToUpload, chunkSize); - } - const startByte = status_.current; - const endByte = startByte + bytesToUpload; - let uploadCommand = ''; - if (bytesToUpload === 0) { - uploadCommand = 'finalize'; - } - else if (bytesLeft === bytesToUpload) { - uploadCommand = 'upload, finalize'; - } - else { - uploadCommand = 'upload'; - } - const headers = { - 'X-Goog-Upload-Command': uploadCommand, - 'X-Goog-Upload-Offset': `${status_.current}` - }; - const body = blob.slice(startByte, endByte); - if (body === null) { - throw cannotSliceBlob(); - } - function handler(xhr, text) { - // TODO(andysoto): Verify the MD5 of each uploaded range: - // the 'x-range-md5' header comes back with status code 308 responses. - // We'll only be able to bail out though, because you can't re-upload a - // range that you previously uploaded. - const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']); - const newCurrent = status_.current + bytesToUpload; - const size = blob.size(); - let metadata; - if (uploadStatus === 'final') { - metadata = metadataHandler(service, mappings)(xhr, text); - } - else { - metadata = null; - } - return new ResumableUploadStatus(newCurrent, size, uploadStatus === 'final', metadata); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.progressCallback = progressCallback || null; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An event that is triggered on a task. - * @internal - */ -const TaskEvent = { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: 'state_changed' -}; -// type keys = keyof TaskState -/** - * Represents the current state of a running upload. - * @internal - */ -const TaskState = { - /** The task is currently transferring data. */ - RUNNING: 'running', - /** The task was paused by the user. */ - PAUSED: 'paused', - /** The task completed successfully. */ - SUCCESS: 'success', - /** The task was canceled. */ - CANCELED: 'canceled', - /** The task failed with an error. */ - ERROR: 'error' -}; -function taskStateFromInternalTaskState(state) { - switch (state) { - case "running" /* InternalTaskState.RUNNING */: - case "pausing" /* InternalTaskState.PAUSING */: - case "canceling" /* InternalTaskState.CANCELING */: - return TaskState.RUNNING; - case "paused" /* InternalTaskState.PAUSED */: - return TaskState.PAUSED; - case "success" /* InternalTaskState.SUCCESS */: - return TaskState.SUCCESS; - case "canceled" /* InternalTaskState.CANCELED */: - return TaskState.CANCELED; - case "error" /* InternalTaskState.ERROR */: - return TaskState.ERROR; - default: - // TODO(andysoto): assert(false); - return TaskState.ERROR; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -class Observer { - constructor(nextOrObserver, error, complete) { - const asFunctions = isFunction(nextOrObserver) || error != null || complete != null; - if (asFunctions) { - this.next = nextOrObserver; - this.error = error ?? undefined; - this.complete = complete ?? undefined; - } - else { - const observer = nextOrObserver; - this.next = observer.next; - this.error = observer.error; - this.complete = observer.complete; - } - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -// eslint-disable-next-line @typescript-eslint/ban-types -function async(f) { - return (...argsToForward) => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.resolve().then(() => f(...argsToForward)); - }; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** An override for the text-based Connection. Used in tests. */ -let textFactoryOverride = null; -/** - * Network layer for browsers. We use this instead of goog.net.XhrIo because - * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android. - */ -class XhrConnection { - constructor() { - this.sent_ = false; - this.xhr_ = new XMLHttpRequest(); - this.initXhr(); - this.errorCode_ = ErrorCode.NO_ERROR; - this.sendPromise_ = new Promise(resolve => { - this.xhr_.addEventListener('abort', () => { - this.errorCode_ = ErrorCode.ABORT; - resolve(); - }); - this.xhr_.addEventListener('error', () => { - this.errorCode_ = ErrorCode.NETWORK_ERROR; - resolve(); - }); - this.xhr_.addEventListener('load', () => { - resolve(); - }); - }); - } - send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - if (isCloudWorkstation(url) && isUsingEmulator) { - this.xhr_.withCredentials = true; - } - this.sent_ = true; - this.xhr_.open(method, url, true); - if (headers !== undefined) { - for (const key in headers) { - if (headers.hasOwnProperty(key)) { - this.xhr_.setRequestHeader(key, headers[key].toString()); - } - } - } - if (body !== undefined) { - this.xhr_.send(body); - } - else { - this.xhr_.send(); - } - return this.sendPromise_; - } - getErrorCode() { - if (!this.sent_) { - throw internalError('cannot .getErrorCode() before sending'); - } - return this.errorCode_; - } - getStatus() { - if (!this.sent_) { - throw internalError('cannot .getStatus() before sending'); - } - try { - return this.xhr_.status; - } - catch (e) { - return -1; - } - } - getResponse() { - if (!this.sent_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.xhr_.response; - } - getErrorText() { - if (!this.sent_) { - throw internalError('cannot .getErrorText() before sending'); - } - return this.xhr_.statusText; - } - /** Aborts the request. */ - abort() { - this.xhr_.abort(); - } - getResponseHeader(header) { - return this.xhr_.getResponseHeader(header); - } - addUploadProgressListener(listener) { - if (this.xhr_.upload != null) { - this.xhr_.upload.addEventListener('progress', listener); - } - } - removeUploadProgressListener(listener) { - if (this.xhr_.upload != null) { - this.xhr_.upload.removeEventListener('progress', listener); - } - } -} -class XhrTextConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'text'; - } -} -function newTextConnection() { - return textFactoryOverride ? textFactoryOverride() : new XhrTextConnection(); -} -class XhrBytesConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'arraybuffer'; - } -} -function newBytesConnection() { - return new XhrBytesConnection(); -} -class XhrBlobConnection extends XhrConnection { - initXhr() { - this.xhr_.responseType = 'blob'; - } -} -function newBlobConnection() { - return new XhrBlobConnection(); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -class UploadTask { - isExponentialBackoffExpired() { - return this.sleepTime > this.maxSleepTime; - } - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref, blob, metadata = null) { - /** - * Number of bytes transferred so far. - */ - this._transferred = 0; - this._needToFetchStatus = false; - this._needToFetchMetadata = false; - this._observers = []; - this._error = undefined; - this._uploadUrl = undefined; - this._request = undefined; - this._chunkMultiplier = 1; - this._resolve = undefined; - this._reject = undefined; - this._ref = ref; - this._blob = blob; - this._metadata = metadata; - this._mappings = getMappings(); - this._resumable = this._shouldDoResumable(this._blob); - this._state = "running" /* InternalTaskState.RUNNING */; - this._errorHandler = error => { - this._request = undefined; - this._chunkMultiplier = 1; - if (error._codeEquals(StorageErrorCode.CANCELED)) { - this._needToFetchStatus = true; - this.completeTransitions_(); - } - else { - const backoffExpired = this.isExponentialBackoffExpired(); - if (isRetryStatusCode(error.status, [])) { - if (backoffExpired) { - error = retryLimitExceeded(); - } - else { - this.sleepTime = Math.max(this.sleepTime * 2, DEFAULT_MIN_SLEEP_TIME_MILLIS); - this._needToFetchStatus = true; - this.completeTransitions_(); - return; - } - } - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this._metadataErrorHandler = error => { - this._request = undefined; - if (error._codeEquals(StorageErrorCode.CANCELED)) { - this.completeTransitions_(); - } - else { - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this.sleepTime = 0; - this.maxSleepTime = this._ref.storage.maxUploadRetryTime; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - this._start(); - }); - // Prevent uncaught rejections on the internal promise from bubbling out - // to the top level with a dummy handler. - this._promise.then(null, () => { }); - } - _makeProgressCallback() { - const sizeBefore = this._transferred; - return loaded => this._updateProgress(sizeBefore + loaded); - } - _shouldDoResumable(blob) { - return blob.size() > 256 * 1024; - } - _start() { - if (this._state !== "running" /* InternalTaskState.RUNNING */) { - // This can happen if someone pauses us in a resume callback, for example. - return; - } - if (this._request !== undefined) { - return; - } - if (this._resumable) { - if (this._uploadUrl === undefined) { - this._createResumable(); - } - else { - if (this._needToFetchStatus) { - this._fetchStatus(); - } - else { - if (this._needToFetchMetadata) { - // Happens if we miss the metadata on upload completion. - this._fetchMetadata(); - } - else { - this.pendingTimeout = setTimeout(() => { - this.pendingTimeout = undefined; - this._continueUpload(); - }, this.sleepTime); - } - } - } - } - else { - this._oneShotUpload(); - } - } - _resolveToken(callback) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.all([ - this._ref.storage._getAuthToken(), - this._ref.storage._getAppCheckToken() - ]).then(([authToken, appCheckToken]) => { - switch (this._state) { - case "running" /* InternalTaskState.RUNNING */: - callback(authToken, appCheckToken); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - } - }); - } - // TODO(andysoto): assert false - _createResumable() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = createRequest; - createRequest.getPromise().then((url) => { - this._request = undefined; - this._uploadUrl = url; - this._needToFetchStatus = false; - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _fetchStatus() { - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob); - const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = statusRequest; - statusRequest.getPromise().then(status => { - status = status; - this._request = undefined; - this._updateProgress(status.current); - this._needToFetchStatus = false; - if (status.finalized) { - this._needToFetchMetadata = true; - } - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _continueUpload() { - const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - const status = new ResumableUploadStatus(this._transferred, this._blob.size()); - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - let requestInfo; - try { - requestInfo = continueResumableUpload(this._ref._location, this._ref.storage, url, this._blob, chunkSize, this._mappings, status, this._makeProgressCallback()); - } - catch (e) { - this._error = e; - this._transition("error" /* InternalTaskState.ERROR */); - return; - } - const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken, - /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file. - ); - this._request = uploadRequest; - uploadRequest.getPromise().then((newStatus) => { - this._increaseMultiplier(); - this._request = undefined; - this._updateProgress(newStatus.current); - if (newStatus.finalized) { - this._metadata = newStatus.metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - } - else { - this.completeTransitions_(); - } - }, this._errorHandler); - }); - } - _increaseMultiplier() { - const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - // Max chunk size is 32M. - if (currentSize * 2 < 32 * 1024 * 1024) { - this._chunkMultiplier *= 2; - } - } - _fetchMetadata() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings); - const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = metadataRequest; - metadataRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._metadataErrorHandler); - }); - } - _oneShotUpload() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = multipartRequest; - multipartRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._updateProgress(this._blob.size()); - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._errorHandler); - }); - } - _updateProgress(transferred) { - const old = this._transferred; - this._transferred = transferred; - // A progress update can make the "transferred" value smaller (e.g. a - // partial upload not completed by server, after which the "transferred" - // value may reset to the value at the beginning of the request). - if (this._transferred !== old) { - this._notifyObservers(); - } - } - _transition(state) { - if (this._state === state) { - return; - } - switch (state) { - case "canceling" /* InternalTaskState.CANCELING */: - case "pausing" /* InternalTaskState.PAUSING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING); - this._state = state; - if (this._request !== undefined) { - this._request.cancel(); - } - else if (this.pendingTimeout) { - clearTimeout(this.pendingTimeout); - this.pendingTimeout = undefined; - this.completeTransitions_(); - } - break; - case "running" /* InternalTaskState.RUNNING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.PAUSING); - const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */; - this._state = state; - if (wasPaused) { - this._notifyObservers(); - this._start(); - } - break; - case "paused" /* InternalTaskState.PAUSED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSING); - this._state = state; - this._notifyObservers(); - break; - case "canceled" /* InternalTaskState.CANCELED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.CANCELING); - this._error = canceled(); - this._state = state; - this._notifyObservers(); - break; - case "error" /* InternalTaskState.ERROR */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - case "success" /* InternalTaskState.SUCCESS */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - } - } - completeTransitions_() { - switch (this._state) { - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "running" /* InternalTaskState.RUNNING */: - this._start(); - break; - } - } - /** - * A snapshot of the current task state. - */ - get snapshot() { - const externalState = taskStateFromInternalTaskState(this._state); - return { - bytesTransferred: this._transferred, - totalBytes: this._blob.size(), - state: externalState, - metadata: this._metadata, - task: this, - ref: this._ref - }; - } - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type, nextOrObserver, error, completed) { - // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string. - const observer = new Observer(nextOrObserver || undefined, error || undefined, completed || undefined); - this._addObserver(observer); - return () => { - this._removeObserver(observer); - }; - } - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled, onRejected) { - // These casts are needed so that TypeScript can infer the types of the - // resulting Promise. - return this._promise.then(onFulfilled, onRejected); - } - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected) { - return this.then(null, onRejected); - } - /** - * Adds the given observer. - */ - _addObserver(observer) { - this._observers.push(observer); - this._notifyObserver(observer); - } - /** - * Removes the given observer. - */ - _removeObserver(observer) { - const i = this._observers.indexOf(observer); - if (i !== -1) { - this._observers.splice(i, 1); - } - } - _notifyObservers() { - this._finishPromise(); - const observers = this._observers.slice(); - observers.forEach(observer => { - this._notifyObserver(observer); - }); - } - _finishPromise() { - if (this._resolve !== undefined) { - let triggered = true; - switch (taskStateFromInternalTaskState(this._state)) { - case TaskState.SUCCESS: - async(this._resolve.bind(null, this.snapshot))(); - break; - case TaskState.CANCELED: - case TaskState.ERROR: - const toCall = this._reject; - async(toCall.bind(null, this._error))(); - break; - default: - triggered = false; - break; - } - if (triggered) { - this._resolve = undefined; - this._reject = undefined; - } - } - } - _notifyObserver(observer) { - const externalState = taskStateFromInternalTaskState(this._state); - switch (externalState) { - case TaskState.RUNNING: - case TaskState.PAUSED: - if (observer.next) { - async(observer.next.bind(observer, this.snapshot))(); - } - break; - case TaskState.SUCCESS: - if (observer.complete) { - async(observer.complete.bind(observer))(); - } - break; - case TaskState.CANCELED: - case TaskState.ERROR: - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - break; - default: - // TODO(andysoto): assert(false); - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - } - } - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume() { - const valid = this._state === "paused" /* InternalTaskState.PAUSED */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("running" /* InternalTaskState.RUNNING */); - } - return valid; - } - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */; - if (valid) { - this._transition("pausing" /* InternalTaskState.PAUSING */); - } - return valid; - } - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("canceling" /* InternalTaskState.CANCELING */); - } - return valid; - } -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -class Reference { - constructor(_service, location) { - this._service = _service; - if (location instanceof Location) { - this._location = location; - } - else { - this._location = Location.makeFromUrl(location, _service.host); - } - } - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString() { - return 'gs://' + this._location.bucket + '/' + this._location.path; - } - _newRef(service, location) { - return new Reference(service, location); - } - /** - * A reference to the root of this object's bucket. - */ - get root() { - const location = new Location(this._location.bucket, ''); - return this._newRef(this._service, location); - } - /** - * The name of the bucket containing this reference's object. - */ - get bucket() { - return this._location.bucket; - } - /** - * The full path of this object. - */ - get fullPath() { - return this._location.path; - } - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name() { - return lastComponent(this._location.path); - } - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage() { - return this._service; - } - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent() { - const newPath = parent(this._location.path); - if (newPath === null) { - return null; - } - const location = new Location(this._location.bucket, newPath); - return new Reference(this._service, location); - } - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name) { - if (this._location.path === '') { - throw invalidRootOperation(name); - } - } -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -function getBytesInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBytes'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBytesConnection) - .then(bytes => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - bytes.slice(0, maxDownloadSizeBytes) - : bytes); -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded blob. - */ -function getBlobInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBlob'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBlobConnection) - .then(blob => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - blob.slice(0, maxDownloadSizeBytes) - : blob); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -function uploadBytes$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytes'); - const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(finalMetadata => { - return { - metadata: finalMetadata, - ref - }; - }); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -function uploadBytesResumable$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytesResumable'); - return new UploadTask(ref, new FbsBlob(data), metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -function uploadString$1(ref, value, format = StringFormat.RAW, metadata) { - ref._throwIfRoot('uploadString'); - const data = dataFromString(format, value); - const metadataClone = { ...metadata }; - if (metadataClone['contentType'] == null && data.contentType != null) { - metadataClone['contentType'] = data.contentType; - } - return uploadBytes$1(ref, data.data, metadataClone); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll$1(ref) { - const accumulator = { - prefixes: [], - items: [] - }; - return listAllHelper(ref, accumulator).then(() => accumulator); -} -/** - * Separated from listAll because async functions can't use "arguments". - * @param ref - * @param accumulator - * @param pageToken - */ -async function listAllHelper(ref, accumulator, pageToken) { - const opt = { - // maxResults is 1000 by default. - pageToken - }; - const nextPage = await list$1(ref, opt); - accumulator.prefixes.push(...nextPage.prefixes); - accumulator.items.push(...nextPage.items); - if (nextPage.nextPageToken != null) { - await listAllHelper(ref, accumulator, nextPage.nextPageToken); - } -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list$1(ref, options) { - if (options != null) { - if (typeof options.maxResults === 'number') { - validateNumber('options.maxResults', - /* minValue= */ 1, - /* maxValue= */ 1000, options.maxResults); - } - } - const op = options || {}; - const requestInfo = list$2(ref.storage, ref._location, - /*delimiter= */ '/', op.pageToken, op.maxResults); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -function getMetadata$1(ref) { - ref._throwIfRoot('getMetadata'); - const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -function updateMetadata$1(ref, metadata) { - ref._throwIfRoot('updateMetadata'); - const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL$1(ref) { - ref._throwIfRoot('getDownloadURL'); - const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings()); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(url => { - if (url === null) { - throw noDownloadURL(); - } - return url; - }); -} -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject$1(ref) { - ref._throwIfRoot('deleteObject'); - const requestInfo = deleteObject$2(ref.storage, ref._location); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -function _getChild$1(ref, childPath) { - const newPath = child(ref._location.path, childPath); - const location = new Location(ref._location.bucket, newPath); - return new Reference(ref.storage, location); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isUrl(path) { - return /^[A-Za-z]+:\/\//.test(path); -} -/** - * Returns a firebaseStorage.Reference for the given url. - */ -function refFromURL(service, url) { - return new Reference(service, url); -} -/** - * Returns a firebaseStorage.Reference for the given path in the default - * bucket. - */ -function refFromPath(ref, path) { - if (ref instanceof FirebaseStorageImpl) { - const service = ref; - if (service._bucket == null) { - throw noDefaultBucket(); - } - const reference = new Reference(service, service._bucket); - if (path != null) { - return refFromPath(reference, path); - } - else { - return reference; - } - } - else { - // ref is a Reference - if (path !== undefined) { - return _getChild$1(ref, path); - } - else { - return ref; - } - } -} -function ref$1(serviceOrRef, pathOrUrl) { - if (pathOrUrl && isUrl(pathOrUrl)) { - if (serviceOrRef instanceof FirebaseStorageImpl) { - return refFromURL(serviceOrRef, pathOrUrl); - } - else { - throw invalidArgument('To use ref(service, url), the first argument must be a Storage instance.'); - } - } - else { - return refFromPath(serviceOrRef, pathOrUrl); - } -} -function extractBucket(host, config) { - const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY]; - if (bucketString == null) { - return null; - } - return Location.makeFromBucketSpec(bucketString, host); -} -function connectStorageEmulator$1(storage, host, port, options = {}) { - storage.host = `${host}:${port}`; - const useSsl = isCloudWorkstation(host); - // Workaround to get cookies in Firebase Studio - if (useSsl) { - void pingServer(`https://${storage.host}/b`); - updateEmulatorBanner('Storage', true); - } - storage._isUsingEmulator = true; - storage._protocol = useSsl ? 'https' : 'http'; - const { mockUserToken } = options; - if (mockUserToken) { - storage._overrideAuthToken = - typeof mockUserToken === 'string' - ? mockUserToken - : createMockUserToken(mockUserToken, storage.app.options.projectId); - } -} -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -class FirebaseStorageImpl { - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app, _authProvider, - /** - * @internal - */ - _appCheckProvider, - /** - * @internal - */ - _url, _firebaseVersion, _isUsingEmulator = false) { - this.app = app; - this._authProvider = _authProvider; - this._appCheckProvider = _appCheckProvider; - this._url = _url; - this._firebaseVersion = _firebaseVersion; - this._isUsingEmulator = _isUsingEmulator; - this._bucket = null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - this._host = DEFAULT_HOST; - this._protocol = 'https'; - this._appId = null; - this._deleted = false; - this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME; - this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME; - this._requests = new Set(); - if (_url != null) { - this._bucket = Location.makeFromBucketSpec(_url, this._host); - } - else { - this._bucket = extractBucket(this._host, this.app.options); - } - } - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host() { - return this._host; - } - set host(host) { - this._host = host; - if (this._url != null) { - this._bucket = Location.makeFromBucketSpec(this._url, host); - } - else { - this._bucket = extractBucket(host, this.app.options); - } - } - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime() { - return this._maxUploadRetryTime; - } - set maxUploadRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxUploadRetryTime = time; - } - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime() { - return this._maxOperationRetryTime; - } - set maxOperationRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxOperationRetryTime = time; - } - async _getAuthToken() { - if (this._overrideAuthToken) { - return this._overrideAuthToken; - } - const auth = this._authProvider.getImmediate({ optional: true }); - if (auth) { - const tokenData = await auth.getToken(); - if (tokenData !== null) { - return tokenData.accessToken; - } - } - return null; - } - async _getAppCheckToken() { - if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) { - return this.app.settings.appCheckToken; - } - const appCheck = this._appCheckProvider.getImmediate({ optional: true }); - if (appCheck) { - const result = await appCheck.getToken(); - // TODO: What do we want to do if there is an error getting the token? - // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be - // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use - // the token (actual or dummy) to send requests. - return result.token; - } - return null; - } - /** - * Stop running requests and prevent more from being created. - */ - _delete() { - if (!this._deleted) { - this._deleted = true; - this._requests.forEach(request => request.cancel()); - this._requests.clear(); - } - return Promise.resolve(); - } - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc) { - return new Reference(this, loc); - } - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) { - if (!this._deleted) { - const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator); - this._requests.add(request); - // Request removes itself from set when complete. - request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request)); - return request; - } - else { - return new FailRequest(appDeleted()); - } - } - async makeRequestWithTokens(requestInfo, requestFactory) { - const [authToken, appCheckToken] = await Promise.all([ - this._getAuthToken(), - this._getAppCheckToken() - ]); - return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise(); - } -} - -const name = "@firebase/storage"; -const version = "0.14.0"; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -const STORAGE_TYPE = 'storage'; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -function getBytes(ref, maxDownloadSizeBytes) { - ref = getModularInstance(ref); - return getBytesInternal(ref, maxDownloadSizeBytes); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -function uploadBytes(ref, data, metadata) { - ref = getModularInstance(ref); - return uploadBytes$1(ref, data, metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -function uploadString(ref, value, format, metadata) { - ref = getModularInstance(ref); - return uploadString$1(ref, value, format, metadata); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -function uploadBytesResumable(ref, data, metadata) { - ref = getModularInstance(ref); - return uploadBytesResumable$1(ref, data, metadata); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -function getMetadata(ref) { - ref = getModularInstance(ref); - return getMetadata$1(ref); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -function updateMetadata(ref, metadata) { - ref = getModularInstance(ref); - return updateMetadata$1(ref, metadata); -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list(ref, options) { - ref = getModularInstance(ref); - return list$1(ref, options); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll(ref) { - ref = getModularInstance(ref); - return listAll$1(ref); -} -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL(ref) { - ref = getModularInstance(ref); - return getDownloadURL$1(ref); -} -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject(ref) { - ref = getModularInstance(ref); - return deleteObject$1(ref); -} -function ref(serviceOrRef, pathOrUrl) { - serviceOrRef = getModularInstance(serviceOrRef); - return ref$1(serviceOrRef, pathOrUrl); -} -/** - * @internal - */ -function _getChild(ref, childPath) { - return _getChild$1(ref, childPath); -} -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -function getStorage(app = getApp(), bucketUrl) { - app = getModularInstance(app); - const storageProvider = _getProvider(app, STORAGE_TYPE); - const storageInstance = storageProvider.getImmediate({ - identifier: bucketUrl - }); - const emulator = getDefaultEmulatorHostnameAndPort('storage'); - if (emulator) { - connectStorageEmulator(storageInstance, ...emulator); - } - return storageInstance; -} -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -function connectStorageEmulator(storage, host, port, options = {}) { - connectStorageEmulator$1(storage, host, port, options); -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -function getBlob(ref, maxDownloadSizeBytes) { - ref = getModularInstance(ref); - return getBlobInternal(ref, maxDownloadSizeBytes); -} -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -function getStream(ref, maxDownloadSizeBytes) { - throw new Error('getStream() is only supported by NodeJS builds'); -} - -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -function factory(container, { instanceIdentifier: url }) { - const app = container.getProvider('app').getImmediate(); - const authProvider = container.getProvider('auth-internal'); - const appCheckProvider = container.getProvider('app-check-internal'); - return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION); -} -function registerStorage() { - _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); - //RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser - registerVersion(name, version, ''); - // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation - registerVersion(name, version, 'esm2020'); -} -registerStorage(); - -export { StorageError, StorageErrorCode, StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString }; -//# sourceMappingURL=index.esm.js.map diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.esm.js.map b/frontend-old/node_modules/@firebase/storage/dist/index.esm.js.map deleted file mode 100644 index 12789a8..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.esm.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.esm.js","sources":["../src/implementation/constants.ts","../src/implementation/error.ts","../src/implementation/location.ts","../src/implementation/failrequest.ts","../src/implementation/backoff.ts","../src/implementation/type.ts","../src/implementation/url.ts","../src/implementation/connection.ts","../src/implementation/utils.ts","../src/implementation/request.ts","../src/implementation/fs.ts","../src/platform/browser/base64.ts","../src/implementation/string.ts","../src/implementation/blob.ts","../src/implementation/json.ts","../src/implementation/path.ts","../src/implementation/metadata.ts","../src/implementation/list.ts","../src/implementation/requestinfo.ts","../src/implementation/requests.ts","../src/implementation/taskenums.ts","../src/implementation/observer.ts","../src/implementation/async.ts","../src/platform/browser/connection.ts","../src/task.ts","../src/reference.ts","../src/service.ts","../src/constants.ts","../src/api.ts","../src/api.browser.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Constants used in the Firebase Storage library.\n */\n\n/**\n * Domain name for firebase storage.\n */\nexport const DEFAULT_HOST = 'firebasestorage.googleapis.com';\n\n/**\n * The key in Firebase config json for the storage bucket.\n */\nexport const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket';\n\n/**\n * 2 minutes\n *\n * The timeout for all operations except upload.\n */\nexport const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000;\n\n/**\n * 10 minutes\n *\n * The timeout for upload.\n */\nexport const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000;\n\n/**\n * 1 second\n */\nexport const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;\n\n/**\n * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported\n * enough for us to use it directly.\n */\nexport const MIN_SAFE_INTEGER = -9007199254740991;\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseError } from '@firebase/util';\n\nimport { CONFIG_STORAGE_BUCKET_KEY } from './constants';\n\n/**\n * An error returned by the Firebase Storage SDK.\n * @public\n */\nexport class StorageError extends FirebaseError {\n private readonly _baseMessage: string;\n /**\n * Stores custom error data unique to the `StorageError`.\n */\n customData: { serverResponse: string | null } = { serverResponse: null };\n\n /**\n * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and\n * added to the end of the message.\n * @param message - Error message.\n * @param status_ - Corresponding HTTP Status Code\n */\n constructor(code: StorageErrorCode, message: string, private status_ = 0) {\n super(\n prependCode(code),\n `Firebase Storage: ${message} (${prependCode(code)})`\n );\n this._baseMessage = this.message;\n // Without this, `instanceof StorageError`, in tests for example,\n // returns false.\n Object.setPrototypeOf(this, StorageError.prototype);\n }\n\n get status(): number {\n return this.status_;\n }\n\n set status(status: number) {\n this.status_ = status;\n }\n\n /**\n * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.\n */\n _codeEquals(code: StorageErrorCode): boolean {\n return prependCode(code) === this.code;\n }\n\n /**\n * Optional response message that was added by the server.\n */\n get serverResponse(): null | string {\n return this.customData.serverResponse;\n }\n\n set serverResponse(serverResponse: string | null) {\n this.customData.serverResponse = serverResponse;\n if (this.customData.serverResponse) {\n this.message = `${this._baseMessage}\\n${this.customData.serverResponse}`;\n } else {\n this.message = this._baseMessage;\n }\n }\n}\n\nexport const errors = {};\n\n/**\n * @public\n * Error codes that can be attached to `StorageError` objects.\n */\nexport enum StorageErrorCode {\n // Shared between all platforms\n UNKNOWN = 'unknown',\n OBJECT_NOT_FOUND = 'object-not-found',\n BUCKET_NOT_FOUND = 'bucket-not-found',\n PROJECT_NOT_FOUND = 'project-not-found',\n QUOTA_EXCEEDED = 'quota-exceeded',\n UNAUTHENTICATED = 'unauthenticated',\n UNAUTHORIZED = 'unauthorized',\n UNAUTHORIZED_APP = 'unauthorized-app',\n RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',\n INVALID_CHECKSUM = 'invalid-checksum',\n CANCELED = 'canceled',\n // JS specific\n INVALID_EVENT_NAME = 'invalid-event-name',\n INVALID_URL = 'invalid-url',\n INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',\n NO_DEFAULT_BUCKET = 'no-default-bucket',\n CANNOT_SLICE_BLOB = 'cannot-slice-blob',\n SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',\n NO_DOWNLOAD_URL = 'no-download-url',\n INVALID_ARGUMENT = 'invalid-argument',\n INVALID_ARGUMENT_COUNT = 'invalid-argument-count',\n APP_DELETED = 'app-deleted',\n INVALID_ROOT_OPERATION = 'invalid-root-operation',\n INVALID_FORMAT = 'invalid-format',\n INTERNAL_ERROR = 'internal-error',\n UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'\n}\n\nexport function prependCode(code: StorageErrorCode): string {\n return 'storage/' + code;\n}\n\nexport function unknown(): StorageError {\n const message =\n 'An unknown error occurred, please check the error payload for ' +\n 'server response.';\n return new StorageError(StorageErrorCode.UNKNOWN, message);\n}\n\nexport function objectNotFound(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.OBJECT_NOT_FOUND,\n \"Object '\" + path + \"' does not exist.\"\n );\n}\n\nexport function bucketNotFound(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.BUCKET_NOT_FOUND,\n \"Bucket '\" + bucket + \"' does not exist.\"\n );\n}\n\nexport function projectNotFound(project: string): StorageError {\n return new StorageError(\n StorageErrorCode.PROJECT_NOT_FOUND,\n \"Project '\" + project + \"' does not exist.\"\n );\n}\n\nexport function quotaExceeded(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.QUOTA_EXCEEDED,\n \"Quota for bucket '\" +\n bucket +\n \"' exceeded, please view quota on \" +\n 'https://firebase.google.com/pricing/.'\n );\n}\n\nexport function unauthenticated(): StorageError {\n const message =\n 'User is not authenticated, please authenticate using Firebase ' +\n 'Authentication and try again.';\n return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);\n}\n\nexport function unauthorizedApp(): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED_APP,\n 'This app does not have permission to access Firebase Storage on this project.'\n );\n}\n\nexport function unauthorized(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED,\n \"User does not have permission to access '\" + path + \"'.\"\n );\n}\n\nexport function retryLimitExceeded(): StorageError {\n return new StorageError(\n StorageErrorCode.RETRY_LIMIT_EXCEEDED,\n 'Max retry time for operation exceeded, please try again.'\n );\n}\n\nexport function invalidChecksum(\n path: string,\n checksum: string,\n calculated: string\n): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_CHECKSUM,\n \"Uploaded/downloaded object '\" +\n path +\n \"' has checksum '\" +\n checksum +\n \"' which does not match '\" +\n calculated +\n \"'. Please retry the upload/download.\"\n );\n}\n\nexport function canceled(): StorageError {\n return new StorageError(\n StorageErrorCode.CANCELED,\n 'User canceled the upload/download.'\n );\n}\n\nexport function invalidEventName(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_EVENT_NAME,\n \"Invalid event name '\" + name + \"'.\"\n );\n}\n\nexport function invalidUrl(url: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_URL,\n \"Invalid URL '\" + url + \"'.\"\n );\n}\n\nexport function invalidDefaultBucket(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_DEFAULT_BUCKET,\n \"Invalid default bucket '\" + bucket + \"'.\"\n );\n}\n\nexport function noDefaultBucket(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DEFAULT_BUCKET,\n 'No default bucket ' +\n \"found. Did you set the '\" +\n CONFIG_STORAGE_BUCKET_KEY +\n \"' property when initializing the app?\"\n );\n}\n\nexport function cannotSliceBlob(): StorageError {\n return new StorageError(\n StorageErrorCode.CANNOT_SLICE_BLOB,\n 'Cannot slice blob for upload. Please retry the upload.'\n );\n}\n\nexport function serverFileWrongSize(): StorageError {\n return new StorageError(\n StorageErrorCode.SERVER_FILE_WRONG_SIZE,\n 'Server recorded incorrect upload file size, please retry the upload.'\n );\n}\n\nexport function noDownloadURL(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DOWNLOAD_URL,\n 'The given file does not have any download URLs.'\n );\n}\n\nexport function missingPolyFill(polyFill: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`\n );\n}\n\n/**\n * @internal\n */\nexport function invalidArgument(message: string): StorageError {\n return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);\n}\n\nexport function invalidArgumentCount(\n argMin: number,\n argMax: number,\n fnName: string,\n real: number\n): StorageError {\n let countPart;\n let plural;\n if (argMin === argMax) {\n countPart = argMin;\n plural = argMin === 1 ? 'argument' : 'arguments';\n } else {\n countPart = 'between ' + argMin + ' and ' + argMax;\n plural = 'arguments';\n }\n return new StorageError(\n StorageErrorCode.INVALID_ARGUMENT_COUNT,\n 'Invalid argument count in `' +\n fnName +\n '`: Expected ' +\n countPart +\n ' ' +\n plural +\n ', received ' +\n real +\n '.'\n );\n}\n\nexport function appDeleted(): StorageError {\n return new StorageError(\n StorageErrorCode.APP_DELETED,\n 'The Firebase app was deleted.'\n );\n}\n\n/**\n * @param name - The name of the operation that was invalid.\n *\n * @internal\n */\nexport function invalidRootOperation(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_ROOT_OPERATION,\n \"The operation '\" +\n name +\n \"' cannot be performed on a root reference, create a non-root \" +\n \"reference using child, such as .child('file.png').\"\n );\n}\n\n/**\n * @param format - The format that was not valid.\n * @param message - A message describing the format violation.\n */\nexport function invalidFormat(format: string, message: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_FORMAT,\n \"String does not match format '\" + format + \"': \" + message\n );\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function unsupportedEnvironment(message: string): StorageError {\n throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, message);\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function internalError(message: string): StorageError {\n throw new StorageError(\n StorageErrorCode.INTERNAL_ERROR,\n 'Internal error: ' + message\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functionality related to the parsing/composition of bucket/\n * object location.\n */\n\nimport { invalidDefaultBucket, invalidUrl } from './error';\nimport { DEFAULT_HOST } from './constants';\n\n/**\n * Firebase Storage location data.\n *\n * @internal\n */\nexport class Location {\n private path_: string;\n\n constructor(public readonly bucket: string, path: string) {\n this.path_ = path;\n }\n\n get path(): string {\n return this.path_;\n }\n\n get isRoot(): boolean {\n return this.path.length === 0;\n }\n\n fullServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o/' + encode(this.path);\n }\n\n bucketOnlyServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o';\n }\n\n static makeFromBucketSpec(bucketString: string, host: string): Location {\n let bucketLocation;\n try {\n bucketLocation = Location.makeFromUrl(bucketString, host);\n } catch (e) {\n // Not valid URL, use as-is. This lets you put bare bucket names in\n // config.\n return new Location(bucketString, '');\n }\n if (bucketLocation.path === '') {\n return bucketLocation;\n } else {\n throw invalidDefaultBucket(bucketString);\n }\n }\n\n static makeFromUrl(url: string, host: string): Location {\n let location: Location | null = null;\n const bucketDomain = '([A-Za-z0-9.\\\\-_]+)';\n\n function gsModify(loc: Location): void {\n if (loc.path.charAt(loc.path.length - 1) === '/') {\n loc.path_ = loc.path_.slice(0, -1);\n }\n }\n const gsPath = '(/(.*))?$';\n const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i');\n const gsIndices = { bucket: 1, path: 3 };\n\n function httpModify(loc: Location): void {\n loc.path_ = decodeURIComponent(loc.path);\n }\n const version = 'v[A-Za-z0-9_]+';\n const firebaseStorageHost = host.replace(/[.]/g, '\\\\.');\n const firebaseStoragePath = '(/([^?#]*).*)?$';\n const firebaseStorageRegExp = new RegExp(\n `^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`,\n 'i'\n );\n const firebaseStorageIndices = { bucket: 1, path: 3 };\n\n const cloudStorageHost =\n host === DEFAULT_HOST\n ? '(?:storage.googleapis.com|storage.cloud.google.com)'\n : host;\n const cloudStoragePath = '([^?#]*)';\n const cloudStorageRegExp = new RegExp(\n `^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`,\n 'i'\n );\n const cloudStorageIndices = { bucket: 1, path: 2 };\n\n const groups = [\n { regex: gsRegex, indices: gsIndices, postModify: gsModify },\n {\n regex: firebaseStorageRegExp,\n indices: firebaseStorageIndices,\n postModify: httpModify\n },\n {\n regex: cloudStorageRegExp,\n indices: cloudStorageIndices,\n postModify: httpModify\n }\n ];\n for (let i = 0; i < groups.length; i++) {\n const group = groups[i];\n const captures = group.regex.exec(url);\n if (captures) {\n const bucketValue = captures[group.indices.bucket];\n let pathValue = captures[group.indices.path];\n if (!pathValue) {\n pathValue = '';\n }\n location = new Location(bucketValue, pathValue);\n group.postModify(location);\n break;\n }\n }\n if (location == null) {\n throw invalidUrl(url);\n }\n return location;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Request } from './request';\n\n/**\n * A request whose promise always fails.\n */\nexport class FailRequest<T> implements Request<T> {\n promise_: Promise<T>;\n\n constructor(error: StorageError) {\n this.promise_ = Promise.reject<T>(error);\n }\n\n /** @inheritDoc */\n getPromise(): Promise<T> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(_appDelete = false): void {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Provides a method for running a function with exponential\n * backoff.\n */\ntype id = (p1: boolean) => void;\n\nexport { id };\n\n/**\n * Accepts a callback for an action to perform (`doRequest`),\n * and then a callback for when the backoff has completed (`backoffCompleteCb`).\n * The callback sent to start requires an argument to call (`onRequestComplete`).\n * When `start` calls `doRequest`, it passes a callback for when the request has\n * completed, `onRequestComplete`. Based on this, the backoff continues, with\n * another call to `doRequest` and the above loop continues until the timeout\n * is hit, or a successful response occurs.\n * @description\n * @param doRequest Callback to perform request\n * @param backoffCompleteCb Callback to call when backoff has been completed\n */\nexport function start(\n doRequest: (\n onRequestComplete: (success: boolean) => void,\n canceled: boolean\n ) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n backoffCompleteCb: (...args: any[]) => unknown,\n timeout: number\n): id {\n // TODO(andysoto): make this code cleaner (probably refactor into an actual\n // type instead of a bunch of functions with state shared in the closure)\n let waitSeconds = 1;\n // Would type this as \"number\" but that doesn't work for Node so ¯\\_(ツ)_/¯\n // TODO: find a way to exclude Node type definition for storage because storage only works in browser\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let retryTimeoutId: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let globalTimeoutId: any = null;\n let hitTimeout = false;\n let cancelState = 0;\n\n function canceled(): boolean {\n return cancelState === 2;\n }\n let triggeredCallback = false;\n\n function triggerCallback(...args: any[]): void {\n if (!triggeredCallback) {\n triggeredCallback = true;\n backoffCompleteCb.apply(null, args);\n }\n }\n\n function callWithDelay(millis: number): void {\n retryTimeoutId = setTimeout(() => {\n retryTimeoutId = null;\n doRequest(responseHandler, canceled());\n }, millis);\n }\n\n function clearGlobalTimeout(): void {\n if (globalTimeoutId) {\n clearTimeout(globalTimeoutId);\n }\n }\n\n function responseHandler(success: boolean, ...args: any[]): void {\n if (triggeredCallback) {\n clearGlobalTimeout();\n return;\n }\n if (success) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n const mustStop = canceled() || hitTimeout;\n if (mustStop) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n if (waitSeconds < 64) {\n /* TODO(andysoto): don't back off so quickly if we know we're offline. */\n waitSeconds *= 2;\n }\n let waitMillis;\n if (cancelState === 1) {\n cancelState = 2;\n waitMillis = 0;\n } else {\n waitMillis = (waitSeconds + Math.random()) * 1000;\n }\n callWithDelay(waitMillis);\n }\n let stopped = false;\n\n function stop(wasTimeout: boolean): void {\n if (stopped) {\n return;\n }\n stopped = true;\n clearGlobalTimeout();\n if (triggeredCallback) {\n return;\n }\n if (retryTimeoutId !== null) {\n if (!wasTimeout) {\n cancelState = 2;\n }\n clearTimeout(retryTimeoutId);\n callWithDelay(0);\n } else {\n if (!wasTimeout) {\n cancelState = 1;\n }\n }\n }\n callWithDelay(0);\n globalTimeoutId = setTimeout(() => {\n hitTimeout = true;\n stop(true);\n }, timeout);\n return stop;\n}\n\n/**\n * Stops the retry loop from repeating.\n * If the function is currently \"in between\" retries, it is invoked immediately\n * with the second parameter as \"true\". Otherwise, it will be invoked once more\n * after the current invocation finishes iff the current invocation would have\n * triggered another retry.\n */\nexport function stop(id: id): void {\n id(false);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { invalidArgument } from './error';\n\nexport function isJustDef<T>(p: T | null | undefined): p is T | null {\n return p !== void 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isFunction(p: unknown): p is Function {\n return typeof p === 'function';\n}\n\nexport function isNonArrayObject(p: unknown): boolean {\n return typeof p === 'object' && !Array.isArray(p);\n}\n\nexport function isString(p: unknown): p is string {\n return typeof p === 'string' || p instanceof String;\n}\n\nexport function isNativeBlob(p: unknown): p is Blob {\n return isNativeBlobDefined() && p instanceof Blob;\n}\n\nexport function isNativeBlobDefined(): boolean {\n return typeof Blob !== 'undefined';\n}\n\nexport function validateNumber(\n argument: string,\n minValue: number,\n maxValue: number,\n value: number\n): void {\n if (value < minValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${minValue} or greater.`\n );\n }\n if (value > maxValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${maxValue} or less.`\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functions to create and manipulate URLs for the server API.\n */\nimport { UrlParams } from './requestinfo';\n\nexport function makeUrl(\n urlPart: string,\n host: string,\n protocol: string\n): string {\n let origin = host;\n if (protocol == null) {\n origin = `https://${host}`;\n }\n return `${protocol}://${origin}/v0${urlPart}`;\n}\n\nexport function makeQueryString(params: UrlParams): string {\n const encode = encodeURIComponent;\n let queryPart = '?';\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const nextPart = encode(key) + '=' + encode(params[key]);\n queryPart = queryPart + nextPart + '&';\n }\n }\n\n // Chop off the extra '&' or '?' on the end\n queryPart = queryPart.slice(0, -1);\n return queryPart;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Network headers */\nexport type Headers = Record<string, string>;\n\n/** Response type exposed by the networking APIs. */\nexport type ConnectionType =\n | string\n | ArrayBuffer\n | Blob\n | ReadableStream<Uint8Array>;\n\n/**\n * A lightweight wrapper around XMLHttpRequest with a\n * goog.net.XhrIo-like interface.\n *\n * You can create a new connection by invoking `newTextConnection()`,\n * `newBytesConnection()` or `newStreamConnection()`.\n */\nexport interface Connection<T extends ConnectionType> {\n /**\n * Sends a request to the provided URL.\n *\n * This method never rejects its promise. In case of encountering an error,\n * it sets an error code internally which can be accessed by calling\n * getErrorCode() by callers.\n */\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string | null,\n headers?: Headers\n ): Promise<void>;\n\n getErrorCode(): ErrorCode;\n\n getStatus(): number;\n\n getResponse(): T;\n\n getErrorText(): string;\n\n /**\n * Abort the request.\n */\n abort(): void;\n\n getResponseHeader(header: string): string | null;\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n}\n\n/**\n * Error codes for requests made by the XhrIo wrapper.\n */\nexport enum ErrorCode {\n NO_ERROR = 0,\n NETWORK_ERROR = 1,\n ABORT = 2\n}\n","/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Checks the status code to see if the action should be retried.\n *\n * @param status Current HTTP status code returned by server.\n * @param additionalRetryCodes additional retry codes to check against\n */\nexport function isRetryStatusCode(\n status: number,\n additionalRetryCodes: number[]\n): boolean {\n // The codes for which to retry came from this page:\n // https://cloud.google.com/storage/docs/exponential-backoff\n const isFiveHundredCode = status >= 500 && status < 600;\n const extraRetryCodes = [\n // Request Timeout: web server didn't receive full request in time.\n 408,\n // Too Many Requests: you're getting rate-limited, basically.\n 429\n ];\n const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;\n const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;\n return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods used to actually send HTTP requests from\n * abstract representations.\n */\n\nimport { id as backoffId, start, stop } from './backoff';\nimport { appDeleted, canceled, retryLimitExceeded, unknown } from './error';\nimport { ErrorHandler, RequestHandler, RequestInfo } from './requestinfo';\nimport { isJustDef } from './type';\nimport { makeQueryString } from './url';\nimport { Connection, ErrorCode, Headers, ConnectionType } from './connection';\nimport { isRetryStatusCode } from './utils';\n\nexport interface Request<T> {\n getPromise(): Promise<T>;\n\n /**\n * Cancels the request. IMPORTANT: the promise may still be resolved with an\n * appropriate value (if the request is finished before you call this method,\n * but the promise has not yet been resolved), so don't just assume it will be\n * rejected if you call this function.\n * @param appDelete - True if the cancelation came from the app being deleted.\n */\n cancel(appDelete?: boolean): void;\n}\n\n/**\n * Handles network logic for all Storage Requests, including error reporting and\n * retries with backoff.\n *\n * @param I - the type of the backend's network response.\n * @param - O the output type used by the rest of the SDK. The conversion\n * happens in the specified `callback_`.\n */\nclass NetworkRequest<I extends ConnectionType, O> implements Request<O> {\n private pendingConnection_: Connection<I> | null = null;\n private backoffId_: backoffId | null = null;\n private resolve_!: (value?: O | PromiseLike<O>) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private reject_!: (reason?: any) => void;\n private canceled_: boolean = false;\n private appDelete_: boolean = false;\n private promise_: Promise<O>;\n\n constructor(\n private url_: string,\n private method_: string,\n private headers_: Headers,\n private body_: string | Blob | Uint8Array | null,\n private successCodes_: number[],\n private additionalRetryCodes_: number[],\n private callback_: RequestHandler<I, O>,\n private errorCallback_: ErrorHandler | null,\n private timeout_: number,\n private progressCallback_: ((p1: number, p2: number) => void) | null,\n private connectionFactory_: () => Connection<I>,\n private retry = true,\n private isUsingEmulator = false\n ) {\n this.promise_ = new Promise((resolve, reject) => {\n this.resolve_ = resolve as (value?: O | PromiseLike<O>) => void;\n this.reject_ = reject;\n this.start_();\n });\n }\n\n /**\n * Actually starts the retry loop.\n */\n private start_(): void {\n const doTheRequest: (\n backoffCallback: (success: boolean, ...p2: unknown[]) => void,\n canceled: boolean\n ) => void = (backoffCallback, canceled) => {\n if (canceled) {\n backoffCallback(false, new RequestEndStatus(false, null, true));\n return;\n }\n const connection = this.connectionFactory_();\n this.pendingConnection_ = connection;\n\n const progressListener: (\n progressEvent: ProgressEvent\n ) => void = progressEvent => {\n const loaded = progressEvent.loaded;\n const total = progressEvent.lengthComputable ? progressEvent.total : -1;\n if (this.progressCallback_ !== null) {\n this.progressCallback_(loaded, total);\n }\n };\n if (this.progressCallback_ !== null) {\n connection.addUploadProgressListener(progressListener);\n }\n\n // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n connection\n .send(\n this.url_,\n this.method_,\n this.isUsingEmulator,\n this.body_,\n this.headers_\n )\n .then(() => {\n if (this.progressCallback_ !== null) {\n connection.removeUploadProgressListener(progressListener);\n }\n this.pendingConnection_ = null;\n const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;\n const status = connection.getStatus();\n if (\n !hitServer ||\n (isRetryStatusCode(status, this.additionalRetryCodes_) &&\n this.retry)\n ) {\n const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;\n backoffCallback(\n false,\n new RequestEndStatus(false, null, wasCanceled)\n );\n return;\n }\n const successCode = this.successCodes_.indexOf(status) !== -1;\n backoffCallback(true, new RequestEndStatus(successCode, connection));\n });\n };\n\n /**\n * @param requestWentThrough - True if the request eventually went\n * through, false if it hit the retry limit or was canceled.\n */\n const backoffDone: (\n requestWentThrough: boolean,\n status: RequestEndStatus<I>\n ) => void = (requestWentThrough, status) => {\n const resolve = this.resolve_;\n const reject = this.reject_;\n const connection = status.connection as Connection<I>;\n if (status.wasSuccessCode) {\n try {\n const result = this.callback_(connection, connection.getResponse());\n if (isJustDef(result)) {\n resolve(result);\n } else {\n resolve();\n }\n } catch (e) {\n reject(e);\n }\n } else {\n if (connection !== null) {\n const err = unknown();\n err.serverResponse = connection.getErrorText();\n if (this.errorCallback_) {\n reject(this.errorCallback_(connection, err));\n } else {\n reject(err);\n }\n } else {\n if (status.canceled) {\n const err = this.appDelete_ ? appDeleted() : canceled();\n reject(err);\n } else {\n const err = retryLimitExceeded();\n reject(err);\n }\n }\n }\n };\n if (this.canceled_) {\n backoffDone(false, new RequestEndStatus(false, null, true));\n } else {\n this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);\n }\n }\n\n /** @inheritDoc */\n getPromise(): Promise<O> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(appDelete?: boolean): void {\n this.canceled_ = true;\n this.appDelete_ = appDelete || false;\n if (this.backoffId_ !== null) {\n stop(this.backoffId_);\n }\n if (this.pendingConnection_ !== null) {\n this.pendingConnection_.abort();\n }\n }\n}\n\n/**\n * A collection of information about the result of a network request.\n * @param opt_canceled - Defaults to false.\n */\nexport class RequestEndStatus<I extends ConnectionType> {\n /**\n * True if the request was canceled.\n */\n canceled: boolean;\n\n constructor(\n public wasSuccessCode: boolean,\n public connection: Connection<I> | null,\n canceled?: boolean\n ) {\n this.canceled = !!canceled;\n }\n}\n\nexport function addAuthHeader_(\n headers: Headers,\n authToken: string | null\n): void {\n if (authToken !== null && authToken.length > 0) {\n headers['Authorization'] = 'Firebase ' + authToken;\n }\n}\n\nexport function addVersionHeader_(\n headers: Headers,\n firebaseVersion?: string\n): void {\n headers['X-Firebase-Storage-Version'] =\n 'webjs/' + (firebaseVersion ?? 'AppManager');\n}\n\nexport function addGmpidHeader_(headers: Headers, appId: string | null): void {\n if (appId) {\n headers['X-Firebase-GMPID'] = appId;\n }\n}\n\nexport function addAppCheckHeader_(\n headers: Headers,\n appCheckToken: string | null\n): void {\n if (appCheckToken !== null) {\n headers['X-Firebase-AppCheck'] = appCheckToken;\n }\n}\n\nexport function makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n appId: string | null,\n authToken: string | null,\n appCheckToken: string | null,\n requestFactory: () => Connection<I>,\n firebaseVersion?: string,\n retry = true,\n isUsingEmulator = false\n): Request<O> {\n const queryPart = makeQueryString(requestInfo.urlParams);\n const url = requestInfo.url + queryPart;\n const headers = Object.assign({}, requestInfo.headers);\n addGmpidHeader_(headers, appId);\n addAuthHeader_(headers, authToken);\n addVersionHeader_(headers, firebaseVersion);\n addAppCheckHeader_(headers, appCheckToken);\n return new NetworkRequest<I, O>(\n url,\n requestInfo.method,\n headers,\n requestInfo.body,\n requestInfo.successCodes,\n requestInfo.additionalRetryCodes,\n requestInfo.handler,\n requestInfo.errorHandler,\n requestInfo.timeout,\n requestInfo.progressCallback,\n requestFactory,\n retry,\n isUsingEmulator\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Some methods copied from goog.fs.\n * We don't include goog.fs because it pulls in a bunch of Deferred code that\n * bloats the size of the released binary.\n */\nimport { isNativeBlobDefined } from './type';\nimport { StorageErrorCode, StorageError } from './error';\n\nfunction getBlobBuilder(): typeof IBlobBuilder | undefined {\n if (typeof BlobBuilder !== 'undefined') {\n return BlobBuilder;\n } else if (typeof WebKitBlobBuilder !== 'undefined') {\n return WebKitBlobBuilder;\n } else {\n return undefined;\n }\n}\n\n/**\n * Concatenates one or more values together and converts them to a Blob.\n *\n * @param args The values that will make up the resulting blob.\n * @return The blob.\n */\nexport function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob {\n const BlobBuilder = getBlobBuilder();\n if (BlobBuilder !== undefined) {\n const bb = new BlobBuilder();\n for (let i = 0; i < args.length; i++) {\n bb.append(args[i]);\n }\n return bb.getBlob();\n } else {\n if (isNativeBlobDefined()) {\n return new Blob(args);\n } else {\n throw new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n \"This browser doesn't seem to support creating Blobs\"\n );\n }\n }\n}\n\n/**\n * Slices the blob. The returned blob contains data from the start byte\n * (inclusive) till the end byte (exclusive). Negative indices cannot be used.\n *\n * @param blob The blob to be sliced.\n * @param start Index of the starting byte.\n * @param end Index of the ending byte.\n * @return The blob slice or null if not supported.\n */\nexport function sliceBlob(blob: Blob, start: number, end: number): Blob | null {\n if (blob.webkitSlice) {\n return blob.webkitSlice(start, end);\n } else if (blob.mozSlice) {\n return blob.mozSlice(start, end);\n } else if (blob.slice) {\n return blob.slice(start, end);\n }\n return null;\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { missingPolyFill } from '../../implementation/error';\n\n/** Converts a Base64 encoded string to a binary string. */\nexport function decodeBase64(encoded: string): string {\n if (typeof atob === 'undefined') {\n throw missingPolyFill('base-64');\n }\n return atob(encoded);\n}\n\nexport function decodeUint8Array(data: Uint8Array): string {\n return new TextDecoder().decode(data);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unknown, invalidFormat } from './error';\nimport { decodeBase64 } from '../platform/base64';\n\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport const StringFormat = {\n /**\n * Indicates the string should be interpreted \"raw\", that is, as normal text.\n * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte\n * sequence.\n * Example: The string 'Hello! \\\\ud83d\\\\ude0a' becomes the byte sequence\n * 48 65 6c 6c 6f 21 20 f0 9f 98 8a\n */\n RAW: 'raw',\n /**\n * Indicates the string should be interpreted as base64-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64: 'base64',\n /**\n * Indicates the string should be interpreted as base64url-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64URL: 'base64url',\n /**\n * Indicates the string is a data URL, such as one obtained from\n * canvas.toDataURL().\n * Example: the string 'data:application/octet-stream;base64,aaaa'\n * becomes the byte sequence\n * 69 a6 9a\n * (the content-type \"application/octet-stream\" is also applied, but can\n * be overridden in the metadata object).\n */\n DATA_URL: 'data_url'\n} as const;\n\nexport class StringData {\n contentType: string | null;\n\n constructor(public data: Uint8Array, contentType?: string | null) {\n this.contentType = contentType || null;\n }\n}\n\n/**\n * @internal\n */\nexport function dataFromString(\n format: StringFormat,\n stringData: string\n): StringData {\n switch (format) {\n case StringFormat.RAW:\n return new StringData(utf8Bytes_(stringData));\n case StringFormat.BASE64:\n case StringFormat.BASE64URL:\n return new StringData(base64Bytes_(format, stringData));\n case StringFormat.DATA_URL:\n return new StringData(\n dataURLBytes_(stringData),\n dataURLContentType_(stringData)\n );\n default:\n // do nothing\n }\n\n // assert(false);\n throw unknown();\n}\n\nexport function utf8Bytes_(value: string): Uint8Array {\n const b: number[] = [];\n for (let i = 0; i < value.length; i++) {\n let c = value.charCodeAt(i);\n if (c <= 127) {\n b.push(c);\n } else {\n if (c <= 2047) {\n b.push(192 | (c >> 6), 128 | (c & 63));\n } else {\n if ((c & 64512) === 55296) {\n // The start of a surrogate pair.\n const valid =\n i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;\n if (!valid) {\n // The second surrogate wasn't there.\n b.push(239, 191, 189);\n } else {\n const hi = c;\n const lo = value.charCodeAt(++i);\n c = 65536 | ((hi & 1023) << 10) | (lo & 1023);\n b.push(\n 240 | (c >> 18),\n 128 | ((c >> 12) & 63),\n 128 | ((c >> 6) & 63),\n 128 | (c & 63)\n );\n }\n } else {\n if ((c & 64512) === 56320) {\n // Invalid low surrogate.\n b.push(239, 191, 189);\n } else {\n b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63));\n }\n }\n }\n }\n }\n return new Uint8Array(b);\n}\n\nexport function percentEncodedBytes_(value: string): Uint8Array {\n let decoded;\n try {\n decoded = decodeURIComponent(value);\n } catch (e) {\n throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.');\n }\n return utf8Bytes_(decoded);\n}\n\nexport function base64Bytes_(format: StringFormat, value: string): Uint8Array {\n switch (format) {\n case StringFormat.BASE64: {\n const hasMinus = value.indexOf('-') !== -1;\n const hasUnder = value.indexOf('_') !== -1;\n if (hasMinus || hasUnder) {\n const invalidChar = hasMinus ? '-' : '_';\n throw invalidFormat(\n format,\n \"Invalid character '\" +\n invalidChar +\n \"' found: is it base64url encoded?\"\n );\n }\n break;\n }\n case StringFormat.BASE64URL: {\n const hasPlus = value.indexOf('+') !== -1;\n const hasSlash = value.indexOf('/') !== -1;\n if (hasPlus || hasSlash) {\n const invalidChar = hasPlus ? '+' : '/';\n throw invalidFormat(\n format,\n \"Invalid character '\" + invalidChar + \"' found: is it base64 encoded?\"\n );\n }\n value = value.replace(/-/g, '+').replace(/_/g, '/');\n break;\n }\n default:\n // do nothing\n }\n let bytes;\n try {\n bytes = decodeBase64(value);\n } catch (e) {\n if ((e as Error).message.includes('polyfill')) {\n throw e;\n }\n throw invalidFormat(format, 'Invalid character found');\n }\n const array = new Uint8Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n array[i] = bytes.charCodeAt(i);\n }\n return array;\n}\n\nclass DataURLParts {\n base64: boolean = false;\n contentType: string | null = null;\n rest: string;\n\n constructor(dataURL: string) {\n const matches = dataURL.match(/^data:([^,]+)?,/);\n if (matches === null) {\n throw invalidFormat(\n StringFormat.DATA_URL,\n \"Must be formatted 'data:[<mediatype>][;base64],<data>\"\n );\n }\n const middle = matches[1] || null;\n if (middle != null) {\n this.base64 = endsWith(middle, ';base64');\n this.contentType = this.base64\n ? middle.substring(0, middle.length - ';base64'.length)\n : middle;\n }\n this.rest = dataURL.substring(dataURL.indexOf(',') + 1);\n }\n}\n\nexport function dataURLBytes_(dataUrl: string): Uint8Array {\n const parts = new DataURLParts(dataUrl);\n if (parts.base64) {\n return base64Bytes_(StringFormat.BASE64, parts.rest);\n } else {\n return percentEncodedBytes_(parts.rest);\n }\n}\n\nexport function dataURLContentType_(dataUrl: string): string | null {\n const parts = new DataURLParts(dataUrl);\n return parts.contentType;\n}\n\nfunction endsWith(s: string, end: string): boolean {\n const longEnough = s.length >= end.length;\n if (!longEnough) {\n return false;\n }\n\n return s.substring(s.length - end.length) === end;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Provides a Blob-like wrapper for various binary types (including the\n * native Blob type). This makes it possible to upload types like ArrayBuffers,\n * making uploads possible in environments without the native Blob type.\n */\nimport { sliceBlob, getBlob } from './fs';\nimport { StringFormat, dataFromString } from './string';\nimport { isNativeBlob, isNativeBlobDefined, isString } from './type';\n\n/**\n * @param opt_elideCopy - If true, doesn't copy mutable input data\n * (e.g. Uint8Arrays). Pass true only if you know the objects will not be\n * modified after this blob's construction.\n *\n * @internal\n */\nexport class FbsBlob {\n private data_!: Blob | Uint8Array;\n private size_: number;\n private type_: string;\n\n constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean) {\n let size: number = 0;\n let blobType: string = '';\n if (isNativeBlob(data)) {\n this.data_ = data as Blob;\n size = (data as Blob).size;\n blobType = (data as Blob).type;\n } else if (data instanceof ArrayBuffer) {\n if (elideCopy) {\n this.data_ = new Uint8Array(data);\n } else {\n this.data_ = new Uint8Array(data.byteLength);\n this.data_.set(new Uint8Array(data));\n }\n size = this.data_.length;\n } else if (data instanceof Uint8Array) {\n if (elideCopy) {\n this.data_ = data as Uint8Array;\n } else {\n this.data_ = new Uint8Array(data.length);\n this.data_.set(data as Uint8Array);\n }\n size = data.length;\n }\n this.size_ = size;\n this.type_ = blobType;\n }\n\n size(): number {\n return this.size_;\n }\n\n type(): string {\n return this.type_;\n }\n\n slice(startByte: number, endByte: number): FbsBlob | null {\n if (isNativeBlob(this.data_)) {\n const realBlob = this.data_ as Blob;\n const sliced = sliceBlob(realBlob, startByte, endByte);\n if (sliced === null) {\n return null;\n }\n return new FbsBlob(sliced);\n } else {\n const slice = new Uint8Array(\n (this.data_ as Uint8Array).buffer,\n startByte,\n endByte - startByte\n );\n return new FbsBlob(slice, true);\n }\n }\n\n static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null {\n if (isNativeBlobDefined()) {\n const blobby: Array<Blob | Uint8Array | string> = args.map(\n (val: string | FbsBlob): Blob | Uint8Array | string => {\n if (val instanceof FbsBlob) {\n return val.data_;\n } else {\n return val;\n }\n }\n );\n return new FbsBlob(getBlob.apply(null, blobby));\n } else {\n const uint8Arrays: Uint8Array[] = args.map(\n (val: string | FbsBlob): Uint8Array => {\n if (isString(val)) {\n return dataFromString(StringFormat.RAW, val as string).data;\n } else {\n // Blobs don't exist, so this has to be a Uint8Array.\n return (val as FbsBlob).data_ as Uint8Array;\n }\n }\n );\n let finalLength = 0;\n uint8Arrays.forEach((array: Uint8Array): void => {\n finalLength += array.byteLength;\n });\n const merged = new Uint8Array(finalLength);\n let index = 0;\n uint8Arrays.forEach((array: Uint8Array) => {\n for (let i = 0; i < array.length; i++) {\n merged[index++] = array[i];\n }\n });\n return new FbsBlob(merged, true);\n }\n }\n\n uploadData(): Blob | Uint8Array {\n return this.data_;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isNonArrayObject } from './type';\n\n/**\n * Returns the Object resulting from parsing the given JSON, or null if the\n * given string does not represent a JSON object.\n */\nexport function jsonObjectOrNull(\n s: string\n): { [name: string]: unknown } | null {\n let obj;\n try {\n obj = JSON.parse(s);\n } catch (e) {\n return null;\n }\n if (isNonArrayObject(obj)) {\n return obj;\n } else {\n return null;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Contains helper methods for manipulating paths.\n */\n\n/**\n * @return Null if the path is already at the root.\n */\nexport function parent(path: string): string | null {\n if (path.length === 0) {\n return null;\n }\n const index = path.lastIndexOf('/');\n if (index === -1) {\n return '';\n }\n const newPath = path.slice(0, index);\n return newPath;\n}\n\nexport function child(path: string, childPath: string): string {\n const canonicalChildPath = childPath\n .split('/')\n .filter(component => component.length > 0)\n .join('/');\n if (path.length === 0) {\n return canonicalChildPath;\n } else {\n return path + '/' + canonicalChildPath;\n }\n}\n\n/**\n * Returns the last component of a path.\n * '/foo/bar' -> 'bar'\n * '/foo/bar/baz/' -> 'baz/'\n * '/a' -> 'a'\n */\nexport function lastComponent(path: string): string {\n const index = path.lastIndexOf('/', path.length - 2);\n if (index === -1) {\n return path;\n } else {\n return path.slice(index + 1);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the metadata format\n */\nimport { Metadata } from '../metadata';\n\nimport { jsonObjectOrNull } from './json';\nimport { Location } from './location';\nimport { lastComponent } from './path';\nimport { isString } from './type';\nimport { makeUrl, makeQueryString } from './url';\nimport { Reference } from '../reference';\nimport { FirebaseStorageImpl } from '../service';\n\nexport function noXform_<T>(metadata: Metadata, value: T): T {\n return value;\n}\n\nclass Mapping<T> {\n local: string;\n writable: boolean;\n xform: (p1: Metadata, p2?: T) => T | undefined;\n\n constructor(\n public server: string,\n local?: string | null,\n writable?: boolean,\n xform?: ((p1: Metadata, p2?: T) => T | undefined) | null\n ) {\n this.local = local || server;\n this.writable = !!writable;\n this.xform = xform || noXform_;\n }\n}\ntype Mappings = Array<Mapping<string> | Mapping<number>>;\n\nexport { Mappings };\n\nlet mappings_: Mappings | null = null;\n\nexport function xformPath(fullPath: string | undefined): string | undefined {\n if (!isString(fullPath) || fullPath.length < 2) {\n return fullPath;\n } else {\n return lastComponent(fullPath);\n }\n}\n\nexport function getMappings(): Mappings {\n if (mappings_) {\n return mappings_;\n }\n const mappings: Mappings = [];\n mappings.push(new Mapping<string>('bucket'));\n mappings.push(new Mapping<string>('generation'));\n mappings.push(new Mapping<string>('metageneration'));\n mappings.push(new Mapping<string>('name', 'fullPath', true));\n\n function mappingsXformPath(\n _metadata: Metadata,\n fullPath: string | undefined\n ): string | undefined {\n return xformPath(fullPath);\n }\n const nameMapping = new Mapping<string>('name');\n nameMapping.xform = mappingsXformPath;\n mappings.push(nameMapping);\n\n /**\n * Coerces the second param to a number, if it is defined.\n */\n function xformSize(\n _metadata: Metadata,\n size?: number | string\n ): number | undefined {\n if (size !== undefined) {\n return Number(size);\n } else {\n return size;\n }\n }\n const sizeMapping = new Mapping<number>('size');\n sizeMapping.xform = xformSize;\n mappings.push(sizeMapping);\n mappings.push(new Mapping<number>('timeCreated'));\n mappings.push(new Mapping<string>('updated'));\n mappings.push(new Mapping<string>('md5Hash', null, true));\n mappings.push(new Mapping<string>('cacheControl', null, true));\n mappings.push(new Mapping<string>('contentDisposition', null, true));\n mappings.push(new Mapping<string>('contentEncoding', null, true));\n mappings.push(new Mapping<string>('contentLanguage', null, true));\n mappings.push(new Mapping<string>('contentType', null, true));\n mappings.push(new Mapping<string>('metadata', 'customMetadata', true));\n mappings_ = mappings;\n return mappings_;\n}\n\nexport function addRef(metadata: Metadata, service: FirebaseStorageImpl): void {\n function generateRef(): Reference {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const loc = new Location(bucket, path);\n return service._makeStorageReference(loc);\n }\n Object.defineProperty(metadata, 'ref', { get: generateRef });\n}\n\nexport function fromResource(\n service: FirebaseStorageImpl,\n resource: { [name: string]: unknown },\n mappings: Mappings\n): Metadata {\n const metadata: Metadata = {} as Metadata;\n metadata['type'] = 'file';\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n metadata[mapping.local] = (mapping as Mapping<unknown>).xform(\n metadata,\n resource[mapping.server]\n );\n }\n addRef(metadata, service);\n return metadata;\n}\n\nexport function fromResourceString(\n service: FirebaseStorageImpl,\n resourceString: string,\n mappings: Mappings\n): Metadata | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as Metadata;\n return fromResource(service, resource, mappings);\n}\n\nexport function downloadUrlFromResourceString(\n metadata: Metadata,\n resourceString: string,\n host: string,\n protocol: string\n): string | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n if (!isString(obj['downloadTokens'])) {\n // This can happen if objects are uploaded through GCS and retrieved\n // through list, so we don't want to throw an Error.\n return null;\n }\n const tokens: string = obj['downloadTokens'] as string;\n if (tokens.length === 0) {\n return null;\n }\n const encode = encodeURIComponent;\n const tokensList = tokens.split(',');\n const urls = tokensList.map((token: string): string => {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path);\n const base = makeUrl(urlPart, host, protocol);\n const queryString = makeQueryString({\n alt: 'media',\n token\n });\n return base + queryString;\n });\n return urls[0];\n}\n\nexport function toResourceString(\n metadata: Partial<Metadata>,\n mappings: Mappings\n): string {\n const resource: {\n [prop: string]: unknown;\n } = {};\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n if (mapping.writable) {\n resource[mapping.server] = metadata[mapping.local];\n }\n }\n return JSON.stringify(resource);\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the listOptions and listResult format\n */\nimport { Location } from './location';\nimport { jsonObjectOrNull } from './json';\nimport { ListResult } from '../list';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Represents the simplified object metadata returned by List API.\n * Other fields are filtered because list in Firebase Rules does not grant\n * the permission to read the metadata.\n */\ninterface ListMetadataResponse {\n name: string;\n bucket: string;\n}\n\n/**\n * Represents the JSON response of List API.\n */\ninterface ListResultResponse {\n prefixes: string[];\n items: ListMetadataResponse[];\n nextPageToken?: string;\n}\n\nconst PREFIXES_KEY = 'prefixes';\nconst ITEMS_KEY = 'items';\n\nfunction fromBackendResponse(\n service: FirebaseStorageImpl,\n bucket: string,\n resource: ListResultResponse\n): ListResult {\n const listResult: ListResult = {\n prefixes: [],\n items: [],\n nextPageToken: resource['nextPageToken']\n };\n if (resource[PREFIXES_KEY]) {\n for (const path of resource[PREFIXES_KEY]) {\n const pathWithoutTrailingSlash = path.replace(/\\/$/, '');\n const reference = service._makeStorageReference(\n new Location(bucket, pathWithoutTrailingSlash)\n );\n listResult.prefixes.push(reference);\n }\n }\n\n if (resource[ITEMS_KEY]) {\n for (const item of resource[ITEMS_KEY]) {\n const reference = service._makeStorageReference(\n new Location(bucket, item['name'])\n );\n listResult.items.push(reference);\n }\n }\n return listResult;\n}\n\nexport function fromResponseString(\n service: FirebaseStorageImpl,\n bucket: string,\n resourceString: string\n): ListResult | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as unknown as ListResultResponse;\n return fromBackendResponse(service, bucket, resource);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Headers, Connection, ConnectionType } from './connection';\n\n/**\n * Type for url params stored in RequestInfo.\n */\nexport interface UrlParams {\n [name: string]: string | number;\n}\n\n/**\n * A function that converts a server response to the API type expected by the\n * SDK.\n *\n * @param I - the type of the backend's network response\n * @param O - the output response type used by the rest of the SDK.\n */\nexport type RequestHandler<I extends ConnectionType, O> = (\n connection: Connection<I>,\n response: I\n) => O;\n\n/** A function to handle an error. */\nexport type ErrorHandler = (\n connection: Connection<ConnectionType>,\n response: StorageError\n) => StorageError;\n\n/**\n * Contains a fully specified request.\n *\n * @param I - the type of the backend's network response.\n * @param O - the output response type used by the rest of the SDK.\n */\nexport class RequestInfo<I extends ConnectionType, O> {\n urlParams: UrlParams = {};\n headers: Headers = {};\n body: Blob | string | Uint8Array | null = null;\n errorHandler: ErrorHandler | null = null;\n\n /**\n * Called with the current number of bytes uploaded and total size (-1 if not\n * computable) of the request body (i.e. used to report upload progress).\n */\n progressCallback: ((p1: number, p2: number) => void) | null = null;\n successCodes: number[] = [200];\n additionalRetryCodes: number[] = [];\n\n constructor(\n public url: string,\n public method: string,\n /**\n * Returns the value with which to resolve the request's promise. Only called\n * if the request is successful. Throw from this function to reject the\n * returned Request's promise with the thrown error.\n * Note: The XhrIo passed to this function may be reused after this callback\n * returns. Do not keep a reference to it in any way.\n */\n public handler: RequestHandler<I, O>,\n public timeout: number\n ) {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods for interacting with the network.\n */\n\nimport { Metadata } from '../metadata';\nimport { ListResult } from '../list';\nimport { FbsBlob } from './blob';\nimport {\n StorageError,\n cannotSliceBlob,\n unauthenticated,\n quotaExceeded,\n unauthorized,\n objectNotFound,\n serverFileWrongSize,\n unknown,\n unauthorizedApp\n} from './error';\nimport { Location } from './location';\nimport {\n Mappings,\n fromResourceString,\n downloadUrlFromResourceString,\n toResourceString\n} from './metadata';\nimport { fromResponseString } from './list';\nimport { RequestInfo, UrlParams } from './requestinfo';\nimport { isString } from './type';\nimport { makeUrl } from './url';\nimport { Connection, ConnectionType } from './connection';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Throws the UNKNOWN StorageError if cndn is false.\n */\nexport function handlerCheck(cndn: boolean): void {\n if (!cndn) {\n throw unknown();\n }\n}\n\nexport function metadataHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => Metadata {\n function handler(xhr: Connection<string>, text: string): Metadata {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return metadata as Metadata;\n }\n return handler;\n}\n\nexport function listHandler(\n service: FirebaseStorageImpl,\n bucket: string\n): (p1: Connection<string>, p2: string) => ListResult {\n function handler(xhr: Connection<string>, text: string): ListResult {\n const listResult = fromResponseString(service, bucket, text);\n handlerCheck(listResult !== null);\n return listResult as ListResult;\n }\n return handler;\n}\n\nexport function downloadUrlHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => string | null {\n function handler(xhr: Connection<string>, text: string): string | null {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return downloadUrlFromResourceString(\n metadata as Metadata,\n text,\n service.host,\n service._protocol\n );\n }\n return handler;\n}\n\nexport function sharedErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr: StorageError;\n if (xhr.getStatus() === 401) {\n if (\n // This exact message string is the only consistent part of the\n // server's error response that identifies it as an App Check error.\n xhr.getErrorText().includes('Firebase App Check token is invalid')\n ) {\n newErr = unauthorizedApp();\n } else {\n newErr = unauthenticated();\n }\n } else {\n if (xhr.getStatus() === 402) {\n newErr = quotaExceeded(location.bucket);\n } else {\n if (xhr.getStatus() === 403) {\n newErr = unauthorized(location.path);\n } else {\n newErr = err;\n }\n }\n }\n newErr.status = xhr.getStatus();\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function objectErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n const shared = sharedErrorHandler(location);\n\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr = shared(xhr, err);\n if (xhr.getStatus() === 404) {\n newErr = objectNotFound(location.path);\n }\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function getMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function list(\n service: FirebaseStorageImpl,\n location: Location,\n delimiter?: string,\n pageToken?: string | null,\n maxResults?: number | null\n): RequestInfo<string, ListResult> {\n const urlParams: UrlParams = {};\n if (location.isRoot) {\n urlParams['prefix'] = '';\n } else {\n urlParams['prefix'] = location.path + '/';\n }\n if (delimiter && delimiter.length > 0) {\n urlParams['delimiter'] = delimiter;\n }\n if (pageToken) {\n urlParams['pageToken'] = pageToken;\n }\n if (maxResults) {\n urlParams['maxResults'] = maxResults;\n }\n const urlPart = location.bucketOnlyServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n listHandler(service, location.bucket),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\nexport function getBytes<I extends ConnectionType>(\n service: FirebaseStorageImpl,\n location: Location,\n maxDownloadSizeBytes?: number\n): RequestInfo<I, I> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n (_: Connection<I>, data: I) => data,\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n if (maxDownloadSizeBytes !== undefined) {\n requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;\n requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];\n }\n return requestInfo;\n}\n\nexport function getDownloadUrl(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, string | null> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n downloadUrlHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function updateMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n metadata: Partial<Metadata>,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'PATCH';\n const body = toResourceString(metadata, mappings);\n const headers = { 'Content-Type': 'application/json; charset=utf-8' };\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function deleteObject(\n service: FirebaseStorageImpl,\n location: Location\n): RequestInfo<string, void> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'DELETE';\n const timeout = service.maxOperationRetryTime;\n\n function handler(_xhr: Connection<string>, _text: string): void {}\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.successCodes = [200, 204];\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function determineContentType_(\n metadata: Metadata | null,\n blob: FbsBlob | null\n): string {\n return (\n (metadata && metadata['contentType']) ||\n (blob && blob.type()) ||\n 'application/octet-stream'\n );\n}\n\nexport function metadataForUpload_(\n location: Location,\n blob: FbsBlob,\n metadata?: Metadata | null\n): Metadata {\n const metadataClone = Object.assign({}, metadata);\n metadataClone['fullPath'] = location.path;\n metadataClone['size'] = blob.size();\n if (!metadataClone['contentType']) {\n metadataClone['contentType'] = determineContentType_(null, blob);\n }\n return metadataClone;\n}\n\n/**\n * Prepare RequestInfo for uploads as Content-Type: multipart.\n */\nexport function multipartUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, Metadata> {\n const urlPart = location.bucketOnlyServerUrl();\n const headers: { [prop: string]: string } = {\n 'X-Goog-Upload-Protocol': 'multipart'\n };\n\n function genBoundary(): string {\n let str = '';\n for (let i = 0; i < 2; i++) {\n str = str + Math.random().toString().slice(2);\n }\n return str;\n }\n const boundary = genBoundary();\n headers['Content-Type'] = 'multipart/related; boundary=' + boundary;\n const metadata_ = metadataForUpload_(location, blob, metadata);\n const metadataString = toResourceString(metadata_, mappings);\n const preBlobPart =\n '--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: application/json; charset=utf-8\\r\\n\\r\\n' +\n metadataString +\n '\\r\\n--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: ' +\n metadata_['contentType'] +\n '\\r\\n\\r\\n';\n const postBlobPart = '\\r\\n--' + boundary + '--';\n const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);\n if (body === null) {\n throw cannotSliceBlob();\n }\n const urlParams: UrlParams = { name: metadata_['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param current The number of bytes that have been uploaded so far.\n * @param total The total number of bytes in the upload.\n * @param opt_finalized True if the server has finished the upload.\n * @param opt_metadata The upload metadata, should\n * only be passed if opt_finalized is true.\n */\nexport class ResumableUploadStatus {\n finalized: boolean;\n metadata: Metadata | null;\n\n constructor(\n public current: number,\n public total: number,\n finalized?: boolean,\n metadata?: Metadata | null\n ) {\n this.finalized = !!finalized;\n this.metadata = metadata || null;\n }\n}\n\nexport function checkResumeHeader_(\n xhr: Connection<string>,\n allowed?: string[]\n): string {\n let status: string | null = null;\n try {\n status = xhr.getResponseHeader('X-Goog-Upload-Status');\n } catch (e) {\n handlerCheck(false);\n }\n const allowedStatus = allowed || ['active'];\n handlerCheck(!!status && allowedStatus.indexOf(status) !== -1);\n return status as string;\n}\n\nexport function createResumableUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, string> {\n const urlPart = location.bucketOnlyServerUrl();\n const metadataForUpload = metadataForUpload_(location, blob, metadata);\n const urlParams: UrlParams = { name: metadataForUpload['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const headers = {\n 'X-Goog-Upload-Protocol': 'resumable',\n 'X-Goog-Upload-Command': 'start',\n 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`,\n 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType']!,\n 'Content-Type': 'application/json; charset=utf-8'\n };\n const body = toResourceString(metadataForUpload, mappings);\n const timeout = service.maxUploadRetryTime;\n\n function handler(xhr: Connection<string>): string {\n checkResumeHeader_(xhr);\n let url;\n try {\n url = xhr.getResponseHeader('X-Goog-Upload-URL');\n } catch (e) {\n handlerCheck(false);\n }\n handlerCheck(isString(url));\n return url as string;\n }\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n */\nexport function getResumableUploadStatus(\n service: FirebaseStorageImpl,\n location: Location,\n url: string,\n blob: FbsBlob\n): RequestInfo<string, ResumableUploadStatus> {\n const headers = { 'X-Goog-Upload-Command': 'query' };\n\n function handler(xhr: Connection<string>): ResumableUploadStatus {\n const status = checkResumeHeader_(xhr, ['active', 'final']);\n let sizeString: string | null = null;\n try {\n sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received');\n } catch (e) {\n handlerCheck(false);\n }\n\n if (!sizeString) {\n // null or empty string\n handlerCheck(false);\n }\n\n const size = Number(sizeString);\n handlerCheck(!isNaN(size));\n return new ResumableUploadStatus(size, blob.size(), status === 'final');\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * Any uploads via the resumable upload API must transfer a number of bytes\n * that is a multiple of this number.\n */\nexport const RESUMABLE_UPLOAD_CHUNK_SIZE: number = 256 * 1024;\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n * @param chunkSize Number of bytes to upload.\n * @param status The previous status.\n * If not passed or null, we start from the beginning.\n * @throws fbs.Error If the upload is already complete, the passed in status\n * has a final size inconsistent with the blob, or the blob cannot be sliced\n * for upload.\n */\nexport function continueResumableUpload(\n location: Location,\n service: FirebaseStorageImpl,\n url: string,\n blob: FbsBlob,\n chunkSize: number,\n mappings: Mappings,\n status?: ResumableUploadStatus | null,\n progressCallback?: ((p1: number, p2: number) => void) | null\n): RequestInfo<string, ResumableUploadStatus> {\n // TODO(andysoto): standardize on internal asserts\n // assert(!(opt_status && opt_status.finalized));\n const status_ = new ResumableUploadStatus(0, 0);\n if (status) {\n status_.current = status.current;\n status_.total = status.total;\n } else {\n status_.current = 0;\n status_.total = blob.size();\n }\n if (blob.size() !== status_.total) {\n throw serverFileWrongSize();\n }\n const bytesLeft = status_.total - status_.current;\n let bytesToUpload = bytesLeft;\n if (chunkSize > 0) {\n bytesToUpload = Math.min(bytesToUpload, chunkSize);\n }\n const startByte = status_.current;\n const endByte = startByte + bytesToUpload;\n let uploadCommand = '';\n if (bytesToUpload === 0) {\n uploadCommand = 'finalize';\n } else if (bytesLeft === bytesToUpload) {\n uploadCommand = 'upload, finalize';\n } else {\n uploadCommand = 'upload';\n }\n const headers = {\n 'X-Goog-Upload-Command': uploadCommand,\n 'X-Goog-Upload-Offset': `${status_.current}`\n };\n const body = blob.slice(startByte, endByte);\n if (body === null) {\n throw cannotSliceBlob();\n }\n\n function handler(\n xhr: Connection<string>,\n text: string\n ): ResumableUploadStatus {\n // TODO(andysoto): Verify the MD5 of each uploaded range:\n // the 'x-range-md5' header comes back with status code 308 responses.\n // We'll only be able to bail out though, because you can't re-upload a\n // range that you previously uploaded.\n const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']);\n const newCurrent = status_.current + bytesToUpload;\n const size = blob.size();\n let metadata;\n if (uploadStatus === 'final') {\n metadata = metadataHandler(service, mappings)(xhr, text);\n } else {\n metadata = null;\n }\n return new ResumableUploadStatus(\n newCurrent,\n size,\n uploadStatus === 'final',\n metadata\n );\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.progressCallback = progressCallback || null;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Enumerations used for upload tasks.\n */\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport type TaskEvent = string;\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport const TaskEvent = {\n /**\n * For this event,\n * <ul>\n * <li>The `next` function is triggered on progress updates and when the\n * task is paused/resumed with an `UploadTaskSnapshot` as the first\n * argument.</li>\n * <li>The `error` function is triggered if the upload is canceled or fails\n * for another reason.</li>\n * <li>The `complete` function is triggered if the upload completes\n * successfully.</li>\n * </ul>\n */\n STATE_CHANGED: 'state_changed'\n};\n\n/**\n * Internal enum for task state.\n */\nexport const enum InternalTaskState {\n RUNNING = 'running',\n PAUSING = 'pausing',\n PAUSED = 'paused',\n SUCCESS = 'success',\n CANCELING = 'canceling',\n CANCELED = 'canceled',\n ERROR = 'error'\n}\n\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport type TaskState = (typeof TaskState)[keyof typeof TaskState];\n\n// type keys = keyof TaskState\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport const TaskState = {\n /** The task is currently transferring data. */\n RUNNING: 'running',\n\n /** The task was paused by the user. */\n PAUSED: 'paused',\n\n /** The task completed successfully. */\n SUCCESS: 'success',\n\n /** The task was canceled. */\n CANCELED: 'canceled',\n\n /** The task failed with an error. */\n ERROR: 'error'\n} as const;\n\nexport function taskStateFromInternalTaskState(\n state: InternalTaskState\n): TaskState {\n switch (state) {\n case InternalTaskState.RUNNING:\n case InternalTaskState.PAUSING:\n case InternalTaskState.CANCELING:\n return TaskState.RUNNING;\n case InternalTaskState.PAUSED:\n return TaskState.PAUSED;\n case InternalTaskState.SUCCESS:\n return TaskState.SUCCESS;\n case InternalTaskState.CANCELED:\n return TaskState.CANCELED;\n case InternalTaskState.ERROR:\n return TaskState.ERROR;\n default:\n // TODO(andysoto): assert(false);\n return TaskState.ERROR;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isFunction } from './type';\nimport { StorageError } from './error';\n\n/**\n * Function that is called once for each value in a stream of values.\n */\nexport type NextFn<T> = (value: T) => void;\n\n/**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\nexport type ErrorFn = (error: StorageError) => void;\n\n/**\n * A function that is called if the event stream ends normally.\n */\nexport type CompleteFn = () => void;\n\n/**\n * Unsubscribes from a stream.\n */\nexport type Unsubscribe = () => void;\n\n/**\n * An observer identical to the `Observer` defined in packages/util except the\n * error passed into the ErrorFn is specifically a `StorageError`.\n */\nexport interface StorageObserver<T> {\n /**\n * Function that is called once for each value in the event stream.\n */\n next?: NextFn<T>;\n /**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\n error?: ErrorFn;\n /**\n * A function that is called if the event stream ends normally.\n */\n complete?: CompleteFn;\n}\n\n/**\n * Subscribes to an event stream.\n */\nexport type Subscribe<T> = (\n next?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n) => Unsubscribe;\n\nexport class Observer<T> implements StorageObserver<T> {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n\n constructor(\n nextOrObserver?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n ) {\n const asFunctions =\n isFunction(nextOrObserver) || error != null || complete != null;\n if (asFunctions) {\n this.next = nextOrObserver as NextFn<T>;\n this.error = error ?? undefined;\n this.complete = complete ?? undefined;\n } else {\n const observer = nextOrObserver as {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n };\n this.next = observer.next;\n this.error = observer.error;\n this.complete = observer.complete;\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a function that invokes f with its arguments asynchronously as a\n * microtask, i.e. as soon as possible after the current script returns back\n * into browser code.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function async(f: Function): Function {\n return (...argsToForward: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => f(...argsToForward));\n };\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isCloudWorkstation } from '@firebase/util';\nimport {\n Connection,\n ConnectionType,\n ErrorCode,\n Headers\n} from '../../implementation/connection';\nimport { internalError } from '../../implementation/error';\n\n/** An override for the text-based Connection. Used in tests. */\nlet textFactoryOverride: (() => Connection<string>) | null = null;\n\n/**\n * Network layer for browsers. We use this instead of goog.net.XhrIo because\n * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.\n */\nabstract class XhrConnection<T extends ConnectionType>\n implements Connection<T>\n{\n protected xhr_: XMLHttpRequest;\n private errorCode_: ErrorCode;\n private sendPromise_: Promise<void>;\n protected sent_: boolean = false;\n\n constructor() {\n this.xhr_ = new XMLHttpRequest();\n this.initXhr();\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.sendPromise_ = new Promise(resolve => {\n this.xhr_.addEventListener('abort', () => {\n this.errorCode_ = ErrorCode.ABORT;\n resolve();\n });\n this.xhr_.addEventListener('error', () => {\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n resolve();\n });\n this.xhr_.addEventListener('load', () => {\n resolve();\n });\n });\n }\n\n abstract initXhr(): void;\n\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string,\n headers?: Headers\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n if (isCloudWorkstation(url) && isUsingEmulator) {\n this.xhr_.withCredentials = true;\n }\n this.sent_ = true;\n this.xhr_.open(method, url, true);\n if (headers !== undefined) {\n for (const key in headers) {\n if (headers.hasOwnProperty(key)) {\n this.xhr_.setRequestHeader(key, headers[key].toString());\n }\n }\n }\n if (body !== undefined) {\n this.xhr_.send(body);\n } else {\n this.xhr_.send();\n }\n return this.sendPromise_;\n }\n\n getErrorCode(): ErrorCode {\n if (!this.sent_) {\n throw internalError('cannot .getErrorCode() before sending');\n }\n return this.errorCode_;\n }\n\n getStatus(): number {\n if (!this.sent_) {\n throw internalError('cannot .getStatus() before sending');\n }\n try {\n return this.xhr_.status;\n } catch (e) {\n return -1;\n }\n }\n\n getResponse(): T {\n if (!this.sent_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.xhr_.response;\n }\n\n getErrorText(): string {\n if (!this.sent_) {\n throw internalError('cannot .getErrorText() before sending');\n }\n return this.xhr_.statusText;\n }\n\n /** Aborts the request. */\n abort(): void {\n this.xhr_.abort();\n }\n\n getResponseHeader(header: string): string | null {\n return this.xhr_.getResponseHeader(header);\n }\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n if (this.xhr_.upload != null) {\n this.xhr_.upload.addEventListener('progress', listener);\n }\n }\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n if (this.xhr_.upload != null) {\n this.xhr_.upload.removeEventListener('progress', listener);\n }\n }\n}\n\nexport class XhrTextConnection extends XhrConnection<string> {\n initXhr(): void {\n this.xhr_.responseType = 'text';\n }\n}\n\nexport function newTextConnection(): Connection<string> {\n return textFactoryOverride ? textFactoryOverride() : new XhrTextConnection();\n}\n\nexport class XhrBytesConnection extends XhrConnection<ArrayBuffer> {\n private data_?: ArrayBuffer;\n\n initXhr(): void {\n this.xhr_.responseType = 'arraybuffer';\n }\n}\n\nexport function newBytesConnection(): Connection<ArrayBuffer> {\n return new XhrBytesConnection();\n}\n\nexport class XhrBlobConnection extends XhrConnection<Blob> {\n initXhr(): void {\n this.xhr_.responseType = 'blob';\n }\n}\n\nexport function newBlobConnection(): Connection<Blob> {\n return new XhrBlobConnection();\n}\n\nexport function newStreamConnection(): Connection<ReadableStream> {\n throw new Error('Streams are only supported on Node');\n}\n\nexport function injectTestConnection(\n factory: (() => Connection<string>) | null\n): void {\n textFactoryOverride = factory;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Defines types for interacting with blob transfer tasks.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport {\n canceled,\n StorageErrorCode,\n StorageError,\n retryLimitExceeded\n} from './implementation/error';\nimport {\n InternalTaskState,\n TaskEvent,\n TaskState,\n taskStateFromInternalTaskState\n} from './implementation/taskenums';\nimport { Metadata } from './metadata';\nimport {\n Observer,\n Subscribe,\n Unsubscribe,\n StorageObserver as StorageObserverInternal,\n NextFn\n} from './implementation/observer';\nimport { Request } from './implementation/request';\nimport { UploadTaskSnapshot, StorageObserver } from './public-types';\nimport { async as fbsAsync } from './implementation/async';\nimport { Mappings, getMappings } from './implementation/metadata';\nimport {\n createResumableUpload,\n getResumableUploadStatus,\n RESUMABLE_UPLOAD_CHUNK_SIZE,\n ResumableUploadStatus,\n continueResumableUpload,\n getMetadata,\n multipartUpload\n} from './implementation/requests';\nimport { Reference } from './reference';\nimport { newTextConnection } from './platform/connection';\nimport { isRetryStatusCode } from './implementation/utils';\nimport { CompleteFn } from '@firebase/util';\nimport { DEFAULT_MIN_SLEEP_TIME_MILLIS } from './implementation/constants';\n\n/**\n * Represents a blob being uploaded. Can be used to pause/resume/cancel the\n * upload and manage callbacks for various events.\n * @internal\n */\nexport class UploadTask {\n private _ref: Reference;\n /**\n * The data to be uploaded.\n */\n _blob: FbsBlob;\n /**\n * Metadata related to the upload.\n */\n _metadata: Metadata | null;\n private _mappings: Mappings;\n /**\n * Number of bytes transferred so far.\n */\n _transferred: number = 0;\n private _needToFetchStatus: boolean = false;\n private _needToFetchMetadata: boolean = false;\n private _observers: Array<StorageObserverInternal<UploadTaskSnapshot>> = [];\n private _resumable: boolean;\n /**\n * Upload state.\n */\n _state: InternalTaskState;\n private _error?: StorageError = undefined;\n private _uploadUrl?: string = undefined;\n private _request?: Request<unknown> = undefined;\n private _chunkMultiplier: number = 1;\n private _errorHandler: (p1: StorageError) => void;\n private _metadataErrorHandler: (p1: StorageError) => void;\n private _resolve?: (p1: UploadTaskSnapshot) => void = undefined;\n private _reject?: (p1: StorageError) => void = undefined;\n private pendingTimeout?: ReturnType<typeof setTimeout>;\n private _promise: Promise<UploadTaskSnapshot>;\n\n private sleepTime: number;\n\n private maxSleepTime: number;\n\n isExponentialBackoffExpired(): boolean {\n return this.sleepTime > this.maxSleepTime;\n }\n\n /**\n * @param ref - The firebaseStorage.Reference object this task came\n * from, untyped to avoid cyclic dependencies.\n * @param blob - The blob to upload.\n */\n constructor(ref: Reference, blob: FbsBlob, metadata: Metadata | null = null) {\n this._ref = ref;\n this._blob = blob;\n this._metadata = metadata;\n this._mappings = getMappings();\n this._resumable = this._shouldDoResumable(this._blob);\n this._state = InternalTaskState.RUNNING;\n this._errorHandler = error => {\n this._request = undefined;\n this._chunkMultiplier = 1;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this._needToFetchStatus = true;\n this.completeTransitions_();\n } else {\n const backoffExpired = this.isExponentialBackoffExpired();\n if (isRetryStatusCode(error.status, [])) {\n if (backoffExpired) {\n error = retryLimitExceeded();\n } else {\n this.sleepTime = Math.max(\n this.sleepTime * 2,\n DEFAULT_MIN_SLEEP_TIME_MILLIS\n );\n this._needToFetchStatus = true;\n this.completeTransitions_();\n return;\n }\n }\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this._metadataErrorHandler = error => {\n this._request = undefined;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this.completeTransitions_();\n } else {\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this.sleepTime = 0;\n this.maxSleepTime = this._ref.storage.maxUploadRetryTime;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n this._start();\n });\n\n // Prevent uncaught rejections on the internal promise from bubbling out\n // to the top level with a dummy handler.\n this._promise.then(null, () => {});\n }\n\n private _makeProgressCallback(): (p1: number, p2: number) => void {\n const sizeBefore = this._transferred;\n return loaded => this._updateProgress(sizeBefore + loaded);\n }\n\n private _shouldDoResumable(blob: FbsBlob): boolean {\n return blob.size() > 256 * 1024;\n }\n\n private _start(): void {\n if (this._state !== InternalTaskState.RUNNING) {\n // This can happen if someone pauses us in a resume callback, for example.\n return;\n }\n if (this._request !== undefined) {\n return;\n }\n if (this._resumable) {\n if (this._uploadUrl === undefined) {\n this._createResumable();\n } else {\n if (this._needToFetchStatus) {\n this._fetchStatus();\n } else {\n if (this._needToFetchMetadata) {\n // Happens if we miss the metadata on upload completion.\n this._fetchMetadata();\n } else {\n this.pendingTimeout = setTimeout(() => {\n this.pendingTimeout = undefined;\n this._continueUpload();\n }, this.sleepTime);\n }\n }\n }\n } else {\n this._oneShotUpload();\n }\n }\n\n private _resolveToken(\n callback: (authToken: string | null, appCheckToken: string | null) => void\n ): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all([\n this._ref.storage._getAuthToken(),\n this._ref.storage._getAppCheckToken()\n ]).then(([authToken, appCheckToken]) => {\n switch (this._state) {\n case InternalTaskState.RUNNING:\n callback(authToken, appCheckToken);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n default:\n }\n });\n }\n\n // TODO(andysoto): assert false\n\n private _createResumable(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = createResumableUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const createRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = createRequest;\n createRequest.getPromise().then((url: string) => {\n this._request = undefined;\n this._uploadUrl = url;\n this._needToFetchStatus = false;\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _fetchStatus(): void {\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getResumableUploadStatus(\n this._ref.storage,\n this._ref._location,\n url,\n this._blob\n );\n const statusRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = statusRequest;\n statusRequest.getPromise().then(status => {\n status = status as ResumableUploadStatus;\n this._request = undefined;\n this._updateProgress(status.current);\n this._needToFetchStatus = false;\n if (status.finalized) {\n this._needToFetchMetadata = true;\n }\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _continueUpload(): void {\n const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n const status = new ResumableUploadStatus(\n this._transferred,\n this._blob.size()\n );\n\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n let requestInfo;\n try {\n requestInfo = continueResumableUpload(\n this._ref._location,\n this._ref.storage,\n url,\n this._blob,\n chunkSize,\n this._mappings,\n status,\n this._makeProgressCallback()\n );\n } catch (e) {\n this._error = e as StorageError;\n this._transition(InternalTaskState.ERROR);\n return;\n }\n const uploadRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken,\n /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file.\n );\n this._request = uploadRequest;\n uploadRequest.getPromise().then((newStatus: ResumableUploadStatus) => {\n this._increaseMultiplier();\n this._request = undefined;\n this._updateProgress(newStatus.current);\n if (newStatus.finalized) {\n this._metadata = newStatus.metadata;\n this._transition(InternalTaskState.SUCCESS);\n } else {\n this.completeTransitions_();\n }\n }, this._errorHandler);\n });\n }\n\n private _increaseMultiplier(): void {\n const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n\n // Max chunk size is 32M.\n if (currentSize * 2 < 32 * 1024 * 1024) {\n this._chunkMultiplier *= 2;\n }\n }\n\n private _fetchMetadata(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getMetadata(\n this._ref.storage,\n this._ref._location,\n this._mappings\n );\n const metadataRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = metadataRequest;\n metadataRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._transition(InternalTaskState.SUCCESS);\n }, this._metadataErrorHandler);\n });\n }\n\n private _oneShotUpload(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = multipartUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const multipartRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = multipartRequest;\n multipartRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._updateProgress(this._blob.size());\n this._transition(InternalTaskState.SUCCESS);\n }, this._errorHandler);\n });\n }\n\n private _updateProgress(transferred: number): void {\n const old = this._transferred;\n this._transferred = transferred;\n\n // A progress update can make the \"transferred\" value smaller (e.g. a\n // partial upload not completed by server, after which the \"transferred\"\n // value may reset to the value at the beginning of the request).\n if (this._transferred !== old) {\n this._notifyObservers();\n }\n }\n\n private _transition(state: InternalTaskState): void {\n if (this._state === state) {\n return;\n }\n switch (state) {\n case InternalTaskState.CANCELING:\n case InternalTaskState.PAUSING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n if (this._request !== undefined) {\n this._request.cancel();\n } else if (this.pendingTimeout) {\n clearTimeout(this.pendingTimeout);\n this.pendingTimeout = undefined;\n this.completeTransitions_();\n }\n break;\n case InternalTaskState.RUNNING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.PAUSING);\n const wasPaused = this._state === InternalTaskState.PAUSED;\n this._state = state;\n if (wasPaused) {\n this._notifyObservers();\n this._start();\n }\n break;\n case InternalTaskState.PAUSED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.CANCELED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.CANCELING);\n this._error = canceled();\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.ERROR:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.SUCCESS:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n default: // Ignore\n }\n }\n\n private completeTransitions_(): void {\n switch (this._state) {\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.RUNNING:\n this._start();\n break;\n default:\n // TODO(andysoto): assert(false);\n break;\n }\n }\n\n /**\n * A snapshot of the current task state.\n */\n get snapshot(): UploadTaskSnapshot {\n const externalState = taskStateFromInternalTaskState(this._state);\n return {\n bytesTransferred: this._transferred,\n totalBytes: this._blob.size(),\n state: externalState,\n metadata: this._metadata!,\n task: this,\n ref: this._ref\n };\n }\n\n /**\n * Adds a callback for an event.\n * @param type - The type of event to listen for.\n * @param nextOrObserver -\n * The `next` function, which gets called for each item in\n * the event stream, or an observer object with some or all of these three\n * properties (`next`, `error`, `complete`).\n * @param error - A function that gets called with a `StorageError`\n * if the event stream ends due to an error.\n * @param completed - A function that gets called if the\n * event stream ends normally.\n * @returns\n * If only the event argument is passed, returns a function you can use to\n * add callbacks (see the examples above). If more than just the event\n * argument is passed, returns a function you can call to unregister the\n * callbacks.\n */\n on(\n type: TaskEvent,\n nextOrObserver?:\n | StorageObserver<UploadTaskSnapshot>\n | null\n | ((snapshot: UploadTaskSnapshot) => unknown),\n error?: ((a: StorageError) => unknown) | null,\n completed?: CompleteFn | null\n ): Unsubscribe | Subscribe<UploadTaskSnapshot> {\n // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string.\n const observer = new Observer(\n (nextOrObserver as\n | StorageObserverInternal<UploadTaskSnapshot>\n | NextFn<UploadTaskSnapshot>) || undefined,\n error || undefined,\n completed || undefined\n );\n this._addObserver(observer);\n return () => {\n this._removeObserver(observer);\n };\n }\n\n /**\n * This object behaves like a Promise, and resolves with its snapshot data\n * when the upload completes.\n * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.\n * @param onRejected - The rejection callback.\n */\n then<U>(\n onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null,\n onRejected?: ((error: StorageError) => U | Promise<U>) | null\n ): Promise<U> {\n // These casts are needed so that TypeScript can infer the types of the\n // resulting Promise.\n return this._promise.then<U>(\n onFulfilled as (value: UploadTaskSnapshot) => U | Promise<U>,\n onRejected as ((error: unknown) => Promise<never>) | null\n );\n }\n\n /**\n * Equivalent to calling `then(null, onRejected)`.\n */\n catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T> {\n return this.then(null, onRejected);\n }\n\n /**\n * Adds the given observer.\n */\n private _addObserver(observer: Observer<UploadTaskSnapshot>): void {\n this._observers.push(observer);\n this._notifyObserver(observer);\n }\n\n /**\n * Removes the given observer.\n */\n private _removeObserver(observer: Observer<UploadTaskSnapshot>): void {\n const i = this._observers.indexOf(observer);\n if (i !== -1) {\n this._observers.splice(i, 1);\n }\n }\n\n private _notifyObservers(): void {\n this._finishPromise();\n const observers = this._observers.slice();\n observers.forEach(observer => {\n this._notifyObserver(observer);\n });\n }\n\n private _finishPromise(): void {\n if (this._resolve !== undefined) {\n let triggered = true;\n switch (taskStateFromInternalTaskState(this._state)) {\n case TaskState.SUCCESS:\n fbsAsync(this._resolve.bind(null, this.snapshot))();\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n const toCall = this._reject as (p1: StorageError) => void;\n fbsAsync(toCall.bind(null, this._error as StorageError))();\n break;\n default:\n triggered = false;\n break;\n }\n if (triggered) {\n this._resolve = undefined;\n this._reject = undefined;\n }\n }\n }\n\n private _notifyObserver(observer: Observer<UploadTaskSnapshot>): void {\n const externalState = taskStateFromInternalTaskState(this._state);\n switch (externalState) {\n case TaskState.RUNNING:\n case TaskState.PAUSED:\n if (observer.next) {\n fbsAsync(observer.next.bind(observer, this.snapshot))();\n }\n break;\n case TaskState.SUCCESS:\n if (observer.complete) {\n fbsAsync(observer.complete.bind(observer))();\n }\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n break;\n default:\n // TODO(andysoto): assert(false);\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n }\n }\n\n /**\n * Resumes a paused task. Has no effect on a currently running or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n resume(): boolean {\n const valid =\n this._state === InternalTaskState.PAUSED ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.RUNNING);\n }\n return valid;\n }\n\n /**\n * Pauses a currently running task. Has no effect on a paused or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n pause(): boolean {\n const valid = this._state === InternalTaskState.RUNNING;\n if (valid) {\n this._transition(InternalTaskState.PAUSING);\n }\n return valid;\n }\n\n /**\n * Cancels a currently running or paused task. Has no effect on a complete or\n * failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n cancel(): boolean {\n const valid =\n this._state === InternalTaskState.RUNNING ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.CANCELING);\n }\n return valid;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines the Firebase StorageReference class.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport { Location } from './implementation/location';\nimport { getMappings } from './implementation/metadata';\nimport { child, lastComponent, parent } from './implementation/path';\nimport {\n deleteObject as requestsDeleteObject,\n getBytes,\n getDownloadUrl as requestsGetDownloadUrl,\n getMetadata as requestsGetMetadata,\n list as requestsList,\n multipartUpload,\n updateMetadata as requestsUpdateMetadata\n} from './implementation/requests';\nimport { ListOptions, UploadResult } from './public-types';\nimport { dataFromString, StringFormat } from './implementation/string';\nimport { Metadata } from './metadata';\nimport { FirebaseStorageImpl } from './service';\nimport { ListResult } from './list';\nimport { UploadTask } from './task';\nimport { invalidRootOperation, noDownloadURL } from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport {\n newBlobConnection,\n newBytesConnection,\n newStreamConnection,\n newTextConnection\n} from './platform/connection';\nimport { RequestInfo } from './implementation/requestinfo';\n\n/**\n * Provides methods to interact with a bucket in the Firebase Storage service.\n * @internal\n * @param _location - An fbs.location, or the URL at\n * which to base this object, in one of the following forms:\n * gs://<bucket>/<object-path>\n * http[s]://firebasestorage.googleapis.com/\n * <api-version>/b/<bucket>/o/<object-path>\n * Any query or fragment strings will be ignored in the http[s]\n * format. If no value is passed, the storage object will use a URL based on\n * the project ID of the base firebase.App instance.\n */\nexport class Reference {\n _location: Location;\n\n constructor(\n private _service: FirebaseStorageImpl,\n location: string | Location\n ) {\n if (location instanceof Location) {\n this._location = location;\n } else {\n this._location = Location.makeFromUrl(location, _service.host);\n }\n }\n\n /**\n * Returns the URL for the bucket and path this object references,\n * in the form gs://<bucket>/<object-path>\n * @override\n */\n toString(): string {\n return 'gs://' + this._location.bucket + '/' + this._location.path;\n }\n\n protected _newRef(\n service: FirebaseStorageImpl,\n location: Location\n ): Reference {\n return new Reference(service, location);\n }\n\n /**\n * A reference to the root of this object's bucket.\n */\n get root(): Reference {\n const location = new Location(this._location.bucket, '');\n return this._newRef(this._service, location);\n }\n\n /**\n * The name of the bucket containing this reference's object.\n */\n get bucket(): string {\n return this._location.bucket;\n }\n\n /**\n * The full path of this object.\n */\n get fullPath(): string {\n return this._location.path;\n }\n\n /**\n * The short name of this object, which is the last component of the full path.\n * For example, if fullPath is 'full/path/image.png', name is 'image.png'.\n */\n get name(): string {\n return lastComponent(this._location.path);\n }\n\n /**\n * The `StorageService` instance this `StorageReference` is associated with.\n */\n get storage(): FirebaseStorageImpl {\n return this._service;\n }\n\n /**\n * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if\n * this reference is the root.\n */\n get parent(): Reference | null {\n const newPath = parent(this._location.path);\n if (newPath === null) {\n return null;\n }\n const location = new Location(this._location.bucket, newPath);\n return new Reference(this._service, location);\n }\n\n /**\n * Utility function to throw an error in methods that do not accept a root reference.\n */\n _throwIfRoot(name: string): void {\n if (this._location.path === '') {\n throw invalidRootOperation(name);\n }\n }\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded bytes.\n */\nexport function getBytesInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref._throwIfRoot('getBytes');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBytesConnection)\n .then(bytes =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (bytes as ArrayBuffer).slice(0, maxDownloadSizeBytes)\n : (bytes as ArrayBuffer)\n );\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded blob.\n */\nexport function getBlobInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref._throwIfRoot('getBlob');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBlobConnection)\n .then(blob =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (blob as Blob).slice(0, maxDownloadSizeBytes)\n : (blob as Blob)\n );\n}\n\n/** Stream the bytes at the object's location. */\nexport function getStreamInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref._throwIfRoot('getStream');\n const requestInfo: RequestInfo<ReadableStream, ReadableStream> = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n\n // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result\n const newMaxSizeTransform = (n: number): Transformer => {\n let missingBytes = n;\n return {\n transform(chunk, controller: TransformStreamDefaultController) {\n // GCS may not honor the Range header for small files\n if (chunk.length < missingBytes) {\n controller.enqueue(chunk);\n missingBytes -= chunk.length;\n } else {\n controller.enqueue(chunk.slice(0, missingBytes));\n controller.terminate();\n }\n }\n };\n };\n\n const result =\n maxDownloadSizeBytes !== undefined\n ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))\n : new TransformStream(); // The default transformer forwards all chunks to its readable side\n\n ref.storage\n .makeRequestWithTokens(requestInfo, newStreamConnection)\n .then(readableStream => readableStream.pipeThrough(result))\n .catch(err => result.writable.abort(err));\n\n return result.readable;\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n *\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadBytes');\n const requestInfo = multipartUpload(\n ref.storage,\n ref._location,\n getMappings(),\n new FbsBlob(data, true),\n metadata\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(finalMetadata => {\n return {\n metadata: finalMetadata,\n ref\n };\n });\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): UploadTask {\n ref._throwIfRoot('uploadBytesResumable');\n return new UploadTask(ref, new FbsBlob(data), metadata);\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - StorageReference where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the newly uploaded string.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: Reference,\n value: string,\n format: StringFormat = StringFormat.RAW,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadString');\n const data = dataFromString(format, value);\n const metadataClone = { ...metadata } as Metadata;\n if (metadataClone['contentType'] == null && data.contentType != null) {\n metadataClone['contentType'] = data.contentType!;\n }\n return uploadBytes(ref, data.data, metadataClone);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: listAll may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - StorageReference to get list from.\n *\n * @returns A Promise that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: Reference): Promise<ListResult> {\n const accumulator: ListResult = {\n prefixes: [],\n items: []\n };\n return listAllHelper(ref, accumulator).then(() => accumulator);\n}\n\n/**\n * Separated from listAll because async functions can't use \"arguments\".\n * @param ref\n * @param accumulator\n * @param pageToken\n */\nasync function listAllHelper(\n ref: Reference,\n accumulator: ListResult,\n pageToken?: string\n): Promise<void> {\n const opt: ListOptions = {\n // maxResults is 1000 by default.\n pageToken\n };\n const nextPage = await list(ref, opt);\n accumulator.prefixes.push(...nextPage.prefixes);\n accumulator.items.push(...nextPage.items);\n if (nextPage.nextPageToken != null) {\n await listAllHelper(ref, accumulator, nextPage.nextPageToken);\n }\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - StorageReference to get list from.\n * @param options - See ListOptions for details.\n * @returns A Promise that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: Reference,\n options?: ListOptions | null\n): Promise<ListResult> {\n if (options != null) {\n if (typeof options.maxResults === 'number') {\n validateNumber(\n 'options.maxResults',\n /* minValue= */ 1,\n /* maxValue= */ 1000,\n options.maxResults\n );\n }\n }\n const op = options || {};\n const requestInfo = requestsList(\n ref.storage,\n ref._location,\n /*delimiter= */ '/',\n op.pageToken,\n op.maxResults\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - StorageReference to get metadata from.\n */\nexport function getMetadata(ref: Reference): Promise<Metadata> {\n ref._throwIfRoot('getMetadata');\n const requestInfo = requestsGetMetadata(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - StorageReference to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves\n * with the new metadata for this object.\n * See `firebaseStorage.Reference.prototype.getMetadata`\n */\nexport function updateMetadata(\n ref: Reference,\n metadata: Partial<Metadata>\n): Promise<Metadata> {\n ref._throwIfRoot('updateMetadata');\n const requestInfo = requestsUpdateMetadata(\n ref.storage,\n ref._location,\n metadata,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns the download URL for the given Reference.\n * @public\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: Reference): Promise<string> {\n ref._throwIfRoot('getDownloadURL');\n const requestInfo = requestsGetDownloadUrl(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(url => {\n if (url === null) {\n throw noDownloadURL();\n }\n return url;\n });\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - StorageReference for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: Reference): Promise<void> {\n ref._throwIfRoot('deleteObject');\n const requestInfo = requestsDeleteObject(ref.storage, ref._location);\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns reference for object obtained by appending `childPath` to `ref`.\n *\n * @param ref - StorageReference to get child of.\n * @param childPath - Child path from provided ref.\n * @returns A reference to the object obtained by\n * appending childPath, removing any duplicate, beginning, or trailing\n * slashes.\n *\n */\nexport function _getChild(ref: Reference, childPath: string): Reference {\n const newPath = child(ref._location.path, childPath);\n const location = new Location(ref._location.bucket, newPath);\n return new Reference(ref.storage, location);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Location } from './implementation/location';\nimport { FailRequest } from './implementation/failrequest';\nimport { Request, makeRequest } from './implementation/request';\nimport { RequestInfo } from './implementation/requestinfo';\nimport { Reference, _getChild } from './reference';\nimport { Provider } from '@firebase/component';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n FirebaseApp,\n FirebaseOptions,\n _isFirebaseServerApp\n} from '@firebase/app';\nimport {\n CONFIG_STORAGE_BUCKET_KEY,\n DEFAULT_HOST,\n DEFAULT_MAX_OPERATION_RETRY_TIME,\n DEFAULT_MAX_UPLOAD_RETRY_TIME\n} from './implementation/constants';\nimport {\n invalidArgument,\n appDeleted,\n noDefaultBucket\n} from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport { FirebaseStorage } from './public-types';\nimport {\n createMockUserToken,\n EmulatorMockTokenOptions,\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\nimport { Connection, ConnectionType } from './implementation/connection';\n\nexport function isUrl(path?: string): boolean {\n return /^[A-Za-z]+:\\/\\//.test(path as string);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given url.\n */\nfunction refFromURL(service: FirebaseStorageImpl, url: string): Reference {\n return new Reference(service, url);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given path in the default\n * bucket.\n */\nfunction refFromPath(\n ref: FirebaseStorageImpl | Reference,\n path?: string\n): Reference {\n if (ref instanceof FirebaseStorageImpl) {\n const service = ref;\n if (service._bucket == null) {\n throw noDefaultBucket();\n }\n const reference = new Reference(service, service._bucket!);\n if (path != null) {\n return refFromPath(reference, path);\n } else {\n return reference;\n }\n } else {\n // ref is a Reference\n if (path !== undefined) {\n return _getChild(ref, path);\n } else {\n return ref;\n }\n }\n}\n\n/**\n * Returns a storage Reference for the given url.\n * @param storage - `Storage` instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorageImpl, url?: string): Reference;\n/**\n * Returns a storage Reference for the given path in the\n * default bucket.\n * @param storageOrRef - `Storage` service or storage `Reference`.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage\n * instance provided) or returns same reference (if Reference provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorageImpl | Reference,\n path?: string\n): Reference;\nexport function ref(\n serviceOrRef: FirebaseStorageImpl | Reference,\n pathOrUrl?: string\n): Reference | null {\n if (pathOrUrl && isUrl(pathOrUrl)) {\n if (serviceOrRef instanceof FirebaseStorageImpl) {\n return refFromURL(serviceOrRef, pathOrUrl);\n } else {\n throw invalidArgument(\n 'To use ref(service, url), the first argument must be a Storage instance.'\n );\n }\n } else {\n return refFromPath(serviceOrRef, pathOrUrl);\n }\n}\n\nfunction extractBucket(\n host: string,\n config?: FirebaseOptions\n): Location | null {\n const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY];\n if (bucketString == null) {\n return null;\n }\n return Location.makeFromBucketSpec(bucketString, host);\n}\n\nexport function connectStorageEmulator(\n storage: FirebaseStorageImpl,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n storage.host = `${host}:${port}`;\n const useSsl = isCloudWorkstation(host);\n // Workaround to get cookies in Firebase Studio\n if (useSsl) {\n void pingServer(`https://${storage.host}/b`);\n updateEmulatorBanner('Storage', true);\n }\n storage._isUsingEmulator = true;\n storage._protocol = useSsl ? 'https' : 'http';\n const { mockUserToken } = options;\n if (mockUserToken) {\n storage._overrideAuthToken =\n typeof mockUserToken === 'string'\n ? mockUserToken\n : createMockUserToken(mockUserToken, storage.app.options.projectId);\n }\n}\n\n/**\n * A service that provides Firebase Storage Reference instances.\n * @param opt_url - gs:// url to a custom Storage Bucket\n *\n * @internal\n */\nexport class FirebaseStorageImpl implements FirebaseStorage {\n _bucket: Location | null = null;\n /**\n * This string can be in the formats:\n * - host\n * - host:port\n */\n private _host: string = DEFAULT_HOST;\n _protocol: string = 'https';\n protected readonly _appId: string | null = null;\n private readonly _requests: Set<Request<unknown>>;\n private _deleted: boolean = false;\n private _maxOperationRetryTime: number;\n private _maxUploadRetryTime: number;\n _overrideAuthToken?: string;\n\n constructor(\n /**\n * FirebaseApp associated with this StorageService instance.\n */\n readonly app: FirebaseApp,\n readonly _authProvider: Provider<FirebaseAuthInternalName>,\n /**\n * @internal\n */\n readonly _appCheckProvider: Provider<AppCheckInternalComponentName>,\n /**\n * @internal\n */\n readonly _url?: string,\n readonly _firebaseVersion?: string,\n public _isUsingEmulator = false\n ) {\n this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;\n this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;\n this._requests = new Set();\n if (_url != null) {\n this._bucket = Location.makeFromBucketSpec(_url, this._host);\n } else {\n this._bucket = extractBucket(this._host, this.app.options);\n }\n }\n\n /**\n * The host string for this service, in the form of `host` or\n * `host:port`.\n */\n get host(): string {\n return this._host;\n }\n\n set host(host: string) {\n this._host = host;\n if (this._url != null) {\n this._bucket = Location.makeFromBucketSpec(this._url, host);\n } else {\n this._bucket = extractBucket(host, this.app.options);\n }\n }\n\n /**\n * The maximum time to retry uploads in milliseconds.\n */\n get maxUploadRetryTime(): number {\n return this._maxUploadRetryTime;\n }\n\n set maxUploadRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxUploadRetryTime = time;\n }\n\n /**\n * The maximum time to retry operations other than uploads or downloads in\n * milliseconds.\n */\n get maxOperationRetryTime(): number {\n return this._maxOperationRetryTime;\n }\n\n set maxOperationRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxOperationRetryTime = time;\n }\n\n async _getAuthToken(): Promise<string | null> {\n if (this._overrideAuthToken) {\n return this._overrideAuthToken;\n }\n const auth = this._authProvider.getImmediate({ optional: true });\n if (auth) {\n const tokenData = await auth.getToken();\n if (tokenData !== null) {\n return tokenData.accessToken;\n }\n }\n return null;\n }\n\n async _getAppCheckToken(): Promise<string | null> {\n if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) {\n return this.app.settings.appCheckToken;\n }\n const appCheck = this._appCheckProvider.getImmediate({ optional: true });\n if (appCheck) {\n const result = await appCheck.getToken();\n // TODO: What do we want to do if there is an error getting the token?\n // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be\n // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use\n // the token (actual or dummy) to send requests.\n return result.token;\n }\n return null;\n }\n\n /**\n * Stop running requests and prevent more from being created.\n */\n _delete(): Promise<void> {\n if (!this._deleted) {\n this._deleted = true;\n this._requests.forEach(request => request.cancel());\n this._requests.clear();\n }\n return Promise.resolve();\n }\n\n /**\n * Returns a new firebaseStorage.Reference object referencing this StorageService\n * at the given Location.\n */\n _makeStorageReference(loc: Location): Reference {\n return new Reference(this, loc);\n }\n\n /**\n * @param requestInfo - HTTP RequestInfo object\n * @param authToken - Firebase auth token\n */\n _makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>,\n authToken: string | null,\n appCheckToken: string | null,\n retry = true\n ): Request<O> {\n if (!this._deleted) {\n const request = makeRequest(\n requestInfo,\n this._appId,\n authToken,\n appCheckToken,\n requestFactory,\n this._firebaseVersion,\n retry,\n this._isUsingEmulator\n );\n this._requests.add(request);\n // Request removes itself from set when complete.\n request.getPromise().then(\n () => this._requests.delete(request),\n () => this._requests.delete(request)\n );\n return request;\n } else {\n return new FailRequest(appDeleted());\n }\n }\n\n async makeRequestWithTokens<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>\n ): Promise<O> {\n const [authToken, appCheckToken] = await Promise.all([\n this._getAuthToken(),\n this._getAppCheckToken()\n ]);\n\n return this._makeRequest(\n requestInfo,\n requestFactory,\n authToken,\n appCheckToken\n ).getPromise();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Type constant for Firebase Storage.\n */\nexport const STORAGE_TYPE = 'storage';\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { _getProvider, FirebaseApp, getApp } from '@firebase/app';\n\nimport {\n ref as refInternal,\n FirebaseStorageImpl,\n connectStorageEmulator as connectEmulatorInternal\n} from './service';\nimport { Provider } from '@firebase/component';\n\nimport {\n StorageReference,\n FirebaseStorage,\n UploadResult,\n ListOptions,\n ListResult,\n UploadTask,\n SettableMetadata,\n UploadMetadata,\n FullMetadata\n} from './public-types';\nimport { Metadata as MetadataInternal } from './metadata';\nimport {\n uploadBytes as uploadBytesInternal,\n uploadBytesResumable as uploadBytesResumableInternal,\n uploadString as uploadStringInternal,\n getMetadata as getMetadataInternal,\n updateMetadata as updateMetadataInternal,\n list as listInternal,\n listAll as listAllInternal,\n getDownloadURL as getDownloadURLInternal,\n deleteObject as deleteObjectInternal,\n Reference,\n _getChild as _getChildInternal,\n getBytesInternal\n} from './reference';\nimport { STORAGE_TYPE } from './constants';\nimport {\n EmulatorMockTokenOptions,\n getModularInstance,\n getDefaultEmulatorHostnameAndPort\n} from '@firebase/util';\nimport { StringFormat } from './implementation/string';\n\nexport { EmulatorMockTokenOptions } from '@firebase/util';\n\nexport { StorageError, StorageErrorCode } from './implementation/error';\n\n/**\n * Public types.\n */\nexport * from './public-types';\n\nexport { Location as _Location } from './implementation/location';\nexport { UploadTask as _UploadTask } from './task';\nexport type { Reference as _Reference } from './reference';\nexport type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';\nexport { FbsBlob as _FbsBlob } from './implementation/blob';\nexport { dataFromString as _dataFromString } from './implementation/string';\nexport {\n invalidRootOperation as _invalidRootOperation,\n invalidArgument as _invalidArgument\n} from './implementation/error';\nexport {\n TaskEvent as _TaskEvent,\n TaskState as _TaskState\n} from './implementation/taskenums';\nexport { StringFormat };\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise containing the object's bytes\n */\nexport function getBytes(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref = getModularInstance(ref);\n return getBytesInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadBytesInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the string to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: StorageReference,\n value: string,\n format?: StringFormat,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadStringInternal(\n ref as Reference,\n value,\n format,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): UploadTask {\n ref = getModularInstance(ref);\n return uploadBytesResumableInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n ) as UploadTask;\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - {@link StorageReference} to get metadata from.\n */\nexport function getMetadata(ref: StorageReference): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return getMetadataInternal(ref as Reference) as Promise<FullMetadata>;\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - {@link StorageReference} to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves with the new metadata for this object.\n */\nexport function updateMetadata(\n ref: StorageReference,\n metadata: SettableMetadata\n): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return updateMetadataInternal(\n ref as Reference,\n metadata as Partial<MetadataInternal>\n ) as Promise<FullMetadata>;\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - {@link StorageReference} to get list from.\n * @param options - See {@link ListOptions} for details.\n * @returns A `Promise` that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: StorageReference,\n options?: ListOptions\n): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listInternal(ref as Reference, options);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: `listAll` may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - {@link StorageReference} to get list from.\n *\n * @returns A `Promise` that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: StorageReference): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listAllInternal(ref as Reference);\n}\n\n/**\n * Returns the download URL for the given {@link StorageReference}.\n * @public\n * @param ref - {@link StorageReference} to get the download URL for.\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: StorageReference): Promise<string> {\n ref = getModularInstance(ref);\n return getDownloadURLInternal(ref as Reference);\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - {@link StorageReference} for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: StorageReference): Promise<void> {\n ref = getModularInstance(ref);\n return deleteObjectInternal(ref as Reference);\n}\n\n/**\n * Returns a {@link StorageReference} for the given url.\n * @param storage - {@link FirebaseStorage} instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorage, url?: string): StorageReference;\n/**\n * Returns a {@link StorageReference} for the given path in the\n * default bucket.\n * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}\n * instance provided) or returns same reference (if {@link StorageReference} provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorage | StorageReference,\n path?: string\n): StorageReference;\nexport function ref(\n serviceOrRef: FirebaseStorage | StorageReference,\n pathOrUrl?: string\n): StorageReference | null {\n serviceOrRef = getModularInstance(serviceOrRef);\n return refInternal(\n serviceOrRef as FirebaseStorageImpl | Reference,\n pathOrUrl\n );\n}\n\n/**\n * @internal\n */\nexport function _getChild(ref: StorageReference, childPath: string): Reference {\n return _getChildInternal(ref as Reference, childPath);\n}\n\n/**\n * Gets a {@link FirebaseStorage} instance for the given Firebase app.\n * @public\n * @param app - Firebase app to get {@link FirebaseStorage} instance for.\n * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.\n * If not passed, uses the app's default Storage Bucket.\n * @returns A {@link FirebaseStorage} instance.\n */\nexport function getStorage(\n app: FirebaseApp = getApp(),\n bucketUrl?: string\n): FirebaseStorage {\n app = getModularInstance(app);\n const storageProvider: Provider<'storage'> = _getProvider(app, STORAGE_TYPE);\n const storageInstance = storageProvider.getImmediate({\n identifier: bucketUrl\n });\n const emulator = getDefaultEmulatorHostnameAndPort('storage');\n if (emulator) {\n connectStorageEmulator(storageInstance, ...emulator);\n }\n return storageInstance;\n}\n\n/**\n * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.\n *\n * @param storage - The {@link FirebaseStorage} instance\n * @param host - The emulator host (ex: localhost)\n * @param port - The emulator port (ex: 5001)\n * @param options - Emulator options. `options.mockUserToken` is the mock auth\n * token to use for unit testing Security Rules.\n * @public\n */\nexport function connectStorageEmulator(\n storage: FirebaseStorage,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n connectEmulatorInternal(storage as FirebaseStorageImpl, host, port, options);\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StorageReference } from './public-types';\nimport { Reference, getBlobInternal } from './reference';\nimport { getModularInstance } from '@firebase/util';\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * This API is not available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise that resolves with a Blob containing the object's bytes\n */\nexport function getBlob(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref = getModularInstance(ref);\n return getBlobInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Downloads the data at the object's location. Raises an error event if the\n * object is not found.\n *\n * This API is only available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A stream with the object's data as bytes\n */\nexport function getStream(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n throw new Error('getStream() is only supported by NodeJS builds');\n}\n","/**\n * Cloud Storage for Firebase\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n _registerComponent,\n registerVersion,\n SDK_VERSION\n} from '@firebase/app';\n\nimport { FirebaseStorageImpl } from '../src/service';\nimport {\n Component,\n ComponentType,\n ComponentContainer,\n InstanceFactoryOptions\n} from '@firebase/component';\n\nimport { name, version } from '../package.json';\n\nimport { FirebaseStorage } from './public-types';\nimport { STORAGE_TYPE } from './constants';\n\nexport * from './api';\nexport * from './api.browser';\n\nfunction factory(\n container: ComponentContainer,\n { instanceIdentifier: url }: InstanceFactoryOptions\n): FirebaseStorage {\n const app = container.getProvider('app').getImmediate();\n const authProvider = container.getProvider('auth-internal');\n const appCheckProvider = container.getProvider('app-check-internal');\n\n return new FirebaseStorageImpl(\n app,\n authProvider,\n appCheckProvider,\n url,\n SDK_VERSION\n );\n}\n\nfunction registerStorage(): void {\n _registerComponent(\n new Component(\n STORAGE_TYPE,\n factory,\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n //RUNTIME_ENV will be replaced during the compilation to \"node\" for nodejs and an empty string for browser\n registerVersion(name, version, '__RUNTIME_ENV__');\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\nregisterStorage();\n"],"names":["getBlob","getMetadata","list","getBytes","updateMetadata","deleteObject","fbsAsync","uploadBytes","uploadBytesResumable","uploadString","listAll","requestsList","requestsGetMetadata","requestsUpdateMetadata","getDownloadURL","requestsGetDownloadUrl","requestsDeleteObject","_getChild","ref","connectStorageEmulator","uploadBytesInternal","uploadStringInternal","uploadBytesResumableInternal","getMetadataInternal","updateMetadataInternal","listInternal","listAllInternal","getDownloadURLInternal","deleteObjectInternal","refInternal","_getChildInternal","connectEmulatorInternal"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;AAeG;AACH;;AAEG;AAEH;;AAEG;AACI,MAAM,YAAY,GAAG,gCA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,CACd,SAA6B,EAC7B,EAAE,kBAAkB,EAAE,GAAG,EAA0B,EAAA;IAEnD,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAErE,IAAA,OAAO,IAAI,mBAAmB,CAC5B,GAAG,EACH,YAAY,EACZ,gBAAgB,EAChB,GAAG,EACH,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,GAAA;AACtB,IAAA,kBAAkB,CAChB,IAAI,SAAS,CACX,YAAY,EACZ,OAAO,EAER,QAAA,4BAAA,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAC7B,CAAC;;AAEF,IAAA,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,EAAiB,CAAC,CAAC;;AAElD,IAAA,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAkB,CAAC,CAAC;AACrD,CAAC;AAED,eAAe,EAAE;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.node.cjs.js b/frontend-old/node_modules/@firebase/storage/dist/index.node.cjs.js deleted file mode 100644 index 26f308c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.node.cjs.js +++ /dev/null @@ -1,3710 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var app = require('@firebase/app'); -var util = require('@firebase/util'); -var component = require('@firebase/component'); - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -const DEFAULT_HOST = 'firebasestorage.googleapis.com'; -/** - * The key in Firebase config json for the storage bucket. - */ -const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket'; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000; -/** - * 10 minutes - * - * The timeout for upload. - */ -const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000; -/** - * 1 second - */ -const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -class StorageError extends util.FirebaseError { - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code, message, status_ = 0) { - super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`); - this.status_ = status_; - /** - * Stores custom error data unique to the `StorageError`. - */ - this.customData = { serverResponse: null }; - this._baseMessage = this.message; - // Without this, `instanceof StorageError`, in tests for example, - // returns false. - Object.setPrototypeOf(this, StorageError.prototype); - } - get status() { - return this.status_; - } - set status(status) { - this.status_ = status; - } - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code) { - return prependCode(code) === this.code; - } - /** - * Optional response message that was added by the server. - */ - get serverResponse() { - return this.customData.serverResponse; - } - set serverResponse(serverResponse) { - this.customData.serverResponse = serverResponse; - if (this.customData.serverResponse) { - this.message = `${this._baseMessage}\n${this.customData.serverResponse}`; - } - else { - this.message = this._baseMessage; - } - } -} -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -exports.StorageErrorCode = void 0; -(function (StorageErrorCode) { - // Shared between all platforms - StorageErrorCode["UNKNOWN"] = "unknown"; - StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found"; - StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found"; - StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found"; - StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded"; - StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated"; - StorageErrorCode["UNAUTHORIZED"] = "unauthorized"; - StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app"; - StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded"; - StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum"; - StorageErrorCode["CANCELED"] = "canceled"; - // JS specific - StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name"; - StorageErrorCode["INVALID_URL"] = "invalid-url"; - StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket"; - StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket"; - StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob"; - StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size"; - StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url"; - StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument"; - StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count"; - StorageErrorCode["APP_DELETED"] = "app-deleted"; - StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation"; - StorageErrorCode["INVALID_FORMAT"] = "invalid-format"; - StorageErrorCode["INTERNAL_ERROR"] = "internal-error"; - StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment"; -})(exports.StorageErrorCode || (exports.StorageErrorCode = {})); -function prependCode(code) { - return 'storage/' + code; -} -function unknown() { - const message = 'An unknown error occurred, please check the error payload for ' + - 'server response.'; - return new StorageError(exports.StorageErrorCode.UNKNOWN, message); -} -function objectNotFound(path) { - return new StorageError(exports.StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist."); -} -function quotaExceeded(bucket) { - return new StorageError(exports.StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + - bucket + - "' exceeded, please view quota on " + - 'https://firebase.google.com/pricing/.'); -} -function unauthenticated() { - const message = 'User is not authenticated, please authenticate using Firebase ' + - 'Authentication and try again.'; - return new StorageError(exports.StorageErrorCode.UNAUTHENTICATED, message); -} -function unauthorizedApp() { - return new StorageError(exports.StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.'); -} -function unauthorized(path) { - return new StorageError(exports.StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'."); -} -function retryLimitExceeded() { - return new StorageError(exports.StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.'); -} -function canceled() { - return new StorageError(exports.StorageErrorCode.CANCELED, 'User canceled the upload/download.'); -} -function invalidUrl(url) { - return new StorageError(exports.StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'."); -} -function invalidDefaultBucket(bucket) { - return new StorageError(exports.StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'."); -} -function noDefaultBucket() { - return new StorageError(exports.StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' + - "found. Did you set the '" + - CONFIG_STORAGE_BUCKET_KEY + - "' property when initializing the app?"); -} -function cannotSliceBlob() { - return new StorageError(exports.StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.'); -} -function serverFileWrongSize() { - return new StorageError(exports.StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.'); -} -function noDownloadURL() { - return new StorageError(exports.StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.'); -} -/** - * @internal - */ -function invalidArgument(message) { - return new StorageError(exports.StorageErrorCode.INVALID_ARGUMENT, message); -} -function appDeleted() { - return new StorageError(exports.StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.'); -} -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -function invalidRootOperation(name) { - return new StorageError(exports.StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + - name + - "' cannot be performed on a root reference, create a non-root " + - "reference using child, such as .child('file.png')."); -} -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -function invalidFormat(format, message) { - return new StorageError(exports.StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message); -} -/** - * @param message - A message describing the internal error. - */ -function internalError(message) { - throw new StorageError(exports.StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -class Location { - constructor(bucket, path) { - this.bucket = bucket; - this.path_ = path; - } - get path() { - return this.path_; - } - get isRoot() { - return this.path.length === 0; - } - fullServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o/' + encode(this.path); - } - bucketOnlyServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o'; - } - static makeFromBucketSpec(bucketString, host) { - let bucketLocation; - try { - bucketLocation = Location.makeFromUrl(bucketString, host); - } - catch (e) { - // Not valid URL, use as-is. This lets you put bare bucket names in - // config. - return new Location(bucketString, ''); - } - if (bucketLocation.path === '') { - return bucketLocation; - } - else { - throw invalidDefaultBucket(bucketString); - } - } - static makeFromUrl(url, host) { - let location = null; - const bucketDomain = '([A-Za-z0-9.\\-_]+)'; - function gsModify(loc) { - if (loc.path.charAt(loc.path.length - 1) === '/') { - loc.path_ = loc.path_.slice(0, -1); - } - } - const gsPath = '(/(.*))?$'; - const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i'); - const gsIndices = { bucket: 1, path: 3 }; - function httpModify(loc) { - loc.path_ = decodeURIComponent(loc.path); - } - const version = 'v[A-Za-z0-9_]+'; - const firebaseStorageHost = host.replace(/[.]/g, '\\.'); - const firebaseStoragePath = '(/([^?#]*).*)?$'; - const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`, 'i'); - const firebaseStorageIndices = { bucket: 1, path: 3 }; - const cloudStorageHost = host === DEFAULT_HOST - ? '(?:storage.googleapis.com|storage.cloud.google.com)' - : host; - const cloudStoragePath = '([^?#]*)'; - const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, 'i'); - const cloudStorageIndices = { bucket: 1, path: 2 }; - const groups = [ - { regex: gsRegex, indices: gsIndices, postModify: gsModify }, - { - regex: firebaseStorageRegExp, - indices: firebaseStorageIndices, - postModify: httpModify - }, - { - regex: cloudStorageRegExp, - indices: cloudStorageIndices, - postModify: httpModify - } - ]; - for (let i = 0; i < groups.length; i++) { - const group = groups[i]; - const captures = group.regex.exec(url); - if (captures) { - const bucketValue = captures[group.indices.bucket]; - let pathValue = captures[group.indices.path]; - if (!pathValue) { - pathValue = ''; - } - location = new Location(bucketValue, pathValue); - group.postModify(location); - break; - } - } - if (location == null) { - throw invalidUrl(url); - } - return location; - } -} - -/** - * A request whose promise always fails. - */ -class FailRequest { - constructor(error) { - this.promise_ = Promise.reject(error); - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(_appDelete = false) { } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -function start(doRequest, -// eslint-disable-next-line @typescript-eslint/no-explicit-any -backoffCompleteCb, timeout) { - // TODO(andysoto): make this code cleaner (probably refactor into an actual - // type instead of a bunch of functions with state shared in the closure) - let waitSeconds = 1; - // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯ - // TODO: find a way to exclude Node type definition for storage because storage only works in browser - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let retryTimeoutId = null; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let globalTimeoutId = null; - let hitTimeout = false; - let cancelState = 0; - function canceled() { - return cancelState === 2; - } - let triggeredCallback = false; - function triggerCallback(...args) { - if (!triggeredCallback) { - triggeredCallback = true; - backoffCompleteCb.apply(null, args); - } - } - function callWithDelay(millis) { - retryTimeoutId = setTimeout(() => { - retryTimeoutId = null; - doRequest(responseHandler, canceled()); - }, millis); - } - function clearGlobalTimeout() { - if (globalTimeoutId) { - clearTimeout(globalTimeoutId); - } - } - function responseHandler(success, ...args) { - if (triggeredCallback) { - clearGlobalTimeout(); - return; - } - if (success) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - const mustStop = canceled() || hitTimeout; - if (mustStop) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - if (waitSeconds < 64) { - /* TODO(andysoto): don't back off so quickly if we know we're offline. */ - waitSeconds *= 2; - } - let waitMillis; - if (cancelState === 1) { - cancelState = 2; - waitMillis = 0; - } - else { - waitMillis = (waitSeconds + Math.random()) * 1000; - } - callWithDelay(waitMillis); - } - let stopped = false; - function stop(wasTimeout) { - if (stopped) { - return; - } - stopped = true; - clearGlobalTimeout(); - if (triggeredCallback) { - return; - } - if (retryTimeoutId !== null) { - if (!wasTimeout) { - cancelState = 2; - } - clearTimeout(retryTimeoutId); - callWithDelay(0); - } - else { - if (!wasTimeout) { - cancelState = 1; - } - } - } - callWithDelay(0); - globalTimeoutId = setTimeout(() => { - hitTimeout = true; - stop(true); - }, timeout); - return stop; -} -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -function stop(id) { - id(false); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isJustDef(p) { - return p !== void 0; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function isFunction(p) { - return typeof p === 'function'; -} -function isNonArrayObject(p) { - return typeof p === 'object' && !Array.isArray(p); -} -function isString(p) { - return typeof p === 'string' || p instanceof String; -} -function isNativeBlob(p) { - return isNativeBlobDefined() && p instanceof Blob; -} -function isNativeBlobDefined() { - return typeof Blob !== 'undefined'; -} -function validateNumber(argument, minValue, maxValue, value) { - if (value < minValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`); - } - if (value > maxValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function makeUrl(urlPart, host, protocol) { - let origin = host; - if (protocol == null) { - origin = `https://${host}`; - } - return `${protocol}://${origin}/v0${urlPart}`; -} -function makeQueryString(params) { - const encode = encodeURIComponent; - let queryPart = '?'; - for (const key in params) { - if (params.hasOwnProperty(key)) { - const nextPart = encode(key) + '=' + encode(params[key]); - queryPart = queryPart + nextPart + '&'; - } - } - // Chop off the extra '&' or '?' on the end - queryPart = queryPart.slice(0, -1); - return queryPart; -} - -/** - * Error codes for requests made by the XhrIo wrapper. - */ -var ErrorCode; -(function (ErrorCode) { - ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR"; - ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR"; - ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT"; -})(ErrorCode || (ErrorCode = {})); - -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -function isRetryStatusCode(status, additionalRetryCodes) { - // The codes for which to retry came from this page: - // https://cloud.google.com/storage/docs/exponential-backoff - const isFiveHundredCode = status >= 500 && status < 600; - const extraRetryCodes = [ - // Request Timeout: web server didn't receive full request in time. - 408, - // Too Many Requests: you're getting rate-limited, basically. - 429 - ]; - const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1; - const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1; - return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Handles network logic for all Storage Requests, including error reporting and - * retries with backoff. - * - * @param I - the type of the backend's network response. - * @param - O the output type used by the rest of the SDK. The conversion - * happens in the specified `callback_`. - */ -class NetworkRequest { - constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) { - this.url_ = url_; - this.method_ = method_; - this.headers_ = headers_; - this.body_ = body_; - this.successCodes_ = successCodes_; - this.additionalRetryCodes_ = additionalRetryCodes_; - this.callback_ = callback_; - this.errorCallback_ = errorCallback_; - this.timeout_ = timeout_; - this.progressCallback_ = progressCallback_; - this.connectionFactory_ = connectionFactory_; - this.retry = retry; - this.isUsingEmulator = isUsingEmulator; - this.pendingConnection_ = null; - this.backoffId_ = null; - this.canceled_ = false; - this.appDelete_ = false; - this.promise_ = new Promise((resolve, reject) => { - this.resolve_ = resolve; - this.reject_ = reject; - this.start_(); - }); - } - /** - * Actually starts the retry loop. - */ - start_() { - const doTheRequest = (backoffCallback, canceled) => { - if (canceled) { - backoffCallback(false, new RequestEndStatus(false, null, true)); - return; - } - const connection = this.connectionFactory_(); - this.pendingConnection_ = connection; - const progressListener = progressEvent => { - const loaded = progressEvent.loaded; - const total = progressEvent.lengthComputable ? progressEvent.total : -1; - if (this.progressCallback_ !== null) { - this.progressCallback_(loaded, total); - } - }; - if (this.progressCallback_ !== null) { - connection.addUploadProgressListener(progressListener); - } - // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - connection - .send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_) - .then(() => { - if (this.progressCallback_ !== null) { - connection.removeUploadProgressListener(progressListener); - } - this.pendingConnection_ = null; - const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR; - const status = connection.getStatus(); - if (!hitServer || - (isRetryStatusCode(status, this.additionalRetryCodes_) && - this.retry)) { - const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT; - backoffCallback(false, new RequestEndStatus(false, null, wasCanceled)); - return; - } - const successCode = this.successCodes_.indexOf(status) !== -1; - backoffCallback(true, new RequestEndStatus(successCode, connection)); - }); - }; - /** - * @param requestWentThrough - True if the request eventually went - * through, false if it hit the retry limit or was canceled. - */ - const backoffDone = (requestWentThrough, status) => { - const resolve = this.resolve_; - const reject = this.reject_; - const connection = status.connection; - if (status.wasSuccessCode) { - try { - const result = this.callback_(connection, connection.getResponse()); - if (isJustDef(result)) { - resolve(result); - } - else { - resolve(); - } - } - catch (e) { - reject(e); - } - } - else { - if (connection !== null) { - const err = unknown(); - err.serverResponse = connection.getErrorText(); - if (this.errorCallback_) { - reject(this.errorCallback_(connection, err)); - } - else { - reject(err); - } - } - else { - if (status.canceled) { - const err = this.appDelete_ ? appDeleted() : canceled(); - reject(err); - } - else { - const err = retryLimitExceeded(); - reject(err); - } - } - } - }; - if (this.canceled_) { - backoffDone(false, new RequestEndStatus(false, null, true)); - } - else { - this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_); - } - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(appDelete) { - this.canceled_ = true; - this.appDelete_ = appDelete || false; - if (this.backoffId_ !== null) { - stop(this.backoffId_); - } - if (this.pendingConnection_ !== null) { - this.pendingConnection_.abort(); - } - } -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -class RequestEndStatus { - constructor(wasSuccessCode, connection, canceled) { - this.wasSuccessCode = wasSuccessCode; - this.connection = connection; - this.canceled = !!canceled; - } -} -function addAuthHeader_(headers, authToken) { - if (authToken !== null && authToken.length > 0) { - headers['Authorization'] = 'Firebase ' + authToken; - } -} -function addVersionHeader_(headers, firebaseVersion) { - headers['X-Firebase-Storage-Version'] = - 'webjs/' + (firebaseVersion ?? 'AppManager'); -} -function addGmpidHeader_(headers, appId) { - if (appId) { - headers['X-Firebase-GMPID'] = appId; - } -} -function addAppCheckHeader_(headers, appCheckToken) { - if (appCheckToken !== null) { - headers['X-Firebase-AppCheck'] = appCheckToken; - } -} -function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) { - const queryPart = makeQueryString(requestInfo.urlParams); - const url = requestInfo.url + queryPart; - const headers = Object.assign({}, requestInfo.headers); - addGmpidHeader_(headers, appId); - addAuthHeader_(headers, authToken); - addVersionHeader_(headers, firebaseVersion); - addAppCheckHeader_(headers, appCheckToken); - return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function getBlobBuilder() { - if (typeof BlobBuilder !== 'undefined') { - return BlobBuilder; - } - else if (typeof WebKitBlobBuilder !== 'undefined') { - return WebKitBlobBuilder; - } - else { - return undefined; - } -} -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -function getBlob$1(...args) { - const BlobBuilder = getBlobBuilder(); - if (BlobBuilder !== undefined) { - const bb = new BlobBuilder(); - for (let i = 0; i < args.length; i++) { - bb.append(args[i]); - } - return bb.getBlob(); - } - else { - if (isNativeBlobDefined()) { - return new Blob(args); - } - else { - throw new StorageError(exports.StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs"); - } - } -} -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -function sliceBlob(blob, start, end) { - if (blob.webkitSlice) { - return blob.webkitSlice(start, end); - } - else if (blob.mozSlice) { - return blob.mozSlice(start, end); - } - else if (blob.slice) { - return blob.slice(start, end); - } - return null; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -function decodeBase64(encoded) { - // Node actually doesn't validate base64 strings. - // A quick sanity check that is not a fool-proof validation - if (/[^-A-Za-z0-9+/=]/.test(encoded)) { - throw invalidFormat('base64', 'Invalid character found'); - } - return Buffer.from(encoded, 'base64').toString('binary'); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -const StringFormat = { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - RAW: 'raw', - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64: 'base64', - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64URL: 'base64url', - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - DATA_URL: 'data_url' -}; -class StringData { - constructor(data, contentType) { - this.data = data; - this.contentType = contentType || null; - } -} -/** - * @internal - */ -function dataFromString(format, stringData) { - switch (format) { - case StringFormat.RAW: - return new StringData(utf8Bytes_(stringData)); - case StringFormat.BASE64: - case StringFormat.BASE64URL: - return new StringData(base64Bytes_(format, stringData)); - case StringFormat.DATA_URL: - return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData)); - // do nothing - } - // assert(false); - throw unknown(); -} -function utf8Bytes_(value) { - const b = []; - for (let i = 0; i < value.length; i++) { - let c = value.charCodeAt(i); - if (c <= 127) { - b.push(c); - } - else { - if (c <= 2047) { - b.push(192 | (c >> 6), 128 | (c & 63)); - } - else { - if ((c & 64512) === 55296) { - // The start of a surrogate pair. - const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320; - if (!valid) { - // The second surrogate wasn't there. - b.push(239, 191, 189); - } - else { - const hi = c; - const lo = value.charCodeAt(++i); - c = 65536 | ((hi & 1023) << 10) | (lo & 1023); - b.push(240 | (c >> 18), 128 | ((c >> 12) & 63), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - else { - if ((c & 64512) === 56320) { - // Invalid low surrogate. - b.push(239, 191, 189); - } - else { - b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - } - } - } - return new Uint8Array(b); -} -function percentEncodedBytes_(value) { - let decoded; - try { - decoded = decodeURIComponent(value); - } - catch (e) { - throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.'); - } - return utf8Bytes_(decoded); -} -function base64Bytes_(format, value) { - switch (format) { - case StringFormat.BASE64: { - const hasMinus = value.indexOf('-') !== -1; - const hasUnder = value.indexOf('_') !== -1; - if (hasMinus || hasUnder) { - const invalidChar = hasMinus ? '-' : '_'; - throw invalidFormat(format, "Invalid character '" + - invalidChar + - "' found: is it base64url encoded?"); - } - break; - } - case StringFormat.BASE64URL: { - const hasPlus = value.indexOf('+') !== -1; - const hasSlash = value.indexOf('/') !== -1; - if (hasPlus || hasSlash) { - const invalidChar = hasPlus ? '+' : '/'; - throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?"); - } - value = value.replace(/-/g, '+').replace(/_/g, '/'); - break; - } - // do nothing - } - let bytes; - try { - bytes = decodeBase64(value); - } - catch (e) { - if (e.message.includes('polyfill')) { - throw e; - } - throw invalidFormat(format, 'Invalid character found'); - } - const array = new Uint8Array(bytes.length); - for (let i = 0; i < bytes.length; i++) { - array[i] = bytes.charCodeAt(i); - } - return array; -} -class DataURLParts { - constructor(dataURL) { - this.base64 = false; - this.contentType = null; - const matches = dataURL.match(/^data:([^,]+)?,/); - if (matches === null) { - throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>"); - } - const middle = matches[1] || null; - if (middle != null) { - this.base64 = endsWith(middle, ';base64'); - this.contentType = this.base64 - ? middle.substring(0, middle.length - ';base64'.length) - : middle; - } - this.rest = dataURL.substring(dataURL.indexOf(',') + 1); - } -} -function dataURLBytes_(dataUrl) { - const parts = new DataURLParts(dataUrl); - if (parts.base64) { - return base64Bytes_(StringFormat.BASE64, parts.rest); - } - else { - return percentEncodedBytes_(parts.rest); - } -} -function dataURLContentType_(dataUrl) { - const parts = new DataURLParts(dataUrl); - return parts.contentType; -} -function endsWith(s, end) { - const longEnough = s.length >= end.length; - if (!longEnough) { - return false; - } - return s.substring(s.length - end.length) === end; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -class FbsBlob { - constructor(data, elideCopy) { - let size = 0; - let blobType = ''; - if (isNativeBlob(data)) { - this.data_ = data; - size = data.size; - blobType = data.type; - } - else if (data instanceof ArrayBuffer) { - if (elideCopy) { - this.data_ = new Uint8Array(data); - } - else { - this.data_ = new Uint8Array(data.byteLength); - this.data_.set(new Uint8Array(data)); - } - size = this.data_.length; - } - else if (data instanceof Uint8Array) { - if (elideCopy) { - this.data_ = data; - } - else { - this.data_ = new Uint8Array(data.length); - this.data_.set(data); - } - size = data.length; - } - this.size_ = size; - this.type_ = blobType; - } - size() { - return this.size_; - } - type() { - return this.type_; - } - slice(startByte, endByte) { - if (isNativeBlob(this.data_)) { - const realBlob = this.data_; - const sliced = sliceBlob(realBlob, startByte, endByte); - if (sliced === null) { - return null; - } - return new FbsBlob(sliced); - } - else { - const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte); - return new FbsBlob(slice, true); - } - } - static getBlob(...args) { - if (isNativeBlobDefined()) { - const blobby = args.map((val) => { - if (val instanceof FbsBlob) { - return val.data_; - } - else { - return val; - } - }); - return new FbsBlob(getBlob$1.apply(null, blobby)); - } - else { - const uint8Arrays = args.map((val) => { - if (isString(val)) { - return dataFromString(StringFormat.RAW, val).data; - } - else { - // Blobs don't exist, so this has to be a Uint8Array. - return val.data_; - } - }); - let finalLength = 0; - uint8Arrays.forEach((array) => { - finalLength += array.byteLength; - }); - const merged = new Uint8Array(finalLength); - let index = 0; - uint8Arrays.forEach((array) => { - for (let i = 0; i < array.length; i++) { - merged[index++] = array[i]; - } - }); - return new FbsBlob(merged, true); - } - } - uploadData() { - return this.data_; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -function jsonObjectOrNull(s) { - let obj; - try { - obj = JSON.parse(s); - } - catch (e) { - return null; - } - if (isNonArrayObject(obj)) { - return obj; - } - else { - return null; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -function parent(path) { - if (path.length === 0) { - return null; - } - const index = path.lastIndexOf('/'); - if (index === -1) { - return ''; - } - const newPath = path.slice(0, index); - return newPath; -} -function child(path, childPath) { - const canonicalChildPath = childPath - .split('/') - .filter(component => component.length > 0) - .join('/'); - if (path.length === 0) { - return canonicalChildPath; - } - else { - return path + '/' + canonicalChildPath; - } -} -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -function lastComponent(path) { - const index = path.lastIndexOf('/', path.length - 2); - if (index === -1) { - return path; - } - else { - return path.slice(index + 1); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function noXform_(metadata, value) { - return value; -} -class Mapping { - constructor(server, local, writable, xform) { - this.server = server; - this.local = local || server; - this.writable = !!writable; - this.xform = xform || noXform_; - } -} -let mappings_ = null; -function xformPath(fullPath) { - if (!isString(fullPath) || fullPath.length < 2) { - return fullPath; - } - else { - return lastComponent(fullPath); - } -} -function getMappings() { - if (mappings_) { - return mappings_; - } - const mappings = []; - mappings.push(new Mapping('bucket')); - mappings.push(new Mapping('generation')); - mappings.push(new Mapping('metageneration')); - mappings.push(new Mapping('name', 'fullPath', true)); - function mappingsXformPath(_metadata, fullPath) { - return xformPath(fullPath); - } - const nameMapping = new Mapping('name'); - nameMapping.xform = mappingsXformPath; - mappings.push(nameMapping); - /** - * Coerces the second param to a number, if it is defined. - */ - function xformSize(_metadata, size) { - if (size !== undefined) { - return Number(size); - } - else { - return size; - } - } - const sizeMapping = new Mapping('size'); - sizeMapping.xform = xformSize; - mappings.push(sizeMapping); - mappings.push(new Mapping('timeCreated')); - mappings.push(new Mapping('updated')); - mappings.push(new Mapping('md5Hash', null, true)); - mappings.push(new Mapping('cacheControl', null, true)); - mappings.push(new Mapping('contentDisposition', null, true)); - mappings.push(new Mapping('contentEncoding', null, true)); - mappings.push(new Mapping('contentLanguage', null, true)); - mappings.push(new Mapping('contentType', null, true)); - mappings.push(new Mapping('metadata', 'customMetadata', true)); - mappings_ = mappings; - return mappings_; -} -function addRef(metadata, service) { - function generateRef() { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const loc = new Location(bucket, path); - return service._makeStorageReference(loc); - } - Object.defineProperty(metadata, 'ref', { get: generateRef }); -} -function fromResource(service, resource, mappings) { - const metadata = {}; - metadata['type'] = 'file'; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]); - } - addRef(metadata, service); - return metadata; -} -function fromResourceString(service, resourceString, mappings) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromResource(service, resource, mappings); -} -function downloadUrlFromResourceString(metadata, resourceString, host, protocol) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - if (!isString(obj['downloadTokens'])) { - // This can happen if objects are uploaded through GCS and retrieved - // through list, so we don't want to throw an Error. - return null; - } - const tokens = obj['downloadTokens']; - if (tokens.length === 0) { - return null; - } - const encode = encodeURIComponent; - const tokensList = tokens.split(','); - const urls = tokensList.map((token) => { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path); - const base = makeUrl(urlPart, host, protocol); - const queryString = makeQueryString({ - alt: 'media', - token - }); - return base + queryString; - }); - return urls[0]; -} -function toResourceString(metadata, mappings) { - const resource = {}; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - if (mapping.writable) { - resource[mapping.server] = metadata[mapping.local]; - } - } - return JSON.stringify(resource); -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const PREFIXES_KEY = 'prefixes'; -const ITEMS_KEY = 'items'; -function fromBackendResponse(service, bucket, resource) { - const listResult = { - prefixes: [], - items: [], - nextPageToken: resource['nextPageToken'] - }; - if (resource[PREFIXES_KEY]) { - for (const path of resource[PREFIXES_KEY]) { - const pathWithoutTrailingSlash = path.replace(/\/$/, ''); - const reference = service._makeStorageReference(new Location(bucket, pathWithoutTrailingSlash)); - listResult.prefixes.push(reference); - } - } - if (resource[ITEMS_KEY]) { - for (const item of resource[ITEMS_KEY]) { - const reference = service._makeStorageReference(new Location(bucket, item['name'])); - listResult.items.push(reference); - } - } - return listResult; -} -function fromResponseString(service, bucket, resourceString) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromBackendResponse(service, bucket, resource); -} - -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -class RequestInfo { - constructor(url, method, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler, timeout) { - this.url = url; - this.method = method; - this.handler = handler; - this.timeout = timeout; - this.urlParams = {}; - this.headers = {}; - this.body = null; - this.errorHandler = null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - this.progressCallback = null; - this.successCodes = [200]; - this.additionalRetryCodes = []; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -function handlerCheck(cndn) { - if (!cndn) { - throw unknown(); - } -} -function metadataHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return metadata; - } - return handler; -} -function listHandler(service, bucket) { - function handler(xhr, text) { - const listResult = fromResponseString(service, bucket, text); - handlerCheck(listResult !== null); - return listResult; - } - return handler; -} -function downloadUrlHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return downloadUrlFromResourceString(metadata, text, service.host, service._protocol); - } - return handler; -} -function sharedErrorHandler(location) { - function errorHandler(xhr, err) { - let newErr; - if (xhr.getStatus() === 401) { - if ( - // This exact message string is the only consistent part of the - // server's error response that identifies it as an App Check error. - xhr.getErrorText().includes('Firebase App Check token is invalid')) { - newErr = unauthorizedApp(); - } - else { - newErr = unauthenticated(); - } - } - else { - if (xhr.getStatus() === 402) { - newErr = quotaExceeded(location.bucket); - } - else { - if (xhr.getStatus() === 403) { - newErr = unauthorized(location.path); - } - else { - newErr = err; - } - } - } - newErr.status = xhr.getStatus(); - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function objectErrorHandler(location) { - const shared = sharedErrorHandler(location); - function errorHandler(xhr, err) { - let newErr = shared(xhr, err); - if (xhr.getStatus() === 404) { - newErr = objectNotFound(location.path); - } - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function getMetadata$2(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function list$2(service, location, delimiter, pageToken, maxResults) { - const urlParams = {}; - if (location.isRoot) { - urlParams['prefix'] = ''; - } - else { - urlParams['prefix'] = location.path + '/'; - } - if (delimiter && delimiter.length > 0) { - urlParams['delimiter'] = delimiter; - } - if (pageToken) { - urlParams['pageToken'] = pageToken; - } - if (maxResults) { - urlParams['maxResults'] = maxResults; - } - const urlPart = location.bucketOnlyServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, listHandler(service, location.bucket), timeout); - requestInfo.urlParams = urlParams; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -function getBytes$1(service, location, maxDownloadSizeBytes) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media'; - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout); - requestInfo.errorHandler = objectErrorHandler(location); - if (maxDownloadSizeBytes !== undefined) { - requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`; - requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */]; - } - return requestInfo; -} -function getDownloadUrl(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function updateMetadata$2(service, location, metadata, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'PATCH'; - const body = toResourceString(metadata, mappings); - const headers = { 'Content-Type': 'application/json; charset=utf-8' }; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function deleteObject$2(service, location) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'DELETE'; - const timeout = service.maxOperationRetryTime; - function handler(_xhr, _text) { } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.successCodes = [200, 204]; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function determineContentType_(metadata, blob) { - return ((metadata && metadata['contentType']) || - (blob && blob.type()) || - 'application/octet-stream'); -} -function metadataForUpload_(location, blob, metadata) { - const metadataClone = Object.assign({}, metadata); - metadataClone['fullPath'] = location.path; - metadataClone['size'] = blob.size(); - if (!metadataClone['contentType']) { - metadataClone['contentType'] = determineContentType_(null, blob); - } - return metadataClone; -} -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -function multipartUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const headers = { - 'X-Goog-Upload-Protocol': 'multipart' - }; - function genBoundary() { - let str = ''; - for (let i = 0; i < 2; i++) { - str = str + Math.random().toString().slice(2); - } - return str; - } - const boundary = genBoundary(); - headers['Content-Type'] = 'multipart/related; boundary=' + boundary; - const metadata_ = metadataForUpload_(location, blob, metadata); - const metadataString = toResourceString(metadata_, mappings); - const preBlobPart = '--' + - boundary + - '\r\n' + - 'Content-Type: application/json; charset=utf-8\r\n\r\n' + - metadataString + - '\r\n--' + - boundary + - '\r\n' + - 'Content-Type: ' + - metadata_['contentType'] + - '\r\n\r\n'; - const postBlobPart = '\r\n--' + boundary + '--'; - const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart); - if (body === null) { - throw cannotSliceBlob(); - } - const urlParams = { name: metadata_['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -class ResumableUploadStatus { - constructor(current, total, finalized, metadata) { - this.current = current; - this.total = total; - this.finalized = !!finalized; - this.metadata = metadata || null; - } -} -function checkResumeHeader_(xhr, allowed) { - let status = null; - try { - status = xhr.getResponseHeader('X-Goog-Upload-Status'); - } - catch (e) { - handlerCheck(false); - } - const allowedStatus = allowed || ['active']; - handlerCheck(!!status && allowedStatus.indexOf(status) !== -1); - return status; -} -function createResumableUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const metadataForUpload = metadataForUpload_(location, blob, metadata); - const urlParams = { name: metadataForUpload['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const headers = { - 'X-Goog-Upload-Protocol': 'resumable', - 'X-Goog-Upload-Command': 'start', - 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`, - 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType'], - 'Content-Type': 'application/json; charset=utf-8' - }; - const body = toResourceString(metadataForUpload, mappings); - const timeout = service.maxUploadRetryTime; - function handler(xhr) { - checkResumeHeader_(xhr); - let url; - try { - url = xhr.getResponseHeader('X-Goog-Upload-URL'); - } - catch (e) { - handlerCheck(false); - } - handlerCheck(isString(url)); - return url; - } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -function getResumableUploadStatus(service, location, url, blob) { - const headers = { 'X-Goog-Upload-Command': 'query' }; - function handler(xhr) { - const status = checkResumeHeader_(xhr, ['active', 'final']); - let sizeString = null; - try { - sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received'); - } - catch (e) { - handlerCheck(false); - } - if (!sizeString) { - // null or empty string - handlerCheck(false); - } - const size = Number(sizeString); - handlerCheck(!isNaN(size)); - return new ResumableUploadStatus(size, blob.size(), status === 'final'); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -const RESUMABLE_UPLOAD_CHUNK_SIZE = 256 * 1024; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -function continueResumableUpload(location, service, url, blob, chunkSize, mappings, status, progressCallback) { - // TODO(andysoto): standardize on internal asserts - // assert(!(opt_status && opt_status.finalized)); - const status_ = new ResumableUploadStatus(0, 0); - if (status) { - status_.current = status.current; - status_.total = status.total; - } - else { - status_.current = 0; - status_.total = blob.size(); - } - if (blob.size() !== status_.total) { - throw serverFileWrongSize(); - } - const bytesLeft = status_.total - status_.current; - let bytesToUpload = bytesLeft; - if (chunkSize > 0) { - bytesToUpload = Math.min(bytesToUpload, chunkSize); - } - const startByte = status_.current; - const endByte = startByte + bytesToUpload; - let uploadCommand = ''; - if (bytesToUpload === 0) { - uploadCommand = 'finalize'; - } - else if (bytesLeft === bytesToUpload) { - uploadCommand = 'upload, finalize'; - } - else { - uploadCommand = 'upload'; - } - const headers = { - 'X-Goog-Upload-Command': uploadCommand, - 'X-Goog-Upload-Offset': `${status_.current}` - }; - const body = blob.slice(startByte, endByte); - if (body === null) { - throw cannotSliceBlob(); - } - function handler(xhr, text) { - // TODO(andysoto): Verify the MD5 of each uploaded range: - // the 'x-range-md5' header comes back with status code 308 responses. - // We'll only be able to bail out though, because you can't re-upload a - // range that you previously uploaded. - const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']); - const newCurrent = status_.current + bytesToUpload; - const size = blob.size(); - let metadata; - if (uploadStatus === 'final') { - metadata = metadataHandler(service, mappings)(xhr, text); - } - else { - metadata = null; - } - return new ResumableUploadStatus(newCurrent, size, uploadStatus === 'final', metadata); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.progressCallback = progressCallback || null; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An event that is triggered on a task. - * @internal - */ -const TaskEvent = { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: 'state_changed' -}; -// type keys = keyof TaskState -/** - * Represents the current state of a running upload. - * @internal - */ -const TaskState = { - /** The task is currently transferring data. */ - RUNNING: 'running', - /** The task was paused by the user. */ - PAUSED: 'paused', - /** The task completed successfully. */ - SUCCESS: 'success', - /** The task was canceled. */ - CANCELED: 'canceled', - /** The task failed with an error. */ - ERROR: 'error' -}; -function taskStateFromInternalTaskState(state) { - switch (state) { - case "running" /* InternalTaskState.RUNNING */: - case "pausing" /* InternalTaskState.PAUSING */: - case "canceling" /* InternalTaskState.CANCELING */: - return TaskState.RUNNING; - case "paused" /* InternalTaskState.PAUSED */: - return TaskState.PAUSED; - case "success" /* InternalTaskState.SUCCESS */: - return TaskState.SUCCESS; - case "canceled" /* InternalTaskState.CANCELED */: - return TaskState.CANCELED; - case "error" /* InternalTaskState.ERROR */: - return TaskState.ERROR; - default: - // TODO(andysoto): assert(false); - return TaskState.ERROR; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -class Observer { - constructor(nextOrObserver, error, complete) { - const asFunctions = isFunction(nextOrObserver) || error != null || complete != null; - if (asFunctions) { - this.next = nextOrObserver; - this.error = error ?? undefined; - this.complete = complete ?? undefined; - } - else { - const observer = nextOrObserver; - this.next = observer.next; - this.error = observer.error; - this.complete = observer.complete; - } - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -// eslint-disable-next-line @typescript-eslint/ban-types -function async(f) { - return (...argsToForward) => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.resolve().then(() => f(...argsToForward)); - }; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** An override for the text-based Connection. Used in tests. */ -let textFactoryOverride = null; -/** - * Network layer that works in Node. - * - * This network implementation should not be used in browsers as it does not - * support progress updates. - */ -class FetchConnection { - constructor() { - this.errorText_ = ''; - this.sent_ = false; - this.errorCode_ = ErrorCode.NO_ERROR; - } - async send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - this.sent_ = true; - try { - const response = await newFetch(url, method, isUsingEmulator, headers, body); - this.headers_ = response.headers; - this.statusCode_ = response.status; - this.errorCode_ = ErrorCode.NO_ERROR; - this.body_ = await response.arrayBuffer(); - } - catch (e) { - this.errorText_ = e?.message; - // emulate XHR which sets status to 0 when encountering a network error - this.statusCode_ = 0; - this.errorCode_ = ErrorCode.NETWORK_ERROR; - } - } - getErrorCode() { - if (this.errorCode_ === undefined) { - throw internalError('cannot .getErrorCode() before receiving response'); - } - return this.errorCode_; - } - getStatus() { - if (this.statusCode_ === undefined) { - throw internalError('cannot .getStatus() before receiving response'); - } - return this.statusCode_; - } - getErrorText() { - return this.errorText_; - } - abort() { - // Not supported - } - getResponseHeader(header) { - if (!this.headers_) { - throw internalError('cannot .getResponseHeader() before receiving response'); - } - return this.headers_.get(header); - } - addUploadProgressListener(listener) { - // Not supported - } - removeUploadProgressListener(listener) { - // Not supported - } -} -class FetchTextConnection extends FetchConnection { - getResponse() { - if (!this.body_) { - throw internalError('cannot .getResponse() before receiving response'); - } - return Buffer.from(this.body_).toString('utf-8'); - } -} -function newTextConnection() { - return textFactoryOverride - ? textFactoryOverride() - : new FetchTextConnection(); -} -class FetchBytesConnection extends FetchConnection { - getResponse() { - if (!this.body_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.body_; - } -} -function newBytesConnection() { - return new FetchBytesConnection(); -} -class FetchStreamConnection extends FetchConnection { - constructor() { - super(...arguments); - this.stream_ = null; - } - async send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - this.sent_ = true; - try { - const response = await newFetch(url, method, isUsingEmulator, headers, body); - this.headers_ = response.headers; - this.statusCode_ = response.status; - this.errorCode_ = ErrorCode.NO_ERROR; - this.stream_ = response.body; - } - catch (e) { - this.errorText_ = e?.message; - // emulate XHR which sets status to 0 when encountering a network error - this.statusCode_ = 0; - this.errorCode_ = ErrorCode.NETWORK_ERROR; - } - } - getResponse() { - if (!this.stream_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.stream_; - } -} -function newFetch(url, method, isUsingEmulator, headers, body) { - const fetchArgs = { - method, - headers: headers || {}, - body: body - }; - if (util.isCloudWorkstation(url) && isUsingEmulator) { - fetchArgs.credentials = 'include'; - } - return fetch(url, fetchArgs); -} -function newStreamConnection() { - return new FetchStreamConnection(); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -class UploadTask { - isExponentialBackoffExpired() { - return this.sleepTime > this.maxSleepTime; - } - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref, blob, metadata = null) { - /** - * Number of bytes transferred so far. - */ - this._transferred = 0; - this._needToFetchStatus = false; - this._needToFetchMetadata = false; - this._observers = []; - this._error = undefined; - this._uploadUrl = undefined; - this._request = undefined; - this._chunkMultiplier = 1; - this._resolve = undefined; - this._reject = undefined; - this._ref = ref; - this._blob = blob; - this._metadata = metadata; - this._mappings = getMappings(); - this._resumable = this._shouldDoResumable(this._blob); - this._state = "running" /* InternalTaskState.RUNNING */; - this._errorHandler = error => { - this._request = undefined; - this._chunkMultiplier = 1; - if (error._codeEquals(exports.StorageErrorCode.CANCELED)) { - this._needToFetchStatus = true; - this.completeTransitions_(); - } - else { - const backoffExpired = this.isExponentialBackoffExpired(); - if (isRetryStatusCode(error.status, [])) { - if (backoffExpired) { - error = retryLimitExceeded(); - } - else { - this.sleepTime = Math.max(this.sleepTime * 2, DEFAULT_MIN_SLEEP_TIME_MILLIS); - this._needToFetchStatus = true; - this.completeTransitions_(); - return; - } - } - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this._metadataErrorHandler = error => { - this._request = undefined; - if (error._codeEquals(exports.StorageErrorCode.CANCELED)) { - this.completeTransitions_(); - } - else { - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this.sleepTime = 0; - this.maxSleepTime = this._ref.storage.maxUploadRetryTime; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - this._start(); - }); - // Prevent uncaught rejections on the internal promise from bubbling out - // to the top level with a dummy handler. - this._promise.then(null, () => { }); - } - _makeProgressCallback() { - const sizeBefore = this._transferred; - return loaded => this._updateProgress(sizeBefore + loaded); - } - _shouldDoResumable(blob) { - return blob.size() > 256 * 1024; - } - _start() { - if (this._state !== "running" /* InternalTaskState.RUNNING */) { - // This can happen if someone pauses us in a resume callback, for example. - return; - } - if (this._request !== undefined) { - return; - } - if (this._resumable) { - if (this._uploadUrl === undefined) { - this._createResumable(); - } - else { - if (this._needToFetchStatus) { - this._fetchStatus(); - } - else { - if (this._needToFetchMetadata) { - // Happens if we miss the metadata on upload completion. - this._fetchMetadata(); - } - else { - this.pendingTimeout = setTimeout(() => { - this.pendingTimeout = undefined; - this._continueUpload(); - }, this.sleepTime); - } - } - } - } - else { - this._oneShotUpload(); - } - } - _resolveToken(callback) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.all([ - this._ref.storage._getAuthToken(), - this._ref.storage._getAppCheckToken() - ]).then(([authToken, appCheckToken]) => { - switch (this._state) { - case "running" /* InternalTaskState.RUNNING */: - callback(authToken, appCheckToken); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - } - }); - } - // TODO(andysoto): assert false - _createResumable() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = createRequest; - createRequest.getPromise().then((url) => { - this._request = undefined; - this._uploadUrl = url; - this._needToFetchStatus = false; - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _fetchStatus() { - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob); - const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = statusRequest; - statusRequest.getPromise().then(status => { - status = status; - this._request = undefined; - this._updateProgress(status.current); - this._needToFetchStatus = false; - if (status.finalized) { - this._needToFetchMetadata = true; - } - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _continueUpload() { - const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - const status = new ResumableUploadStatus(this._transferred, this._blob.size()); - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - let requestInfo; - try { - requestInfo = continueResumableUpload(this._ref._location, this._ref.storage, url, this._blob, chunkSize, this._mappings, status, this._makeProgressCallback()); - } - catch (e) { - this._error = e; - this._transition("error" /* InternalTaskState.ERROR */); - return; - } - const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken, - /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file. - ); - this._request = uploadRequest; - uploadRequest.getPromise().then((newStatus) => { - this._increaseMultiplier(); - this._request = undefined; - this._updateProgress(newStatus.current); - if (newStatus.finalized) { - this._metadata = newStatus.metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - } - else { - this.completeTransitions_(); - } - }, this._errorHandler); - }); - } - _increaseMultiplier() { - const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - // Max chunk size is 32M. - if (currentSize * 2 < 32 * 1024 * 1024) { - this._chunkMultiplier *= 2; - } - } - _fetchMetadata() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings); - const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = metadataRequest; - metadataRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._metadataErrorHandler); - }); - } - _oneShotUpload() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = multipartRequest; - multipartRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._updateProgress(this._blob.size()); - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._errorHandler); - }); - } - _updateProgress(transferred) { - const old = this._transferred; - this._transferred = transferred; - // A progress update can make the "transferred" value smaller (e.g. a - // partial upload not completed by server, after which the "transferred" - // value may reset to the value at the beginning of the request). - if (this._transferred !== old) { - this._notifyObservers(); - } - } - _transition(state) { - if (this._state === state) { - return; - } - switch (state) { - case "canceling" /* InternalTaskState.CANCELING */: - case "pausing" /* InternalTaskState.PAUSING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING); - this._state = state; - if (this._request !== undefined) { - this._request.cancel(); - } - else if (this.pendingTimeout) { - clearTimeout(this.pendingTimeout); - this.pendingTimeout = undefined; - this.completeTransitions_(); - } - break; - case "running" /* InternalTaskState.RUNNING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.PAUSING); - const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */; - this._state = state; - if (wasPaused) { - this._notifyObservers(); - this._start(); - } - break; - case "paused" /* InternalTaskState.PAUSED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSING); - this._state = state; - this._notifyObservers(); - break; - case "canceled" /* InternalTaskState.CANCELED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.CANCELING); - this._error = canceled(); - this._state = state; - this._notifyObservers(); - break; - case "error" /* InternalTaskState.ERROR */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - case "success" /* InternalTaskState.SUCCESS */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - } - } - completeTransitions_() { - switch (this._state) { - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "running" /* InternalTaskState.RUNNING */: - this._start(); - break; - } - } - /** - * A snapshot of the current task state. - */ - get snapshot() { - const externalState = taskStateFromInternalTaskState(this._state); - return { - bytesTransferred: this._transferred, - totalBytes: this._blob.size(), - state: externalState, - metadata: this._metadata, - task: this, - ref: this._ref - }; - } - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type, nextOrObserver, error, completed) { - // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string. - const observer = new Observer(nextOrObserver || undefined, error || undefined, completed || undefined); - this._addObserver(observer); - return () => { - this._removeObserver(observer); - }; - } - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled, onRejected) { - // These casts are needed so that TypeScript can infer the types of the - // resulting Promise. - return this._promise.then(onFulfilled, onRejected); - } - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected) { - return this.then(null, onRejected); - } - /** - * Adds the given observer. - */ - _addObserver(observer) { - this._observers.push(observer); - this._notifyObserver(observer); - } - /** - * Removes the given observer. - */ - _removeObserver(observer) { - const i = this._observers.indexOf(observer); - if (i !== -1) { - this._observers.splice(i, 1); - } - } - _notifyObservers() { - this._finishPromise(); - const observers = this._observers.slice(); - observers.forEach(observer => { - this._notifyObserver(observer); - }); - } - _finishPromise() { - if (this._resolve !== undefined) { - let triggered = true; - switch (taskStateFromInternalTaskState(this._state)) { - case TaskState.SUCCESS: - async(this._resolve.bind(null, this.snapshot))(); - break; - case TaskState.CANCELED: - case TaskState.ERROR: - const toCall = this._reject; - async(toCall.bind(null, this._error))(); - break; - default: - triggered = false; - break; - } - if (triggered) { - this._resolve = undefined; - this._reject = undefined; - } - } - } - _notifyObserver(observer) { - const externalState = taskStateFromInternalTaskState(this._state); - switch (externalState) { - case TaskState.RUNNING: - case TaskState.PAUSED: - if (observer.next) { - async(observer.next.bind(observer, this.snapshot))(); - } - break; - case TaskState.SUCCESS: - if (observer.complete) { - async(observer.complete.bind(observer))(); - } - break; - case TaskState.CANCELED: - case TaskState.ERROR: - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - break; - default: - // TODO(andysoto): assert(false); - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - } - } - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume() { - const valid = this._state === "paused" /* InternalTaskState.PAUSED */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("running" /* InternalTaskState.RUNNING */); - } - return valid; - } - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */; - if (valid) { - this._transition("pausing" /* InternalTaskState.PAUSING */); - } - return valid; - } - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("canceling" /* InternalTaskState.CANCELING */); - } - return valid; - } -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -class Reference { - constructor(_service, location) { - this._service = _service; - if (location instanceof Location) { - this._location = location; - } - else { - this._location = Location.makeFromUrl(location, _service.host); - } - } - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString() { - return 'gs://' + this._location.bucket + '/' + this._location.path; - } - _newRef(service, location) { - return new Reference(service, location); - } - /** - * A reference to the root of this object's bucket. - */ - get root() { - const location = new Location(this._location.bucket, ''); - return this._newRef(this._service, location); - } - /** - * The name of the bucket containing this reference's object. - */ - get bucket() { - return this._location.bucket; - } - /** - * The full path of this object. - */ - get fullPath() { - return this._location.path; - } - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name() { - return lastComponent(this._location.path); - } - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage() { - return this._service; - } - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent() { - const newPath = parent(this._location.path); - if (newPath === null) { - return null; - } - const location = new Location(this._location.bucket, newPath); - return new Reference(this._service, location); - } - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name) { - if (this._location.path === '') { - throw invalidRootOperation(name); - } - } -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -function getBytesInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBytes'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBytesConnection) - .then(bytes => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - bytes.slice(0, maxDownloadSizeBytes) - : bytes); -} -/** Stream the bytes at the object's location. */ -function getStreamInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getStream'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result - const newMaxSizeTransform = (n) => { - let missingBytes = n; - return { - transform(chunk, controller) { - // GCS may not honor the Range header for small files - if (chunk.length < missingBytes) { - controller.enqueue(chunk); - missingBytes -= chunk.length; - } - else { - controller.enqueue(chunk.slice(0, missingBytes)); - controller.terminate(); - } - } - }; - }; - const result = maxDownloadSizeBytes !== undefined - ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes)) - : new TransformStream(); // The default transformer forwards all chunks to its readable side - ref.storage - .makeRequestWithTokens(requestInfo, newStreamConnection) - .then(readableStream => readableStream.pipeThrough(result)) - .catch(err => result.writable.abort(err)); - return result.readable; -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -function uploadBytes$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytes'); - const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(finalMetadata => { - return { - metadata: finalMetadata, - ref - }; - }); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -function uploadBytesResumable$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytesResumable'); - return new UploadTask(ref, new FbsBlob(data), metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -function uploadString$1(ref, value, format = StringFormat.RAW, metadata) { - ref._throwIfRoot('uploadString'); - const data = dataFromString(format, value); - const metadataClone = { ...metadata }; - if (metadataClone['contentType'] == null && data.contentType != null) { - metadataClone['contentType'] = data.contentType; - } - return uploadBytes$1(ref, data.data, metadataClone); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll$1(ref) { - const accumulator = { - prefixes: [], - items: [] - }; - return listAllHelper(ref, accumulator).then(() => accumulator); -} -/** - * Separated from listAll because async functions can't use "arguments". - * @param ref - * @param accumulator - * @param pageToken - */ -async function listAllHelper(ref, accumulator, pageToken) { - const opt = { - // maxResults is 1000 by default. - pageToken - }; - const nextPage = await list$1(ref, opt); - accumulator.prefixes.push(...nextPage.prefixes); - accumulator.items.push(...nextPage.items); - if (nextPage.nextPageToken != null) { - await listAllHelper(ref, accumulator, nextPage.nextPageToken); - } -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list$1(ref, options) { - if (options != null) { - if (typeof options.maxResults === 'number') { - validateNumber('options.maxResults', - /* minValue= */ 1, - /* maxValue= */ 1000, options.maxResults); - } - } - const op = options || {}; - const requestInfo = list$2(ref.storage, ref._location, - /*delimiter= */ '/', op.pageToken, op.maxResults); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -function getMetadata$1(ref) { - ref._throwIfRoot('getMetadata'); - const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -function updateMetadata$1(ref, metadata) { - ref._throwIfRoot('updateMetadata'); - const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL$1(ref) { - ref._throwIfRoot('getDownloadURL'); - const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings()); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(url => { - if (url === null) { - throw noDownloadURL(); - } - return url; - }); -} -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject$1(ref) { - ref._throwIfRoot('deleteObject'); - const requestInfo = deleteObject$2(ref.storage, ref._location); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -function _getChild$1(ref, childPath) { - const newPath = child(ref._location.path, childPath); - const location = new Location(ref._location.bucket, newPath); - return new Reference(ref.storage, location); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isUrl(path) { - return /^[A-Za-z]+:\/\//.test(path); -} -/** - * Returns a firebaseStorage.Reference for the given url. - */ -function refFromURL(service, url) { - return new Reference(service, url); -} -/** - * Returns a firebaseStorage.Reference for the given path in the default - * bucket. - */ -function refFromPath(ref, path) { - if (ref instanceof FirebaseStorageImpl) { - const service = ref; - if (service._bucket == null) { - throw noDefaultBucket(); - } - const reference = new Reference(service, service._bucket); - if (path != null) { - return refFromPath(reference, path); - } - else { - return reference; - } - } - else { - // ref is a Reference - if (path !== undefined) { - return _getChild$1(ref, path); - } - else { - return ref; - } - } -} -function ref$1(serviceOrRef, pathOrUrl) { - if (pathOrUrl && isUrl(pathOrUrl)) { - if (serviceOrRef instanceof FirebaseStorageImpl) { - return refFromURL(serviceOrRef, pathOrUrl); - } - else { - throw invalidArgument('To use ref(service, url), the first argument must be a Storage instance.'); - } - } - else { - return refFromPath(serviceOrRef, pathOrUrl); - } -} -function extractBucket(host, config) { - const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY]; - if (bucketString == null) { - return null; - } - return Location.makeFromBucketSpec(bucketString, host); -} -function connectStorageEmulator$1(storage, host, port, options = {}) { - storage.host = `${host}:${port}`; - const useSsl = util.isCloudWorkstation(host); - // Workaround to get cookies in Firebase Studio - if (useSsl) { - void util.pingServer(`https://${storage.host}/b`); - util.updateEmulatorBanner('Storage', true); - } - storage._isUsingEmulator = true; - storage._protocol = useSsl ? 'https' : 'http'; - const { mockUserToken } = options; - if (mockUserToken) { - storage._overrideAuthToken = - typeof mockUserToken === 'string' - ? mockUserToken - : util.createMockUserToken(mockUserToken, storage.app.options.projectId); - } -} -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -class FirebaseStorageImpl { - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app, _authProvider, - /** - * @internal - */ - _appCheckProvider, - /** - * @internal - */ - _url, _firebaseVersion, _isUsingEmulator = false) { - this.app = app; - this._authProvider = _authProvider; - this._appCheckProvider = _appCheckProvider; - this._url = _url; - this._firebaseVersion = _firebaseVersion; - this._isUsingEmulator = _isUsingEmulator; - this._bucket = null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - this._host = DEFAULT_HOST; - this._protocol = 'https'; - this._appId = null; - this._deleted = false; - this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME; - this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME; - this._requests = new Set(); - if (_url != null) { - this._bucket = Location.makeFromBucketSpec(_url, this._host); - } - else { - this._bucket = extractBucket(this._host, this.app.options); - } - } - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host() { - return this._host; - } - set host(host) { - this._host = host; - if (this._url != null) { - this._bucket = Location.makeFromBucketSpec(this._url, host); - } - else { - this._bucket = extractBucket(host, this.app.options); - } - } - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime() { - return this._maxUploadRetryTime; - } - set maxUploadRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxUploadRetryTime = time; - } - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime() { - return this._maxOperationRetryTime; - } - set maxOperationRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxOperationRetryTime = time; - } - async _getAuthToken() { - if (this._overrideAuthToken) { - return this._overrideAuthToken; - } - const auth = this._authProvider.getImmediate({ optional: true }); - if (auth) { - const tokenData = await auth.getToken(); - if (tokenData !== null) { - return tokenData.accessToken; - } - } - return null; - } - async _getAppCheckToken() { - if (app._isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) { - return this.app.settings.appCheckToken; - } - const appCheck = this._appCheckProvider.getImmediate({ optional: true }); - if (appCheck) { - const result = await appCheck.getToken(); - // TODO: What do we want to do if there is an error getting the token? - // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be - // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use - // the token (actual or dummy) to send requests. - return result.token; - } - return null; - } - /** - * Stop running requests and prevent more from being created. - */ - _delete() { - if (!this._deleted) { - this._deleted = true; - this._requests.forEach(request => request.cancel()); - this._requests.clear(); - } - return Promise.resolve(); - } - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc) { - return new Reference(this, loc); - } - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) { - if (!this._deleted) { - const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator); - this._requests.add(request); - // Request removes itself from set when complete. - request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request)); - return request; - } - else { - return new FailRequest(appDeleted()); - } - } - async makeRequestWithTokens(requestInfo, requestFactory) { - const [authToken, appCheckToken] = await Promise.all([ - this._getAuthToken(), - this._getAppCheckToken() - ]); - return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise(); - } -} - -const name = "@firebase/storage"; -const version = "0.14.0"; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -const STORAGE_TYPE = 'storage'; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -function getBytes(ref, maxDownloadSizeBytes) { - ref = util.getModularInstance(ref); - return getBytesInternal(ref, maxDownloadSizeBytes); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -function uploadBytes(ref, data, metadata) { - ref = util.getModularInstance(ref); - return uploadBytes$1(ref, data, metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -function uploadString(ref, value, format, metadata) { - ref = util.getModularInstance(ref); - return uploadString$1(ref, value, format, metadata); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -function uploadBytesResumable(ref, data, metadata) { - ref = util.getModularInstance(ref); - return uploadBytesResumable$1(ref, data, metadata); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -function getMetadata(ref) { - ref = util.getModularInstance(ref); - return getMetadata$1(ref); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -function updateMetadata(ref, metadata) { - ref = util.getModularInstance(ref); - return updateMetadata$1(ref, metadata); -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list(ref, options) { - ref = util.getModularInstance(ref); - return list$1(ref, options); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll(ref) { - ref = util.getModularInstance(ref); - return listAll$1(ref); -} -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL(ref) { - ref = util.getModularInstance(ref); - return getDownloadURL$1(ref); -} -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject(ref) { - ref = util.getModularInstance(ref); - return deleteObject$1(ref); -} -function ref(serviceOrRef, pathOrUrl) { - serviceOrRef = util.getModularInstance(serviceOrRef); - return ref$1(serviceOrRef, pathOrUrl); -} -/** - * @internal - */ -function _getChild(ref, childPath) { - return _getChild$1(ref, childPath); -} -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -function getStorage(app$1 = app.getApp(), bucketUrl) { - app$1 = util.getModularInstance(app$1); - const storageProvider = app._getProvider(app$1, STORAGE_TYPE); - const storageInstance = storageProvider.getImmediate({ - identifier: bucketUrl - }); - const emulator = util.getDefaultEmulatorHostnameAndPort('storage'); - if (emulator) { - connectStorageEmulator(storageInstance, ...emulator); - } - return storageInstance; -} -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -function connectStorageEmulator(storage, host, port, options = {}) { - connectStorageEmulator$1(storage, host, port, options); -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getBlob(ref, maxDownloadSizeBytes) { - throw new Error('getBlob() is only available in Browser-like environments'); -} -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -function getStream(ref, maxDownloadSizeBytes) { - ref = util.getModularInstance(ref); - return getStreamInternal(ref, maxDownloadSizeBytes); -} - -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -function factory(container, { instanceIdentifier: url }) { - const app$1 = container.getProvider('app').getImmediate(); - const authProvider = container.getProvider('auth-internal'); - const appCheckProvider = container.getProvider('app-check-internal'); - return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider, url, app.SDK_VERSION); -} -function registerStorage() { - app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); - app.registerVersion(name, version); -} -registerStorage(); - -exports.StorageError = StorageError; -exports.StringFormat = StringFormat; -exports._FbsBlob = FbsBlob; -exports._Location = Location; -exports._TaskEvent = TaskEvent; -exports._TaskState = TaskState; -exports._UploadTask = UploadTask; -exports._dataFromString = dataFromString; -exports._getChild = _getChild; -exports._invalidArgument = invalidArgument; -exports._invalidRootOperation = invalidRootOperation; -exports.connectStorageEmulator = connectStorageEmulator; -exports.deleteObject = deleteObject; -exports.getBlob = getBlob; -exports.getBytes = getBytes; -exports.getDownloadURL = getDownloadURL; -exports.getMetadata = getMetadata; -exports.getStorage = getStorage; -exports.getStream = getStream; -exports.list = list; -exports.listAll = listAll; -exports.ref = ref; -exports.updateMetadata = updateMetadata; -exports.uploadBytes = uploadBytes; -exports.uploadBytesResumable = uploadBytesResumable; -exports.uploadString = uploadString; -//# sourceMappingURL=index.node.cjs.js.map diff --git a/frontend-old/node_modules/@firebase/storage/dist/index.node.cjs.js.map b/frontend-old/node_modules/@firebase/storage/dist/index.node.cjs.js.map deleted file mode 100644 index 1411b46..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/index.node.cjs.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.node.cjs.js","sources":["../src/implementation/constants.ts","../src/implementation/error.ts","../src/implementation/location.ts","../src/implementation/failrequest.ts","../src/implementation/backoff.ts","../src/implementation/type.ts","../src/implementation/url.ts","../src/implementation/connection.ts","../src/implementation/utils.ts","../src/implementation/request.ts","../src/implementation/fs.ts","../src/platform/node/base64.ts","../src/implementation/string.ts","../src/implementation/blob.ts","../src/implementation/json.ts","../src/implementation/path.ts","../src/implementation/metadata.ts","../src/implementation/list.ts","../src/implementation/requestinfo.ts","../src/implementation/requests.ts","../src/implementation/taskenums.ts","../src/implementation/observer.ts","../src/implementation/async.ts","../src/platform/node/connection.ts","../src/task.ts","../src/reference.ts","../src/service.ts","../src/constants.ts","../src/api.ts","../src/api.node.ts","../src/index.node.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Constants used in the Firebase Storage library.\n */\n\n/**\n * Domain name for firebase storage.\n */\nexport const DEFAULT_HOST = 'firebasestorage.googleapis.com';\n\n/**\n * The key in Firebase config json for the storage bucket.\n */\nexport const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket';\n\n/**\n * 2 minutes\n *\n * The timeout for all operations except upload.\n */\nexport const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000;\n\n/**\n * 10 minutes\n *\n * The timeout for upload.\n */\nexport const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000;\n\n/**\n * 1 second\n */\nexport const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;\n\n/**\n * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported\n * enough for us to use it directly.\n */\nexport const MIN_SAFE_INTEGER = -9007199254740991;\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseError } from '@firebase/util';\n\nimport { CONFIG_STORAGE_BUCKET_KEY } from './constants';\n\n/**\n * An error returned by the Firebase Storage SDK.\n * @public\n */\nexport class StorageError extends FirebaseError {\n private readonly _baseMessage: string;\n /**\n * Stores custom error data unique to the `StorageError`.\n */\n customData: { serverResponse: string | null } = { serverResponse: null };\n\n /**\n * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and\n * added to the end of the message.\n * @param message - Error message.\n * @param status_ - Corresponding HTTP Status Code\n */\n constructor(code: StorageErrorCode, message: string, private status_ = 0) {\n super(\n prependCode(code),\n `Firebase Storage: ${message} (${prependCode(code)})`\n );\n this._baseMessage = this.message;\n // Without this, `instanceof StorageError`, in tests for example,\n // returns false.\n Object.setPrototypeOf(this, StorageError.prototype);\n }\n\n get status(): number {\n return this.status_;\n }\n\n set status(status: number) {\n this.status_ = status;\n }\n\n /**\n * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.\n */\n _codeEquals(code: StorageErrorCode): boolean {\n return prependCode(code) === this.code;\n }\n\n /**\n * Optional response message that was added by the server.\n */\n get serverResponse(): null | string {\n return this.customData.serverResponse;\n }\n\n set serverResponse(serverResponse: string | null) {\n this.customData.serverResponse = serverResponse;\n if (this.customData.serverResponse) {\n this.message = `${this._baseMessage}\\n${this.customData.serverResponse}`;\n } else {\n this.message = this._baseMessage;\n }\n }\n}\n\nexport const errors = {};\n\n/**\n * @public\n * Error codes that can be attached to `StorageError` objects.\n */\nexport enum StorageErrorCode {\n // Shared between all platforms\n UNKNOWN = 'unknown',\n OBJECT_NOT_FOUND = 'object-not-found',\n BUCKET_NOT_FOUND = 'bucket-not-found',\n PROJECT_NOT_FOUND = 'project-not-found',\n QUOTA_EXCEEDED = 'quota-exceeded',\n UNAUTHENTICATED = 'unauthenticated',\n UNAUTHORIZED = 'unauthorized',\n UNAUTHORIZED_APP = 'unauthorized-app',\n RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',\n INVALID_CHECKSUM = 'invalid-checksum',\n CANCELED = 'canceled',\n // JS specific\n INVALID_EVENT_NAME = 'invalid-event-name',\n INVALID_URL = 'invalid-url',\n INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',\n NO_DEFAULT_BUCKET = 'no-default-bucket',\n CANNOT_SLICE_BLOB = 'cannot-slice-blob',\n SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',\n NO_DOWNLOAD_URL = 'no-download-url',\n INVALID_ARGUMENT = 'invalid-argument',\n INVALID_ARGUMENT_COUNT = 'invalid-argument-count',\n APP_DELETED = 'app-deleted',\n INVALID_ROOT_OPERATION = 'invalid-root-operation',\n INVALID_FORMAT = 'invalid-format',\n INTERNAL_ERROR = 'internal-error',\n UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'\n}\n\nexport function prependCode(code: StorageErrorCode): string {\n return 'storage/' + code;\n}\n\nexport function unknown(): StorageError {\n const message =\n 'An unknown error occurred, please check the error payload for ' +\n 'server response.';\n return new StorageError(StorageErrorCode.UNKNOWN, message);\n}\n\nexport function objectNotFound(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.OBJECT_NOT_FOUND,\n \"Object '\" + path + \"' does not exist.\"\n );\n}\n\nexport function bucketNotFound(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.BUCKET_NOT_FOUND,\n \"Bucket '\" + bucket + \"' does not exist.\"\n );\n}\n\nexport function projectNotFound(project: string): StorageError {\n return new StorageError(\n StorageErrorCode.PROJECT_NOT_FOUND,\n \"Project '\" + project + \"' does not exist.\"\n );\n}\n\nexport function quotaExceeded(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.QUOTA_EXCEEDED,\n \"Quota for bucket '\" +\n bucket +\n \"' exceeded, please view quota on \" +\n 'https://firebase.google.com/pricing/.'\n );\n}\n\nexport function unauthenticated(): StorageError {\n const message =\n 'User is not authenticated, please authenticate using Firebase ' +\n 'Authentication and try again.';\n return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);\n}\n\nexport function unauthorizedApp(): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED_APP,\n 'This app does not have permission to access Firebase Storage on this project.'\n );\n}\n\nexport function unauthorized(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED,\n \"User does not have permission to access '\" + path + \"'.\"\n );\n}\n\nexport function retryLimitExceeded(): StorageError {\n return new StorageError(\n StorageErrorCode.RETRY_LIMIT_EXCEEDED,\n 'Max retry time for operation exceeded, please try again.'\n );\n}\n\nexport function invalidChecksum(\n path: string,\n checksum: string,\n calculated: string\n): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_CHECKSUM,\n \"Uploaded/downloaded object '\" +\n path +\n \"' has checksum '\" +\n checksum +\n \"' which does not match '\" +\n calculated +\n \"'. Please retry the upload/download.\"\n );\n}\n\nexport function canceled(): StorageError {\n return new StorageError(\n StorageErrorCode.CANCELED,\n 'User canceled the upload/download.'\n );\n}\n\nexport function invalidEventName(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_EVENT_NAME,\n \"Invalid event name '\" + name + \"'.\"\n );\n}\n\nexport function invalidUrl(url: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_URL,\n \"Invalid URL '\" + url + \"'.\"\n );\n}\n\nexport function invalidDefaultBucket(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_DEFAULT_BUCKET,\n \"Invalid default bucket '\" + bucket + \"'.\"\n );\n}\n\nexport function noDefaultBucket(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DEFAULT_BUCKET,\n 'No default bucket ' +\n \"found. Did you set the '\" +\n CONFIG_STORAGE_BUCKET_KEY +\n \"' property when initializing the app?\"\n );\n}\n\nexport function cannotSliceBlob(): StorageError {\n return new StorageError(\n StorageErrorCode.CANNOT_SLICE_BLOB,\n 'Cannot slice blob for upload. Please retry the upload.'\n );\n}\n\nexport function serverFileWrongSize(): StorageError {\n return new StorageError(\n StorageErrorCode.SERVER_FILE_WRONG_SIZE,\n 'Server recorded incorrect upload file size, please retry the upload.'\n );\n}\n\nexport function noDownloadURL(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DOWNLOAD_URL,\n 'The given file does not have any download URLs.'\n );\n}\n\nexport function missingPolyFill(polyFill: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`\n );\n}\n\n/**\n * @internal\n */\nexport function invalidArgument(message: string): StorageError {\n return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);\n}\n\nexport function invalidArgumentCount(\n argMin: number,\n argMax: number,\n fnName: string,\n real: number\n): StorageError {\n let countPart;\n let plural;\n if (argMin === argMax) {\n countPart = argMin;\n plural = argMin === 1 ? 'argument' : 'arguments';\n } else {\n countPart = 'between ' + argMin + ' and ' + argMax;\n plural = 'arguments';\n }\n return new StorageError(\n StorageErrorCode.INVALID_ARGUMENT_COUNT,\n 'Invalid argument count in `' +\n fnName +\n '`: Expected ' +\n countPart +\n ' ' +\n plural +\n ', received ' +\n real +\n '.'\n );\n}\n\nexport function appDeleted(): StorageError {\n return new StorageError(\n StorageErrorCode.APP_DELETED,\n 'The Firebase app was deleted.'\n );\n}\n\n/**\n * @param name - The name of the operation that was invalid.\n *\n * @internal\n */\nexport function invalidRootOperation(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_ROOT_OPERATION,\n \"The operation '\" +\n name +\n \"' cannot be performed on a root reference, create a non-root \" +\n \"reference using child, such as .child('file.png').\"\n );\n}\n\n/**\n * @param format - The format that was not valid.\n * @param message - A message describing the format violation.\n */\nexport function invalidFormat(format: string, message: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_FORMAT,\n \"String does not match format '\" + format + \"': \" + message\n );\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function unsupportedEnvironment(message: string): StorageError {\n throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, message);\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function internalError(message: string): StorageError {\n throw new StorageError(\n StorageErrorCode.INTERNAL_ERROR,\n 'Internal error: ' + message\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functionality related to the parsing/composition of bucket/\n * object location.\n */\n\nimport { invalidDefaultBucket, invalidUrl } from './error';\nimport { DEFAULT_HOST } from './constants';\n\n/**\n * Firebase Storage location data.\n *\n * @internal\n */\nexport class Location {\n private path_: string;\n\n constructor(public readonly bucket: string, path: string) {\n this.path_ = path;\n }\n\n get path(): string {\n return this.path_;\n }\n\n get isRoot(): boolean {\n return this.path.length === 0;\n }\n\n fullServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o/' + encode(this.path);\n }\n\n bucketOnlyServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o';\n }\n\n static makeFromBucketSpec(bucketString: string, host: string): Location {\n let bucketLocation;\n try {\n bucketLocation = Location.makeFromUrl(bucketString, host);\n } catch (e) {\n // Not valid URL, use as-is. This lets you put bare bucket names in\n // config.\n return new Location(bucketString, '');\n }\n if (bucketLocation.path === '') {\n return bucketLocation;\n } else {\n throw invalidDefaultBucket(bucketString);\n }\n }\n\n static makeFromUrl(url: string, host: string): Location {\n let location: Location | null = null;\n const bucketDomain = '([A-Za-z0-9.\\\\-_]+)';\n\n function gsModify(loc: Location): void {\n if (loc.path.charAt(loc.path.length - 1) === '/') {\n loc.path_ = loc.path_.slice(0, -1);\n }\n }\n const gsPath = '(/(.*))?$';\n const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i');\n const gsIndices = { bucket: 1, path: 3 };\n\n function httpModify(loc: Location): void {\n loc.path_ = decodeURIComponent(loc.path);\n }\n const version = 'v[A-Za-z0-9_]+';\n const firebaseStorageHost = host.replace(/[.]/g, '\\\\.');\n const firebaseStoragePath = '(/([^?#]*).*)?$';\n const firebaseStorageRegExp = new RegExp(\n `^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`,\n 'i'\n );\n const firebaseStorageIndices = { bucket: 1, path: 3 };\n\n const cloudStorageHost =\n host === DEFAULT_HOST\n ? '(?:storage.googleapis.com|storage.cloud.google.com)'\n : host;\n const cloudStoragePath = '([^?#]*)';\n const cloudStorageRegExp = new RegExp(\n `^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`,\n 'i'\n );\n const cloudStorageIndices = { bucket: 1, path: 2 };\n\n const groups = [\n { regex: gsRegex, indices: gsIndices, postModify: gsModify },\n {\n regex: firebaseStorageRegExp,\n indices: firebaseStorageIndices,\n postModify: httpModify\n },\n {\n regex: cloudStorageRegExp,\n indices: cloudStorageIndices,\n postModify: httpModify\n }\n ];\n for (let i = 0; i < groups.length; i++) {\n const group = groups[i];\n const captures = group.regex.exec(url);\n if (captures) {\n const bucketValue = captures[group.indices.bucket];\n let pathValue = captures[group.indices.path];\n if (!pathValue) {\n pathValue = '';\n }\n location = new Location(bucketValue, pathValue);\n group.postModify(location);\n break;\n }\n }\n if (location == null) {\n throw invalidUrl(url);\n }\n return location;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Request } from './request';\n\n/**\n * A request whose promise always fails.\n */\nexport class FailRequest<T> implements Request<T> {\n promise_: Promise<T>;\n\n constructor(error: StorageError) {\n this.promise_ = Promise.reject<T>(error);\n }\n\n /** @inheritDoc */\n getPromise(): Promise<T> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(_appDelete = false): void {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Provides a method for running a function with exponential\n * backoff.\n */\ntype id = (p1: boolean) => void;\n\nexport { id };\n\n/**\n * Accepts a callback for an action to perform (`doRequest`),\n * and then a callback for when the backoff has completed (`backoffCompleteCb`).\n * The callback sent to start requires an argument to call (`onRequestComplete`).\n * When `start` calls `doRequest`, it passes a callback for when the request has\n * completed, `onRequestComplete`. Based on this, the backoff continues, with\n * another call to `doRequest` and the above loop continues until the timeout\n * is hit, or a successful response occurs.\n * @description\n * @param doRequest Callback to perform request\n * @param backoffCompleteCb Callback to call when backoff has been completed\n */\nexport function start(\n doRequest: (\n onRequestComplete: (success: boolean) => void,\n canceled: boolean\n ) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n backoffCompleteCb: (...args: any[]) => unknown,\n timeout: number\n): id {\n // TODO(andysoto): make this code cleaner (probably refactor into an actual\n // type instead of a bunch of functions with state shared in the closure)\n let waitSeconds = 1;\n // Would type this as \"number\" but that doesn't work for Node so ¯\\_(ツ)_/¯\n // TODO: find a way to exclude Node type definition for storage because storage only works in browser\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let retryTimeoutId: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let globalTimeoutId: any = null;\n let hitTimeout = false;\n let cancelState = 0;\n\n function canceled(): boolean {\n return cancelState === 2;\n }\n let triggeredCallback = false;\n\n function triggerCallback(...args: any[]): void {\n if (!triggeredCallback) {\n triggeredCallback = true;\n backoffCompleteCb.apply(null, args);\n }\n }\n\n function callWithDelay(millis: number): void {\n retryTimeoutId = setTimeout(() => {\n retryTimeoutId = null;\n doRequest(responseHandler, canceled());\n }, millis);\n }\n\n function clearGlobalTimeout(): void {\n if (globalTimeoutId) {\n clearTimeout(globalTimeoutId);\n }\n }\n\n function responseHandler(success: boolean, ...args: any[]): void {\n if (triggeredCallback) {\n clearGlobalTimeout();\n return;\n }\n if (success) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n const mustStop = canceled() || hitTimeout;\n if (mustStop) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n if (waitSeconds < 64) {\n /* TODO(andysoto): don't back off so quickly if we know we're offline. */\n waitSeconds *= 2;\n }\n let waitMillis;\n if (cancelState === 1) {\n cancelState = 2;\n waitMillis = 0;\n } else {\n waitMillis = (waitSeconds + Math.random()) * 1000;\n }\n callWithDelay(waitMillis);\n }\n let stopped = false;\n\n function stop(wasTimeout: boolean): void {\n if (stopped) {\n return;\n }\n stopped = true;\n clearGlobalTimeout();\n if (triggeredCallback) {\n return;\n }\n if (retryTimeoutId !== null) {\n if (!wasTimeout) {\n cancelState = 2;\n }\n clearTimeout(retryTimeoutId);\n callWithDelay(0);\n } else {\n if (!wasTimeout) {\n cancelState = 1;\n }\n }\n }\n callWithDelay(0);\n globalTimeoutId = setTimeout(() => {\n hitTimeout = true;\n stop(true);\n }, timeout);\n return stop;\n}\n\n/**\n * Stops the retry loop from repeating.\n * If the function is currently \"in between\" retries, it is invoked immediately\n * with the second parameter as \"true\". Otherwise, it will be invoked once more\n * after the current invocation finishes iff the current invocation would have\n * triggered another retry.\n */\nexport function stop(id: id): void {\n id(false);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { invalidArgument } from './error';\n\nexport function isJustDef<T>(p: T | null | undefined): p is T | null {\n return p !== void 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isFunction(p: unknown): p is Function {\n return typeof p === 'function';\n}\n\nexport function isNonArrayObject(p: unknown): boolean {\n return typeof p === 'object' && !Array.isArray(p);\n}\n\nexport function isString(p: unknown): p is string {\n return typeof p === 'string' || p instanceof String;\n}\n\nexport function isNativeBlob(p: unknown): p is Blob {\n return isNativeBlobDefined() && p instanceof Blob;\n}\n\nexport function isNativeBlobDefined(): boolean {\n return typeof Blob !== 'undefined';\n}\n\nexport function validateNumber(\n argument: string,\n minValue: number,\n maxValue: number,\n value: number\n): void {\n if (value < minValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${minValue} or greater.`\n );\n }\n if (value > maxValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${maxValue} or less.`\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functions to create and manipulate URLs for the server API.\n */\nimport { UrlParams } from './requestinfo';\n\nexport function makeUrl(\n urlPart: string,\n host: string,\n protocol: string\n): string {\n let origin = host;\n if (protocol == null) {\n origin = `https://${host}`;\n }\n return `${protocol}://${origin}/v0${urlPart}`;\n}\n\nexport function makeQueryString(params: UrlParams): string {\n const encode = encodeURIComponent;\n let queryPart = '?';\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const nextPart = encode(key) + '=' + encode(params[key]);\n queryPart = queryPart + nextPart + '&';\n }\n }\n\n // Chop off the extra '&' or '?' on the end\n queryPart = queryPart.slice(0, -1);\n return queryPart;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Network headers */\nexport type Headers = Record<string, string>;\n\n/** Response type exposed by the networking APIs. */\nexport type ConnectionType =\n | string\n | ArrayBuffer\n | Blob\n | ReadableStream<Uint8Array>;\n\n/**\n * A lightweight wrapper around XMLHttpRequest with a\n * goog.net.XhrIo-like interface.\n *\n * You can create a new connection by invoking `newTextConnection()`,\n * `newBytesConnection()` or `newStreamConnection()`.\n */\nexport interface Connection<T extends ConnectionType> {\n /**\n * Sends a request to the provided URL.\n *\n * This method never rejects its promise. In case of encountering an error,\n * it sets an error code internally which can be accessed by calling\n * getErrorCode() by callers.\n */\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string | null,\n headers?: Headers\n ): Promise<void>;\n\n getErrorCode(): ErrorCode;\n\n getStatus(): number;\n\n getResponse(): T;\n\n getErrorText(): string;\n\n /**\n * Abort the request.\n */\n abort(): void;\n\n getResponseHeader(header: string): string | null;\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n}\n\n/**\n * Error codes for requests made by the XhrIo wrapper.\n */\nexport enum ErrorCode {\n NO_ERROR = 0,\n NETWORK_ERROR = 1,\n ABORT = 2\n}\n","/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Checks the status code to see if the action should be retried.\n *\n * @param status Current HTTP status code returned by server.\n * @param additionalRetryCodes additional retry codes to check against\n */\nexport function isRetryStatusCode(\n status: number,\n additionalRetryCodes: number[]\n): boolean {\n // The codes for which to retry came from this page:\n // https://cloud.google.com/storage/docs/exponential-backoff\n const isFiveHundredCode = status >= 500 && status < 600;\n const extraRetryCodes = [\n // Request Timeout: web server didn't receive full request in time.\n 408,\n // Too Many Requests: you're getting rate-limited, basically.\n 429\n ];\n const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;\n const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;\n return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods used to actually send HTTP requests from\n * abstract representations.\n */\n\nimport { id as backoffId, start, stop } from './backoff';\nimport { appDeleted, canceled, retryLimitExceeded, unknown } from './error';\nimport { ErrorHandler, RequestHandler, RequestInfo } from './requestinfo';\nimport { isJustDef } from './type';\nimport { makeQueryString } from './url';\nimport { Connection, ErrorCode, Headers, ConnectionType } from './connection';\nimport { isRetryStatusCode } from './utils';\n\nexport interface Request<T> {\n getPromise(): Promise<T>;\n\n /**\n * Cancels the request. IMPORTANT: the promise may still be resolved with an\n * appropriate value (if the request is finished before you call this method,\n * but the promise has not yet been resolved), so don't just assume it will be\n * rejected if you call this function.\n * @param appDelete - True if the cancelation came from the app being deleted.\n */\n cancel(appDelete?: boolean): void;\n}\n\n/**\n * Handles network logic for all Storage Requests, including error reporting and\n * retries with backoff.\n *\n * @param I - the type of the backend's network response.\n * @param - O the output type used by the rest of the SDK. The conversion\n * happens in the specified `callback_`.\n */\nclass NetworkRequest<I extends ConnectionType, O> implements Request<O> {\n private pendingConnection_: Connection<I> | null = null;\n private backoffId_: backoffId | null = null;\n private resolve_!: (value?: O | PromiseLike<O>) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private reject_!: (reason?: any) => void;\n private canceled_: boolean = false;\n private appDelete_: boolean = false;\n private promise_: Promise<O>;\n\n constructor(\n private url_: string,\n private method_: string,\n private headers_: Headers,\n private body_: string | Blob | Uint8Array | null,\n private successCodes_: number[],\n private additionalRetryCodes_: number[],\n private callback_: RequestHandler<I, O>,\n private errorCallback_: ErrorHandler | null,\n private timeout_: number,\n private progressCallback_: ((p1: number, p2: number) => void) | null,\n private connectionFactory_: () => Connection<I>,\n private retry = true,\n private isUsingEmulator = false\n ) {\n this.promise_ = new Promise((resolve, reject) => {\n this.resolve_ = resolve as (value?: O | PromiseLike<O>) => void;\n this.reject_ = reject;\n this.start_();\n });\n }\n\n /**\n * Actually starts the retry loop.\n */\n private start_(): void {\n const doTheRequest: (\n backoffCallback: (success: boolean, ...p2: unknown[]) => void,\n canceled: boolean\n ) => void = (backoffCallback, canceled) => {\n if (canceled) {\n backoffCallback(false, new RequestEndStatus(false, null, true));\n return;\n }\n const connection = this.connectionFactory_();\n this.pendingConnection_ = connection;\n\n const progressListener: (\n progressEvent: ProgressEvent\n ) => void = progressEvent => {\n const loaded = progressEvent.loaded;\n const total = progressEvent.lengthComputable ? progressEvent.total : -1;\n if (this.progressCallback_ !== null) {\n this.progressCallback_(loaded, total);\n }\n };\n if (this.progressCallback_ !== null) {\n connection.addUploadProgressListener(progressListener);\n }\n\n // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n connection\n .send(\n this.url_,\n this.method_,\n this.isUsingEmulator,\n this.body_,\n this.headers_\n )\n .then(() => {\n if (this.progressCallback_ !== null) {\n connection.removeUploadProgressListener(progressListener);\n }\n this.pendingConnection_ = null;\n const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;\n const status = connection.getStatus();\n if (\n !hitServer ||\n (isRetryStatusCode(status, this.additionalRetryCodes_) &&\n this.retry)\n ) {\n const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;\n backoffCallback(\n false,\n new RequestEndStatus(false, null, wasCanceled)\n );\n return;\n }\n const successCode = this.successCodes_.indexOf(status) !== -1;\n backoffCallback(true, new RequestEndStatus(successCode, connection));\n });\n };\n\n /**\n * @param requestWentThrough - True if the request eventually went\n * through, false if it hit the retry limit or was canceled.\n */\n const backoffDone: (\n requestWentThrough: boolean,\n status: RequestEndStatus<I>\n ) => void = (requestWentThrough, status) => {\n const resolve = this.resolve_;\n const reject = this.reject_;\n const connection = status.connection as Connection<I>;\n if (status.wasSuccessCode) {\n try {\n const result = this.callback_(connection, connection.getResponse());\n if (isJustDef(result)) {\n resolve(result);\n } else {\n resolve();\n }\n } catch (e) {\n reject(e);\n }\n } else {\n if (connection !== null) {\n const err = unknown();\n err.serverResponse = connection.getErrorText();\n if (this.errorCallback_) {\n reject(this.errorCallback_(connection, err));\n } else {\n reject(err);\n }\n } else {\n if (status.canceled) {\n const err = this.appDelete_ ? appDeleted() : canceled();\n reject(err);\n } else {\n const err = retryLimitExceeded();\n reject(err);\n }\n }\n }\n };\n if (this.canceled_) {\n backoffDone(false, new RequestEndStatus(false, null, true));\n } else {\n this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);\n }\n }\n\n /** @inheritDoc */\n getPromise(): Promise<O> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(appDelete?: boolean): void {\n this.canceled_ = true;\n this.appDelete_ = appDelete || false;\n if (this.backoffId_ !== null) {\n stop(this.backoffId_);\n }\n if (this.pendingConnection_ !== null) {\n this.pendingConnection_.abort();\n }\n }\n}\n\n/**\n * A collection of information about the result of a network request.\n * @param opt_canceled - Defaults to false.\n */\nexport class RequestEndStatus<I extends ConnectionType> {\n /**\n * True if the request was canceled.\n */\n canceled: boolean;\n\n constructor(\n public wasSuccessCode: boolean,\n public connection: Connection<I> | null,\n canceled?: boolean\n ) {\n this.canceled = !!canceled;\n }\n}\n\nexport function addAuthHeader_(\n headers: Headers,\n authToken: string | null\n): void {\n if (authToken !== null && authToken.length > 0) {\n headers['Authorization'] = 'Firebase ' + authToken;\n }\n}\n\nexport function addVersionHeader_(\n headers: Headers,\n firebaseVersion?: string\n): void {\n headers['X-Firebase-Storage-Version'] =\n 'webjs/' + (firebaseVersion ?? 'AppManager');\n}\n\nexport function addGmpidHeader_(headers: Headers, appId: string | null): void {\n if (appId) {\n headers['X-Firebase-GMPID'] = appId;\n }\n}\n\nexport function addAppCheckHeader_(\n headers: Headers,\n appCheckToken: string | null\n): void {\n if (appCheckToken !== null) {\n headers['X-Firebase-AppCheck'] = appCheckToken;\n }\n}\n\nexport function makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n appId: string | null,\n authToken: string | null,\n appCheckToken: string | null,\n requestFactory: () => Connection<I>,\n firebaseVersion?: string,\n retry = true,\n isUsingEmulator = false\n): Request<O> {\n const queryPart = makeQueryString(requestInfo.urlParams);\n const url = requestInfo.url + queryPart;\n const headers = Object.assign({}, requestInfo.headers);\n addGmpidHeader_(headers, appId);\n addAuthHeader_(headers, authToken);\n addVersionHeader_(headers, firebaseVersion);\n addAppCheckHeader_(headers, appCheckToken);\n return new NetworkRequest<I, O>(\n url,\n requestInfo.method,\n headers,\n requestInfo.body,\n requestInfo.successCodes,\n requestInfo.additionalRetryCodes,\n requestInfo.handler,\n requestInfo.errorHandler,\n requestInfo.timeout,\n requestInfo.progressCallback,\n requestFactory,\n retry,\n isUsingEmulator\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Some methods copied from goog.fs.\n * We don't include goog.fs because it pulls in a bunch of Deferred code that\n * bloats the size of the released binary.\n */\nimport { isNativeBlobDefined } from './type';\nimport { StorageErrorCode, StorageError } from './error';\n\nfunction getBlobBuilder(): typeof IBlobBuilder | undefined {\n if (typeof BlobBuilder !== 'undefined') {\n return BlobBuilder;\n } else if (typeof WebKitBlobBuilder !== 'undefined') {\n return WebKitBlobBuilder;\n } else {\n return undefined;\n }\n}\n\n/**\n * Concatenates one or more values together and converts them to a Blob.\n *\n * @param args The values that will make up the resulting blob.\n * @return The blob.\n */\nexport function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob {\n const BlobBuilder = getBlobBuilder();\n if (BlobBuilder !== undefined) {\n const bb = new BlobBuilder();\n for (let i = 0; i < args.length; i++) {\n bb.append(args[i]);\n }\n return bb.getBlob();\n } else {\n if (isNativeBlobDefined()) {\n return new Blob(args);\n } else {\n throw new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n \"This browser doesn't seem to support creating Blobs\"\n );\n }\n }\n}\n\n/**\n * Slices the blob. The returned blob contains data from the start byte\n * (inclusive) till the end byte (exclusive). Negative indices cannot be used.\n *\n * @param blob The blob to be sliced.\n * @param start Index of the starting byte.\n * @param end Index of the ending byte.\n * @return The blob slice or null if not supported.\n */\nexport function sliceBlob(blob: Blob, start: number, end: number): Blob | null {\n if (blob.webkitSlice) {\n return blob.webkitSlice(start, end);\n } else if (blob.mozSlice) {\n return blob.mozSlice(start, end);\n } else if (blob.slice) {\n return blob.slice(start, end);\n }\n return null;\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TextDecoder } from 'util';\nimport { invalidFormat } from '../../implementation/error';\n\n/** Converts a Base64 encoded string to a binary string. */\nexport function decodeBase64(encoded: string): string {\n // Node actually doesn't validate base64 strings.\n // A quick sanity check that is not a fool-proof validation\n if (/[^-A-Za-z0-9+/=]/.test(encoded)) {\n throw invalidFormat('base64', 'Invalid character found');\n }\n return Buffer.from(encoded, 'base64').toString('binary');\n}\n\nexport function decodeUint8Array(data: Uint8Array): string {\n return new TextDecoder().decode(data);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unknown, invalidFormat } from './error';\nimport { decodeBase64 } from '../platform/base64';\n\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport const StringFormat = {\n /**\n * Indicates the string should be interpreted \"raw\", that is, as normal text.\n * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte\n * sequence.\n * Example: The string 'Hello! \\\\ud83d\\\\ude0a' becomes the byte sequence\n * 48 65 6c 6c 6f 21 20 f0 9f 98 8a\n */\n RAW: 'raw',\n /**\n * Indicates the string should be interpreted as base64-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64: 'base64',\n /**\n * Indicates the string should be interpreted as base64url-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64URL: 'base64url',\n /**\n * Indicates the string is a data URL, such as one obtained from\n * canvas.toDataURL().\n * Example: the string 'data:application/octet-stream;base64,aaaa'\n * becomes the byte sequence\n * 69 a6 9a\n * (the content-type \"application/octet-stream\" is also applied, but can\n * be overridden in the metadata object).\n */\n DATA_URL: 'data_url'\n} as const;\n\nexport class StringData {\n contentType: string | null;\n\n constructor(public data: Uint8Array, contentType?: string | null) {\n this.contentType = contentType || null;\n }\n}\n\n/**\n * @internal\n */\nexport function dataFromString(\n format: StringFormat,\n stringData: string\n): StringData {\n switch (format) {\n case StringFormat.RAW:\n return new StringData(utf8Bytes_(stringData));\n case StringFormat.BASE64:\n case StringFormat.BASE64URL:\n return new StringData(base64Bytes_(format, stringData));\n case StringFormat.DATA_URL:\n return new StringData(\n dataURLBytes_(stringData),\n dataURLContentType_(stringData)\n );\n default:\n // do nothing\n }\n\n // assert(false);\n throw unknown();\n}\n\nexport function utf8Bytes_(value: string): Uint8Array {\n const b: number[] = [];\n for (let i = 0; i < value.length; i++) {\n let c = value.charCodeAt(i);\n if (c <= 127) {\n b.push(c);\n } else {\n if (c <= 2047) {\n b.push(192 | (c >> 6), 128 | (c & 63));\n } else {\n if ((c & 64512) === 55296) {\n // The start of a surrogate pair.\n const valid =\n i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;\n if (!valid) {\n // The second surrogate wasn't there.\n b.push(239, 191, 189);\n } else {\n const hi = c;\n const lo = value.charCodeAt(++i);\n c = 65536 | ((hi & 1023) << 10) | (lo & 1023);\n b.push(\n 240 | (c >> 18),\n 128 | ((c >> 12) & 63),\n 128 | ((c >> 6) & 63),\n 128 | (c & 63)\n );\n }\n } else {\n if ((c & 64512) === 56320) {\n // Invalid low surrogate.\n b.push(239, 191, 189);\n } else {\n b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63));\n }\n }\n }\n }\n }\n return new Uint8Array(b);\n}\n\nexport function percentEncodedBytes_(value: string): Uint8Array {\n let decoded;\n try {\n decoded = decodeURIComponent(value);\n } catch (e) {\n throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.');\n }\n return utf8Bytes_(decoded);\n}\n\nexport function base64Bytes_(format: StringFormat, value: string): Uint8Array {\n switch (format) {\n case StringFormat.BASE64: {\n const hasMinus = value.indexOf('-') !== -1;\n const hasUnder = value.indexOf('_') !== -1;\n if (hasMinus || hasUnder) {\n const invalidChar = hasMinus ? '-' : '_';\n throw invalidFormat(\n format,\n \"Invalid character '\" +\n invalidChar +\n \"' found: is it base64url encoded?\"\n );\n }\n break;\n }\n case StringFormat.BASE64URL: {\n const hasPlus = value.indexOf('+') !== -1;\n const hasSlash = value.indexOf('/') !== -1;\n if (hasPlus || hasSlash) {\n const invalidChar = hasPlus ? '+' : '/';\n throw invalidFormat(\n format,\n \"Invalid character '\" + invalidChar + \"' found: is it base64 encoded?\"\n );\n }\n value = value.replace(/-/g, '+').replace(/_/g, '/');\n break;\n }\n default:\n // do nothing\n }\n let bytes;\n try {\n bytes = decodeBase64(value);\n } catch (e) {\n if ((e as Error).message.includes('polyfill')) {\n throw e;\n }\n throw invalidFormat(format, 'Invalid character found');\n }\n const array = new Uint8Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n array[i] = bytes.charCodeAt(i);\n }\n return array;\n}\n\nclass DataURLParts {\n base64: boolean = false;\n contentType: string | null = null;\n rest: string;\n\n constructor(dataURL: string) {\n const matches = dataURL.match(/^data:([^,]+)?,/);\n if (matches === null) {\n throw invalidFormat(\n StringFormat.DATA_URL,\n \"Must be formatted 'data:[<mediatype>][;base64],<data>\"\n );\n }\n const middle = matches[1] || null;\n if (middle != null) {\n this.base64 = endsWith(middle, ';base64');\n this.contentType = this.base64\n ? middle.substring(0, middle.length - ';base64'.length)\n : middle;\n }\n this.rest = dataURL.substring(dataURL.indexOf(',') + 1);\n }\n}\n\nexport function dataURLBytes_(dataUrl: string): Uint8Array {\n const parts = new DataURLParts(dataUrl);\n if (parts.base64) {\n return base64Bytes_(StringFormat.BASE64, parts.rest);\n } else {\n return percentEncodedBytes_(parts.rest);\n }\n}\n\nexport function dataURLContentType_(dataUrl: string): string | null {\n const parts = new DataURLParts(dataUrl);\n return parts.contentType;\n}\n\nfunction endsWith(s: string, end: string): boolean {\n const longEnough = s.length >= end.length;\n if (!longEnough) {\n return false;\n }\n\n return s.substring(s.length - end.length) === end;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Provides a Blob-like wrapper for various binary types (including the\n * native Blob type). This makes it possible to upload types like ArrayBuffers,\n * making uploads possible in environments without the native Blob type.\n */\nimport { sliceBlob, getBlob } from './fs';\nimport { StringFormat, dataFromString } from './string';\nimport { isNativeBlob, isNativeBlobDefined, isString } from './type';\n\n/**\n * @param opt_elideCopy - If true, doesn't copy mutable input data\n * (e.g. Uint8Arrays). Pass true only if you know the objects will not be\n * modified after this blob's construction.\n *\n * @internal\n */\nexport class FbsBlob {\n private data_!: Blob | Uint8Array;\n private size_: number;\n private type_: string;\n\n constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean) {\n let size: number = 0;\n let blobType: string = '';\n if (isNativeBlob(data)) {\n this.data_ = data as Blob;\n size = (data as Blob).size;\n blobType = (data as Blob).type;\n } else if (data instanceof ArrayBuffer) {\n if (elideCopy) {\n this.data_ = new Uint8Array(data);\n } else {\n this.data_ = new Uint8Array(data.byteLength);\n this.data_.set(new Uint8Array(data));\n }\n size = this.data_.length;\n } else if (data instanceof Uint8Array) {\n if (elideCopy) {\n this.data_ = data as Uint8Array;\n } else {\n this.data_ = new Uint8Array(data.length);\n this.data_.set(data as Uint8Array);\n }\n size = data.length;\n }\n this.size_ = size;\n this.type_ = blobType;\n }\n\n size(): number {\n return this.size_;\n }\n\n type(): string {\n return this.type_;\n }\n\n slice(startByte: number, endByte: number): FbsBlob | null {\n if (isNativeBlob(this.data_)) {\n const realBlob = this.data_ as Blob;\n const sliced = sliceBlob(realBlob, startByte, endByte);\n if (sliced === null) {\n return null;\n }\n return new FbsBlob(sliced);\n } else {\n const slice = new Uint8Array(\n (this.data_ as Uint8Array).buffer,\n startByte,\n endByte - startByte\n );\n return new FbsBlob(slice, true);\n }\n }\n\n static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null {\n if (isNativeBlobDefined()) {\n const blobby: Array<Blob | Uint8Array | string> = args.map(\n (val: string | FbsBlob): Blob | Uint8Array | string => {\n if (val instanceof FbsBlob) {\n return val.data_;\n } else {\n return val;\n }\n }\n );\n return new FbsBlob(getBlob.apply(null, blobby));\n } else {\n const uint8Arrays: Uint8Array[] = args.map(\n (val: string | FbsBlob): Uint8Array => {\n if (isString(val)) {\n return dataFromString(StringFormat.RAW, val as string).data;\n } else {\n // Blobs don't exist, so this has to be a Uint8Array.\n return (val as FbsBlob).data_ as Uint8Array;\n }\n }\n );\n let finalLength = 0;\n uint8Arrays.forEach((array: Uint8Array): void => {\n finalLength += array.byteLength;\n });\n const merged = new Uint8Array(finalLength);\n let index = 0;\n uint8Arrays.forEach((array: Uint8Array) => {\n for (let i = 0; i < array.length; i++) {\n merged[index++] = array[i];\n }\n });\n return new FbsBlob(merged, true);\n }\n }\n\n uploadData(): Blob | Uint8Array {\n return this.data_;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isNonArrayObject } from './type';\n\n/**\n * Returns the Object resulting from parsing the given JSON, or null if the\n * given string does not represent a JSON object.\n */\nexport function jsonObjectOrNull(\n s: string\n): { [name: string]: unknown } | null {\n let obj;\n try {\n obj = JSON.parse(s);\n } catch (e) {\n return null;\n }\n if (isNonArrayObject(obj)) {\n return obj;\n } else {\n return null;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Contains helper methods for manipulating paths.\n */\n\n/**\n * @return Null if the path is already at the root.\n */\nexport function parent(path: string): string | null {\n if (path.length === 0) {\n return null;\n }\n const index = path.lastIndexOf('/');\n if (index === -1) {\n return '';\n }\n const newPath = path.slice(0, index);\n return newPath;\n}\n\nexport function child(path: string, childPath: string): string {\n const canonicalChildPath = childPath\n .split('/')\n .filter(component => component.length > 0)\n .join('/');\n if (path.length === 0) {\n return canonicalChildPath;\n } else {\n return path + '/' + canonicalChildPath;\n }\n}\n\n/**\n * Returns the last component of a path.\n * '/foo/bar' -> 'bar'\n * '/foo/bar/baz/' -> 'baz/'\n * '/a' -> 'a'\n */\nexport function lastComponent(path: string): string {\n const index = path.lastIndexOf('/', path.length - 2);\n if (index === -1) {\n return path;\n } else {\n return path.slice(index + 1);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the metadata format\n */\nimport { Metadata } from '../metadata';\n\nimport { jsonObjectOrNull } from './json';\nimport { Location } from './location';\nimport { lastComponent } from './path';\nimport { isString } from './type';\nimport { makeUrl, makeQueryString } from './url';\nimport { Reference } from '../reference';\nimport { FirebaseStorageImpl } from '../service';\n\nexport function noXform_<T>(metadata: Metadata, value: T): T {\n return value;\n}\n\nclass Mapping<T> {\n local: string;\n writable: boolean;\n xform: (p1: Metadata, p2?: T) => T | undefined;\n\n constructor(\n public server: string,\n local?: string | null,\n writable?: boolean,\n xform?: ((p1: Metadata, p2?: T) => T | undefined) | null\n ) {\n this.local = local || server;\n this.writable = !!writable;\n this.xform = xform || noXform_;\n }\n}\ntype Mappings = Array<Mapping<string> | Mapping<number>>;\n\nexport { Mappings };\n\nlet mappings_: Mappings | null = null;\n\nexport function xformPath(fullPath: string | undefined): string | undefined {\n if (!isString(fullPath) || fullPath.length < 2) {\n return fullPath;\n } else {\n return lastComponent(fullPath);\n }\n}\n\nexport function getMappings(): Mappings {\n if (mappings_) {\n return mappings_;\n }\n const mappings: Mappings = [];\n mappings.push(new Mapping<string>('bucket'));\n mappings.push(new Mapping<string>('generation'));\n mappings.push(new Mapping<string>('metageneration'));\n mappings.push(new Mapping<string>('name', 'fullPath', true));\n\n function mappingsXformPath(\n _metadata: Metadata,\n fullPath: string | undefined\n ): string | undefined {\n return xformPath(fullPath);\n }\n const nameMapping = new Mapping<string>('name');\n nameMapping.xform = mappingsXformPath;\n mappings.push(nameMapping);\n\n /**\n * Coerces the second param to a number, if it is defined.\n */\n function xformSize(\n _metadata: Metadata,\n size?: number | string\n ): number | undefined {\n if (size !== undefined) {\n return Number(size);\n } else {\n return size;\n }\n }\n const sizeMapping = new Mapping<number>('size');\n sizeMapping.xform = xformSize;\n mappings.push(sizeMapping);\n mappings.push(new Mapping<number>('timeCreated'));\n mappings.push(new Mapping<string>('updated'));\n mappings.push(new Mapping<string>('md5Hash', null, true));\n mappings.push(new Mapping<string>('cacheControl', null, true));\n mappings.push(new Mapping<string>('contentDisposition', null, true));\n mappings.push(new Mapping<string>('contentEncoding', null, true));\n mappings.push(new Mapping<string>('contentLanguage', null, true));\n mappings.push(new Mapping<string>('contentType', null, true));\n mappings.push(new Mapping<string>('metadata', 'customMetadata', true));\n mappings_ = mappings;\n return mappings_;\n}\n\nexport function addRef(metadata: Metadata, service: FirebaseStorageImpl): void {\n function generateRef(): Reference {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const loc = new Location(bucket, path);\n return service._makeStorageReference(loc);\n }\n Object.defineProperty(metadata, 'ref', { get: generateRef });\n}\n\nexport function fromResource(\n service: FirebaseStorageImpl,\n resource: { [name: string]: unknown },\n mappings: Mappings\n): Metadata {\n const metadata: Metadata = {} as Metadata;\n metadata['type'] = 'file';\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n metadata[mapping.local] = (mapping as Mapping<unknown>).xform(\n metadata,\n resource[mapping.server]\n );\n }\n addRef(metadata, service);\n return metadata;\n}\n\nexport function fromResourceString(\n service: FirebaseStorageImpl,\n resourceString: string,\n mappings: Mappings\n): Metadata | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as Metadata;\n return fromResource(service, resource, mappings);\n}\n\nexport function downloadUrlFromResourceString(\n metadata: Metadata,\n resourceString: string,\n host: string,\n protocol: string\n): string | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n if (!isString(obj['downloadTokens'])) {\n // This can happen if objects are uploaded through GCS and retrieved\n // through list, so we don't want to throw an Error.\n return null;\n }\n const tokens: string = obj['downloadTokens'] as string;\n if (tokens.length === 0) {\n return null;\n }\n const encode = encodeURIComponent;\n const tokensList = tokens.split(',');\n const urls = tokensList.map((token: string): string => {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path);\n const base = makeUrl(urlPart, host, protocol);\n const queryString = makeQueryString({\n alt: 'media',\n token\n });\n return base + queryString;\n });\n return urls[0];\n}\n\nexport function toResourceString(\n metadata: Partial<Metadata>,\n mappings: Mappings\n): string {\n const resource: {\n [prop: string]: unknown;\n } = {};\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n if (mapping.writable) {\n resource[mapping.server] = metadata[mapping.local];\n }\n }\n return JSON.stringify(resource);\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the listOptions and listResult format\n */\nimport { Location } from './location';\nimport { jsonObjectOrNull } from './json';\nimport { ListResult } from '../list';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Represents the simplified object metadata returned by List API.\n * Other fields are filtered because list in Firebase Rules does not grant\n * the permission to read the metadata.\n */\ninterface ListMetadataResponse {\n name: string;\n bucket: string;\n}\n\n/**\n * Represents the JSON response of List API.\n */\ninterface ListResultResponse {\n prefixes: string[];\n items: ListMetadataResponse[];\n nextPageToken?: string;\n}\n\nconst PREFIXES_KEY = 'prefixes';\nconst ITEMS_KEY = 'items';\n\nfunction fromBackendResponse(\n service: FirebaseStorageImpl,\n bucket: string,\n resource: ListResultResponse\n): ListResult {\n const listResult: ListResult = {\n prefixes: [],\n items: [],\n nextPageToken: resource['nextPageToken']\n };\n if (resource[PREFIXES_KEY]) {\n for (const path of resource[PREFIXES_KEY]) {\n const pathWithoutTrailingSlash = path.replace(/\\/$/, '');\n const reference = service._makeStorageReference(\n new Location(bucket, pathWithoutTrailingSlash)\n );\n listResult.prefixes.push(reference);\n }\n }\n\n if (resource[ITEMS_KEY]) {\n for (const item of resource[ITEMS_KEY]) {\n const reference = service._makeStorageReference(\n new Location(bucket, item['name'])\n );\n listResult.items.push(reference);\n }\n }\n return listResult;\n}\n\nexport function fromResponseString(\n service: FirebaseStorageImpl,\n bucket: string,\n resourceString: string\n): ListResult | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as unknown as ListResultResponse;\n return fromBackendResponse(service, bucket, resource);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Headers, Connection, ConnectionType } from './connection';\n\n/**\n * Type for url params stored in RequestInfo.\n */\nexport interface UrlParams {\n [name: string]: string | number;\n}\n\n/**\n * A function that converts a server response to the API type expected by the\n * SDK.\n *\n * @param I - the type of the backend's network response\n * @param O - the output response type used by the rest of the SDK.\n */\nexport type RequestHandler<I extends ConnectionType, O> = (\n connection: Connection<I>,\n response: I\n) => O;\n\n/** A function to handle an error. */\nexport type ErrorHandler = (\n connection: Connection<ConnectionType>,\n response: StorageError\n) => StorageError;\n\n/**\n * Contains a fully specified request.\n *\n * @param I - the type of the backend's network response.\n * @param O - the output response type used by the rest of the SDK.\n */\nexport class RequestInfo<I extends ConnectionType, O> {\n urlParams: UrlParams = {};\n headers: Headers = {};\n body: Blob | string | Uint8Array | null = null;\n errorHandler: ErrorHandler | null = null;\n\n /**\n * Called with the current number of bytes uploaded and total size (-1 if not\n * computable) of the request body (i.e. used to report upload progress).\n */\n progressCallback: ((p1: number, p2: number) => void) | null = null;\n successCodes: number[] = [200];\n additionalRetryCodes: number[] = [];\n\n constructor(\n public url: string,\n public method: string,\n /**\n * Returns the value with which to resolve the request's promise. Only called\n * if the request is successful. Throw from this function to reject the\n * returned Request's promise with the thrown error.\n * Note: The XhrIo passed to this function may be reused after this callback\n * returns. Do not keep a reference to it in any way.\n */\n public handler: RequestHandler<I, O>,\n public timeout: number\n ) {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods for interacting with the network.\n */\n\nimport { Metadata } from '../metadata';\nimport { ListResult } from '../list';\nimport { FbsBlob } from './blob';\nimport {\n StorageError,\n cannotSliceBlob,\n unauthenticated,\n quotaExceeded,\n unauthorized,\n objectNotFound,\n serverFileWrongSize,\n unknown,\n unauthorizedApp\n} from './error';\nimport { Location } from './location';\nimport {\n Mappings,\n fromResourceString,\n downloadUrlFromResourceString,\n toResourceString\n} from './metadata';\nimport { fromResponseString } from './list';\nimport { RequestInfo, UrlParams } from './requestinfo';\nimport { isString } from './type';\nimport { makeUrl } from './url';\nimport { Connection, ConnectionType } from './connection';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Throws the UNKNOWN StorageError if cndn is false.\n */\nexport function handlerCheck(cndn: boolean): void {\n if (!cndn) {\n throw unknown();\n }\n}\n\nexport function metadataHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => Metadata {\n function handler(xhr: Connection<string>, text: string): Metadata {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return metadata as Metadata;\n }\n return handler;\n}\n\nexport function listHandler(\n service: FirebaseStorageImpl,\n bucket: string\n): (p1: Connection<string>, p2: string) => ListResult {\n function handler(xhr: Connection<string>, text: string): ListResult {\n const listResult = fromResponseString(service, bucket, text);\n handlerCheck(listResult !== null);\n return listResult as ListResult;\n }\n return handler;\n}\n\nexport function downloadUrlHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => string | null {\n function handler(xhr: Connection<string>, text: string): string | null {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return downloadUrlFromResourceString(\n metadata as Metadata,\n text,\n service.host,\n service._protocol\n );\n }\n return handler;\n}\n\nexport function sharedErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr: StorageError;\n if (xhr.getStatus() === 401) {\n if (\n // This exact message string is the only consistent part of the\n // server's error response that identifies it as an App Check error.\n xhr.getErrorText().includes('Firebase App Check token is invalid')\n ) {\n newErr = unauthorizedApp();\n } else {\n newErr = unauthenticated();\n }\n } else {\n if (xhr.getStatus() === 402) {\n newErr = quotaExceeded(location.bucket);\n } else {\n if (xhr.getStatus() === 403) {\n newErr = unauthorized(location.path);\n } else {\n newErr = err;\n }\n }\n }\n newErr.status = xhr.getStatus();\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function objectErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n const shared = sharedErrorHandler(location);\n\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr = shared(xhr, err);\n if (xhr.getStatus() === 404) {\n newErr = objectNotFound(location.path);\n }\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function getMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function list(\n service: FirebaseStorageImpl,\n location: Location,\n delimiter?: string,\n pageToken?: string | null,\n maxResults?: number | null\n): RequestInfo<string, ListResult> {\n const urlParams: UrlParams = {};\n if (location.isRoot) {\n urlParams['prefix'] = '';\n } else {\n urlParams['prefix'] = location.path + '/';\n }\n if (delimiter && delimiter.length > 0) {\n urlParams['delimiter'] = delimiter;\n }\n if (pageToken) {\n urlParams['pageToken'] = pageToken;\n }\n if (maxResults) {\n urlParams['maxResults'] = maxResults;\n }\n const urlPart = location.bucketOnlyServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n listHandler(service, location.bucket),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\nexport function getBytes<I extends ConnectionType>(\n service: FirebaseStorageImpl,\n location: Location,\n maxDownloadSizeBytes?: number\n): RequestInfo<I, I> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n (_: Connection<I>, data: I) => data,\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n if (maxDownloadSizeBytes !== undefined) {\n requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;\n requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];\n }\n return requestInfo;\n}\n\nexport function getDownloadUrl(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, string | null> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n downloadUrlHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function updateMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n metadata: Partial<Metadata>,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'PATCH';\n const body = toResourceString(metadata, mappings);\n const headers = { 'Content-Type': 'application/json; charset=utf-8' };\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function deleteObject(\n service: FirebaseStorageImpl,\n location: Location\n): RequestInfo<string, void> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'DELETE';\n const timeout = service.maxOperationRetryTime;\n\n function handler(_xhr: Connection<string>, _text: string): void {}\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.successCodes = [200, 204];\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function determineContentType_(\n metadata: Metadata | null,\n blob: FbsBlob | null\n): string {\n return (\n (metadata && metadata['contentType']) ||\n (blob && blob.type()) ||\n 'application/octet-stream'\n );\n}\n\nexport function metadataForUpload_(\n location: Location,\n blob: FbsBlob,\n metadata?: Metadata | null\n): Metadata {\n const metadataClone = Object.assign({}, metadata);\n metadataClone['fullPath'] = location.path;\n metadataClone['size'] = blob.size();\n if (!metadataClone['contentType']) {\n metadataClone['contentType'] = determineContentType_(null, blob);\n }\n return metadataClone;\n}\n\n/**\n * Prepare RequestInfo for uploads as Content-Type: multipart.\n */\nexport function multipartUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, Metadata> {\n const urlPart = location.bucketOnlyServerUrl();\n const headers: { [prop: string]: string } = {\n 'X-Goog-Upload-Protocol': 'multipart'\n };\n\n function genBoundary(): string {\n let str = '';\n for (let i = 0; i < 2; i++) {\n str = str + Math.random().toString().slice(2);\n }\n return str;\n }\n const boundary = genBoundary();\n headers['Content-Type'] = 'multipart/related; boundary=' + boundary;\n const metadata_ = metadataForUpload_(location, blob, metadata);\n const metadataString = toResourceString(metadata_, mappings);\n const preBlobPart =\n '--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: application/json; charset=utf-8\\r\\n\\r\\n' +\n metadataString +\n '\\r\\n--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: ' +\n metadata_['contentType'] +\n '\\r\\n\\r\\n';\n const postBlobPart = '\\r\\n--' + boundary + '--';\n const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);\n if (body === null) {\n throw cannotSliceBlob();\n }\n const urlParams: UrlParams = { name: metadata_['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param current The number of bytes that have been uploaded so far.\n * @param total The total number of bytes in the upload.\n * @param opt_finalized True if the server has finished the upload.\n * @param opt_metadata The upload metadata, should\n * only be passed if opt_finalized is true.\n */\nexport class ResumableUploadStatus {\n finalized: boolean;\n metadata: Metadata | null;\n\n constructor(\n public current: number,\n public total: number,\n finalized?: boolean,\n metadata?: Metadata | null\n ) {\n this.finalized = !!finalized;\n this.metadata = metadata || null;\n }\n}\n\nexport function checkResumeHeader_(\n xhr: Connection<string>,\n allowed?: string[]\n): string {\n let status: string | null = null;\n try {\n status = xhr.getResponseHeader('X-Goog-Upload-Status');\n } catch (e) {\n handlerCheck(false);\n }\n const allowedStatus = allowed || ['active'];\n handlerCheck(!!status && allowedStatus.indexOf(status) !== -1);\n return status as string;\n}\n\nexport function createResumableUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, string> {\n const urlPart = location.bucketOnlyServerUrl();\n const metadataForUpload = metadataForUpload_(location, blob, metadata);\n const urlParams: UrlParams = { name: metadataForUpload['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const headers = {\n 'X-Goog-Upload-Protocol': 'resumable',\n 'X-Goog-Upload-Command': 'start',\n 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`,\n 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType']!,\n 'Content-Type': 'application/json; charset=utf-8'\n };\n const body = toResourceString(metadataForUpload, mappings);\n const timeout = service.maxUploadRetryTime;\n\n function handler(xhr: Connection<string>): string {\n checkResumeHeader_(xhr);\n let url;\n try {\n url = xhr.getResponseHeader('X-Goog-Upload-URL');\n } catch (e) {\n handlerCheck(false);\n }\n handlerCheck(isString(url));\n return url as string;\n }\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n */\nexport function getResumableUploadStatus(\n service: FirebaseStorageImpl,\n location: Location,\n url: string,\n blob: FbsBlob\n): RequestInfo<string, ResumableUploadStatus> {\n const headers = { 'X-Goog-Upload-Command': 'query' };\n\n function handler(xhr: Connection<string>): ResumableUploadStatus {\n const status = checkResumeHeader_(xhr, ['active', 'final']);\n let sizeString: string | null = null;\n try {\n sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received');\n } catch (e) {\n handlerCheck(false);\n }\n\n if (!sizeString) {\n // null or empty string\n handlerCheck(false);\n }\n\n const size = Number(sizeString);\n handlerCheck(!isNaN(size));\n return new ResumableUploadStatus(size, blob.size(), status === 'final');\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * Any uploads via the resumable upload API must transfer a number of bytes\n * that is a multiple of this number.\n */\nexport const RESUMABLE_UPLOAD_CHUNK_SIZE: number = 256 * 1024;\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n * @param chunkSize Number of bytes to upload.\n * @param status The previous status.\n * If not passed or null, we start from the beginning.\n * @throws fbs.Error If the upload is already complete, the passed in status\n * has a final size inconsistent with the blob, or the blob cannot be sliced\n * for upload.\n */\nexport function continueResumableUpload(\n location: Location,\n service: FirebaseStorageImpl,\n url: string,\n blob: FbsBlob,\n chunkSize: number,\n mappings: Mappings,\n status?: ResumableUploadStatus | null,\n progressCallback?: ((p1: number, p2: number) => void) | null\n): RequestInfo<string, ResumableUploadStatus> {\n // TODO(andysoto): standardize on internal asserts\n // assert(!(opt_status && opt_status.finalized));\n const status_ = new ResumableUploadStatus(0, 0);\n if (status) {\n status_.current = status.current;\n status_.total = status.total;\n } else {\n status_.current = 0;\n status_.total = blob.size();\n }\n if (blob.size() !== status_.total) {\n throw serverFileWrongSize();\n }\n const bytesLeft = status_.total - status_.current;\n let bytesToUpload = bytesLeft;\n if (chunkSize > 0) {\n bytesToUpload = Math.min(bytesToUpload, chunkSize);\n }\n const startByte = status_.current;\n const endByte = startByte + bytesToUpload;\n let uploadCommand = '';\n if (bytesToUpload === 0) {\n uploadCommand = 'finalize';\n } else if (bytesLeft === bytesToUpload) {\n uploadCommand = 'upload, finalize';\n } else {\n uploadCommand = 'upload';\n }\n const headers = {\n 'X-Goog-Upload-Command': uploadCommand,\n 'X-Goog-Upload-Offset': `${status_.current}`\n };\n const body = blob.slice(startByte, endByte);\n if (body === null) {\n throw cannotSliceBlob();\n }\n\n function handler(\n xhr: Connection<string>,\n text: string\n ): ResumableUploadStatus {\n // TODO(andysoto): Verify the MD5 of each uploaded range:\n // the 'x-range-md5' header comes back with status code 308 responses.\n // We'll only be able to bail out though, because you can't re-upload a\n // range that you previously uploaded.\n const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']);\n const newCurrent = status_.current + bytesToUpload;\n const size = blob.size();\n let metadata;\n if (uploadStatus === 'final') {\n metadata = metadataHandler(service, mappings)(xhr, text);\n } else {\n metadata = null;\n }\n return new ResumableUploadStatus(\n newCurrent,\n size,\n uploadStatus === 'final',\n metadata\n );\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.progressCallback = progressCallback || null;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Enumerations used for upload tasks.\n */\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport type TaskEvent = string;\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport const TaskEvent = {\n /**\n * For this event,\n * <ul>\n * <li>The `next` function is triggered on progress updates and when the\n * task is paused/resumed with an `UploadTaskSnapshot` as the first\n * argument.</li>\n * <li>The `error` function is triggered if the upload is canceled or fails\n * for another reason.</li>\n * <li>The `complete` function is triggered if the upload completes\n * successfully.</li>\n * </ul>\n */\n STATE_CHANGED: 'state_changed'\n};\n\n/**\n * Internal enum for task state.\n */\nexport const enum InternalTaskState {\n RUNNING = 'running',\n PAUSING = 'pausing',\n PAUSED = 'paused',\n SUCCESS = 'success',\n CANCELING = 'canceling',\n CANCELED = 'canceled',\n ERROR = 'error'\n}\n\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport type TaskState = (typeof TaskState)[keyof typeof TaskState];\n\n// type keys = keyof TaskState\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport const TaskState = {\n /** The task is currently transferring data. */\n RUNNING: 'running',\n\n /** The task was paused by the user. */\n PAUSED: 'paused',\n\n /** The task completed successfully. */\n SUCCESS: 'success',\n\n /** The task was canceled. */\n CANCELED: 'canceled',\n\n /** The task failed with an error. */\n ERROR: 'error'\n} as const;\n\nexport function taskStateFromInternalTaskState(\n state: InternalTaskState\n): TaskState {\n switch (state) {\n case InternalTaskState.RUNNING:\n case InternalTaskState.PAUSING:\n case InternalTaskState.CANCELING:\n return TaskState.RUNNING;\n case InternalTaskState.PAUSED:\n return TaskState.PAUSED;\n case InternalTaskState.SUCCESS:\n return TaskState.SUCCESS;\n case InternalTaskState.CANCELED:\n return TaskState.CANCELED;\n case InternalTaskState.ERROR:\n return TaskState.ERROR;\n default:\n // TODO(andysoto): assert(false);\n return TaskState.ERROR;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isFunction } from './type';\nimport { StorageError } from './error';\n\n/**\n * Function that is called once for each value in a stream of values.\n */\nexport type NextFn<T> = (value: T) => void;\n\n/**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\nexport type ErrorFn = (error: StorageError) => void;\n\n/**\n * A function that is called if the event stream ends normally.\n */\nexport type CompleteFn = () => void;\n\n/**\n * Unsubscribes from a stream.\n */\nexport type Unsubscribe = () => void;\n\n/**\n * An observer identical to the `Observer` defined in packages/util except the\n * error passed into the ErrorFn is specifically a `StorageError`.\n */\nexport interface StorageObserver<T> {\n /**\n * Function that is called once for each value in the event stream.\n */\n next?: NextFn<T>;\n /**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\n error?: ErrorFn;\n /**\n * A function that is called if the event stream ends normally.\n */\n complete?: CompleteFn;\n}\n\n/**\n * Subscribes to an event stream.\n */\nexport type Subscribe<T> = (\n next?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n) => Unsubscribe;\n\nexport class Observer<T> implements StorageObserver<T> {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n\n constructor(\n nextOrObserver?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n ) {\n const asFunctions =\n isFunction(nextOrObserver) || error != null || complete != null;\n if (asFunctions) {\n this.next = nextOrObserver as NextFn<T>;\n this.error = error ?? undefined;\n this.complete = complete ?? undefined;\n } else {\n const observer = nextOrObserver as {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n };\n this.next = observer.next;\n this.error = observer.error;\n this.complete = observer.complete;\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a function that invokes f with its arguments asynchronously as a\n * microtask, i.e. as soon as possible after the current script returns back\n * into browser code.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function async(f: Function): Function {\n return (...argsToForward: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => f(...argsToForward));\n };\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isCloudWorkstation } from '@firebase/util';\nimport {\n Connection,\n ConnectionType,\n ErrorCode\n} from '../../implementation/connection';\nimport { internalError } from '../../implementation/error';\n\n/** An override for the text-based Connection. Used in tests. */\nlet textFactoryOverride: (() => Connection<string>) | null = null;\n\n/**\n * Network layer that works in Node.\n *\n * This network implementation should not be used in browsers as it does not\n * support progress updates.\n */\nabstract class FetchConnection<T extends ConnectionType>\n implements Connection<T>\n{\n protected errorCode_: ErrorCode;\n protected statusCode_: number | undefined;\n protected body_: ArrayBuffer | undefined;\n protected errorText_ = '';\n protected headers_: Headers | undefined;\n protected sent_: boolean = false;\n\n constructor() {\n this.errorCode_ = ErrorCode.NO_ERROR;\n }\n\n async send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: NodeJS.ArrayBufferView | Blob | string,\n headers?: Record<string, string>\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n this.sent_ = true;\n\n try {\n const response = await newFetch(\n url,\n method,\n isUsingEmulator,\n headers,\n body\n );\n this.headers_ = response.headers;\n this.statusCode_ = response.status;\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.body_ = await response.arrayBuffer();\n } catch (e) {\n this.errorText_ = (e as Error)?.message;\n // emulate XHR which sets status to 0 when encountering a network error\n this.statusCode_ = 0;\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n }\n }\n\n getErrorCode(): ErrorCode {\n if (this.errorCode_ === undefined) {\n throw internalError('cannot .getErrorCode() before receiving response');\n }\n return this.errorCode_;\n }\n\n getStatus(): number {\n if (this.statusCode_ === undefined) {\n throw internalError('cannot .getStatus() before receiving response');\n }\n return this.statusCode_;\n }\n\n abstract getResponse(): T;\n\n getErrorText(): string {\n return this.errorText_;\n }\n\n abort(): void {\n // Not supported\n }\n\n getResponseHeader(header: string): string | null {\n if (!this.headers_) {\n throw internalError(\n 'cannot .getResponseHeader() before receiving response'\n );\n }\n return this.headers_.get(header);\n }\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n // Not supported\n }\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n // Not supported\n }\n}\n\nexport class FetchTextConnection extends FetchConnection<string> {\n getResponse(): string {\n if (!this.body_) {\n throw internalError('cannot .getResponse() before receiving response');\n }\n return Buffer.from(this.body_).toString('utf-8');\n }\n}\n\nexport function newTextConnection(): Connection<string> {\n return textFactoryOverride\n ? textFactoryOverride()\n : new FetchTextConnection();\n}\n\nexport class FetchBytesConnection extends FetchConnection<ArrayBuffer> {\n getResponse(): ArrayBuffer {\n if (!this.body_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.body_;\n }\n}\n\nexport function newBytesConnection(): Connection<ArrayBuffer> {\n return new FetchBytesConnection();\n}\n\nexport class FetchStreamConnection extends FetchConnection<\n ReadableStream<Uint8Array>\n> {\n private stream_: ReadableStream<Uint8Array> | null = null;\n\n async send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: NodeJS.ArrayBufferView | Blob | string,\n headers?: Record<string, string>\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n this.sent_ = true;\n\n try {\n const response = await newFetch(\n url,\n method,\n isUsingEmulator,\n headers,\n body\n );\n this.headers_ = response.headers;\n this.statusCode_ = response.status;\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.stream_ = response.body as ReadableStream<Uint8Array>;\n } catch (e) {\n this.errorText_ = (e as Error)?.message;\n // emulate XHR which sets status to 0 when encountering a network error\n this.statusCode_ = 0;\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n }\n }\n\n getResponse(): ReadableStream {\n if (!this.stream_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.stream_;\n }\n}\n\nfunction newFetch(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n headers?: Record<string, string>,\n body?: NodeJS.ArrayBufferView | Blob | string\n): Promise<Response> {\n const fetchArgs: RequestInit = {\n method,\n headers: headers || {},\n body: body as NodeJS.ArrayBufferView | string\n };\n if (isCloudWorkstation(url) && isUsingEmulator) {\n fetchArgs.credentials = 'include';\n }\n return fetch(url, fetchArgs);\n}\n\nexport function newStreamConnection(): Connection<ReadableStream<Uint8Array>> {\n return new FetchStreamConnection();\n}\n\nexport function newBlobConnection(): Connection<Blob> {\n throw new Error('Blobs are not supported on Node');\n}\n\nexport function injectTestConnection(\n factory: (() => Connection<string>) | null\n): void {\n textFactoryOverride = factory;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Defines types for interacting with blob transfer tasks.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport {\n canceled,\n StorageErrorCode,\n StorageError,\n retryLimitExceeded\n} from './implementation/error';\nimport {\n InternalTaskState,\n TaskEvent,\n TaskState,\n taskStateFromInternalTaskState\n} from './implementation/taskenums';\nimport { Metadata } from './metadata';\nimport {\n Observer,\n Subscribe,\n Unsubscribe,\n StorageObserver as StorageObserverInternal,\n NextFn\n} from './implementation/observer';\nimport { Request } from './implementation/request';\nimport { UploadTaskSnapshot, StorageObserver } from './public-types';\nimport { async as fbsAsync } from './implementation/async';\nimport { Mappings, getMappings } from './implementation/metadata';\nimport {\n createResumableUpload,\n getResumableUploadStatus,\n RESUMABLE_UPLOAD_CHUNK_SIZE,\n ResumableUploadStatus,\n continueResumableUpload,\n getMetadata,\n multipartUpload\n} from './implementation/requests';\nimport { Reference } from './reference';\nimport { newTextConnection } from './platform/connection';\nimport { isRetryStatusCode } from './implementation/utils';\nimport { CompleteFn } from '@firebase/util';\nimport { DEFAULT_MIN_SLEEP_TIME_MILLIS } from './implementation/constants';\n\n/**\n * Represents a blob being uploaded. Can be used to pause/resume/cancel the\n * upload and manage callbacks for various events.\n * @internal\n */\nexport class UploadTask {\n private _ref: Reference;\n /**\n * The data to be uploaded.\n */\n _blob: FbsBlob;\n /**\n * Metadata related to the upload.\n */\n _metadata: Metadata | null;\n private _mappings: Mappings;\n /**\n * Number of bytes transferred so far.\n */\n _transferred: number = 0;\n private _needToFetchStatus: boolean = false;\n private _needToFetchMetadata: boolean = false;\n private _observers: Array<StorageObserverInternal<UploadTaskSnapshot>> = [];\n private _resumable: boolean;\n /**\n * Upload state.\n */\n _state: InternalTaskState;\n private _error?: StorageError = undefined;\n private _uploadUrl?: string = undefined;\n private _request?: Request<unknown> = undefined;\n private _chunkMultiplier: number = 1;\n private _errorHandler: (p1: StorageError) => void;\n private _metadataErrorHandler: (p1: StorageError) => void;\n private _resolve?: (p1: UploadTaskSnapshot) => void = undefined;\n private _reject?: (p1: StorageError) => void = undefined;\n private pendingTimeout?: ReturnType<typeof setTimeout>;\n private _promise: Promise<UploadTaskSnapshot>;\n\n private sleepTime: number;\n\n private maxSleepTime: number;\n\n isExponentialBackoffExpired(): boolean {\n return this.sleepTime > this.maxSleepTime;\n }\n\n /**\n * @param ref - The firebaseStorage.Reference object this task came\n * from, untyped to avoid cyclic dependencies.\n * @param blob - The blob to upload.\n */\n constructor(ref: Reference, blob: FbsBlob, metadata: Metadata | null = null) {\n this._ref = ref;\n this._blob = blob;\n this._metadata = metadata;\n this._mappings = getMappings();\n this._resumable = this._shouldDoResumable(this._blob);\n this._state = InternalTaskState.RUNNING;\n this._errorHandler = error => {\n this._request = undefined;\n this._chunkMultiplier = 1;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this._needToFetchStatus = true;\n this.completeTransitions_();\n } else {\n const backoffExpired = this.isExponentialBackoffExpired();\n if (isRetryStatusCode(error.status, [])) {\n if (backoffExpired) {\n error = retryLimitExceeded();\n } else {\n this.sleepTime = Math.max(\n this.sleepTime * 2,\n DEFAULT_MIN_SLEEP_TIME_MILLIS\n );\n this._needToFetchStatus = true;\n this.completeTransitions_();\n return;\n }\n }\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this._metadataErrorHandler = error => {\n this._request = undefined;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this.completeTransitions_();\n } else {\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this.sleepTime = 0;\n this.maxSleepTime = this._ref.storage.maxUploadRetryTime;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n this._start();\n });\n\n // Prevent uncaught rejections on the internal promise from bubbling out\n // to the top level with a dummy handler.\n this._promise.then(null, () => {});\n }\n\n private _makeProgressCallback(): (p1: number, p2: number) => void {\n const sizeBefore = this._transferred;\n return loaded => this._updateProgress(sizeBefore + loaded);\n }\n\n private _shouldDoResumable(blob: FbsBlob): boolean {\n return blob.size() > 256 * 1024;\n }\n\n private _start(): void {\n if (this._state !== InternalTaskState.RUNNING) {\n // This can happen if someone pauses us in a resume callback, for example.\n return;\n }\n if (this._request !== undefined) {\n return;\n }\n if (this._resumable) {\n if (this._uploadUrl === undefined) {\n this._createResumable();\n } else {\n if (this._needToFetchStatus) {\n this._fetchStatus();\n } else {\n if (this._needToFetchMetadata) {\n // Happens if we miss the metadata on upload completion.\n this._fetchMetadata();\n } else {\n this.pendingTimeout = setTimeout(() => {\n this.pendingTimeout = undefined;\n this._continueUpload();\n }, this.sleepTime);\n }\n }\n }\n } else {\n this._oneShotUpload();\n }\n }\n\n private _resolveToken(\n callback: (authToken: string | null, appCheckToken: string | null) => void\n ): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all([\n this._ref.storage._getAuthToken(),\n this._ref.storage._getAppCheckToken()\n ]).then(([authToken, appCheckToken]) => {\n switch (this._state) {\n case InternalTaskState.RUNNING:\n callback(authToken, appCheckToken);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n default:\n }\n });\n }\n\n // TODO(andysoto): assert false\n\n private _createResumable(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = createResumableUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const createRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = createRequest;\n createRequest.getPromise().then((url: string) => {\n this._request = undefined;\n this._uploadUrl = url;\n this._needToFetchStatus = false;\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _fetchStatus(): void {\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getResumableUploadStatus(\n this._ref.storage,\n this._ref._location,\n url,\n this._blob\n );\n const statusRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = statusRequest;\n statusRequest.getPromise().then(status => {\n status = status as ResumableUploadStatus;\n this._request = undefined;\n this._updateProgress(status.current);\n this._needToFetchStatus = false;\n if (status.finalized) {\n this._needToFetchMetadata = true;\n }\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _continueUpload(): void {\n const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n const status = new ResumableUploadStatus(\n this._transferred,\n this._blob.size()\n );\n\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n let requestInfo;\n try {\n requestInfo = continueResumableUpload(\n this._ref._location,\n this._ref.storage,\n url,\n this._blob,\n chunkSize,\n this._mappings,\n status,\n this._makeProgressCallback()\n );\n } catch (e) {\n this._error = e as StorageError;\n this._transition(InternalTaskState.ERROR);\n return;\n }\n const uploadRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken,\n /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file.\n );\n this._request = uploadRequest;\n uploadRequest.getPromise().then((newStatus: ResumableUploadStatus) => {\n this._increaseMultiplier();\n this._request = undefined;\n this._updateProgress(newStatus.current);\n if (newStatus.finalized) {\n this._metadata = newStatus.metadata;\n this._transition(InternalTaskState.SUCCESS);\n } else {\n this.completeTransitions_();\n }\n }, this._errorHandler);\n });\n }\n\n private _increaseMultiplier(): void {\n const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n\n // Max chunk size is 32M.\n if (currentSize * 2 < 32 * 1024 * 1024) {\n this._chunkMultiplier *= 2;\n }\n }\n\n private _fetchMetadata(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getMetadata(\n this._ref.storage,\n this._ref._location,\n this._mappings\n );\n const metadataRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = metadataRequest;\n metadataRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._transition(InternalTaskState.SUCCESS);\n }, this._metadataErrorHandler);\n });\n }\n\n private _oneShotUpload(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = multipartUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const multipartRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = multipartRequest;\n multipartRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._updateProgress(this._blob.size());\n this._transition(InternalTaskState.SUCCESS);\n }, this._errorHandler);\n });\n }\n\n private _updateProgress(transferred: number): void {\n const old = this._transferred;\n this._transferred = transferred;\n\n // A progress update can make the \"transferred\" value smaller (e.g. a\n // partial upload not completed by server, after which the \"transferred\"\n // value may reset to the value at the beginning of the request).\n if (this._transferred !== old) {\n this._notifyObservers();\n }\n }\n\n private _transition(state: InternalTaskState): void {\n if (this._state === state) {\n return;\n }\n switch (state) {\n case InternalTaskState.CANCELING:\n case InternalTaskState.PAUSING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n if (this._request !== undefined) {\n this._request.cancel();\n } else if (this.pendingTimeout) {\n clearTimeout(this.pendingTimeout);\n this.pendingTimeout = undefined;\n this.completeTransitions_();\n }\n break;\n case InternalTaskState.RUNNING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.PAUSING);\n const wasPaused = this._state === InternalTaskState.PAUSED;\n this._state = state;\n if (wasPaused) {\n this._notifyObservers();\n this._start();\n }\n break;\n case InternalTaskState.PAUSED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.CANCELED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.CANCELING);\n this._error = canceled();\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.ERROR:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.SUCCESS:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n default: // Ignore\n }\n }\n\n private completeTransitions_(): void {\n switch (this._state) {\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.RUNNING:\n this._start();\n break;\n default:\n // TODO(andysoto): assert(false);\n break;\n }\n }\n\n /**\n * A snapshot of the current task state.\n */\n get snapshot(): UploadTaskSnapshot {\n const externalState = taskStateFromInternalTaskState(this._state);\n return {\n bytesTransferred: this._transferred,\n totalBytes: this._blob.size(),\n state: externalState,\n metadata: this._metadata!,\n task: this,\n ref: this._ref\n };\n }\n\n /**\n * Adds a callback for an event.\n * @param type - The type of event to listen for.\n * @param nextOrObserver -\n * The `next` function, which gets called for each item in\n * the event stream, or an observer object with some or all of these three\n * properties (`next`, `error`, `complete`).\n * @param error - A function that gets called with a `StorageError`\n * if the event stream ends due to an error.\n * @param completed - A function that gets called if the\n * event stream ends normally.\n * @returns\n * If only the event argument is passed, returns a function you can use to\n * add callbacks (see the examples above). If more than just the event\n * argument is passed, returns a function you can call to unregister the\n * callbacks.\n */\n on(\n type: TaskEvent,\n nextOrObserver?:\n | StorageObserver<UploadTaskSnapshot>\n | null\n | ((snapshot: UploadTaskSnapshot) => unknown),\n error?: ((a: StorageError) => unknown) | null,\n completed?: CompleteFn | null\n ): Unsubscribe | Subscribe<UploadTaskSnapshot> {\n // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string.\n const observer = new Observer(\n (nextOrObserver as\n | StorageObserverInternal<UploadTaskSnapshot>\n | NextFn<UploadTaskSnapshot>) || undefined,\n error || undefined,\n completed || undefined\n );\n this._addObserver(observer);\n return () => {\n this._removeObserver(observer);\n };\n }\n\n /**\n * This object behaves like a Promise, and resolves with its snapshot data\n * when the upload completes.\n * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.\n * @param onRejected - The rejection callback.\n */\n then<U>(\n onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null,\n onRejected?: ((error: StorageError) => U | Promise<U>) | null\n ): Promise<U> {\n // These casts are needed so that TypeScript can infer the types of the\n // resulting Promise.\n return this._promise.then<U>(\n onFulfilled as (value: UploadTaskSnapshot) => U | Promise<U>,\n onRejected as ((error: unknown) => Promise<never>) | null\n );\n }\n\n /**\n * Equivalent to calling `then(null, onRejected)`.\n */\n catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T> {\n return this.then(null, onRejected);\n }\n\n /**\n * Adds the given observer.\n */\n private _addObserver(observer: Observer<UploadTaskSnapshot>): void {\n this._observers.push(observer);\n this._notifyObserver(observer);\n }\n\n /**\n * Removes the given observer.\n */\n private _removeObserver(observer: Observer<UploadTaskSnapshot>): void {\n const i = this._observers.indexOf(observer);\n if (i !== -1) {\n this._observers.splice(i, 1);\n }\n }\n\n private _notifyObservers(): void {\n this._finishPromise();\n const observers = this._observers.slice();\n observers.forEach(observer => {\n this._notifyObserver(observer);\n });\n }\n\n private _finishPromise(): void {\n if (this._resolve !== undefined) {\n let triggered = true;\n switch (taskStateFromInternalTaskState(this._state)) {\n case TaskState.SUCCESS:\n fbsAsync(this._resolve.bind(null, this.snapshot))();\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n const toCall = this._reject as (p1: StorageError) => void;\n fbsAsync(toCall.bind(null, this._error as StorageError))();\n break;\n default:\n triggered = false;\n break;\n }\n if (triggered) {\n this._resolve = undefined;\n this._reject = undefined;\n }\n }\n }\n\n private _notifyObserver(observer: Observer<UploadTaskSnapshot>): void {\n const externalState = taskStateFromInternalTaskState(this._state);\n switch (externalState) {\n case TaskState.RUNNING:\n case TaskState.PAUSED:\n if (observer.next) {\n fbsAsync(observer.next.bind(observer, this.snapshot))();\n }\n break;\n case TaskState.SUCCESS:\n if (observer.complete) {\n fbsAsync(observer.complete.bind(observer))();\n }\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n break;\n default:\n // TODO(andysoto): assert(false);\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n }\n }\n\n /**\n * Resumes a paused task. Has no effect on a currently running or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n resume(): boolean {\n const valid =\n this._state === InternalTaskState.PAUSED ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.RUNNING);\n }\n return valid;\n }\n\n /**\n * Pauses a currently running task. Has no effect on a paused or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n pause(): boolean {\n const valid = this._state === InternalTaskState.RUNNING;\n if (valid) {\n this._transition(InternalTaskState.PAUSING);\n }\n return valid;\n }\n\n /**\n * Cancels a currently running or paused task. Has no effect on a complete or\n * failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n cancel(): boolean {\n const valid =\n this._state === InternalTaskState.RUNNING ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.CANCELING);\n }\n return valid;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines the Firebase StorageReference class.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport { Location } from './implementation/location';\nimport { getMappings } from './implementation/metadata';\nimport { child, lastComponent, parent } from './implementation/path';\nimport {\n deleteObject as requestsDeleteObject,\n getBytes,\n getDownloadUrl as requestsGetDownloadUrl,\n getMetadata as requestsGetMetadata,\n list as requestsList,\n multipartUpload,\n updateMetadata as requestsUpdateMetadata\n} from './implementation/requests';\nimport { ListOptions, UploadResult } from './public-types';\nimport { dataFromString, StringFormat } from './implementation/string';\nimport { Metadata } from './metadata';\nimport { FirebaseStorageImpl } from './service';\nimport { ListResult } from './list';\nimport { UploadTask } from './task';\nimport { invalidRootOperation, noDownloadURL } from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport {\n newBlobConnection,\n newBytesConnection,\n newStreamConnection,\n newTextConnection\n} from './platform/connection';\nimport { RequestInfo } from './implementation/requestinfo';\n\n/**\n * Provides methods to interact with a bucket in the Firebase Storage service.\n * @internal\n * @param _location - An fbs.location, or the URL at\n * which to base this object, in one of the following forms:\n * gs://<bucket>/<object-path>\n * http[s]://firebasestorage.googleapis.com/\n * <api-version>/b/<bucket>/o/<object-path>\n * Any query or fragment strings will be ignored in the http[s]\n * format. If no value is passed, the storage object will use a URL based on\n * the project ID of the base firebase.App instance.\n */\nexport class Reference {\n _location: Location;\n\n constructor(\n private _service: FirebaseStorageImpl,\n location: string | Location\n ) {\n if (location instanceof Location) {\n this._location = location;\n } else {\n this._location = Location.makeFromUrl(location, _service.host);\n }\n }\n\n /**\n * Returns the URL for the bucket and path this object references,\n * in the form gs://<bucket>/<object-path>\n * @override\n */\n toString(): string {\n return 'gs://' + this._location.bucket + '/' + this._location.path;\n }\n\n protected _newRef(\n service: FirebaseStorageImpl,\n location: Location\n ): Reference {\n return new Reference(service, location);\n }\n\n /**\n * A reference to the root of this object's bucket.\n */\n get root(): Reference {\n const location = new Location(this._location.bucket, '');\n return this._newRef(this._service, location);\n }\n\n /**\n * The name of the bucket containing this reference's object.\n */\n get bucket(): string {\n return this._location.bucket;\n }\n\n /**\n * The full path of this object.\n */\n get fullPath(): string {\n return this._location.path;\n }\n\n /**\n * The short name of this object, which is the last component of the full path.\n * For example, if fullPath is 'full/path/image.png', name is 'image.png'.\n */\n get name(): string {\n return lastComponent(this._location.path);\n }\n\n /**\n * The `StorageService` instance this `StorageReference` is associated with.\n */\n get storage(): FirebaseStorageImpl {\n return this._service;\n }\n\n /**\n * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if\n * this reference is the root.\n */\n get parent(): Reference | null {\n const newPath = parent(this._location.path);\n if (newPath === null) {\n return null;\n }\n const location = new Location(this._location.bucket, newPath);\n return new Reference(this._service, location);\n }\n\n /**\n * Utility function to throw an error in methods that do not accept a root reference.\n */\n _throwIfRoot(name: string): void {\n if (this._location.path === '') {\n throw invalidRootOperation(name);\n }\n }\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded bytes.\n */\nexport function getBytesInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref._throwIfRoot('getBytes');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBytesConnection)\n .then(bytes =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (bytes as ArrayBuffer).slice(0, maxDownloadSizeBytes)\n : (bytes as ArrayBuffer)\n );\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded blob.\n */\nexport function getBlobInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref._throwIfRoot('getBlob');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBlobConnection)\n .then(blob =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (blob as Blob).slice(0, maxDownloadSizeBytes)\n : (blob as Blob)\n );\n}\n\n/** Stream the bytes at the object's location. */\nexport function getStreamInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref._throwIfRoot('getStream');\n const requestInfo: RequestInfo<ReadableStream, ReadableStream> = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n\n // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result\n const newMaxSizeTransform = (n: number): Transformer => {\n let missingBytes = n;\n return {\n transform(chunk, controller: TransformStreamDefaultController) {\n // GCS may not honor the Range header for small files\n if (chunk.length < missingBytes) {\n controller.enqueue(chunk);\n missingBytes -= chunk.length;\n } else {\n controller.enqueue(chunk.slice(0, missingBytes));\n controller.terminate();\n }\n }\n };\n };\n\n const result =\n maxDownloadSizeBytes !== undefined\n ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))\n : new TransformStream(); // The default transformer forwards all chunks to its readable side\n\n ref.storage\n .makeRequestWithTokens(requestInfo, newStreamConnection)\n .then(readableStream => readableStream.pipeThrough(result))\n .catch(err => result.writable.abort(err));\n\n return result.readable;\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n *\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadBytes');\n const requestInfo = multipartUpload(\n ref.storage,\n ref._location,\n getMappings(),\n new FbsBlob(data, true),\n metadata\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(finalMetadata => {\n return {\n metadata: finalMetadata,\n ref\n };\n });\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): UploadTask {\n ref._throwIfRoot('uploadBytesResumable');\n return new UploadTask(ref, new FbsBlob(data), metadata);\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - StorageReference where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the newly uploaded string.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: Reference,\n value: string,\n format: StringFormat = StringFormat.RAW,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadString');\n const data = dataFromString(format, value);\n const metadataClone = { ...metadata } as Metadata;\n if (metadataClone['contentType'] == null && data.contentType != null) {\n metadataClone['contentType'] = data.contentType!;\n }\n return uploadBytes(ref, data.data, metadataClone);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: listAll may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - StorageReference to get list from.\n *\n * @returns A Promise that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: Reference): Promise<ListResult> {\n const accumulator: ListResult = {\n prefixes: [],\n items: []\n };\n return listAllHelper(ref, accumulator).then(() => accumulator);\n}\n\n/**\n * Separated from listAll because async functions can't use \"arguments\".\n * @param ref\n * @param accumulator\n * @param pageToken\n */\nasync function listAllHelper(\n ref: Reference,\n accumulator: ListResult,\n pageToken?: string\n): Promise<void> {\n const opt: ListOptions = {\n // maxResults is 1000 by default.\n pageToken\n };\n const nextPage = await list(ref, opt);\n accumulator.prefixes.push(...nextPage.prefixes);\n accumulator.items.push(...nextPage.items);\n if (nextPage.nextPageToken != null) {\n await listAllHelper(ref, accumulator, nextPage.nextPageToken);\n }\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - StorageReference to get list from.\n * @param options - See ListOptions for details.\n * @returns A Promise that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: Reference,\n options?: ListOptions | null\n): Promise<ListResult> {\n if (options != null) {\n if (typeof options.maxResults === 'number') {\n validateNumber(\n 'options.maxResults',\n /* minValue= */ 1,\n /* maxValue= */ 1000,\n options.maxResults\n );\n }\n }\n const op = options || {};\n const requestInfo = requestsList(\n ref.storage,\n ref._location,\n /*delimiter= */ '/',\n op.pageToken,\n op.maxResults\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - StorageReference to get metadata from.\n */\nexport function getMetadata(ref: Reference): Promise<Metadata> {\n ref._throwIfRoot('getMetadata');\n const requestInfo = requestsGetMetadata(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - StorageReference to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves\n * with the new metadata for this object.\n * See `firebaseStorage.Reference.prototype.getMetadata`\n */\nexport function updateMetadata(\n ref: Reference,\n metadata: Partial<Metadata>\n): Promise<Metadata> {\n ref._throwIfRoot('updateMetadata');\n const requestInfo = requestsUpdateMetadata(\n ref.storage,\n ref._location,\n metadata,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns the download URL for the given Reference.\n * @public\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: Reference): Promise<string> {\n ref._throwIfRoot('getDownloadURL');\n const requestInfo = requestsGetDownloadUrl(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(url => {\n if (url === null) {\n throw noDownloadURL();\n }\n return url;\n });\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - StorageReference for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: Reference): Promise<void> {\n ref._throwIfRoot('deleteObject');\n const requestInfo = requestsDeleteObject(ref.storage, ref._location);\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns reference for object obtained by appending `childPath` to `ref`.\n *\n * @param ref - StorageReference to get child of.\n * @param childPath - Child path from provided ref.\n * @returns A reference to the object obtained by\n * appending childPath, removing any duplicate, beginning, or trailing\n * slashes.\n *\n */\nexport function _getChild(ref: Reference, childPath: string): Reference {\n const newPath = child(ref._location.path, childPath);\n const location = new Location(ref._location.bucket, newPath);\n return new Reference(ref.storage, location);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Location } from './implementation/location';\nimport { FailRequest } from './implementation/failrequest';\nimport { Request, makeRequest } from './implementation/request';\nimport { RequestInfo } from './implementation/requestinfo';\nimport { Reference, _getChild } from './reference';\nimport { Provider } from '@firebase/component';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n FirebaseApp,\n FirebaseOptions,\n _isFirebaseServerApp\n} from '@firebase/app';\nimport {\n CONFIG_STORAGE_BUCKET_KEY,\n DEFAULT_HOST,\n DEFAULT_MAX_OPERATION_RETRY_TIME,\n DEFAULT_MAX_UPLOAD_RETRY_TIME\n} from './implementation/constants';\nimport {\n invalidArgument,\n appDeleted,\n noDefaultBucket\n} from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport { FirebaseStorage } from './public-types';\nimport {\n createMockUserToken,\n EmulatorMockTokenOptions,\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\nimport { Connection, ConnectionType } from './implementation/connection';\n\nexport function isUrl(path?: string): boolean {\n return /^[A-Za-z]+:\\/\\//.test(path as string);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given url.\n */\nfunction refFromURL(service: FirebaseStorageImpl, url: string): Reference {\n return new Reference(service, url);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given path in the default\n * bucket.\n */\nfunction refFromPath(\n ref: FirebaseStorageImpl | Reference,\n path?: string\n): Reference {\n if (ref instanceof FirebaseStorageImpl) {\n const service = ref;\n if (service._bucket == null) {\n throw noDefaultBucket();\n }\n const reference = new Reference(service, service._bucket!);\n if (path != null) {\n return refFromPath(reference, path);\n } else {\n return reference;\n }\n } else {\n // ref is a Reference\n if (path !== undefined) {\n return _getChild(ref, path);\n } else {\n return ref;\n }\n }\n}\n\n/**\n * Returns a storage Reference for the given url.\n * @param storage - `Storage` instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorageImpl, url?: string): Reference;\n/**\n * Returns a storage Reference for the given path in the\n * default bucket.\n * @param storageOrRef - `Storage` service or storage `Reference`.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage\n * instance provided) or returns same reference (if Reference provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorageImpl | Reference,\n path?: string\n): Reference;\nexport function ref(\n serviceOrRef: FirebaseStorageImpl | Reference,\n pathOrUrl?: string\n): Reference | null {\n if (pathOrUrl && isUrl(pathOrUrl)) {\n if (serviceOrRef instanceof FirebaseStorageImpl) {\n return refFromURL(serviceOrRef, pathOrUrl);\n } else {\n throw invalidArgument(\n 'To use ref(service, url), the first argument must be a Storage instance.'\n );\n }\n } else {\n return refFromPath(serviceOrRef, pathOrUrl);\n }\n}\n\nfunction extractBucket(\n host: string,\n config?: FirebaseOptions\n): Location | null {\n const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY];\n if (bucketString == null) {\n return null;\n }\n return Location.makeFromBucketSpec(bucketString, host);\n}\n\nexport function connectStorageEmulator(\n storage: FirebaseStorageImpl,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n storage.host = `${host}:${port}`;\n const useSsl = isCloudWorkstation(host);\n // Workaround to get cookies in Firebase Studio\n if (useSsl) {\n void pingServer(`https://${storage.host}/b`);\n updateEmulatorBanner('Storage', true);\n }\n storage._isUsingEmulator = true;\n storage._protocol = useSsl ? 'https' : 'http';\n const { mockUserToken } = options;\n if (mockUserToken) {\n storage._overrideAuthToken =\n typeof mockUserToken === 'string'\n ? mockUserToken\n : createMockUserToken(mockUserToken, storage.app.options.projectId);\n }\n}\n\n/**\n * A service that provides Firebase Storage Reference instances.\n * @param opt_url - gs:// url to a custom Storage Bucket\n *\n * @internal\n */\nexport class FirebaseStorageImpl implements FirebaseStorage {\n _bucket: Location | null = null;\n /**\n * This string can be in the formats:\n * - host\n * - host:port\n */\n private _host: string = DEFAULT_HOST;\n _protocol: string = 'https';\n protected readonly _appId: string | null = null;\n private readonly _requests: Set<Request<unknown>>;\n private _deleted: boolean = false;\n private _maxOperationRetryTime: number;\n private _maxUploadRetryTime: number;\n _overrideAuthToken?: string;\n\n constructor(\n /**\n * FirebaseApp associated with this StorageService instance.\n */\n readonly app: FirebaseApp,\n readonly _authProvider: Provider<FirebaseAuthInternalName>,\n /**\n * @internal\n */\n readonly _appCheckProvider: Provider<AppCheckInternalComponentName>,\n /**\n * @internal\n */\n readonly _url?: string,\n readonly _firebaseVersion?: string,\n public _isUsingEmulator = false\n ) {\n this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;\n this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;\n this._requests = new Set();\n if (_url != null) {\n this._bucket = Location.makeFromBucketSpec(_url, this._host);\n } else {\n this._bucket = extractBucket(this._host, this.app.options);\n }\n }\n\n /**\n * The host string for this service, in the form of `host` or\n * `host:port`.\n */\n get host(): string {\n return this._host;\n }\n\n set host(host: string) {\n this._host = host;\n if (this._url != null) {\n this._bucket = Location.makeFromBucketSpec(this._url, host);\n } else {\n this._bucket = extractBucket(host, this.app.options);\n }\n }\n\n /**\n * The maximum time to retry uploads in milliseconds.\n */\n get maxUploadRetryTime(): number {\n return this._maxUploadRetryTime;\n }\n\n set maxUploadRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxUploadRetryTime = time;\n }\n\n /**\n * The maximum time to retry operations other than uploads or downloads in\n * milliseconds.\n */\n get maxOperationRetryTime(): number {\n return this._maxOperationRetryTime;\n }\n\n set maxOperationRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxOperationRetryTime = time;\n }\n\n async _getAuthToken(): Promise<string | null> {\n if (this._overrideAuthToken) {\n return this._overrideAuthToken;\n }\n const auth = this._authProvider.getImmediate({ optional: true });\n if (auth) {\n const tokenData = await auth.getToken();\n if (tokenData !== null) {\n return tokenData.accessToken;\n }\n }\n return null;\n }\n\n async _getAppCheckToken(): Promise<string | null> {\n if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) {\n return this.app.settings.appCheckToken;\n }\n const appCheck = this._appCheckProvider.getImmediate({ optional: true });\n if (appCheck) {\n const result = await appCheck.getToken();\n // TODO: What do we want to do if there is an error getting the token?\n // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be\n // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use\n // the token (actual or dummy) to send requests.\n return result.token;\n }\n return null;\n }\n\n /**\n * Stop running requests and prevent more from being created.\n */\n _delete(): Promise<void> {\n if (!this._deleted) {\n this._deleted = true;\n this._requests.forEach(request => request.cancel());\n this._requests.clear();\n }\n return Promise.resolve();\n }\n\n /**\n * Returns a new firebaseStorage.Reference object referencing this StorageService\n * at the given Location.\n */\n _makeStorageReference(loc: Location): Reference {\n return new Reference(this, loc);\n }\n\n /**\n * @param requestInfo - HTTP RequestInfo object\n * @param authToken - Firebase auth token\n */\n _makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>,\n authToken: string | null,\n appCheckToken: string | null,\n retry = true\n ): Request<O> {\n if (!this._deleted) {\n const request = makeRequest(\n requestInfo,\n this._appId,\n authToken,\n appCheckToken,\n requestFactory,\n this._firebaseVersion,\n retry,\n this._isUsingEmulator\n );\n this._requests.add(request);\n // Request removes itself from set when complete.\n request.getPromise().then(\n () => this._requests.delete(request),\n () => this._requests.delete(request)\n );\n return request;\n } else {\n return new FailRequest(appDeleted());\n }\n }\n\n async makeRequestWithTokens<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>\n ): Promise<O> {\n const [authToken, appCheckToken] = await Promise.all([\n this._getAuthToken(),\n this._getAppCheckToken()\n ]);\n\n return this._makeRequest(\n requestInfo,\n requestFactory,\n authToken,\n appCheckToken\n ).getPromise();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Type constant for Firebase Storage.\n */\nexport const STORAGE_TYPE = 'storage';\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { _getProvider, FirebaseApp, getApp } from '@firebase/app';\n\nimport {\n ref as refInternal,\n FirebaseStorageImpl,\n connectStorageEmulator as connectEmulatorInternal\n} from './service';\nimport { Provider } from '@firebase/component';\n\nimport {\n StorageReference,\n FirebaseStorage,\n UploadResult,\n ListOptions,\n ListResult,\n UploadTask,\n SettableMetadata,\n UploadMetadata,\n FullMetadata\n} from './public-types';\nimport { Metadata as MetadataInternal } from './metadata';\nimport {\n uploadBytes as uploadBytesInternal,\n uploadBytesResumable as uploadBytesResumableInternal,\n uploadString as uploadStringInternal,\n getMetadata as getMetadataInternal,\n updateMetadata as updateMetadataInternal,\n list as listInternal,\n listAll as listAllInternal,\n getDownloadURL as getDownloadURLInternal,\n deleteObject as deleteObjectInternal,\n Reference,\n _getChild as _getChildInternal,\n getBytesInternal\n} from './reference';\nimport { STORAGE_TYPE } from './constants';\nimport {\n EmulatorMockTokenOptions,\n getModularInstance,\n getDefaultEmulatorHostnameAndPort\n} from '@firebase/util';\nimport { StringFormat } from './implementation/string';\n\nexport { EmulatorMockTokenOptions } from '@firebase/util';\n\nexport { StorageError, StorageErrorCode } from './implementation/error';\n\n/**\n * Public types.\n */\nexport * from './public-types';\n\nexport { Location as _Location } from './implementation/location';\nexport { UploadTask as _UploadTask } from './task';\nexport type { Reference as _Reference } from './reference';\nexport type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';\nexport { FbsBlob as _FbsBlob } from './implementation/blob';\nexport { dataFromString as _dataFromString } from './implementation/string';\nexport {\n invalidRootOperation as _invalidRootOperation,\n invalidArgument as _invalidArgument\n} from './implementation/error';\nexport {\n TaskEvent as _TaskEvent,\n TaskState as _TaskState\n} from './implementation/taskenums';\nexport { StringFormat };\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise containing the object's bytes\n */\nexport function getBytes(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref = getModularInstance(ref);\n return getBytesInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadBytesInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the string to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: StorageReference,\n value: string,\n format?: StringFormat,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadStringInternal(\n ref as Reference,\n value,\n format,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): UploadTask {\n ref = getModularInstance(ref);\n return uploadBytesResumableInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n ) as UploadTask;\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - {@link StorageReference} to get metadata from.\n */\nexport function getMetadata(ref: StorageReference): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return getMetadataInternal(ref as Reference) as Promise<FullMetadata>;\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - {@link StorageReference} to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves with the new metadata for this object.\n */\nexport function updateMetadata(\n ref: StorageReference,\n metadata: SettableMetadata\n): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return updateMetadataInternal(\n ref as Reference,\n metadata as Partial<MetadataInternal>\n ) as Promise<FullMetadata>;\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - {@link StorageReference} to get list from.\n * @param options - See {@link ListOptions} for details.\n * @returns A `Promise` that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: StorageReference,\n options?: ListOptions\n): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listInternal(ref as Reference, options);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: `listAll` may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - {@link StorageReference} to get list from.\n *\n * @returns A `Promise` that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: StorageReference): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listAllInternal(ref as Reference);\n}\n\n/**\n * Returns the download URL for the given {@link StorageReference}.\n * @public\n * @param ref - {@link StorageReference} to get the download URL for.\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: StorageReference): Promise<string> {\n ref = getModularInstance(ref);\n return getDownloadURLInternal(ref as Reference);\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - {@link StorageReference} for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: StorageReference): Promise<void> {\n ref = getModularInstance(ref);\n return deleteObjectInternal(ref as Reference);\n}\n\n/**\n * Returns a {@link StorageReference} for the given url.\n * @param storage - {@link FirebaseStorage} instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorage, url?: string): StorageReference;\n/**\n * Returns a {@link StorageReference} for the given path in the\n * default bucket.\n * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}\n * instance provided) or returns same reference (if {@link StorageReference} provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorage | StorageReference,\n path?: string\n): StorageReference;\nexport function ref(\n serviceOrRef: FirebaseStorage | StorageReference,\n pathOrUrl?: string\n): StorageReference | null {\n serviceOrRef = getModularInstance(serviceOrRef);\n return refInternal(\n serviceOrRef as FirebaseStorageImpl | Reference,\n pathOrUrl\n );\n}\n\n/**\n * @internal\n */\nexport function _getChild(ref: StorageReference, childPath: string): Reference {\n return _getChildInternal(ref as Reference, childPath);\n}\n\n/**\n * Gets a {@link FirebaseStorage} instance for the given Firebase app.\n * @public\n * @param app - Firebase app to get {@link FirebaseStorage} instance for.\n * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.\n * If not passed, uses the app's default Storage Bucket.\n * @returns A {@link FirebaseStorage} instance.\n */\nexport function getStorage(\n app: FirebaseApp = getApp(),\n bucketUrl?: string\n): FirebaseStorage {\n app = getModularInstance(app);\n const storageProvider: Provider<'storage'> = _getProvider(app, STORAGE_TYPE);\n const storageInstance = storageProvider.getImmediate({\n identifier: bucketUrl\n });\n const emulator = getDefaultEmulatorHostnameAndPort('storage');\n if (emulator) {\n connectStorageEmulator(storageInstance, ...emulator);\n }\n return storageInstance;\n}\n\n/**\n * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.\n *\n * @param storage - The {@link FirebaseStorage} instance\n * @param host - The emulator host (ex: localhost)\n * @param port - The emulator port (ex: 5001)\n * @param options - Emulator options. `options.mockUserToken` is the mock auth\n * token to use for unit testing Security Rules.\n * @public\n */\nexport function connectStorageEmulator(\n storage: FirebaseStorage,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n connectEmulatorInternal(storage as FirebaseStorageImpl, host, port, options);\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StorageReference } from './public-types';\nimport { Reference, getStreamInternal } from './reference';\nimport { getModularInstance } from '@firebase/util';\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * This API is not available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise that resolves with a Blob containing the object's bytes\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function getBlob(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n throw new Error('getBlob() is only available in Browser-like environments');\n}\n\n/**\n * Downloads the data at the object's location. Raises an error event if the\n * object is not found.\n *\n * This API is only available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A stream with the object's data as bytes\n */\nexport function getStream(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref = getModularInstance(ref);\n return getStreamInternal(ref as Reference, maxDownloadSizeBytes);\n}\n","/**\n * Cloud Storage for Firebase\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n _registerComponent,\n registerVersion,\n SDK_VERSION\n} from '@firebase/app';\n\nimport { FirebaseStorageImpl } from './service';\nimport {\n Component,\n ComponentType,\n ComponentContainer,\n InstanceFactoryOptions\n} from '@firebase/component';\n\nimport { name, version } from '../package.json';\n\nimport { FirebaseStorage } from './public-types';\nimport { STORAGE_TYPE } from './constants';\n\nexport * from './api';\nexport * from './api.node';\n\nfunction factory(\n container: ComponentContainer,\n { instanceIdentifier: url }: InstanceFactoryOptions\n): FirebaseStorage {\n const app = container.getProvider('app').getImmediate();\n const authProvider = container.getProvider('auth-internal');\n const appCheckProvider = container.getProvider('app-check-internal');\n\n return new FirebaseStorageImpl(\n app,\n authProvider,\n appCheckProvider,\n url,\n SDK_VERSION\n );\n}\n\nfunction registerStorage(): void {\n _registerComponent(\n new Component(\n STORAGE_TYPE,\n factory,\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n\n registerVersion(name, version);\n}\n\nregisterStorage();\n"],"names":["FirebaseError","StorageErrorCode","getBlob","getMetadata","list","getBytes","updateMetadata","deleteObject","isCloudWorkstation","fbsAsync","uploadBytes","uploadBytesResumable","uploadString","listAll","requestsList","requestsGetMetadata","requestsUpdateMetadata","getDownloadURL","requestsGetDownloadUrl","requestsDeleteObject","_getChild","ref","connectStorageEmulator","pingServer","updateEmulatorBanner","createMockUserToken","_isFirebaseServerApp","getModularInstance","uploadBytesInternal","uploadStringInternal","uploadBytesResumableInternal","getMetadataInternal","updateMetadataInternal","listInternal","listAllInternal","getDownloadURLInternal","deleteObjectInternal","refInternal","_getChildInternal","app","getApp","_getProvider","getDefaultEmulatorHostnameAndPort","connectEmulatorInternal","SDK_VERSION","_registerComponent","Component","registerVersion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AAC;IAC5D,MAAM,gBAAgB,GAAG,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAErE,IAAA,OAAO,IAAI,mBAAmB,CAC5BA,KAAG,EACH,YAAY,EACZ,gBAAgB,EAChB,GAAG,EACHK,eAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,GAAA;AACtB,IAAAC,sBAAkB,CAChB,IAAIC,mBAAS,CACX,YAAY,EACZ,OAAO,EAER,QAAA,4BAAA,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAC7B,CAAC;AAEF,IAAAC,mBAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/index.node.esm.js b/frontend-old/node_modules/@firebase/storage/dist/node-esm/index.node.esm.js deleted file mode 100644 index 7753b65..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/index.node.esm.js +++ /dev/null @@ -1,3681 +0,0 @@ -import { _isFirebaseServerApp, _getProvider, getApp, _registerComponent, registerVersion, SDK_VERSION } from '@firebase/app'; -import { FirebaseError, isCloudWorkstation, pingServer, updateEmulatorBanner, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort } from '@firebase/util'; -import { Component } from '@firebase/component'; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -const DEFAULT_HOST = 'firebasestorage.googleapis.com'; -/** - * The key in Firebase config json for the storage bucket. - */ -const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket'; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000; -/** - * 10 minutes - * - * The timeout for upload. - */ -const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000; -/** - * 1 second - */ -const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -class StorageError extends FirebaseError { - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code, message, status_ = 0) { - super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`); - this.status_ = status_; - /** - * Stores custom error data unique to the `StorageError`. - */ - this.customData = { serverResponse: null }; - this._baseMessage = this.message; - // Without this, `instanceof StorageError`, in tests for example, - // returns false. - Object.setPrototypeOf(this, StorageError.prototype); - } - get status() { - return this.status_; - } - set status(status) { - this.status_ = status; - } - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code) { - return prependCode(code) === this.code; - } - /** - * Optional response message that was added by the server. - */ - get serverResponse() { - return this.customData.serverResponse; - } - set serverResponse(serverResponse) { - this.customData.serverResponse = serverResponse; - if (this.customData.serverResponse) { - this.message = `${this._baseMessage}\n${this.customData.serverResponse}`; - } - else { - this.message = this._baseMessage; - } - } -} -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -var StorageErrorCode; -(function (StorageErrorCode) { - // Shared between all platforms - StorageErrorCode["UNKNOWN"] = "unknown"; - StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found"; - StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found"; - StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found"; - StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded"; - StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated"; - StorageErrorCode["UNAUTHORIZED"] = "unauthorized"; - StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app"; - StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded"; - StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum"; - StorageErrorCode["CANCELED"] = "canceled"; - // JS specific - StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name"; - StorageErrorCode["INVALID_URL"] = "invalid-url"; - StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket"; - StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket"; - StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob"; - StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size"; - StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url"; - StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument"; - StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count"; - StorageErrorCode["APP_DELETED"] = "app-deleted"; - StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation"; - StorageErrorCode["INVALID_FORMAT"] = "invalid-format"; - StorageErrorCode["INTERNAL_ERROR"] = "internal-error"; - StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment"; -})(StorageErrorCode || (StorageErrorCode = {})); -function prependCode(code) { - return 'storage/' + code; -} -function unknown() { - const message = 'An unknown error occurred, please check the error payload for ' + - 'server response.'; - return new StorageError(StorageErrorCode.UNKNOWN, message); -} -function objectNotFound(path) { - return new StorageError(StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist."); -} -function quotaExceeded(bucket) { - return new StorageError(StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + - bucket + - "' exceeded, please view quota on " + - 'https://firebase.google.com/pricing/.'); -} -function unauthenticated() { - const message = 'User is not authenticated, please authenticate using Firebase ' + - 'Authentication and try again.'; - return new StorageError(StorageErrorCode.UNAUTHENTICATED, message); -} -function unauthorizedApp() { - return new StorageError(StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.'); -} -function unauthorized(path) { - return new StorageError(StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'."); -} -function retryLimitExceeded() { - return new StorageError(StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.'); -} -function canceled() { - return new StorageError(StorageErrorCode.CANCELED, 'User canceled the upload/download.'); -} -function invalidUrl(url) { - return new StorageError(StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'."); -} -function invalidDefaultBucket(bucket) { - return new StorageError(StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'."); -} -function noDefaultBucket() { - return new StorageError(StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' + - "found. Did you set the '" + - CONFIG_STORAGE_BUCKET_KEY + - "' property when initializing the app?"); -} -function cannotSliceBlob() { - return new StorageError(StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.'); -} -function serverFileWrongSize() { - return new StorageError(StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.'); -} -function noDownloadURL() { - return new StorageError(StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.'); -} -/** - * @internal - */ -function invalidArgument(message) { - return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message); -} -function appDeleted() { - return new StorageError(StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.'); -} -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -function invalidRootOperation(name) { - return new StorageError(StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + - name + - "' cannot be performed on a root reference, create a non-root " + - "reference using child, such as .child('file.png')."); -} -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -function invalidFormat(format, message) { - return new StorageError(StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message); -} -/** - * @param message - A message describing the internal error. - */ -function internalError(message) { - throw new StorageError(StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -class Location { - constructor(bucket, path) { - this.bucket = bucket; - this.path_ = path; - } - get path() { - return this.path_; - } - get isRoot() { - return this.path.length === 0; - } - fullServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o/' + encode(this.path); - } - bucketOnlyServerUrl() { - const encode = encodeURIComponent; - return '/b/' + encode(this.bucket) + '/o'; - } - static makeFromBucketSpec(bucketString, host) { - let bucketLocation; - try { - bucketLocation = Location.makeFromUrl(bucketString, host); - } - catch (e) { - // Not valid URL, use as-is. This lets you put bare bucket names in - // config. - return new Location(bucketString, ''); - } - if (bucketLocation.path === '') { - return bucketLocation; - } - else { - throw invalidDefaultBucket(bucketString); - } - } - static makeFromUrl(url, host) { - let location = null; - const bucketDomain = '([A-Za-z0-9.\\-_]+)'; - function gsModify(loc) { - if (loc.path.charAt(loc.path.length - 1) === '/') { - loc.path_ = loc.path_.slice(0, -1); - } - } - const gsPath = '(/(.*))?$'; - const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i'); - const gsIndices = { bucket: 1, path: 3 }; - function httpModify(loc) { - loc.path_ = decodeURIComponent(loc.path); - } - const version = 'v[A-Za-z0-9_]+'; - const firebaseStorageHost = host.replace(/[.]/g, '\\.'); - const firebaseStoragePath = '(/([^?#]*).*)?$'; - const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`, 'i'); - const firebaseStorageIndices = { bucket: 1, path: 3 }; - const cloudStorageHost = host === DEFAULT_HOST - ? '(?:storage.googleapis.com|storage.cloud.google.com)' - : host; - const cloudStoragePath = '([^?#]*)'; - const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, 'i'); - const cloudStorageIndices = { bucket: 1, path: 2 }; - const groups = [ - { regex: gsRegex, indices: gsIndices, postModify: gsModify }, - { - regex: firebaseStorageRegExp, - indices: firebaseStorageIndices, - postModify: httpModify - }, - { - regex: cloudStorageRegExp, - indices: cloudStorageIndices, - postModify: httpModify - } - ]; - for (let i = 0; i < groups.length; i++) { - const group = groups[i]; - const captures = group.regex.exec(url); - if (captures) { - const bucketValue = captures[group.indices.bucket]; - let pathValue = captures[group.indices.path]; - if (!pathValue) { - pathValue = ''; - } - location = new Location(bucketValue, pathValue); - group.postModify(location); - break; - } - } - if (location == null) { - throw invalidUrl(url); - } - return location; - } -} - -/** - * A request whose promise always fails. - */ -class FailRequest { - constructor(error) { - this.promise_ = Promise.reject(error); - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(_appDelete = false) { } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -function start(doRequest, -// eslint-disable-next-line @typescript-eslint/no-explicit-any -backoffCompleteCb, timeout) { - // TODO(andysoto): make this code cleaner (probably refactor into an actual - // type instead of a bunch of functions with state shared in the closure) - let waitSeconds = 1; - // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯ - // TODO: find a way to exclude Node type definition for storage because storage only works in browser - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let retryTimeoutId = null; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let globalTimeoutId = null; - let hitTimeout = false; - let cancelState = 0; - function canceled() { - return cancelState === 2; - } - let triggeredCallback = false; - function triggerCallback(...args) { - if (!triggeredCallback) { - triggeredCallback = true; - backoffCompleteCb.apply(null, args); - } - } - function callWithDelay(millis) { - retryTimeoutId = setTimeout(() => { - retryTimeoutId = null; - doRequest(responseHandler, canceled()); - }, millis); - } - function clearGlobalTimeout() { - if (globalTimeoutId) { - clearTimeout(globalTimeoutId); - } - } - function responseHandler(success, ...args) { - if (triggeredCallback) { - clearGlobalTimeout(); - return; - } - if (success) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - const mustStop = canceled() || hitTimeout; - if (mustStop) { - clearGlobalTimeout(); - triggerCallback.call(null, success, ...args); - return; - } - if (waitSeconds < 64) { - /* TODO(andysoto): don't back off so quickly if we know we're offline. */ - waitSeconds *= 2; - } - let waitMillis; - if (cancelState === 1) { - cancelState = 2; - waitMillis = 0; - } - else { - waitMillis = (waitSeconds + Math.random()) * 1000; - } - callWithDelay(waitMillis); - } - let stopped = false; - function stop(wasTimeout) { - if (stopped) { - return; - } - stopped = true; - clearGlobalTimeout(); - if (triggeredCallback) { - return; - } - if (retryTimeoutId !== null) { - if (!wasTimeout) { - cancelState = 2; - } - clearTimeout(retryTimeoutId); - callWithDelay(0); - } - else { - if (!wasTimeout) { - cancelState = 1; - } - } - } - callWithDelay(0); - globalTimeoutId = setTimeout(() => { - hitTimeout = true; - stop(true); - }, timeout); - return stop; -} -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -function stop(id) { - id(false); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isJustDef(p) { - return p !== void 0; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function isFunction(p) { - return typeof p === 'function'; -} -function isNonArrayObject(p) { - return typeof p === 'object' && !Array.isArray(p); -} -function isString(p) { - return typeof p === 'string' || p instanceof String; -} -function isNativeBlob(p) { - return isNativeBlobDefined() && p instanceof Blob; -} -function isNativeBlobDefined() { - return typeof Blob !== 'undefined'; -} -function validateNumber(argument, minValue, maxValue, value) { - if (value < minValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`); - } - if (value > maxValue) { - throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function makeUrl(urlPart, host, protocol) { - let origin = host; - if (protocol == null) { - origin = `https://${host}`; - } - return `${protocol}://${origin}/v0${urlPart}`; -} -function makeQueryString(params) { - const encode = encodeURIComponent; - let queryPart = '?'; - for (const key in params) { - if (params.hasOwnProperty(key)) { - const nextPart = encode(key) + '=' + encode(params[key]); - queryPart = queryPart + nextPart + '&'; - } - } - // Chop off the extra '&' or '?' on the end - queryPart = queryPart.slice(0, -1); - return queryPart; -} - -/** - * Error codes for requests made by the XhrIo wrapper. - */ -var ErrorCode; -(function (ErrorCode) { - ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR"; - ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR"; - ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT"; -})(ErrorCode || (ErrorCode = {})); - -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -function isRetryStatusCode(status, additionalRetryCodes) { - // The codes for which to retry came from this page: - // https://cloud.google.com/storage/docs/exponential-backoff - const isFiveHundredCode = status >= 500 && status < 600; - const extraRetryCodes = [ - // Request Timeout: web server didn't receive full request in time. - 408, - // Too Many Requests: you're getting rate-limited, basically. - 429 - ]; - const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1; - const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1; - return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Handles network logic for all Storage Requests, including error reporting and - * retries with backoff. - * - * @param I - the type of the backend's network response. - * @param - O the output type used by the rest of the SDK. The conversion - * happens in the specified `callback_`. - */ -class NetworkRequest { - constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) { - this.url_ = url_; - this.method_ = method_; - this.headers_ = headers_; - this.body_ = body_; - this.successCodes_ = successCodes_; - this.additionalRetryCodes_ = additionalRetryCodes_; - this.callback_ = callback_; - this.errorCallback_ = errorCallback_; - this.timeout_ = timeout_; - this.progressCallback_ = progressCallback_; - this.connectionFactory_ = connectionFactory_; - this.retry = retry; - this.isUsingEmulator = isUsingEmulator; - this.pendingConnection_ = null; - this.backoffId_ = null; - this.canceled_ = false; - this.appDelete_ = false; - this.promise_ = new Promise((resolve, reject) => { - this.resolve_ = resolve; - this.reject_ = reject; - this.start_(); - }); - } - /** - * Actually starts the retry loop. - */ - start_() { - const doTheRequest = (backoffCallback, canceled) => { - if (canceled) { - backoffCallback(false, new RequestEndStatus(false, null, true)); - return; - } - const connection = this.connectionFactory_(); - this.pendingConnection_ = connection; - const progressListener = progressEvent => { - const loaded = progressEvent.loaded; - const total = progressEvent.lengthComputable ? progressEvent.total : -1; - if (this.progressCallback_ !== null) { - this.progressCallback_(loaded, total); - } - }; - if (this.progressCallback_ !== null) { - connection.addUploadProgressListener(progressListener); - } - // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise. - // eslint-disable-next-line @typescript-eslint/no-floating-promises - connection - .send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_) - .then(() => { - if (this.progressCallback_ !== null) { - connection.removeUploadProgressListener(progressListener); - } - this.pendingConnection_ = null; - const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR; - const status = connection.getStatus(); - if (!hitServer || - (isRetryStatusCode(status, this.additionalRetryCodes_) && - this.retry)) { - const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT; - backoffCallback(false, new RequestEndStatus(false, null, wasCanceled)); - return; - } - const successCode = this.successCodes_.indexOf(status) !== -1; - backoffCallback(true, new RequestEndStatus(successCode, connection)); - }); - }; - /** - * @param requestWentThrough - True if the request eventually went - * through, false if it hit the retry limit or was canceled. - */ - const backoffDone = (requestWentThrough, status) => { - const resolve = this.resolve_; - const reject = this.reject_; - const connection = status.connection; - if (status.wasSuccessCode) { - try { - const result = this.callback_(connection, connection.getResponse()); - if (isJustDef(result)) { - resolve(result); - } - else { - resolve(); - } - } - catch (e) { - reject(e); - } - } - else { - if (connection !== null) { - const err = unknown(); - err.serverResponse = connection.getErrorText(); - if (this.errorCallback_) { - reject(this.errorCallback_(connection, err)); - } - else { - reject(err); - } - } - else { - if (status.canceled) { - const err = this.appDelete_ ? appDeleted() : canceled(); - reject(err); - } - else { - const err = retryLimitExceeded(); - reject(err); - } - } - } - }; - if (this.canceled_) { - backoffDone(false, new RequestEndStatus(false, null, true)); - } - else { - this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_); - } - } - /** @inheritDoc */ - getPromise() { - return this.promise_; - } - /** @inheritDoc */ - cancel(appDelete) { - this.canceled_ = true; - this.appDelete_ = appDelete || false; - if (this.backoffId_ !== null) { - stop(this.backoffId_); - } - if (this.pendingConnection_ !== null) { - this.pendingConnection_.abort(); - } - } -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -class RequestEndStatus { - constructor(wasSuccessCode, connection, canceled) { - this.wasSuccessCode = wasSuccessCode; - this.connection = connection; - this.canceled = !!canceled; - } -} -function addAuthHeader_(headers, authToken) { - if (authToken !== null && authToken.length > 0) { - headers['Authorization'] = 'Firebase ' + authToken; - } -} -function addVersionHeader_(headers, firebaseVersion) { - headers['X-Firebase-Storage-Version'] = - 'webjs/' + (firebaseVersion ?? 'AppManager'); -} -function addGmpidHeader_(headers, appId) { - if (appId) { - headers['X-Firebase-GMPID'] = appId; - } -} -function addAppCheckHeader_(headers, appCheckToken) { - if (appCheckToken !== null) { - headers['X-Firebase-AppCheck'] = appCheckToken; - } -} -function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) { - const queryPart = makeQueryString(requestInfo.urlParams); - const url = requestInfo.url + queryPart; - const headers = Object.assign({}, requestInfo.headers); - addGmpidHeader_(headers, appId); - addAuthHeader_(headers, authToken); - addVersionHeader_(headers, firebaseVersion); - addAppCheckHeader_(headers, appCheckToken); - return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function getBlobBuilder() { - if (typeof BlobBuilder !== 'undefined') { - return BlobBuilder; - } - else if (typeof WebKitBlobBuilder !== 'undefined') { - return WebKitBlobBuilder; - } - else { - return undefined; - } -} -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -function getBlob$1(...args) { - const BlobBuilder = getBlobBuilder(); - if (BlobBuilder !== undefined) { - const bb = new BlobBuilder(); - for (let i = 0; i < args.length; i++) { - bb.append(args[i]); - } - return bb.getBlob(); - } - else { - if (isNativeBlobDefined()) { - return new Blob(args); - } - else { - throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs"); - } - } -} -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -function sliceBlob(blob, start, end) { - if (blob.webkitSlice) { - return blob.webkitSlice(start, end); - } - else if (blob.mozSlice) { - return blob.mozSlice(start, end); - } - else if (blob.slice) { - return blob.slice(start, end); - } - return null; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -function decodeBase64(encoded) { - // Node actually doesn't validate base64 strings. - // A quick sanity check that is not a fool-proof validation - if (/[^-A-Za-z0-9+/=]/.test(encoded)) { - throw invalidFormat('base64', 'Invalid character found'); - } - return Buffer.from(encoded, 'base64').toString('binary'); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -const StringFormat = { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - RAW: 'raw', - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64: 'base64', - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - BASE64URL: 'base64url', - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - DATA_URL: 'data_url' -}; -class StringData { - constructor(data, contentType) { - this.data = data; - this.contentType = contentType || null; - } -} -/** - * @internal - */ -function dataFromString(format, stringData) { - switch (format) { - case StringFormat.RAW: - return new StringData(utf8Bytes_(stringData)); - case StringFormat.BASE64: - case StringFormat.BASE64URL: - return new StringData(base64Bytes_(format, stringData)); - case StringFormat.DATA_URL: - return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData)); - // do nothing - } - // assert(false); - throw unknown(); -} -function utf8Bytes_(value) { - const b = []; - for (let i = 0; i < value.length; i++) { - let c = value.charCodeAt(i); - if (c <= 127) { - b.push(c); - } - else { - if (c <= 2047) { - b.push(192 | (c >> 6), 128 | (c & 63)); - } - else { - if ((c & 64512) === 55296) { - // The start of a surrogate pair. - const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320; - if (!valid) { - // The second surrogate wasn't there. - b.push(239, 191, 189); - } - else { - const hi = c; - const lo = value.charCodeAt(++i); - c = 65536 | ((hi & 1023) << 10) | (lo & 1023); - b.push(240 | (c >> 18), 128 | ((c >> 12) & 63), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - else { - if ((c & 64512) === 56320) { - // Invalid low surrogate. - b.push(239, 191, 189); - } - else { - b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63)); - } - } - } - } - } - return new Uint8Array(b); -} -function percentEncodedBytes_(value) { - let decoded; - try { - decoded = decodeURIComponent(value); - } - catch (e) { - throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.'); - } - return utf8Bytes_(decoded); -} -function base64Bytes_(format, value) { - switch (format) { - case StringFormat.BASE64: { - const hasMinus = value.indexOf('-') !== -1; - const hasUnder = value.indexOf('_') !== -1; - if (hasMinus || hasUnder) { - const invalidChar = hasMinus ? '-' : '_'; - throw invalidFormat(format, "Invalid character '" + - invalidChar + - "' found: is it base64url encoded?"); - } - break; - } - case StringFormat.BASE64URL: { - const hasPlus = value.indexOf('+') !== -1; - const hasSlash = value.indexOf('/') !== -1; - if (hasPlus || hasSlash) { - const invalidChar = hasPlus ? '+' : '/'; - throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?"); - } - value = value.replace(/-/g, '+').replace(/_/g, '/'); - break; - } - // do nothing - } - let bytes; - try { - bytes = decodeBase64(value); - } - catch (e) { - if (e.message.includes('polyfill')) { - throw e; - } - throw invalidFormat(format, 'Invalid character found'); - } - const array = new Uint8Array(bytes.length); - for (let i = 0; i < bytes.length; i++) { - array[i] = bytes.charCodeAt(i); - } - return array; -} -class DataURLParts { - constructor(dataURL) { - this.base64 = false; - this.contentType = null; - const matches = dataURL.match(/^data:([^,]+)?,/); - if (matches === null) { - throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>"); - } - const middle = matches[1] || null; - if (middle != null) { - this.base64 = endsWith(middle, ';base64'); - this.contentType = this.base64 - ? middle.substring(0, middle.length - ';base64'.length) - : middle; - } - this.rest = dataURL.substring(dataURL.indexOf(',') + 1); - } -} -function dataURLBytes_(dataUrl) { - const parts = new DataURLParts(dataUrl); - if (parts.base64) { - return base64Bytes_(StringFormat.BASE64, parts.rest); - } - else { - return percentEncodedBytes_(parts.rest); - } -} -function dataURLContentType_(dataUrl) { - const parts = new DataURLParts(dataUrl); - return parts.contentType; -} -function endsWith(s, end) { - const longEnough = s.length >= end.length; - if (!longEnough) { - return false; - } - return s.substring(s.length - end.length) === end; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -class FbsBlob { - constructor(data, elideCopy) { - let size = 0; - let blobType = ''; - if (isNativeBlob(data)) { - this.data_ = data; - size = data.size; - blobType = data.type; - } - else if (data instanceof ArrayBuffer) { - if (elideCopy) { - this.data_ = new Uint8Array(data); - } - else { - this.data_ = new Uint8Array(data.byteLength); - this.data_.set(new Uint8Array(data)); - } - size = this.data_.length; - } - else if (data instanceof Uint8Array) { - if (elideCopy) { - this.data_ = data; - } - else { - this.data_ = new Uint8Array(data.length); - this.data_.set(data); - } - size = data.length; - } - this.size_ = size; - this.type_ = blobType; - } - size() { - return this.size_; - } - type() { - return this.type_; - } - slice(startByte, endByte) { - if (isNativeBlob(this.data_)) { - const realBlob = this.data_; - const sliced = sliceBlob(realBlob, startByte, endByte); - if (sliced === null) { - return null; - } - return new FbsBlob(sliced); - } - else { - const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte); - return new FbsBlob(slice, true); - } - } - static getBlob(...args) { - if (isNativeBlobDefined()) { - const blobby = args.map((val) => { - if (val instanceof FbsBlob) { - return val.data_; - } - else { - return val; - } - }); - return new FbsBlob(getBlob$1.apply(null, blobby)); - } - else { - const uint8Arrays = args.map((val) => { - if (isString(val)) { - return dataFromString(StringFormat.RAW, val).data; - } - else { - // Blobs don't exist, so this has to be a Uint8Array. - return val.data_; - } - }); - let finalLength = 0; - uint8Arrays.forEach((array) => { - finalLength += array.byteLength; - }); - const merged = new Uint8Array(finalLength); - let index = 0; - uint8Arrays.forEach((array) => { - for (let i = 0; i < array.length; i++) { - merged[index++] = array[i]; - } - }); - return new FbsBlob(merged, true); - } - } - uploadData() { - return this.data_; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -function jsonObjectOrNull(s) { - let obj; - try { - obj = JSON.parse(s); - } - catch (e) { - return null; - } - if (isNonArrayObject(obj)) { - return obj; - } - else { - return null; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -function parent(path) { - if (path.length === 0) { - return null; - } - const index = path.lastIndexOf('/'); - if (index === -1) { - return ''; - } - const newPath = path.slice(0, index); - return newPath; -} -function child(path, childPath) { - const canonicalChildPath = childPath - .split('/') - .filter(component => component.length > 0) - .join('/'); - if (path.length === 0) { - return canonicalChildPath; - } - else { - return path + '/' + canonicalChildPath; - } -} -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -function lastComponent(path) { - const index = path.lastIndexOf('/', path.length - 2); - if (index === -1) { - return path; - } - else { - return path.slice(index + 1); - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function noXform_(metadata, value) { - return value; -} -class Mapping { - constructor(server, local, writable, xform) { - this.server = server; - this.local = local || server; - this.writable = !!writable; - this.xform = xform || noXform_; - } -} -let mappings_ = null; -function xformPath(fullPath) { - if (!isString(fullPath) || fullPath.length < 2) { - return fullPath; - } - else { - return lastComponent(fullPath); - } -} -function getMappings() { - if (mappings_) { - return mappings_; - } - const mappings = []; - mappings.push(new Mapping('bucket')); - mappings.push(new Mapping('generation')); - mappings.push(new Mapping('metageneration')); - mappings.push(new Mapping('name', 'fullPath', true)); - function mappingsXformPath(_metadata, fullPath) { - return xformPath(fullPath); - } - const nameMapping = new Mapping('name'); - nameMapping.xform = mappingsXformPath; - mappings.push(nameMapping); - /** - * Coerces the second param to a number, if it is defined. - */ - function xformSize(_metadata, size) { - if (size !== undefined) { - return Number(size); - } - else { - return size; - } - } - const sizeMapping = new Mapping('size'); - sizeMapping.xform = xformSize; - mappings.push(sizeMapping); - mappings.push(new Mapping('timeCreated')); - mappings.push(new Mapping('updated')); - mappings.push(new Mapping('md5Hash', null, true)); - mappings.push(new Mapping('cacheControl', null, true)); - mappings.push(new Mapping('contentDisposition', null, true)); - mappings.push(new Mapping('contentEncoding', null, true)); - mappings.push(new Mapping('contentLanguage', null, true)); - mappings.push(new Mapping('contentType', null, true)); - mappings.push(new Mapping('metadata', 'customMetadata', true)); - mappings_ = mappings; - return mappings_; -} -function addRef(metadata, service) { - function generateRef() { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const loc = new Location(bucket, path); - return service._makeStorageReference(loc); - } - Object.defineProperty(metadata, 'ref', { get: generateRef }); -} -function fromResource(service, resource, mappings) { - const metadata = {}; - metadata['type'] = 'file'; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]); - } - addRef(metadata, service); - return metadata; -} -function fromResourceString(service, resourceString, mappings) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromResource(service, resource, mappings); -} -function downloadUrlFromResourceString(metadata, resourceString, host, protocol) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - if (!isString(obj['downloadTokens'])) { - // This can happen if objects are uploaded through GCS and retrieved - // through list, so we don't want to throw an Error. - return null; - } - const tokens = obj['downloadTokens']; - if (tokens.length === 0) { - return null; - } - const encode = encodeURIComponent; - const tokensList = tokens.split(','); - const urls = tokensList.map((token) => { - const bucket = metadata['bucket']; - const path = metadata['fullPath']; - const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path); - const base = makeUrl(urlPart, host, protocol); - const queryString = makeQueryString({ - alt: 'media', - token - }); - return base + queryString; - }); - return urls[0]; -} -function toResourceString(metadata, mappings) { - const resource = {}; - const len = mappings.length; - for (let i = 0; i < len; i++) { - const mapping = mappings[i]; - if (mapping.writable) { - resource[mapping.server] = metadata[mapping.local]; - } - } - return JSON.stringify(resource); -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const PREFIXES_KEY = 'prefixes'; -const ITEMS_KEY = 'items'; -function fromBackendResponse(service, bucket, resource) { - const listResult = { - prefixes: [], - items: [], - nextPageToken: resource['nextPageToken'] - }; - if (resource[PREFIXES_KEY]) { - for (const path of resource[PREFIXES_KEY]) { - const pathWithoutTrailingSlash = path.replace(/\/$/, ''); - const reference = service._makeStorageReference(new Location(bucket, pathWithoutTrailingSlash)); - listResult.prefixes.push(reference); - } - } - if (resource[ITEMS_KEY]) { - for (const item of resource[ITEMS_KEY]) { - const reference = service._makeStorageReference(new Location(bucket, item['name'])); - listResult.items.push(reference); - } - } - return listResult; -} -function fromResponseString(service, bucket, resourceString) { - const obj = jsonObjectOrNull(resourceString); - if (obj === null) { - return null; - } - const resource = obj; - return fromBackendResponse(service, bucket, resource); -} - -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -class RequestInfo { - constructor(url, method, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler, timeout) { - this.url = url; - this.method = method; - this.handler = handler; - this.timeout = timeout; - this.urlParams = {}; - this.headers = {}; - this.body = null; - this.errorHandler = null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - this.progressCallback = null; - this.successCodes = [200]; - this.additionalRetryCodes = []; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -function handlerCheck(cndn) { - if (!cndn) { - throw unknown(); - } -} -function metadataHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return metadata; - } - return handler; -} -function listHandler(service, bucket) { - function handler(xhr, text) { - const listResult = fromResponseString(service, bucket, text); - handlerCheck(listResult !== null); - return listResult; - } - return handler; -} -function downloadUrlHandler(service, mappings) { - function handler(xhr, text) { - const metadata = fromResourceString(service, text, mappings); - handlerCheck(metadata !== null); - return downloadUrlFromResourceString(metadata, text, service.host, service._protocol); - } - return handler; -} -function sharedErrorHandler(location) { - function errorHandler(xhr, err) { - let newErr; - if (xhr.getStatus() === 401) { - if ( - // This exact message string is the only consistent part of the - // server's error response that identifies it as an App Check error. - xhr.getErrorText().includes('Firebase App Check token is invalid')) { - newErr = unauthorizedApp(); - } - else { - newErr = unauthenticated(); - } - } - else { - if (xhr.getStatus() === 402) { - newErr = quotaExceeded(location.bucket); - } - else { - if (xhr.getStatus() === 403) { - newErr = unauthorized(location.path); - } - else { - newErr = err; - } - } - } - newErr.status = xhr.getStatus(); - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function objectErrorHandler(location) { - const shared = sharedErrorHandler(location); - function errorHandler(xhr, err) { - let newErr = shared(xhr, err); - if (xhr.getStatus() === 404) { - newErr = objectNotFound(location.path); - } - newErr.serverResponse = err.serverResponse; - return newErr; - } - return errorHandler; -} -function getMetadata$2(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function list$2(service, location, delimiter, pageToken, maxResults) { - const urlParams = {}; - if (location.isRoot) { - urlParams['prefix'] = ''; - } - else { - urlParams['prefix'] = location.path + '/'; - } - if (delimiter && delimiter.length > 0) { - urlParams['delimiter'] = delimiter; - } - if (pageToken) { - urlParams['pageToken'] = pageToken; - } - if (maxResults) { - urlParams['maxResults'] = maxResults; - } - const urlPart = location.bucketOnlyServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, listHandler(service, location.bucket), timeout); - requestInfo.urlParams = urlParams; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -function getBytes$1(service, location, maxDownloadSizeBytes) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media'; - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout); - requestInfo.errorHandler = objectErrorHandler(location); - if (maxDownloadSizeBytes !== undefined) { - requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`; - requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */]; - } - return requestInfo; -} -function getDownloadUrl(service, location, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'GET'; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout); - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function updateMetadata$2(service, location, metadata, mappings) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'PATCH'; - const body = toResourceString(metadata, mappings); - const headers = { 'Content-Type': 'application/json; charset=utf-8' }; - const timeout = service.maxOperationRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function deleteObject$2(service, location) { - const urlPart = location.fullServerUrl(); - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'DELETE'; - const timeout = service.maxOperationRetryTime; - function handler(_xhr, _text) { } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.successCodes = [200, 204]; - requestInfo.errorHandler = objectErrorHandler(location); - return requestInfo; -} -function determineContentType_(metadata, blob) { - return ((metadata && metadata['contentType']) || - (blob && blob.type()) || - 'application/octet-stream'); -} -function metadataForUpload_(location, blob, metadata) { - const metadataClone = Object.assign({}, metadata); - metadataClone['fullPath'] = location.path; - metadataClone['size'] = blob.size(); - if (!metadataClone['contentType']) { - metadataClone['contentType'] = determineContentType_(null, blob); - } - return metadataClone; -} -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -function multipartUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const headers = { - 'X-Goog-Upload-Protocol': 'multipart' - }; - function genBoundary() { - let str = ''; - for (let i = 0; i < 2; i++) { - str = str + Math.random().toString().slice(2); - } - return str; - } - const boundary = genBoundary(); - headers['Content-Type'] = 'multipart/related; boundary=' + boundary; - const metadata_ = metadataForUpload_(location, blob, metadata); - const metadataString = toResourceString(metadata_, mappings); - const preBlobPart = '--' + - boundary + - '\r\n' + - 'Content-Type: application/json; charset=utf-8\r\n\r\n' + - metadataString + - '\r\n--' + - boundary + - '\r\n' + - 'Content-Type: ' + - metadata_['contentType'] + - '\r\n\r\n'; - const postBlobPart = '\r\n--' + boundary + '--'; - const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart); - if (body === null) { - throw cannotSliceBlob(); - } - const urlParams = { name: metadata_['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -class ResumableUploadStatus { - constructor(current, total, finalized, metadata) { - this.current = current; - this.total = total; - this.finalized = !!finalized; - this.metadata = metadata || null; - } -} -function checkResumeHeader_(xhr, allowed) { - let status = null; - try { - status = xhr.getResponseHeader('X-Goog-Upload-Status'); - } - catch (e) { - handlerCheck(false); - } - const allowedStatus = allowed || ['active']; - handlerCheck(!!status && allowedStatus.indexOf(status) !== -1); - return status; -} -function createResumableUpload(service, location, mappings, blob, metadata) { - const urlPart = location.bucketOnlyServerUrl(); - const metadataForUpload = metadataForUpload_(location, blob, metadata); - const urlParams = { name: metadataForUpload['fullPath'] }; - const url = makeUrl(urlPart, service.host, service._protocol); - const method = 'POST'; - const headers = { - 'X-Goog-Upload-Protocol': 'resumable', - 'X-Goog-Upload-Command': 'start', - 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`, - 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType'], - 'Content-Type': 'application/json; charset=utf-8' - }; - const body = toResourceString(metadataForUpload, mappings); - const timeout = service.maxUploadRetryTime; - function handler(xhr) { - checkResumeHeader_(xhr); - let url; - try { - url = xhr.getResponseHeader('X-Goog-Upload-URL'); - } - catch (e) { - handlerCheck(false); - } - handlerCheck(isString(url)); - return url; - } - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.urlParams = urlParams; - requestInfo.headers = headers; - requestInfo.body = body; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -function getResumableUploadStatus(service, location, url, blob) { - const headers = { 'X-Goog-Upload-Command': 'query' }; - function handler(xhr) { - const status = checkResumeHeader_(xhr, ['active', 'final']); - let sizeString = null; - try { - sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received'); - } - catch (e) { - handlerCheck(false); - } - if (!sizeString) { - // null or empty string - handlerCheck(false); - } - const size = Number(sizeString); - handlerCheck(!isNaN(size)); - return new ResumableUploadStatus(size, blob.size(), status === 'final'); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -const RESUMABLE_UPLOAD_CHUNK_SIZE = 256 * 1024; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -function continueResumableUpload(location, service, url, blob, chunkSize, mappings, status, progressCallback) { - // TODO(andysoto): standardize on internal asserts - // assert(!(opt_status && opt_status.finalized)); - const status_ = new ResumableUploadStatus(0, 0); - if (status) { - status_.current = status.current; - status_.total = status.total; - } - else { - status_.current = 0; - status_.total = blob.size(); - } - if (blob.size() !== status_.total) { - throw serverFileWrongSize(); - } - const bytesLeft = status_.total - status_.current; - let bytesToUpload = bytesLeft; - if (chunkSize > 0) { - bytesToUpload = Math.min(bytesToUpload, chunkSize); - } - const startByte = status_.current; - const endByte = startByte + bytesToUpload; - let uploadCommand = ''; - if (bytesToUpload === 0) { - uploadCommand = 'finalize'; - } - else if (bytesLeft === bytesToUpload) { - uploadCommand = 'upload, finalize'; - } - else { - uploadCommand = 'upload'; - } - const headers = { - 'X-Goog-Upload-Command': uploadCommand, - 'X-Goog-Upload-Offset': `${status_.current}` - }; - const body = blob.slice(startByte, endByte); - if (body === null) { - throw cannotSliceBlob(); - } - function handler(xhr, text) { - // TODO(andysoto): Verify the MD5 of each uploaded range: - // the 'x-range-md5' header comes back with status code 308 responses. - // We'll only be able to bail out though, because you can't re-upload a - // range that you previously uploaded. - const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']); - const newCurrent = status_.current + bytesToUpload; - const size = blob.size(); - let metadata; - if (uploadStatus === 'final') { - metadata = metadataHandler(service, mappings)(xhr, text); - } - else { - metadata = null; - } - return new ResumableUploadStatus(newCurrent, size, uploadStatus === 'final', metadata); - } - const method = 'POST'; - const timeout = service.maxUploadRetryTime; - const requestInfo = new RequestInfo(url, method, handler, timeout); - requestInfo.headers = headers; - requestInfo.body = body.uploadData(); - requestInfo.progressCallback = progressCallback || null; - requestInfo.errorHandler = sharedErrorHandler(location); - return requestInfo; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An event that is triggered on a task. - * @internal - */ -const TaskEvent = { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: 'state_changed' -}; -// type keys = keyof TaskState -/** - * Represents the current state of a running upload. - * @internal - */ -const TaskState = { - /** The task is currently transferring data. */ - RUNNING: 'running', - /** The task was paused by the user. */ - PAUSED: 'paused', - /** The task completed successfully. */ - SUCCESS: 'success', - /** The task was canceled. */ - CANCELED: 'canceled', - /** The task failed with an error. */ - ERROR: 'error' -}; -function taskStateFromInternalTaskState(state) { - switch (state) { - case "running" /* InternalTaskState.RUNNING */: - case "pausing" /* InternalTaskState.PAUSING */: - case "canceling" /* InternalTaskState.CANCELING */: - return TaskState.RUNNING; - case "paused" /* InternalTaskState.PAUSED */: - return TaskState.PAUSED; - case "success" /* InternalTaskState.SUCCESS */: - return TaskState.SUCCESS; - case "canceled" /* InternalTaskState.CANCELED */: - return TaskState.CANCELED; - case "error" /* InternalTaskState.ERROR */: - return TaskState.ERROR; - default: - // TODO(andysoto): assert(false); - return TaskState.ERROR; - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -class Observer { - constructor(nextOrObserver, error, complete) { - const asFunctions = isFunction(nextOrObserver) || error != null || complete != null; - if (asFunctions) { - this.next = nextOrObserver; - this.error = error ?? undefined; - this.complete = complete ?? undefined; - } - else { - const observer = nextOrObserver; - this.next = observer.next; - this.error = observer.error; - this.complete = observer.complete; - } - } -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -// eslint-disable-next-line @typescript-eslint/ban-types -function async(f) { - return (...argsToForward) => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.resolve().then(() => f(...argsToForward)); - }; -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** An override for the text-based Connection. Used in tests. */ -let textFactoryOverride = null; -/** - * Network layer that works in Node. - * - * This network implementation should not be used in browsers as it does not - * support progress updates. - */ -class FetchConnection { - constructor() { - this.errorText_ = ''; - this.sent_ = false; - this.errorCode_ = ErrorCode.NO_ERROR; - } - async send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - this.sent_ = true; - try { - const response = await newFetch(url, method, isUsingEmulator, headers, body); - this.headers_ = response.headers; - this.statusCode_ = response.status; - this.errorCode_ = ErrorCode.NO_ERROR; - this.body_ = await response.arrayBuffer(); - } - catch (e) { - this.errorText_ = e?.message; - // emulate XHR which sets status to 0 when encountering a network error - this.statusCode_ = 0; - this.errorCode_ = ErrorCode.NETWORK_ERROR; - } - } - getErrorCode() { - if (this.errorCode_ === undefined) { - throw internalError('cannot .getErrorCode() before receiving response'); - } - return this.errorCode_; - } - getStatus() { - if (this.statusCode_ === undefined) { - throw internalError('cannot .getStatus() before receiving response'); - } - return this.statusCode_; - } - getErrorText() { - return this.errorText_; - } - abort() { - // Not supported - } - getResponseHeader(header) { - if (!this.headers_) { - throw internalError('cannot .getResponseHeader() before receiving response'); - } - return this.headers_.get(header); - } - addUploadProgressListener(listener) { - // Not supported - } - removeUploadProgressListener(listener) { - // Not supported - } -} -class FetchTextConnection extends FetchConnection { - getResponse() { - if (!this.body_) { - throw internalError('cannot .getResponse() before receiving response'); - } - return Buffer.from(this.body_).toString('utf-8'); - } -} -function newTextConnection() { - return textFactoryOverride - ? textFactoryOverride() - : new FetchTextConnection(); -} -class FetchBytesConnection extends FetchConnection { - getResponse() { - if (!this.body_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.body_; - } -} -function newBytesConnection() { - return new FetchBytesConnection(); -} -class FetchStreamConnection extends FetchConnection { - constructor() { - super(...arguments); - this.stream_ = null; - } - async send(url, method, isUsingEmulator, body, headers) { - if (this.sent_) { - throw internalError('cannot .send() more than once'); - } - this.sent_ = true; - try { - const response = await newFetch(url, method, isUsingEmulator, headers, body); - this.headers_ = response.headers; - this.statusCode_ = response.status; - this.errorCode_ = ErrorCode.NO_ERROR; - this.stream_ = response.body; - } - catch (e) { - this.errorText_ = e?.message; - // emulate XHR which sets status to 0 when encountering a network error - this.statusCode_ = 0; - this.errorCode_ = ErrorCode.NETWORK_ERROR; - } - } - getResponse() { - if (!this.stream_) { - throw internalError('cannot .getResponse() before sending'); - } - return this.stream_; - } -} -function newFetch(url, method, isUsingEmulator, headers, body) { - const fetchArgs = { - method, - headers: headers || {}, - body: body - }; - if (isCloudWorkstation(url) && isUsingEmulator) { - fetchArgs.credentials = 'include'; - } - return fetch(url, fetchArgs); -} -function newStreamConnection() { - return new FetchStreamConnection(); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -class UploadTask { - isExponentialBackoffExpired() { - return this.sleepTime > this.maxSleepTime; - } - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref, blob, metadata = null) { - /** - * Number of bytes transferred so far. - */ - this._transferred = 0; - this._needToFetchStatus = false; - this._needToFetchMetadata = false; - this._observers = []; - this._error = undefined; - this._uploadUrl = undefined; - this._request = undefined; - this._chunkMultiplier = 1; - this._resolve = undefined; - this._reject = undefined; - this._ref = ref; - this._blob = blob; - this._metadata = metadata; - this._mappings = getMappings(); - this._resumable = this._shouldDoResumable(this._blob); - this._state = "running" /* InternalTaskState.RUNNING */; - this._errorHandler = error => { - this._request = undefined; - this._chunkMultiplier = 1; - if (error._codeEquals(StorageErrorCode.CANCELED)) { - this._needToFetchStatus = true; - this.completeTransitions_(); - } - else { - const backoffExpired = this.isExponentialBackoffExpired(); - if (isRetryStatusCode(error.status, [])) { - if (backoffExpired) { - error = retryLimitExceeded(); - } - else { - this.sleepTime = Math.max(this.sleepTime * 2, DEFAULT_MIN_SLEEP_TIME_MILLIS); - this._needToFetchStatus = true; - this.completeTransitions_(); - return; - } - } - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this._metadataErrorHandler = error => { - this._request = undefined; - if (error._codeEquals(StorageErrorCode.CANCELED)) { - this.completeTransitions_(); - } - else { - this._error = error; - this._transition("error" /* InternalTaskState.ERROR */); - } - }; - this.sleepTime = 0; - this.maxSleepTime = this._ref.storage.maxUploadRetryTime; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - this._start(); - }); - // Prevent uncaught rejections on the internal promise from bubbling out - // to the top level with a dummy handler. - this._promise.then(null, () => { }); - } - _makeProgressCallback() { - const sizeBefore = this._transferred; - return loaded => this._updateProgress(sizeBefore + loaded); - } - _shouldDoResumable(blob) { - return blob.size() > 256 * 1024; - } - _start() { - if (this._state !== "running" /* InternalTaskState.RUNNING */) { - // This can happen if someone pauses us in a resume callback, for example. - return; - } - if (this._request !== undefined) { - return; - } - if (this._resumable) { - if (this._uploadUrl === undefined) { - this._createResumable(); - } - else { - if (this._needToFetchStatus) { - this._fetchStatus(); - } - else { - if (this._needToFetchMetadata) { - // Happens if we miss the metadata on upload completion. - this._fetchMetadata(); - } - else { - this.pendingTimeout = setTimeout(() => { - this.pendingTimeout = undefined; - this._continueUpload(); - }, this.sleepTime); - } - } - } - } - else { - this._oneShotUpload(); - } - } - _resolveToken(callback) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Promise.all([ - this._ref.storage._getAuthToken(), - this._ref.storage._getAppCheckToken() - ]).then(([authToken, appCheckToken]) => { - switch (this._state) { - case "running" /* InternalTaskState.RUNNING */: - callback(authToken, appCheckToken); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - } - }); - } - // TODO(andysoto): assert false - _createResumable() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = createRequest; - createRequest.getPromise().then((url) => { - this._request = undefined; - this._uploadUrl = url; - this._needToFetchStatus = false; - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _fetchStatus() { - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob); - const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = statusRequest; - statusRequest.getPromise().then(status => { - status = status; - this._request = undefined; - this._updateProgress(status.current); - this._needToFetchStatus = false; - if (status.finalized) { - this._needToFetchMetadata = true; - } - this.completeTransitions_(); - }, this._errorHandler); - }); - } - _continueUpload() { - const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - const status = new ResumableUploadStatus(this._transferred, this._blob.size()); - // TODO(andysoto): assert(this.uploadUrl_ !== null); - const url = this._uploadUrl; - this._resolveToken((authToken, appCheckToken) => { - let requestInfo; - try { - requestInfo = continueResumableUpload(this._ref._location, this._ref.storage, url, this._blob, chunkSize, this._mappings, status, this._makeProgressCallback()); - } - catch (e) { - this._error = e; - this._transition("error" /* InternalTaskState.ERROR */); - return; - } - const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken, - /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file. - ); - this._request = uploadRequest; - uploadRequest.getPromise().then((newStatus) => { - this._increaseMultiplier(); - this._request = undefined; - this._updateProgress(newStatus.current); - if (newStatus.finalized) { - this._metadata = newStatus.metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - } - else { - this.completeTransitions_(); - } - }, this._errorHandler); - }); - } - _increaseMultiplier() { - const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier; - // Max chunk size is 32M. - if (currentSize * 2 < 32 * 1024 * 1024) { - this._chunkMultiplier *= 2; - } - } - _fetchMetadata() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings); - const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = metadataRequest; - metadataRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._metadataErrorHandler); - }); - } - _oneShotUpload() { - this._resolveToken((authToken, appCheckToken) => { - const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata); - const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken); - this._request = multipartRequest; - multipartRequest.getPromise().then(metadata => { - this._request = undefined; - this._metadata = metadata; - this._updateProgress(this._blob.size()); - this._transition("success" /* InternalTaskState.SUCCESS */); - }, this._errorHandler); - }); - } - _updateProgress(transferred) { - const old = this._transferred; - this._transferred = transferred; - // A progress update can make the "transferred" value smaller (e.g. a - // partial upload not completed by server, after which the "transferred" - // value may reset to the value at the beginning of the request). - if (this._transferred !== old) { - this._notifyObservers(); - } - } - _transition(state) { - if (this._state === state) { - return; - } - switch (state) { - case "canceling" /* InternalTaskState.CANCELING */: - case "pausing" /* InternalTaskState.PAUSING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING); - this._state = state; - if (this._request !== undefined) { - this._request.cancel(); - } - else if (this.pendingTimeout) { - clearTimeout(this.pendingTimeout); - this.pendingTimeout = undefined; - this.completeTransitions_(); - } - break; - case "running" /* InternalTaskState.RUNNING */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.PAUSING); - const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */; - this._state = state; - if (wasPaused) { - this._notifyObservers(); - this._start(); - } - break; - case "paused" /* InternalTaskState.PAUSED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSING); - this._state = state; - this._notifyObservers(); - break; - case "canceled" /* InternalTaskState.CANCELED */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.PAUSED || - // this.state_ === InternalTaskState.CANCELING); - this._error = canceled(); - this._state = state; - this._notifyObservers(); - break; - case "error" /* InternalTaskState.ERROR */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - case "success" /* InternalTaskState.SUCCESS */: - // TODO(andysoto): - // assert(this.state_ === InternalTaskState.RUNNING || - // this.state_ === InternalTaskState.PAUSING || - // this.state_ === InternalTaskState.CANCELING); - this._state = state; - this._notifyObservers(); - break; - } - } - completeTransitions_() { - switch (this._state) { - case "pausing" /* InternalTaskState.PAUSING */: - this._transition("paused" /* InternalTaskState.PAUSED */); - break; - case "canceling" /* InternalTaskState.CANCELING */: - this._transition("canceled" /* InternalTaskState.CANCELED */); - break; - case "running" /* InternalTaskState.RUNNING */: - this._start(); - break; - } - } - /** - * A snapshot of the current task state. - */ - get snapshot() { - const externalState = taskStateFromInternalTaskState(this._state); - return { - bytesTransferred: this._transferred, - totalBytes: this._blob.size(), - state: externalState, - metadata: this._metadata, - task: this, - ref: this._ref - }; - } - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type, nextOrObserver, error, completed) { - // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string. - const observer = new Observer(nextOrObserver || undefined, error || undefined, completed || undefined); - this._addObserver(observer); - return () => { - this._removeObserver(observer); - }; - } - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled, onRejected) { - // These casts are needed so that TypeScript can infer the types of the - // resulting Promise. - return this._promise.then(onFulfilled, onRejected); - } - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected) { - return this.then(null, onRejected); - } - /** - * Adds the given observer. - */ - _addObserver(observer) { - this._observers.push(observer); - this._notifyObserver(observer); - } - /** - * Removes the given observer. - */ - _removeObserver(observer) { - const i = this._observers.indexOf(observer); - if (i !== -1) { - this._observers.splice(i, 1); - } - } - _notifyObservers() { - this._finishPromise(); - const observers = this._observers.slice(); - observers.forEach(observer => { - this._notifyObserver(observer); - }); - } - _finishPromise() { - if (this._resolve !== undefined) { - let triggered = true; - switch (taskStateFromInternalTaskState(this._state)) { - case TaskState.SUCCESS: - async(this._resolve.bind(null, this.snapshot))(); - break; - case TaskState.CANCELED: - case TaskState.ERROR: - const toCall = this._reject; - async(toCall.bind(null, this._error))(); - break; - default: - triggered = false; - break; - } - if (triggered) { - this._resolve = undefined; - this._reject = undefined; - } - } - } - _notifyObserver(observer) { - const externalState = taskStateFromInternalTaskState(this._state); - switch (externalState) { - case TaskState.RUNNING: - case TaskState.PAUSED: - if (observer.next) { - async(observer.next.bind(observer, this.snapshot))(); - } - break; - case TaskState.SUCCESS: - if (observer.complete) { - async(observer.complete.bind(observer))(); - } - break; - case TaskState.CANCELED: - case TaskState.ERROR: - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - break; - default: - // TODO(andysoto): assert(false); - if (observer.error) { - async(observer.error.bind(observer, this._error))(); - } - } - } - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume() { - const valid = this._state === "paused" /* InternalTaskState.PAUSED */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("running" /* InternalTaskState.RUNNING */); - } - return valid; - } - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */; - if (valid) { - this._transition("pausing" /* InternalTaskState.PAUSING */); - } - return valid; - } - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel() { - const valid = this._state === "running" /* InternalTaskState.RUNNING */ || - this._state === "pausing" /* InternalTaskState.PAUSING */; - if (valid) { - this._transition("canceling" /* InternalTaskState.CANCELING */); - } - return valid; - } -} - -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -class Reference { - constructor(_service, location) { - this._service = _service; - if (location instanceof Location) { - this._location = location; - } - else { - this._location = Location.makeFromUrl(location, _service.host); - } - } - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString() { - return 'gs://' + this._location.bucket + '/' + this._location.path; - } - _newRef(service, location) { - return new Reference(service, location); - } - /** - * A reference to the root of this object's bucket. - */ - get root() { - const location = new Location(this._location.bucket, ''); - return this._newRef(this._service, location); - } - /** - * The name of the bucket containing this reference's object. - */ - get bucket() { - return this._location.bucket; - } - /** - * The full path of this object. - */ - get fullPath() { - return this._location.path; - } - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name() { - return lastComponent(this._location.path); - } - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage() { - return this._service; - } - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent() { - const newPath = parent(this._location.path); - if (newPath === null) { - return null; - } - const location = new Location(this._location.bucket, newPath); - return new Reference(this._service, location); - } - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name) { - if (this._location.path === '') { - throw invalidRootOperation(name); - } - } -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -function getBytesInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getBytes'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - return ref.storage - .makeRequestWithTokens(requestInfo, newBytesConnection) - .then(bytes => maxDownloadSizeBytes !== undefined - ? // GCS may not honor the Range header for small files - bytes.slice(0, maxDownloadSizeBytes) - : bytes); -} -/** Stream the bytes at the object's location. */ -function getStreamInternal(ref, maxDownloadSizeBytes) { - ref._throwIfRoot('getStream'); - const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes); - // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result - const newMaxSizeTransform = (n) => { - let missingBytes = n; - return { - transform(chunk, controller) { - // GCS may not honor the Range header for small files - if (chunk.length < missingBytes) { - controller.enqueue(chunk); - missingBytes -= chunk.length; - } - else { - controller.enqueue(chunk.slice(0, missingBytes)); - controller.terminate(); - } - } - }; - }; - const result = maxDownloadSizeBytes !== undefined - ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes)) - : new TransformStream(); // The default transformer forwards all chunks to its readable side - ref.storage - .makeRequestWithTokens(requestInfo, newStreamConnection) - .then(readableStream => readableStream.pipeThrough(result)) - .catch(err => result.writable.abort(err)); - return result.readable; -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -function uploadBytes$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytes'); - const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(finalMetadata => { - return { - metadata: finalMetadata, - ref - }; - }); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -function uploadBytesResumable$1(ref, data, metadata) { - ref._throwIfRoot('uploadBytesResumable'); - return new UploadTask(ref, new FbsBlob(data), metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -function uploadString$1(ref, value, format = StringFormat.RAW, metadata) { - ref._throwIfRoot('uploadString'); - const data = dataFromString(format, value); - const metadataClone = { ...metadata }; - if (metadataClone['contentType'] == null && data.contentType != null) { - metadataClone['contentType'] = data.contentType; - } - return uploadBytes$1(ref, data.data, metadataClone); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll$1(ref) { - const accumulator = { - prefixes: [], - items: [] - }; - return listAllHelper(ref, accumulator).then(() => accumulator); -} -/** - * Separated from listAll because async functions can't use "arguments". - * @param ref - * @param accumulator - * @param pageToken - */ -async function listAllHelper(ref, accumulator, pageToken) { - const opt = { - // maxResults is 1000 by default. - pageToken - }; - const nextPage = await list$1(ref, opt); - accumulator.prefixes.push(...nextPage.prefixes); - accumulator.items.push(...nextPage.items); - if (nextPage.nextPageToken != null) { - await listAllHelper(ref, accumulator, nextPage.nextPageToken); - } -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list$1(ref, options) { - if (options != null) { - if (typeof options.maxResults === 'number') { - validateNumber('options.maxResults', - /* minValue= */ 1, - /* maxValue= */ 1000, options.maxResults); - } - } - const op = options || {}; - const requestInfo = list$2(ref.storage, ref._location, - /*delimiter= */ '/', op.pageToken, op.maxResults); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -function getMetadata$1(ref) { - ref._throwIfRoot('getMetadata'); - const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -function updateMetadata$1(ref, metadata) { - ref._throwIfRoot('updateMetadata'); - const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings()); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL$1(ref) { - ref._throwIfRoot('getDownloadURL'); - const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings()); - return ref.storage - .makeRequestWithTokens(requestInfo, newTextConnection) - .then(url => { - if (url === null) { - throw noDownloadURL(); - } - return url; - }); -} -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject$1(ref) { - ref._throwIfRoot('deleteObject'); - const requestInfo = deleteObject$2(ref.storage, ref._location); - return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection); -} -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -function _getChild$1(ref, childPath) { - const newPath = child(ref._location.path, childPath); - const location = new Location(ref._location.bucket, newPath); - return new Reference(ref.storage, location); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -function isUrl(path) { - return /^[A-Za-z]+:\/\//.test(path); -} -/** - * Returns a firebaseStorage.Reference for the given url. - */ -function refFromURL(service, url) { - return new Reference(service, url); -} -/** - * Returns a firebaseStorage.Reference for the given path in the default - * bucket. - */ -function refFromPath(ref, path) { - if (ref instanceof FirebaseStorageImpl) { - const service = ref; - if (service._bucket == null) { - throw noDefaultBucket(); - } - const reference = new Reference(service, service._bucket); - if (path != null) { - return refFromPath(reference, path); - } - else { - return reference; - } - } - else { - // ref is a Reference - if (path !== undefined) { - return _getChild$1(ref, path); - } - else { - return ref; - } - } -} -function ref$1(serviceOrRef, pathOrUrl) { - if (pathOrUrl && isUrl(pathOrUrl)) { - if (serviceOrRef instanceof FirebaseStorageImpl) { - return refFromURL(serviceOrRef, pathOrUrl); - } - else { - throw invalidArgument('To use ref(service, url), the first argument must be a Storage instance.'); - } - } - else { - return refFromPath(serviceOrRef, pathOrUrl); - } -} -function extractBucket(host, config) { - const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY]; - if (bucketString == null) { - return null; - } - return Location.makeFromBucketSpec(bucketString, host); -} -function connectStorageEmulator$1(storage, host, port, options = {}) { - storage.host = `${host}:${port}`; - const useSsl = isCloudWorkstation(host); - // Workaround to get cookies in Firebase Studio - if (useSsl) { - void pingServer(`https://${storage.host}/b`); - updateEmulatorBanner('Storage', true); - } - storage._isUsingEmulator = true; - storage._protocol = useSsl ? 'https' : 'http'; - const { mockUserToken } = options; - if (mockUserToken) { - storage._overrideAuthToken = - typeof mockUserToken === 'string' - ? mockUserToken - : createMockUserToken(mockUserToken, storage.app.options.projectId); - } -} -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -class FirebaseStorageImpl { - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app, _authProvider, - /** - * @internal - */ - _appCheckProvider, - /** - * @internal - */ - _url, _firebaseVersion, _isUsingEmulator = false) { - this.app = app; - this._authProvider = _authProvider; - this._appCheckProvider = _appCheckProvider; - this._url = _url; - this._firebaseVersion = _firebaseVersion; - this._isUsingEmulator = _isUsingEmulator; - this._bucket = null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - this._host = DEFAULT_HOST; - this._protocol = 'https'; - this._appId = null; - this._deleted = false; - this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME; - this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME; - this._requests = new Set(); - if (_url != null) { - this._bucket = Location.makeFromBucketSpec(_url, this._host); - } - else { - this._bucket = extractBucket(this._host, this.app.options); - } - } - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host() { - return this._host; - } - set host(host) { - this._host = host; - if (this._url != null) { - this._bucket = Location.makeFromBucketSpec(this._url, host); - } - else { - this._bucket = extractBucket(host, this.app.options); - } - } - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime() { - return this._maxUploadRetryTime; - } - set maxUploadRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxUploadRetryTime = time; - } - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime() { - return this._maxOperationRetryTime; - } - set maxOperationRetryTime(time) { - validateNumber('time', - /* minValue=*/ 0, - /* maxValue= */ Number.POSITIVE_INFINITY, time); - this._maxOperationRetryTime = time; - } - async _getAuthToken() { - if (this._overrideAuthToken) { - return this._overrideAuthToken; - } - const auth = this._authProvider.getImmediate({ optional: true }); - if (auth) { - const tokenData = await auth.getToken(); - if (tokenData !== null) { - return tokenData.accessToken; - } - } - return null; - } - async _getAppCheckToken() { - if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) { - return this.app.settings.appCheckToken; - } - const appCheck = this._appCheckProvider.getImmediate({ optional: true }); - if (appCheck) { - const result = await appCheck.getToken(); - // TODO: What do we want to do if there is an error getting the token? - // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be - // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use - // the token (actual or dummy) to send requests. - return result.token; - } - return null; - } - /** - * Stop running requests and prevent more from being created. - */ - _delete() { - if (!this._deleted) { - this._deleted = true; - this._requests.forEach(request => request.cancel()); - this._requests.clear(); - } - return Promise.resolve(); - } - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc) { - return new Reference(this, loc); - } - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) { - if (!this._deleted) { - const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator); - this._requests.add(request); - // Request removes itself from set when complete. - request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request)); - return request; - } - else { - return new FailRequest(appDeleted()); - } - } - async makeRequestWithTokens(requestInfo, requestFactory) { - const [authToken, appCheckToken] = await Promise.all([ - this._getAuthToken(), - this._getAppCheckToken() - ]); - return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise(); - } -} - -const name = "@firebase/storage"; -const version = "0.14.0"; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -const STORAGE_TYPE = 'storage'; - -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -function getBytes(ref, maxDownloadSizeBytes) { - ref = getModularInstance(ref); - return getBytesInternal(ref, maxDownloadSizeBytes); -} -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -function uploadBytes(ref, data, metadata) { - ref = getModularInstance(ref); - return uploadBytes$1(ref, data, metadata); -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -function uploadString(ref, value, format, metadata) { - ref = getModularInstance(ref); - return uploadString$1(ref, value, format, metadata); -} -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -function uploadBytesResumable(ref, data, metadata) { - ref = getModularInstance(ref); - return uploadBytesResumable$1(ref, data, metadata); -} -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -function getMetadata(ref) { - ref = getModularInstance(ref); - return getMetadata$1(ref); -} -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -function updateMetadata(ref, metadata) { - ref = getModularInstance(ref); - return updateMetadata$1(ref, metadata); -} -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -function list(ref, options) { - ref = getModularInstance(ref); - return list$1(ref, options); -} -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -function listAll(ref) { - ref = getModularInstance(ref); - return listAll$1(ref); -} -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -function getDownloadURL(ref) { - ref = getModularInstance(ref); - return getDownloadURL$1(ref); -} -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -function deleteObject(ref) { - ref = getModularInstance(ref); - return deleteObject$1(ref); -} -function ref(serviceOrRef, pathOrUrl) { - serviceOrRef = getModularInstance(serviceOrRef); - return ref$1(serviceOrRef, pathOrUrl); -} -/** - * @internal - */ -function _getChild(ref, childPath) { - return _getChild$1(ref, childPath); -} -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -function getStorage(app = getApp(), bucketUrl) { - app = getModularInstance(app); - const storageProvider = _getProvider(app, STORAGE_TYPE); - const storageInstance = storageProvider.getImmediate({ - identifier: bucketUrl - }); - const emulator = getDefaultEmulatorHostnameAndPort('storage'); - if (emulator) { - connectStorageEmulator(storageInstance, ...emulator); - } - return storageInstance; -} -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -function connectStorageEmulator(storage, host, port, options = {}) { - connectStorageEmulator$1(storage, host, port, options); -} - -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getBlob(ref, maxDownloadSizeBytes) { - throw new Error('getBlob() is only available in Browser-like environments'); -} -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -function getStream(ref, maxDownloadSizeBytes) { - ref = getModularInstance(ref); - return getStreamInternal(ref, maxDownloadSizeBytes); -} - -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -function factory(container, { instanceIdentifier: url }) { - const app = container.getProvider('app').getImmediate(); - const authProvider = container.getProvider('auth-internal'); - const appCheckProvider = container.getProvider('app-check-internal'); - return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION); -} -function registerStorage() { - _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); - registerVersion(name, version); -} -registerStorage(); - -export { StorageError, StorageErrorCode, StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString }; -//# sourceMappingURL=index.node.esm.js.map diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/index.node.esm.js.map b/frontend-old/node_modules/@firebase/storage/dist/node-esm/index.node.esm.js.map deleted file mode 100644 index 29cb657..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/index.node.esm.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.node.esm.js","sources":["../../src/implementation/constants.ts","../../src/implementation/error.ts","../../src/implementation/location.ts","../../src/implementation/failrequest.ts","../../src/implementation/backoff.ts","../../src/implementation/type.ts","../../src/implementation/url.ts","../../src/implementation/connection.ts","../../src/implementation/utils.ts","../../src/implementation/request.ts","../../src/implementation/fs.ts","../../src/platform/node/base64.ts","../../src/implementation/string.ts","../../src/implementation/blob.ts","../../src/implementation/json.ts","../../src/implementation/path.ts","../../src/implementation/metadata.ts","../../src/implementation/list.ts","../../src/implementation/requestinfo.ts","../../src/implementation/requests.ts","../../src/implementation/taskenums.ts","../../src/implementation/observer.ts","../../src/implementation/async.ts","../../src/platform/node/connection.ts","../../src/task.ts","../../src/reference.ts","../../src/service.ts","../../src/constants.ts","../../src/api.ts","../../src/api.node.ts","../../src/index.node.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Constants used in the Firebase Storage library.\n */\n\n/**\n * Domain name for firebase storage.\n */\nexport const DEFAULT_HOST = 'firebasestorage.googleapis.com';\n\n/**\n * The key in Firebase config json for the storage bucket.\n */\nexport const CONFIG_STORAGE_BUCKET_KEY = 'storageBucket';\n\n/**\n * 2 minutes\n *\n * The timeout for all operations except upload.\n */\nexport const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1000;\n\n/**\n * 10 minutes\n *\n * The timeout for upload.\n */\nexport const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1000;\n\n/**\n * 1 second\n */\nexport const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;\n\n/**\n * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported\n * enough for us to use it directly.\n */\nexport const MIN_SAFE_INTEGER = -9007199254740991;\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseError } from '@firebase/util';\n\nimport { CONFIG_STORAGE_BUCKET_KEY } from './constants';\n\n/**\n * An error returned by the Firebase Storage SDK.\n * @public\n */\nexport class StorageError extends FirebaseError {\n private readonly _baseMessage: string;\n /**\n * Stores custom error data unique to the `StorageError`.\n */\n customData: { serverResponse: string | null } = { serverResponse: null };\n\n /**\n * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and\n * added to the end of the message.\n * @param message - Error message.\n * @param status_ - Corresponding HTTP Status Code\n */\n constructor(code: StorageErrorCode, message: string, private status_ = 0) {\n super(\n prependCode(code),\n `Firebase Storage: ${message} (${prependCode(code)})`\n );\n this._baseMessage = this.message;\n // Without this, `instanceof StorageError`, in tests for example,\n // returns false.\n Object.setPrototypeOf(this, StorageError.prototype);\n }\n\n get status(): number {\n return this.status_;\n }\n\n set status(status: number) {\n this.status_ = status;\n }\n\n /**\n * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.\n */\n _codeEquals(code: StorageErrorCode): boolean {\n return prependCode(code) === this.code;\n }\n\n /**\n * Optional response message that was added by the server.\n */\n get serverResponse(): null | string {\n return this.customData.serverResponse;\n }\n\n set serverResponse(serverResponse: string | null) {\n this.customData.serverResponse = serverResponse;\n if (this.customData.serverResponse) {\n this.message = `${this._baseMessage}\\n${this.customData.serverResponse}`;\n } else {\n this.message = this._baseMessage;\n }\n }\n}\n\nexport const errors = {};\n\n/**\n * @public\n * Error codes that can be attached to `StorageError` objects.\n */\nexport enum StorageErrorCode {\n // Shared between all platforms\n UNKNOWN = 'unknown',\n OBJECT_NOT_FOUND = 'object-not-found',\n BUCKET_NOT_FOUND = 'bucket-not-found',\n PROJECT_NOT_FOUND = 'project-not-found',\n QUOTA_EXCEEDED = 'quota-exceeded',\n UNAUTHENTICATED = 'unauthenticated',\n UNAUTHORIZED = 'unauthorized',\n UNAUTHORIZED_APP = 'unauthorized-app',\n RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',\n INVALID_CHECKSUM = 'invalid-checksum',\n CANCELED = 'canceled',\n // JS specific\n INVALID_EVENT_NAME = 'invalid-event-name',\n INVALID_URL = 'invalid-url',\n INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',\n NO_DEFAULT_BUCKET = 'no-default-bucket',\n CANNOT_SLICE_BLOB = 'cannot-slice-blob',\n SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',\n NO_DOWNLOAD_URL = 'no-download-url',\n INVALID_ARGUMENT = 'invalid-argument',\n INVALID_ARGUMENT_COUNT = 'invalid-argument-count',\n APP_DELETED = 'app-deleted',\n INVALID_ROOT_OPERATION = 'invalid-root-operation',\n INVALID_FORMAT = 'invalid-format',\n INTERNAL_ERROR = 'internal-error',\n UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'\n}\n\nexport function prependCode(code: StorageErrorCode): string {\n return 'storage/' + code;\n}\n\nexport function unknown(): StorageError {\n const message =\n 'An unknown error occurred, please check the error payload for ' +\n 'server response.';\n return new StorageError(StorageErrorCode.UNKNOWN, message);\n}\n\nexport function objectNotFound(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.OBJECT_NOT_FOUND,\n \"Object '\" + path + \"' does not exist.\"\n );\n}\n\nexport function bucketNotFound(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.BUCKET_NOT_FOUND,\n \"Bucket '\" + bucket + \"' does not exist.\"\n );\n}\n\nexport function projectNotFound(project: string): StorageError {\n return new StorageError(\n StorageErrorCode.PROJECT_NOT_FOUND,\n \"Project '\" + project + \"' does not exist.\"\n );\n}\n\nexport function quotaExceeded(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.QUOTA_EXCEEDED,\n \"Quota for bucket '\" +\n bucket +\n \"' exceeded, please view quota on \" +\n 'https://firebase.google.com/pricing/.'\n );\n}\n\nexport function unauthenticated(): StorageError {\n const message =\n 'User is not authenticated, please authenticate using Firebase ' +\n 'Authentication and try again.';\n return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);\n}\n\nexport function unauthorizedApp(): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED_APP,\n 'This app does not have permission to access Firebase Storage on this project.'\n );\n}\n\nexport function unauthorized(path: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNAUTHORIZED,\n \"User does not have permission to access '\" + path + \"'.\"\n );\n}\n\nexport function retryLimitExceeded(): StorageError {\n return new StorageError(\n StorageErrorCode.RETRY_LIMIT_EXCEEDED,\n 'Max retry time for operation exceeded, please try again.'\n );\n}\n\nexport function invalidChecksum(\n path: string,\n checksum: string,\n calculated: string\n): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_CHECKSUM,\n \"Uploaded/downloaded object '\" +\n path +\n \"' has checksum '\" +\n checksum +\n \"' which does not match '\" +\n calculated +\n \"'. Please retry the upload/download.\"\n );\n}\n\nexport function canceled(): StorageError {\n return new StorageError(\n StorageErrorCode.CANCELED,\n 'User canceled the upload/download.'\n );\n}\n\nexport function invalidEventName(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_EVENT_NAME,\n \"Invalid event name '\" + name + \"'.\"\n );\n}\n\nexport function invalidUrl(url: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_URL,\n \"Invalid URL '\" + url + \"'.\"\n );\n}\n\nexport function invalidDefaultBucket(bucket: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_DEFAULT_BUCKET,\n \"Invalid default bucket '\" + bucket + \"'.\"\n );\n}\n\nexport function noDefaultBucket(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DEFAULT_BUCKET,\n 'No default bucket ' +\n \"found. Did you set the '\" +\n CONFIG_STORAGE_BUCKET_KEY +\n \"' property when initializing the app?\"\n );\n}\n\nexport function cannotSliceBlob(): StorageError {\n return new StorageError(\n StorageErrorCode.CANNOT_SLICE_BLOB,\n 'Cannot slice blob for upload. Please retry the upload.'\n );\n}\n\nexport function serverFileWrongSize(): StorageError {\n return new StorageError(\n StorageErrorCode.SERVER_FILE_WRONG_SIZE,\n 'Server recorded incorrect upload file size, please retry the upload.'\n );\n}\n\nexport function noDownloadURL(): StorageError {\n return new StorageError(\n StorageErrorCode.NO_DOWNLOAD_URL,\n 'The given file does not have any download URLs.'\n );\n}\n\nexport function missingPolyFill(polyFill: string): StorageError {\n return new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`\n );\n}\n\n/**\n * @internal\n */\nexport function invalidArgument(message: string): StorageError {\n return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);\n}\n\nexport function invalidArgumentCount(\n argMin: number,\n argMax: number,\n fnName: string,\n real: number\n): StorageError {\n let countPart;\n let plural;\n if (argMin === argMax) {\n countPart = argMin;\n plural = argMin === 1 ? 'argument' : 'arguments';\n } else {\n countPart = 'between ' + argMin + ' and ' + argMax;\n plural = 'arguments';\n }\n return new StorageError(\n StorageErrorCode.INVALID_ARGUMENT_COUNT,\n 'Invalid argument count in `' +\n fnName +\n '`: Expected ' +\n countPart +\n ' ' +\n plural +\n ', received ' +\n real +\n '.'\n );\n}\n\nexport function appDeleted(): StorageError {\n return new StorageError(\n StorageErrorCode.APP_DELETED,\n 'The Firebase app was deleted.'\n );\n}\n\n/**\n * @param name - The name of the operation that was invalid.\n *\n * @internal\n */\nexport function invalidRootOperation(name: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_ROOT_OPERATION,\n \"The operation '\" +\n name +\n \"' cannot be performed on a root reference, create a non-root \" +\n \"reference using child, such as .child('file.png').\"\n );\n}\n\n/**\n * @param format - The format that was not valid.\n * @param message - A message describing the format violation.\n */\nexport function invalidFormat(format: string, message: string): StorageError {\n return new StorageError(\n StorageErrorCode.INVALID_FORMAT,\n \"String does not match format '\" + format + \"': \" + message\n );\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function unsupportedEnvironment(message: string): StorageError {\n throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, message);\n}\n\n/**\n * @param message - A message describing the internal error.\n */\nexport function internalError(message: string): StorageError {\n throw new StorageError(\n StorageErrorCode.INTERNAL_ERROR,\n 'Internal error: ' + message\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functionality related to the parsing/composition of bucket/\n * object location.\n */\n\nimport { invalidDefaultBucket, invalidUrl } from './error';\nimport { DEFAULT_HOST } from './constants';\n\n/**\n * Firebase Storage location data.\n *\n * @internal\n */\nexport class Location {\n private path_: string;\n\n constructor(public readonly bucket: string, path: string) {\n this.path_ = path;\n }\n\n get path(): string {\n return this.path_;\n }\n\n get isRoot(): boolean {\n return this.path.length === 0;\n }\n\n fullServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o/' + encode(this.path);\n }\n\n bucketOnlyServerUrl(): string {\n const encode = encodeURIComponent;\n return '/b/' + encode(this.bucket) + '/o';\n }\n\n static makeFromBucketSpec(bucketString: string, host: string): Location {\n let bucketLocation;\n try {\n bucketLocation = Location.makeFromUrl(bucketString, host);\n } catch (e) {\n // Not valid URL, use as-is. This lets you put bare bucket names in\n // config.\n return new Location(bucketString, '');\n }\n if (bucketLocation.path === '') {\n return bucketLocation;\n } else {\n throw invalidDefaultBucket(bucketString);\n }\n }\n\n static makeFromUrl(url: string, host: string): Location {\n let location: Location | null = null;\n const bucketDomain = '([A-Za-z0-9.\\\\-_]+)';\n\n function gsModify(loc: Location): void {\n if (loc.path.charAt(loc.path.length - 1) === '/') {\n loc.path_ = loc.path_.slice(0, -1);\n }\n }\n const gsPath = '(/(.*))?$';\n const gsRegex = new RegExp('^gs://' + bucketDomain + gsPath, 'i');\n const gsIndices = { bucket: 1, path: 3 };\n\n function httpModify(loc: Location): void {\n loc.path_ = decodeURIComponent(loc.path);\n }\n const version = 'v[A-Za-z0-9_]+';\n const firebaseStorageHost = host.replace(/[.]/g, '\\\\.');\n const firebaseStoragePath = '(/([^?#]*).*)?$';\n const firebaseStorageRegExp = new RegExp(\n `^https?://${firebaseStorageHost}/${version}/b/${bucketDomain}/o${firebaseStoragePath}`,\n 'i'\n );\n const firebaseStorageIndices = { bucket: 1, path: 3 };\n\n const cloudStorageHost =\n host === DEFAULT_HOST\n ? '(?:storage.googleapis.com|storage.cloud.google.com)'\n : host;\n const cloudStoragePath = '([^?#]*)';\n const cloudStorageRegExp = new RegExp(\n `^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`,\n 'i'\n );\n const cloudStorageIndices = { bucket: 1, path: 2 };\n\n const groups = [\n { regex: gsRegex, indices: gsIndices, postModify: gsModify },\n {\n regex: firebaseStorageRegExp,\n indices: firebaseStorageIndices,\n postModify: httpModify\n },\n {\n regex: cloudStorageRegExp,\n indices: cloudStorageIndices,\n postModify: httpModify\n }\n ];\n for (let i = 0; i < groups.length; i++) {\n const group = groups[i];\n const captures = group.regex.exec(url);\n if (captures) {\n const bucketValue = captures[group.indices.bucket];\n let pathValue = captures[group.indices.path];\n if (!pathValue) {\n pathValue = '';\n }\n location = new Location(bucketValue, pathValue);\n group.postModify(location);\n break;\n }\n }\n if (location == null) {\n throw invalidUrl(url);\n }\n return location;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Request } from './request';\n\n/**\n * A request whose promise always fails.\n */\nexport class FailRequest<T> implements Request<T> {\n promise_: Promise<T>;\n\n constructor(error: StorageError) {\n this.promise_ = Promise.reject<T>(error);\n }\n\n /** @inheritDoc */\n getPromise(): Promise<T> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(_appDelete = false): void {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Provides a method for running a function with exponential\n * backoff.\n */\ntype id = (p1: boolean) => void;\n\nexport { id };\n\n/**\n * Accepts a callback for an action to perform (`doRequest`),\n * and then a callback for when the backoff has completed (`backoffCompleteCb`).\n * The callback sent to start requires an argument to call (`onRequestComplete`).\n * When `start` calls `doRequest`, it passes a callback for when the request has\n * completed, `onRequestComplete`. Based on this, the backoff continues, with\n * another call to `doRequest` and the above loop continues until the timeout\n * is hit, or a successful response occurs.\n * @description\n * @param doRequest Callback to perform request\n * @param backoffCompleteCb Callback to call when backoff has been completed\n */\nexport function start(\n doRequest: (\n onRequestComplete: (success: boolean) => void,\n canceled: boolean\n ) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n backoffCompleteCb: (...args: any[]) => unknown,\n timeout: number\n): id {\n // TODO(andysoto): make this code cleaner (probably refactor into an actual\n // type instead of a bunch of functions with state shared in the closure)\n let waitSeconds = 1;\n // Would type this as \"number\" but that doesn't work for Node so ¯\\_(ツ)_/¯\n // TODO: find a way to exclude Node type definition for storage because storage only works in browser\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let retryTimeoutId: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let globalTimeoutId: any = null;\n let hitTimeout = false;\n let cancelState = 0;\n\n function canceled(): boolean {\n return cancelState === 2;\n }\n let triggeredCallback = false;\n\n function triggerCallback(...args: any[]): void {\n if (!triggeredCallback) {\n triggeredCallback = true;\n backoffCompleteCb.apply(null, args);\n }\n }\n\n function callWithDelay(millis: number): void {\n retryTimeoutId = setTimeout(() => {\n retryTimeoutId = null;\n doRequest(responseHandler, canceled());\n }, millis);\n }\n\n function clearGlobalTimeout(): void {\n if (globalTimeoutId) {\n clearTimeout(globalTimeoutId);\n }\n }\n\n function responseHandler(success: boolean, ...args: any[]): void {\n if (triggeredCallback) {\n clearGlobalTimeout();\n return;\n }\n if (success) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n const mustStop = canceled() || hitTimeout;\n if (mustStop) {\n clearGlobalTimeout();\n triggerCallback.call(null, success, ...args);\n return;\n }\n if (waitSeconds < 64) {\n /* TODO(andysoto): don't back off so quickly if we know we're offline. */\n waitSeconds *= 2;\n }\n let waitMillis;\n if (cancelState === 1) {\n cancelState = 2;\n waitMillis = 0;\n } else {\n waitMillis = (waitSeconds + Math.random()) * 1000;\n }\n callWithDelay(waitMillis);\n }\n let stopped = false;\n\n function stop(wasTimeout: boolean): void {\n if (stopped) {\n return;\n }\n stopped = true;\n clearGlobalTimeout();\n if (triggeredCallback) {\n return;\n }\n if (retryTimeoutId !== null) {\n if (!wasTimeout) {\n cancelState = 2;\n }\n clearTimeout(retryTimeoutId);\n callWithDelay(0);\n } else {\n if (!wasTimeout) {\n cancelState = 1;\n }\n }\n }\n callWithDelay(0);\n globalTimeoutId = setTimeout(() => {\n hitTimeout = true;\n stop(true);\n }, timeout);\n return stop;\n}\n\n/**\n * Stops the retry loop from repeating.\n * If the function is currently \"in between\" retries, it is invoked immediately\n * with the second parameter as \"true\". Otherwise, it will be invoked once more\n * after the current invocation finishes iff the current invocation would have\n * triggered another retry.\n */\nexport function stop(id: id): void {\n id(false);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { invalidArgument } from './error';\n\nexport function isJustDef<T>(p: T | null | undefined): p is T | null {\n return p !== void 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isFunction(p: unknown): p is Function {\n return typeof p === 'function';\n}\n\nexport function isNonArrayObject(p: unknown): boolean {\n return typeof p === 'object' && !Array.isArray(p);\n}\n\nexport function isString(p: unknown): p is string {\n return typeof p === 'string' || p instanceof String;\n}\n\nexport function isNativeBlob(p: unknown): p is Blob {\n return isNativeBlobDefined() && p instanceof Blob;\n}\n\nexport function isNativeBlobDefined(): boolean {\n return typeof Blob !== 'undefined';\n}\n\nexport function validateNumber(\n argument: string,\n minValue: number,\n maxValue: number,\n value: number\n): void {\n if (value < minValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${minValue} or greater.`\n );\n }\n if (value > maxValue) {\n throw invalidArgument(\n `Invalid value for '${argument}'. Expected ${maxValue} or less.`\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Functions to create and manipulate URLs for the server API.\n */\nimport { UrlParams } from './requestinfo';\n\nexport function makeUrl(\n urlPart: string,\n host: string,\n protocol: string\n): string {\n let origin = host;\n if (protocol == null) {\n origin = `https://${host}`;\n }\n return `${protocol}://${origin}/v0${urlPart}`;\n}\n\nexport function makeQueryString(params: UrlParams): string {\n const encode = encodeURIComponent;\n let queryPart = '?';\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const nextPart = encode(key) + '=' + encode(params[key]);\n queryPart = queryPart + nextPart + '&';\n }\n }\n\n // Chop off the extra '&' or '?' on the end\n queryPart = queryPart.slice(0, -1);\n return queryPart;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Network headers */\nexport type Headers = Record<string, string>;\n\n/** Response type exposed by the networking APIs. */\nexport type ConnectionType =\n | string\n | ArrayBuffer\n | Blob\n | ReadableStream<Uint8Array>;\n\n/**\n * A lightweight wrapper around XMLHttpRequest with a\n * goog.net.XhrIo-like interface.\n *\n * You can create a new connection by invoking `newTextConnection()`,\n * `newBytesConnection()` or `newStreamConnection()`.\n */\nexport interface Connection<T extends ConnectionType> {\n /**\n * Sends a request to the provided URL.\n *\n * This method never rejects its promise. In case of encountering an error,\n * it sets an error code internally which can be accessed by calling\n * getErrorCode() by callers.\n */\n send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: ArrayBufferView | Blob | string | null,\n headers?: Headers\n ): Promise<void>;\n\n getErrorCode(): ErrorCode;\n\n getStatus(): number;\n\n getResponse(): T;\n\n getErrorText(): string;\n\n /**\n * Abort the request.\n */\n abort(): void;\n\n getResponseHeader(header: string): string | null;\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;\n}\n\n/**\n * Error codes for requests made by the XhrIo wrapper.\n */\nexport enum ErrorCode {\n NO_ERROR = 0,\n NETWORK_ERROR = 1,\n ABORT = 2\n}\n","/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Checks the status code to see if the action should be retried.\n *\n * @param status Current HTTP status code returned by server.\n * @param additionalRetryCodes additional retry codes to check against\n */\nexport function isRetryStatusCode(\n status: number,\n additionalRetryCodes: number[]\n): boolean {\n // The codes for which to retry came from this page:\n // https://cloud.google.com/storage/docs/exponential-backoff\n const isFiveHundredCode = status >= 500 && status < 600;\n const extraRetryCodes = [\n // Request Timeout: web server didn't receive full request in time.\n 408,\n // Too Many Requests: you're getting rate-limited, basically.\n 429\n ];\n const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;\n const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;\n return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods used to actually send HTTP requests from\n * abstract representations.\n */\n\nimport { id as backoffId, start, stop } from './backoff';\nimport { appDeleted, canceled, retryLimitExceeded, unknown } from './error';\nimport { ErrorHandler, RequestHandler, RequestInfo } from './requestinfo';\nimport { isJustDef } from './type';\nimport { makeQueryString } from './url';\nimport { Connection, ErrorCode, Headers, ConnectionType } from './connection';\nimport { isRetryStatusCode } from './utils';\n\nexport interface Request<T> {\n getPromise(): Promise<T>;\n\n /**\n * Cancels the request. IMPORTANT: the promise may still be resolved with an\n * appropriate value (if the request is finished before you call this method,\n * but the promise has not yet been resolved), so don't just assume it will be\n * rejected if you call this function.\n * @param appDelete - True if the cancelation came from the app being deleted.\n */\n cancel(appDelete?: boolean): void;\n}\n\n/**\n * Handles network logic for all Storage Requests, including error reporting and\n * retries with backoff.\n *\n * @param I - the type of the backend's network response.\n * @param - O the output type used by the rest of the SDK. The conversion\n * happens in the specified `callback_`.\n */\nclass NetworkRequest<I extends ConnectionType, O> implements Request<O> {\n private pendingConnection_: Connection<I> | null = null;\n private backoffId_: backoffId | null = null;\n private resolve_!: (value?: O | PromiseLike<O>) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private reject_!: (reason?: any) => void;\n private canceled_: boolean = false;\n private appDelete_: boolean = false;\n private promise_: Promise<O>;\n\n constructor(\n private url_: string,\n private method_: string,\n private headers_: Headers,\n private body_: string | Blob | Uint8Array | null,\n private successCodes_: number[],\n private additionalRetryCodes_: number[],\n private callback_: RequestHandler<I, O>,\n private errorCallback_: ErrorHandler | null,\n private timeout_: number,\n private progressCallback_: ((p1: number, p2: number) => void) | null,\n private connectionFactory_: () => Connection<I>,\n private retry = true,\n private isUsingEmulator = false\n ) {\n this.promise_ = new Promise((resolve, reject) => {\n this.resolve_ = resolve as (value?: O | PromiseLike<O>) => void;\n this.reject_ = reject;\n this.start_();\n });\n }\n\n /**\n * Actually starts the retry loop.\n */\n private start_(): void {\n const doTheRequest: (\n backoffCallback: (success: boolean, ...p2: unknown[]) => void,\n canceled: boolean\n ) => void = (backoffCallback, canceled) => {\n if (canceled) {\n backoffCallback(false, new RequestEndStatus(false, null, true));\n return;\n }\n const connection = this.connectionFactory_();\n this.pendingConnection_ = connection;\n\n const progressListener: (\n progressEvent: ProgressEvent\n ) => void = progressEvent => {\n const loaded = progressEvent.loaded;\n const total = progressEvent.lengthComputable ? progressEvent.total : -1;\n if (this.progressCallback_ !== null) {\n this.progressCallback_(loaded, total);\n }\n };\n if (this.progressCallback_ !== null) {\n connection.addUploadProgressListener(progressListener);\n }\n\n // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n connection\n .send(\n this.url_,\n this.method_,\n this.isUsingEmulator,\n this.body_,\n this.headers_\n )\n .then(() => {\n if (this.progressCallback_ !== null) {\n connection.removeUploadProgressListener(progressListener);\n }\n this.pendingConnection_ = null;\n const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;\n const status = connection.getStatus();\n if (\n !hitServer ||\n (isRetryStatusCode(status, this.additionalRetryCodes_) &&\n this.retry)\n ) {\n const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;\n backoffCallback(\n false,\n new RequestEndStatus(false, null, wasCanceled)\n );\n return;\n }\n const successCode = this.successCodes_.indexOf(status) !== -1;\n backoffCallback(true, new RequestEndStatus(successCode, connection));\n });\n };\n\n /**\n * @param requestWentThrough - True if the request eventually went\n * through, false if it hit the retry limit or was canceled.\n */\n const backoffDone: (\n requestWentThrough: boolean,\n status: RequestEndStatus<I>\n ) => void = (requestWentThrough, status) => {\n const resolve = this.resolve_;\n const reject = this.reject_;\n const connection = status.connection as Connection<I>;\n if (status.wasSuccessCode) {\n try {\n const result = this.callback_(connection, connection.getResponse());\n if (isJustDef(result)) {\n resolve(result);\n } else {\n resolve();\n }\n } catch (e) {\n reject(e);\n }\n } else {\n if (connection !== null) {\n const err = unknown();\n err.serverResponse = connection.getErrorText();\n if (this.errorCallback_) {\n reject(this.errorCallback_(connection, err));\n } else {\n reject(err);\n }\n } else {\n if (status.canceled) {\n const err = this.appDelete_ ? appDeleted() : canceled();\n reject(err);\n } else {\n const err = retryLimitExceeded();\n reject(err);\n }\n }\n }\n };\n if (this.canceled_) {\n backoffDone(false, new RequestEndStatus(false, null, true));\n } else {\n this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);\n }\n }\n\n /** @inheritDoc */\n getPromise(): Promise<O> {\n return this.promise_;\n }\n\n /** @inheritDoc */\n cancel(appDelete?: boolean): void {\n this.canceled_ = true;\n this.appDelete_ = appDelete || false;\n if (this.backoffId_ !== null) {\n stop(this.backoffId_);\n }\n if (this.pendingConnection_ !== null) {\n this.pendingConnection_.abort();\n }\n }\n}\n\n/**\n * A collection of information about the result of a network request.\n * @param opt_canceled - Defaults to false.\n */\nexport class RequestEndStatus<I extends ConnectionType> {\n /**\n * True if the request was canceled.\n */\n canceled: boolean;\n\n constructor(\n public wasSuccessCode: boolean,\n public connection: Connection<I> | null,\n canceled?: boolean\n ) {\n this.canceled = !!canceled;\n }\n}\n\nexport function addAuthHeader_(\n headers: Headers,\n authToken: string | null\n): void {\n if (authToken !== null && authToken.length > 0) {\n headers['Authorization'] = 'Firebase ' + authToken;\n }\n}\n\nexport function addVersionHeader_(\n headers: Headers,\n firebaseVersion?: string\n): void {\n headers['X-Firebase-Storage-Version'] =\n 'webjs/' + (firebaseVersion ?? 'AppManager');\n}\n\nexport function addGmpidHeader_(headers: Headers, appId: string | null): void {\n if (appId) {\n headers['X-Firebase-GMPID'] = appId;\n }\n}\n\nexport function addAppCheckHeader_(\n headers: Headers,\n appCheckToken: string | null\n): void {\n if (appCheckToken !== null) {\n headers['X-Firebase-AppCheck'] = appCheckToken;\n }\n}\n\nexport function makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n appId: string | null,\n authToken: string | null,\n appCheckToken: string | null,\n requestFactory: () => Connection<I>,\n firebaseVersion?: string,\n retry = true,\n isUsingEmulator = false\n): Request<O> {\n const queryPart = makeQueryString(requestInfo.urlParams);\n const url = requestInfo.url + queryPart;\n const headers = Object.assign({}, requestInfo.headers);\n addGmpidHeader_(headers, appId);\n addAuthHeader_(headers, authToken);\n addVersionHeader_(headers, firebaseVersion);\n addAppCheckHeader_(headers, appCheckToken);\n return new NetworkRequest<I, O>(\n url,\n requestInfo.method,\n headers,\n requestInfo.body,\n requestInfo.successCodes,\n requestInfo.additionalRetryCodes,\n requestInfo.handler,\n requestInfo.errorHandler,\n requestInfo.timeout,\n requestInfo.progressCallback,\n requestFactory,\n retry,\n isUsingEmulator\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Some methods copied from goog.fs.\n * We don't include goog.fs because it pulls in a bunch of Deferred code that\n * bloats the size of the released binary.\n */\nimport { isNativeBlobDefined } from './type';\nimport { StorageErrorCode, StorageError } from './error';\n\nfunction getBlobBuilder(): typeof IBlobBuilder | undefined {\n if (typeof BlobBuilder !== 'undefined') {\n return BlobBuilder;\n } else if (typeof WebKitBlobBuilder !== 'undefined') {\n return WebKitBlobBuilder;\n } else {\n return undefined;\n }\n}\n\n/**\n * Concatenates one or more values together and converts them to a Blob.\n *\n * @param args The values that will make up the resulting blob.\n * @return The blob.\n */\nexport function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob {\n const BlobBuilder = getBlobBuilder();\n if (BlobBuilder !== undefined) {\n const bb = new BlobBuilder();\n for (let i = 0; i < args.length; i++) {\n bb.append(args[i]);\n }\n return bb.getBlob();\n } else {\n if (isNativeBlobDefined()) {\n return new Blob(args);\n } else {\n throw new StorageError(\n StorageErrorCode.UNSUPPORTED_ENVIRONMENT,\n \"This browser doesn't seem to support creating Blobs\"\n );\n }\n }\n}\n\n/**\n * Slices the blob. The returned blob contains data from the start byte\n * (inclusive) till the end byte (exclusive). Negative indices cannot be used.\n *\n * @param blob The blob to be sliced.\n * @param start Index of the starting byte.\n * @param end Index of the ending byte.\n * @return The blob slice or null if not supported.\n */\nexport function sliceBlob(blob: Blob, start: number, end: number): Blob | null {\n if (blob.webkitSlice) {\n return blob.webkitSlice(start, end);\n } else if (blob.mozSlice) {\n return blob.mozSlice(start, end);\n } else if (blob.slice) {\n return blob.slice(start, end);\n }\n return null;\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TextDecoder } from 'util';\nimport { invalidFormat } from '../../implementation/error';\n\n/** Converts a Base64 encoded string to a binary string. */\nexport function decodeBase64(encoded: string): string {\n // Node actually doesn't validate base64 strings.\n // A quick sanity check that is not a fool-proof validation\n if (/[^-A-Za-z0-9+/=]/.test(encoded)) {\n throw invalidFormat('base64', 'Invalid character found');\n }\n return Buffer.from(encoded, 'base64').toString('binary');\n}\n\nexport function decodeUint8Array(data: Uint8Array): string {\n return new TextDecoder().decode(data);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unknown, invalidFormat } from './error';\nimport { decodeBase64 } from '../platform/base64';\n\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];\n/**\n * An enumeration of the possible string formats for upload.\n * @public\n */\nexport const StringFormat = {\n /**\n * Indicates the string should be interpreted \"raw\", that is, as normal text.\n * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte\n * sequence.\n * Example: The string 'Hello! \\\\ud83d\\\\ude0a' becomes the byte sequence\n * 48 65 6c 6c 6f 21 20 f0 9f 98 8a\n */\n RAW: 'raw',\n /**\n * Indicates the string should be interpreted as base64-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64: 'base64',\n /**\n * Indicates the string should be interpreted as base64url-encoded data.\n * Padding characters (trailing '='s) are optional.\n * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence\n * ad 69 8e fb e1 3a b7 bf eb 97\n */\n BASE64URL: 'base64url',\n /**\n * Indicates the string is a data URL, such as one obtained from\n * canvas.toDataURL().\n * Example: the string 'data:application/octet-stream;base64,aaaa'\n * becomes the byte sequence\n * 69 a6 9a\n * (the content-type \"application/octet-stream\" is also applied, but can\n * be overridden in the metadata object).\n */\n DATA_URL: 'data_url'\n} as const;\n\nexport class StringData {\n contentType: string | null;\n\n constructor(public data: Uint8Array, contentType?: string | null) {\n this.contentType = contentType || null;\n }\n}\n\n/**\n * @internal\n */\nexport function dataFromString(\n format: StringFormat,\n stringData: string\n): StringData {\n switch (format) {\n case StringFormat.RAW:\n return new StringData(utf8Bytes_(stringData));\n case StringFormat.BASE64:\n case StringFormat.BASE64URL:\n return new StringData(base64Bytes_(format, stringData));\n case StringFormat.DATA_URL:\n return new StringData(\n dataURLBytes_(stringData),\n dataURLContentType_(stringData)\n );\n default:\n // do nothing\n }\n\n // assert(false);\n throw unknown();\n}\n\nexport function utf8Bytes_(value: string): Uint8Array {\n const b: number[] = [];\n for (let i = 0; i < value.length; i++) {\n let c = value.charCodeAt(i);\n if (c <= 127) {\n b.push(c);\n } else {\n if (c <= 2047) {\n b.push(192 | (c >> 6), 128 | (c & 63));\n } else {\n if ((c & 64512) === 55296) {\n // The start of a surrogate pair.\n const valid =\n i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;\n if (!valid) {\n // The second surrogate wasn't there.\n b.push(239, 191, 189);\n } else {\n const hi = c;\n const lo = value.charCodeAt(++i);\n c = 65536 | ((hi & 1023) << 10) | (lo & 1023);\n b.push(\n 240 | (c >> 18),\n 128 | ((c >> 12) & 63),\n 128 | ((c >> 6) & 63),\n 128 | (c & 63)\n );\n }\n } else {\n if ((c & 64512) === 56320) {\n // Invalid low surrogate.\n b.push(239, 191, 189);\n } else {\n b.push(224 | (c >> 12), 128 | ((c >> 6) & 63), 128 | (c & 63));\n }\n }\n }\n }\n }\n return new Uint8Array(b);\n}\n\nexport function percentEncodedBytes_(value: string): Uint8Array {\n let decoded;\n try {\n decoded = decodeURIComponent(value);\n } catch (e) {\n throw invalidFormat(StringFormat.DATA_URL, 'Malformed data URL.');\n }\n return utf8Bytes_(decoded);\n}\n\nexport function base64Bytes_(format: StringFormat, value: string): Uint8Array {\n switch (format) {\n case StringFormat.BASE64: {\n const hasMinus = value.indexOf('-') !== -1;\n const hasUnder = value.indexOf('_') !== -1;\n if (hasMinus || hasUnder) {\n const invalidChar = hasMinus ? '-' : '_';\n throw invalidFormat(\n format,\n \"Invalid character '\" +\n invalidChar +\n \"' found: is it base64url encoded?\"\n );\n }\n break;\n }\n case StringFormat.BASE64URL: {\n const hasPlus = value.indexOf('+') !== -1;\n const hasSlash = value.indexOf('/') !== -1;\n if (hasPlus || hasSlash) {\n const invalidChar = hasPlus ? '+' : '/';\n throw invalidFormat(\n format,\n \"Invalid character '\" + invalidChar + \"' found: is it base64 encoded?\"\n );\n }\n value = value.replace(/-/g, '+').replace(/_/g, '/');\n break;\n }\n default:\n // do nothing\n }\n let bytes;\n try {\n bytes = decodeBase64(value);\n } catch (e) {\n if ((e as Error).message.includes('polyfill')) {\n throw e;\n }\n throw invalidFormat(format, 'Invalid character found');\n }\n const array = new Uint8Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n array[i] = bytes.charCodeAt(i);\n }\n return array;\n}\n\nclass DataURLParts {\n base64: boolean = false;\n contentType: string | null = null;\n rest: string;\n\n constructor(dataURL: string) {\n const matches = dataURL.match(/^data:([^,]+)?,/);\n if (matches === null) {\n throw invalidFormat(\n StringFormat.DATA_URL,\n \"Must be formatted 'data:[<mediatype>][;base64],<data>\"\n );\n }\n const middle = matches[1] || null;\n if (middle != null) {\n this.base64 = endsWith(middle, ';base64');\n this.contentType = this.base64\n ? middle.substring(0, middle.length - ';base64'.length)\n : middle;\n }\n this.rest = dataURL.substring(dataURL.indexOf(',') + 1);\n }\n}\n\nexport function dataURLBytes_(dataUrl: string): Uint8Array {\n const parts = new DataURLParts(dataUrl);\n if (parts.base64) {\n return base64Bytes_(StringFormat.BASE64, parts.rest);\n } else {\n return percentEncodedBytes_(parts.rest);\n }\n}\n\nexport function dataURLContentType_(dataUrl: string): string | null {\n const parts = new DataURLParts(dataUrl);\n return parts.contentType;\n}\n\nfunction endsWith(s: string, end: string): boolean {\n const longEnough = s.length >= end.length;\n if (!longEnough) {\n return false;\n }\n\n return s.substring(s.length - end.length) === end;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Provides a Blob-like wrapper for various binary types (including the\n * native Blob type). This makes it possible to upload types like ArrayBuffers,\n * making uploads possible in environments without the native Blob type.\n */\nimport { sliceBlob, getBlob } from './fs';\nimport { StringFormat, dataFromString } from './string';\nimport { isNativeBlob, isNativeBlobDefined, isString } from './type';\n\n/**\n * @param opt_elideCopy - If true, doesn't copy mutable input data\n * (e.g. Uint8Arrays). Pass true only if you know the objects will not be\n * modified after this blob's construction.\n *\n * @internal\n */\nexport class FbsBlob {\n private data_!: Blob | Uint8Array;\n private size_: number;\n private type_: string;\n\n constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean) {\n let size: number = 0;\n let blobType: string = '';\n if (isNativeBlob(data)) {\n this.data_ = data as Blob;\n size = (data as Blob).size;\n blobType = (data as Blob).type;\n } else if (data instanceof ArrayBuffer) {\n if (elideCopy) {\n this.data_ = new Uint8Array(data);\n } else {\n this.data_ = new Uint8Array(data.byteLength);\n this.data_.set(new Uint8Array(data));\n }\n size = this.data_.length;\n } else if (data instanceof Uint8Array) {\n if (elideCopy) {\n this.data_ = data as Uint8Array;\n } else {\n this.data_ = new Uint8Array(data.length);\n this.data_.set(data as Uint8Array);\n }\n size = data.length;\n }\n this.size_ = size;\n this.type_ = blobType;\n }\n\n size(): number {\n return this.size_;\n }\n\n type(): string {\n return this.type_;\n }\n\n slice(startByte: number, endByte: number): FbsBlob | null {\n if (isNativeBlob(this.data_)) {\n const realBlob = this.data_ as Blob;\n const sliced = sliceBlob(realBlob, startByte, endByte);\n if (sliced === null) {\n return null;\n }\n return new FbsBlob(sliced);\n } else {\n const slice = new Uint8Array(\n (this.data_ as Uint8Array).buffer,\n startByte,\n endByte - startByte\n );\n return new FbsBlob(slice, true);\n }\n }\n\n static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null {\n if (isNativeBlobDefined()) {\n const blobby: Array<Blob | Uint8Array | string> = args.map(\n (val: string | FbsBlob): Blob | Uint8Array | string => {\n if (val instanceof FbsBlob) {\n return val.data_;\n } else {\n return val;\n }\n }\n );\n return new FbsBlob(getBlob.apply(null, blobby));\n } else {\n const uint8Arrays: Uint8Array[] = args.map(\n (val: string | FbsBlob): Uint8Array => {\n if (isString(val)) {\n return dataFromString(StringFormat.RAW, val as string).data;\n } else {\n // Blobs don't exist, so this has to be a Uint8Array.\n return (val as FbsBlob).data_ as Uint8Array;\n }\n }\n );\n let finalLength = 0;\n uint8Arrays.forEach((array: Uint8Array): void => {\n finalLength += array.byteLength;\n });\n const merged = new Uint8Array(finalLength);\n let index = 0;\n uint8Arrays.forEach((array: Uint8Array) => {\n for (let i = 0; i < array.length; i++) {\n merged[index++] = array[i];\n }\n });\n return new FbsBlob(merged, true);\n }\n }\n\n uploadData(): Blob | Uint8Array {\n return this.data_;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isNonArrayObject } from './type';\n\n/**\n * Returns the Object resulting from parsing the given JSON, or null if the\n * given string does not represent a JSON object.\n */\nexport function jsonObjectOrNull(\n s: string\n): { [name: string]: unknown } | null {\n let obj;\n try {\n obj = JSON.parse(s);\n } catch (e) {\n return null;\n }\n if (isNonArrayObject(obj)) {\n return obj;\n } else {\n return null;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Contains helper methods for manipulating paths.\n */\n\n/**\n * @return Null if the path is already at the root.\n */\nexport function parent(path: string): string | null {\n if (path.length === 0) {\n return null;\n }\n const index = path.lastIndexOf('/');\n if (index === -1) {\n return '';\n }\n const newPath = path.slice(0, index);\n return newPath;\n}\n\nexport function child(path: string, childPath: string): string {\n const canonicalChildPath = childPath\n .split('/')\n .filter(component => component.length > 0)\n .join('/');\n if (path.length === 0) {\n return canonicalChildPath;\n } else {\n return path + '/' + canonicalChildPath;\n }\n}\n\n/**\n * Returns the last component of a path.\n * '/foo/bar' -> 'bar'\n * '/foo/bar/baz/' -> 'baz/'\n * '/a' -> 'a'\n */\nexport function lastComponent(path: string): string {\n const index = path.lastIndexOf('/', path.length - 2);\n if (index === -1) {\n return path;\n } else {\n return path.slice(index + 1);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the metadata format\n */\nimport { Metadata } from '../metadata';\n\nimport { jsonObjectOrNull } from './json';\nimport { Location } from './location';\nimport { lastComponent } from './path';\nimport { isString } from './type';\nimport { makeUrl, makeQueryString } from './url';\nimport { Reference } from '../reference';\nimport { FirebaseStorageImpl } from '../service';\n\nexport function noXform_<T>(metadata: Metadata, value: T): T {\n return value;\n}\n\nclass Mapping<T> {\n local: string;\n writable: boolean;\n xform: (p1: Metadata, p2?: T) => T | undefined;\n\n constructor(\n public server: string,\n local?: string | null,\n writable?: boolean,\n xform?: ((p1: Metadata, p2?: T) => T | undefined) | null\n ) {\n this.local = local || server;\n this.writable = !!writable;\n this.xform = xform || noXform_;\n }\n}\ntype Mappings = Array<Mapping<string> | Mapping<number>>;\n\nexport { Mappings };\n\nlet mappings_: Mappings | null = null;\n\nexport function xformPath(fullPath: string | undefined): string | undefined {\n if (!isString(fullPath) || fullPath.length < 2) {\n return fullPath;\n } else {\n return lastComponent(fullPath);\n }\n}\n\nexport function getMappings(): Mappings {\n if (mappings_) {\n return mappings_;\n }\n const mappings: Mappings = [];\n mappings.push(new Mapping<string>('bucket'));\n mappings.push(new Mapping<string>('generation'));\n mappings.push(new Mapping<string>('metageneration'));\n mappings.push(new Mapping<string>('name', 'fullPath', true));\n\n function mappingsXformPath(\n _metadata: Metadata,\n fullPath: string | undefined\n ): string | undefined {\n return xformPath(fullPath);\n }\n const nameMapping = new Mapping<string>('name');\n nameMapping.xform = mappingsXformPath;\n mappings.push(nameMapping);\n\n /**\n * Coerces the second param to a number, if it is defined.\n */\n function xformSize(\n _metadata: Metadata,\n size?: number | string\n ): number | undefined {\n if (size !== undefined) {\n return Number(size);\n } else {\n return size;\n }\n }\n const sizeMapping = new Mapping<number>('size');\n sizeMapping.xform = xformSize;\n mappings.push(sizeMapping);\n mappings.push(new Mapping<number>('timeCreated'));\n mappings.push(new Mapping<string>('updated'));\n mappings.push(new Mapping<string>('md5Hash', null, true));\n mappings.push(new Mapping<string>('cacheControl', null, true));\n mappings.push(new Mapping<string>('contentDisposition', null, true));\n mappings.push(new Mapping<string>('contentEncoding', null, true));\n mappings.push(new Mapping<string>('contentLanguage', null, true));\n mappings.push(new Mapping<string>('contentType', null, true));\n mappings.push(new Mapping<string>('metadata', 'customMetadata', true));\n mappings_ = mappings;\n return mappings_;\n}\n\nexport function addRef(metadata: Metadata, service: FirebaseStorageImpl): void {\n function generateRef(): Reference {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const loc = new Location(bucket, path);\n return service._makeStorageReference(loc);\n }\n Object.defineProperty(metadata, 'ref', { get: generateRef });\n}\n\nexport function fromResource(\n service: FirebaseStorageImpl,\n resource: { [name: string]: unknown },\n mappings: Mappings\n): Metadata {\n const metadata: Metadata = {} as Metadata;\n metadata['type'] = 'file';\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n metadata[mapping.local] = (mapping as Mapping<unknown>).xform(\n metadata,\n resource[mapping.server]\n );\n }\n addRef(metadata, service);\n return metadata;\n}\n\nexport function fromResourceString(\n service: FirebaseStorageImpl,\n resourceString: string,\n mappings: Mappings\n): Metadata | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as Metadata;\n return fromResource(service, resource, mappings);\n}\n\nexport function downloadUrlFromResourceString(\n metadata: Metadata,\n resourceString: string,\n host: string,\n protocol: string\n): string | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n if (!isString(obj['downloadTokens'])) {\n // This can happen if objects are uploaded through GCS and retrieved\n // through list, so we don't want to throw an Error.\n return null;\n }\n const tokens: string = obj['downloadTokens'] as string;\n if (tokens.length === 0) {\n return null;\n }\n const encode = encodeURIComponent;\n const tokensList = tokens.split(',');\n const urls = tokensList.map((token: string): string => {\n const bucket: string = metadata['bucket'] as string;\n const path: string = metadata['fullPath'] as string;\n const urlPart = '/b/' + encode(bucket) + '/o/' + encode(path);\n const base = makeUrl(urlPart, host, protocol);\n const queryString = makeQueryString({\n alt: 'media',\n token\n });\n return base + queryString;\n });\n return urls[0];\n}\n\nexport function toResourceString(\n metadata: Partial<Metadata>,\n mappings: Mappings\n): string {\n const resource: {\n [prop: string]: unknown;\n } = {};\n const len = mappings.length;\n for (let i = 0; i < len; i++) {\n const mapping = mappings[i];\n if (mapping.writable) {\n resource[mapping.server] = metadata[mapping.local];\n }\n }\n return JSON.stringify(resource);\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Documentation for the listOptions and listResult format\n */\nimport { Location } from './location';\nimport { jsonObjectOrNull } from './json';\nimport { ListResult } from '../list';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Represents the simplified object metadata returned by List API.\n * Other fields are filtered because list in Firebase Rules does not grant\n * the permission to read the metadata.\n */\ninterface ListMetadataResponse {\n name: string;\n bucket: string;\n}\n\n/**\n * Represents the JSON response of List API.\n */\ninterface ListResultResponse {\n prefixes: string[];\n items: ListMetadataResponse[];\n nextPageToken?: string;\n}\n\nconst PREFIXES_KEY = 'prefixes';\nconst ITEMS_KEY = 'items';\n\nfunction fromBackendResponse(\n service: FirebaseStorageImpl,\n bucket: string,\n resource: ListResultResponse\n): ListResult {\n const listResult: ListResult = {\n prefixes: [],\n items: [],\n nextPageToken: resource['nextPageToken']\n };\n if (resource[PREFIXES_KEY]) {\n for (const path of resource[PREFIXES_KEY]) {\n const pathWithoutTrailingSlash = path.replace(/\\/$/, '');\n const reference = service._makeStorageReference(\n new Location(bucket, pathWithoutTrailingSlash)\n );\n listResult.prefixes.push(reference);\n }\n }\n\n if (resource[ITEMS_KEY]) {\n for (const item of resource[ITEMS_KEY]) {\n const reference = service._makeStorageReference(\n new Location(bucket, item['name'])\n );\n listResult.items.push(reference);\n }\n }\n return listResult;\n}\n\nexport function fromResponseString(\n service: FirebaseStorageImpl,\n bucket: string,\n resourceString: string\n): ListResult | null {\n const obj = jsonObjectOrNull(resourceString);\n if (obj === null) {\n return null;\n }\n const resource = obj as unknown as ListResultResponse;\n return fromBackendResponse(service, bucket, resource);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { StorageError } from './error';\nimport { Headers, Connection, ConnectionType } from './connection';\n\n/**\n * Type for url params stored in RequestInfo.\n */\nexport interface UrlParams {\n [name: string]: string | number;\n}\n\n/**\n * A function that converts a server response to the API type expected by the\n * SDK.\n *\n * @param I - the type of the backend's network response\n * @param O - the output response type used by the rest of the SDK.\n */\nexport type RequestHandler<I extends ConnectionType, O> = (\n connection: Connection<I>,\n response: I\n) => O;\n\n/** A function to handle an error. */\nexport type ErrorHandler = (\n connection: Connection<ConnectionType>,\n response: StorageError\n) => StorageError;\n\n/**\n * Contains a fully specified request.\n *\n * @param I - the type of the backend's network response.\n * @param O - the output response type used by the rest of the SDK.\n */\nexport class RequestInfo<I extends ConnectionType, O> {\n urlParams: UrlParams = {};\n headers: Headers = {};\n body: Blob | string | Uint8Array | null = null;\n errorHandler: ErrorHandler | null = null;\n\n /**\n * Called with the current number of bytes uploaded and total size (-1 if not\n * computable) of the request body (i.e. used to report upload progress).\n */\n progressCallback: ((p1: number, p2: number) => void) | null = null;\n successCodes: number[] = [200];\n additionalRetryCodes: number[] = [];\n\n constructor(\n public url: string,\n public method: string,\n /**\n * Returns the value with which to resolve the request's promise. Only called\n * if the request is successful. Throw from this function to reject the\n * returned Request's promise with the thrown error.\n * Note: The XhrIo passed to this function may be reused after this callback\n * returns. Do not keep a reference to it in any way.\n */\n public handler: RequestHandler<I, O>,\n public timeout: number\n ) {}\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines methods for interacting with the network.\n */\n\nimport { Metadata } from '../metadata';\nimport { ListResult } from '../list';\nimport { FbsBlob } from './blob';\nimport {\n StorageError,\n cannotSliceBlob,\n unauthenticated,\n quotaExceeded,\n unauthorized,\n objectNotFound,\n serverFileWrongSize,\n unknown,\n unauthorizedApp\n} from './error';\nimport { Location } from './location';\nimport {\n Mappings,\n fromResourceString,\n downloadUrlFromResourceString,\n toResourceString\n} from './metadata';\nimport { fromResponseString } from './list';\nimport { RequestInfo, UrlParams } from './requestinfo';\nimport { isString } from './type';\nimport { makeUrl } from './url';\nimport { Connection, ConnectionType } from './connection';\nimport { FirebaseStorageImpl } from '../service';\n\n/**\n * Throws the UNKNOWN StorageError if cndn is false.\n */\nexport function handlerCheck(cndn: boolean): void {\n if (!cndn) {\n throw unknown();\n }\n}\n\nexport function metadataHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => Metadata {\n function handler(xhr: Connection<string>, text: string): Metadata {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return metadata as Metadata;\n }\n return handler;\n}\n\nexport function listHandler(\n service: FirebaseStorageImpl,\n bucket: string\n): (p1: Connection<string>, p2: string) => ListResult {\n function handler(xhr: Connection<string>, text: string): ListResult {\n const listResult = fromResponseString(service, bucket, text);\n handlerCheck(listResult !== null);\n return listResult as ListResult;\n }\n return handler;\n}\n\nexport function downloadUrlHandler(\n service: FirebaseStorageImpl,\n mappings: Mappings\n): (p1: Connection<string>, p2: string) => string | null {\n function handler(xhr: Connection<string>, text: string): string | null {\n const metadata = fromResourceString(service, text, mappings);\n handlerCheck(metadata !== null);\n return downloadUrlFromResourceString(\n metadata as Metadata,\n text,\n service.host,\n service._protocol\n );\n }\n return handler;\n}\n\nexport function sharedErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr: StorageError;\n if (xhr.getStatus() === 401) {\n if (\n // This exact message string is the only consistent part of the\n // server's error response that identifies it as an App Check error.\n xhr.getErrorText().includes('Firebase App Check token is invalid')\n ) {\n newErr = unauthorizedApp();\n } else {\n newErr = unauthenticated();\n }\n } else {\n if (xhr.getStatus() === 402) {\n newErr = quotaExceeded(location.bucket);\n } else {\n if (xhr.getStatus() === 403) {\n newErr = unauthorized(location.path);\n } else {\n newErr = err;\n }\n }\n }\n newErr.status = xhr.getStatus();\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function objectErrorHandler(\n location: Location\n): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError {\n const shared = sharedErrorHandler(location);\n\n function errorHandler(\n xhr: Connection<ConnectionType>,\n err: StorageError\n ): StorageError {\n let newErr = shared(xhr, err);\n if (xhr.getStatus() === 404) {\n newErr = objectNotFound(location.path);\n }\n newErr.serverResponse = err.serverResponse;\n return newErr;\n }\n return errorHandler;\n}\n\nexport function getMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function list(\n service: FirebaseStorageImpl,\n location: Location,\n delimiter?: string,\n pageToken?: string | null,\n maxResults?: number | null\n): RequestInfo<string, ListResult> {\n const urlParams: UrlParams = {};\n if (location.isRoot) {\n urlParams['prefix'] = '';\n } else {\n urlParams['prefix'] = location.path + '/';\n }\n if (delimiter && delimiter.length > 0) {\n urlParams['delimiter'] = delimiter;\n }\n if (pageToken) {\n urlParams['pageToken'] = pageToken;\n }\n if (maxResults) {\n urlParams['maxResults'] = maxResults;\n }\n const urlPart = location.bucketOnlyServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n listHandler(service, location.bucket),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\nexport function getBytes<I extends ConnectionType>(\n service: FirebaseStorageImpl,\n location: Location,\n maxDownloadSizeBytes?: number\n): RequestInfo<I, I> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n (_: Connection<I>, data: I) => data,\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n if (maxDownloadSizeBytes !== undefined) {\n requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;\n requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];\n }\n return requestInfo;\n}\n\nexport function getDownloadUrl(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings\n): RequestInfo<string, string | null> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'GET';\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n downloadUrlHandler(service, mappings),\n timeout\n );\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function updateMetadata(\n service: FirebaseStorageImpl,\n location: Location,\n metadata: Partial<Metadata>,\n mappings: Mappings\n): RequestInfo<string, Metadata> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'PATCH';\n const body = toResourceString(metadata, mappings);\n const headers = { 'Content-Type': 'application/json; charset=utf-8' };\n const timeout = service.maxOperationRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function deleteObject(\n service: FirebaseStorageImpl,\n location: Location\n): RequestInfo<string, void> {\n const urlPart = location.fullServerUrl();\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'DELETE';\n const timeout = service.maxOperationRetryTime;\n\n function handler(_xhr: Connection<string>, _text: string): void {}\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.successCodes = [200, 204];\n requestInfo.errorHandler = objectErrorHandler(location);\n return requestInfo;\n}\n\nexport function determineContentType_(\n metadata: Metadata | null,\n blob: FbsBlob | null\n): string {\n return (\n (metadata && metadata['contentType']) ||\n (blob && blob.type()) ||\n 'application/octet-stream'\n );\n}\n\nexport function metadataForUpload_(\n location: Location,\n blob: FbsBlob,\n metadata?: Metadata | null\n): Metadata {\n const metadataClone = Object.assign({}, metadata);\n metadataClone['fullPath'] = location.path;\n metadataClone['size'] = blob.size();\n if (!metadataClone['contentType']) {\n metadataClone['contentType'] = determineContentType_(null, blob);\n }\n return metadataClone;\n}\n\n/**\n * Prepare RequestInfo for uploads as Content-Type: multipart.\n */\nexport function multipartUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, Metadata> {\n const urlPart = location.bucketOnlyServerUrl();\n const headers: { [prop: string]: string } = {\n 'X-Goog-Upload-Protocol': 'multipart'\n };\n\n function genBoundary(): string {\n let str = '';\n for (let i = 0; i < 2; i++) {\n str = str + Math.random().toString().slice(2);\n }\n return str;\n }\n const boundary = genBoundary();\n headers['Content-Type'] = 'multipart/related; boundary=' + boundary;\n const metadata_ = metadataForUpload_(location, blob, metadata);\n const metadataString = toResourceString(metadata_, mappings);\n const preBlobPart =\n '--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: application/json; charset=utf-8\\r\\n\\r\\n' +\n metadataString +\n '\\r\\n--' +\n boundary +\n '\\r\\n' +\n 'Content-Type: ' +\n metadata_['contentType'] +\n '\\r\\n\\r\\n';\n const postBlobPart = '\\r\\n--' + boundary + '--';\n const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);\n if (body === null) {\n throw cannotSliceBlob();\n }\n const urlParams: UrlParams = { name: metadata_['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(\n url,\n method,\n metadataHandler(service, mappings),\n timeout\n );\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param current The number of bytes that have been uploaded so far.\n * @param total The total number of bytes in the upload.\n * @param opt_finalized True if the server has finished the upload.\n * @param opt_metadata The upload metadata, should\n * only be passed if opt_finalized is true.\n */\nexport class ResumableUploadStatus {\n finalized: boolean;\n metadata: Metadata | null;\n\n constructor(\n public current: number,\n public total: number,\n finalized?: boolean,\n metadata?: Metadata | null\n ) {\n this.finalized = !!finalized;\n this.metadata = metadata || null;\n }\n}\n\nexport function checkResumeHeader_(\n xhr: Connection<string>,\n allowed?: string[]\n): string {\n let status: string | null = null;\n try {\n status = xhr.getResponseHeader('X-Goog-Upload-Status');\n } catch (e) {\n handlerCheck(false);\n }\n const allowedStatus = allowed || ['active'];\n handlerCheck(!!status && allowedStatus.indexOf(status) !== -1);\n return status as string;\n}\n\nexport function createResumableUpload(\n service: FirebaseStorageImpl,\n location: Location,\n mappings: Mappings,\n blob: FbsBlob,\n metadata?: Metadata | null\n): RequestInfo<string, string> {\n const urlPart = location.bucketOnlyServerUrl();\n const metadataForUpload = metadataForUpload_(location, blob, metadata);\n const urlParams: UrlParams = { name: metadataForUpload['fullPath']! };\n const url = makeUrl(urlPart, service.host, service._protocol);\n const method = 'POST';\n const headers = {\n 'X-Goog-Upload-Protocol': 'resumable',\n 'X-Goog-Upload-Command': 'start',\n 'X-Goog-Upload-Header-Content-Length': `${blob.size()}`,\n 'X-Goog-Upload-Header-Content-Type': metadataForUpload['contentType']!,\n 'Content-Type': 'application/json; charset=utf-8'\n };\n const body = toResourceString(metadataForUpload, mappings);\n const timeout = service.maxUploadRetryTime;\n\n function handler(xhr: Connection<string>): string {\n checkResumeHeader_(xhr);\n let url;\n try {\n url = xhr.getResponseHeader('X-Goog-Upload-URL');\n } catch (e) {\n handlerCheck(false);\n }\n handlerCheck(isString(url));\n return url as string;\n }\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.urlParams = urlParams;\n requestInfo.headers = headers;\n requestInfo.body = body;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n */\nexport function getResumableUploadStatus(\n service: FirebaseStorageImpl,\n location: Location,\n url: string,\n blob: FbsBlob\n): RequestInfo<string, ResumableUploadStatus> {\n const headers = { 'X-Goog-Upload-Command': 'query' };\n\n function handler(xhr: Connection<string>): ResumableUploadStatus {\n const status = checkResumeHeader_(xhr, ['active', 'final']);\n let sizeString: string | null = null;\n try {\n sizeString = xhr.getResponseHeader('X-Goog-Upload-Size-Received');\n } catch (e) {\n handlerCheck(false);\n }\n\n if (!sizeString) {\n // null or empty string\n handlerCheck(false);\n }\n\n const size = Number(sizeString);\n handlerCheck(!isNaN(size));\n return new ResumableUploadStatus(size, blob.size(), status === 'final');\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n\n/**\n * Any uploads via the resumable upload API must transfer a number of bytes\n * that is a multiple of this number.\n */\nexport const RESUMABLE_UPLOAD_CHUNK_SIZE: number = 256 * 1024;\n\n/**\n * @param url From a call to fbs.requests.createResumableUpload.\n * @param chunkSize Number of bytes to upload.\n * @param status The previous status.\n * If not passed or null, we start from the beginning.\n * @throws fbs.Error If the upload is already complete, the passed in status\n * has a final size inconsistent with the blob, or the blob cannot be sliced\n * for upload.\n */\nexport function continueResumableUpload(\n location: Location,\n service: FirebaseStorageImpl,\n url: string,\n blob: FbsBlob,\n chunkSize: number,\n mappings: Mappings,\n status?: ResumableUploadStatus | null,\n progressCallback?: ((p1: number, p2: number) => void) | null\n): RequestInfo<string, ResumableUploadStatus> {\n // TODO(andysoto): standardize on internal asserts\n // assert(!(opt_status && opt_status.finalized));\n const status_ = new ResumableUploadStatus(0, 0);\n if (status) {\n status_.current = status.current;\n status_.total = status.total;\n } else {\n status_.current = 0;\n status_.total = blob.size();\n }\n if (blob.size() !== status_.total) {\n throw serverFileWrongSize();\n }\n const bytesLeft = status_.total - status_.current;\n let bytesToUpload = bytesLeft;\n if (chunkSize > 0) {\n bytesToUpload = Math.min(bytesToUpload, chunkSize);\n }\n const startByte = status_.current;\n const endByte = startByte + bytesToUpload;\n let uploadCommand = '';\n if (bytesToUpload === 0) {\n uploadCommand = 'finalize';\n } else if (bytesLeft === bytesToUpload) {\n uploadCommand = 'upload, finalize';\n } else {\n uploadCommand = 'upload';\n }\n const headers = {\n 'X-Goog-Upload-Command': uploadCommand,\n 'X-Goog-Upload-Offset': `${status_.current}`\n };\n const body = blob.slice(startByte, endByte);\n if (body === null) {\n throw cannotSliceBlob();\n }\n\n function handler(\n xhr: Connection<string>,\n text: string\n ): ResumableUploadStatus {\n // TODO(andysoto): Verify the MD5 of each uploaded range:\n // the 'x-range-md5' header comes back with status code 308 responses.\n // We'll only be able to bail out though, because you can't re-upload a\n // range that you previously uploaded.\n const uploadStatus = checkResumeHeader_(xhr, ['active', 'final']);\n const newCurrent = status_.current + bytesToUpload;\n const size = blob.size();\n let metadata;\n if (uploadStatus === 'final') {\n metadata = metadataHandler(service, mappings)(xhr, text);\n } else {\n metadata = null;\n }\n return new ResumableUploadStatus(\n newCurrent,\n size,\n uploadStatus === 'final',\n metadata\n );\n }\n const method = 'POST';\n const timeout = service.maxUploadRetryTime;\n const requestInfo = new RequestInfo(url, method, handler, timeout);\n requestInfo.headers = headers;\n requestInfo.body = body.uploadData();\n requestInfo.progressCallback = progressCallback || null;\n requestInfo.errorHandler = sharedErrorHandler(location);\n return requestInfo;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Enumerations used for upload tasks.\n */\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport type TaskEvent = string;\n\n/**\n * An event that is triggered on a task.\n * @internal\n */\nexport const TaskEvent = {\n /**\n * For this event,\n * <ul>\n * <li>The `next` function is triggered on progress updates and when the\n * task is paused/resumed with an `UploadTaskSnapshot` as the first\n * argument.</li>\n * <li>The `error` function is triggered if the upload is canceled or fails\n * for another reason.</li>\n * <li>The `complete` function is triggered if the upload completes\n * successfully.</li>\n * </ul>\n */\n STATE_CHANGED: 'state_changed'\n};\n\n/**\n * Internal enum for task state.\n */\nexport const enum InternalTaskState {\n RUNNING = 'running',\n PAUSING = 'pausing',\n PAUSED = 'paused',\n SUCCESS = 'success',\n CANCELING = 'canceling',\n CANCELED = 'canceled',\n ERROR = 'error'\n}\n\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport type TaskState = (typeof TaskState)[keyof typeof TaskState];\n\n// type keys = keyof TaskState\n/**\n * Represents the current state of a running upload.\n * @internal\n */\nexport const TaskState = {\n /** The task is currently transferring data. */\n RUNNING: 'running',\n\n /** The task was paused by the user. */\n PAUSED: 'paused',\n\n /** The task completed successfully. */\n SUCCESS: 'success',\n\n /** The task was canceled. */\n CANCELED: 'canceled',\n\n /** The task failed with an error. */\n ERROR: 'error'\n} as const;\n\nexport function taskStateFromInternalTaskState(\n state: InternalTaskState\n): TaskState {\n switch (state) {\n case InternalTaskState.RUNNING:\n case InternalTaskState.PAUSING:\n case InternalTaskState.CANCELING:\n return TaskState.RUNNING;\n case InternalTaskState.PAUSED:\n return TaskState.PAUSED;\n case InternalTaskState.SUCCESS:\n return TaskState.SUCCESS;\n case InternalTaskState.CANCELED:\n return TaskState.CANCELED;\n case InternalTaskState.ERROR:\n return TaskState.ERROR;\n default:\n // TODO(andysoto): assert(false);\n return TaskState.ERROR;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { isFunction } from './type';\nimport { StorageError } from './error';\n\n/**\n * Function that is called once for each value in a stream of values.\n */\nexport type NextFn<T> = (value: T) => void;\n\n/**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\nexport type ErrorFn = (error: StorageError) => void;\n\n/**\n * A function that is called if the event stream ends normally.\n */\nexport type CompleteFn = () => void;\n\n/**\n * Unsubscribes from a stream.\n */\nexport type Unsubscribe = () => void;\n\n/**\n * An observer identical to the `Observer` defined in packages/util except the\n * error passed into the ErrorFn is specifically a `StorageError`.\n */\nexport interface StorageObserver<T> {\n /**\n * Function that is called once for each value in the event stream.\n */\n next?: NextFn<T>;\n /**\n * A function that is called with a `StorageError`\n * if the event stream ends due to an error.\n */\n error?: ErrorFn;\n /**\n * A function that is called if the event stream ends normally.\n */\n complete?: CompleteFn;\n}\n\n/**\n * Subscribes to an event stream.\n */\nexport type Subscribe<T> = (\n next?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n) => Unsubscribe;\n\nexport class Observer<T> implements StorageObserver<T> {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n\n constructor(\n nextOrObserver?: NextFn<T> | StorageObserver<T>,\n error?: ErrorFn,\n complete?: CompleteFn\n ) {\n const asFunctions =\n isFunction(nextOrObserver) || error != null || complete != null;\n if (asFunctions) {\n this.next = nextOrObserver as NextFn<T>;\n this.error = error ?? undefined;\n this.complete = complete ?? undefined;\n } else {\n const observer = nextOrObserver as {\n next?: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n };\n this.next = observer.next;\n this.error = observer.error;\n this.complete = observer.complete;\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a function that invokes f with its arguments asynchronously as a\n * microtask, i.e. as soon as possible after the current script returns back\n * into browser code.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function async(f: Function): Function {\n return (...argsToForward: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => f(...argsToForward));\n };\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isCloudWorkstation } from '@firebase/util';\nimport {\n Connection,\n ConnectionType,\n ErrorCode\n} from '../../implementation/connection';\nimport { internalError } from '../../implementation/error';\n\n/** An override for the text-based Connection. Used in tests. */\nlet textFactoryOverride: (() => Connection<string>) | null = null;\n\n/**\n * Network layer that works in Node.\n *\n * This network implementation should not be used in browsers as it does not\n * support progress updates.\n */\nabstract class FetchConnection<T extends ConnectionType>\n implements Connection<T>\n{\n protected errorCode_: ErrorCode;\n protected statusCode_: number | undefined;\n protected body_: ArrayBuffer | undefined;\n protected errorText_ = '';\n protected headers_: Headers | undefined;\n protected sent_: boolean = false;\n\n constructor() {\n this.errorCode_ = ErrorCode.NO_ERROR;\n }\n\n async send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: NodeJS.ArrayBufferView | Blob | string,\n headers?: Record<string, string>\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n this.sent_ = true;\n\n try {\n const response = await newFetch(\n url,\n method,\n isUsingEmulator,\n headers,\n body\n );\n this.headers_ = response.headers;\n this.statusCode_ = response.status;\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.body_ = await response.arrayBuffer();\n } catch (e) {\n this.errorText_ = (e as Error)?.message;\n // emulate XHR which sets status to 0 when encountering a network error\n this.statusCode_ = 0;\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n }\n }\n\n getErrorCode(): ErrorCode {\n if (this.errorCode_ === undefined) {\n throw internalError('cannot .getErrorCode() before receiving response');\n }\n return this.errorCode_;\n }\n\n getStatus(): number {\n if (this.statusCode_ === undefined) {\n throw internalError('cannot .getStatus() before receiving response');\n }\n return this.statusCode_;\n }\n\n abstract getResponse(): T;\n\n getErrorText(): string {\n return this.errorText_;\n }\n\n abort(): void {\n // Not supported\n }\n\n getResponseHeader(header: string): string | null {\n if (!this.headers_) {\n throw internalError(\n 'cannot .getResponseHeader() before receiving response'\n );\n }\n return this.headers_.get(header);\n }\n\n addUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n // Not supported\n }\n\n removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void {\n // Not supported\n }\n}\n\nexport class FetchTextConnection extends FetchConnection<string> {\n getResponse(): string {\n if (!this.body_) {\n throw internalError('cannot .getResponse() before receiving response');\n }\n return Buffer.from(this.body_).toString('utf-8');\n }\n}\n\nexport function newTextConnection(): Connection<string> {\n return textFactoryOverride\n ? textFactoryOverride()\n : new FetchTextConnection();\n}\n\nexport class FetchBytesConnection extends FetchConnection<ArrayBuffer> {\n getResponse(): ArrayBuffer {\n if (!this.body_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.body_;\n }\n}\n\nexport function newBytesConnection(): Connection<ArrayBuffer> {\n return new FetchBytesConnection();\n}\n\nexport class FetchStreamConnection extends FetchConnection<\n ReadableStream<Uint8Array>\n> {\n private stream_: ReadableStream<Uint8Array> | null = null;\n\n async send(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n body?: NodeJS.ArrayBufferView | Blob | string,\n headers?: Record<string, string>\n ): Promise<void> {\n if (this.sent_) {\n throw internalError('cannot .send() more than once');\n }\n this.sent_ = true;\n\n try {\n const response = await newFetch(\n url,\n method,\n isUsingEmulator,\n headers,\n body\n );\n this.headers_ = response.headers;\n this.statusCode_ = response.status;\n this.errorCode_ = ErrorCode.NO_ERROR;\n this.stream_ = response.body as ReadableStream<Uint8Array>;\n } catch (e) {\n this.errorText_ = (e as Error)?.message;\n // emulate XHR which sets status to 0 when encountering a network error\n this.statusCode_ = 0;\n this.errorCode_ = ErrorCode.NETWORK_ERROR;\n }\n }\n\n getResponse(): ReadableStream {\n if (!this.stream_) {\n throw internalError('cannot .getResponse() before sending');\n }\n return this.stream_;\n }\n}\n\nfunction newFetch(\n url: string,\n method: string,\n isUsingEmulator: boolean,\n headers?: Record<string, string>,\n body?: NodeJS.ArrayBufferView | Blob | string\n): Promise<Response> {\n const fetchArgs: RequestInit = {\n method,\n headers: headers || {},\n body: body as NodeJS.ArrayBufferView | string\n };\n if (isCloudWorkstation(url) && isUsingEmulator) {\n fetchArgs.credentials = 'include';\n }\n return fetch(url, fetchArgs);\n}\n\nexport function newStreamConnection(): Connection<ReadableStream<Uint8Array>> {\n return new FetchStreamConnection();\n}\n\nexport function newBlobConnection(): Connection<Blob> {\n throw new Error('Blobs are not supported on Node');\n}\n\nexport function injectTestConnection(\n factory: (() => Connection<string>) | null\n): void {\n textFactoryOverride = factory;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @fileoverview Defines types for interacting with blob transfer tasks.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport {\n canceled,\n StorageErrorCode,\n StorageError,\n retryLimitExceeded\n} from './implementation/error';\nimport {\n InternalTaskState,\n TaskEvent,\n TaskState,\n taskStateFromInternalTaskState\n} from './implementation/taskenums';\nimport { Metadata } from './metadata';\nimport {\n Observer,\n Subscribe,\n Unsubscribe,\n StorageObserver as StorageObserverInternal,\n NextFn\n} from './implementation/observer';\nimport { Request } from './implementation/request';\nimport { UploadTaskSnapshot, StorageObserver } from './public-types';\nimport { async as fbsAsync } from './implementation/async';\nimport { Mappings, getMappings } from './implementation/metadata';\nimport {\n createResumableUpload,\n getResumableUploadStatus,\n RESUMABLE_UPLOAD_CHUNK_SIZE,\n ResumableUploadStatus,\n continueResumableUpload,\n getMetadata,\n multipartUpload\n} from './implementation/requests';\nimport { Reference } from './reference';\nimport { newTextConnection } from './platform/connection';\nimport { isRetryStatusCode } from './implementation/utils';\nimport { CompleteFn } from '@firebase/util';\nimport { DEFAULT_MIN_SLEEP_TIME_MILLIS } from './implementation/constants';\n\n/**\n * Represents a blob being uploaded. Can be used to pause/resume/cancel the\n * upload and manage callbacks for various events.\n * @internal\n */\nexport class UploadTask {\n private _ref: Reference;\n /**\n * The data to be uploaded.\n */\n _blob: FbsBlob;\n /**\n * Metadata related to the upload.\n */\n _metadata: Metadata | null;\n private _mappings: Mappings;\n /**\n * Number of bytes transferred so far.\n */\n _transferred: number = 0;\n private _needToFetchStatus: boolean = false;\n private _needToFetchMetadata: boolean = false;\n private _observers: Array<StorageObserverInternal<UploadTaskSnapshot>> = [];\n private _resumable: boolean;\n /**\n * Upload state.\n */\n _state: InternalTaskState;\n private _error?: StorageError = undefined;\n private _uploadUrl?: string = undefined;\n private _request?: Request<unknown> = undefined;\n private _chunkMultiplier: number = 1;\n private _errorHandler: (p1: StorageError) => void;\n private _metadataErrorHandler: (p1: StorageError) => void;\n private _resolve?: (p1: UploadTaskSnapshot) => void = undefined;\n private _reject?: (p1: StorageError) => void = undefined;\n private pendingTimeout?: ReturnType<typeof setTimeout>;\n private _promise: Promise<UploadTaskSnapshot>;\n\n private sleepTime: number;\n\n private maxSleepTime: number;\n\n isExponentialBackoffExpired(): boolean {\n return this.sleepTime > this.maxSleepTime;\n }\n\n /**\n * @param ref - The firebaseStorage.Reference object this task came\n * from, untyped to avoid cyclic dependencies.\n * @param blob - The blob to upload.\n */\n constructor(ref: Reference, blob: FbsBlob, metadata: Metadata | null = null) {\n this._ref = ref;\n this._blob = blob;\n this._metadata = metadata;\n this._mappings = getMappings();\n this._resumable = this._shouldDoResumable(this._blob);\n this._state = InternalTaskState.RUNNING;\n this._errorHandler = error => {\n this._request = undefined;\n this._chunkMultiplier = 1;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this._needToFetchStatus = true;\n this.completeTransitions_();\n } else {\n const backoffExpired = this.isExponentialBackoffExpired();\n if (isRetryStatusCode(error.status, [])) {\n if (backoffExpired) {\n error = retryLimitExceeded();\n } else {\n this.sleepTime = Math.max(\n this.sleepTime * 2,\n DEFAULT_MIN_SLEEP_TIME_MILLIS\n );\n this._needToFetchStatus = true;\n this.completeTransitions_();\n return;\n }\n }\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this._metadataErrorHandler = error => {\n this._request = undefined;\n if (error._codeEquals(StorageErrorCode.CANCELED)) {\n this.completeTransitions_();\n } else {\n this._error = error;\n this._transition(InternalTaskState.ERROR);\n }\n };\n this.sleepTime = 0;\n this.maxSleepTime = this._ref.storage.maxUploadRetryTime;\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n this._start();\n });\n\n // Prevent uncaught rejections on the internal promise from bubbling out\n // to the top level with a dummy handler.\n this._promise.then(null, () => {});\n }\n\n private _makeProgressCallback(): (p1: number, p2: number) => void {\n const sizeBefore = this._transferred;\n return loaded => this._updateProgress(sizeBefore + loaded);\n }\n\n private _shouldDoResumable(blob: FbsBlob): boolean {\n return blob.size() > 256 * 1024;\n }\n\n private _start(): void {\n if (this._state !== InternalTaskState.RUNNING) {\n // This can happen if someone pauses us in a resume callback, for example.\n return;\n }\n if (this._request !== undefined) {\n return;\n }\n if (this._resumable) {\n if (this._uploadUrl === undefined) {\n this._createResumable();\n } else {\n if (this._needToFetchStatus) {\n this._fetchStatus();\n } else {\n if (this._needToFetchMetadata) {\n // Happens if we miss the metadata on upload completion.\n this._fetchMetadata();\n } else {\n this.pendingTimeout = setTimeout(() => {\n this.pendingTimeout = undefined;\n this._continueUpload();\n }, this.sleepTime);\n }\n }\n }\n } else {\n this._oneShotUpload();\n }\n }\n\n private _resolveToken(\n callback: (authToken: string | null, appCheckToken: string | null) => void\n ): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all([\n this._ref.storage._getAuthToken(),\n this._ref.storage._getAppCheckToken()\n ]).then(([authToken, appCheckToken]) => {\n switch (this._state) {\n case InternalTaskState.RUNNING:\n callback(authToken, appCheckToken);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n default:\n }\n });\n }\n\n // TODO(andysoto): assert false\n\n private _createResumable(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = createResumableUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const createRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = createRequest;\n createRequest.getPromise().then((url: string) => {\n this._request = undefined;\n this._uploadUrl = url;\n this._needToFetchStatus = false;\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _fetchStatus(): void {\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getResumableUploadStatus(\n this._ref.storage,\n this._ref._location,\n url,\n this._blob\n );\n const statusRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = statusRequest;\n statusRequest.getPromise().then(status => {\n status = status as ResumableUploadStatus;\n this._request = undefined;\n this._updateProgress(status.current);\n this._needToFetchStatus = false;\n if (status.finalized) {\n this._needToFetchMetadata = true;\n }\n this.completeTransitions_();\n }, this._errorHandler);\n });\n }\n\n private _continueUpload(): void {\n const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n const status = new ResumableUploadStatus(\n this._transferred,\n this._blob.size()\n );\n\n // TODO(andysoto): assert(this.uploadUrl_ !== null);\n const url = this._uploadUrl as string;\n this._resolveToken((authToken, appCheckToken) => {\n let requestInfo;\n try {\n requestInfo = continueResumableUpload(\n this._ref._location,\n this._ref.storage,\n url,\n this._blob,\n chunkSize,\n this._mappings,\n status,\n this._makeProgressCallback()\n );\n } catch (e) {\n this._error = e as StorageError;\n this._transition(InternalTaskState.ERROR);\n return;\n }\n const uploadRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken,\n /*retry=*/ false // Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file.\n );\n this._request = uploadRequest;\n uploadRequest.getPromise().then((newStatus: ResumableUploadStatus) => {\n this._increaseMultiplier();\n this._request = undefined;\n this._updateProgress(newStatus.current);\n if (newStatus.finalized) {\n this._metadata = newStatus.metadata;\n this._transition(InternalTaskState.SUCCESS);\n } else {\n this.completeTransitions_();\n }\n }, this._errorHandler);\n });\n }\n\n private _increaseMultiplier(): void {\n const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;\n\n // Max chunk size is 32M.\n if (currentSize * 2 < 32 * 1024 * 1024) {\n this._chunkMultiplier *= 2;\n }\n }\n\n private _fetchMetadata(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = getMetadata(\n this._ref.storage,\n this._ref._location,\n this._mappings\n );\n const metadataRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = metadataRequest;\n metadataRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._transition(InternalTaskState.SUCCESS);\n }, this._metadataErrorHandler);\n });\n }\n\n private _oneShotUpload(): void {\n this._resolveToken((authToken, appCheckToken) => {\n const requestInfo = multipartUpload(\n this._ref.storage,\n this._ref._location,\n this._mappings,\n this._blob,\n this._metadata\n );\n const multipartRequest = this._ref.storage._makeRequest(\n requestInfo,\n newTextConnection,\n authToken,\n appCheckToken\n );\n this._request = multipartRequest;\n multipartRequest.getPromise().then(metadata => {\n this._request = undefined;\n this._metadata = metadata;\n this._updateProgress(this._blob.size());\n this._transition(InternalTaskState.SUCCESS);\n }, this._errorHandler);\n });\n }\n\n private _updateProgress(transferred: number): void {\n const old = this._transferred;\n this._transferred = transferred;\n\n // A progress update can make the \"transferred\" value smaller (e.g. a\n // partial upload not completed by server, after which the \"transferred\"\n // value may reset to the value at the beginning of the request).\n if (this._transferred !== old) {\n this._notifyObservers();\n }\n }\n\n private _transition(state: InternalTaskState): void {\n if (this._state === state) {\n return;\n }\n switch (state) {\n case InternalTaskState.CANCELING:\n case InternalTaskState.PAUSING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n if (this._request !== undefined) {\n this._request.cancel();\n } else if (this.pendingTimeout) {\n clearTimeout(this.pendingTimeout);\n this.pendingTimeout = undefined;\n this.completeTransitions_();\n }\n break;\n case InternalTaskState.RUNNING:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.PAUSING);\n const wasPaused = this._state === InternalTaskState.PAUSED;\n this._state = state;\n if (wasPaused) {\n this._notifyObservers();\n this._start();\n }\n break;\n case InternalTaskState.PAUSED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.CANCELED:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.PAUSED ||\n // this.state_ === InternalTaskState.CANCELING);\n this._error = canceled();\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.ERROR:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n case InternalTaskState.SUCCESS:\n // TODO(andysoto):\n // assert(this.state_ === InternalTaskState.RUNNING ||\n // this.state_ === InternalTaskState.PAUSING ||\n // this.state_ === InternalTaskState.CANCELING);\n this._state = state;\n this._notifyObservers();\n break;\n default: // Ignore\n }\n }\n\n private completeTransitions_(): void {\n switch (this._state) {\n case InternalTaskState.PAUSING:\n this._transition(InternalTaskState.PAUSED);\n break;\n case InternalTaskState.CANCELING:\n this._transition(InternalTaskState.CANCELED);\n break;\n case InternalTaskState.RUNNING:\n this._start();\n break;\n default:\n // TODO(andysoto): assert(false);\n break;\n }\n }\n\n /**\n * A snapshot of the current task state.\n */\n get snapshot(): UploadTaskSnapshot {\n const externalState = taskStateFromInternalTaskState(this._state);\n return {\n bytesTransferred: this._transferred,\n totalBytes: this._blob.size(),\n state: externalState,\n metadata: this._metadata!,\n task: this,\n ref: this._ref\n };\n }\n\n /**\n * Adds a callback for an event.\n * @param type - The type of event to listen for.\n * @param nextOrObserver -\n * The `next` function, which gets called for each item in\n * the event stream, or an observer object with some or all of these three\n * properties (`next`, `error`, `complete`).\n * @param error - A function that gets called with a `StorageError`\n * if the event stream ends due to an error.\n * @param completed - A function that gets called if the\n * event stream ends normally.\n * @returns\n * If only the event argument is passed, returns a function you can use to\n * add callbacks (see the examples above). If more than just the event\n * argument is passed, returns a function you can call to unregister the\n * callbacks.\n */\n on(\n type: TaskEvent,\n nextOrObserver?:\n | StorageObserver<UploadTaskSnapshot>\n | null\n | ((snapshot: UploadTaskSnapshot) => unknown),\n error?: ((a: StorageError) => unknown) | null,\n completed?: CompleteFn | null\n ): Unsubscribe | Subscribe<UploadTaskSnapshot> {\n // Note: `type` isn't being used. Its type is also incorrect. TaskEvent should not be a string.\n const observer = new Observer(\n (nextOrObserver as\n | StorageObserverInternal<UploadTaskSnapshot>\n | NextFn<UploadTaskSnapshot>) || undefined,\n error || undefined,\n completed || undefined\n );\n this._addObserver(observer);\n return () => {\n this._removeObserver(observer);\n };\n }\n\n /**\n * This object behaves like a Promise, and resolves with its snapshot data\n * when the upload completes.\n * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.\n * @param onRejected - The rejection callback.\n */\n then<U>(\n onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null,\n onRejected?: ((error: StorageError) => U | Promise<U>) | null\n ): Promise<U> {\n // These casts are needed so that TypeScript can infer the types of the\n // resulting Promise.\n return this._promise.then<U>(\n onFulfilled as (value: UploadTaskSnapshot) => U | Promise<U>,\n onRejected as ((error: unknown) => Promise<never>) | null\n );\n }\n\n /**\n * Equivalent to calling `then(null, onRejected)`.\n */\n catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T> {\n return this.then(null, onRejected);\n }\n\n /**\n * Adds the given observer.\n */\n private _addObserver(observer: Observer<UploadTaskSnapshot>): void {\n this._observers.push(observer);\n this._notifyObserver(observer);\n }\n\n /**\n * Removes the given observer.\n */\n private _removeObserver(observer: Observer<UploadTaskSnapshot>): void {\n const i = this._observers.indexOf(observer);\n if (i !== -1) {\n this._observers.splice(i, 1);\n }\n }\n\n private _notifyObservers(): void {\n this._finishPromise();\n const observers = this._observers.slice();\n observers.forEach(observer => {\n this._notifyObserver(observer);\n });\n }\n\n private _finishPromise(): void {\n if (this._resolve !== undefined) {\n let triggered = true;\n switch (taskStateFromInternalTaskState(this._state)) {\n case TaskState.SUCCESS:\n fbsAsync(this._resolve.bind(null, this.snapshot))();\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n const toCall = this._reject as (p1: StorageError) => void;\n fbsAsync(toCall.bind(null, this._error as StorageError))();\n break;\n default:\n triggered = false;\n break;\n }\n if (triggered) {\n this._resolve = undefined;\n this._reject = undefined;\n }\n }\n }\n\n private _notifyObserver(observer: Observer<UploadTaskSnapshot>): void {\n const externalState = taskStateFromInternalTaskState(this._state);\n switch (externalState) {\n case TaskState.RUNNING:\n case TaskState.PAUSED:\n if (observer.next) {\n fbsAsync(observer.next.bind(observer, this.snapshot))();\n }\n break;\n case TaskState.SUCCESS:\n if (observer.complete) {\n fbsAsync(observer.complete.bind(observer))();\n }\n break;\n case TaskState.CANCELED:\n case TaskState.ERROR:\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n break;\n default:\n // TODO(andysoto): assert(false);\n if (observer.error) {\n fbsAsync(\n observer.error.bind(observer, this._error as StorageError)\n )();\n }\n }\n }\n\n /**\n * Resumes a paused task. Has no effect on a currently running or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n resume(): boolean {\n const valid =\n this._state === InternalTaskState.PAUSED ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.RUNNING);\n }\n return valid;\n }\n\n /**\n * Pauses a currently running task. Has no effect on a paused or failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n pause(): boolean {\n const valid = this._state === InternalTaskState.RUNNING;\n if (valid) {\n this._transition(InternalTaskState.PAUSING);\n }\n return valid;\n }\n\n /**\n * Cancels a currently running or paused task. Has no effect on a complete or\n * failed task.\n * @returns True if the operation took effect, false if ignored.\n */\n cancel(): boolean {\n const valid =\n this._state === InternalTaskState.RUNNING ||\n this._state === InternalTaskState.PAUSING;\n if (valid) {\n this._transition(InternalTaskState.CANCELING);\n }\n return valid;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Defines the Firebase StorageReference class.\n */\n\nimport { FbsBlob } from './implementation/blob';\nimport { Location } from './implementation/location';\nimport { getMappings } from './implementation/metadata';\nimport { child, lastComponent, parent } from './implementation/path';\nimport {\n deleteObject as requestsDeleteObject,\n getBytes,\n getDownloadUrl as requestsGetDownloadUrl,\n getMetadata as requestsGetMetadata,\n list as requestsList,\n multipartUpload,\n updateMetadata as requestsUpdateMetadata\n} from './implementation/requests';\nimport { ListOptions, UploadResult } from './public-types';\nimport { dataFromString, StringFormat } from './implementation/string';\nimport { Metadata } from './metadata';\nimport { FirebaseStorageImpl } from './service';\nimport { ListResult } from './list';\nimport { UploadTask } from './task';\nimport { invalidRootOperation, noDownloadURL } from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport {\n newBlobConnection,\n newBytesConnection,\n newStreamConnection,\n newTextConnection\n} from './platform/connection';\nimport { RequestInfo } from './implementation/requestinfo';\n\n/**\n * Provides methods to interact with a bucket in the Firebase Storage service.\n * @internal\n * @param _location - An fbs.location, or the URL at\n * which to base this object, in one of the following forms:\n * gs://<bucket>/<object-path>\n * http[s]://firebasestorage.googleapis.com/\n * <api-version>/b/<bucket>/o/<object-path>\n * Any query or fragment strings will be ignored in the http[s]\n * format. If no value is passed, the storage object will use a URL based on\n * the project ID of the base firebase.App instance.\n */\nexport class Reference {\n _location: Location;\n\n constructor(\n private _service: FirebaseStorageImpl,\n location: string | Location\n ) {\n if (location instanceof Location) {\n this._location = location;\n } else {\n this._location = Location.makeFromUrl(location, _service.host);\n }\n }\n\n /**\n * Returns the URL for the bucket and path this object references,\n * in the form gs://<bucket>/<object-path>\n * @override\n */\n toString(): string {\n return 'gs://' + this._location.bucket + '/' + this._location.path;\n }\n\n protected _newRef(\n service: FirebaseStorageImpl,\n location: Location\n ): Reference {\n return new Reference(service, location);\n }\n\n /**\n * A reference to the root of this object's bucket.\n */\n get root(): Reference {\n const location = new Location(this._location.bucket, '');\n return this._newRef(this._service, location);\n }\n\n /**\n * The name of the bucket containing this reference's object.\n */\n get bucket(): string {\n return this._location.bucket;\n }\n\n /**\n * The full path of this object.\n */\n get fullPath(): string {\n return this._location.path;\n }\n\n /**\n * The short name of this object, which is the last component of the full path.\n * For example, if fullPath is 'full/path/image.png', name is 'image.png'.\n */\n get name(): string {\n return lastComponent(this._location.path);\n }\n\n /**\n * The `StorageService` instance this `StorageReference` is associated with.\n */\n get storage(): FirebaseStorageImpl {\n return this._service;\n }\n\n /**\n * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if\n * this reference is the root.\n */\n get parent(): Reference | null {\n const newPath = parent(this._location.path);\n if (newPath === null) {\n return null;\n }\n const location = new Location(this._location.bucket, newPath);\n return new Reference(this._service, location);\n }\n\n /**\n * Utility function to throw an error in methods that do not accept a root reference.\n */\n _throwIfRoot(name: string): void {\n if (this._location.path === '') {\n throw invalidRootOperation(name);\n }\n }\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded bytes.\n */\nexport function getBytesInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref._throwIfRoot('getBytes');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBytesConnection)\n .then(bytes =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (bytes as ArrayBuffer).slice(0, maxDownloadSizeBytes)\n : (bytes as ArrayBuffer)\n );\n}\n\n/**\n * Download the bytes at the object's location.\n * @returns A Promise containing the downloaded blob.\n */\nexport function getBlobInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n ref._throwIfRoot('getBlob');\n const requestInfo = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newBlobConnection)\n .then(blob =>\n maxDownloadSizeBytes !== undefined\n ? // GCS may not honor the Range header for small files\n (blob as Blob).slice(0, maxDownloadSizeBytes)\n : (blob as Blob)\n );\n}\n\n/** Stream the bytes at the object's location. */\nexport function getStreamInternal(\n ref: Reference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref._throwIfRoot('getStream');\n const requestInfo: RequestInfo<ReadableStream, ReadableStream> = getBytes(\n ref.storage,\n ref._location,\n maxDownloadSizeBytes\n );\n\n // Transforms the stream so that only `maxDownloadSizeBytes` bytes are piped to the result\n const newMaxSizeTransform = (n: number): Transformer => {\n let missingBytes = n;\n return {\n transform(chunk, controller: TransformStreamDefaultController) {\n // GCS may not honor the Range header for small files\n if (chunk.length < missingBytes) {\n controller.enqueue(chunk);\n missingBytes -= chunk.length;\n } else {\n controller.enqueue(chunk.slice(0, missingBytes));\n controller.terminate();\n }\n }\n };\n };\n\n const result =\n maxDownloadSizeBytes !== undefined\n ? new TransformStream(newMaxSizeTransform(maxDownloadSizeBytes))\n : new TransformStream(); // The default transformer forwards all chunks to its readable side\n\n ref.storage\n .makeRequestWithTokens(requestInfo, newStreamConnection)\n .then(readableStream => readableStream.pipeThrough(result))\n .catch(err => result.writable.abort(err));\n\n return result.readable;\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n *\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadBytes');\n const requestInfo = multipartUpload(\n ref.storage,\n ref._location,\n getMappings(),\n new FbsBlob(data, true),\n metadata\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(finalMetadata => {\n return {\n metadata: finalMetadata,\n ref\n };\n });\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - StorageReference where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the newly uploaded data.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: Reference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: Metadata\n): UploadTask {\n ref._throwIfRoot('uploadBytesResumable');\n return new UploadTask(ref, new FbsBlob(data), metadata);\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - StorageReference where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the newly uploaded string.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: Reference,\n value: string,\n format: StringFormat = StringFormat.RAW,\n metadata?: Metadata\n): Promise<UploadResult> {\n ref._throwIfRoot('uploadString');\n const data = dataFromString(format, value);\n const metadataClone = { ...metadata } as Metadata;\n if (metadataClone['contentType'] == null && data.contentType != null) {\n metadataClone['contentType'] = data.contentType!;\n }\n return uploadBytes(ref, data.data, metadataClone);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: listAll may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - StorageReference to get list from.\n *\n * @returns A Promise that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: Reference): Promise<ListResult> {\n const accumulator: ListResult = {\n prefixes: [],\n items: []\n };\n return listAllHelper(ref, accumulator).then(() => accumulator);\n}\n\n/**\n * Separated from listAll because async functions can't use \"arguments\".\n * @param ref\n * @param accumulator\n * @param pageToken\n */\nasync function listAllHelper(\n ref: Reference,\n accumulator: ListResult,\n pageToken?: string\n): Promise<void> {\n const opt: ListOptions = {\n // maxResults is 1000 by default.\n pageToken\n };\n const nextPage = await list(ref, opt);\n accumulator.prefixes.push(...nextPage.prefixes);\n accumulator.items.push(...nextPage.items);\n if (nextPage.nextPageToken != null) {\n await listAllHelper(ref, accumulator, nextPage.nextPageToken);\n }\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - StorageReference to get list from.\n * @param options - See ListOptions for details.\n * @returns A Promise that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: Reference,\n options?: ListOptions | null\n): Promise<ListResult> {\n if (options != null) {\n if (typeof options.maxResults === 'number') {\n validateNumber(\n 'options.maxResults',\n /* minValue= */ 1,\n /* maxValue= */ 1000,\n options.maxResults\n );\n }\n }\n const op = options || {};\n const requestInfo = requestsList(\n ref.storage,\n ref._location,\n /*delimiter= */ '/',\n op.pageToken,\n op.maxResults\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - StorageReference to get metadata from.\n */\nexport function getMetadata(ref: Reference): Promise<Metadata> {\n ref._throwIfRoot('getMetadata');\n const requestInfo = requestsGetMetadata(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - StorageReference to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves\n * with the new metadata for this object.\n * See `firebaseStorage.Reference.prototype.getMetadata`\n */\nexport function updateMetadata(\n ref: Reference,\n metadata: Partial<Metadata>\n): Promise<Metadata> {\n ref._throwIfRoot('updateMetadata');\n const requestInfo = requestsUpdateMetadata(\n ref.storage,\n ref._location,\n metadata,\n getMappings()\n );\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns the download URL for the given Reference.\n * @public\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: Reference): Promise<string> {\n ref._throwIfRoot('getDownloadURL');\n const requestInfo = requestsGetDownloadUrl(\n ref.storage,\n ref._location,\n getMappings()\n );\n return ref.storage\n .makeRequestWithTokens(requestInfo, newTextConnection)\n .then(url => {\n if (url === null) {\n throw noDownloadURL();\n }\n return url;\n });\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - StorageReference for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: Reference): Promise<void> {\n ref._throwIfRoot('deleteObject');\n const requestInfo = requestsDeleteObject(ref.storage, ref._location);\n return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);\n}\n\n/**\n * Returns reference for object obtained by appending `childPath` to `ref`.\n *\n * @param ref - StorageReference to get child of.\n * @param childPath - Child path from provided ref.\n * @returns A reference to the object obtained by\n * appending childPath, removing any duplicate, beginning, or trailing\n * slashes.\n *\n */\nexport function _getChild(ref: Reference, childPath: string): Reference {\n const newPath = child(ref._location.path, childPath);\n const location = new Location(ref._location.bucket, newPath);\n return new Reference(ref.storage, location);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Location } from './implementation/location';\nimport { FailRequest } from './implementation/failrequest';\nimport { Request, makeRequest } from './implementation/request';\nimport { RequestInfo } from './implementation/requestinfo';\nimport { Reference, _getChild } from './reference';\nimport { Provider } from '@firebase/component';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n FirebaseApp,\n FirebaseOptions,\n _isFirebaseServerApp\n} from '@firebase/app';\nimport {\n CONFIG_STORAGE_BUCKET_KEY,\n DEFAULT_HOST,\n DEFAULT_MAX_OPERATION_RETRY_TIME,\n DEFAULT_MAX_UPLOAD_RETRY_TIME\n} from './implementation/constants';\nimport {\n invalidArgument,\n appDeleted,\n noDefaultBucket\n} from './implementation/error';\nimport { validateNumber } from './implementation/type';\nimport { FirebaseStorage } from './public-types';\nimport {\n createMockUserToken,\n EmulatorMockTokenOptions,\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\nimport { Connection, ConnectionType } from './implementation/connection';\n\nexport function isUrl(path?: string): boolean {\n return /^[A-Za-z]+:\\/\\//.test(path as string);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given url.\n */\nfunction refFromURL(service: FirebaseStorageImpl, url: string): Reference {\n return new Reference(service, url);\n}\n\n/**\n * Returns a firebaseStorage.Reference for the given path in the default\n * bucket.\n */\nfunction refFromPath(\n ref: FirebaseStorageImpl | Reference,\n path?: string\n): Reference {\n if (ref instanceof FirebaseStorageImpl) {\n const service = ref;\n if (service._bucket == null) {\n throw noDefaultBucket();\n }\n const reference = new Reference(service, service._bucket!);\n if (path != null) {\n return refFromPath(reference, path);\n } else {\n return reference;\n }\n } else {\n // ref is a Reference\n if (path !== undefined) {\n return _getChild(ref, path);\n } else {\n return ref;\n }\n }\n}\n\n/**\n * Returns a storage Reference for the given url.\n * @param storage - `Storage` instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorageImpl, url?: string): Reference;\n/**\n * Returns a storage Reference for the given path in the\n * default bucket.\n * @param storageOrRef - `Storage` service or storage `Reference`.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage\n * instance provided) or returns same reference (if Reference provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorageImpl | Reference,\n path?: string\n): Reference;\nexport function ref(\n serviceOrRef: FirebaseStorageImpl | Reference,\n pathOrUrl?: string\n): Reference | null {\n if (pathOrUrl && isUrl(pathOrUrl)) {\n if (serviceOrRef instanceof FirebaseStorageImpl) {\n return refFromURL(serviceOrRef, pathOrUrl);\n } else {\n throw invalidArgument(\n 'To use ref(service, url), the first argument must be a Storage instance.'\n );\n }\n } else {\n return refFromPath(serviceOrRef, pathOrUrl);\n }\n}\n\nfunction extractBucket(\n host: string,\n config?: FirebaseOptions\n): Location | null {\n const bucketString = config?.[CONFIG_STORAGE_BUCKET_KEY];\n if (bucketString == null) {\n return null;\n }\n return Location.makeFromBucketSpec(bucketString, host);\n}\n\nexport function connectStorageEmulator(\n storage: FirebaseStorageImpl,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n storage.host = `${host}:${port}`;\n const useSsl = isCloudWorkstation(host);\n // Workaround to get cookies in Firebase Studio\n if (useSsl) {\n void pingServer(`https://${storage.host}/b`);\n updateEmulatorBanner('Storage', true);\n }\n storage._isUsingEmulator = true;\n storage._protocol = useSsl ? 'https' : 'http';\n const { mockUserToken } = options;\n if (mockUserToken) {\n storage._overrideAuthToken =\n typeof mockUserToken === 'string'\n ? mockUserToken\n : createMockUserToken(mockUserToken, storage.app.options.projectId);\n }\n}\n\n/**\n * A service that provides Firebase Storage Reference instances.\n * @param opt_url - gs:// url to a custom Storage Bucket\n *\n * @internal\n */\nexport class FirebaseStorageImpl implements FirebaseStorage {\n _bucket: Location | null = null;\n /**\n * This string can be in the formats:\n * - host\n * - host:port\n */\n private _host: string = DEFAULT_HOST;\n _protocol: string = 'https';\n protected readonly _appId: string | null = null;\n private readonly _requests: Set<Request<unknown>>;\n private _deleted: boolean = false;\n private _maxOperationRetryTime: number;\n private _maxUploadRetryTime: number;\n _overrideAuthToken?: string;\n\n constructor(\n /**\n * FirebaseApp associated with this StorageService instance.\n */\n readonly app: FirebaseApp,\n readonly _authProvider: Provider<FirebaseAuthInternalName>,\n /**\n * @internal\n */\n readonly _appCheckProvider: Provider<AppCheckInternalComponentName>,\n /**\n * @internal\n */\n readonly _url?: string,\n readonly _firebaseVersion?: string,\n public _isUsingEmulator = false\n ) {\n this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;\n this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;\n this._requests = new Set();\n if (_url != null) {\n this._bucket = Location.makeFromBucketSpec(_url, this._host);\n } else {\n this._bucket = extractBucket(this._host, this.app.options);\n }\n }\n\n /**\n * The host string for this service, in the form of `host` or\n * `host:port`.\n */\n get host(): string {\n return this._host;\n }\n\n set host(host: string) {\n this._host = host;\n if (this._url != null) {\n this._bucket = Location.makeFromBucketSpec(this._url, host);\n } else {\n this._bucket = extractBucket(host, this.app.options);\n }\n }\n\n /**\n * The maximum time to retry uploads in milliseconds.\n */\n get maxUploadRetryTime(): number {\n return this._maxUploadRetryTime;\n }\n\n set maxUploadRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxUploadRetryTime = time;\n }\n\n /**\n * The maximum time to retry operations other than uploads or downloads in\n * milliseconds.\n */\n get maxOperationRetryTime(): number {\n return this._maxOperationRetryTime;\n }\n\n set maxOperationRetryTime(time: number) {\n validateNumber(\n 'time',\n /* minValue=*/ 0,\n /* maxValue= */ Number.POSITIVE_INFINITY,\n time\n );\n this._maxOperationRetryTime = time;\n }\n\n async _getAuthToken(): Promise<string | null> {\n if (this._overrideAuthToken) {\n return this._overrideAuthToken;\n }\n const auth = this._authProvider.getImmediate({ optional: true });\n if (auth) {\n const tokenData = await auth.getToken();\n if (tokenData !== null) {\n return tokenData.accessToken;\n }\n }\n return null;\n }\n\n async _getAppCheckToken(): Promise<string | null> {\n if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) {\n return this.app.settings.appCheckToken;\n }\n const appCheck = this._appCheckProvider.getImmediate({ optional: true });\n if (appCheck) {\n const result = await appCheck.getToken();\n // TODO: What do we want to do if there is an error getting the token?\n // Context: appCheck.getToken() will never throw even if an error happened. In the error case, a dummy token will be\n // returned along with an error field describing the error. In general, we shouldn't care about the error condition and just use\n // the token (actual or dummy) to send requests.\n return result.token;\n }\n return null;\n }\n\n /**\n * Stop running requests and prevent more from being created.\n */\n _delete(): Promise<void> {\n if (!this._deleted) {\n this._deleted = true;\n this._requests.forEach(request => request.cancel());\n this._requests.clear();\n }\n return Promise.resolve();\n }\n\n /**\n * Returns a new firebaseStorage.Reference object referencing this StorageService\n * at the given Location.\n */\n _makeStorageReference(loc: Location): Reference {\n return new Reference(this, loc);\n }\n\n /**\n * @param requestInfo - HTTP RequestInfo object\n * @param authToken - Firebase auth token\n */\n _makeRequest<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>,\n authToken: string | null,\n appCheckToken: string | null,\n retry = true\n ): Request<O> {\n if (!this._deleted) {\n const request = makeRequest(\n requestInfo,\n this._appId,\n authToken,\n appCheckToken,\n requestFactory,\n this._firebaseVersion,\n retry,\n this._isUsingEmulator\n );\n this._requests.add(request);\n // Request removes itself from set when complete.\n request.getPromise().then(\n () => this._requests.delete(request),\n () => this._requests.delete(request)\n );\n return request;\n } else {\n return new FailRequest(appDeleted());\n }\n }\n\n async makeRequestWithTokens<I extends ConnectionType, O>(\n requestInfo: RequestInfo<I, O>,\n requestFactory: () => Connection<I>\n ): Promise<O> {\n const [authToken, appCheckToken] = await Promise.all([\n this._getAuthToken(),\n this._getAppCheckToken()\n ]);\n\n return this._makeRequest(\n requestInfo,\n requestFactory,\n authToken,\n appCheckToken\n ).getPromise();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Type constant for Firebase Storage.\n */\nexport const STORAGE_TYPE = 'storage';\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { _getProvider, FirebaseApp, getApp } from '@firebase/app';\n\nimport {\n ref as refInternal,\n FirebaseStorageImpl,\n connectStorageEmulator as connectEmulatorInternal\n} from './service';\nimport { Provider } from '@firebase/component';\n\nimport {\n StorageReference,\n FirebaseStorage,\n UploadResult,\n ListOptions,\n ListResult,\n UploadTask,\n SettableMetadata,\n UploadMetadata,\n FullMetadata\n} from './public-types';\nimport { Metadata as MetadataInternal } from './metadata';\nimport {\n uploadBytes as uploadBytesInternal,\n uploadBytesResumable as uploadBytesResumableInternal,\n uploadString as uploadStringInternal,\n getMetadata as getMetadataInternal,\n updateMetadata as updateMetadataInternal,\n list as listInternal,\n listAll as listAllInternal,\n getDownloadURL as getDownloadURLInternal,\n deleteObject as deleteObjectInternal,\n Reference,\n _getChild as _getChildInternal,\n getBytesInternal\n} from './reference';\nimport { STORAGE_TYPE } from './constants';\nimport {\n EmulatorMockTokenOptions,\n getModularInstance,\n getDefaultEmulatorHostnameAndPort\n} from '@firebase/util';\nimport { StringFormat } from './implementation/string';\n\nexport { EmulatorMockTokenOptions } from '@firebase/util';\n\nexport { StorageError, StorageErrorCode } from './implementation/error';\n\n/**\n * Public types.\n */\nexport * from './public-types';\n\nexport { Location as _Location } from './implementation/location';\nexport { UploadTask as _UploadTask } from './task';\nexport type { Reference as _Reference } from './reference';\nexport type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';\nexport { FbsBlob as _FbsBlob } from './implementation/blob';\nexport { dataFromString as _dataFromString } from './implementation/string';\nexport {\n invalidRootOperation as _invalidRootOperation,\n invalidArgument as _invalidArgument\n} from './implementation/error';\nexport {\n TaskEvent as _TaskEvent,\n TaskState as _TaskState\n} from './implementation/taskenums';\nexport { StringFormat };\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise containing the object's bytes\n */\nexport function getBytes(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<ArrayBuffer> {\n ref = getModularInstance(ref);\n return getBytesInternal(ref as Reference, maxDownloadSizeBytes);\n}\n\n/**\n * Uploads data to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadBytes(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadBytesInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads a string to this object's location.\n * The upload is not resumable.\n * @public\n * @param ref - {@link StorageReference} where string should be uploaded.\n * @param value - The string to upload.\n * @param format - The format of the string to upload.\n * @param metadata - Metadata for the string to upload.\n * @returns A Promise containing an UploadResult\n */\nexport function uploadString(\n ref: StorageReference,\n value: string,\n format?: StringFormat,\n metadata?: UploadMetadata\n): Promise<UploadResult> {\n ref = getModularInstance(ref);\n return uploadStringInternal(\n ref as Reference,\n value,\n format,\n metadata as MetadataInternal\n );\n}\n\n/**\n * Uploads data to this object's location.\n * The upload can be paused and resumed, and exposes progress updates.\n * @public\n * @param ref - {@link StorageReference} where data should be uploaded.\n * @param data - The data to upload.\n * @param metadata - Metadata for the data to upload.\n * @returns An UploadTask\n */\nexport function uploadBytesResumable(\n ref: StorageReference,\n data: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): UploadTask {\n ref = getModularInstance(ref);\n return uploadBytesResumableInternal(\n ref as Reference,\n data,\n metadata as MetadataInternal\n ) as UploadTask;\n}\n\n/**\n * A `Promise` that resolves with the metadata for this object. If this\n * object doesn't exist or metadata cannot be retrieved, the promise is\n * rejected.\n * @public\n * @param ref - {@link StorageReference} to get metadata from.\n */\nexport function getMetadata(ref: StorageReference): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return getMetadataInternal(ref as Reference) as Promise<FullMetadata>;\n}\n\n/**\n * Updates the metadata for this object.\n * @public\n * @param ref - {@link StorageReference} to update metadata for.\n * @param metadata - The new metadata for the object.\n * Only values that have been explicitly set will be changed. Explicitly\n * setting a value to null will remove the metadata.\n * @returns A `Promise` that resolves with the new metadata for this object.\n */\nexport function updateMetadata(\n ref: StorageReference,\n metadata: SettableMetadata\n): Promise<FullMetadata> {\n ref = getModularInstance(ref);\n return updateMetadataInternal(\n ref as Reference,\n metadata as Partial<MetadataInternal>\n ) as Promise<FullMetadata>;\n}\n\n/**\n * List items (files) and prefixes (folders) under this storage reference.\n *\n * List API is only available for Firebase Rules Version 2.\n *\n * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'\n * delimited folder structure.\n * Refer to GCS's List API if you want to learn more.\n *\n * To adhere to Firebase Rules's Semantics, Firebase Storage does not\n * support objects whose paths end with \"/\" or contain two consecutive\n * \"/\"s. Firebase Storage List API will filter these unsupported objects.\n * list() may fail if there are too many unsupported objects in the bucket.\n * @public\n *\n * @param ref - {@link StorageReference} to get list from.\n * @param options - See {@link ListOptions} for details.\n * @returns A `Promise` that resolves with the items and prefixes.\n * `prefixes` contains references to sub-folders and `items`\n * contains references to objects in this folder. `nextPageToken`\n * can be used to get the rest of the results.\n */\nexport function list(\n ref: StorageReference,\n options?: ListOptions\n): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listInternal(ref as Reference, options);\n}\n\n/**\n * List all items (files) and prefixes (folders) under this storage reference.\n *\n * This is a helper method for calling list() repeatedly until there are\n * no more results. The default pagination size is 1000.\n *\n * Note: The results may not be consistent if objects are changed while this\n * operation is running.\n *\n * Warning: `listAll` may potentially consume too many resources if there are\n * too many results.\n * @public\n * @param ref - {@link StorageReference} to get list from.\n *\n * @returns A `Promise` that resolves with all the items and prefixes under\n * the current storage reference. `prefixes` contains references to\n * sub-directories and `items` contains references to objects in this\n * folder. `nextPageToken` is never returned.\n */\nexport function listAll(ref: StorageReference): Promise<ListResult> {\n ref = getModularInstance(ref);\n return listAllInternal(ref as Reference);\n}\n\n/**\n * Returns the download URL for the given {@link StorageReference}.\n * @public\n * @param ref - {@link StorageReference} to get the download URL for.\n * @returns A `Promise` that resolves with the download\n * URL for this object.\n */\nexport function getDownloadURL(ref: StorageReference): Promise<string> {\n ref = getModularInstance(ref);\n return getDownloadURLInternal(ref as Reference);\n}\n\n/**\n * Deletes the object at this location.\n * @public\n * @param ref - {@link StorageReference} for object to delete.\n * @returns A `Promise` that resolves if the deletion succeeds.\n */\nexport function deleteObject(ref: StorageReference): Promise<void> {\n ref = getModularInstance(ref);\n return deleteObjectInternal(ref as Reference);\n}\n\n/**\n * Returns a {@link StorageReference} for the given url.\n * @param storage - {@link FirebaseStorage} instance.\n * @param url - URL. If empty, returns root reference.\n * @public\n */\nexport function ref(storage: FirebaseStorage, url?: string): StorageReference;\n/**\n * Returns a {@link StorageReference} for the given path in the\n * default bucket.\n * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.\n * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}\n * instance provided) or returns same reference (if {@link StorageReference} provided).\n * @public\n */\nexport function ref(\n storageOrRef: FirebaseStorage | StorageReference,\n path?: string\n): StorageReference;\nexport function ref(\n serviceOrRef: FirebaseStorage | StorageReference,\n pathOrUrl?: string\n): StorageReference | null {\n serviceOrRef = getModularInstance(serviceOrRef);\n return refInternal(\n serviceOrRef as FirebaseStorageImpl | Reference,\n pathOrUrl\n );\n}\n\n/**\n * @internal\n */\nexport function _getChild(ref: StorageReference, childPath: string): Reference {\n return _getChildInternal(ref as Reference, childPath);\n}\n\n/**\n * Gets a {@link FirebaseStorage} instance for the given Firebase app.\n * @public\n * @param app - Firebase app to get {@link FirebaseStorage} instance for.\n * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.\n * If not passed, uses the app's default Storage Bucket.\n * @returns A {@link FirebaseStorage} instance.\n */\nexport function getStorage(\n app: FirebaseApp = getApp(),\n bucketUrl?: string\n): FirebaseStorage {\n app = getModularInstance(app);\n const storageProvider: Provider<'storage'> = _getProvider(app, STORAGE_TYPE);\n const storageInstance = storageProvider.getImmediate({\n identifier: bucketUrl\n });\n const emulator = getDefaultEmulatorHostnameAndPort('storage');\n if (emulator) {\n connectStorageEmulator(storageInstance, ...emulator);\n }\n return storageInstance;\n}\n\n/**\n * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.\n *\n * @param storage - The {@link FirebaseStorage} instance\n * @param host - The emulator host (ex: localhost)\n * @param port - The emulator port (ex: 5001)\n * @param options - Emulator options. `options.mockUserToken` is the mock auth\n * token to use for unit testing Security Rules.\n * @public\n */\nexport function connectStorageEmulator(\n storage: FirebaseStorage,\n host: string,\n port: number,\n options: {\n mockUserToken?: EmulatorMockTokenOptions | string;\n } = {}\n): void {\n connectEmulatorInternal(storage as FirebaseStorageImpl, host, port, options);\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StorageReference } from './public-types';\nimport { Reference, getStreamInternal } from './reference';\nimport { getModularInstance } from '@firebase/util';\n\n/**\n * Downloads the data at the object's location. Returns an error if the object\n * is not found.\n *\n * To use this functionality, you have to whitelist your app's origin in your\n * Cloud Storage bucket. See also\n * https://cloud.google.com/storage/docs/configuring-cors\n *\n * This API is not available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A Promise that resolves with a Blob containing the object's bytes\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function getBlob(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): Promise<Blob> {\n throw new Error('getBlob() is only available in Browser-like environments');\n}\n\n/**\n * Downloads the data at the object's location. Raises an error event if the\n * object is not found.\n *\n * This API is only available in Node.\n *\n * @public\n * @param ref - StorageReference where data should be downloaded.\n * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to\n * retrieve.\n * @returns A stream with the object's data as bytes\n */\nexport function getStream(\n ref: StorageReference,\n maxDownloadSizeBytes?: number\n): ReadableStream {\n ref = getModularInstance(ref);\n return getStreamInternal(ref as Reference, maxDownloadSizeBytes);\n}\n","/**\n * Cloud Storage for Firebase\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n _registerComponent,\n registerVersion,\n SDK_VERSION\n} from '@firebase/app';\n\nimport { FirebaseStorageImpl } from './service';\nimport {\n Component,\n ComponentType,\n ComponentContainer,\n InstanceFactoryOptions\n} from '@firebase/component';\n\nimport { name, version } from '../package.json';\n\nimport { FirebaseStorage } from './public-types';\nimport { STORAGE_TYPE } from './constants';\n\nexport * from './api';\nexport * from './api.node';\n\nfunction factory(\n container: ComponentContainer,\n { instanceIdentifier: url }: InstanceFactoryOptions\n): FirebaseStorage {\n const app = container.getProvider('app').getImmediate();\n const authProvider = container.getProvider('auth-internal');\n const appCheckProvider = container.getProvider('app-check-internal');\n\n return new FirebaseStorageImpl(\n app,\n authProvider,\n appCheckProvider,\n url,\n SDK_VERSION\n );\n}\n\nfunction registerStorage(): void {\n _registerComponent(\n new Component(\n STORAGE_TYPE,\n factory,\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n\n registerVersion(name, version);\n}\n\nregisterStorage();\n"],"names":["getBlob","getMetadata","list","getBytes","updateMetadata","deleteObject","fbsAsync","uploadBytes","uploadBytesResumable","uploadString","listAll","requestsList","requestsGetMetadata","requestsUpdateMetadata","getDownloadURL","requestsGetDownloadUrl","requestsDeleteObject","_getChild","ref","connectStorageEmulator","uploadBytesInternal","uploadStringInternal","uploadBytesResumableInternal","getMetadataInternal","updateMetadataInternal","listInternal","listAllInternal","getDownloadURLInternal","deleteObjectInternal","refInternal","_getChildInternal","connectEmulatorInternal"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;AAeG;AACH;;AAEG;AAEH;;AAEG;AACI,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAE7D;;AAEG;AACI,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAEzD;;;;AAIG;AACI,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9D;;;;AAIG;AACI,MAAM,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5D;;AAEG;AACI,MAAM,6BAA6B,GAAG,IAAI;;AC/CjD;;;;;;;;;;;;;;;AAeG;AAMH;;;AAGG;AACG,MAAO,YAAa,SAAQ,aAAa,CAAA;AAO7C;;;;;AAKG;AACH,IAAA,WAAA,CAAY,IAAsB,EAAE,OAAe,EAAU,UAAU,CAAC,EAAA;AACtE,QAAA,KAAK,CACH,WAAW,CAAC,IAAI,CAAC,EACjB,CAAA,kBAAA,EAAqB,OAAO,CAAA,EAAA,EAAK,WAAW,CAAC,IAAI,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EAAA;AAE7B,IAAA,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;AAWG;AACa,SAAA,SAAS,CACvB,GAAqB,EACrB,oBAA6B,EAAA;AAE7B,IAAA,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAC9B,IAAA,OAAO,iBAAiB,CAAC,GAAgB,EAAE,oBAAoB,CAAC,CAAC;AACnE;;AC/DA;;;;AAIG;AA0CH,SAAS,OAAO,CACd,SAA6B,EAC7B,EAAE,kBAAkB,EAAE,GAAG,EAA0B,EAAA;IAEnD,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAErE,IAAA,OAAO,IAAI,mBAAmB,CAC5B,GAAG,EACH,YAAY,EACZ,gBAAgB,EAChB,GAAG,EACH,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,GAAA;AACtB,IAAA,kBAAkB,CAChB,IAAI,SAAS,CACX,YAAY,EACZ,OAAO,EAER,QAAA,4BAAA,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAC7B,CAAC;AAEF,IAAA,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,eAAe,EAAE;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/package.json b/frontend-old/node_modules/@firebase/storage/dist/node-esm/package.json deleted file mode 100644 index 7c34deb..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/package.json +++ /dev/null @@ -1 +0,0 @@ -{"type":"module"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.browser.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.browser.d.ts deleted file mode 100644 index 00e4761..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.browser.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageReference } from './public-types'; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.d.ts deleted file mode 100644 index 3ba97cc..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.d.ts +++ /dev/null @@ -1,200 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FirebaseApp } from '@firebase/app'; -import { StorageReference, FirebaseStorage, UploadResult, ListOptions, ListResult, UploadTask, SettableMetadata, UploadMetadata, FullMetadata } from './public-types'; -import { Reference } from './reference'; -import { EmulatorMockTokenOptions } from '@firebase/util'; -import { StringFormat } from './implementation/string'; -export { EmulatorMockTokenOptions } from '@firebase/util'; -export { StorageError, StorageErrorCode } from './implementation/error'; -/** - * Public types. - */ -export * from './public-types'; -export { Location as _Location } from './implementation/location'; -export { UploadTask as _UploadTask } from './task'; -export type { Reference as _Reference } from './reference'; -export type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service'; -export { FbsBlob as _FbsBlob } from './implementation/blob'; -export { dataFromString as _dataFromString } from './implementation/string'; -export { invalidRootOperation as _invalidRootOperation, invalidArgument as _invalidArgument } from './implementation/error'; -export { TaskEvent as _TaskEvent, TaskState as _TaskState } from './implementation/taskenums'; -export { StringFormat }; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>; -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>; -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask; -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>; -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>; -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>; -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -export declare function listAll(ref: StorageReference): Promise<ListResult>; -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -export declare function getDownloadURL(ref: StorageReference): Promise<string>; -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -export declare function deleteObject(ref: StorageReference): Promise<void>; -/** - * Returns a {@link StorageReference} for the given url. - * @param storage - {@link FirebaseStorage} instance. - * @param url - URL. If empty, returns root reference. - * @public - */ -export declare function ref(storage: FirebaseStorage, url?: string): StorageReference; -/** - * Returns a {@link StorageReference} for the given path in the - * default bucket. - * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}. - * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage} - * instance provided) or returns same reference (if {@link StorageReference} provided). - * @public - */ -export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference; -/** - * @internal - */ -export declare function _getChild(ref: StorageReference, childPath: string): Reference; -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage; -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.node.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.node.d.ts deleted file mode 100644 index 00e4761..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/api.node.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageReference } from './public-types'; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/constants.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/constants.d.ts deleted file mode 100644 index c9c810f..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/constants.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -export declare const STORAGE_TYPE = "storage"; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/async.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/async.d.ts deleted file mode 100644 index 9d01868..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/async.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -export declare function async(f: Function): Function; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/backoff.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/backoff.d.ts deleted file mode 100644 index 39ab9b7..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/backoff.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Provides a method for running a function with exponential - * backoff. - */ -type id = (p1: boolean) => void; -export { id }; -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -export declare function start(doRequest: (onRequestComplete: (success: boolean) => void, canceled: boolean) => void, backoffCompleteCb: (...args: any[]) => unknown, timeout: number): id; -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -export declare function stop(id: id): void; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/blob.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/blob.d.ts deleted file mode 100644 index 419491b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/blob.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -export declare class FbsBlob { - private data_; - private size_; - private type_; - constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean); - size(): number; - type(): string; - slice(startByte: number, endByte: number): FbsBlob | null; - static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null; - uploadData(): Blob | Uint8Array; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/connection.d.ts deleted file mode 100644 index 269f2d9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/connection.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Network headers */ -export type Headers = Record<string, string>; -/** Response type exposed by the networking APIs. */ -export type ConnectionType = string | ArrayBuffer | Blob | ReadableStream<Uint8Array>; -/** - * A lightweight wrapper around XMLHttpRequest with a - * goog.net.XhrIo-like interface. - * - * You can create a new connection by invoking `newTextConnection()`, - * `newBytesConnection()` or `newStreamConnection()`. - */ -export interface Connection<T extends ConnectionType> { - /** - * Sends a request to the provided URL. - * - * This method never rejects its promise. In case of encountering an error, - * it sets an error code internally which can be accessed by calling - * getErrorCode() by callers. - */ - send(url: string, method: string, isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): T; - getErrorText(): string; - /** - * Abort the request. - */ - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} -/** - * Error codes for requests made by the XhrIo wrapper. - */ -export declare enum ErrorCode { - NO_ERROR = 0, - NETWORK_ERROR = 1, - ABORT = 2 -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/constants.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/constants.d.ts deleted file mode 100644 index 957b4d6..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/constants.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -export declare const DEFAULT_HOST = "firebasestorage.googleapis.com"; -/** - * The key in Firebase config json for the storage bucket. - */ -export declare const CONFIG_STORAGE_BUCKET_KEY = "storageBucket"; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -export declare const DEFAULT_MAX_OPERATION_RETRY_TIME: number; -/** - * 10 minutes - * - * The timeout for upload. - */ -export declare const DEFAULT_MAX_UPLOAD_RETRY_TIME: number; -/** - * 1 second - */ -export declare const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; -/** - * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported - * enough for us to use it directly. - */ -export declare const MIN_SAFE_INTEGER = -9007199254740991; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/error.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/error.d.ts deleted file mode 100644 index dfc0884..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/error.d.ts +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FirebaseError } from '@firebase/util'; -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -export declare class StorageError extends FirebaseError { - private status_; - private readonly _baseMessage; - /** - * Stores custom error data unique to the `StorageError`. - */ - customData: { - serverResponse: string | null; - }; - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code: StorageErrorCode, message: string, status_?: number); - get status(): number; - set status(status: number); - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code: StorageErrorCode): boolean; - /** - * Optional response message that was added by the server. - */ - get serverResponse(): null | string; - set serverResponse(serverResponse: string | null); -} -export declare const errors: {}; -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -export declare enum StorageErrorCode { - UNKNOWN = "unknown", - OBJECT_NOT_FOUND = "object-not-found", - BUCKET_NOT_FOUND = "bucket-not-found", - PROJECT_NOT_FOUND = "project-not-found", - QUOTA_EXCEEDED = "quota-exceeded", - UNAUTHENTICATED = "unauthenticated", - UNAUTHORIZED = "unauthorized", - UNAUTHORIZED_APP = "unauthorized-app", - RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded", - INVALID_CHECKSUM = "invalid-checksum", - CANCELED = "canceled", - INVALID_EVENT_NAME = "invalid-event-name", - INVALID_URL = "invalid-url", - INVALID_DEFAULT_BUCKET = "invalid-default-bucket", - NO_DEFAULT_BUCKET = "no-default-bucket", - CANNOT_SLICE_BLOB = "cannot-slice-blob", - SERVER_FILE_WRONG_SIZE = "server-file-wrong-size", - NO_DOWNLOAD_URL = "no-download-url", - INVALID_ARGUMENT = "invalid-argument", - INVALID_ARGUMENT_COUNT = "invalid-argument-count", - APP_DELETED = "app-deleted", - INVALID_ROOT_OPERATION = "invalid-root-operation", - INVALID_FORMAT = "invalid-format", - INTERNAL_ERROR = "internal-error", - UNSUPPORTED_ENVIRONMENT = "unsupported-environment" -} -export declare function prependCode(code: StorageErrorCode): string; -export declare function unknown(): StorageError; -export declare function objectNotFound(path: string): StorageError; -export declare function bucketNotFound(bucket: string): StorageError; -export declare function projectNotFound(project: string): StorageError; -export declare function quotaExceeded(bucket: string): StorageError; -export declare function unauthenticated(): StorageError; -export declare function unauthorizedApp(): StorageError; -export declare function unauthorized(path: string): StorageError; -export declare function retryLimitExceeded(): StorageError; -export declare function invalidChecksum(path: string, checksum: string, calculated: string): StorageError; -export declare function canceled(): StorageError; -export declare function invalidEventName(name: string): StorageError; -export declare function invalidUrl(url: string): StorageError; -export declare function invalidDefaultBucket(bucket: string): StorageError; -export declare function noDefaultBucket(): StorageError; -export declare function cannotSliceBlob(): StorageError; -export declare function serverFileWrongSize(): StorageError; -export declare function noDownloadURL(): StorageError; -export declare function missingPolyFill(polyFill: string): StorageError; -/** - * @internal - */ -export declare function invalidArgument(message: string): StorageError; -export declare function invalidArgumentCount(argMin: number, argMax: number, fnName: string, real: number): StorageError; -export declare function appDeleted(): StorageError; -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -export declare function invalidRootOperation(name: string): StorageError; -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -export declare function invalidFormat(format: string, message: string): StorageError; -/** - * @param message - A message describing the internal error. - */ -export declare function unsupportedEnvironment(message: string): StorageError; -/** - * @param message - A message describing the internal error. - */ -export declare function internalError(message: string): StorageError; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/failrequest.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/failrequest.d.ts deleted file mode 100644 index 89d079c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/failrequest.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageError } from './error'; -import { Request } from './request'; -/** - * A request whose promise always fails. - */ -export declare class FailRequest<T> implements Request<T> { - promise_: Promise<T>; - constructor(error: StorageError); - /** @inheritDoc */ - getPromise(): Promise<T>; - /** @inheritDoc */ - cancel(_appDelete?: boolean): void; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/fs.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/fs.d.ts deleted file mode 100644 index 30cd68d..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/fs.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -export declare function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob; -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -export declare function sliceBlob(blob: Blob, start: number, end: number): Blob | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/json.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/json.d.ts deleted file mode 100644 index 58151dc..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/json.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -export declare function jsonObjectOrNull(s: string): { - [name: string]: unknown; -} | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/list.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/list.d.ts deleted file mode 100644 index 9107503..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/list.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { ListResult } from '../list'; -import { FirebaseStorageImpl } from '../service'; -export declare function fromResponseString(service: FirebaseStorageImpl, bucket: string, resourceString: string): ListResult | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/location.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/location.d.ts deleted file mode 100644 index f6e1ab6..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/location.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -export declare class Location { - readonly bucket: string; - private path_; - constructor(bucket: string, path: string); - get path(): string; - get isRoot(): boolean; - fullServerUrl(): string; - bucketOnlyServerUrl(): string; - static makeFromBucketSpec(bucketString: string, host: string): Location; - static makeFromUrl(url: string, host: string): Location; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/metadata.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/metadata.d.ts deleted file mode 100644 index fadfd35..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/metadata.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Documentation for the metadata format - */ -import { Metadata } from '../metadata'; -import { FirebaseStorageImpl } from '../service'; -export declare function noXform_<T>(metadata: Metadata, value: T): T; -declare class Mapping<T> { - server: string; - local: string; - writable: boolean; - xform: (p1: Metadata, p2?: T) => T | undefined; - constructor(server: string, local?: string | null, writable?: boolean, xform?: ((p1: Metadata, p2?: T) => T | undefined) | null); -} -type Mappings = Array<Mapping<string> | Mapping<number>>; -export { Mappings }; -export declare function xformPath(fullPath: string | undefined): string | undefined; -export declare function getMappings(): Mappings; -export declare function addRef(metadata: Metadata, service: FirebaseStorageImpl): void; -export declare function fromResource(service: FirebaseStorageImpl, resource: { - [name: string]: unknown; -}, mappings: Mappings): Metadata; -export declare function fromResourceString(service: FirebaseStorageImpl, resourceString: string, mappings: Mappings): Metadata | null; -export declare function downloadUrlFromResourceString(metadata: Metadata, resourceString: string, host: string, protocol: string): string | null; -export declare function toResourceString(metadata: Partial<Metadata>, mappings: Mappings): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/observer.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/observer.d.ts deleted file mode 100644 index 0702651..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/observer.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { StorageError } from './error'; -/** - * Function that is called once for each value in a stream of values. - */ -export type NextFn<T> = (value: T) => void; -/** - * A function that is called with a `StorageError` - * if the event stream ends due to an error. - */ -export type ErrorFn = (error: StorageError) => void; -/** - * A function that is called if the event stream ends normally. - */ -export type CompleteFn = () => void; -/** - * Unsubscribes from a stream. - */ -export type Unsubscribe = () => void; -/** - * An observer identical to the `Observer` defined in packages/util except the - * error passed into the ErrorFn is specifically a `StorageError`. - */ -export interface StorageObserver<T> { - /** - * Function that is called once for each value in the event stream. - */ - next?: NextFn<T>; - /** - * A function that is called with a `StorageError` - * if the event stream ends due to an error. - */ - error?: ErrorFn; - /** - * A function that is called if the event stream ends normally. - */ - complete?: CompleteFn; -} -/** - * Subscribes to an event stream. - */ -export type Subscribe<T> = (next?: NextFn<T> | StorageObserver<T>, error?: ErrorFn, complete?: CompleteFn) => Unsubscribe; -export declare class Observer<T> implements StorageObserver<T> { - next?: NextFn<T>; - error?: ErrorFn; - complete?: CompleteFn; - constructor(nextOrObserver?: NextFn<T> | StorageObserver<T>, error?: ErrorFn, complete?: CompleteFn); -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/path.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/path.d.ts deleted file mode 100644 index f566805..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/path.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -export declare function parent(path: string): string | null; -export declare function child(path: string, childPath: string): string; -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -export declare function lastComponent(path: string): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/request.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/request.d.ts deleted file mode 100644 index 1b01a28..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/request.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { RequestInfo } from './requestinfo'; -import { Connection, Headers, ConnectionType } from './connection'; -export interface Request<T> { - getPromise(): Promise<T>; - /** - * Cancels the request. IMPORTANT: the promise may still be resolved with an - * appropriate value (if the request is finished before you call this method, - * but the promise has not yet been resolved), so don't just assume it will be - * rejected if you call this function. - * @param appDelete - True if the cancelation came from the app being deleted. - */ - cancel(appDelete?: boolean): void; -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -export declare class RequestEndStatus<I extends ConnectionType> { - wasSuccessCode: boolean; - connection: Connection<I> | null; - /** - * True if the request was canceled. - */ - canceled: boolean; - constructor(wasSuccessCode: boolean, connection: Connection<I> | null, canceled?: boolean); -} -export declare function addAuthHeader_(headers: Headers, authToken: string | null): void; -export declare function addVersionHeader_(headers: Headers, firebaseVersion?: string): void; -export declare function addGmpidHeader_(headers: Headers, appId: string | null): void; -export declare function addAppCheckHeader_(headers: Headers, appCheckToken: string | null): void; -export declare function makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection<I>, firebaseVersion?: string, retry?: boolean, isUsingEmulator?: boolean): Request<O>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/requestinfo.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/requestinfo.d.ts deleted file mode 100644 index fec97c9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/requestinfo.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageError } from './error'; -import { Headers, Connection, ConnectionType } from './connection'; -/** - * Type for url params stored in RequestInfo. - */ -export interface UrlParams { - [name: string]: string | number; -} -/** - * A function that converts a server response to the API type expected by the - * SDK. - * - * @param I - the type of the backend's network response - * @param O - the output response type used by the rest of the SDK. - */ -export type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O; -/** A function to handle an error. */ -export type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError) => StorageError; -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -export declare class RequestInfo<I extends ConnectionType, O> { - url: string; - method: string; - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler: RequestHandler<I, O>; - timeout: number; - urlParams: UrlParams; - headers: Headers; - body: Blob | string | Uint8Array | null; - errorHandler: ErrorHandler | null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - progressCallback: ((p1: number, p2: number) => void) | null; - successCodes: number[]; - additionalRetryCodes: number[]; - constructor(url: string, method: string, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler: RequestHandler<I, O>, timeout: number); -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/requests.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/requests.d.ts deleted file mode 100644 index a019496..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/requests.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Defines methods for interacting with the network. - */ -import { Metadata } from '../metadata'; -import { ListResult } from '../list'; -import { FbsBlob } from './blob'; -import { StorageError } from './error'; -import { Location } from './location'; -import { Mappings } from './metadata'; -import { RequestInfo } from './requestinfo'; -import { Connection, ConnectionType } from './connection'; -import { FirebaseStorageImpl } from '../service'; -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -export declare function handlerCheck(cndn: boolean): void; -export declare function metadataHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection<string>, p2: string) => Metadata; -export declare function listHandler(service: FirebaseStorageImpl, bucket: string): (p1: Connection<string>, p2: string) => ListResult; -export declare function downloadUrlHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection<string>, p2: string) => string | null; -export declare function sharedErrorHandler(location: Location): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError; -export declare function objectErrorHandler(location: Location): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError; -export declare function getMetadata(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<string, Metadata>; -export declare function list(service: FirebaseStorageImpl, location: Location, delimiter?: string, pageToken?: string | null, maxResults?: number | null): RequestInfo<string, ListResult>; -export declare function getBytes<I extends ConnectionType>(service: FirebaseStorageImpl, location: Location, maxDownloadSizeBytes?: number): RequestInfo<I, I>; -export declare function getDownloadUrl(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<string, string | null>; -export declare function updateMetadata(service: FirebaseStorageImpl, location: Location, metadata: Partial<Metadata>, mappings: Mappings): RequestInfo<string, Metadata>; -export declare function deleteObject(service: FirebaseStorageImpl, location: Location): RequestInfo<string, void>; -export declare function determineContentType_(metadata: Metadata | null, blob: FbsBlob | null): string; -export declare function metadataForUpload_(location: Location, blob: FbsBlob, metadata?: Metadata | null): Metadata; -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -export declare function multipartUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string, Metadata>; -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -export declare class ResumableUploadStatus { - current: number; - total: number; - finalized: boolean; - metadata: Metadata | null; - constructor(current: number, total: number, finalized?: boolean, metadata?: Metadata | null); -} -export declare function checkResumeHeader_(xhr: Connection<string>, allowed?: string[]): string; -export declare function createResumableUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string, string>; -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -export declare function getResumableUploadStatus(service: FirebaseStorageImpl, location: Location, url: string, blob: FbsBlob): RequestInfo<string, ResumableUploadStatus>; -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -export declare const RESUMABLE_UPLOAD_CHUNK_SIZE: number; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -export declare function continueResumableUpload(location: Location, service: FirebaseStorageImpl, url: string, blob: FbsBlob, chunkSize: number, mappings: Mappings, status?: ResumableUploadStatus | null, progressCallback?: ((p1: number, p2: number) => void) | null): RequestInfo<string, ResumableUploadStatus>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/string.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/string.d.ts deleted file mode 100644 index 0549cf9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/string.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export type StringFormat = (typeof StringFormat)[keyof typeof StringFormat]; -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export declare const StringFormat: { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - readonly RAW: "raw"; - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64: "base64"; - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64URL: "base64url"; - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - readonly DATA_URL: "data_url"; -}; -export declare class StringData { - data: Uint8Array; - contentType: string | null; - constructor(data: Uint8Array, contentType?: string | null); -} -/** - * @internal - */ -export declare function dataFromString(format: StringFormat, stringData: string): StringData; -export declare function utf8Bytes_(value: string): Uint8Array; -export declare function percentEncodedBytes_(value: string): Uint8Array; -export declare function base64Bytes_(format: StringFormat, value: string): Uint8Array; -export declare function dataURLBytes_(dataUrl: string): Uint8Array; -export declare function dataURLContentType_(dataUrl: string): string | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/taskenums.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/taskenums.d.ts deleted file mode 100644 index 6c6d880..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/taskenums.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Enumerations used for upload tasks. - */ -/** - * An event that is triggered on a task. - * @internal - */ -export type TaskEvent = string; -/** - * An event that is triggered on a task. - * @internal - */ -export declare const TaskEvent: { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: string; -}; -/** - * Internal enum for task state. - */ -export declare const enum InternalTaskState { - RUNNING = "running", - PAUSING = "pausing", - PAUSED = "paused", - SUCCESS = "success", - CANCELING = "canceling", - CANCELED = "canceled", - ERROR = "error" -} -/** - * Represents the current state of a running upload. - * @internal - */ -export type TaskState = (typeof TaskState)[keyof typeof TaskState]; -/** - * Represents the current state of a running upload. - * @internal - */ -export declare const TaskState: { - /** The task is currently transferring data. */ - readonly RUNNING: "running"; - /** The task was paused by the user. */ - readonly PAUSED: "paused"; - /** The task completed successfully. */ - readonly SUCCESS: "success"; - /** The task was canceled. */ - readonly CANCELED: "canceled"; - /** The task failed with an error. */ - readonly ERROR: "error"; -}; -export declare function taskStateFromInternalTaskState(state: InternalTaskState): TaskState; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/type.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/type.d.ts deleted file mode 100644 index ed70cc9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/type.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export declare function isJustDef<T>(p: T | null | undefined): p is T | null; -export declare function isFunction(p: unknown): p is Function; -export declare function isNonArrayObject(p: unknown): boolean; -export declare function isString(p: unknown): p is string; -export declare function isNativeBlob(p: unknown): p is Blob; -export declare function isNativeBlobDefined(): boolean; -export declare function validateNumber(argument: string, minValue: number, maxValue: number, value: number): void; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/url.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/url.d.ts deleted file mode 100644 index caf7f3c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/url.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Functions to create and manipulate URLs for the server API. - */ -import { UrlParams } from './requestinfo'; -export declare function makeUrl(urlPart: string, host: string, protocol: string): string; -export declare function makeQueryString(params: UrlParams): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/utils.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/utils.d.ts deleted file mode 100644 index b91f9dc..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/implementation/utils.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -export declare function isRetryStatusCode(status: number, additionalRetryCodes: number[]): boolean; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/index.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/index.d.ts deleted file mode 100644 index 62b1e67..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -export * from './api'; -export * from './api.browser'; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/index.node.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/index.node.d.ts deleted file mode 100644 index 2f613cd..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/index.node.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -export * from './api'; -export * from './api.node'; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/list.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/list.d.ts deleted file mode 100644 index 1f015e5..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/list.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Reference } from './reference'; -/** - * Result returned by `list()`. - * @public - */ -export interface ListResult { - /** - * References to prefixes (sub-folders). You can call list() on them to - * get its contents. - * - * Folders are implicit based on '/' in the object paths. - * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') - * will return '/a/b' as a prefix. - */ - prefixes: Reference[]; - /** - * Objects in this directory. - * You can call getMetadata() and getDownloadUrl() on them. - */ - items: Reference[]; - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken?: string; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/metadata.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/metadata.d.ts deleted file mode 100644 index 48fa64f..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/metadata.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FullMetadata } from './public-types'; -/** - * @fileoverview Documentation for the metadata format. - */ -/** - * The full set of object metadata, including read-only properties. - */ -interface Metadata extends FullMetadata { - [prop: string]: unknown; -} -export { Metadata }; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/base64.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/base64.d.ts deleted file mode 100644 index 7dac903..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/base64.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -export declare function decodeBase64(encoded: string): string; -/** Converts a Uint8Array to a string. */ -export declare function decodeUint8Array(data: Uint8Array): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/browser/base64.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/browser/base64.d.ts deleted file mode 100644 index 23c84f2..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/browser/base64.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -export declare function decodeBase64(encoded: string): string; -export declare function decodeUint8Array(data: Uint8Array): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/browser/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/browser/connection.d.ts deleted file mode 100644 index 14415da..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/browser/connection.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Connection, ConnectionType, ErrorCode, Headers } from '../../implementation/connection'; -/** - * Network layer for browsers. We use this instead of goog.net.XhrIo because - * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android. - */ -declare abstract class XhrConnection<T extends ConnectionType> implements Connection<T> { - protected xhr_: XMLHttpRequest; - private errorCode_; - private sendPromise_; - protected sent_: boolean; - constructor(); - abstract initXhr(): void; - send(url: string, method: string, isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string, headers?: Headers): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): T; - getErrorText(): string; - /** Aborts the request. */ - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} -export declare class XhrTextConnection extends XhrConnection<string> { - initXhr(): void; -} -export declare function newTextConnection(): Connection<string>; -export declare class XhrBytesConnection extends XhrConnection<ArrayBuffer> { - private data_?; - initXhr(): void; -} -export declare function newBytesConnection(): Connection<ArrayBuffer>; -export declare class XhrBlobConnection extends XhrConnection<Blob> { - initXhr(): void; -} -export declare function newBlobConnection(): Connection<Blob>; -export declare function newStreamConnection(): Connection<ReadableStream>; -export declare function injectTestConnection(factory: (() => Connection<string>) | null): void; -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/connection.d.ts deleted file mode 100644 index 72ed64b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/connection.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Connection } from '../implementation/connection'; -export declare function injectTestConnection(factory: (() => Connection<string>) | null): void; -export declare function newTextConnection(): Connection<string>; -export declare function newBytesConnection(): Connection<ArrayBuffer>; -export declare function newBlobConnection(): Connection<Blob>; -export declare function newStreamConnection(): Connection<ReadableStream<Uint8Array>>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/node/base64.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/node/base64.d.ts deleted file mode 100644 index 23c84f2..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/node/base64.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -export declare function decodeBase64(encoded: string): string; -export declare function decodeUint8Array(data: Uint8Array): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/node/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/node/connection.d.ts deleted file mode 100644 index a4e71fa..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/platform/node/connection.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Connection, ConnectionType, ErrorCode } from '../../implementation/connection'; -/** - * Network layer that works in Node. - * - * This network implementation should not be used in browsers as it does not - * support progress updates. - */ -declare abstract class FetchConnection<T extends ConnectionType> implements Connection<T> { - protected errorCode_: ErrorCode; - protected statusCode_: number | undefined; - protected body_: ArrayBuffer | undefined; - protected errorText_: string; - protected headers_: Headers | undefined; - protected sent_: boolean; - constructor(); - send(url: string, method: string, isUsingEmulator: boolean, body?: NodeJS.ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - abstract getResponse(): T; - getErrorText(): string; - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} -export declare class FetchTextConnection extends FetchConnection<string> { - getResponse(): string; -} -export declare function newTextConnection(): Connection<string>; -export declare class FetchBytesConnection extends FetchConnection<ArrayBuffer> { - getResponse(): ArrayBuffer; -} -export declare function newBytesConnection(): Connection<ArrayBuffer>; -export declare class FetchStreamConnection extends FetchConnection<ReadableStream<Uint8Array>> { - private stream_; - send(url: string, method: string, isUsingEmulator: boolean, body?: NodeJS.ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>; - getResponse(): ReadableStream; -} -export declare function newStreamConnection(): Connection<ReadableStream<Uint8Array>>; -export declare function newBlobConnection(): Connection<Blob>; -export declare function injectTestConnection(factory: (() => Connection<string>) | null): void; -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/public-types.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/public-types.d.ts deleted file mode 100644 index 033bd3c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/public-types.d.ts +++ /dev/null @@ -1,424 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FirebaseApp, _FirebaseService } from '@firebase/app'; -import { CompleteFn, NextFn, Subscribe, Unsubscribe } from '@firebase/util'; -import { StorageError } from './implementation/error'; -/** - * A Firebase Storage instance. - * @public - */ -export interface FirebaseStorage extends _FirebaseService { - /** - * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance. - */ - readonly app: FirebaseApp; - /** - * The maximum time to retry uploads in milliseconds. - */ - maxUploadRetryTime: number; - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - maxOperationRetryTime: number; -} -/** - * Represents a reference to a Google Cloud Storage object. Developers can - * upload, download, and delete objects, as well as get/set object metadata. - * @public - */ -export interface StorageReference { - /** - * Returns a gs:// URL for this object in the form - * `gs://<bucket>/<path>/<to>/<object>` - * @returns The gs:// URL. - */ - toString(): string; - /** - * A reference to the root of this object's bucket. - */ - root: StorageReference; - /** - * The name of the bucket containing this reference's object. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The {@link FirebaseStorage} instance associated with this reference. - */ - storage: FirebaseStorage; - /** - * A reference pointing to the parent location of this reference, or null if - * this reference is the root. - */ - parent: StorageReference | null; -} -/** - * The options `list()` accepts. - * @public - */ -export interface ListOptions { - /** - * If set, limits the total number of `prefixes` and `items` to return. - * The default and maximum maxResults is 1000. - */ - maxResults?: number | null; - /** - * The `nextPageToken` from a previous call to `list()`. If provided, - * listing is resumed from the previous position. - */ - pageToken?: string | null; -} -/** - * Result returned by list(). - * @public - */ -export interface ListResult { - /** - * References to prefixes (sub-folders). You can call list() on them to - * get its contents. - * - * Folders are implicit based on '/' in the object paths. - * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') - * will return '/a/b' as a prefix. - */ - prefixes: StorageReference[]; - /** - * Objects in this directory. - * You can call getMetadata() and getDownloadUrl() on them. - */ - items: StorageReference[]; - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken?: string; -} -/** - * Object metadata that can be set at any time. - * @public - */ -export interface SettableMetadata { - /** - * Served as the 'Cache-Control' header on object download. - */ - cacheControl?: string | undefined; - /** - * Served as the 'Content-Disposition' header on object download. - */ - contentDisposition?: string | undefined; - /** - * Served as the 'Content-Encoding' header on object download. - */ - contentEncoding?: string | undefined; - /** - * Served as the 'Content-Language' header on object download. - */ - contentLanguage?: string | undefined; - /** - * Served as the 'Content-Type' header on object download. - */ - contentType?: string | undefined; - /** - * Additional user-defined custom metadata. - */ - customMetadata?: { - [key: string]: string; - } | undefined; -} -/** - * Object metadata that can be set at upload. - * @public - */ -export interface UploadMetadata extends SettableMetadata { - /** - * A Base64-encoded MD5 hash of the object being uploaded. - */ - md5Hash?: string | undefined; -} -/** - * The full set of object metadata, including read-only properties. - * @public - */ -export interface FullMetadata extends UploadMetadata { - /** - * The bucket this object is contained in. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The object's generation. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - generation: string; - /** - * The object's metageneration. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - metageneration: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The size of this object, in bytes. - */ - size: number; - /** - * A date string representing when this object was created. - */ - timeCreated: string; - /** - * A date string representing when this object was last updated. - */ - updated: string; - /** - * Tokens to allow access to the download URL. - */ - downloadTokens: string[] | undefined; - /** - * `StorageReference` associated with this upload. - */ - ref?: StorageReference | undefined; -} -/** - * An event that is triggered on a task. - * @public - */ -export type TaskEvent = 'state_changed'; -/** - * Represents the current state of a running upload. - * @public - */ -export type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error'; -/** - * A stream observer for Firebase Storage. - * @public - */ -export interface StorageObserver<T> { - next?: NextFn<T> | null; - error?: (error: StorageError) => void | null; - complete?: CompleteFn | null; -} -/** - * Represents the process of uploading an object. Allows you to monitor and - * manage the upload. - * @public - */ -export interface UploadTask { - /** - * Cancels a running task. Has no effect on a complete or failed task. - * @returns True if the cancel had an effect. - */ - cancel(): boolean; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected: (error: StorageError) => unknown): Promise<unknown>; - /** - * Listens for events on this task. - * - * Events have three callback functions (referred to as `next`, `error`, and - * `complete`). - * - * If only the event is passed, a function that can be used to register the - * callbacks is returned. Otherwise, the callbacks are passed after the event. - * - * Callbacks can be passed either as three separate arguments <em>or</em> as the - * `next`, `error`, and `complete` properties of an object. Any of the three - * callbacks is optional, as long as at least one is specified. In addition, - * when you add your callbacks, you get a function back. You can call this - * function to unregister the associated callbacks. - * - * @example **Pass callbacks separately or in an object.** - * ```javascript - * var next = function(snapshot) {}; - * var error = function(error) {}; - * var complete = function() {}; - * - * // The first example. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * next, - * error, - * complete); - * - * // This is equivalent to the first example. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe(next, error, complete); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe({ - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * ``` - * - * @example **Any callback is optional.** - * ```javascript - * // Just listening for completion, this is legal. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * null, - * null, - * function() { - * console.log('upload complete!'); - * }); - * - * // Just listening for progress/state changes, this is legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * }); - * - * // This is also legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'complete': function() { - * console.log('upload complete!'); - * } - * }); - * ``` - * - * @example **Use the returned function to remove callbacks.** - * ```javascript - * var unsubscribe = uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * - * // This code is equivalent to the above. - * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * unsubscribe = handle(function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * ``` - * - * @param event - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * A snapshot of the current task state. - */ - snapshot: UploadTaskSnapshot; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>; -} -/** - * Holds data about the current state of the upload task. - * @public - */ -export interface UploadTaskSnapshot { - /** - * The number of bytes that have been successfully uploaded so far. - */ - bytesTransferred: number; - /** - * Before the upload completes, contains the metadata sent to the server. - * After the upload completes, contains the metadata sent back from the server. - */ - metadata: FullMetadata; - /** - * The reference that spawned this snapshot's upload task. - */ - ref: StorageReference; - /** - * The current state of the task. - */ - state: TaskState; - /** - * The task of which this is a snapshot. - */ - task: UploadTask; - /** - * The total number of bytes to be uploaded. - */ - totalBytes: number; -} -/** - * Result returned from a non-resumable upload. - * @public - */ -export interface UploadResult { - /** - * Contains the metadata sent back from the server. - */ - readonly metadata: FullMetadata; - /** - * The reference that spawned this upload. - */ - readonly ref: StorageReference; -} -declare module '@firebase/component' { - interface NameServiceMapping { - 'storage': FirebaseStorage; - } -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/reference.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/reference.d.ts deleted file mode 100644 index 68e93d7..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/reference.d.ts +++ /dev/null @@ -1,208 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Location } from './implementation/location'; -import { ListOptions, UploadResult } from './public-types'; -import { StringFormat } from './implementation/string'; -import { Metadata } from './metadata'; -import { FirebaseStorageImpl } from './service'; -import { ListResult } from './list'; -import { UploadTask } from './task'; -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -export declare class Reference { - private _service; - _location: Location; - constructor(_service: FirebaseStorageImpl, location: string | Location); - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString(): string; - protected _newRef(service: FirebaseStorageImpl, location: Location): Reference; - /** - * A reference to the root of this object's bucket. - */ - get root(): Reference; - /** - * The name of the bucket containing this reference's object. - */ - get bucket(): string; - /** - * The full path of this object. - */ - get fullPath(): string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name(): string; - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage(): FirebaseStorageImpl; - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent(): Reference | null; - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name: string): void; -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -export declare function getBytesInternal(ref: Reference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded blob. - */ -export declare function getBlobInternal(ref: Reference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** Stream the bytes at the object's location. */ -export declare function getStreamInternal(ref: Reference, maxDownloadSizeBytes?: number): ReadableStream; -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -export declare function uploadBytes(ref: Reference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): Promise<UploadResult>; -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -export declare function uploadBytesResumable(ref: Reference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): UploadTask; -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -export declare function uploadString(ref: Reference, value: string, format?: StringFormat, metadata?: Metadata): Promise<UploadResult>; -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -export declare function listAll(ref: Reference): Promise<ListResult>; -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -export declare function list(ref: Reference, options?: ListOptions | null): Promise<ListResult>; -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -export declare function getMetadata(ref: Reference): Promise<Metadata>; -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -export declare function updateMetadata(ref: Reference, metadata: Partial<Metadata>): Promise<Metadata>; -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -export declare function getDownloadURL(ref: Reference): Promise<string>; -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -export declare function deleteObject(ref: Reference): Promise<void>; -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -export declare function _getChild(ref: Reference, childPath: string): Reference; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/service.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/service.d.ts deleted file mode 100644 index 5dd6bb0..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/service.d.ts +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Location } from './implementation/location'; -import { Request } from './implementation/request'; -import { RequestInfo } from './implementation/requestinfo'; -import { Reference } from './reference'; -import { Provider } from '@firebase/component'; -import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; -import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; -import { FirebaseApp } from '@firebase/app'; -import { FirebaseStorage } from './public-types'; -import { EmulatorMockTokenOptions } from '@firebase/util'; -import { Connection, ConnectionType } from './implementation/connection'; -export declare function isUrl(path?: string): boolean; -/** - * Returns a storage Reference for the given url. - * @param storage - `Storage` instance. - * @param url - URL. If empty, returns root reference. - * @public - */ -export declare function ref(storage: FirebaseStorageImpl, url?: string): Reference; -/** - * Returns a storage Reference for the given path in the - * default bucket. - * @param storageOrRef - `Storage` service or storage `Reference`. - * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage - * instance provided) or returns same reference (if Reference provided). - * @public - */ -export declare function ref(storageOrRef: FirebaseStorageImpl | Reference, path?: string): Reference; -export declare function connectStorageEmulator(storage: FirebaseStorageImpl, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -export declare class FirebaseStorageImpl implements FirebaseStorage { - /** - * FirebaseApp associated with this StorageService instance. - */ - readonly app: FirebaseApp; - readonly _authProvider: Provider<FirebaseAuthInternalName>; - /** - * @internal - */ - readonly _appCheckProvider: Provider<AppCheckInternalComponentName>; - /** - * @internal - */ - readonly _url?: string | undefined; - readonly _firebaseVersion?: string | undefined; - _isUsingEmulator: boolean; - _bucket: Location | null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - private _host; - _protocol: string; - protected readonly _appId: string | null; - private readonly _requests; - private _deleted; - private _maxOperationRetryTime; - private _maxUploadRetryTime; - _overrideAuthToken?: string; - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>, - /** - * @internal - */ - _appCheckProvider: Provider<AppCheckInternalComponentName>, - /** - * @internal - */ - _url?: string | undefined, _firebaseVersion?: string | undefined, _isUsingEmulator?: boolean); - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host(): string; - set host(host: string); - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime(): number; - set maxUploadRetryTime(time: number); - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime(): number; - set maxOperationRetryTime(time: number); - _getAuthToken(): Promise<string | null>; - _getAppCheckToken(): Promise<string | null>; - /** - * Stop running requests and prevent more from being created. - */ - _delete(): Promise<void>; - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc: Location): Reference; - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request<O>; - makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>): Promise<O>; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/task.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/task.d.ts deleted file mode 100644 index 19afdfd..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/src/task.d.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Defines types for interacting with blob transfer tasks. - */ -import { FbsBlob } from './implementation/blob'; -import { StorageError } from './implementation/error'; -import { InternalTaskState, TaskEvent } from './implementation/taskenums'; -import { Metadata } from './metadata'; -import { Subscribe, Unsubscribe } from './implementation/observer'; -import { UploadTaskSnapshot, StorageObserver } from './public-types'; -import { Reference } from './reference'; -import { CompleteFn } from '@firebase/util'; -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -export declare class UploadTask { - private _ref; - /** - * The data to be uploaded. - */ - _blob: FbsBlob; - /** - * Metadata related to the upload. - */ - _metadata: Metadata | null; - private _mappings; - /** - * Number of bytes transferred so far. - */ - _transferred: number; - private _needToFetchStatus; - private _needToFetchMetadata; - private _observers; - private _resumable; - /** - * Upload state. - */ - _state: InternalTaskState; - private _error?; - private _uploadUrl?; - private _request?; - private _chunkMultiplier; - private _errorHandler; - private _metadataErrorHandler; - private _resolve?; - private _reject?; - private pendingTimeout?; - private _promise; - private sleepTime; - private maxSleepTime; - isExponentialBackoffExpired(): boolean; - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref: Reference, blob: FbsBlob, metadata?: Metadata | null); - private _makeProgressCallback; - private _shouldDoResumable; - private _start; - private _resolveToken; - private _createResumable; - private _fetchStatus; - private _continueUpload; - private _increaseMultiplier; - private _fetchMetadata; - private _oneShotUpload; - private _updateProgress; - private _transition; - private completeTransitions_; - /** - * A snapshot of the current task state. - */ - get snapshot(): UploadTaskSnapshot; - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe | Subscribe<UploadTaskSnapshot>; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>; - /** - * Adds the given observer. - */ - private _addObserver; - /** - * Removes the given observer. - */ - private _removeObserver; - private _notifyObservers; - private _finishPromise; - private _notifyObserver; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel(): boolean; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/test/unit/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/test/unit/connection.d.ts deleted file mode 100644 index 47fe45b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/test/unit/connection.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { ErrorCode, Headers, Connection } from '../../src/implementation/connection'; -export type SendHook = (connection: TestingConnection, url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => void; -export declare enum State { - START = 0, - SENT = 1, - DONE = 2 -} -export declare class TestingConnection implements Connection<string> { - private state; - private sendPromise; - private resolve; - private sendHook; - private status; - private responseText; - private headers; - private errorCode; - constructor(sendHook: SendHook | null); - send(url: string, method: string, _isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>; - simulateResponse(status: number, body: string, headers: { - [key: string]: string; - }): void; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): string; - getErrorText(): string; - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(): void; - removeUploadProgressListener(): void; -} -export declare function newTestConnection(sendHook?: SendHook | null): Connection<string>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/node-esm/test/unit/testshared.d.ts b/frontend-old/node_modules/@firebase/storage/dist/node-esm/test/unit/testshared.d.ts deleted file mode 100644 index b267049..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/node-esm/test/unit/testshared.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { FirebaseApp } from '@firebase/app-types'; -import { StorageError } from '../../src/implementation/error'; -import { Headers, Connection, ConnectionType } from '../../src/implementation/connection'; -import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; -import { Provider } from '@firebase/component'; -import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; -import { FirebaseStorageImpl } from '../../src/service'; -import { Metadata } from '../../src/metadata'; -export declare const authToken = "totally-legit-auth-token"; -export declare const appCheckToken = "totally-shady-token"; -export declare const bucket = "mybucket"; -export declare const fakeApp: FirebaseApp; -export declare const fakeAuthProvider: Provider<"auth-internal">; -export declare const emptyAuthProvider: Provider<"auth-internal">; -export declare const fakeAppCheckTokenProvider: Provider<"app-check-internal">; -export declare function makeFakeApp(bucketArg?: string): FirebaseApp; -export declare function makeFakeAuthProvider(token: { - accessToken: string; -}): Provider<FirebaseAuthInternalName>; -export declare function makeFakeAppCheckProvider(tokenResult: { - token: string; -}): Provider<AppCheckInternalComponentName>; -/** - * Returns something that looks like an fbs.XhrIo with the given headers - * and status. - */ -export declare function fakeXhrIo<I extends ConnectionType = string>(headers: Headers, status?: number): Connection<I>; -/** - * Binds ignoring types. Used to test calls involving improper arguments. - */ -export declare function bind(f: Function, ctx: any, ...args: any[]): () => void; -export declare function assertThrows(f: () => void, code: string): StorageError; -export declare function assertUint8ArrayEquals(arr1: Uint8Array, arr2: Uint8Array): void; -export declare function assertObjectIncludes(included: { - [name: string]: any; -}, obj: { - [name: string]: any; -}): void; -interface Response { - status: number; - body: string; - headers: Headers; -} -export type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response; -export declare function storageServiceWithHandler(handler: RequestHandler, shouldResponseCb?: () => boolean): FirebaseStorageImpl; -export declare function fakeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler; -/** - * Responds with a 503 for finalize. - * @param fakeMetadata metadata to respond with for finalize - * @returns a handler for requests - */ -export declare function fake503ForFinalizeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler; -/** - * Responds with a 503 for upload. - * @param fakeMetadata metadata to respond with for query - * @returns a handler for requests - */ -export declare function fake503ForUploadServerHandler(fakeMetadata?: Partial<Metadata>, cb?: () => void): RequestHandler; -export declare function fakeOneShot503ServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler; -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/api.browser.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/api.browser.d.ts deleted file mode 100644 index 00e4761..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/api.browser.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageReference } from './public-types'; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/api.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/api.d.ts deleted file mode 100644 index 3ba97cc..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/api.d.ts +++ /dev/null @@ -1,200 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FirebaseApp } from '@firebase/app'; -import { StorageReference, FirebaseStorage, UploadResult, ListOptions, ListResult, UploadTask, SettableMetadata, UploadMetadata, FullMetadata } from './public-types'; -import { Reference } from './reference'; -import { EmulatorMockTokenOptions } from '@firebase/util'; -import { StringFormat } from './implementation/string'; -export { EmulatorMockTokenOptions } from '@firebase/util'; -export { StorageError, StorageErrorCode } from './implementation/error'; -/** - * Public types. - */ -export * from './public-types'; -export { Location as _Location } from './implementation/location'; -export { UploadTask as _UploadTask } from './task'; -export type { Reference as _Reference } from './reference'; -export type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service'; -export { FbsBlob as _FbsBlob } from './implementation/blob'; -export { dataFromString as _dataFromString } from './implementation/string'; -export { invalidRootOperation as _invalidRootOperation, invalidArgument as _invalidArgument } from './implementation/error'; -export { TaskEvent as _TaskEvent, TaskState as _TaskState } from './implementation/taskenums'; -export { StringFormat }; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>; -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>; -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask; -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>; -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>; -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>; -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -export declare function listAll(ref: StorageReference): Promise<ListResult>; -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -export declare function getDownloadURL(ref: StorageReference): Promise<string>; -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -export declare function deleteObject(ref: StorageReference): Promise<void>; -/** - * Returns a {@link StorageReference} for the given url. - * @param storage - {@link FirebaseStorage} instance. - * @param url - URL. If empty, returns root reference. - * @public - */ -export declare function ref(storage: FirebaseStorage, url?: string): StorageReference; -/** - * Returns a {@link StorageReference} for the given path in the - * default bucket. - * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}. - * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage} - * instance provided) or returns same reference (if {@link StorageReference} provided). - * @public - */ -export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference; -/** - * @internal - */ -export declare function _getChild(ref: StorageReference, childPath: string): Reference; -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage; -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/api.node.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/api.node.d.ts deleted file mode 100644 index 00e4761..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/api.node.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageReference } from './public-types'; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/constants.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/constants.d.ts deleted file mode 100644 index c9c810f..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/constants.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Type constant for Firebase Storage. - */ -export declare const STORAGE_TYPE = "storage"; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/async.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/async.d.ts deleted file mode 100644 index 9d01868..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/async.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Returns a function that invokes f with its arguments asynchronously as a - * microtask, i.e. as soon as possible after the current script returns back - * into browser code. - */ -export declare function async(f: Function): Function; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/backoff.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/backoff.d.ts deleted file mode 100644 index 39ab9b7..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/backoff.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Provides a method for running a function with exponential - * backoff. - */ -type id = (p1: boolean) => void; -export { id }; -/** - * Accepts a callback for an action to perform (`doRequest`), - * and then a callback for when the backoff has completed (`backoffCompleteCb`). - * The callback sent to start requires an argument to call (`onRequestComplete`). - * When `start` calls `doRequest`, it passes a callback for when the request has - * completed, `onRequestComplete`. Based on this, the backoff continues, with - * another call to `doRequest` and the above loop continues until the timeout - * is hit, or a successful response occurs. - * @description - * @param doRequest Callback to perform request - * @param backoffCompleteCb Callback to call when backoff has been completed - */ -export declare function start(doRequest: (onRequestComplete: (success: boolean) => void, canceled: boolean) => void, backoffCompleteCb: (...args: any[]) => unknown, timeout: number): id; -/** - * Stops the retry loop from repeating. - * If the function is currently "in between" retries, it is invoked immediately - * with the second parameter as "true". Otherwise, it will be invoked once more - * after the current invocation finishes iff the current invocation would have - * triggered another retry. - */ -export declare function stop(id: id): void; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/blob.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/blob.d.ts deleted file mode 100644 index 419491b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/blob.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -export declare class FbsBlob { - private data_; - private size_; - private type_; - constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean); - size(): number; - type(): string; - slice(startByte: number, endByte: number): FbsBlob | null; - static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null; - uploadData(): Blob | Uint8Array; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/connection.d.ts deleted file mode 100644 index 269f2d9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/connection.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Network headers */ -export type Headers = Record<string, string>; -/** Response type exposed by the networking APIs. */ -export type ConnectionType = string | ArrayBuffer | Blob | ReadableStream<Uint8Array>; -/** - * A lightweight wrapper around XMLHttpRequest with a - * goog.net.XhrIo-like interface. - * - * You can create a new connection by invoking `newTextConnection()`, - * `newBytesConnection()` or `newStreamConnection()`. - */ -export interface Connection<T extends ConnectionType> { - /** - * Sends a request to the provided URL. - * - * This method never rejects its promise. In case of encountering an error, - * it sets an error code internally which can be accessed by calling - * getErrorCode() by callers. - */ - send(url: string, method: string, isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): T; - getErrorText(): string; - /** - * Abort the request. - */ - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} -/** - * Error codes for requests made by the XhrIo wrapper. - */ -export declare enum ErrorCode { - NO_ERROR = 0, - NETWORK_ERROR = 1, - ABORT = 2 -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/constants.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/constants.d.ts deleted file mode 100644 index 957b4d6..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/constants.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Constants used in the Firebase Storage library. - */ -/** - * Domain name for firebase storage. - */ -export declare const DEFAULT_HOST = "firebasestorage.googleapis.com"; -/** - * The key in Firebase config json for the storage bucket. - */ -export declare const CONFIG_STORAGE_BUCKET_KEY = "storageBucket"; -/** - * 2 minutes - * - * The timeout for all operations except upload. - */ -export declare const DEFAULT_MAX_OPERATION_RETRY_TIME: number; -/** - * 10 minutes - * - * The timeout for upload. - */ -export declare const DEFAULT_MAX_UPLOAD_RETRY_TIME: number; -/** - * 1 second - */ -export declare const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000; -/** - * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported - * enough for us to use it directly. - */ -export declare const MIN_SAFE_INTEGER = -9007199254740991; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/error.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/error.d.ts deleted file mode 100644 index dfc0884..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/error.d.ts +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FirebaseError } from '@firebase/util'; -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -export declare class StorageError extends FirebaseError { - private status_; - private readonly _baseMessage; - /** - * Stores custom error data unique to the `StorageError`. - */ - customData: { - serverResponse: string | null; - }; - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code: StorageErrorCode, message: string, status_?: number); - get status(): number; - set status(status: number); - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code: StorageErrorCode): boolean; - /** - * Optional response message that was added by the server. - */ - get serverResponse(): null | string; - set serverResponse(serverResponse: string | null); -} -export declare const errors: {}; -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -export declare enum StorageErrorCode { - UNKNOWN = "unknown", - OBJECT_NOT_FOUND = "object-not-found", - BUCKET_NOT_FOUND = "bucket-not-found", - PROJECT_NOT_FOUND = "project-not-found", - QUOTA_EXCEEDED = "quota-exceeded", - UNAUTHENTICATED = "unauthenticated", - UNAUTHORIZED = "unauthorized", - UNAUTHORIZED_APP = "unauthorized-app", - RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded", - INVALID_CHECKSUM = "invalid-checksum", - CANCELED = "canceled", - INVALID_EVENT_NAME = "invalid-event-name", - INVALID_URL = "invalid-url", - INVALID_DEFAULT_BUCKET = "invalid-default-bucket", - NO_DEFAULT_BUCKET = "no-default-bucket", - CANNOT_SLICE_BLOB = "cannot-slice-blob", - SERVER_FILE_WRONG_SIZE = "server-file-wrong-size", - NO_DOWNLOAD_URL = "no-download-url", - INVALID_ARGUMENT = "invalid-argument", - INVALID_ARGUMENT_COUNT = "invalid-argument-count", - APP_DELETED = "app-deleted", - INVALID_ROOT_OPERATION = "invalid-root-operation", - INVALID_FORMAT = "invalid-format", - INTERNAL_ERROR = "internal-error", - UNSUPPORTED_ENVIRONMENT = "unsupported-environment" -} -export declare function prependCode(code: StorageErrorCode): string; -export declare function unknown(): StorageError; -export declare function objectNotFound(path: string): StorageError; -export declare function bucketNotFound(bucket: string): StorageError; -export declare function projectNotFound(project: string): StorageError; -export declare function quotaExceeded(bucket: string): StorageError; -export declare function unauthenticated(): StorageError; -export declare function unauthorizedApp(): StorageError; -export declare function unauthorized(path: string): StorageError; -export declare function retryLimitExceeded(): StorageError; -export declare function invalidChecksum(path: string, checksum: string, calculated: string): StorageError; -export declare function canceled(): StorageError; -export declare function invalidEventName(name: string): StorageError; -export declare function invalidUrl(url: string): StorageError; -export declare function invalidDefaultBucket(bucket: string): StorageError; -export declare function noDefaultBucket(): StorageError; -export declare function cannotSliceBlob(): StorageError; -export declare function serverFileWrongSize(): StorageError; -export declare function noDownloadURL(): StorageError; -export declare function missingPolyFill(polyFill: string): StorageError; -/** - * @internal - */ -export declare function invalidArgument(message: string): StorageError; -export declare function invalidArgumentCount(argMin: number, argMax: number, fnName: string, real: number): StorageError; -export declare function appDeleted(): StorageError; -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -export declare function invalidRootOperation(name: string): StorageError; -/** - * @param format - The format that was not valid. - * @param message - A message describing the format violation. - */ -export declare function invalidFormat(format: string, message: string): StorageError; -/** - * @param message - A message describing the internal error. - */ -export declare function unsupportedEnvironment(message: string): StorageError; -/** - * @param message - A message describing the internal error. - */ -export declare function internalError(message: string): StorageError; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/failrequest.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/failrequest.d.ts deleted file mode 100644 index 89d079c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/failrequest.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageError } from './error'; -import { Request } from './request'; -/** - * A request whose promise always fails. - */ -export declare class FailRequest<T> implements Request<T> { - promise_: Promise<T>; - constructor(error: StorageError); - /** @inheritDoc */ - getPromise(): Promise<T>; - /** @inheritDoc */ - cancel(_appDelete?: boolean): void; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/fs.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/fs.d.ts deleted file mode 100644 index 30cd68d..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/fs.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Concatenates one or more values together and converts them to a Blob. - * - * @param args The values that will make up the resulting blob. - * @return The blob. - */ -export declare function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob; -/** - * Slices the blob. The returned blob contains data from the start byte - * (inclusive) till the end byte (exclusive). Negative indices cannot be used. - * - * @param blob The blob to be sliced. - * @param start Index of the starting byte. - * @param end Index of the ending byte. - * @return The blob slice or null if not supported. - */ -export declare function sliceBlob(blob: Blob, start: number, end: number): Blob | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/json.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/json.d.ts deleted file mode 100644 index 58151dc..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/json.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Returns the Object resulting from parsing the given JSON, or null if the - * given string does not represent a JSON object. - */ -export declare function jsonObjectOrNull(s: string): { - [name: string]: unknown; -} | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/list.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/list.d.ts deleted file mode 100644 index 9107503..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/list.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { ListResult } from '../list'; -import { FirebaseStorageImpl } from '../service'; -export declare function fromResponseString(service: FirebaseStorageImpl, bucket: string, resourceString: string): ListResult | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/location.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/location.d.ts deleted file mode 100644 index f6e1ab6..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/location.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -export declare class Location { - readonly bucket: string; - private path_; - constructor(bucket: string, path: string); - get path(): string; - get isRoot(): boolean; - fullServerUrl(): string; - bucketOnlyServerUrl(): string; - static makeFromBucketSpec(bucketString: string, host: string): Location; - static makeFromUrl(url: string, host: string): Location; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/metadata.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/metadata.d.ts deleted file mode 100644 index fadfd35..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/metadata.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Documentation for the metadata format - */ -import { Metadata } from '../metadata'; -import { FirebaseStorageImpl } from '../service'; -export declare function noXform_<T>(metadata: Metadata, value: T): T; -declare class Mapping<T> { - server: string; - local: string; - writable: boolean; - xform: (p1: Metadata, p2?: T) => T | undefined; - constructor(server: string, local?: string | null, writable?: boolean, xform?: ((p1: Metadata, p2?: T) => T | undefined) | null); -} -type Mappings = Array<Mapping<string> | Mapping<number>>; -export { Mappings }; -export declare function xformPath(fullPath: string | undefined): string | undefined; -export declare function getMappings(): Mappings; -export declare function addRef(metadata: Metadata, service: FirebaseStorageImpl): void; -export declare function fromResource(service: FirebaseStorageImpl, resource: { - [name: string]: unknown; -}, mappings: Mappings): Metadata; -export declare function fromResourceString(service: FirebaseStorageImpl, resourceString: string, mappings: Mappings): Metadata | null; -export declare function downloadUrlFromResourceString(metadata: Metadata, resourceString: string, host: string, protocol: string): string | null; -export declare function toResourceString(metadata: Partial<Metadata>, mappings: Mappings): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/observer.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/observer.d.ts deleted file mode 100644 index 0702651..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/observer.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { StorageError } from './error'; -/** - * Function that is called once for each value in a stream of values. - */ -export type NextFn<T> = (value: T) => void; -/** - * A function that is called with a `StorageError` - * if the event stream ends due to an error. - */ -export type ErrorFn = (error: StorageError) => void; -/** - * A function that is called if the event stream ends normally. - */ -export type CompleteFn = () => void; -/** - * Unsubscribes from a stream. - */ -export type Unsubscribe = () => void; -/** - * An observer identical to the `Observer` defined in packages/util except the - * error passed into the ErrorFn is specifically a `StorageError`. - */ -export interface StorageObserver<T> { - /** - * Function that is called once for each value in the event stream. - */ - next?: NextFn<T>; - /** - * A function that is called with a `StorageError` - * if the event stream ends due to an error. - */ - error?: ErrorFn; - /** - * A function that is called if the event stream ends normally. - */ - complete?: CompleteFn; -} -/** - * Subscribes to an event stream. - */ -export type Subscribe<T> = (next?: NextFn<T> | StorageObserver<T>, error?: ErrorFn, complete?: CompleteFn) => Unsubscribe; -export declare class Observer<T> implements StorageObserver<T> { - next?: NextFn<T>; - error?: ErrorFn; - complete?: CompleteFn; - constructor(nextOrObserver?: NextFn<T> | StorageObserver<T>, error?: ErrorFn, complete?: CompleteFn); -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/path.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/path.d.ts deleted file mode 100644 index f566805..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/path.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Contains helper methods for manipulating paths. - */ -/** - * @return Null if the path is already at the root. - */ -export declare function parent(path: string): string | null; -export declare function child(path: string, childPath: string): string; -/** - * Returns the last component of a path. - * '/foo/bar' -> 'bar' - * '/foo/bar/baz/' -> 'baz/' - * '/a' -> 'a' - */ -export declare function lastComponent(path: string): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/request.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/request.d.ts deleted file mode 100644 index 1b01a28..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/request.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { RequestInfo } from './requestinfo'; -import { Connection, Headers, ConnectionType } from './connection'; -export interface Request<T> { - getPromise(): Promise<T>; - /** - * Cancels the request. IMPORTANT: the promise may still be resolved with an - * appropriate value (if the request is finished before you call this method, - * but the promise has not yet been resolved), so don't just assume it will be - * rejected if you call this function. - * @param appDelete - True if the cancelation came from the app being deleted. - */ - cancel(appDelete?: boolean): void; -} -/** - * A collection of information about the result of a network request. - * @param opt_canceled - Defaults to false. - */ -export declare class RequestEndStatus<I extends ConnectionType> { - wasSuccessCode: boolean; - connection: Connection<I> | null; - /** - * True if the request was canceled. - */ - canceled: boolean; - constructor(wasSuccessCode: boolean, connection: Connection<I> | null, canceled?: boolean); -} -export declare function addAuthHeader_(headers: Headers, authToken: string | null): void; -export declare function addVersionHeader_(headers: Headers, firebaseVersion?: string): void; -export declare function addGmpidHeader_(headers: Headers, appId: string | null): void; -export declare function addAppCheckHeader_(headers: Headers, appCheckToken: string | null): void; -export declare function makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection<I>, firebaseVersion?: string, retry?: boolean, isUsingEmulator?: boolean): Request<O>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/requestinfo.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/requestinfo.d.ts deleted file mode 100644 index fec97c9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/requestinfo.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { StorageError } from './error'; -import { Headers, Connection, ConnectionType } from './connection'; -/** - * Type for url params stored in RequestInfo. - */ -export interface UrlParams { - [name: string]: string | number; -} -/** - * A function that converts a server response to the API type expected by the - * SDK. - * - * @param I - the type of the backend's network response - * @param O - the output response type used by the rest of the SDK. - */ -export type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O; -/** A function to handle an error. */ -export type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError) => StorageError; -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -export declare class RequestInfo<I extends ConnectionType, O> { - url: string; - method: string; - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler: RequestHandler<I, O>; - timeout: number; - urlParams: UrlParams; - headers: Headers; - body: Blob | string | Uint8Array | null; - errorHandler: ErrorHandler | null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - progressCallback: ((p1: number, p2: number) => void) | null; - successCodes: number[]; - additionalRetryCodes: number[]; - constructor(url: string, method: string, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler: RequestHandler<I, O>, timeout: number); -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/requests.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/requests.d.ts deleted file mode 100644 index a019496..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/requests.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Defines methods for interacting with the network. - */ -import { Metadata } from '../metadata'; -import { ListResult } from '../list'; -import { FbsBlob } from './blob'; -import { StorageError } from './error'; -import { Location } from './location'; -import { Mappings } from './metadata'; -import { RequestInfo } from './requestinfo'; -import { Connection, ConnectionType } from './connection'; -import { FirebaseStorageImpl } from '../service'; -/** - * Throws the UNKNOWN StorageError if cndn is false. - */ -export declare function handlerCheck(cndn: boolean): void; -export declare function metadataHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection<string>, p2: string) => Metadata; -export declare function listHandler(service: FirebaseStorageImpl, bucket: string): (p1: Connection<string>, p2: string) => ListResult; -export declare function downloadUrlHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection<string>, p2: string) => string | null; -export declare function sharedErrorHandler(location: Location): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError; -export declare function objectErrorHandler(location: Location): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError; -export declare function getMetadata(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<string, Metadata>; -export declare function list(service: FirebaseStorageImpl, location: Location, delimiter?: string, pageToken?: string | null, maxResults?: number | null): RequestInfo<string, ListResult>; -export declare function getBytes<I extends ConnectionType>(service: FirebaseStorageImpl, location: Location, maxDownloadSizeBytes?: number): RequestInfo<I, I>; -export declare function getDownloadUrl(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<string, string | null>; -export declare function updateMetadata(service: FirebaseStorageImpl, location: Location, metadata: Partial<Metadata>, mappings: Mappings): RequestInfo<string, Metadata>; -export declare function deleteObject(service: FirebaseStorageImpl, location: Location): RequestInfo<string, void>; -export declare function determineContentType_(metadata: Metadata | null, blob: FbsBlob | null): string; -export declare function metadataForUpload_(location: Location, blob: FbsBlob, metadata?: Metadata | null): Metadata; -/** - * Prepare RequestInfo for uploads as Content-Type: multipart. - */ -export declare function multipartUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string, Metadata>; -/** - * @param current The number of bytes that have been uploaded so far. - * @param total The total number of bytes in the upload. - * @param opt_finalized True if the server has finished the upload. - * @param opt_metadata The upload metadata, should - * only be passed if opt_finalized is true. - */ -export declare class ResumableUploadStatus { - current: number; - total: number; - finalized: boolean; - metadata: Metadata | null; - constructor(current: number, total: number, finalized?: boolean, metadata?: Metadata | null); -} -export declare function checkResumeHeader_(xhr: Connection<string>, allowed?: string[]): string; -export declare function createResumableUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string, string>; -/** - * @param url From a call to fbs.requests.createResumableUpload. - */ -export declare function getResumableUploadStatus(service: FirebaseStorageImpl, location: Location, url: string, blob: FbsBlob): RequestInfo<string, ResumableUploadStatus>; -/** - * Any uploads via the resumable upload API must transfer a number of bytes - * that is a multiple of this number. - */ -export declare const RESUMABLE_UPLOAD_CHUNK_SIZE: number; -/** - * @param url From a call to fbs.requests.createResumableUpload. - * @param chunkSize Number of bytes to upload. - * @param status The previous status. - * If not passed or null, we start from the beginning. - * @throws fbs.Error If the upload is already complete, the passed in status - * has a final size inconsistent with the blob, or the blob cannot be sliced - * for upload. - */ -export declare function continueResumableUpload(location: Location, service: FirebaseStorageImpl, url: string, blob: FbsBlob, chunkSize: number, mappings: Mappings, status?: ResumableUploadStatus | null, progressCallback?: ((p1: number, p2: number) => void) | null): RequestInfo<string, ResumableUploadStatus>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/string.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/string.d.ts deleted file mode 100644 index 0549cf9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/string.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export type StringFormat = (typeof StringFormat)[keyof typeof StringFormat]; -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export declare const StringFormat: { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - readonly RAW: "raw"; - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64: "base64"; - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64URL: "base64url"; - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - readonly DATA_URL: "data_url"; -}; -export declare class StringData { - data: Uint8Array; - contentType: string | null; - constructor(data: Uint8Array, contentType?: string | null); -} -/** - * @internal - */ -export declare function dataFromString(format: StringFormat, stringData: string): StringData; -export declare function utf8Bytes_(value: string): Uint8Array; -export declare function percentEncodedBytes_(value: string): Uint8Array; -export declare function base64Bytes_(format: StringFormat, value: string): Uint8Array; -export declare function dataURLBytes_(dataUrl: string): Uint8Array; -export declare function dataURLContentType_(dataUrl: string): string | null; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/taskenums.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/taskenums.d.ts deleted file mode 100644 index 6c6d880..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/taskenums.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Enumerations used for upload tasks. - */ -/** - * An event that is triggered on a task. - * @internal - */ -export type TaskEvent = string; -/** - * An event that is triggered on a task. - * @internal - */ -export declare const TaskEvent: { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: string; -}; -/** - * Internal enum for task state. - */ -export declare const enum InternalTaskState { - RUNNING = "running", - PAUSING = "pausing", - PAUSED = "paused", - SUCCESS = "success", - CANCELING = "canceling", - CANCELED = "canceled", - ERROR = "error" -} -/** - * Represents the current state of a running upload. - * @internal - */ -export type TaskState = (typeof TaskState)[keyof typeof TaskState]; -/** - * Represents the current state of a running upload. - * @internal - */ -export declare const TaskState: { - /** The task is currently transferring data. */ - readonly RUNNING: "running"; - /** The task was paused by the user. */ - readonly PAUSED: "paused"; - /** The task completed successfully. */ - readonly SUCCESS: "success"; - /** The task was canceled. */ - readonly CANCELED: "canceled"; - /** The task failed with an error. */ - readonly ERROR: "error"; -}; -export declare function taskStateFromInternalTaskState(state: InternalTaskState): TaskState; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/type.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/type.d.ts deleted file mode 100644 index ed70cc9..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/type.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export declare function isJustDef<T>(p: T | null | undefined): p is T | null; -export declare function isFunction(p: unknown): p is Function; -export declare function isNonArrayObject(p: unknown): boolean; -export declare function isString(p: unknown): p is string; -export declare function isNativeBlob(p: unknown): p is Blob; -export declare function isNativeBlobDefined(): boolean; -export declare function validateNumber(argument: string, minValue: number, maxValue: number, value: number): void; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/url.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/url.d.ts deleted file mode 100644 index caf7f3c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/url.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Functions to create and manipulate URLs for the server API. - */ -import { UrlParams } from './requestinfo'; -export declare function makeUrl(urlPart: string, host: string, protocol: string): string; -export declare function makeQueryString(params: UrlParams): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/utils.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/implementation/utils.d.ts deleted file mode 100644 index b91f9dc..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/implementation/utils.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Checks the status code to see if the action should be retried. - * - * @param status Current HTTP status code returned by server. - * @param additionalRetryCodes additional retry codes to check against - */ -export declare function isRetryStatusCode(status: number, additionalRetryCodes: number[]): boolean; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/index.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/index.d.ts deleted file mode 100644 index 62b1e67..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -export * from './api'; -export * from './api.browser'; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/index.node.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/index.node.d.ts deleted file mode 100644 index 2f613cd..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/index.node.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -export * from './api'; -export * from './api.node'; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/list.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/list.d.ts deleted file mode 100644 index 1f015e5..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/list.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Reference } from './reference'; -/** - * Result returned by `list()`. - * @public - */ -export interface ListResult { - /** - * References to prefixes (sub-folders). You can call list() on them to - * get its contents. - * - * Folders are implicit based on '/' in the object paths. - * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') - * will return '/a/b' as a prefix. - */ - prefixes: Reference[]; - /** - * Objects in this directory. - * You can call getMetadata() and getDownloadUrl() on them. - */ - items: Reference[]; - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken?: string; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/metadata.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/metadata.d.ts deleted file mode 100644 index 48fa64f..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/metadata.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FullMetadata } from './public-types'; -/** - * @fileoverview Documentation for the metadata format. - */ -/** - * The full set of object metadata, including read-only properties. - */ -interface Metadata extends FullMetadata { - [prop: string]: unknown; -} -export { Metadata }; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/platform/base64.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/platform/base64.d.ts deleted file mode 100644 index 7dac903..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/platform/base64.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -export declare function decodeBase64(encoded: string): string; -/** Converts a Uint8Array to a string. */ -export declare function decodeUint8Array(data: Uint8Array): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/platform/browser/base64.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/platform/browser/base64.d.ts deleted file mode 100644 index 23c84f2..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/platform/browser/base64.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -export declare function decodeBase64(encoded: string): string; -export declare function decodeUint8Array(data: Uint8Array): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/platform/browser/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/platform/browser/connection.d.ts deleted file mode 100644 index 14415da..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/platform/browser/connection.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Connection, ConnectionType, ErrorCode, Headers } from '../../implementation/connection'; -/** - * Network layer for browsers. We use this instead of goog.net.XhrIo because - * goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android. - */ -declare abstract class XhrConnection<T extends ConnectionType> implements Connection<T> { - protected xhr_: XMLHttpRequest; - private errorCode_; - private sendPromise_; - protected sent_: boolean; - constructor(); - abstract initXhr(): void; - send(url: string, method: string, isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string, headers?: Headers): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): T; - getErrorText(): string; - /** Aborts the request. */ - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} -export declare class XhrTextConnection extends XhrConnection<string> { - initXhr(): void; -} -export declare function newTextConnection(): Connection<string>; -export declare class XhrBytesConnection extends XhrConnection<ArrayBuffer> { - private data_?; - initXhr(): void; -} -export declare function newBytesConnection(): Connection<ArrayBuffer>; -export declare class XhrBlobConnection extends XhrConnection<Blob> { - initXhr(): void; -} -export declare function newBlobConnection(): Connection<Blob>; -export declare function newStreamConnection(): Connection<ReadableStream>; -export declare function injectTestConnection(factory: (() => Connection<string>) | null): void; -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/platform/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/platform/connection.d.ts deleted file mode 100644 index 72ed64b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/platform/connection.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Connection } from '../implementation/connection'; -export declare function injectTestConnection(factory: (() => Connection<string>) | null): void; -export declare function newTextConnection(): Connection<string>; -export declare function newBytesConnection(): Connection<ArrayBuffer>; -export declare function newBlobConnection(): Connection<Blob>; -export declare function newStreamConnection(): Connection<ReadableStream<Uint8Array>>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/platform/node/base64.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/platform/node/base64.d.ts deleted file mode 100644 index 23c84f2..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/platform/node/base64.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Converts a Base64 encoded string to a binary string. */ -export declare function decodeBase64(encoded: string): string; -export declare function decodeUint8Array(data: Uint8Array): string; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/platform/node/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/platform/node/connection.d.ts deleted file mode 100644 index a4e71fa..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/platform/node/connection.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Connection, ConnectionType, ErrorCode } from '../../implementation/connection'; -/** - * Network layer that works in Node. - * - * This network implementation should not be used in browsers as it does not - * support progress updates. - */ -declare abstract class FetchConnection<T extends ConnectionType> implements Connection<T> { - protected errorCode_: ErrorCode; - protected statusCode_: number | undefined; - protected body_: ArrayBuffer | undefined; - protected errorText_: string; - protected headers_: Headers | undefined; - protected sent_: boolean; - constructor(); - send(url: string, method: string, isUsingEmulator: boolean, body?: NodeJS.ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - abstract getResponse(): T; - getErrorText(): string; - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} -export declare class FetchTextConnection extends FetchConnection<string> { - getResponse(): string; -} -export declare function newTextConnection(): Connection<string>; -export declare class FetchBytesConnection extends FetchConnection<ArrayBuffer> { - getResponse(): ArrayBuffer; -} -export declare function newBytesConnection(): Connection<ArrayBuffer>; -export declare class FetchStreamConnection extends FetchConnection<ReadableStream<Uint8Array>> { - private stream_; - send(url: string, method: string, isUsingEmulator: boolean, body?: NodeJS.ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>; - getResponse(): ReadableStream; -} -export declare function newStreamConnection(): Connection<ReadableStream<Uint8Array>>; -export declare function newBlobConnection(): Connection<Blob>; -export declare function injectTestConnection(factory: (() => Connection<string>) | null): void; -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/public-types.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/public-types.d.ts deleted file mode 100644 index 033bd3c..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/public-types.d.ts +++ /dev/null @@ -1,424 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FirebaseApp, _FirebaseService } from '@firebase/app'; -import { CompleteFn, NextFn, Subscribe, Unsubscribe } from '@firebase/util'; -import { StorageError } from './implementation/error'; -/** - * A Firebase Storage instance. - * @public - */ -export interface FirebaseStorage extends _FirebaseService { - /** - * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance. - */ - readonly app: FirebaseApp; - /** - * The maximum time to retry uploads in milliseconds. - */ - maxUploadRetryTime: number; - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - maxOperationRetryTime: number; -} -/** - * Represents a reference to a Google Cloud Storage object. Developers can - * upload, download, and delete objects, as well as get/set object metadata. - * @public - */ -export interface StorageReference { - /** - * Returns a gs:// URL for this object in the form - * `gs://<bucket>/<path>/<to>/<object>` - * @returns The gs:// URL. - */ - toString(): string; - /** - * A reference to the root of this object's bucket. - */ - root: StorageReference; - /** - * The name of the bucket containing this reference's object. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The {@link FirebaseStorage} instance associated with this reference. - */ - storage: FirebaseStorage; - /** - * A reference pointing to the parent location of this reference, or null if - * this reference is the root. - */ - parent: StorageReference | null; -} -/** - * The options `list()` accepts. - * @public - */ -export interface ListOptions { - /** - * If set, limits the total number of `prefixes` and `items` to return. - * The default and maximum maxResults is 1000. - */ - maxResults?: number | null; - /** - * The `nextPageToken` from a previous call to `list()`. If provided, - * listing is resumed from the previous position. - */ - pageToken?: string | null; -} -/** - * Result returned by list(). - * @public - */ -export interface ListResult { - /** - * References to prefixes (sub-folders). You can call list() on them to - * get its contents. - * - * Folders are implicit based on '/' in the object paths. - * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') - * will return '/a/b' as a prefix. - */ - prefixes: StorageReference[]; - /** - * Objects in this directory. - * You can call getMetadata() and getDownloadUrl() on them. - */ - items: StorageReference[]; - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken?: string; -} -/** - * Object metadata that can be set at any time. - * @public - */ -export interface SettableMetadata { - /** - * Served as the 'Cache-Control' header on object download. - */ - cacheControl?: string | undefined; - /** - * Served as the 'Content-Disposition' header on object download. - */ - contentDisposition?: string | undefined; - /** - * Served as the 'Content-Encoding' header on object download. - */ - contentEncoding?: string | undefined; - /** - * Served as the 'Content-Language' header on object download. - */ - contentLanguage?: string | undefined; - /** - * Served as the 'Content-Type' header on object download. - */ - contentType?: string | undefined; - /** - * Additional user-defined custom metadata. - */ - customMetadata?: { - [key: string]: string; - } | undefined; -} -/** - * Object metadata that can be set at upload. - * @public - */ -export interface UploadMetadata extends SettableMetadata { - /** - * A Base64-encoded MD5 hash of the object being uploaded. - */ - md5Hash?: string | undefined; -} -/** - * The full set of object metadata, including read-only properties. - * @public - */ -export interface FullMetadata extends UploadMetadata { - /** - * The bucket this object is contained in. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The object's generation. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - generation: string; - /** - * The object's metageneration. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - metageneration: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The size of this object, in bytes. - */ - size: number; - /** - * A date string representing when this object was created. - */ - timeCreated: string; - /** - * A date string representing when this object was last updated. - */ - updated: string; - /** - * Tokens to allow access to the download URL. - */ - downloadTokens: string[] | undefined; - /** - * `StorageReference` associated with this upload. - */ - ref?: StorageReference | undefined; -} -/** - * An event that is triggered on a task. - * @public - */ -export type TaskEvent = 'state_changed'; -/** - * Represents the current state of a running upload. - * @public - */ -export type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error'; -/** - * A stream observer for Firebase Storage. - * @public - */ -export interface StorageObserver<T> { - next?: NextFn<T> | null; - error?: (error: StorageError) => void | null; - complete?: CompleteFn | null; -} -/** - * Represents the process of uploading an object. Allows you to monitor and - * manage the upload. - * @public - */ -export interface UploadTask { - /** - * Cancels a running task. Has no effect on a complete or failed task. - * @returns True if the cancel had an effect. - */ - cancel(): boolean; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected: (error: StorageError) => unknown): Promise<unknown>; - /** - * Listens for events on this task. - * - * Events have three callback functions (referred to as `next`, `error`, and - * `complete`). - * - * If only the event is passed, a function that can be used to register the - * callbacks is returned. Otherwise, the callbacks are passed after the event. - * - * Callbacks can be passed either as three separate arguments <em>or</em> as the - * `next`, `error`, and `complete` properties of an object. Any of the three - * callbacks is optional, as long as at least one is specified. In addition, - * when you add your callbacks, you get a function back. You can call this - * function to unregister the associated callbacks. - * - * @example **Pass callbacks separately or in an object.** - * ```javascript - * var next = function(snapshot) {}; - * var error = function(error) {}; - * var complete = function() {}; - * - * // The first example. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * next, - * error, - * complete); - * - * // This is equivalent to the first example. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe(next, error, complete); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe({ - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * ``` - * - * @example **Any callback is optional.** - * ```javascript - * // Just listening for completion, this is legal. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * null, - * null, - * function() { - * console.log('upload complete!'); - * }); - * - * // Just listening for progress/state changes, this is legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * }); - * - * // This is also legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'complete': function() { - * console.log('upload complete!'); - * } - * }); - * ``` - * - * @example **Use the returned function to remove callbacks.** - * ```javascript - * var unsubscribe = uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * - * // This code is equivalent to the above. - * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * unsubscribe = handle(function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * ``` - * - * @param event - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * A snapshot of the current task state. - */ - snapshot: UploadTaskSnapshot; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>; -} -/** - * Holds data about the current state of the upload task. - * @public - */ -export interface UploadTaskSnapshot { - /** - * The number of bytes that have been successfully uploaded so far. - */ - bytesTransferred: number; - /** - * Before the upload completes, contains the metadata sent to the server. - * After the upload completes, contains the metadata sent back from the server. - */ - metadata: FullMetadata; - /** - * The reference that spawned this snapshot's upload task. - */ - ref: StorageReference; - /** - * The current state of the task. - */ - state: TaskState; - /** - * The task of which this is a snapshot. - */ - task: UploadTask; - /** - * The total number of bytes to be uploaded. - */ - totalBytes: number; -} -/** - * Result returned from a non-resumable upload. - * @public - */ -export interface UploadResult { - /** - * Contains the metadata sent back from the server. - */ - readonly metadata: FullMetadata; - /** - * The reference that spawned this upload. - */ - readonly ref: StorageReference; -} -declare module '@firebase/component' { - interface NameServiceMapping { - 'storage': FirebaseStorage; - } -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/reference.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/reference.d.ts deleted file mode 100644 index 68e93d7..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/reference.d.ts +++ /dev/null @@ -1,208 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Location } from './implementation/location'; -import { ListOptions, UploadResult } from './public-types'; -import { StringFormat } from './implementation/string'; -import { Metadata } from './metadata'; -import { FirebaseStorageImpl } from './service'; -import { ListResult } from './list'; -import { UploadTask } from './task'; -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -export declare class Reference { - private _service; - _location: Location; - constructor(_service: FirebaseStorageImpl, location: string | Location); - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString(): string; - protected _newRef(service: FirebaseStorageImpl, location: Location): Reference; - /** - * A reference to the root of this object's bucket. - */ - get root(): Reference; - /** - * The name of the bucket containing this reference's object. - */ - get bucket(): string; - /** - * The full path of this object. - */ - get fullPath(): string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name(): string; - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage(): FirebaseStorageImpl; - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent(): Reference | null; - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name: string): void; -} -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded bytes. - */ -export declare function getBytesInternal(ref: Reference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; -/** - * Download the bytes at the object's location. - * @returns A Promise containing the downloaded blob. - */ -export declare function getBlobInternal(ref: Reference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** Stream the bytes at the object's location. */ -export declare function getStreamInternal(ref: Reference, maxDownloadSizeBytes?: number): ReadableStream; -/** - * Uploads data to this object's location. - * The upload is not resumable. - * - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns A Promise containing an UploadResult - */ -export declare function uploadBytes(ref: Reference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): Promise<UploadResult>; -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - StorageReference where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the newly uploaded data. - * @returns An UploadTask - */ -export declare function uploadBytesResumable(ref: Reference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): UploadTask; -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - StorageReference where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the newly uploaded string. - * @returns A Promise containing an UploadResult - */ -export declare function uploadString(ref: Reference, value: string, format?: StringFormat, metadata?: Metadata): Promise<UploadResult>; -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: listAll may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - StorageReference to get list from. - * - * @returns A Promise that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -export declare function listAll(ref: Reference): Promise<ListResult>; -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - StorageReference to get list from. - * @param options - See ListOptions for details. - * @returns A Promise that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -export declare function list(ref: Reference, options?: ListOptions | null): Promise<ListResult>; -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - StorageReference to get metadata from. - */ -export declare function getMetadata(ref: Reference): Promise<Metadata>; -/** - * Updates the metadata for this object. - * @public - * @param ref - StorageReference to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves - * with the new metadata for this object. - * See `firebaseStorage.Reference.prototype.getMetadata` - */ -export declare function updateMetadata(ref: Reference, metadata: Partial<Metadata>): Promise<Metadata>; -/** - * Returns the download URL for the given Reference. - * @public - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -export declare function getDownloadURL(ref: Reference): Promise<string>; -/** - * Deletes the object at this location. - * @public - * @param ref - StorageReference for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -export declare function deleteObject(ref: Reference): Promise<void>; -/** - * Returns reference for object obtained by appending `childPath` to `ref`. - * - * @param ref - StorageReference to get child of. - * @param childPath - Child path from provided ref. - * @returns A reference to the object obtained by - * appending childPath, removing any duplicate, beginning, or trailing - * slashes. - * - */ -export declare function _getChild(ref: Reference, childPath: string): Reference; diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/service.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/service.d.ts deleted file mode 100644 index 5dd6bb0..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/service.d.ts +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Location } from './implementation/location'; -import { Request } from './implementation/request'; -import { RequestInfo } from './implementation/requestinfo'; -import { Reference } from './reference'; -import { Provider } from '@firebase/component'; -import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; -import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; -import { FirebaseApp } from '@firebase/app'; -import { FirebaseStorage } from './public-types'; -import { EmulatorMockTokenOptions } from '@firebase/util'; -import { Connection, ConnectionType } from './implementation/connection'; -export declare function isUrl(path?: string): boolean; -/** - * Returns a storage Reference for the given url. - * @param storage - `Storage` instance. - * @param url - URL. If empty, returns root reference. - * @public - */ -export declare function ref(storage: FirebaseStorageImpl, url?: string): Reference; -/** - * Returns a storage Reference for the given path in the - * default bucket. - * @param storageOrRef - `Storage` service or storage `Reference`. - * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage - * instance provided) or returns same reference (if Reference provided). - * @public - */ -export declare function ref(storageOrRef: FirebaseStorageImpl | Reference, path?: string): Reference; -export declare function connectStorageEmulator(storage: FirebaseStorageImpl, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -export declare class FirebaseStorageImpl implements FirebaseStorage { - /** - * FirebaseApp associated with this StorageService instance. - */ - readonly app: FirebaseApp; - readonly _authProvider: Provider<FirebaseAuthInternalName>; - /** - * @internal - */ - readonly _appCheckProvider: Provider<AppCheckInternalComponentName>; - /** - * @internal - */ - readonly _url?: string | undefined; - readonly _firebaseVersion?: string | undefined; - _isUsingEmulator: boolean; - _bucket: Location | null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - private _host; - _protocol: string; - protected readonly _appId: string | null; - private readonly _requests; - private _deleted; - private _maxOperationRetryTime; - private _maxUploadRetryTime; - _overrideAuthToken?: string; - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>, - /** - * @internal - */ - _appCheckProvider: Provider<AppCheckInternalComponentName>, - /** - * @internal - */ - _url?: string | undefined, _firebaseVersion?: string | undefined, _isUsingEmulator?: boolean); - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host(): string; - set host(host: string); - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime(): number; - set maxUploadRetryTime(time: number); - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime(): number; - set maxOperationRetryTime(time: number); - _getAuthToken(): Promise<string | null>; - _getAppCheckToken(): Promise<string | null>; - /** - * Stop running requests and prevent more from being created. - */ - _delete(): Promise<void>; - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc: Location): Reference; - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request<O>; - makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>): Promise<O>; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/task.d.ts b/frontend-old/node_modules/@firebase/storage/dist/src/task.d.ts deleted file mode 100644 index 19afdfd..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/task.d.ts +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Defines types for interacting with blob transfer tasks. - */ -import { FbsBlob } from './implementation/blob'; -import { StorageError } from './implementation/error'; -import { InternalTaskState, TaskEvent } from './implementation/taskenums'; -import { Metadata } from './metadata'; -import { Subscribe, Unsubscribe } from './implementation/observer'; -import { UploadTaskSnapshot, StorageObserver } from './public-types'; -import { Reference } from './reference'; -import { CompleteFn } from '@firebase/util'; -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -export declare class UploadTask { - private _ref; - /** - * The data to be uploaded. - */ - _blob: FbsBlob; - /** - * Metadata related to the upload. - */ - _metadata: Metadata | null; - private _mappings; - /** - * Number of bytes transferred so far. - */ - _transferred: number; - private _needToFetchStatus; - private _needToFetchMetadata; - private _observers; - private _resumable; - /** - * Upload state. - */ - _state: InternalTaskState; - private _error?; - private _uploadUrl?; - private _request?; - private _chunkMultiplier; - private _errorHandler; - private _metadataErrorHandler; - private _resolve?; - private _reject?; - private pendingTimeout?; - private _promise; - private sleepTime; - private maxSleepTime; - isExponentialBackoffExpired(): boolean; - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref: Reference, blob: FbsBlob, metadata?: Metadata | null); - private _makeProgressCallback; - private _shouldDoResumable; - private _start; - private _resolveToken; - private _createResumable; - private _fetchStatus; - private _continueUpload; - private _increaseMultiplier; - private _fetchMetadata; - private _oneShotUpload; - private _updateProgress; - private _transition; - private completeTransitions_; - /** - * A snapshot of the current task state. - */ - get snapshot(): UploadTaskSnapshot; - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe | Subscribe<UploadTaskSnapshot>; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>; - /** - * Adds the given observer. - */ - private _addObserver; - /** - * Removes the given observer. - */ - private _removeObserver; - private _notifyObservers; - private _finishPromise; - private _notifyObserver; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel(): boolean; -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/src/tsdoc-metadata.json b/frontend-old/node_modules/@firebase/storage/dist/src/tsdoc-metadata.json deleted file mode 100644 index 6af1f6a..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/src/tsdoc-metadata.json +++ /dev/null @@ -1,11 +0,0 @@ -// This file is read by tools that parse documentation comments conforming to the TSDoc standard. -// It should be published with your NPM package. It should not be tracked by Git. -{ - "tsdocVersion": "0.12", - "toolPackages": [ - { - "packageName": "@microsoft/api-extractor", - "packageVersion": "0.1.2" - } - ] -} diff --git a/frontend-old/node_modules/@firebase/storage/dist/storage-public.d.ts b/frontend-old/node_modules/@firebase/storage/dist/storage-public.d.ts deleted file mode 100644 index 83d657b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/storage-public.d.ts +++ /dev/null @@ -1,725 +0,0 @@ -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ -import { CompleteFn , EmulatorMockTokenOptions , FirebaseError , NextFn , Subscribe , Unsubscribe } from '@firebase/util'; -import { FirebaseApp } from '@firebase/app'; -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; -/* Excluded from this release type: _dataFromString */ -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -export declare function deleteObject(ref: StorageReference): Promise<void>; -export { EmulatorMockTokenOptions }; -/* Excluded from this release type: _FbsBlob */ -/* Excluded from this release type: _FirebaseService */ -/** - * A Firebase Storage instance. - * @public - */ -export declare interface FirebaseStorage { - /** - * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance. - */ - readonly app: FirebaseApp; - /** - * The maximum time to retry uploads in milliseconds. - */ - maxUploadRetryTime: number; - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - maxOperationRetryTime: number; -} -/* Excluded from this release type: _FirebaseStorageImpl */ -/** - * The full set of object metadata, including read-only properties. - * @public - */ -export declare interface FullMetadata extends UploadMetadata { - /** - * The bucket this object is contained in. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The object's generation. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - generation: string; - /** - * The object's metageneration. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - metageneration: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The size of this object, in bytes. - */ - size: number; - /** - * A date string representing when this object was created. - */ - timeCreated: string; - /** - * A date string representing when this object was last updated. - */ - updated: string; - /** - * Tokens to allow access to the download URL. - */ - downloadTokens: string[] | undefined; - /** - * `StorageReference` associated with this upload. - */ - ref?: StorageReference | undefined; -} -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>; -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; -/* Excluded from this release type: _getChild */ -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -export declare function getDownloadURL(ref: StorageReference): Promise<string>; -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>; -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage; -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream; -/* Excluded from this release type: _invalidArgument */ -/* Excluded from this release type: _invalidRootOperation */ -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>; -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -export declare function listAll(ref: StorageReference): Promise<ListResult>; -/** - * The options `list()` accepts. - * @public - */ -export declare interface ListOptions { - /** - * If set, limits the total number of `prefixes` and `items` to return. - * The default and maximum maxResults is 1000. - */ - maxResults?: number | null; - /** - * The `nextPageToken` from a previous call to `list()`. If provided, - * listing is resumed from the previous position. - */ - pageToken?: string | null; -} -/** - * Result returned by list(). - * @public - */ -export declare interface ListResult { - /** - * References to prefixes (sub-folders). You can call list() on them to - * get its contents. - * - * Folders are implicit based on '/' in the object paths. - * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') - * will return '/a/b' as a prefix. - */ - prefixes: StorageReference[]; - /** - * Objects in this directory. - * You can call getMetadata() and getDownloadUrl() on them. - */ - items: StorageReference[]; - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken?: string; -} -/** - * Returns a {@link StorageReference} for the given url. - * @param storage - {@link FirebaseStorage} instance. - * @param url - URL. If empty, returns root reference. - * @public - */ -export declare function ref(storage: FirebaseStorage, url?: string): StorageReference; -/** - * Returns a {@link StorageReference} for the given path in the - * default bucket. - * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}. - * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage} - * instance provided) or returns same reference (if {@link StorageReference} provided). - * @public - */ -export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference; -/** - * Object metadata that can be set at any time. - * @public - */ -export declare interface SettableMetadata { - /** - * Served as the 'Cache-Control' header on object download. - */ - cacheControl?: string | undefined; - /** - * Served as the 'Content-Disposition' header on object download. - */ - contentDisposition?: string | undefined; - /** - * Served as the 'Content-Encoding' header on object download. - */ - contentEncoding?: string | undefined; - /** - * Served as the 'Content-Language' header on object download. - */ - contentLanguage?: string | undefined; - /** - * Served as the 'Content-Type' header on object download. - */ - contentType?: string | undefined; - /** - * Additional user-defined custom metadata. - */ - customMetadata?: { - [key: string]: string; - } | undefined; -} -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -export declare class StorageError extends FirebaseError { - private status_; - /** - * Stores custom error data unique to the `StorageError`. - */ - customData: { - serverResponse: string | null; - }; - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code: StorageErrorCode, message: string, status_?: number); - get status(): number; - set status(status: number); - /** - * Optional response message that was added by the server. - */ - get serverResponse(): null | string; - set serverResponse(serverResponse: string | null); -} -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -export declare enum StorageErrorCode { - UNKNOWN = "unknown", - OBJECT_NOT_FOUND = "object-not-found", - BUCKET_NOT_FOUND = "bucket-not-found", - PROJECT_NOT_FOUND = "project-not-found", - QUOTA_EXCEEDED = "quota-exceeded", - UNAUTHENTICATED = "unauthenticated", - UNAUTHORIZED = "unauthorized", - UNAUTHORIZED_APP = "unauthorized-app", - RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded", - INVALID_CHECKSUM = "invalid-checksum", - CANCELED = "canceled", - INVALID_EVENT_NAME = "invalid-event-name", - INVALID_URL = "invalid-url", - INVALID_DEFAULT_BUCKET = "invalid-default-bucket", - NO_DEFAULT_BUCKET = "no-default-bucket", - CANNOT_SLICE_BLOB = "cannot-slice-blob", - SERVER_FILE_WRONG_SIZE = "server-file-wrong-size", - NO_DOWNLOAD_URL = "no-download-url", - INVALID_ARGUMENT = "invalid-argument", - INVALID_ARGUMENT_COUNT = "invalid-argument-count", - APP_DELETED = "app-deleted", - INVALID_ROOT_OPERATION = "invalid-root-operation", - INVALID_FORMAT = "invalid-format", - INTERNAL_ERROR = "internal-error", - UNSUPPORTED_ENVIRONMENT = "unsupported-environment" -} -/** - * A stream observer for Firebase Storage. - * @public - */ -export declare interface StorageObserver<T> { - next?: NextFn<T> | null; - error?: (error: StorageError) => void | null; - complete?: CompleteFn | null; -} -/** - * Represents a reference to a Google Cloud Storage object. Developers can - * upload, download, and delete objects, as well as get/set object metadata. - * @public - */ -export declare interface StorageReference { - /** - * Returns a gs:// URL for this object in the form - * `gs://<bucket>/<path>/<to>/<object>` - * @returns The gs:// URL. - */ - toString(): string; - /** - * A reference to the root of this object's bucket. - */ - root: StorageReference; - /** - * The name of the bucket containing this reference's object. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The {@link FirebaseStorage} instance associated with this reference. - */ - storage: FirebaseStorage; - /** - * A reference pointing to the parent location of this reference, or null if - * this reference is the root. - */ - parent: StorageReference | null; -} -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export declare type StringFormat = (typeof StringFormat)[keyof typeof StringFormat]; -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export declare const StringFormat: { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - readonly RAW: "raw"; - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64: "base64"; - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64URL: "base64url"; - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - readonly DATA_URL: "data_url"; -}; -/** - * An event that is triggered on a task. - * @public - */ -export declare type TaskEvent = 'state_changed'; -/* Excluded from this release type: _TaskEvent */ -/** - * Represents the current state of a running upload. - * @public - */ -export declare type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error'; -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>; -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>; -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask; -/** - * Object metadata that can be set at upload. - * @public - */ -export declare interface UploadMetadata extends SettableMetadata { - /** - * A Base64-encoded MD5 hash of the object being uploaded. - */ - md5Hash?: string | undefined; -} -/** - * Result returned from a non-resumable upload. - * @public - */ -export declare interface UploadResult { - /** - * Contains the metadata sent back from the server. - */ - readonly metadata: FullMetadata; - /** - * The reference that spawned this upload. - */ - readonly ref: StorageReference; -} -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>; -/** - * Represents the process of uploading an object. Allows you to monitor and - * manage the upload. - * @public - */ -export declare interface UploadTask { - /** - * Cancels a running task. Has no effect on a complete or failed task. - * @returns True if the cancel had an effect. - */ - cancel(): boolean; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected: (error: StorageError) => unknown): Promise<unknown>; - /** - * Listens for events on this task. - * - * Events have three callback functions (referred to as `next`, `error`, and - * `complete`). - * - * If only the event is passed, a function that can be used to register the - * callbacks is returned. Otherwise, the callbacks are passed after the event. - * - * Callbacks can be passed either as three separate arguments <em>or</em> as the - * `next`, `error`, and `complete` properties of an object. Any of the three - * callbacks is optional, as long as at least one is specified. In addition, - * when you add your callbacks, you get a function back. You can call this - * function to unregister the associated callbacks. - * - * @example **Pass callbacks separately or in an object.** - * ```javascript - * var next = function(snapshot) {}; - * var error = function(error) {}; - * var complete = function() {}; - * - * // The first example. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * next, - * error, - * complete); - * - * // This is equivalent to the first example. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe(next, error, complete); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe({ - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * ``` - * - * @example **Any callback is optional.** - * ```javascript - * // Just listening for completion, this is legal. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * null, - * null, - * function() { - * console.log('upload complete!'); - * }); - * - * // Just listening for progress/state changes, this is legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * }); - * - * // This is also legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'complete': function() { - * console.log('upload complete!'); - * } - * }); - * ``` - * - * @example **Use the returned function to remove callbacks.** - * ```javascript - * var unsubscribe = uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * - * // This code is equivalent to the above. - * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * unsubscribe = handle(function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * ``` - * - * @param event - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * A snapshot of the current task state. - */ - snapshot: UploadTaskSnapshot; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>; -} -/* Excluded from this release type: _UploadTask */ -/** - * Holds data about the current state of the upload task. - * @public - */ -export declare interface UploadTaskSnapshot { - /** - * The number of bytes that have been successfully uploaded so far. - */ - bytesTransferred: number; - /** - * Before the upload completes, contains the metadata sent to the server. - * After the upload completes, contains the metadata sent back from the server. - */ - metadata: FullMetadata; - /** - * The reference that spawned this snapshot's upload task. - */ - ref: StorageReference; - /** - * The current state of the task. - */ - state: TaskState; - /** - * The task of which this is a snapshot. - */ - task: UploadTask; - /** - * The total number of bytes to be uploaded. - */ - totalBytes: number; -} -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/dist/storage.d.ts b/frontend-old/node_modules/@firebase/storage/dist/storage.d.ts deleted file mode 100644 index 5cb0f83..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/storage.d.ts +++ /dev/null @@ -1,1391 +0,0 @@ -/** - * Cloud Storage for Firebase - * - * @packageDocumentation - */ - -import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; -import { CompleteFn } from '@firebase/util'; -import { EmulatorMockTokenOptions } from '@firebase/util'; -import { FirebaseApp } from '@firebase/app'; -import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; -import { FirebaseError } from '@firebase/util'; -import { _FirebaseService } from '@firebase/app'; -import { NextFn } from '@firebase/util'; -import { Provider } from '@firebase/component'; -import { Subscribe } from '@firebase/util'; -import { Unsubscribe } from '@firebase/util'; - -/** - * A function that is called if the event stream ends normally. - */ -declare type CompleteFn_2 = () => void; - -/** - * A lightweight wrapper around XMLHttpRequest with a - * goog.net.XhrIo-like interface. - * - * You can create a new connection by invoking `newTextConnection()`, - * `newBytesConnection()` or `newStreamConnection()`. - */ -declare interface Connection<T extends ConnectionType> { - /** - * Sends a request to the provided URL. - * - * This method never rejects its promise. In case of encountering an error, - * it sets an error code internally which can be accessed by calling - * getErrorCode() by callers. - */ - send(url: string, method: string, isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers_2): Promise<void>; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): T; - getErrorText(): string; - /** - * Abort the request. - */ - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(listener: (p1: ProgressEvent) => void): void; - removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void; -} - -/** Response type exposed by the networking APIs. */ -declare type ConnectionType = string | ArrayBuffer | Blob | ReadableStream<Uint8Array>; - -/** - * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator. - * - * @param storage - The {@link FirebaseStorage} instance - * @param host - The emulator host (ex: localhost) - * @param port - The emulator port (ex: 5001) - * @param options - Emulator options. `options.mockUserToken` is the mock auth - * token to use for unit testing Security Rules. - * @public - */ -export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: { - mockUserToken?: EmulatorMockTokenOptions | string; -}): void; - -/** - * @internal - */ -export declare function _dataFromString(format: StringFormat, stringData: string): StringData; - -/** - * Deletes the object at this location. - * @public - * @param ref - {@link StorageReference} for object to delete. - * @returns A `Promise` that resolves if the deletion succeeds. - */ -export declare function deleteObject(ref: StorageReference): Promise<void>; -export { EmulatorMockTokenOptions } - -/** - * Error codes for requests made by the XhrIo wrapper. - */ -declare enum ErrorCode { - NO_ERROR = 0, - NETWORK_ERROR = 1, - ABORT = 2 -} - -/** - * A function that is called with a `StorageError` - * if the event stream ends due to an error. - */ -declare type ErrorFn = (error: StorageError) => void; - -/** A function to handle an error. */ -declare type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError) => StorageError; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @param opt_elideCopy - If true, doesn't copy mutable input data - * (e.g. Uint8Arrays). Pass true only if you know the objects will not be - * modified after this blob's construction. - * - * @internal - */ -export declare class _FbsBlob { - private data_; - private size_; - private type_; - constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean); - size(): number; - type(): string; - slice(startByte: number, endByte: number): _FbsBlob | null; - static getBlob(...args: Array<string | _FbsBlob>): _FbsBlob | null; - uploadData(): Blob | Uint8Array; -} - -/** - * A Firebase Storage instance. - * @public - */ -export declare interface FirebaseStorage extends _FirebaseService { - /** - * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance. - */ - readonly app: FirebaseApp; - /** - * The maximum time to retry uploads in milliseconds. - */ - maxUploadRetryTime: number; - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - maxOperationRetryTime: number; -} - -/** - * A service that provides Firebase Storage Reference instances. - * @param opt_url - gs:// url to a custom Storage Bucket - * - * @internal - */ -export declare class _FirebaseStorageImpl implements FirebaseStorage { - /** - * FirebaseApp associated with this StorageService instance. - */ - readonly app: FirebaseApp; - readonly _authProvider: Provider<FirebaseAuthInternalName>; - /** - * @internal - */ - readonly _appCheckProvider: Provider<AppCheckInternalComponentName>; - /** - * @internal - */ - readonly _url?: string | undefined; - readonly _firebaseVersion?: string | undefined; - _isUsingEmulator: boolean; - _bucket: _Location | null; - /** - * This string can be in the formats: - * - host - * - host:port - */ - private _host; - _protocol: string; - protected readonly _appId: string | null; - private readonly _requests; - private _deleted; - private _maxOperationRetryTime; - private _maxUploadRetryTime; - _overrideAuthToken?: string; - constructor( - /** - * FirebaseApp associated with this StorageService instance. - */ - app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>, - /** - * @internal - */ - _appCheckProvider: Provider<AppCheckInternalComponentName>, - /** - * @internal - */ - _url?: string | undefined, _firebaseVersion?: string | undefined, _isUsingEmulator?: boolean); - /** - * The host string for this service, in the form of `host` or - * `host:port`. - */ - get host(): string; - set host(host: string); - /** - * The maximum time to retry uploads in milliseconds. - */ - get maxUploadRetryTime(): number; - set maxUploadRetryTime(time: number); - /** - * The maximum time to retry operations other than uploads or downloads in - * milliseconds. - */ - get maxOperationRetryTime(): number; - set maxOperationRetryTime(time: number); - _getAuthToken(): Promise<string | null>; - _getAppCheckToken(): Promise<string | null>; - /** - * Stop running requests and prevent more from being created. - */ - _delete(): Promise<void>; - /** - * Returns a new firebaseStorage.Reference object referencing this StorageService - * at the given Location. - */ - _makeStorageReference(loc: _Location): _Reference; - /** - * @param requestInfo - HTTP RequestInfo object - * @param authToken - Firebase auth token - */ - _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request_2<O>; - makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>; -} - -/** - * The full set of object metadata, including read-only properties. - * @public - */ -export declare interface FullMetadata extends UploadMetadata { - /** - * The bucket this object is contained in. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The object's generation. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - generation: string; - /** - * The object's metageneration. - * {@link https://cloud.google.com/storage/docs/metadata#generation-number} - */ - metageneration: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The size of this object, in bytes. - */ - size: number; - /** - * A date string representing when this object was created. - */ - timeCreated: string; - /** - * A date string representing when this object was last updated. - */ - updated: string; - /** - * Tokens to allow access to the download URL. - */ - downloadTokens: string[] | undefined; - /** - * `StorageReference` associated with this upload. - */ - ref?: StorageReference | undefined; -} - -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * This API is not available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise that resolves with a Blob containing the object's bytes - */ -export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>; - -/** - * Downloads the data at the object's location. Returns an error if the object - * is not found. - * - * To use this functionality, you have to whitelist your app's origin in your - * Cloud Storage bucket. See also - * https://cloud.google.com/storage/docs/configuring-cors - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A Promise containing the object's bytes - */ -export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; - -/** - * @internal - */ -export declare function _getChild(ref: StorageReference, childPath: string): _Reference; - -/** - * Returns the download URL for the given {@link StorageReference}. - * @public - * @param ref - {@link StorageReference} to get the download URL for. - * @returns A `Promise` that resolves with the download - * URL for this object. - */ -export declare function getDownloadURL(ref: StorageReference): Promise<string>; - -/** - * A `Promise` that resolves with the metadata for this object. If this - * object doesn't exist or metadata cannot be retrieved, the promise is - * rejected. - * @public - * @param ref - {@link StorageReference} to get metadata from. - */ -export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>; - -/** - * Gets a {@link FirebaseStorage} instance for the given Firebase app. - * @public - * @param app - Firebase app to get {@link FirebaseStorage} instance for. - * @param bucketUrl - The gs:// url to your Firebase Storage Bucket. - * If not passed, uses the app's default Storage Bucket. - * @returns A {@link FirebaseStorage} instance. - */ -export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage; - -/** - * Downloads the data at the object's location. Raises an error event if the - * object is not found. - * - * This API is only available in Node. - * - * @public - * @param ref - StorageReference where data should be downloaded. - * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to - * retrieve. - * @returns A stream with the object's data as bytes - */ -export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** Network headers */ -declare type Headers_2 = Record<string, string>; - -/** - * Internal enum for task state. - */ -declare const enum InternalTaskState { - RUNNING = "running", - PAUSING = "pausing", - PAUSED = "paused", - SUCCESS = "success", - CANCELING = "canceling", - CANCELED = "canceled", - ERROR = "error" -} - -/** - * @internal - */ -export declare function _invalidArgument(message: string): StorageError; - -/** - * @param name - The name of the operation that was invalid. - * - * @internal - */ -export declare function _invalidRootOperation(name: string): StorageError; - -/** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' - * delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not - * support objects whose paths end with "/" or contain two consecutive - * "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * @public - * - * @param ref - {@link StorageReference} to get list from. - * @param options - See {@link ListOptions} for details. - * @returns A `Promise` that resolves with the items and prefixes. - * `prefixes` contains references to sub-folders and `items` - * contains references to objects in this folder. `nextPageToken` - * can be used to get the rest of the results. - */ -export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>; - -/** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are - * no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this - * operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are - * too many results. - * @public - * @param ref - {@link StorageReference} to get list from. - * - * @returns A `Promise` that resolves with all the items and prefixes under - * the current storage reference. `prefixes` contains references to - * sub-directories and `items` contains references to objects in this - * folder. `nextPageToken` is never returned. - */ -export declare function listAll(ref: StorageReference): Promise<ListResult>; - -/** - * The options `list()` accepts. - * @public - */ -export declare interface ListOptions { - /** - * If set, limits the total number of `prefixes` and `items` to return. - * The default and maximum maxResults is 1000. - */ - maxResults?: number | null; - /** - * The `nextPageToken` from a previous call to `list()`. If provided, - * listing is resumed from the previous position. - */ - pageToken?: string | null; -} - -/** - * Result returned by list(). - * @public - */ -export declare interface ListResult { - /** - * References to prefixes (sub-folders). You can call list() on them to - * get its contents. - * - * Folders are implicit based on '/' in the object paths. - * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') - * will return '/a/b' as a prefix. - */ - prefixes: StorageReference[]; - /** - * Objects in this directory. - * You can call getMetadata() and getDownloadUrl() on them. - */ - items: StorageReference[]; - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken?: string; -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Firebase Storage location data. - * - * @internal - */ -export declare class _Location { - readonly bucket: string; - private path_; - constructor(bucket: string, path: string); - get path(): string; - get isRoot(): boolean; - fullServerUrl(): string; - bucketOnlyServerUrl(): string; - static makeFromBucketSpec(bucketString: string, host: string): _Location; - static makeFromUrl(url: string, host: string): _Location; -} - -/** - * @fileoverview Documentation for the metadata format. - */ -/** - * The full set of object metadata, including read-only properties. - */ -declare interface Metadata extends FullMetadata { - [prop: string]: unknown; -} - -/** - * Function that is called once for each value in a stream of values. - */ -declare type NextFn_2<T> = (value: T) => void; - -/** - * Returns a {@link StorageReference} for the given url. - * @param storage - {@link FirebaseStorage} instance. - * @param url - URL. If empty, returns root reference. - * @public - */ -export declare function ref(storage: FirebaseStorage, url?: string): StorageReference; - -/** - * Returns a {@link StorageReference} for the given path in the - * default bucket. - * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}. - * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage} - * instance provided) or returns same reference (if {@link StorageReference} provided). - * @public - */ -export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference; - -/** - * Provides methods to interact with a bucket in the Firebase Storage service. - * @internal - * @param _location - An fbs.location, or the URL at - * which to base this object, in one of the following forms: - * gs://<bucket>/<object-path> - * http[s]://firebasestorage.googleapis.com/ - * <api-version>/b/<bucket>/o/<object-path> - * Any query or fragment strings will be ignored in the http[s] - * format. If no value is passed, the storage object will use a URL based on - * the project ID of the base firebase.App instance. - */ -export declare class _Reference { - private _service; - _location: _Location; - constructor(_service: _FirebaseStorageImpl, location: string | _Location); - /** - * Returns the URL for the bucket and path this object references, - * in the form gs://<bucket>/<object-path> - * @override - */ - toString(): string; - protected _newRef(service: _FirebaseStorageImpl, location: _Location): _Reference; - /** - * A reference to the root of this object's bucket. - */ - get root(): _Reference; - /** - * The name of the bucket containing this reference's object. - */ - get bucket(): string; - /** - * The full path of this object. - */ - get fullPath(): string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - get name(): string; - /** - * The `StorageService` instance this `StorageReference` is associated with. - */ - get storage(): _FirebaseStorageImpl; - /** - * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if - * this reference is the root. - */ - get parent(): _Reference | null; - /** - * Utility function to throw an error in methods that do not accept a root reference. - */ - _throwIfRoot(name: string): void; -} - -declare interface Request_2<T> { - getPromise(): Promise<T>; - /** - * Cancels the request. IMPORTANT: the promise may still be resolved with an - * appropriate value (if the request is finished before you call this method, - * but the promise has not yet been resolved), so don't just assume it will be - * rejected if you call this function. - * @param appDelete - True if the cancelation came from the app being deleted. - */ - cancel(appDelete?: boolean): void; -} - -/** - * A function that converts a server response to the API type expected by the - * SDK. - * - * @param I - the type of the backend's network response - * @param O - the output response type used by the rest of the SDK. - */ -declare type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O; - -/** - * Contains a fully specified request. - * - * @param I - the type of the backend's network response. - * @param O - the output response type used by the rest of the SDK. - */ -declare class RequestInfo_2<I extends ConnectionType, O> { - url: string; - method: string; - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler: RequestHandler<I, O>; - timeout: number; - urlParams: UrlParams; - headers: Headers_2; - body: Blob | string | Uint8Array | null; - errorHandler: ErrorHandler | null; - /** - * Called with the current number of bytes uploaded and total size (-1 if not - * computable) of the request body (i.e. used to report upload progress). - */ - progressCallback: ((p1: number, p2: number) => void) | null; - successCodes: number[]; - additionalRetryCodes: number[]; - constructor(url: string, method: string, - /** - * Returns the value with which to resolve the request's promise. Only called - * if the request is successful. Throw from this function to reject the - * returned Request's promise with the thrown error. - * Note: The XhrIo passed to this function may be reused after this callback - * returns. Do not keep a reference to it in any way. - */ - handler: RequestHandler<I, O>, timeout: number); -} - -/** - * Object metadata that can be set at any time. - * @public - */ -export declare interface SettableMetadata { - /** - * Served as the 'Cache-Control' header on object download. - */ - cacheControl?: string | undefined; - /** - * Served as the 'Content-Disposition' header on object download. - */ - contentDisposition?: string | undefined; - /** - * Served as the 'Content-Encoding' header on object download. - */ - contentEncoding?: string | undefined; - /** - * Served as the 'Content-Language' header on object download. - */ - contentLanguage?: string | undefined; - /** - * Served as the 'Content-Type' header on object download. - */ - contentType?: string | undefined; - /** - * Additional user-defined custom metadata. - */ - customMetadata?: { - [key: string]: string; - } | undefined; -} - -/** - * An error returned by the Firebase Storage SDK. - * @public - */ -export declare class StorageError extends FirebaseError { - private status_; - private readonly _baseMessage; - /** - * Stores custom error data unique to the `StorageError`. - */ - customData: { - serverResponse: string | null; - }; - /** - * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and - * added to the end of the message. - * @param message - Error message. - * @param status_ - Corresponding HTTP Status Code - */ - constructor(code: StorageErrorCode, message: string, status_?: number); - get status(): number; - set status(status: number); - /** - * Compares a `StorageErrorCode` against this error's code, filtering out the prefix. - */ - _codeEquals(code: StorageErrorCode): boolean; - /** - * Optional response message that was added by the server. - */ - get serverResponse(): null | string; - set serverResponse(serverResponse: string | null); -} - -/** - * @public - * Error codes that can be attached to `StorageError` objects. - */ -export declare enum StorageErrorCode { - UNKNOWN = "unknown", - OBJECT_NOT_FOUND = "object-not-found", - BUCKET_NOT_FOUND = "bucket-not-found", - PROJECT_NOT_FOUND = "project-not-found", - QUOTA_EXCEEDED = "quota-exceeded", - UNAUTHENTICATED = "unauthenticated", - UNAUTHORIZED = "unauthorized", - UNAUTHORIZED_APP = "unauthorized-app", - RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded", - INVALID_CHECKSUM = "invalid-checksum", - CANCELED = "canceled", - INVALID_EVENT_NAME = "invalid-event-name", - INVALID_URL = "invalid-url", - INVALID_DEFAULT_BUCKET = "invalid-default-bucket", - NO_DEFAULT_BUCKET = "no-default-bucket", - CANNOT_SLICE_BLOB = "cannot-slice-blob", - SERVER_FILE_WRONG_SIZE = "server-file-wrong-size", - NO_DOWNLOAD_URL = "no-download-url", - INVALID_ARGUMENT = "invalid-argument", - INVALID_ARGUMENT_COUNT = "invalid-argument-count", - APP_DELETED = "app-deleted", - INVALID_ROOT_OPERATION = "invalid-root-operation", - INVALID_FORMAT = "invalid-format", - INTERNAL_ERROR = "internal-error", - UNSUPPORTED_ENVIRONMENT = "unsupported-environment" -} - -/** - * A stream observer for Firebase Storage. - * @public - */ -export declare interface StorageObserver<T> { - next?: NextFn<T> | null; - error?: (error: StorageError) => void | null; - complete?: CompleteFn | null; -} - -/** - * An observer identical to the `Observer` defined in packages/util except the - * error passed into the ErrorFn is specifically a `StorageError`. - */ -declare interface StorageObserver_2<T> { - /** - * Function that is called once for each value in the event stream. - */ - next?: NextFn_2<T>; - /** - * A function that is called with a `StorageError` - * if the event stream ends due to an error. - */ - error?: ErrorFn; - /** - * A function that is called if the event stream ends normally. - */ - complete?: CompleteFn_2; -} - -/** - * Represents a reference to a Google Cloud Storage object. Developers can - * upload, download, and delete objects, as well as get/set object metadata. - * @public - */ -export declare interface StorageReference { - /** - * Returns a gs:// URL for this object in the form - * `gs://<bucket>/<path>/<to>/<object>` - * @returns The gs:// URL. - */ - toString(): string; - /** - * A reference to the root of this object's bucket. - */ - root: StorageReference; - /** - * The name of the bucket containing this reference's object. - */ - bucket: string; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The short name of this object, which is the last component of the full path. - * For example, if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * The {@link FirebaseStorage} instance associated with this reference. - */ - storage: FirebaseStorage; - /** - * A reference pointing to the parent location of this reference, or null if - * this reference is the root. - */ - parent: StorageReference | null; -} - -declare class StringData { - data: Uint8Array; - contentType: string | null; - constructor(data: Uint8Array, contentType?: string | null); -} - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export declare type StringFormat = (typeof StringFormat)[keyof typeof StringFormat]; - -/** - * An enumeration of the possible string formats for upload. - * @public - */ -export declare const StringFormat: { - /** - * Indicates the string should be interpreted "raw", that is, as normal text. - * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte - * sequence. - * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence - * 48 65 6c 6c 6f 21 20 f0 9f 98 8a - */ - readonly RAW: "raw"; - /** - * Indicates the string should be interpreted as base64-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64: "base64"; - /** - * Indicates the string should be interpreted as base64url-encoded data. - * Padding characters (trailing '='s) are optional. - * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence - * ad 69 8e fb e1 3a b7 bf eb 97 - */ - readonly BASE64URL: "base64url"; - /** - * Indicates the string is a data URL, such as one obtained from - * canvas.toDataURL(). - * Example: the string 'data:application/octet-stream;base64,aaaa' - * becomes the byte sequence - * 69 a6 9a - * (the content-type "application/octet-stream" is also applied, but can - * be overridden in the metadata object). - */ - readonly DATA_URL: "data_url"; -}; - -/** - * Subscribes to an event stream. - */ -declare type Subscribe_2<T> = (next?: NextFn_2<T> | StorageObserver_2<T>, error?: ErrorFn, complete?: CompleteFn_2) => Unsubscribe_2; - -/** - * An event that is triggered on a task. - * @public - */ -export declare type TaskEvent = 'state_changed'; - -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @fileoverview Enumerations used for upload tasks. - */ -/** - * An event that is triggered on a task. - * @internal - */ -export declare type _TaskEvent = string; - -/** - * An event that is triggered on a task. - * @internal - */ -export declare const _TaskEvent: { - /** - * For this event, - * <ul> - * <li>The `next` function is triggered on progress updates and when the - * task is paused/resumed with an `UploadTaskSnapshot` as the first - * argument.</li> - * <li>The `error` function is triggered if the upload is canceled or fails - * for another reason.</li> - * <li>The `complete` function is triggered if the upload completes - * successfully.</li> - * </ul> - */ - STATE_CHANGED: string; -}; - -/** - * Represents the current state of a running upload. - * @public - */ -export declare type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error'; - -/** - * Represents the current state of a running upload. - * @internal - */ -export declare type _TaskState = (typeof _TaskState)[keyof typeof _TaskState]; - -/** - * Represents the current state of a running upload. - * @internal - */ -export declare const _TaskState: { - /** The task is currently transferring data. */ - readonly RUNNING: "running"; - /** The task was paused by the user. */ - readonly PAUSED: "paused"; - /** The task completed successfully. */ - readonly SUCCESS: "success"; - /** The task was canceled. */ - readonly CANCELED: "canceled"; - /** The task failed with an error. */ - readonly ERROR: "error"; -}; - -/** - * Unsubscribes from a stream. - */ -declare type Unsubscribe_2 = () => void; - -/** - * Updates the metadata for this object. - * @public - * @param ref - {@link StorageReference} to update metadata for. - * @param metadata - The new metadata for the object. - * Only values that have been explicitly set will be changed. Explicitly - * setting a value to null will remove the metadata. - * @returns A `Promise` that resolves with the new metadata for this object. - */ -export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>; - -/** - * Uploads data to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>; - -/** - * Uploads data to this object's location. - * The upload can be paused and resumed, and exposes progress updates. - * @public - * @param ref - {@link StorageReference} where data should be uploaded. - * @param data - The data to upload. - * @param metadata - Metadata for the data to upload. - * @returns An UploadTask - */ -export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask; - -/** - * Object metadata that can be set at upload. - * @public - */ -export declare interface UploadMetadata extends SettableMetadata { - /** - * A Base64-encoded MD5 hash of the object being uploaded. - */ - md5Hash?: string | undefined; -} - -/** - * Result returned from a non-resumable upload. - * @public - */ -export declare interface UploadResult { - /** - * Contains the metadata sent back from the server. - */ - readonly metadata: FullMetadata; - /** - * The reference that spawned this upload. - */ - readonly ref: StorageReference; -} - -/** - * Uploads a string to this object's location. - * The upload is not resumable. - * @public - * @param ref - {@link StorageReference} where string should be uploaded. - * @param value - The string to upload. - * @param format - The format of the string to upload. - * @param metadata - Metadata for the string to upload. - * @returns A Promise containing an UploadResult - */ -export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>; - -/** - * Represents the process of uploading an object. Allows you to monitor and - * manage the upload. - * @public - */ -export declare interface UploadTask { - /** - * Cancels a running task. Has no effect on a complete or failed task. - * @returns True if the cancel had an effect. - */ - cancel(): boolean; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch(onRejected: (error: StorageError) => unknown): Promise<unknown>; - /** - * Listens for events on this task. - * - * Events have three callback functions (referred to as `next`, `error`, and - * `complete`). - * - * If only the event is passed, a function that can be used to register the - * callbacks is returned. Otherwise, the callbacks are passed after the event. - * - * Callbacks can be passed either as three separate arguments <em>or</em> as the - * `next`, `error`, and `complete` properties of an object. Any of the three - * callbacks is optional, as long as at least one is specified. In addition, - * when you add your callbacks, you get a function back. You can call this - * function to unregister the associated callbacks. - * - * @example **Pass callbacks separately or in an object.** - * ```javascript - * var next = function(snapshot) {}; - * var error = function(error) {}; - * var complete = function() {}; - * - * // The first example. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * next, - * error, - * complete); - * - * // This is equivalent to the first example. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe(next, error, complete); - * - * // This is equivalent to the first example. - * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * subscribe({ - * 'next': next, - * 'error': error, - * 'complete': complete - * }); - * ``` - * - * @example **Any callback is optional.** - * ```javascript - * // Just listening for completion, this is legal. - * uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * null, - * null, - * function() { - * console.log('upload complete!'); - * }); - * - * // Just listening for progress/state changes, this is legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * }); - * - * // This is also legal. - * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, { - * 'complete': function() { - * console.log('upload complete!'); - * } - * }); - * ``` - * - * @example **Use the returned function to remove callbacks.** - * ```javascript - * var unsubscribe = uploadTask.on( - * firebase.storage.TaskEvent.STATE_CHANGED, - * function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * - * // This code is equivalent to the above. - * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED); - * unsubscribe = handle(function(snapshot) { - * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100; - * console.log(percent + "% done"); - * // Stop after receiving one update. - * unsubscribe(); - * }); - * ``` - * - * @param event - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * A snapshot of the current task state. - */ - snapshot: UploadTaskSnapshot; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>; -} - -/** - * Represents a blob being uploaded. Can be used to pause/resume/cancel the - * upload and manage callbacks for various events. - * @internal - */ -export declare class _UploadTask { - private _ref; - /** - * The data to be uploaded. - */ - _blob: _FbsBlob; - /** - * Metadata related to the upload. - */ - _metadata: Metadata | null; - private _mappings; - /** - * Number of bytes transferred so far. - */ - _transferred: number; - private _needToFetchStatus; - private _needToFetchMetadata; - private _observers; - private _resumable; - /** - * Upload state. - */ - _state: InternalTaskState; - private _error?; - private _uploadUrl?; - private _request?; - private _chunkMultiplier; - private _errorHandler; - private _metadataErrorHandler; - private _resolve?; - private _reject?; - private pendingTimeout?; - private _promise; - private sleepTime; - private maxSleepTime; - isExponentialBackoffExpired(): boolean; - /** - * @param ref - The firebaseStorage.Reference object this task came - * from, untyped to avoid cyclic dependencies. - * @param blob - The blob to upload. - */ - constructor(ref: _Reference, blob: _FbsBlob, metadata?: Metadata | null); - private _makeProgressCallback; - private _shouldDoResumable; - private _start; - private _resolveToken; - private _createResumable; - private _fetchStatus; - private _continueUpload; - private _increaseMultiplier; - private _fetchMetadata; - private _oneShotUpload; - private _updateProgress; - private _transition; - private completeTransitions_; - /** - * A snapshot of the current task state. - */ - get snapshot(): UploadTaskSnapshot; - /** - * Adds a callback for an event. - * @param type - The type of event to listen for. - * @param nextOrObserver - - * The `next` function, which gets called for each item in - * the event stream, or an observer object with some or all of these three - * properties (`next`, `error`, `complete`). - * @param error - A function that gets called with a `StorageError` - * if the event stream ends due to an error. - * @param completed - A function that gets called if the - * event stream ends normally. - * @returns - * If only the event argument is passed, returns a function you can use to - * add callbacks (see the examples above). If more than just the event - * argument is passed, returns a function you can call to unregister the - * callbacks. - */ - on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>; - /** - * This object behaves like a Promise, and resolves with its snapshot data - * when the upload completes. - * @param onFulfilled - The fulfillment callback. Promise chaining works as normal. - * @param onRejected - The rejection callback. - */ - then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>; - /** - * Equivalent to calling `then(null, onRejected)`. - */ - catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>; - /** - * Adds the given observer. - */ - private _addObserver; - /** - * Removes the given observer. - */ - private _removeObserver; - private _notifyObservers; - private _finishPromise; - private _notifyObserver; - /** - * Resumes a paused task. Has no effect on a currently running or failed task. - * @returns True if the operation took effect, false if ignored. - */ - resume(): boolean; - /** - * Pauses a currently running task. Has no effect on a paused or failed task. - * @returns True if the operation took effect, false if ignored. - */ - pause(): boolean; - /** - * Cancels a currently running or paused task. Has no effect on a complete or - * failed task. - * @returns True if the operation took effect, false if ignored. - */ - cancel(): boolean; -} - -/** - * Holds data about the current state of the upload task. - * @public - */ -export declare interface UploadTaskSnapshot { - /** - * The number of bytes that have been successfully uploaded so far. - */ - bytesTransferred: number; - /** - * Before the upload completes, contains the metadata sent to the server. - * After the upload completes, contains the metadata sent back from the server. - */ - metadata: FullMetadata; - /** - * The reference that spawned this snapshot's upload task. - */ - ref: StorageReference; - /** - * The current state of the task. - */ - state: TaskState; - /** - * The task of which this is a snapshot. - */ - task: UploadTask; - /** - * The total number of bytes to be uploaded. - */ - totalBytes: number; -} - -/** - * Type for url params stored in RequestInfo. - */ -declare interface UrlParams { - [name: string]: string | number; -} - -export { } diff --git a/frontend-old/node_modules/@firebase/storage/dist/test/unit/connection.d.ts b/frontend-old/node_modules/@firebase/storage/dist/test/unit/connection.d.ts deleted file mode 100644 index 47fe45b..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/test/unit/connection.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { ErrorCode, Headers, Connection } from '../../src/implementation/connection'; -export type SendHook = (connection: TestingConnection, url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => void; -export declare enum State { - START = 0, - SENT = 1, - DONE = 2 -} -export declare class TestingConnection implements Connection<string> { - private state; - private sendPromise; - private resolve; - private sendHook; - private status; - private responseText; - private headers; - private errorCode; - constructor(sendHook: SendHook | null); - send(url: string, method: string, _isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>; - simulateResponse(status: number, body: string, headers: { - [key: string]: string; - }): void; - getErrorCode(): ErrorCode; - getStatus(): number; - getResponse(): string; - getErrorText(): string; - abort(): void; - getResponseHeader(header: string): string | null; - addUploadProgressListener(): void; - removeUploadProgressListener(): void; -} -export declare function newTestConnection(sendHook?: SendHook | null): Connection<string>; diff --git a/frontend-old/node_modules/@firebase/storage/dist/test/unit/testshared.d.ts b/frontend-old/node_modules/@firebase/storage/dist/test/unit/testshared.d.ts deleted file mode 100644 index b267049..0000000 --- a/frontend-old/node_modules/@firebase/storage/dist/test/unit/testshared.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { FirebaseApp } from '@firebase/app-types'; -import { StorageError } from '../../src/implementation/error'; -import { Headers, Connection, ConnectionType } from '../../src/implementation/connection'; -import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; -import { Provider } from '@firebase/component'; -import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; -import { FirebaseStorageImpl } from '../../src/service'; -import { Metadata } from '../../src/metadata'; -export declare const authToken = "totally-legit-auth-token"; -export declare const appCheckToken = "totally-shady-token"; -export declare const bucket = "mybucket"; -export declare const fakeApp: FirebaseApp; -export declare const fakeAuthProvider: Provider<"auth-internal">; -export declare const emptyAuthProvider: Provider<"auth-internal">; -export declare const fakeAppCheckTokenProvider: Provider<"app-check-internal">; -export declare function makeFakeApp(bucketArg?: string): FirebaseApp; -export declare function makeFakeAuthProvider(token: { - accessToken: string; -}): Provider<FirebaseAuthInternalName>; -export declare function makeFakeAppCheckProvider(tokenResult: { - token: string; -}): Provider<AppCheckInternalComponentName>; -/** - * Returns something that looks like an fbs.XhrIo with the given headers - * and status. - */ -export declare function fakeXhrIo<I extends ConnectionType = string>(headers: Headers, status?: number): Connection<I>; -/** - * Binds ignoring types. Used to test calls involving improper arguments. - */ -export declare function bind(f: Function, ctx: any, ...args: any[]): () => void; -export declare function assertThrows(f: () => void, code: string): StorageError; -export declare function assertUint8ArrayEquals(arr1: Uint8Array, arr2: Uint8Array): void; -export declare function assertObjectIncludes(included: { - [name: string]: any; -}, obj: { - [name: string]: any; -}): void; -interface Response { - status: number; - body: string; - headers: Headers; -} -export type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response; -export declare function storageServiceWithHandler(handler: RequestHandler, shouldResponseCb?: () => boolean): FirebaseStorageImpl; -export declare function fakeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler; -/** - * Responds with a 503 for finalize. - * @param fakeMetadata metadata to respond with for finalize - * @returns a handler for requests - */ -export declare function fake503ForFinalizeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler; -/** - * Responds with a 503 for upload. - * @param fakeMetadata metadata to respond with for query - * @returns a handler for requests - */ -export declare function fake503ForUploadServerHandler(fakeMetadata?: Partial<Metadata>, cb?: () => void): RequestHandler; -export declare function fakeOneShot503ServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler; -export {}; diff --git a/frontend-old/node_modules/@firebase/storage/package.json b/frontend-old/node_modules/@firebase/storage/package.json deleted file mode 100644 index d0b4b75..0000000 --- a/frontend-old/node_modules/@firebase/storage/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@firebase/storage", - "version": "0.14.0", - "description": "", - "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", - "main": "dist/index.node.cjs.js", - "module": "dist/index.esm.js", - "browser": "dist/index.esm.js", - "exports": { - ".": { - "types": "./dist/storage-public.d.ts", - "node": { - "import": "./dist/node-esm/index.node.esm.js", - "default": "./dist/index.node.cjs.js" - }, - "browser": { - "require": "./dist/index.cjs.js", - "import": "./dist/index.esm.js" - }, - "default": "./dist/index.esm.js" - }, - "./package.json": "./package.json" - }, - "files": [ - "dist" - ], - "scripts": { - "bundle": "rollup -c", - "lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", - "lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", - "build": "rollup -c rollup.config.js && yarn api-report", - "build:deps": "lerna run --scope @firebase/storage --include-dependencies build", - "dev": "rollup -c -w", - "test": "run-p --npm-path npm test:browser test:node lint", - "test:all": "run-p --npm-path npm test:browser test:node", - "test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all", - "test:browser:unit": "karma start --unit", - "test:browser:integration": "karma start --integration", - "test:browser": "karma start", - "test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js", - "test:debug": "karma start --browser=Chrome", - "trusted-type-check": "tsec -p tsconfig.json --noEmit", - "prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", - "api-report": "api-extractor run --local --verbose && ts-node-script ../../repo-scripts/prune-dts/prune-dts.ts --input dist/storage-public.d.ts --output dist/storage-public.d.ts", - "typings:public": "node ../../scripts/build/use_typings.js ./dist/storage-public.d.ts" - }, - "license": "Apache-2.0", - "dependencies": { - "@firebase/util": "1.13.0", - "@firebase/component": "0.7.0", - "tslib": "^2.1.0" - }, - "peerDependencies": { - "@firebase/app": "0.x" - }, - "devDependencies": { - "@firebase/app": "0.14.0", - "@firebase/auth": "1.11.0", - "rollup": "2.79.2", - "@rollup/plugin-alias": "5.1.1", - "@rollup/plugin-json": "6.1.0", - "rollup-plugin-typescript2": "0.36.0", - "typescript": "5.5.4" - }, - "repository": { - "directory": "packages/storage", - "type": "git", - "url": "git+https://github.com/firebase/firebase-js-sdk.git" - }, - "bugs": { - "url": "https://github.com/firebase/firebase-js-sdk/issues" - }, - "typings": "./dist/storage-public.d.ts", - "engines": { - "node": ">=20.0.0" - } -} |
