0.2.1 • Published 1 year ago
@wral/sdk-auth v0.2.1
sdk-auth
The sdk-auth is a JavaScript SDK (Software Development Kit) designed to interact with
an API that generates and validates JWTs.
Installation
You can install the sdk-auth package via npm:
npm install @wral/sdk-authUsage
To use the sdk-auth, you first need to import it into your JavaScript or TypeScript project:
import { createClient } from '@wral/sdk-auth';Then, you can create a client instance with your configuration:
const config = {
baseUrl: 'YOUR_BASE_URL', // Base URL of your API
};
const client = createClient(config);After creating the client instance, you can use its methods to interact with the API. Here are some examples:
// Create a JWT for a user
let token = await client.mintToken({ username: 'someUser', password: 'somePassword' });
// Refresh a JWT
token = await client.refreshToken({ token });API
createClient(config)
Creates a new client instance with the provided configuration.
config: An object containing API configuration parameters:baseUrl: The base URL of the DAM API.
Returns a client instance with methods for interacting with the DAM API.
Methods
mintToken({ username, password }): Generates a JWT for a user.refreshToken({ token }): Refreshes a JWT.pubkey(): Retrieves the public key for signing JWTs.updatePassword({ token, currentPassword, newPassword }): Updates the user's password.triggerResetPassword({ username }): Triggers a password reset for a user.confirmResetPassword({ username, newPassword, confirmationCode }): Confirms a password reset for a user.