@fluid-app/rep-sdk 0.1.4 → 0.1.6
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/dist/MessagingScreen-TWFEUBE3.js +4 -0
- package/dist/{MessagingScreen-5TEWFUX4.js.map → MessagingScreen-TWFEUBE3.js.map} +1 -1
- package/dist/MessagingScreen-ZATI4W3W.cjs +17 -0
- package/dist/{MessagingScreen-JC7I55NG.cjs.map → MessagingScreen-ZATI4W3W.cjs.map} +1 -1
- package/dist/{chunk-OE62VIZU.cjs → chunk-4UJ7ZPDE.cjs} +32 -432
- package/dist/chunk-4UJ7ZPDE.cjs.map +1 -0
- package/dist/{chunk-R4SXB6EV.js → chunk-PFXVDCYO.js} +6 -391
- package/dist/chunk-PFXVDCYO.js.map +1 -0
- package/dist/index.cjs +137 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -471
- package/dist/index.d.ts +6 -471
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/MessagingScreen-5TEWFUX4.js +0 -4
- package/dist/MessagingScreen-JC7I55NG.cjs +0 -17
- package/dist/chunk-OE62VIZU.cjs.map +0 -1
- package/dist/chunk-R4SXB6EV.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,9 @@ import { WidgetSchema, ThemeDefinition, ScreenDefinition as ScreenDefinition$1,
|
|
|
8
8
|
export { AlignOptions, BackgroundType, BackgroundValue, BorderRadiusOptions, ButtonSizeOptions, ColorOptions, FontSizeOptions, GapOptions, NavigationItem, PaddingOptions, RepAppData, RepAppManifest, RepAppProfile, ResolvedTheme, SectionLayoutType, ShareableItem, ThemeColorInput, ThemeDefinition, ThemePayload, TypedWidgetSchema, WIDGET_TYPE_NAMES, WidgetPath, WidgetRegistry, WidgetSchema, WidgetType, WidgetTypeName, assertDefined, assertNever, isWidgetType, isWidgetTypeName, sectionLayoutConfig } from '@fluid-app/rep-core/types';
|
|
9
9
|
import { RawApiTheme } from '@fluid-app/rep-core/theme';
|
|
10
10
|
export { DEFAULT_COLORS, DEFAULT_FONT_FAMILIES, DEFAULT_FONT_SIZES, DEFAULT_RADII, DEFAULT_SPACING, DEFAULT_THEME_ID, DEFAULT_THEME_NAME, FONT_FAMILY_KEYS, FONT_SIZE_KEYS, FontFamilyKey, FontSizeKey, GenerateThemeCSSOptions, OklchPlain, RADIUS_KEYS, RadiusKey, RawApiTheme, ResolvedColorSet, ResolvedSemanticColor, SEMANTIC_COLOR_NAMES, SHADE_STEPS, SemanticColorName, ShadeStep, ThemeColorPlain, applyTheme, buildThemeDefinition, deriveDarkVariant, deserialiseTheme, generateShades, generateThemeCSS, getActiveThemeId, getDefaultThemeDefinition, getForegroundColor, mergeDarkOverrides, parseColor, removeAllThemes, removeTheme, resolveTheme, serialiseTheme, transformThemes } from '@fluid-app/rep-core/theme';
|
|
11
|
+
import { components } from '@fluid-app/fluidos-api-client';
|
|
12
|
+
import { FluidAuthConfig, FluidAuthContextValue } from '@fluid-app/auth';
|
|
13
|
+
export { AUTH_CONSTANTS, DEFAULT_AUTH_URL, FluidAuthConfig, FluidAuthContextValue, JWTPayload, STORAGE_KEYS, TokenValidationResult, URL_PARAMS, USER_TYPES, UserType, cleanTokenFromUrl, clearTokens, createDefaultAuthRedirect, decodeToken, extractAllTokensFromUrl, extractCompanyTokenFromUrl, extractTokenFromUrl, getStoredToken, getTokenExpiration, getTokenTimeRemaining, hasStoredToken, hasTokenInUrl, isTokenExpired, isUserType, isValidToken, storeToken, validateToken } from '@fluid-app/auth';
|
|
11
14
|
import { MessagingAuthContext, FileUploader } from '@fluid-app/fluid-messaging-core';
|
|
12
15
|
export { FileUploader, MessagingAuthContext, MessagingCurrentUser, UploadCallbacks, UploadResult } from '@fluid-app/fluid-messaging-core';
|
|
13
16
|
import { MessagingApiConfig } from '@fluid-app/fluid-messaging-api-client';
|
|
@@ -353,17 +356,8 @@ declare function toScreenDefinition(screen: RawApiScreen): ScreenDefinition$1;
|
|
|
353
356
|
* - apps/fluid-admin/networking/reps/screens.api.ts
|
|
354
357
|
*/
|
|
355
358
|
|
|
356
|
-
/** Raw navigation item from the FluidOS API */
|
|
357
|
-
|
|
358
|
-
id: number | string;
|
|
359
|
-
label?: string | null;
|
|
360
|
-
slug?: string | null;
|
|
361
|
-
icon?: string | null;
|
|
362
|
-
screen_id?: number | string | null;
|
|
363
|
-
parent_id?: number | string | null;
|
|
364
|
-
position?: number | null;
|
|
365
|
-
children?: RawApiNavigationItem[];
|
|
366
|
-
}
|
|
359
|
+
/** Raw navigation item from the FluidOS API (derived from generated types) */
|
|
360
|
+
type RawApiNavigationItem = components["schemas"]["FluidOSNavigationItem"];
|
|
367
361
|
/**
|
|
368
362
|
* Convert a raw FluidOS navigation item to NavigationItem.
|
|
369
363
|
* Recursively transforms children and sorts by position.
|
|
@@ -672,153 +666,6 @@ declare function FluidThemeProvider({ children, initialTheme, container, }: Flui
|
|
|
672
666
|
*/
|
|
673
667
|
declare function useThemeContext(): ThemeContextValue;
|
|
674
668
|
|
|
675
|
-
/**
|
|
676
|
-
* Auth Types for Fluid Rep SDK
|
|
677
|
-
*
|
|
678
|
-
* These types define the JWT payload structure and authentication
|
|
679
|
-
* configuration options for rep portal applications.
|
|
680
|
-
*/
|
|
681
|
-
/**
|
|
682
|
-
* User type constant - single source of truth for user role values.
|
|
683
|
-
* Use USER_TYPES.admin instead of "admin" for type-safe comparisons.
|
|
684
|
-
*/
|
|
685
|
-
declare const USER_TYPES: {
|
|
686
|
-
readonly admin: "admin";
|
|
687
|
-
readonly rep: "rep";
|
|
688
|
-
readonly root_admin: "root_admin";
|
|
689
|
-
readonly customer: "customer";
|
|
690
|
-
};
|
|
691
|
-
/**
|
|
692
|
-
* Union type of all user types, derived from USER_TYPES constant.
|
|
693
|
-
* @see deriving-typeof-for-object-keys pattern
|
|
694
|
-
*/
|
|
695
|
-
type UserType = (typeof USER_TYPES)[keyof typeof USER_TYPES];
|
|
696
|
-
/**
|
|
697
|
-
* Runtime validation for user types.
|
|
698
|
-
* @param value - The value to check
|
|
699
|
-
* @returns true if value is a valid UserType
|
|
700
|
-
*/
|
|
701
|
-
declare function isUserType(value: string): value is UserType;
|
|
702
|
-
/**
|
|
703
|
-
* JWT payload structure from Fluid Commerce authentication.
|
|
704
|
-
* Contains user identity and role information.
|
|
705
|
-
*/
|
|
706
|
-
interface JWTPayload {
|
|
707
|
-
/** User ID */
|
|
708
|
-
id?: number | undefined;
|
|
709
|
-
/** User email address */
|
|
710
|
-
email?: string | undefined;
|
|
711
|
-
/** Full name of the user */
|
|
712
|
-
full_name?: string | undefined;
|
|
713
|
-
/** User role type */
|
|
714
|
-
user_type: UserType;
|
|
715
|
-
/** Original user type (for impersonation scenarios) */
|
|
716
|
-
og_user_type?: UserType | undefined;
|
|
717
|
-
/** Company ID the user belongs to */
|
|
718
|
-
company_id?: number | undefined;
|
|
719
|
-
/** Token expiration timestamp (Unix seconds) */
|
|
720
|
-
exp?: number | undefined;
|
|
721
|
-
/** Authentication type (e.g., "standard", "impersonation") */
|
|
722
|
-
auth_type?: string | undefined;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Configuration options for FluidAuthProvider.
|
|
726
|
-
* All options have sensible defaults.
|
|
727
|
-
*/
|
|
728
|
-
interface FluidAuthConfig {
|
|
729
|
-
/**
|
|
730
|
-
* URL parameter name for the auth token.
|
|
731
|
-
* @default "fluidUserToken"
|
|
732
|
-
*/
|
|
733
|
-
tokenKey?: string;
|
|
734
|
-
/**
|
|
735
|
-
* Cookie name for storing the auth token.
|
|
736
|
-
* @default "auth_token"
|
|
737
|
-
*/
|
|
738
|
-
cookieKey?: string;
|
|
739
|
-
/**
|
|
740
|
-
* Cookie max age in seconds.
|
|
741
|
-
* @default 777600 (9 days)
|
|
742
|
-
*/
|
|
743
|
-
cookieMaxAge?: number;
|
|
744
|
-
/**
|
|
745
|
-
* Grace period in milliseconds to account for clock skew
|
|
746
|
-
* when checking token expiration.
|
|
747
|
-
* @default 30000 (30 seconds)
|
|
748
|
-
*/
|
|
749
|
-
gracePeriodMs?: number;
|
|
750
|
-
/**
|
|
751
|
-
* Callback invoked when authentication fails (no valid token).
|
|
752
|
-
* When omitted, the SDK redirects to `authUrl` with the current URL
|
|
753
|
-
* as a redirect parameter so users can log in and return.
|
|
754
|
-
*/
|
|
755
|
-
onAuthFailure?: () => void;
|
|
756
|
-
/**
|
|
757
|
-
* Base URL for the authentication page.
|
|
758
|
-
* Used by the default auth failure redirect when `onAuthFailure` is not provided.
|
|
759
|
-
* Ignored when a custom `onAuthFailure` callback is set.
|
|
760
|
-
* @default "https://auth.fluid.app"
|
|
761
|
-
*/
|
|
762
|
-
authUrl?: string;
|
|
763
|
-
/**
|
|
764
|
-
* Enable dev-mode auth bypass.
|
|
765
|
-
* When true AND running in Vite dev mode (import.meta.env.DEV),
|
|
766
|
-
* auth will use a synthetic mock user instead of requiring a real JWT.
|
|
767
|
-
* The mock user allows UI rendering but API calls will fail (token is null).
|
|
768
|
-
* @default false
|
|
769
|
-
*/
|
|
770
|
-
devBypass?: boolean;
|
|
771
|
-
/**
|
|
772
|
-
* JWKS (JSON Web Key Set) URL for signature verification.
|
|
773
|
-
* When provided, JWT signatures will be verified against keys
|
|
774
|
-
* from this endpoint before accepting the token.
|
|
775
|
-
*
|
|
776
|
-
* This provides defense-in-depth client-side verification.
|
|
777
|
-
* Without this, tokens are only decoded (not verified) client-side,
|
|
778
|
-
* and real verification happens server-side on API calls.
|
|
779
|
-
*
|
|
780
|
-
* @example "https://api.fluid.app/.well-known/jwks.json"
|
|
781
|
-
*/
|
|
782
|
-
jwksUrl?: string;
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Value provided by the FluidAuthContext.
|
|
786
|
-
* All properties are readonly since context values should not be mutated by consumers.
|
|
787
|
-
*/
|
|
788
|
-
interface FluidAuthContextValue {
|
|
789
|
-
/** Whether the user is authenticated with a valid token */
|
|
790
|
-
readonly isAuthenticated: boolean;
|
|
791
|
-
/** Whether authentication is still being initialized */
|
|
792
|
-
readonly isLoading: boolean;
|
|
793
|
-
/** Decoded JWT payload if authenticated, null otherwise */
|
|
794
|
-
readonly user: JWTPayload | null;
|
|
795
|
-
/** Raw JWT token string if authenticated, null otherwise */
|
|
796
|
-
readonly token: string | null;
|
|
797
|
-
/** Clear authentication state and stored tokens */
|
|
798
|
-
readonly clearAuth: () => void;
|
|
799
|
-
/** Authentication error if any occurred during initialization */
|
|
800
|
-
readonly error: Error | null;
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Result of token validation.
|
|
804
|
-
* Uses a discriminated union for type-safe handling of valid/invalid states.
|
|
805
|
-
*/
|
|
806
|
-
type TokenValidationResult = {
|
|
807
|
-
/** Token is valid */
|
|
808
|
-
isValid: true;
|
|
809
|
-
/** Decoded JWT payload */
|
|
810
|
-
payload: JWTPayload;
|
|
811
|
-
/** No error when valid */
|
|
812
|
-
error?: undefined;
|
|
813
|
-
} | {
|
|
814
|
-
/** Token is invalid */
|
|
815
|
-
isValid: false;
|
|
816
|
-
/** Decoded JWT payload if parseable but expired */
|
|
817
|
-
payload?: JWTPayload;
|
|
818
|
-
/** Error message explaining why validation failed */
|
|
819
|
-
error: string;
|
|
820
|
-
};
|
|
821
|
-
|
|
822
669
|
interface FluidAuthProviderProps {
|
|
823
670
|
/** React children to wrap with auth context */
|
|
824
671
|
children: ReactNode;
|
|
@@ -1753,318 +1600,6 @@ declare function useContacts(_params?: UseContactsParams): UseContactsResult;
|
|
|
1753
1600
|
*/
|
|
1754
1601
|
declare function useContact(_contactId: string): UseContactResult;
|
|
1755
1602
|
|
|
1756
|
-
/**
|
|
1757
|
-
* Auth Constants for Fluid Rep SDK
|
|
1758
|
-
*
|
|
1759
|
-
* These constants define the default values for authentication
|
|
1760
|
-
* configuration and storage keys.
|
|
1761
|
-
*/
|
|
1762
|
-
/**
|
|
1763
|
-
* Authentication-related constants with sensible defaults.
|
|
1764
|
-
*/
|
|
1765
|
-
declare const AUTH_CONSTANTS: {
|
|
1766
|
-
/**
|
|
1767
|
-
* Grace period in milliseconds to account for clock skew
|
|
1768
|
-
* when checking token expiration. Tokens are considered valid
|
|
1769
|
-
* if they expire within this period.
|
|
1770
|
-
*/
|
|
1771
|
-
readonly TOKEN_GRACE_PERIOD_MS: number;
|
|
1772
|
-
/**
|
|
1773
|
-
* Default cookie max age in seconds (9 days).
|
|
1774
|
-
* This matches the typical JWT token lifetime from the Fluid API.
|
|
1775
|
-
*/
|
|
1776
|
-
readonly COOKIE_MAX_AGE: number;
|
|
1777
|
-
};
|
|
1778
|
-
/**
|
|
1779
|
-
* Storage keys for auth tokens.
|
|
1780
|
-
*/
|
|
1781
|
-
declare const STORAGE_KEYS: {
|
|
1782
|
-
/** localStorage key for user token */
|
|
1783
|
-
readonly USER_TOKEN: "fluidUserToken";
|
|
1784
|
-
/** localStorage key for company token (legacy) */
|
|
1785
|
-
readonly COMPANY_TOKEN: "fluidCompanyToken";
|
|
1786
|
-
/** Cookie name for auth token */
|
|
1787
|
-
readonly AUTH_COOKIE: "auth_token";
|
|
1788
|
-
};
|
|
1789
|
-
/**
|
|
1790
|
-
* Default URL parameter names for token extraction.
|
|
1791
|
-
*/
|
|
1792
|
-
declare const URL_PARAMS: {
|
|
1793
|
-
/** URL parameter name for user token */
|
|
1794
|
-
readonly USER_TOKEN: "fluidUserToken";
|
|
1795
|
-
/** URL parameter name for company token (legacy) */
|
|
1796
|
-
readonly COMPANY_TOKEN: "fluidCompanyToken";
|
|
1797
|
-
};
|
|
1798
|
-
|
|
1799
|
-
/**
|
|
1800
|
-
* Auth Redirect Utilities
|
|
1801
|
-
*
|
|
1802
|
-
* Provides default redirect behavior for authentication failures.
|
|
1803
|
-
* When no custom callback is provided, the SDK redirects to Fluid's
|
|
1804
|
-
* auth page with a redirect_url pointing back to the current page.
|
|
1805
|
-
*
|
|
1806
|
-
* Includes loop detection: if a redirect was attempted within the
|
|
1807
|
-
* cooldown window, subsequent calls are suppressed to prevent
|
|
1808
|
-
* infinite redirect cycles (e.g., auth returns a token the API rejects).
|
|
1809
|
-
*/
|
|
1810
|
-
/**
|
|
1811
|
-
* Default Fluid authentication URL.
|
|
1812
|
-
* Users are redirected here when auth fails and no custom handler is provided.
|
|
1813
|
-
*/
|
|
1814
|
-
declare const DEFAULT_AUTH_URL = "https://auth.fluid.app";
|
|
1815
|
-
/**
|
|
1816
|
-
* Creates a redirect function that navigates to the auth URL
|
|
1817
|
-
* with the current page URL encoded as a redirect parameter.
|
|
1818
|
-
*
|
|
1819
|
-
* Includes loop detection: if a redirect was attempted within the last
|
|
1820
|
-
* {@link REDIRECT_COOLDOWN_S} seconds, the redirect is suppressed and
|
|
1821
|
-
* the normal error UI is allowed to render instead.
|
|
1822
|
-
*
|
|
1823
|
-
* @param authUrl - Custom auth URL to redirect to. Defaults to DEFAULT_AUTH_URL.
|
|
1824
|
-
* @returns A function that performs the redirect when called (no-op if loop detected).
|
|
1825
|
-
*
|
|
1826
|
-
* @example
|
|
1827
|
-
* ```ts
|
|
1828
|
-
* const redirect = createDefaultAuthRedirect();
|
|
1829
|
-
* // Redirects to: https://auth.fluid.app/?redirect_url=https%3A%2F%2Fmy-portal.com%2Fdashboard
|
|
1830
|
-
* redirect();
|
|
1831
|
-
* ```
|
|
1832
|
-
*/
|
|
1833
|
-
declare function createDefaultAuthRedirect(authUrl?: string): () => void;
|
|
1834
|
-
|
|
1835
|
-
/**
|
|
1836
|
-
* Token Utilities for Fluid Rep SDK
|
|
1837
|
-
*
|
|
1838
|
-
* Functions for decoding, validating, and checking JWT tokens.
|
|
1839
|
-
*/
|
|
1840
|
-
|
|
1841
|
-
/**
|
|
1842
|
-
* Decode a JWT token and extract its payload.
|
|
1843
|
-
*
|
|
1844
|
-
* **Security note:** This function does NOT verify the JWT signature.
|
|
1845
|
-
* It only decodes the payload. Any valid JWT structure will be accepted,
|
|
1846
|
-
* regardless of who signed it.
|
|
1847
|
-
*
|
|
1848
|
-
* Client-side token decoding is used for UX purposes only (displaying
|
|
1849
|
-
* user info, role-based UI). The real security boundary is the server-side
|
|
1850
|
-
* API, which verifies the signature on every request.
|
|
1851
|
-
*
|
|
1852
|
-
* For signature verification, use {@link verifyToken} with a JWKS URL.
|
|
1853
|
-
*
|
|
1854
|
-
* @param token - The JWT token string
|
|
1855
|
-
* @returns The decoded JWT payload, or null if decoding fails
|
|
1856
|
-
*
|
|
1857
|
-
* @example
|
|
1858
|
-
* ```ts
|
|
1859
|
-
* const payload = decodeToken(token);
|
|
1860
|
-
* if (payload) {
|
|
1861
|
-
* console.log(`User: ${payload.email}`);
|
|
1862
|
-
* }
|
|
1863
|
-
* ```
|
|
1864
|
-
*/
|
|
1865
|
-
declare function decodeToken(token: string): JWTPayload | null;
|
|
1866
|
-
/**
|
|
1867
|
-
* Check if a token has expired.
|
|
1868
|
-
* Includes a configurable grace period to account for clock skew.
|
|
1869
|
-
*
|
|
1870
|
-
* @param token - The JWT token string
|
|
1871
|
-
* @param gracePeriodMs - Grace period in milliseconds (default: 30 seconds)
|
|
1872
|
-
* @returns true if the token is expired, false otherwise
|
|
1873
|
-
*
|
|
1874
|
-
* @example
|
|
1875
|
-
* ```ts
|
|
1876
|
-
* if (isTokenExpired(token)) {
|
|
1877
|
-
* // Token is expired, need to re-authenticate
|
|
1878
|
-
* clearAuth();
|
|
1879
|
-
* }
|
|
1880
|
-
* ```
|
|
1881
|
-
*/
|
|
1882
|
-
declare function isTokenExpired(token: string, gracePeriodMs?: number): boolean;
|
|
1883
|
-
/**
|
|
1884
|
-
* Validate a JWT token for format and expiration.
|
|
1885
|
-
*
|
|
1886
|
-
* **Security note:** This function checks JWT structure and expiration
|
|
1887
|
-
* but does NOT verify the signature. It is a UX-level check only.
|
|
1888
|
-
* For signature verification, use {@link verifyToken} with a JWKS URL.
|
|
1889
|
-
*
|
|
1890
|
-
* @param token - The JWT token string
|
|
1891
|
-
* @param gracePeriodMs - Grace period for expiration check (default: 30 seconds)
|
|
1892
|
-
* @returns Validation result with status and decoded payload if valid
|
|
1893
|
-
*
|
|
1894
|
-
* @example
|
|
1895
|
-
* ```ts
|
|
1896
|
-
* const result = validateToken(token);
|
|
1897
|
-
* if (result.isValid) {
|
|
1898
|
-
* console.log(`Welcome, ${result.payload?.full_name}`);
|
|
1899
|
-
* } else {
|
|
1900
|
-
* console.error(`Auth failed: ${result.error}`);
|
|
1901
|
-
* }
|
|
1902
|
-
* ```
|
|
1903
|
-
*/
|
|
1904
|
-
declare function validateToken(token: string, gracePeriodMs?: number): TokenValidationResult;
|
|
1905
|
-
/**
|
|
1906
|
-
* Type guard to check if a validation result is valid.
|
|
1907
|
-
* Enables TypeScript narrowing of the result type.
|
|
1908
|
-
*
|
|
1909
|
-
* @param result - The validation result to check
|
|
1910
|
-
* @returns true if the token is valid (narrows payload to non-optional)
|
|
1911
|
-
*
|
|
1912
|
-
* @example
|
|
1913
|
-
* ```ts
|
|
1914
|
-
* const result = validateToken(token);
|
|
1915
|
-
* if (isValidToken(result)) {
|
|
1916
|
-
* // result.payload is guaranteed to be JWTPayload (not undefined)
|
|
1917
|
-
* console.log(result.payload.email);
|
|
1918
|
-
* }
|
|
1919
|
-
* ```
|
|
1920
|
-
*/
|
|
1921
|
-
declare function isValidToken(result: TokenValidationResult): result is TokenValidationResult & {
|
|
1922
|
-
isValid: true;
|
|
1923
|
-
payload: JWTPayload;
|
|
1924
|
-
};
|
|
1925
|
-
/**
|
|
1926
|
-
* Get the expiration time of a token as a Date.
|
|
1927
|
-
*
|
|
1928
|
-
* @param token - The JWT token string
|
|
1929
|
-
* @returns The expiration Date, or null if token has no expiration or is invalid
|
|
1930
|
-
*/
|
|
1931
|
-
declare function getTokenExpiration(token: string): Date | null;
|
|
1932
|
-
/**
|
|
1933
|
-
* Get the time remaining until token expiration in milliseconds.
|
|
1934
|
-
*
|
|
1935
|
-
* @param token - The JWT token string
|
|
1936
|
-
* @returns Milliseconds until expiration, or 0 if expired/invalid, or Infinity if no expiration
|
|
1937
|
-
*/
|
|
1938
|
-
declare function getTokenTimeRemaining(token: string): number;
|
|
1939
|
-
|
|
1940
|
-
/**
|
|
1941
|
-
* Token Storage Utilities for Fluid Rep SDK
|
|
1942
|
-
*
|
|
1943
|
-
* Functions for storing and retrieving auth tokens from
|
|
1944
|
-
* cookies and localStorage.
|
|
1945
|
-
*/
|
|
1946
|
-
|
|
1947
|
-
/**
|
|
1948
|
-
* Get the stored auth token.
|
|
1949
|
-
* Checks cookie first, then falls back to localStorage.
|
|
1950
|
-
*
|
|
1951
|
-
* @param config - Optional auth config for custom cookie key
|
|
1952
|
-
* @returns The stored token or null if not found
|
|
1953
|
-
*
|
|
1954
|
-
* @example
|
|
1955
|
-
* ```ts
|
|
1956
|
-
* const token = getStoredToken();
|
|
1957
|
-
* if (token) {
|
|
1958
|
-
* console.log("User is logged in");
|
|
1959
|
-
* }
|
|
1960
|
-
* ```
|
|
1961
|
-
*/
|
|
1962
|
-
declare function getStoredToken(config?: FluidAuthConfig): string | null;
|
|
1963
|
-
/**
|
|
1964
|
-
* Store an auth token in both cookie and localStorage.
|
|
1965
|
-
* Using both provides redundancy and compatibility with different auth flows.
|
|
1966
|
-
*
|
|
1967
|
-
* @param token - The JWT token to store
|
|
1968
|
-
* @param config - Optional auth config for custom storage options
|
|
1969
|
-
*
|
|
1970
|
-
* @example
|
|
1971
|
-
* ```ts
|
|
1972
|
-
* storeToken(newToken);
|
|
1973
|
-
* // Token is now accessible via getStoredToken()
|
|
1974
|
-
* ```
|
|
1975
|
-
*/
|
|
1976
|
-
declare function storeToken(token: string, config?: FluidAuthConfig): void;
|
|
1977
|
-
/**
|
|
1978
|
-
* Clear all stored auth tokens from cookies and localStorage.
|
|
1979
|
-
*
|
|
1980
|
-
* @param config - Optional auth config for custom cookie key
|
|
1981
|
-
*
|
|
1982
|
-
* @example
|
|
1983
|
-
* ```ts
|
|
1984
|
-
* // User logs out
|
|
1985
|
-
* clearTokens();
|
|
1986
|
-
* ```
|
|
1987
|
-
*/
|
|
1988
|
-
declare function clearTokens(config?: FluidAuthConfig): void;
|
|
1989
|
-
/**
|
|
1990
|
-
* Check if any auth token is stored.
|
|
1991
|
-
*
|
|
1992
|
-
* @param config - Optional auth config
|
|
1993
|
-
* @returns true if a token is stored, false otherwise
|
|
1994
|
-
*/
|
|
1995
|
-
declare function hasStoredToken(config?: FluidAuthConfig): boolean;
|
|
1996
|
-
|
|
1997
|
-
/**
|
|
1998
|
-
* URL Token Utilities for Fluid Rep SDK
|
|
1999
|
-
*
|
|
2000
|
-
* Functions for extracting and cleaning auth tokens from URL parameters.
|
|
2001
|
-
* This is the primary way tokens are passed from the parent Fluid Commerce
|
|
2002
|
-
* app to embedded rep portals.
|
|
2003
|
-
*
|
|
2004
|
-
* **Security model**: Tokens in URL parameters are a known tradeoff.
|
|
2005
|
-
* The token is extracted and immediately cleaned from the URL via
|
|
2006
|
-
* `history.replaceState()`. A `Referrer-Policy` meta tag in the
|
|
2007
|
-
* starter template prevents the token from leaking in referrer headers.
|
|
2008
|
-
* See docs/authentication.md for full security analysis.
|
|
2009
|
-
*/
|
|
2010
|
-
/**
|
|
2011
|
-
* Extract the auth token from the URL query parameters.
|
|
2012
|
-
*
|
|
2013
|
-
* @param tokenKey - The URL parameter name (default: "fluidUserToken")
|
|
2014
|
-
* @returns The token value or null if not present
|
|
2015
|
-
*
|
|
2016
|
-
* @example
|
|
2017
|
-
* ```ts
|
|
2018
|
-
* // URL: https://myportal.com?fluidUserToken=eyJhbG...
|
|
2019
|
-
* const token = extractTokenFromUrl();
|
|
2020
|
-
* // token = "eyJhbG..."
|
|
2021
|
-
* ```
|
|
2022
|
-
*/
|
|
2023
|
-
declare function extractTokenFromUrl(tokenKey?: string): string | null;
|
|
2024
|
-
/**
|
|
2025
|
-
* Extract the company token from the URL query parameters.
|
|
2026
|
-
* This is a legacy parameter that may still be used in some flows.
|
|
2027
|
-
*
|
|
2028
|
-
* @param tokenKey - The URL parameter name (default: "fluidCompanyToken")
|
|
2029
|
-
* @returns The token value or null if not present
|
|
2030
|
-
*/
|
|
2031
|
-
declare function extractCompanyTokenFromUrl(tokenKey?: string): string | null;
|
|
2032
|
-
/**
|
|
2033
|
-
* Remove the auth token from the URL without reloading the page.
|
|
2034
|
-
* This prevents the token from being accidentally shared via URL copy/paste
|
|
2035
|
-
* or appearing in browser history.
|
|
2036
|
-
*
|
|
2037
|
-
* Uses history.replaceState to update the URL cleanly.
|
|
2038
|
-
*
|
|
2039
|
-
* @param tokenKey - The URL parameter name to remove (default: "fluidUserToken")
|
|
2040
|
-
*
|
|
2041
|
-
* @example
|
|
2042
|
-
* ```ts
|
|
2043
|
-
* // Before: https://myportal.com?fluidUserToken=eyJhbG...&page=1
|
|
2044
|
-
* cleanTokenFromUrl();
|
|
2045
|
-
* // After: https://myportal.com?page=1
|
|
2046
|
-
* ```
|
|
2047
|
-
*/
|
|
2048
|
-
declare function cleanTokenFromUrl(tokenKey?: string): void;
|
|
2049
|
-
/**
|
|
2050
|
-
* Check if the URL contains an auth token parameter.
|
|
2051
|
-
*
|
|
2052
|
-
* @param tokenKey - The URL parameter name (default: "fluidUserToken")
|
|
2053
|
-
* @returns true if the URL contains the token parameter
|
|
2054
|
-
*/
|
|
2055
|
-
declare function hasTokenInUrl(tokenKey?: string): boolean;
|
|
2056
|
-
/**
|
|
2057
|
-
* Extract all auth-related tokens from the URL at once.
|
|
2058
|
-
*
|
|
2059
|
-
* @param userTokenKey - The URL parameter name for user token
|
|
2060
|
-
* @param companyTokenKey - The URL parameter name for company token
|
|
2061
|
-
* @returns Object with both token values (or null if not present)
|
|
2062
|
-
*/
|
|
2063
|
-
declare function extractAllTokensFromUrl(userTokenKey?: string, companyTokenKey?: string): {
|
|
2064
|
-
userToken: string | null;
|
|
2065
|
-
companyToken: string | null;
|
|
2066
|
-
};
|
|
2067
|
-
|
|
2068
1603
|
interface RequireAuthProps {
|
|
2069
1604
|
/** Content to render when authenticated */
|
|
2070
1605
|
children: ReactNode;
|
|
@@ -2600,4 +2135,4 @@ declare function matchSlugPrefix(fullSlug: string, navSlugs: string[]): SlugMatc
|
|
|
2600
2135
|
declare function extractSlugFromPathname(pathname: string, basePath: string): string;
|
|
2601
2136
|
declare function isSlugInSection(item: NavigationItem, currentSlug: string, navSlugs: string[]): boolean;
|
|
2602
2137
|
|
|
2603
|
-
export { ACTIVITY_SLUGS, APP_DATA_QUERY_KEY,
|
|
2138
|
+
export { ACTIVITY_SLUGS, APP_DATA_QUERY_KEY, type Activity as ActivityItem, type ActivitySlug, ApiError, AppLink, type AppLinkProps, type AppNavigationContextValue, AppNavigationProvider, type AppNavigationProviderProps, AppShell, type AppShellProps, AuthError, type AuthErrorProps, AuthLoading, type BaseListParams, BuilderScreenView, type BuilderScreenViewProps, CORE_PAGE_IDS, CURRENT_REP_QUERY_KEY, type CalendarEvent, type CatchUp as CatchUpItem, type Contact, type ContactAddress, type ContactStatus, type ContactType, ContactsScreen, type Conversation, type ConversationStatus, type CreateOrderData, CustomersScreen, DEFAULT_SDK_WIDGET_REGISTRY, type DashboardData, FluidAuthProvider, type FluidAuthProviderProps, type FluidClient, FluidProvider, type FluidProviderProps, type FluidSDKConfig, FluidThemeProvider, type FluidThemeProviderProps, type ListQueryResult, type Message, type MessageType, type MessagingConfig, MessagingScreen, type MySiteData, type Navigation, type Order, type OrderLineItem, type OrderListParams, OrdersScreen, PAGE_CATEGORIES, PERMISSIONS_QUERY_KEY, PROFILE_QUERY_KEY, type PageCategory, type PageCategoryId, type PageOverride, type PageReference, PageRouter, type PageRouterProps, type PageTemplate, PageTemplateProvider, PageTemplateRegistry, type PaginationParams, type Participant, type PermissionAction, type Permissions, type Product, type ProductListParams, ProductsScreen, type Profile, type QueryResult, type QueryResultNullable, QuickLinksDropdown, type QuickLinksDropdownProps, type RawApiNavigationItem, type RawApiScreen, type RawManifestResponse, type Rep, type RequestOptions, RequireAuth, type RequireAuthProps, type ResourcePermissions, type SalesData, type SalesDataPoint, type SalesParams, type ScreenDefinition, SdkHeader, type SdkHeaderProps, SdkNavigation, type SdkNavigationProps, type SlugMatch, type Todo as TodoItem, type UpdateRepData, type UseContactResult, type UseContactsParams, type UseContactsResult, type UseConversationMessagesResult, type UseConversationsResult, type UseFluidPermissionsResult, type UseFluidThemeResult, type UseListResourceHook, type UseSingleResourceHook, type UserMe, type UserPermissions, type ValueListQueryResult, type WithData, collectNavSlugs, contactsScreenPropertySchema, createFluidClient, createFluidFileUploader, customersScreenPropertySchema, extractSlugFromPathname, getAvailablePageTemplates, getCorePageTemplates, getOptionalPageTemplates, getProperty, hasData, isActivitySlug, isApiError, isContactStatus, isErrorResult, isIdle, isLoading, isSlugInSection, matchSlugPrefix, messagingScreenPropertySchema, normalizeComponentTree, ordersScreenPropertySchema, productsScreenPropertySchema, resolveNavigationPages, screenPropertySchemas, selectProperty, toNavigationItem, toScreenDefinition, transformManifestToRepAppData, useActivities, useAppNavigation, useCalendarEvents, useCatchUps, useContact, useContacts, useConversationMessages, useConversations, useCurrentRep, useFluidApi, useFluidApp, useFluidAuth, useFluidAuthContext, useFluidContext, useFluidPermissions, useFluidProfile, useFluidTheme, useMessagingAuth, useMessagingConfig, useMySite, usePageTemplates, useResolvedPages, useThemeContext, useTodos, validateNavigationPages };
|