Skip to content

Commit 929335b

Browse files
committed
rename fpnv to fully qualified name
1 parent 91bb749 commit 929335b

10 files changed

Lines changed: 263 additions & 319 deletions

‎src/main/java/com/google/firebase/fpnv/FirebasePnv.java‎

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.firebase.phonenumberverification;
18+
19+
import com.google.firebase.FirebaseApp;
20+
import com.google.firebase.ImplFirebaseTrampolines;
21+
import com.google.firebase.internal.FirebaseService;
22+
import com.google.firebase.phonenumberverification.internal.FirebasePhoneNumberVerificationTokenVerifier;
23+
24+
/**
25+
* This class is the entry point for the Firebase Phone Number Verification service.
26+
*
27+
* <p>You can get an instance of {@link FirebasePhoneNumberVerification} via {@link #getInstance()},
28+
* or {@link #getInstance(FirebaseApp)} and then use it.
29+
*/
30+
public final class FirebasePhoneNumberVerification {
31+
private static final String SERVICE_ID = FirebasePhoneNumberVerification.class.getName();
32+
private final FirebasePhoneNumberVerificationTokenVerifier tokenVerifier;
33+
34+
private FirebasePhoneNumberVerification(FirebaseApp app) {
35+
this.tokenVerifier = new FirebasePhoneNumberVerificationTokenVerifier(app);
36+
}
37+
38+
/**
39+
* Gets the {@link FirebasePhoneNumberVerification} instance for the default {@link FirebaseApp}.
40+
*
41+
* @return The {@link FirebasePhoneNumberVerification} instance for the default {@link FirebaseApp}.
42+
*/
43+
public static FirebasePhoneNumberVerification getInstance() {
44+
return getInstance(FirebaseApp.getInstance());
45+
}
46+
47+
/**
48+
* Gets the {@link FirebasePhoneNumberVerification} instance for the specified {@link FirebaseApp}.
49+
*
50+
* @return The {@link FirebasePhoneNumberVerification} instance for the specified {@link FirebaseApp}.
51+
*/
52+
public static synchronized FirebasePhoneNumberVerification getInstance(FirebaseApp app) {
53+
FirebasePhoneNumberVerificationService service = ImplFirebaseTrampolines.getService(app, SERVICE_ID,
54+
FirebasePhoneNumberVerificationService.class);
55+
if (service == null) {
56+
service = ImplFirebaseTrampolines.addService(app, new FirebasePhoneNumberVerificationService(app));
57+
}
58+
return service.getInstance();
59+
}
60+
61+
/**
62+
* Verifies a Firebase Phone Number Verification token (JWT).
63+
*
64+
* @param phoneNumberVerificationJwt The JWT string to verify.
65+
* @return A verified {@link FirebasePhoneNumberVerificationToken}.
66+
* @throws FirebasePhoneNumberVerificationException If verification fails.
67+
*/
68+
public FirebasePhoneNumberVerificationToken verifyToken(String phoneNumberVerificationJwt)
69+
throws FirebasePhoneNumberVerificationException {
70+
return this.tokenVerifier.verifyToken(phoneNumberVerificationJwt);
71+
}
72+
73+
private static class FirebasePhoneNumberVerificationService extends FirebaseService<FirebasePhoneNumberVerification> {
74+
FirebasePhoneNumberVerificationService(FirebaseApp app) {
75+
super(SERVICE_ID, new FirebasePhoneNumberVerification(app));
76+
}
77+
}
78+
}

src/main/java/com/google/firebase/fpnv/FirebasePnvErrorCode.java renamed to src/main/java/com/google/firebase/phonenumberverification/FirebasePhoneNumberVerificationErrorCode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.firebase.fpnv;
17+
package com.google.firebase.phonenumberverification;
1818

