@descope/node-sdk 2.7.0 → 2.9.0

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.
package/dist/index.d.ts CHANGED
@@ -952,6 +952,35 @@ declare type OutboundApplication = {
952
952
  pkce?: boolean;
953
953
  accessType?: AccessType;
954
954
  prompt?: Array<PromptType>;
955
+ useDcr?: boolean;
956
+ dcrUrl?: string;
957
+ };
958
+ declare type OutboundAppTemplateOverrides = {
959
+ name?: string;
960
+ description?: string;
961
+ logo?: string;
962
+ discoveryUrl?: string;
963
+ authorizationUrl?: string;
964
+ authorizationUrlParams?: URLParam[];
965
+ tokenUrl?: string;
966
+ tokenUrlParams?: URLParam[];
967
+ revocationUrl?: string;
968
+ defaultScopes?: string[];
969
+ defaultRedirectUrl?: string;
970
+ callbackDomain?: string;
971
+ pkce?: boolean;
972
+ accessType?: AccessType;
973
+ prompt?: Array<PromptType>;
974
+ useDcr?: boolean;
975
+ dcrUrl?: string;
976
+ };
977
+ declare type CreateOutboundAppByTemplateOptions = {
978
+ templateId: string;
979
+ id?: string;
980
+ clientId?: string;
981
+ clientSecret?: string;
982
+ tenantId?: string;
983
+ overrides?: OutboundAppTemplateOverrides;
955
984
  };
956
985
  declare type URLParam = {
957
986
  key: string;
@@ -1291,7 +1320,7 @@ declare const nodeSdk: {
1291
1320
  searchAll: (ids?: string[], names?: string[], selfProvisioningDomains?: string[], customAttributes?: Record<string, AttributesTypes>, parentTenantId?: string) => Promise<SdkResponse<Tenant[]>>;
1292
1321
  getSettings: (tenantId: string) => Promise<SdkResponse<TenantSettings>>;
1293
1322
  configureSettings: (tenantId: string, settings: TenantSettings) => Promise<SdkResponse<never>>;
1294
- generateSSOConfigurationLink: (tenantId: string, expireDuration: number, ssoId?: string, email?: string, templateId?: string) => Promise<SdkResponse<GenerateSSOConfigurationLinkResponse>>;
1323
+ generateSSOConfigurationLink: (tenantId: string, expireDuration: number, ssoId?: string, email?: string, templateId?: string, actorId?: string) => Promise<SdkResponse<GenerateSSOConfigurationLinkResponse>>;
1295
1324
  };
1296
1325
  ssoApplication: {
1297
1326
  createOidcApplication: (options: OidcApplicationOptions) => Promise<SdkResponse<CreateSSOApplicationResponse>>;
@@ -1330,6 +1359,7 @@ declare const nodeSdk: {
1330
1359
  createApplication: (app: Omit<OutboundApplication, "id"> & Partial<Pick<OutboundApplication, "id">> & {
1331
1360
  clientSecret?: string;
1332
1361
  }) => Promise<SdkResponse<OutboundApplication>>;
1362
+ createApplicationByTemplate: (options: CreateOutboundAppByTemplateOptions) => Promise<SdkResponse<OutboundApplication>>;
1333
1363
  updateApplication: (app: OutboundApplication & {
1334
1364
  clientSecret?: string;
1335
1365
  }) => Promise<SdkResponse<OutboundApplication>>;
@@ -1538,6 +1568,7 @@ declare const nodeSdk: {
1538
1568
  templateOptions?: {
1539
1569
  [x: string]: string;
1540
1570
  };
1571
+ tenantId?: string;
1541
1572
  }) => Promise<SdkResponse<{
1542
1573
  maskedPhone: string;
1543
1574
  }>>;
@@ -1554,6 +1585,7 @@ declare const nodeSdk: {
1554
1585
  templateOptions?: {
1555
1586
  [x: string]: string;
1556
1587
  };
1588
+ tenantId?: string;
1557
1589
  }) => Promise<SdkResponse<{
1558
1590
  maskedPhone: string;
1559
1591
  }>>;
@@ -1570,6 +1602,7 @@ declare const nodeSdk: {
1570
1602
  templateOptions?: {
1571
1603
  [x: string]: string;
1572
1604
  };
1605
+ tenantId?: string;
1573
1606
  }) => Promise<SdkResponse<{
1574
1607
  maskedPhone: string;
1575
1608
  }>>;
@@ -1586,6 +1619,7 @@ declare const nodeSdk: {
1586
1619
  templateOptions?: {
1587
1620
  [x: string]: string;
1588
1621
  };
1622
+ tenantId?: string;
1589
1623
  }) => Promise<SdkResponse<{
1590
1624
  maskedPhone: string;
1591
1625
  }>>;
@@ -1602,6 +1636,7 @@ declare const nodeSdk: {
1602
1636
  templateOptions?: {
1603
1637
  [x: string]: string;
1604
1638
  };
1639
+ tenantId?: string;
1605
1640
  }) => Promise<SdkResponse<{
1606
1641
  maskedEmail: string;
1607
1642
  }>>;
@@ -1632,6 +1667,7 @@ declare const nodeSdk: {
1632
1667
  };
1633
1668
  templateId?: string;
1634
1669
  providerId?: string;
1670
+ mfa?: boolean;
1635
1671
  }) => Promise<SdkResponse<{
1636
1672
  maskedEmail: string;
1637
1673
  }>>;
@@ -1644,6 +1680,7 @@ declare const nodeSdk: {
1644
1680
  };
1645
1681
  templateId?: string;
1646
1682
  providerId?: string;
1683
+ mfa?: boolean;
1647
1684
  }) => Promise<SdkResponse<{
1648
1685
  maskedPhone: string;
1649
1686
  }>>;
@@ -1655,6 +1692,7 @@ declare const nodeSdk: {
1655
1692
  };
1656
1693
  templateId?: string;
1657
1694
  providerId?: string;
1695
+ mfa?: boolean;
1658
1696
  }) => Promise<SdkResponse<{
1659
1697
  maskedPhone: string;
1660
1698
  }>>;
@@ -1666,6 +1704,7 @@ declare const nodeSdk: {
1666
1704
  };
1667
1705
  templateId?: string;
1668
1706
  providerId?: string;
1707
+ mfa?: boolean;
1669
1708
  }) => Promise<SdkResponse<{
1670
1709
  maskedPhone: string;
1671
1710
  }>>;
@@ -1677,6 +1716,7 @@ declare const nodeSdk: {
1677
1716
  };
1678
1717
  templateId?: string;
1679
1718
  providerId?: string;
1719
+ mfa?: boolean;
1680
1720
  }) => Promise<SdkResponse<{
1681
1721
  maskedPhone: string;
1682
1722
  }>>;
@@ -1719,6 +1759,7 @@ declare const nodeSdk: {
1719
1759
  templateOptions?: {
1720
1760
  [x: string]: string;
1721
1761
  };
1762
+ tenantId?: string;
1722
1763
  }) => Promise<SdkResponse<{
1723
1764
  maskedPhone: string;
1724
1765
  }>>;
@@ -1735,6 +1776,7 @@ declare const nodeSdk: {
1735
1776
  templateOptions?: {
1736
1777
  [x: string]: string;
1737
1778
  };
1779
+ tenantId?: string;
1738
1780
  }) => Promise<SdkResponse<{
1739
1781
  maskedPhone: string;
1740
1782
  }>>;
@@ -1751,6 +1793,7 @@ declare const nodeSdk: {
1751
1793
  templateOptions?: {
1752
1794
  [x: string]: string;
1753
1795
  };
1796
+ tenantId?: string;
1754
1797
  }) => Promise<SdkResponse<{
1755
1798
  maskedPhone: string;
1756
1799
  }>>;
@@ -1767,6 +1810,7 @@ declare const nodeSdk: {
1767
1810
  templateOptions?: {
1768
1811
  [x: string]: string;
1769
1812
  };
1813
+ tenantId?: string;
1770
1814
  }) => Promise<SdkResponse<{
1771
1815
  maskedPhone: string;
1772
1816
  }>>;
@@ -1783,6 +1827,7 @@ declare const nodeSdk: {
1783
1827
  templateOptions?: {
1784
1828
  [x: string]: string;
1785
1829
  };
1830
+ tenantId?: string;
1786
1831
  }) => Promise<SdkResponse<{
1787
1832
  maskedEmail: string;
1788
1833
  }>>;
@@ -1794,6 +1839,7 @@ declare const nodeSdk: {
1794
1839
  templateOptions?: {
1795
1840
  [x: string]: string;
1796
1841
  };
1842
+ tenantId?: string;
1797
1843
  }) => Promise<SdkResponse<{
1798
1844
  maskedPhone: string;
1799
1845
  }>>;
@@ -1803,6 +1849,7 @@ declare const nodeSdk: {
1803
1849
  templateOptions?: {
1804
1850
  [x: string]: string;
1805
1851
  };
1852
+ tenantId?: string;
1806
1853
  }) => Promise<SdkResponse<{
1807
1854
  maskedPhone: string;
1808
1855
  }>>;
@@ -1812,6 +1859,7 @@ declare const nodeSdk: {
1812
1859
  templateOptions?: {
1813
1860
  [x: string]: string;
1814
1861
  };
1862
+ tenantId?: string;
1815
1863
  }) => Promise<SdkResponse<{
1816
1864
  maskedPhone: string;
1817
1865
  }>>;
@@ -1821,6 +1869,7 @@ declare const nodeSdk: {
1821
1869
  templateOptions?: {
1822
1870
  [x: string]: string;
1823
1871
  };
1872
+ tenantId?: string;
1824
1873
  }) => Promise<SdkResponse<{
1825
1874
  maskedPhone: string;
1826
1875
  }>>;
@@ -1830,6 +1879,7 @@ declare const nodeSdk: {
1830
1879
  templateOptions?: {
1831
1880
  [x: string]: string;
1832
1881
  };
1882
+ tenantId?: string;
1833
1883
  }) => Promise<SdkResponse<{
1834
1884
  maskedEmail: string;
1835
1885
  }>>;
@@ -1843,6 +1893,7 @@ declare const nodeSdk: {
1843
1893
  };
1844
1894
  templateId?: string;
1845
1895
  providerId?: string;
1896
+ mfa?: boolean;
1846
1897
  }) => Promise<SdkResponse<{
1847
1898
  maskedEmail: string;
1848
1899
  }>>;
@@ -1855,6 +1906,7 @@ declare const nodeSdk: {
1855
1906
  };
1856
1907
  templateId?: string;
1857
1908
  providerId?: string;
1909
+ mfa?: boolean;
1858
1910
  }) => Promise<SdkResponse<{
1859
1911
  maskedPhone: string;
1860
1912
  }>>;
@@ -1866,6 +1918,7 @@ declare const nodeSdk: {
1866
1918
  };
1867
1919
  templateId?: string;
1868
1920
  providerId?: string;
1921
+ mfa?: boolean;
1869
1922
  }) => Promise<SdkResponse<{
1870
1923
  maskedPhone: string;
1871
1924
  }>>;
@@ -1877,6 +1930,7 @@ declare const nodeSdk: {
1877
1930
  };
1878
1931
  templateId?: string;
1879
1932
  providerId?: string;
1933
+ mfa?: boolean;
1880
1934
  }) => Promise<SdkResponse<{
1881
1935
  maskedPhone: string;
1882
1936
  }>>;
@@ -1888,6 +1942,7 @@ declare const nodeSdk: {
1888
1942
  };
1889
1943
  templateId?: string;
1890
1944
  providerId?: string;
1945
+ mfa?: boolean;
1891
1946
  }) => Promise<SdkResponse<{
1892
1947
  maskedPhone: string;
1893
1948
  }>>;
@@ -1908,6 +1963,7 @@ declare const nodeSdk: {
1908
1963
  templateOptions?: {
1909
1964
  [x: string]: string;
1910
1965
  };
1966
+ tenantId?: string;
1911
1967
  } & {
1912
1968
  providerId?: string;
1913
1969
  }) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
@@ -1924,6 +1980,7 @@ declare const nodeSdk: {
1924
1980
  templateOptions?: {
1925
1981
  [x: string]: string;
1926
1982
  };
1983
+ tenantId?: string;
1927
1984
  } & {
1928
1985
  providerId?: string;
1929
1986
  }) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse & {
@@ -1946,6 +2003,7 @@ declare const nodeSdk: {
1946
2003
  };
1947
2004
  templateId?: string;
1948
2005
  providerId?: string;
2006
+ mfa?: boolean;
1949
2007
  }) => Promise<SdkResponse<_descope_core_js_sdk.EnchantedLinkResponse>>;
1950
2008
  };
1951
2009
  };
