Skip to content

Instantly share code, notes, and snippets.

@anwalkers
Created July 26, 2016 16:47
Show Gist options
  • Save anwalkers/98ab6e8d5db199859bcdf020c6d9b6e1 to your computer and use it in GitHub Desktop.
Save anwalkers/98ab6e8d5db199859bcdf020c6d9b6e1 to your computer and use it in GitHub Desktop.
oidc-client TypeScript definitions file
/// <reference path="node_modules/typescript/lib/lib.es6.d.ts" />
declare module "src/Log" {
export default class Log {
static NONE: number;
static ERROR: number;
static WARN: number;
static INFO: number;
static reset(): void;
static level: any;
static logger: any;
static info(...args: any[]): void;
static warn(...args: any[]): void;
static error(...args: any[]): void;
}
}
declare module "src/Global" {
export default class Global {
static _testing(): void;
static location: Location;
static localStorage: Storage;
static sessionStorage: Storage;
static XMLHttpRequest: {
new (): XMLHttpRequest;
prototype: XMLHttpRequest;
DONE: number;
HEADERS_RECEIVED: number;
LOADING: number;
OPENED: number;
UNSENT: number;
create(): XMLHttpRequest;
};
static timer: {
setTimeout: (cb: any, duration: any) => number;
clearTimeout: (handle: any) => void;
};
}
}
declare module "src/WebStorageStateStore" {
export default class WebStorageStateStore {
constructor({prefix, store}?: {
prefix?: string;
store?: Storage;
});
private _store;
private _prefix;
set(key: any, value: any): Promise<void>;
get(key: any): Promise<any>;
remove(key: any): Promise<any>;
getAllKeys(): Promise<any[]>;
}
}
declare module "src/JsonService" {
export interface IJsonService {
getJson: (url: string, token?: string) => Promise<any>;
}
export default class JsonService {
constructor(XMLHttpRequestCtor?: {
new (): XMLHttpRequest;
prototype: XMLHttpRequest;
DONE: number;
HEADERS_RECEIVED: number;
LOADING: number;
OPENED: number;
UNSENT: number;
create(): XMLHttpRequest;
});
private _XMLHttpRequest;
getJson(url: any, token?: any): Promise<{}>;
}
}
declare module "src/MetadataService" {
import JsonService from "src/JsonService";
export default class MetadataService {
constructor(settings: any, JsonServiceCtor?: typeof JsonService);
private _settings;
private _jsonService;
getMetadata(): Promise<any>;
getIssuer(): Promise<any>;
getAuthorizationEndpoint(): Promise<any>;
getUserInfoEndpoint(): Promise<any>;
getCheckSessionIframe(): Promise<any>;
getEndSessionEndpoint(): Promise<any>;
_getMetadataProperty(name: any): Promise<any>;
getSigningKeys(): Promise<any>;
_filterSigningKeys(keys: any): any;
}
}
declare module "src/UserInfoService" {
import JsonService from "src/JsonService";
import MetadataService from "src/MetadataService";
export default class UserInfoService {
constructor(settings: any, JsonServiceCtor?: typeof JsonService, MetadataServiceCtor?: typeof MetadataService);
private _settings;
private _jsonService;
private _metadataService;
getClaims(token: any): Promise<any>;
}
}
declare module "src/ErrorResponse" {
export default class ErrorResponse extends Error {
constructor({error, error_description, error_uri, state}?: {
error?: string;
error_description?: string;
error_uri?: string;
state?: string;
});
_error: any;
_error_description: any;
_error_uri: any;
_state: any;
}
}
declare module "src/JoseUtil" {
export default class JoseUtil {
static parseJwt(jwt: any): {
header: any;
payload: any;
};
static validateJwt(jwt: any, key: any, issuer: any, audience: any, clockSkew: any, now: any): Promise<void>;
static _validateJwt(jwt: any, key: any, issuer: any, audience: any, clockSkew: any, now: any): Promise<void>;
static hashString(value: any, alg: any): any;
static hexToBase64Url(value: any): any;
}
}
declare module "src/ResponseValidator" {
import MetadataService from "src/MetadataService";
import UserInfoService from "src/UserInfoService";
import JoseUtil from "src/JoseUtil";
export default class ResponseValidator {
constructor(settings: any, MetadataServiceCtor?: typeof MetadataService, UserInfoServiceCtor?: typeof UserInfoService, joseUtil?: typeof JoseUtil);
private _settings;
private _metadataService;
private _userInfoService;
private _joseUtil;
validateSigninResponse(state: any, response: any): Promise<any>;
validateSignoutResponse(state: any, response: any): Promise<void>;
_processSigninParams(state: any, response: any): Promise<void>;
_processClaims(response: any): Promise<any>;
_mergeClaims(claims1: any, claims2: any): any;
_filterProtocolClaims(claims: any): any;
_validateTokens(state: any, response: any): Promise<void>;
_validateIdTokenAndAccessToken(state: any, response: any): Promise<void>;
_validateIdToken(state: any, response: any): Promise<void>;
_validateAccessToken(response: any): Promise<void>;
}
}
declare module "src/OidcClientSettings" {
import WebStorageStateStore from "src/WebStorageStateStore";
import ResponseValidator from "src/ResponseValidator";
import MetadataService from "src/MetadataService";
export default class OidcClientSettings {
constructor({authority, metadataUrl, metadata, signingKeys, client_id, response_type, scope, redirect_uri, post_logout_redirect_uri, prompt, display, max_age, ui_locales, acr_values, filterProtocolClaims, loadUserInfo, staleStateAge, clockSkew, stateStore, ResponseValidatorCtor, MetadataServiceCtor}?: {
authority?: string;
metadataUrl?: string;
metadata?: string;
signingKeys?: string;
client_id?: string;
response_type?: string;
scope?: string;
redirect_uri?: string;
post_logout_redirect_uri?: string;
prompt?: string;
display?: string;
max_age?: string;
ui_locales?: string;
acr_values?: string;
filterProtocolClaims?: boolean;
loadUserInfo?: boolean;
staleStateAge?: number;
clockSkew?: number;
stateStore?: WebStorageStateStore;
ResponseValidatorCtor?: typeof ResponseValidator;
MetadataServiceCtor?: typeof MetadataService;
});
private _authority;
private _metadataUrl;
private _metadata;
private _signingKeys;
private _client_id;
private _response_type;
private _scope;
private _redirect_uri;
private _post_logout_redirect_uri;
private _prompt;
private _display;
private _max_age;
private _ui_locales;
private _acr_values;
private _filterProtocolClaims;
private _loadUserInfo;
private _staleStateAge;
private _clockSkew;
private _stateStore;
private _validator;
private _metadataService;
client_id: any;
response_type: any;
scope: string;
redirect_uri: string;
post_logout_redirect_uri: string;
prompt: string;
display: any;
max_age: any;
ui_locales: any;
acr_values: any;
authority: string;
metadataUrl: string;
metadata: any;
signingKeys: any;
filterProtocolClaims: any;
loadUserInfo: any;
staleStateAge: any;
clockSkew: any;
stateStore: any;
validator: any;
metadataService: any;
}
}
declare module "src/UrlUtility" {
import Global from "src/Global";
export default class UrlUtility {
static addQueryParam(url: any, name: any, value: any): any;
static parseUrlFragment(value: any, delimiter?: string, global?: typeof Global): Object;
}
}
declare module "src/random" {
export default function random(): string;
}
declare module "src/State" {
export default class State {
constructor({id, data, created}?: {
id?: string;
data?: {};
created?: number;
});
private _id;
private _data;
private _created;
id: string;
data: {};
created: number;
toStorageString(): string;
static fromStorageString(storageString: any): State;
static clearStaleState(storage: any, age: any): any;
}
}
declare module "src/SigninState" {
import State from "src/State";
export default class SigninState extends State {
constructor({nonce, authority, client_id}?: {
nonce?: {};
authority?: string;
client_id?: string;
});
private _nonce;
private _authority;
private _client_id;
nonce: any;
authority: string;
client_id: string;
toStorageString(): string;
static fromStorageString(storageString: any): SigninState;
}
}
declare module "src/SigninRequest" {
export default class SigninRequest {
constructor({url, client_id, redirect_uri, response_type, scope, authority, data, prompt, display, max_age, ui_locales, id_token_hint, login_hint, acr_values}: {
url: any;
client_id: any;
redirect_uri: any;
response_type: any;
scope: any;
authority: any;
data: any;
prompt: any;
display: any;
max_age: any;
ui_locales: any;
id_token_hint: any;
login_hint: any;
acr_values: any;
});
private state;
private url;
static isOidc(response_type: any): boolean;
static isOAuth(response_type: any): boolean;
}
}
declare module "src/SigninResponse" {
export default class SigninResponse {
constructor(url: any);
private error;
private error_description;
private error_uri;
private state;
private id_token;
private session_state;
private access_token;
private token_type;
private scope;
private profile;
private expires_at;
expires_in: number;
expired: boolean;
scopes: string[];
isOpenIdConnect: boolean;
}
}
declare module "src/SignoutRequest" {
export default class SignoutRequest {
constructor({url, id_token_hint, post_logout_redirect_uri, data}: {
url: any;
id_token_hint: any;
post_logout_redirect_uri: any;
data: any;
});
private state;
private url;
}
}
declare module "src/SignoutResponse" {
export default class SignoutResponse {
constructor(url: any);
private error;
private error_description;
private error_uri;
private state;
}
}
declare module "src/OidcClient" {
import OidcClientSettings from "src/OidcClientSettings";
export default class OidcClient {
constructor(settings?: {});
private _settings;
_stateStore: any;
_validator: any;
_metadataService: any;
settings: OidcClientSettings;
metadataService: any;
createSigninRequest({response_type, scope, redirect_uri, data, prompt, display, max_age, ui_locales, id_token_hint, login_hint, acr_values}?: {
response_type?: string;
scope?: string;
redirect_uri?: string;
data?: {};
prompt?: string;
display?: string;
max_age?: string;
ui_locales?: string;
id_token_hint?: string;
login_hint?: string;
acr_values?: string;
}, stateStore?: any): any;
processSigninResponse(url: any, stateStore?: any): any;
createSignoutRequest({id_token_hint, data, post_logout_redirect_uri}?: {
id_token_hint?: string;
data?: {};
post_logout_redirect_uri?: string;
}, stateStore?: any): any;
processSignoutResponse(url: any, stateStore?: any): any;
clearStaleState(stateStore: any): any;
}
}
declare module "src/InMemoryWebStorage" {
export default class InMemoryWebStorage {
constructor();
private _data;
getItem(key: any): any;
setItem(key: any, value: any): void;
removeItem(key: any): void;
length: number;
key(index: any): string;
}
}
declare module "src/RedirectNavigator" {
export default class RedirectNavigator {
prepare(): Promise<this>;
navigate(params: any): Promise<void>;
url: string;
}
}
declare module "src/PopupWindow" {
export default class PopupWindow {
constructor(params: any);
private _promise;
private _resolve;
private _reject;
private _boundMessageEvent;
private _popup;
private _checkForPopupClosedTimer;
navigate(params: any): Promise<any>;
promise: Promise<any>;
_success(data: any): void;
_error(message: any): void;
_cleanup(): void;
_checkForPopupClosed(): void;
_message(e: any): void;
_origin: string;
static notifyOpener(url: any): void;
}
}
declare module "src/PopupNavigator" {
import PopupWindow from "src/PopupWindow";
export default class PopupNavigator {
prepare(params: any): Promise<PopupWindow>;
callback(url: any): Promise<void>;
}
}
declare module "src/IFrameWindow" {
export default class IFrameWindow {
constructor();
private _promise;
private _resolve;
private _reject;
private _boundMessageEvent;
private _frame;
private _timer;
navigate(params: any): Promise<any>;
promise: Promise<any>;
_success(data: any): void;
_error(message: any): void;
_cleanup(): void;
_timeout(): void;
_message(e: any): void;
_origin: string;
static notifyParent(url: any): void;
}
}
declare module "src/IFrameNavigator" {
import IFrameWindow from "src/IFrameWindow";
export default class IFrameNavigator {
prepare(): Promise<IFrameWindow>;
callback(url: any): Promise<void>;
}
}
declare module "src/UserManagerSettings" {
import OidcClientSettings from "src/OidcClientSettings";
import RedirectNavigator from "src/RedirectNavigator";
import PopupNavigator from "src/PopupNavigator";
import IFrameNavigator from "src/IFrameNavigator";
import WebStorageStateStore from "src/WebStorageStateStore";
export default class UserManagerSettings extends OidcClientSettings {
constructor({popup_redirect_uri, popupWindowFeatures, popupWindowTarget, silent_redirect_uri, automaticSilentRenew, accessTokenExpiringNotificationTime, redirectNavigator, popupNavigator, iframeNavigator, userStore}?: {
popup_redirect_uri?: string;
popupWindowFeatures?: string;
popupWindowTarget?: string;
silent_redirect_uri?: string;
automaticSilentRenew?: boolean;
accessTokenExpiringNotificationTime?: number;
redirectNavigator?: RedirectNavigator;
popupNavigator?: PopupNavigator;
iframeNavigator?: IFrameNavigator;
userStore?: WebStorageStateStore;
});
private _popup_redirect_uri;
private _popupWindowFeatures;
private _popupWindowTarget;
private _silent_redirect_uri;
private _automaticSilentRenew;
private _accessTokenExpiringNotificationTime;
private _redirectNavigator;
private _popupNavigator;
private _iframeNavigator;
private _userStore;
popup_redirect_uri: string;
popupWindowFeatures: any;
popupWindowTarget: any;
silent_redirect_uri: string;
automaticSilentRenew: boolean;
accessTokenExpiringNotificationTime: number;
redirectNavigator: any;
popupNavigator: any;
iframeNavigator: any;
userStore: any;
}
}
declare module "src/User" {
export default class User {
constructor({id_token, session_state, access_token, token_type, scope, profile, expires_at, state}: {
id_token: any;
session_state: any;
access_token: any;
token_type: any;
scope: any;
profile: any;
expires_at: any;
state: any;
});
id_token: string;
private session_state;
private access_token;
private token_type;
private scope;
private profile;
private expires_at;
private state;
expires_in: number;
expired: boolean;
scopes: string[];
toStorageString(): string;
static fromStorageString(storageString: any): User;
}
}
declare module "src/Event" {
export default class Event {
constructor(name: string);
_name: string;
_callbacks: Array<Function>;
addHandler(cb: any): void;
removeHandler(cb: any): void;
raise(...params: any[]): void;
}
}
declare module "src/Timer" {
import Event from "src/Event";
export default class Timer extends Event {
constructor(name: any, timer?: {
setTimeout: (cb: any, duration: any) => number;
clearTimeout: (handle: any) => void;
});
private _timer;
private _timerHandle;
init(duration: any): void;
cancel(): void;
_callback(): void;
}
}
declare module "src/AccessTokenEvents" {
import Timer from "src/Timer";
export default class AccessTokenEvents {
constructor({accessTokenExpiringNotificationTime, accessTokenExpiringTimer, accessTokenExpiredTimer}?: {
accessTokenExpiringNotificationTime?: number;
accessTokenExpiringTimer?: Timer;
accessTokenExpiredTimer?: Timer;
});
_accessTokenExpiringNotificationTime: number;
_accessTokenExpiring: Timer;
_accessTokenExpired: Timer;
load(container: any): void;
unload(): void;
_cancelTimers(): void;
addAccessTokenExpiring(cb: any): void;
removeAccessTokenExpiring(cb: any): void;
addAccessTokenExpired(cb: any): void;
removeAccessTokenExpired(cb: any): void;
}
}
declare module "src/UserManagerEvents" {
import AccessTokenEvents from "src/AccessTokenEvents";
export default class UserManagerEvents extends AccessTokenEvents {
constructor(settings: any);
private _userLoaded;
private _userUnloaded;
private _silentRenewError;
load(user: any): void;
unload(): void;
addUserLoaded(cb: any): void;
removeUserLoaded(cb: any): void;
addUserUnloaded(cb: any): void;
removeUserUnloaded(cb: any): void;
addSilentRenewError(cb: any): void;
removeSilentRenewError(cb: any): void;
_raiseSilentRenewError(e: any): void;
}
}
declare module "src/SilentRenewService" {
export default class SilentRenewService {
constructor(userManager: any);
private _userManager;
_tokenExpiring(): void;
}
}
declare module "src/UserManager" {
import OidcClient from "src/OidcClient";
import UserManagerSettings from "src/UserManagerSettings";
export default class UserManager extends OidcClient {
constructor(settings: UserManagerSettings);
settings: UserManagerSettings;
private _events;
private _silentRenewService;
_redirectNavigator: any;
_popupNavigator: any;
_iframeNavigator: any;
_userStore: any;
events: any;
getUser(): any;
removeUser(): any;
signinPopup(args?: any): any;
signinPopupCallback(url: any): any;
signinSilent(args?: any): any;
signinSilentCallback(url: any): any;
_signin(args: any, navigator: any, navigatorParams?: any): any;
_signinCallback(url: any, navigator: any): any;
_signout(args: any, navigator: any, navigatorParams?: any): any;
_signoutCallback(url: any, navigator: any): any;
signinRedirect(args: any): any;
signinRedirectCallback(url: any): any;
signoutRedirect(args: any): any;
signoutRedirectCallback(url: any): any;
_signinStart(args: any, navigator: any, navigatorParams?: any): any;
_signinEnd(url: any): any;
_signoutStart(args: any, navigator: any, navigatorParams?: any): any;
_signoutEnd(url: any): any;
_userStoreKey: string;
_loadUser(): any;
_storeUser(user: any): any;
}
}
declare module "index" {
import log from "src/Log";
import oidcClient from "src/OidcClient";
import webStorageStateStore from "src/WebStorageStateStore";
import inMemoryWebStorage from "src/InMemoryWebStorage";
import userManager from "src/UserManager";
import accessTokenEvents from "src/AccessTokenEvents";
import metadataService from "src/MetadataService";
export const Log: typeof log;
export const OidcClient: typeof oidcClient;
export const WebStorageStateStore: typeof webStorageStateStore;
export const InMemoryWebStorage: typeof inMemoryWebStorage;
export const UserManager: typeof userManager;
export const AccessTokenEvents: typeof accessTokenEvents;
export const MetadataService: typeof metadataService;
//declare var _default: {
// Log: typeof log;
// OidcClient: typeof oidcClient;
// WebStorageStateStore: typeof webStorageStateStore;
// InMemoryWebStorage: typeof inMemoryWebStorage;
// UserManager: typeof userManager;
// AccessTokenEvents: typeof accessTokenEvents;
// MetadataService: typeof metadataService;
//};
export default _default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment