@openlv/react-native 0.0.1-beta.3 → 0.0.1-beta.4
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/assert.js +3 -3
- package/dist/assert.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/polyfills.js +31 -33
- package/dist/polyfills.js.map +1 -1
- package/dist/provider.js +5 -5
- package/dist/provider.js.map +1 -1
- package/dist/webrtc.js +9 -9
- package/dist/webrtc.js.map +1 -1
- package/package.json +2 -2
package/dist/assert.js
CHANGED
|
@@ -4,8 +4,8 @@ export const assertOpenLVReady = (options = {}) => {
|
|
|
4
4
|
if (!g.__openlvRnGlobalsMounted) {
|
|
5
5
|
throw new Error("@openlv/react-native: OpenLVGlobals is not mounted. Add <OpenLVGlobals /> from '@openlv/react-native' somewhere in your app.");
|
|
6
6
|
}
|
|
7
|
-
if (
|
|
8
|
-
throw new
|
|
7
|
+
if (g.RTCPeerConnection === undefined) {
|
|
8
|
+
throw new TypeError("@openlv/react-native: WebRTC globals are missing (RTCPeerConnection). Ensure react-native-webrtc is available and OpenLVGlobals has mounted.");
|
|
9
9
|
}
|
|
10
10
|
const cryptoFromGlobal = g.crypto;
|
|
11
11
|
const cryptoFromWindow = g.window
|
|
@@ -14,7 +14,7 @@ export const assertOpenLVReady = (options = {}) => {
|
|
|
14
14
|
if (!crypto || typeof crypto.getRandomValues !== "function") {
|
|
15
15
|
throw new Error("@openlv/react-native: crypto.getRandomValues is missing. Ensure OpenLVGlobals is mounted (it loads react-native-get-random-values).");
|
|
16
16
|
}
|
|
17
|
-
if (options.requireCryptoReady &&
|
|
17
|
+
if (options.requireCryptoReady && crypto.subtle === undefined) {
|
|
18
18
|
throw new Error("@openlv/react-native: WebCrypto is not ready (crypto.subtle missing). Ensure OpenLVGlobals has mounted; the WebView crypto bridge may still be initializing.");
|
|
19
19
|
}
|
|
20
20
|
};
|
package/dist/assert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAgD,CAAC;AAMzE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAoC,EAAE,EAChC,EAAE;IACR,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAEtB,IAAI,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,8HAA8H,CAC/H,CAAC;IACJ,CAAC;IAED,IAAI,
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAgD,CAAC;AAMzE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAoC,EAAE,EAChC,EAAE;IACR,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAEtB,IAAI,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,8HAA8H,CAC/H,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,IAAI,SAAS,CACjB,8IAA8I,CAC/I,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAA6C,CAAC;IACzE,MAAM,gBAAgB,GAAI,CAAC,CAAC,MAA8C;QACxE,EAAE,MAA6C,CAAC;IAClD,MAAM,MAAM,GAAG,gBAAgB,IAAI,gBAAgB,CAAC;IAEpD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CACb,qIAAqI,CACtI,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,kBAAkB,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CACb,8JAA8J,CAC/J,CAAC;IACJ,CAAC;AACH,CAAC,CAAC","sourcesContent":["const getGlobal = () => globalThis as unknown as Record<string, unknown>;\n\nexport type AssertOpenLVReadyOptions = {\n requireCryptoReady?: boolean;\n};\n\nexport const assertOpenLVReady = (\n options: AssertOpenLVReadyOptions = {},\n): void => {\n const g = getGlobal();\n\n if (!g.__openlvRnGlobalsMounted) {\n throw new Error(\n \"@openlv/react-native: OpenLVGlobals is not mounted. Add <OpenLVGlobals /> from '@openlv/react-native' somewhere in your app.\",\n );\n }\n\n if (g.RTCPeerConnection === undefined) {\n throw new TypeError(\n \"@openlv/react-native: WebRTC globals are missing (RTCPeerConnection). Ensure react-native-webrtc is available and OpenLVGlobals has mounted.\",\n );\n }\n\n const cryptoFromGlobal = g.crypto as undefined | Record<string, unknown>;\n const cryptoFromWindow = (g.window as undefined | Record<string, unknown>)\n ?.crypto as undefined | Record<string, unknown>;\n const crypto = cryptoFromGlobal ?? cryptoFromWindow;\n\n if (!crypto || typeof crypto.getRandomValues !== \"function\") {\n throw new Error(\n \"@openlv/react-native: crypto.getRandomValues is missing. Ensure OpenLVGlobals is mounted (it loads react-native-get-random-values).\",\n );\n }\n\n if (options.requireCryptoReady && crypto.subtle === undefined) {\n throw new Error(\n \"@openlv/react-native: WebCrypto is not ready (crypto.subtle missing). Ensure OpenLVGlobals has mounted; the WebView crypto bridge may still be initializing.\",\n );\n }\n};\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,qBAAqB,EAErB,iCAAiC,EACjC,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAA2B,MAAM,eAAe,CAAC;AACvE,OAAO,EACL,sBAAsB,GA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E,cAAc;CACpB,CAAC;AAIX,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,GAAG,IAAgD,EACP,EAAE;IAC9C,iBAAiB,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAkB,CAAC;IAE/D,OAAO,GAAG,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,GAAG,IAAiD,EACP,EAAE;IAC/C,iBAAiB,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAkB,CAAC;IAE/D,OAAO,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { assertOpenLVReady } from \"./assert.js\";\n\nexport {\n ensureWebCryptoSubtle,\n type EnsureWebCryptoSubtleOptions,\n installOpenLVReactNativePolyfills,\n OpenLVCryptoPolyfill,\n} from \"./polyfills.js\";\nexport { OpenLVGlobals, type OpenLVGlobalsProps } from \"./provider.js\";\nexport {\n installWebRTCPolyfills,\n type InstallWebRTCPolyfillsOptions,\n} from \"./webrtc.js\";\nexport type {\n Session,\n SessionState,\n SessionStateObject,\n} from \"@openlv/session\";\n\nexport const SESSION_STATE = {\n CREATED: \"created\",\n SIGNALING: \"signaling\",\n READY: \"ready\",\n CONNECTED: \"connected\",\n DISCONNECTED: \"disconnected\",\n} as const;\n\ntype SessionModule = typeof import(\"@openlv/session\");\n\nexport const createSession = async (\n ...args: Parameters<SessionModule[\"createSession\"]>\n): ReturnType<SessionModule[\"createSession\"]> => {\n assertOpenLVReady({ requireCryptoReady: true });\n const mod = (await import(\"@openlv/session\")) as SessionModule;\n\n return mod.createSession(...args);\n};\n\nexport const connectSession = async (\n ...args: Parameters<SessionModule[\"connectSession\"]>\n): ReturnType<SessionModule[\"connectSession\"]> => {\n assertOpenLVReady({ requireCryptoReady: true });\n const mod = (await import(\"@openlv/session\")) as SessionModule;\n\n return mod.connectSession(...args);\n};\n"]}
|
package/dist/polyfills.js
CHANGED
|
@@ -22,20 +22,20 @@ const restoreUnifiedCrypto = () => {
|
|
|
22
22
|
// Restore getRandomValues if a previous value was captured before
|
|
23
23
|
// another polyfill replaced globalThis.crypto.
|
|
24
24
|
const backupGetRandomValues = g[CRYPTO_GRV_BACKUP_KEY];
|
|
25
|
-
if (typeof targetCrypto.getRandomValues !== "function"
|
|
26
|
-
typeof backupGetRandomValues === "function") {
|
|
25
|
+
if (typeof targetCrypto.getRandomValues !== "function"
|
|
26
|
+
&& typeof backupGetRandomValues === "function") {
|
|
27
27
|
targetCrypto.getRandomValues = backupGetRandomValues;
|
|
28
28
|
}
|
|
29
29
|
// If WebCrypto landed on window.crypto, copy `subtle` onto global crypto.
|
|
30
|
-
if (
|
|
31
|
-
windowCrypto
|
|
32
|
-
|
|
30
|
+
if (targetCrypto.subtle === undefined
|
|
31
|
+
&& windowCrypto
|
|
32
|
+
&& windowCrypto.subtle !== undefined) {
|
|
33
33
|
targetCrypto.subtle = windowCrypto.subtle;
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
const hasWebCryptoSubtle = () => {
|
|
37
37
|
const crypto = getCrypto();
|
|
38
|
-
return !!crypto &&
|
|
38
|
+
return !!crypto && crypto.subtle !== undefined;
|
|
39
39
|
};
|
|
40
40
|
const hasGetRandomValues = () => {
|
|
41
41
|
const crypto = getCrypto();
|
|
@@ -43,13 +43,14 @@ const hasGetRandomValues = () => {
|
|
|
43
43
|
};
|
|
44
44
|
const ensureAtobBtoa = () => {
|
|
45
45
|
const g = getGlobal();
|
|
46
|
-
if (
|
|
46
|
+
if (g.btoa === undefined) {
|
|
47
47
|
g.btoa = (input) => base64Encode(input);
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (g.atob === undefined) {
|
|
50
50
|
g.atob = (input) => base64Decode(input);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
const toHex = (b) => b.toString(16).padStart(2, "0");
|
|
53
54
|
const ensureCryptoRandomUUID = () => {
|
|
54
55
|
const g = getGlobal();
|
|
55
56
|
restoreUnifiedCrypto();
|
|
@@ -57,44 +58,43 @@ const ensureCryptoRandomUUID = () => {
|
|
|
57
58
|
if (typeof crypto.randomUUID === "function")
|
|
58
59
|
return;
|
|
59
60
|
if (typeof crypto.getRandomValues !== "function") {
|
|
60
|
-
throw new
|
|
61
|
+
throw new TypeError("@openlv/react-native: crypto.getRandomValues is missing. Add <OpenLVGlobals /> from '@openlv/react-native' somewhere in your app.");
|
|
61
62
|
}
|
|
62
63
|
crypto.randomUUID = () => {
|
|
63
64
|
const bytes = new Uint8Array(16);
|
|
64
65
|
crypto.getRandomValues(bytes);
|
|
65
66
|
// RFC 4122 v4
|
|
66
|
-
bytes[6] = (bytes[6] &
|
|
67
|
-
bytes[8] = (bytes[8] &
|
|
68
|
-
const toHex = (b) => b.toString(16).padStart(2, "0");
|
|
67
|
+
bytes[6] = (bytes[6] & 0x0F) | 0x40;
|
|
68
|
+
bytes[8] = (bytes[8] & 0x3F) | 0x80;
|
|
69
69
|
const hex = Array.from(bytes, toHex);
|
|
70
|
-
return (hex.slice(0, 4).join("")
|
|
71
|
-
"-"
|
|
72
|
-
hex.slice(4, 6).join("")
|
|
73
|
-
"-"
|
|
74
|
-
hex.slice(6, 8).join("")
|
|
75
|
-
"-"
|
|
76
|
-
hex.slice(8, 10).join("")
|
|
77
|
-
"-"
|
|
78
|
-
hex.slice(10, 16).join(""));
|
|
70
|
+
return (hex.slice(0, 4).join("")
|
|
71
|
+
+ "-"
|
|
72
|
+
+ hex.slice(4, 6).join("")
|
|
73
|
+
+ "-"
|
|
74
|
+
+ hex.slice(6, 8).join("")
|
|
75
|
+
+ "-"
|
|
76
|
+
+ hex.slice(8, 10).join("")
|
|
77
|
+
+ "-"
|
|
78
|
+
+ hex.slice(10, 16).join(""));
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
81
|
const ensureMinimumGlobalsForSession = () => {
|
|
82
82
|
const g = getGlobal();
|
|
83
|
-
if (
|
|
84
|
-
throw new
|
|
83
|
+
if (g.URL === undefined) {
|
|
84
|
+
throw new TypeError("@openlv/react-native: global URL is missing. Install a URL polyfill (e.g. 'react-native-url-polyfill') or use an environment that provides URL.");
|
|
85
85
|
}
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
throw new
|
|
86
|
+
if (g.TextEncoder === undefined
|
|
87
|
+
|| g.TextDecoder === undefined) {
|
|
88
|
+
throw new TypeError("@openlv/react-native: TextEncoder/TextDecoder are missing. Use Hermes/modern RN, or add a polyfill (e.g. 'fast-text-encoding').");
|
|
89
89
|
}
|
|
90
90
|
ensureAtobBtoa();
|
|
91
91
|
// Capture getRandomValues once, so we can restore it later if another
|
|
92
92
|
// polyfill overwrites `globalThis.crypto`.
|
|
93
93
|
restoreUnifiedCrypto();
|
|
94
94
|
const capturedCrypto = g.crypto;
|
|
95
|
-
if (typeof g[CRYPTO_GRV_BACKUP_KEY] !== "function"
|
|
96
|
-
capturedCrypto
|
|
97
|
-
typeof capturedCrypto.getRandomValues === "function") {
|
|
95
|
+
if (typeof g[CRYPTO_GRV_BACKUP_KEY] !== "function"
|
|
96
|
+
&& capturedCrypto
|
|
97
|
+
&& typeof capturedCrypto.getRandomValues === "function") {
|
|
98
98
|
g[CRYPTO_GRV_BACKUP_KEY] = capturedCrypto.getRandomValues;
|
|
99
99
|
}
|
|
100
100
|
if (!hasGetRandomValues()) {
|
|
@@ -111,7 +111,7 @@ export const ensureWebCryptoSubtle = async (options = {}) => {
|
|
|
111
111
|
}
|
|
112
112
|
const start = Date.now();
|
|
113
113
|
while (Date.now() - start < timeoutMs) {
|
|
114
|
-
await new Promise(
|
|
114
|
+
await new Promise(r => setTimeout(r, pollIntervalMs));
|
|
115
115
|
if (hasWebCryptoSubtle()) {
|
|
116
116
|
restoreUnifiedCrypto();
|
|
117
117
|
return;
|
|
@@ -123,7 +123,5 @@ export const installOpenLVReactNativePolyfills = () => {
|
|
|
123
123
|
installWebRTCPolyfills();
|
|
124
124
|
ensureMinimumGlobalsForSession();
|
|
125
125
|
};
|
|
126
|
-
export const OpenLVCryptoPolyfill = (props = {}) =>
|
|
127
|
-
return React.createElement(PolyfillCrypto, props);
|
|
128
|
-
};
|
|
126
|
+
export const OpenLVCryptoPolyfill = (props = {}) => React.createElement(PolyfillCrypto, props);
|
|
129
127
|
//# sourceMappingURL=polyfills.js.map
|
package/dist/polyfills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,cAAc,MAAM,6BAA6B,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAOrD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAgD,CAAC;AAEzE,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAEtB,MAAM,WAAW,GAAG,CAAC,CAAC,MAA6C,CAAC;IAEpE,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,WAAW,EAAE,MAAM,CAEZ,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAChC,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAEtB,MAAM,WAAW,GAAG,CAAC,CAAC,MAA6C,CAAC;IACpE,MAAM,YAAY,GAAG,W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K,CACb,8QAA8Q,CAC/Q,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAS,EAAE;IAC1D,sBAAsB,EAAE,CAAC;IACzB,8BAA8B,EAAE,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,QAAiC,EAAE,EACf,EAAE,CAAC,KAAK,CAAC,aAAa,CAC1C,cAA8D,EAC9D,KAAK,CACN,CAAC","sourcesContent":["import { decode as base64Decode, encode as base64Encode } from \"base-64\";\nimport * as React from \"react\";\nimport PolyfillCrypto from \"react-native-webview-crypto\";\n\nimport { installWebRTCPolyfills } from \"./webrtc.js\";\n\nexport type EnsureWebCryptoSubtleOptions = {\n timeoutMs?: number;\n pollIntervalMs?: number;\n};\n\nconst getGlobal = () => globalThis as unknown as Record<string, unknown>;\n\nconst CRYPTO_GRV_BACKUP_KEY = \"__openlvRnGetRandomValues\";\n\nconst getCrypto = () => {\n const g = getGlobal();\n\n const maybeWindow = g.window as undefined | Record<string, unknown>;\n\n return (g.crypto ?? maybeWindow?.crypto) as\n | undefined\n | Record<string, unknown>;\n};\n\nconst restoreUnifiedCrypto = () => {\n const g = getGlobal();\n\n const maybeWindow = g.window as undefined | Record<string, unknown>;\n const windowCrypto = maybeWindow?.crypto as\n | undefined\n | Record<string, unknown>;\n\n const globalCrypto = g.crypto as undefined | Record<string, unknown>;\n\n // Ensure `globalThis.crypto` exists (many libs only look here).\n if (!globalCrypto) {\n g.crypto = {};\n }\n\n const targetCrypto = g.crypto as Record<string, unknown>;\n\n // Restore getRandomValues if a previous value was captured before\n // another polyfill replaced globalThis.crypto.\n const backupGetRandomValues = g[CRYPTO_GRV_BACKUP_KEY];\n\n if (\n typeof targetCrypto.getRandomValues !== \"function\"\n && typeof backupGetRandomValues === \"function\"\n ) {\n targetCrypto.getRandomValues = backupGetRandomValues;\n }\n\n // If WebCrypto landed on window.crypto, copy `subtle` onto global crypto.\n if (\n targetCrypto.subtle === undefined\n && windowCrypto\n && windowCrypto.subtle !== undefined\n ) {\n targetCrypto.subtle = windowCrypto.subtle;\n }\n};\n\nconst hasWebCryptoSubtle = (): boolean => {\n const crypto = getCrypto();\n\n return !!crypto && crypto.subtle !== undefined;\n};\n\nconst hasGetRandomValues = (): boolean => {\n const crypto = getCrypto();\n\n return !!crypto && typeof crypto.getRandomValues === \"function\";\n};\n\nconst ensureAtobBtoa = () => {\n const g = getGlobal();\n\n if (g.btoa === undefined) {\n g.btoa = (input: string) => base64Encode(input);\n }\n\n if (g.atob === undefined) {\n g.atob = (input: string) => base64Decode(input);\n }\n};\n\nconst toHex = (b: number) => b.toString(16).padStart(2, \"0\");\nconst ensureCryptoRandomUUID = () => {\n const g = getGlobal();\n\n restoreUnifiedCrypto();\n\n const crypto = g.crypto as Record<string, unknown>;\n\n if (typeof crypto.randomUUID === \"function\") return;\n\n if (typeof crypto.getRandomValues !== \"function\") {\n throw new TypeError(\n \"@openlv/react-native: crypto.getRandomValues is missing. Add <OpenLVGlobals /> from '@openlv/react-native' somewhere in your app.\",\n );\n }\n\n crypto.randomUUID = () => {\n const bytes = new Uint8Array(16);\n\n (crypto.getRandomValues as (a: Uint8Array) => Uint8Array)(bytes);\n\n // RFC 4122 v4\n bytes[6] = (bytes[6] & 0x0F) | 0x40;\n bytes[8] = (bytes[8] & 0x3F) | 0x80;\n\n const hex = Array.from(bytes, toHex);\n\n return (\n hex.slice(0, 4).join(\"\")\n + \"-\"\n + hex.slice(4, 6).join(\"\")\n + \"-\"\n + hex.slice(6, 8).join(\"\")\n + \"-\"\n + hex.slice(8, 10).join(\"\")\n + \"-\"\n + hex.slice(10, 16).join(\"\")\n );\n };\n};\n\nconst ensureMinimumGlobalsForSession = () => {\n const g = getGlobal();\n\n if (g.URL === undefined) {\n throw new TypeError(\n \"@openlv/react-native: global URL is missing. Install a URL polyfill (e.g. 'react-native-url-polyfill') or use an environment that provides URL.\",\n );\n }\n\n if (\n g.TextEncoder === undefined\n || g.TextDecoder === undefined\n ) {\n throw new TypeError(\n \"@openlv/react-native: TextEncoder/TextDecoder are missing. Use Hermes/modern RN, or add a polyfill (e.g. 'fast-text-encoding').\",\n );\n }\n\n ensureAtobBtoa();\n\n // Capture getRandomValues once, so we can restore it later if another\n // polyfill overwrites `globalThis.crypto`.\n restoreUnifiedCrypto();\n const capturedCrypto = g.crypto as undefined | Record<string, unknown>;\n\n if (\n typeof g[CRYPTO_GRV_BACKUP_KEY] !== \"function\"\n && capturedCrypto\n && typeof capturedCrypto.getRandomValues === \"function\"\n ) {\n g[CRYPTO_GRV_BACKUP_KEY] = capturedCrypto.getRandomValues;\n }\n\n if (!hasGetRandomValues()) {\n throw new Error(\n \"@openlv/react-native: crypto.getRandomValues is missing. Add <OpenLVGlobals /> from '@openlv/react-native' somewhere in your app.\",\n );\n }\n\n ensureCryptoRandomUUID();\n};\n\nexport const ensureWebCryptoSubtle = async (\n options: EnsureWebCryptoSubtleOptions = {},\n): Promise<void> => {\n const timeoutMs = options.timeoutMs ?? 15_000;\n const pollIntervalMs = options.pollIntervalMs ?? 25;\n\n if (hasWebCryptoSubtle()) {\n restoreUnifiedCrypto();\n\n return;\n }\n\n const start = Date.now();\n\n while (Date.now() - start < timeoutMs) {\n await new Promise(r => setTimeout(r, pollIntervalMs));\n\n if (hasWebCryptoSubtle()) {\n restoreUnifiedCrypto();\n\n return;\n }\n }\n\n throw new Error(\n \"@openlv/react-native: WebCrypto is not ready (crypto.subtle missing). Add <OpenLVGlobals /> from '@openlv/react-native' somewhere in your app (or render <OpenLVCryptoPolyfill /> manually) and ensure 'react-native-webview' + 'react-native-webview-crypto' are installed.\",\n );\n};\n\nexport const installOpenLVReactNativePolyfills = (): void => {\n installWebRTCPolyfills();\n ensureMinimumGlobalsForSession();\n};\n\nexport const OpenLVCryptoPolyfill = (\n props: Record<string, unknown> = {},\n): React.ReactElement => React.createElement(\n PolyfillCrypto as React.ComponentType<Record<string, unknown>>,\n props,\n);\n"]}
|
package/dist/provider.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as React from "react";
|
|
|
6
6
|
import { ensureWebCryptoSubtle, installOpenLVReactNativePolyfills, OpenLVCryptoPolyfill, } from "./polyfills.js";
|
|
7
7
|
const getGlobal = () => globalThis;
|
|
8
8
|
export const OpenLVGlobals = ({ cryptoTimeoutMs, } = {}) => {
|
|
9
|
-
const [error, setError] = React.useState(
|
|
9
|
+
const [error, setError] = React.useState();
|
|
10
10
|
React.useEffect(() => {
|
|
11
11
|
try {
|
|
12
12
|
const g = getGlobal();
|
|
@@ -16,8 +16,8 @@ export const OpenLVGlobals = ({ cryptoTimeoutMs, } = {}) => {
|
|
|
16
16
|
installOpenLVReactNativePolyfills();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
catch (
|
|
20
|
-
setError(
|
|
19
|
+
catch (error_) {
|
|
20
|
+
setError(error_);
|
|
21
21
|
}
|
|
22
22
|
}, []);
|
|
23
23
|
// WebCrypto is delivered by the WebView polyfill, which becomes available
|
|
@@ -30,9 +30,9 @@ export const OpenLVGlobals = ({ cryptoTimeoutMs, } = {}) => {
|
|
|
30
30
|
const g = getGlobal();
|
|
31
31
|
g.__openlvRnCryptoReady = true;
|
|
32
32
|
}
|
|
33
|
-
catch (
|
|
33
|
+
catch (error_) {
|
|
34
34
|
if (!cancelled)
|
|
35
|
-
setError(
|
|
35
|
+
setError(error_);
|
|
36
36
|
}
|
|
37
37
|
})();
|
|
38
38
|
return () => {
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;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KAAK,IAAI,EAAE;YACV,IAAI,CAAC;gBACH,MAAM,qBAAqB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;gBAE5D,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;gBAEtB,CAAC,CAAC,qBAAqB,GAAG,IAAI,CAAC;YACjC,CAAC;YACD,OAAO,MAAM,EAAE,CAAC;gBACd,IAAI,CAAC,SAAS;oBAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEvE,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,KAAC,oBAAoB,KAAG,CAAC;AAClC,CAAC,CAAC","sourcesContent":["import \"react-native-url-polyfill/auto\";\nimport \"fast-text-encoding\";\nimport \"react-native-get-random-values\";\n\nimport * as React from \"react\";\n\nimport {\n ensureWebCryptoSubtle,\n installOpenLVReactNativePolyfills,\n OpenLVCryptoPolyfill,\n} from \"./polyfills.js\";\n\nexport type OpenLVGlobalsProps = {\n cryptoTimeoutMs?: number;\n};\n\nconst getGlobal = () => globalThis as unknown as Record<string, unknown>;\n\nexport const OpenLVGlobals = ({\n cryptoTimeoutMs,\n}: OpenLVGlobalsProps = {}): React.ReactElement => {\n const [error, setError] = React.useState<unknown>();\n\n React.useEffect(() => {\n try {\n const g = getGlobal();\n\n g.__openlvRnGlobalsMounted = true;\n\n if (!g.__openlvRnPolyfillsInstalled) {\n g.__openlvRnPolyfillsInstalled = true;\n\n installOpenLVReactNativePolyfills();\n }\n }\n catch (error_) {\n setError(error_);\n }\n }, []);\n\n // WebCrypto is delivered by the WebView polyfill, which becomes available\n // asynchronously after the component mounts.\n React.useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n await ensureWebCryptoSubtle({ timeoutMs: cryptoTimeoutMs });\n\n const g = getGlobal();\n\n g.__openlvRnCryptoReady = true;\n }\n catch (error_) {\n if (!cancelled) setError(error_);\n }\n })();\n\n return () => {\n cancelled = true;\n };\n }, [cryptoTimeoutMs]);\n\n if (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n throw new Error(`OpenLVGlobals initialization failed: ${message}`);\n }\n\n return <OpenLVCryptoPolyfill />;\n};\n"]}
|
package/dist/webrtc.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as RNWebRTC from "react-native-webrtc";
|
|
|
2
2
|
const getGlobal = () => globalThis;
|
|
3
3
|
export const installWebRTCPolyfills = (options = {}) => {
|
|
4
4
|
const g = getGlobal();
|
|
5
|
-
if (!options.force &&
|
|
5
|
+
if (!options.force && g.RTCPeerConnection !== undefined) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
const exports = RNWebRTC;
|
|
@@ -10,21 +10,21 @@ export const installWebRTCPolyfills = (options = {}) => {
|
|
|
10
10
|
exports.registerGlobals();
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
|
-
if (
|
|
14
|
-
|
|
13
|
+
if (g.RTCPeerConnection === undefined
|
|
14
|
+
&& exports.RTCPeerConnection !== undefined) {
|
|
15
15
|
g.RTCPeerConnection = exports.RTCPeerConnection;
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if (g.RTCSessionDescription === undefined
|
|
18
|
+
&& exports.RTCSessionDescription !== undefined) {
|
|
19
19
|
g.RTCSessionDescription = exports.RTCSessionDescription;
|
|
20
20
|
}
|
|
21
|
-
if (
|
|
22
|
-
|
|
21
|
+
if (g.RTCIceCandidate === undefined
|
|
22
|
+
&& exports.RTCIceCandidate !== undefined) {
|
|
23
23
|
g.RTCIceCandidate = exports.RTCIceCandidate;
|
|
24
24
|
}
|
|
25
|
-
if (
|
|
25
|
+
if (exports.mediaDevices !== undefined) {
|
|
26
26
|
const nav = (g.navigator ?? {});
|
|
27
|
-
if (
|
|
27
|
+
if (nav.mediaDevices === undefined) {
|
|
28
28
|
nav.mediaDevices = exports.mediaDevices;
|
|
29
29
|
}
|
|
30
30
|
g.navigator = nav;
|
package/dist/webrtc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webrtc.js","sourceRoot":"","sources":["../src/webrtc.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAUhD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAgD,CAAC;AAEzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,UAAyC,EAAE,EAClC,EAAE;IACX,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAEtB,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"webrtc.js","sourceRoot":"","sources":["../src/webrtc.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAUhD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAgD,CAAC;AAEzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,UAAyC,EAAE,EAClC,EAAE;IACX,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IAEtB,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,QAAsC,CAAC;IAEvD,IAAI,OAAO,OAAO,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAClD,OAAO,CAAC,eAAe,EAAE,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,CAAC,CAAC,iBAAiB,KAAK,SAAS;WAC9B,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAC1C,CAAC;QACD,CAAC,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAClD,CAAC;IAED,IACE,CAAC,CAAC,qBAAqB,KAAK,SAAS;WAClC,OAAO,CAAC,qBAAqB,KAAK,SAAS,EAC9C,CAAC;QACD,CAAC,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAC1D,CAAC;IAED,IACE,CAAC,CAAC,eAAe,KAAK,SAAS;WAC5B,OAAO,CAAC,eAAe,KAAK,SAAS,EACxC,CAAC;QACD,CAAC,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAA4B,CAAC;QAE3D,IAAI,GAAG,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACnC,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1C,CAAC;QAED,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["export type InstallWebRTCPolyfillsOptions = {\n force?: boolean;\n};\n\nimport * as RNWebRTC from \"react-native-webrtc\";\n\ntype RNWebRTCExports = {\n registerGlobals?: () => void;\n RTCPeerConnection?: unknown;\n RTCSessionDescription?: unknown;\n RTCIceCandidate?: unknown;\n mediaDevices?: unknown;\n};\n\nconst getGlobal = () => globalThis as unknown as Record<string, unknown>;\n\nexport const installWebRTCPolyfills = (\n options: InstallWebRTCPolyfillsOptions = {},\n): boolean => {\n const g = getGlobal();\n\n if (!options.force && g.RTCPeerConnection !== undefined) {\n return false;\n }\n\n const exports = RNWebRTC as unknown as RNWebRTCExports;\n\n if (typeof exports.registerGlobals === \"function\") {\n exports.registerGlobals();\n\n return true;\n }\n\n if (\n g.RTCPeerConnection === undefined\n && exports.RTCPeerConnection !== undefined\n ) {\n g.RTCPeerConnection = exports.RTCPeerConnection;\n }\n\n if (\n g.RTCSessionDescription === undefined\n && exports.RTCSessionDescription !== undefined\n ) {\n g.RTCSessionDescription = exports.RTCSessionDescription;\n }\n\n if (\n g.RTCIceCandidate === undefined\n && exports.RTCIceCandidate !== undefined\n ) {\n g.RTCIceCandidate = exports.RTCIceCandidate;\n }\n\n if (exports.mediaDevices !== undefined) {\n const nav = (g.navigator ?? {}) as Record<string, unknown>;\n\n if (nav.mediaDevices === undefined) {\n nav.mediaDevices = exports.mediaDevices;\n }\n\n g.navigator = nav;\n }\n\n return true;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openlv/react-native",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.4",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"open-lavatory",
|
|
6
6
|
"react-native"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"react-native-webrtc": "^124.0.6",
|
|
55
55
|
"react-native-webview": "^13.15.0",
|
|
56
56
|
"react-native-webview-crypto": "^0.0.28",
|
|
57
|
-
"@openlv/session": "0.0.1-beta.
|
|
57
|
+
"@openlv/session": "0.0.1-beta.11"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": ">=18",
|