hephaestus 0.8.15.5 → 0.8.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 507c05485b78ef114764457b17768d84c9d94e57f1171a7ad8823b0aeaa4ea9c
4
- data.tar.gz: 2688ee1d57371e64c8b6677ac249c4c43c5609d7c34067186ad23025ba94915e
3
+ metadata.gz: 3f26ad9b636b27e03c625f6fec30d2c52b6ae050dd48de9159cf9c415689c8b0
4
+ data.tar.gz: 4be4cbe1c5bc93f2088d02e02609961ffc11e63eeba3e22069729bd21a2de16b
5
5
  SHA512:
6
- metadata.gz: 38957f8ca0fddea05fd4a337dbc2632770398d6034fa5635f729ac0b55d2f243bc13283e6076ff245f3e9dc1ee9ff35423a3af809b118798454d5cc00a351ffb
7
- data.tar.gz: f90f995a3c9dc816f20d85b3efcf867f8b78a1de92cec1387d7bd30f2c7585b29713dedc7bea07581456afdd72dbf8b6eb4c1da3cd155ebcf80b39eef29e3c71
6
+ metadata.gz: b9d65aae9cea6fc9b54c51ff92f2b1d286519b2df0bd2cb3485898eca695036d37150a364ef3d836ea59b26c25efaca4a6b96ab636f2c80e6ab50b33ae644532
7
+ data.tar.gz: 218bc243b86df4b8e73a943df816a3bbd462311972e79e309136206bf01e95f89f64e5104dd9e5b5b758b22c40e7ed29b505c9b6a5b099b0823efe60ba0f45aa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [v0.8.16.1] - 28-01-2025
2
+ ## What's Changed
3
+ * correct API URL in test by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/114
4
+
5
+
6
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.16...v0.8.16.1
7
+ # [v0.8.16] - 26-01-2025
8
+ ## What's Changed
9
+ * Point to new API url by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/105
10
+
11
+
12
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.15.5...v0.8.16
1
13
  # [v0.8.15.5] - 16-01-2025
2
14
  **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.15.4...v0.8.15.5
3
15
  # [v0.8.15.4] - 16-01-2025
@@ -17,7 +17,7 @@ module Hephaestus
17
17
  return bad_request unless yetto_signature.start_with?("sha256=")
18
18
 
19
19
  hmac_header = yetto_signature.split("sha256=").last
20
- body = request.env.fetch("RAW_POST_DATA", "")
20
+ body = request.raw_post
21
21
 
22
22
  calculated_hmac = OpenSSL::HMAC.hexdigest(SHA256_DIGEST, Hephaestus::YETTO_SIGNING_SECRET, body)
23
23
 
@@ -17,7 +17,7 @@ end
17
17
  module Hephaestus
18
18
  class YettoService
19
19
  # Version is set by the consuming plug
20
- YETTO_API_VERSION_TLD = "#{Hephaestus::PROTOCOL}#{Hephaestus::YETTO_API_URL}/#{Rails.configuration.yetto_api_version}"
20
+ YETTO_API_VERSION_URL = "#{Hephaestus::YETTO_API_URL}/#{Rails.configuration.yetto_api_version}"
21
21
 
22
22
  class << self
23
23
  def yetto_client
@@ -29,14 +29,14 @@ module Hephaestus
29
29
  end
30
30
 
31
31
  def perform_token_exchange(plug_installation_id)
32
- response = yetto_client.with_headers({ "Authorization" => "Bearer #{encoded_jwt}" }).post("#{YETTO_API_VERSION_TLD}/plug/installations/#{plug_installation_id}/access_tokens")
32
+ response = yetto_client.with_headers({ "Authorization" => "Bearer #{encoded_jwt}" }).post("#{YETTO_API_VERSION_URL}/plug/installations/#{plug_installation_id}/access_tokens")
33
33
  body = response.parsed_json_body
34
34
  body["token"]
35
35
  end
36
36
 
37
37
  def get_plug_installation(plug_installation_id)
