@cloudbase/js-sdk 2.5.36-beta.0 → 2.5.38-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_oauth",[],t):"object"==typeof exports?exports.cloudbase_oauth=t():e.cloudbase_oauth=t()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var e={99:(e,t,n)=>{n.r(t),n.d(t,{Auth:()=>L,AuthClient:()=>k,CloudbaseOAuth:()=>q,ErrorType:()=>i,OAuth2Client:()=>C,Syntax:()=>r,authModels:()=>c,defaultRequest:()=>R,defaultStorage:()=>m,generateRequestId:()=>S,toResponseError:()=>I});var r,i,o,s,a,u,c={};function l(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}n.r(c),function(e){e.CLIENT_ID="client_id",e.CLIENT_SECRET="client_secret",e.RESPONSE_TYPE="response_type",e.SCOPE="scope",e.STATE="state",e.REDIRECT_URI="redirect_uri",e.ERROR="error",e.ERROR_DESCRIPTION="error_description",e.ERROR_URI="error_uri",e.GRANT_TYPE="grant_type",e.CODE="code",e.ACCESS_TOKEN="access_token",e.TOKEN_TYPE="token_type",e.EXPIRES_IN="expires_in",e.USERNAME="username",e.PASSWORD="password",e.REFRESH_TOKEN="refresh_token"}(r||(r={})),function(e){e.UNREACHABLE="unreachable",e.LOCAL="local",e.CANCELLED="cancelled",e.UNKNOWN="unknown",e.INVALID_ARGUMENT="invalid_argument",e.DEADLINE_EXCEEDED="deadline_exceeded",e.NOT_FOUND="not_found",e.ALREADY_EXISTS="already_exists",e.PERMISSION_DENIED="permission_denied",e.UNAUTHENTICATED="unauthenticated",e.RESOURCE_EXHAUSTED="resource_exhausted",e.FAILED_PRECONDITION="failed_precondition",e.ABORTED="aborted",e.OUT_OF_RANGE="out_of_range",e.UNIMPLEMENTED="unimplemented",e.INTERNAL="internal",e.UNAVAILABLE="unavailable",e.DATA_LOSS="data_loss",e.CAPTCHA_REQUIRED="captcha_required",e.CAPTCHA_INVALID="captcha_invalid",e.INVALID_PASSWORD="invalid_password",e.INVALID_STATUS="invalid_status",e.USER_PENDING="user_pending",e.USER_BLOCKED="user_blocked",e.INVALID_VERIFICATION_CODE="invalid_verification_code",e.TWO_FACTOR_REQUIRED="two_factor_required",e.INVALID_TWO_FACTOR="invalid_two_factor",e.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",e.UNDER_REVIEW="under_review",e.INVALID_REQUEST="invalid_request",e.UNAUTHORIZED_CLIENT="unauthorized_client",e.ACCESS_DENIED="access_denied",e.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",e.INVALID_SCOPE="invalid_scope",e.INVALID_GRANT="invalid_grant",e.SERVER_ERROR="server_error",e.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",e.INTERACTION_REQUIRED="interaction_required",e.LOGIN_REQUIRED="login_required",e.ACCOUNT_SELECTION_REQUIRED="account_selection_required",e.CONSENT_REQUIRED="consent_required",e.INVALID_REQUEST_URI="invalid_request_uri",e.INVALID_REQUEST_OBJECT="invalid_request_object",e.REQUEST_NOT_SUPPORTED="request_not_supported",e.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",e.REGISTRATION_NOT_SUPPORTED="registration_not_supported"}(i||(i={})),function(e){e.AUTH_SIGN_IN_URL="/auth/v1/signin",e.AUTH_SIGN_IN_ANONYMOUSLY_URL="/auth/v1/signin/anonymously",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v1/signin/with/provider",e.AUTH_SIGN_UP_URL="/auth/v1/signup",e.AUTH_TOKEN_URL="/auth/v1/token",e.AUTH_REVOKE_URL="/auth/v1/revoke",e.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",e.PROVIDER_TOKEN_URL="/auth/v1/provider/token",e.PROVIDER_URI_URL="/auth/v1/provider/uri",e.USER_ME_URL="/auth/v1/user/me",e.WEDA_USER_URL="/auth/v1/plugin/weda/userinfo",e.USER_QUERY_URL="/auth/v1/user/query",e.USER_PRIFILE_URL="/auth/v1/user/profile",e.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",e.VERIFICATION_URL="/auth/v1/verification",e.VERIFY_URL="/auth/v1/verification/verify",e.PROVIDER_LIST="/auth/v1/user/provider",e.PROVIDER_UNBIND_URL="/auth/v1/user/provider",e.CHECK_PWD_URL="/auth/v1/user/sudo",e.SUDO_URL="/auth/v1/user/sudo",e.BIND_CONTACT_URL="/auth/v1/user/contact",e.AUTH_SET_PASSWORD="/auth/v1/user/password",e.AUTH_RESET_PASSWORD="/auth/v1/reset",e.AUTH_GET_DEVICE_CODE="/auth/v1/device/code",e.CHECK_USERNAME="/auth/v1/checkUsername",e.CHECK_IF_USER_EXIST="/auth/v1/checkIfUserExist"}(o||(o={})),function(e){e.AUTH_SIGN_IN_URL="/auth/v2/signin/username",e.AUTH_TOKEN_URL="/auth/v2/token",e.USER_ME_URL="/auth/v2/user/me",e.VERIFY_URL="/auth/v2/signin/verificationcode",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/auth/v2/signin/with/provider"}(s||(s={})),function(e){e.REGISTER="REGISTER",e.SIGN_IN="SIGN_IN",e.PASSWORD_RESET="PASSWORD_RESET",e.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",e.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(a||(a={})),function(e){e.INVALID_ARGUMENT="invalid_argument",e.DEADLINE_EXCEEDED="deadline_exceeded",e.NOT_FOUND="not_found",e.ALREADY_EXISTS="already_exists",e.PERMISSION_DENIED="permission_denied",e.ABORTED="aborted",e.OUT_OF_RANGE="out_of_range",e.UNIMPLEMENTED="unimplemented",e.INTERNAL="internal",e.UNAVAILABLE="unavailable",e.DATA_LOSS="data_loss",e.CAPTCHA_REQUIRED="captcha_required",e.CAPTCHA_INVALID="captcha_invalid",e.INVALID_PASSWORD="invalid_password",e.PASSWORD_NOT_SET="password_not_set",e.INVALID_STATUS="invalid_status",e.USER_PENDING="user_pending",e.USER_BLOCKED="user_blocked"}(u||(u={}));var h=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},d=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},f=function(){function e(){this.fnPromiseMap=new Map}return e.prototype.run=function(e,t){return h(this,void 0,void 0,(function(){var n,r=this;return d(this,(function(i){switch(i.label){case 0:return[4,n=this.fnPromiseMap.get(e)];case 1:return i.sent()||(n=new Promise((function(n,i){h(r,void 0,void 0,(function(){var r,o,s;return d(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),r=t(),o=n,[4,r];case 2:return o.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),i(s),[3,5];case 4:return this.fnPromiseMap.delete(e),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(e,n)),[2,n]}}))}))},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}(),p=function(){return p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},p.apply(this,arguments)},_=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},v=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},y="x-request-id",g="x-device-id",E="device_id",R=function(e,t){return _(this,void 0,void 0,(function(){var n,r,o,s,a;return v(this,(function(u){switch(u.label){case 0:n=null,r=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(o=Object.assign({},t)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(e,o)];case 2:return[4,u.sent().json()];case 3:return(null==(s=u.sent())?void 0:s.error)?(r=s).error_uri=new URL(e).pathname:n=s,[3,5];case 4:return a=u.sent(),r={error:i.UNREACHABLE,error_description:a.message,error_uri:new URL(e).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))},I=function(e,t){var n,r=t||{};if(e instanceof Error)n={error:r.error||i.LOCAL,error_description:r.error_description||e.message,error_uri:r.error_uri,details:r.details||e.stack};else{var o=e||{};n={error:r.error||o.error||i.LOCAL,error_description:r.error_description||o.error_description,error_uri:r.error_uri||o.error_uri,details:r.details||o.details}}return n};function S(){return l()}var m=new(function(){function e(){}return e.prototype.getItem=function(e){return _(this,void 0,void 0,(function(){return v(this,(function(t){return[2,window.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return _(this,void 0,void 0,(function(){return v(this,(function(t){return window.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return _(this,void 0,void 0,(function(){return v(this,(function(n){return window.localStorage.setItem(e,t),[2]}))}))},e.prototype.getItemSync=function(e){return window.localStorage.getItem(e)},e.prototype.removeItemSync=function(e){window.localStorage.removeItem(e)},e.prototype.setItemSync=function(e,t){window.localStorage.setItem(e,t)},e}());function T(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}var b=function(){function e(e){this.credentials=null,this.singlePromise=new f,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage}return e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e){return _(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return(null==e?void 0:e.expires_in)?(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30)),this.storage?(t=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,t)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},e.prototype.getCredentials=function(){return _(this,void 0,void 0,(function(){var e=this;return v(this,(function(t){return[2,this.singlePromise.run("getCredentials",(function(){return _(e,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return T(this.credentials)?(e=this,[4,this.getStorageCredentials()]):[3,2];case 1:e.credentials=t.sent(),t.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},e.prototype.getStorageCredentials=function(){return _(this,void 0,void 0,(function(){var e=this;return v(this,(function(t){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return _(e,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return e=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),e=null,[3,5];case 5:return[2,e]}}))}))}))]}))}))},e}(),C=function(){function e(t){this.singlePromise=new f,this.apiOrigin=t.apiOrigin,this.clientId=t.clientId,this.retry=this.formatRetry(t.retry,e.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=R,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||m,this.localCredentials=new b({tokenSectionName:"credentials_".concat(t.clientId),storage:this.storage}),this.clientSecret=t.clientSecret,this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc}return e.prototype.setCredentials=function(e){return this.localCredentials.setCredentials(e)},e.prototype.getAccessToken=function(){return _(this,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return[4,this.getCredentials()];case 1:return(null==(e=n.sent())?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:i.UNAUTHENTICATED},[2,Promise.reject(t)])}}))}))},e.prototype.request=function(t,n){return _(this,void 0,void 0,(function(){var r,o,s,a,u,c,l;return v(this,(function(h){switch(h.label){case 0:return n||(n={}),r=this.formatRetry(n.retry,this.retry),n.headers=n.headers||{},this.headers&&(n.headers=p(p({},this.headers),n.headers)),n.headers[y]||(n.headers[y]=S()),n.headers[g]?[3,2]:[4,this.getDeviceId()];case 1:o=h.sent(),n.headers[g]=o,h.label=2;case 2:return(null==n?void 0:n.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(s=h.sent())&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(s.access_token)):n.headers.Authorization="".concat(s.token_type," ").concat(s.access_token)),[3,5];case 4:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),h.label=5;case 5:t.startsWith("/")&&(t=this.apiOrigin+t),a=null,u=r+1,c=0,h.label=6;case 6:if(!(c<u))return[3,15];h.label=7;case 7:return h.trys.push([7,9,,12]),[4,this.baseRequest(t,n)];case 8:return a=h.sent(),[3,15];case 9:return l=h.sent(),n.withCredentials&&l&&l.error===i.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return h.sent(),[2,Promise.reject(l)];case 11:return c!==r&&l&&"unreachable"===l.error?[3,12]:[2,Promise.reject(l)];case 12:return[4,this.sleep(e.retryInterval)];case 13:h.sent(),h.label=14;case 14:return c++,[3,6];case 15:return[2,a]}}))}))},e.prototype.getCredentials=function(){return _(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return T(e=r.sent())?e&&"anonymous"===e.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,5]:[3,8]:[3,10];case 2:return t=r.sent(),(n=t)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:n=r.sent(),r.label=4;case 4:return e=n,[3,7];case 5:return[4,this.anonymousSignIn(e)];case 6:e=r.sent(),r.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(e)];case 9:e=r.sent(),r.label=10;case 10:return[2,e]}}))}))},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){return _(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=t.sent())?[2,e.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},e.prototype.getGroups=function(){return _(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=t.sent())?[2,e.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},e.prototype.refreshToken=function(e){return _(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return _(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:if(!e||!e.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return t=r.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return r.sent(),[2,t];case 4:return(n=r.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},e.prototype.checkRetry=function(t){var n=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(n={error:i.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return _(this,void 0,void 0,(function(){return v(this,(function(t){return[2,new Promise((function(t){setTimeout((function(){t()}),e)}))]}))}))},e.prototype.anonymousSignIn=function(e){return _(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return _(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return t=r.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return r.sent(),[2,t];case 4:return(n=r.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},e.prototype.defaultRefreshTokenFunc=function(e,t){return _(this,void 0,void 0,(function(){var n,r;return v(this,(function(i){switch(i.label){case 0:return void 0===e||""===e?[2,this.unAuthenticatedError("refresh token not found")]:(n=o.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(n=s.AUTH_TOKEN_URL),[4,this.request(n,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return r=i.sent(),[2,p(p({},r),{version:(null==t?void 0:t.version)||"v1"})]}}))}))},e.prototype.getDeviceId=function(){return _(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(E)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=l(),[4,this.storage.setItem(E,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}}))}))},e.prototype.unAuthenticatedError=function(e){var t={error:i.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}(),U=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},w=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},O=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=m),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId)}return e.prototype.request=function(e,t){return U(this,void 0,void 0,(function(){var n,r,i,o;return w(this,(function(s){switch(s.label){case 0:return t||(t={}),t.method||(t.method="GET"),n="".concat(t.method,":").concat(e),r=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,n,!1)]:[3,2];case 1:r=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(r,t)];case 3:return i=s.sent(),[3,7];case 4:return"captcha_required"!==(o=s.sent()).error&&"captcha_invalid"!==o.error?[3,6]:[4,this.appendCaptchaTokenToURL(e,n,"captcha_invalid"===o.error)];case 5:return e=s.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(o)];case 7:return[2,i]}}))}))},e.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var e=document.createElement("div");e.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;",e.setAttribute("id","captcha_panel_wrap"),setTimeout((function(){document.body.appendChild(e)}),0)}return this.defaultOpenURIWithCallback},e.prototype.defaultOpenURIWithCallback=function(e){return U(this,void 0,void 0,(function(){var t,n;return w(this,(function(r){return t=document.getElementById("captcha_panel_wrap"),n=document.createElement("iframe"),t.innerHTML="",n.setAttribute("src",e),n.setAttribute("id","review-panel-iframe"),n.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",t.appendChild(n),t.style.display="block",[2,new Promise((function(e,r){n.onload=function(){try{var i=window.location,o=n.contentWindow.location;if(o.host+o.pathname===i.host+i.pathname){t.style.display="none";var s=new URLSearchParams(o.search),a=s.get("captcha_token");return a?e({captcha_token:a,expires_in:Number(s.get("expires_in"))}):r({error:s.get("error"),error_description:s.get("error_description")})}t.style.display="block"}catch(e){t.style.display="block"}}}))]}))}))},e.prototype.getCaptchaToken=function(e,t){return U(this,void 0,void 0,(function(){var n,r,i,o,s;return w(this,(function(a){switch(a.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=a.sent())return[2,n];a.label=2;case 2:return r="".concat(window.location.origin+window.location.pathname,"?__captcha=on"),[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:r,state:t},withCredentials:!1})];case 3:return(i=a.sent()).captcha_token?(o={captcha_token:i.captcha_token,expires_in:i.expires_in},this.saveCaptchaToken(o),[2,i.captcha_token]):[4,this.config.openURIWithCallback(i.url)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}}))}))},e.prototype.appendCaptchaTokenToURL=function(e,t,n){return U(this,void 0,void 0,(function(){var r;return w(this,(function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(n,t)];case 1:return r=i.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(r):e+="?captcha_token=".concat(r),[2,e]}}))}))},e.prototype.saveCaptchaToken=function(e){return U(this,void 0,void 0,(function(){var t;return w(this,(function(n){switch(n.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return n.sent(),[2]}}))}))},e.prototype.findCaptchaToken=function(){return U(this,void 0,void 0,(function(){var e,t;return w(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},e}(),A=function(e){var t=function(t){for(var n in e)e.hasOwnProperty(n)&&(t[n]=A(e[n]));return t},n=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return e.slice();switch(n){case"Object":return t(Object.create(Object.getPrototypeOf(e)));case"Array":return t([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},N=function(){return N=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},N.apply(this,arguments)},P=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},D=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},L=function(){function e(e){var t=e.request,n=e.credentialsClient;if(!n){var r={apiOrigin:e.apiOrigin,clientId:e.clientId,storage:e.storage};n=new C(r)}if(!t){var i=n.request.bind(n),o=new O({clientId:e.clientId,request:i,storage:e.storage});t=o.request.bind(o)}this.config={apiOrigin:e.apiOrigin,clientId:e.clientId,request:t,credentialsClient:n,storage:e.storage||m}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach((function(t){e[t]||delete e[t]})),new URLSearchParams(e).toString()},e.prototype.getParamsByVersion=function(e,t){var n,r=A(e),i=(null===(n={v2:s}[null==r?void 0:r.version])||void 0===n?void 0:n[t])||o[t];return r&&delete r.version,{params:r,url:i}},e.prototype.signIn=function(e){return P(this,void 0,void 0,(function(){var t,n,r;return D(this,(function(i){switch(i.label){case 0:return t=e.version||"v1",(n=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete n.params.query,[4,this.config.request(n.url,{method:"POST",body:n.params})];case 1:return r=i.sent(),[4,this.config.credentialsClient.setCredentials(N(N({},r),{version:t}))];case 2:return i.sent(),[2,Promise.resolve(r)]}}))}))},e.prototype.signInAnonymously=function(e){return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var t;return D(this,(function(n){switch(n.label){case 0:return[4,this.config.request(o.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}}))}))},e.prototype.signUp=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){switch(n.label){case 0:return[4,this.config.request(o.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}}))}))},e.prototype.signOut=function(){return P(this,void 0,void 0,(function(){var e,t;return D(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return e=n.sent(),[4,this.config.request(o.AUTH_REVOKE_URL,{method:"POST",body:{token:e}})];case 2:return t=n.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return n.sent(),[2,Promise.resolve(t)]}}))}))},e.prototype.getVerification=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){switch(n.label){case 0:return t=!1,"CUR_USER"!==e.target?[3,1]:(t=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:n.sent()&&(t=!0),n.label=3;case 3:return[2,this.config.request(o.VERIFICATION_URL,{method:"POST",body:e,withCaptcha:!0,withCredentials:t})]}}))}))},e.prototype.verify=function(e){return P(this,void 0,void 0,(function(){var t,n;return D(this,(function(r){switch(r.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return n=r.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(N(N({},n),{version:"v2"}))];case 2:r.sent(),r.label=3;case 3:return[2,n]}}))}))},e.prototype.genProviderRedirectUri=function(e){return P(this,void 0,void 0,(function(){var t,n;return D(this,(function(r){return t="".concat(o.PROVIDER_URI_URL,"?client_id=").concat(this.config.clientId,"&provider_id=").concat(e.provider_id,"&redirect_uri=").concat(encodeURIComponent(e.provider_redirect_uri),"&state=").concat(e.state),(n=e.other_params)&&"string"==typeof n.sign_out_uri&&n.sign_out_uri.length>0&&(t+="&other_params[sign_out_uri]=".concat(n.sign_out_uri)),[2,this.config.request(t,{method:"GET"})]}))}))},e.prototype.grantProviderToken=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.PROVIDER_TOKEN_URL,{method:"POST",body:e})]}))}))},e.prototype.patchProviderToken=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]}))}))},e.prototype.signInWithProvider=function(e){return P(this,void 0,void 0,(function(){var t,n;return D(this,(function(r){switch(r.label){case 0:return t=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return n=r.sent(),[4,this.config.credentialsClient.setCredentials(N(N({},n),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return r.sent(),[2,Promise.resolve(n)]}}))}))},e.prototype.bindWithProvider=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0})]}))}))},e.prototype.getUserProfile=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.getUserInfo(e)]}))}))},e.prototype.getUserInfo=function(e){var t;return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var n,r,i;return D(this,(function(o){switch(o.label){case 0:return n=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=n.params)||void 0===t?void 0:t.query)&&(r=new URLSearchParams(n.params.query),n.url+="?".concat(r.toString())),[4,this.config.request(n.url,{method:"GET",withCredentials:!0})];case 1:return(i=o.sent()).sub&&(i.uid=i.sub),[2,i]}}))}))},e.prototype.getWedaUserInfo=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){switch(e.label){case 0:return[4,this.config.request(o.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}}))}))},e.prototype.deleteMe=function(t){return P(this,void 0,void 0,(function(){var n,r;return D(this,(function(i){return n=this.getParamsByVersion(t,"USER_ME_URL"),r="".concat(n.url,"?").concat(e.parseParamsToSearch(n.params)),[2,this.config.request(r,{method:"DELETE",withCredentials:!0})]}))}))},e.prototype.hasLoginState=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},e.prototype.transByProvider=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]}))}))},e.prototype.grantToken=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]}))}))},e.prototype.getProviders=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){return[2,this.config.request(o.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},e.prototype.unbindProvider=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},e.prototype.checkPassword=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.bindPhone=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]}))}))},e.prototype.bindEmail=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]}))}))},e.prototype.setPassword=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]}))}))},e.prototype.updatePasswordByOld=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=n.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}}))}))},e.prototype.sudo=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.getCurUserVerification=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return e.target="CUR_USER",[2,this.config.request(o.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]}))}))},e.prototype.changeBindedProvider=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request("".concat(o.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]}))}))},e.prototype.setUserProfile=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]}))}))},e.prototype.queryUserProfile=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){return t=new URLSearchParams(e),[2,this.config.request("".concat(o.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]}))}))},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){switch(n.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return t=n.sent(),[2,this.signInWithProvider(N(N({},e),{provider_id:"custom",provider_token:t}))]}}))}))},e.prototype.resetPassword=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.AUTH_RESET_PASSWORD,{method:"POST",body:e})]}))}))},e.prototype.deviceAuthorize=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.AUTH_GET_DEVICE_CODE,{method:"POST",body:e,withCredentials:!0})]}))}))},e.prototype.checkUsername=function(e){return P(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.config.request(o.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]}))}))},e.prototype.checkIfUserExist=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){return t=new URLSearchParams(e),[2,this.config.request("".concat(o.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]}))}))},e.prototype.loginScope=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){return[2,this.config.credentialsClient.getScope()]}))}))},e.prototype.loginGroups=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){return[2,this.config.credentialsClient.getGroups()]}))}))},e.prototype.refreshTokenForce=function(e){return P(this,void 0,void 0,(function(){var t;return D(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=n.sent(),[4,this.config.credentialsClient.refreshToken(N(N({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,n.sent()]}}))}))},e.prototype.getCredentials=function(){return P(this,void 0,void 0,(function(){return D(this,(function(e){return[2,this.config.credentialsClient.getCredentials()]}))}))},e}(),k=function(){},x=function(){return x=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},x.apply(this,arguments)},q=function(e){var t=e.apiOrigin,n=e.clientId,r=e.storage,i=e.request,o=e.anonymousSignInFunc;this.oauth2client=new C({apiOrigin:t,clientId:n,storage:r,baseRequest:i,anonymousSignInFunc:o}),this.authApi=new L(x(x({credentialsClient:this.oauth2client},e),{request:i?this.oauth2client.request.bind(this.oauth2client):void 0}))}},118:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(99),t)}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(118)})()));
1
+ /*! For license information please see oauth.js.LICENSE.txt */
2
+ !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,(()=>(()=>{var t={298:function(t,e,r){var n;t.exports=(n=n||function(t,e){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r.g&&r.g.crypto&&(n=r.g.crypto),!n)try{n=r(633)}catch(t){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),o={},a=o.lib={},u=a.Base={extend:function(t){var e=s(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},h=a.WordArray=u.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s++){var o=r[s>>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(var a=0;a<i;a+=4)e[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=u.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r<t;r+=4)e.push(i());return new h.init(e,t)}}),c=o.enc={},l=c.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i<r;i++){var s=e[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new h.init(r,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i<r;i++){var s=e[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new h.init(r,e)}},p=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=p.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,s=n.sigBytes,o=this.blockSize,a=s/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,s);if(u){for(var l=0;l<u;l+=o)this._doProcessBlock(i,l);r=i.splice(0,u),n.sigBytes-=c}return new h.init(r,c)},clone:function(){var t=u.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),g=(a.Hasher=d.extend({cfg:u.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new g.HMAC.init(t,r).finalize(e)}}}),o.algo={});return o}(Math),n)},171:function(t,e,r){var n;t.exports=(n=r(298),r(624),r(775),n.HmacSHA256)},775:function(t,e,r){var n,i,s;t.exports=(i=(n=r(298)).lib.Base,s=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=s.parse(e));var r=t.blockSize,n=4*r;e.sigBytes>n&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),o=this._iKey=e.clone(),a=i.words,u=o.words,h=0;h<r;h++)a[h]^=1549556828,u[h]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,r=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(r))}})))},991:function(t,e,r){var n;t.exports=(n=r(298),function(){if("function"==typeof ArrayBuffer){var t=n.lib.WordArray,e=t.init,r=t.init=function(t){if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),(t instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),t instanceof Uint8Array){for(var r=t.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=t[i]<<24-i%4*8;e.call(this,n,r)}else e.apply(this,arguments)};r.prototype=t}}(),n.lib.WordArray)},624:function(t,e,r){var n;t.exports=(n=r(298),function(t){var e=n,r=e.lib,i=r.WordArray,s=r.Hasher,o=e.algo,a=[],u=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(a[i]=r(t.pow(n,.5))),u[i]=r(t.pow(n,1/3)),i++),n++}();var h=[],c=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],c=r[5],l=r[6],f=r[7],p=0;p<64;p++){if(p<16)h[p]=0|t[e+p];else{var d=h[p-15],g=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,v=h[p-2],y=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;h[p]=g+h[p-7]+y+h[p-16]}var m=n&i^n&s^i&s,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),E=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&c^~a&l)+u[p]+h[p];f=l,l=c,c=a,a=o+E|0,o=s,s=i,i=n,n=E+(b+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+c|0,r[6]=r[6]+l|0,r[7]=r[7]+f|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=s.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=s._createHelper(c),e.HmacSHA256=s._createHmacHelper(c)}(Math),n.SHA256)},550:function(t,e){!function(t){"use strict";var e="0123456789abcdefghijklmnopqrstuvwxyz";function r(t){return e.charAt(t)}function n(t,e){return t&e}function i(t,e){return t|e}function s(t,e){return t^e}function o(t,e){return t&~e}function a(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function u(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="=";function l(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=h.charAt(r>>6)+h.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=h.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=h.charAt(r>>2)+h.charAt((3&r)<<4));(3&n.length)>0;)n+=c;return n}function f(t){var e,n="",i=0,s=0;for(e=0;e<t.length&&t.charAt(e)!=c;++e){var o=h.indexOf(t.charAt(e));o<0||(0==i?(n+=r(o>>2),s=3&o,i=1):1==i?(n+=r(s<<2|o>>4),s=15&o,i=2):2==i?(n+=r(s),n+=r(o>>2),s=3&o,i=3):(n+=r(s<<2|o>>4),n+=r(15&o),i=0))}return 1==i&&(n+=r(s<<2)),n}var p,d=function(t,e){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},d(t,e)};var g,v=function(t){var e;if(void 0===p){var r="0123456789ABCDEF",n=" \f\n\r\t \u2028\u2029";for(p={},e=0;e<16;++e)p[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)p[r.charAt(e)]=e;for(e=0;e<n.length;++e)p[n.charAt(e)]=-1}var i=[],s=0,o=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=p[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);s|=a,++o>=2?(i[i.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return i},y={decode:function(t){var e;if(void 0===g){var r="= \f\n\r\t \u2028\u2029";for(g=Object.create(null),e=0;e<64;++e)g["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<r.length;++e)g[r.charAt(e)]=-1}var n=[],i=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=g[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);i|=o,++s>=4?(n[n.length]=i>>16,n[n.length]=i>>8&255,n[n.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:n[n.length]=i>>10;break;case 3:n[n.length]=i>>16,n[n.length]=i>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=y.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 y.decode(t)}},m=1e13,b=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var r,n,i=this.buf,s=i.length;for(r=0;r<s;++r)(n=i[r]*t+e)<m?e=0:n-=(e=0|n/m)*m,i[r]=n;e>0&&(i[r]=e)},t.prototype.sub=function(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=m,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(m+e[n]).toString().substring(1);return r},t.prototype.valueOf=function(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*m+t[r];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),E="…",S=/^(\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)?)?$/,T=/^(\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 _(t,e){return t.length>e&&(t=t.substring(0,e)+E),t}var w,R=function(){function t(e,r){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=r)}return t.prototype.get=function(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]},t.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},t.prototype.hexDump=function(t,e,r){for(var n="",i=t;i<e;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n},t.prototype.isASCII=function(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r},t.prototype.parseStringUTF=function(t,e){for(var r="",n=t;n<e;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r},t.prototype.parseStringBMP=function(t,e){for(var r,n,i="",s=t;s<e;)r=this.get(s++),n=this.get(s++),i+=String.fromCharCode(r<<8|n);return i},t.prototype.parseTime=function(t,e,r){var n=this.parseStringISO(t,e),i=(r?S:T).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n},t.prototype.parseInteger=function(t,e){for(var r,n=this.get(t),i=n>127,s=i?255:0,o="";n==s&&++t<e;)n=this.get(t);if(0==(r=e-t))return i?-1:0;if(r>4){for(o=n,r<<=3;0==(128&(+o^s));)o=+o<<1,--r;o="("+r+" bit)\n"}i&&(n-=256);for(var a=new b(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return o+a.toString()},t.prototype.parseBitString=function(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",s="",o=t+1;o<e;++o){for(var a=this.get(o),u=o==e-1?n:0,h=7;h>=u;--h)s+=a>>h&1?"1":"0";if(s.length>r)return i+_(s,r)}return i+s},t.prototype.parseOctetString=function(t,e,r){if(this.isASCII(t,e))return _(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var s=t;s<e;++s)i+=this.hexByte(this.get(s));return n>r&&(i+=E),i},t.prototype.parseOID=function(t,e,r){for(var n="",i=new b,s=0,o=t;o<e;++o){var a=this.get(o);if(i.mulAdd(128,127&a),s+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof b)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return _(n,r);i=new b,s=0}}return s>0&&(n+=".incomplete"),n},t}(),I=function(){function t(t,e,r,n,i){if(!(n instanceof D))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,this.sub=i}return t.prototype.typeName=function(){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()}},t.prototype.content=function(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 _(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return _(this.stream.parseStringISO(e,e+r),t);case 30:return _(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null},t.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},t.prototype.toPrettyString=function(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,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e},t.prototype.posStart=function(){return this.stream.pos},t.prototype.posContent=function(){return this.stream.pos+this.header},t.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},t.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},t.decodeLength=function(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 n=0;n<r;++n)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)},t.decode=function(e){var r;r=e instanceof R?e:new R(e,0);var n=new R(r),i=new D(r),s=t.decodeLength(r),o=r.pos,a=o-n.pos,u=null,h=function(){var e=[];if(null!==s){for(var n=o+s;r.pos<n;)e[e.length]=t.decode(r);if(r.pos!=n)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var i=t.decode(r);if(i.tag.isEOC())break;e[e.length]=i}s=o-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(i.tagConstructed)u=h();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");u=h();for(var c=0;c<u.length;++c)if(u[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){u=null}if(null===u){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);r.pos=o+Math.abs(s)}return new t(n,a,s,i,u)},t}(),D=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new b;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),A=[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],O=(1<<26)/A[A.length-1],x=function(){function t(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))}return t.prototype.toString=function(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 n,i=(1<<e)-1,s=!1,o="",a=this.t,u=this.DB-a*this.DB%e;if(a-- >0)for(u<this.DB&&(n=this[a]>>u)>0&&(s=!0,o=r(n));a>=0;)u<e?(n=(this[a]&(1<<u)-1)<<e-u,n|=this[--a]>>(u+=this.DB-e)):(n=this[a]>>(u-=e)&i,u<=0&&(u+=this.DB,--a)),n>0&&(s=!0),s&&(o+=r(n));return s?o:"0"},t.prototype.negate=function(){var e=B();return t.ZERO.subTo(this,e),e},t.prototype.abs=function(){return this.s<0?this.negate():this},t.prototype.compareTo=function(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},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+j(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var r=B();return this.abs().divRemTo(e,null,r),this.s<0&&r.compareTo(t.ZERO)>0&&e.subTo(r,r),r},t.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new C(e):new P(e),this.exp(t,r)},t.prototype.clone=function(){var t=B();return this.copyTo(t),t},t.prototype.intValue=function(){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]},t.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},t.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},t.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},t.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.min=function(t){return this.compareTo(t)<0?this:t},t.prototype.max=function(t){return this.compareTo(t)>0?this:t},t.prototype.and=function(t){var e=B();return this.bitwiseTo(t,n,e),e},t.prototype.or=function(t){var e=B();return this.bitwiseTo(t,i,e),e},t.prototype.xor=function(t){var e=B();return this.bitwiseTo(t,s,e),e},t.prototype.andNot=function(t){var e=B();return this.bitwiseTo(t,o,e),e},t.prototype.not=function(){for(var t=B(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},t.prototype.shiftLeft=function(t){var e=B();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=B();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},t.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+a(this[t]);return this.s<0?this.t*this.DB:-1},t.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=u(this[r]^e);return t},t.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},t.prototype.setBit=function(t){return this.changeBit(t,i)},t.prototype.clearBit=function(t){return this.changeBit(t,o)},t.prototype.flipBit=function(t){return this.changeBit(t,s)},t.prototype.add=function(t){var e=B();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=B();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=B();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=B();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=B();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=B(),r=B();return this.divRemTo(t,e,r),[e,r]},t.prototype.modPow=function(t,e){var r,n,i=t.bitLength(),s=M(1);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new C(e):e.isEven()?new U(e):new P(e);var o=[],a=3,u=r-1,h=(1<<r)-1;if(o[1]=n.convert(this),r>1){var c=B();for(n.sqrTo(o[1],c);a<=h;)o[a]=B(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,p=t.t-1,d=!0,g=B();for(i=j(t[p])-1;p>=0;){for(i>=u?l=t[p]>>i-u&h:(l=(t[p]&(1<<i+1)-1)<<u-i,p>0&&(l|=t[p-1]>>this.DB+i-u)),a=r;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--p),d)o[l].copyTo(s),d=!1;else{for(;a>1;)n.sqrTo(s,g),n.sqrTo(g,s),a-=2;a>0?n.sqrTo(s,g):(f=s,s=g,g=f),n.mulTo(g,o[l],s)}for(;p>=0&&0==(t[p]&1<<i);)n.sqrTo(s,g),f=s,s=g,g=f,--i<0&&(i=this.DB-1,--p)}return n.revert(s)},t.prototype.modInverse=function(e){var r=e.isEven();if(this.isEven()&&r||0==e.signum())return t.ZERO;for(var n=e.clone(),i=this.clone(),s=M(1),o=M(0),a=M(0),u=M(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),r?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),r?(a.isEven()&&u.isEven()||(a.addTo(this,a),u.subTo(e,u)),a.rShiftTo(1,a)):u.isEven()||u.subTo(e,u),u.rShiftTo(1,u);n.compareTo(i)>=0?(n.subTo(i,n),r&&s.subTo(a,s),o.subTo(u,o)):(i.subTo(n,i),r&&a.subTo(s,a),u.subTo(o,u))}return 0!=i.compareTo(t.ONE)?t.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},t.prototype.pow=function(t){return this.exp(t,new N)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},t.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=A[A.length-1]){for(e=0;e<A.length;++e)if(r[0]==A[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<A.length;){for(var n=A[e],i=e+1;i<A.length&&n<O;)n*=A[i++];for(n=r.modInt(n);e<i;)if(n%A[e++]==0)return!1}return r.millerRabin(t)},t.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},t.prototype.fromInt=function(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},t.prototype.fromString=function(e,r){var n;if(16==r)n=4;else if(8==r)n=3;else if(256==r)n=8;else if(2==r)n=1;else if(32==r)n=5;else{if(4!=r)return void this.fromRadix(e,r);n=2}this.t=0,this.s=0;for(var i=e.length,s=!1,o=0;--i>=0;){var a=8==n?255&+e[i]:H(e,i);a<0?"-"==e.charAt(i)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,(o+=n)>=this.DB&&(o-=this.DB))}8==n&&0!=(128&+e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&t.ZERO.subTo(this,this)},t.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},t.prototype.dlShiftTo=function(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},t.prototype.drShiftTo=function(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},t.prototype.lShiftTo=function(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+s+1]=this[a]>>n|o,o=(this[a]&i)<<r;for(a=s-1;a>=0;--a)e[a]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;n>0&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},t.prototype.subTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},t.prototype.multiplyTo=function(e,r){var n=this.abs(),i=e.abs(),s=n.t;for(r.t=s+i.t;--s>=0;)r[s]=0;for(s=0;s<i.t;++s)r[s+n.t]=n.am(0,i[s],r,s,0,n.t);r.s=0,r.clamp(),this.s!=e.s&&t.ZERO.subTo(r,r)},t.prototype.squareTo=function(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 n=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,n,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()},t.prototype.divRemTo=function(e,r,n){var i=e.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=r&&r.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=B());var o=B(),a=this.s,u=e.s,h=this.DB-j(i[i.t-1]);h>0?(i.lShiftTo(h,o),s.lShiftTo(h,n)):(i.copyTo(o),s.copyTo(n));var c=o.t,l=o[c-1];if(0!=l){var f=l*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),p=this.FV/f,d=(1<<this.F1)/f,g=1<<this.F2,v=n.t,y=v-c,m=null==r?B():r;for(o.dlShiftTo(y,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),t.ONE.dlShiftTo(c,m),m.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--y>=0;){var b=n[--v]==l?this.DM:Math.floor(n[v]*p+(n[v-1]+g)*d);if((n[v]+=o.am(0,b,n,y,0,c))<b)for(o.dlShiftTo(y,m),n.subTo(m,n);n[v]<--b;)n.subTo(m,n)}null!=r&&(n.drShiftTo(c,r),a!=u&&t.ZERO.subTo(r,r)),n.t=c,n.clamp(),h>0&&n.rShiftTo(h,n),a<0&&t.ZERO.subTo(n,n)}}},t.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(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},t.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},t.prototype.exp=function(e,r){if(e>4294967295||e<1)return t.ONE;var n=B(),i=B(),s=r.convert(this),o=j(e)-1;for(s.copyTo(n);--o>=0;)if(r.sqrTo(n,i),(e&1<<o)>0)r.mulTo(i,s,n);else{var a=n;n=i,i=a}return r.revert(n)},t.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},t.prototype.toRadix=function(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),n=M(r),i=B(),s=B(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o},t.prototype.fromRadix=function(e,r){this.fromInt(0),null==r&&(r=10);for(var n=this.chunkSize(r),i=Math.pow(r,n),s=!1,o=0,a=0,u=0;u<e.length;++u){var h=H(e,u);h<0?"-"==e.charAt(u)&&0==this.signum()&&(s=!0):(a=r*a+h,++o>=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(r,o)),this.dAddOffset(a,0)),s&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,r,n){if("number"==typeof r)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),i,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var s=[],o=7&e;s.length=1+(e>>3),r.nextBytes(s),o>0?s[0]&=(1<<o)-1:s[0]=0,this.fromString(s,256)}},t.prototype.bitwiseTo=function(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},t.prototype.changeBit=function(e,r){var n=t.ONE.shiftLeft(e);return this.bitwiseTo(n,r,n),n},t.prototype.addTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},t.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},t.prototype.dAddOffset=function(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]}},t.prototype.multiplyLowerTo=function(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()},t.prototype.multiplyUpperTo=function(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},t.prototype.modInt=function(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 n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},t.prototype.millerRabin=function(e){var r=this.subtract(t.ONE),n=r.getLowestSetBit();if(n<=0)return!1;var i=r.shiftRight(n);(e=e+1>>1)>A.length&&(e=A.length);for(var s=B(),o=0;o<e;++o){s.fromInt(A[Math.floor(Math.random()*A.length)]);var a=s.modPow(i,this);if(0!=a.compareTo(t.ONE)&&0!=a.compareTo(r)){for(var u=1;u++<n&&0!=a.compareTo(r);)if(0==(a=a.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=a.compareTo(r))return!1}}return!0},t.prototype.square=function(){var t=B();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var s=r.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)e(r);else{s<o&&(o=s),o>0&&(r.rShiftTo(o,r),n.rShiftTo(o,n));var a=function(){(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),(s=n.getLowestSetBit())>0&&n.rShiftTo(s,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(o>0&&n.lShiftTo(o,n),setTimeout((function(){e(n)}),0))};setTimeout(a,10)}},t.prototype.fromNumberAsync=function(e,r,n,s){if("number"==typeof r)if(e<2)this.fromInt(1);else{this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),i,this),this.isEven()&&this.dAddOffset(1,0);var o=this,a=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(t.ONE.shiftLeft(e-1),o),o.isProbablePrime(r)?setTimeout((function(){s()}),0):setTimeout(a,0)};setTimeout(a,0)}else{var u=[],h=7&e;u.length=1+(e>>3),r.nextBytes(u),h>0?u[0]&=(1<<h)-1:u[0]=0,this.fromString(u,256)}},t}(),N=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}(),C=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}(),P=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=B();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=B();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],n=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,n,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}(),U=function(){function t(t){this.m=t,this.r2=B(),this.q3=B(),x.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=B();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 B(){return new x(null)}function L(t,e){return new x(t,e)}"Microsoft Internet Explorer"==navigator.appName?(x.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var u=32767&this[t],h=this[t++]>>15,c=a*u+h*o;i=((u=o*u+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+a*h+(i>>>30),r[n++]=1073741823&u}return i},w=30):"Netscape"!=navigator.appName?(x.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},w=26):(x.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var u=16383&this[t],h=this[t++]>>14,c=a*u+h*o;i=((u=o*u+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+a*h,r[n++]=268435455&u}return i},w=28),x.prototype.DB=w,x.prototype.DM=(1<<w)-1,x.prototype.DV=1<<w;x.prototype.FV=Math.pow(2,52),x.prototype.F1=52-w,x.prototype.F2=2*w-52;var V,k,q=[];for(V="0".charCodeAt(0),k=0;k<=9;++k)q[V++]=k;for(V="a".charCodeAt(0),k=10;k<36;++k)q[V++]=k;for(V="A".charCodeAt(0),k=10;k<36;++k)q[V++]=k;function H(t,e){var r=q[t.charCodeAt(e)];return null==r?-1:r}function M(t){var e=B();return e.fromInt(t),e}function j(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}x.ZERO=M(0),x.ONE=M(1);var F=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,r,n;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,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0},t.prototype.next=function(){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]},t}();var K,G,W=256,z=null;if(null==z){z=[],G=0;var Y=void 0;if(window.crypto&&window.crypto.getRandomValues){var Z=new Uint32Array(256);for(window.crypto.getRandomValues(Z),Y=0;Y<Z.length;++Y)z[G++]=255&Z[Y]}var Q=function(t){if(this.count=this.count||0,this.count>=256||G>=W)window.removeEventListener?window.removeEventListener("mousemove",Q,!1):window.detachEvent&&window.detachEvent("onmousemove",Q);else try{var e=t.x+t.y;z[G++]=255&e,this.count+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",Q,!1):window.attachEvent&&window.attachEvent("onmousemove",Q)}function $(){if(null==K){for(K=new F;G<W;){var t=Math.floor(65536*Math.random());z[G++]=255&t}for(K.init(z),G=0;G<z.length;++G)z[G]=0;G=0}return K.next()}var J=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=$()},t}();var X=function(){function t(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(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)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=L(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new J,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new x(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n},t.prototype.encryptLong=function(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),l(n)):l(this.encrypt(t))}catch(t){return!1}},t.prototype.decryptLong=function(t){var e=this,r=this.n.bitLength()+7>>3;t=f(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}},t.prototype.setPrivate=function(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=L(t,16),this.e=parseInt(e,16),this.d=L(r,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,r,n,i,s,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=L(t,16),this.e=parseInt(e,16),this.d=L(r,16),this.p=L(n,16),this.q=L(i,16),this.dmp1=L(s,16),this.dmq1=L(o,16),this.coeff=L(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var r=new J,n=t>>1;this.e=parseInt(e,16);for(var i=new x(e,16);;){for(;this.p=new x(t-n,1,r),0!=this.p.subtract(x.ONE).gcd(i).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,r),0!=this.q.subtract(x.ONE).gcd(i).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),u=o.multiply(a);if(0==u.gcd(i).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=L(t,16),r=this.doPrivate(e);return null==r?null:function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,r){var n=new J,i=t>>1;this.e=parseInt(e,16);var s=new x(e,16),o=this,a=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(x.ONE),n=o.q.subtract(x.ONE),i=e.multiply(n);0==i.gcd(s).compareTo(x.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(i),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(n),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=function(){o.q=B(),o.q.fromNumberAsync(i,1,n,(function(){o.q.subtract(x.ONE).gcda(s,(function(t){0==t.compareTo(x.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},h=function(){o.p=B(),o.p.fromNumberAsync(t-i,1,n,(function(){o.p.subtract(x.ONE).gcda(s,(function(t){0==t.compareTo(x.ONE)&&o.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(h,0)}))}))};setTimeout(h,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,r){var n=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var r=e-t.length-6,n="",i=0;i<r;i+=2)n+="ff";return L("0001"+n+"00"+t,16)}((tt[r]||"")+e(t).toString(),this.n.bitLength()/4);if(null==n)return null;var i=this.doPrivate(n);if(null==i)return null;var s=i.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,r){var n=L(e,16),i=this.doPublic(n);return null==i?null:function(t){for(var e in tt)if(tt.hasOwnProperty(e)){var r=tt[e],n=r.length;if(t.substr(0,n)==r)return t.substr(n)}return t}(i.toString(16).replace(/^1f+00/,""))==r(t).toString()},t}();var tt={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};var et={};et.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var n=function(){};if(n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var i;for(i in r)t.prototype[i]=r[i];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(i=0;i<o.length;i+=1){var r=o[i],n=e[r];"function"==typeof n&&n!=Object.prototype[r]&&(t[r]=n)}})}catch(t){}s(t.prototype,r)}}};var rt={};void 0!==rt.asn1&&rt.asn1||(rt.asn1={}),rt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new x(n,16).xor(t).add(x.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=rt.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERBitString,s=e.DEROctetString,o=e.DERNull,a=e.DERObjectIdentifier,u=e.DEREnumerated,h=e.DERUTF8String,c=e.DERNumericString,l=e.DERPrintableString,f=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,g=e.DERGeneralizedTime,v=e.DERSequence,y=e.DERSet,m=e.DERTaggedObject,b=e.ASN1Util.newObject,E=Object.keys(t);if(1!=E.length)throw"key of param shall be only one.";var S=E[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new r(t[S]);if("int"==S)return new n(t[S]);if("bitstr"==S)return new i(t[S]);if("octstr"==S)return new s(t[S]);if("null"==S)return new o(t[S]);if("oid"==S)return new a(t[S]);if("enum"==S)return new u(t[S]);if("utf8str"==S)return new h(t[S]);if("numstr"==S)return new c(t[S]);if("prnstr"==S)return new l(t[S]);if("telstr"==S)return new f(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new d(t[S]);if("gentime"==S)return new g(t[S]);if("seq"==S){for(var T=t[S],_=[],w=0;w<T.length;w++){var R=b(T[w]);_.push(R)}return new v({array:_})}if("set"==S){for(T=t[S],_=[],w=0;w<T.length;w++)R=b(T[w]),_.push(R);return new y({array:_})}if("tag"==S){var I=t[S];if("[object Array]"===Object.prototype.toString.call(I)&&3==I.length){var D=b(I[2]);return new m({tag:I[0],explicit:I[1],obj:D})}var A={};if(void 0!==I.explicit&&(A.explicit=I.explicit),void 0!==I.tag&&(A.tag=I.tag),void 0===I.obj)throw"obj shall be specified for 'tag'.";return A.obj=b(I.obj),new m(A)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},rt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);n+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new x(n,2).toString(10),n="")}return e},rt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new x(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},rt.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},rt.asn1.DERAbstractString=function(t){rt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},et.lang.extend(rt.asn1.DERAbstractString,rt.asn1.ASN1Object),rt.asn1.DERAbstractTime=function(t){rt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},et.lang.extend(rt.asn1.DERAbstractTime,rt.asn1.ASN1Object),rt.asn1.DERAbstractStructured=function(t){rt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},et.lang.extend(rt.asn1.DERAbstractStructured,rt.asn1.ASN1Object),rt.asn1.DERBoolean=function(){rt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},et.lang.extend(rt.asn1.DERBoolean,rt.asn1.ASN1Object),rt.asn1.DERInteger=function(t){rt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=rt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},et.lang.extend(rt.asn1.DERInteger,rt.asn1.ASN1Object),rt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=rt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}rt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},et.lang.extend(rt.asn1.DERBitString,rt.asn1.ASN1Object),rt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=rt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}rt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},et.lang.extend(rt.asn1.DEROctetString,rt.asn1.DERAbstractString),rt.asn1.DERNull=function(){rt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},et.lang.extend(rt.asn1.DERNull,rt.asn1.ASN1Object),rt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new x(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};rt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueName=function(t){var e=rt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},et.lang.extend(rt.asn1.DERObjectIdentifier,rt.asn1.ASN1Object),rt.asn1.DEREnumerated=function(t){rt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=rt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},et.lang.extend(rt.asn1.DEREnumerated,rt.asn1.ASN1Object),rt.asn1.DERUTF8String=function(t){rt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},et.lang.extend(rt.asn1.DERUTF8String,rt.asn1.DERAbstractString),rt.asn1.DERNumericString=function(t){rt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},et.lang.extend(rt.asn1.DERNumericString,rt.asn1.DERAbstractString),rt.asn1.DERPrintableString=function(t){rt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},et.lang.extend(rt.asn1.DERPrintableString,rt.asn1.DERAbstractString),rt.asn1.DERTeletexString=function(t){rt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},et.lang.extend(rt.asn1.DERTeletexString,rt.asn1.DERAbstractString),rt.asn1.DERIA5String=function(t){rt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},et.lang.extend(rt.asn1.DERIA5String,rt.asn1.DERAbstractString),rt.asn1.DERUTCTime=function(t){rt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},et.lang.extend(rt.asn1.DERUTCTime,rt.asn1.DERAbstractTime),rt.asn1.DERGeneralizedTime=function(t){rt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},et.lang.extend(rt.asn1.DERGeneralizedTime,rt.asn1.DERAbstractTime),rt.asn1.DERSequence=function(t){rt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},et.lang.extend(rt.asn1.DERSequence,rt.asn1.DERAbstractStructured),rt.asn1.DERSet=function(t){rt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},et.lang.extend(rt.asn1.DERSet,rt.asn1.DERAbstractStructured),rt.asn1.DERTaggedObject=function(t){rt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},et.lang.extend(rt.asn1.DERTaggedObject,rt.asn1.ASN1Object);var nt=function(t){function e(r){var n=t.call(this)||this;return r&&("string"==typeof r?n.parseKey(r):(e.hasPrivateKeyProperty(r)||e.hasPublicKeyProperty(r))&&n.parsePropertiesFrom(r)),n}return function(t,e){function r(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?v(t):y.unarmor(t),i=I.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=L(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var s=i.sub[3].getHexStringValue();this.d=L(s,16);var o=i.sub[4].getHexStringValue();this.p=L(o,16);var a=i.sub[5].getHexStringValue();this.q=L(a,16);var u=i.sub[6].getHexStringValue();this.dmp1=L(u,16);var h=i.sub[7].getHexStringValue();this.dmq1=L(h,16);var c=i.sub[8].getHexStringValue();this.coeff=L(c,16)}else{if(2!==i.sub.length)return!1;var l=i.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=L(e,16),r=l.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new rt.asn1.DERInteger({int:0}),new rt.asn1.DERInteger({bigint:this.n}),new rt.asn1.DERInteger({int:this.e}),new rt.asn1.DERInteger({bigint:this.d}),new rt.asn1.DERInteger({bigint:this.p}),new rt.asn1.DERInteger({bigint:this.q}),new rt.asn1.DERInteger({bigint:this.dmp1}),new rt.asn1.DERInteger({bigint:this.dmq1}),new rt.asn1.DERInteger({bigint:this.coeff})]};return new rt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return l(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new rt.asn1.DERSequence({array:[new rt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new rt.asn1.DERNull]}),e=new rt.asn1.DERSequence({array:[new rt.asn1.DERInteger({bigint:this.n}),new rt.asn1.DERInteger({int:this.e})]}),r=new rt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new rt.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return l(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return(t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n")+"-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return(t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n")+"-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(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")},e.prototype.parsePropertiesFrom=function(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)},e}(X),it=function(){function t(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}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new nt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return l(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},t.prototype.decryptLong=function(t){try{return this.getKey().decryptLong(t)}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return l(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,f(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new nt,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},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.1.4",t}();window.JSEncrypt=it,t.JSEncrypt=it,t.default=it,Object.defineProperty(t,"__esModule",{value:!0})}(e)},261:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Auth:()=>M,AuthClient:()=>j,CloudbaseOAuth:()=>K,ErrorType:()=>i,OAuth2Client:()=>I,Syntax:()=>n,authModels:()=>h,defaultRequest:()=>E,defaultStorage:()=>_,generateRequestId:()=>T,toResponseError:()=>S});var n,i,s,o,a,u,h={};function c(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}r.r(h),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"}(n||(n={})),function(t){t.UNREACHABLE="unreachable",t.LOCAL="local",t.CANCELLED="cancelled",t.UNKNOWN="unknown",t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.UNAUTHENTICATED="unauthenticated",t.RESOURCE_EXHAUSTED="resource_exhausted",t.FAILED_PRECONDITION="failed_precondition",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked",t.INVALID_VERIFICATION_CODE="invalid_verification_code",t.TWO_FACTOR_REQUIRED="two_factor_required",t.INVALID_TWO_FACTOR="invalid_two_factor",t.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",t.UNDER_REVIEW="under_review",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.ACCESS_DENIED="access_denied",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.INVALID_SCOPE="invalid_scope",t.INVALID_GRANT="invalid_grant",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.INTERACTION_REQUIRED="interaction_required",t.LOGIN_REQUIRED="login_required",t.ACCOUNT_SELECTION_REQUIRED="account_selection_required",t.CONSENT_REQUIRED="consent_required",t.INVALID_REQUEST_URI="invalid_request_uri",t.INVALID_REQUEST_OBJECT="invalid_request_object",t.REQUEST_NOT_SUPPORTED="request_not_supported",t.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",t.REGISTRATION_NOT_SUPPORTED="registration_not_supported"}(i||(i={})),function(t){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_UP_URL="/auth/v1/signup",t.AUTH_TOKEN_URL="/auth/v1/token",t.AUTH_REVOKE_URL="/auth/v1/revoke",t.PROVIDER_BIND_URL="/auth/v1/user/provider/bind",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.WEDA_USER_URL="/auth/v1/plugin/weda/userinfo",t.USER_QUERY_URL="/auth/v1/user/query",t.USER_PRIFILE_URL="/auth/v1/user/profile",t.USER_TRANS_BY_PROVIDER_URL="/auth/v1/user/trans/by/provider",t.VERIFICATION_URL="/auth/v1/verification",t.VERIFY_URL="/auth/v1/verification/verify",t.PROVIDER_LIST="/auth/v1/user/provider",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.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"}(s||(s={})),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"}(o||(o={})),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"}(a||(a={})),function(t){t.INVALID_ARGUMENT="invalid_argument",t.DEADLINE_EXCEEDED="deadline_exceeded",t.NOT_FOUND="not_found",t.ALREADY_EXISTS="already_exists",t.PERMISSION_DENIED="permission_denied",t.ABORTED="aborted",t.OUT_OF_RANGE="out_of_range",t.UNIMPLEMENTED="unimplemented",t.INTERNAL="internal",t.UNAVAILABLE="unavailable",t.DATA_LOSS="data_loss",t.CAPTCHA_REQUIRED="captcha_required",t.CAPTCHA_INVALID="captcha_invalid",t.INVALID_PASSWORD="invalid_password",t.PASSWORD_NOT_SET="password_not_set",t.INVALID_STATUS="invalid_status",t.USER_PENDING="user_pending",t.USER_BLOCKED="user_blocked"}(u||(u={}));var l=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},f=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},p=function(){function t(){this.fnPromiseMap=new Map}return t.prototype.run=function(t,e){return l(this,void 0,void 0,(function(){var r,n=this;return f(this,(function(i){switch(i.label){case 0:return[4,r=this.fnPromiseMap.get(t)];case 1:return i.sent()||(r=new Promise((function(r,i){l(n,void 0,void 0,(function(){var n,s,o;return f(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),n=e(),s=r,[4,n];case 2:return s.apply(void 0,[a.sent()]),[3,5];case 3:return o=a.sent(),i(o),[3,5];case 4:return this.fnPromiseMap.delete(t),[7];case 5:return[2]}}))}))})),this.fnPromiseMap.set(t,r)),[2,r]}}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),d=function(){return d=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},d.apply(this,arguments)},g=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},v=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},y="x-request-id",m="x-device-id",b="device_id",E=function(t,e){return g(this,void 0,void 0,(function(){var r,n,s,o,a;return v(this,(function(u){switch(u.label){case 0:r=null,n=null,u.label=1;case 1:return u.trys.push([1,4,,5]),(s=Object.assign({},e)).method||(s.method="GET"),s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body)),[4,fetch(t,s)];case 2:return[4,u.sent().json()];case 3:return(null==(o=u.sent())?void 0:o.error)?(n=o).error_uri=new URL(t).pathname:r=o,[3,5];case 4:return a=u.sent(),n={error:i.UNREACHABLE,error_description:a.message,error_uri:new URL(t).pathname},[3,5];case 5:if(n)throw n;return[2,r]}}))}))},S=function(t,e){var r,n=e||{};if(t instanceof Error)r={error:n.error||i.LOCAL,error_description:n.error_description||t.message,error_uri:n.error_uri,details:n.details||t.stack};else{var s=t||{};r={error:n.error||s.error||i.LOCAL,error_description:n.error_description||s.error_description,error_uri:n.error_uri||s.error_uri,details:n.details||s.details}}return r};function T(){return c()}var _=new(function(){function t(){}return t.prototype.getItem=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return[2,window.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return window.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return g(this,void 0,void 0,(function(){return v(this,(function(r){return window.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem(t)},t.prototype.removeItemSync=function(t){window.localStorage.removeItem(t)},t.prototype.setItemSync=function(t,e){window.localStorage.setItem(t,e)},t}());function w(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var R=function(){function t(t){this.credentials=null,this.singlePromise=new p,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return g(this,void 0,void 0,(function(){var e;return v(this,(function(r){switch(r.label){case 0:return(null==t?void 0:t.expires_in)?(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30)),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}}))}))},t.prototype.getCredentials=function(){return g(this,void 0,void 0,(function(){var t=this;return v(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return g(t,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return w(this.credentials)?(t=this,[4,this.getStorageCredentials()]):[3,2];case 1:t.credentials=e.sent(),e.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return g(this,void 0,void 0,(function(){var t=this;return v(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return g(t,void 0,void 0,(function(){var t,e;return v(this,(function(r){switch(r.label){case 0:return t=null,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return r.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),t=null,[3,5];case 5:return[2,t]}}))}))}))]}))}))},t}(),I=function(){function t(e){this.singlePromise=new p,this.apiOrigin=e.apiOrigin,this.clientId=e.clientId,this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=E,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||_,this.localCredentials=new R({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage}),this.clientSecret=e.clientSecret,this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc}return t.prototype.setCredentials=function(t){return this.localCredentials.setCredentials(t)},t.prototype.getAccessToken=function(){return g(this,void 0,void 0,(function(){var t,e;return v(this,(function(r){switch(r.label){case 0:return[4,this.getCredentials()];case 1:return(null==(t=r.sent())?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:i.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,r){return g(this,void 0,void 0,(function(){var n,s,o,a,u,h,c;return v(this,(function(l){switch(l.label){case 0:return r||(r={}),n=this.formatRetry(r.retry,this.retry),r.headers=r.headers||{},this.headers&&(r.headers=d(d({},this.headers),r.headers)),r.headers[y]||(r.headers[y]=T()),r.headers[m]?[3,2]:[4,this.getDeviceId()];case 1:s=l.sent(),r.headers[m]=s,l.label=2;case 2:return(null==r?void 0:r.withCredentials)?[4,this.getCredentials()]:[3,4];case 3:return(o=l.sent())&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(o.access_token)):r.headers.Authorization="".concat(o.token_type," ").concat(o.access_token)),[3,5];case 4:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId)),l.label=5;case 5:e.startsWith("/")&&(e=this.apiOrigin+e),a=null,u=n+1,h=0,l.label=6;case 6:if(!(h<u))return[3,15];l.label=7;case 7:return l.trys.push([7,9,,12]),[4,this.baseRequest(e,r)];case 8:return a=l.sent(),[3,15];case 9:return c=l.sent(),r.withCredentials&&c&&c.error===i.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,11];case 10:return l.sent(),[2,Promise.reject(c)];case 11:return h!==n&&c&&"unreachable"===c.error?[3,12]:[2,Promise.reject(c)];case 12:return[4,this.sleep(t.retryInterval)];case 13:l.sent(),l.label=14;case 14:return h++,[3,6];case 15:return[2,a]}}))}))},t.prototype.getCredentials=function(){return g(this,void 0,void 0,(function(){var t,e,r;return v(this,(function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return w(t=n.sent())?t&&"anonymous"===t.scope?this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,5]:[3,8]:[3,10];case 2:return e=n.sent(),(r=e)?[3,4]:[4,this.localCredentials.getCredentials()];case 3:r=n.sent(),n.label=4;case 4:return t=r,[3,7];case 5:return[4,this.anonymousSignIn(t)];case 6:t=n.sent(),n.label=7;case 7:return[3,10];case 8:return[4,this.refreshToken(t)];case 9:t=n.sent(),n.label=10;case 10:return[2,t]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){return g(this,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.scope]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.getGroups=function(){return g(this,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=e.sent())?[2,t.groups]:[2,this.unAuthenticatedError("credentials not found")]}}))}))},t.prototype.refreshToken=function(t){return g(this,void 0,void 0,(function(){var e=this;return v(this,(function(r){return[2,this.singlePromise.run("_refreshToken",(function(){return g(e,void 0,void 0,(function(){var e,r;return v(this,(function(n){switch(n.label){case 0:if(!t||!t.refresh_token)return[2,this.unAuthenticatedError("no refresh token found in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return e=n.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return n.sent(),[2,e];case 4:return(r=n.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.checkRetry=function(e){var r=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(r={error:i.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return g(this,void 0,void 0,(function(){return v(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.anonymousSignIn=function(t){return g(this,void 0,void 0,(function(){var e=this;return v(this,(function(r){return[2,this.singlePromise.run("_anonymous",(function(){return g(e,void 0,void 0,(function(){var e,r;return v(this,(function(n){switch(n.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.request("/auth/v1/signin/anonymously",{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret}})];case 2:return e=n.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return n.sent(),[2,e];case 4:return(r=n.sent()).error!==i.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t,e){return g(this,void 0,void 0,(function(){var r,n;return v(this,(function(i){switch(i.label){case 0:return void 0===t||""===t?[2,this.unAuthenticatedError("refresh token not found")]:(r=s.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(r=o.AUTH_TOKEN_URL),[4,this.request(r,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return n=i.sent(),[2,d(d({},n),{version:(null==e?void 0:e.version)||"v1"})]}}))}))},t.prototype.getDeviceId=function(){return g(this,void 0,void 0,(function(){var t;return v(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(b)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=c(),[4,this.storage.setItem(b,t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:i.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}(),D=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},A=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},O=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=_),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}return t.prototype.request=function(t,e){return D(this,void 0,void 0,(function(){var r,n,i,s;return A(this,(function(o){switch(o.label){case 0:return e||(e={}),e.method||(e.method="GET"),r="".concat(e.method,":").concat(t),n=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,r,!1)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(n,e)];case 3:return i=o.sent(),[3,7];case 4:return"captcha_required"!==(s=o.sent()).error&&"captcha_invalid"!==s.error?[3,6]:[4,this.appendCaptchaTokenToURL(t,r,"captcha_invalid"===s.error)];case 5:return t=o.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(s)];case 7:return[2,i]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){if(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap")){var 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((function(){document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback},t.prototype.defaultOpenURIWithCallback=function(t){return D(this,void 0,void 0,(function(){var e,r;return A(this,(function(n){return e=document.getElementById("captcha_panel_wrap"),r=document.createElement("iframe"),e.innerHTML="",r.setAttribute("src",t),r.setAttribute("id","review-panel-iframe"),r.style.cssText="min-width:355px;display:block;height:355px;margin:0 auto;background-color: rgb(255, 255, 255);border: none;",e.appendChild(r),e.style.display="block",[2,new Promise((function(t,n){r.onload=function(){try{var i=window.location,s=r.contentWindow.location;if(s.host+s.pathname===i.host+i.pathname){e.style.display="none";var o=new URLSearchParams(s.search),a=o.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(o.get("expires_in"))}):n({error:o.get("error"),error_description:o.get("error_description")})}e.style.display="block"}catch(t){e.style.display="block"}}}))]}))}))},t.prototype.getCaptchaToken=function(t,e){return D(this,void 0,void 0,(function(){var r,n,i,s,o;return A(this,(function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=a.sent())return[2,r];a.label=2;case 2:return n="".concat(window.location.origin+window.location.pathname,"?__captcha=on"),[4,this.config.request("/auth/v1/captcha/init",{method:"POST",body:{client_id:this.config.clientId,redirect_uri:n,state:e},withCredentials:!1})];case 3:return(i=a.sent()).captcha_token?(s={captcha_token:i.captcha_token,expires_in:i.expires_in},this.saveCaptchaToken(s),[2,i.captcha_token]):[4,this.config.openURIWithCallback(i.url)];case 4:return o=a.sent(),this.saveCaptchaToken(o),[2,o.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,r){return D(this,void 0,void 0,(function(){var n;return A(this,(function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,e)];case 1:return n=i.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(n):t+="?captcha_token=".concat(n),[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return D(this,void 0,void 0,(function(){var e;return A(this,(function(r){switch(r.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return D(this,void 0,void 0,(function(){var t,e;return A(this,(function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}}))}))},t}(),x=function(t){var e=function(e){for(var r in t)t.hasOwnProperty(r)&&(e[r]=x(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}},N=r(550),C=r.n(N),P=r(171),U=r.n(P),B=r(991),L=r.n(B),V=function(t){var e=void 0===t?{}:t,r=e.publicKey,n=void 0===r?"":r,i=e.payload,s=void 0===i?{}:i;if(!n)return"";try{var o=x(s),a=new(C());a.setPublicKey(n),o.timestamp=+new Date;var u=L().random(16).toString(),h=U()(JSON.stringify(o),u).toString();return o.signature=h,o.nonce=u,o.signMethod="HmacSHA256",a.encryptLong(JSON.stringify(o))}catch(t){}return""},k=function(){return k=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},k.apply(this,arguments)},q=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))},H=function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=function(){function t(t){var e=t.request,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,clientId:t.clientId,storage:t.storage};r=new I(n)}if(!e){var i=r.request.bind(r),s=new O({clientId:t.clientId,request:i,storage:t.storage});e=s.request.bind(s)}this.config={apiOrigin:t.apiOrigin,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||_}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new URLSearchParams(t).toString()},t.prototype.getParamsByVersion=function(t,e){var r,n=x(t),i=(null===(r={v2:o}[null==n?void 0:n.version])||void 0===r?void 0:r[e])||s[e];return n&&delete n.version,{params:n,url:i}},t.prototype.signIn=function(t){return q(this,void 0,void 0,(function(){var e,r,n,i;return H(this,(function(s){switch(s.label){case 0:return e=t.version||"v1",(r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return n=s.sent(),[4,this.config.request(r.url,{method:"POST",body:n})];case 2:return i=s.sent(),[4,this.config.credentialsClient.setCredentials(k(k({},i),{version:e}))];case 3:return s.sent(),[2,Promise.resolve(i)]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),q(this,void 0,void 0,(function(){var e;return H(this,(function(r){switch(r.label){case 0:return[4,this.config.request(s.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signUp=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){switch(r.label){case 0:return[4,this.config.request(s.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(){return q(this,void 0,void 0,(function(){var t,e;return H(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getAccessToken()];case 1:return t=r.sent(),[4,this.config.request(s.AUTH_REVOKE_URL,{method:"POST",body:{token:t}})];case 2:return e=r.sent(),[4,this.config.credentialsClient.setCredentials()];case 3:return r.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.getVerification=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){switch(r.label){case 0:return e=!1,"CUR_USER"!==t.target?[3,1]:(e=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:r.sent()&&(e=!0),r.label=3;case 3:return[2,this.config.request(s.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:!0,withCredentials:e})]}}))}))},t.prototype.verify=function(t){return q(this,void 0,void 0,(function(){var e,r;return H(this,(function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(k(k({},r),{version:"v2"}))];case 2:n.sent(),n.label=3;case 3:return[2,r]}}))}))},t.prototype.genProviderRedirectUri=function(t){return q(this,void 0,void 0,(function(){var e,r;return H(this,(function(n){return e="".concat(s.PROVIDER_URI_URL,"?client_id=").concat(this.config.clientId,"&provider_id=").concat(t.provider_id,"&redirect_uri=").concat(encodeURIComponent(t.provider_redirect_uri),"&state=").concat(t.state),(r=t.other_params)&&"string"==typeof r.sign_out_uri&&r.sign_out_uri.length>0&&(e+="&other_params[sign_out_uri]=".concat(r.sign_out_uri)),[2,this.config.request(e,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.PROVIDER_TOKEN_URL,{method:"POST",body:t})]}))}))},t.prototype.patchProviderToken=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t){return q(this,void 0,void 0,(function(){var e,r;return H(this,(function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(k(k({},r),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return n.sent(),[2,Promise.resolve(r)]}}))}))},t.prototype.bindWithProvider=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.getUserProfile=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.getUserInfo(t)]}))}))},t.prototype.getUserInfo=function(t){var e;return void 0===t&&(t={}),q(this,void 0,void 0,(function(){var r,n,i;return H(this,(function(s){switch(s.label){case 0:return r=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=r.params)||void 0===e?void 0:e.query)&&(n=new URLSearchParams(r.params.query),r.url+="?".concat(n.toString())),[4,this.config.request(r.url,{method:"GET",withCredentials:!0})];case 1:return(i=s.sent()).sub&&(i.uid=i.sub),[2,i]}}))}))},t.prototype.getWedaUserInfo=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){switch(t.label){case 0:return[4,this.config.request(s.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.deleteMe=function(e){return q(this,void 0,void 0,(function(){var r,n;return H(this,(function(i){return r=this.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(t.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]}))}))},t.prototype.getProviders=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this.config.request(s.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.bindPhone=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.bindEmail=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){switch(r.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=r.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.getCurUserVerification=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return t.target="CUR_USER",[2,this.config.request(s.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBindedProvider=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request("".concat(s.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.queryUserProfile=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){return e=new URLSearchParams(t),[2,this.config.request("".concat(s.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){switch(r.label){case 0:return[4,this.getCustomSignTicketFn()];case 1:return e=r.sent(),[2,this.signInWithProvider(k(k({},t),{provider_id:"custom",provider_token:e}))]}}))}))},t.prototype.resetPassword=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})]}))}))},t.prototype.checkUsername=function(t){return q(this,void 0,void 0,(function(){return H(this,(function(e){return[2,this.config.request(s.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){return e=new URLSearchParams(t),[2,this.config.request("".concat(s.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t.prototype.refreshTokenForce=function(t){return q(this,void 0,void 0,(function(){var e;return H(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=r.sent(),[4,this.config.credentialsClient.refreshToken(k(k({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,r.sent()]}}))}))},t.prototype.getCredentials=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this.config.credentialsClient.getCredentials()]}))}))},t.prototype.getPublicKey=function(){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]}))}))},t.prototype.getEncryptParams=function(t){return q(this,void 0,void 0,(function(){var e,r,n,i;return H(this,(function(s){switch(s.label){case 0:if(!(e=x(t)).isEncrypt)return[2,t];r="",n="",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.getPublicKey()];case 2:return i=s.sent(),r=i.public_key,n=i.public_key_thumbprint,[3,4];case 3:return s.sent(),[3,4];case 4:if(!r||!n)throw new Error("public_key or public_key_thumbprint is empty");return delete e.isEncrypt,[2,{params:V({publicKey:r,payload:e}),public_key_thumbprint:n}]}}))}))},t}(),j=function(){},F=function(){return F=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},F.apply(this,arguments)},K=function(t){var e=t.apiOrigin,r=t.clientId,n=t.storage,i=t.request,s=t.baseRequest,o=t.anonymousSignInFunc;this.oauth2client=new I({apiOrigin:e,clientId:r,storage:n,baseRequest:s||i,anonymousSignInFunc:o}),this.authApi=new M(F(F({credentialsClient:this.oauth2client},t),{request:i?this.oauth2client.request.bind(this.oauth2client):void 0}))}},118:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(261),e)},633:()=>{}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),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.5.36-beta.0",
3
+ "version": "2.5.38-alpha.1",
4
4
  "description": "cloudbase javascript sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -46,15 +46,15 @@
46
46
  "license": "Apache-2.0",
47
47
  "dependencies": {
48
48
  "@cloudbase/adapter-interface": "^0.4.1",
49
- "@cloudbase/analytics": "^2.5.36-beta.0",
50
- "@cloudbase/app": "^2.5.36-beta.0",
51
- "@cloudbase/auth": "^2.5.36-beta.0",
49
+ "@cloudbase/analytics": "^2.5.38-alpha.1",
50
+ "@cloudbase/app": "^2.5.38-alpha.1",
51
+ "@cloudbase/auth": "^2.5.38-alpha.1",
52
52
  "@cloudbase/database": "0.9.20",
53
- "@cloudbase/functions": "^2.5.36-beta.0",
54
- "@cloudbase/realtime": "^2.5.36-beta.0",
55
- "@cloudbase/storage": "^2.5.36-beta.0",
56
- "@cloudbase/types": "^2.5.36-beta.0",
57
- "@cloudbase/utilities": "^2.5.36-beta.0"
53
+ "@cloudbase/functions": "^2.5.38-alpha.1",
54
+ "@cloudbase/realtime": "^2.5.38-alpha.1",
55
+ "@cloudbase/storage": "^2.5.38-alpha.1",
56
+ "@cloudbase/types": "^2.5.38-alpha.1",
57
+ "@cloudbase/utilities": "^2.5.38-alpha.1"
58
58
  },
59
59
  "browserslist": [
60
60
  "last 2 version",
@@ -62,5 +62,5 @@
62
62
  "not dead",
63
63
  "chrome 53"
64
64
  ],
65
- "gitHead": "3e5ff75cbbc978aef1fd0d6cf12b8ce9f6f2f86d"
65
+ "gitHead": "0d182ece790ba8a0ef254f63f6a06ab3e878a302"
66
66
  }
@@ -0,0 +1 @@
1
+ export * from '@cloudbase/oauth';
@@ -0,0 +1,9 @@
1
+ import cloudbase from '@cloudbase/app';
2
+ import { ICloudbase } from '@cloudbase/types';
3
+ declare global {
4
+ interface Window {
5
+ cloudbase: ICloudbase;
6
+ }
7
+ }
8
+ export = cloudbase;
9
+ export default cloudbase;