diff --git a/README.md b/README.md index 2c6274b3..ed2479a6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The TurnkeySDK is built to support macOS, iOS, tvOS, watchOS, and visionOS, maki To integrate the TurnkeySDK into your Swift project, you need to add it as a dependency in your Package.swift file: ```swift -.package(url: "https://github.com/tkhq/swift-sdk", from: "1.1.0") +.package(url: "https://github.com/tkhq/swift-sdk", from: "1.2.0") ``` ## Usage diff --git a/Sources/Middleware/ProxyMiddleware.swift b/Sources/Middleware/ProxyMiddleware.swift index 8857b138..b19af892 100644 --- a/Sources/Middleware/ProxyMiddleware.swift +++ b/Sources/Middleware/ProxyMiddleware.swift @@ -21,11 +21,11 @@ extension ProxyMiddleware: ClientMiddleware { // Save the current full path of the request (baseUrl + request.path) let originalURL = baseURL.appendingPathComponent(request.path ?? "") - // Set the X-Forwarded-For header with the saved original request URL + // Set the X-Turnkey-Request-Url header with the saved original request URL var request = request - let xForwardedForHeader = HTTPField( - name: HTTPField.Name("X-Forwarded-For")!, value: originalURL.absoluteString) - request.headerFields.append(xForwardedForHeader) + let xTurnkeyRequestUrl = HTTPField( + name: HTTPField.Name("X-Turnkey-Request-Url")!, value: originalURL.absoluteString) + request.headerFields.append(xTurnkeyRequestUrl) // Remove the request path and just forward to the proxyBaseURL request.path = "" diff --git a/docs/proxy-middleware.md b/docs/proxy-middleware.md index afea20a2..e9a0c1b2 100644 --- a/docs/proxy-middleware.md +++ b/docs/proxy-middleware.md @@ -19,11 +19,9 @@ This setup is especially useful for operations like: - Wallet import/export - Sub-organization creation -## Important Notes +#### Request Header -#### X-Forwarded-For Header - -The middleware adds an `X-Forwarded-For` header to each request, which contains the original request URL. This is used to forward the request to Turnkey's backend. +The middleware adds an `X-Turnkey-Request-Url` header to each request, which contains the original request URL. This is used to forward the request to Turnkey's backend. Example implementation of a proxy server: @@ -35,10 +33,10 @@ app.use(express.json()); app.post('/api/turnkey-proxy', async (req, res) => { // The original request URL e.g. https://api.turnkey.com/public/v1/submit/email_auth - const turnkeyApiRequestURL = req.headers['x-forwarded-for']; + const turnkeyApiRequestURL = req.headers['X-Turnkey-Request-Url']; - // Remove the 'x-forwarded-for' header - delete req.headers['x-forwarded-for']; + // Remove the 'X-Turnkey-Request-Url' header + delete req.headers['X-Turnkey-Request-Url']; try { // Forward the request to the original URL @@ -71,4 +69,4 @@ It is crucial that the response from the developer's backend matches exactly wit ## Conclusion -While `ProxyMiddleware` is not required, it provides a convenient way to send requests on behalf of unauthenticated users looking to perform +While `ProxyMiddleware` is not required, it provides a convenient way to send requests on behalf of unauthenticated users looking to perform operations such as email authentication/recovery, wallet import/export, and sub-organization creation.