15
15
* limitations under the License.
16
16
*/
17
17
18
- import { appCheck } from './index' ;
18
+ import { App } from '../app' ;
19
+ import { FirebaseApp } from '../app/firebase-app' ;
19
20
import {
20
21
HttpRequestConfig , HttpClient , HttpError , AuthorizedHttpClient , HttpResponse
21
22
} from '../utils/api-request' ;
22
- import { FirebaseApp } from '../app/firebase-app' ;
23
23
import { PrefixedFirebaseError } from '../utils/error' ;
24
-
25
24
import * as utils from '../utils/index' ;
26
25
import * as validator from '../utils/validator' ;
27
-
28
- import AppCheckToken = appCheck . AppCheckToken ;
26
+ import { AppCheckToken } from './app-check-api'
29
27
30
28
// App Check backend constants
31
29
const FIREBASE_APP_CHECK_V1_API_URL_FORMAT = 'https://firebaseappcheck.googleapis.com/v1beta/projects/{projectId}/apps/{appId}:exchangeCustomToken' ;
@@ -43,21 +41,21 @@ export class AppCheckApiClient {
43
41
private readonly httpClient : HttpClient ;
44
42
private projectId ?: string ;
45
43
46
- constructor ( private readonly app : FirebaseApp ) {
44
+ constructor ( private readonly app : App ) {
47
45
if ( ! validator . isNonNullObject ( app ) || ! ( 'options' in app ) ) {
48
46
throw new FirebaseAppCheckError (
49
47
'invalid-argument' ,
50
48
'First argument passed to admin.appCheck() must be a valid Firebase app instance.' ) ;
51
49
}
52
- this . httpClient = new AuthorizedHttpClient ( app ) ;
50
+ this . httpClient = new AuthorizedHttpClient ( app as FirebaseApp ) ;
53
51
}
54
52
55
53
/**
56
54
* Exchange a signed custom token to App Check token
57
55
*
58
56
* @param customToken The custom token to be exchanged.
59
57
* @param appId The mobile App ID.
60
- * @return A promise that fulfills with a `AppCheckToken`.
58
+ * @returns A promise that fulfills with a `AppCheckToken`.
61
59
*/
62
60
public exchangeToken ( customToken : string , appId : string ) : Promise < AppCheckToken > {
63
61
if ( ! validator . isNonEmptyString ( appId ) ) {
@@ -143,7 +141,7 @@ export class AppCheckApiClient {
143
141
* Creates an AppCheckToken from the API response.
144
142
*
145
143
* @param resp API response object.
146
- * @return An AppCheckToken instance.
144
+ * @returns An AppCheckToken instance.
147
145
*/
148
146
private toAppCheckToken ( resp : HttpResponse ) : AppCheckToken {
149
147
const token = resp . data . attestationToken ;
@@ -164,7 +162,7 @@ export class AppCheckApiClient {
164
162
* is expressed as "3s", while 3 seconds and 1 nanosecond is expressed as "3.000000001s",
165
163
* and 3 seconds and 1 microsecond is expressed as "3.000001s".
166
164
*
167
- * @return The duration in milliseconds.
165
+ * @returns The duration in milliseconds.
168
166
*/
169
167
private stringToMilliseconds ( duration : string ) : number {
170
168
if ( ! validator . isNonEmptyString ( duration ) || ! duration . endsWith ( 's' ) ) {
@@ -211,8 +209,8 @@ export type AppCheckErrorCode =
211
209
/**
212
210
* Firebase App Check error code structure. This extends PrefixedFirebaseError.
213
211
*
214
- * @param { AppCheckErrorCode } code The error code.
215
- * @param { string } message The error message.
212
+ * @param code The error code.
213
+ * @param message The error message.
216
214
* @constructor
217
215
*/
218
216
export class FirebaseAppCheckError extends PrefixedFirebaseError {
0 commit comments