diff --git a/server/meta.jsx b/server/meta.jsx index 0e4ed4e4..a8b77366 100644 --- a/server/meta.jsx +++ b/server/meta.jsx @@ -24,8 +24,15 @@ import { } from "./constants"; import { constHas, entries } from "./util"; +type SDKAttributes = {| + [string]: string | boolean, +|}; + type SDKMeta = {| getSDKLoader: (options?: {| baseURL?: string, nonce?: string |}) => string, + getSDKScriptAttributes: () => SDKAttributes | void, + getSDKScriptUrl: () => string | void, + getSDKInlineScript: (baseURL?: string) => string | void, |}; const emailRegex = /^.+@.+$/; @@ -239,10 +246,6 @@ function validateSDKUrl(sdkUrl: string) { } } -type SDKAttributes = {| - [string]: string | boolean, -|}; - const getDefaultSDKAttributes = (): SDKAttributes => { // $FlowFixMe return {}; @@ -307,38 +310,8 @@ function sanitizeSDKUrl(sdkUrl: string): string { return sdkUrl; } -export function unpackSDKMeta(sdkMeta?: string): SDKMeta { - const { url, attrs } = sdkMeta - ? JSON.parse( - Buffer.from(decodeURIComponent(sdkMeta), "base64").toString("utf8") - ) - : DEFAULT_SDK_META; - - if (url) { - validateSDKUrl(url); - } - - const getSDKLoader = ({ - baseURL = DEFAULT_LEGACY_SDK_BASE_URL, - nonce = "", - } = {}) => { - if (url) { - const validAttrs = getSDKScriptAttributes(url, attrs); - - // $FlowFixMe - const allAttrs = { - nonce, - src: sanitizeSDKUrl(url), - ...validAttrs, - }; - - return (