authen-express 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authen-express",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "authen-express",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -21,15 +21,15 @@ export interface Privilege {
21
21
  children?: Privilege[];
22
22
  permissions?: number;
23
23
  }
24
- export interface AuthResult {
24
+ export interface AuthResult<ID> {
25
25
  status: number | string;
26
- user?: UserAccount;
26
+ user?: UserAccount<ID>;
27
27
  message?: string;
28
28
  }
29
- export type Result = AuthResult;
30
- export type LoginResult = AuthResult;
31
- export interface UserAccount {
32
- id?: string;
29
+ export type Result<ID> = AuthResult<ID>;
30
+ export type LoginResult<ID> = AuthResult<ID>;
31
+ export interface UserAccount<ID> {
32
+ id?: ID;
33
33
  username?: string;
34
34
  contact?: string;
35
35
  email?: string;
@@ -48,8 +48,8 @@ export interface UserAccount {
48
48
  gender?: string;
49
49
  imageURL?: string;
50
50
  }
51
- export class AuthenticationController<T extends User> {
52
- constructor (public log: Log, public login: (user: T) => Promise<AuthResult>, public cookie?: boolean, public decrypt?: (cipherText: string) => string|undefined) {
51
+ export class AuthenticationController<T extends User, ID> {
52
+ constructor (protected log: Log, protected login: (user: T) => Promise<AuthResult<ID>>, protected cookie?: boolean, protected decrypt?: (cipherText: string) => string|undefined) {
53
53
  this.authenticate = this.authenticate.bind(this);
54
54
  }
55
55
  authenticate(req: Request, res: Response) {
@@ -92,7 +92,7 @@ export class AuthenticationController<T extends User> {
92
92
  export const AuthenticationHandler = AuthenticationController;
93
93
  // tslint:disable-next-line:max-classes-per-file
94
94
  export class PrivilegeController {
95
- constructor(private log: Log, public privileges: () => Promise<Privilege[]>) {
95
+ constructor(private log: Log, private privileges: () => Promise<Privilege[]>) {
96
96
  this.all = this.all.bind(this);
97
97
  }
98
98
  all(req: Request, res: Response) {