componentized

interface componentized:secrets/store@0.1.0

since 0.1.0

A store of secrets, sensitive values looked up by key, e.g. passwords, tokens and keys.

Types

variant secret

The value of a secret.

  • string: string

    A secret that is text.

  • bytes: list<u8>

    A secret that is binary.

    Encoded text is discouraged, favor a string.

variant error-code

An error getting a secret.

  • not-initialized

    The store is not initialized, call init() first.

  • not-found

    The 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

async functioninit: async func() -> result<_, 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.

functionget: func(key: string) -> result<secret, 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.

WIT

/// A store of secrets, sensitive values looked up by key, e.g. passwords, tokens and keys.
@since(version = 0.1.0)
interface store {
  /// The value of a secret.
  variant secret {
    /// A secret that is text.
    %string(string),
    /// A secret that is binary.
    ///
    /// Encoded text is discouraged, favor a string.
    bytes(list<u8>),
  }

  /// An error getting a secret.
  variant error-code {
    /// The store is not initialized, call `init()` first.
    not-initialized,
    /// The store has no secret for the key.
    not-found,
    /// 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.
    other(option<string>),
  }

  /// Initialize the store.
  ///
  /// The store must be initialized before use. Secrets are immutable after
  /// initialization completes. Subsequent calls to initialize are no-ops.
  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.
  get: func(key: string) -> result<secret, error-code>;
}