Skip to content

Commit f19eb4f

Browse files
chore: Update App Check to V1 endpoints (#1632)
1 parent abdfb00 commit f19eb4f

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/app-check/app-check-api-client-internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as validator from '../utils/validator';
2626
import { AppCheckToken } from './app-check-api'
2727

2828
// App Check backend constants
29-
const FIREBASE_APP_CHECK_V1_API_URL_FORMAT = 'https://firebaseappcheck.googleapis.com/v1beta/projects/{projectId}/apps/{appId}:exchangeCustomToken';
29+
const FIREBASE_APP_CHECK_V1_API_URL_FORMAT = 'https://firebaseappcheck.googleapis.com/v1/projects/{projectId}/apps/{appId}:exchangeCustomToken';
3030

3131
const FIREBASE_APP_CHECK_CONFIG_HEADERS = {
3232
'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`
@@ -144,7 +144,7 @@ export class AppCheckApiClient {
144144
* @returns An AppCheckToken instance.
145145
*/
146146
private toAppCheckToken(resp: HttpResponse): AppCheckToken {
147-
const token = resp.data.attestationToken;
147+
const token = resp.data.token;
148148
// `ttl` is a string with the suffix "s" preceded by the number of seconds,
149149
// with nanoseconds expressed as fractional seconds.
150150
const ttlMillis = this.stringToMilliseconds(resp.data.ttl);

src/app-check/token-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const ONE_MINUTE_IN_MILLIS = ONE_MINUTE_IN_SECONDS * 1000;
3131
const ONE_DAY_IN_MILLIS = 24 * 60 * 60 * 1000;
3232

3333
// Audience to use for Firebase App Check Custom tokens
34-
const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1beta.TokenExchangeService';
34+
const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService';
3535

3636
/**
3737
* Class for generating Firebase App Check tokens.

src/app-check/token-verifier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { DecodedAppCheckToken } from './app-check-api'
2626
import { App } from '../app';
2727

2828
const APP_CHECK_ISSUER = 'https://firebaseappcheck.googleapis.com/';
29-
const JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1beta/jwks';
29+
const JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1/jwks';
3030

3131
/**
3232
* Class for verifying Firebase App Check tokens.

test/unit/app-check/app-check-api-client-internal.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('AppCheckApiClient', () => {
5656
const TEST_TOKEN_TO_EXCHANGE = 'signed-custom-token';
5757

5858
const TEST_RESPONSE = {
59-
attestationToken: 'token',
59+
token: 'token',
6060
ttl: '3s'
6161
};
6262

@@ -203,11 +203,11 @@ describe('AppCheckApiClient', () => {
203203
stubs.push(stub);
204204
return apiClient.exchangeToken(TEST_TOKEN_TO_EXCHANGE, APP_ID)
205205
.then((resp) => {
206-
expect(resp.token).to.deep.equal(TEST_RESPONSE.attestationToken);
206+
expect(resp.token).to.deep.equal(TEST_RESPONSE.token);
207207
expect(resp.ttlMillis).to.deep.equal(3000);
208208
expect(stub).to.have.been.calledOnce.and.calledWith({
209209
method: 'POST',
210-
url: `https://firebaseappcheck.googleapis.com/v1beta/projects/test-project/apps/${APP_ID}:exchangeCustomToken`,
210+
url: `https://firebaseappcheck.googleapis.com/v1/projects/test-project/apps/${APP_ID}:exchangeCustomToken`,
211211
headers: EXPECTED_HEADERS,
212212
data: { customToken: TEST_TOKEN_TO_EXCHANGE }
213213
});
@@ -229,7 +229,7 @@ describe('AppCheckApiClient', () => {
229229
stubs.push(stub);
230230
return apiClient.exchangeToken(TEST_TOKEN_TO_EXCHANGE, APP_ID)
231231
.then((resp) => {
232-
expect(resp.token).to.deep.equal(response.attestationToken);
232+
expect(resp.token).to.deep.equal(response.token);
233233
expect(resp.ttlMillis).to.deep.equal(ttlMillis);
234234
});
235235
});

test/unit/app-check/token-generator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const expect = chai.expect;
4444

4545
const ALGORITHM = 'RS256';
4646
const FIVE_MIN_IN_SECONDS = 5 * 60;
47-
const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1beta.TokenExchangeService';
47+
const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService';
4848

4949
/**
5050
* Verifies a token is signed with the private key corresponding to the provided public key.

0 commit comments

Comments
 (0)