@iqauth/sdk 2.0.5 → 2.2.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.
Files changed (38) hide show
  1. package/README.md +19 -3
  2. package/dist/browser.d.mts +2 -2
  3. package/dist/browser.d.ts +2 -2
  4. package/dist/browser.js +57 -6
  5. package/dist/browser.mjs +2 -2
  6. package/dist/{chunk-ZESHDJDU.mjs → chunk-D72UL5HL.mjs} +3 -6
  7. package/dist/{chunk-JQRTY5MY.mjs → chunk-M4J6BPK7.mjs} +3 -8
  8. package/dist/chunk-QEJB7WEQ.mjs +119 -0
  9. package/dist/{chunk-S3M2IXCE.mjs → chunk-QZB745C2.mjs} +3 -8
  10. package/dist/cli/index.js +21 -0
  11. package/dist/cli/index.mjs +1 -1
  12. package/dist/{doctor-OHJRZBBT.mjs → doctor-XCI77BQS.mjs} +2 -1
  13. package/dist/express.js +54 -25
  14. package/dist/express.mjs +5 -8
  15. package/dist/fastify.js +53 -19
  16. package/dist/fastify.mjs +4 -5
  17. package/dist/hono.js +53 -19
  18. package/dist/hono.mjs +4 -5
  19. package/dist/index.d.mts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +59 -4
  22. package/dist/index.mjs +4 -2
  23. package/dist/next.js +66 -34
  24. package/dist/next.mjs +6 -9
  25. package/dist/{publishableKey-B5DIK81A.d.mts → publishableKey-BaR0HoAH.d.mts} +10 -1
  26. package/dist/{publishableKey-B5DIK81A.d.ts → publishableKey-BaR0HoAH.d.ts} +10 -1
  27. package/dist/react.d.mts +91 -4
  28. package/dist/react.d.ts +91 -4
  29. package/dist/react.js +466 -162
  30. package/dist/react.mjs +411 -147
  31. package/dist/server/handlers.js +63 -17
  32. package/dist/server/handlers.mjs +3 -2
  33. package/dist/server.js +53 -21
  34. package/dist/server.mjs +3 -3
  35. package/dist/{signIn-VRNzlNyG.d.ts → signIn-BVDTIA_t.d.ts} +1 -1
  36. package/dist/{signIn-CEMdUAwd.d.mts → signIn-D_kP3v-c.d.mts} +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-5WFR6Y33.mjs +0 -59
package/dist/react.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { S as SessionManager, a as SessionSnapshot, b as SignInOptions, c as SignOutOptions, C as CallbackResult } from './signIn-CEMdUAwd.mjs';
4
+ import { S as SessionManager, a as SessionSnapshot, b as SignInOptions, c as SignOutOptions, C as CallbackResult } from './signIn-D_kP3v-c.mjs';
5
5
  import { d as SessionUser, J as JwtClaims } from './types-Cxl3bQHt.mjs';
6
- import './publishableKey-B5DIK81A.mjs';
6
+ import './publishableKey-BaR0HoAH.mjs';
7
7
 
