Secure Payment Request #402
Replies: 4 comments 3 replies
-
Hello @fabiancook, I suppose it was only a matter of time before this came up given the latest news of the Secure Payment Confirmation spec becoming a Candidate Release: https://www.w3.org/TR/secure-payment-confirmation/ I've been somewhat dialed into the Secure Payments Working Group and its overlap with WebAuthn via my participation in the Web Authentication Working Group. I knew that SPC and WebAuthn were similar, but it sounds like SPC only requires minor accommodations to work with otherwise WebAuthn-compatible code... I'm going to start reading up on the SPC spec, if the two really are that close then maybe it's not so crazy to think that SimpleWebAuthn could also offer support for Secure Payments. I'd have to think about that use case and if it would make sense to bake into @simplewebauthn/browser and @simplewebauthn/server, or perhaps as new packages that import both respectively and then tweak the API for the Secure Payments use case. |
Beta Was this translation helpful? Give feedback.
-
With the registration, to register for a secure payment confirmation passkey, you can use the registration process that SimpleWebAuthn provides, however, the required options include using: {
extensions: {
"payment": {
isPayment: true,
}
}
} The types given currently, do not support this: export type GenerateRegistrationOptionsOpts = {
extensions?: AuthenticationExtensionsClientInputs;
}
export interface AuthenticationExtensionsClientInputs {
appid?: string;
credProps?: boolean;
hmacCreateSecret?: boolean;
} I can see that both In my implementation right now I am just... doing some hacky type jumping to allow this.. I do see that the types for const extendableTypes = [
'AuthenticationExtensionsClientInputs'
]
// ....
types.map(type => {
// ....
if (extendableTypes.includes(type)) {
const extendable = domSourceFile.getInterface(type);
if (!extendable) {
throw new Error(`${type} does not refer to an interface so is not extendable`);
}
extendable.addExtends("Record<string, unknown>");
}
// ....
}) Results in an input type that allows any extensions in the future... but means the outputs type would be hiding these unknown other properties export interface AuthenticationExtensionsClientInputs extends Record<string, unknown> {
appid?: string;
credProps?: boolean;
hmacCreateSecret?: boolean;
} |
Beta Was this translation helpful? Give feedback.
-
Hello again @fabiancook, I glanced at Secure Payment Confirmation again today and I don't see a corresponding |
Beta Was this translation helpful? Give feedback.
-
And I've added docs to the SimpleWebAuthn homepage to describe how to use https://simplewebauthn.dev/docs/advanced/secure-payment-confirmation |
Beta Was this translation helpful? Give feedback.
-
Hi,
It would be great if we could implement secure payment request support in SimpleWebAuthn.
I have a demo of it working here:
opennetwork/logistics#19 (comment)
I'm leaning on
generateAuthenticationOptions
/verifyAuthenticationResponse
to generate the challenge, and verify the response that comes back, with the payment response matching the shape, returning aPublicKeyCredential
with aAuthenticatorAssertionResponse
A credential setup for secure payment requests is setup using the normal register process, with just the
authenticatorAttachment
+extensions
options updated.The only difference between a normal credential and the asserted payment one, is that the
type
given in the returnedclientDataJSON
, in the case of payments, it ispayment.get
instead ofwebauthn.get
, allowing both these types let me use verifyAuthenticationResponse for payments as well.If verifyAuthenticationResponse could accept more than the fixed type of
webauthn.get
, that would work, but, if we setup a dedicated generateOptions for a payment request, that would work better long run, as it has a slightly different shape to authentication but some over-lap.Beta Was this translation helpful? Give feedback.
All reactions