|
| 1 | +/*! |
| 2 | + * Copyright 2020 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * Firebase Phone Number Verification. |
| 19 | + * |
| 20 | + * @packageDocumentation |
| 21 | + */ |
| 22 | + |
| 23 | +import { App, getApp } from '../app'; |
| 24 | +import { FirebaseApp } from '../app/firebase-app'; |
| 25 | +import { Fpnv } from './fpnv'; |
| 26 | + |
| 27 | +/** |
| 28 | + * Gets the {@link Fpnv} service for the default app or a |
| 29 | + * given app. |
| 30 | + * |
| 31 | + * `getFirebasePnv()` can be called with no arguments to access the default app's |
| 32 | + * {@link Fpnv} service or as `getFirebasePnv(app)` to access the |
| 33 | + * {@link Fpnv} service associated with a specific app. |
| 34 | + * |
| 35 | + * @example |
| 36 | + * ```javascript |
| 37 | + * // Get the Fpnv service for the default app |
| 38 | + * const defaultFpnv = getFirebasePnv(); |
| 39 | + * ``` |
| 40 | + * |
| 41 | + * @example |
| 42 | + * ```javascript |
| 43 | + * // Get the Fpnv service for a given app |
| 44 | + * const otherFpnv = getFirebasePnv(otherApp); |
| 45 | + * ``` |
| 46 | + * |
| 47 | + */ |
| 48 | +export function getFirebasePnv(app?: App): Fpnv { |
| 49 | + if (typeof app === 'undefined') { |
| 50 | + app = getApp(); |
| 51 | + } |
| 52 | + |
| 53 | + const firebaseApp: FirebaseApp = app as FirebaseApp; |
| 54 | + return firebaseApp.getOrInitService('fpnv', (app) => new Fpnv(app)); |
| 55 | +} |
| 56 | + |
| 57 | +export { |
| 58 | + Fpnv, |
| 59 | +} from './fpnv'; |
| 60 | + |
| 61 | +export { |
| 62 | + BaseFpnv, |
| 63 | +} from './base-fpnv'; |
| 64 | + |
| 65 | + |
| 66 | +export { |
| 67 | + FpnvToken, |
| 68 | +} from './token-verifier'; |
| 69 | + |
| 70 | + |
| 71 | +export { |
| 72 | + FirebasePnvError, |
| 73 | + FpnvErrorCode, |
| 74 | +} from '../utils/error'; |
0 commit comments