Skip to content

Commit 7812a9d

Browse files
committed
PR feedback, docs
1 parent 763a5ab commit 7812a9d

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

.changeset/wicked-tomatoes-smoke.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
"@firebase/app-check": minor
3-
"@firebase/app": minor
3+
"firebase": minor
44
---
55

66
Add new limited use token method to App Check

common/api-review/app-check.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface CustomProviderOptions {
6161
}
6262

6363
// @public
64-
export function getScopedToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
64+
export function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
6565

6666
// @public
6767
export function getToken(appCheckInstance: AppCheck, forceRefresh?: boolean): Promise<AppCheckTokenResult>;

docs-devsite/app-check.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Firebase App Check
1919
| <b>function(app...)</b> |
2020
| [initializeAppCheck(app, options)](./app-check.md#initializeappcheck) | Activate App Check for the given app. Can be called only once per app. |
2121
| <b>function(appCheckInstance...)</b> |
22+
| [getLimitedUseToken(appCheckInstance)](./app-check.md#getlimitedusetoken) | Requests a Firebase App Check token. This method should be used \*only\* if you need to authorize requests to a non-Firebase backend.<!-- -->Returns limited-use tokens that are intended for use with your non-Firebase backend endpoints that are protected with <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection"> Replay Protection</a>. This method does not affect the token generation behavior of the \#getAppCheckToken() method. |
2223
| [getToken(appCheckInstance, forceRefresh)](./app-check.md#gettoken) | Get the current App Check token. Attaches to the most recent in-flight request if one is present. Returns null if no token is present and no token requests are in-flight. |
2324
| [onTokenChanged(appCheckInstance, observer)](./app-check.md#ontokenchanged) | Registers a listener to changes in the token state. There can be more than one listener registered at the same time for one or more App Check instances. The listeners call back on the UI thread whenever the current token associated with this App Check instance changes. |
2425
| [onTokenChanged(appCheckInstance, onNext, onError, onCompletion)](./app-check.md#ontokenchanged) | Registers a listener to changes in the token state. There can be more than one listener registered at the same time for one or more App Check instances. The listeners call back on the UI thread whenever the current token associated with this App Check instance changes. |
@@ -69,6 +70,30 @@ export declare function initializeAppCheck(app: FirebaseApp | undefined, options
6970

7071
[AppCheck](./app-check.appcheck.md#appcheck_interface)
7172

73+
## getLimitedUseToken()
74+
75+
Requests a Firebase App Check token. This method should be used \*only\* if you need to authorize requests to a non-Firebase backend.
76+
77+
Returns limited-use tokens that are intended for use with your non-Firebase backend endpoints that are protected with <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection"> Replay Protection</a>. This method does not affect the token generation behavior of the \#getAppCheckToken() method.
78+
79+
<b>Signature:</b>
80+
81+
```typescript
82+
export declare function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
83+
```
84+
85+
### Parameters
86+
87+
| Parameter | Type | Description |
88+
| --- | --- | --- |
89+
| appCheckInstance | [AppCheck](./app-check.appcheck.md#appcheck_interface) | The App Check service instance. |
90+
91+
<b>Returns:</b>
92+
93+
Promise&lt;[AppCheckTokenResult](./app-check.appchecktokenresult.md#appchecktokenresult_interface)<!-- -->&gt;
94+
95+
The limited use token.
96+
7297
## getToken()
7398

7499
Get the current App Check token. Attaches to the most recent in-flight request if one is present. Returns null if no token is present and no token requests are in-flight.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ describe('api', () => {
301301
it('getLimitedUseToken() throws errors returned with token', async () => {
302302
const app = getFakeApp({ automaticDataCollectionEnabled: true });
303303
const appCheck = getFakeAppCheck(app);
304-
// If getLimitedUseToken() errors, it returns a dummy token with an error field
305-
// instead of throwing.
304+
// If the internal getToken() errors, it returns a dummy token
305+
// with an error field instead of throwing.
306306
stub(internalApi, 'getToken').resolves({
307307
token: 'a-dummy-token',
308308
error: Error('there was an error')

packages/app-check/src/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ export async function getToken(
215215
*
216216
* Returns limited-use tokens that are intended for use with your
217217
* non-Firebase backend endpoints that are protected with
218-
* <a href=[--URL to public docs--]>Replay Protection</a>. This method
218+
* <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
219+
* Replay Protection</a>. This method
219220
* does not affect the token generation behavior of the
220221
* #getAppCheckToken() method.
221222
*

0 commit comments

Comments
 (0)