Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IAMRISK-2817] Update API for Arkose to use a callback based API #1349

Merged
merged 11 commits into from
Oct 19, 2023
19 changes: 9 additions & 10 deletions dist/auth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -7879,8 +7879,6 @@
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for recaptcha
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containg a callback to trigger the captcha (only if Arkose is the provider)
* @ignore
*/
function render(auth0Client, element, options, callback) {
Expand Down Expand Up @@ -7955,8 +7953,6 @@
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for recaptcha
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containg a callback to trigger the captcha (only if Arkose is the provider)
* @ignore
*/
function renderPasswordless(auth0Client, element, options, callback) {
Expand Down Expand Up @@ -9127,6 +9123,13 @@
});
};

/**
* @callback doneCallback
* @param {Error} [err] Error returned if request to get captcha challenge fails
* @param {Object} [apis] An object containing a callback to trigger the captcha (only if Arkose is the provider)
* @param {Function} [apis.triggerCaptcha] Triggers the captcha with the first parameter as a callback to be fired after it's solved
*/

/**
*
* Renders the captcha challenge in the provided element.
Expand All @@ -9144,9 +9147,7 @@
* @param {Function} [options.templates.arkose] template function receiving the challenge and returning a string
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for the captcha provider
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containg a callback to trigger the captcha (only if Arkose is the provider)
* @param {doneCallback} [callback] An optional callback called after captcha is loaded
* @memberof WebAuth.prototype
*/
WebAuth.prototype.renderCaptcha = function (element, options, callback) {
Expand All @@ -9170,9 +9171,7 @@
* @param {Function} [options.templates.arkose] template function receiving the challenge and returning a string
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for the captcha provider
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containg a callback to trigger the captcha (only if Arkose is the provider)
* @param {doneCallback} [callback] An optional callback called after captcha is loaded
* @memberof WebAuth.prototype
*/
WebAuth.prototype.renderPasswordlessCaptcha = function (
Expand Down
2 changes: 1 addition & 1 deletion dist/auth0.min.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/auth0.min.js.map

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions src/web-auth/captcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ function handleCaptchaProvider(element, options, challenge) {
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for recaptcha
* @param {Function} [callback] An optional callback called after captcha is loaded
Copy link
Contributor

Choose a reason for hiding this comment

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

callback -> captchaLoadedCallback right?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, that's an internal module, not the public interface 👍

Copy link
Member

@frederikprijck frederikprijck Oct 19, 2023

Choose a reason for hiding this comment

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

The callback is typed as captchaLoadedCallback in jsDocs, but the argument name is still callback, or done, or whatever is used in the specific case where we use callbacks. The argument shouldnt be named the same as the type, regardless of internal of public interface.

* - first parameter will be an error if one occured while loading
* - second parameter will be an object containing a callback to trigger the captcha (only if Arkose is the provider)
* @ignore
frederikprijck marked this conversation as resolved.
Show resolved Hide resolved
*/
function render(auth0Client, element, options, callback) {
Expand Down Expand Up @@ -395,8 +393,6 @@ function render(auth0Client, element, options, callback) {
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for recaptcha
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containing a callback to trigger the captcha (only if Arkose is the provider)
* @ignore
*/
function renderPasswordless(auth0Client, element, options, callback) {
Expand Down
15 changes: 9 additions & 6 deletions src/web-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,13 @@ WebAuth.prototype.passwordlessVerify = function (options, cb) {
});
};

/**
* @callback doneCallback
srijonsaha marked this conversation as resolved.
Show resolved Hide resolved
* @param {Error} [err] Error returned if request to get captcha challenge fails
* @param {Object} [apis] An object containing a callback to trigger the captcha (only if Arkose is the provider)
srijonsaha marked this conversation as resolved.
Show resolved Hide resolved
* @param {Function} [apis.triggerCaptcha] Triggers the captcha with the first parameter as a callback to be fired after it's solved
srijonsaha marked this conversation as resolved.
Show resolved Hide resolved
*/

/**
*
* Renders the captcha challenge in the provided element.
Expand All @@ -1146,9 +1153,7 @@ WebAuth.prototype.passwordlessVerify = function (options, cb) {
* @param {Function} [options.templates.arkose] template function receiving the challenge and returning a string
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for the captcha provider
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containing a callback to trigger the captcha (only if Arkose is the provider)
* @param {doneCallback} [callback] An optional callback called after captcha is loaded
srijonsaha marked this conversation as resolved.
Show resolved Hide resolved
* @memberof WebAuth.prototype
*/
WebAuth.prototype.renderCaptcha = function (element, options, callback) {
Expand All @@ -1172,9 +1177,7 @@ WebAuth.prototype.renderCaptcha = function (element, options, callback) {
* @param {Function} [options.templates.arkose] template function receiving the challenge and returning a string
* @param {Function} [options.templates.error] template function returning a custom error message when the challenge could not be fetched, receives the error as first argument
* @param {String} [options.lang=en] the ISO code of the language for the captcha provider
* @param {Function} [callback] An optional callback called after captcha is loaded
* - first parameter will be an error if one occured while loading
* - second parameter will be an object containing a callback to trigger the captcha (only if Arkose is the provider)
* @param {doneCallback} [callback] An optional callback called after captcha is loaded
srijonsaha marked this conversation as resolved.
Show resolved Hide resolved
* @memberof WebAuth.prototype
*/
WebAuth.prototype.renderPasswordlessCaptcha = function (
Expand Down