dymokomi/luce-keychain
Secrets in the system's own credential store: the macOS Keychain, the Windows Credential Manager and the Linux Secret Service (libsecret, loaded at run time). Store, load and remove a secret by service and account.
A library written in luce-base. Latest release 0.5.1.
Install#
luc add dymokomi/luce-keychainDocumentation#
luce-keychain
Secrets in the system's own credential store, for luce-base and Luce programs:
| System | Store |
|---|---|
| macOS | the user's Keychain: generic-password items (Security.framework) |
| Windows | the Credential Manager: generic credentials named service/account (advapi32) |
| Linux | the Secret Service through libsecret, loaded at run time with dlopen; nothing is linked |
from luce_keychain import keychain
keychain.store("com.example.mail", "alice@example.com", password)
let password = keychain.load("com.example.mail", "alice@example.com") # fails with not_found when absent
if keychain.contains("com.example.mail", "bob@example.com"): …
keychain.remove("com.example.mail", "alice@example.com") # nothing kept is not an error
A secret is text of at most 2560 bytes (the Windows limit), kept under a service name and an account, each 1–256 bytes without control characters. Storing replaces whatever was kept for the pair. Errors: not_found, unavailable (no reachable store, such as a Linux system without libsecret or a running Secret Service), failed (the store refused) and invalid (bad names or secret).
From Base, load returns an interop.Owned[str]; release it when done.
Test
./test.sh
The tests make a round trip through the real store, under the service com.luciaos.luce-keychain.test, and clean up after themselves. A system with no reachable store says so and checks argument validation only.
License
Dual-licensed under Apache-2.0 or MIT, at your option.
Dependencies#
| Package | Version |
|---|---|
| dymokomi/luce-std | newest |
Versions#
0.5.1
Browse source · pack · commit ea80494ecbb0
SHA-256 ef80628425d4ae4b82be33a4e0eb87b0bdbbbc559d434c59d0cf7dbe690fbee8
macOS: no default keychain is unavailable, not a dialog; dependencies name no version