diff --git a/knowx/cypress.config.ts b/knowx/cypress.config.ts
index 14f0a9a..ed2c5bb 100644
--- a/knowx/cypress.config.ts
+++ b/knowx/cypress.config.ts
@@ -25,5 +25,6 @@ export default defineConfig({
GITHUB_PASSWORD: process.env.EMAIL_SERVER_PASSWORD,
COOKIE_NAME: "next-auth.session-token",
SITE_NAME: process.env.NEXTAUTH_URL,
+ NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
},
})
diff --git a/knowx/cypress/e2e/login/login.cy.ts b/knowx/cypress/e2e/login/login.cy.ts
index 370d72e..15606ea 100644
--- a/knowx/cypress/e2e/login/login.cy.ts
+++ b/knowx/cypress/e2e/login/login.cy.ts
@@ -15,94 +15,15 @@ describe("Auth Redirect", () => {
})
})
-describe("Login using github", () => {
+describe("Authorization Check", () => {
// beforeEach(() => {
// cy.rewriteHeaders()
// })
+
it("passes", () => {
cy.visit("http://localhost:3000/auth")
-
- const username = Cypress.env("GITHUB_USERNAME")
- const password = Cypress.env("GITHUB_PASSWORD")
- const loginUrl = Cypress.env("SITE_NAME") + "/auth"
- const cookieName = Cypress.env("COOKIE_NAME")
- const socialLoginOptions = {
- username,
- password,
- loginUrl,
- headless: false,
- logs: true,
- isPopup: true,
- loginSelector: "#provider-button-github",
- postLoginSelector: "#provider-button-github",
- screenshotOnError: true,
- loginSelectorDelay: 2000,
- }
-
- cy.clearCookies()
-
- cy.task("GitHubSocialLogin", socialLoginOptions).then((results: any) => {
- results["cookies"].forEach((cookie: any) => {
- if (cookie.domain.includes(cookieName)) {
- cy.setCookie(cookie.name, cookie.value, {
- domain: cookie.domain,
- expiry: cookie.expires,
- httpOnly: cookie.httpOnly,
- path: cookie.path,
- secure: cookie.secure,
- })
- }
- })
- cy.window().then((window) => {
- Object.keys(results.ssd).forEach((key) =>
- window.sessionStorage.setItem(key, results.ssd[key]),
- )
- Object.keys(results.lsd).forEach((key) =>
- window.localStorage.setItem(key, results.lsd[key]),
- )
- })
- })
-
- // cy.get("#provider-button-github").click()
-
- // cy.origin("https://github.com", () => {
- // cy.get("#login_field").should("exist")
-
- // // cy.get("#login_field").type(Cypress.env("GITHUB_USERNAME"))
-
- // cy.task("generateOTP", Cypress.env("OTP_SECRET")).then((otp) => {
- // cy.get("#login_field")
- // .type(otp as string)
- // .wait(15000)
- // })
-
- // cy.get("#password").type(Cypress.env("GITHUB_PASSWORD"))
-
- // cy.task("proxiedmail").then((proxiedmail) => {})
-
- // cy.task("generateOTP", Cypress.env("OTP_SECRET")).then((otp) => {
- // // cy.get('input[name="otp"]').type(otp as string)
- // cy.get("#password").type(otp as string)
- // })
-
- // cy.get('input[type="submit"]').click()
-
- // cy.get('button[name="authorize"]')
- // .contains("Authorize")
- // .then((btn) => {
- // cy.get('button[name="authorize"]').contains("Authorize").click()
- // })
-
- // cy.get('text[name="otp"]').then((otp) => {
- // cy.task("generateOTP", {
- // secret: Cypress.env("OTP_SECRET"),
- // }).then((otp) => {
- // cy.get('input[name="otp"]').type(otp as string)
- // })
- // })
-
- // cy.get('button[name="authorize"]').contains("Authorize").click()
-
+ cy.login()
+ cy.visit("http://localhost:3000/auth")
cy.url().should("eq", "http://localhost:3000/dashboard")
})
})
diff --git a/knowx/cypress/support/commands.ts b/knowx/cypress/support/commands.ts
index 08c40f9..e934ff4 100644
--- a/knowx/cypress/support/commands.ts
+++ b/knowx/cypress/support/commands.ts
@@ -1,12 +1,17 @@
-///
+// /
-declare namespace Cypress {
- interface Chainable {
- rewriteHeaders(): void
+import hkdf from "@panva/hkdf"
+import { EncryptJWT, JWTPayload } from "jose"
+
+declare global {
+ namespace Cypress {
+ interface Chainable {
+ rewriteHeaders(): void
+ login(): void
+ }
}
}
-// commands.ts
// Origin: https://www.tomoliver.net/posts/cypress-samesite-problem
Cypress.Commands.add("rewriteHeaders", () => {
cy.intercept("*", (req) =>
@@ -25,3 +30,49 @@ Cypress.Commands.add("rewriteHeaders", () => {
}),
)
})
+
+async function getDerivedEncryptionKey(secret: string) {
+ return await hkdf(
+ "sha256",
+ secret,
+ "",
+ "NextAuth.js Generated Encryption Key",
+ 32,
+ )
+}
+
+export async function encode(
+ token: JWTPayload,
+ secret: string,
+): Promise {
+ const maxAge = 30 * 24 * 60 * 60
+ const encryptionSecret = await getDerivedEncryptionKey(secret)
+ return await new EncryptJWT(token)
+ .setProtectedHeader({ alg: "dir", enc: "A256GCM" })
+ .setIssuedAt()
+ .setExpirationTime(Math.round(Date.now() / 1000 + maxAge))
+ .setJti("test")
+ .encrypt(encryptionSecret)
+}
+
+Cypress.Commands.add("login", () => {
+ const payload = {
+ name: "Testing",
+ email: "test@gmail.com",
+ picture: "https://avatars.githubusercontent.com/u/65473367?v=",
+ iat: new Date().getTime(),
+ exp: new Date().getTime() + 30 * 24 * 60 * 60 * 1000,
+ }
+
+ cy.wrap(null)
+ .then(() => {
+ return encode(payload, Cypress.env("NEXTAUTH_SECRET"))
+ })
+ .then((encryptedToken) =>
+ cy.setCookie("next-auth.session-token", encryptedToken, {
+ expiry: new Date().setDate(new Date().getDate() + 2),
+ path: "/",
+ sameSite: "lax",
+ }),
+ )
+})
diff --git a/knowx/package-lock.json b/knowx/package-lock.json
index a106d24..daa0dc9 100644
--- a/knowx/package-lock.json
+++ b/knowx/package-lock.json
@@ -19,6 +19,7 @@
"@nextui-org/dropdown": "^2.1.23",
"@nextui-org/react": "^2.3.6",
"@nextui-org/table": "^2.0.33",
+ "@panva/hkdf": "^1.1.1",
"@react-stately/data": "^3.11.3",
"@sendgrid/mail": "^8.1.3",
"@testing-library/jest-dom": "^6.4.5",
@@ -33,8 +34,10 @@
"eslint-plugin-testing-library": "^6.2.2",
"express": "^4.19.2",
"framer-motion": "^11.2.9",
+ "jose": "^5.4.0",
"jsdom": "^24.1.0",
"mailslurp-client": "^15.20.2",
+ "msw": "^2.3.1",
"neon": "^2.0.0",
"net": "^1.0.2",
"next": "^13.4.10",
@@ -1749,6 +1752,30 @@
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
},
+ "node_modules/@bundled-es-modules/cookie": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.0.tgz",
+ "integrity": "sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==",
+ "dependencies": {
+ "cookie": "^0.5.0"
+ }
+ },
+ "node_modules/@bundled-es-modules/cookie/node_modules/cookie": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
+ "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/@bundled-es-modules/statuses": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz",
+ "integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==",
+ "dependencies": {
+ "statuses": "^2.0.1"
+ }
+ },
"node_modules/@colors/colors": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
@@ -2820,6 +2847,81 @@
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz",
"integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA=="
},
+ "node_modules/@inquirer/confirm": {
+ "version": "3.1.9",
+ "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.1.9.tgz",
+ "integrity": "sha512-UF09aejxCi4Xqm6N/jJAiFXArXfi9al52AFaSD+2uIHnhZGtd1d6lIGTRMPouVSJxbGEi+HkOWSYaiEY/+szUw==",
+ "dependencies": {
+ "@inquirer/core": "^8.2.2",
+ "@inquirer/type": "^1.3.3"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@inquirer/core": {
+ "version": "8.2.2",
+ "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-8.2.2.tgz",
+ "integrity": "sha512-K8SuNX45jEFlX3EBJpu9B+S2TISzMPGXZIuJ9ME924SqbdW6Pt6fIkKvXg7mOEOKJ4WxpQsxj0UTfcL/A434Ww==",
+ "dependencies": {
+ "@inquirer/figures": "^1.0.3",
+ "@inquirer/type": "^1.3.3",
+ "@types/mute-stream": "^0.0.4",
+ "@types/node": "^20.12.13",
+ "@types/wrap-ansi": "^3.0.0",
+ "ansi-escapes": "^4.3.2",
+ "chalk": "^4.1.2",
+ "cli-spinners": "^2.9.2",
+ "cli-width": "^4.1.0",
+ "mute-stream": "^1.0.0",
+ "signal-exit": "^4.1.0",
+ "strip-ansi": "^6.0.1",
+ "wrap-ansi": "^6.2.0"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@inquirer/core/node_modules/signal-exit": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
+ "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/@inquirer/core/node_modules/wrap-ansi": {
+ "version": "6.2.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
+ "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
+ "dependencies": {
+ "ansi-styles": "^4.0.0",
+ "string-width": "^4.1.0",
+ "strip-ansi": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@inquirer/figures": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.3.tgz",
+ "integrity": "sha512-ErXXzENMH5pJt5/ssXV0DfWUZqly8nGzf0UcBV9xTnP+KyffE2mqyxIMBrZ8ijQck2nU0TQm40EQB53YreyWHw==",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@inquirer/type": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.3.3.tgz",
+ "integrity": "sha512-xTUt0NulylX27/zMx04ZYar/kr1raaiFTVvQ5feljQsiAgdm0WPj4S73/ye0fbslh+15QrIuDvfCXTek7pMY5A==",
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/@internationalized/date": {
"version": "3.5.4",
"resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.5.4.tgz",
@@ -3008,6 +3110,30 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
+ "node_modules/@mswjs/cookies": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@mswjs/cookies/-/cookies-1.1.0.tgz",
+ "integrity": "sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw==",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@mswjs/interceptors": {
+ "version": "0.29.1",
+ "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.29.1.tgz",
+ "integrity": "sha512-3rDakgJZ77+RiQUuSK69t1F0m8BQKA8Vh5DCS5V0DWvNY67zob2JhhQrhCO0AKLGINTRSFd1tBaHcJTkhefoSw==",
+ "dependencies": {
+ "@open-draft/deferred-promise": "^2.2.0",
+ "@open-draft/logger": "^0.3.0",
+ "@open-draft/until": "^2.0.0",
+ "is-node-process": "^1.2.0",
+ "outvariant": "^1.2.1",
+ "strict-event-emitter": "^0.5.1"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/@neondatabase/serverless": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/@neondatabase/serverless/-/serverless-0.9.1.tgz",
@@ -4751,6 +4877,25 @@
"resolved": "https://registry.npmjs.org/@one-ini/wasm/-/wasm-0.1.1.tgz",
"integrity": "sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw=="
},
+ "node_modules/@open-draft/deferred-promise": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz",
+ "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA=="
+ },
+ "node_modules/@open-draft/logger": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz",
+ "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==",
+ "dependencies": {
+ "is-node-process": "^1.2.0",
+ "outvariant": "^1.4.0"
+ }
+ },
+ "node_modules/@open-draft/until": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz",
+ "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg=="
+ },
"node_modules/@otplib/core": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@otplib/core/-/core-12.0.1.tgz",
@@ -7281,10 +7426,18 @@
"integrity": "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==",
"dev": true
},
+ "node_modules/@types/mute-stream": {
+ "version": "0.0.4",
+ "resolved": "https://registry.npmjs.org/@types/mute-stream/-/mute-stream-0.0.4.tgz",
+ "integrity": "sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/node": {
- "version": "20.12.7",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz",
- "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==",
+ "version": "20.14.2",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz",
+ "integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==",
"dependencies": {
"undici-types": "~5.26.4"
}
@@ -7347,6 +7500,16 @@
"integrity": "sha512-0vWLNK2D5MT9dg0iOo8GlKguPAU02QjmZitPEsXRuJXU/OGIOt9vT9Fc26wtYuavLxtO45v9PGleoL9Z0k1LHg==",
"dev": true
},
+ "node_modules/@types/statuses": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz",
+ "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A=="
+ },
+ "node_modules/@types/wrap-ansi": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz",
+ "integrity": "sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g=="
+ },
"node_modules/@types/yauzl": {
"version": "2.10.3",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz",
@@ -8080,7 +8243,6 @@
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
"integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==",
- "dev": true,
"dependencies": {
"type-fest": "^0.21.3"
},
@@ -8095,7 +8257,6 @@
"version": "0.21.3",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",
"integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
- "dev": true,
"engines": {
"node": ">=10"
},
@@ -8975,6 +9136,17 @@
"node": ">=8"
}
},
+ "node_modules/cli-spinners": {
+ "version": "2.9.2",
+ "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz",
+ "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==",
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/cli-table3": {
"version": "0.6.4",
"resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.4.tgz",
@@ -9006,11 +9178,32 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/cli-width": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz",
+ "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/client-only": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="
},
+ "node_modules/cliui": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
+ "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
+ "dependencies": {
+ "string-width": "^4.2.0",
+ "strip-ansi": "^6.0.1",
+ "wrap-ansi": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/clsx": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
@@ -12006,6 +12199,14 @@
"node": ">=6.9.0"
}
},
+ "node_modules/get-caller-file": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+ "engines": {
+ "node": "6.* || 8.* || >= 10.*"
+ }
+ },
"node_modules/get-east-asian-width": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.2.0.tgz",
@@ -12246,6 +12447,14 @@
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag=="
},
+ "node_modules/graphql": {
+ "version": "16.8.1",
+ "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz",
+ "integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==",
+ "engines": {
+ "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
+ }
+ },
"node_modules/gzip-size": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz",
@@ -12346,6 +12555,11 @@
"node": ">= 0.4"
}
},
+ "node_modules/headers-polyfill": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.3.tgz",
+ "integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ=="
+ },
"node_modules/heap": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/heap/-/heap-0.2.7.tgz",
@@ -12867,6 +13081,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/is-node-process": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz",
+ "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw=="
+ },
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
@@ -13218,9 +13437,9 @@
}
},
"node_modules/jose": {
- "version": "5.2.4",
- "resolved": "https://registry.npmjs.org/jose/-/jose-5.2.4.tgz",
- "integrity": "sha512-6ScbIk2WWCeXkmzF6bRPmEuaqy1m8SbsRFMa/FLrSCkGIhj8OLVG/IH+XHVmNMx/KUo8cVWEE6oKR4dJ+S0Rkg==",
+ "version": "5.4.0",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-5.4.0.tgz",
+ "integrity": "sha512-6rpxTHPAQyWMb9A35BroFl1Sp0ST3DpPcm5EVIxZxdH+e0Hv9fwhyB3XLKFUcHNpdSDnETmBfuPPTTlYz5+USw==",
"funding": {
"url": "https://github.com/sponsors/panva"
}
@@ -14532,6 +14751,72 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
+ "node_modules/msw": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/msw/-/msw-2.3.1.tgz",
+ "integrity": "sha512-ocgvBCLn/5l3jpl1lssIb3cniuACJLoOfZu01e3n5dbJrpA5PeeWn28jCLgQDNt6d7QT8tF2fYRzm9JoEHtiig==",
+ "hasInstallScript": true,
+ "dependencies": {
+ "@bundled-es-modules/cookie": "^2.0.0",
+ "@bundled-es-modules/statuses": "^1.0.1",
+ "@inquirer/confirm": "^3.0.0",
+ "@mswjs/cookies": "^1.1.0",
+ "@mswjs/interceptors": "^0.29.0",
+ "@open-draft/until": "^2.1.0",
+ "@types/cookie": "^0.6.0",
+ "@types/statuses": "^2.0.4",
+ "chalk": "^4.1.2",
+ "graphql": "^16.8.1",
+ "headers-polyfill": "^4.0.2",
+ "is-node-process": "^1.2.0",
+ "outvariant": "^1.4.2",
+ "path-to-regexp": "^6.2.0",
+ "strict-event-emitter": "^0.5.1",
+ "type-fest": "^4.9.0",
+ "yargs": "^17.7.2"
+ },
+ "bin": {
+ "msw": "cli/index.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/mswjs"
+ },
+ "peerDependencies": {
+ "typescript": ">= 4.7.x"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/msw/node_modules/path-to-regexp": {
+ "version": "6.2.2",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.2.tgz",
+ "integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw=="
+ },
+ "node_modules/msw/node_modules/type-fest": {
+ "version": "4.20.0",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.20.0.tgz",
+ "integrity": "sha512-MBh+PHUHHisjXf4tlx0CFWoMdjx8zCMLJHOjnV1prABYZFHqtFOyauCIK2/7w4oIfwkF8iNhLtnJEfVY2vn3iw==",
+ "engines": {
+ "node": ">=16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mute-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz",
+ "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==",
+ "engines": {
+ "node": "^14.17.0 || ^16.13.0 || >=18.0.0"
+ }
+ },
"node_modules/mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
@@ -15444,6 +15729,11 @@
"@otplib/preset-v11": "^12.0.1"
}
},
+ "node_modules/outvariant": {
+ "version": "1.4.2",
+ "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.2.tgz",
+ "integrity": "sha512-Ou3dJ6bA/UJ5GVHxah4LnqDwZRwAmWxrG3wtrHrbGnP4RnLCtA64A4F+ae7Y8ww660JaddSoArUR5HjipWSHAQ=="
+ },
"node_modules/p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
@@ -16692,6 +16982,14 @@
"throttleit": "^1.0.0"
}
},
+ "node_modules/require-directory": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@@ -17811,6 +18109,11 @@
"node": ">=10.0.0"
}
},
+ "node_modules/strict-event-emitter": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz",
+ "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ=="
+ },
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
@@ -19489,7 +19792,6 @@
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
- "dev": true,
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
@@ -19554,6 +19856,14 @@
"node": ">=0.4"
}
},
+ "node_modules/y18n": {
+ "version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
@@ -19570,6 +19880,31 @@
"node": ">= 14"
}
},
+ "node_modules/yargs": {
+ "version": "17.7.2",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
+ "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
+ "dependencies": {
+ "cliui": "^8.0.1",
+ "escalade": "^3.1.1",
+ "get-caller-file": "^2.0.5",
+ "require-directory": "^2.1.1",
+ "string-width": "^4.2.3",
+ "y18n": "^5.0.5",
+ "yargs-parser": "^21.1.1"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/yargs-parser": {
+ "version": "21.1.1",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
+ "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/yauzl": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
diff --git a/knowx/package.json b/knowx/package.json
index d6f9d77..cca90dc 100644
--- a/knowx/package.json
+++ b/knowx/package.json
@@ -27,6 +27,7 @@
"@nextui-org/dropdown": "^2.1.23",
"@nextui-org/react": "^2.3.6",
"@nextui-org/table": "^2.0.33",
+ "@panva/hkdf": "^1.1.1",
"@react-stately/data": "^3.11.3",
"@sendgrid/mail": "^8.1.3",
"@testing-library/jest-dom": "^6.4.5",
@@ -41,8 +42,10 @@
"eslint-plugin-testing-library": "^6.2.2",
"express": "^4.19.2",
"framer-motion": "^11.2.9",
+ "jose": "^5.4.0",
"jsdom": "^24.1.0",
"mailslurp-client": "^15.20.2",
+ "msw": "^2.3.1",
"neon": "^2.0.0",
"net": "^1.0.2",
"next": "^13.4.10",
diff --git a/knowx/src/app/api/auth/[...nextauth]/route.ts b/knowx/src/app/api/auth/[...nextauth]/route.ts
index 0796c18..273a252 100644
--- a/knowx/src/app/api/auth/[...nextauth]/route.ts
+++ b/knowx/src/app/api/auth/[...nextauth]/route.ts
@@ -35,6 +35,9 @@ const authOptions: NextAuthOptions = {
from: process.env.EMAIL_FROM,
}),
],
+ jwt: {
+ secret: process.env.NEXTAUTH_SECRET,
+ },
session: {
strategy: "jwt",
},
diff --git a/knowx/src/app/dashboard/page.tsx b/knowx/src/app/dashboard/page.tsx
index 19eeaf9..3e26842 100644
--- a/knowx/src/app/dashboard/page.tsx
+++ b/knowx/src/app/dashboard/page.tsx
@@ -16,7 +16,9 @@ export default async function Home() {
}
const session = await getServerSession()
- const userId = await getUserId({ newEmail: session?.user?.email || "" })
+ const userId = await getUserId({
+ newEmail: session?.user?.email || "",
+ })
const history: SimpleHistoryType[] =
(await getSimpleUserHistory({
userId: userId,