chore: Small refactor

This commit is contained in:
Sam Tolmay 2023-10-30 17:18:52 +02:00
parent f89a885540
commit bbd4353d0f
No known key found for this signature in database
5 changed files with 13 additions and 11 deletions

View File

@ -21,12 +21,12 @@ import createSignInCallback from './createSignInCallback.js';
function createCallbacks({ authConfig, logger, plugins }) {
const callbacks = {
session: createSessionCallback({ authConfig, plugins }),
session: createSessionCallback({ authConfig, logger, plugins }),
};
const jwt = createJWTCallback({ authConfig, logger, plugins });
if (jwt) callbacks.jwt = jwt;
const redirect = createRedirectCallback({ authConfig, plugins });
const redirect = createRedirectCallback({ authConfig, logger, plugins });
if (redirect) callbacks.redirect = redirect;
const signIn = createSignInCallback({ authConfig, plugins });

View File

@ -45,11 +45,11 @@ function getNextAuthConfig({ authJson, logger, plugins, secrets }) {
throw new Error(operatorErrors[0]);
}
nextAuthConfig.adapter = createAdapter({ authConfig, plugins });
nextAuthConfig.adapter = createAdapter({ authConfig, logger, plugins });
nextAuthConfig.callbacks = createCallbacks({ authConfig, logger, plugins });
nextAuthConfig.events = createEvents({ authConfig, logger, plugins });
nextAuthConfig.logger = createLogger({ logger });
nextAuthConfig.providers = createProviders({ authConfig, plugins });
nextAuthConfig.providers = createProviders({ authConfig, logger, plugins });
nextAuthConfig.debug = authConfig.debug ?? logger?.isLevelEnabled('debug') === true;
nextAuthConfig.pages = authConfig.authPages;
nextAuthConfig.session = authConfig.session;

View File

@ -55,7 +55,7 @@ async function sha1(filePath) {
return crypto
.createHash('sha1')
.update(content || '')
.digest('hex');
.digest('base64');
}
async function nextBuildWatcher(context) {

View File

@ -22,16 +22,18 @@ const config = {
},
};
let license;
async function validateLicense() {
if (global.license) {
if (license) {
// Check cached license every 24 hours
if (global.license?.timestamp.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
return global.license;
if (license?.timestamp.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
return license;
}
}
global.license = await keygenValidateLicense({ config: config['dev'] });
return global.license;
license = await keygenValidateLicense({ config: config['dev'] });
return license;
}
export default validateLicense;

View File

@ -19,7 +19,7 @@ import crypto from 'crypto';
function getCacheKey(fileData, filePath, options) {
const optionsString = typeof options === 'string' ? options : JSON.stringify(options);
return crypto.createHash('sha1').update(fileData).update(optionsString).digest('hex');
return crypto.createHash('sha1').update(fileData).update(optionsString).digest('base64');
}
function process(sourceText) {