@feathersjs/authentication 5.0.0-pre.2 → 5.0.0-pre.22

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.
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/hooks/authenticate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6DAAqC;AACrC,uDAA+B;AAE/B,+CAAsD;AACtD,kDAA0B;AAE1B,MAAM,KAAK,GAAG,eAAK,CAAC,+CAA+C,CAAC,CAAC;AAOrE,kBAAe,CAAC,gBAAmD,EAAE,GAAG,kBAA4B,EAAE,EAAE;IACtG,MAAM,QAAQ,GAAG,OAAO,gBAAgB,KAAK,QAAQ;QACnD,CAAC,CAAC,EAAE,UAAU,EAAE,iBAAO,CAAC,CAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAE,CAAC,EAAE;QACtE,CAAC,CAAC,gBAAgB,CAAC;IAErB,IAAI,CAAC,gBAAgB,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QACzD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;KAC9E;IAED,OAAO,CAAO,OAA8B,EAAE,EAAE;QAC9C,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACrD,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;QAChC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;QAC5C,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEhE,KAAK,CAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;QAEhD,IAAI,IAAI,IAAI,IAAI,KAAK,QAAQ,EAAE;YAC7B,MAAM,IAAI,yBAAgB,CAAC,qDAAqD,CAAC,CAAC;SACnF;QAED,IAA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CAAC;SACf;QAED,IAAI,cAAc,EAAE;YAClB,MAAM,UAAU,GAAG,IAAA,cAAI,EAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;YAE9D,KAAK,CAAC,qBAAqB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;YAEzD,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,cAAc,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,CAAC;YAE7F,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAA,cAAI,EAAC,UAAU,EAAE,aAAa,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;SACtG;aAAM,IAAI,QAAQ,EAAE;YACnB,MAAM,IAAI,yBAAgB,CAAC,mBAAmB,CAAC,CAAC;SACjD;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { HookContext } from '@feathersjs/feathers';
1
+ import { HookContext, NextFunction } from '@feathersjs/feathers';
2
2
  import { ConnectionEvent } from '../core';
3
- declare const _default: (event: ConnectionEvent) => (context: HookContext) => Promise<HookContext<import("@feathersjs/feathers").Application<any, any>, any>>;
3
+ declare const _default: (event: ConnectionEvent) => (context: HookContext, next: NextFunction) => Promise<void>;
4
4
  export default _default;
@@ -1,26 +1,16 @@
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
  const omit_1 = __importDefault(require("lodash/omit"));
16
- exports.default = (event) => (context) => __awaiter(void 0, void 0, void 0, function* () {
7
+ exports.default = (event) => async (context, next) => {
8
+ await next();
17
9
  const { result, params: { connection } } = context;
18
- if (!connection) {
19
- return context;
10
+ if (connection) {
11
+ const service = context.service;
12
+ Object.assign(connection, (0, omit_1.default)(result, 'accessToken', 'authentication'));
13
+ await service.handleConnection(event, connection, result);
20
14
  }
21
- const service = context.service;
22
- Object.assign(connection, omit_1.default(result, 'accessToken', 'authentication'));
23
- yield service.handleConnection(event, connection, result);
24
- return context;
25
- });
15
+ };
26
16
  //# sourceMappingURL=connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/hooks/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,uDAA+B;AAG/B,kBAAe,CAAC,KAAsB,EAAE,EAAE,CAAC,CAAO,OAAoB,EAAE,EAAE;IACxE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC;IAEnD,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,OAAwC,CAAC;IAEjE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAI,CAAC,MAAM,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEzE,MAAM,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA,CAAC"}
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/hooks/connection.ts"],"names":[],"mappings":";;;;;AACA,uDAA+B;AAG/B,kBAAe,CAAC,KAAsB,EAAE,EAAE,CAAC,KAAK,EAAE,OAAoB,EAAE,IAAkB,EAAE,EAAE;IAC5F,MAAM,IAAI,EAAE,CAAC;IAEb,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC;IAEnD,IAAI,UAAU,EAAE;QACd,MAAM,OAAO,GAAG,OAAO,CAAC,OAAwC,CAAC;QAEjE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAA,cAAI,EAAC,MAAM,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAEzE,MAAM,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;KAC3D;AACH,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { HookContext } from '@feathersjs/feathers';
1
+ import { HookContext, NextFunction } from '@feathersjs/feathers';
2
2
  import { ConnectionEvent } from '../core';
3
- declare const _default: (event: ConnectionEvent) => (context: HookContext) => Promise<HookContext<import("@feathersjs/feathers").Application<any, any>, any>>;
3
+ declare const _default: (event: ConnectionEvent) => (context: HookContext, next: NextFunction) => Promise<void>;
4
4
  export default _default;
@@ -1,25 +1,13 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const debug_1 = __importDefault(require("debug"));
16
- const debug = debug_1.default('@feathersjs/authentication/hooks/connection');
17
- exports.default = (event) => (context) => __awaiter(void 0, void 0, void 0, function* () {
3
+ const commons_1 = require("@feathersjs/commons");
4
+ const debug = (0, commons_1.createDebug)('@feathersjs/authentication/hooks/connection');
5
+ exports.default = (event) => async (context, next) => {
6
+ await next();
18
7
  const { app, result, params } = context;
19
8
  if (params.provider && result) {
20
9
  debug(`Sending authentication event '${event}'`);
21
10
  app.emit(event, result, params, context);
22
11
  }
23
- return context;
24
- });
12
+ };
25
13
  //# sourceMappingURL=event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/hooks/event.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAI1B,MAAM,KAAK,GAAG,eAAK,CAAC,6CAA6C,CAAC,CAAC;AAEnE,kBAAe,CAAC,KAAsB,EAAE,EAAE,CAAC,CAAO,OAAoB,EAAE,EAAE;IACxE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAExC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,EAAE;QAC7B,KAAK,CAAC,iCAAiC,KAAK,GAAG,CAAC,CAAC;QACjD,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA,CAAC"}
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/hooks/event.ts"],"names":[],"mappings":";;AACA,iDAAkD;AAGlD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,6CAA6C,CAAC,CAAC;AAEzE,kBAAe,CAAC,KAAsB,EAAE,EAAE,CAAC,KAAK,EAAE,OAAoB,EAAE,IAAkB,EAAE,EAAE;IAC5F,MAAM,IAAI,EAAE,CAAC;IAEb,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAExC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,EAAE;QAC7B,KAAK,CAAC,iCAAiC,KAAK,GAAG,CAAC,CAAC;QACjD,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C;AACH,CAAC,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import * as hooks from './hooks';
2
- declare const authenticate: (originalSettings: string | import("./hooks/authenticate").AuthenticateHookSettings, ...originalStrategies: string[]) => (context: import("@feathersjs/feathers/lib").HookContext<any, any>) => Promise<import("@feathersjs/feathers/lib").HookContext<any, any>>;
3
- export { hooks };
4
- export { authenticate };
5
- export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, AuthenticationStrategy, ConnectionEvent } from './core';
1
+ export * as hooks from './hooks';
2
+ export { authenticate } from './hooks';
3
+ export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, AuthenticationStrategy, AuthenticationParams, ConnectionEvent } from './core';
6
4
  export { AuthenticationBaseStrategy } from './strategy';
7
5
  export { AuthenticationService } from './service';
8
6
  export { JWTStrategy } from './jwt';
7
+ export { authenticationSettingsSchema } from './options';
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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
- const hooks = __importStar(require("./hooks"));
24
- exports.hooks = hooks;
25
- const { authenticate } = hooks;
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":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAIxB,sBAAK;AAFd,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;AAGtB,oCAAY;AACrB,+BAMgB;AALd,0GAAA,kBAAkB,OAAA;AAMpB,uCAAwD;AAA/C,sHAAA,0BAA0B,OAAA;AACnC,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAC9B,6BAAoC;AAA3B,kGAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AACrB,+BAOgB;AANd,0GAAA,kBAAkB,OAAA;AAOpB,uCAAwD;AAA/C,sHAAA,0BAA0B,OAAA;AACnC,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAC9B,6BAAoC;AAA3B,kGAAA,WAAW,OAAA;AACpB,qCAAyD;AAAhD,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: Params): Promise<{
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
7
  /* eslint-disable @typescript-eslint/no-unused-vars */
17
- const debug_1 = __importDefault(require("debug"));
18
8
  const omit_1 = __importDefault(require("lodash/omit"));
19
9
  const errors_1 = require("@feathersjs/errors");
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 = debug_1.default('@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,44 @@ 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 Object.assign({ service: authConfig.service, entity: authConfig.entity, entityId: authConfig.entityId, header: 'Authorization', schemes: ['Bearer', 'JWT'] }, config);
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
- return __awaiter(this, void 0, void 0, function* () {
37
- const isValidLogout = event === 'logout' && connection.authentication && authResult &&
38
- connection.authentication.accessToken === authResult.accessToken;
39
- const { accessToken } = authResult || {};
40
- if (accessToken && event === 'login') {
41
- debug('Adding authentication information to connection');
42
- const { exp } = yield this.authentication.verifyAccessToken(accessToken);
43
- // The time (in ms) until the token expires
44
- const duration = (exp * 1000) - Date.now();
45
- // This may have to be a `logout` event but right now we don't want
46
- // the whole context object lingering around until the timer is gone
47
- const timer = long_timeout_1.default.setTimeout(() => this.app.emit('disconnect', connection), duration);
48
- debug(`Registering connection expiration timer for ${duration}ms`);
49
- long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
50
- this.expirationTimers.set(connection, timer);
51
- debug('Adding authentication information to connection');
52
- connection.authentication = {
53
- strategy: this.name,
54
- accessToken
55
- };
56
- }
57
- else if (event === 'disconnect' || isValidLogout) {
58
- debug('Removing authentication information and expiration timer from connection');
59
- const { entity } = this.configuration;
60
- delete connection[entity];
61
- delete connection.authentication;
62
- long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
63
- this.expirationTimers.delete(connection);
64
- }
65
- });
33
+ async handleConnection(event, connection, authResult) {
34
+ const isValidLogout = event === 'logout' && connection.authentication && authResult &&
35
+ connection.authentication.accessToken === authResult.accessToken;
36
+ const { accessToken } = authResult || {};
37
+ if (accessToken && event === 'login') {
38
+ debug('Adding authentication information to connection');
39
+ const { exp } = await this.authentication.verifyAccessToken(accessToken);
40
+ // The time (in ms) until the token expires
41
+ const duration = (exp * 1000) - Date.now();
42
+ // This may have to be a `logout` event but right now we don't want
43
+ // the whole context object lingering around until the timer is gone
44
+ const timer = long_timeout_1.default.setTimeout(() => this.app.emit('disconnect', connection), duration);
45
+ debug(`Registering connection expiration timer for ${duration}ms`);
46
+ long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
47
+ this.expirationTimers.set(connection, timer);
48
+ debug('Adding authentication information to connection');
49
+ connection.authentication = {
50
+ strategy: this.name,
51
+ accessToken
52
+ };
53
+ }
54
+ else if (event === 'disconnect' || isValidLogout) {
55
+ debug('Removing authentication information and expiration timer from connection');
56
+ const { entity } = this.configuration;
57
+ delete connection[entity];
58
+ delete connection.authentication;
59
+ long_timeout_1.default.clearTimeout(this.expirationTimers.get(connection));
60
+ this.expirationTimers.delete(connection);
61
+ }
66
62
  }
67
63
  verifyConfiguration() {
68
64
  const allowedKeys = ['entity', 'entityId', 'service', 'header', 'schemes'];
@@ -75,10 +71,8 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
75
71
  throw new Error(`The 'header' option for the ${this.name} strategy must be a string`);
76
72
  }
77
73
  }
78
- getEntityQuery(_params) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- return {};
81
- });
74
+ async getEntityQuery(_params) {
75
+ return {};
82
76
  }
83
77
  /**
84
78
  * Return the entity for a given id
@@ -86,70 +80,65 @@ class JWTStrategy extends strategy_1.AuthenticationBaseStrategy {
86
80
  * @param id The id to use
87
81
  * @param params Service call parameters
88
82
  */
89
- getEntity(id, params) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const entityService = this.entityService;
92
- const { entity } = this.configuration;
93
- debug('Getting entity', id);
94
- if (entityService === null) {
95
- throw new errors_1.NotAuthenticated('Could not find entity service');
96
- }
97
- const query = yield this.getEntityQuery(params);
98
- const getParams = Object.assign({}, omit_1.default(params, 'provider'), { query });
99
- const result = yield entityService.get(id, getParams);
100
- if (!params.provider) {
101
- return result;
102
- }
103
- return entityService.get(id, Object.assign(Object.assign({}, params), { [entity]: result }));
104
- });
83
+ async getEntity(id, params) {
84
+ const entityService = this.entityService;
85
+ const { entity } = this.configuration;
86
+ debug('Getting entity', id);
87
+ if (entityService === null) {
88
+ throw new errors_1.NotAuthenticated('Could not find entity service');
89
+ }
90
+ const query = await this.getEntityQuery(params);
91
+ const getParams = Object.assign({}, (0, omit_1.default)(params, 'provider'), { query });
92
+ const result = await entityService.get(id, getParams);
93
+ if (!params.provider) {
94
+ return result;
95
+ }
96
+ return entityService.get(id, { ...params, [entity]: result });
105
97
  }