38
38
  token = perform_token_exchange(plug_installation_id)
39
- yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).get("#{YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
39
+ yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).get("#{YETTO_API_VERSION_URL}/installations/#{plug_installation_id}")
40
40
  end
41
41
 
42
42
  def update_plug_installation(plug_installation_id, params)
@@ -46,47 +46,47 @@ module Hephaestus
46
46
  plug_installation[:credentials] = params.fetch(:credentials, {})
47
47
 
48
48
  token = perform_token_exchange(plug_installation_id)
49
- yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).patch("#{YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}", json: plug_installation)
49
+ yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).patch("#{YETTO_API_VERSION_URL}/installations/#{plug_installation_id}", json: plug_installation)
50
50
  end
51
51
 
52
52
  def get_messages_in_inbox(plug_installation_id, inbox_id, filter: {})
53
53
  token = perform_token_exchange(plug_installation_id)
54
54
 
55
- yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).get("#{YETTO_API_VERSION_TLD}/inboxes/#{inbox_id}/messages#{to_filter_query(filter)}")
55
+ yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).get("#{YETTO_API_VERSION_URL}/inboxes/#{inbox_id}/messages#{to_filter_query(filter)}")
56
56
  end
57
57
 
58
58
  def get_messages_in_conversation(plug_installation_id, conversation_id, filter: {})
59
59
  token = perform_token_exchange(plug_installation_id)
60
60
 
61
- yetto_client.with_headers("Authorization" => "Bearer #{token}").get("#{YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages#{to_filter_query(filter)}")
61
+ yetto_client.with_headers("Authorization" => "Bearer #{token}").get("#{YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages#{to_filter_query(filter)}")
62
62
  end
63
63
 
64
64
  def update_message(plug_installation_id, message_id, params)
65
65
  token = perform_token_exchange(plug_installation_id)
66
66
 
67
- yetto_client.with_headers("Authorization" => "Bearer #{token}").patch("#{YETTO_API_VERSION_TLD}/messages/#{message_id}", json: params)
67
+ yetto_client.with_headers("Authorization" => "Bearer #{token}").patch("#{YETTO_API_VERSION_URL}/messages/#{message_id}", json: params)
68
68
  end
69
69
 
70
70
  def create_conversation(plug_installation_id, inbox_id, params)
71
71
  token = perform_token_exchange(plug_installation_id)
72
72
 
73
- yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).post("#{YETTO_API_VERSION_TLD}/inboxes/#{inbox_id}/conversations", json: params)
73
+ yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).post("#{YETTO_API_VERSION_URL}/inboxes/#{inbox_id}/conversations", json: params)
74
74
  end
75
75
 
76
76
  def create_message_reply(plug_installation_id, message_id, params)
77
77
  token = perform_token_exchange(plug_installation_id)
78
78
 
79
- yetto_client.with_headers("Authorization" => "Bearer #{token}").post("#{YETTO_API_VERSION_TLD}/messages/#{message_id}/replies", json: params)
79
+ yetto_client.with_headers("Authorization" => "Bearer #{token}").post("#{YETTO_API_VERSION_URL}/messages/#{message_id}/replies", json: params)
80
80
  end
81
81
 
82
82
  def add_message_to_conversation(plug_installation_id, conversation_id, params)
83
83
  token = perform_token_exchange(plug_installation_id)
84
84
 
85
- yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).post("#{YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages", json: params)
85
+ yetto_client.with_headers({ "Authorization" => "Bearer #{token}" }).post("#{YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages", json: params)
86
86
  end
87
87
 
88
88
  def get_plug_installations(filter: {})
89
- yetto_client.with_headers({ "Authorization" => "Bearer #{encoded_jwt}" }).get("#{YETTO_API_VERSION_TLD}/plug/installations#{to_filter_query(filter)}")
89
+ yetto_client.with_headers({ "Authorization" => "Bearer #{encoded_jwt}" }).get("#{YETTO_API_VERSION_URL}/plug/installations#{to_filter_query(filter)}")
90
90
  end
