UNPKG

test-mitid-integrator

Version:

Utility for handling communication with MitID broker via client-side JavaScript

86 lines (56 loc) 3.51 kB
# MitIDIntegrator A TypeScript class that simplifies authentication processes by managing popup window interactions and message handling. ## Key Concept - Simplifies integration with authentication systems by handling popup window orchestration for user login and message reception. - Automatically captures authentication codes upon receiving a success message. ## Features - **Popup Window Management**: Easily open and close popup windows with specified URLs and configurations for a seamless user experience. - **Message Listening**: Continuously monitors messages from popup windows, intelligently processing them based on their source and content. - **Authentication Code Handling**: Safely captures authentication codes from successful logins and securely passes them to designated callback functions when instructed to close the popup. ## Getting Started ### Prerequisites - **Environment variables**: Ensure the client possesses the requisite environment variables for the MitID broker. - **Callback function**: Have a callback function in place to manage the authentication code. - **Window Instance**: Have a window instance available for data consumption through the message event. ## Installation ```bash npm install my-mitid-broker ``` ### Usage ```typescript // Initialize MitIDIntegrator const env = { BROKER_DOMAIN: "https://mitid-broker.com", BROKER_CLIENTID: "client-id", REDIRECT_URI: "https://client.com/callback", }; const integrator = new MitIDIntegrator(); // Open popup window for login integrator.openPopup("https://example.com/login", (authCode) => { console.log("Received authentication code:", authCode); }); ``` ## Built With - [TypeScript](https://www.typescriptlang.org/): Used for static typing and class-based object-oriented programming. - [Node.js](https://nodejs.org/): JavaScript runtime built on Chrome's V8 JavaScript engine. - [npm](https://www.npmjs.com/): Package manager for the JavaScript programming language. ## Contributing We welcome contributions from everyone. Before you start, please read our [Code of Conduct](LINK_TO_CODE_OF_CONDUCT). We take it very seriously, and expect that you will as well. ### How to Contribute 1. Fork the repository on GitHub. 2. Make your changes in a new git branch on your fork: `git checkout -b my-branch-name` 3. Commit your changes: `git commit -am 'Add some feature'` 4. Push your branch to GitHub: `git push origin my-branch-name` 5. Open a pull request against the main branch on the original GitHub repository. For more detailed instructions, refer to the [GitHub pull request documentation](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests). Please note that this project is released with a [Contributor Code of Conduct](LINK_TO_CODE_OF_CONDUCT). By participating in this project you agree to abide by its terms. ## Versioning We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/repository/tags). - **MAJOR version** when you make incompatible API changes, - **MINOR version** when you add functionality in a backwards-compatible manner, and - **PATCH version** when you make backwards-compatible bug fixes. For more information on SemVer, please visit [semver.org](http://semver.org/). ## Authors - [jobelles](https://github.com/jobelless) ## License MIT License