Skip to content
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

Uncaught (in promise) TypeError: client.store.getSavedSyncToken is not a function #1608

Closed
niwla23 opened this issue Feb 17, 2021 · 10 comments
Closed

Comments

@niwla23
Copy link

niwla23 commented Feb 17, 2021

    let opts = {
      localStorage: window.localStorage,
      indexedDB: window.indexedDB,
    }
    let store = new sdk.IndexedDBStore(opts)
    let cryptoStore = new sdk.IndexedDBCryptoStore(window.indexedDB, "cryptostuff")
    await store.startup() // load from indexed db
    await cryptoStore.startup()
    const client = sdk.createClient({
      store: cryptoStore,
      baseUrl: 'https://matrix.example.click',
    })
    client.startClient()
    client.publicRooms(function (err2, data2) {
      console.log('Public Rooms: %s', JSON.stringify(data2))
    })

I do login the client like this:

      let opts = {
        localStorage: window.localStorage,
        indexedDB: window.indexedDB,
      }
      let store = new sdk.IndexedDBStore(opts)
      await store.startup() // load from indexed db
      const client = sdk.createClient({
        store: store,
        cryptoStore: store,
        baseUrl: 'https://matrix.example.click',
      })
      await client.startClient()

      try {
        var data = await client.loginWithPassword(this.mxid, this.password)
        this.loading = false
        console.log(data)
      } catch {
        console.log('error')
        this.loading = false
        this.loginError = true
      }

But when I reload the page, this error gets printed:
Uncaught (in promise) TypeError: client.store.getSavedSyncToken is not a function

@t3chguy
Copy link
Member

t3chguy commented Feb 17, 2021

So in your first snippet you do the right thing and instantiate a store and a cryptoStore.
In your second you pass a store as both a store and a cryptoStore

For just logging in you do not need a cryptoStore.

Heck you do not need a cryptoStore if you are not going to run startCrypto.

@niwla23
Copy link
Author

niwla23 commented Feb 17, 2021

So a crypto store is for e2e encryption?

@t3chguy
Copy link
Member

t3chguy commented Feb 17, 2021

Yes. crypto being short for cryptography

@niwla23
Copy link
Author

niwla23 commented Feb 17, 2021

    let store = new sdk.IndexedDBStore({ indexedDB: window.indexedDB })
    await store.startup() // load from indexed db

    const client = sdk.createClient({
      store: store,
      baseUrl: 'https://matrix.cloudserver.click',
    })

    client.startClient()

So I have this now in the vue mounted function, but it makes unauthenticated calls:
grafik

@t3chguy
Copy link
Member

t3chguy commented Feb 17, 2021

The stores don't store your credentials, that is up to the application layer.
You have to pass them in as baseUrl, userId, accessToken etc.

@niwla23
Copy link
Author

niwla23 commented Feb 18, 2021

so the concept is to let the user login with id and password, then store the accessToken (never expiring?) in localstorage or something and then login with that accessToken on Startup? And the store will contain the rooms and all that stuff?

@t3chguy
Copy link
Member

t3chguy commented Feb 18, 2021

Precisely

@niwla23
Copy link
Author

niwla23 commented Feb 18, 2021

thank you

@jryans
Copy link
Collaborator

jryans commented Feb 27, 2021

Is there a bug to fix here? If so, what is it?

@jryans
Copy link
Collaborator

jryans commented Feb 27, 2021

My impression from the linked issue is that the situation has been resolved. I recommend asking similar questions in rooms like #matrix-dev:matrix.org or similar.

@jryans jryans closed this as completed Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants