Skip to content

Commit

Permalink
Update getAllAgentAccess() and getPublicAccess() to automatically aut…
Browse files Browse the repository at this point in the history
…henticate
  • Loading branch information
keylanjensen committed Apr 8, 2024
1 parent 862e478 commit 62b7a9d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,12 @@ const removeFolder = krl.Action(["folderURL", "doAutoAuth"], async function(fold
this.log.debug('Container deleted successfully!\n');
});

const getAllAgentAccess = krl.Function(["resourceURL"], async function(resourceURL: string) {
const getAllAgentAccess = krl.Function(["resourceURL", "doAutoAuth"], async function(resourceURL: string, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":createFolder could not validate Pod access token.";
}
}
const accessByAgent : any = await universalAccess.getAgentAccessAll(resourceURL, { fetch: authFetch });
let agents : string[] = [];
for (const [agent, agentAccess] of Object.entries(accessByAgent)) {
Expand Down Expand Up @@ -615,7 +620,12 @@ const removeAgentAccess = krl.Action(["resourceURL", "webID", "doAutoAuth"], asy
});
});

const getPublicAccess = krl.Function(["resourceURL"], async function(resourceURL: string) {
const getPublicAccess = krl.Function(["resourceURL", "doAutoAuth"], async function(resourceURL: string, doAutoAuth : boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":createFolder could not validate Pod access token.";
}
}
const access = await universalAccess.getPublicAccess(resourceURL, { fetch: authFetch });
if (access === null) {
console.log("Could not load access details for this Resource.");
Expand Down

0 comments on commit 62b7a9d

Please sign in to comment.