# cl-wla-sdk

> React-Native SDK for CoreLedger WLA

Latest version **1.0.44** (published 2022-06-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install cl-wla-sdk
pnpm add cl-wla-sdk
yarn add cl-wla-sdk
bun add cl-wla-sdk
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.44 |
| Published | 2022-06-09 |
| First published | 2021-12-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 51.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anton Borvanov |
| Maintainers | swicdeveloper |

## Links

- npm: https://www.npmjs.com/package/cl-wla-sdk
- Repository: https://bitbucket.org/innowise-group/swic-digital-common
- Issues: https://bitbucket.org/innowise-group/swic-digital-common
- npm.io page: https://npm.io/package/cl-wla-sdk

## Dependencies (5)

- [ky](https://npm.io/package/ky.md) ^0.28.5
- [hash-wasm](https://npm.io/package/hash-wasm.md) ^4.6.0
- [ky-universal](https://npm.io/package/ky-universal.md) ^0.9.1
- [@ethersproject/shims](https://npm.io/package/@ethersproject/shims.md) ^5.5.0
- [web-streams-polyfill](https://npm.io/package/web-streams-polyfill.md) ^3.0.3

## Recent versions

- 1.0.44 (latest) — 2022-06-09
- 1.0.43 — 2022-05-25
- 1.0.42 — 2022-05-13
- 1.0.41 — 2022-05-04
- 1.0.40 — 2022-04-22
- 1.0.39 — 2022-04-14
- 1.0.38-i — 2022-03-25
- 1.0.37 — 2022-01-04
- 1.0.31 — 2021-12-31
- 1.0.30 — 2021-12-31
- 1.0.19 — 2021-12-26
- 1.0.18 — 2021-12-26
- 1.0.17 — 2021-12-26
- 1.0.16 — 2021-12-26
- 1.0.15 — 2021-12-23
- … 15 more at https://npm.io/package/cl-wla-sdk/versions

## README

# SWIC: common repository

The repository exports a client library with all the methods that the client application can call to store / update models and entities.

## Scripts

`yarn run build`
The script uses provided Webpack configuration and generates _dist_ folder.

`yarn run prepare`
The script does all the necessary work to install scripts or initialize variables.

## Linting and formatting

The code of the package is covered by _husky_ pre-commit hook that runs ESlint checks and Prettier formatting on all of the files that were changed by current commit.
It automatically adds all of the changes after the "format" script to the current commit.
The purpose of the hook is to keep the code the same on all the different machines.

## Client usage concept

The SDK exports `WlaClient` class.
You should create an instance of the class inside of your JavaScript application with a configuration object. The configuration object requires you to provide the client with some variables and strategies:

-   `apiUrl` - base CL API url.
-   `txApiUrl` - URL for CL TX service.
-   `tokenStorageStrategy` - an instance of [TokenStorageStrategy](/src/client/token-storage-strategy/token-storage-strategy.ts) abstract class. It's used to store or retrieve token as the behavior is different in every single application. See `Token management concept` section for more.
-   `cryptoStrategy` - an instance of [CryptoStrategy](/src/client/crypto-strategy/crypto-strategy.ts) abstract class.
-   `uuidGenerationStrategy` - an instance of [UUIDGenerationStrategy](/src/client/uuid-generation-strategy/uuid-generation-strategy.ts) abstract class. The instance is used to generate random strings. It will be moved out from the SKD because of some platform differences. As an example, React-Native does not support pure `uuid` value usage.

Example of instance creation:

```ts
const client: WlaClient = new WlaClient({
	txApiUrl: 'https://txapi-uat.dev.coreledger.net/v1.0/api',
	apiUrl: 'https://wlm-be-swic-uat.dev.coreledger.net',
	tokenStorageStrategy: new SecureTokenStorageStrategy(),
	cryptoStrategy: new AesNativeCryptoStrategy(),
	uuidGenerationStrategy: new v4UUIDGenerationStrategy(),
});
```

The class exports basic functions for requests: GET, POST. Both of them could be used with Generics.

Example of usage:

```ts
await this.client.POST<{
	access_token: string;
	expires_in: number;
	id_token: string;
	token_type: string;
}>(`${this.authApiUrl}/connect/token`, form, {
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
	},
});
```

The client also exports a sub modules like `auth`, `device`, `wallet` and so on. Each of the modules has it's own logic wrapped in a class. You can call any of their public methods to receive necessary information.

## Sections

- [Authorization](/docs/auth.md)
- [Wallet](/docs/wallet.md)

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