@moneykit/connect 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +16 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -29,6 +29,21 @@ The `link` method also accepts three optional callback parameters:
29
29
  - `onLinkExit` - called whenever the link process is exited manually by the user. Receives no arguments at this time.
30
30
  - `onLinkEvent` - called whenever various events occur at different stages of the linking process, as indicated by the Event object argument. Can be used to tailor or notify your application as a user progresses through a link.
31
31
 
32
+ ### OAuth Flows
33
+
34
+ Many Financial Institutions require users to authorize the connection via OAuth on the institution's own website.
35
+
36
+ To support this workflow you must provide a `redirect_uri` when creating a Link Session via the MoneyKit API. This URI should go to a page of yours which can re-initialize MoneyKit Connect via its `continue()` method. This method requires the URL that was redirected to as its first argument (the URL should included all query parameters appended by MoneyKit during the redirect) followed by all of the same optional callbacks detailed for the `link()` method above.
37
+
38
+ ```js
39
+ // my-redirect-page.js
40
+ import MoneyKit from "@moneykit/connect";
41
+ const moneykit = new MoneyKit();
42
+ moneykit.continue(window.location.href, (exchangeableToken, institution) => {
43
+ console.log(exchangeableToken, institution);
44
+ });
45
+ ```
46
+
32
47
  ## Link Token Exchange
33
48
 
34
- To finalize the connection and acquire a long-lived access token with which to make subsequent requests, you must pass this exchangeable token to your secure backend service which should then [exchange](https://docs.moneykit.com/openapi/core/#operation/exchange_token) it via the MoneyKit API.
49
+ To finalize the connection and acquire a link ID with which to make subsequent requests, you must pass your exchangeable token received upon completion of a user's connection to your secure backend service. It should then [exchange](https://docs.moneykit.com/openapi/core/#operation/exchange_token) the token for a link ID via the MoneyKit API.
package/index.js CHANGED
@@ -1 +1 @@
1
- import m from"query-string";var u={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:500},input:{size:"19px",lineHeight:"24px",letterSpacing:"-0.02em",weight:500}},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},buttonPrimary:{height:"48px",borderRadius:"24px"},searchBar:{height:"50px",borderRadius:"16px"},textField:{height:"54px",borderRadius:"0px"}},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)"}}},c=u;var h=(o=>(o[o.largeTitle=0]="largeTitle",o[o.title1=1]="title1",o[o.title2=2]="title2",o[o.title3=3]="title3",o[o.body=4]="body",o[o.smallBody=5]="smallBody",o[o.button=6]="button",o[o.input=7]="input",o))(h||{});var s="https://connect.moneykit.com";function k(n,t){let e=document.createElement("iframe");e.src=n,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 i=t?document.getElementById(t):document.body;if(!i)throw new Error(`MoneyKit could not find container element with ID "${t}".`);return i.appendChild(e),e}function d(n){n.remove()}var x="moneykit.linkSessionToken",g=class{constructor(t={}){this.options={...t}}link(t,e,i,l){let a={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin},r=m.stringifyUrl({url:`${s}/start`,query:a});this.launch(r,e,i,l)}relink(t,e,i,l){let a={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin},r=m.stringifyUrl({url:`${s}/relink`,query:a});this.launch(r,e,i,l)}continue(t,e,i,l){if(window.opener){window.opener.postMessage({moneykit:!0,type:"link.resume",eventData:{redirectURL:t}},s);return}let a=localStorage.getItem(x);a||console.warn("Unable to get MoneyKit link session token from local storage.");let r={...this.linkParametersFromOptions(),linkSessionToken:a,redirectURL:t,origin:window.location.origin},p=m.stringifyUrl({url:`${s}/continue`,query:r});this.launch(p,e,i,l)}linkParametersFromOptions(){let t=this.options.applicationName??"",e=this.options.theme??c,i=this.options.device??null,l=this.options.stepTimers??!0;return{applicationName:t,theme:JSON.stringify(e),device:i,stepTimers:l}}launch(t,e,i,l){let a=k(t,this.options.containerID),r=new AbortController,p=T(a,r,e,i,l);window.addEventListener("message",p,{signal:r.signal})}};function T(n,t,e,i,l){return a=>{if(a.origin!=s||!("moneykit"in a.data||"__moneykitDemo"in a.data))return;let r=a.data;switch(r.type){case"link.complete":e&&r.data.exchangeableToken&&e(r.data.exchangeableToken,r.data.institution),d(n),t.abort();break;case"relink.complete":e&&e(r.data.institution),d(n),t.abort();break;case"link.exit":d(n),i&&i(),t.abort();break;case"link.close_oauth":window.close();break;case"link.event":case"demo.link.event":l&&l(r.data);break}}}var y=g;var D=(n,t)=>{switch(t){case 0:return n.typography.largeTitle;case 1:return n.typography.title1;case 2:return n.typography.title2;case 3:return n.typography.title3;case 5:return n.typography.smallBody;case 6:return n.typography.button;case 7:return n.typography.input;default:return n.typography.body}};var E=y;export{h as ThemeTypographyTextStyle,E as default,c as moneyui,D as themeTypographyStyleForTextStyle};
1
+ import m from"query-string";var h="0.1.6";var T={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:500},input:{size:"19px",lineHeight:"24px",letterSpacing:"-0.02em",weight:500}},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},buttonPrimary:{height:"48px",borderRadius:"24px"},searchBar:{height:"50px",borderRadius:"16px"},textField:{height:"54px",borderRadius:"0px"}},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)"}}},c=T;var y=(o=>(o[o.largeTitle=0]="largeTitle",o[o.title1=1]="title1",o[o.title2=2]="title2",o[o.title3=3]="title3",o[o.body=4]="body",o[o.smallBody=5]="smallBody",o[o.button=6]="button",o[o.input=7]="input",o))(y||{});var s="https://connect.moneykit.com";function b(n,t){let e=document.createElement("iframe");e.src=n,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 i=t?document.getElementById(t):document.body;if(!i)throw new Error(`MoneyKit could not find container element with ID "${t}".`);return i.appendChild(e),e}function g(n){n.remove()}var C="moneykit.linkSessionToken",d=class{constructor(t={}){this.options={...t}}link(t,e,i,l){let a={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin},r=m.stringifyUrl({url:`${s}/start`,query:a});this.launch(r,e,i,l)}relink(t,e,i,l){let a={...this.linkParametersFromOptions(),linkSessionToken:t,origin:window.location.origin},r=m.stringifyUrl({url:`${s}/relink`,query:a});this.launch(r,e,i,l)}continue(t,e,i,l){if(window.opener){window.opener.postMessage({moneykit:!0,type:"link.resume",eventData:{redirectURL:t}},s);return}let a=localStorage.getItem(C);a||console.warn("Unable to get MoneyKit link session token from local storage.");let r={...this.linkParametersFromOptions(),linkSessionToken:a,redirectURL:t,origin:window.location.origin},p=m.stringifyUrl({url:`${s}/continue`,query:r});this.launch(p,e,i,l)}linkParametersFromOptions(){let t=this.options.applicationName??"",e=this.options.theme??c,i=this.options.device??null,l=this.options.stepTimers??!0;return{applicationName:t,theme:JSON.stringify(e),device:i,stepTimers:l,launcherVersion:h}}launch(t,e,i,l){let a=b(t,this.options.containerID),r=new AbortController,p=B(a,r,e,i,l);window.addEventListener("message",p,{signal:r.signal})}};function B(n,t,e,i,l){return a=>{if(a.origin!=s||!("moneykit"in a.data||"__moneykitDemo"in a.data))return;let r=a.data;switch(r.type){case"link.complete":e&&r.data.exchangeableToken&&e(r.data.exchangeableToken,r.data.institution),g(n),t.abort();break;case"relink.complete":e&&e(r.data.institution),g(n),t.abort();break;case"link.exit":g(n),i&&i(),t.abort();break;case"link.close_oauth":window.close();break;case"link.event":case"demo.link.event":l&&l(r.data);break}}}var u=d;var E=(n,t)=>{switch(t){case 0:return n.typography.largeTitle;case 1:return n.typography.title1;case 2:return n.typography.title2;case 3:return n.typography.title3;case 5:return n.typography.smallBody;case 6:return n.typography.button;case 7:return n.typography.input;default:return n.typography.body}};var _=u;export{y as ThemeTypographyTextStyle,_ as default,c as moneyui,E as themeTypographyStyleForTextStyle};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moneykit/connect",
3
3
  "description": "MoneyKit Connect launcher for web.",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "author": "MoneyKit",
6
6
  "repository": {
7
7
  "type": "git",