@cloudbase/js-sdk 2.8.2-beta.0 → 2.8.4-beta.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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_oauth",[],e):"object"==typeof exports?exports.cloudbase_oauth=e():t.cloudbase_oauth=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={256:(t,e,r)=>{r.r(e),r.d(e,{Auth:()=>A,CloudbaseOAuth:()=>O,authModels:()=>u});var i,s,n,o,a,h,u={};function c(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.r(u),function(t){t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.WEDA_USER_URL="/auth/v1/plugin/weda/userinfo",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/auth/v1/mgr/provider/providerSubType",t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/auth/v1/signin/wechat/noauth",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.AUTH_SIGNOUT_URL="/auth/v1/user/signout",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_BASIC_EDIT_URL="/auth/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTHORIZE_DEVICE_URL="/auth/v1/user/device/authorize",t.AUTHORIZE_URL="/auth/v1/user/authorize",t.AUTHORIZE_INFO_URL="/auth/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/auth/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/auth/v1/user/revoke/all",t.GET_USER_BEHAVIOR_LOG="/auth/v1/user/security/history",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.CAPTCHA_DATA_URL="/auth/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/auth/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/auth/v1/captcha/init",t.GET_MINIPROGRAM_QRCODE="/auth/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/auth/v1/qrcode/get/status"}(i||(i={})),function(t){t.AUTH_SIGN_IN_URL="/auth/v2/signin/username",t.AUTH_TOKEN_URL="/auth/v2/token",t.USER_ME_URL="/auth/v2/user/me",t.VERIFY_URL="/auth/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/auth/v2/signin/publichkey",t.AUTH_RESET_PASSWORD="/auth/v2/signin/password/update"}(s||(s={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(n||(n={})),(h=o||(o={})).UNREACHABLE="unreachable",h.LOCAL="local",h.CANCELLED="cancelled",h.UNKNOWN="unknown",h.UNAUTHENTICATED="unauthenticated",h.RESOURCE_EXHAUSTED="resource_exhausted",h.FAILED_PRECONDITION="failed_precondition",h.INVALID_ARGUMENT="invalid_argument",h.DEADLINE_EXCEEDED="deadline_exceeded",h.NOT_FOUND="not_found",h.ALREADY_EXISTS="already_exists",h.PERMISSION_DENIED="permission_denied",h.ABORTED="aborted",h.OUT_OF_RANGE="out_of_range",h.UNIMPLEMENTED="unimplemented",h.INTERNAL="internal",h.UNAVAILABLE="unavailable",h.DATA_LOSS="data_loss",h.INVALID_PASSWORD="invalid_password",h.PASSWORD_NOT_SET="password_not_set",h.INVALID_STATUS="invalid_status",h.USER_PENDING="user_pending",h.USER_BLOCKED="user_blocked",h.INVALID_VERIFICATION_CODE="invalid_verification_code",h.TWO_FACTOR_REQUIRED="two_factor_required",h.INVALID_TWO_FACTOR="invalid_two_factor",h.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",h.UNDER_REVIEW="under_review",h.INVALID_REQUEST="invalid_request",h.UNAUTHORIZED_CLIENT="unauthorized_client",h.ACCESS_DENIED="access_denied",h.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",h.INVALID_SCOPE="invalid_scope",h.INVALID_GRANT="invalid_grant",h.SERVER_ERROR="server_error",h.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",h.INTERACTION_REQUIRED="interaction_required",h.LOGIN_REQUIRED="login_required",h.ACCOUNT_SELECTION_REQUIRED="account_selection_required",h.CONSENT_REQUIRED="consent_required",h.INVALID_REQUEST_URI="invalid_request_uri",h.INVALID_REQUEST_OBJECT="invalid_request_object",h.REQUEST_NOT_SUPPORTED="request_not_supported",h.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",h.REGISTRATION_NOT_SUPPORTED="registration_not_supported",h.CAPTCHA_REQUIRED="captcha_required",h.CAPTCHA_INVALID="captcha_invalid",function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(a||(a={}));var l=r(479);class d{constructor(){this.fnPromiseMap=new Map}async run(t,e){let r=this.fnPromiseMap.get(t);return await r||(r=new Promise(((r,i)=>{(async()=>{try{await this.runIdlePromise();const t=e();r(await t)}catch(t){i(t)}finally{this.fnPromiseMap.delete(t)}})()})),this.fnPromiseMap.set(t,r)),r}runIdlePromise(){return Promise.resolve()}}const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p="x-request-id",g="x-device-id",m="device_id",_=async function(t,e){let r=null,i=null;try{const s=Object.assign({},e);s.method||(s.method="GET"),s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));const n=await fetch(t,s),o=await n.json();o?.error?(i=o,i.error_uri=new URL(t).pathname):r=o}catch(e){i={error:o.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(i)throw i;return r},y=new class{constructor(t){this._env=t?.env||""}async getItem(t){return window.localStorage.getItem(`${t}${this._env}`)}async removeItem(t){window.localStorage.removeItem(`${t}${this._env}`)}async setItem(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}getItemSync(t){return window.localStorage.getItem(`${t}${this._env}`)}removeItemSync(t){window.localStorage.removeItem(`${t}${this._env}`)}setItemSync(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}};function v(t){let e=!0;return t?.expires_at&&t?.access_token&&(e=t.expires_at<new Date),e}class T{constructor(t){this.credentials=null,this.singlePromise=new d,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}getStorageCredentialsSync(){let t=null;const e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t}async setCredentials(t){if(t?.expires_in){if(t?.expires_at||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),this.storage){const e=JSON.stringify(t);await this.storage.setItem(this.tokenSectionName,e)}this.credentials=t}else this.storage&&await this.storage.removeItem(this.tokenSectionName),this.credentials=null}async getCredentials(){return this.singlePromise.run("getCredentials",(async()=>(v(this.credentials)&&(this.credentials=await this.getStorageCredentials()),this.credentials)))}async getStorageCredentials(){return this.singlePromise.run("_getStorageCredentials",(async()=>{let t=null;const e=await this.storage.getItem(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){await this.storage.removeItem(this.tokenSectionName),t=null}return t}))}}class E{constructor(t){this.singlePromise=new d,t.clientSecret||(t.clientSecret=""),!t.clientId&&t.env&&(t.clientId=t.env),this.apiOrigin=t.apiOrigin,this.clientId=t.clientId,this.retry=this.formatRetry(t.retry,E.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=_,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||y,this.localCredentials=new T({tokenSectionName:`credentials_${t.clientId}`,storage:this.storage}),this.clientSecret=t.clientSecret,t.clientId&&(this.basicAuth=`Basic ${function(t){let e,r,i,s,n="",o=0;const a=(t=String(t)).length%3;for(;o<t.length;){if((r=t.charCodeAt(o++))>255||(i=t.charCodeAt(o++))>255||(s=t.charCodeAt(o++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");e=r<<16|i<<8|s,n+=f.charAt(e>>18&63)+f.charAt(e>>12&63)+f.charAt(e>>6&63)+f.charAt(63&e)}return a?n.slice(0,a-3)+"===".substring(a):n}(`${t.clientId}:${this.clientSecret}`)}`),this.wxCloud=t.wxCloud;try{(function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0})()&&void 0===this.wxCloud&&t.env&&(wx.cloud.init({env:t.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc}setCredentials(t){return this.localCredentials.setCredentials(t)}async getAccessToken(){const t=await this.getCredentials();if(t?.access_token)return Promise.resolve(t.access_token);const e={error:o.UNAUTHENTICATED};return Promise.reject(e)}async request(t,e){e||(e={});const r=this.formatRetry(e.retry,this.retry);if(e.headers=e.headers||{},this.headers&&(e.headers={...this.headers,...e.headers}),e.headers[p]||(e.headers[p]=c()),!e.headers[g]){const t=await this.getDeviceId();e.headers[g]=t}if(e?.withBasicAuth&&this.basicAuth&&(e.headers.Authorization=this.basicAuth),e?.withCredentials){const r=await this.getCredentials();r&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+=`access_token=${r.access_token}`):e.headers.Authorization=`${r.token_type} ${r.access_token}`)}else this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+=`client_id=${this.clientId}`);t.startsWith("/")&&(t=this.apiOrigin+t);let i=null;const s=r+1;for(let n=0;n<s;n++){try{i=e.useWxCloud?await this.wxCloudCallFunction(t,e):await this.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===o.UNAUTHENTICATED)return await this.setCredentials(null),Promise.reject(t);if(n===r||!t||"unreachable"!==t.error)return Promise.reject(t)}await this.sleep(E.retryInterval)}return i}async wxCloudCallFunction(t,e){let r=null,i=null;try{const s=await wx.getRendererUserAgent(),{result:n}=await this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:{origin:"https://servicewechat.com","User-Agent":s,...e.headers},body:e.body}});n?.body?.error_code?(i=n?.body,i.error_uri=(0,l.y)(t)):r=n?.body}catch(e){i={error:o.UNREACHABLE,error_description:e.message,error_uri:(0,l.y)(t)}}if(i)throw i;return r}async getCredentials(){let t=await this.localCredentials.getCredentials();return t?(v(t)&&(t=t&&"anonymous"===t.scope?this.anonymousSignInFunc?await this.anonymousSignInFunc(t)||await this.localCredentials.getCredentials():await this.anonymousSignIn(t):await this.refreshToken(t)),t):this.unAuthenticatedError("credentials not found")}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}async getScope(){const t=await this.localCredentials.getCredentials();return t?t.scope:this.unAuthenticatedError("credentials not found")}async getGroups(){const t=await this.localCredentials.getCredentials();return t?t.groups:this.unAuthenticatedError("credentials not found")}async refreshToken(t){return this.singlePromise.run("_refreshToken",(async()=>{if(!t||!t.refresh_token)return this.unAuthenticatedError("no refresh token found in credentials");try{const e=await this.refreshTokenFunc(t.refresh_token,t);return await this.localCredentials.setCredentials(e),e}catch(t){return t.error===o.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}checkRetry(t){let e=null;if(("number"!=typeof t||t<E.minRetry||t>E.maxRetry)&&(e={error:o.UNREACHABLE,error_description:"wrong options param: retry"}),e)throw e;return t}formatRetry(t,e){return void 0===t?e:this.checkRetry(t)}async sleep(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}async anonymousSignIn(t){return this.singlePromise.run("_anonymous",(async()=>{if(!t||"anonymous"!==t.scope)return this.unAuthenticatedError("no anonymous in credentials");try{const t=await this.request(i.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return await this.localCredentials.setCredentials(t),t}catch(t){return t.error===o.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}async defaultRefreshTokenFunc(t,e){if(void 0===t||""===t)return this.unAuthenticatedError("refresh token not found");let r=i.AUTH_TOKEN_URL;return"v2"===e?.version&&(r=s.AUTH_TOKEN_URL),{...await this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}}),version:e?.version||"v1"}}async getDeviceId(){if(this.deviceID)return this.deviceID;let t=await this.storage.getItem(m);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=c(),await this.storage.setItem(m,t)),this.deviceID=t,t}unAuthenticatedError(t){const e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function S(){const{wx:t}=globalThis;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getSystemInfoSync)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getSystemInfoSync())return!1;if("qq"===t.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0}E.defaultRetry=2,E.minRetry=0,E.maxRetry=5,E.retryInterval=1e3;let w=!1;function R(){w=w||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{S()||(w=w||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?R():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",R,!1))}catch(t){}function I(){return w}class b{constructor(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=y),this.config=t,this.tokenSectionName=`captcha_${t.clientId}`}async request(t,e){e||(e={}),e.method||(e.method="GET");const r=`${e.method}:${t}`;let i,s=t;e.withCaptcha&&(s=await this.appendCaptchaTokenToURL(t,r,!1));try{i=await this.config.request(s,e)}catch(i){return i.error===o.CAPTCHA_REQUIRED||i.error===o.CAPTCHA_INVALID?(t=await this.appendCaptchaTokenToURL(t,r,i.error===o.CAPTCHA_INVALID),this.config.request(t,e)):Promise.reject(i)}return i}getDefaultOpenURIWithCallback(){if(!S()&&!I()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){const t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((()=>{document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback}async defaultOpenURIWithCallback(t,e){const{width:r="355px",height:i="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:o.UNIMPLEMENTED,error_description:"need to impl captcha data"});const s=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe");return s.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText=`min-width:${r};display:block;height:${i};margin:0 auto;background-color: rgb(255, 255, 255);border: none;`,s.appendChild(n),s.style.display="block",new Promise(((t,e)=>{n.onload=function(){try{const r=window.location,i=n.contentWindow.location;if(i.host+i.pathname===r.host+r.pathname){s.style.display="none";const r=new URLSearchParams(i.search),n=r.get("captcha_token");return n?t({captcha_token:n,expires_in:Number(r.get("expires_in"))}):e({error:r.get("error"),error_description:r.get("error_description")})}s.style.display="block"}catch(t){s.style.display="block"}}}))}async getCaptchaToken(t,e){if(!t){const t=await this.findCaptchaToken();if(t)return t}let r;if(S()||I()){const t=await this.config.request(i.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1});r={url:`${t.data}?state=${encodeURIComponent(e)}&token=${encodeURIComponent(t.token)}`}}else{const t=`${window.location.origin+window.location.pathname}?__captcha=on`;if(r=await this.config.request(i.GET_CAPTCHA_URL,{method:"POST",body:{client_id:this.config.clientId,redirect_uri:t,state:e},withCredentials:!1}),r.captcha_token){const t={captcha_token:r.captcha_token,expires_in:r.expires_in};return this.saveCaptchaToken(t),r.captcha_token}}const s=await this.config.openURIWithCallback(r.url);return this.saveCaptchaToken(s),s.captcha_token}async appendCaptchaTokenToURL(t,e,r){const i=await this.getCaptchaToken(r,e);return t.indexOf("?")>0?t+=`&captcha_token=${i}`:t+=`?captcha_token=${i}`,t}async saveCaptchaToken(t){t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10));const e=JSON.stringify(t);await this.config.storage.setItem(this.tokenSectionName,e)}async findCaptchaToken(){const t=await this.config.storage.getItem(this.tokenSectionName);if(null!=t)try{const e=JSON.parse(t);return e?.expires_at&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?null:e.captcha_token}catch(t){return await this.config.storage.removeItem(this.tokenSectionName),null}return null}}function C(t){if(!globalThis.IS_MP_BUILD&&t)return r(443)}class A{static parseParamsToSearch(t){return Object.keys(t).forEach((e=>{t[e]||delete t[e]})),new URLSearchParams(t).toString()}constructor(t){let{request:e}=t,r=t.credentialsClient;if(!r){const e={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud};r=new E(e)}if(!e){const i=r.request.bind(r),s=new b({clientId:t.clientId,request:i,storage:t.storage,...t.captchaOptions});e=s.request.bind(s)}this.config={env:t.env,apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||y}}getParamsByVersion(t,e){const r=(0,l.I)(t),n={v2:s}[r?.version]?.[e]||i[e];return r&&delete r.version,{params:r,url:n}}async signIn(t){const e=t.version||"v1",r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL");r.params.query&&delete r.params.query;const i=await this.getEncryptParams(r.params),s=await this.config.request(r.url,{method:"POST",body:i});return await this.config.credentialsClient.setCredentials({...s,version:e}),Promise.resolve(s)}async signInAnonymously(t={}){const e=await this.config.request(i.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signUp(t){const e=await this.config.request(i.AUTH_SIGN_UP_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signOut(t){let e={};if(t){try{e=await this.config.request(i.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})}catch(t){t.error!==o.UNAUTHENTICATED&&console.log("sign_out_error",t)}return await this.config.credentialsClient.setCredentials(),e}const r=await this.config.credentialsClient.getAccessToken(),s=await this.config.request(i.AUTH_REVOKE_URL,{method:"POST",body:{token:r}});return await this.config.credentialsClient.setCredentials(),Promise.resolve(s)}async revokeAllDevices(){await this.config.request(i.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}async revokeDevice(t){await this.config.request(i.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})}async getVerification(t){let e=!1;return("CUR_USER"===t.target||await this.hasLoginState())&&(e=!0),this.config.request(i.VERIFICATION_URL,{method:"POST",body:t,withCredentials:e})}async verify(t){const e=this.getParamsByVersion(t,"VERIFY_URL"),r=await this.config.request(e.url,{method:"POST",body:e.params});return"v2"===t?.version&&await this.config.credentialsClient.setCredentials({...r,version:"v2"}),r}async genProviderRedirectUri(t){const{provider_redirect_uri:e,other_params:r={},...s}=t;e&&!s.redirect_uri&&(s.redirect_uri=e);let n=`${i.PROVIDER_URI_URL}?${A.parseParamsToSearch(s)}`;return Object.keys(r).forEach((t=>{const e=r[t];("sign_out_uri"!==t||e?.length>0)&&(n+=`&other_params[${t}]=${encodeURIComponent(e)}`)})),this.config.request(n,{method:"GET"})}async grantProviderToken(t,e=!1){return this.config.request(i.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})}async patchProviderToken(t){return this.config.request(i.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}async signInWithProvider(t,e=!1){const r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),i=await this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e});return await this.config.credentialsClient.setCredentials({...i,version:t?.version||"v1"}),Promise.resolve(i)}async signInWithWechat(t={}){const e=await this.config.request(i.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async bindWithProvider(t){return this.config.request(i.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})}async getUserProfile(t){return this.getUserInfo(t)}async getUserInfo(t={}){const e=this.getParamsByVersion(t,"USER_ME_URL");if(e.params?.query){const t=new URLSearchParams(e.params.query);e.url+=`?${t.toString()}`}const r=await this.config.request(e.url,{method:"GET",withCredentials:!0});return r.sub&&(r.uid=r.sub),r}async getWedaUserInfo(){return await this.config.request(i.WEDA_USER_URL,{method:"GET",withCredentials:!0})}async deleteMe(t){const e=this.getParamsByVersion(t,"USER_ME_URL"),r=`${e.url}?${A.parseParamsToSearch(e.params)}`;return this.config.request(r,{method:"DELETE",withCredentials:!0})}async hasLoginState(){try{return await this.config.credentialsClient.getAccessToken(),!0}catch(t){return!1}}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}async getLoginState(){return this.config.credentialsClient.getCredentialsAsync()}async transByProvider(t){return this.config.request(i.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})}async grantToken(t){const e=this.getParamsByVersion(t,"AUTH_TOKEN_URL");return this.config.request(e.url,{method:"POST",body:e.params})}async getProviders(){return this.config.request(i.PROVIDER_LIST,{method:"GET",withCredentials:!0})}async unbindProvider(t){return this.config.request(`${i.PROVIDER_UNBIND_URL}/${t.provider_id}`,{method:"DELETE",withCredentials:!0})}async checkPassword(t){return this.config.request(`${i.CHECK_PWD_URL}`,{method:"POST",withCredentials:!0,body:t})}async editContact(t){return this.config.request(`${i.BIND_CONTACT_URL}`,{method:"PATCH",withCredentials:!0,body:t})}async setPassword(t){return this.config.request(`${i.AUTH_SET_PASSWORD}`,{method:"PATCH",withCredentials:!0,body:t})}async updatePasswordByOld(t){const e=await this.sudo({password:t.old_password});return this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})}async sudo(t){return this.config.request(`${i.SUDO_URL}`,{method:"POST",withCredentials:!0,body:t})}async sendVerificationCodeToCurrentUser(t){return t.target="CUR_USER",this.config.request(i.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}async changeBoundProvider(t){return this.config.request(`${i.PROVIDER_LIST}/${t.provider_id}/trans`,{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}async setUserProfile(t){return this.config.request(i.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}async updateUserBasicInfo(t){return this.config.request(i.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}async queryUserProfile(t){const e=new URLSearchParams(t);return this.config.request(`${i.USER_QUERY_URL}?${e.toString()}`,{method:"GET",withCredentials:!0})}setCustomSignFunc(t){this.getCustomSignTicketFn=t}async signInWithCustomTicket(t){const e=this.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});const r=await e();return this.signInWithProvider({...t,provider_id:"custom",provider_token:r})}async resetPassword(t){return this.config.request(i.AUTH_RESET_PASSWORD,{method:"POST",body:t})}async authorize(t){return this.config.request(i.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}async authorizeDevice(t){return this.config.request(i.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}async deviceAuthorize(t){return this.config.request(i.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}async authorizeInfo(t){const e=`${i.AUTHORIZE_INFO_URL}?${A.parseParamsToSearch(t)}`;let r=!0,s=!1;return await this.hasLoginState()&&(s=!0,r=!1),this.config.request(e,{method:"GET",withBasicAuth:r,withCredentials:s})}async checkUsername(t){return this.config.request(i.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}async checkIfUserExist(t){const e=new URLSearchParams(t);return this.config.request(`${i.CHECK_IF_USER_EXIST}?${e.toString()}`,{method:"GET"})}async loginScope(){return this.config.credentialsClient.getScope()}async loginGroups(){return this.config.credentialsClient.getGroups()}async refreshTokenForce(t){const e=await this.config.credentialsClient.getCredentials();return await this.config.credentialsClient.refreshToken({...e,version:t?.version||"v1"})}async getCredentials(){return this.config.credentialsClient.getCredentials()}async getPublicKey(){return this.config.request(s.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}async getEncryptParams(t){const{isEncrypt:e}=t;delete t.isEncrypt;const r=(0,l.I)(t),i=C(e);if(!i)return t;let s="",n="";try{const t=await this.getPublicKey();s=t.public_key,n=t.public_key_thumbprint}catch(t){}if(!s||!n)throw new Error("public_key or public_key_thumbprint is empty");return{params:i.getEncryptInfo({publicKey:s,payload:r}),public_key_thumbprint:n}}async getProviderSubType(){return this.config.request(i.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}async verifyCaptchaData({token:t,key:e}){return this.config.request(i.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:e},withCredentials:!1})}async createCaptchaData({state:t,redirect_uri:e}){return this.config.request(i.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:e},withCredentials:!1})}async getMiniProgramCode(t){return this.config.request(i.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}async getMiniProgramQrCodeStatus(t){return this.config.request(i.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}async getUserBehaviorLog(t){const e=`${i.GET_USER_BEHAVIOR_LOG}?${{LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[t.type]}&limit=${t.limit}${t.page_token?`&page_token=${t.page_token}`:""}`;return this.config.request(e,{method:"GET",withCredentials:!0})}async modifyPassword(t){let e="",r="";const s=C(!0);if(!s)throw new Error("do not support encrypt, a encrypt util required.");try{const t=await this.getPublicKey();e=t.public_key,r=t.public_key_thumbprint}catch(t){}if(!e||!r)throw new Error("public_key or public_key_thumbprint is empty");const n=t.password?s.getEncryptInfo({publicKey:e,payload:t.password}):"",o=s.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(i.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:n,encrypt_new_password:o,public_key_thumbprint:r}})}async modifyPasswordWithoutLogin(t){let e="",r="";const i=C(!0);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{const t=await this.getPublicKey();e=t.public_key,r=t.public_key_thumbprint}catch(t){}if(!e||!r)throw new Error("public_key or public_key_thumbprint is empty");const n=t.password?i.getEncryptInfo({publicKey:e,payload:t.password}):"",o=i.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(s.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:n,new_password:o,public_key_thumbprint:r}})}}class O{constructor(t){const{apiOrigin:e,clientId:r,env:i,storage:s,request:n,baseRequest:o,anonymousSignInFunc:a,wxCloud:h}=t;this.oauth2client=new E({apiOrigin:e,clientId:r,env:i,storage:s,baseRequest:o||n,anonymousSignInFunc:a,wxCloud:h}),this.authApi=new A({credentialsClient:this.oauth2client,...t,request:n?this.oauth2client.request.bind(this.oauth2client):void 0})}}},443:(t,e,r)=>{let i;if(r.r(e),r.d(e,{getEncryptInfo:()=>P}),!globalThis.IS_MP_BUILD){const N="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;var s="0123456789abcdefghijklmnopqrstuvwxyz";function D(t){return s.charAt(t)}function L(t,e){return t&e}function x(t,e){return t|e}function k(t,e){return t^e}function q(t,e){return t&~e}function B(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function V(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function H(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=n.charAt(r>>6)+n.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=n.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=n.charAt(r>>2)+n.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function M(t){var e,r="",i=0,s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var o=n.indexOf(t.charAt(e));o<0||(0==i?(r+=D(o>>2),s=3&o,i=1):1==i?(r+=D(s<<2|o>>4),s=15&o,i=2):2==i?(r+=D(s),r+=D(o>>2),s=3&o,i=3):(r+=D(s<<2|o>>4),r+=D(15&o),i=0))}return 1==i&&(r+=D(s<<2)),r}var o,a,h={decode:function(t){var e;if(void 0===o){var r="0123456789ABCDEF";for(o={},e=0;e<16;++e)o[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)o[r.charAt(e)]=e;for(e=0;e<8;++e)o[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var i=[],s=0,n=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=o[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);s|=a,++n>=2?(i[i.length]=s,s=0,n=0):s<<=4}}if(n)throw new Error("Hex encoding incomplete: 4 bits missing");return i}},u={decode:function(t){var e;if(void 0===a){for(a=Object.create(null),e=0;e<64;++e)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)a["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],i=0,s=0;for(e=0;e<t.length;++e){var n=t.charAt(e);if("="==n)break;if(-1!=(n=a[n])){if(void 0===n)throw new Error("Illegal character at offset "+e);i|=n,++s>=4?(r[r.length]=i>>16,r[r.length]=i>>8&255,r[r.length]=255&i,i=0,s=0):i<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=i>>10;break;case 3:r[r.length]=i>>16,r[r.length]=i>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=u.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return u.decode(t)}},c=1e13;class G{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,i,s=this.buf,n=s.length;for(r=0;r<n;++r)(i=s[r]*t+e)<c?e=0:i-=(e=0|i/c)*c,s[r]=i;e>0&&(s[r]=e)}sub(t){var e,r,i=this.buf,s=i.length;for(e=0;e<s;++e)(r=i[e]-t)<0?(r+=c,t=1):t=0,i[e]=r;for(;0===i[i.length-1];)i.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),i=e.length-2;i>=0;--i)r+=(c+e[i]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*c+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var l,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,f=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function F(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class ${constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof $?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var i="",s=t;s<e;++s)if(i+=this.hexByte(this.get(s)),!0!==r)switch(15&s){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i}isASCII(t,e){for(var r=t;r<e;++r){var i=this.get(r);if(i<32||i>176)return!1}return!0}parseStringISO(t,e){for(var r="",i=t;i<e;++i)r+=String.fromCharCode(this.get(i));return r}parseStringUTF(t,e){for(var r="",i=t;i<e;){var s=this.get(i++);r+=s<128?String.fromCharCode(s):s>191&&s<224?String.fromCharCode((31&s)<<6|63&this.get(i++)):String.fromCharCode((15&s)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return r}parseStringBMP(t,e){for(var r,i,s="",n=t;n<e;)r=this.get(n++),i=this.get(n++),s+=String.fromCharCode(r<<8|i);return s}parseTime(t,e,r){var i=this.parseStringISO(t,e),s=(r?d:f).exec(i);return s?(r&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),i=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(i+=":"+s[5],s[6]&&(i+=":"+s[6],s[7]&&(i+="."+s[7]))),s[8]&&(i+=" UTC","Z"!=s[8]&&(i+=s[8],s[9]&&(i+=":"+s[9]))),i):"Unrecognized time: "+i}parseInteger(t,e){for(var r,i=this.get(t),s=i>127,n=s?255:0,o="";i==n&&++t<e;)i=this.get(t);if(0==(r=e-t))return s?-1:0;if(r>4){for(o=i,r<<=3;!(128&(+o^n));)o=+o<<1,--r;o="("+r+" bit)\n"}s&&(i-=256);for(var a=new G(i),h=t+1;h<e;++h)a.mulAdd(256,this.get(h));return o+a.toString()}parseBitString(t,e,r){for(var i=this.get(t),s="("+((e-t-1<<3)-i)+" bit)\n",n="",o=t+1;o<e;++o){for(var a=this.get(o),h=o==e-1?i:0,u=7;u>=h;--u)n+=a>>u&1?"1":"0";if(n.length>r)return s+F(n,r)}return s+n}parseOctetString(t,e,r){if(this.isASCII(t,e))return F(this.parseStringISO(t,e),r);var i=e-t,s="("+i+" byte)\n";i>(r/=2)&&(e=t+r);for(var n=t;n<e;++n)s+=this.hexByte(this.get(n));return i>r&&(s+="…"),s}parseOID(t,e,r){for(var i="",s=new G,n=0,o=t;o<e;++o){var a=this.get(o);if(s.mulAdd(128,127&a),n+=7,!(128&a)){if(""===i)if((s=s.simplify())instanceof G)s.sub(80),i="2."+s.toString();else{var h=s<80?s<40?0:1:2;i=h+"."+(s-40*h)}else i+="."+s.toString();if(i.length>r)return F(i,r);s=new G,n=0}}return n>0&&(i+=".incomplete"),i}}class K{constructor(t,e,r,i,s){if(!(i instanceof W))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=i,this.sub=s}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return F(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return F(this.stream.parseStringISO(e,e+r),t);case 30:return F(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,i=this.sub.length;r<i;++r)e+=this.sub[r].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var i=0;i<r;++i)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof $?t:new $(t,0);var r=new $(e),i=new W(e),s=K.decodeLength(e),n=e.pos,o=n-r.pos,a=null,h=function(){var t=[];if(null!==s){for(var r=n+s;e.pos<r;)t[t.length]=K.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+n)}else try{for(;;){var i=K.decode(e);if(i.tag.isEOC())break;t[t.length]=i}s=n-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(i.tagConstructed)a=h();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=h();for(var u=0;u<a.length;++u)if(a[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+n);e.pos=n+Math.abs(s)}return new K(r,o,s,i,a)}}class W{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new G;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],g=(1<<26)/p[p.length-1];class j{constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,s=!1,n="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(s=!0,n=D(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&i,a<=0&&(a+=this.DB,--o)),r>0&&(s=!0),s&&(n+=D(r));return s?n:"0"}negate(){var t=Y();return j.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+et(this[this.t-1]^this.s&this.DM)}mod(t){var e=Y();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(j.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new _(e):new y(e),this.exp(t,r)}clone(){var t=Y();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var r,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=Y();return this.bitwiseTo(t,L,e),e}or(t){var e=Y();return this.bitwiseTo(t,x,e),e}xor(t){var e=Y();return this.bitwiseTo(t,k,e),e}andNot(t){var e=Y();return this.bitwiseTo(t,q,e),e}not(){for(var t=Y(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=Y();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=Y();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+B(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=V(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,x)}clearBit(t){return this.changeBit(t,q)}flipBit(t){return this.changeBit(t,k)}add(t){var e=Y();return this.addTo(t,e),e}subtract(t){var e=Y();return this.subTo(t,e),e}multiply(t){var e=Y();return this.multiplyTo(t,e),e}divide(t){var e=Y();return this.divRemTo(t,e,null),e}remainder(t){var e=Y();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=Y(),r=Y();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,i,s=t.bitLength(),n=tt(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new _(e):e.isEven()?new v(e):new y(e);var o=[],a=3,h=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var c=Y();for(i.sqrTo(o[1],c);a<=u;)o[a]=Y(),i.mulTo(c,o[a-2],o[a]),a+=2}var l,d,f=t.t-1,p=!0,g=Y();for(s=et(t[f])-1;f>=0;){for(s>=h?l=t[f]>>s-h&u:(l=(t[f]&(1<<s+1)-1)<<h-s,f>0&&(l|=t[f-1]>>this.DB+s-h)),a=r;!(1&l);)l>>=1,--a;if((s-=a)<0&&(s+=this.DB,--f),p)o[l].copyTo(n),p=!1;else{for(;a>1;)i.sqrTo(n,g),i.sqrTo(g,n),a-=2;a>0?i.sqrTo(n,g):(d=n,n=g,g=d),i.mulTo(g,o[l],n)}for(;f>=0&&!(t[f]&1<<s);)i.sqrTo(n,g),d=n,n=g,g=d,--s<0&&(s=this.DB-1,--f)}return i.revert(n)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return j.ZERO;for(var r=t.clone(),i=this.clone(),s=tt(1),n=tt(0),o=tt(0),a=tt(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(o,s),n.subTo(a,n)):(i.subTo(r,i),e&&o.subTo(s,o),a.subTo(n,a))}return 0!=i.compareTo(j.ONE)?j.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new m)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=p[p.length-1]){for(e=0;e<p.length;++e)if(r[0]==p[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<p.length;){for(var i=p[e],s=e+1;s<p.length&&i<g;)i*=p[s++];for(i=r.modInt(i);e<s;)if(i%p[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,n=0;--i>=0;){var o=8==r?255&+t[i]:X(t,i);o<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=o:n+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-n)-1)<<n,this[this.t++]=o>>this.DB-n):this[this.t-1]|=o<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&128&+t[0]&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&j.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,i=this.DB-r,s=(1<<i)-1,n=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+n+1]=this[a]>>i|o,o=(this[a]&s)<<r;for(a=n-1;a>=0;--a)e[a]=0;e[n]=o,e.t=this.t+n+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&n)<<s,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&j.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Y());var n=Y(),o=this.s,a=t.s,h=this.DB-et(i[i.t-1]);h>0?(i.lShiftTo(h,n),s.lShiftTo(h,r)):(i.copyTo(n),s.copyTo(r));var u=n.t,c=n[u-1];if(0!=c){var l=c*(1<<this.F1)+(u>1?n[u-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,p=1<<this.F2,g=r.t,m=g-u,_=null==e?Y():e;for(n.dlShiftTo(m,_),r.compareTo(_)>=0&&(r[r.t++]=1,r.subTo(_,r)),j.ONE.dlShiftTo(u,_),_.subTo(n,n);n.t<u;)n[n.t++]=0;for(;--m>=0;){var y=r[--g]==c?this.DM:Math.floor(r[g]*d+(r[g-1]+p)*f);if((r[g]+=n.am(0,y,r,m,0,u))<y)for(n.dlShiftTo(m,_),r.subTo(_,r);r[g]<--y;)r.subTo(_,r)}null!=e&&(r.drShiftTo(u,e),o!=a&&j.ZERO.subTo(e,e)),r.t=u,r.clamp(),h>0&&r.rShiftTo(h,r),o<0&&j.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return j.ONE;var r=Y(),i=Y(),s=e.convert(this),n=et(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var o=r;r=i,i=o}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=tt(r),s=Y(),n=Y(),o="";for(this.divRemTo(i,s,n);s.signum()>0;)o=(r+n.intValue()).toString(t).substr(1)+o,s.divRemTo(i,s,n);return n.intValue().toString(t)+o}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,o=0,a=0;a<t.length;++a){var h=X(t,a);h<0?"-"==t.charAt(a)&&0==this.signum()&&(s=!0):(o=e*o+h,++n>=r&&(this.dMultiply(i),this.dAddOffset(o,0),n=0,o=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(o,0)),s&&j.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(j.ONE.shiftLeft(t-1),x,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(j.ONE.shiftLeft(t-1),this);else{var i=[],s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}}bitwiseTo(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=j.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(var s=r.t-this.t;i<s;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(s=Math.min(t.t,e);i<s;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()}multiplyUpperTo(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r}millerRabin(t){var e=this.subtract(j.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>p.length&&(t=p.length);for(var s=Y(),n=0;n<t;++n){s.fromInt(p[Math.floor(Math.random()*p.length)]);var o=s.modPow(i,this);if(0!=o.compareTo(j.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(j.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0}square(){var t=Y();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(r.compareTo(i)<0){var s=r;r=i,i=s}var n=r.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)e(r);else{n<o&&(o=n),o>0&&(r.rShiftTo(o,r),i.rShiftTo(o,i));var a=()=>{(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),r.compareTo(i)>=0?(r.subTo(i,r),r.rShiftTo(1,r)):(i.subTo(r,i),i.rShiftTo(1,i)),r.signum()>0?setTimeout(a,0):(o>0&&i.lShiftTo(o,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,i){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(j.ONE.shiftLeft(t-1),x,this),this.isEven()&&this.dAddOffset(1,0);var s=this,n=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(j.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout((function(){i()}),0):setTimeout(n,0)};setTimeout(n,0)}else{var o=[],a=7&t;o.length=1+(t>>3),e.nextBytes(o),a>0?o[0]&=(1<<a)-1:o[0]=0,this.fromString(o,256)}}}var m=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),_=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),y=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=Y();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(j.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=Y();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),v=function(){function t(t){this.m=t,this.r2=Y(),this.q3=Y(),j.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=Y();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function Y(){return new j(null)}function z(t,e){return new j(t,e)}function Z(t,e,r,i,s,n){for(;--n>=0;){var o=e*this[t++]+r[i]+s;s=Math.floor(o/67108864),r[i++]=67108863&o}return s}function Q(t,e,r,i,s,n){for(var o=32767&e,a=e>>15;--n>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;s=((h=o*h+((32767&c)<<15)+r[i]+(1073741823&s))>>>30)+(c>>>15)+a*u+(s>>>30),r[i++]=1073741823&h}return s}function J(t,e,r,i,s,n){for(var o=16383&e,a=e>>14;--n>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;s=((h=o*h+((16383&c)<<14)+r[i]+s)>>28)+(c>>14)+a*u,r[i++]=268435455&h}return s}void 0!==N&&"Microsoft Internet Explorer"==N?.appName?(j.prototype.am=Q,l=30):"Netscape"!=N?.appName?(j.prototype.am=Z,l=26):(j.prototype.am=J,l=28),j.prototype.DB=l,j.prototype.DM=(1<<l)-1,j.prototype.DV=1<<l,j.prototype.FV=Math.pow(2,52),j.prototype.F1=52-l,j.prototype.F2=2*l-52;var T,E,S=[];for(T="0".charCodeAt(0),E=0;E<=9;++E)S[T++]=E;for(T="a".charCodeAt(0),E=10;E<36;++E)S[T++]=E;for(T="A".charCodeAt(0),E=10;E<36;++E)S[T++]=E;function X(t,e){var r=S[t.charCodeAt(e)];return null==r?-1:r}function tt(t){var e=Y();return e.fromInt(t),e}function et(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}j.ZERO=tt(0),j.ONE=tt(1);class rt{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var w,R,I=null;if(null==I){I=[],R=0;var b=void 0;if(window?.crypto&&window?.crypto.getRandomValues){var C=new Uint32Array(256);for(window?.crypto.getRandomValues(C),b=0;b<C.length;++b)I[R++]=255&C[b]}var A=function(t){if(this.count=this.count||0,this.count>=256||R>=256)window?.removeEventListener?window?.removeEventListener("mousemove",A,!1):window?.detachEvent&&window?.detachEvent("onmousemove",A);else try{var e=t.x+t.y;I[R++]=255&e,this.count+=1}catch(t){}};window?.addEventListener?window?.addEventListener("mousemove",A,!1):window?.attachEvent&&window?.attachEvent("onmousemove",A)}function it(){if(null==w){for(w=new rt;R<256;){var t=Math.floor(65536*Math.random());I[R++]=255&t}for(w.init(I),R=0;R<I.length;++R)I[R]=0;R=0}return w.next()}class st{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=it()}}function nt(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],i=t.length-1;i>=0&&e>0;){var s=t.charCodeAt(i--);s<128?r[--e]=s:s>127&&s<2048?(r[--e]=63&s|128,r[--e]=s>>6|192):(r[--e]=63&s|128,r[--e]=s>>6&63|128,r[--e]=s>>12|224)}r[--e]=0;for(var n=new st,o=[];e>2;){for(o[0]=0;0==o[0];)n.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new j(r)}class ot{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=z(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=nt(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var i=r.toString(16);return 1&i.length?"0"+i:i}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var i="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);i+=r})),H(i)):H(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=M(t);try{if(t.length>r){var i="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);i+=r})),i}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=z(t,16),this.e=parseInt(e,16),this.d=z(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,i,s,n,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=z(t,16),this.e=parseInt(e,16),this.d=z(r,16),this.p=z(i,16),this.q=z(s,16),this.dmp1=z(n,16),this.dmq1=z(o,16),this.coeff=z(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new st,i=t>>1;this.e=parseInt(e,16);for(var s=new j(e,16);;){for(;this.p=new j(t-i,1,r),0!=this.p.subtract(j.ONE).gcd(s).compareTo(j.ONE)||!this.p.isProbablePrime(10););for(;this.q=new j(i,1,r),0!=this.q.subtract(j.ONE).gcd(s).compareTo(j.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var n=this.p;this.p=this.q,this.q=n}var o=this.p.subtract(j.ONE),a=this.q.subtract(j.ONE),h=o.multiply(a);if(0==h.gcd(s).compareTo(j.ONE)){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=z(t,16),r=this.doPrivate(e);return null==r?null:at(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var i=new st,s=t>>1;this.e=parseInt(e,16);var n=new j(e,16),o=this,a=()=>{var e=()=>{if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(j.ONE),i=o.q.subtract(j.ONE),s=e.multiply(i);0==s.gcd(n).compareTo(j.ONE)?(o.n=o.p.multiply(o.q),o.d=n.modInverse(s),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(i),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},h=()=>{o.q=Y(),o.q.fromNumberAsync(s,1,i,(function(){o.q.subtract(j.ONE).gcda(n,(function(t){0==t.compareTo(j.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=()=>{o.p=Y(),o.p.fromNumberAsync(t-s,1,i,(function(){o.p.subtract(j.ONE).gcda(n,(function(t){0==t.compareTo(j.ONE)&&o.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)}}function at(t,e){for(var r=t.toByteArray(),i=0;i<r.length&&0==r[i];)++i;if(r.length-i!=e-1||2!=r[i])return null;for(++i;0!=r[i];)if(++i>=r.length)return null;for(var s="";++i<r.length;){var n=255&r[i];n<128?s+=String.fromCharCode(n):n>191&&n<224?(s+=String.fromCharCode((31&n)<<6|63&r[i+1]),++i):(s+=String.fromCharCode((15&n)<<12|(63&r[i+1])<<6|63&r[i+2]),i+=2)}return s}class ht extends ot{constructor(t=""){super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?h.decode(t):u.unarmor(t),s=K.decode(i);if(3===s.sub.length&&(s=s.sub[2].sub[0]),9===s.sub.length){e=s.sub[1].getHexStringValue(),this.n=z(e,16),r=s.sub[2].getHexStringValue(),this.e=parseInt(r,16);var n=s.sub[3].getHexStringValue();this.d=z(n,16);var o=s.sub[4].getHexStringValue();this.p=z(o,16);var a=s.sub[5].getHexStringValue();this.q=z(a,16);var c=s.sub[6].getHexStringValue();this.dmp1=z(c,16);var l=s.sub[7].getHexStringValue();this.dmq1=z(l,16);var d=s.sub[8].getHexStringValue();this.coeff=z(d,16)}else{if(2!==s.sub.length)return!1;var f=s.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=z(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}i=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null},i.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ht(t)},i.prototype.setPrivateKey=function(t){this.setKey(t)},i.prototype.setPublicKey=function(t){this.setKey(t)},i.prototype.decrypt=function(t){try{return this.getKey().decrypt(M(t))}catch(t){return!1}},i.prototype.encrypt=function(t){try{return H(this.getKey().encrypt(t))}catch(t){return!1}},i.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",i=0,s=/null$/g;s.test(r)&&(i++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(i>10)););return e}catch(t){return!1}},i.prototype.getKey=function(t){if(!this.key){if(this.key=new ht,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},i.version="3.1.4"}const O=i;var U=r(479);const P=({publicKey:t="",payload:e={}}={})=>{if(!t)return"";try{const r=(0,U.I)(e),i=new O;return i.setPublicKey(t),i.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){console.error("encrypt error:",t)}return""}},479:(t,e,r)=>{r.d(e,{I:()=>i,y:()=>s});const i=t=>{const e=e=>{for(const r in t)t.hasOwnProperty(r)&&(e[r]=i(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},s=t=>{const e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},118:function(t,e,r){var i=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),s=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||i(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),s(r(256),e)}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(118)})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_oauth",[],e):"object"==typeof exports?exports.cloudbase_oauth=e():t.cloudbase_oauth=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={746:(t,e,r)=>{r.r(e),r.d(e,{Auth:()=>O,CloudbaseOAuth:()=>U,authModels:()=>u});var i,s,n,o,a,h,u={};function c(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.r(u),function(t){t.AUTH_SIGN_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.WEDA_USER_URL="/auth/v1/plugin/weda/userinfo",t.AUTH_RESET_PASSWORD="/auth/v1/reset",t.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",t.CHECK_USERNAME="/auth/v1/checkUsername",t.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/auth/v1/mgr/provider/providerSubType",t.AUTH_SIGN_IN_URL="/auth/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/auth/v1/signin/wechat/noauth",t.PROVIDER_TOKEN_URL="/auth/v1/provider/token",t.PROVIDER_URI_URL="/auth/v1/provider/uri",t.USER_ME_URL="/auth/v1/user/me",t.AUTH_SIGNOUT_URL="/auth/v1/user/signout",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_BASIC_EDIT_URL="/auth/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.PROVIDER_LIST="/auth/v1/user/provider",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",t.PROVIDER_UNBIND_URL="/auth/v1/user/provider",t.CHECK_PWD_URL="/auth/v1/user/sudo",t.SUDO_URL="/auth/v1/user/sudo",t.BIND_CONTACT_URL="/auth/v1/user/contact",t.AUTH_SET_PASSWORD="/auth/v1/user/password",t.AUTHORIZE_DEVICE_URL="/auth/v1/user/device/authorize",t.AUTHORIZE_URL="/auth/v1/user/authorize",t.AUTHORIZE_INFO_URL="/auth/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/auth/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/auth/v1/user/revoke/all",t.GET_USER_BEHAVIOR_LOG="/auth/v1/user/security/history",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.CAPTCHA_DATA_URL="/auth/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/auth/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/auth/v1/captcha/init",t.GET_MINIPROGRAM_QRCODE="/auth/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/auth/v1/qrcode/get/status"}(i||(i={})),function(t){t.AUTH_SIGN_IN_URL="/auth/v2/signin/username",t.AUTH_TOKEN_URL="/auth/v2/token",t.USER_ME_URL="/auth/v2/user/me",t.VERIFY_URL="/auth/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/auth/v2/signin/publichkey",t.AUTH_RESET_PASSWORD="/auth/v2/signin/password/update"}(s||(s={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(n||(n={})),(h=o||(o={})).UNREACHABLE="unreachable",h.LOCAL="local",h.CANCELLED="cancelled",h.UNKNOWN="unknown",h.UNAUTHENTICATED="unauthenticated",h.RESOURCE_EXHAUSTED="resource_exhausted",h.FAILED_PRECONDITION="failed_precondition",h.INVALID_ARGUMENT="invalid_argument",h.DEADLINE_EXCEEDED="deadline_exceeded",h.NOT_FOUND="not_found",h.ALREADY_EXISTS="already_exists",h.PERMISSION_DENIED="permission_denied",h.ABORTED="aborted",h.OUT_OF_RANGE="out_of_range",h.UNIMPLEMENTED="unimplemented",h.INTERNAL="internal",h.UNAVAILABLE="unavailable",h.DATA_LOSS="data_loss",h.INVALID_PASSWORD="invalid_password",h.PASSWORD_NOT_SET="password_not_set",h.INVALID_STATUS="invalid_status",h.USER_PENDING="user_pending",h.USER_BLOCKED="user_blocked",h.INVALID_VERIFICATION_CODE="invalid_verification_code",h.TWO_FACTOR_REQUIRED="two_factor_required",h.INVALID_TWO_FACTOR="invalid_two_factor",h.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",h.UNDER_REVIEW="under_review",h.INVALID_REQUEST="invalid_request",h.UNAUTHORIZED_CLIENT="unauthorized_client",h.ACCESS_DENIED="access_denied",h.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",h.INVALID_SCOPE="invalid_scope",h.INVALID_GRANT="invalid_grant",h.SERVER_ERROR="server_error",h.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",h.INTERACTION_REQUIRED="interaction_required",h.LOGIN_REQUIRED="login_required",h.ACCOUNT_SELECTION_REQUIRED="account_selection_required",h.CONSENT_REQUIRED="consent_required",h.INVALID_REQUEST_URI="invalid_request_uri",h.INVALID_REQUEST_OBJECT="invalid_request_object",h.REQUEST_NOT_SUPPORTED="request_not_supported",h.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",h.REGISTRATION_NOT_SUPPORTED="registration_not_supported",h.CAPTCHA_REQUIRED="captcha_required",h.CAPTCHA_INVALID="captcha_invalid",function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(a||(a={}));var l=r(479);class d{constructor(){this.fnPromiseMap=new Map}async run(t,e){let r=this.fnPromiseMap.get(t);return await r||(r=new Promise(((r,i)=>{(async()=>{try{await this.runIdlePromise();const t=e();r(await t)}catch(t){i(t)}finally{this.fnPromiseMap.delete(t)}})()})),this.fnPromiseMap.set(t,r)),r}runIdlePromise(){return Promise.resolve()}}const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p="x-request-id",g="x-device-id",m="device_id",y=async function(t,e){let r=null,i=null;try{const s=Object.assign({},e);s.method||(s.method="GET"),s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));const n=await fetch(t,s),o=await n.json();o?.error?(i=o,i.error_uri=new URL(t).pathname):r=o}catch(e){i={error:o.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(i)throw i;return r},_=new class{constructor(t){this._env=t?.env||""}async getItem(t){return window.localStorage.getItem(`${t}${this._env}`)}async removeItem(t){window.localStorage.removeItem(`${t}${this._env}`)}async setItem(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}getItemSync(t){return window.localStorage.getItem(`${t}${this._env}`)}removeItemSync(t){window.localStorage.removeItem(`${t}${this._env}`)}setItemSync(t,e){window.localStorage.setItem(`${t}${this._env}`,e)}};function v(t){let e=!0;return t?.expires_at&&t?.access_token&&(e=t.expires_at<new Date),e}class T{constructor(t){this.credentials=null,this.singlePromise=new d,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}getStorageCredentialsSync(){let t=null;const e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t}async setCredentials(t){if(t?.expires_in){if(t?.expires_at||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),this.storage){const e=JSON.stringify(t);await this.storage.setItem(this.tokenSectionName,e)}this.credentials=t}else this.storage&&await this.storage.removeItem(this.tokenSectionName),this.credentials=null}async getCredentials(){return this.singlePromise.run("getCredentials",(async()=>(v(this.credentials)&&(this.credentials=await this.getStorageCredentials()),this.credentials)))}async getStorageCredentials(){return this.singlePromise.run("_getStorageCredentials",(async()=>{let t=null;const e=await this.storage.getItem(this.tokenSectionName);if(null!=e)try{t=JSON.parse(e),t?.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){await this.storage.removeItem(this.tokenSectionName),t=null}return t}))}}class E{constructor(t){this.singlePromise=new d,t.clientSecret||(t.clientSecret=""),!t.clientId&&t.env&&(t.clientId=t.env),this.apiOrigin=t.apiOrigin,this.clientId=t.clientId,this.retry=this.formatRetry(t.retry,E.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=y,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||_,this.localCredentials=new T({tokenSectionName:`credentials_${t.clientId}`,storage:this.storage}),this.clientSecret=t.clientSecret,t.clientId&&(this.basicAuth=`Basic ${function(t){let e,r,i,s,n="",o=0;const a=(t=String(t)).length%3;for(;o<t.length;){if((r=t.charCodeAt(o++))>255||(i=t.charCodeAt(o++))>255||(s=t.charCodeAt(o++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");e=r<<16|i<<8|s,n+=f.charAt(e>>18&63)+f.charAt(e>>12&63)+f.charAt(e>>6&63)+f.charAt(63&e)}return a?n.slice(0,a-3)+"===".substring(a):n}(`${t.clientId}:${this.clientSecret}`)}`),this.wxCloud=t.wxCloud;try{(function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0})()&&void 0===this.wxCloud&&t.env&&(wx.cloud.init({env:t.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc}setCredentials(t){return this.localCredentials.setCredentials(t)}async getAccessToken(){const t=await this.getCredentials();if(t?.access_token)return Promise.resolve(t.access_token);const e={error:o.UNAUTHENTICATED};return Promise.reject(e)}async request(t,e){e||(e={});const r=this.formatRetry(e.retry,this.retry);if(e.headers=e.headers||{},this.headers&&(e.headers={...this.headers,...e.headers}),e.headers[p]||(e.headers[p]=c()),!e.headers[g]){const t=await this.getDeviceId();e.headers[g]=t}if(e?.withBasicAuth&&this.basicAuth&&(e.headers.Authorization=this.basicAuth),e?.withCredentials){const r=await this.getCredentials();r&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+=`access_token=${r.access_token}`):e.headers.Authorization=`${r.token_type} ${r.access_token}`)}else this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+=`client_id=${this.clientId}`);t.startsWith("/")&&(t=this.apiOrigin+t);let i=null;const s=r+1;for(let n=0;n<s;n++){try{i=e.useWxCloud?await this.wxCloudCallFunction(t,e):await this.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===o.UNAUTHENTICATED)return await this.setCredentials(null),Promise.reject(t);if(n===r||!t||"unreachable"!==t.error)return Promise.reject(t)}await this.sleep(E.retryInterval)}return i}async wxCloudCallFunction(t,e){let r=null,i=null;try{let s="";try{s=await wx.getRendererUserAgent()}catch(t){}const{result:n}=await this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:{origin:"https://servicewechat.com","User-Agent":s,...e.headers},body:e.body}});n?.body?.error_code?(i=n?.body,i.error_uri=(0,l.y)(t)):r=n?.body}catch(e){i={error:o.UNREACHABLE,error_description:e.message,error_uri:(0,l.y)(t)}}if(i)throw i;return r}async getCredentials(){let t=await this.localCredentials.getCredentials();return t?(v(t)&&(t=t&&"anonymous"===t.scope?this.anonymousSignInFunc?await this.anonymousSignInFunc(t)||await this.localCredentials.getCredentials():await this.anonymousSignIn(t):await this.refreshToken(t)),t):this.unAuthenticatedError("credentials not found")}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}async getScope(){const t=await this.localCredentials.getCredentials();return t?t.scope:this.unAuthenticatedError("credentials not found")}async getGroups(){const t=await this.localCredentials.getCredentials();return t?t.groups:this.unAuthenticatedError("credentials not found")}async refreshToken(t){return this.singlePromise.run("_refreshToken",(async()=>{if(!t||!t.refresh_token)return this.unAuthenticatedError("no refresh token found in credentials");try{const e=await this.refreshTokenFunc(t.refresh_token,t);return await this.localCredentials.setCredentials(e),e}catch(t){return t.error===o.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}checkRetry(t){let e=null;if(("number"!=typeof t||t<E.minRetry||t>E.maxRetry)&&(e={error:o.UNREACHABLE,error_description:"wrong options param: retry"}),e)throw e;return t}formatRetry(t,e){return void 0===t?e:this.checkRetry(t)}async sleep(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}async anonymousSignIn(t){return this.singlePromise.run("_anonymous",(async()=>{if(!t||"anonymous"!==t.scope)return this.unAuthenticatedError("no anonymous in credentials");try{const t=await this.request(i.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return await this.localCredentials.setCredentials(t),t}catch(t){return t.error===o.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(t.error_description)):Promise.reject(t)}}))}async defaultRefreshTokenFunc(t,e){if(void 0===t||""===t)return this.unAuthenticatedError("refresh token not found");let r=i.AUTH_TOKEN_URL;return"v2"===e?.version&&(r=s.AUTH_TOKEN_URL),{...await this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}}),version:e?.version||"v1"}}async getDeviceId(){if(this.deviceID)return this.deviceID;let t=await this.storage.getItem(m);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=c(),await this.storage.setItem(m,t)),this.deviceID=t,t}unAuthenticatedError(t){const e={error:o.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function S(){const{wx:t}=globalThis;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getSystemInfoSync)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getSystemInfoSync())return!1;if("qq"===t.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0}E.defaultRetry=2,E.minRetry=0,E.maxRetry=5,E.retryInterval=1e3;let w=!1;function I(){w=w||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{S()||(w=w||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?I():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",I,!1))}catch(t){}function b(){return w}const R=class{constructor(t){if(this.params={},"string"==typeof t)this.parse(t);else if(t&&"object"==typeof t)for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.append(e,t[e])}parse(t){t.split("&").forEach((t=>{const[e,r]=t.split("=").map(decodeURIComponent);this.append(e,r)}))}append(t,e){this.params[t]?this.params[t]=this.params[t].concat([e]):this.params[t]=[e]}get(t){return this.params[t]?this.params[t][0]:null}getAll(t){return this.params[t]||[]}delete(t){delete this.params[t]}has(t){return Object.prototype.hasOwnProperty.call(this.params,t)}set(t,e){this.params[t]=[e]}toString(){const t=[];for(const e in this.params)Object.prototype.hasOwnProperty.call(this.params,e)&&this.params[e].forEach((r=>{t.push(`${encodeURIComponent(e)}=${encodeURIComponent(r)}`)}));return t.join("&")}};class C{constructor(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=_),this.config=t,this.tokenSectionName=`captcha_${t.clientId}`}async request(t,e){e||(e={}),e.method||(e.method="GET");const r=`${e.method}:${t}`;let i,s=t;e.withCaptcha&&(s=await this.appendCaptchaTokenToURL(t,r,!1));try{i=await this.config.request(s,e)}catch(i){return i.error===o.CAPTCHA_REQUIRED||i.error===o.CAPTCHA_INVALID?(t=await this.appendCaptchaTokenToURL(t,r,i.error===o.CAPTCHA_INVALID),this.config.request(t,e)):Promise.reject(i)}return i}getDefaultOpenURIWithCallback(){if(!S()&&!b()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){const t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((()=>{document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback}async defaultOpenURIWithCallback(t,e){const{width:r="355px",height:i="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:o.UNIMPLEMENTED,error_description:"need to impl captcha data"});const s=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe");return s.innerHTML="",n.setAttribute("src",t),n.setAttribute("id","review-panel-iframe"),n.style.cssText=`min-width:${r};display:block;height:${i};margin:0 auto;background-color: rgb(255, 255, 255);border: none;`,s.appendChild(n),s.style.display="block",new Promise(((t,e)=>{n.onload=function(){try{const r=window.location,i=n.contentWindow.location;if(i.host+i.pathname===r.host+r.pathname){s.style.display="none";const r=new R(i.search),n=r.get("captcha_token");return n?t({captcha_token:n,expires_in:Number(r.get("expires_in"))}):e({error:r.get("error"),error_description:r.get("error_description")})}s.style.display="block"}catch(t){s.style.display="block"}}}))}async getCaptchaToken(t,e){if(!t){const t=await this.findCaptchaToken();if(t)return t}let r;if(S()||b()){const t=await this.config.request(i.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1});r={url:`${t.data}?state=${encodeURIComponent(e)}&token=${encodeURIComponent(t.token)}`}}else{const t=`${window.location.origin+window.location.pathname}?__captcha=on`;if(r=await this.config.request(i.GET_CAPTCHA_URL,{method:"POST",body:{client_id:this.config.clientId,redirect_uri:t,state:e},withCredentials:!1}),r.captcha_token){const t={captcha_token:r.captcha_token,expires_in:r.expires_in};return this.saveCaptchaToken(t),r.captcha_token}}const s=await this.config.openURIWithCallback(r.url);return this.saveCaptchaToken(s),s.captcha_token}async appendCaptchaTokenToURL(t,e,r){const i=await this.getCaptchaToken(r,e);return t.indexOf("?")>0?t+=`&captcha_token=${i}`:t+=`?captcha_token=${i}`,t}async saveCaptchaToken(t){t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10));const e=JSON.stringify(t);await this.config.storage.setItem(this.tokenSectionName,e)}async findCaptchaToken(){const t=await this.config.storage.getItem(this.tokenSectionName);if(null!=t)try{const e=JSON.parse(t);return e?.expires_at&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?null:e.captcha_token}catch(t){return await this.config.storage.removeItem(this.tokenSectionName),null}return null}}function A(t){if(!globalThis.IS_MP_BUILD&&t)return r(443)}class O{static parseParamsToSearch(t){return Object.keys(t).forEach((e=>{t[e]||delete t[e]})),new R(t).toString()}constructor(t){let{request:e}=t,r=t.credentialsClient;if(!r){const e={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud};r=new E(e)}if(!e){const i=r.request.bind(r),s=new C({clientId:t.clientId,request:i,storage:t.storage,...t.captchaOptions});e=s.request.bind(s)}this.config={env:t.env,apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||_}}getParamsByVersion(t,e){const r=(0,l.I)(t),n={v2:s}[r?.version]?.[e]||i[e];return r&&delete r.version,{params:r,url:n}}async signIn(t){const e=t.version||"v1",r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL");r.params.query&&delete r.params.query;const i=await this.getEncryptParams(r.params),s=await this.config.request(r.url,{method:"POST",body:i});return await this.config.credentialsClient.setCredentials({...s,version:e}),Promise.resolve(s)}async signInAnonymously(t={}){const e=await this.config.request(i.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signUp(t){const e=await this.config.request(i.AUTH_SIGN_UP_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async signOut(t){let e={};if(t){try{e=await this.config.request(i.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})}catch(t){t.error!==o.UNAUTHENTICATED&&console.log("sign_out_error",t)}return await this.config.credentialsClient.setCredentials(),e}const r=await this.config.credentialsClient.getAccessToken(),s=await this.config.request(i.AUTH_REVOKE_URL,{method:"POST",body:{token:r}});return await this.config.credentialsClient.setCredentials(),Promise.resolve(s)}async revokeAllDevices(){await this.config.request(i.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}async revokeDevice(t){await this.config.request(i.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})}async getVerification(t,e){let r=!1;return("CUR_USER"===t.target||await this.hasLoginState())&&(r=!0),this.config.request(i.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:e?.withCaptcha||!1,withCredentials:r})}async verify(t){const e=this.getParamsByVersion(t,"VERIFY_URL"),r=await this.config.request(e.url,{method:"POST",body:e.params});return"v2"===t?.version&&await this.config.credentialsClient.setCredentials({...r,version:"v2"}),r}async genProviderRedirectUri(t){const{provider_redirect_uri:e,other_params:r={},...s}=t;e&&!s.redirect_uri&&(s.redirect_uri=e);let n=`${i.PROVIDER_URI_URL}?${O.parseParamsToSearch(s)}`;return Object.keys(r).forEach((t=>{const e=r[t];("sign_out_uri"!==t||e?.length>0)&&(n+=`&other_params[${t}]=${encodeURIComponent(e)}`)})),this.config.request(n,{method:"GET"})}async grantProviderToken(t,e=!1){return this.config.request(i.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})}async patchProviderToken(t){return this.config.request(i.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}async signInWithProvider(t,e=!1){const r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),i=await this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e});return await this.config.credentialsClient.setCredentials({...i,version:t?.version||"v1"}),Promise.resolve(i)}async signInWithWechat(t={}){const e=await this.config.request(i.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t});return await this.config.credentialsClient.setCredentials(e),Promise.resolve(e)}async bindWithProvider(t){return this.config.request(i.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})}async getUserProfile(t){return this.getUserInfo(t)}async getUserInfo(t={}){const e=this.getParamsByVersion(t,"USER_ME_URL");if(e.params?.query){const t=new R(e.params.query);e.url+=`?${t.toString()}`}const r=await this.config.request(e.url,{method:"GET",withCredentials:!0});return r.sub&&(r.uid=r.sub),r}async getWedaUserInfo(){return await this.config.request(i.WEDA_USER_URL,{method:"GET",withCredentials:!0})}async deleteMe(t){const e=this.getParamsByVersion(t,"USER_ME_URL"),r=`${e.url}?${O.parseParamsToSearch(e.params)}`;return this.config.request(r,{method:"DELETE",withCredentials:!0})}async hasLoginState(){try{return await this.config.credentialsClient.getAccessToken(),!0}catch(t){return!1}}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}async getLoginState(){return this.config.credentialsClient.getCredentialsAsync()}async transByProvider(t){return this.config.request(i.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})}async grantToken(t){const e=this.getParamsByVersion(t,"AUTH_TOKEN_URL");return this.config.request(e.url,{method:"POST",body:e.params})}async getProviders(){return this.config.request(i.PROVIDER_LIST,{method:"GET",withCredentials:!0})}async unbindProvider(t){return this.config.request(`${i.PROVIDER_UNBIND_URL}/${t.provider_id}`,{method:"DELETE",withCredentials:!0})}async checkPassword(t){return this.config.request(`${i.CHECK_PWD_URL}`,{method:"POST",withCredentials:!0,body:t})}async editContact(t){return this.config.request(`${i.BIND_CONTACT_URL}`,{method:"PATCH",withCredentials:!0,body:t})}async setPassword(t){return this.config.request(`${i.AUTH_SET_PASSWORD}`,{method:"PATCH",withCredentials:!0,body:t})}async updatePasswordByOld(t){const e=await this.sudo({password:t.old_password});return this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})}async sudo(t){return this.config.request(`${i.SUDO_URL}`,{method:"POST",withCredentials:!0,body:t})}async sendVerificationCodeToCurrentUser(t){return t.target="CUR_USER",this.config.request(i.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}async changeBoundProvider(t){return this.config.request(`${i.PROVIDER_LIST}/${t.provider_id}/trans`,{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}async setUserProfile(t){return this.config.request(i.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}async updateUserBasicInfo(t){return this.config.request(i.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}async queryUserProfile(t){const e=new R(t);return this.config.request(`${i.USER_QUERY_URL}?${e.toString()}`,{method:"GET",withCredentials:!0})}setCustomSignFunc(t){this.getCustomSignTicketFn=t}async signInWithCustomTicket(t){const e=this.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});const r=await e();return this.signInWithProvider({...t,provider_id:"custom",provider_token:r})}async resetPassword(t){return this.config.request(i.AUTH_RESET_PASSWORD,{method:"POST",body:t})}async authorize(t){return this.config.request(i.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}async authorizeDevice(t){return this.config.request(i.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}async deviceAuthorize(t){return this.config.request(i.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}async authorizeInfo(t){const e=`${i.AUTHORIZE_INFO_URL}?${O.parseParamsToSearch(t)}`;let r=!0,s=!1;return await this.hasLoginState()&&(s=!0,r=!1),this.config.request(e,{method:"GET",withBasicAuth:r,withCredentials:s})}async checkUsername(t){return this.config.request(i.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}async checkIfUserExist(t){const e=new R(t);return this.config.request(`${i.CHECK_IF_USER_EXIST}?${e.toString()}`,{method:"GET"})}async loginScope(){return this.config.credentialsClient.getScope()}async loginGroups(){return this.config.credentialsClient.getGroups()}async refreshTokenForce(t){const e=await this.config.credentialsClient.getCredentials();return await this.config.credentialsClient.refreshToken({...e,version:t?.version||"v1"})}async getCredentials(){return this.config.credentialsClient.getCredentials()}async getPublicKey(){return this.config.request(s.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}async getEncryptParams(t){const{isEncrypt:e}=t;delete t.isEncrypt;const r=(0,l.I)(t),i=A(e);if(!i)return t;let s="",n="";try{const t=await this.getPublicKey();s=t.public_key,n=t.public_key_thumbprint}catch(t){}if(!s||!n)throw new Error("public_key or public_key_thumbprint is empty");return{params:i.getEncryptInfo({publicKey:s,payload:r}),public_key_thumbprint:n}}async getProviderSubType(){return this.config.request(i.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}async verifyCaptchaData({token:t,key:e}){return this.config.request(i.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:e},withCredentials:!1})}async createCaptchaData({state:t,redirect_uri:e}){return this.config.request(i.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:e},withCredentials:!1})}async getMiniProgramCode(t){return this.config.request(i.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}async getMiniProgramQrCodeStatus(t){return this.config.request(i.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}async getUserBehaviorLog(t){const e=`${i.GET_USER_BEHAVIOR_LOG}?${{LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[t.type]}&limit=${t.limit}${t.page_token?`&page_token=${t.page_token}`:""}`;return this.config.request(e,{method:"GET",withCredentials:!0})}async modifyPassword(t){let e="",r="";const s=A(!0);if(!s)throw new Error("do not support encrypt, a encrypt util required.");try{const t=await this.getPublicKey();e=t.public_key,r=t.public_key_thumbprint}catch(t){}if(!e||!r)throw new Error("public_key or public_key_thumbprint is empty");const n=t.password?s.getEncryptInfo({publicKey:e,payload:t.password}):"",o=s.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(i.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:n,encrypt_new_password:o,public_key_thumbprint:r}})}async modifyPasswordWithoutLogin(t){let e="",r="";const i=A(!0);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{const t=await this.getPublicKey();e=t.public_key,r=t.public_key_thumbprint}catch(t){}if(!e||!r)throw new Error("public_key or public_key_thumbprint is empty");const n=t.password?i.getEncryptInfo({publicKey:e,payload:t.password}):"",o=i.getEncryptInfo({publicKey:e,payload:t.new_password});return this.config.request(s.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:n,new_password:o,public_key_thumbprint:r}})}}class U{constructor(t){const{apiOrigin:e,clientId:r,env:i,storage:s,request:n,baseRequest:o,anonymousSignInFunc:a,wxCloud:h}=t;this.oauth2client=new E({apiOrigin:e,clientId:r,env:i,storage:s,baseRequest:o||n,anonymousSignInFunc:a,wxCloud:h}),this.authApi=new O({credentialsClient:this.oauth2client,...t,request:n?this.oauth2client.request.bind(this.oauth2client):void 0})}}},443:(t,e,r)=>{let i;if(r.r(e),r.d(e,{getEncryptInfo:()=>P}),!globalThis.IS_MP_BUILD){const N="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;var s="0123456789abcdefghijklmnopqrstuvwxyz";function D(t){return s.charAt(t)}function L(t,e){return t&e}function x(t,e){return t|e}function k(t,e){return t^e}function q(t,e){return t&~e}function B(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function V(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function H(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=n.charAt(r>>6)+n.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=n.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=n.charAt(r>>2)+n.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function M(t){var e,r="",i=0,s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var o=n.indexOf(t.charAt(e));o<0||(0==i?(r+=D(o>>2),s=3&o,i=1):1==i?(r+=D(s<<2|o>>4),s=15&o,i=2):2==i?(r+=D(s),r+=D(o>>2),s=3&o,i=3):(r+=D(s<<2|o>>4),r+=D(15&o),i=0))}return 1==i&&(r+=D(s<<2)),r}var o,a,h={decode:function(t){var e;if(void 0===o){var r="0123456789ABCDEF";for(o={},e=0;e<16;++e)o[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)o[r.charAt(e)]=e;for(e=0;e<8;++e)o[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var i=[],s=0,n=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=o[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);s|=a,++n>=2?(i[i.length]=s,s=0,n=0):s<<=4}}if(n)throw new Error("Hex encoding incomplete: 4 bits missing");return i}},u={decode:function(t){var e;if(void 0===a){for(a=Object.create(null),e=0;e<64;++e)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)a["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],i=0,s=0;for(e=0;e<t.length;++e){var n=t.charAt(e);if("="==n)break;if(-1!=(n=a[n])){if(void 0===n)throw new Error("Illegal character at offset "+e);i|=n,++s>=4?(r[r.length]=i>>16,r[r.length]=i>>8&255,r[r.length]=255&i,i=0,s=0):i<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=i>>10;break;case 3:r[r.length]=i>>16,r[r.length]=i>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=u.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return u.decode(t)}},c=1e13;class G{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,i,s=this.buf,n=s.length;for(r=0;r<n;++r)(i=s[r]*t+e)<c?e=0:i-=(e=0|i/c)*c,s[r]=i;e>0&&(s[r]=e)}sub(t){var e,r,i=this.buf,s=i.length;for(e=0;e<s;++e)(r=i[e]-t)<0?(r+=c,t=1):t=0,i[e]=r;for(;0===i[i.length-1];)i.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),i=e.length-2;i>=0;--i)r+=(c+e[i]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*c+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var l,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,f=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function F(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class ${constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof $?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var i="",s=t;s<e;++s)if(i+=this.hexByte(this.get(s)),!0!==r)switch(15&s){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i}isASCII(t,e){for(var r=t;r<e;++r){var i=this.get(r);if(i<32||i>176)return!1}return!0}parseStringISO(t,e){for(var r="",i=t;i<e;++i)r+=String.fromCharCode(this.get(i));return r}parseStringUTF(t,e){for(var r="",i=t;i<e;){var s=this.get(i++);r+=s<128?String.fromCharCode(s):s>191&&s<224?String.fromCharCode((31&s)<<6|63&this.get(i++)):String.fromCharCode((15&s)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return r}parseStringBMP(t,e){for(var r,i,s="",n=t;n<e;)r=this.get(n++),i=this.get(n++),s+=String.fromCharCode(r<<8|i);return s}parseTime(t,e,r){var i=this.parseStringISO(t,e),s=(r?d:f).exec(i);return s?(r&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),i=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(i+=":"+s[5],s[6]&&(i+=":"+s[6],s[7]&&(i+="."+s[7]))),s[8]&&(i+=" UTC","Z"!=s[8]&&(i+=s[8],s[9]&&(i+=":"+s[9]))),i):"Unrecognized time: "+i}parseInteger(t,e){for(var r,i=this.get(t),s=i>127,n=s?255:0,o="";i==n&&++t<e;)i=this.get(t);if(0==(r=e-t))return s?-1:0;if(r>4){for(o=i,r<<=3;!(128&(+o^n));)o=+o<<1,--r;o="("+r+" bit)\n"}s&&(i-=256);for(var a=new G(i),h=t+1;h<e;++h)a.mulAdd(256,this.get(h));return o+a.toString()}parseBitString(t,e,r){for(var i=this.get(t),s="("+((e-t-1<<3)-i)+" bit)\n",n="",o=t+1;o<e;++o){for(var a=this.get(o),h=o==e-1?i:0,u=7;u>=h;--u)n+=a>>u&1?"1":"0";if(n.length>r)return s+F(n,r)}return s+n}parseOctetString(t,e,r){if(this.isASCII(t,e))return F(this.parseStringISO(t,e),r);var i=e-t,s="("+i+" byte)\n";i>(r/=2)&&(e=t+r);for(var n=t;n<e;++n)s+=this.hexByte(this.get(n));return i>r&&(s+="…"),s}parseOID(t,e,r){for(var i="",s=new G,n=0,o=t;o<e;++o){var a=this.get(o);if(s.mulAdd(128,127&a),n+=7,!(128&a)){if(""===i)if((s=s.simplify())instanceof G)s.sub(80),i="2."+s.toString();else{var h=s<80?s<40?0:1:2;i=h+"."+(s-40*h)}else i+="."+s.toString();if(i.length>r)return F(i,r);s=new G,n=0}}return n>0&&(i+=".incomplete"),i}}class K{constructor(t,e,r,i,s){if(!(i instanceof W))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=i,this.sub=s}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return F(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return F(this.stream.parseStringISO(e,e+r),t);case 30:return F(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,i=this.sub.length;r<i;++r)e+=this.sub[r].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var i=0;i<r;++i)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof $?t:new $(t,0);var r=new $(e),i=new W(e),s=K.decodeLength(e),n=e.pos,o=n-r.pos,a=null,h=function(){var t=[];if(null!==s){for(var r=n+s;e.pos<r;)t[t.length]=K.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+n)}else try{for(;;){var i=K.decode(e);if(i.tag.isEOC())break;t[t.length]=i}s=n-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(i.tagConstructed)a=h();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=h();for(var u=0;u<a.length;++u)if(a[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+n);e.pos=n+Math.abs(s)}return new K(r,o,s,i,a)}}class W{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new G;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],g=(1<<26)/p[p.length-1];class j{constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,s=!1,n="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(s=!0,n=D(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&i,a<=0&&(a+=this.DB,--o)),r>0&&(s=!0),s&&(n+=D(r));return s?n:"0"}negate(){var t=Y();return j.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+et(this[this.t-1]^this.s&this.DM)}mod(t){var e=Y();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(j.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new y(e):new _(e),this.exp(t,r)}clone(){var t=Y();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var r,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=Y();return this.bitwiseTo(t,L,e),e}or(t){var e=Y();return this.bitwiseTo(t,x,e),e}xor(t){var e=Y();return this.bitwiseTo(t,k,e),e}andNot(t){var e=Y();return this.bitwiseTo(t,q,e),e}not(){for(var t=Y(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=Y();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=Y();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+B(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=V(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,x)}clearBit(t){return this.changeBit(t,q)}flipBit(t){return this.changeBit(t,k)}add(t){var e=Y();return this.addTo(t,e),e}subtract(t){var e=Y();return this.subTo(t,e),e}multiply(t){var e=Y();return this.multiplyTo(t,e),e}divide(t){var e=Y();return this.divRemTo(t,e,null),e}remainder(t){var e=Y();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=Y(),r=Y();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,i,s=t.bitLength(),n=tt(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new y(e):e.isEven()?new v(e):new _(e);var o=[],a=3,h=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var c=Y();for(i.sqrTo(o[1],c);a<=u;)o[a]=Y(),i.mulTo(c,o[a-2],o[a]),a+=2}var l,d,f=t.t-1,p=!0,g=Y();for(s=et(t[f])-1;f>=0;){for(s>=h?l=t[f]>>s-h&u:(l=(t[f]&(1<<s+1)-1)<<h-s,f>0&&(l|=t[f-1]>>this.DB+s-h)),a=r;!(1&l);)l>>=1,--a;if((s-=a)<0&&(s+=this.DB,--f),p)o[l].copyTo(n),p=!1;else{for(;a>1;)i.sqrTo(n,g),i.sqrTo(g,n),a-=2;a>0?i.sqrTo(n,g):(d=n,n=g,g=d),i.mulTo(g,o[l],n)}for(;f>=0&&!(t[f]&1<<s);)i.sqrTo(n,g),d=n,n=g,g=d,--s<0&&(s=this.DB-1,--f)}return i.revert(n)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return j.ZERO;for(var r=t.clone(),i=this.clone(),s=tt(1),n=tt(0),o=tt(0),a=tt(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(o,s),n.subTo(a,n)):(i.subTo(r,i),e&&o.subTo(s,o),a.subTo(n,a))}return 0!=i.compareTo(j.ONE)?j.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new m)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=p[p.length-1]){for(e=0;e<p.length;++e)if(r[0]==p[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<p.length;){for(var i=p[e],s=e+1;s<p.length&&i<g;)i*=p[s++];for(i=r.modInt(i);e<s;)if(i%p[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,n=0;--i>=0;){var o=8==r?255&+t[i]:X(t,i);o<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=o:n+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-n)-1)<<n,this[this.t++]=o>>this.DB-n):this[this.t-1]|=o<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&128&+t[0]&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&j.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,i=this.DB-r,s=(1<<i)-1,n=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+n+1]=this[a]>>i|o,o=(this[a]&s)<<r;for(a=n-1;a>=0;--a)e[a]=0;e[n]=o,e.t=this.t+n+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&n)<<s,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&j.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=Y());var n=Y(),o=this.s,a=t.s,h=this.DB-et(i[i.t-1]);h>0?(i.lShiftTo(h,n),s.lShiftTo(h,r)):(i.copyTo(n),s.copyTo(r));var u=n.t,c=n[u-1];if(0!=c){var l=c*(1<<this.F1)+(u>1?n[u-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,p=1<<this.F2,g=r.t,m=g-u,y=null==e?Y():e;for(n.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),j.ONE.dlShiftTo(u,y),y.subTo(n,n);n.t<u;)n[n.t++]=0;for(;--m>=0;){var _=r[--g]==c?this.DM:Math.floor(r[g]*d+(r[g-1]+p)*f);if((r[g]+=n.am(0,_,r,m,0,u))<_)for(n.dlShiftTo(m,y),r.subTo(y,r);r[g]<--_;)r.subTo(y,r)}null!=e&&(r.drShiftTo(u,e),o!=a&&j.ZERO.subTo(e,e)),r.t=u,r.clamp(),h>0&&r.rShiftTo(h,r),o<0&&j.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return j.ONE;var r=Y(),i=Y(),s=e.convert(this),n=et(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var o=r;r=i,i=o}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=tt(r),s=Y(),n=Y(),o="";for(this.divRemTo(i,s,n);s.signum()>0;)o=(r+n.intValue()).toString(t).substr(1)+o,s.divRemTo(i,s,n);return n.intValue().toString(t)+o}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,o=0,a=0;a<t.length;++a){var h=X(t,a);h<0?"-"==t.charAt(a)&&0==this.signum()&&(s=!0):(o=e*o+h,++n>=r&&(this.dMultiply(i),this.dAddOffset(o,0),n=0,o=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(o,0)),s&&j.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(j.ONE.shiftLeft(t-1),x,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(j.ONE.shiftLeft(t-1),this);else{var i=[],s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}}bitwiseTo(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=j.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(var s=r.t-this.t;i<s;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(s=Math.min(t.t,e);i<s;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()}multiplyUpperTo(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r}millerRabin(t){var e=this.subtract(j.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>p.length&&(t=p.length);for(var s=Y(),n=0;n<t;++n){s.fromInt(p[Math.floor(Math.random()*p.length)]);var o=s.modPow(i,this);if(0!=o.compareTo(j.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(j.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0}square(){var t=Y();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(r.compareTo(i)<0){var s=r;r=i,i=s}var n=r.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)e(r);else{n<o&&(o=n),o>0&&(r.rShiftTo(o,r),i.rShiftTo(o,i));var a=()=>{(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),r.compareTo(i)>=0?(r.subTo(i,r),r.rShiftTo(1,r)):(i.subTo(r,i),i.rShiftTo(1,i)),r.signum()>0?setTimeout(a,0):(o>0&&i.lShiftTo(o,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,i){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(j.ONE.shiftLeft(t-1),x,this),this.isEven()&&this.dAddOffset(1,0);var s=this,n=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(j.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout((function(){i()}),0):setTimeout(n,0)};setTimeout(n,0)}else{var o=[],a=7&t;o.length=1+(t>>3),e.nextBytes(o),a>0?o[0]&=(1<<a)-1:o[0]=0,this.fromString(o,256)}}}var m=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),y=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),_=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=Y();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(j.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=Y();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),v=function(){function t(t){this.m=t,this.r2=Y(),this.q3=Y(),j.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=Y();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function Y(){return new j(null)}function z(t,e){return new j(t,e)}function Z(t,e,r,i,s,n){for(;--n>=0;){var o=e*this[t++]+r[i]+s;s=Math.floor(o/67108864),r[i++]=67108863&o}return s}function Q(t,e,r,i,s,n){for(var o=32767&e,a=e>>15;--n>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;s=((h=o*h+((32767&c)<<15)+r[i]+(1073741823&s))>>>30)+(c>>>15)+a*u+(s>>>30),r[i++]=1073741823&h}return s}function J(t,e,r,i,s,n){for(var o=16383&e,a=e>>14;--n>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;s=((h=o*h+((16383&c)<<14)+r[i]+s)>>28)+(c>>14)+a*u,r[i++]=268435455&h}return s}void 0!==N&&"Microsoft Internet Explorer"==N?.appName?(j.prototype.am=Q,l=30):"Netscape"!=N?.appName?(j.prototype.am=Z,l=26):(j.prototype.am=J,l=28),j.prototype.DB=l,j.prototype.DM=(1<<l)-1,j.prototype.DV=1<<l,j.prototype.FV=Math.pow(2,52),j.prototype.F1=52-l,j.prototype.F2=2*l-52;var T,E,S=[];for(T="0".charCodeAt(0),E=0;E<=9;++E)S[T++]=E;for(T="a".charCodeAt(0),E=10;E<36;++E)S[T++]=E;for(T="A".charCodeAt(0),E=10;E<36;++E)S[T++]=E;function X(t,e){var r=S[t.charCodeAt(e)];return null==r?-1:r}function tt(t){var e=Y();return e.fromInt(t),e}function et(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}j.ZERO=tt(0),j.ONE=tt(1);class rt{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var w,I,b=null;if(null==b){b=[],I=0;var R=void 0;if(window?.crypto&&window?.crypto.getRandomValues){var C=new Uint32Array(256);for(window?.crypto.getRandomValues(C),R=0;R<C.length;++R)b[I++]=255&C[R]}var A=function(t){if(this.count=this.count||0,this.count>=256||I>=256)window?.removeEventListener?window?.removeEventListener("mousemove",A,!1):window?.detachEvent&&window?.detachEvent("onmousemove",A);else try{var e=t.x+t.y;b[I++]=255&e,this.count+=1}catch(t){}};window?.addEventListener?window?.addEventListener("mousemove",A,!1):window?.attachEvent&&window?.attachEvent("onmousemove",A)}function it(){if(null==w){for(w=new rt;I<256;){var t=Math.floor(65536*Math.random());b[I++]=255&t}for(w.init(b),I=0;I<b.length;++I)b[I]=0;I=0}return w.next()}class st{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=it()}}function nt(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],i=t.length-1;i>=0&&e>0;){var s=t.charCodeAt(i--);s<128?r[--e]=s:s>127&&s<2048?(r[--e]=63&s|128,r[--e]=s>>6|192):(r[--e]=63&s|128,r[--e]=s>>6&63|128,r[--e]=s>>12|224)}r[--e]=0;for(var n=new st,o=[];e>2;){for(o[0]=0;0==o[0];)n.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new j(r)}class ot{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=z(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=nt(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var i=r.toString(16);return 1&i.length?"0"+i:i}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var i="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);i+=r})),H(i)):H(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=M(t);try{if(t.length>r){var i="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);i+=r})),i}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=z(t,16),this.e=parseInt(e,16),this.d=z(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,i,s,n,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=z(t,16),this.e=parseInt(e,16),this.d=z(r,16),this.p=z(i,16),this.q=z(s,16),this.dmp1=z(n,16),this.dmq1=z(o,16),this.coeff=z(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new st,i=t>>1;this.e=parseInt(e,16);for(var s=new j(e,16);;){for(;this.p=new j(t-i,1,r),0!=this.p.subtract(j.ONE).gcd(s).compareTo(j.ONE)||!this.p.isProbablePrime(10););for(;this.q=new j(i,1,r),0!=this.q.subtract(j.ONE).gcd(s).compareTo(j.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var n=this.p;this.p=this.q,this.q=n}var o=this.p.subtract(j.ONE),a=this.q.subtract(j.ONE),h=o.multiply(a);if(0==h.gcd(s).compareTo(j.ONE)){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=z(t,16),r=this.doPrivate(e);return null==r?null:at(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var i=new st,s=t>>1;this.e=parseInt(e,16);var n=new j(e,16),o=this,a=()=>{var e=()=>{if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(j.ONE),i=o.q.subtract(j.ONE),s=e.multiply(i);0==s.gcd(n).compareTo(j.ONE)?(o.n=o.p.multiply(o.q),o.d=n.modInverse(s),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(i),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},h=()=>{o.q=Y(),o.q.fromNumberAsync(s,1,i,(function(){o.q.subtract(j.ONE).gcda(n,(function(t){0==t.compareTo(j.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=()=>{o.p=Y(),o.p.fromNumberAsync(t-s,1,i,(function(){o.p.subtract(j.ONE).gcda(n,(function(t){0==t.compareTo(j.ONE)&&o.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)}}function at(t,e){for(var r=t.toByteArray(),i=0;i<r.length&&0==r[i];)++i;if(r.length-i!=e-1||2!=r[i])return null;for(++i;0!=r[i];)if(++i>=r.length)return null;for(var s="";++i<r.length;){var n=255&r[i];n<128?s+=String.fromCharCode(n):n>191&&n<224?(s+=String.fromCharCode((31&n)<<6|63&r[i+1]),++i):(s+=String.fromCharCode((15&n)<<12|(63&r[i+1])<<6|63&r[i+2]),i+=2)}return s}class ht extends ot{constructor(t=""){super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?h.decode(t):u.unarmor(t),s=K.decode(i);if(3===s.sub.length&&(s=s.sub[2].sub[0]),9===s.sub.length){e=s.sub[1].getHexStringValue(),this.n=z(e,16),r=s.sub[2].getHexStringValue(),this.e=parseInt(r,16);var n=s.sub[3].getHexStringValue();this.d=z(n,16);var o=s.sub[4].getHexStringValue();this.p=z(o,16);var a=s.sub[5].getHexStringValue();this.q=z(a,16);var c=s.sub[6].getHexStringValue();this.dmp1=z(c,16);var l=s.sub[7].getHexStringValue();this.dmq1=z(l,16);var d=s.sub[8].getHexStringValue();this.coeff=z(d,16)}else{if(2!==s.sub.length)return!1;var f=s.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=z(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}i=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null},i.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ht(t)},i.prototype.setPrivateKey=function(t){this.setKey(t)},i.prototype.setPublicKey=function(t){this.setKey(t)},i.prototype.decrypt=function(t){try{return this.getKey().decrypt(M(t))}catch(t){return!1}},i.prototype.encrypt=function(t){try{return H(this.getKey().encrypt(t))}catch(t){return!1}},i.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",i=0,s=/null$/g;s.test(r)&&(i++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(i>10)););return e}catch(t){return!1}},i.prototype.getKey=function(t){if(!this.key){if(this.key=new ht,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},i.version="3.1.4"}const O=i;var U=r(479);const P=({publicKey:t="",payload:e={}}={})=>{if(!t)return"";try{const r=(0,U.I)(e),i=new O;return i.setPublicKey(t),i.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){console.error("encrypt error:",t)}return""}},479:(t,e,r)=>{r.d(e,{I:()=>i,y:()=>s});const i=t=>{const e=e=>{for(const r in t)t.hasOwnProperty(r)&&(e[r]=i(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},s=t=>{const e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},118:function(t,e,r){var i=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),s=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||i(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),s(r(746),e)}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(118)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/js-sdk",
3
- "version": "2.8.2-beta.0",
3
+ "version": "2.8.4-beta.0",
4
4
  "description": "cloudbase javascript sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -46,22 +46,22 @@
46
46
  "license": "Apache-2.0",
47
47
  "dependencies": {
48
48
  "@cloudbase/adapter-interface": "^0.5",
49
- "@cloudbase/ai": "^2.8.2-beta.0",
50
- "@cloudbase/analytics": "^2.8.2-beta.0",
51
- "@cloudbase/app": "^2.8.2-beta.0",
52
- "@cloudbase/auth": "^2.8.2-beta.0",
49
+ "@cloudbase/ai": "^2.8.4-beta.0",
50
+ "@cloudbase/analytics": "^2.8.4-beta.0",
51
+ "@cloudbase/app": "^2.8.4-beta.0",
52
+ "@cloudbase/auth": "^2.8.4-beta.0",
53
53
  "@cloudbase/database": "0.9.21",
54
- "@cloudbase/functions": "^2.8.2-beta.0",
55
- "@cloudbase/model": "^2.8.2-beta.0",
56
- "@cloudbase/realtime": "^2.8.2-beta.0",
57
- "@cloudbase/storage": "^2.8.2-beta.0",
58
- "@cloudbase/types": "^2.8.2-beta.0",
59
- "@cloudbase/utilities": "^2.8.2-beta.0"
54
+ "@cloudbase/functions": "^2.8.4-beta.0",
55
+ "@cloudbase/model": "^2.8.4-beta.0",
56
+ "@cloudbase/realtime": "^2.8.4-beta.0",
57
+ "@cloudbase/storage": "^2.8.4-beta.0",
58
+ "@cloudbase/types": "^2.8.4-beta.0",
59
+ "@cloudbase/utilities": "^2.8.4-beta.0"
60
60
  },
61
61
  "browserslist": [
62
62
  "last 2 version",
63
63
  "> 1%",
64
64
  "chrome 53"
65
65
  ],
66
- "gitHead": "d96acd30d014e50c30aa6c48df3d21fc22a68c04"
66
+ "gitHead": "336f70dac56defd4a5d0b82920cecd34125188fb"
67
67
  }