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
13 changes: 13 additions & 0 deletions etc/firebase-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export namespace app {
// (undocumented)
firestore(): firestore.Firestore;
// (undocumented)
fpnv(): fpnv.Fpnv;
// (undocumented)
installations(): installations.Installations;
// @deprecated (undocumented)
instanceId(): instanceId.InstanceId;
Expand Down Expand Up @@ -291,6 +293,17 @@ export namespace firestore {
import setLogFunction = _firestore.setLogFunction;
}

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

// @public (undocumented)
export namespace fpnv {
// Warning: (ae-forgotten-export) The symbol "Fpnv" needs to be exported by the entry point default-namespace.d.ts
export type Fpnv = Fpnv;
// Warning: (ae-forgotten-export) The symbol "FpnvToken" needs to be exported by the entry point default-namespace.d.ts
export type FpnvToken = FpnvToken;
}

// @public
export interface GoogleOAuthAccessToken {
// (undocumented)
Expand Down
32 changes: 32 additions & 0 deletions etc/firebase-admin.fpnv.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## 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';

// @public
export class Fpnv {
// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
get app(): App;
verifyToken(fpnvJwt: string): Promise<FpnvToken>;
}

// @public
export interface FpnvToken {
[key: string]: any;
aud: string[];
exp: number;
getPhoneNumber(): string;
iat: number;
iss: string;
jti: string;
nonce: string;
sub: string;
}

// @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
20 changes: 19 additions & 1 deletion src/app/firebase-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { App as AppCore } from './core';
import { AppStore, defaultAppStore } from './lifecycle';
import {
app, appCheck, auth, messaging, machineLearning, storage, firestore, database,
instanceId, installations, projectManagement, securityRules , remoteConfig, AppOptions,
instanceId, installations, projectManagement, securityRules , remoteConfig, fpnv, AppOptions,
} from '../firebase-namespace-api';
import { cert, refreshToken, applicationDefault } from './credential-factory';
import { getSdkVersion } from '../utils/index';
Expand All @@ -37,6 +37,7 @@ import ProjectManagement = projectManagement.ProjectManagement;
import RemoteConfig = remoteConfig.RemoteConfig;
import SecurityRules = securityRules.SecurityRules;
import Storage = storage.Storage;
import Fpnv = fpnv.Fpnv;

export interface FirebaseServiceNamespace <T> {
(app?: App): T;
Expand Down Expand Up @@ -279,6 +280,18 @@ export class FirebaseNamespace {
return Object.assign(fn, { AppCheck: appCheck });
}

/**
* Gets the `Fpnv` service namespace. The returned namespace can be used to get the
* `Fpnv` service for the default app or an explicitly specified app.
*/
get fpnv(): FirebaseServiceNamespace<Fpnv> {
const fn: FirebaseServiceNamespace<Fpnv> = (app?: App) => {
return this.ensureApp(app).fpnv();
};
const fpnv = require('../fpnv/fpnv').Fpnv;
return Object.assign(fn, { Fpnv: fpnv });
}

// TODO: Change the return types to app.App in the following methods.

/**
Expand Down Expand Up @@ -397,6 +410,11 @@ function extendApp(app: AppCore): App {
return fn(app);
};

result.fpnv = () => {
const fn = require('../fpnv/index').getFirebasePnv;
return fn(app);
};

(result as any).__extended = true;
return result;
}
3 changes: 3 additions & 0 deletions src/firebase-namespace-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { projectManagement } from './project-management/project-management-names
import { remoteConfig } from './remote-config/remote-config-namespace';
import { securityRules } from './security-rules/security-rules-namespace';
import { storage } from './storage/storage-namespace';
import { fpnv } from './fpnv/fpnv-namespace';

import { App as AppCore, AppOptions } from './app/index';

Expand Down Expand Up @@ -56,6 +57,7 @@ export namespace app {
remoteConfig(): remoteConfig.RemoteConfig;
securityRules(): securityRules.SecurityRules;
storage(): storage.Storage;
fpnv(): fpnv.Fpnv;

/**
* Renders this local `FirebaseApp` unusable and frees the resources of
Expand Down Expand Up @@ -91,6 +93,7 @@ export { projectManagement } from './project-management/project-management-names
export { remoteConfig } from './remote-config/remote-config-namespace';
export { securityRules } from './security-rules/security-rules-namespace';
export { storage } from './storage/storage-namespace';
export { fpnv } from './fpnv/fpnv-namespace';

// Declare other top-level members of the admin namespace below. Unfortunately, there's no
// compile-time mechanism to ensure that the FirebaseNamespace class actually provides these
Expand Down
71 changes: 71 additions & 0 deletions src/fpnv/fpnv-api-client-internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*!
* @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 { PrefixedFirebaseError } from '../utils/error';

export interface FirebasePhoneNumberTokenInfo {
/** Documentation URL. */
url: string;
/** verify API name. */
verifyApiName: string;
/** The JWT full name. */
jwtName: string;
/** The JWT short name. */
shortName: string;
/** The JWT typ (Type) */
typ: string;
}

export const JWKS_URL = 'https://fpnv.googleapis.com/v1beta/jwks';

export const PN_TOKEN_INFO: FirebasePhoneNumberTokenInfo = {
url: 'https://firebase.google.com/docs/phone-number-verification',
verifyApiName: 'verifyToken()',
jwtName: 'Firebase Phone Verification token',
shortName: 'FPNV token',
typ: 'JWT',
};

export const FPNV_ERROR_CODE_MAPPING = {
INVALID_ARGUMENT: 'invalid-argument',
INVALID_TOKEN: 'invalid-token',
EXPIRED_TOKEN: 'expired-token',
} satisfies Record<string, FpnvErrorCode>;

export type FpnvErrorCode =
| 'invalid-argument'
| 'invalid-token'
| 'expired-token'

/**
* Firebase Phone Number Verification error code structure. This extends `PrefixedFirebaseError`.
*
* @param code - The error code.
* @param message - The error message.
* @constructor
*/
export class FirebaseFpnvError extends PrefixedFirebaseError {
constructor(code: FpnvErrorCode, message: string) {
super('fpnv', code, message);

/* tslint:disable:max-line-length */
// Set the prototype explicitly. See the following link for more details:
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
/* tslint:enable:max-line-length */
(this as any).__proto__ = FirebaseFpnvError.prototype;
}
}
81 changes: 81 additions & 0 deletions src/fpnv/fpnv-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*!
* @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 {
/**
* The issuer identifier for the issuer of the response.
* This value is a URL with the format
* `https://fpnv.googleapis.com/projects/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
* same project number specified in the {@link FpnvToken.aud} property.
*/
iss: string;

/**
* The audience for which this token is intended.
* This value is a string array, one of which is a URL with the format
* `https://fpnv.googleapis.com/projects/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
* project number of your Firebase project.
*/
aud: string[];

/**
* The Fpnv token's expiration time, in seconds since the Unix epoch. That is, the
* time at which this Fpnv token expires and should no longer be considered valid.
*/
exp: number;

/**
* The Fpnv token's issued-at time, in seconds since the Unix epoch. That is, the
* time at which this Fpnv token was issued and should start to be considered
* valid.
*/
iat: number;

/**
* The phone number of User.
*/
sub: string;

/**
* A case-sensitive string that uniquely identifies a specific JWT instance
*/
jti: string;

/**
* A unique, single-use "number used once" value.
*/
nonce: string;

/**
* The corresponding user's phone number.
* This value is not actually one of the JWT token claims. It is added as a
* convenience, and is set as the value of the {@link FpnvToken.sub} property.
*/
getPhoneNumber(): string;

/**
* Other arbitrary claims included in the token.
*/
[key: string]: any;
}

export { FpnvErrorCode, FirebaseFpnvError } from './fpnv-api-client-internal';

63 changes: 63 additions & 0 deletions src/fpnv/fpnv-namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*!
* @license
* Copyright 2026 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 as TFpnvToken,
} from './fpnv-api';
import { Fpnv as TFpnv } from './fpnv';

/**
* Gets the {@link firebase-admin.fpnv#Fpnv} service for the default app or a given app.
*
* `admin.fpnv()` can be called with no arguments to access the default
* app's `Fpnv` service or as `admin.fpnv(app)` to access the
* `Fpnv` service associated with a specific app.
*
* @example
* ```javascript
* // Get the `Fpnv` service for the default app
* var defaultFpnv = admin.fpnv();
* ```
*
* @example
* ```javascript
* // Get the `Fpnv` service for a given app
* var otherFpnv = admin.fpnv(otherApp);
* ```
*
* @param app - Optional app for which to return the `Fpnv` service.
* If not provided, the default `Fpnv` service is returned.
*
* @returns The default `Fpnv` service if no
* app is provided, or the `Fpnv` service associated with the provided
* app.
*/
export declare function fpnv(app?: App): fpnv.Fpnv;

// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace fpnv {
/**
* Type alias to {@link firebase-admin.fpnv#fpnv}.
*/
export type Fpnv = TFpnv;

/**
* Type alias to {@link firebase-admin.fpnv#FpnvToken}.
*/
export type FpnvToken = TFpnvToken
}
Loading