Skip to content

[OCG] Fix: capture app does not work in http hosts#5

Open
nshandra wants to merge 4 commits intoversion-105.5.2-ocgfrom
fix/ocg-install-issues
Open

[OCG] Fix: capture app does not work in http hosts#5
nshandra wants to merge 4 commits intoversion-105.5.2-ocgfrom
fix/ocg-install-issues

Conversation

@nshandra
Copy link
Copy Markdown

@nshandra nshandra commented Jan 25, 2026

References

Issue: [1348] Capture App - Try to install 102, 103 or 104

Description

Capture app does not work properly with non-localhost http hosts. When starting it only shows:

The application could not be loaded. A possible reason for this is that the browser or mode (e.g. privacy mode) is not supported. See log for details.

This was caused by the use of module window.crypto to generate a hash, but it only works in secure contexts.
A exception handler was added to use a fallback library (js-sha256) in case the context is deemed not secure.

Incidentally this also allows the app to work in private/incognito mode.

…ure context (http non localhost sites). Additionally allows to use the app in private mode.
@nshandra nshandra requested a review from adrianq January 25, 2026 20:35
@nshandra nshandra self-assigned this Jan 25, 2026
@nshandra nshandra changed the title Fix/ocg install issues [OCG] Fix: capture app does not work in http hosts Jan 26, 2026
@nshandra nshandra changed the base branch from master to version-105.5.2-ocg January 26, 2026 08:01
@nshandra nshandra marked this pull request as ready for review January 26, 2026 08:01
@adrianq adrianq requested a review from tokland January 26, 2026 08:36
Copy link
Copy Markdown

@tokland tokland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, it worked also for me. (It’s good to know that this was also the source of the issue with incognito windows!)

Just some minor implementation details:

Comment thread package.json Outdated
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-ui-rich-text": "^7.4.0",
"@dhis2/rule-engine": "^3.4.1",
"@dhis2/rules-engine-javascript": "105.5.2",
Copy link
Copy Markdown

@tokland tokland Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s nice to have the entries sorted, but since this is a patching fork, I’d keep it as close to upstream as possible to make future merges easier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, package was auto sorted by yarn when i added js-sha256 but i see the point.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, yarn started doing this automatically at some version.

return hashArray.map(byte => byte.toString(16).padStart(2, '0')).join('');
} catch (error) {
return sha256(input);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/catch can mask other problems of the block.

What about using a conditional that checks if we have window.crypto.subtle?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try/catch seemed more "elegant" but its true it can mask other issues.
Changed and added a console.warn.

Copy link
Copy Markdown

@tokland tokland Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your point ("whatever goes wrong here, use this as a fallback") was also valid, so it's just about having more control when things go wrong.

@nshandra nshandra requested a review from tokland January 26, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants