HAAPI 网络驱动程序
Typescript/ Javascript 库, 有类和功能访问 Curity 身份服务器 超媒体认证 API (HAAPI) 从基于浏览器的应用程序。 该图书馆可在npm公共登记簿上查阅,并可通过下列方式安装:
npm install @curity/identityserver-haapi-web-driver
用法实例
软件包定义 createHaapiFetch 函数,可以创建类似获取的函数,用于执行 HAAPI 请求。 返回的函数在封面下自动管理验证,访问符,DPoP令牌和会话-Id.
// 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 => {
// ...
});