Skip to content

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

Class: InfisicalClient

@purista/infisical-secret-store.InfisicalClient

The internal http client to connect to the Infisical server.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new InfisicalClient(conf): InfisicalClient

Parameters

NameTypeDescription
confObject-
conf.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
conf.basicAuth?ObjectBasic-Auth information
conf.basicAuth.passwordstringBasic-Auth password
conf.basicAuth.usernamestringBasic-Auth username
conf.bearerTokenstringAuth-Bearer token
conf.defaultHeaders?Record<string, string>Add your default headers here These headers will be part of every request. They can be overwritten per request option
conf.defaultTimeout?numberset global timeout for requests in ms Default ts 30000
conf.enableOpentelemetry?booleanenable Opentelemetry tracing. The client will be handled as own ressource.
conf.isKeepAlive?booleanIf set to false, the HTTP client will not reuse the same connection for multiple requests. Default is true.
conf.logLevel?LogLevelNamethe loglevel if no logger instance is given
conf.logger?LoggerA logger instance
conf.name?stringName of the client
conf.spanProcessor?SpanProcessorOpentelemetry span processor
conf.traceId?stringCustom trace Id

Returns

InfisicalClient

Overrides

HttpClient.constructor

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:16

Properties

auth

Protected auth: AuthCredentials

Inherited from

HttpClient.auth

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:27


baseUrl

baseUrl: URL

Inherited from

HttpClient.baseUrl

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:24


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
bearerToken?stringAuth-Bearer token
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
enableOpentelemetry?booleanenable Opentelemetry tracing. The client will be handled as own ressource.
isKeepAlive?booleanIf set to false, the HTTP client will not reuse the same connection for multiple requests. Default is true.
logLevel?LogLevelNamethe loglevel if no logger instance is given
logger?LoggerA logger instance
name?stringName of the client
spanProcessor?SpanProcessorOpentelemetry span processor
traceId?stringCustom trace Id

Inherited from

HttpClient.config

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:22


logger

logger: Logger

Inherited from

HttpClient.logger

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:21


name

name: string

Inherited from

HttpClient.name

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:20


projectKey

Private projectKey: string = ''

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:14


serviceTokenSecret

Private serviceTokenSecret: string

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:12


spanProcessor

spanProcessor: undefined | SpanProcessor

Inherited from

HttpClient.spanProcessor

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:25


timeout

timeout: number

Inherited from

HttpClient.timeout

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:23


tokenData

Private tokenData: undefined | TokenData

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:13


traceProvider

traceProvider: NodeTracerProvider

Inherited from

HttpClient.traceProvider

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:26

Methods

delete

delete<T>(path, options?, payload?): Promise<T>

DELETE request

Type parameters

Name
T

Parameters

NameType
pathstring
options?HttpClientRequestOptions
payload?unknown

Returns

Promise<T>

Inherited from

HttpClient.delete

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:97


encryptSecret

encryptSecret(secretKey, secretValue, secretComment?): Object

Encrypt the given key, value and optional comment

Parameters

NameTypeDefault value
secretKeystringundefined
secretValuestringundefined
secretCommentstring''

Returns

Object

NameType
secretCommentCiphertextstring
secretCommentIVstring
secretCommentTagstring
secretKeyCiphertextstring
secretKeyIVstring
secretKeyTagstring
secretValueCiphertextstring
secretValueIVstring
secretValueTagstring

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:33


execute

execute(method, path, options?, payload?): Promise<any>

Helper method

Parameters

NameType
methodstring
pathstring
options?HttpClientRequestOptions
payload?unknown

Returns

Promise<any>

Throws

UnhandledError

Inherited from

HttpClient.execute

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:62


get

get<T>(path, options?): Promise<T>

GET request

Type parameters

Name
T

Parameters

NameType
pathstring
options?HttpClientRequestOptions

Returns

Promise<T>

Inherited from

HttpClient.get

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:69


getSecret

getSecret(name): Promise<undefined | string>

Get a single secret

Parameters

NameType
namestring

Returns

Promise<undefined | string>

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:93


getServiceTokenData

getServiceTokenData(): Promise<TokenData>

Fetches the token data from the server for given access token

Returns

Promise<TokenData>

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:77


getTracer

getTracer(): Tracer

Returns open telemetry tracer of this service

Returns

Tracer

Tracer

Inherited from

HttpClient.getTracer

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:34


getUrlAndHeader

getUrlAndHeader(path, options?): Object

Parameters

NameType
pathstring
options?HttpClientRequestOptions

Returns

Object

NameType
headersRecord<string, string>
urlURL

Inherited from

HttpClient.getUrlAndHeader

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:44


patch

patch<T>(path, payload, options?): Promise<T>

PATCH request

Type parameters

Name
T

Parameters

NameType
pathstring
payloadunknown
options?HttpClientRequestOptions

Returns

Promise<T>

Inherited from

HttpClient.patch

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:90


post

post<T>(path, payload, options?): Promise<T>

POST request

Type parameters

Name
T

Parameters

NameType
pathstring
payloadunknown
options?HttpClientRequestOptions

Returns

Promise<T>

Inherited from

HttpClient.post

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:76


put

put<T>(path, payload, options?): Promise<T>

PUT request

Type parameters

Name
T

Parameters

NameType
pathstring
payloadunknown
options?HttpClientRequestOptions

Returns

Promise<T>

Inherited from

HttpClient.put

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:83


removeSecret

removeSecret(name): Promise<void>

Remove a secret

Parameters

NameType
namestring

Returns

Promise<void>

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:168


setBearerToken

setBearerToken(token): void

Set the bearer token for all following requests.

Parameters

NameTypeDescription
tokenundefined | stringthe bearer token

Returns

void

Inherited from

HttpClient.setBearerToken

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:52


setSecret

setSecret(name, value): Promise<void>

Set a secret. It will first try to update and if the secret does not exist, it will create a new one

Parameters

NameType
namestring
valuestring

Returns

Promise<void>

Defined in

infisical-secret-store/src/InfisicalClient/InfisicalClient.impl.ts:133


startActiveSpan

startActiveSpan<F>(name, opts, context, fn): Promise<F>

Start a child span for opentelemetry tracking

Type parameters

Name
F

Parameters

NameTypeDescription
namestringname of span
optsSpanOptionsspan options
contextundefined | Contextoptional context
fn(span: Span) => Promise<F>function to be executed within the span

Returns

Promise<F>

return value of fn

Inherited from

HttpClient.startActiveSpan

Defined in

core/dist/commonjs/HttpClient/HttpClient.impl.d.ts:43