@vaultix.ai/react 0.3.3 → 0.3.5
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 +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +273 -97
- package/dist/index.mjs +334 -159
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
3
|
|
|
4
|
+
type AuthMethod = "password" | "magic_link" | "passkey";
|
|
5
|
+
type OAuthProvider = "google" | "github" | "meta" | "linkedin" | "x" | "threads";
|
|
6
|
+
interface AppConfig {
|
|
7
|
+
methods: AuthMethod[];
|
|
8
|
+
providers: OAuthProvider[];
|
|
9
|
+
}
|
|
4
10
|
type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
5
11
|
type ChallengeType = "passkey" | "magic_link" | "password" | "totp" | "sms_otp" | "email_otp";
|
|
6
12
|
interface SessionClaims {
|
|
@@ -76,6 +82,11 @@ interface VaultixContextValue {
|
|
|
76
82
|
isSignedIn: boolean;
|
|
77
83
|
/** Resolved API origin derived from the publishable key. */
|
|
78
84
|
apiOrigin: string;
|
|
85
|
+
/**
|
|
86
|
+
* Per-app auth configuration. Null while loading, then set from /api/v1/app/config.
|
|
87
|
+
* Controls which login methods and OAuth providers are rendered by <SignIn /> and <SignUp />.
|
|
88
|
+
*/
|
|
89
|
+
appConfig: AppConfig | null;
|
|
79
90
|
signOut: (redirectUrl?: string) => Promise<void>;
|
|
80
91
|
/** Update the current user's profile. Resolves with the updated user. */
|
|
81
92
|
updateUser: (params: UpdateUserParams) => Promise<VaultixUser>;
|
|
@@ -87,6 +98,28 @@ interface VaultixContextValue {
|
|
|
87
98
|
*/
|
|
88
99
|
connectPlatform: (provider: string, options?: ConnectPlatformOptions) => void;
|
|
89
100
|
}
|
|
101
|
+
interface VaultixAppearanceVariables {
|
|
102
|
+
/** Primary accent color — used for buttons, focus rings, and icons. Accepts any CSS color value. */
|
|
103
|
+
colorPrimary?: string;
|
|
104
|
+
/** Card / form background. Default: dark glass (rgba(22,27,45,0.92)). */
|
|
105
|
+
colorBackground?: string;
|
|
106
|
+
/** Primary text color. Default: rgba(255,255,255,0.9). */
|
|
107
|
+
colorText?: string;
|
|
108
|
+
/** Secondary / muted text color. Default: #475569. */
|
|
109
|
+
colorTextMuted?: string;
|
|
110
|
+
}
|
|
111
|
+
interface VaultixAppearance {
|
|
112
|
+
variables?: VaultixAppearanceVariables;
|
|
113
|
+
}
|
|
114
|
+
interface PlatformConnectResult {
|
|
115
|
+
provider: string;
|
|
116
|
+
platformUserId?: string;
|
|
117
|
+
username?: string;
|
|
118
|
+
accessToken?: string;
|
|
119
|
+
scope?: string;
|
|
120
|
+
/** Full decoded JWT payload. */
|
|
121
|
+
raw: Record<string, unknown>;
|
|
122
|
+
}
|
|
90
123
|
interface VaultixProviderProps {
|
|
91
124
|
publishableKey: string;
|
|
92
125
|
/** Required for smritix_ keys. The base URL of your auth-engine (no trailing slash). */
|
|
@@ -132,6 +165,28 @@ interface UseAuthReturn {
|
|
|
132
165
|
/** Returns the session JWT for use in API calls via Authorization: Bearer header. */
|
|
133
166
|
getToken: () => Promise<string | null>;
|
|
134
167
|
}
|
|
168
|
+
interface UsePlatformConnectReturn {
|
|
169
|
+
/** Redirect the user to the provider's OAuth authorization page. */
|
|
170
|
+
connect: (overrides?: ConnectPlatformOptions) => void;
|
|
171
|
+
/**
|
|
172
|
+
* Non-null immediately after the OAuth callback lands on the current page.
|
|
173
|
+
* The token is parsed from `__vaultix_connect` in the URL and then removed
|
|
174
|
+
* from the address bar. Null if the user has not connected yet this page load.
|
|
175
|
+
*/
|
|
176
|
+
connectedAccount: PlatformConnectResult | null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Hook for connecting a social/platform account via Vaultix OAuth.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* const { connect, connectedAccount } = usePlatformConnect("google", {
|
|
183
|
+
* scopes: ["https://www.googleapis.com/auth/youtube.upload"],
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* // After connect() → user returns with __vaultix_connect in URL
|
|
187
|
+
* // connectedAccount.accessToken has the token; URL is cleaned automatically
|
|
188
|
+
*/
|
|
189
|
+
declare function usePlatformConnect(provider: string, defaultOptions?: ConnectPlatformOptions): UsePlatformConnectReturn;
|
|
135
190
|
/** Returns key auth identifiers and helpers. */
|
|
136
191
|
declare function useAuth(): UseAuthReturn;
|
|
137
192
|
|
|
@@ -144,8 +199,10 @@ interface SignInProps {
|
|
|
144
199
|
/** API origin — injected by VaultixProvider via DOM attribute, or pass directly. */
|
|
145
200
|
apiOrigin?: string;
|
|
146
201
|
className?: string;
|
|
202
|
+
/** Override colors and card background. */
|
|
203
|
+
appearance?: VaultixAppearance;
|
|
147
204
|
}
|
|
148
|
-
declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignInProps): react_jsx_runtime.JSX.Element;
|
|
205
|
+
declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignInProps): react_jsx_runtime.JSX.Element;
|
|
149
206
|
|
|
150
207
|
interface SignUpProps {
|
|
151
208
|
redirectUrl?: string;
|
|
@@ -153,8 +210,10 @@ interface SignUpProps {
|
|
|
153
210
|
onError?: (message: string) => void;
|
|
154
211
|
apiOrigin?: string;
|
|
155
212
|
className?: string;
|
|
213
|
+
/** Override colors and card background. */
|
|
214
|
+
appearance?: VaultixAppearance;
|
|
156
215
|
}
|
|
157
|
-
declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
216
|
+
declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
158
217
|
|
|
159
218
|
/** Renders children only when the user is signed in and auth is loaded. */
|
|
160
219
|
declare function SignedIn({ children }: {
|
|
@@ -192,4 +251,4 @@ declare function getStoredToken(): string | null;
|
|
|
192
251
|
/** Clears the stored session JWT. Call on 401 so the user is prompted to sign in again. */
|
|
193
252
|
declare function clearStoredToken(): void;
|
|
194
253
|
|
|
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 };
|
|
254
|
+
export { type AppConfig, type AuthMethod, type ChallengeType, type ConnectPlatformOptions, type OAuthProvider, 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
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1 from 'react';
|
|
3
3
|
|
|
4
|
+
type AuthMethod = "password" | "magic_link" | "passkey";
|
|
5
|
+
type OAuthProvider = "google" | "github" | "meta" | "linkedin" | "x" | "threads";
|
|
6
|
+
interface AppConfig {
|
|
7
|
+
methods: AuthMethod[];
|
|
8
|
+
providers: OAuthProvider[];
|
|
9
|
+
}
|
|
4
10
|
type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
5
11
|
type ChallengeType = "passkey" | "magic_link" | "password" | "totp" | "sms_otp" | "email_otp";
|
|
6
12
|
interface SessionClaims {
|
|
@@ -76,6 +82,11 @@ interface VaultixContextValue {
|
|
|
76
82
|
isSignedIn: boolean;
|
|
77
83
|
/** Resolved API origin derived from the publishable key. */
|
|
78
84
|
apiOrigin: string;
|
|
85
|
+
/**
|
|
86
|
+
* Per-app auth configuration. Null while loading, then set from /api/v1/app/config.
|
|
87
|
+
* Controls which login methods and OAuth providers are rendered by <SignIn /> and <SignUp />.
|
|
88
|
+
*/
|
|
89
|
+
appConfig: AppConfig | null;
|
|
79
90
|
signOut: (redirectUrl?: string) => Promise<void>;
|
|
80
91
|
/** Update the current user's profile. Resolves with the updated user. */
|
|
81
92
|
updateUser: (params: UpdateUserParams) => Promise<VaultixUser>;
|
|
@@ -87,6 +98,28 @@ interface VaultixContextValue {
|
|
|
87
98
|
*/
|
|
88
99
|
connectPlatform: (provider: string, options?: ConnectPlatformOptions) => void;
|
|
89
100
|
}
|
|
101
|
+
interface VaultixAppearanceVariables {
|
|
102
|
+
/** Primary accent color — used for buttons, focus rings, and icons. Accepts any CSS color value. */
|
|
103
|
+
colorPrimary?: string;
|
|
104
|
+
/** Card / form background. Default: dark glass (rgba(22,27,45,0.92)). */
|
|
105
|
+
colorBackground?: string;
|
|
106
|
+
/** Primary text color. Default: rgba(255,255,255,0.9). */
|
|
107
|
+
colorText?: string;
|
|
108
|
+
/** Secondary / muted text color. Default: #475569. */
|
|
109
|
+
colorTextMuted?: string;
|
|
110
|
+
}
|
|
111
|
+
interface VaultixAppearance {
|
|
112
|
+
variables?: VaultixAppearanceVariables;
|
|
113
|
+
}
|
|
114
|
+
interface PlatformConnectResult {
|
|
115
|
+
provider: string;
|
|
116
|
+
platformUserId?: string;
|
|
117
|
+
username?: string;
|
|
118
|
+
accessToken?: string;
|
|
119
|
+
scope?: string;
|
|
120
|
+
/** Full decoded JWT payload. */
|
|
121
|
+
raw: Record<string, unknown>;
|
|
122
|
+
}
|
|
90
123
|
interface VaultixProviderProps {
|
|
91
124
|
publishableKey: string;
|
|
92
125
|
/** Required for smritix_ keys. The base URL of your auth-engine (no trailing slash). */
|
|
@@ -132,6 +165,28 @@ interface UseAuthReturn {
|
|
|
132
165
|
/** Returns the session JWT for use in API calls via Authorization: Bearer header. */
|
|
133
166
|
getToken: () => Promise<string | null>;
|
|
134
167
|
}
|
|
168
|
+
interface UsePlatformConnectReturn {
|
|
169
|
+
/** Redirect the user to the provider's OAuth authorization page. */
|
|
170
|
+
connect: (overrides?: ConnectPlatformOptions) => void;
|
|
171
|
+
/**
|
|
172
|
+
* Non-null immediately after the OAuth callback lands on the current page.
|
|
173
|
+
* The token is parsed from `__vaultix_connect` in the URL and then removed
|
|
174
|
+
* from the address bar. Null if the user has not connected yet this page load.
|
|
175
|
+
*/
|
|
176
|
+
connectedAccount: PlatformConnectResult | null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Hook for connecting a social/platform account via Vaultix OAuth.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* const { connect, connectedAccount } = usePlatformConnect("google", {
|
|
183
|
+
* scopes: ["https://www.googleapis.com/auth/youtube.upload"],
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* // After connect() → user returns with __vaultix_connect in URL
|
|
187
|
+
* // connectedAccount.accessToken has the token; URL is cleaned automatically
|
|
188
|
+
*/
|
|
189
|
+
declare function usePlatformConnect(provider: string, defaultOptions?: ConnectPlatformOptions): UsePlatformConnectReturn;
|
|
135
190
|
/** Returns key auth identifiers and helpers. */
|
|
136
191
|
declare function useAuth(): UseAuthReturn;
|
|
137
192
|
|
|
@@ -144,8 +199,10 @@ interface SignInProps {
|
|
|
144
199
|
/** API origin — injected by VaultixProvider via DOM attribute, or pass directly. */
|
|
145
200
|
apiOrigin?: string;
|
|
146
201
|
className?: string;
|
|
202
|
+
/** Override colors and card background. */
|
|
203
|
+
appearance?: VaultixAppearance;
|
|
147
204
|
}
|
|
148
|
-
declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignInProps): react_jsx_runtime.JSX.Element;
|
|
205
|
+
declare function SignIn({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignInProps): react_jsx_runtime.JSX.Element;
|
|
149
206
|
|
|
150
207
|
interface SignUpProps {
|
|
151
208
|
redirectUrl?: string;
|
|
@@ -153,8 +210,10 @@ interface SignUpProps {
|
|
|
153
210
|
onError?: (message: string) => void;
|
|
154
211
|
apiOrigin?: string;
|
|
155
212
|
className?: string;
|
|
213
|
+
/** Override colors and card background. */
|
|
214
|
+
appearance?: VaultixAppearance;
|
|
156
215
|
}
|
|
157
|
-
declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
216
|
+
declare function SignUp({ redirectUrl, onSuccess, onError, apiOrigin: apiOriginProp, className, appearance, }: SignUpProps): react_jsx_runtime.JSX.Element;
|
|
158
217
|
|
|
159
218
|
/** Renders children only when the user is signed in and auth is loaded. */
|
|
160
219
|
declare function SignedIn({ children }: {
|
|
@@ -192,4 +251,4 @@ declare function getStoredToken(): string | null;
|
|
|
192
251
|
/** Clears the stored session JWT. Call on 401 so the user is prompted to sign in again. */
|
|
193
252
|
declare function clearStoredToken(): void;
|
|
194
253
|
|
|
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 };
|
|
254
|
+
export { type AppConfig, type AuthMethod, type ChallengeType, type ConnectPlatformOptions, type OAuthProvider, 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 };
|