ap2_mandate_verifier 1.1.0 → 1.3.0
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/README.ja.md +21 -7
- data/README.md +21 -7
- data/docs/PAYMENT.md +3 -3
- data/docs/POST_RELEASE_110.md +39 -0
- data/docs/PUBLIC_API.md +14 -4
- data/docs/RELEASE_110_CANDIDATE.md +2 -0
- data/docs/RELEASE_120_CANDIDATE.md +34 -0
- data/docs/RELEASE_130_CANDIDATE.md +29 -0
- data/docs/SELECTIVE_CHECKOUT.md +70 -0
- data/docs/SELECTIVE_PAYMENT.md +67 -0
- data/docs/evidence/1.1.0_publication.json +101 -0
- data/examples/selective_checkout.rb +97 -0
- data/examples/selective_checkout_payment.rb +72 -0
- data/examples/selective_payment.rb +71 -0
- data/lib/ap2_mandate_verifier/checkout_jwt.rb +1 -1
- data/lib/ap2_mandate_verifier/input_builder.rb +1 -1
- data/lib/ap2_mandate_verifier/payment.rb +15 -4
- data/lib/ap2_mandate_verifier/root_disclosures.rb +8 -0
- data/lib/ap2_mandate_verifier/scoped_constraints.rb +1 -1
- data/lib/ap2_mandate_verifier/selective_checkout.rb +261 -0
- data/lib/ap2_mandate_verifier/selective_payment.rb +261 -0
- data/lib/ap2_mandate_verifier/trust_context.rb +6 -0
- data/lib/ap2_mandate_verifier.rb +2 -0
- metadata +17 -5
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AP2MandateVerifier
|
|
4
|
+
# Explicit conditional-Payment profile. Unknown hidden conditions are never
|
|
5
|
+
# inferred to be absent; unresolved commitments exist only at candidate slots.
|
|
6
|
+
module SelectivePayment
|
|
7
|
+
PROFILE_REF = "ap2.payment.selective_candidates.1".freeze
|
|
8
|
+
MAX_WIRE = 65_536
|
|
9
|
+
MAX_DISCLOSURES = 17
|
|
10
|
+
AXES = {"payment.allowed_payees" => "payee", "payment.allowed_payment_instruments" => "payment_instrument"}.freeze
|
|
11
|
+
class Invalid < ArgumentError
|
|
12
|
+
def initialize = super("invalid selective payment information")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# All candidates and their exact Cartesian authorization come from a
|
|
16
|
+
# protected approval record. This confidential issuance MUST NOT be sent.
|
|
17
|
+
def self.issue_open(open_checkout_sd_jwt:, constraints:, fixed:, approved_combinations:, selective:,
|
|
18
|
+
agent_public_key_pem:, issued_at:, expires_at:, signer:, public_key_pem:,
|
|
19
|
+
checkout_profile_ref: ScopedConstraints::MULTI_PROFILE_REF)
|
|
20
|
+
RootSignature.send(:dependencies!)
|
|
21
|
+
raise Invalid unless %i[payees instruments both].include?(selective)
|
|
22
|
+
checkout = Payment.send(:checkout_open!, open_checkout_sd_jwt, profile_ref: checkout_profile_ref)
|
|
23
|
+
cs = InputBuilder.send(:copy!, constraints)
|
|
24
|
+
raise Invalid unless cs.instance_of?(Array)
|
|
25
|
+
cs << {"type" => "payment.reference", "conditional_transaction_id" => digest(checkout)}
|
|
26
|
+
value = InputBuilder.send(:copy!, fixed)
|
|
27
|
+
raise Invalid unless value.instance_of?(Hash) && (value.keys - Payment::FIELDS.drop(1)).empty?
|
|
28
|
+
opening = value.merge("vct" => "mandate.payment.open.1", "iat" => issued_at, "exp" => expires_at,
|
|
29
|
+
"cnf" => {"jwk" => RootSignature.public_jwk!(agent_public_key_pem)}, "constraints" => cs)
|
|
30
|
+
Payment.send(:open!, opening)
|
|
31
|
+
payees = constraint!(opening, "payment.allowed_payees").fetch("allowed")
|
|
32
|
+
instruments = constraint!(opening, "payment.allowed_payment_instruments").fetch("allowed")
|
|
33
|
+
pairs = InputBuilder.send(:copy!, approved_combinations)
|
|
34
|
+
expected = payees.each_index.flat_map { |p| instruments.each_index.map { |i| [p, i] } }
|
|
35
|
+
raise Invalid unless pairs.instance_of?(Array) && pairs.size == expected.size && pairs.all? do |pair|
|
|
36
|
+
pair.instance_of?(Array) && pair.size == 2 && pair.all? { |n| Object.instance_method(:instance_of?).bind_call(n, Integer) }
|
|
37
|
+
end
|
|
38
|
+
raise Invalid unless pairs.sort == expected.sort
|
|
39
|
+
AXES.each do |type, field|
|
|
40
|
+
raise Invalid if opening.key?(field) && !constraint!(opening, type).fetch("allowed").include?(opening[field])
|
|
41
|
+
end
|
|
42
|
+
disclosures = []
|
|
43
|
+
modes = selective == :both ? AXES.keys : [selective == :payees ? AXES.keys[0] : AXES.keys[1]]
|
|
44
|
+
modes.each do |type|
|
|
45
|
+
c = constraint!(opening, type)
|
|
46
|
+
c["allowed"] = c["allowed"].map { |candidate| disclose!(candidate, disclosures) }
|
|
47
|
+
end
|
|
48
|
+
content = []
|
|
49
|
+
pointer = disclose!(opening, content)
|
|
50
|
+
payload = {"ap2_profile" => PROFILE_REF, "_sd_alg" => "sha-256", "delegate_payload" => [pointer]}
|
|
51
|
+
preview = [encode({"alg" => "ES256", "typ" => "example+sd-jwt"}), encode(payload), encode("\0" * 64)].join(".")
|
|
52
|
+
wire = ([preview] + content + disclosures + [""]).join("~")
|
|
53
|
+
parse!(wire, complete: true) # Full wire/disclosure bounds BEFORE signer effects.
|
|
54
|
+
jwt = MerchantSignature.sign!(payload, signer, public_key_pem, typ: "example+sd-jwt")
|
|
55
|
+
([jwt] + content + disclosures + [""]).join("~").freeze
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Each selective index selects one original signed candidate slot. For an
|
|
59
|
+
# inline/nonselective axis, pass nil: every approved inline value is visible.
|
|
60
|
+
def self.select(open_sd_jwt:, payee_index:, instrument_index:)
|
|
61
|
+
parsed = parse!(open_sd_jwt, complete: true)
|
|
62
|
+
keep = [parsed.fetch(:content_digest)]
|
|
63
|
+
{"payment.allowed_payees" => payee_index, "payment.allowed_payment_instruments" => instrument_index}.each do |type, index|
|
|
64
|
+
c = constraint!(parsed.fetch(:original), type)
|
|
65
|
+
slots = parsed.fetch(:slots).fetch(type)
|
|
66
|
+
if slots.empty?
|
|
67
|
+
raise Invalid unless index.nil?
|
|
68
|
+
else
|
|
69
|
+
raise Invalid unless Object.instance_method(:instance_of?).bind_call(index, Integer) && index.between?(0, slots.size - 1)
|
|
70
|
+
keep << slots.fetch(index)
|
|
71
|
+
field = AXES.fetch(type)
|
|
72
|
+
selected = parsed.fetch(:values).fetch(slots.fetch(index))
|
|
73
|
+
raise Invalid if parsed.fetch(:original).key?(field) && parsed.fetch(:original)[field] != selected
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
wire = ([parsed.fetch(:compact)] + parsed.fetch(:disclosures).select { |d| keep.include?(digest(d)) } + [""]).join("~")
|
|
77
|
+
parse!(wire, complete: false)
|
|
78
|
+
wire.freeze
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.issue_closed(open_presentation:, payment:, trusted_provider_public_key_pem:, agent_public_key_pem:,
|
|
82
|
+
audience:, nonce:, verified_at:, signer:)
|
|
83
|
+
agent = InputValidator.snapshot!(agent_public_key_pem, max_bytes: 1_024)
|
|
84
|
+
provider = InputValidator.snapshot!(trusted_provider_public_key_pem, max_bytes: 1_024)
|
|
85
|
+
aud = InputValidator.snapshot!(audience, max_bytes: 512)
|
|
86
|
+
challenge = InputValidator.snapshot!(nonce, max_bytes: 512)
|
|
87
|
+
parsed = authenticated!(open_presentation, provider)
|
|
88
|
+
opening = parsed.fetch(:opening)
|
|
89
|
+
Payment.send(:valid_now!, opening, verified_at)
|
|
90
|
+
raise Invalid unless opening.fetch("cnf") == {"jwk" => RootSignature.public_jwk!(agent)}
|
|
91
|
+
closed = Payment.send(:copy_details!, payment).merge("vct" => "mandate.payment.1", "iat" => verified_at, "exp" => opening.fetch("exp"))
|
|
92
|
+
Payment.send(:closed!, closed); Payment.send(:conditions!, opening, closed)
|
|
93
|
+
Payment.send(:text!, aud, 512); Payment.send(:text!, challenge, 512)
|
|
94
|
+
claims = {"delegate_payload" => [closed], "iat" => verified_at, "aud" => aud, "nonce" => challenge,
|
|
95
|
+
"sd_hash" => digest(parsed.fetch(:wire))}
|
|
96
|
+
Payment.send(:preflight!, claims, "kb+sd-jwt")
|
|
97
|
+
terminal = MerchantSignature.sign!(claims, signer, agent, typ: "kb+sd-jwt")
|
|
98
|
+
Payment::Presentation.send(:new, parsed.fetch(:wire), terminal + "~")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Structural restoration only. It never authenticates a stored presentation.
|
|
102
|
+
def self.present(open_presentation:, closed_sd_jwt:)
|
|
103
|
+
root = parse!(open_presentation, complete: false)
|
|
104
|
+
terminal, wire = Payment.send(:final!, closed_sd_jwt, conditional: true)
|
|
105
|
+
closed = terminal.fetch("delegate_payload").first
|
|
106
|
+
bind_terminal!(root, terminal, closed)
|
|
107
|
+
Payment::Presentation.send(:new, root.fetch(:wire), wire)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.verify(open_presentation:, closed_sd_jwt:, checkout_inputs:, expected_payment:,
|
|
111
|
+
trusted_provider_public_key_pem:, expected_agent_public_key_pem:,
|
|
112
|
+
expected_audience:, expected_nonce:, verified_at:)
|
|
113
|
+
CheckoutReceipt.send(:epoch!, verified_at)
|
|
114
|
+
agent = InputValidator.snapshot!(expected_agent_public_key_pem, max_bytes: 1_024)
|
|
115
|
+
provider = InputValidator.snapshot!(trusted_provider_public_key_pem, max_bytes: 1_024)
|
|
116
|
+
aud = InputValidator.snapshot!(expected_audience, max_bytes: 512)
|
|
117
|
+
nonce = InputValidator.snapshot!(expected_nonce, max_bytes: 512)
|
|
118
|
+
fields = %i[trust_json selection_json host_json root_presentation terminal_jws host_checkout_jws verified_at]
|
|
119
|
+
raise Invalid unless checkout_inputs.instance_of?(Hash) && checkout_inputs.size == fields.size &&
|
|
120
|
+
fields.all? { |f| checkout_inputs.key?(f) } && checkout_inputs[:verified_at] == verified_at
|
|
121
|
+
limits = {host_json: 32_768, terminal_jws: 32_768, host_checkout_jws: 16_384}
|
|
122
|
+
inputs = checkout_inputs.to_h do |key, value|
|
|
123
|
+
[key, key == :verified_at ? value : InputValidator.snapshot!(value, max_bytes: limits.fetch(key, 131_072))]
|
|
124
|
+
end.freeze
|
|
125
|
+
raise Invalid unless inputs.size == fields.size && fields.all? { |f| inputs.key?(f) } && inputs[:verified_at] == verified_at
|
|
126
|
+
expected = Payment.send(:copy_details!, expected_payment)
|
|
127
|
+
checkout = AP2MandateVerifier.verify_checkout(**inputs)
|
|
128
|
+
raise Invalid unless checkout.success?
|
|
129
|
+
raise Invalid unless expected.fetch("transaction_id") == digest(inputs.fetch(:host_checkout_jws))
|
|
130
|
+
binding = checkout.evidence["checkout_binding"]
|
|
131
|
+
amount = expected.fetch("payment_amount")
|
|
132
|
+
raise Invalid unless expected.fetch("payee").fetch("id") == binding.fetch("merchant_id") &&
|
|
133
|
+
amount.fetch("currency") == binding.fetch("currency") && amount.fetch("amount") == binding.fetch("expected_total")
|
|
134
|
+
Payment.send(:bind_checkout!, expected, Payment.send(:jwt_payload!, inputs.fetch(:host_checkout_jws), "JWT"))
|
|
135
|
+
parsed = authenticated!(open_presentation, provider)
|
|
136
|
+
opening = parsed.fetch(:opening)
|
|
137
|
+
Payment.send(:valid_now!, opening, verified_at)
|
|
138
|
+
raise Invalid unless opening.fetch("cnf") == {"jwk" => RootSignature.public_jwk!(agent)}
|
|
139
|
+
terminal, wire = Payment.send(:final!, closed_sd_jwt, conditional: true)
|
|
140
|
+
RootSignature.verified_payload!(wire.split("~", -1).first, agent,
|
|
141
|
+
expected_typ: "kb+sd-jwt", max_bytes: 32_768)
|
|
142
|
+
Payment.send(:text!, aud, 512); Payment.send(:text!, nonce, 512)
|
|
143
|
+
raise Invalid unless terminal.fetch("aud") == aud && terminal.fetch("nonce") == nonce &&
|
|
144
|
+
terminal.fetch("iat") <= verified_at && verified_at - terminal.fetch("iat") <= 300
|
|
145
|
+
closed = terminal.fetch("delegate_payload").first
|
|
146
|
+
bind_terminal!(parsed, terminal, closed)
|
|
147
|
+
Payment.send(:valid_now!, closed, verified_at)
|
|
148
|
+
ref = constraint!(opening, "payment.reference").fetch("conditional_transaction_id")
|
|
149
|
+
raise Invalid unless ref == digest(inputs.fetch(:root_presentation)) && closed.slice(*Payment::FIELDS) == expected
|
|
150
|
+
Payment::Verification.send(:new, closed, wire)
|
|
151
|
+
rescue StandardError, LoadError
|
|
152
|
+
Payment::Verification.send(:new)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def self.bind_terminal!(root, terminal, closed)
|
|
156
|
+
opening = root.fetch(:opening)
|
|
157
|
+
Payment.send(:closed!, closed)
|
|
158
|
+
raise Invalid unless terminal.fetch("sd_hash") == digest(root.fetch(:wire)) && terminal.fetch("iat") == closed.fetch("iat") &&
|
|
159
|
+
closed.fetch("iat") >= opening.fetch("iat") && closed.fetch("exp") <= opening.fetch("exp")
|
|
160
|
+
Payment.send(:conditions!, opening, closed)
|
|
161
|
+
end
|
|
162
|
+
def self.authenticated!(wire, key)
|
|
163
|
+
parsed = parse!(wire, complete: false)
|
|
164
|
+
RootSignature.verified_payload!(parsed.fetch(:compact), key, max_bytes: 16_384)
|
|
165
|
+
parsed
|
|
166
|
+
end
|
|
167
|
+
def self.parse!(source, complete:)
|
|
168
|
+
RootSignature.send(:dependencies!)
|
|
169
|
+
wire = InputValidator.snapshot!(source, max_bytes: MAX_WIRE)
|
|
170
|
+
raise Invalid unless wire.ascii_only? && wire.end_with?("~")
|
|
171
|
+
compact, *disclosures = wire.split("~", -1)
|
|
172
|
+
disclosures.pop
|
|
173
|
+
raise Invalid unless disclosures.size.between?(2, MAX_DISCLOSURES) && disclosures.none?(&:empty?)
|
|
174
|
+
compact = InputValidator.snapshot!(compact, max_bytes: 16_384)
|
|
175
|
+
claims = Payment.send(:jwt_payload!, compact, "example+sd-jwt")
|
|
176
|
+
Payment.send(:exact!, claims, %w[ap2_profile _sd_alg delegate_payload])
|
|
177
|
+
raise Invalid unless claims["ap2_profile"] == PROFILE_REF && claims["_sd_alg"] == "sha-256" &&
|
|
178
|
+
claims["delegate_payload"].instance_of?(Array) && claims["delegate_payload"].size == 1
|
|
179
|
+
pointer = claims.fetch("delegate_payload").first
|
|
180
|
+
Payment.send(:exact!, pointer, ["..."])
|
|
181
|
+
hash!(pointer["..."])
|
|
182
|
+
values = {}; salts = []
|
|
183
|
+
disclosures.each do |disclosure|
|
|
184
|
+
value = Buyer.send(:decode_disclosure!, disclosure, 2)
|
|
185
|
+
hash = digest(disclosure)
|
|
186
|
+
raise Invalid if values.key?(hash) || salts.include?(value[0])
|
|
187
|
+
salts << value[0]
|
|
188
|
+
values[hash] = value[1]
|
|
189
|
+
end
|
|
190
|
+
content_digest = pointer.fetch("...")
|
|
191
|
+
original = values.fetch(content_digest)
|
|
192
|
+
raise Invalid unless original.instance_of?(Hash) && original["constraints"].instance_of?(Array)
|
|
193
|
+
opening = InputBuilder.send(:copy!, original)
|
|
194
|
+
slots = {}; used = [content_digest]; all_commitments = [content_digest]
|
|
195
|
+
AXES.each do |type, field|
|
|
196
|
+
c = constraint!(opening, type)
|
|
197
|
+
Payment.send(:exact!, c, %w[type allowed])
|
|
198
|
+
list = c.fetch("allowed")
|
|
199
|
+
raise Invalid unless list.instance_of?(Array) && list.size.between?(1, 8)
|
|
200
|
+
markers = list.map { |item| item.instance_of?(Hash) && item.keys == ["..."] }
|
|
201
|
+
raise Invalid unless markers.all? || markers.none?
|
|
202
|
+
slots[type] = []
|
|
203
|
+
if markers.all?
|
|
204
|
+
selected = []
|
|
205
|
+
list.each do |item|
|
|
206
|
+
h = item.fetch("..."); hash!(h)
|
|
207
|
+
raise Invalid if all_commitments.include?(h)
|
|
208
|
+
all_commitments << h; slots[type] << h
|
|
209
|
+
if values.key?(h)
|
|
210
|
+
selected << values.fetch(h); used << h
|
|
211
|
+
elsif complete
|
|
212
|
+
raise Invalid
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
raise Invalid unless complete ? selected.size == list.size : selected.size == 1
|
|
216
|
+
c["allowed"] = selected
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
raise Invalid if slots.values.all?(&:empty?)
|
|
220
|
+
raise Invalid unless used.sort == values.keys.sort
|
|
221
|
+
Payment.send(:open!, opening) # Only candidate markers were resolved/omitted.
|
|
222
|
+
{wire: wire, compact: compact, disclosures: disclosures, opening: opening,
|
|
223
|
+
original: original, content_digest: content_digest, slots: slots, values: values}
|
|
224
|
+
end
|
|
225
|
+
def self.constraint!(opening, type)
|
|
226
|
+
cs = opening.fetch("constraints")
|
|
227
|
+
raise Invalid unless cs.instance_of?(Array)
|
|
228
|
+
found = cs.select { |c| c.instance_of?(Hash) && c["type"] == type }
|
|
229
|
+
raise Invalid unless found.size == 1
|
|
230
|
+
found.first
|
|
231
|
+
end
|
|
232
|
+
def self.disclose!(value, disclosures)
|
|
233
|
+
require "securerandom"
|
|
234
|
+
wire = encode([encode(SecureRandom.random_bytes(16)), value])
|
|
235
|
+
disclosures << wire
|
|
236
|
+
{"..." => digest(wire)}
|
|
237
|
+
end
|
|
238
|
+
def self.hash!(value)
|
|
239
|
+
raise Invalid unless value.instance_of?(String) && value.match?(/\A[A-Za-z0-9_-]{43}\z/)
|
|
240
|
+
end
|
|
241
|
+
def self.encode(value) = Buyer.send(:encode, value)
|
|
242
|
+
def self.digest(wire) = Payment.send(:digest, wire)
|
|
243
|
+
|
|
244
|
+
%i[issue_open select issue_closed present verify].each do |name|
|
|
245
|
+
implementation = method(name)
|
|
246
|
+
required = implementation.parameters.filter_map { |kind, field| field if kind == :keyreq }.freeze
|
|
247
|
+
fields = implementation.parameters.map(&:last).freeze
|
|
248
|
+
define_singleton_method(name) do |**args|
|
|
249
|
+
unless (required - args.keys).empty? && (args.keys - fields).empty?
|
|
250
|
+
next Payment::Verification.send(:new) if name == :verify
|
|
251
|
+
raise Invalid
|
|
252
|
+
end
|
|
253
|
+
implementation.call(**args)
|
|
254
|
+
rescue StandardError, LoadError
|
|
255
|
+
next Payment::Verification.send(:new) if name == :verify
|
|
256
|
+
raise Invalid.new, cause: nil
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
singleton_methods(false).reject { |n| %i[issue_open select issue_closed present verify].include?(n) }.each { |n| private_class_method n }
|
|
260
|
+
end
|
|
261
|
+
end
|
|
@@ -12,6 +12,10 @@ module AP2MandateVerifier
|
|
|
12
12
|
MULTI_PROFILE_VERSION = "1"
|
|
13
13
|
MULTI_PROFILE_BODY = '{"profile_ref":"ap2.checkout.single_merchant_multi_item","version":"1","ap2_source":"b4587ac1d055888a73b4b21750973cffba961793","algorithm":"ES256","key_format":"canonical-public-SPKI-P256-SHA256","root_type":"example+sd-jwt","terminal_type":"kb+sd-jwt","checkout_type":"JWT","disclosure_path_semantics":"root-walker-with-synthetic-disclosed-edges","disclosure_positions":["delegate_payload[0]","delegate_payload[0].disclosed.constraints[0].items[*].acceptable_items[*]","delegate_payload[0].disclosed.constraints[1].allowed[0]"],"constraints":["checkout.line_items","checkout.allowed_merchants"],"max_disclosures":66,"max_disclosure_segment_bytes":8192,"max_root_bytes":131072,"max_graph_nodes":2048,"max_graph_depth":24,"max_array_entries":16,"max_line_items":8,"max_requirements":8,"max_candidates_per_requirement":8,"quantity_matching":"integer-max-flow-product-id-exact-coverage","duplicate_line_ids":"reject","duplicate_requirement_ids":"reject","same_product_multiple_lines":"allow","amount_model":"integer-minor-unit-no-tax-shipping-discount"}'.freeze
|
|
14
14
|
MULTI_PROFILE_HASH = Digest::SHA256.hexdigest(MULTI_PROFILE_BODY).freeze
|
|
15
|
+
SELECTIVE_PROFILE_REF = "ap2.checkout.selective_candidates.1".freeze
|
|
16
|
+
SELECTIVE_PROFILE_VERSION = "1".freeze
|
|
17
|
+
SELECTIVE_PROFILE_BODY = '{"profile_ref":"ap2.checkout.selective_candidates.1","version":"1","ap2_source":"b4587ac1d055888a73b4b21750973cffba961793","algorithm":"ES256","root_type":"example+sd-jwt","terminal_type":"kb+sd-jwt","checkout_type":"JWT","signed_profile_marker":"ap2_profile","mandatory_content":"all-requirements-id-quantity-cnf-iat-exp","selective_positions":["constraints[0].items[*].acceptable_items[*]","constraints[1].allowed[*]"],"max_disclosures":73,"max_disclosure_segment_bytes":8192,"max_root_bytes":131072,"max_requirements":8,"max_candidates_per_requirement":8,"max_merchants":8,"merchant_selection":"exactly-one","item_selection":"nonempty-subset-per-requirement","candidate_policy":"independent-lists-no-correlation","quantity_matching":"integer-max-flow-product-id-exact-coverage","amount_model":"integer-minor-unit-no-tax-shipping-discount"}'.freeze
|
|
18
|
+
SELECTIVE_PROFILE_HASH = Digest::SHA256.hexdigest(SELECTIVE_PROFILE_BODY).freeze
|
|
15
19
|
|
|
16
20
|
# Explicit Host policy registration. Signed token claims never select this.
|
|
17
21
|
def self.profile!(reference)
|
|
@@ -20,6 +24,8 @@ module AP2MandateVerifier
|
|
|
20
24
|
{ref: PROFILE_REF, version: PROFILE_VERSION, body: PROFILE_BODY, hash: PROFILE_HASH}.freeze
|
|
21
25
|
when MULTI_PROFILE_REF
|
|
22
26
|
{ref: MULTI_PROFILE_REF, version: MULTI_PROFILE_VERSION, body: MULTI_PROFILE_BODY, hash: MULTI_PROFILE_HASH}.freeze
|
|
27
|
+
when SELECTIVE_PROFILE_REF
|
|
28
|
+
{ref: SELECTIVE_PROFILE_REF, version: SELECTIVE_PROFILE_VERSION, body: SELECTIVE_PROFILE_BODY, hash: SELECTIVE_PROFILE_HASH}.freeze
|
|
23
29
|
else
|
|
24
30
|
reject!(:unsupported_trust_profile)
|
|
25
31
|
end
|
data/lib/ap2_mandate_verifier.rb
CHANGED
|
@@ -17,6 +17,8 @@ require_relative "ap2_mandate_verifier/buyer"
|
|
|
17
17
|
require_relative "ap2_mandate_verifier/conditional_checkout"
|
|
18
18
|
require_relative "ap2_mandate_verifier/payment"
|
|
19
19
|
require_relative "ap2_mandate_verifier/payment_receipt"
|
|
20
|
+
require_relative "ap2_mandate_verifier/selective_payment"
|
|
21
|
+
require_relative "ap2_mandate_verifier/selective_checkout"
|
|
20
22
|
|
|
21
23
|
module AP2MandateVerifier
|
|
22
24
|
# Accepts original JSON bytes only. Syntax validity is not AP2 validity,
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ap2_mandate_verifier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- AP2 Mandate Verifier contributors
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-11-04 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: json
|
|
@@ -82,8 +82,9 @@ dependencies:
|
|
|
82
82
|
description: 'Framework-independent Ruby SDK for supported AP2 Checkout profiles:
|
|
83
83
|
Merchant JWT signing, Direct and conditional Mandate issuance and presentation,
|
|
84
84
|
full verification with immutable Evidence, Checkout Receipts, Direct and conditional
|
|
85
|
-
Payment Mandates, and Payment Receipts.
|
|
86
|
-
|
|
85
|
+
Payment Mandates, and Payment Receipts. Adds opt-in selective Checkout and Payment
|
|
86
|
+
candidate disclosure. Requires independently trusted application inputs; verification
|
|
87
|
+
does not grant purchase or payment permission.'
|
|
87
88
|
executables: []
|
|
88
89
|
extensions: []
|
|
89
90
|
extra_rdoc_files: []
|
|
@@ -100,13 +101,22 @@ files:
|
|
|
100
101
|
- docs/MERCHANT_SIGNING.md
|
|
101
102
|
- docs/MULTI_ITEM_CHECKOUT.md
|
|
102
103
|
- docs/PAYMENT.md
|
|
104
|
+
- docs/POST_RELEASE_110.md
|
|
103
105
|
- docs/POST_RELEASE_MAINTENANCE.md
|
|
104
106
|
- docs/PUBLIC_API.md
|
|
105
107
|
- docs/RELEASE_100_CANDIDATE.md
|
|
106
108
|
- docs/RELEASE_110_CANDIDATE.md
|
|
109
|
+
- docs/RELEASE_120_CANDIDATE.md
|
|
110
|
+
- docs/RELEASE_130_CANDIDATE.md
|
|
111
|
+
- docs/SELECTIVE_CHECKOUT.md
|
|
112
|
+
- docs/SELECTIVE_PAYMENT.md
|
|
107
113
|
- docs/SUPPORT_CONTRACT.md
|
|
114
|
+
- docs/evidence/1.1.0_publication.json
|
|
108
115
|
- examples/conditional_checkout.rb
|
|
109
116
|
- examples/payment.rb
|
|
117
|
+
- examples/selective_checkout.rb
|
|
118
|
+
- examples/selective_checkout_payment.rb
|
|
119
|
+
- examples/selective_payment.rb
|
|
110
120
|
- lib/ap2_mandate_verifier.rb
|
|
111
121
|
- lib/ap2_mandate_verifier/buyer.rb
|
|
112
122
|
- lib/ap2_mandate_verifier/checkout_jwt.rb
|
|
@@ -125,6 +135,8 @@ files:
|
|
|
125
135
|
- lib/ap2_mandate_verifier/root_disclosures.rb
|
|
126
136
|
- lib/ap2_mandate_verifier/root_signature.rb
|
|
127
137
|
- lib/ap2_mandate_verifier/scoped_constraints.rb
|
|
138
|
+
- lib/ap2_mandate_verifier/selective_checkout.rb
|
|
139
|
+
- lib/ap2_mandate_verifier/selective_payment.rb
|
|
128
140
|
- lib/ap2_mandate_verifier/trust_context.rb
|
|
129
141
|
homepage: https://github.com/cuichangquan/ap2-mandate-verifier
|
|
130
142
|
licenses:
|
|
@@ -147,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
147
159
|
- !ruby/object:Gem::Version
|
|
148
160
|
version: '0'
|
|
149
161
|
requirements: []
|
|
150
|
-
rubygems_version:
|
|
162
|
+
rubygems_version: 3.6.9
|
|
151
163
|
specification_version: 4
|
|
152
164
|
summary: Ruby SDK for supported AP2 Checkout and Payment Mandates
|
|
153
165
|
test_files: []
|