Skip to content

Commit 0419303

Browse files
Renamed PublicKeyCredentialRequestOptions.rpId to relyingPartyID
1 parent 681eb6f commit 0419303

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

Sources/WebAuthn/Ceremonies/Authentication/PublicKeyCredentialRequestOptions.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ public struct PublicKeyCredentialRequestOptions: Encodable {
3232
/// See https://www.w3.org/TR/webauthn-2/#dictionary-assertion-options
3333
public let timeout: Duration?
3434

35-
/// The Relying Party ID.
36-
public let rpId: String?
35+
/// The ID of the Relying Party making the request.
36+
///
37+
/// This is configured on ``WebAuthnManager`` before its ``WebAuthnManager/beginAuthentication(timeout:allowCredentials:userVerification:)`` method is called.
38+
/// - Note: When encoded, this field appears as `rpId` to match the expectations of `navigator.credentials.get()`.
39+
public let relyingPartyID: String?
3740

3841
/// Optionally used by the client to find authenticators eligible for this authentication ceremony.
3942
public let allowCredentials: [PublicKeyCredentialDescriptor]?
@@ -48,15 +51,15 @@ public struct PublicKeyCredentialRequestOptions: Encodable {
4851

4952
try container.encode(challenge.base64URLEncodedString(), forKey: .challenge)
5053
try container.encodeIfPresent(timeout?.milliseconds, forKey: .timeout)
51-
try container.encodeIfPresent(rpId, forKey: .rpId)
54+
try container.encodeIfPresent(relyingPartyID, forKey: .rpID)
5255
try container.encodeIfPresent(allowCredentials, forKey: .allowCredentials)
5356
try container.encodeIfPresent(userVerification, forKey: .userVerification)
5457
}
5558

5659
private enum CodingKeys: String, CodingKey {
5760
case challenge
5861
case timeout
59-
case rpId
62+
case rpID = "rpId"
6063
case allowCredentials
6164
case userVerification
6265
}

Sources/WebAuthn/WebAuthnManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public struct WebAuthnManager {
143143
return PublicKeyCredentialRequestOptions(
144144
challenge: challenge,
145145
timeout: timeout,
146-
rpId: configuration.relyingPartyID,
146+
relyingPartyID: configuration.relyingPartyID,
147147
allowCredentials: allowCredentials,
148148
userVerification: userVerification
149149
)

Tests/WebAuthnTests/WebAuthnManagerAuthenticationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class WebAuthnManagerAuthenticationTests: XCTestCase {
4444

4545
XCTAssertEqual(options.challenge, challenge)
4646
XCTAssertEqual(options.timeout, .seconds(1234))
47-
XCTAssertEqual(options.rpId, relyingPartyID)
47+
XCTAssertEqual(options.relyingPartyID, relyingPartyID)
4848
XCTAssertEqual(options.allowCredentials, allowCredentials)
4949
XCTAssertEqual(options.userVerification, .preferred)
5050
}

Tests/WebAuthnTests/WebAuthnManagerIntegrationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ final class WebAuthnManagerIntegrationTests: XCTestCase {
106106
userVerification: userVerification
107107
)
108108

109-
XCTAssertEqual(authenticationOptions.rpId, configuration.relyingPartyID)
109+
XCTAssertEqual(authenticationOptions.relyingPartyID, configuration.relyingPartyID)
110110
XCTAssertEqual(authenticationOptions.timeout, authenticationTimeout)
111111
XCTAssertEqual(authenticationOptions.challenge, mockChallenge)
112112
XCTAssertEqual(authenticationOptions.userVerification, userVerification)

0 commit comments

Comments
 (0)