Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@transferwise/approve-api-action-helpers

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@transferwise/approve-api-action-helpers - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

2

dist/main.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@transferwise/approve-api-action-helpers"]=t():e["@transferwise/approve-api-action-helpers"]=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{"use strict";var e={650:(e,t,n)=>{function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e,t,n){return(u=l()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&s(o,n.prototype),o}).apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}n.r(t),n.d(t,{Flow:()=>h,Mode:()=>w,create:()=>E,runFlow:()=>O});var d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(o,e);var t,n,r=(t=o,n=l(),function(){var e,r=f(t);if(n){var o=f(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return c(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=r.call(this,e.statusText)).name="HTTPError",t.response=e,t}return o}(p(Error));function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return fetch(e,o(o({},t),{},{headers:o(o({},{"Content-Type":"application/json"}),t.headers)})).then((function(e){if(!e.ok)throw new d(e);return e}))}var y="tw-approve-api-action-success",b="tw-approve-api-action-failed",m="tw-approve-api-action-closed";var h={IFRAME:"iframe",TAB:"tab"},w={PRODUCTION:"production",SANDBOX:"sandbox"},g=function(e){return e===w.SANDBOX?"https://sandbox.transferwise.tech/approve-api-action/":"https://transferwise.com/approve-api-action/"};function O(e){var t=e.token,n=e.flow,r=void 0===n?h.IFRAME:n,o=e.mode,a=void 0===o?w.PRODUCTION:o,i=e.approvalPageUrl;return new Promise((function(e,n){var o={token:t,approvalPageUrl:i||g(a),resolve:e,reject:n};r===h.TAB?function(e){var t=e.token,n=e.approvalPageUrl,r=e.resolve,o=e.reject,a="tw-approve-api-action",i=function(e){var t=e.name,n=e.token,r=e.approvalPageUrl,o=document.createElement("form"),a=document.createElement("input");return o.style.display="none",o.target=t,o.method="POST",o.action=r,a.value=n,a.name="ott",o.appendChild(a),o}({name:a,token:t,approvalPageUrl:n});document.body.appendChild(i);var c=window.open(n,a);i.submit();var p=function(e){switch(e.data){case y:return u(),void r();case b:return u(),void o();case m:u()}},u=function(){c.close(),window.removeEventListener("message",p)};window.addEventListener("message",p)}(o):function(e){var t,n,r=e.token,o=e.approvalPageUrl,a=e.resolve,i=e.reject;document.getElementById("tw-approve-api-action-styles")||(t=document.head,(n=document.createElement("style")).id="tw-approve-api-action-styles",n.appendChild(document.createTextNode("\n .tw-approval-modal-overlay {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n height: 100%;\n width: 100%;\n background: rgba(55,81,126,0);\n transition: background-color .35s cubic-bezier(0,.94,.62,1);\n z-index: 1050;\n }\n .tw-approval-modal-overlay--open {\n background: rgba(55,81,126,0.8);\n }\n .tw-approval-modal-wrapper {\n height: 100%;\n width: 100vw;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 16px;\n }\n .tw-approval-modal {\n display: flex;\n max-height: 100%;\n height: 540px;\n width: 540px;\n background-color: #fff;\n border-radius: 3px;\n box-shadow: 0 5px 15px rgba(0,0,0,.2);\n overflow: auto;\n }\n")),t.appendChild(n));var c=document.createElement("div");c.classList.add("tw-approval-modal-overlay");var p=document.createElement("div");p.classList.add("tw-approval-modal-wrapper"),c.appendChild(p);var u=document.createElement("div");u.classList.add("tw-approval-modal"),p.appendChild(u);var l=document.createElement("iframe");l.name="tw-approve-api-action",l.width="100%",l.height="100%",l.style.border="0",u.appendChild(l);var s=document.createElement("form"),f=document.createElement("input");s.style.display="none",s.method="POST",s.action=o,f.value=r,f.name="ott",s.appendChild(f),u.appendChild(s),document.body.appendChild(c),c.classList.add("tw-approval-modal-overlay--open"),s.setAttribute("target","tw-approve-api-action"),s.submit();var d=function(e){switch(e.data){case y:return v(),void a();case b:return v(),void i();case m:v()}},v=function(){c.remove(),window.removeEventListener("message",d)};c.addEventListener("click",v,{once:!0}),window.addEventListener("message",d)}(o)}))}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return v(t,n).then((function(e){return{response:e,metadata:{scaRequired:!1}}})).catch((function(r){if(C(r)){var o=R(r.response);return S(e.onSCARequired),O({token:o,flow:e.flow,mode:e.mode,approvalPageUrl:e.approvalPageUrl}).then((function(){S(e.onSCACompleted);var r=j(j({},n.headers||{}),{},{"X-2FA-APPROVAL":o});return v(t,j(j({},n),{},{headers:r})).then((function(e){return{response:e,metadata:{scaRequired:!0}}}))}))}throw r})).then((function(e){return n&&n.withMetadata?e:e.response}))}}function S(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};e()}function C(e){if(!e||!e.response)return!1;var t=R(e.response),n=e.response.status;return(403===n||400===n)&&t}function R(e){return e&&e.headers&&e.headers.get?e.headers.get("X-2FA-APPROVAL"):null}}},t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(650)})()}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).twApproveApiActionHelpers={})}(this,(function(e){function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,n){return(c=i()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&a(o,n.prototype),o}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return c(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,e)})(e)}function u(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}var l=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(c,e);var t,n,r=(t=c,n=i(),function(){var e,r=o(t);if(n){var a=o(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return u(this,e)});function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=r.call(this,e.statusText)).name="HTTPError",t.response=e,t}return c}(p(Error));function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return fetch(e,r(r({},t),{},{headers:r(r({},{"Content-Type":"application/json"}),t.headers)})).then((function(e){if(!e.ok)throw new l(e);return e}))}var d="tw-approve-api-action-success",f="tw-approve-api-action-failed",v="tw-approve-api-action-closed";function h(e){var t,n,r=e.token,o=e.approvalPageUrl,a=e.resolve,i=e.reject;document.getElementById("tw-approve-api-action-styles")||(t=document.head,(n=document.createElement("style")).id="tw-approve-api-action-styles",n.appendChild(document.createTextNode("\n .tw-approval-modal-overlay {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n height: 100%;\n width: 100%;\n background: rgba(55,81,126,0);\n transition: background-color .35s cubic-bezier(0,.94,.62,1);\n z-index: 1050;\n }\n .tw-approval-modal-overlay--open {\n background: rgba(55,81,126,0.8);\n }\n .tw-approval-modal-wrapper {\n height: 100%;\n width: 100vw;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 16px;\n }\n .tw-approval-modal {\n display: flex;\n max-height: 100%;\n height: 540px;\n width: 540px;\n background-color: #fff;\n border-radius: 3px;\n box-shadow: 0 5px 15px rgba(0,0,0,.2);\n overflow: auto;\n }\n")),t.appendChild(n));var c=document.createElement("div");c.id="tw-approval-modal-overlay",c.classList.add("tw-approval-modal-overlay");var p=document.createElement("div");p.classList.add("tw-approval-modal-wrapper"),c.appendChild(p);var u=document.createElement("div");u.classList.add("tw-approval-modal"),p.appendChild(u);var l=document.createElement("iframe");l.name="tw-approve-api-action",l.width="100%",l.height="100%",l.style.border="0",u.appendChild(l);var s=document.createElement("form"),h=document.createElement("input");s.style.display="none",s.method="POST",s.action=o,h.value=r,h.name="ott",s.appendChild(h),u.appendChild(s),document.body.appendChild(c),c.classList.add("tw-approval-modal-overlay--open"),s.setAttribute("target","tw-approve-api-action"),s.submit();var m=function(e){switch(e.data){case d:return w(),void a();case f:return w(),void i();case v:w()}},w=function(){var e=document.getElementById("tw-approval-modal-overlay");e.parentNode.removeChild(e),window.removeEventListener("message",m)};c.addEventListener("click",w,{once:!0}),window.addEventListener("message",m)}function m(e){var t=e.token,n=e.approvalPageUrl,r=e.resolve,o=e.reject,a="tw-approve-api-action",i=function(e){var t=e.name,n=e.token,r=e.approvalPageUrl,o=document.createElement("form"),a=document.createElement("input");return o.style.display="none",o.target=t,o.method="POST",o.action=r,a.value=n,a.name="ott",o.appendChild(a),o}({name:a,token:t,approvalPageUrl:n});document.body.appendChild(i);var c=window.open(n,a);i.submit();var p=function(e){switch(e.data){case d:return u(),void r();case f:return u(),void o();case v:u()}},u=function(){c.close(),window.removeEventListener("message",p)};window.addEventListener("message",p)}var w={IFRAME:"iframe",TAB:"tab"},y={PRODUCTION:"production",SANDBOX:"sandbox"},b=function(e){return e===y.SANDBOX?"https://sandbox.transferwise.tech/approve-api-action/":"https://transferwise.com/approve-api-action/"};function g(e){var t=e.token,n=e.flow,r=void 0===n?w.IFRAME:n,o=e.mode,a=void 0===o?y.PRODUCTION:o,i=e.approvalPageUrl;return new Promise((function(e,n){var o={token:t,approvalPageUrl:i||b(a),resolve:e,reject:n};r===w.TAB?m(o):h(o)}))}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};e()}function P(e){if(!e||!e.response)return!1;var t=j(e.response),n=e.response.status;return(403===n||400===n)&&t}function j(e){return e&&e.headers&&e.headers.get?e.headers.get("X-2FA-APPROVAL"):null}e.Flow=w,e.Mode=y,e.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(t,n).then((function(e){return{response:e,metadata:{scaRequired:!1}}})).catch((function(o){if(P(o)){var a=j(o.response);return O(e.onSCARequired),g({token:a,flow:e.flow,mode:e.mode,approvalPageUrl:e.approvalPageUrl}).then((function(){O(e.onSCACompleted);var o=r(r({},n.headers||{}),{},{"X-2FA-APPROVAL":a});return s(t,r(r({},n),{},{headers:o})).then((function(e){return{response:e,metadata:{scaRequired:!0}}}))}))}throw o})).then((function(e){return n&&n.withMetadata?e:e.response}))}},e.runFlow=g,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@transferwise/approve-api-action-helpers",
"version": "0.2.0",
"version": "0.3.0",
"description": "An http client that handles SCA required requests gracefully",

