momento 0.5.2 → 0.6.4
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/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +46 -0
- data/Gemfile.lock +1 -1
- data/examples/Gemfile +1 -1
- data/lib/momento/auth/credential_provider.rb +92 -0
- data/lib/momento/cache_client.rb +7 -2
- data/lib/momento/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d710dce969543a0ceca5d48787b0caa8900068d41897d1f58bb5e376f0ef6fc5
|
|
4
|
+
data.tar.gz: 20667320d3f97f74e1e4b4620f9f0e9922a76cbecde617c5da06129187444bc8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a947860bed1a3e0f7ebab1e3740bcbb73d55d69f476988a42226fc20cd6203d0c8eb6987ce089c4d6949d5d3340ed4c311b314fb78bf1d22c41d0251b5872a2
|
|
7
|
+
data.tar.gz: 59fbc4168cc931a1e6d4672610b1402b044e59ee78c9b51439eec66634f86c39aab50f437490f4b21ebc074f9e29e7cacd3e7e82335618f80c8ff50475a7b672
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.4](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.6.3...momento/v0.6.4) (2026-01-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* run bundle install and use bundle exec to call rake build ([28615a7](https://github.com/momentohq/client-sdk-ruby/commit/28615a7834cabef92215661eb8833d468c7fd4d9))
|
|
9
|
+
* run bundle install and use bundle exec to call rake build ([#206](https://github.com/momentohq/client-sdk-ruby/issues/206)) ([16256d2](https://github.com/momentohq/client-sdk-ruby/commit/16256d273ea48c61395bd1bf12fba4d8a31066af))
|
|
10
|
+
|
|
11
|
+
## [0.6.3](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.6.2...momento/v0.6.3) (2026-01-08)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* use rake build to package gem for publishing ([c6c8ac3](https://github.com/momentohq/client-sdk-ruby/commit/c6c8ac3e9dd293b3aa3fd3bdeaeb870870f0cf35))
|
|
17
|
+
* use rake build to package gem for publishing ([#204](https://github.com/momentohq/client-sdk-ruby/issues/204)) ([a6a7105](https://github.com/momentohq/client-sdk-ruby/commit/a6a71051f99fc1805c6dcd2ed9c79770b2d5a6fc))
|
|
18
|
+
|
|
19
|
+
## [0.6.2](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.6.1...momento/v0.6.2) (2026-01-08)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Miscellaneous Chores
|
|
23
|
+
|
|
24
|
+
* release 0.6.2 ([e435dde](https://github.com/momentohq/client-sdk-ruby/commit/e435dde85def1dea661169a92f3ecc5dec477523))
|
|
25
|
+
* release 0.6.2 ([#202](https://github.com/momentohq/client-sdk-ruby/issues/202)) ([210dbf1](https://github.com/momentohq/client-sdk-ruby/commit/210dbf10ad3056e9f142620c6d4726a3e1a8e856))
|
|
26
|
+
|
|
27
|
+
## [0.6.1](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.6.0...momento/v0.6.1) (2025-12-17)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Miscellaneous Chores
|
|
31
|
+
|
|
32
|
+
* release 0.6.1 ([d857669](https://github.com/momentohq/client-sdk-ruby/commit/d857669abf0934391e61580832f713142c187a17))
|
|
33
|
+
* release 0.6.1 ([#198](https://github.com/momentohq/client-sdk-ruby/issues/198)) ([ed8998e](https://github.com/momentohq/client-sdk-ruby/commit/ed8998e361068ce2100fc5b54c65c13c483a4990))
|
|
34
|
+
|
|
35
|
+
## [0.6.0](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.5.2...momento/v0.6.0) (2025-12-15)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* new credential provider methods for accepting global api keys ([eb4737f](https://github.com/momentohq/client-sdk-ruby/commit/eb4737ff608e15dad77064e40157da3b4691b2da))
|
|
41
|
+
* new credential provider methods for accepting v2 api keys ([#195](https://github.com/momentohq/client-sdk-ruby/issues/195)) ([79e3777](https://github.com/momentohq/client-sdk-ruby/commit/79e37776ef9c7a8703bddc3dfbe569af8e42e888))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* disable dynamic DNS service config ([#194](https://github.com/momentohq/client-sdk-ruby/issues/194)) ([d9a0976](https://github.com/momentohq/client-sdk-ruby/commit/d9a0976dec3c8ab68e8ed4a83d50ee97963fb4b1))
|
|
47
|
+
* only configure git in release please if the repo was checked out ([#192](https://github.com/momentohq/client-sdk-ruby/issues/192)) ([d202329](https://github.com/momentohq/client-sdk-ruby/commit/d2023298b388e36616e766157d2a7ad017f07917))
|
|
48
|
+
|
|
3
49
|
## [0.5.2](https://github.com/momentohq/client-sdk-ruby/compare/momento/v0.5.1...momento/v0.5.2) (2024-11-25)
|
|
4
50
|
|
|
5
51
|
|
data/Gemfile.lock
CHANGED
data/examples/Gemfile
CHANGED
|
@@ -10,6 +10,7 @@ module Momento
|
|
|
10
10
|
# @param env_var_name [String] the environment variable containing the API key
|
|
11
11
|
# @return [Momento::CredentialProvider]
|
|
12
12
|
# @raise [Momento::Error::InvalidArgumentError] if the API key is invalid
|
|
13
|
+
# @deprecated Please use {#from_env_var_v2} instead.
|
|
13
14
|
def self.from_env_var(env_var_name)
|
|
14
15
|
api_key = ENV.fetch(env_var_name) {
|
|
15
16
|
raise Momento::Error::InvalidArgumentError, "Env var #{env_var_name} must be set"
|
|
@@ -21,15 +22,84 @@ module Momento
|
|
|
21
22
|
# @param api_key [String] the Momento API key
|
|
22
23
|
# @return [Momento::CredentialProvider]
|
|
23
24
|
# @raise [Momento::Error::InvalidArgumentError] if the API key is invalid
|
|
25
|
+
# @deprecated Please use {#from_api_key_v2} or {#from_disposable_token} instead.
|
|
24
26
|
def self.from_string(api_key)
|
|
25
27
|
raise Momento::Error::InvalidArgumentError, 'Auth token string cannot be empty' if api_key.empty?
|
|
26
28
|
|
|
27
29
|
new(api_key)
|
|
28
30
|
end
|
|
29
31
|
|
|
32
|
+
# Creates a CredentialProvider from a Momento disposable token
|
|
33
|
+
# @param token [String] the Momento disposable token
|
|
34
|
+
# @return [Momento::CredentialProvider]
|
|
35
|
+
# @raise [Momento::Error::InvalidArgumentError] if the token is invalid
|
|
36
|
+
def self.from_disposable_token(token)
|
|
37
|
+
raise Momento::Error::InvalidArgumentError, 'Auth token string cannot be empty' if token.empty?
|
|
38
|
+
|
|
39
|
+
new(token)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Creates a CredentialProvider from a v2 API key string and endpoint.
|
|
43
|
+
# @param api_key [String] the v2 API key
|
|
44
|
+
# @param endpoint [String] the Momento service endpoint
|
|
45
|
+
# @return [Momento::CredentialProvider]
|
|
46
|
+
# @raise [Momento::Error::InvalidArgumentError] if parameters are invalid
|
|
47
|
+
def self.from_api_key_v2(api_key:, endpoint:)
|
|
48
|
+
raise Momento::Error::InvalidArgumentError, 'API key cannot be empty' if api_key.nil? || api_key.empty?
|
|
49
|
+
raise Momento::Error::InvalidArgumentError, 'Endpoint cannot be empty' if endpoint.nil? || endpoint.empty?
|
|
50
|
+
|
|
51
|
+
unless v2_api_key?(api_key)
|
|
52
|
+
raise Momento::Error::InvalidArgumentError,
|
|
53
|
+
'Received an invalid v2 API key. Are you using the correct key? \
|
|
54
|
+
Or did you mean to use `from_string()` with a legacy key instead?'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
allocate.tap do |instance|
|
|
58
|
+
instance.send(:initialize_from_v2, api_key, endpoint)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Creates a CredentialProvider from a v2 API key and endpoint loaded from environment variables
|
|
63
|
+
# MOMENTO_API_KEY and MOMENTO_ENDPOINT by default.
|
|
64
|
+
# @param api_key_env_var [String] optionally provide alternate environment variable containing the v2 API key
|
|
65
|
+
# @param endpoint_env_var [String] optionally provide alternate environment variable containing the endpoint
|
|
66
|
+
# @return [Momento::CredentialProvider]
|
|
67
|
+
# @raise [Momento::Error::InvalidArgumentError] if parameters are invalid
|
|
68
|
+
def self.from_env_var_v2(api_key_env_var: "MOMENTO_API_KEY", endpoint_env_var: "MOMENTO_ENDPOINT")
|
|
69
|
+
api_key = ENV.fetch(api_key_env_var) {
|
|
70
|
+
raise Momento::Error::InvalidArgumentError, "Env var #{api_key_env_var} must be set"
|
|
71
|
+
}
|
|
72
|
+
endpoint = ENV.fetch(endpoint_env_var) {
|
|
73
|
+
raise Momento::Error::InvalidArgumentError, "Env var #{endpoint_env_var} must be set"
|
|
74
|
+
}
|
|
75
|
+
unless v2_api_key?(api_key)
|
|
76
|
+
raise Momento::Error::InvalidArgumentError,
|
|
77
|
+
'Received an invalid v2 API key. Are you using the correct key? \
|
|
78
|
+
Or did you mean to use `from_env_var()` with a legacy key instead?'
|
|
79
|
+
end
|
|
80
|
+
allocate.tap do |instance|
|
|
81
|
+
instance.send(:initialize_from_v2, api_key, endpoint)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
30
85
|
private
|
|
31
86
|
|
|
87
|
+
def initialize_from_v2(api_key, endpoint)
|
|
88
|
+
raise Momento::Error::InvalidArgumentError, 'API key cannot be empty' if api_key.nil? || api_key.empty?
|
|
89
|
+
raise Momento::Error::InvalidArgumentError, 'Endpoint cannot be empty' if endpoint.nil? || endpoint.empty?
|
|
90
|
+
|
|
91
|
+
@api_key = api_key
|
|
92
|
+
@control_endpoint = "control.#{endpoint}"
|
|
93
|
+
@cache_endpoint = "cache.#{endpoint}"
|
|
94
|
+
end
|
|
95
|
+
|
|
32
96
|
def initialize(api_key)
|
|
97
|
+
if v2_api_key?(api_key)
|
|
98
|
+
raise Momento::Error::InvalidArgumentError,
|
|
99
|
+
'Received a v2 API key. Are you using the correct key? Or did you mean to use\
|
|
100
|
+
`from_api_key_v2()` or `from_env_var_v2()` instead?'
|
|
101
|
+
end
|
|
102
|
+
|
|
33
103
|
decoded_token = decode_api_key(api_key)
|
|
34
104
|
@api_key = decoded_token.api_key
|
|
35
105
|
@control_endpoint = decoded_token.control_endpoint
|
|
@@ -76,3 +146,25 @@ module Momento
|
|
|
76
146
|
end
|
|
77
147
|
end
|
|
78
148
|
end
|
|
149
|
+
|
|
150
|
+
def base64?(string)
|
|
151
|
+
return false if string.nil? || string.empty?
|
|
152
|
+
|
|
153
|
+
Base64.strict_decode64(string)
|
|
154
|
+
true
|
|
155
|
+
rescue ArgumentError
|
|
156
|
+
false
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def v2_api_key?(api_key)
|
|
160
|
+
false if base64?(api_key)
|
|
161
|
+
|
|
162
|
+
key_parts = api_key.split('.')
|
|
163
|
+
raise Momento::Error::InvalidArgumentError, 'Malformed legacy API key' if key_parts.size != 3
|
|
164
|
+
|
|
165
|
+
decoded_key = Base64.decode64(key_parts[1])
|
|
166
|
+
key_json = JSON.parse(decoded_key, symbolize_names: true)
|
|
167
|
+
key_json[:t] == 'g'
|
|
168
|
+
rescue ArgumentError, JSON::ParserError
|
|
169
|
+
false
|
|
170
|
+
end
|
data/lib/momento/cache_client.rb
CHANGED
|
@@ -345,7 +345,9 @@ module Momento
|
|
|
345
345
|
@cache_stubs ||= (1..@num_cache_stubs).map {
|
|
346
346
|
CACHE_CLIENT_STUB_CLASS.new(@cache_endpoint, combined_credentials,
|
|
347
347
|
timeout: @configuration.transport_strategy.grpc_configuration.deadline,
|
|
348
|
-
channel_args: { 'grpc.use_local_subchannel_pool' => 1
|
|
348
|
+
channel_args: { 'grpc.use_local_subchannel_pool' => 1,
|
|
349
|
+
# Disable service config resolution to avoid DNS TXT record lookups
|
|
350
|
+
'grpc.service_config_disable_resolution' => 1 }
|
|
349
351
|
)
|
|
350
352
|
}
|
|
351
353
|
@next_cache_stub_index = (@next_cache_stub_index + 1) % @num_cache_stubs
|
|
@@ -353,7 +355,10 @@ module Momento
|
|
|
353
355
|
end
|
|
354
356
|
|
|
355
357
|
def control_stub
|
|
356
|
-
@control_stub ||= CONTROL_CLIENT_STUB_CLASS.new(@control_endpoint, combined_credentials
|
|
358
|
+
@control_stub ||= CONTROL_CLIENT_STUB_CLASS.new(@control_endpoint, combined_credentials,
|
|
359
|
+
# Disable service config resolution to avoid DNS TXT record lookups
|
|
360
|
+
channel_args: { 'grpc.service_config_disable_resolution' => 1 }
|
|
361
|
+
)
|
|
357
362
|
end
|
|
358
363
|
|
|
359
364
|
def combined_credentials
|
data/lib/momento/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: momento
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Momento
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -321,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
321
321
|
- !ruby/object:Gem::Version
|
|
322
322
|
version: '0'
|
|
323
323
|
requirements: []
|
|
324
|
-
rubygems_version: 3.
|
|
324
|
+
rubygems_version: 3.4.10
|
|
325
325
|
signing_key:
|
|
326
326
|
specification_version: 4
|
|
327
327
|
summary: Client for Momento Serverless Cache
|