defaultDocumentLoader should make use of agentDependencies.fetch
From what i've seen, the defaultDocumentLoader does not use the injected fetch agentDependency;
it looks the document loader is pulled from an external lib:
// fetches the documentLoader from documentLoader.ts or documentLoader.native.ts depending on the platform at bundle time
const platformLoader = getNativeDocumentLoader()
const nativeLoader = platformLoader.apply(jsonld, [])
return await nativeLoader(url)
where:
export function getNativeDocumentLoader(): () => DocumentLoader {
const loader = require('@digitalcredentials/jsonld/lib/documentLoaders/node')
return loader as () => DocumentLoader
}
so whatever custom fetch you inject, i don't think it'll be used by this loader, have i read that right?
if so, it would be a nice improvement to use the injected fetch, such that whatever rules (e.g. security rules) are enforced by the injected fetch are also enforced during document loading. I'm not familiar with the @digitalcredentials/jsonld/lib/documentLoaders/node loader, it's flexibility for custom fetch might determine how complex this improvement would be...
I think having a single fetch document loader that is used in both node and react native makes sense. We just have to make sure it adheres to the document loader interface