diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index aef313ea1..e83416097 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -3,7 +3,7 @@ version: '3.8' services: app: # Use offical typescript-node devcontainer image - image: mcr.microsoft.com/vscode/devcontainers/typescript-node:1-20@sha256:87f45e7d18579ffbe6370697cd77bf921669d0d6d3643eda3920426432fe461a + image: mcr.microsoft.com/vscode/devcontainers/typescript-node:1-20@sha256:6a200731ff2e66af7d342c8118f989822e81ab98c2ad2e5c180fa308d057e395 volumes: - ..:/workspace:cached @@ -20,7 +20,7 @@ services: # (Adding the "ports" property to this file will not forward from a Codespace.) db: - image: postgres:latest@sha256:0cf02e45421b780449f0bab6b4af7e5ab2c37d3ca729e284fcec1a18f3fa9354 + image: postgres:latest@sha256:79c927b43c8bf2fc1e78b7f4badb394237ee0001032324ef015da562e57a5dcd restart: unless-stopped volumes: - postgres-data:/var/lib/postgresql/data diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 72bead132..04a055947 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -9,6 +9,8 @@ module.exports = { 'plugin:nuxt/recommended', // Turns off all rules that are unnecessary or might conflict with Prettier (needs to be last) 'prettier', + // Disable rules covered by oxlint + 'plugin:oxlint/recommended', ], plugins: ['unused-imports'], rules: { diff --git a/.github/scripts/README.md b/.github/scripts/README.md index add105b4a..e2cba50bc 100644 --- a/.github/scripts/README.md +++ b/.github/scripts/README.md @@ -9,6 +9,6 @@ pip install azure-identity azure-mgmt-web azure-mgmt-storage azure-mgmt-applicat az login export SUBSCRIPTION_ID=<...> export DATABASE_URL=<...> -export AZURE_SESSION_SECRET=<...> +export NUXT_SESSION_PASSWORD=<...> python3 .github/scripts/deploy.py --env dev -v ``` diff --git a/.github/scripts/deploy.py b/.github/scripts/deploy.py index d0ad31cad..61607d56f 100644 --- a/.github/scripts/deploy.py +++ b/.github/scripts/deploy.py @@ -36,7 +36,7 @@ def main(environment_name: str, verbose: bool = False): APP_INSIGHTS_NAME = "jabref-online" REDIS_NAME = "jabref" DATABASE_URL = os.environ.get("DATABASE_URL", "") - SESSION_SECRET = os.environ.get("AZURE_SESSION_SECRET", "") + SESSION_SECRET = os.environ.get("NUXT_SESSION_PASSWORD", "") GITHUB_REPO_TOKEN = os.environ.get("GITHUB_REPO_TOKEN", "") function_app_name = "jabref-function-" + environment_name @@ -132,7 +132,7 @@ def main(environment_name: str, verbose: bool = False): "name": "REDIS_PASSWORD", "value": redis_keys.primary_key, }, - {"name": "SESSION_SECRET_PRIMARY", "value": SESSION_SECRET}, + {"name": "NUXT_SESSION_PASSWORD", "value": SESSION_SECRET}, {"name": "GITHUB_REPO_TOKEN", "value": GITHUB_REPO_TOKEN}, # Disable indexing of non-production sites # https://nuxtseo.com/robots/guides/disable-indexing#preview-staging-testing-environments diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be4b3b472..de2b72c4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 @@ -25,7 +25,7 @@ jobs: uses: pnpm/action-setup@v4 - name: Setup Node.js - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: node-version: 20 cache: 'pnpm' @@ -54,7 +54,7 @@ jobs: services: postgres: - image: postgres@sha256:0cf02e45421b780449f0bab6b4af7e5ab2c37d3ca729e284fcec1a18f3fa9354 + image: postgres@sha256:79c927b43c8bf2fc1e78b7f4badb394237ee0001032324ef015da562e57a5dcd env: POSTGRES_PASSWORD: postgres POSTGRES_DB: jabref @@ -68,7 +68,7 @@ jobs: - 5432:5432 redis: - image: redis@sha256:79676a8f74e4aed85b6d6a2f4e4e3e55d8a229baa7168362e592bbfdc67b0c9b + image: redis@sha256:05f99264e2928ad472f2751b3a8d1f65c9c2cc1819be04548b2261c08e2e026b # Set health checks to wait until redis has started options: >- --health-cmd "redis-cli ping" @@ -82,10 +82,11 @@ jobs: env: DATABASE_URL: postgresql://postgres:postgres@localhost:5432/jabref?schema=public GITHUB_REPO_TOKEN: ${{ secrets.GITHUBS_REPO_TOKEN }} + NUXT_SESSION_PASSWORD: somerandompasswordNxFHaqCSPpBe6n5kRz2dru4hJ7K9bjgEtmsV8QAT3MDXcUfWGL steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 @@ -93,7 +94,7 @@ jobs: uses: pnpm/action-setup@v4 - name: Setup Node.js - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: node-version: ${{ matrix.node }} cache: 'pnpm' @@ -125,7 +126,7 @@ jobs: - name: Publish and test Storybook if: always() - uses: chromaui/action@fdbe7756d4dbf493e2fbb822df73be7accd07e1c # v11 + uses: chromaui/action@64a9c0ca3bfb724389b0d536e544f56b7b5ff5b3 # v11 with: projectToken: 'b3787adf2fa5' # Don't wait until Chroma verified the build (for this we have the Github check) @@ -134,6 +135,6 @@ jobs: debug: true - name: Upload coverage to Codecov - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/deploy-preview-close.yml b/.github/workflows/deploy-preview-close.yml index a897ca85e..96a5892f5 100644 --- a/.github/workflows/deploy-preview-close.yml +++ b/.github/workflows/deploy-preview-close.yml @@ -24,7 +24,7 @@ jobs: action: 'close' - name: Login to Azure - uses: Azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2 + uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # v2 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index e0bc20c91..3afda5475 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -25,6 +25,7 @@ jobs: env: PREVIEW_NAME: ${{ github.event.pull_request.number || github.event.inputs.preview_name }} GITHUB_REPO_TOKEN: ${{ secrets.GITHUBS_REPO_TOKEN }} + NUXT_SESSION_PASSWORD: ${{ secrets.AZURE_SESSION_SECRET }} steps: # We could also add these checks to a job-wide if condition, to skip the workflow if its unsecure to run. @@ -34,7 +35,7 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.pull_request.head.sha || github.ref }} @@ -42,7 +43,7 @@ jobs: uses: pnpm/action-setup@v4 - name: Setup Node.js - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: node-version: 20 cache: 'pnpm' @@ -54,7 +55,7 @@ jobs: run: pnpm build:azure - name: Login to Azure - uses: Azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2 + uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # v2 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} @@ -74,7 +75,7 @@ jobs: SWA_CLI_DEPLOYMENT_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PEBBLE_0224C3803 }} - name: Install Python - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 with: python-version: '3.10' @@ -106,7 +107,6 @@ jobs: python .github\scripts\deploy.py --env $env:PREVIEW_NAME env: SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - AZURE_SESSION_SECRET: ${{ secrets.AZURE_SESSION_SECRET }} - name: Deploy Function App run: | diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4149d4b99..2f3ad4bfb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,16 +36,17 @@ jobs: env: DATABASE_URL: ${{ matrix.environment == 'Test' && secrets.AZURE_TEST_DATABASE_URL || secrets.AZURE_DATABASE_URL }} GITHUB_REPO_TOKEN: ${{ secrets.GITHUBS_REPO_TOKEN }} + NUXT_SESSION_PASSWORD: ${{ secrets.AZURE_SESSION_SECRET }} steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install pnpm uses: pnpm/action-setup@v4 - name: Setup Node.js - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: node-version: 20 cache: 'pnpm' @@ -65,7 +66,7 @@ jobs: run: pnpm build:azure - name: Login to Azure - uses: Azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2 + uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # v2 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} @@ -81,7 +82,7 @@ jobs: SWA_CLI_DEPLOYMENT_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PEBBLE_0224C3803 }} - name: Install Python - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 with: python-version: '3.10' @@ -91,7 +92,6 @@ jobs: python .github\scripts\deploy.py --env ${{ matrix.deployment_environment }} env: SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - AZURE_SESSION_SECRET: ${{ secrets.AZURE_SESSION_SECRET }} - name: Deploy Function App run: | diff --git a/.vscode/settings.json b/.vscode/settings.json index 19977e72c..c74739969 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,10 +12,15 @@ "journaltitle", "Nuxt", "nuxtjs", + "oxlint", + "pinia", "scimago", "transpiled", "tsyringe", - "upsert" + "unstorage", + "upsert", + "vite", + "vitest" ], "[jsonc]": { "editor.formatOnSave": true diff --git a/README.md b/README.md index 292da181e..be833f377 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,20 @@ Now close and re-open the workspace. | pnpm prisma:studio | Explore data in the database using a visual editor. | | pnpm storybook | Start [Storybook](#ui-workflow-storybook) in your browser. | +### Running tests locally + +To run the tests locally, it's best to start the development server by running `pnpm dev`. +Then, in a separate terminal, set the environment variable `TEST_URL` to the URL of the development server (e.g., `http://localhost:3000`) + +```bash +# Linux +export TEST_URL=http://localhost:3000 +# Windows +$env:TEST_URL = "http://localhost:3000" +``` + +Then you can run the tests by executing `pnpm test`. + ### Workflow for editing the database schema 1. Prototype your new feature by making the necessary changes to `schema.prisma`. diff --git a/auth.d.ts b/auth.d.ts new file mode 100644 index 000000000..f0b294e64 --- /dev/null +++ b/auth.d.ts @@ -0,0 +1,33 @@ +declare module '#auth-utils' { + /** + * The public information about a user stored in the session + */ + interface User { + id: string + } + + /** + * The public information about the current session + */ + interface UserSession { + /** + * The secure data associated with the session, only accessible on the server + */ + server: ServerSessionData + } + + /** + * Private information about the current session, only accessible on the server + * (exposed in an encrypted form to the client) + */ + interface SecureSessionData {} + + /** + * The data stored for the session on the server + */ + interface ServerSessionData { + lastActive: Date + } +} + +export {} diff --git a/components/JabRefLogo.stories.vue b/components/JabRefLogo.stories.vue index eaa4062f3..076b44dbf 100644 --- a/components/JabRefLogo.stories.vue +++ b/components/JabRefLogo.stories.vue @@ -3,6 +3,7 @@ import JabRefLogo from './JabrefLogo.vue' + diff --git a/components/n-button.stories.vue b/components/n-button.stories.vue index c90b7e7f2..32b09810f 100644 --- a/components/n-button.stories.vue +++ b/components/n-button.stories.vue @@ -2,6 +2,7 @@ import { NButton } from 'naive-ui'