Skip to content

Commit

Permalink
fix(PSG-4799): return passkey on currentUser.addPasskey (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickycpadilla authored Sep 24, 2024
1 parent 49fdbc7 commit 2d61b9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
11 changes: 1 addition & 10 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "fd6f2919a6beae8573b7edd484b251a4d01d37ca02c6a7f36527f0f3c797a195",
"originHash" : "7e98e0c0713867f950e25ec1449eb07b639fe756ca08d6d5f949fda33c8fa967",
"pins" : [
{
"identity" : "anycodable",
Expand All @@ -9,15 +9,6 @@
"revision" : "69261f239f0fffaf51495dadc4f8483fbfe97025",
"version" : "0.6.1"
}
},
{
"identity" : "passage-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/passageidentity/passage-swift",
"state" : {
"revision" : "4b9b700f731a6cabb91524da91fa775636adf491",
"version" : "1.0.0"
}
}
],
"version" : 3
Expand Down
11 changes: 5 additions & 6 deletions Sources/Passage/interfaces/PassageCurrentUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ final public class PassageCurrentUser {
@available(iOS 16.0, macOS 12.0, tvOS 16.0, visionOS 1.0, *)
@available(watchOS, unavailable)
@discardableResult
public func addPasskey(options: PasskeyCreationOptions? = nil) async throws -> AuthResult {
public func addPasskey(options: PasskeyCreationOptions? = nil) async throws -> Passkey {
setAuthTokenHeader()
do {
// Request a Registration Start Handshake from Passage server
Expand All @@ -172,17 +172,16 @@ final public class PassageCurrentUser {
registrationRequest: registrationRequest,
includeSecurityKeyOption: includeSecurityKeyOption
)
// Send the new Credential Handshake Response to Passage server
let finishRequest = RegisterWebAuthnFinishRequest(
let finishRequest = AddDeviceFinishRequest(
handshakeId: startResponse.handshake.id,
handshakeResponse: credential.response(),
userId: startResponse.user?.id ?? ""
)
let finishResponse = try await RegisterAPI.registerWebauthnFinish(
let finishResponse = try await CurrentuserAPI.postCurrentuserAddDeviceFinish(
appId: appId,
registerWebAuthnFinishRequest: finishRequest
addDeviceFinishRequest: finishRequest
)
return finishResponse.authResult
return finishResponse.device
} catch {
throw CurrentUserError.convert(error: error)
}
Expand Down

0 comments on commit 2d61b9f

Please sign in to comment.