@patch-adams/core 1.4.16 → 1.4.18
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 +34 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +34 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +37 -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 +37 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -408,6 +416,8 @@ function generateLrsBridgeCode(options) {
|
|
|
408
416
|
var COURSE_HOMEPAGE = '${courseHomepage}';
|
|
409
417
|
var AUTO_DETECT_LRS = ${options.autoDetectLrs ?? true};
|
|
410
418
|
var EMPLOYEE_API_ENDPOINT = '${employeeApiEndpoint}';
|
|
419
|
+
var LRS_AUTH = '${lrsAuth}';
|
|
420
|
+
var LRS_PROXY_ENDPOINT = '${lrsProxyEndpoint}';
|
|
411
421
|
|
|
412
422
|
// Bravais LRS endpoint pattern: https://lrs-{tenant}.bravais.com/XAPI/statements
|
|
413
423
|
// Example: core-acme.bravais.com -> lrs-acme.bravais.com
|
|
@@ -2837,24 +2847,41 @@ function generateLrsBridgeCode(options) {
|
|
|
2837
2847
|
}
|
|
2838
2848
|
|
|
2839
2849
|
function sendViaDirectLRS(statement) {
|
|
2850
|
+
// Use proxy endpoint if configured, otherwise direct LRS
|
|
2851
|
+
var useProxy = LRS_PROXY_ENDPOINT && LRS_PROXY_ENDPOINT.length > 0;
|
|
2852
|
+
var endpoint = useProxy ? LRS_PROXY_ENDPOINT : LRS_ENDPOINT;
|
|
2853
|
+
|
|
2854
|
+
if (!endpoint || endpoint.length === 0) {
|
|
2855
|
+
warn('No LRS endpoint available');
|
|
2856
|
+
LRS.stats.statementsFailed++;
|
|
2857
|
+
return Promise.reject(new Error('No LRS endpoint'));
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2840
2860
|
return new Promise(function(resolve, reject) {
|
|
2841
2861
|
var xhr = new XMLHttpRequest();
|
|
2842
|
-
|
|
2862
|
+
// POST to proxy (proxy handles PUT to LRS), POST to direct LRS
|
|
2863
|
+
xhr.open('POST', endpoint, true);
|
|
2843
2864
|
|
|
2844
|
-
// xAPI required headers
|
|
2865
|
+
// xAPI required headers
|
|
2845
2866
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
2846
2867
|
xhr.setRequestHeader('X-Experience-API-Version', '1.0');
|
|
2847
2868
|
|
|
2848
|
-
if (
|
|
2869
|
+
if (useProxy) {
|
|
2870
|
+
// Proxy handles auth server-side, no auth headers needed
|
|
2871
|
+
log('Sending via LRS proxy:', endpoint);
|
|
2872
|
+
} else if (LRS_AUTH && LRS_AUTH.length > 0) {
|
|
2873
|
+
xhr.setRequestHeader('Authorization', 'Basic ' + LRS_AUTH);
|
|
2874
|
+
log('Using Basic Auth for LRS request');
|
|
2875
|
+
} else if (LRS_WITH_CREDENTIALS) {
|
|
2849
2876
|
xhr.withCredentials = true;
|
|
2850
2877
|
}
|
|
2851
2878
|
|
|
2852
2879
|
xhr.onreadystatechange = function() {
|
|
2853
2880
|
if (xhr.readyState === 4) {
|
|
2854
2881
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
2855
|
-
log('Statement sent successfully:', statement.verb.display['en-US']);
|
|
2882
|
+
log('Statement sent successfully:', statement.verb.display['en-US'], useProxy ? '(via proxy)' : '(direct)');
|
|
2856
2883
|
LRS.stats.statementsSent++;
|
|
2857
|
-
resolve({ sent: true, via: 'directLRS', status: xhr.status });
|
|
2884
|
+
resolve({ sent: true, via: useProxy ? 'proxy' : 'directLRS', status: xhr.status });
|
|
2858
2885
|
} else {
|
|
2859
2886
|
warn('Statement send failed:', xhr.status, xhr.statusText);
|
|
2860
2887
|
LRS.stats.statementsFailed++;
|
|
@@ -4200,7 +4227,9 @@ function buildJsBeforeOptions(config, metadata) {
|
|
|
4200
4227
|
lrsEndpoint: lrsBridgeConfig.lrsEndpoint,
|
|
4201
4228
|
lrsWithCredentials: lrsBridgeConfig.lrsWithCredentials,
|
|
4202
4229
|
courseHomepage: lrsBridgeConfig.courseHomepage,
|
|
4203
|
-
autoDetectLrs: lrsBridgeConfig.autoDetectLrs
|
|
4230
|
+
autoDetectLrs: lrsBridgeConfig.autoDetectLrs,
|
|
4231
|
+
lrsAuth: lrsBridgeConfig.lrsAuth,
|
|
4232
|
+
lrsProxyEndpoint: lrsBridgeConfig.lrsProxyEndpoint
|
|
4204
4233
|
};
|
|
4205
4234
|
return {
|
|
4206
4235
|
remoteUrl: `${config.remoteDomain}/${config.localFolders.js}/${config.jsBefore.filename}`,
|