Introduction

Before you begin, we recommend perusing the DeepAffex Developer Guide so that you have a basic understanding of NuraLogix's DeepAffex technologies and terminologies. Please be sure to read the first two chapters - Introduction and Getting Started.

The Web Measurement Service is designed for a simple use-case, explained in the scenario described below.

Scenario overview and concepts

The user visits your website hosting a single-page application (called "app" hereafter).

In the field, the app (which you develop) will manage:

  • user authentication
  • user consent
  • collecting subject's profile information and
  • collecting answers to subject's medical history questionnaire
  • obtaining a token and a refresh token from the DeepAffex API

Then, the app will redirect the user to WMS with the profile information that is necessary to take a measurement. On WMS, the user will complete a measurement and then WMS will redirect the user back to the app with the results of the measurement.

Information will be passed from the app to WMS through a specially crafted URL (the "call-in" URL). Since this URL will contain personal information, it will be encrypted so that only a specially configured WMS will be able to read the information. Additionally, for the app to link the measurements results to the user's profile, a unique Partner ID will also be passed along with the user profile details to WMS.

The measurement results will be passed back via a preconfigured "callback" URL.

Measurement Flow (Two-Way Encryption)

The details of the measurement flow described above are captured in the following diagram.

sequenceDiagram
    autonumber
    participant TPAPI as Third-party Cloud
    participant APP as Third-party app
    participant WMS as Web Measurement Service
    participant DFX as DeepAffex API

    APP->>+TPAPI: Request short-lived DFX_AUTH_TOKEN
    TPAPI->>+DFX: Request short-lived DFX_AUTH_TOKEN
    DFX-->>-TPAPI: Issue short-lived DFX_AUTH_TOKEN & DFX_REFRESH_TOKEN
    TPAPI-->>-APP: Return short-lived DFX_AUTH_TOKEN & DFX_REFRESH_TOKEN

    Note over APP: PROFILE_DATA { "identifier": [PartnerID], "height": 175, "weight": 75, ... }
    APP->>APP: Generate SESSION_ID
    APP->>TPAPI: Send PROFILE_DATA for encryption
    TPAPI->>TPAPI: Encrypt PROFILE_DATA with WMS public key
    TPAPI->>TPAPI: Sign PROFILE_DATA with client private key
    TPAPI-->>APP: Encrypted and signed PROFILE_DATA
    APP->>APP: Construct WMS call-in URL

    Note over APP,WMS: WMS_URL: https://awe.na-east.nuralogix.ai/c/[CONFIG_ID]/[PROFILE_DATA]/[DFX_AUTH_TOKEN]/[DFX_REFRESH_TOKEN]/[SESSION_ID]
    APP->>WMS: Call WMS at WMS Call-in URL
    WMS->>WMS: Verify with client public key
    WMS->>WMS: Decrypt PROFILE_DATA with WMS private key
    WMS->>DFX: Forward DFX_AUTH_TOKEN & DFX_REFRESH_TOKEN

    loop Until measurement is successful
        WMS->>DFX: Create Measurement
        DFX-->>WMS: Return MeasurementID
        WMS->>DFX: Subscribe Results
        activate DFX
        loop Until all payloads are sent
            WMS-)DFX: Add Data
            DFX--)WMS: Send Results
        end
        deactivate DFX
    end

    WMS->>WMS: Encrypt with client public key
    WMS->>WMS: Sign with WMS private key
    WMS-->>APP: Signed and encrypted measurement results
    APP->>APP: Verify with WMS public key
    APP->>APP: Decrypt results with client private key
    Note over WMS,APP: https://thirdparty.com/example/measurementComplete?results=<<encrypted and signed results>>

(Click here to open a larger version of this diagram in a new window)

Measurement Flow (Legacy Encryption)

The details of the measurement flow described above are captured in the following diagram.

sequenceDiagram
    autonumber
    participant TPAPI as Third-party Cloud
    participant APP as Third-party app
    participant WMS as Web Measurement Service
    participant DFX as DeepAffex API

    APP->>+TPAPI: Request short-lived DFX_AUTH_TOKEN
    TPAPI->>+DFX: Request short-lived DFX_AUTH_TOKEN
    DFX-->>-TPAPI: Issue short-lived DFX_AUTH_TOKEN & DFX_REFRESH_TOKEN
    TPAPI-->>-APP: Return short-lived DFX_AUTH_TOKEN & DFX_REFRESH_TOKEN

    Note over APP: PROFILE_DATA { "identifier": [PartnerID], "height": 175, "weight": 75, ... }
    APP->>APP: Generate SESSION_ID
    APP->>APP: Encrypt PROFILE_DATA with public key and construct WMS URL

    Note over APP,WMS: WMS_URL: https://awe.na-east.nuralogix.ai/c/[CONFIG_ID]/[PROFILE_DATA]/[DFX_AUTH_TOKEN]/[DFX_REFRESH_TOKEN]/[SESSION_ID]
    APP->>WMS: Call WMS at WMS_URL
    WMS->>WMS: Decrypt PROFILE_DATA with private key
    WMS->>DFX: Forward DFX_AUTH_TOKEN & DFX_REFRESH_TOKEN

    loop Until measurement is successful
        WMS->>DFX: Create Measurement
        DFX-->>WMS: Return MeasurementID
        WMS->>DFX: Subscribe Results
        activate DFX
        loop Until all payloads are sent
            WMS-)DFX: Add Data
            DFX--)WMS: Send Results
        end
        deactivate DFX
    end

    WMS-->>APP: Send MeasurementID and Results back through CALLBACK_URL (SESSION_ID in Results)
    Note over WMS,APP: https://thirdparty.com/example/measurementComplete?results=<<base64encoded>>

(Click here to open a larger version of this diagram in a new window)