@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/index.d.cts CHANGED
@@ -28,6 +28,10 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
28
28
  courseHomepage: z.ZodOptional<z.ZodString>;
29
29
  /** Auto-detect Bravais LRS endpoint from parent frame URL (default: true) */
30
30
  autoDetectLrs: z.ZodDefault<z.ZodBoolean>;
31
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
32
+ lrsAuth: z.ZodOptional<z.ZodString>;
33
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
34
+ lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
31
35
  }, "strip", z.ZodTypeAny, {
32
36
  enabled: boolean;
33
37
  trackMedia: boolean;
@@ -40,6 +44,8 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
40
44
  autoDetectLrs: boolean;
41
45
  lrsEndpoint?: string | undefined;
42
46
  courseHomepage?: string | undefined;
47
+ lrsAuth?: string | undefined;
48
+ lrsProxyEndpoint?: string | undefined;
43
49
  }, {
44
50
  enabled?: boolean | undefined;
45
51
  trackMedia?: boolean | undefined;
@@ -52,6 +58,8 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
52
58
  lrsWithCredentials?: boolean | undefined;
53
59
  courseHomepage?: string | undefined;
54
60
  autoDetectLrs?: boolean | undefined;
61
+ lrsAuth?: string | undefined;
62
+ lrsProxyEndpoint?: string | undefined;
55
63
  }>;
56
64
  /**
57
65
  * Configuration for a blocking asset (CSS before, JS before)
@@ -215,6 +223,10 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
215
223
  courseHomepage: z.ZodOptional<z.ZodString>;
216
224
  /** Auto-detect Bravais LRS endpoint from parent frame URL (default: true) */
217
225
  autoDetectLrs: z.ZodDefault<z.ZodBoolean>;
226
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
227
+ lrsAuth: z.ZodOptional<z.ZodString>;
228
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
229
+ lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
218
230
  }, "strip", z.ZodTypeAny, {
219
231
  enabled: boolean;
220
232
  trackMedia: boolean;
@@ -227,6 +239,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
227
239
  autoDetectLrs: boolean;
228
240
  lrsEndpoint?: string | undefined;
229
241
  courseHomepage?: string | undefined;
242
+ lrsAuth?: string | undefined;
243
+ lrsProxyEndpoint?: string | undefined;
230
244
  }, {
231
245
  enabled?: boolean | undefined;
232
246
  trackMedia?: boolean | undefined;
@@ -239,6 +253,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
239
253
  lrsWithCredentials?: boolean | undefined;
240
254
  courseHomepage?: string | undefined;
241
255
  autoDetectLrs?: boolean | undefined;
256
+ lrsAuth?: string | undefined;
257
+ lrsProxyEndpoint?: string | undefined;
242
258
  }>>;
243
259
  /** Plugin configurations - each plugin is keyed by its name */
244
260
  plugins: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -291,6 +307,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
291
307
  autoDetectLrs: boolean;
292
308
  lrsEndpoint?: string | undefined;
293
309
  courseHomepage?: string | undefined;
310
+ lrsAuth?: string | undefined;
311
+ lrsProxyEndpoint?: string | undefined;
294
312
  };
295
313
  plugins: Record<string, z.objectOutputType<{
296
314
  /** Whether this plugin is enabled */
@@ -336,6 +354,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
336
354
  lrsWithCredentials?: boolean | undefined;
337
355
  courseHomepage?: string | undefined;
338
356
  autoDetectLrs?: boolean | undefined;
357
+ lrsAuth?: string | undefined;
358
+ lrsProxyEndpoint?: string | undefined;
339
359
  } | undefined;
