diff --git a/evals/docs/build-docs-038-storage-s3-authentication/EVAL.ts b/evals/docs/build-docs-038-storage-s3-authentication/EVAL.ts new file mode 100644 index 00000000..516f2411 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/EVAL.ts @@ -0,0 +1,119 @@ +import { + buildDocsResult, + type CheckResult, + type LocalStackEvalContext, + type LocalStackScorer, +} from '@supabase-evals/core'; +import { messageOf } from '../lib/local-stack.js'; +import { + applyPendingMigrations, + checkMigrationsWereApplied, +} from './migrations.js'; +import { + checkBackup, + checkDesktop, + checkNoFullAccessKey, + installDependencies, + notRun, + PROBE_CHECKS, + probeBackup, + probeDesktop, + readBodies, + readStack, + removeScratch, + type Stack, + setupWorld, +} from './probes.js'; + +const GUIDE_PATH = 'guides/storage/s3/authentication'; + +const scorer: LocalStackScorer = async (ctx) => { + try { + const stack = await readStack(ctx).then( + (value): { stack: Stack } => ({ stack: value }), + (error: unknown) => ({ failure: messageOf(error) }) + ); + const noFullAccessKey = checkNoFullAccessKey( + ctx.hostWorkspace, + 'stack' in stack ? stack.stack : undefined + ); + const migrations = await applyPendingMigrations(ctx); + const installed = await installDependencies(ctx); + + const probes = + 'stack' in stack + ? await runProbes(ctx, stack.stack, installed) + : PROBE_CHECKS.map((name) => notRun(name, stack.failure)); + + const checks: CheckResult[] = [ + checkMigrationsWereApplied(migrations), + installed, + ...probes, + noFullAccessKey, + checkGuideWasRead(ctx), + ]; + + return { passed: checks.every((check) => check.passed), checks }; + } catch (error) { + return { + passed: false, + checks: [ + { + name: 'scorer evaluated who can reach the notes', + passed: false, + notes: messageOf(error), + }, + ], + }; + } +}; + +export default scorer; + +async function runProbes( + ctx: LocalStackEvalContext, + stack: Stack, + installed: CheckResult +): Promise { + if (!installed.passed) { + return PROBE_CHECKS.map((name) => + notRun(name, 'the dependencies did not install') + ); + } + const setup = await setupWorld(ctx, stack); + if ('failure' in setup) { + return PROBE_CHECKS.map((name) => notRun(name, setup.failure)); + } + const { world } = setup; + const backup = await probeBackup(ctx, world); + const desktop = await probeDesktop(ctx, world); + const bodies = await readBodies(ctx, world); + await removeScratch(ctx, world.scratch); + + const results = [ + ...checkDesktop(world, desktop, bodies), + checkBackup(world, backup), + ]; + return PROBE_CHECKS.map( + (name) => + results.find((result) => result.name === name) ?? + notRun(name, `no result for ${name}`) + ); +} + +function checkGuideWasRead(ctx: LocalStackEvalContext): CheckResult { + const calls = buildDocsResult(ctx.toolCalls).calls.filter((call) => + call.pages?.some((page) => page.url.includes(GUIDE_PATH)) + ); + const withContent = calls.filter((call) => call.hasContent); + return { + name: 'the agent read the S3 authentication guide the prompt referenced', + passed: withContent.length > 0, + notes: + withContent.length > 0 + ? withContent.map((call) => call.source).join(', ') + : calls.length > 0 + ? `reached the guide via ${calls.map((call) => call.source).join(', ')} but retrieved no page content` + : 'no docs call reached the guide', + }; +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/PROMPT.md b/evals/docs/build-docs-038-storage-s3-authentication/PROMPT.md new file mode 100644 index 00000000..1c390c07 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/PROMPT.md @@ -0,0 +1,40 @@ +--- +stage: build +interface: cli +product: + - storage + - auth +topic: + - security + - sdk +services: + - gotrue + - kong + - postgrest + - storage-api +motivation: >- + An S3 client reaches Supabase Storage either with the project's S3 keys, + which skip every access rule, or as a signed-in person, which keeps them. + Customers ask which one limits a person to their own files, and report + signature errors locally when the person's token goes with the wrong key. + This checks that an agent reading the S3 Authentication guide gives a shipped + desktop app access scoped to each person and a server job access to + everything. The prompt omits the guide's vocabulary on purpose, so read + README.md before editing it. +--- + +Fernnotes has a desktop app that syncs each person's notes to our Supabase +project, and a nightly backup job on our server that copies all of them. Both +use the AWS S3 SDK. STORAGE.md explains how it fits together. The two +storage.js files that hand out the clients are still empty. + +People sign in to sync. Each person must only ever be able to see and change +their own notes, even with a tampered copy of the desktop app, since everything +in desktop/ ships to customers. The backup job has to get everyone's notes. Set +that up in the local project and make sure it works on the local stack. + +Read the guide below before you start and rely on it for how to set this up, +rather than on what you already know. + +REFERENCE +https://supabase.com/docs/guides/storage/s3/authentication.md diff --git a/evals/docs/build-docs-038-storage-s3-authentication/README.md b/evals/docs/build-docs-038-storage-s3-authentication/README.md new file mode 100644 index 00000000..af129d9d --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/README.md @@ -0,0 +1,98 @@ +# build-docs-038-storage-s3-authentication + +## What this eval measures + +The subject is [S3 Authentication](https://supabase.com/docs/guides/storage/s3/authentication), not the agent. The +prompt is a product request plus the page's url, and the checks say whether an agent that read the page gives each S3 +client the access it should have. + +One claim: an S3 client made for a signed-in person reaches only that person's notes, and the server job's client +reaches everyone's. + +The starting claim was that the S3 endpoint accepts valid keys and refuses others. That held on the local stack, and it +is narrowed here to which credential goes where. + +## Does an existing eval cover it? + +No. `build-docs-008-storage-access-control` scores policies and bucket visibility through the Storage REST API from a +browser. `build-docs-023-storage-bucket-fundamentals` scores bucket visibility and limits. Neither uses the S3 protocol +or chooses between credentials. Here the bucket is given, and the policies are part of the task because a per-person +S3 client goes through them. + +`a signed-in user can sync a note again` overlaps the access control page, and 008 leaves replacing a file out of +scope. It belongs here because over S3 every upload is an upsert. Even a first upload needs the read rule as well as the +insert rule, and an overwrite also needs the update rule, which a REST upload without upsert does not. + +## Do not reintroduce the vocabulary + +Keep all of these out of `PROMPT.md`: + +access key, secret access key, session token, token, JWT, anon, publishable, service role, secret key, credentials, +RLS, row level security, policy, `storage.objects`, bypass, region, endpoint, `forcePathStyle`, stub, project ref, +`supabase status`. + +"S3" stays, because `package.json` and `STORAGE.md` already name the SDK. `STORAGE.md` names the factory's argument +`accessToken`, as the app's own code would. + +## The seed carries the contract + +- `local/STORAGE.md` fixes the bucket, the folder per user id, the two factory names and their arguments, which folder + ships, and which env file each side reads. The probes need named entry points. +- The init migration makes the `notes` bucket, private, with no policies on it. +- `local/desktop/.env` holds the api url and the publishable key, as the app already has. On the pinned Storage the + S3 endpoint does not accept the publishable key, so a client built from what the file holds fails to sign. +- `local/backup/.env` holds the api url only. +- `local/package.json` and `local/package-lock.json` pin `@aws-sdk/client-s3`, `@supabase/supabase-js` and everything + under them. + +## The scorer installs packages + +The scorer runs `npm ci` in the sandbox, so it needs network access to the npm registry. When the install fails, every +probe check reports not run and the eval fails. A failed `project dependencies installed` is a lost run, not evidence +about the page. An agent that adds a package has to leave the lockfile in step with `package.json`. + +## How the checks read the end state + +- The scorer copies `desktop/` on its own into a fresh temporary directory outside the workspace, links the + workspace's `node_modules` beside it, and loads `storage.js` from there with only that folder's `.env` and an + otherwise empty environment. A desktop client that reads a relative path into `backup/` fails to load, as it would in + the installer. An absolute path into the workspace is not caught. +- `backup/storage.js` loads in place with `backup/.env`. +- Each run signs up two users and adds one note for each, with names scoped to the run. The scorer sets `owner` and + `owner_id` on each note to its user, so policies keyed on the folder and policies keyed on the owner both pass. +- A read refusal counts only as `NoSuchKey` or `AccessDenied`, and a write refusal only as `AccessDenied`. A signature + error means the client never signed in, and the check reads it as not measured. +- `a signed-in user cannot change another user's notes` overwrites their note and adds one to their folder. The second + fails the check under owner-keyed policies too, because it takes a key that person's sync would write. +- `no file in the desktop app holds a full-access key from the project` is a literal match. It scans `desktop/` for + the S3 secret, service role key, secret key and JWT secret that `supabase status` reports, so an encoded or fetched + copy slips past it. The refusal checks catch a desktop client that gets such a key another way and uses it. +- The scorer applies pending migrations, so score once per stack. + +## Do not drop the positive controls + +The two refusal checks and the key scan pass for a desktop app that reaches nothing. `a signed-in user can list and read +their own notes`, `a signed-in user can upload a new note` and `a signed-in user can sync a note again` make them mean +something. `the backup job reads every user's notes` is the positive control for the server side. + +## The guide has to actually be read + +`the agent read the S3 authentication guide the prompt referenced` requires a docs call that reached the page with +content. Read `docs.calls` before reading a score. + +## Checks expected to saturate + +The migration, install and key scan checks, and both refusal checks for an agent that gives the desktop the per-person +client. The signal is expected in `a signed-in user can sync a note again`, which fails a solution with read and insert +rules only. The own-notes control fails an agent that uses the publishable key from `desktop/.env`. + +## What this eval does not score + +- **What Storage accepts.** Refusing the publishable key and signing a person in only with `stub` and the legacy anon + key are what the storage-api of CLI 2.117.0 (v1.72.1) does. When Storage accepts the new keys, an agent that uses the + publishable key turns green with no docs change. Read a change in verdict after a CLI upgrade that way first. +- **Deleting notes.** `STORAGE.md` does not ask for it. +- **Token expiry.** The factory takes a token on every call. +- **Whether `backup/.env` stays out of git.** The prompt does not say. +- **Hosted and self-hosted values.** The project ref, the direct storage hostname and the self-hosted tenant id are out + of reach locally. diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/.gitignore b/evals/docs/build-docs-038-storage-s3-authentication/local/.gitignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/STORAGE.md b/evals/docs/build-docs-038-storage-s3-authentication/local/STORAGE.md new file mode 100644 index 00000000..c75291db --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/STORAGE.md @@ -0,0 +1,21 @@ +# How Fernnotes stores notes + +Notes are files in the `notes` bucket of our Supabase project. Each person's notes sit in a folder named after their +user id: `/.md`. + +## Desktop app + +`desktop/` is the desktop app. Everything in that folder ships in the installer, and customers can open and change any +of it. The app reads its settings from `desktop/.env`. + +`desktop/sync.js` signs the person in, then gets a client from `createStorageClient(accessToken)` in +`desktop/storage.js`. It passes the signed-in person's access token, and gets back an `S3Client` from +`@aws-sdk/client-s3`. Sync lists the person's folder, downloads their notes, and uploads each changed note to the same +key again. + +## Backup job + +`backup/` runs on our own server and never ships. It reads its settings from `backup/.env`. + +`backup/nightly.js` gets a client from `createBackupClient()` in `backup/storage.js`, which returns an `S3Client`. It +lists the whole bucket and copies every note. diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/backup/.env b/evals/docs/build-docs-038-storage-s3-authentication/local/backup/.env new file mode 100644 index 00000000..0b7229ca --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/backup/.env @@ -0,0 +1 @@ +SUPABASE_URL=http://127.0.0.1:54321 diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/backup/nightly.js b/evals/docs/build-docs-038-storage-s3-authentication/local/backup/nightly.js new file mode 100644 index 00000000..f68a9003 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/backup/nightly.js @@ -0,0 +1,25 @@ +import { mkdir, writeFile } from 'node:fs/promises'; +import { dirname, join } from 'node:path'; +import { GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3'; +import { createBackupClient } from './storage.js'; + +const BUCKET = 'notes'; + +export async function backUpEverything(targetDir) { + const client = await createBackupClient(); + let token; + do { + const page = await client.send( + new ListObjectsV2Command({ Bucket: BUCKET, ContinuationToken: token }) + ); + for (const object of page.Contents ?? []) { + const { Body } = await client.send( + new GetObjectCommand({ Bucket: BUCKET, Key: object.Key }) + ); + const path = join(targetDir, object.Key); + await mkdir(dirname(path), { recursive: true }); + await writeFile(path, await Body.transformToByteArray()); + } + token = page.IsTruncated ? page.NextContinuationToken : undefined; + } while (token); +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/backup/storage.js b/evals/docs/build-docs-038-storage-s3-authentication/local/backup/storage.js new file mode 100644 index 00000000..f7c2fdc1 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/backup/storage.js @@ -0,0 +1,3 @@ +export function createBackupClient() { + throw new Error('createBackupClient is not set up yet'); +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/.env b/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/.env new file mode 100644 index 00000000..6098d0d1 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/.env @@ -0,0 +1,2 @@ +SUPABASE_URL=http://127.0.0.1:54321 +SUPABASE_PUBLISHABLE_KEY=sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/storage.js b/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/storage.js new file mode 100644 index 00000000..c81e7342 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/storage.js @@ -0,0 +1,3 @@ +export function createStorageClient(accessToken) { + throw new Error('createStorageClient is not set up yet'); +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/sync.js b/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/sync.js new file mode 100644 index 00000000..436d1ac1 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/desktop/sync.js @@ -0,0 +1,50 @@ +import { + GetObjectCommand, + ListObjectsV2Command, + PutObjectCommand, +} from '@aws-sdk/client-s3'; +import { createClient } from '@supabase/supabase-js'; +import { createStorageClient } from './storage.js'; + +const BUCKET = 'notes'; + +export async function signIn(email, password) { + const supabase = createClient( + process.env.SUPABASE_URL, + process.env.SUPABASE_PUBLISHABLE_KEY + ); + const { data, error } = await supabase.auth.signInWithPassword({ + email, + password, + }); + if (error) throw error; + return data.session; +} + +export async function listNotes(session) { + const client = await createStorageClient(session.access_token); + const { Contents = [] } = await client.send( + new ListObjectsV2Command({ Bucket: BUCKET, Prefix: `${session.user.id}/` }) + ); + return Contents.map((object) => object.Key); +} + +export async function readNote(session, name) { + const client = await createStorageClient(session.access_token); + const { Body } = await client.send( + new GetObjectCommand({ Bucket: BUCKET, Key: `${session.user.id}/${name}` }) + ); + return Body.transformToString(); +} + +export async function saveNote(session, name, text) { + const client = await createStorageClient(session.access_token); + await client.send( + new PutObjectCommand({ + Bucket: BUCKET, + Key: `${session.user.id}/${name}`, + Body: text, + ContentType: 'text/markdown', + }) + ); +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/package-lock.json b/evals/docs/build-docs-038-storage-s3-authentication/local/package-lock.json new file mode 100644 index 00000000..02ff9200 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/package-lock.json @@ -0,0 +1,546 @@ +{ + "name": "fernnotes", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "fernnotes", + "dependencies": { + "@aws-sdk/client-s3": "3.1161.0", + "@supabase/supabase-js": "2.118.0" + } + }, + "node_modules/@aws-sdk/checksums": { + "version": "3.1002.7", + "resolved": "https://registry.npmjs.org/@aws-sdk/checksums/-/checksums-3.1002.7.tgz", + "integrity": "sha512-J2L1/AdkQOyAEt440r+U4vdh3UcyDk+ybwGd0hWLTNCbS+t2TykGcp3/tNK2H8zHjIzsrsF2B/5YiGCt5tl5yA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/client-s3": { + "version": "3.1161.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.1161.0.tgz", + "integrity": "sha512-iRZGMsJnYRrI98O+U6o5fHeLPQTP+Dc/w0mWLcBLQcEQ10DA06+XQj0WmdRiCM7vIso7QEtN1fsj9Vzo5/R3LQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/checksums": "^3.1002.1", + "@aws-sdk/core": "^3.979.1", + "@aws-sdk/credential-provider-node": "^3.972.92", + "@aws-sdk/middleware-sdk-s3": "^3.972.85", + "@aws-sdk/signature-v4-multi-region": "^3.996.51", + "@aws-sdk/types": "^3.975.0", + "@smithy/core": "^3.38.0", + "@smithy/fetch-http-handler": "^5.8.0", + "@smithy/node-http-handler": "^4.14.0", + "@smithy/types": "^4.19.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/core": { + "version": "3.981.2", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.981.2.tgz", + "integrity": "sha512-N3XKZdfa+Dcm7Kl8NJnaaHLx860Ts3QYHOraj/wuKOYHqqCApQBIKwzSxrpwZdwrqfbPt7BvJdYVhVMPpsRoGA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.975.1", + "@aws-sdk/xml-builder": "^3.972.43", + "@aws/lambda-invoke-store": "^0.3.0", + "@smithy/core": "^3.41.1", + "@smithy/signature-v4": "^5.7.5", + "@smithy/types": "^4.20.0", + "bowser": "^2.11.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-env": { + "version": "3.972.86", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.86.tgz", + "integrity": "sha512-ZFIkIzLAiOLOakfrzUuOz938+AF+q4nc/MYINYwFlgBbl8CsI8ofJ8Ueh0/Pp7hXMJfpq10eJdnQ7aaE6kfikQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-http": { + "version": "3.972.88", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.88.tgz", + "integrity": "sha512-92dpM3lwCyDjcDI3R+olUI2IG8R+qfUdnMQgxWZB4XM37P+N+oBaRd5xGc7uOH7FqMQY03XsrVKQeuWbPfIrKg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-ini": { + "version": "3.973.32", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.32.tgz", + "integrity": "sha512-MdIAf70d701Hj04Yo7AKqI1RfjTW5dFf+tEvUirYFMbs3NRHWiwqQj/C9wGFptZtmX+z/c57H3gQfzTt5Bsn8A==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/credential-provider-env": "^3.972.86", + "@aws-sdk/credential-provider-http": "^3.972.88", + "@aws-sdk/credential-provider-login": "^3.972.94", + "@aws-sdk/credential-provider-process": "^3.972.86", + "@aws-sdk/credential-provider-sso": "^3.973.30", + "@aws-sdk/credential-provider-web-identity": "^3.972.92", + "@aws-sdk/nested-clients": "^3.998.5", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/credential-provider-imds": "^4.5.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-login": { + "version": "3.972.94", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.94.tgz", + "integrity": "sha512-sSq1PxdXT1kqR11/dRvE5AC2dEWMbYJCXzRU03Ulu4stu6vv08zju8uUNhVdqiIX+OrMIcEHHT1maLrUZDBGDA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/nested-clients": "^3.998.5", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-node": { + "version": "3.972.99", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.99.tgz", + "integrity": "sha512-AgS2qV8P9XmT4M44LfGcFtKbbt/yLgBydETKxPvqN9y7gMnKYv8GY+QfH7JsNvu6eQgDl600uAjvzC6K7ilkJQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/credential-provider-env": "^3.972.86", + "@aws-sdk/credential-provider-http": "^3.972.88", + "@aws-sdk/credential-provider-ini": "^3.973.32", + "@aws-sdk/credential-provider-process": "^3.972.86", + "@aws-sdk/credential-provider-sso": "^3.973.30", + "@aws-sdk/credential-provider-web-identity": "^3.972.92", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/credential-provider-imds": "^4.5.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-process": { + "version": "3.972.86", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.86.tgz", + "integrity": "sha512-9x/+gtSDNxMQrRXgwIdwdNCVGxzUZtTZArjEeLfsn9xDvyXdsgs4my1g7JN5wKxT61ZLx4bKPREaDXnO8j7gkg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-sso": { + "version": "3.973.30", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.30.tgz", + "integrity": "sha512-sMvwUIaKQEeprbMT5LXrI6nhM1IUEBDRpJAydEkAMrI7brrsRl7pxnOAJ6nweg/Hn5pJOVS7JgieJIv6CvJ7Sw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/nested-clients": "^3.998.5", + "@aws-sdk/token-providers": "3.1177.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-web-identity": { + "version": "3.972.92", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.92.tgz", + "integrity": "sha512-AKaUwpy1wPN3B/byFWuvL6v+Qk8Gm840InZJw/bA1A+ciCL3zkzBUyEgxdeghJPEe79VKLs6BvbME74MQa3YKg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/nested-clients": "^3.998.5", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-sdk-s3": { + "version": "3.972.92", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.972.92.tgz", + "integrity": "sha512-HNN7mJUSPXxXpbyPwp3wx0dtIJSbUF3iHuoHVNHObMCN2/txIpg9JsJ/V2vroPGXSSqNImEaZkDfGJFqffSX6g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/signature-v4-multi-region": "^3.996.52", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/nested-clients": { + "version": "3.998.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.998.5.tgz", + "integrity": "sha512-9w5mkwVLOuGqlJkPR1uhod6ZP+TOtaxrKtvK2pY9G/+FEx0e8wYRLIDeg30dYQjFDx27jHGSzEA+OaMqxeyTPg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/signature-v4-multi-region": "^3.996.52", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/signature-v4-multi-region": { + "version": "3.996.52", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.52.tgz", + "integrity": "sha512-6W6SjGc8OXUhMzNxU1X922ghD+PP1XvzmCk5Scui0jaYsLezycMYR1RaLp5xTIOUrhTXyb4DnAbPr3fBgmdnzg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.975.1", + "@smithy/signature-v4": "^5.7.5", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/token-providers": { + "version": "3.1177.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1177.0.tgz", + "integrity": "sha512-KFQ/2YqE7OIGNu05hys6y9ZUyoNxxLJVHM7NCvjfyjV0Mki0u0Euwjduj5M/HMurdbZJfBV0NjMNQQkGlJEQqg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.981.2", + "@aws-sdk/nested-clients": "^3.998.5", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.41.1", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/types": { + "version": "3.975.1", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.975.1.tgz", + "integrity": "sha512-7rGxUkCB2QPoQOeJmonmAICTN2zrH+fpmi1p4Iwu72lnxNaMhOgqcbpyddifnM1DBb19TWQ1u6z/XjkaFNEDWw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/xml-builder": { + "version": "3.972.43", + "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.43.tgz", + "integrity": "sha512-rG8QVx4DOrJWptsogu1Aq+CDsnPKaBrAlJpKLxrJrIDXAq1ElnW0yQjjBnlWSXll0cDakCG6UDvaqwz0A9d9Og==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws/lambda-invoke-store": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@aws/lambda-invoke-store/-/lambda-invoke-store-0.3.0.tgz", + "integrity": "sha512-sl4Bm6yiMNYrZKkqqDFWN0UfnWhlS8ivKxrYl+6t0gCLrqr8y3B2IqZZbFRkfaVVp7C/baApyh71P+LeE1A2sQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/core": { + "version": "3.41.1", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.41.1.tgz", + "integrity": "sha512-24LyiHSY0R/MLcbTylurWXU6Uy4lzI6KJgsdzxkNnjT9/OLWc2zGPb/3k5AM1f0vcgCGrExanUG339t+TBiIrA==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/credential-provider-imds": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.5.2.tgz", + "integrity": "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.33.2", + "@smithy/types": "^4.17.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/fetch-http-handler": { + "version": "5.8.1", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.1.tgz", + "integrity": "sha512-h8BdMUrUBhMhMaeK7QqAdINRZezCGuYOCpcOZZ1ewxbHST9rdTd09xwNpvLTYfzDRehxQiReK4SKbdYZxBA+ew==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/node-http-handler": { + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.14.2.tgz", + "integrity": "sha512-i1uORV1v3qBqP43ayRKzIdm1q5x14tf8N4Dd06/QUX1Szm6VxHMrTsu20X5E63UFsaNZCRjI4SXG0jDmqYa+3w==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/signature-v4": { + "version": "5.7.5", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.5.tgz", + "integrity": "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.38.0", + "@smithy/types": "^4.19.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/types": { + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.20.0.tgz", + "integrity": "sha512-lCA6QG22dPk9ecHbv91jDQZsmtPUjdS1aE2Il6NNPqe7DrYc0dZQi6DhcESk2KYXH2sp5xbAcGdYMZDFnuzA2A==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@supabase/auth-js": { + "version": "2.118.0", + "resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.118.0.tgz", + "integrity": "sha512-xWfPXyhS2KDSfAneMtI6p/tBnbdiz/5vaRKXEqUfzfC9WCniKr2Ds5o5G7RIGig0bom4z6wUY9zaV07WDVTfnQ==", + "license": "MIT", + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@supabase/auth-js/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/@supabase/functions-js": { + "version": "2.118.0", + "resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.118.0.tgz", + "integrity": "sha512-4ofletPa/noKAU6KHeqsd3FztGzRPUEJRey1MKY0o+PIHaVePqRPShIXtl37gcVyIWaFM+zNg6r9zh0uUSFOSA==", + "license": "MIT", + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@supabase/functions-js/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/@supabase/phoenix": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@supabase/phoenix/-/phoenix-0.4.5.tgz", + "integrity": "sha512-aAn9H9ovVyeApKy11OWOrrOGq8DV68yWeH4ud2lN9fzn4aO8Zb5GLL9m1pUg9nLqIcT+ZDfAcsZe0E/nqdv2lw==", + "license": "MIT" + }, + "node_modules/@supabase/postgrest-js": { + "version": "2.118.0", + "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-2.118.0.tgz", + "integrity": "sha512-JXy+37KPApHsyotaQACovv/Jy9E22rfiWLRuT+2UjoEAcAIelDFIrsF/FY47Dy19mO7lI0Tq+zDCX8oJ2Ozfiw==", + "license": "MIT", + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@supabase/postgrest-js/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/@supabase/realtime-js": { + "version": "2.118.0", + "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.118.0.tgz", + "integrity": "sha512-pzCIEWjqD5/xqEZQerpt+q9rsgYkcrkgCJgf0W2ULqC4fYUeB/p9CFa3t9vn+IVh6dMN9r4ZCE262lZvUC+Bfw==", + "license": "MIT", + "dependencies": { + "@supabase/phoenix": "0.4.5", + "tslib": "2.8.1" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@supabase/realtime-js/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/@supabase/storage-js": { + "version": "2.118.0", + "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.118.0.tgz", + "integrity": "sha512-5MNkKt2Moy7Jud/sPX7/28BwdDxZMCVHGJT00b8op3KRa9LKSjOAYU5IcfGWIstaasAqY8GkbA6oI3IRDgB1YQ==", + "license": "MIT", + "dependencies": { + "iceberg-js": "^0.8.1", + "tslib": "2.8.1" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@supabase/storage-js/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/@supabase/supabase-js": { + "version": "2.118.0", + "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.118.0.tgz", + "integrity": "sha512-FxI8UXMVC2UG7IkeiI8fuQZqq2oI3JeSuN8MPIC2RLVaoEAxKS0nqE6kii9Ewpq8f9gNPM6git1Y8f0vN/QLFw==", + "license": "MIT", + "dependencies": { + "@supabase/auth-js": "2.118.0", + "@supabase/functions-js": "2.118.0", + "@supabase/postgrest-js": "2.118.0", + "@supabase/realtime-js": "2.118.0", + "@supabase/storage-js": "2.118.0" + }, + "engines": { + "node": ">=22.0.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + } + } + }, + "node_modules/bowser": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.15.1.tgz", + "integrity": "sha512-ma47ABeUiTsmG4McKDtGCgQSiTCatM97Mlbn13K42N1kPSFE14oN3WFMjtyL4KubhGvQTqYheKl4Qx2bJtMXLQ==", + "license": "MIT" + }, + "node_modules/iceberg-js": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/iceberg-js/-/iceberg-js-0.8.1.tgz", + "integrity": "sha512-1dhVQZXhcHje7798IVM+xoo/1ZdVfzOMIc8/rgVSijRK38EDqOJoGula9N/8ZI5RD8QTxNQtK/Gozpr+qUqRRA==", + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD" + } + } +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/package.json b/evals/docs/build-docs-038-storage-s3-authentication/local/package.json new file mode 100644 index 00000000..23836fca --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/package.json @@ -0,0 +1,9 @@ +{ + "name": "fernnotes", + "private": true, + "type": "module", + "dependencies": { + "@aws-sdk/client-s3": "3.1161.0", + "@supabase/supabase-js": "2.118.0" + } +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/supabase/config.toml b/evals/docs/build-docs-038-storage-s3-authentication/local/supabase/config.toml new file mode 100644 index 00000000..8bc4c37f --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/supabase/config.toml @@ -0,0 +1,165 @@ +project_id = "sandbox-storage-s3-authentication" + +[api] +enabled = true +port = 54321 +schemas = ["public", "graphql_public"] +extra_search_path = ["public", "extensions"] +max_rows = 1000 + +[api.tls] +enabled = false + +[db] +port = 54322 +shadow_port = 54320 +major_version = 17 + +[db.pooler] +enabled = false +port = 54329 +pool_mode = "transaction" +default_pool_size = 20 +max_client_conn = 100 + +[db.migrations] +enabled = true +schema_paths = [] + +[db.seed] +enabled = false + +[realtime] +enabled = true + +[studio] +enabled = true +port = 54323 +api_url = "http://127.0.0.1" +openai_api_key = "env(OPENAI_API_KEY)" + +[inbucket] +enabled = true +port = 54324 + +[storage] +enabled = true +file_size_limit = "50MiB" + +[storage.s3_protocol] +enabled = true + +[storage.analytics] +enabled = false +max_namespaces = 5 +max_tables = 10 +max_catalogs = 2 + +[storage.vector] +enabled = false +max_buckets = 10 +max_indexes = 5 + +[auth] +enabled = true +site_url = "http://127.0.0.1:3000" +additional_redirect_urls = ["https://127.0.0.1:3000"] +jwt_expiry = 3600 +enable_refresh_token_rotation = true +refresh_token_reuse_interval = 10 +enable_signup = true +enable_anonymous_sign_ins = false +enable_manual_linking = false +minimum_password_length = 6 +password_requirements = "" + +[auth.rate_limit] +email_sent = 2 +sms_sent = 30 +anonymous_users = 30 +token_refresh = 150 +sign_in_sign_ups = 30 +token_verifications = 30 +web3 = 30 + +[auth.email] +enable_signup = true +double_confirm_changes = true +enable_confirmations = false +secure_password_change = false +max_frequency = "1s" +otp_length = 6 +otp_expiry = 3600 + +[auth.sms] +enable_signup = false +enable_confirmations = false +template = "Your code is {{ .Code }}" +max_frequency = "5s" + +[auth.sms.twilio] +enabled = false +account_sid = "" +message_service_sid = "" +auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)" + +[auth.mfa] +max_enrolled_factors = 10 + +[auth.mfa.totp] +enroll_enabled = false +verify_enabled = false + +[auth.mfa.phone] +enroll_enabled = false +verify_enabled = false +otp_length = 6 +template = "Your code is {{ .Code }}" +max_frequency = "5s" + +[auth.external.apple] +enabled = false +client_id = "" +secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)" +redirect_uri = "" +url = "" +skip_nonce_check = false +email_optional = false + +[auth.web3.solana] +enabled = false + +[auth.third_party.firebase] +enabled = false + +[auth.third_party.auth0] +enabled = false + +[auth.third_party.aws_cognito] +enabled = false + +[auth.third_party.clerk] +enabled = false + +[auth.oauth_server] +enabled = false +authorization_url_path = "/oauth/consent" +allow_dynamic_registration = false + +[edge_runtime] +enabled = true +policy = "per_worker" +inspector_port = 8083 +deno_version = 2 + +[analytics] +enabled = true +port = 54327 +backend = "postgres" + +[experimental] +orioledb_version = "" +s3_host = "env(S3_HOST)" +s3_region = "env(S3_REGION)" +s3_access_key = "env(S3_ACCESS_KEY)" +s3_secret_key = "env(S3_SECRET_KEY)" diff --git a/evals/docs/build-docs-038-storage-s3-authentication/local/supabase/migrations/20240101000000_init.sql b/evals/docs/build-docs-038-storage-s3-authentication/local/supabase/migrations/20240101000000_init.sql new file mode 100644 index 00000000..9ad3e105 --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/local/supabase/migrations/20240101000000_init.sql @@ -0,0 +1,2 @@ +insert into storage.buckets (id, name, public) +values ('notes', 'notes', false); diff --git a/evals/docs/build-docs-038-storage-s3-authentication/migrations.ts b/evals/docs/build-docs-038-storage-s3-authentication/migrations.ts new file mode 100644 index 00000000..89f75cab --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/migrations.ts @@ -0,0 +1,97 @@ +import { readdirSync } from 'node:fs'; +import { join } from 'node:path'; +import type { CheckResult, LocalStackEvalContext } from '@supabase-evals/core'; + +export type MigrationState = { + pending: string[]; + applyFailed?: string; +}; + +export async function applyPendingMigrations( + ctx: LocalStackEvalContext +): Promise { + try { + return await apply(ctx); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + return { pending: ['unknown'], applyFailed: message.slice(0, 300) }; + } +} + +async function apply(ctx: LocalStackEvalContext): Promise { + const pending = await pendingVersions(ctx); + + if (pending.length === 0) { + return { pending }; + } + + const applied = await ctx.exec('supabase migration up --local', { + timeoutMs: 300_000, + }); + if (applied.exitCode !== 0) { + return { + pending, + applyFailed: firstError( + `${applied.stderr ?? ''}\n${applied.stdout ?? ''}` + ), + }; + } + return { pending }; +} + +export function checkMigrationsWereApplied(state: MigrationState): CheckResult { + return { + name: 'the agent applied the migrations it wrote', + passed: state.pending.length === 0, + notes: + state.pending.length === 0 + ? 'nothing pending' + : state.applyFailed + ? `pending: ${state.pending.join(', ')}; the scorer could not apply them: ${state.applyFailed}` + : `pending: ${state.pending.join(', ')}; the scorer applied them so the rest of the checks could run`, + }; +} + +async function pendingVersions(ctx: LocalStackEvalContext): Promise { + const onDisk = migrationVersionsOnDisk(ctx.hostWorkspace); + if (onDisk.length === 0) { + return []; + } + + const { rows: history } = await ctx.query( + "SELECT to_regclass('supabase_migrations.schema_migrations') IS NOT NULL AS present;" + ); + if (history[0]?.present !== true) { + return onDisk; + } + + const { rows } = await ctx.query( + 'SELECT version FROM supabase_migrations.schema_migrations;' + ); + const applied = new Set(rows.map((row) => String(row.version))); + return onDisk.filter((version) => !applied.has(version)); +} + +function migrationVersionsOnDisk(hostWorkspace: string): string[] { + let entries: string[]; + try { + entries = readdirSync(join(hostWorkspace, 'supabase', 'migrations')); + } catch { + return []; + } + return entries + .map((entry) => /^(\d+)(?:_.*)?\.sql$/.exec(entry)?.[1]) + .filter((version): version is string => version !== undefined) + .sort(); +} + +function firstError(output: string): string { + const lines = output + .split('\n') + .map((line) => line.trim()) + .filter((line) => line.length > 0); + const named = lines.find((line) => + /^(ERROR|FATAL|DETAIL|HINT)\b/i.test(line) + ); + return (named ?? lines[0] ?? 'no output').slice(0, 300); +} diff --git a/evals/docs/build-docs-038-storage-s3-authentication/probe-source.ts b/evals/docs/build-docs-038-storage-s3-authentication/probe-source.ts new file mode 100644 index 00000000..c9e955ff --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/probe-source.ts @@ -0,0 +1,170 @@ +export const PROBE_SOURCE = String.raw` +import { createRequire } from 'node:module'; +import { join } from 'node:path'; +import { pathToFileURL } from 'node:url'; + +const input = JSON.parse(Buffer.from(process.env.PROBE_INPUT, 'base64').toString('utf8')); +const mode = process.argv[2]; +const BUCKET = 'notes'; +const out = (value) => console.log(JSON.stringify(value)); +const messageOf = (error) => String(error?.message ?? error).slice(0, 200); +const failure = (error) => ({ + ok: false, + code: error?.name ?? 'Error', + status: error?.$metadata?.httpStatusCode, + message: messageOf(error), +}); + +async function sdkFor(dir) { + const require = createRequire(join(dir, 'probe.js')); + const mod = await import(pathToFileURL(require.resolve('@aws-sdk/client-s3')).href); + return mod.ListObjectsV2Command ? mod : mod.default; +} + +async function agentClient(dir, factory, ...args) { + const mod = await import(pathToFileURL(join(dir, 'storage.js')).href); + if (typeof mod[factory] !== 'function') { + throw new Error(factory + ' is not exported from storage.js'); + } + const client = await mod[factory](...args); + if (!client || typeof client.send !== 'function') { + throw new Error(factory + ' did not return an S3 client'); + } + return client; +} + +async function list(client, s3, prefix) { + try { + const keys = []; + let token; + let pages = 0; + do { + const page = await client.send( + new s3.ListObjectsV2Command({ Bucket: BUCKET, Prefix: prefix, ContinuationToken: token }) + ); + for (const object of page.Contents ?? []) keys.push(object.Key); + token = page.IsTruncated ? page.NextContinuationToken : undefined; + pages += 1; + } while (token && pages < 50); + return { ok: true, keys }; + } catch (error) { + return failure(error); + } +} + +async function read(client, s3, key) { + try { + const { Body } = await client.send(new s3.GetObjectCommand({ Bucket: BUCKET, Key: key })); + return { ok: true, body: await Body.transformToString() }; + } catch (error) { + return failure(error); + } +} + +async function put(client, s3, key, body) { + try { + await client.send( + new s3.PutObjectCommand({ Bucket: BUCKET, Key: key, Body: body, ContentType: 'text/markdown' }) + ); + return { ok: true }; + } catch (error) { + return failure(error); + } +} + +async function admin() { + const { createClient } = await import('@supabase/supabase-js'); + return createClient(input.apiUrl, input.adminKey, { + auth: { persistSession: false, autoRefreshToken: false }, + }); +} + +async function setup() { + const { createClient } = await import('@supabase/supabase-js'); + const users = {}; + for (const who of ['owner', 'other']) { + const client = createClient(input.apiUrl, input.clientKey, { + auth: { persistSession: false, autoRefreshToken: false }, + }); + const { data, error } = await client.auth.signUp({ + email: who + '-' + input.run + '@example.test', + password: input.password, + }); + if (error || !data.session) { + return out({ ok: false, message: 'could not sign up a user: ' + (error?.message ?? 'no session') }); + } + users[who] = { id: data.user.id, token: data.session.access_token }; + } + const notes = { + mine: users.owner.id + '/' + input.run + '-mine.md', + fresh: users.owner.id + '/' + input.run + '-fresh.md', + theirs: users.other.id + '/' + input.run + '-theirs.md', + planted: users.other.id + '/' + input.run + '-planted.md', + }; + const storage = (await admin()).storage.from(BUCKET); + for (const [key, body] of [ + [notes.mine, input.texts.mine], + [notes.theirs, input.texts.theirs], + ]) { + const { error } = await storage.upload(key, body, { contentType: 'text/markdown' }); + if (error) return out({ ok: false, message: 'could not add ' + key + ': ' + error.message }); + } + out({ ok: true, users, notes }); +} + +async function backup() { + const dir = process.cwd(); + let client; + try { + client = await agentClient(dir, 'createBackupClient'); + } catch (error) { + return out({ ok: false, message: messageOf(error) }); + } + const s3 = await sdkFor(dir); + out({ + ok: true, + listing: await list(client, s3, undefined), + mine: await read(client, s3, input.notes.mine), + theirs: await read(client, s3, input.notes.theirs), + }); +} + +async function desktop() { + const dir = process.cwd(); + let client; + try { + client = await agentClient(dir, 'createStorageClient', input.users.owner.token); + } catch (error) { + return out({ ok: false, message: messageOf(error) }); + } + const s3 = await sdkFor(dir); + const result = { ok: true }; + result.listOwn = await list(client, s3, input.users.owner.id + '/'); + result.readOwn = await read(client, s3, input.notes.mine); + result.upload = await put(client, s3, input.notes.fresh, input.texts.fresh); + result.resync = await put(client, s3, input.notes.mine, input.texts.again); + result.listOther = await list(client, s3, input.users.other.id + '/'); + result.listAll = await list(client, s3, undefined); + result.readOther = await read(client, s3, input.notes.theirs); + result.writeOther = await put(client, s3, input.notes.theirs, input.texts.tampered); + result.plantOther = await put(client, s3, input.notes.planted, input.texts.planted); + out(result); +} + +async function verify() { + const storage = (await admin()).storage.from(BUCKET); + const bodies = {}; + for (const [name, key] of Object.entries(input.notes)) { + const { data, error } = await storage.download(key); + bodies[name] = error ? null : await data.text(); + } + out({ ok: true, bodies }); +} + +const modes = { setup, backup, desktop, verify }; +try { + await modes[mode](); +} catch (error) { + out({ ok: false, message: messageOf(error) }); +} +`; diff --git a/evals/docs/build-docs-038-storage-s3-authentication/probes.ts b/evals/docs/build-docs-038-storage-s3-authentication/probes.ts new file mode 100644 index 00000000..f676b23b --- /dev/null +++ b/evals/docs/build-docs-038-storage-s3-authentication/probes.ts @@ -0,0 +1,591 @@ +import { randomUUID } from 'node:crypto'; +import { readdirSync, readFileSync, statSync } from 'node:fs'; +import { join, relative } from 'node:path'; +import type { CheckResult, LocalStackEvalContext } from '@supabase-evals/core'; +import { execSql } from '../lib/exec-sql.js'; +import { errorLine, messageOf } from '../lib/local-stack.js'; +import { PROBE_SOURCE } from './probe-source.js'; + +type Exec = Pick; + +export const CHECK = { + installed: 'project dependencies installed', + ownNotes: 'a signed-in user can list and read their own notes', + upload: 'a signed-in user can upload a new note', + resync: 'a signed-in user can sync a note again', + otherHidden: "a signed-in user cannot read or list another user's notes", + otherUnchanged: "a signed-in user cannot change another user's notes", + noFullAccessKey: + 'no file in the desktop app holds a full-access key from the project', + backup: "the backup job reads every user's notes", +} as const; + +const DESKTOP_CHECKS = [ + CHECK.ownNotes, + CHECK.upload, + CHECK.resync, + CHECK.otherHidden, + CHECK.otherUnchanged, +] as const; + +export const PROBE_CHECKS = [...DESKTOP_CHECKS, CHECK.backup] as const; + +const REFUSALS = new Set(['NoSuchKey', 'AccessDenied']); +const SKIPPED_DIRS = new Set(['node_modules', '.git']); +const MAX_FILE_BYTES = 2_000_000; + +export type Stack = { + apiUrl: string; + clientKey: string; + adminKey: string; + fullAccess: { label: string; value: string }[]; +}; + +export async function readStack(ctx: Exec): Promise { + const result = await ctx.exec('supabase status -o json 2>/dev/null'); + const out = result.stdout ?? ''; + const parsed = JSON.parse( + out.slice(out.indexOf('{'), out.lastIndexOf('}') + 1) + ); + const stack = { + apiUrl: parsed.API_URL, + clientKey: parsed.PUBLISHABLE_KEY || parsed.ANON_KEY, + adminKey: parsed.SERVICE_ROLE_KEY || parsed.SECRET_KEY, + fullAccess: [ + { + label: 'the S3 secret key', + value: parsed.S3_PROTOCOL_ACCESS_KEY_SECRET, + }, + { label: 'the service role key', value: parsed.SERVICE_ROLE_KEY }, + { label: 'the secret key', value: parsed.SECRET_KEY }, + { label: 'the JWT secret', value: parsed.JWT_SECRET }, + ].filter( + (entry): entry is { label: string; value: string } => + typeof entry.value === 'string' && entry.value.length > 0 + ), + }; + if (!stack.apiUrl || !stack.clientKey || !stack.adminKey) { + throw new Error( + `supabase status is missing the api url or a key: ${Object.keys(parsed).join(', ')}` + ); + } + return stack; +} + +export function checkNoFullAccessKey( + workspace: string, + stack: Stack | undefined +): CheckResult { + const name = CHECK.noFullAccessKey; + if (!stack || stack.fullAccess.length === 0) { + return notRun(name, 'the project keys could not be read'); + } + const root = join(workspace, 'desktop'); + const hits = stack.fullAccess.flatMap(({ label, value }) => + filesContaining(root, root, value).map((file) => `${label} in ${file}`) + ); + return { + name, + passed: hits.length === 0, + notes: + hits.length === 0 + ? 'no file in desktop/ holds the S3 secret, the service role key, the secret key or the JWT secret' + : `found ${hits.join(', ')}`, + }; +} + +function filesContaining(root: string, dir: string, needle: string): string[] { + let entries: string[]; + try { + entries = readdirSync(dir); + } catch { + return []; + } + return entries.flatMap((entry) => { + const path = join(dir, entry); + let stats: ReturnType; + try { + stats = statSync(path); + } catch { + return []; + } + if (stats.isDirectory()) { + return SKIPPED_DIRS.has(entry) ? [] : filesContaining(root, path, needle); + } + if (stats.size > MAX_FILE_BYTES) return []; + try { + return readFileSync(path, 'utf8').includes(needle) + ? [`desktop/${relative(root, path)}`] + : []; + } catch { + return []; + } + }); +} + +export async function installDependencies(ctx: Exec): Promise { + try { + const result = await ctx.exec('npm ci --no-audit --no-fund --silent', { + timeoutMs: 420_000, + }); + return { + name: CHECK.installed, + passed: result.exitCode === 0, + notes: + result.exitCode === 0 + ? 'npm ci succeeded' + : errorLine(`${result.stderr ?? ''}\n${result.stdout ?? ''}`), + }; + } catch (error) { + return { name: CHECK.installed, passed: false, notes: messageOf(error) }; + } +} + +type Failure = { + ok: false; + code?: string; + status?: number; + message: string; +}; +type Listing = { ok: true; keys: string[] } | Failure; +type Read = { ok: true; body: string } | Failure; +type Write = { ok: true } | Failure; + +type Person = { id: string; token: string }; +type Users = { owner: Person; other: Person }; +type Notes = { mine: string; fresh: string; theirs: string; planted: string }; +type Texts = { + mine: string; + fresh: string; + again: string; + theirs: string; + tampered: string; + planted: string; +}; + +export type World = { + run: string; + scratch: string; + users: Users; + notes: Notes; + texts: Texts; + stack: Stack; +}; + +type BackupResult = + | { ok: true; listing: Listing; mine: Read; theirs: Read } + | Failure; + +type DesktopOk = { + ok: true; + listOwn: Listing; + readOwn: Read; + upload: Write; + resync: Write; + listOther: Listing; + listAll: Listing; + readOther: Read; + writeOther: Write; + plantOther: Write; +}; +type DesktopResult = DesktopOk | Failure; + +type Bodies = Partial>; + +function textsFor(run: string): Texts { + return { + mine: `mine-${run}`, + fresh: `fresh-${run}`, + again: `again-${run}`, + theirs: `theirs-${run}`, + tampered: `tampered-${run}`, + planted: `planted-${run}`, + }; +} + +export async function setupWorld( + ctx: Exec, + stack: Stack +): Promise<{ world: World } | { failure: string }> { + const run = randomUUID().slice(0, 8); + const texts = textsFor(run); + const encoded = Buffer.from(PROBE_SOURCE, 'utf8').toString('base64'); + const prepared = await ctx.exec( + `scratch=$(mktemp -d) && ln -s "$PWD/node_modules" "$scratch/node_modules" && echo ${encoded} | base64 -d > "$scratch/probe.mjs" && echo "SCRATCH:$scratch"` + ); + const scratch = (prepared.stdout ?? '') + .split('\n') + .find((line) => line.startsWith('SCRATCH:')) + ?.slice('SCRATCH:'.length) + .trim(); + if (prepared.exitCode !== 0 || !scratch) { + return { + failure: `could not write the probe: ${errorLine(prepared.stderr ?? '')}`, + }; + } + const result = await probe< + { ok: true; users: Users; notes: Notes } | Failure + >(ctx, scratch, scratch, 'setup', { + run, + texts, + apiUrl: stack.apiUrl, + clientKey: stack.clientKey, + adminKey: stack.adminKey, + password: `probe-${run}-password`, + }); + if (!result.ok) { + await removeScratch(ctx, scratch); + return { failure: result.message }; + } + const owned = await execSql( + ctx, + [ + [result.notes.mine, result.users.owner.id], + [result.notes.theirs, result.users.other.id], + ] + .map( + ([note, user]) => + `update storage.objects set owner = '${user}', owner_id = '${user}' where bucket_id = 'notes' and name = '${note}';` + ) + .join('\n') + ); + if (!owned.ok) { + await removeScratch(ctx, scratch); + return { + failure: `could not hand the notes to their owners: ${owned.message}`, + }; + } + return { + world: { + run, + scratch, + users: result.users, + notes: result.notes, + texts, + stack, + }, + }; +} + +export async function probeBackup( + ctx: Exec, + world: World +): Promise { + return probe( + ctx, + world.scratch, + 'backup', + 'backup', + inputFor(world) + ); +} + +export async function probeDesktop( + ctx: Exec, + world: World +): Promise { + const shipped = `${world.scratch}/desktop`; + const copied = await ctx.exec(`cp -R desktop "${shipped}"`); + if (copied.exitCode !== 0) { + return { + ok: false, + message: `could not copy desktop/ on its own: ${errorLine(copied.stderr ?? '')}`, + }; + } + return probe( + ctx, + world.scratch, + shipped, + 'desktop', + inputFor(world) + ); +} + +export async function readBodies( + ctx: Exec, + world: World +): Promise { + const result = await probe<{ ok: true; bodies: Bodies } | Failure>( + ctx, + world.scratch, + world.scratch, + 'verify', + inputFor(world) + ); + return result.ok ? result.bodies : result; +} + +export async function removeScratch(ctx: Exec, scratch: string): Promise { + await ctx.exec(`rm -rf "${scratch}"`).then( + () => undefined, + () => undefined + ); +} + +function inputFor(world: World) { + return { + run: world.run, + texts: world.texts, + apiUrl: world.stack.apiUrl, + adminKey: world.stack.adminKey, + users: world.users, + notes: world.notes, + }; +} + +async function probe( + ctx: Exec, + scratch: string, + cwd: string, + mode: string, + input: Record +): Promise { + const encoded = Buffer.from(JSON.stringify(input), 'utf8').toString('base64'); + try { + const result = await ctx.exec( + `cd "${cwd}" && env -i PATH="$PATH" HOME="$HOME" PROBE_INPUT=${encoded} node $([ -f .env ] && echo --env-file=.env) "${scratch}/probe.mjs" ${mode}`, + { timeoutMs: 120_000 } + ); + const line = + (result.stdout ?? '') + .trim() + .split('\n') + .reverse() + .find((entry) => entry.startsWith('{')) ?? ''; + if (line) return JSON.parse(line) as T; + return { + ok: false, + message: `the ${mode} probe printed no result: ${errorLine(`${result.stderr ?? ''}\n${result.stdout ?? ''}`)}`, + }; + } catch (error) { + return { ok: false, message: messageOf(error) }; + } +} + +export function notRun(name: string, reason: string): CheckResult { + return { name, passed: false, notes: `not run: ${reason}` }; +} + +export function checkBackup(world: World, result: BackupResult): CheckResult { + const name = CHECK.backup; + if (!result.ok) return { name, passed: false, notes: result.message }; + const { listing } = result; + if (!listing.ok) { + return { + name, + passed: false, + notes: `listing the bucket failed: ${describe(listing)}`, + }; + } + const missing = [world.notes.mine, world.notes.theirs].filter( + (key) => !listing.keys.includes(key) + ); + if (missing.length > 0) { + return { + name, + passed: false, + notes: `the listing left out ${missing.join(', ')}`, + }; + } + const reads: [label: string, read: Read, expected: string][] = [ + ['their own note', result.mine, world.texts.mine], + ["the other user's note", result.theirs, world.texts.theirs], + ]; + const wrong = reads.filter( + ([, read, expected]) => !read.ok || read.body !== expected + ); + return { + name, + passed: wrong.length === 0, + notes: + wrong.length === 0 + ? "listed and read both users' notes" + : wrong + .map(([label, read]) => `reading ${label}: ${describe(read)}`) + .join('; '), + }; +} + +export function checkDesktop( + world: World, + result: DesktopResult, + bodies: Bodies | Failure +): CheckResult[] { + if (!result.ok) { + return DESKTOP_CHECKS.map((name) => ({ + name, + passed: false, + notes: result.message, + })); + } + const readBack = ( + name: string, + check: (stored: Bodies) => CheckResult + ): CheckResult => + 'ok' in bodies + ? { + name, + passed: false, + notes: `the scorer could not read the notes back: ${bodies.message}`, + } + : check(bodies); + return [ + ownNotes(world, result), + readBack(CHECK.upload, (stored) => upload(world, result, stored)), + readBack(CHECK.resync, (stored) => resync(world, result, stored)), + otherHidden(world, result), + readBack(CHECK.otherUnchanged, (stored) => + otherUnchanged(world, result, stored) + ), + ]; +} + +function ownNotes(world: World, result: DesktopOk): CheckResult { + const name = CHECK.ownNotes; + if (!result.listOwn.ok) { + return { + name, + passed: false, + notes: `listing their folder failed: ${describe(result.listOwn)}`, + }; + } + if (!result.listOwn.keys.includes(world.notes.mine)) { + return { name, passed: false, notes: 'their note was not in the listing' }; + } + if (!result.readOwn.ok || result.readOwn.body !== world.texts.mine) { + return { + name, + passed: false, + notes: `reading their note: ${describe(result.readOwn)}`, + }; + } + return { name, passed: true, notes: 'listed and read their own note' }; +} + +function upload(world: World, result: DesktopOk, bodies: Bodies): CheckResult { + const name = CHECK.upload; + if (!result.upload.ok) { + return { name, passed: false, notes: describe(result.upload) }; + } + return bodies.fresh === world.texts.fresh + ? { name, passed: true, notes: 'the new note is stored' } + : { + name, + passed: false, + notes: 'the upload returned no error, but the note is not stored', + }; +} + +function resync(world: World, result: DesktopOk, bodies: Bodies): CheckResult { + const name = CHECK.resync; + if (!result.resync.ok) { + return { + name, + passed: false, + notes: `uploading an existing note again failed: ${describe(result.resync)}`, + }; + } + return bodies.mine === world.texts.again + ? { name, passed: true, notes: 'the note holds the new text' } + : { + name, + passed: false, + notes: `the upload returned no error, but the note holds ${JSON.stringify(bodies.mine)}`, + }; +} + +function otherHidden(world: World, result: DesktopOk): CheckResult { + const name = CHECK.otherHidden; + const otherPrefix = `${world.users.other.id}/`; + const { listOther, listAll, readOther } = result; + if (!listOther.ok || !listAll.ok) { + const failed = !listOther.ok ? listOther : listAll; + return { + name, + passed: false, + notes: `not measured: listing failed rather than coming back empty: ${describe(failed)}`, + }; + } + const listed = [...listOther.keys, ...listAll.keys].filter((key) => + key.startsWith(otherPrefix) + ); + if (listed.length > 0) { + return { + name, + passed: false, + notes: `the listing showed ${[...new Set(listed)].join(', ')}`, + }; + } + if (readOther.ok) { + return { name, passed: false, notes: "read the other user's note" }; + } + if (!REFUSALS.has(readOther.code ?? '')) { + return { + name, + passed: false, + notes: `not measured: the read failed with ${describe(readOther)}, not a refusal`, + }; + } + return { + name, + passed: true, + notes: `their listings were empty and the read came back ${readOther.code}`, + }; +} + +function otherUnchanged( + world: World, + result: DesktopOk, + bodies: Bodies +): CheckResult { + const name = CHECK.otherUnchanged; + if (bodies.theirs !== world.texts.theirs) { + return { + name, + passed: false, + notes: `the other user's note now holds ${JSON.stringify(bodies.theirs)}`, + }; + } + if (typeof bodies.planted === 'string') { + return { + name, + passed: false, + notes: "a new note landed in the other user's folder", + }; + } + const writes: [label: string, write: Write][] = [ + ['the upload over their note', result.writeOther], + ['the upload into their folder', result.plantOther], + ]; + const accepted = writes.filter(([, write]) => write.ok); + if (accepted.length > 0) { + return { + name, + passed: false, + notes: `${accepted.map(([label]) => label).join(' and ')} returned no error`, + }; + } + const unmeasured = writes.filter( + ([, write]) => !write.ok && write.code !== 'AccessDenied' + ); + if (unmeasured.length > 0) { + return { + name, + passed: false, + notes: `not measured: ${unmeasured.map(([label, write]) => `${label} failed with ${describe(write)}`).join('; ')}, not a refusal`, + }; + } + return { + name, + passed: true, + notes: + 'both uploads were refused with AccessDenied, their note is unchanged and nothing new is in their folder', + }; +} + +function describe(value: Listing | Read | Write): string { + if (value.ok) return 'ok'; + return [value.code, value.status, value.message] + .filter((part) => part !== undefined && part !== '') + .join(' '); +}