It has to do with the new authentication model, as you know there are two separate steps that an app has to perform:
1- get authorised by the user thru the authenticator
2- use the authorisation URI that was provided to actually connect to the network.
If the app is designed to store the auth URI locally (securely cached), it could use it to connect without needing the authenticator, this is the main reason you have at least to separate steps when invoking the API functions. I think the main purpose was to be able to have this decoupled to support mobiles so you don’t need to authenticator to be running in your phone every time you run your app, but you can also think of the IoT devices that need to be pre-provisioned with an auth URI so they can connect without the authenticator.
I guess you are imagining of having a function which does step 1 and 2 altogether, i.e. authoriseAndConnect
, and maybe also which includes the step of initialising the library (initialise
) too, all these options can be considered I guess, I think in such a case they shouldn’t be a replacement but just additional helper functions.
Unless I’m misunderstanding, there are no sessions as you are describing it, the initialise
function basically just creates a safeApp
instance which dynamically loads the safe_app library and it makes some initial setup like activating the logging.
When you call authorise
you are not really creating a session but just getting an authorisation URI (or an auth token) that you can then use to connect. After you received the auth URI, there is no sessions neither with the network nor with the authenticator.
At this point, you can connect to the network using the auth URI and start interacting with it until the safeApp
instance is deleted. After you are connected, you could re-connect using the same safeApp
instance with the same auth URI, or a different auth URI, but you cannot have several connections/sessions with the same safeApp
instance, so if an app needs multiple sessions it needs to create multiple safeApp
instances (note the same auth URI can be used to connect with all of them, as log as the AppInfo is the same).