Skip to content

About

Identisure API client for Swift

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Identisure Swift Client

Swift Package Manager Documentation MIT license

API client for the Identisure REST API.

Documentation: identisure.github.io/api-client-swift

Supports iOS 15+, macOS 12+, tvOS 15+, watchOS 8+.

Requirements

Swift 5.9 or later. iOS 15, macOS 12, tvOS 15 or watchOS 8 and later.

Supported providers

  • BankID SE: auth, sign, phone auth and sign, QR verify, age verification
  • BankID NO: auth, backchannel auth, sign, age verification
  • Freja eID: auth, backchannel auth, sign, backchannel sign, age verification
  • MitID: auth, backchannel auth, sign, age verification
  • FTN (Finnish Trust Network): auth, age verification
  • Vipps MobilePay: auth, backchannel auth
  • Documents: upload and download documents for signing

Installation

Add to Package.swift:

dependencies: [
    .package(url: "https://github.com/identisure/api-client-swift.git", from: "0.1.0")
],
targets: [
    .target(name: "MyApp", dependencies: [
        .product(name: "IdentisureClient", package: "api-client-swift")
    ])
]

Usage

import IdentisureClient

let client = IdentisureClientBuilder(clientId: "client_id", clientSecret: "client_secret")
    .environment(.staging)
    .build()

let session = try await client.bankIdSe.auth(BankIdSeAuthRequest())
if case .pending(let pending) = session {
    print("Session ID: \(pending.id)")

    let result = try await client.bankIdSe.waitForAuth(id: pending.id)
    switch result {
    case .completed(let done):
        print("Authenticated: \(done.name) (\(done.ssn))")
    case .failed(let failed):
        print("Failed: \(failed.error)")
    case .pending, .unknown:
        break
    }
}

Verifying callbacks

Verify the X-Signature-SHA256 header against the raw request body before parsing it:

let valid = CallbackSignature.verify(body: rawBody, signature: signatureHeader, secret: "hmac_secret")

Development

Prerequisites

  • Swift 5.9+ (swift --version)

Setup

Test fixtures live in a git submodule. Clone with --recurse-submodules, or run git submodule update --init in an existing clone.

Build / Test

swift build
swift test

Release

Set the version in Sources/IdentisureClient/Transport.swift and commit. Then push a tag:

git tag v0.1.0
git push origin v0.1.0

The release workflow checks that the tag matches the version, runs CI and creates a GitHub release. SwiftPM resolves versions from the tags.

Other languages

C#, Dart, Go, TypeScript/JavaScript, Java/Kotlin, PHP, Python, Ruby, Rust

About

Identisure API client for Swift

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages