Skip to content

feat(appcheck): create FirebaseAppCheck.tokenChanges Flow #4806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thatfiredev
Copy link
Member

Adding the Flow approved in go/kotlin-flows-firebase-android-addendum.

Note that I've used .buffer(capacity = Channel.CONFLATED) in this one to handle back-pressure. This will drop older values, which I assume are not relevant because developers might only be interested in the newest AppCheckToken emitted by the Flow.

@thatfiredev thatfiredev requested a review from rlazo March 21, 2023 12:37
@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2023

Javadoc Changes:
--- /Users/runner/diff/original/firebase-kotlindoc/kotlin/com/google/firebase/appcheck/ktx/package-summary.html	2023-03-21 12:57:53.000000000 +0000
+++ /Users/runner/diff/modified/firebase-kotlindoc/kotlin/com/google/firebase/appcheck/ktx/package-summary.html	2023-03-21 12:53:18.000000000 +0000
@@ -53,6 +53,13 @@
               <p>Returns the <code><a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.html">FirebaseAppCheck</a></code> instance of the default <code><a href="/docs/reference/kotlin/com/google/firebase/FirebaseApp.html">FirebaseApp</a></code>.</p>
             </td>
           </tr>
+          <tr>
+            <td><code><a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="/docs/reference/kotlin/com/google/firebase/appcheck/AppCheckToken.html">AppCheckToken</a>&gt;</code></td>
+            <td>
+              <div><code><a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.html">FirebaseAppCheck</a>.<a href="/docs/reference/kotlin/com/google/firebase/appcheck/ktx/package-summary.html#(com.google.firebase.appcheck.FirebaseAppCheck).tokenChanges()">tokenChanges</a></code></div>
+              <p>Registers an <code><a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.AppCheckListener.html">AppCheckListener</a></code> to changes in the token state.</p>
+            </td>
+          </tr>
         </tbody>
       </table>
     </div>
@@ -120,6 +127,12 @@
       <pre class="api-signature no-pretty-print">val&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/ktx/Firebase.html">Firebase</a>.<a href="/docs/reference/kotlin/com/google/firebase/appcheck/ktx/package-summary.html#(com.google.firebase.ktx.Firebase).appCheck()">appCheck</a>:&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.html">FirebaseAppCheck</a></pre>
       <p>Returns the <code><a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.html">FirebaseAppCheck</a></code> instance of the default <code><a href="/docs/reference/kotlin/com/google/firebase/FirebaseApp.html">FirebaseApp</a></code>.</p>
     </div>
+    <div class="api-item"><a name="(com.google.firebase.appcheck.FirebaseAppCheck).getTokenChanges()"></a><a name="(com.google.firebase.appcheck.FirebaseAppCheck).setTokenChanges()"></a><a name="-com.google.firebase.appcheck.FirebaseAppCheck-.getTokenChanges--"></a><a name="-com.google.firebase.appcheck.FirebaseAppCheck-.setTokenChanges--"></a>
+      <h3 class="api-name" id="(com.google.firebase.appcheck.FirebaseAppCheck).tokenChanges()">tokenChanges</h3>
+      <pre class="api-signature no-pretty-print">val&nbsp;<a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.html">FirebaseAppCheck</a>.<a href="/docs/reference/kotlin/com/google/firebase/appcheck/ktx/package-summary.html#(com.google.firebase.appcheck.FirebaseAppCheck).tokenChanges()">tokenChanges</a>:&nbsp;<a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="/docs/reference/kotlin/com/google/firebase/appcheck/AppCheckToken.html">AppCheckToken</a>&gt;</pre>
+      <p>Registers an <code><a href="/docs/reference/kotlin/com/google/firebase/appcheck/FirebaseAppCheck.AppCheckListener.html">AppCheckListener</a></code> to changes in the token state. This <code><a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> should be used ONLY if you need to authorize requests to a non-Firebase backend. Requests to Firebase backends are authorized automatically if configured.</p>
+      <p>Back-pressure is handled by dropping the oldest value in the buffer on overflow.</p>
+    </div>
   </body>
 </html>
 

@google-oss-bot
Copy link
Contributor

@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2023

Unit Test Results

  74 files   -      84    74 suites   - 84   4m 52s ⏱️ + 2m 36s
237 tests  -    880  237 ✔️  -    864  0 💤  - 16  0 ±0 
362 runs   - 1 872  362 ✔️  - 1 840  0 💤  - 32  0 ±0 

Results for commit 9c4553a. ± Comparison against base commit 47e7a88.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

Size Report 1

Affected Products

  • firebase-appcheck-ktx

    TypeBase (47e7a88)Merge (43f43cc)Diff
    aar5.98 kB9.17 kB+3.19 kB (+53.3%)
    apk (release)1.94 MB1.94 MB+1.08 kB (+0.1%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/AMzmnBv69Z.html

@google-oss-bot
Copy link
Contributor

Startup Time Report 1

Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS.

Notes

Startup Times

  • fire-app-check

    DeviceStatisticsDistributions
    oriole-32
    Percentile47e7a8843f43ccDiffSignificant (?)
    p10685 ±927 μs275 ±123 μs-410 μs (-59.8%)NO
    p25726 ±950 μs294 ±138 μs-432 μs (-59.5%)NO
    p50787 ±1022 μs329 ±168 μs-457 μs (-58.1%)NO
    p75912 ±1164 μs398 ±212 μs-515 μs (-56.4%)NO
    p901.03 ±1 ms529 ±327 μs-506 μs (-48.9%)NO

    20 test runs in comparison
    CommitTest Runs
    47e7a88
    • 2023-03-20_22:59:07.222837_LfDg
    • 2023-03-20_22:59:07.227049_jqpt
    • 2023-03-20_22:59:07.227079_kdqG
    • 2023-03-20_22:59:07.227095_GhhT
    • 2023-03-20_22:59:07.227103_qaZw
    • 2023-03-20_22:59:07.227116_EfAu
    • 2023-03-20_22:59:07.227302_zHFV
    • 2023-03-20_22:59:07.227312_ZrVG
    • 2023-03-20_22:59:07.227319_vAot
    • 2023-03-20_22:59:07.227327_CIfG
    43f43cc
    • 2023-03-21_12:53:31.879130_Uyam
    • 2023-03-21_12:53:31.887952_gwdT
    • 2023-03-21_12:53:31.887964_IkgE
    • 2023-03-21_12:53:31.887971_KGRe
    • 2023-03-21_12:53:31.887977_ollF
    • 2023-03-21_12:53:31.887983_wezv
    • 2023-03-21_12:53:31.887989_OgYW
    • 2023-03-21_12:53:31.888167_dFNW
    • 2023-03-21_12:53:31.888173_Fxwi
    • 2023-03-21_12:53:31.888179_teeL
    redfin-30
    Percentile47e7a8843f43ccDiffSignificant (?)
    p10938 ±1678 μs1.37 ±2 ms+427 μs (+45.5%)NO
    p251.02 ±2 ms1.50 ±2 ms+482 μs (+47.4%)NO
    p501.16 ±2 ms1.70 ±2 ms+539 μs (+46.5%)NO
    p751.39 ±2 ms1.98 ±2 ms+584 μs (+42.0%)NO
    p901.78 ±3 ms2.47 ±3 ms+681 μs (+38.2%)NO

    20 test runs in comparison
    CommitTest Runs
    47e7a88
    • 2023-03-20_22:59:07.222837_LfDg
    • 2023-03-20_22:59:07.227049_jqpt
    • 2023-03-20_22:59:07.227079_kdqG
    • 2023-03-20_22:59:07.227095_GhhT
    • 2023-03-20_22:59:07.227103_qaZw
    • 2023-03-20_22:59:07.227116_EfAu
    • 2023-03-20_22:59:07.227302_zHFV
    • 2023-03-20_22:59:07.227312_ZrVG
    • 2023-03-20_22:59:07.227319_vAot
    • 2023-03-20_22:59:07.227327_CIfG
    43f43cc
    • 2023-03-21_12:53:31.879130_Uyam
    • 2023-03-21_12:53:31.887952_gwdT
    • 2023-03-21_12:53:31.887964_IkgE
    • 2023-03-21_12:53:31.887971_KGRe
    • 2023-03-21_12:53:31.887977_ollF
    • 2023-03-21_12:53:31.887983_wezv
    • 2023-03-21_12:53:31.887989_OgYW
    • 2023-03-21_12:53:31.888167_dFNW
    • 2023-03-21_12:53:31.888173_Fxwi
    • 2023-03-21_12:53:31.888179_teeL
  • fire-gcs

    DeviceStatisticsDistributions
    oriole-32
    Percentile47e7a8843f43ccDiffSignificant (?)
    p1013.5 ±4 μs13.3 ±4 μs-214 ns (-1.6%)NO
    p2514.1 ±4 μs13.8 ±4 μs-334 ns (-2.4%)NO
    p5015.1 ±4 μs15.1 ±4 μs-51.1 ns (-0.3%)NO
    p7517.4 ±3 μs17.6 ±4 μs+229 ns (+1.3%)NO
    p9020.3 ±2 μs22.5 ±9 μs+2.24 μs (+11.0%)NO

    20 test runs in comparison
    CommitTest Runs
    47e7a88
    • 2023-03-20_22:59:07.222837_LfDg
    • 2023-03-20_22:59:07.227049_jqpt
    • 2023-03-20_22:59:07.227079_kdqG
    • 2023-03-20_22:59:07.227095_GhhT
    • 2023-03-20_22:59:07.227103_qaZw
    • 2023-03-20_22:59:07.227116_EfAu
    • 2023-03-20_22:59:07.227302_zHFV
    • 2023-03-20_22:59:07.227312_ZrVG
    • 2023-03-20_22:59:07.227319_vAot
    • 2023-03-20_22:59:07.227327_CIfG
    43f43cc
    • 2023-03-21_12:53:31.879130_Uyam
    • 2023-03-21_12:53:31.887952_gwdT
    • 2023-03-21_12:53:31.887964_IkgE
    • 2023-03-21_12:53:31.887971_KGRe
    • 2023-03-21_12:53:31.887977_ollF
    • 2023-03-21_12:53:31.887983_wezv
    • 2023-03-21_12:53:31.887989_OgYW
    • 2023-03-21_12:53:31.888167_dFNW
    • 2023-03-21_12:53:31.888173_Fxwi
    • 2023-03-21_12:53:31.888179_teeL
    redfin-30
    Percentile47e7a8843f43ccDiffSignificant (?)
    p1028.4 ±7 μs24.4 ±7 μs-3.94 μs (-13.9%)NO
    p2529.7 ±8 μs25.5 ±7 μs-4.15 μs (-14.0%)NO
    p5031.9 ±8 μs27.9 ±8 μs-3.94 μs (-12.4%)NO
    p7535.3 ±9.5 μs33.5 ±16 μs-1.87 μs (-5.3%)NO
    p9046.2 ±22 μs41.2 ±21 μs-5.06 μs (-10.9%)NO

    20 test runs in comparison
    CommitTest Runs
    47e7a88
    • 2023-03-20_22:59:07.222837_LfDg
    • 2023-03-20_22:59:07.227049_jqpt
    • 2023-03-20_22:59:07.227079_kdqG
    • 2023-03-20_22:59:07.227095_GhhT
    • 2023-03-20_22:59:07.227103_qaZw
    • 2023-03-20_22:59:07.227116_EfAu
    • 2023-03-20_22:59:07.227302_zHFV
    • 2023-03-20_22:59:07.227312_ZrVG
    • 2023-03-20_22:59:07.227319_vAot
    • 2023-03-20_22:59:07.227327_CIfG
    43f43cc
    • 2023-03-21_12:53:31.879130_Uyam
    • 2023-03-21_12:53:31.887952_gwdT
    • 2023-03-21_12:53:31.887964_IkgE
    • 2023-03-21_12:53:31.887971_KGRe
    • 2023-03-21_12:53:31.887977_ollF
    • 2023-03-21_12:53:31.887983_wezv
    • 2023-03-21_12:53:31.887989_OgYW
    • 2023-03-21_12:53:31.888167_dFNW
    • 2023-03-21_12:53:31.888173_Fxwi
    • 2023-03-21_12:53:31.888179_teeL
  • timeToInitialDisplay

    DeviceStatisticsDistributions
    oriole-32
    Percentile47e7a8843f43ccDiffSignificant (?)
    p10189 ±2 ms198 ±12 ms+8.84 ms (+4.7%)NO
    p25195 ±3 ms204 ±14 ms+9.81 ms (+5.0%)NO
    p50202 ±3 ms215 ±22 ms+12.6 ms (+6.2%)NO
    p75209 ±3 ms225 ±27 ms+15.6 ms (+7.4%)NO
    p90217 ±4 ms236 ±30 ms+19.8 ms (+9.2%)NO

    20 test runs in comparison
    CommitTest Runs
    47e7a88
    • 2023-03-20_22:59:07.222837_LfDg
    • 2023-03-20_22:59:07.227049_jqpt
    • 2023-03-20_22:59:07.227079_kdqG
    • 2023-03-20_22:59:07.227095_GhhT
    • 2023-03-20_22:59:07.227103_qaZw
    • 2023-03-20_22:59:07.227116_EfAu
    • 2023-03-20_22:59:07.227302_zHFV
    • 2023-03-20_22:59:07.227312_ZrVG
    • 2023-03-20_22:59:07.227319_vAot
    • 2023-03-20_22:59:07.227327_CIfG
    43f43cc
    • 2023-03-21_12:53:31.879130_Uyam
    • 2023-03-21_12:53:31.887952_gwdT
    • 2023-03-21_12:53:31.887964_IkgE
    • 2023-03-21_12:53:31.887971_KGRe
    • 2023-03-21_12:53:31.887977_ollF
    • 2023-03-21_12:53:31.887983_wezv
    • 2023-03-21_12:53:31.887989_OgYW
    • 2023-03-21_12:53:31.888167_dFNW
    • 2023-03-21_12:53:31.888173_Fxwi
    • 2023-03-21_12:53:31.888179_teeL
    redfin-30
    Percentile47e7a8843f43ccDiffSignificant (?)
    p10233 ±13 ms254 ±3 ms+21.1 ms (+9.1%)NO
    p25240 ±14 ms260 ±3 ms+19.9 ms (+8.3%)NO
    p50247 ±16 ms267 ±3 ms+20.8 ms (+8.4%)NO
    p75259 ±28 ms277 ±5 ms+17.9 ms (+6.9%)NO
    p90270 ±31 ms291 ±6 ms+20.8 ms (+7.7%)NO

    20 test runs in comparison
    CommitTest Runs
    47e7a88
    • 2023-03-20_22:59:07.222837_LfDg
    • 2023-03-20_22:59:07.227049_jqpt
    • 2023-03-20_22:59:07.227079_kdqG
    • 2023-03-20_22:59:07.227095_GhhT
    • 2023-03-20_22:59:07.227103_qaZw
    • 2023-03-20_22:59:07.227116_EfAu
    • 2023-03-20_22:59:07.227302_zHFV
    • 2023-03-20_22:59:07.227312_ZrVG
    • 2023-03-20_22:59:07.227319_vAot
    • 2023-03-20_22:59:07.227327_CIfG
    43f43cc
    • 2023-03-21_12:53:31.879130_Uyam
    • 2023-03-21_12:53:31.887952_gwdT
    • 2023-03-21_12:53:31.887964_IkgE
    • 2023-03-21_12:53:31.887971_KGRe
    • 2023-03-21_12:53:31.887977_ollF
    • 2023-03-21_12:53:31.887983_wezv
    • 2023-03-21_12:53:31.887989_OgYW
    • 2023-03-21_12:53:31.888167_dFNW
    • 2023-03-21_12:53:31.888173_Fxwi
    • 2023-03-21_12:53:31.888179_teeL

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/SkaAAdYMW0/index.html

Copy link
Collaborator

@rlazo rlazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you plan to merge it now, it has to be done also in non-ktx version of the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants