@@ -36,7 +36,7 @@ var JWKSUrl = "https://firebaseappcheck.googleapis.com/v1beta/jwks"
36
36
37
37
const appCheckIssuer = "https://firebaseappcheck.googleapis.com/"
38
38
39
- const tokenVerificationUrlFormat = "https://firebaseappcheck.googleapis.com/v1beta/projects/%s:verifyAppCheckToken "
39
+ const tokenVerifierBaseUrl = "https://firebaseappcheck.googleapis.com"
40
40
41
41
var (
42
42
// ErrIncorrectAlgorithm is returned when the token is signed with a non-RSA256 algorithm.
@@ -72,9 +72,9 @@ type DecodedAppCheckToken struct {
72
72
73
73
// Client is the interface for the Firebase App Check service.
74
74
type Client struct {
75
- projectID string
76
- jwks * keyfunc.JWKS
77
- tokenVerificationUrl string
75
+ projectID string
76
+ jwks * keyfunc.JWKS
77
+ tokenVerifierUrl string
78
78
}
79
79
80
80
// NewClient creates a new instance of the Firebase App Check Client.
@@ -92,9 +92,9 @@ func NewClient(ctx context.Context, conf *internal.AppCheckConfig) (*Client, err
92
92
}
93
93
94
94
return & Client {
95
- projectID : conf .ProjectID ,
96
- jwks : jwks ,
97
- tokenVerificationUrl : fmt . Sprintf ( tokenVerificationUrlFormat , conf .ProjectID ),
95
+ projectID : conf .ProjectID ,
96
+ jwks : jwks ,
97
+ tokenVerifierUrl : buildTokenVerifierUrl ( conf .ProjectID ),
98
98
}, nil
99
99
}
100
100
@@ -212,7 +212,7 @@ func (c *Client) VerifyOneTimeToken(token string) (*DecodedAppCheckToken, error)
212
212
213
213
bodyReader := bytes .NewReader ([]byte (fmt .Sprintf (`{"app_check_token":%s}` , token )))
214
214
215
- resp , err := http .Post (c .tokenVerificationUrl , "application/json" , bodyReader )
215
+ resp , err := http .Post (c .tokenVerifierUrl , "application/json" , bodyReader )
216
216
217
217
if err != nil {
218
218
return nil , err
@@ -235,6 +235,10 @@ func (c *Client) VerifyOneTimeToken(token string) (*DecodedAppCheckToken, error)
235
235
return decodedAppCheckToken , nil
236
236
}
237
237
238
+ func buildTokenVerifierUrl (projectId string ) string {
239
+ return fmt .Sprintf ("%s/v1beta/projects/%s:verifyAppCheckToken" , tokenVerifierBaseUrl , projectId )
240
+ }
241
+
238
242
func contains (s []string , str string ) bool {
239
243
for _ , v := range s {
240
244
if v == str {
0 commit comments