From 62b7a9d003c5b395b59c527fbf998092775c57cb Mon Sep 17 00:00:00 2001 From: Keylan Jensen Date: Mon, 8 Apr 2024 10:49:01 -0600 Subject: [PATCH] Update getAllAgentAccess() and getPublicAccess() to automatically authenticate --- pods.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pods.ts b/pods.ts index ce37b9c..956d641 100644 --- a/pods.ts +++ b/pods.ts @@ -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)) { @@ -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.");