# ledger-stellar-sdk

> Ledger Hardware Wallet Stellar JavaScript bindings.

Latest version **0.0.1-alpha.2** (published 2022-11-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ledger-stellar-sdk
pnpm add ledger-stellar-sdk
yarn add ledger-stellar-sdk
bun add ledger-stellar-sdk
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-alpha.2 |
| Published | 2022-11-20 |
| First published | 2022-11-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 35.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | overcat |
| Maintainers | overcat |
| Keywords | Ledger, Ledger Wallet, Stellar, XLM, Hardware Wallet |

## Links

- npm: https://www.npmjs.com/package/ledger-stellar-sdk
- npm.io page: https://npm.io/package/ledger-stellar-sdk

## Dependencies (2)

- [crc](https://npm.io/package/crc.md) >=3.0.0, <5.0.0
- [@scure/base](https://npm.io/package/@scure/base.md) ^1.1.1

## Recent versions

- 0.0.1-alpha.2 (latest) — 2022-11-20
- 0.0.1-alpha.1 — 2022-11-20
- 0.0.1-alpha.0 — 2022-11-20

## README

# JavaScript Ledger Stellar SDK

![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/overcat/js-ledger-stellar-sdk/Main/main)
![npm](https://img.shields.io/npm/v/ledger-stellar-sdk)

Ledger Hardware Wallet Stellar JavaScript bindings.

## Installation

```bash
npm install ledger-stellar-sdk
```

## API Documentation
### Classes

<dl>
<dt><a href="#Stellar">Stellar</a></dt>
<dd><p>Ledger Hardware Wallet Stellar JavaScript bindings.</p>
</dd>
</dl>

### Typedefs

<dl>
<dt><a href="#Signature">Signature</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#PublicKey">PublicKey</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#AppConfiguration">AppConfiguration</a> : <code>object</code></dt>
<dd></dd>
</dl>

<a name="Stellar"></a>

### Stellar
Ledger Hardware Wallet Stellar JavaScript bindings.

**Kind**: global class

* [Stellar](#Stellar)
    * [new Stellar(transport, [scrambleKey])](#new_Stellar_new)
    * [.getPublicKey(accountIndex, [display])](#Stellar+getPublicKey) ⇒ [<code>PublicKey</code>](#PublicKey)
    * [.signTransaction(accountIndex, transaction)](#Stellar+signTransaction) ⇒ [<code>Signature</code>](#Signature)
    * [.signHash(accountIndex, hash)](#Stellar+signHash) ⇒ [<code>Signature</code>](#Signature)
    * [.getAppConfiguration()](#Stellar+getAppConfiguration) ⇒ [<code>AppConfiguration</code>](#AppConfiguration)

<a name="new_Stellar_new"></a>

#### new Stellar(transport, [scrambleKey])

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| transport | <code>Transport</code> |  | The Ledger transport to use |
| [scrambleKey] | <code>string</code> | <code>&quot;w0w&quot;</code> | A string that will be used to scramble the device communication |

**Example**
```typescript
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
import LedgerStellarApi from "ledger-stellar-sdk";

const transport = await TransportWebUSB.create();
const stellar = new LedgerStellarApi(transport);
```
<a name="Stellar+getPublicKey"></a>

#### stellar.getPublicKey(accountIndex, [display]) ⇒ [<code>PublicKey</code>](#PublicKey)
Get Stellar public key for a given account index.

**Kind**: instance method of [<code>Stellar</code>](#Stellar)
**Returns**: [<code>PublicKey</code>](#PublicKey) - an object with a publicKey and rawPublicKey.

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| accountIndex | <code>number</code> |  | It is part of key derivation path: `m/44'/148'/accountIndex'` |
| [display] | <code>boolean</code> | <code>false</code> | If set to "true", the public key will be displayed on the Ledger device and the user will be asked to confirm, otherwise it will not |

**Example**
```typescript
const response = stellar.getPublicKey(0, true)
```
<a name="Stellar+signTransaction"></a>

#### stellar.signTransaction(accountIndex, transaction) ⇒ [<code>Signature</code>](#Signature)
Sign the given transaction.

**Kind**: instance method of [<code>Stellar</code>](#Stellar)
**Returns**: [<code>Signature</code>](#Signature) - the signature

| Param | Type | Description |
| --- | --- | --- |
| accountIndex | <code>number</code> | It is part of key derivation path: `m/44'/148'/accountIndex'` |
| transaction | <code>Buffer</code> | The transaction to sign. It consists of network id and transaction envelope, if you are using `stellar-sdk`, you can use `transaction.signatureBase()` to get the value |

<a name="Stellar+signHash"></a>

#### stellar.signHash(accountIndex, hash) ⇒ [<code>Signature</code>](#Signature)
Sign the given hash.

It is intended for signing transactions not supported by the Ledger Stellar
app and should be avoided as much as possible.

**Kind**: instance method of [<code>Stellar</code>](#Stellar)
**Returns**: [<code>Signature</code>](#Signature) - the signature

| Param | Type | Description |
| --- | --- | --- |
| accountIndex | <code>number</code> | It is part of key derivation path: `m/44'/148'/accountIndex'` |
| hash | <code>string</code> \| <code>Buffer</code> | The hash to sign |

**Example**
```typescript
const response = stellar.signHash(0, "4b480b455a7ee154c33651819e3ce2ceb6bcd9dda78887777c4d2718c5cd04cd")
```
<a name="Stellar+getAppConfiguration"></a>

#### stellar.getAppConfiguration() ⇒ [<code>AppConfiguration</code>](#AppConfiguration)
Get the configuration of the Ledger Stellar app installed on the hardware device.

**Kind**: instance method of [<code>Stellar</code>](#Stellar)
**Returns**: [<code>AppConfiguration</code>](#AppConfiguration) - an object with the version and the flag to indicate whether hash signing is enabled
**Example**
```typescript
const response = await stellar.getAppConfiguration();
```
<a name="Signature"></a>

### Signature : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| signature | <code>Buffer</code> | The signature |

<a name="PublicKey"></a>

### PublicKey : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| publicKey | <code>string</code> | Encoded public key |
| rawPublicKey | <code>Buffer</code> | Raw public key |

<a name="AppConfiguration"></a>

### AppConfiguration : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| version | <code>string</code> | The version of the Stellar app installed on the device |
| hashSigningEnabled | <code>boolean</code> | Whether hash signing is enabled |

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