nb-js-client 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,6 +23,10 @@ api.request.use((params: RequestParams) => {
23
23
 
24
24
  // Перехват ответа (обработка параметров ответа)
25
25
  api.response.use((params: Response) => {
26
+ if (!params.ok) {
27
+ return Promise.reject({...params});
28
+ }
29
+
26
30
  return Promise.resolve({...params});
27
31
 
28
32
  }, (error) => return Promise.reject(error))
@@ -1 +1 @@
1
- "use strict";const e="/login",t=`${e}/ldap`,s=`${e}/update`;class i{constructor(e){this.client=e}info(){return this.client.rest.get(e)}login(t){return this.client.rest.post(e,JSON.stringify(t))}ldapLogin(e){return this.client.rest.post(t,JSON.stringify(e))}updateToken(e){return this.client.rest.post(s,JSON.stringify(e))}logout(){return this.client.rest.post("/logout")}}var r,n,o,c,a,l,d,p,h,u,g,f,x,y,v,S,_,$,k,m,w,O,A,T,N,E;exports.OrderDirection=void 0,(r=exports.OrderDirection||(exports.OrderDirection={})).DEFAULT="",r.ASC="asc",r.DESC="desc",exports.EngineType=void 0,(n=exports.EngineType||(exports.EngineType={})).WebSocket="websocket",n.PostMessage="postmessage",n.Empty="",exports.ConnectionGroup=void 0,(o=exports.ConnectionGroup||(exports.ConnectionGroup={})).Storages="storages_connections_group",o.Webhooks="webhooks_connections_group",o.Unknown="unknown_connections_group",o.Proxy="proxy_connections_group",exports.ConnectionType=void 0,(c=exports.ConnectionType||(exports.ConnectionType={})).SSH="ssh_connection",c.YandexDisk="yandex_disk",c.Mail="mail",c.Discord="discord",c.Webdav="webdav_connection",c.Nextcloud="nextcloud_connection",c.NextBox="nextbox_connection",c.HttpProxy="http_proxy_connection",c.S3="s3_connection",exports.ExtensionType=void 0,(a=exports.ExtensionType||(exports.ExtensionType={})).App="app",a.File="file",a.WorkDir="work_dir",exports.ExtensionFileMode=void 0,(l=exports.ExtensionFileMode||(exports.ExtensionFileMode={})).Read="read",l.ReadAndWrite="read_and_write",l.Write="write",exports.DivideScope=void 0,(d=exports.DivideScope||(exports.DivideScope={})).Storage="/storage/element",d.Connection="/connections",exports.PermissionType=void 0,(p=exports.PermissionType||(exports.PermissionType={})).CLOSE="",p.READ="r",p.WRITE="rw",exports.RestrictionStatus=void 0,(h=exports.RestrictionStatus||(exports.RestrictionStatus={})).WAITING="waiting",h.APPROVED="approved",h.REJECTED="rejected",exports.RestrictionBooleanStatus=void 0,(u=exports.RestrictionBooleanStatus||(exports.RestrictionBooleanStatus={})).TRUE="true",u.FALSE="false",exports.DivideMode=void 0,(g=exports.DivideMode||(exports.DivideMode={})).User="to_user_id",g.Group="to_user_group_id",exports.Tariff=void 0,(f=exports.Tariff||(exports.Tariff={})).Free="free",f.Business="business",f.Enterprise="enterprise",exports.LicenseError=void 0,(x=exports.LicenseError||(exports.LicenseError={})).NotActivated="License not activated",x.Blocked="License blocked",x.Expired="License has been expired",x.NotValid="License not valid",x.NotFound="license file not found",exports.NotificationEntityType=void 0,(y=exports.NotificationEntityType||(exports.NotificationEntityType={})).Dir="dir",y.File="file",y.User="user",y.Other="other",y.WorkDir="work_dir",y.License="license",y.Extension="extension",y.Connection="connection",exports.NotificationAction=void 0,(v=exports.NotificationAction||(exports.NotificationAction={})).OpenSharing="open_sharing",v.ChangeSharing="change_sharing",v.CancelSharing="cancel_sharing",v.DivideDirAddFileToOwner="divide_dir_add_file_to_owner",v.DivideDirAddDirToOwner="divide_dir_add_dir_to_owner",v.DivideDirAddWorkDirToOwner="divide_dir_add_work_dir_to_owner",v.DivideConnectionAddFileToOwner="divide_connection_add_file_to_owner",v.DivideConnectionAddDirToOwner="divide_connection_add_dir_to_owner",v.CancelDivideDir="cancel_divide_dir",v.CancelDivideFile="cancel_divide_file",v.CancelDivideWorkDir="cancel_divide_work_dir",v.CancelDivideConnection="cancel_divide_connection",v.DeleteExtension="delete_extension",v.NewVersionExtension="new_version_extension",v.Other="other",exports.NotificationRowAction=void 0,(S=exports.NotificationRowAction||(exports.NotificationRowAction={})).Read="read",S.Unread="unread",S.Delete="delete",exports.NotificationStyle=void 0,(_=exports.NotificationStyle||(exports.NotificationStyle={})).Plain="plain",_.Success="success",_.Info="info",_.Warning="warning",_.Error="error",exports.RestrictionSharing=void 0,($=exports.RestrictionSharing||(exports.RestrictionSharing={})).NONE="none",$.SOFT="soft",$.HARD="hard",exports.UserAuthType=void 0,(k=exports.UserAuthType||(exports.UserAuthType={})).Native="native",k.Ldap="ldap",exports.UserStatus=void 0,(m=exports.UserStatus||(exports.UserStatus={})).Registering="registering",m.Activated="activated",m.Blocked="blocked",m.BlockedByLicense="blocked_by_license",exports.UserType=void 0,(w=exports.UserType||(exports.UserType={})).User="user",w.Guest="guest",w.Emperor="emperor",w.Anonymous="anonymous",exports.SettingControlType=void 0,(O=exports.SettingControlType||(exports.SettingControlType={})).Text="text",O.String="string",O.Number="number",O.CheckBox="checkbox",O.Select="select",O.RadioList="radio_list",O.ConnectionChoose="connection_choose",O.MultiConnectionChoose="multi_connection_choose",exports.StorageElementType=void 0,(A=exports.StorageElementType||(exports.StorageElementType={})).Dir="dir",A.File="file",A.WorkDir="work_dir",exports.StorageElementContentType=void 0,(T=exports.StorageElementContentType||(exports.StorageElementContentType={})).Any="any",T.Dir="dir",T.Code="code",T.Image="image",T.Audio="audio",T.Video="video",T.Text="text",T.Doc="doc",T.Xls="xls",T.Ppt="ppt",exports.StorageRoot=void 0,(N=exports.StorageRoot||(exports.StorageRoot={})).my="my",N.fca="fca",N.divide="divide",N.share="share",N.favorite="favorite",exports.StorageElementHistoryAction=void 0,(E=exports.StorageElementHistoryAction||(exports.StorageElementHistoryAction={})).Create="create",E.Update="update",E.Move="move";const b="/connections",D=`${b}/dashboard`;class C{constructor(e){this.client=e}list(e){return this.client.rest.get(b,e)}get(e){return this.client.rest.get(`${b}/${e}`)}update(e,t){return this.client.rest.put(`${b}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${b}/${e}`)}create(e){const t={[exports.ConnectionType.SSH]:"/disk/ssh",[exports.ConnectionType.Webdav]:"/disk/webdav",[exports.ConnectionType.Nextcloud]:"/disk/nextcloud",[exports.ConnectionType.NextBox]:"/disk/nextbox",[exports.ConnectionType.Discord]:"/webhooks/discord",[exports.ConnectionType.Mail]:"/webhooks/mail",[exports.ConnectionType.HttpProxy]:"/http_proxy",[exports.ConnectionType.S3]:"/disk/s3"};return this.client.rest.post(t[e.type]||b,JSON.stringify(e))}dashboard(e){return this.client.rest.get(D,e)}}class J{constructor(e){this.client=e}discovery(e){return this.client.rest.get("/discovery",e)}}class U{constructor(e){this.client=e}divideDelete(e,t){return this.client.rest.delete(`${e}/divide/${t}`)}divideDeleteAll(e,t,s,i){return this.client.rest.delete(`${e}/divide`,Object.assign(Object.assign({},this.makeParam(e,t)),{is_to_user_group:i,access_mode:s}))}divideChange(e,t,s){return this.client.rest.put(`${e}/divide/${t}`,JSON.stringify({access_mode:s}))}divideCreate(e,t,s,i,r){const n=Object.assign(Object.assign({},this.makeParam(e,t)),{[r]:s,access_mode:i});return this.client.rest.post(`${e}/divide`,JSON.stringify(n))}divideUsers(e,t,s){return this.client.rest.get(`${e}/divide/users`,Object.assign(Object.assign({},this.makeParam(e,t)),s))}restrictions(e){return this.client.rest.get("/divide/restrictions",e)}restrictionsChange(e,t){return this.client.rest.put(`/divide/restrictions/${e}`,JSON.stringify(t))}makeParam(e,t){const s={};return e===exports.DivideScope.Connection?s.connection_id=t:s.path=t,s}}const R="/static/extensions",P="/extensions/defaults";class I{constructor(e){this.client=e}getSetting(e){return this.client.rest.get(`${R}/${e}/settings`)}setSetting(e,t){return this.client.rest.post(`${R}/${e}/settings`,JSON.stringify(t))}deleteSetting(e){return this.client.rest.delete(`${R}/${e}/settings`)}get(e){return this.client.rest.get(`${R}/${e}`)}getByKey(e){return this.client.rest.get(`${R}/${e}`)}getDefault(e=[]){return this.client.rest.get(P,{ext_code:e})}setDefault(e,t){return this.client.rest.post(P,JSON.stringify({ext_code:e,ext_uniq_key:t}))}checkUpdates(){return this.client.rest.post("/static/extensions/check_updates")}updateVersion(e,t){return this.client.rest.put(`/static/extensions/${e}`,JSON.stringify({version:t}))}list(e){return this.client.rest.get(R,e)}delete(e,t){return this.client.rest.delete(`${R}/${e}`)}upload(e){const t=new FormData;return t.set("file",e),this.client.rest.post(R,t)}install(e,t){return this.client.rest.post("/static/extensions/site",JSON.stringify({uniq_key:e,version:t}))}}class j{constructor(e){this.client=e}listExtensionsSite(e){return this.client.rest.get("/anons_ext/extensions",e)}extensionDetailSite(e){return this.client.rest.get(`/anons_ext/extensions/${e}`)}extensionMarkdown(e){return this.client.rest.get(`/anons_ext/extensions/${e}/readme`)}}const q="/disk",L=`${q}/check`;class F{constructor(e){this.client=e}info(e,t){return this.client.rest.get(`${q}/${e}/element`,{path:t})}list(e,t){return this.client.rest.get(`${q}/${e}`,t)}create(e,t){return this.client.rest.post(`${q}/${e}/element`,JSON.stringify(t))}replace(e,t,s){return this.client.rest.put(`${q}/${e}/files?path=${t}`,s)}read(e,t){return this.client.rest.get(`${q}/${e}/files?path=${t}`)}upload(e,t,s=""){const i=new FormData;return i.set("path",s),i.set("file",t),this.client.rest.post(`${q}/${e}/files`,i)}delete(e,t){return this.client.rest.delete(`${q}/${e}/trash/element`,{path:t})}check(e){return this.client.rest.post(L,JSON.stringify(e))}}class W{constructor(e){this.client=e}settings(){return this.client.rest.get("/settings")}changeSettings(e){return this.client.rest.post("/settings",JSON.stringify(e))}queryInit(){return this.client.rest.get("/query/init")}}const M="/groups";class B{constructor(e){this.client=e}list(e){return this.client.rest.get(M,e)}listUsers(e){return this.client.rest.get(`${M}/${e}/users`)}create(e){return this.client.rest.post(M,JSON.stringify(e))}update(e,t){return this.client.rest.put(`${M}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${M}/${e}`)}}const G="/license",H=`${G}/manual-check`,V=`${G}/hardware/hash`;class z{constructor(e){this.client=e}info(){return this.client.rest.get(G)}create(e){return this.client.rest.post(G,JSON.stringify(e))}check(){return this.client.rest.post(H)}delete(){return this.client.rest.delete(G)}getHash(){return this.client.rest.get(V)}}class K{constructor(e){this.client=e}getUsersLogs(e){return this.client.rest.get("/logs/users",e)}getSystemLogs(e){return this.client.rest.get(e)}}const X="/roles",Y=`${X}/default`;class Q{constructor(e){this.client=e}list(e){return this.client.rest.get(X,e)}get(e){return this.client.rest.get(`${X}/${e}`)}getDefault(){return this.client.rest.get(`${Y}`)}create(e){return this.client.rest.post(X,JSON.stringify(e))}update(e,t){return this.client.rest.put(`${X}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${X}/${e}`)}permissions(){return this.client.rest.get("/permissions")}addPermissions(e,t){return this.client.rest.put(`${X}/${e}/permissions`,JSON.stringify({ids:t}))}deletePermissions(e,t){return this.client.rest.delete(`${X}/${e}/permissions`,{ids:t})}}const Z="/users",ee=`${Z}/me`,te=`${ee}/avatars`,se=`${ee}/sessions`,ie=`${ee}/tokens`,re=`${ee}/change-password`;class ne{constructor(e){this.client=e}list(e){return this.client.rest.get(Z,e)}get(e){return this.client.rest.get(Z+`/${e}`)}create(e){return this.client.rest.post(Z,JSON.stringify(e))}update(e,t){return this.client.rest.put(Z+`/${e}`,JSON.stringify(t))}delete(e,t){return this.client.rest.delete(`${Z}/${e}`,t)}restore(e){return this.client.rest.post(`${Z}/${e}/restore`)}me(){return this.client.rest.get(ee)}updateMe(e){return this.client.rest.put(ee,JSON.stringify(e))}createToken(e){return this.client.rest.post(ie,JSON.stringify(e))}listToken(e){return this.client.rest.get(ie,e)}deleteToken(e){return this.client.rest.delete(`${ie}/${e}`)}changeMyPassword(e){return this.client.rest.put(re,JSON.stringify(e))}changeUsersPassword(e,t){return this.client.rest.put(`${Z}/${e}/change-password`,JSON.stringify(t))}meUploadAvatar(e,t){const s=new FormData;return s.append("file",e,t),this.client.rest.post(te,s)}meDeleteAvatar(){return this.client.rest.delete(te)}meListSession(e){return this.client.rest.get(se,e)}meDeleteSession(e){let t=se;return e&&(t+=`/${e}`),this.client.rest.delete(t)}setRole(e,t=null){return this.client.rest.put(`${Z}/${e}/roles`,JSON.stringify({role_id:t}))}}class oe{constructor(e){this.client=e}info(e,t){const s=new URLSearchParams({path:e,share_token:t});return this.client.rest.get(`/share?${s.toString()}`)}checkPassword(e,t){const s=encodeURIComponent(e);return this.client.rest.get(`share/password?share_token=${t}&share_pass=${s}`)}checkToken(e){return this.client.rest.get(`share?share_token=${e}`)}restrictions(e){return this.client.rest.get("/share/restrictions",e)}restrictionsChange(e,t){return this.client.rest.put(`/share/restrictions/${e}`,JSON.stringify(t))}}const ce="/storage/element/share";class ae{constructor(e){this.client=e}info(e){return this.client.rest.get(ce,{path:e})}create(e,t){const s={path:e,permissions_type:t};return this.client.rest.post(ce,JSON.stringify(s))}change(e){return this.client.rest.put(`${ce}/${e.token}`,JSON.stringify(e))}delete(e){return this.client.rest.delete(ce,{path:e})}refresh(e){return this.client.rest.put(`${ce}/${e}/refresh`)}}const le="/storage",de=`${le}/element`,pe=`${de}/move`,he=`${de}/copy`,ue=`${de}/history`,ge=`${de}/version`,fe=`${ge}/current`;class xe{constructor(e){this.client=e}list(e){return this.client.rest.get(le,e)}info(e){var t;return parseInt((null===(t=e.divide_id)||void 0===t?void 0:t.toString())||"")||delete e.divide_id,e.file_version_id||delete e.file_version_id,this.client.rest.get(de,e)}size(e){var t;return parseInt((null===(t=e.divide_id)||void 0===t?void 0:t.toString())||"")||delete e.divide_id,this.client.rest.post(`${de}/size`,JSON.stringify(e))}move(e,t=!1){const{from_divide_id:s,to_divide_id:i}=e,r=Object.assign(Object.assign({},e),{from_divide_id:null,to_divide_id:null});return t?s?i?this.client.rest.post(`/disk/${s}/files/move/disk/${i}`,JSON.stringify(r)):this.client.rest.put(`/disk/${s}/files/to/box`,JSON.stringify(r)):this.client.rest.put(`/disk/${i}/files/from/box`,JSON.stringify(r)):this.client.rest.post(pe,JSON.stringify(e))}copy(e,t,s){const{from_divide_id:i,to_divide_id:r}=e;let n=Object.assign(Object.assign({},e),{from_divide_id:null,to_divide_id:null});return s===exports.StorageRoot.fca&&t===exports.StorageRoot.fca?this.client.rest.post(`/disk/${i}/files/copy/disk/${r}`,JSON.stringify(n)):s===exports.StorageRoot.fca?(i&&(n.from_divide_id=i),this.client.rest.post(`/disk/${r}/files/from/box`,JSON.stringify(n))):t===exports.StorageRoot.fca?(r&&(n.to_divide_id=r),this.client.rest.post(`/disk/${i}/files/to/box`,JSON.stringify(n))):this.client.rest.post(he,JSON.stringify(e))}pasteFromShared(e,t,s){const i={from_sharing_token:e,from_sharing_password:s,paths:t};return this.client.rest.post("/storage/element/copy",JSON.stringify(i))}create(e){return this.client.rest.post(de,JSON.stringify(e))}delete(e,t){const s={path:e};return t&&(s.divide_id=t),this.client.rest.delete(de,s)}favorite(e){return this.client.rest.put(`${de}?path=${encodeURIComponent(e)}`,JSON.stringify({is_favorite:!0}))}removeFavorite(e){return this.client.rest.put(`${de}?path=${encodeURIComponent(e)}`,JSON.stringify({is_favorite:!1}))}createItem(e){return this.client.rest.post(de,JSON.stringify(e))}createWorkDir(e){return this.client.rest.post(de,JSON.stringify(e))}history(e){return this.client.rest.get(ue,e)}versions(e){return this.client.rest.get(ge,e)}createVersion(e){return this.client.rest.post(ge,JSON.stringify(e))}editVersion(e){return this.client.rest.put(ge,JSON.stringify(e))}deleteVersion(e){return this.client.rest.delete(ge,e)}makeCurrentVersion(e){return this.client.rest.post(fe,JSON.stringify(e))}}const ye="/storage/trash",ve=`${ye}/element`,Se=`${ve}/all`;class _e{constructor(e){this.client=e}list(e){return this.client.rest.get(ye,e)}clear(e){return this.client.rest.delete(ve,e)}clearAll(){return this.client.rest.delete(Se)}restore(e){return this.client.rest.patch(ve,JSON.stringify({del_groups:e}))}}function $e(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{a(i.next(e))}catch(e){n(e)}}function c(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,c)}a((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class ke extends Error{}function me(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s})))}(t)}catch(e){return atob(t)}}ke.prototype.name="InvalidTokenError";class we{constructor(e,t){this.client=e,this.tokenUpdate=t}get state(){return this.client.state}get(e,t){return this.sendRequest("GET",e,{query:t,cache:"no-cache"})}post(e,t){return this.sendRequest("POST",e,{body:t})}put(e,t){return this.sendRequest("PUT",e,{body:t,cache:"no-cache"})}patch(e,t){return this.sendRequest("PATCH",e,{body:t})}delete(e,t){return this.sendRequest("DELETE",e,{query:t})}sendRequest(e,t){return $e(this,arguments,void 0,(function*(e,t,s={}){var i;const r=null!==(i=this.state.skipInterceptors)&&void 0!==i&&i;this.state.skipInterceptors=!1,s.query&&(t+="?"+Oe(s.query));let n={method:e,headers:this.state.requestParams.headers,cache:s.cache||this.state.requestParams.cache,body:s.body||this.state.requestParams.body};if(this.state.authToken.access_token){const e=function(e,t){if("string"!=typeof e)throw new ke("Invalid token specified: must be a string");t||(t={});const s=!0===t.header?0:1,i=e.split(".")[s];if("string"!=typeof i)throw new ke(`Invalid token specified: missing part #${s+1}`);let r;try{r=me(i)}catch(e){throw new ke(`Invalid token specified: invalid base64 for part #${s+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new ke(`Invalid token specified: invalid json for part #${s+1} (${e.message})`)}}(this.state.authToken.access_token),s=e&&e.is_remember&&this.tokenUpdate.isTokenExpire(e.exp);if(console.log(this.state.authToken),s&&!t.includes("/login")&&!t.includes("/assets")){const e=yield this.tokenUpdate.refreshToken(this.state.authToken);console.log(e),e&&(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:`Bearer ${e.access_token}`}))}}if(!r)for(const e of this.client.requestInterceptors)try{n=yield e.fulfilled(n)}catch(t){if(!e.rejected)throw t;e.rejected(t)}const o=`${this.state.clientParams.host}/api/v${this.state.clientParams.version||1}${t}`.replace(/([^:]\/)\/+/g,"$1");let c;try{c=yield fetch(o,n)}catch(e){for(const t of this.client.responseInterceptors){if(!t.rejected)throw e;try{yield t.rejected(e)}catch(e){throw e}}throw e}for(const e of this.client.responseInterceptors)try{c=yield e.fulfilled(c)}catch(t){if(!e.rejected)throw t;e.rejected(t)}return c}))}}const Oe=e=>{const t=new URLSearchParams;return Object.keys(e).forEach((s=>{Array.isArray(e[s])?e[s].forEach((e=>{t.append(s,e)})):t.append(s,e[s])})),t},Ae="/notifications",Te=`${Ae}/all`,Ne=`${Ae}/subscription`,Ee=`${Ae}/permission`;class be{constructor(e){this.client=e}list(e){return this.client.rest.get(Ae,e)}toggleStatus(e,t){return this.client.rest.put(Ae,JSON.stringify({ids:e,to_status:t}))}toggleAllStatus(e){return this.client.rest.put(Te,JSON.stringify({to_status:e}))}delete(e){return this.client.rest.delete(Ae,{id:e})}deleteAll(){return this.client.rest.delete(Te)}getPermission(){return this.client.rest.get(Ee)}setPermission(e){return this.client.rest.post(Ee,JSON.stringify({enabled:e}))}getSubscription(){return this.client.rest.get(Ne)}setSubscription(e){const t={action_groups:Object.assign({},e)};return this.client.rest.post(Ne,JSON.stringify(t))}}const De="/storage/files",Ce=`${De}/net`;class Je{constructor(e){this.client=e}read(e,t){return t.path=e,this.client.rest.get(De,t)}replace(e,t){const s=new URLSearchParams;return Object.keys(e).forEach((t=>{e[t]&&s.append(t,e[t])})),this.client.rest.put(`${De}?${s.toString()}`,t)}upload(e,t,s){const i=new FormData;return i.set("path",t),i.set("file",e),s&&i.set("divide_id",s.toString()),this.client.rest.post(De,i)}uploadNet(e){return this.client.rest.post(Ce,JSON.stringify(e))}}class Ue{constructor(e){this.authApiService=e,this.isUpdating=!1,this.tokenUpdatePromise=null,this.tokenUpdateResolve=null}isTokenExpire(e){if(!e)return!1;return 1e3*e<=(new Date).getTime()+3e3}refreshToken(e){return $e(this,void 0,void 0,(function*(){const{access_token:t,refresh_token:s}=e;if(!t||!s)return null;if(this.isUpdating)return this.waitForTokenUpdate();this.isUpdating=!0;try{const t=yield this.authApiService.updateToken(e);if(t&&t.access_token&&t.refresh_token){const e={access_token:t.access_token,refresh_token:t.refresh_token};return this.tokenUpdateResolve&&(this.tokenUpdateResolve(e),this.tokenUpdateResolve=null),e}return null}catch(e){throw e}finally{this.isUpdating=!1}}))}waitForTokenUpdate(){return this.tokenUpdatePromise||(this.tokenUpdatePromise=new Promise((e=>{this.tokenUpdateResolve=e}))),this.tokenUpdatePromise}}exports.AuthApiService=i,exports.Client=class{constructor(e){this.AuthApi=new i(this),this.ConnectionsApi=new C(this),this.DiscoveryApi=new J(this),this.DivideApi=new U(this),this.ExtensionsApi=new I(this),this.ExtensionsExternalApi=new j(this),this.FcaApi=new F(this),this.GatewayApi=new W(this),this.GroupApi=new B(this),this.LicenseApi=new z(this),this.LogstashApi=new K(this),this.NotificationsApi=new be(this),this.RoleApi=new Q(this),this.ShareApi=new oe(this),this.StorageElementApi=new xe(this),this.StorageFilesApi=new Je(this),this.StorageShareApi=new ae(this),this.StorageTrashApi=new _e(this),this.UserApi=new ne(this),this.tokenUpdate=new Ue(this.AuthApi),this.rest=new we(this,this.tokenUpdate),this.requestInterceptors=[],this.responseInterceptors=[],this.request={use:(e,t)=>{this.requestInterceptors.push({fulfilled:e,rejected:t})}},this.response={use:(e,t)=>{this.responseInterceptors.push({fulfilled:e,rejected:t})}},this.state={clientParams:{host:(null==e?void 0:e.host)||"",version:(null==e?void 0:e.version)||1},requestParams:{path:"",headers:{},query:{},body:null,cache:"no-cache"},authToken:{access_token:"",refresh_token:""},skipInterceptors:!1}}resetParams(e){return new Promise((t=>{const{host:s,version:i,headers:r,cache:n,authTokens:o,skipInterceptors:c}=e;this.state={clientParams:{host:s||this.state.clientParams.host,version:null!=i?i:this.state.clientParams.version},requestParams:Object.assign(Object.assign({},this.state.requestParams),{headers:r||this.state.requestParams.headers,cache:n||this.state.requestParams.cache}),authToken:o||this.state.authToken,skipInterceptors:c||this.state.skipInterceptors},t()}))}},exports.ConnectionsApiService=C,exports.DiscoveryApiService=J,exports.DivideApiService=U,exports.ExtensionsApiService=I,exports.ExtensionsExternalApiService=j,exports.FcaApiService=F,exports.GatewayApiService=W,exports.GroupApiService=B,exports.LicenseApiService=z,exports.LogstashApiService=K,exports.Rest=we,exports.RoleApiService=Q,exports.ShareApiService=oe,exports.StorageElementApiService=xe,exports.StorageShareApiService=ae,exports.StorageTrashApiService=_e,exports.TokenUpdate=Ue,exports.UserApiService=ne;
1
+ "use strict";const e="/login",t=`${e}/ldap`,s=`${e}/update`;class i{constructor(e){this.client=e}info(){return this.client.rest.get(e)}login(t){return this.client.rest.post(e,JSON.stringify(t))}ldapLogin(e){return this.client.rest.post(t,JSON.stringify(e))}updateToken(e){return this.client.rest.post(s,JSON.stringify(e))}logout(){return this.client.rest.post("/logout")}}var r,n,o,c,a,l,p,d,h,u,g,f,x,v,y,S,_,m,k,$,w,O,T,N,A,E;exports.OrderDirection=void 0,(r=exports.OrderDirection||(exports.OrderDirection={})).DEFAULT="",r.ASC="asc",r.DESC="desc",exports.EngineType=void 0,(n=exports.EngineType||(exports.EngineType={})).WebSocket="websocket",n.PostMessage="postmessage",n.Empty="",exports.ConnectionGroup=void 0,(o=exports.ConnectionGroup||(exports.ConnectionGroup={})).Storages="storages_connections_group",o.Webhooks="webhooks_connections_group",o.Unknown="unknown_connections_group",o.Proxy="proxy_connections_group",exports.ConnectionType=void 0,(c=exports.ConnectionType||(exports.ConnectionType={})).SSH="ssh_connection",c.YandexDisk="yandex_disk",c.Mail="mail",c.Discord="discord",c.Webdav="webdav_connection",c.Nextcloud="nextcloud_connection",c.NextBox="nextbox_connection",c.HttpProxy="http_proxy_connection",c.S3="s3_connection",exports.ExtensionType=void 0,(a=exports.ExtensionType||(exports.ExtensionType={})).App="app",a.File="file",a.WorkDir="work_dir",exports.ExtensionFileMode=void 0,(l=exports.ExtensionFileMode||(exports.ExtensionFileMode={})).Read="read",l.ReadAndWrite="read_and_write",l.Write="write",exports.DivideScope=void 0,(p=exports.DivideScope||(exports.DivideScope={})).Storage="/storage/element",p.Connection="/connections",exports.PermissionType=void 0,(d=exports.PermissionType||(exports.PermissionType={})).CLOSE="",d.READ="r",d.WRITE="rw",exports.RestrictionStatus=void 0,(h=exports.RestrictionStatus||(exports.RestrictionStatus={})).WAITING="waiting",h.APPROVED="approved",h.REJECTED="rejected",exports.RestrictionBooleanStatus=void 0,(u=exports.RestrictionBooleanStatus||(exports.RestrictionBooleanStatus={})).TRUE="true",u.FALSE="false",exports.DivideMode=void 0,(g=exports.DivideMode||(exports.DivideMode={})).User="to_user_id",g.Group="to_user_group_id",exports.Tariff=void 0,(f=exports.Tariff||(exports.Tariff={})).Free="free",f.Business="business",f.Enterprise="enterprise",exports.LicenseError=void 0,(x=exports.LicenseError||(exports.LicenseError={})).NotActivated="License not activated",x.Blocked="License blocked",x.Expired="License has been expired",x.NotValid="License not valid",x.NotFound="license file not found",exports.NotificationEntityType=void 0,(v=exports.NotificationEntityType||(exports.NotificationEntityType={})).Dir="dir",v.File="file",v.User="user",v.Other="other",v.WorkDir="work_dir",v.License="license",v.Extension="extension",v.Connection="connection",exports.NotificationAction=void 0,(y=exports.NotificationAction||(exports.NotificationAction={})).OpenSharing="open_sharing",y.ChangeSharing="change_sharing",y.CancelSharing="cancel_sharing",y.DivideDirAddFileToOwner="divide_dir_add_file_to_owner",y.DivideDirAddDirToOwner="divide_dir_add_dir_to_owner",y.DivideDirAddWorkDirToOwner="divide_dir_add_work_dir_to_owner",y.DivideConnectionAddFileToOwner="divide_connection_add_file_to_owner",y.DivideConnectionAddDirToOwner="divide_connection_add_dir_to_owner",y.CancelDivideDir="cancel_divide_dir",y.CancelDivideFile="cancel_divide_file",y.CancelDivideWorkDir="cancel_divide_work_dir",y.CancelDivideConnection="cancel_divide_connection",y.DeleteExtension="delete_extension",y.NewVersionExtension="new_version_extension",y.Other="other",exports.NotificationRowAction=void 0,(S=exports.NotificationRowAction||(exports.NotificationRowAction={})).Read="read",S.Unread="unread",S.Delete="delete",exports.NotificationStyle=void 0,(_=exports.NotificationStyle||(exports.NotificationStyle={})).Plain="plain",_.Success="success",_.Info="info",_.Warning="warning",_.Error="error",exports.RestrictionSharing=void 0,(m=exports.RestrictionSharing||(exports.RestrictionSharing={})).NONE="none",m.SOFT="soft",m.HARD="hard",exports.UserAuthType=void 0,(k=exports.UserAuthType||(exports.UserAuthType={})).Native="native",k.Ldap="ldap",exports.UserStatus=void 0,($=exports.UserStatus||(exports.UserStatus={})).Registering="registering",$.Activated="activated",$.Blocked="blocked",$.BlockedByLicense="blocked_by_license",exports.UserType=void 0,(w=exports.UserType||(exports.UserType={})).User="user",w.Guest="guest",w.Emperor="emperor",w.Anonymous="anonymous",exports.SettingControlType=void 0,(O=exports.SettingControlType||(exports.SettingControlType={})).Text="text",O.String="string",O.Number="number",O.CheckBox="checkbox",O.Select="select",O.RadioList="radio_list",O.ConnectionChoose="connection_choose",O.MultiConnectionChoose="multi_connection_choose",exports.StorageElementType=void 0,(T=exports.StorageElementType||(exports.StorageElementType={})).Dir="dir",T.File="file",T.WorkDir="work_dir",exports.StorageElementContentType=void 0,(N=exports.StorageElementContentType||(exports.StorageElementContentType={})).Any="any",N.Dir="dir",N.Code="code",N.Image="image",N.Audio="audio",N.Video="video",N.Text="text",N.Doc="doc",N.Xls="xls",N.Ppt="ppt",exports.StorageRoot=void 0,(A=exports.StorageRoot||(exports.StorageRoot={})).my="my",A.fca="fca",A.divide="divide",A.share="share",A.favorite="favorite",exports.StorageElementHistoryAction=void 0,(E=exports.StorageElementHistoryAction||(exports.StorageElementHistoryAction={})).Create="create",E.Update="update",E.Move="move";const D="/connections",b=`${D}/dashboard`;class C{constructor(e){this.client=e}list(e){return this.client.rest.get(D,e)}get(e){return this.client.rest.get(`${D}/${e}`)}update(e,t){return this.client.rest.put(`${D}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${D}/${e}`)}create(e){const t={[exports.ConnectionType.SSH]:"/disk/ssh",[exports.ConnectionType.Webdav]:"/disk/webdav",[exports.ConnectionType.Nextcloud]:"/disk/nextcloud",[exports.ConnectionType.NextBox]:"/disk/nextbox",[exports.ConnectionType.Discord]:"/webhooks/discord",[exports.ConnectionType.Mail]:"/webhooks/mail",[exports.ConnectionType.HttpProxy]:"/http_proxy",[exports.ConnectionType.S3]:"/disk/s3"};return this.client.rest.post(t[e.type]||D,JSON.stringify(e))}dashboard(e){return this.client.rest.get(b,e)}}class R{constructor(e){this.client=e}discovery(e){return this.client.rest.get("/discovery",e)}}class J{constructor(e){this.client=e}divideDelete(e,t){return this.client.rest.delete(`${e}/divide/${t}`)}divideDeleteAll(e,t,s,i){return this.client.rest.delete(`${e}/divide`,Object.assign(Object.assign({},this.makeParam(e,t)),{is_to_user_group:i,access_mode:s}))}divideChange(e,t,s){return this.client.rest.put(`${e}/divide/${t}`,JSON.stringify({access_mode:s}))}divideCreate(e,t,s,i,r){const n=Object.assign(Object.assign({},this.makeParam(e,t)),{[r]:s,access_mode:i});return this.client.rest.post(`${e}/divide`,JSON.stringify(n))}divideUsers(e,t,s){return this.client.rest.get(`${e}/divide/users`,Object.assign(Object.assign({},this.makeParam(e,t)),s))}restrictions(e){return this.client.rest.get("/divide/restrictions",e)}restrictionsChange(e,t){return this.client.rest.put(`/divide/restrictions/${e}`,JSON.stringify(t))}makeParam(e,t){const s={};return e===exports.DivideScope.Connection?s.connection_id=t:s.path=t,s}}const U="/static/extensions",P="/extensions/defaults";class I{constructor(e){this.client=e}getSetting(e){return this.client.rest.get(`${U}/${e}/settings`)}setSetting(e,t){return this.client.rest.post(`${U}/${e}/settings`,JSON.stringify(t))}deleteSetting(e){return this.client.rest.delete(`${U}/${e}/settings`)}get(e){return this.client.rest.get(`${U}/${e}`)}getByKey(e){return this.client.rest.get(`${U}/${e}`)}getDefault(e=[]){return this.client.rest.get(P,{ext_code:e})}setDefault(e,t){return this.client.rest.post(P,JSON.stringify({ext_code:e,ext_uniq_key:t}))}checkUpdates(){return this.client.rest.post("/static/extensions/check_updates")}updateVersion(e,t){return this.client.rest.put(`/static/extensions/${e}`,JSON.stringify({version:t}))}list(e){return this.client.rest.get(U,e)}delete(e,t){return this.client.rest.delete(`${U}/${e}`)}upload(e){const t=new FormData;return t.set("file",e),this.client.rest.post(U,t)}install(e,t){return this.client.rest.post("/static/extensions/site",JSON.stringify({uniq_key:e,version:t}))}}class q{constructor(e){this.client=e}listExtensionsSite(e){return this.client.rest.get("/anons_ext/extensions",e)}extensionDetailSite(e){return this.client.rest.get(`/anons_ext/extensions/${e}`)}extensionMarkdown(e){return this.client.rest.get(`/anons_ext/extensions/${e}/readme`)}}const L="/disk",F=`${L}/check`;class j{constructor(e){this.client=e}info(e,t){return this.client.rest.get(`${L}/${e}/element`,{path:t})}list(e,t){return this.client.rest.get(`${L}/${e}`,t)}create(e,t){return this.client.rest.post(`${L}/${e}/element`,JSON.stringify(t))}replace(e,t,s){return this.client.rest.put(`${L}/${e}/files?path=${t}`,s)}read(e,t){return this.client.rest.get(`${L}/${e}/files?path=${t}`)}upload(e,t,s=""){const i=new FormData;return i.set("path",s),i.set("file",t),this.client.rest.post(`${L}/${e}/files`,i)}delete(e,t){return this.client.rest.delete(`${L}/${e}/trash/element`,{path:t})}check(e){return this.client.rest.post(F,JSON.stringify(e))}}class W{constructor(e){this.client=e}settings(){return this.client.rest.get("/settings")}changeSettings(e){return this.client.rest.post("/settings",JSON.stringify(e))}queryInit(){return this.client.rest.get("/query/init")}}const B="/groups";class M{constructor(e){this.client=e}list(e){return this.client.rest.get(B,e)}listUsers(e){return this.client.rest.get(`${B}/${e}/users`)}create(e){return this.client.rest.post(B,JSON.stringify(e))}update(e,t){return this.client.rest.put(`${B}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${B}/${e}`)}}const H="/license",G=`${H}/manual-check`,V=`${H}/hardware/hash`;class z{constructor(e){this.client=e}info(){return this.client.rest.get(H)}create(e){return this.client.rest.post(H,JSON.stringify(e))}check(){return this.client.rest.post(G)}delete(){return this.client.rest.delete(H)}getHash(){return this.client.rest.get(V)}}class K{constructor(e){this.client=e}getUsersLogs(e){return this.client.rest.get("/logs/users",e)}getSystemLogs(e){return this.client.rest.get(e)}}const X="/roles",Y=`${X}/default`;class Q{constructor(e){this.client=e}list(e){return this.client.rest.get(X,e)}get(e){return this.client.rest.get(`${X}/${e}`)}getDefault(){return this.client.rest.get(`${Y}`)}create(e){return this.client.rest.post(X,JSON.stringify(e))}update(e,t){return this.client.rest.put(`${X}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${X}/${e}`)}permissions(){return this.client.rest.get("/permissions")}addPermissions(e,t){return this.client.rest.put(`${X}/${e}/permissions`,JSON.stringify({ids:t}))}deletePermissions(e,t){return this.client.rest.delete(`${X}/${e}/permissions`,{ids:t})}}const Z="/users",ee=`${Z}/me`,te=`${ee}/avatars`,se=`${ee}/sessions`,ie=`${ee}/tokens`,re=`${ee}/change-password`;class ne{constructor(e){this.client=e}list(e){return this.client.rest.get(Z,e)}get(e){return this.client.rest.get(Z+`/${e}`)}create(e){return this.client.rest.post(Z,JSON.stringify(e))}update(e,t){return this.client.rest.put(Z+`/${e}`,JSON.stringify(t))}delete(e,t){return this.client.rest.delete(`${Z}/${e}`,t)}restore(e){return this.client.rest.post(`${Z}/${e}/restore`)}me(){return this.client.rest.get(ee)}updateMe(e){return this.client.rest.put(ee,JSON.stringify(e))}createToken(e){return this.client.rest.post(ie,JSON.stringify(e))}listToken(e){return this.client.rest.get(ie,e)}deleteToken(e){return this.client.rest.delete(`${ie}/${e}`)}changeMyPassword(e){return this.client.rest.put(re,JSON.stringify(e))}changeUsersPassword(e,t){return this.client.rest.put(`${Z}/${e}/change-password`,JSON.stringify(t))}meUploadAvatar(e,t){const s=new FormData;return s.append("file",e,t),this.client.rest.post(te,s)}meDeleteAvatar(){return this.client.rest.delete(te)}meListSession(e){return this.client.rest.get(se,e)}meDeleteSession(e){let t=se;return e&&(t+=`/${e}`),this.client.rest.delete(t)}setRole(e,t=null){return this.client.rest.put(`${Z}/${e}/roles`,JSON.stringify({role_id:t}))}}class oe{constructor(e){this.client=e}info(e,t){const s=new URLSearchParams({path:e,share_token:t});return this.client.rest.get(`/share?${s.toString()}`)}checkPassword(e,t){const s=encodeURIComponent(e);return this.client.rest.get(`share/password?share_token=${t}&share_pass=${s}`)}checkToken(e){return this.client.rest.get(`share?share_token=${e}`)}restrictions(e){return this.client.rest.get("/share/restrictions",e)}restrictionsChange(e,t){return this.client.rest.put(`/share/restrictions/${e}`,JSON.stringify(t))}}const ce="/storage/element/share";class ae{constructor(e){this.client=e}info(e){return this.client.rest.get(ce,{path:e})}create(e,t){const s={path:e,permissions_type:t};return this.client.rest.post(ce,JSON.stringify(s))}change(e){return this.client.rest.put(`${ce}/${e.token}`,JSON.stringify(e))}delete(e){return this.client.rest.delete(ce,{path:e})}refresh(e){return this.client.rest.put(`${ce}/${e}/refresh`)}}const le="/storage",pe=`${le}/element`,de=`${pe}/move`,he=`${pe}/copy`,ue=`${pe}/history`,ge=`${pe}/version`,fe=`${ge}/current`;class xe{constructor(e){this.client=e}list(e){return this.client.rest.get(le,e)}info(e){var t;return parseInt((null===(t=e.divide_id)||void 0===t?void 0:t.toString())||"")||delete e.divide_id,e.file_version_id||delete e.file_version_id,this.client.rest.get(pe,e)}size(e){var t;return parseInt((null===(t=e.divide_id)||void 0===t?void 0:t.toString())||"")||delete e.divide_id,this.client.rest.post(`${pe}/size`,JSON.stringify(e))}move(e,t=!1){const{from_divide_id:s,to_divide_id:i}=e,r=Object.assign(Object.assign({},e),{from_divide_id:null,to_divide_id:null});return t?s?i?this.client.rest.post(`/disk/${s}/files/move/disk/${i}`,JSON.stringify(r)):this.client.rest.put(`/disk/${s}/files/to/box`,JSON.stringify(r)):this.client.rest.put(`/disk/${i}/files/from/box`,JSON.stringify(r)):this.client.rest.post(de,JSON.stringify(e))}copy(e,t,s){const{from_divide_id:i,to_divide_id:r}=e;let n=Object.assign(Object.assign({},e),{from_divide_id:null,to_divide_id:null});return s===exports.StorageRoot.fca&&t===exports.StorageRoot.fca?this.client.rest.post(`/disk/${i}/files/copy/disk/${r}`,JSON.stringify(n)):s===exports.StorageRoot.fca?(i&&(n.from_divide_id=i),this.client.rest.post(`/disk/${r}/files/from/box`,JSON.stringify(n))):t===exports.StorageRoot.fca?(r&&(n.to_divide_id=r),this.client.rest.post(`/disk/${i}/files/to/box`,JSON.stringify(n))):this.client.rest.post(he,JSON.stringify(e))}pasteFromShared(e,t,s){const i={from_sharing_token:e,from_sharing_password:s,paths:t};return this.client.rest.post("/storage/element/copy",JSON.stringify(i))}create(e){return this.client.rest.post(pe,JSON.stringify(e))}delete(e,t){const s={path:e};return t&&(s.divide_id=t),this.client.rest.delete(pe,s)}favorite(e){return this.client.rest.put(`${pe}?path=${encodeURIComponent(e)}`,JSON.stringify({is_favorite:!0}))}removeFavorite(e){return this.client.rest.put(`${pe}?path=${encodeURIComponent(e)}`,JSON.stringify({is_favorite:!1}))}createItem(e){return this.client.rest.post(pe,JSON.stringify(e))}createWorkDir(e){return this.client.rest.post(pe,JSON.stringify(e))}history(e){return this.client.rest.get(ue,e)}versions(e){return this.client.rest.get(ge,e)}createVersion(e){return this.client.rest.post(ge,JSON.stringify(e))}editVersion(e){return this.client.rest.put(ge,JSON.stringify(e))}deleteVersion(e){return this.client.rest.delete(ge,e)}makeCurrentVersion(e){return this.client.rest.post(fe,JSON.stringify(e))}}const ve="/storage/trash",ye=`${ve}/element`,Se=`${ye}/all`;class _e{constructor(e){this.client=e}list(e){return this.client.rest.get(ve,e)}clear(e){return this.client.rest.delete(ye,e)}clearAll(){return this.client.rest.delete(Se)}restore(e){return this.client.rest.patch(ye,JSON.stringify({del_groups:e}))}}function me(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{a(i.next(e))}catch(e){n(e)}}function c(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,c)}a((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class ke extends Error{}function $e(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s})))}(t)}catch(e){return atob(t)}}function we(e,t){if("string"!=typeof e)throw new ke("Invalid token specified: must be a string");t||(t={});const s=!0===t.header?0:1,i=e.split(".")[s];if("string"!=typeof i)throw new ke(`Invalid token specified: missing part #${s+1}`);let r;try{r=$e(i)}catch(e){throw new ke(`Invalid token specified: invalid base64 for part #${s+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new ke(`Invalid token specified: invalid json for part #${s+1} (${e.message})`)}}ke.prototype.name="InvalidTokenError";class Oe{constructor(e){var t,s;this.name="HttpErrorResponse",this.ok=!1,this.message=e.error?`${e.error.message}`:"HttpErrorResponse",this.error=e.error||null,this.status=null!==(t=e.status)&&void 0!==t?t:500,this.statusText=null!==(s=e.statusText)&&void 0!==s?s:"Internal Server Error",this.headers=e.headers,this.url=e.url}}const Te=(e,t)=>me(void 0,void 0,void 0,(function*(){let s=t;for(const t of e)try{s=yield t.fulfilled(s)}catch(e){if(!t.rejected)throw e;s=yield t.rejected(e)}return s})),Ne=e=>{const t=document.cookie.split(";"),s=e+"=";for(let e of t)if(e=e.trim(),e.startsWith(s)){let t=e.substring(s.length);return decodeURIComponent(t)}return null},Ae=e=>{const t=new URLSearchParams;return Object.keys(e).forEach((s=>{Array.isArray(e[s])?e[s].forEach((e=>{t.append(s,e)})):t.append(s,e[s])})),t};class Ee{constructor(e,t){this.client=e,this.tokenUpdate=t}get state(){return this.client.state}get(e,t){return this.sendRequest("GET",e,{query:t,cache:"no-cache"})}post(e,t){return this.sendRequest("POST",e,{body:t})}put(e,t){return this.sendRequest("PUT",e,{body:t,cache:"no-cache"})}patch(e,t){return this.sendRequest("PATCH",e,{body:t})}delete(e,t){return this.sendRequest("DELETE",e,{query:t})}sendRequest(e,t){return me(this,arguments,void 0,(function*(e,t,s={}){var i;const r=null!==(i=this.state.skipInterceptors)&&void 0!==i&&i;this.state.skipInterceptors=!1;let n={method:e,headers:this.state.requestParams.headers,cache:s.cache||this.state.requestParams.cache,body:s.body||this.state.requestParams.body};if(r||(n=yield Te(this.client.requestInterceptors,n)),this.state.authToken)for(const[e,s]of this.state.authToken.entries()){const i=we(s.access_token);if(i&&i.is_remember&&this.tokenUpdate.isTokenExpire(i.exp)&&!t.includes("/login")&&!t.includes("/assets")){const t=yield this.tokenUpdate.refreshToken(s);t&&(this.state.authToken[e]=t,n=yield Te(this.client.requestInterceptors,n))}}s.query&&(t+="?"+Ae(s.query));const o=`${this.state.clientParams.host}/api/v${this.state.clientParams.version||1}${t}`.replace(/([^:]\/)+\/+/g,"$1");let c=yield((e,t)=>me(this,void 0,void 0,(function*(){try{const s=yield fetch(e,t);let i;try{i=yield s.clone().json()}catch(e){i=yield s.text()}if(!s.ok)throw console.log("NB RESPONSE NOT OK",s),new Oe({error:i,status:s.status,statusText:s.statusText,url:s.url});return s}catch(e){throw console.log("NB ERROR",e),yield Te(this.client.responseInterceptors,e),e}})))(o,n);return c=yield Te(this.client.responseInterceptors,c),c}))}}const De="/notifications",be=`${De}/all`,Ce=`${De}/subscription`,Re=`${De}/permission`;class Je{constructor(e){this.client=e}list(e){return this.client.rest.get(De,e)}toggleStatus(e,t){return this.client.rest.put(De,JSON.stringify({ids:e,to_status:t}))}toggleAllStatus(e){return this.client.rest.put(be,JSON.stringify({to_status:e}))}delete(e){return this.client.rest.delete(De,{id:e})}deleteAll(){return this.client.rest.delete(be)}getPermission(){return this.client.rest.get(Re)}setPermission(e){return this.client.rest.post(Re,JSON.stringify({enabled:e}))}getSubscription(){return this.client.rest.get(Ce)}setSubscription(e){const t={action_groups:Object.assign({},e)};return this.client.rest.post(Ce,JSON.stringify(t))}}const Ue="/storage/files",Pe=`${Ue}/net`;class Ie{constructor(e){this.client=e}read(e,t){return t.path=e,this.client.rest.get(Ue,t)}replace(e,t){const s=new URLSearchParams;return Object.keys(e).forEach((t=>{e[t]&&s.append(t,e[t])})),this.client.rest.put(`${Ue}?${s.toString()}`,t)}upload(e,t,s){const i=new FormData;return i.set("path",t),i.set("file",e),s&&i.set("divide_id",s.toString()),this.client.rest.post(Ue,i)}uploadNet(e){return this.client.rest.post(Pe,JSON.stringify(e))}}class qe{constructor(e){this.authApiService=e,this.isUpdating=!1,this.tokenUpdatePromise=null,this.tokenUpdateResolve=null}isTokenExpire(e){if(!e)return!1;return 1e3*e<=(new Date).getTime()+3e3}refreshToken(e){return me(this,void 0,void 0,(function*(){const{access_token:t,refresh_token:s}=e;if(!t||!s)return null;if(this.isUpdating)return this.waitForTokenUpdate();this.isUpdating=!0;try{const t=yield this.authApiService.updateToken(e);if(t&&t.access_token&&t.refresh_token){const e={access_token:t.access_token,refresh_token:t.refresh_token};return Ne("access_token")===e.access_token&&localStorage.setItem("refresh-token",e.refresh_token),this.tokenUpdateResolve&&(this.tokenUpdateResolve(e),this.tokenUpdateResolve=null),e}return null}catch(e){throw e}finally{this.isUpdating=!1}}))}waitForTokenUpdate(){return this.tokenUpdatePromise||(this.tokenUpdatePromise=new Promise((e=>{this.tokenUpdateResolve=e}))),this.tokenUpdatePromise}}exports.AuthApiService=i,exports.Client=class{constructor(e){this.AuthApi=new i(this),this.ConnectionsApi=new C(this),this.DiscoveryApi=new R(this),this.DivideApi=new J(this),this.ExtensionsApi=new I(this),this.ExtensionsExternalApi=new q(this),this.FcaApi=new j(this),this.GatewayApi=new W(this),this.GroupApi=new M(this),this.LicenseApi=new z(this),this.LogstashApi=new K(this),this.NotificationsApi=new Je(this),this.RoleApi=new Q(this),this.ShareApi=new oe(this),this.StorageElementApi=new xe(this),this.StorageFilesApi=new Ie(this),this.StorageShareApi=new ae(this),this.StorageTrashApi=new _e(this),this.UserApi=new ne(this),this.tokenUpdate=new qe(this.AuthApi),this.rest=new Ee(this,this.tokenUpdate),this.requestInterceptors=[],this.responseInterceptors=[],this.request={use:(e,t)=>{this.requestInterceptors.push({fulfilled:e,rejected:t})}},this.response={use:(e,t)=>{this.responseInterceptors.push({fulfilled:e,rejected:t})}},this.state={clientParams:{host:(null==e?void 0:e.host)||"",version:(null==e?void 0:e.version)||1},requestParams:{path:"",headers:{},query:{},body:null,cache:"no-cache"},authToken:null,skipInterceptors:!1}}resetParams(e){return new Promise((t=>{const{host:s,version:i,headers:r,cache:n,authTokens:o,skipInterceptors:c}=e;this.state={clientParams:{host:s||this.state.clientParams.host,version:null!=i?i:this.state.clientParams.version},requestParams:Object.assign(Object.assign({},this.state.requestParams),{headers:r||this.state.requestParams.headers,cache:n||this.state.requestParams.cache}),authToken:o||this.state.authToken,skipInterceptors:c||this.state.skipInterceptors},t()}))}},exports.ConnectionsApiService=C,exports.DiscoveryApiService=R,exports.DivideApiService=J,exports.ExtensionsApiService=I,exports.ExtensionsExternalApiService=q,exports.FcaApiService=j,exports.GatewayApiService=W,exports.GroupApiService=M,exports.LicenseApiService=z,exports.LogstashApiService=K,exports.Rest=Ee,exports.RoleApiService=Q,exports.ShareApiService=oe,exports.StorageElementApiService=xe,exports.StorageShareApiService=ae,exports.StorageTrashApiService=_e,exports.TokenUpdate=qe,exports.UserApiService=ne,exports.applyInterceptors=Te,exports.getCookieValue=Ne,exports.makeUrlParams=Ae;
@@ -1 +1 @@
1
- const e="/login",t=`${e}/ldap`,s=`${e}/update`;class i{constructor(e){this.client=e}info(){return this.client.rest.get(e)}login(t){return this.client.rest.post(e,JSON.stringify(t))}ldapLogin(e){return this.client.rest.post(t,JSON.stringify(e))}updateToken(e){return this.client.rest.post(s,JSON.stringify(e))}logout(){return this.client.rest.post("/logout")}}var r,n,o,c,a,l,h,d,u,p,g,f,_,$,y,k,v,m,S,w,O,N,x,b,J,A;!function(e){e.DEFAULT="",e.ASC="asc",e.DESC="desc"}(r||(r={})),function(e){e.WebSocket="websocket",e.PostMessage="postmessage",e.Empty=""}(n||(n={})),function(e){e.Storages="storages_connections_group",e.Webhooks="webhooks_connections_group",e.Unknown="unknown_connections_group",e.Proxy="proxy_connections_group"}(o||(o={})),function(e){e.SSH="ssh_connection",e.YandexDisk="yandex_disk",e.Mail="mail",e.Discord="discord",e.Webdav="webdav_connection",e.Nextcloud="nextcloud_connection",e.NextBox="nextbox_connection",e.HttpProxy="http_proxy_connection",e.S3="s3_connection"}(c||(c={})),function(e){e.App="app",e.File="file",e.WorkDir="work_dir"}(a||(a={})),function(e){e.Read="read",e.ReadAndWrite="read_and_write",e.Write="write"}(l||(l={})),function(e){e.Storage="/storage/element",e.Connection="/connections"}(h||(h={})),function(e){e.CLOSE="",e.READ="r",e.WRITE="rw"}(d||(d={})),function(e){e.WAITING="waiting",e.APPROVED="approved",e.REJECTED="rejected"}(u||(u={})),function(e){e.TRUE="true",e.FALSE="false"}(p||(p={})),function(e){e.User="to_user_id",e.Group="to_user_group_id"}(g||(g={})),function(e){e.Free="free",e.Business="business",e.Enterprise="enterprise"}(f||(f={})),function(e){e.NotActivated="License not activated",e.Blocked="License blocked",e.Expired="License has been expired",e.NotValid="License not valid",e.NotFound="license file not found"}(_||(_={})),function(e){e.Dir="dir",e.File="file",e.User="user",e.Other="other",e.WorkDir="work_dir",e.License="license",e.Extension="extension",e.Connection="connection"}($||($={})),function(e){e.OpenSharing="open_sharing",e.ChangeSharing="change_sharing",e.CancelSharing="cancel_sharing",e.DivideDirAddFileToOwner="divide_dir_add_file_to_owner",e.DivideDirAddDirToOwner="divide_dir_add_dir_to_owner",e.DivideDirAddWorkDirToOwner="divide_dir_add_work_dir_to_owner",e.DivideConnectionAddFileToOwner="divide_connection_add_file_to_owner",e.DivideConnectionAddDirToOwner="divide_connection_add_dir_to_owner",e.CancelDivideDir="cancel_divide_dir",e.CancelDivideFile="cancel_divide_file",e.CancelDivideWorkDir="cancel_divide_work_dir",e.CancelDivideConnection="cancel_divide_connection",e.DeleteExtension="delete_extension",e.NewVersionExtension="new_version_extension",e.Other="other"}(y||(y={})),function(e){e.Read="read",e.Unread="unread",e.Delete="delete"}(k||(k={})),function(e){e.Plain="plain",e.Success="success",e.Info="info",e.Warning="warning",e.Error="error"}(v||(v={})),function(e){e.NONE="none",e.SOFT="soft",e.HARD="hard"}(m||(m={})),function(e){e.Native="native",e.Ldap="ldap"}(S||(S={})),function(e){e.Registering="registering",e.Activated="activated",e.Blocked="blocked",e.BlockedByLicense="blocked_by_license"}(w||(w={})),function(e){e.User="user",e.Guest="guest",e.Emperor="emperor",e.Anonymous="anonymous"}(O||(O={})),function(e){e.Text="text",e.String="string",e.Number="number",e.CheckBox="checkbox",e.Select="select",e.RadioList="radio_list",e.ConnectionChoose="connection_choose",e.MultiConnectionChoose="multi_connection_choose"}(N||(N={})),function(e){e.Dir="dir",e.File="file",e.WorkDir="work_dir"}(x||(x={})),function(e){e.Any="any",e.Dir="dir",e.Code="code",e.Image="image",e.Audio="audio",e.Video="video",e.Text="text",e.Doc="doc",e.Xls="xls",e.Ppt="ppt"}(b||(b={})),function(e){e.my="my",e.fca="fca",e.divide="divide",e.share="share",e.favorite="favorite"}(J||(J={})),function(e){e.Create="create",e.Update="update",e.Move="move"}(A||(A={}));const D="/connections",P=`${D}/dashboard`;class U{constructor(e){this.client=e}list(e){return this.client.rest.get(D,e)}get(e){return this.client.rest.get(`${D}/${e}`)}update(e,t){return this.client.rest.put(`${D}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${D}/${e}`)}create(e){const t={[c.SSH]:"/disk/ssh",[c.Webdav]:"/disk/webdav",[c.Nextcloud]:"/disk/nextcloud",[c.NextBox]:"/disk/nextbox",[c.Discord]:"/webhooks/discord",[c.Mail]:"/webhooks/mail",[c.HttpProxy]:"/http_proxy",[c.S3]:"/disk/s3"};return this.client.rest.post(t[e.type]||D,JSON.stringify(e))}dashboard(e){return this.client.rest.get(P,e)}}class T{constructor(e){this.client=e}discovery(e){return this.client.rest.get("/discovery",e)}}class E{constructor(e){this.client=e}divideDelete(e,t){return this.client.rest.delete(`${e}/divide/${t}`)}divideDeleteAll(e,t,s,i){return this.client.rest.delete(`${e}/divide`,Object.assign(Object.assign({},this.makeParam(e,t)),{is_to_user_group:i,access_mode:s}))}divideChange(e,t,s){return this.client.rest.put(`${e}/divide/${t}`,JSON.stringify({access_mode:s}))}divideCreate(e,t,s,i,r){const n=Object.assign(Object.assign({},this.makeParam(e,t)),{[r]:s,access_mode:i});return this.client.rest.post(`${e}/divide`,JSON.stringify(n))}divideUsers(e,t,s){return this.client.rest.get(`${e}/divide/users`,Object.assign(Object.assign({},this.makeParam(e,t)),s))}restrictions(e){return this.client.rest.get("/divide/restrictions",e)}restrictionsChange(e,t){return this.client.rest.put(`/divide/restrictions/${e}`,JSON.stringify(t))}makeParam(e,t){const s={};return e===h.Connection?s.connection_id=t:s.path=t,s}}const C="/static/extensions",I="/extensions/defaults";class R{constructor(e){this.client=e}getSetting(e){return this.client.rest.get(`${C}/${e}/settings`)}setSetting(e,t){return this.client.rest.post(`${C}/${e}/settings`,JSON.stringify(t))}deleteSetting(e){return this.client.rest.delete(`${C}/${e}/settings`)}get(e){return this.client.rest.get(`${C}/${e}`)}getByKey(e){return this.client.rest.get(`${C}/${e}`)}getDefault(e=[]){return this.client.rest.get(I,{ext_code:e})}setDefault(e,t){return this.client.rest.post(I,JSON.stringify({ext_code:e,ext_uniq_key:t}))}checkUpdates(){return this.client.rest.post("/static/extensions/check_updates")}updateVersion(e,t){return this.client.rest.put(`/static/extensions/${e}`,JSON.stringify({version:t}))}list(e){return this.client.rest.get(C,e)}delete(e,t){return this.client.rest.delete(`${C}/${e}`)}upload(e){const t=new FormData;return t.set("file",e),this.client.rest.post(C,t)}install(e,t){return this.client.rest.post("/static/extensions/site",JSON.stringify({uniq_key:e,version:t}))}}class j{constructor(e){this.client=e}listExtensionsSite(e){return this.client.rest.get("/anons_ext/extensions",e)}extensionDetailSite(e){return this.client.rest.get(`/anons_ext/extensions/${e}`)}extensionMarkdown(e){return this.client.rest.get(`/anons_ext/extensions/${e}/readme`)}}const q="/disk",F=`${q}/check`;class L{constructor(e){this.client=e}info(e,t){return this.client.rest.get(`${q}/${e}/element`,{path:t})}list(e,t){return this.client.rest.get(`${q}/${e}`,t)}create(e,t){return this.client.rest.post(`${q}/${e}/element`,JSON.stringify(t))}replace(e,t,s){return this.client.rest.put(`${q}/${e}/files?path=${t}`,s)}read(e,t){return this.client.rest.get(`${q}/${e}/files?path=${t}`)}upload(e,t,s=""){const i=new FormData;return i.set("path",s),i.set("file",t),this.client.rest.post(`${q}/${e}/files`,i)}delete(e,t){return this.client.rest.delete(`${q}/${e}/trash/element`,{path:t})}check(e){return this.client.rest.post(F,JSON.stringify(e))}}class W{constructor(e){this.client=e}settings(){return this.client.rest.get("/settings")}changeSettings(e){return this.client.rest.post("/settings",JSON.stringify(e))}queryInit(){return this.client.rest.get("/query/init")}}const B="/groups";class V{constructor(e){this.client=e}list(e){return this.client.rest.get(B,e)}listUsers(e){return this.client.rest.get(`${B}/${e}/users`)}create(e){return this.client.rest.post(B,JSON.stringify(e))}update(e,t){return this.client.rest.put(`${B}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${B}/${e}`)}}const M="/license",H=`${M}/manual-check`,G=`${M}/hardware/hash`;class z{constructor(e){this.client=e}info(){return this.client.rest.get(M)}create(e){return this.client.rest.post(M,JSON.stringify(e))}check(){return this.client.rest.post(H)}delete(){return this.client.rest.delete(M)}getHash(){return this.client.rest.get(G)}}class K{constructor(e){this.client=e}getUsersLogs(e){return this.client.rest.get("/logs/users",e)}getSystemLogs(e){return this.client.rest.get(e)}}const X="/roles",Y=`${X}/default`;class Q{constructor(e){this.client=e}list(e){return this.client.rest.get(X,e)}get(e){return this.client.rest.get(`${X}/${e}`)}getDefault(){return this.client.rest.get(`${Y}`)}create(e){return this.client.rest.post(X,JSON.stringify(e))}update(e,t){return this.client.rest.put(`${X}/${e}`,JSON.stringify(t))}delete(e){return this.client.rest.delete(`${X}/${e}`)}permissions(){return this.client.rest.get("/permissions")}addPermissions(e,t){return this.client.rest.put(`${X}/${e}/permissions`,JSON.stringify({ids:t}))}deletePermissions(e,t){return this.client.rest.delete(`${X}/${e}/permissions`,{ids:t})}}const Z="/users",ee=`${Z}/me`,te=`${ee}/avatars`,se=`${ee}/sessions`,ie=`${ee}/tokens`,re=`${ee}/change-password`;class ne{constructor(e){this.client=e}list(e){return this.client.rest.get(Z,e)}get(e){return this.client.rest.get(Z+`/${e}`)}create(e){return this.client.rest.post(Z,JSON.stringify(e))}update(e,t){return this.client.rest.put(Z+`/${e}`,JSON.stringify(t))}delete(e,t){return this.client.rest.delete(`${Z}/${e}`,t)}restore(e){return this.client.rest.post(`${Z}/${e}/restore`)}me(){return this.client.rest.get(ee)}updateMe(e){return this.client.rest.put(ee,JSON.stringify(e))}createToken(e){return this.client.rest.post(ie,JSON.stringify(e))}listToken(e){return this.client.rest.get(ie,e)}deleteToken(e){return this.client.rest.delete(`${ie}/${e}`)}changeMyPassword(e){return this.client.rest.put(re,JSON.stringify(e))}changeUsersPassword(e,t){return this.client.rest.put(`${Z}/${e}/change-password`,JSON.stringify(t))}meUploadAvatar(e,t){const s=new FormData;return s.append("file",e,t),this.client.rest.post(te,s)}meDeleteAvatar(){return this.client.rest.delete(te)}meListSession(e){return this.client.rest.get(se,e)}meDeleteSession(e){let t=se;return e&&(t+=`/${e}`),this.client.rest.delete(t)}setRole(e,t=null){return this.client.rest.put(`${Z}/${e}/roles`,JSON.stringify({role_id:t}))}}class oe{constructor(e){this.client=e}info(e,t){const s=new URLSearchParams({path:e,share_token:t});return this.client.rest.get(`/share?${s.toString()}`)}checkPassword(e,t){const s=encodeURIComponent(e);return this.client.rest.get(`share/password?share_token=${t}&share_pass=${s}`)}checkToken(e){return this.client.rest.get(`share?share_token=${e}`)}restrictions(e){return this.client.rest.get("/share/restrictions",e)}restrictionsChange(e,t){return this.client.rest.put(`/share/restrictions/${e}`,JSON.stringify(t))}}const ce="/storage/element/share";class ae{constructor(e){this.client=e}info(e){return this.client.rest.get(ce,{path:e})}create(e,t){const s={path:e,permissions_type:t};return this.client.rest.post(ce,JSON.stringify(s))}change(e){return this.client.rest.put(`${ce}/${e.token}`,JSON.stringify(e))}delete(e){return this.client.rest.delete(ce,{path:e})}refresh(e){return this.client.rest.put(`${ce}/${e}/refresh`)}}const le="/storage",he=`${le}/element`,de=`${he}/move`,ue=`${he}/copy`,pe=`${he}/history`,ge=`${he}/version`,fe=`${ge}/current`;class _e{constructor(e){this.client=e}list(e){return this.client.rest.get(le,e)}info(e){var t;return parseInt((null===(t=e.divide_id)||void 0===t?void 0:t.toString())||"")||delete e.divide_id,e.file_version_id||delete e.file_version_id,this.client.rest.get(he,e)}size(e){var t;return parseInt((null===(t=e.divide_id)||void 0===t?void 0:t.toString())||"")||delete e.divide_id,this.client.rest.post(`${he}/size`,JSON.stringify(e))}move(e,t=!1){const{from_divide_id:s,to_divide_id:i}=e,r=Object.assign(Object.assign({},e),{from_divide_id:null,to_divide_id:null});return t?s?i?this.client.rest.post(`/disk/${s}/files/move/disk/${i}`,JSON.stringify(r)):this.client.rest.put(`/disk/${s}/files/to/box`,JSON.stringify(r)):this.client.rest.put(`/disk/${i}/files/from/box`,JSON.stringify(r)):this.client.rest.post(de,JSON.stringify(e))}copy(e,t,s){const{from_divide_id:i,to_divide_id:r}=e;let n=Object.assign(Object.assign({},e),{from_divide_id:null,to_divide_id:null});return s===J.fca&&t===J.fca?this.client.rest.post(`/disk/${i}/files/copy/disk/${r}`,JSON.stringify(n)):s===J.fca?(i&&(n.from_divide_id=i),this.client.rest.post(`/disk/${r}/files/from/box`,JSON.stringify(n))):t===J.fca?(r&&(n.to_divide_id=r),this.client.rest.post(`/disk/${i}/files/to/box`,JSON.stringify(n))):this.client.rest.post(ue,JSON.stringify(e))}pasteFromShared(e,t,s){const i={from_sharing_token:e,from_sharing_password:s,paths:t};return this.client.rest.post("/storage/element/copy",JSON.stringify(i))}create(e){return this.client.rest.post(he,JSON.stringify(e))}delete(e,t){const s={path:e};return t&&(s.divide_id=t),this.client.rest.delete(he,s)}favorite(e){return this.client.rest.put(`${he}?path=${encodeURIComponent(e)}`,JSON.stringify({is_favorite:!0}))}removeFavorite(e){return this.client.rest.put(`${he}?path=${encodeURIComponent(e)}`,JSON.stringify({is_favorite:!1}))}createItem(e){return this.client.rest.post(he,JSON.stringify(e))}createWorkDir(e){return this.client.rest.post(he,JSON.stringify(e))}history(e){return this.client.rest.get(pe,e)}versions(e){return this.client.rest.get(ge,e)}createVersion(e){return this.client.rest.post(ge,JSON.stringify(e))}editVersion(e){return this.client.rest.put(ge,JSON.stringify(e))}deleteVersion(e){return this.client.rest.delete(ge,e)}makeCurrentVersion(e){return this.client.rest.post(fe,JSON.stringify(e))}}const $e="/storage/trash",ye=`${$e}/element`,ke=`${ye}/all`;class ve{constructor(e){this.client=e}list(e){return this.client.rest.get($e,e)}clear(e){return this.client.rest.delete(ye,e)}clearAll(){return this.client.rest.delete(ke)}restore(e){return this.client.rest.patch(ye,JSON.stringify({del_groups:e}))}}function me(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{a(i.next(e))}catch(e){n(e)}}function c(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,c)}a((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class Se extends Error{}function we(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s})))}(t)}catch(e){return atob(t)}}Se.prototype.name="InvalidTokenError";class Oe{constructor(e,t){this.client=e,this.tokenUpdate=t}get state(){return this.client.state}get(e,t){return this.sendRequest("GET",e,{query:t,cache:"no-cache"})}post(e,t){return this.sendRequest("POST",e,{body:t})}put(e,t){return this.sendRequest("PUT",e,{body:t,cache:"no-cache"})}patch(e,t){return this.sendRequest("PATCH",e,{body:t})}delete(e,t){return this.sendRequest("DELETE",e,{query:t})}sendRequest(e,t){return me(this,arguments,void 0,(function*(e,t,s={}){var i;const r=null!==(i=this.state.skipInterceptors)&&void 0!==i&&i;this.state.skipInterceptors=!1,s.query&&(t+="?"+Ne(s.query));let n={method:e,headers:this.state.requestParams.headers,cache:s.cache||this.state.requestParams.cache,body:s.body||this.state.requestParams.body};if(this.state.authToken.access_token){const e=function(e,t){if("string"!=typeof e)throw new Se("Invalid token specified: must be a string");t||(t={});const s=!0===t.header?0:1,i=e.split(".")[s];if("string"!=typeof i)throw new Se(`Invalid token specified: missing part #${s+1}`);let r;try{r=we(i)}catch(e){throw new Se(`Invalid token specified: invalid base64 for part #${s+1} (${e.message})`)}try{return JSON.parse(r)}catch(e){throw new Se(`Invalid token specified: invalid json for part #${s+1} (${e.message})`)}}(this.state.authToken.access_token),s=e&&e.is_remember&&this.tokenUpdate.isTokenExpire(e.exp);if(console.log(this.state.authToken),s&&!t.includes("/login")&&!t.includes("/assets")){const e=yield this.tokenUpdate.refreshToken(this.state.authToken);console.log(e),e&&(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:`Bearer ${e.access_token}`}))}}if(!r)for(const e of this.client.requestInterceptors)try{n=yield e.fulfilled(n)}catch(t){if(!e.rejected)throw t;e.rejected(t)}const o=`${this.state.clientParams.host}/api/v${this.state.clientParams.version||1}${t}`.replace(/([^:]\/)\/+/g,"$1");let c;try{c=yield fetch(o,n)}catch(e){for(const t of this.client.responseInterceptors){if(!t.rejected)throw e;try{yield t.rejected(e)}catch(e){throw e}}throw e}for(const e of this.client.responseInterceptors)try{c=yield e.fulfilled(c)}catch(t){if(!e.rejected)throw t;e.rejected(t)}return c}))}}const Ne=e=>{const t=new URLSearchParams;return Object.keys(e).forEach((s=>{Array.isArray(e[s])?e[s].forEach((e=>{t.append(s,e)})):t.append(s,e[s])})),t},xe="/notifications",be=`${xe}/all`,Je=`${xe}/subscription`,Ae=`${xe}/permission`;class De{constructor(e){this.client=e}list(e){return this.client.rest.get(xe,e)}toggleStatus(e,t){return this.client.rest.put(xe,JSON.stringify({ids:e,to_status:t}))}toggleAllStatus(e){return this.client.rest.put(be,JSON.stringify({to_status:e}))}delete(e){return this.client.rest.delete(xe,{id:e})}deleteAll(){return this.client.rest.delete(be)}getPermission(){return this.client.rest.get(Ae)}setPermission(e){return this.client.rest.post(Ae,JSON.stringify({enabled:e}))}getSubscription(){return this.client.rest.get(Je)}setSubscription(e){const t={action_groups:Object.assign({},e)};return this.client.rest.post(Je,JSON.stringify(t))}}const Pe="/storage/files",Ue=`${Pe}/net`;class Te{constructor(e){this.client=e}read(e,t){return t.path=e,this.client.rest.get(Pe,t)}replace(e,t){const s=new URLSearchParams;return Object.keys(e).forEach((t=>{e[t]&&s.append(t,e[t])})),this.client.rest.put(`${Pe}?${s.toString()}`,t)}upload(e,t,s){const i=new FormData;return i.set("path",t),i.set("file",e),s&&i.set("divide_id",s.toString()),this.client.rest.post(Pe,i)}uploadNet(e){return this.client.rest.post(Ue,JSON.stringify(e))}}class Ee{constructor(e){this.authApiService=e,this.isUpdating=!1,this.tokenUpdatePromise=null,this.tokenUpdateResolve=null}isTokenExpire(e){if(!e)return!1;return 1e3*e<=(new Date).getTime()+3e3}refreshToken(e){return me(this,void 0,void 0,(function*(){const{access_token:t,refresh_token:s}=e;if(!t||!s)return null;if(this.isUpdating)return this.waitForTokenUpdate();this.isUpdating=!0;try{const t=yield this.authApiService.updateToken(e);if(t&&t.access_token&&t.refresh_token){const e={access_token:t.access_token,refresh_token:t.refresh_token};return this.tokenUpdateResolve&&(this.tokenUpdateResolve(e),this.tokenUpdateResolve=null),e}return null}catch(e){throw e}finally{this.isUpdating=!1}}))}waitForTokenUpdate(){return this.tokenUpdatePromise||(this.tokenUpdatePromise=new Promise((e=>{this.tokenUpdateResolve=e}))),this.tokenUpdatePromise}}class Ce{constructor(e){this.AuthApi=new i(this),this.ConnectionsApi=new U(this),this.DiscoveryApi=new T(this),this.DivideApi=new E(this),this.ExtensionsApi=new R(this),this.ExtensionsExternalApi=new j(this),this.FcaApi=new L(this),this.GatewayApi=new W(this),this.GroupApi=new V(this),this.LicenseApi=new z(this),this.LogstashApi=new K(this),this.NotificationsApi=new De(this),this.RoleApi=new Q(this),this.ShareApi=new oe(this),this.StorageElementApi=new _e(this),this.StorageFilesApi=new Te(this),this.StorageShareApi=new ae(this),this.StorageTrashApi=new ve(this),this.UserApi=new ne(this),this.tokenUpdate=new Ee(this.AuthApi),this.rest=new Oe(this,this.tokenUpdate),this.requestInterceptors=[],this.responseInterceptors=[],this.request={use:(e,t)=>{this.requestInterceptors.push({fulfilled:e,rejected:t})}},this.response={use:(e,t)=>{this.responseInterceptors.push({fulfilled:e,rejected:t})}},this.state={clientParams:{host:(null==e?void 0:e.host)||"",version:(null==e?void 0:e.version)||1},requestParams:{path:"",headers:{},query:{},body:null,cache:"no-cache"},authToken:{access_token:"",refresh_token:""},skipInterceptors:!1}}resetParams(e){return new Promise((t=>{const{host:s,version:i,headers:r,cache:n,authTokens:o,skipInterceptors:c}=e;this.state={clientParams:{host:s||this.state.clientParams.host,version:null!=i?i:this.state.clientParams.version},requestParams:Object.assign(Object.assign({},this.state.requestParams),{headers:r||this.state.requestParams.headers,cache:n||this.state.requestParams.cache}),authToken:o||this.state.authToken,skipInterceptors:c||this.state.skipInterceptors},t()}))}}export{i as AuthApiService,Ce as Client,o as ConnectionGroup,c as ConnectionType,U as ConnectionsApiService,T as DiscoveryApiService,E as DivideApiService,g as DivideMode,h as DivideScope,n as EngineType,l as ExtensionFileMode,a as ExtensionType,R as ExtensionsApiService,j as ExtensionsExternalApiService,L as FcaApiService,W as GatewayApiService,V as GroupApiService,z as LicenseApiService,_ as LicenseError,K as LogstashApiService,y as NotificationAction,$ as NotificationEntityType,k as NotificationRowAction,v as NotificationStyle,r as OrderDirection,d as PermissionType,Oe as Rest,p as RestrictionBooleanStatus,m as RestrictionSharing,u as RestrictionStatus,Q as RoleApiService,N as SettingControlType,oe as ShareApiService,_e as StorageElementApiService,b as StorageElementContentType,A as StorageElementHistoryAction,x as StorageElementType,J as StorageRoot,ae as StorageShareApiService,ve as StorageTrashApiService,f as Tariff,Ee as TokenUpdate,ne as UserApiService,S as UserAuthType,w as UserStatus,O as UserType};
1
+ const t="/login",e=`${t}/ldap`,s=`${t}/update`;class i{constructor(t){this.client=t}info(){return this.client.rest.get(t)}login(e){return this.client.rest.post(t,JSON.stringify(e))}ldapLogin(t){return this.client.rest.post(e,JSON.stringify(t))}updateToken(t){return this.client.rest.post(s,JSON.stringify(t))}logout(){return this.client.rest.post("/logout")}}var r,n,o,c,a,l,h,d,u,p,g,f,_,v,y,$,k,m,S,w,O,N,x,b,J,A;!function(t){t.DEFAULT="",t.ASC="asc",t.DESC="desc"}(r||(r={})),function(t){t.WebSocket="websocket",t.PostMessage="postmessage",t.Empty=""}(n||(n={})),function(t){t.Storages="storages_connections_group",t.Webhooks="webhooks_connections_group",t.Unknown="unknown_connections_group",t.Proxy="proxy_connections_group"}(o||(o={})),function(t){t.SSH="ssh_connection",t.YandexDisk="yandex_disk",t.Mail="mail",t.Discord="discord",t.Webdav="webdav_connection",t.Nextcloud="nextcloud_connection",t.NextBox="nextbox_connection",t.HttpProxy="http_proxy_connection",t.S3="s3_connection"}(c||(c={})),function(t){t.App="app",t.File="file",t.WorkDir="work_dir"}(a||(a={})),function(t){t.Read="read",t.ReadAndWrite="read_and_write",t.Write="write"}(l||(l={})),function(t){t.Storage="/storage/element",t.Connection="/connections"}(h||(h={})),function(t){t.CLOSE="",t.READ="r",t.WRITE="rw"}(d||(d={})),function(t){t.WAITING="waiting",t.APPROVED="approved",t.REJECTED="rejected"}(u||(u={})),function(t){t.TRUE="true",t.FALSE="false"}(p||(p={})),function(t){t.User="to_user_id",t.Group="to_user_group_id"}(g||(g={})),function(t){t.Free="free",t.Business="business",t.Enterprise="enterprise"}(f||(f={})),function(t){t.NotActivated="License not activated",t.Blocked="License blocked",t.Expired="License has been expired",t.NotValid="License not valid",t.NotFound="license file not found"}(_||(_={})),function(t){t.Dir="dir",t.File="file",t.User="user",t.Other="other",t.WorkDir="work_dir",t.License="license",t.Extension="extension",t.Connection="connection"}(v||(v={})),function(t){t.OpenSharing="open_sharing",t.ChangeSharing="change_sharing",t.CancelSharing="cancel_sharing",t.DivideDirAddFileToOwner="divide_dir_add_file_to_owner",t.DivideDirAddDirToOwner="divide_dir_add_dir_to_owner",t.DivideDirAddWorkDirToOwner="divide_dir_add_work_dir_to_owner",t.DivideConnectionAddFileToOwner="divide_connection_add_file_to_owner",t.DivideConnectionAddDirToOwner="divide_connection_add_dir_to_owner",t.CancelDivideDir="cancel_divide_dir",t.CancelDivideFile="cancel_divide_file",t.CancelDivideWorkDir="cancel_divide_work_dir",t.CancelDivideConnection="cancel_divide_connection",t.DeleteExtension="delete_extension",t.NewVersionExtension="new_version_extension",t.Other="other"}(y||(y={})),function(t){t.Read="read",t.Unread="unread",t.Delete="delete"}($||($={})),function(t){t.Plain="plain",t.Success="success",t.Info="info",t.Warning="warning",t.Error="error"}(k||(k={})),function(t){t.NONE="none",t.SOFT="soft",t.HARD="hard"}(m||(m={})),function(t){t.Native="native",t.Ldap="ldap"}(S||(S={})),function(t){t.Registering="registering",t.Activated="activated",t.Blocked="blocked",t.BlockedByLicense="blocked_by_license"}(w||(w={})),function(t){t.User="user",t.Guest="guest",t.Emperor="emperor",t.Anonymous="anonymous"}(O||(O={})),function(t){t.Text="text",t.String="string",t.Number="number",t.CheckBox="checkbox",t.Select="select",t.RadioList="radio_list",t.ConnectionChoose="connection_choose",t.MultiConnectionChoose="multi_connection_choose"}(N||(N={})),function(t){t.Dir="dir",t.File="file",t.WorkDir="work_dir"}(x||(x={})),function(t){t.Any="any",t.Dir="dir",t.Code="code",t.Image="image",t.Audio="audio",t.Video="video",t.Text="text",t.Doc="doc",t.Xls="xls",t.Ppt="ppt"}(b||(b={})),function(t){t.my="my",t.fca="fca",t.divide="divide",t.share="share",t.favorite="favorite"}(J||(J={})),function(t){t.Create="create",t.Update="update",t.Move="move"}(A||(A={}));const D="/connections",P=`${D}/dashboard`;class E{constructor(t){this.client=t}list(t){return this.client.rest.get(D,t)}get(t){return this.client.rest.get(`${D}/${t}`)}update(t,e){return this.client.rest.put(`${D}/${t}`,JSON.stringify(e))}delete(t){return this.client.rest.delete(`${D}/${t}`)}create(t){const e={[c.SSH]:"/disk/ssh",[c.Webdav]:"/disk/webdav",[c.Nextcloud]:"/disk/nextcloud",[c.NextBox]:"/disk/nextbox",[c.Discord]:"/webhooks/discord",[c.Mail]:"/webhooks/mail",[c.HttpProxy]:"/http_proxy",[c.S3]:"/disk/s3"};return this.client.rest.post(e[t.type]||D,JSON.stringify(t))}dashboard(t){return this.client.rest.get(P,t)}}class T{constructor(t){this.client=t}discovery(t){return this.client.rest.get("/discovery",t)}}class U{constructor(t){this.client=t}divideDelete(t,e){return this.client.rest.delete(`${t}/divide/${e}`)}divideDeleteAll(t,e,s,i){return this.client.rest.delete(`${t}/divide`,Object.assign(Object.assign({},this.makeParam(t,e)),{is_to_user_group:i,access_mode:s}))}divideChange(t,e,s){return this.client.rest.put(`${t}/divide/${e}`,JSON.stringify({access_mode:s}))}divideCreate(t,e,s,i,r){const n=Object.assign(Object.assign({},this.makeParam(t,e)),{[r]:s,access_mode:i});return this.client.rest.post(`${t}/divide`,JSON.stringify(n))}divideUsers(t,e,s){return this.client.rest.get(`${t}/divide/users`,Object.assign(Object.assign({},this.makeParam(t,e)),s))}restrictions(t){return this.client.rest.get("/divide/restrictions",t)}restrictionsChange(t,e){return this.client.rest.put(`/divide/restrictions/${t}`,JSON.stringify(e))}makeParam(t,e){const s={};return t===h.Connection?s.connection_id=e:s.path=e,s}}const R="/static/extensions",C="/extensions/defaults";class I{constructor(t){this.client=t}getSetting(t){return this.client.rest.get(`${R}/${t}/settings`)}setSetting(t,e){return this.client.rest.post(`${R}/${t}/settings`,JSON.stringify(e))}deleteSetting(t){return this.client.rest.delete(`${R}/${t}/settings`)}get(t){return this.client.rest.get(`${R}/${t}`)}getByKey(t){return this.client.rest.get(`${R}/${t}`)}getDefault(t=[]){return this.client.rest.get(C,{ext_code:t})}setDefault(t,e){return this.client.rest.post(C,JSON.stringify({ext_code:t,ext_uniq_key:e}))}checkUpdates(){return this.client.rest.post("/static/extensions/check_updates")}updateVersion(t,e){return this.client.rest.put(`/static/extensions/${t}`,JSON.stringify({version:e}))}list(t){return this.client.rest.get(R,t)}delete(t,e){return this.client.rest.delete(`${R}/${t}`)}upload(t){const e=new FormData;return e.set("file",t),this.client.rest.post(R,e)}install(t,e){return this.client.rest.post("/static/extensions/site",JSON.stringify({uniq_key:t,version:e}))}}class q{constructor(t){this.client=t}listExtensionsSite(t){return this.client.rest.get("/anons_ext/extensions",t)}extensionDetailSite(t){return this.client.rest.get(`/anons_ext/extensions/${t}`)}extensionMarkdown(t){return this.client.rest.get(`/anons_ext/extensions/${t}/readme`)}}const j="/disk",F=`${j}/check`;class L{constructor(t){this.client=t}info(t,e){return this.client.rest.get(`${j}/${t}/element`,{path:e})}list(t,e){return this.client.rest.get(`${j}/${t}`,e)}create(t,e){return this.client.rest.post(`${j}/${t}/element`,JSON.stringify(e))}replace(t,e,s){return this.client.rest.put(`${j}/${t}/files?path=${e}`,s)}read(t,e){return this.client.rest.get(`${j}/${t}/files?path=${e}`)}upload(t,e,s=""){const i=new FormData;return i.set("path",s),i.set("file",e),this.client.rest.post(`${j}/${t}/files`,i)}delete(t,e){return this.client.rest.delete(`${j}/${t}/trash/element`,{path:e})}check(t){return this.client.rest.post(F,JSON.stringify(t))}}class W{constructor(t){this.client=t}settings(){return this.client.rest.get("/settings")}changeSettings(t){return this.client.rest.post("/settings",JSON.stringify(t))}queryInit(){return this.client.rest.get("/query/init")}}const B="/groups";class H{constructor(t){this.client=t}list(t){return this.client.rest.get(B,t)}listUsers(t){return this.client.rest.get(`${B}/${t}/users`)}create(t){return this.client.rest.post(B,JSON.stringify(t))}update(t,e){return this.client.rest.put(`${B}/${t}`,JSON.stringify(e))}delete(t){return this.client.rest.delete(`${B}/${t}`)}}const V="/license",M=`${V}/manual-check`,G=`${V}/hardware/hash`;class z{constructor(t){this.client=t}info(){return this.client.rest.get(V)}create(t){return this.client.rest.post(V,JSON.stringify(t))}check(){return this.client.rest.post(M)}delete(){return this.client.rest.delete(V)}getHash(){return this.client.rest.get(G)}}class K{constructor(t){this.client=t}getUsersLogs(t){return this.client.rest.get("/logs/users",t)}getSystemLogs(t){return this.client.rest.get(t)}}const X="/roles",Y=`${X}/default`;class Q{constructor(t){this.client=t}list(t){return this.client.rest.get(X,t)}get(t){return this.client.rest.get(`${X}/${t}`)}getDefault(){return this.client.rest.get(`${Y}`)}create(t){return this.client.rest.post(X,JSON.stringify(t))}update(t,e){return this.client.rest.put(`${X}/${t}`,JSON.stringify(e))}delete(t){return this.client.rest.delete(`${X}/${t}`)}permissions(){return this.client.rest.get("/permissions")}addPermissions(t,e){return this.client.rest.put(`${X}/${t}/permissions`,JSON.stringify({ids:e}))}deletePermissions(t,e){return this.client.rest.delete(`${X}/${t}/permissions`,{ids:e})}}const Z="/users",tt=`${Z}/me`,et=`${tt}/avatars`,st=`${tt}/sessions`,it=`${tt}/tokens`,rt=`${tt}/change-password`;class nt{constructor(t){this.client=t}list(t){return this.client.rest.get(Z,t)}get(t){return this.client.rest.get(Z+`/${t}`)}create(t){return this.client.rest.post(Z,JSON.stringify(t))}update(t,e){return this.client.rest.put(Z+`/${t}`,JSON.stringify(e))}delete(t,e){return this.client.rest.delete(`${Z}/${t}`,e)}restore(t){return this.client.rest.post(`${Z}/${t}/restore`)}me(){return this.client.rest.get(tt)}updateMe(t){return this.client.rest.put(tt,JSON.stringify(t))}createToken(t){return this.client.rest.post(it,JSON.stringify(t))}listToken(t){return this.client.rest.get(it,t)}deleteToken(t){return this.client.rest.delete(`${it}/${t}`)}changeMyPassword(t){return this.client.rest.put(rt,JSON.stringify(t))}changeUsersPassword(t,e){return this.client.rest.put(`${Z}/${t}/change-password`,JSON.stringify(e))}meUploadAvatar(t,e){const s=new FormData;return s.append("file",t,e),this.client.rest.post(et,s)}meDeleteAvatar(){return this.client.rest.delete(et)}meListSession(t){return this.client.rest.get(st,t)}meDeleteSession(t){let e=st;return t&&(e+=`/${t}`),this.client.rest.delete(e)}setRole(t,e=null){return this.client.rest.put(`${Z}/${t}/roles`,JSON.stringify({role_id:e}))}}class ot{constructor(t){this.client=t}info(t,e){const s=new URLSearchParams({path:t,share_token:e});return this.client.rest.get(`/share?${s.toString()}`)}checkPassword(t,e){const s=encodeURIComponent(t);return this.client.rest.get(`share/password?share_token=${e}&share_pass=${s}`)}checkToken(t){return this.client.rest.get(`share?share_token=${t}`)}restrictions(t){return this.client.rest.get("/share/restrictions",t)}restrictionsChange(t,e){return this.client.rest.put(`/share/restrictions/${t}`,JSON.stringify(e))}}const ct="/storage/element/share";class at{constructor(t){this.client=t}info(t){return this.client.rest.get(ct,{path:t})}create(t,e){const s={path:t,permissions_type:e};return this.client.rest.post(ct,JSON.stringify(s))}change(t){return this.client.rest.put(`${ct}/${t.token}`,JSON.stringify(t))}delete(t){return this.client.rest.delete(ct,{path:t})}refresh(t){return this.client.rest.put(`${ct}/${t}/refresh`)}}const lt="/storage",ht=`${lt}/element`,dt=`${ht}/move`,ut=`${ht}/copy`,pt=`${ht}/history`,gt=`${ht}/version`,ft=`${gt}/current`;class _t{constructor(t){this.client=t}list(t){return this.client.rest.get(lt,t)}info(t){var e;return parseInt((null===(e=t.divide_id)||void 0===e?void 0:e.toString())||"")||delete t.divide_id,t.file_version_id||delete t.file_version_id,this.client.rest.get(ht,t)}size(t){var e;return parseInt((null===(e=t.divide_id)||void 0===e?void 0:e.toString())||"")||delete t.divide_id,this.client.rest.post(`${ht}/size`,JSON.stringify(t))}move(t,e=!1){const{from_divide_id:s,to_divide_id:i}=t,r=Object.assign(Object.assign({},t),{from_divide_id:null,to_divide_id:null});return e?s?i?this.client.rest.post(`/disk/${s}/files/move/disk/${i}`,JSON.stringify(r)):this.client.rest.put(`/disk/${s}/files/to/box`,JSON.stringify(r)):this.client.rest.put(`/disk/${i}/files/from/box`,JSON.stringify(r)):this.client.rest.post(dt,JSON.stringify(t))}copy(t,e,s){const{from_divide_id:i,to_divide_id:r}=t;let n=Object.assign(Object.assign({},t),{from_divide_id:null,to_divide_id:null});return s===J.fca&&e===J.fca?this.client.rest.post(`/disk/${i}/files/copy/disk/${r}`,JSON.stringify(n)):s===J.fca?(i&&(n.from_divide_id=i),this.client.rest.post(`/disk/${r}/files/from/box`,JSON.stringify(n))):e===J.fca?(r&&(n.to_divide_id=r),this.client.rest.post(`/disk/${i}/files/to/box`,JSON.stringify(n))):this.client.rest.post(ut,JSON.stringify(t))}pasteFromShared(t,e,s){const i={from_sharing_token:t,from_sharing_password:s,paths:e};return this.client.rest.post("/storage/element/copy",JSON.stringify(i))}create(t){return this.client.rest.post(ht,JSON.stringify(t))}delete(t,e){const s={path:t};return e&&(s.divide_id=e),this.client.rest.delete(ht,s)}favorite(t){return this.client.rest.put(`${ht}?path=${encodeURIComponent(t)}`,JSON.stringify({is_favorite:!0}))}removeFavorite(t){return this.client.rest.put(`${ht}?path=${encodeURIComponent(t)}`,JSON.stringify({is_favorite:!1}))}createItem(t){return this.client.rest.post(ht,JSON.stringify(t))}createWorkDir(t){return this.client.rest.post(ht,JSON.stringify(t))}history(t){return this.client.rest.get(pt,t)}versions(t){return this.client.rest.get(gt,t)}createVersion(t){return this.client.rest.post(gt,JSON.stringify(t))}editVersion(t){return this.client.rest.put(gt,JSON.stringify(t))}deleteVersion(t){return this.client.rest.delete(gt,t)}makeCurrentVersion(t){return this.client.rest.post(ft,JSON.stringify(t))}}const vt="/storage/trash",yt=`${vt}/element`,$t=`${yt}/all`;class kt{constructor(t){this.client=t}list(t){return this.client.rest.get(vt,t)}clear(t){return this.client.rest.delete(yt,t)}clearAll(){return this.client.rest.delete($t)}restore(t){return this.client.rest.patch(yt,JSON.stringify({del_groups:t}))}}function mt(t,e,s,i){return new(s||(s=Promise))((function(r,n){function o(t){try{a(i.next(t))}catch(t){n(t)}}function c(t){try{a(i.throw(t))}catch(t){n(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,c)}a((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class St extends Error{}function wt(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,((t,e)=>{let s=e.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s})))}(e)}catch(t){return atob(e)}}function Ot(t,e){if("string"!=typeof t)throw new St("Invalid token specified: must be a string");e||(e={});const s=!0===e.header?0:1,i=t.split(".")[s];if("string"!=typeof i)throw new St(`Invalid token specified: missing part #${s+1}`);let r;try{r=wt(i)}catch(t){throw new St(`Invalid token specified: invalid base64 for part #${s+1} (${t.message})`)}try{return JSON.parse(r)}catch(t){throw new St(`Invalid token specified: invalid json for part #${s+1} (${t.message})`)}}St.prototype.name="InvalidTokenError";class Nt{constructor(t){var e,s;this.name="HttpErrorResponse",this.ok=!1,this.message=t.error?`${t.error.message}`:"HttpErrorResponse",this.error=t.error||null,this.status=null!==(e=t.status)&&void 0!==e?e:500,this.statusText=null!==(s=t.statusText)&&void 0!==s?s:"Internal Server Error",this.headers=t.headers,this.url=t.url}}const xt=(t,e)=>mt(void 0,void 0,void 0,(function*(){let s=e;for(const e of t)try{s=yield e.fulfilled(s)}catch(t){if(!e.rejected)throw t;s=yield e.rejected(t)}return s})),bt=t=>{const e=document.cookie.split(";"),s=t+"=";for(let t of e)if(t=t.trim(),t.startsWith(s)){let e=t.substring(s.length);return decodeURIComponent(e)}return null},Jt=t=>{const e=new URLSearchParams;return Object.keys(t).forEach((s=>{Array.isArray(t[s])?t[s].forEach((t=>{e.append(s,t)})):e.append(s,t[s])})),e};class At{constructor(t,e){this.client=t,this.tokenUpdate=e}get state(){return this.client.state}get(t,e){return this.sendRequest("GET",t,{query:e,cache:"no-cache"})}post(t,e){return this.sendRequest("POST",t,{body:e})}put(t,e){return this.sendRequest("PUT",t,{body:e,cache:"no-cache"})}patch(t,e){return this.sendRequest("PATCH",t,{body:e})}delete(t,e){return this.sendRequest("DELETE",t,{query:e})}sendRequest(t,e){return mt(this,arguments,void 0,(function*(t,e,s={}){var i;const r=null!==(i=this.state.skipInterceptors)&&void 0!==i&&i;this.state.skipInterceptors=!1;let n={method:t,headers:this.state.requestParams.headers,cache:s.cache||this.state.requestParams.cache,body:s.body||this.state.requestParams.body};if(r||(n=yield xt(this.client.requestInterceptors,n)),this.state.authToken)for(const[t,s]of this.state.authToken.entries()){const i=Ot(s.access_token);if(i&&i.is_remember&&this.tokenUpdate.isTokenExpire(i.exp)&&!e.includes("/login")&&!e.includes("/assets")){const e=yield this.tokenUpdate.refreshToken(s);e&&(this.state.authToken[t]=e,n=yield xt(this.client.requestInterceptors,n))}}s.query&&(e+="?"+Jt(s.query));const o=`${this.state.clientParams.host}/api/v${this.state.clientParams.version||1}${e}`.replace(/([^:]\/)+\/+/g,"$1");let c=yield((t,e)=>mt(this,void 0,void 0,(function*(){try{const s=yield fetch(t,e);let i;try{i=yield s.clone().json()}catch(t){i=yield s.text()}if(!s.ok)throw console.log("NB RESPONSE NOT OK",s),new Nt({error:i,status:s.status,statusText:s.statusText,url:s.url});return s}catch(t){throw console.log("NB ERROR",t),yield xt(this.client.responseInterceptors,t),t}})))(o,n);return c=yield xt(this.client.responseInterceptors,c),c}))}}const Dt="/notifications",Pt=`${Dt}/all`,Et=`${Dt}/subscription`,Tt=`${Dt}/permission`;class Ut{constructor(t){this.client=t}list(t){return this.client.rest.get(Dt,t)}toggleStatus(t,e){return this.client.rest.put(Dt,JSON.stringify({ids:t,to_status:e}))}toggleAllStatus(t){return this.client.rest.put(Pt,JSON.stringify({to_status:t}))}delete(t){return this.client.rest.delete(Dt,{id:t})}deleteAll(){return this.client.rest.delete(Pt)}getPermission(){return this.client.rest.get(Tt)}setPermission(t){return this.client.rest.post(Tt,JSON.stringify({enabled:t}))}getSubscription(){return this.client.rest.get(Et)}setSubscription(t){const e={action_groups:Object.assign({},t)};return this.client.rest.post(Et,JSON.stringify(e))}}const Rt="/storage/files",Ct=`${Rt}/net`;class It{constructor(t){this.client=t}read(t,e){return e.path=t,this.client.rest.get(Rt,e)}replace(t,e){const s=new URLSearchParams;return Object.keys(t).forEach((e=>{t[e]&&s.append(e,t[e])})),this.client.rest.put(`${Rt}?${s.toString()}`,e)}upload(t,e,s){const i=new FormData;return i.set("path",e),i.set("file",t),s&&i.set("divide_id",s.toString()),this.client.rest.post(Rt,i)}uploadNet(t){return this.client.rest.post(Ct,JSON.stringify(t))}}class qt{constructor(t){this.authApiService=t,this.isUpdating=!1,this.tokenUpdatePromise=null,this.tokenUpdateResolve=null}isTokenExpire(t){if(!t)return!1;return 1e3*t<=(new Date).getTime()+3e3}refreshToken(t){return mt(this,void 0,void 0,(function*(){const{access_token:e,refresh_token:s}=t;if(!e||!s)return null;if(this.isUpdating)return this.waitForTokenUpdate();this.isUpdating=!0;try{const e=yield this.authApiService.updateToken(t);if(e&&e.access_token&&e.refresh_token){const t={access_token:e.access_token,refresh_token:e.refresh_token};return bt("access_token")===t.access_token&&localStorage.setItem("refresh-token",t.refresh_token),this.tokenUpdateResolve&&(this.tokenUpdateResolve(t),this.tokenUpdateResolve=null),t}return null}catch(t){throw t}finally{this.isUpdating=!1}}))}waitForTokenUpdate(){return this.tokenUpdatePromise||(this.tokenUpdatePromise=new Promise((t=>{this.tokenUpdateResolve=t}))),this.tokenUpdatePromise}}class jt{constructor(t){this.AuthApi=new i(this),this.ConnectionsApi=new E(this),this.DiscoveryApi=new T(this),this.DivideApi=new U(this),this.ExtensionsApi=new I(this),this.ExtensionsExternalApi=new q(this),this.FcaApi=new L(this),this.GatewayApi=new W(this),this.GroupApi=new H(this),this.LicenseApi=new z(this),this.LogstashApi=new K(this),this.NotificationsApi=new Ut(this),this.RoleApi=new Q(this),this.ShareApi=new ot(this),this.StorageElementApi=new _t(this),this.StorageFilesApi=new It(this),this.StorageShareApi=new at(this),this.StorageTrashApi=new kt(this),this.UserApi=new nt(this),this.tokenUpdate=new qt(this.AuthApi),this.rest=new At(this,this.tokenUpdate),this.requestInterceptors=[],this.responseInterceptors=[],this.request={use:(t,e)=>{this.requestInterceptors.push({fulfilled:t,rejected:e})}},this.response={use:(t,e)=>{this.responseInterceptors.push({fulfilled:t,rejected:e})}},this.state={clientParams:{host:(null==t?void 0:t.host)||"",version:(null==t?void 0:t.version)||1},requestParams:{path:"",headers:{},query:{},body:null,cache:"no-cache"},authToken:null,skipInterceptors:!1}}resetParams(t){return new Promise((e=>{const{host:s,version:i,headers:r,cache:n,authTokens:o,skipInterceptors:c}=t;this.state={clientParams:{host:s||this.state.clientParams.host,version:null!=i?i:this.state.clientParams.version},requestParams:Object.assign(Object.assign({},this.state.requestParams),{headers:r||this.state.requestParams.headers,cache:n||this.state.requestParams.cache}),authToken:o||this.state.authToken,skipInterceptors:c||this.state.skipInterceptors},e()}))}}export{i as AuthApiService,jt as Client,o as ConnectionGroup,c as ConnectionType,E as ConnectionsApiService,T as DiscoveryApiService,U as DivideApiService,g as DivideMode,h as DivideScope,n as EngineType,l as ExtensionFileMode,a as ExtensionType,I as ExtensionsApiService,q as ExtensionsExternalApiService,L as FcaApiService,W as GatewayApiService,H as GroupApiService,z as LicenseApiService,_ as LicenseError,K as LogstashApiService,y as NotificationAction,v as NotificationEntityType,$ as NotificationRowAction,k as NotificationStyle,r as OrderDirection,d as PermissionType,At as Rest,p as RestrictionBooleanStatus,m as RestrictionSharing,u as RestrictionStatus,Q as RoleApiService,N as SettingControlType,ot as ShareApiService,_t as StorageElementApiService,b as StorageElementContentType,A as StorageElementHistoryAction,x as StorageElementType,J as StorageRoot,at as StorageShareApiService,kt as StorageTrashApiService,f as Tariff,qt as TokenUpdate,nt as UserApiService,S as UserAuthType,w as UserStatus,O as UserType,xt as applyInterceptors,bt as getCookieValue,Jt as makeUrlParams};
@@ -5,7 +5,7 @@ import { AuthToken } from '../types';
5
5
  import { NbAppState, NbClientParams } from '../types/base';
6
6
  import { Interceptor } from '../types/interceptor';
7
7
  import { Rest } from './rest';
8
- import { TokenUpdate } from './tokenUpdate';
8
+ import { TokenUpdate } from './token-update';
9
9
  export declare class Client {
10
10
  state: NbAppState;
11
11
  AuthApi: AuthApiService;
@@ -43,7 +43,7 @@ export declare class Client {
43
43
  version?: number;
44
44
  headers?: Record<string, any>;
45
45
  cache?: RequestCache;
46
- authTokens?: AuthToken;
46
+ authTokens?: AuthToken[] | null;
47
47
  skipInterceptors?: boolean;
48
48
  }): Promise<void>;
49
49
  }
@@ -0,0 +1,17 @@
1
+ export declare class HttpErrorResponse implements Error {
2
+ readonly name: string;
3
+ readonly message: string;
4
+ readonly error: any | null;
5
+ readonly status: number;
6
+ readonly statusText: string;
7
+ readonly headers: Headers | undefined;
8
+ readonly url: string | undefined;
9
+ readonly ok: boolean;
10
+ constructor(init: {
11
+ error?: any;
12
+ status?: number;
13
+ statusText?: string;
14
+ headers?: Headers;
15
+ url?: string;
16
+ });
17
+ }
@@ -1,3 +1,3 @@
1
1
  export * from './rest';
2
2
  export * from './client';
3
- export * from './tokenUpdate';
3
+ export * from './token-update';
@@ -1,6 +1,6 @@
1
1
  import { Client } from './client';
2
2
  import { NbAppState } from '../types';
3
- import { TokenUpdate } from './tokenUpdate';
3
+ import { TokenUpdate } from './token-update';
4
4
  export declare class Rest {
5
5
  private client;
6
6
  private tokenUpdate;
@@ -0,0 +1,12 @@
1
+ import { AuthApiService } from '../api';
2
+ import { AuthToken } from '../types';
3
+ export declare class TokenUpdate {
4
+ private authApiService;
5
+ private isUpdating;
6
+ private tokenUpdatePromise;
7
+ private tokenUpdateResolve;
8
+ constructor(authApiService: AuthApiService);
9
+ isTokenExpire(timestamp: number): boolean;
10
+ refreshToken(authToken: AuthToken): Promise<AuthToken | null>;
11
+ private waitForTokenUpdate;
12
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  interface AuthToken {
2
2
  access_token: string;
3
3
  refresh_token: string;
4
+ with_cookie?: boolean;
4
5
  }
5
6
  interface AuthType {
6
7
  classic: boolean;
@@ -22,7 +23,7 @@ interface NbRequestParams {
22
23
  interface NbAppState {
23
24
  clientParams: NbClientParams;
24
25
  requestParams: NbRequestParams;
25
- authToken: AuthToken;
26
+ authToken: AuthToken[] | null;
26
27
  skipInterceptors: boolean;
27
28
  }
28
29
  interface ResponseItem<T> {
@@ -815,7 +816,7 @@ declare class Client {
815
816
  version?: number;
816
817
  headers?: Record<string, any>;
817
818
  cache?: RequestCache;
818
- authTokens?: AuthToken;
819
+ authTokens?: AuthToken[] | null;
819
820
  skipInterceptors?: boolean;
820
821
  }): Promise<void>;
821
822
  }
@@ -1077,4 +1078,13 @@ declare class StorageTrashApiService {
1077
1078
  restore(del_groups: StorageTrashItem[]): Promise<void>;
1078
1079
  }
1079
1080
 
1080
- export { AuthApiService, type AuthToken, type AuthType, type ChangeLicenseParams, Client, type Connection, type ConnectionCreateParams, ConnectionGroup, ConnectionType, ConnectionsApiService, type CreateGroupParams, type CreateRoleParams, type CreateStorageElementParams, type CreateUserParams, type Discovery, DiscoveryApiService, DivideApiService, DivideMode, type DivideResourceType, type DivideResponseList, DivideScope, EngineType, type Extension, type ExtensionDefault, type ExtensionExternal, type ExtensionExternalInList, type ExtensionExternalListParams, ExtensionFileMode, type ExtensionListParams, type ExtensionMetaPayload, ExtensionType, ExtensionsApiService, ExtensionsExternalApiService, FcaApiService, GatewayApiService, type Group, GroupApiService, type Lang, type License, LicenseApiService, LicenseError, type LockScreen, LogstashApiService, type NbAppState, type NbClientParams, type NbRequestParams, NotificationAction, type NotificationActionGroup, NotificationEntityType, type NotificationPayload, NotificationRowAction, NotificationStyle, OrderDirection, type PayloadFile, type Permission, type PermissionItem, PermissionType, type QueryInit, type RequestBaseParams, type RequestConnectionParams, type RequestGroupListParams, type RequestHistoryListParams, type RequestNotificationListParams, type RequestRoleListParams, type RequestStorageListParams, type RequestUserDivideParams, type RequestUserListParams, type RequestUsersLogParams, type ResponseItem, type ResponseList, type ResponseListNotification, Rest, type Restriction, RestrictionBooleanStatus, RestrictionSharing, RestrictionStatus, type Role, RoleApiService, type Setting, SettingControlType, type SettingField, type SettingFieldView, type SettingLang, type SettingValue, type SettingValueField, type SettingVariant, type SettingViewConnectionChoose, type SettingViewSelect, ShareApiService, type ShareInfo, type ShareModel, type StorageElement, StorageElementApiService, StorageElementContentType, type StorageElementHistory, StorageElementHistoryAction, type StorageElementHistoryNote, type StorageElementPaste, type StorageElementPasteParams, StorageElementType, type StorageElementVersion, StorageRoot, type StorageRouteData, StorageShareApiService, StorageTrashApiService, type StorageTrashElement, type StorageTrashItem, Tariff, TokenUpdate, type UploadNetRequestParams, type User, UserApiService, UserAuthType, type UserDivide, type UserLabel, type UserNotification, type UserSession, UserStatus, type UserToken, UserType, type UsersLog };
1081
+ declare const applyInterceptors: <T>(interceptors: {
1082
+ fulfilled: (arg: T) => T | Promise<T>;
1083
+ rejected?: (error: any) => T | Promise<T>;
1084
+ }[], arg: T) => Promise<T>;
1085
+
1086
+ declare const getCookieValue: (name: string) => string | null;
1087
+
1088
+ declare const makeUrlParams: (params: Record<string, any>) => URLSearchParams;
1089
+
1090
+ export { AuthApiService, type AuthToken, type AuthType, type ChangeLicenseParams, Client, type Connection, type ConnectionCreateParams, ConnectionGroup, ConnectionType, ConnectionsApiService, type CreateGroupParams, type CreateRoleParams, type CreateStorageElementParams, type CreateUserParams, type Discovery, DiscoveryApiService, DivideApiService, DivideMode, type DivideResourceType, type DivideResponseList, DivideScope, EngineType, type Extension, type ExtensionDefault, type ExtensionExternal, type ExtensionExternalInList, type ExtensionExternalListParams, ExtensionFileMode, type ExtensionListParams, type ExtensionMetaPayload, ExtensionType, ExtensionsApiService, ExtensionsExternalApiService, FcaApiService, GatewayApiService, type Group, GroupApiService, type Lang, type License, LicenseApiService, LicenseError, type LockScreen, LogstashApiService, type NbAppState, type NbClientParams, type NbRequestParams, NotificationAction, type NotificationActionGroup, NotificationEntityType, type NotificationPayload, NotificationRowAction, NotificationStyle, OrderDirection, type PayloadFile, type Permission, type PermissionItem, PermissionType, type QueryInit, type RequestBaseParams, type RequestConnectionParams, type RequestGroupListParams, type RequestHistoryListParams, type RequestNotificationListParams, type RequestRoleListParams, type RequestStorageListParams, type RequestUserDivideParams, type RequestUserListParams, type RequestUsersLogParams, type ResponseItem, type ResponseList, type ResponseListNotification, Rest, type Restriction, RestrictionBooleanStatus, RestrictionSharing, RestrictionStatus, type Role, RoleApiService, type Setting, SettingControlType, type SettingField, type SettingFieldView, type SettingLang, type SettingValue, type SettingValueField, type SettingVariant, type SettingViewConnectionChoose, type SettingViewSelect, ShareApiService, type ShareInfo, type ShareModel, type StorageElement, StorageElementApiService, StorageElementContentType, type StorageElementHistory, StorageElementHistoryAction, type StorageElementHistoryNote, type StorageElementPaste, type StorageElementPasteParams, StorageElementType, type StorageElementVersion, StorageRoot, type StorageRouteData, StorageShareApiService, StorageTrashApiService, type StorageTrashElement, type StorageTrashItem, Tariff, TokenUpdate, type UploadNetRequestParams, type User, UserApiService, UserAuthType, type UserDivide, type UserLabel, type UserNotification, type UserSession, UserStatus, type UserToken, UserType, type UsersLog, applyInterceptors, getCookieValue, makeUrlParams };
@@ -0,0 +1,4 @@
1
+ export declare const applyInterceptors: <T>(interceptors: {
2
+ fulfilled: (arg: T) => T | Promise<T>;
3
+ rejected?: (error: any) => T | Promise<T>;
4
+ }[], arg: T) => Promise<T>;
@@ -0,0 +1 @@
1
+ export declare const getCookieValue: (name: string) => string | null;
@@ -0,0 +1,3 @@
1
+ export * from './apply-interceptors';
2
+ export * from './get-cookie-value';
3
+ export * from './make-url-params';
@@ -0,0 +1 @@
1
+ export declare const makeUrlParams: (params: Record<string, any>) => URLSearchParams;
@@ -1,6 +1,7 @@
1
1
  export interface AuthToken {
2
2
  access_token: string;
3
3
  refresh_token: string;
4
+ with_cookie?: boolean;
4
5
  }
5
6
  export interface AuthType {
6
7
  classic: boolean;
@@ -13,7 +13,7 @@ export interface NbRequestParams {
13
13
  export interface NbAppState {
14
14
  clientParams: NbClientParams;
15
15
  requestParams: NbRequestParams;
16
- authToken: AuthToken;
16
+ authToken: AuthToken[] | null;
17
17
  skipInterceptors: boolean;
18
18
  }
19
19
  export interface ResponseItem<T> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nb-js-client",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "main": "dist/bundle.cjs.js",
5
5
  "module": "dist/bundle.esm.js",
6
6
  "files": [