npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mapify/sdk

v0.0.34

Published

Mapify javascript SDK

Downloads

2

Readme

Mapify JS SDK

The 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.

Build Status

Mapify Platform

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.

Requirements

Installing

Via npm

npm install @mapify/sdk

Via yarn.

yarn add @mapify/sdk

Basic usage examples

Instantiate Authentication Client

const { AuthenticationClient } = require(`@mapify/sdk`)
const authenticationClient = new AuthenticationClient({
    publicKey: "/path/to/key.pub"
})

Sign with a API key

Note: Before you sign an Api Key, you must create one on Mapify Console

const { AuthenticationClient, Token } = require(`@mapify/sdk`)
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.
}

Sign with a API key and a custom payload

const { AuthenticationClient } = require(`@mapify/sdk`)
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.
}

Sign with a API key and a Handler

const { Handler, AuthenticationClient } = require(`@mapify/sdk`)

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.
}

Verify token

const fs = require('fs')
const { Handler, AuthenticationClient } = require(`@mapify/sdk`)
const authenticationClient = new AuthenticationClient({
    publicKey: fs.readFileSync(`${__dirname}/key.pub`, { encoding: 'utf8' })
})

try{
    const isValid = authenticationClient.verify(`token`)
}catch(e){
    // * `TokenExpiredError` Token is expired
    // * `InvalidToken` 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
const fs = require('fs')
const { AuthenticationClient } = require(`@mapify/sdk`)

try{
    const isValid = AuthenticationClient.verify(`token`, fs.readFileSync(`${__dirname}/key.pub`, { encoding: 'utf8' }))
}catch(e){
    // * `TokenExpiredError` Token is expired
    // * `InvalidToken` Token is invalid with he public key
}

Refresh Token

const { AuthenticationClient } = require(`@mapify/sdk`)

try{
    const authenticationClient = new AuthenticationClient()
    const authorization = await authenticationClient.refresh(refreshToken)
}catch(e){
    // * `HTTPException` its thrown wherever is a problem with a Sign.
}

Exceptions

This library throws exceptions to indicate problems:

  • HTTPException its thrown wherever is a problem with a Sign.
  • TokenExpiredError Token is expired
  • InvalidToken Token is invalid with he public key

Testing

NPM

npm test

Yarn

yarn install && yarn build && yarn test

Docker

docker build . -t mapify-js-sdk && \
docker run -it mapify-js-sdk sh -c "yarn test"

Contributing

Please follow our contributor guide

License

This project is licensed under the terms of the Apache License Version 2.0, January 2004.