import { getSolidDataset, getStringNoLocale, getThingAll, getUrl, } from "@inrupt/solid-client"; import { fetch, getDefaultSession } from "@inrupt/solid-client-authn-browser"; import { FOAF, VCARD } from "@inrupt/vocab-common-rdf"; export const getProfile = async () => { const session = getDefaultSession(); const webId = session.info.webId; if (!webId) return null; const profileDataset = await getSolidDataset(webId, { fetch: fetch }); const subjects = getThingAll(profileDataset); const findValue = (predicate: string) => subjects .map( subject => getStringNoLocale(subject, predicate) || getUrl(subject, predicate) ) ?.filter(i => !!i)[0]; return { name: findValue(FOAF.name), organization: findValue(VCARD.organization_name), image: findValue(VCARD.hasPhoto), webId, }; };