UNPKG

2.45 kBTypeScriptView Raw
1import '@feathersjs/transport-commons';
2import { ServiceMethods } from '@feathersjs/feathers';
3import { AuthenticationBase, AuthenticationResult, AuthenticationRequest, AuthenticationParams } from './core';
4declare module '@feathersjs/feathers/lib/declarations' {
5 interface FeathersApplication<Services, Settings> {
6 /**
7 * Returns the default authentication service or the
8 * authentication service for a given path.
9 *
10 * @param location The service path to use (optional)
11 */
12 defaultAuthentication?(location?: string): AuthenticationService;
13 }
14 interface Params {
15 authenticated?: boolean;
16 authentication?: AuthenticationRequest;
17 }
18}
19export declare class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult, AuthenticationRequest, AuthenticationParams>> {
20 constructor(app: any, configKey?: string, options?: {});
21 /**
22 * Return the payload for a JWT based on the authentication result.
23 * Called internally by the `create` method.
24 *
25 * @param _authResult The current authentication result
26 * @param params The service call parameters
27 */
28 getPayload(_authResult: AuthenticationResult, params: AuthenticationParams): Promise<{
29 [key: string]: any;
30 }>;
31 /**
32 * Returns the JWT options based on an authentication result.
33 * By default sets the JWT subject to the entity id.
34 *
35 * @param authResult The authentication result
36 * @param params Service call parameters
37 */
38 getTokenOptions(authResult: AuthenticationResult, params: AuthenticationParams): Promise<any>;
39 /**
40 * Create and return a new JWT for a given authentication request.
41 * Will trigger the `login` event.
42 *
43 * @param data The authentication request (should include `strategy` key)
44 * @param params Service call parameters
45 */
46 create(data: AuthenticationRequest, params?: AuthenticationParams): Promise<AuthenticationResult>;
47 /**
48 * Mark a JWT as removed. By default only verifies the JWT and returns the result.
49 * Triggers the `logout` event.
50 *
51 * @param id The JWT to remove or null
52 * @param params Service call parameters
53 */
54 remove(id: string | null, params?: AuthenticationParams): Promise<AuthenticationResult>;
55 /**
56 * Validates the service configuration.
57 */
58 setup(): Promise<void>;
59}