cryptomator / hub

Cryptomator Hub helps you manage vaults in large teams
GNU Affero General Public License v3.0
36 stars 8 forks source link

error TS18048: 'browserKeys' is possibly 'undefined'. #244

Closed chenkins closed 5 months ago

chenkins commented 7 months ago

Please agree to the following

Summary

error TS18048: 'browserKeys' is possibly 'undefined'.

System Setup

- Hub: 1.3.0-beta-1

Steps to Reproduce

git checkout 1.3.0-beta1
npm run build     

Expected Behavior

No errors error TS18048: 'browserKeys' is possibly 'undefined'.

Actual Behavior

Multiple such errors.

Reproducibility

Always

Relevant Log Output

src/components/DeviceList.vue:127:27 - error TS18048: 'browserKeys' is possibly 'undefined'.

127   const browserId = await browserKeys.id();
                              ~~~~~~~~~~~

src/components/ManageSetupCode.vue:78:29 - error TS18048: 'browserKeys' is possibly 'undefined'.

78     const browserId = await browserKeys.id();
                               ~~~~~~~~~~~

src/components/ManageSetupCode.vue:83:79 - error TS18048: 'browserKeys' is possibly 'undefined'.

83     const userKeys = await UserKeys.decryptOnBrowser(myDevice.userPrivateKey, browserKeys.keyPair.privateKey, base64.parse(me.publicKey));
                                                                                 ~~~~~~~~~~~

src/components/RegenerateSetupCodeDialog.vue:159:29 - error TS18048: 'browserKeys' is possibly 'undefined'.

159     const browserId = await browserKeys.id();
                                ~~~~~~~~~~~

src/components/RegenerateSetupCodeDialog.vue:165:79 - error TS18048: 'browserKeys' is possibly 'undefined'.

165     const userKeys = await UserKeys.decryptOnBrowser(myDevice.userPrivateKey, browserKeys.keyPair.privateKey, base64.parse(me.publicKey));
                                                                                  ~~~~~~~~~~~

src/components/VaultDetails.vue:285:27 - error TS18048: 'browserKeys' is possibly 'undefined'.

285   const browserId = await browserKeys.id();
                              ~~~~~~~~~~~

src/components/VaultDetails.vue:290:77 - error TS18048: 'browserKeys' is possibly 'undefined'.

290   const userKeys = await UserKeys.decryptOnBrowser(myDevice.userPrivateKey, browserKeys.keyPair.privateKey, base64.parse(me.value.publicKey));

Anything else?

Rather imperfection/enhancement than bug. Introduced in 36fcf97bd7403cb0d22aff8f2ec2da6ce29f288b

chenkins commented 7 months ago

Re-enabling vue-tsc --noEmit in ci would be great, see #22.

overheadhunter commented 7 months ago

Right, we changed the contract of BrowserKeys.load(...) to return an optional value. It works, as the affected pages can not be visited without a browser key, but the code needs to check this defensively anyway.

Thanks for reporting!

tobihagemann commented 5 months ago

Fixed in d0c3d47b8848155823f3eb174c16632f5a93eac6.