Skip to content

Commit 7702cdc

Browse files
committed
Rename
1 parent 5dcd943 commit 7702cdc

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
initializeAppCheck,
2323
getToken,
2424
onTokenChanged,
25-
getScopedToken
25+
getLimitedUseToken
2626
} from './api';
2727
import {
2828
FAKE_SITE_KEY,
@@ -285,29 +285,29 @@ describe('api', () => {
285285
);
286286
});
287287
});
288-
describe('getScopedToken()', () => {
289-
it('getScopedToken() calls the internal getScopedToken() function', async () => {
288+
describe('getLimitedUseToken()', () => {
289+
it('getLimitedUseToken() calls the internal getLimitedUseToken() function', async () => {
290290
const app = getFakeApp({ automaticDataCollectionEnabled: true });
291291
const appCheck = getFakeAppCheck(app);
292-
const internalGetScopedToken = stub(
292+
const internalgetLimitedUseToken = stub(
293293
internalApi,
294-
'getScopedToken'
294+
'getLimitedUseToken'
295295
).resolves({
296296
token: 'a-token-string'
297297
});
298-
await getScopedToken(appCheck);
299-
expect(internalGetScopedToken).to.be.calledWith(appCheck);
298+
await getLimitedUseToken(appCheck);
299+
expect(internalgetLimitedUseToken).to.be.calledWith(appCheck);
300300
});
301-
it('getScopedToken() throws errors returned with token', async () => {
301+
it('getLimitedUseToken() throws errors returned with token', async () => {
302302
const app = getFakeApp({ automaticDataCollectionEnabled: true });
303303
const appCheck = getFakeAppCheck(app);
304-
// If getScopedToken() errors, it returns a dummy token with an error field
304+
// If getLimitedUseToken() errors, it returns a dummy token with an error field
305305
// instead of throwing.
306-
stub(internalApi, 'getScopedToken').resolves({
306+
stub(internalApi, 'getLimitedUseToken').resolves({
307307
token: 'a-dummy-token',
308308
error: Error('there was an error')
309309
});
310-
await expect(getScopedToken(appCheck)).to.be.rejectedWith(
310+
await expect(getLimitedUseToken(appCheck)).to.be.rejectedWith(
311311
'there was an error'
312312
);
313313
});

packages/app-check/src/api.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { AppCheckService } from './factory';
3535
import { AppCheckProvider, ListenerType } from './types';
3636
import {
3737
getToken as getTokenInternal,
38-
getScopedToken as getScopedTokenInternal,
38+
getLimitedUseToken as getLimitedUseTokenInternal,
3939
addTokenListener,
4040
removeTokenListener,
4141
isValid,
@@ -211,19 +211,23 @@ export async function getToken(
211211
}
212212

213213
/**
214-
* Requests a Firebase App Check token. This method should be used ONLY if you
215-
* need to authorize requests to a non-Firebase backend. Tokens from this
216-
* method are intended for use with the Admin SDKs when `consume` is set to
217-
* true. Tokens from this method do not interact with FirebaseAppCheck’s token
218-
* cache.
214+
* Requests a Firebase App Check token. This method should be used
215+
* *only* if you need to authorize requests to a non-Firebase backend.
219216
*
217+
* Returns limited-use tokens that are intended for use with your
218+
* non-Firebase backend endpoints that are protected with
219+
* <a href=[--URL to public docs--]>Replay Protection</a>. This method
220+
* does not affect the token generation behavior of the
221+
* #getAppCheckToken() method.
222+
*
220223
* @param appCheckInstance - The App Check service instance.
224+
* @returns The limited use token.
221225
* @public
222226
*/
223-
export async function getScopedToken(
227+
export async function getLimitedUseToken(
224228
appCheckInstance: AppCheck
225229
): Promise<AppCheckTokenResult> {
226-
const result = await getScopedTokenInternal(
230+
const result = await getLimitedUseTokenInternal(
227231
appCheckInstance as AppCheckService
228232
);
229233
if (result.error) {

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
removeTokenListener,
3434
formatDummyToken,
3535
defaultTokenErrorData,
36-
getScopedToken
36+
getLimitedUseToken
3737
} from './internal-api';
3838
import * as reCAPTCHA from './recaptcha';
3939
import * as client from './client';
@@ -638,15 +638,15 @@ describe('internal api', () => {
638638
});
639639
});
640640

641-
describe('getScopedToken()', () => {
641+
describe('getLimitedUseToken()', () => {
642642
it('uses customTokenProvider to get an AppCheck token', async () => {
643643
const customTokenProvider = getFakeCustomTokenProvider();
644644
const customProviderSpy = spy(customTokenProvider, 'getToken');
645645

646646
const appCheck = initializeAppCheck(app, {
647647
provider: customTokenProvider
648648
});
649-
const token = await getScopedToken(appCheck as AppCheckService);
649+
const token = await getLimitedUseToken(appCheck as AppCheckService);
650650

651651
expect(customProviderSpy).to.be.called;
652652
expect(token).to.deep.equal({
@@ -661,7 +661,7 @@ describe('internal api', () => {
661661
const appCheck = initializeAppCheck(app, {
662662
provider: customTokenProvider
663663
});
664-
await getScopedToken(appCheck as AppCheckService);
664+
await getLimitedUseToken(appCheck as AppCheckService);
665665

666666
expect(getStateReference(app).token).to.be.undefined;
667667
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.be.false;
@@ -680,7 +680,7 @@ describe('internal api', () => {
680680
'exchangeToken'
681681
).returns(Promise.resolve(fakeRecaptchaAppCheckToken));
682682

683-
const token = await getScopedToken(appCheck as AppCheckService);
683+
const token = await getLimitedUseToken(appCheck as AppCheckService);
684684

685685
expect(reCAPTCHASpy).to.be.called;
686686

@@ -703,7 +703,7 @@ describe('internal api', () => {
703703
'exchangeToken'
704704
).returns(Promise.resolve(fakeRecaptchaAppCheckToken));
705705

706-
const token = await getScopedToken(appCheck as AppCheckService);
706+
const token = await getLimitedUseToken(appCheck as AppCheckService);
707707

708708
expect(reCAPTCHASpy).to.be.called;
709709

@@ -726,7 +726,7 @@ describe('internal api', () => {
726726
const error = new Error('oops, something went wrong');
727727
stub(client, 'exchangeToken').returns(Promise.reject(error));
728728

729-
const token = await getScopedToken(appCheck as AppCheckService);
729+
const token = await getLimitedUseToken(appCheck as AppCheckService);
730730

731731
expect(reCAPTCHASpy).to.be.called;
732732
expect(token).to.deep.equal({
@@ -752,7 +752,7 @@ describe('internal api', () => {
752752
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY)
753753
});
754754

755-
const token = await getScopedToken(appCheck as AppCheckService);
755+
const token = await getLimitedUseToken(appCheck as AppCheckService);
756756
expect(exchangeTokenStub.args[0][0].body['debug_token']).to.equal(
757757
'my-debug-token'
758758
);
@@ -773,7 +773,7 @@ describe('internal api', () => {
773773
)
774774
);
775775

776-
const token = await getScopedToken(appCheck as AppCheckService);
776+
const token = await getLimitedUseToken(appCheck as AppCheckService);
777777

778778
// ReCaptchaV3Provider's _throttleData is private so checking
779779
// the resulting error message to be sure it has roughly the
@@ -799,7 +799,7 @@ describe('internal api', () => {
799799
)
800800
);
801801

802-
const token = await getScopedToken(appCheck as AppCheckService);
802+
const token = await getLimitedUseToken(appCheck as AppCheckService);
803803

804804
// ReCaptchaV3Provider's _throttleData is private so checking
805805
// the resulting error message to be sure it has roughly the

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export async function getToken(
210210
* The result will contain an error field if there is any error.
211211
* In case there is an error, the token field in the result will be populated with a dummy value
212212
*/
213-
export async function getScopedToken(
213+
export async function getLimitedUseToken(
214214
appCheck: AppCheckService
215215
): Promise<AppCheckTokenResult> {
216216
const app = appCheck.app;

0 commit comments

Comments
 (0)