@feathersjs/authentication
Advanced tools
Comparing version 5.0.0-pre.4 to 5.0.0-pre.5
@@ -1,2 +0,2 @@ | ||
import { HookContext } from '@feathersjs/feathers'; | ||
import { HookContext, NextFunction } from '@feathersjs/feathers'; | ||
export interface AuthenticateHookSettings { | ||
@@ -6,3 +6,3 @@ service?: string; | ||
} | ||
declare const _default: (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => (context: HookContext<any, any>) => Promise<HookContext<any, any>>; | ||
declare const _default: (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => (context: HookContext<any, any>, _next?: NextFunction) => Promise<any>; | ||
export default _default; |
@@ -27,3 +27,4 @@ "use strict"; | ||
} | ||
return (context) => __awaiter(void 0, void 0, void 0, function* () { | ||
return (context, _next) => __awaiter(void 0, void 0, void 0, function* () { | ||
const next = typeof _next === 'function' ? _next : () => __awaiter(void 0, void 0, void 0, function* () { return context; }); | ||
const { app, params, type, path, service } = context; | ||
@@ -45,3 +46,3 @@ const { strategies } = settings; | ||
if (params.authenticated === true) { | ||
return context; | ||
return next(); | ||
} | ||
@@ -53,3 +54,2 @@ if (authentication) { | ||
context.params = Object.assign({}, params, omit_1.default(authResult, 'accessToken'), { authenticated: true }); | ||
return context; | ||
} | ||
@@ -59,5 +59,5 @@ else if (provider) { | ||
} | ||
return context; | ||
return next(); | ||
}); | ||
}; | ||
//# sourceMappingURL=authenticate.js.map |
@@ -1,4 +0,4 @@ | ||
import { HookContext } from '@feathersjs/feathers'; | ||
import { HookContext, NextFunction } from '@feathersjs/feathers'; | ||
import { ConnectionEvent } from '../core'; | ||
declare const _default: (event: ConnectionEvent) => (context: HookContext) => Promise<HookContext<import("@feathersjs/feathers").Application<any, any>, any>>; | ||
declare const _default: (event: ConnectionEvent) => (context: HookContext, next: NextFunction) => Promise<void>; | ||
export default _default; |
@@ -16,12 +16,11 @@ "use strict"; | ||
const omit_1 = __importDefault(require("lodash/omit")); | ||
exports.default = (event) => (context) => __awaiter(void 0, void 0, void 0, function* () { | ||
exports.default = (event) => (context, next) => __awaiter(void 0, void 0, void 0, function* () { | ||
yield next(); | ||
const { result, params: { connection } } = context; | ||
if (!connection) { | ||
return context; | ||
if (connection) { | ||
const service = context.service; | ||
Object.assign(connection, omit_1.default(result, 'accessToken', 'authentication')); | ||
yield service.handleConnection(event, connection, result); | ||
} | ||
const service = context.service; | ||
Object.assign(connection, omit_1.default(result, 'accessToken', 'authentication')); | ||
yield service.handleConnection(event, connection, result); | ||
return context; | ||
}); | ||
//# sourceMappingURL=connection.js.map |
@@ -1,4 +0,4 @@ | ||
import { HookContext } from '@feathersjs/feathers'; | ||
import { HookContext, NextFunction } from '@feathersjs/feathers'; | ||
import { ConnectionEvent } from '../core'; | ||
declare const _default: (event: ConnectionEvent) => (context: HookContext) => Promise<HookContext<import("@feathersjs/feathers").Application<any, any>, any>>; | ||
declare const _default: (event: ConnectionEvent) => (context: HookContext, next: NextFunction) => Promise<void>; | ||
export default _default; |
@@ -14,3 +14,4 @@ "use strict"; | ||
const debug = commons_1.createDebug('@feathersjs/authentication/hooks/connection'); | ||
exports.default = (event) => (context) => __awaiter(void 0, void 0, void 0, function* () { | ||
exports.default = (event) => (context, next) => __awaiter(void 0, void 0, void 0, function* () { | ||
yield next(); | ||
const { app, result, params } = context; | ||
@@ -21,4 +22,3 @@ if (params.provider && result) { | ||
} | ||
return context; | ||
}); | ||
//# sourceMappingURL=event.js.map |
import * as hooks from './hooks'; | ||
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>>; | ||
declare const authenticate: (originalSettings: string | import("./hooks/authenticate").AuthenticateHookSettings, ...originalStrategies: string[]) => (context: import("@feathersjs/feathers/lib").HookContext<any, any>, _next?: import("@feathersjs/hooks/lib").NextFunction) => Promise<any>; | ||
export { hooks }; | ||
@@ -4,0 +4,0 @@ export { authenticate }; |
@@ -31,3 +31,3 @@ /// <reference types="node" /> | ||
accessToken: string; | ||
}>; | ||
} | null>; | ||
} |
@@ -147,6 +147,4 @@ "use strict"; | ||
this.hooks({ | ||
after: { | ||
create: [hooks_1.connection('login'), hooks_1.event('login')], | ||
remove: [hooks_1.connection('logout'), hooks_1.event('logout')] | ||
} | ||
create: [hooks_1.connection('login'), hooks_1.event('login')], | ||
remove: [hooks_1.connection('logout'), hooks_1.event('logout')] | ||
}); | ||
@@ -153,0 +151,0 @@ this.app.on('disconnect', (connection) => __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@feathersjs/authentication", | ||
"description": "Add Authentication to your FeathersJS app.", | ||
"version": "5.0.0-pre.4", | ||
"version": "5.0.0-pre.5", | ||
"homepage": "https://feathersjs.com", | ||
@@ -55,6 +55,6 @@ "main": "lib/", | ||
"dependencies": { | ||
"@feathersjs/commons": "^5.0.0-pre.4", | ||
"@feathersjs/errors": "^5.0.0-pre.4", | ||
"@feathersjs/feathers": "^5.0.0-pre.4", | ||
"@feathersjs/transport-commons": "^5.0.0-pre.4", | ||
"@feathersjs/commons": "^5.0.0-pre.5", | ||
"@feathersjs/errors": "^5.0.0-pre.5", | ||
"@feathersjs/feathers": "^5.0.0-pre.5", | ||
"@feathersjs/transport-commons": "^5.0.0-pre.5", | ||
"@types/jsonwebtoken": "^8.5.1", | ||
@@ -67,14 +67,13 @@ "jsonwebtoken": "^8.5.1", | ||
"devDependencies": { | ||
"@feathersjs/adapter-memory": "^5.0.0-pre.4", | ||
"@types/debug": "^4.1.5", | ||
"@types/lodash": "^4.14.169", | ||
"@feathersjs/memory": "^5.0.0-pre.5", | ||
"@types/lodash": "^4.14.170", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^15.0.3", | ||
"@types/node": "^15.12.1", | ||
"@types/uuid": "^8.3.0", | ||
"mocha": "^8.4.0", | ||
"shx": "^0.3.3", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.4" | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.2" | ||
}, | ||
"gitHead": "d2f1d200b6d9a790a03dc3e6e345f4e0ab726720" | ||
"gitHead": "738f84f91fb72d5e10a0bf57b58db75b0b03d3ff" | ||
} |
import flatten from 'lodash/flatten'; | ||
import omit from 'lodash/omit'; | ||
import { HookContext } from '@feathersjs/feathers'; | ||
import { HookContext, NextFunction } from '@feathersjs/feathers'; | ||
import { NotAuthenticated } from '@feathersjs/errors'; | ||
@@ -23,3 +23,4 @@ import { createDebug } from '@feathersjs/commons'; | ||
return async (context: HookContext<any, any>) => { | ||
return async (context: HookContext<any, any>, _next?: NextFunction) => { | ||
const next = typeof _next === 'function' ? _next : async () => context; | ||
const { app, params, type, path, service } = context; | ||
@@ -46,3 +47,3 @@ const { strategies } = settings; | ||
if (params.authenticated === true) { | ||
return context; | ||
return next(); | ||
} | ||
@@ -58,4 +59,2 @@ | ||
context.params = Object.assign({}, params, omit(authResult, 'accessToken'), { authenticated: true }); | ||
return context; | ||
} else if (provider) { | ||
@@ -65,4 +64,4 @@ throw new NotAuthenticated('Not authenticated'); | ||
return context; | ||
return next(); | ||
}; | ||
}; |
@@ -1,19 +0,17 @@ | ||
import { HookContext } from '@feathersjs/feathers'; | ||
import { HookContext, NextFunction } from '@feathersjs/feathers'; | ||
import omit from 'lodash/omit'; | ||
import { AuthenticationBase, ConnectionEvent } from '../core'; | ||
export default (event: ConnectionEvent) => async (context: HookContext) => { | ||
export default (event: ConnectionEvent) => async (context: HookContext, next: NextFunction) => { | ||
await next(); | ||
const { result, params: { connection } } = context; | ||
if (!connection) { | ||
return context; | ||
} | ||
if (connection) { | ||
const service = context.service as unknown as AuthenticationBase; | ||
const service = context.service as unknown as AuthenticationBase; | ||
Object.assign(connection, omit(result, 'accessToken', 'authentication')); | ||
Object.assign(connection, omit(result, 'accessToken', 'authentication')); | ||
await service.handleConnection(event, connection, result); | ||
return context; | ||
await service.handleConnection(event, connection, result); | ||
} | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { HookContext } from '@feathersjs/feathers'; | ||
import { HookContext, NextFunction } from '@feathersjs/feathers'; | ||
import { createDebug } from '@feathersjs/commons'; | ||
@@ -7,3 +7,5 @@ import { ConnectionEvent } from '../core'; | ||
export default (event: ConnectionEvent) => async (context: HookContext) => { | ||
export default (event: ConnectionEvent) => async (context: HookContext, next: NextFunction) => { | ||
await next(); | ||
const { app, result, params } = context; | ||
@@ -15,4 +17,2 @@ | ||
} | ||
return context; | ||
}; |
@@ -150,3 +150,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
async parse (req: IncomingMessage) { | ||
async parse (req: IncomingMessage): Promise<{ | ||
strategy: string; | ||
accessToken: string; | ||
} | null> { | ||
const { header, schemes }: { header: string, schemes: string[] } = this.configuration; | ||
@@ -153,0 +156,0 @@ const headerValue = req.headers && req.headers[header.toLowerCase()]; |
@@ -175,6 +175,4 @@ import merge from 'lodash/merge'; | ||
(this as any).hooks({ | ||
after: { | ||
create: [ connection('login'), event('login') ], | ||
remove: [ connection('logout'), event('logout') ] | ||
} | ||
create: [ connection('login'), event('login') ], | ||
remove: [ connection('logout'), event('logout') ] | ||
}); | ||
@@ -181,0 +179,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
195864
9
1617