@asgardeo/react 0.5.0 → 0.5.2

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.
Files changed (28) hide show
  1. package/dist/AsgardeoReactClient.d.ts +3 -2
  2. package/dist/api/{scim2/createOrganization.d.ts → createOrganization.d.ts} +32 -25
  3. package/dist/api/{scim2/getAllOrganizations.d.ts → getAllOrganizations.d.ts} +30 -13
  4. package/dist/api/{scim2/getMeOrganizations.d.ts → getMeOrganizations.d.ts} +35 -10
  5. package/dist/api/{scim2/getOrganization.d.ts → getOrganization.d.ts} +28 -20
  6. package/dist/api/getSchemas.d.ts +67 -0
  7. package/dist/api/getScim2Me.d.ts +67 -0
  8. package/dist/api/updateMeProfile.d.ts +55 -0
  9. package/dist/api/{scim2/updateOrganization.d.ts → updateOrganization.d.ts} +27 -25
  10. package/dist/cjs/index.js +278 -498
  11. package/dist/cjs/index.js.map +4 -4
  12. package/dist/components/control/AsgardeoLoading.d.ts +2 -0
  13. package/dist/components/control/SignedIn.d.ts +2 -0
  14. package/dist/components/control/SignedOut.d.ts +2 -0
  15. package/dist/components/factories/FieldFactory.d.ts +4 -9
  16. package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +1 -1
  17. package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts +1 -1
  18. package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +1 -1
  19. package/dist/components/presentation/SignIn/BaseSignIn.d.ts +4 -0
  20. package/dist/components/presentation/SignIn/SignIn.d.ts +3 -15
  21. package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +6 -2
  22. package/dist/index.d.ts +10 -4
  23. package/dist/index.js +316 -511
  24. package/dist/index.js.map +4 -4
  25. package/package.json +1 -1
  26. package/dist/api/scim2/getMeProfile.d.ts +0 -39
  27. package/dist/api/scim2/getSchemas.d.ts +0 -39
  28. package/dist/api/scim2/updateMeProfile.d.ts +0 -38
package/dist/cjs/index.js CHANGED
@@ -119,11 +119,16 @@ __export(index_exports, {
119
119
  UsernamePassword: () => UsernamePassword_default,
120
120
  createField: () => createField,
121
121
  createOrganization: () => createOrganization_default,
122
+ createPatchOperations: () => import_browser60.createPatchOperations,
122
123
  createSignInOption: () => createSignInOption,
123
124
  createSignInOptionFromAuthenticator: () => createSignInOptionFromAuthenticator,
124
- formatMultiValuedString: () => formatMultiValuedString,
125
+ getAllOrganizations: () => getAllOrganizations_default,
125
126
  getMeOrganizations: () => getMeOrganizations_default,
126
- parseMultiValuedString: () => parseMultiValuedString,
127
+ getMeProfile: () => getScim2Me_default,
128
+ getOrganization: () => getOrganization_default,
129
+ getSchemas: () => getSchemas_default,
130
+ updateMeProfile: () => updateMeProfile_default,
131
+ updateOrganization: () => updateOrganization_default,
127
132
  useAsgardeo: () => useAsgardeo_default,
128
133
  useBrowserUrl: () => useBrowserUrl_default,
129
134
  useFlow: () => useFlow_default,
@@ -144,11 +149,14 @@ var import_react13 = require("react");
144
149
  // src/contexts/Asgardeo/AsgardeoContext.ts
145
150
  var import_react = require("react");
146
151
  var AsgardeoContext = (0, import_react.createContext)({
147
- afterSignInUrl: "",
148
- baseUrl: "",
152
+ signInUrl: void 0,
153
+ signUpUrl: void 0,
154
+ afterSignInUrl: void 0,
155
+ baseUrl: void 0,
149
156
  isInitialized: false,
150
157
  isLoading: true,
151
158
  isSignedIn: false,
159
+ organization: null,
152
160
  signIn: null,
153
161
  signOut: null,
154
162
  signUp: null,
@@ -507,133 +515,78 @@ AuthAPI.DEFAULT_STATE = {
507
515
  };
508
516
  var api_default = AuthAPI;
509
517
 
510
- // src/api/scim2/getMeOrganizations.ts
518
+ // src/api/getMeOrganizations.ts
511
519
  var import_browser2 = require("@asgardeo/browser");
512
520
  var httpClient = import_browser2.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser2.AsgardeoSPAClient.getInstance());
513
- var getMeOrganizations = async ({
514
- baseUrl,
515
- after = "",
516
- authorizedAppName = "",
517
- before = "",
518
- filter = "",
519
- limit = 10,
520
- recursive = false,
521
- ...requestConfig
522
- }) => {
523
- if (!baseUrl) {
524
- throw new import_browser2.AsgardeoAPIError(
525
- "Base URL is required",
526
- "getMeOrganizations-ValidationError-001",
527
- "javascript",
528
- 400,
529
- "Invalid Request"
530
- );
531
- }
532
- const queryParams = new URLSearchParams(
533
- Object.fromEntries(
534
- Object.entries({
535
- after,
536
- authorizedAppName,
537
- before,
538
- filter,
539
- limit: limit.toString(),
540
- recursive: recursive.toString()
541
- }).filter(([, value]) => Boolean(value))
542
- )
543
- );
544
- const response = await httpClient({
545
- headers: {
546
- Accept: "application/json",
547
- "Content-Type": "application/json"
548
- },
549
- method: "GET",
550
- url: `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`,
551
- ...requestConfig
521
+ var getMeOrganizations = async ({ fetcher, ...requestConfig }) => {
522
+ const defaultFetcher = async (url, config) => {
523
+ const response = await httpClient({
524
+ url,
525
+ method: config.method || "GET",
526
+ headers: config.headers
527
+ });
528
+ return {
529
+ ok: response.status >= 200 && response.status < 300,
530
+ status: response.status,
531
+ statusText: response.statusText || "",
532
+ json: () => Promise.resolve(response.data),
533
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
534
+ };
535
+ };
536
+ return (0, import_browser2.getMeOrganizations)({
537
+ ...requestConfig,
538
+ fetcher: fetcher || defaultFetcher
552
539
  });
553
- if (!response.data) {
554
- const errorText = await response.text();
555
- throw new import_browser2.AsgardeoAPIError(
556
- `Failed to fetch associated organizations of the user: ${errorText}`,
557
- "getMeOrganizations-ResponseError-001",
558
- "javascript",
559
- response.status,
560
- response.statusText
561
- );
562
- }
563
- return response.data.organizations || [];
564
540
  };
565
541
  var getMeOrganizations_default = getMeOrganizations;
566
542
 
567
- // src/api/scim2/getMeProfile.ts
543
+ // src/api/getScim2Me.ts
568
544
  var import_browser3 = require("@asgardeo/browser");
569
545
  var httpClient2 = import_browser3.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser3.AsgardeoSPAClient.getInstance());
570
- var getMeProfile = async ({ url, ...requestConfig }) => {
571
- try {
572
- new URL(url);
573
- } catch (error) {
574
- throw new import_browser3.AsgardeoAPIError(
575
- "Invalid endpoint URL provided",
576
- "getMeProfile-ValidationError-001",
577
- "javascript",
578
- 400,
579
- "Invalid Request"
580
- );
581
- }
582
- const response = await httpClient2({
583
- url,
584
- method: "GET",
585
- headers: {
586
- "Content-Type": "application/scim+json",
587
- Accept: "application/json"
588
- }
546
+ var getScim2Me = async ({ fetcher, ...requestConfig }) => {
547
+ const defaultFetcher = async (url, config) => {
548
+ const response = await httpClient2({
549
+ url,
550
+ method: config.method || "GET",
551
+ headers: config.headers
552
+ });
553
+ return {
554
+ ok: response.status >= 200 && response.status < 300,
555
+ status: response.status,
556
+ statusText: response.statusText || "",
557
+ json: () => Promise.resolve(response.data),
558
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
559
+ };
560
+ };
561
+ return (0, import_browser3.getScim2Me)({
562
+ ...requestConfig,
563
+ fetcher: fetcher || defaultFetcher
589
564
  });
590
- if (!response.data) {
591
- const errorText = await response.text();
592
- throw new import_browser3.AsgardeoAPIError(
593
- `Failed to fetch user profile: ${errorText}`,
594
- "getMeProfile-ResponseError-001",
595
- "javascript",
596
- response.status,
597
- response.statusText
598
- );
599
- }
600
- return response.data;
601
565
  };
602
- var getMeProfile_default = getMeProfile;
566
+ var getScim2Me_default = getScim2Me;
603
567
 
604
- // src/api/scim2/getSchemas.ts
568
+ // src/api/getSchemas.ts
605
569
  var import_browser4 = require("@asgardeo/browser");
606
570
  var httpClient3 = import_browser4.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser4.AsgardeoSPAClient.getInstance());
607
- var getSchemas = async ({ url }) => {
608
- try {
609
- new URL(url);
610
- } catch (error) {
611
- throw new import_browser4.AsgardeoAPIError(
612
- "Invalid endpoint URL provided",
613
- "getSchemas-ValidationError-001",
614
- "javascript",
615
- 400,
616
- "Invalid Request"
617
- );
618
- }
619
- const response = await httpClient3({
620
- url,
621
- method: "GET",
622
- headers: {
623
- "Content-Type": "application/json",
624
- Accept: "application/json"
625
- }
571
+ var getSchemas = async ({ fetcher, ...requestConfig }) => {
572
+ const defaultFetcher = async (url, config) => {
573
+ const response = await httpClient3({
574
+ url,
575
+ method: config.method || "GET",
576
+ headers: config.headers
577
+ });
578
+ return {
579
+ ok: response.status >= 200 && response.status < 300,
580
+ status: response.status,
581
+ statusText: response.statusText || "",
582
+ json: () => Promise.resolve(response.data),
583
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
584
+ };
585
+ };
586
+ return (0, import_browser4.getSchemas)({
587
+ ...requestConfig,
588
+ fetcher: fetcher || defaultFetcher
626
589
  });
627
- if (!response.data) {
628
- throw new import_browser4.AsgardeoAPIError(
629
- `Failed to fetch SCIM2 schemas`,
630
- "getSchemas-ResponseError-001",
631
- "javascript",
632
- response.status,
633
- response.statusText
634
- );
635
- }
636
- return response.data;
637
590
  };
638
591
  var getSchemas_default = getSchemas;
639
592
 
@@ -651,8 +604,8 @@ var AsgardeoReactClient = class extends import_browser5.AsgardeoBrowserClient {
651
604
  try {
652
605
  const configData = await this.asgardeo.getConfigData();
653
606
  const baseUrl = configData?.baseUrl;
654
- const profile = await getMeProfile_default({ url: `${baseUrl}/scim2/Me` });
655
- const schemas = await getSchemas_default({ url: `${baseUrl}/scim2/Schemas` });
607
+ const profile = await getScim2Me_default({ baseUrl });
608
+ const schemas = await getSchemas_default({ baseUrl });
656
609
  return (0, import_browser5.generateUserProfile)(profile, (0, import_browser5.flattenUserSchema)(schemas));
657
610
  } catch (error) {
658
611
  return this.asgardeo.getDecodedIdToken();
@@ -662,8 +615,8 @@ var AsgardeoReactClient = class extends import_browser5.AsgardeoBrowserClient {
662
615
  try {
663
616
  const configData = await this.asgardeo.getConfigData();
664
617
  const baseUrl = configData?.baseUrl;
665
- const profile = await getMeProfile_default({ url: `${baseUrl}/scim2/Me` });
666
- const schemas = await getSchemas_default({ url: `${baseUrl}/scim2/Schemas` });
618
+ const profile = await getScim2Me_default({ baseUrl });
619
+ const schemas = await getSchemas_default({ baseUrl });
667
620
  const processedSchemas = (0, import_browser5.flattenUserSchema)(schemas);
668
621
  const output = {
669
622
  schemas: processedSchemas,
@@ -751,6 +704,9 @@ var AsgardeoReactClient = class extends import_browser5.AsgardeoBrowserClient {
751
704
  isSignedIn() {
752
705
  return this.asgardeo.isSignedIn();
753
706
  }
707
+ getConfiguration() {
708
+ return this.asgardeo.getConfigData();
709
+ }
754
710
  async signIn(...args) {
755
711
  const arg1 = args[0];
756
712
  const arg2 = args[1];
@@ -1093,60 +1049,31 @@ var useAsgardeo = () => {
1093
1049
  };
1094
1050
  var useAsgardeo_default = useAsgardeo;
1095
1051
 
1096
- // src/api/scim2/getAllOrganizations.ts
1052
+ // src/api/getAllOrganizations.ts
1097
1053
  var import_browser9 = require("@asgardeo/browser");
1098
1054
  var httpClient4 = import_browser9.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser9.AsgardeoSPAClient.getInstance());
1099
1055
  var getAllOrganizations = async ({
1100
- baseUrl,
1101
- filter = "",
1102
- limit = 10,
1103
- recursive = false,
1056
+ fetcher,
1104
1057
  ...requestConfig
1105
1058
  }) => {
1106
- if (!baseUrl) {
1107
- throw new import_browser9.AsgardeoAPIError(
1108
- "Base URL is required",
1109
- "getAllOrganizations-ValidationError-001",
1110
- "javascript",
1111
- 400,
1112
- "Invalid Request"
1113
- );
1114
- }
1115
- const queryParams = new URLSearchParams(
1116
- Object.fromEntries(
1117
- Object.entries({
1118
- filter,
1119
- limit: limit.toString(),
1120
- recursive: recursive.toString()
1121
- }).filter(([, value]) => Boolean(value))
1122
- )
1123
- );
1124
- const response = await httpClient4({
1125
- headers: {
1126
- Accept: "application/json",
1127
- "Content-Type": "application/json"
1128
- },
1129
- method: "GET",
1130
- url: `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`,
1131
- ...requestConfig
1132
- });
1133
- if (!response.data) {
1134
- const errorText = await response.text();
1135
- throw new import_browser9.AsgardeoAPIError(
1136
- errorText || "Failed to get organizations",
1137
- "getAllOrganizations-NetworkError-001",
1138
- "javascript",
1139
- response.status,
1140
- response.statusText
1141
- );
1142
- }
1143
- const { data } = response;
1144
- return {
1145
- hasMore: data.hasMore,
1146
- nextCursor: data.nextCursor,
1147
- organizations: data.organizations || [],
1148
- totalCount: data.totalCount
1059
+ const defaultFetcher = async (url, config) => {
1060
+ const response = await httpClient4({
1061
+ url,
1062
+ method: config.method || "GET",
1063
+ headers: config.headers
1064
+ });
1065
+ return {
1066
+ ok: response.status >= 200 && response.status < 300,
1067
+ status: response.status,
1068
+ statusText: response.statusText || "",
1069
+ json: () => Promise.resolve(response.data),
1070
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
1071
+ };
1149
1072
  };
1073
+ return (0, import_browser9.getAllOrganizations)({
1074
+ ...requestConfig,
1075
+ fetcher: fetcher || defaultFetcher
1076
+ });
1150
1077
  };
1151
1078
  var getAllOrganizations_default = getAllOrganizations;
1152
1079
 
@@ -1430,6 +1357,8 @@ var AsgardeoProvider = ({
1430
1357
  children,
1431
1358
  scopes,
1432
1359
  preferences,
1360
+ signInUrl,
1361
+ signUpUrl,
1433
1362
  ...rest
1434
1363
  }) => {
1435
1364
  const reRenderCheckRef = (0, import_react13.useRef)(false);
@@ -1448,6 +1377,8 @@ var AsgardeoProvider = ({
1448
1377
  baseUrl,
1449
1378
  clientId,
1450
1379
  scopes,
1380
+ signUpUrl,
1381
+ signInUrl,
1451
1382
  ...rest
1452
1383
  });
1453
1384
  })();
@@ -1567,11 +1498,14 @@ var AsgardeoProvider = ({
1567
1498
  AsgardeoContext_default.Provider,
1568
1499
  {
1569
1500
  value: {
1501
+ signInUrl,
1502
+ signUpUrl,
1570
1503
  afterSignInUrl,
1571
1504
  baseUrl,
1572
1505
  isInitialized: isInitializedSync,
1573
1506
  isLoading: asgardeo.isLoading(),
1574
1507
  isSignedIn: isSignedInSync,
1508
+ organization: currentOrganization,
1575
1509
  signIn,
1576
1510
  signOut,
1577
1511
  signUp,
@@ -2242,20 +2176,25 @@ var import_browser17 = require("@asgardeo/browser");
2242
2176
  var import_react23 = require("react");
2243
2177
  var import_jsx_runtime10 = require("react/jsx-runtime");
2244
2178
  var SignInButton = (0, import_react23.forwardRef)(({ children, onClick, preferences, ...rest }, ref) => {
2245
- const { signIn } = useAsgardeo_default();
2179
+ const { signIn, signInUrl } = useAsgardeo_default();
2246
2180
  const { t } = useTranslation_default(preferences?.i18n);
2247
2181
  const [isLoading, setIsLoading] = (0, import_react23.useState)(false);
2248
2182
  const handleSignIn = async (e) => {
2249
2183
  try {
2250
2184
  setIsLoading(true);
2251
- await signIn();
2185
+ if (signInUrl) {
2186
+ window.history.pushState(null, "", signInUrl);
2187
+ window.dispatchEvent(new PopStateEvent("popstate", { state: null }));
2188
+ } else {
2189
+ await signIn();
2190
+ }
2252
2191
  if (onClick) {
2253
2192
  onClick(e);
2254
2193
  }
2255
2194
  } catch (error) {
2256
2195
  throw new import_browser17.AsgardeoRuntimeError(
2257
2196
  `Sign in failed: ${error instanceof Error ? error.message : String(error)}`,
2258
- "handleSignIn-RuntimeError-001",
2197
+ "SignInButton-handleSignIn-RuntimeError-001",
2259
2198
  "react",
2260
2199
  "Something went wrong while trying to sign in. Please try again later."
2261
2200
  );
@@ -2327,7 +2266,7 @@ var SignOutButton = (0, import_react25.forwardRef)(({ children, onClick, prefere
2327
2266
  } catch (error) {
2328
2267
  throw new import_browser19.AsgardeoRuntimeError(
2329
2268
  `Sign out failed: ${error instanceof Error ? error.message : String(error)}`,
2330
- "handleSignOut-RuntimeError-001",
2269
+ "SignOutButton-handleSignOut-RuntimeError-001",
2331
2270
  "react",
2332
2271
  "Something went wrong while trying to sign out. Please try again later."
2333
2272
  );
@@ -2386,20 +2325,25 @@ var import_browser21 = require("@asgardeo/browser");
2386
2325
  var import_react27 = require("react");
2387
2326
  var import_jsx_runtime14 = require("react/jsx-runtime");
2388
2327
  var SignUpButton = (0, import_react27.forwardRef)(({ children, onClick, preferences, ...rest }, ref) => {
2389
- const { signUp } = useAsgardeo_default();
2328
+ const { signUp, signUpUrl } = useAsgardeo_default();
2390
2329
  const { t } = useTranslation_default(preferences?.i18n);
2391
2330
  const [isLoading, setIsLoading] = (0, import_react27.useState)(false);
2392
2331
  const handleSignUp = async (e) => {
2393
2332
  try {
2394
2333
  setIsLoading(true);
2395
- await signUp();
2334
+ if (signUpUrl) {
2335
+ window.history.pushState(null, "", signUpUrl);
2336
+ window.dispatchEvent(new PopStateEvent("popstate", { state: null }));
2337
+ } else {
2338
+ await signUp();
2339
+ }
2396
2340
  if (onClick) {
2397
2341
  onClick(e);
2398
2342
  }
2399
2343
  } catch (error) {
2400
2344
  throw new import_browser21.AsgardeoRuntimeError(
2401
2345
  `Sign up failed: ${error instanceof Error ? error.message : String(error)}`,
2402
- "handleSignUp-RuntimeError-001",
2346
+ "SignUpButton-handleSignUp-RuntimeError-001",
2403
2347
  "react",
2404
2348
  "Something went wrong while trying to sign up. Please try again later."
2405
2349
  );
@@ -2465,7 +2409,7 @@ var AsgardeoLoading = ({
2465
2409
  }
2466
2410
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children });
2467
2411
  };
2468
- AsgardeoLoading.displayName = "Loading";
2412
+ AsgardeoLoading.displayName = "AsgardeoLoading";
2469
2413
  var AsgardeoLoading_default = AsgardeoLoading;
2470
2414
 
2471
2415
  // src/components/presentation/SignIn/BaseSignIn.tsx
@@ -3253,13 +3197,6 @@ var Checkbox_default = Checkbox;
3253
3197
  // src/components/factories/FieldFactory.tsx
3254
3198
  var import_browser27 = require("@asgardeo/browser");
3255
3199
  var import_jsx_runtime29 = require("react/jsx-runtime");
3256
- var parseMultiValuedString = (value) => {
3257
- if (!value || value.trim() === "") return [];
3258
- return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
3259
- };
3260
- var formatMultiValuedString = (values) => {
3261
- return values.join(", ");
3262
- };
3263
3200
  var validateFieldValue = (value, type, required = false, touched = false) => {
3264
3201
  if (required && touched && (!value || value.trim() === "")) {
3265
3202
  return "This field is required";
@@ -4814,11 +4751,6 @@ var handleWebAuthnAuthentication = async (challengeData) => {
4814
4751
  }))
4815
4752
  }
4816
4753
  };
4817
- console.log("WebAuthn authentication with options:", {
4818
- originalRpId: challengeRpId,
4819
- adjustedRpId: rpIdToUse,
4820
- currentDomain
4821
- });
4822
4754
  const credential = await navigator.credentials.get({
4823
4755
  publicKey: adjustedOptions
4824
4756
  });
@@ -4882,6 +4814,7 @@ var BaseSignIn = (props) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(FlowPr
4882
4814
  var BaseSignInContent = ({
4883
4815
  afterSignInUrl,
4884
4816
  onInitialize,
4817
+ isLoading: externalIsLoading,
4885
4818
  onSubmit,
4886
4819
  onSuccess,
4887
4820
  onError,
@@ -4896,13 +4829,14 @@ var BaseSignInContent = ({
4896
4829
  }) => {
4897
4830
  const { t } = useTranslation_default();
4898
4831
  const { subtitle: flowSubtitle, title: flowTitle, messages: flowMessages } = useFlow_default();
4899
- const [isLoading, setIsLoading] = (0, import_react38.useState)(false);
4832
+ const [isSignInInitializationRequestLoading, setIsSignInInitializationRequestLoading] = (0, import_react38.useState)(false);
4900
4833
  const [isInitialized, setIsInitialized] = (0, import_react38.useState)(false);
4901
4834
  const [currentFlow, setCurrentFlow] = (0, import_react38.useState)(null);
4902
4835
  const [currentAuthenticator, setCurrentAuthenticator] = (0, import_react38.useState)(null);
4903
4836
  const [error, setError] = (0, import_react38.useState)(null);
4904
4837
  const [messages, setMessages] = (0, import_react38.useState)([]);
4905
- const initializationAttemptedRef = (0, import_react38.useRef)(false);
4838
+ const isLoading = externalIsLoading || isSignInInitializationRequestLoading;
4839
+ const reRenderCheckRef = (0, import_react38.useRef)(false);
4906
4840
  const formFields = currentAuthenticator?.metadata?.params?.map((param) => ({
4907
4841
  name: param.param,
4908
4842
  required: currentAuthenticator.requiredParams.includes(param.param),
@@ -4951,7 +4885,7 @@ var BaseSignInContent = ({
4951
4885
  touchAllFields();
4952
4886
  };
4953
4887
  const handleRedirectionIfNeeded = (response) => {
4954
- if ("nextStep" in response && response.nextStep && response.nextStep.stepType === import_browser38.EmbeddedSignInFlowStepType.AuthenticatorPrompt && response.nextStep.authenticators && response.nextStep.authenticators.length === 1) {
4888
+ if (response && "nextStep" in response && response.nextStep && response.nextStep.stepType === import_browser38.EmbeddedSignInFlowStepType.AuthenticatorPrompt && response.nextStep.authenticators && response.nextStep.authenticators.length === 1) {
4955
4889
  const responseAuthenticator = response.nextStep.authenticators[0];
4956
4890
  if (responseAuthenticator.metadata?.promptType === import_browser38.EmbeddedSignInFlowAuthenticatorPromptType.RedirectionPrompt && responseAuthenticator.metadata?.additionalData?.redirectUrl) {
4957
4891
  const redirectUrl = responseAuthenticator.metadata?.additionalData?.redirectUrl;
@@ -5039,7 +4973,7 @@ var BaseSignInContent = ({
5039
4973
  });
5040
4974
  popup.close();
5041
4975
  onFlowChange?.(response2);
5042
- if (response2.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
4976
+ if (response2?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5043
4977
  onSuccess?.(response2.authData);
5044
4978
  }
5045
4979
  }
@@ -5064,7 +4998,7 @@ var BaseSignInContent = ({
5064
4998
  if (!validation.isValid) {
5065
4999
  return;
5066
5000
  }
5067
- setIsLoading(true);
5001
+ setIsSignInInitializationRequestLoading(true);
5068
5002
  setError(null);
5069
5003
  setMessages([]);
5070
5004
  try {
@@ -5080,18 +5014,18 @@ var BaseSignInContent = ({
5080
5014
  url: currentFlow?.links[0].href
5081
5015
  });
5082
5016
  onFlowChange?.(response);
5083
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5017
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5084
5018
  onSuccess?.(response.authData);
5085
5019
  return;
5086
5020
  }
5087
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5021
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5088
5022
  setError(t("errors.sign.in.flow.completion.failure"));
5089
5023
  return;
5090
5024
  }
5091
5025
  if (handleRedirectionIfNeeded(response)) {
5092
5026
  return;
5093
5027
  }
5094
- if ("flowId" in response && "nextStep" in response) {
5028
+ if (response && "flowId" in response && "nextStep" in response) {
5095
5029
  const nextStepResponse = response;
5096
5030
  setCurrentFlow(nextStepResponse);
5097
5031
  if (nextStepResponse.nextStep?.authenticators?.length > 0) {
@@ -5117,7 +5051,7 @@ var BaseSignInContent = ({
5117
5051
  setError(errorMessage);
5118
5052
  onError?.(err);
5119
5053
  } finally {
5120
- setIsLoading(false);
5054
+ setIsSignInInitializationRequestLoading(false);
5121
5055
  }
5122
5056
  };
5123
5057
  const handleAuthenticatorSelection = async (authenticator, formData) => {
@@ -5127,7 +5061,7 @@ var BaseSignInContent = ({
5127
5061
  if (formData) {
5128
5062
  touchAllFields();
5129
5063
  }
5130
- setIsLoading(true);
5064
+ setIsSignInInitializationRequestLoading(true);
5131
5065
  setError(null);
5132
5066
  setMessages([]);
5133
5067
  try {
@@ -5152,15 +5086,15 @@ var BaseSignInContent = ({
5152
5086
  url: currentFlow?.links[0].href
5153
5087
  });
5154
5088
  onFlowChange?.(response);
5155
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5089
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5156
5090
  onSuccess?.(response.authData);
5157
5091
  return;
5158
5092
  }
5159
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5093
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5160
5094
  setError(t("errors.sign.in.flow.passkeys.completion.failure"));
5161
5095
  return;
5162
5096
  }
5163
- if ("flowId" in response && "nextStep" in response) {
5097
+ if (response && "flowId" in response && "nextStep" in response) {
5164
5098
  const nextStepResponse = response;
5165
5099
  setCurrentFlow(nextStepResponse);
5166
5100
  if (nextStepResponse.nextStep?.authenticators?.length > 0) {
@@ -5206,7 +5140,7 @@ var BaseSignInContent = ({
5206
5140
  url: currentFlow?.links[0].href
5207
5141
  });
5208
5142
  onFlowChange?.(response);
5209
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5143
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5210
5144
  onSuccess?.(response.authData);
5211
5145
  return;
5212
5146
  }
@@ -5229,18 +5163,18 @@ var BaseSignInContent = ({
5229
5163
  url: currentFlow?.links[0].href
5230
5164
  });
5231
5165
  onFlowChange?.(response);
5232
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5166
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5233
5167
  onSuccess?.(response.authData);
5234
5168
  return;
5235
5169
  }
5236
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5170
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5237
5171
  setError("Authentication failed. Please check your credentials and try again.");
5238
5172
  return;
5239
5173
  }
5240
5174
  if (handleRedirectionIfNeeded(response)) {
5241
5175
  return;
5242
5176
  }
5243
- if ("flowId" in response && "nextStep" in response) {
5177
+ if (response && "flowId" in response && "nextStep" in response) {
5244
5178
  const nextStepResponse = response;
5245
5179
  setCurrentFlow(nextStepResponse);
5246
5180
  if (nextStepResponse.nextStep?.authenticators?.length > 0) {
@@ -5280,18 +5214,18 @@ var BaseSignInContent = ({
5280
5214
  url: currentFlow?.links[0].href
5281
5215
  });
5282
5216
  onFlowChange?.(response);
5283
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5217
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5284
5218
  onSuccess?.(response.authData);
5285
5219
  return;
5286
5220
  }
5287
- if (response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5221
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailCompleted || response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.FailIncomplete) {
5288
5222
  setError("Authentication failed. Please try again.");
5289
5223
  return;
5290
5224
  }
5291
5225
  if (handleRedirectionIfNeeded(response)) {
5292
5226
  return;
5293
5227
  }
5294
- if ("flowId" in response && "nextStep" in response) {
5228
+ if (response && "flowId" in response && "nextStep" in response) {
5295
5229
  const nextStepResponse = response;
5296
5230
  setCurrentFlow(nextStepResponse);
5297
5231
  if (nextStepResponse.nextStep?.authenticators?.length > 0) {
@@ -5322,11 +5256,11 @@ var BaseSignInContent = ({
5322
5256
  }
5323
5257
  }
5324
5258
  } catch (err) {
5325
- const errorMessage = err instanceof import_browser38.AsgardeoAPIError ? err.message : "Authenticator selection failed";
5259
+ const errorMessage = err instanceof import_browser38.AsgardeoAPIError ? err?.message : "Authenticator selection failed";
5326
5260
  setError(errorMessage);
5327
5261
  onError?.(err);
5328
5262
  } finally {
5329
- setIsLoading(false);
5263
+ setIsSignInInitializationRequestLoading(false);
5330
5264
  }
5331
5265
  };
5332
5266
  const handleInputChange = (param, value) => {
@@ -5370,52 +5304,52 @@ var BaseSignInContent = ({
5370
5304
  const errorClasses = (0, import_clsx15.clsx)([(0, import_browser38.withVendorCSSClassPrefix)("signin__error")], errorClassName);
5371
5305
  const messageClasses = (0, import_clsx15.clsx)([(0, import_browser38.withVendorCSSClassPrefix)("signin__messages")], messageClassName);
5372
5306
  (0, import_react38.useEffect)(() => {
5373
- if (!isInitialized && !initializationAttemptedRef.current) {
5374
- initializationAttemptedRef.current = true;
5375
- const performInitialization = async () => {
5376
- setIsLoading(true);
5377
- setError(null);
5378
- try {
5379
- const response = await onInitialize();
5380
- setCurrentFlow(response);
5381
- setIsInitialized(true);
5382
- onFlowChange?.(response);
5383
- if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5384
- onSuccess?.(response.authData || {});
5385
- return;
5386
- }
5387
- if (response?.nextStep?.authenticators?.length > 0) {
5388
- if (response.nextStep.stepType === import_browser38.EmbeddedSignInFlowStepType.MultiOptionsPrompt && response.nextStep.authenticators.length > 1) {
5389
- setCurrentAuthenticator(null);
5390
- } else {
5391
- const authenticator = response.nextStep.authenticators[0];
5392
- setCurrentAuthenticator(authenticator);
5393
- setupFormFields(authenticator);
5394
- }
5395
- }
5396
- if (response && "nextStep" in response && response.nextStep && "messages" in response.nextStep) {
5397
- const stepMessages = response.nextStep.messages || [];
5398
- setMessages(
5399
- stepMessages.map((msg) => ({
5400
- type: msg.type || "INFO",
5401
- message: msg.message || ""
5402
- }))
5403
- );
5307
+ if (isLoading) {
5308
+ return;
5309
+ }
5310
+ if (reRenderCheckRef.current) {
5311
+ return;
5312
+ }
5313
+ reRenderCheckRef.current = true;
5314
+ (async () => {
5315
+ setIsSignInInitializationRequestLoading(true);
5316
+ setError(null);
5317
+ try {
5318
+ const response = await onInitialize();
5319
+ setCurrentFlow(response);
5320
+ setIsInitialized(true);
5321
+ onFlowChange?.(response);
5322
+ if (response?.flowStatus === import_browser38.EmbeddedSignInFlowStatus.SuccessCompleted) {
5323
+ onSuccess?.(response.authData || {});
5324
+ return;
5325
+ }
5326
+ if (response?.nextStep?.authenticators?.length > 0) {
5327
+ if (response.nextStep.stepType === import_browser38.EmbeddedSignInFlowStepType.MultiOptionsPrompt && response.nextStep.authenticators.length > 1) {
5328
+ setCurrentAuthenticator(null);
5329
+ } else {
5330
+ const authenticator = response.nextStep.authenticators[0];
5331
+ setCurrentAuthenticator(authenticator);
5332
+ setupFormFields(authenticator);
5404
5333
  }
5405
- } catch (err) {
5406
- const errorMessage = err instanceof import_browser38.AsgardeoAPIError ? err.message : t("errors.sign.in.initialization");
5407
- setError(errorMessage);
5408
- onError?.(err);
5409
- } finally {
5410
- setIsLoading(false);
5411
5334
  }
5412
- };
5413
- performInitialization();
5414
- }
5415
- return () => {
5416
- initializationAttemptedRef.current = false;
5417
- };
5418
- }, [isInitialized]);
5335
+ if (response && "nextStep" in response && response.nextStep && "messages" in response.nextStep) {
5336
+ const stepMessages = response.nextStep.messages || [];
5337
+ setMessages(
5338
+ stepMessages.map((msg) => ({
5339
+ type: msg.type || "INFO",
5340
+ message: msg.message || ""
5341
+ }))
5342
+ );
5343
+ }
5344
+ } catch (err) {
5345
+ const errorMessage = err instanceof import_browser38.AsgardeoAPIError ? err.message : t("errors.sign.in.initialization");
5346
+ setError(errorMessage);
5347
+ onError?.(err);
5348
+ } finally {
5349
+ setIsSignInInitializationRequestLoading(false);
5350
+ }
5351
+ })();
5352
+ }, [isLoading]);
5419
5353
  if (!isInitialized && isLoading) {
5420
5354
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Card_default, { className: containerClasses, variant, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Card_default.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", padding: "2rem" }, children: [
5421
5355
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Spinner_default, { size: "medium" }),
@@ -5575,9 +5509,13 @@ var BaseSignIn_default = BaseSignIn;
5575
5509
  // src/components/presentation/SignIn/SignIn.tsx
5576
5510
  var import_jsx_runtime52 = require("react/jsx-runtime");
5577
5511
  var SignIn = ({ className, size = "medium", variant = "outlined" }) => {
5578
- const { signIn, afterSignInUrl } = useAsgardeo_default();
5579
- const handleInitialize = async () => await signIn({ response_mode: "direct" });
5580
- const handleOnSubmit = async (payload, request) => await signIn(payload, request);
5512
+ const { signIn, afterSignInUrl, isInitialized, isLoading } = useAsgardeo_default();
5513
+ const handleInitialize = async () => {
5514
+ return await signIn({ response_mode: "direct" });
5515
+ };
5516
+ const handleOnSubmit = async (payload, request) => {
5517
+ return await signIn(payload, request);
5518
+ };
5581
5519
  const handleSuccess = (authData) => {
5582
5520
  if (authData && afterSignInUrl) {
5583
5521
  const url = new URL(afterSignInUrl, window.location.origin);
@@ -5592,6 +5530,7 @@ var SignIn = ({ className, size = "medium", variant = "outlined" }) => {
5592
5530
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
5593
5531
  BaseSignIn_default,
5594
5532
  {
5533
+ isLoading: isLoading || !isInitialized,
5595
5534
  afterSignInUrl,
5596
5535
  onInitialize: handleInitialize,
5597
5536
  onSubmit: handleOnSubmit,
@@ -6623,12 +6562,12 @@ var BaseOrganization_default = BaseOrganization;
6623
6562
 
6624
6563
  // src/components/presentation/Organization/Organization.tsx
6625
6564
  var import_jsx_runtime66 = require("react/jsx-runtime");
6626
- var Organization6 = ({ children, fallback = null }) => {
6565
+ var Organization5 = ({ children, fallback = null }) => {
6627
6566
  const { currentOrganization } = useOrganization_default();
6628
6567
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(BaseOrganization_default, { organization: currentOrganization, fallback, children });
6629
6568
  };
6630
- Organization6.displayName = "Organization";
6631
- var Organization_default = Organization6;
6569
+ Organization5.displayName = "Organization";
6570
+ var Organization_default = Organization5;
6632
6571
 
6633
6572
  // src/components/presentation/UserProfile/BaseUserProfile.tsx
6634
6573
  var import_browser51 = require("@asgardeo/browser");
@@ -7652,55 +7591,29 @@ var useStyles4 = () => {
7652
7591
  };
7653
7592
  var BaseUserProfile_default = BaseUserProfile;
7654
7593
 
7655
- // src/api/scim2/updateMeProfile.ts
7594
+ // src/api/updateMeProfile.ts
7656
7595
  var import_browser52 = require("@asgardeo/browser");
7657
7596
  var httpClient5 = import_browser52.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser52.AsgardeoSPAClient.getInstance());
7658
- var updateMeProfile = async ({
7659
- url,
7660
- payload,
7661
- ...requestConfig
7662
- }) => {
7663
- try {
7664
- new URL(url);
7665
- } catch (error) {
7666
- throw new import_browser52.AsgardeoAPIError(
7667
- "Invalid endpoint URL provided",
7668
- "updateMeProfile-ValidationError-001",
7669
- "javascript",
7670
- 400,
7671
- "Invalid Request"
7672
- );
7673
- }
7674
- const data = {
7675
- Operations: [
7676
- {
7677
- op: "replace",
7678
- value: payload
7679
- }
7680
- ],
7681
- schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
7597
+ var updateMeProfile = async ({ fetcher, ...requestConfig }) => {
7598
+ const defaultFetcher = async (url, config) => {
7599
+ const response = await httpClient5({
7600
+ url,
7601
+ method: config.method || "PATCH",
7602
+ headers: config.headers,
7603
+ data: config.body ? JSON.parse(config.body) : void 0
7604
+ });
7605
+ return {
7606
+ ok: response.status >= 200 && response.status < 300,
7607
+ status: response.status,
7608
+ statusText: response.statusText || "",
7609
+ json: () => Promise.resolve(response.data),
7610
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
7611
+ };
7682
7612
  };
7683
- const response = await httpClient5({
7684
- url,
7685
- method: "PATCH",
7686
- headers: {
7687
- "Content-Type": "application/scim+json",
7688
- Accept: "application/json"
7689
- },
7690
- data,
7691
- ...requestConfig
7613
+ return (0, import_browser52.updateMeProfile)({
7614
+ ...requestConfig,
7615
+ fetcher: fetcher || defaultFetcher
7692
7616
  });
7693
- if (!response.data) {
7694
- const errorText = await response.text();
7695
- throw new import_browser52.AsgardeoAPIError(
7696
- `Failed to update user profile: ${errorText}`,
7697
- "updateMeProfile-ResponseError-001",
7698
- "javascript",
7699
- response.status,
7700
- response.statusText
7701
- );
7702
- }
7703
- return response.data;
7704
7617
  };
7705
7618
  var updateMeProfile_default = updateMeProfile;
7706
7619
 
@@ -7710,7 +7623,7 @@ var UserProfile3 = ({ ...rest }) => {
7710
7623
  const { baseUrl } = useAsgardeo_default();
7711
7624
  const { profile, flattenedProfile, schemas, revalidateProfile } = useUser_default();
7712
7625
  const handleProfileUpdate = async (payload) => {
7713
- await updateMeProfile_default({ url: `${baseUrl}/scim2/Me`, payload });
7626
+ await updateMeProfile_default({ baseUrl, payload });
7714
7627
  await revalidateProfile();
7715
7628
  };
7716
7629
  return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
@@ -8072,7 +7985,7 @@ var UserDropdown = ({
8072
7985
  };
8073
7986
  const handleSignOut = () => {
8074
7987
  signOut();
8075
- onSignOut();
7988
+ onSignOut && onSignOut();
8076
7989
  };
8077
7990
  const closeProfile = () => {
8078
7991
  setIsProfileOpen(false);
@@ -8751,8 +8664,6 @@ var BaseCreateOrganization = ({
8751
8664
  const styles = useStyles7();
8752
8665
  const { theme } = useTheme_default();
8753
8666
  const { t } = useTranslation_default();
8754
- const [avatarUrl, setAvatarUrl] = (0, import_react49.useState)("");
8755
- const [avatarFile, setAvatarFile] = (0, import_react49.useState)(null);
8756
8667
  const [formData, setFormData] = (0, import_react49.useState)({
8757
8668
  description: "",
8758
8669
  handle: "",
@@ -8788,35 +8699,6 @@ var BaseCreateOrganization = ({
8788
8699
  }));
8789
8700
  }
8790
8701
  };
8791
- const handleAvatarUpload = (event) => {
8792
- const file = event.target.files?.[0];
8793
- if (file) {
8794
- if (!file.type.startsWith("image/")) {
8795
- setFormErrors((prev) => ({
8796
- ...prev,
8797
- avatar: "Please select a valid image file"
8798
- }));
8799
- return;
8800
- }
8801
- if (file.size > 2 * 1024 * 1024) {
8802
- setFormErrors((prev) => ({
8803
- ...prev,
8804
- avatar: "Image size must be less than 2MB"
8805
- }));
8806
- return;
8807
- }
8808
- setAvatarFile(file);
8809
- const reader = new FileReader();
8810
- reader.onload = (e) => {
8811
- setAvatarUrl(e.target?.result);
8812
- };
8813
- reader.readAsDataURL(file);
8814
- setFormErrors((prev) => ({
8815
- ...prev,
8816
- avatar: void 0
8817
- }));
8818
- }
8819
- };
8820
8702
  const handleNameChange = (value) => {
8821
8703
  handleInputChange("name", value);
8822
8704
  if (!formData.handle || formData.handle === generateHandleFromName(formData.name)) {
@@ -8848,7 +8730,6 @@ var BaseCreateOrganization = ({
8848
8730
  console.error("Form submission error:", submitError);
8849
8731
  }
8850
8732
  };
8851
- const defaultRenderHeader = () => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: (0, import_browser55.withVendorCSSClassPrefix)("create-organization__header"), style: styles.header, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Typography_default, { variant: "h6", component: "h2", children: t("organization.create.title") }) });
8852
8733
  const containerStyle = {
8853
8734
  ...styles.root,
8854
8735
  ...cardLayout ? styles.card : {}
@@ -8933,57 +8814,29 @@ var BaseCreateOrganization = ({
8933
8814
  return createOrganizationContent;
8934
8815
  };
8935
8816
 
8936
- // src/api/scim2/createOrganization.ts
8817
+ // src/api/createOrganization.ts
8937
8818
  var import_browser56 = require("@asgardeo/browser");
8938
8819
  var httpClient6 = import_browser56.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser56.AsgardeoSPAClient.getInstance());
8939
- var createOrganization = async ({
8940
- baseUrl,
8941
- payload,
8942
- ...requestConfig
8943
- }) => {
8944
- if (!baseUrl) {
8945
- throw new import_browser56.AsgardeoAPIError(
8946
- "Base URL is required",
8947
- "createOrganization-ValidationError-001",
8948
- "javascript",
8949
- 400,
8950
- "Invalid Request"
8951
- );
8952
- }
8953
- if (!payload) {
8954
- throw new import_browser56.AsgardeoAPIError(
8955
- "Organization payload is required",
8956
- "createOrganization-ValidationError-002",
8957
- "javascript",
8958
- 400,
8959
- "Invalid Request"
8960
- );
8961
- }
8962
- const organizationPayload = {
8963
- ...payload,
8964
- type: "TENANT"
8820
+ var createOrganization = async ({ fetcher, ...requestConfig }) => {
8821
+ const defaultFetcher = async (url, config) => {
8822
+ const response = await httpClient6({
8823
+ url,
8824
+ method: config.method || "POST",
8825
+ headers: config.headers,
8826
+ data: config.body ? JSON.parse(config.body) : void 0
8827
+ });
8828
+ return {
8829
+ ok: response.status >= 200 && response.status < 300,
8830
+ status: response.status,
8831
+ statusText: response.statusText || "",
8832
+ json: () => Promise.resolve(response.data),
8833
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
8834
+ };
8965
8835
  };
8966
- const response = await httpClient6({
8967
- data: JSON.stringify(organizationPayload),
8968
- headers: {
8969
- Accept: "application/json",
8970
- "Content-Type": "application/json"
8971
- },
8972
- method: "POST",
8973
- url: `${baseUrl}/api/server/v1/organizations`,
8974
- ...requestConfig
8836
+ return (0, import_browser56.createOrganization)({
8837
+ ...requestConfig,
8838
+ fetcher: fetcher || defaultFetcher
8975
8839
  });
8976
- if (!response.data) {
8977
- const errorText = await response.text();
8978
- throw new import_browser56.AsgardeoAPIError(
8979
- `Failed to create organization: ${errorText}`,
8980
- "createOrganization-ResponseError-001",
8981
- "javascript",
8982
- response.status,
8983
- response.statusText
8984
- );
8985
- }
8986
- return response.data;
8987
8840
  };
8988
8841
  var createOrganization_default = createOrganization;
8989
8842
 
@@ -9820,129 +9673,56 @@ var useStyles8 = () => {
9820
9673
  };
9821
9674
  var BaseOrganizationProfile_default = BaseOrganizationProfile;
9822
9675
 
9823
- // src/api/scim2/getOrganization.ts
9676
+ // src/api/getOrganization.ts
9824
9677
  var import_browser59 = require("@asgardeo/browser");
9825
9678
  var httpClient7 = import_browser59.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser59.AsgardeoSPAClient.getInstance());
9826
- var getOrganization = async ({
9827
- baseUrl,
9828
- organizationId,
9829
- ...requestConfig
9830
- }) => {
9831
- if (!baseUrl) {
9832
- throw new import_browser59.AsgardeoAPIError(
9833
- "Base URL is required",
9834
- "getOrganization-ValidationError-001",
9835
- "javascript",
9836
- 400,
9837
- "Invalid Request"
9838
- );
9839
- }
9840
- if (!organizationId) {
9841
- throw new import_browser59.AsgardeoAPIError(
9842
- "Organization ID is required",
9843
- "getOrganization-ValidationError-002",
9844
- "javascript",
9845
- 400,
9846
- "Invalid Request"
9847
- );
9848
- }
9849
- const response = await httpClient7({
9850
- headers: {
9851
- Accept: "application/json",
9852
- "Content-Type": "application/json"
9853
- },
9854
- method: "GET",
9855
- url: `${baseUrl}/api/server/v1/organizations/${organizationId}`,
9856
- ...requestConfig
9679
+ var getOrganization = async ({ fetcher, ...requestConfig }) => {
9680
+ const defaultFetcher = async (url, config) => {
9681
+ const response = await httpClient7({
9682
+ url,
9683
+ method: config.method || "GET",
9684
+ headers: config.headers
9685
+ });
9686
+ return {
9687
+ ok: response.status >= 200 && response.status < 300,
9688
+ status: response.status,
9689
+ statusText: response.statusText || "",
9690
+ json: () => Promise.resolve(response.data),
9691
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
9692
+ };
9693
+ };
9694
+ return (0, import_browser59.getOrganization)({
9695
+ ...requestConfig,
9696
+ fetcher: fetcher || defaultFetcher
9857
9697
  });
9858
- if (!response.data) {
9859
- const errorText = await response.text();
9860
- throw new import_browser59.AsgardeoAPIError(
9861
- `Failed to fetch organization details: ${errorText}`,
9862
- "getOrganization-ResponseError-001",
9863
- "javascript",
9864
- response.status,
9865
- response.statusText
9866
- );
9867
- }
9868
- return response.data;
9869
9698
  };
9870
9699
  var getOrganization_default = getOrganization;
9871
9700
 
9872
- // src/api/scim2/updateOrganization.ts
9701
+ // src/api/updateOrganization.ts
9873
9702
  var import_browser60 = require("@asgardeo/browser");
9874
9703
  var httpClient8 = import_browser60.AsgardeoSPAClient.getInstance().httpRequest.bind(import_browser60.AsgardeoSPAClient.getInstance());
9875
9704
  var updateOrganization = async ({
9876
- baseUrl,
9877
- organizationId,
9878
- operations,
9705
+ fetcher,
9879
9706
  ...requestConfig
9880
9707
  }) => {
9881
- try {
9882
- new URL(baseUrl);
9883
- } catch (error) {
9884
- throw new import_browser60.AsgardeoAPIError(
9885
- "Invalid base URL provided",
9886
- "updateOrganization-ValidationError-001",
9887
- "javascript",
9888
- 400,
9889
- "Invalid Request"
9890
- );
9891
- }
9892
- if (!organizationId) {
9893
- throw new import_browser60.AsgardeoAPIError(
9894
- "Organization ID is required",
9895
- "updateOrganization-ValidationError-002",
9896
- "javascript",
9897
- 400,
9898
- "Invalid Request"
9899
- );
9900
- }
9901
- if (!operations || !Array.isArray(operations) || operations.length === 0) {
9902
- throw new import_browser60.AsgardeoAPIError(
9903
- "Operations array is required and cannot be empty",
9904
- "updateOrganization-ValidationError-003",
9905
- "javascript",
9906
- 400,
9907
- "Invalid Request"
9908
- );
9909
- }
9910
- const url = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
9911
- const response = await httpClient8({
9912
- url,
9913
- method: "PATCH",
9914
- headers: {
9915
- "Content-Type": "application/json",
9916
- Accept: "application/json"
9917
- },
9918
- data: operations,
9919
- ...requestConfig
9920
- });
9921
- if (!response.data) {
9922
- const errorText = await response.text();
9923
- throw new import_browser60.AsgardeoAPIError(
9924
- `Failed to update organization: ${errorText}`,
9925
- "updateOrganization-ResponseError-001",
9926
- "javascript",
9927
- response.status,
9928
- response.statusText
9929
- );
9930
- }
9931
- return response.data;
9932
- };
9933
- var createPatchOperations = (payload) => {
9934
- return Object.entries(payload).map(([key, value]) => {
9935
- if ((0, import_browser60.isEmpty)(value)) {
9936
- return {
9937
- operation: "REMOVE",
9938
- path: `/${key}`
9939
- };
9940
- }
9708
+ const defaultFetcher = async (url, config) => {
9709
+ const response = await httpClient8({
9710
+ url,
9711
+ method: config.method || "PATCH",
9712
+ headers: config.headers,
9713
+ data: config.body ? JSON.parse(config.body) : void 0
9714
+ });
9941
9715
  return {
9942
- operation: "REPLACE",
9943
- path: `/${key}`,
9944
- value
9716
+ ok: response.status >= 200 && response.status < 300,
9717
+ status: response.status,
9718
+ statusText: response.statusText || "",
9719
+ json: () => Promise.resolve(response.data),
9720
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
9945
9721
  };
9722
+ };
9723
+ return (0, import_browser60.updateOrganization)({
9724
+ ...requestConfig,
9725
+ fetcher: fetcher || defaultFetcher
9946
9726
  });
9947
9727
  };
9948
9728
  var updateOrganization_default = updateOrganization;
@@ -9993,7 +9773,7 @@ var OrganizationProfile = ({
9993
9773
  const handleOrganizationUpdate = async (payload) => {
9994
9774
  if (!baseUrl || !organizationId) return;
9995
9775
  try {
9996
- const operations = createPatchOperations(payload);
9776
+ const operations = (0, import_browser60.createPatchOperations)(payload);
9997
9777
  await updateOrganization_default({
9998
9778
  baseUrl,
9999
9779
  organizationId,