UNPKG

react-app-protect

Version:
11 lines (10 loc) 16.1 kB
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("react")),r=e(require("@fingerprintjs/fingerprintjs")),n=e(require("crypto-js")),o=e(require("html2canvas")),a=e(require("crypto-js/aes"));function i(e,t){return e(t={exports:{}},t.exports),t.exports /** @license React v16.13.1 * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */}var c="function"==typeof Symbol&&Symbol.for,u=c?Symbol.for("react.element"):60103,s=c?Symbol.for("react.portal"):60106,f=c?Symbol.for("react.fragment"):60107,l=c?Symbol.for("react.strict_mode"):60108,p=c?Symbol.for("react.profiler"):60114,y=c?Symbol.for("react.provider"):60109,d=c?Symbol.for("react.context"):60110,m=c?Symbol.for("react.async_mode"):60111,b=c?Symbol.for("react.concurrent_mode"):60111,v=c?Symbol.for("react.forward_ref"):60112,h=c?Symbol.for("react.suspense"):60113,g=c?Symbol.for("react.suspense_list"):60120,S=c?Symbol.for("react.memo"):60115,E=c?Symbol.for("react.lazy"):60116,O=c?Symbol.for("react.block"):60121,w=c?Symbol.for("react.fundamental"):60117,j=c?Symbol.for("react.responder"):60118,$=c?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case u:switch(e=e.type){case m:case b:case f:case p:case l:case h:return e;default:switch(e=e&&e.$$typeof){case d:case v:case E:case S:case y:return e;default:return t}}case s:return t}}}function _(e){return x(e)===b}var P={AsyncMode:m,ConcurrentMode:b,ContextConsumer:d,ContextProvider:y,Element:u,ForwardRef:v,Fragment:f,Lazy:E,Memo:S,Portal:s,Profiler:p,StrictMode:l,Suspense:h,isAsyncMode:function(e){return _(e)||x(e)===m},isConcurrentMode:_,isContextConsumer:function(e){return x(e)===d},isContextProvider:function(e){return x(e)===y},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===u},isForwardRef:function(e){return x(e)===v},isFragment:function(e){return x(e)===f},isLazy:function(e){return x(e)===E},isMemo:function(e){return x(e)===S},isPortal:function(e){return x(e)===s},isProfiler:function(e){return x(e)===p},isStrictMode:function(e){return x(e)===l},isSuspense:function(e){return x(e)===h},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===f||e===b||e===p||e===l||e===h||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===E||e.$$typeof===S||e.$$typeof===y||e.$$typeof===d||e.$$typeof===v||e.$$typeof===w||e.$$typeof===j||e.$$typeof===$||e.$$typeof===O)},typeOf:x},N=i(function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,s=e?Symbol.for("react.async_mode"):60111,f=e?Symbol.for("react.concurrent_mode"):60111,l=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,h=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:var y=e.type;switch(y){case s:case f:case o:case i:case a:case p:return y;default:var b=y&&y.$$typeof;switch(b){case u:case l:case m:case d:case c:return b;default:return t}}case n:return t}}}var E=f,O=u,w=c,j=r,$=l,x=o,_=m,P=d,N=n,T=i,C=a,I=p,k=!1;function R(e){return S(e)===f}t.AsyncMode=s,t.ConcurrentMode=E,t.ContextConsumer=O,t.ContextProvider=w,t.Element=j,t.ForwardRef=$,t.Fragment=x,t.Lazy=_,t.Memo=P,t.Portal=N,t.Profiler=T,t.StrictMode=C,t.Suspense=I,t.isAsyncMode=function(e){return k||(k=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),R(e)||S(e)===s},t.isConcurrentMode=R,t.isContextConsumer=function(e){return S(e)===u},t.isContextProvider=function(e){return S(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return S(e)===l},t.isFragment=function(e){return S(e)===o},t.isLazy=function(e){return S(e)===m},t.isMemo=function(e){return S(e)===d},t.isPortal=function(e){return S(e)===n},t.isProfiler=function(e){return S(e)===i},t.isStrictMode=function(e){return S(e)===a},t.isSuspense=function(e){return S(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===f||e===i||e===a||e===p||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===c||e.$$typeof===u||e.$$typeof===l||e.$$typeof===v||e.$$typeof===h||e.$$typeof===g||e.$$typeof===b)},t.typeOf=S}()}),T=i(function(e){e.exports="production"===process.env.NODE_ENV?P:N}),C=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;function R(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var A=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,o=R(e),a=1;a<arguments.length;a++){for(var i in r=Object(arguments[a]))I.call(r,i)&&(o[i]=r[i]);if(C){n=C(r);for(var c=0;c<n.length;c++)k.call(r,n[c])&&(o[n[c]]=r[n[c]])}}return o},M="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",V=function(){};if("production"!==process.env.NODE_ENV){var q=M,F={},D=Function.call.bind(Object.prototype.hasOwnProperty);V=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function L(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var a in e)if(D(e,a)){var i;try{if("function"!=typeof e[a]){var c=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.");throw c.name="Invariant Violation",c}i=e[a](t,a,n,r,null,q)}catch(e){i=e}if(!i||i instanceof Error||V((n||"React class")+": type specification of "+r+" `"+a+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof i+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),i instanceof Error&&!(i.message in F)){F[i.message]=!0;var u=o?o():"";V("Failed "+r+" type: "+i.message+(null!=u?u:""))}}}L.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(F={})};var z=L,J=Function.call.bind(Object.prototype.hasOwnProperty),W=function(){};function K(){return null}function U(){}function H(){}"production"!==process.env.NODE_ENV&&(W=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),H.resetWarningCache=U;var Y=i(function(e){e.exports="production"!==process.env.NODE_ENV?function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n={array:c("array"),bool:c("boolean"),func:c("function"),number:c("number"),object:c("object"),string:c("string"),symbol:c("symbol"),any:i(K),arrayOf:function(e){return i(function(t,r,n,o,i){if("function"!=typeof e)return new a("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var c=t[r];if(!Array.isArray(c))return new a("Invalid "+o+" `"+i+"` of type `"+s(c)+"` supplied to `"+n+"`, expected an array.");for(var u=0;u<c.length;u++){var f=e(c,u,n,o,i+"["+u+"]",M);if(f instanceof Error)return f}return null})},element:i(function(t,r,n,o,i){var c=t[r];return e(c)?null:new a("Invalid "+o+" `"+i+"` of type `"+s(c)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:i(function(e,t,r,n,o){var i=e[t];return T.isValidElementType(i)?null:new a("Invalid "+n+" `"+o+"` of type `"+s(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return i(function(t,r,n,o,i){var c;return t[r]instanceof e?null:new a("Invalid "+o+" `"+i+"` of type `"+((c=t[r]).constructor&&c.constructor.name?c.constructor.name:"<<anonymous>>")+"` supplied to `"+n+"`, expected instance of `"+(e.name||"<<anonymous>>")+"`.")})},node:i(function(e,t,r,n,o){return u(e[t])?null:new a("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return i(function(t,r,n,o,i){if("function"!=typeof e)return new a("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var c=t[r],u=s(c);if("object"!==u)return new a("Invalid "+o+" `"+i+"` of type `"+u+"` supplied to `"+n+"`, expected an object.");for(var f in c)if(J(c,f)){var l=e(c,f,n,o,i+"."+f,M);if(l instanceof Error)return l}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&W(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),K;function t(t,r,n,i,c){for(var u=t[r],s=0;s<e.length;s++)if(o(u,e[s]))return null;var l=JSON.stringify(e,function(e,t){return"symbol"===f(t)?String(t):t});return new a("Invalid "+i+" `"+c+"` of value `"+String(u)+"` supplied to `"+n+"`, expected one of "+l+".")}return i(t)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&W("Invalid argument supplied to oneOfType, expected an instance of array."),K;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return W("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+l(r)+" at index "+t+"."),K}return i(function(t,r,n,o,i){for(var c=0;c<e.length;c++)if(null==(0,e[c])(t,r,n,o,i,M))return null;return new a("Invalid "+o+" `"+i+"` supplied to `"+n+"`.")})},shape:function(e){return i(function(t,r,n,o,i){var c=t[r],u=s(c);if("object"!==u)return new a("Invalid "+o+" `"+i+"` of type `"+u+"` supplied to `"+n+"`, expected `object`.");for(var f in e){var l=e[f];if(l){var p=l(c,f,n,o,i+"."+f,M);if(p)return p}}return null})},exact:function(e){return i(function(t,r,n,o,i){var c=t[r],u=s(c);if("object"!==u)return new a("Invalid "+o+" `"+i+"` of type `"+u+"` supplied to `"+n+"`, expected `object`.");var f=A({},t[r],e);for(var l in f){var p=e[l];if(!p)return new a("Invalid "+o+" `"+i+"` key `"+l+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=p(c,l,n,o,i+"."+l,M);if(y)return y}return null})}};function o(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function a(e){this.message=e,this.stack=""}function i(e){function t(t,r,n,o,i,c,u){if(o=o||"<<anonymous>>",c=c||n,u!==M){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}return null==r[n]?t?new a(null===r[n]?"The "+i+" `"+c+"` is marked as required in `"+o+"`, but its value is `null`.":"The "+i+" `"+c+"` is marked as required in `"+o+"`, but its value is `undefined`."):null:e(r,n,o,i,c)}process;var r=t.bind(null,!1);return r.isRequired=t.bind(null,!0),r}function c(e){return i(function(t,r,n,o,i,c){var u=t[r];return s(u)!==e?new a("Invalid "+o+" `"+i+"` of type `"+f(u)+"` supplied to `"+n+"`, expected `"+e+"`."):null})}function u(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(u);if(null===t||e(t))return!0;var n=function(e){var t=e&&(r&&e[r]||e["@@iterator"]);if("function"==typeof t)return t}(t);if(!n)return!1;var o,a=n.call(t);if(n!==t.entries){for(;!(o=a.next()).done;)if(!u(o.value))return!1}else for(;!(o=a.next()).done;){var i=o.value;if(i&&!u(i[1]))return!1}return!0;default:return!1}}function s(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function f(e){if(null==e)return""+e;var t=s(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function l(e){var t=f(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return a.prototype=Error.prototype,n.checkPropTypes=z,n.resetWarningCache=z.resetWarningCache,n.PropTypes=n,n}(T.isElement):function(){function e(e,t,r,n,o,a){if(a!==M){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:H,resetWarningCache:U};return r.PropTypes=r,r}()}),B=function(e){var i=e.blur,c=e.boxTitle,u=e.inputPlaceholder,s=e.buttonLabel,f=e.styles,l=e.children,p=e.sha512.toLowerCase(),y=t.useState(null),d=y[0],m=y[1],b=t.useState(""),v=b[0],h=b[1],g=t.useState(""),S=g[0],E=g[1],O=function(e,r){var n=t.useState(function(){var t=localStorage.getItem(e);return t?JSON.parse(t):""}),o=n[0],a=n[1];return t.useEffect(function(){window.localStorage.setItem(e,JSON.stringify(o))},[o,e]),[o,a]}("cipher"),w=O[0],j=O[1],$=(t.useMemo(function(){return{cipher:w,setCipher:j}},[w,j]),t.useRef(null)),x=t.useState(!0),_=x[0],P=x[1],N=function(){var e=n.SHA512(S).toString();e===p?(j(a.encrypt(JSON.stringify({pass:S}),d.visitorId).toString()),h(e)):(j(""),E(""))};return t.useEffect(function(){!function(){try{Promise.resolve(r.load()).then(function(e){return Promise.resolve(e.get()).then(function(e){var t;try{t=a.decrypt(w,e.visitorId).toString(n.enc.Utf8)}catch(e){t=""}if(t){var r=n.SHA512(JSON.parse(t).pass).toString();h(r)}m(e)})})}catch(e){Promise.reject(e)}}()},[]),t.useEffect(function(){i&&$.current&&_&&o($.current,{useCORS:!0}).then(function(e){$.current.appendChild(e),P(!1)})}),null!==d&&v===p?l:t.createElement("div",null,null===d&&t.createElement("div",{className:"_3O418"},t.createElement("div",{className:"_1djK_"}),t.createElement("div",{className:"_1djK_"}),t.createElement("div",{className:"_1djK_"}),t.createElement("div",{className:"_1djK_"}),t.createElement("div",{className:"_1djK_"})),null!==d&&v!==p&&t.createElement("div",null,t.createElement("div",{style:f.wrapper,className:"_37_FJ"},t.createElement("div",{style:f.header,className:"_ovIFV"},c),t.createElement("div",null,t.createElement("input",{value:S,onChange:function(e){return E(e.target.value)},type:"password",onKeyDown:function(e){"Enter"===e.key&&N()},placeholder:u,style:f.input})),t.createElement("div",{className:"_1YwH3"},t.createElement("button",{style:f.button,onClick:N},s))),t.createElement("div",{ref:$,className:i&&"_3GnVl",style:{filter:""+(i&&"blur(10px)"),overflow:"hidden"}},i&&_&&l)))};B.defaultProps={blur:!1,boxTitle:"This page is password protected.",inputPlaceholder:"Password",buttonLabel:"Submit",styles:{input:{},button:{},header:{},wrapper:{}}},B.propTypes={sha512:Y.string.isRequired,blur:Y.bool,title:Y.string,inputPlaceholder:Y.string,buttonLabel:Y.string,styles:Y.object,children:Y.element.isRequired},module.exports=B; //# sourceMappingURL=index.js.map