@vaultix.ai/react 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
  }
@@ -42,13 +43,49 @@ interface VaultixSession {
42
43
  expiresAt: number;
43
44
  claims: SessionClaims;
44
45
  }
46
+ interface ConnectPlatformOptions {
47
+ /** OAuth scopes to request. Joined by the provider's delimiter (space or comma). */
48
+ scopes?: string[];
49
+ /**
50
+ * Meta-specific: a Login Config ID registered on the Vaultix Meta app.
51
+ * When provided, takes precedence over `scopes` (Meta's rule).
52
+ */
53
+ configId?: string;
54
+ /**
55
+ * Extra provider-specific params forwarded to the authorization URL.
56
+ * e.g. { shop: "mystore.myshopify.com" } for Shopify.
57
+ */
58
+ extraParams?: Record<string, string>;
59
+ /** Where to redirect after the user authorizes. Defaults to current page. */
60
+ redirectUrl?: string;
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
+ }
45
71
  interface VaultixContextValue {
46
72
  user: VaultixUser | null;
47
73
  session: VaultixSession | null;
48
74
  organization: VaultixOrganization | null;
49
75
  isLoaded: boolean;
50
76
  isSignedIn: boolean;
51
- 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>;
82
+ /**
83
+ * Initiate a platform OAuth connection flow (posting, reading, etc.).
84
+ * Redirects the user to the provider's authorization page via Vaultix.
85
+ * On completion, Vaultix redirects back with `__vaultix_connect` + `provider`
86
+ * query params that your app exchanges via POST /oauth/{provider}/connect-complete.
87
+ */
88
+ connectPlatform: (provider: string, options?: ConnectPlatformOptions) => void;
52
89
  }
53
90
  interface VaultixProviderProps {
54
91
  publishableKey: string;
@@ -70,6 +107,8 @@ interface UseUserReturn {
70
107
  user: VaultixUser | null;
71
108
  isLoaded: boolean;
72
109
  isSignedIn: boolean;
110
+ /** Update the current user's profile fields or password. */
111
+ update: (params: UpdateUserParams) => Promise<VaultixUser>;
73
112
  }
74
113
  interface UseOrganizationReturn {
75
114
  organization: VaultixOrganization | null;
@@ -79,7 +118,7 @@ interface UseOrganizationReturn {
79
118
  declare function useVaultix(): VaultixContextValue;
80
119
  /** Returns the current session and its loading state. */
81
120
  declare function useSession(): UseSessionReturn;
82
- /** Returns the current user and their loading state. */
121
+ /** Returns the current user, their loading state, and an update function. */
83
122
  declare function useUser(): UseUserReturn;
84
123
  /** Returns the active organization for the current session. */
85
124
  declare function useOrganization(): UseOrganizationReturn;
@@ -93,7 +132,7 @@ interface UseAuthReturn {
93
132
  /** Returns the session JWT for use in API calls via Authorization: Bearer header. */
94
133
  getToken: () => Promise<string | null>;
95
134
  }
96
- /** Clerk-compatible auth hook. Returns key auth identifiers and helpers. */
135
+ /** Returns key auth identifiers and helpers. */
97
136
  declare function useAuth(): UseAuthReturn;
98
137
 
99
138
  interface SignInProps {
@@ -136,12 +175,11 @@ declare function RedirectToSignIn({ redirectUrl }: RedirectProps): null;
136
175
  declare function RedirectToSignUp({ redirectUrl }: RedirectProps): null;
137
176
 
138
177
  interface UserButtonProps {
139
- /** Show the user's name next to the avatar. Default false. */
140
178
  showName?: boolean;
141
179
  afterSignOutUrl?: string;
142
180
  className?: string;
143
181
  }
144
- declare function UserButton({ showName, afterSignOutUrl, className, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
182
+ declare function UserButton({ showName, afterSignOutUrl, className }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
145
183
 
146
184
  interface OrganizationSwitcherProps {
147
185
  afterSwitchUrl?: string;
@@ -149,4 +187,9 @@ interface OrganizationSwitcherProps {
149
187
  }
150
188
  declare function OrganizationSwitcher({ afterSwitchUrl, className, }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element | null;
151
189
 
152
- export { type ChallengeType, OrganizationSwitcher, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, UserButton, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, useAuth, useOrganization, useSession, useUser, useVaultix };
190
+ /** Returns the stored session JWT from the vaultix-token cookie, or null if not signed in. */
191
+ declare function getStoredToken(): string | null;
192
+ /** Clears the stored session JWT. Call on 401 so the user is prompted to sign in again. */
193
+ declare function clearStoredToken(): void;
194
+
195
+ export { type ChallengeType, type ConnectPlatformOptions, OrganizationSwitcher, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, type UpdateUserParams, UserButton, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, clearStoredToken, getStoredToken, useAuth, useOrganization, 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
  }
@@ -42,13 +43,49 @@ interface VaultixSession {
42
43
  expiresAt: number;
43
44
  claims: SessionClaims;
44
45
  }
46
+ interface ConnectPlatformOptions {
47
+ /** OAuth scopes to request. Joined by the provider's delimiter (space or comma). */
48
+ scopes?: string[];
49
+ /**
50
+ * Meta-specific: a Login Config ID registered on the Vaultix Meta app.
51
+ * When provided, takes precedence over `scopes` (Meta's rule).
52
+ */
53
+ configId?: string;
54
+ /**
55
+ * Extra provider-specific params forwarded to the authorization URL.
56
+ * e.g. { shop: "mystore.myshopify.com" } for Shopify.
57
+ */
58
+ extraParams?: Record<string, string>;
59
+ /** Where to redirect after the user authorizes. Defaults to current page. */
60
+ redirectUrl?: string;
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
+ }
45
71
  interface VaultixContextValue {
46
72
  user: VaultixUser | null;
47
73
  session: VaultixSession | null;
48
74
  organization: VaultixOrganization | null;
49
75
  isLoaded: boolean;
50
76
  isSignedIn: boolean;
51
- 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>;
82
+ /**
83
+ * Initiate a platform OAuth connection flow (posting, reading, etc.).
84
+ * Redirects the user to the provider's authorization page via Vaultix.
85
+ * On completion, Vaultix redirects back with `__vaultix_connect` + `provider`
86
+ * query params that your app exchanges via POST /oauth/{provider}/connect-complete.
87
+ */
88
+ connectPlatform: (provider: string, options?: ConnectPlatformOptions) => void;
52
89
  }
53
90
  interface VaultixProviderProps {
54
91
  publishableKey: string;
@@ -70,6 +107,8 @@ interface UseUserReturn {
70
107
  user: VaultixUser | null;
71
108
  isLoaded: boolean;
72
109
  isSignedIn: boolean;
110
+ /** Update the current user's profile fields or password. */
111
+ update: (params: UpdateUserParams) => Promise<VaultixUser>;
73
112
  }
74
113
  interface UseOrganizationReturn {
75
114
  organization: VaultixOrganization | null;
@@ -79,7 +118,7 @@ interface UseOrganizationReturn {
79
118
  declare function useVaultix(): VaultixContextValue;
80
119
  /** Returns the current session and its loading state. */
81
120
  declare function useSession(): UseSessionReturn;
82
- /** Returns the current user and their loading state. */
121
+ /** Returns the current user, their loading state, and an update function. */
83
122
  declare function useUser(): UseUserReturn;
84
123
  /** Returns the active organization for the current session. */
85
124
  declare function useOrganization(): UseOrganizationReturn;
@@ -93,7 +132,7 @@ interface UseAuthReturn {
93
132
  /** Returns the session JWT for use in API calls via Authorization: Bearer header. */
94
133
  getToken: () => Promise<string | null>;
95
134
  }
96
- /** Clerk-compatible auth hook. Returns key auth identifiers and helpers. */
135
+ /** Returns key auth identifiers and helpers. */
97
136
  declare function useAuth(): UseAuthReturn;
98
137
 
99
138
  interface SignInProps {
@@ -136,12 +175,11 @@ declare function RedirectToSignIn({ redirectUrl }: RedirectProps): null;
136
175
  declare function RedirectToSignUp({ redirectUrl }: RedirectProps): null;
137
176
 
138
177
  interface UserButtonProps {
139
- /** Show the user's name next to the avatar. Default false. */
140
178
  showName?: boolean;
141
179
  afterSignOutUrl?: string;
142
180
  className?: string;
143
181
  }
144
- declare function UserButton({ showName, afterSignOutUrl, className, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
182
+ declare function UserButton({ showName, afterSignOutUrl, className }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
145
183
 
146
184
  interface OrganizationSwitcherProps {
147
185
  afterSwitchUrl?: string;
@@ -149,4 +187,9 @@ interface OrganizationSwitcherProps {
149
187
  }
150
188
  declare function OrganizationSwitcher({ afterSwitchUrl, className, }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element | null;
151
189
 
152
- export { type ChallengeType, OrganizationSwitcher, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, UserButton, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, useAuth, useOrganization, useSession, useUser, useVaultix };
190
+ /** Returns the stored session JWT from the vaultix-token cookie, or null if not signed in. */
191
+ declare function getStoredToken(): string | null;
192
+ /** Clears the stored session JWT. Call on 401 so the user is prompted to sign in again. */
193
+ declare function clearStoredToken(): void;
194
+
195
+ export { type ChallengeType, type ConnectPlatformOptions, OrganizationSwitcher, RedirectToSignIn, RedirectToSignUp, type RiskLevel, type SessionClaims, SignIn, SignUp, SignedIn, SignedOut, type UpdateUserParams, UserButton, type VaultixContextValue, type VaultixOrganization, VaultixProvider, type VaultixProviderProps, type VaultixSession, type VaultixUser, clearStoredToken, getStoredToken, useAuth, useOrganization, useSession, useUser, useVaultix };