Skip to content

fix(web): detect secure context for subtle crypto#262

Open
HamdaanAliQuatil wants to merge 1 commit intomasterfrom
detect-secure-context
Open

fix(web): detect secure context for subtle crypto#262
HamdaanAliQuatil wants to merge 1 commit intomasterfrom
detect-secure-context

Conversation

@HamdaanAliQuatil
Copy link
Copy Markdown
Collaborator

closes #159

Copy link
Copy Markdown
Member

@jonasfj jonasfj left a comment

Choose a reason for hiding this comment

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

Minor improvement, but let's consider putting the logic into the subtle getter

Comment on lines +66 to +67
@JS('subtle')
external JSSubtleCrypto? get subtleOrNull;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@JS('subtle')
external JSSubtleCrypto? get subtleOrNull;
@JS('subtle')
external JSSubtleCrypto? get _subtleOrNull;
JSSubtleCrypto get subtle => requireSubtleCrypto();

Then we don't need to refactor the rest of the code.

We can even make _requireSubtleCrypto a private function, or inline it inside the subtle getter.

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.

Better detection of when window.crypto.subtle works (detection of secure context)

2 participants