@asgardeo/react 0.5.0 → 0.5.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.
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 +262 -482
  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 +17 -4
  23. package/dist/index.js +301 -496
  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/index.js CHANGED
@@ -11,11 +11,14 @@ import { useEffect as useEffect5, useMemo as useMemo6, useRef, useState as useSt
11
11
  // src/contexts/Asgardeo/AsgardeoContext.ts
12
12
  import { createContext } from "react";
13
13
  var AsgardeoContext = createContext({
14
- afterSignInUrl: "",
15
- baseUrl: "",
14
+ signInUrl: void 0,
15
+ signUpUrl: void 0,
16
+ afterSignInUrl: void 0,
17
+ baseUrl: void 0,
16
18
  isInitialized: false,
17
19
  isLoading: true,
18
20
  isSignedIn: false,
21
+ organization: null,
19
22
  signIn: null,
20
23
  signOut: null,
21
24
  signUp: null,
@@ -385,133 +388,87 @@ AuthAPI.DEFAULT_STATE = {
385
388
  };
386
389
  var api_default = AuthAPI;
387
390
 
388
- // src/api/scim2/getMeOrganizations.ts
389
- import { AsgardeoAPIError, AsgardeoSPAClient as AsgardeoSPAClient2 } from "@asgardeo/browser";
391
+ // src/api/getMeOrganizations.ts
392
+ import {
393
+ AsgardeoSPAClient as AsgardeoSPAClient2,
394
+ getMeOrganizations as baseGetMeOrganizations
395
+ } from "@asgardeo/browser";
390
396
  var httpClient = AsgardeoSPAClient2.getInstance().httpRequest.bind(AsgardeoSPAClient2.getInstance());
391
- var getMeOrganizations = async ({
392
- baseUrl,
393
- after = "",
394
- authorizedAppName = "",
395
- before = "",
396
- filter = "",
397
- limit = 10,
398
- recursive = false,
399
- ...requestConfig
400
- }) => {
401
- if (!baseUrl) {
402
- throw new AsgardeoAPIError(
403
- "Base URL is required",
404
- "getMeOrganizations-ValidationError-001",
405
- "javascript",
406
- 400,
407
- "Invalid Request"
408
- );
409
- }
410
- const queryParams = new URLSearchParams(
411
- Object.fromEntries(
412
- Object.entries({
413
- after,
414
- authorizedAppName,
415
- before,
416
- filter,
417
- limit: limit.toString(),
418
- recursive: recursive.toString()
419
- }).filter(([, value]) => Boolean(value))
420
- )
421
- );
422
- const response = await httpClient({
423
- headers: {
424
- Accept: "application/json",
425
- "Content-Type": "application/json"
426
- },
427
- method: "GET",
428
- url: `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`,
429
- ...requestConfig
397
+ var getMeOrganizations = async ({ fetcher, ...requestConfig }) => {
398
+ const defaultFetcher = async (url, config) => {
399
+ const response = await httpClient({
400
+ url,
401
+ method: config.method || "GET",
402
+ headers: config.headers
403
+ });
404
+ return {
405
+ ok: response.status >= 200 && response.status < 300,
406
+ status: response.status,
407
+ statusText: response.statusText || "",
408
+ json: () => Promise.resolve(response.data),
409
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
410
+ };
411
+ };
412
+ return baseGetMeOrganizations({
413
+ ...requestConfig,
414
+ fetcher: fetcher || defaultFetcher
430
415
  });
431
- if (!response.data) {
432
- const errorText = await response.text();
433
- throw new AsgardeoAPIError(
434
- `Failed to fetch associated organizations of the user: ${errorText}`,
435
- "getMeOrganizations-ResponseError-001",
436
- "javascript",
437
- response.status,
438
- response.statusText
439
- );
440
- }
441
- return response.data.organizations || [];
442
416
  };
443
417
  var getMeOrganizations_default = getMeOrganizations;
444
418
 
445
- // src/api/scim2/getMeProfile.ts
446
- import { AsgardeoAPIError as AsgardeoAPIError2, AsgardeoSPAClient as AsgardeoSPAClient3 } from "@asgardeo/browser";
419
+ // src/api/getScim2Me.ts
420
+ import {
421
+ AsgardeoSPAClient as AsgardeoSPAClient3,
422
+ getScim2Me as baseGetScim2Me
423
+ } from "@asgardeo/browser";
447
424
  var httpClient2 = AsgardeoSPAClient3.getInstance().httpRequest.bind(AsgardeoSPAClient3.getInstance());
448
- var getMeProfile = async ({ url, ...requestConfig }) => {
449
- try {
450
- new URL(url);
451
- } catch (error) {
452
- throw new AsgardeoAPIError2(
453
- "Invalid endpoint URL provided",
454
- "getMeProfile-ValidationError-001",
455
- "javascript",
456
- 400,
457
- "Invalid Request"
458
- );
459
- }
460
- const response = await httpClient2({
461
- url,
462
- method: "GET",
463
- headers: {
464
- "Content-Type": "application/scim+json",
465
- Accept: "application/json"
466
- }
425
+ var getScim2Me = async ({ fetcher, ...requestConfig }) => {
426
+ const defaultFetcher = async (url, config) => {
427
+ const response = await httpClient2({
428
+ url,
429
+ method: config.method || "GET",
430
+ headers: config.headers
431
+ });
432
+ return {
433
+ ok: response.status >= 200 && response.status < 300,
434
+ status: response.status,
435
+ statusText: response.statusText || "",
436
+ json: () => Promise.resolve(response.data),
437
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
438
+ };
439
+ };
440
+ return baseGetScim2Me({
441
+ ...requestConfig,
442
+ fetcher: fetcher || defaultFetcher
467
443
  });
468
- if (!response.data) {
469
- const errorText = await response.text();
470
- throw new AsgardeoAPIError2(
471
- `Failed to fetch user profile: ${errorText}`,
472
- "getMeProfile-ResponseError-001",
473
- "javascript",
474
- response.status,
475
- response.statusText
476
- );
477
- }
478
- return response.data;
479
444
  };
480
- var getMeProfile_default = getMeProfile;
445
+ var getScim2Me_default = getScim2Me;
481
446
 
482
- // src/api/scim2/getSchemas.ts
483
- import { AsgardeoAPIError as AsgardeoAPIError3, AsgardeoSPAClient as AsgardeoSPAClient4 } from "@asgardeo/browser";
447
+ // src/api/getSchemas.ts
448
+ import {
449
+ AsgardeoSPAClient as AsgardeoSPAClient4,
450
+ getSchemas as baseGetSchemas
451
+ } from "@asgardeo/browser";
484
452
  var httpClient3 = AsgardeoSPAClient4.getInstance().httpRequest.bind(AsgardeoSPAClient4.getInstance());
485
- var getSchemas = async ({ url }) => {
486
- try {
487
- new URL(url);
488
- } catch (error) {
489
- throw new AsgardeoAPIError3(
490
- "Invalid endpoint URL provided",
491
- "getSchemas-ValidationError-001",
492
- "javascript",
493
- 400,
494
- "Invalid Request"
495
- );
496
- }
497
- const response = await httpClient3({
498
- url,
499
- method: "GET",
500
- headers: {
501
- "Content-Type": "application/json",
502
- Accept: "application/json"
503
- }
453
+ var getSchemas = async ({ fetcher, ...requestConfig }) => {
454
+ const defaultFetcher = async (url, config) => {
455
+ const response = await httpClient3({
456
+ url,
457
+ method: config.method || "GET",
458
+ headers: config.headers
459
+ });
460
+ return {
461
+ ok: response.status >= 200 && response.status < 300,
462
+ status: response.status,
463
+ statusText: response.statusText || "",
464
+ json: () => Promise.resolve(response.data),
465
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
466
+ };
467
+ };
468
+ return baseGetSchemas({
469
+ ...requestConfig,
470
+ fetcher: fetcher || defaultFetcher
504
471
  });
505
- if (!response.data) {
506
- throw new AsgardeoAPIError3(
507
- `Failed to fetch SCIM2 schemas`,
508
- "getSchemas-ResponseError-001",
509
- "javascript",
510
- response.status,
511
- response.statusText
512
- );
513
- }
514
- return response.data;
515
472
  };
516
473
  var getSchemas_default = getSchemas;
517
474
 
@@ -529,8 +486,8 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
529
486
  try {
530
487
  const configData = await this.asgardeo.getConfigData();
531
488
  const baseUrl = configData?.baseUrl;
532
- const profile = await getMeProfile_default({ url: `${baseUrl}/scim2/Me` });
533
- const schemas = await getSchemas_default({ url: `${baseUrl}/scim2/Schemas` });
489
+ const profile = await getScim2Me_default({ baseUrl });
490
+ const schemas = await getSchemas_default({ baseUrl });
534
491
  return generateUserProfile(profile, flattenUserSchema(schemas));
535
492
  } catch (error) {
536
493
  return this.asgardeo.getDecodedIdToken();
@@ -540,8 +497,8 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
540
497
  try {
541
498
  const configData = await this.asgardeo.getConfigData();
542
499
  const baseUrl = configData?.baseUrl;
543
- const profile = await getMeProfile_default({ url: `${baseUrl}/scim2/Me` });
544
- const schemas = await getSchemas_default({ url: `${baseUrl}/scim2/Schemas` });
500
+ const profile = await getScim2Me_default({ baseUrl });
501
+ const schemas = await getSchemas_default({ baseUrl });
545
502
  const processedSchemas = flattenUserSchema(schemas);
546
503
  const output = {
547
504
  schemas: processedSchemas,
@@ -629,6 +586,9 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
629
586
  isSignedIn() {
630
587
  return this.asgardeo.isSignedIn();
631
588
  }
589
+ getConfiguration() {
590
+ return this.asgardeo.getConfigData();
591
+ }
632
592
  async signIn(...args) {
633
593
  const arg1 = args[0];
634
594
  const arg2 = args[1];
@@ -971,60 +931,34 @@ var useAsgardeo = () => {
971
931
  };
972
932
  var useAsgardeo_default = useAsgardeo;
973
933
 
974
- // src/api/scim2/getAllOrganizations.ts
975
- import { AsgardeoAPIError as AsgardeoAPIError4, AsgardeoSPAClient as AsgardeoSPAClient5 } from "@asgardeo/browser";
934
+ // src/api/getAllOrganizations.ts
935
+ import {
936
+ AsgardeoSPAClient as AsgardeoSPAClient5,
937
+ getAllOrganizations as baseGetAllOrganizations
938
+ } from "@asgardeo/browser";
976
939
  var httpClient4 = AsgardeoSPAClient5.getInstance().httpRequest.bind(AsgardeoSPAClient5.getInstance());
977
940
  var getAllOrganizations = async ({
978
- baseUrl,
979
- filter = "",
980
- limit = 10,
981
- recursive = false,
941
+ fetcher,
982
942
  ...requestConfig
983
943
  }) => {
984
- if (!baseUrl) {
985
- throw new AsgardeoAPIError4(
986
- "Base URL is required",
987
- "getAllOrganizations-ValidationError-001",
988
- "javascript",
989
- 400,
990
- "Invalid Request"
991
- );
992
- }
993
- const queryParams = new URLSearchParams(
994
- Object.fromEntries(
995
- Object.entries({
996
- filter,
997
- limit: limit.toString(),
998
- recursive: recursive.toString()
999
- }).filter(([, value]) => Boolean(value))
1000
- )
1001
- );
1002
- const response = await httpClient4({
1003
- headers: {
1004
- Accept: "application/json",
1005
- "Content-Type": "application/json"
1006
- },
1007
- method: "GET",
1008
- url: `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`,
1009
- ...requestConfig
1010
- });
1011
- if (!response.data) {
1012
- const errorText = await response.text();
1013
- throw new AsgardeoAPIError4(
1014
- errorText || "Failed to get organizations",
1015
- "getAllOrganizations-NetworkError-001",
1016
- "javascript",
1017
- response.status,
1018
- response.statusText
1019
- );
1020
- }
1021
- const { data } = response;
1022
- return {
1023
- hasMore: data.hasMore,
1024
- nextCursor: data.nextCursor,
1025
- organizations: data.organizations || [],
1026
- totalCount: data.totalCount
944
+ const defaultFetcher = async (url, config) => {
945
+ const response = await httpClient4({
946
+ url,
947
+ method: config.method || "GET",
948
+ headers: config.headers
949
+ });
950
+ return {
951
+ ok: response.status >= 200 && response.status < 300,
952
+ status: response.status,
953
+ statusText: response.statusText || "",
954
+ json: () => Promise.resolve(response.data),
955
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
956
+ };
1027
957
  };
958
+ return baseGetAllOrganizations({
959
+ ...requestConfig,
960
+ fetcher: fetcher || defaultFetcher
961
+ });
1028
962
  };
1029
963
  var getAllOrganizations_default = getAllOrganizations;
1030
964
 
@@ -1308,6 +1242,8 @@ var AsgardeoProvider = ({
1308
1242
  children,
1309
1243
  scopes,
1310
1244
  preferences,
1245
+ signInUrl,
1246
+ signUpUrl,
1311
1247
  ...rest
1312
1248
  }) => {
1313
1249
  const reRenderCheckRef = useRef(false);
@@ -1326,6 +1262,8 @@ var AsgardeoProvider = ({
1326
1262
  baseUrl,
1327
1263
  clientId,
1328
1264
  scopes,
1265
+ signUpUrl,
1266
+ signInUrl,
1329
1267
  ...rest
1330
1268
  });
1331
1269
  })();
@@ -1445,11 +1383,14 @@ var AsgardeoProvider = ({
1445
1383
  AsgardeoContext_default.Provider,
1446
1384
  {
1447
1385
  value: {
1386
+ signInUrl,
1387
+ signUpUrl,
1448
1388
  afterSignInUrl,
1449
1389
  baseUrl,
1450
1390
  isInitialized: isInitializedSync,
1451
1391
  isLoading: asgardeo.isLoading(),
1452
1392
  isSignedIn: isSignedInSync,
1393
+ organization: currentOrganization,
1453
1394
  signIn,
1454
1395
  signOut,
1455
1396
  signUp,
@@ -2122,20 +2063,25 @@ import { AsgardeoRuntimeError as AsgardeoRuntimeError4 } from "@asgardeo/browser
2122
2063
  import { forwardRef as forwardRef3, useState as useState8 } from "react";
2123
2064
  import { jsx as jsx10 } from "react/jsx-runtime";
2124
2065
  var SignInButton = forwardRef3(({ children, onClick, preferences, ...rest }, ref) => {
2125
- const { signIn } = useAsgardeo_default();
2066
+ const { signIn, signInUrl } = useAsgardeo_default();
2126
2067
  const { t } = useTranslation_default(preferences?.i18n);
2127
2068
  const [isLoading, setIsLoading] = useState8(false);
2128
2069
  const handleSignIn = async (e) => {
2129
2070
  try {
2130
2071
  setIsLoading(true);
2131
- await signIn();
2072
+ if (signInUrl) {
2073
+ window.history.pushState(null, "", signInUrl);
2074
+ window.dispatchEvent(new PopStateEvent("popstate", { state: null }));
2075
+ } else {
2076
+ await signIn();
2077
+ }
2132
2078
  if (onClick) {
2133
2079
  onClick(e);
2134
2080
  }
2135
2081
  } catch (error) {
2136
2082
  throw new AsgardeoRuntimeError4(
2137
2083
  `Sign in failed: ${error instanceof Error ? error.message : String(error)}`,
2138
- "handleSignIn-RuntimeError-001",
2084
+ "SignInButton-handleSignIn-RuntimeError-001",
2139
2085
  "react",
2140
2086
  "Something went wrong while trying to sign in. Please try again later."
2141
2087
  );
@@ -2209,7 +2155,7 @@ var SignOutButton = forwardRef5(({ children, onClick, preferences, ...rest }, re
2209
2155
  } catch (error) {
2210
2156
  throw new AsgardeoRuntimeError5(
2211
2157
  `Sign out failed: ${error instanceof Error ? error.message : String(error)}`,
2212
- "handleSignOut-RuntimeError-001",
2158
+ "SignOutButton-handleSignOut-RuntimeError-001",
2213
2159
  "react",
2214
2160
  "Something went wrong while trying to sign out. Please try again later."
2215
2161
  );
@@ -2270,20 +2216,25 @@ import { AsgardeoRuntimeError as AsgardeoRuntimeError6 } from "@asgardeo/browser
2270
2216
  import { forwardRef as forwardRef7, useState as useState10 } from "react";
2271
2217
  import { jsx as jsx14 } from "react/jsx-runtime";
2272
2218
  var SignUpButton = forwardRef7(({ children, onClick, preferences, ...rest }, ref) => {
2273
- const { signUp } = useAsgardeo_default();
2219
+ const { signUp, signUpUrl } = useAsgardeo_default();
2274
2220
  const { t } = useTranslation_default(preferences?.i18n);
2275
2221
  const [isLoading, setIsLoading] = useState10(false);
2276
2222
  const handleSignUp = async (e) => {
2277
2223
  try {
2278
2224
  setIsLoading(true);
2279
- await signUp();
2225
+ if (signUpUrl) {
2226
+ window.history.pushState(null, "", signUpUrl);
2227
+ window.dispatchEvent(new PopStateEvent("popstate", { state: null }));
2228
+ } else {
2229
+ await signUp();
2230
+ }
2280
2231
  if (onClick) {
2281
2232
  onClick(e);
2282
2233
  }
2283
2234
  } catch (error) {
2284
2235
  throw new AsgardeoRuntimeError6(
2285
2236
  `Sign up failed: ${error instanceof Error ? error.message : String(error)}`,
2286
- "handleSignUp-RuntimeError-001",
2237
+ "SignUpButton-handleSignUp-RuntimeError-001",
2287
2238
  "react",
2288
2239
  "Something went wrong while trying to sign up. Please try again later."
2289
2240
  );
@@ -2349,7 +2300,7 @@ var AsgardeoLoading = ({
2349
2300
  }
2350
2301
  return /* @__PURE__ */ jsx17(Fragment8, { children });
2351
2302
  };
2352
- AsgardeoLoading.displayName = "Loading";
2303
+ AsgardeoLoading.displayName = "AsgardeoLoading";
2353
2304
  var AsgardeoLoading_default = AsgardeoLoading;
2354
2305
 
2355
2306
  // src/components/presentation/SignIn/BaseSignIn.tsx
@@ -2358,7 +2309,7 @@ import {
2358
2309
  EmbeddedSignInFlowStatus,
2359
2310
  EmbeddedSignInFlowAuthenticatorPromptType,
2360
2311
  ApplicationNativeAuthenticationConstants as ApplicationNativeAuthenticationConstants3,
2361
- AsgardeoAPIError as AsgardeoAPIError5,
2312
+ AsgardeoAPIError as AsgardeoAPIError2,
2362
2313
  withVendorCSSClassPrefix as withVendorCSSClassPrefix14
2363
2314
  } from "@asgardeo/browser";
2364
2315
  import { clsx as clsx15 } from "clsx";
@@ -3147,13 +3098,6 @@ var Checkbox_default = Checkbox;
3147
3098
  // src/components/factories/FieldFactory.tsx
3148
3099
  import { FieldType } from "@asgardeo/browser";
3149
3100
  import { jsx as jsx29 } from "react/jsx-runtime";
3150
- var parseMultiValuedString = (value) => {
3151
- if (!value || value.trim() === "") return [];
3152
- return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
3153
- };
3154
- var formatMultiValuedString = (values) => {
3155
- return values.join(", ");
3156
- };
3157
3101
  var validateFieldValue = (value, type, required = false, touched = false) => {
3158
3102
  if (required && touched && (!value || value.trim() === "")) {
3159
3103
  return "This field is required";
@@ -4714,11 +4658,6 @@ var handleWebAuthnAuthentication = async (challengeData) => {
4714
4658
  }))
4715
4659
  }
4716
4660
  };
4717
- console.log("WebAuthn authentication with options:", {
4718
- originalRpId: challengeRpId,
4719
- adjustedRpId: rpIdToUse,
4720
- currentDomain
4721
- });
4722
4661
  const credential = await navigator.credentials.get({
4723
4662
  publicKey: adjustedOptions
4724
4663
  });
@@ -4782,6 +4721,7 @@ var BaseSignIn = (props) => /* @__PURE__ */ jsx51(FlowProvider_default, { childr
4782
4721
  var BaseSignInContent = ({
4783
4722
  afterSignInUrl,
4784
4723
  onInitialize,
4724
+ isLoading: externalIsLoading,
4785
4725
  onSubmit,
4786
4726
  onSuccess,
4787
4727
  onError,
@@ -4796,13 +4736,14 @@ var BaseSignInContent = ({
4796
4736
  }) => {
4797
4737
  const { t } = useTranslation_default();
4798
4738
  const { subtitle: flowSubtitle, title: flowTitle, messages: flowMessages } = useFlow_default();
4799
- const [isLoading, setIsLoading] = useState13(false);
4739
+ const [isSignInInitializationRequestLoading, setIsSignInInitializationRequestLoading] = useState13(false);
4800
4740
  const [isInitialized, setIsInitialized] = useState13(false);
4801
4741
  const [currentFlow, setCurrentFlow] = useState13(null);
4802
4742
  const [currentAuthenticator, setCurrentAuthenticator] = useState13(null);
4803
4743
  const [error, setError] = useState13(null);
4804
4744
  const [messages, setMessages] = useState13([]);
4805
- const initializationAttemptedRef = useRef3(false);
4745
+ const isLoading = externalIsLoading || isSignInInitializationRequestLoading;
4746
+ const reRenderCheckRef = useRef3(false);
4806
4747
  const formFields = currentAuthenticator?.metadata?.params?.map((param) => ({
4807
4748
  name: param.param,
4808
4749
  required: currentAuthenticator.requiredParams.includes(param.param),
@@ -4964,7 +4905,7 @@ var BaseSignInContent = ({
4964
4905
  if (!validation.isValid) {
4965
4906
  return;
4966
4907
  }
4967
- setIsLoading(true);
4908
+ setIsSignInInitializationRequestLoading(true);
4968
4909
  setError(null);
4969
4910
  setMessages([]);
4970
4911
  try {
@@ -5013,11 +4954,11 @@ var BaseSignInContent = ({
5013
4954
  }
5014
4955
  }
5015
4956
  } catch (err) {
5016
- const errorMessage = err instanceof AsgardeoAPIError5 ? err.message : t("errors.sign.in.flow.failure");
4957
+ const errorMessage = err instanceof AsgardeoAPIError2 ? err.message : t("errors.sign.in.flow.failure");
5017
4958
  setError(errorMessage);
5018
4959
  onError?.(err);
5019
4960
  } finally {
5020
- setIsLoading(false);
4961
+ setIsSignInInitializationRequestLoading(false);
5021
4962
  }
5022
4963
  };
5023
4964
  const handleAuthenticatorSelection = async (authenticator, formData) => {
@@ -5027,7 +4968,7 @@ var BaseSignInContent = ({
5027
4968
  if (formData) {
5028
4969
  touchAllFields();
5029
4970
  }
5030
- setIsLoading(true);
4971
+ setIsSignInInitializationRequestLoading(true);
5031
4972
  setError(null);
5032
4973
  setMessages([]);
5033
4974
  try {
@@ -5222,11 +5163,11 @@ var BaseSignInContent = ({
5222
5163
  }
5223
5164
  }
5224
5165
  } catch (err) {
5225
- const errorMessage = err instanceof AsgardeoAPIError5 ? err.message : "Authenticator selection failed";
5166
+ const errorMessage = err instanceof AsgardeoAPIError2 ? err.message : "Authenticator selection failed";
5226
5167
  setError(errorMessage);
5227
5168
  onError?.(err);
5228
5169
  } finally {
5229
- setIsLoading(false);
5170
+ setIsSignInInitializationRequestLoading(false);
5230
5171
  }
5231
5172
  };
5232
5173
  const handleInputChange = (param, value) => {
@@ -5270,52 +5211,52 @@ var BaseSignInContent = ({
5270
5211
  const errorClasses = clsx15([withVendorCSSClassPrefix14("signin__error")], errorClassName);
5271
5212
  const messageClasses = clsx15([withVendorCSSClassPrefix14("signin__messages")], messageClassName);
5272
5213
  useEffect12(() => {
5273
- if (!isInitialized && !initializationAttemptedRef.current) {
5274
- initializationAttemptedRef.current = true;
5275
- const performInitialization = async () => {
5276
- setIsLoading(true);
5277
- setError(null);
5278
- try {
5279
- const response = await onInitialize();
5280
- setCurrentFlow(response);
5281
- setIsInitialized(true);
5282
- onFlowChange?.(response);
5283
- if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) {
5284
- onSuccess?.(response.authData || {});
5285
- return;
5286
- }
5287
- if (response?.nextStep?.authenticators?.length > 0) {
5288
- if (response.nextStep.stepType === EmbeddedSignInFlowStepType.MultiOptionsPrompt && response.nextStep.authenticators.length > 1) {
5289
- setCurrentAuthenticator(null);
5290
- } else {
5291
- const authenticator = response.nextStep.authenticators[0];
5292
- setCurrentAuthenticator(authenticator);
5293
- setupFormFields(authenticator);
5294
- }
5295
- }
5296
- if (response && "nextStep" in response && response.nextStep && "messages" in response.nextStep) {
5297
- const stepMessages = response.nextStep.messages || [];
5298
- setMessages(
5299
- stepMessages.map((msg) => ({
5300
- type: msg.type || "INFO",
5301
- message: msg.message || ""
5302
- }))
5303
- );
5214
+ if (isLoading) {
5215
+ return;
5216
+ }
5217
+ if (reRenderCheckRef.current) {
5218
+ return;
5219
+ }
5220
+ reRenderCheckRef.current = true;
5221
+ (async () => {
5222
+ setIsSignInInitializationRequestLoading(true);
5223
+ setError(null);
5224
+ try {
5225
+ const response = await onInitialize();
5226
+ setCurrentFlow(response);
5227
+ setIsInitialized(true);
5228
+ onFlowChange?.(response);
5229
+ if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) {
5230
+ onSuccess?.(response.authData || {});
5231
+ return;
5232
+ }
5233
+ if (response?.nextStep?.authenticators?.length > 0) {
5234
+ if (response.nextStep.stepType === EmbeddedSignInFlowStepType.MultiOptionsPrompt && response.nextStep.authenticators.length > 1) {
5235
+ setCurrentAuthenticator(null);
5236
+ } else {
5237
+ const authenticator = response.nextStep.authenticators[0];
5238
+ setCurrentAuthenticator(authenticator);
5239
+ setupFormFields(authenticator);
5304
5240
  }
5305
- } catch (err) {
5306
- const errorMessage = err instanceof AsgardeoAPIError5 ? err.message : t("errors.sign.in.initialization");
5307
- setError(errorMessage);
5308
- onError?.(err);
5309
- } finally {
5310
- setIsLoading(false);
5311
5241
  }
5312
- };
5313
- performInitialization();
5314
- }
5315
- return () => {
5316
- initializationAttemptedRef.current = false;
5317
- };
5318
- }, [isInitialized]);
5242
+ if (response && "nextStep" in response && response.nextStep && "messages" in response.nextStep) {
5243
+ const stepMessages = response.nextStep.messages || [];
5244
+ setMessages(
5245
+ stepMessages.map((msg) => ({
5246
+ type: msg.type || "INFO",
5247
+ message: msg.message || ""
5248
+ }))
5249
+ );
5250
+ }
5251
+ } catch (err) {
5252
+ const errorMessage = err instanceof AsgardeoAPIError2 ? err.message : t("errors.sign.in.initialization");
5253
+ setError(errorMessage);
5254
+ onError?.(err);
5255
+ } finally {
5256
+ setIsSignInInitializationRequestLoading(false);
5257
+ }
5258
+ })();
5259
+ }, [isLoading]);
5319
5260
  if (!isInitialized && isLoading) {
5320
5261
  return /* @__PURE__ */ jsx51(Card_default, { className: containerClasses, variant, children: /* @__PURE__ */ jsx51(Card_default.Content, { children: /* @__PURE__ */ jsxs27("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", padding: "2rem" }, children: [
5321
5262
  /* @__PURE__ */ jsx51(Spinner_default, { size: "medium" }),
@@ -5475,9 +5416,13 @@ var BaseSignIn_default = BaseSignIn;
5475
5416
  // src/components/presentation/SignIn/SignIn.tsx
5476
5417
  import { jsx as jsx52 } from "react/jsx-runtime";
5477
5418
  var SignIn = ({ className, size = "medium", variant = "outlined" }) => {
5478
- const { signIn, afterSignInUrl } = useAsgardeo_default();
5479
- const handleInitialize = async () => await signIn({ response_mode: "direct" });
5480
- const handleOnSubmit = async (payload, request) => await signIn(payload, request);
5419
+ const { signIn, afterSignInUrl, isInitialized, isLoading } = useAsgardeo_default();
5420
+ const handleInitialize = async () => {
5421
+ return await signIn({ response_mode: "direct" });
5422
+ };
5423
+ const handleOnSubmit = async (payload, request) => {
5424
+ return await signIn(payload, request);
5425
+ };
5481
5426
  const handleSuccess = (authData) => {
5482
5427
  if (authData && afterSignInUrl) {
5483
5428
  const url = new URL(afterSignInUrl, window.location.origin);
@@ -5492,6 +5437,7 @@ var SignIn = ({ className, size = "medium", variant = "outlined" }) => {
5492
5437
  return /* @__PURE__ */ jsx52(
5493
5438
  BaseSignIn_default,
5494
5439
  {
5440
+ isLoading: isLoading || !isInitialized,
5495
5441
  afterSignInUrl,
5496
5442
  onInitialize: handleInitialize,
5497
5443
  onSubmit: handleOnSubmit,
@@ -5510,7 +5456,7 @@ import {
5510
5456
  EmbeddedFlowComponentType as EmbeddedFlowComponentType2,
5511
5457
  EmbeddedFlowResponseType,
5512
5458
  withVendorCSSClassPrefix as withVendorCSSClassPrefix15,
5513
- AsgardeoAPIError as AsgardeoAPIError6
5459
+ AsgardeoAPIError as AsgardeoAPIError3
5514
5460
  } from "@asgardeo/browser";
5515
5461
  import { clsx as clsx16 } from "clsx";
5516
5462
  import { useEffect as useEffect13, useState as useState14, useCallback as useCallback7, useRef as useRef4 } from "react";
@@ -6199,7 +6145,7 @@ var BaseSignUpContent = ({
6199
6145
  setupFormFields(response);
6200
6146
  }
6201
6147
  } catch (err) {
6202
- const errorMessage = err instanceof AsgardeoAPIError6 ? err.message : t("errors.sign.up.flow.failure");
6148
+ const errorMessage = err instanceof AsgardeoAPIError3 ? err.message : t("errors.sign.up.flow.failure");
6203
6149
  setError(errorMessage);
6204
6150
  onError?.(err);
6205
6151
  } finally {
@@ -6245,7 +6191,7 @@ var BaseSignUpContent = ({
6245
6191
  popup.close();
6246
6192
  cleanup();
6247
6193
  } catch (err) {
6248
- const errorMessage = err instanceof AsgardeoAPIError6 ? err.message : t("errors.sign.up.flow.failure");
6194
+ const errorMessage = err instanceof AsgardeoAPIError3 ? err.message : t("errors.sign.up.flow.failure");
6249
6195
  setError(errorMessage);
6250
6196
  onError?.(err);
6251
6197
  popup.close();
@@ -6305,7 +6251,7 @@ var BaseSignUpContent = ({
6305
6251
  }
6306
6252
  popup.close();
6307
6253
  } catch (err) {
6308
- const errorMessage = err instanceof AsgardeoAPIError6 ? err.message : t("errors.sign.up.flow.failure");
6254
+ const errorMessage = err instanceof AsgardeoAPIError3 ? err.message : t("errors.sign.up.flow.failure");
6309
6255
  setError(errorMessage);
6310
6256
  onError?.(err);
6311
6257
  popup.close();
@@ -6532,12 +6478,12 @@ var BaseOrganization_default = BaseOrganization;
6532
6478
 
6533
6479
  // src/components/presentation/Organization/Organization.tsx
6534
6480
  import { jsx as jsx66 } from "react/jsx-runtime";
6535
- var Organization6 = ({ children, fallback = null }) => {
6481
+ var Organization5 = ({ children, fallback = null }) => {
6536
6482
  const { currentOrganization } = useOrganization_default();
6537
6483
  return /* @__PURE__ */ jsx66(BaseOrganization_default, { organization: currentOrganization, fallback, children });
6538
6484
  };
6539
- Organization6.displayName = "Organization";
6540
- var Organization_default = Organization6;
6485
+ Organization5.displayName = "Organization";
6486
+ var Organization_default = Organization5;
6541
6487
 
6542
6488
  // src/components/presentation/UserProfile/BaseUserProfile.tsx
6543
6489
  import { withVendorCSSClassPrefix as withVendorCSSClassPrefix18, WellKnownSchemaIds } from "@asgardeo/browser";
@@ -7576,55 +7522,32 @@ var useStyles4 = () => {
7576
7522
  };
7577
7523
  var BaseUserProfile_default = BaseUserProfile;
7578
7524
 
7579
- // src/api/scim2/updateMeProfile.ts
7580
- import { AsgardeoAPIError as AsgardeoAPIError7, AsgardeoSPAClient as AsgardeoSPAClient6 } from "@asgardeo/browser";
7525
+ // src/api/updateMeProfile.ts
7526
+ import {
7527
+ AsgardeoSPAClient as AsgardeoSPAClient6,
7528
+ updateMeProfile as baseUpdateMeProfile
7529
+ } from "@asgardeo/browser";
7581
7530
  var httpClient5 = AsgardeoSPAClient6.getInstance().httpRequest.bind(AsgardeoSPAClient6.getInstance());
7582
- var updateMeProfile = async ({
7583
- url,
7584
- payload,
7585
- ...requestConfig
7586
- }) => {
7587
- try {
7588
- new URL(url);
7589
- } catch (error) {
7590
- throw new AsgardeoAPIError7(
7591
- "Invalid endpoint URL provided",
7592
- "updateMeProfile-ValidationError-001",
7593
- "javascript",
7594
- 400,
7595
- "Invalid Request"
7596
- );
7597
- }
7598
- const data = {
7599
- Operations: [
7600
- {
7601
- op: "replace",
7602
- value: payload
7603
- }
7604
- ],
7605
- schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
7531
+ var updateMeProfile = async ({ fetcher, ...requestConfig }) => {
7532
+ const defaultFetcher = async (url, config) => {
7533
+ const response = await httpClient5({
7534
+ url,
7535
+ method: config.method || "PATCH",
7536
+ headers: config.headers,
7537
+ data: config.body ? JSON.parse(config.body) : void 0
7538
+ });
7539
+ return {
7540
+ ok: response.status >= 200 && response.status < 300,
7541
+ status: response.status,
7542
+ statusText: response.statusText || "",
7543
+ json: () => Promise.resolve(response.data),
7544
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
7545
+ };
7606
7546
  };
7607
- const response = await httpClient5({
7608
- url,
7609
- method: "PATCH",
7610
- headers: {
7611
- "Content-Type": "application/scim+json",
7612
- Accept: "application/json"
7613
- },
7614
- data,
7615
- ...requestConfig
7547
+ return baseUpdateMeProfile({
7548
+ ...requestConfig,
7549
+ fetcher: fetcher || defaultFetcher
7616
7550
  });
7617
- if (!response.data) {
7618
- const errorText = await response.text();
7619
- throw new AsgardeoAPIError7(
7620
- `Failed to update user profile: ${errorText}`,
7621
- "updateMeProfile-ResponseError-001",
7622
- "javascript",
7623
- response.status,
7624
- response.statusText
7625
- );
7626
- }
7627
- return response.data;
7628
7551
  };
7629
7552
  var updateMeProfile_default = updateMeProfile;
7630
7553
 
@@ -7634,7 +7557,7 @@ var UserProfile3 = ({ ...rest }) => {
7634
7557
  const { baseUrl } = useAsgardeo_default();
7635
7558
  const { profile, flattenedProfile, schemas, revalidateProfile } = useUser_default();
7636
7559
  const handleProfileUpdate = async (payload) => {
7637
- await updateMeProfile_default({ url: `${baseUrl}/scim2/Me`, payload });
7560
+ await updateMeProfile_default({ baseUrl, payload });
7638
7561
  await revalidateProfile();
7639
7562
  };
7640
7563
  return /* @__PURE__ */ jsx74(
@@ -8008,7 +7931,7 @@ var UserDropdown = ({
8008
7931
  };
8009
7932
  const handleSignOut = () => {
8010
7933
  signOut();
8011
- onSignOut();
7934
+ onSignOut && onSignOut();
8012
7935
  };
8013
7936
  const closeProfile = () => {
8014
7937
  setIsProfileOpen(false);
@@ -8699,8 +8622,6 @@ var BaseCreateOrganization = ({
8699
8622
  const styles = useStyles7();
8700
8623
  const { theme } = useTheme_default();
8701
8624
  const { t } = useTranslation_default();
8702
- const [avatarUrl, setAvatarUrl] = useState19("");
8703
- const [avatarFile, setAvatarFile] = useState19(null);
8704
8625
  const [formData, setFormData] = useState19({
8705
8626
  description: "",
8706
8627
  handle: "",
@@ -8736,35 +8657,6 @@ var BaseCreateOrganization = ({
8736
8657
  }));
8737
8658
  }
8738
8659
  };
8739
- const handleAvatarUpload = (event) => {
8740
- const file = event.target.files?.[0];
8741
- if (file) {
8742
- if (!file.type.startsWith("image/")) {
8743
- setFormErrors((prev) => ({
8744
- ...prev,
8745
- avatar: "Please select a valid image file"
8746
- }));
8747
- return;
8748
- }
8749
- if (file.size > 2 * 1024 * 1024) {
8750
- setFormErrors((prev) => ({
8751
- ...prev,
8752
- avatar: "Image size must be less than 2MB"
8753
- }));
8754
- return;
8755
- }
8756
- setAvatarFile(file);
8757
- const reader = new FileReader();
8758
- reader.onload = (e) => {
8759
- setAvatarUrl(e.target?.result);
8760
- };
8761
- reader.readAsDataURL(file);
8762
- setFormErrors((prev) => ({
8763
- ...prev,
8764
- avatar: void 0
8765
- }));
8766
- }
8767
- };
8768
8660
  const handleNameChange = (value) => {
8769
8661
  handleInputChange("name", value);
8770
8662
  if (!formData.handle || formData.handle === generateHandleFromName(formData.name)) {
@@ -8796,7 +8688,6 @@ var BaseCreateOrganization = ({
8796
8688
  console.error("Form submission error:", submitError);
8797
8689
  }
8798
8690
  };
8799
- const defaultRenderHeader = () => /* @__PURE__ */ jsx81("div", { className: withVendorCSSClassPrefix21("create-organization__header"), style: styles.header, children: /* @__PURE__ */ jsx81(Typography_default, { variant: "h6", component: "h2", children: t("organization.create.title") }) });
8800
8691
  const containerStyle = {
8801
8692
  ...styles.root,
8802
8693
  ...cardLayout ? styles.card : {}
@@ -8881,57 +8772,32 @@ var BaseCreateOrganization = ({
8881
8772
  return createOrganizationContent;
8882
8773
  };
8883
8774
 
8884
- // src/api/scim2/createOrganization.ts
8885
- import { AsgardeoAPIError as AsgardeoAPIError8, AsgardeoSPAClient as AsgardeoSPAClient7 } from "@asgardeo/browser";
8775
+ // src/api/createOrganization.ts
8776
+ import {
8777
+ AsgardeoSPAClient as AsgardeoSPAClient7,
8778
+ createOrganization as baseCreateOrganization
8779
+ } from "@asgardeo/browser";
8886
8780
  var httpClient6 = AsgardeoSPAClient7.getInstance().httpRequest.bind(AsgardeoSPAClient7.getInstance());
8887
- var createOrganization = async ({
8888
- baseUrl,
8889
- payload,
8890
- ...requestConfig
8891
- }) => {
8892
- if (!baseUrl) {
8893
- throw new AsgardeoAPIError8(
8894
- "Base URL is required",
8895
- "createOrganization-ValidationError-001",
8896
- "javascript",
8897
- 400,
8898
- "Invalid Request"
8899
- );
8900
- }
8901
- if (!payload) {
8902
- throw new AsgardeoAPIError8(
8903
- "Organization payload is required",
8904
- "createOrganization-ValidationError-002",
8905
- "javascript",
8906
- 400,
8907
- "Invalid Request"
8908
- );
8909
- }
8910
- const organizationPayload = {
8911
- ...payload,
8912
- type: "TENANT"
8781
+ var createOrganization = async ({ fetcher, ...requestConfig }) => {
8782
+ const defaultFetcher = async (url, config) => {
8783
+ const response = await httpClient6({
8784
+ url,
8785
+ method: config.method || "POST",
8786
+ headers: config.headers,
8787
+ data: config.body ? JSON.parse(config.body) : void 0
8788
+ });
8789
+ return {
8790
+ ok: response.status >= 200 && response.status < 300,
8791
+ status: response.status,
8792
+ statusText: response.statusText || "",
8793
+ json: () => Promise.resolve(response.data),
8794
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
8795
+ };
8913
8796
  };
8914
- const response = await httpClient6({
8915
- data: JSON.stringify(organizationPayload),
8916
- headers: {
8917
- Accept: "application/json",
8918
- "Content-Type": "application/json"
8919
- },
8920
- method: "POST",
8921
- url: `${baseUrl}/api/server/v1/organizations`,
8922
- ...requestConfig
8797
+ return baseCreateOrganization({
8798
+ ...requestConfig,
8799
+ fetcher: fetcher || defaultFetcher
8923
8800
  });
8924
- if (!response.data) {
8925
- const errorText = await response.text();
8926
- throw new AsgardeoAPIError8(
8927
- `Failed to create organization: ${errorText}`,
8928
- "createOrganization-ResponseError-001",
8929
- "javascript",
8930
- response.status,
8931
- response.statusText
8932
- );
8933
- }
8934
- return response.data;
8935
8801
  };
8936
8802
  var createOrganization_default = createOrganization;
8937
8803
 
@@ -9768,129 +9634,63 @@ var useStyles8 = () => {
9768
9634
  };
9769
9635
  var BaseOrganizationProfile_default = BaseOrganizationProfile;
9770
9636
 
9771
- // src/api/scim2/getOrganization.ts
9772
- import { AsgardeoAPIError as AsgardeoAPIError9, AsgardeoSPAClient as AsgardeoSPAClient8 } from "@asgardeo/browser";
9637
+ // src/api/getOrganization.ts
9638
+ import {
9639
+ AsgardeoSPAClient as AsgardeoSPAClient8,
9640
+ getOrganization as baseGetOrganization
9641
+ } from "@asgardeo/browser";
9773
9642
  var httpClient7 = AsgardeoSPAClient8.getInstance().httpRequest.bind(AsgardeoSPAClient8.getInstance());
9774
- var getOrganization = async ({
9775
- baseUrl,
9776
- organizationId,
9777
- ...requestConfig
9778
- }) => {
9779
- if (!baseUrl) {
9780
- throw new AsgardeoAPIError9(
9781
- "Base URL is required",
9782
- "getOrganization-ValidationError-001",
9783
- "javascript",
9784
- 400,
9785
- "Invalid Request"
9786
- );
9787
- }
9788
- if (!organizationId) {
9789
- throw new AsgardeoAPIError9(
9790
- "Organization ID is required",
9791
- "getOrganization-ValidationError-002",
9792
- "javascript",
9793
- 400,
9794
- "Invalid Request"
9795
- );
9796
- }
9797
- const response = await httpClient7({
9798
- headers: {
9799
- Accept: "application/json",
9800
- "Content-Type": "application/json"
9801
- },
9802
- method: "GET",
9803
- url: `${baseUrl}/api/server/v1/organizations/${organizationId}`,
9804
- ...requestConfig
9643
+ var getOrganization = async ({ fetcher, ...requestConfig }) => {
9644
+ const defaultFetcher = async (url, config) => {
9645
+ const response = await httpClient7({
9646
+ url,
9647
+ method: config.method || "GET",
9648
+ headers: config.headers
9649
+ });
9650
+ return {
9651
+ ok: response.status >= 200 && response.status < 300,
9652
+ status: response.status,
9653
+ statusText: response.statusText || "",
9654
+ json: () => Promise.resolve(response.data),
9655
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
9656
+ };
9657
+ };
9658
+ return baseGetOrganization({
9659
+ ...requestConfig,
9660
+ fetcher: fetcher || defaultFetcher
9805
9661
  });
9806
- if (!response.data) {
9807
- const errorText = await response.text();
9808
- throw new AsgardeoAPIError9(
9809
- `Failed to fetch organization details: ${errorText}`,
9810
- "getOrganization-ResponseError-001",
9811
- "javascript",
9812
- response.status,
9813
- response.statusText
9814
- );
9815
- }
9816
- return response.data;
9817
9662
  };
9818
9663
  var getOrganization_default = getOrganization;
9819
9664
 
9820
- // src/api/scim2/updateOrganization.ts
9821
- import { AsgardeoAPIError as AsgardeoAPIError10, AsgardeoSPAClient as AsgardeoSPAClient9, isEmpty } from "@asgardeo/browser";
9665
+ // src/api/updateOrganization.ts
9666
+ import {
9667
+ AsgardeoSPAClient as AsgardeoSPAClient9,
9668
+ updateOrganization as baseUpdateOrganization,
9669
+ createPatchOperations
9670
+ } from "@asgardeo/browser";
9822
9671
  var httpClient8 = AsgardeoSPAClient9.getInstance().httpRequest.bind(AsgardeoSPAClient9.getInstance());
9823
9672
  var updateOrganization = async ({
9824
- baseUrl,
9825
- organizationId,
9826
- operations,
9673
+ fetcher,
9827
9674
  ...requestConfig
9828
9675
  }) => {
9829
- try {
9830
- new URL(baseUrl);
9831
- } catch (error) {
9832
- throw new AsgardeoAPIError10(
9833
- "Invalid base URL provided",
9834
- "updateOrganization-ValidationError-001",
9835
- "javascript",
9836
- 400,
9837
- "Invalid Request"
9838
- );
9839
- }
9840
- if (!organizationId) {
9841
- throw new AsgardeoAPIError10(
9842
- "Organization ID is required",
9843
- "updateOrganization-ValidationError-002",
9844
- "javascript",
9845
- 400,
9846
- "Invalid Request"
9847
- );
9848
- }
9849
- if (!operations || !Array.isArray(operations) || operations.length === 0) {
9850
- throw new AsgardeoAPIError10(
9851
- "Operations array is required and cannot be empty",
9852
- "updateOrganization-ValidationError-003",
9853
- "javascript",
9854
- 400,
9855
- "Invalid Request"
9856
- );
9857
- }
9858
- const url = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
9859
- const response = await httpClient8({
9860
- url,
9861
- method: "PATCH",
9862
- headers: {
9863
- "Content-Type": "application/json",
9864
- Accept: "application/json"
9865
- },
9866
- data: operations,
9867
- ...requestConfig
9868
- });
9869
- if (!response.data) {
9870
- const errorText = await response.text();
9871
- throw new AsgardeoAPIError10(
9872
- `Failed to update organization: ${errorText}`,
9873
- "updateOrganization-ResponseError-001",
9874
- "javascript",
9875
- response.status,
9876
- response.statusText
9877
- );
9878
- }
9879
- return response.data;
9880
- };
9881
- var createPatchOperations = (payload) => {
9882
- return Object.entries(payload).map(([key, value]) => {
9883
- if (isEmpty(value)) {
9884
- return {
9885
- operation: "REMOVE",
9886
- path: `/${key}`
9887
- };
9888
- }
9676
+ const defaultFetcher = async (url, config) => {
9677
+ const response = await httpClient8({
9678
+ url,
9679
+ method: config.method || "PATCH",
9680
+ headers: config.headers,
9681
+ data: config.body ? JSON.parse(config.body) : void 0
9682
+ });
9889
9683
  return {
9890
- operation: "REPLACE",
9891
- path: `/${key}`,
9892
- value
9684
+ ok: response.status >= 200 && response.status < 300,
9685
+ status: response.status,
9686
+ statusText: response.statusText || "",
9687
+ json: () => Promise.resolve(response.data),
9688
+ text: () => Promise.resolve(typeof response.data === "string" ? response.data : JSON.stringify(response.data))
9893
9689
  };
9690
+ };
9691
+ return baseUpdateOrganization({
9692
+ ...requestConfig,
9693
+ fetcher: fetcher || defaultFetcher
9894
9694
  });
9895
9695
  };
9896
9696
  var updateOrganization_default = updateOrganization;
@@ -10662,11 +10462,16 @@ export {
10662
10462
  UsernamePassword_default as UsernamePassword,
10663
10463
  createField,
10664
10464
  createOrganization_default as createOrganization,
10465
+ createPatchOperations,
10665
10466
  createSignInOption,
10666
10467
  createSignInOptionFromAuthenticator,
10667
- formatMultiValuedString,
10468
+ getAllOrganizations_default as getAllOrganizations,
10668
10469
  getMeOrganizations_default as getMeOrganizations,
10669
- parseMultiValuedString,
10470
+ getScim2Me_default as getMeProfile,
10471
+ getOrganization_default as getOrganization,
10472
+ getSchemas_default as getSchemas,
10473
+ updateMeProfile_default as updateMeProfile,
10474
+ updateOrganization_default as updateOrganization,
10670
10475
  useAsgardeo_default as useAsgardeo,
10671
10476
  useBrowserUrl_default as useBrowserUrl,
10672
10477
  useFlow_default as useFlow,