diff --git a/.changeset/big-parrots-sleep.md b/.changeset/big-parrots-sleep.md
new file mode 100644
index 000000000..2bfed380f
--- /dev/null
+++ b/.changeset/big-parrots-sleep.md
@@ -0,0 +1,9 @@
+---
+'@asgardeo/javascript': patch
+'@asgardeo/browser': patch
+'@asgardeo/nextjs': patch
+'@asgardeo/node': patch
+'@asgardeo/react': minor
+---
+
+Initial release with basic redirection capabilities and components.
diff --git a/.changeset/config.json b/.changeset/config.json
index 098a375c2..b65ea2b7d 100644
--- a/.changeset/config.json
+++ b/.changeset/config.json
@@ -1,15 +1,24 @@
{
- "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
- "changelog": ["@changesets/changelog-github", { "repo": "asgardeo/web-ui-sdks" }],
+ "$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json",
+ "access": "restricted",
+ "baseBranch": "main",
+ "changelog": [
+ "@changesets/changelog-github",
+ {
+ "repo": "asgardeo/javascript"
+ }
+ ],
"commit": false,
"fixed": [],
+ "ignore": [],
"linked": [],
- "access": "restricted",
- "baseBranch": "main",
"privatePackages": {
- "version": true,
- "tag": true
+ "version": false,
+ "tag": false
+ },
+ "root": {
+ "packageDir": "."
},
- "updateInternalDependencies": "patch",
- "ignore": []
-}
+ "tagFormat": "@/@${version}",
+ "updateInternalDependencies": "patch"
+}
\ No newline at end of file
diff --git a/.eslintrc.js b/.eslintrc.cjs
similarity index 92%
rename from .eslintrc.js
rename to .eslintrc.cjs
index ca7c9259e..c5cc5f0bd 100644
--- a/.eslintrc.js
+++ b/.eslintrc.cjs
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
diff --git a/.github/workflows/pr-builder.yml b/.github/workflows/pr-builder.yml
index 69eac7ef2..4eeccda03 100644
--- a/.github/workflows/pr-builder.yml
+++ b/.github/workflows/pr-builder.yml
@@ -118,6 +118,10 @@ jobs:
- name: 🧩 Install Dependencies
id: install-dependencies
run: pnpm install
+
+ - name: 🏗️ Build
+ id: build
+ run: pnpm build
- name: ☄️ Check Type Errors
run: pnpm nx affected --target=typecheck --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }}
@@ -166,6 +170,10 @@ jobs:
- name: 🧩 Install Dependencies
id: install-dependencies
run: pnpm install
+
+ - name: 🏗️ Build
+ id: build
+ run: pnpm build
- name: 🃏 Run Jest & Collect Coverage
id: run-jest-test-and-coverage
diff --git a/.gitignore b/.gitignore
index c6240fcc2..cf3dd4a4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,9 @@
-# See http://help.github.com/ignore-files/ for more about ignoring files.
+# See https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# compiled output
dist
tmp
-/out-tsc
+out-tsc
# dependencies
node_modules
@@ -38,5 +38,9 @@ testem.log
.DS_Store
Thumbs.db
-# Nx
.nx/cache
+.nx/workspace-data
+
+# Environment files
+*.env
+.env*
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
index 5781d0a8c..e7c97543c 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -4,3 +4,5 @@
/build
/node_modules
/coverage
+/.nx/cache
+/.nx/workspace-data
diff --git a/.vscode/settings.json b/.vscode/settings.json
index b2efe7834..1ed1b3fab 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -17,5 +17,6 @@
"css",
"scss"
],
- "typescript.tsdk": "node_modules/typescript/lib"
+ "typescript.tsdk": "node_modules/typescript/lib",
+ "editor.formatOnSave": true
}
diff --git a/README.md b/README.md
index 3d2afdab6..ed4c90e16 100644
--- a/README.md
+++ b/README.md
@@ -3,16 +3,15 @@
src="https://github.com/asgardeo/web-ui-sdks/assets/25959096/ae77b70c-6570-40b1-a723-719abd0f7d02" alt="Asgardeo Logo" height="40" width="auto"
>
- Web SDKs
+ Asgardeo JavaScript SDKs

