@exweiv/wix-secret-helpers
v2.1.4
Published
Some basic helper functions for secrets in Wix, works with @wix/secrets SDK module.
Maintainers
Readme
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
elevateAccessin options.
Usage
Basic Example: Retrieve a Secret as a String
import { getSecretValue } from '@exweiv/wix-secret-helpers';
// Returns `string`
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';
// Returns defined `object`
const twitterAPIConfig = /** @type {{appKey: string, appSecret: string, accessToken: string, accessSecret: string}} */ (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
