UNPKG

2.14 kBJavaScriptView Raw
1/*! firebase-admin v10.0.0 */
2"use strict";
3/*!
4 * @license
5 * Copyright 2021 Google Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19Object.defineProperty(exports, "__esModule", { value: true });
20exports.getAppCheck = void 0;
21/**
22 * Firebase App Check.
23 *
24 * @packageDocumentation
25 */
26var app_1 = require("../app");
27var app_check_1 = require("./app-check");
28var app_check_2 = require("./app-check");
29Object.defineProperty(exports, "AppCheck", { enumerable: true, get: function () { return app_check_2.AppCheck; } });
30/**
31 * Gets the {@link AppCheck} service for the default app or a given app.
32 *
33 * `getAppCheck()` can be called with no arguments to access the default
34 * app's `AppCheck` service or as `getAppCheck(app)` to access the
35 * `AppCheck` service associated with a specific app.
36 *
37 * @example
38 * ```javascript
39 * // Get the `AppCheck` service for the default app
40 * const defaultAppCheck = getAppCheck();
41 * ```
42 *
43 * @example
44 * ```javascript
45 * // Get the `AppCheck` service for a given app
46 * const otherAppCheck = getAppCheck(otherApp);
47 * ```
48 *
49 * @param app - Optional app for which to return the `AppCheck` service.
50 * If not provided, the default `AppCheck` service is returned.
51 *
52 * @returns The default `AppCheck` service if no
53 * app is provided, or the `AppCheck` service associated with the provided
54 * app.
55 */
56function getAppCheck(app) {
57 if (typeof app === 'undefined') {
58 app = app_1.getApp();
59 }
60 var firebaseApp = app;
61 return firebaseApp.getOrInitService('appCheck', function (app) { return new app_check_1.AppCheck(app); });
62}
63exports.getAppCheck = getAppCheck;