@poly-x/react 0.1.1 → 0.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.
- package/README.md +33 -2
- package/dist/index.cjs +646 -81
- package/dist/index.d.cts +107 -2
- package/dist/index.d.mts +107 -2
- package/dist/index.mjs +646 -83
- package/dist/styles.css +151 -0
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -136,6 +136,16 @@ interface UseAuth {
|
|
|
136
136
|
* BFF custody, where the token is httpOnly server-side by design (FR-SES-3).
|
|
137
137
|
*/
|
|
138
138
|
getToken: () => Promise<string | null>;
|
|
139
|
+
/**
|
|
140
|
+
* Re-read the session's authorization from the server and resolve whether it actually
|
|
141
|
+
* changed (FR-CLIENT-3).
|
|
142
|
+
*
|
|
143
|
+
* This capability already existed on the BFF store but was not reachable from the public
|
|
144
|
+
* surface, so both consuming apps wrote their own refresher — and they already differ:
|
|
145
|
+
* one treats a module change as an authorization change, the other only a permission
|
|
146
|
+
* change. Pair it with `useLiveAuthz`/`startLiveAuthz`, which single-flights callers.
|
|
147
|
+
*/
|
|
148
|
+
refresh: () => Promise<boolean>;
|
|
139
149
|
}
|
|
140
150
|
declare function useAuth(): UseAuth;
|
|
141
151
|
/** Run this on your callback route to complete a sign-in (see `<AuthCallback>`). */
|
|
@@ -239,6 +249,8 @@ interface SignInLabels {
|
|
|
239
249
|
noAccess: string;
|
|
240
250
|
passwordChangeRequired: string;
|
|
241
251
|
genericError: string;
|
|
252
|
+
/** Reserved second-factor step (F020). Unreachable until MFA ships. */
|
|
253
|
+
verificationRequired?: string;
|
|
242
254
|
}
|
|
243
255
|
/**
|
|
244
256
|
* `card` renders just the card — drop it into your own layout.
|
|
@@ -500,6 +512,70 @@ interface Viewport {
|
|
|
500
512
|
*/
|
|
501
513
|
declare function resolveSide(preferred: SideOption, trigger: Rect, menu: Size, viewport: Viewport, gap?: number): Side;
|
|
502
514
|
//#endregion
|
|
515
|
+
//#region src/components/user-profile.d.ts
|
|
516
|
+
/** Every user-facing string, overridable for i18n / white-labelling (FR-BRAND-4). */
|
|
517
|
+
interface UserProfileLabels {
|
|
518
|
+
trigger: string;
|
|
519
|
+
title: string;
|
|
520
|
+
description: string;
|
|
521
|
+
firstName: string;
|
|
522
|
+
lastName: string;
|
|
523
|
+
phoneNumber: string;
|
|
524
|
+
cnic: string;
|
|
525
|
+
gender: string;
|
|
526
|
+
photo: string;
|
|
527
|
+
changePhoto: string;
|
|
528
|
+
optional: string;
|
|
529
|
+
save: string;
|
|
530
|
+
saving: string;
|
|
531
|
+
cancel: string;
|
|
532
|
+
close: string;
|
|
533
|
+
loading: string;
|
|
534
|
+
loadFailed: string;
|
|
535
|
+
saveFailed: string;
|
|
536
|
+
saved: string;
|
|
537
|
+
signedOut: string;
|
|
538
|
+
genderUnset: string;
|
|
539
|
+
genderMale: string;
|
|
540
|
+
genderFemale: string;
|
|
541
|
+
genderOther: string;
|
|
542
|
+
}
|
|
543
|
+
interface UserProfileProps {
|
|
544
|
+
/** Replaces the trigger's contents. The SDK still owns the button and its dialog semantics. */
|
|
545
|
+
trigger?: ReactNode;
|
|
546
|
+
/** Render no trigger at all and control the dialog from outside (`open` / `onOpenChange`). */
|
|
547
|
+
open?: boolean;
|
|
548
|
+
defaultOpen?: boolean;
|
|
549
|
+
onOpenChange?: (open: boolean) => void;
|
|
550
|
+
/** Notified after a successful save, with the saved profile (FR-PROF-10). */
|
|
551
|
+
onSaved?: (user: Record<string, unknown>) => void;
|
|
552
|
+
/** Appended to the root element's class list. */
|
|
553
|
+
className?: string;
|
|
554
|
+
/** Appended to the trigger button's class list — the element a consumer places in their layout. */
|
|
555
|
+
triggerClassName?: string;
|
|
556
|
+
/** Appended to the dialog's class list. */
|
|
557
|
+
dialogClassName?: string;
|
|
558
|
+
labels?: Partial<UserProfileLabels>;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* The signed-in person's own profile, as a dialog (v0.4 / FR-PROF).
|
|
562
|
+
*
|
|
563
|
+
* Every application that wanted this had to build the same four things: a form, a validation
|
|
564
|
+
* ruleset guessed at from error messages, a file upload, and — because the browser holds no
|
|
565
|
+
* credential under BFF custody — a server route to carry the call. The last of those is
|
|
566
|
+
* security-adjacent work that had no business being duplicated per app.
|
|
567
|
+
*
|
|
568
|
+
* The credential never comes near this component: it posts to the SDK's own route, which
|
|
569
|
+
* attaches the session server-side and takes the identity from the sealed session rather than
|
|
570
|
+
* from anything sent here. This surface cannot be aimed at another person's profile even if a
|
|
571
|
+
* caller tries (FR-CUSTODY-4 / D24).
|
|
572
|
+
*
|
|
573
|
+
* ```tsx
|
|
574
|
+
* <UserProfile onSaved={() => router.refresh()} />
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
declare function UserProfile(props: UserProfileProps): ReactNode;
|
|
578
|
+
//#endregion
|
|
503
579
|
//#region src/components/user-button.d.ts
|
|
504
580
|
/** Every user-facing string, overridable for i18n / white-labelling. */
|
|
505
581
|
interface UserButtonLabels {
|
|
@@ -542,6 +618,17 @@ interface UserButtonProps {
|
|
|
542
618
|
* hosted profile page, so the destination is the consumer's to own.
|
|
543
619
|
*/
|
|
544
620
|
manageAccountUrl?: string;
|
|
621
|
+
/**
|
|
622
|
+
* Make "Manage account" open the SDK's own `<UserProfile/>` dialog instead of navigating
|
|
623
|
+
* (v0.4 / FR-PROF-8). Opt-in, so an app that already links its menu to its own account page
|
|
624
|
+
* keeps that behavior untouched (FR-COMPAT-2).
|
|
625
|
+
*
|
|
626
|
+
* Ignored when `manageAccountUrl` is set — a menu entry that both navigates and opens a
|
|
627
|
+
* dialog is a bug, so the explicit destination wins and this is a no-op.
|
|
628
|
+
*/
|
|
629
|
+
showUserProfile?: boolean;
|
|
630
|
+
/** Passed through to the dialog `showUserProfile` opens. */
|
|
631
|
+
userProfileProps?: Omit<UserProfileProps, "open" | "onOpenChange">;
|
|
545
632
|
/** Offer "Sign out everywhere" (ends every session for the user). Default `false`. */
|
|
546
633
|
showSignOutEverywhere?: boolean;
|
|
547
634
|
/** Start with the menu open. Default `false`. */
|
|
@@ -631,6 +718,23 @@ declare function UserAvatar({
|
|
|
631
718
|
className
|
|
632
719
|
}: UserAvatarProps): ReactNode;
|
|
633
720
|
//#endregion
|
|
721
|
+
//#region src/auth-event.d.ts
|
|
722
|
+
/**
|
|
723
|
+
* Read a one-shot auth event published by the BFF (F017 / FR-CLIENT-5).
|
|
724
|
+
*
|
|
725
|
+
* Sign-in and sign-out are full-page navigations, so an app cannot simply react in the
|
|
726
|
+
* handler that triggered them — the page is gone. The BFF leaves a short-lived, readable
|
|
727
|
+
* cookie; the destination page consumes it once.
|
|
728
|
+
*/
|
|
729
|
+
type AuthEventKind = "signed-in" | "signed-out";
|
|
730
|
+
/**
|
|
731
|
+
* Read the pending auth event and clear it, so it fires exactly once.
|
|
732
|
+
*
|
|
733
|
+
* Returns `null` when there is nothing pending — which is the normal case on almost every
|
|
734
|
+
* page load. Safe to call during render or in an effect; it is a no-op on the server.
|
|
735
|
+
*/
|
|
736
|
+
declare function consumeAuthEvent(): AuthEventKind | null;
|
|
737
|
+
//#endregion
|
|
634
738
|
//#region src/live-authz.d.ts
|
|
635
739
|
/**
|
|
636
740
|
* @poly-x/react/live-authz — keeps live claims current (SDK v2: FR-LIVE, FR-SIG, FR-TRIG).
|
|
@@ -699,6 +803,7 @@ declare function useAuthzChanged(callback: () => void): void;
|
|
|
699
803
|
* F006; this entry is the state foundation (provider, hooks, browser seams).
|
|
700
804
|
*/
|
|
701
805
|
declare const PACKAGE_NAME = "@poly-x/react";
|
|
702
|
-
|
|
806
|
+
/** The published version of this package, injected at build time. */
|
|
807
|
+
declare const version: string;
|
|
703
808
|
//#endregion
|
|
704
|
-
export { type Align, AuthCallback, type AuthCallbackMessage, type AuthCallbackProps, type AuthChannel, BroadcastAuthChannel, BroadcastChannelSessionChannel, type BrowserBridge, type CallbackParams, type CaptureOptions, type CapturedGeo, ForgotPassword, type ForgotPasswordLabels, type ForgotPasswordProps, type GeolocationLike, type LiveAuthzHandle, type LiveAuthzOptions, type LoginController, type LoginControllerDeps, PACKAGE_NAME, PolyXContext, type PolyXContextValue, PolyXProvider, type PolyXProviderProps, PopupCancelledError, type PopupHandle, Protected, type ProtectedProps, ResetPassword, type ResetPasswordLabels, type ResetPasswordProps, SessionStoragePkceStore, type Side, type SideOption, SignIn, type SignInLabels, type SignInOptions, type SignInProps, type SignInVariant, type UseAuth, type UseLiveAuthzOptions, UserAvatar, type UserAvatarProps, UserButton, type UserButtonActionProps, type UserButtonLabels, type UserButtonLinkProps, type UserButtonProps, type UserButtonSlotProps, WebLocksLock, WindowBrowserBridge, capturePreciseLocation, createLoginController, initialsFrom, resolveSide, startLiveAuthz, useAuth, useAuthCallback, useAuthzChanged, useLiveAuthz, useSession, useUser, version };
|
|
809
|
+
export { type Align, AuthCallback, type AuthCallbackMessage, type AuthCallbackProps, type AuthChannel, type AuthEventKind, BroadcastAuthChannel, BroadcastChannelSessionChannel, type BrowserBridge, type CallbackParams, type CaptureOptions, type CapturedGeo, ForgotPassword, type ForgotPasswordLabels, type ForgotPasswordProps, type GeolocationLike, type LiveAuthzHandle, type LiveAuthzOptions, type LoginController, type LoginControllerDeps, PACKAGE_NAME, PolyXContext, type PolyXContextValue, PolyXProvider, type PolyXProviderProps, PopupCancelledError, type PopupHandle, Protected, type ProtectedProps, ResetPassword, type ResetPasswordLabels, type ResetPasswordProps, SessionStoragePkceStore, type Side, type SideOption, SignIn, type SignInLabels, type SignInOptions, type SignInProps, type SignInVariant, type UseAuth, type UseLiveAuthzOptions, UserAvatar, type UserAvatarProps, UserButton, type UserButtonActionProps, type UserButtonLabels, type UserButtonLinkProps, type UserButtonProps, type UserButtonSlotProps, UserProfile, type UserProfileLabels, type UserProfileProps, WebLocksLock, WindowBrowserBridge, capturePreciseLocation, consumeAuthEvent, createLoginController, initialsFrom, resolveSide, startLiveAuthz, useAuth, useAuthCallback, useAuthzChanged, useLiveAuthz, useSession, useUser, version };
|
package/dist/index.d.mts
CHANGED
|
@@ -136,6 +136,16 @@ interface UseAuth {
|
|
|
136
136
|
* BFF custody, where the token is httpOnly server-side by design (FR-SES-3).
|
|
137
137
|
*/
|
|
138
138
|
getToken: () => Promise<string | null>;
|
|
139
|
+
/**
|
|
140
|
+
* Re-read the session's authorization from the server and resolve whether it actually
|
|
141
|
+
* changed (FR-CLIENT-3).
|
|
142
|
+
*
|
|
143
|
+
* This capability already existed on the BFF store but was not reachable from the public
|
|
144
|
+
* surface, so both consuming apps wrote their own refresher — and they already differ:
|
|
145
|
+
* one treats a module change as an authorization change, the other only a permission
|
|
146
|
+
* change. Pair it with `useLiveAuthz`/`startLiveAuthz`, which single-flights callers.
|
|
147
|
+
*/
|
|
148
|
+
refresh: () => Promise<boolean>;
|
|
139
149
|
}
|
|
140
150
|
declare function useAuth(): UseAuth;
|
|
141
151
|
/** Run this on your callback route to complete a sign-in (see `<AuthCallback>`). */
|
|
@@ -239,6 +249,8 @@ interface SignInLabels {
|
|
|
239
249
|
noAccess: string;
|
|
240
250
|
passwordChangeRequired: string;
|
|
241
251
|
genericError: string;
|
|
252
|
+
/** Reserved second-factor step (F020). Unreachable until MFA ships. */
|
|
253
|
+
verificationRequired?: string;
|
|
242
254
|
}
|
|
243
255
|
/**
|
|
244
256
|
* `card` renders just the card — drop it into your own layout.
|
|
@@ -500,6 +512,70 @@ interface Viewport {
|
|
|
500
512
|
*/
|
|
501
513
|
declare function resolveSide(preferred: SideOption, trigger: Rect, menu: Size, viewport: Viewport, gap?: number): Side;
|
|
502
514
|
//#endregion
|
|
515
|
+
//#region src/components/user-profile.d.ts
|
|
516
|
+
/** Every user-facing string, overridable for i18n / white-labelling (FR-BRAND-4). */
|
|
517
|
+
interface UserProfileLabels {
|
|
518
|
+
trigger: string;
|
|
519
|
+
title: string;
|
|
520
|
+
description: string;
|
|
521
|
+
firstName: string;
|
|
522
|
+
lastName: string;
|
|
523
|
+
phoneNumber: string;
|
|
524
|
+
cnic: string;
|
|
525
|
+
gender: string;
|
|
526
|
+
photo: string;
|
|
527
|
+
changePhoto: string;
|
|
528
|
+
optional: string;
|
|
529
|
+
save: string;
|
|
530
|
+
saving: string;
|
|
531
|
+
cancel: string;
|
|
532
|
+
close: string;
|
|
533
|
+
loading: string;
|
|
534
|
+
loadFailed: string;
|
|
535
|
+
saveFailed: string;
|
|
536
|
+
saved: string;
|
|
537
|
+
signedOut: string;
|
|
538
|
+
genderUnset: string;
|
|
539
|
+
genderMale: string;
|
|
540
|
+
genderFemale: string;
|
|
541
|
+
genderOther: string;
|
|
542
|
+
}
|
|
543
|
+
interface UserProfileProps {
|
|
544
|
+
/** Replaces the trigger's contents. The SDK still owns the button and its dialog semantics. */
|
|
545
|
+
trigger?: ReactNode;
|
|
546
|
+
/** Render no trigger at all and control the dialog from outside (`open` / `onOpenChange`). */
|
|
547
|
+
open?: boolean;
|
|
548
|
+
defaultOpen?: boolean;
|
|
549
|
+
onOpenChange?: (open: boolean) => void;
|
|
550
|
+
/** Notified after a successful save, with the saved profile (FR-PROF-10). */
|
|
551
|
+
onSaved?: (user: Record<string, unknown>) => void;
|
|
552
|
+
/** Appended to the root element's class list. */
|
|
553
|
+
className?: string;
|
|
554
|
+
/** Appended to the trigger button's class list — the element a consumer places in their layout. */
|
|
555
|
+
triggerClassName?: string;
|
|
556
|
+
/** Appended to the dialog's class list. */
|
|
557
|
+
dialogClassName?: string;
|
|
558
|
+
labels?: Partial<UserProfileLabels>;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* The signed-in person's own profile, as a dialog (v0.4 / FR-PROF).
|
|
562
|
+
*
|
|
563
|
+
* Every application that wanted this had to build the same four things: a form, a validation
|
|
564
|
+
* ruleset guessed at from error messages, a file upload, and — because the browser holds no
|
|
565
|
+
* credential under BFF custody — a server route to carry the call. The last of those is
|
|
566
|
+
* security-adjacent work that had no business being duplicated per app.
|
|
567
|
+
*
|
|
568
|
+
* The credential never comes near this component: it posts to the SDK's own route, which
|
|
569
|
+
* attaches the session server-side and takes the identity from the sealed session rather than
|
|
570
|
+
* from anything sent here. This surface cannot be aimed at another person's profile even if a
|
|
571
|
+
* caller tries (FR-CUSTODY-4 / D24).
|
|
572
|
+
*
|
|
573
|
+
* ```tsx
|
|
574
|
+
* <UserProfile onSaved={() => router.refresh()} />
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
declare function UserProfile(props: UserProfileProps): ReactNode;
|
|
578
|
+
//#endregion
|
|
503
579
|
//#region src/components/user-button.d.ts
|
|
504
580
|
/** Every user-facing string, overridable for i18n / white-labelling. */
|
|
505
581
|
interface UserButtonLabels {
|
|
@@ -542,6 +618,17 @@ interface UserButtonProps {
|
|
|
542
618
|
* hosted profile page, so the destination is the consumer's to own.
|
|
543
619
|
*/
|
|
544
620
|
manageAccountUrl?: string;
|
|
621
|
+
/**
|
|
622
|
+
* Make "Manage account" open the SDK's own `<UserProfile/>` dialog instead of navigating
|
|
623
|
+
* (v0.4 / FR-PROF-8). Opt-in, so an app that already links its menu to its own account page
|
|
624
|
+
* keeps that behavior untouched (FR-COMPAT-2).
|
|
625
|
+
*
|
|
626
|
+
* Ignored when `manageAccountUrl` is set — a menu entry that both navigates and opens a
|
|
627
|
+
* dialog is a bug, so the explicit destination wins and this is a no-op.
|
|
628
|
+
*/
|
|
629
|
+
showUserProfile?: boolean;
|
|
630
|
+
/** Passed through to the dialog `showUserProfile` opens. */
|
|
631
|
+
userProfileProps?: Omit<UserProfileProps, "open" | "onOpenChange">;
|
|
545
632
|
/** Offer "Sign out everywhere" (ends every session for the user). Default `false`. */
|
|
546
633
|
showSignOutEverywhere?: boolean;
|
|
547
634
|
/** Start with the menu open. Default `false`. */
|
|
@@ -631,6 +718,23 @@ declare function UserAvatar({
|
|
|
631
718
|
className
|
|
632
719
|
}: UserAvatarProps): ReactNode;
|
|
633
720
|
//#endregion
|
|
721
|
+
//#region src/auth-event.d.ts
|
|
722
|
+
/**
|
|
723
|
+
* Read a one-shot auth event published by the BFF (F017 / FR-CLIENT-5).
|
|
724
|
+
*
|
|
725
|
+
* Sign-in and sign-out are full-page navigations, so an app cannot simply react in the
|
|
726
|
+
* handler that triggered them — the page is gone. The BFF leaves a short-lived, readable
|
|
727
|
+
* cookie; the destination page consumes it once.
|
|
728
|
+
*/
|
|
729
|
+
type AuthEventKind = "signed-in" | "signed-out";
|
|
730
|
+
/**
|
|
731
|
+
* Read the pending auth event and clear it, so it fires exactly once.
|
|
732
|
+
*
|
|
733
|
+
* Returns `null` when there is nothing pending — which is the normal case on almost every
|
|
734
|
+
* page load. Safe to call during render or in an effect; it is a no-op on the server.
|
|
735
|
+
*/
|
|
736
|
+
declare function consumeAuthEvent(): AuthEventKind | null;
|
|
737
|
+
//#endregion
|
|
634
738
|
//#region src/live-authz.d.ts
|
|
635
739
|
/**
|
|
636
740
|
* @poly-x/react/live-authz — keeps live claims current (SDK v2: FR-LIVE, FR-SIG, FR-TRIG).
|
|
@@ -699,6 +803,7 @@ declare function useAuthzChanged(callback: () => void): void;
|
|
|
699
803
|
* F006; this entry is the state foundation (provider, hooks, browser seams).
|
|
700
804
|
*/
|
|
701
805
|
declare const PACKAGE_NAME = "@poly-x/react";
|
|
702
|
-
|
|
806
|
+
/** The published version of this package, injected at build time. */
|
|
807
|
+
declare const version: string;
|
|
703
808
|
//#endregion
|
|
704
|
-
export { type Align, AuthCallback, type AuthCallbackMessage, type AuthCallbackProps, type AuthChannel, BroadcastAuthChannel, BroadcastChannelSessionChannel, type BrowserBridge, type CallbackParams, type CaptureOptions, type CapturedGeo, ForgotPassword, type ForgotPasswordLabels, type ForgotPasswordProps, type GeolocationLike, type LiveAuthzHandle, type LiveAuthzOptions, type LoginController, type LoginControllerDeps, PACKAGE_NAME, PolyXContext, type PolyXContextValue, PolyXProvider, type PolyXProviderProps, PopupCancelledError, type PopupHandle, Protected, type ProtectedProps, ResetPassword, type ResetPasswordLabels, type ResetPasswordProps, SessionStoragePkceStore, type Side, type SideOption, SignIn, type SignInLabels, type SignInOptions, type SignInProps, type SignInVariant, type UseAuth, type UseLiveAuthzOptions, UserAvatar, type UserAvatarProps, UserButton, type UserButtonActionProps, type UserButtonLabels, type UserButtonLinkProps, type UserButtonProps, type UserButtonSlotProps, WebLocksLock, WindowBrowserBridge, capturePreciseLocation, createLoginController, initialsFrom, resolveSide, startLiveAuthz, useAuth, useAuthCallback, useAuthzChanged, useLiveAuthz, useSession, useUser, version };
|
|
809
|
+
export { type Align, AuthCallback, type AuthCallbackMessage, type AuthCallbackProps, type AuthChannel, type AuthEventKind, BroadcastAuthChannel, BroadcastChannelSessionChannel, type BrowserBridge, type CallbackParams, type CaptureOptions, type CapturedGeo, ForgotPassword, type ForgotPasswordLabels, type ForgotPasswordProps, type GeolocationLike, type LiveAuthzHandle, type LiveAuthzOptions, type LoginController, type LoginControllerDeps, PACKAGE_NAME, PolyXContext, type PolyXContextValue, PolyXProvider, type PolyXProviderProps, PopupCancelledError, type PopupHandle, Protected, type ProtectedProps, ResetPassword, type ResetPasswordLabels, type ResetPasswordProps, SessionStoragePkceStore, type Side, type SideOption, SignIn, type SignInLabels, type SignInOptions, type SignInProps, type SignInVariant, type UseAuth, type UseLiveAuthzOptions, UserAvatar, type UserAvatarProps, UserButton, type UserButtonActionProps, type UserButtonLabels, type UserButtonLinkProps, type UserButtonProps, type UserButtonSlotProps, UserProfile, type UserProfileLabels, type UserProfileProps, WebLocksLock, WindowBrowserBridge, capturePreciseLocation, consumeAuthEvent, createLoginController, initialsFrom, resolveSide, startLiveAuthz, useAuth, useAuthCallback, useAuthzChanged, useLiveAuthz, useSession, useUser, version };
|