@asgardeo/javascript 0.1.0 → 0.1.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 (44) hide show
  1. package/dist/AsgardeoJavaScriptClient.d.ts +16 -50
  2. package/dist/IsomorphicCrypto.d.ts +2 -2
  3. package/dist/StorageManager.d.ts +1 -1
  4. package/dist/__legacy__/client.d.ts +2 -2
  5. package/dist/__legacy__/helpers/authentication-helper.d.ts +3 -3
  6. package/dist/api/createOrganization.d.ts +129 -0
  7. package/dist/api/executeEmbeddedSignInFlow.d.ts +21 -0
  8. package/dist/api/executeEmbeddedSignUpFlow.d.ts +44 -0
  9. package/dist/api/getAllOrganizations.d.ts +112 -0
  10. package/dist/api/getMeOrganizations.d.ts +119 -0
  11. package/dist/api/getOrganization.d.ts +109 -0
  12. package/dist/api/getSchemas.d.ts +89 -0
  13. package/dist/api/getScim2Me.d.ts +89 -0
  14. package/dist/api/initializeEmbeddedSignInFlow.d.ts +51 -0
  15. package/dist/api/updateMeProfile.d.ts +82 -0
  16. package/dist/api/updateOrganization.d.ts +118 -0
  17. package/dist/cjs/index.js +966 -146
  18. package/dist/cjs/index.js.map +4 -4
  19. package/dist/constants/OIDCRequestConstants.d.ts +1 -1
  20. package/dist/constants/ScopeConstants.d.ts +3 -6
  21. package/dist/constants/TokenExchangeConstants.d.ts +2 -2
  22. package/dist/constants/VendorConstants.d.ts +31 -0
  23. package/dist/index.d.ts +20 -5
  24. package/dist/index.js +939 -137
  25. package/dist/index.js.map +4 -4
  26. package/dist/models/client.d.ts +52 -3
  27. package/dist/models/config.d.ts +36 -12
  28. package/dist/models/embedded-flow.d.ts +66 -0
  29. package/dist/models/embedded-signin-flow.d.ts +99 -0
  30. package/dist/models/flow.d.ts +30 -0
  31. package/dist/models/i18n.d.ts +24 -0
  32. package/dist/models/organization.d.ts +24 -0
  33. package/dist/models/token.d.ts +42 -30
  34. package/dist/theme/createTheme.d.ts +1 -1
  35. package/dist/theme/types.d.ts +29 -16
  36. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +2 -2
  37. package/dist/utils/extractUserClaimsFromIdToken.d.ts +2 -2
  38. package/dist/utils/generateFlattenedUserProfile.d.ts +9 -2
  39. package/dist/utils/isEmpty.d.ts +48 -0
  40. package/dist/utils/withVendorCSSClassPrefix.d.ts +32 -0
  41. package/package.json +1 -1
  42. package/dist/api/handleApplicationNativeAuthentication.d.ts +0 -33
  43. package/dist/api/initializeApplicationNativeAuthentication.d.ts +0 -117
  44. package/dist/models/application-native-authentication.d.ts +0 -82
package/dist/index.js CHANGED
@@ -65,8 +65,8 @@ var StorageManager = class {
65
65
  async setCustomData(key, customData, userId) {
66
66
  this.setDataInBulk(this._resolveKey(key, userId), customData);
67
67
  }
68
- async getConfigData() {
69
- return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */)) ?? null);
68
+ async getConfigData(userId) {
69
+ return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */, userId)) ?? null);
70
70
  }
71
71
  async loadOpenIDProviderConfiguration() {
72
72
  return JSON.parse(await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
@@ -265,12 +265,24 @@ var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
265
265
 
266
266
  // src/constants/ScopeConstants.ts
267
267
  var ScopeConstants = {
268
+ /**
269
+ * The scope for accessing the user's profile information from SCIM.
270
+ * This scope allows the client to retrieve basic user information such as
271
+ * name, email, profile picture, etc.
272
+ */
273
+ INTERNAL_LOGIN: "internal_login",
268
274
  /**
269
275
  * The base OpenID Connect scope.
270
276
  * Required for all OpenID Connect flows. Indicates that the client
271
277
  * is initiating an OpenID Connect authentication request.
272
278
  */
273
- OPENID: "openid"
279
+ OPENID: "openid",
280
+ /**
281
+ * The OpenID Connect profile scope.
282
+ * This scope allows the client to access the user's profile information.
283
+ * It includes details such as the user's name, email, and other profile attributes.
284
+ */
285
+ PROFILE: "profile"
274
286
  };
275
287
  var ScopeConstants_default = ScopeConstants;
276
288
 
@@ -308,7 +320,7 @@ var OIDCRequestConstants = {
308
320
  /**
309
321
  * The default scopes used in OIDC sign-in requests.
310
322
  */
311
- DEFAULT_SCOPES: [ScopeConstants_default.OPENID]
323
+ DEFAULT_SCOPES: [ScopeConstants_default.OPENID, ScopeConstants_default.PROFILE, ScopeConstants_default.INTERNAL_LOGIN]
312
324
  }
313
325
  },
314
326
  /**
@@ -529,39 +541,6 @@ var extractPkceStorageKeyFromState = (state) => {
529
541
  };
530
542
  var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
531
543
 
532
- // src/utils/extractUserClaimsFromIdToken.ts
533
- var extractUserClaimsFromIdToken = (payload) => {
534
- const filteredPayload = { ...payload };
535
- const protocolClaims = [
536
- "iss",
537
- "aud",
538
- "exp",
539
- "iat",
540
- "acr",
541
- "amr",
542
- "azp",
543
- "auth_time",
544
- "nonce",
545
- "c_hash",
546
- "at_hash",
547
- "nbf",
548
- "isk",
549
- "sid",
550
- "jti",
551
- "sub"
552
- ];
553
- protocolClaims.forEach((claim) => {
554
- delete filteredPayload[claim];
555
- });
556
- const userClaims = {};
557
- Object.entries(filteredPayload).forEach(([key, value]) => {
558
- const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
559
- userClaims[camelCasedKey] = value;
560
- });
561
- return userClaims;
562
- };
563
- var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
564
-
565
544
  // src/constants/TokenExchangeConstants.ts
566
545
  var TokenExchangeConstants = {
567
546
  /**
@@ -574,7 +553,7 @@ var TokenExchangeConstants = {
574
553
  * Placeholder for the token value in exchange requests.
575
554
  * Usually replaced with an access token or refresh token.
576
555
  */
577
- TOKEN: "{{token}}",
556
+ ACCESS_TOKEN: "{{accessToken}}",
578
557
  /**
579
558
  * Placeholder for the username in token exchange operations.
580
559
  * Used when user identity needs to be included in the exchange.
@@ -584,7 +563,7 @@ var TokenExchangeConstants = {
584
563
  * Placeholder for OAuth scopes in token exchange requests.
585
564
  * Replaced with space-separated scope strings.
586
565
  */
587
- SCOPE: "{{scope}}",
566
+ SCOPES: "{{scopes}}",
588
567
  /**
589
568
  * Placeholder for client ID in token exchange operations.
590
569
  * Required for client authentication.
@@ -599,6 +578,39 @@ var TokenExchangeConstants = {
599
578
  };
600
579
  var TokenExchangeConstants_default = TokenExchangeConstants;
601
580
 
581
+ // src/utils/extractUserClaimsFromIdToken.ts
582
+ var extractUserClaimsFromIdToken = (payload) => {
583
+ const filteredPayload = { ...payload };
584
+ const protocolClaims = [
585
+ "iss",
586
+ "aud",
587
+ "exp",
588
+ "iat",
589
+ "acr",
590
+ "amr",
591
+ "azp",
592
+ "auth_time",
593
+ "nonce",
594
+ "c_hash",
595
+ "at_hash",
596
+ "nbf",
597
+ "isk",
598
+ "sid",
599
+ "jti",
600
+ "sub"
601
+ ];
602
+ protocolClaims.forEach((claim) => {
603
+ delete filteredPayload[claim];
604
+ });
605
+ const userClaims = {};
606
+ Object.entries(filteredPayload).forEach(([key, value]) => {
607
+ const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
608
+ userClaims[camelCasedKey] = value;
609
+ });
610
+ return userClaims;
611
+ };
612
+ var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
613
+
602
614
  // src/errors/AsgardeoError.ts
603
615
  var AsgardeoError = class _AsgardeoError extends Error {
604
616
  constructor(message, code, origin) {
@@ -667,17 +679,19 @@ Message: ${this.message}`;
667
679
  // src/utils/processOpenIDScopes.ts
668
680
  var processOpenIDScopes = (scopes) => {
669
681
  let processedScopes = [];
670
- if (Array.isArray(scopes)) {
671
- processedScopes = scopes;
672
- } else if (typeof scopes === "string") {
673
- processedScopes = scopes.split(" ");
674
- } else {
675
- throw new AsgardeoRuntimeError(
676
- "Scopes must be a string or an array of strings.",
677
- "processOpenIDScopes-Invalid-001",
678
- "javascript",
679
- "The provided scopes are not in the expected format. Please provide a string or an array of strings."
680
- );
682
+ if (scopes) {
683
+ if (Array.isArray(scopes)) {
684
+ processedScopes = scopes;
685
+ } else if (typeof scopes === "string") {
686
+ processedScopes = scopes.split(" ");
687
+ } else {
688
+ throw new AsgardeoRuntimeError(
689
+ "Scopes must be a string or an array of strings.",
690
+ "processOpenIDScopes-Invalid-001",
691
+ "javascript",
692
+ "The provided scopes are not in the expected format. Please provide a string or an array of strings."
693
+ );
694
+ }
681
695
  }
682
696
  OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
683
697
  if (!processedScopes.includes(defaultScope)) {
@@ -696,8 +710,8 @@ var AuthenticationHelper = class {
696
710
  __publicField(this, "_oidcProviderMetaData");
697
711
  __publicField(this, "_cryptoHelper");
698
712
  this._storageManager = storageManager;
699
- this._config = async () => await this._storageManager.getConfigData();
700
- this._oidcProviderMetaData = async () => await this._storageManager.loadOpenIDProviderConfiguration();
713
+ this._config = async () => this._storageManager.getConfigData();
714
+ this._oidcProviderMetaData = async () => this._storageManager.loadOpenIDProviderConfiguration();
701
715
  this._cryptoHelper = cryptoHelper;
702
716
  }
703
717
  async resolveEndpoints(response) {
@@ -722,15 +736,15 @@ var AuthenticationHelper = class {
722
736
  OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
723
737
  OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
724
738
  ];
725
- const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every((reqEndpointName) => {
726
- return configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
739
+ const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every(
740
+ (reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
727
741
  const snakeCasedName = endpointName.replace(
728
742
  /[A-Z]/g,
729
743
  (letter) => `_${letter.toLowerCase()}`
730
744
  );
731
745
  return snakeCasedName === reqEndpointName;
732
- }) : false;
733
- }) : false;
746
+ }) : false
747
+ ) : false;
734
748
  if (!isRequiredEndpointsContains) {
735
749
  throw new AsgardeoAuthException(
736
750
  "JS-AUTH_HELPER-REE-NF01",
@@ -747,7 +761,7 @@ var AuthenticationHelper = class {
747
761
  async resolveEndpointsByBaseURL() {
748
762
  const oidcProviderMetaData = {};
749
763
  const configData = await this._config();
750
- const baseUrl = configData.baseUrl;
764
+ const { baseUrl } = configData;
751
765
  if (!baseUrl) {
752
766
  throw new AsgardeoAuthException(
753
767
  "JS-AUTH_HELPER_REBO-NF01",
@@ -800,7 +814,7 @@ var AuthenticationHelper = class {
800
814
  await response.json()
801
815
  );
802
816
  }
803
- const issuer = (await this._oidcProviderMetaData()).issuer;
817
+ const { issuer } = await this._oidcProviderMetaData();
804
818
  const { keys } = await response.json();
805
819
  const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
806
820
  return this._cryptoHelper.isValidIdToken(
@@ -818,7 +832,7 @@ var AuthenticationHelper = class {
818
832
  const username = payload?.["username"] ?? "";
819
833
  const givenName = payload?.["given_name"] ?? "";
820
834
  const familyName = payload?.["family_name"] ?? "";
821
- const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName ? givenName : familyName ? familyName : "";
835
+ const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName || familyName || "";
822
836
  const displayName = payload.preferred_username ?? fullName;
823
837
  return {
824
838
  displayName,
@@ -829,11 +843,14 @@ var AuthenticationHelper = class {
829
843
  async replaceCustomGrantTemplateTags(text, userId) {
830
844
  const configData = await this._config();
831
845
  const sessionData = await this._storageManager.getSessionData(userId);
832
- let scope = processOpenIDScopes_default(configData.scopes);
833
- return text.replace(TokenExchangeConstants_default.Placeholders.TOKEN, sessionData.access_token).replace(
846
+ const scope = processOpenIDScopes_default(configData.scopes);
847
+ if (typeof text !== "string") {
848
+ return text;
849
+ }
850
+ return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData.access_token).replace(
834
851
  TokenExchangeConstants_default.Placeholders.USERNAME,
835
852
  this.getAuthenticatedUserInfo(sessionData.id_token).username
836
- ).replace(TokenExchangeConstants_default.Placeholders.SCOPE, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
853
+ ).replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
837
854
  }
838
855
  async clearSession(userId) {
839
856
  await this._storageManager.removeTemporaryData(userId);
@@ -853,7 +870,7 @@ var AuthenticationHelper = class {
853
870
  if (shouldValidateIdToken) {
854
871
  return this.validateIdToken(parsedResponse.id_token).then(async () => {
855
872
  await this._storageManager.setSessionData(parsedResponse, userId);
856
- const tokenResponse = {
873
+ const tokenResponse2 = {
857
874
  accessToken: parsedResponse.access_token,
858
875
  createdAt: parsedResponse.created_at,
859
876
  expiresIn: parsedResponse.expires_in,
@@ -862,21 +879,20 @@ var AuthenticationHelper = class {
862
879
  scope: parsedResponse.scope,
863
880
  tokenType: parsedResponse.token_type
864
881
  };
865
- return Promise.resolve(tokenResponse);
882
+ return Promise.resolve(tokenResponse2);
866
883
  });
867
- } else {
868
- const tokenResponse = {
869
- accessToken: parsedResponse.access_token,
870
- createdAt: parsedResponse.created_at,
871
- expiresIn: parsedResponse.expires_in,
872
- idToken: parsedResponse.id_token,
873
- refreshToken: parsedResponse.refresh_token,
874
- scope: parsedResponse.scope,
875
- tokenType: parsedResponse.token_type
876
- };
877
- await this._storageManager.setSessionData(parsedResponse, userId);
878
- return Promise.resolve(tokenResponse);
879
884
  }
885
+ const tokenResponse = {
886
+ accessToken: parsedResponse.access_token,
887
+ createdAt: parsedResponse.created_at,
888
+ expiresIn: parsedResponse.expires_in,
889
+ idToken: parsedResponse.id_token,
890
+ refreshToken: parsedResponse.refresh_token,
891
+ scope: parsedResponse.scope,
892
+ tokenType: parsedResponse.token_type
893
+ };
894
+ await this._storageManager.setSessionData(parsedResponse, userId);
895
+ return Promise.resolve(tokenResponse);
880
896
  }
881
897
  };
882
898
 
@@ -903,7 +919,7 @@ var generateStateParamForRequestCorrelation_default = generateStateParamForReque
903
919
 
904
920
  // src/utils/getAuthorizeRequestUrlParams.ts
905
921
  var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
906
- const { redirectUri, clientId, scopes, responseMode, codeChallenge, codeChallengeMethod, prompt } = options;
922
+ const { redirectUri, clientId, clientSecret, scopes, responseMode, codeChallenge, codeChallengeMethod, prompt } = options;
907
923
  const authorizeRequestParams = /* @__PURE__ */ new Map();
908
924
  authorizeRequestParams.set("response_type", "code");
909
925
  authorizeRequestParams.set("client_id", clientId);
@@ -1106,6 +1122,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
1106
1122
  codeChallenge = this._cryptoHelper?.getCodeChallenge(codeVerifier);
1107
1123
  await this._storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
1108
1124
  }
1125
+ if (authRequestConfig["client_secret"]) {
1126
+ authRequestConfig["client_secret"] = configData.clientSecret;
1127
+ }
1109
1128
  const authorizeRequestParams = getAuthorizeRequestUrlParams_default(
1110
1129
  {
1111
1130
  redirectUri: configData.afterSignInUrl,
@@ -1908,8 +1927,8 @@ Message: ${this.message}`;
1908
1927
  }
1909
1928
  };
1910
1929
 
1911
- // src/api/initializeApplicationNativeAuthentication.ts
1912
- var initializeApplicationNativeAuthentication = async ({
1930
+ // src/api/initializeEmbeddedSignInFlow.ts
1931
+ var initializeEmbeddedSignInFlow = async ({
1913
1932
  url,
1914
1933
  baseUrl,
1915
1934
  payload,
@@ -1918,7 +1937,7 @@ var initializeApplicationNativeAuthentication = async ({
1918
1937
  if (!payload) {
1919
1938
  throw new AsgardeoAPIError(
1920
1939
  "Authorization payload is required",
1921
- "initializeApplicationNativeAuthentication-ValidationError-002",
1940
+ "initializeEmbeddedSignInFlow-ValidationError-002",
1922
1941
  "javascript",
1923
1942
  400,
1924
1943
  "If an authorization payload is not provided, the request cannot be constructed correctly."
@@ -1945,7 +1964,7 @@ var initializeApplicationNativeAuthentication = async ({
1945
1964
  const errorText = await response.text();
1946
1965
  throw new AsgardeoAPIError(
1947
1966
  `Authorization request failed: ${errorText}`,
1948
- "initializeApplicationNativeAuthentication-ResponseError-001",
1967
+ "initializeEmbeddedSignInFlow-ResponseError-001",
1949
1968
  "javascript",
1950
1969
  response.status,
1951
1970
  response.statusText
@@ -1953,10 +1972,10 @@ var initializeApplicationNativeAuthentication = async ({
1953
1972
  }
1954
1973
  return await response.json();
1955
1974
  };
1956
- var initializeApplicationNativeAuthentication_default = initializeApplicationNativeAuthentication;
1975
+ var initializeEmbeddedSignInFlow_default = initializeEmbeddedSignInFlow;
1957
1976
 
1958
- // src/api/handleApplicationNativeAuthentication.ts
1959
- var handleApplicationNativeAuthentication = async ({
1977
+ // src/api/executeEmbeddedSignInFlow.ts
1978
+ var executeEmbeddedSignInFlow = async ({
1960
1979
  url,
1961
1980
  baseUrl,
1962
1981
  payload,
@@ -1965,7 +1984,7 @@ var handleApplicationNativeAuthentication = async ({
1965
1984
  if (!payload) {
1966
1985
  throw new AsgardeoAPIError(
1967
1986
  "Authorization payload is required",
1968
- "handleApplicationNativeAuthentication-ValidationError-002",
1987
+ "executeEmbeddedSignInFlow-ValidationError-002",
1969
1988
  "javascript",
1970
1989
  400,
1971
1990
  "If an authorization payload is not provided, the request cannot be constructed correctly."
@@ -1986,7 +2005,7 @@ var handleApplicationNativeAuthentication = async ({
1986
2005
  const errorText = await response.text();
1987
2006
  throw new AsgardeoAPIError(
1988
2007
  `Authorization request failed: ${errorText}`,
1989
- "initializeApplicationNativeAuthentication-ResponseError-001",
2008
+ "initializeEmbeddedSignInFlow-ResponseError-001",
1990
2009
  "javascript",
1991
2010
  response.status,
1992
2011
  response.statusText
@@ -1994,7 +2013,79 @@ var handleApplicationNativeAuthentication = async ({
1994
2013
  }
1995
2014
  return await response.json();
1996
2015
  };
1997
- var handleApplicationNativeAuthentication_default = handleApplicationNativeAuthentication;
2016
+ var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
2017
+
2018
+ // src/models/embedded-flow.ts
2019
+ var EmbeddedFlowType = /* @__PURE__ */ ((EmbeddedFlowType2) => {
2020
+ EmbeddedFlowType2["Registration"] = "REGISTRATION";
2021
+ return EmbeddedFlowType2;
2022
+ })(EmbeddedFlowType || {});
2023
+ var EmbeddedFlowStatus = /* @__PURE__ */ ((EmbeddedFlowStatus2) => {
2024
+ EmbeddedFlowStatus2["Complete"] = "COMPLETE";
2025
+ EmbeddedFlowStatus2["Incomplete"] = "INCOMPLETE";
2026
+ return EmbeddedFlowStatus2;
2027
+ })(EmbeddedFlowStatus || {});
2028
+ var EmbeddedFlowResponseType = /* @__PURE__ */ ((EmbeddedFlowResponseType2) => {
2029
+ EmbeddedFlowResponseType2["Redirection"] = "REDIRECTION";
2030
+ EmbeddedFlowResponseType2["View"] = "VIEW";
2031
+ return EmbeddedFlowResponseType2;
2032
+ })(EmbeddedFlowResponseType || {});
2033
+ var EmbeddedFlowComponentType = /* @__PURE__ */ ((EmbeddedFlowComponentType2) => {
2034
+ EmbeddedFlowComponentType2["Button"] = "BUTTON";
2035
+ EmbeddedFlowComponentType2["Checkbox"] = "CHECKBOX";
2036
+ EmbeddedFlowComponentType2["Divider"] = "DIVIDER";
2037
+ EmbeddedFlowComponentType2["Form"] = "FORM";
2038
+ EmbeddedFlowComponentType2["Image"] = "IMAGE";
2039
+ EmbeddedFlowComponentType2["Input"] = "INPUT";
2040
+ EmbeddedFlowComponentType2["Radio"] = "RADIO";
2041
+ EmbeddedFlowComponentType2["Select"] = "SELECT";
2042
+ EmbeddedFlowComponentType2["Typography"] = "TYPOGRAPHY";
2043
+ return EmbeddedFlowComponentType2;
2044
+ })(EmbeddedFlowComponentType || {});
2045
+
2046
+ // src/api/executeEmbeddedSignUpFlow.ts
2047
+ var executeEmbeddedSignUpFlow = async ({
2048
+ url,
2049
+ baseUrl,
2050
+ payload,
2051
+ ...requestConfig
2052
+ }) => {
2053
+ if (!baseUrl && !url) {
2054
+ throw new AsgardeoAPIError(
2055
+ "Embedded SignUp flow execution failed: Base URL or URL is not provided.",
2056
+ "javascript-executeEmbeddedSignUpFlow-ValidationError-001",
2057
+ "javascript",
2058
+ 400,
2059
+ "At least one of the baseUrl or url must be provided to execute the embedded sign up flow."
2060
+ );
2061
+ }
2062
+ const { headers: customHeaders, ...otherConfig } = requestConfig;
2063
+ const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
2064
+ method: requestConfig.method || "POST",
2065
+ headers: {
2066
+ "Content-Type": "application/json",
2067
+ Accept: "application/json",
2068
+ ...customHeaders
2069
+ },
2070
+ body: JSON.stringify({
2071
+ ...payload ?? {},
2072
+ flowType: "REGISTRATION" /* Registration */
2073
+ }),
2074
+ ...otherConfig
2075
+ });
2076
+ if (!response.ok) {
2077
+ const errorText = await response.text();
2078
+ throw new AsgardeoAPIError(
2079
+ `Embedded SignUp flow execution failed: ${errorText}`,
2080
+ "javascript-executeEmbeddedSignUpFlow-ResponseError-100",
2081
+ "javascript",
2082
+ response.status,
2083
+ response.statusText
2084
+ );
2085
+ }
2086
+ return await response.json();
2087
+ };
2088
+ var executeEmbeddedSignUpFlow_default = executeEmbeddedSignUpFlow;
1998
2089
 
1999
2090
  // src/api/getUserInfo.ts
2000
2091
  var getUserInfo = async ({ url, ...requestConfig }) => {
@@ -2031,6 +2122,574 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
2031
2122
  };
2032
2123
  var getUserInfo_default = getUserInfo;
2033
2124
 
2125
+ // src/api/getScim2Me.ts
2126
+ var getScim2Me = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
2127
+ try {
2128
+ new URL(url ?? baseUrl);
2129
+ } catch (error) {
2130
+ throw new AsgardeoAPIError(
2131
+ `Invalid URL provided. ${error?.toString()}`,
2132
+ "getScim2Me-ValidationError-001",
2133
+ "javascript",
2134
+ 400,
2135
+ "The provided `url` or `baseUrl` path does not adhere to the URL schema."
2136
+ );
2137
+ }
2138
+ const fetchFn = fetcher || fetch;
2139
+ const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
2140
+ const requestInit = {
2141
+ method: "GET",
2142
+ headers: {
2143
+ "Content-Type": "application/scim+json",
2144
+ Accept: "application/json",
2145
+ ...requestConfig.headers
2146
+ },
2147
+ ...requestConfig
2148
+ };
2149
+ try {
2150
+ const response = await fetchFn(resolvedUrl, requestInit);
2151
+ if (!response?.ok) {
2152
+ const errorText = await response.text();
2153
+ throw new AsgardeoAPIError(
2154
+ `Failed to fetch user profile: ${errorText}`,
2155
+ "getScim2Me-ResponseError-001",
2156
+ "javascript",
2157
+ response.status,
2158
+ response.statusText
2159
+ );
2160
+ }
2161
+ return await response.json();
2162
+ } catch (error) {
2163
+ if (error instanceof AsgardeoAPIError) {
2164
+ throw error;
2165
+ }
2166
+ throw new AsgardeoAPIError(
2167
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2168
+ "getScim2Me-NetworkError-001",
2169
+ "javascript",
2170
+ 0,
2171
+ "Network Error"
2172
+ );
2173
+ }
2174
+ };
2175
+ var getScim2Me_default = getScim2Me;
2176
+
2177
+ // src/api/getSchemas.ts
2178
+ var getSchemas = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
2179
+ try {
2180
+ new URL(url ?? baseUrl);
2181
+ } catch (error) {
2182
+ throw new AsgardeoAPIError(
2183
+ `Invalid URL provided. ${error?.toString()}`,
2184
+ "getSchemas-ValidationError-001",
2185
+ "javascript",
2186
+ 400,
2187
+ "The provided `url` or `baseUrl` path does not adhere to the URL schema."
2188
+ );
2189
+ }
2190
+ const fetchFn = fetcher || fetch;
2191
+ const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
2192
+ const requestInit = {
2193
+ method: "GET",
2194
+ headers: {
2195
+ "Content-Type": "application/json",
2196
+ Accept: "application/json",
2197
+ ...requestConfig.headers
2198
+ },
2199
+ ...requestConfig
2200
+ };
2201
+ try {
2202
+ const response = await fetchFn(resolvedUrl, requestInit);
2203
+ if (!response?.ok) {
2204
+ const errorText = await response.text();
2205
+ throw new AsgardeoAPIError(
2206
+ `Failed to fetch SCIM2 schemas: ${errorText}`,
2207
+ "getSchemas-ResponseError-001",
2208
+ "javascript",
2209
+ response.status,
2210
+ response.statusText
2211
+ );
2212
+ }
2213
+ return await response.json();
2214
+ } catch (error) {
2215
+ if (error instanceof AsgardeoAPIError) {
2216
+ throw error;
2217
+ }
2218
+ throw new AsgardeoAPIError(
2219
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2220
+ "getSchemas-NetworkError-001",
2221
+ "javascript",
2222
+ 0,
2223
+ "Network Error"
2224
+ );
2225
+ }
2226
+ };
2227
+ var getSchemas_default = getSchemas;
2228
+
2229
+ // src/api/getAllOrganizations.ts
2230
+ var getAllOrganizations = async ({
2231
+ baseUrl,
2232
+ filter = "",
2233
+ limit = 10,
2234
+ recursive = false,
2235
+ fetcher,
2236
+ ...requestConfig
2237
+ }) => {
2238
+ try {
2239
+ new URL(baseUrl);
2240
+ } catch (error) {
2241
+ throw new AsgardeoAPIError(
2242
+ `Invalid base URL provided. ${error?.toString()}`,
2243
+ "getAllOrganizations-ValidationError-001",
2244
+ "javascript",
2245
+ 400,
2246
+ "The provided `baseUrl` does not adhere to the URL schema."
2247
+ );
2248
+ }
2249
+ const queryParams = new URLSearchParams(
2250
+ Object.fromEntries(
2251
+ Object.entries({
2252
+ filter,
2253
+ limit: limit.toString(),
2254
+ recursive: recursive.toString()
2255
+ }).filter(([, value]) => Boolean(value))
2256
+ )
2257
+ );
2258
+ const fetchFn = fetcher || fetch;
2259
+ const resolvedUrl = `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`;
2260
+ const requestInit = {
2261
+ method: "GET",
2262
+ headers: {
2263
+ "Content-Type": "application/json",
2264
+ Accept: "application/json",
2265
+ ...requestConfig.headers
2266
+ },
2267
+ ...requestConfig
2268
+ };
2269
+ try {
2270
+ const response = await fetchFn(resolvedUrl, requestInit);
2271
+ if (!response?.ok) {
2272
+ const errorText = await response.text();
2273
+ throw new AsgardeoAPIError(
2274
+ `Failed to get organizations: ${errorText}`,
2275
+ "getAllOrganizations-ResponseError-001",
2276
+ "javascript",
2277
+ response.status,
2278
+ response.statusText
2279
+ );
2280
+ }
2281
+ const data = await response.json();
2282
+ return {
2283
+ hasMore: data.hasMore,
2284
+ nextCursor: data.nextCursor,
2285
+ organizations: data.organizations || [],
2286
+ totalCount: data.totalCount
2287
+ };
2288
+ } catch (error) {
2289
+ if (error instanceof AsgardeoAPIError) {
2290
+ throw error;
2291
+ }
2292
+ throw new AsgardeoAPIError(
2293
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2294
+ "getAllOrganizations-NetworkError-001",
2295
+ "javascript",
2296
+ 0,
2297
+ "Network Error"
2298
+ );
2299
+ }
2300
+ };
2301
+ var getAllOrganizations_default = getAllOrganizations;
2302
+
2303
+ // src/api/createOrganization.ts
2304
+ var createOrganization = async ({
2305
+ baseUrl,
2306
+ payload,
2307
+ fetcher,
2308
+ ...requestConfig
2309
+ }) => {
2310
+ try {
2311
+ new URL(baseUrl);
2312
+ } catch (error) {
2313
+ throw new AsgardeoAPIError(
2314
+ `Invalid base URL provided. ${error?.toString()}`,
2315
+ "createOrganization-ValidationError-001",
2316
+ "javascript",
2317
+ 400,
2318
+ "The provided `baseUrl` does not adhere to the URL schema."
2319
+ );
2320
+ }
2321
+ if (!payload) {
2322
+ throw new AsgardeoAPIError(
2323
+ "Organization payload is required",
2324
+ "createOrganization-ValidationError-002",
2325
+ "javascript",
2326
+ 400,
2327
+ "Invalid Request"
2328
+ );
2329
+ }
2330
+ const organizationPayload = {
2331
+ ...payload,
2332
+ type: "TENANT"
2333
+ };
2334
+ const fetchFn = fetcher || fetch;
2335
+ const resolvedUrl = `${baseUrl}/api/server/v1/organizations`;
2336
+ const requestInit = {
2337
+ method: "POST",
2338
+ headers: {
2339
+ "Content-Type": "application/json",
2340
+ Accept: "application/json",
2341
+ ...requestConfig.headers
2342
+ },
2343
+ body: JSON.stringify(organizationPayload),
2344
+ ...requestConfig
2345
+ };
2346
+ try {
2347
+ const response = await fetchFn(resolvedUrl, requestInit);
2348
+ if (!response?.ok) {
2349
+ const errorText = await response.text();
2350
+ throw new AsgardeoAPIError(
2351
+ `Failed to create organization: ${errorText}`,
2352
+ "createOrganization-ResponseError-001",
2353
+ "javascript",
2354
+ response.status,
2355
+ response.statusText
2356
+ );
2357
+ }
2358
+ return await response.json();
2359
+ } catch (error) {
2360
+ if (error instanceof AsgardeoAPIError) {
2361
+ throw error;
2362
+ }
2363
+ throw new AsgardeoAPIError(
2364
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2365
+ "createOrganization-NetworkError-001",
2366
+ "javascript",
2367
+ 0,
2368
+ "Network Error"
2369
+ );
2370
+ }
2371
+ };
2372
+ var createOrganization_default = createOrganization;
2373
+
2374
+ // src/api/getMeOrganizations.ts
2375
+ var getMeOrganizations = async ({
2376
+ baseUrl,
2377
+ after = "",
2378
+ authorizedAppName = "",
2379
+ before = "",
2380
+ filter = "",
2381
+ limit = 10,
2382
+ recursive = false,
2383
+ fetcher,
2384
+ ...requestConfig
2385
+ }) => {
2386
+ try {
2387
+ new URL(baseUrl);
2388
+ } catch (error) {
2389
+ throw new AsgardeoAPIError(
2390
+ `Invalid base URL provided. ${error?.toString()}`,
2391
+ "getMeOrganizations-ValidationError-001",
2392
+ "javascript",
2393
+ 400,
2394
+ "The provided `baseUrl` does not adhere to the URL schema."
2395
+ );
2396
+ }
2397
+ const queryParams = new URLSearchParams(
2398
+ Object.fromEntries(
2399
+ Object.entries({
2400
+ after,
2401
+ authorizedAppName,
2402
+ before,
2403
+ filter,
2404
+ limit: limit.toString(),
2405
+ recursive: recursive.toString()
2406
+ }).filter(([, value]) => Boolean(value))
2407
+ )
2408
+ );
2409
+ const fetchFn = fetcher || fetch;
2410
+ const resolvedUrl = `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`;
2411
+ const requestInit = {
2412
+ method: "GET",
2413
+ headers: {
2414
+ "Content-Type": "application/json",
2415
+ Accept: "application/json",
2416
+ ...requestConfig.headers
2417
+ },
2418
+ ...requestConfig
2419
+ };
2420
+ try {
2421
+ const response = await fetchFn(resolvedUrl, requestInit);
2422
+ if (!response?.ok) {
2423
+ const errorText = await response.text();
2424
+ throw new AsgardeoAPIError(
2425
+ `Failed to fetch associated organizations of the user: ${errorText}`,
2426
+ "getMeOrganizations-ResponseError-001",
2427
+ "javascript",
2428
+ response.status,
2429
+ response.statusText
2430
+ );
2431
+ }
2432
+ const data = await response.json();
2433
+ return data.organizations || [];
2434
+ } catch (error) {
2435
+ if (error instanceof AsgardeoAPIError) {
2436
+ throw error;
2437
+ }
2438
+ throw new AsgardeoAPIError(
2439
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2440
+ "getMeOrganizations-NetworkError-001",
2441
+ "javascript",
2442
+ 0,
2443
+ "Network Error"
2444
+ );
2445
+ }
2446
+ };
2447
+ var getMeOrganizations_default = getMeOrganizations;
2448
+
2449
+ // src/api/getOrganization.ts
2450
+ var getOrganization = async ({
2451
+ baseUrl,
2452
+ organizationId,
2453
+ fetcher,
2454
+ ...requestConfig
2455
+ }) => {
2456
+ try {
2457
+ new URL(baseUrl);
2458
+ } catch (error) {
2459
+ throw new AsgardeoAPIError(
2460
+ `Invalid base URL provided. ${error?.toString()}`,
2461
+ "getOrganization-ValidationError-001",
2462
+ "javascript",
2463
+ 400,
2464
+ "The provided `baseUrl` does not adhere to the URL schema."
2465
+ );
2466
+ }
2467
+ if (!organizationId) {
2468
+ throw new AsgardeoAPIError(
2469
+ "Organization ID is required",
2470
+ "getOrganization-ValidationError-002",
2471
+ "javascript",
2472
+ 400,
2473
+ "Invalid Request"
2474
+ );
2475
+ }
2476
+ const fetchFn = fetcher || fetch;
2477
+ const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
2478
+ const requestInit = {
2479
+ method: "GET",
2480
+ headers: {
2481
+ "Content-Type": "application/json",
2482
+ Accept: "application/json",
2483
+ ...requestConfig.headers
2484
+ },
2485
+ ...requestConfig
2486
+ };
2487
+ try {
2488
+ const response = await fetchFn(resolvedUrl, requestInit);
2489
+ if (!response?.ok) {
2490
+ const errorText = await response.text();
2491
+ throw new AsgardeoAPIError(
2492
+ `Failed to fetch organization details: ${errorText}`,
2493
+ "getOrganization-ResponseError-001",
2494
+ "javascript",
2495
+ response.status,
2496
+ response.statusText
2497
+ );
2498
+ }
2499
+ return await response.json();
2500
+ } catch (error) {
2501
+ if (error instanceof AsgardeoAPIError) {
2502
+ throw error;
2503
+ }
2504
+ throw new AsgardeoAPIError(
2505
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2506
+ "getOrganization-NetworkError-001",
2507
+ "javascript",
2508
+ 0,
2509
+ "Network Error"
2510
+ );
2511
+ }
2512
+ };
2513
+ var getOrganization_default = getOrganization;
2514
+
2515
+ // src/utils/isEmpty.ts
2516
+ var isEmpty = (value) => {
2517
+ if (value === null || value === void 0) {
2518
+ return true;
2519
+ }
2520
+ if (typeof value === "string") {
2521
+ return value.trim() === "";
2522
+ }
2523
+ if (Array.isArray(value)) {
2524
+ return value.length === 0;
2525
+ }
2526
+ if (typeof value === "object" && value.constructor === Object) {
2527
+ return Object.keys(value).length === 0;
2528
+ }
2529
+ return false;
2530
+ };
2531
+ var isEmpty_default = isEmpty;
2532
+
2533
+ // src/api/updateOrganization.ts
2534
+ var updateOrganization = async ({
2535
+ baseUrl,
2536
+ organizationId,
2537
+ operations,
2538
+ fetcher,
2539
+ ...requestConfig
2540
+ }) => {
2541
+ try {
2542
+ new URL(baseUrl);
2543
+ } catch (error) {
2544
+ throw new AsgardeoAPIError(
2545
+ `Invalid base URL provided. ${error?.toString()}`,
2546
+ "updateOrganization-ValidationError-001",
2547
+ "javascript",
2548
+ 400,
2549
+ "The provided `baseUrl` does not adhere to the URL schema."
2550
+ );
2551
+ }
2552
+ if (!organizationId) {
2553
+ throw new AsgardeoAPIError(
2554
+ "Organization ID is required",
2555
+ "updateOrganization-ValidationError-002",
2556
+ "javascript",
2557
+ 400,
2558
+ "Invalid Request"
2559
+ );
2560
+ }
2561
+ if (!operations || !Array.isArray(operations) || operations.length === 0) {
2562
+ throw new AsgardeoAPIError(
2563
+ "Operations array is required and cannot be empty",
2564
+ "updateOrganization-ValidationError-003",
2565
+ "javascript",
2566
+ 400,
2567
+ "Invalid Request"
2568
+ );
2569
+ }
2570
+ const fetchFn = fetcher || fetch;
2571
+ const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
2572
+ const requestInit = {
2573
+ method: "PATCH",
2574
+ headers: {
2575
+ "Content-Type": "application/json",
2576
+ Accept: "application/json",
2577
+ ...requestConfig.headers
2578
+ },
2579
+ body: JSON.stringify(operations),
2580
+ ...requestConfig
2581
+ };
2582
+ try {
2583
+ const response = await fetchFn(resolvedUrl, requestInit);
2584
+ if (!response?.ok) {
2585
+ const errorText = await response.text();
2586
+ throw new AsgardeoAPIError(
2587
+ `Failed to update organization: ${errorText}`,
2588
+ "updateOrganization-ResponseError-001",
2589
+ "javascript",
2590
+ response.status,
2591
+ response.statusText
2592
+ );
2593
+ }
2594
+ return await response.json();
2595
+ } catch (error) {
2596
+ if (error instanceof AsgardeoAPIError) {
2597
+ throw error;
2598
+ }
2599
+ throw new AsgardeoAPIError(
2600
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2601
+ "updateOrganization-NetworkError-001",
2602
+ "javascript",
2603
+ 0,
2604
+ "Network Error"
2605
+ );
2606
+ }
2607
+ };
2608
+ var createPatchOperations = (payload) => {
2609
+ return Object.entries(payload).map(([key, value]) => {
2610
+ if (isEmpty_default(value)) {
2611
+ return {
2612
+ operation: "REMOVE",
2613
+ path: `/${key}`
2614
+ };
2615
+ }
2616
+ return {
2617
+ operation: "REPLACE",
2618
+ path: `/${key}`,
2619
+ value
2620
+ };
2621
+ });
2622
+ };
2623
+ var updateOrganization_default = updateOrganization;
2624
+
2625
+ // src/api/updateMeProfile.ts
2626
+ var updateMeProfile = async ({
2627
+ url,
2628
+ baseUrl,
2629
+ payload,
2630
+ fetcher,
2631
+ ...requestConfig
2632
+ }) => {
2633
+ try {
2634
+ new URL(url ?? baseUrl);
2635
+ } catch (error) {
2636
+ throw new AsgardeoAPIError(
2637
+ `Invalid URL provided. ${error?.toString()}`,
2638
+ "updateMeProfile-ValidationError-001",
2639
+ "javascript",
2640
+ 400,
2641
+ "The provided `url` or `baseUrl` path does not adhere to the URL schema."
2642
+ );
2643
+ }
2644
+ const data = {
2645
+ Operations: [
2646
+ {
2647
+ op: "replace",
2648
+ value: payload
2649
+ }
2650
+ ],
2651
+ schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
2652
+ };
2653
+ const fetchFn = fetcher || fetch;
2654
+ const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
2655
+ const requestInit = {
2656
+ method: "PATCH",
2657
+ headers: {
2658
+ "Content-Type": "application/scim+json",
2659
+ Accept: "application/json",
2660
+ ...requestConfig.headers
2661
+ },
2662
+ body: JSON.stringify(data),
2663
+ ...requestConfig
2664
+ };
2665
+ try {
2666
+ const response = await fetchFn(resolvedUrl, requestInit);
2667
+ if (!response?.ok) {
2668
+ const errorText = await response.text();
2669
+ throw new AsgardeoAPIError(
2670
+ `Failed to update user profile: ${errorText}`,
2671
+ "updateMeProfile-ResponseError-001",
2672
+ "javascript",
2673
+ response.status,
2674
+ response.statusText
2675
+ );
2676
+ }
2677
+ return await response.json();
2678
+ } catch (error) {
2679
+ if (error instanceof AsgardeoAPIError) {
2680
+ throw error;
2681
+ }
2682
+ throw new AsgardeoAPIError(
2683
+ `Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
2684
+ "updateMeProfile-NetworkError-001",
2685
+ "javascript",
2686
+ 0,
2687
+ "Network Error"
2688
+ );
2689
+ }
2690
+ };
2691
+ var updateMeProfile_default = updateMeProfile;
2692
+
2034
2693
  // src/constants/ApplicationNativeAuthenticationConstants.ts
2035
2694
  var ApplicationNativeAuthenticationConstants = {
2036
2695
  SupportedAuthenticators: {
@@ -2052,39 +2711,55 @@ var ApplicationNativeAuthenticationConstants = {
2052
2711
  };
2053
2712
  var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
2054
2713
 
2055
- // src/models/application-native-authentication.ts
2056
- var ApplicationNativeAuthenticationFlowStatus = /* @__PURE__ */ ((ApplicationNativeAuthenticationFlowStatus2) => {
2057
- ApplicationNativeAuthenticationFlowStatus2["SuccessCompleted"] = "SUCCESS_COMPLETED";
2058
- ApplicationNativeAuthenticationFlowStatus2["FailCompleted"] = "FAIL_COMPLETED";
2059
- ApplicationNativeAuthenticationFlowStatus2["FailIncomplete"] = "FAIL_INCOMPLETE";
2060
- ApplicationNativeAuthenticationFlowStatus2["Incomplete"] = "INCOMPLETE";
2061
- return ApplicationNativeAuthenticationFlowStatus2;
2062
- })(ApplicationNativeAuthenticationFlowStatus || {});
2063
- var ApplicationNativeAuthenticationFlowType = /* @__PURE__ */ ((ApplicationNativeAuthenticationFlowType2) => {
2064
- ApplicationNativeAuthenticationFlowType2["Authentication"] = "AUTHENTICATION";
2065
- return ApplicationNativeAuthenticationFlowType2;
2066
- })(ApplicationNativeAuthenticationFlowType || {});
2067
- var ApplicationNativeAuthenticationStepType = /* @__PURE__ */ ((ApplicationNativeAuthenticationStepType2) => {
2068
- ApplicationNativeAuthenticationStepType2["AuthenticatorPrompt"] = "AUTHENTICATOR_PROMPT";
2069
- ApplicationNativeAuthenticationStepType2["MultOptionsPrompt"] = "MULTI_OPTIONS_PROMPT";
2070
- return ApplicationNativeAuthenticationStepType2;
2071
- })(ApplicationNativeAuthenticationStepType || {});
2072
- var ApplicationNativeAuthenticationAuthenticatorParamType = /* @__PURE__ */ ((ApplicationNativeAuthenticationAuthenticatorParamType2) => {
2073
- ApplicationNativeAuthenticationAuthenticatorParamType2["String"] = "STRING";
2074
- ApplicationNativeAuthenticationAuthenticatorParamType2["Integer"] = "INTEGER";
2075
- ApplicationNativeAuthenticationAuthenticatorParamType2["MultiValued"] = "MULTI_VALUED";
2076
- return ApplicationNativeAuthenticationAuthenticatorParamType2;
2077
- })(ApplicationNativeAuthenticationAuthenticatorParamType || {});
2078
- var ApplicationNativeAuthenticationAuthenticatorKnownIdPType = /* @__PURE__ */ ((ApplicationNativeAuthenticationAuthenticatorKnownIdPType2) => {
2079
- ApplicationNativeAuthenticationAuthenticatorKnownIdPType2["Local"] = "LOCAL";
2080
- return ApplicationNativeAuthenticationAuthenticatorKnownIdPType2;
2081
- })(ApplicationNativeAuthenticationAuthenticatorKnownIdPType || {});
2082
- var ApplicationNativeAuthenticationAuthenticatorPromptType = /* @__PURE__ */ ((ApplicationNativeAuthenticationAuthenticatorPromptType2) => {
2083
- ApplicationNativeAuthenticationAuthenticatorPromptType2["UserPrompt"] = "USER_PROMPT";
2084
- ApplicationNativeAuthenticationAuthenticatorPromptType2["InternalPrompt"] = "INTERNAL_PROMPT";
2085
- ApplicationNativeAuthenticationAuthenticatorPromptType2["RedirectionPrompt"] = "REDIRECTION_PROMPT";
2086
- return ApplicationNativeAuthenticationAuthenticatorPromptType2;
2087
- })(ApplicationNativeAuthenticationAuthenticatorPromptType || {});
2714
+ // src/constants/VendorConstants.ts
2715
+ var VendorConstants = {
2716
+ /**
2717
+ * The prefix used for vendor-specific API endpoints, CSS classes, or other identifiers.
2718
+ */
2719
+ VENDOR_PREFIX: "asgardeo"
2720
+ };
2721
+ var VendorConstants_default = VendorConstants;
2722
+
2723
+ // src/models/embedded-signin-flow.ts
2724
+ var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus2) => {
2725
+ EmbeddedSignInFlowStatus2["FailCompleted"] = "FAIL_COMPLETED";
2726
+ EmbeddedSignInFlowStatus2["FailIncomplete"] = "FAIL_INCOMPLETE";
2727
+ EmbeddedSignInFlowStatus2["Incomplete"] = "INCOMPLETE";
2728
+ EmbeddedSignInFlowStatus2["SuccessCompleted"] = "SUCCESS_COMPLETED";
2729
+ return EmbeddedSignInFlowStatus2;
2730
+ })(EmbeddedSignInFlowStatus || {});
2731
+ var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType2) => {
2732
+ EmbeddedSignInFlowType2["Authentication"] = "AUTHENTICATION";
2733
+ return EmbeddedSignInFlowType2;
2734
+ })(EmbeddedSignInFlowType || {});
2735
+ var EmbeddedSignInFlowStepType = /* @__PURE__ */ ((EmbeddedSignInFlowStepType2) => {
2736
+ EmbeddedSignInFlowStepType2["AuthenticatorPrompt"] = "AUTHENTICATOR_PROMPT";
2737
+ EmbeddedSignInFlowStepType2["MultiOptionsPrompt"] = "MULTI_OPTIONS_PROMPT";
2738
+ return EmbeddedSignInFlowStepType2;
2739
+ })(EmbeddedSignInFlowStepType || {});
2740
+ var EmbeddedSignInFlowAuthenticatorParamType = /* @__PURE__ */ ((EmbeddedSignInFlowAuthenticatorParamType2) => {
2741
+ EmbeddedSignInFlowAuthenticatorParamType2["Integer"] = "INTEGER";
2742
+ EmbeddedSignInFlowAuthenticatorParamType2["MultiValued"] = "MULTI_VALUED";
2743
+ EmbeddedSignInFlowAuthenticatorParamType2["String"] = "STRING";
2744
+ return EmbeddedSignInFlowAuthenticatorParamType2;
2745
+ })(EmbeddedSignInFlowAuthenticatorParamType || {});
2746
+ var EmbeddedSignInFlowAuthenticatorKnownIdPType = /* @__PURE__ */ ((EmbeddedSignInFlowAuthenticatorKnownIdPType2) => {
2747
+ EmbeddedSignInFlowAuthenticatorKnownIdPType2["Local"] = "LOCAL";
2748
+ return EmbeddedSignInFlowAuthenticatorKnownIdPType2;
2749
+ })(EmbeddedSignInFlowAuthenticatorKnownIdPType || {});
2750
+ var EmbeddedSignInFlowAuthenticatorPromptType = /* @__PURE__ */ ((EmbeddedSignInFlowAuthenticatorPromptType2) => {
2751
+ EmbeddedSignInFlowAuthenticatorPromptType2["InternalPrompt"] = "INTERNAL_PROMPT";
2752
+ EmbeddedSignInFlowAuthenticatorPromptType2["RedirectionPrompt"] = "REDIRECTION_PROMPT";
2753
+ EmbeddedSignInFlowAuthenticatorPromptType2["UserPrompt"] = "USER_PROMPT";
2754
+ return EmbeddedSignInFlowAuthenticatorPromptType2;
2755
+ })(EmbeddedSignInFlowAuthenticatorPromptType || {});
2756
+
2757
+ // src/models/flow.ts
2758
+ var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
2759
+ FlowMode2["Embedded"] = "DIRECT";
2760
+ FlowMode2["Redirect"] = "REDIRECTION";
2761
+ return FlowMode2;
2762
+ })(FlowMode || {});
2088
2763
 
