@asgardeo/javascript 0.1.19 → 0.1.21
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/AsgardeoJavaScriptClient.d.ts +1 -0
- package/dist/__legacy__/models/client-config.d.ts +1 -1
- package/dist/api/v2/executeEmbeddedSignInFlowV2.d.ts +20 -0
- package/dist/cjs/index.js +132 -0
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +19 -0
- package/dist/models/config.d.ts +7 -0
- package/dist/models/embedded-flow.d.ts +1 -0
- package/dist/models/platforms.d.ts +2 -0
- package/dist/models/v2/embedded-signin-flow-v2.d.ts +78 -0
- package/dist/utils/arrayBufferToBase64url.d.ts +48 -0
- package/dist/utils/base64urlToArrayBuffer.d.ts +55 -0
- package/package.json +2 -2
package/dist/models/client.d.ts
CHANGED
|
@@ -40,6 +40,11 @@ export interface AsgardeoClient<T> {
|
|
|
40
40
|
* @returns Associated organizations.
|
|
41
41
|
*/
|
|
42
42
|
getMyOrganizations(options?: any, sessionId?: string): Promise<Organization[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets all organizations available to the user.
|
|
45
|
+
* @param options - Optional parameters for the request.
|
|
46
|
+
* @param sessionId - Optional session ID to be used for the request.
|
|
47
|
+
*/
|
|
43
48
|
getAllOrganizations(options?: any, sessionId?: string): Promise<AllOrganizationsApiResponse>;
|
|
44
49
|
/**
|
|
45
50
|
* Gets the current organization of the user.
|
|
@@ -53,6 +58,10 @@ export interface AsgardeoClient<T> {
|
|
|
53
58
|
* @returns A promise that resolves when the switch is complete.
|
|
54
59
|
*/
|
|
55
60
|
switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the client configuration.
|
|
63
|
+
* @returns The client configuration.
|
|
64
|
+
*/
|
|
56
65
|
getConfiguration(): T;
|
|
57
66
|
/**
|
|
58
67
|
* Swaps the current access token with a new one based on the provided configuration (with a grant type).
|
|
@@ -60,6 +69,11 @@ export interface AsgardeoClient<T> {
|
|
|
60
69
|
* @param sessionId - Optional session ID to be used for the token exchange.
|
|
61
70
|
*/
|
|
62
71
|
exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response>;
|
|
72
|
+
/**
|
|
73
|
+
* Updates the user profile with the provided payload.
|
|
74
|
+
* @param payload - The new user profile data.
|
|
75
|
+
* @param userId - Optional user ID to specify which user's profile to update.
|
|
76
|
+
*/
|
|
63
77
|
updateUserProfile(payload: any, userId?: string): Promise<User>;
|
|
64
78
|
/**
|
|
65
79
|
* Gets user information from the session.
|
|
@@ -172,4 +186,9 @@ export interface AsgardeoClient<T> {
|
|
|
172
186
|
* @returns A promise that resolves to the access token string.
|
|
173
187
|
*/
|
|
174
188
|
getAccessToken(sessionId?: string): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* Clears the session for the specified session ID.
|
|
191
|
+
* @param sessionId - Optional session ID to clear the session for.
|
|
192
|
+
*/
|
|
193
|
+
clearSession(sessionId?: string): void;
|
|
175
194
|
}
|
package/dist/models/config.d.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { I18nBundle } from '@asgardeo/i18n';
|
|
19
19
|
import { RecursivePartial } from './utility-types';
|
|
20
20
|
import { ThemeConfig, ThemeMode } from '../theme/types';
|
|
21
|
+
import { Platform } from './platforms';
|
|
21
22
|
/**
|
|
22
23
|
* Interface representing the additional parameters to be sent in the sign-in request.
|
|
23
24
|
* This can include custom parameters that your authorization server supports.
|
|
@@ -100,6 +101,12 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
|
|
|
100
101
|
* Not recommended for public clients like browser applications.
|
|
101
102
|
*/
|
|
102
103
|
clientSecret?: string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Optional platform where the application is running.
|
|
106
|
+
* This helps the SDK to optimize its behavior based on the platform.
|
|
107
|
+
* If not provided, the SDK will attempt to auto-detect the platform.
|
|
108
|
+
*/
|
|
109
|
+
platform?: keyof typeof Platform;
|
|
103
110
|
/**
|
|
104
111
|
* The scopes to request during authentication.
|
|
105
112
|
* Accepts either a space-separated string or an array of strings.
|
|
@@ -30,6 +30,8 @@ export declare enum Platform {
|
|
|
30
30
|
Asgardeo = "ASGARDEO",
|
|
31
31
|
/** WSO2 Identity Server (on-prem or custom domains) */
|
|
32
32
|
IdentityServer = "IDENTITY_SERVER",
|
|
33
|
+
/** @experimental WSO2 Asgardeo V2 */
|
|
34
|
+
AsgardeoV2 = "AsgardeoV2",
|
|
33
35
|
/** Unknown or unsupported platform */
|
|
34
36
|
Unknown = "UNKNOWN"
|
|
35
37
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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, EmbeddedFlowResponseType, EmbeddedFlowType } from '../embedded-flow';
|
|
19
|
+
export declare enum EmbeddedSignInFlowStatusV2 {
|
|
20
|
+
Complete = "COMPLETE",
|
|
21
|
+
Incomplete = "INCOMPLETE",
|
|
22
|
+
Error = "ERROR"
|
|
23
|
+
}
|
|
24
|
+
export declare enum EmbeddedSignInFlowTypeV2 {
|
|
25
|
+
Redirection = "REDIRECTION",
|
|
26
|
+
View = "VIEW"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Response structure for the new Asgardeo V2 embedded sign-in flow.
|
|
30
|
+
* @experimental
|
|
31
|
+
*/
|
|
32
|
+
export interface EmbeddedSignInFlowResponseV2 {
|
|
33
|
+
flowId: string;
|
|
34
|
+
flowStatus: EmbeddedSignInFlowStatusV2;
|
|
35
|
+
type: EmbeddedSignInFlowTypeV2;
|
|
36
|
+
data: {
|
|
37
|
+
actions?: {
|
|
38
|
+
type: EmbeddedFlowResponseType;
|
|
39
|
+
id: string;
|
|
40
|
+
}[];
|
|
41
|
+
inputs?: {
|
|
42
|
+
name: string;
|
|
43
|
+
type: string;
|
|
44
|
+
required: boolean;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Response structure for the new Asgardeo V2 embedded sign-in flow when the flow is complete.
|
|
50
|
+
* @experimental
|
|
51
|
+
*/
|
|
52
|
+
export interface EmbeddedSignInFlowCompleteResponse {
|
|
53
|
+
redirect_uri: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request payload for initiating the new Asgardeo V2 embedded sign-in flow.
|
|
57
|
+
* @experimental
|
|
58
|
+
*/
|
|
59
|
+
export type EmbeddedSignInFlowInitiateRequestV2 = {
|
|
60
|
+
applicationId: string;
|
|
61
|
+
flowType: EmbeddedFlowType;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Request payload for executing steps in the new Asgardeo V2 embedded sign-in flow.
|
|
65
|
+
* @experimental
|
|
66
|
+
*/
|
|
67
|
+
export interface EmbeddedSignInFlowRequestV2 extends Partial<EmbeddedSignInFlowInitiateRequestV2> {
|
|
68
|
+
flowId?: string;
|
|
69
|
+
actionId?: string;
|
|
70
|
+
inputs?: Record<string, any>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Request config for executing the new Asgardeo V2 embedded sign-in flow.
|
|
74
|
+
* @experimental
|
|
75
|
+
*/
|
|
76
|
+
export interface EmbeddedFlowExecuteRequestConfigV2<T = any> extends EmbeddedFlowExecuteRequestConfig<T> {
|
|
77
|
+
sessionDataKey?: string;
|
|
78
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
* Converts an ArrayBuffer to a base64url encoded string.
|
|
20
|
+
*
|
|
21
|
+
* Base64url encoding is a URL-safe variant of base64 encoding that:
|
|
22
|
+
* - Replaces '+' with '-'
|
|
23
|
+
* - Replaces '/' with '_'
|
|
24
|
+
* - Removes padding '=' characters
|
|
25
|
+
*
|
|
26
|
+
* This encoding is commonly used in JWT tokens, OAuth2 PKCE challenges,
|
|
27
|
+
* and other web standards where the encoded data needs to be safely
|
|
28
|
+
* transmitted in URLs or HTTP headers.
|
|
29
|
+
*
|
|
30
|
+
* @param buffer - The ArrayBuffer to convert to base64url string
|
|
31
|
+
* @returns The base64url encoded string representation of the input buffer
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const buffer = new TextEncoder().encode('Hello World');
|
|
36
|
+
* const encoded = arrayBufferToBase64url(buffer);
|
|
37
|
+
* console.log(encoded); // "SGVsbG8gV29ybGQ"
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Converting crypto random bytes for PKCE challenge
|
|
43
|
+
* const randomBytes = crypto.getRandomValues(new Uint8Array(32));
|
|
44
|
+
* const codeVerifier = arrayBufferToBase64url(randomBytes.buffer);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare const arrayBufferToBase64url: (buffer: ArrayBuffer) => string;
|
|
48
|
+
export default arrayBufferToBase64url;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
* Converts a base64url encoded string back to an ArrayBuffer.
|
|
20
|
+
*
|
|
21
|
+
* This function performs the inverse operation of base64url encoding by:
|
|
22
|
+
* - Replacing URL-safe characters: '-' becomes '+', '_' becomes '/'
|
|
23
|
+
* - Adding back padding '=' characters that were removed during base64url encoding
|
|
24
|
+
* - Decoding the resulting base64 string to binary data
|
|
25
|
+
* - Converting the binary data to an ArrayBuffer
|
|
26
|
+
*
|
|
27
|
+
* This is commonly used for decoding JWT tokens, OAuth2 PKCE code verifiers,
|
|
28
|
+
* and other cryptographic data that was encoded using base64url format.
|
|
29
|
+
*
|
|
30
|
+
* @param base64url - The base64url encoded string to decode
|
|
31
|
+
* @returns The ArrayBuffer containing the decoded binary data
|
|
32
|
+
*
|
|
33
|
+
* @throws {DOMException} Throws an error if the input string is not valid base64url
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const encoded = 'SGVsbG8gV29ybGQ';
|
|
38
|
+
* const buffer = base64urlToArrayBuffer(encoded);
|
|
39
|
+
* const text = new TextDecoder().decode(buffer);
|
|
40
|
+
* console.log(text); // "Hello World"
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Decoding a JWT payload
|
|
46
|
+
* const jwtPayload = 'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ';
|
|
47
|
+
* const payloadBuffer = base64urlToArrayBuffer(jwtPayload);
|
|
48
|
+
* const payloadJson = new TextDecoder().decode(payloadBuffer);
|
|
49
|
+
* const payload = JSON.parse(payloadJson);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @see {@link arrayBufferToBase64url} - The inverse function for encoding ArrayBuffer to base64url
|
|
53
|
+
*/
|
|
54
|
+
declare const base64urlToArrayBuffer: (base64url: string) => ArrayBuffer;
|
|
55
|
+
export default base64urlToArrayBuffer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/javascript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Framework agnostic JavaScript SDK for Asgardeo.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"asgardeo",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"tslib": "^2.8.1",
|
|
49
|
-
"@asgardeo/i18n": "^0.
|
|
49
|
+
"@asgardeo/i18n": "^0.3.1"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|