1 | import { FeathersError } from '@feathersjs/errors';
|
2 | import { Application, Params } from '@feathersjs/feathers';
|
3 | import { AuthenticationRequest, AuthenticationResult } from '@feathersjs/authentication';
|
4 | import { Storage } from './storage';
|
5 | export type ClientConstructor = new (app: Application, options: AuthenticationClientOptions) => AuthenticationClient;
|
6 | export interface AuthenticationClientOptions {
|
7 | storage: Storage;
|
8 | header: string;
|
9 | scheme: string;
|
10 | storageKey: string;
|
11 | locationKey: string;
|
12 | locationErrorKey: string;
|
13 | jwtStrategy: string;
|
14 | path: string;
|
15 | Authentication: ClientConstructor;
|
16 | }
|
17 | export declare class AuthenticationClient {
|
18 | app: Application;
|
19 | authenticated: boolean;
|
20 | options: AuthenticationClientOptions;
|
21 | constructor(app: Application, options: AuthenticationClientOptions);
|
22 | get service(): import("@feathersjs/feathers").FeathersService<Application<any, any>, import("@feathersjs/feathers").Service<any, Partial<any>, Params<import("@feathersjs/feathers").Query>, Partial<Partial<any>>>>;
|
23 | get storage(): Storage;
|
24 | handleSocket(socket: any): void;
|
25 | /**
|
26 | * Parse the access token or authentication error from the window location hash. Will remove it from the hash
|
27 | * if found.
|
28 | *
|
29 | * @param location The window location
|
30 | * @returns The access token if available, will throw an error if found, otherwise null
|
31 | */
|
32 | getFromLocation(location: Location): Promise<any>;
|
33 | /**
|
34 | * Set the access token in storage.
|
35 | *
|
36 | * @param accessToken The access token to set
|
37 | * @returns
|
38 | */
|
39 | setAccessToken(accessToken: string): any;
|
40 | /**
|
41 | * Returns the access token from storage or the window location hash.
|
42 | *
|
43 | * @returns The access token from storage or location hash
|
44 | */
|
45 | getAccessToken(): Promise<string | null>;
|
46 | /**
|
47 | * Remove the access token from storage
|
48 | * @returns The removed access token
|
49 | */
|
50 | removeAccessToken(): any;
|
51 | /**
|
52 | * Reset the internal authentication state. Usually not necessary to call directly.
|
53 | *
|
54 | * @returns null
|
55 | */
|
56 | reset(): Promise<any>;
|
57 | handleError(error: FeathersError, type: 'authenticate' | 'logout'): any;
|
58 | /**
|
59 | * Try to reauthenticate using the token from storage. Will do nothing if already authenticated unless
|
60 | * `force` is true.
|
61 | *
|
62 | * @param force force reauthentication with the server
|
63 | * @param strategy The name of the strategy to use. Defaults to `options.jwtStrategy`
|
64 | * @param authParams Additional authentication parameters
|
65 | * @returns The reauthentication result
|
66 | */
|
67 | reAuthenticate(force?: boolean, strategy?: string, authParams?: Params): Promise<AuthenticationResult>;
|
68 | /**
|
69 | * Authenticate using a specific strategy and data.
|
70 | *
|
71 | * @param authentication The authentication data
|
72 | * @param params Additional parameters
|
73 | * @returns The authentication result
|
74 | */
|
75 | authenticate(authentication?: AuthenticationRequest, params?: Params): Promise<AuthenticationResult>;
|
76 | /**
|
77 | * Log out the current user and remove their token. Will do nothing
|
78 | * if not authenticated.
|
79 | *
|
80 | * @returns The log out result.
|
81 | */
|
82 | logout(): Promise<AuthenticationResult | null>;
|
83 | }
|