@@ -2016,6 +2074,7 @@ declare const nodeSdk: {
2016
2074
  templateOptions?: {
2017
2075
  [x: string]: string;
2018
2076
  };
2077
+ tenantId?: string;
2019
2078
  } & {
2020
2079
  providerId?: string;
2021
2080
  }) => Promise<SdkResponse<{
@@ -2036,6 +2095,7 @@ declare const nodeSdk: {
2036
2095
  templateOptions?: {
2037
2096
  [x: string]: string;
2038
2097
  };
2098
+ tenantId?: string;
2039
2099
  } & {
2040
2100
  providerId?: string;
2041
2101
  }) => Promise<SdkResponse<{
@@ -2060,7 +2120,7 @@ declare const nodeSdk: {
2060
2120
  };
2061
2121
  webauthn: {
2062
2122
  signUp: {
2063
- start: (loginId: string, origin: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<SdkResponse<{
2123
+ start: (loginId: string, origin: string, name: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions, loginOptions?: _descope_core_js_sdk.LoginOptions) => Promise<SdkResponse<{
2064
2124
  transactionId: string;
2065
2125
  options: string;
2066
2126
  create: boolean;
@@ -2082,7 +2142,7 @@ declare const nodeSdk: {
2082
2142
  }>>;
2083
2143
  };
2084
2144
  signUpOrIn: {
2085
- start: (loginId: string, origin: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions) => Promise<SdkResponse<{
2145
+ start: (loginId: string, origin: string, passkeyOptions?: _descope_core_js_sdk.PasskeyOptions, loginOptions?: _descope_core_js_sdk.LoginOptions) => Promise<SdkResponse<{
2086
2146
  transactionId: string;
2087
2147
  options: string;
2088
2148
  create: boolean;
@@ -2111,6 +2171,7 @@ declare const nodeSdk: {
2111
2171
  templateOptions?: {
2112
2172
  [x: string]: string;
2113
2173
  };
2174
+ tenantId?: string;
2114
2175
  } & {
2115
2176
  providerId?: string;
2116
2177
  }) => Promise<SdkResponse<JWTResponse & {
@@ -2165,8 +2226,10 @@ declare const nodeSdk: {
2165
2226
  oidcIdpStateId?: string;
2166
2227
  preview?: boolean;
2167
2228
  samlIdpStateId?: string;
2229
+ wsfedIdpStateId?: string;
2168
2230
  samlIdpUsername?: string;
2169
2231
  ssoAppId?: string;
2232
+ customAppId?: string;
2170
2233
  thirdPartyAppId?: string;
2171
2234
  oidcLoginHint?: string;
2172
2235
  abTestingKey?: number;
@@ -2180,6 +2243,7 @@ declare const nodeSdk: {
2180
2243
  platform: "ios" | "android";
2181
2244
  oauthProvider?: string;
2182
2245
  oauthRedirect?: string;
2246
+ externalAuthRedirect?: string;
2183
2247
  };
2184
2248
  thirdPartyAppStateId?: string;
2185
2249
  applicationScopes?: string;
@@ -2244,4 +2308,4 @@ declare const nodeSdk: {
2244
2308
  };
2245
2309
  };
2246
2310
 
2247
- export { AccessKey, AccessType, AssociatedTenant, AttributeMapping, AttributesTypes, AuditCreateOptions, AuditRecord, AuditSearchOptions, AuditType, AuthenticationInfo, AuthzModified, AuthzNamespace, AuthzNode, AuthzNodeExpression, AuthzNodeExpressionType, AuthzNodeType, AuthzRelation, AuthzRelationDefinition, AuthzRelationQuery, AuthzResource, AuthzSchema, AuthzUserQuery, CheckResponseRelation, ClientAssertionResponse, CloneProjectResponse, CreateInboundApplicationResponse, CreateOrInviteBatchResponse, CreateSSOApplicationResponse, CreateTenantResponse, CreatedAccessKeyResponse, Descoper, DescoperAttributes, DescoperCreate, DescoperProjectRole, DescoperRBAC, DescoperRole, DescoperTagRole, ExpirationUnit, ExportSnapshotResponse, FGAConfig, FGARelation, FGAResourceDetails, FGAResourceIdentifier, FGASchema, FetchLatestOutboundAppTenantTokenRequest, FetchLatestOutboundAppUserTokenRequest, FetchOutboundAppTenantTokenRequest, FetchOutboundAppTokenOptions, FetchOutboundAppUserTokenRequest, Flow, FlowMetadata, FlowResponse, FlowsResponse, GenerateEmbeddedLinkResponse, GenerateEnchantedLinkForTestResponse, GenerateMagicLinkForTestResponse, GenerateOTPForTestResponse, GenerateSSOConfigurationLinkResponse, Group, GroupMember, GroupsMapping, IDPResponse, ImportSnapshotRequest, InboundApplication, InboundApplicationConsent, InboundApplicationConsentDeleteOptions, InboundApplicationConsentSearchOptions, InboundApplicationOptions, InboundApplicationScope, InboundApplicationSecretResponse, License, ManagementFlowOptions, MgmtKey, MgmtKeyCreateResponse, MgmtKeyProjectRole, MgmtKeyReBac, MgmtKeyStatus, MgmtKeyTagRole, MgmtLoginOptions, MgmtSignUpOptions, MgmtUserOptions, OIDCAttributeMapping, OIDCRoleMapping, OidcApplicationOptions, OutboundAppToken, OutboundAppTokenResponse, OutboundApplication, PasswordSettings, PatchUserBatchResponse, PatchUserOptions, Permission, Project, ProjectEnvironment, Prompt, PromptType, ProviderTokenOptions, ProviderTokenResponse, RefreshAuthenticationInfo, Role, RoleItem, RoleMapping, RoleMappings, RoleSearchOptions, RunManagementFlowResponse, SAMLIDPRoleGroupMappingInfo, SSOApplication, SSOApplicationOIDCSettings, SSOApplicationSAMLSettings, SSOApplicationWSFedSettings, SSOOIDCSettings, SSOSAMLByMetadataSettings, SSOSAMLSettings, SSOSAMLSettingsResponse, SSOSettings, SSOSettingsResponse, SSOSetupSuiteSettings, SSOSetupSuiteSettingsDisabledFeatures, SamlApplicationOptions, SamlIdpAttributeMappingInfo, SamlIdpGroupsMappingInfo, Screen, SnapshotSecret, SnapshotSecrets, TemplateOptions, Tenant, TenantSettings, Theme, ThemeResponse, URLParam, UpdateJWTResponse, User, UserFailedResponse, UserMapping, UserOptions, UserPasswordBcrypt, UserPasswordDjango, UserPasswordFirebase, UserPasswordHashed, UserPasswordMd5, UserPasswordPbkdf2, UserPasswordPhpass, UserSearchResponse, UserStatus, ValidateSnapshotRequest, ValidateSnapshotResponse, VerifyOptions, WsFedApplicationOptions, nodeSdk as default };
2311
+ export { AccessKey, AccessType, AssociatedTenant, AttributeMapping, AttributesTypes, AuditCreateOptions, AuditRecord, AuditSearchOptions, AuditType, AuthenticationInfo, AuthzModified, AuthzNamespace, AuthzNode, AuthzNodeExpression, AuthzNodeExpressionType, AuthzNodeType, AuthzRelation, AuthzRelationDefinition, AuthzRelationQuery, AuthzResource, AuthzSchema, AuthzUserQuery, CheckResponseRelation, ClientAssertionResponse, CloneProjectResponse, CreateInboundApplicationResponse, CreateOrInviteBatchResponse, CreateOutboundAppByTemplateOptions, CreateSSOApplicationResponse, CreateTenantResponse, CreatedAccessKeyResponse, Descoper, DescoperAttributes, DescoperCreate, DescoperProjectRole, DescoperRBAC, DescoperRole, DescoperTagRole, ExpirationUnit, ExportSnapshotResponse, FGAConfig, FGARelation, FGAResourceDetails, FGAResourceIdentifier, FGASchema, FetchLatestOutboundAppTenantTokenRequest, FetchLatestOutboundAppUserTokenRequest, FetchOutboundAppTenantTokenRequest, FetchOutboundAppTokenOptions, FetchOutboundAppUserTokenRequest, Flow, FlowMetadata, FlowResponse, FlowsResponse, GenerateEmbeddedLinkResponse, GenerateEnchantedLinkForTestResponse, GenerateMagicLinkForTestResponse, GenerateOTPForTestResponse, GenerateSSOConfigurationLinkResponse, Group, GroupMember, GroupsMapping, IDPResponse, ImportSnapshotRequest, InboundApplication, InboundApplicationConsent, InboundApplicationConsentDeleteOptions, InboundApplicationConsentSearchOptions, InboundApplicationOptions, InboundApplicationScope, InboundApplicationSecretResponse, License, ManagementFlowOptions, MgmtKey, MgmtKeyCreateResponse, MgmtKeyProjectRole, MgmtKeyReBac, MgmtKeyStatus, MgmtKeyTagRole, MgmtLoginOptions, MgmtSignUpOptions, MgmtUserOptions, OIDCAttributeMapping, OIDCRoleMapping, OidcApplicationOptions, OutboundAppTemplateOverrides, OutboundAppToken, OutboundAppTokenResponse, OutboundApplication, PasswordSettings, PatchUserBatchResponse, PatchUserOptions, Permission, Project, ProjectEnvironment, Prompt, PromptType, ProviderTokenOptions, ProviderTokenResponse, RefreshAuthenticationInfo, Role, RoleItem, RoleMapping, RoleMappings, RoleSearchOptions, RunManagementFlowResponse, SAMLIDPRoleGroupMappingInfo, SSOApplication, SSOApplicationOIDCSettings, SSOApplicationSAMLSettings, SSOApplicationWSFedSettings, SSOOIDCSettings, SSOSAMLByMetadataSettings, SSOSAMLSettings, SSOSAMLSettingsResponse, SSOSettings, SSOSettingsResponse, SSOSetupSuiteSettings, SSOSetupSuiteSettingsDisabledFeatures, SamlApplicationOptions, SamlIdpAttributeMappingInfo, SamlIdpGroupsMappingInfo, Screen, SnapshotSecret, SnapshotSecrets, TemplateOptions, Tenant, TenantSettings, Theme, ThemeResponse, URLParam, UpdateJWTResponse, User, UserFailedResponse, UserMapping, UserOptions, UserPasswordBcrypt, UserPasswordDjango, UserPasswordFirebase, UserPasswordHashed, UserPasswordMd5, UserPasswordPbkdf2, UserPasswordPhpass, UserSearchResponse, UserStatus, ValidateSnapshotRequest, ValidateSnapshotResponse, VerifyOptions, WsFedApplicationOptions, nodeSdk as default };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"tslib";import t,{transformResponse as s,createHttpClient as a,wrapWith as o}from"@descope/core-js-sdk";import{jwtVerify as r,errors as n,importJWK as i}from"jose";import{Headers as d,fetch as l}from"cross-fetch";var p;null!==(p=globalThis.Headers)&&void 0!==p||(globalThis.Headers=d);const m=(...e)=>(e.forEach((e=>{var t,s;e&&"object"==typeof e&&(null!==(t=(s=e).highWaterMark)&&void 0!==t||(s.highWaterMark=31457280))})),l(...e)),c=(e,t)=>{const s=null==e?void 0:e.match(RegExp(`(?:^|[;,]\\s*)${t}=([^;]*)`));return s?s[1]:null};const u=t=>async(...s)=>{var a,o,r;const n=await t(...s);if(!n.data)return n;let i=n.data,{refreshJwt:d}=i,l=e(i,["refreshJwt"]);const p=[];var m;return d?p.push(`${"DSR"}=${d}; Domain=${(null==(m=l)?void 0:m.cookieDomain)||""}; Max-Age=${(null==m?void 0:m.cookieMaxAge)||""}; Path=${(null==m?void 0:m.cookiePath)||"/"}; HttpOnly; SameSite=Strict`):(null===(a=n.response)||void 0===a?void 0:a.headers.get("set-cookie"))&&(d=c(null===(o=n.response)||void 0===o?void 0:o.headers.get("set-cookie"),"DSR"),p.push(null===(r=n.response)||void 0===r?void 0:r.headers.get("set-cookie"))),Object.assign(Object.assign({},n),{data:Object.assign(Object.assign({},n.data),{refreshJwt:d,cookies:p})})};function g(e,t,s){var a,o;const r=s?null===(o=null===(a=e.token.tenants)||void 0===a?void 0:a[s])||void 0===o?void 0:o[t]:e.token[t];return Array.isArray(r)?r:[]}function v(e,t){var s;return!!(null===(s=e.token.tenants)||void 0===s?void 0:s[t])}var h={create:"/v1/mgmt/user/create",createTestUser:"/v1/mgmt/user/create/test",createBatch:"/v1/mgmt/user/create/batch",update:"/v1/mgmt/user/update",patch:"/v1/mgmt/user/patch",patchBatch:"/v1/mgmt/user/patch/batch",delete:"/v1/mgmt/user/delete",deleteBatch:"/v1/mgmt/user/delete/batch",deleteAllTestUsers:"/v1/mgmt/user/test/delete/all",load:"/v1/mgmt/user",logout:"/v1/mgmt/user/logout",loadUsers:"/v1/mgmt/users/load",search:"/v2/mgmt/user/search",searchTestUsers:"/v2/mgmt/user/search/test",getProviderToken:"/v1/mgmt/user/provider/token",updateStatus:"/v1/mgmt/user/update/status",updateLoginId:"/v1/mgmt/user/update/loginid",updateEmail:"/v1/mgmt/user/update/email",updatePhone:"/v1/mgmt/user/update/phone",updateDisplayName:"/v1/mgmt/user/update/name",updatePicture:"/v1/mgmt/user/update/picture",updateCustomAttribute:"/v1/mgmt/user/update/customAttribute",setRole:"/v1/mgmt/user/update/role/set",addRole:"/v2/mgmt/user/update/role/add",removeRole:"/v1/mgmt/user/update/role/remove",setSSOApps:"/v1/mgmt/user/update/ssoapp/set",addSSOApps:"/v1/mgmt/user/update/ssoapp/add",removeSSOApps:"/v1/mgmt/user/update/ssoapp/remove",addTenant:"/v1/mgmt/user/update/tenant/add",removeTenant:"/v1/mgmt/user/update/tenant/remove",setPassword:"/v1/mgmt/user/password/set",setTemporaryPassword:"/v1/mgmt/user/password/set/temporary",setActivePassword:"/v1/mgmt/user/password/set/active",expirePassword:"/v1/mgmt/user/password/expire",removeAllPasskeys:"/v1/mgmt/user/passkeys/delete",removeTOTPSeed:"/v1/mgmt/user/totp/delete",generateOTPForTest:"/v1/mgmt/tests/generate/otp",generateMagicLinkForTest:"/v1/mgmt/tests/generate/magiclink",generateEnchantedLinkForTest:"/v1/mgmt/tests/generate/enchantedlink",generateEmbeddedLink:"/v1/mgmt/user/signin/embeddedlink",generateSignUpEmbeddedLink:"/v1/mgmt/user/signup/embeddedlink",history:"/v1/mgmt/user/history"},f={updateName:"/v1/mgmt/project/update/name",updateTags:"/v1/mgmt/project/update/tags",clone:"/v1/mgmt/project/clone",projectsList:"/v1/mgmt/projects/list",exportSnapshot:"/v1/mgmt/project/snapshot/export",importSnapshot:"/v1/mgmt/project/snapshot/import",validateSnapshot:"/v1/mgmt/project/snapshot/validate"},I={create:"/v1/mgmt/accesskey/create",load:"/v1/mgmt/accesskey",search:"/v1/mgmt/accesskey/search",update:"/v1/mgmt/accesskey/update",deactivate:"/v1/mgmt/accesskey/deactivate",activate:"/v1/mgmt/accesskey/activate",delete:"/v1/mgmt/accesskey/delete"},y={create:"/v1/mgmt/tenant/create",update:"/v1/mgmt/tenant/update",delete:"/v1/mgmt/tenant/delete",load:"/v1/mgmt/tenant",settings:"/v1/mgmt/tenant/settings",loadAll:"/v1/mgmt/tenant/all",searchAll:"/v1/mgmt/tenant/search",updateDefaultRoles:"/v1/mgmt/tenant/updateDefaultRoles",generateSSOConfigurationLink:"/v2/mgmt/tenant/adminlinks/sso/generate"},b={oidcCreate:"/v1/mgmt/sso/idp/app/oidc/create",samlCreate:"/v1/mgmt/sso/idp/app/saml/create",oidcUpdate:"/v1/mgmt/sso/idp/app/oidc/update",samlUpdate:"/v1/mgmt/sso/idp/app/saml/update",wsfedCreate:"/v1/mgmt/sso/idp/app/wsfed/create",wsfedUpdate:"/v1/mgmt/sso/idp/app/wsfed/update",delete:"/v1/mgmt/sso/idp/app/delete",load:"/v1/mgmt/sso/idp/app/load",loadAll:"/v1/mgmt/sso/idp/apps/load"},k={create:"/v1/mgmt/thirdparty/app/create",update:"/v1/mgmt/thirdparty/app/update",patch:"/v1/mgmt/thirdparty/app/patch",delete:"/v1/mgmt/thirdparty/app/delete",load:"/v1/mgmt/thirdparty/app/load",loadAll:"/v1/mgmt/thirdparty/apps/load",secret:"/v1/mgmt/thirdparty/app/secret",rotate:"/v1/mgmt/thirdparty/app/rotate"},O={delete:"/v1/mgmt/thirdparty/consents/delete",search:"/v1/mgmt/thirdparty/consents/search"},A={create:"/v1/mgmt/outbound/app/create",update:"/v1/mgmt/outbound/app/update",delete:"/v1/mgmt/outbound/app/delete",load:"/v1/mgmt/outbound/app",loadAll:"/v1/mgmt/outbound/apps",fetchToken:"/v1/mgmt/outbound/app/user/token/latest",fetchTokenByScopes:"/v1/mgmt/outbound/app/user/token",fetchTenantToken:"/v1/mgmt/outbound/app/tenant/token/latest",fetchTenantTokenByScopes:"/v1/mgmt/outbound/app/tenant/token",deleteUserTokens:"/v1/mgmt/outbound/user/tokens",deleteTokenById:"/v1/mgmt/outbound/token"},w={settings:"/v1/mgmt/sso/settings",settingsNew:"/v1/mgmt/sso/settings/new",metadata:"/v1/mgmt/sso/metadata",mapping:"/v1/mgmt/sso/mapping",settingsv2:"/v2/mgmt/sso/settings",settingsAllV2:"/v2/mgmt/sso/settings/all",oidc:{configure:"/v1/mgmt/sso/oidc"},saml:{configure:"/v1/mgmt/sso/saml",metadata:"/v1/mgmt/sso/saml/metadata"}},T={update:"/v1/mgmt/jwt/update",impersonate:"/v1/mgmt/impersonate",stopImpersonation:"/v1/mgmt/stop/impersonation",signIn:"/v1/mgmt/auth/signin",signUp:"/v1/mgmt/auth/signup",signUpOrIn:"/v1/mgmt/auth/signup-in",anonymous:"/v1/mgmt/auth/anonymous",clientAssertion:"/v1/mgmt/token/clientassertion"},S={settings:"/v1/mgmt/password/settings"},j={create:"/v1/mgmt/permission/create",update:"/v1/mgmt/permission/update",delete:"/v1/mgmt/permission/delete",loadAll:"/v1/mgmt/permission/all"},N={create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update",delete:"/v1/mgmt/role/delete",loadAll:"/v1/mgmt/role/all",search:"/v1/mgmt/role/search"},R={list:"/v1/mgmt/flow/list",delete:"/v1/mgmt/flow/delete",export:"/v1/mgmt/flow/export",import:"/v1/mgmt/flow/import",run:"/v1/mgmt/flow/run"},P={export:"/v1/mgmt/theme/export",import:"/v1/mgmt/theme/import"},U={loadAllGroups:"/v1/mgmt/group/all",loadAllGroupsForMember:"/v1/mgmt/group/member/all",loadAllGroupMembers:"/v1/mgmt/group/members"},E={search:"/v1/mgmt/audit/search",createEvent:"/v1/mgmt/audit/event"},x={schemaSave:"/v1/mgmt/authz/schema/save",schemaDelete:"/v1/mgmt/authz/schema/delete",schemaLoad:"/v1/mgmt/authz/schema/load",nsSave:"/v1/mgmt/authz/ns/save",nsDelete:"/v1/mgmt/authz/ns/delete",rdSave:"/v1/mgmt/authz/rd/save",rdDelete:"/v1/mgmt/authz/rd/delete",reCreate:"/v1/mgmt/authz/re/create",reDelete:"/v1/mgmt/authz/re/delete",reDeleteResources:"/v1/mgmt/authz/re/deleteresources",reDeleteResourceRelationsForResources:"/v1/mgmt/authz/re/deleteresourcesrelations",hasRelations:"/v1/mgmt/authz/re/has",who:"/v1/mgmt/authz/re/who",resource:"/v1/mgmt/authz/re/resource",targets:"/v1/mgmt/authz/re/targets",targetAll:"/v1/mgmt/authz/re/targetall",targetWithRelation:"/v1/mgmt/authz/re/targetwithrelation",getModified:"/v1/mgmt/authz/getmodified"},M={schema:"/v1/mgmt/fga/schema",relations:"/v1/mgmt/fga/relations",deleteRelations:"/v1/mgmt/fga/relations/delete",check:"/v1/mgmt/fga/check",resourcesLoad:"/v1/mgmt/fga/resources/load",resourcesSave:"/v1/mgmt/fga/resources/save"},C={create:"/v1/mgmt/descoper",update:"/v1/mgmt/descoper",get:"/v1/mgmt/descoper",delete:"/v1/mgmt/descoper",list:"/v1/mgmt/descoper/list"},D={create:"/v1/mgmt/managementkey",update:"/v1/mgmt/managementkey",load:"/v1/mgmt/managementkey",delete:"/v1/mgmt/managementkey/delete",search:"/v1/mgmt/managementkey/search"},L={get:"/v1/mgmt/license"};function F(t){return t.map((t=>{var{loginIdOrUserId:s,loginId:a,roles:o}=t,r=e(t,["loginIdOrUserId","loginId","roles"]);return Object.assign(Object.assign({},r),{loginId:null!=s?s:a,roleNames:o})}))}const B=e=>{function t(e,t){const s={loginId:e};return void 0!==t.email&&(s.email=t.email),void 0!==t.phone&&(s.phone=t.phone),void 0!==t.displayName&&(s.displayName=t.displayName),void 0!==t.givenName&&(s.givenName=t.givenName),void 0!==t.middleName&&(s.middleName=t.middleName),void 0!==t.familyName&&(s.familyName=t.familyName),void 0!==t.roles&&(s.roleNames=t.roles),void 0!==t.userTenants&&(s.userTenants=t.userTenants),void 0!==t.customAttributes&&(s.customAttributes=t.customAttributes),void 0!==t.picture&&(s.picture=t.picture),void 0!==t.verifiedEmail&&(s.verifiedEmail=t.verifiedEmail),void 0!==t.verifiedPhone&&(s.verifiedPhone=t.verifiedPhone),void 0!==t.ssoAppIds&&(s.ssoAppIds=t.ssoAppIds),void 0!==t.scim&&(s.scim=t.scim),void 0!==t.status&&(s.status=t.status),void 0!==t.additionalIdentifiers&&(s.additionalIdentifiers=t.additionalIdentifiers),s}return{create:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v){const f="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:c,middleName:u,familyName:g,roleNames:n,userTenants:i,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,additionalLoginIds:v}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0});return s(e.post(h.create,f),(e=>e.user))},createTestUser:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v){const f="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:c,middleName:u,familyName:g,roleNames:n,userTenants:i,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,additionalLoginIds:v,test:!0}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0,test:!0});return s(e.post(h.createTestUser,f),(e=>e.user))},invite:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v,f,I,y,b,k){const O="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:v,middleName:f,familyName:I,roleNames:n,userTenants:i,invite:!0,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,inviteUrl:c,sendMail:u,sendSMS:g,additionalLoginIds:y,templateId:b,locale:k}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0,invite:!0});return s(e.post(h.create,O),(e=>e.user))},inviteBatch:(t,a,o,r,n,i,d)=>s(e.post(h.createBatch,{users:F(t),invite:!0,inviteUrl:a,sendMail:o,sendSMS:r,templateOptions:n,templateId:i,locale:d}),(e=>e)),createBatch:t=>s(e.post(h.createBatch,{users:F(t)}),(e=>e)),deleteBatch:t=>s(e.post(h.deleteBatch,{userIds:t})),update:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v){const f="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:c,middleName:u,familyName:g,roleNames:n,userTenants:i,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,additionalLoginIds:v}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0});return s(e.post(h.update,f),(e=>e.user))},patch:function(a,o){const r=t(a,o);return s(e.patch(h.patch,r),(e=>e.user))},patchBatch:function(a){if(a.find((e=>!e.loginIdOrUserId&&!e.loginId)))return Promise.reject(new Error("patchBatch: each user must have loginIdOrUserId or loginId"));const o={users:a.map((e=>{var s;return t(null!==(s=e.loginIdOrUserId)&&void 0!==s?s:e.loginId,e)}))};return s(e.patch(h.patchBatch,o),(e=>e))},delete:t=>s(e.post(h.delete,{loginId:t})),deleteByUserId:t=>s(e.post(h.delete,{userId:t})),deleteAllTestUsers:()=>s(e.delete(h.deleteAllTestUsers)),load:t=>s(e.get(h.load,{queryParams:{loginId:t}}),(e=>e.user)),loadByUserId:t=>s(e.get(h.load,{queryParams:{userId:t}}),(e=>e.user)),logoutUser:t=>s(e.post(h.logout,{loginId:t})),logoutUserByUserId:t=>s(e.post(h.logout,{userId:t})),loadUsers:(t,a)=>s(e.post(h.loadUsers,{userIds:t,includeInvalidUsers:a}),(e=>e.users)),searchAll:(t,a,o,r,n,i,d,l,p,m)=>s(e.post(h.search,{tenantIds:t,roleNames:a,limit:o,page:r,testUsersOnly:n,withTestUser:i,customAttributes:d,statuses:l,emails:p,phones:m}),(e=>e.users)),searchTestUsers:t=>s(e.post(h.searchTestUsers,Object.assign(Object.assign({},t),{withTestUser:!0,testUsersOnly:!0,roleNames:t.roles,roles:void 0})),(e=>({users:e.users,total:e.total}))),search:t=>s(e.post(h.search,Object.assign(Object.assign({},t),{roleNames:t.roles,roles:void 0})),(e=>({users:e.users,total:e.total}))),getProviderToken:(t,a,o)=>s(e.get(h.getProviderToken,{queryParams:{loginId:t,provider:a,withRefreshToken:(null==o?void 0:o.withRefreshToken)?"true":"false",forceRefresh:(null==o?void 0:o.forceRefresh)?"true":"false"}}),(e=>e)),activate:t=>s(e.post(h.updateStatus,{loginId:t,status:"enabled"}),(e=>e.user)),deactivate:t=>s(e.post(h.updateStatus,{loginId:t,status:"disabled"}),(e=>e.user)),updateLoginId:(t,a)=>s(e.post(h.updateLoginId,{loginId:t,newLoginId:a}),(e=>e.user)),updateEmail:(t,a,o,r)=>s(e.post(h.updateEmail,{loginId:t,email:a,verified:o,failOnConflict:r}),(e=>e.user)),updatePhone:(t,a,o,r)=>s(e.post(h.updatePhone,{loginId:t,phone:a,verified:o,failOnConflict:r}),(e=>e.user)),updateDisplayName:(t,a,o,r,n)=>s(e.post(h.updateDisplayName,{loginId:t,displayName:a,givenName:o,middleName:r,familyName:n}),(e=>e.user)),updatePicture:(t,a)=>s(e.post(h.updatePicture,{loginId:t,picture:a}),(e=>e.user)),updateCustomAttribute:(t,a,o)=>s(e.post(h.updateCustomAttribute,{loginId:t,attributeKey:a,attributeValue:o}),(e=>e.user)),setRoles:(t,a)=>s(e.post(h.setRole,{loginId:t,roleNames:a}),(e=>e.user)),addRoles:(t,a)=>s(e.post(h.addRole,{loginId:t,roleNames:a}),(e=>e.user)),removeRoles:(t,a)=>s(e.post(h.removeRole,{loginId:t,roleNames:a}),(e=>e.user)),addTenant:(t,a)=>s(e.post(h.addTenant,{loginId:t,tenantId:a}),(e=>e.user)),removeTenant:(t,a)=>s(e.post(h.removeTenant,{loginId:t,tenantId:a}),(e=>e.user)),setTenantRoles:(t,a,o)=>s(e.post(h.setRole,{loginId:t,tenantId:a,roleNames:o}),(e=>e.user)),addTenantRoles:(t,a,o)=>s(e.post(h.addRole,{loginId:t,tenantId:a,roleNames:o}),(e=>e.user)),removeTenantRoles:(t,a,o)=>s(e.post(h.removeRole,{loginId:t,tenantId:a,roleNames:o}),(e=>e.user)),addSSOapps:(t,a)=>s(e.post(h.addSSOApps,{loginId:t,ssoAppIds:a}),(e=>e.user)),setSSOapps:(t,a)=>s(e.post(h.setSSOApps,{loginId:t,ssoAppIds:a}),(e=>e.user)),removeSSOapps:(t,a)=>s(e.post(h.removeSSOApps,{loginId:t,ssoAppIds:a}),(e=>e.user)),generateOTPForTestUser:(t,a,o)=>s(e.post(h.generateOTPForTest,{deliveryMethod:t,loginId:a,loginOptions:o}),(e=>e)),generateMagicLinkForTestUser:(t,a,o,r)=>s(e.post(h.generateMagicLinkForTest,{deliveryMethod:t,loginId:a,URI:o,loginOptions:r}),(e=>e)),generateEnchantedLinkForTestUser:(t,a,o)=>s(e.post(h.generateEnchantedLinkForTest,{loginId:t,URI:a,loginOptions:o}),(e=>e)),generateEmbeddedLink:(t,a,o)=>s(e.post(h.generateEmbeddedLink,{loginId:t,customClaims:a,timeout:o}),(e=>e)),generateSignUpEmbeddedLink:(t,a,o,r,n,i)=>s(e.post(h.generateSignUpEmbeddedLink,{loginId:t,user:a,emailVerified:o,phoneVerified:r,loginOptions:n,timeout:i}),(e=>e)),setTemporaryPassword:(t,a)=>s(e.post(h.setTemporaryPassword,{loginId:t,password:a}),(e=>e)),setActivePassword:(t,a)=>s(e.post(h.setActivePassword,{loginId:t,password:a}),(e=>e)),setPassword:(t,a)=>s(e.post(h.setPassword,{loginId:t,password:a}),(e=>e)),expirePassword:t=>s(e.post(h.expirePassword,{loginId:t}),(e=>e)),removeAllPasskeys:t=>s(e.post(h.removeAllPasskeys,{loginId:t}),(e=>e)),removeTOTPSeed:t=>s(e.post(h.removeTOTPSeed,{loginId:t}),(e=>e)),history:t=>s(e.post(h.history,t),(e=>e))}},q=e=>({create:(t,a,o,r,n,i,d)=>s(e.post(y.create,{name:t,selfProvisioningDomains:a,customAttributes:o,enforceSSO:r,disabled:n,parent:i,roleInheritance:d})),createWithId:(t,a,o,r,n,i,d,l)=>s(e.post(y.create,{id:t,name:a,selfProvisioningDomains:o,customAttributes:r,enforceSSO:n,disabled:i,parent:d,roleInheritance:l})),update:(t,a,o,r,n,i,d)=>s(e.post(y.update,{id:t,name:a,selfProvisioningDomains:o,customAttributes:r,enforceSSO:n,disabled:i,roleInheritance:d})),updateDefaultRoles:(t,a)=>s(e.post(y.updateDefaultRoles,{id:t,defaultRoles:a})),delete:(t,a)=>s(e.post(y.delete,{id:t,cascade:a})),load:t=>s(e.get(y.load,{queryParams:{id:t}}),(e=>e)),loadAll:()=>s(e.get(y.loadAll,{}),(e=>e.tenants)),searchAll:(t,a,o,r,n)=>s(e.post(y.searchAll,{tenantIds:t,tenantNames:a,tenantSelfProvisioningDomains:o,customAttributes:r,parentTenantId:n}),(e=>e.tenants)),getSettings:t=>s(e.get(y.settings,{queryParams:{id:t}}),(e=>e)),configureSettings:(t,a)=>s(e.post(y.settings,Object.assign(Object.assign({},a),{tenantId:t}),{})),generateSSOConfigurationLink:(t,a,o,r,n)=>s(e.post(y.generateSSOConfigurationLink,{tenantId:t,expireTime:a,ssoId:o,email:r,templateId:n},{}),(e=>e))}),$=e=>({update:(t,a,o)=>s(e.post(T.update,{jwt:t,customClaims:a,refreshDuration:o})),impersonate:(t,a,o,r,n,i)=>s(e.post(T.impersonate,{impersonatorId:t,loginId:a,validateConsent:o,customClaims:r,selectedTenant:n,refreshDuration:i})),stopImpersonation:(t,a,o,r)=>s(e.post(T.stopImpersonation,{jwt:t,customClaims:a,selectedTenant:o,refreshDuration:r})),signIn:(t,a)=>s(e.post(T.signIn,Object.assign({loginId:t},a))),signUp:(t,a,o)=>s(e.post(T.signUp,Object.assign({loginId:t,user:a},o))),signUpOrIn:(t,a,o)=>s(e.post(T.signUpOrIn,Object.assign({loginId:t,user:a},o))),anonymous:(t,a,o)=>s(e.post(T.anonymous,{customClaims:t,selectedTenant:a,refreshDuration:o})),generateClientAssertionJwt:(t,a,o,r,n,i)=>s(e.post(T.clientAssertion,{issuer:t,subject:a,audience:o,expiresIn:r,flattenAudience:n,algorithm:i}))}),z=e=>({create:(t,a)=>s(e.post(j.create,{name:t,description:a})),update:(t,a,o)=>s(e.post(j.update,{name:t,newName:a,description:o})),delete:t=>s(e.post(j.delete,{name:t})),loadAll:()=>s(e.get(j.loadAll,{}),(e=>e.permissions))}),J=e=>({create:(t,a,o,r,n)=>s(e.post(N.create,{name:t,description:a,permissionNames:o,tenantId:r,default:n})),update:(t,a,o,r,n,i)=>s(e.post(N.update,{name:t,newName:a,description:o,permissionNames:r,tenantId:n,default:i})),delete:(t,a)=>s(e.post(N.delete,{name:t,tenantId:a})),loadAll:()=>s(e.get(N.loadAll,{}),(e=>e.roles)),search:t=>s(e.post(N.search,t,{}),(e=>e.roles))}),K=e=>({loadAllGroups:t=>s(e.post(U.loadAllGroups,{tenantId:t})),loadAllGroupsForMember:(t,a,o)=>s(e.post(U.loadAllGroupsForMember,{tenantId:t,loginIds:o,userIds:a})),loadAllGroupMembers:(t,a)=>s(e.post(U.loadAllGroupMembers,{tenantId:t,groupId:a}))});function G(e){var t,s;const a=e;return a.oidc&&(a.oidc=Object.assign(Object.assign({},a.oidc),{attributeMapping:a.oidc.userAttrMapping}),delete a.oidc.userAttrMapping),(null===(t=a.saml)||void 0===t?void 0:t.groupsMapping)&&(a.saml.groupsMapping=null===(s=a.saml)||void 0===s?void 0:s.groupsMapping.map((e=>{const t=e;return t.roleName=t.role.name,delete t.role,t}))),a}const W=e=>({getSettings:t=>s(e.get(w.settings,{queryParams:{tenantId:t}}),(e=>e)),newSettings:(t,a,o)=>s(e.post(w.settingsNew,Object.assign(Object.assign({tenantId:t},a?{ssoId:a}:{}),{displayName:o})),(e=>G(e))),deleteSettings:(t,a)=>s(e.delete(w.settings,{queryParams:Object.assign({tenantId:t},a?{ssoId:a}:{})})),configureSettings:(t,a,o,r,n,i)=>s(e.post(w.settings,{tenantId:t,idpURL:a,entityId:r,idpCert:o,redirectURL:n,domains:i})),configureMetadata:(t,a,o,r)=>s(e.post(w.metadata,{tenantId:t,idpMetadataURL:a,redirectURL:o,domains:r})),configureMapping:(t,a,o,r)=>s(e.post(w.mapping,{tenantId:t,roleMappings:a,attributeMapping:o,defaultSSORoles:r})),configureOIDCSettings:(t,a,o,r)=>{const n=Object.assign(Object.assign({},a),{userAttrMapping:a.attributeMapping});return delete n.attributeMapping,s(e.post(w.oidc.configure,Object.assign({tenantId:t,settings:n,domains:o},r?{ssoId:r}:{})))},configureSAMLSettings:(t,a,o,r,n)=>s(e.post(w.saml.configure,Object.assign({tenantId:t,settings:a,redirectUrl:o,domains:r},n?{ssoId:n}:{}))),configureSAMLByMetadata:(t,a,o,r,n)=>s(e.post(w.saml.metadata,Object.assign({tenantId:t,settings:a,redirectUrl:o,domains:r},n?{ssoId:n}:{}))),loadSettings:(t,a)=>s(e.get(w.settingsv2,{queryParams:Object.assign({tenantId:t},a?{ssoId:a}:{})}),(e=>G(e))),loadAllSettings:t=>s(e.get(w.settingsAllV2,{queryParams:{tenantId:t}}),(e=>function(e){const t=e.SSOSettings,s=[];return t.forEach((e=>s.push(G(e)))),s}(e)))}),H=e=>({create:(t,a,o,r,n,i,d,l,p)=>s(e.post(I.create,{name:t,expireTime:a,roleNames:o,keyTenants:r,userId:n,customClaims:i,description:d,permittedIps:l,customAttributes:p})),load:t=>s(e.get(I.load,{queryParams:{id:t}}),(e=>e.key)),searchAll:(t,a,o,r)=>s(e.post(I.search,{tenantIds:t,boundUserId:a,creatingUser:o,customAttributes:r}),(e=>e.keys)),update:(t,a,o,r,n,i,d,l)=>s(e.post(I.update,{id:t,name:a,description:o,roleNames:r,keyTenants:n,customClaims:i,permittedIps:d,customAttributes:l}),(e=>e.key)),deactivate:t=>s(e.post(I.deactivate,{id:t})),activate:t=>s(e.post(I.activate,{id:t})),delete:t=>s(e.post(I.delete,{id:t}))}),V=e=>({list:()=>s(e.post(R.list,{})),delete:t=>s(e.post(R.delete,{ids:t})),export:t=>s(e.post(R.export,{flowId:t})),import:(t,a,o)=>s(e.post(R.import,{flowId:t,flow:a,screens:o})),run:(t,a)=>s(e.post(R.run,{flowId:t,options:a}),(e=>null==e?void 0:e.output))}),Q=e=>({export:()=>s(e.post(P.export,{})),import:t=>s(e.post(P.import,{theme:t}))}),_=e=>({search:t=>{const a=Object.assign(Object.assign({},t),{externalIds:t.loginIds});return delete a.loginIds,s(e.post(E.search,a),(e=>null==e?void 0:e.audits.map((e=>{const t=Object.assign(Object.assign({},e),{occurred:parseFloat(e.occurred),loginIds:e.externalIds});return delete t.externalIds,t}))))},createEvent:t=>{const a=Object.assign({},t);return s(e.post(E.createEvent,a))}}),X=(e,t)=>{var a;const o=null!==(a=null==t?void 0:t.fgaCacheTimeoutMs)&&void 0!==a?a:3e4,r=Number.isFinite(o)&&o>0?o:3e4,n=async(s,a)=>{if((null==t?void 0:t.fgaCacheUrl)&&t.managementKey){const e=`${t.fgaCacheUrl}${s}`,o=new AbortController,n=setTimeout((()=>o.abort()),r);try{const s=await m(e,{method:"POST",headers:Object.assign(Object.assign({},t.headers),{"Content-Type":"application/json",Authorization:`Bearer ${t.projectId}:${t.managementKey}`,"x-descope-project-id":t.projectId}),body:JSON.stringify(a),signal:o.signal});if(s.ok){const e=await s.text();return s.text=()=>Promise.resolve(e),s.json=async()=>JSON.parse(e),s.clone=()=>s,s}}catch(e){}finally{clearTimeout(n)}}return e.post(s,a)};return{saveSchema:(t,a)=>s(e.post(x.schemaSave,{schema:t,upgrade:a})),deleteSchema:()=>s(e.post(x.schemaDelete,{})),loadSchema:()=>s(e.post(x.schemaLoad,{}),(e=>e.schema)),saveNamespace:(t,a,o)=>s(e.post(x.nsSave,{namespace:t,oldName:a,schemaName:o})),deleteNamespace:(t,a)=>s(e.post(x.nsDelete,{name:t,schemaName:a})),saveRelationDefinition:(t,a,o,r)=>s(e.post(x.rdSave,{relationDefinition:t,namespace:a,oldName:o,schemaName:r})),deleteRelationDefinition:(t,a,o)=>s(e.post(x.rdDelete,{name:t,namespace:a,schemaName:o})),createRelations:t=>s(e.post(x.reCreate,{relations:t})),deleteRelations:t=>s(e.post(x.reDelete,{relations:t})),deleteRelationsForResources:t=>s(e.post(x.reDeleteResources,{resources:t})),deleteResourceRelationsForResources:t=>s(e.post(x.reDeleteResourceRelationsForResources,{resources:t})),deleteRelationsForIds:t=>s(e.post(x.reDeleteResources,{resources:t})),hasRelations:t=>s(e.post(x.hasRelations,{relationQueries:t}),(e=>e.relationQueries)),whoCanAccess:(e,t,a)=>s(n(x.who,{resource:e,relationDefinition:t,namespace:a}),(e=>e.targets)),resourceRelations:(t,a=!1)=>s(e.post(x.resource,{resource:t,ignoreTargetSetRelations:a}),(e=>e.relations)),targetsRelations:(t,a=!1)=>s(e.post(x.targets,{targets:t,includeTargetSetRelations:a}),(e=>e.relations)),whatCanTargetAccess:e=>s(n(x.targetAll,{target:e}),(e=>e.relations)),whatCanTargetAccessWithRelation:(t,a,o)=>s(e.post(x.targetWithRelation,{target:t,relationDefinition:a,namespace:o}),(e=>e.resources.map((e=>({resource:e}))))),getModified:t=>s(e.post(x.getModified,{since:t?t.getTime():0}),(e=>e))}},Y=e=>({createOidcApplication:t=>{var a;return s(e.post(b.oidcCreate,Object.assign(Object.assign({},t),{enabled:null===(a=t.enabled)||void 0===a||a})))},createSamlApplication:t=>{var a;return s(e.post(b.samlCreate,Object.assign(Object.assign({},t),{enabled:null===(a=t.enabled)||void 0===a||a})))},updateOidcApplication:t=>s(e.post(b.oidcUpdate,Object.assign({},t))),updateSamlApplication:t=>s(e.post(b.samlUpdate,Object.assign({},t))),createWsFedApplication:t=>{var a;return s(e.post(b.wsfedCreate,Object.assign(Object.assign({},t),{enabled:null===(a=t.enabled)||void 0===a||a})))},updateWsFedApplication:t=>s(e.post(b.wsfedUpdate,Object.assign({},t))),delete:t=>s(e.post(b.delete,{id:t})),load:t=>s(e.get(b.load,{queryParams:{id:t}}),(e=>e)),loadAll:()=>s(e.get(b.loadAll,{}),(e=>e.apps))}),Z=e=>({getSettings:t=>s(e.get(S.settings,{queryParams:{tenantId:t}}),(e=>e)),configureSettings:(t,a)=>s(e.post(S.settings,Object.assign(Object.assign({},a),{tenantId:t})))}),ee=(e,t)=>{var a;const o=null!==(a=null==t?void 0:t.fgaCacheTimeoutMs)&&void 0!==a?a:3e4,r=Number.isFinite(o)&&o>0?o:3e4,n=async(s,a)=>{if((null==t?void 0:t.fgaCacheUrl)&&t.managementKey){const e=`${t.fgaCacheUrl}${s}`,o=new AbortController,n=setTimeout((()=>o.abort()),r);try{const s=await m(e,{method:"POST",headers:Object.assign(Object.assign({},t.headers),{"Content-Type":"application/json",Authorization:`Bearer ${t.projectId}:${t.managementKey}`,"x-descope-project-id":t.projectId}),body:JSON.stringify(a),signal:o.signal});if(s.ok){const e=await s.text();return s.text=()=>Promise.resolve(e),s.json=async()=>JSON.parse(e),s.clone=()=>s,s}}catch(e){}finally{clearTimeout(n)}}return e.post(s,a)};return{saveSchema:e=>s(n(M.schema,e)),deleteSchema:()=>s(e.post(x.schemaDelete,{})),createRelations:e=>s(n(M.relations,{tuples:e})),deleteRelations:e=>s(n(M.deleteRelations,{tuples:e})),check:e=>s(n(M.check,{tuples:e}),(e=>e.tuples)),loadResourcesDetails:t=>s(e.post(M.resourcesLoad,{resourceIdentifiers:t}),(e=>e.resourcesDetails)),saveResourcesDetails:t=>s(e.post(M.resourcesSave,{resourcesDetails:t})),deleteAllRelations:()=>s(e.delete(M.relations))}},te=e=>({createApplication:t=>s(e.post(k.create,Object.assign({},t))),updateApplication:t=>s(e.post(k.update,Object.assign({},t))),patchApplication:t=>s(e.post(k.patch,Object.assign({},t))),deleteApplication:t=>s(e.post(k.delete,{id:t})),loadApplication:t=>s(e.get(k.load,{queryParams:{id:t}}),(e=>e)),loadAllApplications:()=>s(e.get(k.loadAll,{}),(e=>e.apps)),getApplicationSecret:t=>s(e.get(k.secret,{queryParams:{id:t}}),(e=>e)),rotateApplicationSecret:t=>s(e.post(k.rotate,{id:t})),searchConsents:t=>s(e.post(O.search,Object.assign({},t)),(e=>e.consents)),deleteConsents:t=>s(e.post(O.delete,Object.assign({},t)))}),se=e=>({createApplication:t=>s(e.post(A.create,Object.assign({},t)),(e=>e.app)),updateApplication:t=>s(e.post(A.update,{app:t}),(e=>e.app)),deleteApplication:t=>s(e.post(A.delete,{id:t})),loadApplication:t=>s(e.get(`${A.load}/${t}`),(e=>e.app)),loadAllApplications:()=>s(e.get(A.loadAll,{}),(e=>e.apps)),fetchTokenByScopes:(t,a,o,r,n)=>s(e.post(A.fetchTokenByScopes,{appId:t,userId:a,scopes:o,options:r,tenantId:n}),(e=>e.token)),fetchToken:(t,a,o,r)=>s(e.post(A.fetchToken,{appId:t,userId:a,tenantId:o,options:r}),(e=>e.token)),fetchTenantTokenByScopes:(t,a,o,r)=>s(e.post(A.fetchTenantTokenByScopes,{appId:t,tenantId:a,scopes:o,options:r}),(e=>e.token)),fetchTenantToken:(t,a,o)=>s(e.post(A.fetchTenantToken,{appId:t,tenantId:a,options:o}),(e=>e.token)),deleteUserTokens:(t,a)=>s(e.delete(A.deleteUserTokens,{queryParams:{appId:t,userId:a}})),deleteTokenById:t=>s(e.delete(A.deleteTokenById,{queryParams:{id:t}}))}),ae=e=>({create:t=>s(e.put(C.create,{descopers:t}),(e=>({descopers:e.descopers,total:e.total}))),update:(t,a,o)=>s(e.patch(C.update,{id:t,attributes:a,rbac:o}),(e=>e.descoper)),load:t=>s(e.get(C.get,{queryParams:{id:t}}),(e=>e.descoper)),delete:t=>s(e.delete(C.delete,{queryParams:{id:t}})),list:()=>s(e.post(C.list),(e=>({descopers:e.descopers,total:e.total})))}),oe=e=>({create:(t,a,o,r,n)=>s(e.put(D.create,{name:t,description:o,expiresIn:r,permittedIps:n,reBac:a})),update:(t,a,o,r,n)=>s(e.patch(D.update,{id:t,name:a,description:o,permittedIps:n,status:r}),(e=>e.key)),delete:t=>s(e.post(D.delete,{ids:t})),load:t=>s(e.get(D.load,{queryParams:{id:t}}),(e=>e.key)),search:()=>s(e.get(D.search),(e=>e.keys))});const re=d=>{var l,p,h,{authManagementKey:I,managementKey:y,publicKey:b,fgaCacheUrl:k}=d,O=e(d,["authManagementKey","managementKey","publicKey","fgaCacheUrl"]);const A={"x-descope-sdk-name":"nodejs","x-descope-sdk-node-version":(null===(l=null===process||void 0===process?void 0:process.versions)||void 0===l?void 0:l.node)||"","x-descope-sdk-version":"2.7.0"},w=Object.assign(Object.assign({fetch:m},O),{baseHeaders:Object.assign(Object.assign({},O.baseHeaders),A),hooks:Object.assign(Object.assign({},O.hooks),{beforeRequest:[e=>(I&&(e.token=e.token?`${e.token}:${I}`:I),e)].concat((null===(p=O.hooks)||void 0===p?void 0:p.beforeRequest)||[])})}),T=t(w),{projectId:S,logger:j}=O,N={};let R;const P=Object.assign(Object.assign({fetch:m},O),{baseConfig:{baseHeaders:Object.assign(Object.assign({},O.baseHeaders),A)},hooks:Object.assign(Object.assign({},O.hooks),{beforeRequest:[e=>(e.token=y,R&&(e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-license":R})),e)].concat((null===(h=O.hooks)||void 0===h?void 0:h.beforeRequest)||[])})}),U=a(P),E=(M={fgaCacheUrl:k,managementKey:y,projectId:S,headers:A},{user:B(x=U),project:(C=x,{updateName:e=>s(C.post(f.updateName,{name:e})),updateTags:e=>s(C.post(f.updateTags,{tags:e})),clone:(e,t,a)=>s(C.post(f.clone,{name:e,environment:t,tags:a})),listProjects:async()=>s(C.post(f.projectsList,{}),(e=>e.projects.map((({id:e,name:t,environment:s,tags:a})=>({id:e,name:t,environment:s,tags:a}))))),exportSnapshot:()=>s(C.post(f.exportSnapshot,{})),importSnapshot:e=>s(C.post(f.importSnapshot,e)),validateSnapshot:e=>s(C.post(f.validateSnapshot,e)),export:()=>s(C.post(f.exportSnapshot,{}),(e=>e.files)),import:e=>s(C.post(f.importSnapshot,{files:e}))}),accessKey:H(x),tenant:q(x),ssoApplication:Y(x),inboundApplication:te(x),outboundApplication:se(x),sso:W(x),jwt:$(x),permission:z(x),password:Z(x),role:J(x),group:K(x),flow:V(x),theme:Q(x),audit:_(x),authz:X(x,M),fga:ee(x,M),descoper:ae(x),managementKey:oe(x)});var x,M,C;y&&(e=>({get:()=>s(e.get(L.get))}))(U).get().then((e=>{var t;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.rateLimitTier)&&(R=e.data.rateLimitTier)})).catch((e=>{var t;null===(t=null==j?void 0:j.warn)||void 0===t||t.call(j,"License handshake failed",e)}));const D=Object.assign(Object.assign({},T),{refresh:async(e,t)=>T.refresh(e,void 0,t),management:E,async getKey(e){if(!(null==e?void 0:e.kid))throw Error("header.kid must not be empty");if(N[e.kid])return N[e.kid];if(Object.assign(N,await(async()=>{if(b)try{const e=JSON.parse(b),t=await i(e);return{[e.kid]:t}}catch(e){throw null==j||j.error("Failed to parse the provided public key",e),new Error(`Failed to parse public key. Error: ${e}`)}const e=(await T.httpClient.get(`v2/keys/${S}`).then((e=>e.json()))).keys;return Array.isArray(e)?(await Promise.all(e.map((async e=>[e.kid,await i(e)])))).reduce(((e,[t,s])=>t?Object.assign(Object.assign({},e),{[t.toString()]:s}):e),{}):{}})()),!N[e.kid])throw Error("failed to fetch matching key");return N[e.kid]},async validateJwt(e,t){const s={clockTolerance:5};(null==t?void 0:t.audience)&&(s.audience=t.audience);const a=(await r(e,D.getKey,s)).payload;if(a){const e=a.iss;if(!function(e,t){if(e===t)return!0;if(!e||!t)return!1;const s=e=>e[e.length-1]===t||e[e.length-2]===t;try{const{pathname:t}=new URL(e);return s(t.split("/").filter((e=>e.length>0)))}catch(t){return s(e.split("/").filter((e=>e.length>0)))}}("string"==typeof e?e:void 0,S))throw new n.JWTClaimValidationFailed('unexpected "iss" claim value',"iss","check_failed");a.iss=S}return{jwt:e,token:a}},async validateSession(e,t){if(!e)throw Error("session token is required for validation");try{return await D.validateJwt(e,t)}catch(e){throw null==j||j.error("session validation failed",e),Error(`session validation failed. Error: ${e}`)}},async refreshSession(e,t){var s,a,o,r,n,i;if(!e)throw Error("refresh token is required to refresh a session");try{await D.validateJwt(e);const d=await D.refresh(e);if(d.ok){const e=c(null===(a=null===(s=d.data)||void 0===s?void 0:s.cookies)||void 0===a?void 0:a.join(";"),"DS")||(null===(o=d.data)||void 0===o?void 0:o.sessionJwt),i=await D.validateJwt(e,t);return i.cookies=(null===(r=d.data)||void 0===r?void 0:r.cookies)||[],(null===(n=d.data)||void 0===n?void 0:n.refreshJwt)&&(i.refreshJwt=d.data.refreshJwt),i}throw Error(null===(i=d.error)||void 0===i?void 0:i.errorMessage)}catch(e){throw null==j||j.error("refresh token validation failed",e),Error(`refresh token validation failed, Error: ${e}`)}},async validateAndRefreshSession(e,t,s){if(!e&&!t)throw Error("both session and refresh tokens are empty");try{return await D.validateSession(e,s)}catch(e){null==j||j.log(`session validation failed with error ${e} - trying to refresh it`)}return D.refreshSession(t,s)},async exchangeAccessKey(e,t,s){var a;if(!e)throw Error("access key must not be empty");let o;try{o=await D.accessKey.exchange(e,t)}catch(e){throw null==j||j.error("failed to exchange access key",e),Error(`could not exchange access key - Failed to exchange. Error: ${e}`)}if(!o.ok)throw null==j||j.error("failed to exchange access key",o.error),Error(`could not exchange access key - ${null===(a=o.error)||void 0===a?void 0:a.errorMessage}`);const{sessionJwt:r}=o.data;if(!r)throw null==j||j.error("failed to parse exchange access key response"),Error("could not exchange access key");try{return await D.validateJwt(r,s)}catch(e){throw null==j||j.error("failed to parse jwt from access key",e),Error(`could not exchange access key - failed to validate jwt. Error: ${e}`)}},validatePermissions:(e,t)=>D.validateTenantPermissions(e,"",t),getMatchedPermissions:(e,t)=>D.getMatchedTenantPermissions(e,"",t),validateTenantPermissions(e,t,s){if(t&&!v(e,t))return!1;const a=g(e,"permissions",t);return s.every((e=>a.includes(e)))},getMatchedTenantPermissions(e,t,s){if(t&&!v(e,t))return[];const a=g(e,"permissions",t);return s.filter((e=>a.includes(e)))},validateRoles:(e,t)=>D.validateTenantRoles(e,"",t),getMatchedRoles:(e,t)=>D.getMatchedTenantRoles(e,"",t),validateTenantRoles(e,t,s){if(t&&!v(e,t))return!1;const a=g(e,"roles",t);return s.every((e=>a.includes(e)))},getMatchedTenantRoles(e,t,s){if(t&&!v(e,t))return[];const a=g(e,"roles",t);return s.filter((e=>a.includes(e)))}});return o(D,["otp.verify.email","otp.verify.sms","otp.verify.voice","otp.verify.whatsapp","otp.verify.im","notp.waitForSession","magicLink.verify","enchantedLink.signUp","enchantedLink.signIn","enchantedLink.waitForSession","oauth.exchangeOneTapIDToken","password.signIn","password.signUp","password.replace","oauth.exchange","saml.exchange","totp.verify","selectTenant","webauthn.signIn.finish","webauthn.signUp.finish","refresh"],u)};re.RefreshTokenCookieName="DSR",re.SessionTokenCookieName="DS",re.DescopeErrors={badRequest:"E011001",missingArguments:"E011002",invalidRequest:"E011003",invalidArguments:"E011004",wrongOTPCode:"E061102",tooManyOTPAttempts:"E061103",enchantedLinkPending:"E062503",userNotFound:"E062108"};export{re as default};
1
+ import{__rest as e}from"tslib";import t,{transformResponse as s,createHttpClient as a,wrapWith as o}from"@descope/core-js-sdk";import{jwtVerify as r,errors as n,importJWK as i}from"jose";import{Headers as d,fetch as l}from"cross-fetch";var p;null!==(p=globalThis.Headers)&&void 0!==p||(globalThis.Headers=d);const m="function"==typeof globalThis.fetch?(...e)=>globalThis.fetch(...e):(...e)=>(e.forEach((e=>{var t,s;e&&"object"==typeof e&&(null!==(t=(s=e).highWaterMark)&&void 0!==t||(s.highWaterMark=31457280))})),l(...e)),c=(e,t)=>{const s=null==e?void 0:e.match(RegExp(`(?:^|[;,]\\s*)${t}=([^;]*)`));return s?s[1]:null};const u=t=>async(...s)=>{var a,o,r;const n=await t(...s);if(!n.data)return n;let i=n.data,{refreshJwt:d}=i,l=e(i,["refreshJwt"]);const p=[];var m;return d?p.push(`${"DSR"}=${d}; Domain=${(null==(m=l)?void 0:m.cookieDomain)||""}; Max-Age=${(null==m?void 0:m.cookieMaxAge)||""}; Path=${(null==m?void 0:m.cookiePath)||"/"}; HttpOnly; SameSite=Strict`):(null===(a=n.response)||void 0===a?void 0:a.headers.get("set-cookie"))&&(d=c(null===(o=n.response)||void 0===o?void 0:o.headers.get("set-cookie"),"DSR"),p.push(null===(r=n.response)||void 0===r?void 0:r.headers.get("set-cookie"))),Object.assign(Object.assign({},n),{data:Object.assign(Object.assign({},n.data),{refreshJwt:d,cookies:p})})};function g(e,t,s){var a,o;const r=s?null===(o=null===(a=e.token.tenants)||void 0===a?void 0:a[s])||void 0===o?void 0:o[t]:e.token[t];return Array.isArray(r)?r:[]}function v(e,t){var s;return!!(null===(s=e.token.tenants)||void 0===s?void 0:s[t])}var h={create:"/v1/mgmt/user/create",createTestUser:"/v1/mgmt/user/create/test",createBatch:"/v1/mgmt/user/create/batch",update:"/v1/mgmt/user/update",patch:"/v1/mgmt/user/patch",patchBatch:"/v1/mgmt/user/patch/batch",delete:"/v1/mgmt/user/delete",deleteBatch:"/v1/mgmt/user/delete/batch",deleteAllTestUsers:"/v1/mgmt/user/test/delete/all",load:"/v1/mgmt/user",logout:"/v1/mgmt/user/logout",loadUsers:"/v1/mgmt/users/load",search:"/v2/mgmt/user/search",searchTestUsers:"/v2/mgmt/user/search/test",getProviderToken:"/v1/mgmt/user/provider/token",updateStatus:"/v1/mgmt/user/update/status",updateLoginId:"/v1/mgmt/user/update/loginid",updateEmail:"/v1/mgmt/user/update/email",updatePhone:"/v1/mgmt/user/update/phone",updateDisplayName:"/v1/mgmt/user/update/name",updatePicture:"/v1/mgmt/user/update/picture",updateCustomAttribute:"/v1/mgmt/user/update/customAttribute",setRole:"/v1/mgmt/user/update/role/set",addRole:"/v2/mgmt/user/update/role/add",removeRole:"/v1/mgmt/user/update/role/remove",setSSOApps:"/v1/mgmt/user/update/ssoapp/set",addSSOApps:"/v1/mgmt/user/update/ssoapp/add",removeSSOApps:"/v1/mgmt/user/update/ssoapp/remove",addTenant:"/v1/mgmt/user/update/tenant/add",removeTenant:"/v1/mgmt/user/update/tenant/remove",setPassword:"/v1/mgmt/user/password/set",setTemporaryPassword:"/v1/mgmt/user/password/set/temporary",setActivePassword:"/v1/mgmt/user/password/set/active",expirePassword:"/v1/mgmt/user/password/expire",removeAllPasskeys:"/v1/mgmt/user/passkeys/delete",removeTOTPSeed:"/v1/mgmt/user/totp/delete",generateOTPForTest:"/v1/mgmt/tests/generate/otp",generateMagicLinkForTest:"/v1/mgmt/tests/generate/magiclink",generateEnchantedLinkForTest:"/v1/mgmt/tests/generate/enchantedlink",generateEmbeddedLink:"/v1/mgmt/user/signin/embeddedlink",generateSignUpEmbeddedLink:"/v1/mgmt/user/signup/embeddedlink",history:"/v1/mgmt/user/history"},f={updateName:"/v1/mgmt/project/update/name",updateTags:"/v1/mgmt/project/update/tags",clone:"/v1/mgmt/project/clone",projectsList:"/v1/mgmt/projects/list",exportSnapshot:"/v1/mgmt/project/snapshot/export",importSnapshot:"/v1/mgmt/project/snapshot/import",validateSnapshot:"/v1/mgmt/project/snapshot/validate"},y={create:"/v1/mgmt/accesskey/create",load:"/v1/mgmt/accesskey",search:"/v1/mgmt/accesskey/search",update:"/v1/mgmt/accesskey/update",deactivate:"/v1/mgmt/accesskey/deactivate",activate:"/v1/mgmt/accesskey/activate",delete:"/v1/mgmt/accesskey/delete"},I={create:"/v1/mgmt/tenant/create",update:"/v1/mgmt/tenant/update",delete:"/v1/mgmt/tenant/delete",load:"/v1/mgmt/tenant",settings:"/v1/mgmt/tenant/settings",loadAll:"/v1/mgmt/tenant/all",searchAll:"/v1/mgmt/tenant/search",updateDefaultRoles:"/v1/mgmt/tenant/updateDefaultRoles",generateSSOConfigurationLink:"/v2/mgmt/tenant/adminlinks/sso/generate"},b={oidcCreate:"/v1/mgmt/sso/idp/app/oidc/create",samlCreate:"/v1/mgmt/sso/idp/app/saml/create",oidcUpdate:"/v1/mgmt/sso/idp/app/oidc/update",samlUpdate:"/v1/mgmt/sso/idp/app/saml/update",wsfedCreate:"/v1/mgmt/sso/idp/app/wsfed/create",wsfedUpdate:"/v1/mgmt/sso/idp/app/wsfed/update",delete:"/v1/mgmt/sso/idp/app/delete",load:"/v1/mgmt/sso/idp/app/load",loadAll:"/v1/mgmt/sso/idp/apps/load"},k={create:"/v1/mgmt/thirdparty/app/create",update:"/v1/mgmt/thirdparty/app/update",patch:"/v1/mgmt/thirdparty/app/patch",delete:"/v1/mgmt/thirdparty/app/delete",load:"/v1/mgmt/thirdparty/app/load",loadAll:"/v1/mgmt/thirdparty/apps/load",secret:"/v1/mgmt/thirdparty/app/secret",rotate:"/v1/mgmt/thirdparty/app/rotate"},O={delete:"/v1/mgmt/thirdparty/consents/delete",search:"/v1/mgmt/thirdparty/consents/search"},T={create:"/v1/mgmt/outbound/app/create",createByTemplate:"/v1/mgmt/outbound/app/create/bytemplate",update:"/v1/mgmt/outbound/app/update",delete:"/v1/mgmt/outbound/app/delete",load:"/v1/mgmt/outbound/app",loadAll:"/v1/mgmt/outbound/apps",fetchToken:"/v1/mgmt/outbound/app/user/token/latest",fetchTokenByScopes:"/v1/mgmt/outbound/app/user/token",fetchTenantToken:"/v1/mgmt/outbound/app/tenant/token/latest",fetchTenantTokenByScopes:"/v1/mgmt/outbound/app/tenant/token",deleteUserTokens:"/v1/mgmt/outbound/user/tokens",deleteTokenById:"/v1/mgmt/outbound/token"},A={settings:"/v1/mgmt/sso/settings",settingsNew:"/v1/mgmt/sso/settings/new",metadata:"/v1/mgmt/sso/metadata",mapping:"/v1/mgmt/sso/mapping",settingsv2:"/v2/mgmt/sso/settings",settingsAllV2:"/v2/mgmt/sso/settings/all",oidc:{configure:"/v1/mgmt/sso/oidc"},saml:{configure:"/v1/mgmt/sso/saml",metadata:"/v1/mgmt/sso/saml/metadata"}},w={update:"/v1/mgmt/jwt/update",impersonate:"/v1/mgmt/impersonate",stopImpersonation:"/v1/mgmt/stop/impersonation",signIn:"/v1/mgmt/auth/signin",signUp:"/v1/mgmt/auth/signup",signUpOrIn:"/v1/mgmt/auth/signup-in",anonymous:"/v1/mgmt/auth/anonymous",clientAssertion:"/v1/mgmt/token/clientassertion"},S={settings:"/v1/mgmt/password/settings"},j={create:"/v1/mgmt/permission/create",update:"/v1/mgmt/permission/update",delete:"/v1/mgmt/permission/delete",loadAll:"/v1/mgmt/permission/all"},N={create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update",delete:"/v1/mgmt/role/delete",loadAll:"/v1/mgmt/role/all",search:"/v1/mgmt/role/search"},R={list:"/v1/mgmt/flow/list",delete:"/v1/mgmt/flow/delete",export:"/v1/mgmt/flow/export",import:"/v1/mgmt/flow/import",run:"/v1/mgmt/flow/run"},P={export:"/v1/mgmt/theme/export",import:"/v1/mgmt/theme/import"},U={loadAllGroups:"/v1/mgmt/group/all",loadAllGroupsForMember:"/v1/mgmt/group/member/all",loadAllGroupMembers:"/v1/mgmt/group/members"},E={search:"/v1/mgmt/audit/search",createEvent:"/v1/mgmt/audit/event"},x={schemaSave:"/v1/mgmt/authz/schema/save",schemaDelete:"/v1/mgmt/authz/schema/delete",schemaLoad:"/v1/mgmt/authz/schema/load",nsSave:"/v1/mgmt/authz/ns/save",nsDelete:"/v1/mgmt/authz/ns/delete",rdSave:"/v1/mgmt/authz/rd/save",rdDelete:"/v1/mgmt/authz/rd/delete",reCreate:"/v1/mgmt/authz/re/create",reDelete:"/v1/mgmt/authz/re/delete",reDeleteResources:"/v1/mgmt/authz/re/deleteresources",reDeleteResourceRelationsForResources:"/v1/mgmt/authz/re/deleteresourcesrelations",hasRelations:"/v1/mgmt/authz/re/has",who:"/v1/mgmt/authz/re/who",resource:"/v1/mgmt/authz/re/resource",targets:"/v1/mgmt/authz/re/targets",targetAll:"/v1/mgmt/authz/re/targetall",targetWithRelation:"/v1/mgmt/authz/re/targetwithrelation",getModified:"/v1/mgmt/authz/getmodified"},M={schema:"/v1/mgmt/fga/schema",relations:"/v1/mgmt/fga/relations",deleteRelations:"/v1/mgmt/fga/relations/delete",check:"/v1/mgmt/fga/check",resourcesLoad:"/v1/mgmt/fga/resources/load",resourcesSave:"/v1/mgmt/fga/resources/save"},C={create:"/v1/mgmt/descoper",update:"/v1/mgmt/descoper",get:"/v1/mgmt/descoper",delete:"/v1/mgmt/descoper",list:"/v1/mgmt/descoper/list"},D={create:"/v1/mgmt/managementkey",update:"/v1/mgmt/managementkey",load:"/v1/mgmt/managementkey",delete:"/v1/mgmt/managementkey/delete",search:"/v1/mgmt/managementkey/search"},L={get:"/v1/mgmt/license"};function B(t){return t.map((t=>{var{loginIdOrUserId:s,loginId:a,roles:o}=t,r=e(t,["loginIdOrUserId","loginId","roles"]);return Object.assign(Object.assign({},r),{loginId:null!=s?s:a,roleNames:o})}))}const F=e=>{function t(e,t){const s={loginId:e};return void 0!==t.email&&(s.email=t.email),void 0!==t.phone&&(s.phone=t.phone),void 0!==t.displayName&&(s.displayName=t.displayName),void 0!==t.givenName&&(s.givenName=t.givenName),void 0!==t.middleName&&(s.middleName=t.middleName),void 0!==t.familyName&&(s.familyName=t.familyName),void 0!==t.roles&&(s.roleNames=t.roles),void 0!==t.userTenants&&(s.userTenants=t.userTenants),void 0!==t.customAttributes&&(s.customAttributes=t.customAttributes),void 0!==t.picture&&(s.picture=t.picture),void 0!==t.verifiedEmail&&(s.verifiedEmail=t.verifiedEmail),void 0!==t.verifiedPhone&&(s.verifiedPhone=t.verifiedPhone),void 0!==t.ssoAppIds&&(s.ssoAppIds=t.ssoAppIds),void 0!==t.scim&&(s.scim=t.scim),void 0!==t.status&&(s.status=t.status),void 0!==t.additionalIdentifiers&&(s.additionalIdentifiers=t.additionalIdentifiers),s}return{create:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v){const f="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:c,middleName:u,familyName:g,roleNames:n,userTenants:i,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,additionalLoginIds:v}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0});return s(e.post(h.create,f),(e=>e.user))},createTestUser:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v){const f="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:c,middleName:u,familyName:g,roleNames:n,userTenants:i,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,additionalLoginIds:v,test:!0}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0,test:!0});return s(e.post(h.createTestUser,f),(e=>e.user))},invite:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v,f,y,I,b,k){const O="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:v,middleName:f,familyName:y,roleNames:n,userTenants:i,invite:!0,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,inviteUrl:c,sendMail:u,sendSMS:g,additionalLoginIds:I,templateId:b,locale:k}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0,invite:!0});return s(e.post(h.create,O),(e=>e.user))},inviteBatch:(t,a,o,r,n,i,d)=>s(e.post(h.createBatch,{users:B(t),invite:!0,inviteUrl:a,sendMail:o,sendSMS:r,templateOptions:n,templateId:i,locale:d}),(e=>e)),createBatch:t=>s(e.post(h.createBatch,{users:B(t)}),(e=>e)),deleteBatch:t=>s(e.post(h.deleteBatch,{userIds:t})),update:function(t,a,o,r,n,i,d,l,p,m,c,u,g,v){const f="string"==typeof a?{loginId:t,email:a,phone:o,displayName:r,givenName:c,middleName:u,familyName:g,roleNames:n,userTenants:i,customAttributes:d,picture:l,verifiedEmail:p,verifiedPhone:m,additionalLoginIds:v}:Object.assign(Object.assign({loginId:t},a),{roleNames:null==a?void 0:a.roles,roles:void 0});return s(e.post(h.update,f),(e=>e.user))},patch:function(a,o){const r=t(a,o);return s(e.patch(h.patch,r),(e=>e.user))},patchBatch:function(a){if(a.find((e=>!e.loginIdOrUserId&&!e.loginId)))return Promise.reject(new Error("patchBatch: each user must have loginIdOrUserId or loginId"));const o={users:a.map((e=>{var s;return t(null!==(s=e.loginIdOrUserId)&&void 0!==s?s:e.loginId,e)}))};return s(e.patch(h.patchBatch,o),(e=>e))},delete:t=>s(e.post(h.delete,{loginId:t})),deleteByUserId:t=>s(e.post(h.delete,{userId:t})),deleteAllTestUsers:()=>s(e.delete(h.deleteAllTestUsers)),load:t=>s(e.get(h.load,{queryParams:{loginId:t}}),(e=>e.user)),loadByUserId:t=>s(e.get(h.load,{queryParams:{userId:t}}),(e=>e.user)),logoutUser:t=>s(e.post(h.logout,{loginId:t})),logoutUserByUserId:t=>s(e.post(h.logout,{userId:t})),loadUsers:(t,a)=>s(e.post(h.loadUsers,{userIds:t,includeInvalidUsers:a}),(e=>e.users)),searchAll:(t,a,o,r,n,i,d,l,p,m)=>s(e.post(h.search,{tenantIds:t,roleNames:a,limit:o,page:r,testUsersOnly:n,withTestUser:i,customAttributes:d,statuses:l,emails:p,phones:m}),(e=>e.users)),searchTestUsers:t=>s(e.post(h.searchTestUsers,Object.assign(Object.assign({},t),{withTestUser:!0,testUsersOnly:!0,roleNames:t.roles,roles:void 0})),(e=>({users:e.users,total:e.total}))),search:t=>s(e.post(h.search,Object.assign(Object.assign({},t),{roleNames:t.roles,roles:void 0})),(e=>({users:e.users,total:e.total}))),getProviderToken:(t,a,o)=>s(e.get(h.getProviderToken,{queryParams:{loginId:t,provider:a,withRefreshToken:(null==o?void 0:o.withRefreshToken)?"true":"false",forceRefresh:(null==o?void 0:o.forceRefresh)?"true":"false"}}),(e=>e)),activate:t=>s(e.post(h.updateStatus,{loginId:t,status:"enabled"}),(e=>e.user)),deactivate:t=>s(e.post(h.updateStatus,{loginId:t,status:"disabled"}),(e=>e.user)),updateLoginId:(t,a)=>s(e.post(h.updateLoginId,{loginId:t,newLoginId:a}),(e=>e.user)),updateEmail:(t,a,o,r)=>s(e.post(h.updateEmail,{loginId:t,email:a,verified:o,failOnConflict:r}),(e=>e.user)),updatePhone:(t,a,o,r)=>s(e.post(h.updatePhone,{loginId:t,phone:a,verified:o,failOnConflict:r}),(e=>e.user)),updateDisplayName:(t,a,o,r,n)=>s(e.post(h.updateDisplayName,{loginId:t,displayName:a,givenName:o,middleName:r,familyName:n}),(e=>e.user)),updatePicture:(t,a)=>s(e.post(h.updatePicture,{loginId:t,picture:a}),(e=>e.user)),updateCustomAttribute:(t,a,o)=>s(e.post(h.updateCustomAttribute,{loginId:t,attributeKey:a,attributeValue:o}),(e=>e.user)),setRoles:(t,a)=>s(e.post(h.setRole,{loginId:t,roleNames:a}),(e=>e.user)),addRoles:(t,a)=>s(e.post(h.addRole,{loginId:t,roleNames:a}),(e=>e.user)),removeRoles:(t,a)=>s(e.post(h.removeRole,{loginId:t,roleNames:a}),(e=>e.user)),addTenant:(t,a)=>s(e.post(h.addTenant,{loginId:t,tenantId:a}),(e=>e.user)),removeTenant:(t,a)=>s(e.post(h.removeTenant,{loginId:t,tenantId:a}),(e=>e.user)),setTenantRoles:(t,a,o)=>s(e.post(h.setRole,{loginId:t,tenantId:a,roleNames:o}),(e=>e.user)),addTenantRoles:(t,a,o)=>s(e.post(h.addRole,{loginId:t,tenantId:a,roleNames:o}),(e=>e.user)),removeTenantRoles:(t,a,o)=>s(e.post(h.removeRole,{loginId:t,tenantId:a,roleNames:o}),(e=>e.user)),addSSOapps:(t,a)=>s(e.post(h.addSSOApps,{loginId:t,ssoAppIds:a}),(e=>e.user)),setSSOapps:(t,a)=>s(e.post(h.setSSOApps,{loginId:t,ssoAppIds:a}),(e=>e.user)),removeSSOapps:(t,a)=>s(e.post(h.removeSSOApps,{loginId:t,ssoAppIds:a}),(e=>e.user)),generateOTPForTestUser:(t,a,o)=>s(e.post(h.generateOTPForTest,{deliveryMethod:t,loginId:a,loginOptions:o}),(e=>e)),generateMagicLinkForTestUser:(t,a,o,r)=>s(e.post(h.generateMagicLinkForTest,{deliveryMethod:t,loginId:a,URI:o,loginOptions:r}),(e=>e)),generateEnchantedLinkForTestUser:(t,a,o)=>s(e.post(h.generateEnchantedLinkForTest,{loginId:t,URI:a,loginOptions:o}),(e=>e)),generateEmbeddedLink:(t,a,o)=>s(e.post(h.generateEmbeddedLink,{loginId:t,customClaims:a,timeout:o}),(e=>e)),generateSignUpEmbeddedLink:(t,a,o,r,n,i)=>s(e.post(h.generateSignUpEmbeddedLink,{loginId:t,user:a,emailVerified:o,phoneVerified:r,loginOptions:n,timeout:i}),(e=>e)),setTemporaryPassword:(t,a)=>s(e.post(h.setTemporaryPassword,{loginId:t,password:a}),(e=>e)),setActivePassword:(t,a)=>s(e.post(h.setActivePassword,{loginId:t,password:a}),(e=>e)),setPassword:(t,a)=>s(e.post(h.setPassword,{loginId:t,password:a}),(e=>e)),expirePassword:t=>s(e.post(h.expirePassword,{loginId:t}),(e=>e)),removeAllPasskeys:t=>s(e.post(h.removeAllPasskeys,{loginId:t}),(e=>e)),removeTOTPSeed:t=>s(e.post(h.removeTOTPSeed,{loginId:t}),(e=>e)),history:t=>s(e.post(h.history,t),(e=>e))}},q=e=>({create:(t,a,o,r,n,i,d)=>s(e.post(I.create,{name:t,selfProvisioningDomains:a,customAttributes:o,enforceSSO:r,disabled:n,parent:i,roleInheritance:d})),createWithId:(t,a,o,r,n,i,d,l)=>s(e.post(I.create,{id:t,name:a,selfProvisioningDomains:o,customAttributes:r,enforceSSO:n,disabled:i,parent:d,roleInheritance:l})),update:(t,a,o,r,n,i,d)=>s(e.post(I.update,{id:t,name:a,selfProvisioningDomains:o,customAttributes:r,enforceSSO:n,disabled:i,roleInheritance:d})),updateDefaultRoles:(t,a)=>s(e.post(I.updateDefaultRoles,{id:t,defaultRoles:a})),delete:(t,a)=>s(e.post(I.delete,{id:t,cascade:a})),load:t=>s(e.get(I.load,{queryParams:{id:t}}),(e=>e)),loadAll:()=>s(e.get(I.loadAll,{}),(e=>e.tenants)),searchAll:(t,a,o,r,n)=>s(e.post(I.searchAll,{tenantIds:t,tenantNames:a,tenantSelfProvisioningDomains:o,customAttributes:r,parentTenantId:n}),(e=>e.tenants)),getSettings:t=>s(e.get(I.settings,{queryParams:{id:t}}),(e=>e)),configureSettings:(t,a)=>s(e.post(I.settings,Object.assign(Object.assign({},a),{tenantId:t}),{})),generateSSOConfigurationLink:(t,a,o,r,n,i)=>s(e.post(I.generateSSOConfigurationLink,{tenantId:t,expireTime:a,ssoId:o,email:r,templateId:n,actorId:i},{}),(e=>e))}),$=e=>({update:(t,a,o)=>s(e.post(w.update,{jwt:t,customClaims:a,refreshDuration:o})),impersonate:(t,a,o,r,n,i)=>s(e.post(w.impersonate,{impersonatorId:t,loginId:a,validateConsent:o,customClaims:r,selectedTenant:n,refreshDuration:i})),stopImpersonation:(t,a,o,r)=>s(e.post(w.stopImpersonation,{jwt:t,customClaims:a,selectedTenant:o,refreshDuration:r})),signIn:(t,a)=>s(e.post(w.signIn,Object.assign({loginId:t},a))),signUp:(t,a,o)=>s(e.post(w.signUp,Object.assign({loginId:t,user:a},o))),signUpOrIn:(t,a,o)=>s(e.post(w.signUpOrIn,Object.assign({loginId:t,user:a},o))),anonymous:(t,a,o)=>s(e.post(w.anonymous,{customClaims:t,selectedTenant:a,refreshDuration:o})),generateClientAssertionJwt:(t,a,o,r,n,i)=>s(e.post(w.clientAssertion,{issuer:t,subject:a,audience:o,expiresIn:r,flattenAudience:n,algorithm:i}))}),z=e=>({create:(t,a)=>s(e.post(j.create,{name:t,description:a})),update:(t,a,o)=>s(e.post(j.update,{name:t,newName:a,description:o})),delete:t=>s(e.post(j.delete,{name:t})),loadAll:()=>s(e.get(j.loadAll,{}),(e=>e.permissions))}),J=e=>({create:(t,a,o,r,n)=>s(e.post(N.create,{name:t,description:a,permissionNames:o,tenantId:r,default:n})),update:(t,a,o,r,n,i)=>s(e.post(N.update,{name:t,newName:a,description:o,permissionNames:r,tenantId:n,default:i})),delete:(t,a)=>s(e.post(N.delete,{name:t,tenantId:a})),loadAll:()=>s(e.get(N.loadAll,{}),(e=>e.roles)),search:t=>s(e.post(N.search,t,{}),(e=>e.roles))}),K=e=>({loadAllGroups:t=>s(e.post(U.loadAllGroups,{tenantId:t})),loadAllGroupsForMember:(t,a,o)=>s(e.post(U.loadAllGroupsForMember,{tenantId:t,loginIds:o,userIds:a})),loadAllGroupMembers:(t,a)=>s(e.post(U.loadAllGroupMembers,{tenantId:t,groupId:a}))});function G(e){var t,s;const a=e;return a.oidc&&(a.oidc=Object.assign(Object.assign({},a.oidc),{attributeMapping:a.oidc.userAttrMapping}),delete a.oidc.userAttrMapping),(null===(t=a.saml)||void 0===t?void 0:t.groupsMapping)&&(a.saml.groupsMapping=null===(s=a.saml)||void 0===s?void 0:s.groupsMapping.map((e=>{const t=e;return t.roleName=t.role.name,delete t.role,t}))),a}const W=e=>({getSettings:t=>s(e.get(A.settings,{queryParams:{tenantId:t}}),(e=>e)),newSettings:(t,a,o)=>s(e.post(A.settingsNew,Object.assign(Object.assign({tenantId:t},a?{ssoId:a}:{}),{displayName:o})),(e=>G(e))),deleteSettings:(t,a)=>s(e.delete(A.settings,{queryParams:Object.assign({tenantId:t},a?{ssoId:a}:{})})),configureSettings:(t,a,o,r,n,i)=>s(e.post(A.settings,{tenantId:t,idpURL:a,entityId:r,idpCert:o,redirectURL:n,domains:i})),configureMetadata:(t,a,o,r)=>s(e.post(A.metadata,{tenantId:t,idpMetadataURL:a,redirectURL:o,domains:r})),configureMapping:(t,a,o,r)=>s(e.post(A.mapping,{tenantId:t,roleMappings:a,attributeMapping:o,defaultSSORoles:r})),configureOIDCSettings:(t,a,o,r)=>{const n=Object.assign(Object.assign({},a),{userAttrMapping:a.attributeMapping});return delete n.attributeMapping,s(e.post(A.oidc.configure,Object.assign({tenantId:t,settings:n,domains:o},r?{ssoId:r}:{})))},configureSAMLSettings:(t,a,o,r,n)=>s(e.post(A.saml.configure,Object.assign({tenantId:t,settings:a,redirectUrl:o,domains:r},n?{ssoId:n}:{}))),configureSAMLByMetadata:(t,a,o,r,n)=>s(e.post(A.saml.metadata,Object.assign({tenantId:t,settings:a,redirectUrl:o,domains:r},n?{ssoId:n}:{}))),loadSettings:(t,a)=>s(e.get(A.settingsv2,{queryParams:Object.assign({tenantId:t},a?{ssoId:a}:{})}),(e=>G(e))),loadAllSettings:t=>s(e.get(A.settingsAllV2,{queryParams:{tenantId:t}}),(e=>function(e){const t=e.SSOSettings,s=[];return t.forEach((e=>s.push(G(e)))),s}(e)))}),H=e=>({create:(t,a,o,r,n,i,d,l,p)=>s(e.post(y.create,{name:t,expireTime:a,roleNames:o,keyTenants:r,userId:n,customClaims:i,description:d,permittedIps:l,customAttributes:p})),load:t=>s(e.get(y.load,{queryParams:{id:t}}),(e=>e.key)),searchAll:(t,a,o,r)=>s(e.post(y.search,{tenantIds:t,boundUserId:a,creatingUser:o,customAttributes:r}),(e=>e.keys)),update:(t,a,o,r,n,i,d,l)=>s(e.post(y.update,{id:t,name:a,description:o,roleNames:r,keyTenants:n,customClaims:i,permittedIps:d,customAttributes:l}),(e=>e.key)),deactivate:t=>s(e.post(y.deactivate,{id:t})),activate:t=>s(e.post(y.activate,{id:t})),delete:t=>s(e.post(y.delete,{id:t}))}),V=e=>({list:()=>s(e.post(R.list,{})),delete:t=>s(e.post(R.delete,{ids:t})),export:t=>s(e.post(R.export,{flowId:t})),import:(t,a,o)=>s(e.post(R.import,{flowId:t,flow:a,screens:o})),run:(t,a)=>s(e.post(R.run,{flowId:t,options:a}),(e=>null==e?void 0:e.output))}),Q=e=>({export:()=>s(e.post(P.export,{})),import:t=>s(e.post(P.import,{theme:t}))}),_=e=>({search:t=>{const a=Object.assign(Object.assign({},t),{externalIds:t.loginIds});return delete a.loginIds,s(e.post(E.search,a),(e=>null==e?void 0:e.audits.map((e=>{const t=Object.assign(Object.assign({},e),{occurred:parseFloat(e.occurred),loginIds:e.externalIds});return delete t.externalIds,t}))))},createEvent:t=>{const a=Object.assign({},t);return s(e.post(E.createEvent,a))}}),X=(e,t)=>{var a;const o=null!==(a=null==t?void 0:t.fgaCacheTimeoutMs)&&void 0!==a?a:3e4,r=Number.isFinite(o)&&o>0?o:3e4,n=async(s,a)=>{if((null==t?void 0:t.fgaCacheUrl)&&t.managementKey){const e=`${t.fgaCacheUrl}${s}`,o=new AbortController,n=setTimeout((()=>o.abort()),r);try{const s=await m(e,{method:"POST",headers:Object.assign(Object.assign({},t.headers),{"Content-Type":"application/json",Authorization:`Bearer ${t.projectId}:${t.managementKey}`,"x-descope-project-id":t.projectId}),body:JSON.stringify(a),signal:o.signal});if(s.ok){const e=await s.text();return s.text=()=>Promise.resolve(e),s.json=async()=>JSON.parse(e),s.clone=()=>s,s}}catch(e){}finally{clearTimeout(n)}}return e.post(s,a)};return{saveSchema:(t,a)=>s(e.post(x.schemaSave,{schema:t,upgrade:a})),deleteSchema:()=>s(e.post(x.schemaDelete,{})),loadSchema:()=>s(e.post(x.schemaLoad,{}),(e=>e.schema)),saveNamespace:(t,a,o)=>s(e.post(x.nsSave,{namespace:t,oldName:a,schemaName:o})),deleteNamespace:(t,a)=>s(e.post(x.nsDelete,{name:t,schemaName:a})),saveRelationDefinition:(t,a,o,r)=>s(e.post(x.rdSave,{relationDefinition:t,namespace:a,oldName:o,schemaName:r})),deleteRelationDefinition:(t,a,o)=>s(e.post(x.rdDelete,{name:t,namespace:a,schemaName:o})),createRelations:t=>s(e.post(x.reCreate,{relations:t})),deleteRelations:t=>s(e.post(x.reDelete,{relations:t})),deleteRelationsForResources:t=>s(e.post(x.reDeleteResources,{resources:t})),deleteResourceRelationsForResources:t=>s(e.post(x.reDeleteResourceRelationsForResources,{resources:t})),deleteRelationsForIds:t=>s(e.post(x.reDeleteResources,{resources:t})),hasRelations:t=>s(e.post(x.hasRelations,{relationQueries:t}),(e=>e.relationQueries)),whoCanAccess:(e,t,a)=>s(n(x.who,{resource:e,relationDefinition:t,namespace:a}),(e=>e.targets)),resourceRelations:(t,a=!1)=>s(e.post(x.resource,{resource:t,ignoreTargetSetRelations:a}),(e=>e.relations)),targetsRelations:(t,a=!1)=>s(e.post(x.targets,{targets:t,includeTargetSetRelations:a}),(e=>e.relations)),whatCanTargetAccess:e=>s(n(x.targetAll,{target:e}),(e=>e.relations)),whatCanTargetAccessWithRelation:(t,a,o)=>s(e.post(x.targetWithRelation,{target:t,relationDefinition:a,namespace:o}),(e=>e.resources.map((e=>({resource:e}))))),getModified:t=>s(e.post(x.getModified,{since:t?t.getTime():0}),(e=>e))}},Y=e=>({createOidcApplication:t=>{var a;return s(e.post(b.oidcCreate,Object.assign(Object.assign({},t),{enabled:null===(a=t.enabled)||void 0===a||a})))},createSamlApplication:t=>{var a;return s(e.post(b.samlCreate,Object.assign(Object.assign({},t),{enabled:null===(a=t.enabled)||void 0===a||a})))},updateOidcApplication:t=>s(e.post(b.oidcUpdate,Object.assign({},t))),updateSamlApplication:t=>s(e.post(b.samlUpdate,Object.assign({},t))),createWsFedApplication:t=>{var a;return s(e.post(b.wsfedCreate,Object.assign(Object.assign({},t),{enabled:null===(a=t.enabled)||void 0===a||a})))},updateWsFedApplication:t=>s(e.post(b.wsfedUpdate,Object.assign({},t))),delete:t=>s(e.post(b.delete,{id:t})),load:t=>s(e.get(b.load,{queryParams:{id:t}}),(e=>e)),loadAll:()=>s(e.get(b.loadAll,{}),(e=>e.apps))}),Z=e=>({getSettings:t=>s(e.get(S.settings,{queryParams:{tenantId:t}}),(e=>e)),configureSettings:(t,a)=>s(e.post(S.settings,Object.assign(Object.assign({},a),{tenantId:t})))}),ee=(e,t)=>{var a;const o=null!==(a=null==t?void 0:t.fgaCacheTimeoutMs)&&void 0!==a?a:3e4,r=Number.isFinite(o)&&o>0?o:3e4,n=async(s,a)=>{if((null==t?void 0:t.fgaCacheUrl)&&t.managementKey){const e=`${t.fgaCacheUrl}${s}`,o=new AbortController,n=setTimeout((()=>o.abort()),r);try{const s=await m(e,{method:"POST",headers:Object.assign(Object.assign({},t.headers),{"Content-Type":"application/json",Authorization:`Bearer ${t.projectId}:${t.managementKey}`,"x-descope-project-id":t.projectId}),body:JSON.stringify(a),signal:o.signal});if(s.ok){const e=await s.text();return s.text=()=>Promise.resolve(e),s.json=async()=>JSON.parse(e),s.clone=()=>s,s}}catch(e){}finally{clearTimeout(n)}}return e.post(s,a)};return{saveSchema:e=>s(n(M.schema,e)),deleteSchema:()=>s(e.post(x.schemaDelete,{})),createRelations:e=>s(n(M.relations,{tuples:e})),deleteRelations:e=>s(n(M.deleteRelations,{tuples:e})),check:e=>s(n(M.check,{tuples:e}),(e=>e.tuples)),loadResourcesDetails:t=>s(e.post(M.resourcesLoad,{resourceIdentifiers:t}),(e=>e.resourcesDetails)),saveResourcesDetails:t=>s(e.post(M.resourcesSave,{resourcesDetails:t})),deleteAllRelations:()=>s(e.delete(M.relations))}},te=e=>({createApplication:t=>s(e.post(k.create,Object.assign({},t))),updateApplication:t=>s(e.post(k.update,Object.assign({},t))),patchApplication:t=>s(e.post(k.patch,Object.assign({},t))),deleteApplication:t=>s(e.post(k.delete,{id:t})),loadApplication:t=>s(e.get(k.load,{queryParams:{id:t}}),(e=>e)),loadAllApplications:()=>s(e.get(k.loadAll,{}),(e=>e.apps)),getApplicationSecret:t=>s(e.get(k.secret,{queryParams:{id:t}}),(e=>e)),rotateApplicationSecret:t=>s(e.post(k.rotate,{id:t})),searchConsents:t=>s(e.post(O.search,Object.assign({},t)),(e=>e.consents)),deleteConsents:t=>s(e.post(O.delete,Object.assign({},t)))}),se=e=>({createApplication:t=>s(e.post(T.create,Object.assign({},t)),(e=>e.app)),createApplicationByTemplate:t=>s(e.post(T.createByTemplate,Object.assign({},t)),(e=>e.app)),updateApplication:t=>s(e.post(T.update,{app:t}),(e=>e.app)),deleteApplication:t=>s(e.post(T.delete,{id:t})),loadApplication:t=>s(e.get(`${T.load}/${t}`),(e=>e.app)),loadAllApplications:()=>s(e.get(T.loadAll,{}),(e=>e.apps)),fetchTokenByScopes:(t,a,o,r,n)=>s(e.post(T.fetchTokenByScopes,{appId:t,userId:a,scopes:o,options:r,tenantId:n}),(e=>e.token)),fetchToken:(t,a,o,r)=>s(e.post(T.fetchToken,{appId:t,userId:a,tenantId:o,options:r}),(e=>e.token)),fetchTenantTokenByScopes:(t,a,o,r)=>s(e.post(T.fetchTenantTokenByScopes,{appId:t,tenantId:a,scopes:o,options:r}),(e=>e.token)),fetchTenantToken:(t,a,o)=>s(e.post(T.fetchTenantToken,{appId:t,tenantId:a,options:o}),(e=>e.token)),deleteUserTokens:(t,a)=>s(e.delete(T.deleteUserTokens,{queryParams:{appId:t,userId:a}})),deleteTokenById:t=>s(e.delete(T.deleteTokenById,{queryParams:{id:t}}))}),ae=e=>({create:t=>s(e.put(C.create,{descopers:t}),(e=>({descopers:e.descopers,total:e.total}))),update:(t,a,o)=>s(e.patch(C.update,{id:t,attributes:a,rbac:o}),(e=>e.descoper)),load:t=>s(e.get(C.get,{queryParams:{id:t}}),(e=>e.descoper)),delete:t=>s(e.delete(C.delete,{queryParams:{id:t}})),list:()=>s(e.post(C.list),(e=>({descopers:e.descopers,total:e.total})))}),oe=e=>({create:(t,a,o,r,n)=>s(e.put(D.create,{name:t,description:o,expiresIn:r,permittedIps:n,reBac:a})),update:(t,a,o,r,n)=>s(e.patch(D.update,{id:t,name:a,description:o,permittedIps:n,status:r}),(e=>e.key)),delete:t=>s(e.post(D.delete,{ids:t})),load:t=>s(e.get(D.load,{queryParams:{id:t}}),(e=>e.key)),search:()=>s(e.get(D.search),(e=>e.keys))});const re=d=>{var l,p,h,{authManagementKey:y,managementKey:I,publicKey:b,fgaCacheUrl:k}=d,O=e(d,["authManagementKey","managementKey","publicKey","fgaCacheUrl"]);const T={"x-descope-sdk-name":"nodejs","x-descope-sdk-node-version":(null===(l=null===process||void 0===process?void 0:process.versions)||void 0===l?void 0:l.node)||"","x-descope-sdk-version":"2.9.0"},A=Object.assign(Object.assign({fetch:m},O),{baseHeaders:Object.assign(Object.assign({},O.baseHeaders),T),hooks:Object.assign(Object.assign({},O.hooks),{beforeRequest:[e=>(y&&(e.token=e.token?`${e.token}:${y}`:y),e)].concat((null===(p=O.hooks)||void 0===p?void 0:p.beforeRequest)||[])})}),w=t(A),{projectId:S,logger:j}=O,N={};let R;const P=Object.assign(Object.assign({fetch:m},O),{baseConfig:{baseHeaders:Object.assign(Object.assign({},O.baseHeaders),T)},hooks:Object.assign(Object.assign({},O.hooks),{beforeRequest:[e=>(e.token=I,R&&(e.headers=Object.assign(Object.assign({},e.headers),{"x-descope-license":R})),e)].concat((null===(h=O.hooks)||void 0===h?void 0:h.beforeRequest)||[])})}),U=a(P),E=(M={fgaCacheUrl:k,managementKey:I,projectId:S,headers:T},{user:F(x=U),project:(C=x,{updateName:e=>s(C.post(f.updateName,{name:e})),updateTags:e=>s(C.post(f.updateTags,{tags:e})),clone:(e,t,a)=>s(C.post(f.clone,{name:e,environment:t,tags:a})),listProjects:async()=>s(C.post(f.projectsList,{}),(e=>e.projects.map((({id:e,name:t,environment:s,tags:a})=>({id:e,name:t,environment:s,tags:a}))))),exportSnapshot:()=>s(C.post(f.exportSnapshot,{})),importSnapshot:e=>s(C.post(f.importSnapshot,e)),validateSnapshot:e=>s(C.post(f.validateSnapshot,e)),export:()=>s(C.post(f.exportSnapshot,{}),(e=>e.files)),import:e=>s(C.post(f.importSnapshot,{files:e}))}),accessKey:H(x),tenant:q(x),ssoApplication:Y(x),inboundApplication:te(x),outboundApplication:se(x),sso:W(x),jwt:$(x),permission:z(x),password:Z(x),role:J(x),group:K(x),flow:V(x),theme:Q(x),audit:_(x),authz:X(x,M),fga:ee(x,M),descoper:ae(x),managementKey:oe(x)});var x,M,C;I&&(e=>({get:()=>s(e.get(L.get))}))(U).get().then((e=>{var t;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.rateLimitTier)&&(R=e.data.rateLimitTier)})).catch((e=>{var t;null===(t=null==j?void 0:j.warn)||void 0===t||t.call(j,"License handshake failed",e)}));const D=Object.assign(Object.assign({},w),{refresh:async(e,t)=>w.refresh(e,void 0,t),management:E,async getKey(e){if(!(null==e?void 0:e.kid))throw Error("header.kid must not be empty");if(N[e.kid])return N[e.kid];if(Object.assign(N,await(async()=>{if(b)try{const e=JSON.parse(b),t=await i(e);return{[e.kid]:t}}catch(e){throw null==j||j.error("Failed to parse the provided public key",e),new Error(`Failed to parse public key. Error: ${e}`)}const e=(await w.httpClient.get(`v2/keys/${S}`).then((e=>e.json()))).keys;return Array.isArray(e)?(await Promise.all(e.map((async e=>[e.kid,await i(e)])))).reduce(((e,[t,s])=>t?Object.assign(Object.assign({},e),{[t.toString()]:s}):e),{}):{}})()),!N[e.kid])throw Error("failed to fetch matching key");return N[e.kid]},async validateJwt(e,t){const s={clockTolerance:5};(null==t?void 0:t.audience)&&(s.audience=t.audience);const a=(await r(e,D.getKey,s)).payload;if(a){const e=a.iss;if(!function(e,t){if(e===t)return!0;if(!e||!t)return!1;const s=e=>e[e.length-1]===t||e[e.length-2]===t;try{const{pathname:t}=new URL(e);return s(t.split("/").filter((e=>e.length>0)))}catch(t){return s(e.split("/").filter((e=>e.length>0)))}}("string"==typeof e?e:void 0,S))throw new n.JWTClaimValidationFailed('unexpected "iss" claim value',"iss","check_failed");a.iss=S}return{jwt:e,token:a}},async validateSession(e,t){if(!e)throw Error("session token is required for validation");try{return await D.validateJwt(e,t)}catch(e){throw null==j||j.error("session validation failed",e),Error(`session validation failed. Error: ${e}`)}},async refreshSession(e,t){var s,a,o,r,n,i;if(!e)throw Error("refresh token is required to refresh a session");try{await D.validateJwt(e);const d=await D.refresh(e);if(d.ok){const e=c(null===(a=null===(s=d.data)||void 0===s?void 0:s.cookies)||void 0===a?void 0:a.join(";"),"DS")||(null===(o=d.data)||void 0===o?void 0:o.sessionJwt),i=await D.validateJwt(e,t);return i.cookies=(null===(r=d.data)||void 0===r?void 0:r.cookies)||[],(null===(n=d.data)||void 0===n?void 0:n.refreshJwt)&&(i.refreshJwt=d.data.refreshJwt),i}throw Error(null===(i=d.error)||void 0===i?void 0:i.errorMessage)}catch(e){throw null==j||j.error("refresh token validation failed",e),Error(`refresh token validation failed, Error: ${e}`)}},async validateAndRefreshSession(e,t,s){if(!e&&!t)throw Error("both session and refresh tokens are empty");try{return await D.validateSession(e,s)}catch(e){null==j||j.log(`session validation failed with error ${e} - trying to refresh it`)}return D.refreshSession(t,s)},async exchangeAccessKey(e,t,s){var a;if(!e)throw Error("access key must not be empty");let o;try{o=await D.accessKey.exchange(e,t)}catch(e){throw null==j||j.error("failed to exchange access key",e),Error(`could not exchange access key - Failed to exchange. Error: ${e}`)}if(!o.ok)throw null==j||j.error("failed to exchange access key",o.error),Error(`could not exchange access key - ${null===(a=o.error)||void 0===a?void 0:a.errorMessage}`);const{sessionJwt:r}=o.data;if(!r)throw null==j||j.error("failed to parse exchange access key response"),Error("could not exchange access key");try{return await D.validateJwt(r,s)}catch(e){throw null==j||j.error("failed to parse jwt from access key",e),Error(`could not exchange access key - failed to validate jwt. Error: ${e}`)}},validatePermissions:(e,t)=>D.validateTenantPermissions(e,"",t),getMatchedPermissions:(e,t)=>D.getMatchedTenantPermissions(e,"",t),validateTenantPermissions(e,t,s){if(t&&!v(e,t))return!1;const a=g(e,"permissions",t);return s.every((e=>a.includes(e)))},getMatchedTenantPermissions(e,t,s){if(t&&!v(e,t))return[];const a=g(e,"permissions",t);return s.filter((e=>a.includes(e)))},validateRoles:(e,t)=>D.validateTenantRoles(e,"",t),getMatchedRoles:(e,t)=>D.getMatchedTenantRoles(e,"",t),validateTenantRoles(e,t,s){if(t&&!v(e,t))return!1;const a=g(e,"roles",t);return s.every((e=>a.includes(e)))},getMatchedTenantRoles(e,t,s){if(t&&!v(e,t))return[];const a=g(e,"roles",t);return s.filter((e=>a.includes(e)))}});return o(D,["otp.verify.email","otp.verify.sms","otp.verify.voice","otp.verify.whatsapp","otp.verify.im","notp.waitForSession","magicLink.verify","enchantedLink.signUp","enchantedLink.signIn","enchantedLink.waitForSession","oauth.exchangeOneTapIDToken","password.signIn","password.signUp","password.replace","oauth.exchange","saml.exchange","totp.verify","selectTenant","webauthn.signIn.finish","webauthn.signUp.finish","refresh"],u)};re.RefreshTokenCookieName="DSR",re.SessionTokenCookieName="DS",re.DescopeErrors={badRequest:"E011001",missingArguments:"E011002",invalidRequest:"E011003",invalidArguments:"E011004",wrongOTPCode:"E061102",tooManyOTPAttempts:"E061103",enchantedLinkPending:"E062503",userNotFound:"E062108"};export{re as default};
2
2
  //# sourceMappingURL=index.esm.js.map