mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
minimal readme
This commit is contained in:
@@ -6,6 +6,7 @@ authors = { workspace = true }
|
||||
license = { workspace = true }
|
||||
repository = { workspace = true }
|
||||
links = "tauri-plugin-secure-storage"
|
||||
description = "Store data in the platforms' keychains."
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustc-args = ["--cfg", "docsrs"]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||

|
||||
|
||||
<!-- description -->
|
||||
Store data in the platforms' keychains.
|
||||
|
||||
<!-- TODO: List the keychains we use -->
|
||||
|
||||
| Platform | Supported |
|
||||
| -------- | --------- |
|
||||
@@ -12,6 +14,8 @@
|
||||
|
||||
## Install
|
||||
|
||||
<!-- TODO: This will change with keyring v4 -->
|
||||
|
||||
_This plugin requires a Rust version of at least **1.77.2**_
|
||||
|
||||
There are three general methods of installation that we can recommend.
|
||||
@@ -33,23 +37,12 @@ tauri-plugin-secure-storage = { git = "https://github.com/tauri-apps/plugins-wor
|
||||
|
||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||
|
||||
> 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.
|
||||
|
||||
<!-- Add the branch for installations using git! -->
|
||||
|
||||
```sh
|
||||
pnpm add @tauri-apps/plugin-secure-storage
|
||||
# or
|
||||
npm add @tauri-apps/plugin-secure-storage
|
||||
# or
|
||||
yarn add @tauri-apps/plugin-secure-storage
|
||||
|
||||
# alternatively with Git:
|
||||
pnpm add https://github.com/tauri-apps/tauri-plugin-secure-storage#v2
|
||||
# or
|
||||
npm add https://github.com/tauri-apps/tauri-plugin-secure-storage#v2
|
||||
# or
|
||||
yarn add https://github.com/tauri-apps/tauri-plugin-secure-storage#v2
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -69,8 +62,24 @@ fn main() {
|
||||
|
||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
import { setString, getString } from '@tauri-apps/plugin-secure-storage'
|
||||
|
||||
await setString('some-key', 'some-secret-value')
|
||||
|
||||
const storedData = getString('some-key')
|
||||
|
||||
console.log(storedData) // Should return `some-secret-value`
|
||||
```
|
||||
|
||||
Similarily, the plugin also has Rust APIs:
|
||||
|
||||
```rs
|
||||
use tauri_plugin_secure_storage::SecureStorageExt;
|
||||
|
||||
app.secure_storage().set_string("some-key", "some-secret-value");
|
||||
|
||||
let stored_data = app.secure_storage().get_string("some-key");
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -7,20 +7,20 @@ import { invoke } from '@tauri-apps/api/core'
|
||||
// TODO: functions to delete entries?
|
||||
|
||||
export async function setString(key: string, value: string) {
|
||||
return invoke('plugin:secure-storage|set_string', { key, value })
|
||||
return await invoke('plugin:secure-storage|set_string', { key, value })
|
||||
}
|
||||
|
||||
export async function getString(key: string): Promise<string> {
|
||||
return invoke('plugin:secure-storage|get_string', { key })
|
||||
return await invoke('plugin:secure-storage|get_string', { key })
|
||||
}
|
||||
|
||||
export async function setBinary(
|
||||
key: string,
|
||||
value: number[] | Uint8Array | ArrayBuffer
|
||||
) {
|
||||
return invoke('plugin:secure-storage|set_binary', { key, value })
|
||||
return await invoke('plugin:secure-storage|set_binary', { key, value })
|
||||
}
|
||||
|
||||
export async function getBinary(key: string): Promise<number[]> {
|
||||
return invoke('plugin:secure-storage|set_string', { key })
|
||||
return await invoke('plugin:secure-storage|set_string', { key })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user