Skip to content

Commit 227b6bb

Browse files
authored
Allow passing your own device ID to client (#56)
1 parent 9c16787 commit 227b6bb

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

module/gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ pomGroup=com.authsignal
22
pomPackaging=aar
33
pomName=Authsignal SDK for Android
44
pomArtifactId=authsignal-android
5-
versionName=2.2.12
6-
5+
versionName=2.3.0

module/src/main/java/com/authsignal/Authsignal.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import com.authsignal.device.AuthsignalDevice
1111
class Authsignal(
1212
tenantID: String,
1313
baseURL: String,
14-
activity: Activity? = null
14+
activity: Activity? = null,
15+
deviceId: String? = null,
1516
) {
16-
val passkey = AuthsignalPasskey(tenantID = tenantID, baseURL = baseURL, activity = activity)
17+
val passkey = AuthsignalPasskey(tenantID = tenantID, baseURL = baseURL, activity = activity, deviceId = deviceId)
1718
val push = AuthsignalPush(tenantID = tenantID, baseURL = baseURL)
1819
val device = AuthsignalDevice(tenantID = tenantID, baseURL = baseURL)
1920
val email = AuthsignalEmail(tenantID = tenantID, baseURL = baseURL)

module/src/main/java/com/authsignal/passkey/AuthsignalPasskey.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import java.util.UUID
1313
class AuthsignalPasskey(
1414
tenantID: String,
1515
baseURL: String,
16-
private val activity: Activity?) {
16+
private val activity: Activity?,
17+
private val deviceId: String?) {
1718
private val api = PasskeyAPI(tenantID, baseURL)
1819
private val manager = PasskeyManager(activity)
1920
private val passkeyLocalKey = "@as_passkey_credential_id"
@@ -55,7 +56,7 @@ class AuthsignalPasskey(
5556
errorCode = registerResponse.errorCode
5657
)
5758

58-
val deviceId = getDefaultDeviceId()
59+
val deviceId = deviceId ?: getDefaultDeviceId()
5960

6061
val addAuthenticatorResponse = api.addAuthenticator(
6162
userToken,
@@ -121,7 +122,7 @@ class AuthsignalPasskey(
121122
errorCode = authResponse.errorCode,
122123
)
123124

124-
val deviceId = getDefaultDeviceId()
125+
val deviceId = deviceId ?: getDefaultDeviceId()
125126

126127
val verifyResponse = api.verify(
127128
optsData.challengeId,

0 commit comments

Comments
 (0)