Skip to content

Commit

Permalink
feat: include typescript exports
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeleusin committed Oct 7, 2019
1 parent a09dd1c commit 11f8348
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
16 changes: 15 additions & 1 deletion src/Auth0Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ import { AuthenticationError } from './errors';
import * as ClientStorage from './storage';
import { DEFAULT_POPUP_CONFIG_OPTIONS } from './constants';
import version from './version';
import {
Auth0ClientOptions,
BaseLoginOptions,
AuthorizeOptions,
PopupConfigOptions,
PopupLoginOptions,
GetUserOptions,
GetIdTokenClaimsOptions,
RedirectLoginOptions,
RedirectLoginResult,
GetTokenSilentlyOptions,
GetTokenWithPopupOptions,
LogoutOptions
} from './global';

/**
* Auth0 SDK for Single Page Applications using [Authorization Code Grant Flow with PKCE](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant-pkce).
Expand Down Expand Up @@ -174,7 +188,7 @@ export default class Auth0Client {
* @param options
*/
public async getIdTokenClaims(
options: getIdTokenClaimsOptions = {
options: GetIdTokenClaimsOptions = {
audience: this.options.audience || 'default',
scope: this.options.scope || this.DEFAULT_SCOPE
}
Expand Down
2 changes: 2 additions & 0 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IdToken } from './global';

interface CacheKeyData {
audience: string;
scope: string;
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PopupConfigOptions } from './global';

/**
* @ignore
*/
Expand Down
35 changes: 19 additions & 16 deletions src/global.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @ignore
*/
interface BaseLoginOptions {
export interface BaseLoginOptions {
/**
* - `'page'`: displays the UI with a full page view
* - `'popup'`: displays the UI with a popup window
Expand Down Expand Up @@ -61,7 +61,7 @@ interface BaseLoginOptions {
[key: string]: any;
}

interface Auth0ClientOptions extends BaseLoginOptions {
export interface Auth0ClientOptions extends BaseLoginOptions {
/**
* Your Auth0 account domain such as `'example.auth0.com'`,
* `'example.eu.auth0.com'` or , `'example.mycompany.com'`
Expand Down Expand Up @@ -90,7 +90,7 @@ interface Auth0ClientOptions extends BaseLoginOptions {
/**
* @ignore
*/
interface AuthorizeOptions extends BaseLoginOptions {
export interface AuthorizeOptions extends BaseLoginOptions {
response_type: string;
response_mode: string;
redirect_uri: string;
Expand All @@ -101,7 +101,7 @@ interface AuthorizeOptions extends BaseLoginOptions {
code_challenge_method: string;
}

interface RedirectLoginOptions extends BaseLoginOptions {
export interface RedirectLoginOptions extends BaseLoginOptions {
/**
* The URL where Auth0 will redirect your browser to with
* the authentication result. It must be whitelisted in
Expand All @@ -115,24 +115,24 @@ interface RedirectLoginOptions extends BaseLoginOptions {
appState?: any;
}

interface RedirectLoginResult {
export interface RedirectLoginResult {
/**
* State stored when the redirect request was made
*/
appState?: any;
}

interface PopupLoginOptions extends BaseLoginOptions {}
export interface PopupLoginOptions extends BaseLoginOptions {}

interface PopupConfigOptions {
export interface PopupConfigOptions {
/**
* The number of seconds to wait for a popup response before
* throwing a timeout error. Defaults to 60s
*/
timeoutInSeconds?: number;
}

interface GetUserOptions {
export interface GetUserOptions {
/**
* The scope that was used in the authentication request
*/
Expand All @@ -143,7 +143,7 @@ interface GetUserOptions {
audience: string;
}

interface getIdTokenClaimsOptions {
export interface GetIdTokenClaimsOptions {
/**
* The scope that was used in the authentication request
*/
Expand All @@ -154,7 +154,9 @@ interface getIdTokenClaimsOptions {
audience: string;
}

interface GetTokenSilentlyOptions extends GetUserOptions {
export type getIdTokenClaimsOptions = GetIdTokenClaimsOptions;

export interface GetTokenSilentlyOptions extends GetUserOptions {
/**
* When `true`, ignores the cache and always sends a
* request to Auth0.
Expand All @@ -177,9 +179,10 @@ interface GetTokenSilentlyOptions extends GetUserOptions {
*/
[key: string]: any;
}
interface GetTokenWithPopupOptions extends PopupLoginOptions {}

interface LogoutOptions {
export interface GetTokenWithPopupOptions extends PopupLoginOptions {}

export interface LogoutOptions {
/**
* The URL where Auth0 will redirect your browser to after the logout.
*
Expand Down Expand Up @@ -209,7 +212,7 @@ interface LogoutOptions {
/**
* @ignore
*/
interface AuthenticationResult {
export interface AuthenticationResult {
state: string;
code?: string;
error?: string;
Expand All @@ -219,7 +222,7 @@ interface AuthenticationResult {
/**
* @ignore
*/
interface OAuthTokenOptions {
export interface OAuthTokenOptions {
baseUrl: string;
client_id: string;
audience?: string;
Expand All @@ -230,7 +233,7 @@ interface OAuthTokenOptions {
/**
* @ignore
*/
interface JWTVerifyOptions {
export interface JWTVerifyOptions {
iss: string;
aud: string;
id_token: string;
Expand All @@ -241,7 +244,7 @@ interface JWTVerifyOptions {
/**
* @ignore
*/
interface IdToken {
export interface IdToken {
__raw: string;
name?: string;
given_name?: string;
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Auth0Client from './Auth0Client';
import * as ClientStorage from './storage';

//this is necessary to export the type definitions used in this file
import './global';
import { Auth0ClientOptions } from './global';

export default async function createAuth0Client(options: Auth0ClientOptions) {
if (!window.crypto && (<any>window).msCrypto) {
Expand Down Expand Up @@ -44,3 +44,5 @@ export default async function createAuth0Client(options: Auth0ClientOptions) {
}
return auth0;
}

export * from './global';
1 change: 1 addition & 0 deletions src/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { urlDecodeB64 } from './utils';
import { JWTVerifyOptions, IdToken } from './global';

const idTokendecoded = [
'iss',
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import fetch from 'unfetch';

import { DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS } from './constants';
import {
AuthenticationResult,
PopupConfigOptions,
OAuthTokenOptions
} from './global';

const dedupe = arr => arr.filter((x, i) => arr.indexOf(x) === i);

Expand Down

0 comments on commit 11f8348

Please sign in to comment.