Secrets React Native Reference Documentation

Secrets

Current Version: 11.6.1

Chilkat.Secrets

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.

Object Creation

// npm install @chilkat/react-native react-native-nitro-modules
// (React Native 0.76+ with the New Architecture; then `pod install` for iOS.  The Chilkat
//  native library is downloaded and verified during the native build -- see the package README.)

import { Chilkat, Secrets } from '@chilkat/react-native'

// Once per app start, before any other Chilkat call:
Chilkat.unlockBundle('Anything for 30-day trial')   // shorthand for new Global().unlockBundle(..)

const secrets = new Secrets()
// ... the native object is released when `secrets` is garbage collected, or now with secrets.dispose()
new Secrets()

Creates the underlying native Chilkat object. Secrets is a Nitro Module HybridObject: use it from the JavaScript thread only (it cannot be passed to a Worklet or another runtime). Every member is synchronous and blocks the JavaScript thread until Chilkat returns; a method that can take a while also exists as a ...Async twin returning a Promise, which runs the same call on a native worker thread so the UI keeps rendering. While such a call is pending, every other call on this object throws, except abort() and assigning onPercentDone / onProgressInfo.

dispose(): void

Releases the native object immediately instead of waiting for garbage collection (useful for a large BinData or an open socket). Calling it more than once is harmless; any other use of the object afterwards throws. An object with a pending ...Async call cannot be disposed until the promise settles.

Errors

A method that can fail throws a plain Error: a method whose only outcome is success or failure returns void and throws on failure; a method producing a string or an object returns it and throws where Chilkat would have returned null. The error's message is "Class.method(...): reason", where the reason is the last informative line of the object's lastErrorText, which holds the full Chilkat log of the failed call. A ...Async twin rejects its promise with the same Error instead of throwing. Properties never throw, and methods that answer a question (has..., is..., ...) return a plain boolean.

try {
  secrets.someMethod(...)
} catch (e) {
  console.log((e as Error).message)   // Secrets.someMethod(...): <reason>
  console.log(secrets.lastErrorText)   // the full Chilkat log of the failed call
}

// The same call without blocking the JavaScript thread:
try {
  await secrets.someMethodAsync(...)
} catch (e) {
  console.log((e as Error).message)   // Secrets.someMethodAsync: <reason>
}

Properties

AutoSplit
// read/write
autoSplit: boolean
Introduced in version 10.1.0

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.

top
Compression
// read/write
compression: boolean
Introduced in version 10.1.0

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

top
DebugLogFilePath
// read/write
debugLogFilePath: string

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
LastErrorHtml
// read-only
readonly lastErrorHtml: string

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
// read-only
readonly lastErrorText: string

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
// read-only
readonly lastErrorXml: string

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
// read/write
lastMethodSuccess: boolean

Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
Location
// read/write
location: string
Introduced in version 10.1.0

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.

top
UncommonOptions
// read/write
uncommonOptions: string
Introduced in version 10.1.0

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

top
VerboseLogging
// read/write
verboseLogging: boolean

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
// read-only
readonly version: string

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

DeleteSecret
deleteSecret(jsonId: JsonObject): void
Introduced in version 10.1.0

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

Returns normally on success; throws an Error on failure.

top
DeleteSecretAsync
deleteSecretAsync(jsonId: JsonObject): Promise<void>
Introduced in version 10.1.0

Asynchronous form of DeleteSecret: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
GetSecretBd
getSecretBd(jsonId: JsonObject, bd: BinData): void
Introduced in version 10.1.0

Fetches a binary secret and returns the content in bd.

Returns normally on success; throws an Error on failure.

top
GetSecretBdAsync
getSecretBdAsync(jsonId: JsonObject, bd: BinData): Promise<void>
Introduced in version 10.1.0

Asynchronous form of GetSecretBd: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
GetSecretJson
getSecretJson(jsonId: JsonObject, jsonOut: JsonObject): void
Introduced in version 10.1.0

Fetches a JSON secret and returns the content in jsonOut.

Returns normally on success; throws an Error on failure.

top
GetSecretJsonAsync
getSecretJsonAsync(jsonId: JsonObject, jsonOut: JsonObject): Promise<void>
Introduced in version 10.1.0

Asynchronous form of GetSecretJson: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
GetSecretSb
getSecretSb(jsonId: JsonObject, sb: StringBuilder): void
Introduced in version 10.1.0

Fetches a string secret and returns the content in sb.

Returns normally on success; throws an Error on failure.

top
GetSecretSbAsync
getSecretSbAsync(jsonId: JsonObject, sb: StringBuilder): Promise<void>
Introduced in version 10.1.0

