token-verifier.d.ts 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * Copyright 2018 Google Inc.
  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. /**
  18. * Interface representing a decoded Firebase ID token, returned from the
  19. * {@link BaseAuth.verifyIdToken} method.
  20. *
  21. * Firebase ID tokens are OpenID Connect spec-compliant JSON Web Tokens (JWTs).
  22. * See the
  23. * [ID Token section of the OpenID Connect spec](http://openid.net/specs/openid-connect-core-1_0.html#IDToken)
  24. * for more information about the specific properties below.
  25. */
  26. export interface DecodedIdToken {
  27. /**
  28. * The audience for which this token is intended.
  29. *
  30. * This value is a string equal to your Firebase project ID, the unique
  31. * identifier for your Firebase project, which can be found in [your project's
  32. * settings](https://console.firebase.google.com/project/_/settings/general/android:com.random.android).
  33. */
  34. aud: string;
  35. /**
  36. * Time, in seconds since the Unix epoch, when the end-user authentication
  37. * occurred.
  38. *
  39. * This value is not set when this particular ID token was created, but when the
  40. * user initially logged in to this session. In a single session, the Firebase
  41. * SDKs will refresh a user's ID tokens every hour. Each ID token will have a
  42. * different [`iat`](#iat) value, but the same `auth_time` value.
  43. */
  44. auth_time: number;
  45. /**
  46. * The email of the user to whom the ID token belongs, if available.
  47. */
  48. email?: string;
  49. /**
  50. * Whether or not the email of the user to whom the ID token belongs is
  51. * verified, provided the user has an email.
  52. */
  53. email_verified?: boolean;
  54. /**
  55. * The ID token's expiration time, in seconds since the Unix epoch. That is, the
  56. * time at which this ID token expires and should no longer be considered valid.
  57. *
  58. * The Firebase SDKs transparently refresh ID tokens every hour, issuing a new
  59. * ID token with up to a one hour expiration.
  60. */
  61. exp: number;
  62. /**
  63. * Information about the sign in event, including which sign in provider was
  64. * used and provider-specific identity details.
  65. *
  66. * This data is provided by the Firebase Authentication service and is a
  67. * reserved claim in the ID token.
  68. */
  69. firebase: {
  70. /**
  71. * Provider-specific identity details corresponding
  72. * to the provider used to sign in the user.
  73. */
  74. identities: {
  75. [key: string]: any;
  76. };
  77. /**
  78. * The ID of the provider used to sign in the user.
  79. * One of `"anonymous"`, `"password"`, `"facebook.com"`, `"github.com"`,
  80. * `"google.com"`, `"twitter.com"`, `"apple.com"`, `"microsoft.com"`,
  81. * `"yahoo.com"`, `"phone"`, `"playgames.google.com"`, `"gc.apple.com"`,
  82. * or `"custom"`.
  83. *
  84. * Additional Identity Platform provider IDs include `"linkedin.com"`,
  85. * OIDC and SAML identity providers prefixed with `"saml."` and `"oidc."`
  86. * respectively.
  87. */
  88. sign_in_provider: string;
  89. /**
  90. * The type identifier or `factorId` of the second factor, provided the
  91. * ID token was obtained from a multi-factor authenticated user.
  92. * For phone, this is `"phone"`.
  93. */
  94. sign_in_second_factor?: string;
  95. /**
  96. * The `uid` of the second factor used to sign in, provided the
  97. * ID token was obtained from a multi-factor authenticated user.
  98. */
  99. second_factor_identifier?: string;
  100. /**
  101. * The ID of the tenant the user belongs to, if available.
  102. */
  103. tenant?: string;
  104. [key: string]: any;
  105. };
  106. /**
  107. * The ID token's issued-at time, in seconds since the Unix epoch. That is, the
  108. * time at which this ID token was issued and should start to be considered
  109. * valid.
  110. *
  111. * The Firebase SDKs transparently refresh ID tokens every hour, issuing a new
  112. * ID token with a new issued-at time. If you want to get the time at which the
  113. * user session corresponding to the ID token initially occurred, see the
  114. * [`auth_time`](#auth_time) property.
  115. */
  116. iat: number;
  117. /**
  118. * The issuer identifier for the issuer of the response.
  119. *
  120. * This value is a URL with the format
  121. * `https://securetoken.google.com/<PROJECT_ID>`, where `<PROJECT_ID>` is the
  122. * same project ID specified in the [`aud`](#aud) property.
  123. */
  124. iss: string;
  125. /**
  126. * The phone number of the user to whom the ID token belongs, if available.
  127. */
  128. phone_number?: string;
  129. /**
  130. * The photo URL for the user to whom the ID token belongs, if available.
  131. */
  132. picture?: string;
  133. /**
  134. * The `uid` corresponding to the user who the ID token belonged to.
  135. *
  136. * As a convenience, this value is copied over to the [`uid`](#uid) property.
  137. */
  138. sub: string;
  139. /**
  140. * The `uid` corresponding to the user who the ID token belonged to.
  141. *
  142. * This value is not actually in the JWT token claims itself. It is added as a
  143. * convenience, and is set as the value of the [`sub`](#sub) property.
  144. */
  145. uid: string;
  146. /**
  147. * Other arbitrary claims included in the ID token.
  148. */
  149. [key: string]: any;
  150. }
  151. /** @alpha */
  152. export interface DecodedAuthBlockingSharedUserInfo {
  153. uid: string;
  154. display_name?: string;
  155. email?: string;
  156. photo_url?: string;
  157. phone_number?: string;
  158. }
  159. /** @alpha */
  160. export interface DecodedAuthBlockingMetadata {
  161. creation_time?: number;
  162. last_sign_in_time?: number;
  163. }
  164. /** @alpha */
  165. export interface DecodedAuthBlockingUserInfo extends DecodedAuthBlockingSharedUserInfo {
  166. provider_id: string;
  167. }
  168. /** @alpha */
  169. export interface DecodedAuthBlockingMfaInfo {
  170. uid: string;
  171. display_name?: string;
  172. phone_number?: string;
  173. enrollment_time?: string;
  174. factor_id?: string;
  175. }
  176. /** @alpha */
  177. export interface DecodedAuthBlockingEnrolledFactors {
  178. enrolled_factors?: DecodedAuthBlockingMfaInfo[];
  179. }
  180. /** @alpha */
  181. export interface DecodedAuthBlockingUserRecord extends DecodedAuthBlockingSharedUserInfo {
  182. email_verified?: boolean;
  183. disabled?: boolean;
  184. metadata?: DecodedAuthBlockingMetadata;
  185. password_hash?: string;
  186. password_salt?: string;
  187. provider_data?: DecodedAuthBlockingUserInfo[];
  188. multi_factor?: DecodedAuthBlockingEnrolledFactors;
  189. custom_claims?: any;
  190. tokens_valid_after_time?: number;
  191. tenant_id?: string;
  192. [key: string]: any;
  193. }
  194. /** @alpha */
  195. export interface DecodedAuthBlockingToken {
  196. aud: string;
  197. exp: number;
  198. iat: number;
  199. iss: string;
  200. sub: string;
  201. event_id: string;
  202. event_type: string;
  203. ip_address: string;
  204. user_agent?: string;
  205. locale?: string;
  206. sign_in_method?: string;
  207. user_record?: DecodedAuthBlockingUserRecord;
  208. tenant_id?: string;
  209. raw_user_info?: string;
  210. sign_in_attributes?: {
  211. [key: string]: any;
  212. };
  213. oauth_id_token?: string;
  214. oauth_access_token?: string;
  215. oauth_refresh_token?: string;
  216. oauth_token_secret?: string;
  217. oauth_expires_in?: number;
  218. [key: string]: any;
  219. }