diff --git a/README.md b/README.md index 1b3aa31..751238a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Once you have a Link Session Token, create your MoneyKit Connect instance: ```js import MoneyKit from "@moneykit/connect"; -] + const moneykit = new MoneyKit(); ``` diff --git a/index.js b/index.js index a3e7f60..972ebcc 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import c from"query-string";var h=(n=>(n[n.largeTitle=0]="largeTitle",n[n.title1=1]="title1",n[n.title2=2]="title2",n[n.title3=3]="title3",n[n.body=4]="body",n[n.smallBody=5]="smallBody",n[n.button=6]="button",n[n.input=7]="input",n))(h||{});var d={colors:{accent:"#0077ff",primaryBackground:{light:"#fff",dark:"#212124"},secondaryBackground:{light:"#f2f2f5",dark:"#212124"},primaryContent:{light:"#fff",dark:"#343438"},secondaryContent:{light:"#f5f5f5",dark:"#343438"},primaryForeground:{light:"#111",dark:"#fff"},secondaryForeground:{light:"rgba(67, 67, 76, 0.6)",dark:"rgba(235, 235, 245, 0.6)"},tertiaryForeground:{light:"rgba(67, 67, 76, 0.3)",dark:"rgba(235, 234, 244, 0.3)"},primaryFill:{light:"rgba(120, 120, 128, 0.2)",dark:"rgba(120, 120, 128, 0.36)"},secondaryFill:{light:"rgba(120, 120, 128, 0.16)",dark:"rgba(120, 120, 128, 0.32)"},tertiaryFill:{light:"rgba(118, 118, 128, 0.12)",dark:"rgba(118, 118, 128, 0.24)"},success:{light:"#00ca32",dark:"#35DE5F"},warning:{light:"#ff9500",dark:"#FF9400"},error:{light:"#dd2424",dark:"#FA4242"},separator:{light:"rgba(60, 60, 67, 0.06)",dark:"rgba(84, 84, 88, 0.4)"},selection:{light:"rgba(120, 120, 128, 0.28)",dark:"rgba(120, 120, 128, 0.48)"}},typography:{fontFamily:"Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif",largeTitle:{size:"34px",lineHeight:"41px",letterSpacing:"-0.01em",weight:700},title1:{size:"28px",lineHeight:"34px",letterSpacing:"-0.03em",weight:700},title2:{size:"22px",lineHeight:"28px",letterSpacing:"0",weight:700},title3:{size:"20px",lineHeight:"24px",letterSpacing:"0",weight:700},body:{size:"17px",lineHeight:"24px",letterSpacing:"-0.01em",weight:500},smallBody:{size:"11px",lineHeight:"16px",letterSpacing:"-0.0225em",weight:400},button:{size:"18px",lineHeight:"24px",letterSpacing:"-1%",weight:700},input:{size:"19px",lineHeight:"24px",letterSpacing:"-0.02em",weight:500}},images:{close:"/images/close.svg",search:"/images/search.svg",spinner:"/images/spinner.png"},spacing:{contentHorizontalInset:"32px",buttonHorizontalInset:"24px"},components:{navigationBar:{height:"64px"},contentView:{borderRadius:"16px",boxShadow:{light:"none",dark:"inset 0 0 0 1px rgba(228, 227, 243, 0.04)"},border:null,separatorStyle:"all_except_last"},buttonPrimary:{height:"48px",borderRadius:"24px",inheritInstitutionColor:!0},searchInput:{backgroundColor:{light:"rgba(118, 118, 128, 0.12)",dark:"rgba(118, 118, 128, 0.24)"},height:"50px",borderRadius:"16px",border:null,alignment:"center",focus:{glow:!0,backgroundColor:null,border:null,boxShadow:null}},textField:{backgroundColor:null,height:"54px",borderRadius:"0px",boxShadow:null,focus:{glow:!0,backgroundColor:null,border:null,boxShadow:null}},progressSpinner:{strokeWidth:8,diameter:56,lineCap:"round"},icon:{strokeWidth:8,lineCap:"round"},separator:{height:"1px"}},screens:{finder:{title:"Connect Your Bank",subtitle:null,searchPlaceholder:"Search Banks",institutionCellBoxShadow:null,institutionCellBorderRadius:"16px",institutionCellBorder:{light:"1px solid rgba(60, 60, 67, 0.1)",dark:"1px solid rgba(84, 84, 88, 0.4)"},institutionCellSpacing:"16px",institutionCellBackgroundColor:{light:"#fff",dark:"#212124"}}},modal:{borderRadius:"20px",boxShadow:{light:"0px 2px 4px rgba(0, 0, 0, 0.1), 0 40px 80px rgba(0,0,0,.15)",dark:"inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 0 1px black, 0px 6px 18px rgba(0, 0, 0, 0.3)"},overlayBackgroundColor:{light:"rgba(0, 0, 0, 0.4)",dark:"rgba(0, 0, 0, 0.75)"},overlayBackdropFilter:null},popover:{borderRadius:"24px",boxShadow:{light:"0px 0px 80px rgba(0, 0, 0, 0.16)",dark:"inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 0 1px black, 0px 6px 18px rgba(0, 0, 0, 0.3)"}}};var u={name:"@moneykit/connect",description:"MoneyKit Connect launcher for web.",version:"0.3.0",author:"MoneyKit",repository:{type:"git",url:"https://github.com/moneykit/connect-js.git"},types:"./types/index.d.ts",license:"MIT"};var p="https://connect.moneykit.com";function T(i,t){let e=document.createElement("iframe");e.id="moneykit-connect-frame",e.src=i,e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.zIndex="999999";let o=t?document.getElementById(t):document.body;if(!o)throw new Error(`MoneyKit could not find container element with ID "${t}".`);return o.appendChild(e),e.addEventListener("load",function(){e.focus()}),e}function m(i){i.remove()}var y="moneykit.linkSessionToken",g=class{constructor(t={}){this.options={...t}}link(t,e,o,r){this.startLink(t,e,o,r)}relink(t,e,o,r){let s={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin},a=c.stringifyUrl({url:`${p}/relink`,query:s});this.launch(a,e,o,r)}continue(t,e,o,r){if(window.opener){window.opener.postMessage({moneykit:!0,type:"link.resume",eventData:{redirectURL:t}},p);return}this.continueLink(t,e,o,r)}__linkDirect(t,e,o,r){this.startLink(t,e,o,r,{viewMode:"direct"})}__continueDirect(t,e,o,r){this.continueLink(t,e,o,r,{viewMode:"direct"})}startLink(t,e,o,r,s){let a={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin,...s},l=c.stringifyUrl({url:`${p}/start`,query:a});localStorage.setItem(y,t),this.launch(l,e,o,r)}continueLink(t,e,o,r,s){let a=localStorage.getItem(y);a||console.warn("Unable to get MoneyKit link session token from local storage.");let l={...this.linkParametersFromOptions(),linkSessionToken:a,redirectURL:t,origin:window.location.origin,...s},n=c.stringifyUrl({url:`${p}/continue`,query:l});this.launch(n,e,o,r)}linkParametersFromOptions(){let t=this.options.applicationName??"",e=this.options.device??null,o=this.options.stepTimers??!0;return{applicationName:t,device:e,stepTimers:o,launcherVersion:u.version}}launch(t,e,o,r){let s=T(t,this.options.containerID),a=new AbortController,l=x(s,this.options.theme??d,a,e,o,r,this.options.__onDemoEvent);window.addEventListener("message",l,{signal:a.signal})}};function x(i,t,e,o,r,s,a){return l=>{if(l.origin!=p||!("moneykit"in l.data||"__moneykitDemo"in l.data))return;let n=l.data;switch(n.type){case"connect.started":l.source?.postMessage({moneykit:!0,type:"connect.set_theme",data:{theme:t}},{targetOrigin:p});break;case"link.complete":o&&n.data.exchangeableToken&&o(n.data.exchangeableToken,n.data.institution),m(i),e.abort();break;case"relink.complete":o&&o(n.data.institution),m(i),e.abort();break;case"link.exit":m(i),r&&r(n.data.error),e.abort();break;case"link.close_oauth":window.close();break;case"link.event":s&&s(n.data);break;case"demo.link.event":a&&a(n.data);break}}}var k=g,I=(i,t)=>{switch(t){case 0:return i.typography.largeTitle;case 1:return i.typography.title1;case 2:return i.typography.title2;case 3:return i.typography.title3;case 5:return i.typography.smallBody;case 6:return i.typography.button;case 7:return i.typography.input;default:return i.typography.body}};var E=k;export{h as ThemeTypographyTextStyle,E as default,d as moneyui,I as themeTypographyStyleForTextStyle}; +import c from"query-string";var h=(n=>(n[n.largeTitle=0]="largeTitle",n[n.title1=1]="title1",n[n.title2=2]="title2",n[n.title3=3]="title3",n[n.body=4]="body",n[n.smallBody=5]="smallBody",n[n.button=6]="button",n[n.input=7]="input",n))(h||{});var d={colors:{accent:"#0077ff",primaryBackground:{light:"#fff",dark:"#212124"},secondaryBackground:{light:"#f2f2f5",dark:"#212124"},primaryContent:{light:"#fff",dark:"#343438"},secondaryContent:{light:"#f5f5f5",dark:"#343438"},primaryForeground:{light:"#111",dark:"#fff"},secondaryForeground:{light:"rgba(67, 67, 76, 0.6)",dark:"rgba(235, 235, 245, 0.6)"},tertiaryForeground:{light:"rgba(67, 67, 76, 0.3)",dark:"rgba(235, 234, 244, 0.3)"},primaryFill:{light:"rgba(120, 120, 128, 0.2)",dark:"rgba(120, 120, 128, 0.36)"},secondaryFill:{light:"rgba(120, 120, 128, 0.16)",dark:"rgba(120, 120, 128, 0.32)"},tertiaryFill:{light:"rgba(118, 118, 128, 0.12)",dark:"rgba(118, 118, 128, 0.24)"},success:{light:"#00ca32",dark:"#35DE5F"},warning:{light:"#ff9500",dark:"#FF9400"},error:{light:"#dd2424",dark:"#FA4242"},separator:{light:"rgba(60, 60, 67, 0.06)",dark:"rgba(84, 84, 88, 0.4)"},selection:{light:"rgba(120, 120, 128, 0.28)",dark:"rgba(120, 120, 128, 0.48)"}},typography:{fontFamily:"Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif",largeTitle:{size:"34px",lineHeight:"41px",letterSpacing:"-0.01em",weight:700},title1:{size:"28px",lineHeight:"34px",letterSpacing:"-0.03em",weight:700},title2:{size:"22px",lineHeight:"28px",letterSpacing:"0",weight:700},title3:{size:"20px",lineHeight:"24px",letterSpacing:"0",weight:700},body:{size:"17px",lineHeight:"24px",letterSpacing:"-0.01em",weight:500},smallBody:{size:"11px",lineHeight:"16px",letterSpacing:"-0.0225em",weight:400},button:{size:"18px",lineHeight:"24px",letterSpacing:"-1%",weight:700},input:{size:"19px",lineHeight:"24px",letterSpacing:"-0.02em",weight:500}},images:{close:"/images/close.svg",search:"/images/search.svg",spinner:"/images/spinner.png"},spacing:{contentHorizontalInset:"32px",buttonHorizontalInset:"24px"},components:{navigationBar:{height:"64px"},contentView:{borderRadius:"16px",boxShadow:{light:"none",dark:"inset 0 0 0 1px rgba(228, 227, 243, 0.04)"},border:null,separatorStyle:"all_except_last"},buttonPrimary:{height:"48px",borderRadius:"24px",inheritInstitutionColor:!0},searchInput:{backgroundColor:{light:"rgba(118, 118, 128, 0.12)",dark:"rgba(118, 118, 128, 0.24)"},height:"50px",borderRadius:"16px",border:null,alignment:"center",focus:{glow:!0,backgroundColor:null,border:null,boxShadow:null}},textField:{backgroundColor:null,height:"54px",borderRadius:"0px",boxShadow:null,focus:{glow:!0,backgroundColor:null,border:null,boxShadow:null}},progressSpinner:{strokeWidth:8,diameter:56,lineCap:"round"},icon:{strokeWidth:8,lineCap:"round"},separator:{height:"1px"}},screens:{finder:{title:"Connect Your Bank",subtitle:null,searchPlaceholder:"Search Banks",institutionCellBoxShadow:null,institutionCellBorderRadius:"16px",institutionCellBorder:{light:"1px solid rgba(60, 60, 67, 0.1)",dark:"1px solid rgba(84, 84, 88, 0.4)"},institutionCellSpacing:"16px",institutionCellBackgroundColor:{light:"#fff",dark:"#212124"}}},modal:{borderRadius:"20px",boxShadow:{light:"0px 2px 4px rgba(0, 0, 0, 0.1), 0 40px 80px rgba(0,0,0,.15)",dark:"inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 0 1px black, 0px 6px 18px rgba(0, 0, 0, 0.3)"},overlayBackgroundColor:{light:"rgba(0, 0, 0, 0.4)",dark:"rgba(0, 0, 0, 0.75)"},overlayBackdropFilter:null},popover:{borderRadius:"24px",boxShadow:{light:"0px 0px 80px rgba(0, 0, 0, 0.16)",dark:"inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 0 1px black, 0px 6px 18px rgba(0, 0, 0, 0.3)"}}};var u={name:"@moneykit/connect",description:"MoneyKit Connect launcher for web.",version:"0.3.1",author:"MoneyKit",repository:{type:"git",url:"https://github.com/moneykit/connect-js.git"},types:"./types/index.d.ts",license:"MIT"};var p="https://connect.moneykit.com";function T(i,t){let e=document.createElement("iframe");e.id="moneykit-connect-frame",e.src=i,e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.zIndex="999999";let o=t?document.getElementById(t):document.body;if(!o)throw new Error(`MoneyKit could not find container element with ID "${t}".`);return o.appendChild(e),e.addEventListener("load",function(){e.focus()}),e}function m(i){i.remove()}var y="moneykit.linkSessionToken",g=class{constructor(t={}){this.options={...t}}link(t,e,o,r){this.startLink(t,e,o,r)}relink(t,e,o,r){let s={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin},a=c.stringifyUrl({url:`${p}/relink`,query:s});this.launch(a,e,o,r)}continue(t,e,o,r){if(window.opener){window.opener.postMessage({moneykit:!0,type:"link.resume",eventData:{redirectURL:t}},p);return}this.continueLink(t,e,o,r)}__linkDirect(t,e,o,r){this.startLink(t,e,o,r,{viewMode:"direct"})}__continueDirect(t,e,o,r){this.continueLink(t,e,o,r,{viewMode:"direct"})}startLink(t,e,o,r,s){let a={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin,...s},l=c.stringifyUrl({url:`${p}/start`,query:a});localStorage.setItem(y,t),this.launch(l,e,o,r)}continueLink(t,e,o,r,s){let a=localStorage.getItem(y);a||console.warn("Unable to get MoneyKit link session token from local storage.");let l={...this.linkParametersFromOptions(),linkSessionToken:a,redirectURL:t,origin:window.location.origin,...s},n=c.stringifyUrl({url:`${p}/continue`,query:l});this.launch(n,e,o,r)}linkParametersFromOptions(){let t=this.options.applicationName??"",e=this.options.device??null,o=this.options.stepTimers??!0;return{applicationName:t,device:e,stepTimers:o,launcherVersion:u.version}}launch(t,e,o,r){let s=T(t,this.options.containerID),a=new AbortController,l=x(s,this.options.theme??d,a,e,o,r,this.options.__onDemoEvent);window.addEventListener("message",l,{signal:a.signal})}};function x(i,t,e,o,r,s,a){return l=>{if(l.origin!=p||!("moneykit"in l.data||"__moneykitDemo"in l.data))return;let n=l.data;switch(n.type){case"connect.started":l.source?.postMessage({moneykit:!0,type:"connect.set_theme",data:{theme:t}},{targetOrigin:p});break;case"link.complete":o&&n.data.exchangeableToken&&o(n.data.exchangeableToken,n.data.institution),m(i),e.abort();break;case"relink.complete":o&&o(n.data.institution),m(i),e.abort();break;case"link.exit":m(i),r&&r(n.data.error),e.abort();break;case"link.close_oauth":window.close();break;case"link.event":s&&s(n.data);break;case"demo.link.event":a&&a(n.data);break}}}var k=g,I=(i,t)=>{switch(t){case 0:return i.typography.largeTitle;case 1:return i.typography.title1;case 2:return i.typography.title2;case 3:return i.typography.title3;case 5:return i.typography.smallBody;case 6:return i.typography.button;case 7:return i.typography.input;default:return i.typography.body}};var E=k;export{h as ThemeTypographyTextStyle,E as default,d as moneyui,I as themeTypographyStyleForTextStyle}; diff --git a/package.json b/package.json index 0b94b81..26b7b95 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@moneykit/connect", "description": "MoneyKit Connect launcher for web.", - "version": "0.3.0", + "version": "0.3.1", "author": "MoneyKit", "repository": { "type": "git",