@nebular/auth
- Version 14.0.2
- Published
- 1.66 MB
- 1 dependency
- MIT license
Install
npm i @nebular/auth
yarn add @nebular/auth
pnpm add @nebular/auth
Overview
@nebular/auth
Index
Variables
Functions
Classes
NbOAuth2AuthStrategy
- addCredentialsToParams()
- authenticate()
- authorizeRedirect()
- buildAuthHeader()
- buildCodeRequestData()
- buildPasswordRequestData()
- buildRedirectUrl()
- buildRefreshRequestData()
- cleanParams()
- clientAuthMethod
- createRefreshedToken()
- defaultOptions
- getAuthorizationResult()
- getHeaders()
- handleResponseError()
- http
- isRedirectResult()
- logout()
- ɵfac
- ɵprov
- parseHashAsQueryParams()
- passwordToken()
- redirectResultHandlers
- redirectResults
- refreshToken()
- register()
- requestPassword()
- requestToken()
- resetPassword()
- responseType
- route
- setup()
- urlEncodeParameters()
- window
Interfaces
Enums
Type Aliases
Variables
variable auth2StrategyOptions
const auth2StrategyOptions: NbOAuth2AuthStrategyOptions;
variable defaultAuthOptions
const defaultAuthOptions: any;
variable dummyStrategyOptions
const dummyStrategyOptions: NbDummyAuthStrategyOptions;
variable NB_AUTH_FALLBACK_TOKEN
const NB_AUTH_FALLBACK_TOKEN: InjectionToken<NbAuthTokenClass<NbAuthToken>>;
variable NB_AUTH_INTERCEPTOR_HEADER
const NB_AUTH_INTERCEPTOR_HEADER: InjectionToken<string>;
variable NB_AUTH_OPTIONS
const NB_AUTH_OPTIONS: InjectionToken<NbAuthOptions>;
variable NB_AUTH_STRATEGIES
const NB_AUTH_STRATEGIES: InjectionToken<NbAuthStrategies>;
variable NB_AUTH_TOKEN_INTERCEPTOR_FILTER
const NB_AUTH_TOKEN_INTERCEPTOR_FILTER: InjectionToken< (req: HttpRequest<any>) => boolean>;
variable NB_AUTH_TOKENS
const NB_AUTH_TOKENS: InjectionToken<NbAuthTokenClass<NbAuthToken>[]>;
variable NB_AUTH_USER_OPTIONS
const NB_AUTH_USER_OPTIONS: InjectionToken<NbAuthOptions>;
variable passwordStrategyOptions
const passwordStrategyOptions: NbPasswordAuthStrategyOptions;
variable routes
const routes: Routes;
Functions
function b64decode
b64decode: (str: string) => string;
function b64DecodeUnicode
b64DecodeUnicode: (str: any) => string;
function decodeJwtPayload
decodeJwtPayload: (payload: string) => any;
function deepExtend
deepExtend: (...objects: any[]) => any;
Extending object that entered in first argument.
Returns extended object or false if have no target object or incorrect type.
If you wish to clone source object (without modify it), just use empty new object as first argument, like this: deepExtend({}, yourObj_1, [yourObj_N]);
function getDeepFromObject
getDeepFromObject: (object: {}, name: string, defaultValue?: any) => any;
function nbAuthCreateToken
nbAuthCreateToken: <T extends NbAuthToken>( tokenClass: NbAuthTokenClass<T>, token: any, ownerStrategyName: string, createdAt?: Date) => T;
function nbNoOpInterceptorFilter
nbNoOpInterceptorFilter: (req: HttpRequest<any>) => boolean;
function nbOptionsFactory
nbOptionsFactory: (options: any) => any;
function nbStrategiesFactory
nbStrategiesFactory: ( options: NbAuthOptions, injector: Injector) => NbAuthStrategy[];
function nbTokensFactory
nbTokensFactory: (strategies: NbAuthStrategy[]) => NbAuthTokenClass[];
function urlBase64Decode
urlBase64Decode: (str: string) => string;
Classes
class NbAuthBlockComponent
class NbAuthBlockComponent {}
class NbAuthComponent
class NbAuthComponent implements OnDestroy {}
constructor
constructor(auth: NbAuthService, location: Location);
property auth
protected auth: NbAuthService;
property authenticated
authenticated: boolean;
property location
protected location: Location;
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< NbAuthComponent, 'nb-auth', never, {}, {}, never, never, false, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthComponent, never>;
property subscription
subscription: any;
property token
token: string;
method back
back: () => boolean;
method ngOnDestroy
ngOnDestroy: () => void;
class NbAuthEmptyTokenError
class NbAuthEmptyTokenError extends NbAuthIllegalTokenError {}
constructor
constructor(message: string);
class NbAuthIllegalJWTTokenError
class NbAuthIllegalJWTTokenError extends NbAuthIllegalTokenError {}
constructor
constructor(message: string);
class NbAuthIllegalTokenError
class NbAuthIllegalTokenError extends Error {}
constructor
constructor(message: string);
class NbAuthJWTInterceptor
class NbAuthJWTInterceptor implements HttpInterceptor {}
constructor
constructor(injector: Injector, filter: any);
property authService
readonly authService: NbAuthService;
property filter
protected filter: any;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthJWTInterceptor, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbAuthJWTInterceptor>;
method intercept
intercept: ( req: HttpRequest<any>, next: HttpHandler) => Observable<HttpEvent<any>>;
class NbAuthJWTToken
class NbAuthJWTToken extends NbAuthSimpleToken {}
Wrapper for JWT token with additional methods.
property NAME
static NAME: string;
method getTokenExpDate
getTokenExpDate: () => Date;
Returns expiration date
Returns
Date
method isValid
isValid: () => boolean;
Is data expired
Returns
{boolean}
method parsePayload
protected parsePayload: () => void;
Returns payload object
Returns
any
method prepareCreatedAt
protected prepareCreatedAt: (date: Date) => Date;
for JWT token, the iat (issued at) field of the token payload contains the creation Date
class NbAuthModule
class NbAuthModule {}
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthModule, never>;
property ɵinj
static ɵinj: i0.ɵɵInjectorDeclaration<NbAuthModule>;
property ɵmod
static ɵmod: i0.ɵɵNgModuleDeclaration< NbAuthModule, [ typeof i1.NbAuthComponent, typeof i2.NbAuthBlockComponent, typeof i3.NbLoginComponent, typeof i4.NbRegisterComponent, typeof i5.NbRequestPasswordComponent, typeof i6.NbResetPasswordComponent, typeof i7.NbLogoutComponent ], [any, any, any, any, any, any, any, any, any, any], [ typeof i1.NbAuthComponent, typeof i2.NbAuthBlockComponent, typeof i3.NbLoginComponent, typeof i4.NbRegisterComponent, typeof i5.NbRequestPasswordComponent, typeof i6.NbResetPasswordComponent, typeof i7.NbLogoutComponent ]>;
method forRoot
static forRoot: ( nbAuthOptions?: NbAuthOptions) => ModuleWithProviders<NbAuthModule>;
class NbAuthOAuth2JWTToken
class NbAuthOAuth2JWTToken extends NbAuthOAuth2Token {}
Wrapper for OAuth2 token embedding JWT tokens
property accessTokenPayload
protected accessTokenPayload: any;
property NAME
static NAME: string;
method getAccessTokenPayload
getAccessTokenPayload: () => any;
Returns access token payload
Returns
any
method getTokenExpDate
getTokenExpDate: () => Date;
Returns expiration date : - exp if set, - super.getExpDate() otherwise
Returns
Date
method isValid
isValid: () => boolean;
Is token valid
Returns
{boolean}
method parseAccessTokenPayload
protected parseAccessTokenPayload: () => any;
method parsePayload
protected parsePayload: () => void;
method prepareCreatedAt
protected prepareCreatedAt: (date: Date) => Date;
for Oauth2 JWT token, the iat (issued at) field of the access_token payload
class NbAuthOAuth2Token
class NbAuthOAuth2Token extends NbAuthSimpleToken {}
Wrapper for OAuth2 token whose access_token is a JWT Token
constructor
constructor( data: string | { [key: string]: string | number }, ownerStrategyName: string, createdAt?: Date);
property NAME
static NAME: string;
method getRefreshToken
getRefreshToken: () => string;
Returns the refresh token
Returns
string
method getTokenExpDate
getTokenExpDate: () => Date;
Returns expiration date
Returns
Date
method getType
getType: () => string;
Returns the token type
Returns
string
method getValue
getValue: () => string;
Returns the token value
Returns
string
method isValid
isValid: () => boolean;
Is data expired
Returns
{boolean}
method parsePayload
protected parsePayload: () => void;
Parses token payload
Returns
any
method setRefreshToken
setRefreshToken: (refreshToken: string) => void;
put refreshToken in the token payload
Parameter refreshToken
method toString
toString: () => string;
Convert to string
Returns
{string}
class NbAuthResult
class NbAuthResult {}
constructor
constructor( success: boolean, response?: any, redirect?: any, errors?: any, messages?: any, token?: NbAuthToken);
property errors
protected errors: string[];
property messages
protected messages: string[];
property redirect
protected redirect?: any;
property response
protected response?: any;
property success
protected success: boolean;
property token
protected token: NbAuthToken;
method getErrors
getErrors: () => string[];
method getMessages
getMessages: () => string[];
method getRedirect
getRedirect: () => string;
method getResponse
getResponse: () => any;
method getToken
getToken: () => NbAuthToken;
method isFailure
isFailure: () => boolean;
method isSuccess
isSuccess: () => boolean;
class NbAuthService
class NbAuthService {}
Common authentication service. Should be used to as an interlayer between UI Components and Auth Strategy.
constructor
constructor(tokenService: NbTokenService, strategies: any);
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthService, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbAuthService>;
property strategies
protected strategies: any;
property tokenService
protected tokenService: NbTokenService;
method authenticate
authenticate: (strategyName: string, data?: any) => Observable<NbAuthResult>;
Authenticates with the selected strategy Stores received token in the token storage
Example: authenticate('email', {email: 'email@example.com', password: 'test'})
Parameter strategyName
Parameter data
Returns
{Observable}
method getStrategy
protected getStrategy: (strategyName: string) => NbAuthStrategy;
Get registered strategy by name
Example: getStrategy('email')
Parameter provider
Returns
{NbAbstractAuthProvider}
method getToken
getToken: () => Observable<NbAuthToken>;
Retrieves current authenticated token stored
Returns
{Observable}
method isAuthenticated
isAuthenticated: () => Observable<boolean>;
Returns true if auth token is present in the token storage
Returns
{Observable}
method isAuthenticatedOrRefresh
isAuthenticatedOrRefresh: () => Observable<boolean>;
Returns true if valid auth token is present in the token storage. If not, calls the strategy refreshToken, and returns isAuthenticated() if success, false otherwise
Returns
{Observable}
method logout
logout: (strategyName: string) => Observable<NbAuthResult>;
Sign outs with the selected strategy Removes token from the token storage
Example: logout('email')
Parameter strategyName
Returns
{Observable}
method onAuthenticationChange
onAuthenticationChange: () => Observable<boolean>;
Returns authentication status stream
Returns
{Observable}
method onTokenChange
onTokenChange: () => Observable<NbAuthToken>;
Returns tokens stream
Returns
{Observable}
method refreshToken
refreshToken: (strategyName: string, data?: any) => Observable<NbAuthResult>;
Sends a refresh token request Stores received token in the token storage
Example: refreshToken('email', {token: token})
Parameter strategyName
Parameter data
Returns
{Observable}
method register
register: (strategyName: string, data?: any) => Observable<NbAuthResult>;
Registers with the selected strategy Stores received token in the token storage
Example: register('email', {email: 'email@example.com', name: 'Some Name', password: 'test'})
Parameter strategyName
Parameter data
Returns
{Observable}
method requestPassword
requestPassword: (strategyName: string, data?: any) => Observable<NbAuthResult>;
Sends forgot password request to the selected strategy
Example: requestPassword('email', {email: 'email@example.com'})
Parameter strategyName
Parameter data
Returns
{Observable}
method resetPassword
resetPassword: (strategyName: string, data?: any) => Observable<NbAuthResult>;
Tries to reset password with the selected strategy
Example: resetPassword('email', {newPassword: 'test'})
Parameter strategyName
Parameter data
Returns
{Observable}
class NbAuthSimpleInterceptor
class NbAuthSimpleInterceptor implements HttpInterceptor {}
constructor
constructor(injector: Injector, headerName?: string);
property authService
readonly authService: NbAuthService;
property headerName
protected headerName: string;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthSimpleInterceptor, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbAuthSimpleInterceptor>;
method intercept
intercept: ( req: HttpRequest<any>, next: HttpHandler) => Observable<HttpEvent<any>>;
class NbAuthSimpleToken
class NbAuthSimpleToken extends NbAuthToken {}
Wrapper for simple (text) token
constructor
constructor(token: any, ownerStrategyName: string, createdAt?: Date);
property createdAt
protected createdAt?: Date;
property NAME
static NAME: string;
property ownerStrategyName
protected readonly ownerStrategyName: string;
property token
protected readonly token: any;
method getCreatedAt
getCreatedAt: () => Date;
Returns the token's creation date
Returns
{Date}
method getOwnerStrategyName
getOwnerStrategyName: () => string;
method getValue
getValue: () => string;
Returns the token value
Returns
string
method isValid
isValid: () => boolean;
Is non empty and valid
Returns
{boolean}
method parsePayload
protected parsePayload: () => any;
method prepareCreatedAt
protected prepareCreatedAt: (date: Date) => Date;
method toString
toString: () => string;
Validate value and convert to string, if value is not valid return empty string
Returns
{string}
class NbAuthStrategy
abstract class NbAuthStrategy {}
property defaultOptions
protected defaultOptions: NbAuthStrategyOptions;
property options
protected options: NbAuthStrategyOptions;
method authenticate
abstract authenticate: (data?: any) => Observable<NbAuthResult>;
method createFailResponse
protected createFailResponse: (data?: any) => HttpResponse<Object>;
method createSuccessResponse
protected createSuccessResponse: (data?: any) => HttpResponse<Object>;
method createToken
createToken: <T extends NbAuthToken>( value: any, failWhenInvalidToken?: boolean) => T;
method getActionEndpoint
protected getActionEndpoint: (action: string) => string;
method getHeaders
protected getHeaders: () => HttpHeaders;
method getName
getName: () => string;
method getOption
getOption: (key: string) => any;
method logout
abstract logout: () => Observable<NbAuthResult>;
method refreshToken
abstract refreshToken: (data?: any) => Observable<NbAuthResult>;
method register
abstract register: (data?: any) => Observable<NbAuthResult>;
method requestPassword
abstract requestPassword: (data?: any) => Observable<NbAuthResult>;
method resetPassword
abstract resetPassword: (data?: any) => Observable<NbAuthResult>;
method setOptions
setOptions: (options: any) => void;
class NbAuthStrategyOptions
class NbAuthStrategyOptions {}
class NbAuthToken
abstract class NbAuthToken {}
property payload
protected payload: any;
method getCreatedAt
abstract getCreatedAt: () => Date;
method getName
getName: () => string;
method getOwnerStrategyName
abstract getOwnerStrategyName: () => string;
method getPayload
getPayload: () => any;
method getValue
abstract getValue: () => string;
method isValid
abstract isValid: () => boolean;
method toString
abstract toString: () => string;
class NbAuthTokenNotFoundError
class NbAuthTokenNotFoundError extends Error {}
constructor
constructor(message: string);
class NbAuthTokenParceler
class NbAuthTokenParceler {}
Creates a token parcel which could be stored/restored
constructor
constructor( fallbackClass: NbAuthTokenClass<NbAuthToken>, tokenClasses: NbAuthTokenClass<NbAuthToken>[]);
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbAuthTokenParceler, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbAuthTokenParceler>;
method getClassByName
protected getClassByName: (name: any) => NbAuthTokenClass;
method parseTokenPack
protected parseTokenPack: (value: any) => NbTokenPack;
method unwrap
unwrap: (value: string) => NbAuthToken;
method wrap
wrap: (token: NbAuthToken) => string;
class NbDummyAuthStrategy
class NbDummyAuthStrategy extends NbAuthStrategy {}
Dummy auth strategy. Could be useful for auth setup when backend is not available yet.
Strategy settings.
export class NbDummyAuthStrategyOptions extends NbAuthStrategyOptions {name = 'dummy';token = {class: NbAuthSimpleToken,};delay? = 1000;alwaysFail? = false;}
property defaultOptions
protected defaultOptions: NbDummyAuthStrategyOptions;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbDummyAuthStrategy, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbDummyAuthStrategy>;
method authenticate
authenticate: (data?: any) => Observable<NbAuthResult>;
method createDummyResult
protected createDummyResult: (data?: any) => NbAuthResult;
method logout
logout: (data?: any) => Observable<NbAuthResult>;
method refreshToken
refreshToken: (data?: any) => Observable<NbAuthResult>;
method register
register: (data?: any) => Observable<NbAuthResult>;
method requestPassword
requestPassword: (data?: any) => Observable<NbAuthResult>;
method resetPassword
resetPassword: (data?: any) => Observable<NbAuthResult>;
method setup
static setup: ( options: NbDummyAuthStrategyOptions) => [NbAuthStrategyClass, NbDummyAuthStrategyOptions];
class NbDummyAuthStrategyOptions
class NbDummyAuthStrategyOptions extends NbAuthStrategyOptions {}
property alwaysFail
alwaysFail?: boolean;
property delay
delay?: number;
property token
token?: NbStrategyToken;
class NbLoginComponent
class NbLoginComponent {}
constructor
constructor( service: NbAuthService, options: {}, cd: ChangeDetectorRef, router: Router);
property cd
protected cd: ChangeDetectorRef;
property errors
errors: string[];
property messages
messages: string[];
property options
protected options: {};
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< NbLoginComponent, 'nb-login', never, {}, {}, never, never, false, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbLoginComponent, never>;
property redirectDelay
redirectDelay: number;
property rememberMe
rememberMe: boolean;
property router
protected router: Router;
property service
protected service: NbAuthService;
property showMessages
showMessages: any;
property socialLinks
socialLinks: NbAuthSocialLink[];
property strategy
strategy: string;
property submitted
submitted: boolean;
property user
user: any;
method getConfigValue
getConfigValue: (key: string) => any;
method login
login: () => void;
class NbLogoutComponent
class NbLogoutComponent implements OnInit {}
constructor
constructor(service: NbAuthService, options: {}, router: Router);
property options
protected options: {};
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< NbLogoutComponent, 'nb-logout', never, {}, {}, never, never, false, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbLogoutComponent, never>;
property redirectDelay
redirectDelay: number;
property router
protected router: Router;
property service
protected service: NbAuthService;
property strategy
strategy: string;
method getConfigValue
getConfigValue: (key: string) => any;
method logout
logout: (strategy: string) => void;
method ngOnInit
ngOnInit: () => void;
class NbOAuth2AuthStrategy
class NbOAuth2AuthStrategy extends NbAuthStrategy {}
OAuth2 authentication strategy.
Strategy settings:
export enum NbOAuth2ResponseType {CODE = 'code',TOKEN = 'token',}export enum NbOAuth2GrantType {AUTHORIZATION_CODE = 'authorization_code',PASSWORD = 'password',REFRESH_TOKEN = 'refresh_token',}export class NbOAuth2AuthStrategyOptions {name: string;baseEndpoint?: string = '';clientId: string = '';clientSecret: string = '';clientAuthMethod: string = NbOAuth2ClientAuthMethod.NONE;redirect?: { success?: string; failure?: string } = {success: '/',failure: null,};defaultErrors?: any[] = ['Something went wrong, please try again.'];defaultMessages?: any[] = ['You have been successfully authenticated.'];authorize?: {endpoint?: string;redirectUri?: string;responseType?: string;requireValidToken: true,scope?: string;state?: string;params?: { [key: string]: string };} = {endpoint: 'authorize',responseType: NbOAuth2ResponseType.CODE,};token?: {endpoint?: string;grantType?: string;requireValidToken: true,redirectUri?: string;scope?: string;class: NbAuthTokenClass,} = {endpoint: 'token',grantType: NbOAuth2GrantType.AUTHORIZATION_CODE,class: NbAuthOAuth2Token,};refresh?: {endpoint?: string;grantType?: string;scope?: string;requireValidToken: true,} = {endpoint: 'token',grantType: NbOAuth2GrantType.REFRESH_TOKEN,};}
constructor
constructor(http: HttpClient, route: ActivatedRoute, window: any);
property clientAuthMethod
readonly clientAuthMethod: any;
property defaultOptions
protected defaultOptions: NbOAuth2AuthStrategyOptions;
property http
protected http: HttpClient;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbOAuth2AuthStrategy, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbOAuth2AuthStrategy>;
property redirectResultHandlers
protected redirectResultHandlers: { [key: string]: Function };
property redirectResults
protected redirectResults: { [key: string]: Function };
property responseType
readonly responseType: any;
property route
protected route: ActivatedRoute;
property window
protected window: any;
method addCredentialsToParams
protected addCredentialsToParams: (params: any) => any;
method authenticate
authenticate: (data?: any) => Observable<NbAuthResult>;
method authorizeRedirect
protected authorizeRedirect: () => void;
method buildAuthHeader
protected buildAuthHeader: () => HttpHeaders | undefined;
method buildCodeRequestData
protected buildCodeRequestData: (code: string) => any;
method buildPasswordRequestData
protected buildPasswordRequestData: ( username: string, password: string) => string;
method buildRedirectUrl
protected buildRedirectUrl: () => string;
method buildRefreshRequestData
protected buildRefreshRequestData: (token: NbAuthRefreshableToken) => any;
method cleanParams
protected cleanParams: (params: any) => any;
method createRefreshedToken
protected createRefreshedToken: ( res: any, existingToken: NbAuthRefreshableToken, requireValidToken: boolean) => NbAuthToken;
method getAuthorizationResult
getAuthorizationResult: () => Observable<any>;
method getHeaders
protected getHeaders: () => HttpHeaders;
method handleResponseError
protected handleResponseError: (res: any) => Observable<NbAuthResult>;
method isRedirectResult
protected isRedirectResult: () => Observable<boolean>;
method logout
logout: () => Observable<NbAuthResult>;
method parseHashAsQueryParams
protected parseHashAsQueryParams: (hash: string) => { [key: string]: string };
method passwordToken
passwordToken: (username: string, password: string) => Observable<NbAuthResult>;
method refreshToken
refreshToken: (token: NbAuthRefreshableToken) => Observable<NbAuthResult>;
method register
register: (data?: any) => Observable<NbAuthResult>;
method requestPassword
requestPassword: (data?: any) => Observable<NbAuthResult>;
method requestToken
protected requestToken: (code: string) => Observable<NbAuthResult>;
method resetPassword
resetPassword: (data?: any) => Observable<NbAuthResult>;
method setup
static setup: ( options: NbOAuth2AuthStrategyOptions) => [NbAuthStrategyClass, NbOAuth2AuthStrategyOptions];
method urlEncodeParameters
protected urlEncodeParameters: (params: any) => string;
class NbOAuth2AuthStrategyOptions
class NbOAuth2AuthStrategyOptions extends NbAuthStrategyOptions {}
property authorize
authorize?: { endpoint?: string; redirectUri?: string; responseType?: string; requireValidToken?: boolean; scope?: string; state?: string; params?: { [key: string]: string };};
property baseEndpoint
baseEndpoint?: string;
property clientAuthMethod
clientAuthMethod?: string;
property clientId
clientId: string;
property clientSecret
clientSecret?: string;
property defaultErrors
defaultErrors?: any[];
property defaultMessages
defaultMessages?: any[];
property redirect
redirect?: { success?: string; failure?: string };
property refresh
refresh?: { endpoint?: string; grantType?: string; scope?: string; requireValidToken?: boolean;};
property token
token?: { endpoint?: string; grantType?: string; redirectUri?: string; scope?: string; requireValidToken?: boolean; class: NbAuthTokenClass;};
class NbPasswordAuthStrategy
class NbPasswordAuthStrategy extends NbAuthStrategy {}
The most common authentication provider for email/password strategy.
Strategy settings. Note, there is no need to copy over the whole object to change the settings you need. Also, this.getOption call won't work outside of the default options declaration (which is inside of the
NbPasswordAuthStrategy
class), so you have to replace it with a custom helper function if you need it.export class NbPasswordAuthStrategyOptions extends NbAuthStrategyOptions {name: string;baseEndpoint? = '/api/auth/';login?: boolean | NbPasswordStrategyModule = {alwaysFail: false,endpoint: 'login',method: 'post',requireValidToken: true,redirect: {success: '/',failure: null,},defaultErrors: ['Login/Email combination is not correct, please try again.'],defaultMessages: ['You have been successfully logged in.'],};register?: boolean | NbPasswordStrategyModule = {alwaysFail: false,endpoint: 'register',method: 'post',requireValidToken: true,redirect: {success: '/',failure: null,},defaultErrors: ['Something went wrong, please try again.'],defaultMessages: ['You have been successfully registered.'],};requestPass?: boolean | NbPasswordStrategyModule = {endpoint: 'request-pass',method: 'post',redirect: {success: '/',failure: null,},defaultErrors: ['Something went wrong, please try again.'],defaultMessages: ['Reset password instructions have been sent to your email.'],};resetPass?: boolean | NbPasswordStrategyReset = {endpoint: 'reset-pass',method: 'put',redirect: {success: '/',failure: null,},resetPasswordTokenKey: 'reset_password_token',defaultErrors: ['Something went wrong, please try again.'],defaultMessages: ['Your password has been successfully changed.'],};logout?: boolean | NbPasswordStrategyReset = {alwaysFail: false,endpoint: 'logout',method: 'delete',redirect: {success: '/',failure: null,},defaultErrors: ['Something went wrong, please try again.'],defaultMessages: ['You have been successfully logged out.'],};refreshToken?: boolean | NbPasswordStrategyModule = {endpoint: 'refresh-token',method: 'post',requireValidToken: true,redirect: {success: null,failure: null,},defaultErrors: ['Something went wrong, please try again.'],defaultMessages: ['Your token has been successfully refreshed.'],};token?: NbPasswordStrategyToken = {class: NbAuthSimpleToken,key: 'data.token',getter: (module: string, res: HttpResponse<Object>, options: NbPasswordAuthStrategyOptions) => getDeepFromObject(res.body,options.token.key,),};errors?: NbPasswordStrategyMessage = {key: 'data.errors',getter: (module: string, res: HttpErrorResponse, options: NbPasswordAuthStrategyOptions) => getDeepFromObject(res.error,options.errors.key,options[module].defaultErrors,),};messages?: NbPasswordStrategyMessage = {key: 'data.messages',getter: (module: string, res: HttpResponse<Object>, options: NbPasswordAuthStrategyOptions) => getDeepFromObject(res.body,options.messages.key,options[module].defaultMessages,),};validation?: {password?: {required?: boolean;minLength?: number | null;maxLength?: number | null;regexp?: string | null;};email?: {required?: boolean;regexp?: string | null;};fullName?: {required?: boolean;minLength?: number | null;maxLength?: number | null;regexp?: string | null;};};}
constructor
constructor(http: HttpClient, route: ActivatedRoute);
property defaultOptions
protected defaultOptions: NbPasswordAuthStrategyOptions;
property http
protected http: HttpClient;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbPasswordAuthStrategy, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbPasswordAuthStrategy>;
method authenticate
authenticate: (data?: any) => Observable<NbAuthResult>;
method handleResponseError
protected handleResponseError: ( res: any, module: string) => Observable<NbAuthResult>;
method logout
logout: () => Observable<NbAuthResult>;
method refreshToken
refreshToken: (data?: any) => Observable<NbAuthResult>;
method register
register: (data?: any) => Observable<NbAuthResult>;
method requestPassword
requestPassword: (data?: any) => Observable<NbAuthResult>;
method resetPassword
resetPassword: (data?: any) => Observable<NbAuthResult>;
method setup
static setup: ( options: NbPasswordAuthStrategyOptions) => [NbAuthStrategyClass, NbPasswordAuthStrategyOptions];
class NbPasswordAuthStrategyOptions
class NbPasswordAuthStrategyOptions extends NbAuthStrategyOptions {}
property baseEndpoint
baseEndpoint?: string;
property errors
errors?: NbPasswordStrategyMessage;
property login
login?: boolean | NbPasswordStrategyModule;
property logout
logout?: boolean | NbPasswordStrategyReset;
property messages
messages?: NbPasswordStrategyMessage;
property refreshToken
refreshToken?: boolean | NbPasswordStrategyModule;
property register
register?: boolean | NbPasswordStrategyModule;
property requestPass
requestPass?: boolean | NbPasswordStrategyModule;
property resetPass
resetPass?: boolean | NbPasswordStrategyReset;
property token
token?: NbPasswordStrategyToken;
property validation
validation?: { password?: { required?: boolean; minLength?: number | null; maxLength?: number | null; regexp?: string | null; }; email?: { required?: boolean; regexp?: string | null }; fullName?: { required?: boolean; minLength?: number | null; maxLength?: number | null; regexp?: string | null; };};
class NbRegisterComponent
class NbRegisterComponent {}
constructor
constructor( service: NbAuthService, options: {}, cd: ChangeDetectorRef, router: Router);
property cd
protected cd: ChangeDetectorRef;
property errors
errors: string[];
property messages
messages: string[];
property options
protected options: {};
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< NbRegisterComponent, 'nb-register', never, {}, {}, never, never, false, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbRegisterComponent, never>;
property redirectDelay
redirectDelay: number;
property router
protected router: Router;
property service
protected service: NbAuthService;
property showMessages
showMessages: any;
property socialLinks
socialLinks: NbAuthSocialLink[];
property strategy
strategy: string;
property submitted
submitted: boolean;
property user
user: any;
method getConfigValue
getConfigValue: (key: string) => any;
method register
register: () => void;
class NbRequestPasswordComponent
class NbRequestPasswordComponent {}
constructor
constructor( service: NbAuthService, options: {}, cd: ChangeDetectorRef, router: Router);
property cd
protected cd: ChangeDetectorRef;
property errors
errors: string[];
property messages
messages: string[];
property options
protected options: {};
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< NbRequestPasswordComponent, 'nb-request-password-page', never, {}, {}, never, never, false, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbRequestPasswordComponent, never>;
property redirectDelay
redirectDelay: number;
property router
protected router: Router;
property service
protected service: NbAuthService;
property showMessages
showMessages: any;
property strategy
strategy: string;
property submitted
submitted: boolean;
property user
user: any;
method getConfigValue
getConfigValue: (key: string) => any;
method requestPass
requestPass: () => void;
class NbResetPasswordComponent
class NbResetPasswordComponent {}
constructor
constructor( service: NbAuthService, options: {}, cd: ChangeDetectorRef, router: Router);
property cd
protected cd: ChangeDetectorRef;
property errors
errors: string[];
property messages
messages: string[];
property options
protected options: {};
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< NbResetPasswordComponent, 'nb-reset-password-page', never, {}, {}, never, never, false, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbResetPasswordComponent, never>;
property redirectDelay
redirectDelay: number;
property router
protected router: Router;
property service
protected service: NbAuthService;
property showMessages
showMessages: any;
property strategy
strategy: string;
property submitted
submitted: boolean;
property user
user: any;
method getConfigValue
getConfigValue: (key: string) => any;
method resetPass
resetPass: () => void;
class NbTokenLocalStorage
class NbTokenLocalStorage extends NbTokenStorage {}
Service that uses browser localStorage as a storage.
The token storage is provided into auth module the following way:
{ provide: NbTokenStorage, useClass: NbTokenLocalStorage },If you need to change the storage behaviour or provide your own - just extend your class from basic
NbTokenStorage
orNbTokenLocalStorage
and provide in yourapp.module
:{ provide: NbTokenStorage, useClass: NbTokenCustomStorage },
constructor
constructor(parceler: NbAuthTokenParceler);
property key
protected key: string;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbTokenLocalStorage, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbTokenLocalStorage>;
method clear
clear: () => void;
Clears token from localStorage
method get
get: () => NbAuthToken;
Returns token from localStorage
Returns
{NbAuthToken}
method set
set: (token: NbAuthToken) => void;
Sets token to localStorage
Parameter token
class NbTokenService
class NbTokenService {}
Service that allows you to manage authentication token - get, set, clear and also listen to token changes over time.
constructor
constructor(tokenStorage: NbTokenStorage);
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<NbTokenService, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<NbTokenService>;
property token$
protected token$: BehaviorSubject<NbAuthToken>;
property tokenStorage
protected tokenStorage: NbTokenStorage;
method clear
clear: () => Observable<null>;
Removes the token and published token value
Returns
{Observable}
method get
get: () => Observable<NbAuthToken>;
Returns observable of current token
Returns
{Observable}
method publishStoredToken
protected publishStoredToken: () => void;
method set
set: (token: NbAuthToken) => Observable<null>;
Sets a token into the storage. This method is used by the NbAuthService automatically.
Parameter token
Returns
{Observable}
method tokenChange
tokenChange: () => Observable<NbAuthToken>;
Publishes token when it changes.
Returns
{Observable}
class NbTokenStorage
abstract class NbTokenStorage {}
class NbUser
class NbUser {}
constructor
constructor( id?: number, email?: string, password?: string, rememberMe?: boolean, terms?: boolean, confirmPassword?: string, fullName?: string);
property confirmPassword
confirmPassword?: string;
property email
email?: string;
property fullName
fullName?: string;
property id
id?: number;
property password
password?: string;
property rememberMe
rememberMe?: boolean;
property terms
terms?: boolean;
Interfaces
interface NbAuthOptions
interface NbAuthOptions {}
property forms
forms?: any;
property strategies
strategies?: NbAuthStrategies;
interface NbAuthRefreshableToken
interface NbAuthRefreshableToken {}
method getRefreshToken
getRefreshToken: () => string;
method setRefreshToken
setRefreshToken: (refreshToken: string) => any;
interface NbAuthSocialLink
interface NbAuthSocialLink {}
interface NbAuthTokenClass
interface NbAuthTokenClass<T = NbAuthToken> {}
property NAME
NAME: string;
construct signature
new (raw: any, strategyName: string, expDate?: Date): T;
interface NbPasswordStrategyMessage
interface NbPasswordStrategyMessage {}
interface NbPasswordStrategyModule
interface NbPasswordStrategyModule {}
property alwaysFail
alwaysFail?: boolean;
property defaultErrors
defaultErrors?: string[];
property defaultMessages
defaultMessages?: string[];
property endpoint
endpoint?: string;
property method
method?: string;
property redirect
redirect?: { success?: string | null; failure?: string | null;};
property requireValidToken
requireValidToken?: boolean;
interface NbPasswordStrategyReset
interface NbPasswordStrategyReset extends NbPasswordStrategyModule {}
property resetPasswordTokenKey
resetPasswordTokenKey?: string;
interface NbPasswordStrategyToken
interface NbPasswordStrategyToken {}
interface NbStrategyToken
interface NbStrategyToken {}
property class
class?: NbAuthTokenClass;
index signature
[key: string]: any;
interface NbTokenPack
interface NbTokenPack {}
property createdAt
createdAt: Number;
property name
name: string;
property ownerStrategyName
ownerStrategyName: string;
property value
value: string;
Enums
enum NbOAuth2ClientAuthMethod
enum NbOAuth2ClientAuthMethod { NONE = 'none', BASIC = 'basic', REQUEST_BODY = 'request-body',}
enum NbOAuth2GrantType
enum NbOAuth2GrantType { AUTHORIZATION_CODE = 'authorization_code', PASSWORD = 'password', REFRESH_TOKEN = 'refresh_token',}
member AUTHORIZATION_CODE
AUTHORIZATION_CODE = 'authorization_code'
member PASSWORD
PASSWORD = 'password'
member REFRESH_TOKEN
REFRESH_TOKEN = 'refresh_token'
enum NbOAuth2ResponseType
enum NbOAuth2ResponseType { CODE = 'code', TOKEN = 'token',}
Type Aliases
type NbAuthStrategies
type NbAuthStrategies = [NbAuthStrategyClass, NbAuthStrategyOptions][];
type NbAuthStrategyClass
type NbAuthStrategyClass = new (...params: any[]) => NbAuthStrategy;
Package Files (29)
- auth.module.d.ts
- auth.options.d.ts
- auth.routes.d.ts
- components/auth-block/auth-block.component.d.ts
- components/auth.component.d.ts
- components/login/login.component.d.ts
- components/logout/logout.component.d.ts
- components/register/register.component.d.ts
- components/request-password/request-password.component.d.ts
- components/reset-password/reset-password.component.d.ts
- helpers.d.ts
- index.d.ts
- models/user.d.ts
- services/auth-result.d.ts
- services/auth.service.d.ts
- services/interceptors/jwt-interceptor.d.ts
- services/interceptors/simple-interceptor.d.ts
- services/token/token-parceler.d.ts
- services/token/token-storage.d.ts
- services/token/token.d.ts
- services/token/token.service.d.ts
- strategies/auth-strategy-options.d.ts
- strategies/auth-strategy.d.ts
- strategies/dummy/dummy-strategy-options.d.ts
- strategies/dummy/dummy-strategy.d.ts
- strategies/oauth2/oauth2-strategy.d.ts
- strategies/oauth2/oauth2-strategy.options.d.ts
- strategies/password/password-strategy-options.d.ts
- strategies/password/password-strategy.d.ts
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (6)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@nebular/auth
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@nebular/auth)
- HTML<a href="https://www.jsdocs.io/package/@nebular/auth"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 7469 ms. - Missing or incorrect documentation? Open an issue for this package.