@qikdev/sdk 0.1.11 → 0.1.12
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/package.json +2 -2
- package/src/version.js +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.LICENSE.txt +0 -8
- package/webpack.config.js +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qikdev/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Promise based Javascript SDK",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test:watch": "mocha --colors -w ./test/*.spec.js",
|
|
11
11
|
"document": "jsdoc -r . -d docs -c jsdoc.conf README.md"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
13
|
+
"exports": "src/index.js",
|
|
14
14
|
"homepage": "https://qik.dev",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://support.qik.dev"
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.12'
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("axios"),require("lodash"),require("axios-extensions")):"function"==typeof define&&define.amd?define(["axios","lodash","axios-extensions"],r):"object"==typeof exports?exports["@qikdev/sdk"]=r(require("axios"),require("lodash"),require("axios-extensions")):e["@qikdev/sdk"]=r(e.axios,e._,e["axios-extensions"])}("undefined"!=typeof self?self:this,(function(e,r,t){return(()=>{"use strict";var n={818:(e,r)=>{var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};"undefined"!=typeof window&&window.document,"object"===("undefined"==typeof self?"undefined":t(self))&&self.constructor&&self.constructor.name,"undefined"!=typeof process&&null!=process.versions&&process.versions.node},798:e=>{var r=String.prototype.replace,t=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return r.call(e,t,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},129:(e,r,t)=>{var n=t(261),o=t(235),i=t(798);e.exports={formats:i,parse:o,stringify:n}},235:(e,r,t)=>{var n=t(769),o=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:n.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(e,r,t){if(e){var n=t.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(n),s=a?n.slice(0,a.index):n,u=[];if(s){if(!t.plainObjects&&o.call(Object.prototype,s)&&!t.allowPrototypes)return;u.push(s)}for(var c=0;null!==(a=i.exec(n))&&c<t.depth;){if(c+=1,!t.plainObjects&&o.call(Object.prototype,a[1].slice(1,-1))&&!t.allowPrototypes)return;u.push(a[1])}return a&&u.push("["+n.slice(a.index)+"]"),function(e,r,t){for(var n=r,o=e.length-1;o>=0;--o){var i,a=e[o];if("[]"===a&&t.parseArrays)i=[].concat(n);else{i=t.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,u=parseInt(s,10);t.parseArrays||""!==s?!isNaN(u)&&a!==s&&String(u)===s&&u>=0&&t.parseArrays&&u<=t.arrayLimit?(i=[])[u]=n:"__proto__"!==s&&(i[s]=n):i={0:n}}n=i}return n}(u,r,t)}};e.exports=function(e,r){var t=r?n.assign({},r):{};if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(t.ignoreQueryPrefix=!0===t.ignoreQueryPrefix,t.delimiter="string"==typeof t.delimiter||n.isRegExp(t.delimiter)?t.delimiter:i.delimiter,t.depth="number"==typeof t.depth?t.depth:i.depth,t.arrayLimit="number"==typeof t.arrayLimit?t.arrayLimit:i.arrayLimit,t.parseArrays=!1!==t.parseArrays,t.decoder="function"==typeof t.decoder?t.decoder:i.decoder,t.allowDots="boolean"==typeof t.allowDots?t.allowDots:i.allowDots,t.plainObjects="boolean"==typeof t.plainObjects?t.plainObjects:i.plainObjects,t.allowPrototypes="boolean"==typeof t.allowPrototypes?t.allowPrototypes:i.allowPrototypes,t.parameterLimit="number"==typeof t.parameterLimit?t.parameterLimit:i.parameterLimit,t.strictNullHandling="boolean"==typeof t.strictNullHandling?t.strictNullHandling:i.strictNullHandling,""===e||null==e)return t.plainObjects?Object.create(null):{};for(var s="string"==typeof e?function(e,r){for(var t={},n=r.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=r.parameterLimit===1/0?void 0:r.parameterLimit,s=n.split(r.delimiter,a),u=0;u<s.length;++u){var c,l,f=s[u],p=f.indexOf("]="),d=-1===p?f.indexOf("="):p+1;-1===d?(c=r.decoder(f,i.decoder),l=r.strictNullHandling?null:""):(c=r.decoder(f.slice(0,d),i.decoder),l=r.decoder(f.slice(d+1),i.decoder)),o.call(t,c)?t[c]=[].concat(t[c]).concat(l):t[c]=l}return t}(e,t):e,u=t.plainObjects?Object.create(null):{},c=Object.keys(s),l=0;l<c.length;++l){var f=c[l],p=a(f,s[f],t);u=n.merge(u,p,t)}return n.compact(u)}},261:(e,r,t)=>{var n=t(769),o=t(798),i={brackets:function(e){return e+"[]"},indices:function(e,r){return e+"["+r+"]"},repeat:function(e){return e}},a=Array.isArray,s=Array.prototype.push,u=function(e,r){s.apply(e,a(r)?r:[r])},c=Date.prototype.toISOString,l={delimiter:"&",encode:!0,encoder:n.encode,encodeValuesOnly:!1,serializeDate:function(e){return c.call(e)},skipNulls:!1,strictNullHandling:!1},f=function e(r,t,o,i,s,c,f,p,d,h,g,y){var m=r;if("function"==typeof f?m=f(t,m):m instanceof Date&&(m=h(m)),null===m){if(i)return c&&!y?c(t,l.encoder):t;m=""}if("string"==typeof m||"number"==typeof m||"boolean"==typeof m||n.isBuffer(m))return c?[g(y?t:c(t,l.encoder))+"="+g(c(m,l.encoder))]:[g(t)+"="+g(String(m))];var v,b=[];if(void 0===m)return b;if(a(f))v=f;else{var w=Object.keys(m);v=p?w.sort(p):w}for(var k=0;k<v.length;++k){var j=v[k];s&&null===m[j]||(a(m)?u(b,e(m[j],o(t,j),o,i,s,c,f,p,d,h,g,y)):u(b,e(m[j],t+(d?"."+j:"["+j+"]"),o,i,s,c,f,p,d,h,g,y)))}return b};e.exports=function(e,r){var t=e,s=r?n.assign({},r):{};if(null!==s.encoder&&void 0!==s.encoder&&"function"!=typeof s.encoder)throw new TypeError("Encoder has to be a function.");var c=void 0===s.delimiter?l.delimiter:s.delimiter,p="boolean"==typeof s.strictNullHandling?s.strictNullHandling:l.strictNullHandling,d="boolean"==typeof s.skipNulls?s.skipNulls:l.skipNulls,h="boolean"==typeof s.encode?s.encode:l.encode,g="function"==typeof s.encoder?s.encoder:l.encoder,y="function"==typeof s.sort?s.sort:null,m=void 0!==s.allowDots&&s.allowDots,v="function"==typeof s.serializeDate?s.serializeDate:l.serializeDate,b="boolean"==typeof s.encodeValuesOnly?s.encodeValuesOnly:l.encodeValuesOnly;if(void 0===s.format)s.format=o.default;else if(!Object.prototype.hasOwnProperty.call(o.formatters,s.format))throw new TypeError("Unknown format option provided.");var w,k,j=o.formatters[s.format];"function"==typeof s.filter?t=(k=s.filter)("",t):a(s.filter)&&(w=k=s.filter);var A,O=[];if("object"!=typeof t||null===t)return"";A=s.arrayFormat in i?s.arrayFormat:"indices"in s?s.indices?"indices":"repeat":"indices";var R=i[A];w||(w=Object.keys(t)),y&&w.sort(y);for(var q=0;q<w.length;++q){var x=w[q];d&&null===t[x]||u(O,f(t[x],x,R,p,d,h?g:null,k,y,m,v,j,b))}var S=O.join(c),P=!0===s.addQueryPrefix?"?":"";return S.length>0?P+S:""}},769:e=>{var r=Object.prototype.hasOwnProperty,t=function(){for(var e=[],r=0;r<256;++r)e.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return e}(),n=function(e,r){for(var t=r&&r.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(t[n]=e[n]);return t};e.exports={arrayToObject:n,assign:function(e,r){return Object.keys(r).reduce((function(e,t){return e[t]=r[t],e}),e)},compact:function(e){for(var r=[{obj:{o:e},prop:"o"}],t=[],n=0;n<r.length;++n)for(var o=r[n],i=o.obj[o.prop],a=Object.keys(i),s=0;s<a.length;++s){var u=a[s],c=i[u];"object"==typeof c&&null!==c&&-1===t.indexOf(c)&&(r.push({obj:i,prop:u}),t.push(c))}return function(e){for(var r;e.length;){var t=e.pop();if(r=t.obj[t.prop],Array.isArray(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&n.push(r[o]);t.obj[t.prop]=n}}return r}(r)},decode:function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(r){return e}},encode:function(e){if(0===e.length)return e;for(var r="string"==typeof e?e:String(e),n="",o=0;o<r.length;++o){var i=r.charCodeAt(o);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?n+=r.charAt(o):i<128?n+=t[i]:i<2048?n+=t[192|i>>6]+t[128|63&i]:i<55296||i>=57344?n+=t[224|i>>12]+t[128|i>>6&63]+t[128|63&i]:(o+=1,i=65536+((1023&i)<<10|1023&r.charCodeAt(o)),n+=t[240|i>>18]+t[128|i>>12&63]+t[128|i>>6&63]+t[128|63&i])}return n},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,o,i){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if(!t||"object"!=typeof t)return[t,o];(i&&(i.plainObjects||i.allowPrototypes)||!r.call(Object.prototype,o))&&(t[o]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(o);var a=t;return Array.isArray(t)&&!Array.isArray(o)&&(a=n(t,i)),Array.isArray(t)&&Array.isArray(o)?(o.forEach((function(n,o){if(r.call(t,o)){var a=t[o];a&&"object"==typeof a&&n&&"object"==typeof n?t[o]=e(a,n,i):t.push(n)}else t[o]=n})),t):Object.keys(o).reduce((function(t,n){var a=o[n];return r.call(t,n)?t[n]=e(t[n],a,i):t[n]=a,t}),a)}}},103:r=>{r.exports=e},757:e=>{e.exports=t},607:e=>{e.exports=r}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={exports:{}};return n[e](t,t.exports,i),t.exports}i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{i.r(a),i.d(a,{default:()=>y});var e=i(103),r=i(607),t=i(129);const n="0.1.11";var o=i(757);const s=e.CancelToken,u=function(o){var i;"undefined"!=typeof window&&(i=o.cache.get("api"));const a=e.defaults.adapter,u=(c=function(r){return new Promise((function(t,n){var o,s;switch(String(r.method).toLowerCase()){case"post":case"patch":case"put":case"delete":r.cache||(r.cache=!1)}if(!1===r.cache);else if(o=r.cache||i){var u=getCacheKeyFromConfig(r);s=o.get(u)}return s?t(s):(Object.assign(r,{adapter:a}),e.request(r).then((function(e){t(e)}),(function(e){n(e)})))}))},(l=e.create({paramsSerializer:e=>t.stringify(e,{arrayFormat:"repeat"}),adapter:c})).defaults.baseURL=o.apiURL,l.defaults.headers.common.Accept="application/json",l.interceptors.request.use((function(e){return e.headers["qik-request-date"]=(new Date).getTime(),Intl&&(e.headers["qik-request-timezone"]=Intl.DateTimeFormat().resolvedOptions().timeZone),e.headers["qik-api-version"]=n,e})),l.interceptors.response.use((function(e){return e.config,e}),(function(t){if(e.isCancel(t))return console.log("Request cancelled"),Promise.reject(t);var n=r.get(t,"response.status")||t.status;switch(n){case 401:case 404:break;case 502:case 504:return console.log(`qik.api > ${n} connection error retrying`),l.request(t.config);default:console.log("qik.api > connection error",n,t)}return Promise.reject(t)})),l);var c,l;return u.generateEndpointURL=function(e,r){if(e&&String(e).length){r||(r={});var t=`${o.apiURL}${e}`;t=function(e,r){if(!r.withoutToken){var t=o.auth.getCurrentToken();!r.access_token&&t&&(r.access_token=t)}return e}(t,r);var n=o.utils.mapParameters(r);return n.length&&(t+="?"+n),t}},u.CancelToken=s,u.axios=e,u};i(818);var c={mapParameters:function(e){return r.chain(e).reduce((function(e,t,n){return null==t||!1===t||(r.isArray(t)?r.each(t,(function(r){e.push(`${n}=${encodeURIComponent(r)}`)})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))),e}),[]).compact().value().join("&")},formatCurrency:function(e,r){return e&&!isNaN(e)||(e=0),`${c.currencySymbol(r)}${parseFloat(parseInt(e)/100).toFixed(2)}`},currencySymbol:function(e){switch(e=String(e).toLowerCase(),String(e).toLowerCase()){case"gbp":return"£";case"eur":return"€";default:return"$"}},getAvailableCurrencies:function(e){var r=[];if(r.push({name:`USD (${c.currencySymbol("usd")})`,value:"usd",countryCode:{US:!0}}),r.push({name:`GBP (${c.currencySymbol("gbp")})`,value:"gbp",countryCode:{GB:!0,UK:!0}}),r.push({name:`CAD (${c.currencySymbol("cad")})`,value:"cad",countryCode:{CA:!0}}),r.push({name:`AUD (${c.currencySymbol("aud")})`,value:"aud",countryCode:{AU:!0}}),r.push({name:`NZD (${c.currencySymbol("nzd")})`,value:"nzd",countryCode:{NZ:!0}}),r.push({name:`SGD (${c.currencySymbol("sgd")})`,value:"sgd",countryCode:{SG:!0}}),e){var t=r.findIndex((function(r){return r.countryCode[e]}));const n=(e,r,t)=>{const n=[...e];return n.splice(t,0,...n.splice(r,1)),n};-1!=t&&(r=n(r,t,0))}return r},hash:function(e,t){return Array.isArray(e)||(e=[]),e.reduce((function(e,t){var n=r.get(t,n);return e[n]=t,e}),{})},guid:function(){var e=(new Date).getTime().toString(16)+Math.random().toString(16).substring(2)+"0".repeat(16);return e.substr(0,8)+"-"+e.substr(8,4)+"-4000-8"+e.substr(12,3)+"-"+e.substr(15,12)},extractFromArray:function(e,t,n,o,i,a,s){s||(s={}),n&&(s.sum=n),o&&(s.flatten=!0),i&&(s.unique=!0),a&&(s.excludeNull=!0);var u=r.reduce(e,(function(e,n){var o=r.get(n,t),i=!o&&!1!==o&&0!==o;return s.excludeNull&&i||e.push(o),e}),[]);return s.flatten&&(u=r.flatten(u)),s.unique&&(u=r.uniq(u)),s.sum&&(u=u.reduce((function(e,r){return e+r}),0)),u},matchInArray:function(e,t,n,o){return r.filter(e,(function(e){var i,a=r.get(e,t);switch(o){case">":i=a>n;break;case"<":i=a<n;break;case">=":i=a>=n;break;case"<=":i=a<=n;break;case"in":i=r.includes(a,n);break;default:i=void 0===n?a:a==n}return i}))},comma:function(e,t,n){return n&&(e=e.slice(0,n)),r.chain(e).compact().map((function(e){return t&&t.length?r.get(e,t):e})).value().join(", ")},id:function(e){var r;if(e&&(r=e._id?String(e._id):String(e),service.isValidID(r)))return r},ids:function(e){return r.chain(e).reduce((function(e,r){if(!r)return e;var t=service.id(r);return t&&(e[t]=1),e}),{}).keys().value()},isValidID:function(e){return new RegExp("^[0-9a-fA-F]{24}$").test(String(e))},errorMessage:function(e){r.isArray(e)&&(e=r.first(e));var t=r.chain(["response.data.message","response.data","message"]).map((function(t){return r.get(e,t)})).compact().first().value();return Array.isArray(t)&&(t=t[0]),t&&t.length?t:String(e)},machineName:function(e){if(e&&e.length)return e.replace(/[^a-zA-Z0-9-_]+/g,"")}};const l=c;function f(){var e={},r={removeAllListeners:function(){e={}},dispatch:function(r,t){e[r]&&e[r].forEach((function(e){return e(t)}))},addEventListener:function(r,t){e[r]||(e[r]=[]),-1==e[r].indexOf(t)&&e[r].push(t)},removeEventListener:function(r,t){e[r]||(e[r]=[]);var n=e[r].indexOf(t);-1!=n&&e[r].splice(n,1)},bootstrap:function(e){e&&(e.dispatch=r.dispatch,e.addEventListener=r.addEventListener,e.removeEventListener=r.removeEventListener,e.removeAllListeners=r.removeAllListeners)}};return r}const p=function(e){if(!e.api)throw new Error("Can't Instantiate QikAuth before QikAPI exists");var t={},n={debug:!1};Object.defineProperty(n,"store",{value:t,writable:!1});var o=new f;function i(e){var r=t.user;n.onChange&&n.onChange(r),o.dispatch("change",r,e)}function a(e){n.debug&&console.log(e)}o.bootstrap(n),n.set=function(e,r,n){return t.user=e,a("qik.auth > user set"),i(r)},n.logout=function(){return delete t.user,e.cache.reset(),a("qik.auth > user logout"),e.withCredentials&&(window.location.href="/qik/logout"),i()},n.changeOrganisation=function(r,t){r=e.utils.getStringID(r),t||(t={});var o=!0;t.disableAutoAuthentication&&(o=!1);var i=e.api.post(`/user/switch/${r}`);return i.then((function(r){o&&(e.cache.reset(),n.set(r.data))}),(function(e){})),i},n.impersonate=function(r,t){r=e.utils.getStringID(r),t||(t={});var o=!0;t.disableAutoAuthentication&&(o=!1);var i=e.api.post(`/user/impersonate/${r}`);return i.then((function(r){o&&(e.cache.reset(),n.set(r.data))}),(function(e){})),i},n.login=function(r,n){n||(n={});var o=!0;return n.disableAutoAuthentication&&(o=!1),new Promise((function(a,s){if(!r)return s({message:"Missing credentials!"});if(!r.email||!r.email.length)return s({message:"Username was not provided"});if(!r.password||!r.password.length)return s({message:"Password was not provided"});var u=`${e.apiURL}/user/login`;n.url&&(u=n.url),e.api.post(u,r,{bypassInterceptor:!0}).then((function(e){o&&(t.user=e.data,i()),a(e)}),s)}))},n.signup=function(r,n){n||(n={});var o=!0;return n.disableAutoAuthentication&&(o=!1),new Promise((function(a,s){if(!r)return s({message:"No details provided"});if(!r.firstName||!r.firstName.length)return s({message:"First Name was not provided"});if(!r.lastName||!r.lastName.length)return s({message:"Last Name was not provided"});if(!r.email||!r.email.length)return s({message:"Email/Username was not provided"});if(!r.password||!r.password.length)return s({message:"Password was not provided"});if(!r.confirmPassword||!r.confirmPassword.length)return s({message:"Confirm Password was not provided"});if(r.confirmPassword!=r.password)return s({message:"Your passwords do not match"});var u=`${e.apiURL}/user/signup`;n.application&&(u=`${e.domain||""}/qik/application/signup`),n.url&&(u=n.url),e.api.post(u,r,{bypassInterceptor:!0}).then((function(e){o&&(t.user=e.data,i()),a(e)}),s)}))},n.retrieveUserFromResetToken=function(r,t){return t||(t={}),new Promise((function(n,o){var i=`${e.apiURL}/user/reset/${r}`;t.url&&(i=t.url),e.api.get(i,{bypassInterceptor:!0}).then((function(e){return n(e.data)}),o)}))},n.updateUserWithToken=function(r,t,o){o||(o={});var i=!0;return o.disableAutoAuthentication&&(i=!1),new Promise((function(a,s){var u=`${e.apiURL}/user/reset/${r}`;o.url&&(u=o.url),e.api.post(u,t,{bypassInterceptor:!0}).then((function(r){return i&&(e.cache.reset(),n.set(r.data)),a(r.data)}),s)}))},n.sendResetPasswordRequest=function(r,t){return t||(t={}),new Promise((function(n,o){if(!r)return o({message:"No details provided"});if(!r.email||!r.email.length)return o({message:"Email was not provided"});r.email=r.email;var i=`${e.apiURL}/user/forgot`;t.url&&(i=t.url),e.api.post(i,r,{bypassInterceptor:!0}).then(n,o)}))};const s={};return n.refreshAccessToken=function(r){return s.inflightRefreshRequest?(a("qik.auth > use inflight request"),s.inflightRefreshRequest):(a("qik.auth > refresh token new request"),s.inflightRefreshRequest=new Promise((function(n,o){a(`qik.auth > refresh token ${r}`),e.api.post("/user/refresh",{refreshToken:r},{bypassInterceptor:!0}).then((function(e){if(!e)return a("qik.auth > no res"),s.inflightRefreshRequest=null,o();t.user?Object.assign(t.user,e.data):t.user=e.data,a(`qik.auth > token refreshed > ${e.data}`),i(),n(e.data.token),setTimeout((function(){s.inflightRefreshRequest=null}))})).catch((function(e){console.log("TOKEN REFRESH FAILED",e),setTimeout((function(){s.inflightRefreshRequest=null})),o(e)}))})),s.inflightRefreshRequest)},n.sync=function(){return e.api.get("/user").then((function(e){e.data?t.user&&Object.assign(t.user,e.data):t.user=null,a("qik.auth > server session refreshed"),i()})).catch((function(e){console.log("auth sync not logged in"),t.user=null,i()}))},n.getCurrentUser=function(){return t.user},n.getCurrentToken=function(){return n.getCurrentUser().accessToken},e.api.interceptors.request.use((function(e){if(e.bypassInterceptor)return console.log("auth interceptor was bypassed"),e;var o=e,i=r.get(t,"user.accessToken"),s=r.get(t,"user.refreshToken");if(!i)return a("qik.auth > no token"),o;if(o.headers.Authorization=`Bearer ${i}`,a("qik.auth > using user token"),!s)return a("qik.auth > no refresh token"),o;var u=new Date;u.setSeconds(u.getSeconds()+10);var c=r.get(t,"user.expires");return u<new Date(c)?o:(a("qik.auth > token expired"),new Promise((function(e,r){n.refreshAccessToken(s).then((function(r){return a("qik.auth > token refreshed",isManagedUser),o.headers.Authorization=`Bearer ${r}`,e(o)})).catch((function(e){return console.log("ERRRRRR",e),a("qik.auth > token refresh rejected"),r(e)}))})))}),(function(e){return Promise.reject(e)})),e.api.interceptors.response.use((function(e){return e}),(function(e){var t=r.get(e,"response.status")||e.status;return a("qik.auth > error"),401===t&&(console.log("logout from 401"),n.logout()),Promise.reject(e)})),n};var d={};const h={reset(){r.each(d,(function(e,r){e.reset()}))},get:(e,r)=>(d[e]||(d[e]=new o.Cache(r)),d[e])},g=function(e){if(!e.auth)throw new Error("Can't Instantiate QikAccess before QikAccess has been initialized");var t={};return(new f).bootstrap(t),t.has=function(e,n){var o=t.retrieveCurrentSession(n);if(!o)return!1;if(t.isQikAdmin()&&!n)return!0;var i=o.permissionSets,a=r.chain(i).reduce((function(e,r,t){return e.push(r.permissions),e}),[]).flattenDeep().compact().uniq().value();return r.includes(a,e)},t};console.log("BEFORE class"),console.log("qik 0.1.11");const y=function(e){switch(e||(e={}),e.apiURL&&e.apiURL.length||(e.apiURL="staging"),String(e.apiURL).toLowerCase()){case"production":e.apiURL="https://api.qik.dev";break;case"staging":e.apiURL="https://api.staging.qik.dev";break;case"local":e.apiURL="http://localhost:4001"}const r=Object.assign(e,{version:n});console.log("Instantiate class",r);var t=h;Object.defineProperty(r,"cache",{value:t,writable:!1});var o=l;Object.defineProperty(r,"utils",{value:o,writable:!1}),(new f).bootstrap(r),r.error=function(e){return r.dispatch("error",o.errorMessage(e))},r.notify=function(e,t){return r.dispatch("notification",{message:e,options:t})};var i=new u(r);Object.defineProperty(r,"api",{value:i,writable:!1});var a=new p(r);Object.defineProperty(r,"auth",{value:a,writable:!1});var s=new g(r);return Object.defineProperty(r,"access",{value:s,writable:!1}),r}})(),a})()}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Lodash <https://lodash.com/>
|
|
4
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
5
|
-
* Released under MIT license <https://lodash.com/license>
|
|
6
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8
|
-
*/
|
package/webpack.config.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import {fileURLToPath} from 'url';
|
|
3
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = path.dirname(__filename);
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
entry: './src/index.js',
|
|
8
|
-
output: {
|
|
9
|
-
filename: 'index.js',
|
|
10
|
-
library: {
|
|
11
|
-
name:'@qikdev/sdk',
|
|
12
|
-
type:'umd',
|
|
13
|
-
},
|
|
14
|
-
path: path.resolve(__dirname, 'dist'),
|
|
15
|
-
globalObject: 'typeof self !== \'undefined\' ? self : this',
|
|
16
|
-
},
|
|
17
|
-
optimization: {
|
|
18
|
-
// splitChunks: {
|
|
19
|
-
// chunks: 'all'
|
|
20
|
-
// }
|
|
21
|
-
},
|
|
22
|
-
externals: {
|
|
23
|
-
'axios': {
|
|
24
|
-
commonjs: 'axios',
|
|
25
|
-
commonjs2: 'axios',
|
|
26
|
-
amd: 'axios',
|
|
27
|
-
root: 'axios'
|
|
28
|
-
},
|
|
29
|
-
'lodash': {
|
|
30
|
-
commonjs: 'lodash',
|
|
31
|
-
commonjs2: 'lodash',
|
|
32
|
-
amd: 'lodash',
|
|
33
|
-
root: '_'
|
|
34
|
-
},
|
|
35
|
-
'axios-extensions': {
|
|
36
|
-
commonjs: 'axios-extensions',
|
|
37
|
-
commonjs2: 'axios-extensions',
|
|
38
|
-
amd: 'axios-extensions',
|
|
39
|
-
root: 'axios-extensions'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
// output: {
|
|
43
|
-
// filename: 'main.js',
|
|
44
|
-
// path: path.resolve(__dirname, 'dist')
|
|
45
|
-
// }
|
|
46
|
-
};
|