Skip to content

Commit

Permalink
Merge pull request #40 from iMi-digital/client-0-9-14
Browse files Browse the repository at this point in the history
Update to friendly-challenge from 0.9.9 to 0.9.14
  • Loading branch information
DanieliMi authored Mar 4, 2024
2 parents eae0220 + 2c74641 commit 2201927
Show file tree
Hide file tree
Showing 16 changed files with 637 additions and 558 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ IMI_FriendlyCaptcha adds a Friendly Captcha widget to:
## Security Scan

This module is accepted by the Magento security scan by Adobe, which normally looks for Google ReCAPTCHA, i.e. replacing the ReCAPTCHA with the Friendly Captcha should not trigger any false positives.

## Development

### Updating the vendor code

```bash
cd view/frontend/web/js/vendor
rm -r friendly-challenge
npm pack friendly-challenge
tar -xvf friendly-challenge-*.tgz
rm friendly-challenge-*.tgz
mv package friendly-challenge
```

Then make a pullrequest.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Localization {
text_error: string;
button_retry: string;
text_fetch_error: string;
rtl?: boolean;
}
declare const localizations: {
en: Localization;
Expand Down Expand Up @@ -43,8 +44,10 @@ declare const localizations: {
hu: Localization;
ro: Localization;
zh: Localization;
zh_TW: Localization;
zh_tw: Localization;
vi: Localization;
he: Localization;
th: Localization;
nb: Localization;
};

Expand Down Expand Up @@ -92,6 +95,11 @@ declare class WidgetInstance {
private expiryTimeout;
constructor(element: HTMLElement, options?: Partial<WidgetInstanceOptions>);
init(forceStart?: boolean): void;
/**
* Loads the configured language, or a language passed to this function.
* Note that only the next update will be in the new language, consider calling `reset()` after switching languages.
*/
loadLanguage(lang?: keyof typeof localizations | Localization): void;
/**
* Add a listener to the button that calls `this.start` on click.
*/
Expand Down
227 changes: 132 additions & 95 deletions view/frontend/web/js/vendor/friendly-challenge/compat/index.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Localization {
text_error: string;
button_retry: string;
text_fetch_error: string;
rtl?: boolean;
}
declare const localizations: {
en: Localization;
Expand Down Expand Up @@ -43,8 +44,10 @@ declare const localizations: {
hu: Localization;
ro: Localization;
zh: Localization;
zh_TW: Localization;
zh_tw: Localization;
vi: Localization;
he: Localization;
th: Localization;
nb: Localization;
};

Expand Down Expand Up @@ -92,6 +95,11 @@ declare class WidgetInstance {
private expiryTimeout;
constructor(element: HTMLElement, options?: Partial<WidgetInstanceOptions>);
init(forceStart?: boolean): void;
/**
* Loads the configured language, or a language passed to this function.
* Note that only the next update will be in the new language, consider calling `reset()` after switching languages.
*/
loadLanguage(lang?: keyof typeof localizations | Localization): void;
/**
* Add a listener to the button that calls `this.start` on click.
*/
Expand Down
20 changes: 20 additions & 0 deletions view/frontend/web/js/vendor/friendly-challenge/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
<script nomodule src="widget.min.js" defer async></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<style>
body {
font-family: sans-serif;
}

.frc-captcha { /* Puts some space between the widgets below */
margin-top: 8px;
}
</style>
</head>
<body>
<!-- This index.html is used for e2e testing -->
Expand All @@ -16,11 +26,15 @@ <h3>Localization tests</h3>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-lang="de"></div>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-lang="nl"></div>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-lang="ja"></div>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-lang="he"></div>
<h4>This one has an invalid data-lang, it should fall back to English.</h4>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-lang="ww"></div>
<h3>Custom field name</h3>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-solution-field-name="my-field-name"></div>

<h3>No hidden form field</h3>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSQ5H" data-solution-field-name="-"></div>

<h3>Invalid sitekey</h3>
<div class="frc-captcha" data-sitekey="FCMGEMUD2KTDSABC"></div>

Expand All @@ -46,6 +60,7 @@ <h3>With fallback endpoint</h3>
<button id="reset-button">Reset widget</button>
<button id="destroy-button">Destroy widget</button>
<button id="theme-button">Toggle dark theme</button>
<button id="lang-button">Set language to Vietnamese (reset required)</button>
<script>
function doneCallback() {
const doneEl = document.createElement("div")
Expand All @@ -66,6 +81,11 @@ <h3>With fallback endpoint</h3>
friendlyChallenge.autoWidget.destroy();
});

document.querySelector("#lang-button").addEventListener("click", function() {
friendlyChallenge.autoWidget.loadLanguage("vi");
});


document.querySelector("#theme-button").addEventListener("click", function() {
[].forEach.call(document.querySelectorAll(".frc-captcha"), function(c) {
c.classList.toggle("dark")
Expand Down
Loading

0 comments on commit 2201927

Please sign in to comment.