Add definitions for 16 packages of the @feathersjs scope (#22805)

* add various packages in @feathersjs scope

* formatting, make feathers package pass linting.

* add typings for feathersjs core packages:

@feathersjs/authentication
@feathersjs/authentication-client
@feathersjs/authentication-jwt
@feathersjs/authentication-local
@feathersjs/authentication-oauth1
@feathersjs/authentication-oauth2
@feathersjs/configuration
@feathersjs/errors
@feathersjs/express
@feathersjs/feathers
@feathersjs/primus
@feathersjs/primus-client
@feathersjs/rest-client
@feathersjs/socket-commons
@feathersjs/socketio
@feathersjs/socketio-client

* remove unnecessary package.json files

* fix TS versions

* add some tests, fix errors module, add doc comments, minor todos left
This commit is contained in:
Jan Lohage
2018-01-17 11:16:10 -08:00
committed by Wesley Wigham
parent 426d98a191
commit ea29e9588e
69 changed files with 1418 additions and 0 deletions
@@ -0,0 +1,4 @@
import feathers from '@feathersjs/feathers';
import feathersAuthentication from '@feathersjs/authentication';
feathers().configure(feathersAuthentication({}));
+106
View File
@@ -0,0 +1,106 @@
// Type definitions for @feathersjs/authentication 2.1
// Project: http://feathersjs.com/
// Definitions by: Abraao Alves <https://github.com/AbraaoAlves>, Jan Lohage <https://github.com/j2L4e>
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
import { Hook } from '@feathersjs/feathers';
export default function feathersAuthentication(config?: FeathersAuthenticationOptions): () => void;
export const hooks: AuthHooks.Hooks;
export interface FeathersAuthenticationOptions {
path?: string;
header?: string;
entity?: string;
service?: string;
passReqToCallback?: boolean;
session?: boolean;
cookie?: {
enabled?: boolean;
name?: string;
httpOnly?: boolean;
secure?: boolean;
};
jwt?: {
/**
* By default is an access token
*/
header?: {
[key: string]: any
};
/**
* The resource server where the token is processed
*/
audience?: string;
/**
* Typically the entity id associated with the JWT
*/
subject?: string;
/**
* The issuing server, application or resource
*/
issuer?: string;
algorithm?: string;
expiresIn?: string;
};
}
export namespace AuthHooks {
interface HashPassOptions {
passwordField: string;
}
interface RestrictOptions {
ownerField: string;
idField: string;
}
interface Hooks {
authenticate(strategies: string[] | string): Hook;
/**
* The `verifyToken` hook will attempt to verify a token.
* If the token is missing or is invalid it returns an error.
* If the token is valid it adds the decrypted payload to hook.params.payload which contains the user id.
* It is intended to be used as a before hook on any of the service methods.
*
*/
verifyToken(options?: any): Hook;
/**
* The populateUser hook is for populating a user based on an id.
* It can be used on any service method as either a before or after hook.
* It is called internally after a token is created.
*
*/
populateUser(options?: any): Hook;
/**
* The `restrictToAuthenticated` hook throws an error if there isn't a logged-in user by checking for the `hook.params.user` object.
* It can be used on any service method and is intended to be used as a before hook.
* It doesn't take any arguments.
*
*/
restrictToAuthenticated(): Hook;
/**
* `restrictToOwner` is meant to be used as a before hook.
* It only allows the user to retrieve resources that are owned by them.
* It will return a *Forbidden* error without the proper permissions.
* It can be used on `get`, `create`, `update`, `patch` or `remove` methods.
*
*/
restrictToOwner(options?: RestrictOptions): Hook;
/**
* The `hashPassword` hook will automatically hash the data coming in on the provided passwordField.
* It is intended to be used as a before hook on the user service for the create, update, or patch methods.
*
*/
hashPassword(options?: HashPassOptions): Hook;
}
}
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@feathersjs/authentication": ["feathersjs__authentication"],
"@feathersjs/feathers": ["feathersjs__feathers"]
}
},
"files": [
"index.d.ts", "feathersjs__authentication-tests.ts"
]
}
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}