Skip to content

Fix compatibility with external CIMD URLs - #3154

Merged
Meldiron merged 3 commits into
mainfrom
fix-cimd-client-id-resolution
Aug 11, 2026
Merged

Fix compatibility with external CIMD URLs#3154
Meldiron merged 3 commits into
mainfrom
fix-cimd-client-id-resolution

Conversation

@Meldiron

Copy link
Copy Markdown
Contributor

Original prompt

Appwrite APIs no longer support CIMD URL for apps.get() apps.list() and others. Simply, appId is now just ID, never URL.

Update the Console to account for this change. Instead, as needed, fetch the data directly from CIMD URL

What changed

The API no longer resolves CIMD (Client ID Metadata Document) URLs passed as appId, so the console now resolves them itself:

  • New $lib/helpers/oauth2-cimd.ts with getOAuth2App(appId): plain IDs go through sdk.forConsole.apps.get() as before; URL-shaped client IDs (https, or http on loopback for local dev) are fetched directly from the browser and the RFC 7591 metadata document is mapped onto Models.App (client_namename, logo_urilogoUri, policy_uri/tos_uri → privacy/terms links, device-code grant → deviceFlow, etc.).
  • Per the CIMD spec, the document's client_id must equal the URL it was fetched from; mismatching or malformed documents are rejected. URI fields are sanitized to http(s) before being rendered in src/href.
  • Fetch/validation failures degrade to hostname-only branding instead of blocking the flow — the server still validates the client during authorization, so this only affects display.
  • Routed all four apps.get() call sites through the helper: OAuth2 consent page (grant load + already-consented redirect), device flow page, and the account Applications list.
  • Unit tests for client-ID detection and document mapping/validation.

Testing

  • bun run test:unit — new oauth2-cimd.test.ts passes (7 tests)
  • bun run format, bun run lint on touched files — clean
  • bun run check — only pre-existing failure (dompurify types in modal.svelte), unrelated

🤖 Generated with Claude Code

Appwrite's apps.get()/apps.list() no longer resolve CIMD URLs — appId is
always a plain ID now. Detect URL-shaped OAuth2 client IDs in the console
and fetch the Client ID Metadata Document directly from the browser,
mapping its RFC 7591 fields onto Models.App for consent/device/applications
rendering. Fetch or validation failures fall back to hostname-only branding
so the flow never blocks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Aug 11, 2026

Copy link
Copy Markdown

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Schedule functions to run as often as every minute with cron expressions

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds browser-side resolution of URL-shaped CIMD client IDs after the API stopped resolving them.

  • Fetches and validates external client metadata, maps it to the existing application model, and falls back to hostname-only branding on failure.
  • Routes OAuth consent, device authorization, and connected-application metadata lookups through the new helper.
  • Adds unit coverage for client-ID detection, metadata validation, mapping, and unsafe URI rejection.
  • Updates nanoid and its resolved transitive versions.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/lib/helpers/oauth2-cimd.ts Adds CIMD URL detection, metadata fetching and validation, application-model mapping, URI filtering, and graceful branding fallback.
src/lib/helpers/oauth2-cimd.test.ts Covers supported client-ID forms, metadata mapping, identity matching, malformed documents, fallback naming, and unsafe URI values.
src/routes/(public)/oauth2/consent/+page.svelte Uses the CIMD-aware application resolver when loading resumed grants and non-web authorization outcomes.
src/routes/(public)/oauth2/device/+page.svelte Uses the CIMD-aware resolver for application metadata returned by device-grant creation.
src/routes/(console)/account/applications/+page.ts Resolves connected OAuth2 applications through the CIMD-aware helper while preserving null handling.
package.json Raises the nanoid dependency floor within the existing major version.
bun.lock Records deterministic direct and transitive nanoid patch updates.

Reviews (2): Last reviewed commit: "chore(deps): raise the nanoid floor past..." | Re-trigger Greptile

…-2v37-7h3g-55p8

bun audit fails the CI build on three high nanoid advisories. All fixes are
within the existing semver ranges: the direct dependency and @melt-ui/svelte's
nested copy move to 5.1.16, and the 3.x copies under @ai-sdk/provider-utils
and postcss move to 3.3.17.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Meldiron
Meldiron merged commit 00ba9b1 into main Aug 11, 2026
4 checks passed
@Meldiron
Meldiron deleted the fix-cimd-client-id-resolution branch August 11, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants