Skip to content

Add a package sdk-vanilla to the repository #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

lyleschemmerling
Copy link

@lyleschemmerling lyleschemmerling commented Feb 7, 2025

Fixes #175

Add a new package sdk-vanilla to the repository to provide FusionAuth SDK for vanilla JavaScript with web components.

  • Package Metadata and Configuration

    • Add package.json with package metadata, scripts, dependencies, and build configuration.
    • Add vite.config.ts for Vite build configuration.
  • Web Components

    • Add fa-account.ts to implement the fa-account web component with a button to redirect to the user's account management page.
    • Add fa-login.ts to implement the fa-login web component with a button to redirect to the /app/login endpoint and start the OAuth flow.
    • Add fa-logout.ts to implement the fa-logout web component with a button to redirect to the /app/logout endpoint.
    • Add fa-register.ts to implement the fa-register web component with a button to redirect to the /app/register endpoint.
  • FusionAuthService

    • Add FusionAuthService.ts to implement the FusionAuthService class with methods for login, register, logout, manage account, fetch user info, refresh token, auto-refresh, and post-redirect handling.
    • Store and retrieve configuration from localStorage.
  • Documentation

    • Add README.md with instructions and examples on how to use the sdk-vanilla package.
  • Tests

    • Add tests for FusionAuthService in FusionAuthService.test.ts.
    • Add tests for web components in fa-account.test.ts, fa-login.test.ts, fa-logout.test.ts, and fa-register.test.ts.

For more details, open the Copilot Workspace session.

Fixes FusionAuth#175

Add a new package `sdk-vanilla` to the repository to provide FusionAuth SDK for vanilla JavaScript with web components.

* **Package Metadata and Configuration**
  - Add `package.json` with package metadata, scripts, dependencies, and build configuration.
  - Add `vite.config.ts` for Vite build configuration.

* **Web Components**
  - Add `fa-account.ts` to implement the `fa-account` web component with a button to redirect to the user's account management page.
  - Add `fa-login.ts` to implement the `fa-login` web component with a button to redirect to the /app/login endpoint and start the OAuth flow.
  - Add `fa-logout.ts` to implement the `fa-logout` web component with a button to redirect to the /app/logout endpoint.
  - Add `fa-register.ts` to implement the `fa-register` web component with a button to redirect to the /app/register endpoint.

* **FusionAuthService**
  - Add `FusionAuthService.ts` to implement the `FusionAuthService` class with methods for login, register, logout, manage account, fetch user info, refresh token, auto-refresh, and post-redirect handling.
  - Store and retrieve configuration from localStorage.

* **Documentation**
  - Add `README.md` with instructions and examples on how to use the `sdk-vanilla` package.

* **Tests**
  - Add tests for `FusionAuthService` in `FusionAuthService.test.ts`.
  - Add tests for web components in `fa-account.test.ts`, `fa-login.test.ts`, `fa-logout.test.ts`, and `fa-register.test.ts`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/FusionAuth/fusionauth-javascript-sdk/issues/175?shareId=XXXX-XXXX-XXXX-XXXX).
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 14 changed files in this pull request and generated no comments.

Files not reviewed (9)
  • packages/sdk-vanilla/package.json: Language not supported
  • packages/sdk-vanilla/src/components/fa-register.test.ts: Evaluated as low risk
  • packages/sdk-vanilla/src/FusionAuthService.test.ts: Evaluated as low risk
  • packages/sdk-vanilla/src/FusionAuthService.ts: Evaluated as low risk
  • packages/sdk-vanilla/src/components/fa-account.test.ts: Evaluated as low risk
  • packages/sdk-vanilla/src/components/fa-account.ts: Evaluated as low risk
  • packages/sdk-vanilla/src/components/fa-login.test.ts: Evaluated as low risk
  • packages/sdk-vanilla/README.md: Evaluated as low risk
  • packages/sdk-vanilla/vite.config.ts: Evaluated as low risk

</script>
</head>
<body>
<fa-login></fa-login>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add all component buttons to this example

…ll request

* **New `sdk-vanilla` package**
  - Add the package to the repository
  - Include specified web components (`fa-account`, `fa-login`, `fa-logout`, `fa-register`) and a `FusionAuthService` typescript class
  - Implement the `FusionAuthService` class to handle intermediate functions and use the same functions from the core package as the other SDKs
  - Match the styles of the web components with the existing SDKs
  - Add a `vite.config.ts` file to build the library
  - Create documentation and a `README.md` file with instructions and examples on how to use the `sdk-vanilla` package
  - Update the `FusionAuthService` class to store the config in localStorage and pull the config from localStorage before making any requests
  - Ensure each of the "start" methods in the service uses `getConfig` before making requests
  - Remove the need for components to pass a config into the constructor for the service
  - Add tests for the `FusionAuthService` class and the web components
</script>
</head>
<body>
<fa-login></fa-login>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add all component buttons to this example

@lyleschemmerling
Copy link
Author

Please add build scripts for yalc in the top-level package.json for sdk-vanilla

…s for sdk-vanilla

* **README.md**
  - Add a section to address new comments
  - Include details about the new `sdk-vanilla` package, documentation updates, and additional examples
  - Mention performance optimizations and styling updates for web components
  - Update Vite configuration and tests for `FusionAuthService` and web components

* **package.json**
  - Add `sdk-vanilla` to workspaces
  - Add build script for `sdk-vanilla`
  - Add yalc publish script for `sdk-vanilla`
  - Update test script to include `sdk-vanilla`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a package sdk-vanilla to the repository
2 participants