@patch-adams/core 1.4.16 → 1.4.19
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 +60 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +60 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +63 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +63 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -378,7 +378,11 @@ var LrsBridgeConfigSchema = z.object({
|
|
|
378
378
|
/** Course homepage IRI for xAPI context */
|
|
379
379
|
courseHomepage: z.string().optional(),
|
|
380
380
|
/** Auto-detect Bravais LRS endpoint from parent frame URL (default: true) */
|
|
381
|
-
autoDetectLrs: z.boolean().default(true)
|
|
381
|
+
autoDetectLrs: z.boolean().default(true),
|
|
382
|
+
/** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
|
|
383
|
+
lrsAuth: z.string().optional(),
|
|
384
|
+
/** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
|
|
385
|
+
lrsProxyEndpoint: z.string().optional()
|
|
382
386
|
});
|
|
383
387
|
var BlockingAssetConfigSchema = z.object({
|
|
384
388
|
/** Filename for the asset */
|
|
@@ -721,6 +725,8 @@ function generateLrsBridgeCode(options) {
|
|
|
721
725
|
const lrsEndpoint = options.lrsEndpoint || "";
|
|
722
726
|
const courseHomepage = options.courseHomepage || "";
|
|
723
727
|
const employeeApiEndpoint = options.employeeApiEndpoint || "";
|
|
728
|
+
const lrsAuth = options.lrsAuth || "";
|
|
729
|
+
const lrsProxyEndpoint = options.lrsProxyEndpoint || "";
|
|
724
730
|
return `
|
|
725
731
|
// ==========================================================================
|
|
726
732
|
// PATCH-ADAMS LRS BRIDGE v2.2.0
|
|
@@ -733,6 +739,12 @@ function generateLrsBridgeCode(options) {
|
|
|
733
739
|
'use strict';
|
|
734
740
|
|
|
735
741
|
var DEBUG = ${options.debug};
|
|
742
|
+
// Allow URL-based debug toggle: ?pa_debug=1 or #pa_debug
|
|
743
|
+
try {
|
|
744
|
+
if (window.location.search.indexOf('pa_debug') > -1 || window.location.hash.indexOf('pa_debug') > -1) {
|
|
745
|
+
DEBUG = true;
|
|
746
|
+
}
|
|
747
|
+
} catch (e) {}
|
|
736
748
|
var TRACK_MEDIA = ${options.trackMedia};
|
|
737
749
|
var TRACK_NAVIGATION = ${options.trackNavigation};
|
|
738
750
|
var TRACK_QUIZZES = ${options.trackQuizzes};
|
|
@@ -743,6 +755,8 @@ function generateLrsBridgeCode(options) {
|
|
|
743
755
|
var COURSE_HOMEPAGE = '${courseHomepage}';
|
|
744
756
|
var AUTO_DETECT_LRS = ${options.autoDetectLrs ?? true};
|
|
745
757
|
var EMPLOYEE_API_ENDPOINT = '${employeeApiEndpoint}';
|
|
758
|
+
var LRS_AUTH = '${lrsAuth}';
|
|
759
|
+
var LRS_PROXY_ENDPOINT = '${lrsProxyEndpoint}';
|
|
746
760
|
|
|
747
761
|
// Bravais LRS endpoint pattern: https://lrs-{tenant}.bravais.com/XAPI/statements
|
|
748
762
|
// Example: core-acme.bravais.com -> lrs-acme.bravais.com
|
|
@@ -3102,6 +3116,17 @@ function generateLrsBridgeCode(options) {
|
|
|
3102
3116
|
function sendStatement(statement) {
|
|
3103
3117
|
log('Sending statement:', statement.verb.display['en-US'] || statement.verb.id, statement);
|
|
3104
3118
|
|
|
3119
|
+
// Log first statement visibly (not gated by DEBUG) for production diagnostics
|
|
3120
|
+
if (LRS.stats.statementsSent === 0 && LRS.stats.statementsFailed === 0 && LRS.stats.statementsQueued === 0) {
|
|
3121
|
+
if (window.console && window.console.info) {
|
|
3122
|
+
var verb = statement.verb.display ? (statement.verb.display['en-US'] || statement.verb.id) : statement.verb.id;
|
|
3123
|
+
console.info('[PA-LRS] First statement: verb=' + verb +
|
|
3124
|
+
', endpoint=' + (LRS_ENDPOINT || 'NONE') +
|
|
3125
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
3126
|
+
', mode=' + LRS.mode);
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3105
3130
|
// Store in event log
|
|
3106
3131
|
LRS.eventLog.push({
|
|
3107
3132
|
statement: statement,
|
|
@@ -3172,24 +3197,41 @@ function generateLrsBridgeCode(options) {
|
|
|
3172
3197
|
}
|
|
3173
3198
|
|
|
3174
3199
|
function sendViaDirectLRS(statement) {
|
|
3200
|
+
// Use proxy endpoint if configured, otherwise direct LRS
|
|
3201
|
+
var useProxy = LRS_PROXY_ENDPOINT && LRS_PROXY_ENDPOINT.length > 0;
|
|
3202
|
+
var endpoint = useProxy ? LRS_PROXY_ENDPOINT : LRS_ENDPOINT;
|
|
3203
|
+
|
|
3204
|
+
if (!endpoint || endpoint.length === 0) {
|
|
3205
|
+
warn('No LRS endpoint available');
|
|
3206
|
+
LRS.stats.statementsFailed++;
|
|
3207
|
+
return Promise.reject(new Error('No LRS endpoint'));
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3175
3210
|
return new Promise(function(resolve, reject) {
|
|
3176
3211
|
var xhr = new XMLHttpRequest();
|
|
3177
|
-
|
|
3212
|
+
// POST to proxy (proxy handles PUT to LRS), POST to direct LRS
|
|
3213
|
+
xhr.open('POST', endpoint, true);
|
|
3178
3214
|
|
|
3179
|
-
// xAPI required headers
|
|
3215
|
+
// xAPI required headers
|
|
3180
3216
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
3181
3217
|
xhr.setRequestHeader('X-Experience-API-Version', '1.0');
|
|
3182
3218
|
|
|
3183
|
-
if (
|
|
3219
|
+
if (useProxy) {
|
|
3220
|
+
// Proxy handles auth server-side, no auth headers needed
|
|
3221
|
+
log('Sending via LRS proxy:', endpoint);
|
|
3222
|
+
} else if (LRS_AUTH && LRS_AUTH.length > 0) {
|
|
3223
|
+
xhr.setRequestHeader('Authorization', 'Basic ' + LRS_AUTH);
|
|
3224
|
+
log('Using Basic Auth for LRS request');
|
|
3225
|
+
} else if (LRS_WITH_CREDENTIALS) {
|
|
3184
3226
|
xhr.withCredentials = true;
|
|
3185
3227
|
}
|
|
3186
3228
|
|
|
3187
3229
|
xhr.onreadystatechange = function() {
|
|
3188
3230
|
if (xhr.readyState === 4) {
|
|
3189
3231
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
3190
|
-
log('Statement sent successfully:', statement.verb.display['en-US']);
|
|
3232
|
+
log('Statement sent successfully:', statement.verb.display['en-US'], useProxy ? '(via proxy)' : '(direct)');
|
|
3191
3233
|
LRS.stats.statementsSent++;
|
|
3192
|
-
resolve({ sent: true, via: 'directLRS', status: xhr.status });
|
|
3234
|
+
resolve({ sent: true, via: useProxy ? 'proxy' : 'directLRS', status: xhr.status });
|
|
3193
3235
|
} else {
|
|
3194
3236
|
warn('Statement send failed:', xhr.status, xhr.statusText);
|
|
3195
3237
|
LRS.stats.statementsFailed++;
|
|
@@ -4264,6 +4306,15 @@ function generateLrsBridgeCode(options) {
|
|
|
4264
4306
|
LRS.mode = 'offline';
|
|
4265
4307
|
}
|
|
4266
4308
|
|
|
4309
|
+
// Always-visible bridge summary (not gated by DEBUG)
|
|
4310
|
+
// This ensures diagnostics are available even in production builds
|
|
4311
|
+
if (window.console && window.console.info) {
|
|
4312
|
+
console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
|
|
4313
|
+
', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
|
|
4314
|
+
', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
|
|
4315
|
+
', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4267
4318
|
// Set up event interceptors
|
|
4268
4319
|
setupMediaInterceptors();
|
|
4269
4320
|
setupNavigationInterceptors();
|
|
@@ -4535,7 +4586,9 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4535
4586
|
lrsEndpoint: lrsBridgeConfig.lrsEndpoint,
|
|
4536
4587
|
lrsWithCredentials: lrsBridgeConfig.lrsWithCredentials,
|
|
4537
4588
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4538
|
-
autoDetectLrs: lrsBridgeConfig.autoDetectLrs
|
|
4589
|
+
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4590
|
+
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4591
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4539
4592
|
};
|
|
4540
4593
|
return {
|
|
4541
4594
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|