8
8
  interface IQAuthContextValue {
9
9
  manager: SessionManager;
@@ -89,6 +89,38 @@ declare function SignedOut({ children }: {
89
89
  }): React.FunctionComponentElement<{
90
90
  children?: ReactNode | undefined;
91
91
  }> | null;
92
+ /**
93
+ * Renders its children only while the SDK is still bootstrapping (i.e.
94
+ * `useAuth().isLoaded === false`). Mirrors Clerk's `<ClerkLoading/>`.
95
+ *
96
+ * Recommended pattern (slow-network-safe):
97
+ * ```tsx
98
+ * <IQAuthProvider publishableKey={…}>
99
+ * <IQAuthLoading><Spinner /></IQAuthLoading>
100
+ * <IQAuthLoaded>
101
+ * <SignedIn><App /></SignedIn>
102
+ * <SignedOut><SignIn /></SignedOut>
103
+ * </IQAuthLoaded>
104
+ * </IQAuthProvider>
105
+ * ```
106
+ */
107
+ declare function IQAuthLoading({ children }: {
108
+ children?: ReactNode;
109
+ }): React.FunctionComponentElement<{
110
+ children?: ReactNode | undefined;
111
+ }> | null;
112
+ /**
113
+ * Renders its children only after the SDK has finished bootstrapping (i.e.
114
+ * `useAuth().isLoaded === true`). Mirrors Clerk's `<ClerkLoaded/>`. Wrap
115
+ * `<SignedIn/>` / `<SignedOut/>` in this to avoid a flash of blank UI on
116
+ * slow connections — see `<IQAuthLoading/>` above for the recommended
117
+ * full pattern.
118
+ */
119
+ declare function IQAuthLoaded({ children }: {
120
+ children?: ReactNode;
121
+ }): React.FunctionComponentElement<{
122
+ children?: ReactNode | undefined;
123
+ }> | null;
92
124
  interface RedirectToSignInProps extends SignInOptions {
93
125
  }
94
126
  declare function RedirectToSignIn(props?: RedirectToSignInProps): React.DetailedReactHTMLElement<{
@@ -122,6 +154,7 @@ declare function AuthCallback({ onComplete, fallback }?: AuthCallbackProps): Rea
122
154
  interface IQAuthBranding {
123
155
  brandName: string | null;
124
156
  logoUrl: string | null;
157
+ logoLightUrl?: string | null;
125
158
  logoDarkUrl?: string | null;
126
159
  faviconUrl?: string | null;
127
160
  loginHeadline: string | null;
@@ -132,14 +165,30 @@ interface IQAuthBranding {
132
165
  surfaceColor: string | null;
133
166
  textColor: string | null;
134
167
  heroImageUrl?: string | null;
168
+ /** Optional full-bleed background image for the `full_bleed` layout. */
169
+ backgroundImageUrl?: string | null;
135
170
  tagline?: string | null;
136
171
  loginSideCopy?: string | null;
137
172
  googleButtonLabel?: string | null;
138
173
  customCss?: string | null;
174
+ /** "centered_card" | "split_screen" | "full_bleed" */
175
+ loginLayout?: string | null;
176
+ /** "solid" | "outline" | "ghost" */
177
+ socialButtonStyle?: string | null;
178
+ fontFamilyBody?: string | null;
179
+ fontFamilyHeading?: string | null;
180
+ customFontUrl?: string | null;
181
+ borderRadius?: number | string | null;
182
+ footerText?: string | null;
183
+ emailHeaderImageUrl?: string | null;
184
+ emailSenderName?: string | null;
185
+ emailFooter?: string | null;
139
186
  supportEmail?: string | null;
140
187
  supportUrl?: string | null;
141
188
  termsUrl?: string | null;
142
189
  privacyUrl?: string | null;
190
+ /** Composite revision (`${tenantRev}.${appRev}`) for cache-busting. */
191
+ brandingRev?: string | null;
143
192
  }
144
193
  interface IQAuthSignInContext {
145
194
  app: {
@@ -156,6 +205,13 @@ interface IQAuthSignInContext {
156
205
  allowedOrigins: string[];
157
206
  returnAllowed: boolean;
158
207
  branding: IQAuthBranding | null;
208
+ brandingRev?: string | null;
209
+ session?: {
210
+ userId: string;
211
+ email: string;
212
+ name: string;
213
+ authenticatedAt: number;
214
+ } | null;
159
215
  }
160
216
  interface SharedComponentProps {
161
217
  /** Base URL of the IQAuth service (e.g. https://auth.dispositioniq.com). */
@@ -173,13 +229,44 @@ declare function useIQAuthSignInContext(iqAuthBaseUrl: string, appKey: string, r
173
229
  loading: boolean;
174
230
  error: string | null;
175
231
  };
232
+ declare function sanitizeBrandCss(input: string | null | undefined): string;
233
+ /**
234
+ * Fetches the layered tenant/app branding for use by chrome-only SDK
235
+ * components (`<UserButton/>`, `<UserProfile/>`, `<OrganizationSwitcher/>`)
236
+ * that don't go through `<SignIn/>`'s sign-in-context.
237
+ *
238
+ * Cached at module scope for 60s, keyed by URL. The cache is also
239
+ * brandingRev-aware: a newer rev for the same URL replaces older entries
240
+ * even within the TTL window. Returns `null` until first resolution; callers
241
+ * should treat that as "use neutral defaults".
242
+ *
243
+ * Reads `appId` from the IQAuthProvider's session manager (parsed from the
244
+ * publishable key) so per-app branding overrides are layered. Callers may
245
+ * override with the explicit `appId` parameter.
246
+ */
247
+ declare function useResolvedSdkBranding(iqAuthBaseUrl: string, appId?: string | null): IQAuthBranding | null;
176
248
  interface SignInProps extends SharedComponentProps {
177
249
  /** URL the IQAuth backend should redirect back to with `?code=...`. Must be in the app's allowed_origins. */
178
250
  returnTo: string;
179
251
  /** Called after successful redirect. By default, `window.location.href = url`. */
180
252
  onRedirect?: (url: string) => void;
253
+ /** Pass `"login"` to force the form to render even when an SSO session is active. */
254
+ prompt?: "login";
181
255
  }
182
- declare function SignIn({ iqAuthBaseUrl, appKey, returnTo, onRedirect, className }: SignInProps): react_jsx_runtime.JSX.Element;
256
+ /**
257
+ * Pure render-decision helper. When this returns `true`, `<SignIn/>` MUST
258
+ * render the silent SSO placeholder instead of the email/password form,
259
+ * even on the very first render before `useEffect` fires. Exported so that
260
+ * smoke tests can verify the no-flash guarantee without standing up a DOM.
261
+ */
262
+ declare function isSilentSsoEligible(ctx: {
263
+ session?: unknown;
264
+ app: {
265
+ defaultClientId: string | null;
266
+ };
267
+ returnAllowed: boolean;
268
+ } | null | undefined, effectivePrompt: "login" | undefined): boolean;
269
+ declare function SignIn({ iqAuthBaseUrl, appKey, returnTo, onRedirect, className, prompt }: SignInProps): react_jsx_runtime.JSX.Element;
183
270
  interface SignUpProps extends SharedComponentProps {
184
271
  returnTo?: string;
185
272
  onSuccess?: () => void;
@@ -213,4 +300,4 @@ interface OrganizationSwitcherProps {
213
300
  declare function OrganizationSwitcher({ iqAuthBaseUrl, onSwitched, className }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element;
214
301
  declare const __version__ = "phase-bc-1.0.0";
215
302
 
216
- export { AuthCallback, type AuthCallbackProps, type IQAuthBranding, IQAuthProvider, type IQAuthProviderProps, type IQAuthSignInContext, OrganizationSwitcher, type OrganizationSwitcherProps, RedirectToSignIn, type RedirectToSignInProps, type SessionError, type SharedComponentProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, type UseAuthResult, type UseOrganizationResult, type UseSessionResult, type UseUserResult, UserButton, type UserButtonProps, UserProfile, type UserProfileProps, type UserSummary, __version__, useAuth, useAuthFetch, useIQAuthSignInContext, useOrganization, useSession, useUser };
303
+ export { AuthCallback, type AuthCallbackProps, type IQAuthBranding, IQAuthLoaded, IQAuthLoading, IQAuthProvider, type IQAuthProviderProps, type IQAuthSignInContext, OrganizationSwitcher, type OrganizationSwitcherProps, RedirectToSignIn, type RedirectToSignInProps, type SessionError, type SharedComponentProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, type UseAuthResult, type UseOrganizationResult, type UseSessionResult, type UseUserResult, UserButton, type UserButtonProps, UserProfile, type UserProfileProps, type UserSummary, __version__, isSilentSsoEligible, sanitizeBrandCss, useAuth, useAuthFetch, useIQAuthSignInContext, useOrganization, useResolvedSdkBranding, useSession, useUser };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { S as SessionManager, a as SessionSnapshot, b as SignInOptions, c as SignOutOptions, C as CallbackResult } from './signIn-VRNzlNyG.js';
4
+ import { S as SessionManager, a as SessionSnapshot, b as SignInOptions, c as SignOutOptions, C as CallbackResult } from './signIn-BVDTIA_t.js';
5
5
  import { d as SessionUser, J as JwtClaims } from './types-Cxl3bQHt.js';
6
- import './publishableKey-B5DIK81A.js';
6
+ import './publishableKey-BaR0HoAH.js';
7
7
 
8
8
  interface IQAuthContextValue {
9
9
  manager: SessionManager;
@@ -89,6 +89,38 @@ declare function SignedOut({ children }: {
89
89
  }): React.FunctionComponentElement<{
90
90
  children?: ReactNode | undefined;
91
91
  }> | null;
92
+ /**
93
+ * Renders its children only while the SDK is still bootstrapping (i.e.
94
+ * `useAuth().isLoaded === false`). Mirrors Clerk's `<ClerkLoading/>`.
95
+ *
96
+ * Recommended pattern (slow-network-safe):
97
+ * ```tsx
98
+ * <IQAuthProvider publishableKey={…}>
99
+ * <IQAuthLoading><Spinner /></IQAuthLoading>
100
+ * <IQAuthLoaded>
101
+ * <SignedIn><App /></SignedIn>
102
+ * <SignedOut><SignIn /></SignedOut>
103
+ * </IQAuthLoaded>
104
+ * </IQAuthProvider>
105
+ * ```
106
+ */
107
+ declare function IQAuthLoading({ children }: {
108
+ children?: ReactNode;
109
+ }): React.FunctionComponentElement<{
110
+ children?: ReactNode | undefined;
111
+ }> | null;
112
+ /**
113
+ * Renders its children only after the SDK has finished bootstrapping (i.e.
114
+ * `useAuth().isLoaded === true`). Mirrors Clerk's `<ClerkLoaded/>`. Wrap
115
+ * `<SignedIn/>` / `<SignedOut/>` in this to avoid a flash of blank UI on
116
+ * slow connections — see `<IQAuthLoading/>` above for the recommended
117
+ * full pattern.
118
+ */
119
+ declare function IQAuthLoaded({ children }: {
120
+ children?: ReactNode;
121
+ }): React.FunctionComponentElement<{
122
+ children?: ReactNode | undefined;
123
+ }> | null;
92
124
  interface RedirectToSignInProps extends SignInOptions {
93
125
  }
94
126
  declare function RedirectToSignIn(props?: RedirectToSignInProps): React.DetailedReactHTMLElement<{
@@ -122,6 +154,7 @@ declare function AuthCallback({ onComplete, fallback }?: AuthCallbackProps): Rea
122
154
  interface IQAuthBranding {
123
155
  brandName: string | null;
124
156
  logoUrl: string | null;
157
+ logoLightUrl?: string | null;
125
158
  logoDarkUrl?: string | null;
126
159
  faviconUrl?: string | null;
127
160
  loginHeadline: string | null;
@@ -132,14 +165,30 @@ interface IQAuthBranding {
132
165
  surfaceColor: string | null;
133
166
  textColor: string | null;
134
167
  heroImageUrl?: string | null;
168
+ /** Optional full-bleed background image for the `full_bleed` layout. */
169
+ backgroundImageUrl?: string | null;
135
170
  tagline?: string | null;
136
171
  loginSideCopy?: string | null;
137
172
  googleButtonLabel?: string | null;
138
173
  customCss?: string | null;
174
+ /** "centered_card" | "split_screen" | "full_bleed" */
175
+ loginLayout?: string | null;
176
+ /** "solid" | "outline" | "ghost" */
177
+ socialButtonStyle?: string | null;
178
+ fontFamilyBody?: string | null;
179
+ fontFamilyHeading?: string | null;
180
+ customFontUrl?: string | null;
181
+ borderRadius?: number | string | null;
182
+ footerText?: string | null;
183
+ emailHeaderImageUrl?: string | null;
184
+ emailSenderName?: string | null;
185
+ emailFooter?: string | null;
139
186
  supportEmail?: string | null;
140
187
  supportUrl?: string | null;
141
188
  termsUrl?: string | null;
142
189
  privacyUrl?: string | null;
190
+ /** Composite revision (`${tenantRev}.${appRev}`) for cache-busting. */
191
+ brandingRev?: string | null;
143
192
  }
144
193
  interface IQAuthSignInContext {
145
194
  app: {
@@ -156,6 +205,13 @@ interface IQAuthSignInContext {
156
205
  allowedOrigins: string[];
157
206
  returnAllowed: boolean;
158
207
  branding: IQAuthBranding | null;
208
+ brandingRev?: string | null;
209
+ session?: {
210
+ userId: string;
211
+ email: string;
212
+ name: string;
213
+ authenticatedAt: number;
214
+ } | null;
159
215
  }
160
216
  interface SharedComponentProps {
161
217
  /** Base URL of the IQAuth service (e.g. https://auth.dispositioniq.com). */
@@ -173,13 +229,44 @@ declare function useIQAuthSignInContext(iqAuthBaseUrl: string, appKey: string, r
173
229
  loading: boolean;
174
230
  error: string | null;
175
231
  };
232
+ declare function sanitizeBrandCss(input: string | null | undefined): string;
233
+ /**
234
+ * Fetches the layered tenant/app branding for use by chrome-only SDK
235
+ * components (`<UserButton/>`, `<UserProfile/>`, `<OrganizationSwitcher/>`)
236
+ * that don't go through `<SignIn/>`'s sign-in-context.
237
+ *
238
+ * Cached at module scope for 60s, keyed by URL. The cache is also
239
+ * brandingRev-aware: a newer rev for the same URL replaces older entries
240
+ * even within the TTL window. Returns `null` until first resolution; callers
241
+ * should treat that as "use neutral defaults".
242
+ *
243
+ * Reads `appId` from the IQAuthProvider's session manager (parsed from the
244
+ * publishable key) so per-app branding overrides are layered. Callers may
245
+ * override with the explicit `appId` parameter.
246
+ */
247
+ declare function useResolvedSdkBranding(iqAuthBaseUrl: string, appId?: string | null): IQAuthBranding | null;
176
248
  interface SignInProps extends SharedComponentProps {
177
249
  /** URL the IQAuth backend should redirect back to with `?code=...`. Must be in the app's allowed_origins. */
178
250
  returnTo: string;
179
251
  /** Called after successful redirect. By default, `window.location.href = url`. */
180
252
  onRedirect?: (url: string) => void;
253
+ /** Pass `"login"` to force the form to render even when an SSO session is active. */
254
+ prompt?: "login";
181
255
  }
182
- declare function SignIn({ iqAuthBaseUrl, appKey, returnTo, onRedirect, className }: SignInProps): react_jsx_runtime.JSX.Element;
256
+ /**
257
+ * Pure render-decision helper. When this returns `true`, `<SignIn/>` MUST
258
+ * render the silent SSO placeholder instead of the email/password form,
259
+ * even on the very first render before `useEffect` fires. Exported so that
260
+ * smoke tests can verify the no-flash guarantee without standing up a DOM.
261
+ */
262
+ declare function isSilentSsoEligible(ctx: {
263
+ session?: unknown;
264
+ app: {
265
+ defaultClientId: string | null;
266
+ };
267
+ returnAllowed: boolean;
268
+ } | null | undefined, effectivePrompt: "login" | undefined): boolean;
269
+ declare function SignIn({ iqAuthBaseUrl, appKey, returnTo, onRedirect, className, prompt }: SignInProps): react_jsx_runtime.JSX.Element;
183
270
  interface SignUpProps extends SharedComponentProps {
184
271
  returnTo?: string;
185
272
  onSuccess?: () => void;
@@ -213,4 +300,4 @@ interface OrganizationSwitcherProps {
213
300
  declare function OrganizationSwitcher({ iqAuthBaseUrl, onSwitched, className }: OrganizationSwitcherProps): react_jsx_runtime.JSX.Element;
214
301
  declare const __version__ = "phase-bc-1.0.0";
215
302
 
216
- export { AuthCallback, type AuthCallbackProps, type IQAuthBranding, IQAuthProvider, type IQAuthProviderProps, type IQAuthSignInContext, OrganizationSwitcher, type OrganizationSwitcherProps, RedirectToSignIn, type RedirectToSignInProps, type SessionError, type SharedComponentProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, type UseAuthResult, type UseOrganizationResult, type UseSessionResult, type UseUserResult, UserButton, type UserButtonProps, UserProfile, type UserProfileProps, type UserSummary, __version__, useAuth, useAuthFetch, useIQAuthSignInContext, useOrganization, useSession, useUser };
303
+ export { AuthCallback, type AuthCallbackProps, type IQAuthBranding, IQAuthLoaded, IQAuthLoading, IQAuthProvider, type IQAuthProviderProps, type IQAuthSignInContext, OrganizationSwitcher, type OrganizationSwitcherProps, RedirectToSignIn, type RedirectToSignInProps, type SessionError, type SharedComponentProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, type UseAuthResult, type UseOrganizationResult, type UseSessionResult, type UseUserResult, UserButton, type UserButtonProps, UserProfile, type UserProfileProps, type UserSummary, __version__, isSilentSsoEligible, sanitizeBrandCss, useAuth, useAuthFetch, useIQAuthSignInContext, useOrganization, useResolvedSdkBranding, useSession, useUser };