91
91
 
92
92
  private def to_filter_query(hash)
@@ -80,16 +80,30 @@ module Hephaestus
80
80
  end
81
81
 
82
82
  PROTOCOL = Rails.env.development? ? "http://" : "https://"
83
- YETTO_URL = if Rails.env.production?
84
- "web.yetto.app"
83
+
84
+ YETTO_DOMAIN = if Rails.env.production?
85
+ "yetto.app"
85
86
  elsif Rails.env.staging?
86
- "web.yetto.dev"
87
- elsif Rails.env.development?
87
+ "yetto.dev"
88
+ elsif Rails.env.test?
89
+ "yetto.test"
90
+ end
91
+ YETTO_URL = if Rails.env.development?
88
92
  "localhost:3000"
93
+ else
94
+ "web.#{YETTO_DOMAIN}"
95
+ end
96
+
97
+ YETTO_API_URL = if Rails.env.development?
98
+ "http://localhost:3000/api"
89
99
  elsif Rails.env.test?
90
- "web.yetto.test"
100
+ "http://#{YETTO_URL}/api"
101
+ else
102
+ "https://api.#{YETTO_DOMAIN}"
91
103
  end
92
104
 
105
+ YETTO_REDIRECT_URL = productionish? ? "#{PROTOCOL}#{YETTO_URL}" : "#{PROTOCOL}127.0.0.1:3000"
106
+
93
107
  # Every plug has secrets; to reduce the amount of API calls to 1Password,
94
108
  # we can grab one document that contains all the secrets we need
95
109
  if productionish?
@@ -114,9 +128,6 @@ module Hephaestus
114
128
  end
115
129
  end
116
130
 
