@vaultix.ai/react 0.3.2 → 0.3.4

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/index.d.mts CHANGED
@@ -22,6 +22,7 @@ interface VaultixUser {
22
22
  firstName: string | null;
23
23
  lastName: string | null;
24
24
  imageUrl: string | null;
25
+ publicMetadata: Record<string, unknown>;
25
26
  createdAt: number;
26
27
  updatedAt: number;
27
28
  }
@@ -58,13 +59,26 @@ interface ConnectPlatformOptions {
58
59
  /** Where to redirect after the user authorizes. Defaults to current page. */
59
60
  redirectUrl?: string;
60
61
  }
62
+ interface UpdateUserParams {
63
+ firstName?: string | null;
64
+ lastName?: string | null;
65
+ imageUrl?: string | null;
66
+ publicMetadata?: Record<string, unknown>;
67
+ /** Requires currentPassword when changing password. */
68
+ newPassword?: string;
69
+ currentPassword?: string;
70
+ }
61
71
  interface VaultixContextValue {
62
72
  user: VaultixUser | null;
63
73
  session: VaultixSession | null;
64
74
  organization: VaultixOrganization | null;
65
75
  isLoaded: boolean;
66
76
  isSignedIn: boolean;
67
- signOut: () => Promise<void>;
77
+ /** Resolved API origin derived from the publishable key. */
78
+ apiOrigin: string;
79
+ signOut: (redirectUrl?: string) => Promise<void>;
80
+ /** Update the current user's profile. Resolves with the updated user. */
81
+ updateUser: (params: UpdateUserParams) => Promise<VaultixUser>;
68
82
  /**
69
83
  * Initiate a platform OAuth connection flow (posting, reading, etc.).
70
84
  * Redirects the user to the provider's authorization page via Vaultix.
@@ -73,6 +87,28 @@ interface VaultixContextValue {
73
87
  */
74
88
  connectPlatform: (provider: string, options?: ConnectPlatformOptions) => void;
75
89
  }
