mirror of
https://github.com/Blah-IM/Weblah.git
synced 2025-08-20 19:12:40 +00:00
chore: update @blah-im/core and use ID URL validation from it
Upgrade pnpm to 10.10.0 and @blah-im/core to 0.7.0, refactor identity URL validation to use the core library's getIdentityDescriptionFileURL function
This commit is contained in:
parent
c5716718bf
commit
757175a5c7
3 changed files with 18 additions and 23 deletions
|
@ -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<IDURLValidity> {
|
||||
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, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue