Skip to main content

Class: InfisicalSecretStore


PURISTA API / Modules / @purista/infisical-secret-store / InfisicalSecretStore

Class: InfisicalSecretStore

@purista/infisical-secret-store.InfisicalSecretStore

A secret store for using Infisicalopen in new window as storage.

For performance reasons, and to reduce costs, the secret values are cached in memory after first fetch.

You can disable the whole caching via config by setting enableCache to false.
If the cache is enabled, you can set the ttl for cached secret values via config cacheTtl (in ms).

This will return the cached secret if available and if ttl is not exceeded.
If a secret value exceeds the ttl, it does not automatically get removed from cache.
It will be removed/overwritten on next get request.

Example

const config = {
  baseUrl: 'http://example.com'
}

const store = new InfisicalSecretStore( config )

await store.setSecret('mySecret', 'value')

let value = await store.getSecret('mySecret')
console.log(value) // outputs: { mySecret: 'value' }

await store.removeSecret('mySecret')

value = await store.getSecret('mySecret')
console.log(value) // outputs: undefined

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new InfisicalSecretStore(config): InfisicalSecretStore

Parameters

NameTypeDescription
configObject-
config.baseUrlstringthe base url to be used Example typescript const config = { baseUrl: 'http://localhost/api` } // each request will be below http://localhost/api // get('v1/orders') will call http://localhost/api/v1/orders
config.basicAuth?ObjectBasic-Auth information
config.basicAuth.passwordstringBasic-Auth password
config.basicAuth.usernamestringBasic-Auth username
config.bearerTokenstringAuth-Bearer token
config.cacheTtl?numberCache time to live in ms
config.defaultHeaders?Record<string, string>Add your default headers here These headers will be part of every request. They can be overwritten per request option
config.defaultTimeout?numberset global timeout for requests in ms Default ts 30000
config.enableCache?booleanEnable cache
config.enableGet?booleanEnable generally get method
config.enableOpentelemetry?booleanenable Opentelemetry tracing. The client will be handled as own ressource.
config.enableRemove?booleanEnable generally remove method
config.enableSet?booleanEnable generally set method
config.isKeepAlive?booleanIf set to false, the HTTP client will not reuse the same connection for multiple requests. Default is true.
config.logLevel?LogLevelNameA log level for new logger if logger is not set
config.logger?LoggerA logger instance
config.name?stringName of the client
config.spanProcessor?SpanProcessorOpentelemetry span processor

Returns

InfisicalSecretStore

Overrides

SecretStoreBaseClass&lt;InfisicalSecretConfig&gt;.constructor

Defined in

infisical-secret-store/src/InfisicalSecretStore.impl.ts:40open in new window

Properties

cache

cache: SecretStoreCacheMap

Inherited from

SecretStoreBaseClass.cache

Defined in

core/lib/types/core/SecretStore/SecretStoreBaseClass.impl.d.ts:12


client

client: InfisicalClient

Defined in

infisical-secret-store/src/InfisicalSecretStore.impl.ts:38open in new window


config

config: Object

Type declaration

NameTypeDescription
baseUrlstringthe base url to be used Example typescript const config = { baseUrl: 'http://localhost/api` } // each request will be below http://localhost/api // get('v1/orders') will call http://localhost/api/v1/orders
basicAuth?{ password: string ; username: string }Basic-Auth information
basicAuth.passwordstringBasic-Auth password
basicAuth.usernamestringBasic-Auth username
bearerTokenstringAuth-Bearer token
cacheTtl?numberCache time to live in ms
defaultHeaders?Record<string, string>Add your default headers here These headers will be part of every request. They can be overwritten per request option
defaultTimeout?numberset global timeout for requests in ms Default ts 30000
enableCache?booleanEnable cache
enableGet?booleanEnable generally get method
enableOpentelemetry?booleanenable Opentelemetry tracing. The client will be handled as own ressource.
enableRemove?booleanEnable generally remove method
enableSet?booleanEnable generally set method
isKeepAlive?booleanIf set to false, the HTTP client will not reuse the same connection for multiple requests. Default is true.
logLevel?LogLevelNameA log level for new logger if logger is not set
logger?LoggerA logger instance
name?stringName of the client
spanProcessor?SpanProcessorOpentelemetry span processor

Inherited from

SecretStoreBaseClass.config

Defined in

core/lib/types/core/SecretStore/SecretStoreBaseClass.impl.d.ts:10


logger

logger: Logger

Inherited from

SecretStoreBaseClass.logger

Defined in

core/lib/types/core/SecretStore/SecretStoreBaseClass.impl.d.ts:9


name

name: string

Inherited from

SecretStoreBaseClass.name

Defined in

core/lib/types/core/SecretStore/SecretStoreBaseClass.impl.d.ts:11

Methods

destroy

destroy(): Promise<void>

Returns

Promise<void>

Inherited from

SecretStoreBaseClass.destroy

Defined in

core/lib/types/core/SecretStore/SecretStoreBaseClass.impl.d.ts:17


getSecret

getSecret(...secretNames): Promise<Record<string, undefined | string>>

Parameters

NameType
...secretNamesstring[]

Returns

Promise<Record<string, undefined | string>>

Overrides

SecretStoreBaseClass.getSecret

Defined in

infisical-secret-store/src/InfisicalSecretStore.impl.ts:49open in new window


removeSecret

removeSecret(secretName): Promise<void>

Parameters

NameType
secretNamestring

Returns

Promise<void>

Overrides

SecretStoreBaseClass.removeSecret

Defined in

infisical-secret-store/src/InfisicalSecretStore.impl.ts:80open in new window


setSecret

setSecret(secretName, secretValue): Promise<void>

Parameters

NameType
secretNamestring
secretValuestring

Returns

Promise<void>

Overrides

SecretStoreBaseClass.setSecret

Defined in

infisical-secret-store/src/InfisicalSecretStore.impl.ts:96open in new window

Last update:
Contributors: Sebastian Wessel