@asgardeo/javascript 0.0.1 → 0.1.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.
Files changed (56) hide show
  1. package/README.md +3 -3
  2. package/dist/AsgardeoJavaScriptClient.d.ts +2 -1
  3. package/dist/IsomorphicCrypto.d.ts +4 -4
  4. package/dist/{__legacy__/data/data-layer.d.ts → StorageManager.d.ts} +26 -25
  5. package/dist/__legacy__/client.d.ts +82 -98
  6. package/dist/__legacy__/helpers/authentication-helper.d.ts +8 -8
  7. package/dist/__legacy__/models/client-config.d.ts +6 -6
  8. package/dist/__legacy__/models/index.d.ts +0 -5
  9. package/dist/api/{oidc/getUserInfo.d.ts → getUserInfo.d.ts} +1 -1
  10. package/dist/api/handleApplicationNativeAuthentication.d.ts +33 -0
  11. package/dist/api/initializeApplicationNativeAuthentication.d.ts +117 -0
  12. package/dist/cjs/index.js +1581 -1188
  13. package/dist/cjs/index.js.map +4 -4
  14. package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +39 -0
  15. package/dist/constants/OIDCRequestConstants.d.ts +14 -0
  16. package/dist/constants/PKCEConstants.d.ts +1 -0
  17. package/dist/constants/TokenExchangeConstants.d.ts +1 -1
  18. package/dist/{__legacy__/exception → errors}/exception.d.ts +3 -0
  19. package/dist/{__legacy__/data/index.d.ts → i18n/en-US.d.ts} +4 -2
  20. package/dist/{__legacy__/exception → i18n}/index.d.ts +2 -2
  21. package/dist/index.d.ts +28 -10
  22. package/dist/index.js +1562 -1184
  23. package/dist/index.js.map +4 -4
  24. package/dist/models/application-native-authentication.d.ts +82 -0
  25. package/dist/models/client.d.ts +8 -2
  26. package/dist/models/config.d.ts +26 -1
  27. package/dist/models/crypto.d.ts +2 -2
  28. package/dist/{__legacy__/models/custom-grant.d.ts → models/field.d.ts} +13 -9
  29. package/dist/models/i18n.d.ts +66 -0
  30. package/dist/{__legacy__/models/authorization-url.d.ts → models/oauth-request.d.ts} +3 -3
  31. package/dist/models/oauth-response.d.ts +1 -17
  32. package/dist/models/scim2-schema.d.ts +3 -0
  33. package/dist/{__legacy__/models/data.d.ts → models/session.d.ts} +4 -0
  34. package/dist/models/store.d.ts +1 -1
  35. package/dist/models/token.d.ts +47 -0
  36. package/dist/models/user.d.ts +11 -84
  37. package/dist/theme/types.d.ts +0 -1
  38. package/dist/utils/deepMerge.d.ts +44 -0
  39. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +1 -1
  40. package/dist/utils/extractUserClaimsFromIdToken.d.ts +1 -1
  41. package/dist/utils/flattenUserSchema.d.ts +64 -0
  42. package/dist/utils/generateFlattenedUserProfile.d.ts +46 -0
  43. package/dist/utils/generateUserProfile.d.ts +55 -0
  44. package/dist/utils/get.d.ts +29 -0
  45. package/dist/utils/getAuthorizeRequestUrlParams.d.ts +59 -0
  46. package/dist/utils/getI18nBundles.d.ts +26 -0
  47. package/dist/utils/getLatestStateParam.d.ts +40 -0
  48. package/dist/utils/processOpenIDScopes.d.ts +36 -0
  49. package/dist/{__legacy__/core/index.d.ts → utils/resolveFieldName.d.ts} +3 -2
  50. package/dist/utils/resolveFieldType.d.ts +20 -0
  51. package/dist/utils/set.d.ts +30 -0
  52. package/package.json +4 -4
  53. package/dist/__legacy__/core/authentication-core.d.ts +0 -51
  54. package/dist/__legacy__/models/fetch.d.ts +0 -55
  55. package/dist/__legacy__/models/user.d.ts +0 -85
  56. package/dist/models/id-token.d.ts +0 -55
@@ -15,18 +15,18 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { ResponseMode } from '../../models/oauth-response';
18
+ import { OAuthResponseMode } from '../../models/oauth-response';
19
19
  import { OIDCEndpoints } from '../../models/oidc-endpoints';
20
20
  export interface DefaultAuthClientConfig {
21
- signInRedirectURL: string;
22
- signOutRedirectURL?: string;
21
+ afterSignInUrl: string;
22
+ afterSignOutUrl?: string;
23
23
  clientHost?: string;
24
- clientID: string;
24
+ clientId: string;
25
25
  clientSecret?: string;
26
26
  enablePKCE?: boolean;
27
27
  prompt?: string;
28
- responseMode?: ResponseMode;
29
- scope?: string[];
28
+ responseMode?: OAuthResponseMode;
29
+ scopes?: string | string[] | undefined;
30
30
  validateIDToken?: boolean;
31
31
  validateIDTokenIssuer?: boolean;
32
32
  /**
@@ -16,8 +16,3 @@
16
16
  * under the License.
17
17
  */
18
18
  export * from './client-config';
19
- export * from './data';
20
- export * from './custom-grant';
21
- export * from './authorization-url';
22
- export * from './user';
23
- export * from './fetch';
@@ -15,7 +15,7 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { User } from '../../models/user';
18
+ import { User } from '../models/user';
19
19
  /**
20
20
  * Retrieves the user information from the specified OIDC userinfo endpoint.
21
21
  *
@@ -0,0 +1,33 @@
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;
@@ -0,0 +1,117 @@
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;