From 1d964920cff0c3fb688c313ede736fd5dafdc884 Mon Sep 17 00:00:00 2001 From: Justin Simms Date: Thu, 8 Feb 2018 20:15:33 -0600 Subject: [PATCH] Remove the enums --- .../definitions/request/request-events.d.ts | 5 --- .../route/route-options-access.d.ts | 43 ++----------------- .../route/route-options-cache.d.ts | 8 +--- types/hapi/test/route/route-options.ts | 12 ++---- 4 files changed, 8 insertions(+), 60 deletions(-) diff --git a/types/hapi/definitions/request/request-events.d.ts b/types/hapi/definitions/request/request-events.d.ts index 7b750d360b..dfcb004d24 100644 --- a/types/hapi/definitions/request/request-events.d.ts +++ b/types/hapi/definitions/request/request-events.d.ts @@ -42,9 +42,4 @@ export interface RequestEvents extends Podium { once(criteria: "peek", listener: PeekListener): void; once(criteria: "finish" | "disconnect", listener: () => void): void; once(criteria: RequestEventType, listener: Function): void; - - - - // TODO is it necessary to implement "emmit" event here? - } diff --git a/types/hapi/definitions/route/route-options-access.d.ts b/types/hapi/definitions/route/route-options-access.d.ts index 6cdc703cf4..de815c44c0 100644 --- a/types/hapi/definitions/route/route-options-access.d.ts +++ b/types/hapi/definitions/route/route-options-access.d.ts @@ -1,40 +1,3 @@ -/** - * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: - * * 'any' - the authentication can be on behalf of a user or application. - * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. - * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) - */ -export const enum RouteOptionsAccessEntity { - Any = 'any', - User = 'user', - App = 'app' -} - -/** - * The authentication mode. Available values: - * * 'required' - authentication is required. - * * 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. - * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) - */ -export const enum RouteOptionsAccessMode { - Required = 'required', - Optional = 'optional', - Try = 'try', -} - -/** - * Available values: - * * false - no payload authentication. - * * 'required' - payload authentication required. - * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) - */ -export const enum RouteOptionsAccessPayload { - Required = 'required', - Optional = 'optional', -} /** * Route Authentication Options @@ -65,7 +28,7 @@ export interface RouteOptionsAccess { * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) */ - entity?: RouteOptionsAccessEntity; + entity?: 'any' | 'user' | 'app'; /** * Default value: 'required'. @@ -75,7 +38,7 @@ export interface RouteOptionsAccess { * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) */ - mode?: RouteOptionsAccessMode; + mode?: 'required' | 'optional' | 'try'; /** * Default value: false, unless the scheme requires payload authentication. @@ -86,7 +49,7 @@ export interface RouteOptionsAccess { * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) */ - payload?: false | RouteOptionsAccessPayload; + payload?: false | 'required' | 'optional'; /** * Default value: the default strategy set via server.auth.default(). diff --git a/types/hapi/definitions/route/route-options-cache.d.ts b/types/hapi/definitions/route/route-options-cache.d.ts index 2120bcbba9..1b17ee4e96 100644 --- a/types/hapi/definitions/route/route-options-cache.d.ts +++ b/types/hapi/definitions/route/route-options-cache.d.ts @@ -1,9 +1,3 @@ -export const enum RouteOptionsPrivacy { - Default = 'default', - Public = 'public', - Private = 'private' -} - /** * Values are: * * * 'default' - no privacy flag. @@ -16,7 +10,7 @@ export const enum RouteOptionsPrivacy { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) */ export type RouteOptionsCache = { - privacy?: RouteOptionsPrivacy; + privacy?: 'default' | 'public' | 'privacy'; statuses?: number[]; otherwise?: string; } & ( diff --git a/types/hapi/test/route/route-options.ts b/types/hapi/test/route/route-options.ts index 60c2810e73..333fd9cbf6 100644 --- a/types/hapi/test/route/route-options.ts +++ b/types/hapi/test/route/route-options.ts @@ -4,12 +4,8 @@ import { ResponseToolkit, RouteOptions, RouteOptionsAccess, - RouteOptionsAccessEntity, - RouteOptionsAccessMode, - RouteOptionsAccessPayload, RouteOptionsCors, RouteOptionsPayload, - RouteOptionsPrivacy, RouteOptionsResponse, RouteOptionsValidate, Server @@ -18,9 +14,9 @@ import { const routeOptionsAccess: RouteOptionsAccess = { access: {}, scope: false, - entity: RouteOptionsAccessEntity.User, - mode: RouteOptionsAccessMode.Optional, - payload: RouteOptionsAccessPayload.Optional, + entity: 'user', + mode: 'optional', + payload: 'optional', strategies: ['', ''], strategy: '' }; @@ -103,7 +99,7 @@ const routeOptions: RouteOptions = { auth: routeOptionsAccess, bind: null, cache: { - privacy: RouteOptionsPrivacy.Default, + privacy: 'default', statuses: [200], otherwise: 'no-cache' },