Skip to content

Commit

Permalink
Ability to customise recipe functions (supertokens#251)
Browse files Browse the repository at this point in the history
* bumps version and changes changelog

* changes to typing of user input

* more types fixing

* type fixing for thirdparty

* type fixing for thirdpartyemailpassword

* fixes types in emailpassword > components

* fixes types in emailverification > components

* gets all TS to build

* builds and prettifies

* fixes bug with emailverificaiton type inside authmodule

* adds comments for types in emailverification

* fixes use of emailverification recipe inside authmodule

* changes to js map

* fixes all tests

* creates email password interface

* gets ts to build

* fixes tests

* adds interface definition to thirdparty recipe

* implements thirdparty interface

* adds override config for thirdparty recipe and fixes tests

* creates interface for thirdpartyemailpassword and some other refactors

* fixes tests

* reverts preAPIHook to how it used to be - for ease of use

* refactors thirdparty recipe feature code to put it in the implementation class

* cleans up props passed to theme in thirdparty and tpep recipe

* cleans up props passed

* changes to redirectToAuth function signature

* fixes tests, and using one recipe inside the other without duplicate creation of objects

* fixes tests

* adds override for emailverification

* adds recipe interface to session with ability to override

* removes sigout API call from authrecipe module

* fixes test

* fires events when the relevant API is called as opposed to in feature logic. Removoes onSuccess callback function from base theme props

* fires success events when the relevant API is called as opposed to in feature logic.

* removes httpRequest from base class recipe class

* moves with-ts project into test folder and removes unnecessary .ts files from the project

* checks ts for override

* Add component override context, make components functional, add override map

This is the preliminary work to allow component overriding.

* Rename theme components to include recipe name

This aims to provide a unique name for each component to simplify overriding them.

* adds few more recipe interface functions to session recipe to save, fetch session and to handle session expiry

* removes handleSessionExpiry from recipe interface for sessions

* changes to testing for normalisation of url and path

* changes how path is normalised

* Change component override context implementation to object, throw error on no context

* Move override mechanism parts to a dedicated component directory

* Add override map to normalised config, use override provider in feature component

* Add overrides for ThirdParty and ThirdPartyEmailPassword recipes

* updates use of session SDK

* checks pre api hook for session recipe

* Add default component override map for normalised configs

* Make EmailVerification components overridable

* Add component overrides for resetPasswordUsingToken feature

* Enable override component for signInAndUpCallback feature

* Change theme component exports to named exports

This is done so that component names in React inspector match
the override names. To accomplish that, a named export with variable
matching the filename is exported instead of default.

Otherwise, the only way to do this would be to use variable shadowing, like:
```ts
export const EmailPasswordSignUp = withOverride("EmailPasswordSignUp", class EmailPasswordSignUp extends ... );
// or
export const EmailPasswordSignUp = withOverride("EmailPasswordSignUp", function EmailPasswordSignUp(...));
```

Since variable shadowing is not recommended and this is pretty ugly, unexpected and "tricky", current approach was used.

* updates changelog

* Add .idea to gitignore, check for undefined or null context in withOverride

* detects if withOverride is being using without parent provider

* Add component testing framework, test withOverride as an example

* Move jest.config.js to test/unit

* Move tsconfig.test.json to test/unit folder, adjust testRegex config

* Add unit component-testing step to test script

* Remove redundant check of null or undefined context

This probably was a merging leftover.

* Extend emailVerification override with components override map

* Pass component overrides to recipes instantiated within ThirdPartyEmailPassword

* Update withOverride test to throw an error without parent provider

* Test EmailPassword component overrides

* Enforce testing all overridable components in tests

* Change default to named exports in remaining recipes, add missing override tests

* adds prop-types to dev dependency

* fixes routing issue when base path is /

* streamlines type of override function

* updates dependencies

* Separate e2e test script in package file

* Add Querier preApiHook tests

* Separate e2e test script in package file

* Test embedding component behaviour using disableDefaultImplementation

* Add EmailVerification and ResetPassword tests

* Fix EmailVerification test issue by signing up

* Add preAPIHook and onHandleEvent handlers, test handlers

* changes input type of thirdparty

* Remove leftover page.screenshot call

* Link an issue to a refresh session workaround

* Add EmailPassword recipe override tests

* Add ThirdParty recipe override tests

* Add Session recipe override tests

* Add ThirdPartyEmailPassword recipe override tests

* Use log with prefix function in override implementations

* Add EmailVerification implementation overrides tests for all recipes

* changes to pre api hook action name for third party

* changes to tests for previous commit

* fixes to tests

Co-authored-by: Marek Dulowski <[email protected]>
  • Loading branch information
rishabhpoddar and dulowski-marek committed Jun 17, 2021
1 parent abec062 commit 6ad3da8
Show file tree
Hide file tree
Showing 428 changed files with 33,807 additions and 11,428 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
/.history
.vscode
.idea
coverage
apiPassword
releasePassword
Expand Down
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ frontendDriverInterfaceSupported.json
.babelrc
.gitattributes
examples/
.prettierignore
.prettierignore
other/
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [0.14.0] - 2021-05-24

### Added:

- Ability to override recipe functions to customize the behavior of feature components.
- Refactors code to:
- Make types simpler.
- Remove components folder from AuthRecipeModule, and puts them in the themes of the respective recipes.
- Uses redirectToAuth everywhere instead of calling redirect manually.
- Adds additional props / config to Session and EmailVerification recipe to make them more isolated
- Passes recipe to feature components directly, as opposed to recipeId
- In session recipe, we remove `setAuth0API` and `getAuth0API`
- Removes `GET_REDIRECTION_URL` from the possible action types for `getRedirectionURL`.
- Changes `redirectToAuth` to take an object and adds `redirectBack` param, which can be used to indicate if the user should be redirected to the current page.
- Removes `getRefreshURLDomain` function from session recipe.
- Moves `SIGN_OUT` even and pre API hook into the Session recipe.
- Change to type of `preAPIHook` function
- Uses supertokens-website version >= 8.0
- Changed `SIGN_IN`, `SIGN_UP` Pre API hook action to `EMAIL_PASSWORD_SIGN_IN`, `EMAIL_PASSWORD_SIGN_UP` or `THIRD_PARTY_SIGN_IN_UP`

### Fixed:

- State update post unmounting when using EmailVerification wrapper.

## [0.13.2] - 2021-06-05

### Added:
Expand Down
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ We're so excited you're interested in helping with SuperTokens! We are happy to
npm run test
```

VSCode User snippets to use with puppeteer: https://gist.github.com/NkxxkN/ae6c0ba190c0a1fda7a4a11f9d59235c

## Run the test application.

1. `npm run start`
Expand Down
Loading

0 comments on commit 6ad3da8

Please sign in to comment.