@asgardeo/javascript 0.0.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 (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +57 -0
  3. package/dist/AsgardeoJavaScriptClient.d.ts +81 -0
  4. package/dist/IsomorphicCrypto.d.ts +73 -0
  5. package/dist/__legacy__/client.d.ts +488 -0
  6. package/dist/__legacy__/core/authentication-core.d.ts +51 -0
  7. package/dist/__legacy__/core/index.d.ts +18 -0
  8. package/dist/__legacy__/data/data-layer.d.ts +64 -0
  9. package/dist/__legacy__/data/index.d.ts +18 -0
  10. package/dist/__legacy__/exception/exception.d.ts +23 -0
  11. package/dist/__legacy__/exception/index.d.ts +18 -0
  12. package/dist/__legacy__/helpers/authentication-helper.d.ts +37 -0
  13. package/dist/__legacy__/helpers/index.d.ts +18 -0
  14. package/dist/__legacy__/models/authorization-url.d.ts +23 -0
  15. package/dist/__legacy__/models/client-config.d.ts +60 -0
  16. package/dist/__legacy__/models/custom-grant.d.ts +26 -0
  17. package/dist/__legacy__/models/data.d.ts +27 -0
  18. package/dist/__legacy__/models/fetch.d.ts +55 -0
  19. package/dist/__legacy__/models/index.d.ts +23 -0
  20. package/dist/__legacy__/models/user.d.ts +85 -0
  21. package/dist/api/oidc/getUserInfo.d.ts +37 -0
  22. package/dist/cjs/index.js +2227 -0
  23. package/dist/cjs/index.js.map +7 -0
  24. package/dist/constants/OIDCDiscoveryConstants.d.ts +153 -0
  25. package/dist/constants/OIDCRequestConstants.d.ts +66 -0
  26. package/dist/constants/PKCEConstants.d.ts +58 -0
  27. package/dist/constants/ScopeConstants.d.ts +45 -0
  28. package/dist/constants/TokenConstants.d.ts +76 -0
  29. package/dist/constants/TokenExchangeConstants.d.ts +68 -0
  30. package/dist/errors/AsgardeoAPIError.d.ts +52 -0
  31. package/dist/errors/AsgardeoError.d.ts +49 -0
  32. package/dist/errors/AsgardeoRuntimeError.d.ts +50 -0
  33. package/dist/index.d.ts +45 -0
  34. package/dist/index.js +2186 -0
  35. package/dist/index.js.map +7 -0
  36. package/dist/models/client.d.ts +84 -0
  37. package/dist/models/config.d.ts +81 -0
  38. package/dist/models/crypto.d.ts +100 -0
  39. package/dist/models/id-token.d.ts +55 -0
  40. package/dist/models/oauth-response.d.ts +34 -0
  41. package/dist/models/oidc-discovery.d.ts +369 -0
  42. package/dist/models/oidc-endpoints.d.ts +70 -0
  43. package/dist/models/scim2-schema.d.ts +62 -0
  44. package/dist/models/store.d.ts +81 -0
  45. package/dist/models/token.d.ts +121 -0
  46. package/dist/models/user.d.ts +106 -0
  47. package/dist/models/utility-types.d.ts +20 -0
  48. package/dist/theme/createTheme.d.ts +21 -0
  49. package/dist/theme/types.d.ts +59 -0
  50. package/dist/utils/cryptoUtils.d.ts +0 -0
  51. package/dist/utils/extractPkceStorageKeyFromState.d.ts +32 -0
  52. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +31 -0
  53. package/dist/utils/extractUserClaimsFromIdToken.d.ts +44 -0
  54. package/dist/utils/generatePkceStorageKey.d.ts +34 -0
  55. package/dist/utils/generateStateParamForRequestCorrelation.d.ts +34 -0
  56. package/dist/utils/removeTrailingSlash.d.ts +31 -0
  57. package/package.json +61 -0
@@ -0,0 +1,58 @@
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
+ * Constants related to Proof Key for Code Exchange (PKCE) implementation.
20
+ * This object contains all the necessary constants for implementing PKCE
21
+ * flow in the OAuth 2.0 authorization code grant.
22
+ *
23
+ * @remarks
24
+ * PKCE is an extension to the authorization code flow to prevent CSRF and
25
+ * authorization code injection attacks. The constants are organized into
26
+ * storage-related sections for managing PKCE state.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Using storage keys
31
+ * const codeVerifierKey = PKCEConstants.Storage.StorageKeys.CODE_VERIFIER;
32
+ * const separator = PKCEConstants.Storage.StorageKeys.SEPARATOR;
33
+ * ```
34
+ */
35
+ declare const PKCEConstants: {
36
+ /**
37
+ * Storage-related constants for managing PKCE state
38
+ */
39
+ readonly Storage: {
40
+ /**
41
+ * Collection of storage keys used in PKCE implementation
42
+ */
43
+ readonly StorageKeys: {
44
+ /**
45
+ * Key used to store the PKCE code verifier in temporary storage.
46
+ * The code verifier is a cryptographically random string that is
47
+ * used to generate the code challenge.
48
+ */
49
+ readonly CODE_VERIFIER: "pkce_code_verifier";
50
+ /**
51
+ * Separator used in storage keys to create unique identifiers
52
+ * by combining different parts of the key.
53
+ */
54
+ readonly SEPARATOR: "#";
55
+ };
56
+ };
57
+ };
58
+ export default PKCEConstants;
@@ -0,0 +1,45 @@
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
+ * Constants for OAuth 2.0 and OpenID Connect scopes.
20
+ * These scopes define the level of access that the client application
21
+ * is requesting from the authorization server.
22
+ *
23
+ * @remarks
24
+ * Scopes are space-separated strings that represent different permissions.
25
+ * The 'openid' scope is required for OpenID Connect flows, while other
26
+ * scopes provide access to different resources or user information.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Requesting OpenID Connect authentication
31
+ * const scope = [ScopeConstants.OPENID];
32
+ *
33
+ * // Requesting profile information
34
+ * const scopes = [ScopeConstants.OPENID, ScopeConstants.PROFILE];
35
+ * ```
36
+ */
37
+ declare const ScopeConstants: {
38
+ /**
39
+ * The base OpenID Connect scope.
40
+ * Required for all OpenID Connect flows. Indicates that the client
41
+ * is initiating an OpenID Connect authentication request.
42
+ */
43
+ readonly OPENID: "openid";
44
+ };
45
+ export default ScopeConstants;
@@ -0,0 +1,76 @@
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
+ * Constants related to OIDC token management and storage.
20
+ * This object contains configuration values and storage keys
21
+ * used in token validation and management processes.
22
+ *
23
+ * @remarks
24
+ * The constants are organized into two main sections:
25
+ * 1. SignatureValidation - Contains supported algorithms for token validation
26
+ * 2. Storage - Contains keys used for storing token-related data
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Using signature validation algorithms
31
+ * const algorithms = TokenConstants.SignatureValidation.SUPPORTED_ALGORITHMS;
32
+ *
33
+ * // Using storage keys
34
+ * const timerKey = TokenConstants.Storage.StorageKeys.REFRESH_TOKEN_TIMER;
35
+ * ```
36
+ */
37
+ declare const TokenConstants: {
38
+ /**
39
+ * Token signature validation constants.
40
+ * Contains configurations related to token signature verification.
41
+ */
42
+ readonly SignatureValidation: {
43
+ /**
44
+ * Fallback array of supported signature algorithms for OIDC token validation.
45
+ * These values are used when the supported algorithms cannot be retrieved from
46
+ * the .well-known/openid-configuration endpoint.
47
+ *
48
+ * Supported algorithms:
49
+ * - `RS256` - RSASSA-PKCS1-v1_5 using SHA-256
50
+ * - `RS512` - RSASSA-PKCS1-v1_5 using SHA-512
51
+ * - `RS384` - RSASSA-PKCS1-v1_5 using SHA-384
52
+ * - `PS256` - RSASSA-PSS using SHA-256 and MGF1 with SHA-256
53
+ */
54
+ readonly SUPPORTED_ALGORITHMS: readonly ["RS256", "RS512", "RS384", "PS256"];
55
+ };
56
+ /**
57
+ * Storage-related constants for OIDC tokens.
58
+ * Contains keys used to store token-related data in browser storage.
59
+ */
60
+ readonly Storage: {
61
+ /**
62
+ * Collection of storage keys used in token management.
63
+ * These keys are used to store and retrieve token-related
64
+ * information from browser storage.
65
+ */
66
+ readonly StorageKeys: {
67
+ /**
68
+ * Key used to store the refresh token timer identifier.
69
+ * This timer is used to schedule token refresh operations
70
+ * before the current token expires.
71
+ */
72
+ readonly REFRESH_TOKEN_TIMER: "refresh_token_timer";
73
+ };
74
+ };
75
+ };
76
+ export default TokenConstants;
@@ -0,0 +1,68 @@
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
+ * Constants for OAuth 2.0 Token Exchange operations.
20
+ * This object contains placeholders used in token exchange requests
21
+ * and responses for dynamic value substitution.
22
+ *
23
+ * @remarks
24
+ * These placeholders are used in token exchange templates and are replaced
25
+ * with actual values during request processing. They help in creating
26
+ * flexible and reusable token exchange configurations.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Using placeholders in a token exchange template
31
+ * const template = `grant_type=urn:ietf:params:oauth:grant-type:token-exchange&subject_token=${TokenExchangeConstants.Placeholders.TOKEN}`;
32
+ * ```
33
+ */
34
+ declare const TokenExchangeConstants: {
35
+ /**
36
+ * Collection of placeholder strings used in token exchange operations.
37
+ * These placeholders are replaced with actual values when processing
38
+ * token exchange requests.
39
+ */
40
+ readonly Placeholders: {
41
+ /**
42
+ * Placeholder for the token value in exchange requests.
43
+ * Usually replaced with an access token or refresh token.
44
+ */
45
+ readonly TOKEN: "{{token}}";
46
+ /**
47
+ * Placeholder for the username in token exchange operations.
48
+ * Used when user identity needs to be included in the exchange.
49
+ */
50
+ readonly USERNAME: "{{username}}";
51
+ /**
52
+ * Placeholder for OAuth scopes in token exchange requests.
53
+ * Replaced with space-separated scope strings.
54
+ */
55
+ readonly SCOPE: "{{scope}}";
56
+ /**
57
+ * Placeholder for client ID in token exchange operations.
58
+ * Required for client authentication.
59
+ */
60
+ readonly CLIENT_ID: "{{clientID}}";
61
+ /**
62
+ * Placeholder for client secret in token exchange operations.
63
+ * Used for client authentication in confidential client flows.
64
+ */
65
+ readonly CLIENT_SECRET: "{{clientSecret}}";
66
+ };
67
+ };
68
+ export default TokenExchangeConstants;
@@ -0,0 +1,52 @@
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 AsgardeoError from './AsgardeoError';
19
+ /**
20
+ * Base class for all API-related errors in Asgardeo. This class extends AsgardeoError
21
+ * and adds support for HTTP status codes and status text.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * throw new AsgardeoAPIError(
26
+ * "Failed to fetch user data",
27
+ * "API_FETCH_ERROR",
28
+ * 404,
29
+ * "Not Found"
30
+ * );
31
+ * ```
32
+ */
33
+ export default class AsgardeoAPIError extends AsgardeoError {
34
+ readonly statusCode?: number;
35
+ readonly statusText?: string;
36
+ /**
37
+ * Creates an instance of AsgardeoAPIError.
38
+ *
39
+ * @param message - Human-readable description of the error
40
+ * @param code - A unique error code that identifies the error type
41
+ * @param statusCode - HTTP status code of the failed request
42
+ * @param statusText - HTTP status text of the failed request
43
+ * @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
44
+ * @constructor
45
+ */
46
+ constructor(message: string, code: string, origin: string, statusCode?: number, statusText?: string);
47
+ /**
48
+ * Returns a string representation of the API error
49
+ * @returns Formatted error string with name, code, status, and message
50
+ */
51
+ toString(): string;
52
+ }
@@ -0,0 +1,49 @@
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
+ * Base class for all Asgardeo errors. This class extends the native Error class
20
+ * and adds support for error codes and proper stack traces. Each error is prefixed
21
+ * with a shield emoji and the SDK name for easy identification.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // Create a new error with a message and code
26
+ * throw new AsgardeoError(
27
+ * "Invalid authentication response",
28
+ * "AUTH_ERROR"
29
+ * );
30
+ *
31
+ * // Or with a specific SDK name
32
+ * throw new AsgardeoError(
33
+ * "Invalid authentication response",
34
+ * "AUTH_ERROR",
35
+ * "@asgardeo/react"
36
+ * );
37
+ *
38
+ * // The error message will be formatted as:
39
+ * // 🛡️ Asgardeo React: Invalid authentication response
40
+ * //
41
+ * // (code="AUTH_ERROR")
42
+ */
43
+ export default class AsgardeoError extends Error {
44
+ readonly code: string;
45
+ readonly origin: string;
46
+ private static resolveOrigin;
47
+ constructor(message: string, code: string, origin: string);
48
+ toString(): string;
49
+ }
@@ -0,0 +1,50 @@
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 AsgardeoError from './AsgardeoError';
19
+ /**
20
+ * Base class for all runtime errors in Asgardeo. This class extends AsgardeoError
21
+ * and adds support for additional error details. Use this class for errors that occur
22
+ * during runtime execution that are not related to API calls.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * throw new AsgardeoRuntimeError(
27
+ * "Failed to parse configuration",
28
+ * "CONFIG_PARSE_ERROR",
29
+ * { invalidField: "redirectUri" }
30
+ * );
31
+ * ```
32
+ */
33
+ export default class AsgardeoRuntimeError extends AsgardeoError {
34
+ readonly details?: unknown;
35
+ /**
36
+ * Creates an instance of AsgardeoRuntimeError.
37
+ *
38
+ * @param message - Human-readable description of the error
39
+ * @param code - A unique error code that identifies the error type
40
+ * @param details - Additional details about the error that might be helpful for debugging
41
+ * @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
42
+ * @constructor
43
+ */
44
+ constructor(message: string, code: string, origin: string, details?: unknown);
45
+ /**
46
+ * Returns a string representation of the runtime error
47
+ * @returns Formatted error string with name, code, details, and message
48
+ */
49
+ toString(): string;
50
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
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
+ export * from './__legacy__/client';
19
+ export * from './__legacy__/models';
20
+ export * from './models/oauth-response';
21
+ export * from './IsomorphicCrypto';
22
+ export * from './__legacy__/exception';
23
+ export * from './__legacy__/data';
24
+ export { default as getUserInfo } from './api/oidc/getUserInfo';
25
+ export { default as TokenConstants } from './constants/TokenConstants';
26
+ export { default as OIDCRequestConstants } from './constants/OIDCRequestConstants';
27
+ export { default as AsgardeoError } from './errors/AsgardeoError';
28
+ export { default as AsgardeoAPIError } from './errors/AsgardeoAPIError';
29
+ export { default as AsgardeoRuntimeError } from './errors/AsgardeoRuntimeError';
30
+ export { AsgardeoClient, SignInOptions, SignOutOptions } from './models/client';
31
+ export { BaseConfig, Config, Preferences, ThemePreferences } from './models/config';
32
+ export { TokenResponse } from './models/token';
33
+ export { Crypto, JWKInterface } from './models/crypto';
34
+ export { IdTokenPayload } from './models/id-token';
35
+ export { OIDCEndpoints } from './models/oidc-endpoints';
36
+ export { Store } from './models/store';
37
+ export { User } from './models/user';
38
+ export { Schema, SchemaAttribute, WellKnownSchemaIds } from './models/scim2-schema';
39
+ export { RecursivePartial } from './models/utility-types';
40
+ export { default as AsgardeoJavaScriptClient } from './AsgardeoJavaScriptClient';
41
+ export { default as createTheme } from './theme/createTheme';
42
+ export { ThemeColors, ThemeConfig, Theme, ThemeMode } from './theme/types';
43
+ export { default as extractUserClaimsFromIdToken } from './utils/extractUserClaimsFromIdToken';
44
+ export { default as extractPkceStorageKeyFromState } from './utils/extractPkceStorageKeyFromState';
45
+ export { default as removeTrailingSlash } from './utils/removeTrailingSlash';