Asynchronous form of GetSecretSb: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
GetSecretStr
getSecretStr(jsonId: JsonObject): string
Introduced in version 10.1.0

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

Throws an Error on failure (where the description says null is returned, the method throws instead).

top
GetSecretStrAsync
getSecretStrAsync(jsonId: JsonObject): Promise<string>
Introduced in version 10.1.0

Asynchronous form of GetSecretStr: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
ListSecrets
listSecrets(json: JsonObject, jsonOut: JsonObject): void
Introduced in version 10.1.0

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

Returns normally on success; throws an Error on failure.

top
ListSecretsAsync
listSecretsAsync(json: JsonObject, jsonOut: JsonObject): Promise<void>
Introduced in version 10.1.0

Asynchronous form of ListSecrets: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
SecretSpecToJson
secretSpecToJson(secretSpec: string, json: JsonObject): void
Introduced in version 11.5.0

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 normally on success; throws an Error on failure.

More Information and Examples
top
SetBootstrapSecret
setBootstrapSecret(jsonId: JsonObject, secretContent: Secrets): void
Introduced in version 10.1.0

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 normally on success; throws an Error on failure.

top
UpdateSecretBd
updateSecretBd(jsonId: JsonObject, secret: BinData): void
Introduced in version 10.1.0

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 normally on success; throws an Error on failure.

top
UpdateSecretBdAsync
updateSecretBdAsync(jsonId: JsonObject, secret: BinData): Promise<void>
Introduced in version 10.1.0

Asynchronous form of UpdateSecretBd: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
UpdateSecretJson
updateSecretJson(jsonId: JsonObject, secret: JsonObject): void
Introduced in version 10.1.0

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 normally on success; throws an Error on failure.

top
UpdateSecretJsonAsync
updateSecretJsonAsync(jsonId: JsonObject, secret: JsonObject): Promise<void>
Introduced in version 10.1.0

Asynchronous form of UpdateSecretJson: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
UpdateSecretSb
updateSecretSb(jsonId: JsonObject, sb: StringBuilder): void
Introduced in version 10.1.0

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 normally on success; throws an Error on failure.

top
UpdateSecretSbAsync
updateSecretSbAsync(jsonId: JsonObject, sb: StringBuilder): Promise<void>
Introduced in version 10.1.0

Asynchronous form of UpdateSecretSb: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top
UpdateSecretStr
updateSecretStr(jsonId: JsonObject, secret: string): void
Introduced in version 10.1.0

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 normally on success; throws an Error on failure.

top
UpdateSecretStrAsync
updateSecretStrAsync(jsonId: JsonObject, secret: string): Promise<void>
Introduced in version 10.1.0

Asynchronous form of UpdateSecretStr: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.

Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.

Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.

top

Events

While a method runs, Secrets reports progress through two optional callback properties. Assign a function to receive the event, or undefined to stop receiving it. The callbacks are delivered on the JavaScript thread, so they are useful with the ...Async methods: during a synchronous call the JavaScript thread is busy inside Chilkat, and the events can only arrive after it returns.

const secrets = new Secrets()
secrets.onPercentDone = (pct) => setProgress(pct)          // pct is 0..100
secrets.onProgressInfo = (name, value) => console.log(`${name}: ${value}`)
secrets.heartbeatMs = 250   // let abort() take effect within a quarter second

const pending = secrets.someMethodAsync(...)
cancelButton.onPress = () => secrets.abort()   // the promise then rejects
await pending

PercentDone fires when an operation's completion percentage is known; ProgressInfo delivers named progress values (what is reported depends on the class and method). There is no AbortCheck callback: to cancel a pending ...Async call, call abort() on the object. Chilkat notices the request at its next progress check, which happens at least every heartbeatMs milliseconds on the classes that have that property (0, the default, disables the heartbeat, so set it for a responsive cancel), and the promise rejects with Chilkat's abort error. abort() is harmless when nothing is pending.

PercentDone
// callback property; assign undefined to remove
onPercentDone?: (pctDone: number) => void

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the abort output argument to true. This will cause the method to terminate and return a failure status or corresponding failure value.

More Information and Examples

Example:

secrets.onPercentDone = (pct) => {
  // pct ranges from 0 to 100.
  setProgress(pct)   // runs on the JavaScript thread: React state may be updated directly
}
await secrets.someMethodAsync(...)
// To stop an operation from within the callback, call secrets.abort()
top
ProgressInfo
// callback property; assign undefined to remove
onProgressInfo?: (name: string, value: string) => void

This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

More Information and Examples

Example:

secrets.onProgressInfo = (name, value) => console.log(`${name}: ${value}`)
await secrets.someMethodAsync(...)
top