@plusauth/plusauth-rest-js
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -0,1 +1,8 @@ | ||
# [0.2.0](https://github.com/PlusAuth/plusauth-rest-js/compare/v0.1.2...v0.2.0) (2021-03-23) | ||
### Features | ||
* option for providing custom http client ([759d4f1](https://github.com/PlusAuth/plusauth-rest-js/commit/759d4f1bcd891c82d1022d6320bf14053ffefe8f)) | ||
## [0.1.2](https://github.com/PlusAuth/plusauth-rest-js/compare/v0.1.1...v0.1.2) (2021-03-22) | ||
@@ -2,0 +9,0 @@ |
@@ -519,3 +519,3 @@ | ||
['constructor']: typeof HttpService; | ||
constructor(apiURL: string, headers?: Record<string, any>); | ||
constructor(apiURL: string, options?: Record<string, any>); | ||
} | ||
@@ -741,2 +741,3 @@ | ||
declare type Options = { | ||
httpClient?: (uri: string, options: RequestInit) => Promise<any>; | ||
token?: string | (() => string); | ||
@@ -743,0 +744,0 @@ } & Record<string, string>; |
@@ -240,3 +240,3 @@ var PlusAuthRestClient = (function () { | ||
class HttpService { | ||
constructor(apiURL, headers = {}) { | ||
constructor(apiURL, options = {}) { | ||
if (!apiURL) { | ||
@@ -251,8 +251,12 @@ throw new Error("'apiURL' must be provided"); | ||
} | ||
if (typeof headers !== 'object') { | ||
throw new Error("'headers' must be an object"); | ||
if (typeof options !== 'object') { | ||
throw new Error("'options' must be an object"); | ||
} | ||
if (options.httpClient && typeof options.httpClient !== 'function') { | ||
throw new Error('"httpClient" must be function'); | ||
} | ||
const finalUri = apiURL + (/\/api\/v\d(\/)?$/.test(apiURL) ? '' | ||
: `${apiURL.endsWith('/') ? '' : '/'}api/v1`); | ||
const _baseUrl = finalUri + this.constructor.prefix; | ||
const httpClient = options.httpClient || fetchAsPromise; | ||
const http = {}; | ||
@@ -262,7 +266,7 @@ ['get', 'post', 'patch', 'delete'].forEach(method => { | ||
let token; | ||
if (headers && typeof headers.token === 'function') { | ||
token = headers.token.call(undefined); | ||
if (options && typeof options.token === 'function') { | ||
token = options.token.call(undefined); | ||
} | ||
else { | ||
token = headers.token; | ||
token = options.token; | ||
} | ||
@@ -272,3 +276,2 @@ let fetchOptions = { | ||
mode: 'cors', | ||
credentials: 'include', | ||
headers: Object.assign({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }, token ? { 'Authorization': `Bearer ${token}` } : {}) | ||
@@ -284,3 +287,3 @@ }; | ||
} | ||
return fetchAsPromise.call(null, _baseUrl + args[0], fetchOptions); | ||
return httpClient.call(null, _baseUrl + args[0], fetchOptions); | ||
}; | ||
@@ -287,0 +290,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
var PlusAuthRestClient=function(){"use strict";function t(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function u(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,u)}h((n=n.apply(t,e||[])).next())}))}var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===i}(t)}(t)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(t,e){return!1!==e.clone&&e.isMergeableObject(t)?h((i=t,Array.isArray(i)?[]:{}),t,e):t;var i}function r(t,e,i){return t.concat(e).map((function(t){return n(t,i)}))}function o(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return t.propertyIsEnumerable(e)})):[]}(t))}function s(t,e){try{return e in t}catch(t){return!1}}function u(t,e,i){var r={};return i.isMergeableObject(t)&&o(t).forEach((function(e){r[e]=n(t[e],i)})),o(e).forEach((function(o){(function(t,e){return s(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,o)||(s(t,o)&&i.isMergeableObject(e[o])?r[o]=function(t,e){if(!e.customMerge)return h;var i=e.customMerge(t);return"function"==typeof i?i:h}(o,i)(t[o],e[o],i):r[o]=n(e[o],i))})),r}function h(t,i,o){(o=o||{}).arrayMerge=o.arrayMerge||r,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=n;var s=Array.isArray(i);return s===Array.isArray(t)?s?o.arrayMerge(t,i,o):u(t,i,o):n(i,o)}h.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,i){return h(t,i,e)}),{})};var d=h;function c(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})})),e}var p=c(Object.freeze({__proto__:null,default:function(t,e){return e=e||{},new Promise((function(i,n){var r=new XMLHttpRequest,o=[],s=[],u={},h=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(JSON.parse(r.responseText))},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:h,headers:{keys:function(){return o},entries:function(){return s},get:function(t){return u[t.toLowerCase()]},has:function(t){return t.toLowerCase()in u}}}};for(var d in r.open(e.method||"get",t,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,i){o.push(e=e.toLowerCase()),s.push([e,i]),u[e]=u[e]?u[e]+","+i:i})),i(h())},r.onerror=n,r.withCredentials="include"==e.credentials,e.headers)r.setRequestHeader(d,e.headers[d]);r.send(e.body||null)}))}}));const v=window.fetch||(window.fetch=p.default||p);function a(e,i){var n;return t(this,void 0,void 0,(function*(){const t=e.headers.get("content-type");return"stream"===i.responseType?null===(n=e.body)||void 0===n?void 0:n.getReader():"json"===i.responseType||t&&t.indexOf("application/json")>-1?yield e.json():yield e.text()}))}function f(t,e){return new Promise((function(i,n){v(t,e).then((t=>{const r=t.clone();t.ok?a(r,e).then(i).catch(n):400===t.status?a(r,e).then((t=>{if("xhr_request"===t.error&&t.location)return window.location.replace(t.location),!1;n(t)})).catch(n):a(r,e).then(n).catch(n)})).catch(n)}))}class l{constructor(t,e={}){if(!t)throw new Error("'apiURL' must be provided");try{new URL(t)}catch(t){throw new Error("'apiUrl' must be a valid uri")}if("object"!=typeof e)throw new Error("'headers' must be an object");const i=t+(/\/api\/v\d(\/)?$/.test(t)?"":(t.endsWith("/")?"":"/")+"api/v1")+this.constructor.prefix,n={};["get","post","patch","delete"].forEach((t=>{n[t]=function(...n){let r;r=e&&"function"==typeof e.token?e.token.call(void 0):e.token;let o={method:t.toUpperCase(),mode:"cors",credentials:"include",headers:Object.assign({Accept:"application/json","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},r?{Authorization:`Bearer ${r}`}:{})};return n.length>1&&"get"!==t&&(o.body="object"==typeof n[1]?JSON.stringify(n[1]):n[1]),n[2]&&"object"==typeof n[2]&&(o=d(o,n[2])),f.call(null,i+n[0],o)}})),this._baseUrl=i,this.http=n}}function g(t,e=!0){if(!t)return"";const i=[];for(const e in t)null!=t[e]&&i.push(`${encodeURIComponent(e)}=${t[e].toString()}`);return e?`?${i.join("&")}`:i.join("&")}l.prefix="";class $ extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/permissions${g(i)}`)}))}createPermission(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/permissions`,i)}))}removePermission(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/permissions/${i}`)}))}getAuthorizedClients(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/authorized_clients${g(i)}`)}))}authorizeClients(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/authorized_clients`,i)}))}unAuthorizeClients(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/authorized_clients`,i)}))}getAssignedPermissionsToClient(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/authorized_clients/${i}/permissions`)}))}assignPermissionsToClient(e,i,n){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/authorized_clients/${i}/permissions`,n)}))}unassignPermissionsFromClient(e,i,n){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/authorized_clients/${i}/permissions`,n)}))}}$.prefix="/apis";class m extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}}m.prefix="/clients";class y extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}validate(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/validate`)}))}}y.prefix="/custom-domain";class b extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}}b.prefix="/federated";class w extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(`${g(e)}`)}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(""+(e?`/${e}`:""),i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}addPackages(e,i,n=!1){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/packages`,i,{responseType:n?"stream":void 0})}))}deletePackages(e,i,n=!1){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/packages`,i,{responseType:n?"stream":void 0})}))}execute(t,e,i){return this.http.post("/hook-test",{context:t,user:e,hook:i})}}w.prefix="/hooks";class x extends l{getAll(e,i){return t(this,void 0,void 0,(function*(){return i&&"object"==typeof i&&(i=JSON.stringify(i)),this.http.get(g(Object.assign(Object.assign({},e),{query:i})))}))}}x.prefix="/logs";class j extends l{getAll(){return t(this,void 0,void 0,(function*(){return this.http.get("")}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}}j.prefix="/mfa";class A extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/roles${g(i)}`)}))}assignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/roles`,i)}))}unAssignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/roles/${i}`)}))}}A.prefix="/roleGroups";class P extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/permissions${g(i)}`)}))}assignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/permissions`,i)}))}unAssignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/permissions/${i}`)}))}}P.prefix="/roles";class O extends l{get(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/${i}`)}))}update(e,i,n){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/${i}`,n)}))}}O.prefix="/templates";class S extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(`${g(e)}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e,{headers:{"X-PlusAuth-Tenant":"api"}})}))}delete(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getSettings(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/settings`)}))}updateSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/settings`,i)}))}inviteAdmin(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/invite`,{email:i})}))}getAdministrators(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/administrators`)}))}removeAdministrator(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/administrators/${i}`)}))}getStats(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/stats${g(i)}`)}))}getSMSProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/provider/sms${i?`/${i}`:""}`)}))}updateSMSProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/provider/sms`,i)}))}getEmailProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/provider/email${i?`/${i}`:""}`)}))}updateEmailProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/provider/sms`,i)}))}}S.prefix="/tenants";class R extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}getSessions(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/session`)}))}endSession(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/session/${i}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}getTenants(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/tenants`)}))}getRoleGroups(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/roleGroups`)}))}assignRoleGroups(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/roleGroups`,i)}))}unAssignRoleGroups(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/roleGroups`,i)}))}getRoles(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/roles`)}))}assignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/roles`,i)}))}unAssignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/roles`,i)}))}getPermissions(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/permissions`)}))}assignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/permissions`,i)}))}unAssignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/permissions`,i)}))}}R.prefix="/users";class k extends l{get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i,{headers:{"Content-Type":"text/plain"}})}))}}k.prefix="/views";return class{constructor(t,e={}){this.options=e,this.apis=new $(t,this.options),this.clients=new m(t,this.options),this.customDomains=new y(t,this.options),this.federated=new b(t,this.options),this.hooks=new w(t,this.options),this.logs=new x(t,this.options),this.mfa=new j(t,this.options),this.roleGroups=new A(t,this.options),this.roles=new P(t,this.options),this.templates=new O(t,this.options),this.tenants=new S(t,this.options),this.users=new R(t,this.options),this.views=new k(t,this.options)}}}(); | ||
var PlusAuthRestClient=function(){"use strict";function t(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function u(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,u)}h((n=n.apply(t,e||[])).next())}))}var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===i}(t)}(t)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(t,e){return!1!==e.clone&&e.isMergeableObject(t)?h((i=t,Array.isArray(i)?[]:{}),t,e):t;var i}function r(t,e,i){return t.concat(e).map((function(t){return n(t,i)}))}function o(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return t.propertyIsEnumerable(e)})):[]}(t))}function s(t,e){try{return e in t}catch(t){return!1}}function u(t,e,i){var r={};return i.isMergeableObject(t)&&o(t).forEach((function(e){r[e]=n(t[e],i)})),o(e).forEach((function(o){(function(t,e){return s(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,o)||(s(t,o)&&i.isMergeableObject(e[o])?r[o]=function(t,e){if(!e.customMerge)return h;var i=e.customMerge(t);return"function"==typeof i?i:h}(o,i)(t[o],e[o],i):r[o]=n(e[o],i))})),r}function h(t,i,o){(o=o||{}).arrayMerge=o.arrayMerge||r,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=n;var s=Array.isArray(i);return s===Array.isArray(t)?s?o.arrayMerge(t,i,o):u(t,i,o):n(i,o)}h.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,i){return h(t,i,e)}),{})};var d=h;function c(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})})),e}var p=c(Object.freeze({__proto__:null,default:function(t,e){return e=e||{},new Promise((function(i,n){var r=new XMLHttpRequest,o=[],s=[],u={},h=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(JSON.parse(r.responseText))},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:h,headers:{keys:function(){return o},entries:function(){return s},get:function(t){return u[t.toLowerCase()]},has:function(t){return t.toLowerCase()in u}}}};for(var d in r.open(e.method||"get",t,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,i){o.push(e=e.toLowerCase()),s.push([e,i]),u[e]=u[e]?u[e]+","+i:i})),i(h())},r.onerror=n,r.withCredentials="include"==e.credentials,e.headers)r.setRequestHeader(d,e.headers[d]);r.send(e.body||null)}))}}));const v=window.fetch||(window.fetch=p.default||p);function a(e,i){var n;return t(this,void 0,void 0,(function*(){const t=e.headers.get("content-type");return"stream"===i.responseType?null===(n=e.body)||void 0===n?void 0:n.getReader():"json"===i.responseType||t&&t.indexOf("application/json")>-1?yield e.json():yield e.text()}))}function f(t,e){return new Promise((function(i,n){v(t,e).then((t=>{const r=t.clone();t.ok?a(r,e).then(i).catch(n):400===t.status?a(r,e).then((t=>{if("xhr_request"===t.error&&t.location)return window.location.replace(t.location),!1;n(t)})).catch(n):a(r,e).then(n).catch(n)})).catch(n)}))}class l{constructor(t,e={}){if(!t)throw new Error("'apiURL' must be provided");try{new URL(t)}catch(t){throw new Error("'apiUrl' must be a valid uri")}if("object"!=typeof e)throw new Error("'options' must be an object");if(e.httpClient&&"function"!=typeof e.httpClient)throw new Error('"httpClient" must be function');const i=t+(/\/api\/v\d(\/)?$/.test(t)?"":(t.endsWith("/")?"":"/")+"api/v1")+this.constructor.prefix,n=e.httpClient||f,r={};["get","post","patch","delete"].forEach((t=>{r[t]=function(...r){let o;o=e&&"function"==typeof e.token?e.token.call(void 0):e.token;let s={method:t.toUpperCase(),mode:"cors",headers:Object.assign({Accept:"application/json","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},o?{Authorization:`Bearer ${o}`}:{})};return r.length>1&&"get"!==t&&(s.body="object"==typeof r[1]?JSON.stringify(r[1]):r[1]),r[2]&&"object"==typeof r[2]&&(s=d(s,r[2])),n.call(null,i+r[0],s)}})),this._baseUrl=i,this.http=r}}function g(t,e=!0){if(!t)return"";const i=[];for(const e in t)null!=t[e]&&i.push(`${encodeURIComponent(e)}=${t[e].toString()}`);return e?`?${i.join("&")}`:i.join("&")}l.prefix="";class $ extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/permissions${g(i)}`)}))}createPermission(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/permissions`,i)}))}removePermission(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/permissions/${i}`)}))}getAuthorizedClients(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/authorized_clients${g(i)}`)}))}authorizeClients(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/authorized_clients`,i)}))}unAuthorizeClients(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/authorized_clients`,i)}))}getAssignedPermissionsToClient(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/authorized_clients/${i}/permissions`)}))}assignPermissionsToClient(e,i,n){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/authorized_clients/${i}/permissions`,n)}))}unassignPermissionsFromClient(e,i,n){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/authorized_clients/${i}/permissions`,n)}))}}$.prefix="/apis";class m extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}}m.prefix="/clients";class y extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}validate(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/validate`)}))}}y.prefix="/custom-domain";class b extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}}b.prefix="/federated";class w extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(`${g(e)}`)}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(""+(e?`/${e}`:""),i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}addPackages(e,i,n=!1){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/packages`,i,{responseType:n?"stream":void 0})}))}deletePackages(e,i,n=!1){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/packages`,i,{responseType:n?"stream":void 0})}))}execute(t,e,i){return this.http.post("/hook-test",{context:t,user:e,hook:i})}}w.prefix="/hooks";class x extends l{getAll(e,i){return t(this,void 0,void 0,(function*(){return i&&"object"==typeof i&&(i=JSON.stringify(i)),this.http.get(g(Object.assign(Object.assign({},e),{query:i})))}))}}x.prefix="/logs";class j extends l{getAll(){return t(this,void 0,void 0,(function*(){return this.http.get("")}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}}j.prefix="/mfa";class A extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/roles${g(i)}`)}))}assignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/roles`,i)}))}unAssignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/roles/${i}`)}))}}A.prefix="/roleGroups";class P extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/permissions${g(i)}`)}))}assignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/permissions`,i)}))}unAssignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/permissions/${i}`)}))}}P.prefix="/roles";class O extends l{get(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/${i}`)}))}update(e,i,n){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/${i}`,n)}))}}O.prefix="/templates";class S extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(`${g(e)}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e,{headers:{"X-PlusAuth-Tenant":"api"}})}))}delete(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}getSettings(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/settings`)}))}updateSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/settings`,i)}))}inviteAdmin(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/invite`,{email:i})}))}getAdministrators(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/administrators`)}))}removeAdministrator(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/administrators/${i}`)}))}getStats(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/stats${g(i)}`)}))}getSMSProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/provider/sms${i?`/${i}`:""}`)}))}updateSMSProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/provider/sms`,i)}))}getEmailProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/provider/email${i?`/${i}`:""}`)}))}updateEmailProviderSettings(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}/provider/sms`,i)}))}}S.prefix="/tenants";class R extends l{getAll(e){return t(this,void 0,void 0,(function*(){return this.http.get(g(e))}))}get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}getSessions(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/session`)}))}endSession(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/session/${i}`)}))}create(e){return t(this,void 0,void 0,(function*(){return this.http.post("",e)}))}remove(e){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}`)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i)}))}getTenants(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/tenants`)}))}getRoleGroups(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/roleGroups`)}))}assignRoleGroups(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/roleGroups`,i)}))}unAssignRoleGroups(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/roleGroups`,i)}))}getRoles(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/roles`)}))}assignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/roles`,i)}))}unAssignRoles(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/roles`,i)}))}getPermissions(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}/permissions`)}))}assignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.post(`/${e}/permissions`,i)}))}unAssignPermissions(e,i){return t(this,void 0,void 0,(function*(){return this.http.delete(`/${e}/permissions`,i)}))}}R.prefix="/users";class C extends l{get(e){return t(this,void 0,void 0,(function*(){return this.http.get(`/${e}`)}))}update(e,i){return t(this,void 0,void 0,(function*(){return this.http.patch(`/${e}`,i,{headers:{"Content-Type":"text/plain"}})}))}}C.prefix="/views";return class{constructor(t,e={}){this.options=e,this.apis=new $(t,this.options),this.clients=new m(t,this.options),this.customDomains=new y(t,this.options),this.federated=new b(t,this.options),this.hooks=new w(t,this.options),this.logs=new x(t,this.options),this.mfa=new j(t,this.options),this.roleGroups=new A(t,this.options),this.roles=new P(t,this.options),this.templates=new O(t,this.options),this.tenants=new S(t,this.options),this.users=new R(t,this.options),this.views=new C(t,this.options)}}}(); | ||
//# sourceMappingURL=plusauth-rest-js.min.js.map |
{ | ||
"name": "@plusauth/plusauth-rest-js", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "PlusAuth JavaScript Rest Client", | ||
@@ -5,0 +5,0 @@ "main": "dist/plusauth-rest-js.cjs.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
309779
8398