Skip to content

Update App Check to v1 from v1beta #6136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-gorillas-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app-check': patch
---

Update App Check to use v1 endpoint instead of v1beta endpoint for both reCAPTCHA v3 and reCAPTCHA Enterprise
8 changes: 4 additions & 4 deletions packages/app-check/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ describe('client', () => {
const { projectId, appId, apiKey } = app.options;

expect(request).to.deep.equal({
url: `${BASE_ENDPOINT}/projects/${projectId}/apps/${appId}:exchangeRecaptchaToken?key=${apiKey}`,
url: `${BASE_ENDPOINT}/projects/${projectId}/apps/${appId}:exchangeRecaptchaV3Token?key=${apiKey}`,
body: {
// eslint-disable-next-line camelcase
recaptcha_token: 'fake-recaptcha-token'
recaptcha_v3_token: 'fake-recaptcha-token'
}
});
});
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('client', () => {
Promise.resolve({
status: 200,
json: async () => ({
attestationToken: 'fake-appcheck-token',
token: 'fake-appcheck-token',
ttl: '3.600s'
})
} as Response)
Expand Down Expand Up @@ -189,7 +189,7 @@ describe('client', () => {
status: 200,
json: () =>
Promise.resolve({
attestationToken: 'fake-appcheck-token',
token: 'fake-appcheck-token',
ttl: 'NAN'
})
} as Response)
Expand Down
6 changes: 3 additions & 3 deletions packages/app-check/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { AppCheckTokenInternal } from './types';
* Response JSON returned from AppCheck server endpoint.
*/
interface AppCheckResponse {
attestationToken: string;
token: string;
// timeToLive
ttl: string;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ export async function exchangeToken(

const now = Date.now();
return {
token: responseBody.attestationToken,
token: responseBody.token,
expireTimeMillis: now + timeToLiveAsNumber,
issuedAtTimeMillis: now
};
Expand All @@ -116,7 +116,7 @@ export function getExchangeRecaptchaV3TokenRequest(
return {
url: `${BASE_ENDPOINT}/projects/${projectId}/apps/${appId}:${EXCHANGE_RECAPTCHA_TOKEN_METHOD}?key=${apiKey}`,
body: {
'recaptcha_token': reCAPTCHAToken
'recaptcha_v3_token': reCAPTCHAToken
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-check/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/
export const BASE_ENDPOINT =
'https://content-firebaseappcheck.googleapis.com/v1beta';
'https://content-firebaseappcheck.googleapis.com/v1';

export const EXCHANGE_RECAPTCHA_TOKEN_METHOD = 'exchangeRecaptchaToken';
export const EXCHANGE_RECAPTCHA_TOKEN_METHOD = 'exchangeRecaptchaV3Token';
export const EXCHANGE_RECAPTCHA_ENTERPRISE_TOKEN_METHOD =
'exchangeRecaptchaEnterpriseToken';
export const EXCHANGE_DEBUG_TOKEN_METHOD = 'exchangeDebugToken';
Expand Down
2 changes: 1 addition & 1 deletion packages/app-check/src/internal-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('internal api', () => {

expect(reCAPTCHASpy).to.be.called;

expect(exchangeTokenStub.args[0][0].body['recaptcha_token']).to.equal(
expect(exchangeTokenStub.args[0][0].body['recaptcha_v3_token']).to.equal(
fakeRecaptchaToken
);
expect(token).to.deep.equal({ token: fakeRecaptchaAppCheckToken.token });
Expand Down