airgram / airgram-js-example

Basic usage Airgram with JavaScript
GNU General Public License v3.0
13 stars 7 forks source link

Error: Type "continue" is not supported #2

Open AshwinTayson opened 5 years ago

AshwinTayson commented 5 years ago

OS: Ubuntu 18.04 Node: 8.15.1

require('reflect-metadata')

const inversify = require('inversify')
const {Airgram, AuthDialog, TYPES} = require('airgram')
const {prompt, getCalleeName} = require('airgram/helpers')
const {DebugLogger} = require('airgram-debug')
const {createCollection} = require('./pouchdb')
const PouchDBStore = require('./PouchDBStore')

const airgram = new Airgram({id: "ID", hash: "HASH"})

// Logger
airgram.bind(TYPES.Logger).to(DebugLogger).onActivation((context, logger) => {
  logger.namespace = [getCalleeName(context)]
  logger.level = 'verbose'
  return logger
})

// Mount PouchDB store
const collection = createCollection('airgram')

function mountCollection (context, store) {
  store.collection = collection
  return store
}

inversify.decorate(inversify.injectable(), PouchDBStore)
airgram.bind(TYPES.AuthStore).to(PouchDBStore).onActivation(mountCollection)
airgram.bind(TYPES.MtpStateStore).to(PouchDBStore).onActivation(mountCollection)

// Authorization
airgram.use(airgram.auth)

airgram.auth.use(new AuthDialog({
  samePhoneNumber: () => false,
  phoneNumber: () => process.env.PHONE_NUMBER || prompt(`Please enter your phone number:\n`),
  code: () => prompt(`Please enter the secret code:\n`)
}))

// Updates
airgram.use(airgram.updates)

airgram.updates.use(({update}, next) => {
  console.log(`"${update._}" ${JSON.stringify(update)}`)
  return next()
})

airgram.auth.login().then(async () => {
  // Start long polling
  await airgram.updates.startPolling()

  // Get dialogs list
  const dialogs = await airgram.client.messages.getDialogs({
    limit: 30,
    offset_date: 0,
    offset_id: 0,
    offset_peer: {_: 'inputPeerEmpty'}
  })

  console.log(dialogs)
})

(node:2089) UnhandledPromiseRejectionWarning: TypeError: (intermediate value)(intermediate value)(intermediate value).finally is not a function at Auth.forceLogin (/home/ubuntu/dash/node_modules/airgram/base/Auth.js:476:112) at /home/ubuntu/dash/node_modules/airgram/base/Auth.js:203:26 at at process._tickCallback (internal/process/next_tick.js:189:7) (node:2089) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:2089) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Please enter your phone number:

Once I enter the phone number, it throws the following error

(node:2037) UnhandledPromiseRejectionWarning: Error: Type "continue" is not supported at AuthDialog. (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:93:23) at step (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:43:23) at Object.next (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:24:53) at /home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:18:71 at new Promise () at __awaiter (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:14:12) at AuthDialog.prompt (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:88:16) at AuthDialog. (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:79:51) at step (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:43:23) at Object.next (/home/ubuntu/dash/node_modules/airgram/components/AuthDialog.js:24:53) (node:2037) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

esindger commented 5 years ago

Please check out the last version.