Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
],
"license": "ISC",
"dependencies": {
"@balazsorban/require-optional": "^1.0.0",
"futoin-hkdf": "^1.3.2",
"jose": "^1.27.2",
"jsonwebtoken": "^8.5.1",
"oauth": "^0.9.15",
"optional-require": "^1.0.3",
"pkce-challenge": "^2.1.0",
"preact": "^10.4.1",
"preact-render-to-string": "^5.1.14"
Expand Down
8 changes: 6 additions & 2 deletions src/adapters/typeorm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Models from './models'

import { updateConnectionEntities } from './lib/utils'

import optionalRequire from 'optional-require'
import requireOptional from '@balazsorban/require-optional'

const Adapter = (typeOrmConfig, options = {}) => {
// Ensure typeOrmConfigObject is normalized to an object
Expand Down Expand Up @@ -95,7 +95,11 @@ const Adapter = (typeOrmConfig, options = {}) => {
let ObjectId
if (config.type === 'mongodb') {
idKey = '_id'
const mongodb = optionalRequire('mongodb')
// We should/could use dynamic import here, but
// bundlers like webpack will try to import the module,
// even if this conditional branch is never entered.
// We work around this with requireOptional.
const mongodb = requireOptional('mongodb')
ObjectId = mongodb.ObjectID
}

Expand Down
4 changes: 2 additions & 2 deletions src/providers/email.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logger from '../lib/logger'
import optionalRequire from 'optional-require'
import requireOptional from '@balazsorban/require-optional'

export default (options) => {
return {
Expand Down Expand Up @@ -27,7 +27,7 @@ async function sendVerificationRequest ({ identifier: email, url, baseUrl, provi
// Strip protocol from URL and use domain as site name
const site = baseUrl.replace(/^https?:\/\//, '')
try {
const nodemailer = optionalRequire('nodemailer')
const nodemailer = requireOptional('nodemailer')
await nodemailer
.createTransport(server)
.sendMail({
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import csrfTokenHandler from './lib/csrf-token-handler'
import * as pkce from './lib/oauth/pkce-handler'
import * as state from './lib/oauth/state-handler'

import optionalRequire from 'optional-require'
import optionalRequire from '@balazsorban/require-optional'

// To work properly in production with OAuth providers the NEXTAUTH_URL
// environment variable must be set.
Expand Down