1.0.44 • Published 2 years ago

cl-wla-sdk v1.0.44

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
2 years ago

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 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 abstract class.
  • uuidGenerationStrategy - an instance of UUIDGenerationStrategy 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:

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:

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

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.39

2 years ago

1.0.40

2 years ago

1.0.41

2 years ago

1.0.38-i

2 years ago

1.0.37

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago