Skip to content

Feat: js flow api sdk #2097

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

Merged
merged 3 commits into from
Apr 24, 2025
Merged

Feat: js flow api sdk #2097

merged 3 commits into from
Apr 24, 2025

Conversation

bjoern-m
Copy link
Contributor

@bjoern-m bjoern-m commented Mar 21, 2025

Description

This PR introduces a new TypeScript-based SDK for managing authentication flows with Hanko.

Key Features

  • State Management: The State class encapsulates flow states with properties like name, payload, actions, and csrfToken. It supports initialization, serialization (save/load), and event dispatching for state changes.
  • Action Execution: The Action class enables type-safe action invocation.
  • Auto-Stepping: Automatically progresses through predefined states via autoSteps, with configurable exclusion options.
  • Passkey Autofill: Integrates passkey autofill activation handlers for supported states.
  • Persistence: Serializes state to localStorage.

Example Usage:

const hanko = new Hanko(/* params */);
const state = await hanko.createState("login");

await state.actions.continue_with_login_identifier.run({
  username: "user",
});

hanko.onBeforeStateChange(({state}) => {
  console.log(`action has been invoked ${state.invokedAction.name}`);
});

hanko.onAfterStateChange(({state}) => {
  console.log(`action has been finished ${state.previousAction.name}`);

  if (state.name == "login_init") {
    state.passkeyAutofillActivation();
  }
});

Todos

  • Support for IdP-initiated SAML sign-in
  • Readme

@github-project-automation github-project-automation bot moved this to 🆕 New in Hanko Mar 21, 2025
@bjoern-m bjoern-m marked this pull request as ready for review March 21, 2025 14:57
@bjoern-m bjoern-m force-pushed the feat-js-flow-api-sdk branch from e523af8 to 06acf9e Compare March 28, 2025 12:35
@bjoern-m bjoern-m requested a review from lfleischmann April 23, 2025 13:55
@bjoern-m bjoern-m force-pushed the feat-js-flow-api-sdk branch from 3cb87cb to c404832 Compare April 23, 2025 15:37
@bjoern-m bjoern-m merged commit 6af6953 into main Apr 24, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Recently closed in Hanko Apr 24, 2025
@bjoern-m bjoern-m deleted the feat-js-flow-api-sdk branch April 24, 2025 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants