open-index/open-npm huggingface dataset:
npm package: @randlabs/communication-bridge
Description: * [Overview](#Overview) * [Installation](#Installation) * [API Usage](#API-Usage) * [Copyright and License](#Copyright-and-License)
Author: RandLabs.IO
Latest version: 1.0.1

# Communication-bridge

* [Overview](#Overview)
* [Installation](#Installation)
* [API Usage](#API-Usage)
* [Copyright and License](#Copyright-and-License)

### Overview

A cross-domain communication library develop by Rand Labs that enables send and receive messages between browser windows/tabs.

### Instalation

The library can be installed via npm:

```sh
npm i @randlabs/communication-bridge
```

### API Usage

Import and define the communication channel

```js
const Messenger = require("@randlabs/communication-bridge");
const channelName = "channel name";
```

#### Tab #1

```js
const client = new Messenger(channelName); // If listener is undefined, it will ignore all incoming request

const window = window.open("https://another.website.com");

const response = await client.sendMessage(window, { customMethod: "doSomething" }, { waitForReply: true, origin: "*" }); // If you are sending sensitive data, put a specific origin, for example: https://another.website.com

console.log(response); // { response: "OK" }

```

#### Tab #2

```js
const hub = new Messenger(channelName, function(data, origin, source, sendResponse) {
    console.log(data); // { customMethod: "doSomething" }
    sendResponse({ response: "OK" });
});

```

### Copyright and License  

See [LICENSE](LICENSE.md) file.
npm package: @randlabs/js-config-reader
Description: Configuration settings loader
Author: RandLabs IO
Latest version: 1.1.0

# js-config-reader

Config Reader is a module to ease configuration settings load and validation with the help of JSON schemas.

## Installation

```shell
npm install --save @randlabs/js-config-reader
```

## Usage

```javascript
const ConfigReader = require("@randlabs/js-config-reader");

const settings = await ConfigReader.initialize(options);
```

### Example
```javascript
const ConfigReader = require("@randlabs/js-config-reader");
 
const settings = await ConfigReader.initialize({
    source: path.join(__dirname, "./settings.json"),
    schema: path.join(__dirname, "./settings.schema.json")
});
```

The `options` parameter is an object with the following fields:

* `source` - Source location of the configuration settings. Can be a filename or url depending on the used loader. Optional.
* `envVar` - Environment variable name used to find the source. Optional.
  I.e.: Define `export MY_SETTINGS=/home/myuser/settings.json` and set `MY_SETTINGS` as the `envVar`.
* `cmdLineParam` - Command-line parameter to use to find the source. Optional.
  I.e.: If `settings` is specified, then the code will look for the `--settings` command-line parameter.
* `loader` - Loader function used to load the configuration settings. Optional.
* `schema` - Schema location or JSON Schema object to validate configuration settings. Optional.
* `schemaOpts` - Additional options to pass to the JSON Schema validator. Optional.
* `extendedValidator` - Specifies an additional settings validator. Optional.
* `usingClusters` - Prepares usage for a cluster environment. Optional.
 
# License

Apache 2.0
npm package: @randlabs/js-metrics
Description: Metrics & Health Mini Server
Author: RandLabs IO
Latest version: 1.0.0

# js-metrics

Metrics is a lightweight web server that provides health status and Prometheus-compatible reports.

## Installation

```shell
npm install --save @randlabs/js-metrics
```

## Usage

```javascript
const Metrics = require("@randlabs/js-metrics");

const metricsServer = await Metrics.createServer(options);
```

### Example
```javascript
const Metrics = require("@randlabs/js-metrics");
 
const metricsServer = await Metrics.createServer({
	host: "127.0.0.1",
	port: 3001,
	accessToken: "1234",
	endpoints: {
		getHealth: "/health",
		getStats: "/metrics",
	},
	getHealthCallback: () => {
		return {
			value: Math.random() * 100
		};
	},
	metricsSetupCallback: (registry) => {
		const g = new promclient.Gauge({
			name: 'test_gauge',
			help: 'Example of a gauge',
			registers: [ registry ]
		});

		g.set(Math.random() * 100);
	}
});

// do other stuff

await metricsServer.shutdown();
```

Create a new metrics web server with the given `options`.

*   `options` - Initialization options.
*   `options.host` - Bind address. Defaults to 127.0.0.1. Not used in cluster workers.
*   `options.port` - Specifies the server port. Not used in cluster workers.
*   `options.accessToken` - Protect access to endpoints with an access token. Optional. Not used in cluster workers.
*   `options.usingClusters` - If the app runs inside a cluster environment, set this option to true.
*   `options.endpoints` - Overrides the endpoints paths. Optional. Not used in cluster workers.
*   `options.endpoints.getHealth` - Overrides the "/health" url path. Optional.
*   `options.endpoints.getStats` - Overrides the "/stats" url path. Optional.
*   `options.getHealthCallback` - Callback function called when health information is required. It must return a `HealthStatus` object.
*   `options.metricsSetupCallback` - Callback function called to initialize Prometheus metrics. It receives a `registry` objects where collectors must be added.

# License

Apache 2.0
npm package: @randlabs/js-postgres
Description: An augmented Postgres database wrapper for RandLabs apps
Author: RandLabs IO
Latest version: 1.0.3

# js-postgres

An augmented Postgresql database wrapper.

## Installation

Run `npm i @randlabs/js-postgres` inside your project's root directory.

## Quick usage

```typescript
import * as Database from "@randlabs/js-postgres";

// Initialize database manager
let manager = new Database.Manager({
	host: "127.0.0.1",
	port: 5432,
	user: "my-user",
	password: "my-password",
	database: "my-database",
	usePool: true,
	maxConnections: 100
});

// Get a connection
const client = await manager.getClient();

// Execute a query within a try/catch block in order to return the connection to the pool after using it
try {
	// For documentation about queries, see node-postgres documentation at https://node-postgres.com/
	const result = await client.query(
		"SELECT value FROM config WHERE key = $1",
		[ key ]
	);
	...
	client.release();
}
catch (err) {
	client.release(err);
	throw err; //re-throw
}

// Or use our wrapper to handle errors automatically
const result = await manager.withClient((client: Database.Client, customParam: any): Promise<any> => {
	const result = await client.query(
		"SELECT value FROM config WHERE key = $1",
		[ customParam.key ]
	);
	return result;
}, {
	key: "test-key"
});

// Also we provide a transaction wrapper
const result = await manager.withClient((client: Database.Client): Promise<any> => {
	// withTx will start a transaction and commit/rollback it, depending if an error is thrown or not
	await client.withTx((c: Database.Client) => {
		await c.query("INSERT INTO ....");
	});
});

```

# License

Apache 2.0
npm package: @randlabs/msgpack-bigint
Description: MsgPack library with BigInt support
Author: RandLabs IO
Latest version: 1.0.3

# msgpack-bigint

A message-pack encoder/decoder library that supports ES2020 bigints.

## Installation

```shell
npm install --save @randlabs/msgpack-bigint
```

# License

Apache 2.0

# Credits

We would like to mention and thanks https://github.com/kawanet/msgpack-lite because MsgPack code is based on some ideas from this project.
npm package: @randlabs/myalgo-connect
Description: [![npm version](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect.svg)](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect) [![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](https://connect.myalgo.com/) [![Di
Author: RandLabs.IO
Latest version: 1.4.2

# MyAlgo Connect

[![npm version](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect.svg)](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect)
[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](https://connect.myalgo.com/)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/channels/491256308461207573/817420411502329896)
[![Twitter](https://badgen.net/badge/icon/twitter?icon=twitter&label)](https://twitter.com/myalgo_)

![myalgo-logo](brand-kit/my-algo.png)

* [Overview](#Overview)
* [Installation](#Installation)
* [API Usage](#API-Usage)
  * [Quick start](#Quick-start)
  * [Connect to My Algo](#Connect-to-My-Algo)
  * [Sign transaction](#Sign-transaction)
* [Documentation](#Documentation)
* [Copyright and License](#Copyright-and-License)

## Overview

MyAlgo Connect is a Javascript library developed by Rand Labs to securely sign transactions with [My Algo](https://wallet.myalgo.com)

## Installation  

The package can be installed via npm:

```sh
npm i @randlabs/myalgo-connect
```

or imported in the HTML

```html
<script src="./myalgo.min.js"></script>
```

Find the browser minified version in our github [releases](https://github.com/randlabs/myalgo-connect/releases)

## API Usage  

### Quick start

```js
import MyAlgoConnect from '@randlabs/myalgo-connect';
const myAlgoWallet = new MyAlgoConnect();
```

### Connect to My Algo  

```js
/*Warning: Browser will block pop-up if user doesn't trigger myAlgoWallet.connect() with a button interation */
async function connectToMyAlgo() {
  try {
    const accounts = await myAlgoWallet.connect();
    const addresses = accounts.map(account => account.address);
    
  } catch (err) {
    console.error(err);
  }
}
```

```html
<button onclick="connectToMyAlgo()">Connect!</button>
```

### Sign transaction

```js
import algosdk from 'algosdk';
const algodClient = new algosdk.Algodv2('', 'https://node.algoexplorerapi.io/', 443);

/*Warning: Browser will block pop-up if user doesn't trigger myAlgoWallet.connect() with a button interation */
async function signTransaction (from, to, amount, suggestedParams) {
  try {
    const txn = algosdk.makePaymentTxnWithSuggestedParams({ suggestedParams, from, to, amount });
    const signedTxn = await myAlgoWallet.signTransaction(txn.toByte());  
    const response = await algodClient.sendRawTransaction(signedTxn.blob).do();
    console.log(response)
  } catch(err) {
    console.error(err); 
  }
};
```

## Documentation

Documentation for this package is available here: <https://connect.myalgo.com/>. An example of an integration with MyAlgo Connect: <https://github.com/randlabs/myalgo-connect-test>

## Copyright and License  

See [LICENSE](LICENSE.md) file.