chore: Adapt readmes to next branch

This commit is contained in:
FabianLars
2023-04-26 18:01:46 +02:00
parent b1b6c34b9c
commit 59cb08e902
21 changed files with 116 additions and 136 deletions
+10 -22
View File
@@ -20,7 +20,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
[dependencies]
tauri-plugin-authenticator = "0.1"
# or through git
tauri-plugin-authenticator = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
tauri-plugin-authenticator = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "next" }
```
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
@@ -28,11 +28,11 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
```sh
pnpm add https://github.com/tauri-apps/tauri-plugin-authenticator
pnpm add https://github.com/tauri-apps/tauri-plugin-authenticator#next
# or
npm add https://github.com/tauri-apps/tauri-plugin-authenticator
npm add https://github.com/tauri-apps/tauri-plugin-authenticator#next
# or
yarn add https://github.com/tauri-apps/tauri-plugin-authenticator
yarn add https://github.com/tauri-apps/tauri-plugin-authenticator#next
```
## Usage
@@ -53,7 +53,7 @@ fn main() {
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
import { Authenticator } from "tauri-plugin-authenticator-api";
import { Authenticator } from 'tauri-plugin-authenticator-api';
const auth = new Authenticator();
auth.init(); // initialize transports
@@ -63,21 +63,16 @@ const arr = new Uint32Array(32);
window.crypto.getRandomValues(arr);
const b64 = btoa(String.fromCharCode.apply(null, arr));
// web-safe base64
const challenge = b64.replace(/\+/g, "-").replace(/\//g, "_");
const challenge = b64.replace(/\+/g, '-').replace(/\//g, '_');
const domain = "https://tauri.app";
const domain = 'https://tauri.app';
// attempt to register with the security key
const json = await auth.register(challenge, domain);
const registerResult = JSON.parse(json);
// verify te registration was successfull
const r2 = await auth.verifyRegistration(
challenge,
app,
registerResult.registerData,
registerResult.clientData
);
const r2 = await auth.verifyRegistration(challenge, app, registerResult.registerData, registerResult.clientData);
const j2 = JSON.parse(r2);
// sign some data
@@ -85,17 +80,10 @@ const json = await auth.sign(challenge, app, keyHandle);
const signData = JSON.parse(json);
// verify the signature again
const counter = await auth.verifySignature(
challenge,
app,
signData.signData,
clientData,
keyHandle,
pubkey
);
const counter = await auth.verifySignature(challenge, app, signData.signData, clientData, keyHandle, pubkey);
if (counter && counter > 0) {
console.log("SUCCESS!");
console.log('SUCCESS!');
}
```