106
- getEntityId(authResult, _params) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- return authResult.authentication.payload.sub;
109
- });
98
+ async getEntityId(authResult, _params) {
99
+ return authResult.authentication.payload.sub;
110
100
  }
111
- authenticate(authentication, params) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const { accessToken } = authentication;
114
- const { entity } = this.configuration;
115
- if (!accessToken) {
116
- throw new errors_1.NotAuthenticated('No access token');
117
- }
118
- const payload = yield this.authentication.verifyAccessToken(accessToken, params.jwt);
119
- const result = {
101
+ async authenticate(authentication, params) {
102
+ const { accessToken } = authentication;
103
+ const { entity } = this.configuration;
104
+ if (!accessToken) {
105
+ throw new errors_1.NotAuthenticated('No access token');
106
+ }
107
+ const payload = await this.authentication.verifyAccessToken(accessToken, params.jwt);
108
+ const result = {
109
+ accessToken,
110
+ authentication: {
111
+ strategy: 'jwt',
120
112
  accessToken,
121
- authentication: {
122
- strategy: 'jwt',
123
- accessToken,
124
- payload
125
- }
126
- };
127
- if (entity === null) {
128
- return result;
113
+ payload
129
114
  }
130
- const entityId = yield this.getEntityId(result, params);
131
- const value = yield this.getEntity(entityId, params);
132
- return Object.assign(Object.assign({}, result), { [entity]: value });
133
- });
115
+ };
116
+ if (entity === null) {
117
+ return result;
118
+ }
119
+ const entityId = await this.getEntityId(result, params);
120
+ const value = await this.getEntity(entityId, params);
121
+ return {
122
+ ...result,
123
+ [entity]: value
124
+ };
134
125
  }
135
- parse(req) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- const { header, schemes } = this.configuration;
138
- const headerValue = req.headers && req.headers[header.toLowerCase()];
139
- if (!headerValue || typeof headerValue !== 'string') {
140
- return null;
141
- }
142
- debug('Found parsed header value');
143
- const [, scheme, schemeValue] = headerValue.match(SPLIT_HEADER) || [];
144
- const hasScheme = scheme && schemes.some(current => new RegExp(current, 'i').test(scheme));
145
- if (scheme && !hasScheme) {
146
- return null;
147
- }
148
- return {
149
- strategy: this.name,
150
- accessToken: hasScheme ? schemeValue : headerValue
151
- };
152
- });
126
+ async parse(req) {
127
+ const { header, schemes } = this.configuration;
128
+ const headerValue = req.headers && req.headers[header.toLowerCase()];
129
+ if (!headerValue || typeof headerValue !== 'string') {
130
+ return null;
131
+ }
132
+ debug('Found parsed header value');
133
+ const [, scheme, schemeValue] = headerValue.match(SPLIT_HEADER) || [];
134
+ const hasScheme = scheme && schemes.some(current => new RegExp(current, 'i').test(scheme));
135
+ if (scheme && !hasScheme) {
136
+ return null;
137
+ }
138
+ return {
139
+ strategy: this.name,
140
+ accessToken: hasScheme ? schemeValue : headerValue
141
+ };
153
142
  }
154
143
  }
155
144
  exports.JWTStrategy = JWTStrategy;
package/lib/jwt.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAsD;AACtD,kDAA0B;AAC1B,uDAA+B;AAE/B,+CAAsD;AAEtD,aAAa;AACb,gEAA8B;AAE9B,yCAAwD;AAGxD,MAAM,KAAK,GAAG,eAAK,CAAC,gCAAgC,CAAC,CAAC;AACtD,MAAM,YAAY,GAAG,eAAe,CAAC;AAErC,MAAa,WAAY,SAAQ,qCAA0B;IAA3D;;QACE,qBAAgB,GAAG,IAAI,OAAO,EAAE,CAAC;IA6JnC,CAAC;IA3JC,IAAI,aAAa;QACf,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;QACrD,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;QAEnC,uBACE,OAAO,EAAE,UAAU,CAAC,OAAO,EAC3B,MAAM,EAAE,UAAU,CAAC,MAAM,EACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAC7B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,CAAE,QAAQ,EAAE,KAAK,CAAE,IACzB,MAAM,EACT;IACJ,CAAC;IAEK,gBAAgB,CA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MAAM,CAAC,CACjD,CAAC;QAEF,IAAI,MAAM,IAAI,CAAC,SAAS,EAAE;YACxB,OAAO,IAAI,CAAC;SACb;QAED,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;SACnD,CAAC;IACJ,CAAC;CACF;AAjKD,kCAiKC"}
package/lib/options.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare const _default: {
2
- authStrategies: any[];
1
+ export declare const defaultOptions: {
2
+ authStrategies: string[];
3
3
  jwtOptions: {
4
4
  header: {
5
5
  typ: string;
@@ -10,4 +10,119 @@ declare const _default: {
10
10
  expiresIn: string;
11
11
  };
12
12
  };
13
- export default _default;
13
+ export declare const authenticationSettingsSchema: {
14
+ readonly type: "object";
15
+ readonly required: readonly ["secret", "entity", "authStrategies"];
16
+ readonly properties: {
17
+ readonly secret: {
18
+ readonly type: "string";
19
+ readonly description: "The JWT signing secret";
20
+ };
21
+ readonly entity: {
22
+ readonly oneOf: readonly [{
23
+ readonly type: "null";
24
+ }, {
25
+ readonly type: "string";
26
+ }];
27
+ readonly description: "The name of the authentication entity (e.g. user)";
28
+ };
29
+ readonly entityId: {
30
+ readonly type: "string";
31
+ readonly description: "The name of the authentication entity id property";
32
+ };
33
+ readonly service: {
34
+ readonly type: "string";
35
+ readonly description: "The path of the entity service";
36
+ };
37
+ readonly authStrategies: {
38
+ readonly type: "array";
39
+ readonly items: {
40
+ readonly type: "string";
41
+ };
42
+ readonly description: "A list of authentication strategy names that are allowed to create JWT access tokens";
43
+ };
44
+ readonly parseStrategies: {
45
+ readonly type: "array";
46
+ readonly items: {
47
+ readonly type: "string";
48
+ };
49
+ readonly description: "A list of authentication strategy names that should parse HTTP headers for authentication information (defaults to `authStrategies`)";
50
+ };
51
+ readonly jwtOptions: {
52
+ readonly type: "object";
53
+ };
54
+ readonly jwt: {
55
+ readonly type: "object";
56
+ readonly properties: {
57
+ readonly header: {
58
+ readonly type: "string";
59
+ readonly default: "Authorization";
60
+ readonly description: "The HTTP header containing the JWT";
61
+ };
62
+ readonly schemes: {
63
+ readonly type: "array";
64
+ readonly items: {
65
+ readonly type: "string";
66
+ };
67
+ readonly description: "An array of schemes to support";
68
+ };
69
+ };
70
+ };
71
+ readonly local: {
72
+ readonly type: "object";
73
+ readonly required: readonly ["usernameField", "passwordField"];
74
+ readonly properties: {
75
+ readonly usernameField: {
76
+ readonly type: "string";
77
+ readonly description: "Name of the username field (e.g. `email`)";
78
+ };
79
+ readonly passwordField: {
80
+ readonly type: "string";
81
+ readonly description: "Name of the password field (e.g. `password`)";
82
+ };
83
+ readonly hashSize: {
84
+ readonly type: "number";
85
+ readonly description: "The BCrypt salt length";
86
+ };
87
+ readonly errorMessage: {
88
+ readonly type: "string";
89
+ readonly default: "Invalid login";
90
+ readonly description: "The error message to return on errors";
91
+ };
92
+ readonly entityUsernameField: {
93
+ readonly type: "string";
94
+ readonly description: "Name of the username field on the entity if authentication request data and entity field names are different";
95
+ };
96
+ readonly entityPasswordField: {
97
+ readonly type: "string";
98
+ readonly description: "Name of the password field on the entity if authentication request data and entity field names are different";
99
+ };
100
+ };
101
+ };
102
+ readonly oauth: {
103
+ readonly type: "object";
104
+ readonly properties: {
105
+ readonly redirect: {
106
+ readonly type: "string";
107
+ };
108
+ readonly origins: {
109
+ readonly type: "array";
110
+ readonly items: {
111
+ readonly type: "string";
112
+ };
113
+ };
114
+ readonly defaults: {
115
+ readonly type: "object";
116
+ readonly properties: {
117
+ readonly key: {
118
+ readonly type: "string";
119
+ };
120
+ readonly secret: {
121
+ readonly type: "string";
122
+ };
123
+ };
124
+ };
125
+ };
126
+ };
127
+ };
128
+ };