-
@@ -21,7 +20,7 @@
-This repository contains the source code of the different Web SDKs that can be used to build customizable UIs for Asgardeo and WSO2 Identity Server. If you have any questions, please reach out to us through one of the following channels:
+This repository contains the source code of JavaScript SDKs that can be used to build applications integrated with Asgardeo. If you have any questions, please reach out to us through one of the following channels:
[](https://stackoverflow.com/questions/tagged/wso2is)
[](https://discord.gg/wso2)
@@ -31,16 +30,21 @@ This repository contains the source code of the different Web SDKs that can be u
| Package | Description |
| --- | --- |
-| [](./packages/core/) | Framework-agnostic JavaScript Core SDK |
-| [](./packages/react/) | React SDK for building customizable UIs for React applications |
+| [](./packages/javascript/) | Framework-agnostic JavaScript Core SDK |
+| [](./packages/browser/) | Browser-based JavaScript SDK |
+| [](./packages/next/) | Next.js SDK for building applications with Asgardeo |
+| [](./packages/node/) | Node.js SDK for server-side integration |
+| [](./packages/nuxt/) | Nuxt.js SDK for building applications with Asgardeo |
+| [](./packages/react/) | React SDK for building applications with Asgardeo |
+| [](./packages/vue/) | Vue.js SDK for building applications with Asgardeo |
## Contribute
-Please read [Contributing Guide](CONTRIBUTING.md) for details on how to contribute to Asgardeo web UI SDKs. Refer to [General Contribution Guidelines](http://wso2.github.io/) for details on our code of conduct, and the process for submitting pull requests to us.
+Please read [Contributing Guide](CONTRIBUTING.md) for details on how to contribute to Asgardeo JavaScript SDKs. Refer to [General Contribution Guidelines](http://wso2.github.io/) for details on our code of conduct, and the process for submitting pull requests to us.
### Reporting issues
We encourage you to report issues, improvements, and feature requests creating [Github Issues](https://github.com/asgardeo/web-ui-sdks/issues).
-**Important**: Please be advised that security issues MUST be reported to
security@wso2com, not as GitHub issues, in order to reach the proper audience. We strongly advise following the WSO2 Security Vulnerability Reporting Guidelines when reporting the security issues.
+**Important**: Please be advised that security issues MUST be reported to
security@wso2.com, not as GitHub issues, in order to reach the proper audience. We strongly advise following the WSO2 Security Vulnerability Reporting Guidelines when reporting the security issues.
## License
This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.
diff --git a/nx.json b/nx.json
index 027b7d137..f5c24760f 100644
--- a/nx.json
+++ b/nx.json
@@ -1,4 +1,26 @@
{
- "extends": "nx/presets/npm.json",
- "$schema": "./node_modules/nx/schemas/nx-schema.json"
-}
+ "$schema": "./node_modules/nx/schemas/nx-schema.json",
+ "namedInputs": {
+ "default": [
+ "{projectRoot}/**/*",
+ "sharedGlobals"
+ ],
+ "production": [
+ "default"
+ ],
+ "sharedGlobals": []
+ },
+ "targetDefaults": {
+ "build": {
+ "dependsOn": [
+ "^build"
+ ]
+ },
+ "typecheck": {
+ "dependsOn": [
+ "^build"
+ ]
+ }
+ },
+ "plugins": []
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index e7bcb44be..2d08546be 100644
--- a/package.json
+++ b/package.json
@@ -1,52 +1,42 @@
{
"private": true,
- "name": "@asgardeo/web-ui-sdks",
- "version": "0.1.0",
- "description": "Web SDKs for building customizable login UIs for Asgardeo & WSO2 Identity Server.",
+ "name": "@asgardeo/javascript-workspace",
+ "version": "0.0.0",
+ "description": "Workspace to hold the Asgardeo JavaScript SDKs.",
"author": "WSO2",
"license": "Apache-2.0",
- "homepage": "https://github.com/asgardeo/web-ui-sdks#readme",
+ "homepage": "https://github.com/asgardeo/javascript#readme",
"bugs": {
- "url": "https://github.com/asgardeo/web-ui-sdks/issues"
+ "url": "https://github.com/asgardeo/javascript/issues"
},
"repository": {
"type": "git",
- "url": "https://github.com/asgardeo/web-ui-sdks"
+ "url": "https://github.com/asgardeo/javascript"
},
"keywords": [
"asgardeo",
- "web-sdks",
- "api-based-auth"
+ "javascript",
+ "workspace"
],
"scripts": {
- "build": "nx run-many --target=build --parallel --projects=@asgardeo/js,@asgardeo/react",
- "changeset": "changeset",
- "lint": "nx run-many --target=lint --parallel",
+ "build": "nx run-many --target=build --all",
+ "fix:lint": "nx run-many --target=fix:lint --all --parallel",
+ "lint": "nx run-many --target=lint --all --parallel",
"publish:packages": "changeset publish",
- "test": "nx run-many --target=test --parallel",
- "typecheck": "nx run-many --target=typecheck --parallel",
+ "test": "nx run-many --target=test --all --parallel",
"version:packages": "changeset version && pnpm install --lockfile-only"
},
"devDependencies": {
- "@changesets/changelog-github": "^0.5.0",
- "@changesets/cli": "^2.27.3",
+ "@changesets/changelog-github": "^0.5.1",
+ "@changesets/cli": "^2.29.4",
"@wso2/eslint-plugin": "catalog:",
"@wso2/prettier-config": "catalog:",
- "eslint": "catalog:",
- "nx": "18.2.4",
- "prettier": "^3.2.5",
- "typescript": "5.1.6"
- },
- "workspaces": [
- "packages/*",
- "recipes/*"
- ],
- "engines": {
- "node": ">=18",
- "pnpm": ">=9"
+ "eslint": "8.57.0",
+ "nx": "20.8.1",
+ "prettier": "^2.6.2",
+ "typescript": "~5.7.2"
},
"publishConfig": {
"access": "restricted"
- },
- "packageManager": "pnpm@10.8.0+sha512.0e82714d1b5b43c74610193cb20734897c1d00de89d0e18420aebc5977fa13d780a9cb05734624e81ebd81cc876cd464794850641c48b9544326b5622ca29971"
-}
+ }
+}
\ No newline at end of file
diff --git a/packages/core/.editorconfig b/packages/__legacy__/core/.editorconfig
similarity index 100%
rename from packages/core/.editorconfig
rename to packages/__legacy__/core/.editorconfig
diff --git a/packages/core/.eslintignore b/packages/__legacy__/core/.eslintignore
similarity index 100%
rename from packages/core/.eslintignore
rename to packages/__legacy__/core/.eslintignore
diff --git a/packages/core/.eslintrc.cjs b/packages/__legacy__/core/.eslintrc.cjs
similarity index 100%
rename from packages/core/.eslintrc.cjs
rename to packages/__legacy__/core/.eslintrc.cjs
diff --git a/packages/core/.gitignore b/packages/__legacy__/core/.gitignore
similarity index 100%
rename from packages/core/.gitignore
rename to packages/__legacy__/core/.gitignore
diff --git a/packages/core/.prettierignore b/packages/__legacy__/core/.prettierignore
similarity index 100%
rename from packages/core/.prettierignore
rename to packages/__legacy__/core/.prettierignore
diff --git a/packages/core/CHANGELOG.md b/packages/__legacy__/core/CHANGELOG.md
similarity index 100%
rename from packages/core/CHANGELOG.md
rename to packages/__legacy__/core/CHANGELOG.md
diff --git a/packages/core/LICENSE b/packages/__legacy__/core/LICENSE
similarity index 100%
rename from packages/core/LICENSE
rename to packages/__legacy__/core/LICENSE
diff --git a/packages/core/README.md b/packages/__legacy__/core/README.md
similarity index 100%
rename from packages/core/README.md
rename to packages/__legacy__/core/README.md
diff --git a/packages/core/package.json b/packages/__legacy__/core/package.json
similarity index 93%
rename from packages/core/package.json
rename to packages/__legacy__/core/package.json
index 49dc63133..6a42b3908 100644
--- a/packages/core/package.json
+++ b/packages/__legacy__/core/package.json
@@ -1,5 +1,6 @@
{
- "name": "@asgardeo/js",
+ "private": true,
+ "name": "@asgardeo/js-legacy",
"version": "0.1.3",
"description": "Framework agnostic JS for Asgardeo or Identity Server",
"main": "dist/esm/index.js",
@@ -43,7 +44,7 @@
"@types/node": "^20.12.7",
"@wso2/eslint-plugin": "catalog:",
"@wso2/prettier-config": "catalog:",
- "eslint": "catalog:",
+ "eslint": "8.57.0",
"prettier": "^3.2.5",
"rollup": "^4.17.2",
"rollup-plugin-dts": "^6.1.0",
@@ -51,7 +52,7 @@
"typescript": "5.1.6"
},
"publishConfig": {
- "access": "public"
+ "access": "restricted"
},
"dependencies": {
"@asgardeo/auth-js": "^5.0.1",
diff --git a/packages/core/prettier.config.cjs b/packages/__legacy__/core/prettier.config.cjs
similarity index 100%
rename from packages/core/prettier.config.cjs
rename to packages/__legacy__/core/prettier.config.cjs
diff --git a/packages/core/rollup.config.cjs b/packages/__legacy__/core/rollup.config.cjs
similarity index 100%
rename from packages/core/rollup.config.cjs
rename to packages/__legacy__/core/rollup.config.cjs
diff --git a/packages/core/src/api/authenticate.ts b/packages/__legacy__/core/src/api/authenticate.ts
similarity index 100%
rename from packages/core/src/api/authenticate.ts
rename to packages/__legacy__/core/src/api/authenticate.ts
diff --git a/packages/core/src/api/authorize.ts b/packages/__legacy__/core/src/api/authorize.ts
similarity index 100%
rename from packages/core/src/api/authorize.ts
rename to packages/__legacy__/core/src/api/authorize.ts
diff --git a/packages/core/src/api/get-branding-preference-text.ts b/packages/__legacy__/core/src/api/get-branding-preference-text.ts
similarity index 100%
rename from packages/core/src/api/get-branding-preference-text.ts
rename to packages/__legacy__/core/src/api/get-branding-preference-text.ts
diff --git a/packages/core/src/api/get-branding-preference.ts b/packages/__legacy__/core/src/api/get-branding-preference.ts
similarity index 100%
rename from packages/core/src/api/get-branding-preference.ts
rename to packages/__legacy__/core/src/api/get-branding-preference.ts
diff --git a/packages/core/src/api/get-profile-information.ts b/packages/__legacy__/core/src/api/get-profile-information.ts
similarity index 100%
rename from packages/core/src/api/get-profile-information.ts
rename to packages/__legacy__/core/src/api/get-profile-information.ts
diff --git a/packages/core/src/api/public-api.ts b/packages/__legacy__/core/src/api/public-api.ts
similarity index 100%
rename from packages/core/src/api/public-api.ts
rename to packages/__legacy__/core/src/api/public-api.ts
diff --git a/packages/core/src/api/sign-out.ts b/packages/__legacy__/core/src/api/sign-out.ts
similarity index 97%
rename from packages/core/src/api/sign-out.ts
rename to packages/__legacy__/core/src/api/sign-out.ts
index 542353864..ad6416a00 100644
--- a/packages/core/src/api/sign-out.ts
+++ b/packages/__legacy__/core/src/api/sign-out.ts
@@ -51,7 +51,7 @@ const signOut = async (): Promise
=> {
try {
formBody.append('id_token_hint', await authClient.getIDToken());
formBody.append('client_id', (await authClient.getDataLayer().getConfigData()).clientID);
- formBody.append('response_mode', ResponseMode.direct);
+ formBody.append('response_mode', ResponseMode.Direct);
} catch (error) {
throw new AsgardeoUIException('JS_UI_CORE-SIGNOUT-SO-IV', 'Failed to build the body of the signout request.');
}
diff --git a/packages/core/src/auth-client.ts b/packages/__legacy__/core/src/auth-client.ts
similarity index 85%
rename from packages/core/src/auth-client.ts
rename to packages/__legacy__/core/src/auth-client.ts
index 06ef83743..51e67bcad 100644
--- a/packages/core/src/auth-client.ts
+++ b/packages/__legacy__/core/src/auth-client.ts
@@ -16,7 +16,7 @@
* under the License.
*/
-import {AsgardeoAuthClient, Store, CryptoUtils, ResponseMode} from '@asgardeo/auth-js';
+import {AsgardeoAuthClient, Store, Crypto, ResponseMode} from '@asgardeo/auth-js';
import {UIAuthClient, UIAuthConfig} from './models/auth-config';
import {BrandingPreferenceTypes} from './models/branding-api-response';
@@ -38,10 +38,10 @@ export class AuthClient {
*
* @param {UIAuthConfig} authClientConfig - The configuration for the `UIAuthClient`.
* @param {Store} store - The store for the `UIAuthClient`.
- * @param {CryptoUtils} cryptoUtils - The crypto utilities for the `UIAuthClient`.
+ * @param {Crypto} cryptoUtils - The crypto utilities for the `UIAuthClient`.
* @returns {UIAuthClient} The singleton instance of `UIAuthClient`.
*/
- static getInstance(authClientConfig?: UIAuthConfig, store?: Store, cryptoUtils?: CryptoUtils): UIAuthClient {
+ static getInstance(authClientConfig?: UIAuthConfig, store?: Store, cryptoUtils?: Crypto): UIAuthClient {
if (!AuthClient.instance) {
const DEFAULT_NAME: string = 'carbon.super';
@@ -50,7 +50,7 @@ export class AuthClient {
enableConsoleBranding: authClientConfig?.enableConsoleBranding ?? true,
enableConsoleTextBranding: authClientConfig?.enableConsoleTextBranding ?? true,
name: authClientConfig?.name ?? DEFAULT_NAME,
- responseMode: ResponseMode.direct,
+ responseMode: ResponseMode.Direct,
type: authClientConfig?.type ?? BrandingPreferenceTypes.Org,
};
@@ -63,4 +63,4 @@ export class AuthClient {
}
/* Interfaces, classes and enums required from the auth-js package */
-export {CryptoUtils, JWKInterface, Store, AsgardeoAuthClient, TokenResponse, ResponseMode} from '@asgardeo/auth-js';
+export {Crypto, JWKInterface, Store, AsgardeoAuthClient, TokenResponse, ResponseMode} from '@asgardeo/auth-js';
diff --git a/packages/core/src/branding/default-branding/dark-theme.ts b/packages/__legacy__/core/src/branding/default-branding/dark-theme.ts
similarity index 100%
rename from packages/core/src/branding/default-branding/dark-theme.ts
rename to packages/__legacy__/core/src/branding/default-branding/dark-theme.ts
diff --git a/packages/core/src/branding/default-branding/default-branding.ts b/packages/__legacy__/core/src/branding/default-branding/default-branding.ts
similarity index 100%
rename from packages/core/src/branding/default-branding/default-branding.ts
rename to packages/__legacy__/core/src/branding/default-branding/default-branding.ts
diff --git a/packages/core/src/branding/default-branding/light-theme.ts b/packages/__legacy__/core/src/branding/default-branding/light-theme.ts
similarity index 100%
rename from packages/core/src/branding/default-branding/light-theme.ts
rename to packages/__legacy__/core/src/branding/default-branding/light-theme.ts
diff --git a/packages/core/src/branding/get-branding-css.ts b/packages/__legacy__/core/src/branding/get-branding-css.ts
similarity index 100%
rename from packages/core/src/branding/get-branding-css.ts
rename to packages/__legacy__/core/src/branding/get-branding-css.ts
diff --git a/packages/core/src/branding/get-branding.ts b/packages/__legacy__/core/src/branding/get-branding.ts
similarity index 100%
rename from packages/core/src/branding/get-branding.ts
rename to packages/__legacy__/core/src/branding/get-branding.ts
diff --git a/packages/core/src/branding/public.ts b/packages/__legacy__/core/src/branding/public.ts
similarity index 100%
rename from packages/core/src/branding/public.ts
rename to packages/__legacy__/core/src/branding/public.ts
diff --git a/packages/core/src/exception.ts b/packages/__legacy__/core/src/exception.ts
similarity index 100%
rename from packages/core/src/exception.ts
rename to packages/__legacy__/core/src/exception.ts
diff --git a/packages/core/src/i18n/get-localization.ts b/packages/__legacy__/core/src/i18n/get-localization.ts
similarity index 100%
rename from packages/core/src/i18n/get-localization.ts
rename to packages/__legacy__/core/src/i18n/get-localization.ts
diff --git a/packages/core/src/i18n/public.ts b/packages/__legacy__/core/src/i18n/public.ts
similarity index 100%
rename from packages/core/src/i18n/public.ts
rename to packages/__legacy__/core/src/i18n/public.ts
diff --git a/packages/core/src/i18n/screens/common/en-US.ts b/packages/__legacy__/core/src/i18n/screens/common/en-US.ts
similarity index 100%
rename from packages/core/src/i18n/screens/common/en-US.ts
rename to packages/__legacy__/core/src/i18n/screens/common/en-US.ts
diff --git a/packages/core/src/i18n/screens/common/fr-FR.ts b/packages/__legacy__/core/src/i18n/screens/common/fr-FR.ts
similarity index 100%
rename from packages/core/src/i18n/screens/common/fr-FR.ts
rename to packages/__legacy__/core/src/i18n/screens/common/fr-FR.ts
diff --git a/packages/core/src/i18n/screens/common/model.ts b/packages/__legacy__/core/src/i18n/screens/common/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/common/model.ts
rename to packages/__legacy__/core/src/i18n/screens/common/model.ts
diff --git a/packages/core/src/i18n/screens/emailOtp/en-US.ts b/packages/__legacy__/core/src/i18n/screens/emailOtp/en-US.ts
similarity index 100%
rename from packages/core/src/i18n/screens/emailOtp/en-US.ts
rename to packages/__legacy__/core/src/i18n/screens/emailOtp/en-US.ts
diff --git a/packages/core/src/i18n/screens/emailOtp/model.ts b/packages/__legacy__/core/src/i18n/screens/emailOtp/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/emailOtp/model.ts
rename to packages/__legacy__/core/src/i18n/screens/emailOtp/model.ts
diff --git a/packages/core/src/i18n/screens/identifierFirst/en-US.ts b/packages/__legacy__/core/src/i18n/screens/identifierFirst/en-US.ts
similarity index 100%
rename from packages/core/src/i18n/screens/identifierFirst/en-US.ts
rename to packages/__legacy__/core/src/i18n/screens/identifierFirst/en-US.ts
diff --git a/packages/core/src/i18n/screens/identifierFirst/fr-FR.ts b/packages/__legacy__/core/src/i18n/screens/identifierFirst/fr-FR.ts
similarity index 100%
rename from packages/core/src/i18n/screens/identifierFirst/fr-FR.ts
rename to packages/__legacy__/core/src/i18n/screens/identifierFirst/fr-FR.ts
diff --git a/packages/core/src/i18n/screens/identifierFirst/model.ts b/packages/__legacy__/core/src/i18n/screens/identifierFirst/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/identifierFirst/model.ts
rename to packages/__legacy__/core/src/i18n/screens/identifierFirst/model.ts
diff --git a/packages/core/src/i18n/screens/keys.ts b/packages/__legacy__/core/src/i18n/screens/keys.ts
similarity index 100%
rename from packages/core/src/i18n/screens/keys.ts
rename to packages/__legacy__/core/src/i18n/screens/keys.ts
diff --git a/packages/core/src/i18n/screens/login/en-US.ts b/packages/__legacy__/core/src/i18n/screens/login/en-US.ts
similarity index 100%
rename from packages/core/src/i18n/screens/login/en-US.ts
rename to packages/__legacy__/core/src/i18n/screens/login/en-US.ts
diff --git a/packages/core/src/i18n/screens/login/fr-FR.ts b/packages/__legacy__/core/src/i18n/screens/login/fr-FR.ts
similarity index 100%
rename from packages/core/src/i18n/screens/login/fr-FR.ts
rename to packages/__legacy__/core/src/i18n/screens/login/fr-FR.ts
diff --git a/packages/core/src/i18n/screens/login/model.ts b/packages/__legacy__/core/src/i18n/screens/login/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/login/model.ts
rename to packages/__legacy__/core/src/i18n/screens/login/model.ts
diff --git a/packages/core/src/i18n/screens/model.ts b/packages/__legacy__/core/src/i18n/screens/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/model.ts
rename to packages/__legacy__/core/src/i18n/screens/model.ts
diff --git a/packages/core/src/i18n/screens/smsOtp/en-US.ts b/packages/__legacy__/core/src/i18n/screens/smsOtp/en-US.ts
similarity index 100%
rename from packages/core/src/i18n/screens/smsOtp/en-US.ts
rename to packages/__legacy__/core/src/i18n/screens/smsOtp/en-US.ts
diff --git a/packages/core/src/i18n/screens/smsOtp/model.ts b/packages/__legacy__/core/src/i18n/screens/smsOtp/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/smsOtp/model.ts
rename to packages/__legacy__/core/src/i18n/screens/smsOtp/model.ts
diff --git a/packages/core/src/i18n/screens/totp/en-US.ts b/packages/__legacy__/core/src/i18n/screens/totp/en-US.ts
similarity index 100%
rename from packages/core/src/i18n/screens/totp/en-US.ts
rename to packages/__legacy__/core/src/i18n/screens/totp/en-US.ts
diff --git a/packages/core/src/i18n/screens/totp/fr-FR.ts b/packages/__legacy__/core/src/i18n/screens/totp/fr-FR.ts
similarity index 100%
rename from packages/core/src/i18n/screens/totp/fr-FR.ts
rename to packages/__legacy__/core/src/i18n/screens/totp/fr-FR.ts
diff --git a/packages/core/src/i18n/screens/totp/model.ts b/packages/__legacy__/core/src/i18n/screens/totp/model.ts
similarity index 100%
rename from packages/core/src/i18n/screens/totp/model.ts
rename to packages/__legacy__/core/src/i18n/screens/totp/model.ts
diff --git a/packages/core/src/index.ts b/packages/__legacy__/core/src/index.ts
similarity index 100%
rename from packages/core/src/index.ts
rename to packages/__legacy__/core/src/index.ts
diff --git a/packages/core/src/models/auth-api-request.ts b/packages/__legacy__/core/src/models/auth-api-request.ts
similarity index 100%
rename from packages/core/src/models/auth-api-request.ts
rename to packages/__legacy__/core/src/models/auth-api-request.ts
diff --git a/packages/core/src/models/auth-api-response.ts b/packages/__legacy__/core/src/models/auth-api-response.ts
similarity index 100%
rename from packages/core/src/models/auth-api-response.ts
rename to packages/__legacy__/core/src/models/auth-api-response.ts
diff --git a/packages/core/src/models/auth-config.ts b/packages/__legacy__/core/src/models/auth-config.ts
similarity index 100%
rename from packages/core/src/models/auth-config.ts
rename to packages/__legacy__/core/src/models/auth-config.ts
diff --git a/packages/core/src/models/branding-api-response.ts b/packages/__legacy__/core/src/models/branding-api-response.ts
similarity index 100%
rename from packages/core/src/models/branding-api-response.ts
rename to packages/__legacy__/core/src/models/branding-api-response.ts
diff --git a/packages/core/src/models/branding-text-api-response.ts b/packages/__legacy__/core/src/models/branding-text-api-response.ts
similarity index 100%
rename from packages/core/src/models/branding-text-api-response.ts
rename to packages/__legacy__/core/src/models/branding-text-api-response.ts
diff --git a/packages/core/src/models/branding.ts b/packages/__legacy__/core/src/models/branding.ts
similarity index 100%
rename from packages/core/src/models/branding.ts
rename to packages/__legacy__/core/src/models/branding.ts
diff --git a/packages/core/src/models/common.ts b/packages/__legacy__/core/src/models/common.ts
similarity index 100%
rename from packages/core/src/models/common.ts
rename to packages/__legacy__/core/src/models/common.ts
diff --git a/packages/core/src/models/element-styles.ts b/packages/__legacy__/core/src/models/element-styles.ts
similarity index 100%
rename from packages/core/src/models/element-styles.ts
rename to packages/__legacy__/core/src/models/element-styles.ts
diff --git a/packages/core/src/models/get-branding-props.ts b/packages/__legacy__/core/src/models/get-branding-props.ts
similarity index 100%
rename from packages/core/src/models/get-branding-props.ts
rename to packages/__legacy__/core/src/models/get-branding-props.ts
diff --git a/packages/core/src/models/get-localization-props.ts b/packages/__legacy__/core/src/models/get-localization-props.ts
similarity index 100%
rename from packages/core/src/models/get-localization-props.ts
rename to packages/__legacy__/core/src/models/get-localization-props.ts
diff --git a/packages/core/src/models/me-api-response.ts b/packages/__legacy__/core/src/models/me-api-response.ts
similarity index 100%
rename from packages/core/src/models/me-api-response.ts
rename to packages/__legacy__/core/src/models/me-api-response.ts
diff --git a/packages/core/src/models/public-models.ts b/packages/__legacy__/core/src/models/public-models.ts
similarity index 100%
rename from packages/core/src/models/public-models.ts
rename to packages/__legacy__/core/src/models/public-models.ts
diff --git a/packages/core/src/models/screen-type.ts b/packages/__legacy__/core/src/models/screen-type.ts
similarity index 100%
rename from packages/core/src/models/screen-type.ts
rename to packages/__legacy__/core/src/models/screen-type.ts
diff --git a/packages/core/tsconfig.eslint.json b/packages/__legacy__/core/tsconfig.eslint.json
similarity index 100%
rename from packages/core/tsconfig.eslint.json
rename to packages/__legacy__/core/tsconfig.eslint.json
diff --git a/packages/core/tsconfig.json b/packages/__legacy__/core/tsconfig.json
similarity index 100%
rename from packages/core/tsconfig.json
rename to packages/__legacy__/core/tsconfig.json
diff --git a/packages/core/tsconfig.lib.json b/packages/__legacy__/core/tsconfig.lib.json
similarity index 100%
rename from packages/core/tsconfig.lib.json
rename to packages/__legacy__/core/tsconfig.lib.json
diff --git a/packages/__legacy__/react/.editorconfig b/packages/__legacy__/react/.editorconfig
new file mode 100644
index 000000000..54a161112
--- /dev/null
+++ b/packages/__legacy__/react/.editorconfig
@@ -0,0 +1 @@
+../../.editorconfig
diff --git a/packages/__legacy__/react/.eslintignore b/packages/__legacy__/react/.eslintignore
new file mode 100644
index 000000000..c925c21d5
--- /dev/null
+++ b/packages/__legacy__/react/.eslintignore
@@ -0,0 +1,2 @@
+/dist
+/node_modules
diff --git a/packages/__legacy__/react/.eslintrc.cjs b/packages/__legacy__/react/.eslintrc.cjs
new file mode 100644
index 000000000..d8644f33e
--- /dev/null
+++ b/packages/__legacy__/react/.eslintrc.cjs
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const path = require('path');
+
+module.exports = {
+ extends: [
+ 'plugin:@wso2/typescript',
+ 'plugin:@wso2/react',
+ 'plugin:@wso2/strict',
+ 'plugin:@wso2/internal',
+ 'plugin:@wso2/prettier',
+ 'plugin:@wso2/jest',
+ 'plugin:react/jsx-runtime',
+ ],
+ parserOptions: {
+ project: [path.resolve(__dirname, 'tsconfig.lib.json'), path.resolve(__dirname, 'tsconfig.eslint.json')],
+ },
+ plugins: ['@wso2'],
+ rules: {
+ // In `SignIn.tsx` we are using non dot notation to access the object properties.
+ // TODO: Refactor the code to use dot notation.
+ '@typescript-eslint/dot-notation': 'off',
+ // We are throwing custom exceptions in the codebase.
+ // Hence, turning this off to avoid linting errors. (https://eslint.org/docs/latest/rules/no-throw-literal#known-limitations)
+ '@typescript-eslint/no-throw-literal': 'off',
+ // TODO: Fix this and enable.
+ // Occurred while linting /packages/react/src/utils/crypto-utils.ts:33
+ // Rule: "@typescript-eslint/no-useless-constructor"
+ '@typescript-eslint/no-useless-constructor': 'off',
+ 'class-methods-use-this': 'off',
+ },
+};
diff --git a/packages/__legacy__/react/.gitignore b/packages/__legacy__/react/.gitignore
new file mode 100644
index 000000000..f20a8a8c1
--- /dev/null
+++ b/packages/__legacy__/react/.gitignore
@@ -0,0 +1,134 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+.pnpm-debug.log*
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+*.lcov
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+web_modules/
+
+# TypeScript cache
+*.tsbuildinfo
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional stylelint cache
+.stylelintcache
+
+# Microbundle cache
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variable files
+.env
+.env.development.local
+.env.test.local
+.env.production.local
+.env.local
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+.parcel-cache
+
+# Next.js build output
+.next
+out
+
+# Nuxt.js build / generate output
+.nuxt
+dist
+
+# Gatsby files
+.cache/
+# Comment in the public line in if your project uses Gatsby and not Next.js
+# https://nextjs.org/blog/next-9-1#public-directory-support
+# public
+
+# vuepress build output
+.vuepress/dist
+
+# vuepress v2.x temp and cache directory
+.temp
+.cache
+
+# Docusaurus cache and generated files
+.docusaurus
+
+# Serverless directories
+.serverless/
+
+# FuseBox cache
+.fusebox/
+
+# DynamoDB Local files
+.dynamodb/
+
+# TernJS port file
+.tern-port
+
+# Stores VSCode versions used for testing VSCode extensions
+.vscode-test
+
+# yarn v2
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.*
+
+# misc
+.DS_Store
+*.pem
diff --git a/packages/__legacy__/react/.prettierignore b/packages/__legacy__/react/.prettierignore
new file mode 100644
index 000000000..c925c21d5
--- /dev/null
+++ b/packages/__legacy__/react/.prettierignore
@@ -0,0 +1,2 @@
+/dist
+/node_modules
diff --git a/packages/react/CHANGELOG.md b/packages/__legacy__/react/CHANGELOG.md
similarity index 100%
rename from packages/react/CHANGELOG.md
rename to packages/__legacy__/react/CHANGELOG.md
diff --git a/packages/__legacy__/react/LICENSE b/packages/__legacy__/react/LICENSE
new file mode 100644
index 000000000..261eeb9e9
--- /dev/null
+++ b/packages/__legacy__/react/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/__legacy__/react/README.md b/packages/__legacy__/react/README.md
new file mode 100644
index 000000000..30b225361
--- /dev/null
+++ b/packages/__legacy__/react/README.md
@@ -0,0 +1,27 @@
+
+
@asgardeo/react
+
+React Wrapper to build customizable login UIs for Asgardeo or Identity Server
+
+
+## Installation
+
+```bash
+# With npm
+npm install @asgardeo/react
+
+# With pnpm
+pnpm add @asgardeo/react
+
+# With yarn
+yarn add @asgardeo/react
+```
+
+## License
+
+Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in
+compliance with the License.
diff --git a/packages/react/declarations.d.ts b/packages/__legacy__/react/declarations.d.ts
similarity index 100%
rename from packages/react/declarations.d.ts
rename to packages/__legacy__/react/declarations.d.ts
diff --git a/packages/__legacy__/react/package.json b/packages/__legacy__/react/package.json
new file mode 100644
index 000000000..a0cffd761
--- /dev/null
+++ b/packages/__legacy__/react/package.json
@@ -0,0 +1,81 @@
+{
+ "private": true,
+ "name": "@asgardeo/react-legacy",
+ "version": "0.2.4",
+ "description": "React Wrapper to build customizable login UIs for Asgardeo or Identity Server",
+ "main": "dist/esm/index.js",
+ "module": "dist/esm/index.js",
+ "types": "dist/index.d.ts",
+ "type": "module",
+ "author": "WSO2",
+ "license": "Apache-2.0",
+ "files": [
+ "dist",
+ "LICENSE",
+ "README.md"
+ ],
+ "homepage": "https://github.com/asgardeo/web-ui-sdks/tree/main/packages/react#readme",
+ "bugs": {
+ "url": "https://github.com/asgardeo/web-ui-sdks/issues"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/asgardeo/web-ui-sdks",
+ "directory": "packages/react"
+ },
+ "keywords": [
+ "asgardeo",
+ "identity",
+ "ui",
+ "react",
+ "login",
+ "customize"
+ ],
+ "scripts": {
+ "build": "rollup -c",
+ "lint": "eslint .",
+ "lint:fix": "eslint . --fix"
+ },
+ "publishConfig": {
+ "access": "restricted"
+ },
+ "devDependencies": {
+ "@rollup/plugin-commonjs": "^25.0.7",
+ "@rollup/plugin-image": "^3.0.3",
+ "@rollup/plugin-node-resolve": "^15.2.3",
+ "@rollup/plugin-typescript": "^11.1.6",
+ "@types/node": "^20.12.7",
+ "@types/randombytes": "^2.0.3",
+ "@types/react": "^18.2.79",
+ "@types/react-dom": "^18.2.25",
+ "@wso2/eslint-plugin": "catalog:",
+ "@wso2/prettier-config": "catalog:",
+ "@wso2/stylelint-config": "catalog:",
+ "eslint": "8.57.0",
+ "prettier": "^3.2.5",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "rollup": "^4.17.2",
+ "rollup-plugin-dts": "^6.1.0",
+ "rollup-plugin-polyfill-node": "^0.13.0",
+ "rollup-plugin-styles": "^4.0.0",
+ "sass": "^1.75.0",
+ "stylelint": "15.1.0",
+ "tslib": "^2.6.2",
+ "typescript": "5.1.6"
+ },
+ "dependencies": {
+ "@asgardeo/js": "*",
+ "@oxygen-ui/react": "^1.11.0",
+ "base64url": "^3.0.1",
+ "buffer": "^6.0.3",
+ "clsx": "^2.1.1",
+ "fast-sha256": "^1.3.0",
+ "jose": "^5.3.0",
+ "randombytes": "^2.1.0"
+ },
+ "peerDependencies": {
+ "react": ">=18.0.0",
+ "react-dom": ">=18.0.0"
+ }
+}
diff --git a/packages/__legacy__/react/prettier.config.cjs b/packages/__legacy__/react/prettier.config.cjs
new file mode 100644
index 000000000..c07f730d2
--- /dev/null
+++ b/packages/__legacy__/react/prettier.config.cjs
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+module.exports = require('@wso2/prettier-config');
diff --git a/packages/react/rollup.config.cjs b/packages/__legacy__/react/rollup.config.cjs
similarity index 100%
rename from packages/react/rollup.config.cjs
rename to packages/__legacy__/react/rollup.config.cjs
diff --git a/packages/react/src/assets/building-icon.svg b/packages/__legacy__/react/src/assets/building-icon.svg
similarity index 100%
rename from packages/react/src/assets/building-icon.svg
rename to packages/__legacy__/react/src/assets/building-icon.svg
diff --git a/packages/react/src/assets/email-solid.svg b/packages/__legacy__/react/src/assets/email-solid.svg
similarity index 100%
rename from packages/react/src/assets/email-solid.svg
rename to packages/__legacy__/react/src/assets/email-solid.svg
diff --git a/packages/react/src/assets/sms-icon.svg b/packages/__legacy__/react/src/assets/sms-icon.svg
similarity index 100%
rename from packages/react/src/assets/sms-icon.svg
rename to packages/__legacy__/react/src/assets/sms-icon.svg
diff --git a/packages/react/src/assets/social-logins/facebook.svg b/packages/__legacy__/react/src/assets/social-logins/facebook.svg
similarity index 100%
rename from packages/react/src/assets/social-logins/facebook.svg
rename to packages/__legacy__/react/src/assets/social-logins/facebook.svg
diff --git a/packages/react/src/assets/social-logins/github.svg b/packages/__legacy__/react/src/assets/social-logins/github.svg
similarity index 100%
rename from packages/react/src/assets/social-logins/github.svg
rename to packages/__legacy__/react/src/assets/social-logins/github.svg
diff --git a/packages/react/src/assets/social-logins/google.svg b/packages/__legacy__/react/src/assets/social-logins/google.svg
similarity index 100%
rename from packages/react/src/assets/social-logins/google.svg
rename to packages/__legacy__/react/src/assets/social-logins/google.svg
diff --git a/packages/react/src/assets/social-logins/microsoft.svg b/packages/__legacy__/react/src/assets/social-logins/microsoft.svg
similarity index 100%
rename from packages/react/src/assets/social-logins/microsoft.svg
rename to packages/__legacy__/react/src/assets/social-logins/microsoft.svg
diff --git a/packages/react/src/assets/totp.svg b/packages/__legacy__/react/src/assets/totp.svg
similarity index 100%
rename from packages/react/src/assets/totp.svg
rename to packages/__legacy__/react/src/assets/totp.svg
diff --git a/packages/react/src/components/SignIn/SignIn.tsx b/packages/__legacy__/react/src/components/SignIn/SignIn.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/SignIn.tsx
rename to packages/__legacy__/react/src/components/SignIn/SignIn.tsx
diff --git a/packages/react/src/components/SignIn/fragments/BasicAuth.tsx b/packages/__legacy__/react/src/components/SignIn/fragments/BasicAuth.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/BasicAuth.tsx
rename to packages/__legacy__/react/src/components/SignIn/fragments/BasicAuth.tsx
diff --git a/packages/react/src/components/SignIn/fragments/EmailOtp.tsx b/packages/__legacy__/react/src/components/SignIn/fragments/EmailOtp.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/EmailOtp.tsx
rename to packages/__legacy__/react/src/components/SignIn/fragments/EmailOtp.tsx
diff --git a/packages/react/src/components/SignIn/fragments/IdentifierFirst.tsx b/packages/__legacy__/react/src/components/SignIn/fragments/IdentifierFirst.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/IdentifierFirst.tsx
rename to packages/__legacy__/react/src/components/SignIn/fragments/IdentifierFirst.tsx
diff --git a/packages/react/src/components/SignIn/fragments/LoginOptionsBox.tsx b/packages/__legacy__/react/src/components/SignIn/fragments/LoginOptionsBox.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/LoginOptionsBox.tsx
rename to packages/__legacy__/react/src/components/SignIn/fragments/LoginOptionsBox.tsx
diff --git a/packages/react/src/components/SignIn/fragments/SmsOtp.tsx b/packages/__legacy__/react/src/components/SignIn/fragments/SmsOtp.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/SmsOtp.tsx
rename to packages/__legacy__/react/src/components/SignIn/fragments/SmsOtp.tsx
diff --git a/packages/react/src/components/SignIn/fragments/Totp.tsx b/packages/__legacy__/react/src/components/SignIn/fragments/Totp.tsx
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/Totp.tsx
rename to packages/__legacy__/react/src/components/SignIn/fragments/Totp.tsx
diff --git a/packages/react/src/components/SignIn/fragments/basic-auth.scss b/packages/__legacy__/react/src/components/SignIn/fragments/basic-auth.scss
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/basic-auth.scss
rename to packages/__legacy__/react/src/components/SignIn/fragments/basic-auth.scss
diff --git a/packages/react/src/components/SignIn/fragments/email-otp.scss b/packages/__legacy__/react/src/components/SignIn/fragments/email-otp.scss
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/email-otp.scss
rename to packages/__legacy__/react/src/components/SignIn/fragments/email-otp.scss
diff --git a/packages/react/src/components/SignIn/fragments/totp.scss b/packages/__legacy__/react/src/components/SignIn/fragments/totp.scss
similarity index 100%
rename from packages/react/src/components/SignIn/fragments/totp.scss
rename to packages/__legacy__/react/src/components/SignIn/fragments/totp.scss
diff --git a/packages/react/src/components/SignIn/sign-in.scss b/packages/__legacy__/react/src/components/SignIn/sign-in.scss
similarity index 100%
rename from packages/react/src/components/SignIn/sign-in.scss
rename to packages/__legacy__/react/src/components/SignIn/sign-in.scss
diff --git a/packages/react/src/components/SignInButton/SignInButton.tsx b/packages/__legacy__/react/src/components/SignInButton/SignInButton.tsx
similarity index 100%
rename from packages/react/src/components/SignInButton/SignInButton.tsx
rename to packages/__legacy__/react/src/components/SignInButton/SignInButton.tsx
diff --git a/packages/react/src/components/SignInButton/sign-in-button.scss b/packages/__legacy__/react/src/components/SignInButton/sign-in-button.scss
similarity index 100%
rename from packages/react/src/components/SignInButton/sign-in-button.scss
rename to packages/__legacy__/react/src/components/SignInButton/sign-in-button.scss
diff --git a/packages/react/src/components/SignOutButton/SignOutButton.tsx b/packages/__legacy__/react/src/components/SignOutButton/SignOutButton.tsx
similarity index 100%
rename from packages/react/src/components/SignOutButton/SignOutButton.tsx
rename to packages/__legacy__/react/src/components/SignOutButton/SignOutButton.tsx
diff --git a/packages/react/src/components/SignedIn/SignedIn.tsx b/packages/__legacy__/react/src/components/SignedIn/SignedIn.tsx
similarity index 100%
rename from packages/react/src/components/SignedIn/SignedIn.tsx
rename to packages/__legacy__/react/src/components/SignedIn/SignedIn.tsx
diff --git a/packages/react/src/components/SignedOut/SignedOut.tsx b/packages/__legacy__/react/src/components/SignedOut/SignedOut.tsx
similarity index 100%
rename from packages/react/src/components/SignedOut/SignedOut.tsx
rename to packages/__legacy__/react/src/components/SignedOut/SignedOut.tsx
diff --git a/packages/react/src/components/public-components.ts b/packages/__legacy__/react/src/components/public-components.ts
similarity index 100%
rename from packages/react/src/components/public-components.ts
rename to packages/__legacy__/react/src/components/public-components.ts
diff --git a/packages/react/src/contexts/asgardeo-context.ts b/packages/__legacy__/react/src/contexts/asgardeo-context.ts
similarity index 100%
rename from packages/react/src/contexts/asgardeo-context.ts
rename to packages/__legacy__/react/src/contexts/asgardeo-context.ts
diff --git a/packages/react/src/contexts/branding-preference-context.ts b/packages/__legacy__/react/src/contexts/branding-preference-context.ts
similarity index 100%
rename from packages/react/src/contexts/branding-preference-context.ts
rename to packages/__legacy__/react/src/contexts/branding-preference-context.ts
diff --git a/packages/react/src/contexts/i18n-context.ts b/packages/__legacy__/react/src/contexts/i18n-context.ts
similarity index 100%
rename from packages/react/src/contexts/i18n-context.ts
rename to packages/__legacy__/react/src/contexts/i18n-context.ts
diff --git a/packages/react/src/hooks/use-authentication.ts b/packages/__legacy__/react/src/hooks/use-authentication.ts
similarity index 100%
rename from packages/react/src/hooks/use-authentication.ts
rename to packages/__legacy__/react/src/hooks/use-authentication.ts
diff --git a/packages/react/src/hooks/use-config.ts b/packages/__legacy__/react/src/hooks/use-config.ts
similarity index 100%
rename from packages/react/src/hooks/use-config.ts
rename to packages/__legacy__/react/src/hooks/use-config.ts
diff --git a/packages/react/src/hooks/use-on.ts b/packages/__legacy__/react/src/hooks/use-on.ts
similarity index 100%
rename from packages/react/src/hooks/use-on.ts
rename to packages/__legacy__/react/src/hooks/use-on.ts
diff --git a/packages/react/src/hooks/use-translations.ts b/packages/__legacy__/react/src/hooks/use-translations.ts
similarity index 100%
rename from packages/react/src/hooks/use-translations.ts
rename to packages/__legacy__/react/src/hooks/use-translations.ts
diff --git a/packages/__legacy__/react/src/index.ts b/packages/__legacy__/react/src/index.ts
new file mode 100644
index 000000000..98f497c95
--- /dev/null
+++ b/packages/__legacy__/react/src/index.ts
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from './components/public-components';
+export * from './models/public-models';
+export {default as AsgardeoProvider} from './providers/AsgardeoProvider';
+export {default as useAuthentication} from './hooks/use-authentication';
+export {default as useOn} from './hooks/use-on';
diff --git a/packages/react/src/models/asgardeo-provider-props.ts b/packages/__legacy__/react/src/models/asgardeo-provider-props.ts
similarity index 100%
rename from packages/react/src/models/asgardeo-provider-props.ts
rename to packages/__legacy__/react/src/models/asgardeo-provider-props.ts
diff --git a/packages/react/src/models/auth-context.ts b/packages/__legacy__/react/src/models/auth-context.ts
similarity index 100%
rename from packages/react/src/models/auth-context.ts
rename to packages/__legacy__/react/src/models/auth-context.ts
diff --git a/packages/react/src/models/basic-auth-props.ts b/packages/__legacy__/react/src/models/basic-auth-props.ts
similarity index 100%
rename from packages/react/src/models/basic-auth-props.ts
rename to packages/__legacy__/react/src/models/basic-auth-props.ts
diff --git a/packages/react/src/models/branding-preference-provider-props.ts b/packages/__legacy__/react/src/models/branding-preference-provider-props.ts
similarity index 100%
rename from packages/react/src/models/branding-preference-provider-props.ts
rename to packages/__legacy__/react/src/models/branding-preference-provider-props.ts
diff --git a/packages/react/src/models/email-otp-props.ts b/packages/__legacy__/react/src/models/email-otp-props.ts
similarity index 100%
rename from packages/react/src/models/email-otp-props.ts
rename to packages/__legacy__/react/src/models/email-otp-props.ts
diff --git a/packages/react/src/models/i18n.ts b/packages/__legacy__/react/src/models/i18n.ts
similarity index 100%
rename from packages/react/src/models/i18n.ts
rename to packages/__legacy__/react/src/models/i18n.ts
diff --git a/packages/react/src/models/jwt-verify-options.ts b/packages/__legacy__/react/src/models/jwt-verify-options.ts
similarity index 100%
rename from packages/react/src/models/jwt-verify-options.ts
rename to packages/__legacy__/react/src/models/jwt-verify-options.ts
diff --git a/packages/react/src/models/login-options-box-props.ts b/packages/__legacy__/react/src/models/login-options-box-props.ts
similarity index 100%
rename from packages/react/src/models/login-options-box-props.ts
rename to packages/__legacy__/react/src/models/login-options-box-props.ts
diff --git a/packages/react/src/models/public-models.ts b/packages/__legacy__/react/src/models/public-models.ts
similarity index 100%
rename from packages/react/src/models/public-models.ts
rename to packages/__legacy__/react/src/models/public-models.ts
diff --git a/packages/react/src/models/sign-in.ts b/packages/__legacy__/react/src/models/sign-in.ts
similarity index 100%
rename from packages/react/src/models/sign-in.ts
rename to packages/__legacy__/react/src/models/sign-in.ts
diff --git a/packages/react/src/models/signed-props.ts b/packages/__legacy__/react/src/models/signed-props.ts
similarity index 100%
rename from packages/react/src/models/signed-props.ts
rename to packages/__legacy__/react/src/models/signed-props.ts
diff --git a/packages/react/src/models/totp-props.ts b/packages/__legacy__/react/src/models/totp-props.ts
similarity index 100%
rename from packages/react/src/models/totp-props.ts
rename to packages/__legacy__/react/src/models/totp-props.ts
diff --git a/packages/react/src/models/use-authentication.ts b/packages/__legacy__/react/src/models/use-authentication.ts
similarity index 100%
rename from packages/react/src/models/use-authentication.ts
rename to packages/__legacy__/react/src/models/use-authentication.ts
diff --git a/packages/react/src/models/use-config.ts b/packages/__legacy__/react/src/models/use-config.ts
similarity index 100%
rename from packages/react/src/models/use-config.ts
rename to packages/__legacy__/react/src/models/use-config.ts
diff --git a/packages/react/src/models/use-on.ts b/packages/__legacy__/react/src/models/use-on.ts
similarity index 100%
rename from packages/react/src/models/use-on.ts
rename to packages/__legacy__/react/src/models/use-on.ts
diff --git a/packages/react/src/models/use-translations.ts b/packages/__legacy__/react/src/models/use-translations.ts
similarity index 100%
rename from packages/react/src/models/use-translations.ts
rename to packages/__legacy__/react/src/models/use-translations.ts
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignIn/SignIn.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignIn/SignIn.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignIn/SignIn.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignIn/SignIn.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignIn/sign-in.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignIn/sign-in.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignIn/sign-in.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignIn/sign-in.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInAlert/sign-in-alert.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInAlert/sign-in-alert.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInAlert/sign-in-alert.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInAlert/sign-in-alert.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInButton/SignInButton.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInButton/SignInButton.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInButton/SignInButton.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInButton/SignInButton.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInButton/sign-in-button.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInButton/sign-in-button.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInButton/sign-in-button.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInButton/sign-in-button.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInDivider/sign-in-divider.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInDivider/sign-in-divider.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInDivider/sign-in-divider.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInDivider/sign-in-divider.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInFooter/sign-in-footer.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInFooter/sign-in-footer.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInFooter/sign-in-footer.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInFooter/sign-in-footer.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInImage/SignInImage.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInImage/SignInImage.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInImage/SignInImage.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInImage/SignInImage.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInImage/sign-in-image.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInImage/sign-in-image.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInImage/sign-in-image.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInImage/sign-in-image.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInLink/SignInLink.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInLink/SignInLink.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInLink/SignInLink.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInLink/SignInLink.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInPaper/sign-in-paper.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPaper/sign-in-paper.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInPaper/sign-in-paper.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPaper/sign-in-paper.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInPinInput/sign-in-pin-input.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPinInput/sign-in-pin-input.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInPinInput/sign-in-pin-input.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInPinInput/sign-in-pin-input.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInTextField/sign-in-text-field.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTextField/sign-in-text-field.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInTextField/sign-in-text-field.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTextField/sign-in-text-field.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.tsx b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.tsx
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.tsx
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.tsx
diff --git a/packages/react/src/oxygen-ui-react-auth-components/SignInTypography/sign-in-typography.scss b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTypography/sign-in-typography.scss
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/SignInTypography/sign-in-typography.scss
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/SignInTypography/sign-in-typography.scss
diff --git a/packages/react/src/oxygen-ui-react-auth-components/index.ts b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/index.ts
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/index.ts
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/index.ts
diff --git a/packages/react/src/oxygen-ui-react-auth-components/models/component.ts b/packages/__legacy__/react/src/oxygen-ui-react-auth-components/models/component.ts
similarity index 100%
rename from packages/react/src/oxygen-ui-react-auth-components/models/component.ts
rename to packages/__legacy__/react/src/oxygen-ui-react-auth-components/models/component.ts
diff --git a/packages/__legacy__/react/src/providers/AsgardeoProvider.tsx b/packages/__legacy__/react/src/providers/AsgardeoProvider.tsx
new file mode 100644
index 000000000..0400cee9a
--- /dev/null
+++ b/packages/__legacy__/react/src/providers/AsgardeoProvider.tsx
@@ -0,0 +1,187 @@
+/**
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ AuthApiResponse,
+ AuthClient,
+ Crypto,
+ MeAPIResponse,
+ Store,
+ UIAuthClient,
+ getProfileInformation,
+} from '@asgardeo/js';
+import {FC, PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState} from 'react';
+import BrandingPreferenceProvider from './BrandingPreferenceProvider';
+import I18nProvider from './I18nProvider';
+import AsgardeoContext from '../contexts/asgardeo-context';
+import AsgardeoProviderProps from '../models/asgardeo-provider-props';
+import AuthContext from '../models/auth-context';
+import SPACryptoUtils from '../utils/crypto-utils';
+import SessionStore from '../utils/session-store';
+
+/**
+ * `AsgardeoProvider` is a component that provides an Asgardeo context to all its children.
+ * It takes an object of type `AsgardeProviderProps` as props, which includes the children to render,
+ * a configuration object, a store instance, and a branding object.
+ *
+ * @param {PropsWithChildren} props - The properties passed to the component.
+ * @param {ReactNode} props.children - The children to render inside the provider.
+ * @param {Config} props.config - The configuration object for the Asgardeo context.
+ * @param {Store} [props.store] - An optional store instance. If not provided, a new SessionStore will be created.
+ * @param {Branding} props.branding - The branding object for the Asgardeo context.
+ *
+ * @returns {ReactElement} A React element that provides the Asgardeo context to all its children.
+ */
+const AsgardeoProvider: FC> = (
+ props: PropsWithChildren,
+) => {
+ const {children, config, store, branding} = props;
+
+ const [accessToken, setAccessToken] = useState('');
+ const [isAuthenticated, setIsAuthenticated] = useState();
+ const [user, setUser] = useState();
+ const [isBrandingLoading, setIsBrandingLoading] = useState(true);
+ const [isTextLoading, setIsTextLoading] = useState(true);
+ const [isAuthLoading, setIsAuthLoading] = useState(false);
+ const [isComponentLoading, setIsComponentLoading] = useState(true);
+ const [authResponse, setAuthResponse] = useState();
+ const [username, setUsername] = useState('');
+
+ const onSignInRef: React.MutableRefObject = useRef();
+ const onSignOutRef: React.MutableRefObject = useRef();
+
+ const setOnSignIn: (newOnSignIn: Function) => void = useCallback(
+ (newOnSignIn: Function): void => {
+ onSignInRef.current = newOnSignIn;
+ },
+ [], // Add any dependencies here...
+ );
+
+ const setOnSignOut: (newOnSignOut: Function) => void = useCallback(
+ (newOnSignOut: Function): void => {
+ onSignOutRef.current = newOnSignOut;
+ },
+ [], // Add any dependencies here...
+ );
+
+ const storeInstance: Store = store || new SessionStore();
+
+ const spaUtils: Crypto = new SPACryptoUtils();
+
+ const authClient: UIAuthClient = AuthClient.getInstance(config, storeInstance, spaUtils);
+
+ /**
+ * Sets the authentication status and access token.
+ */
+ const setAuthentication: () => void = useCallback((): void => {
+ authClient.isAuthenticated().then((isAuth: boolean) => {
+ setIsAuthenticated(isAuth);
+
+ if (isAuth) {
+ authClient.getAccessToken().then((accessTokenFromClient: string) => {
+ if (accessTokenFromClient) {
+ setAccessToken(accessTokenFromClient);
+
+ getProfileInformation().then((response: MeAPIResponse) => {
+ setUser(response);
+ });
+
+ if (onSignInRef.current) {
+ onSignInRef.current();
+ }
+ }
+ });
+ }
+ });
+ }, [authClient]);
+
+ useEffect(() => {
+ setAuthentication();
+
+ /**
+ * This script is added so that the popup window can send the code and state to the parent window
+ */
+ const url: URL = new URL(window.location.href);
+ if (url.searchParams.has('code') && url.searchParams.has('state')) {
+ const code: string = url.searchParams.get('code');
+ const state: string = url.searchParams.get('state');
+
+ /**
+ * Send the 'code' and 'state' to the parent window and close the current window (popup)
+ */
+ window.opener.postMessage({code, state}, config.signInRedirectURL);
+ window.close();
+ }
+ }, [config.signInRedirectURL, setAuthentication]);
+
+ const value: AuthContext = useMemo(
+ () => ({
+ accessToken,
+ authResponse,
+ config,
+ isAuthLoading,
+ isAuthenticated,
+ isBrandingLoading,
+ isComponentLoading,
+ isGlobalLoading: isAuthLoading || isBrandingLoading || isComponentLoading || isTextLoading,
+ isTextLoading,
+ onSignOutRef,
+ setAuthResponse,
+ setAuthentication,
+ setIsAuthLoading,
+ setIsBrandingLoading,
+ setIsComponentLoading,
+ setIsTextLoading,
+ setOnSignIn,
+ setOnSignOut,
+ setUsername,
+ user,
+ username,
+ }),
+ [
+ accessToken,
+ authResponse,
+ config,
+ isAuthLoading,
+ isAuthenticated,
+ isBrandingLoading,
+ isComponentLoading,
+ isTextLoading,
+ setAuthResponse,
+ setAuthentication,
+ setIsComponentLoading,
+ setOnSignIn,
+ setOnSignOut,
+ setUsername,
+ user,
+ username,
+ ],
+ );
+
+ return (
+
+
+
+ {children}
+
+
+
+ );
+};
+
+export default AsgardeoProvider;
diff --git a/packages/react/src/providers/BrandingPreferenceProvider.tsx b/packages/__legacy__/react/src/providers/BrandingPreferenceProvider.tsx
similarity index 100%
rename from packages/react/src/providers/BrandingPreferenceProvider.tsx
rename to packages/__legacy__/react/src/providers/BrandingPreferenceProvider.tsx
diff --git a/packages/react/src/providers/I18nProvider.tsx b/packages/__legacy__/react/src/providers/I18nProvider.tsx
similarity index 100%
rename from packages/react/src/providers/I18nProvider.tsx
rename to packages/__legacy__/react/src/providers/I18nProvider.tsx
diff --git a/packages/react/src/theme/generate-theme-sign-in.ts b/packages/__legacy__/react/src/theme/generate-theme-sign-in.ts
similarity index 100%
rename from packages/react/src/theme/generate-theme-sign-in.ts
rename to packages/__legacy__/react/src/theme/generate-theme-sign-in.ts
diff --git a/packages/react/src/theme/generate-theme.ts b/packages/__legacy__/react/src/theme/generate-theme.ts
similarity index 100%
rename from packages/react/src/theme/generate-theme.ts
rename to packages/__legacy__/react/src/theme/generate-theme.ts
diff --git a/packages/react/src/utils/crypto-utils.ts b/packages/__legacy__/react/src/utils/crypto-utils.ts
similarity index 94%
rename from packages/react/src/utils/crypto-utils.ts
rename to packages/__legacy__/react/src/utils/crypto-utils.ts
index 9612bdd5d..566756560 100644
--- a/packages/react/src/utils/crypto-utils.ts
+++ b/packages/__legacy__/react/src/utils/crypto-utils.ts
@@ -17,14 +17,14 @@
*/
import {Buffer} from 'buffer';
-import {CryptoUtils, JWKInterface, AsgardeoUIException} from '@asgardeo/js';
+import {Crypto, JWKInterface, AsgardeoUIException} from '@asgardeo/js';
import base64url from 'base64url';
import sha256 from 'fast-sha256';
import {createLocalJWKSet, jwtVerify} from 'jose';
import randombytes from 'randombytes';
import JwtVerifyOptions from '../models/jwt-verify-options';
-export default class SPACryptoUtils implements CryptoUtils {
+export default class SPACryptoUtils implements Crypto {
/**
* Get URL encoded string.
*
diff --git a/packages/react/src/utils/session-store.ts b/packages/__legacy__/react/src/utils/session-store.ts
similarity index 100%
rename from packages/react/src/utils/session-store.ts
rename to packages/__legacy__/react/src/utils/session-store.ts
diff --git a/packages/react/stylelint.config.cjs b/packages/__legacy__/react/stylelint.config.cjs
similarity index 100%
rename from packages/react/stylelint.config.cjs
rename to packages/__legacy__/react/stylelint.config.cjs
diff --git a/packages/__legacy__/react/tsconfig.eslint.json b/packages/__legacy__/react/tsconfig.eslint.json
new file mode 100644
index 000000000..bdaa69d4b
--- /dev/null
+++ b/packages/__legacy__/react/tsconfig.eslint.json
@@ -0,0 +1,14 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "module": "ESNext",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "**/*.cjs",
+ "**/*.js",
+ "**/*.jsx",
+ "**/*.ts",
+ "**/*.tsx",
+ ]
+ }
diff --git a/packages/__legacy__/react/tsconfig.json b/packages/__legacy__/react/tsconfig.json
new file mode 100644
index 000000000..cb627bf60
--- /dev/null
+++ b/packages/__legacy__/react/tsconfig.json
@@ -0,0 +1,35 @@
+{
+ "compileOnSave": false,
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "target": "es2016",
+ "module": "ESNext",
+ "emitDecoratorMetadata": true,
+ "esModuleInterop": true,
+ "experimentalDecorators": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": false,
+ "skipLibCheck": true,
+ "skipDefaultLibCheck": true,
+ "allowJs": true,
+ "allowSyntheticDefaultImports": true,
+ "declaration": true,
+ "declarationDir": "dist/types",
+ "outDir": "dist",
+ "moduleResolution": "node",
+ "importHelpers": true,
+ "resolveJsonModule": true,
+ "noImplicitOverride": true,
+ "noPropertyAccessFromIndexSignature": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ },
+ "include": [],
+ "files": [],
+ "exclude": ["node_modules", "tmp"],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ }
+ ]
+}
diff --git a/packages/__legacy__/react/tsconfig.lib.json b/packages/__legacy__/react/tsconfig.lib.json
new file mode 100644
index 000000000..7f9476b9b
--- /dev/null
+++ b/packages/__legacy__/react/tsconfig.lib.json
@@ -0,0 +1,26 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "declaration": true,
+ "outDir": "dist",
+ "declarationDir": "types",
+ "types": ["node"],
+ "emitDeclarationOnly": true
+ },
+ "files": [],
+ "exclude": [
+ "test-configs",
+ "jest.config.ts",
+ "**/*.spec.ts",
+ "**/*.test.ts",
+ "**/*.spec.tsx",
+ "**/*.test.tsx",
+ "**/*.spec.js",
+ "**/*.test.js",
+ "**/*.spec.jsx",
+ "**/*.test.jsx",
+ "scripts",
+ "dist"
+ ],
+ "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "rollup.config.cjs", "declarations.d.ts"]
+ }
diff --git a/packages/browser/.editorconfig b/packages/browser/.editorconfig
new file mode 100644
index 000000000..1b3ce07de
--- /dev/null
+++ b/packages/browser/.editorconfig
@@ -0,0 +1 @@
+../../.editorconfig
\ No newline at end of file
diff --git a/packages/browser/.eslintignore b/packages/browser/.eslintignore
new file mode 100644
index 000000000..177586b6b
--- /dev/null
+++ b/packages/browser/.eslintignore
@@ -0,0 +1,4 @@
+/dist
+/build
+/node_modules
+/coverage
\ No newline at end of file
diff --git a/packages/browser/.eslintrc.cjs b/packages/browser/.eslintrc.cjs
new file mode 100644
index 000000000..2676ca816
--- /dev/null
+++ b/packages/browser/.eslintrc.cjs
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const path = require('path');
+
+module.exports = {
+ env: {
+ es6: true,
+ node: true,
+ },
+ extends: [
+ 'plugin:@wso2/typescript',
+ 'plugin:@wso2/strict',
+ 'plugin:@wso2/internal',
+ 'plugin:@wso2/jest',
+ 'plugin:@wso2/prettier',
+ ],
+ parserOptions: {
+ ecmaVersion: 2018,
+ project: [path.resolve(__dirname, 'tsconfig.eslint.json')],
+ },
+ plugins: ['@wso2'],
+};
diff --git a/packages/browser/.gitignore b/packages/browser/.gitignore
new file mode 100644
index 000000000..c6bba5913
--- /dev/null
+++ b/packages/browser/.gitignore
@@ -0,0 +1,130 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+.pnpm-debug.log*
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+*.lcov
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+web_modules/
+
+# TypeScript cache
+*.tsbuildinfo
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional stylelint cache
+.stylelintcache
+
+# Microbundle cache
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variable files
+.env
+.env.development.local
+.env.test.local
+.env.production.local
+.env.local
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+.parcel-cache
+
+# Next.js build output
+.next
+out
+
+# Nuxt.js build / generate output
+.nuxt
+dist
+
+# Gatsby files
+.cache/
+# Comment in the public line in if your project uses Gatsby and not Next.js
+# https://nextjs.org/blog/next-9-1#public-directory-support
+# public
+
+# vuepress build output
+.vuepress/dist
+
+# vuepress v2.x temp and cache directory
+.temp
+.cache
+
+# Docusaurus cache and generated files
+.docusaurus
+
+# Serverless directories
+.serverless/
+
+# FuseBox cache
+.fusebox/
+
+# DynamoDB Local files
+.dynamodb/
+
+# TernJS port file
+.tern-port
+
+# Stores VSCode versions used for testing VSCode extensions
+.vscode-test
+
+# yarn v2
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.*
diff --git a/packages/browser/.prettierignore b/packages/browser/.prettierignore
new file mode 100644
index 000000000..99b0b518a
--- /dev/null
+++ b/packages/browser/.prettierignore
@@ -0,0 +1,4 @@
+/dist
+/build
+/node_modules
+/coverage
diff --git a/packages/browser/README.md b/packages/browser/README.md
new file mode 100644
index 000000000..5f334aeb0
--- /dev/null
+++ b/packages/browser/README.md
@@ -0,0 +1,48 @@
+
+
@asgardeo/browser
+
+Browser-based SDK for Asgardeo
+
+
+## Installation
+
+```bash
+# Using npm
+npm install @asgardeo/browser
+
+# or using pnpm
+pnpm add @asgardeo/browser
+
+# or using yarn
+yarn add @asgardeo/browser
+```
+
+## Quick Start
+
+```javascript
+import { AsgardeoAuthClient } from "@asgardeo/browser";
+
+// Initialize the auth client
+const authClient = new AsgardeoAuthClient({
+ signInRedirectURL: "https://localhost:3000",
+ clientID: "",
+ baseUrl: "https://api.asgardeo.io/t/"
+});
+
+// Sign in
+authClient.signIn();
+
+// Get user info after authentication
+const userInfo = await authClient.getBasicUserInfo();
+
+// Sign out
+authClient.signOut();
+```
+
+## License
+
+Apache-2.0
diff --git a/packages/browser/esbuild.config.mjs b/packages/browser/esbuild.config.mjs
new file mode 100644
index 000000000..244371280
--- /dev/null
+++ b/packages/browser/esbuild.config.mjs
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { readFileSync } from 'fs';
+import * as esbuild from 'esbuild';
+import { createRequire } from 'module';
+import { fileURLToPath } from 'url';
+
+const require = createRequire(import.meta.url);
+const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
+
+// Get dependencies excluding crypto-related ones that need to be bundled
+const externalDeps = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]
+ .filter(dep => !['crypto-browserify', 'randombytes', 'buffer'].includes(dep));
+
+// Plugin to alias crypto and buffer modules
+const polyfillPlugin = {
+ name: 'polyfill-plugin',
+ setup(build) {
+ // Crypto polyfill
+ build.onResolve({ filter: /^crypto$/ }, () => ({
+ path: require.resolve('crypto-browserify')
+ }));
+
+ // Buffer polyfill
+ build.onResolve({ filter: /^buffer$/ }, () => ({
+ path: require.resolve('buffer/')
+ }));
+ }
+};
+
+const commonOptions = {
+ bundle: true,
+ entryPoints: ['src/index.ts'],
+ external: externalDeps,
+ platform: 'browser',
+ target: ['es2020'],
+ define: {
+ global: 'globalThis', // Required by crypto-browserify
+ 'process.env.NODE_DEBUG': 'false',
+ 'process.version': '"16.0.0"',
+ 'process.browser': 'true'
+ },
+ banner: {
+ js: `
+ import { Buffer } from 'buffer/';
+ if (typeof window !== 'undefined' && !window.Buffer) {
+ window.Buffer = Buffer;
+ }
+ `
+ },
+ footer: {
+ js: `
+ if (typeof window !== 'undefined' && !window.Buffer) {
+ window.Buffer = require('buffer/').Buffer;
+ }
+ `
+ },
+ plugins: [polyfillPlugin]
+};
+
+await esbuild.build({
+ ...commonOptions,
+ format: 'esm',
+ outfile: 'dist/index.js',
+ sourcemap: true
+});
+
+await esbuild.build({
+ ...commonOptions,
+ format: 'cjs',
+ outfile: 'dist/cjs/index.js',
+ sourcemap: true
+});
diff --git a/packages/browser/package.json b/packages/browser/package.json
new file mode 100644
index 000000000..edb5091fe
--- /dev/null
+++ b/packages/browser/package.json
@@ -0,0 +1,76 @@
+{
+ "name": "@asgardeo/browser",
+ "version": "0.0.0",
+ "description": "Browser-specific implementation of Asgardeo JavaScript SDK.",
+ "keywords": [
+ "asgardeo",
+ "browser",
+ "spa"
+ ],
+ "homepage": "https://github.com/asgardeo/javascript/tree/main/packages/browser#readme",
+ "bugs": {
+ "url": "https://github.com/asgardeo/javascript/issues"
+ },
+ "author": "WSO2",
+ "license": "Apache-2.0",
+ "type": "module",
+ "main": "dist/cjs/index.js",
+ "module": "dist/index.js",
+ "exports": {
+ "import": "./dist/index.js",
+ "require": "./dist/cjs/index.js"
+ },
+ "files": [
+ "dist",
+ "README.md",
+ "LICENSE"
+ ],
+ "types": "dist/index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/asgardeo/javascript",
+ "directory": "packages/browser"
+ },
+ "scripts": {
+ "build": "pnpm clean && node esbuild.config.mjs && tsc -p tsconfig.lib.json --emitDeclarationOnly --outDir dist",
+ "clean": "rimraf dist",
+ "fix:lint": "eslint . --ext .js,.jsx,.ts,.tsx,.cjs,.mjs",
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx,.cjs,.mjs",
+ "test": "vitest",
+ "test:browser": "vitest --workspace=vitest.workspace.ts",
+ "typecheck": "tsc -p tsconfig.lib.json"
+ },
+ "devDependencies": {
+ "@testing-library/dom": "^10.4.0",
+ "@types/node": "^22.15.3",
+ "@vitest/browser": "^3.1.3",
+ "@wso2/eslint-plugin": "catalog:",
+ "@wso2/prettier-config": "catalog:",
+ "esbuild": "^0.25.4",
+ "esbuild-plugins-node-modules-polyfill": "^1.7.0",
+ "eslint": "8.57.0",
+ "playwright": "^1.52.0",
+ "prettier": "^2.6.2",
+ "rimraf": "^6.0.1",
+ "typescript": "~5.7.2",
+ "vitest": "^3.1.3"
+ },
+ "dependencies": {
+ "@asgardeo/javascript": "workspace:^",
+ "axios": "^0.26.0",
+ "base64url": "^3.0.1",
+ "buffer": "^6.0.3",
+ "core-js": "^3.42.0",
+ "crypto-browserify": "^3.12.1",
+ "esbuild-plugin-polyfill-node": "^0.3.0",
+ "fast-sha256": "^1.3.0",
+ "jose": "^6.0.11",
+ "process": "^0.11.10",
+ "randombytes": "^2.1.0",
+ "stream-browserify": "^3.0.0",
+ "tslib": "^2.8.1"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
\ No newline at end of file
diff --git a/packages/browser/prettier.config.cjs b/packages/browser/prettier.config.cjs
new file mode 100644
index 000000000..929b9b15f
--- /dev/null
+++ b/packages/browser/prettier.config.cjs
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+module.exports = require('@wso2/prettier-config');
diff --git a/packages/browser/src/AsgardeoBrowserClient.ts b/packages/browser/src/AsgardeoBrowserClient.ts
new file mode 100644
index 000000000..ad3b13b28
--- /dev/null
+++ b/packages/browser/src/AsgardeoBrowserClient.ts
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {AsgardeoJavaScriptClient} from '@asgardeo/javascript';
+import {AsgardeoBrowserConfig} from './models/config';
+
+/**
+ * Base class for implementing Asgardeo in browser-based applications.
+ * This class provides the core functionality for managing user authentication and sessions.
+ *
+ * @typeParam T - Configuration type that extends AsgardeoBrowserConfig.
+ */
+abstract class AsgardeoBrowserClient extends AsgardeoJavaScriptClient {}
+
+export default AsgardeoBrowserClient;
diff --git a/packages/browser/src/__legacy__/client.ts b/packages/browser/src/__legacy__/client.ts
new file mode 100755
index 000000000..17a878d90
--- /dev/null
+++ b/packages/browser/src/__legacy__/client.ts
@@ -0,0 +1,1171 @@
+/**
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ AsgardeoAuthClient,
+ AsgardeoAuthException,
+ AuthClientConfig,
+ BasicUserInfo,
+ IsomorphicCrypto,
+ CustomGrantConfig,
+ DataLayer,
+ IdTokenPayload,
+ FetchResponse,
+ OIDCEndpoints,
+} from '@asgardeo/javascript';
+import WorkerFile from '../worker';
+import {MainThreadClient, WebWorkerClient} from './clients';
+import {Hooks, REFRESH_ACCESS_TOKEN_ERR0R} from './constants';
+import {AuthenticationHelper, SPAHelper} from './helpers';
+import {HttpClientInstance} from './http-client';
+import {
+ AuthSPAClientConfig,
+ LegacyConfig as Config,
+ HttpRequestConfig,
+ HttpResponse,
+ MainThreadClientConfig,
+ MainThreadClientInterface,
+ SignInConfig,
+ SignOutError,
+ WebWorkerClientConfig,
+ WebWorkerClientInterface,
+} from './models';
+import {Storage} from './models/storage';
+import {SPAUtils} from './utils';
+
+/**
+ * Default configurations.
+ */
+const DefaultConfig: Partial> = {
+ autoLogoutOnTokenRefreshError: true,
+ checkSessionInterval: 3,
+ clientHost: origin,
+ enableOIDCSessionManagement: false,
+ periodicTokenRefresh: false,
+ sessionRefreshInterval: 300,
+ storage: Storage.SessionStorage,
+};
+
+/**
+ * This class provides the necessary methods to implement authentication in a Single Page Application.
+ *
+ * @export
+ * @class AsgardeoSPAClient
+ */
+export class AsgardeoSPAClient {
+ protected static _instances: Map = new Map();
+ protected _client: WebWorkerClientInterface | MainThreadClientInterface | undefined;
+ protected _storage: Storage | undefined;
+ protected _authHelper: typeof AuthenticationHelper = AuthenticationHelper;
+ protected _worker: new () => Worker = WorkerFile;
+ protected _initialized: boolean = false;
+ protected _startedInitialize: boolean = false;
+ protected _onSignInCallback: (response: BasicUserInfo) => void = () => null;
+ protected _onSignOutCallback: () => void = () => null;
+ protected _onSignOutFailedCallback: (error: SignOutError) => void = () => null;
+ protected _onEndUserSession: (response: any) => void = () => null;
+ protected _onInitialize: (response: boolean) => void = () => null;
+ protected _onCustomGrant: Map void> = new Map();
+ protected _instanceID: number;
+
+ protected constructor(id: number) {
+ this._instanceID = id;
+ }
+
+ public instantiateAuthHelper(authHelper?: typeof AuthenticationHelper) {
+ if (authHelper) {
+ this._authHelper = authHelper;
+ } else {
+ this._authHelper = AuthenticationHelper;
+ }
+ }
+
+ public instantiateWorker(worker: new () => Worker) {
+ if (worker) {
+ this._worker = worker;
+ } else {
+ this._worker = WorkerFile;
+ }
+ }
+
+ /**
+ * This method specifies if the `AsgardeoSPAClient` has been initialized or not.
+ *
+ * @return {Promise} - Resolves to `true` if the client has been initialized.
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @private
+ */
+ private async _isInitialized(): Promise {
+ if (!this._startedInitialize) {
+ return false;
+ }
+
+ let iterationToWait = 0;
+
+ const sleep = (): Promise => {
+ return new Promise(resolve => setTimeout(resolve, 1));
+ };
+
+ while (!this._initialized) {
+ if (iterationToWait === 1e4) {
+ // eslint-disable-next-line no-console
+ console.warn('It is taking longer than usual for the object to be initialized');
+ }
+ await sleep();
+ iterationToWait++;
+ }
+
+ return true;
+ }
+
+ /**
+ * This method checks if the SDK is initialized and the user is authenticated.
+ *
+ * @param validateAuthentication - should user's authenticated status be checked as part of validation
+ *
+ * @return {Promise} - A Promise that resolves with `true` if the SDK is initialized and the
+ * user is authenticated.
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @private
+ */
+ private async _validateMethod(validateAuthentication: boolean = true): Promise {
+ if (!(await this._isInitialized())) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-VM-NF01',
+ 'The SDK is not initialized.',
+ 'The SDK must be initialized first.',
+ ),
+ );
+ }
+
+ if (validateAuthentication && !(await this.isAuthenticated())) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-VM-IV02',
+ 'The user is not authenticated.',
+ 'The user must be authenticated first.',
+ ),
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * This method returns the instance of the singleton class.
+ * If an ID is provided, it will return the instance with the given ID.
+ * If no ID is provided, it will return the default instance value 0.
+ *
+ * @return {AsgardeoSPAClient} - Returns the instance of the singleton class.
+ *
+ * @example
+ * ```
+ * const auth = AsgardeoSPAClient.getInstance();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getinstance
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public static getInstance(id?: number): AsgardeoSPAClient | undefined {
+ if (id && this._instances?.get(id)) {
+ return this._instances.get(id);
+ } else if (!id && this._instances?.get(0)) {
+ return this._instances.get(0);
+ }
+
+ if (id) {
+ this._instances.set(id, new AsgardeoSPAClient(id));
+
+ return this._instances.get(id);
+ }
+
+ this._instances.set(0, new AsgardeoSPAClient(0));
+
+ return this._instances.get(0);
+ }
+
+ /**
+ * This method initializes the `AsgardeoSPAClient` instance.
+ *
+ * @param {ConfigInterface} config The config object to initialize with.
+ *
+ * @return {Promise} - Resolves to `true` if initialization is successful.
+ *
+ * @example
+ * ```
+ * auth.initialize({
+ * signInRedirectURL: "http://localhost:3000/sign-in",
+ * clientID: "client ID",
+ * baseUrl: "https://api.asgardeo.io"
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#initialize
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+
+ public async initialize(
+ config: AuthSPAClientConfig,
+ authHelper?: typeof AuthenticationHelper,
+ workerFile?: new () => Worker,
+ ): Promise {
+ this._storage = (config.storage as Storage) ?? Storage.SessionStorage;
+ this._initialized = false;
+ this._startedInitialize = true;
+
+ authHelper && this.instantiateAuthHelper(authHelper);
+ workerFile && this.instantiateWorker(workerFile);
+
+ const _config = await this._client?.getConfigData();
+
+ if (!(this._storage === Storage.WebWorker)) {
+ const mainThreadClientConfig = config as AuthClientConfig;
+ const defaultConfig = {...DefaultConfig} as Partial>;
+ const mergedConfig: AuthClientConfig = {
+ ...defaultConfig,
+ ...mainThreadClientConfig,
+ };
+
+ // If the client is not initialized, initialize it as usual.
+ // NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent
+ // issue where the config object is not getting stored in the storage layer with Vite scaffolding.
+ // Hence, we need to check if the client is initialized but the config object is empty, and reinitialize.
+ // Tracker: https://github.com/asgardeo/asgardeo-auth-react-sdk/issues/240
+ if (!this._client || (this._client && (!_config || Object.keys(_config)?.length === 0))) {
+ this._client = await MainThreadClient(
+ this._instanceID,
+ mergedConfig,
+ (authClient: AsgardeoAuthClient, spaHelper: SPAHelper) => {
+ return new this._authHelper(authClient, spaHelper);
+ },
+ );
+ }
+
+ this._initialized = true;
+
+ if (this._onInitialize) {
+ this._onInitialize(true);
+ }
+
+ // Do not sign out the user if the autoLogoutOnTokenRefreshError is set to false.
+ if (!mergedConfig.autoLogoutOnTokenRefreshError) {
+ return Promise.resolve(true);
+ }
+
+ window.addEventListener('message', event => {
+ if (event?.data?.type === REFRESH_ACCESS_TOKEN_ERR0R) {
+ this.signOut();
+ }
+ });
+
+ return Promise.resolve(true);
+ } else {
+ // If the client is not initialized, initialize it as usual.
+ // NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent
+ // issue where the config object is not getting stored in the storage layer with Vite scaffolding.
+ // Hence, we need to check if the client is initialized but the config object is empty, and reinitialize.
+ // Tracker: https://github.com/asgardeo/asgardeo-auth-react-sdk/issues/240
+ if (!this._client || (this._client && (!_config || Object.keys(_config)?.length === 0))) {
+ const webWorkerClientConfig = config as AuthClientConfig;
+ this._client = (await WebWorkerClient(
+ this._instanceID,
+ {
+ ...DefaultConfig,
+ ...webWorkerClientConfig,
+ },
+ this._worker,
+ (authClient: AsgardeoAuthClient, spaHelper: SPAHelper) => {
+ return new this._authHelper(authClient, spaHelper);
+ },
+ )) as WebWorkerClientInterface;
+
+ return this._client
+ .initialize()
+ .then(() => {
+ if (this._onInitialize) {
+ this._onInitialize(true);
+ }
+ this._initialized = true;
+
+ return Promise.resolve(true);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ }
+
+ return Promise.resolve(true);
+ }
+ }
+
+ /**
+ * This method returns a Promise that resolves with the basic user information obtained from the ID token.
+ *
+ * @return {Promise} - A promise that resolves with the user information.
+ *
+ * @example
+ * ```
+ * auth.getBasicUserInfo().then((response) => {
+ * // console.log(response);
+ * }).catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getuserinfo
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getBasicUserInfo(): Promise {
+ await this._validateMethod();
+
+ return this._client?.getBasicUserInfo();
+ }
+
+ /**
+ * This method initiates the authentication flow. This should be called twice.
+ * 1. To initiate the authentication flow.
+ * 2. To obtain the access token after getting the authorization code.
+ *
+ * To satisfy the second condition, one of the two strategies mentioned below can be used:
+ * 1. Redirect the user back to the same login page that initiated the authentication flow.
+ * 2. Call the `signIn()` method in the page the user is redirected to after authentication.
+ *
+ * **To fire a callback function after signing in, use the `on()` method.**
+ * **To learn more about the `on()` method:**
+ * @see {@link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on}
+ *
+ * @param {SignInConfig} config - The sign-in config.
+ * The `SignInConfig` object has these two attributes in addition to any custom key-value pairs.
+ * 1. fidp - Specifies the FIDP parameter that is used to take the user directly to an IdP login page.
+ * 2. forceInit: Specifies if the OIDC Provider Meta Data should be loaded again from the `well-known`
+ * endpoint.
+ * 3. Any other parameters that should be appended to the authorization request.
+ * @param {string} authorizationCode - The authorization code. (Optional)
+ * @param {string} sessionState - The session state. (Optional)
+ * @param {string} state - The state. (Optional)
+ *
+ * @return {Promise} - A promise that resolves with the user information.
+ *
+ * @example
+ * ```
+ * auth.signIn();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#signin
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async signIn(
+ config?: SignInConfig,
+ authorizationCode?: string,
+ sessionState?: string,
+ state?: string,
+ tokenRequestConfig?: {
+ params: Record;
+ },
+ ): Promise {
+ await this._isInitialized();
+
+ // Discontinues the execution of this method if `config.callOnlyOnRedirect` is true and the `signIn` method
+ // is not being called on redirect.
+ if (!SPAUtils.canContinueSignIn(Boolean(config?.callOnlyOnRedirect), authorizationCode)) {
+ return undefined;
+ }
+
+ delete config?.callOnlyOnRedirect;
+
+ return this._client
+ ?.signIn(config, authorizationCode, sessionState, state, tokenRequestConfig)
+ .then((response: BasicUserInfo) => {
+ if (this._onSignInCallback) {
+ if (response.allowedScopes || response.displayName || response.email || response.username) {
+ this._onSignInCallback(response);
+ }
+ }
+
+ return response;
+ });
+ }
+
+ /**
+ * This method allows you to sign in silently.
+ * First, this method sends a prompt none request to see if there is an active user session in the identity server.
+ * If there is one, then it requests the access token and stores it. Else, it returns false.
+ *
+ * If this method is to be called on page load and the `signIn` method is also to be called on page load,
+ * then it is advisable to call this method after the `signIn` call.
+ *
+ * @return {Promise} - A Promise that resolves with the user information after signing in
+ * or with `false` if the user is not signed in.
+ *
+ * @example
+ *```
+ * auth.trySignInSilently()
+ *```
+ */
+ public async trySignInSilently(
+ additionalParams?: Record,
+ tokenRequestConfig?: {params: Record},
+ ): Promise {
+ await this._isInitialized();
+
+ // checks if the `signIn` method has been called.
+ if (SPAUtils.wasSignInCalled()) {
+ return undefined;
+ }
+
+ return this._client
+ ?.trySignInSilently(additionalParams, tokenRequestConfig)
+ .then((response: BasicUserInfo | boolean) => {
+ if (this._onSignInCallback && response) {
+ const basicUserInfo = response as BasicUserInfo;
+ if (
+ basicUserInfo.allowedScopes ||
+ basicUserInfo.displayName ||
+ basicUserInfo.email ||
+ basicUserInfo.username
+ ) {
+ this._onSignInCallback(basicUserInfo);
+ }
+ }
+
+ return response;
+ });
+ }
+
+ /**
+ * This method initiates the sign-out flow.
+ *
+ * **To fire a callback function after signing out, use the `on()` method.**
+ * **To learn more about the `on()` method:**
+ * @see {@link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on}
+ *
+ * @return {Promise} - Returns a promise that resolves with `true` if sign out is successful.
+ *
+ * @example
+ * ```
+ * auth.signOut();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#signout
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async signOut(): Promise {
+ await this._validateMethod(false);
+
+ const signOutResponse = (await this._client?.signOut()) ?? false;
+
+ return signOutResponse;
+ }
+
+ /**
+ * This method sends an API request to a protected endpoint.
+ * The access token is automatically attached to the header of the request.
+ * This is the only way by which protected endpoints can be accessed
+ * when the web worker is used to store session information.
+ *
+ * @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
+ *
+ * @return {Promise} - Returns a Promise that resolves with the response to the request.
+ *
+ * @example
+ * ```
+ * const requestConfig = {
+ * headers: {
+ * "Accept": "application/json",
+ * "Access-Control-Allow-Origin": "https://api.asgardeo.io/myaccount",
+ * "Content-Type": "application/scim+json"
+ * },
+ * method: "GET",
+ * url: "https://api.asgardeo.io/scim2/me"
+ * };
+ *
+ * return auth.httpRequest(requestConfig)
+ * .then((response) => {
+ * // console.log(response);
+ * })
+ * .catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#httprequest
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async httpRequest(config: HttpRequestConfig): Promise {
+ await this._validateMethod(false);
+
+ return this._client?.httpRequest(config);
+ }
+
+ /**
+ * This method sends multiple API requests to a protected endpoint.
+ * The access token is automatically attached to the header of the request.
+ * This is the only way by which multiple requests can be sent to protected endpoints
+ * when the web worker is used to store session information.
+ *
+ * @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
+ *
+ * @return {Promise} - Returns a Promise that resolves with the responses to the requests.
+ *
+ * @example
+ * ```
+ * const requestConfig = {
+ * headers: {
+ * "Accept": "application/json",
+ * "Content-Type": "application/scim+json"
+ * },
+ * method: "GET",
+ * url: "https://api.asgardeo.io/scim2/me"
+ * };
+ *
+ * const requestConfig2 = {
+ * headers: {
+ * "Accept": "application/json",
+ * "Content-Type": "application/scim+json"
+ * },
+ * method: "GET",
+ * url: "https://api.asgardeo.io/scim2/me"
+ * };
+ *
+ * return auth.httpRequest([requestConfig, requestConfig2])
+ * .then((responses) => {
+ * response.forEach((response)=>{
+ * // console.log(response);
+ * });
+ * })
+ * .catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#httprequestall
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async httpRequestAll(config: HttpRequestConfig[]): Promise {
+ await this._validateMethod(false);
+
+ return this._client?.httpRequestAll(config);
+ }
+
+ /**
+ * This method allows you to send a request with a custom grant.
+ *
+ * @param {CustomGrantRequestParams} config - The request parameters.
+ *
+ * @return {Promise | SignInResponse>} - A Promise that resolves with
+ * the value returned by the custom grant request.
+ *
+ * @example
+ * ```
+ * auth.customGrant({
+ * attachToken: false,
+ * data: {
+ * client_id: "{{clientId}}",
+ * grant_type: "account_switch",
+ * scope: "{{scope}}",
+ * token: "{{token}}",
+ * },
+ * id: "account-switch",
+ * returnResponse: true,
+ * returnsSession: true,
+ * signInRequired: true
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#customgrant
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async requestCustomGrant(config: CustomGrantConfig): Promise | BasicUserInfo | undefined> {
+ if (config.signInRequired) {
+ await this._validateMethod();
+ } else {
+ await this._validateMethod();
+ }
+
+ if (!config.id) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-RCG-NF01',
+ 'The custom grant request id not found.',
+ 'The id attribute of the custom grant config object passed as an argument should have a value.',
+ ),
+ );
+ }
+
+ const customGrantResponse = await this._client?.requestCustomGrant(config);
+
+ const customGrantCallback = this._onCustomGrant.get(config.id);
+ customGrantCallback && customGrantCallback(this._onCustomGrant?.get(config.id));
+
+ return customGrantResponse;
+ }
+
+ /**
+ * This method ends a user session. The access token is revoked and the session information is destroyed.
+ *
+ * **To fire a callback function after ending user session, use the `on()` method.**
+ * **To learn more about the `on()` method:**
+ * @see {@link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on}
+ *
+ * @return {Promise} - A promise that resolves with `true` if the process is successful.
+ *
+ * @example
+ * ```
+ * auth.endUserSession();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#endusersession
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async revokeAccessToken(): Promise {
+ await this._validateMethod();
+
+ const revokeAccessToken = await this._client?.revokeAccessToken();
+ this._onEndUserSession && (await this._onEndUserSession(revokeAccessToken));
+
+ return revokeAccessToken;
+ }
+
+ /**
+ * This method returns a Promise that resolves with an object containing the service endpoints.
+ *
+ * @return {Promise {
+ * // console.log(endpoints);
+ * }).error((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getserviceendpoints
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getOIDCServiceEndpoints(): Promise {
+ await this._isInitialized();
+
+ return this._client?.getOIDCServiceEndpoints();
+ }
+
+ /**
+ * This methods returns the Axios http client.
+ *
+ * @return {HttpClientInstance} - The Axios HTTP client.
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public getHttpClient(): HttpClientInstance {
+ if (this._client) {
+ if (this._storage !== Storage.WebWorker) {
+ const mainThreadClient = this._client as MainThreadClientInterface;
+ return mainThreadClient.getHttpClient();
+ }
+
+ throw new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-GHC-IV01',
+ 'Http client cannot be returned.',
+ 'The http client cannot be returned when the storage type is set to webWorker.',
+ );
+ }
+
+ throw new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-GHC-NF02',
+ 'The SDK is not initialized.',
+ 'The SDK has not been initialized yet. Initialize the SDK using the initialize method ' +
+ 'before calling this method.',
+ );
+ }
+
+ /**
+ * This method decodes the payload of the id token and returns it.
+ *
+ * @return {Promise} - A Promise that resolves with
+ * the decoded payload of the id token.
+ *
+ * @example
+ * ```
+ * auth.getDecodedIDToken().then((response)=>{
+ * // console.log(response);
+ * }).catch((error)=>{
+ * // console.error(error);
+ * });
+ * ```
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getdecodedidtoken
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getDecodedIDToken(): Promise {
+ await this._validateMethod();
+
+ return this._client?.getDecodedIDToken();
+ }
+
+ /**
+ * This method returns the IsomorphicCrypto instance.
+ *
+ * @return {Promise} - A Promise that resolves with
+ * the IsomorphicCrypto instance.
+ *
+ * @example
+ * ```
+ * auth.getCryptoHelper().then((response)=>{
+ * // console.log(response);
+ * }).catch((error)=>{
+ * // console.error(error);
+ * });
+ * ```
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getCryptoHelper
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getCryptoHelper(): Promise {
+ await this._validateMethod();
+
+ return this._client?.getCryptoHelper();
+ }
+
+ /**
+ * This method return the ID token.
+ *
+ * @return {Promise} - A Promise that resolves with the ID token.
+ *
+ * @example
+ * ```
+ * const idToken = await auth.getIDToken();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIDToken
+ *
+ * @memberof AsgardeoAuthClient
+ *
+ * @preserve
+ */
+ public async getIDToken(): Promise {
+ await this._validateMethod();
+
+ return this._client?.getIDToken();
+ }
+
+ /**
+ * This method return a Promise that resolves with the access token.
+ *
+ * **This method will not return the access token if the storage type is set to `webWorker`.**
+ *
+ * @return {Promise} - A Promise that resolves with the access token.
+ *
+ * @example
+ * ```
+ * auth.getAccessToken().then((token) => {
+ * // console.log(token);
+ * }).catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getaccesstoken
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getAccessToken(): Promise {
+ await this._validateMethod();
+
+ if (this._storage && [(Storage.WebWorker, Storage.BrowserMemory)].includes(this._storage)) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-GAT-IV01',
+ 'The access token cannot be returned.',
+ 'The access token cannot be returned when the storage type is set to webWorker or browserMemory.',
+ ),
+ );
+ }
+ const mainThreadClient = this._client as MainThreadClientInterface;
+
+ return mainThreadClient.getAccessToken();
+ }
+
+ /**
+ * This method return a Promise that resolves with the idp access token.
+ *
+ * **This method will not return the access token if the storage type is set to `webWorker`.**
+ *
+ * @return {Promise} - A Promise that resolves with the idp access token.
+ *
+ * @example
+ * ```
+ * auth.getIDPAccessToken().then((token) => {
+ * // console.log(token);
+ * }).catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getaccesstoken
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getIDPAccessToken(): Promise {
+ await this._validateMethod();
+
+ if (this._storage && [(Storage.WebWorker, Storage.BrowserMemory)].includes(this._storage)) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-GIAT-IV01',
+ 'The access token cannot be returned.',
+ 'The access token cannot be returned when the storage type is set to webWorker or browserMemory.',
+ ),
+ );
+ }
+ const mainThreadClient = this._client as MainThreadClientInterface;
+
+ return mainThreadClient.getAccessToken();
+ }
+
+ /**
+ * This method return a Promise that resolves with the data layer object.
+ *
+ * **This method will not return the data layer object, if the storage type is set to `webWorker`.**
+ *
+ * @return {Promise} - A Promise that resolves with the data layer object.
+ *
+ * @example
+ * ```
+ * auth.getDataLayer().then((dataLayer) => {
+ * // console.log(dataLayer);
+ * }).catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getdatalayer
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getDataLayer(): Promise> {
+ await this._validateMethod();
+
+ if (this._storage && [(Storage.WebWorker, Storage.BrowserMemory)].includes(this._storage)) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-GDL-IV01',
+ 'The data layer cannot be returned.',
+ 'The data layer cannot be returned when the storage type is set to webWorker or browserMemory.',
+ ),
+ );
+ }
+ const mainThreadClient = this._client as MainThreadClientInterface;
+
+ return mainThreadClient.getDataLayer();
+ }
+
+ /**
+ * This method return a Promise that resolves with the config data stored in the storage.
+ *
+ * @return - A Promise that resolves with the config data.
+ *
+ * @example
+ * ```
+ * auth.getConfigData().then((configData) => {
+ * // console.log(configData);
+ * }).catch((error) => {
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/main#getConfigData
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async getConfigData(): Promise<
+ AuthClientConfig | AuthClientConfig | undefined
+ > {
+ return this._client?.getConfigData();
+ }
+
+ /**
+ * This method refreshes the access token.
+ *
+ * @return {TokenResponseInterface} - A Promise that resolves with an object containing
+ * information about the refreshed access token.
+ *
+ * @example
+ * ```
+ * auth.refreshToken().then((response)=>{
+ * // console.log(response);
+ * }).catch((error)=>{
+ * // console.error(error);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#refreshtoken
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async refreshAccessToken(): Promise {
+ await this._validateMethod(false);
+
+ return this._client?.refreshAccessToken();
+ }
+
+ /**
+ * This method specifies if the user is authenticated or not.
+ *
+ * @return {Promise} - A Promise that resolves with `true` if the user is authenticated.
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async isAuthenticated(): Promise {
+ await this._isInitialized();
+
+ return this._client?.isAuthenticated();
+ }
+
+ /**
+ * This method specifies if there is an active session in the browser or not.
+ *
+ * @return {Promise} - A Promise that resolves with `true` if there is a session.
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async isSessionActive(): Promise {
+ await this._isInitialized();
+
+ if (this._storage && [(Storage.WebWorker, Storage.BrowserMemory)].includes(this._storage)) {
+ return Promise.reject(
+ new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-ISA-IV01',
+ 'The active session cannot be returned.',
+ 'The active session cannot be returned when the storage type is set to webWorker ' + 'or browserMemory.',
+ ),
+ );
+ }
+ const mainThreadClient = this._client as MainThreadClientInterface;
+
+ return mainThreadClient?.isSessionActive();
+ }
+
+ /**
+ * This method attaches a callback function to an event hook that fires the callback when the event happens.
+ *
+ * @param {Hooks.CustomGrant} hook - The name of the hook.
+ * @param {(response?: any) => void} callback - The callback function.
+ * @param {string} id (optional) - The id of the hook. This is used when multiple custom grants are used.
+ *
+ * @example
+ * ```
+ * auth.on("sign-in", (response)=>{
+ * // console.log(response);
+ * });
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#on
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): Promise;
+ public async on(hook: Exclude, callback: (response?: any) => void): Promise;
+ public async on(hook: Hooks, callback: (response?: any) => void | Promise, id?: string): Promise {
+ await this._isInitialized();
+ if (callback && typeof callback === 'function') {
+ switch (hook) {
+ case Hooks.SignIn:
+ this._onSignInCallback = callback;
+ break;
+ case Hooks.SignOut:
+ this._onSignOutCallback = callback;
+ if (await SPAUtils.isSignOutSuccessful()) {
+ this._onSignOutCallback();
+ }
+ break;
+ case Hooks.RevokeAccessToken:
+ this._onEndUserSession = callback;
+ break;
+ case Hooks.Initialize:
+ this._onInitialize = callback;
+ break;
+ case Hooks.HttpRequestError:
+ this._client?.setHttpRequestErrorCallback(callback);
+ break;
+ case Hooks.HttpRequestFinish:
+ this._client?.setHttpRequestFinishCallback(callback);
+ break;
+ case Hooks.HttpRequestStart:
+ this._client?.setHttpRequestStartCallback(callback);
+ break;
+ case Hooks.HttpRequestSuccess:
+ this._client?.setHttpRequestSuccessCallback(callback);
+ break;
+ case Hooks.CustomGrant:
+ id && this._onCustomGrant.set(id, callback);
+ break;
+ case Hooks.SignOutFailed: {
+ this._onSignOutFailedCallback = callback;
+ const signOutFail: boolean | SignOutError = SPAUtils.didSignOutFail();
+
+ if (signOutFail) {
+ this._onSignOutFailedCallback(signOutFail as SignOutError);
+ }
+ break;
+ }
+ default:
+ throw new AsgardeoAuthException('SPA-AUTH_CLIENT-ON-IV01', 'Invalid hook.', 'The provided hook is invalid.');
+ }
+ } else {
+ throw new AsgardeoAuthException(
+ 'SPA-AUTH_CLIENT-ON-IV02',
+ 'Invalid callback function.',
+ 'The provided callback function is invalid.',
+ );
+ }
+ }
+
+ /**
+ * This method enables callback functions attached to the http client.
+ *
+ * @return {Promise} - A promise that resolves with True.
+ *
+ * @example
+ * ```
+ * auth.enableHttpHandler();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#enableHttpHandler
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async enableHttpHandler(): Promise {
+ await this._isInitialized();
+
+ return this._client?.enableHttpHandler();
+ }
+
+ /**
+ * This method disables callback functions attached to the http client.
+ *
+ * @return {Promise} - A promise that resolves with True.
+ *
+ * @example
+ * ```
+ * auth.disableHttpHandler();
+ * ```
+ *
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#disableHttpHandler
+ *
+ * @memberof AsgardeoSPAClient
+ *
+ * @preserve
+ */
+ public async disableHttpHandler(): Promise {
+ await this._isInitialized();
+
+ return this._client?.disableHttpHandler();
+ }
+
+ /**
+ * This method updates the configuration that was passed into the constructor when instantiating this class.
+ *
+ * @param {Partial>} config - A config object to update the SDK configurations with.
+ *
+ * @example
+ * ```
+ * const config = {
+ * signInRedirectURL: "http://localhost:3000/sign-in",
+ * clientID: "client ID",
+ * baseUrl: "https://api.asgardeo.io"
+ * }
+ * const auth.updateConfig(config);
+ * ```
+ * @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master/lib#updateConfig
+ *
+ * @memberof AsgardeoAuthClient
+ *
+ * @preserve
+ */
+ public async updateConfig(config: Partial>): Promise {
+ await this._isInitialized();
+ if (this._storage === Storage.WebWorker) {
+ const client = this._client as WebWorkerClientInterface;
+ await client.updateConfig(config as Partial>);
+ } else {
+ const client = this._client as WebWorkerClientInterface;
+ await client.updateConfig(config as Partial>);
+ }
+
+ return;
+ }
+}
diff --git a/packages/browser/src/__legacy__/clients/index.ts b/packages/browser/src/__legacy__/clients/index.ts
new file mode 100644
index 000000000..6148f41d4
--- /dev/null
+++ b/packages/browser/src/__legacy__/clients/index.ts
@@ -0,0 +1,20 @@
+/**
+* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+export * from "./main-thread-client";
+export * from "./web-worker-client";
diff --git a/packages/browser/src/__legacy__/clients/main-thread-client.ts b/packages/browser/src/__legacy__/clients/main-thread-client.ts
new file mode 100755
index 000000000..639ac72a6
--- /dev/null
+++ b/packages/browser/src/__legacy__/clients/main-thread-client.ts
@@ -0,0 +1,462 @@
+/**
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ AsgardeoAuthClient,
+ AuthClientConfig,
+ BasicUserInfo,
+ IsomorphicCrypto,
+ DataLayer,
+ IdTokenPayload,
+ FetchResponse,
+ GetAuthURLConfig,
+ OIDCEndpoints,
+ ResponseMode,
+ OIDCRequestConstants,
+ SessionData,
+ Store,
+ extractPkceStorageKeyFromState,
+} from '@asgardeo/javascript';
+import {SILENT_SIGN_IN_STATE, TOKEN_REQUEST_CONFIG_KEY} from '../constants';
+import {AuthenticationHelper, SPAHelper, SessionManagementHelper} from '../helpers';
+import {HttpClient, HttpClientInstance} from '../http-client';
+import {HttpError, HttpRequestConfig, HttpResponse, MainThreadClientConfig, MainThreadClientInterface} from '../models';
+import {SPACustomGrantConfig} from '../models/request-custom-grant';
+import {Storage} from '../models/storage';
+import {LocalStore, MemoryStore, SessionStore} from '../stores';
+import {SPAUtils} from '../utils';
+import {SPACryptoUtils} from '../utils/crypto-utils';
+
+const initiateStore = (store: Storage | undefined): Store => {
+ switch (store) {
+ case Storage.LocalStorage:
+ return new LocalStore();
+ case Storage.SessionStorage:
+ return new SessionStore();
+ case Storage.BrowserMemory:
+ return new MemoryStore();
+ default:
+ return new SessionStore();
+ }
+};
+
+export const MainThreadClient = async (
+ instanceID: number,
+ config: AuthClientConfig,
+ getAuthHelper: (
+ authClient: AsgardeoAuthClient,
+ spaHelper: SPAHelper,
+ ) => AuthenticationHelper,
+): Promise => {
+ const _store: Store = initiateStore(config.storage as Storage);
+ const _cryptoUtils: SPACryptoUtils = new SPACryptoUtils();
+ const _authenticationClient = new AsgardeoAuthClient();
+ await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceID);
+
+ const _spaHelper = new SPAHelper(_authenticationClient);
+ const _dataLayer = _authenticationClient.getDataLayer();
+ const _sessionManagementHelper = await SessionManagementHelper(
+ async () => {
+ return _authenticationClient.getSignOutURL();
+ },
+ (config.storage as Storage) ?? Storage.SessionStorage,
+ (sessionState: string) =>
+ _dataLayer.setSessionDataParameter(
+ OIDCRequestConstants.Params.SESSION_STATE as keyof SessionData,
+ sessionState ?? '',
+ ),
+ );
+
+ const _authenticationHelper = getAuthHelper(_authenticationClient, _spaHelper);
+
+ let _getSignOutURLFromSessionStorage: boolean = false;
+
+ const _httpClient: HttpClientInstance = HttpClient.getInstance();
+ let _isHttpHandlerEnabled: boolean = true;
+ let _httpErrorCallback: (error: HttpError) => void | Promise;
+ let _httpFinishCallback: () => void;
+
+ const attachToken = async (request: HttpRequestConfig): Promise => {
+ await _authenticationHelper.attachTokenToRequestConfig(request);
+ };
+
+ _httpClient?.init && (await _httpClient.init(true, attachToken));
+
+ const setHttpRequestStartCallback = (callback: () => void): void => {
+ _httpClient?.setHttpRequestStartCallback && _httpClient.setHttpRequestStartCallback(callback);
+ };
+
+ const setHttpRequestSuccessCallback = (callback: (response: HttpResponse) => void): void => {
+ _httpClient?.setHttpRequestSuccessCallback && _httpClient.setHttpRequestSuccessCallback(callback);
+ };
+
+ const setHttpRequestFinishCallback = (callback: () => void): void => {
+ _httpClient?.setHttpRequestFinishCallback && _httpClient.setHttpRequestFinishCallback(callback);
+ };
+
+ const setHttpRequestErrorCallback = (callback: (error: HttpError) => void | Promise): void => {
+ _httpErrorCallback = callback;
+ };
+
+ const httpRequest = async (requestConfig: HttpRequestConfig): Promise => {
+ return await _authenticationHelper.httpRequest(
+ _httpClient,
+ requestConfig,
+ _isHttpHandlerEnabled,
+ _httpErrorCallback,
+ _httpFinishCallback,
+ );
+ };
+
+ const httpRequestAll = async (requestConfigs: HttpRequestConfig[]): Promise => {
+ return await _authenticationHelper.httpRequestAll(
+ requestConfigs,
+ _httpClient,
+ _isHttpHandlerEnabled,
+ _httpErrorCallback,
+ _httpFinishCallback,
+ );
+ };
+
+ const getHttpClient = (): HttpClientInstance => {
+ return _httpClient;
+ };
+
+ const enableHttpHandler = (): boolean => {
+ _authenticationHelper.enableHttpHandler(_httpClient);
+ _isHttpHandlerEnabled = true;
+
+ return true;
+ };
+
+ const disableHttpHandler = (): boolean => {
+ _authenticationHelper.disableHttpHandler(_httpClient);
+ _isHttpHandlerEnabled = false;
+
+ return true;
+ };
+
+ const checkSession = async (): Promise => {
+ const oidcEndpoints: OIDCEndpoints = await _authenticationClient.getOIDCServiceEndpoints() as OIDCEndpoints;
+ const config = await _dataLayer.getConfigData();
+
+ _authenticationHelper.initializeSessionManger(
+ config,
+ oidcEndpoints,
+ async () => (await _authenticationClient.getBasicUserInfo()).sessionState,
+ async (params?: GetAuthURLConfig): Promise => _authenticationClient.getAuthorizationURL(params),
+ _sessionManagementHelper,
+ );
+ };
+
+ const shouldStopAuthn = async (): Promise => {
+ return await _sessionManagementHelper.receivePromptNoneResponse(async (sessionState: string | null) => {
+ await _dataLayer.setSessionDataParameter(
+ OIDCRequestConstants.Params.SESSION_STATE as keyof SessionData,
+ sessionState ?? '',
+ );
+ return;
+ });
+ };
+
+ const setSessionStatus = async (sessionStatus: string): Promise => {
+ await _dataLayer.setSessionStatus(sessionStatus);
+ };
+
+ const signIn = async (
+ signInConfig?: GetAuthURLConfig,
+ authorizationCode?: string,
+ sessionState?: string,
+ state?: string,
+ tokenRequestConfig?: {
+ params: Record;
+ },
+ ): Promise => {
+ const basicUserInfo = await _authenticationHelper.handleSignIn(shouldStopAuthn, checkSession, undefined);
+
+ if (basicUserInfo) {
+ return basicUserInfo;
+ } else {
+ let resolvedAuthorizationCode: string;
+ let resolvedSessionState: string;
+ let resolvedState: string;
+ let resolvedTokenRequestConfig: {
+ params: Record;
+ } = {params: {}};
+
+ if (config?.responseMode === ResponseMode.FormPost && authorizationCode) {
+ resolvedAuthorizationCode = authorizationCode;
+ resolvedSessionState = sessionState ?? '';
+ resolvedState = state ?? '';
+ } else {
+ resolvedAuthorizationCode =
+ new URL(window.location.href).searchParams.get(OIDCRequestConstants.Params.AUTHORIZATION_CODE) ?? '';
+ resolvedSessionState =
+ new URL(window.location.href).searchParams.get(OIDCRequestConstants.Params.SESSION_STATE) ?? '';
+ resolvedState = new URL(window.location.href).searchParams.get(OIDCRequestConstants.Params.STATE) ?? '';
+
+ SPAUtils.removeAuthorizationCode();
+ }
+
+ if (resolvedAuthorizationCode && resolvedState) {
+ setSessionStatus('true');
+ const storedTokenRequestConfig = await _dataLayer.getTemporaryDataParameter(TOKEN_REQUEST_CONFIG_KEY);
+ if (storedTokenRequestConfig && typeof storedTokenRequestConfig === 'string') {
+ resolvedTokenRequestConfig = JSON.parse(storedTokenRequestConfig);
+ }
+ return requestAccessToken(
+ resolvedAuthorizationCode,
+ resolvedSessionState,
+ resolvedState,
+ resolvedTokenRequestConfig,
+ );
+ }
+
+ return _authenticationClient.getAuthorizationURL(signInConfig).then(async (url: string) => {
+ if (config.storage === Storage.BrowserMemory && config.enablePKCE) {
+ const pkceKey: string = extractPkceStorageKeyFromState(resolvedState);
+
+ SPAUtils.setPKCE(pkceKey, (await _authenticationClient.getPKCECode(resolvedState)) as string);
+ }
+
+ if (tokenRequestConfig) {
+ _dataLayer.setTemporaryDataParameter(TOKEN_REQUEST_CONFIG_KEY, JSON.stringify(tokenRequestConfig));
+ }
+
+ location.href = url;
+
+ await SPAUtils.waitTillPageRedirect();
+
+ return Promise.resolve({
+ allowedScopes: '',
+ displayName: '',
+ email: '',
+ sessionState: '',
+ sub: '',
+ tenantDomain: '',
+ username: '',
+ });
+ });
+ }
+ };
+
+ const signOut = async (): Promise => {
+ if ((await _authenticationClient.isAuthenticated()) && !_getSignOutURLFromSessionStorage) {
+ location.href = await _authenticationClient.getSignOutURL();
+ } else {
+ location.href = SPAUtils.getSignOutURL(config.clientID, instanceID);
+ }
+
+ _spaHelper.clearRefreshTokenTimeout();
+
+ await _dataLayer.removeOIDCProviderMetaData();
+ await _dataLayer.removeTemporaryData();
+ await _dataLayer.removeSessionData();
+ await _dataLayer.removeSessionStatus();
+
+ await SPAUtils.waitTillPageRedirect();
+
+ return true;
+ };
+
+ const enableRetrievingSignOutURLFromSession = (config: SPACustomGrantConfig) => {
+ if (config.preventSignOutURLUpdate) {
+ _getSignOutURLFromSessionStorage = true;
+ }
+ };
+
+ const requestCustomGrant = async (config: SPACustomGrantConfig): Promise => {
+ return await _authenticationHelper.requestCustomGrant(config, enableRetrievingSignOutURLFromSession);
+ };
+
+ const refreshAccessToken = async (): Promise => {
+ try {
+ return await _authenticationHelper.refreshAccessToken(enableRetrievingSignOutURLFromSession);
+ } catch (error) {
+ return Promise.reject(error);
+ }
+ };
+
+ const revokeAccessToken = async (): Promise => {
+ const timer: number = await _spaHelper.getRefreshTimeoutTimer();
+
+ return _authenticationClient
+ .revokeAccessToken()
+ .then(() => {
+ _sessionManagementHelper.reset();
+ _spaHelper.clearRefreshTokenTimeout(timer);
+
+ return Promise.resolve(true);
+ })
+ .catch(error => Promise.reject(error));
+ };
+
+ const requestAccessToken = async (
+ resolvedAuthorizationCode: string,
+ resolvedSessionState: string,
+ resolvedState: string,
+ tokenRequestConfig?: {
+ params: Record;
+ },
+ ): Promise => {
+ return await _authenticationHelper.requestAccessToken(
+ resolvedAuthorizationCode,
+ resolvedSessionState,
+ checkSession,
+ undefined,
+ resolvedState,
+ tokenRequestConfig,
+ );
+ };
+
+ const constructSilentSignInUrl = async (additionalParams: Record = {}): Promise => {
+ const config = await _dataLayer.getConfigData();
+ const urlString: string = await _authenticationClient.getAuthorizationURL({
+ prompt: 'none',
+ state: SILENT_SIGN_IN_STATE,
+ ...additionalParams,
+ });
+
+ // Replace form_post with query
+ const urlObject = new URL(urlString);
+ urlObject.searchParams.set('response_mode', 'query');
+ const url: string = urlObject.toString();
+
+ if (config.storage === Storage.BrowserMemory && config.enablePKCE) {
+ const state = urlObject.searchParams.get(OIDCRequestConstants.Params.STATE);
+
+ SPAUtils.setPKCE(
+ extractPkceStorageKeyFromState(state ?? ''),
+ (await _authenticationClient.getPKCECode(state ?? '')) as string,
+ );
+ }
+
+ return url;
+ };
+
+ /**
+ * This method checks if there is an active user session in the server by sending a prompt none request.
+ * If the user is signed in, this method sends a token request. Returns false otherwise.
+ *
+ * @return {Promise,
+ tokenRequestConfig?: {params: Record},
+ ): Promise => {
+ return await _authenticationHelper.trySignInSilently(
+ constructSilentSignInUrl,
+ requestAccessToken,
+ _sessionManagementHelper,
+ additionalParams,
+ tokenRequestConfig,
+ );
+ };
+
+ const getBasicUserInfo = async (): Promise => {
+ return _authenticationHelper.getBasicUserInfo();
+ };
+
+ const getDecodedIDToken = async (): Promise => {
+ return _authenticationHelper.getDecodedIDToken();
+ };
+
+ const getCryptoHelper = async (): Promise => {
+ return _authenticationHelper.getCryptoHelper();
+ };
+
+ const getIDToken = async (): Promise => {
+ return _authenticationHelper.getIDToken();
+ };
+
+ const getOIDCServiceEndpoints = async (): Promise => {
+ return _authenticationHelper.getOIDCServiceEndpoints();
+ };
+
+ const getAccessToken = async (): Promise => {
+ return _authenticationHelper.getAccessToken();
+ };
+
+ const getDataLayer = async (): Promise> => {
+ return _authenticationHelper.getDataLayer();
+ };
+
+ const getConfigData = async (): Promise> => {
+ return await _dataLayer.getConfigData();
+ };
+
+ const isAuthenticated = async (): Promise => {
+ return _authenticationHelper.isAuthenticated();
+ };
+
+ const isSessionActive = async (): Promise => {
+ return (await _dataLayer.getSessionStatus()) === 'true';
+ };
+
+ const updateConfig = async (newConfig: Partial>): Promise => {
+ const existingConfig = await _dataLayer.getConfigData();
+ const isCheckSessionIframeDifferent: boolean = !(
+ existingConfig &&
+ existingConfig.endpoints &&
+ existingConfig.endpoints.checkSessionIframe &&
+ newConfig &&
+ newConfig.endpoints &&
+ newConfig.endpoints.checkSessionIframe &&
+ existingConfig.endpoints.checkSessionIframe === newConfig.endpoints.checkSessionIframe
+ );
+ const config = {...existingConfig, ...newConfig};
+ await _authenticationClient.updateConfig(config);
+
+ // Re-initiates check session if the check session endpoint is updated.
+ if (config.enableOIDCSessionManagement && isCheckSessionIframeDifferent) {
+ _sessionManagementHelper.reset();
+
+ checkSession();
+ }
+ };
+
+ return {
+ disableHttpHandler,
+ enableHttpHandler,
+ getAccessToken,
+ getBasicUserInfo,
+ getConfigData,
+ getCryptoHelper,
+ getDataLayer,
+ getDecodedIDToken,
+ getHttpClient,
+ getIDToken,
+ getOIDCServiceEndpoints,
+ httpRequest,
+ httpRequestAll,
+ isAuthenticated,
+ isSessionActive,
+ refreshAccessToken,
+ requestCustomGrant,
+ revokeAccessToken,
+ setHttpRequestErrorCallback,
+ setHttpRequestFinishCallback,
+ setHttpRequestStartCallback,
+ setHttpRequestSuccessCallback,
+ signIn,
+ signOut,
+ trySignInSilently,
+ updateConfig,
+ };
+};
diff --git a/packages/browser/src/__legacy__/clients/web-worker-client.ts b/packages/browser/src/__legacy__/clients/web-worker-client.ts
new file mode 100755
index 000000000..9a4ab4939
--- /dev/null
+++ b/packages/browser/src/__legacy__/clients/web-worker-client.ts
@@ -0,0 +1,864 @@
+/**
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ AsgardeoAuthClient,
+ AsgardeoAuthException,
+ AuthClientConfig,
+ BasicUserInfo,
+ IsomorphicCrypto,
+ CustomGrantConfig,
+ IdTokenPayload,
+ FetchResponse,
+ GetAuthURLConfig,
+ OIDCEndpoints,
+ ResponseMode,
+ OIDCRequestConstants,
+ Store,
+ extractPkceStorageKeyFromState,
+} from '@asgardeo/javascript';
+import {
+ DISABLE_HTTP_HANDLER,
+ ENABLE_HTTP_HANDLER,
+ GET_AUTH_URL,
+ GET_BASIC_USER_INFO,
+ GET_CONFIG_DATA,
+ GET_CRYPTO_HELPER,
+ GET_DECODED_IDP_ID_TOKEN,
+ GET_DECODED_ID_TOKEN,
+ GET_ID_TOKEN,
+ GET_OIDC_SERVICE_ENDPOINTS,
+ GET_SIGN_OUT_URL,
+ HTTP_REQUEST,
+ HTTP_REQUEST_ALL,
+ INIT,
+ IS_AUTHENTICATED,
+ REFRESH_ACCESS_TOKEN,
+ REQUEST_ACCESS_TOKEN,
+ REQUEST_CUSTOM_GRANT,
+ REQUEST_FINISH,
+ REQUEST_START,
+ REQUEST_SUCCESS,
+ REVOKE_ACCESS_TOKEN,
+ SET_SESSION_STATE,
+ SIGN_OUT,
+ SILENT_SIGN_IN_STATE,
+ START_AUTO_REFRESH_TOKEN,
+ UPDATE_CONFIG,
+} from '../constants';
+import {AuthenticationHelper, SPAHelper, SessionManagementHelper} from '../helpers';
+import {
+ AuthorizationInfo,
+ AuthorizationResponse,
+ HttpClient,
+ HttpError,
+ HttpRequestConfig,
+ HttpResponse,
+ Message,
+ ResponseMessage,
+ WebWorkerClientConfig,
+ WebWorkerClientInterface,
+} from '../models';
+import {SPACustomGrantConfig} from '../models/request-custom-grant';
+import {Storage} from '../models/storage';
+import {LocalStore, MemoryStore, SessionStore} from '../stores';
+import {SPAUtils} from '../utils';
+import {SPACryptoUtils} from '../utils/crypto-utils';
+
+const initiateStore = (store: Storage | undefined): Store => {
+ switch (store) {
+ case Storage.LocalStorage:
+ return new LocalStore();
+ case Storage.SessionStorage:
+ return new SessionStore();
+ case Storage.BrowserMemory:
+ return new MemoryStore();
+ default:
+ return new SessionStore();
+ }
+};
+
+export const WebWorkerClient = async (
+ instanceID: number,
+ config: AuthClientConfig,
+ webWorker: new () => Worker,
+ getAuthHelper: (
+ authClient: AsgardeoAuthClient,
+ spaHelper: SPAHelper,
+ ) => AuthenticationHelper,
+): Promise => {
+ /**
+ * HttpClient handlers
+ */
+ let httpClientHandlers: HttpClient;
+ /**
+ * API request time out.
+ */
+ const _requestTimeout: number = config?.requestTimeout ?? 60000;
+ let _isHttpHandlerEnabled: boolean = true;
+ let _getSignOutURLFromSessionStorage: boolean = false;
+
+ const _store: Store = initiateStore(config.storage as Storage);
+ const _cryptoUtils: SPACryptoUtils = new SPACryptoUtils();
+ const _authenticationClient = new AsgardeoAuthClient();
+ await _authenticationClient.initialize(config, _store, _cryptoUtils, instanceID);
+ const _spaHelper = new SPAHelper(_authenticationClient);
+
+ const _sessionManagementHelper = await SessionManagementHelper(
+ async () => {
+ const message: Message = {
+ type: SIGN_OUT,
+ };
+
+ try {
+ const signOutURL = await communicate(message);
+
+ return signOutURL;
+ } catch {
+ return SPAUtils.getSignOutURL(config.clientID, instanceID);
+ }
+ },
+ config.storage as Storage,
+ (sessionState: string) => setSessionState(sessionState),
+ );
+
+ const _authenticationHelper: AuthenticationHelper = getAuthHelper(
+ _authenticationClient,
+ _spaHelper,
+ );
+
+ const worker: Worker = new webWorker();
+
+ const communicate = (message: Message): Promise => {
+ const channel = new MessageChannel();
+
+ worker.postMessage(message, [channel.port2]);
+
+ return new Promise((resolve, reject) => {
+ const timer = setTimeout(() => {
+ reject(
+ new AsgardeoAuthException(
+ 'SPA-WEB_WORKER_CLIENT-COM-TO01',
+ 'Operation timed out.',
+ 'No response was received from the web worker for ' +
+ _requestTimeout / 1000 +
+ ' since dispatching the request',
+ ),
+ );
+ }, _requestTimeout);
+
+ return (channel.port1.onmessage = ({data}: {data: ResponseMessage}) => {
+ clearTimeout(timer);
+ channel.port1.close();
+ channel.port2.close();
+
+ if (data?.success) {
+ const responseData = data?.data ? JSON.parse(data?.data) : null;
+ if (data?.blob) {
+ responseData.data = data?.blob;
+ }
+
+ resolve(responseData);
+ } else {
+ reject(data.error ? JSON.parse(data.error) : null);
+ }
+ });
+ });
+ };
+
+ /**
+ * Allows using custom grant types.
+ *
+ * @param {CustomGrantRequestParams} requestParams Request Parameters.
+ *
+ * @returns {Promise} A promise that resolves with a boolean value or the request
+ * response if the the `returnResponse` attribute in the `requestParams` object is set to `true`.
+ */
+ const requestCustomGrant = (requestParams: SPACustomGrantConfig): Promise => {
+ const message: Message = {
+ data: requestParams,
+ type: REQUEST_CUSTOM_GRANT,
+ };
+
+ return communicate(message)
+ .then(response => {
+ if (requestParams.preventSignOutURLUpdate) {
+ _getSignOutURLFromSessionStorage = true;
+ }
+
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ /**
+ *
+ * Send the API request to the web worker and returns the response.
+ *
+ * @param {HttpRequestConfig} config The Http Request Config object
+ *
+ * @returns {Promise} A promise that resolves with the response data.
+ */
+ const httpRequest = (config: HttpRequestConfig): Promise> => {
+ /**
+ *
+ * Currently FormData is not supported to send to a web worker
+ *
+ * Below workaround will represent FormData object as a JSON.
+ * This workaround will not be needed once FormData object is made cloneable
+ * Reference: https://github.com/whatwg/xhr/issues/55
+ */
+ if (config?.data && config?.data instanceof FormData) {
+ config.data = {...Object.fromEntries((config?.data as any).entries()), formData: true};
+ }
+
+ const message: Message = {
+ data: config,
+ type: HTTP_REQUEST,
+ };
+
+ return communicate>(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(async error => {
+ if (_isHttpHandlerEnabled) {
+ if (typeof httpClientHandlers.requestErrorCallback === 'function') {
+ await httpClientHandlers.requestErrorCallback(error);
+ }
+ if (typeof httpClientHandlers.requestFinishCallback === 'function') {
+ httpClientHandlers.requestFinishCallback();
+ }
+ }
+
+ return Promise.reject(error);
+ });
+ };
+
+ /**
+ *
+ * Send multiple API requests to the web worker and returns the response.
+ * Similar `axios.spread` in functionality.
+ *
+ * @param {HttpRequestConfig[]} configs - The Http Request Config object
+ *
+ * @returns {Promise[]>} A promise that resolves with the response data.
+ */
+ const httpRequestAll = (configs: HttpRequestConfig[]): Promise[]> => {
+ const message: Message = {
+ data: configs,
+ type: HTTP_REQUEST_ALL,
+ };
+
+ return communicate[]>(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(async error => {
+ if (_isHttpHandlerEnabled) {
+ if (typeof httpClientHandlers.requestErrorCallback === 'function') {
+ await httpClientHandlers.requestErrorCallback(error);
+ }
+ if (typeof httpClientHandlers.requestFinishCallback === 'function') {
+ httpClientHandlers.requestFinishCallback();
+ }
+ }
+
+ return Promise.reject(error);
+ });
+ };
+
+ const enableHttpHandler = (): Promise => {
+ const message: Message = {
+ type: ENABLE_HTTP_HANDLER,
+ };
+ return communicate(message)
+ .then(() => {
+ _isHttpHandlerEnabled = true;
+
+ return Promise.resolve(true);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const disableHttpHandler = (): Promise => {
+ const message: Message = {
+ type: DISABLE_HTTP_HANDLER,
+ };
+ return communicate(message)
+ .then(() => {
+ _isHttpHandlerEnabled = false;
+
+ return Promise.resolve(true);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ /**
+ * Initializes the object with authentication parameters.
+ *
+ * @param {ConfigInterface} config The configuration object.
+ *
+ * @returns {Promise} Promise that resolves when initialization is successful.
+ *
+ */
+ const initialize = (): Promise => {
+ if (!httpClientHandlers) {
+ httpClientHandlers = {
+ requestErrorCallback: () => Promise.resolve(),
+ requestFinishCallback: () => null,
+ requestStartCallback: () => null,
+ requestSuccessCallback: () => null,
+ };
+ }
+
+ worker.onmessage = ({data}) => {
+ switch (data.type) {
+ case REQUEST_FINISH:
+ httpClientHandlers?.requestFinishCallback && httpClientHandlers?.requestFinishCallback();
+ break;
+ case REQUEST_START:
+ httpClientHandlers?.requestStartCallback && httpClientHandlers?.requestStartCallback();
+ break;
+ case REQUEST_SUCCESS:
+ httpClientHandlers?.requestSuccessCallback &&
+ httpClientHandlers?.requestSuccessCallback(data.data ? JSON.parse(data.data) : null);
+ break;
+ }
+ };
+
+ const message: Message> = {
+ data: config,
+ type: INIT,
+ };
+
+ return communicate, null>(message)
+ .then(() => {
+ return Promise.resolve(true);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const setSessionState = (sessionState: string | null): Promise => {
+ const message: Message = {
+ data: sessionState,
+ type: SET_SESSION_STATE,
+ };
+
+ return communicate(message);
+ };
+
+ const startAutoRefreshToken = (): Promise => {
+ const message: Message = {
+ type: START_AUTO_REFRESH_TOKEN,
+ };
+
+ return communicate(message);
+ };
+
+ const checkSession = async (): Promise => {
+ const oidcEndpoints: OIDCEndpoints = await getOIDCServiceEndpoints();
+ const config: AuthClientConfig = await getConfigData();
+
+ _authenticationHelper.initializeSessionManger(
+ config,
+ oidcEndpoints,
+ async () => (await getBasicUserInfo()).sessionState,
+ async (params?: GetAuthURLConfig): Promise => (await getAuthorizationURL(params)).authorizationURL,
+ _sessionManagementHelper,
+ );
+ };
+
+ const constructSilentSignInUrl = async (additionalParams: Record = {}): Promise => {
+ const config: AuthClientConfig = await getConfigData();
+ const message: Message = {
+ data: {
+ prompt: 'none',
+ state: SILENT_SIGN_IN_STATE,
+ ...additionalParams,
+ },
+ type: GET_AUTH_URL,
+ };
+
+ const response: AuthorizationResponse = await communicate(message);
+
+ const pkceKey: string = extractPkceStorageKeyFromState(
+ new URL(response.authorizationURL).searchParams.get(OIDCRequestConstants.Params.STATE) ?? '',
+ );
+
+ response.pkce && config.enablePKCE && SPAUtils.setPKCE(pkceKey, response.pkce);
+
+ const urlString: string = response.authorizationURL;
+
+ // Replace form_post with query
+ const urlObject = new URL(urlString);
+ urlObject.searchParams.set('response_mode', 'query');
+ const url: string = urlObject.toString();
+
+ return url;
+ };
+
+ /**
+ * This method checks if there is an active user session in the server by sending a prompt none request.
+ * If the user is signed in, this method sends a token request. Returns false otherwise.
+ *
+ * @return {Promise,
+ tokenRequestConfig?: {params: Record},
+ ): Promise => {
+ return await _authenticationHelper.trySignInSilently(
+ constructSilentSignInUrl,
+ requestAccessToken,
+ _sessionManagementHelper,
+ additionalParams,
+ tokenRequestConfig,
+ );
+ };
+
+ /**
+ * Generates an authorization URL.
+ *
+ * @param {GetAuthURLConfig} params Authorization URL params.
+ * @returns {Promise} Authorization URL.
+ */
+ const getAuthorizationURL = async (params?: GetAuthURLConfig): Promise => {
+ const config: AuthClientConfig = await getConfigData();
+
+ const message: Message = {
+ data: params,
+ type: GET_AUTH_URL,
+ };
+
+ return communicate(message).then(
+ async (response: AuthorizationResponse) => {
+ if (response.pkce && config.enablePKCE) {
+ const pkceKey: string = extractPkceStorageKeyFromState(
+ new URL(response.authorizationURL).searchParams.get(OIDCRequestConstants.Params.STATE) ?? '',
+ );
+
+ SPAUtils.setPKCE(pkceKey, response.pkce);
+ }
+
+ return Promise.resolve(response);
+ },
+ );
+ };
+
+ const requestAccessToken = async (
+ resolvedAuthorizationCode: string,
+ resolvedSessionState: string,
+ resolvedState: string,
+ tokenRequestConfig?: {
+ params: Record;
+ },
+ ): Promise => {
+ const config: AuthClientConfig = await getConfigData();
+ const pkceKey: string = extractPkceStorageKeyFromState(resolvedState);
+
+ const message: Message = {
+ data: {
+ code: resolvedAuthorizationCode,
+ pkce: config.enablePKCE ? SPAUtils.getPKCE(pkceKey) : undefined,
+ sessionState: resolvedSessionState,
+ state: resolvedState,
+ tokenRequestConfig,
+ },
+ type: REQUEST_ACCESS_TOKEN,
+ };
+
+ config.enablePKCE && SPAUtils.removePKCE(pkceKey);
+
+ return communicate(message)
+ .then(response => {
+ const message: Message = {
+ type: GET_SIGN_OUT_URL,
+ };
+
+ return communicate(message)
+ .then((url: string) => {
+ SPAUtils.setSignOutURL(url, config.clientID, instanceID);
+
+ // Enable OIDC Sessions Management only if it is set to true in the config.
+ if (config.enableOIDCSessionManagement) {
+ checkSession();
+ }
+
+ startAutoRefreshToken();
+
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const shouldStopAuthn = async (): Promise => {
+ return await _sessionManagementHelper.receivePromptNoneResponse(async (sessionState: string | null) => {
+ return setSessionState(sessionState);
+ });
+ };
+
+ const tryRetrievingUserInfo = async (): Promise => {
+ if (await isAuthenticated()) {
+ await startAutoRefreshToken();
+
+ // Enable OIDC Sessions Management only if it is set to true in the config.
+ if (config.enableOIDCSessionManagement) {
+ checkSession();
+ }
+
+ return getBasicUserInfo();
+ }
+
+ return Promise.resolve(undefined);
+ };
+
+ /**
+ * Initiates the authentication flow.
+ *
+ * @returns {Promise} A promise that resolves when authentication is successful.
+ */
+ const signIn = async (
+ params?: GetAuthURLConfig,
+ authorizationCode?: string,
+ sessionState?: string,
+ state?: string,
+ tokenRequestConfig?: {
+ params: Record;
+ },
+ ): Promise => {
+ const basicUserInfo = await _authenticationHelper.handleSignIn(
+ shouldStopAuthn,
+ checkSession,
+ tryRetrievingUserInfo,
+ );
+
+ if (basicUserInfo) {
+ return basicUserInfo;
+ } else {
+ let resolvedAuthorizationCode: string;
+ let resolvedSessionState: string;
+ let resolvedState: string;
+
+ if (config?.responseMode === ResponseMode.FormPost && authorizationCode) {
+ resolvedAuthorizationCode = authorizationCode;
+ resolvedSessionState = sessionState ?? '';
+ resolvedState = state ?? '';
+ } else {
+ resolvedAuthorizationCode =
+ new URL(window.location.href).searchParams.get(OIDCRequestConstants.Params.AUTHORIZATION_CODE) ?? '';
+ resolvedSessionState =
+ new URL(window.location.href).searchParams.get(OIDCRequestConstants.Params.SESSION_STATE) ?? '';
+ resolvedState = new URL(window.location.href).searchParams.get(OIDCRequestConstants.Params.STATE) ?? '';
+
+ SPAUtils.removeAuthorizationCode();
+ }
+
+ if (resolvedAuthorizationCode && resolvedState) {
+ return requestAccessToken(resolvedAuthorizationCode, resolvedSessionState, resolvedState, tokenRequestConfig);
+ }
+
+ return getAuthorizationURL(params)
+ .then(async (response: AuthorizationResponse) => {
+ location.href = response.authorizationURL;
+
+ await SPAUtils.waitTillPageRedirect();
+
+ return Promise.resolve({
+ allowedScopes: '',
+ displayName: '',
+ email: '',
+ sessionState: '',
+ sub: '',
+ tenantDomain: '',
+ username: '',
+ });
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ }
+ };
+
+ /**
+ * Initiates the sign out flow.
+ *
+ * @returns {Promise} A promise that resolves when sign out is completed.
+ */
+ const signOut = (): Promise => {
+ return new Promise((resolve, reject) => {
+ if (!_getSignOutURLFromSessionStorage) {
+ const message: Message = {
+ type: SIGN_OUT,
+ };
+
+ return communicate(message)
+ .then(async response => {
+ window.location.href = response;
+
+ await SPAUtils.waitTillPageRedirect();
+
+ return resolve(true);
+ })
+ .catch(error => {
+ return reject(error);
+ });
+ } else {
+ window.location.href = SPAUtils.getSignOutURL(config.clientID, instanceID);
+
+ return SPAUtils.waitTillPageRedirect().then(() => {
+ return Promise.resolve(true);
+ });
+ }
+ });
+ };
+
+ /**
+ * Revokes token.
+ *
+ * @returns {Promise} A promise that resolves when revoking is completed.
+ */
+ const revokeAccessToken = (): Promise => {
+ const message: Message = {
+ type: REVOKE_ACCESS_TOKEN,
+ };
+
+ return communicate(message)
+ .then(response => {
+ _sessionManagementHelper.reset();
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getOIDCServiceEndpoints = (): Promise => {
+ const message: Message = {
+ type: GET_OIDC_SERVICE_ENDPOINTS,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getConfigData = (): Promise> => {
+ const message: Message = {
+ type: GET_CONFIG_DATA,
+ };
+
+ return communicate>(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getBasicUserInfo = (): Promise => {
+ const message: Message = {
+ type: GET_BASIC_USER_INFO,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getDecodedIDToken = (): Promise => {
+ const message: Message = {
+ type: GET_DECODED_ID_TOKEN,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getDecodedIDPIDToken = (): Promise => {
+ const message: Message = {
+ type: GET_DECODED_IDP_ID_TOKEN,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getCryptoHelper = (): Promise => {
+ const message: Message = {
+ type: GET_CRYPTO_HELPER,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const getIDToken = (): Promise => {
+ const message: Message = {
+ type: GET_ID_TOKEN,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const isAuthenticated = (): Promise => {
+ const message: Message = {
+ type: IS_AUTHENTICATED,
+ };
+
+ return communicate(message)
+ .then(response => {
+ return Promise.resolve(response);
+ })
+ .catch(error => {
+ return Promise.reject(error);
+ });
+ };
+
+ const refreshAccessToken = (): Promise => {
+ const message: Message = {
+ type: REFRESH_ACCESS_TOKEN,
+ };
+
+ return communicate(message);
+ };
+
+ const setHttpRequestSuccessCallback = (callback: (response: HttpResponse) => void): void => {
+ if (callback && typeof callback === 'function') {
+ httpClientHandlers.requestSuccessCallback = callback;
+ }
+ };
+
+ const setHttpRequestErrorCallback = (callback: (response: HttpError) => void | Promise): void => {
+ if (callback && typeof callback === 'function') {
+ httpClientHandlers.requestErrorCallback = callback;
+ }
+ };
+
+ const setHttpRequestStartCallback = (callback: () => void): void => {
+ if (callback && typeof callback === 'function') {
+ httpClientHandlers.requestStartCallback = callback;
+ }
+ };
+
+ const setHttpRequestFinishCallback = (callback: () => void): void => {
+ if (callback && typeof callback === 'function') {
+ httpClientHandlers.requestFinishCallback = callback;
+ }
+ };
+
+ const updateConfig = async (newConfig: Partial>): Promise => {
+ const existingConfig = await getConfigData();
+ const isCheckSessionIframeDifferent: boolean = !(
+ existingConfig &&
+ existingConfig.endpoints &&
+ existingConfig.endpoints.checkSessionIframe &&
+ newConfig &&
+ newConfig.endpoints &&
+ newConfig.endpoints.checkSessionIframe &&
+ existingConfig.endpoints.checkSessionIframe === newConfig.endpoints.checkSessionIframe
+ );
+ const config = {...existingConfig, ...newConfig};
+
+ const message: Message>> = {
+ data: config,
+ type: UPDATE_CONFIG,
+ };
+
+ await communicate>, void>(message);
+
+ // Re-initiates check session if the check session endpoint is updated.
+ if (config.enableOIDCSessionManagement && isCheckSessionIframeDifferent) {
+ _sessionManagementHelper.reset();
+
+ checkSession();
+ }
+ };
+
+ return {
+ disableHttpHandler,
+ enableHttpHandler,
+ getBasicUserInfo,
+ getConfigData,
+ getCryptoHelper,
+ getDecodedIDPIDToken,
+ getDecodedIDToken,
+ getIDToken,
+ getOIDCServiceEndpoints,
+ httpRequest,
+ httpRequestAll,
+ initialize,
+ isAuthenticated,
+ refreshAccessToken,
+ requestCustomGrant,
+ revokeAccessToken,
+ setHttpRequestErrorCallback,
+ setHttpRequestFinishCallback,
+ setHttpRequestStartCallback,
+ setHttpRequestSuccessCallback,
+ signIn,
+ signOut,
+ trySignInSilently,
+ updateConfig,
+ };
+};
diff --git a/packages/browser/src/__legacy__/constants/errors.ts b/packages/browser/src/__legacy__/constants/errors.ts
new file mode 100644
index 000000000..506db48e9
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/errors.ts
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export const ACCESS_TOKEN_INVALID = "Access token is invalid";
diff --git a/packages/browser/src/__legacy__/constants/hooks.ts b/packages/browser/src/__legacy__/constants/hooks.ts
new file mode 100644
index 000000000..e34baf4b0
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/hooks.ts
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export enum Hooks {
+ SignIn = "sign-in",
+ SignOut = "sign-out",
+ Initialize = "initialize",
+ HttpRequestStart = "http-request-start",
+ HttpRequestFinish = "http-request-finish",
+ HttpRequestError = "http-request-error",
+ HttpRequestSuccess = "http-request-success",
+ RevokeAccessToken = "revoke-access-token",
+ CustomGrant = "custom-grant",
+ SignOutFailed = "sign-out-failed"
+}
diff --git a/packages/browser/src/__legacy__/constants/index.ts b/packages/browser/src/__legacy__/constants/index.ts
new file mode 100644
index 000000000..67b72880a
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/index.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from "./messages-types";
+export * from "./storage";
+export * from "./hooks";
+export * from "./session-management";
+export * from "./parameters";
+export * from "./errors";
diff --git a/packages/browser/src/__legacy__/constants/messages-types.ts b/packages/browser/src/__legacy__/constants/messages-types.ts
new file mode 100644
index 000000000..a37317af1
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/messages-types.ts
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export const INIT = "init";
+export const SIGN_IN = "sign-in";
+export const AUTH_CODE = "auth-code";
+export const SIGN_OUT = "sign-out";
+export const HTTP_REQUEST = "http-request";
+export const HTTP_REQUEST_ALL = "http-request-all";
+export const REQUEST_CUSTOM_GRANT = "request-custom-grant";
+export const REVOKE_ACCESS_TOKEN = "revoke-access-token";
+export const END_USER_SESSION = "end-user-session";
+export const REQUEST_START = "request-start";
+export const REQUEST_SUCCESS = "request-success";
+export const REQUEST_ERROR = "request-error";
+export const REQUEST_FINISH = "request-finish";
+export const GET_OIDC_SERVICE_ENDPOINTS = "get-oidc-service-endpoints";
+export const GET_BASIC_USER_INFO = "get-basic-user-info";
+export const GET_DECODED_ID_TOKEN = "get-decoded-id-token";
+export const GET_DECODED_IDP_ID_TOKEN = "get-decoded-idp-id-token";
+export const GET_CRYPTO_HELPER = "get-crypto-helper"
+export const ENABLE_HTTP_HANDLER = "enable_http_handler";
+export const DISABLE_HTTP_HANDLER = "disable_http_handler";
+export const GET_AUTH_URL = "get_auth_url";
+export const REQUEST_ACCESS_TOKEN = "request_get_token";
+export const IS_AUTHENTICATED = "is_authenticated";
+export const GET_SIGN_OUT_URL = "get_sign_out_url";
+export const REFRESH_ACCESS_TOKEN = "refresh_access-token";
+export const REFRESH_ACCESS_TOKEN_ERR0R = "refresh-access-token-error";
+export const SET_SESSION_STATE = "set_session_state";
+export const START_AUTO_REFRESH_TOKEN = "start_auto_refresh_token";
+export const UPDATE_CONFIG = "update_config";
+export const GET_ID_TOKEN = "get_id_token";
+export const CHECK_SESSION_SIGNED_IN = "check_session_signed_in";
+export const CHECK_SESSION_SIGNED_OUT = "check_session_signed_out";
+export const GET_CONFIG_DATA = "get_config_data";
+export const SET_SESSION_STATE_FROM_IFRAME = "set_session_state_from_iframe";
diff --git a/packages/browser/src/__legacy__/constants/parameters.ts b/packages/browser/src/__legacy__/constants/parameters.ts
new file mode 100644
index 000000000..869771ca7
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/parameters.ts
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export const ERROR = "error";
+export const ERROR_DESCRIPTION = "error_description";
+export const CUSTOM_GRANT_CONFIG = "custom_grant_config";
+export const STATE_QUERY = "state";
diff --git a/packages/browser/src/__legacy__/constants/session-management.ts b/packages/browser/src/__legacy__/constants/session-management.ts
new file mode 100644
index 000000000..9102f7dd0
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/session-management.ts
@@ -0,0 +1,26 @@
+/**
+* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+export const OP_IFRAME = "opIFrame";
+export const RP_IFRAME = "rpIFrame";
+export const PROMPT_NONE_IFRAME = "promptNoneIFrame";
+export const STATE = "Y2hlY2tTZXNzaW9u";
+export const SILENT_SIGN_IN_STATE = "sign-in-silently";
+export const INITIALIZED_SIGN_IN = "initialized-sign-in";
+export const INITIALIZED_SILENT_SIGN_IN = "initialized-silent-sign-in";
+export const PROMPT_NONE_REQUEST_SENT = "promptNoneRequestSent";
diff --git a/packages/browser/src/__legacy__/constants/storage.ts b/packages/browser/src/__legacy__/constants/storage.ts
new file mode 100644
index 000000000..56661a09e
--- /dev/null
+++ b/packages/browser/src/__legacy__/constants/storage.ts
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export const TOKEN_REQUEST_CONFIG_KEY = "token_request_config";
diff --git a/packages/browser/src/__legacy__/helpers/authentication-helper.ts b/packages/browser/src/__legacy__/helpers/authentication-helper.ts
new file mode 100644
index 000000000..cb9f83e0d
--- /dev/null
+++ b/packages/browser/src/__legacy__/helpers/authentication-helper.ts
@@ -0,0 +1,698 @@
+/**
+ * Copyright (c) 2022-2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ AsgardeoAuthClient,
+ AsgardeoAuthException,
+ AuthClientConfig,
+ BasicUserInfo,
+ IsomorphicCrypto,
+ CustomGrantConfig,
+ DataLayer,
+ IdTokenPayload,
+ FetchResponse,
+ GetAuthURLConfig,
+ OIDCEndpoints,
+ TokenResponse,
+ extractPkceStorageKeyFromState,
+} from '@asgardeo/javascript';
+import {SPAHelper} from './spa-helper';
+import {
+ ACCESS_TOKEN_INVALID,
+ CHECK_SESSION_SIGNED_IN,
+ CHECK_SESSION_SIGNED_OUT,
+ CUSTOM_GRANT_CONFIG,
+ ERROR,
+ ERROR_DESCRIPTION,
+ PROMPT_NONE_IFRAME,
+ REFRESH_ACCESS_TOKEN_ERR0R,
+ RP_IFRAME,
+} from '../constants';
+import {
+ AuthorizationInfo,
+ HttpClientInstance,
+ HttpError,
+ HttpRequestConfig,
+ HttpRequestInterface,
+ HttpResponse,
+ MainThreadClientConfig,
+ Message,
+ SessionManagementHelperInterface,
+ WebWorkerClientConfig,
+} from '../models';
+import {SPACustomGrantConfig} from '../models/request-custom-grant';
+import {Storage} from '../models/storage';
+import {SPAUtils} from '../utils';
+
+export class AuthenticationHelper {
+ protected _authenticationClient: AsgardeoAuthClient;
+ protected _dataLayer: DataLayer;
+ protected _spaHelper: SPAHelper