firebase-admin 13.6.1 → 13.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +1 -1
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +1 -1
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +1 -1
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +1 -1
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +1 -1
- package/lib/app/lifecycle.js +1 -1
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +1 -1
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +1 -1
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +1 -1
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +1 -1
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +1 -1
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +1 -1
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +1 -1
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +1 -1
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +1 -1
- package/lib/auth/base-auth.js +1 -1
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +1 -1
- package/lib/auth/project-config-manager.d.ts +1 -1
- package/lib/auth/project-config-manager.js +1 -1
- package/lib/auth/project-config.d.ts +1 -1
- package/lib/auth/project-config.js +1 -1
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +1 -1
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +1 -1
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +1 -1
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +1 -1
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +1 -1
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +1 -1
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +1 -1
- package/lib/data-connect/data-connect-api-client-internal.d.ts +1 -1
- package/lib/data-connect/data-connect-api-client-internal.js +1 -1
- package/lib/data-connect/data-connect-api.d.ts +1 -1
- package/lib/data-connect/data-connect-api.js +1 -1
- package/lib/data-connect/data-connect.d.ts +1 -1
- package/lib/data-connect/data-connect.js +1 -1
- package/lib/data-connect/index.d.ts +1 -1
- package/lib/data-connect/index.js +1 -1
- package/lib/data-connect/validate-admin-args.d.ts +1 -1
- package/lib/data-connect/validate-admin-args.js +1 -1
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +1 -1
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +1 -1
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +1 -1
- package/lib/esm/phone-number-verification/index.js +4 -0
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +1 -1
- package/lib/eventarc/eventarc-utils.d.ts +1 -1
- package/lib/eventarc/eventarc-utils.js +1 -1
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +1 -1
- package/lib/eventarc/index.d.ts +1 -1
- package/lib/eventarc/index.js +1 -1
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
- package/lib/extensions/extensions-api-client-internal.js +1 -1
- package/lib/extensions/extensions-api.d.ts +1 -1
- package/lib/extensions/extensions-api.js +1 -1
- package/lib/extensions/extensions.d.ts +1 -1
- package/lib/extensions/extensions.js +1 -1
- package/lib/extensions/index.d.ts +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +1 -1
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +1 -1
- package/lib/firestore/firestore-namespace.d.ts +1 -1
- package/lib/firestore/firestore-namespace.js +1 -1
- package/lib/firestore/index.d.ts +1 -1
- package/lib/firestore/index.js +1 -1
- package/lib/functions/functions-api-client-internal.d.ts +1 -1
- package/lib/functions/functions-api-client-internal.js +1 -1
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +1 -1
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/index.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +1 -1
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +1 -1
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +1 -1
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +1 -1
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +1 -1
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +1 -1
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +1 -1
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +1 -1
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +1 -1
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +1 -1
- package/lib/messaging/messaging-api.d.ts +11 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +1 -1
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +3 -1
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +1 -1
- package/lib/phone-number-verification/index.d.ts +50 -0
- package/lib/phone-number-verification/index.js +60 -0
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.d.ts +48 -0
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.js +52 -0
- package/lib/phone-number-verification/phone-number-verification-api.d.ts +72 -0
- package/lib/phone-number-verification/phone-number-verification-api.js +22 -0
- package/lib/phone-number-verification/phone-number-verification.d.ts +39 -0
- package/lib/phone-number-verification/phone-number-verification.js +54 -0
- package/lib/phone-number-verification/token-verifier.d.ts +35 -0
- package/lib/phone-number-verification/token-verifier.js +170 -0
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +1 -1
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +1 -1
- package/lib/project-management/index.js +1 -1
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +1 -1
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +1 -1
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +1 -1
- package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
- package/lib/remote-config/condition-evaluator-internal.js +1 -1
- package/lib/remote-config/index.d.ts +2 -2
- package/lib/remote-config/index.js +1 -1
- package/lib/remote-config/internal/value-impl.d.ts +1 -1
- package/lib/remote-config/internal/value-impl.js +1 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +1 -1
- package/lib/remote-config/remote-config-api.d.ts +115 -2
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +38 -2
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +4 -2
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +1 -1
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +1 -1
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +1 -1
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +1 -1
- package/lib/utils/api-request.d.ts +1 -1
- package/lib/utils/api-request.js +8 -2
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +1 -1
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/jwt.d.ts +2 -1
- package/lib/utils/jwt.js +4 -3
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +16 -8
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2025 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.PhoneNumberVerification = void 0;
|
|
21
|
+
exports.getPhoneNumberVerification = getPhoneNumberVerification;
|
|
22
|
+
/**
|
|
23
|
+
* Firebase Phone Number Verification.
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
*/
|
|
27
|
+
const app_1 = require("../app");
|
|
28
|
+
const phone_number_verification_1 = require("./phone-number-verification");
|
|
29
|
+
var phone_number_verification_2 = require("./phone-number-verification");
|
|
30
|
+
Object.defineProperty(exports, "PhoneNumberVerification", { enumerable: true, get: function () { return phone_number_verification_2.PhoneNumberVerification; } });
|
|
31
|
+
/**
|
|
32
|
+
* Gets the {@link PhoneNumberVerification} service for the default app or a
|
|
33
|
+
* given app.
|
|
34
|
+
*
|
|
35
|
+
* `getPhoneNumberVerification()` can be called with no arguments to access the default app's
|
|
36
|
+
* {@link PhoneNumberVerification} service or as `getPhoneNumberVerification(app)` to access the
|
|
37
|
+
* {@link PhoneNumberVerification} service associated with a specific app.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```javascript
|
|
41
|
+
* // Get the PhoneNumberVerification service for the default app
|
|
42
|
+
* const defaultPnv = getPhoneNumberVerification();
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```javascript
|
|
47
|
+
* // Get the PhoneNumberVerification service for a given app
|
|
48
|
+
* const otherPnv = getPhoneNumberVerification(otherApp);
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @returns The {@link PhoneNumberVerification} service associated with the provided app.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
function getPhoneNumberVerification(app) {
|
|
55
|
+
if (typeof app === 'undefined') {
|
|
56
|
+
app = (0, app_1.getApp)();
|
|
57
|
+
}
|
|
58
|
+
const firebaseApp = app;
|
|
59
|
+
return firebaseApp.getOrInitService('phone-number-verification', (app) => new phone_number_verification_1.PhoneNumberVerification(app));
|
|
60
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { PrefixedFirebaseError } from '../utils/error';
|
|
19
|
+
export interface FirebasePhoneNumberTokenInfo {
|
|
20
|
+
/** Documentation URL. */
|
|
21
|
+
url: string;
|
|
22
|
+
/** verify API name. */
|
|
23
|
+
verifyApiName: string;
|
|
24
|
+
/** The JWT full name. */
|
|
25
|
+
jwtName: string;
|
|
26
|
+
/** The JWT short name. */
|
|
27
|
+
shortName: string;
|
|
28
|
+
/** The JWT typ (Type) */
|
|
29
|
+
typ: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const JWKS_URL = "https://fpnv.googleapis.com/v1beta/jwks";
|
|
32
|
+
export declare const FPNV_TOKEN_INFO: FirebasePhoneNumberTokenInfo;
|
|
33
|
+
export declare const FPNV_ERROR_CODE_MAPPING: {
|
|
34
|
+
INVALID_ARGUMENT: "invalid-argument";
|
|
35
|
+
INVALID_TOKEN: "invalid-token";
|
|
36
|
+
EXPIRED_TOKEN: "expired-token";
|
|
37
|
+
};
|
|
38
|
+
export type PhoneNumberVerificationErrorCode = 'invalid-argument' | 'invalid-token' | 'expired-token';
|
|
39
|
+
/**
|
|
40
|
+
* Firebase Phone Number Verification error code structure. This extends `PrefixedFirebaseError`.
|
|
41
|
+
*
|
|
42
|
+
* @param code - The error code.
|
|
43
|
+
* @param message - The error message.
|
|
44
|
+
* @constructor
|
|
45
|
+
*/
|
|
46
|
+
export declare class FirebasePhoneNumberVerificationError extends PrefixedFirebaseError {
|
|
47
|
+
constructor(code: PhoneNumberVerificationErrorCode, message: string);
|
|
48
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2025 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.FirebasePhoneNumberVerificationError = exports.FPNV_ERROR_CODE_MAPPING = exports.FPNV_TOKEN_INFO = exports.JWKS_URL = void 0;
|
|
21
|
+
const error_1 = require("../utils/error");
|
|
22
|
+
exports.JWKS_URL = 'https://fpnv.googleapis.com/v1beta/jwks';
|
|
23
|
+
exports.FPNV_TOKEN_INFO = {
|
|
24
|
+
url: 'https://firebase.google.com/docs/phone-number-verification',
|
|
25
|
+
verifyApiName: 'verifyToken()',
|
|
26
|
+
jwtName: 'Firebase Phone Verification token',
|
|
27
|
+
shortName: 'FPNV token',
|
|
28
|
+
typ: 'JWT',
|
|
29
|
+
};
|
|
30
|
+
exports.FPNV_ERROR_CODE_MAPPING = {
|
|
31
|
+
INVALID_ARGUMENT: 'invalid-argument',
|
|
32
|
+
INVALID_TOKEN: 'invalid-token',
|
|
33
|
+
EXPIRED_TOKEN: 'expired-token',
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Firebase Phone Number Verification error code structure. This extends `PrefixedFirebaseError`.
|
|
37
|
+
*
|
|
38
|
+
* @param code - The error code.
|
|
39
|
+
* @param message - The error message.
|
|
40
|
+
* @constructor
|
|
41
|
+
*/
|
|
42
|
+
class FirebasePhoneNumberVerificationError extends error_1.PrefixedFirebaseError {
|
|
43
|
+
constructor(code, message) {
|
|
44
|
+
super('phone-number-verification', code, message);
|
|
45
|
+
/* tslint:disable:max-line-length */
|
|
46
|
+
// Set the prototype explicitly. See the following link for more details:
|
|
47
|
+
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
48
|
+
/* tslint:enable:max-line-length */
|
|
49
|
+
this.__proto__ = FirebasePhoneNumberVerificationError.prototype;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.FirebasePhoneNumberVerificationError = FirebasePhoneNumberVerificationError;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Interface representing a PhoneNumberVerification token.
|
|
20
|
+
*/
|
|
21
|
+
export interface PhoneNumberVerificationToken {
|
|
22
|
+
/**
|
|
23
|
+
* The issuer identifier for the issuer of the response.
|
|
24
|
+
* This value is a URL with the format
|
|
25
|
+
* `https://fpnv.googleapis.com/projects/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
|
|
26
|
+
* project number of your Firebase project, and the
|
|
27
|
+
* same project number specified in the {@link PhoneNumberVerificationToken.aud} property.
|
|
28
|
+
*/
|
|
29
|
+
iss: string;
|
|
30
|
+
/**
|
|
31
|
+
* The audience for which this token is intended.
|
|
32
|
+
* This value is a JSON array of two strings, the first is the project number of your
|
|
33
|
+
* Firebase project, and the second is the project ID of the same project.
|
|
34
|
+
*/
|
|
35
|
+
aud: string[];
|
|
36
|
+
/**
|
|
37
|
+
* The PhoneNumber Verification token's expiration time, in seconds since the Unix epoch. That is, the
|
|
38
|
+
* time at which this PhoneNumber Verification token expires and should no longer be considered valid.
|
|
39
|
+
*/
|
|
40
|
+
exp: number;
|
|
41
|
+
/**
|
|
42
|
+
* The PhoneNumber Verification token's issued-at time, in seconds since the Unix epoch. That is, the
|
|
43
|
+
* time at which this PhoneNumber Verification token was issued and should start to be considered
|
|
44
|
+
* valid.
|
|
45
|
+
*/
|
|
46
|
+
iat: number;
|
|
47
|
+
/**
|
|
48
|
+
* The phone number corresponding to this token.
|
|
49
|
+
* As a convenience, this value is copied over to the
|
|
50
|
+
* {@link PhoneNumberVerificationToken.phoneNumber | phoneNumber} property.
|
|
51
|
+
*/
|
|
52
|
+
sub: string;
|
|
53
|
+
/**
|
|
54
|
+
* A case-sensitive string that uniquely identifies a specific JWT instance
|
|
55
|
+
*/
|
|
56
|
+
jti: string;
|
|
57
|
+
/**
|
|
58
|
+
* A unique, single-use "number used once" value.
|
|
59
|
+
*/
|
|
60
|
+
nonce: string;
|
|
61
|
+
/**
|
|
62
|
+
* The corresponding user's phone number.
|
|
63
|
+
* This value is not actually one of the JWT token claims. It is added as a
|
|
64
|
+
* convenience, and is set as the value of the {@link PhoneNumberVerificationToken.sub} property.
|
|
65
|
+
*/
|
|
66
|
+
phoneNumber: string;
|
|
67
|
+
/**
|
|
68
|
+
* Other arbitrary claims included in the token.
|
|
69
|
+
*/
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
}
|
|
72
|
+
export { PhoneNumberVerificationErrorCode, FirebasePhoneNumberVerificationError, } from './phone-number-verification-api-client-internal';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2025 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.FirebasePhoneNumberVerificationError = void 0;
|
|
21
|
+
var phone_number_verification_api_client_internal_1 = require("./phone-number-verification-api-client-internal");
|
|
22
|
+
Object.defineProperty(exports, "FirebasePhoneNumberVerificationError", { enumerable: true, get: function () { return phone_number_verification_api_client_internal_1.FirebasePhoneNumberVerificationError; } });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { App } from '../app';
|
|
19
|
+
import { PhoneNumberVerificationToken } from './phone-number-verification-api';
|
|
20
|
+
/**
|
|
21
|
+
* PhoneNumberVerification service bound to the provided app.
|
|
22
|
+
*/
|
|
23
|
+
export declare class PhoneNumberVerification {
|
|
24
|
+
private readonly appInternal;
|
|
25
|
+
private readonly phoneNumberVerificationVerifier;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the app associated with this `PhoneNumberVerification` instance.
|
|
28
|
+
*
|
|
29
|
+
* @returns The app associated with this `PhoneNumberVerification` instance.
|
|
30
|
+
*/
|
|
31
|
+
get app(): App;
|
|
32
|
+
/**
|
|
33
|
+
* Verifies a Firebase Phone Number Verification token.
|
|
34
|
+
*
|
|
35
|
+
* @param jwt - A string containing the Firebase Phone Number Verification JWT.
|
|
36
|
+
* @returns A promise that resolves with the decoded token.
|
|
37
|
+
*/
|
|
38
|
+
verifyToken(jwt: string): Promise<PhoneNumberVerificationToken>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2025 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.PhoneNumberVerification = void 0;
|
|
21
|
+
const token_verifier_1 = require("./token-verifier");
|
|
22
|
+
const phone_number_verification_api_client_internal_1 = require("./phone-number-verification-api-client-internal");
|
|
23
|
+
/**
|
|
24
|
+
* PhoneNumberVerification service bound to the provided app.
|
|
25
|
+
*/
|
|
26
|
+
class PhoneNumberVerification {
|
|
27
|
+
/**
|
|
28
|
+
* @param app - The app for this `PhoneNumberVerification` service.
|
|
29
|
+
* @constructor
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
constructor(app) {
|
|
33
|
+
this.appInternal = app;
|
|
34
|
+
this.phoneNumberVerificationVerifier = new token_verifier_1.PhoneNumberTokenVerifier(phone_number_verification_api_client_internal_1.JWKS_URL, 'https://fpnv.googleapis.com/projects/', phone_number_verification_api_client_internal_1.FPNV_TOKEN_INFO, app);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the app associated with this `PhoneNumberVerification` instance.
|
|
38
|
+
*
|
|
39
|
+
* @returns The app associated with this `PhoneNumberVerification` instance.
|
|
40
|
+
*/
|
|
41
|
+
get app() {
|
|
42
|
+
return this.appInternal;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Verifies a Firebase Phone Number Verification token.
|
|
46
|
+
*
|
|
47
|
+
* @param jwt - A string containing the Firebase Phone Number Verification JWT.
|
|
48
|
+
* @returns A promise that resolves with the decoded token.
|
|
49
|
+
*/
|
|
50
|
+
verifyToken(jwt) {
|
|
51
|
+
return this.phoneNumberVerificationVerifier.verifyJWT(jwt);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.PhoneNumberVerification = PhoneNumberVerification;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { App } from '../app';
|
|
19
|
+
import { PhoneNumberVerificationToken } from './phone-number-verification-api';
|
|
20
|
+
import { FirebasePhoneNumberTokenInfo } from './phone-number-verification-api-client-internal';
|
|
21
|
+
export declare class PhoneNumberTokenVerifier {
|
|
22
|
+
private readonly issuer;
|
|
23
|
+
private readonly tokenInfo;
|
|
24
|
+
private readonly app;
|
|
25
|
+
private readonly shortNameArticle;
|
|
26
|
+
private readonly signatureVerifier;
|
|
27
|
+
constructor(jwksUrl: string, issuer: string, tokenInfo: FirebasePhoneNumberTokenInfo, app: App);
|
|
28
|
+
verifyJWT(jwtToken: string): Promise<PhoneNumberVerificationToken>;
|
|
29
|
+
private ensureProjectId;
|
|
30
|
+
private decodeAndVerify;
|
|
31
|
+
private safeDecode;
|
|
32
|
+
private verifyContent;
|
|
33
|
+
private verifySignature;
|
|
34
|
+
private mapJwtErrorToAuthError;
|
|
35
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*! firebase-admin v13.8.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2025 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.PhoneNumberTokenVerifier = void 0;
|
|
21
|
+
const phone_number_verification_api_1 = require("./phone-number-verification-api");
|
|
22
|
+
const util = require("../utils/index");
|
|
23
|
+
const validator = require("../utils/validator");
|
|
24
|
+
const jwt_1 = require("../utils/jwt");
|
|
25
|
+
const phone_number_verification_api_client_internal_1 = require("./phone-number-verification-api-client-internal");
|
|
26
|
+
class PhoneNumberTokenVerifier {
|
|
27
|
+
constructor(jwksUrl, issuer, tokenInfo, app) {
|
|
28
|
+
this.issuer = issuer;
|
|
29
|
+
this.tokenInfo = tokenInfo;
|
|
30
|
+
this.app = app;
|
|
31
|
+
if (!validator.isURL(jwksUrl)) {
|
|
32
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The provided public client certificate URL is an invalid URL.');
|
|
33
|
+
}
|
|
34
|
+
else if (!validator.isURL(issuer)) {
|
|
35
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The provided JWT issuer is an invalid URL.');
|
|
36
|
+
}
|
|
37
|
+
else if (!validator.isNonNullObject(tokenInfo)) {
|
|
38
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The provided JWT information is not an object or null.');
|
|
39
|
+
}
|
|
40
|
+
else if (!validator.isURL(tokenInfo.url)) {
|
|
41
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The provided JWT verification documentation URL is invalid.');
|
|
42
|
+
}
|
|
43
|
+
else if (!validator.isNonEmptyString(tokenInfo.verifyApiName)) {
|
|
44
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The JWT verify API name must be a non-empty string.');
|
|
45
|
+
}
|
|
46
|
+
else if (!validator.isNonEmptyString(tokenInfo.jwtName)) {
|
|
47
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The JWT public full name must be a non-empty string.');
|
|
48
|
+
}
|
|
49
|
+
else if (!validator.isNonEmptyString(tokenInfo.shortName)) {
|
|
50
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'The JWT public short name must be a non-empty string.');
|
|
51
|
+
}
|
|
52
|
+
this.shortNameArticle = tokenInfo.shortName.charAt(0).match(/[aeiou]/i) ? 'an' : 'a';
|
|
53
|
+
this.signatureVerifier = jwt_1.PublicKeySignatureVerifier.withJwksUrl(jwksUrl, app.options.httpAgent);
|
|
54
|
+
// Project ID is validated in the verification call.
|
|
55
|
+
}
|
|
56
|
+
async verifyJWT(jwtToken) {
|
|
57
|
+
if (!validator.isString(jwtToken)) {
|
|
58
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_TOKEN, `First argument to ${this.tokenInfo.verifyApiName} must be a string.`);
|
|
59
|
+
}
|
|
60
|
+
const projectId = await this.ensureProjectId();
|
|
61
|
+
const decoded = await this.decodeAndVerify(jwtToken, projectId);
|
|
62
|
+
const decodedIdToken = decoded.payload;
|
|
63
|
+
decodedIdToken.phoneNumber = decodedIdToken.sub;
|
|
64
|
+
return decodedIdToken;
|
|
65
|
+
}
|
|
66
|
+
async ensureProjectId() {
|
|
67
|
+
const projectId = await util.findProjectId(this.app);
|
|
68
|
+
if (!validator.isNonEmptyString(projectId)) {
|
|
69
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, 'Must initialize app with a cert credential or set your Firebase project ID as the ' +
|
|
70
|
+
`GOOGLE_CLOUD_PROJECT environment variable to call ${this.tokenInfo.verifyApiName}.`);
|
|
71
|
+
}
|
|
72
|
+
return projectId;
|
|
73
|
+
}
|
|
74
|
+
async decodeAndVerify(token, projectId) {
|
|
75
|
+
const decodedToken = await this.safeDecode(token);
|
|
76
|
+
this.verifyContent(decodedToken, projectId);
|
|
77
|
+
await this.verifySignature(token);
|
|
78
|
+
return decodedToken;
|
|
79
|
+
}
|
|
80
|
+
async safeDecode(jwtToken) {
|
|
81
|
+
try {
|
|
82
|
+
return await (0, jwt_1.decodeJwt)(jwtToken);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (err.code === jwt_1.JwtErrorCode.INVALID_ARGUMENT) {
|
|
86
|
+
const verifyJwtTokenDocsMessage = ` See ${this.tokenInfo.url} ` +
|
|
87
|
+
`for details on how to retrieve ${this.shortNameArticle} ${this.tokenInfo.shortName}.`;
|
|
88
|
+
const errorMessage = `Decoding ${this.tokenInfo.jwtName} failed. Make sure you passed ` +
|
|
89
|
+
`the entire string JWT which represents ${this.shortNameArticle} ` +
|
|
90
|
+
`${this.tokenInfo.shortName}.` + verifyJwtTokenDocsMessage;
|
|
91
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
|
|
92
|
+
}
|
|
93
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, err.message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
verifyContent(fullDecodedToken, projectId) {
|
|
97
|
+
const header = fullDecodedToken && fullDecodedToken.header;
|
|
98
|
+
const payload = fullDecodedToken && fullDecodedToken.payload;
|
|
99
|
+
const projectIdMatchMessage = ` Make sure the ${this.tokenInfo.shortName} comes from the same ` +
|
|
100
|
+
'Firebase project as the service account used to authenticate this SDK.';
|
|
101
|
+
const verifyJwtTokenDocsMessage = ` See ${this.tokenInfo.url} ` +
|
|
102
|
+
`for details on how to retrieve ${this.shortNameArticle} ${this.tokenInfo.shortName}.`;
|
|
103
|
+
const scopedProjectId = `${this.issuer}${projectId}`;
|
|
104
|
+
let errorMessage;
|
|
105
|
+
// JWT Header
|
|
106
|
+
if (!header || typeof header.kid === 'undefined') {
|
|
107
|
+
errorMessage = `${this.tokenInfo.jwtName} has no "kid" claim.`;
|
|
108
|
+
errorMessage += verifyJwtTokenDocsMessage;
|
|
109
|
+
}
|
|
110
|
+
else if (header.alg !== jwt_1.ALGORITHM_ES256) {
|
|
111
|
+
errorMessage = `${this.tokenInfo.jwtName} has incorrect algorithm. Expected ` +
|
|
112
|
+
`"${jwt_1.ALGORITHM_ES256}" but got "${header.alg}". ${verifyJwtTokenDocsMessage}`;
|
|
113
|
+
}
|
|
114
|
+
else if (header.typ !== this.tokenInfo.typ) {
|
|
115
|
+
errorMessage = `${this.tokenInfo.jwtName} has incorrect typ. Expected "${this.tokenInfo.typ}" but got ` +
|
|
116
|
+
`"${header.typ}". ${verifyJwtTokenDocsMessage}`;
|
|
117
|
+
}
|
|
118
|
+
// FPNV Token
|
|
119
|
+
else if (!payload) {
|
|
120
|
+
errorMessage = `${this.tokenInfo.jwtName} has no payload. ${verifyJwtTokenDocsMessage}`;
|
|
121
|
+
}
|
|
122
|
+
else if (typeof payload.iss !== 'string' || !payload.iss.startsWith(this.issuer)) {
|
|
123
|
+
errorMessage = `${this.tokenInfo.jwtName} has incorrect "iss" (issuer) claim. Expected ` +
|
|
124
|
+
`an issuer starting with "${this.issuer}" but got "${payload.iss}".`
|
|
125
|
+
+ ` ${projectIdMatchMessage} ${verifyJwtTokenDocsMessage}`;
|
|
126
|
+
}
|
|
127
|
+
else if (!validator.isNonEmptyArray(payload.aud) || !payload.aud.includes(scopedProjectId)) {
|
|
128
|
+
errorMessage = `${this.tokenInfo.jwtName} has incorrect "aud" (audience) claim. Expected ` +
|
|
129
|
+
`"${scopedProjectId}" to be one of "${payload.aud}". ${projectIdMatchMessage} ${verifyJwtTokenDocsMessage}`;
|
|
130
|
+
}
|
|
131
|
+
else if (typeof payload.sub !== 'string') {
|
|
132
|
+
errorMessage = `${this.tokenInfo.jwtName} has no "sub" (subject) claim. ${verifyJwtTokenDocsMessage}`;
|
|
133
|
+
}
|
|
134
|
+
else if (payload.sub === '') {
|
|
135
|
+
errorMessage = `${this.tokenInfo.jwtName} has an empty "sub" (subject) claim. ${verifyJwtTokenDocsMessage}`;
|
|
136
|
+
}
|
|
137
|
+
if (errorMessage) {
|
|
138
|
+
throw new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async verifySignature(jwtToken) {
|
|
142
|
+
try {
|
|
143
|
+
return await this.signatureVerifier.verify(jwtToken);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
throw this.mapJwtErrorToAuthError(error);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
mapJwtErrorToAuthError(error) {
|
|
150
|
+
const verifyJwtTokenDocsMessage = ` See ${this.tokenInfo.url} ` +
|
|
151
|
+
`for details on how to retrieve ${this.shortNameArticle} ${this.tokenInfo.shortName}.`;
|
|
152
|
+
if (error.code === jwt_1.JwtErrorCode.TOKEN_EXPIRED) {
|
|
153
|
+
const errorMessage = `${this.tokenInfo.jwtName} has expired. Get a fresh ${this.tokenInfo.shortName}` +
|
|
154
|
+
` from your client app and try again. ${verifyJwtTokenDocsMessage}`;
|
|
155
|
+
return new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.EXPIRED_TOKEN, errorMessage);
|
|
156
|
+
}
|
|
157
|
+
else if (error.code === jwt_1.JwtErrorCode.INVALID_SIGNATURE) {
|
|
158
|
+
const errorMessage = `${this.tokenInfo.jwtName} has invalid signature. ${verifyJwtTokenDocsMessage}`;
|
|
159
|
+
return new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
|
|
160
|
+
}
|
|
161
|
+
else if (error.code === jwt_1.JwtErrorCode.NO_MATCHING_KID) {
|
|
162
|
+
const errorMessage = `${this.tokenInfo.jwtName} has "kid" claim which does not ` +
|
|
163
|
+
`correspond to a known public key. Most likely the ${this.tokenInfo.shortName} ` +
|
|
164
|
+
'is expired, so get a fresh token from your client app and try again.';
|
|
165
|
+
return new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, errorMessage);
|
|
166
|
+
}
|
|
167
|
+
return new phone_number_verification_api_1.FirebasePhoneNumberVerificationError(phone_number_verification_api_client_internal_1.FPNV_ERROR_CODE_MAPPING.INVALID_ARGUMENT, error.message);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.PhoneNumberTokenVerifier = PhoneNumberTokenVerifier;
|