Repository navigation
Support session credentials for identity verification - #22
Conversation
Orders on the Crossmint KYC UI send {verificationId, clientSecret, deviceSessionKey?}
in payment.preparation.kyc. Decode and encode that shape next to the Persona one,
make the Persona-only properties optional, log the stable id and the shape instead
of the inquiry id, and redact deviceSessionKey in logs.
With the session flow the order leaves requires-kyc when the buyer submits, before the flow shows its result. The README and demo present the sheet when the order has new credentials and close it from onComplete or onCancel.
The README and demo presented the sheet again on a rotated clientSecret or a new sessionToken after the buyer cancelled or swiped it away. Latch the close in the sheet's onDismiss and stop presenting for that order, and describe the full rule in the view's documentation.
Test that complete session keys win over Persona keys and that an incomplete session falls back to Persona. Keep a non-string deviceSessionKey from dropping the whole session, and log hasSessionToken only for Persona credentials, as Kotlin does.
|
[codex] Can we preserve the original The new Please consider a round-trip test with an extra nested field and an unfamiliar credential shape. Preserve structural JSON equality and secret-rotation detection, and keep raw credentials out of logs. This is a forward-compatibility design concern; the current PR does address today's session format. |
The README and demo kept a single kycClosed flag, so after the first close the sheet never presented again, even for a later order that needs verification. Remember the id of the order whose sheet closed and present again for any other order. Key it by the order id because a verification or inquiry id can repeat across orders.
String(describing:), interpolation and String(reflecting:) printed the clientSecret, sessionToken and deviceSessionKey. Describe the credentials by their shape and stable id only.
|
Keeping typed parsing for now, reasoning in ID-692. We'll revisit with ID-658. |
This pull request lets the SDK read the identity verification credentials of orders on the new Crossmint KYC UI. Those orders carry
{ verificationId, clientSecret, deviceSessionKey }inpayment.preparation.kycinstead of a Persona inquiry. Today the decoder rejects that shape and logscheckout.order.kyc.decodeError, soidentityVerificationCredentialsisnil. An app onidentityVerificationHandling: .externalnever shows the step, and the order waits atrequires-kyc.Part of ID-693.
Usage
Changes
IdentityVerificationCredentialsdecodes both shapes: the session shape whenverificationIdandclientSecretare non-empty, the Persona rules otherwise. It sends each shape to the hosted page as it came. The Persona JSON is unchanged.init(verificationId:clientSecret:deviceSessionKey:).init(inquiryId:sessionToken:)is unchanged.idis the verification id for a session and the inquiry id for Persona, so a rotatedclientSecretupdates the open sheet instead of presenting a new one. Equality still compares every field.credentialsIdandcredentialsShape(personaorsession) replaceinquiryId, andhasSessionTokenis logged for Persona only. The scrubber now also redactsdeviceSessionKey. Datadog queries on@inquiryIdfor this SDK need the new key.onCompleteoronCancel, and keep it closed for that order, including after a swipe dismiss. With the session flow the order leavesrequires-kycas soon as the buyer submits, before the result screen, so the old example closed the sheet too early.Breaking change
inquiryIdandproviderare nowString?. Both arenilfor session credentials, and so issessionToken. Code that only passes the credentials toCrossmintIdentityVerificationbuilds unchanged. The release that ships this needs a version that says so.Tests
deviceSessionKey, which shape wins when an order carries both sets of keys, invalid shapes, id and equality, session credentials in the hosted URL, the controller exposing session credentials from an order update, scrubber redaction, and the log attributes.xcodebuild teston the iPhone 17 simulator: 146 tests pass. The CheckoutDemo builds for the simulator.verified, and the order moved toawaiting-payment. The sheet stayed open after the order leftrequires-kycand closed only fromonComplete.A rotated secret reloads the hosted page, the same way a new Persona
sessionTokendoes today. ID-658 tracks keeping the page stable across rotations.