dauth-context-react 0.1.1 → 0.1.3

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.
@@ -2,7 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
5
7
  var React = require('react');
8
+ var React__default = _interopDefault(React);
6
9
 
7
10
  function _regeneratorRuntime() {
8
11
  _regeneratorRuntime = function () {
@@ -350,56 +353,9 @@ function _extends() {
350
353
  return _extends.apply(this, arguments);
351
354
  }
352
355
 
353
- // export interface IDauthUser {
354
- // _id: string
355
- // ssid: string
356
- // name: string
357
- // lastname: string
358
- // nickname: string
359
- // email: string
360
- // is_verified: boolean
361
- // language: string
362
- // avatar: string
363
- // createdAt: Date
364
- // updatedAt: Date
365
- // last_login: Date
366
- // }
367
- // export interface IDauthDomain {
368
- // name: string
369
- // loginRedirect: string
370
- // allowedOrigins: string[]
371
- // }
372
- // export interface IDauthState {
373
- // user: IDauthUser
374
- // domain: IDauthDomain
375
- // isLoading: boolean
376
- // isAuthenticated: boolean
377
- // loginWithRedirect: () => void
378
- // logout: () => void
379
- // getAccessToken: () => void
380
- // }
381
- var userState = {
382
- _id: "",
383
- ssid: "",
384
- name: "",
385
- lastname: "",
386
- nickname: "",
387
- email: "",
388
- is_verified: false,
389
- language: "",
390
- avatar: "",
391
- createdAt: /*#__PURE__*/new Date(),
392
- updatedAt: /*#__PURE__*/new Date(),
393
- last_login: /*#__PURE__*/new Date()
394
- };
395
- var domainState = {
396
- name: "",
397
- loginRedirect: "",
398
- allowedOrigins: [""]
399
- };
400
356
  var initialDauthState = {
401
- user: userState,
402
- domain: domainState,
357
+ user: {},
358
+ domain: {},
403
359
  isLoading: true,
404
360
  isAuthenticated: false,
405
361
  loginWithRedirect: function loginWithRedirect() {},
@@ -649,18 +605,15 @@ function _setLogoutAction() {
649
605
  return _setLogoutAction.apply(this, arguments);
650
606
  }
651
607
 
652
- // Delete me
653
- var Thing = function Thing() {
654
- return React.createElement("div", null, "the snozzberries taste like snozzberries");
655
- };
656
608
  var DauthProvider = function DauthProvider(props) {
657
609
  var domainName = props.domainName,
658
610
  sid = props.sid,
659
611
  ssid = props.ssid,
660
612
  children = props.children;
661
613
  var _useReducer = React.useReducer(userReducer, initialDauthState),
662
- dauthState = _useReducer[0],
614
+ ds = _useReducer[0],
663
615
  dispatch = _useReducer[1];
616
+ var dauthState = ds;
664
617
  // Catch login redirect
665
618
  React.useEffect(function () {
666
619
  var queryString = window.location.search;
@@ -704,12 +657,12 @@ var DauthProvider = function DauthProvider(props) {
704
657
  logout: logout
705
658
  });
706
659
  }, [dauthState, loginWithRedirect, logout]);
707
- return React.createElement(DauthContext.Provider, {
660
+ return React__default.createElement(DauthContext.Provider, {
708
661
  value: memoProvider
709
662
  }, children);
710
663
  };
711
664
  var DauthContext = /*#__PURE__*/React.createContext(initialDauthState);
712
- var useDauthContext = function useDauthContext() {
665
+ var useDauth = function useDauth() {
713
666
  var context = React.useContext(DauthContext);
714
667
  if (!context) {
715
668
  throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');
@@ -718,6 +671,5 @@ var useDauthContext = function useDauthContext() {
718
671
  };
719
672
 
720
673
  exports.DauthProvider = DauthProvider;
721
- exports.Thing = Thing;
722
- exports.useDauthContext = useDauthContext;
674
+ exports.useDauth = useDauth;
723
675
  //# sourceMappingURL=dauth-context-react.cjs.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dauth-context-react.cjs.development.js","sources":["../src/initialDauthState.ts","../src/reducer/dauth.types.ts","../src/reducer/dauth.reducer.ts","../src/api/utils/config.ts","../src/api/dauth.api.ts","../src/constants.ts","../src/reducer/dauth.actions.ts","../src/index.tsx"],"sourcesContent":["// export interface IDauthUser {\n// \t_id: string\n// \tssid: string\n// \tname: string\n// \tlastname: string\n// \tnickname: string\n// \temail: string\n// \tis_verified: boolean\n// \tlanguage: string\n// \tavatar: string\n// \tcreatedAt: Date\n// \tupdatedAt: Date\n// \tlast_login: Date\n// }\n\n// export interface IDauthDomain {\n// \tname: string\n// \tloginRedirect: string\n// \tallowedOrigins: string[]\n// }\n\n// export interface IDauthState {\n// \tuser: IDauthUser\n// \tdomain: IDauthDomain\n// \tisLoading: boolean\n// \tisAuthenticated: boolean\n// \tloginWithRedirect: () => void\n// \tlogout: () => void\n// \tgetAccessToken: () => void\n// }\n\nconst userState = {\n\t_id: \"\",\n\tssid: \"\",\n\tname: \"\",\n\tlastname: \"\",\n\tnickname: \"\",\n\temail: \"\",\n\tis_verified: false,\n\tlanguage: \"\",\n\tavatar: \"\",\n\tcreatedAt: new Date(),\n\tupdatedAt: new Date(),\n\tlast_login: new Date(),\n}\n\nconst domainState = {\n\tname: \"\",\n\tloginRedirect: \"\",\n\tallowedOrigins: [\"\"],\n}\n\nconst initialDauthState = {\n\tuser: userState,\n\tdomain: domainState,\n\tisLoading: true,\n\tisAuthenticated: false,\n\tloginWithRedirect: () => { },\n\tlogout: () => { },\n\tgetAccessToken: () => { },\n}\n\nexport default initialDauthState","export const LOGIN = 'LOGIN';\nexport const SET_IS_LOADING = 'SET_IS_LOADING';","import * as DauthTypes from './dauth.types'\n\nexport default function userReducer(state: any, action: any) {\n\tconst { type, payload } = action;\n\n\tswitch (type) {\n\t\tcase DauthTypes.LOGIN:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tuser: payload.user,\n\t\t\t\tdomain: payload.domain,\n\t\t\t\tisAuthenticated: payload.isAuthenticated,\n\t\t\t}\n\n\t\tcase DauthTypes.SET_IS_LOADING:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisLoading: payload.isLoading,\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn state\n\t}\n}","const isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"[::1]\" ||\n window.location.hostname.match(\n /(192)\\.(168)\\.(1)\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm\n ) ||\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\nexport const apiVersion = \"v1\";\nexport const serverDomain = \"dauth.ovh\";\n\nexport function getServerBasePath({ domainName }: { domainName: string }) {\n const serverPort = 4012;\n const serverLocalUrl = `${window.location.protocol}//${window.location.hostname}:${serverPort}/api/${apiVersion}`\n const serverProdUrl = `https://${domainName}.${serverDomain}/api/${apiVersion}`\n const serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;\n return serverBasePath;\n}\n\nexport function getClientBasePath({ domainName }: { domainName: string }) {\n const clientPort = 5185;\n const clientLocalUrl = `${window.location.protocol}//${window.location.hostname}:${clientPort}`\n const clientProdUrl = `https://${domainName}.${serverDomain}`\n const clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;\n return clientBasePath;\n}","import { getServerBasePath } from \"./utils/config\";\n\nexport const getTenantUserAPI = async (domainName: string, ssid: string, token: string): Promise<any> => {\n const params = {\n method: \"GET\",\n headers: {\n Authorization: `${token}`,\n \"Content-Type\": \"application/json\",\n }\n }\n const response = await fetch(`${getServerBasePath({ domainName })}/get-tenant-user/${ssid}`, params)\n const data = await response.json()\n return { response, data }\n}","export const DAUTH_STATE = 'dauth_state';","import { getTenantUserAPI } from '../api/dauth.api';\nimport { DAUTH_STATE } from '../constants';\nimport * as DauthTypes from './dauth.types'\n\nexport async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: { dispatch: any, dauth_state: string, domainName: string, ssid: string }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);\n return localStorage.setItem(DAUTH_STATE, dauth_state);\n } else {\n return localStorage.removeItem(DAUTH_STATE);\n }\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: { dispatch: any, dauth_state_ls: string, domainName: string, ssid: string }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n localStorage.setItem(DAUTH_STATE, dauth_state_ls);\n } else {\n localStorage.removeItem(DAUTH_STATE);\n }\n\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setLogoutAction({ dispatch }: { dispatch: any }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: {},\n domain: {},\n isAuthenticated: false,\n },\n })\n localStorage.removeItem(DAUTH_STATE);\n return dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n}","import * as React from 'react';\nimport { useReducer, useMemo, useEffect, useCallback } from 'react'\nimport initialDauthState from './initialDauthState'\nimport userReducer from './reducer/dauth.reducer'\nimport * as action from \"./reducer/dauth.actions\"\nimport { getClientBasePath } from './api/utils/config'\nimport { DAUTH_STATE } from './constants'\n\n// Delete me\nexport const Thing = () => {\n return <div>the snozzberries taste like snozzberries</div>;\n};\n\ninterface DauthProviderProps {\n domainName: string\n sid: string\n ssid: string\n children: React.ReactNode\n}\n\nexport const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {\n\tconst { domainName, sid, ssid, children } = props\n\tconst [dauthState, dispatch] = useReducer(userReducer, initialDauthState)\n\n\t// Catch login redirect\n\tuseEffect(() => {\n\t\tconst queryString = window.location.search;\n\t\tif (!queryString) return\n\t\tconst urlParams = new URLSearchParams(queryString);\n\t\tconst dauth_state = urlParams.get(DAUTH_STATE);\n\t\tif (dauth_state && !dauthState.isAuthenticated) {\n\t\t\taction.setDauthStateAction({ dispatch, dauth_state, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\t// Auto Login\n\tuseEffect(() => {\n\t\tconst dauth_state_ls = localStorage.getItem(DAUTH_STATE);\n\t\tif (dauth_state_ls && !dauthState.isAuthenticated) {\n\t\t\taction.setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\tconst loginWithRedirect = useCallback(() => {\n\t\treturn window.location.replace(`${getClientBasePath({ domainName })}/t-sign/${sid}`);\n\t}, [domainName, sid])\n\n\tconst logout = useCallback(() => {\n\t\treturn action.setLogoutAction({ dispatch })\n\t}, [])\n\n\tconst memoProvider = useMemo(\n\t\t() => ({\n\t\t\t...dauthState,\n\t\t\tloginWithRedirect,\n\t\t\tlogout\n\t\t}), [\n\t\tdauthState,\n\t\tloginWithRedirect,\n\t\tlogout\n\t])\n\n\n\treturn (\n\t\t<DauthContext.Provider value={memoProvider}>\n\t\t\t{children}\n\t\t</DauthContext.Provider>\n\t)\n}\n\nconst DauthContext = React.createContext(initialDauthState);\n\nexport const useDauthContext = () => {\n const context = React.useContext(DauthContext);\n if (!context) {\n throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');\n }\n return context;\n};"],"names":["userState","_id","ssid","name","lastname","nickname","email","is_verified","language","avatar","createdAt","Date","updatedAt","last_login","domainState","loginRedirect","allowedOrigins","initialDauthState","user","domain","isLoading","isAuthenticated","loginWithRedirect","logout","getAccessToken","LOGIN","SET_IS_LOADING","userReducer","state","action","type","payload","DauthTypes","_extends","isLocalhost","Boolean","window","location","hostname","match","apiVersion","serverDomain","getServerBasePath","_ref","domainName","serverPort","serverLocalUrl","protocol","serverProdUrl","serverBasePath","getClientBasePath","_ref2","clientPort","clientLocalUrl","clientProdUrl","clientBasePath","getTenantUserAPI","_asyncToGenerator","_regeneratorRuntime","mark","_callee","token","params","response","data","wrap","_callee$","_context","prev","next","method","headers","Authorization","fetch","sent","json","abrupt","stop","_x","_x2","_x3","apply","arguments","DAUTH_STATE","setDauthStateAction","_setDauthStateAction","dispatch","dauth_state","getUserFetch","status","history","replaceState","document","title","localStorage","setItem","removeItem","t0","console","log","finish","setAutoLoginAction","_setAutoLoginAction","_callee2","dauth_state_ls","_callee2$","_context2","setLogoutAction","_setLogoutAction","_callee3","_ref3","_callee3$","_context3","Thing","React","DauthProvider","props","sid","children","_useReducer","useReducer","dauthState","useEffect","queryString","search","urlParams","URLSearchParams","get","getItem","useCallback","replace","memoProvider","useMemo","DauthContext","Provider","value","useDauthContext","context","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAC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AANA;;GACC,EAAE,CACJkG,UAAU,EACVnG,iBAAiB,EACjBC,MAAM,CACN,CAAC;EAGF,OACC2F,oBAACmB,YAAY,CAACC,QAAQ;IAACC,KAAK,EAAEJ;KAC5Bb,QAAQ,CACc;AAE1B,CAAC;AAED,IAAMe,YAAY,gBAAGnB,mBAAmB,CAACjG,iBAAiB,CAAC;AAE3D,IAAauH,eAAe,GAAG,SAAlBA,eAAeA;EAC1B,IAAMC,OAAO,GAAGvB,gBAAgB,CAACmB,YAAY,CAAC;EAC9C,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,gEAAgE,CAAC;;EAEnF,OAAOD,OAAO;AAChB,CAAC;;;;;;"}
1
+ {"version":3,"file":"dauth-context-react.cjs.development.js","sources":["../src/initialDauthState.ts","../src/reducer/dauth.types.ts","../src/reducer/dauth.reducer.ts","../src/api/utils/config.ts","../src/api/dauth.api.ts","../src/constants.ts","../src/reducer/dauth.actions.ts","../src/index.tsx"],"sourcesContent":["export interface IDauthUser {\n\t_id: string\n\tssid: string\n\tname: string\n\tlastname: string\n\tnickname: string\n\temail: string\n\tis_verified: boolean\n\tlanguage: string\n\tavatar: string\n\tcreatedAt: Date\n\tupdatedAt: Date\n\tlast_login: Date\n}\n\nexport interface IDauthDomain {\n\tname: string\n\tloginRedirect: string\n\tallowedOrigins: string[]\n}\n\nexport interface IDauthState {\n\tuser: IDauthUser\n\tdomain: IDauthDomain\n\tisLoading: boolean\n\tisAuthenticated: boolean\n\tloginWithRedirect: () => void\n\tlogout: () => void\n\tgetAccessToken: () => void\n}\n\nconst initialDauthState: IDauthState = {\n\tuser: {} as IDauthUser,\n\tdomain: {} as IDauthDomain,\n\tisLoading: true,\n\tisAuthenticated: false,\n\tloginWithRedirect: () => { },\n\tlogout: () => { },\n\tgetAccessToken: () => { },\n}\n\nexport default initialDauthState","export const LOGIN = 'LOGIN';\nexport const SET_IS_LOADING = 'SET_IS_LOADING';","import * as DauthTypes from './dauth.types'\n\nexport default function userReducer(state: any, action: any) {\n\tconst { type, payload } = action;\n\n\tswitch (type) {\n\t\tcase DauthTypes.LOGIN:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tuser: payload.user,\n\t\t\t\tdomain: payload.domain,\n\t\t\t\tisAuthenticated: payload.isAuthenticated,\n\t\t\t}\n\n\t\tcase DauthTypes.SET_IS_LOADING:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisLoading: payload.isLoading,\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn state\n\t}\n}","const isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"[::1]\" ||\n window.location.hostname.match(\n /(192)\\.(168)\\.(1)\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm\n ) ||\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\nexport const apiVersion = \"v1\";\nexport const serverDomain = \"dauth.ovh\";\n\nexport function getServerBasePath({ domainName }: { domainName: string }) {\n const serverPort = 4012;\n const serverLocalUrl = `${window.location.protocol}//${window.location.hostname}:${serverPort}/api/${apiVersion}`\n const serverProdUrl = `https://${domainName}.${serverDomain}/api/${apiVersion}`\n const serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;\n return serverBasePath;\n}\n\nexport function getClientBasePath({ domainName }: { domainName: string }) {\n const clientPort = 5185;\n const clientLocalUrl = `${window.location.protocol}//${window.location.hostname}:${clientPort}`\n const clientProdUrl = `https://${domainName}.${serverDomain}`\n const clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;\n return clientBasePath;\n}","import { getServerBasePath } from \"./utils/config\";\n\nexport const getTenantUserAPI = async (domainName: string, ssid: string, token: string): Promise<any> => {\n const params = {\n method: \"GET\",\n headers: {\n Authorization: `${token}`,\n \"Content-Type\": \"application/json\",\n }\n }\n const response = await fetch(`${getServerBasePath({ domainName })}/get-tenant-user/${ssid}`, params)\n const data = await response.json()\n return { response, data }\n}","export const DAUTH_STATE = 'dauth_state';","import { getTenantUserAPI } from '../api/dauth.api';\nimport { DAUTH_STATE } from '../constants';\nimport * as DauthTypes from './dauth.types'\n\ntype TSetDauthStateAction = {\n dispatch: any\n dauth_state: string\n domainName: string\n ssid: string\n}\nexport async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: TSetDauthStateAction) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);\n return localStorage.setItem(DAUTH_STATE, dauth_state);\n } else {\n return localStorage.removeItem(DAUTH_STATE);\n }\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\ntype TSetAutoLoginAction = {\n dispatch: any\n dauth_state_ls: string\n domainName: string\n ssid: string\n}\nexport async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: TSetAutoLoginAction) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n localStorage.setItem(DAUTH_STATE, dauth_state_ls);\n } else {\n localStorage.removeItem(DAUTH_STATE);\n }\n\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setLogoutAction({ dispatch }: { dispatch: any }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: {},\n domain: {},\n isAuthenticated: false,\n },\n })\n localStorage.removeItem(DAUTH_STATE);\n return dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n}","import React, { useReducer, useMemo, useEffect, useCallback, createContext, useContext } from 'react'\nimport initialDauthState, { IDauthState } from './initialDauthState'\nimport userReducer from './reducer/dauth.reducer'\nimport * as action from \"./reducer/dauth.actions\"\nimport { getClientBasePath } from './api/utils/config'\nimport { DAUTH_STATE } from './constants'\n\ninterface DauthProviderProps {\n domainName: string\n sid: string\n ssid: string\n children: React.ReactNode\n}\n\nexport const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {\n\tconst { domainName, sid, ssid, children } = props\n\tconst [ds, dispatch] = useReducer(userReducer, initialDauthState)\n const dauthState = ds as IDauthState\n\n\t// Catch login redirect\n\tuseEffect(() => {\n\t\tconst queryString = window.location.search;\n\t\tif (!queryString) return\n\t\tconst urlParams = new URLSearchParams(queryString);\n\t\tconst dauth_state = urlParams.get(DAUTH_STATE);\n\t\tif (dauth_state && !dauthState.isAuthenticated) {\n\t\t\taction.setDauthStateAction({ dispatch, dauth_state, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\t// Auto Login\n\tuseEffect(() => {\n\t\tconst dauth_state_ls = localStorage.getItem(DAUTH_STATE);\n\t\tif (dauth_state_ls && !dauthState.isAuthenticated) {\n\t\t\taction.setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\tconst loginWithRedirect = useCallback(() => {\n\t\treturn window.location.replace(`${getClientBasePath({ domainName })}/t-sign/${sid}`);\n\t}, [domainName, sid])\n\n\tconst logout = useCallback(() => {\n\t\treturn action.setLogoutAction({ dispatch })\n\t}, [])\n\n\tconst memoProvider = useMemo(\n\t\t() => ({\n\t\t\t...dauthState,\n\t\t\tloginWithRedirect,\n\t\t\tlogout\n\t\t}), [\n\t\tdauthState,\n\t\tloginWithRedirect,\n\t\tlogout\n\t])\n\n\n\treturn (\n\t\t<DauthContext.Provider value={memoProvider}>\n\t\t\t{children}\n\t\t</DauthContext.Provider>\n\t)\n}\n\nconst DauthContext = createContext(initialDauthState);\n\nexport const useDauth = () => {\n const context = useContext(DauthContext);\n if (!context) {\n throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');\n }\n return context;\n};"],"names":["initialDauthState","user","domain","isLoading","isAuthenticated","loginWithRedirect","logout","getAccessToken","LOGIN","SET_IS_LOADING","userReducer","state","action","type","payload","DauthTypes","_extends","isLocalhost","Boolean","window","location","hostname","match","apiVersion","serverDomain","getServerBasePath","_ref","domainName","serverPort","serverLocalUrl","protocol","serverProdUrl","serverBasePath","getClientBasePath","_ref2","clientPort","clientLocalUrl","clientProdUrl","clientBasePath","getTenantUserAPI","_asyncToGenerator","_regeneratorRuntime","mark","_callee","ssid","token","params","response","data","wrap","_callee$","_context","prev","next","method","headers","Authorization","fetch","sent","json","abrupt","stop","_x","_x2","_x3","apply","arguments","DAUTH_STATE","setDauthStateAction","_setDauthStateAction","dispatch","dauth_state","getUserFetch","status","history","replaceState","document","title","loginRedirect","localStorage","setItem","removeItem","t0","console","log","finish","setAutoLoginAction","_setAutoLoginAction","_callee2","dauth_state_ls","_callee2$","_context2","setLogoutAction","_setLogoutAction","_callee3","_ref3","_callee3$","_context3","DauthProvider","props","sid","children","_useReducer","useReducer","ds","dauthState","useEffect","queryString","search","urlParams","URLSearchParams","get","getItem","useCallback","replace","memoProvider","useMemo","React","DauthContext","Provider","value","createContext","useDauth","context","useContext","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC;AAErD,IAAa0H,QAAQ,GAAG,SAAXA,QAAQA;EACnB,IAAMC,OAAO,GAAGC,gBAAU,CAACN,YAAY,CAAC;EACxC,IAAI,CAACK,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,gEAAgE,CAAC;;EAEnF,OAAOF,OAAO;AAChB,CAAC;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function e(){e=function(){return r};var t,r={},n=Object.prototype,o=n.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=Object.create((e&&e.prototype instanceof m?e:m).prototype),i=new k(n||[]);return a(o,"_invoke",{value:S(t,r,i)}),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var p="suspendedStart",d="executing",v="completed",y={};function m(){}function g(){}function w(){}var L={};l(L,c,(function(){return this}));var x=Object.getPrototypeOf,b=x&&x(x(G([])));b&&b!==n&&o.call(b,c)&&(L=b);var _=w.prototype=m.prototype=Object.create(L);function E(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(n,a,i,c){var u=f(t[n],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&o.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var n;a(this,"_invoke",{value:function(t,o){function a(){return new e((function(e,n){r(t,o,e,n)}))}return n=n?n.then(a,a):a()}})}function S(e,r,n){var o=p;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=I(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?v:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function I(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function G(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function r(){for(;++n<e.length;)if(o.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=w,a(_,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:g,configurable:!0}),g.displayName=l(w,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(_),t},r.awrap=function(t){return{__await:t}},E(O.prototype),l(O.prototype,u,(function(){return this})),r.AsyncIterator=O,r.async=function(t,e,n,o,a){void 0===a&&(a=Promise);var i=new O(h(t,e,n,o),a);return r.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},E(_),l(_,s,"Generator"),l(_,c,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=G,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=o.call(i,"catchLoc"),s=o.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:G(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},r}function r(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,a){var i=t.apply(e,n);function c(t){r(i,o,a,c,u,"next",t)}function u(t){r(i,o,a,c,u,"throw",t)}c(void 0)}))}}function o(){return(o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var a={user:{_id:"",ssid:"",name:"",lastname:"",nickname:"",email:"",is_verified:!1,language:"",avatar:"",createdAt:new Date,updatedAt:new Date,last_login:new Date},domain:{name:"",loginRedirect:"",allowedOrigins:[""]},isLoading:!0,isAuthenticated:!1,loginWithRedirect:function(){},logout:function(){},getAccessToken:function(){}};function i(t,e){var r=e.payload;switch(e.type){case"LOGIN":return o({},t,{user:r.user,domain:r.domain,isAuthenticated:r.isAuthenticated});case"SET_IS_LOADING":return o({},t,{isLoading:r.isLoading});default:return t}}var c=Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/(192)\.(168)\.(1)\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm)||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function u(t){var e=window.location.protocol+"//"+window.location.hostname+":4012/api/v1";return c?e:"https://"+t.domainName+".dauth.ovh/api/v1"}var s=function(){var t=n(e().mark((function t(r,n,o){var a,i;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={method:"GET",headers:{Authorization:""+o,"Content-Type":"application/json"}},t.next=3,fetch(u({domainName:r})+"/get-tenant-user/"+n,a);case 3:return i=t.sent,t.next=6,i.json();case 6:return t.abrupt("return",{response:i,data:t.sent});case 8:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),l="dauth_state";function h(){return(h=n(e().mark((function t(r){var n,o,a,i,c;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r.dauth_state,a=r.domainName,i=r.ssid,(n=r.dispatch)({type:"SET_IS_LOADING",payload:{isLoading:!0}}),t.prev=2,t.next=5,s(a,i,o);case 5:if(200!==(c=t.sent).response.status){t.next=12;break}return n({type:"LOGIN",payload:{user:c.data.user,domain:c.data.domain,isAuthenticated:!0}}),window.history.replaceState({},document.title,c.data.domain.loginRedirect),t.abrupt("return",localStorage.setItem(l,o));case 12:return t.abrupt("return",localStorage.removeItem(l));case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(2),localStorage.removeItem(l),console.log(t.t0);case 19:return t.prev=19,n({type:"SET_IS_LOADING",payload:{isLoading:!1}}),t.finish(19);case 22:case"end":return t.stop()}}),t,null,[[2,15,19,22]])})))).apply(this,arguments)}function f(){return(f=n(e().mark((function t(r){var n,o,a,i,c;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r.dauth_state_ls,a=r.domainName,i=r.ssid,(n=r.dispatch)({type:"SET_IS_LOADING",payload:{isLoading:!0}}),t.prev=2,t.next=5,s(a,i,o);case 5:200===(c=t.sent).response.status?(n({type:"LOGIN",payload:{user:c.data.user,domain:c.data.domain,isAuthenticated:!0}}),localStorage.setItem(l,o)):localStorage.removeItem(l),t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),localStorage.removeItem(l),console.log(t.t0);case 13:return t.prev=13,n({type:"SET_IS_LOADING",payload:{isLoading:!1}}),t.finish(13);case 16:case"end":return t.stop()}}),t,null,[[2,9,13,16]])})))).apply(this,arguments)}function p(){return(p=n(e().mark((function t(r){var n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(n=r.dispatch)({type:"SET_IS_LOADING",payload:{isLoading:!0}}),n({type:"LOGIN",payload:{user:{},domain:{},isAuthenticated:!1}}),localStorage.removeItem(l),t.abrupt("return",n({type:"SET_IS_LOADING",payload:{isLoading:!1}}));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var d=t.createContext(a);exports.DauthProvider=function(e){var r=e.domainName,n=e.sid,u=e.ssid,s=e.children,v=t.useReducer(i,a),y=v[0],m=v[1];t.useEffect((function(){var t=window.location.search;if(t){var e=new URLSearchParams(t).get(l);e&&!y.isAuthenticated&&function(t){h.apply(this,arguments)}({dispatch:m,dauth_state:e,domainName:r,ssid:u})}}),[y.isAuthenticated,r,u]),t.useEffect((function(){var t=localStorage.getItem(l);t&&!y.isAuthenticated&&function(t){f.apply(this,arguments)}({dispatch:m,dauth_state_ls:t,domainName:r,ssid:u})}),[y.isAuthenticated,r,u]);var g=t.useCallback((function(){return window.location.replace((t=window.location.protocol+"//"+window.location.hostname+":5185",(c?t:"https://"+r+".dauth.ovh")+"/t-sign/"+n));var t}),[r,n]),w=t.useCallback((function(){return function(t){return p.apply(this,arguments)}({dispatch:m})}),[]),L=t.useMemo((function(){return o({},y,{loginWithRedirect:g,logout:w})}),[y,g,w]);return t.createElement(d.Provider,{value:L},s)},exports.Thing=function(){return t.createElement("div",null,"the snozzberries taste like snozzberries")},exports.useDauthContext=function(){var e=t.useContext(d);if(!e)throw new Error("useMyContext debe ser utilizado dentro de un MyContextProvider");return e};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),r=(t=e)&&"object"==typeof t&&"default"in t?t.default:t;function n(){n=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=Object.create((e&&e.prototype instanceof m?e:m).prototype),i=new j(n||[]);return a(o,"_invoke",{value:S(t,r,i)}),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var p="suspendedStart",d="executing",v="completed",y={};function m(){}function g(){}function w(){}var L={};l(L,c,(function(){return this}));var x=Object.getPrototypeOf,b=x&&x(x(G([])));b&&b!==r&&o.call(b,c)&&(L=b);var _=w.prototype=m.prototype=Object.create(L);function E(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(n,a,i,c){var u=f(t[n],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&o.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var n;a(this,"_invoke",{value:function(t,o){function a(){return new e((function(e,n){r(t,o,e,n)}))}return n=n?n.then(a,a):a()}})}function S(e,r,n){var o=p;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=I(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?v:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function I(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function G(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function r(){for(;++n<e.length;)if(o.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=w,a(_,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:g,configurable:!0}),g.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},E(O.prototype),l(O.prototype,u,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(h(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},E(_),l(_,s,"Generator"),l(_,c,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=G,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=o.call(i,"catchLoc"),s=o.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:G(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function o(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var i=t.apply(e,r);function c(t){o(i,n,a,c,u,"next",t)}function u(t){o(i,n,a,c,u,"throw",t)}c(void 0)}))}}function i(){return(i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var c={user:{},domain:{},isLoading:!0,isAuthenticated:!1,loginWithRedirect:function(){},logout:function(){},getAccessToken:function(){}};function u(t,e){var r=e.payload;switch(e.type){case"LOGIN":return i({},t,{user:r.user,domain:r.domain,isAuthenticated:r.isAuthenticated});case"SET_IS_LOADING":return i({},t,{isLoading:r.isLoading});default:return t}}var s=Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/(192)\.(168)\.(1)\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm)||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function l(t){var e=window.location.protocol+"//"+window.location.hostname+":4012/api/v1";return s?e:"https://"+t.domainName+".dauth.ovh/api/v1"}var h=function(){var t=a(n().mark((function t(e,r,o){var a,i;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={method:"GET",headers:{Authorization:""+o,"Content-Type":"application/json"}},t.next=3,fetch(l({domainName:e})+"/get-tenant-user/"+r,a);case 3:return i=t.sent,t.next=6,i.json();case 6:return t.abrupt("return",{response:i,data:t.sent});case 8:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),f="dauth_state";function p(){return(p=a(n().mark((function t(e){var r,o,a,i,c;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.dauth_state,a=e.domainName,i=e.ssid,(r=e.dispatch)({type:"SET_IS_LOADING",payload:{isLoading:!0}}),t.prev=2,t.next=5,h(a,i,o);case 5:if(200!==(c=t.sent).response.status){t.next=12;break}return r({type:"LOGIN",payload:{user:c.data.user,domain:c.data.domain,isAuthenticated:!0}}),window.history.replaceState({},document.title,c.data.domain.loginRedirect),t.abrupt("return",localStorage.setItem(f,o));case 12:return t.abrupt("return",localStorage.removeItem(f));case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(2),localStorage.removeItem(f),console.log(t.t0);case 19:return t.prev=19,r({type:"SET_IS_LOADING",payload:{isLoading:!1}}),t.finish(19);case 22:case"end":return t.stop()}}),t,null,[[2,15,19,22]])})))).apply(this,arguments)}function d(){return(d=a(n().mark((function t(e){var r,o,a,i,c;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.dauth_state_ls,a=e.domainName,i=e.ssid,(r=e.dispatch)({type:"SET_IS_LOADING",payload:{isLoading:!0}}),t.prev=2,t.next=5,h(a,i,o);case 5:200===(c=t.sent).response.status?(r({type:"LOGIN",payload:{user:c.data.user,domain:c.data.domain,isAuthenticated:!0}}),localStorage.setItem(f,o)):localStorage.removeItem(f),t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),localStorage.removeItem(f),console.log(t.t0);case 13:return t.prev=13,r({type:"SET_IS_LOADING",payload:{isLoading:!1}}),t.finish(13);case 16:case"end":return t.stop()}}),t,null,[[2,9,13,16]])})))).apply(this,arguments)}function v(){return(v=a(n().mark((function t(e){var r;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r=e.dispatch)({type:"SET_IS_LOADING",payload:{isLoading:!0}}),r({type:"LOGIN",payload:{user:{},domain:{},isAuthenticated:!1}}),localStorage.removeItem(f),t.abrupt("return",r({type:"SET_IS_LOADING",payload:{isLoading:!1}}));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var y=e.createContext(c);exports.DauthProvider=function(t){var n=t.domainName,o=t.sid,a=t.ssid,l=t.children,h=e.useReducer(u,c),m=h[1],g=h[0];e.useEffect((function(){var t=window.location.search;if(t){var e=new URLSearchParams(t).get(f);e&&!g.isAuthenticated&&function(t){p.apply(this,arguments)}({dispatch:m,dauth_state:e,domainName:n,ssid:a})}}),[g.isAuthenticated,n,a]),e.useEffect((function(){var t=localStorage.getItem(f);t&&!g.isAuthenticated&&function(t){d.apply(this,arguments)}({dispatch:m,dauth_state_ls:t,domainName:n,ssid:a})}),[g.isAuthenticated,n,a]);var w=e.useCallback((function(){return window.location.replace((t=window.location.protocol+"//"+window.location.hostname+":5185",(s?t:"https://"+n+".dauth.ovh")+"/t-sign/"+o));var t}),[n,o]),L=e.useCallback((function(){return function(t){return v.apply(this,arguments)}({dispatch:m})}),[]),x=e.useMemo((function(){return i({},g,{loginWithRedirect:w,logout:L})}),[g,w,L]);return r.createElement(y.Provider,{value:x},l)},exports.useDauth=function(){var t=e.useContext(y);if(!t)throw new Error("useMyContext debe ser utilizado dentro de un MyContextProvider");return t};
2
2
  //# sourceMappingURL=dauth-context-react.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dauth-context-react.cjs.production.min.js","sources":["../src/initialDauthState.ts","../src/reducer/dauth.reducer.ts","../src/reducer/dauth.types.ts","../src/api/utils/config.ts","../src/api/dauth.api.ts","../src/constants.ts","../src/reducer/dauth.actions.ts","../src/index.tsx"],"sourcesContent":["// export interface IDauthUser {\n// \t_id: string\n// \tssid: string\n// \tname: string\n// \tlastname: string\n// \tnickname: string\n// \temail: string\n// \tis_verified: boolean\n// \tlanguage: string\n// \tavatar: string\n// \tcreatedAt: Date\n// \tupdatedAt: Date\n// \tlast_login: Date\n// }\n\n// export interface IDauthDomain {\n// \tname: string\n// \tloginRedirect: string\n// \tallowedOrigins: string[]\n// }\n\n// export interface IDauthState {\n// \tuser: IDauthUser\n// \tdomain: IDauthDomain\n// \tisLoading: boolean\n// \tisAuthenticated: boolean\n// \tloginWithRedirect: () => void\n// \tlogout: () => void\n// \tgetAccessToken: () => void\n// }\n\nconst userState = {\n\t_id: \"\",\n\tssid: \"\",\n\tname: \"\",\n\tlastname: \"\",\n\tnickname: \"\",\n\temail: \"\",\n\tis_verified: false,\n\tlanguage: \"\",\n\tavatar: \"\",\n\tcreatedAt: new Date(),\n\tupdatedAt: new Date(),\n\tlast_login: new Date(),\n}\n\nconst domainState = {\n\tname: \"\",\n\tloginRedirect: \"\",\n\tallowedOrigins: [\"\"],\n}\n\nconst initialDauthState = {\n\tuser: userState,\n\tdomain: domainState,\n\tisLoading: true,\n\tisAuthenticated: false,\n\tloginWithRedirect: () => { },\n\tlogout: () => { },\n\tgetAccessToken: () => { },\n}\n\nexport default initialDauthState","import * as DauthTypes from './dauth.types'\n\nexport default function userReducer(state: any, action: any) {\n\tconst { type, payload } = action;\n\n\tswitch (type) {\n\t\tcase DauthTypes.LOGIN:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tuser: payload.user,\n\t\t\t\tdomain: payload.domain,\n\t\t\t\tisAuthenticated: payload.isAuthenticated,\n\t\t\t}\n\n\t\tcase DauthTypes.SET_IS_LOADING:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisLoading: payload.isLoading,\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn state\n\t}\n}","export const LOGIN = 'LOGIN';\nexport const SET_IS_LOADING = 'SET_IS_LOADING';","const isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"[::1]\" ||\n window.location.hostname.match(\n /(192)\\.(168)\\.(1)\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm\n ) ||\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\nexport const apiVersion = \"v1\";\nexport const serverDomain = \"dauth.ovh\";\n\nexport function getServerBasePath({ domainName }: { domainName: string }) {\n const serverPort = 4012;\n const serverLocalUrl = `${window.location.protocol}//${window.location.hostname}:${serverPort}/api/${apiVersion}`\n const serverProdUrl = `https://${domainName}.${serverDomain}/api/${apiVersion}`\n const serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;\n return serverBasePath;\n}\n\nexport function getClientBasePath({ domainName }: { domainName: string }) {\n const clientPort = 5185;\n const clientLocalUrl = `${window.location.protocol}//${window.location.hostname}:${clientPort}`\n const clientProdUrl = `https://${domainName}.${serverDomain}`\n const clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;\n return clientBasePath;\n}","import { getServerBasePath } from \"./utils/config\";\n\nexport const getTenantUserAPI = async (domainName: string, ssid: string, token: string): Promise<any> => {\n const params = {\n method: \"GET\",\n headers: {\n Authorization: `${token}`,\n \"Content-Type\": \"application/json\",\n }\n }\n const response = await fetch(`${getServerBasePath({ domainName })}/get-tenant-user/${ssid}`, params)\n const data = await response.json()\n return { response, data }\n}","export const DAUTH_STATE = 'dauth_state';","import { getTenantUserAPI } from '../api/dauth.api';\nimport { DAUTH_STATE } from '../constants';\nimport * as DauthTypes from './dauth.types'\n\nexport async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: { dispatch: any, dauth_state: string, domainName: string, ssid: string }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);\n return localStorage.setItem(DAUTH_STATE, dauth_state);\n } else {\n return localStorage.removeItem(DAUTH_STATE);\n }\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: { dispatch: any, dauth_state_ls: string, domainName: string, ssid: string }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n localStorage.setItem(DAUTH_STATE, dauth_state_ls);\n } else {\n localStorage.removeItem(DAUTH_STATE);\n }\n\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setLogoutAction({ dispatch }: { dispatch: any }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: {},\n domain: {},\n isAuthenticated: false,\n },\n })\n localStorage.removeItem(DAUTH_STATE);\n return dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n}","import * as React from 'react';\nimport { useReducer, useMemo, useEffect, useCallback } from 'react'\nimport initialDauthState from './initialDauthState'\nimport userReducer from './reducer/dauth.reducer'\nimport * as action from \"./reducer/dauth.actions\"\nimport { getClientBasePath } from './api/utils/config'\nimport { DAUTH_STATE } from './constants'\n\n// Delete me\nexport const Thing = () => {\n return <div>the snozzberries taste like snozzberries</div>;\n};\n\ninterface DauthProviderProps {\n domainName: string\n sid: string\n ssid: string\n children: React.ReactNode\n}\n\nexport const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {\n\tconst { domainName, sid, ssid, children } = props\n\tconst [dauthState, dispatch] = useReducer(userReducer, initialDauthState)\n\n\t// Catch login redirect\n\tuseEffect(() => {\n\t\tconst queryString = window.location.search;\n\t\tif (!queryString) return\n\t\tconst urlParams = new URLSearchParams(queryString);\n\t\tconst dauth_state = urlParams.get(DAUTH_STATE);\n\t\tif (dauth_state && !dauthState.isAuthenticated) {\n\t\t\taction.setDauthStateAction({ dispatch, dauth_state, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\t// Auto Login\n\tuseEffect(() => {\n\t\tconst dauth_state_ls = localStorage.getItem(DAUTH_STATE);\n\t\tif (dauth_state_ls && !dauthState.isAuthenticated) {\n\t\t\taction.setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\tconst loginWithRedirect = useCallback(() => {\n\t\treturn window.location.replace(`${getClientBasePath({ domainName })}/t-sign/${sid}`);\n\t}, [domainName, sid])\n\n\tconst logout = useCallback(() => {\n\t\treturn action.setLogoutAction({ dispatch })\n\t}, [])\n\n\tconst memoProvider = useMemo(\n\t\t() => ({\n\t\t\t...dauthState,\n\t\t\tloginWithRedirect,\n\t\t\tlogout\n\t\t}), [\n\t\tdauthState,\n\t\tloginWithRedirect,\n\t\tlogout\n\t])\n\n\n\treturn (\n\t\t<DauthContext.Provider value={memoProvider}>\n\t\t\t{children}\n\t\t</DauthContext.Provider>\n\t)\n}\n\nconst DauthContext = React.createContext(initialDauthState);\n\nexport const useDauthContext = () => {\n const context = React.useContext(DauthContext);\n if (!context) {\n throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');\n }\n return context;\n};"],"names":["initialDauthState","user","_id","ssid","name","lastname","nickname","email","is_verified","language","avatar","createdAt","Date","updatedAt","last_login","domain","loginRedirect","allowedOrigins","isLoading","isAuthenticated","loginWithRedirect","logout","getAccessToken","userReducer","state","action","payload","type","_extends","isLocalhost","Boolean","window","location","hostname","match","getServerBasePath","_ref","serverLocalUrl","protocol","domainName","getTenantUserAPI","_asyncToGenerator","_regeneratorRuntime","mark","_callee","token","params","response","wrap","_context","prev","next","method","headers","Authorization","Content-Type","fetch","sent","json","abrupt","data","stop","_x","_x2","_x3","apply","arguments","DAUTH_STATE","_setDauthStateAction","dispatch","dauth_state","getUserFetch","status","history","replaceState","document","title","localStorage","setItem","removeItem","t0","console","log","finish","_setAutoLoginAction","_callee2","_ref2","dauth_state_ls","_context2","_setLogoutAction","_callee3","_ref3","_context3","DauthContext","React","props","sid","children","_useReducer","useReducer","dauthState","useEffect","queryString","search","URLSearchParams","get","getItem","useCallback","replace","clientLocalUrl","memoProvider","useMemo","Provider","value","context","Error"],"mappings":"s+NA+BA,IAqBMA,EAAoB,CACzBC,KAtBiB,CACjBC,IAAK,GACLC,KAAM,GACNC,KAAM,GACNC,SAAU,GACVC,SAAU,GACVC,MAAO,GACPC,aAAa,EACbC,SAAU,GACVC,OAAQ,GACRC,UAAW,IAAIC,KACfC,UAAW,IAAID,KACfE,WAAY,IAAIF,MAWhBG,OARmB,CACnBX,KAAM,GACNY,cAAe,GACfC,eAAgB,CAAC,KAMjBC,WAAW,EACXC,iBAAiB,EACjBC,kBAAmB,aACnBC,OAAQ,aACRC,eA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"version":3,"file":"dauth-context-react.cjs.production.min.js","sources":["../src/initialDauthState.ts","../src/reducer/dauth.reducer.ts","../src/reducer/dauth.types.ts","../src/api/utils/config.ts","../src/api/dauth.api.ts","../src/constants.ts","../src/reducer/dauth.actions.ts","../src/index.tsx"],"sourcesContent":["export interface IDauthUser {\n\t_id: string\n\tssid: string\n\tname: string\n\tlastname: string\n\tnickname: string\n\temail: string\n\tis_verified: boolean\n\tlanguage: string\n\tavatar: string\n\tcreatedAt: Date\n\tupdatedAt: Date\n\tlast_login: Date\n}\n\nexport interface IDauthDomain {\n\tname: string\n\tloginRedirect: string\n\tallowedOrigins: string[]\n}\n\nexport interface IDauthState {\n\tuser: IDauthUser\n\tdomain: IDauthDomain\n\tisLoading: boolean\n\tisAuthenticated: boolean\n\tloginWithRedirect: () => void\n\tlogout: () => void\n\tgetAccessToken: () => void\n}\n\nconst initialDauthState: IDauthState = {\n\tuser: {} as IDauthUser,\n\tdomain: {} as IDauthDomain,\n\tisLoading: true,\n\tisAuthenticated: false,\n\tloginWithRedirect: () => { },\n\tlogout: () => { },\n\tgetAccessToken: () => { },\n}\n\nexport default initialDauthState","import * as DauthTypes from './dauth.types'\n\nexport default function userReducer(state: any, action: any) {\n\tconst { type, payload } = action;\n\n\tswitch (type) {\n\t\tcase DauthTypes.LOGIN:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tuser: payload.user,\n\t\t\t\tdomain: payload.domain,\n\t\t\t\tisAuthenticated: payload.isAuthenticated,\n\t\t\t}\n\n\t\tcase DauthTypes.SET_IS_LOADING:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisLoading: payload.isLoading,\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn state\n\t}\n}","export const LOGIN = 'LOGIN';\nexport const SET_IS_LOADING = 'SET_IS_LOADING';","const isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"[::1]\" ||\n window.location.hostname.match(\n /(192)\\.(168)\\.(1)\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm\n ) ||\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\nexport const apiVersion = \"v1\";\nexport const serverDomain = \"dauth.ovh\";\n\nexport function getServerBasePath({ domainName }: { domainName: string }) {\n const serverPort = 4012;\n const serverLocalUrl = `${window.location.protocol}//${window.location.hostname}:${serverPort}/api/${apiVersion}`\n const serverProdUrl = `https://${domainName}.${serverDomain}/api/${apiVersion}`\n const serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;\n return serverBasePath;\n}\n\nexport function getClientBasePath({ domainName }: { domainName: string }) {\n const clientPort = 5185;\n const clientLocalUrl = `${window.location.protocol}//${window.location.hostname}:${clientPort}`\n const clientProdUrl = `https://${domainName}.${serverDomain}`\n const clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;\n return clientBasePath;\n}","import { getServerBasePath } from \"./utils/config\";\n\nexport const getTenantUserAPI = async (domainName: string, ssid: string, token: string): Promise<any> => {\n const params = {\n method: \"GET\",\n headers: {\n Authorization: `${token}`,\n \"Content-Type\": \"application/json\",\n }\n }\n const response = await fetch(`${getServerBasePath({ domainName })}/get-tenant-user/${ssid}`, params)\n const data = await response.json()\n return { response, data }\n}","export const DAUTH_STATE = 'dauth_state';","import { getTenantUserAPI } from '../api/dauth.api';\nimport { DAUTH_STATE } from '../constants';\nimport * as DauthTypes from './dauth.types'\n\ntype TSetDauthStateAction = {\n dispatch: any\n dauth_state: string\n domainName: string\n ssid: string\n}\nexport async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: TSetDauthStateAction) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);\n return localStorage.setItem(DAUTH_STATE, dauth_state);\n } else {\n return localStorage.removeItem(DAUTH_STATE);\n }\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\ntype TSetAutoLoginAction = {\n dispatch: any\n dauth_state_ls: string\n domainName: string\n ssid: string\n}\nexport async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: TSetAutoLoginAction) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n localStorage.setItem(DAUTH_STATE, dauth_state_ls);\n } else {\n localStorage.removeItem(DAUTH_STATE);\n }\n\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setLogoutAction({ dispatch }: { dispatch: any }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: {},\n domain: {},\n isAuthenticated: false,\n },\n })\n localStorage.removeItem(DAUTH_STATE);\n return dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n}","import React, { useReducer, useMemo, useEffect, useCallback, createContext, useContext } from 'react'\nimport initialDauthState, { IDauthState } from './initialDauthState'\nimport userReducer from './reducer/dauth.reducer'\nimport * as action from \"./reducer/dauth.actions\"\nimport { getClientBasePath } from './api/utils/config'\nimport { DAUTH_STATE } from './constants'\n\ninterface DauthProviderProps {\n domainName: string\n sid: string\n ssid: string\n children: React.ReactNode\n}\n\nexport const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {\n\tconst { domainName, sid, ssid, children } = props\n\tconst [ds, dispatch] = useReducer(userReducer, initialDauthState)\n const dauthState = ds as IDauthState\n\n\t// Catch login redirect\n\tuseEffect(() => {\n\t\tconst queryString = window.location.search;\n\t\tif (!queryString) return\n\t\tconst urlParams = new URLSearchParams(queryString);\n\t\tconst dauth_state = urlParams.get(DAUTH_STATE);\n\t\tif (dauth_state && !dauthState.isAuthenticated) {\n\t\t\taction.setDauthStateAction({ dispatch, dauth_state, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\t// Auto Login\n\tuseEffect(() => {\n\t\tconst dauth_state_ls = localStorage.getItem(DAUTH_STATE);\n\t\tif (dauth_state_ls && !dauthState.isAuthenticated) {\n\t\t\taction.setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\tconst loginWithRedirect = useCallback(() => {\n\t\treturn window.location.replace(`${getClientBasePath({ domainName })}/t-sign/${sid}`);\n\t}, [domainName, sid])\n\n\tconst logout = useCallback(() => {\n\t\treturn action.setLogoutAction({ dispatch })\n\t}, [])\n\n\tconst memoProvider = useMemo(\n\t\t() => ({\n\t\t\t...dauthState,\n\t\t\tloginWithRedirect,\n\t\t\tlogout\n\t\t}), [\n\t\tdauthState,\n\t\tloginWithRedirect,\n\t\tlogout\n\t])\n\n\n\treturn (\n\t\t<DauthContext.Provider value={memoProvider}>\n\t\t\t{children}\n\t\t</DauthContext.Provider>\n\t)\n}\n\nconst DauthContext = createContext(initialDauthState);\n\nexport const useDauth = () => {\n const context = useContext(DauthContext);\n if (!context) {\n throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');\n }\n return context;\n};"],"names":["initialDauthState","user","domain","isLoading","isAuthenticated","loginWithRedirect","logout","getAccessToken","userReducer","state","action","payload","type","_extends","isLocalhost","Boolean","window","location","hostname","match","getServerBasePath","_ref","serverLocalUrl","protocol","domainName","getTenantUserAPI","_asyncToGenerator","_regeneratorRuntime","mark","_callee","ssid","token","params","response","wrap","_context","prev","next","method","headers","Authorization","Content-Type","fetch","sent","json","abrupt","data","stop","_x","_x2","_x3","apply","arguments","DAUTH_STATE","_setDauthStateAction","dispatch","dauth_state","getUserFetch","status","history","replaceState","document","title","loginRedirect","localStorage","setItem","removeItem","t0","console","log","finish","_setAutoLoginAction","_callee2","_ref2","dauth_state_ls","_context2","_setLogoutAction","_callee3","_ref3","_context3","DauthContext","createContext","props","sid","children","_useReducer","useReducer","dauthState","useEffect","queryString","search","URLSearchParams","get","getItem","useCallback","replace","clientLocalUrl","memoProvider","useMemo","React","Provider","value","context","useContext","Error"],"mappings":"+hOA+BA,IAAMA,EAAiC,CACtCC,KAAM,GACNC,OAAQ,GACRC,WAAW,EACXC,iBAAiB,EACjBC,kBAAmB,aACnBC,OAAQ,aACRC,eAAgB,uBCpCOC,EAAYC,EAAYC,GAC/C,IAAcC,EAAYD,EAAZC,QAEd,OAF0BD,EAAlBE,MAGP,ICNmB,QDOlB,OAAAC,KACIJ,GACHR,KAAMU,EAAQV,KACdC,OAAQS,EAAQT,OAChBE,gBAAiBO,EAAQP,kBAG3B,ICb4B,iBDc3B,OAAAS,KACIJ,GACHN,UAAWQ,EAAQR,YAGrB,QACC,OAAOM,GErBV,IAAMK,EAAcC,QACW,cAA7BC,OAAOC,SAASC,UACa,UAA7BF,OAAOC,SAASC,UAChBF,OAAOC,SAASC,SAASC,MACvB,2EAEFH,OAAOC,SAASC,SAASC,MACvB,oEAMYC,EAAiBC,OAEzBC,EAAoBN,OAAOC,SAASM,cAAaP,OAAOC,SAASC,SAA7CF,eAG1B,OADuBF,EAAcQ,aAJOD,EAAVG,mCCXvBC,aAAgB,IAAAJ,EAAAK,EAAAC,IAAAC,MAAG,SAAAC,EAAOL,EAAoBM,EAAcC,GAAa,IAA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nF,gBAAiBoB,EAAYM,IAE5C,IAAMzB,EAAoByF,eAAY,WACrC,OAAO9E,OAAOC,SAAS8E,SJhBjBC,EAAoBhF,OAAOC,SAASM,cAAaP,OAAOC,SAASC,SAA7CF,SAEHF,EAAckF,aIciBxE,2BAAwB2D,QJhBxEa,IIiBJ,CAACxE,EAAY2D,IAEV7E,EAASwF,eAAY,WAC1B,gBDyBmC5C,GAAA,OAAA0B,EAAAzB,WAAAC,WCzB5B1C,CAAuB,CAAE6C,SAAAA,MAC9B,IAEG0C,EAAeC,WACpB,WAAA,OAAArF,KACI0E,GACHlF,kBAAAA,EACAC,OAAAA,MACG,CACJiF,EACAlF,EACAC,IAID,OACC6F,gBAACnB,EAAaoB,UAASC,MAAOJ,GAC5Bb,qBAOoB,WACtB,IAAMkB,EAAUC,aAAWvB,GAC3B,IAAKsB,EACH,MAAM,IAAIE,MAAM,kEAElB,OAAOF"}
@@ -1,4 +1,4 @@
1
- import { createElement, useReducer, useEffect, useCallback, useMemo, createContext, useContext } from 'react';
1
+ import React, { useReducer, useEffect, useCallback, useMemo, createContext, useContext } from 'react';
2
2
 
3
3
  function _regeneratorRuntime() {
4
4
  _regeneratorRuntime = function () {
@@ -346,56 +346,9 @@ function _extends() {
346
346
  return _extends.apply(this, arguments);
347
347
  }
348
348
 
349
- // export interface IDauthUser {
350
- // _id: string
351
- // ssid: string
352
- // name: string
353
- // lastname: string
354
- // nickname: string
355
- // email: string
356
- // is_verified: boolean
357
- // language: string
358
- // avatar: string
359
- // createdAt: Date
360
- // updatedAt: Date
361
- // last_login: Date
362
- // }
363
- // export interface IDauthDomain {
364
- // name: string
365
- // loginRedirect: string
366
- // allowedOrigins: string[]
367
- // }
368
- // export interface IDauthState {
369
- // user: IDauthUser
370
- // domain: IDauthDomain
371
- // isLoading: boolean
372
- // isAuthenticated: boolean
373
- // loginWithRedirect: () => void
374
- // logout: () => void
375
- // getAccessToken: () => void
376
- // }
377
- var userState = {
378
- _id: "",
379
- ssid: "",
380
- name: "",
381
- lastname: "",
382
- nickname: "",
383
- email: "",
384
- is_verified: false,
385
- language: "",
386
- avatar: "",
387
- createdAt: /*#__PURE__*/new Date(),
388
- updatedAt: /*#__PURE__*/new Date(),
389
- last_login: /*#__PURE__*/new Date()
390
- };
391
- var domainState = {
392
- name: "",
393
- loginRedirect: "",
394
- allowedOrigins: [""]
395
- };
396
349
  var initialDauthState = {
397
- user: userState,
398
- domain: domainState,
350
+ user: {},
351
+ domain: {},
399
352
  isLoading: true,
400
353
  isAuthenticated: false,
401
354
  loginWithRedirect: function loginWithRedirect() {},
@@ -645,18 +598,15 @@ function _setLogoutAction() {
645
598
  return _setLogoutAction.apply(this, arguments);
646
599
  }
647
600
 
648
- // Delete me
649
- var Thing = function Thing() {
650
- return createElement("div", null, "the snozzberries taste like snozzberries");
651
- };
652
601
  var DauthProvider = function DauthProvider(props) {
653
602
  var domainName = props.domainName,
654
603
  sid = props.sid,
655
604
  ssid = props.ssid,
656
605
  children = props.children;
657
606
  var _useReducer = useReducer(userReducer, initialDauthState),
658
- dauthState = _useReducer[0],
607
+ ds = _useReducer[0],
659
608
  dispatch = _useReducer[1];
609
+ var dauthState = ds;
660
610
  // Catch login redirect
661
611
  useEffect(function () {
662
612
  var queryString = window.location.search;
@@ -700,12 +650,12 @@ var DauthProvider = function DauthProvider(props) {
700
650
  logout: logout
701
651
  });
702
652
  }, [dauthState, loginWithRedirect, logout]);
703
- return createElement(DauthContext.Provider, {
653
+ return React.createElement(DauthContext.Provider, {
704
654
  value: memoProvider
705
655
  }, children);
706
656
  };
707
657
  var DauthContext = /*#__PURE__*/createContext(initialDauthState);
708
- var useDauthContext = function useDauthContext() {
658
+ var useDauth = function useDauth() {
709
659
  var context = useContext(DauthContext);
710
660
  if (!context) {
711
661
  throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');
@@ -713,5 +663,5 @@ var useDauthContext = function useDauthContext() {
713
663
  return context;
714
664
  };
715
665
 
716
- export { DauthProvider, Thing, useDauthContext };
666
+ export { DauthProvider, useDauth };
717
667
  //# sourceMappingURL=dauth-context-react.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dauth-context-react.esm.js","sources":["../src/initialDauthState.ts","../src/reducer/dauth.types.ts","../src/reducer/dauth.reducer.ts","../src/api/utils/config.ts","../src/api/dauth.api.ts","../src/constants.ts","../src/reducer/dauth.actions.ts","../src/index.tsx"],"sourcesContent":["// export interface IDauthUser {\n// \t_id: string\n// \tssid: string\n// \tname: string\n// \tlastname: string\n// \tnickname: string\n// \temail: string\n// \tis_verified: boolean\n// \tlanguage: string\n// \tavatar: string\n// \tcreatedAt: Date\n// \tupdatedAt: Date\n// \tlast_login: Date\n// }\n\n// export interface IDauthDomain {\n// \tname: string\n// \tloginRedirect: string\n// \tallowedOrigins: string[]\n// }\n\n// export interface IDauthState {\n// \tuser: IDauthUser\n// \tdomain: IDauthDomain\n// \tisLoading: boolean\n// \tisAuthenticated: boolean\n// \tloginWithRedirect: () => void\n// \tlogout: () => void\n// \tgetAccessToken: () => void\n// }\n\nconst userState = {\n\t_id: \"\",\n\tssid: \"\",\n\tname: \"\",\n\tlastname: \"\",\n\tnickname: \"\",\n\temail: \"\",\n\tis_verified: false,\n\tlanguage: \"\",\n\tavatar: \"\",\n\tcreatedAt: new Date(),\n\tupdatedAt: new Date(),\n\tlast_login: new Date(),\n}\n\nconst domainState = {\n\tname: \"\",\n\tloginRedirect: \"\",\n\tallowedOrigins: [\"\"],\n}\n\nconst initialDauthState = {\n\tuser: userState,\n\tdomain: domainState,\n\tisLoading: true,\n\tisAuthenticated: false,\n\tloginWithRedirect: () => { },\n\tlogout: () => { },\n\tgetAccessToken: () => { },\n}\n\nexport default initialDauthState","export const LOGIN = 'LOGIN';\nexport const SET_IS_LOADING = 'SET_IS_LOADING';","import * as DauthTypes from './dauth.types'\n\nexport default function userReducer(state: any, action: any) {\n\tconst { type, payload } = action;\n\n\tswitch (type) {\n\t\tcase DauthTypes.LOGIN:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tuser: payload.user,\n\t\t\t\tdomain: payload.domain,\n\t\t\t\tisAuthenticated: payload.isAuthenticated,\n\t\t\t}\n\n\t\tcase DauthTypes.SET_IS_LOADING:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisLoading: payload.isLoading,\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn state\n\t}\n}","const isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"[::1]\" ||\n window.location.hostname.match(\n /(192)\\.(168)\\.(1)\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm\n ) ||\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\nexport const apiVersion = \"v1\";\nexport const serverDomain = \"dauth.ovh\";\n\nexport function getServerBasePath({ domainName }: { domainName: string }) {\n const serverPort = 4012;\n const serverLocalUrl = `${window.location.protocol}//${window.location.hostname}:${serverPort}/api/${apiVersion}`\n const serverProdUrl = `https://${domainName}.${serverDomain}/api/${apiVersion}`\n const serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;\n return serverBasePath;\n}\n\nexport function getClientBasePath({ domainName }: { domainName: string }) {\n const clientPort = 5185;\n const clientLocalUrl = `${window.location.protocol}//${window.location.hostname}:${clientPort}`\n const clientProdUrl = `https://${domainName}.${serverDomain}`\n const clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;\n return clientBasePath;\n}","import { getServerBasePath } from \"./utils/config\";\n\nexport const getTenantUserAPI = async (domainName: string, ssid: string, token: string): Promise<any> => {\n const params = {\n method: \"GET\",\n headers: {\n Authorization: `${token}`,\n \"Content-Type\": \"application/json\",\n }\n }\n const response = await fetch(`${getServerBasePath({ domainName })}/get-tenant-user/${ssid}`, params)\n const data = await response.json()\n return { response, data }\n}","export const DAUTH_STATE = 'dauth_state';","import { getTenantUserAPI } from '../api/dauth.api';\nimport { DAUTH_STATE } from '../constants';\nimport * as DauthTypes from './dauth.types'\n\nexport async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: { dispatch: any, dauth_state: string, domainName: string, ssid: string }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);\n return localStorage.setItem(DAUTH_STATE, dauth_state);\n } else {\n return localStorage.removeItem(DAUTH_STATE);\n }\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: { dispatch: any, dauth_state_ls: string, domainName: string, ssid: string }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n localStorage.setItem(DAUTH_STATE, dauth_state_ls);\n } else {\n localStorage.removeItem(DAUTH_STATE);\n }\n\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setLogoutAction({ dispatch }: { dispatch: any }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: {},\n domain: {},\n isAuthenticated: false,\n },\n })\n localStorage.removeItem(DAUTH_STATE);\n return dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n}","import * as React from 'react';\nimport { useReducer, useMemo, useEffect, useCallback } from 'react'\nimport initialDauthState from './initialDauthState'\nimport userReducer from './reducer/dauth.reducer'\nimport * as action from \"./reducer/dauth.actions\"\nimport { getClientBasePath } from './api/utils/config'\nimport { DAUTH_STATE } from './constants'\n\n// Delete me\nexport const Thing = () => {\n return <div>the snozzberries taste like snozzberries</div>;\n};\n\ninterface DauthProviderProps {\n domainName: string\n sid: string\n ssid: string\n children: React.ReactNode\n}\n\nexport const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {\n\tconst { domainName, sid, ssid, children } = props\n\tconst [dauthState, dispatch] = useReducer(userReducer, initialDauthState)\n\n\t// Catch login redirect\n\tuseEffect(() => {\n\t\tconst queryString = window.location.search;\n\t\tif (!queryString) return\n\t\tconst urlParams = new URLSearchParams(queryString);\n\t\tconst dauth_state = urlParams.get(DAUTH_STATE);\n\t\tif (dauth_state && !dauthState.isAuthenticated) {\n\t\t\taction.setDauthStateAction({ dispatch, dauth_state, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\t// Auto Login\n\tuseEffect(() => {\n\t\tconst dauth_state_ls = localStorage.getItem(DAUTH_STATE);\n\t\tif (dauth_state_ls && !dauthState.isAuthenticated) {\n\t\t\taction.setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\tconst loginWithRedirect = useCallback(() => {\n\t\treturn window.location.replace(`${getClientBasePath({ domainName })}/t-sign/${sid}`);\n\t}, [domainName, sid])\n\n\tconst logout = useCallback(() => {\n\t\treturn action.setLogoutAction({ dispatch })\n\t}, [])\n\n\tconst memoProvider = useMemo(\n\t\t() => ({\n\t\t\t...dauthState,\n\t\t\tloginWithRedirect,\n\t\t\tlogout\n\t\t}), [\n\t\tdauthState,\n\t\tloginWithRedirect,\n\t\tlogout\n\t])\n\n\n\treturn (\n\t\t<DauthContext.Provider value={memoProvider}>\n\t\t\t{children}\n\t\t</DauthContext.Provider>\n\t)\n}\n\nconst DauthContext = React.createContext(initialDauthState);\n\nexport const useDauthContext = () => {\n const context = React.useContext(DauthContext);\n if (!context) {\n throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');\n }\n return context;\n};"],"names":["userState","_id","ssid","name","lastname","nickname","email","is_verified","language","avatar","createdAt","Date","updatedAt","last_login","domainState","loginRedirect","allowedOrigins","initialDauthState","user","domain","isLoading","isAuthenticated","loginWithRedirect","logout","getAccessToken","LOGIN","SET_IS_LOADING","userReducer","state","action","type","payload","DauthTypes","_extends","isLocalhost","Boolean","window","location","hostname","match","apiVersion","serverDomain","getServerBasePath","_ref","domainName","serverPort","serverLocalUrl","protocol","serverProdUrl","serverBasePath","getClientBasePath","_ref2","clientPort","clientLocalUrl","clientProdUrl","clientBasePath","getTenantUserAPI","_asyncToGenerator","_regeneratorRuntime","mark","_callee","token","params","response","data","wrap","_callee$","_context","prev","next","method","headers","Authorization","fetch","sent","json","abrupt","stop","_x","_x2","_x3","apply","arguments","DAUTH_STATE","setDauthStateAction","_setDauthStateAction","dispatch","dauth_state","getUserFetch","status","history","replaceState","document","title","localStorage","setItem","removeItem","t0","console","log","finish","setAutoLoginAction","_setAutoLoginAction","_callee2","dauth_state_ls","_callee2$","_context2","setLogoutAction","_setLogoutAction","_callee3","_ref3","_callee3$","_context3","Thing","React","DauthProvider","props","sid","children","_useReducer","useReducer","dauthState","useEffect","queryString","search","urlParams","URLSearchParams","get","getItem","useCallback","replace","memoProvider","useMemo","DauthContext","Provider","value","useDauthContext","context","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A;KAAY,CAAC,gBAAWyE,GAAK,CAAC;GACpF,EAAE,CAACzE,UAAU,EAAEyE,GAAG,CAAC,CAAC;EAErB,IAAM9F,MAAM,GAAG0G,WAAW,CAAC;IAC1B,OAAOpG,eAAsB,CAAC;MAAEyD,QAAQ,EAARA;KAAU,CAAC;GAC3C,EAAE,EAAE,CAAC;EAEN,IAAM6C,YAAY,GAAGC,OAAO,CAC3B;IAAA,OAAAnG,QAAA,KACIwF,UAAU;MACbnG,iBAAiB,EAAjBA,iBAAiB;MACjBC,MAAM,EAANA;;GACC,EAAE,CACJkG,UAAU,EACVnG,iBAAiB,EACjBC,MAAM,CACN,CAAC;EAGF,OACC2F,cAACmB,YAAY,CAACC,QAAQ;IAACC,KAAK,EAAEJ;KAC5Bb,QAAQ,CACc;AAE1B,CAAC;AAED,IAAMe,YAAY,gBAAGnB,aAAmB,CAACjG,iBAAiB,CAAC;AAE3D,IAAauH,eAAe,GAAG,SAAlBA,eAAeA;EAC1B,IAAMC,OAAO,GAAGvB,UAAgB,CAACmB,YAAY,CAAC;EAC9C,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,gEAAgE,CAAC;;EAEnF,OAAOD,OAAO;AAChB,CAAC;;;;"}
1
+ {"version":3,"file":"dauth-context-react.esm.js","sources":["../src/initialDauthState.ts","../src/reducer/dauth.types.ts","../src/reducer/dauth.reducer.ts","../src/api/utils/config.ts","../src/api/dauth.api.ts","../src/constants.ts","../src/reducer/dauth.actions.ts","../src/index.tsx"],"sourcesContent":["export interface IDauthUser {\n\t_id: string\n\tssid: string\n\tname: string\n\tlastname: string\n\tnickname: string\n\temail: string\n\tis_verified: boolean\n\tlanguage: string\n\tavatar: string\n\tcreatedAt: Date\n\tupdatedAt: Date\n\tlast_login: Date\n}\n\nexport interface IDauthDomain {\n\tname: string\n\tloginRedirect: string\n\tallowedOrigins: string[]\n}\n\nexport interface IDauthState {\n\tuser: IDauthUser\n\tdomain: IDauthDomain\n\tisLoading: boolean\n\tisAuthenticated: boolean\n\tloginWithRedirect: () => void\n\tlogout: () => void\n\tgetAccessToken: () => void\n}\n\nconst initialDauthState: IDauthState = {\n\tuser: {} as IDauthUser,\n\tdomain: {} as IDauthDomain,\n\tisLoading: true,\n\tisAuthenticated: false,\n\tloginWithRedirect: () => { },\n\tlogout: () => { },\n\tgetAccessToken: () => { },\n}\n\nexport default initialDauthState","export const LOGIN = 'LOGIN';\nexport const SET_IS_LOADING = 'SET_IS_LOADING';","import * as DauthTypes from './dauth.types'\n\nexport default function userReducer(state: any, action: any) {\n\tconst { type, payload } = action;\n\n\tswitch (type) {\n\t\tcase DauthTypes.LOGIN:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tuser: payload.user,\n\t\t\t\tdomain: payload.domain,\n\t\t\t\tisAuthenticated: payload.isAuthenticated,\n\t\t\t}\n\n\t\tcase DauthTypes.SET_IS_LOADING:\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisLoading: payload.isLoading,\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn state\n\t}\n}","const isLocalhost = Boolean(\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"[::1]\" ||\n window.location.hostname.match(\n /(192)\\.(168)\\.(1)\\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm\n ) ||\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\nexport const apiVersion = \"v1\";\nexport const serverDomain = \"dauth.ovh\";\n\nexport function getServerBasePath({ domainName }: { domainName: string }) {\n const serverPort = 4012;\n const serverLocalUrl = `${window.location.protocol}//${window.location.hostname}:${serverPort}/api/${apiVersion}`\n const serverProdUrl = `https://${domainName}.${serverDomain}/api/${apiVersion}`\n const serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;\n return serverBasePath;\n}\n\nexport function getClientBasePath({ domainName }: { domainName: string }) {\n const clientPort = 5185;\n const clientLocalUrl = `${window.location.protocol}//${window.location.hostname}:${clientPort}`\n const clientProdUrl = `https://${domainName}.${serverDomain}`\n const clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;\n return clientBasePath;\n}","import { getServerBasePath } from \"./utils/config\";\n\nexport const getTenantUserAPI = async (domainName: string, ssid: string, token: string): Promise<any> => {\n const params = {\n method: \"GET\",\n headers: {\n Authorization: `${token}`,\n \"Content-Type\": \"application/json\",\n }\n }\n const response = await fetch(`${getServerBasePath({ domainName })}/get-tenant-user/${ssid}`, params)\n const data = await response.json()\n return { response, data }\n}","export const DAUTH_STATE = 'dauth_state';","import { getTenantUserAPI } from '../api/dauth.api';\nimport { DAUTH_STATE } from '../constants';\nimport * as DauthTypes from './dauth.types'\n\ntype TSetDauthStateAction = {\n dispatch: any\n dauth_state: string\n domainName: string\n ssid: string\n}\nexport async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: TSetDauthStateAction) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);\n return localStorage.setItem(DAUTH_STATE, dauth_state);\n } else {\n return localStorage.removeItem(DAUTH_STATE);\n }\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\ntype TSetAutoLoginAction = {\n dispatch: any\n dauth_state_ls: string\n domainName: string\n ssid: string\n}\nexport async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: TSetAutoLoginAction) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n try {\n const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);\n if (getUserFetch.response.status === 200) {\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: getUserFetch.data.user,\n domain: getUserFetch.data.domain,\n isAuthenticated: true,\n },\n })\n localStorage.setItem(DAUTH_STATE, dauth_state_ls);\n } else {\n localStorage.removeItem(DAUTH_STATE);\n }\n\n } catch (error) {\n localStorage.removeItem(DAUTH_STATE);\n console.log(error);\n } finally {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n }\n}\n\nexport async function setLogoutAction({ dispatch }: { dispatch: any }) {\n dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })\n dispatch({\n type: DauthTypes.LOGIN,\n payload: {\n user: {},\n domain: {},\n isAuthenticated: false,\n },\n })\n localStorage.removeItem(DAUTH_STATE);\n return dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: false } })\n}","import React, { useReducer, useMemo, useEffect, useCallback, createContext, useContext } from 'react'\nimport initialDauthState, { IDauthState } from './initialDauthState'\nimport userReducer from './reducer/dauth.reducer'\nimport * as action from \"./reducer/dauth.actions\"\nimport { getClientBasePath } from './api/utils/config'\nimport { DAUTH_STATE } from './constants'\n\ninterface DauthProviderProps {\n domainName: string\n sid: string\n ssid: string\n children: React.ReactNode\n}\n\nexport const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {\n\tconst { domainName, sid, ssid, children } = props\n\tconst [ds, dispatch] = useReducer(userReducer, initialDauthState)\n const dauthState = ds as IDauthState\n\n\t// Catch login redirect\n\tuseEffect(() => {\n\t\tconst queryString = window.location.search;\n\t\tif (!queryString) return\n\t\tconst urlParams = new URLSearchParams(queryString);\n\t\tconst dauth_state = urlParams.get(DAUTH_STATE);\n\t\tif (dauth_state && !dauthState.isAuthenticated) {\n\t\t\taction.setDauthStateAction({ dispatch, dauth_state, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\t// Auto Login\n\tuseEffect(() => {\n\t\tconst dauth_state_ls = localStorage.getItem(DAUTH_STATE);\n\t\tif (dauth_state_ls && !dauthState.isAuthenticated) {\n\t\t\taction.setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid })\n\t\t}\n\t}, [dauthState.isAuthenticated, domainName, ssid])\n\n\tconst loginWithRedirect = useCallback(() => {\n\t\treturn window.location.replace(`${getClientBasePath({ domainName })}/t-sign/${sid}`);\n\t}, [domainName, sid])\n\n\tconst logout = useCallback(() => {\n\t\treturn action.setLogoutAction({ dispatch })\n\t}, [])\n\n\tconst memoProvider = useMemo(\n\t\t() => ({\n\t\t\t...dauthState,\n\t\t\tloginWithRedirect,\n\t\t\tlogout\n\t\t}), [\n\t\tdauthState,\n\t\tloginWithRedirect,\n\t\tlogout\n\t])\n\n\n\treturn (\n\t\t<DauthContext.Provider value={memoProvider}>\n\t\t\t{children}\n\t\t</DauthContext.Provider>\n\t)\n}\n\nconst DauthContext = createContext(initialDauthState);\n\nexport const useDauth = () => {\n const context = useContext(DauthContext);\n if (!context) {\n throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');\n }\n return context;\n};"],"names":["initialDauthState","user","domain","isLoading","isAuthenticated","loginWithRedirect","logout","getAccessToken","LOGIN","SET_IS_LOADING","userReducer","state","action","type","payload","DauthTypes","_extends","isLocalhost","Boolean","window","location","hostname","match","apiVersion","serverDomain","getServerBasePath","_ref","domainName","serverPort","serverLocalUrl","protocol","serverProdUrl","serverBasePath","getClientBasePath","_ref2","clientPort","clientLocalUrl","clientProdUrl","clientBasePath","getTenantUserAPI","_asyncToGenerator","_regeneratorRuntime","mark","_callee","ssid","token","params","response","data","wrap","_callee$","_context","prev","next","method","headers","Authorization","fetch","sent","json","abrupt","stop","_x","_x2","_x3","apply","arguments","DAUTH_STATE","setDauthStateAction","_setDauthStateAction","dispatch","dauth_state","getUserFetch","status","history","replaceState","document","title","loginRedirect","localStorage","setItem","removeItem","t0","console","log","finish","setAutoLoginAction","_setAutoLoginAction","_callee2","dauth_state_ls","_callee2$","_context2","setLogoutAction","_setLogoutAction","_callee3","_ref3","_callee3$","_context3","DauthProvider","props","sid","children","_useReducer","useReducer","ds","dauthState","useEffect","queryString","search","urlParams","URLSearchParams","get","getItem","useCallback","replace","memoProvider","useMemo","React","DauthContext","Provider","value","createContext","useDauth","context","useContext","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAMA,iBAAiB,GAAgB;EACtCC,IAAI,EAAE,EAAgB;EACtBC,MAAM,EAAE,EAAkB;EAC1BC,SAAS,EAAE,IAAI;EACfC,eAAe,EAAE,KAAK;EACtBC,iBAAiB,EAAE,SAAAA,sBAAS;EAC5BC,MAAM,EAAE,SAAAA,WAAS;EACjBC,cAAc,EAAE,SAAAA;CAChB;;ACvCM,IAAMC,KAAK,GAAG,OAAO;AAC5B,AAAO,IAAMC,cAAc,GAAG,gBAAgB;;SCCtBC,WAAWA,CAACC,KAAU,EAAEC,MAAW;EAC1D,IAAQC,IAAI,GAAcD,MAAM,CAAxBC,IAAI;IAAEC,OAAO,GAAKF,MAAM,CAAlBE,OAAO;EAErB,QAAQD,IAAI;IACX,KAAKE,KAAgB;MACpB,OAAAC,QAAA,KACIL,KAAK;QACRV,IAAI,EAAEa,OAAO,CAACb,IAAI;QAClBC,MAAM,EAAEY,OAAO,CAACZ,MAAM;Q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Y,GAAGC,OAAO,CAC3B;IAAA,OAAApG,QAAA,KACIyF,UAAU;MACbpG,iBAAiB,EAAjBA,iBAAiB;MACjBC,MAAM,EAANA;;GACC,EAAE,CACJmG,UAAU,EACVpG,iBAAiB,EACjBC,MAAM,CACN,CAAC;EAGF,OACC+G,oBAACC,YAAY,CAACC,QAAQ;IAACC,KAAK,EAAEL;KAC5Bd,QAAQ,CACc;AAE1B,CAAC;AAED,IAAMiB,YAAY,gBAAGG,aAAa,CAACzH,iBAAiB,CAAC;AAErD,IAAa0H,QAAQ,GAAG,SAAXA,QAAQA;EACnB,IAAMC,OAAO,GAAGC,UAAU,CAACN,YAAY,CAAC;EACxC,IAAI,CAACK,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,gEAAgE,CAAC;;EAEnF,OAAOF,OAAO;AAChB,CAAC;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- export declare const Thing: () => React.JSX.Element;
1
+ import React from 'react';
2
+ import { IDauthState } from './initialDauthState';
3
3
  interface DauthProviderProps {
4
4
  domainName: string;
5
5
  sid: string;
@@ -7,30 +7,5 @@ interface DauthProviderProps {
7
7
  children: React.ReactNode;
8
8
  }
9
9
  export declare const DauthProvider: React.FC<DauthProviderProps>;
10
- export declare const useDauthContext: () => {
11
- user: {
12
- _id: string;
13
- ssid: string;
14
- name: string;
15
- lastname: string;
16
- nickname: string;
17
- email: string;
18
- is_verified: boolean;
19
- language: string;
20
- avatar: string;
21
- createdAt: Date;
22
- updatedAt: Date;
23
- last_login: Date;
24
- };
25
- domain: {
26
- name: string;
27
- loginRedirect: string;
28
- allowedOrigins: string[];
29
- };
30
- isLoading: boolean;
31
- isAuthenticated: boolean;
32
- loginWithRedirect: () => void;
33
- logout: () => void;
34
- getAccessToken: () => void;
35
- };
10
+ export declare const useDauth: () => IDauthState;
36
11
  export {};
@@ -1,27 +1,30 @@
1
- declare const initialDauthState: {
2
- user: {
3
- _id: string;
4
- ssid: string;
5
- name: string;
6
- lastname: string;
7
- nickname: string;
8
- email: string;
9
- is_verified: boolean;
10
- language: string;
11
- avatar: string;
12
- createdAt: Date;
13
- updatedAt: Date;
14
- last_login: Date;
15
- };
16
- domain: {
17
- name: string;
18
- loginRedirect: string;
19
- allowedOrigins: string[];
20
- };
1
+ export interface IDauthUser {
2
+ _id: string;
3
+ ssid: string;
4
+ name: string;
5
+ lastname: string;
6
+ nickname: string;
7
+ email: string;
8
+ is_verified: boolean;
9
+ language: string;
10
+ avatar: string;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ last_login: Date;
14
+ }
15
+ export interface IDauthDomain {
16
+ name: string;
17
+ loginRedirect: string;
18
+ allowedOrigins: string[];
19
+ }
20
+ export interface IDauthState {
21
+ user: IDauthUser;
22
+ domain: IDauthDomain;
21
23
  isLoading: boolean;
22
24
  isAuthenticated: boolean;
23
25
  loginWithRedirect: () => void;
24
26
  logout: () => void;
25
27
  getAccessToken: () => void;
26
- };
28
+ }
29
+ declare const initialDauthState: IDauthState;
27
30
  export default initialDauthState;
@@ -1,15 +1,18 @@
1
- export declare function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: {
1
+ declare type TSetDauthStateAction = {
2
2
  dispatch: any;
3
3
  dauth_state: string;
4
4
  domainName: string;
5
5
  ssid: string;
6
- }): Promise<void>;
7
- export declare function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: {
6
+ };
7
+ export declare function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: TSetDauthStateAction): Promise<void>;
8
+ declare type TSetAutoLoginAction = {
8
9
  dispatch: any;
9
10
  dauth_state_ls: string;
10
11
  domainName: string;
11
12
  ssid: string;
12
- }): Promise<void>;
13
+ };
14
+ export declare function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: TSetAutoLoginAction): Promise<void>;
13
15
  export declare function setLogoutAction({ dispatch }: {
14
16
  dispatch: any;
15
17
  }): Promise<any>;
18
+ export {};
package/package.json CHANGED
@@ -1 +1,61 @@
1
- {"version":"0.1.1","license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","files":["dist","src"],"engines":{"node":">=10"},"scripts":{"start":"tsdx watch","build":"tsdx build","test":"tsdx test --passWithNoTests","lint":"tsdx lint","prepare":"tsdx build","size":"size-limit","analyze":"size-limit --why"},"peerDependencies":{"react":">=16"},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"prettier":{"printWidth":80,"semi":true,"singleQuote":true,"trailingComma":"es5"},"name":"dauth-context-react","author":"David T. Pizarro Frick","module":"dist/dauth-context-react.esm.js","size-limit":[{"path":"dist/dauth-context-react.cjs.production.min.js","limit":"10 KB"},{"path":"dist/dauth-context-react.esm.js","limit":"10 KB"}],"devDependencies":{"@size-limit/preset-small-lib":"^11.0.2","@types/react":"^18.2.55","@types/react-dom":"^18.2.19","husky":"^9.0.10","react":"^18.2.0","react-dom":"^18.2.0","size-limit":"^11.0.2","tsdx":"^0.14.1","tslib":"^2.6.2","typescript":"^3.9.10"}}
1
+ {
2
+ "version": "0.1.3",
3
+ "license": "MIT",
4
+ "main": "dist/index.js",
5
+ "typings": "dist/index.d.ts",
6
+ "files": [
7
+ "dist",
8
+ "src"
9
+ ],
10
+ "engines": {
11
+ "node": ">=10"
12
+ },
13
+ "scripts": {
14
+ "start": "tsdx watch",
15
+ "build": "tsdx build",
16
+ "test": "tsdx test --passWithNoTests",
17
+ "lint": "tsdx lint",
18
+ "prepare": "tsdx build",
19
+ "size": "size-limit",
20
+ "analyze": "size-limit --why"
21
+ },
22
+ "peerDependencies": {
23
+ "react": ">=16"
24
+ },
25
+ "husky": {
26
+ "hooks": {
27
+ "pre-commit": "tsdx lint"
28
+ }
29
+ },
30
+ "prettier": {
31
+ "printWidth": 80,
32
+ "semi": true,
33
+ "singleQuote": true,
34
+ "trailingComma": "es5"
35
+ },
36
+ "name": "dauth-context-react",
37
+ "author": "David T. Pizarro Frick",
38
+ "module": "dist/dauth-context-react.esm.js",
39
+ "size-limit": [
40
+ {
41
+ "path": "dist/dauth-context-react.cjs.production.min.js",
42
+ "limit": "10 KB"
43
+ },
44
+ {
45
+ "path": "dist/dauth-context-react.esm.js",
46
+ "limit": "10 KB"
47
+ }
48
+ ],
49
+ "devDependencies": {
50
+ "@size-limit/preset-small-lib": "^11.0.2",
51
+ "@types/react": "^18.2.55",
52
+ "@types/react-dom": "^18.2.19",
53
+ "husky": "^9.0.10",
54
+ "react": "^18.2.0",
55
+ "react-dom": "^18.2.0",
56
+ "size-limit": "^11.0.2",
57
+ "tsdx": "^0.14.1",
58
+ "tslib": "^2.6.2",
59
+ "typescript": "^3.9.10"
60
+ }
61
+ }
package/src/index.tsx CHANGED
@@ -1,16 +1,10 @@
1
- import * as React from 'react';
2
- import { useReducer, useMemo, useEffect, useCallback } from 'react'
3
- import initialDauthState from './initialDauthState'
1
+ import React, { useReducer, useMemo, useEffect, useCallback, createContext, useContext } from 'react'
2
+ import initialDauthState, { IDauthState } from './initialDauthState'
4
3
  import userReducer from './reducer/dauth.reducer'
5
4
  import * as action from "./reducer/dauth.actions"
6
5
  import { getClientBasePath } from './api/utils/config'
7
6
  import { DAUTH_STATE } from './constants'
8
7
 
9
- // Delete me
10
- export const Thing = () => {
11
- return <div>the snozzberries taste like snozzberries</div>;
12
- };
13
-
14
8
  interface DauthProviderProps {
15
9
  domainName: string
16
10
  sid: string
@@ -20,7 +14,8 @@ interface DauthProviderProps {
20
14
 
21
15
  export const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProviderProps) => {
22
16
  const { domainName, sid, ssid, children } = props
23
- const [dauthState, dispatch] = useReducer(userReducer, initialDauthState)
17
+ const [ds, dispatch] = useReducer(userReducer, initialDauthState)
18
+ const dauthState = ds as IDauthState
24
19
 
25
20
  // Catch login redirect
26
21
  useEffect(() => {
@@ -68,10 +63,10 @@ export const DauthProvider: React.FC<DauthProviderProps> = (props: DauthProvider
68
63
  )
69
64
  }
70
65
 
71
- const DauthContext = React.createContext(initialDauthState);
66
+ const DauthContext = createContext(initialDauthState);
72
67
 
73
- export const useDauthContext = () => {
74
- const context = React.useContext(DauthContext);
68
+ export const useDauth = () => {
69
+ const context = useContext(DauthContext);
75
70
  if (!context) {
76
71
  throw new Error('useMyContext debe ser utilizado dentro de un MyContextProvider');
77
72
  }
@@ -1,58 +1,37 @@
1
- // export interface IDauthUser {
2
- // _id: string
3
- // ssid: string
4
- // name: string
5
- // lastname: string
6
- // nickname: string
7
- // email: string
8
- // is_verified: boolean
9
- // language: string
10
- // avatar: string
11
- // createdAt: Date
12
- // updatedAt: Date
13
- // last_login: Date
14
- // }
15
-
16
- // export interface IDauthDomain {
17
- // name: string
18
- // loginRedirect: string
19
- // allowedOrigins: string[]
20
- // }
21
-
22
- // export interface IDauthState {
23
- // user: IDauthUser
24
- // domain: IDauthDomain
25
- // isLoading: boolean
26
- // isAuthenticated: boolean
27
- // loginWithRedirect: () => void
28
- // logout: () => void
29
- // getAccessToken: () => void
30
- // }
1
+ export interface IDauthUser {
2
+ _id: string
3
+ ssid: string
4
+ name: string
5
+ lastname: string
6
+ nickname: string
7
+ email: string
8
+ is_verified: boolean
9
+ language: string
10
+ avatar: string
11
+ createdAt: Date
12
+ updatedAt: Date
13
+ last_login: Date
14
+ }
31
15
 
32
- const userState = {
33
- _id: "",
34
- ssid: "",
35
- name: "",
36
- lastname: "",
37
- nickname: "",
38
- email: "",
39
- is_verified: false,
40
- language: "",
41
- avatar: "",
42
- createdAt: new Date(),
43
- updatedAt: new Date(),
44
- last_login: new Date(),
16
+ export interface IDauthDomain {
17
+ name: string
18
+ loginRedirect: string
19
+ allowedOrigins: string[]
45
20
  }
46
21
 
47
- const domainState = {
48
- name: "",
49
- loginRedirect: "",
50
- allowedOrigins: [""],
22
+ export interface IDauthState {
23
+ user: IDauthUser
24
+ domain: IDauthDomain
25
+ isLoading: boolean
26
+ isAuthenticated: boolean
27
+ loginWithRedirect: () => void
28
+ logout: () => void
29
+ getAccessToken: () => void
51
30
  }
52
31
 
53
- const initialDauthState = {
54
- user: userState,
55
- domain: domainState,
32
+ const initialDauthState: IDauthState = {
33
+ user: {} as IDauthUser,
34
+ domain: {} as IDauthDomain,
56
35
  isLoading: true,
57
36
  isAuthenticated: false,
58
37
  loginWithRedirect: () => { },
@@ -2,7 +2,13 @@ import { getTenantUserAPI } from '../api/dauth.api';
2
2
  import { DAUTH_STATE } from '../constants';
3
3
  import * as DauthTypes from './dauth.types'
4
4
 
5
- export async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: { dispatch: any, dauth_state: string, domainName: string, ssid: string }) {
5
+ type TSetDauthStateAction = {
6
+ dispatch: any
7
+ dauth_state: string
8
+ domainName: string
9
+ ssid: string
10
+ }
11
+ export async function setDauthStateAction({ dispatch, dauth_state, domainName, ssid }: TSetDauthStateAction) {
6
12
  dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })
7
13
  try {
8
14
  const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state);
@@ -28,7 +34,13 @@ export async function setDauthStateAction({ dispatch, dauth_state, domainName, s
28
34
  }
29
35
  }
30
36
 
31
- export async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: { dispatch: any, dauth_state_ls: string, domainName: string, ssid: string }) {
37
+ type TSetAutoLoginAction = {
38
+ dispatch: any
39
+ dauth_state_ls: string
40
+ domainName: string
41
+ ssid: string
42
+ }
43
+ export async function setAutoLoginAction({ dispatch, dauth_state_ls, domainName, ssid }: TSetAutoLoginAction) {
32
44
  dispatch({ type: DauthTypes.SET_IS_LOADING, payload: { isLoading: true } })
33
45
  try {
34
46
  const getUserFetch = await getTenantUserAPI(domainName, ssid, dauth_state_ls);