Class: AgentAdmit::AppAttestedPresence
- Inherits:
-
Object
- Object
- AgentAdmit::AppAttestedPresence
- Defined in:
- lib/agentadmit/app_attested_presence.rb
Overview
App-attested presence: a ceremony fact your app attests at token issuance.
Pass an instance to TokensClient#issue_token AFTER verifying and consuming
your app's own fresh, purpose-bound WebAuthn/passkey attestation for the
mint. The SDK forwards it to the hosted mint as
presence true, uv: true, method, verified_at; the hosted
service stores it method-prefixed "app:
Honesty ceiling: this is YOUR attestation, recorded and provenance-marked. It is not witnessed by AgentAdmit and not independently verifiable. Only construct one for a ceremony that verified the user with UV (biometric or PIN user verification); verified/uv serialize as literal true and cannot represent anything else — a ceremony without UV carries no presence fact, so simply pass nil.
verified_at must be recent: the hosted service enforces a 10-minute freshness window with 60 seconds of future clock-skew slack. Ruby Time and DateTime always carry an offset, so #iso8601 serializes RFC 3339 with an explicit offset by construction (the hosted contract; offset-less timestamps are rejected with 400).
Constant Summary collapse
- METHOD_PATTERN =
/\A[a-z0-9_]+\z/- METHOD_MAX_LENGTH =
60
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
NOTE: a
methodreader shadows Object#method on instances — the same trade stdlib's Net::HTTPGenericRequest makes; the name matches the wire field. -
#verified_at ⇒ Object
readonly
NOTE: a
methodreader shadows Object#method on instances — the same trade stdlib's Net::HTTPGenericRequest makes; the name matches the wire field.
Instance Method Summary collapse
-
#initialize(method:, verified_at:) ⇒ AppAttestedPresence
constructor
A new instance of AppAttestedPresence.
-
#to_wire ⇒ Hash
The exact JSON object forwarded to the hosted mint.
Constructor Details
#initialize(method:, verified_at:) ⇒ AppAttestedPresence
Returns a new instance of AppAttestedPresence.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/agentadmit/app_attested_presence.rb', line 46 def initialize(method:, verified_at:) unless method.is_a?(String) && !method.empty? && method.length <= METHOD_MAX_LENGTH && METHOD_PATTERN.match?(method) raise ArgumentError, "method must be 1-#{METHOD_MAX_LENGTH} lowercase alphanumeric/underscore " \ "characters (e.g. 'my_webauthn')" end unless verified_at.respond_to?(:iso8601) raise ArgumentError, "verified_at must be a Time or DateTime (the ceremony that authorized " \ "this mint just happened)" end @method = method @verified_at = verified_at end |
Instance Attribute Details
#method ⇒ Object (readonly)
NOTE: a method reader shadows Object#method on instances — the same
trade stdlib's Net::HTTPGenericRequest makes; the name matches the wire
field.
36 37 38 |
# File 'lib/agentadmit/app_attested_presence.rb', line 36 def method @method end |
#verified_at ⇒ Object (readonly)
NOTE: a method reader shadows Object#method on instances — the same
trade stdlib's Net::HTTPGenericRequest makes; the name matches the wire
field.
36 37 38 |
# File 'lib/agentadmit/app_attested_presence.rb', line 36 def verified_at @verified_at end |
Instance Method Details
#to_wire ⇒ Hash
The exact JSON object forwarded to the hosted mint.
68 69 70 71 72 73 74 75 |
# File 'lib/agentadmit/app_attested_presence.rb', line 68 def to_wire { "verified" => true, "uv" => true, "method" => @method, "verified_at" => @verified_at.iso8601 } end |