mock_auth.d.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 { Provider } from '@firebase/component';
  18. import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
  19. import { PopupRedirectResolver } from '../../src/model/public_types';
  20. import { AuthImpl } from '../../src/core/auth/auth_impl';
  21. import { PersistedBlob } from '../../src/core/persistence';
  22. import { InMemoryPersistence } from '../../src/core/persistence/in_memory';
  23. import { AuthInternal } from '../../src/model/auth';
  24. import { UserInternal } from '../../src/model/user';
  25. export declare const TEST_HOST = "localhost";
  26. export declare const TEST_TOKEN_HOST = "localhost/token";
  27. export declare const TEST_AUTH_DOMAIN = "localhost";
  28. export declare const TEST_SCHEME = "mock";
  29. export declare const TEST_KEY = "test-api-key";
  30. export interface TestAuth extends AuthImpl {
  31. persistenceLayer: MockPersistenceLayer;
  32. }
  33. export declare const FAKE_HEARTBEAT_CONTROLLER: {
  34. getHeartbeatsHeader: () => Promise<string>;
  35. };
  36. export declare const FAKE_HEARTBEAT_CONTROLLER_PROVIDER: Provider<'heartbeat'>;
  37. export declare const FAKE_APP_CHECK_CONTROLLER: {
  38. getToken: () => Promise<AppCheckTokenResult>;
  39. };
  40. export declare const FAKE_APP_CHECK_CONTROLLER_PROVIDER: Provider<'app-check-internal'>;
  41. export declare class MockPersistenceLayer extends InMemoryPersistence {
  42. lastObjectSet: PersistedBlob | null;
  43. _set(key: string, object: PersistedBlob): Promise<void>;
  44. _remove(key: string): Promise<void>;
  45. }
  46. export declare function testAuth(popupRedirectResolver?: PopupRedirectResolver, persistence?: MockPersistenceLayer, skipAwaitOnInit?: boolean): Promise<TestAuth>;
  47. export declare function testUser(auth: AuthInternal, uid: string, email?: string, fakeTokens?: boolean): UserInternal;