@@ -6,7 +6,7 @@ import mtLinkSdk, {
6
6
OpenServicesConfigsOptions ,
7
7
ServiceId ,
8
8
LoginLinkTo ,
9
- ServicesListType ,
9
+ ServicesListType
10
10
} from '@moneytree/mt-link-javascript-sdk' ;
11
11
12
12
import elements from './elements' ;
@@ -35,8 +35,7 @@ elements.initializeBtn.onclick = () => {
35
35
}
36
36
37
37
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' ;
40
39
commonOptions . showAuthToggle = commonOptionsElms . showAuthToggle . checked ;
41
40
commonOptions . showRememberMe = commonOptionsElms . showRememberMe . checked ;
42
41
commonOptions . isNewTab = commonOptionsElms . isNewTab . checked ;
@@ -49,9 +48,7 @@ elements.authorizeBtn.onclick = () => {
49
48
const authorizeOptions : AuthorizeOptions = { } ;
50
49
const { authorizeOptionsElms } = elements ;
51
50
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 ) ;
55
52
if ( scopesSelectedOptions . length ) {
56
53
authorizeOptions . scopes = scopesSelectedOptions . map ( ( x ) => x . value ) ;
57
54
}
@@ -70,9 +67,7 @@ elements.doOnboardBtn.onclick = async () => {
70
67
71
68
const onBoardOptions : OnboardOptions = { } ;
72
69
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 ) ;
76
71
if ( scopesSelectedOptions . length ) {
77
72
onBoardOptions . scopes = scopesSelectedOptions . map ( ( x ) => x . value ) ;
78
73
}
@@ -123,37 +118,43 @@ elements.logoutBtn.onclick = () => {
123
118
elements . openServiceBtn . onclick = ( ) => {
124
119
const { openServiceOptionsElms } = elements ;
125
120
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 ;
129
123
130
124
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' ;
133
130
134
131
switch ( view ) {
135
132
case 'services-list' :
136
133
OpenServicesConfigsOptions = {
137
134
view : 'services-list' ,
138
135
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 ,
141
140
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
145
146
} ;
146
147
break ;
147
148
case 'service-connection' :
148
149
OpenServicesConfigsOptions = {
149
150
view : 'service-connection' ,
150
- entityKey : openServiceOptionsElms . entityKey . value ,
151
+ entityKey : openServiceOptionsElms . entityKey . value
151
152
} ;
152
153
break ;
153
154
case 'connection-setting' :
154
155
OpenServicesConfigsOptions = {
155
156
view : 'connection-setting' ,
156
- credentialId : openServiceOptionsElms . credentialId . value ,
157
+ credentialId : openServiceOptionsElms . credentialId . value
157
158
} ;
158
159
break ;
159
160
case 'customer-support' :
@@ -163,8 +164,7 @@ elements.openServiceBtn.onclick = () => {
163
164
}
164
165
165
166
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
168
168
| 'authorized-applications'
169
169
| 'change-language'
170
170
| 'email-preferences'
@@ -187,7 +187,7 @@ elements.sendLoginLinkBtn.onclick = async () => {
187
187
188
188
await mtLinkSdk . requestLoginLink ( {
189
189
loginLinkTo : loginLinkToElm . options [ loginLinkToElm . selectedIndex ] . value as LoginLinkTo ,
190
- email : loginLinkEmailElm . value ,
190
+ email : loginLinkEmailElm . value
191
191
} ) ;
192
192
window . alert ( 'Success, loginLink sent out.' ) ;
193
193
} catch ( error ) {
@@ -200,8 +200,7 @@ elements.sendLoginLinkBtn.onclick = async () => {
200
200
// Helper, to switch the vault options, depends on openService's serviceId value
201
201
elements . openServiceOptionsElms . serviceId . onchange = ( ) => {
202
202
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 ;
205
204
206
205
if ( selectedValue === 'vault' || selectedValue === 'myaccount-settings' ) {
207
206
vaultOptions . style . display = 'block' ;
@@ -214,8 +213,7 @@ elements.openServiceOptionsElms.serviceId.onchange = () => {
214
213
// Helper, To switch the options, depends on openService's view value for vault
215
214
elements . openServiceOptionsElms . view . onchange = ( ) => {
216
215
const { openServiceOptionsElms } = elements ;
217
- const selectedValue =
218
- openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ] . value ;
216
+ const selectedValue = openServiceOptionsElms . view . options [ openServiceOptionsElms . view . selectedIndex ] . value ;
219
217
220
218
const vaultServicesElms = document . getElementsByClassName ( 'vault-services' ) ;
221
219
for ( let indx = 0 ; indx < vaultServicesElms . length ; indx ++ ) {
@@ -234,7 +232,7 @@ const initializeLinkSDK = (options: InitOptions = {}) => {
234
232
redirectUri : 'https://localhost:9000' ,
235
233
locale : 'en' ,
236
234
mode : 'develop' ,
237
- ...options ,
235
+ ...options
238
236
} ) ;
239
237
} ;
240
238
@@ -256,14 +254,11 @@ const validateToken = async () => {
256
254
elements . accessTokenLabel . innerText = `Your access token is ${ accessToken } .` ;
257
255
const authHeaders = new Headers ( {
258
256
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
260
261
} ) ;
261
- const response = await fetch (
262
- 'https://myaccount-staging.getmoneytree.com/oauth/token/info.json' ,
263
- {
264
- headers : authHeaders ,
265
- }
266
- ) ;
267
262
const data : ITokenInfo = await response . json ( ) ;
268
263
elements . accessTokenLabel . innerText = `Your access token is ${ accessToken }
269
264
It was generated for the app: ${ data . aud . name } .
0 commit comments