optify-config 1.23.2-aarch64-linux → 1.25.0-aarch64-linux
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.so +0 -0
- data/lib/optify_ruby/3.4/optify_ruby.so +0 -0
- data/lib/optify_ruby/4.0/optify_ruby.so +0 -0
- data/lib/optify_ruby/policies.rb +33 -0
- data/lib/optify_ruby/provider_module.rb +27 -1
- data/rbi/optify.rbi +73 -0
- data/sig/optify.rbs +45 -1
- metadata +15 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12c8a44e681d15af03f05c898aa7dd2352c5ff951782bf48230714c77c7ade38
|
|
4
|
+
data.tar.gz: d714a38e4b8eb5f6d051dab0663bd34c5e7d2c0ae83c673b5409de31a4432f31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4316956a4532e071eaeb48f5181a84c2008ab2174bbb86163d9ffd07a7025d1892a5f500f062f28607f67c60bc20d3f8fddcaf305a7e1c49907cf634cd0dc52
|
|
7
|
+
data.tar.gz: 7a977869f72fa3ace54e56125a5cd58ce82ffde091032bcd40f22b795d7582af3a2f5158a13b8cd97fb1a39eda25682519ce82ad02fe585ce1bf793ccede3980
|
|
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,23 @@ module Optify
|
|
|
358
412
|
end
|
|
359
413
|
def map_feature_names(feature_names, preferences); end
|
|
360
414
|
|
|
415
|
+
# @return The policies directly declared for the feature, or `nil` if the feature has no policies.
|
|
416
|
+
# This may not consider all policies defined per requester outside of the feature configuration.
|
|
417
|
+
sig { params(canonical_feature_name: String).returns(T.nilable(Optify::Policies)) }
|
|
418
|
+
def get_policies(canonical_feature_name); end
|
|
419
|
+
|
|
361
420
|
private
|
|
362
421
|
|
|
422
|
+
# Rust implementation.
|
|
423
|
+
sig do
|
|
424
|
+
params(
|
|
425
|
+
requester: String,
|
|
426
|
+
feature_names: T::Array[String],
|
|
427
|
+
)
|
|
428
|
+
.returns(T.nilable(String))
|
|
429
|
+
end
|
|
430
|
+
def _check_policies(requester, feature_names); end
|
|
431
|
+
|
|
363
432
|
# Map aliases or canonical feature names (perhaps derived from a file names) to the canonical feature names.
|
|
364
433
|
# Canonical feature names map to themselves.
|
|
365
434
|
# This implementation calls the Rust implementation directly.
|
|
@@ -372,6 +441,10 @@ module Optify
|
|
|
372
441
|
# @return The metadata for the feature.
|
|
373
442
|
sig { params(canonical_feature_name: String).returns(T.nilable(String)) }
|
|
374
443
|
def get_feature_metadata_json(canonical_feature_name); end
|
|
444
|
+
|
|
445
|
+
# @return The policies for the feature as JSON, or `nil` if the feature has no policies.
|
|
446
|
+
sig { params(canonical_feature_name: String).returns(T.nilable(String)) }
|
|
447
|
+
def get_policies_json(canonical_feature_name); end
|
|
375
448
|
end
|
|
376
449
|
|
|
377
450
|
# 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,12 @@ 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 directly declared for the feature, or `nil` if the feature has no policies.
|
|
239
|
+
# This may not consider all policies defined per requester outside of the feature configuration.
|
|
240
|
+
def get_policies: (String canonical_feature_name) -> Optify::Policies?
|
|
241
|
+
|
|
242
|
+
def _check_policies: (String requester, ::Array[String] feature_names) -> String?
|
|
243
|
+
|
|
203
244
|
# Map aliases or canonical feature names (perhaps derived from a file names) to the canonical feature names.
|
|
204
245
|
# Canonical feature names map to themselves.
|
|
205
246
|
# This implementation calls the Rust implementation directly.
|
|
@@ -210,6 +251,9 @@ module Optify::ProviderModule
|
|
|
210
251
|
|
|
211
252
|
# @return The metadata for the feature.
|
|
212
253
|
def get_feature_metadata_json: (String canonical_feature_name) -> String?
|
|
254
|
+
|
|
255
|
+
# @return The policies for the feature as JSON, or `nil` if the feature has no policies.
|
|
256
|
+
def get_policies_json: (String canonical_feature_name) -> String?
|
|
213
257
|
end
|
|
214
258
|
|
|
215
259
|
# Provides configurations based on keys and enabled feature names.
|
metadata
CHANGED
|
@@ -1,43 +1,49 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: optify-config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.25.0
|
|
5
5
|
platform: aarch64-linux
|
|
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-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: optify-from_hash
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.4.0
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '1'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
29
|
+
version: 0.4.0
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: sin_lru_redux
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.5.
|
|
39
|
+
version: 2.5.3
|
|
34
40
|
type: :runtime
|
|
35
41
|
prerelease: false
|
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
43
|
requirements:
|
|
38
44
|
- - "~>"
|
|
39
45
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.5.
|
|
46
|
+
version: 2.5.3
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
48
|
name: sorbet-runtime
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -179,6 +185,7 @@ files:
|
|
|
179
185
|
- lib/optify_ruby/get_options_preferences.rb
|
|
180
186
|
- lib/optify_ruby/implementation.rb
|
|
181
187
|
- lib/optify_ruby/options_metadata.rb
|
|
188
|
+
- lib/optify_ruby/policies.rb
|
|
182
189
|
- lib/optify_ruby/provider_module.rb
|
|
183
190
|
- lib/optify_ruby/watcher_implementation.rb
|
|
184
191
|
- rbi/optify.rbi
|