Mapify javascript SDK
npm install @mapify/sdkThe Mapify JS SDK library is a wrapper for the Mapify APIs, such as the Authorization API, allowing you to develop your Location Intelligence application and services using the javascript programming languages.
Mapify is a Location Intelligence Platform to prototype and develop large scalable enterprise solutions. It aggregates data from IOT sensing devices, modern and legacy information systems, enriching its value through location intelligence and machine learning layers to assist human decision on every imaginable use case while allowing virtually infinite platform extensibility.
* Website
* Privacy Policy
* Terms of Use
* NodeJS >= 11.1.0
* A Mapify account
Via npm
``bash`
npm install @mapify/sdk
Via yarn.
`bash`
yarn add @mapify/sdk
`typescript@mapify/sdk
const { AuthenticationClient } = require()`
const authenticationClient = new AuthenticationClient({
publicKey: "/path/to/key.pub"
})
Note: Before you sign an Api Key, you must create one on Mapify Console
`js@mapify/sdk
const { AuthenticationClient, Token } = require()
const authenticationClient = new AuthenticationClient()
try{
const authorization = await authenticationClient.sign('apikey')
// Authentication token
authorization.authenticationToken
// Refresh token
authorization.refreshToken
// Authentication token expire date (UTC in seconds)
authorization.expires
// Decoded payload
tokenPayload = authenticationClient.decode(authorization.authenticationToken)
tokenPayload.apis //the apis
tokenPayload.payload //the custom payload
// List of Claims
const decodedToken = new Token(tokenPayload)
claims = token.getClaimsByApi('api')
}catch(e){
// * HTTPException its thrown wherever is a problem with a Sign.`
}
`js@mapify/sdk
const { AuthenticationClient } = require()
const authenticationClient = new AuthenticationClient()
try{
const customPayload = {
example: "example"
}
const token = await authenticationClient.sign('apikey', customPayload)
}catch(e){
// * HTTPException its thrown wherever is a problem with a Sign.`
}
`js@mapify/sdk
const { Handler, AuthenticationClient } = require()
class AuthenticationHandler implements Handler {
construct(private readonly username, private readonly password) { }
execute(payload) {
return {
...payload,
basic_auth: new Buffer(${this.username}:${this.password}).toString('base64')
};
}
}
const authenticationClient = new AuthenticationClient()
authenticationClient.withHandler(new AuthenticationHandler(user, password))
try{
const authorization = await authenticationClient.sign('apikey')
// authorization code
}catch(e){
// * HTTPException its thrown wherever is a problem with a Sign.`
}
`js@mapify/sdk
const fs = require('fs')
const { Handler, AuthenticationClient } = require()${__dirname}/key.pub
const authenticationClient = new AuthenticationClient({
publicKey: fs.readFileSync(, { encoding: 'utf8' })
})
try{
const isValid = authenticationClient.verify(token)TokenExpiredError
}catch(e){
// * Token is expiredInvalidToken
// * Token is invalid with he public key
}
// Decode payload
tokenPayload = authenticationClient.decode(token)
tokenPayload.apis //the apis
tokenPayload.payload //the custom payload
// List of Claims
const decodedToken = new Token(tokenPayload)
claims = token.getClaimsByApi('api')
`
##### OR
`js@mapify/sdk
const fs = require('fs')
const { AuthenticationClient } = require()
try{
const isValid = AuthenticationClient.verify(token, fs.readFileSync(${__dirname}/key.pub, { encoding: 'utf8' }))TokenExpiredError
}catch(e){
// * Token is expiredInvalidToken
// * Token is invalid with he public key`
}
`js@mapify/sdk
const { AuthenticationClient } = require()
try{
const authenticationClient = new AuthenticationClient()
const authorization = await authenticationClient.refresh(refreshToken)
}catch(e){
// * HTTPException its thrown wherever is a problem with a Sign.`
}
This library throws exceptions to indicate problems:
* HTTPException its thrown wherever is a problem with a Sign.TokenExpiredError
* Token is expiredInvalidToken
* Token is invalid with he public key
bash
npm test
`
$3
`bash
yarn install && yarn build && yarn test
`
$3
`sh
docker build . -t mapify-js-sdk && \
docker run -it mapify-js-sdk sh -c "yarn test"
``Please follow our contributor guide
This project is licensed under the terms of the Apache License Version 2.0, January 2004.