@feathersjs/authentication 5.0.0-pre.6 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +281 -268
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/lib/core.d.ts +31 -5
- package/lib/core.js +84 -80
- package/lib/core.js.map +1 -1
- package/lib/hooks/authenticate.d.ts +2 -2
- package/lib/hooks/authenticate.js +11 -19
- package/lib/hooks/authenticate.js.map +1 -1
- package/lib/hooks/connection.js +4 -18
- package/lib/hooks/connection.js.map +1 -1
- package/lib/hooks/event.js +4 -13
- package/lib/hooks/event.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.js +11 -6
- package/lib/index.js.map +1 -1
- package/lib/jwt.d.ts +2 -2
- package/lib/jwt.js +98 -104
- package/lib/jwt.js.map +1 -1
- package/lib/options.d.ts +5 -3
- package/lib/options.js +4 -1
- package/lib/options.js.map +1 -1
- package/lib/service.d.ts +10 -8
- package/lib/service.js +82 -95
- package/lib/service.js.map +1 -1
- package/lib/strategy.d.ts +1 -1
- package/lib/strategy.js.map +1 -1
- package/package.json +25 -22
- package/src/core.ts +133 -83
- package/src/hooks/authenticate.ts +37 -33
- package/src/hooks/connection.ts +10 -10
- package/src/hooks/event.ts +9 -9
- package/src/hooks/index.ts +3 -3
- package/src/index.ts +8 -10
- package/src/jwt.ts +93 -82
- package/src/options.ts +9 -3
- package/src/service.ts +87 -71
- package/src/strategy.ts +17 -17
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgC;AAChC,iCAAsC;AAA7B,qGAAA,YAAY,OAAA;AACrB,+BAOe;AANb,0GAAA,kBAAkB,OAAA;AAOpB,uCAAuD;AAA9C,sHAAA,0BAA0B,OAAA;AACnC,qCAAiD;AAAxC,gHAAA,qBAAqB,OAAA;AAC9B,6BAAmC;AAA1B,kGAAA,WAAW,OAAA;AACpB,qCAAqF;AAA5E,uHAAA,4BAA4B,OAAA"}
|
package/lib/jwt.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { IncomingMessage } from 'http';
|
|
3
3
|
import { Params } from '@feathersjs/feathers';
|
|
4
4
|
import { AuthenticationBaseStrategy } from './strategy';
|
|
5
|
-
import { AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core';
|
|
5
|
+
import { AuthenticationParams, AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core';
|
|
6
6
|
export declare class JWTStrategy extends AuthenticationBaseStrategy {
|
|
7
7
|
expirationTimers: WeakMap<object, any>;
|
|
8
8
|
get configuration(): any;
|
|
@@ -17,7 +17,7 @@ export declare class JWTStrategy extends AuthenticationBaseStrategy {
|
|
|
17
17
|
*/
|
|
18
18
|
getEntity(id: string, params: Params): Promise<any>;
|
|
19
19
|
getEntityId(authResult: AuthenticationResult, _params: Params): Promise<any>;
|
|
20
|
-
authenticate(authentication: AuthenticationRequest, params:
|
|
20
|
+
authenticate(authentication: AuthenticationRequest, params: AuthenticationParams): Promise<{
|
|
21
21
|
accessToken: any;
|
|
22
22
|
authentication: {
|
|
23
23
|
strategy: string;
|
package/lib/jwt.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.JWTStrategy = void 0;
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/ban-ts-comment */
|
|
17
8
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
18
9
|
const errors_1 = require("@feathersjs/errors");
|
|
19
10
|
const commons_1 = require("@feathersjs/commons");
|
|
20
11
|
// @ts-ignore
|
|
21
12
|
const long_timeout_1 = __importDefault(require("long-timeout"));
|
|
22
13
|
const strategy_1 = require("./strategy");
|
|
23
|
-
const debug = commons_1.createDebug('@feathersjs/authentication/jwt');
|
|
14
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication/jwt');
|
|
24
15
|
const SPLIT_HEADER = /(\S+)\s+(\S+)/;
|
|
25
16
|
class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
|
|
26
17
|
constructor() {
|
|
@@ -30,39 +21,49 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
|
|
|
30
21
|
get configuration() {
|
|
31
22
|
const authConfig = this.authentication.configuration;
|
|
32
23
|
const config = super.configuration;
|
|
33
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
service: authConfig.service,
|
|
26
|
+
entity: authConfig.entity,
|
|
27
|
+
entityId: authConfig.entityId,
|
|
28
|
+
header: 'Authorization',
|
|
29
|
+
schemes: ['Bearer', 'JWT'],
|
|
30
|
+
...config
|
|
31
|
+
};
|
|
34
32
|
}
|
|
35
|
-
handleConnection(event, connection, authResult) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
async handleConnection(event, connection, authResult) {
|
|
34
|
+
var _a;
|
|
35
|
+
const isValidLogout = event === 'logout' &&
|
|
36
|
+
connection.authentication &&
|
|
37
|
+
authResult &&
|
|
38
|
+
connection.authentication.accessToken === authResult.accessToken;
|
|
39
|
+
const { accessToken } = authResult || {};
|
|
40
|
+
const { entity } = this.configuration;
|
|
41
|
+
if (accessToken && event === 'login') {
|
|
42
|
+
debug('Adding authentication information to connection');
|
|
43
|
+
const { exp } = ((_a = authResult === null || authResult === void 0 ? void 0 : authResult.authentication) === null || _a === void 0 ? void 0 : _a.payload) || (await this.authentication.verifyAccessToken(accessToken));
|
|
44
|
+
// The time (in ms) until the token expires
|
|
45
|
+
const duration = exp * 1000 - Date.now();
|
|
46
|
+
const timer = long_timeout_1.default.setTimeout(() => this.app.emit('disconnect', connection), duration);
|
|
47
|
+
debug(`Registering connection expiration timer for ${duration}ms`);
|
|
48
|
+
long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
|
|
49
|
+
this.expirationTimers.set(connection, timer);
|
|
50
|
+
debug('Adding authentication information to connection');
|
|
51
|
+
connection.authentication = {
|
|
52
|
+
strategy: this.name,
|
|
53
|
+
accessToken
|
|
54
|
+
};
|
|
55
|
+
connection[entity] = authResult[entity];
|
|
56
|
+
}
|
|
57
|
+
else if (event === 'disconnect' || isValidLogout) {
|
|
58
|
+
debug('Removing authentication information and expiration timer from connection');
|
|
59
|
+
await new Promise((resolve) => process.nextTick(() => {
|
|
60
60
|
delete connection[entity];
|
|
61
61
|
delete connection.authentication;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
resolve(connection);
|
|
63
|
+
}));
|
|
64
|
+
long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
|
|
65
|
+
this.expirationTimers.delete(connection);
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
68
|
verifyConfiguration() {
|
|
68
69
|
const allowedKeys = ['entity', 'entityId', 'service', 'header', 'schemes'];
|
|
@@ -75,10 +76,8 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
|
|
|
75
76
|
throw new Error(`The 'header' option for the ${this.name} strategy must be a string`);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
getEntityQuery(_params) {
|
|
79
|
-
return
|
|
80
|
-
return {};
|
|
81
|
-
});
|
|
79
|
+
async getEntityQuery(_params) {
|
|
80
|
+
return {};
|
|
82
81
|
}
|
|
83
82
|
/**
|
|
84
83
|
* Return the entity for a given id
|
|
@@ -86,70 +85,65 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
|
|
|
86
85
|
* @param id The id to use
|
|
87
86
|
* @param params Service call parameters
|
|
88
87
|
*/
|
|
89
|
-
getEntity(id, params) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return entityService.get(id, Object.assign(Object.assign({}, params), { [entity]: result }));
|
|
104
|
-
});
|
|
88
|
+
async getEntity(id, params) {
|
|
89
|
+
const entityService = this.entityService;
|
|
90
|
+
const { entity } = this.configuration;
|
|
91
|
+
debug('Getting entity', id);
|
|
92
|
+
if (entityService === null) {
|
|
93
|
+
throw new errors_1.NotAuthenticated('Could not find entity service');
|
|
94
|
+
}
|
|
95
|
+
const query = await this.getEntityQuery(params);
|
|
96
|
+
const getParams = Object.assign({}, (0, omit_1.default)(params, 'provider'), { query });
|
|
97
|
+
const result = await entityService.get(id, getParams);
|
|
98
|
+
if (!params.provider) {
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
return entityService.get(id, { ...params, [entity]: result });
|
|
105
102
|
}
|
|
106
|
-
getEntityId(authResult, _params) {
|
|
107
|
-
return
|
|
108
|
-
return authResult.authentication.payload.sub;
|
|
109
|
-
});
|
|
103
|
+
async getEntityId(authResult, _params) {
|
|
104
|
+
return authResult.authentication.payload.sub;
|
|
110
105
|
}
|
|
111
|
-
authenticate(authentication, params) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
async authenticate(authentication, params) {
|
|
107
|
+
const { accessToken } = authentication;
|
|
108
|
+
const { entity } = this.configuration;
|
|
109
|
+
if (!accessToken) {
|
|
110
|
+
throw new errors_1.NotAuthenticated('No access token');
|
|
111
|
+
}
|
|
112
|
+
const payload = await this.authentication.verifyAccessToken(accessToken, params.jwt);
|
|
113
|
+
const result = {
|
|
114
|
+
accessToken,
|
|
115
|
+
authentication: {
|
|
116
|
+
strategy: 'jwt',
|
|
120
117
|
accessToken,
|
|
121
|
-
|
|
122
|
-
strategy: 'jwt',
|
|
123
|
-
accessToken,
|
|
124
|
-
payload
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
if (entity === null) {
|
|
128
|
-
return result;
|
|
118
|
+
payload
|
|
129
119
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
}
|
|
120
|
+
};
|
|
121
|
+
if (entity === null) {
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
const entityId = await this.getEntityId(result, params);
|
|
125
|
+
const value = await this.getEntity(entityId, params);
|
|
126
|
+
return {
|
|
127
|
+
...result,
|
|
128
|
+
[entity]: value
|
|
129
|
+
};
|
|
134
130
|
}
|
|
135
|
-
parse(req) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
});
|
|
131
|
+
async parse(req) {
|
|
132
|
+
const { header, schemes } = this.configuration;
|
|
133
|
+
const headerValue = req.headers && req.headers[header.toLowerCase()];
|
|
134
|
+
if (!headerValue || typeof headerValue !== 'string') {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
debug('Found parsed header value');
|
|
138
|
+
const [, scheme, schemeValue] = headerValue.match(SPLIT_HEADER) || [];
|
|
139
|
+
const hasScheme = scheme && schemes.some((current) => new RegExp(current, 'i').test(scheme));
|
|
140
|
+
if (scheme && !hasScheme) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
strategy: this.name,
|
|
145
|
+
accessToken: hasScheme ? schemeValue : headerValue
|
|
146
|
+
};
|
|
153
147
|
}
|
|
154
148
|
}
|
|
155
149
|
exports.JWTStrategy = JWTStrategy;
|
package/lib/jwt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":";;;;;;AAAA,yFAAyF;AACzF,uDAA8B;AAE9B,+CAAqD;AAErD,iDAAiD;AACjD,aAAa;AACb,gEAA6B;AAE7B,yCAAuD;AAGvD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,gCAAgC,CAAC,CAAA;AAC3D,MAAM,YAAY,GAAG,eAAe,CAAA;AAEpC,MAAa,WAAY,SAAQ,qCAA0B;IAA3D;;QACE,qBAAgB,GAAG,IAAI,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C,YAAY,CAAC,IAAI,EAAE,CAAA;QACrE,MAAM,SAAS,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QAE5F,IAAI,MAAM,IAAI,CAAC,SAAS,EAAE;YACxB,OAAO,IAAI,CAAA;SACZ;QAED,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;SACnD,CAAA;IACH,CAAC;CACF;AA5KD,kCA4KC"}
|
package/lib/options.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { FromSchema, authenticationSettingsSchema } from '@feathersjs/schema';
|
|
2
|
+
export declare const defaultOptions: {
|
|
3
|
+
authStrategies: string[];
|
|
3
4
|
jwtOptions: {
|
|
4
5
|
header: {
|
|
5
6
|
typ: string;
|
|
@@ -10,4 +11,5 @@ declare const _default: {
|
|
|
10
11
|
expiresIn: string;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
|
-
export
|
|
14
|
+
export { authenticationSettingsSchema };
|
|
15
|
+
export type AuthenticationConfiguration = FromSchema<typeof authenticationSettingsSchema>;
|
package/lib/options.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.authenticationSettingsSchema = exports.defaultOptions = void 0;
|
|
4
|
+
const schema_1 = require("@feathersjs/schema");
|
|
5
|
+
Object.defineProperty(exports, "authenticationSettingsSchema", { enumerable: true, get: function () { return schema_1.authenticationSettingsSchema; } });
|
|
6
|
+
exports.defaultOptions = {
|
|
4
7
|
authStrategies: [],
|
|
5
8
|
jwtOptions: {
|
|
6
9
|
header: { typ: 'access' },
|
package/lib/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AAAA,+CAA6E;AAapE,6GAbY,qCAA4B,OAaZ;AAXxB,QAAA,cAAc,GAAG;IAC5B,cAAc,EAAE,EAAc;IAC9B,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;QACzB,QAAQ,EAAE,wBAAwB;QAClC,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,IAAI;KAChB;CACF,CAAA"}
|
package/lib/service.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AuthenticationBase, AuthenticationResult, AuthenticationRequest } from './core';
|
|
2
1
|
import '@feathersjs/transport-commons';
|
|
3
|
-
import {
|
|
2
|
+
import { ServiceMethods, ServiceAddons } from '@feathersjs/feathers';
|
|
3
|
+
import { AuthenticationBase, AuthenticationResult, AuthenticationRequest, AuthenticationParams } from './core';
|
|
4
4
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
5
|
-
interface FeathersApplication<
|
|
5
|
+
interface FeathersApplication<Services, Settings> {
|
|
6
6
|
/**
|
|
7
7
|
* Returns the default authentication service or the
|
|
8
8
|
* authentication service for a given path.
|
|
@@ -18,7 +18,7 @@ declare module '@feathersjs/feathers/lib/declarations' {
|
|
|
18
18
|
}
|
|
19
19
|
export interface AuthenticationService extends ServiceAddons<AuthenticationResult, AuthenticationResult> {
|
|
20
20
|
}
|
|
21
|
-
export declare class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult>> {
|
|
21
|
+
export declare class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult, AuthenticationRequest, AuthenticationParams>> {
|
|
22
22
|
constructor(app: any, configKey?: string, options?: {});
|
|
23
23
|
/**
|
|
24
24
|
* Return the payload for a JWT based on the authentication result.
|
|
@@ -27,7 +27,9 @@ export declare class AuthenticationService extends AuthenticationBase implements
|
|
|
27
27
|
* @param _authResult The current authentication result
|
|
28
28
|
* @param params The service call parameters
|
|
29
29
|
*/
|
|
30
|
-
getPayload(_authResult: AuthenticationResult, params:
|
|
30
|
+
getPayload(_authResult: AuthenticationResult, params: AuthenticationParams): Promise<{
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}>;
|
|
31
33
|
/**
|
|
32
34
|
* Returns the JWT options based on an authentication result.
|
|
33
35
|
* By default sets the JWT subject to the entity id.
|
|
@@ -35,7 +37,7 @@ export declare class AuthenticationService extends AuthenticationBase implements
|
|
|
35
37
|
* @param authResult The authentication result
|
|
36
38
|
* @param params Service call parameters
|
|
37
39
|
*/
|
|
38
|
-
getTokenOptions(authResult: AuthenticationResult, params:
|
|
40
|
+
getTokenOptions(authResult: AuthenticationResult, params: AuthenticationParams): Promise<any>;
|
|
39
41
|
/**
|
|
40
42
|
* Create and return a new JWT for a given authentication request.
|
|
41
43
|
* Will trigger the `login` event.
|
|
@@ -43,7 +45,7 @@ export declare class AuthenticationService extends AuthenticationBase implements
|
|
|
43
45
|
* @param data The authentication request (should include `strategy` key)
|
|
44
46
|
* @param params Service call parameters
|
|
45
47
|
*/
|
|
46
|
-
create(data: AuthenticationRequest, params?:
|
|
48
|
+
create(data: AuthenticationRequest, params?: AuthenticationParams): Promise<AuthenticationResult>;
|
|
47
49
|
/**
|
|
48
50
|
* Mark a JWT as removed. By default only verifies the JWT and returns the result.
|
|
49
51
|
* Triggers the `logout` event.
|
|
@@ -51,7 +53,7 @@ export declare class AuthenticationService extends AuthenticationBase implements
|
|
|
51
53
|
* @param id The JWT to remove or null
|
|
52
54
|
* @param params Service call parameters
|
|
53
55
|
*/
|
|
54
|
-
remove(id: string | null, params?:
|
|
56
|
+
remove(id: string | null, params?: AuthenticationParams): Promise<AuthenticationResult>;
|
|
55
57
|
/**
|
|
56
58
|
* Validates the service configuration.
|
|
57
59
|
*/
|