matrix-org / matrix-js-sdk

Matrix Client-Server SDK for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error uploading one-time keys TypeError: account.unpublished_fallback_key is not a function

nahakiole opened this issue · comments

Describe the bug
A undocumented error called Error uploading one-time keys TypeError: account.unpublished_fallback_key is not a function is printed in the console, when using loginWithPassword or using an access token to login.

To Reproduce
Steps to reproduce the behavior:

  1. Setup matrix-js-sdk for Encryption
  2. Try to login via password and username
this.client.loginWithPassword(username, password, (err, res) => {
    this.client.initCrypto().then(() => {
        this.client.startClient({});
    })
});
logger.js:57 Error uploading one-time keys TypeError: account.unpublished_fallback_key is not a function
    at http://localhost:4200/vendor.js:61196:39
    at http://localhost:4200/vendor.js:60952:9
    at LocalStorageCryptoStore.getAccount (http://localhost:4200/vendor.js:74620:5)
    at OlmDevice.getAccount (http://localhost:4200/vendor.js:60947:22)
    at http://localhost:4200/vendor.js:61195:16
    at LocalStorageCryptoStore.doTxn (http://localhost:4200/vendor.js:74646:28)
    at http://localhost:4200/vendor.js:61194:32
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (http://localhost:4200/vendor.js:107143:24)
    at _next (http://localhost:4200/vendor.js:107165:9)

Expected behavior
I would expect the encryption to work and be better documented? It's not clear how I could add/generate key according to the implementation guide (https://matrix.org/docs/guides/end-to-end-encryption-implementation-guide) after logging in, similar to the element client, where you can import keys after logging in.

The example in the repository doesn't address this issue:
https://github.com/matrix-org/matrix-js-sdk/blob/develop/examples/crypto-browser/olm-device-export-import.js

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser Chrome
  • Version 96.0.4664.110

Update to latest olm.

I'm using the one specified in the readme:

yarn add https://packages.matrix.org/npm/olm/olm-3.1.4.tgz (replace the URL with the latest version you want to use from https://packages.matrix.org/npm/olm/)
global.Olm = require('olm'); before loading matrix-js-sdk.

So I should be using 3.2.1? If so I can create a pull request updating the readme.

I'm now using 3.2.1 and I still get the same error.

You probably need 3.2.8

In the provided link it only provides up to 3.2.1 https://packages.matrix.org/npm/olm/

How do I use the newer one? I have the same issue.

commented

You can use the olm.wasm from the latest element-web build (https://github.com/vector-im/element-web/releases/tag/v1.9.9-rc.1, asset: element-v1.9.9-rc.1.tar.gz -> see file olm.cccfd1d.wasm).

Rename olm.cccfd1d.wasm to olm.wasm to use it with the latest matrix-js-sdk.

Hey.. I am not sure if you fixed your problem, but I was having a lot of issues to understand the e2ee in matrix as well.
I tried to created a REPO to help people by adding some small documentation and some utility functions in it.

I don't know if it will help you, but here's the link
https://github.com/hmendes00/matrix-js-sdk-e2ee-helpers

If you want to contribute to it with more knowledge, please feel free to do so.

UPDATE: Just noticed it was you @nahakiole :) I'm almost done with the setup of the public repo.