@@ -11,4 +11,3 @@ "main": "dist/main.js",

"lint": "eslint src",
"build": "webpack",
"analyse-bundle": "webpack --profile --json > dist/stats.json && webpack-bundle-analyzer dist/stats.json"
"build": "rollup -c"
},

@@ -38,2 +37,3 @@ "repository": {

"babel-loader": "^8.0.6",
"core-js": "^3.6.5",
"eslint": "^7.11.0",

@@ -52,5 +52,8 @@ "eslint-config-prettier": "^6.13.0",

"prettier": "^2.1.2",
"webpack": "^5.1.3",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^4.1.0"
"rollup": "^2.32.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-babel-minify": "^10.0.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2"
},

@@ -57,0 +60,0 @@ "lint-staged": {

@@ -54,2 +54,3 @@ /* eslint-disable fp/no-mutation */

const overlay = document.createElement('div');
overlay.id = 'tw-approval-modal-overlay';
overlay.classList.add('tw-approval-modal-overlay');

@@ -106,3 +107,4 @@

const closeModal = () => {
overlay.remove();
const overlayElement = document.getElementById('tw-approval-modal-overlay');
overlayElement.parentNode.removeChild(overlayElement);
window.removeEventListener('message', handleEvents);

@@ -109,0 +111,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc