From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/secure-payment-confirmation/META.yml | 4 + .../authentication-accepted.https.html | 79 +++++ .../authentication-cannot-bypass-spc.https.html | 56 ++++ .../authentication-cross-origin.sub.https.html | 71 ++++ .../authentication-icon-data-url.https.html | 58 ++++ .../authentication-in-iframe.sub.https.html | 146 +++++++++ .../authentication-invalid-icon.https.html | 109 +++++++ .../authentication-optout.https.html | 50 +++ .../authentication-rejected.https.html | 49 +++ ...hentication-requires-user-activation.https.html | 48 +++ ...tructor-validate-payment-method-data.https.html | 358 +++++++++++++++++++++ .../constructor.https.html | 201 ++++++++++++ .../enrollment-in-iframe.sub.https.html | 166 ++++++++++ .../enrollment.https.html | 64 ++++ .../resources/iframe-authenticate.html | 59 ++++ .../resources/iframe-enroll.html | 28 ++ .../tests/secure-payment-confirmation/troy.png | Bin 0 -> 884 bytes .../tests/secure-payment-confirmation/utils.sub.js | 103 ++++++ 18 files changed, 1649 insertions(+) create mode 100644 testing/web-platform/tests/secure-payment-confirmation/META.yml create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-accepted.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-cannot-bypass-spc.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-cross-origin.sub.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-icon-data-url.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-in-iframe.sub.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-invalid-icon.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-optout.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-rejected.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/authentication-requires-user-activation.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/constructor-validate-payment-method-data.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/constructor.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/enrollment-in-iframe.sub.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/enrollment.https.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/resources/iframe-authenticate.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/resources/iframe-enroll.html create mode 100644 testing/web-platform/tests/secure-payment-confirmation/troy.png create mode 100644 testing/web-platform/tests/secure-payment-confirmation/utils.sub.js (limited to 'testing/web-platform/tests/secure-payment-confirmation') diff --git a/testing/web-platform/tests/secure-payment-confirmation/META.yml b/testing/web-platform/tests/secure-payment-confirmation/META.yml new file mode 100644 index 0000000000..cdcab0e705 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/META.yml @@ -0,0 +1,4 @@ +spec: https://w3c.github.io/secure-payment-confirmation/ +suggested_reviewers: + - stephenmcgruer + - rsolomakhin diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-accepted.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-accepted.https.html new file mode 100644 index 0000000000..b9417b88e0 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-accepted.https.html @@ -0,0 +1,79 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - accepted case + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-cannot-bypass-spc.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-cannot-bypass-spc.https.html new file mode 100644 index 0000000000..2125f644c7 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-cannot-bypass-spc.https.html @@ -0,0 +1,56 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - cannot authenticate via navigator.credentials.get directly + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-cross-origin.sub.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-cross-origin.sub.https.html new file mode 100644 index 0000000000..bf03d4c11c --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-cross-origin.sub.https.html @@ -0,0 +1,71 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - cross origin + + + + + + + + +
Non-empty body
+ + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-icon-data-url.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-icon-data-url.https.html new file mode 100644 index 0000000000..cd820d84c3 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-icon-data-url.https.html @@ -0,0 +1,58 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - data URL icon + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-in-iframe.sub.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-in-iframe.sub.https.html new file mode 100644 index 0000000000..4402e2825d --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-in-iframe.sub.https.html @@ -0,0 +1,146 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - cross origin + + + + + + + + +
Non-empty body
+ + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-invalid-icon.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-invalid-icon.https.html new file mode 100644 index 0000000000..988d867462 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-invalid-icon.https.html @@ -0,0 +1,109 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - invalid icon + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-optout.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-optout.https.html new file mode 100644 index 0000000000..a69e0a456a --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-optout.https.html @@ -0,0 +1,50 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - user opt out case + + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-rejected.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-rejected.https.html new file mode 100644 index 0000000000..7c84abc9e0 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-rejected.https.html @@ -0,0 +1,49 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - user rejects case + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/authentication-requires-user-activation.https.html b/testing/web-platform/tests/secure-payment-confirmation/authentication-requires-user-activation.https.html new file mode 100644 index 0000000000..dd6a737696 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/authentication-requires-user-activation.https.html @@ -0,0 +1,48 @@ + + +Test for the 'secure-payment-confirmation' payment method authentication - requires user activation + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/constructor-validate-payment-method-data.https.html b/testing/web-platform/tests/secure-payment-confirmation/constructor-validate-payment-method-data.https.html new file mode 100644 index 0000000000..1ece6318b5 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/constructor-validate-payment-method-data.https.html @@ -0,0 +1,358 @@ + + + +Tests for the 'secure-payment-confirmation' steps to validate payment method data + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/constructor.https.html b/testing/web-platform/tests/secure-payment-confirmation/constructor.https.html new file mode 100644 index 0000000000..e42f8d47c7 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/constructor.https.html @@ -0,0 +1,201 @@ + + + +Test for the 'secure-payment-confirmation' payment method constructor + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/enrollment-in-iframe.sub.https.html b/testing/web-platform/tests/secure-payment-confirmation/enrollment-in-iframe.sub.https.html new file mode 100644 index 0000000000..9a0f2093a1 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/enrollment-in-iframe.sub.https.html @@ -0,0 +1,166 @@ + + +Test for the 'secure-payment-confirmation' payment method enrollment - cross origin + + + + + + + + +
Non-empty body
+ + diff --git a/testing/web-platform/tests/secure-payment-confirmation/enrollment.https.html b/testing/web-platform/tests/secure-payment-confirmation/enrollment.https.html new file mode 100644 index 0000000000..b93822c7f1 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/enrollment.https.html @@ -0,0 +1,64 @@ + + + +Test for registering a PublicKeyCredential with "payment" extension + + + + + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/resources/iframe-authenticate.html b/testing/web-platform/tests/secure-payment-confirmation/resources/iframe-authenticate.html new file mode 100644 index 0000000000..828e81f60d --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/resources/iframe-authenticate.html @@ -0,0 +1,59 @@ + + +SPC Authentication iframe + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/resources/iframe-enroll.html b/testing/web-platform/tests/secure-payment-confirmation/resources/iframe-enroll.html new file mode 100644 index 0000000000..f1a4d0daf0 --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/resources/iframe-enroll.html @@ -0,0 +1,28 @@ + + +SPC Enrollment iframe + + + + diff --git a/testing/web-platform/tests/secure-payment-confirmation/troy.png b/testing/web-platform/tests/secure-payment-confirmation/troy.png new file mode 100644 index 0000000000..4987ba65c2 Binary files /dev/null and b/testing/web-platform/tests/secure-payment-confirmation/troy.png differ diff --git a/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js b/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js new file mode 100644 index 0000000000..acb016367d --- /dev/null +++ b/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js @@ -0,0 +1,103 @@ +const PAYMENT_DETAILS = { + total: {label: 'Total', amount: {value: '0.01', currency: 'USD'}} +}; +const AUTHENTICATOR_OPTS = { + protocol: 'ctap2_1', + transport: 'internal', + hasResidentKey: true, + hasUserVerification: true, + isUserVerified: true, +}; + +const ICON_URL = 'https://{{hosts[][www]}}:{{ports[https][0]}}/secure-payment-confirmation/troy.png'; +const NONEXISTENT_ICON_URL = 'https://{{hosts[][www]}}:{{ports[https][0]}}/secure-payment-confirmation/nonexistent.png'; + +const ICON_DATA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swCAKbu69w3TXN92tXYdKoyR6+xa6DVQR9EiXl71K9p4xwg5491e9zrqX9bi+FLIFOp+N03VEWm+IpKC6hzzbAqU8+xGJOpKyyhjPNrcRpVfQ/u4HxGQ8Z57sQgMbVaayN1LP+hx62VVWSnLSU1o4uNq5bw8Xuy5S8vQ+P1/v3AIxRETTUHSM22khzRxefNzTy0f59+P0BNuUXMulwKo33cfqjFMQt4uWrNp56IJqC+BguuGbJar9Mbn4Or215iWAgiGPKyc5dFfT0Xv8Tk0JmQKNRU2TN5cnH0hHVao6fPMX2V/IZHZ+g9J0qhRGypRkjKU1K4OsJB9stS7jlclM7PEbzhIP1qx/n8HsVSmbOtV7kYO0xboxPzA+ATJfIiHCijVEIgojD6SR2UQwej1eJXvJLzMmCUaPGHwhiCtPi8PqwrFzBssQE0lNX8PTGdQwM2fng6AkmHVNc67PND4AoiiQtXYLBYFC4OzMzo/Da5Z5WgEAQr1dSKGqMivrj0CBut5uait2YHowlTKfD4bxDxf5DXPqlR9nj8/nmB0DepdFoFLGRHcvCISuhnE75W36XH7knRFFQQMqm1WgpLrQSYTBgH7nB+bYO+gftf3E878tIPlhxfM96bwhz8jwHQP4XE21UgHt9PtzT00iSP6SE/zduQ3kgmZqaUsl1Xki7O5D82yPZ7y210ZoMhOgBAAAAAElFTkSuQmCC'; + +// Creates and returns a WebAuthn credential, optionally with the payment +// extension set. +// +// Assumes that a virtual authenticator has already been created. +async function createCredential(set_payment_extension=true) { + const challengeBytes = new Uint8Array(16); + window.crypto.getRandomValues(challengeBytes); + + const publicKey = { + challenge: challengeBytes, + rp: { + name: 'Acme', + }, + user: { + id: new Uint8Array(16), + name: 'jane.doe@example.com', + displayName: 'Jane Doe', + }, + pubKeyCredParams: [{ + type: 'public-key', + alg: -7, // 'ES256' + }], + authenticatorSelection: { + userVerification: 'required', + residentKey: 'required', + authenticatorAttachment: 'platform', + }, + timeout: 30000, + }; + + if (set_payment_extension) { + publicKey.extensions = { + payment: { isPayment: true }, + }; + } + + return navigator.credentials.create({publicKey}); +} + +// Creates a SPC credential in an iframe for the WPT 'alt' domain. Returns a +// promise that resolves with the created credential id. +// +// Assumes that a virtual authenticator has already been created. +async function createCredentialForAltDomain() { + const frame = document.createElement('iframe'); + frame.allow = 'payment'; + frame.src = 'https://{{hosts[alt][]}}:{{ports[https][0]}}' + + '/secure-payment-confirmation/resources/iframe-enroll.html'; + + // Wait for the iframe to load. + const readyPromise = new Promise(resolve => { + window.addEventListener('message', function handler(evt) { + if (evt.source === frame.contentWindow && evt.data.type == 'loaded') { + window.removeEventListener('message', handler); + + resolve(evt.data); + } + }); + }); + document.body.appendChild(frame); + await readyPromise; + + // Setup the result promise, and then trigger credential creation. + const resultPromise = new Promise(resolve => { + window.addEventListener('message', function handler(evt) { + if (evt.source === frame.contentWindow && evt.data.type == 'spc_result') { + document.body.removeChild(frame); + window.removeEventListener('message', handler); + + resolve(evt.data); + } + }); + }); + frame.contentWindow.postMessage({ userActivation: true }, '*'); + return resultPromise; +} + +function arrayBufferToString(buffer) { + return String.fromCharCode(...new Uint8Array(buffer)); +} + +function base64UrlEncode(data) { + let result = btoa(data); + return result.replace(/=+$/g, '').replace(/\+/g, "-").replace(/\//g, "_"); +} + -- cgit v1.2.3