@patch-adams/core 1.4.7 → 1.4.8
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 +35 -30
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +35 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +35 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1684,15 +1684,11 @@ function generateLrsBridgeCode(options) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
|
|
1686
1686
|
/**
|
|
1687
|
-
* Fetch document metadata from Bravais API to get GUIDs
|
|
1688
|
-
*
|
|
1687
|
+
* Fetch document metadata from Bravais shared API to get GUIDs
|
|
1688
|
+
* PRIMARY endpoint: /api/shared/{token}/documents (does NOT require auth)
|
|
1689
|
+
* FALLBACK endpoint: /api/v3/documents/{documentId} (requires auth)
|
|
1689
1690
|
*/
|
|
1690
|
-
function fetchDocumentMetadata(
|
|
1691
|
-
if (!documentId) {
|
|
1692
|
-
callback(null);
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1691
|
+
function fetchDocumentMetadata(documentIdOrToken, callback) {
|
|
1696
1692
|
if (documentApiFetched) {
|
|
1697
1693
|
callback(documentApiData);
|
|
1698
1694
|
return;
|
|
@@ -1706,8 +1702,24 @@ function generateLrsBridgeCode(options) {
|
|
|
1706
1702
|
return;
|
|
1707
1703
|
}
|
|
1708
1704
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1705
|
+
// Determine which endpoint to use
|
|
1706
|
+
// If we have a shared link token, use /api/shared/{token}/documents (no auth required)
|
|
1707
|
+
// This is the same endpoint Xyleme Cloud Player uses
|
|
1708
|
+
var sharedToken = LRS.courseInfo ? LRS.courseInfo.sharedLinkToken : null;
|
|
1709
|
+
var apiUrl;
|
|
1710
|
+
|
|
1711
|
+
if (sharedToken) {
|
|
1712
|
+
apiUrl = coreUrl + '/api/shared/' + sharedToken + '/documents';
|
|
1713
|
+
log('Fetching document via shared API (no auth required):', apiUrl);
|
|
1714
|
+
} else if (documentIdOrToken) {
|
|
1715
|
+
apiUrl = coreUrl + '/api/v3/documents/' + documentIdOrToken;
|
|
1716
|
+
log('Fetching document via v3 API (requires auth):', apiUrl);
|
|
1717
|
+
} else {
|
|
1718
|
+
log('No shared token or document ID available for metadata fetch');
|
|
1719
|
+
documentApiFetched = true;
|
|
1720
|
+
callback(null);
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1711
1723
|
|
|
1712
1724
|
var xhr = new XMLHttpRequest();
|
|
1713
1725
|
xhr.open('GET', apiUrl, true);
|
|
@@ -3642,32 +3654,25 @@ function generateLrsBridgeCode(options) {
|
|
|
3642
3654
|
}
|
|
3643
3655
|
|
|
3644
3656
|
if (!LRS.courseInfo.guid) {
|
|
3645
|
-
//
|
|
3646
|
-
//
|
|
3657
|
+
// When we have a shared link token, use /api/shared/{token}/documents directly
|
|
3658
|
+
// This endpoint does NOT require authentication and returns both document GUID and version GUID
|
|
3647
3659
|
if (sharedLinkToken) {
|
|
3648
|
-
log('
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
LRS.courseInfo.sharedLinkName = linkData.documentName;
|
|
3660
|
+
log('Have shared link token, fetching document data via shared API...');
|
|
3661
|
+
// fetchDocumentMetadata will use /api/shared/{token}/documents when sharedLinkToken is present
|
|
3662
|
+
fetchDocumentMetadata(null, function(docData) {
|
|
3663
|
+
if (docData) {
|
|
3664
|
+
updateCourseInfoFromApi(docData);
|
|
3665
|
+
// Also update document name if available
|
|
3666
|
+
if (docData.name) {
|
|
3667
|
+
LRS.courseInfo.sharedLinkName = docData.name;
|
|
3657
3668
|
}
|
|
3658
|
-
fetchDocDataAndSend(linkData.documentId);
|
|
3659
|
-
} else if (documentId) {
|
|
3660
|
-
// Fallback to extracted document ID (may be thin pack ID)
|
|
3661
|
-
warn('Could not get document ID from shared link, using extracted ID:', documentId);
|
|
3662
|
-
fetchDocDataAndSend(documentId);
|
|
3663
3669
|
} else {
|
|
3664
|
-
|
|
3665
|
-
warn('No document ID available - statements may fail aggregation');
|
|
3666
|
-
setTimeout(sendLaunchEvents, 100);
|
|
3670
|
+
warn('Could not fetch document data from shared API - statements may fail aggregation');
|
|
3667
3671
|
}
|
|
3672
|
+
setTimeout(sendLaunchEvents, 100);
|
|
3668
3673
|
});
|
|
3669
3674
|
} else if (documentId) {
|
|
3670
|
-
// No shared link token, try with extracted document ID
|
|
3675
|
+
// No shared link token, try with extracted document ID (requires auth)
|
|
3671
3676
|
log('No shared link token, fetching document data with ID:', documentId);
|
|
3672
3677
|
fetchDocDataAndSend(documentId);
|
|
3673
3678
|
} else {
|