@abcagency/hc-ui-components 1.3.95 → 1.3.96

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.
@@ -1,6 +1,6 @@
1
1
  import { getClientAuthKey } from '../clientToken.js';
2
2
 
3
- const baseURL = "http://localhost:5108";
3
+ const baseURL = "https://api.myhirecontrol.com";
4
4
  const memoryStorage = {
5
5
  authToken: null,
6
6
  tokenExpiration: null
@@ -1 +1 @@
1
- {"version":3,"file":"hcApi.js","sources":["../../src/apis/hcApi.ts"],"sourcesContent":["import { getClientAuthKey } from '~/clientToken';\nconst baseURL = process.env.HC_API_BASE_URL as string;\n\ninterface MemoryStorage {\n\tauthToken: string | null;\n\ttokenExpiration: string | null;\n}\n\nconst memoryStorage: MemoryStorage = {\n\tauthToken: null,\n\ttokenExpiration: null\n};\n\nfunction setStorage(key: keyof MemoryStorage, value: string): void {\n\ttry {\n\t\tsessionStorage.setItem(key, value);\n\t} catch (error) {\n\t\tmemoryStorage[key] = value;\n\t}\n}\n\nfunction getStorage(key: keyof MemoryStorage): string | null {\n\ttry {\n\t\treturn sessionStorage.getItem(key) || memoryStorage[key];\n\t} catch (error) {\n\t\treturn memoryStorage[key];\n\t}\n}\n\ninterface AuthResponse {\n\ttoken: string;\n\texpiration: string;\n}\n\nconst login = async (): Promise<AuthResponse> => {\n\tconst clientAuthKey = getClientAuthKey();\n\n\ttry {\n\t\tconst response = await fetch(`${baseURL}/auth/login`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tclientAuthKey: clientAuthKey\n\t\t\t})\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error('Login failed');\n\t\t}\n\n\t\tconst data = await response.json();\n\n\t\tif (data.token && data.expiration) {\n\t\t\tsetStorage('authToken', data.token);\n\t\t\tsetStorage('tokenExpiration', data.expiration);\n\t\t\treturn { token: data.token, expiration: data.expiration };\n\t\t} else {\n\t\t\tthrow new Error('Invalid login response');\n\t\t}\n\t} catch (error) {\n\t\tconsole.error('Login failed:', error);\n\t\tthrow error;\n\t}\n};\n\nconst fetchWithAuth = async (url: string, options: RequestInit = {}): Promise<Response> => {\n\tlet token = getStorage('authToken');\n\n\tconst expirationDateTime = getStorage('tokenExpiration');\n\tconst currentTime = new Date();\n\n\tif (!token || !expirationDateTime || new Date(expirationDateTime) <= currentTime) {\n\t\tconst authResponse = await login();\n\t\ttoken = authResponse.token;\n\t}\n\n\tconst headers = new Headers(options.headers || {});\n\theaders.append('Authorization', `Bearer ${token}`);\n\n\tconst finalOptions = {\n\t\t...options,\n\t\theaders\n\t};\n\n\tconst response = await fetch(`${baseURL}${url}`, finalOptions);\n\n\tif (!response.ok) throw new Error('Network response was not ok.');\n\n\treturn response;\n};\n\nexport default {\n\tget: async <T>(url: string): Promise<T> => {\n\t\tconst response = await fetchWithAuth(url);\n\t\treturn await response.json() as T;\n\t},\n\tpost: async <T>(url: string, data: any): Promise<T> => {\n\t\tconst response = await fetchWithAuth(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify(data)\n\t\t});\n\t\treturn await response.json() as T;\n\t}\n};\n"],"names":[],"mappings":";;AACA,MAAM,OAAO,GAAG,uBAAqC,CAAC;AAOtD,MAAM,aAAa,GAAkB;AACpC,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,eAAe,EAAE,IAAI;CACrB,CAAC;AAEF,SAAS,UAAU,CAAC,GAAwB,EAAE,KAAa,EAAA;IAC1D,IAAI;AACH,QAAA,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACnC,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACf,QAAA,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC3B,KAAA;AACF,CAAC;AAED,SAAS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C,CAAC;AAC1C,QAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAO,CAAC;KAClC;AACD,IAAA,IAAI,EAAE,OAAU,GAAW,EAAE,IAAS,KAAgB;AACrD,QAAA,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE;AACzC,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,OAAO,EAAE;AACR,gBAAA,cAAc,EAAE,kBAAkB;AAClC,aAAA;AACD,YAAA,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAC1B,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAO,CAAC;KAClC;CACD;;;;"}
1
+ {"version":3,"file":"hcApi.js","sources":["../../src/apis/hcApi.ts"],"sourcesContent":["import { getClientAuthKey } from '~/clientToken';\nconst baseURL = process.env.HC_API_BASE_URL as string;\n\ninterface MemoryStorage {\n\tauthToken: string | null;\n\ttokenExpiration: string | null;\n}\n\nconst memoryStorage: MemoryStorage = {\n\tauthToken: null,\n\ttokenExpiration: null\n};\n\nfunction setStorage(key: keyof MemoryStorage, value: string): void {\n\ttry {\n\t\tsessionStorage.setItem(key, value);\n\t} catch (error) {\n\t\tmemoryStorage[key] = value;\n\t}\n}\n\nfunction getStorage(key: keyof MemoryStorage): string | null {\n\ttry {\n\t\treturn sessionStorage.getItem(key) || memoryStorage[key];\n\t} catch (error) {\n\t\treturn memoryStorage[key];\n\t}\n}\n\ninterface AuthResponse {\n\ttoken: string;\n\texpiration: string;\n}\n\nconst login = async (): Promise<AuthResponse> => {\n\tconst clientAuthKey = getClientAuthKey();\n\n\ttry {\n\t\tconst response = await fetch(`${baseURL}/auth/login`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tclientAuthKey: clientAuthKey\n\t\t\t})\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error('Login failed');\n\t\t}\n\n\t\tconst data = await response.json();\n\n\t\tif (data.token && data.expiration) {\n\t\t\tsetStorage('authToken', data.token);\n\t\t\tsetStorage('tokenExpiration', data.expiration);\n\t\t\treturn { token: data.token, expiration: data.expiration };\n\t\t} else {\n\t\t\tthrow new Error('Invalid login response');\n\t\t}\n\t} catch (error) {\n\t\tconsole.error('Login failed:', error);\n\t\tthrow error;\n\t}\n};\n\nconst fetchWithAuth = async (url: string, options: RequestInit = {}): Promise<Response> => {\n\tlet token = getStorage('authToken');\n\n\tconst expirationDateTime = getStorage('tokenExpiration');\n\tconst currentTime = new Date();\n\n\tif (!token || !expirationDateTime || new Date(expirationDateTime) <= currentTime) {\n\t\tconst authResponse = await login();\n\t\ttoken = authResponse.token;\n\t}\n\n\tconst headers = new Headers(options.headers || {});\n\theaders.append('Authorization', `Bearer ${token}`);\n\n\tconst finalOptions = {\n\t\t...options,\n\t\theaders\n\t};\n\n\tconst response = await fetch(`${baseURL}${url}`, finalOptions);\n\n\tif (!response.ok) throw new Error('Network response was not ok.');\n\n\treturn response;\n};\n\nexport default {\n\tget: async <T>(url: string): Promise<T> => {\n\t\tconst response = await fetchWithAuth(url);\n\t\treturn await response.json() as T;\n\t},\n\tpost: async <T>(url: string, data: any): Promise<T> => {\n\t\tconst response = await fetchWithAuth(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json'\n\t\t\t},\n\t\t\tbody: JSON.stringify(data)\n\t\t});\n\t\treturn await response.json() as T;\n\t}\n};\n"],"names":[],"mappings":";;AACA,MAAM,OAAO,GAAG,+BAAqC,CAAC;AAOtD,MAAM,aAAa,GAAkB;AACpC,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,eAAe,EAAE,IAAI;CACrB,CAAC;AAEF,SAAS,UAAU,CAAC,GAAwB,EAAE,KAAa,EAAA;IAC1D,IAAI;AACH,QAAA,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,K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,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,UAAe;AACd,IAAA,GAAG,EAAE,OAAU,GAAW,KAAgB;AACzC,QAAA,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;AAC1C,QAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAO,CAAC;KAClC;AACD,IAAA,IAAI,EAAE,OAAU,GAAW,EAAE,IAAS,KAAgB;AACrD,QAAA,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE;AACzC,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,OAAO,EAAE;AACR,gBAAA,cAAc,EAAE,kBAAkB;AAClC,aAAA;AACD,YAAA,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAC1B,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAO,CAAC;KAClC;CACD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcagency/hc-ui-components",
3
- "version": "1.3.95",
3
+ "version": "1.3.96",
4
4
  "description": "UI Components for HireControl",
5
5
  "main": "dist/index.js",
6
6
  "files": [