๐ŸงชMulti-device (beta)

Using Multiple devices with one Keyless account

This process enables Keyless users to add and use multiple devices to their Keyless account, without the need to go through the enrollment process with each new device.

Definitions

A Keyless device is identified by an ID (a signing key) and it contains any additional info specified

  1. during the enrollment in the withDeviceInfo method;

  2. when adding a a new device in the setupNewDevice method;

Prerequisites

Let's call the device you want to add the "new device" and any device already enrolled in the Keyless network "old device".

  • The old device must be enrolled with Keyless.

  • The new device must not be enrolled with Keyless.

Retrieve the new device data

The first step starts with the new device; the Keyless SDK will generate and encrypt the required data to add the new device to the Keyless network. In this step it is also possible to pass any additional info you want to associate to the device (similar to the withDeviceInfo method in the enrollment).

Grab the KeylessNewDeviceData object containing the new device data.

val newDeviceData : KeylessNewDeviceData = Keyless.setupNewDevice(info = "device-info")

You should now share the newDeviceData with your "old device". In fact, it is your "old device" that will add the "new device" to the Keyless network.

Add the new device data from your old device

The second step needs to be performed on the "old device" and it will require an authentication passing the newDeviceData.

This informs your "old device" to add your "new device" to the KeylessNetwork.

Using .addingNewDevice in the AuthenticationConfiguration will output some encrypted data: oldDeviceData. The integretor is responsible to pass this oldDeviceData to your "new device". You can see this oldDeviceData as a confirmation blob necessary to complete the new device registration.

 val configuration = AuthenticationConfiguration.builder
   .addingNewDevice(newDeviceData = newDeviceData)
   .build()

Keyless.authenticate(
    authenticationConfiguration = configuration,
    onCompletion = { result ->
        when (result) {
            is Keyless.KeylessResult.Success -> {
                val oldDeviceData: KeylessOldDeviceData? = authResult.value.oldDeviceData
            }
            is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
        }
    }
)

Confirm new device

The third and last step is performed on the "new device". Authenticating providing the oldDeviceData from the previous step will finalize the "new device" registration with the Keyless network.

 val configuration = AuthenticationConfiguration.builder
   .confirmingNewDevice(oldDeviceData)
   .build()

Keyless.authenticate(
    authenticationConfiguration = configuration,
    onCompletion = { result ->
        when (result) {
            is Keyless.KeylessResult.Success -> {
                // new device added
            }
            is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
        }
    }
)

Revoking a device

It is possible to revoke any device for a given identifier. Revoking a device will make it impossible for the user to authenticate. Devices' identifiers are returned by the Keyless.getDevicesList method.

val configuration = AuthenticationConfiguration.builder
    .revokingDevice(id = "device_identifier")
    .build()
    
Keyless.authenticate(
    authenticationConfiguration = configuration,
    onCompletion = { result ->
        when (result) {
            is Keyless.KeylessResult.Success -> Log.d("KeylessSDK ", "Revoke device success")
            is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Revoke device - error code ${result.error.code}")
        }
    }
)

Last updated