TrustPinConfiguration

public struct TrustPinConfiguration : Sendable

Encapsulates all configuration options for a TrustPin instance.

Pass a TrustPinConfiguration to setup(_:) (or the static setup(_:autoRegisterURLProtocol:) for the default instance). All properties are immutable — construct the value once and pass it directly to setup.

Basic usage

try await TrustPin.setup(TrustPinConfiguration(
    organizationId: "your-org-id",
    projectId: "your-project-id",
    publicKey: "your-base64-public-key"
))

Custom mode

try await TrustPin.setup(TrustPinConfiguration(
    organizationId: "your-org-id",
    projectId: "your-project-id",
    publicKey: "your-base64-public-key",
    mode: .permissive
))

Custom configuration URL

For self-hosted or BYOK deployments, supply a configurationURL pointing to a signed JWS payload. CDN-managed projects should leave this nil.

try await TrustPin.setup(TrustPinConfiguration(
    organizationId: "org",
    projectId: "proj",
    publicKey: key,
    configurationURL: URL(string: "https://your-server.com/pins.jws")
))

Required

  • Your organization identifier from the TrustPin dashboard.

    Declaration

    Swift

    public let organizationId: String
  • Your project identifier from the TrustPin dashboard.

    Declaration

    Swift

    public let projectId: String
  • Base64-encoded public key used to verify the signature of the pinning payload.

    Declaration

    Swift

    public let publicKey: String

Optional

  • Controls how TrustPin behaves for domains not present in the pinning payload.

    Declaration

    Swift

    public let mode: TrustPinMode
  • Custom URL for the signed pinning payload.

    When nil, TrustPin fetches from the CDN chain in order: primary → mobile → backup. When set, this URL is tried first; if it fails, the SDK falls through to the CDN chain automatically. Only set this for self-hosted or BYOK deployments.

    Declaration

    Swift

    public let configurationURL: URL?
  • Creates a new TrustPinConfiguration with the required credentials and optional overrides.

    Declaration

    Swift

    public init(organizationId: String,
                projectId: String,
                publicKey: String,
                mode: TrustPinMode = .strict,
                configurationURL: URL? = nil)

    Parameters

    organizationId

    Your organization identifier from the TrustPin dashboard.

    projectId

    Your project identifier from the TrustPin dashboard.

    publicKey

    A Base64-encoded public key used to verify the signature of the pinning payload.

    mode

    Controls how TrustPin handles domains not present in the pinning payload. Defaults to strict, which throws domainNotRegistered for unknown domains. Use permissive during development to allow unregistered domains instead.

    configurationURL

    A custom URL pointing to a signed JWS pinning payload. When set, this URL is tried first; if it fails, the SDK automatically falls through to the CDN chain (primary → mobile → backup). Pass nil (the default) to start directly from the CDN chain. Only set this for self-hosted or BYOK deployments.