@moneykit/connect 0.3.22 → 0.3.24

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.
package/README.md CHANGED
@@ -1,200 +1,3 @@
1
1
  # MoneyKit Connect
2
2
 
3
- JavaScript SDK for connecting to a financial institution via MoneyKit Connect in a web browser.
4
-
5
- ## Installation
6
-
7
- To begin using Connect simply add the `@moneykit/connect` package to your project's dependencies.
8
-
9
- ```sh
10
- npm install @moneykit/connect
11
- ```
12
-
13
- ## Usage
14
-
15
- To use MoneyKit Connect you must first [create a Link Session](https://docs.moneykit.com/link-session/create-link-session) via the MoneyKit API to acquire a Link Session Token.
16
-
17
- Once you have a Link Session Token, create your MoneyKit Connect instance:
18
-
19
- ```js
20
- import MoneyKit from "@moneykit/connect";
21
-
22
- const moneykit = new MoneyKit();
23
- ```
24
-
25
- Configuration options may also be provided to customize Connect's behavior. See [Configuration](#configuration) for details.
26
-
27
- You may then launch the MoneyKit Connect flow by calling `link()` with your link session token. This will open a popup window to MoneyKit Connect in which the user may select and log into their financial institution, select their accounts and grant permissions before handing off back to your application.
28
-
29
- ---
30
-
31
- Note that to support financial institutions that require OAuth login it is required that you also provide a `redirect_uri` when creating your Link Session. This URI should point to a page within your app which re-initializes MoneyKit Connect via its `continue()` method. This method requires the URL that was redirected to as its first parameter (the URL should include any query parameters appended by MoneyKit during the redirect).
32
-
33
- ---
34
-
35
- The `link`, `continue` and [`relink`](#relinking) methods accept the same three optional callbacks which you may use to handle the results of the Connect flow:
36
-
37
- - `onLinkSuccess`: called when the linking process completes successfully. This callback will be passed two parameters: an exchangeable MoneyKit API token (see [Link Token Exchange](#link-token-exchange)) and the [Institution](#linkedinstitution) which was linked. The linked institution also includes a subset of data from financial accounts linked by the user including account type, name and mask.
38
- - `onLinkExit`: called whenever the Connect process is exited manually by the user or due to an unexpected error.
39
- - `onLinkEvent`: called with an [`Event`](#events) object whenever certain events occur throughout the Connect flow, as indicated by the Event object parameter. These may be used to tailor or notify your application as a user progresses through a link or for analytics purposes.
40
-
41
- ### OAuth
42
-
43
- When a user's financial institution uses OAuth for login, the user will be temporarily navigated to the institution's login page before being returned to your application.
44
-
45
- In most cases the OAuth page will be opened as a new popup window. Upon successful authorization with the institution this window will navigate back to the `redirect_uri` you specified when creating your Link Session. (Note that on mobile browsers such as iOS Safari this window will be opened as a new tab instead of a popup.)
46
-
47
- When you call `continue()` from your app after receiving this redirect, the OAuth window will be closed and the Connect flow will resume back in the original window.
48
-
49
- #### Note on Webview usage
50
-
51
- If Connect is launched inside of a mobile webview (such as one embedded within a native iOS or Android app) where it is not permitted to open a new window or tab, this will be detected by Connect and instead the topmost window in the window hierarchy will be navigated to the OAuth page. This window will then redirect back to your `redirect_uri` as normal. Calling `continue()` in this scenario will re-launch Connect and allow the user to proceed with their in-progress link.
52
-
53
- ### Example
54
-
55
- ```js
56
- // Present Connect to the user and log the result
57
- moneykit.link(
58
- linkSessionToken,
59
- (exchangeableToken, institution) => {
60
- // onLinkSuccess
61
- console.log("Link created successfully", exchangeableToken, institution);
62
- },
63
- (error) => {
64
- // onLinkExit
65
- console.log(
66
- "Connect closed without creating a link. Error will be provided if one occurred."
67
- );
68
- },
69
- (event) => {
70
- // onLinkEvent
71
- console.log("Link event occurred: ", JSON.stringify(event));
72
- }
73
- );
74
-
75
- /**
76
- * Required for OAuth institutions.
77
- * This will present Connect again and allow the user to continue their link
78
- * in progress after completing OAuth with their financial institution.
79
- *
80
- * This `continue()` call should be performed on the page you indicated
81
- * as your `redirect_uri` when creating a Link Session.
82
- * The complete URL that was redirected to should be passed as the first argument.
83
- */
84
- moneykit.continue(window.location.href, (exchangeableToken, institution) => {
85
- console.log(exchangeableToken, institution);
86
- });
87
- ```
88
-
89
- ### Relinking
90
-
91
- In the event that a user's existing link has expired (e.g. due to the financial institution requiring periodic user re-authorization) your MoneyKit API requests will respond with an `auth_expired` error.
92
-
93
- To re-authorize the user you may call `relink()` with a link session token and callbacks identical to those for the `link()` method. In this case the link session token must have been created with the `existing_link_id` field set to the ID of the link you wish to re-authorize.
94
-
95
- Connect will be opened as normal, however the institution selection step will be bypassed and the user will be immediately prompted to log in to the institution and re-authorize the connection.
96
-
97
- ## Link Token Exchange
98
-
99
- To finalize the connection and acquire a link ID with which to make subsequent API 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/link-session/exchange-token) the token for a link ID via the MoneyKit API.
100
-
101
- ## Configuration
102
-
103
- When initializing MoneyKit Connect you may optionally provide it with an options object.
104
-
105
- ```
106
- const moneykit = new MoneyKit({
107
- containerID: "moneykit-container",
108
- });
109
- ```
110
-
111
- Currently the following options are supported:
112
-
113
- **`containerID`**
114
-
115
- The ID of the DOM element to which Connect and it's overlay will be appended. If not provided, Connect will be appended to the document body by default.
116
-
117
- ## Data Types
118
-
119
- ### LinkedInstitution
120
-
121
- A LinkedInstitution will be returned to your link success callback functions and includes the following data.
122
-
123
- ```
124
- {
125
- avatar: string | null;
126
- avatar_dark: string | null;
127
- color: string;
128
- color_dark: string | null;
129
- country: string;
130
- domain: string;
131
- id: string;
132
- logo: string | null;
133
- logo_dark: string | null;
134
- name: string;
135
- selectedAccounts: {
136
- account_id: string;
137
- account_type: AccountType;
138
- name: string;
139
- account_mask: string | null;
140
- }[];
141
- trackedScreens: {
142
- tag: string;
143
- name: string;
144
- duration: number;
145
- }[]
146
- }
147
- ```
148
-
149
- ### Events
150
-
151
- The following event types will be sent to your `onLinkEvent` callback function if you provide one.
152
-
153
- ```
154
- {
155
- name: EventType;
156
- properties?: Record<string, unknown>
157
- meta: {
158
- link_type: "link" | "relink";
159
- timestamp: string;
160
- link_session_id: string;
161
- institution_id?: string;
162
- institution_name?: string;
163
- }
164
- }
165
- ```
166
-
167
- The contents of `properties` will depend on the event type. `institution_id` and `institution_name` will be present only on events occurring after an Institution has been selected by the user.
168
-
169
- **Event types:**
170
-
171
- - `open`
172
- - Connect was opened
173
- - `exit`
174
- - Connect was closed without a link being created
175
- - `success`
176
- - Connect was closed after successfully creating a link
177
- - `error`
178
- - An error occurred during the Connect flow. Details of the error will be included in the event's properties.
179
- - `change_screen`
180
- - The user navigated to a new screen within Connect. The screen name will be included in the event's properties.
181
- - `select_institution`
182
- - The user selected an institution. The institution ID and name will be included in the event's properties.
183
- - `search_institution`
184
- - The user searched for an institution. The search query will be included in the event's properties.
185
- - `submit_credentials`
186
- - The user submitted their credentials to log in to their institution.
187
- - `open_oauth`
188
- - The user was directed to their institution's OAuth page.
189
- - `submit_otp_device`
190
- - The user selected a device to receive an OTP.
191
- - `submit_otp`
192
- - The user submitted their OTP.
193
- - `submit_mfa`
194
- - The user submitted a MFA answer.
195
- - `submit_permissions`
196
- - The user selected which permissions to grant.
197
- - `submit_accounts`
198
- - The user selected which accounts to link.
199
-
200
- Note that it is possible new event types not yet included here may also be sent.
3
+ Please refer to the [MoneyKit Connect Web SDK documentation](https://docs.moneykit.com/connect/web) for more info.
package/index.js CHANGED
@@ -1 +1 @@
1
- import m from"query-string";var y={name:"@moneykit/connect",description:"MoneyKit Connect launcher for web.",version:"0.3.20",author:"MoneyKit",repository:{type:"git",url:"https://github.com/moneykit/connect-js.git"},types:"./types/index.d.ts",license:"MIT"};var c="https://connect.moneykit.com";function T(i,e){let t=document.createElement("iframe");t.id="moneykit-connect-frame",t.src=i,t.style.position=e?"absolute":"fixed",t.style.top="0",t.style.left="0",t.style.width=e?"100%":"100vw",t.style.height=e?"100%":"100svh",t.style.zIndex="999999";let o=e?document.getElementById(e):document.body;if(!o)throw new Error(`MoneyKit could not find container element with ID "${e}".`);return o.appendChild(t),t.addEventListener("load",function(){t.focus()}),t}function h(i){i.remove()}var g="moneykit.linkSessionToken",d=class{constructor(e={}){c=e.__connectSDKUIHost??c,this.options={...e}}link(e,t,o,r){this.startLink(e,t,o,r)}relink(e,t,o,r){this.startRelink(e,t,o,r)}continue(e,t,o,r){if(window.opener){window.opener.postMessage({moneykit:!0,type:"link.resume",eventData:{redirectURL:e}},c);return}this.continueLink(e,t,o,r)}__linkDirect(e,t,o,r){this.startLink(e,t,o,r,{viewMode:"direct"})}__relinkDirect(e,t,o,r){this.startRelink(e,t,o,r,{viewMode:"direct"})}__continueDirect(e,t,o,r){this.continueLink(e,t,o,r,{viewMode:"direct"})}startLink(e,t,o,r,l){let a={...this.linkParametersFromOptions(),linkSessionToken:e,origin:window.location.origin,...l},s=m.stringifyUrl({url:`${c}/start`,query:a});localStorage.setItem(g,e),this.launch(s,t,o,r)}startRelink(e,t,o,r,l){let a={...this.linkParametersFromOptions(),linkSessionToken:e,origin:window.location.origin,...l},s=m.stringifyUrl({url:`${c}/relink`,query:a});localStorage.setItem(g,e),this.launch(s,t,o,r)}continueLink(e,t,o,r,l){let a=localStorage.getItem(g);a||console.warn("Unable to get MoneyKit link session token from local storage.");let s={...this.linkParametersFromOptions(),linkSessionToken:a,redirectURL:e,origin:window.location.origin,...l},n=m.stringifyUrl({url:`${c}/continue`,query:s});this.launch(n,t,o,r)}linkParametersFromOptions(){let e=this.options.__applicationName??null,t=this.options.device??null,o=this.options.stepTimers??!1;return{applicationName:e,device:t,stepTimers:o,launcherVersion:y.version}}launch(e,t,o,r){let l=T(e,this.options.containerID),a=new AbortController,s=b(l,a,t,o,r,this.options.__onDemoEvent,this.options.theme,this.options.colorScheme);window.addEventListener("message",s,{signal:a.signal})}};function b(i,e,t,o,r,l,a,s){return n=>{if(n.origin!=c||!("moneykit"in n.data||"__moneykitDemo"in n.data)){console.warn("MoneyKit Connect received a message from an unexpected origin",n.origin);return}let p=n.data;switch(p.type){case"connect.started":s&&n.source?.postMessage({moneykit:!0,type:"connect.set_color_scheme",data:{colorScheme:s}},{targetOrigin:c}),a&&n.source?.postMessage({moneykit:!0,type:"connect.set_theme",data:{theme:a}},{targetOrigin:c});break;case"link.complete":t&&p.data.exchangeableToken&&t(p.data.exchangeableToken,p.data.institution),h(i),e.abort();break;case"relink.complete":t&&t(p.data.institution),h(i),e.abort();break;case"link.exit":h(i),o&&o(p.data.error),e.abort();break;case"link.close_oauth":window.close();break;case"link.event":r&&r(p.data);break;case"demo.link.event":l&&l(p.data);break}}}var u=d;var x=(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))(x||{}),v=(i,e)=>{switch(e){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 M={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",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:"18px",lineHeight:"24px",letterSpacing:"0",weight:500}},images:{close:"/images/close.svg",search:"/images/search.svg",spinner:"/images/spinner.png"},spacing:{contentHorizontalInset:"28px",buttonHorizontalInset:"28px"},components:{navigationBar:{height:"64px"},contentView:{borderRadius:"12px",boxShadow:{light:"none",dark:"inset 0 0 0 1px rgba(228, 227, 243, 0.04)"},border:null,separatorStyle:"all_except_last"},button:{height:"44px",borderRadius:"12px",inheritInstitutionColor:!0,continueTitle:"Continue",doneTitle:"Done"},searchInput:{backgroundColor:{light:"rgba(118, 118, 128, 0.12)",dark:"rgba(118, 118, 128, 0.24)"},height:"48px",borderRadius:"12px",border:null,alignment:"center",focus:{glow:!0,backgroundColor:null,border:null,boxShadow:null}},textField:{backgroundColor:null,height:"52px",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:"12px",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 L=u;export{x as ThemeTypographyTextStyle,L as default,M as moneyui,v as themeTypographyStyleForTextStyle};
1
+ var N=Object.defineProperty;var v=(e,r)=>{for(var t in r)N(e,t,{get:r[t],enumerable:!0})};var b={};v(b,{exclude:()=>W,extract:()=>k,parse:()=>x,parseUrl:()=>R,pick:()=>O,stringify:()=>_,stringifyUrl:()=>K});var B="%[a-f0-9]{2}",F=new RegExp("("+B+")|([^%]+?)","gi"),w=new RegExp("("+B+")+","gi");function u(e,r){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;r=r||1;let t=e.slice(0,r),n=e.slice(r);return Array.prototype.concat.call([],u(t),u(n))}function H(e){try{return decodeURIComponent(e)}catch{let r=e.match(F)||[];for(let t=1;t<r.length;t++)e=u(r,t).join(""),r=e.match(F)||[];return e}}function z(e){let r={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},t=w.exec(e);for(;t;){try{r[t[0]]=decodeURIComponent(t[0])}catch{let o=H(t[0]);o!==t[0]&&(r[t[0]]=o)}t=w.exec(e)}r["%C2"]="\uFFFD";let n=Object.keys(r);for(let o of n)e=e.replace(new RegExp(o,"g"),r[o]);return e}function y(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return z(e)}}function h(e,r){if(!(typeof e=="string"&&typeof r=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||r==="")return[];let t=e.indexOf(r);return t===-1?[]:[e.slice(0,t),e.slice(t+r.length)]}function I(e,r){let t={};if(Array.isArray(r))for(let n of r){let o=Object.getOwnPropertyDescriptor(e,n);o?.enumerable&&Object.defineProperty(t,n,o)}else for(let n of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,n);if(o.enumerable){let a=e[n];r(n,a,e)&&Object.defineProperty(t,n,o)}}return t}var j=e=>e==null,P=e=>encodeURIComponent(e).replace(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`),f=Symbol("encodeFragmentIdentifier");function $(e){switch(e.arrayFormat){case"index":return r=>(t,n)=>{let o=t.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),"[",o,"]"].join("")]:[...t,[c(r,e),"[",c(o,e),"]=",c(n,e)].join("")]};case"bracket":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),"[]"].join("")]:[...t,[c(r,e),"[]=",c(n,e)].join("")];case"colon-list-separator":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),":list="].join("")]:[...t,[c(r,e),":list=",c(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{let r=e.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,o)=>o===void 0||e.skipNull&&o===null||e.skipEmptyString&&o===""?n:(o=o===null?"":o,n.length===0?[[c(t,e),r,c(o,e)].join("")]:[[n,c(o,e)].join(e.arrayFormatSeparator)])}default:return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,c(r,e)]:[...t,[c(r,e),"=",c(n,e)].join("")]}}function V(e){let r;switch(e.arrayFormat){case"index":return(t,n,o)=>{if(r=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!r){o[t]=n;return}o[t]===void 0&&(o[t]={}),o[t][r[1]]=n};case"bracket":return(t,n,o)=>{if(r=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!r){o[t]=n;return}if(o[t]===void 0){o[t]=[n];return}o[t]=[...o[t],n]};case"colon-list-separator":return(t,n,o)=>{if(r=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!r){o[t]=n;return}if(o[t]===void 0){o[t]=[n];return}o[t]=[...o[t],n]};case"comma":case"separator":return(t,n,o)=>{let a=typeof n=="string"&&n.includes(e.arrayFormatSeparator),i=typeof n=="string"&&!a&&m(n,e).includes(e.arrayFormatSeparator);n=i?m(n,e):n;let l=a||i?n.split(e.arrayFormatSeparator).map(s=>m(s,e)):n===null?n:m(n,e);o[t]=l};case"bracket-separator":return(t,n,o)=>{let a=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!a){o[t]=n&&m(n,e);return}let i=n===null?[]:n.split(e.arrayFormatSeparator).map(l=>m(l,e));if(o[t]===void 0){o[t]=i;return}o[t]=[...o[t],...i]};default:return(t,n,o)=>{if(o[t]===void 0){o[t]=n;return}o[t]=[...[o[t]].flat(),n]}}}function E(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function c(e,r){return r.encode?r.strict?P(e):encodeURIComponent(e):e}function m(e,r){return r.decode?y(e):e}function D(e){return Array.isArray(e)?e.sort():typeof e=="object"?D(Object.keys(e)).sort((r,t)=>Number(r)-Number(t)).map(r=>e[r]):e}function L(e){let r=e.indexOf("#");return r!==-1&&(e=e.slice(0,r)),e}function q(e){let r="",t=e.indexOf("#");return t!==-1&&(r=e.slice(t)),r}function M(e,r){return r.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?e=Number(e):r.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")&&(e=e.toLowerCase()==="true"),e}function k(e){e=L(e);let r=e.indexOf("?");return r===-1?"":e.slice(r+1)}function x(e,r){r={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...r},E(r.arrayFormatSeparator);let t=V(r),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(let o of e.split("&")){if(o==="")continue;let a=r.decode?o.replace(/\+/g," "):o,[i,l]=h(a,"=");i===void 0&&(i=a),l=l===void 0?null:["comma","separator","bracket-separator"].includes(r.arrayFormat)?l:m(l,r),t(m(i,r),l,n)}for(let[o,a]of Object.entries(n))if(typeof a=="object"&&a!==null)for(let[i,l]of Object.entries(a))a[i]=M(l,r);else n[o]=M(a,r);return r.sort===!1?n:(r.sort===!0?Object.keys(n).sort():Object.keys(n).sort(r.sort)).reduce((o,a)=>{let i=n[a];return i&&typeof i=="object"&&!Array.isArray(i)?o[a]=D(i):o[a]=i,o},Object.create(null))}function _(e,r){if(!e)return"";r={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...r},E(r.arrayFormatSeparator);let t=i=>r.skipNull&&j(e[i])||r.skipEmptyString&&e[i]==="",n=$(r),o={};for(let[i,l]of Object.entries(e))t(i)||(o[i]=l);let a=Object.keys(o);return r.sort!==!1&&a.sort(r.sort),a.map(i=>{let l=e[i];return l===void 0?"":l===null?c(i,r):Array.isArray(l)?l.length===0&&r.arrayFormat==="bracket-separator"?c(i,r)+"[]":l.reduce(n(i),[]).join("&"):c(i,r)+"="+c(l,r)}).filter(i=>i.length>0).join("&")}function R(e,r){r={decode:!0,...r};let[t,n]=h(e,"#");return t===void 0&&(t=e),{url:t?.split("?")?.[0]??"",query:x(k(e),r),...r&&r.parseFragmentIdentifier&&n?{fragmentIdentifier:m(n,r)}:{}}}function K(e,r){r={encode:!0,strict:!0,[f]:!0,...r};let t=L(e.url).split("?")[0]||"",n=k(e.url),o={...x(n,{sort:!1}),...e.query},a=_(o,r);a&&(a=`?${a}`);let i=q(e.url);if(e.fragmentIdentifier){let l=new URL(t);l.hash=e.fragmentIdentifier,i=r[f]?l.hash:`#${e.fragmentIdentifier}`}return`${t}${a}${i}`}function O(e,r,t){t={parseFragmentIdentifier:!0,[f]:!1,...t};let{url:n,query:o,fragmentIdentifier:a}=R(e,t);return K({url:n,query:I(o,r),fragmentIdentifier:a},t)}function W(e,r,t){let n=Array.isArray(r)?o=>!r.includes(o):(o,a)=>!r(o,a);return O(e,n,t)}var g=b;var U={name:"@moneykit/connect",description:"MoneyKit Connect launcher for web.",version:"0.3.24",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 G(e,r){let t=document.createElement("iframe");t.id="moneykit-connect-frame",t.src=e,t.style.position=r?"absolute":"fixed",t.style.top="0",t.style.left="0",t.style.width=r?"100%":"100vw",t.style.height=r?"100%":"100svh",t.style.zIndex="999999",t.style.border="none";let n=r?document.getElementById(r):document.body;if(!n)throw new Error(`MoneyKit could not find container element with ID "${r}".`);return n.appendChild(t),t.addEventListener("load",function(){t.focus()}),t}function T(e){e.remove()}var C="moneykit.linkSessionToken",S=class{constructor(r={}){p=r.__connectSDKUIHost??p,this.options={...r}}link(r,t,n,o){this.startLink(r,t,n,o)}relink(r,t,n,o){this.startRelink(r,t,n,o)}continue(r,t,n,o){if(window.opener){window.opener.postMessage({moneykit:!0,type:"link.resume",eventData:{redirectURL:r}},p);return}this.continueLink(r,t,n,o)}__linkDirect(r,t,n,o){this.startLink(r,t,n,o,{viewMode:"direct"})}__relinkDirect(r,t,n,o){this.startRelink(r,t,n,o,{viewMode:"direct"})}__continueDirect(r,t,n,o){this.continueLink(r,t,n,o,{viewMode:"direct"})}startLink(r,t,n,o,a){let i={...this.linkParametersFromOptions(),linkSessionToken:r,origin:window.location.origin,...a},l=g.stringifyUrl({url:`${p}/start`,query:i});localStorage.setItem(C,r),this.launch(l,t,n,o)}startRelink(r,t,n,o,a){let i={...this.linkParametersFromOptions(),linkSessionToken:r,origin:window.location.origin,...a},l=g.stringifyUrl({url:`${p}/relink`,query:i});localStorage.setItem(C,r),this.launch(l,t,n,o)}continueLink(r,t,n,o,a){let i=localStorage.getItem(C);i||console.warn("Unable to get MoneyKit link session token from local storage.");let l={...this.linkParametersFromOptions(),linkSessionToken:i,redirectURL:r,origin:window.location.origin,...a},s=g.stringifyUrl({url:`${p}/continue`,query:l});this.launch(s,t,n,o)}linkParametersFromOptions(){let r=this.options.__applicationName??null,t=this.options.device??null,n=this.options.stepTimers??!1;return{applicationName:r,device:t,stepTimers:n,launcherVersion:U.version}}launch(r,t,n,o){let a=G(r,this.options.containerID),i=new AbortController,l=J(a,i,t,n,o,this.options.__onDemoEvent,this.options.theme,this.options.colorScheme);window.addEventListener("message",l,{signal:i.signal})}};function J(e,r,t,n,o,a,i,l){return s=>{if(s.origin!=p||!("moneykit"in s.data||"__moneykitDemo"in s.data)){console.warn("MoneyKit Connect received a message from an unexpected origin",s.origin);return}let d=s.data;switch(d.type){case"connect.started":l&&s.source?.postMessage({moneykit:!0,type:"connect.set_color_scheme",data:{colorScheme:l}},{targetOrigin:p}),i&&s.source?.postMessage({moneykit:!0,type:"connect.set_theme",data:{theme:i}},{targetOrigin:p});break;case"link.complete":t&&d.data.exchangeableToken&&t(d.data.exchangeableToken,d.data.institution),T(e),r.abort();break;case"relink.complete":t&&t(d.data.institution),T(e),r.abort();break;case"link.exit":localStorage.clear(),T(e),n&&n(d.data.error),r.abort();break;case"link.close_oauth":window.close();break;case"link.event":o&&o(d.data);break;case"demo.link.event":a&&a(d.data);break}}}var A=S;var X=(s=>(s[s.largeTitle=0]="largeTitle",s[s.title1=1]="title1",s[s.title2=2]="title2",s[s.title3=3]="title3",s[s.body=4]="body",s[s.smallBody=5]="smallBody",s[s.button=6]="button",s[s.input=7]="input",s))(X||{}),me=(e,r)=>{switch(r){case 0:return e.typography.largeTitle;case 1:return e.typography.title1;case 2:return e.typography.title2;case 3:return e.typography.title3;case 5:return e.typography.smallBody;case 6:return e.typography.button;case 7:return e.typography.input;default:return e.typography.body}};var de={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",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:"18px",lineHeight:"24px",letterSpacing:"0",weight:500}},images:{close:"/images/close.svg",search:"/images/search.svg",spinner:"/images/spinner.png"},spacing:{contentHorizontalInset:"28px",buttonHorizontalInset:"28px"},components:{navigationBar:{height:"64px"},contentView:{borderRadius:"12px",boxShadow:{light:"none",dark:"inset 0 0 0 1px rgba(228, 227, 243, 0.04)"},border:null,separatorStyle:"all_except_last"},button:{height:"44px",borderRadius:"12px",inheritInstitutionColor:!0,continueTitle:"Continue",doneTitle:"Done"},searchInput:{backgroundColor:{light:"rgba(118, 118, 128, 0.12)",dark:"rgba(118, 118, 128, 0.24)"},height:"48px",borderRadius:"12px",border:null,alignment:"center",focus:{glow:!0,backgroundColor:null,border:null,boxShadow:null}},textField:{backgroundColor:null,height:"52px",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:"12px",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 ue=A;export{X as ThemeTypographyTextStyle,ue as default,de as moneyui,me 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.3.22",
4
+ "version": "0.3.24",
5
5
  "author": "MoneyKit",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,9 +9,6 @@
9
9
  },
10
10
  "types": "./types/index.d.ts",
11
11
  "license": "MIT",
12
- "dependencies": {
13
- "query-string": "^8.1.0"
14
- },
15
12
  "module": "./index.js",
16
13
  "type": "module",
17
14
  "main": "./index.js"
@@ -11,6 +11,8 @@ export type Institution = {
11
11
  logo_dark: string | null;
12
12
  name: string;
13
13
  search_group: "primary" | "secondary" | "tertiary";
14
+ is_featured?: boolean | null;
15
+ providers?: string[] | null;
14
16
  };
15
17
  export type AccountType = "depository.cash" | "depository.checking" | "depository.savings" | "depository.prepaid" | "depository.other" | "credit_card" | "loan.general" | "loan.mortgage" | "loan.other" | "investment" | "other";
16
18
  export type LinkedInstitution = Institution & {
@@ -86,6 +86,7 @@ export type ThemeImages = {
86
86
  mfaSms?: ThemeImageUrl;
87
87
  mfaEmail?: ThemeImageUrl;
88
88
  mfaPhone?: ThemeImageUrl;
89
+ errorSmall?: ThemeImageUrl;
89
90
  };
90
91
  export declare enum ThemeTypographyTextStyle {
91
92
  largeTitle = 0,