@feathersjs/authentication 5.0.0-pre.3 → 5.0.0-pre.30
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 +257 -262
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/lib/core.d.ts +30 -4
- package/lib/core.js +84 -80
- package/lib/core.js.map +1 -1
- package/lib/hooks/authenticate.d.ts +3 -3
- package/lib/hooks/authenticate.js +12 -20
- package/lib/hooks/authenticate.js.map +1 -1
- package/lib/hooks/connection.d.ts +2 -2
- package/lib/hooks/connection.js +7 -17
- package/lib/hooks/connection.js.map +1 -1
- package/lib/hooks/event.d.ts +2 -2
- 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 +3 -3
- package/lib/jwt.js +97 -106
- 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 +78 -94
- package/lib/service.js.map +1 -1
- package/lib/strategy.d.ts +1 -1
- package/lib/strategy.js.map +1 -1
- package/package.json +23 -22
- package/src/core.ts +133 -83
- package/src/hooks/authenticate.ts +36 -33
- package/src/hooks/connection.ts +15 -14
- package/src/hooks/event.ts +11 -11
- package/src/hooks/index.ts +3 -3
- package/src/index.ts +8 -10
- package/src/jwt.ts +85 -75
- package/src/options.ts +9 -3
- package/src/service.ts +83 -71
- package/src/strategy.ts +17 -17
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,11 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.JWTStrategy = exports.AuthenticationService = exports.AuthenticationBaseStrategy = exports.AuthenticationBase = exports.authenticate = exports.hooks = void 0;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports.authenticate = authenticate;
|
|
26
|
+
exports.authenticationSettingsSchema = exports.JWTStrategy = exports.AuthenticationService = exports.AuthenticationBaseStrategy = exports.AuthenticationBase = exports.authenticate = exports.hooks = void 0;
|
|
27
|
+
exports.hooks = __importStar(require("./hooks"));
|
|
28
|
+
var hooks_1 = require("./hooks");
|
|
29
|
+
Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return hooks_1.authenticate; } });
|
|
27
30
|
var core_1 = require("./core");
|
|
28
31
|
Object.defineProperty(exports, "AuthenticationBase", { enumerable: true, get: function () { return core_1.AuthenticationBase; } });
|
|
29
32
|
var strategy_1 = require("./strategy");
|
|
@@ -32,4 +35,6 @@ var service_1 = require("./service");
|
|
|
32
35
|
Object.defineProperty(exports, "AuthenticationService", { enumerable: true, get: function () { return service_1.AuthenticationService; } });
|
|
33
36
|
var jwt_1 = require("./jwt");
|
|
34
37
|
Object.defineProperty(exports, "JWTStrategy", { enumerable: true, get: function () { return jwt_1.JWTStrategy; } });
|
|
38
|
+
var options_1 = require("./options");
|
|
39
|
+
Object.defineProperty(exports, "authenticationSettingsSchema", { enumerable: true, get: function () { return options_1.authenticationSettingsSchema; } });
|
|
35
40
|
//# sourceMappingURL=index.js.map
|
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;
|
|
@@ -28,5 +28,5 @@ export declare class JWTStrategy extends AuthenticationBaseStrategy {
|
|
|
28
28
|
parse(req: IncomingMessage): Promise<{
|
|
29
29
|
strategy: string;
|
|
30
30
|
accessToken: string;
|
|
31
|
-
}>;
|
|
31
|
+
} | null>;
|
|
32
32
|
}
|
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,46 @@ 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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
33
|
+
async handleConnection(event, connection, authResult) {
|
|
34
|
+
const isValidLogout = event === 'logout' &&
|
|
35
|
+
connection.authentication &&
|
|
36
|
+
authResult &&
|
|
37
|
+
connection.authentication.accessToken === authResult.accessToken;
|
|
38
|
+
const { accessToken } = authResult || {};
|
|
39
|
+
if (accessToken && event === 'login') {
|
|
40
|
+
debug('Adding authentication information to connection');
|
|
41
|
+
const { exp } = await this.authentication.verifyAccessToken(accessToken);
|
|
42
|
+
// The time (in ms) until the token expires
|
|
43
|
+
const duration = exp * 1000 - Date.now();
|
|
44
|
+
// This may have to be a `logout` event but right now we don't want
|
|
45
|
+
// the whole context object lingering around until the timer is gone
|
|
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
|
+
}
|
|
56
|
+
else if (event === 'disconnect' || isValidLogout) {
|
|
57
|
+
debug('Removing authentication information and expiration timer from connection');
|
|
58
|
+
const { entity } = this.configuration;
|
|
59
|
+
delete connection[entity];
|
|
60
|
+
delete connection.authentication;
|
|
61
|
+
long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
|
|
62
|
+
this.expirationTimers.delete(connection);
|
|
63
|
+
}
|
|
66
64
|
}
|
|
67
65
|
verifyConfiguration() {
|
|
68
66
|
const allowedKeys = ['entity', 'entityId', 'service', 'header', 'schemes'];
|
|
@@ -75,10 +73,8 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
|
|
|
75
73
|
throw new Error(`The 'header' option for the ${this.name} strategy must be a string`);
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
getEntityQuery(_params) {
|
|
79
|
-
return
|
|
80
|
-
return {};
|
|
81
|
-
});
|
|
76
|
+
async getEntityQuery(_params) {
|
|
77
|
+
return {};
|
|
82
78
|
}
|
|
83
79
|
/**
|
|
84
80
|
* Return the entity for a given id
|
|
@@ -86,70 +82,65 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
|
|
|
86
82
|
* @param id The id to use
|
|
87
83
|
* @param params Service call parameters
|
|
88
84
|
*/
|
|
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
|
-
});
|
|
85
|
+
async getEntity(id, params) {
|
|
86
|
+
const entityService = this.entityService;
|
|
87
|
+
const { entity } = this.configuration;
|
|
88
|
+
debug('Getting entity', id);
|
|
89
|
+
if (entityService === null) {
|
|
90
|
+
throw new errors_1.NotAuthenticated('Could not find entity service');
|
|
91
|
+
}
|
|
92
|
+
const query = await this.getEntityQuery(params);
|
|
93
|
+
const getParams = Object.assign({}, (0, omit_1.default)(params, 'provider'), { query });
|
|
94
|
+
const result = await entityService.get(id, getParams);
|
|
95
|
+
if (!params.provider) {
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
return entityService.get(id, { ...params, [entity]: result });
|
|
105
99
|
}
|
|
106
|
-
getEntityId(authResult, _params) {
|
|
107
|
-
return
|
|
108
|
-
return authResult.authentication.payload.sub;
|
|
109
|
-
});
|
|
100
|
+
async getEntityId(authResult, _params) {
|
|
101
|
+
return authResult.authentication.payload.sub;
|
|
110
102
|
}
|
|
111
|
-
authenticate(authentication, params) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
103
|
+
async authenticate(authentication, params) {
|
|
104
|
+
const { accessToken } = authentication;
|
|
105
|
+
const { entity } = this.configuration;
|
|
106
|
+
if (!accessToken) {
|
|
107
|
+
throw new errors_1.NotAuthenticated('No access token');
|
|
108
|
+
}
|
|
109
|
+
const payload = await this.authentication.verifyAccessToken(accessToken, params.jwt);
|
|
110
|
+
const result = {
|
|
111
|
+
accessToken,
|
|
112
|
+
authentication: {
|
|
113
|
+
strategy: 'jwt',
|
|
120
114
|
accessToken,
|
|
121
|
-
|
|
122
|
-
strategy: 'jwt',
|
|
123
|
-
accessToken,
|
|
124
|
-
payload
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
if (entity === null) {
|
|
128
|
-
return result;
|
|
115
|
+
payload
|
|
129
116
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
}
|
|
117
|
+
};
|
|
118
|
+
if (entity === null) {
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
const entityId = await this.getEntityId(result, params);
|
|
122
|
+
const value = await this.getEntity(entityId, params);
|
|
123
|
+
return {
|
|
124
|
+
...result,
|
|
125
|
+
[entity]: value
|
|
126
|
+
};
|
|
134
127
|
}
|
|
135
|
-
parse(req) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
});
|
|
128
|
+
async parse(req) {
|
|
129
|
+
const { header, schemes } = this.configuration;
|
|
130
|
+
const headerValue = req.headers && req.headers[header.toLowerCase()];
|
|
131
|
+
if (!headerValue || typeof headerValue !== 'string') {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
debug('Found parsed header value');
|
|
135
|
+
const [, scheme, schemeValue] = headerValue.match(SPLIT_HEADER) || [];
|
|
136
|
+
const hasScheme = scheme && schemes.some((current) => new RegExp(current, 'i').test(scheme));
|
|
137
|
+
if (scheme && !hasScheme) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
strategy: this.name,
|
|
142
|
+
accessToken: hasScheme ? schemeValue : headerValue
|
|
143
|
+
};
|
|
153
144
|
}
|
|
154
145
|
}
|
|
155
146
|
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,OAAO,EAAE,CAAA;IAuKlC,CAAC;IArKC,IAAI,aAAa;QACf,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAA;QACpD,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAA;QAElC,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;YAC1B,GAAG,MAAM;SACV,CAAA;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,KAAsB,EACtB,UAAe,EACf,UAAiC;QAEjC,MAAM,aAAa,GACjB,KAAK,KAAK,QAAQ;YAClB,UAAU,CAAC,cAAc;YACzB,UAAU;YACV,UAAU,CAAC,cAAc,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW,CAAA;QAElE,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;QAExC,IAAI,WAAW,IAAI,KAAK,KAAK,OAAO,EAAE;YACpC,KAAK,CAAC,iDAAiD,CAAC,CAAA;YACxD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,iBAAiB,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Z;QAED,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAElC,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,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;AAxKD,kCAwKC"}
|
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 declare 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';
|
|
1
|
+
import { AuthenticationBase, AuthenticationResult, AuthenticationRequest, AuthenticationParams } from './core';
|
|
2
2
|
import '@feathersjs/transport-commons';
|
|
3
|
-
import {
|
|
3
|
+
import { ServiceMethods, ServiceAddons } from '@feathersjs/feathers';
|
|
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
|
*/
|