A store of secrets, sensitive values looked up by key, e.g. passwords, tokens and keys.
Types
use variant secretsince 0.1.0
from componentized:secrets/types@0.1.1-dev
The value of a secret.
string:stringA secret that is text.
bytes:list<u8>A secret that is binary.
Encoded text is discouraged, favor a string.
use variant error-codesince 0.1.0
from componentized:secrets/types@0.1.1-dev
An error getting a secret.
not-initializedThe store is not initialized, call
init()first.not-foundThe store has no secret for the key.
other:option<string>Any other error, e.g. the store is unavailable or access to the secret is denied, with a message describing the error, when there is one.
Functions
init: async func() -> result<_, error-code>since 0.1.0
Initialize the store.
The store must be initialized before use. Secrets are immutable after initialization completes. Subsequent calls to initialize are no-ops.
get: func(key: string) -> result<secret, error-code>since 0.1.0
Gets the secret for the key.
Returns error-code::not-found when the store has no secret for the
key. Returns error-code::not-initialized when the store is not
initialized, call init() first.
WIT
/// A store of secrets, sensitive values looked up by key, e.g. passwords, tokens and keys.
@since(version = 0.1.0)
interface store {
@since(version = 0.1.0)
use types.{secret, error-code};
/// Initialize the store.
///
/// The store must be initialized before use. Secrets are immutable after
/// initialization completes. Subsequent calls to initialize are no-ops.
@since(version = 0.1.0)
init: async func() -> result<_, error-code>;
/// Gets the secret for the key.
///
/// Returns `error-code::not-found` when the store has no secret for the
/// key. Returns `error-code::not-initialized` when the store is not
/// initialized, call `init()` first.
@since(version = 0.1.0)
get: func(key: string) -> result<secret, error-code>;
}