90
+ interface VaultixAppearanceVariables {
91
+ /** Primary accent color — used for buttons, focus rings, and icons. Accepts any CSS color value. */
92
+ colorPrimary?: string;
93
+ /** Card / form background. Default: dark glass (rgba(22,27,45,0.92)). */
94
+ colorBackground?: string;
95
+ /** Primary text color. Default: rgba(255,255,255,0.9). */
96
+ colorText?: string;
97
+ /** Secondary / muted text color. Default: #475569. */
98
+ colorTextMuted?: string;
99
+ }
100
+ interface VaultixAppearance {
101
+ variables?: VaultixAppearanceVariables;
102
+ }
103
+ interface PlatformConnectResult {
104
+ provider: string;
105
+ platformUserId?: string;
106
+ username?: string;
107
+ accessToken?: string;
108
+ scope?: string;
109
+ /** Full decoded JWT payload. */
110
+ raw: Record<string, unknown>;
111
+ }
76
112
  interface VaultixProviderProps {
77
113
  publishableKey: string;
78
114
  /** Required for smritix_ keys. The base URL of your auth-engine (no trailing slash). */
@@ -93,6 +129,8 @@ interface UseUserReturn {
93
129
  user: VaultixUser | null;
94
130
  isLoaded: boolean;
95
131
  isSignedIn: boolean;
132
+ /** Update the current user's profile fields or password. */
133
+ update: (params: UpdateUserParams) => Promise<VaultixUser>;
96
134
  }
97
135
  interface UseOrganizationReturn {
98
136
  organization: VaultixOrganization | null;
@@ -102,7 +140,7 @@ interface UseOrganizationReturn {
102
140
  declare function useVaultix(): VaultixContextValue;
103
141
  /** Returns the current session and its loading state. */
104
142
  declare function useSession(): UseSessionReturn;
105
- /** Returns the current user and their loading state. */
143
+ /** Returns the current user, their loading state, and an update function. */
106
144
  declare function useUser(): UseUserReturn;
107
145
  /** Returns the active organization for the current session. */
108
146
  declare function useOrganization(): UseOrganizationReturn;
@@ -116,7 +154,29 @@ interface UseAuthReturn {
116
154
  /** Returns the session JWT for use in API calls via Authorization: Bearer header. */
117
155
  getToken: () => Promise<string | null>;
118
156
  }
119
- /** Clerk-compatible auth hook. Returns key auth identifiers and helpers. */
157
+ interface UsePlatformConnectReturn {
158
+ /** Redirect the user to the provider's OAuth authorization page. */
159
+ connect: (overrides?: ConnectPlatformOptions) => void;
160
+ /**
161
+ * Non-null immediately after the OAuth callback lands on the current page.
162
+ * The token is parsed from `__vaultix_connect` in the URL and then removed
163
+ * from the address bar. Null if the user has not connected yet this page load.
164
+ */
165
+ connectedAccount: PlatformConnectResult | null;
166
+ }
167
+ /**
168
+ * Hook for connecting a social/platform account via Vaultix OAuth.
169
+ *
170
+ * @example
171
+ * const { connect, connectedAccount } = usePlatformConnect("google", {
172
+ * scopes: ["https://www.googleapis.com/auth/youtube.upload"],
173
+ * });
174
+ *
175
+ * // After connect() → user returns with __vaultix_connect in URL
176
+ * // connectedAccount.accessToken has the token; URL is cleaned automatically
177
+ */
178
+ declare function usePlatformConnect(provider: string, defaultOptions?: ConnectPlatformOptions): UsePlatformConnectReturn;
179
+ /** Returns key auth identifiers and helpers. */
120
180
  declare function useAuth(): UseAuthReturn;
121
181
 
122
182
  interface SignInProps {
@@ -128,8 +188,10 @@ interface SignInProps {
128
188
  /** API origin — injected by VaultixProvider via DOM attribute, or pass directly. */
129
189
  apiOrigin?: string;
130
190
  className?: string;
191
+ /** Override colors and card background. */
192
+ appearance?: VaultixAppearance;
131
193
  }
132
- declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignInProps): react_jsx_runtime.JSX.Element;
194
+ declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignInProps): react_jsx_runtime.JSX.Element;
133
195
 
134
196
  interface SignUpProps {
135
197
  redirectUrl?: string;
@@ -137,8 +199,10 @@ interface SignUpProps {
137
199
  onError?: (message: string) => void;
138
200
  apiOrigin?: string;
139
201
  className?: string;
202
+ /** Override colors and card background. */
203
+ appearance?: VaultixAppearance;
140
204
  }
141
- declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignUpProps): react_jsx_runtime.JSX.Element;
205
+ declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignUpProps): react_jsx_runtime.JSX.Element;
142
206
 
143
207
  /** Renders children only when the user is signed in and auth is loaded. */
144
208
  declare function SignedIn({ children }: {
@@ -159,12 +223,11 @@ declare function RedirectToSignIn({ redirectUrl }: RedirectProps): null;
159
223
  declare function RedirectToSignUp({ redirectUrl }: RedirectProps): null;
160
224
 
161
225
  interface UserButtonProps {
162
- /** Show the user's name next to the avatar. Default false. */
163
226
  showName?: boolean;
164
227
  afterSignOutUrl?: string;
165
228
  className?: string;
166
229
  }
167
- declare function UserButton({ showName, afterSignOutUrl, className, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
230
+ declare function UserButton({ showName, afterSignOutUrl, className }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
168
231
 
169
232
  interface OrganizationSwitcherProps {
170
233
  afterSwitchUrl?: string;
@@ -172,9 +235,9 @@ interface OrganizationSwitcherProps {
172
235
  }
173
236
  declare function OrganizationSwitcher({ afterSwitchUrl, className, }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element | null;
174
237
 
175
- /** Returns the stored session JWT, or null if not signed in. */
238
+ /** Returns the stored session JWT from the vaultix-token cookie, or null if not signed in. */
176
239
  declare function getStoredToken(): string | null;
177
240
  /** Clears the stored session JWT. Call on 401 so the user is prompted to sign in again. */
178
241
  declare function clearStoredToken(): void;
179
242
 
180
- export { type ChallengeType, type ConnectPlatformOptions, OrganizationSwitcher, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, UserButton, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, clearStoredToken, getStoredToken, useAuth, useOrganization, useSession, useUser, useVaultix };
243
+ export { type ChallengeType, type ConnectPlatformOptions, OrganizationSwitcher, type PlatformConnectResult, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, type UpdateUserParams, UserButton, type VaultixAppearance, type VaultixAppearanceVariables, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, clearStoredToken, getStoredToken, useAuth, useOrganization, usePlatformConnect, useSession, useUser, useVaultix };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ interface VaultixUser {
22
22
  firstName: string | null;
23
23
  lastName: string | null;
24
24
  imageUrl: string | null;
25
+ publicMetadata: Record<string, unknown>;
25
26
  createdAt: number;
26
27
  updatedAt: number;
27
28
  }
@@ -58,13 +59,26 @@ interface ConnectPlatformOptions {
58
59
  /** Where to redirect after the user authorizes. Defaults to current page. */
59
60
  redirectUrl?: string;
60
61
  }
62
+ interface UpdateUserParams {
63
+ firstName?: string | null;
64
+ lastName?: string | null;
65
+ imageUrl?: string | null;
66
+ publicMetadata?: Record<string, unknown>;
67
+ /** Requires currentPassword when changing password. */
68
+ newPassword?: string;
69
+ currentPassword?: string;
70
+ }
61
71
  interface VaultixContextValue {
62
72
  user: VaultixUser | null;
63
73
  session: VaultixSession | null;
64
74
  organization: VaultixOrganization | null;
65
75
  isLoaded: boolean;
66
76
  isSignedIn: boolean;
67
- signOut: () => Promise<void>;
77
+ /** Resolved API origin derived from the publishable key. */
78
+ apiOrigin: string;
79
+ signOut: (redirectUrl?: string) => Promise<void>;
80
+ /** Update the current user's profile. Resolves with the updated user. */
81
+ updateUser: (params: UpdateUserParams) => Promise<VaultixUser>;
68
82
  /**
69
83
  * Initiate a platform OAuth connection flow (posting, reading, etc.).
70
84
  * Redirects the user to the provider's authorization page via Vaultix.
@@ -73,6 +87,28 @@ interface VaultixContextValue {
73
87
  */
74
88
  connectPlatform: (provider: string, options?: ConnectPlatformOptions) => void;
75
89
  }
90
+ interface VaultixAppearanceVariables {
91
+ /** Primary accent color — used for buttons, focus rings, and icons. Accepts any CSS color value. */
92
+ colorPrimary?: string;
93
+ /** Card / form background. Default: dark glass (rgba(22,27,45,0.92)). */
94
+ colorBackground?: string;
95
+ /** Primary text color. Default: rgba(255,255,255,0.9). */
96
+ colorText?: string;
97
+ /** Secondary / muted text color. Default: #475569. */
98
+ colorTextMuted?: string;
99
+ }
100
+ interface VaultixAppearance {
101
+ variables?: VaultixAppearanceVariables;
102
+ }
103
+ interface PlatformConnectResult {
104
+ provider: string;
105
+ platformUserId?: string;
106
+ username?: string;
107
+ accessToken?: string;
108
+ scope?: string;
109
+ /** Full decoded JWT payload. */
110
+ raw: Record<string, unknown>;
111
+ }
76
112
  interface VaultixProviderProps {
77
113
  publishableKey: string;
78
114
  /** Required for smritix_ keys. The base URL of your auth-engine (no trailing slash). */
@@ -93,6 +129,8 @@ interface UseUserReturn {
93
129
  user: VaultixUser | null;
94
130
  isLoaded: boolean;
95
131
  isSignedIn: boolean;
132
+ /** Update the current user's profile fields or password. */
133
+ update: (params: UpdateUserParams) => Promise<VaultixUser>;
96
134
  }
97
135
  interface UseOrganizationReturn {
98
136
  organization: VaultixOrganization | null;
@@ -102,7 +140,7 @@ interface UseOrganizationReturn {
102
140
  declare function useVaultix(): VaultixContextValue;
103
141
  /** Returns the current session and its loading state. */
104
142
  declare function useSession(): UseSessionReturn;
105
- /** Returns the current user and their loading state. */
143
+ /** Returns the current user, their loading state, and an update function. */
106
144
  declare function useUser(): UseUserReturn;
107
145
  /** Returns the active organization for the current session. */
108
146
  declare function useOrganization(): UseOrganizationReturn;
@@ -116,7 +154,29 @@ interface UseAuthReturn {
116
154
  /** Returns the session JWT for use in API calls via Authorization: Bearer header. */
117
155
  getToken: () => Promise<string | null>;
118
156
  }
119
- /** Clerk-compatible auth hook. Returns key auth identifiers and helpers. */
157
+ interface UsePlatformConnectReturn {
158
+ /** Redirect the user to the provider's OAuth authorization page. */
159
+ connect: (overrides?: ConnectPlatformOptions) => void;
160
+ /**
161
+ * Non-null immediately after the OAuth callback lands on the current page.
162
+ * The token is parsed from `__vaultix_connect` in the URL and then removed
163
+ * from the address bar. Null if the user has not connected yet this page load.
164
+ */
165
+ connectedAccount: PlatformConnectResult | null;
166
+ }
167
+ /**
168
+ * Hook for connecting a social/platform account via Vaultix OAuth.
169
+ *
170
+ * @example
171
+ * const { connect, connectedAccount } = usePlatformConnect("google", {
172
+ * scopes: ["https://www.googleapis.com/auth/youtube.upload"],
173
+ * });
174
+ *
175
+ * // After connect() → user returns with __vaultix_connect in URL
176
+ * // connectedAccount.accessToken has the token; URL is cleaned automatically
177
+ */
178
+ declare function usePlatformConnect(provider: string, defaultOptions?: ConnectPlatformOptions): UsePlatformConnectReturn;
179
+ /** Returns key auth identifiers and helpers. */
120
180
  declare function useAuth(): UseAuthReturn;
121
181
 
122
182
  interface SignInProps {
@@ -128,8 +188,10 @@ interface SignInProps {
128
188
  /** API origin — injected by VaultixProvider via DOM attribute, or pass directly. */
129
189
  apiOrigin?: string;
130
190
  className?: string;
191
+ /** Override colors and card background. */
192
+ appearance?: VaultixAppearance;
131
193
  }
132
- declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignInProps): react_jsx_runtime.JSX.Element;
194
+ declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignInProps): react_jsx_runtime.JSX.Element;
133
195
 
134
196
  interface SignUpProps {
135
197
  redirectUrl?: string;
@@ -137,8 +199,10 @@ interface SignUpProps {
137
199
  onError?: (message: string) => void;
138
200
  apiOrigin?: string;
139
201
  className?: string;
202
+ /** Override colors and card background. */
203
+ appearance?: VaultixAppearance;
140
204
  }
141
- declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignUpProps): react_jsx_runtime.JSX.Element;
205
+ declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignUpProps): react_jsx_runtime.JSX.Element;
142
206
 
143
207
  /** Renders children only when the user is signed in and auth is loaded. */
144
208
  declare function SignedIn({ children }: {
@@ -159,12 +223,11 @@ declare function RedirectToSignIn({ redirectUrl }: RedirectProps): null;
159
223
  declare function RedirectToSignUp({ redirectUrl }: RedirectProps): null;
160
224
 
161
225
  interface UserButtonProps {
162
- /** Show the user's name next to the avatar. Default false. */
163
226
  showName?: boolean;
164
227
  afterSignOutUrl?: string;
165
228
  className?: string;
166
229
  }
167
- declare function UserButton({ showName, afterSignOutUrl, className, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
230
+ declare function UserButton({ showName, afterSignOutUrl, className }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
168
231
 
169
232
  interface OrganizationSwitcherProps {
170
233
  afterSwitchUrl?: string;
@@ -172,9 +235,9 @@ interface OrganizationSwitcherProps {
172
235
  }
173
236
  declare function OrganizationSwitcher({ afterSwitchUrl, className, }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element | null;
174
237
 
175
- /** Returns the stored session JWT, or null if not signed in. */
238
+ /** Returns the stored session JWT from the vaultix-token cookie, or null if not signed in. */
176
239
  declare function getStoredToken(): string | null;
177
240
  /** Clears the stored session JWT. Call on 401 so the user is prompted to sign in again. */
178
241
  declare function clearStoredToken(): void;
179
242
 
180
- export { type ChallengeType, type ConnectPlatformOptions, OrganizationSwitcher, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, UserButton, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, clearStoredToken, getStoredToken, useAuth, useOrganization, useSession, useUser, useVaultix };
243
+ export { type ChallengeType, type ConnectPlatformOptions, OrganizationSwitcher, type PlatformConnectResult, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, type UpdateUserParams, UserButton, type VaultixAppearance, type VaultixAppearanceVariables, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, clearStoredToken, getStoredToken, useAuth, useOrganization, usePlatformConnect, useSession, useUser, useVaultix };