diff --git a/src/acl/acl.internal.ts b/src/acl/acl.internal.ts index 3d30b5abdd..4479d23bca 100644 --- a/src/acl/acl.internal.ts +++ b/src/acl/acl.internal.ts @@ -20,17 +20,17 @@ // import type { Quad } from "@rdfjs/types"; -import { getSolidDataset } from "../resource/solidDataset"; +import { getSolidDataset, ParseOptions } from "../resource/solidDataset"; import type { IriString, - WithChangeLog, Thing, + WithChangeLog, WithServerResourceInfo, } from "../interfaces"; import { - getSourceUrl, getResourceInfo, getSourceIri, + getSourceUrl, } from "../resource/resource"; import { acl, rdf } from "../constants"; import { DataFactory, subjectToRdfJsQuads } from "../rdfjs.internal"; @@ -68,7 +68,7 @@ import { isAcr } from "../acp/acp.internal"; */ export async function internal_fetchAcl( resourceInfo: WithServerResourceInfo, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { if (!hasAccessibleAcl(resourceInfo)) { return { @@ -104,7 +104,7 @@ export async function internal_fetchAcl( /** @internal */ export async function internal_fetchResourceAcl( dataset: WithServerResourceInfo, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { if (!hasAccessibleAcl(dataset)) { return null; @@ -136,7 +136,7 @@ export async function internal_fetchResourceAcl( /** @internal */ export async function internal_fetchFallbackAcl( resource: WithAccessibleAcl, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { const resourceUrl = new URL(getSourceUrl(resource)); const resourcePath = resourceUrl.pathname; diff --git a/src/acl/acl.ts b/src/acl/acl.ts index 6aee565068..7cd3a74cba 100644 --- a/src/acl/acl.ts +++ b/src/acl/acl.ts @@ -23,6 +23,7 @@ import { acl } from "../constants"; import { createSolidDataset, getSolidDataset, + ParseOptions, saveSolidDatasetAt, } from "../resource/solidDataset"; import type { @@ -114,7 +115,7 @@ export function hasResourceAcl< */ export async function getSolidDatasetWithAcl( url: UrlString | Url, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { const solidDataset = await getSolidDataset(url, options); const acl = await internal_fetchAcl(solidDataset, options); diff --git a/src/acp/acp.ts b/src/acp/acp.ts index 746a748aa1..d4b11248d7 100644 --- a/src/acp/acp.ts +++ b/src/acp/acp.ts @@ -35,7 +35,7 @@ import { getResourceInfo, getSourceUrl } from "../resource/resource"; import type { WithAcl } from "../acl/acl"; import { hasAccessibleAcl } from "../acl/acl"; import { internal_fetchAcl, internal_setAcl } from "../acl/acl.internal"; -import { getSolidDataset, saveSolidDatasetAt } from "../resource/solidDataset"; +import { getSolidDataset, ParseOptions, saveSolidDatasetAt } from "../resource/solidDataset"; import type { AccessControlResource } from "./control"; import { getAcrPolicyUrlAll, @@ -62,7 +62,7 @@ import { isAcr } from "./acp.internal"; */ export async function getSolidDatasetWithAcr( url: Url | UrlString, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { const urlString = internal_toIriString(url); const solidDataset = await getSolidDataset(urlString, options); @@ -135,7 +135,7 @@ export async function getResourceInfoWithAcr( */ export async function getSolidDatasetWithAccessDatasets( url: Url | UrlString, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { const urlString = internal_toIriString(url); const solidDataset = await getSolidDataset(urlString, options); @@ -266,7 +266,7 @@ export function hasAccessibleAcr( async function fetchAcr( resource: WithServerResourceInfo, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { let acrUrl: UrlString | undefined; if (hasLinkedAcr(resource)) { diff --git a/src/profile/webid.ts b/src/profile/webid.ts index f014553ebd..ac3b6df03e 100644 --- a/src/profile/webid.ts +++ b/src/profile/webid.ts @@ -20,6 +20,7 @@ // import type { + ParseOptions, SolidDataset, UrlString, WebId, @@ -90,11 +91,14 @@ export async function getProfileAll< options?: { fetch?: typeof fetch; webIdProfile?: T; - }, + } & Partial, ): Promise>; export async function getProfileAll( webId: WebId, - options?: { fetch?: typeof fetch; webIdProfile: undefined }, + options?: { + fetch?: typeof fetch; + webIdProfile: undefined; + } & Partial, ): Promise>; export async function getProfileAll< T extends SolidDataset & WithServerResourceInfo, @@ -103,17 +107,19 @@ export async function getProfileAll< options?: { fetch?: typeof fetch; webIdProfile?: T; - }, + } & Partial, ): Promise> { - const authFetch = options?.fetch ?? fetch; + const unauthenticatedOptions = Object.assign({}, options); + delete unauthenticatedOptions["fetch"]; + const webIdProfile = options?.webIdProfile ?? // This should always use an unauthenticated fetch. - (await getSolidDataset(webId)); + (await getSolidDataset(webId, unauthenticatedOptions)); const altProfileAll = ( await Promise.allSettled( getAltProfileUrlAllFrom(webId, webIdProfile).map((uniqueProfileIri) => - getSolidDataset(uniqueProfileIri, { fetch: authFetch }), + getSolidDataset(uniqueProfileIri, options), ), ) ) @@ -147,7 +153,7 @@ export async function getProfileAll< */ export async function getPodUrlAll( webId: WebId, - options?: { fetch?: typeof fetch }, + options?: { fetch?: typeof fetch } & Partial, ): Promise { const profiles = await getProfileAll(webId, options); return getPodUrlAllFrom(profiles, webId); @@ -201,6 +207,7 @@ export function getPodUrlAllFrom( */ export async function getWebIdDataset( webId: WebId, + options?: { fetch?: typeof fetch } & Partial, ): Promise> { - return getSolidDataset(webId); + return getSolidDataset(webId, options); } diff --git a/src/resource/solidDataset.ts b/src/resource/solidDataset.ts index 3fa338f05e..31c241e9f0 100644 --- a/src/resource/solidDataset.ts +++ b/src/resource/solidDataset.ts @@ -240,7 +240,7 @@ export async function responseToSolidDataset( */ export async function getSolidDataset( url: UrlString | Url, - options?: Partial<{ fetch: typeof fetch } & ParseOptions>, + options?: Partial<{ fetch: typeof fetch } & Partial>, ): Promise { const normalizedUrl = normalizeUrl(internal_toIriString(url)); const parserContentTypes = Object.keys(options?.parsers ?? {}); @@ -1151,7 +1151,7 @@ function resolveLocalIrisInThing( */ export async function getWellKnownSolid( url: UrlString | Url, - options?: Partial<{ fetch?: typeof fetch } & ParseOptions>, + options?: Partial<{ fetch?: typeof fetch } & Partial>, ): Promise { const urlString = internal_toIriString(url);