@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/cli.cjs
CHANGED
|
@@ -391,7 +391,9 @@ var LrsBridgeConfigSchema = zod.z.object({
|
|
|
391
391
|
/** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
|
|
392
392
|
lrsAuth: zod.z.string().optional(),
|
|
393
393
|
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
394
|
-
lrsProxyEndpoint: zod.z.string().optional()
|
|
394
|
+
lrsProxyEndpoint: zod.z.string().optional(),
|
|
395
|
+
/** Employee API endpoint URL for user identity lookup (e.g., https://node.example.com/admin_api/users/employees/) */
|
|
396
|
+
employeeApiEndpoint: zod.z.string().optional()
|
|
395
397
|
});
|
|
396
398
|
var BlockingAssetConfigSchema = zod.z.object({
|
|
397
399
|
/** Filename for the asset */
|
|
@@ -1612,12 +1614,32 @@ function generateLrsBridgeCode(options) {
|
|
|
1612
1614
|
return;
|
|
1613
1615
|
}
|
|
1614
1616
|
|
|
1615
|
-
//
|
|
1617
|
+
// In-memory cache check
|
|
1616
1618
|
if (employeeLookupFetched && employeeLookupData) {
|
|
1617
1619
|
callback(employeeLookupData);
|
|
1618
1620
|
return;
|
|
1619
1621
|
}
|
|
1620
1622
|
|
|
1623
|
+
// localStorage cache check (persists across page loads / sessions)
|
|
1624
|
+
var cacheKey = 'pa_employee_' + employeeId;
|
|
1625
|
+
try {
|
|
1626
|
+
var cached = localStorage.getItem(cacheKey);
|
|
1627
|
+
if (cached) {
|
|
1628
|
+
var parsed = JSON.parse(cached);
|
|
1629
|
+
// TTL: 7 days = 604800000 ms
|
|
1630
|
+
if (parsed.timestamp && (Date.now() - parsed.timestamp) < 604800000) {
|
|
1631
|
+
log('Employee data from localStorage cache');
|
|
1632
|
+
employeeLookupData = parsed;
|
|
1633
|
+
employeeLookupFetched = true;
|
|
1634
|
+
callback(parsed);
|
|
1635
|
+
return;
|
|
1636
|
+
}
|
|
1637
|
+
localStorage.removeItem(cacheKey);
|
|
1638
|
+
}
|
|
1639
|
+
} catch (e) {
|
|
1640
|
+
// localStorage unavailable (private browsing, iframe restrictions)
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1621
1643
|
// Build URL: endpoint should end with ? or include query param structure
|
|
1622
1644
|
var apiUrl = EMPLOYEE_API_ENDPOINT + (EMPLOYEE_API_ENDPOINT.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(employeeId);
|
|
1623
1645
|
log('Fetching employee data from:', apiUrl);
|
|
@@ -1649,6 +1671,14 @@ function generateLrsBridgeCode(options) {
|
|
|
1649
1671
|
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1650
1672
|
};
|
|
1651
1673
|
log('Parsed employee data:', employeeLookupData);
|
|
1674
|
+
// Persist to localStorage for cross-session caching
|
|
1675
|
+
try {
|
|
1676
|
+
var cacheData = {};
|
|
1677
|
+
for (var k in employeeLookupData) { if (employeeLookupData.hasOwnProperty(k)) cacheData[k] = employeeLookupData[k]; }
|
|
1678
|
+
cacheData.timestamp = Date.now();
|
|
1679
|
+
localStorage.setItem(cacheKey, JSON.stringify(cacheData));
|
|
1680
|
+
log('Employee data cached in localStorage');
|
|
1681
|
+
} catch (e) { /* localStorage unavailable */ }
|
|
1652
1682
|
callback(employeeLookupData);
|
|
1653
1683
|
} else {
|
|
1654
1684
|
callback(null);
|
|
@@ -3593,6 +3623,34 @@ function generateLrsBridgeCode(options) {
|
|
|
3593
3623
|
sendStatement(statement);
|
|
3594
3624
|
};
|
|
3595
3625
|
|
|
3626
|
+
/**
|
|
3627
|
+
* Re-extract actor from SCORM after LMSInitialize has been called.
|
|
3628
|
+
* Call this from the SCORM wrapper after scormInit() succeeds,
|
|
3629
|
+
* because the bridge initializes in <head> before LMSInitialize runs.
|
|
3630
|
+
*/
|
|
3631
|
+
LRS.refreshActor = function(callback) {
|
|
3632
|
+
log('refreshActor called - re-extracting from SCORM...');
|
|
3633
|
+
var previousName = LRS.actor ? LRS.actor.name : 'none';
|
|
3634
|
+
|
|
3635
|
+
// Re-run sync extraction (SCORM data should now be available)
|
|
3636
|
+
var newActor = extractActor();
|
|
3637
|
+
|
|
3638
|
+
if (isValidActor(newActor) && newActor.account && newActor.account.name !== 'unknown') {
|
|
3639
|
+
log('refreshActor: got valid actor:', newActor.name, newActor.account ? newActor.account.name : '');
|
|
3640
|
+
// Enhance with email lookup (async)
|
|
3641
|
+
extractActorAsync(function(enhancedActor) {
|
|
3642
|
+
if (window.console && window.console.info) {
|
|
3643
|
+
console.info('[PA-LRS] Actor refreshed: ' + previousName + ' -> ' + enhancedActor.name +
|
|
3644
|
+
(enhancedActor.mbox ? ' (' + enhancedActor.mbox + ')' : ''));
|
|
3645
|
+
}
|
|
3646
|
+
if (callback) callback(enhancedActor);
|
|
3647
|
+
});
|
|
3648
|
+
} else {
|
|
3649
|
+
log('refreshActor: no valid actor found after re-extraction');
|
|
3650
|
+
if (callback) callback(LRS.actor);
|
|
3651
|
+
}
|
|
3652
|
+
};
|
|
3653
|
+
|
|
3596
3654
|
// Course terminated/exited
|
|
3597
3655
|
LRS.courseTerminated = function() {
|
|
3598
3656
|
// Calculate duration
|
|
@@ -4597,7 +4655,8 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4597
4655
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4598
4656
|
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4599
4657
|
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4600
|
-
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4658
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint,
|
|
4659
|
+
employeeApiEndpoint: lrsBridgeConfig.employeeApiEndpoint
|
|
4601
4660
|
};
|
|
4602
4661
|
return {
|
|
4603
4662
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|