Skip to content

Commit 71f48cb

Browse files
committed
chore: linting
1 parent 38e5a17 commit 71f48cb

File tree

5 files changed

+26
-55
lines changed

5 files changed

+26
-55
lines changed

etc/firebase-admin.fpnv.api.md

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,28 @@
66

77
import { Agent } from 'http';
88

9-
// Warning: (ae-forgotten-export) The symbol "PrefixedFirebaseError" needs to be exported by the entry point index.d.ts
10-
//
11-
// @public
12-
export class FirebasePnvError extends PrefixedFirebaseError {
13-
}
14-
159
// @public
1610
export class Fpnv {
1711
// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
18-
constructor(app: App);
1912
get app(): App;
2013
// Warning: (ae-forgotten-export) The symbol "FirebasePhoneNumberTokenVerifier" needs to be exported by the entry point index.d.ts
2114
//
2215
// (undocumented)
2316
protected readonly fpnvVerifier: FirebasePhoneNumberTokenVerifier;
2417
// (undocumented)
25-
verifyToken(idToken: string): Promise<FpnvToken>;
26-
}
27-
28-
// @public (undocumented)
29-
export class FpnvErrorCode {
30-
// (undocumented)
31-
static readonly EXPIRED_TOKEN: ErrorInfo;
32-
// Warning: (ae-forgotten-export) The symbol "ErrorInfo" needs to be exported by the entry point index.d.ts
33-
//
34-
// (undocumented)
35-
static readonly INVALID_ARGUMENT: ErrorInfo;
36-
// (undocumented)
37-
static readonly INVALID_TOKEN: ErrorInfo;
38-
// (undocumented)
39-
static readonly PROJECT_NOT_FOUND: ErrorInfo;
18+
verifyToken(fpnvJwt: string): Promise<FpnvToken>;
4019
}
4120

4221
// @public
4322
export interface FpnvToken {
4423
[key: string]: any;
45-
// (undocumented)
46-
aud: string;
47-
// (undocumented)
48-
auth_time: number;
49-
// (undocumented)
24+
aud: string[];
5025
exp: number;
51-
// (undocumented)
5226
getPhoneNumber(): string;
53-
// (undocumented)
5427
iat: number;
55-
// (undocumented)
5628
iss: string;
57-
// (undocumented)
29+
jti: string;
30+
nonce: string;
5831
sub: string;
5932
}
6033

src/fpnv/fpnv-api-client-internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ export type FpnvErrorCode =
5858
* @param message - The error message.
5959
* @constructor
6060
*/
61-
export class FirebasePnvError extends PrefixedFirebaseError {
61+
export class FirebaseFpnvError extends PrefixedFirebaseError {
6262
constructor(code: FpnvErrorCode, message: string) {
6363
super('fpnv', code, message);
6464

6565
/* tslint:disable:max-line-length */
6666
// Set the prototype explicitly. See the following link for more details:
6767
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
6868
/* tslint:enable:max-line-length */
69-
(this as any).__proto__ = FirebasePnvError.prototype;
69+
(this as any).__proto__ = FirebaseFpnvError.prototype;
7070
}
7171
}

src/fpnv/fpnv-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface FpnvToken {
2424
* The issuer identifier for the issuer of the response.
2525
* This value is a URL with the format
2626
* `https://firebaseappcheck.googleapis.com/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
27-
* same project number specified in the {@link aud} property.
27+
* same project number specified in the {@link FpnvToken.aud} property.
2828
*/
2929
iss: string;
3030

@@ -66,7 +66,7 @@ export interface FpnvToken {
6666
/**
6767
* The corresponding user's phone number.
6868
* This value is not actually one of the JWT token claims. It is added as a
69-
* convenience, and is set as the value of the {@link sub} property.
69+
* convenience, and is set as the value of the {@link FpnvToken.sub} property.
7070
*/
7171
getPhoneNumber(): string;
7272

@@ -76,5 +76,5 @@ export interface FpnvToken {
7676
[key: string]: any;
7777
}
7878

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

src/fpnv/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export {
3131

3232
export {
3333
FpnvToken,
34-
FirebasePnvError,
35-
FpnvErrorCode,
3634
} from './fpnv-api'
3735

3836
/**

src/fpnv/token-verifier.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { App } from '../app';
19-
import { FirebasePnvError, FpnvToken } from './fpnv-api';
19+
import { FirebaseFpnvError, FpnvToken } from './fpnv-api';
2020
import * as util from '../utils/index';
2121
import * as validator from '../utils/validator';
2222
import {
@@ -38,37 +38,37 @@ export class FirebasePhoneNumberTokenVerifier {
3838
) {
3939

4040
if (!validator.isURL(clientCertUrl)) {
41-
throw new FirebasePnvError(
41+
throw new FirebaseFpnvError(
4242
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
4343
'The provided public client certificate URL is an invalid URL.',
4444
);
4545
} else if (!validator.isURL(issuer)) {
46-
throw new FirebasePnvError(
46+
throw new FirebaseFpnvError(
4747
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
4848
'The provided JWT issuer is an invalid URL.',
4949
);
5050
} else if (!validator.isNonNullObject(tokenInfo)) {
51-
throw new FirebasePnvError(
51+
throw new FirebaseFpnvError(
5252
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
5353
'The provided JWT information is not an object or null.',
5454
);
5555
} else if (!validator.isURL(tokenInfo.url)) {
56-
throw new FirebasePnvError(
56+
throw new FirebaseFpnvError(
5757
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
5858
'The provided JWT verification documentation URL is invalid.',
5959
);
6060
} else if (!validator.isNonEmptyString(tokenInfo.verifyApiName)) {
61-
throw new FirebasePnvError(
61+
throw new FirebaseFpnvError(
6262
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
6363
'The JWT verify API name must be a non-empty string.',
6464
);
6565
} else if (!validator.isNonEmptyString(tokenInfo.jwtName)) {
66-
throw new FirebasePnvError(
66+
throw new FirebaseFpnvError(
6767
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
6868
'The JWT public full name must be a non-empty string.',
6969
);
7070
} else if (!validator.isNonEmptyString(tokenInfo.shortName)) {
71-
throw new FirebasePnvError(
71+
throw new FirebaseFpnvError(
7272
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
7373
'The JWT public short name must be a non-empty string.',
7474
);
@@ -83,7 +83,7 @@ export class FirebasePhoneNumberTokenVerifier {
8383

8484
public async verifyJWT(jwtToken: string): Promise<FpnvToken> {
8585
if (!validator.isString(jwtToken)) {
86-
throw new FirebasePnvError(
86+
throw new FirebaseFpnvError(
8787
FPNV_ERROR_CODE_MAPPING.INVALID_TOKEN,
8888
`First argument to ${this.tokenInfo.verifyApiName} must be a string.`,
8989
);
@@ -99,7 +99,7 @@ export class FirebasePhoneNumberTokenVerifier {
9999
private async ensureProjectId(): Promise<string> {
100100
const projectId = await util.findProjectId(this.app);
101101
if (!validator.isNonEmptyString(projectId)) {
102-
throw new FirebasePnvError(
102+
throw new FirebaseFpnvError(
103103
FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
104104
'Must initialize app with a cert credential or set your Firebase project ID as the ' +
105105
`GOOGLE_CLOUD_PROJECT environment variable to call ${this.tokenInfo.verifyApiName}.`);
@@ -127,10 +127,10 @@ export class FirebasePhoneNumberTokenVerifier {
127127
const errorMessage = `Decoding ${this.tokenInfo.jwtName} failed. Make sure you passed ` +
128128
`the entire string JWT which represents ${this.shortNameArticle} ` +
129129
`${this.tokenInfo.shortName}.` + verifyJwtTokenDocsMessage;
130-
throw new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
130+
throw new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT,
131131
errorMessage);
132132
}
133-
throw new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, err.message);
133+
throw new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, err.message);
134134
}
135135
}
136136

@@ -171,7 +171,7 @@ export class FirebasePhoneNumberTokenVerifier {
171171
}
172172

173173
if (errorMessage) {
174-
throw new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
174+
throw new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
175175
}
176176
}
177177

@@ -189,17 +189,17 @@ export class FirebasePhoneNumberTokenVerifier {
189189
if (error.code === JwtErrorCode.TOKEN_EXPIRED) {
190190
const errorMessage = `${this.tokenInfo.jwtName} has expired. Get a fresh ${this.tokenInfo.shortName}` +
191191
` from your client app and try again. ${verifyJwtTokenDocsMessage}`;
192-
return new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.EXPIRED_TOKEN, errorMessage);
192+
return new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.EXPIRED_TOKEN, errorMessage);
193193
} else if (error.code === JwtErrorCode.INVALID_SIGNATURE) {
194194
const errorMessage = `${this.tokenInfo.jwtName} has invalid signature. ${verifyJwtTokenDocsMessage}`;
195-
return new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
195+
return new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
196196
} else if (error.code === JwtErrorCode.NO_MATCHING_KID) {
197197
const errorMessage = `${this.tokenInfo.jwtName} has "kid" claim which does not ` +
198198
`correspond to a known public key. Most likely the ${this.tokenInfo.shortName} ` +
199199
'is expired, so get a fresh token from your client app and try again.';
200-
return new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
200+
return new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
201201
}
202-
return new FirebasePnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, error.message);
202+
return new FirebaseFpnvError(FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, error.message);
203203
}
204204

205205
}

0 commit comments

Comments
 (0)