# gl-client

> Greenlight is non-custodial lightning-as-a-service. Your users hold their keys, while we take care of everything else. These are the JS client bindings.

Latest version **0.1.10** (published 2023-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install gl-client
pnpm add gl-client
yarn add gl-client
bun add gl-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.10 |
| Published | 2023-07-04 |
| First published | 2023-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 804.8 KB |
| Known vulnerabilities | 0 (+11 in 1 direct dependencies) |
| Install scripts | yes |
| Maintainers | cdecker |

## Links

- npm: https://www.npmjs.com/package/gl-client
- npm.io page: https://npm.io/package/gl-client

## Dependencies (3)

- [protobufjs](https://npm.io/package/protobufjs.md) ^6.11.2
- [cargo-cp-artifact](https://npm.io/package/cargo-cp-artifact.md) ^0.1.7
- [@mapbox/node-pre-gyp](https://npm.io/package/@mapbox/node-pre-gyp.md) ^1.0.10

## Recent versions

- 0.1.10 (latest) — 2023-07-04
- 0.1.9 — 2023-06-09
- 0.1.8 — 2023-06-06
- 0.1.7 — 2023-05-31

## README

# Getting started

## Installation

Installing the dependency is done via `npm`:

```bash
npm install gl-client
```

And it should automatically pull down a precompiled binary image of
the library, skipping the lengthy compilation process. If this fails
we likely just haven't compiled the library for your architecture and
platform, so please let us know by opening an issue. You might be able
to compile the binary extension from its source, automatically when
`npm install`ing or `npm update`ing in your project (though that may
take a while).

## Updating

`npm update` should just work:

```bash
npm update
```

## Examples

The following examples show how the API can be used to talk to greenlight:

```javascript
const glclient = require('gl-client');
const buffer = require("buffer");

let invite = "..." // You'll need an invite from GL to create a new node

// The scheduler accepts connections with identity /users/nobody for `register` and `recover`
let tls = new glclient.TlsConfig();

// We assume you're storing the secret somewhere safe! Don't store it in the code like this
let signer = new glclient.Signer(
  buffer.Buffer.from("00000000000000000000000000000000", "utf8"),
    "regtest",
    tls
);

let node_id = signer.node_id();
let sched = new glclient.Scheduler(node_id, "regtest");

let response = sched.register(signer, invite);
console.log(response);
```

The following allows you to schedule the node on our infrastructure:

```js
const glclient = require('gl-client');
const buffer = require("buffer");

// Notice this time we have to load an identity that corresponds to the node, this is
// because we want to schedule the node and then talk to it.
let tls = new glclient.TlsConfig();
let user_tls = tls.load_file("device.crt", "device-key.pem");

let signer = new glclient.Signer(
  buffer.Buffer.from("00000000000000000000000000000000", "utf8"),
  "regtest",
  user_tls
);

let node_id = signer.node_id();
console.log("Node ID", node_id);
let sched = new glclient.Scheduler(node_id, "regtest", user_tls);

let node = sched.schedule();

// Now you can use `node` as if it were any other c-lightning node:
console.log(node.get_info())

node.stop();
```

---
_Source: https://npm.io/package/gl-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
