diff --git a/package.json b/package.json index 59e3a96..04c57e9 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "format": "prettier --write ." }, "type": "module", - "packageManager": "pnpm@10.9.0", + "packageManager": "pnpm@10.10.0", "devDependencies": { "@sveltejs/adapter-auto": "^6.0.0", "@sveltejs/kit": "^2.20.7", @@ -37,7 +37,7 @@ "vitest": "^3.1.2" }, "dependencies": { - "@blah-im/core": "^0.6.0", + "@blah-im/core": "^0.7.0", "@zeabur/svelte-adapter": "^1.0.0", "bits-ui": "^1.3.19", "canonicalize": "^2.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0fb6313..b4c2967 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@blah-im/core': - specifier: ^0.6.0 - version: 0.6.0 + specifier: ^0.7.0 + version: 0.7.0 '@zeabur/svelte-adapter': specifier: ^1.0.0 version: 1.0.0(@sveltejs/kit@2.20.7(@sveltejs/vite-plugin-svelte@5.0.3(svelte@5.28.2)(vite@6.3.3(jiti@2.4.2)(lightningcss@1.29.2)))(svelte@5.28.2)(vite@6.3.3(jiti@2.4.2)(lightningcss@1.29.2))) @@ -133,8 +133,8 @@ packages: resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} - '@blah-im/core@0.6.0': - resolution: {integrity: sha512-CBYFGbCDkQ1vXGYskKSxCWiknaga63NCtmpraZyWjHq8ZyNcG6UYIe6K0DMCJ7BtkbImW+7jk/k4Z2J+0e2kSw==} + '@blah-im/core@0.7.0': + resolution: {integrity: sha512-S3XhaETyRdz9kdeMHrk0yokDYbWaFKvC12uJjd4FGAZZx+40w9+RUCrDxkrqifn8QOiZR3xw6eAryeLILNuIcA==} '@esbuild/aix-ppc64@0.19.12': resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} @@ -2074,7 +2074,7 @@ snapshots: '@jridgewell/gen-mapping': 0.3.8 '@jridgewell/trace-mapping': 0.3.25 - '@blah-im/core@0.6.0': + '@blah-im/core@0.7.0': dependencies: zod: 3.24.3 diff --git a/src/lib/idURL.ts b/src/lib/idURL.ts index d692c0c..e7f53c3 100644 --- a/src/lib/idURL.ts +++ b/src/lib/idURL.ts @@ -1,4 +1,8 @@ -import { BlahIdentity, blahIdentityDescriptionSchema } from '@blah-im/core/identity'; +import { + BlahIdentity, + blahIdentityDescriptionSchema, + getIdentityDescriptionFileURL +} from '@blah-im/core/identity'; export function idURLToUsername(idURL: string): string { const url = new URL(idURL); @@ -24,22 +28,13 @@ export type IDURLValidity = } )); export async function validateIDURL(url: string, identity: BlahIdentity): Promise { - const idURL = URL.parse(url); - if ( - !idURL || - idURL.protocol !== 'https:' || - idURL.pathname !== '/' || - idURL.search || - idURL.username || - idURL.password - ) - return { valid: false, reason: 'invalid-url' }; + let profileFileURL: string; - const profileFileURL = (() => { - let url = idURL; - url.pathname = identityDescriptionFilePath; - return url.toString(); - })(); + try { + profileFileURL = getIdentityDescriptionFileURL(url); + } catch (e) { + return { valid: false, reason: 'invalid-url' }; + } try { const response = await fetch(profileFileURL, {