From 6b301f05c7b4fec37e11803cedaba0d3513d1da6 Mon Sep 17 00:00:00 2001 From: Pramod Prajapati Date: Tue, 24 Sep 2024 21:56:26 +0530 Subject: [PATCH] fix(predictions): region handling for creating correct streaming endpoint from region (#3880) * Added region handling for creating correct streaming endpoint * Added region handling for creating correct streaming endpoint --------- Co-authored-by: Pramod Prajapati --- .../Liveness/SPI/LivenessStreamingURL.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessStreamingURL.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessStreamingURL.swift index 93ee45ad3c..15c25593d2 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessStreamingURL.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessStreamingURL.swift @@ -7,8 +7,20 @@ import Foundation +private let isoPartitionBaseDomain: String = "csp.hci.ic.gov" +private let defaultBaseDomain: String = "amazonaws.com" + func streamingSessionURL(for region: String) throws -> URL { - let urlString = "wss://streaming-rekognition.\(region).amazonaws.com/start-face-liveness-session-websocket" + + // Determine the base domain based on the region + let baseDomain: String + if region.lowercased().starts(with: "us-isof") { + baseDomain = isoPartitionBaseDomain + } else { + baseDomain = defaultBaseDomain + } + + let urlString = "wss://streaming-rekognition.\(region).\(baseDomain)/start-face-liveness-session-websocket" guard let url = URL(string: urlString) else { throw FaceLivenessSessionError.invalidRegion }