From e11a7c132bac4802658b6e541222ea7d31eef9ed Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sat, 28 Mar 2020 18:37:45 -0600 Subject: [PATCH] jsonwebtoken --- packages/next/next-server/server/api-utils.ts | 4 ++-- packages/next/package.json | 2 +- packages/next/taskfile.js | 8 ++++++++ packages/next/types/misc.d.ts | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/next/next-server/server/api-utils.ts b/packages/next/next-server/server/api-utils.ts index f1e933e26d..bc76edab2f 100644 --- a/packages/next/next-server/server/api-utils.ts +++ b/packages/next/next-server/server/api-utils.ts @@ -302,7 +302,7 @@ export function tryGetPreviewData( const tokenPreviewData = cookies[COOKIE_NAME_PRERENDER_DATA] - const jsonwebtoken = require('jsonwebtoken') as typeof import('jsonwebtoken') + const jsonwebtoken = require('next/dist/compiled/jsonwebtoken') as typeof import('jsonwebtoken') let encryptedPreviewData: string try { encryptedPreviewData = jsonwebtoken.verify( @@ -360,7 +360,7 @@ function setPreviewData( throw new Error('invariant: invalid previewModeSigningKey') } - const jsonwebtoken = require('jsonwebtoken') as typeof import('jsonwebtoken') + const jsonwebtoken = require('next/dist/compiled/jsonwebtoken') as typeof import('jsonwebtoken') const payload = jsonwebtoken.sign( encryptWithSecret( diff --git a/packages/next/package.json b/packages/next/package.json index ba0182e22c..b10ca110a6 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -71,7 +71,6 @@ "fork-ts-checker-webpack-plugin": "3.1.1", "ignore-loader": "0.1.2", "jest-worker": "24.9.0", - "jsonwebtoken": "8.5.1", "launch-editor": "2.2.1", "loader-utils": "2.0.0", "lodash.curry": "4.1.1", @@ -193,6 +192,7 @@ "is-docker": "2.0.0", "is-wsl": "2.1.1", "json5": "2.1.2", + "jsonwebtoken": "8.5.1", "nanoid": "2.0.3", "resolve": "1.11.0", "taskr": "1.1.0", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index fc94fde698..43acb5e9cc 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -370,6 +370,13 @@ export async function ncc_json5(task, opts) { .target('dist/compiled/json5') } // eslint-disable-next-line camelcase +export async function ncc_jsonwebtoken(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('jsonwebtoken'))) + .ncc({ packageName: 'jsonwebtoken' }) + .target('dist/compiled/jsonwebtoken') +} +// eslint-disable-next-line camelcase export async function ncc_nanoid(task, opts) { await task .source(opts.src || relative(__dirname, require.resolve('nanoid'))) @@ -441,6 +448,7 @@ export async function precompile(task) { 'ncc_is_docker', 'ncc_is_wsl', 'ncc_json5', + 'ncc_jsonwebtoken', 'ncc_nanoid', 'ncc_resolve', 'ncc_text_table', diff --git a/packages/next/types/misc.d.ts b/packages/next/types/misc.d.ts index 4f6ecd9bb7..561c43d7ae 100644 --- a/packages/next/types/misc.d.ts +++ b/packages/next/types/misc.d.ts @@ -120,6 +120,10 @@ declare module 'next/dist/compiled/json5' { import m from 'json5' export = m } +declare module 'next/dist/compiled/jsonwebtoken' { + import m from 'jsonwebtoken' + export = m +} declare module 'next/dist/compiled/nanoid/index.js' { function nanoid(size?: number): string export = nanoid -- GitLab