@@ -1274,6 +1274,8 @@ declare namespace firebase {
1274
1274
* If not passed, uses the default app.
1275
1275
*/
1276
1276
function analytics ( app ?: firebase . app . App ) : firebase . analytics . Analytics ;
1277
+
1278
+ function appCheck ( app ?: firebase . app . App ) : firebase . appCheck . AppCheck ;
1277
1279
}
1278
1280
1279
1281
declare namespace firebase . app {
@@ -1471,6 +1473,123 @@ declare namespace firebase.app {
1471
1473
* ```
1472
1474
*/
1473
1475
analytics ( ) : firebase . analytics . Analytics ;
1476
+ appCheck ( ) : firebase . appCheck . AppCheck ;
1477
+ }
1478
+ }
1479
+
1480
+ declare namespace firebase . appCheck {
1481
+ /**
1482
+ * Result returned by
1483
+ * {@link firebase.appCheck.AppCheck.getToken `firebase.appCheck().getToken()`}.
1484
+ */
1485
+ interface AppCheckTokenResult {
1486
+ token : string ;
1487
+ }
1488
+ /**
1489
+ * The Firebase AppCheck service interface.
1490
+ *
1491
+ * Do not call this constructor directly. Instead, use
1492
+ * {@link firebase.appCheck `firebase.appCheck()`}.
1493
+ */
1494
+ export interface AppCheck {
1495
+ /**
1496
+ * Activate AppCheck
1497
+ * @param siteKeyOrProvider reCAPTCHA v3 site key (public key) or
1498
+ * custom token provider.
1499
+ * @param isTokenAutoRefreshEnabled If true, the SDK automatically
1500
+ * refreshes App Check tokens as needed. If undefined, defaults to the
1501
+ * value of `app.automaticDataCollectionEnabled`, which defaults to
1502
+ * false and can be set in the app config.
1503
+ */
1504
+ activate (
1505
+ siteKeyOrProvider : string | AppCheckProvider ,
1506
+ isTokenAutoRefreshEnabled ?: boolean
1507
+ ) : void ;
1508
+
1509
+ /**
1510
+ *
1511
+ * @param isTokenAutoRefreshEnabled If true, the SDK automatically
1512
+ * refreshes App Check tokens as needed. This overrides any value set
1513
+ * during `activate()`.
1514
+ */
1515
+ setTokenAutoRefreshEnabled ( isTokenAutoRefreshEnabled : boolean ) : void ;
1516
+ /**
1517
+ * Get the current App Check token. Attaches to the most recent
1518
+ * in-flight request if one is present. Returns null if no token
1519
+ * is present and no token requests are in-flight.
1520
+ *
1521
+ * @param forceRefresh - If true, will always try to fetch a fresh token.
1522
+ * If false, will use a cached token if found in storage.
1523
+ */
1524
+ getToken (
1525
+ forceRefresh ?: boolean
1526
+ ) : Promise < firebase . appCheck . AppCheckTokenResult > ;
1527
+
1528
+ /**
1529
+ * Registers a listener to changes in the token state. There can be more
1530
+ * than one listener registered at the same time for one or more
1531
+ * App Check instances. The listeners call back on the UI thread whenever
1532
+ * the current token associated with this App Check instance changes.
1533
+ *
1534
+ * @param observer An object with `next`, `error`, and `complete`
1535
+ * properties. `next` is called with an
1536
+ * {@link firebase.appCheck.AppCheckTokenResult `AppCheckTokenResult`}
1537
+ * whenever the token changes. `error` is optional and is called if an
1538
+ * error is thrown by the listener (the `next` function). `complete`
1539
+ * is unused, as the token stream is unending.
1540
+ *
1541
+ * @returns A function that unsubscribes this listener.
1542
+ */
1543
+ onTokenChanged ( observer : {
1544
+ next : ( tokenResult : firebase . appCheck . AppCheckTokenResult ) => void ;
1545
+ error ?: ( error : Error ) => void ;
1546
+ complete ?: ( ) => void ;
1547
+ } ) : Unsubscribe ;
1548
+
1549
+ /**
1550
+ * Registers a listener to changes in the token state. There can be more
1551
+ * than one listener registered at the same time for one or more
1552
+ * App Check instances. The listeners call back on the UI thread whenever
1553
+ * the current token associated with this App Check instance changes.
1554
+ *
1555
+ * @param onNext When the token changes, this function is called with aa
1556
+ * {@link firebase.appCheck.AppCheckTokenResult `AppCheckTokenResult`}.
1557
+ * @param onError Optional. Called if there is an error thrown by the
1558
+ * listener (the `onNext` function).
1559
+ * @param onCompletion Currently unused, as the token stream is unending.
1560
+ * @returns A function that unsubscribes this listener.
1561
+ */
1562
+ onTokenChanged (
1563
+ onNext : ( tokenResult : firebase . appCheck . AppCheckTokenResult ) => void ,
1564
+ onError ?: ( error : Error ) => void ,
1565
+ onCompletion ?: ( ) => void
1566
+ ) : Unsubscribe ;
1567
+ }
1568
+
1569
+ /**
1570
+ * An App Check provider. This can be either the built-in reCAPTCHA
1571
+ * provider or a custom provider. For more on custom providers, see
1572
+ * https://firebase.google.com/docs/app-check/web-custom-provider
1573
+ */
1574
+ interface AppCheckProvider {
1575
+ /**
1576
+ * Returns an AppCheck token.
1577
+ */
1578
+ getToken ( ) : Promise < AppCheckToken > ;
1579
+ }
1580
+
1581
+ /**
1582
+ * The token returned from an {@link firebase.appCheck.AppCheckProvider `AppCheckProvider`}.
1583
+ */
1584
+ interface AppCheckToken {
1585
+ /**
1586
+ * The token string in JWT format.
1587
+ */
1588
+ readonly token : string ;
1589
+ /**
1590
+ * The local timestamp after which the token will expire.
1591
+ */
1592
+ readonly expireTimeMillis : number ;
1474
1593
}
1475
1594
}
1476
1595
@@ -4419,7 +4538,8 @@ declare namespace firebase.auth {
4419
4538
* @hidden
4420
4539
*/
4421
4540
class RecaptchaVerifier_Instance
4422
- implements firebase . auth . ApplicationVerifier {
4541
+ implements firebase . auth . ApplicationVerifier
4542
+ {
4423
4543
constructor (
4424
4544
container : any | string ,
4425
4545
parameters ?: Object | null ,
0 commit comments