A JavaScript compatible ipTIME router controllable interface library.
Note that I build this library with following router:
ax3004i
(EFM ipTIME ax3004ITL)You can install this library from NPM and GitHub. Note that we only provide ESM version.
# From NPM
npm install --save iniptime
## using Yarn
yarn add iniptime
# From GitHub
yarn add https://github.com/seia-soto/iniptime
Note that TypeDoc is following master
branch of this repository, to match version:
git clone https://github.com/seia-soto/iniptime
# After moving to a branch or tag, run:
cd iniptime && yarn && yarn build:docs && yarn dlx serve docs
For authentication before using the library, please see authentication section.
We're currently supporting following features:
auth.getLoginToken
)auth.getCaptchaImage
)auth.getLoginOptions
, auth.getCaptchaOptions
)router.getBriefing
)router.getStatus
)router.network.getConfiguration
)router.network.getConnectedMacAddresses
)router.network.getWlanConfiguration
, router.network.getWlanOptions
)router.network.getWpsStatus
, router.network.setWpsStatus
)router.firmware.getStatus
)router.firmware.getRemoteStatus
, router.firmware.upgrade
)ipTIME routers support two authentication method: HTTP Basic Auth
and Session
.
You can extend default got
instance from iniptime.defaults
module to apply router username and password.
import { defaults } from 'iniptime'
const instance = defaults.instance.extend({
username: '',
password: ''
})
iniptime
supports session authentication with got
and tough-cookie
library.
Session with default credentials
import { CookieJar } from 'tough-cookie'
import { auth, defaults } from 'iniptime'
const cookieJar = new CookieJar()
const instance = defaults.instance.extend({
cookieJar
})
const loginOptions = await auth.getLoginOptions(instance)
// Update session cookie with `auth.setSessionToken`.
await auth.setSessionToken(
cookieJar,
await auth.getLoginToken(instance) // Use default option for token generation.
)
Session with username and password
import { CookieJar } from 'tough-cookie'
import { auth, defaults } from 'iniptime'
const cookieJar = new CookieJar()
const instance = defaults.instance.extend({
cookieJar
})
const loginOptions = await auth.getLoginOptions(instance)
// Update session cookie with `auth.setSessionToken`.
await auth.setSessionToken(
cookieJar,
await auth.getLoginToken(instance, {
initStatus: loginOptions.initStatus,
username: 'username',
password: 'password',
defaultPassword: loginOptions.defaultPassword
})
)
Session with captcha
import { CookieJar } from 'tough-cookie'
import { auth, defaults } from 'iniptime'
const cookieJar = new CookieJar()
const instance = defaults.instance.extend({
cookieJar
})
const loginOptions = await auth.getLoginOptions(instance)
if (!loginOptions.isCaptchaEnabled) {
throw new Error('Captcha is not enabled!')
}
// Get image URL from the router.
const {
token,
imageURL // /captcha/TOKEN.gif
} = await auth.getCaptchaImage(instance)
// Update session cookie with `auth.setSessionToken`.
await auth.setSessionToken(
cookieJar,
await auth.getLoginToken(instance, {
initStatus: loginOptions.initStatus,
username: 'username',
password: 'password',
defaultPassword: loginOptions.defaultPassword,
// Provide captcha information.
captcha: {
token,
code: '' // Put solved captcha-code here.
}
})
)
I am not associated with EFM networks or any firms while building this library.
MIT License Copyright 2021 HoJeong Go
Permission is hereby granted, free of
charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice
(including the next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Generated using TypeDoc