Class: Mpp::Extensions::MCP::MCPCredential
- Inherits:
-
Data
- Object
- Data
- Mpp::Extensions::MCP::MCPCredential
- Defined in:
- lib/mpp/extensions/mcp/types.rb
Instance Attribute Summary collapse
-
#challenge ⇒ Object
readonly
Returns the value of attribute challenge.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(challenge:, payload:, source: nil) ⇒ MCPCredential
constructor
A new instance of MCPCredential.
- #to_core ⇒ Object
- #to_dict ⇒ Object
- #to_meta ⇒ Object
Constructor Details
#initialize(challenge:, payload:, source: nil) ⇒ MCPCredential
Returns a new instance of MCPCredential.
74 75 76 |
# File 'lib/mpp/extensions/mcp/types.rb', line 74 def initialize(challenge:, payload:, source: nil) super end |
Instance Attribute Details
#challenge ⇒ Object (readonly)
Returns the value of attribute challenge
73 74 75 |
# File 'lib/mpp/extensions/mcp/types.rb', line 73 def challenge @challenge end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload
73 74 75 |
# File 'lib/mpp/extensions/mcp/types.rb', line 73 def payload @payload end |
#source ⇒ Object (readonly)
Returns the value of attribute source
73 74 75 |
# File 'lib/mpp/extensions/mcp/types.rb', line 73 def source @source end |
Class Method Details
.from_core(credential, challenge) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/mpp/extensions/mcp/types.rb', line 132 def self.from_core(credential, challenge) new( challenge: challenge, payload: credential.payload, source: credential.source ) end |
.from_dict(data) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/mpp/extensions/mcp/types.rb', line 91 def self.from_dict(data) new( challenge: MCPChallenge.from_dict(data["challenge"]), payload: data["payload"], source: data["source"] ) end |
.from_meta(meta) ⇒ Object
99 100 101 102 103 |
# File 'lib/mpp/extensions/mcp/types.rb', line 99 def self.() return nil unless .key?(META_CREDENTIAL) from_dict([META_CREDENTIAL]) end |
Instance Method Details
#to_core ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/mpp/extensions/mcp/types.rb', line 105 def to_core request_json = Mpp::Json.compact_encode(challenge.request) request_b64 = Base64.urlsafe_encode64(request_json, padding: false) opaque_b64 = nil if challenge.opaque opaque_json = Mpp::Json.compact_encode(challenge.opaque) opaque_b64 = Base64.urlsafe_encode64(opaque_json, padding: false) end echo = Mpp::ChallengeEcho.new( id: challenge.id, realm: challenge.realm, method: challenge.method, intent: challenge.intent, request: request_b64, expires: challenge.expires, digest: challenge.digest, opaque: opaque_b64 ) Mpp::Credential.new( challenge: echo, payload: payload, source: source ) end |
#to_dict ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/mpp/extensions/mcp/types.rb', line 78 def to_dict result = { "challenge" => challenge.to_dict, "payload" => payload } result["source"] = source if source result end |
#to_meta ⇒ Object
87 88 89 |
# File 'lib/mpp/extensions/mcp/types.rb', line 87 def {META_CREDENTIAL => to_dict} end |