1 | import { Observable } from 'rxjs';
|
2 | import { NbAuthStrategy } from '../strategies/auth-strategy';
|
3 | import { NbAuthResult } from './auth-result';
|
4 | import { NbTokenService } from './token/token.service';
|
5 | import { NbAuthToken } from './token/token';
|
6 | /**
|
7 | * Common authentication service.
|
8 | * Should be used to as an interlayer between UI Components and Auth Strategy.
|
9 | */
|
10 | export declare class NbAuthService {
|
11 | protected tokenService: NbTokenService;
|
12 | protected strategies: any;
|
13 | constructor(tokenService: NbTokenService, strategies: any);
|
14 | /**
|
15 | * Retrieves current authenticated token stored
|
16 | * @returns {Observable<any>}
|
17 | */
|
18 | getToken(): Observable<NbAuthToken>;
|
19 | /**
|
20 | * Returns true if auth token is present in the token storage
|
21 | * @returns {Observable<boolean>}
|
22 | */
|
23 | isAuthenticated(): Observable<boolean>;
|
24 | /**
|
25 | * Returns true if valid auth token is present in the token storage.
|
26 | * If not, calls the strategy refreshToken, and returns isAuthenticated() if success, false otherwise
|
27 | * @returns {Observable<boolean>}
|
28 | */
|
29 | isAuthenticatedOrRefresh(): Observable<boolean>;
|
30 | /**
|
31 | * Returns tokens stream
|
32 | * @returns {Observable<NbAuthSimpleToken>}
|
33 | */
|
34 | onTokenChange(): Observable<NbAuthToken>;
|
35 | /**
|
36 | * Returns authentication status stream
|
37 | * @returns {Observable<boolean>}
|
38 | */
|
39 | onAuthenticationChange(): Observable<boolean>;
|
40 | /**
|
41 | * Authenticates with the selected strategy
|
42 | * Stores received token in the token storage
|
43 | *
|
44 | * Example:
|
45 | * authenticate('email', {email: 'email@example.com', password: 'test'})
|
46 | *
|
47 | * @param strategyName
|
48 | * @param data
|
49 | * @returns {Observable<NbAuthResult>}
|
50 | */
|
51 | authenticate(strategyName: string, data?: any): Observable<NbAuthResult>;
|
52 | /**
|
53 | * Registers with the selected strategy
|
54 | * Stores received token in the token storage
|
55 | *
|
56 | * Example:
|
57 | * register('email', {email: 'email@example.com', name: 'Some Name', password: 'test'})
|
58 | *
|
59 | * @param strategyName
|
60 | * @param data
|
61 | * @returns {Observable<NbAuthResult>}
|
62 | */
|
63 | register(strategyName: string, data?: any): Observable<NbAuthResult>;
|
64 | /**
|
65 | * Sign outs with the selected strategy
|
66 | * Removes token from the token storage
|
67 | *
|
68 | * Example:
|
69 | * logout('email')
|
70 | *
|
71 | * @param strategyName
|
72 | * @returns {Observable<NbAuthResult>}
|
73 | */
|
74 | logout(strategyName: string): Observable<NbAuthResult>;
|
75 | /**
|
76 | * Sends forgot password request to the selected strategy
|
77 | *
|
78 | * Example:
|
79 | * requestPassword('email', {email: 'email@example.com'})
|
80 | *
|
81 | * @param strategyName
|
82 | * @param data
|
83 | * @returns {Observable<NbAuthResult>}
|
84 | */
|
85 | requestPassword(strategyName: string, data?: any): Observable<NbAuthResult>;
|
86 | /**
|
87 | * Tries to reset password with the selected strategy
|
88 | *
|
89 | * Example:
|
90 | * resetPassword('email', {newPassword: 'test'})
|
91 | *
|
92 | * @param strategyName
|
93 | * @param data
|
94 | * @returns {Observable<NbAuthResult>}
|
95 | */
|
96 | resetPassword(strategyName: string, data?: any): Observable<NbAuthResult>;
|
97 | /**
|
98 | * Sends a refresh token request
|
99 | * Stores received token in the token storage
|
100 | *
|
101 | * Example:
|
102 | * refreshToken('email', {token: token})
|
103 | *
|
104 | * @param {string} strategyName
|
105 | * @param data
|
106 | * @returns {Observable<NbAuthResult>}
|
107 | */
|
108 | refreshToken(strategyName: string, data?: any): Observable<NbAuthResult>;
|
109 | /**
|
110 | * Get registered strategy by name
|
111 | *
|
112 | * Example:
|
113 | * getStrategy('email')
|
114 | *
|
115 | * @param {string} provider
|
116 | * @returns {NbAbstractAuthProvider}
|
117 | */
|
118 | protected getStrategy(strategyName: string): NbAuthStrategy;
|
119 | private processResultToken;
|
120 | }
|