Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. /**
  2. *
  3. * This method checks whether cookie is enabled within current browser
  4. * @return true if cookie is enabled within current browser
  5. */
  6. export declare function areCookiesEnabled(): boolean;
  7. /**
  8. * Throws an error if the provided assertion is falsy
  9. */
  10. export declare const assert: (assertion: unknown, message: string) => void;
  11. /**
  12. * Returns an Error object suitable for throwing.
  13. */
  14. export declare const assertionError: (message: string) => Error;
  15. /** Turn synchronous function into one called asynchronously. */
  16. export declare function async(fn: Function, onError?: ErrorFn): Function;
  17. /**
  18. * @license
  19. * Copyright 2017 Google LLC
  20. *
  21. * Licensed under the Apache License, Version 2.0 (the "License");
  22. * you may not use this file except in compliance with the License.
  23. * You may obtain a copy of the License at
  24. *
  25. * http://www.apache.org/licenses/LICENSE-2.0
  26. *
  27. * Unless required by applicable law or agreed to in writing, software
  28. * distributed under the License is distributed on an "AS IS" BASIS,
  29. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  30. * See the License for the specific language governing permissions and
  31. * limitations under the License.
  32. */
  33. declare interface Base64 {
  34. byteToCharMap_: {
  35. [key: number]: string;
  36. } | null;
  37. charToByteMap_: {
  38. [key: string]: number;
  39. } | null;
  40. byteToCharMapWebSafe_: {
  41. [key: number]: string;
  42. } | null;
  43. charToByteMapWebSafe_: {
  44. [key: string]: number;
  45. } | null;
  46. ENCODED_VALS_BASE: string;
  47. readonly ENCODED_VALS: string;
  48. readonly ENCODED_VALS_WEBSAFE: string;
  49. HAS_NATIVE_SUPPORT: boolean;
  50. encodeByteArray(input: number[] | Uint8Array, webSafe?: boolean): string;
  51. encodeString(input: string, webSafe?: boolean): string;
  52. decodeString(input: string, webSafe: boolean): string;
  53. decodeStringToByteArray(input: string, webSafe: boolean): number[];
  54. init_(): void;
  55. }
  56. export declare const base64: Base64;
  57. /**
  58. * URL-safe base64 decoding
  59. *
  60. * NOTE: DO NOT use the global atob() function - it does NOT support the
  61. * base64Url variant encoding.
  62. *
  63. * @param str To be decoded
  64. * @return Decoded result, if possible
  65. */
  66. export declare const base64Decode: (str: string) => string | null;
  67. /**
  68. * URL-safe base64 encoding
  69. */
  70. export declare const base64Encode: (str: string) => string;
  71. /**
  72. * URL-safe base64 encoding (without "." padding in the end).
  73. * e.g. Used in JSON Web Token (JWT) parts.
  74. */
  75. export declare const base64urlEncodeWithoutPadding: (str: string) => string;
  76. /**
  77. * Based on the backoff method from
  78. * https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.
  79. * Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.
  80. */
  81. export declare function calculateBackoffMillis(backoffCount: number, intervalMillis?: number, backoffFactor?: number): number;
  82. /**
  83. * @license
  84. * Copyright 2017 Google LLC
  85. *
  86. * Licensed under the Apache License, Version 2.0 (the "License");
  87. * you may not use this file except in compliance with the License.
  88. * You may obtain a copy of the License at
  89. *
  90. * http://www.apache.org/licenses/LICENSE-2.0
  91. *
  92. * Unless required by applicable law or agreed to in writing, software
  93. * distributed under the License is distributed on an "AS IS" BASIS,
  94. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  95. * See the License for the specific language governing permissions and
  96. * limitations under the License.
  97. */
  98. declare interface Claims {
  99. [key: string]: {};
  100. }
  101. /**
  102. * @license
  103. * Copyright 2021 Google LLC
  104. *
  105. * Licensed under the Apache License, Version 2.0 (the "License");
  106. * you may not use this file except in compliance with the License.
  107. * You may obtain a copy of the License at
  108. *
  109. * http://www.apache.org/licenses/LICENSE-2.0
  110. *
  111. * Unless required by applicable law or agreed to in writing, software
  112. * distributed under the License is distributed on an "AS IS" BASIS,
  113. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  114. * See the License for the specific language governing permissions and
  115. * limitations under the License.
  116. */
  117. export declare interface Compat<T> {
  118. _delegate: T;
  119. }
  120. export declare type CompleteFn = () => void;
  121. /**
  122. * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time.
  123. */
  124. export declare const CONSTANTS: {
  125. /**
  126. * @define {boolean} Whether this is the client Node.js SDK.
  127. */
  128. NODE_CLIENT: boolean;
  129. /**
  130. * @define {boolean} Whether this is the Admin Node.js SDK.
  131. */
  132. NODE_ADMIN: boolean;
  133. /**
  134. * Firebase SDK Version
  135. */
  136. SDK_VERSION: string;
  137. };
  138. /**
  139. * @license
  140. * Copyright 2017 Google LLC
  141. *
  142. * Licensed under the Apache License, Version 2.0 (the "License");
  143. * you may not use this file except in compliance with the License.
  144. * You may obtain a copy of the License at
  145. *
  146. * http://www.apache.org/licenses/LICENSE-2.0
  147. *
  148. * Unless required by applicable law or agreed to in writing, software
  149. * distributed under the License is distributed on an "AS IS" BASIS,
  150. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  151. * See the License for the specific language governing permissions and
  152. * limitations under the License.
  153. */
  154. export declare function contains<T extends object>(obj: T, key: string): boolean;
  155. export declare function createMockUserToken(token: EmulatorMockTokenOptions, projectId?: string): string;
  156. /**
  157. * Helper to make a Subscribe function (just like Promise helps make a
  158. * Thenable).
  159. *
  160. * @param executor Function which can make calls to a single Observer
  161. * as a proxy.
  162. * @param onNoObservers Callback when count of Observers goes to zero.
  163. */
  164. export declare function createSubscribe<T>(executor: Executor<T>, onNoObservers?: Executor<T>): Subscribe<T>;
  165. /**
  166. * Decodes a Firebase auth. token into constituent parts.
  167. *
  168. * Notes:
  169. * - May return with invalid / incomplete claims if there's no native base64 decoding support.
  170. * - Doesn't check if the token is actually valid.
  171. */
  172. export declare const decode: (token: string) => DecodedToken;
  173. declare interface DecodedToken {
  174. header: object;
  175. claims: Claims;
  176. data: object;
  177. signature: string;
  178. }
  179. declare interface DecodedToken {
  180. header: object;
  181. claims: Claims;
  182. data: object;
  183. signature: string;
  184. }
  185. /**
  186. * @license
  187. * Copyright 2017 Google LLC
  188. *
  189. * Licensed under the Apache License, Version 2.0 (the "License");
  190. * you may not use this file except in compliance with the License.
  191. * You may obtain a copy of the License at
  192. *
  193. * http://www.apache.org/licenses/LICENSE-2.0
  194. *
  195. * Unless required by applicable law or agreed to in writing, software
  196. * distributed under the License is distributed on an "AS IS" BASIS,
  197. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  198. * See the License for the specific language governing permissions and
  199. * limitations under the License.
  200. */
  201. /**
  202. * Do a deep-copy of basic JavaScript Objects or Arrays.
  203. */
  204. export declare function deepCopy<T>(value: T): T;
  205. /**
  206. * Deep equal two objects. Support Arrays and Objects.
  207. */
  208. export declare function deepEqual(a: object, b: object): boolean;
  209. /**
  210. * Copy properties from source to target (recursively allows extension
  211. * of Objects and Arrays). Scalar values in the target are over-written.
  212. * If target is undefined, an object of the appropriate type will be created
  213. * (and returned).
  214. *
  215. * We recursively copy all child properties of plain Objects in the source- so
  216. * that namespace- like dictionaries are merged.
  217. *
  218. * Note that the target can be a function, in which case the properties in
  219. * the source Object are copied onto it as static properties of the Function.
  220. *
  221. * Note: we don't merge __proto__ to prevent prototype pollution
  222. */
  223. export declare function deepExtend(target: unknown, source: unknown): unknown;
  224. /**
  225. * @license
  226. * Copyright 2017 Google LLC
  227. *
  228. * Licensed under the Apache License, Version 2.0 (the "License");
  229. * you may not use this file except in compliance with the License.
  230. * You may obtain a copy of the License at
  231. *
  232. * http://www.apache.org/licenses/LICENSE-2.0
  233. *
  234. * Unless required by applicable law or agreed to in writing, software
  235. * distributed under the License is distributed on an "AS IS" BASIS,
  236. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  237. * See the License for the specific language governing permissions and
  238. * limitations under the License.
  239. */
  240. export declare class Deferred<R> {
  241. promise: Promise<R>;
  242. reject: (value?: unknown) => void;
  243. resolve: (value?: unknown) => void;
  244. constructor();
  245. /**
  246. * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around
  247. * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
  248. * and returns a node-style callback which will resolve or reject the Deferred's promise.
  249. */
  250. wrapCallback(callback?: (error?: unknown, value?: unknown) => void): (error: unknown, value?: unknown) => void;
  251. }
  252. export declare type EmulatorMockTokenOptions = ({
  253. user_id: string;
  254. } | {
  255. sub: string;
  256. }) & Partial<FirebaseIdToken>;
  257. export declare interface ErrorData {
  258. [key: string]: unknown;
  259. }
  260. export declare class ErrorFactory<ErrorCode extends string, ErrorParams extends {
  261. readonly [K in ErrorCode]?: ErrorData;
  262. } = {}> {
  263. private readonly service;
  264. private readonly serviceName;
  265. private readonly errors;
  266. constructor(service: string, serviceName: string, errors: ErrorMap<ErrorCode>);
  267. create<K extends ErrorCode>(code: K, ...data: K extends keyof ErrorParams ? [ErrorParams[K]] : []): FirebaseError;
  268. }
  269. export declare type ErrorFn = (error: Error) => void;
  270. /**
  271. * @license
  272. * Copyright 2017 Google LLC
  273. *
  274. * Licensed under the Apache License, Version 2.0 (the "License");
  275. * you may not use this file except in compliance with the License.
  276. * You may obtain a copy of the License at
  277. *
  278. * http://www.apache.org/licenses/LICENSE-2.0
  279. *
  280. * Unless required by applicable law or agreed to in writing, software
  281. * distributed under the License is distributed on an "AS IS" BASIS,
  282. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  283. * See the License for the specific language governing permissions and
  284. * limitations under the License.
  285. */
  286. /**
  287. * @fileoverview Standardized Firebase Error.
  288. *
  289. * Usage:
  290. *
  291. * // Typescript string literals for type-safe codes
  292. * type Err =
  293. * 'unknown' |
  294. * 'object-not-found'
  295. * ;
  296. *
  297. * // Closure enum for type-safe error codes
  298. * // at-enum {string}
  299. * var Err = {
  300. * UNKNOWN: 'unknown',
  301. * OBJECT_NOT_FOUND: 'object-not-found',
  302. * }
  303. *
  304. * let errors: Map<Err, string> = {
  305. * 'generic-error': "Unknown error",
  306. * 'file-not-found': "Could not find file: {$file}",
  307. * };
  308. *
  309. * // Type-safe function - must pass a valid error code as param.
  310. * let error = new ErrorFactory<Err>('service', 'Service', errors);
  311. *
  312. * ...
  313. * throw error.create(Err.GENERIC);
  314. * ...
  315. * throw error.create(Err.FILE_NOT_FOUND, {'file': fileName});
  316. * ...
  317. * // Service: Could not file file: foo.txt (service/file-not-found).
  318. *
  319. * catch (e) {
  320. * assert(e.message === "Could not find file: foo.txt.");
  321. * if ((e as FirebaseError)?.code === 'service/file-not-found') {
  322. * console.log("Could not read file: " + e['file']);
  323. * }
  324. * }
  325. */
  326. export declare type ErrorMap<ErrorCode extends string> = {
  327. readonly [K in ErrorCode]: string;
  328. };
  329. /**
  330. * Generates a string to prefix an error message about failed argument validation
  331. *
  332. * @param fnName The function name
  333. * @param argName The name of the argument
  334. * @return The prefix to add to the error thrown for validation.
  335. */
  336. export declare function errorPrefix(fnName: string, argName: string): string;
  337. export declare type Executor<T> = (observer: Observer<T>) => void;
  338. /**
  339. * @license
  340. * Copyright 2022 Google LLC
  341. *
  342. * Licensed under the Apache License, Version 2.0 (the "License");
  343. * you may not use this file except in compliance with the License.
  344. * You may obtain a copy of the License at
  345. *
  346. * http://www.apache.org/licenses/LICENSE-2.0
  347. *
  348. * Unless required by applicable law or agreed to in writing, software
  349. * distributed under the License is distributed on an "AS IS" BASIS,
  350. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  351. * See the License for the specific language governing permissions and
  352. * limitations under the License.
  353. */
  354. /**
  355. * Keys for experimental properties on the `FirebaseDefaults` object.
  356. * @public
  357. */
  358. export declare type ExperimentalKey = 'authTokenSyncURL' | 'authIdTokenMaxAge';
  359. /**
  360. * Extract the query string part of a URL, including the leading question mark (if present).
  361. */
  362. export declare function extractQuerystring(url: string): string;
  363. /**
  364. * An object that can be injected into the environment as __FIREBASE_DEFAULTS__,
  365. * either as a property of globalThis, a shell environment variable, or a
  366. * cookie.
  367. *
  368. * This object can be used to automatically configure and initialize
  369. * a Firebase app as well as any emulators.
  370. *
  371. * @public
  372. */
  373. export declare interface FirebaseDefaults {
  374. config?: Record<string, string>;
  375. emulatorHosts?: Record<string, string>;
  376. _authTokenSyncURL?: string;
  377. _authIdTokenMaxAge?: number;
  378. /**
  379. * Override Firebase's runtime environment detection and
  380. * force the SDK to act as if it were in the specified environment.
  381. */
  382. forceEnvironment?: 'browser' | 'node';
  383. [key: string]: unknown;
  384. }
  385. export declare class FirebaseError extends Error {
  386. /** The error code for this error. */
  387. readonly code: string;
  388. /** Custom data for this error. */
  389. customData?: Record<string, unknown> | undefined;
  390. /** The custom name for all FirebaseErrors. */
  391. readonly name: string;
  392. constructor(
  393. /** The error code for this error. */
  394. code: string, message: string,
  395. /** Custom data for this error. */
  396. customData?: Record<string, unknown> | undefined);
  397. }
  398. declare interface FirebaseIdToken {
  399. iss: string;
  400. aud: string;
  401. sub: string;
  402. iat: number;
  403. exp: number;
  404. user_id: string;
  405. auth_time: number;
  406. provider_id?: 'anonymous';
  407. email?: string;
  408. email_verified?: boolean;
  409. phone_number?: string;
  410. name?: string;
  411. picture?: string;
  412. firebase: {
  413. sign_in_provider: FirebaseSignInProvider;
  414. identities?: {
  415. [provider in FirebaseSignInProvider]?: string[];
  416. };
  417. };
  418. [claim: string]: unknown;
  419. uid?: never;
  420. }
  421. /**
  422. * @license
  423. * Copyright 2021 Google LLC
  424. *
  425. * Licensed under the Apache License, Version 2.0 (the "License");
  426. * you may not use this file except in compliance with the License.
  427. * You may obtain a copy of the License at
  428. *
  429. * http://www.apache.org/licenses/LICENSE-2.0
  430. *
  431. * Unless required by applicable law or agreed to in writing, software
  432. * distributed under the License is distributed on an "AS IS" BASIS,
  433. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  434. * See the License for the specific language governing permissions and
  435. * limitations under the License.
  436. */
  437. export declare type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
  438. /**
  439. * Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
  440. * @public
  441. */
  442. export declare const getDefaultAppConfig: () => Record<string, string> | undefined;
  443. /**
  444. * Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
  445. * for the given product.
  446. * @returns a URL host formatted like `127.0.0.1:9999` or `[::1]:4000` if available
  447. * @public
  448. */
  449. export declare const getDefaultEmulatorHost: (productName: string) => string | undefined;
  450. /**
  451. * Returns emulator hostname and port stored in the __FIREBASE_DEFAULTS__ object
  452. * for the given product.
  453. * @returns a pair of hostname and port like `["::1", 4000]` if available
  454. * @public
  455. */
  456. export declare const getDefaultEmulatorHostnameAndPort: (productName: string) => [hostname: string, port: number] | undefined;
  457. /**
  458. * Get the __FIREBASE_DEFAULTS__ object. It checks in order:
  459. * (1) if such an object exists as a property of `globalThis`
  460. * (2) if such an object was provided on a shell environment variable
  461. * (3) if such an object exists in a cookie
  462. * @public
  463. */
  464. export declare const getDefaults: () => FirebaseDefaults | undefined;
  465. /**
  466. * Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
  467. * prefixed by "_")
  468. * @public
  469. */
  470. export declare const getExperimentalSetting: <T extends ExperimentalKey>(name: T) => FirebaseDefaults[`_${T}`];
  471. /**
  472. * @license
  473. * Copyright 2022 Google LLC
  474. *
  475. * Licensed under the Apache License, Version 2.0 (the "License");
  476. * you may not use this file except in compliance with the License.
  477. * You may obtain a copy of the License at
  478. *
  479. * http://www.apache.org/licenses/LICENSE-2.0
  480. *
  481. * Unless required by applicable law or agreed to in writing, software
  482. * distributed under the License is distributed on an "AS IS" BASIS,
  483. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  484. * See the License for the specific language governing permissions and
  485. * limitations under the License.
  486. */
  487. /**
  488. * Polyfill for `globalThis` object.
  489. * @returns the `globalThis` object for the given environment.
  490. * @public
  491. */
  492. export declare function getGlobal(): typeof globalThis;
  493. export declare function getModularInstance<ExpService>(service: Compat<ExpService> | ExpService): ExpService;
  494. /**
  495. * @license
  496. * Copyright 2017 Google LLC
  497. *
  498. * Licensed under the Apache License, Version 2.0 (the "License");
  499. * you may not use this file except in compliance with the License.
  500. * You may obtain a copy of the License at
  501. *
  502. * http://www.apache.org/licenses/LICENSE-2.0
  503. *
  504. * Unless required by applicable law or agreed to in writing, software
  505. * distributed under the License is distributed on an "AS IS" BASIS,
  506. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  507. * See the License for the specific language governing permissions and
  508. * limitations under the License.
  509. */
  510. /**
  511. * Returns navigator.userAgent string or '' if it's not defined.
  512. * @return user agent string
  513. */
  514. export declare function getUA(): string;
  515. /**
  516. * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
  517. *
  518. * Notes:
  519. * - May return a false negative if there's no native base64 decoding support.
  520. * - Doesn't check if the token is actually valid.
  521. */
  522. export declare const isAdmin: (token: string) => boolean;
  523. /**
  524. * Detect Browser Environment
  525. */
  526. export declare function isBrowser(): boolean;
  527. export declare function isBrowserExtension(): boolean;
  528. /** Detects Electron apps. */
  529. export declare function isElectron(): boolean;
  530. export declare function isEmpty(obj: object): obj is {};
  531. /** Detects Internet Explorer. */
  532. export declare function isIE(): boolean;
  533. /**
  534. * This method checks if indexedDB is supported by current browser/service worker context
  535. * @return true if indexedDB is supported by current browser/service worker context
  536. */
  537. export declare function isIndexedDBAvailable(): boolean;
  538. /**
  539. * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.
  540. *
  541. * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap
  542. * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally
  543. * wait for a callback.
  544. */
  545. export declare function isMobileCordova(): boolean;
  546. /**
  547. * Detect Node.js.
  548. *
  549. * @return true if Node.js environment is detected or specified.
  550. */
  551. export declare function isNode(): boolean;
  552. /**
  553. * Detect whether the current SDK build is the Node version.
  554. *
  555. * @return true if it's the Node SDK build.
  556. */
  557. export declare function isNodeSdk(): boolean;
  558. /**
  559. * Detect React Native.
  560. *
  561. * @return true if ReactNative environment is detected.
  562. */
  563. export declare function isReactNative(): boolean;
  564. /** Returns true if we are running in Safari. */
  565. export declare function isSafari(): boolean;
  566. /**
  567. * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
  568. *
  569. * Notes:
  570. * - May return null if there's no native base64 decoding support.
  571. * - Doesn't check if the token is actually valid.
  572. */
  573. export declare const issuedAtTime: (token: string) => number | null;
  574. /** Detects Universal Windows Platform apps. */
  575. export declare function isUWP(): boolean;
  576. /**
  577. * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
  578. *
  579. * Notes:
  580. * - May return a false negative if there's no native base64 decoding support.
  581. * - Doesn't check if the token is actually valid.
  582. */
  583. export declare const isValidFormat: (token: string) => boolean;
  584. /**
  585. * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
  586. * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
  587. *
  588. * Notes:
  589. * - May return a false negative if there's no native base64 decoding support.
  590. * - Doesn't check if the token is actually valid.
  591. */
  592. export declare const isValidTimestamp: (token: string) => boolean;
  593. /**
  594. * @license
  595. * Copyright 2017 Google LLC
  596. *
  597. * Licensed under the Apache License, Version 2.0 (the "License");
  598. * you may not use this file except in compliance with the License.
  599. * You may obtain a copy of the License at
  600. *
  601. * http://www.apache.org/licenses/LICENSE-2.0
  602. *
  603. * Unless required by applicable law or agreed to in writing, software
  604. * distributed under the License is distributed on an "AS IS" BASIS,
  605. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  606. * See the License for the specific language governing permissions and
  607. * limitations under the License.
  608. */
  609. /**
  610. * Evaluates a JSON string into a javascript object.
  611. *
  612. * @param {string} str A string containing JSON.
  613. * @return {*} The javascript object representing the specified JSON.
  614. */
  615. export declare function jsonEval(str: string): unknown;
  616. export declare function map<K extends string, V, U>(obj: {
  617. [key in K]: V;
  618. }, fn: (value: V, key: K, obj: {
  619. [key in K]: V;
  620. }) => U, contextObj?: unknown): {
  621. [key in K]: U;
  622. };
  623. /**
  624. * The maximum milliseconds to increase to.
  625. *
  626. * <p>Visible for testing
  627. */
  628. export declare const MAX_VALUE_MILLIS: number;
  629. /**
  630. * @license
  631. * Copyright 2017 Google LLC
  632. *
  633. * Licensed under the Apache License, Version 2.0 (the "License");
  634. * you may not use this file except in compliance with the License.
  635. * You may obtain a copy of the License at
  636. *
  637. * http://www.apache.org/licenses/LICENSE-2.0
  638. *
  639. * Unless required by applicable law or agreed to in writing, software
  640. * distributed under the License is distributed on an "AS IS" BASIS,
  641. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  642. * See the License for the specific language governing permissions and
  643. * limitations under the License.
  644. */
  645. export declare type NextFn<T> = (value: T) => void;
  646. export declare interface Observable<T> {
  647. subscribe: Subscribe<T>;
  648. }
  649. export declare interface Observer<T> {
  650. next: NextFn<T>;
  651. error: ErrorFn;
  652. complete: CompleteFn;
  653. }
  654. /**
  655. * @license
  656. * Copyright 2020 Google LLC
  657. *
  658. * Licensed under the Apache License, Version 2.0 (the "License");
  659. * you may not use this file except in compliance with the License.
  660. * You may obtain a copy of the License at
  661. *
  662. * http://www.apache.org/licenses/LICENSE-2.0
  663. *
  664. * Unless required by applicable law or agreed to in writing, software
  665. * distributed under the License is distributed on an "AS IS" BASIS,
  666. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  667. * See the License for the specific language governing permissions and
  668. * limitations under the License.
  669. */
  670. /**
  671. * Provide English ordinal letters after a number
  672. */
  673. export declare function ordinal(i: number): string;
  674. export declare type PartialObserver<T> = Partial<Observer<T>>;
  675. /**
  676. * @license
  677. * Copyright 2022 Google LLC
  678. *
  679. * Licensed under the Apache License, Version 2.0 (the "License");
  680. * you may not use this file except in compliance with the License.
  681. * You may obtain a copy of the License at
  682. *
  683. * http://www.apache.org/licenses/LICENSE-2.0
  684. *
  685. * Unless required by applicable law or agreed to in writing, software
  686. * distributed under the License is distributed on an "AS IS" BASIS,
  687. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  688. * See the License for the specific language governing permissions and
  689. * limitations under the License.
  690. */
  691. /**
  692. * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
  693. * @internal
  694. */
  695. export declare function promiseWithTimeout<T>(promise: Promise<T>, timeInMS?: number): Promise<T>;
  696. /**
  697. * @license
  698. * Copyright 2017 Google LLC
  699. *
  700. * Licensed under the Apache License, Version 2.0 (the "License");
  701. * you may not use this file except in compliance with the License.
  702. * You may obtain a copy of the License at
  703. *
  704. * http://www.apache.org/licenses/LICENSE-2.0
  705. *
  706. * Unless required by applicable law or agreed to in writing, software
  707. * distributed under the License is distributed on an "AS IS" BASIS,
  708. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  709. * See the License for the specific language governing permissions and
  710. * limitations under the License.
  711. */
  712. /**
  713. * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
  714. * params object (e.g. {arg: 'val', arg2: 'val2'})
  715. * Note: You must prepend it with ? when adding it to a URL.
  716. */
  717. export declare function querystring(querystringParams: {
  718. [key: string]: string | number;
  719. }): string;
  720. /**
  721. * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
  722. * (e.g. {arg: 'val', arg2: 'val2'})
  723. */
  724. export declare function querystringDecode(querystring: string): Record<string, string>;
  725. /**
  726. * The percentage of backoff time to randomize by.
  727. * See
  728. * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
  729. * for context.
  730. *
  731. * <p>Visible for testing
  732. */
  733. export declare const RANDOM_FACTOR = 0.5;
  734. export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
  735. /**
  736. * @license
  737. * Copyright 2017 Google LLC
  738. *
  739. * Licensed under the Apache License, Version 2.0 (the "License");
  740. * you may not use this file except in compliance with the License.
  741. * You may obtain a copy of the License at
  742. *
  743. * http://www.apache.org/licenses/LICENSE-2.0
  744. *
  745. * Unless required by applicable law or agreed to in writing, software
  746. * distributed under the License is distributed on an "AS IS" BASIS,
  747. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  748. * See the License for the specific language governing permissions and
  749. * limitations under the License.
  750. */
  751. /**
  752. * @fileoverview SHA-1 cryptographic hash.
  753. * Variable names follow the notation in FIPS PUB 180-3:
  754. * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
  755. *
  756. * Usage:
  757. * var sha1 = new sha1();
  758. * sha1.update(bytes);
  759. * var hash = sha1.digest();
  760. *
  761. * Performance:
  762. * Chrome 23: ~400 Mbit/s
  763. * Firefox 16: ~250 Mbit/s
  764. *
  765. */
  766. /**
  767. * SHA-1 cryptographic hash constructor.
  768. *
  769. * The properties declared here are discussed in the above algorithm document.
  770. * @constructor
  771. * @final
  772. * @struct
  773. */
  774. export declare class Sha1 {
  775. /**
  776. * Holds the previous values of accumulated variables a-e in the compress_
  777. * function.
  778. * @private
  779. */
  780. private chain_;
  781. /**
  782. * A buffer holding the partially computed hash result.
  783. * @private
  784. */
  785. private buf_;
  786. /**
  787. * An array of 80 bytes, each a part of the message to be hashed. Referred to
  788. * as the message schedule in the docs.
  789. * @private
  790. */
  791. private W_;
  792. /**
  793. * Contains data needed to pad messages less than 64 bytes.
  794. * @private
  795. */
  796. private pad_;
  797. /**
  798. * @private {number}
  799. */
  800. private inbuf_;
  801. /**
  802. * @private {number}
  803. */
  804. private total_;
  805. blockSize: number;
  806. constructor();
  807. reset(): void;
  808. /**
  809. * Internal compress helper function.
  810. * @param buf Block to compress.
  811. * @param offset Offset of the block in the buffer.
  812. * @private
  813. */
  814. compress_(buf: number[] | Uint8Array | string, offset?: number): void;
  815. update(bytes?: number[] | Uint8Array | string, length?: number): void;
  816. /** @override */
  817. digest(): number[];
  818. }
  819. /**
  820. * Returns JSON representing a javascript object.
  821. * @param {*} data Javascript object to be stringified.
  822. * @return {string} The JSON contents of the object.
  823. */
  824. export declare function stringify(data: unknown): string;
  825. /**
  826. * Calculate length without actually converting; useful for doing cheaper validation.
  827. * @param {string} str
  828. * @return {number}
  829. */
  830. export declare const stringLength: (str: string) => number;
  831. export declare interface StringLike {
  832. toString(): string;
  833. }
  834. /**
  835. * @param {string} str
  836. * @return {Array}
  837. */
  838. export declare const stringToByteArray: (str: string) => number[];
  839. /**
  840. * The Subscribe interface has two forms - passing the inline function
  841. * callbacks, or a object interface with callback properties.
  842. */
  843. export declare interface Subscribe<T> {
  844. (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
  845. (observer: PartialObserver<T>): Unsubscribe;
  846. }
  847. export declare type Unsubscribe = () => void;
  848. /**
  849. * Copied from https://stackoverflow.com/a/2117523
  850. * Generates a new uuid.
  851. * @public
  852. */
  853. export declare const uuidv4: () => string;
  854. /**
  855. * Check to make sure the appropriate number of arguments are provided for a public function.
  856. * Throws an error if it fails.
  857. *
  858. * @param fnName The function name
  859. * @param minCount The minimum number of arguments to allow for the function call
  860. * @param maxCount The maximum number of argument to allow for the function call
  861. * @param argCount The actual number of arguments provided.
  862. */
  863. export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
  864. export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
  865. export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
  866. /**
  867. * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
  868. * if errors occur during the database open operation.
  869. *
  870. * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
  871. * private browsing)
  872. */
  873. export declare function validateIndexedDBOpenable(): Promise<boolean>;
  874. /**
  875. * @param fnName
  876. * @param argumentNumber
  877. * @param namespace
  878. * @param optional
  879. */
  880. export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
  881. export { }