mockforme 3.0.0-alpha.2 → 4.0.0
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/README.md +7 -7
- package/dist/index.html +1 -1
- package/dist/mockforme.client.cjs.js +1 -1
- package/dist/mockforme.client.esm.js +1 -1
- package/dist/mockforme.client.umd.js +1 -1
- package/dist/mockforme.d.ts +19 -3
- package/dist/mockforme.server.cjs.js +1 -1
- package/dist/mockforme.server.esm.js +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -27,25 +27,25 @@ yarn add mockforme
|
|
|
27
27
|
```
|
|
28
28
|
* Initialize the SDK using Access Token (Generate access token [here](https://dashboard.mockforme.com/user/token))
|
|
29
29
|
```
|
|
30
|
-
mockforme('
|
|
30
|
+
mockforme('ACCESS_TOKEN').run();
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
* You can also access mockforme object in your browser from window object:
|
|
34
34
|
```
|
|
35
|
-
window.mockforme
|
|
35
|
+
console.log(window.mockforme);
|
|
36
36
|
```
|
|
37
37
|
And initialize it directly from window:
|
|
38
38
|
```
|
|
39
|
-
window.mockforme('
|
|
39
|
+
window.mockforme('ACCESS_TOKEN').run();
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
* You can also directly use mockforme through script file using jsdelivr CDN.
|
|
43
43
|
```
|
|
44
|
-
<script src="https://cdn.jsdelivr.net/npm/mockforme@
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/mockforme@4.0.0/dist/mockforme.client.umd.js"></script>
|
|
45
45
|
|
|
46
46
|
<script>
|
|
47
|
-
window.mockforme
|
|
48
|
-
window.mockforme('
|
|
47
|
+
console.log(window.mockforme);
|
|
48
|
+
window.mockforme('ACCESS_TOKEN').run();
|
|
49
49
|
</script>
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ yarn add mockforme
|
|
|
56
56
|
```
|
|
57
57
|
* Initialize the SDK using Access Token (Generate access token [here](https://dashboard.mockforme.com/user/token))
|
|
58
58
|
```
|
|
59
|
-
mockforme('
|
|
59
|
+
mockforme('ACCESS_TOKEN').run();
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## Example
|
package/dist/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><meta charset="utf-8"><title>mockforme - The best way to mock your APIs</title><meta name="viewport" content="width=device-width,initial-scale=1"><script defer="defer" src="mockforme.client.
|
|
1
|
+
<!doctype html><html><head><meta charset="utf-8"><title>mockforme - The best way to mock your APIs</title><meta name="viewport" content="width=device-width,initial-scale=1"><script defer="defer" src="mockforme.client.umd.js"></script></head><body></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{mockforme:()=>l});const o=t=>{try{return t?t.toLowerCase():t}catch(t){return console.log(t),null}},r=()=>"undefined"==typeof window,n=function(t,e,o){const n=r();var i;function a(){if(4==i.readyState)if(i.status.toString().match(/^20[0-9]$/)){var t=function(){var t=i.getResponseHeader("Content-Type"),e=i.responseText;if(t){var o=t.split(";");try{return"application/json"===o[0]?JSON.parse(e):e}catch(t){throw"Unable to convert response header"}}}();e.call(this,t,i)}else o.call(this,i.responseText,i)}function s(t,e){var o=[];for(var r in t)if(t.hasOwnProperty(r)){var n=e?e+"["+r+"]":r,i=t[r];o.push("object"==typeof i?s(i,n):encodeURIComponent(n)+"="+encodeURIComponent(i))}return o.join("&")}return n||(window.XMLHttpRequest?i=new XMLHttpRequest:window.ActiveXObject&&(i=new ActiveXObject("Microsoft.XMLHTTP"))),{request:function(){if(!n){if(window.XMLHttpRequest)i.onload=a;else{if(!window.ActiveXObject)throw"unable to process ajax";i.onreadystatechange=a}var e=s(t.params);if("get"==t.method.toLowerCase()&&"object"==typeof t.params){if(-1==t.url.indexOf("?"))t.url+="?";else{var o=t.url.split("?");o[1]&&o[1].split("=")[1]&&(t.url+="&")}t.url+=e}t.hasOwnProperty("async")||(t.async=!0),i.open(t.method,t.url,t.async),t.headers&&function(t){for(let e in t)i.setRequestHeader(e,t[e])}(t.headers),i.send(e)}}}},i=(t,e)=>{const o=t.split("/"),r=e.split("/");if(o.length!==r.length)return!1;for(let t=0;t<o.length;t++){const e=o[t];if(e!==r[t]&&":any"!==e)return!1}return!0},a=t=>{if(r())return;const e="https://dashboard.mockforme.com",a=`${e}/mockforme`,s=`${e}/gateway/_mfm_`,c="mockforme";let l=[];const d=window.location,p=d.protocol;if(d.host,d.port,!t)throw"mockforme token cannot be null";const u=(t,e="get")=>{let r=null;if(!Array.isArray(l))return r;for(let n=0;n<l.length;n++){const a=l[n];if(o(a.apiMethod)===o(e)&&(a.apiEndpoint===t||i(a.apiEndpoint,t))){r={url:t,method:a.apiMethod},a._ri_&&(r._ri_=a._ri_);break}}return r},h=()=>{(()=>{const e=window.fetch;window.fetch=function(o,r={}){r.method||(r.method="get");let n=arguments;o&&(o.startsWith("//")?o=`${window.location.protocol}${o}`:o.startsWith("/")&&(o=`${window.location.origin}${o}`));const i=new URL(o),s=i&&i.pathname,l=i&&i.search,d=u(s,r.method);return d&&(o=`${a}${d.url}${l}`,n[0]=o,r.headers={[c]:t},d&&d._ri_&&(r.headers._ri_=d._ri_)),e.call(this,o,r)}})(),(()=>{let e=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(o,r,n,i,s){try{r&&(r.startsWith("//")?r=`${window.location.protocol}${r}`:r.startsWith("/")?r=`${window.location.origin}${r}`:r.indexOf("://")>-1||(r=`${p}//${r}`));const n=new URL(r),i=n&&n.pathname,s=n&&n.search;let l=arguments;const d=u(i,o);return d&&(l[1]=`${a}${d.url}${s}`),this.onreadystatechange=function(){1==this.readyState&&(this.setRequestHeader(c,t),d&&d._ri_&&this.setRequestHeader("_ri_",d._ri_))},e.apply(this,l)}catch(t){return console.log("Error in mock api, could be invalid url",t),e.apply(this,arguments)}}})()};return{run:t=>{var e;h(),e=e=>{t&&t(e)},n({method:"get",url:s,async:!1},(t=>{var o;t&&(o=t,l=l.concat(o)),e(t)}),(()=>{console.log("Error in loading mocked apis")})).request()}}},s=r();s||(window.mockforme=a);let c=a;s&&(c=t=>({run:()=>{}}));const l=c;module.exports=e})();
|
|
1
|
+
function a0_0x207f(_0x18324c,_0x599ce2){const _0x48f576=a0_0x48f5();return a0_0x207f=function(_0x207fa0,_0x158d87){_0x207fa0=_0x207fa0-0x193;let _0x40c64d=_0x48f576[_0x207fa0];return _0x40c64d;},a0_0x207f(_0x18324c,_0x599ce2);}(function(_0x110010,_0x2710a2){const _0xc706e3=a0_0x207f,_0xb1d398=_0x110010();while(!![]){try{const _0x3383d7=parseInt(_0xc706e3(0x1ca))/0x1+-parseInt(_0xc706e3(0x198))/0x2*(parseInt(_0xc706e3(0x1b9))/0x3)+parseInt(_0xc706e3(0x1c4))/0x4*(-parseInt(_0xc706e3(0x1d0))/0x5)+parseInt(_0xc706e3(0x194))/0x6*(parseInt(_0xc706e3(0x1bf))/0x7)+-parseInt(_0xc706e3(0x1ad))/0x8*(parseInt(_0xc706e3(0x199))/0x9)+parseInt(_0xc706e3(0x1a5))/0xa*(parseInt(_0xc706e3(0x1c5))/0xb)+-parseInt(_0xc706e3(0x1a7))/0xc*(-parseInt(_0xc706e3(0x19b))/0xd);if(_0x3383d7===_0x2710a2)break;else _0xb1d398['push'](_0xb1d398['shift']());}catch(_0x342bc3){_0xb1d398['push'](_0xb1d398['shift']());}}}(a0_0x48f5,0x9af8a),((()=>{'use strict';const _0x2c8cfd=a0_0x207f;var _0x24b3b5={'d':(_0x111b03,_0x222fc3)=>{for(var _0x192b8e in _0x222fc3)_0x24b3b5['o'](_0x222fc3,_0x192b8e)&&!_0x24b3b5['o'](_0x111b03,_0x192b8e)&&Object['defineProperty'](_0x111b03,_0x192b8e,{'enumerable':!0x0,'get':_0x222fc3[_0x192b8e]});},'o':(_0x436219,_0x57c75b)=>Object[_0x2c8cfd(0x19d)][_0x2c8cfd(0x1ab)][_0x2c8cfd(0x1ce)](_0x436219,_0x57c75b),'r':_0x4f397b=>{const _0x4ead32=_0x2c8cfd,_0x32516c={};_0x32516c[_0x4ead32(0x1cd)]='Module';const _0x10e2a2={};_0x10e2a2['value']=!0x0,(_0x4ead32(0x1b2)!=typeof Symbol&&Symbol[_0x4ead32(0x1b6)]&&Object[_0x4ead32(0x19a)](_0x4f397b,Symbol[_0x4ead32(0x1b6)],_0x32516c),Object['defineProperty'](_0x4f397b,_0x4ead32(0x1af),_0x10e2a2));}},_0x2fad13={};const _0xf088b8={};_0xf088b8[_0x2c8cfd(0x1c7)]=()=>_0x1ff294,(_0x24b3b5['r'](_0x2fad13),_0x24b3b5['d'](_0x2fad13,_0xf088b8));const _0x73171b=_0x448587=>{try{return _0x448587?_0x448587['toLowerCase']():_0x448587;}catch(_0x28a665){return console['log'](_0x28a665),null;}},_0x222c7a=()=>_0x2c8cfd(0x1b2)==typeof window,_0x429b37=function(_0x17debe,_0xa70f7f,_0x3ffaec){const _0x202757=_0x2c8cfd,_0x13a072=_0x222c7a();var _0x4afaf0;function _0x248a58(){const _0x3470ba=a0_0x207f;if(0x4==_0x4afaf0['readyState']){if(_0x4afaf0['status'][_0x3470ba(0x1bc)]()['match'](/^20[0-9]$/)){var _0x5e9e4e=(function(){const _0x12b01a=_0x3470ba;var _0x49333e=_0x4afaf0['getResponseHeader']('Content-Type'),_0x3f96e9=_0x4afaf0['responseText'];if(_0x49333e){var _0x4fec9a=_0x49333e['split'](';');try{return _0x12b01a(0x1aa)===_0x4fec9a[0x0]?JSON[_0x12b01a(0x1a2)](_0x3f96e9):_0x3f96e9;}catch(_0x41baac){throw'Unable\x20to\x20convert\x20response\x20header';}}}());_0xa70f7f['call'](this,_0x5e9e4e,_0x4afaf0);}else _0x3ffaec['call'](this,_0x4afaf0[_0x3470ba(0x1b8)],_0x4afaf0);}}function _0x1f9d5b(_0x3e9594,_0x93fd69){const _0x59b2db=a0_0x207f;var _0x2fd96b=[];for(var _0x5d51bc in _0x3e9594)if(_0x3e9594['hasOwnProperty'](_0x5d51bc)){var _0x512dab=_0x93fd69?_0x93fd69+'['+_0x5d51bc+']':_0x5d51bc,_0x5f359f=_0x3e9594[_0x5d51bc];_0x2fd96b[_0x59b2db(0x1a6)]('object'==typeof _0x5f359f?_0x1f9d5b(_0x5f359f,_0x512dab):encodeURIComponent(_0x512dab)+'='+encodeURIComponent(_0x5f359f));}return _0x2fd96b['join']('&');}return _0x13a072||(window['XMLHttpRequest']?_0x4afaf0=new XMLHttpRequest():window[_0x202757(0x1bd)]&&(_0x4afaf0=new ActiveXObject(_0x202757(0x197)))),{'request':function(){const _0x4a6154=_0x202757;if(!_0x13a072){if(window[_0x4a6154(0x1b5)])_0x4afaf0['onload']=_0x248a58;else{if(!window['ActiveXObject'])throw _0x4a6154(0x1c1);_0x4afaf0['onreadystatechange']=_0x248a58;}var _0x535c4b=_0x1f9d5b(_0x17debe[_0x4a6154(0x1c6)]);if('get'==_0x17debe[_0x4a6154(0x1c3)]['toLowerCase']()&&'object'==typeof _0x17debe[_0x4a6154(0x1c6)]){if(-0x1==_0x17debe['url'][_0x4a6154(0x1cf)]('?'))_0x17debe[_0x4a6154(0x1cc)]+='?';else{var _0xfc3262=_0x17debe['url']['split']('?');_0xfc3262[0x1]&&_0xfc3262[0x1][_0x4a6154(0x1a0)]('=')[0x1]&&(_0x17debe[_0x4a6154(0x1cc)]+='&');}_0x17debe[_0x4a6154(0x1cc)]+=_0x535c4b;}_0x17debe[_0x4a6154(0x1ab)]('async')||(_0x17debe['async']=!0x0),_0x4afaf0['open'](_0x17debe['method'],_0x17debe['url'],_0x17debe['async']),_0x17debe[_0x4a6154(0x1b7)]&&function(_0x109be3){for(let _0x3972e1 in _0x109be3)_0x4afaf0['setRequestHeader'](_0x3972e1,_0x109be3[_0x3972e1]);}(_0x17debe[_0x4a6154(0x1b7)]),_0x4afaf0['send'](_0x535c4b);}}};},_0x543d41=(_0x4f021a,_0x4f70d9)=>{const _0x1db2e8=_0x2c8cfd,_0x3de536=_0x4f021a[_0x1db2e8(0x1a0)]('/'),_0x5cd30a=_0x4f70d9[_0x1db2e8(0x1a0)]('/');if(_0x3de536[_0x1db2e8(0x1b0)]!==_0x5cd30a['length'])return!0x1;for(let _0x4924c0=0x0;_0x4924c0<_0x3de536['length'];_0x4924c0++){const _0x5e5131=_0x3de536[_0x4924c0];if(_0x5e5131!==_0x5cd30a[_0x4924c0]&&_0x1db2e8(0x1a9)!==_0x5e5131)return!0x1;}return!0x0;},_0x429e4d=_0x50b9b5=>{const _0x4dc666=_0x2c8cfd;if(_0x222c7a())return;const _0x597825='https://api.mockforme.com',_0xd14e70=_0x597825+'/mockforme';let _0x1006de=_0x597825+'/gateway/3f4eae522b';const _0xd44c35=_0x4dc666(0x1c7),_0x3cc565='mfmver',_0xc9c9e9='4.0.0';let _0x1efef3=null,_0x25a881=null,_0x10aff1=null,_0x2252cb=[];const _0x3ecad3=window['location'],_0x5f1265=_0x3ecad3['protocol'];if(_0x3ecad3['host'],_0x3ecad3['port'],!_0x50b9b5)throw'mockforme\x20token\x20cannot\x20be\x20null';const _0x954693=()=>_0xd14e70+'/'+_0x1efef3+'/'+_0x25a881,_0x5ae813=(_0x21e0d7,_0x333798='get')=>{const _0x5ec9c2=_0x4dc666;let _0x4de651=null;if(!Array[_0x5ec9c2(0x196)](_0x2252cb))return _0x4de651;for(let _0xcdf7cb=0x0;_0xcdf7cb<_0x2252cb['length'];_0xcdf7cb++){const _0x4a8a71=_0x2252cb[_0xcdf7cb];if(_0x73171b(_0x4a8a71['apiMethod'])===_0x73171b(_0x333798)&&(_0x4a8a71['apiEndpoint']===_0x21e0d7||_0x543d41(_0x4a8a71[_0x5ec9c2(0x1c8)],_0x21e0d7))){const _0xfe7ccf={};_0xfe7ccf['url']=_0x21e0d7,_0xfe7ccf['method']=_0x4a8a71['apiMethod'],(_0x4de651=_0xfe7ccf,_0x4a8a71['_ri_']&&(_0x4de651[_0x5ec9c2(0x1cb)]=_0x4a8a71['_ri_']));break;}}return _0x4de651;},_0x561f04=()=>{((()=>{const _0x58d4e5=a0_0x207f,_0x6b7faa=window[_0x58d4e5(0x1d1)];window['fetch']=function(_0x4d98a1,_0x46bce4={}){const _0x115094=_0x58d4e5;_0x46bce4[_0x115094(0x1c3)]||(_0x46bce4[_0x115094(0x1c3)]=_0x115094(0x1b1));let _0x15758c=arguments;_0x4d98a1&&(_0x4d98a1['startsWith']('//')?_0x4d98a1=''+window[_0x115094(0x1b3)]['protocol']+_0x4d98a1:_0x4d98a1['startsWith']('/')&&(_0x4d98a1=''+window['location']['origin']+_0x4d98a1));const _0x10b25c=new URL(_0x4d98a1),_0xef2296=_0x10b25c&&_0x10b25c[_0x115094(0x19e)],_0x396ef9=_0x10b25c&&_0x10b25c[_0x115094(0x1a8)],_0x453f6c=_0x5ae813(_0xef2296,_0x46bce4[_0x115094(0x1c3)]),_0x4b90d7={};return _0x4b90d7[_0xd44c35]=_0x50b9b5,_0x4b90d7[_0x3cc565]=_0xc9c9e9,(_0x453f6c&&(_0x4d98a1=''+_0x954693()+_0x453f6c['url']+_0x396ef9,_0x15758c[0x0]=_0x4d98a1,_0x46bce4['headers']=_0x4b90d7,_0x453f6c&&_0x453f6c['_ri_']&&(_0x46bce4[_0x115094(0x1b7)][_0x115094(0x1cb)]=_0x453f6c[_0x115094(0x1cb)]),_0x10aff1&&(_0x46bce4['headers']['x-mfm-key']=_0x10aff1)),_0x6b7faa[_0x115094(0x1ce)](this,_0x4d98a1,_0x46bce4));};})()),((()=>{const _0x232b03=a0_0x207f;let _0x1bede3=window[_0x232b03(0x1b5)]['prototype'][_0x232b03(0x1a3)];window['XMLHttpRequest']['prototype'][_0x232b03(0x1a3)]=function(_0x5df6e9,_0x42b6a0,_0x356924,_0x3c02a6,_0x92fa69){const _0x4bf862=_0x232b03;try{_0x42b6a0&&(_0x42b6a0[_0x4bf862(0x19f)]('//')?_0x42b6a0=''+window[_0x4bf862(0x1b3)]['protocol']+_0x42b6a0:_0x42b6a0['startsWith']('/')?_0x42b6a0=''+window['location'][_0x4bf862(0x1be)]+_0x42b6a0:_0x42b6a0[_0x4bf862(0x1cf)](_0x4bf862(0x195))>-0x1||(_0x42b6a0=_0x5f1265+'//'+_0x42b6a0));const _0x36661b=new URL(_0x42b6a0),_0x28c5d0=_0x36661b&&_0x36661b['pathname'],_0x363fb4=_0x36661b&&_0x36661b['search'];let _0x51d19e=arguments;const _0x36a1ac=_0x5ae813(_0x28c5d0,_0x5df6e9);return _0x36a1ac&&(_0x51d19e[0x1]=''+_0x954693()+_0x36a1ac[_0x4bf862(0x1cc)]+_0x363fb4),this[_0x4bf862(0x1ba)]=function(){const _0x5ecef5=_0x4bf862;if(0x1==this['readyState']){const _0x4198e8=['api.mockforme.com','dashboard.mockforme.com',_0x5ecef5(0x1c9)],_0x398582=new URL(_0x51d19e[0x1]);_0x4198e8['includes'](_0x398582['hostname'])&&(this['setRequestHeader'](_0xd44c35,_0x50b9b5),this['setRequestHeader'](_0x3cc565,_0xc9c9e9),_0x10aff1&&this['setRequestHeader'](_0x5ecef5(0x1ae),_0x10aff1),_0x36a1ac&&_0x36a1ac['_ri_']&&this['setRequestHeader']('_ri_',_0x36a1ac['_ri_']));}},_0x1bede3[_0x4bf862(0x1c0)](this,_0x51d19e);}catch(_0x120f97){return console['log'](_0x4bf862(0x1ac),_0x120f97),_0x1bede3['apply'](this,arguments);}};})());},_0x2a2f1d=_0x56fc52=>{const _0x47bfac=_0x4dc666,_0x3cea7d={};_0x3cea7d['method']=_0x47bfac(0x1b1),_0x3cea7d['url']=_0x1006de,_0x3cea7d[_0x47bfac(0x1a1)]=!0x1,_0x429b37(_0x3cea7d,_0x13c0e3=>{if(_0x13c0e3){const {di:_0x2d7eb3,iv:_0x455a28,_o:_0x14786c,_mck:_0x5c69f6,mk:_0x2febb8}=_0x13c0e3;_0x1efef3=_0x14786c,_0x25a881=_0x2febb8,_0x10aff1=_0x5c69f6;const _0xd4c236=function({di:_0x2d5271,iv:_0xbb32f7},_0x2ed4bf){const _0x528a61=a0_0x207f;var _0xa0028a;const _0x2e8daa=function(_0x31fe24,_0xc54bad){const _0xe993fa=a0_0x207f,_0x49bad6=_0xc54bad['length'];return _0x31fe24['split']('')['map']((_0x373ca8,_0x24365e)=>String[_0xe993fa(0x1b4)](_0x373ca8[_0xe993fa(0x193)](0x0)^_0xc54bad['charCodeAt'](_0x24365e%_0x49bad6)))[_0xe993fa(0x1bb)]('');}((_0xa0028a=_0x2d5271,'undefined'!=typeof Buffer?Buffer[_0x528a61(0x1a4)](_0xa0028a,_0x528a61(0x1c2))['toString']('utf8'):decodeURIComponent(escape(atob(_0xa0028a)))),_0x2ed4bf+_0xbb32f7);return JSON['parse'](_0x2e8daa);}({'di':_0x2d7eb3,'iv':_0x455a28},_0x14786c);_0xd4c236&&(_0x95c673=_0xd4c236,_0x2252cb=_0x2252cb['concat'](_0x95c673),_0x56fc52(_0xd4c236));}var _0x95c673;},()=>{const _0x358279=_0x47bfac;console['log'](_0x358279(0x19c));})['request']();};return{'run':_0x2ba4ff=>{_0x561f04(),_0x2a2f1d(_0x3a6ec3=>{_0x2ba4ff&&_0x2ba4ff(_0x3a6ec3);});}};},_0x57c166=_0x222c7a();_0x57c166||(window[_0x2c8cfd(0x1c7)]=_0x429e4d);let _0x15f66f=_0x429e4d;_0x57c166&&(_0x15f66f=_0x53c947=>({'run':()=>{}}));const _0x1ff294=_0x15f66f;module['exports']=_0x2fad13;})()));function a0_0x48f5(){const _0x42180f=['XMLHttpRequest','toStringTag','headers','responseText','3SMPDLF','onreadystatechange','join','toString','ActiveXObject','origin','1656802XdkVCL','apply','unable\x20to\x20process\x20ajax','base64','method','14184ilMwka','297mwUkxT','params','mockforme','apiEndpoint','localhost','1062328bqbysL','_ri_','url','value','call','indexOf','1570MPxopu','fetch','charCodeAt','30IczIoY','://','isArray','Microsoft.XMLHTTP','1561588DMgNfD','726651Zqletf','defineProperty','13pAMbbX','Error\x20in\x20loading\x20mocked\x20apis','prototype','pathname','startsWith','split','async','parse','open','from','224040wtvvSI','push','6797556iBZMvM','search',':any','application/json','hasOwnProperty','Error\x20in\x20mock\x20api,\x20could\x20be\x20invalid\x20url','88xCeSzu','x-mfm-key','__esModule','length','get','undefined','location','fromCharCode'];a0_0x48f5=function(){return _0x42180f;};return a0_0x48f5();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{_:()=>l});const o=t=>{try{return t?t.toLowerCase():t}catch(t){return console.log(t),null}},r=()=>"undefined"==typeof window,n=function(t,e,o){const n=r();var i;function a(){if(4==i.readyState)if(i.status.toString().match(/^20[0-9]$/)){var t=function(){var t=i.getResponseHeader("Content-Type"),e=i.responseText;if(t){var o=t.split(";");try{return"application/json"===o[0]?JSON.parse(e):e}catch(t){throw"Unable to convert response header"}}}();e.call(this,t,i)}else o.call(this,i.responseText,i)}function s(t,e){var o=[];for(var r in t)if(t.hasOwnProperty(r)){var n=e?e+"["+r+"]":r,i=t[r];o.push("object"==typeof i?s(i,n):encodeURIComponent(n)+"="+encodeURIComponent(i))}return o.join("&")}return n||(window.XMLHttpRequest?i=new XMLHttpRequest:window.ActiveXObject&&(i=new ActiveXObject("Microsoft.XMLHTTP"))),{request:function(){if(!n){if(window.XMLHttpRequest)i.onload=a;else{if(!window.ActiveXObject)throw"unable to process ajax";i.onreadystatechange=a}var e=s(t.params);if("get"==t.method.toLowerCase()&&"object"==typeof t.params){if(-1==t.url.indexOf("?"))t.url+="?";else{var o=t.url.split("?");o[1]&&o[1].split("=")[1]&&(t.url+="&")}t.url+=e}t.hasOwnProperty("async")||(t.async=!0),i.open(t.method,t.url,t.async),t.headers&&function(t){for(let e in t)i.setRequestHeader(e,t[e])}(t.headers),i.send(e)}}}},i=(t,e)=>{const o=t.split("/"),r=e.split("/");if(o.length!==r.length)return!1;for(let t=0;t<o.length;t++){const e=o[t];if(e!==r[t]&&":any"!==e)return!1}return!0},a=t=>{if(r())return;const e="https://dashboard.mockforme.com",a=`${e}/mockforme`,s=`${e}/gateway/_mfm_`,c="mockforme";let l=[];const p=window.location,d=p.protocol;if(p.host,p.port,!t)throw"mockforme token cannot be null";const u=(t,e="get")=>{let r=null;if(!Array.isArray(l))return r;for(let n=0;n<l.length;n++){const a=l[n];if(o(a.apiMethod)===o(e)&&(a.apiEndpoint===t||i(a.apiEndpoint,t))){r={url:t,method:a.apiMethod},a._ri_&&(r._ri_=a._ri_);break}}return r},h=()=>{(()=>{const e=window.fetch;window.fetch=function(o,r={}){r.method||(r.method="get");let n=arguments;o&&(o.startsWith("//")?o=`${window.location.protocol}${o}`:o.startsWith("/")&&(o=`${window.location.origin}${o}`));const i=new URL(o),s=i&&i.pathname,l=i&&i.search,p=u(s,r.method);return p&&(o=`${a}${p.url}${l}`,n[0]=o,r.headers={[c]:t},p&&p._ri_&&(r.headers._ri_=p._ri_)),e.call(this,o,r)}})(),(()=>{let e=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(o,r,n,i,s){try{r&&(r.startsWith("//")?r=`${window.location.protocol}${r}`:r.startsWith("/")?r=`${window.location.origin}${r}`:r.indexOf("://")>-1||(r=`${d}//${r}`));const n=new URL(r),i=n&&n.pathname,s=n&&n.search;let l=arguments;const p=u(i,o);return p&&(l[1]=`${a}${p.url}${s}`),this.onreadystatechange=function(){1==this.readyState&&(this.setRequestHeader(c,t),p&&p._ri_&&this.setRequestHeader("_ri_",p._ri_))},e.apply(this,l)}catch(t){return console.log("Error in mock api, could be invalid url",t),e.apply(this,arguments)}}})()};return{run:t=>{var e;h(),e=e=>{t&&t(e)},n({method:"get",url:s,async:!1},(t=>{var o;t&&(o=t,l=l.concat(o)),e(t)}),(()=>{console.log("Error in loading mocked apis")})).request()}}},s=r();s||(window.mockforme=a);let c=a;s&&(c=t=>({run:()=>{}}));const l=c;var p=e._;export{p as mockforme};
|
|
1
|
+
const a0_0x59d0fb=a0_0x46a5;(function(_0x579590,_0x2d3d3c){const _0x3c4be3=a0_0x46a5,_0x15a3da=_0x579590();while(!![]){try{const _0x19b8a7=-parseInt(_0x3c4be3(0xce))/0x1*(parseInt(_0x3c4be3(0xe7))/0x2)+-parseInt(_0x3c4be3(0xc6))/0x3+-parseInt(_0x3c4be3(0xe0))/0x4+parseInt(_0x3c4be3(0xcf))/0x5*(parseInt(_0x3c4be3(0xf9))/0x6)+-parseInt(_0x3c4be3(0xd2))/0x7+-parseInt(_0x3c4be3(0xc2))/0x8*(parseInt(_0x3c4be3(0xdd))/0x9)+parseInt(_0x3c4be3(0xd1))/0xa;if(_0x19b8a7===_0x2d3d3c)break;else _0x15a3da['push'](_0x15a3da['shift']());}catch(_0x3e9417){_0x15a3da['push'](_0x15a3da['shift']());}}}(a0_0x1371,0x318de));var e={'d':(_0x3523b5,_0x50114f)=>{const _0x5c0e30=a0_0x46a5;for(var _0x4d5ba3 in _0x50114f)e['o'](_0x50114f,_0x4d5ba3)&&!e['o'](_0x3523b5,_0x4d5ba3)&&Object[_0x5c0e30(0xc9)](_0x3523b5,_0x4d5ba3,{'enumerable':!0x0,'get':_0x50114f[_0x4d5ba3]});},'o':(_0x1a9d3e,_0x417618)=>Object[a0_0x59d0fb(0xdc)]['hasOwnProperty'][a0_0x59d0fb(0xe2)](_0x1a9d3e,_0x417618)},t={};const a0_0x5bab25={};a0_0x5bab25['_']=()=>l,e['d'](t,a0_0x5bab25);const o=_0xdfa8d9=>{const _0x376644=a0_0x59d0fb;try{return _0xdfa8d9?_0xdfa8d9['toLowerCase']():_0xdfa8d9;}catch(_0x370b8d){return console[_0x376644(0xc4)](_0x370b8d),null;}},n=()=>'undefined'==typeof window,r=function(_0x4ccf8f,_0x56a405,_0x345c95){const _0x895854=a0_0x59d0fb,_0x1f3966=n();var _0x2e58e9;function _0x4749a5(){const _0x5b8af5=a0_0x46a5;if(0x4==_0x2e58e9['readyState']){if(_0x2e58e9[_0x5b8af5(0xd5)][_0x5b8af5(0xe4)]()['match'](/^20[0-9]$/)){var _0x360fdb=(function(){const _0x2decfd=_0x5b8af5;var _0x2d81aa=_0x2e58e9[_0x2decfd(0xee)]('Content-Type'),_0x36a2a5=_0x2e58e9[_0x2decfd(0xcd)];if(_0x2d81aa){var _0x58cf8b=_0x2d81aa['split'](';');try{return'application/json'===_0x58cf8b[0x0]?JSON['parse'](_0x36a2a5):_0x36a2a5;}catch(_0x5628d7){throw'Unable\x20to\x20convert\x20response\x20header';}}}());_0x56a405[_0x5b8af5(0xe2)](this,_0x360fdb,_0x2e58e9);}else _0x345c95['call'](this,_0x2e58e9[_0x5b8af5(0xcd)],_0x2e58e9);}}function _0x4180a2(_0x38f092,_0x28fd70){const _0xf412ff=a0_0x46a5;var _0x3d36ec=[];for(var _0x1c7565 in _0x38f092)if(_0x38f092['hasOwnProperty'](_0x1c7565)){var _0x4430d6=_0x28fd70?_0x28fd70+'['+_0x1c7565+']':_0x1c7565,_0x531e8b=_0x38f092[_0x1c7565];_0x3d36ec[_0xf412ff(0xf5)]('object'==typeof _0x531e8b?_0x4180a2(_0x531e8b,_0x4430d6):encodeURIComponent(_0x4430d6)+'='+encodeURIComponent(_0x531e8b));}return _0x3d36ec['join']('&');}return _0x1f3966||(window[_0x895854(0xde)]?_0x2e58e9=new XMLHttpRequest():window[_0x895854(0xe8)]&&(_0x2e58e9=new ActiveXObject(_0x895854(0xd9)))),{'request':function(){const _0x20700a=_0x895854;if(!_0x1f3966){if(window['XMLHttpRequest'])_0x2e58e9['onload']=_0x4749a5;else{if(!window['ActiveXObject'])throw _0x20700a(0xcc);_0x2e58e9[_0x20700a(0xd4)]=_0x4749a5;}var _0x2c306f=_0x4180a2(_0x4ccf8f[_0x20700a(0xe5)]);if('get'==_0x4ccf8f['method']['toLowerCase']()&&_0x20700a(0xc8)==typeof _0x4ccf8f['params']){if(-0x1==_0x4ccf8f['url'][_0x20700a(0xd0)]('?'))_0x4ccf8f[_0x20700a(0xea)]+='?';else{var _0x1132a8=_0x4ccf8f['url'][_0x20700a(0xd7)]('?');_0x1132a8[0x1]&&_0x1132a8[0x1][_0x20700a(0xd7)]('=')[0x1]&&(_0x4ccf8f['url']+='&');}_0x4ccf8f[_0x20700a(0xea)]+=_0x2c306f;}_0x4ccf8f[_0x20700a(0xc5)](_0x20700a(0xed))||(_0x4ccf8f[_0x20700a(0xed)]=!0x0),_0x2e58e9['open'](_0x4ccf8f['method'],_0x4ccf8f['url'],_0x4ccf8f['async']),_0x4ccf8f['headers']&&function(_0x6a6d95){for(let _0x5726c8 in _0x6a6d95)_0x2e58e9['setRequestHeader'](_0x5726c8,_0x6a6d95[_0x5726c8]);}(_0x4ccf8f['headers']),_0x2e58e9[_0x20700a(0xdf)](_0x2c306f);}}};},i=(_0x307ef5,_0x1dd3c1)=>{const _0x6aa83b=a0_0x59d0fb,_0x28e3ca=_0x307ef5['split']('/'),_0x2068de=_0x1dd3c1[_0x6aa83b(0xd7)]('/');if(_0x28e3ca['length']!==_0x2068de['length'])return!0x1;for(let _0x12bcf4=0x0;_0x12bcf4<_0x28e3ca['length'];_0x12bcf4++){const _0x255903=_0x28e3ca[_0x12bcf4];if(_0x255903!==_0x2068de[_0x12bcf4]&&':any'!==_0x255903)return!0x1;}return!0x0;},s=_0x435a2f=>{const _0x506568=a0_0x59d0fb;if(n())return;const _0x45ff5d='https://api.mockforme.com',_0x5e4384=_0x45ff5d+'/mockforme';let _0x2ab033=_0x45ff5d+'/gateway/3f4eae522b';const _0x1c6bcd=_0x506568(0xef),_0x3de70c=_0x506568(0xe9),_0x419cb4='4.0.0';let _0x1ce52e=null,_0x3c2a6a=null,_0x5b4468=null,_0x370d37=[];const _0x81f1b3=window['location'],_0x3a69d3=_0x81f1b3['protocol'];if(_0x81f1b3[_0x506568(0xd8)],_0x81f1b3['port'],!_0x435a2f)throw _0x506568(0xda);const _0x34ffef=()=>_0x5e4384+'/'+_0x1ce52e+'/'+_0x3c2a6a,_0x30b7e0=(_0x5693f8,_0x203549='get')=>{const _0x1bafcf=_0x506568;let _0x398c77=null;if(!Array[_0x1bafcf(0xf0)](_0x370d37))return _0x398c77;for(let _0x39488b=0x0;_0x39488b<_0x370d37[_0x1bafcf(0xf4)];_0x39488b++){const _0x12b4f8=_0x370d37[_0x39488b];if(o(_0x12b4f8['apiMethod'])===o(_0x203549)&&(_0x12b4f8['apiEndpoint']===_0x5693f8||i(_0x12b4f8['apiEndpoint'],_0x5693f8))){const _0x47d804={};_0x47d804['url']=_0x5693f8,_0x47d804['method']=_0x12b4f8['apiMethod'],(_0x398c77=_0x47d804,_0x12b4f8[_0x1bafcf(0xd3)]&&(_0x398c77[_0x1bafcf(0xd3)]=_0x12b4f8[_0x1bafcf(0xd3)]));break;}}return _0x398c77;},_0x4871e6=()=>{((()=>{const _0x492ebf=window['fetch'];window['fetch']=function(_0x419f73,_0xadb671={}){const _0x57518e=a0_0x46a5;_0xadb671[_0x57518e(0xf2)]||(_0xadb671[_0x57518e(0xf2)]='get');let _0x4c02e7=arguments;_0x419f73&&(_0x419f73['startsWith']('//')?_0x419f73=''+window['location'][_0x57518e(0xc3)]+_0x419f73:_0x419f73[_0x57518e(0xfc)]('/')&&(_0x419f73=''+window['location']['origin']+_0x419f73));const _0x295d40=new URL(_0x419f73),_0x938a41=_0x295d40&&_0x295d40['pathname'],_0x2fda20=_0x295d40&&_0x295d40[_0x57518e(0xcb)],_0x1370ef=_0x30b7e0(_0x938a41,_0xadb671['method']),_0x54e4ae={};return _0x54e4ae[_0x1c6bcd]=_0x435a2f,_0x54e4ae[_0x3de70c]=_0x419cb4,(_0x1370ef&&(_0x419f73=''+_0x34ffef()+_0x1370ef[_0x57518e(0xea)]+_0x2fda20,_0x4c02e7[0x0]=_0x419f73,_0xadb671[_0x57518e(0xfb)]=_0x54e4ae,_0x1370ef&&_0x1370ef['_ri_']&&(_0xadb671[_0x57518e(0xfb)]['_ri_']=_0x1370ef[_0x57518e(0xd3)]),_0x5b4468&&(_0xadb671[_0x57518e(0xfb)]['x-mfm-key']=_0x5b4468)),_0x492ebf['call'](this,_0x419f73,_0xadb671));};})()),((()=>{const _0x3af522=a0_0x46a5;let _0x39d3b0=window['XMLHttpRequest']['prototype']['open'];window['XMLHttpRequest']['prototype'][_0x3af522(0xdb)]=function(_0x434050,_0xb5ad3a,_0x2d784e,_0x500f31,_0x151d9f){const _0x3f99cc=_0x3af522;try{_0xb5ad3a&&(_0xb5ad3a[_0x3f99cc(0xfc)]('//')?_0xb5ad3a=''+window['location'][_0x3f99cc(0xc3)]+_0xb5ad3a:_0xb5ad3a['startsWith']('/')?_0xb5ad3a=''+window['location'][_0x3f99cc(0xca)]+_0xb5ad3a:_0xb5ad3a['indexOf'](_0x3f99cc(0xeb))>-0x1||(_0xb5ad3a=_0x3a69d3+'//'+_0xb5ad3a));const _0x44bb0c=new URL(_0xb5ad3a),_0x43c291=_0x44bb0c&&_0x44bb0c[_0x3f99cc(0xf1)],_0x1dac55=_0x44bb0c&&_0x44bb0c[_0x3f99cc(0xcb)];let _0x1abd98=arguments;const _0x440b77=_0x30b7e0(_0x43c291,_0x434050);return _0x440b77&&(_0x1abd98[0x1]=''+_0x34ffef()+_0x440b77['url']+_0x1dac55),this['onreadystatechange']=function(){const _0xb1ab70=_0x3f99cc;if(0x1==this['readyState']){const _0x41f122=[_0xb1ab70(0xf3),'dashboard.mockforme.com',_0xb1ab70(0xe1)],_0x4ead08=new URL(_0x1abd98[0x1]);_0x41f122['includes'](_0x4ead08[_0xb1ab70(0xd6)])&&(this[_0xb1ab70(0xf6)](_0x1c6bcd,_0x435a2f),this[_0xb1ab70(0xf6)](_0x3de70c,_0x419cb4),_0x5b4468&&this[_0xb1ab70(0xf6)]('x-mfm-key',_0x5b4468),_0x440b77&&_0x440b77['_ri_']&&this[_0xb1ab70(0xf6)](_0xb1ab70(0xd3),_0x440b77['_ri_']));}},_0x39d3b0[_0x3f99cc(0xf8)](this,_0x1abd98);}catch(_0x44f25e){return console[_0x3f99cc(0xc4)](_0x3f99cc(0xe3),_0x44f25e),_0x39d3b0['apply'](this,arguments);}};})());},_0x4d653e=_0x1d11af=>{const _0x93bb1a=_0x506568,_0x2e3431={};_0x2e3431[_0x93bb1a(0xf2)]='get',_0x2e3431['url']=_0x2ab033,_0x2e3431['async']=!0x1,r(_0x2e3431,_0x4189ef=>{const _0x354430=_0x93bb1a;if(_0x4189ef){const {di:_0x56e934,iv:_0x18ad03,_o:_0x5e1df7,_mck:_0x3a58bc,mk:_0x405b61}=_0x4189ef;_0x1ce52e=_0x5e1df7,_0x3c2a6a=_0x405b61,_0x5b4468=_0x3a58bc;const _0x260d20=function({di:_0x2ab0aa,iv:_0x8185b7},_0x4693de){const _0x4ecd41=a0_0x46a5;var _0x266c71;const _0x49c064=function(_0x22b214,_0x220ab7){const _0x3916bc=a0_0x46a5,_0x4089d8=_0x220ab7[_0x3916bc(0xf4)];return _0x22b214[_0x3916bc(0xd7)]('')['map']((_0x3eb273,_0x5e4bd4)=>String[_0x3916bc(0xfa)](_0x3eb273['charCodeAt'](0x0)^_0x220ab7[_0x3916bc(0xf7)](_0x5e4bd4%_0x4089d8)))['join']('');}((_0x266c71=_0x2ab0aa,'undefined'!=typeof Buffer?Buffer['from'](_0x266c71,_0x4ecd41(0xec))['toString']('utf8'):decodeURIComponent(escape(atob(_0x266c71)))),_0x4693de+_0x8185b7);return JSON['parse'](_0x49c064);}({'di':_0x56e934,'iv':_0x18ad03},_0x5e1df7);_0x260d20&&(_0x57512d=_0x260d20,_0x370d37=_0x370d37[_0x354430(0xc7)](_0x57512d),_0x1d11af(_0x260d20));}var _0x57512d;},()=>{const _0x27307b=_0x93bb1a;console[_0x27307b(0xc4)]('Error\x20in\x20loading\x20mocked\x20apis');})[_0x93bb1a(0xe6)]();};return{'run':_0x420e95=>{_0x4871e6(),_0x4d653e(_0x33ec9d=>{_0x420e95&&_0x420e95(_0x33ec9d);});}};},a=n();a||(window[a0_0x59d0fb(0xef)]=s);let c=s;a&&(c=_0x59554b=>({'run':()=>{}}));const l=c;function a0_0x1371(){const _0x4021a4=['prototype','573471PEaUMl','XMLHttpRequest','send','360368JWalFa','localhost','call','Error\x20in\x20mock\x20api,\x20could\x20be\x20invalid\x20url','toString','params','request','2dYuJsn','ActiveXObject','mfmver','url','://','base64','async','getResponseHeader','mockforme','isArray','pathname','method','api.mockforme.com','length','push','setRequestHeader','charCodeAt','apply','126GsjPbU','fromCharCode','headers','startsWith','16IPNAnQ','protocol','log','hasOwnProperty','1007097fuVkXf','concat','object','defineProperty','origin','search','unable\x20to\x20process\x20ajax','responseText','380667hPgrrY','45290STIcTj','indexOf','10530020ABxyfM','744450gEpKAl','_ri_','onreadystatechange','status','hostname','split','host','Microsoft.XMLHTTP','mockforme\x20token\x20cannot\x20be\x20null','open'];a0_0x1371=function(){return _0x4021a4;};return a0_0x1371();}var d=t['_'];function a0_0x46a5(_0x53b975,_0x432452){const _0x13719a=a0_0x1371();return a0_0x46a5=function(_0x46a5ea,_0x2a9195){_0x46a5ea=_0x46a5ea-0xc2;let _0x388a92=_0x13719a[_0x46a5ea];return _0x388a92;},a0_0x46a5(_0x53b975,_0x432452);}export{d as mockforme};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mockforme=e():t.mockforme=e()}(this,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{mockforme:()=>l});const o=t=>{try{return t?t.toLowerCase():t}catch(t){return console.log(t),null}},r=()=>"undefined"==typeof window,n=function(t,e,o){const n=r();var i;function s(){if(4==i.readyState)if(i.status.toString().match(/^20[0-9]$/)){var t=function(){var t=i.getResponseHeader("Content-Type"),e=i.responseText;if(t){var o=t.split(";");try{return"application/json"===o[0]?JSON.parse(e):e}catch(t){throw"Unable to convert response header"}}}();e.call(this,t,i)}else o.call(this,i.responseText,i)}function a(t,e){var o=[];for(var r in t)if(t.hasOwnProperty(r)){var n=e?e+"["+r+"]":r,i=t[r];o.push("object"==typeof i?a(i,n):encodeURIComponent(n)+"="+encodeURIComponent(i))}return o.join("&")}return n||(window.XMLHttpRequest?i=new XMLHttpRequest:window.ActiveXObject&&(i=new ActiveXObject("Microsoft.XMLHTTP"))),{request:function(){if(!n){if(window.XMLHttpRequest)i.onload=s;else{if(!window.ActiveXObject)throw"unable to process ajax";i.onreadystatechange=s}var e=a(t.params);if("get"==t.method.toLowerCase()&&"object"==typeof t.params){if(-1==t.url.indexOf("?"))t.url+="?";else{var o=t.url.split("?");o[1]&&o[1].split("=")[1]&&(t.url+="&")}t.url+=e}t.hasOwnProperty("async")||(t.async=!0),i.open(t.method,t.url,t.async),t.headers&&function(t){for(let e in t)i.setRequestHeader(e,t[e])}(t.headers),i.send(e)}}}},i=(t,e)=>{const o=t.split("/"),r=e.split("/");if(o.length!==r.length)return!1;for(let t=0;t<o.length;t++){const e=o[t];if(e!==r[t]&&":any"!==e)return!1}return!0},s=t=>{if(r())return;const e="https://dashboard.mockforme.com",s=`${e}/mockforme`,a=`${e}/gateway/_mfm_`,c="mockforme";let l=[];const p=window.location,d=p.protocol;if(p.host,p.port,!t)throw"mockforme token cannot be null";const u=(t,e="get")=>{let r=null;if(!Array.isArray(l))return r;for(let n=0;n<l.length;n++){const s=l[n];if(o(s.apiMethod)===o(e)&&(s.apiEndpoint===t||i(s.apiEndpoint,t))){r={url:t,method:s.apiMethod},s._ri_&&(r._ri_=s._ri_);break}}return r},f=()=>{(()=>{const e=window.fetch;window.fetch=function(o,r={}){r.method||(r.method="get");let n=arguments;o&&(o.startsWith("//")?o=`${window.location.protocol}${o}`:o.startsWith("/")&&(o=`${window.location.origin}${o}`));const i=new URL(o),a=i&&i.pathname,l=i&&i.search,p=u(a,r.method);return p&&(o=`${s}${p.url}${l}`,n[0]=o,r.headers={[c]:t},p&&p._ri_&&(r.headers._ri_=p._ri_)),e.call(this,o,r)}})(),(()=>{let e=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(o,r,n,i,a){try{r&&(r.startsWith("//")?r=`${window.location.protocol}${r}`:r.startsWith("/")?r=`${window.location.origin}${r}`:r.indexOf("://")>-1||(r=`${d}//${r}`));const n=new URL(r),i=n&&n.pathname,a=n&&n.search;let l=arguments;const p=u(i,o);return p&&(l[1]=`${s}${p.url}${a}`),this.onreadystatechange=function(){1==this.readyState&&(this.setRequestHeader(c,t),p&&p._ri_&&this.setRequestHeader("_ri_",p._ri_))},e.apply(this,l)}catch(t){return console.log("Error in mock api, could be invalid url",t),e.apply(this,arguments)}}})()};return{run:t=>{var e;f(),e=e=>{t&&t(e)},n({method:"get",url:a,async:!1},(t=>{var o;t&&(o=t,l=l.concat(o)),e(t)}),(()=>{console.log("Error in loading mocked apis")})).request()}}},a=r();a||(window.mockforme=s);let c=s;a&&(c=t=>({run:()=>{}}));const l=c;return e.mockforme})()));
|
|
1
|
+
(function(_0x2b61fd,_0x1c34d3){const _0x1ae1ac=a0_0xf098,_0x10f294=_0x2b61fd();while(!![]){try{const _0x4e5d39=parseInt(_0x1ae1ac(0xf1))/0x1*(-parseInt(_0x1ae1ac(0xd0))/0x2)+parseInt(_0x1ae1ac(0xe1))/0x3*(parseInt(_0x1ae1ac(0xd2))/0x4)+-parseInt(_0x1ae1ac(0xfc))/0x5+-parseInt(_0x1ae1ac(0xcf))/0x6+parseInt(_0x1ae1ac(0xf9))/0x7*(-parseInt(_0x1ae1ac(0xd1))/0x8)+-parseInt(_0x1ae1ac(0xd5))/0x9*(-parseInt(_0x1ae1ac(0xcc))/0xa)+-parseInt(_0x1ae1ac(0xec))/0xb*(-parseInt(_0x1ae1ac(0xe6))/0xc);if(_0x4e5d39===_0x1c34d3)break;else _0x10f294['push'](_0x10f294['shift']());}catch(_0x4b218f){_0x10f294['push'](_0x10f294['shift']());}}}(a0_0xe92d,0x6e04a),!function(_0x1df2d2,_0x10380d){const _0x19c373=a0_0xf098;'object'==typeof exports&&_0x19c373(0xdd)==typeof module?module['exports']=_0x10380d():'function'==typeof define&&define[_0x19c373(0xd6)]?define([],_0x10380d):_0x19c373(0xdd)==typeof exports?exports[_0x19c373(0xde)]=_0x10380d():_0x1df2d2['mockforme']=_0x10380d();}(this,()=>((()=>{'use strict';const _0x478eea=a0_0xf098;var _0x3da9c5={'d':(_0x2feb6e,_0x839bab)=>{const _0x1e3496=a0_0xf098;for(var _0x4cd0bb in _0x839bab)_0x3da9c5['o'](_0x839bab,_0x4cd0bb)&&!_0x3da9c5['o'](_0x2feb6e,_0x4cd0bb)&&Object[_0x1e3496(0xcd)](_0x2feb6e,_0x4cd0bb,{'enumerable':!0x0,'get':_0x839bab[_0x4cd0bb]});},'o':(_0x2e77fb,_0x4572ca)=>Object['prototype'][_0x478eea(0xd3)]['call'](_0x2e77fb,_0x4572ca)},_0x38c22b={};const _0x4ab2ad={};_0x4ab2ad['mockforme']=()=>_0x69f7b6,_0x3da9c5['d'](_0x38c22b,_0x4ab2ad);const _0x2bd667=_0x548d57=>{try{return _0x548d57?_0x548d57['toLowerCase']():_0x548d57;}catch(_0xd58f55){return console['log'](_0xd58f55),null;}},_0x3340a7=()=>'undefined'==typeof window,_0x2af443=function(_0xff0ed1,_0x2b15b5,_0x16258f){const _0x4c8e5b=_0x478eea,_0x35e667=_0x3340a7();var _0x16d309;function _0x1a0f5d(){const _0x372810=a0_0xf098;if(0x4==_0x16d309['readyState']){if(_0x16d309[_0x372810(0xcb)][_0x372810(0xe0)]()['match'](/^20[0-9]$/)){var _0x4a6e21=(function(){const _0x53e7c3=_0x372810;var _0x305b3b=_0x16d309[_0x53e7c3(0xd4)]('Content-Type'),_0x23657d=_0x16d309[_0x53e7c3(0xff)];if(_0x305b3b){var _0x19cb84=_0x305b3b[_0x53e7c3(0xe8)](';');try{return'application/json'===_0x19cb84[0x0]?JSON['parse'](_0x23657d):_0x23657d;}catch(_0x2cb649){throw'Unable\x20to\x20convert\x20response\x20header';}}}());_0x2b15b5['call'](this,_0x4a6e21,_0x16d309);}else _0x16258f[_0x372810(0xea)](this,_0x16d309[_0x372810(0xff)],_0x16d309);}}function _0x1c0c21(_0x16b67a,_0x387b4a){const _0x1cefdb=a0_0xf098;var _0x5be018=[];for(var _0x272ff6 in _0x16b67a)if(_0x16b67a[_0x1cefdb(0xd3)](_0x272ff6)){var _0x47371d=_0x387b4a?_0x387b4a+'['+_0x272ff6+']':_0x272ff6,_0x5762a8=_0x16b67a[_0x272ff6];_0x5be018[_0x1cefdb(0xf4)](_0x1cefdb(0xdd)==typeof _0x5762a8?_0x1c0c21(_0x5762a8,_0x47371d):encodeURIComponent(_0x47371d)+'='+encodeURIComponent(_0x5762a8));}return _0x5be018['join']('&');}return _0x35e667||(window[_0x4c8e5b(0xef)]?_0x16d309=new XMLHttpRequest():window[_0x4c8e5b(0x100)]&&(_0x16d309=new ActiveXObject(_0x4c8e5b(0xfb)))),{'request':function(){const _0x51fe97=_0x4c8e5b;if(!_0x35e667){if(window['XMLHttpRequest'])_0x16d309[_0x51fe97(0x102)]=_0x1a0f5d;else{if(!window[_0x51fe97(0x100)])throw _0x51fe97(0x108);_0x16d309['onreadystatechange']=_0x1a0f5d;}var _0x16543c=_0x1c0c21(_0xff0ed1['params']);if('get'==_0xff0ed1['method']['toLowerCase']()&&'object'==typeof _0xff0ed1[_0x51fe97(0x107)]){if(-0x1==_0xff0ed1['url']['indexOf']('?'))_0xff0ed1['url']+='?';else{var _0x52efcf=_0xff0ed1['url'][_0x51fe97(0xe8)]('?');_0x52efcf[0x1]&&_0x52efcf[0x1]['split']('=')[0x1]&&(_0xff0ed1[_0x51fe97(0xdb)]+='&');}_0xff0ed1[_0x51fe97(0xdb)]+=_0x16543c;}_0xff0ed1['hasOwnProperty'](_0x51fe97(0xf7))||(_0xff0ed1['async']=!0x0),_0x16d309[_0x51fe97(0xe9)](_0xff0ed1['method'],_0xff0ed1['url'],_0xff0ed1['async']),_0xff0ed1['headers']&&function(_0x24714e){for(let _0x2b6a10 in _0x24714e)_0x16d309['setRequestHeader'](_0x2b6a10,_0x24714e[_0x2b6a10]);}(_0xff0ed1[_0x51fe97(0xca)]),_0x16d309['send'](_0x16543c);}}};},_0x49b030=(_0xb4145d,_0x254ea2)=>{const _0x5ebdef=_0x478eea,_0xc61e64=_0xb4145d[_0x5ebdef(0xe8)]('/'),_0x25fa4a=_0x254ea2[_0x5ebdef(0xe8)]('/');if(_0xc61e64[_0x5ebdef(0xee)]!==_0x25fa4a['length'])return!0x1;for(let _0x507be7=0x0;_0x507be7<_0xc61e64['length'];_0x507be7++){const _0x3b108b=_0xc61e64[_0x507be7];if(_0x3b108b!==_0x25fa4a[_0x507be7]&&':any'!==_0x3b108b)return!0x1;}return!0x0;},_0x34ac5b=_0x49aa59=>{const _0x1f8866=_0x478eea;if(_0x3340a7())return;const _0x2972ec='https://api.mockforme.com',_0x3cdcb6=_0x2972ec+'/mockforme';let _0x52b7d5=_0x2972ec+'/gateway/3f4eae522b';const _0x1f33c2='mockforme',_0x1ea125='mfmver',_0x5c81d7='4.0.0';let _0x5a8fe3=null,_0x4e0928=null,_0x5a1f82=null,_0x1dfd80=[];const _0x2c29b4=window[_0x1f8866(0xfe)],_0x580603=_0x2c29b4['protocol'];if(_0x2c29b4['host'],_0x2c29b4['port'],!_0x49aa59)throw'mockforme\x20token\x20cannot\x20be\x20null';const _0x431667=()=>_0x3cdcb6+'/'+_0x5a8fe3+'/'+_0x4e0928,_0x1c01db=(_0x3fd5e5,_0x80dc03=_0x1f8866(0x101))=>{const _0x52706f=_0x1f8866;let _0x6424fd=null;if(!Array['isArray'](_0x1dfd80))return _0x6424fd;for(let _0x3c9ead=0x0;_0x3c9ead<_0x1dfd80['length'];_0x3c9ead++){const _0x41be92=_0x1dfd80[_0x3c9ead];if(_0x2bd667(_0x41be92['apiMethod'])===_0x2bd667(_0x80dc03)&&(_0x41be92['apiEndpoint']===_0x3fd5e5||_0x49b030(_0x41be92[_0x52706f(0xce)],_0x3fd5e5))){const _0x18c22e={};_0x18c22e['url']=_0x3fd5e5,_0x18c22e[_0x52706f(0x103)]=_0x41be92['apiMethod'],(_0x6424fd=_0x18c22e,_0x41be92[_0x52706f(0xdf)]&&(_0x6424fd['_ri_']=_0x41be92[_0x52706f(0xdf)]));break;}}return _0x6424fd;},_0x3c47d8=()=>{((()=>{const _0xb95e92=a0_0xf098,_0x5e69c3=window[_0xb95e92(0xe7)];window[_0xb95e92(0xe7)]=function(_0x15041d,_0x263fc4={}){const _0x47518a=_0xb95e92;_0x263fc4[_0x47518a(0x103)]||(_0x263fc4[_0x47518a(0x103)]='get');let _0x7645de=arguments;_0x15041d&&(_0x15041d['startsWith']('//')?_0x15041d=''+window['location'][_0x47518a(0x104)]+_0x15041d:_0x15041d[_0x47518a(0xf3)]('/')&&(_0x15041d=''+window[_0x47518a(0xfe)][_0x47518a(0xd7)]+_0x15041d));const _0x121fd2=new URL(_0x15041d),_0x1c519d=_0x121fd2&&_0x121fd2[_0x47518a(0xed)],_0x56308f=_0x121fd2&&_0x121fd2['search'],_0x5b7978=_0x1c01db(_0x1c519d,_0x263fc4[_0x47518a(0x103)]),_0x5d7918={};return _0x5d7918[_0x1f33c2]=_0x49aa59,_0x5d7918[_0x1ea125]=_0x5c81d7,(_0x5b7978&&(_0x15041d=''+_0x431667()+_0x5b7978[_0x47518a(0xdb)]+_0x56308f,_0x7645de[0x0]=_0x15041d,_0x263fc4['headers']=_0x5d7918,_0x5b7978&&_0x5b7978[_0x47518a(0xdf)]&&(_0x263fc4['headers'][_0x47518a(0xdf)]=_0x5b7978[_0x47518a(0xdf)]),_0x5a1f82&&(_0x263fc4[_0x47518a(0xca)][_0x47518a(0xf0)]=_0x5a1f82)),_0x5e69c3['call'](this,_0x15041d,_0x263fc4));};})()),((()=>{const _0x478479=a0_0xf098;let _0x4f70e6=window['XMLHttpRequest'][_0x478479(0xf6)]['open'];window['XMLHttpRequest'][_0x478479(0xf6)]['open']=function(_0xa89dd9,_0x28c6c0,_0x2bec31,_0x4d31b6,_0x20a969){const _0x439d10=_0x478479;try{_0x28c6c0&&(_0x28c6c0['startsWith']('//')?_0x28c6c0=''+window['location'][_0x439d10(0x104)]+_0x28c6c0:_0x28c6c0[_0x439d10(0xf3)]('/')?_0x28c6c0=''+window[_0x439d10(0xfe)]['origin']+_0x28c6c0:_0x28c6c0[_0x439d10(0xe5)]('://')>-0x1||(_0x28c6c0=_0x580603+'//'+_0x28c6c0));const _0x13e558=new URL(_0x28c6c0),_0x310e72=_0x13e558&&_0x13e558['pathname'],_0x5f0ef8=_0x13e558&&_0x13e558[_0x439d10(0xf8)];let _0x302f2e=arguments;const _0x4afe1e=_0x1c01db(_0x310e72,_0xa89dd9);return _0x4afe1e&&(_0x302f2e[0x1]=''+_0x431667()+_0x4afe1e[_0x439d10(0xdb)]+_0x5f0ef8),this[_0x439d10(0xe2)]=function(){const _0x40cd98=_0x439d10;if(0x1==this['readyState']){const _0x4eb0b7=[_0x40cd98(0xe3),'dashboard.mockforme.com','localhost'],_0x311f46=new URL(_0x302f2e[0x1]);_0x4eb0b7[_0x40cd98(0xf2)](_0x311f46['hostname'])&&(this[_0x40cd98(0xeb)](_0x1f33c2,_0x49aa59),this['setRequestHeader'](_0x1ea125,_0x5c81d7),_0x5a1f82&&this['setRequestHeader']('x-mfm-key',_0x5a1f82),_0x4afe1e&&_0x4afe1e['_ri_']&&this['setRequestHeader'](_0x40cd98(0xdf),_0x4afe1e['_ri_']));}},_0x4f70e6['apply'](this,_0x302f2e);}catch(_0x37aa71){return console['log']('Error\x20in\x20mock\x20api,\x20could\x20be\x20invalid\x20url',_0x37aa71),_0x4f70e6[_0x439d10(0xd8)](this,arguments);}};})());},_0x1b268b=_0x1f90e5=>{const _0x134ff0=_0x1f8866,_0x4f2ffd={};_0x4f2ffd['method']=_0x134ff0(0x101),_0x4f2ffd['url']=_0x52b7d5,_0x4f2ffd['async']=!0x1,_0x2af443(_0x4f2ffd,_0x54c2dc=>{const _0x13f366=_0x134ff0;if(_0x54c2dc){const {di:_0x483a9a,iv:_0x6ab961,_o:_0x40ba4d,_mck:_0x412b8b,mk:_0x11ba47}=_0x54c2dc;_0x5a8fe3=_0x40ba4d,_0x4e0928=_0x11ba47,_0x5a1f82=_0x412b8b;const _0x481c2f=function({di:_0x4de3c9,iv:_0x168d8f},_0x43e279){const _0x339d13=a0_0xf098;var _0x12e1b8;const _0x478240=function(_0x4851cd,_0x5ad868){const _0x3765b8=a0_0xf098,_0x3141e5=_0x5ad868['length'];return _0x4851cd[_0x3765b8(0xe8)]('')[_0x3765b8(0xfd)]((_0x55c4fe,_0x5e0d19)=>String['fromCharCode'](_0x55c4fe['charCodeAt'](0x0)^_0x5ad868['charCodeAt'](_0x5e0d19%_0x3141e5)))[_0x3765b8(0xfa)]('');}((_0x12e1b8=_0x4de3c9,'undefined'!=typeof Buffer?Buffer[_0x339d13(0xda)](_0x12e1b8,_0x339d13(0xf5))[_0x339d13(0xe0)](_0x339d13(0xe4)):decodeURIComponent(escape(atob(_0x12e1b8)))),_0x43e279+_0x168d8f);return JSON[_0x339d13(0x105)](_0x478240);}({'di':_0x483a9a,'iv':_0x6ab961},_0x40ba4d);_0x481c2f&&(_0x49f26c=_0x481c2f,_0x1dfd80=_0x1dfd80[_0x13f366(0xd9)](_0x49f26c),_0x1f90e5(_0x481c2f));}var _0x49f26c;},()=>{const _0x26b172=_0x134ff0;console[_0x26b172(0x106)](_0x26b172(0xdc));})['request']();};return{'run':_0x41c954=>{_0x3c47d8(),_0x1b268b(_0x42c49a=>{_0x41c954&&_0x41c954(_0x42c49a);});}};},_0x174110=_0x3340a7();_0x174110||(window[_0x478eea(0xde)]=_0x34ac5b);let _0xe6d035=_0x34ac5b;_0x174110&&(_0xe6d035=_0x13f02c=>({'run':()=>{}}));const _0x69f7b6=_0xe6d035;return _0x38c22b[_0x478eea(0xde)];})())));function a0_0xf098(_0x1fa6a5,_0x4375eb){const _0xe92d5a=a0_0xe92d();return a0_0xf098=function(_0xf098b3,_0x43d507){_0xf098b3=_0xf098b3-0xca;let _0x3c4949=_0xe92d5a[_0xf098b3];return _0x3c4949;},a0_0xf098(_0x1fa6a5,_0x4375eb);}function a0_0xe92d(){const _0x2f2888=['2452476HnYIBW','316fCvyTc','1377944yIWuCR','16pdXIGx','hasOwnProperty','getResponseHeader','9XKeVgC','amd','origin','apply','concat','from','url','Error\x20in\x20loading\x20mocked\x20apis','object','mockforme','_ri_','toString','254433YkwUEw','onreadystatechange','api.mockforme.com','utf8','indexOf','192DeYZoC','fetch','split','open','call','setRequestHeader','747285jTxiVT','pathname','length','XMLHttpRequest','x-mfm-key','3529gMeRpP','includes','startsWith','push','base64','prototype','async','search','7cWRrDW','join','Microsoft.XMLHTTP','872845nouwjC','map','location','responseText','ActiveXObject','get','onload','method','protocol','parse','log','params','unable\x20to\x20process\x20ajax','headers','status','3375700tOURcR','defineProperty','apiEndpoint'];a0_0xe92d=function(){return _0x2f2888;};return a0_0xe92d();}
|
package/dist/mockforme.d.ts
CHANGED
|
@@ -3,9 +3,25 @@ export as namespace mockforme;
|
|
|
3
3
|
export = mockforme;
|
|
4
4
|
|
|
5
5
|
declare namespace mockforme {
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Initialize mockforme with your access token.
|
|
8
|
+
*
|
|
9
|
+
* @param token - mockforme access token.
|
|
10
|
+
* @returns An object with a method to start mock API interception.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* mockforme("ACCESS_TOKEN").run((apis) => {
|
|
14
|
+
* console.log("Available APIs for mock:", apis);
|
|
15
|
+
* });
|
|
16
|
+
*/
|
|
17
|
+
function mockforme(token: string): MockForMe;
|
|
7
18
|
|
|
8
|
-
interface
|
|
9
|
-
|
|
19
|
+
interface MockForMe {
|
|
20
|
+
/**
|
|
21
|
+
* Starts intercepting and loading mockable APIs.
|
|
22
|
+
*
|
|
23
|
+
* @param callback - Optional. Called with the list of available APIs once loaded.
|
|
24
|
+
*/
|
|
25
|
+
run(callback?: (apis: []) => void): void;
|
|
10
26
|
}
|
|
11
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";
|
|
1
|
+
(()=>{var e={56:e=>{"use strict";e.exports=JSON.parse('{"name":"dotenv","version":"16.5.0","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"homepage":"https://github.com/motdotla/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}')},857:e=>{"use strict";e.exports=require("os")},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")},982:e=>{"use strict";e.exports=require("crypto")},998:(e,t,n)=>{const o=n(896),r=n(928),s=n(857),i=n(982),a=n(56).version,c=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function p(e){console.log(`[dotenv@${a}][DEBUG] ${e}`)}function l(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function u(e,t){let n;try{n=new URL(t)}catch(e){if("ERR_INVALID_URL"===e.code){const e=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw e.code="INVALID_DOTENV_KEY",e}throw e}const o=n.password;if(!o){const e=new Error("INVALID_DOTENV_KEY: Missing key part");throw e.code="INVALID_DOTENV_KEY",e}const r=n.searchParams.get("environment");if(!r){const e=new Error("INVALID_DOTENV_KEY: Missing environment part");throw e.code="INVALID_DOTENV_KEY",e}const s=`DOTENV_VAULT_${r.toUpperCase()}`,i=e.parsed[s];if(!i){const e=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw e.code="NOT_FOUND_DOTENV_ENVIRONMENT",e}return{ciphertext:i,key:o}}function d(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const n of e.path)o.existsSync(n)&&(t=n.endsWith(".vault")?n:`${n}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),".env.vault");return o.existsSync(t)?t:null}function h(e){return"~"===e[0]?r.join(s.homedir(),e.slice(1)):e}const f={configDotenv:function(e){const t=r.resolve(process.cwd(),".env");let n="utf8";const s=Boolean(e&&e.debug);e&&e.encoding?n=e.encoding:s&&p("No encoding is specified. UTF-8 is used by default");let i,a=[t];if(e&&e.path)if(Array.isArray(e.path)){a=[];for(const t of e.path)a.push(h(t))}else a=[h(e.path)];const c={};for(const t of a)try{const r=f.parse(o.readFileSync(t,{encoding:n}));f.populate(c,r,e)}catch(e){s&&p(`Failed to load ${t} ${e.message}`),i=e}let l=process.env;return e&&null!=e.processEnv&&(l=e.processEnv),f.populate(l,c,e),i?{parsed:c,error:i}:{parsed:c}},_configVault:function(e){Boolean(e&&e.debug)&&p("Loading env from encrypted .env.vault");const t=f._parseVault(e);let n=process.env;return e&&null!=e.processEnv&&(n=e.processEnv),f.populate(n,t,e),{parsed:t}},_parseVault:function(e){const t=d(e),n=f.configDotenv({path:t});if(!n.parsed){const e=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code="MISSING_DATA",e}const o=l(e).split(","),r=o.length;let s;for(let e=0;e<r;e++)try{const t=u(n,o[e].trim());s=f.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=r)throw t}return f.parse(s)},config:function(e){if(0===l(e).length)return f.configDotenv(e);const t=d(e);return t?f._configVault(e):(n=`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`,console.log(`[dotenv@${a}][WARN] ${n}`),f.configDotenv(e));var n},decrypt:function(e,t){const n=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const r=o.subarray(0,12),s=o.subarray(-16);o=o.subarray(12,-16);try{const e=i.createDecipheriv("aes-256-gcm",n,r);return e.setAuthTag(s),`${e.update(o)}${e.final()}`}catch(e){const t=e instanceof RangeError,n="Invalid key length"===e.message,o="Unsupported state or unable to authenticate data"===e.message;if(t||n){const e=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw e.code="INVALID_DOTENV_KEY",e}if(o){const e=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw e.code="DECRYPTION_FAILED",e}throw e}},parse:function(e){const t={};let n,o=e.toString();for(o=o.replace(/\r\n?/gm,"\n");null!=(n=c.exec(o));){const e=n[1];let o=n[2]||"";o=o.trim();const r=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),'"'===r&&(o=o.replace(/\\n/g,"\n"),o=o.replace(/\\r/g,"\r")),t[e]=o}return t},populate:function(e,t,n={}){const o=Boolean(n&&n.debug),r=Boolean(n&&n.override);if("object"!=typeof t){const e=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw e.code="OBJECT_REQUIRED",e}for(const n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(!0===r&&(e[n]=t[n]),o&&p(!0===r?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}};e.exports.configDotenv=f.configDotenv,e.exports._configVault=f._configVault,e.exports._parseVault=f._parseVault,e.exports.config=f.config,e.exports.decrypt=f.decrypt,e.exports.parse=f.parse,e.exports.populate=f.populate,e.exports=f}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{mockforme:()=>f});const e=require("http");var t=n.n(e);const r=require("https");var s=n.n(r);const i=require("child_process");var a=n(998);n.n(a)().config("../../.env");const c="https://api.mockforme.com",p=`${c}/mockforme`;let l=`${c}/gateway/3f4eae522b`;const u="mfmver",d="4.0.0";class h{constructor(e){this.token=e,this.apiMappings=[],this.isReady=!1,this.originalHttpRequest=t().request,this.originalHttpGet=t().get,this.originalHttpsRequest=s().request,this.originalHttpsGet=s().get,this.originalFetch=globalThis.fetch,this.organisationId=null,this.memberKey=null,this.memberCacheKey=null,this.fetchApiMappings(),this.setupInterceptor()}fetchApiMappings(){try{const e=`curl -s -H "mockforme: ${this.token}" "${l}"`,t=(0,i.execSync)(e,{encoding:"utf8"});if(t){const{di:e,iv:n,_o:o,_mck:r,mk:s}=JSON.parse(t);this.organisationId=o,this.memberKey=s,this.memberCacheKey=r;const i=function({di:e,iv:t},n){var o;const r=function(e,t){const n=t.length;return e.split("").map(((e,o)=>String.fromCharCode(e.charCodeAt(0)^t.charCodeAt(o%n)))).join("")}((o=e,"undefined"!=typeof Buffer?Buffer.from(o,"base64").toString("utf8"):decodeURIComponent(escape(atob(o)))),n+t);return JSON.parse(r)}({di:e,iv:n},o);i&&(this.apiMappings=i)}this.isReady=!0}catch(e){console.error("Failed to fetch mappings:",e.message)}}getProxyUrl(){return`${p}/${this.organisationId}/${this.memberKey}`}setupInterceptor(){const e=this;t().request=function(...t){return e.handleIntercept(e.originalHttpRequest,t)},s().request=function(...t){return e.handleIntercept(e.originalHttpsRequest,t)},t().get=function(...t){return e.handleIntercept(e.originalHttpGet,t)},s().get=function(...t){return e.handleIntercept(e.originalHttpsGet,t)},globalThis.fetch=async function(t,n={}){if(!e.isReady)return e.originalFetch(t,n);let o=t;"string"==typeof t?o=new URL(t,"http://localhost"):t instanceof Request&&(o=new URL(t.url));const r=e.interceptFetch(o,n);return e.originalFetch(r.url,r.init)}}handleIntercept(e,t){let n=t[0];if("string"==typeof n&&(n=new URL(n)),!this.isReady)return e.apply(null,[n,...t.slice(1)]);const o=this.interceptRequest(n);return e.apply(null,[o,...t.slice(1)])}interceptRequest(e){const t=this.apiMappings.find((t=>t.apiEndpoint===e.path&&t.apiMethod.toLowerCase()===e.method.toLowerCase()));if(t){const n={};n.mockforme=this.token,n[u]=d,this.memberCacheKey&&(n["x-mfm-key"]=this.memberCacheKey);const o=`${this.getProxyUrl()}${t.apiEndpoint}`,r=new URL(o);return{...e,hostname:r.hostname,path:r.pathname,headers:{...e.headers,...n}}}return e}interceptFetch(e,t){const n=(t.method||"GET").toUpperCase(),o=this.apiMappings.find((t=>t.apiEndpoint===e.pathname&&t.apiMethod.toLowerCase()===n.toLowerCase()));if(o){const e={};return e.mockforme=this.token,e[u]=d,this.memberCacheKey&&(e["x-mfm-key"]=this.memberCacheKey),{url:`${this.getProxyUrl()}${o.apiEndpoint}`,init:{...t,headers:{...t.headers,...e}}}}return{url:e.href,init:t}}run(e){e&&e(this.apiMappings)}}function f(e){return new h(e)}})(),module.exports=o})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";var t={
|
|
1
|
+
import{createRequire as e}from"node:module";var t={56:e=>{e.exports=JSON.parse('{"name":"dotenv","version":"16.5.0","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"homepage":"https://github.com/motdotla/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}')},857:t=>{t.exports=e(import.meta.url)("os")},896:t=>{t.exports=e(import.meta.url)("fs")},928:t=>{t.exports=e(import.meta.url)("path")},982:t=>{t.exports=e(import.meta.url)("crypto")},998:(e,t,n)=>{const o=n(896),r=n(928),s=n(857),i=n(982),a=n(56).version,c=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function p(e){console.log(`[dotenv@${a}][DEBUG] ${e}`)}function l(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function u(e,t){let n;try{n=new URL(t)}catch(e){if("ERR_INVALID_URL"===e.code){const e=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw e.code="INVALID_DOTENV_KEY",e}throw e}const o=n.password;if(!o){const e=new Error("INVALID_DOTENV_KEY: Missing key part");throw e.code="INVALID_DOTENV_KEY",e}const r=n.searchParams.get("environment");if(!r){const e=new Error("INVALID_DOTENV_KEY: Missing environment part");throw e.code="INVALID_DOTENV_KEY",e}const s=`DOTENV_VAULT_${r.toUpperCase()}`,i=e.parsed[s];if(!i){const e=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw e.code="NOT_FOUND_DOTENV_ENVIRONMENT",e}return{ciphertext:i,key:o}}function h(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const n of e.path)o.existsSync(n)&&(t=n.endsWith(".vault")?n:`${n}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),".env.vault");return o.existsSync(t)?t:null}function d(e){return"~"===e[0]?r.join(s.homedir(),e.slice(1)):e}const f={configDotenv:function(e){const t=r.resolve(process.cwd(),".env");let n="utf8";const s=Boolean(e&&e.debug);e&&e.encoding?n=e.encoding:s&&p("No encoding is specified. UTF-8 is used by default");let i,a=[t];if(e&&e.path)if(Array.isArray(e.path)){a=[];for(const t of e.path)a.push(d(t))}else a=[d(e.path)];const c={};for(const t of a)try{const r=f.parse(o.readFileSync(t,{encoding:n}));f.populate(c,r,e)}catch(e){s&&p(`Failed to load ${t} ${e.message}`),i=e}let l=process.env;return e&&null!=e.processEnv&&(l=e.processEnv),f.populate(l,c,e),i?{parsed:c,error:i}:{parsed:c}},_configVault:function(e){Boolean(e&&e.debug)&&p("Loading env from encrypted .env.vault");const t=f._parseVault(e);let n=process.env;return e&&null!=e.processEnv&&(n=e.processEnv),f.populate(n,t,e),{parsed:t}},_parseVault:function(e){const t=h(e),n=f.configDotenv({path:t});if(!n.parsed){const e=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code="MISSING_DATA",e}const o=l(e).split(","),r=o.length;let s;for(let e=0;e<r;e++)try{const t=u(n,o[e].trim());s=f.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=r)throw t}return f.parse(s)},config:function(e){if(0===l(e).length)return f.configDotenv(e);const t=h(e);return t?f._configVault(e):(n=`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`,console.log(`[dotenv@${a}][WARN] ${n}`),f.configDotenv(e));var n},decrypt:function(e,t){const n=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const r=o.subarray(0,12),s=o.subarray(-16);o=o.subarray(12,-16);try{const e=i.createDecipheriv("aes-256-gcm",n,r);return e.setAuthTag(s),`${e.update(o)}${e.final()}`}catch(e){const t=e instanceof RangeError,n="Invalid key length"===e.message,o="Unsupported state or unable to authenticate data"===e.message;if(t||n){const e=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw e.code="INVALID_DOTENV_KEY",e}if(o){const e=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw e.code="DECRYPTION_FAILED",e}throw e}},parse:function(e){const t={};let n,o=e.toString();for(o=o.replace(/\r\n?/gm,"\n");null!=(n=c.exec(o));){const e=n[1];let o=n[2]||"";o=o.trim();const r=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),'"'===r&&(o=o.replace(/\\n/g,"\n"),o=o.replace(/\\r/g,"\r")),t[e]=o}return t},populate:function(e,t,n={}){const o=Boolean(n&&n.debug),r=Boolean(n&&n.override);if("object"!=typeof t){const e=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw e.code="OBJECT_REQUIRED",e}for(const n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(!0===r&&(e[n]=t[n]),o&&p(!0===r?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}};e.exports.configDotenv=f.configDotenv,e.exports._configVault=f._configVault,e.exports._parseVault=f._parseVault,e.exports.config=f.config,e.exports.decrypt=f.decrypt,e.exports.parse=f.parse,e.exports.populate=f.populate,e.exports=f}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var s=n[e]={exports:{}};return t[e](s,s.exports,o),s.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};o.d(r,{_:()=>v});const s=e(import.meta.url)("http");var i=o.n(s);const a=e(import.meta.url)("https");var c=o.n(a);const p=e(import.meta.url)("child_process");var l=o(998);o.n(l)().config("../../.env");const u="https://api.mockforme.com",h=`${u}/mockforme`;let d=`${u}/gateway/3f4eae522b`;const f="mfmver",m="4.0.0";class g{constructor(e){this.token=e,this.apiMappings=[],this.isReady=!1,this.originalHttpRequest=i().request,this.originalHttpGet=i().get,this.originalHttpsRequest=c().request,this.originalHttpsGet=c().get,this.originalFetch=globalThis.fetch,this.organisationId=null,this.memberKey=null,this.memberCacheKey=null,this.fetchApiMappings(),this.setupInterceptor()}fetchApiMappings(){try{const e=`curl -s -H "mockforme: ${this.token}" "${d}"`,t=(0,p.execSync)(e,{encoding:"utf8"});if(t){const{di:e,iv:n,_o:o,_mck:r,mk:s}=JSON.parse(t);this.organisationId=o,this.memberKey=s,this.memberCacheKey=r;const i=function({di:e,iv:t},n){var o;const r=function(e,t){const n=t.length;return e.split("").map(((e,o)=>String.fromCharCode(e.charCodeAt(0)^t.charCodeAt(o%n)))).join("")}((o=e,"undefined"!=typeof Buffer?Buffer.from(o,"base64").toString("utf8"):decodeURIComponent(escape(atob(o)))),n+t);return JSON.parse(r)}({di:e,iv:n},o);i&&(this.apiMappings=i)}this.isReady=!0}catch(e){console.error("Failed to fetch mappings:",e.message)}}getProxyUrl(){return`${h}/${this.organisationId}/${this.memberKey}`}setupInterceptor(){const e=this;i().request=function(...t){return e.handleIntercept(e.originalHttpRequest,t)},c().request=function(...t){return e.handleIntercept(e.originalHttpsRequest,t)},i().get=function(...t){return e.handleIntercept(e.originalHttpGet,t)},c().get=function(...t){return e.handleIntercept(e.originalHttpsGet,t)},globalThis.fetch=async function(t,n={}){if(!e.isReady)return e.originalFetch(t,n);let o=t;"string"==typeof t?o=new URL(t,"http://localhost"):t instanceof Request&&(o=new URL(t.url));const r=e.interceptFetch(o,n);return e.originalFetch(r.url,r.init)}}handleIntercept(e,t){let n=t[0];if("string"==typeof n&&(n=new URL(n)),!this.isReady)return e.apply(null,[n,...t.slice(1)]);const o=this.interceptRequest(n);return e.apply(null,[o,...t.slice(1)])}interceptRequest(e){const t=this.apiMappings.find((t=>t.apiEndpoint===e.path&&t.apiMethod.toLowerCase()===e.method.toLowerCase()));if(t){const n={};n.mockforme=this.token,n[f]=m,this.memberCacheKey&&(n["x-mfm-key"]=this.memberCacheKey);const o=`${this.getProxyUrl()}${t.apiEndpoint}`,r=new URL(o);return{...e,hostname:r.hostname,path:r.pathname,headers:{...e.headers,...n}}}return e}interceptFetch(e,t){const n=(t.method||"GET").toUpperCase(),o=this.apiMappings.find((t=>t.apiEndpoint===e.pathname&&t.apiMethod.toLowerCase()===n.toLowerCase()));if(o){const e={};return e.mockforme=this.token,e[f]=m,this.memberCacheKey&&(e["x-mfm-key"]=this.memberCacheKey),{url:`${this.getProxyUrl()}${o.apiEndpoint}`,init:{...t,headers:{...t.headers,...e}}}}return{url:e.href,init:t}}run(e){e&&e(this.apiMappings)}}function v(e){return new g(e)}var y=r._;export{y as mockforme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mockforme",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "mockforme client integration kit. Intercept APIs & get mock responses. Integrate mockforme SDK with your codebase in seconds",
|
|
5
5
|
"main": "dist/mockforme.client.cjs.js",
|
|
6
6
|
"module": "dist/mockforme.client.esm.js",
|
|
@@ -34,12 +34,14 @@
|
|
|
34
34
|
"mock for me"
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
},
|
|
39
39
|
"author": "team mockforme",
|
|
40
40
|
"license": "ISC",
|
|
41
41
|
"homepage": "https://www.mockforme.com",
|
|
42
|
-
"dependencies": {
|
|
42
|
+
"dependencies": {
|
|
43
|
+
|
|
44
|
+
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
|
|
45
47
|
}
|