auth-javascript 0.0.16
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 +167 -0
- package/dist/auth-js.js +1 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
auth-js
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
> Auth JS Client for e-city
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
### Using yarn
|
|
10
|
+
|
|
11
|
+
`yarn add auth-js`
|
|
12
|
+
|
|
13
|
+
### Using npm
|
|
14
|
+
|
|
15
|
+
`npm i --save auth-js`
|
|
16
|
+
|
|
17
|
+
Usage
|
|
18
|
+
=====
|
|
19
|
+
|
|
20
|
+
Config
|
|
21
|
+
------
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
const baseURL = 'http://isse.paliari.com.br/app/rest'
|
|
25
|
+
const Auth = {
|
|
26
|
+
install (Vue, {baseURL}) {
|
|
27
|
+
const auth = AuthJs({appModule: 'nfse', baseURL, statusBar: 'darken'})
|
|
28
|
+
Vue.prototype.$auth = auth
|
|
29
|
+
Vue.auth = auth
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
Vue.use(Auth, {baseURL})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Methods
|
|
36
|
+
-------
|
|
37
|
+
|
|
38
|
+
All methods return the Promise instance.
|
|
39
|
+
|
|
40
|
+
### Sign In
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
|
|
44
|
+
this.$auth.signIn().then( response => {
|
|
45
|
+
// the response contains token and usuario e.g: {token: {...}, usuario: {...}}
|
|
46
|
+
console.log('success', response)
|
|
47
|
+
})
|
|
48
|
+
.catch( e => {
|
|
49
|
+
console.log('error', e)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Sign Out
|
|
55
|
+
|
|
56
|
+
Sign out current session of user.
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
|
|
60
|
+
this.$auth.signOut().then( response => {
|
|
61
|
+
console.log('success', response)
|
|
62
|
+
})
|
|
63
|
+
.catch( e => {
|
|
64
|
+
console.log('error', e)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Update passowrd
|
|
70
|
+
|
|
71
|
+
Update current passowrd of user.
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
|
|
75
|
+
this.$auth.updatePassword().then( response => {
|
|
76
|
+
console.log('success', response)
|
|
77
|
+
})
|
|
78
|
+
.catch( e => {
|
|
79
|
+
console.log('error', e)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Account
|
|
85
|
+
|
|
86
|
+
Update account of user.
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
|
|
90
|
+
this.$auth.account().then( response => {
|
|
91
|
+
console.log('success', response)
|
|
92
|
+
})
|
|
93
|
+
.catch( e => {
|
|
94
|
+
console.log('error', e)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Image
|
|
100
|
+
|
|
101
|
+
Change image of perfil the user.
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
|
|
105
|
+
this.$auth.image().then( response => {
|
|
106
|
+
console.log('success', response)
|
|
107
|
+
})
|
|
108
|
+
.catch( e => {
|
|
109
|
+
console.log('error', e)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Address
|
|
115
|
+
|
|
116
|
+
Update address of user.
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
|
|
120
|
+
this.$auth.address().then( response => {
|
|
121
|
+
console.log('success', response)
|
|
122
|
+
})
|
|
123
|
+
.catch( e => {
|
|
124
|
+
console.log('error', e)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Modules
|
|
130
|
+
|
|
131
|
+
Insert/Remove modules of user.
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
|
|
135
|
+
this.$auth.modules().then( response => {
|
|
136
|
+
console.log('success', response)
|
|
137
|
+
})
|
|
138
|
+
.catch( e => {
|
|
139
|
+
console.log('error', e)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Current
|
|
145
|
+
|
|
146
|
+
Get current user.
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
|
|
150
|
+
this.$auth.current().then( response => {
|
|
151
|
+
console.log('success', response)
|
|
152
|
+
})
|
|
153
|
+
.catch( e => {
|
|
154
|
+
console.log('error', e)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Dependencies
|
|
160
|
+
============
|
|
161
|
+
|
|
162
|
+
- Promise (the browser suporte reuquired), see: [MDN Promise](https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
163
|
+
|
|
164
|
+
License
|
|
165
|
+
-------
|
|
166
|
+
|
|
167
|
+
This project is licensed under [MIT License](http://en.wikipedia.org/wiki/MIT_License)
|
package/dist/auth-js.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AuthJs=t():e.AuthJs=t()})("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=4)}([function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),i=function(e){for(var t;e.length;){var r=e.pop();if(t=r.obj[r.prop],Array.isArray(t)){for(var n=[],o=0;o<t.length;++o)void 0!==t[o]&&n.push(t[o]);r.obj[r.prop]=n}}return t};t.arrayToObject=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r},t.merge=function(e,r,o){if(!r)return e;if("object"!=typeof r){if(Array.isArray(e))e.push(r);else{if("object"!=typeof e)return[e,r];(o.plainObjects||o.allowPrototypes||!n.call(Object.prototype,r))&&(e[r]=!0)}return e}if("object"!=typeof e)return[e].concat(r);var i=e;return Array.isArray(e)&&!Array.isArray(r)&&(i=t.arrayToObject(e,o)),Array.isArray(e)&&Array.isArray(r)?(r.forEach(function(r,i){n.call(e,i)?e[i]&&"object"==typeof e[i]?e[i]=t.merge(e[i],r,o):e.push(r):e[i]=r}),e):Object.keys(r).reduce(function(e,i){var a=r[i];return n.call(e,i)?e[i]=t.merge(e[i],a,o):e[i]=a,e},i)},t.assign=function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.encode=function(e){if(0===e.length)return e;for(var t="string"==typeof e?e:String(e),r="",n=0;n<t.length;++n){var i=t.charCodeAt(n);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?r+=t.charAt(n):i<128?r+=o[i]:i<2048?r+=o[192|i>>6]+o[128|63&i]:i<55296||i>=57344?r+=o[224|i>>12]+o[128|i>>6&63]+o[128|63&i]:(n+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(n)),r+=o[240|i>>18]+o[128|i>>12&63]+o[128|i>>6&63]+o[128|63&i])}return r},t.compact=function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var o=t[n],a=o.obj[o.prop],s=Object.keys(a),c=0;c<s.length;++c){var u=s[c],l=a[u];"object"==typeof l&&null!==l&&-1===r.indexOf(l)&&(t.push({obj:a,prop:u}),r.push(l))}return i(t)},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null!==e&&void 0!==e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}},function(e,t,r){"use strict";var n=String.prototype.replace,o=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return n.call(e,o,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(e,t,r){"use strict";var n=r(11),o=r(3),i="remember";t.a={storage:null,set remember(e){this.storage=e?n.a:o.a,localStorage.setItem(i,e)},get remember(){if(void 0===this._remember){var e=localStorage.getItem(i);this._remember=!!e&&JSON.parse(e)}return this._remember},get _storageKey(){return this.storage._storageKey},set _storageKey(e){o.a._storageKey=e,n.a._storageKey=e},setToken:function(e){this.storage.setToken(e)},getToken:function(){return this.storage||(this.storage=this.remember?n.a:o.a),this.storage.getToken()},removeToken:function(){this.storage.removeToken()}}},function(e,t,r){"use strict";t.a={_storageKey:"auth_token",setToken:function(e){document.cookie=this._storageKey+"="+JSON.stringify(e)},getToken:function(){var e=new RegExp("(?:(?:^|.*;s*)"+this._storageKey+"s*=s*([^;]*).*$)|^.*$"),t=document.cookie.replace(e,"$1");return t?JSON.parse(t):""},removeToken:function(){document.cookie=this._storageKey+"="}}},function(e,t,r){e.exports=r(5)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=r(2),i=r(3);r.d(t,"AuthManager",function(){return n.a}),r.d(t,"TokenManager",function(){return o.a}),r.d(t,"CookieManager",function(){return i.a}),t.default=function(e){var t=e.baseURL,r=void 0===t?"":t,o=e.appModule,i=void 0===o?"":o,a=e.statusBar,s=void 0===a?"":a;return new n.a({baseURL:r,appModule:i,statusBar:s})}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=r(7),i=r.n(o),a=r(10),s=r(2),c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=function(e){return e+"_auth_token"},l=function(){function e(t){var r=t.baseURL,o=void 0===r?"":r,i=t.appModule,a=void 0===i?"":i,c=t.authPath,l=void 0===c?"auth":c,f=t.statusBar,d=void 0===f?"":f;n(this,e),this.baseURL=o,this.tokenManager=s.a,this.appModule=a,this.authPath=l,this.statusBar=d,this.tokenManager._storageKey=u(a)}return c(e,[{key:"open",value:function(e,t){var r=this;t._close=1,this.statusBar&&(t._statusBar=this.statusBar);var n=this.baseURL+"/"+this.authPath+"/"+e+"?"+i.a.stringify(t);return a.a.iframeCreate(n),new Promise(function(e,t){var n=new URL(r.baseURL);r._resolve=function(t){n.origin===t.origin&&e(JSON.parse(t.message||t.data))},window.addEventListener("message",r._resolve,!1)})}},{key:"close",value:function(){a.a.iframeRemove(),window.removeEventListener("message",this._resolve,!1)}},{key:"signIn",value:function(){return this.openAction("sign_in",{return_to:"postMessage"})}},{key:"updatePassword",value:function(){return this.openAction("update_password",this.tokenAsQS())}},{key:"home",value:function(){return this.openAction("home",this.tokenAsQS())}},{key:"aclManager",value:function(){return this.openAction("acl-manager",this.tokenAsQS())}},{key:"account",value:function(){return this.openAction("account",this.tokenAsQS())}},{key:"image",value:function(){return this.openAction("image",this.tokenAsQS())}},{key:"address",value:function(){return this.openAction("address",this.tokenAsQS())}},{key:"modules",value:function(){return this.openAction("modules",this.tokenAsQS())}},{key:"openAction",value:function(e,t){var r=this;return this.open(e+"/"+this.appModule,t).then(function(e){return e.token&&e.token.uid&&(r.tokenManager.remember=e.remember,r.tokenManager.setToken(e.token)),r.close(),e})}},{key:"getToken",value:function(){return this._token||(this._token=this.tokenManager.getToken()),this._token}},{key:"current",value:function(){return a.a.$http(this.baseURL+"/usuarios/current",{headers:this.getToken()})}},{key:"signOut",value:function(){var e=this;return a.a.$http(this.baseURL+"/usuarios",{headers:this.getToken(),method:"delete"}).then(function(t){return e._token=null,e.tokenManager.removeToken(),t})}},{key:"tokenAsQS",value:function(){return{_t:a.a.tokenEncode(this.getToken()),remember:this.tokenManager.remember}}}]),e}();t.a=l},function(e,t,r){"use strict";var n=r(8),o=r(9),i=r(1);e.exports={formats:i,parse:o,stringify:n}},function(e,t,r){"use strict";var n=r(0),o=r(1),i={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},a=Date.prototype.toISOString,s={delimiter:"&",encode:!0,encoder:n.encode,encodeValuesOnly:!1,serializeDate:function(e){return a.call(e)},skipNulls:!1,strictNullHandling:!1},c=function e(t,r,o,i,a,c,u,l,f,d,p,y){var h=t;if("function"==typeof u)h=u(r,h);else if(h instanceof Date)h=d(h);else if(null===h){if(i)return c&&!y?c(r,s.encoder):r;h=""}if("string"==typeof h||"number"==typeof h||"boolean"==typeof h||n.isBuffer(h)){if(c){return[p(y?r:c(r,s.encoder))+"="+p(c(h,s.encoder))]}return[p(r)+"="+p(String(h))]}var g=[];if(void 0===h)return g;var m;if(Array.isArray(u))m=u;else{var v=Object.keys(h);m=l?v.sort(l):v}for(var b=0;b<m.length;++b){var k=m[b];a&&null===h[k]||(g=Array.isArray(h)?g.concat(e(h[k],o(r,k),o,i,a,c,u,l,f,d,p,y)):g.concat(e(h[k],r+(f?"."+k:"["+k+"]"),o,i,a,c,u,l,f,d,p,y)))}return g};e.exports=function(e,t){var r=e,a=t?n.assign({},t):{};if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");var u=void 0===a.delimiter?s.delimiter:a.delimiter,l="boolean"==typeof a.strictNullHandling?a.strictNullHandling:s.strictNullHandling,f="boolean"==typeof a.skipNulls?a.skipNulls:s.skipNulls,d="boolean"==typeof a.encode?a.encode:s.encode,p="function"==typeof a.encoder?a.encoder:s.encoder,y="function"==typeof a.sort?a.sort:null,h=void 0!==a.allowDots&&a.allowDots,g="function"==typeof a.serializeDate?a.serializeDate:s.serializeDate,m="boolean"==typeof a.encodeValuesOnly?a.encodeValuesOnly:s.encodeValuesOnly;if(void 0===a.format)a.format=o.default;else if(!Object.prototype.hasOwnProperty.call(o.formatters,a.format))throw new TypeError("Unknown format option provided.");var v,b,k=o.formatters[a.format];"function"==typeof a.filter?(b=a.filter,r=b("",r)):Array.isArray(a.filter)&&(b=a.filter,v=b);var j=[];if("object"!=typeof r||null===r)return"";var O;O=a.arrayFormat in i?a.arrayFormat:"indices"in a?a.indices?"indices":"repeat":"indices";var A=i[O];v||(v=Object.keys(r)),y&&v.sort(y);for(var w=0;w<v.length;++w){var I=v[w];f&&null===r[I]||(j=j.concat(c(r[I],I,A,l,f,d?p:null,b,y,h,g,k,m)))}var M=j.join(u),L=!0===a.addQueryPrefix?"?":"";return M.length>0?L+M:""}},function(e,t,r){"use strict";var n=r(0),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,t){for(var r={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=n.split(t.delimiter,a),c=0;c<s.length;++c){var u,l,f=s[c],d=f.indexOf("]="),p=-1===d?f.indexOf("="):d+1;-1===p?(u=t.decoder(f,i.decoder),l=t.strictNullHandling?null:""):(u=t.decoder(f.slice(0,p),i.decoder),l=t.decoder(f.slice(p+1),i.decoder)),o.call(r,u)?r[u]=[].concat(r[u]).concat(l):r[u]=l}return r},s=function(e,t,r){for(var n=t,o=e.length-1;o>=0;--o){var i,a=e[o];if("[]"===a)i=[],i=i.concat(n);else{i=r.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(s,10);!isNaN(c)&&a!==s&&String(c)===s&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(i=[],i[c]=n):i[s]=n}n=i}return n},c=function(e,t,r){if(e){var n=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,c=i.exec(n),u=c?n.slice(0,c.index):n,l=[];if(u){if(!r.plainObjects&&o.call(Object.prototype,u)&&!r.allowPrototypes)return;l.push(u)}for(var f=0;null!==(c=a.exec(n))&&f<r.depth;){if(f+=1,!r.plainObjects&&o.call(Object.prototype,c[1].slice(1,-1))&&!r.allowPrototypes)return;l.push(c[1])}return c&&l.push("["+n.slice(c.index)+"]"),s(l,t,r)}};e.exports=function(e,t){var r=t?n.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||n.isRegExp(r.delimiter)?r.delimiter:i.delimiter,r.depth="number"==typeof r.depth?r.depth:i.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:i.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:i.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:i.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:i.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:i.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:i.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:i.strictNullHandling,""===e||null===e||void 0===e)return r.plainObjects?Object.create(null):{};for(var o="string"==typeof e?a(e,r):e,s=r.plainObjects?Object.create(null):{},u=Object.keys(o),l=0;l<u.length;++l){var f=u[l],d=c(f,o[f],r);s=n.merge(s,d,r)}return n.compact(s)}},function(e,t,r){"use strict";t.a={iframeCreate:function(e){var t=document.createElement("iframe");return t.src=e,t.style.width="100%",t.style.height="100vh",t.style.position="absolute",t.style.top=0,t.style.left=0,t.style.border="none",t.style.margin=0,t.style.zIndex=99999,this.oldOverflowY=document.body.style.overflowY,document.body.style.overflowY="hidden",t.style.background='#fff url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjAiIHdpZHRoPSI3MnB4IiBoZWlnaHQ9IjcycHgiIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB4bWw6c3BhY2U9InByZXNlcnZlIj48Zz48cGF0aCBmaWxsPSIjOTk5OTk5IiBkPSJNMTA5LjI1IDU1LjVoLTM2bDEyLTEyYTI5LjU0IDI5LjU0IDAgMCAwLTQ5LjUzIDEySDE4Ljc1QTQ2LjA0IDQ2LjA0IDAgMCAxIDk2LjkgMzEuODRsMTIuMzUtMTIuMzR2MzZ6bS05MC41IDE3aDM2bC0xMiAxMmEyOS41NCAyOS41NCAwIDAgMCA0OS41My0xMmgxNi45N0E0Ni4wNCA0Ni4wNCAwIDAgMSAzMS4xIDk2LjE2TDE4Ljc0IDEwOC41di0zNnoiLz48YW5pbWF0ZVRyYW5zZm9ybSBhdHRyaWJ1dGVOYW1lPSJ0cmFuc2Zvcm0iIHR5cGU9InJvdGF0ZSIgZnJvbT0iMCA2NCA2NCIgdG89IjM2MCA2NCA2NCIgZHVyPSIxMDQwbXMiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIj48L2FuaW1hdGVUcmFuc2Zvcm0+PC9nPjwvc3ZnPg==") center center no-repeat',document.body.appendChild(t),this.iframe=t,t},iframeRemove:function(){this.iframe&&(document.body.style.overflowY=this.oldOverflowY,this.iframe.remove())},$http:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(r,n){var o=new XMLHttpRequest;if(o.timeout=1e4,o.onerror=function(e){return n(e)},o.onload=function(e){return o.status>=200&&o.status<400?r(o.response):n(e)},o.responseType="json",o.open(t.method||"get",e),t.headers)for(var i in t.headers)o.setRequestHeader(i,t.headers[i]);o.send()})},tokenEncode:function(e){return btoa(JSON.stringify(e))},tokenDecode:function(e){return atob(JSON.parse(e))}}},function(e,t,r){"use strict";t.a={_storageKey:"auth_token",setToken:function(e){this._token=e,localStorage.setItem(this._storageKey,JSON.stringify(e))},getToken:function(){if(!this._token){var e=localStorage.getItem(this._storageKey);this._token=e?JSON.parse(e):""}return this._token},removeToken:function(){delete this._token,localStorage.removeItem(this._storageKey)}}}])});
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "auth-javascript",
|
|
3
|
+
"version": "0.0.16",
|
|
4
|
+
"description": "Auth JS Client for e-city",
|
|
5
|
+
"author": "Marcos Paliari <marcos@paliari.com.br>",
|
|
6
|
+
"main": "dist/auth-js.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dist": "poi build ./src/index.js --format umd --module-name AuthJs --filename.js auth-js.js --no-sourceMap --no-html",
|
|
10
|
+
"dist:demo": "poi build ./demo/index.js --config ./demo/build.config.js --filename.css auth-js.css --no-sourceMap --dist ./docs",
|
|
11
|
+
"start": "yarn dev",
|
|
12
|
+
"dev": "poi build ./demo/index.js --config ./demo/build.config.js --filename.css auth-js.css --no-sourceMap --no-minimize --dist ./docs",
|
|
13
|
+
"release": "rm -rf dist && rm -rf docs && yarn dist:demo && yarn dist",
|
|
14
|
+
"demo:open": "open 'http://localhost:5000/'; serve ./docs/"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"auth",
|
|
21
|
+
"auth-js"
|
|
22
|
+
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"poi": "^9.6.1"
|
|
25
|
+
}
|
|
26
|
+
}
|