---
product: Chilkat
product_version: 11.7.0
language: js
language_label: JavaScript
class: Secrets
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/jsSecretsRef.html
---
# Chilkat Secrets — JavaScript — v11.7.0

> Chilkat 11.7.0 · language=js · class=Secrets
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Secrets.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/guide.md`.

## Purpose

**Manage application secrets through one consistent API.**

`Chilkat.Secrets` provides a unified interface for storing, retrieving, listing, and deleting secrets across local, cloud-based, and in-memory secret stores. It supports string, binary, and JSON secrets, making it useful for passwords, API keys, OAuth credentials, tokens, unlock codes, certificates, and private configuration data.

**Local secure storage**

- Windows Credential Manager
- Apple Keychain

**Cloud secret managers**

- AWS Secrets Manager
- Azure Key Vault
- IBM Cloud Secrets Manager
- Oracle Cloud Secrets
- Doppler Secrets

**Temporary secrets**

Use in-memory secrets when values should exist only for the lifetime of the running process.

**Flexible content types**

Store and retrieve secrets as strings, binary data, or structured JSON.

**Note:** Cloud-based secret managers often require local bootstrap credentials. These can be stored securely in the Windows Credential Manager or Apple Keychain and then used to authenticate to the cloud secret manager.

Start with the [Conceptual Overview](https://www.chilkatsoft.com/chilkat_secrets_api.asp) and [Components of a Secret Name](https://www.chilkatsoft.com/components_of_a_secret_name.asp). For an extended overview, see the [Secrets Class Overview](https://www.chilkatsoft.com/secrets_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

Note: This is intended for running within a [Chilkat.Js embedded JavaScript engine](https://www.chilkatsoft.com/chilkat_javascript_engine.asp).

```
var obj = new CkSecrets();
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in JavaScript.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `DebugLogFilePath` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `LastErrorHtml` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `LastErrorText` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `LastErrorXml` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `LastMethodSuccess` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `VerboseLogging` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `Version` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AutoSplit` | property, read/write | `AutoSplit` |
| `Compression` | property, read/write | `Compression` |
| `Location` | property, read/write | `Location` |
| `UncommonOptions` | property, read/write | `UncommonOptions` |
| `DeleteSecret` | method | `var success = DeleteSecret(jsonId);` |
| `GetSecretBd` | method | `var success = GetSecretBd(jsonId, bd);` |
| `GetSecretJson` | method | `var success = GetSecretJson(jsonId, jsonOut);` |
| `GetSecretSb` | method | `var success = GetSecretSb(jsonId, sb);` |
| `GetSecretStr` | method | `var strVal = GetSecretStr(jsonId);` |
| `ListSecrets` | method | `var success = ListSecrets(json, jsonOut);` |
| `SecretSpecToJson` | method | `var success = SecretSpecToJson(secretSpec, json);` |
| `SetBootstrapSecret` | method | `var success = SetBootstrapSecret(jsonId, secretContent);` |
| `UpdateSecretBd` | method | `var success = UpdateSecretBd(jsonId, secret);` |
| `UpdateSecretJson` | method | `var success = UpdateSecretJson(jsonId, secret);` |
| `UpdateSecretSb` | method | `var success = UpdateSecretSb(jsonId, sb);` |
| `UpdateSecretStr` | method | `var success = UpdateSecretStr(jsonId, secret);` |

## Properties

### Secrets.AutoSplit

`Chilkat 11.7.0 · js · Secrets · AutoSplit · property · read/write · since 10.1.0`

```javascript
AutoSplit
```

· `boolean`

The AutoSplit property is specific to `local_manager` secrets on Windows. The Windows Credentials Manager supports a maximum of 2560 bytes per secret. If a secret exceeds this size, it will be automatically compressed and split when created or updated, and automatically recomposed when retrieved.

A secret can be split into a maximum of 10 parts.

The default value is `true`.

### Secrets.Compression

`Chilkat 11.7.0 · js · Secrets · Compression · property · read/write · since 10.1.0`

```javascript
Compression
```

· `boolean`

If set to `true`, then the contents of the secret will be stored compressed. The default value of this property is `false`.

### Secrets.Location

`Chilkat 11.7.0 · js · Secrets · Location · property · read/write · since 10.1.0`

```javascript
Location
```

· `string`

The location of the secrets. Possible values are:

- `local_manager` - On Windows this is the Credentials Manager. On MacOS and iOS it is the Keychain. This is not yet an option on Linux or Android.
- `aws_secrets_manager` - AWS Secrets Manager
- `azure_key_vault` - Azure Key Vault
- `ibm_cloud` - IBM Cloud Secrets Manager
- `oracle_cloud` - Oracle Cloud Secrets
- `doppler` - Doppler Secrets
- `memory` - In-Memory Secrets

The default location is the `local_manager`. On Linux and Android, `local_manager` will behave the same as `memory`.

### Secrets.UncommonOptions

`Chilkat 11.7.0 · js · Secrets · UncommonOptions · property · read/write · since 10.1.0`

```javascript
UncommonOptions
```

· `string`

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.

## Methods

### Secrets.DeleteSecret

`Chilkat 11.7.0 · js · Secrets · DeleteSecret · method · since 10.1.0`

```javascript
var success = DeleteSecret(jsonId);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`

Deletes a secret. Cloud secrets managers will typically disable the secret and schedule the secret for deletion after some number of days.

Returns true for success, false for failure.

### Secrets.GetSecretBd

`Chilkat 11.7.0 · js · Secrets · GetSecretBd · method · since 10.1.0`

```javascript
var success = GetSecretBd(jsonId, bd);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· bd: `CkBinData`

