@@ -6,7 +6,7 @@ import mtLinkSdk, {
66 OpenServicesConfigsOptions ,
77 ServiceId ,
88 LoginLinkTo ,
9- ServicesListType ,
9+ ServicesListType
1010} from '@moneytree/mt-link-javascript-sdk' ;
1111
1212import elements from './elements' ;
@@ -35,8 +35,7 @@ elements.initializeBtn.onclick = () => {
3535 }
3636
3737 commonOptions . authAction =
38- ( commonOptionsElms . authAction . options [ commonOptionsElms . authAction . selectedIndex ]
39- . value as AuthAction ) || 'login' ;
38+ ( commonOptionsElms . authAction . options [ commonOptionsElms . authAction . selectedIndex ] . value as AuthAction ) || 'login' ;
4039 commonOptions . showAuthToggle = commonOptionsElms . showAuthToggle . checked ;
4140 commonOptions . showRememberMe = commonOptionsElms . showRememberMe . checked ;
4241 commonOptions . isNewTab = commonOptionsElms . isNewTab . checked ;
@@ -49,9 +48,7 @@ elements.authorizeBtn.onclick = () => {
4948 const authorizeOptions : AuthorizeOptions = { } ;
5049 const { authorizeOptionsElms } = elements ;
5150
52- const scopesSelectedOptions = Array . from ( authorizeOptionsElms . scopes . options ) . filter (
53- ( x ) => x . selected
54- ) ;
51+ const scopesSelectedOptions = Array . from ( authorizeOptionsElms . scopes . options ) . filter ( ( x ) => x . selected ) ;
5552 if ( scopesSelectedOptions . length ) {
5653 authorizeOptions . scopes = scopesSelectedOptions . map ( ( x ) => x . value ) ;
5754 }
@@ -70,9 +67,7 @@ elements.doOnboardBtn.onclick = async () => {
7067
7168 const onBoardOptions : OnboardOptions = { } ;
7269
73- const scopesSelectedOptions = Array . from ( onboardOptionsElms . scopes . options ) . filter (
74- ( x ) => x . selected
75- ) ;
70+ const scopesSelectedOptions = Array . from ( onboardOptionsElms . scopes . options ) . filter ( ( x ) => x . selected ) ;
7671 if ( scopesSelectedOptions . length ) {
7772 onBoardOptions . scopes = scopesSelectedOptions . map ( ( x ) => x . value ) ;
7873 }
@@ -123,37 +118,43 @@ elements.logoutBtn.onclick = () => {
123118elements . openServiceBtn . onclick = ( ) => {
124119 const { openServiceOptionsElms } = elements ;
125120 let OpenServicesConfigsOptions : OpenServicesConfigsOptions = { } ;
126- const serviceId = openServiceOptionsElms . serviceId . options [
127- openServiceOptionsElms . serviceId . selectedIndex
128- ] . value as ServiceId ;
121+ const serviceId = openServiceOptionsElms . serviceId . options [ openServiceOptionsElms . serviceId . selectedIndex ]
122+ . value as ServiceId ;
129123
130124 if ( serviceId === 'vault' ) {
131- const view = openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ]
132- . value as 'services-list' | 'service-connection' | 'connection-setting' | 'customer-support' ;
125+ const view = openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ] . value as
126+ | 'services-list'
127+ | 'service-connection'
128+ | 'connection-setting'
129+ | 'customer-support' ;
133130
134131 switch ( view ) {
135132 case 'services-list' :
136133 OpenServicesConfigsOptions = {
137134 view : 'services-list' ,
138135 type :
139- ( openServiceOptionsElms . type . options [ openServiceOptionsElms . type . selectedIndex ]
140- . value as Pick < ServicesListType , 'type' > [ 'type' ] ) || undefined ,
136+ ( openServiceOptionsElms . type . options [ openServiceOptionsElms . type . selectedIndex ] . value as Pick <
137+ ServicesListType ,
138+ 'type'
139+ > [ 'type' ] ) || undefined ,
141140 group :
142- ( openServiceOptionsElms . group . options [ openServiceOptionsElms . group . selectedIndex ]
143- . value as Pick < ServicesListType , 'group' > [ 'group' ] ) || undefined ,
144- search : openServiceOptionsElms . search . value || undefined ,
141+ ( openServiceOptionsElms . group . options [ openServiceOptionsElms . group . selectedIndex ] . value as Pick <
142+ ServicesListType ,
143+ 'group'
144+ > [ 'group' ] ) || undefined ,
145+ search : openServiceOptionsElms . search . value || undefined
145146 } ;
146147 break ;
147148 case 'service-connection' :
148149 OpenServicesConfigsOptions = {
149150 view : 'service-connection' ,
150- entityKey : openServiceOptionsElms . entityKey . value ,
151+ entityKey : openServiceOptionsElms . entityKey . value
151152 } ;
152153 break ;
153154 case 'connection-setting' :
154155 OpenServicesConfigsOptions = {
155156 view : 'connection-setting' ,
156- credentialId : openServiceOptionsElms . credentialId . value ,
157+ credentialId : openServiceOptionsElms . credentialId . value
157158 } ;
158159 break ;
159160 case 'customer-support' :
@@ -163,8 +164,7 @@ elements.openServiceBtn.onclick = () => {
163164 }
164165
165166 if ( serviceId === 'myaccount-settings' ) {
166- const view = openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ]
167- . value as
167+ const view = openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ] . value as
168168 | 'authorized-applications'
169169 | 'change-language'
170170 | 'email-preferences'
@@ -187,7 +187,7 @@ elements.sendLoginLinkBtn.onclick = async () => {
187187
188188 await mtLinkSdk . requestLoginLink ( {
189189 loginLinkTo : loginLinkToElm . options [ loginLinkToElm . selectedIndex ] . value as LoginLinkTo ,
190- email : loginLinkEmailElm . value ,
190+ email : loginLinkEmailElm . value
191191 } ) ;
192192 window . alert ( 'Success, loginLink sent out.' ) ;
193193 } catch ( error ) {
@@ -200,8 +200,7 @@ elements.sendLoginLinkBtn.onclick = async () => {
200200// Helper, to switch the vault options, depends on openService's serviceId value
201201elements . openServiceOptionsElms . serviceId . onchange = ( ) => {
202202 const { openServiceOptionsElms, vaultOptions } = elements ;
203- const selectedValue =
204- openServiceOptionsElms . serviceId . options [ openServiceOptionsElms . serviceId . selectedIndex ] . value ;
203+ const selectedValue = openServiceOptionsElms . serviceId . options [ openServiceOptionsElms . serviceId . selectedIndex ] . value ;
205204
206205 if ( selectedValue === 'vault' || selectedValue === 'myaccount-settings' ) {
207206 vaultOptions . style . display = 'block' ;
@@ -214,8 +213,7 @@ elements.openServiceOptionsElms.serviceId.onchange = () => {
214213// Helper, To switch the options, depends on openService's view value for vault
215214elements . openServiceOptionsElms . view . onchange = ( ) => {
216215 const { openServiceOptionsElms } = elements ;
217- const selectedValue =
218- openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ] . value ;
216+ const selectedValue = openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ] . value ;
219217
220218 const vaultServicesElms = document . getElementsByClassName ( 'vault-services' ) ;
221219 for ( let indx = 0 ; indx < vaultServicesElms . length ; indx ++ ) {
@@ -234,7 +232,7 @@ const initializeLinkSDK = (options: InitOptions = {}) => {
234232 redirectUri : 'https://localhost:9000' ,
235233 locale : 'en' ,
236234 mode : 'develop' ,
237- ...options ,
235+ ...options
238236 } ) ;
239237} ;
240238
@@ -256,14 +254,11 @@ const validateToken = async () => {
256254 elements . accessTokenLabel . innerText = `Your access token is ${ accessToken } .` ;
257255 const authHeaders = new Headers ( {
258256 method : 'GET' ,
259- Authorization : `Bearer ${ accessToken } ` ,
257+ Authorization : `Bearer ${ accessToken } `
258+ } ) ;
259+ const response = await fetch ( 'https://myaccount-staging.getmoneytree.com/oauth/token/info.json' , {
260+ headers : authHeaders
260261 } ) ;
261- const response = await fetch (
262- 'https://myaccount-staging.getmoneytree.com/oauth/token/info.json' ,
263- {
264- headers : authHeaders ,
265- }
266- ) ;
267262 const data : ITokenInfo = await response . json ( ) ;
268263 elements . accessTokenLabel . innerText = `Your access token is ${ accessToken }
269264 It was generated for the app: ${ data . aud . name } .
0 commit comments