@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
@@ -15,9 +15,12 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { AsgardeoClient, SignInOptions, SignOutOptions } from './models/client';
19
- import { User, UserProfile } from './models/user';
18
+ import { AsgardeoClient, SignInOptions, SignOutOptions, SignUpOptions } from './models/client';
20
19
  import { Config } from './models/config';
20
+ import { EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from './models/embedded-flow';
21
+ import { EmbeddedSignInFlowHandleRequestPayload } from './models/embedded-signin-flow';
22
+ import { Organization } from './models/organization';
23
+ import { User, UserProfile } from './models/user';
21
24
  /**
22
25
  * Base class for implementing Asgardeo clients.
23
26
  * This class provides the core functionality for managing user authentication and sessions.
@@ -25,58 +28,21 @@ import { Config } from './models/config';
25
28
  * @typeParam T - Configuration type that extends Config.
26
29
  */
27
30
  declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T> {
28
- /**
29
- * Initializes the authentication client with provided configuration.
30
- *
31
- * @param config - SDK Client instance configuration options.
32
- * @returns Promise resolving to boolean indicating success.
33
- */
31
+ abstract switchOrganization(organization: Organization): Promise<void>;
34
32
  abstract initialize(config: T): Promise<boolean>;
35
- /**
36
- * Gets user information from the session.
37
- *
38
- * @returns User object containing user details.
39
- */
40
33
  abstract getUser(): Promise<User>;
34
+ abstract getOrganizations(): Promise<Organization[]>;
35
+ abstract getCurrentOrganization(): Promise<Organization | null>;
41
36
  abstract getUserProfile(): Promise<UserProfile>;
42
- /**
43
- * Checks if the client is currently loading.
44
- * This can be used to determine if the client is in the process of initializing or fetching user data.
45
- *
46
- * @returns Boolean indicating if the client is loading.
47
- */
48
37
  abstract isLoading(): boolean;
49
- /**
50
- * Checks if a user is signed in.
51
- * FIXME: Check if this should return a boolean or a Promise<boolean>.
52
- *
53
- * @returns Promise resolving to boolean indicating sign-in status.
54
- */
55
38
  abstract isSignedIn(): Promise<boolean>;
56
- /**
57
- * Initiates the sign-in process for the user.
58
- *
59
- * @param options - Optional sign-in options like additional parameters to be sent in the authorize request, etc.
60
- * @returns Promise resolving the user upon successful sign in.
61
- */
62
- abstract signIn(options?: SignInOptions): Promise<User>;
63
- /**
64
- * Signs out the currently signed-in user.
65
- *
66
- * @param options - Optional sign-out options like additional parameters to be sent in the sign-out request, etc.
67
- * @param afterSignOut - Callback function to be executed after sign-out is complete.
68
- * @returns A promise that resolves to true if sign-out is successful
69
- */
70
- abstract signOut(options?: SignOutOptions, afterSignOut?: (redirectUrl: string) => void): Promise<string>;
71
- /**
72
- * Signs out the currently signed-in user with an optional session ID.
73
- *
74
- * @param options - Optional sign-out options like additional parameters to be sent in the sign-out request, etc.
75
- * @param sessionId - Optional session ID to be used for sign-out.
76
- * This can be useful in scenarios where multiple sessions are managed.
77
- * @param afterSignOut - Callback function to be executed after sign-out is complete.
78
- * @returns A promise that resolves to true if sign-out is successful
79
- */
80
- abstract signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (redirectUrl: string) => void): Promise<string>;
39
+ abstract getConfiguration(): T;
40
+ abstract signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
41
+ abstract signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: Request, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
42
+ abstract signOut(options?: SignOutOptions, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
43
+ abstract signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
44
+ abstract signUp(options?: SignUpOptions): Promise<void>;
45
+ abstract signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
46
+ abstract signUp(payload?: unknown): Promise<void> | Promise<EmbeddedFlowExecuteResponse>;
81
47
  }
82
48
  export default AsgardeoJavaScriptClient;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { Crypto, JWKInterface } from './models/crypto';
19
- import { IdTokenPayload } from './models/token';
19
+ import { IdToken } from './models/token';
20
20
  export declare class IsomorphicCrypto<T = any> {
21
21
  private _cryptoUtils;
22
22
  constructor(cryptoUtils: Crypto<T>);
@@ -69,5 +69,5 @@ export declare class IsomorphicCrypto<T = any> {
69
69
  *
70
70
  * @throws
71
71
  */
72
- decodeIdToken(idToken: string): IdTokenPayload;
72
+ decodeIdToken(idToken: string): IdToken;
73
73
  }
@@ -37,7 +37,7 @@ declare class StorageManager<T> {
37
37
  setTemporaryData(temporaryData: Partial<TemporaryStore>, userId?: string): Promise<void>;
38
38
  setSessionData(sessionData: Partial<SessionData>, userId?: string): Promise<void>;
39
39
  setCustomData<K>(key: string, customData: Partial<K>, userId?: string): Promise<void>;
40
- getConfigData(): Promise<AuthClientConfig<T>>;
40
+ getConfigData(userId?: string): Promise<AuthClientConfig<T>>;
41
41
  loadOpenIDProviderConfiguration(): Promise<OIDCDiscoveryApiResponse>;
42
42
  getTemporaryData(userId?: string): Promise<TemporaryStore>;
43
43
  getSessionData(userId?: string): Promise<SessionData>;
@@ -19,7 +19,7 @@ import StorageManager from '../StorageManager';
19
19
  import { AuthClientConfig } from './models';
20
20
  import { ExtendedAuthorizeRequestUrlParams } from '../models/oauth-request';
21
21
  import { Crypto } from '../models/crypto';
22
- import { TokenResponse, IdTokenPayload, TokenExchangeRequestConfig } from '../models/token';
22
+ import { TokenResponse, IdToken, TokenExchangeRequestConfig } from '../models/token';
23
23
  import { OIDCEndpoints } from '../models/oidc-endpoints';
24
24
  import { Storage } from '../models/store';
25
25
  import { IsomorphicCrypto } from '../IsomorphicCrypto';
@@ -206,7 +206,7 @@ export declare class AsgardeoAuthClient<T> {
206
206
  *
207
207
  * @preserve
208
208
  */
209
- getDecodedIdToken(userId?: string): Promise<IdTokenPayload>;
209
+ getDecodedIdToken(userId?: string): Promise<IdToken>;
210
210
  /**
211
211
  * This method returns the ID token.
212
212
  *
@@ -16,10 +16,10 @@
16
16
  * under the License.
17
17
  */
18
18
  import { IsomorphicCrypto } from '../../IsomorphicCrypto';
19
- import StorageManager from '../../StorageManager';
20
- import { User } from '../../models/user';
21
- import { TokenResponse } from '../../models/token';
22
19
  import { OIDCDiscoveryEndpointsApiResponse, OIDCDiscoveryApiResponse } from '../../models/oidc-discovery';
20
+ import { TokenResponse } from '../../models/token';
21
+ import { User } from '../../models/user';
22
+ import StorageManager from '../../StorageManager';
23
23
  export declare class AuthenticationHelper<T> {
24
24
  private _storageManager;
25
25
  private _config;
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Organization } from '../models/organization';
19
+ /**
20
+ * Interface for organization creation payload.
21
+ */
22
+ export interface CreateOrganizationPayload {
23
+ /**
24
+ * Organization description.
25
+ */
26
+ description: string;
27
+ /**
28
+ * Organization handle/slug.
29
+ */
30
+ orgHandle?: string;
31
+ /**
32
+ * Organization name.
33
+ */
34
+ name: string;
35
+ /**
36
+ * Parent organization ID.
37
+ */
38
+ parentId: string;
39
+ /**
40
+ * Organization type.
41
+ */
42
+ type: 'TENANT';
43
+ }
44
+ /**
45
+ * Configuration for the createOrganization request
46
+ */
47
+ export interface CreateOrganizationConfig extends Omit<RequestInit, 'method' | 'body'> {
48
+ /**
49
+ * The base URL for the API endpoint.
50
+ */
51
+ baseUrl: string;
52
+ /**
53
+ * Organization creation payload
54
+ */
55
+ payload: CreateOrganizationPayload;
56
+ /**
57
+ * Optional custom fetcher function.
58
+ * If not provided, native fetch will be used
59
+ */
60
+ fetcher?: (url: string, config: RequestInit) => Promise<Response>;
61
+ }
62
+ /**
63
+ * Creates a new organization.
64
+ *
65
+ * @param config - Configuration object containing baseUrl, payload and optional request config.
66
+ * @returns A promise that resolves with the created organization information.
67
+ * @example
68
+ * ```typescript
69
+ * // Using default fetch
70
+ * try {
71
+ * const organization = await createOrganization({
72
+ * baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
73
+ * payload: {
74
+ * description: "Share your screens",
75
+ * name: "Team Viewer",
76
+ * orgHandle: "team-viewer",
77
+ * parentId: "f4825104-4948-40d9-ab65-a960eee3e3d5",
78
+ * type: "TENANT"
79
+ * }
80
+ * });
81
+ * console.log(organization);
82
+ * } catch (error) {
83
+ * if (error instanceof AsgardeoAPIError) {
84
+ * console.error('Failed to create organization:', error.message);
85
+ * }
86
+ * }
87
+ * ```
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // Using custom fetcher (e.g., axios-based httpClient)
92
+ * try {
93
+ * const organization = await createOrganization({
94
+ * baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
95
+ * payload: {
96
+ * description: "Share your screens",
97
+ * name: "Team Viewer",
98
+ * orgHandle: "team-viewer",
99
+ * parentId: "f4825104-4948-40d9-ab65-a960eee3e3d5",
100
+ * type: "TENANT"
101
+ * },
102
+ * fetcher: async (url, config) => {
103
+ * const response = await httpClient({
104
+ * url,
105
+ * method: config.method,
106
+ * headers: config.headers,
107
+ * data: config.body,
108
+ * ...config
109
+ * });
110
+ * // Convert axios-like response to fetch-like Response
111
+ * return {
112
+ * ok: response.status >= 200 && response.status < 300,
113
+ * status: response.status,
114
+ * statusText: response.statusText,
115
+ * json: () => Promise.resolve(response.data),
116
+ * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
117
+ * } as Response;
118
+ * }
119
+ * });
120
+ * console.log(organization);
121
+ * } catch (error) {
122
+ * if (error instanceof AsgardeoAPIError) {
123
+ * console.error('Failed to create organization:', error.message);
124
+ * }
125
+ * }
126
+ * ```
127
+ */
128
+ declare const createOrganization: ({ baseUrl, payload, fetcher, ...requestConfig }: CreateOrganizationConfig) => Promise<Organization>;
129
+ export default createOrganization;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { EmbeddedFlowExecuteRequestConfig } from '../models/embedded-flow';
19
+ import { EmbeddedSignInFlowHandleResponse } from '../models/embedded-signin-flow';
20
+ declare const executeEmbeddedSignInFlow: ({ url, baseUrl, payload, ...requestConfig }: EmbeddedFlowExecuteRequestConfig) => Promise<EmbeddedSignInFlowHandleResponse>;
21
+ export default executeEmbeddedSignInFlow;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { EmbeddedFlowExecuteResponse, EmbeddedFlowExecuteRequestConfig } from '../models/embedded-flow';
19
+ /**
20
+ * Executes an embedded signup flow by sending a request to the specified flow execution endpoint.
21
+ *
22
+ * @param requestConfig - Request configuration object containing URL and payload.
23
+ * @returns A promise that resolves with the flow execution response.
24
+ * @throws AsgardeoAPIError when the request fails or URL is invalid.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * try {
29
+ * const embeddedSignUpResponse = await executeEmbeddedSignUpFlow({
30
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/api/server/v1/flow/execute",
31
+ * payload: {
32
+ * flowType: "REGISTRATION"
33
+ * }
34
+ * });
35
+ * console.log(embeddedSignUpResponse);
36
+ * } catch (error) {
37
+ * if (error instanceof AsgardeoAPIError) {
38
+ * console.error('Embedded SignUp flow execution failed:', error.message);
39
+ * }
40
+ * }
41
+ * ```
42
+ */
43
+ declare const executeEmbeddedSignUpFlow: ({ url, baseUrl, payload, ...requestConfig }: EmbeddedFlowExecuteRequestConfig) => Promise<EmbeddedFlowExecuteResponse>;
44
+ export default executeEmbeddedSignUpFlow;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Organization } from '../models/organization';
19
+ /**
20
+ * Interface for paginated organization response.
21
+ */
22
+ export interface PaginatedOrganizationsResponse {
23
+ hasMore?: boolean;
24
+ nextCursor?: string;
25
+ organizations: Organization[];
26
+ totalCount?: number;
27
+ }
28
+ /**
29
+ * Configuration for the getAllOrganizations request
30
+ */
31
+ export interface GetAllOrganizationsConfig extends Omit<RequestInit, 'method'> {
32
+ /**
33
+ * The base URL for the API endpoint.
34
+ */
35
+ baseUrl: string;
36
+ /**
37
+ * Filter expression for organizations
38
+ */
39
+ filter?: string;
40
+ /**
41
+ * Maximum number of organizations to return
42
+ */
43
+ limit?: number;
44
+ /**
45
+ * Whether to include child organizations recursively
46
+ */
47
+ recursive?: boolean;
48
+ /**
49
+ * Optional custom fetcher function.
50
+ * If not provided, native fetch will be used
51
+ */
52
+ fetcher?: (url: string, config: RequestInit) => Promise<Response>;
53
+ }
54
+ /**
55
+ * Retrieves all organizations with pagination support.
56
+ *
57
+ * @param config - Configuration object containing baseUrl, optional query parameters, and request config.
58
+ * @returns A promise that resolves with the paginated organizations information.
59
+ * @example
60
+ * ```typescript
61
+ * // Using default fetch
62
+ * try {
63
+ * const response = await getAllOrganizations({
64
+ * baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
65
+ * filter: "",
66
+ * limit: 10,
67
+ * recursive: false
68
+ * });
69
+ * console.log(response.organizations);
70
+ * } catch (error) {
71
+ * if (error instanceof AsgardeoAPIError) {
72
+ * console.error('Failed to get organizations:', error.message);
73
+ * }
74
+ * }
75
+ * ```
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Using custom fetcher (e.g., axios-based httpClient)
80
+ * try {
81
+ * const response = await getAllOrganizations({
82
+ * baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
83
+ * filter: "",
84
+ * limit: 10,
85
+ * recursive: false,
86
+ * fetcher: async (url, config) => {
87
+ * const response = await httpClient({
88
+ * url,
89
+ * method: config.method,
90
+ * headers: config.headers,
91
+ * ...config
92
+ * });
93
+ * // Convert axios-like response to fetch-like Response
94
+ * return {
95
+ * ok: response.status >= 200 && response.status < 300,
96
+ * status: response.status,
97
+ * statusText: response.statusText,
98
+ * json: () => Promise.resolve(response.data),
99
+ * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
100
+ * } as Response;
101
+ * }
102
+ * });
103
+ * console.log(response.organizations);
104
+ * } catch (error) {
105
+ * if (error instanceof AsgardeoAPIError) {
106
+ * console.error('Failed to get organizations:', error.message);
107
+ * }
108
+ * }
109
+ * ```
110
+ */
111
+ declare const getAllOrganizations: ({ baseUrl, filter, limit, recursive, fetcher, ...requestConfig }: GetAllOrganizationsConfig) => Promise<PaginatedOrganizationsResponse>;
112
+ export default getAllOrganizations;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Organization } from '../models/organization';
19
+ /**
20
+ * Configuration for the getMeOrganizations request
21
+ */
22
+ export interface GetMeOrganizationsConfig extends Omit<RequestInit, 'method'> {
23
+ /**
24
+ * The base URL for the API endpoint.
25
+ */
26
+ baseUrl: string;
27
+ /**
28
+ * Base64 encoded cursor value for forward pagination
29
+ */
30
+ after?: string;
31
+ /**
32
+ * Authorized application name filter
33
+ */
34
+ authorizedAppName?: string;
35
+ /**
36
+ * Base64 encoded cursor value for backward pagination
37
+ */
38
+ before?: string;
39
+ /**
40
+ * Filter expression for organizations
41
+ */
42
+ filter?: string;
43
+ /**
44
+ * Maximum number of organizations to return
45
+ */
46
+ limit?: number;
47
+ /**
48
+ * Whether to include child organizations recursively
49
+ */
50
+ recursive?: boolean;
51
+ /**
52
+ * Optional custom fetcher function.
53
+ * If not provided, native fetch will be used
54
+ */
55
+ fetcher?: (url: string, config: RequestInit) => Promise<Response>;
56
+ }
57
+ /**
58
+ * Retrieves the organizations associated with the current user.
59
+ *
60
+ * @param config - Configuration object containing baseUrl, optional query parameters, and request config.
61
+ * @returns A promise that resolves with the organizations information.
62
+ * @example
63
+ * ```typescript
64
+ * // Using default fetch
65
+ * try {
66
+ * const organizations = await getMeOrganizations({
67
+ * baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
68
+ * after: "",
69
+ * before: "",
70
+ * filter: "",
71
+ * limit: 10,
72
+ * recursive: false
73
+ * });
74
+ * console.log(organizations);
75
+ * } catch (error) {
76
+ * if (error instanceof AsgardeoAPIError) {
77
+ * console.error('Failed to get organizations:', error.message);
78
+ * }
79
+ * }
80
+ * ```
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Using custom fetcher (e.g., axios-based httpClient)
85
+ * try {
86
+ * const organizations = await getMeOrganizations({
87
+ * baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
88
+ * after: "",
89
+ * before: "",
90
+ * filter: "",
91
+ * limit: 10,
92
+ * recursive: false,
93
+ * fetcher: async (url, config) => {
94
+ * const response = await httpClient({
95
+ * url,
96
+ * method: config.method,
97
+ * headers: config.headers,
98
+ * ...config
99
+ * });
100
+ * // Convert axios-like response to fetch-like Response
101
+ * return {
102
+ * ok: response.status >= 200 && response.status < 300,
103
+ * status: response.status,
104
+ * statusText: response.statusText,
105
+ * json: () => Promise.resolve(response.data),
106
+ * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
107
+ * } as Response;
108
+ * }
109
+ * });
110
+ * console.log(organizations);
111
+ * } catch (error) {
112
+ * if (error instanceof AsgardeoAPIError) {
113
+ * console.error('Failed to get organizations:', error.message);
114
+ * }
115
+ * }
116
+ * ```
117
+ */
118
+ declare const getMeOrganizations: ({ baseUrl, after, authorizedAppName, before, filter, limit, recursive, fetcher, ...requestConfig }: GetMeOrganizationsConfig) => Promise<Organization[]>;
119
+ export default getMeOrganizations;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ /**
19
+ * Extended organization interface with additional properties
20
+ */
21
+ export interface OrganizationDetails {
22
+ attributes?: Record<string, any>;
23
+ created?: string;
24
+ description?: string;
25
+ id: string;
26
+ lastModified?: string;
27
+ name: string;
28
+ orgHandle: string;
29
+ parent?: {
30
+ id: string;
31
+ ref: string;
32
+ };
33
+ permissions?: string[];
34
+ status?: string;
35
+ type?: string;
36
+ }
37
+ /**
38
+ * Configuration for the getOrganization request
39
+ */
40
+ export interface GetOrganizationConfig extends Omit<RequestInit, 'method'> {
41
+ /**
42
+ * The base URL for the API endpoint.
43
+ */
44
+ baseUrl: string;
45
+ /**
46
+ * The ID of the organization to retrieve
47
+ */
48
+ organizationId: string;
49
+ /**
50
+ * Optional custom fetcher function.
51
+ * If not provided, native fetch will be used
52
+ */
53
+ fetcher?: (url: string, config: RequestInit) => Promise<Response>;
54
+ }
55
+ /**
56
+ * Retrieves detailed information for a specific organization.
57
+ *
58
+ * @param config - Configuration object containing baseUrl, organizationId, and request config.
59
+ * @returns A promise that resolves with the organization details.
60
+ * @example
61
+ * ```typescript
62
+ * // Using default fetch
63
+ * try {
64
+ * const organization = await getOrganization({
65
+ * baseUrl: "https://api.asgardeo.io/t/dxlab",
66
+ * organizationId: "0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1"
67
+ * });
68
+ * console.log(organization);
69
+ * } catch (error) {
70
+ * if (error instanceof AsgardeoAPIError) {
71
+ * console.error('Failed to get organization:', error.message);
72
+ * }
73
+ * }
74
+ * ```
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * // Using custom fetcher (e.g., axios-based httpClient)
79
+ * try {
80
+ * const organization = await getOrganization({
81
+ * baseUrl: "https://api.asgardeo.io/t/dxlab",
82
+ * organizationId: "0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1",
83
+ * fetcher: async (url, config) => {
84
+ * const response = await httpClient({
85
+ * url,
86
+ * method: config.method,
87
+ * headers: config.headers,
88
+ * ...config
89
+ * });
90
+ * // Convert axios-like response to fetch-like Response
91
+ * return {
92
+ * ok: response.status >= 200 && response.status < 300,
93
+ * status: response.status,
94
+ * statusText: response.statusText,
95
+ * json: () => Promise.resolve(response.data),
96
+ * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
97
+ * } as Response;
98
+ * }
99
+ * });
100
+ * console.log(organization);
101
+ * } catch (error) {
102
+ * if (error instanceof AsgardeoAPIError) {
103
+ * console.error('Failed to get organization:', error.message);
104
+ * }
105
+ * }
106
+ * ```
107
+ */
108
+ declare const getOrganization: ({ baseUrl, organizationId, fetcher, ...requestConfig }: GetOrganizationConfig) => Promise<OrganizationDetails>;
109
+ export default getOrganization;