Fetches a binary secret and returns the content in `bd`.

Returns true for success, false for failure.

### Secrets.GetSecretJson

`Chilkat 11.7.0 · js · Secrets · GetSecretJson · method · since 10.1.0`

```javascript
var success = GetSecretJson(jsonId, jsonOut);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· jsonOut: `CkJsonObject`

Fetches a JSON secret and returns the content in `jsonOut`.

Returns true for success, false for failure.

### Secrets.GetSecretSb

`Chilkat 11.7.0 · js · Secrets · GetSecretSb · method · since 10.1.0`

```javascript
var success = GetSecretSb(jsonId, sb);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· sb: `CkStringBuilder`

Fetches a string secret and returns the content in `sb`.

Returns true for success, false for failure.

### Secrets.GetSecretStr

`Chilkat 11.7.0 · js · Secrets · GetSecretStr · method · since 10.1.0`

```javascript
var strVal = GetSecretStr(jsonId);
```

· return: `string`  
· jsonId: `CkJsonObject`

Fetches a string secret and returns the content of the secret.

Returns `null` on failure

### Secrets.ListSecrets

`Chilkat 11.7.0 · js · Secrets · ListSecrets · method · since 10.1.0`

```javascript
var success = ListSecrets(json, jsonOut);
```

· return: `boolean`; `true` for success, `false` for failure  
· json: `CkJsonObject`  
· jsonOut: `CkJsonObject`

Lists secrets matching the wildcarded or exact values passed in `json`. The results of the query are returned in `jsonOut`.

Returns true for success, false for failure.

### Secrets.SecretSpecToJson

`Chilkat 11.7.0 · js · Secrets · SecretSpecToJson · method · since 11.5.0`

```javascript
var success = SecretSpecToJson(secretSpec, json);
```

· return: `boolean`; `true` for success, `false` for failure  
· secretSpec: `string`  
· json: `CkJsonObject`

Converts a secret specification string (`secretSpec`) to JSON. A secret specification string is formatted as "!!part1\|part2\|part3\|part4" where parts 3 and 4 are optional. `json` is the output argument.

Returns true for success, false for failure.

### Secrets.SetBootstrapSecret

`Chilkat 11.7.0 · js · Secrets · SetBootstrapSecret · method · since 10.1.0`

```javascript
var success = SetBootstrapSecret(jsonId, secretContent);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· secretContent: `CkSecrets`

Accessing a cloud-based secrets manager requires authentication credentials, which cannot be stored in the manager itself. Instead, they must be securely stored locally.

One solution is to store the authentication credentials as a secret in the Windows Credentials Manager or Apple Keychain. These credentials serve as the `bootstrap secret` for authenticating with the cloud-based secrets manager.

`jsonId` contains the name of the bootstrap secret. `secretContent` contains the bootstrap's secret content.

Returns true for success, false for failure.

### Secrets.UpdateSecretBd

`Chilkat 11.7.0 · js · Secrets · UpdateSecretBd · method · since 10.1.0`

```javascript
var success = UpdateSecretBd(jsonId, secret);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· secret: `CkBinData`

Creates a binary secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the binary content of the secret in `secret`.

Returns true for success, false for failure.

### Secrets.UpdateSecretJson

`Chilkat 11.7.0 · js · Secrets · UpdateSecretJson · method · since 10.1.0`

```javascript
var success = UpdateSecretJson(jsonId, secret);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· secret: `CkJsonObject`

Creates a JSON secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the JSON content of the secret in `secret`.

Returns true for success, false for failure.

### Secrets.UpdateSecretSb

`Chilkat 11.7.0 · js · Secrets · UpdateSecretSb · method · since 10.1.0`

```javascript
var success = UpdateSecretSb(jsonId, sb);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· sb: `CkStringBuilder`

Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the string content of the secret in `sb`.

Returns true for success, false for failure.

### Secrets.UpdateSecretStr

`Chilkat 11.7.0 · js · Secrets · UpdateSecretStr · method · since 10.1.0`

```javascript
var success = UpdateSecretStr(jsonId, secret);
```

· return: `boolean`; `true` for success, `false` for failure  
· jsonId: `CkJsonObject`  
· secret: `string`

Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the string content of the secret in `secret`.

Note: Starting in Chilkat **v11.3.0**, if the `service` = `"Chilkat"` and the `username` = `"unlock_code"`, then the secret (which is the Chilkat unlock code) can be stored and retrieved without Chilkat being unlocked. This allows for the Chilkat unlock code itself to be persisted to a secrets manager.

Returns true for success, false for failure.

## Events and callbacks

This binding has no event callbacks.

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/BinData.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/JsonObject.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/StringBuilder.md)

