@@ -28,7 +28,7 @@ def tool_verify(http_method:, uri:, signature:, signature_input:, signature_agen
2828 end
2929
3030 def agent_headers ( http_method :, uri :, private_jwk :, id :)
31- private_jwk = serialize_json_arg ( private_jwk , name : "private_jwk" )
31+ private_jwk = private_jwk . as_json . to_json
3232
3333 command = [
3434 @executable ,
@@ -46,7 +46,7 @@ def agent_headers(http_method:, uri:, private_jwk:, id:)
4646 end
4747
4848 def primitives_verify ( http_method :, uri :, signature_header :, signature_input_header :, public_jwk :)
49- public_jwk = serialize_json_arg ( public_jwk , name : "public_jwk" )
49+ public_jwk = public_jwk . as_json . to_json
5050
5151 command = [
5252 @executable ,
@@ -75,33 +75,5 @@ def run_json_command(command_args)
7575
7676 JSON . parse ( stdout )
7777 end
78-
79- def serialize_json_arg ( value , name :)
80- return value if value . is_a? ( String )
81-
82- return JSON . generate ( value ) if value . is_a? ( Hash ) || value . is_a? ( Array )
83-
84- if value . respond_to? ( :to_h )
85- json = serialize_json_arg_from_to_h ( value )
86- return json unless json . nil?
87- end
88- return JSON . generate ( value . as_json ) if value . respond_to? ( :as_json )
89-
90- raise ArgumentError , "#{ name } must be a JSON string, Hash/Array, or object responding to #to_h"
91- end
92-
93- def serialize_json_arg_from_to_h ( value )
94- JSON . generate ( value . to_h )
95- rescue StandardError => e
96- raise unless action_controller_unfiltered_parameters? ( e )
97-
98- nil
99- end
100-
101- def action_controller_unfiltered_parameters? ( error )
102- error . instance_of? ( Object . const_get ( "ActionController::UnfilteredParameters" ) )
103- rescue NameError
104- false
105- end
10678 end
10779end
0 commit comments