diff --git a/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts b/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts index 155bb928e3..4df23a6955 100644 --- a/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts +++ b/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts @@ -8,15 +8,17 @@ server.register({ }); const options: auth.Options = { - clearInvalid: true, - cookie: 'session', - domain: '.typescript.org', + cookie: { + clearInvalid: true, + name: 'session', + domain: '.typescript.org', + password: 'abcdef', + isSecure: true, + ttl: 259200000, + }, keepAlive: true, - password: 'abcdef', redirectTo: '/login', - isSecure: true, appendNext: false, - ttl: 259200000, validateFunc: async () => { return { valid: true }; }, diff --git a/types/hapi-auth-cookie/index.d.ts b/types/hapi-auth-cookie/index.d.ts index 8184ffd2fe..bcae2b3bdc 100644 --- a/types/hapi-auth-cookie/index.d.ts +++ b/types/hapi-auth-cookie/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for hapi-auth-cookie 9.1 +// Type definitions for hapi-auth-cookie 10.0 // Project: https://github.com/hapijs/hapi-auth-cookie // Definitions by: Silas Rech // Simon Schick @@ -32,51 +32,18 @@ declare module 'hapi' { declare namespace hapiAuthCookie { interface ValidateResponse { valid: boolean; credentials?: AuthCredentials; } type ValidateFunction = (request?: Request, session?: object) => Promise; - type RedirectToFunction = (request?: Request) => void; + type RedirectToFunction = (request?: Request) => string; /** * Options passed to 'hapi.auth.strategy' when this plugin is used */ interface Options { /** - * The cookie name. + * Cookie options. * - * @default 'sid' + * @default { name: 'sid', clearInvalid: false, isSameSite: 'Strict', isSecure: true, isHttpOnly: true } */ - cookie?: string; - - /** - * Used for Iron cookie encoding. - * Should be at least 32 characters long. - */ - password: string; - - /** - * Sets the cookie expires time in milliseconds. - * Required when 'keepAlive' is true. - * Defaults to single browser session (ends when browser closes). - */ - ttl?: number; - - /** - * Sets the cookie Domain value. - * Defaults to none. - */ - domain?: string; - - /** - * Sets the cookie path value. - * - * @default '/' - */ - path?: string; - - /** - * Any authentication cookie that fails validation will be marked as expired in the response and cleared. - * - * @default false - */ - clearInvalid?: boolean; + cookie?: ServerStateCookieOptions & { name: string }; /** * Automatically sets the session cookie after validation to extend the current session for a new TTL duration. @@ -85,28 +52,6 @@ declare namespace hapiAuthCookie { */ keepAlive?: boolean; - /** - * If false omitted. - * Other options Strict or Lax. - * - * @default 'Strict' - */ - isSameSite?: ServerStateCookieOptions['isSameSite']; - - /** - * If false, the cookie is allowed to be transmitted over insecure connections which exposes it to attacks. - * - * @default true - */ - isSecure?: boolean; - - /** - * If false, the cookie will not include the 'HttpOnly' flag. - * - * @default true - */ - isHttpOnly?: boolean; - /** * Login URI or function that returns a URI to redirect unauthenticated requests to. * Note that it will only trigger when the authentication mode is 'required'.