New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@feathersjs/authentication

Package Overview
Dependencies
Maintainers
4
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feathersjs/authentication - npm Package Compare versions

Comparing version 4.3.0-pre.1 to 4.3.0-pre.2

6

lib/hooks/authenticate.js

@@ -27,5 +27,5 @@ "use strict";

const { app, params, type, path, service } = context;
const { service: authPath = app.get('defaultAuthentication'), strategies } = settings;
const { strategies } = settings;
const { provider, authentication } = params;
const authService = app.service(authPath);
const authService = app.defaultAuthentication(settings.service);
debug(`Running authenticate hook on '${path}'`);

@@ -36,3 +36,3 @@ if (type && type !== 'before') {

if (!authService || typeof authService.authenticate !== 'function') {
throw new errors_1.NotAuthenticated(`Could not find authentication service at '${authPath}'`);
throw new errors_1.NotAuthenticated('Could not find a valid authentication service');
}

@@ -39,0 +39,0 @@ // @ts-ignore

@@ -0,1 +1,2 @@

/// <reference path="service.d.ts" />
import * as hooks from './hooks';

@@ -2,0 +3,0 @@ declare const authenticate: (originalSettings: string | import("./hooks/authenticate").AuthenticateHookSettings, ...originalStrategies: string[]) => (context: import("@feathersjs/feathers").HookContext<any>) => Promise<import("@feathersjs/feathers").HookContext<any>>;

/// <reference types="node" />
import { AuthenticationRequest } from './core';
import { AuthenticationRequest, AuthenticationResult } from './core';
import { Params } from '@feathersjs/feathers';

@@ -15,2 +15,3 @@ import { IncomingMessage } from 'http';

getEntity(id: string, params: Params): Promise<any>;
getEntityId(authResult: AuthenticationResult, _params: Params): Promise<any>;
authenticate(authentication: AuthenticationRequest, params: Params): Promise<{

@@ -17,0 +18,0 @@ accessToken: any;

@@ -48,2 +48,7 @@ "use strict";

}
getEntityId(authResult, _params) {
return __awaiter(this, void 0, void 0, function* () {
return authResult.authentication.payload.sub;
});
}
authenticate(authentication, params) {

@@ -57,3 +62,2 @@ return __awaiter(this, void 0, void 0, function* () {

const payload = yield this.authentication.verifyAccessToken(accessToken, params.jwt);
const entityId = payload.sub;
const result = {

@@ -66,2 +70,3 @@ accessToken,

};
const entityId = yield this.getEntityId(result, params);
if (entity === null) {

@@ -68,0 +73,0 @@ return result;

import { AuthenticationBase, AuthenticationResult, AuthenticationRequest } from './core';
import { Params, ServiceMethods } from '@feathersjs/feathers';
import { Application, Params, ServiceMethods } from '@feathersjs/feathers';
declare module '@feathersjs/feathers' {
interface Application<ServiceTypes = {}> {
/**
* Returns the default authentication service or the
* authentication service for a given path.
*
* @param location The service path to use (optional)
*/
defaultAuthentication(location?: string): AuthenticationService;
}
}
export declare class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult>> {
constructor(app: Application, configKey?: string, options?: {});
/**

@@ -5,0 +17,0 @@ * Return the payload for a JWT based on the authentication result.

@@ -21,2 +21,12 @@ "use strict";

class AuthenticationService extends core_1.AuthenticationBase {
constructor(app, configKey = 'authentication', options = {}) {
super(app, configKey, options);
if (typeof app.defaultAuthentication !== 'function') {
app.defaultAuthentication = function (location) {
const configKey = app.get('defaultAuthentication');
const path = location || Object.keys(this.services).find(current => this.service(current).configKey === configKey);
return path ? this.service(path) : null;
};
}
}
/**

@@ -23,0 +33,0 @@ * Return the payload for a JWT based on the authentication result.

{
"name": "@feathersjs/authentication",
"description": "Add Authentication to your FeathersJS app.",
"version": "4.3.0-pre.1",
"version": "4.3.0-pre.2",
"homepage": "https://feathersjs.com",

@@ -42,3 +42,3 @@ "main": "lib/",

"dependencies": {
"@feathersjs/errors": "^4.3.0-pre.1",
"@feathersjs/errors": "^4.3.0-pre.2",
"debug": "^4.1.1",

@@ -50,3 +50,3 @@ "jsonwebtoken": "^8.5.1",

"devDependencies": {
"@feathersjs/feathers": "^4.3.0-pre.1",
"@feathersjs/feathers": "^4.3.0-pre.2",
"@types/debug": "^4.1.4",

@@ -64,3 +64,3 @@ "@types/jsonwebtoken": "^8.3.2",

},
"gitHead": "e0b7e978ae31d55a168d8257195134e461c4c6fb"
"gitHead": "4d350e5299315df3090a2231ef3caaf795dee994"
}

@@ -5,3 +5,2 @@ import { flatten, omit, merge } from 'lodash';

import Debug from 'debug';
import { AuthenticationService } from '../service';

@@ -26,8 +25,5 @@ const debug = Debug('@feathersjs/authentication/hooks/authenticate');

const { app, params, type, path, service } = context;
const {
service: authPath = app.get('defaultAuthentication'),
strategies
} = settings;
const { strategies } = settings;
const { provider, authentication } = params;
const authService = app.service(authPath) as unknown as AuthenticationService;
const authService = app.defaultAuthentication(settings.service);

@@ -41,3 +37,3 @@ debug(`Running authenticate hook on '${path}'`);

if (!authService || typeof authService.authenticate !== 'function') {
throw new NotAuthenticated(`Could not find authentication service at '${authPath}'`);
throw new NotAuthenticated('Could not find a valid authentication service');
}

@@ -44,0 +40,0 @@

import { NotAuthenticated } from '@feathersjs/errors';
import { omit } from 'lodash';
import { AuthenticationRequest } from './core';
import { AuthenticationRequest, AuthenticationResult } from './core';
import { Params } from '@feathersjs/feathers';

@@ -56,2 +56,6 @@ import { IncomingMessage } from 'http';

async getEntityId (authResult: AuthenticationResult, _params: Params) {
return authResult.authentication.payload.sub;
}
async authenticate (authentication: AuthenticationRequest, params: Params) {

@@ -66,3 +70,2 @@ const { accessToken } = authentication;

const payload = await this.authentication.verifyAccessToken(accessToken, params.jwt);
const entityId = payload.sub;
const result = {

@@ -75,2 +78,3 @@ accessToken,

};
const entityId = await this.getEntityId(result, params);

@@ -77,0 +81,0 @@ if (entity === null) {

@@ -6,7 +6,34 @@ import Debug from 'debug';

import { connection, events } from './hooks';
import { Params, ServiceMethods } from '@feathersjs/feathers';
import { Application, Params, ServiceMethods } from '@feathersjs/feathers';
const debug = Debug('@feathersjs/authentication/service');
declare module '@feathersjs/feathers' {
interface Application<ServiceTypes = {}> {
/**
* Returns the default authentication service or the
* authentication service for a given path.
*
* @param location The service path to use (optional)
*/
defaultAuthentication (location?: string): AuthenticationService;
}
}
export class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult>> {
constructor (app: Application, configKey: string = 'authentication', options = {}) {
super(app, configKey, options);
if (typeof app.defaultAuthentication !== 'function') {
app.defaultAuthentication = function (location?: string) {
const configKey = app.get('defaultAuthentication');
const path = location || Object.keys(this.services).find(current =>
this.service(current).configKey === configKey
);
return path ? this.service(path) : null;
};
}
}
/**

@@ -13,0 +40,0 @@ * Return the payload for a JWT based on the authentication result.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc