diff --git a/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/BraveSkusScriptHandler.swift b/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/BraveSkusScriptHandler.swift index 2d7bd9109f31..572b32e9659a 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/BraveSkusScriptHandler.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Paged/BraveSkusScriptHandler.swift @@ -38,7 +38,8 @@ class BraveSkusScriptHandler: TabContentScript { return WKUserScript( source: secureScript( - handlerNamesMap: ["$": messageHandlerName], + handlerNamesMap: ["$": messageHandlerName] + .merging(Method.map, uniquingKeysWith: { $1 }), securityToken: scriptId, script: script ), @@ -68,7 +69,7 @@ class BraveSkusScriptHandler: TabContentScript { return } - guard let requestedMethod = response["method_id"] as? Int, + guard let requestedMethod = response["method_id"] as? String, let method = Method(rawValue: requestedMethod) else { Logger.module.error("Brave skus request with invalid method-id") @@ -139,12 +140,12 @@ class BraveSkusScriptHandler: TabContentScript { } extension BraveSkusScriptHandler { - private enum Method: Int, CaseIterable { - case refreshOrder = 1 - case fetchOrderCredentials = 2 - case prepareCredentialsPresentation = 3 - case credentialsSummary = 4 - case setLocalStorageReceipt = 5 + private enum Method: String, CaseIterable { + case refreshOrder + case fetchOrderCredentials + case prepareCredentialsPresentation + case credentialsSummary + case setLocalStorageReceipt static var map: [String: String] { var jsDict = [String: String]() diff --git a/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/DomainSpecific/Paged/BraveSkusScript.js b/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/DomainSpecific/Paged/BraveSkusScript.js index 76778062066b..3794edfbda27 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/DomainSpecific/Paged/BraveSkusScript.js +++ b/ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/DomainSpecific/Paged/BraveSkusScript.js @@ -19,7 +19,7 @@ window.__firefox__.includeOnce("BraveSkusScript", function($) { } // Request VPN Receipt - sendMessage($, { "message": "vpn" }) + sendMessage('$', { "message": "vpn" }) .then(function(jsonData) { if (jsonData) { window.localStorage.setItem(jsonData["key"], jsonData["data"]); @@ -31,7 +31,7 @@ window.__firefox__.includeOnce("BraveSkusScript", function($) { }); // Request Leo Receipt - sendMessage($, { "message": "leo" }) + sendMessage('$', { "message": "leo" }) .then(function(jsonData) { if (jsonData) { window.localStorage.setItem("braveLeo.orderId", jsonData["braveLeo.orderId"]) @@ -49,19 +49,19 @@ window.__firefox__.includeOnce("BraveSkusScript", function($) { writable: false, value: { refresh_order(orderId) { - return sendMessage($, { orderId }); + return sendMessage('$', { orderId }); }, fetch_order_credentials(orderId) { - return sendMessage($, { orderId }); + return sendMessage('$', { orderId }); }, prepare_credentials_presentation(domain, path) { - return sendMessage($, { domain, path }); + return sendMessage('$', { domain, path }); }, credential_summary(domain) { - return sendMessage($, { domain }); + return sendMessage('$', { domain }); } } });