@asgardeo/react 0.5.14 → 0.5.16

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.
@@ -20,7 +20,12 @@ import { BaseSignInButtonProps } from './BaseSignInButton';
20
20
  /**
21
21
  * Props interface of {@link SignInButton}
22
22
  */
23
- export type SignInButtonProps = BaseSignInButtonProps;
23
+ export type SignInButtonProps = BaseSignInButtonProps & {
24
+ /**
25
+ * Additional parameters to pass to the `authorize` request.
26
+ */
27
+ signInOptions?: Record<string, any>;
28
+ };
24
29
  /**
25
30
  * SignInButton component that supports both render props and traditional props patterns.
26
31
  *
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { Context } from 'react';
19
- import { HttpRequestConfig, HttpResponse, Organization } from '@asgardeo/browser';
19
+ import { HttpRequestConfig, HttpResponse, IdToken, Organization, SignInOptions } from '@asgardeo/browser';
20
20
  import AsgardeoReactClient from '../../AsgardeoReactClient';
21
21
  /**
22
22
  * Props interface of {@link AsgardeoContext}
@@ -77,6 +77,24 @@ export type AsgardeoContextProps = {
77
77
  */
78
78
  requestAll: (requestConfigs?: HttpRequestConfig[]) => Promise<HttpResponse<any>[]>;
79
79
  };
80
+ /**
81
+ * Optional additional parameters to be sent in the sign-in request.
82
+ * This can include custom parameters that your authorization server supports.
83
+ * These parameters will be included in the authorization request sent to the server.
84
+ * If not provided, no additional parameters will be sent.
85
+ *
86
+ * @example
87
+ * signInOptions: { prompt: "login", fidp: "OrganizationSSO" }
88
+ */
89
+ signInOptions?: SignInOptions;
90
+ /**
91
+ * Function to retrieve the decoded ID token.
92
+ * This function decodes the ID token and returns its payload.
93
+ * It can be used to access user claims and other information contained in the ID token.
94
+ *
95
+ * @returns A promise that resolves to the decoded ID token payload.
96
+ */
97
+ getDecodedIdToken?: () => Promise<IdToken>;
80
98
  };
81
99
  /**
82
100
  * Context object for managing the Authentication flow builder core context.
package/dist/index.js CHANGED
@@ -31,7 +31,9 @@ var AsgardeoContext = createContext({
31
31
  http: {
32
32
  request: () => null,
33
33
  requestAll: () => null
34
- }
34
+ },
35
+ signInOptions: {},
36
+ getDecodedIdToken: null
35
37
  });
36
38
  AsgardeoContext.displayName = "AsgardeoContext";
37
39
  var AsgardeoContext_default = AsgardeoContext;
@@ -1370,6 +1372,8 @@ var AsgardeoProvider = ({
1370
1372
  signUpUrl,
1371
1373
  organizationHandle,
1372
1374
  applicationId,
1375
+ signInOptions,
1376
+ syncSession,
1373
1377
  ...rest
1374
1378
  }) => {
1375
1379
  const reRenderCheckRef = useRef(false);
@@ -1393,6 +1397,8 @@ var AsgardeoProvider = ({
1393
1397
  scopes,
1394
1398
  signUpUrl,
1395
1399
  signInUrl,
1400
+ signInOptions,
1401
+ syncSession,
1396
1402
  ...rest
1397
1403
  });
1398
1404
  const [brandingPreference, setBrandingPreference] = useState7(null);
@@ -1630,7 +1636,10 @@ var AsgardeoProvider = ({
1630
1636
  http: {
1631
1637
  request: asgardeo.request.bind(asgardeo),
1632
1638
  requestAll: asgardeo.requestAll.bind(asgardeo)
1633
- }
1639
+ },
1640
+ signInOptions,
1641
+ getDecodedIdToken: asgardeo.getDecodedIdToken.bind(asgardeo),
1642
+ syncSession
1634
1643
  }),
1635
1644
  [
1636
1645
  applicationId,
@@ -1646,7 +1655,9 @@ var AsgardeoProvider = ({
1646
1655
  signIn,
1647
1656
  signInSilently,
1648
1657
  user,
1649
- asgardeo
1658
+ asgardeo,
1659
+ signInOptions,
1660
+ syncSession
1650
1661
  ]
1651
1662
  );
1652
1663
  return /* @__PURE__ */ jsx7(AsgardeoContext_default.Provider, { value, children: /* @__PURE__ */ jsx7(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ jsx7(
@@ -2457,8 +2468,8 @@ var BaseSignInButton_default = BaseSignInButton;
2457
2468
  import { AsgardeoRuntimeError as AsgardeoRuntimeError4 } from "@asgardeo/browser";
2458
2469
  import { forwardRef as forwardRef3, useState as useState9 } from "react";
2459
2470
  import { jsx as jsx11 } from "react/jsx-runtime";
2460
- var SignInButton = forwardRef3(({ children, onClick, preferences, ...rest }, ref) => {
2461
- const { signIn, signInUrl } = useAsgardeo_default();
2471
+ var SignInButton = forwardRef3(({ children, onClick, preferences, signInOptions: overriddenSignInOptions = {}, ...rest }, ref) => {
2472
+ const { signIn, signInUrl, signInOptions } = useAsgardeo_default();
2462
2473
  const { t } = useTranslation_default(preferences?.i18n);
2463
2474
  const [isLoading, setIsLoading] = useState9(false);
2464
2475
  const handleSignIn = async (e) => {
@@ -2468,7 +2479,7 @@ var SignInButton = forwardRef3(({ children, onClick, preferences, ...rest }, ref
2468
2479
  window.history.pushState(null, "", signInUrl);
2469
2480
  window.dispatchEvent(new PopStateEvent("popstate", { state: null }));
2470
2481
  } else {
2471
- await signIn();
2482
+ await signIn(overriddenSignInOptions ?? signInOptions);
2472
2483
  }
2473
2484
  if (onClick) {
2474
2485
  onClick(e);