<commit_before>'use strict';

const Hoek = require('hoek');
const Joi = require('joi');

const OAuth = require('./oauth');
const Providers = require('./providers');


const internals = {
    simulate: false,
    flexBoolean: Joi.boolean().truthy('true', 'yes', 1, '1').falsy('false', 'no', 0, '0')
};


// Utilities

exports.providers = Providers;

exports.oauth = OAuth;


// Plugin

exports.plugin = {
    pkg: require('../package.json'),
    requirements: {
        hapi: '>=17.7.0'
    },

    register: function (server, options) {

        server.auth.scheme('bell', internals.implementation);
        server.expose('oauth', OAuth);
    }
};


internals.schema = Joi.object({
    provider: Joi.object({
        name: Joi.string().optional().default('custom'),
        protocol: Joi.string().valid('oauth', 'oauth2'),
        temporary: Joi.string().when('protocol', { is: 'oauth', then: Joi.required(), otherwise: Joi.forbidden() }),
        signatureMethod: Joi.string().valid('HMAC-SHA1', 'RSA-SHA1').when('protocol', { is: 'oauth', then: Joi.default('HMAC-SHA1'), otherwise: Joi.forbidden() }),
        auth: Joi.string().required(),
        useParamsAuth: internals.flexBoolean.default(false).when('protocol', { is: 'oauth2', then: Joi.optional(), otherwise: Joi.forbidden() }),
        token: Joi.string().required(),
        headers: Joi.object(),
        profile: Joi.func(),
        profileMethod: Joi.string().valid('get', 'post').default('get'),
        scope: Joi.alternatives().try(
            Joi.array().items(Joi.string()),
            Joi.func()
        ).when('protocol', { is: 'oauth2', otherwise: Joi.forbidden() }),
        scopeSeparator: Joi.string().when('protocol', { is: 'oauth2', otherwise: Joi.forbidden() })
    }).required(),
    password: Joi.string().required(),
    clientId: Joi.string().required(),
    clientSecret: Joi.alternatives().when('protocol', {
        is: 'oauth',
        then: Joi.string().required().allow(''),
        otherwise: Joi.alternatives().try(Joi.string().allow(''), Joi.object())
    }).required(),
    cookie: Joi.string(),
    isSameSite: Joi.string().allow(false).default('Strict'),
    isSecure: internals.flexBoolean,
    isHttpOnly: internals.flexBoolean,
    ttl: Joi.number(),
    domain: Joi.string().allow(null),
    providerParams: Joi.alternatives().try(Joi.object(), Joi.func()),
    allowRuntimeProviderParams: internals.flexBoolean.default(false),
    scope: Joi.alternatives().try(
        Joi.array().items(Joi.string()),
        Joi.func()
    ).when('provider.protocol', { is: 'oauth2', otherwise: Joi.forbidden() }),
    name: Joi.string().required(),
    config: Joi.object(),
    profileParams: Joi.object(),
    skipProfile: internals.flexBoolean.optional().default(false),
    forceHttps: internals.flexBoolean.optional().default(false),
    location: Joi.alternatives().try(
        Joi.func().maxArity(1),
        Joi.string()
    ).default(false),
    runtimeStateCallback: Joi.func().optional()
});


internals.implementation = function (server, options) {<commit_msg>fix(schema): make isSameSite schema the same as hapi's<commit_after>'use strict';

const Hoek = require('hoek');
const Joi = require('joi');

const OAuth = require('./oauth');
const Providers = require('./providers');


const internals = {
    simulate: false,
    flexBoolean: Joi.boolean().truthy('true', 'yes', 1, '1').falsy('false', 'no', 0, '0')
};


// Utilities

exports.providers = Providers;

exports.oauth = OAuth;


// Plugin

exports.plugin = {
    pkg: require('../package.json'),
    requirements: {
        hapi: '>=17.7.0'
    },

    register: function (server, options) {

        server.auth.scheme('bell', internals.implementation);
        server.expose('oauth', OAuth);
    }
};


internals.schema = Joi.object({
    provider: Joi.object({
        name: Joi.string().optional().default('custom'),
        protocol: Joi.string().valid('oauth', 'oauth2'),
        temporary: Joi.string().when('protocol', { is: 'oauth', then: Joi.required(), otherwise: Joi.forbidden() }),
        signatureMethod: Joi.string().valid('HMAC-SHA1', 'RSA-SHA1').when('protocol', { is: 'oauth', then: Joi.default('HMAC-SHA1'), otherwise: Joi.forbidden() }),
        auth: Joi.string().required(),
        useParamsAuth: internals.flexBoolean.default(false).when('protocol', { is: 'oauth2', then: Joi.optional(), otherwise: Joi.forbidden() }),
        token: Joi.string().required(),
        headers: Joi.object(),
        profile: Joi.func(),
        profileMethod: Joi.string().valid('get', 'post').default('get'),
        scope: Joi.alternatives().try(
            Joi.array().items(Joi.string()),
            Joi.func()
        ).when('protocol', { is: 'oauth2', otherwise: Joi.forbidden() }),
        scopeSeparator: Joi.string().when('protocol', { is: 'oauth2', otherwise: Joi.forbidden() })
    }).required(),
    password: <PASSWORD>().required(),
    clientId: Joi.string().required(),
    clientSecret: Joi.alternatives().when('protocol', {
        is: 'oauth',
        then: Joi.string().required().allow(''),
        otherwise: Joi.alternatives().try(Joi.string().allow(''), Joi.object())
    }).required(),
    cookie: Joi.string(),
    isSameSite: Joi.valid('Strict', 'Lax').allow(false).default('Strict'),
    isSecure: internals.flexBoolean,
    isHttpOnly: internals.flexBoolean,
    ttl: Joi.number(),
    domain: Joi.string().allow(null),
    providerParams: Joi.alternatives().try(Joi.object(), Joi.func()),
    allowRuntimeProviderParams: internals.flexBoolean.default(false),
    scope: Joi.alternatives().try(
        Joi.array().items(Joi.string()),
        Joi.func()
    ).when('provider.protocol', { is: 'oauth2', otherwise: Joi.forbidden() }),
    name: Joi.string().required(),
    config: Joi.object(),
    profileParams: Joi.object(),
    skipProfile: internals.flexBoolean.optional().default(false),
    forceHttps: internals.flexBoolean.optional().default(false),
    location: Joi.alternatives().try(
        Joi.func().maxArity(1),
        Joi.string()
    ).default(false),
    runtimeStateCallback: Joi.func().optional()
});


internals.implementation = function (server, options) {
{'fraction_non_alphanumeric': 0.19485353617090145, 'fraction_numerical': 0.005502508496520473, 'mean_word_length': 3.5241581259150805, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6383028', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1979, 'n_words': 344}