KEYCLOAK-7219: Remove keycloak.js from new Account Console

This commit is contained in:
Stan Silvert 2019-04-22 08:14:39 -04:00 committed by Bruno Oliveira da Silva
parent e52be73d41
commit 6806a4c660
3 changed files with 48 additions and 1455 deletions

View file

@ -29,11 +29,12 @@ export = Keycloak;
declare function Keycloak(config?: string|{}): Keycloak.KeycloakInstance; declare function Keycloak(config?: string|{}): Keycloak.KeycloakInstance;
declare namespace Keycloak { declare namespace Keycloak {
type KeycloakAdapterName = 'cordova'|'default' | any; type KeycloakAdapterName = 'cordova' | 'cordova-native' |'default' | any;
type KeycloakOnLoad = 'login-required'|'check-sso'; type KeycloakOnLoad = 'login-required'|'check-sso';
type KeycloakResponseMode = 'query'|'fragment'; type KeycloakResponseMode = 'query'|'fragment';
type KeycloakResponseType = 'code'|'id_token token'|'code id_token token'; type KeycloakResponseType = 'code'|'id_token token'|'code id_token token';
type KeycloakFlow = 'standard'|'implicit'|'hybrid'; type KeycloakFlow = 'standard'|'implicit'|'hybrid';
type KeycloakPromiseType = 'native'
interface KeycloakInitOptions { interface KeycloakInitOptions {
/** /**
@ -98,11 +99,24 @@ declare namespace Keycloak {
*/ */
responseMode?: KeycloakResponseMode; responseMode?: KeycloakResponseMode;
/**
* Specifies a default uri to redirect to after login or logout.
* This is currently supported for adapter 'cordova-native' and 'default'
*/
redirectUri?: string;
/** /**
* Set the OpenID Connect flow. * Set the OpenID Connect flow.
* @default standard * @default standard
*/ */
flow?: KeycloakFlow; flow?: KeycloakFlow;
/**
* Set the promise type. If set to `'native'` all methods returning a promise
* will return a native JavaScript promise. If not set will return
* Keycloak specific promise objects.
*/
promiseType?: KeycloakPromiseType;
} }
interface KeycloakLoginOptions { interface KeycloakLoginOptions {
@ -161,6 +175,14 @@ declare namespace Keycloak {
* the user's profile to a new preferred locale. * the user's profile to a new preferred locale.
*/ */
kcLocale?: string; kcLocale?: string;
/**
* Specifies arguments that are passed to the Cordova in-app-browser (if applicable).
* Options 'hidden' and 'location' are not affected by these arguments.
* All available options are defined at https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/.
* Example of use: { zoom: "no", hardwareback: "yes" }
*/
cordovaOptions?: { [optionName: string]: string };
} }
type KeycloakPromiseCallback<T> = (result: T) => void; type KeycloakPromiseCallback<T> = (result: T) => void;
@ -202,6 +224,24 @@ declare namespace Keycloak {
createdTimestamp?: number; createdTimestamp?: number;
} }
interface KeycloakTokenParsed {
exp?: number;
iat?: number;
nonce?: string;
sub?: string;
session_state?: string;
realm_access?: { roles: string[] };
resource_access?: string[];
}
interface KeycloakResourceAccess {
[key: string]: KeycloakRoles
}
interface KeycloakRoles {
roles: string[];
}
// export interface KeycloakUserInfo {} // export interface KeycloakUserInfo {}
/** /**
@ -239,12 +279,12 @@ declare namespace Keycloak {
/** /**
* The realm roles associated with the token. * The realm roles associated with the token.
*/ */
realmAccess?: { roles: string[] }; realmAccess?: KeycloakRoles;
/** /**
* The resource roles associated with the token. * The resource roles associated with the token.
*/ */
resourceAccess?: string[]; resourceAccess?: KeycloakResourceAccess;
/** /**
* The base64 encoded token that can be sent in the Authorization header in * The base64 encoded token that can be sent in the Authorization header in
@ -255,15 +295,7 @@ declare namespace Keycloak {
/** /**
* The parsed token as a JavaScript object. * The parsed token as a JavaScript object.
*/ */
tokenParsed?: { tokenParsed?: KeycloakTokenParsed;
exp?: number;
iat?: number;
nonce?: string;
sub?: string;
session_state?: string;
realm_access?: { roles: string[] };
resource_access?: string[];
};
/** /**
* The base64 encoded refresh token that can be used to retrieve a new token. * The base64 encoded refresh token that can be used to retrieve a new token.
@ -273,7 +305,7 @@ declare namespace Keycloak {
/** /**
* The parsed refresh token as a JavaScript object. * The parsed refresh token as a JavaScript object.
*/ */
refreshTokenParsed?: { nonce?: string }; refreshTokenParsed?: KeycloakTokenParsed;
/** /**
* The base64 encoded ID token. * The base64 encoded ID token.
@ -283,7 +315,7 @@ declare namespace Keycloak {
/** /**
* The parsed id token as a JavaScript object. * The parsed id token as a JavaScript object.
*/ */
idTokenParsed?: { nonce?: string }; idTokenParsed?: KeycloakTokenParsed;
/** /**
* The estimated time difference between the browser time and the Keycloak * The estimated time difference between the browser time and the Keycloak

View file

@ -16,12 +16,8 @@
*/ */
import {KeycloakLoginOptions, KeycloakError} from './keycloak.d'; import {KeycloakLoginOptions, KeycloakError} from './keycloak.d';
// If using a local keycloak.js, uncomment this import. With keycloak.js fetched // keycloak.js downloaded in index.ftl
// from the server, you get a compile-time warning on use of the Keycloak() declare function Keycloak(config?: string|{}): Keycloak.KeycloakInstance;
// method below. I'm not sure how to fix this, but it's certainly cleaner
// to get keycloak.js from the server.
//
import * as Keycloak from './keycloak';
export type KeycloakClient = Keycloak.KeycloakInstance; export type KeycloakClient = Keycloak.KeycloakInstance;
type InitOptions = Keycloak.KeycloakInitOptions; type InitOptions = Keycloak.KeycloakInitOptions;