-
Notifications
You must be signed in to change notification settings - Fork 0
/
pods.ts
638 lines (580 loc) · 24.6 KB
/
pods.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
import { krl, KrlCtx } from "krl-stdlib";
import {
overwriteFile,
getSolidDataset,
getContainedResourceUrlAll,
getFile,
isRawData,
getContentType,
getSourceUrl,
createContainerAt,
deleteContainer,
deleteFile,
universalAccess,
saveFileInContainer,
} from '@inrupt/solid-client';
import {
createDpopHeader,
generateDpopKeyPair,
buildAuthenticatedFetch,
} from '@inrupt/solid-client-authn-core';
import * as fs from "fs";
const STORAGE_ENT_NAME : string = "__pods_storageURL";
const MODULE_NAME : string = "pods";
const CLIENT_ID_ENT_NAME : string = "__pods_clientID";
const CLIENT_SECRET_ENT_NAME : string = "__pods_clientSecret";
const TOKEN_URL_ENT_NAME : string = "__pods_tokenURL";
let authFetch : (typeof fetch);
let accessToken : string | undefined;
let accessTokenReceiveTime : number | undefined;
let accessTokenValidDuration : number | undefined;
const getStorage = krl.Function([], async function() : Promise<string | undefined> {
return this.rsCtx.getEnt(STORAGE_ENT_NAME);
});
const setStorage = krl.Action(["new_URL"], async function(new_URL : string | undefined) {
this.rsCtx.putEnt(STORAGE_ENT_NAME, new_URL);
});
const getClientID = krl.Function([], async function() : Promise<string | undefined> {
return this.rsCtx.getEnt(CLIENT_ID_ENT_NAME);
});
const setClientID = krl.Action(["new_ID"], async function(new_ID : string | undefined) {
this.rsCtx.putEnt(CLIENT_ID_ENT_NAME, new_ID);
});
const getClientSecret = krl.Function([], async function() : Promise<string | undefined> {
return this.rsCtx.getEnt(CLIENT_SECRET_ENT_NAME);
});
const setClientSecret = krl.Action(["new_Secret"], async function(new_Secret : string | undefined) {
this.rsCtx.putEnt(CLIENT_SECRET_ENT_NAME, new_Secret);
});
const getRefreshTokenURL = krl.Function([], async function() : Promise<string | undefined> {
return this.rsCtx.getEnt(TOKEN_URL_ENT_NAME);
});
const setRefreshTokenURL = krl.Action(["new_URL"], async function(new_URL : string | undefined) {
this.rsCtx.putEnt(TOKEN_URL_ENT_NAME, new_URL);
});
const getAccessToken = krl.Function([], async function() : Promise<string | undefined> {
return accessToken;
});
const setAccessToken = krl.Action(["new_Token"], async function(new_Token : string | undefined) {
accessToken = new_Token;
});
const getAccessTokenReceiveTime = krl.Function([], async function() : Promise<number | undefined> {
return accessTokenReceiveTime
});
const setAccessTokenReceiveTime = krl.Action(["new_obj"], async function(new_obj : number | undefined) {
accessTokenReceiveTime = new_obj;
});
const getAccessTokenValidDuration = krl.Function([], async function() : Promise<number | undefined> {
return accessTokenValidDuration;
});
const setAccessTokenValidDuration = krl.Action(["new_obj"], async function(new_obj : number | undefined) {
accessTokenValidDuration = new_obj;
});
function getCurrentTimeInSeconds() : number {
return new Date().getTime() / 1000;
}
const hasValidAccessToken = krl.Function([], async function() {
let accessToken = await getAccessToken(this, []);
let receiveTime = await getAccessTokenReceiveTime(this, []);
let validDuration = await getAccessTokenValidDuration(this, []);
if (!accessToken || !receiveTime || !validDuration) {
return false;
}
const currentTime = getCurrentTimeInSeconds();
this.log.debug("Current Time: " + String(currentTime) + ", " +
"Receive Time: " + String(receiveTime));
this.log.debug("Valid Duration: " + String(validDuration) + ", " +
"Current Duration: " + String(currentTime - receiveTime));
if (currentTime-receiveTime > validDuration) {
return false;
}
return true;
});
const isStorageConnected = krl.Function([], async function() : Promise<boolean> {
const storeURL : string | undefined = await getStorage(this, []);
if (!storeURL) {
return false;
}
return true;
});
async function getBlob(originURL : string) {
let data : Blob;
if (originURL.startsWith("file://")) {
let response = fs.readFileSync(new URL(originURL));
data = new Blob([response]);
} else {
let response = await fetch(originURL);
data = await response.blob();
}
return data;
}
async function createFileObject(data : Blob, url : string, functionName : string) : Promise<File> {
let fileName : string;
//Get file name
//Forward Slash Filename
let fS_filename = url.split('/').pop();
//Backward Slash Filename
let bS_filename = url.split('\\').pop();
if (typeof fS_filename === "undefined" && typeof bS_filename === "undefined") {
fileName = url;
} else if (typeof fS_filename === "undefined" || fS_filename.length == 0) {
fileName = <string>bS_filename;
} else if (typeof bS_filename === "undefined" || bS_filename.length == 0) {
fileName = fS_filename;
} else if (fS_filename.length > bS_filename.length) {
fileName = bS_filename;
} else {
fileName = fS_filename;
}
if (typeof fileName === "undefined") {
throw MODULE_NAME + ":" + functionName + " could not define file name.";
}
if (fileName.length == 0) {
throw MODULE_NAME + ":" + functionName + " detected a file name of length 0.";
}
let file = new File([data], <string>fileName);
return file;
}
const authenticate = krl.Action([], async function authenticate() {
// A key pair is needed for encryption.
// This function from `solid-client-authn` generates such a pair for you.
const dpopKey = await generateDpopKeyPair();
// These are the ID and secret generated in the previous step.
// Both the ID and the secret need to be form-encoded.
const authString = `${encodeURIComponent(await getClientID(this, []))}:${encodeURIComponent(await getClientSecret(this, []))}`;
// This URL can be found by looking at the "token_endpoint" field at
// http://localhost:3000/.well-known/openid-configuration
// if your server is hosted at http://localhost:3000/.
const tokenUrl = await getRefreshTokenURL(this, []);
const response = await fetch(tokenUrl, {
method: 'POST',
headers: {
// The header needs to be in base64 encoding.
authorization: `Basic ${Buffer.from(authString).toString('base64')}`,
'content-type': 'application/x-www-form-urlencoded',
dpop: await createDpopHeader(tokenUrl, 'POST', dpopKey),
},
body: 'grant_type=client_credentials&scope=webid',
});
// This is the Access token that will be used to do an authenticated request to the server.
// The JSON also contains an "expires_in" field in seconds,
// which you can use to know when you need request a new Access token.
let response_json = await response.json();
const { access_token: accessToken } = response_json;
const { expires_in : expiresIn } = response_json;
const token_now = getCurrentTimeInSeconds();
await setAccessToken(this, [accessToken]);
await setAccessTokenReceiveTime(this, [token_now]);
await setAccessTokenValidDuration(this, [expiresIn]);
this.log.debug("Access Token expires in " + String(expiresIn) + " seconds.");
authFetch = await buildAuthenticatedFetch(accessToken, { dpopKey });
});
/**
* This function checks the access token's expiration and authenticates a single time if the token has expired.
* If the token succeeds validation at any point, the function returns true immediately.
* If the token is still failing validation after an authenticate() call, the function returns a false.
*/
const autoAuth = krl.Action([], async function() : Promise<Boolean> {
this.log.debug("Automatically authenticating...");
let is_valid = await hasValidAccessToken(this, []);
if (is_valid) {
return true;
}
await authenticate(this, []);
is_valid = await hasValidAccessToken(this, []);
if (is_valid) {
return true;
}
return false;
});
const connectStorage = krl.Action(["storageURL", "clientID", "clientSecret", "tokenURL"],
async function(
storageURL : string,
clientID : string,
clientSecret : string,
tokenURL : string) {
if (await isStorageConnected(this, [])) {
throw MODULE_NAME + ":connectStorage cannot connect an already-connected Pico.";
}
await setStorage(this, [storageURL]);
await setClientID(this, [clientID]);
await setClientSecret(this, [clientSecret]);
await setRefreshTokenURL(this, [tokenURL]);
await authenticate(this, []);
if (!await hasValidAccessToken(this, [])) {
await disconnectStorage(this, []);
throw MODULE_NAME + ":authenticate could not authenticate.";
}
return getStorage(this, []);
});
const disconnectStorage = krl.Action([], async function() {
if (!await isStorageConnected(this, [])) {
throw MODULE_NAME + ":disconnectStorage cannot disconnect an unconnected Pico.";
}
await setStorage(this, [undefined]);
await setClientID(this, [undefined]);
await setClientSecret(this, [undefined]);
await setRefreshTokenURL(this, [undefined]);
await setAccessToken(this, [undefined]);
await setAccessTokenReceiveTime(this, [undefined]);
await setAccessTokenValidDuration(this, [undefined]);
return "Disconnected successfully.";
});
/**
* Stores a file in the connected Pod storage if the given Storage's directory to the file
* already exists and the file does not already exist.
* @param originURL A required parameter for the location that the file is loaded into memory from. Must be an absolute url.
* @param destinationURL A required parameter for the location in the Pod to store the file in. Must be an absolute url.
* @param fileName An optional parameter for setting the file's name when it is stored in the Pod storage.
*/
const store = krl.Action(["originURL", "destinationURL", "doAutoAuth"],
async function(
originURL : string,
destinationURL : string,
doAutoAuth : Boolean = true
) {
const FUNCTION_NAME = "store";
if (!await isStorageConnected(this, [])) {
throw MODULE_NAME + ":" + FUNCTION_NAME + " needs a Pod to be connected.";
}
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":" + FUNCTION_NAME + " could not validate Pod access token.";
}
}
let file : File = await getNonPodFile(this, [originURL, destinationURL, FUNCTION_NAME])
let newDestinationURL : string = getDestinationURLWithoutFileName(destinationURL);
this.log.debug("Destination: " + newDestinationURL);
saveFileInContainer(
newDestinationURL,
file,
{ fetch: authFetch }
)
.then(() => {
this.log.debug("File uploaded successfully!\n");
})
.catch(error => {
this.log.error("Error uploading file: ", error.message);
});
});
const overwrite = krl.Action(["originURL", "destinationURL", "doAutoAuth"],
async function(
originURL : string,
destinationURL : string,
doAutoAuth : Boolean = true
) {
const FUNCTION_NAME = "overwrite";
if (!await isStorageConnected(this, [])) {
throw MODULE_NAME + ":" + FUNCTION_NAME + " needs a Pod to be connected.";
}
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":" + FUNCTION_NAME + " could not validate Pod access token.";
}
}
let file : File = await getNonPodFile(this, [originURL, destinationURL, FUNCTION_NAME]);
this.log.debug("Destination: " + destinationURL);
overwriteFile(
destinationURL,
file,
{ fetch: authFetch }
)
.then(() => {
this.log.debug("File uploaded successfully!\n");
})
.catch(error => {
this.log.error("Error uploading file: ", error.message);
});
});
const getNonPodFile = krl.Action(["originURL", "destinationURL", "functionName"],
async function(originURL : string, destinationURL : string, functionName : string) : Promise<File> {
let file : File;
let blob : Blob = await getBlob(originURL);
file = await createFileObject(blob, destinationURL, functionName);
return file;
});
function getDestinationURLWithoutFileName(destinationURL : string) : string {
//(Rushed) code to keep functions consistent and have file names at the end of destination URLs.
let fS_filename : string | undefined = destinationURL.split("/").pop();
let bS_filename : string | undefined = destinationURL.split("\\").pop();
let newDestinationURL : string = destinationURL;
if (typeof fS_filename === "undefined" && typeof bS_filename === "undefined") {
newDestinationURL = destinationURL;
} else if (typeof fS_filename === "undefined" || fS_filename.length == 0) {
let destArray : Array<string> = destinationURL.split("\\");
destArray.pop();
newDestinationURL = <string>destArray.join("\\");
} else if (typeof bS_filename === "undefined" || bS_filename.length == 0) {
let destArray : Array<string> = destinationURL.split("/");
destArray.pop();
newDestinationURL = <string>destArray.join("/");
} else if (fS_filename.length > bS_filename.length) {
let destArray : Array<string> = destinationURL.split("\\");
destArray.pop();
newDestinationURL = <string>destArray.join("\\");
} else {
let destArray : Array<string> = destinationURL.split("/");
destArray.pop();
newDestinationURL = <string>destArray.join("/");
}
newDestinationURL = newDestinationURL + "/";
return newDestinationURL;
}
const removeFile = krl.Action(["fileURL", "doAutoAuth"], async function(fileURL : string,
doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":removeFile could not validate Pod access token.";
}
}
await deleteFile(fileURL, { fetch: authFetch });
this.log.debug('File deleted successfully!\n');
});
const copyFile = krl.Action(["originURL", "destinationURL", "doAutoAuth"],
async function(originURL : string, destinationURL : string, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":copyFile could not validate Pod access token.";
}
}
try {
let file = await getFile(
originURL, // File in Pod to Read
{ fetch: authFetch } // fetch from authenticated session
);
this.log.debug( `Fetched a ${getContentType(file)} file from ${getSourceUrl(file)}.`);
this.log.debug(`The file is ${isRawData(file) ? "not " : ""}a dataset.`);
if (destinationURL.startsWith('http://') || destinationURL.startsWith('https://')) {
let newDestinationURL = getDestinationURLWithoutFileName(destinationURL);
this.log.debug("Destination: " + newDestinationURL);
let newFile = await createFileObject(file, destinationURL, "copyFile");
saveFileInContainer(
newDestinationURL,
newFile,
{ fetch: authFetch }
)
.then(() => {
this.log.debug(`File copied to ${newDestinationURL} successfully!\n`);
})
.catch(error => {
this.log.error("Error copying file:", error);
});
} else {
const arrayBuffer = await file.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
// Writing the buffer to a file
fs.writeFile(destinationURL, buffer, (err : Error | null) => {
if (err) {
this.log.error('Failed to save the file:', err);
} else {
this.log.debug('File saved successfully.');
}
});
}
} catch(err) {
this.log.error((err as Error).message);
};
});
const pods_fetch = krl.Function(["fileURL", "doAutoAuth"], async function(fileURL : string, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":fetch could not validate Pod access token.";
}
}
let file = await getFile(
fileURL,
{ fetch: authFetch }
)
this.log.debug(`Fetched a ${getContentType(file)} file from ${getSourceUrl(file)}.`);
this.log.debug(`The file is ${isRawData(file) ? "not " : ""}a dataset.`);
this.log.debug(file + '\n');
const arrayBuffer = await file.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const base64String = buffer.toString('base64');
const dataUrl = `data:${getContentType(file)};base64,${base64String}`;
return dataUrl;
});
const listItems = krl.Function(["folderURL", "doAutoAuth"], async function(fileURL : string, doAutoAuth : Boolean = true) {
if ((fileURL != '') && (!fileURL.endsWith('/'))) {
throw MODULE_NAME + ":listItems can only be called on folders (AKA containers). Ensure that folders have their trailing slash."
}
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":listItems could not validate Pod access token.";
}
}
let dataset;
try {
dataset = await getSolidDataset(fileURL, { fetch: authFetch });
let containedResources = getContainedResourceUrlAll(dataset)
let directory : string[] = [];
for (let i = 0; i < containedResources.length; i++) {
let resource = containedResources[i]
let item = resource.substring(fileURL.length, resource.length);
directory.push(item);
}
for (let i = 0; i < directory.length; i++) {
this.log.debug(directory[i]);
}
return directory;
} catch (e) {
this.log.error((e as Error).message);
}
});
const findFile = krl.Function(["fileName", "doAutoAuth"], async function (fileName : string, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":findFile could not validate Pod access token.";
}
}
// first item: get the root directory
let baseURL = await getStorage(this, [])
let directory = await listItems(this, [baseURL]);
let queue : string[][] = [];
queue.push(directory);
let urls : string[] = []
urls.push(baseURL);
// using a breadth-first search, only on directories
// each directory, when listed, returns an array (or undefined)
while (queue.length > 0) {
let dir = queue.shift();
let url = urls.shift();
// check if directory has the file
if (dir?.includes(fileName)) {
return url;
}
// go through each subdirectory and enqueue all of them
if (dir != undefined) {
for (let i = 0; i < dir?.length; i++) {
let subdir = dir[i];
if (subdir.endsWith('/')) {
let nextItem = await listItems(this, [url + subdir]);
queue.push(nextItem);
urls.push(url + subdir)
}
}
}
}
// not found
return null;
});
const createFolder = krl.Action(["folderURL", "doAutoAuth"], async function(folderURL : string, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":createFolder could not validate Pod access token.";
}
}
await createContainerAt(folderURL, { fetch: authFetch});
this.log.debug('Container created successfully!\n');
});
const removeFolder = krl.Action(["folderURL", "doAutoAuth"], async function(folderURL : string, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":removeFolder could not validate Pod access token.";
}
}
await deleteContainer(folderURL, { fetch: authFetch});
this.log.debug('Container deleted successfully!\n');
});
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)) {
console.log(`For resource::: ${resourceURL}`);
agents.push(agent);
if (agentAccess === null) {
console.log(`Could not load ${agent}'s access details.`);
} else {
console.log(`${agent}'s Access:: ${JSON.stringify(agentAccess)}`);
}
}
return agents;
});
const setAgentAccess = krl.Action(["resourceURL", "webID", "read", "write", "append", "doAutoAuth"],
async function(resourceURL : string, webID : string, read : boolean, write : boolean = false, append : boolean = false, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":grantAgentAccess could not validate Pod access token.";
}
}
universalAccess.setAgentAccess(
resourceURL, // resource
webID, // agent
{ read: read, write: write, append: append },
{ fetch: authFetch } // fetch function from authenticated session
).then((agentAccess) => {
this.log.debug(`For resource::: ${resourceURL}`);
if (agentAccess === null) {
this.log.debug(`Could not load ${webID}'s access details.`);
} else {
this.log.debug(`${webID}'s Access:: ${JSON.stringify(agentAccess)}`);
}
});
});
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.");
} else {
console.log("Returned Public Access:: ", JSON.stringify(access));
return JSON.stringify(access.read);
}
});
const setPublicAccess = krl.Action(["resourceURL", "read", "write", "append", "doAutoAuth"],
async function(resourceURL: string, read : boolean, write : boolean = false, append : boolean = false, doAutoAuth : Boolean = true) {
if (doAutoAuth) {
if (!await autoAuth(this, [])) {
throw MODULE_NAME + ":grantPublicAccess could not validate Pod access token.";
}
}
universalAccess.setPublicAccess(
resourceURL, // Resource
{ read: read, write: write, append: append }, // Access object
{ fetch: authFetch } // fetch function from authenticated session
).then((newAccess) => {
if (newAccess === null) {
this.log.debug("Could not load access details for this Resource.");
} else {
this.log.debug("Returned Public Access:: ", JSON.stringify(newAccess));
}
});
});
const pods: krl.Module = {
connectStorage: connectStorage,
disconnectStorage: disconnectStorage,
isStorageConnected: isStorageConnected,
hasValidAccessToken: hasValidAccessToken,
store: store,
overwrite: overwrite,
removeFile: removeFile,
copyFile: copyFile,
fetch: pods_fetch,
listItems: listItems,
findFile: findFile,
createFolder: createFolder,
removeFolder: removeFolder,
//The following are helper functions that are exported for testing
getStorage : getStorage, //Private KRL helper function, does not need to be exported but may be useful for the developer
// setStorage : setStorage, //Private KRL helper function, does not need to be exported
// setClientID: setClientID, //Private KRL helper function, does not need to be exported
// setClientSecret: setClientSecret, //Private KRL helper function, does not need to be exported
// setRefreshTokenURL: setRefreshTokenURL, //Private KRL helper function, does not need to be exported
getAccessTokenValidDuration : getAccessTokenValidDuration, //Mostly private KRL helper function, but exported since developer may want to know about the token
getAccessTokenReceiveTime : getAccessTokenReceiveTime, //Mostly private KRL helper function, but exported since developer may want to know about the token
authenticate: authenticate,
getAllAgentAccess: getAllAgentAccess,
setAgentAccess: setAgentAccess,
getPublicAccess: getPublicAccess,
setPublicAccess: setPublicAccess,
}
export default pods;