Observe State and Send Data

  • A collector object that registers secure input fields (VGSTextField) and submits their data/files to a VGS Vault.

    Summary: Provides the orchestration layer for secure data collection: field registration, state observation, JSON/body construction, vault/network submission, tokenization/alias creation and file lifecycle management.

    Responsibilities:

    • Registers text fields automatically when a VGSConfiguration referencing this collector is assigned.
    • Observes editing state via observeFieldState (focused field) and observeStates (all fields snapshot).
    • Submits values with sendData / sendFile (closure, async/await, Combine variants).
    • Performs tokenization (tokenizeData) and alias creation (createAliases), plus card creation via CMP (createCard).
    • Cleans up attached files after successful upload (cleanFiles).

    Security:

    • Never logs or exposes raw sensitive values through public APIs.
    • Avoid adding PII or secrets to customHeaders & fieldName values; use them strictly for routing/auth metadata.
    • Internal storage is transient and cleared/replaced as input changes; persistence is the caller’s responsibility (and should only store aliases).

    Usage:

    1. Initialize with vault id & environment: let collector = VGSCollect(id: vaultId, environment: .sandbox).
    2. Create a VGSConfiguration per field and assign to each VGSTextField (registration happens automatically).
    3. Optionally set observation closures for validation/UI updates.
    4. Validate all required fields (state.isValid) before calling a submit method.
    5. Parse response aliases/tokens; discard raw user input from UI components.
    6. After file submission success, call cleanFiles().

    Invariants / Preconditions:

    • id must be a non-empty vault identifier.
    • All required fields should be valid before invoking submission APIs.
    • Only one logical file should be attached when calling sendFile.
    • For alias creation (createAliases), appropriate authentication must be provided in customHeaders.
    • UI access (field state collection) occurs on the main thread; ensure you invoke async calls from the main actor when updating UI.

    See also:

    See more

    Declaration

    Swift

    @MainActor
    public class VGSCollect
  • Organization vault environment.

    See more

    Declaration

    Swift

    public enum Environment : String
  • An object that describes VGSTextField state. State attributes are read-only.

    See more

    Declaration

    Swift

    @MainActor
    public class VGSTextFieldState
  • An object that describes VGSTextField state with configuration FieldType.ssn . State attributes are read-only.

    See more

    Declaration

    Swift

    @MainActor
    public class VGSSSNState : VGSTextFieldState
  • An object that describes VGSTextField state with configuration FieldType.cardNumber . State attributes are read-only.

    See more

    Declaration

    Swift

    @MainActor
    public class VGSCardState : VGSTextFieldState
  • A custom publisher that emits State of a given VGSTextField.

    See more

    Declaration

    Swift

    @available(iOS 13, *)
    @MainActor
    public struct VGSTextFieldStatePublisher : @preconcurrency Publisher
  • Response enum cases for SDK requests.

    See more

    Declaration

    Swift

    @frozen
    public enum VGSResponse
  • Tokenization response enum cases for SDK requests.

    See more

    Declaration

    Swift

    @frozen
    public enum VGSTokenizationResponse : @unchecked Sendable
  • Request options.

    See more

    Declaration

    Swift

    public struct VGSCollectRequestOptions
  • Key-value data type, usually used for response format.

    Declaration

    Swift

    public typealias JsonData = [String : Any]
  • HTTP request methods

    See more

    Declaration

    Swift

    public enum VGSCollectHTTPMethod : String
  • Key-value data type, used in http request headers.

    Declaration

    Swift

    public typealias HTTPHeaders = [String : String]