flagkit 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3ba83a1fc643ed1bbdcf80d9695a3ae28302ec5dbf7d039a21c5c11790f7a62
4
- data.tar.gz: b1fd7d1a6d11c2a6ce3b6f6de65bc590a0d079c737b2fa6d6b79ec697c5cdc0e
3
+ metadata.gz: 3e2d0b53a53b1d0116535ec2dc9b9ec7b113ea8fa5c4fe5c7f8bd5f6cee0e3d1
4
+ data.tar.gz: 3ec79923ba3b252727b310cf714def3914fd3cb02b2256b3e19a3f406cf10322
5
5
  SHA512:
6
- metadata.gz: 6bc92efe9c63d284ea821ddc647d25e965b75733e95e97235159e3311c2d2c0857dbbfe003fb9cb76a624cbea6a480c3651ef16acc8246cdd3439247c5c926b5
7
- data.tar.gz: cd0b81515495aea25cc104fa71f336e4ead228a6d3312c9f5754bc8645037c88e46fee220aadbac3f545e8609e5080cccc2169ca7ae647cb433a3bf4c114e2cc
6
+ metadata.gz: 1e9e1d1c19c15e7a9aec498d58e8ff8743086e71c69d79bfa6dd0dacd73b7c2beb313136df8fcc51f826f7e6e2953d8d2f3b05022dc41a1e1fd44ec120062bf9
7
+ data.tar.gz: 1a2e335d182040483745f2cad2fbf51c7475d9a65dedf00314884738e62e45551d65f9e5c6e5bf1a2f9baa688ddf3191c1f2e7b07772bb997a0837f0788af3bf
data/README.md CHANGED
@@ -75,7 +75,6 @@ client = FlagKit.initialize(
75
75
  retry_attempts: 3, # Number of retry attempts
76
76
  circuit_breaker_threshold: 5, # Failures before circuit opens
77
77
  circuit_breaker_reset_timeout: 30, # Seconds before half-open
78
- local_port: nil # Local dev server port (uses http://localhost:{port}/api/v1)
79
78
  )
80
79
  ```
81
80
 
@@ -83,12 +82,10 @@ Security features such as PII detection, request signing, bootstrap verification
83
82
 
84
83
  ## Local Development
85
84
 
86
- For local development, use the `local_port` option to connect to a local FlagKit server:
87
85
 
88
86
  ```ruby
89
87
  client = FlagKit.initialize(
90
88
  'sdk_your_api_key',
91
- local_port: 8200 # Uses http://localhost:8200/api/v1
92
89
  )
93
90
  ```
94
91
 
@@ -71,7 +71,6 @@ module FlagKit
71
71
  CONFIG_INVALID_BOOTSTRAP = "CONFIG_INVALID_BOOTSTRAP"
72
72
 
73
73
  # Security errors
74
- SECURITY_LOCAL_PORT_IN_PRODUCTION = "SECURITY_LOCAL_PORT_IN_PRODUCTION"
75
74
  SECURITY_PII_DETECTED = "SECURITY_PII_DETECTED"
76
75
  SECURITY_ENCRYPTION_ERROR = "SECURITY_ENCRYPTION_ERROR"
77
76
 
@@ -39,6 +39,8 @@ module FlagKit
39
39
  # request signing, and key rotation support.
40
40
  class HttpClient
41
41
  BASE_URL = "https://api.flagkit.dev/api/v1"
42
+ BETA_BASE_URL = "https://api.beta.flagkit.dev/api/v1"
43
+ LOCAL_BASE_URL = "https://api.flagkit.on/api/v1"
42
44
  BASE_RETRY_DELAY = 1.0
43
45
  MAX_RETRY_DELAY = 30.0
44
46
  RETRY_MULTIPLIER = 2.0
@@ -46,12 +48,18 @@ module FlagKit
46
48
 
47
49
  attr_reader :timeout, :retry_attempts, :circuit_breaker
48
50
 
49
- # Returns the base URL for the given local port, or the default production URL.
51
+ # Returns the base URL based on internal SDK mode.
50
52
  #
51
- # @param local_port [Integer, nil] The local port number
52
53
  # @return [String] The base URL
53
- def self.get_base_url(local_port)
54
- local_port ? "http://localhost:#{local_port}/api/v1" : BASE_URL
54
+ def self.get_base_url
55
+ case ENV.fetch("FLAGKIT_MODE", "").strip.downcase
56
+ when "local"
57
+ LOCAL_BASE_URL
58
+ when "beta"
59
+ BETA_BASE_URL
60
+ else
61
+ BASE_URL
62
+ end
55
63
  end
56
64
 
57
65
  # Returns the currently active API key.
@@ -83,7 +91,6 @@ module FlagKit
83
91
  # @param retry_attempts [Integer] Number of retry attempts
84
92
  # @param circuit_breaker [CircuitBreaker] The circuit breaker
85
93
  # @param logger [Object, nil] Logger instance
86
- # @param local_port [Integer, nil] Local development server port
87
94
  # @param secondary_api_key [String, nil] Secondary API key for rotation
88
95
  # @param key_rotation_grace_period [Integer] Grace period in seconds
89
96
  # @param enable_request_signing [Boolean] Enable HMAC-SHA256 request signing
@@ -94,13 +101,12 @@ module FlagKit
94
101
  retry_attempts:,
95
102
  circuit_breaker:,
96
103
  logger: nil,
97
- local_port: nil,
98
104
  secondary_api_key: nil,
99
105
  key_rotation_grace_period: 300,
100
106
  enable_request_signing: true,
101
107
  on_usage_update: nil
102
108
  )
103
- @base_url = self.class.get_base_url(local_port)
109
+ @base_url = self.class.get_base_url()
104
110
  @primary_api_key = api_key
105
111
  @secondary_api_key = secondary_api_key
106
112
  @current_api_key = api_key
@@ -39,7 +39,6 @@ module FlagKit
39
39
  :bootstrap,
40
40
  :logger,
41
41
  :storage,
42
- :local_port,
43
42
  :secondary_api_key,
44
43
  :key_rotation_grace_period,
45
44
  :strict_pii_mode,
@@ -76,7 +75,6 @@ module FlagKit
76
75
  # @param bootstrap [Hash, nil] Bootstrap data
77
76
  # @param logger [Object, nil] Logger instance
78
77
  # @param storage [Object, nil] Storage adapter
79
- # @param local_port [Integer, nil] Local development server port (uses http://localhost:{port}/api/v1)
80
78
  # @param secondary_api_key [String, nil] Secondary API key for key rotation
81
79
  # @param key_rotation_grace_period [Integer] Grace period in seconds during key rotation
82
80
  # @param strict_pii_mode [Boolean] Raise SecurityError instead of warning when PII detected
@@ -113,7 +111,6 @@ module FlagKit
113
111
  bootstrap: nil,
114
112
  logger: nil,
115
113
  storage: nil,
116
- local_port: nil,
117
114
  secondary_api_key: nil,
118
115
  key_rotation_grace_period: DEFAULT_KEY_ROTATION_GRACE_PERIOD,
119
116
  strict_pii_mode: false,
@@ -150,7 +147,6 @@ module FlagKit
150
147
  @bootstrap = bootstrap
151
148
  @logger = logger
152
149
  @storage = storage
153
- @local_port = local_port
154
150
  @secondary_api_key = secondary_api_key
155
151
  @key_rotation_grace_period = key_rotation_grace_period
156
152
  @strict_pii_mode = strict_pii_mode
@@ -176,28 +172,12 @@ module FlagKit
176
172
  # Validates the options.
177
173
  #
178
174
  # @raise [Error] If validation fails
179
- # @raise [SecurityError] If local_port is used in production
180
175
  def validate!
181
176
  validate_api_key!
182
177
  validate_positive_integers!
183
- validate_local_port_restriction!
184
178
  end
185
179
 
186
180
  private
187
-
188
- def validate_local_port_restriction!
189
- return unless local_port
190
-
191
- env = ENV.fetch("RACK_ENV", ENV.fetch("RAILS_ENV", nil))
192
- return unless env == "production"
193
-
194
- raise SecurityError.new(
195
- ErrorCode::SECURITY_LOCAL_PORT_IN_PRODUCTION,
196
- "local_port cannot be used in production environment. " \
197
- "This is a security risk as it bypasses HTTPS and may expose traffic to interception."
198
- )
199
- end
200
-
201
181
  def validate_api_key!
202
182
  raise Error.config_error(ErrorCode::CONFIG_INVALID_API_KEY, "API key is required") if api_key.nil? || api_key.empty?
203
183
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FlagKit
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flagkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlagKit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-09 00:00:00.000000000 Z
11
+ date: 2026-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday