pub struct CredentialStore { /* private fields */ }Expand description
Encrypted credential storage.
Stores API keys and other credentials encrypted with AES-256-GCM. Credentials are stored on disk with restrictive permissions.
// Create with 32-byte hex encryption key
const store = new CredentialStore(
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
'/path/to/credentials'
);
// Store a credential
const key = new NodeApiKey('sk-secret');
await store.store('anthropic', key);
// Load it back
const loaded = await store.load('anthropic');Implementations§
Source§impl CredentialStore
impl CredentialStore
pub fn into_reference( val: CredentialStore, env: Env, ) -> Result<Reference<CredentialStore>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<CredentialStore>>
Source§impl CredentialStore
impl CredentialStore
Sourcepub fn new(encryption_key_hex: String, store_path: String) -> Result<Self>
pub fn new(encryption_key_hex: String, store_path: String) -> Result<Self>
Create a new credential store.
§Arguments
encryption_key_hex- 32-byte encryption key as hex string (64 characters)store_path- Directory to store encrypted credentials
§Example
// Generate a key: require('crypto').randomBytes(32).toString('hex')
const store = new CredentialStore(keyHex, '/path/to/creds');Sourcepub async fn store(&self, name: String, api_key: &NodeApiKey) -> Result<()>
pub async fn store(&self, name: String, api_key: &NodeApiKey) -> Result<()>
Store an encrypted credential.
The credential is encrypted with AES-256-GCM and written to disk with restrictive permissions (0600 on Unix).
Sourcepub async fn load(&self, name: String) -> Result<NodeApiKey>
pub async fn load(&self, name: String) -> Result<NodeApiKey>
Load and decrypt a credential.
Returns the decrypted API key wrapped in NodeApiKey for safety.
Trait Implementations§
Source§impl FromNapiMutRef for CredentialStore
impl FromNapiMutRef for CredentialStore
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for CredentialStore
impl FromNapiRef for CredentialStore
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &CredentialStore
impl FromNapiValue for &CredentialStore
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut CredentialStore
impl FromNapiValue for &mut CredentialStore
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ObjectFinalize for CredentialStore
impl ObjectFinalize for CredentialStore
Source§impl ToNapiValue for CredentialStore
impl ToNapiValue for CredentialStore
Source§unsafe fn to_napi_value(
env: napi_env,
val: CredentialStore,
) -> Result<napi_value>
unsafe fn to_napi_value( env: napi_env, val: CredentialStore, ) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &CredentialStore
impl TypeName for &CredentialStore
Source§impl TypeName for &mut CredentialStore
impl TypeName for &mut CredentialStore
Source§impl TypeName for CredentialStore
impl TypeName for CredentialStore
Source§impl ValidateNapiValue for &CredentialStore
impl ValidateNapiValue for &CredentialStore
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut CredentialStore
impl ValidateNapiValue for &mut CredentialStore
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for CredentialStore
impl !RefUnwindSafe for CredentialStore
impl Send for CredentialStore
impl Sync for CredentialStore
impl Unpin for CredentialStore
impl !UnwindSafe for CredentialStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more