2089
2764
  // src/models/scim2-schema.ts
2090
2765
  var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
@@ -2139,6 +2814,14 @@ var lightTheme = {
2139
2814
  main: "#d32f2f",
2140
2815
  contrastText: "#ffffff"
2141
2816
  },
2817
+ success: {
2818
+ main: "#4caf50",
2819
+ contrastText: "#ffffff"
2820
+ },
2821
+ warning: {
2822
+ main: "#ff9800",
2823
+ contrastText: "#ffffff"
2824
+ },
2142
2825
  text: {
2143
2826
  primary: "#1a1a1a",
2144
2827
  secondary: "#666666"
@@ -2152,6 +2835,11 @@ var lightTheme = {
2152
2835
  small: "4px",
2153
2836
  medium: "8px",
2154
2837
  large: "16px"
2838
+ },
2839
+ shadows: {
2840
+ small: "0 2px 8px rgba(0, 0, 0, 0.1)",
2841
+ medium: "0 4px 16px rgba(0, 0, 0, 0.15)",
2842
+ large: "0 8px 32px rgba(0, 0, 0, 0.2)"
2155
2843
  }
2156
2844
  };
2157
2845
  var darkTheme = {
@@ -2175,6 +2863,14 @@ var darkTheme = {
2175
2863
  main: "#d32f2f",
2176
2864
  contrastText: "#ffffff"
2177
2865
  },
2866
+ success: {
2867
+ main: "#4caf50",
2868
+ contrastText: "#ffffff"
2869
+ },
2870
+ warning: {
2871
+ main: "#ff9800",
2872
+ contrastText: "#ffffff"
2873
+ },
2178
2874
  text: {
2179
2875
  primary: "#ffffff",
2180
2876
  secondary: "#b3b3b3"
@@ -2188,6 +2884,11 @@ var darkTheme = {
2188
2884
  small: "4px",
2189
2885
  medium: "8px",
2190
2886
  large: "16px"
2887
+ },
2888
+ shadows: {
2889
+ small: "0 2px 8px rgba(0, 0, 0, 0.3)",
2890
+ medium: "0 4px 16px rgba(0, 0, 0, 0.4)",
2891
+ large: "0 8px 32px rgba(0, 0, 0, 0.5)"
2191
2892
  }
2192
2893
  };
2193
2894
  var toCssVariables = (theme) => {
@@ -2201,6 +2902,10 @@ var toCssVariables = (theme) => {
2201
2902
  cssVars["--asgardeo-color-background-body-main"] = theme.colors.background.body.main;
2202
2903
  cssVars["--asgardeo-color-error-main"] = theme.colors.error.main;
2203
2904
  cssVars["--asgardeo-color-error-contrastText"] = theme.colors.error.contrastText;
2905
+ cssVars["--asgardeo-color-success-main"] = theme.colors.success.main;
2906
+ cssVars["--asgardeo-color-success-contrastText"] = theme.colors.success.contrastText;
2907
+ cssVars["--asgardeo-color-warning-main"] = theme.colors.warning.main;
2908
+ cssVars["--asgardeo-color-warning-contrastText"] = theme.colors.warning.contrastText;
2204
2909
  cssVars["--asgardeo-color-text-primary"] = theme.colors.text.primary;
2205
2910
  cssVars["--asgardeo-color-text-secondary"] = theme.colors.text.secondary;
2206
2911
  cssVars["--asgardeo-color-border"] = theme.colors.border;
@@ -2208,6 +2913,9 @@ var toCssVariables = (theme) => {
2208
2913
  cssVars["--asgardeo-border-radius-small"] = theme.borderRadius.small;
2209
2914
  cssVars["--asgardeo-border-radius-medium"] = theme.borderRadius.medium;
2210
2915
  cssVars["--asgardeo-border-radius-large"] = theme.borderRadius.large;
2916
+ cssVars["--asgardeo-shadow-small"] = theme.shadows.small;
2917
+ cssVars["--asgardeo-shadow-medium"] = theme.shadows.medium;
2918
+ cssVars["--asgardeo-shadow-large"] = theme.shadows.large;
2211
2919
  return cssVars;
2212
2920
  };
2213
2921
  var createTheme = (config = {}, isDark = false) => {
@@ -2230,6 +2938,10 @@ var createTheme = (config = {}, isDark = false) => {
2230
2938
  borderRadius: {
2231
2939
  ...baseTheme.borderRadius,
2232
2940
  ...config.borderRadius
2941
+ },
2942
+ shadows: {
2943
+ ...baseTheme.shadows,
2944
+ ...config.shadows
2233
2945
  }
2234
2946
  };
2235
2947
  return {
@@ -2378,27 +3090,67 @@ var generateFlattenedUserProfile = (meResponse, processedSchemas) => {
2378
3090
  const { name, type, multiValued } = schema;
2379
3091
  if (!name) return;
2380
3092
  const hasChildProperties = allSchemaNames.some(
2381
- (schemaName) => schemaName !== name && schemaName.startsWith(name + ".")
3093
+ (schemaName) => schemaName !== name && schemaName.startsWith(`${name}.`)
2382
3094
  );
2383
3095
  if (hasChildProperties) {
2384
3096
  return;
2385
3097
  }
2386
3098
  let value = get_default(meResponse, name);
3099
+ if (value === void 0) {
3100
+ const schemaNamespaces = [
3101
+ "urn:ietf:params:scim:schemas:core:2.0:User",
3102
+ "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
3103
+ "urn:scim:wso2:schema",
3104
+ "urn:scim:schemas:extension:custom:User"
3105
+ ];
3106
+ schemaNamespaces.some((namespace) => {
3107
+ if (meResponse[namespace]) {
3108
+ if (meResponse[namespace][name] !== void 0) {
3109
+ value = meResponse[namespace][name];
3110
+ return true;
3111
+ }
3112
+ const nestedValue = get_default(meResponse[namespace], name);
3113
+ if (nestedValue !== void 0) {
3114
+ value = nestedValue;
3115
+ return true;
3116
+ }
3117
+ }
3118
+ return false;
3119
+ });
3120
+ }
2387
3121
  if (value !== void 0) {
2388
3122
  if (multiValued && !Array.isArray(value)) {
2389
3123
  value = [value];
2390
3124
  }
3125
+ } else if (multiValued) {
3126
+ value = void 0;
3127
+ } else if (type === "STRING") {
3128
+ value = "";
2391
3129
  } else {
2392
- if (multiValued) {
2393
- value = void 0;
2394
- } else if (type === "STRING") {
2395
- value = "";
2396
- } else {
2397
- value = void 0;
2398
- }
3130
+ value = void 0;
2399
3131
  }
2400
3132
  profile[name] = value;
2401
3133
  });
3134
+ const flattenObject = (obj, prefix = "") => {
3135
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
3136
+ Object.keys(obj).forEach((key) => {
3137
+ const fullKey = prefix ? `${prefix}.${key}` : key;
3138
+ const value = obj[key];
3139
+ if (Object.prototype.hasOwnProperty.call(profile, fullKey)) {
3140
+ return;
3141
+ }
3142
+ const hasSchemaChildProperties = allSchemaNames.some(
3143
+ (schemaName) => schemaName.startsWith(`${fullKey}.`)
3144
+ );
3145
+ if (hasSchemaChildProperties) {
3146
+ flattenObject(value, fullKey);
3147
+ } else {
3148
+ profile[fullKey] = value;
3149
+ }
3150
+ });
3151
+ }
3152
+ };
3153
+ flattenObject(meResponse);
2402
3154
  return profile;
2403
3155
  };
2404
3156
  var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
@@ -2433,6 +3185,10 @@ var translations = {
2433
3185
  /* |---------------------------------------------------------------| */
2434
3186
  /* Base Sign In */
2435
3187
  "signin.title": "Sign In",
3188
+ "signin.subtitle": "Enter your credentials to continue.",
3189
+ /* Base Sign Up */
3190
+ "signup.title": "Sign Up",
3191
+ "signup.subtitle": "Create a new account to get started.",
2436
3192
  /* Email OTP */
2437
3193
  "email.otp.title": "OTP Verification",
2438
3194
  "email.otp.subtitle": "Enter the code sent to your email address.",
@@ -2454,6 +3210,30 @@ var translations = {
2454
3210
  "username.password.title": "Sign In",
2455
3211
  "username.password.subtitle": "Enter your username and password to continue.",
2456
3212
  /* |---------------------------------------------------------------| */
3213
+ /* | Organization Switcher | */
3214
+ /* |---------------------------------------------------------------| */
3215
+ "organization.switcher.select.organization": "Select Organization",
3216
+ "organization.switcher.switch.organization": "Switch Organization",
3217
+ "organization.switcher.loading.organizations": "Loading organizations...",
3218
+ "organization.switcher.members": "members",
3219
+ "organization.switcher.member": "member",
3220
+ "organization.switcher.create.organization": "Create Organization",
3221
+ "organization.switcher.manage.organizations": "Manage Organization",
3222
+ "organization.switcher.manage.button": "Manage",
3223
+ "organization.profile.title": "Organization Profile",
3224
+ "organization.profile.loading": "Loading organization...",
3225
+ "organization.profile.error": "Failed to load organization",
3226
+ "organization.create.title": "Create Organization",
3227
+ "organization.create.name.label": "Organization Name",
3228
+ "organization.create.name.placeholder": "Enter organization name",
3229
+ "organization.create.handle.label": "Organization Handle",
3230
+ "organization.create.handle.placeholder": "my-organization",
3231
+ "organization.create.description.label": "Description",
3232
+ "organization.create.description.placeholder": "Enter organization description",
3233
+ "organization.create.button": "Create Organization",
3234
+ "organization.create.creating": "Creating...",
3235
+ "organization.create.cancel": "Cancel",
3236
+ /* |---------------------------------------------------------------| */
2457
3237
  /* | Messages | */
2458
3238
  /* |---------------------------------------------------------------| */
2459
3239
  "messages.loading": "Loading...",
@@ -2522,43 +3302,65 @@ var resolveFieldName = (field) => {
2522
3302
  );
2523
3303
  };
2524
3304
  var resolveFieldName_default = resolveFieldName;
3305
+
3306
+ // src/utils/withVendorCSSClassPrefix.ts
3307
+ var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;
3308
+ var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
2525
3309
  export {
2526
- ApplicationNativeAuthenticationAuthenticatorKnownIdPType,
2527
- ApplicationNativeAuthenticationAuthenticatorParamType,
2528
- ApplicationNativeAuthenticationAuthenticatorPromptType,
2529
3310
  ApplicationNativeAuthenticationConstants_default as ApplicationNativeAuthenticationConstants,
2530
- ApplicationNativeAuthenticationFlowStatus,
2531
- ApplicationNativeAuthenticationFlowType,
2532
- ApplicationNativeAuthenticationStepType,
2533
3311
  AsgardeoAPIError,
2534
3312
  AsgardeoAuthClient,
2535
3313
  AsgardeoAuthException,
2536
3314
  AsgardeoError,
2537
3315
  AsgardeoJavaScriptClient_default as AsgardeoJavaScriptClient,
2538
3316
  AsgardeoRuntimeError,
3317
+ EmbeddedFlowComponentType,
3318
+ EmbeddedFlowResponseType,
3319
+ EmbeddedFlowStatus,
3320
+ EmbeddedFlowType,
3321
+ EmbeddedSignInFlowAuthenticatorKnownIdPType,
3322
+ EmbeddedSignInFlowAuthenticatorParamType,
3323
+ EmbeddedSignInFlowAuthenticatorPromptType,
3324
+ EmbeddedSignInFlowStatus,
3325
+ EmbeddedSignInFlowStepType,
3326
+ EmbeddedSignInFlowType,
2539
3327
  FieldType,
3328
+ FlowMode,
2540
3329
  IsomorphicCrypto,
2541
3330
  OIDCRequestConstants_default as OIDCRequestConstants,
2542
3331
  StorageManager_default as StorageManager,
2543
3332
  TokenConstants_default as TokenConstants,
3333
+ VendorConstants_default as VendorConstants,
2544
3334
  WellKnownSchemaIds,
3335
+ createOrganization_default as createOrganization,
3336
+ createPatchOperations,
2545
3337
  createTheme_default as createTheme,
2546
3338
  deepMerge_default as deepMerge,
3339
+ executeEmbeddedSignInFlow_default as executeEmbeddedSignInFlow,
3340
+ executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow,
2547
3341
  extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
2548
3342
  extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
2549
3343
  flattenUserSchema_default as flattenUserSchema,
2550
3344
  generateFlattenedUserProfile_default as generateFlattenedUserProfile,
2551
3345
  generateUserProfile_default as generateUserProfile,
2552
3346
  get_default as get,
3347
+ getAllOrganizations_default as getAllOrganizations,
2553
3348
  getI18nBundles_default as getI18nBundles,
2554
3349
  getLatestStateParam_default as getLatestStateParam,
3350
+ getMeOrganizations_default as getMeOrganizations,
3351
+ getOrganization_default as getOrganization,
3352
+ getSchemas_default as getSchemas,
3353
+ getScim2Me_default as getScim2Me,
2555
3354
  getUserInfo_default as getUserInfo,
2556
- handleApplicationNativeAuthentication_default as handleApplicationNativeAuthentication,
2557
- initializeApplicationNativeAuthentication_default as initializeApplicationNativeAuthentication,
3355
+ initializeEmbeddedSignInFlow_default as initializeEmbeddedSignInFlow,
3356
+ isEmpty_default as isEmpty,
2558
3357
  processOpenIDScopes_default as processOpenIDScopes,
2559
3358
  removeTrailingSlash_default as removeTrailingSlash,
2560
3359
  resolveFieldName_default as resolveFieldName,
2561
3360
  resolveFieldType_default as resolveFieldType,
2562
- set_default as set
3361
+ set_default as set,
3362
+ updateMeProfile_default as updateMeProfile,
3363
+ updateOrganization_default as updateOrganization,
3364
+ withVendorCSSClassPrefix_default as withVendorCSSClassPrefix
2563
3365
  };
2564
3366
  //# sourceMappingURL=index.js.map