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

hyper-sdk-js

v1.0.2

Published

SDK for TypeScript and JavaScript.

Downloads

230

Readme

Hyper Solutions SDK

SDK for TypeScript and JavaScript.

Installation

To use the Hyper Solutions SDK in your Go project, you need to install it using the following command:

npm install hyper-sdk-js

Usage

Creating a Session

To start using the SDK, you need to create a new Session instance by providing your API key:

import {Session} from "hyper-sdk-js";

const session = new Session("Your API key");

You can also optionally set a JWT private key:

import {Session} from "hyper-sdk-js";

const session = new Session("Your API key", "Your base64 JWT private key");

Akamai

The Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.

Generating Sensor Data

To generate sensor data required for generating valid Akamai cookies, use the generateSensorData function:

import {generateSensorData} from "hyper-sdk-js/akamai/sensor.js";

// Caution: will throw an error if the API returns a non-OK response
const sensorData = await generateSensorData(session, {
    abck: "..", // _abck cookie value
    bmsz: "..", // bm_sz cookie value
    pageUrl: "https://example.com", // URL of the page to generate a cookie for
    userAgent: ".." // Browser user agent to impersonate
});

Parsing Script Path

To parse the Akamai Bot Manager script path from the given HTML code, use the parseAkamaiPath function:

import {parseAkamaiPath} from "hyper-sdk-js/akamai/script_path.js";

// Caution: may return null
const scriptPath = parseAkamaiPath(body);

Handling Sec-Cpt Challenges

The Akamai package provides functions for handling sec-cpt challenges:

  • parseChallengeHTML: Parses a sec-cpt challenge from the given HTML code.
  • parseChallengeJSON: Parses a sec-cpt challenge from a JSON response. Use this if you receive an HTTP 429 block.
  • CryptoChallenge.generatePayload: Generates a crypto challenge payload using the provided sec-cpt cookie.
  • CryptoChallenge.wait: Returns a Promise<void> that is resolved after the challenge duration.

Validating Cookies

The Akamai package provides functions for validating cookies:

  • isAkamaiCookieValid: Determines if the provided _abck cookie value is valid based on the given request count.
  • isAkamaiCookieInvalidated: Determines if the current session requires more sensors to be sent.

Generating Pixel Data

To generate pixel data, use the generatePixelData function:

import {generatePixelData} from "hyper-sdk-js/akamai/pixel.js";

const data = await generatePixelData(
    session,
    new PixelInput(
        "..", // Browser user agent to impersonate
        "..", // HTML var, obtained with parsePixelHtmlVar
        ".." // Script var, obtained with parsePixelScriptVar
    )
);

Parsing Pixel Challenges

The Akamai package provides functions for parsing pixel challenges:

  • parsePixelHtmlVar: Parses the required pixel challenge variable from the given HTML code.
  • parsePixelScriptUrl: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.
  • parsePixelScriptVar: Parses the dynamic value from the pixel script.

Incapsula

The Incapsula package provides functions for interacting with Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.

Generating Reese84 Sensor

To generate sensor data required for generating valid Reese84 cookies, use the generateReese84Sensor function:

import {generateReese84Sensor} from "hyper-sdk-js/incapsula/reese.js";

const sensor = await generateReese84Sensor(session, {
    userAgent: "..", // Browser user agent to impersonate
    site: ".." // Site identifier; ask for your site in your ticket
});

Generating UTMVC Cookie

To generate the UTMVC cookie using the Hyper Solutions API, use the generateUtmvcCookie function:

import {generateUtmvcCookie} from "hyper-sdk-js/incapsula/utmvc.js";

const cookie = await generateUtmvcCookie(session, {
    userAgent: "..", // Browser user agent to impersonate
    script: "..", // utmvc script
    sessionIds: [] // Session identifiers, obtained with getSessionIds
});

Obtaining session identifiers

To obtain the session identifiers (sessionIds), use the getSessionIds function:

import {getSessionIds} from "hyper-sdk-js/incapsula/utmvc.js";

// Example input. You need to provide an array of objects,
// each containing the cookie's name (`name` field) and
// the cookie's value (`value` field).
const sessionIds = getSessionIds([
    {
        name: "incap_ses_a",
        value: "test1"
    },
    {
        name: "incap_ses_b",
        value: "test2"
    }
]);

Parsing UTMVC Script Path

To parse the UTMVC script path from a given HTML code, use the parseUtmvcScriptPath function:

import {parseUtmvcScriptPath} from "hyper-sdk-js/incapsula/utmvc.js";

const scriptPath = parseUtmvcScriptPath(body);

Generating UTMVC Submit Path

To generate a unique UTMVC submit path with a random query parameter, use the generateUtmvcScriptPath function:

import {generateUtmvcScriptPath} from "hyper-sdk-js/incapsula/utmvc.js";

const submitPath = generateUtmvcScriptPath();

Contributing

If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.

License

This SDK is licensed under the MIT License.