PushUriParser
public enum PushUriParser
Utility class for parsing and formatting Push URIs. Supports both pushauth:// and mfauth:// schemes.
This parser handles the standard Push URI format used for credential registration via QR codes and supports additional parameters for enhanced functionality.
URI Format
pushauth://push/issuer:accountName?r=regEndpoint&a=authEndpoint&s=sharedSecret&d=userId
mfauth://push/issuer:accountName?r=regEndpoint&a=authEndpoint&s=sharedSecret&d=userId
Required Parameters
r: Registration endpoint (base64-encoded)a: Authentication endpoint (base64-encoded)s: Shared secret for signing (base64url-encoded)
Optional Parameters
d: User ID (base64-encoded)pid: Push resource ID (base64-encoded)issuer: Issuer name (base64-encoded if from pushauth, plain if from mfauth)image: Image URL (base64-encoded)b: Background color (hex without #)policies: Authenticator policies (base64-encoded JSON)c: Challenge parameter for registrationl: Load balancer cookie for registrationm: Message ID for registration
-
parse(_:Asynchronous) Parse a Push URI string into a PushCredential.
Throws
PushError.invalidUriif the URI is malformed.Declaration
Swift
public static func parse(_ uri: String) async throws -> PushCredentialParameters
uriThe URI string (pushauth:// or mfauth://).
Return Value
A PushCredential instance.
-
registrationParameters(_:Asynchronous) Extract registration parameters from a Push URI. These parameters are used during the credential registration flow.
Throws
PushError.invalidUriif the URI cannot be parsed or required parameters are missing.Notes
- All three parameters (challenge, loadBalancer, messageId) are required
- Will throw if any parameter is missing (matches Android behavior)
- The loadBalancer parameter is returned with key “amlbCookie” for consistency with the handler
- Base64-encoded values are decoded automatically
Declaration
Swift
public static func registrationParameters(_ uri: String) async throws -> [String : String]Parameters
uriThe URI string (pushauth:// or mfauth://).
Return Value
A dictionary containing registration parameters:
- “challenge”: Challenge value for registration response (key: “c”)
- “amlbCookie”: Load balancer cookie for proper routing (key: “l”)
- “messageId”: Message ID for registration response (key: “m”)
-
format(_:Asynchronous) Format a PushCredential into a URI string.
Throws
PushError.uriFormattingif formatting fails.Example Output
pushauth://push/ForgeRock:user@example.com?r=...&a=...&s=...&issuer=ForgeRockDeclaration
Swift
public static func format(_ credential: PushCredential) async throws -> StringParameters
credentialThe PushCredential to format.
Return Value
A pushauth:// URI string.
View on GitHub