qlfy-ecological-login 1.0.0 → 1.0.1
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.
|
@@ -15,6 +15,6 @@ export declare function getLoginInfo(): any;
|
|
|
15
15
|
* @param {string} redirectUrl 重定向地址
|
|
16
16
|
* @returns {string}
|
|
17
17
|
*/
|
|
18
|
-
export declare function getLoginUrl(loginPageIpAddress: string, clientId: string, clientSecret: string, redirectUrl?: string): string;
|
|
18
|
+
export declare function getLoginUrl(loginPageIpAddress: string, clientId: string, clientSecret: string, tenantId: string, redirectUrl?: string): string;
|
|
19
19
|
export declare function generateUUID(): string;
|
|
20
20
|
export declare function getUserPermission(): any;
|
package/lib/index.mjs
CHANGED
|
@@ -1784,14 +1784,14 @@ function Dn() {
|
|
|
1784
1784
|
return console.log(e), !e || !e.isEnabled ? null : L.get(e.tokenName);
|
|
1785
1785
|
}
|
|
1786
1786
|
function fe() {
|
|
1787
|
-
const e = L.get("qlfyEcologicalLogin_" + _.componentId), t = jn(e.loginPageIpAddress, e.clientId, e.clientSecret, e.redirectPath);
|
|
1787
|
+
const e = L.get("qlfyEcologicalLogin_" + _.componentId), t = jn(e.loginPageIpAddress, e.clientId, e.clientSecret, e.tenantId, e.redirectPath);
|
|
1788
1788
|
t && window.open(t, "_self");
|
|
1789
1789
|
}
|
|
1790
1790
|
function qn() {
|
|
1791
1791
|
return L.get("loginInfo");
|
|
1792
1792
|
}
|
|
1793
|
-
function jn(e, t, r, n) {
|
|
1794
|
-
return !t || !r ? (console.error("未配置应用id或应用密钥"), "") :
|
|
1793
|
+
function jn(e, t, r, n, o) {
|
|
1794
|
+
return !t || !r ? (console.error("未配置应用id或应用密钥"), "") : n ? (o = o || encodeURIComponent(window.location.href), `${e}/#/login?clientId=${t}&clientSecret=${r}&tenantId=${n}&redirectUrl=${o}`) : (console.error("未配置租户id"), "");
|
|
1795
1795
|
}
|
|
1796
1796
|
function Mn() {
|
|
1797
1797
|
let e = "", t;
|
package/lib/index.mjs.gz
CHANGED
|
Binary file
|
package/lib/index.umd.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[De]=this[De]={accessors:{}}).accessors,o=this.prototype;function s(i){const l=z(i);n[l]||(cn(o,i),n[l]=!0)}return a.isArray(t)?t.forEach(s):s(t),this}};A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(A.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),a.freezeMethods(A);function fe(e,t){const r=this||v,n=t||r,o=A.from(n.headers);let s=n.data;return a.forEach(e,function(l){s=l.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function qe(e){return!!(e&&e.__CANCEL__)}function M(e,t,r){g.call(this,e??"canceled",g.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(M,g,{__CANCEL__:!0});function je(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new g("Request failed with status code "+r.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function un(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function fn(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(p){const c=Date.now(),u=n[s];i||(i=c),r[o]=p,n[o]=c;let m=s,y=0;for(;m!==o;)y+=r[m++],m=m%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const E=u&&c-u;return E?Math.round(y*1e3/E):void 0}}function dn(e,t){let r=0,n=1e3/t,o,s;const i=(c,u=Date.now())=>{r=u,o=null,s&&(clearTimeout(s),s=null),e.apply(null,c)};return[(...c)=>{const u=Date.now(),m=u-r;m>=n?i(c,u):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},n-m)))},()=>o&&i(o)]}const Z=(e,t,r=3)=>{let n=0;const o=fn(50,250);return dn(s=>{const i=s.loaded,l=s.lengthComputable?s.total:void 0,p=i-n,c=o(p),u=i<=l;n=i;const m={loaded:i,total:l,progress:l?i/l:void 0,bytes:p,rate:c||void 0,estimated:c&&l&&u?(l-i)/c:void 0,event:s,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(m)},r)},Me=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},$e=e=>(...t)=>a.asap(()=>e(...t)),pn=O.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,O.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,hn=O.hasStandardBrowserEnv?{write(e,t,r,n,o,s){const i=[e+"="+encodeURIComponent(t)];a.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),a.isString(n)&&i.push("path="+n),a.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function mn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function gn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function He(e,t,r){let n=!mn(t);return e&&(n||r==!1)?gn(e,t):t}const ve=e=>e instanceof A?{...e}:e;function I(e,t){t=t||{};const r={};function n(c,u,m,y){return a.isPlainObject(c)&&a.isPlainObject(u)?a.merge.call({caseless:y},c,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(c,u,m,y){if(a.isUndefined(u)){if(!a.isUndefined(c))return n(void 0,c,m,y)}else return n(c,u,m,y)}function s(c,u){if(!a.isUndefined(u))return n(void 0,u)}function i(c,u){if(a.isUndefined(u)){if(!a.isUndefined(c))return n(void 0,c)}else return n(void 0,u)}function l(c,u,m){if(m in t)return n(c,u);if(m in e)return n(void 0,c)}const p={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(c,u,m)=>o(ve(c),ve(u),m,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){const m=p[u]||o,y=m(e[u],t[u],u);a.isUndefined(y)&&m!==l||(r[u]=y)}),r}const ze=e=>{const t=I({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:l}=t;t.headers=i=A.from(i),t.url=Ue(He(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let p;if(a.isFormData(r)){if(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((p=i.getContentType())!==!1){const[c,...u]=p?p.split(";").map(m=>m.trim()).filter(Boolean):[];i.setContentType([c||"multipart/form-data",...u].join("; "))}}if(O.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(t)),n||n!==!1&&pn(t.url))){const c=o&&s&&hn.read(s);c&&i.set(o,c)}return t},yn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=ze(e);let s=o.data;const i=A.from(o.headers).normalize();let{responseType:l,onUploadProgress:p,onDownloadProgress:c}=o,u,m,y,E,f;function h(){E&&E(),f&&f(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let d=new XMLHttpRequest;d.open(o.method.toUpperCase(),o.url,!0),d.timeout=o.timeout;function b(){if(!d)return;const R=A.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),x={data:!l||l==="text"||l==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:R,config:e,request:d};je(function(q){r(q),h()},function(q){n(q),h()},x),d=null}"onloadend"in d?d.onloadend=b:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(b)},d.onabort=function(){d&&(n(new g("Request aborted",g.ECONNABORTED,e,d)),d=null)},d.onerror=function(){n(new g("Network Error",g.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const x=o.transitional||Be;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),n(new g(k,x.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,e,d)),d=null},s===void 0&&i.setContentType(null),"setRequestHeader"in d&&a.forEach(i.toJSON(),function(k,x){d.setRequestHeader(x,k)}),a.isUndefined(o.withCredentials)||(d.withCredentials=!!o.withCredentials),l&&l!=="json"&&(d.responseType=o.responseType),c&&([y,f]=Z(c,!0),d.addEventListener("progress",y)),p&&d.upload&&([m,E]=Z(p),d.upload.addEventListener("progress",m),d.upload.addEventListener("loadend",E)),(o.cancelToken||o.signal)&&(u=R=>{d&&(n(!R||R.type?new M(null,e,d):R),d.abort(),d=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const S=un(o.url);if(S&&O.protocols.indexOf(S)===-1){n(new g("Unsupported protocol "+S+":",g.ERR_BAD_REQUEST,e));return}d.send(s||null)})},bn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(c){if(!o){o=!0,l();const u=c instanceof Error?c:this.reason;n.abort(u instanceof g?u:new M(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,s(new g(`timeout ${t} of ms exceeded`,g.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:p}=n;return p.unsubscribe=()=>a.asap(l),p}},wn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},En=async function*(e,t){for await(const r of Sn(e))yield*wn(r,t)},Sn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Je=(e,t,r,n)=>{const o=En(e,t);let s=0,i,l=p=>{i||(i=!0,n&&n(p))};return new ReadableStream({async pull(p){try{const{done:c,value:u}=await o.next();if(c){l(),p.close();return}let m=u.byteLength;if(r){let y=s+=m;r(y)}p.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(p){return l(p),o.return()}},{highWaterMark:2})},Y=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ve=Y&&typeof ReadableStream=="function",Rn=Y&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),We=(e,...t)=>{try{return!!e(...t)}catch{return!1}},On=Ve&&We(()=>{let e=!1;const t=new Request(O.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Ke=64*1024,de=Ve&&We(()=>a.isReadableStream(new Response("").body)),ee={stream:de&&(e=>e.body)};Y&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ee[t]&&(ee[t]=a.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new g(`Response type '${t}' is not supported`,g.ERR_NOT_SUPPORT,n)})})})(new Response);const Tn=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(O.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await Rn(e)).byteLength},An=async(e,t)=>{const r=a.toFiniteNumber(e.getContentLength());return r??Tn(t)},pe={http:Jt,xhr:yn,fetch:Y&&(async e=>{let{url:t,method:r,data:n,signal:o,cancelToken:s,timeout:i,onDownloadProgress:l,onUploadProgress:p,responseType:c,headers:u,withCredentials:m="same-origin",fetchOptions:y}=ze(e);c=c?(c+"").toLowerCase():"text";let E=bn([o,s&&s.toAbortSignal()],i),f;const h=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let d;try{if(p&&On&&r!=="get"&&r!=="head"&&(d=await An(u,n))!==0){let x=new Request(t,{method:"POST",body:n,duplex:"half"}),F;if(a.isFormData(n)&&(F=x.headers.get("content-type"))&&u.setContentType(F),x.body){const[q,re]=Me(d,Z($e(p)));n=Je(x.body,Ke,q,re)}}a.isString(m)||(m=m?"include":"omit");const b="credentials"in Request.prototype;f=new Request(t,{...y,signal:E,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:b?m:void 0});let S=await fetch(f,y);const R=de&&(c==="stream"||c==="response");if(de&&(l||R&&h)){const x={};["status","statusText","headers"].forEach(st=>{x[st]=S[st]});const F=a.toFiniteNumber(S.headers.get("content-length")),[q,re]=l&&Me(F,Z($e(l),!0))||[];S=new Response(Je(S.body,Ke,q,()=>{re&&re(),h&&h()}),x)}c=c||"text";let k=await ee[a.findKey(ee,c)||"text"](S,e);return!R&&h&&h(),await new Promise((x,F)=>{je(x,F,{data:k,headers:A.from(S.headers),status:S.status,statusText:S.statusText,config:e,request:f})})}catch(b){throw h&&h(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,e,f),{cause:b.cause||b}):g.from(b,b&&b.code,e,f)}})};a.forEach(pe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Xe=e=>`- ${e}`,xn=e=>a.isFunction(e)||e===null||e===!1,Ge={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let r,n;const o={};for(let s=0;s<t;s++){r=e[s];let i;if(n=r,!xn(r)&&(n=pe[(i=String(r)).toLowerCase()],n===void 0))throw new g(`Unknown adapter '${i}'`);if(n)break;o[i||"#"+s]=n}if(!n){const s=Object.entries(o).map(([l,p])=>`adapter ${l} `+(p===!1?"is not supported by the environment":"is not available in the build"));let i=t?s.length>1?`since :
|
|
4
4
|
`+s.map(Xe).join(`
|
|
5
5
|
`):" "+Xe(s[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:pe};function he(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new M(null,e)}function Qe(e){return he(e),e.headers=A.from(e.headers),e.data=fe.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ge.getAdapter(e.adapter||v.adapter)(e).then(function(n){return he(e),n.data=fe.call(e,e.transformResponse,n),n.headers=A.from(n.headers),n},function(n){return qe(n)||(he(e),n&&n.response&&(n.response.data=fe.call(e,e.transformResponse,n.response),n.response.headers=A.from(n.response.headers))),Promise.reject(n)})}const Ze="1.10.0",te={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{te[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Ye={};te.transitional=function(t,r,n){function o(s,i){return"[Axios v"+Ze+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,l)=>{if(t===!1)throw new g(o(i," has been removed"+(r?" in "+r:"")),g.ERR_DEPRECATED);return r&&!Ye[i]&&(Ye[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,l):!0}},te.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function Cn(e,t,r){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const l=e[s],p=l===void 0||i(l,s,e);if(p!==!0)throw new g("option "+s+" must be "+p,g.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new g("Unknown option "+s,g.ERR_BAD_OPTION)}}const ne={assertOptions:Cn,validators:te},_=ne.validators;let D=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Fe,response:new Fe}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
6
|
-
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=I(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&ne.assertOptions(n,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ne.assertOptions(o,{encode:_.function,serialize:_.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ne.assertOptions(r,{baseUrl:_.spelling("baseURL"),withXsrfToken:_.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&a.merge(s.common,s[r.method]);s&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),r.headers=A.concat(i,s);const l=[];let p=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(p=p&&h.synchronous,l.unshift(h.fulfilled,h.rejected))});const c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let u,m=0,y;if(!p){const f=[Qe.bind(this),void 0];for(f.unshift.apply(f,l),f.push.apply(f,c),y=f.length,u=Promise.resolve(r);m<y;)u=u.then(f[m++],f[m++]);return u}y=l.length;let E=r;for(m=0;m<y;){const f=l[m++],h=l[m++];try{E=f(E)}catch(d){h.call(this,d);break}}try{u=Qe.call(this,E)}catch(f){return Promise.reject(f)}for(m=0,y=c.length;m<y;)u=u.then(c[m++],c[m++]);return u}getUri(t){t=I(this.defaults,t);const r=He(t.baseURL,t.url,t.allowAbsoluteUrls);return Ue(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){D.prototype[t]=function(r,n){return this.request(I(n||{},{method:t,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,l){return this.request(I(l||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}D.prototype[t]=r(),D.prototype[t+"Form"]=r(!0)});let Nn=class it{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(l=>{n.subscribe(l),s=l}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,l){n.reason||(n.reason=new M(s,i,l),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new it(function(o){t=o}),cancel:t}}};function _n(e){return function(r){return e.apply(null,r)}}function Pn(e){return a.isObject(e)&&e.isAxiosError===!0}const me={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(me).forEach(([e,t])=>{me[t]=e});function et(e){const t=new D(e),r=be(D.prototype.request,t);return a.extend(r,D.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return et(I(e,o))},r}const w=et(v);w.Axios=D,w.CanceledError=M,w.CancelToken=Nn,w.isCancel=qe,w.VERSION=Ze,w.toFormData=G,w.AxiosError=g,w.Cancel=w.CanceledError,w.all=function(t){return Promise.all(t)},w.spread=_n,w.isAxiosError=Pn,w.mergeConfig=I,w.AxiosHeaders=A,w.formToJSON=e=>Ie(a.isHTMLForm(e)?new FormData(e):e),w.getAdapter=Ge.getAdapter,w.HttpStatusCode=me,w.default=w;const{Axios:zn,AxiosError:Jn,CanceledError:Vn,isCancel:Wn,CancelToken:Kn,VERSION:Xn,all:Gn,Cancel:Qn,isAxiosError:Zn,spread:Yn,toFormData:er,AxiosHeaders:tr,HttpStatusCode:nr,formToJSON:rr,getAdapter:or,mergeConfig:sr}=w;class ge{set(t,r,n){let o=null;if(typeof n=="number"&&n>0)o=Date.now()+n*1e3;else if(typeof n>"u"){const i=this.getRaw(t);o=i?i.expire:null}const s={value:r,expire:o};localStorage.setItem(t,JSON.stringify(s))}get(t){const r=this.getRaw(t);return r?r.expire&&Date.now()>r.expire?(this.remove(t),null):r.value:null}getRaw(t){try{const r=localStorage.getItem(t);if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"&&"value"in n&&"expire"in n?n:{value:r,expire:null}}catch{return{value:localStorage.getItem(t),expire:null}}}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}const kn=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"})),P={componentId:"",userPermission:null},U=new ge;function tt(){const e=U.get("qlfyEcologicalLogin_"+P.componentId);if(!e||!e.isEnabled)return console.error(new Error("统一登陆未开启,请检查配置")),null;let t=U.get(e.tokenName);console.log(t),w({method:"post",url:e.loginServiceIpAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":e.tenantId,Authorization:"Bearer "+t}}).then(r=>{r.data.code||(U.remove(e.tokenName),U.remove("loginInfo"),ye())})}function nt(){const e=U.get("qlfyEcologicalLogin_"+P.componentId);return console.log(e),!e||!e.isEnabled?null:U.get(e.tokenName)}function ye(){const e=U.get("qlfyEcologicalLogin_"+P.componentId),t=Un(e.loginPageIpAddress,e.clientId,e.clientSecret,e.redirectPath);t&&window.open(t,"_self")}function Ln(){return U.get("loginInfo")}function Un(e,t,r,n){return!t||!r?(console.error("未配置应用id或应用密钥"),""):(
|
|
6
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=I(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&ne.assertOptions(n,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ne.assertOptions(o,{encode:_.function,serialize:_.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ne.assertOptions(r,{baseUrl:_.spelling("baseURL"),withXsrfToken:_.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&a.merge(s.common,s[r.method]);s&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),r.headers=A.concat(i,s);const l=[];let p=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(p=p&&h.synchronous,l.unshift(h.fulfilled,h.rejected))});const c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let u,m=0,y;if(!p){const f=[Qe.bind(this),void 0];for(f.unshift.apply(f,l),f.push.apply(f,c),y=f.length,u=Promise.resolve(r);m<y;)u=u.then(f[m++],f[m++]);return u}y=l.length;let E=r;for(m=0;m<y;){const f=l[m++],h=l[m++];try{E=f(E)}catch(d){h.call(this,d);break}}try{u=Qe.call(this,E)}catch(f){return Promise.reject(f)}for(m=0,y=c.length;m<y;)u=u.then(c[m++],c[m++]);return u}getUri(t){t=I(this.defaults,t);const r=He(t.baseURL,t.url,t.allowAbsoluteUrls);return Ue(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){D.prototype[t]=function(r,n){return this.request(I(n||{},{method:t,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,l){return this.request(I(l||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}D.prototype[t]=r(),D.prototype[t+"Form"]=r(!0)});let Nn=class it{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(l=>{n.subscribe(l),s=l}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,l){n.reason||(n.reason=new M(s,i,l),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new it(function(o){t=o}),cancel:t}}};function _n(e){return function(r){return e.apply(null,r)}}function Pn(e){return a.isObject(e)&&e.isAxiosError===!0}const me={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(me).forEach(([e,t])=>{me[t]=e});function et(e){const t=new D(e),r=be(D.prototype.request,t);return a.extend(r,D.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return et(I(e,o))},r}const w=et(v);w.Axios=D,w.CanceledError=M,w.CancelToken=Nn,w.isCancel=qe,w.VERSION=Ze,w.toFormData=G,w.AxiosError=g,w.Cancel=w.CanceledError,w.all=function(t){return Promise.all(t)},w.spread=_n,w.isAxiosError=Pn,w.mergeConfig=I,w.AxiosHeaders=A,w.formToJSON=e=>Ie(a.isHTMLForm(e)?new FormData(e):e),w.getAdapter=Ge.getAdapter,w.HttpStatusCode=me,w.default=w;const{Axios:zn,AxiosError:Jn,CanceledError:Vn,isCancel:Wn,CancelToken:Kn,VERSION:Xn,all:Gn,Cancel:Qn,isAxiosError:Zn,spread:Yn,toFormData:er,AxiosHeaders:tr,HttpStatusCode:nr,formToJSON:rr,getAdapter:or,mergeConfig:sr}=w;class ge{set(t,r,n){let o=null;if(typeof n=="number"&&n>0)o=Date.now()+n*1e3;else if(typeof n>"u"){const i=this.getRaw(t);o=i?i.expire:null}const s={value:r,expire:o};localStorage.setItem(t,JSON.stringify(s))}get(t){const r=this.getRaw(t);return r?r.expire&&Date.now()>r.expire?(this.remove(t),null):r.value:null}getRaw(t){try{const r=localStorage.getItem(t);if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"&&"value"in n&&"expire"in n?n:{value:r,expire:null}}catch{return{value:localStorage.getItem(t),expire:null}}}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}const kn=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"})),P={componentId:"",userPermission:null},U=new ge;function tt(){const e=U.get("qlfyEcologicalLogin_"+P.componentId);if(!e||!e.isEnabled)return console.error(new Error("统一登陆未开启,请检查配置")),null;let t=U.get(e.tokenName);console.log(t),w({method:"post",url:e.loginServiceIpAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":e.tenantId,Authorization:"Bearer "+t}}).then(r=>{r.data.code||(U.remove(e.tokenName),U.remove("loginInfo"),ye())})}function nt(){const e=U.get("qlfyEcologicalLogin_"+P.componentId);return console.log(e),!e||!e.isEnabled?null:U.get(e.tokenName)}function ye(){const e=U.get("qlfyEcologicalLogin_"+P.componentId),t=Un(e.loginPageIpAddress,e.clientId,e.clientSecret,e.tenantId,e.redirectPath);t&&window.open(t,"_self")}function Ln(){return U.get("loginInfo")}function Un(e,t,r,n,o){return!t||!r?(console.error("未配置应用id或应用密钥"),""):n?(o=o||encodeURIComponent(window.location.href),`${e}/#/login?clientId=${t}&clientSecret=${r}&tenantId=${n}&redirectUrl=${o}`):(console.error("未配置租户id"),"")}function Fn(){let e="",t;for(let r=0;r<32;r++)t=Math.random()*16|0,(r===8||r===12||r===16||r===20)&&(e+="-"),e+=(r===12?4:r===16?t&3|8:t).toString(16);return e}function rt(){return P.userPermission}const ot=L.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageIpAddress:{},loginServiceIpAddress:{},useRouter:{},loginInfo:{},token:{},isEnabled:{type:Boolean,default:!0},listenToken:{type:Boolean,default:!1},redirectPath:{default:""},tokenName:{default:"access_token"},refreshInterval:{default:60*10},tokenValidity:{default:60*30},tenantId:{default:7}},emits:["loggingIn","loginSuccess","tokenChange"],setup(e,{expose:t,emit:r}){const n=e,o=n.useRouter,s=n.useRouter.currentRoute,i=r,l=new ge;l.get("loginInfo");let p=!0;const c=Fn();t({logout:tt,getToken:nt,getLoginInfo:Ln,getUserPermission:rt}),P.componentId||(P.componentId=c),L.onBeforeUnmount(()=>{for(let f=0;f<localStorage.length;f++){let h=localStorage.key(f);h&&h.indexOf("qlfyEcologicalLogin_")>=0&&l.remove(h)}}),L.watch(()=>s.value.path,(f,h)=>{setTimeout(()=>{n.isEnabled&&u()})},{deep:!0}),L.watch(()=>n.isEnabled,()=>{setTimeout(()=>{if(u(),!n.isEnabled){l.remove(n.tokenName);for(let f=0;f<localStorage.length;f++){let h=localStorage.key(f);h&&h.indexOf("qlfyEcologicalLogin_")===0&&l.remove(h)}l.remove("loginInfo")}})},{deep:!0});function u(){if(!n.isEnabled||c!==P.componentId)return;E(),n.token&&l.set(n.tokenName,n.token,n.tokenValidity);const f=l.get(n.tokenName),h=!!s.value.query.token;if(P.userPermission=null,!f&&h){l.set(n.tokenName,s.value.query.token,n.tokenValidity);let d={...s.value.query};delete d.token,o.replace({path:s.value.path,query:d}),y(f)}else f&&p?(m(f),p=!1):ye()}function m(f){let h={token:f};const d={"tenant-id":n.tenantId,Authorization:"Basic "+btoa(n.clientId+":"+n.clientSecret)};w.post(n.loginServiceIpAddress+"/admin-api/system/oauth2/check-token","",{params:h,headers:d}).then(b=>{if(b.data.code){l.remove(n.tokenName),ye();return}y(f)}).catch(b=>{console.log(b)})}function y(f){let h={clientId:n.clientId};const d={"tenant-id":n.tenantId,Authorization:f};w.get(n.loginServiceIpAddress+"/admin-api/system/auth/get-permission-info",{params:h,headers:d}).then(b=>{P.userPermission=c,i("loginSuccess",b.data)}).catch(b=>{console.log(b)})}function E(){if(c!==P.componentId)return;for(let h=0;h<localStorage.length;h++){let d=localStorage.key(h);d&&d.indexOf("qlfyEcologicalLogin_")===0&&l.remove(d)}const f={...n};delete f.useRouter,l.set("qlfyEcologicalLogin_"+c,f)}return(f,h)=>null}}),Bn=ot,In={install(e){e.component("qlfyEcologicalLogin",ot)}};C.LocalStorageManager=kn,C.default=In,C.getToken=nt,C.getUserPermission=rt,C.logout=tt,C.qlfyEcologicalLogin=Bn,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/lib/index.umd.js.gz
CHANGED
|
Binary file
|