@asgardeo/react 0.11.3 → 0.12.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.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { FC } from 'react';
19
+ /**
20
+ * Props for Callback component
21
+ */
22
+ export interface CallbackProps {
23
+ /**
24
+ * Callback function called when an error occurs
25
+ */
26
+ onError?: (error: Error) => void;
27
+ /**
28
+ * Function to navigate to a different path.
29
+ * If not provided, falls back to the browser navigate utility (SPA navigation via History API for same-origin paths).
30
+ * Provide this prop to enable framework-specific navigation (e.g., from React Router).
31
+ */
32
+ onNavigate?: (path: string) => void;
33
+ }
34
+ /**
35
+ * BaseCallback is a headless component that handles OAuth callback parameter forwarding.
36
+ * This component extracts OAuth parameters (code, state, error) from the URL and forwards them
37
+ * to the original component that initiated the OAuth flow.
38
+ *
39
+ * Works standalone using the browser navigate utility (History API) for navigation by default.
40
+ * Pass an onNavigate prop to enable framework-specific navigation (e.g., via React Router).
41
+ *
42
+ * Flow: Extract OAuth parameters from URL -> Parse state parameter -> Redirect to original path with parameters
43
+ *
44
+ * The original component (SignIn/AcceptInvite) is responsible for:
45
+ * - Processing the OAuth code via the SDK
46
+ * - Calling /flow/execute
47
+ * - Handling the assertion and auth/callback POST
48
+ * - Managing the authenticated session
49
+ */
50
+ export declare const Callback: FC<CallbackProps>;
51
+ export default Callback;
@@ -27,6 +27,7 @@ export interface AcceptInviteFlowResponse {
27
27
  meta?: {
28
28
  components?: any[];
29
29
  };
30
+ redirectURL?: string;
30
31
  };
31
32
  failureReason?: string;
32
33
  flowId: string;
@@ -27,6 +27,14 @@ export interface UseBrowserUrl {
27
27
  * @returns True if the URL contains authentication parameters and matches the afterSignInUrl, or if it contains an error parameter
28
28
  */
29
29
  hasAuthParams: (url: URL, afterSignInUrl: string) => boolean;
30
+ /**
31
+ * Checks if the URL indicates that the authentication flow has been called for this instance.
32
+ *
33
+ * @param url - The URL object to check
34
+ * @param instanceId - The instance ID to check against
35
+ * @returns True if the URL indicates the flow has been called for this instance
36
+ */
37
+ hasCalledForThisInstance: (url: URL, instanceId: number) => boolean;
30
38
  }
31
39
  /**
32
40
  * Hook that provides utilities for handling browser URLs in authentication flows.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { type RefObject } from 'react';
19
+ export interface UseOAuthCallbackOptions {
20
+ /**
21
+ * Current flowId from component state
22
+ */
23
+ currentFlowId: string | null;
24
+ /**
25
+ * SessionStorage key for flowId (defaults to 'asgardeo_flow_id')
26
+ */
27
+ flowIdStorageKey?: string;
28
+ /**
29
+ * Whether the component is initialized and ready to process OAuth callback
30
+ */
31
+ isInitialized: boolean;
32
+ /**
33
+ * Whether a submission is currently in progress
34
+ */
35
+ isSubmitting?: boolean;
36
+ /**
37
+ * Callback when OAuth flow completes successfully
38
+ */
39
+ onComplete?: () => void;
40
+ /**
41
+ * Callback when OAuth flow encounters an error
42
+ */
43
+ onError?: (error: any) => void;
44
+ /**
45
+ * Function to handle flow response after submission
46
+ */
47
+ onFlowChange?: (response: any) => void;
48
+ /**
49
+ * Callback to set loading state at the start of OAuth processing
50
+ */
51
+ onProcessingStart?: () => void;
52
+ /**
53
+ * Function to submit OAuth code to the server
54
+ */
55
+ onSubmit: (payload: OAuthCallbackPayload) => Promise<any>;
56
+ /**
57
+ * Optional external ref to track processed state. If provided, the component
58
+ * manages the ref (allowing resets on flow clear/retry). Otherwise hook manages internally.
59
+ */
60
+ processedRef?: RefObject<boolean>;
61
+ /**
62
+ * Additional handler for setting state (e.g., setFlowId)
63
+ */
64
+ setFlowId?: (flowId: string) => void;
65
+ /**
66
+ * Ref to mark that token validation was attempted (prevents duplicate validation)
67
+ * Used in AcceptInvite to coordinate between OAuth callback and token validation
68
+ */
69
+ tokenValidationAttemptedRef?: RefObject<boolean>;
70
+ }
71
+ export interface OAuthCallbackPayload {
72
+ flowId: string;
73
+ inputs: {
74
+ code: string;
75
+ nonce?: string;
76
+ };
77
+ }
78
+ /**
79
+ * Processes OAuth callbacks by detecting auth code in URL, resolving flowId, and submitting to server.
80
+ * Used by SignIn, SignUp, and AcceptInvite components.
81
+ */
82
+ export declare function useOAuthCallback({ currentFlowId, flowIdStorageKey, isInitialized, isSubmitting, onComplete, onError, onFlowChange, onProcessingStart, onSubmit, processedRef, setFlowId, tokenValidationAttemptedRef, }: UseOAuthCallbackOptions): void;
package/dist/index.d.ts CHANGED
@@ -82,8 +82,9 @@ export { default as BaseSignUp } from './components/presentation/auth/SignUp/Bas
82
82
  export * from './components/presentation/auth/SignUp/BaseSignUp';
83
83
  export { default as SignUp } from './components/presentation/auth/SignUp/SignUp';
84
84
  export * from './components/presentation/auth/SignUp/SignUp';
85
- export { BaseInviteUser, InviteUser } from './components/presentation/auth/InviteUser';
85
+ export * from './components/presentation/auth/InviteUser';
86
86
  export { BaseAcceptInvite, AcceptInvite } from './components/presentation/auth/AcceptInvite';
87
+ export * from './components/auth/Callback/Callback';
87
88
  export { default as IdentifierFirst } from './components/presentation/auth/SignIn/v1/options/IdentifierFirst';
88
89
  export { default as UsernamePassword } from './components/presentation/auth/SignIn/v1/options/UsernamePassword';
89
90
  export { default as GoogleButton } from './components/adapters/GoogleButton';