Skip to content

jin-frame / providers/security/ApiKeyProvider / ApiKeyProvider

Class: ApiKeyProvider ​

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:9

Places a key in a header, query parameter, or cookie.

Extended by ​

Implements ​

Constructors ​

Constructor ​

new ApiKeyProvider(key, keyName, location, name): ApiKeyProvider

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:27

Parameters ​

key ​

Static key or synchronous supplier; undefined uses authorization fallback.

ProviderKey | undefined

keyName ​

string

Destination name, such as X-API-Key, Authorization, or api_key.

location ​

Send the key as a header, query parameter, or cookie.

"cookie" | "header" | "query"

name ​

string = "api-key"

Provider metadata, independent of the destination name.

Returns ​

ApiKeyProvider

Properties ​

name ​

readonly name: string

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:12

Unique name for this security provider instance

Implementation of ​

SecurityProvider.name


type ​

readonly type: "api-key" | "http" | "oauth2" | "open-id-connect" = "api-key"

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:11

The type of security scheme (following OpenAPI 3.0 security scheme types)

Implementation of ​

SecurityProvider.type

Methods ​

createContext() ​

createContext(authorization?, dynamicKey?): SecurityContext

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:58

Resolves dynamicKey > provider key > authorization and formats the result. Suppliers run once per context unless dynamicKey is present; errors propagate. Empty strings are preserved; missing or non-string keys produce no credentials. Async authorization suppliers are resolved by _execute(), not by this method.

Parameters ​

authorization? ​

AuthorizationData

dynamicKey? ​

string

Returns ​

SecurityContext

Implementation of ​

SecurityProvider.createContext


formatKey() ​

protected formatKey(key): string

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:48

Override to format credentials, such as adding a Basic or Bearer prefix.

Parameters ​

key ​

string

Returns ​

string


setKey() ​

setKey(key): this

Defined in: packages/jin-frame/src/providers/security/ApiKeyProvider.ts:41

Replaces the shared key source for future requests and returns this provider.

Parameters ​

key ​

ProviderKey

Returns ​

this