Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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
3 changes: 3 additions & 0 deletions src/firebase-namespace-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { appCheck } from './app-check/app-check-namespace';
import { auth } from './auth/auth-namespace';
import { fpnv } from './fpnv/fpnv-namespace';
import { database } from './database/database-namespace';
import { firestore } from './firestore/firestore-namespace';
import { instanceId } from './instance-id/instance-id-namespace';
Expand Down Expand Up @@ -43,6 +44,7 @@ export namespace app {
export interface App extends AppCore {
appCheck(): appCheck.AppCheck;
auth(): auth.Auth;
fpnv(): fpnv.Fpnv;
database(url?: string): database.Database;
firestore(): firestore.Firestore;
installations(): installations.Installations;
Expand Down Expand Up @@ -81,6 +83,7 @@ export namespace app {
export * from './credential/index';
export { appCheck } from './app-check/app-check-namespace';
export { auth } from './auth/auth-namespace';
export { fpnv } from './fpnv/fpnv-namespace';
export { database } from './database/database-namespace';
export { firestore } from './firestore/firestore-namespace';
export { instanceId } from './instance-id/instance-id-namespace';
Expand Down
23 changes: 23 additions & 0 deletions src/fpnv/base-fpnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { App } from '../app';

import {
FirebasePhoneNumberTokenVerifier,
FpnvToken,
createFPNTVerifier,
} from './token-verifier';


export abstract class BaseFpnv {
protected readonly fPNTVerifier: FirebasePhoneNumberTokenVerifier;

protected constructor(
app: App,
) {
this.fPNTVerifier = createFPNTVerifier(app);
}


public async verifyToken(idToken: string): Promise<FpnvToken> {
return await this.fPNTVerifier.verifyJWT(idToken);
}
}
39 changes: 39 additions & 0 deletions src/fpnv/fpnv-namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* Copyright 2021 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 all public types with aliases, and re-export from the auth namespace.

import { Fpnv as TFpnv } from './fpnv';

import {
BaseFpnv as TBaseFpnv,
} from './base-fpnv';

import {
FpnvToken as TFpnvToken,
} from './token-verifier';


export declare function fpnv(app?: App): fpnv.Fpnv;

/* eslint-disable @typescript-eslint/no-namespace */
export namespace fpnv {
export type BaseFpnv = TBaseFpnv;
export type Fpnv = TFpnv;
export type FpnvToken = TFpnvToken;
}
41 changes: 41 additions & 0 deletions src/fpnv/fpnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*!
* @license
* Copyright 2017 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 { BaseFpnv } from './base-fpnv';

/**
* Fpnv service bound to the provided app.
*/
export class Fpnv extends BaseFpnv {
private readonly app_: App;

constructor(app: App) {
super(app);

this.app_ = app;
}

/**
* Returns the app associated with this Fpnv instance.
*
* @returns The app associated with this Fpnv instance.
*/
get app(): App {
return this.app_;
}
}
74 changes: 74 additions & 0 deletions src/fpnv/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*!
* Copyright 2020 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.
*/

/**
* Firebase Phone Number Verification.
*
* @packageDocumentation
*/

import { App, getApp } from '../app';
import { FirebaseApp } from '../app/firebase-app';
import { Fpnv } from './fpnv';

/**
* 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));
}

export {
Fpnv,
} from './fpnv';

export {
BaseFpnv,
} from './base-fpnv';


export {
FpnvToken,
} from './token-verifier';


export {
FirebasePnvError,
FpnvErrorCode,
} from '../utils/error';
Loading
Loading