340
360
  plugins?: Record<string, z.objectInputType<{
341
361
  /** Whether this plugin is enabled */
@@ -950,6 +970,10 @@ interface LrsBridgeOptions {
950
970
  autoDetectLrs?: boolean;
951
971
  /** Employee API endpoint for user lookup (e.g., https://node.example.com/admin_api/users/employees/) */
952
972
  employeeApiEndpoint?: string;
973
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
974
+ lrsAuth?: string;
975
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
976
+ lrsProxyEndpoint?: string;
953
977
  }
954
978
  declare const DEFAULT_LRS_OPTIONS: LrsBridgeOptions;
955
979
  /**
package/dist/index.d.ts CHANGED
@@ -28,6 +28,10 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
28
28
  courseHomepage: z.ZodOptional<z.ZodString>;
29
29
  /** Auto-detect Bravais LRS endpoint from parent frame URL (default: true) */
30
30
  autoDetectLrs: z.ZodDefault<z.ZodBoolean>;
31
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
32
+ lrsAuth: z.ZodOptional<z.ZodString>;
33
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
34
+ lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
31
35
  }, "strip", z.ZodTypeAny, {
32
36
  enabled: boolean;
33
37
  trackMedia: boolean;
@@ -40,6 +44,8 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
40
44
  autoDetectLrs: boolean;
41
45
  lrsEndpoint?: string | undefined;
42
46
  courseHomepage?: string | undefined;
47
+ lrsAuth?: string | undefined;
48
+ lrsProxyEndpoint?: string | undefined;
43
49
  }, {
44
50
  enabled?: boolean | undefined;
45
51
  trackMedia?: boolean | undefined;
@@ -52,6 +58,8 @@ declare const LrsBridgeConfigSchema: z.ZodObject<{
52
58
  lrsWithCredentials?: boolean | undefined;
53
59
  courseHomepage?: string | undefined;
54
60
  autoDetectLrs?: boolean | undefined;
61
+ lrsAuth?: string | undefined;
62
+ lrsProxyEndpoint?: string | undefined;
55
63
  }>;
56
64
  /**
57
65
  * Configuration for a blocking asset (CSS before, JS before)
@@ -215,6 +223,10 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
215
223
  courseHomepage: z.ZodOptional<z.ZodString>;
216
224
  /** Auto-detect Bravais LRS endpoint from parent frame URL (default: true) */
217
225
  autoDetectLrs: z.ZodDefault<z.ZodBoolean>;
226
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
227
+ lrsAuth: z.ZodOptional<z.ZodString>;
228
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
229
+ lrsProxyEndpoint: z.ZodOptional<z.ZodString>;
218
230
  }, "strip", z.ZodTypeAny, {
219
231
  enabled: boolean;
220
232
  trackMedia: boolean;
@@ -227,6 +239,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
227
239
  autoDetectLrs: boolean;
228
240
  lrsEndpoint?: string | undefined;
229
241
  courseHomepage?: string | undefined;
242
+ lrsAuth?: string | undefined;
243
+ lrsProxyEndpoint?: string | undefined;
230
244
  }, {
231
245
  enabled?: boolean | undefined;
232
246
  trackMedia?: boolean | undefined;
@@ -239,6 +253,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
239
253
  lrsWithCredentials?: boolean | undefined;
240
254
  courseHomepage?: string | undefined;
241
255
  autoDetectLrs?: boolean | undefined;
256
+ lrsAuth?: string | undefined;
257
+ lrsProxyEndpoint?: string | undefined;
242
258
  }>>;
243
259
  /** Plugin configurations - each plugin is keyed by its name */
244
260
  plugins: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -291,6 +307,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
291
307
  autoDetectLrs: boolean;
292
308
  lrsEndpoint?: string | undefined;
293
309
  courseHomepage?: string | undefined;
310
+ lrsAuth?: string | undefined;
311
+ lrsProxyEndpoint?: string | undefined;
294
312
  };
295
313
  plugins: Record<string, z.objectOutputType<{
296
314
  /** Whether this plugin is enabled */
@@ -336,6 +354,8 @@ declare const PatchAdamsConfigSchema: z.ZodObject<{
336
354
  lrsWithCredentials?: boolean | undefined;
337
355
  courseHomepage?: string | undefined;
338
356
  autoDetectLrs?: boolean | undefined;
357
+ lrsAuth?: string | undefined;
358
+ lrsProxyEndpoint?: string | undefined;
339
359
  } | undefined;
340
360
  plugins?: Record<string, z.objectInputType<{
341
361
  /** Whether this plugin is enabled */
@@ -950,6 +970,10 @@ interface LrsBridgeOptions {
950
970
  autoDetectLrs?: boolean;
951
971
  /** Employee API endpoint for user lookup (e.g., https://node.example.com/admin_api/users/employees/) */
952
972
  employeeApiEndpoint?: string;
973
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
974
+ lrsAuth?: string;
975
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
976
+ lrsProxyEndpoint?: string;
953
977
  }
954
978
  declare const DEFAULT_LRS_OPTIONS: LrsBridgeOptions;
955
979
  /**
package/dist/index.js CHANGED
@@ -31,7 +31,11 @@ var LrsBridgeConfigSchema = z.object({
31
31
  /** Course homepage IRI for xAPI context */
32
32
  courseHomepage: z.string().optional(),
33
33
  /** Auto-detect Bravais LRS endpoint from parent frame URL (default: true) */
34
- autoDetectLrs: z.boolean().default(true)
34
+ autoDetectLrs: z.boolean().default(true),
35
+ /** Basic auth credentials for LRS (Base64 encoded "username:password") - used when no cookie session exists */
36
+ lrsAuth: z.string().optional(),
37
+ /** LRS proxy endpoint URL - statements are sent here instead of direct LRS, proxy handles auth server-side */
38
+ lrsProxyEndpoint: z.string().optional()
35
39
  });
