StoredKey

StoredKey provides access to keys stored in the Calcish keychain.

Keys can be added and edited in Settings ▸ Keys.

StoredKey returns an object that has name and secret properties. The secret property is redacted in the object representation: it is not displayed or stored in the codebook. However, it can be read by the engine normally. The secret property is an object that contains a single string property key, which is the value of the key stored in the keychain. It’s important to note that the secret will be displayed and stored in the codebook if it’s requested directly: StoredKey("MyKey").secret or otherwise exposed in the result or the console by other code.

Syntax

StoredKey(name)

Parameters

Return value

Returns a new StoredKey instance.

StoredKey will throw StoredKeyNotFoundError error if the key doesn’t exist.

Examples

StoredKey("MyAPI")
StoredKey {
  name: MyAPI,
  secret: (redacted)
}
// Assuming "MyKey" exists and is set to "123".
// Do not do this, as the key will be revealed,
// just pass the result to a function that expects it.
StoredKey("MyKey").secret.key
"123"
StoredKey("DoesNotExists")
StoredKeyNotFoundError: key "DoesNotExists" not found