@openfeature/flagd-provider
Advanced tools
Comparing version 0.7.4 to 0.7.5
{ | ||
"name": "@openfeature/flagd-provider", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"scripts": { | ||
@@ -9,3 +9,3 @@ "publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi", | ||
"peerDependencies": { | ||
"@openfeature/js-sdk": "^1.0.0" | ||
"@openfeature/js-sdk": "^1.1.0" | ||
}, | ||
@@ -24,6 +24,8 @@ "module": "./index.js", | ||
"dependencies": { | ||
"@grpc/grpc-js": "^1.7.3", | ||
"@protobuf-ts/grpc-transport": "2.8.2", | ||
"@protobuf-ts/runtime": "2.8.2", | ||
"@protobuf-ts/runtime-rpc": "2.8.2", | ||
"@grpc/grpc-js": "1.8.0" | ||
"lru-cache": "^7.14.1" | ||
} | ||
} |
@@ -26,8 +26,11 @@ # Server-side flagd Provider | ||
| Option name | Environment variable name | Type | Default | | ||
| ----------- | ------------------------- | ------- | --------- | | ||
| host | FLAGD_HOST | string | localhost | | ||
| port | FLAGD_PORT | number | 8013 | | ||
| tls | FLAGD_TLS | boolean | false | | ||
| socketPath | FLAGD_SOCKET_PATH | string | - | | ||
| Option name | Environment variable name | Type | Default | Values | | ||
| --------------------- | ------------------------------- | ------- | --------- | ------------- | | ||
| host | FLAGD_HOST | string | localhost | | | ||
| port | FLAGD_PORT | number | 8013 | | | ||
| tls | FLAGD_TLS | boolean | false | | | ||
| socketPath | FLAGD_SOCKET_PATH | string | - | | | ||
| cache | FLAGD_CACHE | string | lru | lru,disabled | | ||
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | | | ||
| maxEventStreamRetries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | | | ||
@@ -34,0 +37,0 @@ ### Example using TCP |
@@ -0,1 +1,2 @@ | ||
export type CacheOption = 'lru' | 'disabled'; | ||
export interface Config { | ||
@@ -26,2 +27,20 @@ /** | ||
socketPath?: string; | ||
/** | ||
* Cache implementation to use (or disabled). | ||
* | ||
* @default 'lru' | ||
*/ | ||
cache?: CacheOption; | ||
/** | ||
* Max cache size (items). | ||
* | ||
* @default 1000 | ||
*/ | ||
maxCacheSize?: number; | ||
/** | ||
* Amount of times to attempt to reconnect to the event stream. | ||
* | ||
* @default 5 | ||
*/ | ||
maxEventStreamRetries?: number; | ||
} | ||
@@ -34,2 +53,5 @@ export type FlagdProviderOptions = Partial<Config>; | ||
socketPath?: string | undefined; | ||
cache?: CacheOption | undefined; | ||
maxCacheSize?: number | undefined; | ||
maxEventStreamRetries?: number | undefined; | ||
}; |
@@ -5,2 +5,3 @@ import { EvaluationContext, JsonValue, Logger, Provider, ResolutionDetails } from '@openfeature/js-sdk'; | ||
export declare class FlagdProvider implements Provider { | ||
private logger?; | ||
metadata: { | ||
@@ -10,3 +11,12 @@ name: string; | ||
private readonly _service; | ||
constructor(options?: FlagdProviderOptions, service?: Service); | ||
/** | ||
* Promise indicating the gRPC stream is connected. | ||
* | ||
* Can be used in instances where the provider being connected to the event stream is a prerequisite | ||
* to execution (e.g. testing). Not necessary for standard usage. | ||
* | ||
* @returns true if stream connected successfully, false if connection not enabled. | ||
*/ | ||
get streamConnection(): Promise<boolean>; | ||
constructor(options?: FlagdProviderOptions, service?: Service, logger?: Logger | undefined); | ||
resolveBooleanEvaluation(flagKey: string, _: boolean, transformedContext: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>; | ||
@@ -13,0 +23,0 @@ resolveStringEvaluation(flagKey: string, _: string, transformedContext: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>; |
@@ -5,2 +5,12 @@ import { EvaluationContext, JsonValue, Logger, ResolutionDetails } from '@openfeature/js-sdk'; | ||
import { Service } from '../service'; | ||
interface FlagChange { | ||
type: 'delete' | 'write' | 'update'; | ||
source: string; | ||
flagKey: string; | ||
} | ||
export interface FlagChangeMessage { | ||
flags?: { | ||
[key: string]: FlagChange; | ||
}; | ||
} | ||
export declare const Codes: { | ||
@@ -13,4 +23,13 @@ readonly InvalidArgument: "INVALID_ARGUMENT"; | ||
export declare class GRPCService implements Service { | ||
client: ServiceClient; | ||
constructor(config: Config, client?: ServiceClient); | ||
private logger?; | ||
private _client; | ||
private _cache; | ||
private _cacheEnabled; | ||
private _streamAlive; | ||
private _streamConnectAttempt; | ||
private _streamConnectBackoff; | ||
private _maxEventStreamRetries; | ||
private get _cacheActive(); | ||
readonly streamConnection: Promise<boolean>; | ||
constructor(config: Config, client?: ServiceClient, logger?: Logger | undefined); | ||
resolveBoolean(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>; | ||
@@ -20,5 +39,12 @@ resolveString(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>; | ||
resolveObject<T extends JsonValue>(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<T>>; | ||
private connectStream; | ||
private handleProviderReady; | ||
private handleFlagsChanged; | ||
private handleError; | ||
private handleComplete; | ||
private objectParser; | ||
private resolve; | ||
private convertContext; | ||
private onFulfilled; | ||
private onRejected; | ||
} | ||
export {}; |
import { EvaluationContext, JsonValue, Logger, ResolutionDetails } from '@openfeature/js-sdk'; | ||
export interface Service { | ||
readonly streamConnection: Promise<boolean>; | ||
resolveBoolean(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>; | ||
@@ -4,0 +5,0 @@ resolveString(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
17
62
212597
6
4280
31
+ Added@protobuf-ts/runtime@2.8.2
+ Addedlru-cache@^7.14.1
+ Added@grpc/grpc-js@1.12.6(transitive)
+ Added@js-sdsl/ordered-map@4.4.2(transitive)
+ Added@protobuf-ts/runtime@2.8.2(transitive)
+ Addedlru-cache@7.18.3(transitive)
- Removed@grpc/grpc-js@1.8.0(transitive)
- Removed@protobuf-ts/runtime@2.9.4(transitive)
Updated@grpc/grpc-js@^1.7.3