1919
/**
20-
* Error codes that are used in {@link FirebasePnv}.
20+
* Error codes that are used in {@link FirebasePhoneNumberVerification}.
2121
*/
22-
public enum FirebasePnvErrorCode {
22+
public enum FirebasePhoneNumberVerificationErrorCode {
2323
INVALID_ARGUMENT,
2424
INVALID_TOKEN,
2525
TOKEN_EXPIRED,

src/main/java/com/google/firebase/fpnv/FirebasePnvException.java renamed to src/main/java/com/google/firebase/phonenumberverification/FirebasePhoneNumberVerificationException.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.firebase.fpnv;
17+
package com.google.firebase.phonenumberverification;
1818

1919
import com.google.firebase.ErrorCode;
2020
import com.google.firebase.FirebaseException;
2121

2222
/**
2323
* Generic exception related to Firebase Phone Number Verification.
24-
* Check the error code and message for more
25-
* details.
24+
* Check the error code and message for more details.
2625
*/
27-
public class FirebasePnvException extends FirebaseException {
28-
private final FirebasePnvErrorCode errorCode;
26+
public class FirebasePhoneNumberVerificationException extends FirebaseException {
27+
private final FirebasePhoneNumberVerificationErrorCode errorCode;
2928

3029
/**
31-
* Exception that created from {@link FirebasePnvErrorCode},
30+
* Exception that created from {@link FirebasePhoneNumberVerificationErrorCode},
3231
* {@link String} message and {@link Throwable} cause.
3332
*
34-
* @param errorCode {@link FirebasePnvErrorCode}
33+
* @param errorCode {@link FirebasePhoneNumberVerificationErrorCode}
3534
* @param message {@link String}
3635
* @param cause {@link Throwable}
3736
*/
38-
public FirebasePnvException(
39-
FirebasePnvErrorCode errorCode,
37+
public FirebasePhoneNumberVerificationException(
38+
FirebasePhoneNumberVerificationErrorCode errorCode,
4039
String message,
4140
Throwable cause
4241
) {
@@ -45,23 +44,23 @@ public FirebasePnvException(
4544
}
4645

4746
/**
48-
* Exception that created from {@link FirebasePnvErrorCode} and {@link String} message.
47+
* Exception that created from {@link FirebasePhoneNumberVerificationErrorCode} and {@link String} message.
4948
*
50-
* @param errorCode {@link FirebasePnvErrorCode}
49+
* @param errorCode {@link FirebasePhoneNumberVerificationErrorCode}
5150
* @param message {@link String}
5251
*/
53-
public FirebasePnvException(
54-
FirebasePnvErrorCode errorCode,
52+
public FirebasePhoneNumberVerificationException(
53+
FirebasePhoneNumberVerificationErrorCode errorCode,
5554
String message
5655
) {
5756
this(errorCode, message, null);
5857
}
5958

60-
public FirebasePnvErrorCode getFpnvErrorCode() {
59+
public FirebasePhoneNumberVerificationErrorCode getPhoneNumberVerificationErrorCode() {
6160
return errorCode;
6261
}
6362

64-
private static ErrorCode mapToFirebaseError(FirebasePnvErrorCode code) {
63+
private static ErrorCode mapToFirebaseError(FirebasePhoneNumberVerificationErrorCode code) {
6564
if (code == null) {
6665
return ErrorCode.INTERNAL;
6766
}
@@ -79,4 +78,3 @@ private static ErrorCode mapToFirebaseError(FirebasePnvErrorCode code) {
7978
}
8079
}
8180
}
82-

src/main/java/com/google/firebase/fpnv/FirebasePnvToken.java renamed to src/main/java/com/google/firebase/phonenumberverification/FirebasePhoneNumberVerificationToken.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.firebase.fpnv;
17+
package com.google.firebase.phonenumberverification;
1818

1919
import static com.google.common.base.Preconditions.checkArgument;
2020

@@ -26,15 +26,15 @@
2626
/**
2727
* Represents a verified Firebase Phone Number Verification token.
2828
*/
29-
public class FirebasePnvToken {
29+
public class FirebasePhoneNumberVerificationToken {
3030
private final Map<String, Object> claims;
3131

3232
/**
33-
* Create an instance of {@link FirebasePnvToken} from a map of JWT claims.
33+
* Create an instance of {@link FirebasePhoneNumberVerificationToken} from a map of JWT claims.
3434
*
3535
* @param claims A map of JWT claims.
3636
*/
37-
public FirebasePnvToken(Map<String, Object> claims) {
37+
public FirebasePhoneNumberVerificationToken(Map<String, Object> claims) {
3838
checkArgument(claims != null && claims.containsKey("sub"),
3939
"Claims map must at least contain sub");
4040
this.claims = ImmutableMap.copyOf(claims);
@@ -63,8 +63,6 @@ public List<String> getAudience() {
6363
if (audience instanceof String) {
6464
return ImmutableList.of((String) audience);
6565
} else if (audience instanceof List) {
66-
// The nimbus-jose-jwt library should provide a List<String>, but we copy it
67-
// to an immutable list for safety and to prevent modification.
6866
@SuppressWarnings("unchecked")
6967
List<String> audienceList = (List<String>) audience;
7068
return ImmutableList.copyOf(audienceList);

0 commit comments

Comments
 (0)