From a8503dc6f5a3e6a85464b405d45f1716922a2ce2 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 26 Nov 2024 16:23:12 +0100 Subject: [PATCH 01/19] Added tests and made a start to auth.ts --- .gitignore | 1 + __tests__/auth.spec.ts | 77 + jest.config.ts | 201 ++ jest.setup.ts | 38 + package-lock.json | 3935 +++++++++++++++++++++++++++++++++++++++- package.json | 8 +- src/auth.ts | 1 + tsconfig.json | 3 +- 8 files changed, 4190 insertions(+), 74 deletions(-) create mode 100644 __tests__/auth.spec.ts create mode 100644 jest.config.ts create mode 100644 jest.setup.ts diff --git a/.gitignore b/.gitignore index 8d67a86..f39ad38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store node_modules dist +coverage diff --git a/__tests__/auth.spec.ts b/__tests__/auth.spec.ts new file mode 100644 index 0000000..9f7c287 --- /dev/null +++ b/__tests__/auth.spec.ts @@ -0,0 +1,77 @@ +import { describe, it, expect, beforeEach, jest } from '@jest/globals'; + +import { getSignInUrl, getSignUpUrl, signOut } from '../src/auth.js'; + +// These are mocked in jest.setup.ts +import { cookies, headers } from 'next/headers'; +import { redirect } from 'next/navigation'; + +describe('auth.ts', () => { + beforeEach(async () => { + // Clear all mocks between tests + jest.clearAllMocks(); + + // Reset the cookie store + const nextCookies = await cookies(); + // @ts-expect-error - _reset is part of the mock + nextCookies._reset(); + + const nextHeaders = await headers(); + // @ts-expect-error - _reset is part of the mock + nextHeaders._reset(); + }); + + describe('getSignInUrl', () => { + it('should return a valid URL', async () => { + const url = await getSignInUrl(); + expect(url).toBeDefined(); + expect(() => new URL(url)).not.toThrow(); + }); + + it('should use the organizationId if provided', async () => { + const url = await getSignInUrl({ organizationId: 'org_123' }); + expect(url).toContain('organization_id=org_123'); + expect(url).toBeDefined(); + expect(() => new URL(url)).not.toThrow(); + }); + }); + + describe('getSignUpUrl', () => { + it('should return a valid URL', async () => { + const url = await getSignUpUrl(); + expect(url).toBeDefined(); + expect(() => new URL(url)).not.toThrow(); + }); + }); + + describe('signOut', () => { + it('should delete the cookie and redirect', async () => { + const nextCookies = await cookies(); + const nextHeaders = await headers(); + + nextHeaders.set('x-workos-middleware', 'true'); + nextCookies.set('wos-session', 'foo'); + + await signOut(); + + const sessionCookie = nextCookies.get('wos-session'); + + expect(sessionCookie).toBeUndefined(); + expect(redirect).toHaveBeenCalledTimes(1); + expect(redirect).toHaveBeenCalledWith('/'); + }); + + it('should delete the cookie with a specific domain', async () => { + const nextCookies = await cookies(); + const nextHeaders = await headers(); + + nextHeaders.set('x-workos-middleware', 'true'); + nextCookies.set('wos-session', 'foo', { domain: 'example.com' }); + + await signOut(); + + const sessionCookie = nextCookies.get('wos-session'); + expect(sessionCookie).toBeUndefined(); + }); + }); +}); diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 0000000..bffefff --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,201 @@ +import type { Config } from 'jest'; + +const config: Config = { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/private/var/folders/rg/0ppfq_s11hv0l53tlfb8m4vm0000gn/T/jest_dx", + + // Automatically clear mock calls, instances, contexts and results before every test + clearMocks: true, + + // Indicates whether the coverage information should be collected while executing the test + collectCoverage: true, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: undefined, + + // The directory where Jest should output its coverage files + coverageDirectory: 'coverage', + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // Indicates which provider should be used to instrument code for coverage + coverageProvider: 'v8', + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: undefined, + + // A path to a custom dependency extractor + // dependencyExtractor: undefined, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // The default configuration for fake timers + // fakeTimers: { + // "enableGlobally": false + // }, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: undefined, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: undefined, + + // A set of global variables that need to be available in all test environments + // globals: {}, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "mjs", + // "cjs", + // "jsx", + // "ts", + // "tsx", + // "json", + // "node" + // ], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', // Handle ESM imports + }, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + preset: 'ts-jest', + + // Run tests from one or more projects + // projects: undefined, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state before every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: undefined, + + // Automatically restore mock state and implementation before every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: undefined, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + setupFiles: ['/jest.setup.ts'], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // The number of seconds after which a test is considered as slow and reported as such in the results. + // slowTestThreshold: 5, + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + testEnvironment: 'node', + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + // testMatch: [ + // "**/__tests__/**/*.[jt]s?(x)", + // "**/?(*.)+(spec|test).[tj]s?(x)" + // ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + // testPathIgnorePatterns: [ + // "/node_modules/" + // ], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: undefined, + + // This option allows use of a custom test runner + // testRunner: "jest-circus/runner", + + // A map from regular expressions to paths to transformers + transform: { + '^.+\\.(ts|tsx)$': 'ts-jest', + }, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "/node_modules/", + // "\\.pnp\\.[^\\/]+$" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: undefined, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, + + // Optionally, add these for better TypeScript support + extensionsToTreatAsEsm: ['.ts'], +}; + +export default config; diff --git a/jest.setup.ts b/jest.setup.ts new file mode 100644 index 0000000..c0b0068 --- /dev/null +++ b/jest.setup.ts @@ -0,0 +1,38 @@ +process.env.WORKOS_API_KEY = 'sk_test_1234567890'; +process.env.WORKOS_CLIENT_ID = '1234567890'; +process.env.WORKOS_COOKIE_PASSWORD = 'kR620keEzOIzPThfnMEAba8XYgKdQ5vg'; +process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI = 'http://localhost:3000/callback'; +process.env.WORKOS_COOKIE_DOMAIN = 'example.com'; + +const cookieStore = new Map(); +const headersStore = new Map(); + +type CookieValue = string | { [key: string]: string | number | boolean }; + +// Mock the next/headers module +jest.mock('next/headers', () => ({ + headers: async () => ({ + delete: jest.fn((name: string) => headersStore.delete(name)), + get: jest.fn((name: string) => headersStore.get(name)), + set: jest.fn((name: string, value: string) => headersStore.set(name, value)), + _reset: () => { + headersStore.clear(); + }, + }), + cookies: async () => ({ + delete: jest.fn((nameOrObject: string | { name: string; [key: string]: unknown }) => { + const cookieName = typeof nameOrObject === 'string' ? nameOrObject : nameOrObject.name; + cookieStore.delete(cookieName); + }), + get: jest.fn((name: string) => cookieStore.get(name)), + getAll: jest.fn(() => Array.from(cookieStore.entries())), + set: jest.fn((name: string, value: CookieValue) => cookieStore.set(name, value)), + _reset: () => { + cookieStore.clear(); + }, + }), +})); + +jest.mock('next/navigation', () => ({ + redirect: jest.fn(), +})); diff --git a/package-lock.json b/package-lock.json index 7672c6d..0432541 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@workos-inc/authkit-nextjs", - "version": "0.15.0", + "version": "0.16.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@workos-inc/authkit-nextjs", - "version": "0.15.0", + "version": "0.16.1", "license": "MIT", "dependencies": { "@workos-inc/node": "^7.33.0", @@ -15,14 +15,19 @@ "path-to-regexp": "^6.2.2" }, "devDependencies": { + "@types/jest": "^29.5.14", "@types/node": "^20.11.28", "@types/react": "18.2.67", "@types/react-dom": "18.2.22", "eslint": "^8.29.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-require-extensions": "^0.1.3", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", "next": "^15.0.1", "prettier": "^3.3.3", + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", "typescript": "5.4.2", "typescript-eslint": "^7.2.0" }, @@ -41,6 +46,520 @@ "node": ">=0.10.0" } }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.2.tgz", + "integrity": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz", + "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.26.0", + "@babel/generator": "^7.26.0", + "@babel/helper-compilation-targets": "^7.25.9", + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helpers": "^7.26.0", + "@babel/parser": "^7.26.0", + "@babel/template": "^7.25.9", + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.26.0", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", + "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.26.2", + "@babel/types": "^7.26.0", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", + "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.25.9", + "@babel/helper-validator-option": "^7.25.9", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", + "dev": true, + "dependencies": { + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", + "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", + "dev": true, + "dependencies": { + "@babel/template": "^7.25.9", + "@babel/types": "^7.26.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.26.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.26.0.tgz", + "integrity": "sha512-e2dttdsJ1ZTpi3B9UYGLw41hifAubg19AtCu/2I/F1QNVclOBr1dYpTdmdyZ84Xiz43BS/tCUkMAZNLv12Pi+A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", + "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", + "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", + "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/types": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@emnapi/runtime": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz", @@ -545,11 +1064,445 @@ "url": "https://opencollective.com/libvips" } }, - "node_modules/@next/env": { - "version": "15.0.3", - "resolved": "https://registry.npmjs.org/@next/env/-/env-15.0.3.tgz", - "integrity": "sha512-t9Xy32pjNOvVn2AS+Utt6VmyrshbpfUMhIjFO60gI58deSo/KgLOp31XZ4O+kY/Is8WAGYwA5gR7kOb1eORDBA==", - "devOptional": true + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dev": true, + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@next/env": { + "version": "15.0.3", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.0.3.tgz", + "integrity": "sha512-t9Xy32pjNOvVn2AS+Utt6VmyrshbpfUMhIjFO60gI58deSo/KgLOp31XZ4O+kY/Is8WAGYwA5gR7kOb1eORDBA==", + "devOptional": true }, "node_modules/@next/swc-darwin-arm64": { "version": "15.0.3", @@ -750,6 +1703,30 @@ "node": ">=10.12.0" } }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, "node_modules/@swc/counter": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", @@ -765,6 +1742,39 @@ "tslib": "^2.4.0" } }, + "node_modules/@tootallnate/once": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", + "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.7.tgz", @@ -773,6 +1783,47 @@ "@types/node": "*" } }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.6.tgz", + "integrity": "sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.20.7" + } + }, "node_modules/@types/body-parser": { "version": "1.19.5", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", @@ -833,6 +1884,15 @@ "@types/send": "*" } }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/http-assert": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.5.tgz", @@ -843,19 +1903,64 @@ "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==" }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", "dev": true }, - "node_modules/@types/keygrip": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.6.tgz", - "integrity": "sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==" + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } }, - "node_modules/@types/koa": { - "version": "2.15.0", + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.14", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/jsdom": { + "version": "20.0.1", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz", + "integrity": "sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==", + "dev": true, + "dependencies": { + "@types/node": "*", + "@types/tough-cookie": "*", + "parse5": "^7.0.0" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, + "node_modules/@types/keygrip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.6.tgz", + "integrity": "sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==" + }, + "node_modules/@types/koa": { + "version": "2.15.0", "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.15.0.tgz", "integrity": "sha512-7QFsywoE5URbuVnG3loe03QXuGajrnotr3gQkXcEBShORai23MePfFYdhz90FEtBBpkyIYQbVD+evKtloCgX3g==", "dependencies": { @@ -957,6 +2062,33 @@ "@types/send": "*" } }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true + }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.7.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.1.tgz", @@ -1223,6 +2355,13 @@ "url": "https://github.com/sponsors/brc-dd" } }, + "node_modules/abab": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", + "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==", + "deprecated": "Use your platform's native atob() and btoa() methods instead", + "dev": true + }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", @@ -1235,6 +2374,16 @@ "node": ">=0.4.0" } }, + "node_modules/acorn-globals": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-7.0.1.tgz", + "integrity": "sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==", + "dev": true, + "dependencies": { + "acorn": "^8.1.0", + "acorn-walk": "^8.0.2" + } + }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", @@ -1244,6 +2393,30 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -1260,6 +2433,33 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-escapes": { + "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" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-escapes/node_modules/type-fest": { + "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" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -1284,6 +2484,25 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1312,6 +2531,137 @@ "node": ">=12.0.0" } }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/babel-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", + "dev": true, + "dependencies": { + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz", + "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==", + "dev": true, + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-import-attributes": "^7.24.7", + "@babel/plugin-syntax-import-meta": "^7.10.4", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1358,6 +2708,59 @@ "node": ">=8" } }, + "node_modules/browserslist": { + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", + "node-releases": "^2.0.18", + "update-browserslist-db": "^1.1.1" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, "node_modules/buffer": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", @@ -1381,6 +2784,12 @@ "ieee754": "^1.2.1" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -1402,10 +2811,19 @@ "node": ">=6" } }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/caniuse-lite": { - "version": "1.0.30001612", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001612.tgz", - "integrity": "sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==", + "version": "1.0.30001684", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001684.tgz", + "integrity": "sha512-G1LRwLIQjBQoyq0ZJGqGIJUXzJ8irpbjHLpVRXDvBEScFJ9b17sgK6vlx0GAJFE21okD7zXl08rRRUfq6HdoEQ==", "devOptional": true, "funding": [ { @@ -1438,12 +2856,72 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.1.tgz", + "integrity": "sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA==", + "dev": true + }, "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==", "devOptional": true }, + "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==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true + }, "node_modules/color": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", @@ -1487,12 +2965,30 @@ "simple-swizzle": "^0.2.2" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, "node_modules/cookie": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", @@ -1501,6 +2997,33 @@ "node": ">= 0.6" } }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -1515,27 +3038,85 @@ "node": ">= 8" } }, - "node_modules/csstype": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "node_modules/cssom": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz", + "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==", "dev": true }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "node_modules/cssstyle": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", + "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", "dev": true, "dependencies": { - "ms": "2.1.2" + "cssom": "~0.3.6" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">=8" + } + }, + "node_modules/cssstyle/node_modules/cssom": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", + "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", + "dev": true + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "dev": true + }, + "node_modules/data-urls": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", + "integrity": "sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==", + "dev": true, + "dependencies": { + "abab": "^2.0.6", + "whatwg-mimetype": "^3.0.0", + "whatwg-url": "^11.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", + "dev": true + }, + "node_modules/dedent": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", + "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==", + "dev": true, + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } } }, "node_modules/deep-is": { @@ -1544,6 +3125,24 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/detect-libc": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", @@ -1554,6 +3153,33 @@ "node": ">=8" } }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -1578,6 +3204,94 @@ "node": ">=6.0.0" } }, + "node_modules/domexception": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", + "integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==", + "deprecated": "Use your platform's native DOMException instead", + "dev": true, + "dependencies": { + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "dev": true, + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.65", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.65.tgz", + "integrity": "sha512-PWVzBjghx7/wop6n22vS2MLU8tKGd4Q91aCEGhG/TYmW6PP5OcSXcdnxTe1NNt0T66N8D6jxh4kC8UsdzOGaIw==", + "dev": true + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/error-ex/node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -1590,6 +3304,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/escodegen": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "dev": true, + "dependencies": { + "esprima": "^4.0.1", + "estraverse": "^5.2.0", + "esutils": "^2.0.2" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=6.0" + }, + "optionalDependencies": { + "source-map": "~0.6.1" + } + }, "node_modules/eslint": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", @@ -1736,6 +3471,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/esquery": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", @@ -1778,6 +3526,54 @@ "node": ">=0.10.0" } }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1833,6 +3629,15 @@ "reusify": "^1.0.4" } }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -1845,6 +3650,27 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/filelist": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "dev": true, + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -1893,12 +3719,88 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "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==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -1988,6 +3890,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -2003,45 +3911,142 @@ "node": ">=8" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, "engines": { - "node": ">= 4" + "node": ">= 0.4" } }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "node_modules/html-encoding-sniffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", + "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==", "dev": true, "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" + "whatwg-encoding": "^2.0.0" }, "engines": { - "node": ">=6" + "node": ">=12" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/http-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", + "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "dev": true, + "dependencies": { + "@tootallnate/once": "2", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dev": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-local": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -2101,6 +4106,21 @@ "dev": true, "optional": true }, + "node_modules/is-core-module": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "dev": true, + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2110,6 +4130,24 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2140,12 +4178,718 @@ "node": ">=8" } }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jake": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz", + "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==", + "dev": true, + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jake/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/jake/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.7.0" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dev": true, + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dev": true, + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", + "dev": true, + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-jsdom": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-29.7.0.tgz", + "integrity": "sha512-k9iQbsf9OyOfdzWH8HDmrRT0gSIcX+FLNW7IQq94tFX0gynPwqDTW0Ho6iMVNjGz/nb+l/vW3dWM2bbLLpkbXA==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/jsdom": "^20.0.0", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0", + "jsdom": "^20.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "canvas": "^2.5.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", + "dev": true, + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/jose": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/jose/-/jose-5.6.3.tgz", @@ -2157,8 +4901,7 @@ "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "peer": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { "version": "4.1.0", @@ -2172,12 +4915,75 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdom": { + "version": "20.0.3", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-20.0.3.tgz", + "integrity": "sha512-SYhBvTh89tTfCD/CRdSOm13mOBa42iTaTyfyEWBdKcGdPxPtLFBXuHR8XHb33YNYaP+lLbmSvBTsnoesCNJEsQ==", + "dev": true, + "dependencies": { + "abab": "^2.0.6", + "acorn": "^8.8.1", + "acorn-globals": "^7.0.0", + "cssom": "^0.5.0", + "cssstyle": "^2.3.0", + "data-urls": "^3.0.2", + "decimal.js": "^10.4.2", + "domexception": "^4.0.0", + "escodegen": "^2.0.0", + "form-data": "^4.0.0", + "html-encoding-sniffer": "^3.0.0", + "http-proxy-agent": "^5.0.0", + "https-proxy-agent": "^5.0.1", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.2", + "parse5": "^7.1.1", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^4.1.2", + "w3c-xmlserializer": "^4.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^2.0.0", + "whatwg-mimetype": "^3.0.0", + "whatwg-url": "^11.0.0", + "ws": "^8.11.0", + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "canvas": "^2.5.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -2190,6 +4996,18 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -2199,6 +5017,24 @@ "json-buffer": "3.0.1" } }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -2212,6 +5048,12 @@ "node": ">= 0.8.0" } }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -2227,6 +5069,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -2245,6 +5093,51 @@ "loose-envify": "cli.js" } }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2267,6 +5160,36 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/minimatch": { "version": "9.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", @@ -2366,6 +5289,45 @@ } } }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nwsapi": { + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.13.tgz", + "integrity": "sha512-cTGB9ptp9dY9A5VbMSe7fQBcl/tt22Vcqdq8+eN93rblOuE0aCFu4aZ2vMwct/2t+lFnosm8RkQW1I0Omb1UtQ==", + "dev": true + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2375,6 +5337,21 @@ "wrappy": "1" } }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -2422,6 +5399,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -2434,6 +5420,36 @@ "node": ">=6" } }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parse5": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz", + "integrity": "sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==", + "dev": true, + "dependencies": { + "entities": "^4.5.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2461,6 +5477,12 @@ "node": ">=8" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "node_modules/path-to-regexp": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", @@ -2476,9 +5498,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "devOptional": true }, "node_modules/picomatch": { @@ -2493,6 +5515,79 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/pluralize": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", @@ -2553,6 +5648,54 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/psl": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.13.0.tgz", + "integrity": "sha512-BFwmFXiJoFqlUpZ5Qssolv15DMyc84gTBds1BjsV1BfXEo1UyyD7GsmN67n7J77uRhoSNW1AXtXKPLcBFQn9Aw==", + "dev": true, + "dependencies": { + "punycode": "^2.3.1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -2562,6 +5705,22 @@ "node": ">=6" } }, + "node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ] + }, "node_modules/pvtsutils": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz", @@ -2578,6 +5737,12 @@ "node": ">=6.0.0" } }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -2623,6 +5788,65 @@ "react": "^18.2.0" } }, + "node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "dev": true + }, + "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==", + "dev": true, + "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", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-cwd/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2632,6 +5856,15 @@ "node": ">=4" } }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -2680,6 +5913,24 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -2762,6 +6013,12 @@ "node": ">=8" } }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -2772,6 +6029,12 @@ "is-arrayish": "^0.3.1" } }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -2781,6 +6044,15 @@ "node": ">=8" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", @@ -2790,13 +6062,77 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/streamsearch": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", "devOptional": true, "engines": { - "node": ">=10.0.0" + "node": ">=10.0.0" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" } }, "node_modules/strip-ansi": { @@ -2811,6 +6147,24 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -2858,12 +6212,72 @@ "node": ">=8" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2876,6 +6290,33 @@ "node": ">=8.0" } }, + "node_modules/tough-cookie": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", + "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", + "dev": true, + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dev": true, + "dependencies": { + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", @@ -2888,6 +6329,97 @@ "typescript": ">=4.2.0" } }, + "node_modules/ts-jest": { + "version": "29.2.5", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz", + "integrity": "sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==", + "dev": true, + "dependencies": { + "bs-logger": "^0.2.6", + "ejs": "^3.1.10", + "fast-json-stable-stringify": "^2.1.0", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.6.3", + "yargs-parser": "^21.1.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/transform": "^29.0.0", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/transform": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -2905,6 +6437,15 @@ "node": ">= 0.8.0" } }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", @@ -2966,6 +6507,45 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" }, + "node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", + "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -2975,6 +6555,57 @@ "punycode": "^2.1.0" } }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/w3c-xmlserializer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz", + "integrity": "sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==", + "dev": true, + "dependencies": { + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "dependencies": { + "makeerror": "1.0.12" + } + }, "node_modules/webcrypto-core": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.8.0.tgz", @@ -2987,6 +6618,49 @@ "tslib": "^2.6.2" } }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-encoding": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz", + "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==", + "dev": true, + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-mimetype": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", + "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dev": true, + "dependencies": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -3002,12 +6676,129 @@ "node": ">= 8" } }, + "node_modules/wrap-ansi": { + "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", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-name-validator": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", + "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "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==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 41cf3bd..4619556 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "build": "tsc --project tsconfig.json", "prepublishOnly": "npm run lint", "lint": "eslint \"src/**/*.ts*\"", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "jest", + "test:watch": "jest --watch" }, "dependencies": { "@workos-inc/node": "^7.33.0", @@ -32,14 +33,19 @@ "react-dom": "^18.0 || ^19.0.0" }, "devDependencies": { + "@types/jest": "^29.5.14", "@types/node": "^20.11.28", "@types/react": "18.2.67", "@types/react-dom": "18.2.22", "eslint": "^8.29.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-require-extensions": "^0.1.3", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", "next": "^15.0.1", "prettier": "^3.3.3", + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", "typescript": "5.4.2", "typescript-eslint": "^7.2.0" }, diff --git a/src/auth.ts b/src/auth.ts index a0b5cb2..875d80f 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -20,6 +20,7 @@ async function signOut() { if (WORKOS_COOKIE_DOMAIN) cookie.domain = WORKOS_COOKIE_DOMAIN; const nextCookies = await cookies(); + nextCookies.delete(cookie); await terminateSession(); } diff --git a/tsconfig.json b/tsconfig.json index 29d2c94..fde330e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,6 @@ "outDir": "./dist/esm", "module": "ES2020", "moduleResolution": "Node" - } + }, + "exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"] } From ecd3173eb16dc3729ff7ee9b55a57901be1b21ee Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 26 Nov 2024 18:35:35 +0100 Subject: [PATCH 02/19] Add tests for cookie and callback route --- __tests__/authkit-callback-route.spec.ts | 199 +++++++++++++++++++++++ __tests__/cookie.spec.ts | 49 ++++++ jest.setup.ts | 2 +- 3 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 __tests__/authkit-callback-route.spec.ts create mode 100644 __tests__/cookie.spec.ts diff --git a/__tests__/authkit-callback-route.spec.ts b/__tests__/authkit-callback-route.spec.ts new file mode 100644 index 0000000..94b163b --- /dev/null +++ b/__tests__/authkit-callback-route.spec.ts @@ -0,0 +1,199 @@ +import { handleAuth } from '../src/authkit-callback-route.js'; +import { NextRequest, NextResponse } from 'next/server'; +import { workos } from '../src/workos.js'; + +// Mocked in jest.setup.ts +import { cookies, headers } from 'next/headers'; + +// Mock dependencies +jest.mock('../src/workos', () => ({ + workos: { + userManagement: { + authenticateWithCode: jest.fn(), + getJwksUrl: jest.fn(() => 'https://api.workos.com/sso/jwks/client_1234567890'), + }, + }, +})); + +describe('authkit-callback-route', () => { + let request: NextRequest; + + beforeEach(async () => { + // Reset all mocks + jest.clearAllMocks(); + + // Create a new request with searchParams + request = new NextRequest(new URL('http://example.com/callback')); + + // Reset the cookie store + const nextCookies = await cookies(); + // @ts-expect-error - _reset is part of the mock + nextCookies._reset(); + + const nextHeaders = await headers(); + // @ts-expect-error - _reset is part of the mock + nextHeaders._reset(); + }); + + it('should handle successful authentication', async () => { + // Mock successful authentication response + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user_123' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); + + const handler = handleAuth(); + const response = await handler(request); + + expect(workos.userManagement.authenticateWithCode).toHaveBeenCalledWith({ + clientId: process.env.WORKOS_CLIENT_ID, + code: 'test-code', + }); + expect(response).toBeInstanceOf(NextResponse); + }); + + it('should handle authentication failure', async () => { + // Mock authentication failure + (workos.userManagement.authenticateWithCode as jest.Mock).mockRejectedValue(new Error('Auth failed')); + + request.nextUrl.searchParams.set('code', 'invalid-code'); + + const handler = handleAuth(); + const response = await handler(request); + + expect(response.status).toBe(500); + const data = await response.json(); + expect(data.error.message).toBe('Something went wrong'); + }); + + it('should handle missing code parameter', async () => { + const handler = handleAuth(); + const response = await handler(request); + + expect(response.status).toBe(500); + const data = await response.json(); + expect(data.error.message).toBe('Something went wrong'); + }); + + it('should respect custom returnPathname', async () => { + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user1' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + request.nextUrl.searchParams.set('code', 'test-code'); + + const handler = handleAuth({ returnPathname: '/dashboard' }); + const response = await handler(request); + + expect(response.headers.get('Location')).toContain('/dashboard'); + }); + + it('should handle state parameter with returnPathname', async () => { + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user1' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + const state = btoa(JSON.stringify({ returnPathname: '/custom-path' })); + request.nextUrl.searchParams.set('code', 'test-code'); + request.nextUrl.searchParams.set('state', state); + + const handler = handleAuth(); + const response = await handler(request); + + expect(response.headers.get('Location')).toContain('/custom-path'); + }); + + it('should extract custom search params from returnPathname', async () => { + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user1' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + const state = btoa(JSON.stringify({ returnPathname: '/custom-path?foo=bar&baz=qux' })); + request.nextUrl.searchParams.set('code', 'test-code'); + request.nextUrl.searchParams.set('state', state); + + const handler = handleAuth(); + const response = await handler(request); + + expect(response.headers.get('Location')).toContain('/custom-path?foo=bar&baz=qux'); + }); + + it('should use Response if NextResponse.redirect is not available', async () => { + const originalRedirect = NextResponse.redirect; + (NextResponse as Partial).redirect = undefined; + + // Mock successful authentication response + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user_123' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); + + const handler = handleAuth(); + const response = await handler(request); + + expect(response).toBeInstanceOf(Response); + + // Restore the original redirect method + (NextResponse as Partial).redirect = originalRedirect; + }); + + it('should use Response if NextResponse.json is not available', async () => { + const originalJson = NextResponse.json; + (NextResponse as Partial).json = undefined; + + const handler = handleAuth(); + const response = await handler(request); + + expect(response).toBeInstanceOf(Response); + + // Restore the original json method + (NextResponse as Partial).json = originalJson; + }); + + it('should throw an error if baseURL is provided but invalid', async () => { + expect(() => handleAuth({ baseURL: 'invalid-url' })).toThrow('Invalid baseURL: invalid-url'); + }); + + it('should use baseURL if provided', async () => { + // Mock successful authentication response + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user_123' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); + + const handler = handleAuth({ baseURL: 'https://base.com' }); + const response = await handler(request); + + expect(response.headers.get('Location')).toContain('https://base.com'); + }); +}); diff --git a/__tests__/cookie.spec.ts b/__tests__/cookie.spec.ts new file mode 100644 index 0000000..d4ace04 --- /dev/null +++ b/__tests__/cookie.spec.ts @@ -0,0 +1,49 @@ +import { describe, it, expect } from '@jest/globals'; + +// Mock at the top of the file +jest.mock('../src/env-variables'); + +describe('cookie.ts', () => { + beforeEach(() => { + // Clear all mocks before each test + jest.clearAllMocks(); + // Reset modules + jest.resetModules(); + }); + + it('should return the default cookie options', async () => { + const { getCookieOptions } = await import('../src/cookie'); + + const options = getCookieOptions(); + expect(options).toEqual( + expect.objectContaining({ + path: '/', + httpOnly: true, + secure: false, + sameSite: 'lax', + maxAge: 400 * 24 * 60 * 60, + domain: 'example.com', + }), + ); + }); + + it('should return the cookie options with custom values', async () => { + // Import the mocked module + const envVars = await import('../src/env-variables'); + + // Set the mock values + Object.defineProperty(envVars, 'WORKOS_COOKIE_MAX_AGE', { value: '1000' }); + Object.defineProperty(envVars, 'WORKOS_COOKIE_DOMAIN', { value: 'foobar.com' }); + + const { getCookieOptions } = await import('../src/cookie'); + const options = getCookieOptions('http://example.com'); + + expect(options).toEqual( + expect.objectContaining({ + secure: false, + maxAge: 1000, + domain: 'foobar.com', + }), + ); + }); +}); diff --git a/jest.setup.ts b/jest.setup.ts index c0b0068..7cbadcb 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -1,5 +1,5 @@ process.env.WORKOS_API_KEY = 'sk_test_1234567890'; -process.env.WORKOS_CLIENT_ID = '1234567890'; +process.env.WORKOS_CLIENT_ID = 'client_1234567890'; process.env.WORKOS_COOKIE_PASSWORD = 'kR620keEzOIzPThfnMEAba8XYgKdQ5vg'; process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI = 'http://localhost:3000/callback'; process.env.WORKOS_COOKIE_DOMAIN = 'example.com'; From 60f70f85d6f7ca56fd1f82f8a72f5bb4805e6c26 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Mon, 2 Dec 2024 16:34:18 +0100 Subject: [PATCH 03/19] Tests for session and actions --- __tests__/actions.spec.ts | 10 + __tests__/authkit-callback-route.spec.ts | 285 ++++++----- __tests__/cookie.spec.ts | 70 +-- __tests__/session.spec.ts | 605 +++++++++++++++++++++++ jest.config.ts | 2 +- src/session.ts | 52 +- 6 files changed, 827 insertions(+), 197 deletions(-) create mode 100644 __tests__/actions.spec.ts create mode 100644 __tests__/session.spec.ts diff --git a/__tests__/actions.spec.ts b/__tests__/actions.spec.ts new file mode 100644 index 0000000..dabf4a9 --- /dev/null +++ b/__tests__/actions.spec.ts @@ -0,0 +1,10 @@ +import { checkSessionAction } from '../src/actions.js'; + +describe('actions', () => { + describe('checkSessionAction', () => { + it('should return true for authenticated users', async () => { + const result = await checkSessionAction(); + expect(result).toBe(true); + }); + }); +}); diff --git a/__tests__/authkit-callback-route.spec.ts b/__tests__/authkit-callback-route.spec.ts index 94b163b..50764b4 100644 --- a/__tests__/authkit-callback-route.spec.ts +++ b/__tests__/authkit-callback-route.spec.ts @@ -16,184 +16,207 @@ jest.mock('../src/workos', () => ({ })); describe('authkit-callback-route', () => { - let request: NextRequest; + describe('handleAuth', () => { + let request: NextRequest; - beforeEach(async () => { - // Reset all mocks - jest.clearAllMocks(); + beforeAll(() => { + // Silence console.error during tests + jest.spyOn(console, 'error').mockImplementation(() => {}); + }); - // Create a new request with searchParams - request = new NextRequest(new URL('http://example.com/callback')); + beforeEach(async () => { + // Reset all mocks + jest.clearAllMocks(); - // Reset the cookie store - const nextCookies = await cookies(); - // @ts-expect-error - _reset is part of the mock - nextCookies._reset(); + // Create a new request with searchParams + request = new NextRequest(new URL('http://example.com/callback')); - const nextHeaders = await headers(); - // @ts-expect-error - _reset is part of the mock - nextHeaders._reset(); - }); + // Reset the cookie store + const nextCookies = await cookies(); + // @ts-expect-error - _reset is part of the mock + nextCookies._reset(); + + const nextHeaders = await headers(); + // @ts-expect-error - _reset is part of the mock + nextHeaders._reset(); + }); - it('should handle successful authentication', async () => { - // Mock successful authentication response - const mockAuthResponse = { - accessToken: 'access123', - refreshToken: 'refresh123', - user: { id: 'user_123' }, - }; + it('should handle successful authentication', async () => { + // Mock successful authentication response + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user_123' }, + }; - (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); - // Set up request with code - request.nextUrl.searchParams.set('code', 'test-code'); + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); - const handler = handleAuth(); - const response = await handler(request); + const handler = handleAuth(); + const response = await handler(request); - expect(workos.userManagement.authenticateWithCode).toHaveBeenCalledWith({ - clientId: process.env.WORKOS_CLIENT_ID, - code: 'test-code', + expect(workos.userManagement.authenticateWithCode).toHaveBeenCalledWith({ + clientId: process.env.WORKOS_CLIENT_ID, + code: 'test-code', + }); + expect(response).toBeInstanceOf(NextResponse); }); - expect(response).toBeInstanceOf(NextResponse); - }); - it('should handle authentication failure', async () => { - // Mock authentication failure - (workos.userManagement.authenticateWithCode as jest.Mock).mockRejectedValue(new Error('Auth failed')); + it('should handle authentication failure', async () => { + // Mock authentication failure + (workos.userManagement.authenticateWithCode as jest.Mock).mockRejectedValue(new Error('Auth failed')); - request.nextUrl.searchParams.set('code', 'invalid-code'); + request.nextUrl.searchParams.set('code', 'invalid-code'); - const handler = handleAuth(); - const response = await handler(request); + const handler = handleAuth(); + const response = await handler(request); - expect(response.status).toBe(500); - const data = await response.json(); - expect(data.error.message).toBe('Something went wrong'); - }); + expect(response.status).toBe(500); + const data = await response.json(); + expect(data.error.message).toBe('Something went wrong'); + }); - it('should handle missing code parameter', async () => { - const handler = handleAuth(); - const response = await handler(request); + it('should handle missing code parameter', async () => { + const handler = handleAuth(); + const response = await handler(request); - expect(response.status).toBe(500); - const data = await response.json(); - expect(data.error.message).toBe('Something went wrong'); - }); + expect(response.status).toBe(500); + const data = await response.json(); + expect(data.error.message).toBe('Something went wrong'); + }); - it('should respect custom returnPathname', async () => { - const mockAuthResponse = { - accessToken: 'access123', - refreshToken: 'refresh123', - user: { id: 'user1' }, - }; + it('should respect custom returnPathname', async () => { + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user1' }, + }; - (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); - request.nextUrl.searchParams.set('code', 'test-code'); + request.nextUrl.searchParams.set('code', 'test-code'); - const handler = handleAuth({ returnPathname: '/dashboard' }); - const response = await handler(request); + const handler = handleAuth({ returnPathname: '/dashboard' }); + const response = await handler(request); - expect(response.headers.get('Location')).toContain('/dashboard'); - }); + expect(response.headers.get('Location')).toContain('/dashboard'); + }); - it('should handle state parameter with returnPathname', async () => { - const mockAuthResponse = { - accessToken: 'access123', - refreshToken: 'refresh123', - user: { id: 'user1' }, - }; + it('should handle state parameter with returnPathname', async () => { + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user1' }, + }; - (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); - const state = btoa(JSON.stringify({ returnPathname: '/custom-path' })); - request.nextUrl.searchParams.set('code', 'test-code'); - request.nextUrl.searchParams.set('state', state); + const state = btoa(JSON.stringify({ returnPathname: '/custom-path' })); + request.nextUrl.searchParams.set('code', 'test-code'); + request.nextUrl.searchParams.set('state', state); - const handler = handleAuth(); - const response = await handler(request); + const handler = handleAuth(); + const response = await handler(request); - expect(response.headers.get('Location')).toContain('/custom-path'); - }); + expect(response.headers.get('Location')).toContain('/custom-path'); + }); - it('should extract custom search params from returnPathname', async () => { - const mockAuthResponse = { - accessToken: 'access123', - refreshToken: 'refresh123', - user: { id: 'user1' }, - }; + it('should extract custom search params from returnPathname', async () => { + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user1' }, + }; - (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); - const state = btoa(JSON.stringify({ returnPathname: '/custom-path?foo=bar&baz=qux' })); - request.nextUrl.searchParams.set('code', 'test-code'); - request.nextUrl.searchParams.set('state', state); + const state = btoa(JSON.stringify({ returnPathname: '/custom-path?foo=bar&baz=qux' })); + request.nextUrl.searchParams.set('code', 'test-code'); + request.nextUrl.searchParams.set('state', state); - const handler = handleAuth(); - const response = await handler(request); + const handler = handleAuth(); + const response = await handler(request); - expect(response.headers.get('Location')).toContain('/custom-path?foo=bar&baz=qux'); - }); + expect(response.headers.get('Location')).toContain('/custom-path?foo=bar&baz=qux'); + }); - it('should use Response if NextResponse.redirect is not available', async () => { - const originalRedirect = NextResponse.redirect; - (NextResponse as Partial).redirect = undefined; + it('should use Response if NextResponse.redirect is not available', async () => { + const originalRedirect = NextResponse.redirect; + (NextResponse as Partial).redirect = undefined; - // Mock successful authentication response - const mockAuthResponse = { - accessToken: 'access123', - refreshToken: 'refresh123', - user: { id: 'user_123' }, - }; + // Mock successful authentication response + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user_123' }, + }; - (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); - // Set up request with code - request.nextUrl.searchParams.set('code', 'test-code'); + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); - const handler = handleAuth(); - const response = await handler(request); + const handler = handleAuth(); + const response = await handler(request); - expect(response).toBeInstanceOf(Response); + expect(response).toBeInstanceOf(Response); - // Restore the original redirect method - (NextResponse as Partial).redirect = originalRedirect; - }); + // Restore the original redirect method + (NextResponse as Partial).redirect = originalRedirect; + }); - it('should use Response if NextResponse.json is not available', async () => { - const originalJson = NextResponse.json; - (NextResponse as Partial).json = undefined; + it('should use Response if NextResponse.json is not available', async () => { + const originalJson = NextResponse.json; + (NextResponse as Partial).json = undefined; - const handler = handleAuth(); - const response = await handler(request); + const handler = handleAuth(); + const response = await handler(request); - expect(response).toBeInstanceOf(Response); + expect(response).toBeInstanceOf(Response); - // Restore the original json method - (NextResponse as Partial).json = originalJson; - }); + // Restore the original json method + (NextResponse as Partial).json = originalJson; + }); - it('should throw an error if baseURL is provided but invalid', async () => { - expect(() => handleAuth({ baseURL: 'invalid-url' })).toThrow('Invalid baseURL: invalid-url'); - }); + it('should throw an error if baseURL is provided but invalid', async () => { + expect(() => handleAuth({ baseURL: 'invalid-url' })).toThrow('Invalid baseURL: invalid-url'); + }); - it('should use baseURL if provided', async () => { - // Mock successful authentication response - const mockAuthResponse = { - accessToken: 'access123', - refreshToken: 'refresh123', - user: { id: 'user_123' }, - }; + it('should use baseURL if provided', async () => { + // Mock successful authentication response + const mockAuthResponse = { + accessToken: 'access123', + refreshToken: 'refresh123', + user: { id: 'user_123' }, + }; - (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); - // Set up request with code - request.nextUrl.searchParams.set('code', 'test-code'); + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); - const handler = handleAuth({ baseURL: 'https://base.com' }); - const response = await handler(request); + const handler = handleAuth({ baseURL: 'https://base.com' }); + const response = await handler(request); - expect(response.headers.get('Location')).toContain('https://base.com'); + expect(response.headers.get('Location')).toContain('https://base.com'); + }); + + it('should throw an error if response is missing tokens', async () => { + const mockAuthResponse = { + user: { id: 'user_123' }, + }; + + (workos.userManagement.authenticateWithCode as jest.Mock).mockResolvedValue(mockAuthResponse); + + // Set up request with code + request.nextUrl.searchParams.set('code', 'test-code'); + + const handler = handleAuth(); + const response = await handler(request); + + expect(response.status).toBe(500); + }); }); }); diff --git a/__tests__/cookie.spec.ts b/__tests__/cookie.spec.ts index d4ace04..fb026ef 100644 --- a/__tests__/cookie.spec.ts +++ b/__tests__/cookie.spec.ts @@ -11,39 +11,41 @@ describe('cookie.ts', () => { jest.resetModules(); }); - it('should return the default cookie options', async () => { - const { getCookieOptions } = await import('../src/cookie'); - - const options = getCookieOptions(); - expect(options).toEqual( - expect.objectContaining({ - path: '/', - httpOnly: true, - secure: false, - sameSite: 'lax', - maxAge: 400 * 24 * 60 * 60, - domain: 'example.com', - }), - ); - }); - - it('should return the cookie options with custom values', async () => { - // Import the mocked module - const envVars = await import('../src/env-variables'); - - // Set the mock values - Object.defineProperty(envVars, 'WORKOS_COOKIE_MAX_AGE', { value: '1000' }); - Object.defineProperty(envVars, 'WORKOS_COOKIE_DOMAIN', { value: 'foobar.com' }); - - const { getCookieOptions } = await import('../src/cookie'); - const options = getCookieOptions('http://example.com'); - - expect(options).toEqual( - expect.objectContaining({ - secure: false, - maxAge: 1000, - domain: 'foobar.com', - }), - ); + describe('getCookieOptions', () => { + it('should return the default cookie options', async () => { + const { getCookieOptions } = await import('../src/cookie'); + + const options = getCookieOptions(); + expect(options).toEqual( + expect.objectContaining({ + path: '/', + httpOnly: true, + secure: false, + sameSite: 'lax', + maxAge: 400 * 24 * 60 * 60, + domain: 'example.com', + }), + ); + }); + + it('should return the cookie options with custom values', async () => { + // Import the mocked module + const envVars = await import('../src/env-variables'); + + // Set the mock values + Object.defineProperty(envVars, 'WORKOS_COOKIE_MAX_AGE', { value: '1000' }); + Object.defineProperty(envVars, 'WORKOS_COOKIE_DOMAIN', { value: 'foobar.com' }); + + const { getCookieOptions } = await import('../src/cookie'); + const options = getCookieOptions('http://example.com'); + + expect(options).toEqual( + expect.objectContaining({ + secure: false, + maxAge: 1000, + domain: 'foobar.com', + }), + ); + }); }); }); diff --git a/__tests__/session.spec.ts b/__tests__/session.spec.ts new file mode 100644 index 0000000..afa4ac5 --- /dev/null +++ b/__tests__/session.spec.ts @@ -0,0 +1,605 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { cookies, headers } from 'next/headers'; +import { redirect } from 'next/navigation'; +import { withAuth, updateSession, refreshSession, getSession, terminateSession } from '../src/session.js'; +import { jwtVerify, SignJWT } from 'jose'; +import { sealData } from 'iron-session'; +import { workos } from '../src/workos.js'; +import { User } from '@workos-inc/node'; +import * as envVariables from '../src/env-variables.js'; + +jest.mock('jose', () => ({ + jwtVerify: jest.fn(), + createRemoteJWKSet: jest.fn(), + SignJWT: jest.requireActual('jose').SignJWT, + decodeJwt: jest.requireActual('jose').decodeJwt, +})); + +describe('session.ts', () => { + const mockSession = { + accessToken: 'access-token', + oauthTokens: undefined, + sessionId: 'session_123', + organizationId: 'org_123', + role: 'member', + permissions: ['posts:create', 'posts:delete'], + entitlements: ['audit-logs'], + impersonator: undefined, + user: { + object: 'user', + id: 'user_123', + email: 'test@example.com', + emailVerified: true, + profilePictureUrl: null, + firstName: null, + lastName: null, + createdAt: '2024-01-01', + updatedAt: '2024-01-01', + } as User, + }; + + let consoleLogSpy: jest.SpyInstance; + + beforeEach(async () => { + // Clear all mocks between tests + jest.clearAllMocks(); + + // Reset the cookie store + const nextCookies = await cookies(); + // @ts-expect-error - _reset is part of the mock + nextCookies._reset(); + + const nextHeaders = await headers(); + // @ts-expect-error - _reset is part of the mock + nextHeaders._reset(); + nextHeaders.set('x-workos-middleware', 'true'); + + (jwtVerify as jest.Mock).mockReset(); + + consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); + }); + + afterEach(() => { + consoleLogSpy.mockRestore(); + }); + + describe('withAuth', () => { + it('should return user info when authenticated', async () => { + mockSession.accessToken = await generateTestToken(); + + const nextHeaders = await headers(); + + nextHeaders.set( + 'x-workos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + const result = await withAuth(); + expect(result).toHaveProperty('user'); + expect(result.user).toEqual(mockSession.user); + }); + + it('should return null when user is not authenticated', async () => { + const result = await withAuth(); + + expect(result).toEqual({ user: null }); + }); + + it('should redirect when ensureSignedIn is true and user is not authenticated', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-url', 'https://example.com/protected'); + + await withAuth({ ensureSignedIn: true }); + + expect(redirect).toHaveBeenCalledTimes(1); + }); + + it('should throw an error if the route is not covered by the middleware', async () => { + const nextHeaders = await headers(); + nextHeaders.delete('x-workos-middleware'); + nextHeaders.set('x-url', 'https://example.com/'); + + await expect(async () => { + await withAuth(); + }).rejects.toThrow( + "You are calling 'withAuth' on https://example.com/ that isn’t covered by the AuthKit middleware. Make sure it is running on all paths you are calling 'withAuth' from by updating your middleware config in 'middleware.(js|ts)'.", + ); + }); + + it('should throw an error if the URL is not found in the headers', async () => { + const nextHeaders = await headers(); + nextHeaders.delete('x-url'); + + await expect(async () => { + await withAuth({ ensureSignedIn: true }); + }).rejects.toThrow('No URL found in the headers'); + }); + + it('should include any search parameters in the redirect URL', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-url', 'https://example.com/protected?test=123'); + + await withAuth({ ensureSignedIn: true }); + + const pathname = encodeURIComponent(btoa(JSON.stringify({ returnPathname: '/protected?test=123' }))); + + expect(redirect).toHaveBeenCalledWith(expect.stringContaining(pathname)); + }); + }); + + describe('updateSession', () => { + it('should throw an error if the redirect URI is not set', async () => { + const originalWorkosRedirectUri = envVariables.WORKOS_REDIRECT_URI; + + jest.replaceProperty(envVariables, 'WORKOS_REDIRECT_URI', ''); + + await expect(async () => { + await updateSession( + new NextRequest(new URL('http://example.com')), + false, + { + enabled: false, + unauthenticatedPaths: [], + }, + '', + [], + ); + }).rejects.toThrow('You must provide a redirect URI in the AuthKit middleware or in the environment variables.'); + + jest.replaceProperty(envVariables, 'WORKOS_REDIRECT_URI', originalWorkosRedirectUri); + }); + + it('should return early if there is no session', async () => { + const request = new NextRequest(new URL('http://example.com')); + const result = await updateSession( + request, + false, + { + enabled: false, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result).toBeInstanceOf(NextResponse); + expect(result.status).toBe(200); + }); + + it('should return 200 if the session is valid', async () => { + jest.spyOn(console, 'log').mockImplementation(() => {}); + + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + (jwtVerify as jest.Mock).mockImplementation(() => { + return true; + }); + + const request = new NextRequest(new URL('http://example.com')); + const result = await updateSession( + request, + true, + { + enabled: false, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result).toBeInstanceOf(NextResponse); + expect(result.status).toBe(200); + expect(console.log).toHaveBeenCalledWith('Session is valid'); + }); + + it('should attempt to refresh the session when the access token is invalid', async () => { + mockSession.accessToken = await generateTestToken({}, true); + + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + (jwtVerify as jest.Mock).mockImplementation(() => { + throw new Error('Invalid token'); + }); + + jest.spyOn(workos.userManagement, 'authenticateWithRefreshToken').mockResolvedValue({ + accessToken: await generateTestToken(), + refreshToken: 'new-refresh-token', + user: mockSession.user, + }); + + const request = new NextRequest(new URL('http://example.com')); + + const result = await updateSession( + request, + true, + { + enabled: false, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result.status).toBe(200); + expect(console.log).toHaveBeenCalledWith( + `Session invalid. Refreshing access token that ends in ${mockSession.accessToken.slice(-10)}`, + ); + expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Refresh successful. New access token ends in')); + }); + + it('should delete the cookie and redirect when refreshing fails', async () => { + jest.spyOn(console, 'log').mockImplementation(() => {}); + + mockSession.accessToken = await generateTestToken({}, true); + + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + (jwtVerify as jest.Mock).mockImplementation(() => { + throw new Error('Invalid token'); + }); + + jest + .spyOn(workos.userManagement, 'authenticateWithRefreshToken') + .mockRejectedValue(new Error('Failed to refresh')); + + const request = new NextRequest(new URL('http://example.com')); + + const result = await updateSession( + request, + true, + { + enabled: false, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result.status).toBe(307); + expect(nextCookies.get('wos-session')).toBeUndefined(); + expect(console.log).toHaveBeenCalledTimes(2); + expect(console.log).toHaveBeenNthCalledWith( + 1, + `Session invalid. Refreshing access token that ends in ${mockSession.accessToken.slice(-10)}`, + ); + expect(console.log).toHaveBeenNthCalledWith( + 2, + 'Failed to refresh. Deleting cookie and redirecting.', + new Error('Failed to refresh'), + ); + }); + + describe('middleware auth', () => { + it('should redirect unauthenticated users on protected routes', async () => { + jest.spyOn(console, 'log').mockImplementation(() => {}); + + const request = new NextRequest(new URL('http://example.com/protected')); + const result = await updateSession( + request, + true, + { + enabled: true, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result.status).toBe(307); + expect(console.log).toHaveBeenCalledWith( + 'Unauthenticated user on protected route http://example.com/protected, redirecting to AuthKit', + ); + }); + + it('should use Response if NextResponse.redirect is not available', async () => { + const originalRedirect = NextResponse.redirect; + (NextResponse as Partial).redirect = undefined; + + const request = new NextRequest(new URL('http://example.com/protected')); + const result = await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result).toBeInstanceOf(Response); + + // Restore the original redirect method + (NextResponse as Partial).redirect = originalRedirect; + }); + + it('should automatically add the redirect URI to unauthenticatedPaths when middleware is enabled', async () => { + const request = new NextRequest(new URL('http://example.com/protected')); + const result = await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: [], + }, + 'http://example.com/protected', + [], + ); + + expect(result.status).toBe(200); + }); + + it('should redirect unauthenticated users to sign up page on protected routes included in signUpPaths', async () => { + const request = new NextRequest(new URL('http://example.com/protected-signup')); + const result = await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + ['/protected-signup'], + ); + + expect(result.status).toBe(307); + expect(result.headers.get('Location')).toContain('screen_hint=sign-up'); + }); + + it('should allow logged out users on unauthenticated paths', async () => { + const request = new NextRequest(new URL('http://example.com/unauthenticated')); + const result = await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: ['/unauthenticated'], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + + expect(result.status).toBe(200); + }); + + it('should throw an error if the provided regex is invalid', async () => { + const request = new NextRequest(new URL('http://example.com/invalid-regex')); + await expect(async () => { + await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: ['[*'], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + }).rejects.toThrow(); + }); + + it('should default to the WORKOS_REDIRECT_URI environment variable if no redirect URI is provided', async () => { + const request = new NextRequest(new URL('http://example.com/protected')); + const result = await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: [], + }, + '', + [], + ); + + expect(result.status).toBe(307); + }); + + describe('sign up paths', () => { + it('should redirect to sign up when unauthenticated user is on a sign up path', async () => { + const request = new NextRequest(new URL('http://example.com/signup')); + + const result = await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: [], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + ['/signup'], + ); + + expect(result.status).toBe(307); + expect(result.headers.get('Location')).toContain('screen_hint=sign-up'); + }); + + it('should accept a sign up path as a string', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-url', 'http://example.com/signup'); + nextHeaders.set('x-sign-up-paths', '/signup'); + + await withAuth({ ensureSignedIn: true }); + expect(redirect).toHaveBeenCalledTimes(1); + expect(redirect).toHaveBeenCalledWith(expect.stringContaining('screen_hint=sign-up')); + }); + }); + }); + }); + + describe('refreshSession', () => { + it('should refresh session successfully', async () => { + jest.spyOn(workos.userManagement, 'authenticateWithRefreshToken').mockResolvedValue({ + accessToken: await generateTestToken(), + refreshToken: 'new-refresh-token', + user: mockSession.user, + }); + + jest + .spyOn(workos.userManagement, 'getJwksUrl') + .mockReturnValue('https://api.workos.com/sso/jwks/client_1234567890'); + + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + const result = await refreshSession({ ensureSignedIn: false }); + + expect(result).toHaveProperty('user'); + expect(result).toHaveProperty('accessToken'); + }); + + it('should return null user when no session exists', async () => { + const result = await refreshSession({ ensureSignedIn: false }); + expect(result).toEqual({ user: null }); + }); + + it('should redirect to sign in when ensureSignedIn is true and no session exists', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-url', 'http://example.com/protected'); + + const response = await refreshSession({ ensureSignedIn: true }); + + expect(response).toEqual({ user: null }); + expect(redirect).toHaveBeenCalledTimes(1); + }); + + it('should use the organizationId provided in the options', async () => { + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + jest.spyOn(workos.userManagement, 'authenticateWithRefreshToken').mockResolvedValue({ + accessToken: await generateTestToken({ org_id: 'org_456' }), + refreshToken: 'new-refresh-token', + user: mockSession.user, + }); + + jest + .spyOn(workos.userManagement, 'getJwksUrl') + .mockReturnValue('https://api.workos.com/sso/jwks/client_1234567890'); + + const result = await refreshSession({ organizationId: 'org_456' }); + + expect(result).toHaveProperty('user'); + expect(result.organizationId).toBe('org_456'); + }); + }); + + describe('getSession', () => { + it('should return session info when valid', async () => { + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + const result = await getSession(); + expect(result).toHaveProperty('user'); + }); + + it('should return null user when no session exists', async () => { + const result = await getSession(); + expect(result).toEqual({ user: null }); + }); + + it('should return undefined if the access token is invalid', async () => { + mockSession.accessToken = 'invalid-token'; + + const nextCookies = await cookies(); + nextCookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + (jwtVerify as jest.Mock).mockImplementation(() => { + throw new Error('Invalid token'); + }); + + const result = await getSession(); + expect(result).toEqual(undefined); + }); + + it('should return cookie from a response object if provided', async () => { + mockSession.accessToken = await generateTestToken(); + + const response = new NextResponse(); + response.cookies.set( + 'wos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + const result = await getSession(response); + expect(result).toEqual(mockSession); + }); + }); + + describe('terminateSession', () => { + it('should redirect to logout url when there is a session', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-url', 'http://example.com/protected'); + + mockSession.accessToken = await generateTestToken(); + + nextHeaders.set( + 'x-workos-session', + await sealData(mockSession, { password: process.env.WORKOS_COOKIE_PASSWORD as string }), + ); + + await terminateSession(); + + expect(redirect).toHaveBeenCalledTimes(1); + expect(redirect).toHaveBeenCalledWith( + 'https://api.workos.com/user_management/sessions/logout?session_id=session_123', + ); + }); + + it('should redirect to home when there is no session', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-url', 'http://example.com/protected'); + + await terminateSession(); + + expect(redirect).toHaveBeenCalledTimes(1); + expect(redirect).toHaveBeenCalledWith('/'); + }); + }); +}); + +async function generateTestToken(payload = {}, expired = false) { + const defaultPayload = { + sid: 'session_123', + org_id: 'org_123', + role: 'member', + permissions: ['posts:create', 'posts:delete'], + entitlements: ['audit-logs'], + }; + + const mergedPayload = { ...defaultPayload, ...payload }; + + const secret = new TextEncoder().encode(process.env.WORKOS_COOKIE_PASSWORD as string); + + const token = await new SignJWT(mergedPayload) + .setProtectedHeader({ alg: 'HS256' }) + .setIssuedAt() + .setIssuer('urn:example:issuer') + .setExpirationTime(expired ? '0s' : '2h') + .sign(secret); + + return token; +} diff --git a/jest.config.ts b/jest.config.ts index bffefff..839ae96 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -186,7 +186,7 @@ const config: Config = { // unmockedModulePathPatterns: undefined, // Indicates whether each individual test should be reported during the run - // verbose: undefined, + verbose: true, // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode // watchPathIgnorePatterns: [], diff --git a/src/session.ts b/src/session.ts index 0f49c3e..b482667 100644 --- a/src/session.ts +++ b/src/session.ts @@ -94,16 +94,7 @@ async function updateSession( screenHint: getScreenHint(signUpPaths, request.nextUrl.pathname), }); - // Fall back to standard Response if NextResponse is not available. - // This is to support Next.js 13. - return NextResponse?.redirect - ? NextResponse.redirect(redirectTo) - : new Response(null, { - status: 302, - headers: { - Location: redirectTo, - }, - }); + return redirectWithFallback(redirectTo); } // If no session, just continue @@ -168,14 +159,7 @@ async function updateSession( // We redirect to the current URL which will trigger the middleware again. // This is outside of the above block because you cannot redirect in Next.js // from inside a try/catch block. - return NextResponse?.redirect - ? NextResponse.redirect(request.url) - : new Response(null, { - status: 307, - headers: { - Location: request.url, - }, - }); + return redirectWithFallback(request.url); } async function refreshSession(options: { @@ -242,14 +226,12 @@ async function refreshSession({ } function getMiddlewareAuthPathRegex(pathGlob: string) { - let regex: string; - try { const url = new URL(pathGlob, 'https://example.com'); const path = `${url.pathname!}${url.hash || ''}`; const tokens = parse(path); - regex = tokensToRegexp(tokens).source; + const regex = tokensToRegexp(tokens).source; return new RegExp(regex); } catch (err) { @@ -261,7 +243,11 @@ function getMiddlewareAuthPathRegex(pathGlob: string) { async function redirectToSignIn() { const headersList = await headers(); - const url = headersList.get('x-url') ?? ''; + const url = headersList.get('x-url'); + + if (!url) { + throw new Error('No URL found in the headers'); + } // Determine if the current route is in the sign up paths const signUpPaths = headersList.get(signUpPathsHeaderName)?.split(','); @@ -269,7 +255,7 @@ async function redirectToSignIn() { const pathname = new URL(url).pathname; const screenHint = getScreenHint(signUpPaths, pathname); - const returnPathname = url && getReturnPathname(url); + const returnPathname = getReturnPathname(url); redirect(await getAuthorizationUrl({ returnPathname, screenHint })); } @@ -312,8 +298,9 @@ async function terminateSession() { const { sessionId } = await withAuth(); if (sessionId) { redirect(workos.userManagement.getLogoutUrl({ sessionId })); + } else { + redirect('/'); } - redirect('/'); } async function verifyAccessToken(accessToken: string) { @@ -331,7 +318,7 @@ async function getSessionFromCookie(response?: NextResponse) { const cookie = response ? response.cookies.get(cookieName) : nextCookies.get(cookieName); if (cookie) { - return unsealData(cookie.value, { + return unsealData(cookie.value ?? cookie, { password: WORKOS_COOKIE_PASSWORD, }); } @@ -392,14 +379,9 @@ function getReturnPathname(url: string): string { return `${newUrl.pathname}${newUrl.searchParams.size > 0 ? '?' + newUrl.searchParams.toString() : ''}`; } -function getScreenHint(signUpPaths: string[] | string | undefined, pathname: string) { +function getScreenHint(signUpPaths: string[] | undefined, pathname: string) { if (!signUpPaths) return 'sign-in'; - if (!Array.isArray(signUpPaths)) { - const pathRegex = getMiddlewareAuthPathRegex(signUpPaths); - return pathRegex.exec(pathname) ? 'sign-up' : 'sign-in'; - } - const screenHintPaths: string[] = signUpPaths.filter((pathGlob) => { const pathRegex = getMiddlewareAuthPathRegex(pathGlob); return pathRegex.exec(pathname); @@ -408,4 +390,12 @@ function getScreenHint(signUpPaths: string[] | string | undefined, pathname: str return screenHintPaths.length > 0 ? 'sign-up' : 'sign-in'; } +function redirectWithFallback(redirectUri: string) { + // Fall back to standard Response if NextResponse is not available. + // This is to support Next.js 13. + return NextResponse?.redirect + ? NextResponse.redirect(redirectUri) + : new Response(null, { status: 307, headers: { Location: redirectUri } }); +} + export { encryptSession, withAuth, refreshSession, terminateSession, updateSession, getSession }; From 0c55d70efd901b784e1168f4e9d92d42f3c685d9 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 3 Dec 2024 15:21:29 +0100 Subject: [PATCH 04/19] Add jsdom tests for tsx files --- __tests__/actions.spec.ts | 14 +- __tests__/authkit-callback-route.spec.ts | 2 +- __tests__/authkit-provider.spec.tsx | 149 ++++++++++++++ __tests__/button.spec.tsx | 46 +++++ __tests__/impersonation.spec.tsx | 98 +++++++++ __tests__/min-max-button.spec.tsx | 44 ++++ __tests__/session.spec.ts | 6 +- jest.config.ts | 36 +++- jest.setup.ts | 6 +- package-lock.json | 244 +++++++++++++++++++++++ package.json | 6 +- src/actions.ts | 6 + src/authkit-callback-route.ts | 9 +- src/authkit-provider.tsx | 1 + src/impersonation.tsx | 9 +- tsconfig.json | 3 +- 16 files changed, 655 insertions(+), 24 deletions(-) create mode 100644 __tests__/authkit-provider.spec.tsx create mode 100644 __tests__/button.spec.tsx create mode 100644 __tests__/impersonation.spec.tsx create mode 100644 __tests__/min-max-button.spec.tsx diff --git a/__tests__/actions.spec.ts b/__tests__/actions.spec.ts index dabf4a9..976d2e7 100644 --- a/__tests__/actions.spec.ts +++ b/__tests__/actions.spec.ts @@ -1,4 +1,9 @@ -import { checkSessionAction } from '../src/actions.js'; +import { checkSessionAction, handleSignOutAction } from '../src/actions.js'; +import { signOut } from '../src/auth.js'; + +jest.mock('../src/auth.js', () => ({ + signOut: jest.fn().mockResolvedValue(true), +})); describe('actions', () => { describe('checkSessionAction', () => { @@ -7,4 +12,11 @@ describe('actions', () => { expect(result).toBe(true); }); }); + + describe('handleSignOutAction', () => { + it('should call signOut', async () => { + await handleSignOutAction(); + expect(signOut).toHaveBeenCalled(); + }); + }); }); diff --git a/__tests__/authkit-callback-route.spec.ts b/__tests__/authkit-callback-route.spec.ts index 50764b4..3360210 100644 --- a/__tests__/authkit-callback-route.spec.ts +++ b/__tests__/authkit-callback-route.spec.ts @@ -1,6 +1,6 @@ +import { workos } from '../src/workos.js'; import { handleAuth } from '../src/authkit-callback-route.js'; import { NextRequest, NextResponse } from 'next/server'; -import { workos } from '../src/workos.js'; // Mocked in jest.setup.ts import { cookies, headers } from 'next/headers'; diff --git a/__tests__/authkit-provider.spec.tsx b/__tests__/authkit-provider.spec.tsx new file mode 100644 index 0000000..f77830b --- /dev/null +++ b/__tests__/authkit-provider.spec.tsx @@ -0,0 +1,149 @@ +import React from 'react'; +import { render, waitFor } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { AuthKitProvider } from '../src/authkit-provider.js'; +import { checkSessionAction } from '../src/actions.js'; + +jest.mock('../src/actions', () => ({ + checkSessionAction: jest.fn(), +})); + +describe('AuthKitProvider', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should render children', () => { + const { getByText } = render( + +
Test Child
+
, + ); + + expect(getByText('Test Child')).toBeInTheDocument(); + }); + + it('should do nothing if onSessionExpired is false', async () => { + jest.spyOn(window, 'addEventListener'); + + render( + +
Test Child
+
, + ); + + // expect window to not have an event listener + expect(window.addEventListener).not.toHaveBeenCalled(); + }); + + it('should call onSessionExpired when session is expired', async () => { + (checkSessionAction as jest.Mock).mockRejectedValueOnce(new Error('Failed to fetch')); + const onSessionExpired = jest.fn(); + + render( + +
Test Child
+
, + ); + + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + + await waitFor(() => { + expect(onSessionExpired).toHaveBeenCalled(); + }); + }); + + it('should only call onSessionExpired once if multiple visibility changes occur', async () => { + (checkSessionAction as jest.Mock).mockRejectedValueOnce(new Error('Failed to fetch')); + const onSessionExpired = jest.fn(); + + render( + +
Test Child
+
, + ); + + // Simulate visibility change twice + window.dispatchEvent(new Event('visibilitychange')); + window.dispatchEvent(new Event('visibilitychange')); + + await waitFor(() => { + expect(onSessionExpired).toHaveBeenCalledTimes(1); + }); + }); + + it('should pass through if checkSessionAction does not throw "Failed to fetch"', async () => { + (checkSessionAction as jest.Mock).mockResolvedValueOnce(false); + + const onSessionExpired = jest.fn(); + + render( + +
Test Child
+
, + ); + + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + + await waitFor(() => { + expect(onSessionExpired).not.toHaveBeenCalled(); + }); + }); + + it('should reload the page when session is expired and no onSessionExpired handler is provided', async () => { + (checkSessionAction as jest.Mock).mockRejectedValueOnce(new Error('Failed to fetch')); + + const originalLocation = window.location; + + // @ts-expect-error - we're deleting the property to test the mock + delete window.location; + + window.location = { ...window.location, reload: jest.fn() }; + + render( + +
Test Child
+
, + ); + + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + + await waitFor(() => { + expect(window.location.reload).toHaveBeenCalled(); + }); + + // Restore original reload function + window.location = originalLocation; + }); + + it('should not call onSessionExpired or reload the page if session is valid', async () => { + (checkSessionAction as jest.Mock).mockResolvedValueOnce(true); + const onSessionExpired = jest.fn(); + + const originalLocation = window.location; + + // @ts-expect-error - we're deleting the property to test the mock + delete window.location; + + window.location = { ...window.location, reload: jest.fn() }; + + render( + +
Test Child
+
, + ); + + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + + await waitFor(() => { + expect(onSessionExpired).not.toHaveBeenCalled(); + expect(window.location.reload).not.toHaveBeenCalled(); + }); + + window.location = originalLocation; + }); +}); diff --git a/__tests__/button.spec.tsx b/__tests__/button.spec.tsx new file mode 100644 index 0000000..1db8da2 --- /dev/null +++ b/__tests__/button.spec.tsx @@ -0,0 +1,46 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { Button } from '../src/button.js'; + +describe('Button', () => { + it('should render with default props', () => { + const { getByRole } = render(); + const button = getByRole('button'); + + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent('Click me'); + expect(button).toHaveAttribute('type', 'button'); + }); + + it('should forward ref correctly', () => { + const ref = React.createRef(); + render(); + + expect(ref.current).toBeInstanceOf(HTMLButtonElement); + }); + + it('should merge custom styles with default styles', () => { + const { getByRole } = render(); + const button = getByRole('button'); + + expect(button).toHaveStyle({ + backgroundColor: 'red', + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + }); + }); + + it('should pass through additional props', () => { + const { getByRole } = render( + , + ); + const button = getByRole('button'); + + expect(button).toHaveAttribute('data-testid', 'test-button'); + expect(button).toHaveAttribute('aria-label', 'Test Button'); + }); +}); diff --git a/__tests__/impersonation.spec.tsx b/__tests__/impersonation.spec.tsx new file mode 100644 index 0000000..7bc1521 --- /dev/null +++ b/__tests__/impersonation.spec.tsx @@ -0,0 +1,98 @@ +import { render } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { Impersonation } from '../src/impersonation.js'; +import { withAuth } from '../src/session.js'; +import { workos } from '../src/workos.js'; + +jest.mock('../src/session', () => ({ + withAuth: jest.fn(), +})); + +jest.mock('../src/workos', () => ({ + workos: { + organizations: { + getOrganization: jest.fn(), + }, + }, +})); + +describe('Impersonation', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should return null if not impersonating', async () => { + (withAuth as jest.Mock).mockResolvedValue({ + impersonator: null, + user: { id: '123' }, + organizationId: null, + }); + + const { container } = await render(await Impersonation({})); + expect(container).toBeEmptyDOMElement(); + }); + + it('should render impersonation banner when impersonating', async () => { + (withAuth as jest.Mock).mockResolvedValue({ + impersonator: { email: 'admin@example.com' }, + user: { id: '123' }, + organizationId: null, + }); + + const { container } = await render(await Impersonation({})); + expect(container.querySelector('[data-workos-impersonation-root]')).toBeInTheDocument(); + }); + + it('should render with organization info when organizationId is provided', async () => { + (withAuth as jest.Mock).mockResolvedValue({ + impersonator: { email: 'admin@example.com' }, + user: { id: '123' }, + organizationId: 'org_123', + }); + + (workos.organizations.getOrganization as jest.Mock).mockResolvedValue({ + id: 'org_123', + name: 'Test Org', + }); + + const { container } = await render(await Impersonation({})); + expect(container.querySelector('[data-workos-impersonation-root]')).toBeInTheDocument(); + }); + + it('should render at the bottom by default', async () => { + (withAuth as jest.Mock).mockResolvedValue({ + impersonator: { email: 'admin@example.com' }, + user: { id: '123' }, + organizationId: null, + }); + + const { container } = await render(await Impersonation({})); + const banner = container.querySelector('[data-workos-impersonation-root] > div:nth-child(2)'); + expect(banner).toHaveStyle({ bottom: 'var(--wi-s)' }); + }); + + it('should render at the top when side prop is "top"', async () => { + (withAuth as jest.Mock).mockResolvedValue({ + impersonator: { email: 'admin@example.com' }, + user: { id: '123' }, + organizationId: null, + }); + + const { container } = await render(await Impersonation({ side: 'top' })); + const banner = container.querySelector('[data-workos-impersonation-root] > div:nth-child(2)'); + expect(banner).toHaveStyle({ top: 'var(--wi-s)' }); + }); + + it('should merge custom styles with default styles', async () => { + (withAuth as jest.Mock).mockResolvedValue({ + impersonator: { email: 'admin@example.com' }, + user: { id: '123' }, + organizationId: null, + }); + + const customStyle = { backgroundColor: 'red' }; + const { container } = await render(await Impersonation({ style: customStyle })); + const root = container.querySelector('[data-workos-impersonation-root]'); + expect(root).toHaveStyle({ backgroundColor: 'red' }); + }); +}); diff --git a/__tests__/min-max-button.spec.tsx b/__tests__/min-max-button.spec.tsx new file mode 100644 index 0000000..0c304f3 --- /dev/null +++ b/__tests__/min-max-button.spec.tsx @@ -0,0 +1,44 @@ +import { render, fireEvent } from '@testing-library/react'; +import { MinMaxButton } from '../src/min-max-button.js'; +import * as React from 'react'; +import '@testing-library/jest-dom'; + +describe('MinMaxButton', () => { + beforeEach(() => { + // Create the root element before each test + const root = document.createElement('div'); + root.setAttribute('data-workos-impersonation-root', ''); + document.body.appendChild(root); + }); + + afterEach(() => { + // Clean up after each test + document.body.innerHTML = ''; + }); + + it('sets minimized value when clicked', () => { + const { getByRole } = render(Minimize); + + const button = getByRole('button'); + fireEvent.click(button); + + const root = document.querySelector('[data-workos-impersonation-root]'); + expect(root).toHaveStyle({ '--wi-minimized': '1' }); + }); + + it('renders children correctly', () => { + const { getByText } = render(Test Child); + + expect(getByText('Test Child')).toBeInTheDocument(); + }); + + it('applies correct default styling', () => { + const { getByRole } = render(Test); + + const button = getByRole('button'); + expect(button).toHaveStyle({ + padding: 0, + width: '1.714em', + }); + }); +}); diff --git a/__tests__/session.spec.ts b/__tests__/session.spec.ts index afa4ac5..a55c543 100644 --- a/__tests__/session.spec.ts +++ b/__tests__/session.spec.ts @@ -1,12 +1,14 @@ import { NextRequest, NextResponse } from 'next/server'; import { cookies, headers } from 'next/headers'; import { redirect } from 'next/navigation'; + import { withAuth, updateSession, refreshSession, getSession, terminateSession } from '../src/session.js'; +import { workos } from '../src/workos.js'; +import * as envVariables from '../src/env-variables.js'; + import { jwtVerify, SignJWT } from 'jose'; import { sealData } from 'iron-session'; -import { workos } from '../src/workos.js'; import { User } from '@workos-inc/node'; -import * as envVariables from '../src/env-variables.js'; jest.mock('jose', () => ({ jwtVerify: jest.fn(), diff --git a/jest.config.ts b/jest.config.ts index 839ae96..05e0475 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -102,7 +102,31 @@ const config: Config = { preset: 'ts-jest', // Run tests from one or more projects - // projects: undefined, + projects: [ + { + displayName: 'jsdom', + testEnvironment: 'jsdom', + testMatch: ['**/__tests__/**/*.spec.tsx'], + transform: { + '^.+\\.tsx?$': 'ts-jest', // Use ts-jest for TypeScript files + }, + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + }, + { + displayName: 'node', + testEnvironment: 'node', + testMatch: ['**/__tests__/**/*.spec.ts'], + transform: { + '^.+\\.tsx?$': 'ts-jest', + }, + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + setupFiles: ['/jest.setup.ts'], + }, + ], // Use this configuration option to add custom reporters to Jest // reporters: undefined, @@ -131,7 +155,7 @@ const config: Config = { // runner: "jest-runner", // The paths to modules that run some code to configure or set up the testing environment before each test - setupFiles: ['/jest.setup.ts'], + // setupFiles: ['/jest.setup.ts'], // A list of paths to modules that run some code to configure or set up the testing framework before each test // setupFilesAfterEnv: [], @@ -143,7 +167,7 @@ const config: Config = { // snapshotSerializers: [], // The test environment that will be used for testing - testEnvironment: 'node', + // testEnvironment: 'node', // Options that will be passed to the testEnvironment // testEnvironmentOptions: {}, @@ -172,9 +196,9 @@ const config: Config = { // testRunner: "jest-circus/runner", // A map from regular expressions to paths to transformers - transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', - }, + // transform: { + // '^.+\\.(ts|tsx)$': 'ts-jest', + // }, // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation // transformIgnorePatterns: [ diff --git a/jest.setup.ts b/jest.setup.ts index 7cbadcb..ae3f199 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -7,8 +7,6 @@ process.env.WORKOS_COOKIE_DOMAIN = 'example.com'; const cookieStore = new Map(); const headersStore = new Map(); -type CookieValue = string | { [key: string]: string | number | boolean }; - // Mock the next/headers module jest.mock('next/headers', () => ({ headers: async () => ({ @@ -26,7 +24,9 @@ jest.mock('next/headers', () => ({ }), get: jest.fn((name: string) => cookieStore.get(name)), getAll: jest.fn(() => Array.from(cookieStore.entries())), - set: jest.fn((name: string, value: CookieValue) => cookieStore.set(name, value)), + set: jest.fn((name: string, value: string | { [key: string]: string | number | boolean }) => + cookieStore.set(name, value), + ), _reset: () => { cookieStore.clear(); }, diff --git a/package-lock.json b/package-lock.json index 0432541..4775a84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,8 @@ "path-to-regexp": "^6.2.2" }, "devDependencies": { + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/react": "^16.0.1", "@types/jest": "^29.5.14", "@types/node": "^20.11.28", "@types/react": "18.2.67", @@ -46,6 +48,12 @@ "node": ">=0.10.0" } }, + "node_modules/@adobe/css-tools": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.1.tgz", + "integrity": "sha512-12WGKBQzjUAI4ayyF4IAtfw2QR/IDoqk6jTddXDhtYTJF9ASmoE1zst7cVtP0aL/F1jUJL5r+JxKXKEgHNbEUQ==", + "dev": true + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -478,6 +486,18 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/runtime": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", + "integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.25.9", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", @@ -1742,6 +1762,127 @@ "tslib": "^2.4.0" } }, + "node_modules/@testing-library/dom": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", + "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "chalk": "^4.1.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/dom/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@testing-library/dom/node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "peer": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/@testing-library/dom/node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, + "peer": true + }, + "node_modules/@testing-library/jest-dom": { + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", + "dev": true, + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "chalk": "^3.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "lodash": "^4.17.21", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true + }, + "node_modules/@testing-library/react": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.0.1.tgz", + "integrity": "sha512-dSmwJVtJXmku+iocRhWOUFbrERC76TX2Mnf0ATODz8brzAZrMBbzLwQixlBSanZxR6LddK3eiwpSFZgDET1URg==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@tootallnate/once": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", @@ -1783,6 +1924,13 @@ "@types/node": "*" } }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "peer": true + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -2509,6 +2657,15 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -3038,6 +3195,12 @@ "node": ">= 8" } }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true + }, "node_modules/cssom": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz", @@ -3143,6 +3306,15 @@ "node": ">=0.4.0" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/detect-libc": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", @@ -3204,6 +3376,13 @@ "node": ">=6.0.0" } }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "peer": true + }, "node_modules/domexception": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", @@ -4061,6 +4240,15 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -5069,6 +5257,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -5102,6 +5296,16 @@ "yallist": "^3.0.2" } }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "peer": true, + "bin": { + "lz-string": "bin/bin.js" + } + }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -5190,6 +5394,15 @@ "node": ">=6" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/minimatch": { "version": "9.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", @@ -5794,6 +6007,25 @@ "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", "dev": true }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "dev": true + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -6165,6 +6397,18 @@ "node": ">=6" } }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", diff --git a/package.json b/package.json index 4619556..7cc77a5 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "prepublishOnly": "npm run lint", "lint": "eslint \"src/**/*.ts*\"", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "prettier": "prettier \"src/**/*.{js,ts,tsx}\" --check", + "format": "prettier \"src/**/*.{js,ts,tsx}\" --write" }, "dependencies": { "@workos-inc/node": "^7.33.0", @@ -33,6 +35,8 @@ "react-dom": "^18.0 || ^19.0.0" }, "devDependencies": { + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/react": "^16.0.1", "@types/jest": "^29.5.14", "@types/node": "^20.11.28", "@types/react": "18.2.67", diff --git a/src/actions.ts b/src/actions.ts index dcc1ee4..af32585 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,5 +1,7 @@ 'use server'; +import { signOut } from './auth.js'; + /** * This action is only accessible to authenticated users, * there is no need to check the session here as the middleware will @@ -8,3 +10,7 @@ export const checkSessionAction = async () => { return true; }; + +export const handleSignOutAction = async () => { + await signOut(); +}; diff --git a/src/authkit-callback-route.ts b/src/authkit-callback-route.ts index e7126c6..9747729 100644 --- a/src/authkit-callback-route.ts +++ b/src/authkit-callback-route.ts @@ -26,10 +26,11 @@ export function handleAuth(options: HandleAuthOptions = {}) { if (code) { try { // Use the code returned to us by AuthKit and authenticate the user with WorkOS - const { accessToken, refreshToken, user, impersonator, oauthTokens } = await workos.userManagement.authenticateWithCode({ - clientId: WORKOS_CLIENT_ID, - code, - }); + const { accessToken, refreshToken, user, impersonator, oauthTokens } = + await workos.userManagement.authenticateWithCode({ + clientId: WORKOS_CLIENT_ID, + code, + }); // If baseURL is provided, use it instead of request.nextUrl // This is useful if the app is being run in a container like docker where diff --git a/src/authkit-provider.tsx b/src/authkit-provider.tsx index 444f5b9..4b34000 100644 --- a/src/authkit-provider.tsx +++ b/src/authkit-provider.tsx @@ -19,6 +19,7 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP return; } + // We'll use this flag to prevent multiple calls to the checkSessionAction let visibilityChangedCalled = false; const handleVisibilityChange = async () => { diff --git a/src/impersonation.tsx b/src/impersonation.tsx index f39ef41..f29b1da 100644 --- a/src/impersonation.tsx +++ b/src/impersonation.tsx @@ -1,9 +1,11 @@ +'use client'; + import * as React from 'react'; import { withAuth } from './session.js'; -import { signOut } from './auth.js'; import { workos } from './workos.js'; import { Button } from './button.js'; import { MinMaxButton } from './min-max-button.js'; +import { handleSignOutAction } from './actions.js'; interface ImpersonationProps extends React.ComponentPropsWithoutRef<'div'> { side?: 'top' | 'bottom'; @@ -69,10 +71,7 @@ export async function Impersonation({ side = 'bottom', ...props }: Impersonation }} >
{ - 'use server'; - await signOut(); - }} + onSubmit={handleSignOutAction} style={{ display: 'flex', alignItems: 'baseline', diff --git a/tsconfig.json b/tsconfig.json index fde330e..fee4ee6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,8 @@ "skipLibCheck": true, "outDir": "./dist/esm", "module": "ES2020", - "moduleResolution": "Node" + "moduleResolution": "node", + "allowSyntheticDefaultImports": true }, "exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"] } From 47aee5039ed9b3722b26c7fa6d5206167c71e504 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 3 Dec 2024 16:00:44 +0100 Subject: [PATCH 05/19] Add new workflow --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++ jest.setup.ts | 54 +++++++++++++++++++++------------------- 2 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f61e658 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + branches: + - 'main' + pull_request: {} + +defaults: + run: + shell: bash + +jobs: + test: + name: Test Node ${{ matrix.node }} + runs-on: ubuntu-latest + strategy: + matrix: + node: [18, 20, 22] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + + - name: Install Dependencies + run: | + npm install + + - name: Prettier + run: | + npm run prettier + + - name: Lint + run: | + npm run lint + + - name: Build + run: | + npm run build + + - name: Test + run: | + npm run test diff --git a/jest.setup.ts b/jest.setup.ts index ae3f199..7163a08 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -4,34 +4,36 @@ process.env.WORKOS_COOKIE_PASSWORD = 'kR620keEzOIzPThfnMEAba8XYgKdQ5vg'; process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI = 'http://localhost:3000/callback'; process.env.WORKOS_COOKIE_DOMAIN = 'example.com'; -const cookieStore = new Map(); -const headersStore = new Map(); - // Mock the next/headers module -jest.mock('next/headers', () => ({ - headers: async () => ({ - delete: jest.fn((name: string) => headersStore.delete(name)), - get: jest.fn((name: string) => headersStore.get(name)), - set: jest.fn((name: string, value: string) => headersStore.set(name, value)), - _reset: () => { - headersStore.clear(); - }, - }), - cookies: async () => ({ - delete: jest.fn((nameOrObject: string | { name: string; [key: string]: unknown }) => { - const cookieName = typeof nameOrObject === 'string' ? nameOrObject : nameOrObject.name; - cookieStore.delete(cookieName); +jest.mock('next/headers', () => { + const cookieStore = new Map(); + const headersStore = new Map(); + + return { + headers: async () => ({ + delete: jest.fn((name: string) => headersStore.delete(name)), + get: jest.fn((name: string) => headersStore.get(name)), + set: jest.fn((name: string, value: string) => headersStore.set(name, value)), + _reset: () => { + headersStore.clear(); + }, }), - get: jest.fn((name: string) => cookieStore.get(name)), - getAll: jest.fn(() => Array.from(cookieStore.entries())), - set: jest.fn((name: string, value: string | { [key: string]: string | number | boolean }) => - cookieStore.set(name, value), - ), - _reset: () => { - cookieStore.clear(); - }, - }), -})); + cookies: async () => ({ + delete: jest.fn((nameOrObject: string | { name: string; [key: string]: unknown }) => { + const cookieName = typeof nameOrObject === 'string' ? nameOrObject : nameOrObject.name; + cookieStore.delete(cookieName); + }), + get: jest.fn((name: string) => cookieStore.get(name)), + getAll: jest.fn(() => Array.from(cookieStore.entries())), + set: jest.fn((name: string, value: string | { [key: string]: string | number | boolean }) => + cookieStore.set(name, value), + ), + _reset: () => { + cookieStore.clear(); + }, + }), + }; +}); jest.mock('next/navigation', () => ({ redirect: jest.fn(), From 10d2004659f60f7707d07bb51b968df77b416b56 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 3 Dec 2024 16:03:19 +0100 Subject: [PATCH 06/19] Clean up jest config file --- jest.config.ts | 167 ------------------------------------------------- 1 file changed, 167 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 05e0475..a5a0f5e 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,103 +1,23 @@ import type { Config } from 'jest'; const config: Config = { - // All imported modules in your tests should be mocked automatically - // automock: false, - - // Stop running tests after `n` failures - // bail: 0, - - // The directory where Jest should store its cached dependency information - // cacheDirectory: "/private/var/folders/rg/0ppfq_s11hv0l53tlfb8m4vm0000gn/T/jest_dx", - // Automatically clear mock calls, instances, contexts and results before every test clearMocks: true, // Indicates whether the coverage information should be collected while executing the test collectCoverage: true, - // An array of glob patterns indicating a set of files for which coverage information should be collected - // collectCoverageFrom: undefined, - // The directory where Jest should output its coverage files coverageDirectory: 'coverage', - // An array of regexp pattern strings used to skip coverage collection - // coveragePathIgnorePatterns: [ - // "/node_modules/" - // ], - // Indicates which provider should be used to instrument code for coverage coverageProvider: 'v8', - // A list of reporter names that Jest uses when writing coverage reports - // coverageReporters: [ - // "json", - // "text", - // "lcov", - // "clover" - // ], - - // An object that configures minimum threshold enforcement for coverage results - // coverageThreshold: undefined, - - // A path to a custom dependency extractor - // dependencyExtractor: undefined, - - // Make calling deprecated APIs throw helpful error messages - // errorOnDeprecated: false, - - // The default configuration for fake timers - // fakeTimers: { - // "enableGlobally": false - // }, - - // Force coverage collection from ignored files using an array of glob patterns - // forceCoverageMatch: [], - - // A path to a module which exports an async function that is triggered once before all test suites - // globalSetup: undefined, - - // A path to a module which exports an async function that is triggered once after all test suites - // globalTeardown: undefined, - - // A set of global variables that need to be available in all test environments - // globals: {}, - - // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. - // maxWorkers: "50%", - - // An array of directory names to be searched recursively up from the requiring module's location - // moduleDirectories: [ - // "node_modules" - // ], - - // An array of file extensions your modules use - // moduleFileExtensions: [ - // "js", - // "mjs", - // "cjs", - // "jsx", - // "ts", - // "tsx", - // "json", - // "node" - // ], - // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', // Handle ESM imports }, - // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader - // modulePathIgnorePatterns: [], - - // Activates notifications for test results - // notify: false, - - // An enum that specifies notification mode. Requires { notify: true } - // notifyMode: "failure-change", - // A preset that is used as a base for Jest's configuration preset: 'ts-jest', @@ -128,96 +48,9 @@ const config: Config = { }, ], - // Use this configuration option to add custom reporters to Jest - // reporters: undefined, - - // Automatically reset mock state before every test - // resetMocks: false, - - // Reset the module registry before running each individual test - // resetModules: false, - - // A path to a custom resolver - // resolver: undefined, - - // Automatically restore mock state and implementation before every test - // restoreMocks: false, - - // The root directory that Jest should scan for tests and modules within - // rootDir: undefined, - - // A list of paths to directories that Jest should use to search for files in - // roots: [ - // "" - // ], - - // Allows you to use a custom runner instead of Jest's default test runner - // runner: "jest-runner", - - // The paths to modules that run some code to configure or set up the testing environment before each test - // setupFiles: ['/jest.setup.ts'], - - // A list of paths to modules that run some code to configure or set up the testing framework before each test - // setupFilesAfterEnv: [], - - // The number of seconds after which a test is considered as slow and reported as such in the results. - // slowTestThreshold: 5, - - // A list of paths to snapshot serializer modules Jest should use for snapshot testing - // snapshotSerializers: [], - - // The test environment that will be used for testing - // testEnvironment: 'node', - - // Options that will be passed to the testEnvironment - // testEnvironmentOptions: {}, - - // Adds a location field to test results - // testLocationInResults: false, - - // The glob patterns Jest uses to detect test files - // testMatch: [ - // "**/__tests__/**/*.[jt]s?(x)", - // "**/?(*.)+(spec|test).[tj]s?(x)" - // ], - - // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - // testPathIgnorePatterns: [ - // "/node_modules/" - // ], - - // The regexp pattern or array of patterns that Jest uses to detect test files - // testRegex: [], - - // This option allows the use of a custom results processor - // testResultsProcessor: undefined, - - // This option allows use of a custom test runner - // testRunner: "jest-circus/runner", - - // A map from regular expressions to paths to transformers - // transform: { - // '^.+\\.(ts|tsx)$': 'ts-jest', - // }, - - // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation - // transformIgnorePatterns: [ - // "/node_modules/", - // "\\.pnp\\.[^\\/]+$" - // ], - - // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them - // unmockedModulePathPatterns: undefined, - // Indicates whether each individual test should be reported during the run verbose: true, - // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode - // watchPathIgnorePatterns: [], - - // Whether to use watchman for file crawling - // watchman: true, - // Optionally, add these for better TypeScript support extensionsToTreatAsEsm: ['.ts'], }; From ff50e18d78cfe7da6babe7a596d12c92de42a674 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 3 Dec 2024 16:05:12 +0100 Subject: [PATCH 07/19] Didn't mean to add this --- src/authkit-provider.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/authkit-provider.tsx b/src/authkit-provider.tsx index 4b34000..444f5b9 100644 --- a/src/authkit-provider.tsx +++ b/src/authkit-provider.tsx @@ -19,7 +19,6 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP return; } - // We'll use this flag to prevent multiple calls to the checkSessionAction let visibilityChangedCalled = false; const handleVisibilityChange = async () => { From 77393b9c5e88b40d4cb696d1614e7ea3a236fbb7 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 3 Dec 2024 16:22:50 +0100 Subject: [PATCH 08/19] Add jest config and setup scripts to ts exclude --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index fee4ee6..0a07773 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,5 @@ "moduleResolution": "node", "allowSyntheticDefaultImports": true }, - "exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"] + "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "jest.config.ts", "jest.setup.ts"] } From 33559b009787c295323d373312c0daa635e4996b Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 3 Dec 2024 16:27:40 +0100 Subject: [PATCH 09/19] Impersonation shouldn't be a client component for now --- src/impersonation.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/impersonation.tsx b/src/impersonation.tsx index f29b1da..614f66c 100644 --- a/src/impersonation.tsx +++ b/src/impersonation.tsx @@ -1,5 +1,3 @@ -'use client'; - import * as React from 'react'; import { withAuth } from './session.js'; import { workos } from './workos.js'; From 72f1c2e08ed9f3ec332df73da0ab485877297258 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Wed, 4 Dec 2024 12:46:36 +0100 Subject: [PATCH 10/19] 100% test coverage --- __tests__/authkit-callback-route.spec.ts | 14 +++ __tests__/min-max-button.spec.tsx | 13 +++ __tests__/session.spec.ts | 37 ++++++- __tests__/utils.spec.ts | 132 +++++++++++++++++++++++ __tests__/workos.spec.ts | 66 ++++++++++++ jest.config.ts | 9 ++ src/authkit-callback-route.ts | 25 +---- src/session.ts | 12 +-- src/utils.ts | 20 ++++ tsconfig.json | 4 +- 10 files changed, 301 insertions(+), 31 deletions(-) create mode 100644 __tests__/utils.spec.ts create mode 100644 __tests__/workos.spec.ts create mode 100644 src/utils.ts diff --git a/__tests__/authkit-callback-route.spec.ts b/__tests__/authkit-callback-route.spec.ts index 3360210..f074643 100644 --- a/__tests__/authkit-callback-route.spec.ts +++ b/__tests__/authkit-callback-route.spec.ts @@ -78,6 +78,20 @@ describe('authkit-callback-route', () => { expect(data.error.message).toBe('Something went wrong'); }); + it('should handle authentication failure if a non-Error object is thrown', async () => { + // Mock authentication failure + (workos.userManagement.authenticateWithCode as jest.Mock).mockRejectedValue('Auth failed'); + + request.nextUrl.searchParams.set('code', 'invalid-code'); + + const handler = handleAuth(); + const response = await handler(request); + + expect(response.status).toBe(500); + const data = await response.json(); + expect(data.error.message).toBe('Something went wrong'); + }); + it('should handle missing code parameter', async () => { const handler = handleAuth(); const response = await handler(request); diff --git a/__tests__/min-max-button.spec.tsx b/__tests__/min-max-button.spec.tsx index 0c304f3..8628e2e 100644 --- a/__tests__/min-max-button.spec.tsx +++ b/__tests__/min-max-button.spec.tsx @@ -26,6 +26,19 @@ describe('MinMaxButton', () => { expect(root).toHaveStyle({ '--wi-minimized': '1' }); }); + it('does nothing if root is undefined', () => { + const { getByRole } = render(Minimize); + + const root = document.querySelector('[data-workos-impersonation-root]'); + + // Mock querySelector to return null for this test + jest.spyOn(document, 'querySelector').mockReturnValue(null); + + const button = getByRole('button'); + fireEvent.click(button); + expect(root).not.toHaveStyle({ '--wi-minimized': '1' }); + }); + it('renders children correctly', () => { const { getByText } = render(Test Child); diff --git a/__tests__/session.spec.ts b/__tests__/session.spec.ts index a55c543..7616119 100644 --- a/__tests__/session.spec.ts +++ b/__tests__/session.spec.ts @@ -58,11 +58,14 @@ describe('session.ts', () => { (jwtVerify as jest.Mock).mockReset(); - consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); + consoleLogSpy = jest.spyOn(console, 'log').mockImplementation((...args) => { + console.info(...args); + }); }); afterEach(() => { consoleLogSpy.mockRestore(); + jest.resetModules(); }); describe('withAuth', () => { @@ -392,6 +395,38 @@ describe('session.ts', () => { }).rejects.toThrow(); }); + it('should throw an error if the provided regex is invalid and a non-Error object is thrown', async () => { + // Reset modules to ensure clean import state + jest.resetModules(); + + // Import first, then spy + const pathToRegexp = await import('path-to-regexp'); + const parseSpy = jest.spyOn(pathToRegexp, 'parse').mockImplementation(() => { + throw 'invalid regex'; + }); + + // Import session after setting up the spy + const { updateSession } = await import('../src/session.js'); + + const request = new NextRequest(new URL('http://example.com/invalid-regex')); + + await expect(async () => { + await updateSession( + request, + false, + { + enabled: true, + unauthenticatedPaths: ['[*'], + }, + process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI as string, + [], + ); + }).rejects.toThrow('Error parsing routes for middleware auth. Reason: invalid regex'); + + // Verify the mock was called + expect(parseSpy).toHaveBeenCalled(); + }); + it('should default to the WORKOS_REDIRECT_URI environment variable if no redirect URI is provided', async () => { const request = new NextRequest(new URL('http://example.com/protected')); const result = await updateSession( diff --git a/__tests__/utils.spec.ts b/__tests__/utils.spec.ts new file mode 100644 index 0000000..e54687f --- /dev/null +++ b/__tests__/utils.spec.ts @@ -0,0 +1,132 @@ +import { NextResponse } from 'next/server'; +import { redirectWithFallback, errorResponseWithFallback } from '../src/utils.js'; + +describe('utils', () => { + afterEach(() => { + jest.resetModules(); + }); + + describe('redirectWithFallback', () => { + it('uses NextResponse.redirect when available', () => { + const redirectUrl = 'https://example.com'; + const mockRedirect = jest.fn().mockReturnValue('redirected'); + const originalRedirect = NextResponse.redirect; + + NextResponse.redirect = mockRedirect; + + const result = redirectWithFallback(redirectUrl); + + expect(mockRedirect).toHaveBeenCalledWith(redirectUrl); + expect(result).toBe('redirected'); + + NextResponse.redirect = originalRedirect; + }); + + it('falls back to standard Response when NextResponse exists but redirect is undefined', async () => { + const redirectUrl = 'https://example.com'; + + jest.resetModules(); + + jest.mock('next/server', () => ({ + NextResponse: { + // exists but has no redirect method + }, + })); + + const { redirectWithFallback } = await import('../src/utils.js'); + + const result = redirectWithFallback(redirectUrl); + + expect(result).toBeInstanceOf(Response); + expect(result.status).toBe(307); + expect(result.headers.get('Location')).toBe(redirectUrl); + }); + + it('falls back to standard Response when NextResponse is undefined', async () => { + const redirectUrl = 'https://example.com'; + + jest.resetModules(); + + // Mock with undefined NextResponse + jest.mock('next/server', () => ({ + NextResponse: undefined, + })); + + const { redirectWithFallback } = await import('../src/utils.js'); + + const result = redirectWithFallback(redirectUrl); + + expect(result).toBeInstanceOf(Response); + expect(result.status).toBe(307); + expect(result.headers.get('Location')).toBe(redirectUrl); + }); + }); + + describe('errorResponseWithFallback', () => { + const errorBody = { + error: { + message: 'Test error', + description: 'Test description', + }, + }; + + it('uses NextResponse.json when available', () => { + const mockJson = jest.fn().mockReturnValue('error json response'); + NextResponse.json = mockJson; + + const result = errorResponseWithFallback(errorBody); + + expect(mockJson).toHaveBeenCalledWith(errorBody, { status: 500 }); + expect(result).toBe('error json response'); + }); + + it('falls back to standard Response when NextResponse is not available', () => { + const originalJson = NextResponse.json; + + // @ts-expect-error - This is to test the fallback + delete NextResponse.json; + + const result = errorResponseWithFallback(errorBody); + + expect(result).toBeInstanceOf(Response); + expect(result.status).toBe(500); + expect(result.headers.get('Content-Type')).toBe('application/json'); + + NextResponse.json = originalJson; + }); + + it('falls back to standard Response when NextResponse exists but json is undefined', async () => { + jest.resetModules(); + + jest.mock('next/server', () => ({ + NextResponse: { + // exists but has no json method + }, + })); + + const { errorResponseWithFallback } = await import('../src/utils.js'); + + const result = errorResponseWithFallback(errorBody); + + expect(result).toBeInstanceOf(Response); + expect(result.status).toBe(500); + expect(result.headers.get('Content-Type')).toBe('application/json'); + }); + + it('falls back to standard Response when NextResponse is undefined', async () => { + jest.resetModules(); + + jest.mock('next/server', () => ({ + NextResponse: undefined, + })); + + const { errorResponseWithFallback } = await import('../src/utils.js'); + + const result = errorResponseWithFallback(errorBody); + + expect(result).toBeInstanceOf(Response); + expect(result.status).toBe(500); + expect(result.headers.get('Content-Type')).toBe('application/json'); + }); + }); +}); diff --git a/__tests__/workos.spec.ts b/__tests__/workos.spec.ts new file mode 100644 index 0000000..26a1db0 --- /dev/null +++ b/__tests__/workos.spec.ts @@ -0,0 +1,66 @@ +import { WorkOS } from '@workos-inc/node'; +import { workos, VERSION } from '../src/workos.js'; + +describe('workos', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('initializes WorkOS with the correct configuration', () => { + // Extracting the config to avoid a circular dependency error + const workosConfig = { + apiHostname: workos.options.apiHostname, + https: workos.options.https, + port: workos.options.port, + appInfo: workos.options.appInfo, + }; + + expect(workosConfig).toEqual({ + apiHostname: undefined, + https: true, + port: undefined, + appInfo: { + name: 'authkit/nextjs', + version: VERSION, + }, + }); + }); + + it('exports a WorkOS instance', () => { + expect(workos).toBeInstanceOf(WorkOS); + }); + + describe('with custom environment variables', () => { + const originalEnv = process.env; + + beforeEach(() => { + jest.resetModules(); + process.env = { ...originalEnv }; + }); + + afterEach(() => { + process.env = originalEnv; + }); + + it('uses custom API hostname when provided', async () => { + process.env.WORKOS_API_HOSTNAME = 'custom.workos.com'; + const { workos: customWorkos } = await import('../src/workos.js'); + + expect(customWorkos.options.apiHostname).toEqual('custom.workos.com'); + }); + + it('uses custom HTTPS setting when provided', async () => { + process.env.WORKOS_API_HTTPS = 'false'; + const { workos: customWorkos } = await import('../src/workos.js'); + + expect(customWorkos.options.https).toEqual(false); + }); + + it('uses custom port when provided', async () => { + process.env.WORKOS_API_PORT = '8080'; + const { workos: customWorkos } = await import('../src/workos.js'); + + expect(customWorkos.options.port).toEqual(8080); + }); + }); +}); diff --git a/jest.config.ts b/jest.config.ts index a5a0f5e..7629368 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -53,6 +53,15 @@ const config: Config = { // Optionally, add these for better TypeScript support extensionsToTreatAsEsm: ['.ts'], + + coverageThreshold: { + global: { + branches: 100, + functions: 100, + lines: 100, + statements: 100, + }, + }, }; export default config; diff --git a/src/authkit-callback-route.ts b/src/authkit-callback-route.ts index 9747729..6817114 100644 --- a/src/authkit-callback-route.ts +++ b/src/authkit-callback-route.ts @@ -1,8 +1,9 @@ -import { NextRequest, NextResponse } from 'next/server'; +import { NextRequest } from 'next/server'; import { cookies } from 'next/headers'; import { workos } from './workos.js'; import { WORKOS_CLIENT_ID, WORKOS_COOKIE_NAME } from './env-variables.js'; import { encryptSession } from './session.js'; +import { errorResponseWithFallback, redirectWithFallback } from './utils.js'; import { getCookieOptions } from './cookie.js'; import { HandleAuthOptions } from './interfaces.js'; @@ -58,14 +59,7 @@ export function handleAuth(options: HandleAuthOptions = {}) { // Fall back to standard Response if NextResponse is not available. // This is to support Next.js 13. - const response = NextResponse?.redirect - ? NextResponse.redirect(url) - : new Response(null, { - status: 302, - headers: { - Location: url.toString(), - }, - }); + const response = redirectWithFallback(url.toString()); if (!accessToken || !refreshToken) throw new Error('response is missing tokens'); @@ -93,20 +87,11 @@ export function handleAuth(options: HandleAuthOptions = {}) { }; function errorResponse() { - const errorBody = { + return errorResponseWithFallback({ error: { message: 'Something went wrong', description: "Couldn't sign in. If you are not sure what happened, please contact your organization admin.", }, - }; - - // Use NextResponse if available, fallback to standard Response - // This is to support Next.js 13. - return NextResponse?.json - ? NextResponse.json(errorBody, { status: 500 }) - : new Response(JSON.stringify(errorBody), { - status: 500, - headers: { 'Content-Type': 'application/json' }, - }); + }); } } diff --git a/src/session.ts b/src/session.ts index b482667..4bc6945 100644 --- a/src/session.ts +++ b/src/session.ts @@ -12,6 +12,7 @@ import { getAuthorizationUrl } from './get-authorization-url.js'; import { AccessToken, AuthkitMiddlewareAuth, NoUserInfo, Session, UserInfo } from './interfaces.js'; import { parse, tokensToRegexp } from 'path-to-regexp'; +import { redirectWithFallback } from './utils.js'; const sessionHeaderName = 'x-workos-session'; const middlewareHeaderName = 'x-workos-middleware'; @@ -90,7 +91,7 @@ async function updateSession( const redirectTo = await getAuthorizationUrl({ returnPathname: getReturnPathname(request.url), - redirectUri: redirectUri ?? WORKOS_REDIRECT_URI, + redirectUri: redirectUri, screenHint: getScreenHint(signUpPaths, request.nextUrl.pathname), }); @@ -235,6 +236,7 @@ function getMiddlewareAuthPathRegex(pathGlob: string) { return new RegExp(regex); } catch (err) { + console.log('err', err); const message = err instanceof Error ? err.message : String(err); throw new Error(`Error parsing routes for middleware auth. Reason: ${message}`); @@ -390,12 +392,4 @@ function getScreenHint(signUpPaths: string[] | undefined, pathname: string) { return screenHintPaths.length > 0 ? 'sign-up' : 'sign-in'; } -function redirectWithFallback(redirectUri: string) { - // Fall back to standard Response if NextResponse is not available. - // This is to support Next.js 13. - return NextResponse?.redirect - ? NextResponse.redirect(redirectUri) - : new Response(null, { status: 307, headers: { Location: redirectUri } }); -} - export { encryptSession, withAuth, refreshSession, terminateSession, updateSession, getSession }; diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..d3c1a89 --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,20 @@ +import { NextResponse } from 'next/server'; + +export function redirectWithFallback(redirectUri: string) { + // Fall back to standard Response if NextResponse is not available. + // This is to support Next.js 13. + return NextResponse?.redirect + ? NextResponse.redirect(redirectUri) + : new Response(null, { status: 307, headers: { Location: redirectUri } }); +} + +export function errorResponseWithFallback(errorBody: { error: { message: string; description: string } }) { + // Fall back to standard Response if NextResponse is not available. + // This is to support Next.js 13. + return NextResponse?.json + ? NextResponse.json(errorBody, { status: 500 }) + : new Response(JSON.stringify(errorBody), { + status: 500, + headers: { 'Content-Type': 'application/json' }, + }); +} diff --git a/tsconfig.json b/tsconfig.json index 0a07773..8595c61 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,9 @@ "outDir": "./dist/esm", "module": "ES2020", "moduleResolution": "node", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "declarationDir": "./dist/types" }, "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "jest.config.ts", "jest.setup.ts"] } + From 27a5a1e9ed437621fa8d1b496b886ef575cfc04c Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Wed, 4 Dec 2024 12:54:37 +0100 Subject: [PATCH 11/19] Add debug flag --- .github/workflows/ci.yml | 2 +- __tests__/session.spec.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f61e658..cbdf229 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,4 +41,4 @@ jobs: - name: Test run: | - npm run test + npm run test -- --coverage diff --git a/__tests__/session.spec.ts b/__tests__/session.spec.ts index 7616119..344d43e 100644 --- a/__tests__/session.spec.ts +++ b/__tests__/session.spec.ts @@ -17,6 +17,9 @@ jest.mock('jose', () => ({ decodeJwt: jest.requireActual('jose').decodeJwt, })); +// logging is disabled by default, flip this to true to still have logs in the console +const DEBUG = false; + describe('session.ts', () => { const mockSession = { accessToken: 'access-token', @@ -59,7 +62,9 @@ describe('session.ts', () => { (jwtVerify as jest.Mock).mockReset(); consoleLogSpy = jest.spyOn(console, 'log').mockImplementation((...args) => { - console.info(...args); + if (DEBUG) { + console.info(...args); + } }); }); From 3b568af785737d5fa24b8c374a6e3dd40306f52e Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Wed, 4 Dec 2024 13:30:03 +0100 Subject: [PATCH 12/19] Add another test and change coverage engine to have local and github show the same results --- jest.config.ts | 2 +- src/session.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jest.config.ts b/jest.config.ts index 7629368..4ee2e00 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -11,7 +11,7 @@ const config: Config = { coverageDirectory: 'coverage', // Indicates which provider should be used to instrument code for coverage - coverageProvider: 'v8', + coverageProvider: 'babel', // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module moduleNameMapper: { diff --git a/src/session.ts b/src/session.ts index 4bc6945..31ccb5a 100644 --- a/src/session.ts +++ b/src/session.ts @@ -167,6 +167,8 @@ async function refreshSession(options: { organizationId?: string; ensureSignedIn?: boolean; }): Promise; + +/* istanbul ignore next */ async function refreshSession({ organizationId: nextOrganizationId, ensureSignedIn = false, From 05abae46ce48620e4d7940c80c98162b6268b046 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Wed, 4 Dec 2024 13:33:11 +0100 Subject: [PATCH 13/19] Should actually add the test --- __tests__/get-authorization-url.spec.ts | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 __tests__/get-authorization-url.spec.ts diff --git a/__tests__/get-authorization-url.spec.ts b/__tests__/get-authorization-url.spec.ts new file mode 100644 index 0000000..c2193f6 --- /dev/null +++ b/__tests__/get-authorization-url.spec.ts @@ -0,0 +1,37 @@ +import { describe, it, expect, beforeEach, jest } from '@jest/globals'; +import { getAuthorizationUrl } from '../src/get-authorization-url.js'; +import { headers } from 'next/headers'; +import { workos } from '../src/workos.js'; + +jest.mock('next/headers'); +jest.mock('../src/workos.js'); + +describe('getAuthorizationUrl', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('uses x-redirect-uri header when redirectUri option is not provided', async () => { + const nextHeaders = await headers(); + nextHeaders.set('x-redirect-uri', 'http://test-redirect.com'); + + // Mock workos.userManagement.getAuthorizationUrl + jest.mocked(workos.userManagement.getAuthorizationUrl).mockReturnValue('mock-url'); + + await getAuthorizationUrl({}); + + expect(workos.userManagement.getAuthorizationUrl).toHaveBeenCalledWith( + expect.objectContaining({ + redirectUri: 'http://test-redirect.com', + }), + ); + }); + + it('works when called with no arguments', async () => { + jest.mocked(workos.userManagement.getAuthorizationUrl).mockReturnValue('mock-url'); + + await getAuthorizationUrl(); // Call with no arguments + + expect(workos.userManagement.getAuthorizationUrl).toHaveBeenCalled(); + }); +}); From b18937581f1336a5b88e9405a252dc3f2d7f6f59 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 10 Dec 2024 13:40:59 +0100 Subject: [PATCH 14/19] Restructured components, added provider hooks --- README.md | 37 ++++- __tests__/authkit-provider.spec.tsx | 2 +- __tests__/button.spec.tsx | 2 +- __tests__/impersonation.spec.tsx | 2 +- __tests__/min-max-button.spec.tsx | 2 +- package.json | 12 +- src/actions.ts | 20 +++ src/authkit-provider.tsx | 66 --------- src/components/authkit-provider.tsx | 182 ++++++++++++++++++++++++ src/{ => components}/button.tsx | 0 src/{ => components}/impersonation.tsx | 21 ++- src/components/index.ts | 4 + src/{ => components}/min-max-button.tsx | 0 src/index.ts | 5 - src/interfaces.ts | 1 + src/session.ts | 3 +- tsconfig.json | 4 +- 17 files changed, 270 insertions(+), 93 deletions(-) delete mode 100644 src/authkit-provider.tsx create mode 100644 src/components/authkit-provider.tsx rename src/{ => components}/button.tsx (100%) rename src/{ => components}/impersonation.tsx (88%) create mode 100644 src/components/index.ts rename src/{ => components}/min-max-button.tsx (100%) diff --git a/README.md b/README.md index ed19004..6cfa4c5 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,10 @@ Custom redirect URIs will be used over a redirect URI configured in the environm ### Wrap your app in `AuthKitProvider` -Use `AuthKitProvider` to wrap your app layout, which adds some protections for auth edge cases. +Use `AuthKitProvider` to wrap your app layout, which provides client side auth methods adds protections for auth edge cases. ```jsx -import { AuthKitProvider } from '@workos-inc/authkit-nextjs'; +import { AuthKitProvider } from '@workos-inc/authkit-nextjs/components'; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( @@ -148,7 +148,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) } ``` -### Get the current user +### Get the current user in a server component For pages where you want to display a signed-in and signed-out view, use `withAuth` to retrieve the user profile from WorkOS. @@ -189,12 +189,35 @@ export default async function HomePage() { } ``` +### Get the current user in a client component + +For client components, use the `useAuth` hook to get the current user session. + +```jsx +// Note the updated import path +import { useAuth } from '@workos-inc/authkit-nextjs/components'; + +export default function MyComponent() { + const { user, loading } = useAuth(); + + if (loading) { + return
Loading...
; + } + + return
{user?.firstName}
; +} +``` + ### Requiring auth For pages where a signed-in user is mandatory, you can use the `ensureSignedIn` option: ```jsx +// Server component const { user } = await withAuth({ ensureSignedIn: true }); + +// Client component +const { user, loading } = useAuth({ ensureSignedIn: true }); ``` Enabling `ensureSignedIn` will redirect users to AuthKit if they attempt to access the page without being authenticated. @@ -256,13 +279,15 @@ Render the `Impersonation` component in your app so that it is clear when someon The component will display a frame with some information about the impersonated user, as well as a button to stop impersonating. ```jsx -import { Impersonation } from '@workos-inc/authkit-nextjs'; +import { Impersonation, AuthKitProvider } from '@workos-inc/authkit-nextjs/components'; export default function App() { return (
- - {/* Your app content */} + + + {/* Your app content */} +
); } diff --git a/__tests__/authkit-provider.spec.tsx b/__tests__/authkit-provider.spec.tsx index f77830b..084155f 100644 --- a/__tests__/authkit-provider.spec.tsx +++ b/__tests__/authkit-provider.spec.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { render, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { AuthKitProvider } from '../src/authkit-provider.js'; +import { AuthKitProvider } from '../src/components/authkit-provider.js'; import { checkSessionAction } from '../src/actions.js'; jest.mock('../src/actions', () => ({ diff --git a/__tests__/button.spec.tsx b/__tests__/button.spec.tsx index 1db8da2..0c40ce7 100644 --- a/__tests__/button.spec.tsx +++ b/__tests__/button.spec.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { Button } from '../src/button.js'; +import { Button } from '../src/components/button.js'; describe('Button', () => { it('should render with default props', () => { diff --git a/__tests__/impersonation.spec.tsx b/__tests__/impersonation.spec.tsx index 7bc1521..808943d 100644 --- a/__tests__/impersonation.spec.tsx +++ b/__tests__/impersonation.spec.tsx @@ -1,6 +1,6 @@ import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { Impersonation } from '../src/impersonation.js'; +import { Impersonation } from '../src/components/impersonation.js'; import { withAuth } from '../src/session.js'; import { workos } from '../src/workos.js'; diff --git a/__tests__/min-max-button.spec.tsx b/__tests__/min-max-button.spec.tsx index 8628e2e..d60ea47 100644 --- a/__tests__/min-max-button.spec.tsx +++ b/__tests__/min-max-button.spec.tsx @@ -1,5 +1,5 @@ import { render, fireEvent } from '@testing-library/react'; -import { MinMaxButton } from '../src/min-max-button.js'; +import { MinMaxButton } from '../src/components/min-max-button.js'; import * as React from 'react'; import '@testing-library/jest-dom'; diff --git a/package.json b/package.json index 7cc77a5..36c844d 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,23 @@ "sideEffects": false, "type": "module", "main": "./dist/esm/index.js", - "types": "./dist/esm/index.d.ts", + "types": "./dist/esm/types/index.d.ts", "files": [ "dist", "src", "LICENSE", "README.md" ], + "exports": { + "./components": { + "types": "./dist/esm/types/components/index.d.ts", + "import": "./dist/esm/components/index.js" + }, + ".": { + "types": "./dist/esm/types/index.d.ts", + "import": "./dist/esm/index.js" + } + }, "scripts": { "clean": "rm -rf dist", "prebuild": "npm run clean", diff --git a/src/actions.ts b/src/actions.ts index af32585..1c6f5be 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,6 +1,8 @@ 'use server'; import { signOut } from './auth.js'; +import { refreshSession, withAuth } from './session.js'; +import { workos } from './workos.js'; /** * This action is only accessible to authenticated users, @@ -14,3 +16,21 @@ export const checkSessionAction = async () => { export const handleSignOutAction = async () => { await signOut(); }; + +export const getOrganizationAction = async (organizationId: string) => { + return await workos.organizations.getOrganization(organizationId); +}; + +export const getAuthAction = async (ensureSignedIn?: boolean) => { + return await withAuth({ ensureSignedIn: ensureSignedIn as false }); +}; + +export const refreshAuthAction = async ({ + ensureSignedIn, + organizationId, +}: { + ensureSignedIn?: boolean; + organizationId?: string; +}) => { + return await refreshSession({ ensureSignedIn, organizationId }); +}; diff --git a/src/authkit-provider.tsx b/src/authkit-provider.tsx deleted file mode 100644 index 444f5b9..0000000 --- a/src/authkit-provider.tsx +++ /dev/null @@ -1,66 +0,0 @@ -'use client'; - -import * as React from 'react'; -import { checkSessionAction } from './actions.js'; - -interface AuthKitProviderProps { - children: React.ReactNode; - /** - * Customize what happens when a session is expired. By default,the entire page will be reloaded. - * You can also pass this as `false` to disable the expired session checks. - */ - onSessionExpired?: false | (() => void); -} - -export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderProps) => { - React.useEffect(() => { - // Return early if the session expired checks are disabled. - if (onSessionExpired === false) { - return; - } - - let visibilityChangedCalled = false; - - const handleVisibilityChange = async () => { - if (visibilityChangedCalled) { - return; - } - - // In the case where we're using middleware auth mode, a user that has signed out in a different tab - // will run into an issue if they attempt to hit a server action in the original tab. - // This will force a refresh of the page in that case, which will redirect them to the sign-in page. - if (document.visibilityState === 'visible') { - visibilityChangedCalled = true; - - try { - const hasSession = await checkSessionAction(); - if (!hasSession) { - throw new Error('Session expired'); - } - } catch (error) { - // 'Failed to fetch' is the error we are looking for if the action fails - // If any other error happens, for other reasons, we should not reload the page - if (error instanceof Error && error.message.includes('Failed to fetch')) { - if (onSessionExpired) { - onSessionExpired(); - } else { - window.location.reload(); - } - } - } finally { - visibilityChangedCalled = false; - } - } - }; - - window.addEventListener('visibilitychange', handleVisibilityChange); - window.addEventListener('focus', handleVisibilityChange); - - return () => { - window.removeEventListener('focus', handleVisibilityChange); - window.removeEventListener('visibilitychange', handleVisibilityChange); - }; - }, [onSessionExpired]); - - return <>{children}; -}; diff --git a/src/components/authkit-provider.tsx b/src/components/authkit-provider.tsx new file mode 100644 index 0000000..466545b --- /dev/null +++ b/src/components/authkit-provider.tsx @@ -0,0 +1,182 @@ +'use client'; + +import React, { createContext, ReactNode, useContext, useEffect, useState } from 'react'; +import { checkSessionAction, getAuthAction, refreshAuthAction } from '../actions.js'; +import type { Impersonator, OauthTokens, User } from '@workos-inc/node'; + +type AuthContextType = { + user: User | null; + sessionId: string | undefined; + organizationId: string | undefined; + role: string | undefined; + permissions: string[] | undefined; + entitlements: string[] | undefined; + impersonator: Impersonator | undefined; + oauthTokens: OauthTokens | undefined; + accessToken: string | undefined; + loading: boolean; + getAuth: (options?: { ensureSignedIn?: boolean }) => Promise; + refreshAuth: (options?: { ensureSignedIn?: boolean; organizationId?: string }) => Promise; +}; + +const AuthContext = createContext(undefined); + +interface AuthKitProviderProps { + children: ReactNode; + /** + * Customize what happens when a session is expired. By default,the entire page will be reloaded. + * You can also pass this as `false` to disable the expired session checks. + */ + onSessionExpired?: false | (() => void); +} + +export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderProps) => { + const [user, setUser] = useState(null); + const [sessionId, setSessionId] = useState(undefined); + const [organizationId, setOrganizationId] = useState(undefined); + const [role, setRole] = useState(undefined); + const [permissions, setPermissions] = useState(undefined); + const [entitlements, setEntitlements] = useState(undefined); + const [impersonator, setImpersonator] = useState(undefined); + const [oauthTokens, setOauthTokens] = useState(undefined); + const [accessToken, setAccessToken] = useState(undefined); + const [loading, setLoading] = useState(true); + + const getAuth = async ({ ensureSignedIn = false }: { ensureSignedIn?: boolean } = {}) => { + try { + const auth = await getAuthAction(ensureSignedIn); + setUser(auth.user); + setSessionId(auth.sessionId); + setOrganizationId(auth.organizationId); + setRole(auth.role); + setPermissions(auth.permissions); + setEntitlements(auth.entitlements); + setImpersonator(auth.impersonator); + setOauthTokens(auth.oauthTokens); + setAccessToken(auth.accessToken); + } catch (error) { + setUser(null); + } finally { + setLoading(false); + } + }; + + const refreshAuth = async ({ + ensureSignedIn = false, + organizationId, + }: { ensureSignedIn?: boolean; organizationId?: string } = {}) => { + try { + setLoading(true); + const auth = await refreshAuthAction({ ensureSignedIn, organizationId }); + setUser(auth.user); + setSessionId(auth.sessionId); + setOrganizationId(auth.organizationId); + setRole(auth.role); + setPermissions(auth.permissions); + setEntitlements(auth.entitlements); + setImpersonator(auth.impersonator); + setOauthTokens(auth.oauthTokens); + setAccessToken(auth.accessToken); + } catch (error) { + setUser(null); + setSessionId(undefined); + setOrganizationId(undefined); + setRole(undefined); + setPermissions(undefined); + setEntitlements(undefined); + setImpersonator(undefined); + setOauthTokens(undefined); + setAccessToken(undefined); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + getAuth(); + + // Return early if the session expired checks are disabled. + if (onSessionExpired === false) { + return; + } + + let visibilityChangedCalled = false; + + const handleVisibilityChange = async () => { + if (visibilityChangedCalled) { + return; + } + + // In the case where we're using middleware auth mode, a user that has signed out in a different tab + // will run into an issue if they attempt to hit a server action in the original tab. + // This will force a refresh of the page in that case, which will redirect them to the sign-in page. + if (document.visibilityState === 'visible') { + visibilityChangedCalled = true; + + try { + const hasSession = await checkSessionAction(); + if (!hasSession) { + throw new Error('Session expired'); + } + } catch (error) { + // 'Failed to fetch' is the error we are looking for if the action fails + // If any other error happens, for other reasons, we should not reload the page + if (error instanceof Error && error.message.includes('Failed to fetch')) { + if (onSessionExpired) { + onSessionExpired(); + } else { + window.location.reload(); + } + } + } finally { + visibilityChangedCalled = false; + } + } + }; + + window.addEventListener('visibilitychange', handleVisibilityChange); + window.addEventListener('focus', handleVisibilityChange); + + return () => { + window.removeEventListener('focus', handleVisibilityChange); + window.removeEventListener('visibilitychange', handleVisibilityChange); + }; + }, [onSessionExpired]); + + return ( + + {children} + + ); +}; + +export function useAuth() { + const context = useContext(AuthContext); + if (!context) { + throw new Error('useAuth must be used within an AuthKitProvider'); + } + return context; +} + +export function refreshAuth() { + const context = useContext(AuthContext); + if (!context) { + throw new Error('refreshAuth must be used within an AuthKitProvider'); + } + return context; +} diff --git a/src/button.tsx b/src/components/button.tsx similarity index 100% rename from src/button.tsx rename to src/components/button.tsx diff --git a/src/impersonation.tsx b/src/components/impersonation.tsx similarity index 88% rename from src/impersonation.tsx rename to src/components/impersonation.tsx index 614f66c..6edf1bd 100644 --- a/src/impersonation.tsx +++ b/src/components/impersonation.tsx @@ -1,20 +1,27 @@ +'use client'; + import * as React from 'react'; -import { withAuth } from './session.js'; -import { workos } from './workos.js'; import { Button } from './button.js'; import { MinMaxButton } from './min-max-button.js'; -import { handleSignOutAction } from './actions.js'; +import { getOrganizationAction, handleSignOutAction } from '../actions.js'; +import type { Organization } from '@workos-inc/node'; +import { useAuth } from './authkit-provider.js'; interface ImpersonationProps extends React.ComponentPropsWithoutRef<'div'> { side?: 'top' | 'bottom'; } -export async function Impersonation({ side = 'bottom', ...props }: ImpersonationProps) { - const { impersonator, user, organizationId } = await withAuth(); +export function Impersonation({ side = 'bottom', ...props }: ImpersonationProps) { + const { user, impersonator, organizationId, loading } = useAuth(); + + const [organization, setOrganization] = React.useState(null); - if (!impersonator) return null; + React.useEffect(() => { + if (!organizationId) return; + getOrganizationAction(organizationId).then(setOrganization); + }, [organizationId]); - const organization = organizationId ? await workos.organizations.getOrganization(organizationId) : null; + if (loading || !impersonator || !user) return null; return (
; -// @ts-expect-error - TS complains about the overload signature when we have more than 2 optional properties async function withAuth(options: { ensureSignedIn: true }): Promise; -async function withAuth({ ensureSignedIn = false } = {}) { +async function withAuth({ ensureSignedIn = false } = {}): Promise { const session = await getSessionFromHeader(); if (!session) { diff --git a/tsconfig.json b/tsconfig.json index 8595c61..d41140b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,11 +12,11 @@ "alwaysStrict": true, "skipLibCheck": true, "outDir": "./dist/esm", + "declarationDir": "./dist/esm/types", "module": "ES2020", "moduleResolution": "node", "allowSyntheticDefaultImports": true, - "declarationDir": "./dist/types" }, - "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "jest.config.ts", "jest.setup.ts"] + "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "jest.config.ts", "jest.setup.ts", "/dist/**/*"] } From 0bc25b25c8da8cfeab8af40e64d6290f629cec8c Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 10 Dec 2024 14:37:14 +0100 Subject: [PATCH 15/19] Update readme and make sure refreshAuth works as expected --- README.md | 52 +++++++++++++++++++++++++---- src/components/authkit-provider.tsx | 9 +---- src/components/index.ts | 4 +-- src/session.ts | 19 ++++++++--- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6cfa4c5..06e1db4 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) ### Get the current user in a server component -For pages where you want to display a signed-in and signed-out view, use `withAuth` to retrieve the user profile from WorkOS. +For pages where you want to display a signed-in and signed-out view, use `withAuth` to retrieve the user session from WorkOS. ```jsx import Link from 'next/link'; @@ -198,6 +198,7 @@ For client components, use the `useAuth` hook to get the current user session. import { useAuth } from '@workos-inc/authkit-nextjs/components'; export default function MyComponent() { + // Retrieves the user from the session or returns `null` if no user is signed in const { user, loading } = useAuth(); if (loading) { @@ -222,6 +223,45 @@ const { user, loading } = useAuth({ ensureSignedIn: true }); Enabling `ensureSignedIn` will redirect users to AuthKit if they attempt to access the page without being authenticated. +### Refreshing the session + +Use the `refreshSession` method in a server action or route handler to fetch the latest session details, including any changes to the user's roles or permissions. + +The `organizationId` parameter can be passed to `refreshSession` in order to switch the session to a different organization. If the current session is not authorized for the next organization, an appropriate [authentication error](https://workos.com/docs/reference/user-management/authentication-errors) will be returned. + +In client components, you can refresh the session with the `refreshAuth` hook. + +```tsx +'use client'; + +import { useAuth } from '@workos-inc/authkit-nextjs/components'; +import React, { useEffect } from 'react'; + +export function SwitchOrganizationButton() { + const { user, organizationId, loading, refreshAuth } = useAuth(); + + useEffect(() => { + // This will log out the new organizationId after refreshing the session + console.log('organizationId', organizationId); + }, [organizationId]); + + if (loading) { + return
Loading...
; + } + + const handleRefreshSession = async () => { + // Provide the organizationId to switch to + await refreshAuth({ organizationId: 'org_123' }); + }; + + if (user) { + return ; + } else { + return
Not signed in
; + } +} +``` + ### Middleware auth The default behavior of this library is to request authentication via the `withAuth` method on a per-page basis. There are some use cases where you don't want to call `withAuth` (e.g. you don't need user data for your page) or if you'd prefer a "secure by default" approach where every route defined in your middleware matcher is protected unless specified otherwise. In those cases you can opt-in to use middleware auth instead: @@ -317,12 +357,6 @@ export default async function HomePage() { } ``` -### Refreshing the session - -Use the `refreshSession` method in a server action or route handler to fetch the latest session details, including any changes to the user's roles or permissions. - -The `organizationId` parameter can be passed to `refreshSession` in order to switch the session to a different organization. If the current session is not authorized for the next organization, an appropriate [authentication error](https://workos.com/docs/reference/user-management/authentication-errors) will be returned. - ### Sign up paths The `signUpPaths` option can be passed to `authkitMiddleware` to specify paths that should use the 'sign-up' screen hint when redirecting to AuthKit. This is useful for cases where you want a path that mandates authentication to be treated as a sign up page. @@ -350,3 +384,7 @@ export default authkitMiddleware({ debug: true }); #### NEXT_REDIRECT error when using try/catch blocks Wrapping a `withAuth({ ensureSignedIn: true })` call in a try/catch block will cause a `NEXT_REDIRECT` error. This is because `withAuth` will attempt to redirect the user to AuthKit if no session is detected and redirects in Next must be [called outside a try/catch](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#redirecting). + +#### Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme). + +You may encounter this error if you attempt to import server side code from authkit-nextjs into a client component. Likely you are using `withAuth` in a client component instead of the `useAuth` hook. Either move the code to a server component or use the `useAuth` hook. diff --git a/src/components/authkit-provider.tsx b/src/components/authkit-provider.tsx index 466545b..41e1f8e 100644 --- a/src/components/authkit-provider.tsx +++ b/src/components/authkit-provider.tsx @@ -68,6 +68,7 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP try { setLoading(true); const auth = await refreshAuthAction({ ensureSignedIn, organizationId }); + setUser(auth.user); setSessionId(auth.sessionId); setOrganizationId(auth.organizationId); @@ -172,11 +173,3 @@ export function useAuth() { } return context; } - -export function refreshAuth() { - const context = useContext(AuthContext); - if (!context) { - throw new Error('refreshAuth must be used within an AuthKitProvider'); - } - return context; -} diff --git a/src/components/index.ts b/src/components/index.ts index c0016f3..6f6aeb5 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,4 +1,4 @@ import { Impersonation } from './impersonation.js'; -import { AuthKitProvider, useAuth, refreshAuth } from './authkit-provider.js'; +import { AuthKitProvider, useAuth } from './authkit-provider.js'; -export { Impersonation, AuthKitProvider, useAuth, refreshAuth }; +export { Impersonation, AuthKitProvider, useAuth }; diff --git a/src/session.ts b/src/session.ts index 96cd963..e680bbe 100644 --- a/src/session.ts +++ b/src/session.ts @@ -186,12 +186,21 @@ async function refreshSession({ const { org_id: organizationIdFromAccessToken } = decodeJwt(session.accessToken); - const { accessToken, refreshToken, user, impersonator } = await workos.userManagement.authenticateWithRefreshToken({ - clientId: WORKOS_CLIENT_ID, - refreshToken: session.refreshToken, - organizationId: nextOrganizationId ?? organizationIdFromAccessToken, - }); + let refreshResult; + + try { + refreshResult = await workos.userManagement.authenticateWithRefreshToken({ + clientId: WORKOS_CLIENT_ID, + refreshToken: session.refreshToken, + organizationId: nextOrganizationId ?? organizationIdFromAccessToken, + }); + } catch (error) { + throw new Error(`Failed to refresh session: ${error instanceof Error ? error.message : String(error)}`, { + cause: error, + }); + } + const { accessToken, refreshToken, user, impersonator } = refreshResult; // Encrypt session with new access and refresh tokens const encryptedSession = await encryptSession({ accessToken, From 363685dcd278ba07abc550a7a815521518c7471e Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 10 Dec 2024 15:49:49 +0100 Subject: [PATCH 16/19] Tests --- README.md | 9 +- __tests__/actions.spec.ts | 49 +++++- __tests__/authkit-provider.spec.tsx | 243 +++++++++++++++++++++++++--- __tests__/impersonation.spec.tsx | 91 +++++++---- __tests__/session.spec.ts | 11 ++ src/components/authkit-provider.tsx | 20 +-- src/session.ts | 2 +- 7 files changed, 351 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 06e1db4..4ce43cf 100644 --- a/README.md +++ b/README.md @@ -250,8 +250,13 @@ export function SwitchOrganizationButton() { } const handleRefreshSession = async () => { - // Provide the organizationId to switch to - await refreshAuth({ organizationId: 'org_123' }); + const result = await refreshAuth({ + // Provide the organizationId to switch to + organizationId: 'org_123', + }); + if (result?.error) { + console.log('Error refreshing session:', result.error); + } }; if (user) { diff --git a/__tests__/actions.spec.ts b/__tests__/actions.spec.ts index 976d2e7..404757d 100644 --- a/__tests__/actions.spec.ts +++ b/__tests__/actions.spec.ts @@ -1,10 +1,31 @@ -import { checkSessionAction, handleSignOutAction } from '../src/actions.js'; +import { + checkSessionAction, + handleSignOutAction, + getOrganizationAction, + getAuthAction, + refreshAuthAction, +} from '../src/actions.js'; import { signOut } from '../src/auth.js'; +import { workos } from '../src/workos.js'; +import { withAuth, refreshSession } from '../src/session.js'; jest.mock('../src/auth.js', () => ({ signOut: jest.fn().mockResolvedValue(true), })); +jest.mock('../src/workos.js', () => ({ + workos: { + organizations: { + getOrganization: jest.fn().mockResolvedValue({ id: 'org_123', name: 'Test Org' }), + }, + }, +})); + +jest.mock('../src/session.js', () => ({ + withAuth: jest.fn().mockResolvedValue({ user: 'testUser' }), + refreshSession: jest.fn().mockResolvedValue({ session: 'newSession' }), +})); + describe('actions', () => { describe('checkSessionAction', () => { it('should return true for authenticated users', async () => { @@ -19,4 +40,30 @@ describe('actions', () => { expect(signOut).toHaveBeenCalled(); }); }); + + describe('getOrganizationAction', () => { + it('should return organization details', async () => { + const organizationId = 'org_123'; + const result = await getOrganizationAction(organizationId); + expect(workos.organizations.getOrganization).toHaveBeenCalledWith(organizationId); + expect(result).toEqual({ id: 'org_123', name: 'Test Org' }); + }); + }); + + describe('getAuthAction', () => { + it('should return auth details', async () => { + const result = await getAuthAction(); + expect(withAuth).toHaveBeenCalled(); + expect(result).toEqual({ user: 'testUser' }); + }); + }); + + describe('refreshAuthAction', () => { + it('should refresh session', async () => { + const params = { ensureSignedIn: true, organizationId: 'org_123' }; + const result = await refreshAuthAction(params); + expect(refreshSession).toHaveBeenCalledWith(params); + expect(result).toEqual({ session: 'newSession' }); + }); + }); }); diff --git a/__tests__/authkit-provider.spec.tsx b/__tests__/authkit-provider.spec.tsx index 084155f..5175072 100644 --- a/__tests__/authkit-provider.spec.tsx +++ b/__tests__/authkit-provider.spec.tsx @@ -1,11 +1,13 @@ import React from 'react'; -import { render, waitFor } from '@testing-library/react'; +import { render, waitFor, act } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { AuthKitProvider } from '../src/components/authkit-provider.js'; -import { checkSessionAction } from '../src/actions.js'; +import { AuthKitProvider, useAuth } from '../src/components/authkit-provider.js'; +import { checkSessionAction, getAuthAction, refreshAuthAction } from '../src/actions.js'; jest.mock('../src/actions', () => ({ checkSessionAction: jest.fn(), + getAuthAction: jest.fn(), + refreshAuthAction: jest.fn(), })); describe('AuthKitProvider', () => { @@ -13,12 +15,14 @@ describe('AuthKitProvider', () => { jest.clearAllMocks(); }); - it('should render children', () => { - const { getByText } = render( - -
Test Child
-
, - ); + it('should render children', async () => { + const { getByText } = await act(async () => { + return render( + +
Test Child
+
, + ); + }); expect(getByText('Test Child')).toBeInTheDocument(); }); @@ -26,11 +30,13 @@ describe('AuthKitProvider', () => { it('should do nothing if onSessionExpired is false', async () => { jest.spyOn(window, 'addEventListener'); - render( - -
Test Child
-
, - ); + await act(async () => { + render( + +
Test Child
+
, + ); + }); // expect window to not have an event listener expect(window.addEventListener).not.toHaveBeenCalled(); @@ -46,8 +52,10 @@ describe('AuthKitProvider', () => { , ); - // Simulate visibility change - window.dispatchEvent(new Event('visibilitychange')); + act(() => { + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + }); await waitFor(() => { expect(onSessionExpired).toHaveBeenCalled(); @@ -64,9 +72,11 @@ describe('AuthKitProvider', () => { , ); - // Simulate visibility change twice - window.dispatchEvent(new Event('visibilitychange')); - window.dispatchEvent(new Event('visibilitychange')); + act(() => { + // Simulate visibility change twice + window.dispatchEvent(new Event('visibilitychange')); + window.dispatchEvent(new Event('visibilitychange')); + }); await waitFor(() => { expect(onSessionExpired).toHaveBeenCalledTimes(1); @@ -84,8 +94,10 @@ describe('AuthKitProvider', () => { , ); - // Simulate visibility change - window.dispatchEvent(new Event('visibilitychange')); + act(() => { + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + }); await waitFor(() => { expect(onSessionExpired).not.toHaveBeenCalled(); @@ -108,8 +120,10 @@ describe('AuthKitProvider', () => { , ); - // Simulate visibility change - window.dispatchEvent(new Event('visibilitychange')); + act(() => { + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + }); await waitFor(() => { expect(window.location.reload).toHaveBeenCalled(); @@ -136,8 +150,10 @@ describe('AuthKitProvider', () => { , ); - // Simulate visibility change - window.dispatchEvent(new Event('visibilitychange')); + act(() => { + // Simulate visibility change + window.dispatchEvent(new Event('visibilitychange')); + }); await waitFor(() => { expect(onSessionExpired).not.toHaveBeenCalled(); @@ -147,3 +163,180 @@ describe('AuthKitProvider', () => { window.location = originalLocation; }); }); + +describe('useAuth', () => { + it('should throw error when used outside of AuthKitProvider', () => { + const TestComponent = () => { + const auth = useAuth(); + return
{auth.user?.email}
; + }; + + // Suppress console.error for this test since we expect an error + const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + expect(() => { + render(); + }).toThrow('useAuth must be used within an AuthKitProvider'); + + consoleSpy.mockRestore(); + }); + + it('should provide auth context values when used within AuthKitProvider', async () => { + (getAuthAction as jest.Mock).mockResolvedValueOnce({ + user: { email: 'test@example.com' }, + sessionId: 'test-session', + organizationId: 'test-org', + role: 'admin', + permissions: ['read', 'write'], + entitlements: ['feature1'], + impersonator: { email: 'admin@example.com' }, + oauthTokens: { access_token: 'token123' }, + accessToken: 'access123', + }); + + const TestComponent = () => { + const auth = useAuth(); + return ( +
+
{auth.loading.toString()}
+
{auth.user?.email}
+
{auth.sessionId}
+
{auth.organizationId}
+
+ ); + }; + + const { getByTestId } = render( + + + , + ); + + // Initially loading + expect(getByTestId('loading')).toHaveTextContent('true'); + + // Wait for auth to load + await waitFor(() => { + expect(getByTestId('loading')).toHaveTextContent('false'); + expect(getByTestId('email')).toHaveTextContent('test@example.com'); + expect(getByTestId('session')).toHaveTextContent('test-session'); + expect(getByTestId('org')).toHaveTextContent('test-org'); + }); + }); + + it('should handle auth methods (getAuth and refreshAuth)', async () => { + const mockAuth = { + user: { email: 'test@example.com' }, + sessionId: 'test-session', + }; + + (getAuthAction as jest.Mock).mockResolvedValueOnce(mockAuth); + (refreshAuthAction as jest.Mock).mockResolvedValueOnce({ + ...mockAuth, + sessionId: 'new-session', + }); + + const TestComponent = () => { + const auth = useAuth(); + return ( +
+
{auth.sessionId}
+ +
+ ); + }; + + const { getByTestId, getByRole } = render( + + + , + ); + + await waitFor(() => { + expect(getByTestId('session')).toHaveTextContent('test-session'); + }); + + // Test refresh + act(() => { + getByRole('button').click(); + }); + + await waitFor(() => { + expect(getByTestId('session')).toHaveTextContent('new-session'); + }); + }); + + it('should receive an error when refreshAuth fails with an error', async () => { + (refreshAuthAction as jest.Mock).mockRejectedValueOnce(new Error('Refresh failed')); + + let error: string | undefined; + + const TestComponent = () => { + const auth = useAuth(); + return ( +
+
{auth.sessionId}
+ +
+ ); + }; + + const { getByRole } = render( + + + , + ); + + act(() => { + getByRole('button').click(); + }); + + await waitFor(() => { + expect(error).toBe('Refresh failed'); + }); + }); + + it('should receive an error when refreshAuth fails with an errstringor', async () => { + (refreshAuthAction as jest.Mock).mockRejectedValueOnce('Refresh failed'); + + let error: string | undefined; + + const TestComponent = () => { + const auth = useAuth(); + return ( +
+
{auth.sessionId}
+ +
+ ); + }; + + const { getByRole } = render( + + + , + ); + + act(() => { + getByRole('button').click(); + }); + + await waitFor(() => { + expect(error).toBe('Refresh failed'); + }); + }); +}); diff --git a/__tests__/impersonation.spec.tsx b/__tests__/impersonation.spec.tsx index 808943d..382da78 100644 --- a/__tests__/impersonation.spec.tsx +++ b/__tests__/impersonation.spec.tsx @@ -1,19 +1,19 @@ -import { render } from '@testing-library/react'; +import { render, act } from '@testing-library/react'; import '@testing-library/jest-dom'; import { Impersonation } from '../src/components/impersonation.js'; -import { withAuth } from '../src/session.js'; -import { workos } from '../src/workos.js'; +import { useAuth } from '../src/components/authkit-provider.js'; +import { getOrganizationAction } from '../src/actions.js'; +import * as React from 'react'; -jest.mock('../src/session', () => ({ - withAuth: jest.fn(), +// Mock the useAuth hook +jest.mock('../src/components/authkit-provider', () => ({ + useAuth: jest.fn(), })); -jest.mock('../src/workos', () => ({ - workos: { - organizations: { - getOrganization: jest.fn(), - }, - }, +// Mock the getOrganizationAction +jest.mock('../src/actions', () => ({ + getOrganizationAction: jest.fn(), + handleSignOutAction: jest.fn(), })); describe('Impersonation', () => { @@ -21,77 +21,98 @@ describe('Impersonation', () => { jest.clearAllMocks(); }); - it('should return null if not impersonating', async () => { - (withAuth as jest.Mock).mockResolvedValue({ + it('should return null if not impersonating', () => { + (useAuth as jest.Mock).mockReturnValue({ impersonator: null, - user: { id: '123' }, + user: { id: '123', email: 'user@example.com' }, organizationId: null, + loading: false, }); - const { container } = await render(await Impersonation({})); + const { container } = render(); expect(container).toBeEmptyDOMElement(); }); - it('should render impersonation banner when impersonating', async () => { - (withAuth as jest.Mock).mockResolvedValue({ + it('should return null if loading', () => { + (useAuth as jest.Mock).mockReturnValue({ impersonator: { email: 'admin@example.com' }, - user: { id: '123' }, + user: { id: '123', email: 'user@example.com' }, organizationId: null, + loading: true, }); - const { container } = await render(await Impersonation({})); + const { container } = render(); + expect(container).toBeEmptyDOMElement(); + }); + + it('should render impersonation banner when impersonating', () => { + (useAuth as jest.Mock).mockReturnValue({ + impersonator: { email: 'admin@example.com' }, + user: { id: '123', email: 'user@example.com' }, + organizationId: null, + loading: false, + }); + + const { container } = render(); expect(container.querySelector('[data-workos-impersonation-root]')).toBeInTheDocument(); }); it('should render with organization info when organizationId is provided', async () => { - (withAuth as jest.Mock).mockResolvedValue({ + (useAuth as jest.Mock).mockReturnValue({ impersonator: { email: 'admin@example.com' }, - user: { id: '123' }, + user: { id: '123', email: 'user@example.com' }, organizationId: 'org_123', + loading: false, }); - (workos.organizations.getOrganization as jest.Mock).mockResolvedValue({ + (getOrganizationAction as jest.Mock).mockResolvedValue({ id: 'org_123', name: 'Test Org', }); - const { container } = await render(await Impersonation({})); + const { container } = await act(async () => { + return render(); + }); + expect(container.querySelector('[data-workos-impersonation-root]')).toBeInTheDocument(); }); - it('should render at the bottom by default', async () => { - (withAuth as jest.Mock).mockResolvedValue({ + it('should render at the bottom by default', () => { + (useAuth as jest.Mock).mockReturnValue({ impersonator: { email: 'admin@example.com' }, - user: { id: '123' }, + user: { id: '123', email: 'user@example.com' }, organizationId: null, + loading: false, }); - const { container } = await render(await Impersonation({})); + const { container } = render(); const banner = container.querySelector('[data-workos-impersonation-root] > div:nth-child(2)'); expect(banner).toHaveStyle({ bottom: 'var(--wi-s)' }); }); - it('should render at the top when side prop is "top"', async () => { - (withAuth as jest.Mock).mockResolvedValue({ + it('should render at the top when side prop is "top"', () => { + (useAuth as jest.Mock).mockReturnValue({ impersonator: { email: 'admin@example.com' }, - user: { id: '123' }, + user: { id: '123', email: 'user@example.com' }, organizationId: null, + loading: false, }); - const { container } = await render(await Impersonation({ side: 'top' })); + const { container } = render(); const banner = container.querySelector('[data-workos-impersonation-root] > div:nth-child(2)'); expect(banner).toHaveStyle({ top: 'var(--wi-s)' }); }); - it('should merge custom styles with default styles', async () => { - (withAuth as jest.Mock).mockResolvedValue({ + it('should merge custom styles with default styles', () => { + (useAuth as jest.Mock).mockReturnValue({ impersonator: { email: 'admin@example.com' }, - user: { id: '123' }, + user: { id: '123', email: 'user@example.com' }, organizationId: null, + loading: false, }); const customStyle = { backgroundColor: 'red' }; - const { container } = await render(await Impersonation({ style: customStyle })); + const { container } = render(); const root = container.querySelector('[data-workos-impersonation-root]'); expect(root).toHaveStyle({ backgroundColor: 'red' }); }); diff --git a/__tests__/session.spec.ts b/__tests__/session.spec.ts index 344d43e..62f0058 100644 --- a/__tests__/session.spec.ts +++ b/__tests__/session.spec.ts @@ -116,6 +116,17 @@ describe('session.ts', () => { ); }); + it('should throw an error if the route is not covered by the middleware and there is no URL in the headers', async () => { + const nextHeaders = await headers(); + nextHeaders.delete('x-workos-middleware'); + + await expect(async () => { + await withAuth({ ensureSignedIn: true }); + }).rejects.toThrow( + "You are calling 'withAuth' on a route that isn’t covered by the AuthKit middleware. Make sure it is running on all paths you are calling 'withAuth' from by updating your middleware config in 'middleware.(js|ts)'.", + ); + }); + it('should throw an error if the URL is not found in the headers', async () => { const nextHeaders = await headers(); nextHeaders.delete('x-url'); diff --git a/src/components/authkit-provider.tsx b/src/components/authkit-provider.tsx index 41e1f8e..d46d8db 100644 --- a/src/components/authkit-provider.tsx +++ b/src/components/authkit-provider.tsx @@ -16,7 +16,7 @@ type AuthContextType = { accessToken: string | undefined; loading: boolean; getAuth: (options?: { ensureSignedIn?: boolean }) => Promise; - refreshAuth: (options?: { ensureSignedIn?: boolean; organizationId?: string }) => Promise; + refreshAuth: (options?: { ensureSignedIn?: boolean; organizationId?: string }) => Promise; }; const AuthContext = createContext(undefined); @@ -56,6 +56,14 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP setAccessToken(auth.accessToken); } catch (error) { setUser(null); + setSessionId(undefined); + setOrganizationId(undefined); + setRole(undefined); + setPermissions(undefined); + setEntitlements(undefined); + setImpersonator(undefined); + setOauthTokens(undefined); + setAccessToken(undefined); } finally { setLoading(false); } @@ -79,15 +87,7 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP setOauthTokens(auth.oauthTokens); setAccessToken(auth.accessToken); } catch (error) { - setUser(null); - setSessionId(undefined); - setOrganizationId(undefined); - setRole(undefined); - setPermissions(undefined); - setEntitlements(undefined); - setImpersonator(undefined); - setOauthTokens(undefined); - setAccessToken(undefined); + return error instanceof Error ? { error: error.message } : { error: String(error) }; } finally { setLoading(false); } diff --git a/src/session.ts b/src/session.ts index e680bbe..230fbf6 100644 --- a/src/session.ts +++ b/src/session.ts @@ -375,7 +375,7 @@ async function getSessionFromHeader(): Promise { if (!hasMiddleware) { const url = headersList.get('x-url'); throw new Error( - `You are calling 'withAuth' on ${url} that isn’t covered by the AuthKit middleware. Make sure it is running on all paths you are calling 'withAuth' from by updating your middleware config in 'middleware.(js|ts)'.`, + `You are calling 'withAuth' on ${url ?? 'a route'} that isn’t covered by the AuthKit middleware. Make sure it is running on all paths you are calling 'withAuth' from by updating your middleware config in 'middleware.(js|ts)'.`, ); } From b636c4c5c8b66c394164a19d8b0bed3f74c17b4d Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Tue, 10 Dec 2024 16:21:50 +0100 Subject: [PATCH 17/19] Fix coverage --- src/env-variables.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/env-variables.ts b/src/env-variables.ts index 58536b1..e161f9a 100644 --- a/src/env-variables.ts +++ b/src/env-variables.ts @@ -1,15 +1,20 @@ +/* istanbul ignore file */ + function getEnvVariable(name: string): string | undefined { return process.env[name]; } +// Optional env variables const WORKOS_API_HOSTNAME = getEnvVariable('WORKOS_API_HOSTNAME'); const WORKOS_API_HTTPS = getEnvVariable('WORKOS_API_HTTPS'); -const WORKOS_API_KEY = getEnvVariable('WORKOS_API_KEY') ?? ''; const WORKOS_API_PORT = getEnvVariable('WORKOS_API_PORT'); -const WORKOS_CLIENT_ID = getEnvVariable('WORKOS_CLIENT_ID') ?? ''; const WORKOS_COOKIE_DOMAIN = getEnvVariable('WORKOS_COOKIE_DOMAIN'); const WORKOS_COOKIE_MAX_AGE = getEnvVariable('WORKOS_COOKIE_MAX_AGE'); const WORKOS_COOKIE_NAME = getEnvVariable('WORKOS_COOKIE_NAME'); + +// Required env variables +const WORKOS_API_KEY = getEnvVariable('WORKOS_API_KEY') ?? ''; +const WORKOS_CLIENT_ID = getEnvVariable('WORKOS_CLIENT_ID') ?? ''; const WORKOS_COOKIE_PASSWORD = getEnvVariable('WORKOS_COOKIE_PASSWORD') ?? ''; const WORKOS_REDIRECT_URI = process.env.NEXT_PUBLIC_WORKOS_REDIRECT_URI ?? ''; From e6cacb7fe34e351882c6a56c381b101810fd2263 Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Fri, 27 Dec 2024 17:44:20 +0200 Subject: [PATCH 18/19] Remove oauthTokens from provider --- src/actions.ts | 6 ------ src/components/authkit-provider.tsx | 8 +------- src/components/impersonation.tsx | 8 -------- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/actions.ts b/src/actions.ts index 35ca599..1c6f5be 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,11 +1,8 @@ 'use server'; import { signOut } from './auth.js'; -<<<<<<< HEAD import { refreshSession, withAuth } from './session.js'; import { workos } from './workos.js'; -======= ->>>>>>> main /** * This action is only accessible to authenticated users, @@ -19,7 +16,6 @@ export const checkSessionAction = async () => { export const handleSignOutAction = async () => { await signOut(); }; -<<<<<<< HEAD export const getOrganizationAction = async (organizationId: string) => { return await workos.organizations.getOrganization(organizationId); @@ -38,5 +34,3 @@ export const refreshAuthAction = async ({ }) => { return await refreshSession({ ensureSignedIn, organizationId }); }; -======= ->>>>>>> main diff --git a/src/components/authkit-provider.tsx b/src/components/authkit-provider.tsx index d46d8db..b61f7f4 100644 --- a/src/components/authkit-provider.tsx +++ b/src/components/authkit-provider.tsx @@ -2,7 +2,7 @@ import React, { createContext, ReactNode, useContext, useEffect, useState } from 'react'; import { checkSessionAction, getAuthAction, refreshAuthAction } from '../actions.js'; -import type { Impersonator, OauthTokens, User } from '@workos-inc/node'; +import type { Impersonator, User } from '@workos-inc/node'; type AuthContextType = { user: User | null; @@ -12,7 +12,6 @@ type AuthContextType = { permissions: string[] | undefined; entitlements: string[] | undefined; impersonator: Impersonator | undefined; - oauthTokens: OauthTokens | undefined; accessToken: string | undefined; loading: boolean; getAuth: (options?: { ensureSignedIn?: boolean }) => Promise; @@ -38,7 +37,6 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP const [permissions, setPermissions] = useState(undefined); const [entitlements, setEntitlements] = useState(undefined); const [impersonator, setImpersonator] = useState(undefined); - const [oauthTokens, setOauthTokens] = useState(undefined); const [accessToken, setAccessToken] = useState(undefined); const [loading, setLoading] = useState(true); @@ -52,7 +50,6 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP setPermissions(auth.permissions); setEntitlements(auth.entitlements); setImpersonator(auth.impersonator); - setOauthTokens(auth.oauthTokens); setAccessToken(auth.accessToken); } catch (error) { setUser(null); @@ -62,7 +59,6 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP setPermissions(undefined); setEntitlements(undefined); setImpersonator(undefined); - setOauthTokens(undefined); setAccessToken(undefined); } finally { setLoading(false); @@ -84,7 +80,6 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP setPermissions(auth.permissions); setEntitlements(auth.entitlements); setImpersonator(auth.impersonator); - setOauthTokens(auth.oauthTokens); setAccessToken(auth.accessToken); } catch (error) { return error instanceof Error ? { error: error.message } : { error: String(error) }; @@ -154,7 +149,6 @@ export const AuthKitProvider = ({ children, onSessionExpired }: AuthKitProviderP permissions, entitlements, impersonator, - oauthTokens, accessToken, loading, getAuth, diff --git a/src/components/impersonation.tsx b/src/components/impersonation.tsx index bd1d43c..6edf1bd 100644 --- a/src/components/impersonation.tsx +++ b/src/components/impersonation.tsx @@ -1,19 +1,11 @@ 'use client'; import * as React from 'react'; -<<<<<<< HEAD:src/components/impersonation.tsx import { Button } from './button.js'; import { MinMaxButton } from './min-max-button.js'; import { getOrganizationAction, handleSignOutAction } from '../actions.js'; import type { Organization } from '@workos-inc/node'; import { useAuth } from './authkit-provider.js'; -======= -import { withAuth } from './session.js'; -import { workos } from './workos.js'; -import { Button } from './button.js'; -import { MinMaxButton } from './min-max-button.js'; -import { handleSignOutAction } from './actions.js'; ->>>>>>> main:src/impersonation.tsx interface ImpersonationProps extends React.ComponentPropsWithoutRef<'div'> { side?: 'top' | 'bottom'; From 05d8294d9e1d3329953c2078cf6436e423adfbcd Mon Sep 17 00:00:00 2001 From: Paul Asjes Date: Fri, 27 Dec 2024 19:46:27 +0200 Subject: [PATCH 19/19] Exclude all test files from build --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index d41140b..b436740 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,6 @@ "moduleResolution": "node", "allowSyntheticDefaultImports": true, }, - "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "jest.config.ts", "jest.setup.ts", "/dist/**/*"] + "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "jest.config.ts", "jest.setup.ts", "/dist/**/*", "__tests__/**/*"] }