@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.
- package/dist/AsgardeoJavaScriptClient.d.ts +16 -50
- package/dist/IsomorphicCrypto.d.ts +2 -2
- package/dist/StorageManager.d.ts +1 -1
- package/dist/__legacy__/client.d.ts +2 -2
- package/dist/__legacy__/helpers/authentication-helper.d.ts +3 -3
- package/dist/api/createOrganization.d.ts +129 -0
- package/dist/api/executeEmbeddedSignInFlow.d.ts +21 -0
- package/dist/api/executeEmbeddedSignUpFlow.d.ts +44 -0
- package/dist/api/getAllOrganizations.d.ts +112 -0
- package/dist/api/getMeOrganizations.d.ts +119 -0
- package/dist/api/getOrganization.d.ts +109 -0
- package/dist/api/getSchemas.d.ts +89 -0
- package/dist/api/getScim2Me.d.ts +89 -0
- package/dist/api/initializeEmbeddedSignInFlow.d.ts +51 -0
- package/dist/api/updateMeProfile.d.ts +82 -0
- package/dist/api/updateOrganization.d.ts +118 -0
- package/dist/cjs/index.js +966 -146
- package/dist/cjs/index.js.map +4 -4
- package/dist/constants/OIDCRequestConstants.d.ts +1 -1
- package/dist/constants/ScopeConstants.d.ts +3 -6
- package/dist/constants/TokenExchangeConstants.d.ts +2 -2
- package/dist/constants/VendorConstants.d.ts +31 -0
- package/dist/index.d.ts +20 -5
- package/dist/index.js +939 -137
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +52 -3
- package/dist/models/config.d.ts +36 -12
- package/dist/models/embedded-flow.d.ts +66 -0
- package/dist/models/embedded-signin-flow.d.ts +99 -0
- package/dist/models/flow.d.ts +30 -0
- package/dist/models/i18n.d.ts +24 -0
- package/dist/models/organization.d.ts +24 -0
- package/dist/models/token.d.ts +42 -30
- package/dist/theme/createTheme.d.ts +1 -1
- package/dist/theme/types.d.ts +29 -16
- package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +2 -2
- package/dist/utils/extractUserClaimsFromIdToken.d.ts +2 -2
- package/dist/utils/generateFlattenedUserProfile.d.ts +9 -2
- package/dist/utils/isEmpty.d.ts +48 -0
- package/dist/utils/withVendorCSSClassPrefix.d.ts +32 -0
- package/package.json +1 -1
- package/dist/api/handleApplicationNativeAuthentication.d.ts +0 -33
- package/dist/api/initializeApplicationNativeAuthentication.d.ts +0 -117
- package/dist/models/application-native-authentication.d.ts +0 -82
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { IdToken } from '../models/token';
|
|
19
19
|
/**
|
|
20
20
|
* Extracts the tenant domain from the ID token payload.
|
|
21
21
|
*
|
|
@@ -27,5 +27,5 @@ import { IdTokenPayload } from '../models/token';
|
|
|
27
27
|
*
|
|
28
28
|
* Consider extracting the tenant domain using a dedicated claim (e.g., `tenant_domain`) when available.
|
|
29
29
|
*/
|
|
30
|
-
declare const extractTenantDomainFromIdTokenPayload: (payload:
|
|
30
|
+
declare const extractTenantDomainFromIdTokenPayload: (payload: IdToken, subjectSeparator?: string) => string;
|
|
31
31
|
export default extractTenantDomainFromIdTokenPayload;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { IdToken } from '../models/token';
|
|
19
19
|
/**
|
|
20
20
|
* Removes standard protocol-specific claims from the ID token payload
|
|
21
21
|
* and returns a camelCased object of user-specific claims.
|
|
@@ -40,5 +40,5 @@ import { IdTokenPayload } from '../models/token';
|
|
|
40
40
|
* // }
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
declare const extractUserClaimsFromIdToken: (payload:
|
|
43
|
+
declare const extractUserClaimsFromIdToken: (payload: IdToken) => Record<string, unknown>;
|
|
44
44
|
export default extractUserClaimsFromIdToken;
|
|
@@ -23,6 +23,9 @@ import { User } from '../models/user';
|
|
|
23
23
|
* a flat object with dot notation keys instead of nested objects. Multi-valued
|
|
24
24
|
* properties and type-specific defaults are handled appropriately.
|
|
25
25
|
*
|
|
26
|
+
* Additionally, any fields present in the response but not defined in the schema
|
|
27
|
+
* will be included to ensure no user data is lost during flattening.
|
|
28
|
+
*
|
|
26
29
|
* @param meResponse - The response object containing user data
|
|
27
30
|
* @param processedSchemas - Array of schema objects defining field properties
|
|
28
31
|
* @param processedSchemas[].name - The field name/path for the property
|
|
@@ -37,9 +40,13 @@ import { User } from '../models/user';
|
|
|
37
40
|
* { name: 'name.givenName', type: 'STRING', multiValued: false },
|
|
38
41
|
* { name: 'emails', type: 'STRING', multiValued: true }
|
|
39
42
|
* ];
|
|
40
|
-
* const response = {
|
|
43
|
+
* const response = {
|
|
44
|
+
* name: { givenName: 'John' },
|
|
45
|
+
* emails: 'john@example.com',
|
|
46
|
+
* country: 'US' // This will be included even if not in schema
|
|
47
|
+
* };
|
|
41
48
|
* const profile = generateFlattenedUserProfile(response, schemas);
|
|
42
|
-
* // Result: { "name.givenName": 'John', emails: ['john@example.com'] }
|
|
49
|
+
* // Result: { "name.givenName": 'John', emails: ['john@example.com'], country: 'US' }
|
|
43
50
|
* ```
|
|
44
51
|
*/
|
|
45
52
|
declare const generateFlattenedUserProfile: (meResponse: any, processedSchemas: any[]) => User;
|
|
@@ -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
|
+
* Checks if a value is considered empty.
|
|
20
|
+
*
|
|
21
|
+
* A value is considered empty if it is:
|
|
22
|
+
* - null
|
|
23
|
+
* - undefined
|
|
24
|
+
* - empty string ("")
|
|
25
|
+
* - string containing only whitespace characters
|
|
26
|
+
* - empty array ([])
|
|
27
|
+
* - empty object ({})
|
|
28
|
+
*
|
|
29
|
+
* @param value - The value to check
|
|
30
|
+
* @returns true if the value is empty, false otherwise
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* isEmpty(null); // true
|
|
35
|
+
* isEmpty(undefined); // true
|
|
36
|
+
* isEmpty(""); // true
|
|
37
|
+
* isEmpty(" "); // true
|
|
38
|
+
* isEmpty("hello"); // false
|
|
39
|
+
* isEmpty([]); // true
|
|
40
|
+
* isEmpty([1, 2, 3]); // false
|
|
41
|
+
* isEmpty({}); // true
|
|
42
|
+
* isEmpty({ name: "John" }); // false
|
|
43
|
+
* isEmpty(0); // false
|
|
44
|
+
* isEmpty(false); // false
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare const isEmpty: (value: any) => boolean;
|
|
48
|
+
export default isEmpty;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* Adds a vendor-specific prefix to a CSS class name.
|
|
20
|
+
*
|
|
21
|
+
* @param className - The original CSS class name to be prefixed
|
|
22
|
+
* @returns A new string with the vendor prefix added to the class name
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Usage with clsx
|
|
27
|
+
* clsx(withVendorCSSClassPrefix('sign-in-button'), className)
|
|
28
|
+
* // Result: "wso2-sign-in-button"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const withVendorCSSClassPrefix: (className: string) => string;
|
|
32
|
+
export default withVendorCSSClassPrefix;
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
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 { ApplicationNativeAuthenticationHandleRequestPayload, ApplicationNativeAuthenticationHandleResponse } from '../models/application-native-authentication';
|
|
19
|
-
/**
|
|
20
|
-
* Request configuration for the authorize function.
|
|
21
|
-
*/
|
|
22
|
-
export interface AuthorizeRequestConfig extends Partial<Request> {
|
|
23
|
-
/**
|
|
24
|
-
* The base URL of the Asgardeo server.
|
|
25
|
-
*/
|
|
26
|
-
baseUrl?: string;
|
|
27
|
-
/**
|
|
28
|
-
* The authorization request payload.
|
|
29
|
-
*/
|
|
30
|
-
payload: ApplicationNativeAuthenticationHandleRequestPayload;
|
|
31
|
-
}
|
|
32
|
-
declare const handleApplicationNativeAuthentication: ({ url, baseUrl, payload, ...requestConfig }: AuthorizeRequestConfig) => Promise<ApplicationNativeAuthenticationHandleResponse>;
|
|
33
|
-
export default handleApplicationNativeAuthentication;
|
|
@@ -1,117 +0,0 @@
|
|
|
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 { ApplicationNativeAuthenticationInitiateResponse } from '../models/application-native-authentication';
|
|
19
|
-
/**
|
|
20
|
-
* Represents the authorization request payload that can be sent to the authorization endpoint.
|
|
21
|
-
*/
|
|
22
|
-
export interface AuthorizationRequest {
|
|
23
|
-
/**
|
|
24
|
-
* The response type (e.g., 'code', 'token', 'id_token').
|
|
25
|
-
*/
|
|
26
|
-
response_type?: string;
|
|
27
|
-
/**
|
|
28
|
-
* The client identifier.
|
|
29
|
-
*/
|
|
30
|
-
client_id?: string;
|
|
31
|
-
/**
|
|
32
|
-
* The redirection URI after authorization.
|
|
33
|
-
*/
|
|
34
|
-
redirect_uri?: string;
|
|
35
|
-
/**
|
|
36
|
-
* The scope of the access request.
|
|
37
|
-
*/
|
|
38
|
-
scope?: string;
|
|
39
|
-
/**
|
|
40
|
-
* An unguessable random string to prevent CSRF attacks.
|
|
41
|
-
*/
|
|
42
|
-
state?: string;
|
|
43
|
-
/**
|
|
44
|
-
* String value used to associate a Client session with an ID Token.
|
|
45
|
-
*/
|
|
46
|
-
nonce?: string;
|
|
47
|
-
/**
|
|
48
|
-
* How the authorization response should be returned.
|
|
49
|
-
*/
|
|
50
|
-
response_mode?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Space delimited, case sensitive list of ASCII string values.
|
|
53
|
-
*/
|
|
54
|
-
prompt?: string;
|
|
55
|
-
/**
|
|
56
|
-
* The allowable elapsed time in seconds since the last time the End-User was actively authenticated.
|
|
57
|
-
*/
|
|
58
|
-
max_age?: number;
|
|
59
|
-
/**
|
|
60
|
-
* PKCE code challenge.
|
|
61
|
-
*/
|
|
62
|
-
code_challenge?: string;
|
|
63
|
-
/**
|
|
64
|
-
* PKCE code challenge method.
|
|
65
|
-
*/
|
|
66
|
-
code_challenge_method?: string;
|
|
67
|
-
/**
|
|
68
|
-
* Additional authorization parameters.
|
|
69
|
-
*/
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Request configuration for the authorize function.
|
|
74
|
-
*/
|
|
75
|
-
export interface AuthorizeRequestConfig extends Partial<Request> {
|
|
76
|
-
url?: string;
|
|
77
|
-
/**
|
|
78
|
-
* The base URL of the Asgardeo server.
|
|
79
|
-
*/
|
|
80
|
-
baseUrl?: string;
|
|
81
|
-
/**
|
|
82
|
-
* The authorization request payload.
|
|
83
|
-
*/
|
|
84
|
-
payload: AuthorizationRequest;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Sends an authorization request to the specified OAuth2/OIDC authorization endpoint.
|
|
88
|
-
*
|
|
89
|
-
* @param requestConfig - Request configuration object containing URL and payload.
|
|
90
|
-
* @returns A promise that resolves with the authorization response.
|
|
91
|
-
* @throws AsgardeoAPIError when the request fails or URL is invalid.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* try {
|
|
96
|
-
* const authResponse = await initializeApplicationNativeAuthentication({
|
|
97
|
-
* url: "https://api.asgardeo.io/t/<ORGANIZATION>/oauth2/authorize",
|
|
98
|
-
* payload: {
|
|
99
|
-
* response_type: "code",
|
|
100
|
-
* client_id: "your-client-id",
|
|
101
|
-
* redirect_uri: "https://your-app.com/callback",
|
|
102
|
-
* scope: "openid profile email",
|
|
103
|
-
* state: "random-state-value",
|
|
104
|
-
* code_challenge: "your-pkce-challenge",
|
|
105
|
-
* code_challenge_method: "S256"
|
|
106
|
-
* }
|
|
107
|
-
* });
|
|
108
|
-
* console.log(authResponse);
|
|
109
|
-
* } catch (error) {
|
|
110
|
-
* if (error instanceof AsgardeoAPIError) {
|
|
111
|
-
* console.error('Authorization failed:', error.message);
|
|
112
|
-
* }
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
declare const initializeApplicationNativeAuthentication: ({ url, baseUrl, payload, ...requestConfig }: AuthorizeRequestConfig) => Promise<ApplicationNativeAuthenticationInitiateResponse>;
|
|
117
|
-
export default initializeApplicationNativeAuthentication;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export interface ApplicationNativeAuthenticationInitiateResponse {
|
|
2
|
-
flowId: string;
|
|
3
|
-
flowStatus: ApplicationNativeAuthenticationFlowStatus;
|
|
4
|
-
flowType: ApplicationNativeAuthenticationFlowType;
|
|
5
|
-
nextStep: {
|
|
6
|
-
stepType: ApplicationNativeAuthenticationStepType;
|
|
7
|
-
authenticators: ApplicationNativeAuthenticationAuthenticator[];
|
|
8
|
-
};
|
|
9
|
-
links: ApplicationNativeAuthenticationLink[];
|
|
10
|
-
}
|
|
11
|
-
export declare enum ApplicationNativeAuthenticationFlowStatus {
|
|
12
|
-
SuccessCompleted = "SUCCESS_COMPLETED",
|
|
13
|
-
FailCompleted = "FAIL_COMPLETED",
|
|
14
|
-
FailIncomplete = "FAIL_INCOMPLETE",
|
|
15
|
-
Incomplete = "INCOMPLETE"
|
|
16
|
-
}
|
|
17
|
-
export declare enum ApplicationNativeAuthenticationFlowType {
|
|
18
|
-
Authentication = "AUTHENTICATION"
|
|
19
|
-
}
|
|
20
|
-
export declare enum ApplicationNativeAuthenticationStepType {
|
|
21
|
-
AuthenticatorPrompt = "AUTHENTICATOR_PROMPT",
|
|
22
|
-
MultOptionsPrompt = "MULTI_OPTIONS_PROMPT"
|
|
23
|
-
}
|
|
24
|
-
export interface ApplicationNativeAuthenticationAuthenticator {
|
|
25
|
-
authenticatorId: string;
|
|
26
|
-
authenticator: string;
|
|
27
|
-
idp: string;
|
|
28
|
-
metadata: {
|
|
29
|
-
i18nKey: string;
|
|
30
|
-
promptType: ApplicationNativeAuthenticationAuthenticatorPromptType;
|
|
31
|
-
params: {
|
|
32
|
-
param: string;
|
|
33
|
-
type: ApplicationNativeAuthenticationAuthenticatorParamType;
|
|
34
|
-
order: number;
|
|
35
|
-
i18nKey: string;
|
|
36
|
-
displayName: string;
|
|
37
|
-
confidential: boolean;
|
|
38
|
-
}[];
|
|
39
|
-
};
|
|
40
|
-
requiredParams: string[];
|
|
41
|
-
}
|
|
42
|
-
export interface ApplicationNativeAuthenticationLink {
|
|
43
|
-
name: string;
|
|
44
|
-
href: string;
|
|
45
|
-
method: string;
|
|
46
|
-
}
|
|
47
|
-
export interface ApplicationNativeAuthenticationHandleRequestPayload {
|
|
48
|
-
flowId: string;
|
|
49
|
-
selectedAuthenticator: {
|
|
50
|
-
authenticatorId: string;
|
|
51
|
-
params: Record<string, string>;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export interface ApplicationNativeAuthenticationHandleResponse {
|
|
55
|
-
flowStatus: string;
|
|
56
|
-
authData: Record<string, any>;
|
|
57
|
-
}
|
|
58
|
-
export declare enum ApplicationNativeAuthenticationAuthenticatorParamType {
|
|
59
|
-
String = "STRING",
|
|
60
|
-
Integer = "INTEGER",
|
|
61
|
-
MultiValued = "MULTI_VALUED"
|
|
62
|
-
}
|
|
63
|
-
export declare enum ApplicationNativeAuthenticationAuthenticatorExtendedParamType {
|
|
64
|
-
Otp = "OTPCode"
|
|
65
|
-
}
|
|
66
|
-
export declare enum ApplicationNativeAuthenticationAuthenticatorKnownIdPType {
|
|
67
|
-
Local = "LOCAL"
|
|
68
|
-
}
|
|
69
|
-
export declare enum ApplicationNativeAuthenticationAuthenticatorPromptType {
|
|
70
|
-
/**
|
|
71
|
-
* Prompt for user input, typically for username/password or similar credentials.
|
|
72
|
-
*/
|
|
73
|
-
UserPrompt = "USER_PROMPT",
|
|
74
|
-
/**
|
|
75
|
-
* Prompt for internal system use, such as API keys or tokens.
|
|
76
|
-
*/
|
|
77
|
-
InternalPrompt = "INTERNAL_PROMPT",
|
|
78
|
-
/**
|
|
79
|
-
* Prompt for redirection to another page or service.
|
|
80
|
-
*/
|
|
81
|
-
RedirectionPrompt = "REDIRECTION_PROMPT"
|
|
82
|
-
}
|