1 | import { Http, Request, RequestOptions, RequestOptionsArgs, Response } from "@angular/http";
|
2 | import { Provider, ModuleWithProviders } from "@angular/core";
|
3 | import { Observable } from "rxjs/Observable";
|
4 | import "rxjs/add/observable/fromPromise";
|
5 | import "rxjs/add/observable/defer";
|
6 | import "rxjs/add/operator/mergeMap";
|
7 | export interface IAuthConfig {
|
8 | globalHeaders: Array<Object>;
|
9 | headerName: string;
|
10 | headerPrefix: string;
|
11 | noJwtError: boolean;
|
12 | noClientCheck: boolean;
|
13 | noTokenScheme?: boolean;
|
14 | tokenGetter: () => string | Promise<string>;
|
15 | tokenName: string;
|
16 | }
|
17 | export interface IAuthConfigOptional {
|
18 | headerName?: string;
|
19 | headerPrefix?: string;
|
20 | tokenName?: string;
|
21 | tokenGetter?: () => string | Promise<string>;
|
22 | noJwtError?: boolean;
|
23 | noClientCheck?: boolean;
|
24 | globalHeaders?: Array<Object>;
|
25 | noTokenScheme?: boolean;
|
26 | }
|
27 | export declare class AuthConfigConsts {
|
28 | static DEFAULT_TOKEN_NAME: string;
|
29 | static DEFAULT_HEADER_NAME: string;
|
30 | static HEADER_PREFIX_BEARER: string;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 | export declare class AuthConfig {
|
36 | private _config;
|
37 | constructor(config?: IAuthConfigOptional);
|
38 | getConfig(): IAuthConfig;
|
39 | }
|
40 | export declare class AuthHttpError extends Error {
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 | export declare class AuthHttp {
|
46 | private http;
|
47 | private defOpts;
|
48 | private config;
|
49 | tokenStream: Observable<string>;
|
50 | constructor(options: AuthConfig, http: Http, defOpts?: RequestOptions);
|
51 | private mergeOptions(providedOpts, defaultOpts?);
|
52 | private requestHelper(requestArgs, additionalOptions?);
|
53 | requestWithToken(req: Request, token: string): Observable<Response>;
|
54 | setGlobalHeaders(headers: Array<Object>, request: Request | RequestOptionsArgs): void;
|
55 | request(url: string | Request, options?: RequestOptionsArgs): Observable<Response>;
|
56 | get(url: string, options?: RequestOptionsArgs): Observable<Response>;
|
57 | post(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
|
58 | put(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
|
59 | delete(url: string, options?: RequestOptionsArgs): Observable<Response>;
|
60 | patch(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>;
|
61 | head(url: string, options?: RequestOptionsArgs): Observable<Response>;
|
62 | options(url: string, options?: RequestOptionsArgs): Observable<Response>;
|
63 | }
|
64 | /**
|
65 | * Helper class to decode and find JWT expiration.
|
66 | */
|
67 | export declare class JwtHelper {
|
68 | urlBase64Decode(str: string): string;
|
69 | private b64decode(str);
|
70 | private b64DecodeUnicode(str);
|
71 | decodeToken(token: string): any;
|
72 | getTokenExpirationDate(token: string): Date;
|
73 | isTokenExpired(token: string, offsetSeconds?: number): boolean;
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | export declare function tokenNotExpired(tokenName?: string, jwt?: string): boolean;
|
80 | export declare const AUTH_PROVIDERS: Provider[];
|
81 | export declare function provideAuth(config?: IAuthConfigOptional): Provider[];
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | export declare class AuthModule {
|
87 | constructor(parentModule: AuthModule);
|
88 | static forRoot(config: AuthConfig): ModuleWithProviders;
|
89 | }
|