Home > @curity/identityserver-haapi-web-driver

identityserver-haapi-web-driver package

TypeScript/JavaScript library with classes and functions to access the Curity Identity Server Hypermedia Authentication API (HAAPI) from browser-based applications.

Remarks

The library is available on the npm public registry and can be installed using:

npm install @curity/identityserver-haapi-web-driver

Example

// 0 - Import the createHaapiFetch function
import { createHaapiFetch } from '@curity/identityserver-haapi-web-driver';

// 1 - Create a fetch-like function to perform HAAPI requests
const haapiFetch = createHaapiFetch({
    clientId: 'test-client-id',
    tokenEndpoint: 'https://localhost:8443/dev/oauth/token',
});

// 2 - Use haapiFetch to access HAAPI resources
const authorizeRequest = '/dev/oauth/authorize?client_id=test-client-id&response_type=code&scope=read&state=foobar&redirect_uri=https://localhost:7777/client-callback';
haapiFetch(authorizeRequest)
    .then(res => {
        // ...
    });

Functions

Function Description
createHaapiFetch(config) Creates a fetch-like function that can be used to perform HAAPI requests, managing attestation, access tokens, DPoP tokens, and Session-Id.

Interfaces

Interface Description
HaapiConfiguration Configuration for HAAPI access.

Type Aliases

Type Alias Description
FetchLike A function similar to fetch used to perform HAAPI requests.