Skip to content

Commit 38da5d9

Browse files
authored
Update App Check to v1 from v1beta (#6136)
* Update App Check from v1beta to v1 * Update JSON object containing the FAC token * Update request JSON object for recaptcha. * Add changeset * Update wording describing the change.
1 parent 5249483 commit 38da5d9

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

.changeset/new-gorillas-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/app-check': patch
3+
---
4+
5+
Update App Check to use v1 endpoint instead of v1beta endpoint for both reCAPTCHA v3 and reCAPTCHA Enterprise

packages/app-check/src/client.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ describe('client', () => {
4747
const { projectId, appId, apiKey } = app.options;
4848

4949
expect(request).to.deep.equal({
50-
url: `${BASE_ENDPOINT}/projects/${projectId}/apps/${appId}:exchangeRecaptchaToken?key=${apiKey}`,
50+
url: `${BASE_ENDPOINT}/projects/${projectId}/apps/${appId}:exchangeRecaptchaV3Token?key=${apiKey}`,
5151
body: {
5252
// eslint-disable-next-line camelcase
53-
recaptcha_token: 'fake-recaptcha-token'
53+
recaptcha_v3_token: 'fake-recaptcha-token'
5454
}
5555
});
5656
});
@@ -78,7 +78,7 @@ describe('client', () => {
7878
Promise.resolve({
7979
status: 200,
8080
json: async () => ({
81-
attestationToken: 'fake-appcheck-token',
81+
token: 'fake-appcheck-token',
8282
ttl: '3.600s'
8383
})
8484
} as Response)
@@ -189,7 +189,7 @@ describe('client', () => {
189189
status: 200,
190190
json: () =>
191191
Promise.resolve({
192-
attestationToken: 'fake-appcheck-token',
192+
token: 'fake-appcheck-token',
193193
ttl: 'NAN'
194194
})
195195
} as Response)

packages/app-check/src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { AppCheckTokenInternal } from './types';
3030
* Response JSON returned from AppCheck server endpoint.
3131
*/
3232
interface AppCheckResponse {
33-
attestationToken: string;
33+
token: string;
3434
// timeToLive
3535
ttl: string;
3636
}
@@ -101,7 +101,7 @@ export async function exchangeToken(
101101

102102
const now = Date.now();
103103
return {
104-
token: responseBody.attestationToken,
104+
token: responseBody.token,
105105
expireTimeMillis: now + timeToLiveAsNumber,
106106
issuedAtTimeMillis: now
107107
};
@@ -116,7 +116,7 @@ export function getExchangeRecaptchaV3TokenRequest(
116116
return {
117117
url: `${BASE_ENDPOINT}/projects/${projectId}/apps/${appId}:${EXCHANGE_RECAPTCHA_TOKEN_METHOD}?key=${apiKey}`,
118118
body: {
119-
'recaptcha_token': reCAPTCHAToken
119+
'recaptcha_v3_token': reCAPTCHAToken
120120
}
121121
};
122122
}

packages/app-check/src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717
export const BASE_ENDPOINT =
18-
'https://content-firebaseappcheck.googleapis.com/v1beta';
18+
'https://content-firebaseappcheck.googleapis.com/v1';
1919

20-
export const EXCHANGE_RECAPTCHA_TOKEN_METHOD = 'exchangeRecaptchaToken';
20+
export const EXCHANGE_RECAPTCHA_TOKEN_METHOD = 'exchangeRecaptchaV3Token';
2121
export const EXCHANGE_RECAPTCHA_ENTERPRISE_TOKEN_METHOD =
2222
'exchangeRecaptchaEnterpriseToken';
2323
export const EXCHANGE_DEBUG_TOKEN_METHOD = 'exchangeDebugToken';

packages/app-check/src/internal-api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('internal api', () => {
111111

112112
expect(reCAPTCHASpy).to.be.called;
113113

114-
expect(exchangeTokenStub.args[0][0].body['recaptcha_token']).to.equal(
114+
expect(exchangeTokenStub.args[0][0].body['recaptcha_v3_token']).to.equal(
115115
fakeRecaptchaToken
116116
);
117117
expect(token).to.deep.equal({ token: fakeRecaptchaAppCheckToken.token });

0 commit comments

Comments
 (0)