@asgardeo/react 0.17.0 → 0.18.1

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.
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FlowMetadataResponse, HttpRequestConfig, HttpResponse, IdToken, Organization, SignInOptions, TokenExchangeRequestConfig, TokenResponse } from '@asgardeo/browser';
18
+ import { FlowMetadataResponse, HttpRequestConfig, HttpResponse, IdToken, OIDCDiscoveryApiResponse, Organization, SignInOptions, TokenExchangeRequestConfig, TokenResponse } from '@asgardeo/browser';
19
19
  import { Context } from 'react';
20
20
  import AsgardeoReactClient from '../../AsgardeoReactClient';
21
21
  import { AsgardeoReactConfig } from '../../models/config';
@@ -27,6 +27,17 @@ export type AsgardeoContextProps = {
27
27
  applicationId: string | undefined;
28
28
  baseUrl: string | undefined;
29
29
  clientId: string | undefined;
30
+ /**
31
+ * OIDC discovery data.
32
+ */
33
+ discovery: {
34
+ /**
35
+ * The response from the `.well-known/openid-configuration` endpoint.
36
+ * Contains server capabilities, supported endpoints, and metadata.
37
+ * `null` while loading or when discovery has not been fetched.
38
+ */
39
+ wellKnown: OIDCDiscoveryApiResponse | null;
40
+ };
30
41
  /**
31
42
  * Swaps the current access token with a new one based on the provided configuration (with a grant type).
32
43
  * @param config - Configuration for the token exchange request.
package/dist/index.js CHANGED
@@ -22,6 +22,9 @@ var AsgardeoContext = createContext({
22
22
  clearSession: () => {
23
23
  },
24
24
  clientId: void 0,
25
+ discovery: {
26
+ wellKnown: null
27
+ },
25
28
  exchangeToken: null,
26
29
  getAccessToken: null,
27
30
  getDecodedIdToken: null,
@@ -612,9 +615,10 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
612
615
  if (!resolvedOrganizationHandle) {
613
616
  resolvedOrganizationHandle = deriveOrganizationHandleFromBaseUrl(config?.baseUrl);
614
617
  }
615
- return this.withLoading(
616
- async () => this.asgardeo.init({ ...config, organizationHandle: resolvedOrganizationHandle })
617
- );
618
+ return this.withLoading(async () => {
619
+ this.initializeConfig = { ...config, organizationHandle: resolvedOrganizationHandle };
620
+ return this.asgardeo.init(this.initializeConfig);
621
+ });
618
622
  }
619
623
  reInitialize(config) {
620
624
  return this.withLoading(async () => {
@@ -886,6 +890,10 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
886
890
  navigate(getRedirectBasedSignUpUrl(config));
887
891
  return void 0;
888
892
  }
893
+ async getDiscoveryResponse() {
894
+ const storageManager = await this.asgardeo.getStorageManager();
895
+ return storageManager.loadOpenIDProviderConfiguration();
896
+ }
889
897
  async request(requestConfig) {
890
898
  return this.asgardeo.httpRequest(requestConfig);
891
899
  }
@@ -2034,6 +2042,7 @@ var AsgardeoProvider = ({
2034
2042
  ...rest
2035
2043
  });
2036
2044
  const [isUpdatingSession, setIsUpdatingSession] = useState8(false);
2045
+ const [wellKnown, setWellKnown] = useState8(null);
2037
2046
  const [brandingPreference, setBrandingPreference] = useState8(null);
2038
2047
  const [isBrandingLoading, setIsBrandingLoading] = useState8(false);
2039
2048
  const [brandingError, setBrandingError] = useState8(null);
@@ -2051,6 +2060,7 @@ var AsgardeoProvider = ({
2051
2060
  await asgardeo.initialize(config);
2052
2061
  const initializedConfig = await asgardeo.getConfiguration();
2053
2062
  setConfig(initializedConfig);
2063
+ setWellKnown(await asgardeo.getDiscoveryResponse());
2054
2064
  })();
2055
2065
  }, []);
2056
2066
  async function updateSession() {
@@ -2375,6 +2385,9 @@ var AsgardeoProvider = ({
2375
2385
  baseUrl,
2376
2386
  clearSession,
2377
2387
  clientId,
2388
+ discovery: {
2389
+ wellKnown
2390
+ },
2378
2391
  exchangeToken,
2379
2392
  getAccessToken,
2380
2393
  getDecodedIdToken,
@@ -2411,6 +2424,7 @@ var AsgardeoProvider = ({
2411
2424
  afterSignInUrl,
2412
2425
  baseUrl,
2413
2426
  clientId,
2427
+ wellKnown,
2414
2428
  isInitializedSync,
2415
2429
  isLoadingSync,
2416
2430
  isSignedInSync,