Skip to content

Commit a4db18f

Browse files
committed
chore: Update FAC to beta
1 parent d2330d2 commit a4db18f

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as validator from '../utils/validator';
2828
import AppCheckToken = appCheck.AppCheckToken;
2929

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

3333
const FIREBASE_APP_CHECK_CONFIG_HEADERS = {
3434
'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`
@@ -147,9 +147,9 @@ export class AppCheckApiClient {
147147
*/
148148
private toAppCheckToken(resp: HttpResponse): AppCheckToken {
149149
const token = resp.data.attestationToken;
150-
// `timeToLive` is a string with the suffix "s" preceded by the number of seconds,
150+
// `ttl` is a string with the suffix "s" preceded by the number of seconds,
151151
// with nanoseconds expressed as fractional seconds.
152-
const ttlMillis = this.stringToMilliseconds(resp.data.timeToLive);
152+
const ttlMillis = this.stringToMilliseconds(resp.data.ttl);
153153
return {
154154
token,
155155
ttlMillis

src/app-check/token-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { HttpError } from '../utils/api-request';
2929
const ONE_HOUR_IN_SECONDS = 60 * 60;
3030

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

3434
/**
3535
* 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
@@ -27,7 +27,7 @@ import {
2727
import DecodedAppCheckToken = appCheck.DecodedAppCheckToken;
2828

2929
const APP_CHECK_ISSUER = 'https://firebaseappcheck.googleapis.com/';
30-
const JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1alpha/jwks';
30+
const JWKS_URL = 'https://firebaseappcheck.googleapis.com/v1beta/jwks';
3131

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

test/integration/app-check.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,34 @@ describe('admin.appCheck', () => {
7070
});
7171
});
7272
});
73+
74+
describe('verifyToken', () => {
75+
let validToken: admin.appCheck.AppCheckToken;
76+
77+
before(async () => {
78+
if (!appId) {
79+
return;
80+
}
81+
// obtain a valid app check token
82+
validToken = await admin.appCheck().createToken(appId as string);
83+
});
84+
85+
it('should succeed with a decoded verifed token response', function() {
86+
if (!appId) {
87+
this.skip();
88+
}
89+
return admin.appCheck().verifyToken(validToken.token)
90+
.then((verifedToken) => {
91+
expect(verifedToken).to.have.keys(['token', 'appId']);
92+
expect(verifedToken.token).to.have.keys(['iss', 'sub', 'aud', 'exp', 'iat', 'app_id']);
93+
expect(verifedToken.token.app_id).to.be.a('string').and.equals(appId);
94+
});
95+
});
96+
97+
it('should propagate API errors', () => {
98+
// rejects with invalid-argument when the token is invalid
99+
return admin.appCheck().verifyToken('invalid-token')
100+
.should.eventually.be.rejected.and.have.property('code', 'app-check/invalid-argument');
101+
});
102+
});
73103
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ describe('AppCheckApiClient', () => {
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/v1alpha/projects/test-project/apps/${APP_ID}:exchangeCustomToken`,
210+
url: `https://firebaseappcheck.googleapis.com/v1beta/projects/test-project/apps/${APP_ID}:exchangeCustomToken`,
211211
headers: EXPECTED_HEADERS,
212212
data: { customToken: TEST_TOKEN_TO_EXCHANGE }
213213
});

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 ONE_HOUR_IN_SECONDS = 60 * 60;
47-
const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1alpha.TokenExchangeService';
47+
const FIREBASE_APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1beta.TokenExchangeService';
4848

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

0 commit comments

Comments
 (0)