UNPKG

1.31 kBTypeScriptView Raw
1import { Observable, BehaviorSubject } from 'rxjs';
2import { NbTokenStorage } from './token-storage';
3import { NbAuthToken } from './token';
4import * as i0 from "@angular/core";
5/**
6 * Service that allows you to manage authentication token - get, set, clear and also listen to token changes over time.
7 */
8export declare class NbTokenService {
9 protected tokenStorage: NbTokenStorage;
10 protected token$: BehaviorSubject<NbAuthToken>;
11 constructor(tokenStorage: NbTokenStorage);
12 /**
13 * Publishes token when it changes.
14 * @returns {Observable<NbAuthToken>}
15 */
16 tokenChange(): Observable<NbAuthToken>;
17 /**
18 * Sets a token into the storage. This method is used by the NbAuthService automatically.
19 *
20 * @param {NbAuthToken} token
21 * @returns {Observable<any>}
22 */
23 set(token: NbAuthToken): Observable<null>;
24 /**
25 * Returns observable of current token
26 * @returns {Observable<NbAuthToken>}
27 */
28 get(): Observable<NbAuthToken>;
29 /**
30 * Removes the token and published token value
31 *
32 * @returns {Observable<any>}
33 */
34 clear(): Observable<null>;
35 protected publishStoredToken(): void;
36 static ɵfac: i0.ɵɵFactoryDeclaration<NbTokenService, never>;
37 static ɵprov: i0.ɵɵInjectableDeclaration<NbTokenService>;
38}