New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@netology-group/account

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netology-group/account - npm Package Compare versions

Comparing version 2.0.4 to 2.1.0-rc.1

2

dist/account.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Account=t():e.Account=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=n(3);n.d(t,"IdP",function(){return o.a}),n.d(t,"Account",function(){return r.a}),t.default=r.a},function(e,t,n){"use strict";function r(e){return c(e)||i(e)||o()}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function i(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function c(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){h(e,t,n[t])})}return e}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",function(){return y});var l=n(2),d=3,p=1e3,v=3e3,y=function(){function e(t,n){if(u(this,e),h(this,"fetchFn",void 0),h(this,"fetchOpts",void 0),h(this,"id",void 0),h(this,"label",void 0),h(this,"leeway",void 0),h(this,"requestMode",void 0),h(this,"provider",void 0),h(this,"retries",void 0),h(this,"retryDelay",void 0),h(this,"storage",void 0),!t||!t.provider)throw new TypeError("Missing `provider` in config");if(!n)throw new TypeError("Storage is not defined");this.storage=n,this.provider=t.provider,this.fetchFn=l.a,this.fetchOpts={delay:t.retryDelay||p,retries:t.retries||d},this.leeway=t.leeway||v,this.requestMode=t.requestMode||"id";var r=this._createId(t.audience,t.label),o=r.id,i=r.label;if(this.label=i,this.id=o,!this.id)throw new TypeError("Failed to configure account. Id is not present")}return f(e,[{key:"_createId",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"me",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!e)throw new TypeError("`audience` is absent");return{label:t,id:"".concat(t).concat(n).concat(e)}}},{key:"_requestLabel",value:function(){return"label"===this.requestMode?this.label:this.id}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id;return n?Promise.resolve(function(){return e.storage.getItem(n)}).then(function(e){var t=e();if(!t)throw new TypeError("Can not load data");return Object(l.c)(t)}):Promise.reject(new TypeError("`label` is absent"))}},{key:"remove",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id;return n?this.load(n).then(function(t){return e.storage.removeItem(n),t}):Promise.reject(new TypeError("`label` is absent"))}},{key:"store",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=n||this.id;return r?Promise.resolve(e).then(function(e){var t=0;if(e.expires_in){var n=Number(e.expires_in);if(isNaN(n))throw new TypeError("Wrong `expires_in` value");t=Date.now()+1e3*(n||0)}return a({},e,{expires_time:t})}).then(function(e){return t.storage.setItem(r,JSON.stringify(e)),e}):Promise.reject(new TypeError("`label` is absent"))}},{key:"account",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id,o=this.provider.account;return this.tokenData(n).then(function(t){var n=t.access_token;return[e._requestLabel(),n]}).then(function(t){return e.fetchFn(function(){return o.call.apply(o,[e.provider].concat(r(t)))},e.fetchOpts)}).then(l.e).then(l.d)}},{key:"tokenData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id,o=this.provider.refreshAccessToken;return this.load(n).then(function(t){if(!Object(l.b)(t,e.leeway))return t;var i=t.refresh_token;return Promise.resolve([e._requestLabel(),i]).then(function(t){return e.fetchFn(function(){return o.call.apply(o,[e.provider].concat(r(t)))},e.fetchOpts)}).then(l.e).then(l.d).then(function(t){return e.load(n).then(function(n){return e.store(a({},n,{access_token:t.access_token,expires_in:t.expires_in}))})})})}},{key:"revokeRefreshToken",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id,o=this.provider.revokeRefreshToken;return this.load(n).then(function(t){var n=t.refresh_token;return[e._requestLabel(),n]}).then(function(t){return e.fetchFn(function(){return o.call.apply(o,[e.provider].concat(r(t)))},e.fetchOpts)}).then(l.e).then(l.d).then(function(t){return e.load(n).then(function(n){return e.store(a({},n,{refresh_token:t.refresh_token}))})})}}]),e}()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"b",function(){return o}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return a});var r=function(e,t){if(!e)throw new TypeError("Missing 'requestFn': ".concat(e));return new Promise(function(n,r){var o=[];!function i(c){c<1?r(o):fetch(e()).then(function(e){return n(e)}).catch(function(e){o.push(e),setTimeout(function(){i(c-1)},t.delay||1e3)})}(t.retries||3)})},o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;return function(e){return!e||!e.expires_time||Date.now()>Number(e.expires_time)-t}(e)},i=function(e){if(e.status&&e.status>=200&&e.status<300)return e;throw new Error(e.statusText||"Invalid request. Status: ".concat(e.status))},c=function(e){if(!e)throw new TypeError("`response` is absent");try{return e.json()}catch(e){throw new Error("Response is not a JSON")}},a=function(e){var t="function"==typeof e?e():e;if("string"!=typeof t)throw new TypeError("Can not parse");return new Promise(function(e,n){try{e(JSON.parse(t))}catch(e){n(e)}})}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",function(){return a});var a=function(){function e(t){var n=this;if(r(this,e),c(this,"endpoint",void 0),c(this,"accountEndpoint",void 0),c(this,"authnEndpoint",void 0),!t)throw new TypeError("Missing provider configuration");this.endpoint=t.endpoint,this.accountEndpoint=function(e){if(!n.endpoint&&!e.accountEndpoint)throw new TypeError("Can not resolve account endpoint");return e.accountEndpoint&&"function"==typeof e.accountEndpoint?e.accountEndpoint():e.accountEndpoint||"".concat(n.endpoint,"/accounts")}(t),this.authnEndpoint=function(e){if(!n.endpoint&&!e.authnEndpoint)throw new TypeError("Can not resolve authentication endpoint");return e.authnEndpoint&&"function"==typeof e.authnEndpoint?e.authnEndpoint():e.authnEndpoint||"".concat(n.endpoint,"/auth")}(t)}return i(e,[{key:"refreshAccessToken",value:function(e,t){if(!e)throw new TypeError("Incorrect parameter `label`");if(!t)throw new TypeError("Incorrect parameter 'refreshToken': ".concat(t));var n="".concat(this.accountEndpoint,"/").concat(e,"/refresh");return new Request(n,{method:"POST",headers:{Authorization:"Bearer ".concat(t)}})}},{key:"revokeRefreshToken",value:function(e,t){if(!e)throw new TypeError("Incorrect parameter `label`");if(!t)throw new TypeError("Incorrect parameter 'refreshToken': ".concat(t));var n="".concat(this.accountEndpoint,"/").concat(e,"/revoke");return new Request(n,{method:"POST",headers:{Authorization:"Bearer ".concat(t)}})}},{key:"account",value:function(e,t){if(!e)throw new TypeError("Incorrect parameter `label`");if(!t)throw new TypeError("Incorrect parameter 'accessToken': ".concat(t));var n="".concat(this.authnEndpoint,"/").concat(e);return new Request(n,{method:"GET",headers:{Authorization:"Bearer ".concat(t)}})}}]),e}()}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Account=t():e.Account=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=n(3);n.d(t,"IdP",function(){return o.a}),n.d(t,"Account",function(){return r.a}),t.default=r.a},function(e,t,n){"use strict";function r(e){return c(e)||i(e)||o()}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function i(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function c(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){h(e,t,n[t])})}return e}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",function(){return y});var l=n(2),d=3,p=1e3,v=3e3,y=function(){function e(t,n,r){if(u(this,e),h(this,"fetchFn",void 0),h(this,"fetchOpts",void 0),h(this,"id",void 0),h(this,"label",void 0),h(this,"leeway",void 0),h(this,"requestMode",void 0),h(this,"provider",void 0),h(this,"retries",void 0),h(this,"retryDelay",void 0),h(this,"storage",void 0),!t)throw new TypeError("Missing `config`");if(!n)throw new TypeError("Provider is not defined");if(!r)throw new TypeError("Storage is not defined");this.storage=r,this.provider=n,this.fetchFn=l.a,this.fetchOpts={delay:t.retryDelay||p,retries:t.retries||d},this.leeway=t.leeway||v,this.requestMode=t.requestMode||"id";var o=this._createId(t.audience,t.label),i=o.id,c=o.label;if(this.label=c,this.id=i,!this.id)throw new TypeError("Failed to configure account. Id is not present")}return f(e,[{key:"_createId",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"me",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!e)throw new TypeError("`audience` is absent");return{label:t,id:"".concat(t).concat(n).concat(e)}}},{key:"_requestLabel",value:function(){return"label"===this.requestMode?this.label:this.id}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id;return n?Promise.resolve(function(){return e.storage.getItem(n)}).then(function(e){var t=e();if(!t)throw new TypeError("Can not load data");return Object(l.c)(t)}):Promise.reject(new TypeError("`label` is absent"))}},{key:"remove",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id;return n?this.load(n).then(function(t){return e.storage.removeItem(n),t}):Promise.reject(new TypeError("`label` is absent"))}},{key:"store",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=n||this.id;return r?Promise.resolve(e).then(function(e){var t=0;if(e.expires_in){var n=Number(e.expires_in);if(isNaN(n))throw new TypeError("Wrong `expires_in` value");t=Date.now()+1e3*(n||0)}return a({},e,{expires_time:t})}).then(function(e){return t.storage.setItem(r,JSON.stringify(e)),e}):Promise.reject(new TypeError("`label` is absent"))}},{key:"account",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id,o=this.provider.account;return this.tokenData(n).then(function(t){var n=t.access_token;return[e._requestLabel(),n]}).then(function(t){return e.fetchFn(function(){return o.call.apply(o,[e.provider].concat(r(t)))},e.fetchOpts)}).then(l.e).then(l.d)}},{key:"tokenData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id,o=this.provider.refreshAccessToken;return this.load(n).then(function(t){if(!Object(l.b)(t,e.leeway))return t;var i=t.refresh_token;return Promise.resolve([e._requestLabel(),i]).then(function(t){return e.fetchFn(function(){return o.call.apply(o,[e.provider].concat(r(t)))},e.fetchOpts)}).then(l.e).then(l.d).then(function(t){return e.load(n).then(function(n){return e.store(a({},n,{access_token:t.access_token,expires_in:t.expires_in}))})})})}},{key:"revokeRefreshToken",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t||this.id,o=this.provider.revokeRefreshToken;return this.load(n).then(function(t){var n=t.refresh_token;return[e._requestLabel(),n]}).then(function(t){return e.fetchFn(function(){return o.call.apply(o,[e.provider].concat(r(t)))},e.fetchOpts)}).then(l.e).then(l.d).then(function(t){return e.load(n).then(function(n){return e.store(a({},n,{refresh_token:t.refresh_token}))})})}}]),e}()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"b",function(){return o}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return a});var r=function(e,t){if(!e)throw new TypeError("Missing 'requestFn': ".concat(e));return new Promise(function(n,r){var o=[];!function i(c){c<1?r(o):fetch(e()).then(function(e){return n(e)}).catch(function(e){o.push(e),setTimeout(function(){i(c-1)},t.delay||1e3)})}(t.retries||3)})},o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;return function(e){return!e||!e.expires_time||Date.now()>Number(e.expires_time)-t}(e)},i=function(e){if(e.status&&e.status>=200&&e.status<300)return e;throw new Error(e.statusText||"Invalid request. Status: ".concat(e.status))},c=function(e){if(!e)throw new TypeError("`response` is absent");try{return e.json()}catch(e){throw new Error("Response is not a JSON")}},a=function(e){var t="function"==typeof e?e():e;if("string"!=typeof t)throw new TypeError("Can not parse");return new Promise(function(e,n){try{e(JSON.parse(t))}catch(e){n(e)}})}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",function(){return a});var a=function(){function e(t){var n=this;if(r(this,e),c(this,"endpoint",void 0),c(this,"accountEndpoint",void 0),c(this,"authnEndpoint",void 0),!t)throw new TypeError("Missing provider configuration");this.endpoint=t.endpoint,this.accountEndpoint=function(e){if(!n.endpoint&&!e.accountEndpoint)throw new TypeError("Can not resolve account endpoint");return e.accountEndpoint&&"function"==typeof e.accountEndpoint?e.accountEndpoint():e.accountEndpoint||"".concat(n.endpoint,"/accounts")}(t),this.authnEndpoint=function(e){if(!n.endpoint&&!e.authnEndpoint)throw new TypeError("Can not resolve authentication endpoint");return e.authnEndpoint&&"function"==typeof e.authnEndpoint?e.authnEndpoint():e.authnEndpoint||"".concat(n.endpoint,"/auth")}(t)}return i(e,[{key:"refreshAccessToken",value:function(e,t){if(!e)throw new TypeError("Incorrect parameter `label`");if(!t)throw new TypeError("Incorrect parameter 'refreshToken': ".concat(t));var n="".concat(this.accountEndpoint,"/").concat(e,"/refresh");return new Request(n,{method:"POST",headers:{Authorization:"Bearer ".concat(t)}})}},{key:"revokeRefreshToken",value:function(e,t){if(!e)throw new TypeError("Incorrect parameter `label`");if(!t)throw new TypeError("Incorrect parameter 'refreshToken': ".concat(t));var n="".concat(this.accountEndpoint,"/").concat(e,"/revoke");return new Request(n,{method:"POST",headers:{Authorization:"Bearer ".concat(t)}})}},{key:"account",value:function(e,t){if(!e)throw new TypeError("Incorrect parameter `label`");if(!t)throw new TypeError("Incorrect parameter 'accessToken': ".concat(t));var n="".concat(this.authnEndpoint,"/").concat(e);return new Request(n,{method:"GET",headers:{Authorization:"Bearer ".concat(t)}})}}]),e}()}])});
{
"name": "@netology-group/account",
"version": "2.0.4",
"version": "2.1.0-rc.1",
"description": "account client",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc