No Description
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.

api.d.ts 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @license
  3. * Copyright 2020 Google LLC
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { AppCheck, AppCheckOptions, AppCheckTokenResult, Unsubscribe, PartialObserver } from './public-types';
  18. import { FirebaseApp } from '@firebase/app';
  19. import { AppCheckService } from './factory';
  20. declare module '@firebase/component' {
  21. interface NameServiceMapping {
  22. 'app-check': AppCheckService;
  23. }
  24. }
  25. export { ReCaptchaV3Provider, CustomProvider, ReCaptchaEnterpriseProvider } from './providers';
  26. /**
  27. * Activate App Check for the given app. Can be called only once per app.
  28. * @param app - the {@link @firebase/app#FirebaseApp} to activate App Check for
  29. * @param options - App Check initialization options
  30. * @public
  31. */
  32. export declare function initializeAppCheck(app: FirebaseApp | undefined, options: AppCheckOptions): AppCheck;
  33. /**
  34. * Set whether App Check will automatically refresh tokens as needed.
  35. *
  36. * @param appCheckInstance - The App Check service instance.
  37. * @param isTokenAutoRefreshEnabled - If true, the SDK automatically
  38. * refreshes App Check tokens as needed. This overrides any value set
  39. * during `initializeAppCheck()`.
  40. * @public
  41. */
  42. export declare function setTokenAutoRefreshEnabled(appCheckInstance: AppCheck, isTokenAutoRefreshEnabled: boolean): void;
  43. /**
  44. * Get the current App Check token. Attaches to the most recent
  45. * in-flight request if one is present. Returns null if no token
  46. * is present and no token requests are in-flight.
  47. *
  48. * @param appCheckInstance - The App Check service instance.
  49. * @param forceRefresh - If true, will always try to fetch a fresh token.
  50. * If false, will use a cached token if found in storage.
  51. * @public
  52. */
  53. export declare function getToken(appCheckInstance: AppCheck, forceRefresh?: boolean): Promise<AppCheckTokenResult>;
  54. /**
  55. * Registers a listener to changes in the token state. There can be more
  56. * than one listener registered at the same time for one or more
  57. * App Check instances. The listeners call back on the UI thread whenever
  58. * the current token associated with this App Check instance changes.
  59. *
  60. * @param appCheckInstance - The App Check service instance.
  61. * @param observer - An object with `next`, `error`, and `complete`
  62. * properties. `next` is called with an
  63. * {@link AppCheckTokenResult}
  64. * whenever the token changes. `error` is optional and is called if an
  65. * error is thrown by the listener (the `next` function). `complete`
  66. * is unused, as the token stream is unending.
  67. *
  68. * @returns A function that unsubscribes this listener.
  69. * @public
  70. */
  71. export declare function onTokenChanged(appCheckInstance: AppCheck, observer: PartialObserver<AppCheckTokenResult>): Unsubscribe;
  72. /**
  73. * Registers a listener to changes in the token state. There can be more
  74. * than one listener registered at the same time for one or more
  75. * App Check instances. The listeners call back on the UI thread whenever
  76. * the current token associated with this App Check instance changes.
  77. *
  78. * @param appCheckInstance - The App Check service instance.
  79. * @param onNext - When the token changes, this function is called with aa
  80. * {@link AppCheckTokenResult}.
  81. * @param onError - Optional. Called if there is an error thrown by the
  82. * listener (the `onNext` function).
  83. * @param onCompletion - Currently unused, as the token stream is unending.
  84. * @returns A function that unsubscribes this listener.
  85. * @public
  86. */
  87. export declare function onTokenChanged(appCheckInstance: AppCheck, onNext: (tokenResult: AppCheckTokenResult) => void, onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;