36
40
  var BlockingAssetConfigSchema = z.object({
37
41
  /** Filename for the asset */
@@ -374,7 +378,9 @@ var DEFAULT_LRS_OPTIONS = {
374
378
  lrsWithCredentials: true,
375
379
  courseHomepage: "",
376
380
  autoDetectLrs: true,
377
- employeeApiEndpoint: ""
381
+ employeeApiEndpoint: "",
382
+ lrsAuth: "",
383
+ lrsProxyEndpoint: ""
378
384
  };
379
385
  function generateLrsBridgeCode(options) {
380
386
  if (!options.enabled) {
@@ -386,6 +392,8 @@ function generateLrsBridgeCode(options) {
386
392
  const lrsEndpoint = options.lrsEndpoint || "";
387
393
  const courseHomepage = options.courseHomepage || "";
388
394
  const employeeApiEndpoint = options.employeeApiEndpoint || "";
395
+ const lrsAuth = options.lrsAuth || "";
396
+ const lrsProxyEndpoint = options.lrsProxyEndpoint || "";
389
397
  return `
390
398
  // ==========================================================================
391
399
  // PATCH-ADAMS LRS BRIDGE v2.2.0
@@ -398,6 +406,12 @@ function generateLrsBridgeCode(options) {
398
406
  'use strict';
399
407
 
400
408
  var DEBUG = ${options.debug};
409
+ // Allow URL-based debug toggle: ?pa_debug=1 or #pa_debug
410
+ try {
411
+ if (window.location.search.indexOf('pa_debug') > -1 || window.location.hash.indexOf('pa_debug') > -1) {
412
+ DEBUG = true;
413
+ }
414
+ } catch (e) {}
401
415
  var TRACK_MEDIA = ${options.trackMedia};
402
416
  var TRACK_NAVIGATION = ${options.trackNavigation};
403
417
  var TRACK_QUIZZES = ${options.trackQuizzes};
@@ -408,6 +422,8 @@ function generateLrsBridgeCode(options) {
408
422
  var COURSE_HOMEPAGE = '${courseHomepage}';
409
423
  var AUTO_DETECT_LRS = ${options.autoDetectLrs ?? true};
410
424
  var EMPLOYEE_API_ENDPOINT = '${employeeApiEndpoint}';
425
+ var LRS_AUTH = '${lrsAuth}';
426
+ var LRS_PROXY_ENDPOINT = '${lrsProxyEndpoint}';
411
427
 
412
428
  // Bravais LRS endpoint pattern: https://lrs-{tenant}.bravais.com/XAPI/statements
413
429
  // Example: core-acme.bravais.com -> lrs-acme.bravais.com
@@ -2767,6 +2783,17 @@ function generateLrsBridgeCode(options) {
2767
2783
  function sendStatement(statement) {
2768
2784
  log('Sending statement:', statement.verb.display['en-US'] || statement.verb.id, statement);
2769
2785
 
2786
+ // Log first statement visibly (not gated by DEBUG) for production diagnostics
2787
+ if (LRS.stats.statementsSent === 0 && LRS.stats.statementsFailed === 0 && LRS.stats.statementsQueued === 0) {
2788
+ if (window.console && window.console.info) {
2789
+ var verb = statement.verb.display ? (statement.verb.display['en-US'] || statement.verb.id) : statement.verb.id;
2790
+ console.info('[PA-LRS] First statement: verb=' + verb +
2791
+ ', endpoint=' + (LRS_ENDPOINT || 'NONE') +
2792
+ ', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
2793
+ ', mode=' + LRS.mode);
2794
+ }
2795
+ }
2796
+
2770
2797
  // Store in event log
2771
2798
  LRS.eventLog.push({
2772
2799
  statement: statement,
@@ -2837,24 +2864,41 @@ function generateLrsBridgeCode(options) {
2837
2864
  }
2838
2865
 
2839
2866
  function sendViaDirectLRS(statement) {
2867
+ // Use proxy endpoint if configured, otherwise direct LRS
2868
+ var useProxy = LRS_PROXY_ENDPOINT && LRS_PROXY_ENDPOINT.length > 0;
2869
+ var endpoint = useProxy ? LRS_PROXY_ENDPOINT : LRS_ENDPOINT;
2870
+
2871
+ if (!endpoint || endpoint.length === 0) {
2872
+ warn('No LRS endpoint available');
2873
+ LRS.stats.statementsFailed++;
2874
+ return Promise.reject(new Error('No LRS endpoint'));
2875
+ }
2876
+
2840
2877
  return new Promise(function(resolve, reject) {
2841
2878
  var xhr = new XMLHttpRequest();
2842
- xhr.open('POST', LRS_ENDPOINT, true);
2879
+ // POST to proxy (proxy handles PUT to LRS), POST to direct LRS
2880
+ xhr.open('POST', endpoint, true);
2843
2881
 
2844
- // xAPI required headers (Bravais LRS requires version 1.0)
2882
+ // xAPI required headers
2845
2883
  xhr.setRequestHeader('Content-Type', 'application/json');
2846
2884
  xhr.setRequestHeader('X-Experience-API-Version', '1.0');
2847
2885
 
2848
- if (LRS_WITH_CREDENTIALS) {
2886
+ if (useProxy) {
2887
+ // Proxy handles auth server-side, no auth headers needed
2888
+ log('Sending via LRS proxy:', endpoint);
2889
+ } else if (LRS_AUTH && LRS_AUTH.length > 0) {
2890
+ xhr.setRequestHeader('Authorization', 'Basic ' + LRS_AUTH);
2891
+ log('Using Basic Auth for LRS request');
2892
+ } else if (LRS_WITH_CREDENTIALS) {
2849
2893
  xhr.withCredentials = true;
2850
2894
  }
2851
2895
 
2852
2896
  xhr.onreadystatechange = function() {
2853
2897
  if (xhr.readyState === 4) {
2854
2898
  if (xhr.status >= 200 && xhr.status < 300) {
2855
- log('Statement sent successfully:', statement.verb.display['en-US']);
2899
+ log('Statement sent successfully:', statement.verb.display['en-US'], useProxy ? '(via proxy)' : '(direct)');
2856
2900
  LRS.stats.statementsSent++;
2857
- resolve({ sent: true, via: 'directLRS', status: xhr.status });
2901
+ resolve({ sent: true, via: useProxy ? 'proxy' : 'directLRS', status: xhr.status });
2858
2902
  } else {
2859
2903
  warn('Statement send failed:', xhr.status, xhr.statusText);
2860
2904
  LRS.stats.statementsFailed++;
@@ -3929,6 +3973,15 @@ function generateLrsBridgeCode(options) {
3929
3973
  LRS.mode = 'offline';
3930
3974
  }
3931
3975
 
3976
+ // Always-visible bridge summary (not gated by DEBUG)
3977
+ // This ensures diagnostics are available even in production builds
3978
+ if (window.console && window.console.info) {
3979
+ console.info('[PA-LRS] Bridge: mode=' + LRS.mode +
3980
+ ', endpoint=' + (LRS_ENDPOINT ? LRS_ENDPOINT.substring(0, 30) + '...' : 'NONE') +
3981
+ ', proxy=' + (LRS_PROXY_ENDPOINT ? 'yes' : 'no') +
3982
+ ', actor=' + (LRS.actor ? (LRS.actor.name || 'anonymous') : 'none'));
3983
+ }
3984
+
3932
3985
  // Set up event interceptors
3933
3986
  setupMediaInterceptors();
3934
3987
  setupNavigationInterceptors();
@@ -4200,7 +4253,9 @@ function buildJsBeforeOptions(config, metadata) {
4200
4253
  lrsEndpoint: lrsBridgeConfig.lrsEndpoint,
4201
4254
  lrsWithCredentials: lrsBridgeConfig.lrsWithCredentials,
4202
4255
  courseHomepage: lrsBridgeConfig.courseHomepage,
4203
- autoDetectLrs: lrsBridgeConfig.autoDetectLrs
4256
+ autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
4257
+ lrsAuth: lrsBridgeConfig.lrsAuth,
4258
+ lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
4204
4259
  };
4205
4260
  return {
4206
4261
  remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,