This library provides a convenient helper for securely retrieving secrets from Wix Secrets Manager, with built-in memory caching and optional JSON parsing.
Note: this library uses @wix/essentials SDK to grant access to secrets for any client. This is usually fine but in some cases you may not want it, in these cases disable elevateAccess in options.
Usage
Basic Example: Retrieve a Secret as a String
import { getSecretValue } from '@exweiv/wix-secret-helpers';
const weatherAPIKey = await getSecretValue({ secretName: "WeatherAPIKey" });
const client = new WeatherClient(weatherAPIKey);
Advanced Example: Retrieve and Parse a JSON Secret
import { getSecretValue } from '@exweiv/wix-secret-helpers';
const twitterAPIConfig = (await getSecretValue({ secretName: "TwitterJSON", parseJSON: true }));
const client = new TwitterAPI(twitterAPIConfig);
Features:
- Memory caching (enabled by default, but can be disabled)
- Optional JSON parsing for secrets stored as JSON
Kolay Gelsin đź’ś
