@petrarca/sonnet-shell 0.4.2 → 0.6.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/dist/auth/index.d.ts +42 -30
- package/dist/auth/index.js +412 -119
- package/dist/auth/index.js.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,43 +1,50 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* multiple
|
|
6
|
-
* before the app loads.
|
|
4
|
+
* OrgSelection -- shown after authentication when the user belongs to
|
|
5
|
+
* multiple organizations and no default is set. The user selects which
|
|
6
|
+
* organization context to act in before the app loads.
|
|
7
|
+
*
|
|
8
|
+
* "Organization" is used generically: in Sestina this is an org-unit; in
|
|
9
|
+
* another app it could be a tenant, workspace, team, or company. The
|
|
10
|
+
* consumer maps their domain type to OrgOption.
|
|
7
11
|
*
|
|
8
12
|
* Fully props-driven with no app-specific imports.
|
|
9
13
|
* Target package: @petrarca/sonnet-shell
|
|
10
14
|
*/
|
|
11
|
-
/** Minimal
|
|
12
|
-
interface
|
|
15
|
+
/** Minimal organization descriptor. Consumers map their domain type to this shape. */
|
|
16
|
+
interface OrgOption {
|
|
13
17
|
id: string;
|
|
14
18
|
name: string;
|
|
15
19
|
}
|
|
16
|
-
interface
|
|
17
|
-
|
|
20
|
+
interface OrgSelectionProps {
|
|
21
|
+
orgs: OrgOption[];
|
|
18
22
|
isLoading: boolean;
|
|
19
23
|
error: string | null;
|
|
20
24
|
onSelect: (id: string) => void;
|
|
21
25
|
}
|
|
22
|
-
declare function
|
|
26
|
+
declare function OrgSelection({ orgs, isLoading, error, onSelect, }: OrgSelectionProps): React.ReactElement;
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* Login -- multi-step authentication flow.
|
|
26
30
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* Steps:
|
|
32
|
+
* identifier -- email/username entry (when onDiscover is provided)
|
|
33
|
+
* auth -- resolved providers: password form first, SSO buttons below
|
|
34
|
+
* credentials -- legacy single-screen (no onDiscover)
|
|
35
|
+
* org-selection -- organization picker after successful auth
|
|
36
|
+
*
|
|
37
|
+
* When onDiscover is NOT provided, falls back to the legacy single-screen
|
|
38
|
+
* behaviour. Backward compatible.
|
|
29
39
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
40
|
+
* All async operations are injected via props. The component knows nothing
|
|
41
|
+
* about OIDC, PKCE, Sestina, or discover endpoints.
|
|
32
42
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
43
|
+
* Design: centered card on gray-100, white card with elevated shadow,
|
|
44
|
+
* consistent with Auth0 Universal Login / WorkOS AuthKit visual language.
|
|
35
45
|
*
|
|
36
|
-
* All auth state and operations are injected via props -- no direct
|
|
37
|
-
* store or context imports.
|
|
38
46
|
* Target package: @petrarca/sonnet-shell
|
|
39
47
|
*/
|
|
40
|
-
/** Auth feature flags and provider configuration. Consumer-supplied. */
|
|
41
48
|
interface AuthConfig {
|
|
42
49
|
enabled: boolean;
|
|
43
50
|
features: {
|
|
@@ -55,30 +62,35 @@ interface AuthConfig {
|
|
|
55
62
|
direct_redirect: string | null;
|
|
56
63
|
};
|
|
57
64
|
}
|
|
65
|
+
interface LoginProvider {
|
|
66
|
+
type: "local" | "external";
|
|
67
|
+
name: string;
|
|
68
|
+
label: string;
|
|
69
|
+
}
|
|
58
70
|
interface LoginProps {
|
|
59
|
-
/** Auth feature flags and OAuth provider config. */
|
|
60
71
|
config: AuthConfig | null;
|
|
61
|
-
/** Whether the user is currently authenticated (token present). */
|
|
62
72
|
isAuthenticated: boolean;
|
|
63
|
-
/** Active tenant id, null when not yet selected. */
|
|
64
73
|
activeTenantId: string | null;
|
|
65
|
-
/** Whether an async operation is in flight. */
|
|
66
74
|
isLoading: boolean;
|
|
67
|
-
/** Auth error message to display, null when none. */
|
|
68
75
|
error: string | null;
|
|
69
|
-
|
|
70
|
-
tenants: TenantOption[] | null;
|
|
71
|
-
/** Perform credential login. Throws on failure. */
|
|
76
|
+
orgs: OrgOption[] | null;
|
|
72
77
|
onLogin: (credentials: {
|
|
73
78
|
identifier: string;
|
|
74
79
|
password: string;
|
|
75
80
|
}) => Promise<void>;
|
|
76
|
-
/** Fetch the current user after login to resolve tenant state. */
|
|
77
81
|
onFetchCurrentUser: () => Promise<void>;
|
|
78
|
-
|
|
79
|
-
onSwitchTenant: (id: string) => Promise<void>;
|
|
80
|
-
/** Clear the current auth error. */
|
|
82
|
+
onSelectOrg: (id: string) => Promise<void>;
|
|
81
83
|
onClearError: () => void;
|
|
84
|
+
/** Application name shown above the card as a brand label. */
|
|
85
|
+
appName?: string;
|
|
86
|
+
/** Logo URL shown above the card. If provided, appName is used as alt text. */
|
|
87
|
+
logoUrl?: string;
|
|
88
|
+
/** Enables identifier-first flow. App calls discover endpoint and returns providers. */
|
|
89
|
+
onDiscover?: (identifier: string) => Promise<LoginProvider[]>;
|
|
90
|
+
/** Called when user clicks an external provider button. App handles PKCE + redirect. */
|
|
91
|
+
onExternalLogin?: (provider: LoginProvider) => Promise<void> | void;
|
|
92
|
+
/** Whether discovery is in flight. */
|
|
93
|
+
isDiscovering?: boolean;
|
|
82
94
|
}
|
|
83
95
|
declare function Login(props: LoginProps): React.ReactElement | null;
|
|
84
96
|
|
|
@@ -114,4 +126,4 @@ interface ProtectedRouteProps {
|
|
|
114
126
|
}
|
|
115
127
|
declare function ProtectedRoute({ children, authEnabled, authConfigLoading, isAuthenticated, accessToken, activeTenantId, initializeAuth, }: ProtectedRouteProps): React.ReactElement;
|
|
116
128
|
|
|
117
|
-
export { type AuthConfig, Login, type LoginProps,
|
|
129
|
+
export { type AuthConfig, Login, type LoginProps, type LoginProvider, type OrgOption, OrgSelection, ProtectedRoute, type ProtectedRouteProps };
|