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

test-ow-js-sdk

v1.4.1

Published

## Installation

Downloads

32

Readme

OW-JS-SDK

Installation

OW-JS-SDK requires npm v8+ and Node.js v14 to run.

# Using Yarn:
yarn add ow-js-sdk

# Or, using NPM:
npm install ow-js-sdk

Usage

First of all, it`s necessary to initialize the sdk with OW API base address in order to use its methods.

import * as OW from ow-js-sdk;

OW.initialize('https://ws.dev.overdrive.asia/');

# ...and then you can use the methods you need as it`s shown below

const signOut = async () => {
    return await OW.authn.signOut().run();
}

Methods

Authentication:
Devices:
Messages:

signIn

Performs a sign-in step. It accepts an object as a parameter with a required field "petition". It's an object with a "credentials" field - an array of objects. The response contains the "resolution" object. If credentials fail or are insufficient there is a "challenge" object in the resolution that contains errors and required credential type. If there are sessionId or challengeNo fields in the challenge object, it`s required to use them when trying to sign-in after a failed attempt. Once sign-in succeeded, the client session is established and resolution does not contain a challenge object and may contain verification token required for some sensitive operations.

import * as OW from ow-js-sdk;

const signInPayload = {
    petition: {
        credentials: [
            { credentialType: 'loginName', value: '[email protected]' },
            { credentialType: 'password', value: 'your password' }
        ]
    }
}

const signIn = async (signInPayload) => {
    try {
        const { resolution } = await OW.authn.signIn(petition).run();
        
        if (resolution?.challenge) {
            throw new Error(resolution.challenge.error);
        }
        
         # here functionality to handle response goes;
    } catch (error) {
        console.log(error);
    }
}

sessionId and challengeNo should be used in a petition as shown below:

const signInPayload = {
    petition: {
        sessionId: 'some session id',
        credentials: [
            { credentialType: 'loginName', value: '[email protected]', challengeNo: 1 },
            { credentialType: 'password', value: 'your password', challengeNo: 1 }
        ]
    }
}

resendSignIn

Requests to re-generate previously dispatched re-sendable sign-in challenge. It`s possible to re-generate only those challenges that have field "resendable" equal to true.

const resendSignIn = async (challengeNo) => {
    try {
        const { challenge } = await OW.authn.resendSignIn(challengeNo).run();
        console.log(challenge);
    } catch (error) {
        console.log(error);
    }
}

verify

The method is similar to sign-in request but it does not affect session authentication status. It should be used to re-generate expired verification token which is required for some sensitive operations.

const payload = {
    petition: {
        credentials: [
            { credentialType: 'loginName', value: '[email protected]' },
            { credentialType: 'password', value: 'your password' }
        ]
    }
}

const verify = async (payload) => {
    try {
        const { resolution } = await OW.authn.verify(petition).run();
        console.log(resolution);
    } catch (error) {
        console.log(error);
    }
}

resendVerification

Requests to re-generate previously dispatched re-sendable verification challenge.

const resendVerification = async (challengeNo) => {
    try {
        const { challenge } = await OW.authn.resendVerification(challengeNo).run();
        console.log(challenge);
    } catch (error) {
        console.log(error);
    }
}

generateSignInToken

Generates token that can be used as a credential to sign in.

const generateSignInToken = async () => {
    try {
        const { token } = await OW.authn.generateSignInToken().run();
        console.log(token);
    } catch (error) {
        console.log(error);
    }
}

renewToken

Refreshes the current token by generating a new one.

const renewToken = async (currentToken) => {
    try {
        const { token } = await OW.authn.renewToken(currentToken).run();
        console.log(token);
    } catch (error) {
        console.log(error);
    }
}

removeToken

Removes current token.

const removeToken = async (currentToken) => {
    try {
        await OW.authn.removeToken(currentToken).run();
    } catch (error) {
        console.log(error);
    }
}

inspect

Re-establishes authentication context of the current session on behalf of another user. The current user must have privilege to access context of another user. The request requires a valid verification token.

const payload = {
    inspectionRequest: {
        loginName: '[email protected]'
    }
}

const inspect = async (payload) => {
    try {
        const { ack } = await OW.authn.inspect(payload).run();
        console.log(ack);
    } catch (error) {
        console.log(error);
    }
}

signOut

Ends current session.

const signOut = async () => {
    try {
        await OW.authn.signOut().run();
    } catch (error) {
        console.log(error);
    }
}

load

Retrieves user`s devices.

const getUserDevices = async () => {
    try {
        const { devices } = await OW.device.load().run();
    } catch (error) {
        console.log(error);
    }
}

loadFields

Retrieves message fields' meta-data. The data returned describe fields and its values that can be presented in a device`s message.

const getMessageMetadata = async () => {
    try {
        const { messageFields } = await OW.message.loadFields().run();
    } catch (error) {
        console.log(error);
    }
}

latest

Retrieves the latest device's message.

const getDeviceLatestMessage = async (deviceUri) => {
    try {
        const { messageDetails } = await OW.message.latest(deviceUri).run();
    } catch (error) {
        console.log(error);
    }
}