117
- YETTO_API_URL = "#{YETTO_URL}/api"
118
- YETTO_REDIRECT_URL = productionish? ? "#{PROTOCOL}#{YETTO_URL}" : "#{PROTOCOL}127.0.0.1:3000"
119
-
120
131
  YETTO_PLUG_PEM = fetch_vault_secret(
121
132
  label: "YETTO_PLUG_PEM",
122
133
  default: Rails.root.join("test/fixtures/files/fake_pem_file/fake.pem"),
@@ -9,7 +9,7 @@ module Hephaestus
9
9
  end
10
10
 
11
11
  def assert_requested_post_access_token(plug_installation_id, times: 1)
12
- assert_requested(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/plug/installations/#{plug_installation_id}/access_tokens", times: times)
12
+ assert_requested(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/plug/installations/#{plug_installation_id}/access_tokens", times: times)
13
13
  end
14
14
 
15
15
  def stub_post_access_token(plug_installation_id)
@@ -17,18 +17,18 @@ module Hephaestus
17
17
  token: Faker::Alphanumeric.alphanumeric(number: 26).upcase,
18
18
  }
19
19
 
20
- stub_request(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/plug/installations/#{plug_installation_id}/access_tokens")
20
+ stub_request(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/plug/installations/#{plug_installation_id}/access_tokens")
21
21
  .to_return(
22
22
  body: response.to_json,
23
23
  )
24
24
  end
25
25
 
26
26
  def assert_requested_get_plug_installation(plug_installation_id, times: 1)
27
- assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}", times:)
27
+ assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/installations/#{plug_installation_id}", times:)
28
28
  end
29
29
 
30
30
  def stub_get_plug_installation(plug_installation_id, response: {}, status: 200)
31
- stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
31
+ stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/installations/#{plug_installation_id}")
32
32
  .to_return(
33
33
  status: status,
34
34
  headers: { content_type: "application/json; charset=utf-8" },
@@ -37,11 +37,11 @@ module Hephaestus
37
37
  end
38
38
 
39
39
  def assert_requested_update_plug_installation(plug_installation_id)
40
- assert_requested(:patch, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
40
+ assert_requested(:patch, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/installations/#{plug_installation_id}")
41
41
  end
42
42
 
43
43
  def assert_not_requested_update_plug_installation(plug_installation_id)
44
- assert_requested(:patch, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}", times: 0)
44
+ assert_requested(:patch, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/installations/#{plug_installation_id}", times: 0)
45
45
  end
46
46
 
47
47
  def stub_update_plug_installation(plug_installation_id, params, response: {}, status: 200)
@@ -49,7 +49,7 @@ module Hephaestus
49
49
 
50
50
  response[:plug_installation] = { id: plug_installation_id }
51
51
 
52
- stub_request(:patch, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/installations/#{plug_installation_id}")
52
+ stub_request(:patch, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/installations/#{plug_installation_id}")
53
53
  .with(
54
54
  body: params,
55
55
  )
@@ -61,7 +61,7 @@ module Hephaestus
61
61
  end
62
62
 
63
63
  def assert_requested_create_conversation(plug_installation_id, inbox_id)
64
- assert_requested(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/inboxes/#{inbox_id}/conversations")
64
+ assert_requested(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/inboxes/#{inbox_id}/conversations")
65
65
  end
66
66
 
67
67
  def stub_create_conversation(plug_installation_id, inbox_id, payload, response: {})
@@ -69,7 +69,7 @@ module Hephaestus
69
69
 
70
70
  response[:plug_installation] = { id: plug_installation_id }
71
71
 
72
- stub_request(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/inboxes/#{inbox_id}/conversations")
72
+ stub_request(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/inboxes/#{inbox_id}/conversations")
73
73
  .with(
74
74
  body: payload,
75
75
  )
@@ -81,11 +81,11 @@ module Hephaestus
81
81
  end
82
82
 
83
83
  def assert_requested_get_plug_installations(filter: "")
84
- assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/plug/installations?#{filter}")
84
+ assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/plug/installations?#{filter}")
85
85
  end
86
86
 
87
87
  def stub_get_plug_installations(response, status: 200, filter: "")
88
- stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/plug/installations?#{filter}")
88
+ stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/plug/installations?#{filter}")
89
89
  .to_return(
90
90
  status: status,
91
91
  headers: { content_type: "application/json; charset=utf-8" },
@@ -94,12 +94,12 @@ module Hephaestus
94
94
  end
95
95
 
96
96
  def assert_requested_get_messages_in_inbox(plug_installation_id, inbox_id, filter: "")
97
- assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/inboxes/#{inbox_id}/messages?#{filter}")
97
+ assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/inboxes/#{inbox_id}/messages?#{filter}")
98
98
  end
99
99
 
100
100
  def stub_get_messages_in_inbox(plug_installation_id, inbox_id, response, filter: "")
101
101
  stub_post_access_token(plug_installation_id)
102
- stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/inboxes/#{inbox_id}/messages?#{filter}")
102
+ stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/inboxes/#{inbox_id}/messages?#{filter}")
103
103
  .to_return(
104
104
  status: 200,
105
105
  body: response.to_json,
@@ -107,13 +107,13 @@ module Hephaestus
107
107
  end
108
108
 
109
109
  def assert_requested_get_messages_in_conversation(plug_installation_id, conversation_id, filter: "")
110
- assert_requested(:get, "#{::Hephaestus::YettoService::YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages?#{filter}")
110
+ assert_requested(:get, "#{::Hephaestus::YettoService::YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages?#{filter}")
111
111
  end
112
112
 
113
113
  def stub_get_messages_in_conversation(plug_installation_id, conversation_id, response, status: 200, filter: "")
114
114
  stub_post_access_token(plug_installation_id)
115
115
 
116
- stub_request(:get, "#{::Hephaestus::YettoService::YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages?#{filter}")
116
+ stub_request(:get, "#{::Hephaestus::YettoService::YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages?#{filter}")
117
117
  .to_return(
118
118
  status: status,
119
119
  headers: { content_type: "application/json; charset=utf-8" },
@@ -126,7 +126,7 @@ module Hephaestus
126
126
 
127
127
  response[:plug_installation] = { id: plug_installation_id }
128
128
 
129
- stub_request(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages")
129
+ stub_request(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages")
130
130
  .with(
131
131
  body: payload,
132
132
  )
@@ -138,17 +138,17 @@ module Hephaestus
138
138
  end
139
139
 
140
140
  def assert_requested_add_message_to_conversation(plug_installation_id, conversation_id)
141
- assert_requested(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages")
141
+ assert_requested(:post, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages")
142
142
  end
143
143
 
144
144
  def assert_requested_create_message(plug_installation_id, message_id)
145
- assert_requested(:post, "#{::Hephaestus::YettoService::YETTO_API_VERSION_TLD}/messages/#{message_id}/replies")
145
+ assert_requested(:post, "#{::Hephaestus::YettoService::YETTO_API_VERSION_URL}/messages/#{message_id}/replies")
146
146
  end
147
147
 
148
148
  def stub_create_message(plug_installation_id, message_id, payload)
149
149
  stub_post_access_token(plug_installation_id)
150
150
 
151
- stub_request(:post, "#{::Hephaestus::YettoService::YETTO_API_VERSION_TLD}/messages/#{message_id}/replies")
151
+ stub_request(:post, "#{::Hephaestus::YettoService::YETTO_API_VERSION_URL}/messages/#{message_id}/replies")
152
152
  .with(
153
153
  body: payload,
154
154
  )
@@ -160,12 +160,12 @@ module Hephaestus
160
160
  end
161
161
 
162
162
  def assert_requested_update_message(plug_installation_id, message_id)
163
- assert_requested(:patch, "#{::Hephaestus::YettoService::YETTO_API_VERSION_TLD}/messages/#{message_id}")
163
+ assert_requested(:patch, "#{::Hephaestus::YettoService::YETTO_API_VERSION_URL}/messages/#{message_id}")
164
164
  end
165
165
 
166
166
  def stub_update_message(plug_installation_id, message_id, payload)
167
167
  stub_post_access_token(plug_installation_id)
168
- stub_request(:patch, "#{::Hephaestus::YettoService::YETTO_API_VERSION_TLD}/messages/#{message_id}")
168
+ stub_request(:patch, "#{::Hephaestus::YettoService::YETTO_API_VERSION_URL}/messages/#{message_id}")
169
169
  .with(
170
170
  body: payload,
171
171
  )
@@ -177,13 +177,13 @@ module Hephaestus
177
177
  end
178
178
 
179
179
  def assert_requested_find_message_in_conversation_by_metadata(plug_installation_id, conversation_id)
180
- assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages?#{filter}")
180
+ assert_requested(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages?#{filter}")
181
181
  end
182
182
 
183
183
  def stub_find_message_in_conversation(plug_installation_id, conversation_id, response, status: 200, filter: "")
184
184
  stub_post_access_token(plug_installation_id)
185
185
 
186
- stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_TLD}/conversations/#{conversation_id}/messages?#{filter}")
186
+ stub_request(:get, "#{Hephaestus::YettoService::YETTO_API_VERSION_URL}/conversations/#{conversation_id}/messages?#{filter}")
187
187
  .to_return(
188
188
  status: status,
189
189
  headers: { content_type: "application/json; charset=utf-8" },
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Hephaestus
5
- VERSION = "0.8.15.5"
5
+ VERSION = "0.8.16.1"
6
6
  RAILS_VERSION = ">= 8.0"
7
7
  RUBY_VERSION = File
8
8
  .read("#{File.dirname(__FILE__)}/../../.ruby-version")
@@ -294,4 +294,4 @@ app/javascript/controllers/*.js
294
294
  !app/javascript/controllers/index.js
295
295
 
296
296
  security_results.json
297
- vendor/cache/
297
+ vendor/cache
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hephaestus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.15.5
4
+ version: 0.8.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-16 00:00:00.000000000 Z
11
+ date: 2025-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap