From 4d801409b40b5916e08e6c71622270883f1d9083 Mon Sep 17 00:00:00 2001 From: Chae Jeong Ah Date: Sun, 29 Jan 2023 18:28:53 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20.p8=20=ED=8C=8C=EC=9D=BC=20string=20?= =?UTF-8?q?=EB=B3=80=ED=99=98=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?(#310)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/lib/appleAuth.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/lib/appleAuth.js b/functions/lib/appleAuth.js index 2c486be..77d5141 100644 --- a/functions/lib/appleAuth.js +++ b/functions/lib/appleAuth.js @@ -6,13 +6,10 @@ const fs = require('fs').promises; const { resolve } = require('path'); const qs = require('qs'); -const dotenv = require('dotenv'); -dotenv.config(); - const appleBaseURL = "https://appleid.apple.com"; const getPrivateKey = async () => { - return await fs.readFile(resolve(__dirname, `../${process.env.APPLE_PRIVATE_KEY_FILE}`), 'utf8'); + return (await fs.readFile(resolve(__dirname, `../${process.env.APPLE_PRIVATE_KEY_FILE}`), 'utf8')).toString(); } const header = { @@ -32,7 +29,7 @@ const payload = { * @param {String} appleCode */ const getAppleRefreshToken = async (appleCode) => { - const clientSecret = jwt.sign(payload, (await getPrivateKey()).toString, { + const clientSecret = jwt.sign(payload, await getPrivateKey(), { algorithm: 'ES256', header }); @@ -61,7 +58,7 @@ const getAppleRefreshToken = async (appleCode) => { * @param {String} appleRefreshToken */ const revokeAppleToken = async (appleRefreshToken) => { - const clientSecret = jwt.sign(payload, (await getPrivateKey()).toString, { + const clientSecret = jwt.sign(payload, await getPrivateKey(), { algorithm: 'ES256', header });