New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

testsuckit

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testsuckit

testsuckit Javascript library for browser and nodejs

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Websuckit Javascript Client

Test Deploy to NPM

This Websuckit client library supports web browsers and Node.js

For tutorials and more in-depth information about websuckit Channels, visit our official docs.

Usage Overview

The following topics are covered:

Supported platforms

  • Web
    • We test against Chrome, Firefox and Safari.
    • Works in web pages.
    • Works with major web frameworks, including
  • Node.js

Installation

Web

If you're using websuckit Channels on a web page, you can install the library via:

Yarn (or NPM)

You can use any NPM-compatible package manager, including NPM itself and Yarn.

yarn add @websuckit/js

Then:

import websuckit from '@websuckit/js';

Or, if you're not using ES6 modules:

const websuckit = require('@websuckit/js');
CDN
<script src="https://unpkg.com/@websuckit/js@0.0.7/dist/websuckit.umd.js"></script>

Node.js

Having installed @websuckit/js via an NPM-compatible package manager, run:

import websuckit from '@websuckit/js';

Initialization

const ws = new Websuckit({
  userId: USER_ID,
  accessKey: ACCESS_KEY,
  publicKey: PUBLIC_KEY,
})

You can get your USER_ID, ACCESS_KEY and PUBLIC_KEY from the websuckit dashboard.

Channel

Create channel

const channelResponse = ws.createChannel({
  channel: "channel_name", // channel should be a slug e.g test-channel
})

// Expected response
// {
//     channel: {
//         id: string;
//         name: string;
//         pass_key: string;
//         user_id: string;
//         created_at: string;
//         updated_at: string;
//     }
// }

Get channel

const channelResponse = ws.getChannel({
  channelName: "channel_name",
})

// Expected response
// {
//   id: string;
//   name: string;
//   pass_key: string;
//   user_id: string;
//   created_at: string;
//   updated_at: string;
// }

Get channels (paginated)

const channelResponse = ws.getChannels({
    page: "0", // page is 0 indexed
    per_page: "10",
    search_key: "channel_name"; // (optional) search channels by channel name
})

// Expected response
// {
//   id: string;
//   name: string;
//   pass_key: string;
//   user_id: string;
//   created_at: string;
//   updated_at: string;
// }[]

Get or Create channel

const channelResponse = ws.getOrCreateChannel({
  channelName: "channelName", // channel should be a slug e.g test-channel
})

// Expected response
// {
//   id: string;
//   name: string;
//   pass_key: string;
//   user_id: string;
//   created_at: string;
//   updated_at: string;
// }

Update channel

const channelResponse = ws.getOrCreateChannel({
    channelId: "<CHANNEL_UUID>",
    channel: "channel_name"
    regenerate_pass_key: false; // (optional) If regenerate_pass_key is true the channel passkey will be regenerated
})

// Expected response
// {
//     channel: {
//         id: string;
//         name: string;
//         pass_key: string;
//         user_id: string;
//         created_at: string;
//         updated_at: string;
//     }
// }

Delete channel

const channelResponse = ws.getOrCreateChannel({
    channelId: "<CHANNEL_UUID>",
})

// Expected response
// string

Accessing a channel's websocket URL

It is possible to access a channel websocket URL by channel name, through the getConnectionUrl function:

const connectionUrl = ws.getConnectionUrl({
  channelName: CHANNEL_NAME,
  channelPassKey: CHANNEL_PASSKEY,
})

// The expected return of the connectionUrl is a websocket connection e.g wss://backend.websuckit.com/e762eaad-397b-4af8-9376-a8eff2731966/bright/{encrypted_token}
  • channelName - name of channel
  • channelPassKey - channel passkey

Test SDK

yarn test

Run Locally

yarn install

yarn dev

Run SDK locally

  1. Run yarn build && cp package.json ./dist && cd dist && yarn link in the root directory.
  2. Next, Change directory into example folder and run cd ../example && yarn link "@websuckit/js"

Keywords

FAQs

Package last updated on 23 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc