@superwall/runtime 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/base64.d.ts +1 -3
- package/dist/bridge/base64.js +1 -14
- package/dist/bridge/transport.js +2 -0
- package/package.json +2 -2
- package/src/bridge/base64.ts +1 -20
- package/src/bridge/transport.ts +1 -0
package/dist/bridge/base64.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const decodeBase64Utf8: (message: string) => string;
|
|
3
|
-
export declare const decodeIncomingMessages: (message: string) => TIncomingMessage[];
|
|
1
|
+
export { decodeBase64Utf8, decodeIncomingMessages } from "@superwall/protocol";
|
package/dist/bridge/base64.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const standard = input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
3
|
-
const remainder = standard.length % 4;
|
|
4
|
-
return remainder === 0 ? standard : standard + "=".repeat(4 - remainder);
|
|
5
|
-
};
|
|
6
|
-
export const decodeBase64Utf8 = (message) => {
|
|
7
|
-
const binary = atob(normalizeBase64(message));
|
|
8
|
-
return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
|
|
9
|
-
};
|
|
10
|
-
const isMessageLike = (entry) => typeof entry === "object" && entry !== null;
|
|
11
|
-
export const decodeIncomingMessages = (message) => {
|
|
12
|
-
const parsed = JSON.parse(decodeBase64Utf8(message));
|
|
13
|
-
return Array.isArray(parsed) ? parsed.filter(isMessageLike) : [];
|
|
14
|
-
};
|
|
1
|
+
export { decodeBase64Utf8, decodeIncomingMessages } from "@superwall/protocol";
|
package/dist/bridge/transport.js
CHANGED
|
@@ -8,6 +8,8 @@ export const detectRuntimeTransportKind = (options = {}) => {
|
|
|
8
8
|
return TransportKind.Android;
|
|
9
9
|
if (params.get("transport") === "editor")
|
|
10
10
|
return TransportKind.EditorIframe;
|
|
11
|
+
if (params.get("transport") === "web")
|
|
12
|
+
return TransportKind.WebSdk;
|
|
11
13
|
return TransportKind.WebKitPostMessage;
|
|
12
14
|
};
|
|
13
15
|
export const createRuntimeTransport = (kind = detectRuntimeTransportKind()) => buildTransport(kind);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superwall/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Framework-agnostic runtime for headless Superwall paywalls: bridge, session, products, localization, mock host.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paywall",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"clean": "rm -rf dist coverage"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@superwall/protocol": "1.
|
|
42
|
+
"@superwall/protocol": "1.6.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@superwall/host": "workspace:*",
|
package/src/bridge/base64.ts
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const normalizeBase64 = (input: string): string => {
|
|
4
|
-
const standard = input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
5
|
-
const remainder = standard.length % 4;
|
|
6
|
-
return remainder === 0 ? standard : standard + "=".repeat(4 - remainder);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const decodeBase64Utf8 = (message: string): string => {
|
|
10
|
-
const binary = atob(normalizeBase64(message));
|
|
11
|
-
return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const isMessageLike = (entry: unknown): entry is TIncomingMessage =>
|
|
15
|
-
typeof entry === "object" && entry !== null;
|
|
16
|
-
|
|
17
|
-
export const decodeIncomingMessages = (message: string): TIncomingMessage[] => {
|
|
18
|
-
const parsed: unknown = JSON.parse(decodeBase64Utf8(message));
|
|
19
|
-
return Array.isArray(parsed) ? parsed.filter(isMessageLike) : [];
|
|
20
|
-
};
|
|
1
|
+
export { decodeBase64Utf8, decodeIncomingMessages } from "@superwall/protocol";
|
package/src/bridge/transport.ts
CHANGED
|
@@ -13,6 +13,7 @@ export const detectRuntimeTransportKind = (
|
|
|
13
13
|
const params = new URLSearchParams(options.search ?? window.location.search);
|
|
14
14
|
if (params.get("platform") === "android") return TransportKind.Android;
|
|
15
15
|
if (params.get("transport") === "editor") return TransportKind.EditorIframe;
|
|
16
|
+
if (params.get("transport") === "web") return TransportKind.WebSdk;
|
|
16
17
|
return TransportKind.WebKitPostMessage;
|
|
17
18
|
};
|
|
18
19
|
|