Skip to content

Commit 3e8d14c

Browse files
committed
Fix: fixed try-catch for deciding acl-acp util
1 parent e7b033e commit 3e8d14c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/shell/commands/perms.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export default class PermsCommand extends SolidCommand {
3232
const authenticationInfo = await authenticate(programOpts)
3333
options.fetch = authenticationInfo.fetch
3434
url = await changeUrlPrefixes(authenticationInfo, url)
35-
3635

3736
const { acp, acl } = await discoverAccessMechanism(url, options.fetch)
3837
if ( !acp && !acl ) {
@@ -47,7 +46,7 @@ export default class PermsCommand extends SolidCommand {
4746
return;
4847
}
4948
} catch (e) {
50-
if (options.verbose) writeErrorString('Unable to list permissions for WAC', e, options)
49+
if (options.verbose) writeErrorString('Unable to list permissions using WAC', e, options)
5150
}
5251
}
5352
if (acp) {
@@ -65,7 +64,6 @@ export default class PermsCommand extends SolidCommand {
6564
if (this.mayExit) process.exit(0)
6665
})
6766

68-
6967
access
7068
.command('set')
7169
.argument('<url>', 'Resource URL')
@@ -96,7 +94,7 @@ export default class PermsCommand extends SolidCommand {
9694
}
9795
let id = splitPerm[0]
9896
const permissionOptions = splitPerm[1].split('')
99-
let type;
97+
let type = 'agent';
10098

10199
if (options.group) {
102100
type = 'group'
@@ -107,7 +105,6 @@ export default class PermsCommand extends SolidCommand {
107105
writeErrorString('Could not autmatically fill in webId of authenticated user.', 'Please make sure you have an authenticated session to auto-fill your webId', options);
108106
process.exit(0)
109107
}
110-
type = 'agent'
111108
id = authenticationInfo.webId
112109
}
113110
const read = permissionOptions.indexOf('r') !== -1

src/utils/util.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,18 @@ export async function isRDFResource(fileInfo: FileInfo, fetch: any) {
507507

508508
export async function discoverAccessMechanism(url: string, fetch: any) {
509509
// We need to first check acp because Inrupt libs are kinda wack and reuse of acl rel header is confusing their own libs.
510-
const acpInfo = await acp_ess_2.getResourceInfoWithAcr(url, { fetch })
511-
const acp = acp_ess_2.hasAccessibleAcr(acpInfo)
512-
if (acp) return({ acp: true, acl: false })
513-
510+
try {
511+
const acpInfo = await acp_ess_2.getResourceInfoWithAcr(url, { fetch })
512+
const acp = acp_ess_2.hasAccessibleAcr(acpInfo)
513+
if (acp) return({ acp: true, acl: false })
514+
} catch {}
515+
514516
// Now we check acl
515-
const dataset = await acp_ess_2.getResourceInfoWithAccessDatasets(url, { fetch })
516-
const acl = hasAccessibleAcl(dataset) && !acp
517-
if (acl) return({ acp: false, acl: true })
518-
517+
try {
518+
const dataset = await acp_ess_2.getResourceInfoWithAccessDatasets(url, { fetch })
519+
const acl = hasAccessibleAcl(dataset) // && !acp -> is implicit here
520+
if (acl) return({ acp: false, acl: true })
521+
} catch {}
522+
519523
return ({ acp: false, acl: false })
520524
}

0 commit comments

Comments
 (0)