From df1ba4bfe8c67d913cdb4b7afcce0ffe970f565e Mon Sep 17 00:00:00 2001 From: "Johannes C. Schneider" Date: Tue, 17 Dec 2019 19:31:15 +0100 Subject: [PATCH] [auth0] added user blocks functions (#40774) --- types/auth0/auth0-tests.ts | 52 ++++++++++++++++++++++++++++++++++++++ types/auth0/index.d.ts | 27 +++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/types/auth0/auth0-tests.ts b/types/auth0/auth0-tests.ts index 332d24aded..75b838f55e 100644 --- a/types/auth0/auth0-tests.ts +++ b/types/auth0/auth0-tests.ts @@ -517,3 +517,55 @@ management.getEmailTemplate({name: 'template_name'}).then(data => {console.log(d management.getEmailTemplate({name: 'template_name'}, (err, data) => {console.log(data)}); management.updateEmailTemplate({name: 'template_name'}, {type:'type'}).then(data => {console.log(data)}); management.updateEmailTemplate({name: 'template_name'}, {type:'type'}, (err, data) => {console.log(data)}); + +management.getUserBlocks({ id: 'user_id' }) + .then(response => { + response.blocked_for.forEach(blockedFor => console.log(`${blockedFor.identifier}:${blockedFor.ip}`)); + }) + .catch(err => console.log('Error: ' + err)); + +management.getUserBlocks({ id: 'user_id' }, (err, response) => { + if (err) { + console.log('Error: ' + err); + return; + } + response.blocked_for.forEach(blockedFor => console.log(`${blockedFor.identifier}:${blockedFor.ip}`)); +}); + +management.getUserBlocksByIdentifier({ identifier: 'email' }) + .then(response => { + response.blocked_for.forEach(blockedFor => console.log(`${blockedFor.identifier}:${blockedFor.ip}`)); + }) + .catch(err => console.log('Error: ' + err)); + +management.getUserBlocksByIdentifier({ identifier: 'email' }, (err, response) => { + if (err) { + console.log('Error: ' + err); + return; + } + response.blocked_for.forEach(blockedFor => console.log(`${blockedFor.identifier}:${blockedFor.ip}`)); +}); + +management.unblockUser({ id: 'user_id' }) + .then(response => console.log(response)) + .catch(err => console.log('Error: ' + err)); + +management.unblockUser({ id: 'user_id' }, (err, response) => { + if (err) { + console.log('Error: ' + err); + return; + } + console.log(response); +}); + +management.unblockUserByIdentifier({ identifier: 'email' }) + .then(response => console.log(response)) + .catch(err => console.log('Error: ' + err)); + +management.unblockUserByIdentifier({ identifier: 'email' }, (err, response) => { + if (err) { + console.log('Error: ' + err); + return; + } + console.log(response); +}); diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index a07fa4ff59..e94652c44f 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for auth0 2.9.4 +// Type definitions for auth0 2.20.0 // Project: https://github.com/auth0/node-auth0 // Definitions by: Seth Westphal // Ian Howe @@ -6,6 +6,7 @@ // Dan Rumney // Peter // Anthony Messerschmidt +// Johannes Schneider // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -782,6 +783,20 @@ export interface GetClientsOptions { app_type?: ClientAppType[]; } +export interface ObjectWithIdentifier { + identifier: string; +} + +export interface BlockedForEntry { + identifier: string; + ip?: string; +} + +export interface UserBlocks { + blocked_for: BlockedForEntry[]; +} + + export class AuthenticationClient { // Members @@ -1017,6 +1032,16 @@ export class ManagementClient { assignPermissionsToUser(params: ObjectWithId, data: PermissionsData): Promise; assignPermissionsToUser(params: ObjectWithId, data: PermissionsData, cb: (err: Error) => void): void; + // User Blocks + getUserBlocks(params: ObjectWithId): Promise; + getUserBlocks(params: ObjectWithId, cb: (err: Error, response: UserBlocks) => void): void; + getUserBlocksByIdentifier(params: ObjectWithIdentifier): Promise; + getUserBlocksByIdentifier(params: ObjectWithIdentifier, cb: (err: Error, response: UserBlocks) => void): void; + unblockUser(params: ObjectWithId): Promise; + unblockUser(params: ObjectWithId, cb: (err: Error, response: string) => void): void; + unblockUserByIdentifier(params: ObjectWithIdentifier): Promise; + unblockUserByIdentifier(params: ObjectWithIdentifier, cb: (err: Error, response: string) => void): void; + // Tokens getBlacklistedTokens(): Promise; getBlacklistedTokens(cb?: (err: Error, data: any) => void): void;