-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
119 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
holo-key-manager-extension/src/routes/webapp-extension/login/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="flex flex-col items-center justify-center"> | ||
<h1 class="mt-4 text-2xl font-bold">Login Page</h1> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,87 @@ | ||
# Holo Key Manager JS Client | ||
|
||
This is a JavaScript client for the Holo Key Manager. | ||
This JavaScript client library facilitates interactions with the Holo Key Manager, streamlining user signup processes and other key management functionalities. For full functionality, ensure the Holo Key Manager browser extension is installed. | ||
|
||
## Install Holo Key Manager | ||
## Prerequisites | ||
|
||
To fully utilize the Holo Key Manager JS Client, you need to install the Holo Key Manager extension for your browser. Here are the links for each browser: | ||
Before using this library, install the Holo Key Manager extension for your browser: | ||
|
||
- [Chrome](https://chrome.google.com/webstore/detail/holo-key-manager/eggfhkdnfdhdpmkfpihjjbnncgmhihce) | ||
- [Edge](https://microsoftedge.microsoft.com/addons/detail/jfecdgefjljjfcflgbhgfkbeofjenceh) | ||
- [Mozilla](https://addons.mozilla.org/en-US/firefox/addon/holo-key-manager/) | ||
- Chrome: [Install from Chrome Web Store](https://chrome.google.com/webstore/detail/holo-key-manager/eggfhkdnfdhdpmkfpihjjbnncgmhihce) | ||
- Edge: [Install from Microsoft Edge Add-ons](https://microsoftedge.microsoft.com/addons/detail/jfecdgefjljjfcflgbhgfkbeofjenceh) | ||
- Mozilla: [Install from Firefox Browser Add-ons](https://addons.mozilla.org/en-US/firefox/addon/holo-key-manager/) | ||
|
||
## Installation and Usage | ||
## Installation | ||
|
||
### Adding the Library | ||
1. Download the `tgz` file provided by the developer. | ||
2. Include the library in your project by adding the following to your `package.json`: | ||
|
||
To add this library as a dependency, download the `tgz` file from the developer. Then, add the following to your `package.json`: | ||
```json | ||
"dependencies": { | ||
"holo-key-manager-js-client": "file:<path_to_downloaded_tgz_file>" | ||
} | ||
``` | ||
|
||
```json | ||
"dependencies": { | ||
"holo-key-manager-js-client": "file:<path_to_your_downloaded_tgz_file>" | ||
} | ||
``` | ||
## Usage | ||
|
||
To use the library, import and initialize the Holo Key Manager JS Client with your application's details. Then, use the `signUp` method to initiate the signup process. | ||
|
||
### Testing | ||
### Basic Setup | ||
|
||
```javascript | ||
import createHoloKeyManager from 'holo-key-manager-js-client'; | ||
|
||
// Create a new instance of the Holo Key Manager | ||
const keyManager = createHoloKeyManager(); | ||
|
||
// Use the openWindow method | ||
keyManager | ||
.openWindow() | ||
.then(() => { | ||
console.log('Window opened successfully'); | ||
}) | ||
.catch((error) => { | ||
console.error('Failed to open window:', error); | ||
}); | ||
const holoKeyManagerConfig = { | ||
happId: 'your-happId', | ||
happName: 'your-happName', | ||
happLogo: 'https://example.com/happLogo.png', | ||
happUiUrl: 'https://example.com/ui', | ||
requireRegistrationCode: true | ||
}; | ||
|
||
const initiateSignUp = async () => { | ||
const { signUp } = createHoloKeyManager(holoKeyManagerConfig); | ||
try { | ||
const response = await signUp(); | ||
handleSignUpResponse(response); | ||
} catch (error) { | ||
handleSignUpError(error); | ||
} | ||
}; | ||
``` | ||
|
||
### Handling Responses | ||
|
||
```javascript | ||
const handleSignUpResponse = (response) => { | ||
switch (response.action) { | ||
case 'NeedsSetup': | ||
// Prompt the user to complete the extension setup, then retry signup. | ||
break; | ||
case 'SignUpStarted': | ||
// Notify the user to follow the extension's instructions, then redirect to login on success. | ||
break; | ||
default: | ||
// Handle other actions or statuses. | ||
break; | ||
} | ||
}; | ||
``` | ||
|
||
### Error Handling | ||
|
||
```javascript | ||
const handleSignUpError = (error) => { | ||
const errorMessage = getErrorMessage(error); | ||
console.error(errorMessage); | ||
}; | ||
|
||
const getErrorMessage = (error) => { | ||
if (error.message.includes('permissions are not granted')) { | ||
return 'Ensure the extension is installed and permissions are granted in Firefox.'; | ||
} else if (error.message.includes('not installed')) { | ||
return 'Install the Holo Key Manager extension in Chrome/Edge to proceed.'; | ||
} else { | ||
return 'An unexpected error occurred. Please try again.'; | ||
} | ||
}; | ||
``` |