@descope/flow-scripts 1.0.7 → 1.0.9
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/fingerprint.js +1 -1
- package/dist/fingerprintDescope.js +1 -1
- package/dist/grecaptcha.js +1 -1
- package/package.json +5 -5
- package/src/grecaptcha.spec.ts +15 -1
- package/src/grecaptcha.ts +2 -1
- package/src/index.spec.ts +2 -17
package/dist/fingerprint.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).descope=e.descope||{},e.descope.fingerprint=n())}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(u,c)}a((r=r.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t={default:"endpoint"},r="Blocked by CSP",o="The endpoint parameter is not a valid URL",i="Failed to load the JS script of the agent",u="9319";function c(e,n){var t,c,a,f,l,s=[],p=(t=function(e){var n=function(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0);return{current:function(){return n[0]},postpone:function(){var e=n.shift();void 0!==e&&n.push(e)},exclude:function(){n.shift()}}}(e),f=0,c=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,f++))},a=new Set,[t.current(),function(e,n){var f,l=n instanceof Error?n.message:"";if(l===r||l===o)t.exclude(),f=0;else if(l===u)t.exclude();else if(l===i){var s=Date.now()-e.getTime()<50,p=t.current();p&&s&&!a.has(p)&&(a.add(p),f=0),t.postpone()}else t.postpone();var d=t.current();return void 0===d?void 0:[d,null!=f?f:e.getTime()+c()-Date.now()]}]),d=p[0],v=p[1];if(void 0===d)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var h=function(e){var t=new Date,r=function(n){return s.push({url:e,startedAt:t,finishedAt:new Date,error:n})},o=n(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=l||(l=e),s.length>=5)throw l;var n=v(t,e);if(!n)throw l;var r,o=n[0],i=n[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return h(o)}))}))};return h(d).then((function(e){return[e,s]}))}var a="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",f=a;function l(n){var t;n.scriptUrlPattern;var r=n.token,o=n.apiKey,f=void 0===o?r:o,l=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(n,["scriptUrlPattern","token","apiKey"]),p=null!==(t=function(e,n){return function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}(e,n)?e[n]:void 0}(n,"scriptUrlPattern"))&&void 0!==t?t:a,d=function(){var e=[],n=function(){e.push({time:new Date,state:document.visibilityState})},t=function(e,n,t,r){return e.addEventListener(n,t,r),function(){return e.removeEventListener(n,t,r)}}(document,"visibilitychange",n);return n(),[e,t]}(),v=d[0],h=d[1];return Promise.resolve().then((function(){if(!f||"string"!=typeof f)throw new Error("API key required");return c(function(e,n){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,n){var t=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?t(n):"<loaderVersion>"===e?t("3.11.
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).descope=e.descope||{},e.descope.fingerprint=n())}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(u,c)}a((r=r.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t={default:"endpoint"},r="Blocked by CSP",o="The endpoint parameter is not a valid URL",i="Failed to load the JS script of the agent",u="9319";function c(e,n){var t,c,a,f,l,s=[],p=(t=function(e){var n=function(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0);return{current:function(){return n[0]},postpone:function(){var e=n.shift();void 0!==e&&n.push(e)},exclude:function(){n.shift()}}}(e),f=0,c=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,f++))},a=new Set,[t.current(),function(e,n){var f,l=n instanceof Error?n.message:"";if(l===r||l===o)t.exclude(),f=0;else if(l===u)t.exclude();else if(l===i){var s=Date.now()-e.getTime()<50,p=t.current();p&&s&&!a.has(p)&&(a.add(p),f=0),t.postpone()}else t.postpone();var d=t.current();return void 0===d?void 0:[d,null!=f?f:e.getTime()+c()-Date.now()]}]),d=p[0],v=p[1];if(void 0===d)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var h=function(e){var t=new Date,r=function(n){return s.push({url:e,startedAt:t,finishedAt:new Date,error:n})},o=n(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=l||(l=e),s.length>=5)throw l;var n=v(t,e);if(!n)throw l;var r,o=n[0],i=n[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return h(o)}))}))};return h(d).then((function(e){return[e,s]}))}var a="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",f=a;function l(n){var t;n.scriptUrlPattern;var r=n.token,o=n.apiKey,f=void 0===o?r:o,l=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(n,["scriptUrlPattern","token","apiKey"]),p=null!==(t=function(e,n){return function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}(e,n)?e[n]:void 0}(n,"scriptUrlPattern"))&&void 0!==t?t:a,d=function(){var e=[],n=function(){e.push({time:new Date,state:document.visibilityState})},t=function(e,n,t,r){return e.addEventListener(n,t,r),function(){return e.removeEventListener(n,t,r)}}(document,"visibilitychange",n);return n(),[e,t]}(),v=d[0],h=d[1];return Promise.resolve().then((function(){if(!f||"string"!=typeof f)throw new Error("API key required");return c(function(e,n){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,n){var t=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?t(n):"<loaderVersion>"===e?t("3.11.10"):e}))}(String(e),n)}))}(p,f),s)})).catch((function(e){throw h(),function(e){return e instanceof Error&&e.message===u?new Error(i):e}(e)})).then((function(n){var t=n[0],r=n[1];return h(),t.load(e(e({},l),{ldi:{attempts:r,visibilityStates:v}}))}))}function s(e){return function(e,n,t){var r,o=document,i="securitypolicyviolation",u=function(n){var t=new URL(e,location.href),o=n.blockedURI;o!==t.href&&o!==t.protocol.slice(0,-1)&&o!==t.origin||(r=n,c())};o.addEventListener(i,u);var c=function(){return o.removeEventListener(i,u)};return Promise.resolve().then(n).then((function(e){return c(),e}),(function(e){return new Promise((function(e){var n=new MessageChannel;n.port1.onmessage=function(){return e()},n.port2.postMessage(null)})).then((function(){if(c(),r)return t(r);throw e}))}))}(e,(function(){return function(e){return new Promise((function(n,t){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(o);var r=document.createElement("script"),u=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},c=document.head||document.getElementsByTagName("head")[0];r.onload=function(){u(),n()},r.onerror=function(){u(),t(new Error(i))},r.async=!0,r.src=e,c.appendChild(r)}))}(e)}),(function(){throw new Error(r)})).then(p)}function p(){var e=window,n="__fpjs_p_l_b",t=e[n];if(function(e,n){var t,r=null===(t=Object.getOwnPropertyDescriptor)||void 0===t?void 0:t.call(Object,e,n);(null==r?void 0:r.configurable)?delete e[n]:r&&!r.writable||(e[n]=void 0)}(e,n),"function"!=typeof(null==t?void 0:t.load))throw new Error(u);return t}
|
|
2
2
|
/*! Source: (c) FingerprintJS and other contributors | https://dev.fingerprint.com/ */return(e,r,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:n,useCloudflareIntegration:r,cloudflareScriptUrl:i,cloudflareEndpointUrl:u}=e;let c=[];c=r&&u?[u,t]:[t];let a=[];if(r&&i){const e=new URL(i);a=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,f]}else a=[f];const s=l({apiKey:n,endpoint:c,scriptUrlPattern:a}),p=yield s,{requestId:d}=yield p.get();o(d)}catch(e){console.warn("Could not load fingerprint",e)}}))}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).descope=e.descope||{},e.descope.fingerprintDescope=n())}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,u)}a((r=r.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t={default:"endpoint"},r="Blocked by CSP",o="The endpoint parameter is not a valid URL",i="Failed to load the JS script of the agent",c="9319";function u(e,n){var t,u,a,f,s,l=[],p=(t=function(e){var n=function(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0);return{current:function(){return n[0]},postpone:function(){var e=n.shift();void 0!==e&&n.push(e)},exclude:function(){n.shift()}}}(e),f=0,u=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,f++))},a=new Set,[t.current(),function(e,n){var f,s=n instanceof Error?n.message:"";if(s===r||s===o)t.exclude(),f=0;else if(s===c)t.exclude();else if(s===i){var l=Date.now()-e.getTime()<50,p=t.current();p&&l&&!a.has(p)&&(a.add(p),f=0),t.postpone()}else t.postpone();var d=t.current();return void 0===d?void 0:[d,null!=f?f:e.getTime()+u()-Date.now()]}]),d=p[0],v=p[1];if(void 0===d)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var h=function(e){var t=new Date,r=function(n){return l.push({url:e,startedAt:t,finishedAt:new Date,error:n})},o=n(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=s||(s=e),l.length>=5)throw s;var n=v(t,e);if(!n)throw s;var r,o=n[0],i=n[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return h(o)}))}))};return h(d).then((function(e){return[e,l]}))}var a="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",f=a;function s(n){var t;n.scriptUrlPattern;var r=n.token,o=n.apiKey,f=void 0===o?r:o,s=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(n,["scriptUrlPattern","token","apiKey"]),p=null!==(t=function(e,n){return function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}(e,n)?e[n]:void 0}(n,"scriptUrlPattern"))&&void 0!==t?t:a,d=function(){var e=[],n=function(){e.push({time:new Date,state:document.visibilityState})},t=function(e,n,t,r){return e.addEventListener(n,t,r),function(){return e.removeEventListener(n,t,r)}}(document,"visibilitychange",n);return n(),[e,t]}(),v=d[0],h=d[1];return Promise.resolve().then((function(){if(!f||"string"!=typeof f)throw new Error("API key required");return u(function(e,n){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,n){var t=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?t(n):"<loaderVersion>"===e?t("3.11.
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((e="undefined"!=typeof globalThis?globalThis:e||self).descope=e.descope||{},e.descope.fingerprintDescope=n())}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,u)}a((r=r.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t={default:"endpoint"},r="Blocked by CSP",o="The endpoint parameter is not a valid URL",i="Failed to load the JS script of the agent",c="9319";function u(e,n){var t,u,a,f,s,l=[],p=(t=function(e){var n=function(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0);return{current:function(){return n[0]},postpone:function(){var e=n.shift();void 0!==e&&n.push(e)},exclude:function(){n.shift()}}}(e),f=0,u=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,f++))},a=new Set,[t.current(),function(e,n){var f,s=n instanceof Error?n.message:"";if(s===r||s===o)t.exclude(),f=0;else if(s===c)t.exclude();else if(s===i){var l=Date.now()-e.getTime()<50,p=t.current();p&&l&&!a.has(p)&&(a.add(p),f=0),t.postpone()}else t.postpone();var d=t.current();return void 0===d?void 0:[d,null!=f?f:e.getTime()+u()-Date.now()]}]),d=p[0],v=p[1];if(void 0===d)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var h=function(e){var t=new Date,r=function(n){return l.push({url:e,startedAt:t,finishedAt:new Date,error:n})},o=n(e);return o.then((function(){return r()}),r),o.catch((function(e){if(null!=s||(s=e),l.length>=5)throw s;var n=v(t,e);if(!n)throw s;var r,o=n[0],i=n[1];return(r=i,new Promise((function(e){return setTimeout(e,r)}))).then((function(){return h(o)}))}))};return h(d).then((function(e){return[e,l]}))}var a="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",f=a;function s(n){var t;n.scriptUrlPattern;var r=n.token,o=n.apiKey,f=void 0===o?r:o,s=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(n,["scriptUrlPattern","token","apiKey"]),p=null!==(t=function(e,n){return function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}(e,n)?e[n]:void 0}(n,"scriptUrlPattern"))&&void 0!==t?t:a,d=function(){var e=[],n=function(){e.push({time:new Date,state:document.visibilityState})},t=function(e,n,t,r){return e.addEventListener(n,t,r),function(){return e.removeEventListener(n,t,r)}}(document,"visibilitychange",n);return n(),[e,t]}(),v=d[0],h=d[1];return Promise.resolve().then((function(){if(!f||"string"!=typeof f)throw new Error("API key required");return u(function(e,n){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,n){var t=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?t(n):"<loaderVersion>"===e?t("3.11.10"):e}))}(String(e),n)}))}(p,f),l)})).catch((function(e){throw h(),function(e){return e instanceof Error&&e.message===c?new Error(i):e}(e)})).then((function(n){var t=n[0],r=n[1];return h(),t.load(e(e({},s),{ldi:{attempts:r,visibilityStates:v}}))}))}function l(e){return function(e,n,t){var r,o=document,i="securitypolicyviolation",c=function(n){var t=new URL(e,location.href),o=n.blockedURI;o!==t.href&&o!==t.protocol.slice(0,-1)&&o!==t.origin||(r=n,u())};o.addEventListener(i,c);var u=function(){return o.removeEventListener(i,c)};return Promise.resolve().then(n).then((function(e){return u(),e}),(function(e){return new Promise((function(e){var n=new MessageChannel;n.port1.onmessage=function(){return e()},n.port2.postMessage(null)})).then((function(){if(u(),r)return t(r);throw e}))}))}(e,(function(){return function(e){return new Promise((function(n,t){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(o);var r=document.createElement("script"),c=function(){var e;return null===(e=r.parentNode)||void 0===e?void 0:e.removeChild(r)},u=document.head||document.getElementsByTagName("head")[0];r.onload=function(){c(),n()},r.onerror=function(){c(),t(new Error(i))},r.async=!0,r.src=e,u.appendChild(r)}))}(e)}),(function(){throw new Error(r)})).then(p)}function p(){var e=window,n="__fpjs_p_l_b",t=e[n];if(function(e,n){var t,r=null===(t=Object.getOwnPropertyDescriptor)||void 0===t?void 0:t.call(Object,e,n);(null==r?void 0:r.configurable)?delete e[n]:r&&!r.writable||(e[n]=void 0)}(e,n),"function"!=typeof(null==t?void 0:t.load))throw new Error(c);return t}
|
|
2
2
|
/*! Source: (c) FingerprintJS and other contributors | https://dev.fingerprint.com/ */return(e,r,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:c,cloudflareScriptPath:u}=e,{baseUrl:a}=r;let l;l=n?`https://${n}`:a||"https://api.descope.com";const p=new URL(l);p.pathname=c;const d=new URL(l);d.pathname=u;const v=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=s({apiKey:i,endpoint:[p.toString(),t],scriptUrlPattern:[v,f]}),y=yield h,{requestId:m}=yield y.get();o(m)}catch(e){console.warn("Could not load descope fingerprint",e)}}))}));
|
package/dist/grecaptcha.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).descope=e.descope||{},e.descope.grecaptcha=t())}(this,(function(){"use strict";function e(e,t,n,o){return new(n||(n=Promise))((function(r,c){function i(e){try{s(o.next(e))}catch(e){c(e)}}function a(e){try{s(o.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}s((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;
|
|
2
2
|
/*! Source: (c) google and other contributors | https://developers.google.com/recaptcha/docs/v3 */
|
|
3
|
-
const t=105e3;return(n,o,r)=>{let c=(new Date).getTime();const i=()=>{var e;return n.enterprise?null===(e=window.grecaptcha)||void 0===e?void 0:e.enterprise:window.grecaptcha};let a,s;const d=(e,o)=>{e.ready((()=>{n.siteKey&&(null==e||e.execute(s,{action:"load"}).then(((n,o)=>{o?console.warn("could not execute recaptcha",o):(r(n),c=(new Date).getTime(),a=setTimeout((()=>{d(e)}),t))})))}))},p=()=>{clearTimeout(a)},u=(()=>{const e=document.createElement("div");return e.style.display="none",e.id="recaptcha",document.body.appendChild(e)})(),l=()=>{const e=i();e&&d(e)};return window.onRecaptchaLoadCallback=()=>{const e=u;if(e.hasChildNodes())return;const t=i();t&&setTimeout((()=>{s=t.render(e,{sitekey:n.siteKey,badge:"inline",size:"invisible"}),d(t)}),0)},(()=>{const e=document.createElement("script");e.src=(()=>{const e=new URL("https://www.google.com/recaptcha
|
|
3
|
+
const t=105e3;return(n,o,r)=>{let c=(new Date).getTime();const i=()=>{var e;return n.enterprise?null===(e=window.grecaptcha)||void 0===e?void 0:e.enterprise:window.grecaptcha};let a,s;const d=(e,o)=>{e.ready((()=>{n.siteKey&&(null==e||e.execute(s,{action:"load"}).then(((n,o)=>{o?console.warn("could not execute recaptcha",o):(r(n),c=(new Date).getTime(),a=setTimeout((()=>{d(e)}),t))})))}))},p=()=>{clearTimeout(a)},u=(()=>{const e=document.createElement("div");return e.style.display="none",e.id="recaptcha",document.body.appendChild(e)})(),l=()=>{const e=i();e&&d(e)};return window.onRecaptchaLoadCallback=()=>{const e=u;if(e.hasChildNodes())return;const t=i();t&&setTimeout((()=>{s=t.render(e,{sitekey:n.siteKey,badge:"inline",size:"invisible"}),d(t)}),0)},(()=>{const e=document.createElement("script");e.src=(()=>{const e=new URL(`${n.baseUrl||"https://www.google.com"}/recaptcha/`);return e.pathname+=(n.enterprise?"enterprise":"api")+".js",e.searchParams.append("onload","onRecaptchaLoadCallback"),e.searchParams.append("render","explicit"),e.toString()})(),e.async=!0,e.id="recaptcha-script",e.defer=!0,document.body.appendChild(e)})(),{stop:p,start:l,refresh:()=>e(void 0,void 0,void 0,(function*(){if(Date.now()-c>t){p();const e=c;return l(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),o=()=>{c!==e?(clearTimeout(n),t()):setTimeout(o,150)};o()}))}return Promise.resolve()}))}}}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/flow-scripts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.9",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/descope/content"
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"@testing-library/dom": "10.4.0",
|
|
22
22
|
"@testing-library/react": "16.3.0",
|
|
23
23
|
"@types/jest": "29.5.14",
|
|
24
|
-
"eslint": "9.
|
|
24
|
+
"eslint": "9.28.0",
|
|
25
25
|
"eslint-plugin-import": "2.31.0",
|
|
26
26
|
"jest": "29.7.0",
|
|
27
27
|
"jest-environment-jsdom": "29.7.0",
|
|
28
|
-
"rollup": "4.
|
|
29
|
-
"ts-jest": "29.3.
|
|
28
|
+
"rollup": "4.42.0",
|
|
29
|
+
"ts-jest": "29.3.4",
|
|
30
30
|
"ts-node": "10.9.2",
|
|
31
31
|
"typescript": "5.8.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@fingerprintjs/fingerprintjs-pro": "3.11.
|
|
34
|
+
"@fingerprintjs/fingerprintjs-pro": "3.11.10"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/grecaptcha.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { waitFor } from '@testing-library/dom';
|
|
1
2
|
import { default as loadGRecaptcha } from './grecaptcha';
|
|
2
3
|
|
|
3
4
|
describe('reCAPTCHA script', () => {
|
|
@@ -33,7 +34,7 @@ describe('reCAPTCHA script', () => {
|
|
|
33
34
|
|
|
34
35
|
afterEach(() => {
|
|
35
36
|
jest.clearAllMocks();
|
|
36
|
-
document.
|
|
37
|
+
document.getElementsByTagName('html')[0].innerHTML = '';
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
it('should load reCAPTCHA script and return proper module', () => {
|
|
@@ -55,6 +56,19 @@ describe('reCAPTCHA script', () => {
|
|
|
55
56
|
expect(typeof module.refresh).toBe('function');
|
|
56
57
|
});
|
|
57
58
|
|
|
59
|
+
it('should load reCAPTCHA script with the given base url', async () => {
|
|
60
|
+
const initArgs = {
|
|
61
|
+
enterprise: true,
|
|
62
|
+
baseUrl: 'https://custom-url.com',
|
|
63
|
+
siteKey: 'test-site-key',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
loadGRecaptcha(initArgs, {}, onTokenReady);
|
|
67
|
+
|
|
68
|
+
await waitFor(() => expect(document.querySelector('#recaptcha-script')).toBeTruthy());
|
|
69
|
+
expect(document.querySelector('#recaptcha-script')).toHaveProperty('src', 'https://custom-url.com/recaptcha/enterprise.js?onload=onRecaptchaLoadCallback&render=explicit');
|
|
70
|
+
});
|
|
71
|
+
|
|
58
72
|
it('should have a refresh method with timeout safety', () => {
|
|
59
73
|
const initArgs = {
|
|
60
74
|
enterprise: false,
|
package/src/grecaptcha.ts
CHANGED
|
@@ -21,6 +21,7 @@ const loadGRecaptcha = (
|
|
|
21
21
|
initArgs: {
|
|
22
22
|
enterprise: boolean;
|
|
23
23
|
siteKey: string;
|
|
24
|
+
baseUrl?: string;
|
|
24
25
|
},
|
|
25
26
|
_inputs: { baseUrl?: string },
|
|
26
27
|
onTokenReady: (token: string) => void,
|
|
@@ -28,7 +29,7 @@ const loadGRecaptcha = (
|
|
|
28
29
|
let lastTokenFetchTime = new Date().getTime();
|
|
29
30
|
|
|
30
31
|
const getScriptURL = () => {
|
|
31
|
-
const url = new URL('https://www.google.com/recaptcha
|
|
32
|
+
const url = new URL(`${initArgs.baseUrl || 'https://www.google.com'}/recaptcha/`);
|
|
32
33
|
url.pathname += `${initArgs.enterprise ? 'enterprise' : 'api'}.js`;
|
|
33
34
|
url.searchParams.append('onload', 'onRecaptchaLoadCallback');
|
|
34
35
|
url.searchParams.append('render', 'explicit');
|
package/src/index.spec.ts
CHANGED
|
@@ -7,23 +7,8 @@ const urlPattern =
|
|
|
7
7
|
const mockFetch = jest.fn();
|
|
8
8
|
|
|
9
9
|
async function loadSdkScript(scriptId: string) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
case 'forter':
|
|
13
|
-
res = await import('./forter');
|
|
14
|
-
return res.default;
|
|
15
|
-
case 'fingerprint':
|
|
16
|
-
res = await import('./fingerprint');
|
|
17
|
-
return res.default;
|
|
18
|
-
case 'fingerprintDescope':
|
|
19
|
-
res = await import('./fingerprintDescope');
|
|
20
|
-
return res.default;
|
|
21
|
-
case 'grecaptcha':
|
|
22
|
-
res = await import('./grecaptcha');
|
|
23
|
-
return res.default;
|
|
24
|
-
default:
|
|
25
|
-
throw new Error(`Unknown script id: ${scriptId}`);
|
|
26
|
-
}
|
|
10
|
+
const res = await import(`./${scriptId}`);
|
|
11
|
+
return res.default;
|
|
27
12
|
}
|
|
28
13
|
|
|
29
14
|
global.fetch = mockFetch;
|