diff --git a/auth0-lock/auth0.lock-tests.ts b/auth0-lock/auth0.lock-tests.ts
index e62cd4ba2d..bba2fc8228 100644
--- a/auth0-lock/auth0.lock-tests.ts
+++ b/auth0-lock/auth0.lock-tests.ts
@@ -1,4 +1,4 @@
-///
+///
const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts
index da99744841..10ee3aac0d 100644
--- a/auth0-lock/index.d.ts
+++ b/auth0-lock/index.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Brian Caruso
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-///
+///
interface Auth0LockAdditionalSignUpFieldOption {
value: string;
diff --git a/auth0.widget/auth0.widget-tests.ts b/auth0.widget/auth0.widget-tests.ts
index 79f1a2a7a7..ec5502ca7e 100644
--- a/auth0.widget/auth0.widget-tests.ts
+++ b/auth0.widget/auth0.widget-tests.ts
@@ -1,4 +1,4 @@
-///
+///
var widget: Auth0WidgetStatic = new Auth0Widget({
diff --git a/auth0.widget/index.d.ts b/auth0.widget/index.d.ts
index ed6a2f341b..24d978ab9d 100644
--- a/auth0.widget/index.d.ts
+++ b/auth0.widget/index.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Robert McLaws
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-///
+///
interface Auth0WidgetStatic {
diff --git a/auth0/auth0-tests.ts b/auth0/auth0-tests.ts
index 7f48274eaf..391dee655a 100644
--- a/auth0/auth0-tests.ts
+++ b/auth0/auth0-tests.ts
@@ -1,23 +1,51 @@
///
-var auth0 = new Auth0({
- domain: 'mine.auth0.com',
- clientID: 'dsa7d77dsa7d7',
- callbackURL: 'http://my-app.com/callback',
- callbackOnLocationHash: true
+import * as auth0 from 'auth0';
+
+const management = new auth0.ManagementClient({
+ token: '{YOUR_API_V2_TOKEN}',
+ domain: '{YOUR_ACCOUNT}.auth0.com'
});
-auth0.login({
- connection: 'google-oauth2',
- popup: true,
- popupOptions: {
- width: 450,
- height: 800
- }
-}, (err, profile, idToken, accessToken, state) => {
- if (err) {
- alert("something went wrong: " + err.message);
- return;
- }
- alert('hello ' + profile.name);
- });
+const auth = new auth0.AuthenticationClient({
+ domain: '{YOUR_ACCOUNT}.auth0.com',
+ clientId: '{OPTIONAL_CLIENT_ID}'
+});
+
+// Using a callback.
+management.getUsers((err: Error, users: auth0.User[]) => {
+ if (err) {
+ // Handle error.
+ }
+ console.log(users);
+});
+
+// Using a Promise.
+management
+ .getUsers()
+ .then((users) => {
+ console.log(users);
+ })
+ .catch((err) => {
+ // Handle the error.
+ });
+
+management
+ .createUser({
+ connection: 'My-Connection',
+ email: 'hi@me.co',
+ }).then((user) => {
+ console.log(user);
+ }).catch((err) => {
+ // Handle the error.
+ });
+
+auth
+ .requestChangePasswordEmail({
+ connection: 'My-Connection',
+ email: 'hi@me.co',
+ }).then((response) => {
+ console.log(response);
+ }).catch((err) => {
+ // Handle the error.
+ });
diff --git a/auth0/index.d.ts b/auth0/index.d.ts
index 5ca8487f85..e367d30411 100644
--- a/auth0/index.d.ts
+++ b/auth0/index.d.ts
@@ -1,132 +1,95 @@
-// Type definitions for Auth0.js
-// Project: http://auth0.com
-// Definitions by: Robert McLaws
+// Type definitions for auth0 v2.3.1
+// Project: https://github.com/auth0/node-auth0
+// Definitions by: Seth Westphal
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-/** Extensions to the browser Window object. */
-interface Window {
- /** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
+///
+
+declare module "auth0" {
+
+ import * as Promise from 'bluebird';
+
+ export interface ManagementClientOptions {
token: string;
-}
+ domain?: string;
+ }
-/** This is the interface for the main Auth0 client. */
-interface Auth0Static {
-
- new(options: Auth0ClientOptions): Auth0Static;
- changePassword(options: any, callback?: Function): void;
- decodeJwt(jwt: string): any;
- login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
- loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
- loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
- loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
- logout(query: string): void;
- getConnections(callback?: Function): void;
- refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
- getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
- getProfile(id_token: string, callback?: Function): Auth0UserProfile;
- getSSOData(withActiveDirectories: any, callback?: Function): void;
- parseHash(hash: string): Auth0DecodedHash;
- signup(options: Auth0SignupOptions, callback: Function): void;
- validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
-}
-
-/** Represents constructor options for the Auth0 client. */
-interface Auth0ClientOptions {
- clientID: string;
- callbackURL: string;
- callbackOnLocationHash?: boolean;
- domain: string;
- forceJSONP?: boolean;
-}
-
-/** Represents a normalized UserProfile. */
-interface Auth0UserProfile {
- email: string;
- family_name: string;
- gender: string;
- given_name: string;
- locale: string;
- name: string;
- nickname: string;
- picture: string;
- user_id: string;
- /** Represents one or more Identities that may be associated with the User. */
- identities: Auth0Identity[];
- user_metadata?: any;
- app_metadata?: any;
-}
-
-/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
-interface MicrosoftUserProfile extends Auth0UserProfile {
- emails: string[];
-}
-
-/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
-interface Office365UserProfile extends Auth0UserProfile {
- tenantid: string;
- upn: string;
-}
-
-/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
-interface AdfsUserProfile extends Auth0UserProfile {
- issuer: string;
-}
-
-/** Represents multiple identities assigned to a user. */
-interface Auth0Identity {
- access_token: string;
+ export interface UserData {
connection: string;
- isSocial: boolean;
- provider: string;
- user_id: string;
-}
-
-interface Auth0DecodedHash {
- access_token: string;
- id_token: string;
- profile: Auth0UserProfile;
- state: any;
-}
-
-interface Auth0PopupOptions {
- width: number;
- height: number;
-}
-
-interface Auth0LoginOptions {
- auto_login?: boolean;
- connection?: string;
email?: string;
username?: string;
password?: string;
- popup?: boolean;
- popupOptions?: Auth0PopupOptions;
-}
+ phone_number?: string;
+ user_metadata?: {};
+ email_verified?: boolean;
+ app_metadata?: {};
+ }
-interface Auth0SignupOptions extends Auth0LoginOptions {
- auto_login: boolean;
-}
+ export interface GetUsersData {
+ per_page?: number;
+ page?: number;
+ include_totals?: boolean;
+ sort?: string;
+ connection?: string;
+ fields?: string;
+ include_fields?: boolean;
+ q?: string;
+ search_engine?: string;
+ }
-interface Auth0Error {
- code: any;
- details: any;
- name: string;
- message: string;
- status: any;
-}
+ export interface User {
+ email?: string;
+ email_verified?: boolean;
+ username?: string;
+ phone_number?: string;
+ phone_verified?: boolean;
+ user_id?: string;
+ created_at?: string;
+ updated_at?: string;
+ identities?: Identity[];
+ app_metadata?: {};
+ user_metadata?: {};
+ picture?: string;
+ name?: string;
+ nickname?: string;
+ multifactor?: string[];
+ last_ip?: string;
+ last_login?: string;
+ logins_count?: number;
+ blocked?: boolean;
+ }
-/** Represents the response from an API Token Delegation request. */
-interface Auth0DelegationToken {
- /** The length of time in seconds the token is valid for. */
- expires_in: string;
- /** The JWT for delegated access. */
- id_token: string;
- /** The type of token being returned. Possible values: "Bearer" */
- token_type: string;
-}
+ export interface Identity {
+ connection: string;
+ user_id: string;
+ provider: string;
+ isSocial: boolean;
+ }
-declare var Auth0: Auth0Static;
+ export class ManagementClient {
+ constructor(options: ManagementClientOptions);
+
+ getUsers(params?: GetUsersData): Promise;
+ getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void;
+ createUser(data: UserData): Promise;
+ createUser(data: UserData, cb: (err: Error, data: User) => void): void;
+ }
+
+ export interface AuthenticationClientOptions {
+ clientId?: string;
+ domain: string;
+ }
+
+ export interface RequestChangePasswordEmailData {
+ connection: string;
+ email: string;
+ }
+
+ export class AuthenticationClient {
+ constructor(options: AuthenticationClientOptions);
+
+ requestChangePasswordEmail(data: RequestChangePasswordEmailData): Promise;
+ requestChangePasswordEmail(data: RequestChangePasswordEmailData, cb: (err: Error, message: string) => void): void;
+ }
-declare module "auth0" {
- export = Auth0
}
diff --git a/eventemitter2/index.d.ts b/eventemitter2/index.d.ts
index 39a349c6b6..de1be0d064 100644
--- a/eventemitter2/index.d.ts
+++ b/eventemitter2/index.d.ts
@@ -43,7 +43,7 @@ declare class EventEmitter2 {
* @param event
* @param listener
*/
- on(event: string, listener: Function): EventEmitter2;
+ on(event: string | string[], listener: Function): EventEmitter2;
/**
* Adds a listener that will be fired when any event is emitted.
@@ -128,7 +128,7 @@ declare class EventEmitter2 {
* @param event
* @param args
*/
- emit(event: string, ...args: any[]): boolean;
+ emit(event: string | string[], ...args: any[]): boolean;
/**
* Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.
@@ -156,7 +156,7 @@ declare module "eventemitter2" {
* @param event
* @param listener
*/
- on(event: string, listener: Function): EventEmitter2;
+ on(event: string | string[], listener: Function): EventEmitter2;
/**
* Adds a listener that will be fired when any event is emitted.
@@ -241,7 +241,7 @@ declare module "eventemitter2" {
* @param event
* @param args
*/
- emit(event: string, ...args: any[]): boolean;
+ emit(event: string | string[], ...args: any[]): boolean;
/**
* Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.
diff --git a/express-serve-static-core/index.d.ts b/express-serve-static-core/index.d.ts
index c8bfaf7f29..707b408714 100644
--- a/express-serve-static-core/index.d.ts
+++ b/express-serve-static-core/index.d.ts
@@ -22,7 +22,7 @@ declare module "express-serve-static-core" {
}
interface RequestHandler {
- (req: Request, res: Response, next: NextFunction): any;
+ (req: Request, res: Response, next?: NextFunction): any;
}
interface ErrorRequestHandler {
diff --git a/express-validator/express-validator-tests.ts b/express-validator/express-validator-tests.ts
index 8f4f9bab9c..9c374d9948 100644
--- a/express-validator/express-validator-tests.ts
+++ b/express-validator/express-validator-tests.ts
@@ -13,19 +13,23 @@ app.post('/:urlparam', function(req: express.Request, res: express.Response) {
// Similarly checkParams only checks in req.params (URL params) and
// checkQuery only checks req.query (GET params).
req.checkBody('postparam', 'Invalid postparam').notEmpty().isInt();
- req.checkParams('urlparam', 'Invalid urlparam').isAlpha();
+ req.checkParams('urlparam', 'Invalid urlparam').isAlpha().matches(/test?/i).matches('test?', 'i');
req.checkQuery('getparam', 'Invalid getparam').isInt();
- req.checkHeader('testHeader', 'Invalid testHeader').isLowercase().isUppercase();
- req.checkFiles('testFiles', 'Invalid testFiles').isUrl();
-
+ req.checkHeaders('testHeader', 'Invalid testHeader').isLowercase().isUppercase();
+ req.checkFiles('testFiles', 'Invalid testFiles').isURL();
// OR assert can be used to check on all 3 types of params.
// req.assert('postparam', 'Invalid postparam').notEmpty().isInt();
// req.assert('urlparam', 'Invalid urlparam').isAlpha();
// req.assert('getparam', 'Invalid getparam').isInt();
- req.sanitize('postparam').toBoolean();
req.filter('postparam').toBoolean();
+ req.sanitize('postparam').blacklist('t').blacklist(['