UNPKG

3.26 kBTypeScriptView Raw
1/*! firebase-admin v10.0.0 */
2/*!
3 * @license
4 * Copyright 2021 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18/**
19 * Interface representing an App Check token.
20 */
21export interface AppCheckToken {
22 /**
23 * The Firebase App Check token.
24 */
25 token: string;
26 /**
27 * The time-to-live duration of the token in milliseconds.
28 */
29 ttlMillis: number;
30}
31/**
32 * Interface representing App Check token options.
33 */
34export interface AppCheckTokenOptions {
35 /**
36 * The length of time, in milliseconds, for which the App Check token will
37 * be valid. This value must be between 30 minutes and 7 days, inclusive.
38 */
39 ttlMillis?: number;
40}
41/**
42 * Interface representing a decoded Firebase App Check token, returned from the
43 * {@link AppCheck.verifyToken} method.
44 */
45export interface DecodedAppCheckToken {
46 /**
47 * The issuer identifier for the issuer of the response.
48 * This value is a URL with the format
49 * `https://firebaseappcheck.googleapis.com/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
50 * same project number specified in the {@link DecodedAppCheckToken.aud | aud} property.
51 */
52 iss: string;
53 /**
54 * The Firebase App ID corresponding to the app the token belonged to.
55 * As a convenience, this value is copied over to the {@link DecodedAppCheckToken.app_id | app_id} property.
56 */
57 sub: string;
58 /**
59 * The audience for which this token is intended.
60 * This value is a JSON array of two strings, the first is the project number of your
61 * Firebase project, and the second is the project ID of the same project.
62 */
63 aud: string[];
64 /**
65 * The App Check token's expiration time, in seconds since the Unix epoch. That is, the
66 * time at which this App Check token expires and should no longer be considered valid.
67 */
68 exp: number;
69 /**
70 * The App Check token's issued-at time, in seconds since the Unix epoch. That is, the
71 * time at which this App Check token was issued and should start to be considered
72 * valid.
73 */
74 iat: number;
75 /**
76 * The App ID corresponding to the App the App Check token belonged to.
77 * This value is not actually one of the JWT token claims. It is added as a
78 * convenience, and is set as the value of the {@link DecodedAppCheckToken.sub | sub} property.
79 */
80 app_id: string;
81 [key: string]: any;
82}
83/**
84 * Interface representing a verified App Check token response.
85 */
86export interface VerifyAppCheckTokenResponse {
87 /**
88 * The App ID corresponding to the App the App Check token belonged to.
89 */
90 appId: string;
91 /**
92 * The decoded Firebase App Check token.
93 */
94 token: DecodedAppCheckToken;
95}