Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"typings": "./lib/auth/index.d.ts",
"dist": "./lib/auth/index.js"
},
"firebase-admin/fpnv": {
"typings": "./lib/fpnv/index.d.ts",
"dist": "./lib/fpnv/index.js"
},
"firebase-admin/database": {
"typings": "./lib/database/index.d.ts",
"dist": "./lib/database/index.js"
Expand Down
64 changes: 64 additions & 0 deletions etc/firebase-admin.fpnv.api.md
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;
Copy link
Member

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:

* The audience for which this token is intended.

}

// @public
export function getFirebasePnv(app?: App): Fpnv;

```
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
"auth": [
"lib/auth"
],
"fpnv": [
"lib/fpnv"
],
"eventarc": [
"lib/eventarc"
],
Expand Down Expand Up @@ -134,6 +137,11 @@
"require": "./lib/auth/index.js",
"import": "./lib/esm/auth/index.js"
},
"./fpnv": {
"types": "./lib/fpnv/index.d.ts",
"require": "./lib/fpnv/index.js",
"import": "./lib/esm/fpnv/index.js"
},
"./database": {
"types": "./lib/database/index.d.ts",
"require": "./lib/database/index.js",
Expand Down
39 changes: 39 additions & 0 deletions src/fpnv/fpnv-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* @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';

51 changes: 51 additions & 0 deletions src/fpnv/fpnv.ts
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;
Copy link
Member

Choose a reason for hiding this comment

The 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;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @param app - The app for this `Fpnv` service.
* @constructor
* @internal
*/

constructor(app: App) {

this.app_ = app;
this.fpnvVerifier = createFPNTVerifier(app);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified to a new FirebasePhoneNumberTokenVerifier(app)?

}

/**
* Returns the app associated with this Auth instance.
*
* @returns The app associated with this Auth instance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean Fpnv instance here?

*/
get app(): App {
Copy link
Member

Choose a reason for hiding this comment

The 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_;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing documentation here

public async verifyToken(idToken: string): Promise<FpnvToken> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really an idToken?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public async verifyToken(idToken: string): Promise<FpnvToken> {
public async verifyToken(fpnvJwt: string): Promise<FpnvToken> {

return await this.fpnvVerifier.verifyJWT(idToken);
}
}
66 changes: 66 additions & 0 deletions src/fpnv/index.ts
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);
* ```
*
*/
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));
}
Loading