@@ -3,7 +3,11 @@ import mtLinkSdk, {
33 AuthAction ,
44 AuthorizeOptions ,
55 OnboardOptions ,
6- OpenServicesConfigsOptions ,
6+ VaultOpenServiceViewServiceList ,
7+ VaultOpenServiceViewServiceConnection ,
8+ VaultOpenServiceViewConnectionSetting ,
9+ MyAccountOpenServiceOptions ,
10+ VaultOpenServiceViewCustomerSupport ,
711 ServiceId ,
812 LoginLinkTo ,
913 VaultViewServiceList
@@ -19,8 +23,6 @@ interface ITokenInfo {
1923 scopes : string [ ] ;
2024}
2125
22- const AWESOME_APP_ID = 'af84f08f40970caf17f2e53b31771ceb50d0f32f7d44b826753982e809395290' ;
23-
2426// Re-initialize when clicked
2527elements . initializeBtn . onclick = ( ) => {
2628 const commonOptions : InitOptions = { } ;
@@ -75,7 +77,7 @@ elements.doOnboardBtn.onclick = async () => {
7577 onBoardOptions . email = onboardOptionsElms . email . value ;
7678 onBoardOptions . pkce = true ;
7779
78- await mtLinkSdk . onboard ( onBoardOptions ) ;
80+ mtLinkSdk . onboard ( onBoardOptions ) ;
7981 } catch ( error ) {
8082 console . log ( error ) ;
8183 }
@@ -117,11 +119,16 @@ elements.logoutBtn.onclick = () => {
117119// Launch open service
118120elements . openServiceBtn . onclick = ( ) => {
119121 const { openServiceOptionsElms } = elements ;
120- let OpenServicesConfigsOptions : OpenServicesConfigsOptions = { } ;
121- const serviceId = openServiceOptionsElms . serviceId . options [ openServiceOptionsElms . serviceId . selectedIndex ]
122+ const serviceId : ServiceId = openServiceOptionsElms . serviceId . options [ openServiceOptionsElms . serviceId . selectedIndex ]
122123 . value as ServiceId ;
123124
124125 if ( serviceId === 'vault' ) {
126+ type VaultOptions =
127+ | VaultOpenServiceViewServiceConnection
128+ | VaultOpenServiceViewConnectionSetting
129+ | VaultOpenServiceViewServiceList
130+ | VaultOpenServiceViewCustomerSupport ;
131+ let openServicesOptions : VaultOptions = { } as VaultOptions ;
125132 const view = openServiceOptionsElms . vaultView . options [ openServiceOptionsElms . vaultView . selectedIndex ] . value as
126133 | 'services-list'
127134 | 'service-connection'
@@ -130,7 +137,7 @@ elements.openServiceBtn.onclick = () => {
130137
131138 switch ( view ) {
132139 case 'services-list' :
133- OpenServicesConfigsOptions = {
140+ openServicesOptions = {
134141 view : 'services-list' ,
135142 type :
136143 ( openServiceOptionsElms . type . options [ openServiceOptionsElms . type . selectedIndex ] . value as Pick <
@@ -146,21 +153,22 @@ elements.openServiceBtn.onclick = () => {
146153 } ;
147154 break ;
148155 case 'service-connection' :
149- OpenServicesConfigsOptions = {
156+ openServicesOptions = {
150157 view : 'service-connection' ,
151158 entityKey : openServiceOptionsElms . entityKey . value
152159 } ;
153160 break ;
154161 case 'connection-setting' :
155- OpenServicesConfigsOptions = {
162+ openServicesOptions = {
156163 view : 'connection-setting' ,
157164 credentialId : openServiceOptionsElms . credentialId . value
158165 } ;
159166 break ;
160167 case 'customer-support' :
161168 default :
162- OpenServicesConfigsOptions = { view } ;
169+ openServicesOptions = { view } ;
163170 }
171+ mtLinkSdk . openService ( serviceId , openServicesOptions ) ;
164172 }
165173
166174 if ( serviceId === 'myaccount' ) {
@@ -174,10 +182,8 @@ elements.openServiceBtn.onclick = () => {
174182 | 'settings/update-email'
175183 | 'settings/update-password' ;
176184
177- OpenServicesConfigsOptions = { view } ;
185+ mtLinkSdk . openService ( serviceId , { view } ) ;
178186 }
179-
180- mtLinkSdk . openService ( serviceId , OpenServicesConfigsOptions ) ;
181187} ;
182188
183189// Launch open login link
@@ -234,11 +240,11 @@ elements.openServiceOptionsElms.vaultView.onchange = () => {
234240} ;
235241
236242const initializeLinkSDK = ( options : InitOptions = { } ) => {
237- mtLinkSdk . init ( AWESOME_APP_ID , {
243+ mtLinkSdk . init ( 'af84f08f40970caf17f2e53b31771ceb50d0f32f7d44b826753982e809395290' , {
238244 sdkPlatform : 'js' ,
239245 redirectUri : 'https://localhost:9000' ,
240246 locale : 'en' ,
241- mode : 'develop ' ,
247+ mode : 'staging ' ,
242248 ...options
243249 } ) ;
244250} ;
0 commit comments