@purista/infisical-secret-store v2.0.5
PURISTA API / @purista/infisical-secret-store / InfisicalSecretStore
Class: InfisicalSecretStore
Defined in: infisical-secret-store/src/InfisicalSecretStore.impl.ts:39
A secret store for using Infisical 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
* ```typescript
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
## Extends
- [`SecretStoreBaseClass`](../../core/classes/SecretStoreBaseClass.md)\<[`InfisicalSecretConfig`](../type-aliases/InfisicalSecretConfig.md)\>
## Constructors
### new InfisicalSecretStore()
> **new InfisicalSecretStore**(`config`): [`InfisicalSecretStore`](InfisicalSecretStore.md)
Defined in: [infisical-secret-store/src/InfisicalSecretStore.impl.ts:42](https://github.com/puristajs/purista/blob/master/packages/infisical-secret-store/src/InfisicalSecretStore.impl.ts#L42)
#### Parameters
##### config
###### baseUrl
`string`
the 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.password
string
Basic-Auth password
basicAuth.username
string
Basic-Auth username
bearerToken
string
Auth-Bearer token
cacheTtl?
number
Cache 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?
number
set global timeout for requests in ms
Default
30000
enableCache?
boolean
Enable cache
enableGet?
boolean
Enable generally get method
enableOpentelemetry?
boolean
enable Opentelemetry tracing. The client will be handled as own resource.
enableRemove?
boolean
Enable generally remove method
enableSet?
boolean
Enable generally set method
isKeepAlive?
boolean
If set to false, the HTTP client will not reuse the same connection for multiple requests. Default is true.
logger?
A logger instance
logLevel?
A log level for new logger if logger is not set
name?
string
Name of the client
spanProcessor?
SpanProcessor
Opentelemetry span processor
traceId?
string
Custom trace Id
Returns
Overrides
SecretStoreBaseClass
.constructor
Properties
cache
cache:
SecretStoreCacheMap
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:20
Inherited from
client
client:
InfisicalClient
Defined in: infisical-secret-store/src/InfisicalSecretStore.impl.ts:40
config
config:
object
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:18
baseUrl
baseUrl:
string
the base url to be used
Example
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?
optional
basicAuth:object
Basic-Auth information
basicAuth.password
basicAuth.password:
string
Basic-Auth password
basicAuth.username
basicAuth.username:
string
Basic-Auth username
bearerToken
bearerToken:
string
Auth-Bearer token
cacheTtl?
optional
cacheTtl:number
Cache time to live in ms
defaultHeaders?
optional
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?
optional
defaultTimeout:number
set global timeout for requests in ms
Default
30000
enableCache?
optional
enableCache:boolean
Enable cache
enableGet?
optional
enableGet:boolean
Enable generally get method
enableOpentelemetry?
optional
enableOpentelemetry:boolean
enable Opentelemetry tracing. The client will be handled as own resource.
enableRemove?
optional
enableRemove:boolean
Enable generally remove method
enableSet?
optional
enableSet:boolean
Enable generally set method
isKeepAlive?
optional
isKeepAlive:boolean
If set to false, the HTTP client will not reuse the same connection for multiple requests. Default is true.
logger?
optional
logger:Logger
A logger instance
logLevel?
optional
logLevel:LogLevelName
A log level for new logger if logger is not set
name?
optional
name:string
Name of the client
spanProcessor?
optional
spanProcessor:SpanProcessor
Opentelemetry span processor
traceId?
optional
traceId:string
Custom trace Id
Inherited from
logger
logger:
Logger
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:17
Inherited from
name
name:
string
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:19
Inherited from
Methods
destroy()
destroy():
Promise
<void
>
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:28
Returns
Promise
<void
>
Inherited from
getSecret()
getSecret<
SecretNames
>(...secretNames
):Promise
<ObjectWithKeysFromStringArray
<SecretNames
,undefined
|string
>>
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:23
Type Parameters
• SecretNames extends string
[]
Parameters
secretNames
...SecretNames
Returns
Promise
<ObjectWithKeysFromStringArray
<SecretNames
, undefined
| string
>>
Inherited from
SecretStoreBaseClass
.getSecret
getSecretImpl()
protected
getSecretImpl<SecretNames
>(...secretNames
):Promise
<ObjectWithKeysFromStringArray
<SecretNames
,undefined
|string
>>
Defined in: infisical-secret-store/src/InfisicalSecretStore.impl.ts:51
Type Parameters
• SecretNames extends string
[]
Parameters
secretNames
...SecretNames
Returns
Promise
<ObjectWithKeysFromStringArray
<SecretNames
, undefined
| string
>>
Overrides
SecretStoreBaseClass
.getSecretImpl
removeSecret()
removeSecret(
secretName
):Promise
<void
>
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:25
Parameters
secretName
string
Returns
Promise
<void
>
Inherited from
SecretStoreBaseClass
.removeSecret
removeSecretImpl()
protected
removeSecretImpl(secretName
):Promise
<void
>
Defined in: infisical-secret-store/src/InfisicalSecretStore.impl.ts:67
Parameters
secretName
string
Returns
Promise
<void
>
Overrides
SecretStoreBaseClass
.removeSecretImpl
setSecret()
setSecret(
secretName
,secretValue
):Promise
<void
>
Defined in: core/dist/commonjs/core/SecretStore/SecretStoreBaseClass.impl.d.ts:27
Parameters
secretName
string
secretValue
string
Returns
Promise
<void
>
Inherited from
SecretStoreBaseClass
.setSecret
setSecretImpl()
protected
setSecretImpl(secretName
,secretValue
):Promise
<void
>
Defined in: infisical-secret-store/src/InfisicalSecretStore.impl.ts:77
Parameters
secretName
string
secretValue
string
Returns
Promise
<void
>