optify-config 1.23.2-arm64-darwin → 1.24.0-arm64-darwin
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 +4 -4
- data/lib/optify_ruby/3.3/optify_ruby.bundle +0 -0
- data/lib/optify_ruby/3.4/optify_ruby.bundle +0 -0
- data/lib/optify_ruby/4.0/optify_ruby.bundle +0 -0
- data/lib/optify_ruby/policies.rb +33 -0
- data/lib/optify_ruby/provider_module.rb +27 -1
- data/rbi/optify.rbi +72 -0
- data/sig/optify.rbs +44 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26482def652f70e00a0c650fc607494e927192316d12685c2e9ca64c9c1c58e0
|
|
4
|
+
data.tar.gz: d52d8ed89ac3acd80d81236b041b1dca082b9c8507c30380d8f4534244ed7099
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c248ddba8ad6eae39cbebd607f0b7d42bc2617dcc33b1d49f8c1510580966ad36f38a82435399ef03b48601fa69b8573295da98f5239a259d206316b169fa40
|
|
7
|
+
data.tar.gz: 28245dbb77170c4c3c4a2d682676c4dd5706a81b7c0070567c86a285cb86c464eade396e4e94e47f46579b67f20ccd41a6181dc33d95a100c071ca21a7021540
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'sorbet-runtime'
|
|
5
|
+
|
|
6
|
+
require 'optify-from_hash'
|
|
7
|
+
|
|
8
|
+
module Optify
|
|
9
|
+
# The policy for the requester identifier passed via preferences.
|
|
10
|
+
#
|
|
11
|
+
# Either `allow` or `block` will be set, not both.
|
|
12
|
+
# - `allow`: only the listed requesters may use the feature; can be empty.
|
|
13
|
+
# - `block`: the listed requesters may not use the feature; all others are allowed.
|
|
14
|
+
class RequesterPolicy < FromHashable
|
|
15
|
+
extend T::Sig
|
|
16
|
+
|
|
17
|
+
sig { returns(T.nilable(T::Set[String])) }
|
|
18
|
+
attr_reader :allow
|
|
19
|
+
|
|
20
|
+
sig { returns(T.nilable(T::Set[String])) }
|
|
21
|
+
attr_reader :block
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Policies that restrict access to a feature based on values in the request's preferences.
|
|
25
|
+
#
|
|
26
|
+
# See https://github.com/juharris/optify#policies for details.
|
|
27
|
+
class Policies < FromHashable
|
|
28
|
+
extend T::Sig
|
|
29
|
+
|
|
30
|
+
sig { returns(T.nilable(RequesterPolicy)) }
|
|
31
|
+
attr_reader :requester
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -5,9 +5,27 @@ require 'json'
|
|
|
5
5
|
require 'lru_redux'
|
|
6
6
|
require 'sorbet-runtime'
|
|
7
7
|
|
|
8
|
+
require_relative './policies'
|
|
9
|
+
|
|
8
10
|
module Optify
|
|
9
11
|
# @!visibility private
|
|
10
|
-
module ProviderModule
|
|
12
|
+
module ProviderModule # rubocop:disable Metrics/ModuleLength
|
|
13
|
+
#: (String, Array[String], ?CacheOptions?) -> void
|
|
14
|
+
def check_policies(requester, feature_names, cache_options = nil)
|
|
15
|
+
if cache_options
|
|
16
|
+
init unless @cache
|
|
17
|
+
ProviderModule._cache_getset(
|
|
18
|
+
@cache, #: as !nil
|
|
19
|
+
[:check_policies, feature_names, requester],
|
|
20
|
+
cache_options.on_cache_event,
|
|
21
|
+
) do
|
|
22
|
+
_check_policies(requester, feature_names)
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
_check_policies(requester, feature_names)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
11
29
|
#: [T] (LruRedux::Cache | Hash[Array[untyped], T], Array[untyped], (^(Array[untyped] key, T value, bool is_cache_hit) -> void)?) { -> T } -> T
|
|
12
30
|
def self._cache_getset(cache, cache_key, on_cache_event, &block)
|
|
13
31
|
is_cache_hit = true #: bool
|
|
@@ -69,6 +87,14 @@ module Optify
|
|
|
69
87
|
OptionsMetadata.from_hash(JSON.parse(metadata_json))
|
|
70
88
|
end
|
|
71
89
|
|
|
90
|
+
#: (String canonical_feature_name) -> Optify::Policies?
|
|
91
|
+
def get_policies(canonical_feature_name)
|
|
92
|
+
policies_json = get_policies_json(canonical_feature_name)
|
|
93
|
+
return nil if policies_json.nil?
|
|
94
|
+
|
|
95
|
+
Policies.from_hash(JSON.parse(policies_json))
|
|
96
|
+
end
|
|
97
|
+
|
|
72
98
|
private
|
|
73
99
|
|
|
74
100
|
#: -> Hash[String, OptionsMetadata]
|
data/rbi/optify.rbi
CHANGED
|
@@ -7,6 +7,31 @@ module Optify
|
|
|
7
7
|
class UnknownFeatureError < StandardError
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
# The policy for the requester identifier passed via preferences.
|
|
11
|
+
#
|
|
12
|
+
# Either `allow` or `block` will be set, not both.
|
|
13
|
+
# - `allow`: only the listed requesters may use the feature; can be empty.
|
|
14
|
+
# - `block`: the listed requesters may not use the feature; all others are allowed.
|
|
15
|
+
class RequesterPolicy < FromHashable
|
|
16
|
+
sig { returns(T.nilable(T::Set[String])) }
|
|
17
|
+
attr_reader :allow
|
|
18
|
+
|
|
19
|
+
sig { returns(T.nilable(T::Set[String])) }
|
|
20
|
+
attr_reader :block
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Policies that restrict access to a feature based on values in the request's preferences.
|
|
24
|
+
#
|
|
25
|
+
# See https://github.com/juharris/optify#policies for details.
|
|
26
|
+
class Policies < FromHashable
|
|
27
|
+
sig { returns(T.nilable(RequesterPolicy)) }
|
|
28
|
+
attr_reader :requester
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Raised when a requester is not permitted to use a feature due to its policies.
|
|
32
|
+
class PolicyDeniedError < StandardError
|
|
33
|
+
end
|
|
34
|
+
|
|
10
35
|
# DEPRECATED: Use `Optify::FromHashable` instead.
|
|
11
36
|
# A base class for classes from configuration files.
|
|
12
37
|
# Classes that derive from this can easily be used with `Optify::OptionsProvider.get_options`
|
|
@@ -162,6 +187,22 @@ module Optify
|
|
|
162
187
|
|
|
163
188
|
sig { returns(T::Boolean) }
|
|
164
189
|
def skip_feature_name_conversion; end
|
|
190
|
+
|
|
191
|
+
# The requester identifier to use for policy enforcement.
|
|
192
|
+
# If not set, policy checks are bypassed.
|
|
193
|
+
sig { params(value: T.nilable(String)).void }
|
|
194
|
+
def requester=(value); end
|
|
195
|
+
|
|
196
|
+
sig { returns(T.nilable(String)) }
|
|
197
|
+
def requester; end
|
|
198
|
+
|
|
199
|
+
# When `true`, raises `PolicyDeniedError` if a feature is not permitted for the requester.
|
|
200
|
+
# When `false` (default), denied features are silently filtered out.
|
|
201
|
+
sig { params(value: T::Boolean).void }
|
|
202
|
+
def raise_if_policy_denied=(value); end
|
|
203
|
+
|
|
204
|
+
sig { returns(T::Boolean) }
|
|
205
|
+
def raise_if_policy_denied; end
|
|
165
206
|
end
|
|
166
207
|
|
|
167
208
|
# A registry of features that provides configurations.
|
|
@@ -233,6 +274,19 @@ module Optify
|
|
|
233
274
|
# Some of the methods shown within this module are implemented in Rust
|
|
234
275
|
# and are declared in this common module to avoid duplicate declarations in different classes.
|
|
235
276
|
module ProviderModule
|
|
277
|
+
# Checks policies for a list of features for the given requester.
|
|
278
|
+
# Returns `nil` if there are no policy issues (or no policies defined).
|
|
279
|
+
# Raises `Optify::PolicyDeniedError` if any of the features are not allowed for the requester.
|
|
280
|
+
sig do
|
|
281
|
+
params(
|
|
282
|
+
requester: String,
|
|
283
|
+
feature_names: T::Array[String],
|
|
284
|
+
cache_options: T.nilable(CacheOptions),
|
|
285
|
+
)
|
|
286
|
+
.returns(T.nilable(String))
|
|
287
|
+
end
|
|
288
|
+
def check_policies(requester, feature_names, cache_options = nil); end
|
|
289
|
+
|
|
236
290
|
# @param canonical_feature_name [String] A canonical feature name
|
|
237
291
|
# @return Whether the feature has conditions.
|
|
238
292
|
sig { params(canonical_feature_name: String).returns(T::Boolean) }
|
|
@@ -358,8 +412,22 @@ module Optify
|
|
|
358
412
|
end
|
|
359
413
|
def map_feature_names(feature_names, preferences); end
|
|
360
414
|
|
|
415
|
+
# @return The policies for the feature, or `nil` if the feature has no policies.
|
|
416
|
+
sig { params(canonical_feature_name: String).returns(T.nilable(Optify::Policies)) }
|
|
417
|
+
def get_policies(canonical_feature_name); end
|
|
418
|
+
|
|
361
419
|
private
|
|
362
420
|
|
|
421
|
+
# Rust implementation.
|
|
422
|
+
sig do
|
|
423
|
+
params(
|
|
424
|
+
requester: String,
|
|
425
|
+
feature_names: T::Array[String],
|
|
426
|
+
)
|
|
427
|
+
.returns(T.nilable(String))
|
|
428
|
+
end
|
|
429
|
+
def _check_policies(requester, feature_names); end
|
|
430
|
+
|
|
363
431
|
# Map aliases or canonical feature names (perhaps derived from a file names) to the canonical feature names.
|
|
364
432
|
# Canonical feature names map to themselves.
|
|
365
433
|
# This implementation calls the Rust implementation directly.
|
|
@@ -372,6 +440,10 @@ module Optify
|
|
|
372
440
|
# @return The metadata for the feature.
|
|
373
441
|
sig { params(canonical_feature_name: String).returns(T.nilable(String)) }
|
|
374
442
|
def get_feature_metadata_json(canonical_feature_name); end
|
|
443
|
+
|
|
444
|
+
# @return The policies for the feature as JSON, or `nil` if the feature has no policies.
|
|
445
|
+
sig { params(canonical_feature_name: String).returns(T.nilable(String)) }
|
|
446
|
+
def get_policies_json(canonical_feature_name); end
|
|
375
447
|
end
|
|
376
448
|
|
|
377
449
|
# Provides configurations based on keys and enabled feature names.
|
data/sig/optify.rbs
CHANGED
|
@@ -6,6 +6,24 @@ end
|
|
|
6
6
|
class Optify::UnknownFeatureError < StandardError
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
# The policy for the requester identifier passed via preferences.
|
|
10
|
+
#
|
|
11
|
+
# Either `allow` or `block` will be set, not both.
|
|
12
|
+
# - `allow`: only the listed requesters may use the feature; can be empty.
|
|
13
|
+
# - `block`: the listed requesters may not use the feature; all others are allowed.
|
|
14
|
+
class Optify::RequesterPolicy < FromHashable
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Policies that restrict access to a feature based on values in the request's preferences.
|
|
18
|
+
#
|
|
19
|
+
# See https://github.com/juharris/optify#policies for details.
|
|
20
|
+
class Optify::Policies < FromHashable
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Raised when a requester is not permitted to use a feature due to its policies.
|
|
24
|
+
class Optify::PolicyDeniedError < StandardError
|
|
25
|
+
end
|
|
26
|
+
|
|
9
27
|
# DEPRECATED: Use `Optify::FromHashable` instead.
|
|
10
28
|
# A base class for classes from configuration files.
|
|
11
29
|
# Classes that derive from this can easily be used with `Optify::OptionsProvider.get_options`
|
|
@@ -18,7 +36,10 @@ end
|
|
|
18
36
|
|
|
19
37
|
# Options for caching.
|
|
20
38
|
class Optify::CacheOptions
|
|
21
|
-
def initialize: () ->
|
|
39
|
+
def initialize: () -> ::Set[String]?
|
|
40
|
+
| () -> ::Set[String]?
|
|
41
|
+
| () -> RequesterPolicy?
|
|
42
|
+
| () -> (^(::Array[untyped] key, untyped value, bool is_cache_hit) -> void)?
|
|
22
43
|
| (?on_cache_event: (^(::Array[untyped] key, untyped value, bool is_cache_hit) -> void)? on_cache_event) -> void
|
|
23
44
|
end
|
|
24
45
|
|
|
@@ -100,6 +121,18 @@ class Optify::GetOptionsPreferences
|
|
|
100
121
|
def skip_feature_name_conversion=: (bool value) -> void
|
|
101
122
|
|
|
102
123
|
def skip_feature_name_conversion: () -> bool
|
|
124
|
+
|
|
125
|
+
# The requester identifier to use for policy enforcement.
|
|
126
|
+
# If not set, policy checks are bypassed.
|
|
127
|
+
def requester=: (String? value) -> void
|
|
128
|
+
|
|
129
|
+
def requester: () -> String?
|
|
130
|
+
|
|
131
|
+
# When `true`, raises `PolicyDeniedError` if a feature is not permitted for the requester.
|
|
132
|
+
# When `false` (default), denied features are silently filtered out.
|
|
133
|
+
def raise_if_policy_denied=: (bool value) -> void
|
|
134
|
+
|
|
135
|
+
def raise_if_policy_denied: () -> bool
|
|
103
136
|
end
|
|
104
137
|
|
|
105
138
|
# A registry of features that provides configurations.
|
|
@@ -149,6 +182,8 @@ end
|
|
|
149
182
|
# Some of the methods shown within this module are implemented in Rust
|
|
150
183
|
# and are declared in this common module to avoid duplicate declarations in different classes.
|
|
151
184
|
module Optify::ProviderModule
|
|
185
|
+
def check_policies: (String requester, ::Array[String] feature_names, ?CacheOptions? cache_options) -> String?
|
|
186
|
+
|
|
152
187
|
# @param canonical_feature_name [String] A canonical feature name
|
|
153
188
|
# @return Whether the feature has conditions.
|
|
154
189
|
def conditions?: (String canonical_feature_name) -> bool
|
|
@@ -200,6 +235,11 @@ module Optify::ProviderModule
|
|
|
200
235
|
|
|
201
236
|
def map_feature_names: (::Array[String] feature_names, GetOptionsPreferences preferences) -> ::Array[String?]
|
|
202
237
|
|
|
238
|
+
# @return The policies for the feature, or `nil` if the feature has no policies.
|
|
239
|
+
def get_policies: (String canonical_feature_name) -> Optify::Policies?
|
|
240
|
+
|
|
241
|
+
def _check_policies: (String requester, ::Array[String] feature_names) -> String?
|
|
242
|
+
|
|
203
243
|
# Map aliases or canonical feature names (perhaps derived from a file names) to the canonical feature names.
|
|
204
244
|
# Canonical feature names map to themselves.
|
|
205
245
|
# This implementation calls the Rust implementation directly.
|
|
@@ -210,6 +250,9 @@ module Optify::ProviderModule
|
|
|
210
250
|
|
|
211
251
|
# @return The metadata for the feature.
|
|
212
252
|
def get_feature_metadata_json: (String canonical_feature_name) -> String?
|
|
253
|
+
|
|
254
|
+
# @return The policies for the feature as JSON, or `nil` if the feature has no policies.
|
|
255
|
+
def get_policies_json: (String canonical_feature_name) -> String?
|
|
213
256
|
end
|
|
214
257
|
|
|
215
258
|
# Provides configurations based on keys and enabled feature names.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: optify-config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.24.0
|
|
5
5
|
platform: arm64-darwin
|
|
6
6
|
authors:
|
|
7
7
|
- Justin D. Harris
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: optify-from_hash
|
|
@@ -179,6 +179,7 @@ files:
|
|
|
179
179
|
- lib/optify_ruby/get_options_preferences.rb
|
|
180
180
|
- lib/optify_ruby/implementation.rb
|
|
181
181
|
- lib/optify_ruby/options_metadata.rb
|
|
182
|
+
- lib/optify_ruby/policies.rb
|
|
182
183
|
- lib/optify_ruby/provider_module.rb
|
|
183
184
|
- lib/optify_ruby/watcher_implementation.rb
|
|
184
185
|
- rbi/optify.rbi
|