mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Add types for keycloak-authz.js in keycloak-js package
This commit is contained in:
2
keycloak-js/index.d.ts
vendored
2
keycloak-js/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for keycloak-js 2.4
|
||||
// Type definitions for keycloak-js 2.5
|
||||
// Project: https://github.com/keycloak/keycloak
|
||||
// Definitions by: Brett Epps <https://github.com/eppsilon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
39
keycloak-js/keycloak-authz.d.ts
vendored
Normal file
39
keycloak-js/keycloak-authz.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import * as Keycloak from 'keycloak-js';
|
||||
|
||||
export as namespace KeycloakAuthorization;
|
||||
|
||||
export = KeycloakAuthorization;
|
||||
|
||||
/**
|
||||
* Creates a new Keycloak client instance.
|
||||
* @param config Path to a JSON config file or a plain config object.
|
||||
*/
|
||||
declare function KeycloakAuthorization(keycloak: Keycloak.KeycloakInstance): KeycloakAuthorization.KeycloakAuthorizationInstance;
|
||||
|
||||
declare namespace KeycloakAuthorization {
|
||||
export interface KeycloakAuthorizationPromise {
|
||||
then(onGrant: (rpt: string) => void, onDeny: () => void, onError: () => void): void;
|
||||
}
|
||||
|
||||
export interface KeycloakAuthorizationInstance {
|
||||
rpt: any;
|
||||
config: { rpt_endpoint: string };
|
||||
|
||||
init(): void;
|
||||
|
||||
/**
|
||||
* This method enables client applications to better integrate with resource servers protected by a Keycloak
|
||||
* policy enforcer.
|
||||
*
|
||||
* In this case, the resource server will respond with a 401 status code and a WWW-Authenticate header holding the
|
||||
* necessary information to ask a Keycloak server for authorization data using both UMA and Entitlement protocol,
|
||||
* depending on how the policy enforcer at the resource server was configured.
|
||||
*/
|
||||
authorize(wwwAuthenticateHeader: string): KeycloakAuthorizationPromise;
|
||||
|
||||
/**
|
||||
* Obtains all entitlements from a Keycloak server based on a given resourceServerId.
|
||||
*/
|
||||
entitlement(resourceServerId: string, entitlementRequest: {}): KeycloakAuthorizationPromise;
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,8 @@ import {
|
||||
KeycloakResponseType
|
||||
} from 'keycloak-js';
|
||||
|
||||
import * as KeycloakAuthorization from 'keycloak-js/keycloak-authz';
|
||||
import { KeycloakAuthorizationPromise } from 'keycloak-js/keycloak-authz';
|
||||
|
||||
let keycloak = Keycloak();
|
||||
let keycloakAuthz = KeycloakAuthorization(keycloak);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"keycloak-authz.d.ts",
|
||||
"keycloak-js-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user