@soramux/node-auth-sdk 0.8.0
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.
- package/README.md +105 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/react.js +6 -0
- package/dist/cjs/react.js.map +1 -0
- package/dist/cjs/server.js +3 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/esm/fields-types-BawiMTEP.d.mts +48 -0
- package/dist/esm/index.d.mts +13 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interceptor-CbsDF_WC.d.mts +117 -0
- package/dist/esm/react.d.mts +201 -0
- package/dist/esm/react.js +6 -0
- package/dist/esm/react.js.map +1 -0
- package/dist/esm/server.d.mts +14 -0
- package/dist/esm/server.js +3 -0
- package/dist/esm/server.js.map +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# NodeAuth
|
|
2
|
+
|
|
3
|
+
SDK for integrating with the TrieOH authentication ecosystem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @trieoh/node-auth-sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @trieoh/node-auth-sdk
|
|
11
|
+
# or
|
|
12
|
+
bun add @trieoh/node-auth-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Configuration (Vite / React)
|
|
16
|
+
|
|
17
|
+
To use the SDK in a React project (Vite, Next.js, or CRA), wrap your application with `AuthProvider`.
|
|
18
|
+
|
|
19
|
+
### Option 1: Environment Variables (Recommended)
|
|
20
|
+
|
|
21
|
+
The SDK automatically looks for these variables:
|
|
22
|
+
|
|
23
|
+
- `VITE_TRIEOH_AUTH_PROJECT_ID` (Vite)
|
|
24
|
+
- `NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID` (Next.js)
|
|
25
|
+
- `PUBLIC_TRIEOH_AUTH_PROJECT_ID` (General)
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { AuthProvider } from '@trieoh/node-auth-sdk/react';
|
|
29
|
+
|
|
30
|
+
function App() {
|
|
31
|
+
return (
|
|
32
|
+
<AuthProvider>
|
|
33
|
+
<YourRoutes />
|
|
34
|
+
</AuthProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Option 2: Passing via Props
|
|
40
|
+
|
|
41
|
+
Useful if you load the project ID dynamically or want to avoid environment issues.
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<AuthProvider projectId="your-project-id-here">
|
|
45
|
+
<YourApp />
|
|
46
|
+
</AuthProvider>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Option 3: Global Configuration via Code
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { configure } from '@trieoh/node-auth-sdk';
|
|
53
|
+
|
|
54
|
+
configure({
|
|
55
|
+
PROJECT_ID: 'your-id',
|
|
56
|
+
BASE_URL: 'https://your-api.com'
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Components
|
|
61
|
+
|
|
62
|
+
The SDK provides ready-to-use components:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { SignIn, SignUp } from '@trieoh/node-auth-sdk/react';
|
|
66
|
+
|
|
67
|
+
// Example usage
|
|
68
|
+
const LoginPage = () => <SignIn />;
|
|
69
|
+
const RegisterPage = () => <SignUp />;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Hooks
|
|
73
|
+
|
|
74
|
+
You can access the authentication state anywhere in your application:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { useAuth } from '@trieoh/node-auth-sdk/react';
|
|
78
|
+
|
|
79
|
+
function Header() {
|
|
80
|
+
const { isAuthenticated, auth } = useAuth();
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<nav>
|
|
84
|
+
{isAuthenticated ? (
|
|
85
|
+
<button onClick={() => auth.logout()}>Logout</button>
|
|
86
|
+
) : (
|
|
87
|
+
<span>Not logged in</span>
|
|
88
|
+
)}
|
|
89
|
+
</nav>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Server-Side
|
|
95
|
+
|
|
96
|
+
For server-side operations (Node.js / Next.js API routes), use `createServerAuth`:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { createServerAuth } from '@trieoh/node-auth-sdk/server';
|
|
100
|
+
|
|
101
|
+
const auth = createServerAuth();
|
|
102
|
+
// auth.assignRoleByNameToUser(...)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function c(s,e){if(e.startsWith("http"))return e;let t=s.replace(/\/$/,""),r=e.replace(/^\//,"");return `${t}/${r}`}var d="trieoh_access_expiry",m="trieoh_refresh_expiry";function g(s){localStorage.setItem(m,String(s.refresh_expire_date)),localStorage.setItem(d,String(s.access.exp)),console.log("[TRIEOH SDK] Token claims saved");}function E(s=30){try{let e=localStorage.getItem(d);if(!e)return !0;let t=parseInt(e,10),r=Math.floor(Date.now()/1e3);return t-r<=s}catch(e){return console.warn("[TRIEOH SDK] Error reading access expiry date:",e),true}}function w(){try{let s=localStorage.getItem(m);if(!s)return !0;let e=parseInt(s,10),t=Math.floor(Date.now()/1e3);return e<=t}catch(s){return console.warn("[TRIEOH SDK] Error reading refresh expiry date:",s),true}}function a(){localStorage.removeItem(d),localStorage.removeItem(m),console.log("[TRIEOH SDK] Auth tokens and claims cleared");}function I(){let s=typeof window>"u",e=typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) })<"u"&&undefined?undefined:{},t=typeof process<"u"?process.env:{},r=e.VITE_TRIEOH_AUTH_PROJECT_ID||t.NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID||t.PUBLIC_TRIEOH_AUTH_PROJECT_ID||"",n=s&&t.TRIEOH_AUTH_API_KEY||"";return {PROJECT_ID:r,API_KEY:n,BASE_URL:"https://api.default.com"}}var u=null,R={};function k(s){R={...R,...s},u=null;}function f(){return u||(u={...I(),...R}),u}var h={get BASE_URL(){return f().BASE_URL}};var o=class{constructor(e){this.isRefreshing=false;this.refreshPromise=null;this.authBaseURL=e?.authBaseURL||h.BASE_URL,this.baseURL=e?.baseURL||this.authBaseURL,this.onTokenRefreshed=e?.onTokenRefreshed,this.onRefreshFailed=e?.onRefreshFailed;}async fetchClaimsAndSave(){let t=await(await fetch(c(this.authBaseURL,"/sessions/me"),{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(t.code!==200||!t.data)throw a(),new Error(t.message||"Failed to fetch session claims after refresh");let r=t.data;return g(r),r}async refreshToken(){return this.isRefreshing&&this.refreshPromise?this.refreshPromise:(this.isRefreshing=true,this.refreshPromise=(async()=>{let e;try{let r=await(await fetch(c(this.authBaseURL,"/auth/refresh"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(r.code!==200)throw r.code!==503&&a(),new Error(r.message||"Failed to refresh token");e=await this.fetchClaimsAndSave(),this.onTokenRefreshed?.(e),console.log("[TRIEOH SDK] Token refreshed successfully");}catch(t){throw console.warn("[TRIEOH SDK] Failed to refresh token:",t),a(),this.onRefreshFailed?.(t),t}finally{this.isRefreshing=false,this.refreshPromise=null;}})(),this.refreshPromise)}async beforeRequest(){if(w()){a();return}if(E(30)){console.log("[TRIEOH SDK] Token expiring soon, refreshing...");try{await this.refreshToken();}catch(e){console.warn("[TRIEOH SDK] Refresh interceptor failed:",e);}}}async fetch(e,t){let r=t?.requiresAuth!==false,n=!t?.skipRefresh;r&&n&&await this.beforeRequest();let v=c(this.baseURL,e);return fetch(v,{...t,credentials:"include",headers:{"Content-Type":"application/json",...t?.headers}})}},q=s=>new o(s),D=s=>{let e=new o(s);return async(t,r)=>e.fetch(t,r)};var p=class extends Error{constructor(e){super(e.message),this.name="ApiError",this.code=e.code,this.trace=e.success?[]:e.trace,this.response=e;}},l=class{constructor(e,t){this.baseURL=e||h.BASE_URL,this.authInterceptor=new o({baseURL:this.baseURL,authBaseURL:t});}get headers(){return {"Content-Type":"application/json"}}async request(e,t){try{let r=await this.authInterceptor.fetch(e,{...t,headers:{...this.headers,...t?.headers??{}}}),n=await r.json().catch(()=>({module:"Client",message:r.statusText||"Unknown error",timestamp:new Date().toISOString(),code:r.status,error_id:"CLIENT_PARSE_ERROR",trace:["Failed to parse API response as JSON"]}));return r.ok?{success:!0,module:n.module,message:n.message,timestamp:n.timestamp,code:n.code,data:n.data}:{success:!1,module:n.module||"Unknown",message:n.message||r.statusText||"An unknown error occurred",timestamp:n.timestamp||new Date().toISOString(),code:n.code||r.status,error_id:n.error_id||"UNKNOWN_ERROR",trace:n.trace}}catch(r){let n=r instanceof Error?r.message:"A network or unknown error occurred.";return {success:false,module:"Network",message:n,timestamp:new Date().toISOString(),code:503,error_id:"CLIENT_NETWORK_ERROR",trace:r instanceof Error?[r.stack||n]:[n]}}}get(e,t){return this.request(e,{...t,method:"GET"})}post(e,t,r){return this.request(e,{...r,method:"POST",body:t?JSON.stringify(t):void 0})}put(e,t,r){return this.request(e,{...r,method:"PUT",body:t?JSON.stringify(t):void 0})}patch(e,t,r){return this.request(e,{...r,method:"PATCH",body:t?JSON.stringify(t):void 0})}delete(e,t,r){return this.request(e,{...r,method:"DELETE",body:t?JSON.stringify(t):void 0})}},A=s=>{let e=new l(s?.baseURL,s?.authBaseURL);return {request:e.request.bind(e),get:e.get.bind(e),post:e.post.bind(e),put:e.put.bind(e),patch:e.patch.bind(e),delete:e.delete.bind(e)}},_=s=>{let e=new l(s?.baseURL,s?.authBaseURL);return async(t,r)=>{let n=await e.request(t,r);if(!n.success)throw new p(n);return n.data}};
|
|
2
|
+
exports.ApiError=p;exports.AuthInterceptor=o;exports.configure=k;exports.createAuthInterceptor=q;exports.createAuthenticatedFetch=D;exports.createFetcher=A;exports.createQueryFetcher=_;//# sourceMappingURL=index.js.map
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/url-utils.ts","../../src/utils/token-utils.ts","../../src/core/env.ts","../../src/core/interceptor.ts","../../src/core/api.ts"],"names":["joinUrl","base","path","cleanBase","cleanPath","ACCESS_EXPIRY_KEY","REFRESH_EXPIRY_KEY","saveTokenClaims","claims","isTokenExpiringSoon","thresholdSeconds","expiryStr","accessExpiryTimestamp","now","isRefreshSessionExpired","refreshExpiryTimestamp","e","clearAuthTokens","resolveEnv","isServer","viteEnv","safeProcessEnv","resolvedProjectId","resolvedApiKey","memoizedEnv","overrides","configure","config","getEnv","env","AuthInterceptor","resJson","data","error","url","options","shouldAuth","shouldRefresh","finalUrl","createAuthInterceptor","createAuthenticatedFetch","interceptor","ApiError","response","Api","baseURL","authBaseURL","raw","errorMessage","body","createFetcher","api","createQueryFetcher","init"],"mappings":"kGAAO,SAASA,CAAAA,CAAQC,CAAAA,CAAcC,CAAAA,CAAsB,CAC1D,GAAIA,CAAAA,CAAK,UAAA,CAAW,MAAM,CAAA,CAAG,OAAOA,CAAAA,CAEpC,IAAMC,CAAAA,CAAYF,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAA,CAClCG,CAAAA,CAAYF,CAAAA,CAAK,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAA,CAExC,OAAO,CAAA,EAAGC,CAAS,CAAA,CAAA,EAAIC,CAAS,CAAA,CAClC,CCcA,IAAMC,CAAAA,CAAoB,sBAAA,CACpBC,CAAAA,CAAqB,uBAAA,CAKpB,SAASC,CAAAA,CAAgBC,CA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CAAejD,CAAAA,CAAMmD,CAAI,CAAA,CACpD,GAAI,CAACV,CAAAA,CAAS,OAAA,CAAS,MAAM,IAAID,CAAAA,CAASC,CAAQ,CAAA,CAClD,OAAOA,CAAAA,CAAS,IAClB,CACF","file":"index.js","sourcesContent":["export function joinUrl(base: string, path: string): string {\n if (path.startsWith(\"http\")) return path;\n \n const cleanBase = base.replace(/\\/$/, \"\");\n const cleanPath = path.replace(/^\\//, \"\");\n \n return `${cleanBase}/${cleanPath}`;\n}\n","import type { Api } from \"../core/api\";\n\ninterface TokenClaims {\n sub: {\n id: string;\n email: string;\n session_id: string;\n user_agent: string;\n user_ip: string;\n };\n iss: string;\n exp: number;\n iat: number;\n jti: string;\n}\n\nexport interface AuthTokenClaims {\n access: TokenClaims;\n refresh_expire_date: number;\n}\n\nconst ACCESS_EXPIRY_KEY = \"trieoh_access_expiry\";\nconst REFRESH_EXPIRY_KEY = \"trieoh_refresh_expiry\";\n\n// Stored only in memory\nlet memoryClaims: AuthTokenClaims | null = null;\n\nexport function saveTokenClaims(claims: AuthTokenClaims): void {\n memoryClaims = claims;\n localStorage.setItem(REFRESH_EXPIRY_KEY, String(claims.refresh_expire_date));\n localStorage.setItem(ACCESS_EXPIRY_KEY, String(claims.access.exp));\n console.log(\"[TRIEOH SDK] Token claims saved\");\n}\n\nexport function getTokenClaims(): AuthTokenClaims | null {\n return memoryClaims;\n}\n\nexport function isTokenExpiringSoon(thresholdSeconds: number = 30): boolean {\n try {\n const expiryStr = localStorage.getItem(ACCESS_EXPIRY_KEY);\n if (!expiryStr) return true;\n\n const accessExpiryTimestamp = parseInt(expiryStr, 10);\n const now = Math.floor(Date.now() / 1000);\n const timeUntilExpiry = accessExpiryTimestamp - now;\n \n return timeUntilExpiry <= thresholdSeconds;\n } catch (e) {\n console.warn(\"[TRIEOH SDK] Error reading access expiry date:\", e);\n return true;\n }\n}\n\nexport function isRefreshSessionExpired(): boolean {\n try {\n const expiryStr = localStorage.getItem(REFRESH_EXPIRY_KEY);\n if (!expiryStr) return true;\n\n const refreshExpiryTimestamp = parseInt(expiryStr, 10);\n const now = Math.floor(Date.now() / 1000);\n \n return refreshExpiryTimestamp <= now;\n } catch (e) {\n console.warn(\"[TRIEOH SDK] Error reading refresh expiry date:\", e);\n return true;\n }\n}\n\nexport function isAuthenticated(): boolean {\n const claims = getTokenClaims();\n if (!claims) return false;\n const now = Math.floor(Date.now() / 1000);\n return claims.access.exp > now;\n}\n\nexport function clearAuthTokens(): void {\n memoryClaims = null;\n localStorage.removeItem(ACCESS_EXPIRY_KEY);\n localStorage.removeItem(REFRESH_EXPIRY_KEY);\n console.log(\"[TRIEOH SDK] Auth tokens and claims cleared\");\n}\n\nexport function getUserInfo() {\n const claims = getTokenClaims();\n if (!claims) return null;\n \n return claims.access.sub\n}\n\nexport const fetchAndSaveClaims = async (apiInstance: Api) => {\n try {\n const res = await apiInstance.get<AuthTokenClaims>(\"/sessions/me\",\n { requiresAuth: true }\n );\n \n if (res.success) {\n saveTokenClaims(res.data);\n return res;\n }\n throw new Error(res.message || \"Failed to fetch session claims\");\n } catch (error) {\n console.warn(\"[TRIEOH SDK] fetch claims failed (network/server)\", error);\n throw error;\n }\n};","export interface TrieOHEnv {\n PROJECT_ID: string;\n API_KEY: string;\n BASE_URL: string;\n}\n\nexport function resolveEnv(): TrieOHEnv {\n const isServer = typeof window === \"undefined\";\n\n const viteEnv = (\n typeof import.meta !== \"undefined\" && import.meta.env\n ? import.meta.env\n : {}\n ) as Partial<ImportMetaEnv>;\n\n const safeProcessEnv: NodeJS.ProcessEnv = \n typeof process !== \"undefined\" ? process.env : {};\n\n const resolvedProjectId =\n viteEnv.VITE_TRIEOH_AUTH_PROJECT_ID ||\n safeProcessEnv.NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID ||\n safeProcessEnv.PUBLIC_TRIEOH_AUTH_PROJECT_ID ||\n \"\";\n\n const resolvedApiKey = isServer\n ? (safeProcessEnv.TRIEOH_AUTH_API_KEY || \"\")\n : \"\";\n\n return {\n PROJECT_ID: resolvedProjectId,\n API_KEY: resolvedApiKey,\n BASE_URL: \"https://api.default.com\",\n };\n}\nlet memoizedEnv: TrieOHEnv | null = null;\nlet overrides: Partial<TrieOHEnv> = {};\n\n/**\n * Configure the SDK manually. This will override any environment variables.\n */\nexport function configure(config: Partial<TrieOHEnv>) {\n overrides = { ...overrides, ...config };\n memoizedEnv = null; // Reset memoization to apply new config\n}\n\nfunction getEnv(): TrieOHEnv {\n if (!memoizedEnv) {\n const resolved = resolveEnv();\n memoizedEnv = {\n ...resolved,\n ...overrides,\n };\n }\n return memoizedEnv;\n}\nexport const env: TrieOHEnv = {\n get PROJECT_ID() {\n return getEnv().PROJECT_ID;\n },\n get API_KEY() {\n return getEnv().API_KEY;\n },\n get BASE_URL() {\n return getEnv().BASE_URL;\n },\n};\n","import { joinUrl } from \"../utils/url-utils\";\nimport {\n clearAuthTokens,\n isRefreshSessionExpired,\n isTokenExpiringSoon,\n saveTokenClaims,\n type AuthTokenClaims\n} from \"../utils/token-utils\";\nimport { env } from \"./env\";\n\n\nexport interface RequestOptions extends RequestInit {\n requiresAuth?: boolean;\n skipRefresh?: boolean;\n}\n\ninterface InterceptorConfig {\n baseURL?: string;\n authBaseURL?: string;\n onTokenRefreshed?: (claims: AuthTokenClaims) => void;\n onRefreshFailed?: (error: Error) => void;\n}\n\nexport class AuthInterceptor {\n private baseURL: string;\n private authBaseURL: string;\n private isRefreshing = false;\n private refreshPromise: Promise<void> | null = null;\n private onTokenRefreshed?: (claims: AuthTokenClaims) => void;\n private onRefreshFailed?: (error: Error) => void;\n\n constructor(config?: InterceptorConfig) {\n this.authBaseURL = config?.authBaseURL || env.BASE_URL;\n this.baseURL = config?.baseURL || this.authBaseURL;\n\n this.onTokenRefreshed = config?.onTokenRefreshed;\n this.onRefreshFailed = config?.onRefreshFailed;\n }\n\n private async fetchClaimsAndSave(): Promise<AuthTokenClaims> {\n const response = await fetch(joinUrl(this.authBaseURL, \"/sessions/me\"), {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n credentials: \"include\",\n });\n\n const resJson = await response.json();\n\n if (resJson.code !== 200 || !resJson.data) {\n clearAuthTokens();\n throw new Error(resJson.message || \"Failed to fetch session claims after refresh\");\n }\n \n const claims = resJson.data as AuthTokenClaims;\n saveTokenClaims(claims);\n return claims;\n }\n\n private async refreshToken(): Promise<void> {\n if (this.isRefreshing && this.refreshPromise) return this.refreshPromise;\n \n this.isRefreshing = true;\n this.refreshPromise = (async () => {\n let claims: AuthTokenClaims;\n try {\n const response = await fetch(joinUrl(this.authBaseURL, \"/auth/refresh\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n credentials: \"include\",\n });\n\n const data = await response.json();\n\n if (data.code !== 200) {\n if (data.code !== 503) clearAuthTokens();\n throw new Error(data.message || \"Failed to refresh token\");\n }\n\n claims = await this.fetchClaimsAndSave();\n this.onTokenRefreshed?.(claims);\n console.log(\"[TRIEOH SDK] Token refreshed successfully\");\n } catch (error) {\n console.warn(\"[TRIEOH SDK] Failed to refresh token:\", error);\n clearAuthTokens();\n this.onRefreshFailed?.(error as Error);\n throw error;\n } finally {\n this.isRefreshing = false;\n this.refreshPromise = null;\n }\n })();\n\n return this.refreshPromise;\n }\n\n async beforeRequest(): Promise<void> {\n if(isRefreshSessionExpired()) {\n clearAuthTokens();\n return;\n }\n \n if (isTokenExpiringSoon(30)) {\n console.log(\"[TRIEOH SDK] Token expiring soon, refreshing...\");\n try {\n await this.refreshToken();\n } catch (error) {\n console.warn(\"[TRIEOH SDK] Refresh interceptor failed:\", error);\n }\n }\n }\n\n async fetch(url: string, options?: RequestOptions): Promise<Response> {\n const shouldAuth = options?.requiresAuth !== false;\n const shouldRefresh = !options?.skipRefresh;\n\n if (shouldAuth && shouldRefresh) await this.beforeRequest();\n\n const finalUrl = joinUrl(this.baseURL, url);\n\n return fetch(finalUrl, {\n ...options,\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...options?.headers,\n },\n });\n }\n}\n\nexport const createAuthInterceptor = (config?: InterceptorConfig) => {\n return new AuthInterceptor(config);\n};\n\nexport const createAuthenticatedFetch = (config?: InterceptorConfig) => {\n const interceptor = new AuthInterceptor(config);\n \n return async (url: string, options?: RequestOptions): Promise<Response> => {\n return interceptor.fetch(url, options);\n };\n};","import { env } from \"./env\";\nimport { AuthInterceptor, type RequestOptions } from \"./interceptor\";\n\n/**\n * Base structure shared by all API responses.\n */\nexport interface BaseResponse {\n module: string;\n message: string;\n timestamp: string;\n code: number;\n}\n\n/**\n * Standardized API Response. \n * Use 'success' to narrow down to the data or error details.\n */\nexport type ApiResponse<T> = \n | (BaseResponse & { success: true; data: T })\n | (BaseResponse & { \n success: false; \n error_id: string; \n trace?: string[]; \n });\n\n/**\n * Internal type for parsing the raw response from the server.\n */\ntype RawApiResponse<T> = BaseResponse & { \n data?: T; \n error_id?: string; \n trace?: string[] \n};\n\n/**\n * Custom error class for API failures.\n * Provides access to the full standardized response.\n */\nexport class ApiError extends Error {\n code: number;\n trace?: string[];\n response: ApiResponse<unknown>;\n\n constructor(response: ApiResponse<unknown>) {\n super(response.message);\n this.name = \"ApiError\";\n this.code = response.code;\n this.trace = !response.success ? response.trace : [];\n this.response = response;\n }\n}\n\nexport class Api {\n private baseURL: string;\n private authInterceptor: AuthInterceptor;\n\n constructor(baseURL?: string, authBaseURL?: string) {\n this.baseURL = baseURL || env.BASE_URL;\n this.authInterceptor = new AuthInterceptor({ \n baseURL: this.baseURL,\n authBaseURL: authBaseURL\n });\n }\n\n private get headers() {\n return { \"Content-Type\": \"application/json\" };\n }\n\n async request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>> {\n try {\n const response = await this.authInterceptor.fetch(path, {\n ...options,\n headers: { ...this.headers, ...(options?.headers ?? {}) },\n });\n\n const raw: RawApiResponse<T> = await response.json().catch(() => ({\n module: \"Client\",\n message: response.statusText || \"Unknown error\",\n timestamp: new Date().toISOString(),\n code: response.status,\n error_id: \"CLIENT_PARSE_ERROR\",\n trace: [\"Failed to parse API response as JSON\"],\n }));\n\n if (!response.ok) {\n return {\n success: false,\n module: raw.module || \"Unknown\",\n message: raw.message || response.statusText || \"An unknown error occurred\",\n timestamp: raw.timestamp || new Date().toISOString(),\n code: raw.code || response.status,\n error_id: raw.error_id || \"UNKNOWN_ERROR\",\n trace: raw.trace,\n };\n }\n\n return {\n success: true,\n module: raw.module,\n message: raw.message,\n timestamp: raw.timestamp,\n code: raw.code,\n data: raw.data as T,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : \"A network or unknown error occurred.\";\n return {\n success: false,\n module: \"Network\",\n message: errorMessage,\n timestamp: new Date().toISOString(),\n code: 503,\n error_id: \"CLIENT_NETWORK_ERROR\",\n trace: error instanceof Error ? [error.stack || errorMessage] : [errorMessage],\n };\n }\n }\n\n get<T = unknown>(path: string, options?: RequestOptions) {\n return this.request<T>(path, { ...options, method: \"GET\" });\n }\n\n post<T = unknown>(path: string, body?: unknown, options?: RequestOptions) {\n return this.request<T>(path, {\n ...options,\n method: \"POST\",\n body: body ? JSON.stringify(body) : undefined,\n });\n }\n\n put<T = unknown>(path: string, body?: unknown, options?: RequestOptions) {\n return this.request<T>(path, {\n ...options,\n method: \"PUT\",\n body: body ? JSON.stringify(body) : undefined,\n });\n }\n\n patch<T = unknown>(path: string, body?: unknown, options?: RequestOptions) {\n return this.request<T>(path, {\n ...options,\n method: \"PATCH\",\n body: body ? JSON.stringify(body) : undefined,\n });\n }\n\n delete<T = unknown>(path: string, body?: unknown, options?: RequestOptions) {\n return this.request<T>(path, { \n ...options, \n method: \"DELETE\", \n body: body ? JSON.stringify(body) : undefined \n });\n }\n}\n\n/**\n * Creates a fetcher object with all HTTP methods returning standardized ApiResponse.\n * \n * @param config - Optional configuration for the fetcher (baseURL, authBaseURL, etc.)\n * @returns An object with get, post, put, patch, delete, and request methods.\n */\nexport const createFetcher = (config?: { baseURL?: string; authBaseURL?: string }) => {\n const api = new Api(config?.baseURL, config?.authBaseURL);\n\n return {\n request: api.request.bind(api),\n get: api.get.bind(api),\n post: api.post.bind(api),\n put: api.put.bind(api),\n patch: api.patch.bind(api),\n delete: api.delete.bind(api),\n };\n};\n\n/**\n * Creates a simple fetcher function that returns data directly or throws an ApiError on failure.\n * Ideal for Query libraries like TanStack Query.\n * \n * @param config - Optional configuration for the fetcher (baseURL, authBaseURL, etc.)\n * @returns A single fetcher function that returns a Promise of TData.\n */\nexport const createQueryFetcher = (config?: { baseURL?: string; authBaseURL?: string }) => {\n const api = new Api(config?.baseURL, config?.authBaseURL);\n\n return async <TData>(path: string, init?: RequestOptions): Promise<TData> => {\n const response = await api.request<TData>(path, init);\n if (!response.success) throw new ApiError(response);\n return response.data;\n };\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),ri=require('react-icons/ri'),go=require('react-icons/go'),im=require('react-icons/im'),fa=require('react-icons/fa'),uaParserJs=require('ua-parser-js');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function Ge(){let e=typeof window>"u",t=typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('react.js', document.baseURI).href)) })<"u"&&undefined?undefined:{},r=typeof process<"u"?process.env:{},o=t.VITE_TRIEOH_AUTH_PROJECT_ID||r.NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID||r.PUBLIC_TRIEOH_AUTH_PROJECT_ID||"",s=e&&r.TRIEOH_AUTH_API_KEY||"";return {PROJECT_ID:o,API_KEY:s,BASE_URL:"https://api.default.com"}}var Q=null,ue={};function Ie(e){ue={...ue,...e},Q=null;}function ce(){return Q||(Q={...Ge(),...ue}),Q}var _={get PROJECT_ID(){return ce().PROJECT_ID},get BASE_URL(){return ce().BASE_URL}};function Z(e,t){if(t.startsWith("http"))return t;let r=e.replace(/\/$/,""),o=t.replace(/^\//,"");return `${r}/${o}`}var de="trieoh_access_expiry",pe="trieoh_refresh_expiry",me=null;function he(e){me=e,localStorage.setItem(pe,String(e.refresh_expire_date)),localStorage.setItem(de,String(e.access.exp)),console.log("[TRIEOH SDK] Token claims saved");}function fe(){return me}function Ce(e=30){try{let t=localStorage.getItem(de);if(!t)return !0;let r=parseInt(t,10),o=Math.floor(Date.now()/1e3);return r-o<=e}catch(t){return console.warn("[TRIEOH SDK] Error reading access expiry date:",t),true}}function Ae(){try{let e=localStorage.getItem(pe);if(!e)return !0;let t=parseInt(e,10),r=Math.floor(Date.now()/1e3);return t<=r}catch(e){return console.warn("[TRIEOH SDK] Error reading refresh expiry date:",e),true}}function U(){me=null,localStorage.removeItem(de),localStorage.removeItem(pe),console.log("[TRIEOH SDK] Auth tokens and claims cleared");}function De(){let e=fe();return e?e.access.sub:null}var J=async e=>{try{let t=await e.get("/sessions/me",{requiresAuth:!0});if(t.success)return he(t.data),t;throw new Error(t.message||"Failed to fetch session claims")}catch(t){throw console.warn("[TRIEOH SDK] fetch claims failed (network/server)",t),t}};var ee=class{constructor(t){this.isRefreshing=false;this.refreshPromise=null;this.authBaseURL=t?.authBaseURL||_.BASE_URL,this.baseURL=t?.baseURL||this.authBaseURL,this.onTokenRefreshed=t?.onTokenRefreshed,this.onRefreshFailed=t?.onRefreshFailed;}async fetchClaimsAndSave(){let r=await(await fetch(Z(this.authBaseURL,"/sessions/me"),{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(r.code!==200||!r.data)throw U(),new Error(r.message||"Failed to fetch session claims after refresh");let o=r.data;return he(o),o}async refreshToken(){return this.isRefreshing&&this.refreshPromise?this.refreshPromise:(this.isRefreshing=true,this.refreshPromise=(async()=>{let t;try{let o=await(await fetch(Z(this.authBaseURL,"/auth/refresh"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(o.code!==200)throw o.code!==503&&U(),new Error(o.message||"Failed to refresh token");t=await this.fetchClaimsAndSave(),this.onTokenRefreshed?.(t),console.log("[TRIEOH SDK] Token refreshed successfully");}catch(r){throw console.warn("[TRIEOH SDK] Failed to refresh token:",r),U(),this.onRefreshFailed?.(r),r}finally{this.isRefreshing=false,this.refreshPromise=null;}})(),this.refreshPromise)}async beforeRequest(){if(Ae()){U();return}if(Ce(30)){console.log("[TRIEOH SDK] Token expiring soon, refreshing...");try{await this.refreshToken();}catch(t){console.warn("[TRIEOH SDK] Refresh interceptor failed:",t);}}}async fetch(t,r){let o=r?.requiresAuth!==false,s=!r?.skipRefresh;o&&s&&await this.beforeRequest();let n=Z(this.baseURL,t);return fetch(n,{...r,credentials:"include",headers:{"Content-Type":"application/json",...r?.headers}})}};var te=class{constructor(t,r){this.baseURL=t||_.BASE_URL,this.authInterceptor=new ee({baseURL:this.baseURL,authBaseURL:r});}get headers(){return {"Content-Type":"application/json"}}async request(t,r){try{let o=await this.authInterceptor.fetch(t,{...r,headers:{...this.headers,...r?.headers??{}}}),s=await o.json().catch(()=>({module:"Client",message:o.statusText||"Unknown error",timestamp:new Date().toISOString(),code:o.status,error_id:"CLIENT_PARSE_ERROR",trace:["Failed to parse API response as JSON"]}));return o.ok?{success:!0,module:s.module,message:s.message,timestamp:s.timestamp,code:s.code,data:s.data}:{success:!1,module:s.module||"Unknown",message:s.message||o.statusText||"An unknown error occurred",timestamp:s.timestamp||new Date().toISOString(),code:s.code||o.status,error_id:s.error_id||"UNKNOWN_ERROR",trace:s.trace}}catch(o){let s=o instanceof Error?o.message:"A network or unknown error occurred.";return {success:false,module:"Network",message:s,timestamp:new Date().toISOString(),code:503,error_id:"CLIENT_NETWORK_ERROR",trace:o instanceof Error?[o.stack||s]:[s]}}}get(t,r){return this.request(t,{...r,method:"GET"})}post(t,r,o){return this.request(t,{...o,method:"POST",body:r?JSON.stringify(r):void 0})}put(t,r,o){return this.request(t,{...o,method:"PUT",body:r?JSON.stringify(r):void 0})}patch(t,r,o){return this.request(t,{...o,method:"PATCH",body:r?JSON.stringify(r):void 0})}delete(t,r,o){return this.request(t,{...o,method:"DELETE",body:r?JSON.stringify(r):void 0})}};var k=()=>{if(!_.PROJECT_ID||_.PROJECT_ID.trim()==="")throw new Error("[TRIEOH SDK] Project ID is missing. Please set PUBLIC_TRIEOH_AUTH_PROJECT_ID, NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID or VITE_TRIEOH_AUTH_PROJECT_ID.")};var Oe=e=>({login:async(t,r)=>{let o={requiresAuth:false};if(_.PROJECT_ID){k();let n=`/projects/${_.PROJECT_ID}/login`,i=await e.post(n,{email:t,password:r},o);return i.success&&await J(e),i}let s=await e.post("/auth/login",{email:t,password:r},o);return s.success&&await J(e),s},register:(t,r,o,s={})=>{let n={requiresAuth:false};if(_.PROJECT_ID){k();let i=new URLSearchParams;o&&(i.append("flow_id",o),i.append("schema_type","context"),i.append("version","1"));let a={email:t,password:r,...o&&{custom_fields:s}},p=i.toString()?`?${i.toString()}`:"",d=`/projects/${_.PROJECT_ID}/register${p}`;return e.post(d,a,n)}return e.post("/auth/register",{email:t,password:r},n)},logout:async()=>{let t=await e.post("/auth/logout");return t.success&&U(),t},refresh:async()=>{let t=await e.post("/auth/refresh",void 0,{skipRefresh:true});return t.success&&await J(e),t},sessions:async()=>e.get("/sessions"),revokeASession:async t=>e.delete(`/sessions/${t}`),revokeSessions:async(t=false)=>{let r=t?"/sessions":"/sessions/others";return e.delete(r)},refreshProfileInfo:async()=>J(e),profile:()=>De(),getProfileUpgradeForms:async()=>{k();let t=`/projects/${_.PROJECT_ID}/upgrade-form`;return e.get(t)},updateProfile:async t=>{k();let r=`/projects/${_.PROJECT_ID}/metadata`;return e.post(r,{custom_fields:t})},sendForgotPassword:async t=>{let r={requiresAuth:false};return _.PROJECT_ID?(k(),e.post("/auth/forgot-password",{email:t,project_id:_.PROJECT_ID},r)):e.post("/auth/forgot-password",{email:t},r)},resetPassword:async(t,r)=>e.post(`/auth/reset-password?token=${t}`,{new_password:r},{requiresAuth:false}),resendVerifyEmail:async()=>e.post("/auth/verify/resend"),verifyEmail:async()=>e.get("/auth/verify",{requiresAuth:false}),addSubContext:async(t,r)=>(k(),e.post(`/projects/${_.PROJECT_ID}/sub-context`,{data:r,user_id:t})),removeSubContext:async(t,r)=>(k(),e.delete(`/projects/${_.PROJECT_ID}/sub-context`,{keys:r,user_id:t}))});var Ne=react.createContext(null);function hr({children:e,baseURL:t,projectId:r,isClient:o=true}){let[s,n]=react.useState(false),[i,a]=react.useState(false);react.useMemo(()=>{(r||t)&&Ie({...r?{PROJECT_ID:r}:{},...t?{BASE_URL:t}:{}});},[r,t]);let p=react.useMemo(()=>new te(t),[t]),d=react.useMemo(()=>Oe(p),[p]);return react.useEffect(()=>{o&&k(),(async()=>{if(fe()){a(true),n(true);return}console.log("[TRIEOH SDK] Attempting to refresh session...");try{(await d.refreshProfileInfo()).success?(a(!0),console.log("[TRIEOH SDK] Session restored successfully.")):(a(!1),console.warn("[TRIEOH SDK] Session restoration failed/no session."));}catch{console.warn("[TRIEOH SDK] Unable to verify session (offline?)"),a(false);}finally{n(true);}})();},[d,o]),s?jsxRuntime.jsx(Ne.Provider,{value:{auth:d,isAuthenticated:i,isClient:o},children:e}):null}function P(){let e=react.useContext(Ne);if(!e)throw new Error("useAuth must be used inside <AuthProvider>");return e}function j(e,{insertAt:t}={}){if(!e||typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e));}j(`@import"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap";:root{--trieoh-primary: oklch(.1139 .0789 264.05);--trieoh-secondary: oklch(.7975 .1018 262.7);--trieoh-neutral1: oklch(.9702 0 0);--trieoh-neutral2: oklch(.1944 .0051 248.09);--trieoh-radius-full: 50%;--trieoh-text-sm: .75rem;--trieoh-text-base: .875rem;--trieoh-text-xl: 1.25rem;--trieoh-text-2xl: 1.5rem;--trieoh-text-3xl: 1.875rem;--trieoh-text-6xl: 3.75rem}
|
|
2
|
+
`);j(`.trieoh{font-family:Inter,sans-serif}.trieoh-input{position:relative;width:100%;display:flex;flex-direction:column;gap:.25rem;color:var(--trieoh-neutral2)}.trieoh-input__label{font-size:1rem;font-weight:600}.trieoh-input__container{display:flex;justify-content:space-between;align-items:center;padding:.0625rem .625rem;gap:.625rem;border-bottom:solid .125rem var(--trieoh-neutral2)}.trieoh-input__container--error{border-color:#e53935!important}.trieoh-input__container-field{min-width:10rem;flex:1;font-size:var(--trieoh-text-base);font-weight:300;color:var(--trieoh-neutral2);-webkit-appearance:none;background:none;outline:none;border:none;box-shadow:none!important;padding:.125rem 0}.trieoh-custom-select__wrapper{position:relative;width:100%}.trieoh-custom-select{cursor:pointer;user-select:none;box-sizing:border-box}.trieoh-custom-select.is-disabled{opacity:.5;cursor:not-allowed}.trieoh-custom-select:focus-visible{outline:2px solid var(--trieoh-primary);outline-offset:2px}.trieoh-custom-select__trigger{display:flex;align-items:center;width:100%}.trieoh-custom-select__trigger.placeholder{opacity:.6}.trieoh-custom-select__arrow{transition:transform .2s ease;flex-shrink:0}.trieoh-custom-select__arrow.is-open{transform:rotate(180deg)}.trieoh-custom-select__dropdown{position:absolute;top:calc(100% + .25rem);left:0;right:0;width:100%;box-sizing:border-box;background:var(--trieoh-neutral1);border:solid .125rem var(--trieoh-neutral2);border-radius:.25rem;box-shadow:0 4px 12px #00000026;z-index:1000;max-height:15rem;overflow-y:auto;animation:dropdownSlide .15s ease-out}@keyframes dropdownSlide{0%{opacity:0;transform:translateY(-.5rem)}to{opacity:1;transform:translateY(0)}}.trieoh-custom-select__options{padding:.25rem 0}.trieoh-custom-select__option{padding:.5rem .625rem;font-size:var(--trieoh-text-base);font-weight:300;color:var(--trieoh-neutral2);cursor:pointer;transition:background-color .15s ease,color .15s ease;outline:none}.trieoh-custom-select__option:hover,.trieoh-custom-select__option:focus-visible{background-color:var(--trieoh-secondary);color:var(--trieoh-neutral2)}.trieoh-custom-select__option.is-selected{background-color:var(--trieoh-secondary);color:var(--trieoh-neutral2);font-weight:500}.trieoh-custom-select.is-open{border-color:var(--trieoh-primary, var(--trieoh-neutral2))}.trieoh-input__container-icon{cursor:pointer;flex-shrink:0;-webkit-user-select:none;user-select:none}.trieoh-input__hint{font-size:.75rem;color:#6b7280;transition:opacity .2s ease-in-out}.trieoh-input__hint .hint-part{transition:color .12s ease,text-decoration .12s ease,opacity .12s ease;opacity:.95;margin:.125rem}.trieoh-input__hint .hint-part.passed{text-decoration:line-through;opacity:.6;color:#10b981}.trieoh-input__hint .hint-part.failed-on-submit{color:#e53935;font-weight:600;opacity:1}.trieoh-button{--trieoh-button-color: var(--trieoh-neutral2);width:100%;height:3.25rem;font-size:var(--trieoh-text-xl);font-weight:600;color:var(--trieoh-button-color);outline:none;background:none;position:relative;overflow:hidden;min-width:10rem;flex-shrink:0;border:.125rem solid var(--trieoh-button-color);cursor:pointer;padding:0 1.5rem;transition:transform .5s}.trieoh-button--all-rounded{border-radius:.25rem}.trieoh-button:hover{transform:scale(102%)}.trieoh-button:active{transform:scale(99%)}.trieoh-button[disabled],.trieoh-button--logout[disabled]{opacity:.6;cursor:not-allowed;transform:none!important}.trieoh-button--loading:after{content:"";position:absolute;top:0;left:-150%;width:150%;height:100%;background:linear-gradient(120deg,transparent 0%,color-mix(in oklab,var(--trieoh-button-color) 40%,white 15%) 40%,transparent 80%);animation:trieoh-shine 1.5s infinite}@keyframes trieoh-shine{0%{left:-150%}to{left:150%}}.trieoh-button--logout{border:none;background:none;cursor:pointer;--trieoh-button-color: oklch(.628 .2577 29.23);display:flex;align-items:end;gap:.25rem;font-size:var(--trieoh-text-base);font-weight:500;color:var(--trieoh-button-color);transition:transform .2s}.trieoh-button--logout:hover{transform:scale(1.05)}.trieoh-button--logout:active{transform:scale(.98)}.trieoh-avacard{display:flex;flex-direction:column;align-items:center}.trieoh-avacard__container{display:flex;justify-content:center;align-items:center;padding:.5rem;background-color:#d9d9d94d;border-radius:var(--trieoh-radius-full);margin-bottom:.625rem}.trieoh-avacard__content{width:64px;height:64px;padding:.625rem;background-color:var(--trieoh-neutral1);border-radius:var(--trieoh-radius-full);box-shadow:0 .25rem 1rem #00000040}.trieoh-avacard__title{text-align:center;font-size:var(--trieoh-text-xl);font-weight:500;margin:0}.trieoh-avacard__sub-title{text-align:center;font-size:.875rem;font-weight:300;opacity:.6}.trieoh-card{display:flex;flex-direction:column;width:100%;max-width:30rem;min-width:15rem;max-height:max(75dvh,32rem);overflow:hidden;gap:1.25rem;align-items:center;background-color:var(--trieoh-neutral1);color:var(--trieoh-neutral2);padding:1.25rem 1.5rem;box-shadow:0 .25rem .25rem #00000040;transition:transform .15s ease}.trieoh-card--full-rounded{border-radius:.25rem}.trieoh-card__fields{width:100%;display:flex;flex-direction:column;gap:.625rem;flex:1 1 auto;overflow-y:auto;margin-bottom:.5rem}.trieoh-card__divider{display:flex;align-items:center;gap:.625rem;width:100%;font-size:var(--trieoh-text-base);font-weight:600;opacity:.6}.trieoh-card__divider hr{flex:1}.trieoh-card__other{font-size:var(--trieoh-text-sm);font-weight:600}.trieoh-card__other span{cursor:pointer;color:var(--trieoh-secondary);transition:color .2s}.trieoh-card__other span:hover{color:var(--trieoh-primary)}.trieoh-card__empty{display:block;padding:1.25rem .75rem;text-align:center;font-weight:400;opacity:.6}.trieoh-copyright{font-size:var(--trieoh-text-xl);font-weight:500}.trieoh-copyright--xs{font-size:var(--trieoh-text-sm)}.trieoh-copyright--sm{font-size:var(--trieoh-text-base)}.trieoh-copyright--md{font-size:var(--trieoh-text-xl)}.trieoh-copyright--lg{font-size:var(--trieoh-text-2xl)}.trieoh-copyright--xl{font-size:var(--trieoh-text-3xl)}.trieoh-copyright--2xl{font-size:var(--trieoh-text-6xl)}.trieoh-sessions{width:100%;min-width:20rem;margin:.5rem;container-type:inline-size;background-color:var(--trieoh-neutral1);color:var(--trieoh-neutral2);padding:1.5rem .5rem;border-radius:.5rem}.trieoh-sessions__header{width:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;text-align:center;gap:1rem;box-sizing:border-box;padding:0 .75rem}.trieoh-sessions__header div{flex:0 1 auto;max-width:25rem}.trieoh-sessions__header div h3{font-weight:600;font-size:var(--trieoh-text-2xl);margin:0;margin-bottom:.25rem}.trieoh-sessions__header div p{font-weight:200;font-size:var(--trieoh-text-base);margin:0}.trieoh-sessions__header button{max-width:14rem;padding:1rem 0;height:auto;font-size:var(--trieoh-text-base)}.trieoh-sessions__content{margin-top:1rem}.trieoh-sessions__empty{display:block;border-top:1px solid rgba(0,0,0,.3);padding:1.25rem .75rem;text-align:center;font-weight:600}.trieoh-session{border-top:1px solid rgba(0,0,0,.3);padding:1.25rem .75rem;color:var(--trieoh-neutral2)}.trieoh-session__content{position:relative;display:flex;flex-direction:column;align-items:center;gap:.5rem;flex:1;text-align:center}.trieoh-session__info{display:flex;flex-direction:column;min-width:0}.trieoh-session__meta{display:inline-flex;flex-direction:column;font-size:var(--trieoh-text-sm);font-weight:200}.trieoh-session h3{font-size:var(--trieoh-text-base);font-weight:600;margin:0}.trieoh-session span strong{color:var(--trieoh-primary);font-weight:400}.trieoh-session__content svg:last-child{position:absolute;top:0;right:0;cursor:pointer;opacity:.6;transition:opacity .2s,transform .15s}.trieoh-session__content svg:last-child:hover{opacity:1;transform:scale(1.05)}.trieoh-session__content svg:last-child:active{transform:scale(.95)}@container (min-width: 640px){.trieoh-sessions__header{justify-content:space-between;text-align:left;gap:2rem}.trieoh-session{flex-direction:row;text-align:left}.trieoh-session__content{flex-direction:row;align-items:center;gap:1rem;text-align:left}.trieoh-session__meta{flex-direction:row;gap:.5rem;align-items:center}}.trieoh-tabbed-signup{width:100%;max-width:30rem;min-width:15rem;background-color:var(--trieoh-neutral1);color:var(--trieoh-neutral2);box-shadow:0 .25rem .25rem #00000040;transition:transform .15s ease}.trieoh-tabbed-signup__header{width:100%;display:flex;justify-content:space-between;gap:.25rem;overflow-x:auto;overflow-y:hidden;padding:.25rem 0;position:relative;-webkit-overflow-scrolling:touch;scrollbar-width:thin;scrollbar-color:transparent}.trieoh-tabbed-signup__tab{flex-shrink:0;padding:.875rem 1.5rem;border:none;background:transparent;color:var(--trieoh-neutral2);opacity:.8;font-size:.8125rem;font-weight:500;letter-spacing:.01em;cursor:pointer;position:relative;white-space:nowrap;transition:color .2s ease,opacity .2s ease;border-radius:.375rem .375rem 0 0}.trieoh-tabbed-signup__tab:hover{color:var(--trieoh-primary);opacity:1}.trieoh-tabbed-signup__tab.active{color:var(--trieoh-primary);background:transparent}.trieoh-tabbed-signup__tab.active:after{content:"";position:absolute;bottom:4px;left:1rem;right:1rem;height:2px;background:var(--trieoh-primary);border-radius:2px}.trieoh-tabbed-signup__tab:focus-visible{outline:none;color:var(--trieoh-primary)}.trieoh-tabbed-signup hr{opacity:.5;border-top:1px solid var(--trieoh-primary);margin:0 .5rem;border-radius:1rem}.trieoh-tabbed-signup .trieoh-card{box-shadow:none;background:none;overflow-y:auto;box-sizing:border-box}.trieoh-tabbed-signup__content{width:100%}
|
|
3
|
+
`);function S({name:e,label:t,placeholder:r,type:o="text",value:s,onValueChange:n,onBlur:i,autoComplete:a,rulesStatus:p=[],submitted:d=false,inputRef:l}){let[c,f]=react.useState(false),h=p.some(v=>!v.passed);return jsxRuntime.jsxs("div",{className:"trieoh trieoh-input",children:[jsxRuntime.jsx("label",{htmlFor:e,className:"trieoh-input__label",children:t}),jsxRuntime.jsxs("div",{className:(h&&d?"trieoh-input__container--error ":"")+"trieoh-input__container",children:[jsxRuntime.jsx("input",{type:c?"text":o,name:e,id:e,placeholder:r,value:s,onChange:v=>n&&n(v.target.value),onBlur:i,autoComplete:a,"aria-invalid":h&&d,ref:l,className:"trieoh-input__container-field"}),o==="password"&&(c?jsxRuntime.jsx(ri.RiEyeCloseLine,{className:"trieoh-input__container-icon",size:24,onClick:()=>f(false)}):jsxRuntime.jsx(ri.RiEyeLine,{className:"trieoh-input__container-icon",size:24,onClick:()=>f(true)}))]}),jsxRuntime.jsx("div",{className:"trieoh-input__hint",children:p.map((v,y)=>{let u=["hint-part",v.passed?"passed":"",!v.passed&&d?"failed-on-submit":""].filter(Boolean).join(" ");return jsxRuntime.jsx("p",{className:u,children:v.message},v.id??y)})})]})}function B({label:e,onSubmit:t,loading:r}){return jsxRuntime.jsx("button",{type:"submit",onClick:t,disabled:r,className:`trieoh trieoh-button trieoh-button--all-rounded
|
|
4
|
+
${r?"trieoh-button--loading":""}`,children:e})}function Y({mainText:e,subText:t}){return jsxRuntime.jsxs("div",{className:"trieoh trieoh-avacard",children:[jsxRuntime.jsx("div",{className:"trieoh-avacard__container",children:jsxRuntime.jsx(go.GoPerson,{className:"trieoh-avacard__content",size:70})}),jsxRuntime.jsx("h3",{className:"trieoh-avacard__title",children:e}),jsxRuntime.jsx("span",{className:"trieoh-avacard__sub-title",children:t})]})}function H(e,t){return e.map(r=>({id:r.id,message:r.message,passed:!!r.test(t)}))}function nt({onSuccess:e,onFailed:t,signUpRedirect:r,forgotPasswordRedirect:o,emailRules:s}){let[n,i]=react.useState(""),[a,p]=react.useState(""),[d,l]=react.useState(false),[c,f]=react.useState(false),h=react.useRef(null),v=react.useRef(null),{auth:y}=P(),u={email:s||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:E=>/\S+@\S+\.\S+/.test(E)}],password:[]},b=H(u.email,n),T=H(u.password,a);return jsxRuntime.jsxs("form",{className:"trieoh trieoh-card trieoh-card--full-rounded",children:[jsxRuntime.jsx(Y,{mainText:"Fa\xE7a login na sua conta",subText:"Insira seus dados para fazer login"}),jsxRuntime.jsxs("div",{className:"trieoh-card__fields",children:[jsxRuntime.jsx(S,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:n,onValueChange:i,inputRef:h,rulesStatus:b,submitted:d}),jsxRuntime.jsx(S,{label:"Senha",name:"password",placeholder:"**********",autoComplete:"current-password",type:"password",value:a,onValueChange:p,inputRef:v,rulesStatus:T,submitted:d})]}),jsxRuntime.jsx(B,{label:"Entrar",onSubmit:async E=>{E.preventDefault(),l(true);let g=b.some(L=>!L.passed),w=T.some(L=>!L.passed);if(g){h.current?.focus();return}if(w){v.current?.focus();return}f(true);let N=await y.login(n,a);N.success&&e?await e(N.data.is_up_to_date||true):t&&await t(N.message),f(false);},loading:c}),o&&jsxRuntime.jsx("span",{className:"trieoh-card__other",style:{textAlign:"center",cursor:"pointer"},children:jsxRuntime.jsx("span",{onClick:o,children:"Esqueceu sua senha?"})}),r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"trieoh-card__divider",children:[jsxRuntime.jsx("hr",{}),"OU",jsxRuntime.jsx("hr",{})]}),jsxRuntime.jsxs("span",{className:"trieoh-card__other",children:["Ainda n\xE3o possui uma conta? ",jsxRuntime.jsx("span",{onClick:r,children:"Cadastra-se"})]})]})]})}function se({name:e,label:t,placeholder:r="Selecione uma op\xE7\xE3o",value:o,options:s,onValueChange:n,onBlur:i,rulesStatus:a=[],submitted:p=false,triggerRef:d,disabled:l=false}){let[c,f]=react.useState(false),[h,v]=react.useState(""),y=react.useRef(null),u=a.some(g=>!g.passed);react.useEffect(()=>{let g=s.find(w=>w.value===o);v(g?g.label:"");},[o,s]),react.useEffect(()=>{let g=w=>{y.current&&!y.current.contains(w.target)&&f(false);};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);let b=g=>{n&&n(g),f(false);},T=()=>{l||f(!c);},F=g=>{y.current?.contains(g.relatedTarget)||i&&i(g);},E=h||r;return jsxRuntime.jsxs("div",{className:"trieoh trieoh-input",children:[jsxRuntime.jsx("label",{htmlFor:e,className:"trieoh-input__label",children:t}),jsxRuntime.jsxs("div",{className:"trieoh-custom-select__wrapper",ref:y,children:[jsxRuntime.jsxs("div",{className:(u&&p?"trieoh-input__container--error ":"")+"trieoh-input__container trieoh-custom-select "+(c?"is-open ":"")+(l?"is-disabled ":""),onClick:T,onBlur:F,ref:d,id:e,role:"combobox","aria-expanded":c,"aria-haspopup":"listbox","aria-disabled":l,tabIndex:l?-1:0,children:[jsxRuntime.jsx("div",{className:"trieoh-input__container-field trieoh-custom-select__trigger "+(h?"":"placeholder"),children:E}),jsxRuntime.jsx(ri.RiArrowDownSLine,{className:`trieoh-input__container-icon trieoh-custom-select__arrow ${c?"is-open":""}`,size:24})]}),c&&jsxRuntime.jsx("div",{className:"trieoh-custom-select__dropdown",role:"listbox","aria-label":`Op\xE7\xF5es para ${t}`,children:jsxRuntime.jsx("div",{className:"trieoh-custom-select__options",children:s.map(g=>jsxRuntime.jsx("div",{className:`trieoh-custom-select__option ${g.value===o?"is-selected":""}`,onClick:()=>b(g.value),role:"option","aria-selected":g.value===o,tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),b(g.value));},children:g.label},g.id))})})]}),jsxRuntime.jsx("div",{className:"trieoh-input__hint",children:a.map((g,w)=>{let N=["hint-part",g.passed?"passed":"",!g.passed&&p?"failed-on-submit":""].filter(Boolean).join(" ");return jsxRuntime.jsx("p",{className:N,children:g.message},g.id??w)})})]})}function be(e,t,r){return react.useMemo(()=>{if(!e||e.length===0)return {satisfied:true,statuses:[]};let o=e.map(n=>dt(n,t,r));return {satisfied:o.every(n=>n.passed),statuses:o}},[e,t,r])}function dt(e,t,r){let o=r[e.depends_on_field_id];if(!o)return {id:e.id,message:"Campo dependente n\xE3o encontrado.",passed:false};let s=t[o.key],n=e.operator,i=e.value,a=o.title,p,d,l=c=>c==null?"":String(c);switch(n){case "exists":{p=s!=null&&s!=="",d=`O campo "${a}" deve estar preenchido.`;break}case "not_exists":{p=s==null||s==="",d=`O campo "${a}" deve estar vazio.`;break}case "equals":{p=l(s)===l(i),d=`O campo "${a}" deve ser igual a "${l(i)}".`;break}case "not_equals":{p=l(s)!==l(i),d=`O campo "${a}" deve ser diferente de "${l(i)}".`;break}case "contains":{p=l(s).includes(l(i)),d=`O campo "${a}" deve conter "${l(i)}".`;break}case "greater_than":{p=Number(s)>Number(i),d=`O campo "${a}" deve ser maior que ${l(i)}.`;break}case "greater_than_equal":{p=Number(s)>=Number(i),d=`O campo "${a}" deve ser maior ou igual a ${l(i)}.`;break}case "lower_than":{p=Number(s)<Number(i),d=`O campo "${a}" deve ser menor que ${l(i)}.`;break}case "lower_than_equal":{p=Number(s)<=Number(i),d=`O campo "${a}" deve ser menor ou igual a ${l(i)}.`;break}case "in":{let c=l(i).split(",").map(h=>h.trim());p=c.includes(l(s));let f=c.join(", ");d=`O campo "${a}" deve ser um dos seguintes: ${f}.`;break}case "not_in":{let c=l(i).split(",").map(h=>h.trim());p=!c.includes(l(s));let f=c.join(", ");d=`O campo "${a}" n\xE3o pode ser um dos seguintes: ${f}.`;break}default:p=false,d=`Operador "${n}" desconhecido.`;}return {passed:p,id:e.id,message:d}}function $({fields:e,values:t,onValueChange:r,submitted:o=false}){if(!e||e.length===0)return null;let s=react.useMemo(()=>e.reduce((i,a)=>(i[a.id]={key:a.key,title:a.title},a.object_id&&(i[a.object_id]={key:a.key,title:a.title}),i),{}),[e]),n=react.useMemo(()=>[...e].sort((i,a)=>i.position-a.position),[e]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n.map(i=>jsxRuntime.jsx(pt,{field:i,values:t,onValueChange:r,submitted:o,fieldsMap:s},i.id))})}function pt({field:e,values:t,onValueChange:r,submitted:o,fieldsMap:s}){let n=be(e.visibility_rules,t,s),a=!(e.visibility_rules&&e.visibility_rules.length>0)||n.satisfied,p=be(e.required_rules,t,s),l=e.required_rules&&e.required_rules.length>0&&p.satisfied,c=e.required||l,f=t[e.key]??e.default_value??"",h=f===""||f===void 0||f===null,v=react.useMemo(()=>{let u=[];return c&&u.push({message:`${e.title} \xE9 obrigat\xF3rio.`,passed:!h}),u},[e.title,c,h]);if(!a)return null;let y={name:e.key,label:e.title,placeholder:e.placeholder,value:String(f),submitted:o,rulesStatus:v,required:c};switch(e.type){case "string":case "email":return jsxRuntime.jsx(S,{...y,type:e.type==="email"?"email":"text",onValueChange:u=>r(e.key,u)});case "int":return jsxRuntime.jsx(S,{...y,type:"number",onValueChange:u=>r(e.key,u)});case "radio":return jsxRuntime.jsxs("div",{className:"trieoh trieoh-input",children:[jsxRuntime.jsxs("label",{className:"trieoh-input__label",children:[e.title,c&&jsxRuntime.jsx("span",{style:{color:"#e74c3c",marginLeft:"4px"},children:"*"})]}),jsxRuntime.jsx("div",{className:"trieoh-radio-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.options?.map(u=>jsxRuntime.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsxRuntime.jsx("input",{type:"radio",name:e.key,value:u.value,checked:f===u.value,onChange:b=>r(e.key,b.target.value)}),jsxRuntime.jsx("span",{children:u.label})]},u.id))}),o&&v.filter(u=>!u.passed).map((u,b)=>jsxRuntime.jsx("span",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"4px",display:"block"},children:u.message},b))]});case "select":return jsxRuntime.jsx(se,{...y,options:e.options||[],onValueChange:u=>r(e.key,u)});case "checkbox":{let u=Array.isArray(t[e.key])?t[e.key]:[];return jsxRuntime.jsxs("div",{className:"trieoh trieoh-input",children:[jsxRuntime.jsxs("label",{className:"trieoh-input__label",children:[e.title,c&&jsxRuntime.jsx("span",{style:{color:"#e74c3c",marginLeft:"4px"},children:"*"})]}),jsxRuntime.jsx("div",{className:"trieoh-checkbox-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.options?.map(b=>jsxRuntime.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsxRuntime.jsx("input",{type:"checkbox",name:e.key,value:b.value,checked:u.includes(b.value),onChange:T=>{let F=T.target.checked?[...u,b.value]:u.filter(E=>E!==b.value);r(e.key,F);}}),jsxRuntime.jsx("span",{children:b.label})]},b.id))}),o&&v.filter(b=>!b.passed).map((b,T)=>jsxRuntime.jsx("span",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"4px",display:"block"},children:b.message},T))]})}case "bool":return jsxRuntime.jsxs("div",{className:"trieoh trieoh-input",style:{flexDirection:"row",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsx("input",{type:"checkbox",id:e.key,name:e.key,checked:!!t[e.key],onChange:u=>r(e.key,u.target.checked)}),jsxRuntime.jsxs("label",{htmlFor:e.key,className:"trieoh-input__label",style:{marginBottom:0},children:[e.title,c&&jsxRuntime.jsx("span",{style:{color:"#e74c3c",marginLeft:"4px"},children:"*"})]}),o&&v.filter(u=>!u.passed).map((u,b)=>jsxRuntime.jsx("span",{style:{color:"#e74c3c",fontSize:"12px",marginLeft:"8px"},children:u.message},b))]});default:return null}}function xe({onSuccess:e,onFailed:t,loginRedirect:r,emailRules:o,passwordRules:s,flow_id:n,fields:i=[]}){let[a,p]=react.useState(""),[d,l]=react.useState(""),[c,f]=react.useState(""),[h,v]=react.useState({}),[y,u]=react.useState(false),[b,T]=react.useState(false),F=react.useRef(null),E=react.useRef(null),g=react.useRef(null),{auth:w}=P(),N=(R,ne)=>{v(ae=>({...ae,[R]:ne}));},L={email:o||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:R=>/\S+@\S+\.\S+/.test(R)}],password:s||[{message:"M\xEDnimo de 8 caracteres.",test:R=>R.length>=8},{message:"Deve conter uma letra mai\xFAscula.",test:R=>/[A-Z]/.test(R)},{message:"Inclua pelo menos um caractere especial, ex: ! @ # $ % & * . ,",test:R=>/[!@#$%^&*(),.?":{}|<>_\-+=~`;/\\[\]]/.test(R)},{message:"Deve conter um n\xFAmero.",test:R=>/\d/.test(R)}],confirmPassword:[{message:"Senhas n\xE3o conferem.",test:R=>R===d}]},Ee=H(L.email,a),ke=H(L.password,d),Pe=H(L.confirmPassword,c);return jsxRuntime.jsxs("form",{className:"trieoh trieoh-card trieoh-card--full-rounded",children:[jsxRuntime.jsx(Y,{mainText:"Crie sua conta",subText:"Insira seus dados para come\xE7ar"}),jsxRuntime.jsxs("div",{className:"trieoh-card__fields",children:[jsxRuntime.jsx(S,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:a,onValueChange:p,inputRef:F,rulesStatus:Ee,submitted:y}),jsxRuntime.jsx(S,{label:"Senha",name:"password",placeholder:"**********",autoComplete:"new-password",type:"password",value:d,onValueChange:l,inputRef:E,rulesStatus:ke,submitted:y}),jsxRuntime.jsx(S,{label:"Confirme a Senha",name:"confirm-password",placeholder:"**********",autoComplete:"new-password",type:"password",value:c,onValueChange:f,inputRef:g,rulesStatus:Pe,submitted:y}),jsxRuntime.jsx($,{fields:i,values:h,onValueChange:N,submitted:y})]}),jsxRuntime.jsx(B,{label:"Criar Conta",onSubmit:async R=>{R.preventDefault(),u(true);let ne=Ee.some(A=>!A.passed),ae=ke.some(A=>!A.passed),je=Pe.some(A=>!A.passed),Ye=i.some(A=>A.required&&!h[A.key]);if(ne){F.current?.focus();return}if(ae){E.current?.focus();return}if(je){g.current?.focus();return}if(Ye)return;T(true);let le=await w.register(a,d,n,h);le.success?e&&await e():t&&await t(le.message,le.trace),T(false);},loading:b}),r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"trieoh-card__divider",children:[jsxRuntime.jsx("hr",{}),"OU",jsxRuntime.jsx("hr",{})]}),jsxRuntime.jsxs("span",{className:"trieoh-card__other",children:["J\xE1 possui uma conta? ",jsxRuntime.jsx("span",{onClick:r,children:"Entre"})]})]})]})}function gt({flowIds:e,...t}){let[r,o]=react.useState(e[0]?.value||"");if(!e||e.length===0)return null;let s=e.find(n=>n.value===r);return jsxRuntime.jsxs("div",{className:"trieoh-tabbed-signup",children:[jsxRuntime.jsx("div",{className:"trieoh-tabbed-signup__header",children:e.map(n=>jsxRuntime.jsx("button",{className:`trieoh-tabbed-signup__tab ${r===n.value?"active":""}`,onClick:()=>o(n.value),type:"button","aria-selected":r===n.value,role:"tab",children:jsxRuntime.jsx("span",{className:"trieoh-tabbed-signup__tab-text",children:n.label})},n.value))}),jsxRuntime.jsx("hr",{}),jsxRuntime.jsx("div",{className:"trieoh-tabbed-signup__content",children:jsxRuntime.jsx(xe,{flow_id:r,...t,fields:s?.fields},r)})]})}function bt({size:e}){let t=e?`trieoh-copyright--${e}`:"";return jsxRuntime.jsxs("span",{className:`trieoh trieoh-copyright ${t}`,children:["\xA9 ",new Date().getFullYear()," TrieOH"]})}function Rt({onSuccess:e,onFailed:t}){let{auth:r}=P(),[o,s]=react.useState(false);return jsxRuntime.jsxs("button",{onClick:async i=>{if(i.preventDefault(),o)return;s(true);let a=await r.logout();a.success&&e?await e():t&&await t(a.message),s(false);},type:"button",disabled:o,className:"trieoh trieoh-button--logout",children:[jsxRuntime.jsx(im.ImExit,{size:24})," ",jsxRuntime.jsx("span",{children:"Log out"})]})}var Me={mobile:fa.FaMobileAlt,tablet:fa.FaTabletAlt,desktop:fa.FaDesktop};function Ve(e){let{device:t,os:r,browser:o}=uaParserJs.UAParser(e);return {deviceType:t.type??"desktop",os:r.name,browser:o.name}}function ze(e){let t=Ve(e);return {device:Pt(t.deviceType),os:t.os,browser:t.browser}}function Pt(e){if(!e)return "desktop";switch(e){case "mobile":return "mobile";case "tablet":return "tablet";default:return "desktop"}}function qe(e){let t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3),o=Math.floor(r/60),s=Math.floor(o/60),n=Math.floor(s/24),i=Math.floor(n/7);return r<60?"agora mesmo":o<60?`${o} minutos atr\xE1s`:s<24?`${s} horas atr\xE1s`:n<7?`${n} dias atr\xE1s`:`${i} semanas atr\xE1s`}function Re({is_current:e,session_id:t,user_agent:r,issued_at:o,user_ip:s,onClick:n}){let i=ze(r),a=Me[i.device];return jsxRuntime.jsx("div",{className:"trieoh-session",children:jsxRuntime.jsxs("div",{className:"trieoh-session__content",children:[jsxRuntime.jsx(a,{size:40}),jsxRuntime.jsxs("div",{className:"trieoh-session__info",children:[jsxRuntime.jsxs("h3",{children:[i.browser," - ",i.os]}),jsxRuntime.jsxs("span",{className:"trieoh-session__meta",children:[e&&jsxRuntime.jsx("strong",{children:"\u2022 Sess\xE3o Atual \u2022"}),jsxRuntime.jsx("span",{children:`${s} - ${qe(o)}`})]})]}),!e&&jsxRuntime.jsx(fa.FaTrashAlt,{size:20,color:"red",onClick:p=>n(p,t)})]})})}function At({revokeAll:e=false,onSuccess:t}){let{auth:r}=P(),[o,s]=react.useState(false),[n,i]=react.useState([]),a=async()=>{let l=await r.sessions();if(l.success){let c=r.profile()?.session_id,f=l.data.sort((h,v)=>h.session_id===c?-1:v.session_id===c?1:0);i(f);}};react.useEffect(()=>{a();},[]);let p=async(l,c)=>{l.preventDefault();let f=n.find(h=>h.session_id===c);if(f){i(n.filter(h=>h.session_id!==c));try{(await r.revokeASession(c)).success||i(v=>[...v,f]);}catch{i(h=>[...h,f]);}}};return jsxRuntime.jsxs("div",{className:"trieoh trieoh-sessions",children:[jsxRuntime.jsxs("div",{className:"trieoh-sessions__header",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{children:"Navegadores e Dispositivos"}),jsxRuntime.jsx("p",{children:"Esses navegadores e dispositivos est\xE3o atualmente conectados \xE0 sua conta. Remova quaisquer dispositivos n\xE3o autorizados."})]}),jsxRuntime.jsx("button",{type:"submit",onClick:async l=>{if(l.preventDefault(),o)return;s(true);let c=await r.revokeSessions(e),f=r.profile()?.session_id;c.success&&(i(e?[]:n.filter(h=>h.session_id===f)),t&&t()),s(false);},disabled:o,className:`trieoh trieoh-button trieoh-button--all-rounded
|
|
5
|
+
${o?"trieoh-button--loading":""}`,children:"Revogar todas as sess\xF5es"})]}),jsxRuntime.jsx("div",{className:"trieoh-sessions__content",children:n.length>0?n.map(l=>jsxRuntime.jsx(Re,{...l,is_current:r.profile()?.session_id===l.session_id,onClick:p},l.session_id)):jsxRuntime.jsx("span",{className:"trieoh-sessions__empty",children:"Nenhuma Sess\xE3o Dispon\xEDvel"})})]})}function Ot({fields:e,initialValues:t,onSuccess:r,onFailed:o,submitLabel:s="Atualizar Dados"}){let[n,i]=react.useState(t||{}),[a,p]=react.useState(false),[d,l]=react.useState(false),{auth:c}=P();return react.useEffect(()=>{t&&i(t);},[t]),jsxRuntime.jsxs("form",{className:"trieoh trieoh-card trieoh-card--full-rounded",children:[jsxRuntime.jsx("div",{className:"trieoh-card__fields",children:jsxRuntime.jsx($,{fields:e,values:n,onValueChange:(v,y)=>{i(u=>({...u,[v]:y}));},submitted:a})}),jsxRuntime.jsx(B,{label:s,onSubmit:async v=>{if(v.preventDefault(),p(true),e.some(b=>b.required&&!n[b.key]))return;l(true);let u=await c.updateProfile(n);u.success?r&&await r():o&&await o(u.message,u.trace),l(false);},loading:d})]})}function Lt({fields:e,submitted:t=false,title:r,description:o,noFieldsMessage:s="No fields available"}){let[n,i]=react.useState({}),a=(p,d)=>{i(l=>({...l,[p]:d}));};return jsxRuntime.jsxs("div",{className:"trieoh trieoh-card trieoh-card--full-rounded",style:{gap:"0.25rem"},children:[(r||o)&&jsxRuntime.jsxs("div",{style:{width:"100%",textAlign:"center"},children:[r&&jsxRuntime.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600},children:r}),o&&jsxRuntime.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.875rem",opacity:.7},children:o}),jsxRuntime.jsx("hr",{style:{marginTop:"1rem",border:0,borderTop:"1px solid rgba(0,0,0,0.1)",marginBottom:"0.5rem"}})]}),jsxRuntime.jsx("div",{className:"trieoh-card__fields",children:e&&e.length>0?jsxRuntime.jsx($,{fields:e,values:n,onValueChange:a,submitted:t}):jsxRuntime.jsx("div",{className:"trieoh-card__empty",children:s})})]})}exports.AuthProvider=hr;exports.BasicInputField=S;exports.BasicLogoutButton=Rt;exports.BasicSelectField=se;exports.Copyright=bt;exports.EditorForm=Lt;exports.Sessions=At;exports.SignIn=nt;exports.SignUp=xe;exports.TabbedSignUp=gt;exports.UpdateProfile=Ot;exports.useAuth=P;//# sourceMappingURL=react.js.map
|
|
6
|
+
//# sourceMappingURL=react.js.map
|