-
Notifications
You must be signed in to change notification settings - Fork 409
feat: add basic fpnv #3030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fpnv
Are you sure you want to change the base?
feat: add basic fpnv #3030
Changes from all commits
f603e65
23868e8
7f71eed
8413368
e90c2bd
2a759df
fabcf80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| ## API Report File for "firebase-admin.fpnv" | ||
|
|
||
| > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
|
||
| ```ts | ||
|
|
||
| import { Agent } from 'http'; | ||
|
|
||
| // Warning: (ae-forgotten-export) The symbol "PrefixedFirebaseError" needs to be exported by the entry point index.d.ts | ||
| // | ||
| // @public | ||
| export class FirebasePnvError extends PrefixedFirebaseError { | ||
| } | ||
|
|
||
| // @public | ||
| export class Fpnv { | ||
| // Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts | ||
| constructor(app: App); | ||
| get app(): App; | ||
| // Warning: (ae-forgotten-export) The symbol "FirebasePhoneNumberTokenVerifier" needs to be exported by the entry point index.d.ts | ||
| // | ||
| // (undocumented) | ||
| protected readonly fpnvVerifier: FirebasePhoneNumberTokenVerifier; | ||
| // (undocumented) | ||
| verifyToken(idToken: string): Promise<FpnvToken>; | ||
| } | ||
|
|
||
| // @public (undocumented) | ||
| export class FpnvErrorCode { | ||
| // (undocumented) | ||
| static readonly EXPIRED_TOKEN: ErrorInfo; | ||
| // Warning: (ae-forgotten-export) The symbol "ErrorInfo" needs to be exported by the entry point index.d.ts | ||
| // | ||
| // (undocumented) | ||
| static readonly INVALID_ARGUMENT: ErrorInfo; | ||
| // (undocumented) | ||
| static readonly INVALID_TOKEN: ErrorInfo; | ||
| // (undocumented) | ||
| static readonly PROJECT_NOT_FOUND: ErrorInfo; | ||
| } | ||
|
|
||
| // @public | ||
| export interface FpnvToken { | ||
| [key: string]: any; | ||
| // (undocumented) | ||
| aud: string; | ||
| // (undocumented) | ||
| auth_time: number; | ||
| // (undocumented) | ||
| exp: number; | ||
| // (undocumented) | ||
| getPhoneNumber(): string; | ||
| // (undocumented) | ||
| iat: number; | ||
| // (undocumented) | ||
| iss: string; | ||
| // (undocumented) | ||
| sub: string; | ||
| } | ||
|
|
||
| // @public | ||
| export function getFirebasePnv(app?: App): Fpnv; | ||
|
|
||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /*! | ||
boikoa-gl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
|
|
||
| /** | ||
| * Interface representing a Fpnv token. | ||
| */ | ||
| export interface FpnvToken { | ||
| aud: string; | ||
| auth_time: number; | ||
| exp: number; | ||
| iat: number; | ||
| iss: string; | ||
| sub: string; | ||
|
|
||
| getPhoneNumber(): string; | ||
|
|
||
| /** | ||
| * Other arbitrary claims included in the ID token. | ||
| */ | ||
| [key: string]: any; | ||
| } | ||
|
|
||
| export { FpnvErrorCode, FirebasePnvError } from '../utils/error'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||||||||
| /*! | ||||||||||||||
| * @license | ||||||||||||||
| * Copyright 2025 Google LLC | ||||||||||||||
| * | ||||||||||||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||
| * you may not use this file except in compliance with the License. | ||||||||||||||
| * You may obtain a copy of the License at | ||||||||||||||
| * | ||||||||||||||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||
| * | ||||||||||||||
| * Unless required by applicable law or agreed to in writing, software | ||||||||||||||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||
| * See the License for the specific language governing permissions and | ||||||||||||||
| * limitations under the License. | ||||||||||||||
| */ | ||||||||||||||
|
|
||||||||||||||
| import { App } from '../app'; | ||||||||||||||
| import { FpnvToken } from './fpnv-api'; | ||||||||||||||
| import { | ||||||||||||||
| FirebasePhoneNumberTokenVerifier, | ||||||||||||||
| createFPNTVerifier, | ||||||||||||||
| } from './token-verifier'; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Fpnv service bound to the provided app. | ||||||||||||||
| */ | ||||||||||||||
| export class Fpnv { | ||||||||||||||
| private readonly app_: App; | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: you can simplify this by using constructor parameter properties. constructor(readonly app: App) { ...
// this.app |
||||||||||||||
|
|
||||||||||||||
| protected readonly fpnvVerifier: FirebasePhoneNumberTokenVerifier; | ||||||||||||||
|
|
||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| constructor(app: App) { | ||||||||||||||
|
|
||||||||||||||
| this.app_ = app; | ||||||||||||||
| this.fpnvVerifier = createFPNTVerifier(app); | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be simplified to a |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Returns the app associated with this Auth instance. | ||||||||||||||
| * | ||||||||||||||
| * @returns The app associated with this Auth instance. | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean Fpnv instance here? |
||||||||||||||
| */ | ||||||||||||||
| get app(): App { | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used for anything? If not, we can probably remove this getter |
||||||||||||||
| return this.app_; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing documentation here |
||||||||||||||
| public async verifyToken(idToken: string): Promise<FpnvToken> { | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really an
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| return await this.fpnvVerifier.verifyJWT(idToken); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /** | ||
| * Firebase Phone Number Verification. | ||
| * | ||
| * @packageDocumentation | ||
| */ | ||
|
|
||
| /*! | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { App, getApp } from '../app'; | ||
| import { FirebaseApp } from '../app/firebase-app'; | ||
| import { Fpnv } from './fpnv'; | ||
|
|
||
| export { | ||
| Fpnv | ||
| } from './fpnv'; | ||
|
|
||
| export { | ||
| FpnvToken, | ||
| FirebasePnvError, | ||
| FpnvErrorCode, | ||
| } from './fpnv-api' | ||
|
|
||
| /** | ||
| * Gets the {@link Fpnv} service for the default app or a | ||
| * given app. | ||
| * | ||
| * `getFirebasePnv()` can be called with no arguments to access the default app's | ||
| * {@link Fpnv} service or as `getFirebasePnv(app)` to access the | ||
| * {@link Fpnv} service associated with a specific app. | ||
| * | ||
| * @example | ||
| * ```javascript | ||
| * // Get the Fpnv service for the default app | ||
| * const defaultFpnv = getFirebasePnv(); | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```javascript | ||
| * // Get the Fpnv service for a given app | ||
| * const otherFpnv = getFirebasePnv(otherApp); | ||
| * ``` | ||
boikoa-gl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| */ | ||
| export function getFirebasePnv(app?: App): Fpnv { | ||
| if (typeof app === 'undefined') { | ||
| app = getApp(); | ||
| } | ||
|
|
||
| const firebaseApp: FirebaseApp = app as FirebaseApp; | ||
| return firebaseApp.getOrInitService('fpnv', (app) => new Fpnv(app)); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add documentation to these types. For example see:
firebase-admin-node/src/app-check/app-check-api.ts
Line 87 in 179dab7