From a986a12d54d22d3a9f5743b50fda0ae75f3fee88 Mon Sep 17 00:00:00 2001 From: rtsehynka Date: Wed, 20 Jul 2022 13:34:19 +0300 Subject: [PATCH 1/9] The current problem is that the 3D Secure feature is not working. Whenever you are trying to run a transaction, you get an error (see image), and there seems to be no API call to process this request. --- .../Intercepts/brainTreeDropIn.js | 112 ++++++++++++++++++ .../Model/useBraintreeThreeDSecure.js | 22 ++++ .../Queries/createBraintreeClientToken.gql.js | 10 ++ .../README.md | 7 ++ .../index.js | 1 + .../intercept.js | 9 ++ .../package.json | 15 +++ 7 files changed, 176 insertions(+) create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/Queries/createBraintreeClientToken.gql.js create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/README.md create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/index.js create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js create mode 100644 packages/extensions/gomage-plugin-braintree-three-d-secure/package.json diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js new file mode 100644 index 0000000000..7e596cd9b0 --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js @@ -0,0 +1,112 @@ +/** + * adding to brainTreeDropIn 3D secure part + * @param targets + */ +function localIntercept(targets) { + const {Targetables} = require('@magento/pwa-buildpack'); + const targetables = Targetables.using(targets); + + /** + * We can disable the logic if you will add to .env param CHECKOUT_BRAINTREE_3D with value false + */ + if (process.env.CHECKOUT_BRAINTREE_3D != 'false') { + const brainTreeDropIn = targetables.reactComponent( + '@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/brainTreeDropIn.js' + ); + + /** + * import 3d secure plugin + */ + brainTreeDropIn.addImport('{useBraintreeThreeDSecure} from "@gomage/plugin-braintree-three-d-secure"'); + brainTreeDropIn.addImport('{usePriceSummary} from "@magento/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary"'); + + /** + * add hook for getting of client token + */ + brainTreeDropIn.insertAfterSource( + 'const [dropinInstance, setDropinInstance] = useState();', + '\n const clientToken = useBraintreeThreeDSecure();' + + '\n const talonProps = usePriceSummary();' + ); + /** + * check if exist clientToken + */ + brainTreeDropIn.insertAfterSource( + 'const createDropinInstance = useCallback(async () => {', + '\n if(clientToken){ ' + ); + /** + * end condition of check if exist clientToken + */ + brainTreeDropIn.insertAfterSource( + 'return dropinInstance;', + '\n}' + ); + /** + * setting new dependency clientToken to useCallback createDropinInstance hook + */ + brainTreeDropIn.insertAfterSource( + '[containerId', + ' ,clientToken, talonProps.flatData.total.value' + ); + + + /** + * check if exist clientToken + */ + brainTreeDropIn.insertBeforeSource( + 'const renderDropin = async () => {', + '\n if(clientToken){ ' + ); + + /** + * end condition of check if exist clientToken + */ + brainTreeDropIn.insertBeforeSource( + '}, [createDropinInstance, onReady]);', + '} \n' + ); + + /** + * setting new dependency clientToken to useEffect hook + */ + brainTreeDropIn.insertAfterSource( + '[createDropinInstance, onReady', + ' ,clientToken' + ); + + + /** + * change of value token to client Token + */ + brainTreeDropIn.insertAfterSource( + 'const dropinInstance = await dropIn.create({\n' + + ' authorization', + ':clientToken', + ); + + /** + * enable 3d secure + */ + brainTreeDropIn.insertAfterSource( + 'container: `#${containerId}`,', + '\n threeDSecure: {amount:talonProps.flatData.total.value},', + ); + + /** + * update brain tree if total was changes + */ + brainTreeDropIn.insertBeforeSource( + 'if (isError) {', + 'useEffect(() => {\n' + + ' if(dropinInstance) {\n' + + ' dropinInstance.teardown();\n' + + ' }\n' + + ' }, [\n' + + ' talonProps.flatData.total.value,\n' + + ']);', + ); + } +} + +module.exports = localIntercept; diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js new file mode 100644 index 0000000000..701936a7ae --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js @@ -0,0 +1,22 @@ +import {useMutation} from "@apollo/client"; +import {useEffect} from "react"; +import {GET_BRAINTREE_CLIENT_TOKEN} from '../Queries/createBraintreeClientToken.gql'; + +/** + * + * @returns {*|string} + */ +export const useBraintreeThreeDSecure = () => { + const [setBraintreeClientToken, {data}] = useMutation(GET_BRAINTREE_CLIENT_TOKEN); + const clientToken = data ? data.createBraintreeClientToken : ''; + /** + * set Braintree Client Token + */ + useEffect(() => { + if(!clientToken) { + setBraintreeClientToken(); + } + }, []); + + return clientToken; +} diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/Queries/createBraintreeClientToken.gql.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/Queries/createBraintreeClientToken.gql.js new file mode 100644 index 0000000000..f7a9301e1e --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/Queries/createBraintreeClientToken.gql.js @@ -0,0 +1,10 @@ +import { gql } from '@apollo/client'; +/** + * + * @type {DocumentNode} + */ +export const GET_BRAINTREE_CLIENT_TOKEN = gql` + mutation { + createBraintreeClientToken + } +`; diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/README.md b/packages/extensions/gomage-plugin-braintree-three-d-secure/README.md new file mode 100644 index 0000000000..7c8c153890 --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/README.md @@ -0,0 +1,7 @@ +# GoMage Braintree 3D Secure + +GoMage Braintree 3D Secure + +That plugin works only as a fix bugs of PWA Studio and adds 3d secure part. + +If you need to disable the module, you can add to the .env parameter CHECKOUT_BRAINTREE_3D=false, or remove the plugin. diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js new file mode 100644 index 0000000000..63217c9505 --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js @@ -0,0 +1 @@ +export {useBraintreeThreeDSecure} from './Model/useBraintreeThreeDSecure' diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js new file mode 100644 index 0000000000..1fca3204ab --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js @@ -0,0 +1,9 @@ +/** + * + * @param targets + */ +function localIntercept(targets) { + require("@gomage/plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn")(targets); +} + +module.exports = localIntercept; diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json new file mode 100644 index 0000000000..540fe545b5 --- /dev/null +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json @@ -0,0 +1,15 @@ +{ + "name": "@gomage/plugin-braintree-three-d-secure", + "version": "1.0.3", + "description": "GoMage Braintree 3D Secure", + "main": "./index.js", + "author": "GoMage", + "pwa-studio": { + "targets": { + "intercept": "./intercept.js" + } + }, + "dependencies": { + "braintree-web-drop-in": "~1.33.1" + } +} From 36fd306a2c6fcc8d993e335ad0d00d2f7006240a Mon Sep 17 00:00:00 2001 From: rtsehynka Date: Fri, 29 Jul 2022 16:24:58 +0300 Subject: [PATCH 2/9] [PWA Studio] - Test Braintree #D Secure fix for Venia --- packages/venia-concept/package.json | 7 +- yarn.lock | 120 ++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) diff --git a/packages/venia-concept/package.json b/packages/venia-concept/package.json index af14191dc4..d65115b541 100644 --- a/packages/venia-concept/package.json +++ b/packages/venia-concept/package.json @@ -56,6 +56,7 @@ "@magento/peregrine": "~12.5.0", "@magento/pwa-theme-venia": "~1.3.0", "@magento/upward-security-headers": "~1.0.9", + "@gomage/plugin-braintree-three-d-secure": "~1.0.3", "@magento/venia-ui": "~9.5.0", "@pmmmwh/react-refresh-webpack-plugin": "0.4.1", "@storybook/react": "~6.3.7", @@ -144,6 +145,10 @@ "pwa-studio": { "targets": { "intercept": "./local-intercept.js" - } + }, + "trusted-vendors": [ + "@gomage" + ] } + } diff --git a/yarn.lock b/yarn.lock index 28ffd75f50..d6358a7bf4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2051,6 +2051,18 @@ dependencies: promise-polyfill "^8.1.0" +"@braintree/asset-loader@0.4.4": + version "0.4.4" + resolved "https://npm-pwa.gomage.dev/@braintree%2fasset-loader/-/asset-loader-0.4.4.tgz#9a5eda24c3627bfd5c7f7483cd48f0e411dd2f09" + integrity sha512-uVhXC5dydmngmNVuDiKgfXSlz4kv4x5ytIJodI8N5SY16mRh13m/UmbQ7yH+o8DQqp50qPZ45MUHIZkXKPg85w== + dependencies: + promise-polyfill "^8.1.3" + +"@braintree/browser-detection@1.14.0", "@braintree/browser-detection@^1.12.1": + version "1.14.0" + resolved "https://npm-pwa.gomage.dev/@braintree%2fbrowser-detection/-/browser-detection-1.14.0.tgz#d1b397b00ccbc7cac12f6cec27c0a413d740332a" + integrity sha512-OsqU+28RhNvSw8Y5JEiUHUrAyn4OpYazFkjSJe8ZVZfkAaRXQc6hsV38MMEpIlkPMig+A68buk/diY+0O8/dMQ== + "@braintree/browser-detection@1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@braintree/browser-detection/-/browser-detection-1.7.0.tgz#895ba64b700c3f36cab5c54591caf71a41171dd8" @@ -2066,21 +2078,56 @@ resolved "https://registry.yarnpkg.com/@braintree/class-list/-/class-list-0.1.0.tgz#d6c8606ce6a82b4b37f28e32eadd090abcf1adaa" integrity sha512-AmXPsYhiNJKcxuwkgQjwyyTwFCeRlyFTeUJ9ecV/jLxS8ZH8fCAB4enYgArMRyvCekZZkqLK54kOJ6+OJBzJwA== +"@braintree/class-list@0.2.0": + version "0.2.0" + resolved "https://npm-pwa.gomage.dev/@braintree%2fclass-list/-/class-list-0.2.0.tgz#4c4352ac19c262f61526f93d07d248244b399ec4" + integrity sha512-iLXJT51jnBFuGvyTAQqZ2uwyEVwdyapyz52F5MK1Uoh2ZOiPJ5hoqI0wncyCP2KfqrgyCpOkkEaLMLb/94unGA== + +"@braintree/event-emitter@0.4.1": + version "0.4.1" + resolved "https://npm-pwa.gomage.dev/@braintree%2fevent-emitter/-/event-emitter-0.4.1.tgz#204eaad8cf84eb7bf81fb288a359d34eda85a396" + integrity sha512-X41357O3OXUDlnwMvS1m0GQEn3zB3s3flOBeg2J5OBvLvdJEIAVpPkblABPtsPrlciDSvfv1aSG5ixHPgFH0Zg== + +"@braintree/extended-promise@0.4.1": + version "0.4.1" + resolved "https://npm-pwa.gomage.dev/@braintree%2fextended-promise/-/extended-promise-0.4.1.tgz#b44f8e6236ddb43434be11924f00fa69f8782a36" + integrity sha512-00n7m4z+swWHoFQLHLvrIBIEoxnGUBsl3ogvX79ITpcn8CHczDwtxYy5+RhMoAraRdfN3oB+8QIpN3KOxs2Q7w== + "@braintree/iframer@1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@braintree/iframer/-/iframer-1.0.3.tgz#21dd1fd4cebd4154aeab1efa4d5b0d5f4384364e" integrity sha1-Id0f1M69QVSuqx76TVsNX0OENk4= +"@braintree/iframer@1.1.0": + version "1.1.0" + resolved "https://npm-pwa.gomage.dev/@braintree%2fiframer/-/iframer-1.1.0.tgz#7e59b975c2a48bd92616f653367a5214fc2ddd4b" + integrity sha512-tVpr7U6u6bqeQlHreEjYMNtnHX62vLnNWziY2kQLqkWhvusPuY5DfuGEIPpWqsd+V/a1slyTQaxK6HWTlH6A/Q== + "@braintree/sanitize-url@3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-3.0.0.tgz#a0ce629d18d4d435f23a0b880098cff7d99e8bb3" integrity sha512-ymeXC1qObTag/hhEG7BoTMdIzuhKekTxNJTIfiVXsoP1fUXHKBpr0EfCsSA06BuP5gxTPs2vDKjtmYbgvEfY+g== +"@braintree/sanitize-url@6.0.0": + version "6.0.0" + resolved "https://npm-pwa.gomage.dev/@braintree%2fsanitize-url/-/sanitize-url-6.0.0.tgz#fe364f025ba74f6de6c837a84ef44bdb1d61e68f" + integrity sha512-mgmE7XBYY/21erpzhexk4Cj1cyTQ9LzvnTxtzM17BJ7ERMNE6W72mQRo0I1Ud8eFJ+RVVIcBNhLFZ3GX4XFz5w== + +"@braintree/uuid@0.1.0", "@braintree/uuid@^0.1.0": + version "0.1.0" + resolved "https://npm-pwa.gomage.dev/@braintree%2fuuid/-/uuid-0.1.0.tgz#ab9355015a7fb0e25cf3c2ff9cd32ece8ea304b0" + integrity sha512-YvZJdlNcK5EnR+7M8AjgEAf4Qx696+FOSYlPfy5ePn80vODtVAUU0FxHnzKZC0og1VbDNQDDiwhthR65D4Na0g== + "@braintree/wrap-promise@1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@braintree/wrap-promise/-/wrap-promise-1.1.1.tgz#d22c76855e6d4b4012610060421fae1a37ec90b0" integrity sha1-0ix2hV5tS0ASYQBgQh+uGjfskLA= +"@braintree/wrap-promise@2.1.0": + version "2.1.0" + resolved "https://npm-pwa.gomage.dev/@braintree%2fwrap-promise/-/wrap-promise-2.1.0.tgz#7e27ffc5dacd2d71533b0c42506eea8e7c2e50fa" + integrity sha512-UIrJB+AfKU0CCfbMoWrsGpd2D/hBpY/SGgFI6WRHPOwhaZ3g9rz1weiJ6eb6L9KgVyunT7s2tckcPkbHw+NzeA== + "@cnakazawa/watch@^1.0.3": version "1.0.4" resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a" @@ -6376,6 +6423,20 @@ braintree-web-drop-in@~1.16.0: braintree-web "3.42.0" promise-polyfill "8.1.0" +braintree-web-drop-in@~1.33.1: + version "1.33.3" + resolved "https://npm-pwa.gomage.dev/braintree-web-drop-in/-/braintree-web-drop-in-1.33.3.tgz#d8b27d7caffc8a8bf2e3bfafaaa2ca831dcf42aa" + integrity sha512-0Jz8MrTkN50B0WKsC/Zvf4vm8/6sZdufZqtDlMz/VLAkp+kbJ9uHs/ydxBFAPUrORXKbcH8kTqa7gShvbGDeHA== + dependencies: + "@braintree/asset-loader" "0.4.4" + "@braintree/browser-detection" "1.14.0" + "@braintree/class-list" "0.2.0" + "@braintree/event-emitter" "0.4.1" + "@braintree/uuid" "0.1.0" + "@braintree/wrap-promise" "2.1.0" + braintree-web "3.85.5" + promise-polyfill "8.2.3" + braintree-web@3.42.0: version "3.42.0" resolved "https://registry.yarnpkg.com/braintree-web/-/braintree-web-3.42.0.tgz#07d8cb87bdbd89e9629098c9f4065c92e537e34c" @@ -6394,6 +6455,27 @@ braintree-web@3.42.0: promise-polyfill "8.1.0" restricted-input "1.2.7" +braintree-web@3.85.5: + version "3.85.5" + resolved "https://npm-pwa.gomage.dev/braintree-web/-/braintree-web-3.85.5.tgz#318fad1439e9f95c0819049648567ea7584592a3" + integrity sha512-fRUwF8as9SJd2PCwmdkwE94nvItGmKHmB1Py4C4RM5G/j1v6rxh67l0pXBW14RtvEbnuQ0eIMeR1JQbu/Y5K2g== + dependencies: + "@braintree/asset-loader" "0.4.4" + "@braintree/browser-detection" "1.14.0" + "@braintree/class-list" "0.2.0" + "@braintree/event-emitter" "0.4.1" + "@braintree/extended-promise" "0.4.1" + "@braintree/iframer" "1.1.0" + "@braintree/sanitize-url" "6.0.0" + "@braintree/uuid" "0.1.0" + "@braintree/wrap-promise" "2.1.0" + card-validator "8.1.1" + credit-card-type "9.1.0" + framebus "5.1.2" + inject-stylesheet "5.0.0" + promise-polyfill "8.2.3" + restricted-input "3.0.5" + brorand@^1.0.1, brorand@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" @@ -6836,6 +6918,13 @@ card-validator@6.1.0: dependencies: credit-card-type "^8.0.0" +card-validator@8.1.1: + version "8.1.1" + resolved "https://npm-pwa.gomage.dev/card-validator/-/card-validator-8.1.1.tgz#418f5f32435553fb9ca2a02634ad413bb38697a9" + integrity sha512-cN4FsKwoTfTFnqPwVc7TQLSsH/QMDB3n/gWm0XelcApz4sKipnOQ6k33sa3bWsNnnIpgs7eXOF+mUV2UQAX2Sw== + dependencies: + credit-card-type "^9.1.0" + case-sensitive-paths-webpack-plugin@^2.3.0: version "2.4.0" resolved "https://registry.yarnpkg.com/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.4.0.tgz#db64066c6422eed2e08cc14b986ca43796dbc6d4" @@ -7677,6 +7766,11 @@ credit-card-type@8.0.0: resolved "https://registry.yarnpkg.com/credit-card-type/-/credit-card-type-8.0.0.tgz#e65347bcdb979b4deb3107cd43a1cd9da802cd50" integrity sha512-q3k5fbLJJIkPTBLr03Wo2Ui8cF5vHE8eTT/3K7BUW1ROoyns2vHoglWrzjmU/8JKA0X7JFlYlUVuDRwn7l2ldw== +credit-card-type@9.1.0, credit-card-type@^9.1.0: + version "9.1.0" + resolved "https://npm-pwa.gomage.dev/credit-card-type/-/credit-card-type-9.1.0.tgz#54dd96c93b6579623e9c8656e6798fc2b93f5f05" + integrity sha512-CpNFuLxiPFxuZqhSKml3M+t0K/484pMAnfYWH14JoD7OZMnmC0Lmo+P7JX9SobqFpRoo7ifA18kOHdxJywYPEA== + credit-card-type@^8.0.0: version "8.3.0" resolved "https://registry.yarnpkg.com/credit-card-type/-/credit-card-type-8.3.0.tgz#f93c187c9362411544158c91d552efcc443aa87a" @@ -9900,6 +9994,13 @@ framebus@3.0.2: resolved "https://registry.yarnpkg.com/framebus/-/framebus-3.0.2.tgz#0c99c70cb507522aae6ed485e1317fc913873a8a" integrity sha512-OqhYkhgRYlpKZoSl5EA3whKh8O8omFPCzf7MGzFqC6CtrT8lg7evNgU6QdjC3uY3ATq5saMDiY5HJ8KGiGDYCA== +framebus@5.1.2: + version "5.1.2" + resolved "https://npm-pwa.gomage.dev/framebus/-/framebus-5.1.2.tgz#cb38cf6a282d405411227cfaab4a1095ca9e8e15" + integrity sha512-Z/y6/0gHVx4Td4c0jkDiASBo0pXlJ2fKOP6CynSFnxTzqojG9xOKOFOqoYkcBHlz1vP4t4yHHR6Esp+GsYIh/Q== + dependencies: + "@braintree/uuid" "^0.1.0" + fresh@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" @@ -11289,6 +11390,11 @@ inject-stylesheet@1.0.0: resolved "https://registry.yarnpkg.com/inject-stylesheet/-/inject-stylesheet-1.0.0.tgz#f673047458ee58f109fee4cfb66b09f362ccc261" integrity sha1-9nMEdFjuWPEJ/uTPtmsJ82LMwmE= +inject-stylesheet@5.0.0: + version "5.0.0" + resolved "https://npm-pwa.gomage.dev/inject-stylesheet/-/inject-stylesheet-5.0.0.tgz#bb34acf05ca6ed86e5763d886cd6c9b19f360ab1" + integrity sha512-GzncrJP8E/pavMQzoO93CXoYCfTttwVm2cX2TyXJdgtVE0cCvWSFCn1/uMsM6ZkEg7LUsOcKuamcLiGWlv2p9A== + inline-style-parser@0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.1.1.tgz#ec8a3b429274e9c0a1f1c4ffa9453a7fef72cea1" @@ -15481,6 +15587,11 @@ promise-polyfill@8.1.3: resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.1.3.tgz#8c99b3cf53f3a91c68226ffde7bde81d7f904116" integrity sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g== +promise-polyfill@8.2.3, promise-polyfill@^8.1.3: + version "8.2.3" + resolved "https://npm-pwa.gomage.dev/promise-polyfill/-/promise-polyfill-8.2.3.tgz#2edc7e4b81aff781c88a0d577e5fe9da822107c6" + integrity sha512-Og0+jCRQetV84U8wVjMNccfGCnMQ9mGs9Hv78QFe+pSDD3gWTpz0y+1QCuxy5d/vBFuZ3iwP2eycAkvqIMPmWg== + promise-polyfill@^7.1.1: version "7.1.2" resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-7.1.2.tgz#ab05301d8c28536301622d69227632269a70ca3b" @@ -16584,6 +16695,13 @@ restricted-input@1.2.7: dependencies: "@braintree/browser-detection" "^1.5.0" +restricted-input@3.0.5: + version "3.0.5" + resolved "https://npm-pwa.gomage.dev/restricted-input/-/restricted-input-3.0.5.tgz#c43d279df36be0a11085daa3b1ae1d28044c44d8" + integrity sha512-lUuXZ3wUnHURRarj5/0C8vomWIfWJO+p7T6RYwB46v7Oyuyr3yyupU+i7SjqUv4S6RAeAAZt1C/QCLJ9xhQBow== + dependencies: + "@braintree/browser-detection" "^1.12.1" + resumer@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" @@ -19119,8 +19237,10 @@ watchpack@^1.7.4: resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.7.5.tgz#1267e6c55e0b9b5be44c2023aed5437a2c26c453" integrity sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ== dependencies: + chokidar "^3.4.1" graceful-fs "^4.1.2" neo-async "^2.5.0" + watchpack-chokidar2 "^2.0.1" optionalDependencies: chokidar "^3.4.1" watchpack-chokidar2 "^2.0.1" From 5fc8db381dba5c3484d317ae7ec06c34aab74aa4 Mon Sep 17 00:00:00 2001 From: rtsehynka Date: Fri, 29 Jul 2022 17:22:24 +0300 Subject: [PATCH 3/9] [PWA Studio] - Add to frame-src *.cardinalcommerce.com (for test only) --- packages/extensions/upward-security-headers/upward.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/extensions/upward-security-headers/upward.yml b/packages/extensions/upward-security-headers/upward.yml index ff22d7afa6..61fcee8867 100644 --- a/packages/extensions/upward-security-headers/upward.yml +++ b/packages/extensions/upward-security-headers/upward.yml @@ -25,7 +25,7 @@ veniaSecurityHeaders: base-uri 'none'; child-src 'self'; font-src 'self' fonts.gstatic.com; - frame-src assets.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com + frame-src assets.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com *.cardinalcommerce.com " default: inline: " @@ -36,7 +36,7 @@ veniaSecurityHeaders: base-uri 'none'; child-src 'self'; font-src 'self' fonts.gstatic.com; - frame-src assets.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com + frame-src assets.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com *.cardinalcommerce.com " strict-transport-security: inline: max-age=31536000 From 3440addc75bebee7d0a79366d3d70e102900d904 Mon Sep 17 00:00:00 2001 From: rtsehynka Date: Tue, 9 Aug 2022 16:42:11 +0300 Subject: [PATCH 4/9] [PWA Studio] - Add to frame-src *.cardinalcommerce.com (for test only) --- packages/extensions/upward-security-headers/upward.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/extensions/upward-security-headers/upward.yml b/packages/extensions/upward-security-headers/upward.yml index 61fcee8867..db8c6a0de5 100644 --- a/packages/extensions/upward-security-headers/upward.yml +++ b/packages/extensions/upward-security-headers/upward.yml @@ -25,7 +25,7 @@ veniaSecurityHeaders: base-uri 'none'; child-src 'self'; font-src 'self' fonts.gstatic.com; - frame-src assets.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com *.cardinalcommerce.com + frame-src *.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com *.cardinalcommerce.com " default: inline: " @@ -36,7 +36,7 @@ veniaSecurityHeaders: base-uri 'none'; child-src 'self'; font-src 'self' fonts.gstatic.com; - frame-src assets.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com *.cardinalcommerce.com + frame-src *.braintreegateway.com *.google.com *.youtube.com *.youtu.be *.vimeo.com *.cardinalcommerce.com " strict-transport-security: inline: max-age=31536000 From dcd95e56e584dcbd0aeb95510a0d01bfd1f4a446 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Thu, 8 Aug 2024 17:23:12 +0530 Subject: [PATCH 5/9] PWA-2968::[Issue] Gomage/plugin braintree three d secure --- .../Intercepts/brainTreeDropIn.js | 37 +++++++++---------- .../Model/useBraintreeThreeDSecure.js | 16 ++++---- .../index.js | 2 +- .../intercept.js | 4 +- .../package.json | 8 ++-- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js index 7e596cd9b0..8f60682b61 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js @@ -3,7 +3,7 @@ * @param targets */ function localIntercept(targets) { - const {Targetables} = require('@magento/pwa-buildpack'); + const { Targetables } = require('@magento/pwa-buildpack'); const targetables = Targetables.using(targets); /** @@ -17,8 +17,12 @@ function localIntercept(targets) { /** * import 3d secure plugin */ - brainTreeDropIn.addImport('{useBraintreeThreeDSecure} from "@gomage/plugin-braintree-three-d-secure"'); - brainTreeDropIn.addImport('{usePriceSummary} from "@magento/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary"'); + brainTreeDropIn.addImport( + '{useBraintreeThreeDSecure} from "@gomage/plugin-braintree-three-d-secure"' + ); + brainTreeDropIn.addImport( + '{usePriceSummary} from "@magento/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary"' + ); /** * add hook for getting of client token @@ -26,7 +30,7 @@ function localIntercept(targets) { brainTreeDropIn.insertAfterSource( 'const [dropinInstance, setDropinInstance] = useState();', '\n const clientToken = useBraintreeThreeDSecure();' + - '\n const talonProps = usePriceSummary();' + '\n const talonProps = usePriceSummary();' ); /** * check if exist clientToken @@ -38,10 +42,7 @@ function localIntercept(targets) { /** * end condition of check if exist clientToken */ - brainTreeDropIn.insertAfterSource( - 'return dropinInstance;', - '\n}' - ); + brainTreeDropIn.insertAfterSource('return dropinInstance;', '\n}'); /** * setting new dependency clientToken to useCallback createDropinInstance hook */ @@ -50,7 +51,6 @@ function localIntercept(targets) { ' ,clientToken, talonProps.flatData.total.value' ); - /** * check if exist clientToken */ @@ -75,14 +75,13 @@ function localIntercept(targets) { ' ,clientToken' ); - /** * change of value token to client Token */ brainTreeDropIn.insertAfterSource( 'const dropinInstance = await dropIn.create({\n' + - ' authorization', - ':clientToken', + ' authorization', + ':clientToken' ); /** @@ -90,7 +89,7 @@ function localIntercept(targets) { */ brainTreeDropIn.insertAfterSource( 'container: `#${containerId}`,', - '\n threeDSecure: {amount:talonProps.flatData.total.value},', + '\n threeDSecure: {amount:talonProps.flatData.total.value},' ); /** @@ -99,12 +98,12 @@ function localIntercept(targets) { brainTreeDropIn.insertBeforeSource( 'if (isError) {', 'useEffect(() => {\n' + - ' if(dropinInstance) {\n' + - ' dropinInstance.teardown();\n' + - ' }\n' + - ' }, [\n' + - ' talonProps.flatData.total.value,\n' + - ']);', + ' if(dropinInstance) {\n' + + ' dropinInstance.teardown();\n' + + ' }\n' + + ' }, [\n' + + ' talonProps.flatData.total.value,\n' + + ']);' ); } } diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js index 701936a7ae..03aad4f2e8 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js @@ -1,22 +1,24 @@ -import {useMutation} from "@apollo/client"; -import {useEffect} from "react"; -import {GET_BRAINTREE_CLIENT_TOKEN} from '../Queries/createBraintreeClientToken.gql'; +import { useMutation } from '@apollo/client'; +import { useEffect } from 'react'; +import { GET_BRAINTREE_CLIENT_TOKEN } from '../Queries/createBraintreeClientToken.gql'; /** * * @returns {*|string} */ export const useBraintreeThreeDSecure = () => { - const [setBraintreeClientToken, {data}] = useMutation(GET_BRAINTREE_CLIENT_TOKEN); + const [setBraintreeClientToken, { data }] = useMutation( + GET_BRAINTREE_CLIENT_TOKEN + ); const clientToken = data ? data.createBraintreeClientToken : ''; /** * set Braintree Client Token */ useEffect(() => { - if(!clientToken) { + if (!clientToken) { setBraintreeClientToken(); } - }, []); + }, [clientToken, setBraintreeClientToken]); return clientToken; -} +}; diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js index 63217c9505..100e265a35 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/index.js @@ -1 +1 @@ -export {useBraintreeThreeDSecure} from './Model/useBraintreeThreeDSecure' +export { useBraintreeThreeDSecure } from './Model/useBraintreeThreeDSecure'; diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js b/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js index 1fca3204ab..9c3560643d 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js @@ -3,7 +3,9 @@ * @param targets */ function localIntercept(targets) { - require("@gomage/plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn")(targets); + require('@gomage/plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn')( + targets + ); } module.exports = localIntercept; diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json index 540fe545b5..3d8e3e82e3 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json @@ -4,12 +4,12 @@ "description": "GoMage Braintree 3D Secure", "main": "./index.js", "author": "GoMage", + "dependencies": { + "braintree-web-drop-in": "~1.33.1" + }, "pwa-studio": { "targets": { "intercept": "./intercept.js" } - }, - "dependencies": { - "braintree-web-drop-in": "~1.33.1" } -} +} \ No newline at end of file From 050189a06ab7107b8e32aa2d9f51a6a12bd1e213 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Thu, 8 Aug 2024 17:40:00 +0530 Subject: [PATCH 6/9] PWA-2968::[Issue] Gomage/plugin braintree three d secure --- .../__snapshots__/TargetableReactComponent.spec.js.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pwa-buildpack/lib/WebpackTools/targetables/__tests__/__snapshots__/TargetableReactComponent.spec.js.snap b/packages/pwa-buildpack/lib/WebpackTools/targetables/__tests__/__snapshots__/TargetableReactComponent.spec.js.snap index f415de366a..a6dd8f453a 100644 --- a/packages/pwa-buildpack/lib/WebpackTools/targetables/__tests__/__snapshots__/TargetableReactComponent.spec.js.snap +++ b/packages/pwa-buildpack/lib/WebpackTools/targetables/__tests__/__snapshots__/TargetableReactComponent.spec.js.snap @@ -273,8 +273,8 @@ exports.Checkbox = Checkbox; var _react = require(\\"react\\"); const _excluded = [\\"classes\\", \\"fieldState\\", \\"id\\", \\"label\\", \\"message\\"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } -function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } -function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } +function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } +function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; } function _getRequireWildcardCache(e) { if (\\"function\\" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \\"object\\" != typeof e && \\"function\\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if (\\"default\\" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } const DynamicComponent$3 = (0, _react.lazy)(() => Promise.resolve().then(() => _interopRequireWildcard(require('./path/to/a-third/component')))); From efbb67c3fc37c08eacef3d2b26b46c978ec4c059 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Tue, 13 Aug 2024 15:55:33 +0530 Subject: [PATCH 7/9] Resolve clean issue --- .../gomage-plugin-braintree-three-d-secure/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json index 3d8e3e82e3..38ce9461a7 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json @@ -7,6 +7,10 @@ "dependencies": { "braintree-web-drop-in": "~1.33.1" }, + + "scripts": { + "clean": " " + }, "pwa-studio": { "targets": { "intercept": "./intercept.js" From 287a68c9e3b681d83b7115f43dd7f2b99b191fa4 Mon Sep 17 00:00:00 2001 From: chetana11 Date: Thu, 17 Oct 2024 12:01:53 +0530 Subject: [PATCH 8/9] PWA-2968:updating version --- .../gomage-plugin-braintree-three-d-secure/package.json | 4 ++-- packages/venia-concept/package.json | 5 +++-- packages/venia-ui/package.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json index 38ce9461a7..72463a6c47 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json @@ -1,11 +1,11 @@ { "name": "@gomage/plugin-braintree-three-d-secure", - "version": "1.0.3", + "version": "3.94.0", "description": "GoMage Braintree 3D Secure", "main": "./index.js", "author": "GoMage", "dependencies": { - "braintree-web-drop-in": "~1.33.1" + "braintree-web-drop-in": "~1.43.0" }, "scripts": { diff --git a/packages/venia-concept/package.json b/packages/venia-concept/package.json index 50c00c4c86..d45d644687 100644 --- a/packages/venia-concept/package.json +++ b/packages/venia-concept/package.json @@ -35,6 +35,7 @@ }, "homepage": "https://github.com/magento/pwa-studio/tree/main/packages/venia-concept#readme", "dependencies": { + "@gomage/plugin-braintree-three-d-secure": "3.94.0", "@magento/pwa-buildpack": "~11.5.3" }, "devDependencies": { @@ -50,6 +51,7 @@ "@babel/plugin-transform-runtime": "~7.4.4", "@babel/preset-env": "~7.16.0", "@babel/runtime": "~7.15.3", + "@gomage/plugin-braintree-three-d-secure": "3.94.0", "@magento/babel-preset-peregrine": "~1.3.3", "@magento/eslint-config": "~1.5.0", "@magento/pagebuilder": "~9.3.1", @@ -69,7 +71,7 @@ "babel-plugin-graphql-tag": "~2.0.0", "babel-plugin-module-resolver": "~3.2.0", "babel-plugin-react-remove-properties": "~0.3.0", - "braintree-web-drop-in": "~1.33.3", + "braintree-web-drop-in": "~1.43.0", "compression": "~1.7.4", "css-loader": "~5.2.7", "dotenv": "~6.2.0", @@ -149,5 +151,4 @@ "@gomage" ] } - } diff --git a/packages/venia-ui/package.json b/packages/venia-ui/package.json index c2cc1e518f..d253bc902a 100644 --- a/packages/venia-ui/package.json +++ b/packages/venia-ui/package.json @@ -83,7 +83,7 @@ "@magento/peregrine": "~14.3.1", "@magento/pwa-buildpack": "~11.5.3", "apollo-cache-persist": "~0.1.1", - "braintree-web-drop-in": "~1.33.3", + "braintree-web-drop-in": "~1.43.0", "graphql": "~15.5.0", "react": "~17.0.1", "react-intl": "~5.20.0", From 8bf8c5b08083eba0e133007d0125ce92a8bdc88a Mon Sep 17 00:00:00 2001 From: chetana11 Date: Tue, 22 Oct 2024 16:48:57 +0530 Subject: [PATCH 9/9] Adding license field else showing error during yarn clean:all --- .../gomage-plugin-braintree-three-d-secure/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json index 72463a6c47..e9cf101f9e 100644 --- a/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json +++ b/packages/extensions/gomage-plugin-braintree-three-d-secure/package.json @@ -11,6 +11,7 @@ "scripts": { "clean": " " }, + "license": "SEE LICENSE IN LICENSE.txt", "pwa-studio": { "targets": { "intercept": "./intercept.js"