Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@seniorsistemas/senior-platform-data

Package Overview
Dependencies
Maintainers
2
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@seniorsistemas/senior-platform-data - npm Package Compare versions

Comparing version 5.2.0-dc573ff4-a3bd-4750-a9a3-9133566ad892 to 5.2.0-dd7d2f7b-59e5-4267-9c08-8140dd8c9154

8

CHANGELOG.md

@@ -8,6 +8,6 @@ # {version}

### Novas funcionalidades
* [ARQPTF-6633](https://jira.senior.com.br/browse/ARQPTF-6633) - Criação das funções para salvar (setPreference) e buscar (getPreference) uma preferencia do usuário no indexedDB.
* N/A.
### Melhorias
* N/A.
* [ARQENG-317](http://jira.senior.com.br/browse/ARQENG-317) - Adicionado parâmetro no método getToken para não aguardar o token quando não existir no cookie.

@@ -45,3 +45,3 @@ ### Correções

### Quebras de compatibilidade
* [SRE-9011](http://jira.senior.com.br/browse/SRE-9011) - Adicionado o parâmetro opcional `useCache` na função `getUserData`. O valor padrão será `true`.
* [SRE-9011](http://jira.senior.com.br/browse/SRE-9011) - Adicionado o parâmetro opcional `useCache` na função `getUserData`. O valor padrão será `true`.

@@ -72,3 +72,3 @@ **NOTA**: O comportamento padrão será de utilizar o cache da resposta do `getUser` que terá o tempo de vida padrão de `1800000 milissegundos (30 minutos)`. Caso exista o item `SENIOR_USER_INFO_TTL` no localStorage, o ttl será pego de lá. Para não utilizar o cache, basta informar o parâmetro useCache com o valor `false`. É importante ressaltar que essas informações poderão estar desatualizadas em caso de alguma atualização do usuário ser feita no sistema, sendo necessário relogar.

* Alterado a chamada da api de `obterMeusDados` para `getUser`, no qual será necessário alterar a chamada das propriedades do objeto retornado pela função `getUserData`:
```

@@ -75,0 +75,0 @@ Retorno:

@@ -6,4 +6,4 @@ // Type definitions for @seniorsistemas/senior-platform-data

export namespace user {
export function getAuthHeader(): Promise<string>;
export function getToken(): Promise<any>;
export function getAuthHeader(skipWaitToken?: boolean): Promise<string>;
export function getToken(skipWaitToken?: boolean): Promise<any>;
export function getUserData(useCache?: boolean): Promise<any>;

@@ -26,6 +26,1 @@ export function getRememberMe(): Promise<any>;

}
export namespace preference {
export function setPreference(preference: any): Promise<any>;
export function getPreference(onpreferenceIDj: any): Promise<any>;
}

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("@seniorsistemas/senior-platform-data",[],t):"object"==typeof exports?exports["@seniorsistemas/senior-platform-data"]=t():e["@seniorsistemas/senior-platform-data"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(){return s.hasTabData()?s.getToken():l.getServicesUrl().then(function(e){return e?l.getToken():a.getToken()})}function i(){return s.hasTabData()?s.getRestUrl():l.getServicesUrl().then(function(e){return e?e+"rest/":a.getRestUrl()})}Object.defineProperty(t,"__esModule",{value:!0}),t.preference=t.utils=t.service=t.user=void 0;var u=r(2),a=n(u),c=r(3),s=n(c),f=r(4),l=n(f),d=r(6),v=n(d),g=r(9),m=new s.NewTabProvider,p=new a.IFrameProvider,b=new l.CookiesProvider,y=new v.IndexedDBProvider;t.user={getToken:o,getAuthHeader:function(){return(0,g.getAuthHeader)(o)},getUserData:function(e){return(0,g.getUserData)(i,o,e)},getRememberMe:l.getRememberMe},t.service={getRestUrl:i,getXServicesUrl:function(){if(s.hasTabData())return m.getXServicesUrl();var e=b.getXServicesUrl();return e||p.getXServicesUrl()},getSoapUrl:l.getSoapUrl,getODataUrl:l.getODataUrl},t.utils={getDomain:l.getDomain,getSelectedSub:l.getSelectedSub,getSelectedCompany:l.getSelectedCompany},t.preference={setPreference:y.setPreference,getPreference:y.getPreference}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return c||(console.warn("Senior Platform data not found. Waiting for message event..."),c=new Promise(function(e,t){setTimeout(function(){t(new Error("It was not possible to retrieve the Senior Platform data. Try to get a token on initialization."))},5e3),window.addEventListener("message",function(t){t.data&&t.data.token&&t.data.token.username&&t.data.token.token_type&&e(t.data)})})),c}function i(){return o().then(function(e){return e.servicesUrl})}function u(){return o().then(function(e){return e.token})}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.getRestUrl=i,t.getToken=u;var c=void 0;t.IFrameProvider=function(){function e(){n(this,e)}return a(e,[{key:"getXServicesUrl",value:function(){return o().then(function(e){return e.xServicesUrl})}}]),e}()},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return window&&window.name&&0===window.name.indexOf(c)}function i(){return Promise.resolve(s.servicesUrl)}function u(){return Promise.resolve(s.token)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.hasTabData=o,t.getRestUrl=i,t.getToken=u;var c=t.PREFIX="SENIOR_CREDENTIALS",s=o()?JSON.parse(window.name.substring(c.length)):{};t.NewTabProvider=function(){function e(){n(this,e)}return a(e,[{key:"getXServicesUrl",value:function(){return Promise.resolve(s.xServicesUrl)}}]),e}()},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return Promise.resolve(m.default.get("com.senior.services.url"))}function i(){return o().then(function(e){return e?e+"rest/":m.default.get("com.senior.pau.services.url")})}function u(){return o().then(function(e){return e?e+"soap/":m.default.get("com.senior.pau.soap.url")})}function a(){return o().then(function(e){return e?e+"odata/":m.default.get("com.senior.pau.odata.url")})}function c(){var e=JSON.parse(m.default.get("com.senior.token")||"{}");return Object.keys(e).length||(e=JSON.parse(JSON.parse(m.default.get("com.senior.pau.token")||'"{}"'))),Promise.resolve(e)}function s(){return Promise.resolve(m.default.get("com.senior.rememberme")||m.default.get("com.senior.pau.rememberme"))}function f(){return Promise.resolve(m.default.get("com.senior.domain")||m.default.get("com.senior.pau.domain"))}function l(){return Promise.resolve(m.default.get("com.senior.selectedSub")||m.default.get("com.senior.pau.selectedSub"))}function d(){return Promise.resolve(m.default.get("com.senior.selectedCompany")||m.default.get("com.senior.pau.selectedCompany"))}Object.defineProperty(t,"__esModule",{value:!0}),t.CookiesProvider=void 0;var v=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.getServicesUrl=o,t.getRestUrl=i,t.getSoapUrl=u,t.getODataUrl=a,t.getToken=c,t.getRememberMe=s,t.getDomain=f,t.getSelectedSub=l,t.getSelectedCompany=d;var g=r(5),m=function(e){return e&&e.__esModule?e:{default:e}}(g);t.CookiesProvider=function(){function e(){n(this,e)}return v(e,[{key:"getXServicesUrl",value:function(){return Promise.resolve(m.default.get("com.senior.x.services.url"))}}]),e}()},function(e,t){e.exports=require("js-cookie")},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return new Promise(function(e,t){var r=indexedDB.open(c,1);r.onupgradeneeded=function(){var t=r.result,n={keyPath:"id"};t.objectStoreNames.contains(s)||t.createObjectStore(s,n),e(t)},r.onerror=function(){t(new Error(r.error))},r.onsuccess=function(){e(r.result)}})}Object.defineProperty(t,"__esModule",{value:!0}),t.IndexedDBProvider=void 0;var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();r(7);var u=r(8),a=void 0,c="platformDB",s="userPreference",f=function(e,t){return u.AES.encrypt(t,e.toString())},l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"readonly";return a.transaction(e,t)};t.IndexedDBProvider=function(){function e(){n(this,e),this.createDB()}return i(e,[{key:"createDB",value:function(){o().then(function(e){a=e}).catch(function(e){console.error(e)})}},{key:"setPreference",value:function(e){var t=f(e.id,e.name);return new Promise(function(r,n){var o={id:e.id,name:t},i=l(s,"readwrite"),u=i.objectStore(s),a=u.put(o);a.onsuccess=function(){r(a.result)},a.onerror=function(){n(new Error(a.error))}})}},{key:"getPreference",value:function(e){return new Promise(function(t,r){var n=l(s),o=n.objectStore(s),i=o.get(e);i.onsuccess=function(){t(i.result)},i.onerror=function(){r(new Error(i.error))}})}}]),e}()},function(e,t){e.exports=require("regenerator-runtime/runtime")},function(e,t){e.exports=require("crypto-js")},function(e,t,r){"use strict";function n(e){return e().then(function(e){return e&&Object.keys(e).length?e.token_type+" "+e.access_token:""})}function o(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=localStorage.getItem(s)||f;return Promise.all([e(),t()]).then(function(e){var t=i(e,2),o=t[0],u=t[1],s=null,f=localStorage.getItem(c);if(r&&f){var l=JSON.parse(f);if(l.data.username+"@"+l.data.tenantDomain===u.username&&l.ttl>Date.now())return new Promise(function(e){return e(l.data)});l.ttl<Date.now()&&(s=l.ETag)}return a.default.post(o+"platform/user/queries/getUser",{includePhoto:!0},{headers:{Authorization:u.token_type+" "+u.access_token,Accept:"application/json;seniorx.version=8","If-None-Match":s}}).then(function(e){var t=Date.now()+Number(n),r={data:e.data,ttl:t,ETag:e.headers.ETag};return 304===e.status&&(r.data=JSON.parse(f).data),localStorage.setItem(c,JSON.stringify(r)),r.data})})}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.getAuthHeader=n,t.getUserData=o;var u=r(10),a=function(e){return e&&e.__esModule?e:{default:e}}(u),c="SENIOR_USER_INFO",s="SENIOR_USER_INFO_TTL",f="1800000"},function(e,t){e.exports=require("axios")}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("@seniorsistemas/senior-platform-data",[],t):"object"==typeof exports?exports["@seniorsistemas/senior-platform-data"]=t():e["@seniorsistemas/senior-platform-data"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(){return s.hasTabData()?s.getRestUrl():l.getServicesUrl().then(function(e){return e?e+"rest/":i.getRestUrl()})}Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.service=t.user=void 0;var a=r(2),i=n(a),u=r(3),s=n(u),c=r(4),l=n(c),f=r(6),d=new s.NewTabProvider,g=new i.IFrameProvider,m=new l.CookiesProvider,v=function(e){return s.hasTabData()?s.getToken():l.getServicesUrl().then(function(t){return t?l.getToken():e?Promise.reject():i.getToken()})};t.user={getToken:function(e){return v(e)},getAuthHeader:function(e){return(0,f.getAuthHeader)(v(e))},getUserData:function(e){return(0,f.getUserData)(o,v,e)},getRememberMe:l.getRememberMe},t.service={getRestUrl:o,getXServicesUrl:function(){if(s.hasTabData())return d.getXServicesUrl();var e=m.getXServicesUrl();return e||g.getXServicesUrl()},getSoapUrl:l.getSoapUrl,getODataUrl:l.getODataUrl},t.utils={getDomain:l.getDomain,getSelectedSub:l.getSelectedSub,getSelectedCompany:l.getSelectedCompany}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return s||(console.warn("Senior Platform data not found. Waiting for message event..."),s=new Promise(function(e,t){setTimeout(function(){t(new Error("It was not possible to retrieve the Senior Platform data. Try to get a token on initialization."))},c),window.addEventListener("message",function(t){t.data&&t.data.token&&t.data.token.username&&t.data.token.token_type&&e(t.data)})})),s}function a(){return o().then(function(e){return e.servicesUrl})}function i(){return o().then(function(e){return e.token})}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.getRestUrl=a,t.getToken=i;var s=void 0,c=5e3;t.IFrameProvider=function(){function e(){n(this,e)}return u(e,[{key:"getXServicesUrl",value:function(){return o().then(function(e){return e.xServicesUrl})}}]),e}()},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return window&&window.name&&0===window.name.indexOf(s)}function a(){return Promise.resolve(c.servicesUrl)}function i(){return Promise.resolve(c.token)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.hasTabData=o,t.getRestUrl=a,t.getToken=i;var s=t.PREFIX="SENIOR_CREDENTIALS",c=o()?JSON.parse(window.name.substring(s.length)):{};t.NewTabProvider=function(){function e(){n(this,e)}return u(e,[{key:"getXServicesUrl",value:function(){return Promise.resolve(c.xServicesUrl)}}]),e}()},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){return Promise.resolve(v.default.get("com.senior.services.url"))}function a(){return o().then(function(e){return e?e+"rest/":v.default.get("com.senior.pau.services.url")})}function i(){return o().then(function(e){return e?e+"soap/":v.default.get("com.senior.pau.soap.url")})}function u(){return o().then(function(e){return e?e+"odata/":v.default.get("com.senior.pau.odata.url")})}function s(){var e=JSON.parse(v.default.get("com.senior.token")||"{}");return Object.keys(e).length||(e=JSON.parse(JSON.parse(v.default.get("com.senior.pau.token")||'"{}"'))),Promise.resolve(e)}function c(){return Promise.resolve(v.default.get("com.senior.rememberme")||v.default.get("com.senior.pau.rememberme"))}function l(){return Promise.resolve(v.default.get("com.senior.domain")||v.default.get("com.senior.pau.domain"))}function f(){return Promise.resolve(v.default.get("com.senior.selectedSub")||v.default.get("com.senior.pau.selectedSub"))}function d(){return Promise.resolve(v.default.get("com.senior.selectedCompany")||v.default.get("com.senior.pau.selectedCompany"))}Object.defineProperty(t,"__esModule",{value:!0}),t.CookiesProvider=void 0;var g=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.getServicesUrl=o,t.getRestUrl=a,t.getSoapUrl=i,t.getODataUrl=u,t.getToken=s,t.getRememberMe=c,t.getDomain=l,t.getSelectedSub=f,t.getSelectedCompany=d;var m=r(5),v=function(e){return e&&e.__esModule?e:{default:e}}(m);t.CookiesProvider=function(){function e(){n(this,e)}return g(e,[{key:"getXServicesUrl",value:function(){return Promise.resolve(v.default.get("com.senior.x.services.url"))}}]),e}()},function(e,t){e.exports=require("js-cookie")},function(e,t,r){"use strict";function n(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=localStorage.getItem(s)||c;return Promise.all([e(),t()]).then(function(e){var t=o(e,2),a=t[0],s=t[1],c=null,l=localStorage.getItem(u);if(r&&l){var f=JSON.parse(l);if(f.data.username+"@"+f.data.tenantDomain===s.username&&f.ttl>Date.now())return new Promise(function(e){return e(f.data)});f.ttl<Date.now()&&(c=f.ETag)}return i.default.post(a+"platform/user/queries/getUser",{includePhoto:!0},{headers:{Authorization:s.token_type+" "+s.access_token,Accept:"application/json;seniorx.version=8","If-None-Match":c}}).then(function(e){var t=Date.now()+Number(n),r={data:e.data,ttl:t,ETag:e.headers.ETag};return 304===e.status&&(r.data=JSON.parse(l).data),localStorage.setItem(u,JSON.stringify(r)),r.data})})}Object.defineProperty(t,"__esModule",{value:!0}),t.getAuthHeader=void 0;var o=function(){function e(e,t){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{!n&&u.return&&u.return()}finally{if(o)throw a}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.getUserData=n;var a=r(7),i=function(e){return e&&e.__esModule?e:{default:e}}(a),u="SENIOR_USER_INFO",s="SENIOR_USER_INFO_TTL",c="1800000";t.getAuthHeader=function(e){return e.then(function(e){return e&&Object.keys(e).length?e.token_type+" "+e.access_token:""})}},function(e,t){e.exports=require("axios")}])});
{
"name": "@seniorsistemas/senior-platform-data",
"version": "5.2.0-dc573ff4-a3bd-4750-a9a3-9133566ad892",
"version": "5.2.0-dd7d2f7b-59e5-4267-9c08-8140dd8c9154",
"description": "API para retornar valores dos usuários, atualmente retorna via cookies",

@@ -47,6 +47,4 @@ "project": {

"axios": "~0.17.1",
"crypto-js": "^4.2.0",
"js-cookie": "~2.2.0",
"regenerator-runtime": "^0.14.0"
"js-cookie": "~2.2.0"
}
}

@@ -40,6 +40,2 @@ # senior-platform-data

* `preference`
* `setPreference()` - Insere uma preferência do usuário no IndexedDB
* `getPrefence()` - Retorna uma preferência do usuário
### **Integração para passagem credenciais na abertura de nova aba ou iframe**

@@ -51,3 +47,3 @@

### FAQ
Estou recebendo erro no console com a seguinte mensagem:
Estou recebendo erro no console com a seguinte mensagem:
"It was not possible to retrieve the Senior Platform data. Try to get a token on initialization.". O que devo fazer para funcionar?

@@ -59,3 +55,3 @@ Abaixo um exemplo para inicializar o token:

import { Observable, of } from 'rxjs';
@Injectable()

@@ -65,3 +61,3 @@ export class AppService {

constructor() {
//Inicializa o token da propriedade corrente.
//Inicializa o token da propriedade corrente.
user.getToken().then(data => this.token = data.token);

@@ -77,2 +73,2 @@ }

}
```
```
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