Salt Edge Connect

You can easily test Connect from your Dashboard page by pressing Create Connection button.

After your application has received a token for connecting or reconnecting a login, you can redirect your user to the Salt Edge Connect URL. There, they will see a screen that lets them pick a country and a provider.

Your user will also be asked to input their credentials and, if needed, any of the interactive credentials.

For example, a user picked Italy as the country and the American Express as the provider. This is what they will see:

To start the fetching process, they will have to press “Connect”. Afterwards, they will be informed about their connection progress.

After the fetching is done, the user will be redirected back to your application.

Embedding Salt Edge Connect in your application

When you request for a connect token, you can pass an optional argument javascript_callback_type. This argument enables one of the following notification methods:

Salt Edge Connect will send any of these callbacks only in case when javascript_callback_type was specified in the token request.

Iframe injection

When not using the SDKs, your app is responsible for capturing the URLs, if you wish to be notified about the connect process.

The inserted URL has a custom scheme and host. The scheme of the URL is saltbridge and the host is connect. Here’s an example of such a URL: saltbridge://connect/{"data":{"login_id":997674448,"state":"fetching","secret":"Oqws977brjJUfXbEnGqHNsIRl8PytSL60T7JIsRBCZM","custom_fields":{"key":"value"}}}

The URL will be URLEncoded (percent-encoded), the URL above is not URLEncoded to preserve it’s readability.

Once your app has captured the inserted URL, it has to serialize the JSON-encoded URL path following the scheme and the host. Here’s another example, this time of a duplicated login callback:

saltbridge://connect/{"data":{"duplicated_login_id":994317674,"state":"error","custom_fields":{"key":"value"}}}

Once your app has decoded the URL path, it can start performing several actions like accounts listing or error handling.

External Object

If you access the connect page from a .Net host, and you use WebBrowser.ObjectForScripting, Salt Edge will try to call the window.external.SaltBridge function with the login attributes serialized as json:

public void SaltBridge(String serializedLogin) {
  // serializedLogin here looks like this:
  // '{"data":{
  //    "login_id":997674448,
  //    "state":"fetching",
  //    "secret":"Oqws977brjJUfXbEnGqHNsIRl8PytSL60T7JIsRBCZM",
  //    "custom_fields":{"key":"value"}
  //    }
  //  }'
}

Note that in the example above the SaltBridge function is a method defined on the object that was specified as a object for scripting:

webBrowser1.ObjectForScripting = this

which in this case is the object that initialized the web view.

Post message

If you access the connect page wrapped in an iframe, you can use Window.postMessage which performs cross-origin communication:

  window.addEventListener("message", function(event) {
      console.log(JSON.parse(event.data))
    }
  )

  // serializedLogin here looks like this:
  // {
  //   "data": {
  //     "login_id":997674448,
  //     "state":"fetching",
  //     "secret":"Oqws977brjJUfXbEnGqHNsIRl8PytSL60T7JIsRBCZM",
  //     "custom_fields":{"key":"value"}
  //   }
  // }

External Notify

On Windows Store app platform you can use event handler for ScriptNotify event of WebView. Your code should handle window.external.notify(args) call, ScriptNotify will fire and you’ll get the args in Value property of NotifyEventArgs parameter.

Remember to add https://saltedge.com and https://*.saltedge.com to Content URIs in Package.appxmanifest.

protected override void OnNavigatedTo(NavigationEventArgs e) {
  browser.ScriptNotify += browser_ScriptNotify;
}

private void browser_ScriptNotify(object sender, NotifyEventArgs e) {
  var serializedLogin = e.Value;
  // serializedLogin here looks like this:
  // '{"data":{
  //    "login_id":997674448,
  //    "state":"fetching",
  //    "secret":"Oqws977brjJUfXbEnGqHNsIRl8PytSL60T7JIsRBCZM",
  //    "custom_fields":{"key":"value"}
  //    }
  //  }'
}