zerobias / telegram-mtproto

Telegram client api (MTProto) library
MIT License
617 stars 136 forks source link

Saving auth data in localstorage #227

Closed AaronPorts closed 5 years ago

AaronPorts commented 5 years ago

I'm trying to reuse auth data from browser localstorage using mtproto-storage-browser and localforage, but I get AUTH_KEY_UNREGISTERED error after any api call. Checked on all 3.2.* versions.

const api = {
  layer: 57,
  initConnection: 0x69796de9,
  api_id: 123456,
};
const server = {
  dev: false,
  webogram: true,
};
const id = JSON.parse(localStorage.getItem(`localforage/dc2_auth_id`));
const key = JSON.parse(localStorage.getItem(`localforage/dc2_auth_key`));
const salt = JSON.parse(localStorage.getItem(`localforage/dc2_server_salt`));
const app = {
  debug: true,
  storage: new BrowserStorage(
    localforage.createInstance({
      dc2_auth_id: id,
      dc2_auth_key: key,
      dc2_server_salt: salt,
    }),
  ),
};
const client = MTProto({ server, api, app });

Does anyone faced similar problem?

AaronPorts commented 5 years ago

It seems like 3.2.6 works fine despite these errors. image