GSI - Employe Self Service Mobile
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.

949 lines
30 KiB

2 months ago
  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. /* Excluded from this release type: promiseWithTimeout */
  676. /**
  677. * @license
  678. * Copyright 2017 Google LLC
  679. *
  680. * Licensed under the Apache License, Version 2.0 (the "License");
  681. * you may not use this file except in compliance with the License.
  682. * You may obtain a copy of the License at
  683. *
  684. * http://www.apache.org/licenses/LICENSE-2.0
  685. *
  686. * Unless required by applicable law or agreed to in writing, software
  687. * distributed under the License is distributed on an "AS IS" BASIS,
  688. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  689. * See the License for the specific language governing permissions and
  690. * limitations under the License.
  691. */
  692. /**
  693. * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
  694. * params object (e.g. {arg: 'val', arg2: 'val2'})
  695. * Note: You must prepend it with ? when adding it to a URL.
  696. */
  697. export declare function querystring(querystringParams: {
  698. [key: string]: string | number;
  699. }): string;
  700. /**
  701. * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
  702. * (e.g. {arg: 'val', arg2: 'val2'})
  703. */
  704. export declare function querystringDecode(querystring: string): Record<string, string>;
  705. /**
  706. * The percentage of backoff time to randomize by.
  707. * See
  708. * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic
  709. * for context.
  710. *
  711. * <p>Visible for testing
  712. */
  713. export declare const RANDOM_FACTOR = 0.5;
  714. export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
  715. /**
  716. * @license
  717. * Copyright 2017 Google LLC
  718. *
  719. * Licensed under the Apache License, Version 2.0 (the "License");
  720. * you may not use this file except in compliance with the License.
  721. * You may obtain a copy of the License at
  722. *
  723. * http://www.apache.org/licenses/LICENSE-2.0
  724. *
  725. * Unless required by applicable law or agreed to in writing, software
  726. * distributed under the License is distributed on an "AS IS" BASIS,
  727. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  728. * See the License for the specific language governing permissions and
  729. * limitations under the License.
  730. */
  731. /**
  732. * @fileoverview SHA-1 cryptographic hash.
  733. * Variable names follow the notation in FIPS PUB 180-3:
  734. * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
  735. *
  736. * Usage:
  737. * var sha1 = new sha1();
  738. * sha1.update(bytes);
  739. * var hash = sha1.digest();
  740. *
  741. * Performance:
  742. * Chrome 23: ~400 Mbit/s
  743. * Firefox 16: ~250 Mbit/s
  744. *
  745. */
  746. /**
  747. * SHA-1 cryptographic hash constructor.
  748. *
  749. * The properties declared here are discussed in the above algorithm document.
  750. * @constructor
  751. * @final
  752. * @struct
  753. */
  754. export declare class Sha1 {
  755. /**
  756. * Holds the previous values of accumulated variables a-e in the compress_
  757. * function.
  758. * @private
  759. */
  760. private chain_;
  761. /**
  762. * A buffer holding the partially computed hash result.
  763. * @private
  764. */
  765. private buf_;
  766. /**
  767. * An array of 80 bytes, each a part of the message to be hashed. Referred to
  768. * as the message schedule in the docs.
  769. * @private
  770. */
  771. private W_;
  772. /**
  773. * Contains data needed to pad messages less than 64 bytes.
  774. * @private
  775. */
  776. private pad_;
  777. /**
  778. * @private {number}
  779. */
  780. private inbuf_;
  781. /**
  782. * @private {number}
  783. */
  784. private total_;
  785. blockSize: number;
  786. constructor();
  787. reset(): void;
  788. /**
  789. * Internal compress helper function.
  790. * @param buf Block to compress.
  791. * @param offset Offset of the block in the buffer.
  792. * @private
  793. */
  794. compress_(buf: number[] | Uint8Array | string, offset?: number): void;
  795. update(bytes?: number[] | Uint8Array | string, length?: number): void;
  796. /** @override */
  797. digest(): number[];
  798. }
  799. /**
  800. * Returns JSON representing a javascript object.
  801. * @param {*} data Javascript object to be stringified.
  802. * @return {string} The JSON contents of the object.
  803. */
  804. export declare function stringify(data: unknown): string;
  805. /**
  806. * Calculate length without actually converting; useful for doing cheaper validation.
  807. * @param {string} str
  808. * @return {number}
  809. */
  810. export declare const stringLength: (str: string) => number;
  811. export declare interface StringLike {
  812. toString(): string;
  813. }
  814. /**
  815. * @param {string} str
  816. * @return {Array}
  817. */
  818. export declare const stringToByteArray: (str: string) => number[];
  819. /**
  820. * The Subscribe interface has two forms - passing the inline function
  821. * callbacks, or a object interface with callback properties.
  822. */
  823. export declare interface Subscribe<T> {
  824. (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
  825. (observer: PartialObserver<T>): Unsubscribe;
  826. }
  827. export declare type Unsubscribe = () => void;
  828. /**
  829. * Copied from https://stackoverflow.com/a/2117523
  830. * Generates a new uuid.
  831. * @public
  832. */
  833. export declare const uuidv4: () => string;
  834. /**
  835. * Check to make sure the appropriate number of arguments are provided for a public function.
  836. * Throws an error if it fails.
  837. *
  838. * @param fnName The function name
  839. * @param minCount The minimum number of arguments to allow for the function call
  840. * @param maxCount The maximum number of argument to allow for the function call
  841. * @param argCount The actual number of arguments provided.
  842. */
  843. export declare const validateArgCount: (fnName: string, minCount: number, maxCount: number, argCount: number) => void;
  844. export declare function validateCallback(fnName: string, argumentName: string, callback: Function, optional: boolean): void;
  845. export declare function validateContextObject(fnName: string, argumentName: string, context: unknown, optional: boolean): void;
  846. /**
  847. * This method validates browser/sw context for indexedDB by opening a dummy indexedDB database and reject
  848. * if errors occur during the database open operation.
  849. *
  850. * @throws exception if current browser/sw context can't run idb.open (ex: Safari iframe, Firefox
  851. * private browsing)
  852. */
  853. export declare function validateIndexedDBOpenable(): Promise<boolean>;
  854. /**
  855. * @param fnName
  856. * @param argumentNumber
  857. * @param namespace
  858. * @param optional
  859. */
  860. export declare function validateNamespace(fnName: string, namespace: string, optional: boolean): void;
  861. export { }