@patch-adams/core 1.4.19 → 1.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +62 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +62 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +62 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,9 @@ var LrsBridgeConfigSchema = zod.z.object({
|
|
|
43
43
|
/** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
|
|
44
44
|
lrsAuth: zod.z.string().optional(),
|
|
45
45
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
46
|
-
lrsProxyEndpoint: zod.z.string().optional()
|
|
46
|
+
lrsProxyEndpoint: zod.z.string().optional(),
|
|
47
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
48
|
+
employeeApiEndpoint: zod.z.string().optional()
|
|
47
49
|
});
|
|
48
50
|
var BlockingAssetConfigSchema = zod.z.object({
|
|
49
51
|
/** Filename for the asset */
|
|
@@ -1278,12 +1280,32 @@ function generateLrsBridgeCode(options) {
|
|
|
1278
1280
|
return;
|
|
1279
1281
|
}
|
|
1280
1282
|
|
|
1281
|
-
//
|
|
1283
|
+
// In-memory cache check
|
|
1282
1284
|
if (employeeLookupFetched && employeeLookupData) {
|
|
1283
1285
|
callback(employeeLookupData);
|
|
1284
1286
|
return;
|
|
1285
1287
|
}
|
|
1286
1288
|
|
|
1289
|
+
// localStorage cache check (persists across page loads / sessions)
|
|
1290
|
+
var cacheKey = 'pa_employee_' + employeeId;
|
|
1291
|
+
try {
|
|
1292
|
+
var cached = localStorage.getItem(cacheKey);
|
|
1293
|
+
if (cached) {
|
|
1294
|
+
var parsed = JSON.parse(cached);
|
|
1295
|
+
// TTL: 7 days = 604800000 ms
|
|
1296
|
+
if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000) {
|
|
1297
|
+
log('Employee data from localStorage cache');
|
|
1298
|
+
employeeLookupData = parsed;
|
|
1299
|
+
employeeLookupFetched = true;
|
|
1300
|
+
callback(parsed);
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
localStorage.removeItem(cacheKey);
|
|
1304
|
+
}
|
|
1305
|
+
} catch (e) {
|
|
1306
|
+
// localStorage unavailable (private browsing, iframe restrictions)
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1287
1309
|
// Build URL: endpoint should end with ? or include query param structure
|
|
1288
1310
|
var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
|
|
1289
1311
|
log('Fetching employee data from:', apiUrl);
|
|
@@ -1315,6 +1337,14 @@ function generateLrsBridgeCode(options) {
|
|
|
1315
1337
|
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1316
1338
|
};
|
|
1317
1339
|
log('Parsed employee data:', employeeLookupData);
|
|
1340
|
+
// Persist to localStorage for cross-session caching
|
|
1341
|
+
try {
|
|
1342
|
+
var cacheData = {};
|
|
1343
|
+
for (var k in employeeLookupData) { if (employeeLookupData.hasOwnProperty(k)) cacheData[k] = employeeLookupData[k]; }
|
|
1344
|
+
cacheData.timestamp = Date.now();
|
|
1345
|
+
localStorage.setItem(cacheKey, JSON.stringify(cacheData));
|
|
1346
|
+
log('Employee data cached in localStorage');
|
|
1347
|
+
} catch (e) { /* localStorage unavailable */ }
|
|
1318
1348
|
callback(employeeLookupData);
|
|
1319
1349
|
} else {
|
|
1320
1350
|
callback(null);
|
|
@@ -3259,6 +3289,34 @@ function generateLrsBridgeCode(options) {
|
|
|
3259
3289
|
sendStatement(statement);
|
|
3260
3290
|
};
|
|
3261
3291
|
|
|
3292
|
+
/**
|
|
3293
|
+
* Re-extract actor from SCORM after LMSInitialize has been called.
|
|
3294
|
+
* Call this from the SCORM wrapper after scormInit() succeeds,
|
|
3295
|
+
* because the bridge initializes in <head> before LMSInitialize runs.
|
|
3296
|
+
*/
|
|
3297
|
+
LRS.refreshActor = function(callback) {
|
|
3298
|
+
log('refreshActor called - re-extracting from SCORM...');
|
|
3299
|
+
var previousName = LRS.actor ? LRS.actor.name : 'none';
|
|
3300
|
+
|
|
3301
|
+
// Re-run sync extraction (SCORM data should now be available)
|
|
3302
|
+
var newActor = extractActor();
|
|
3303
|
+
|
|
3304
|
+
if (isValidActor(newActor) && newActor.account && newActor.account.name !== 'unknown') {
|
|
3305
|
+
log('refreshActor: got valid actor:', newActor.name, newActor.account ? newActor.account.name : '');
|
|
3306
|
+
// Enhance with email lookup (async)
|
|
3307
|
+
extractActorAsync(function(enhancedActor) {
|
|
3308
|
+
if (window.console && window.console.info) {
|
|
3309
|
+
console.info('[PA-LRS] Actor refreshed: ' + previousName + ' -> ' + enhancedActor.name +
|
|
3310
|
+
(enhancedActor.mbox ? ' (' + enhancedActor.mbox + ')' : ''));
|
|
3311
|
+
}
|
|
3312
|
+
if (callback) callback(enhancedActor);
|
|
3313
|
+
});
|
|
3314
|
+
} else {
|
|
3315
|
+
log('refreshActor: no valid actor found after re-extraction');
|
|
3316
|
+
if (callback) callback(LRS.actor);
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
|
|
3262
3320
|
// Course terminated/exited
|
|
3263
3321
|
LRS.courseTerminated = function() {
|
|
3264
3322
|
// Calculate duration
|
|
@@ -4263,7 +4321,8 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4263
4321
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4264
4322
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4265
4323
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4266
|
-
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4324
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4325
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4267
4326
|
};
|
|
4268
4327
|
return {
|
|
4269
4328
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|