Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
reading profile quads
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed May 24, 2019
1 parent 865de49 commit 24d75cd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/lib/auth/appIsTrustedForMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const debug = Debug('DetermineAllowedModeForOrigin')

const OWNER_PROFILES_FETCH_TIMEOUT = 2000

const ownerProfilesCache: { [webId: string]: string } = {}
const ownerProfilesCache: { [webId: string]: any } = {}

export interface OriginCheckTask {
origin: string,
Expand All @@ -19,9 +19,22 @@ export interface OriginCheckTask {
async function checkOwnerProfile (webId: URL, origin: string, mode: string, graphFetcher: RdfFetcher): Promise<boolean> {
// TODO: move this cache into a decorator pattern, see #81
if (!ownerProfilesCache[webId.toString()]) {
debug('cache miss', webId)
ownerProfilesCache[webId.toString()] = await graphFetcher.fetchGraph(webId)
}
return Promise.resolve(false)
if (!ownerProfilesCache[webId.toString()]) {
return Promise.resolve(false)
}
const quads: Array<any> = []
try {
ownerProfilesCache[webId.toString()].map((quad: any) => {
debug('reading quad', quad)
quads.push(quad)
})
} catch (err) {
debug('error looping over quads', err)
}
return false
}

export async function appIsTrustedForMode (task: OriginCheckTask, graphFetcher: RdfFetcher): Promise<boolean> {
Expand Down

0 comments on commit 24d75cd

Please sign in to comment.